diff options
author | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-01-06 15:58:59 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-03-19 15:32:56 +0100 |
commit | 3e3461dbf9a6231c922b7fc809226763c9a06e55 (patch) | |
tree | 4b79674ab0e684699af9822b0d39adf265232dab | |
parent | 645d87ec7f886136f58991bbba08c77fb76aa9a1 (diff) |
One LineListBox to rule them all: started improving column sep line
-rw-r--r-- | sw/inc/fmtclds.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/colmgr.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/column.cxx | 92 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/column.hrc | 6 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/column.src | 53 | ||||
-rw-r--r-- | sw/source/ui/inc/colmgr.hxx | 8 | ||||
-rw-r--r-- | sw/source/ui/inc/column.hxx | 4 |
9 files changed, 146 insertions, 39 deletions
diff --git a/sw/inc/fmtclds.hxx b/sw/inc/fmtclds.hxx index e5dc2db886..e54fcc31f5 100644 --- a/sw/inc/fmtclds.hxx +++ b/sw/inc/fmtclds.hxx @@ -28,6 +28,7 @@ #ifndef _FMTCLDS_HXX #define _FMTCLDS_HXX +#include <editeng/borderline.hxx> #include <tools/color.hxx> #include <svl/poolitem.hxx> #include "swdllapi.h" @@ -77,8 +78,9 @@ enum SwColLineAdj class SW_DLLPUBLIC SwFmtCol : public SfxPoolItem { + SvxBorderStyle eLineStyle; //style of the separator line sal_uLong nLineWidth; // Width of the separator line. - Color aLineColor; //color of the separator line + Color aLineColor; // Color of the separator line. sal_uInt16 nLineHeight; // Percentile height of lines. // (Based on height of columns including UL). @@ -119,6 +121,7 @@ public: SwColumns &GetColumns() { return aColumns; } sal_uInt16 GetNumCols() const { return aColumns.Count(); } + SvxBorderStyle GetLineStyle() const { return eLineStyle;} sal_uLong GetLineWidth() const { return nLineWidth;} const Color& GetLineColor() const { return aLineColor;} @@ -132,6 +135,7 @@ public: // Return smallest width if bMin is true. sal_uInt16 GetGutterWidth( sal_Bool bMin = sal_False ) const; + void SetLineStyle(SvxBorderStyle eStyle) { eLineStyle = eStyle;} void SetLineWidth(sal_uLong nLWidth) { nLineWidth = nLWidth;} void SetLineColor(const Color& rCol ) { aLineColor = rCol;} void SetLineHeight( sal_uInt8 nNew ) { nLineHeight = nNew; } diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 401a146cac..e4fc765654 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -777,6 +777,7 @@ sal_Bool SwColumn::operator==( const SwColumn &rCmp ) SwFmtCol::SwFmtCol( const SwFmtCol& rCpy ) : SfxPoolItem( RES_COL ), + eLineStyle( rCpy.eLineStyle ), nLineWidth( rCpy.nLineWidth), aLineColor( rCpy.aLineColor), nLineHeight( rCpy.GetLineHeight() ), @@ -796,6 +797,7 @@ SwFmtCol::~SwFmtCol() {} SwFmtCol& SwFmtCol::operator=( const SwFmtCol& rCpy ) { + eLineStyle = rCpy.eLineStyle; nLineWidth = rCpy.nLineWidth; aLineColor = rCpy.aLineColor; nLineHeight = rCpy.GetLineHeight(); @@ -815,6 +817,7 @@ SwFmtCol& SwFmtCol::operator=( const SwFmtCol& rCpy ) SwFmtCol::SwFmtCol() : SfxPoolItem( RES_COL ), + eLineStyle( NO_STYLE ), nLineWidth(0), nLineHeight( 100 ), eAdj( COLADJ_NONE ), @@ -827,7 +830,8 @@ int SwFmtCol::operator==( const SfxPoolItem& rAttr ) const { OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); const SwFmtCol &rCmp = (const SwFmtCol&)rAttr; - if( !(nLineWidth == rCmp.nLineWidth && + if( !(eLineStyle == rCmp.eLineStyle && + nLineWidth == rCmp.nLineWidth && aLineColor == rCmp.aLineColor && nLineHeight == rCmp.GetLineHeight() && eAdj == rCmp.GetLineAdj() && diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 24caae70b0..bbb02a6369 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -4858,7 +4858,8 @@ void SwLayoutFrm::PaintColLines( const SwRect &rRect, const SwFmtCol &rFmtCol, (aLineRect.*fnRect->fnSetPosX) ( (pCol->Frm().*fnGetX)() - nPenHalf ); if ( aRect.IsOver( aLineRect ) ) - PaintBorderLine( aRect, aLineRect , pPage, &rFmtCol.GetLineColor() ); + PaintBorderLine( aRect, aLineRect , pPage, &rFmtCol.GetLineColor(), + rFmtCol.GetLineStyle() ); pCol = pCol->GetNext(); } } diff --git a/sw/source/ui/frmdlg/colmgr.cxx b/sw/source/ui/frmdlg/colmgr.cxx index 503a7f6840..a0209ca885 100644 --- a/sw/source/ui/frmdlg/colmgr.cxx +++ b/sw/source/ui/frmdlg/colmgr.cxx @@ -155,4 +155,11 @@ SwColMgr::~SwColMgr() { } +void SwColMgr::SetLineWidthAndColor(SvxBorderStyle eStyle, sal_uLong nLWidth, const Color& rCol) +{ + aFmtCol.SetLineStyle(eStyle); + aFmtCol.SetLineWidth(nLWidth); + aFmtCol.SetLineColor(rCol); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index 861a9ab31b..a73e8e8da4 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -36,7 +36,11 @@ #include "column.hxx" #include "hintids.hxx" +#include <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> #include <svx/htmlmode.hxx> +#include <svx/xtable.hxx> +#include <svx/drawitem.hxx> #include <editeng/borderline.hxx> #include <editeng/boxitem.hxx> #include <editeng/lrspitem.hxx> @@ -80,15 +84,7 @@ SV_IMPL_PTRARR( SwColumns, SwColumnPtr ) /*-------------------------------------------------------------------- Beschreibung: Statische Daten --------------------------------------------------------------------*/ -static const sal_uInt16 nLines[] = { - DEF_LINE_WIDTH_0, - DEF_LINE_WIDTH_1, - DEF_LINE_WIDTH_2, - DEF_LINE_WIDTH_3, - DEF_LINE_WIDTH_4 -}; -static const sal_uInt16 nLineCount = SAL_N_ELEMENTS(nLines); static const sal_uInt16 nVisCols = 3; inline sal_Bool IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect ) @@ -399,15 +395,6 @@ static sal_uInt16 aPageRg[] = { DBG_NAME(columnhdl) -sal_uInt16 lcl_LineWidthToPos(sal_uLong nWidth) -{ - const sal_uInt16 nUShortWidth = (sal_uInt16)nWidth; - for(sal_uInt16 i = 0; i < nLineCount; ++i) - if(nUShortWidth == nLines[i]) - return i; - return 0; -} - void SwColumnPage::ResetColWidth() { if( nCols ) @@ -453,6 +440,10 @@ SwColumnPage::SwColumnPage(Window *pParent, const SfxItemSet &rSet) aFLLineType(this, SW_RES(FL_LINETYPE)), aLineTypeLbl(this, SW_RES(FT_STYLE)), aLineTypeDLB(this, SW_RES(LB_STYLE)), + aLineWidthLbl(this, SW_RES(FT_LINEWIDTH)), + aLineWidthEdit(this, SW_RES(ED_LINEWIDTH)), + aLineColorLbl(this, SW_RES(FT_COLOR)), + aLineColorDLB(this, SW_RES(LB_COLOR)), aLineHeightLbl(this, SW_RES(FT_HEIGHT)), aLineHeightEdit(this, SW_RES(ED_HEIGHT)), aLinePosLbl(this, SW_RES(FT_POSITION)), @@ -476,7 +467,7 @@ SwColumnPage::SwColumnPage(Window *pParent, const SfxItemSet &rSet) bHtmlMode(sal_False), bLockUpdate(sal_False) { - sal_uInt16 i; + long i; FreeResource(); SetExchangeSupport(); @@ -534,14 +525,50 @@ SwColumnPage::SwColumnPage(Window *pParent, const SfxItemSet &rSet) aLk = LINK( this, SwColumnPage, UpdateColMgr ); aLineTypeDLB.SetSelectHdl( aLk ); + aLineWidthEdit.SetModifyHdl( aLk ); + aLineColorDLB.SetSelectHdl( aLk ); aLineHeightEdit.SetModifyHdl( aLk ); aLinePosDLB.SetSelectHdl( aLk ); - // Trennlinie + // Separator line aLineTypeDLB.SetUnit( FUNIT_POINT ); aLineTypeDLB.SetSourceUnit( FUNIT_TWIP ); - for( i = 0; i < nLineCount; ++i ) - aLineTypeDLB.InsertEntry( 100 * nLines[ i ] ); + + // Fill the line styles listbox + aLineTypeDLB.SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) ); + aLineTypeDLB.InsertEntry( SvxBorderLine::getWidthImpl( SOLID ), SOLID ); + aLineTypeDLB.InsertEntry( SvxBorderLine::getWidthImpl( DOTTED ), DOTTED ); + aLineTypeDLB.InsertEntry( SvxBorderLine::getWidthImpl( DASHED ), DASHED ); + + long nLineWidth = MetricField::ConvertDoubleValue( + aLineWidthEdit.GetValue( ), + aLineWidthEdit.GetDecimalDigits( ), + aLineWidthEdit.GetUnit(), MAP_TWIP ); + aLineTypeDLB.SetWidth( nLineWidth ); + + // Fill the color listbox + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem = NULL; + XColorTable* pColorTable = NULL; + if ( pDocSh ) + { + pItem = pDocSh->GetItem( SID_COLOR_TABLE ); + if ( pItem != NULL ) + pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable(); + } + + if ( pColorTable ) + { + aLineColorDLB.SetUpdateMode( sal_False ); + + for ( i = 0; i < pColorTable->Count(); ++i ) + { + XColorEntry* pEntry = pColorTable->GetColor(i); + aLineColorDLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() ); + } + aLineColorDLB.SetUpdateMode( sal_True ); + } + aLineColorDLB.SelectEntryPos( 0 ); } SwColumnPage::~SwColumnPage() @@ -705,11 +732,18 @@ IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ ) sal_Bool bEnable = 0 != nPos; aLineHeightEdit.Enable( bEnable ); aLineHeightLbl.Enable( bEnable ); + long nLineWidth = MetricField::ConvertDoubleValue( + aLineWidthEdit.GetValue( ), + aLineWidthEdit.GetDecimalDigits( ), + aLineWidthEdit.GetUnit(), MAP_TWIP ); if( !bEnable ) pColMgr->SetNoLine(); else if( LISTBOX_ENTRY_NOTFOUND != nPos ) { - pColMgr->SetLineWidthAndColor(nLines[nPos - 1], Color(COL_BLACK) ); + pColMgr->SetLineWidthAndColor( + SvxBorderStyle( aLineTypeDLB.GetSelectEntryStyle( ) ), + nLineWidth, + aLineColorDLB.GetSelectEntryColor() ); pColMgr->SetAdjust( SwColLineAdj( aLinePosDLB.GetSelectEntryPos() + 1) ); pColMgr->SetLineHeightPercent((short)aLineHeightEdit.GetValue()); @@ -717,6 +751,9 @@ IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ ) } aLinePosLbl.Enable( bEnable ); aLinePosDLB.Enable( bEnable ); + + aLineTypeDLB.SetWidth( nLineWidth ); + aLineTypeDLB.SetColor( aLineColorDLB.GetSelectEntryColor( ) ); } else { @@ -785,8 +822,13 @@ void SwColumnPage::Init() } else { - aLineTypeDLB.SelectEntryPos( lcl_LineWidthToPos(( pColMgr->GetLineWidth() )) + 1); + // Need to multiply by 100 because of the 2 decimals + aLineWidthEdit.SetValue( pColMgr->GetLineWidth() * 100, FUNIT_TWIP ); + aLineColorDLB.SelectEntry( pColMgr->GetLineColor() ); + aLineTypeDLB.SelectEntry( pColMgr->GetLineStyle() ); + aLineTypeDLB.SetWidth( pColMgr->GetLineWidth( ) ); aLineHeightEdit.SetValue( pColMgr->GetLineHeightPercent() ); + } aLinePosDLB.SelectEntryPos( static_cast< sal_uInt16 >(eAdj - 1) ); } @@ -858,6 +900,10 @@ void SwColumnPage::UpdateCols() aLineHeightLbl.Enable( bEnable ); aLineTypeDLB.Enable( bEnable ); aLineTypeLbl.Enable( bEnable ); + aLineWidthLbl.Enable( bEnable ); + aLineWidthEdit.Enable( bEnable ); + aLineColorDLB.Enable( bEnable ); + aLineColorLbl.Enable( bEnable ); aAutoWidthBox.Enable( bEnable && !bHtmlMode ); } diff --git a/sw/source/ui/frmdlg/column.hrc b/sw/source/ui/frmdlg/column.hrc index 781bd100dc..a45c68d771 100644 --- a/sw/source/ui/frmdlg/column.hrc +++ b/sw/source/ui/frmdlg/column.hrc @@ -79,6 +79,12 @@ #define FT_TEXTDIRECTION 60 #define LB_TEXTDIRECTION 61 #define FL_VERT 62 + +#define FT_LINEWIDTH 63 +#define ED_LINEWIDTH 64 +#define FT_COLOR 65 +#define LB_COLOR 66 + #define LISTBOX_SELECTION 0 #define LISTBOX_SECTION 1 #define LISTBOX_SECTIONS 2 diff --git a/sw/source/ui/frmdlg/column.src b/sw/source/ui/frmdlg/column.src index 8734383294..30d96c5931 100644 --- a/sw/source/ui/frmdlg/column.src +++ b/sw/source/ui/frmdlg/column.src @@ -262,7 +262,7 @@ TabPage TP_COLUMN { Pos = MAP_APPFONT ( 12 , 140 ) ; Size = MAP_APPFONT ( 35 , 8 ) ; - Text [ en-US ] = "~Line" ; + Text [ en-US ] = "St~yle" ; Left = TRUE ; }; ListBox LB_STYLE @@ -272,15 +272,50 @@ TabPage TP_COLUMN Size = MAP_APPFONT ( 60 , 66 ) ; TabStop = TRUE ; DropDown = TRUE ; - StringList [ en-US ] = - { - < "None" ; Default ; > ; - }; }; - FixedText FT_HEIGHT + FixedText FT_LINEWIDTH { Pos = MAP_APPFONT ( 12 , 156 ) ; Size = MAP_APPFONT ( 35 , 8 ) ; + Text [ en-US ] = "~Width" ; + Left = TRUE ; + }; + MetricField ED_LINEWIDTH + { + Border = TRUE ; + Pos = MAP_APPFONT ( 50 , 154 ) ; + Size = MAP_APPFONT ( 60 , 12 ) ; + TabStop = TRUE ; + Spin = TRUE ; + Repeat = TRUE ; + First = 25 ; + Last = 900 ; + Minimum = 25 ; + Maximum = 900 ; + DecimalDigits = 2 ; + SpinSize = 25 ; + Unit = FUNIT_POINT ; + }; + FixedText FT_COLOR + { + Pos = MAP_APPFONT ( 12 , 172 ) ; + Size = MAP_APPFONT ( 35 , 8 ) ; + Text [ en-US ] = "~Color" ; + Left = TRUE ; + }; + ListBox LB_COLOR + { + Border = TRUE ; + Pos = MAP_APPFONT ( 50 , 170 ) ; + Size = MAP_APPFONT ( 60 , 68 ) ; + DropDown = TRUE ; + DDExtraWidth = TRUE ; + TabStop = TRUE ; + }; + FixedText FT_HEIGHT + { + Pos = MAP_APPFONT ( 122 , 140 ) ; + Size = MAP_APPFONT ( 35 , 8 ) ; Text [ en-US ] = "H~eight" ; Left = TRUE ; }; @@ -288,7 +323,7 @@ TabPage TP_COLUMN { HelpID = "sw:MetricField:TP_COLUMN:ED_HEIGHT"; Border = TRUE ; - Pos = MAP_APPFONT ( 50 , 154 ) ; + Pos = MAP_APPFONT ( 160 , 138 ) ; Size = MAP_APPFONT ( 60 , 12 ) ; TabStop = TRUE ; Left = TRUE ; @@ -304,7 +339,7 @@ TabPage TP_COLUMN }; FixedText FT_POSITION { - Pos = MAP_APPFONT ( 12 , 172 ) ; + Pos = MAP_APPFONT ( 122 , 156 ) ; Size = MAP_APPFONT ( 35 , 8 ) ; Left = TRUE ; Text [ en-US ] = "~Position" ; @@ -312,7 +347,7 @@ TabPage TP_COLUMN ListBox LB_POSITION { HelpID = "sw:ListBox:TP_COLUMN:LB_POSITION"; - Pos = MAP_APPFONT ( 50 , 170 ) ; + Pos = MAP_APPFONT ( 160 , 154 ) ; Size = MAP_APPFONT ( 60 , 40 ) ; TabStop = TRUE ; DropDown = TRUE ; diff --git a/sw/source/ui/inc/colmgr.hxx b/sw/source/ui/inc/colmgr.hxx index 2488d270e2..bb1358ce9f 100644 --- a/sw/source/ui/inc/colmgr.hxx +++ b/sw/source/ui/inc/colmgr.hxx @@ -56,7 +56,8 @@ public: inline sal_Bool HasLine() const; inline void SetNoLine(); - inline void SetLineWidthAndColor(sal_uLong nWidth, const Color& rCol); + void SetLineWidthAndColor(SvxBorderStyle eStyle, sal_uLong nWidth, const Color& rCol); + inline SvxBorderStyle GetLineStyle() const; inline sal_uLong GetLineWidth() const; inline const Color& GetLineColor() const; @@ -87,10 +88,9 @@ inline sal_uInt16 SwColMgr::GetCount() const return aFmtCol.GetNumCols(); } -inline void SwColMgr::SetLineWidthAndColor(sal_uLong nLWidth, const Color& rCol) +inline SvxBorderStyle SwColMgr::GetLineStyle() const { - aFmtCol.SetLineWidth(nLWidth); - aFmtCol.SetLineColor(rCol); + return aFmtCol.GetLineStyle(); } inline sal_uLong SwColMgr::GetLineWidth() const { diff --git a/sw/source/ui/inc/column.hxx b/sw/source/ui/inc/column.hxx index 436fad884e..865e55c0e6 100644 --- a/sw/source/ui/inc/column.hxx +++ b/sw/source/ui/inc/column.hxx @@ -130,6 +130,10 @@ class SwColumnPage : public SfxTabPage FixedLine aFLLineType; FixedText aLineTypeLbl; LineListBox aLineTypeDLB; + FixedText aLineWidthLbl; + MetricField aLineWidthEdit; + FixedText aLineColorLbl; + ColorListBox aLineColorDLB; FixedText aLineHeightLbl; MetricField aLineHeightEdit; FixedText aLinePosLbl; |