1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: border.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #ifdef SVX_DLLIMPLEMENTATION
34 #undef SVX_DLLIMPLEMENTATION
37 // include ---------------------------------------------------------------
38 #include <sfx2/app.hxx>
39 #include <sfx2/objsh.hxx>
40 #include <sfx2/module.hxx>
42 #define _SVX_BORDER_CXX
44 #include <svx/dialogs.hrc>
45 #include <svx/svxitems.hrc>
49 #define LINESTYLE_HTML_MAX 5
51 #include <svx/xtable.hxx> // XColorTable
52 #include "drawitem.hxx"
53 #include <svx/boxitem.hxx>
54 #include <svx/shaditem.hxx>
56 #include "dlgutil.hxx"
57 #include <svx/dialmgr.hxx>
58 #include "htmlmode.hxx"
59 #include <vcl/msgbox.hxx>
60 #include <svx/svxids.hrc> //CHINA001
61 #include "flagsdef.hxx" //CHINA001
62 #include <sfx2/request.hxx>
63 #include <svtools/intitem.hxx> //CHINA001
64 #include <sfx2/itemconnect.hxx>
65 #include "borderconn.hxx"
67 // -----------------------------------------------------------------------
71 * TabPage zum Einstellen der Rahmen-Attribute.
73 * ein SvxShadowItem: Schatten
74 * ein SvxBoxItem: Linien links,rechts,oben,unten ),
75 * ein SvxBoxInfo: Linien vertikal,horizontal, Abstaende, Flags )
77 * Linien koennen drei Zustaende haben.
78 * 1. Show ( -> gueltige Werte )
79 * 2. Hide ( -> NULL-Pointer )
80 * 3. DontCare ( -> gesonderte Valid-Flags im InfoItem )
83 // static ----------------------------------------------------------------
85 static USHORT pRanges
[] =
87 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_SHADOW
,
88 SID_ATTR_ALIGN_MARGIN
, SID_ATTR_ALIGN_MARGIN
,
89 SID_ATTR_BORDER_CONNECT
, SID_ATTR_BORDER_CONNECT
,
90 SID_SW_COLLAPSING_BORDERS
, SID_SW_COLLAPSING_BORDERS
,
91 SID_ATTR_BORDER_DIAG_TLBR
, SID_ATTR_BORDER_DIAG_BLTR
,
95 BOOL
SvxBorderTabPage::bSync
= TRUE
;
98 //------------------------------------------------------------------------
100 #define LINE_WIDTH0 (DEF_LINE_WIDTH_0 *100)
101 #define LINE_WIDTH1 (DEF_LINE_WIDTH_1 *100)
102 #define LINE_WIDTH2 (DEF_LINE_WIDTH_2 *100)
103 #define LINE_WIDTH3 (DEF_LINE_WIDTH_3 *100)
104 #define LINE_WIDTH4 (DEF_LINE_WIDTH_4 *100)
105 #define LINE_WIDTH5 (DEF_LINE_WIDTH_5 *100)
107 #define DLINE0_OUT (DEF_DOUBLE_LINE0_OUT *100)
108 #define DLINE0_IN (DEF_DOUBLE_LINE0_IN *100)
109 #define DLINE0_DIST (DEF_DOUBLE_LINE0_DIST *100)
111 #define DLINE1_OUT (DEF_DOUBLE_LINE1_OUT *100)
112 #define DLINE1_IN (DEF_DOUBLE_LINE1_IN *100)
113 #define DLINE1_DIST (DEF_DOUBLE_LINE1_DIST *100)
115 #define DLINE2_OUT (DEF_DOUBLE_LINE2_OUT *100)
116 #define DLINE2_IN (DEF_DOUBLE_LINE2_IN *100)
117 #define DLINE2_DIST (DEF_DOUBLE_LINE2_DIST *100)
119 #define DLINE3_OUT (DEF_DOUBLE_LINE3_OUT *100)
120 #define DLINE3_IN (DEF_DOUBLE_LINE3_IN *100)
121 #define DLINE3_DIST (DEF_DOUBLE_LINE3_DIST *100)
123 #define DLINE4_OUT (DEF_DOUBLE_LINE4_OUT *100)
124 #define DLINE4_IN (DEF_DOUBLE_LINE4_IN *100)
125 #define DLINE4_DIST (DEF_DOUBLE_LINE4_DIST *100)
127 #define DLINE5_OUT (DEF_DOUBLE_LINE5_OUT *100)
128 #define DLINE5_IN (DEF_DOUBLE_LINE5_IN *100)
129 #define DLINE5_DIST (DEF_DOUBLE_LINE5_DIST *100)
131 #define DLINE6_OUT (DEF_DOUBLE_LINE6_OUT *100)
132 #define DLINE6_IN (DEF_DOUBLE_LINE6_IN *100)
133 #define DLINE6_DIST (DEF_DOUBLE_LINE6_DIST *100)
135 #define DLINE7_OUT (DEF_DOUBLE_LINE7_OUT *100)
136 #define DLINE7_IN (DEF_DOUBLE_LINE7_IN *100)
137 #define DLINE7_DIST (DEF_DOUBLE_LINE7_DIST *100)
139 #define DLINE8_OUT (DEF_DOUBLE_LINE8_OUT *100)
140 #define DLINE8_IN (DEF_DOUBLE_LINE8_IN *100)
141 #define DLINE8_DIST (DEF_DOUBLE_LINE8_DIST *100)
143 #define DLINE9_OUT (DEF_DOUBLE_LINE9_OUT *100)
144 #define DLINE9_IN (DEF_DOUBLE_LINE9_IN *100)
145 #define DLINE9_DIST (DEF_DOUBLE_LINE9_DIST *100)
147 #define DLINE10_OUT (DEF_DOUBLE_LINE10_OUT *100)
148 #define DLINE10_IN (DEF_DOUBLE_LINE10_IN *100)
149 #define DLINE10_DIST (DEF_DOUBLE_LINE10_DIST*100)
151 #define RGBCOL(eColorName) (TpBorderRGBColor(eColorName))
154 // Konvertiert in echte RGB-Farben, damit in den Listboxen
155 // endlich mal richtig selektiert werden kann.
157 Color
TpBorderRGBColor( ColorData aColorData
)
159 Color
aRGBColor( aColorData
);
164 // -----------------------------------------------------------------------
166 Color
TpBorderRGBColor( const Color
& rColor
)
168 Color
aRGBColor( rColor
.GetRed(),
175 // -----------------------------------------------------------------------
176 void lcl_SetDecimalDigitsTo1(MetricField
& rField
)
178 sal_Int64 nMin
= rField
.Denormalize( rField
.GetMin( FUNIT_TWIP
) );
179 rField
.SetDecimalDigits(1);
180 rField
.SetMin( rField
.Normalize( nMin
), FUNIT_TWIP
);
182 // -----------------------------------------------------------------------
184 SvxBorderTabPage::SvxBorderTabPage( Window
* pParent
,
185 const SfxItemSet
& rCoreAttrs
)
187 : SfxTabPage( pParent
, SVX_RES( RID_SVXPAGE_BORDER
), rCoreAttrs
),
189 aFlBorder ( this, SVX_RES( FL_BORDER
) ),
190 aDefaultFT ( this, SVX_RES( FT_DEFAULT
) ),
191 aWndPresets ( this, SVX_RES( WIN_PRESETS
) ),
192 aUserDefFT ( this, SVX_RES( FT_USERDEF
) ),
193 aFrameSel ( this, SVX_RES( WIN_FRAMESEL
) ),
195 aFlSep1 ( this, SVX_RES( FL_SEPARATOR1
) ),
196 aFlLine ( this, SVX_RES( FL_LINE
) ),
197 aStyleFT ( this, SVX_RES( FT_STYLE
) ),
198 aLbLineStyle ( this, SVX_RES( LB_LINESTYLE
) ),
199 aColorFT ( this, SVX_RES( FT_COLOR
) ),
200 aLbLineColor ( this, SVX_RES( LB_LINECOLOR
) ),
202 aFlSep2 ( this, SVX_RES( FL_SEPARATOR2
) ),
203 aDistanceFL ( this, SVX_RES( FL_DISTANCE
) ),
204 aLeftFT ( this, SVX_RES( FT_LEFT
) ),
205 aLeftMF ( this, SVX_RES( MF_LEFT
) ),
206 aRightFT ( this, SVX_RES( FT_RIGHT
) ),
207 aRightMF ( this, SVX_RES( MF_RIGHT
) ),
208 aTopFT ( this, SVX_RES( FT_TOP
) ),
209 aTopMF ( this, SVX_RES( MF_TOP
) ),
210 aBottomFT ( this, SVX_RES( FT_BOTTOM
) ),
211 aBottomMF ( this, SVX_RES( MF_BOTTOM
) ),
212 aSynchronizeCB ( this, SVX_RES( CB_SYNC
) ),
214 aFlShadow ( this, SVX_RES( FL_SHADOW
) ),
215 aFtShadowPos ( this, SVX_RES( FT_SHADOWPOS
) ),
216 aWndShadows ( this, SVX_RES( WIN_SHADOWS
) ),
217 aFtShadowSize ( this, SVX_RES( FT_SHADOWSIZE
) ),
218 aEdShadowSize ( this, SVX_RES( ED_SHADOWSIZE
) ),
219 aFtShadowColor ( this, SVX_RES( FT_SHADOWCOLOR
) ),
220 aLbShadowColor ( this, SVX_RES( LB_SHADOWCOLOR
) ),
221 aPropertiesFL ( this, SVX_RES( FL_PROPERTIES
) ),
222 aMergeWithNextCB( this, SVX_RES( CB_MERGEWITHNEXT
) ),
223 aMergeAdjacentBordersCB( this, SVX_RES( CB_MERGEADJACENTBORDERS
) ),
224 aShadowImgLstH( SVX_RES(ILH_SDW_BITMAPS
)),
225 aShadowImgLst( SVX_RES(IL_SDW_BITMAPS
)),
226 aBorderImgLstH( SVX_RES(ILH_PRE_BITMAPS
)),
227 aBorderImgLst( SVX_RES(IL_PRE_BITMAPS
)),
230 mbHorEnabled( false ),
231 mbVerEnabled( false ),
232 mbTLBREnabled( false ),
233 mbBLTREnabled( false ),
234 mbUseMarginItem( false )
237 // diese Page braucht ExchangeSupport
238 SetExchangeSupport();
240 /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
241 -> Remember this state in mbUseMarginItem, because other special handling
242 is needed across various functions... */
243 mbUseMarginItem
= rCoreAttrs
.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN
),TRUE
) != SFX_ITEM_UNKNOWN
;
246 FieldUnit eFUnit
= GetModuleFieldUnit( &rCoreAttrs
);
248 if( mbUseMarginItem
)
250 // copied from SvxAlignmentTabPage
253 // #103396# the default value (1pt) can't be accurately represented in
254 // inches or pica with two decimals, so point is used instead.
259 eFUnit
= FUNIT_POINT
;
267 default: ;//prevent warning
278 default: ; //prevent warning
282 SetFieldUnit( aEdShadowSize
, eFUnit
);
284 USHORT nWhich
= GetWhich( SID_ATTR_BORDER_INNER
, sal_False
);
285 BOOL bIsDontCare
= TRUE
;
287 if ( rCoreAttrs
.GetItemState( nWhich
, TRUE
) >= SFX_ITEM_AVAILABLE
)
289 // Absatz oder Tabelle
290 const SvxBoxInfoItem
* pBoxInfo
=
291 (const SvxBoxInfoItem
*)&( rCoreAttrs
.Get( nWhich
) );
293 mbHorEnabled
= pBoxInfo
->IsHorEnabled();
294 mbVerEnabled
= pBoxInfo
->IsVerEnabled();
295 mbTLBREnabled
= sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs
, SID_ATTR_BORDER_DIAG_TLBR
);
296 mbBLTREnabled
= sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs
, SID_ATTR_BORDER_DIAG_BLTR
);
298 if(pBoxInfo
->IsDist())
300 SetFieldUnit(aLeftMF
, eFUnit
);
301 SetFieldUnit(aRightMF
, eFUnit
);
302 SetFieldUnit(aTopMF
, eFUnit
);
303 SetFieldUnit(aBottomMF
, eFUnit
);
304 aSynchronizeCB
.Check(bSync
);
305 aSynchronizeCB
.SetClickHdl(LINK(this, SvxBorderTabPage
, SyncHdl_Impl
));
306 aLeftMF
.SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
307 aRightMF
.SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
308 aTopMF
.SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
309 aBottomMF
.SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
323 aSynchronizeCB
.Hide();
325 bIsDontCare
= !pBoxInfo
->IsValid( VALID_DISABLE
);
327 if(!mbUseMarginItem
&& eFUnit
== FUNIT_MM
&& SFX_MAPUNIT_TWIP
== rCoreAttrs
.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER
) ))
329 //#i91548# changing the number of decimal digits changes the minimum values, too
330 lcl_SetDecimalDigitsTo1(aLeftMF
);
331 lcl_SetDecimalDigitsTo1(aRightMF
);
332 lcl_SetDecimalDigitsTo1(aTopMF
);
333 lcl_SetDecimalDigitsTo1(aBottomMF
);
334 lcl_SetDecimalDigitsTo1(aEdShadowSize
);
337 svx::FrameSelFlags nFlags
= svx::FRAMESEL_OUTER
;
339 nFlags
|= svx::FRAMESEL_INNER_HOR
;
341 nFlags
|= svx::FRAMESEL_INNER_VER
;
343 nFlags
|= svx::FRAMESEL_DIAG_TLBR
;
345 nFlags
|= svx::FRAMESEL_DIAG_BLTR
;
347 nFlags
|= svx::FRAMESEL_DONTCARE
;
348 aFrameSel
.Initialize( nFlags
);
350 aFrameSel
.SetSelectHdl(LINK(this, SvxBorderTabPage
, LinesChanged_Impl
));
351 aLbLineStyle
.SetSelectHdl( LINK( this, SvxBorderTabPage
, SelStyleHdl_Impl
) );
352 aLbLineColor
.SetSelectHdl( LINK( this, SvxBorderTabPage
, SelColHdl_Impl
) );
353 aLbShadowColor
.SetSelectHdl( LINK( this, SvxBorderTabPage
, SelColHdl_Impl
) );
354 aWndPresets
.SetSelectHdl( LINK( this, SvxBorderTabPage
, SelPreHdl_Impl
) );
355 aWndShadows
.SetSelectHdl( LINK( this, SvxBorderTabPage
, SelSdwHdl_Impl
) );
358 FillLineListBox_Impl();
360 // ColorBox aus der XColorTable fuellen.
361 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
362 const SfxPoolItem
* pItem
= NULL
;
363 XColorTable
* pColorTable
= NULL
;
365 DBG_ASSERT( pDocSh
, "DocShell not found!" );
369 pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
371 pColorTable
= ( (SvxColorTableItem
*)pItem
)->GetColorTable();
374 DBG_ASSERT( pColorTable
, "ColorTable not found!" );
378 // fuellen der Linienfarben-Box
379 aLbLineColor
.SetUpdateMode( FALSE
);
381 for ( long i
= 0; i
< pColorTable
->Count(); ++i
)
383 XColorEntry
* pEntry
= pColorTable
->GetColor(i
);
384 aLbLineColor
.InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
386 aLbLineColor
.SetUpdateMode( TRUE
);
387 // dann nur noch in die Schattenfarben-Box kopieren
388 aLbShadowColor
.CopyEntries( aLbLineColor
);
394 bool bSupportsShadow
= !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW
) );
395 if( bSupportsShadow
)
396 AddItemConnection( svx::CreateShadowConnection( rCoreAttrs
, aWndShadows
, aEdShadowSize
, aLbShadowColor
) );
398 HideShadowControls();
400 if( mbUseMarginItem
)
401 AddItemConnection( svx::CreateMarginConnection( rCoreAttrs
, aLeftMF
, aRightMF
, aTopMF
, aBottomMF
) );
402 if( aFrameSel
.IsBorderEnabled( svx::FRAMEBORDER_TLBR
) )
403 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR
, aFrameSel
, svx::FRAMEBORDER_TLBR
) );
404 if( aFrameSel
.IsBorderEnabled( svx::FRAMEBORDER_BLTR
) )
405 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_BLTR
, aFrameSel
, svx::FRAMEBORDER_BLTR
) );
406 // --> OD 2005-03-01 #i43593# - item connection doesn't work for Writer,
407 // because the Writer item sets contain these items
408 // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
409 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT
, aMergeWithNextCB
, sfx::ITEMCONN_DEFAULT
) );
410 aMergeWithNextCB
.Hide();
411 // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
412 AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS
, aMergeAdjacentBordersCB
, sfx::ITEMCONN_DEFAULT
) );
413 aMergeAdjacentBordersCB
.Hide();
417 // -----------------------------------------------------------------------
419 SvxBorderTabPage::~SvxBorderTabPage()
423 // -----------------------------------------------------------------------
425 USHORT
* SvxBorderTabPage::GetRanges()
430 // -----------------------------------------------------------------------
432 SfxTabPage
* SvxBorderTabPage::Create( Window
* pParent
,
433 const SfxItemSet
& rAttrSet
)
435 return ( new SvxBorderTabPage( pParent
, rAttrSet
) );
438 // -----------------------------------------------------------------------
440 void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder
, const SvxBorderLine
* pCoreLine
, bool bValid
)
442 if( aFrameSel
.IsBorderEnabled( eBorder
) )
445 aFrameSel
.ShowBorder( eBorder
, pCoreLine
);
447 aFrameSel
.SetBorderDontCare( eBorder
);
451 // -----------------------------------------------------------------------
453 void SvxBorderTabPage::Reset( const SfxItemSet
& rSet
)
455 SfxTabPage::Reset( rSet
);
457 const SvxBoxItem
* pBoxItem
;
458 const SvxBoxInfoItem
* pBoxInfoItem
;
459 USHORT nWhichBox
= GetWhich(SID_ATTR_BORDER_OUTER
);
460 SfxMapUnit eCoreUnit
;
461 const Color aColBlack
= RGBCOL(COL_BLACK
);
463 pBoxItem
= (const SvxBoxItem
*)GetItem( rSet
, SID_ATTR_BORDER_OUTER
);
466 pBoxInfoItem
= (const SvxBoxInfoItem
*)GetItem( rSet
, SID_ATTR_BORDER_INNER
, sal_False
);
468 eCoreUnit
= rSet
.GetPool()->GetMetric( nWhichBox
);
470 if ( pBoxItem
&& pBoxInfoItem
) // -> Don't Care
472 ResetFrameLine_Impl( svx::FRAMEBORDER_LEFT
, pBoxItem
->GetLeft(), pBoxInfoItem
->IsValid( VALID_LEFT
) );
473 ResetFrameLine_Impl( svx::FRAMEBORDER_RIGHT
, pBoxItem
->GetRight(), pBoxInfoItem
->IsValid( VALID_RIGHT
) );
474 ResetFrameLine_Impl( svx::FRAMEBORDER_TOP
, pBoxItem
->GetTop(), pBoxInfoItem
->IsValid( VALID_TOP
) );
475 ResetFrameLine_Impl( svx::FRAMEBORDER_BOTTOM
, pBoxItem
->GetBottom(), pBoxInfoItem
->IsValid( VALID_BOTTOM
) );
476 ResetFrameLine_Impl( svx::FRAMEBORDER_VER
, pBoxInfoItem
->GetVert(), pBoxInfoItem
->IsValid( VALID_VERT
) );
477 ResetFrameLine_Impl( svx::FRAMEBORDER_HOR
, pBoxInfoItem
->GetHori(), pBoxInfoItem
->IsValid( VALID_HORI
) );
479 //-------------------
480 // Abstand nach innen
481 //-------------------
482 if( !mbUseMarginItem
)
484 if ( aLeftMF
.IsVisible() )
486 SetMetricValue( aLeftMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
487 SetMetricValue( aRightMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
488 SetMetricValue( aTopMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
489 SetMetricValue( aBottomMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
491 nMinValue
= static_cast<long>(aLeftMF
.GetValue());
493 if ( pBoxInfoItem
->IsMinDist() )
495 aLeftMF
.SetFirst( nMinValue
);
496 aRightMF
.SetFirst( nMinValue
);
497 aTopMF
.SetFirst( nMinValue
);
498 aBottomMF
.SetFirst( nMinValue
);
501 if ( pBoxInfoItem
->IsDist() )
503 if( rSet
.GetItemState( nWhichBox
, TRUE
) >= SFX_ITEM_DEFAULT
)
505 BOOL bIsAnyBorderVisible
= aFrameSel
.IsAnyBorderVisible();
506 if( !bIsAnyBorderVisible
|| !pBoxInfoItem
->IsMinDist() )
509 aLeftMF
.SetFirst( 0 );
510 aRightMF
.SetMin( 0 );
511 aRightMF
.SetFirst( 0 );
513 aTopMF
.SetFirst( 0 );
514 aBottomMF
.SetMin( 0 );
515 aBottomMF
.SetFirst( 0 );
517 long nLeftDist
= pBoxItem
->GetDistance( BOX_LINE_LEFT
);
518 SetMetricValue( aLeftMF
, nLeftDist
, eCoreUnit
);
519 long nRightDist
= pBoxItem
->GetDistance( BOX_LINE_RIGHT
);
520 SetMetricValue( aRightMF
, nRightDist
, eCoreUnit
);
521 long nTopDist
= pBoxItem
->GetDistance( BOX_LINE_TOP
);
522 SetMetricValue( aTopMF
, nTopDist
, eCoreUnit
);
523 long nBottomDist
= pBoxItem
->GetDistance( BOX_LINE_BOTTOM
);
524 SetMetricValue( aBottomMF
, nBottomDist
, eCoreUnit
);
526 // ist der Abstand auf nicht-default gesetzt,
527 // dann soll der Wert auch nicht
528 // mehr autom. veraendert werden
530 // if the distance is set with no active border line
531 // or it is null with an active border line
532 // no automatic changes should be made
533 const long nDefDist
= bIsAnyBorderVisible
? pBoxInfoItem
->GetDefDist() : 0;
534 BOOL bDiffDist
= (nDefDist
!= nLeftDist
||
535 nDefDist
!= nRightDist
||
536 nDefDist
!= nTopDist
||
537 nDefDist
!= nBottomDist
);
538 if((pBoxItem
->GetDistance() ||
539 bIsAnyBorderVisible
) && bDiffDist
)
541 aLeftMF
.SetModifyFlag();
542 aRightMF
.SetModifyFlag();
543 aTopMF
.SetModifyFlag();
544 aBottomMF
.SetModifyFlag();
549 // #106224# different margins -> do not fill the edits
550 aLeftMF
.SetText( String() );
551 aRightMF
.SetText( String() );
552 aTopMF
.SetText( String() );
553 aBottomMF
.SetText( String() );
557 aRightMF
.SaveValue();
559 aBottomMF
.SaveValue();
565 // ResetFrameLine-Aufrufe einsparen:
566 aFrameSel
.HideAllBorders();
569 //-------------------------------------------------------------
570 // Linie/Linienfarbe in Controllern darstellen, wenn eindeutig:
571 //-------------------------------------------------------------
573 // Do all visible lines show the same line widths?
574 USHORT nPrim
, nDist
, nSecn
;
575 bool bWidthEq
= aFrameSel
.GetVisibleWidth( nPrim
, nDist
, nSecn
);
577 aLbLineStyle
.SelectEntry( nPrim
* 100, nSecn
* 100, nDist
* 100 );
579 aLbLineStyle
.SelectEntryPos( 1 );
581 // Do all visible lines show the same line color?
583 bool bColorEq
= aFrameSel
.GetVisibleColor( aColor
);
585 aColor
.SetColor( COL_BLACK
);
587 USHORT nSelPos
= aLbLineColor
.GetEntryPos( aColor
);
588 if( nSelPos
== LISTBOX_ENTRY_NOTFOUND
)
589 nSelPos
= aLbLineColor
.InsertEntry( aColor
, SVX_RESSTR( RID_SVXSTR_COLOR_USER
) );
591 aLbLineColor
.SelectEntryPos( nSelPos
);
592 aLbLineStyle
.SetColor( aColor
);
594 // Select all visible lines, if they are all equal.
595 if( bWidthEq
&& bColorEq
)
596 aFrameSel
.SelectAllVisibleBorders();
598 // set the current style and color (caches style in control even if nothing is selected)
599 SelStyleHdl_Impl( &aLbLineStyle
);
600 SelColHdl_Impl( &aLbLineColor
);
603 BOOL bEnable
= aWndShadows
.GetSelectItemId() > 1 ;
604 aFtShadowSize
.Enable(bEnable
);
605 aEdShadowSize
.Enable(bEnable
);
606 aFtShadowColor
.Enable(bEnable
);
607 aLbShadowColor
.Enable(bEnable
);
609 aWndPresets
.SetNoSelection();
611 // - keine Line - sollte nicht selektiert sein
613 if ( aLbLineStyle
.GetSelectEntryPos() == 0 )
615 aLbLineStyle
.SelectEntryPos( 1 );
616 SelStyleHdl_Impl( &aLbLineStyle
);
619 const SfxPoolItem
* pItem
;
620 SfxObjectShell
* pShell
;
621 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_HTML_MODE
, FALSE
, &pItem
) ||
622 ( 0 != (pShell
= SfxObjectShell::Current()) &&
623 0 != (pItem
= pShell
->GetItem(SID_HTML_MODE
))))
625 USHORT nHtmlMode
= ((SfxUInt16Item
*)pItem
)->GetValue();
626 if(nHtmlMode
& HTMLMODE_ON
)
628 //Im Html-Mode gibt es keinen Schatten und nur komplette Umrandungen
629 aFtShadowPos
.Disable();
630 aWndShadows
.Disable();
631 aFtShadowSize
.Disable();
632 aEdShadowSize
.Disable();
633 aFtShadowColor
.Disable();
634 aLbShadowColor
.Disable();
635 aFlShadow
.Disable();
637 USHORT nLBCount
= aLbLineStyle
.GetEntryCount();
638 // ist es ein Absatzdialog, dann alle Linien fuer
639 // Sw-Export, sonst ist die Page nicht da
640 if(!(mbHorEnabled
|| mbVerEnabled
)
641 && 0 == (nHtmlMode
& HTMLMODE_FULL_ABS_POS
) &&
642 SFX_ITEM_AVAILABLE
> rSet
.GetItemState(GetWhich( SID_ATTR_PARA_LINESPACE
)))
644 for( USHORT i
= nLBCount
- 1; i
> LINESTYLE_HTML_MAX
; --i
)
645 aLbLineStyle
.RemoveEntry(i
);
648 if( !(nSWMode
& SW_BORDER_MODE_TABLE
) )
650 aUserDefFT
.Disable();
652 aWndPresets
.RemoveItem(3);
653 aWndPresets
.RemoveItem(4);
654 aWndPresets
.RemoveItem(5);
659 LinesChanged_Impl( 0 );
662 // -----------------------------------------------------------------------
664 int SvxBorderTabPage::DeactivatePage( SfxItemSet
* _pSet
)
667 FillItemSet( *_pSet
);
672 // -----------------------------------------------------------------------
674 #define IS_DONT_CARE(a) ((a).GetState() == svx::FRAMESTATE_DONTCARE )
676 BOOL
SvxBorderTabPage::FillItemSet( SfxItemSet
& rCoreAttrs
)
678 bool bAttrsChanged
= SfxTabPage::FillItemSet( rCoreAttrs
);
681 USHORT nBoxWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
682 USHORT nBoxInfoWhich
= rCoreAttrs
.GetPool()->GetWhich( SID_ATTR_BORDER_INNER
, sal_False
);
683 const SfxItemSet
& rOldSet
= GetItemSet();
684 SvxBoxItem
aBoxItem ( nBoxWhich
);
685 SvxBoxInfoItem
aBoxInfoItem ( nBoxInfoWhich
);
686 SvxBoxItem
* pOldBoxItem
= (SvxBoxItem
*)GetOldItem( rCoreAttrs
, SID_ATTR_BORDER_OUTER
);
688 SfxMapUnit eCoreUnit
= rOldSet
.GetPool()->GetMetric( nBoxWhich
);
689 const SfxPoolItem
* pOld
= 0;
694 typedef ::std::pair
<svx::FrameBorderType
,USHORT
> TBorderPair
;
695 TBorderPair eTypes1
[] = {
696 TBorderPair(svx::FRAMEBORDER_TOP
,BOX_LINE_TOP
),
697 TBorderPair(svx::FRAMEBORDER_BOTTOM
,BOX_LINE_BOTTOM
),
698 TBorderPair(svx::FRAMEBORDER_LEFT
,BOX_LINE_LEFT
),
699 TBorderPair(svx::FRAMEBORDER_RIGHT
,BOX_LINE_RIGHT
),
702 for (sal_uInt32 i
=0; i
< sizeof(eTypes1
)/sizeof(TBorderPair
); ++i
)
703 aBoxItem
.SetLine( aFrameSel
.GetFrameBorderStyle( eTypes1
[i
].first
), eTypes1
[i
].second
);
705 //--------------------------------
706 // Umrandung hor/ver und TableFlag
707 //--------------------------------
708 TBorderPair eTypes2
[] = {
709 TBorderPair(svx::FRAMEBORDER_HOR
,BOXINFO_LINE_HORI
),
710 TBorderPair(svx::FRAMEBORDER_VER
,BOXINFO_LINE_VERT
)
712 for (sal_uInt32 j
=0; j
< sizeof(eTypes2
)/sizeof(TBorderPair
); ++j
)
713 aBoxInfoItem
.SetLine( aFrameSel
.GetFrameBorderStyle( eTypes2
[j
].first
), eTypes2
[j
].second
);
715 aBoxInfoItem
.EnableHor( mbHorEnabled
);
716 aBoxInfoItem
.EnableVer( mbVerEnabled
);
718 //-------------------
719 // Abstand nach Innen
720 //-------------------
721 if( aLeftMF
.IsVisible() )
723 // #i40405# enable distance controls for next dialog call
724 aBoxInfoItem
.SetDist( TRUE
);
726 if( !mbUseMarginItem
)
728 // #106224# all edits empty: do nothing
729 if( aLeftMF
.GetText().Len() || aRightMF
.GetText().Len() ||
730 aTopMF
.GetText().Len() || aBottomMF
.GetText().Len() )
732 if ( ((mbHorEnabled
|| mbVerEnabled
|| (nSWMode
& SW_BORDER_MODE_TABLE
)) &&
733 (aLeftMF
.IsModified()||aRightMF
.IsModified()||
734 aTopMF
.IsModified()||aBottomMF
.IsModified()) )||
735 aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_TOP
) != svx::FRAMESTATE_HIDE
736 || aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM
) != svx::FRAMESTATE_HIDE
737 || aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_LEFT
) != svx::FRAMESTATE_HIDE
738 || aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_RIGHT
) != svx::FRAMESTATE_HIDE
)
740 SvxBoxInfoItem
* pOldBoxInfoItem
= (SvxBoxInfoItem
*)GetOldItem(
741 rCoreAttrs
, SID_ATTR_BORDER_INNER
);
744 aLeftMF
.GetText() != aLeftMF
.GetSavedValue() ||
745 aRightMF
.GetText() != aRightMF
.GetSavedValue() ||
746 aTopMF
.GetText() != aTopMF
.GetSavedValue() ||
747 aBottomMF
.GetText() != aBottomMF
.GetSavedValue() ||
748 nMinValue
== aLeftMF
.GetValue() ||
749 nMinValue
== aRightMF
.GetValue() ||
750 nMinValue
== aTopMF
.GetValue() ||
751 nMinValue
== aBottomMF
.GetValue() ||
752 (pOldBoxInfoItem
&& !pOldBoxInfoItem
->IsValid(VALID_DISTANCE
))
755 aBoxItem
.SetDistance( (USHORT
)GetCoreValue( aLeftMF
, eCoreUnit
), BOX_LINE_LEFT
);
756 aBoxItem
.SetDistance( (USHORT
)GetCoreValue( aRightMF
, eCoreUnit
), BOX_LINE_RIGHT
);
757 aBoxItem
.SetDistance( (USHORT
)GetCoreValue( aTopMF
, eCoreUnit
), BOX_LINE_TOP
);
758 aBoxItem
.SetDistance( (USHORT
)GetCoreValue( aBottomMF
, eCoreUnit
), BOX_LINE_BOTTOM
);
762 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_LEFT
), BOX_LINE_LEFT
);
763 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_RIGHT
), BOX_LINE_RIGHT
);
764 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_TOP
), BOX_LINE_TOP
);
765 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_BOTTOM
), BOX_LINE_BOTTOM
);
767 aBoxInfoItem
.SetValid( VALID_DISTANCE
, TRUE
);
770 aBoxInfoItem
.SetValid( VALID_DISTANCE
, FALSE
);
775 //------------------------------------------
776 // Don't Care Status im Info-Item vermerken:
777 //------------------------------------------
778 aBoxInfoItem
.SetValid( VALID_TOP
, aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_TOP
) != svx::FRAMESTATE_DONTCARE
);
779 aBoxInfoItem
.SetValid( VALID_BOTTOM
, aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM
) != svx::FRAMESTATE_DONTCARE
);
780 aBoxInfoItem
.SetValid( VALID_LEFT
, aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_LEFT
) != svx::FRAMESTATE_DONTCARE
);
781 aBoxInfoItem
.SetValid( VALID_RIGHT
, aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_RIGHT
) != svx::FRAMESTATE_DONTCARE
);
782 aBoxInfoItem
.SetValid( VALID_HORI
, aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_HOR
) != svx::FRAMESTATE_DONTCARE
);
783 aBoxInfoItem
.SetValid( VALID_VERT
, aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_VER
) != svx::FRAMESTATE_DONTCARE
);
786 // Put oder Clear der Umrandung?
790 if ( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nBoxWhich
, FALSE
))
792 bPut
= aBoxItem
!= (const SvxBoxItem
&)(rOldSet
.Get(nBoxWhich
)) ? sal_True
: sal_False
;
794 if( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nBoxInfoWhich
, FALSE
) )
796 const SvxBoxInfoItem
& rOldBoxInfo
= (const SvxBoxInfoItem
&)
797 rOldSet
.Get(nBoxInfoWhich
);
799 aBoxInfoItem
.SetMinDist( rOldBoxInfo
.IsMinDist() );
800 aBoxInfoItem
.SetDefDist( rOldBoxInfo
.GetDefDist() );
801 bPut
|= (aBoxInfoItem
!= rOldBoxInfo
);
806 if ( !pOldBoxItem
|| !( *pOldBoxItem
== aBoxItem
) )
808 rCoreAttrs
.Put( aBoxItem
);
809 bAttrsChanged
|= TRUE
;
811 pOld
= GetOldItem( rCoreAttrs
, SID_ATTR_BORDER_INNER
, sal_False
);
813 if ( !pOld
|| !( *(const SvxBoxInfoItem
*)pOld
== aBoxInfoItem
) )
815 rCoreAttrs
.Put( aBoxInfoItem
);
816 bAttrsChanged
|= TRUE
;
821 rCoreAttrs
.ClearItem( nBoxWhich
);
822 rCoreAttrs
.ClearItem( nBoxInfoWhich
);
825 return bAttrsChanged
;
828 // -----------------------------------------------------------------------
830 void SvxBorderTabPage::HideShadowControls()
834 aFtShadowSize
.Hide();
835 aEdShadowSize
.Hide();
836 aFtShadowColor
.Hide();
837 aLbShadowColor
.Hide();
841 // -----------------------------------------------------------------------
843 IMPL_LINK( SvxBorderTabPage
, SelPreHdl_Impl
, void *, EMPTYARG
)
845 const svx::FrameBorderState SHOW
= svx::FRAMESTATE_SHOW
;
846 const svx::FrameBorderState HIDE
= svx::FRAMESTATE_HIDE
;
847 const svx::FrameBorderState DONT
= svx::FRAMESTATE_DONTCARE
;
849 static const svx::FrameBorderState ppeStates
[][ svx::FRAMEBORDERTYPE_COUNT
] =
850 { /* Left Right Top Bot Hor Ver TLBR BLTR */
851 /* ---------------------+--------------------------------------------------- */
852 /* IID_PRE_CELL_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
853 /* IID_PRE_CELL_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
854 /* IID_PRE_CELL_LR */ { SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
855 /* IID_PRE_CELL_TB */ { HIDE
, HIDE
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
856 /* IID_PRE_CELL_L */ { SHOW
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
857 /* IID_PRE_CELL_DIAG */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, SHOW
, SHOW
},
858 /* IID_PRE_HOR_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
859 /* IID_PRE_HOR_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
860 /* IID_PRE_HOR_HOR */ { HIDE
, HIDE
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
861 /* IID_PRE_HOR_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
862 /* IID_PRE_HOR_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, DONT
, HIDE
, HIDE
, HIDE
},
863 /* IID_PRE_VER_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
864 /* IID_PRE_VER_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
865 /* IID_PRE_VER_VER */ { SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, SHOW
, HIDE
, HIDE
},
866 /* IID_PRE_VER_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, SHOW
, HIDE
, HIDE
},
867 /* IID_PRE_VER_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, DONT
, HIDE
, HIDE
},
868 /* IID_PRE_TABLE_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
869 /* IID_PRE_TABLE_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
870 /* IID_PRE_TABLE_OUTERH */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
871 /* IID_PRE_TABLE_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
},
872 /* IID_PRE_TABLE_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, DONT
, DONT
, HIDE
, HIDE
}
875 // first hide and deselect all frame borders
876 aFrameSel
.HideAllBorders();
877 aFrameSel
.DeselectAllBorders();
879 // Using image ID to find correct line in table above.
880 USHORT nLine
= GetPresetImageId( aWndPresets
.GetSelectItemId() ) - 1;
882 // Apply all styles from the table
883 for( int nBorder
= 0; nBorder
< svx::FRAMEBORDERTYPE_COUNT
; ++nBorder
)
885 svx::FrameBorderType eBorder
= svx::GetFrameBorderTypeFromIndex( nBorder
);
886 switch( ppeStates
[ nLine
][ nBorder
] )
888 case SHOW
: aFrameSel
.SelectBorder( eBorder
); break;
889 case HIDE
: /* nothing to do */ break;
890 case DONT
: aFrameSel
.SetBorderDontCare( eBorder
); break;
894 // Show all lines that have been selected above
895 if( aFrameSel
.IsAnyBorderSelected() )
897 // any visible style, but "no-line" in line list box? -> use hair-line
898 if( (aLbLineStyle
.GetSelectEntryPos() == 0) || (aLbLineStyle
.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND
) )
899 aLbLineStyle
.SelectEntryPos( 1 );
901 // set current style to all previously selected lines
902 SelStyleHdl_Impl( &aLbLineStyle
);
903 SelColHdl_Impl( &aLbLineColor
);
906 // Presets ValueSet does not show a selection (used as push buttons).
907 aWndPresets
.SetNoSelection();
909 LinesChanged_Impl( 0 );
913 // -----------------------------------------------------------------------
915 IMPL_LINK( SvxBorderTabPage
, SelSdwHdl_Impl
, void *, EMPTYARG
)
917 BOOL bEnable
= aWndShadows
.GetSelectItemId() > 1;
918 aFtShadowSize
.Enable(bEnable
);
919 aEdShadowSize
.Enable(bEnable
);
920 aFtShadowColor
.Enable(bEnable
);
921 aLbShadowColor
.Enable(bEnable
);
925 // -----------------------------------------------------------------------
927 IMPL_LINK( SvxBorderTabPage
, SelColHdl_Impl
, ListBox
*, pLb
)
929 ColorListBox
* pColLb
= (ColorListBox
*)pLb
;
931 if ( pLb
== &aLbLineColor
)
933 aFrameSel
.SetColorToSelection( pColLb
->GetSelectEntryColor() );
934 aLbLineStyle
.SetColor( pColLb
->GetSelectEntryColor() );
940 // -----------------------------------------------------------------------
942 IMPL_LINK( SvxBorderTabPage
, SelStyleHdl_Impl
, ListBox
*, pLb
)
944 if ( pLb
== &aLbLineStyle
)
945 aFrameSel
.SetStyleToSelection(
946 static_cast< USHORT
>( aLbLineStyle
.GetSelectEntryLine1() / 100 ),
947 static_cast< USHORT
>( aLbLineStyle
.GetSelectEntryDistance() / 100 ),
948 static_cast< USHORT
>( aLbLineStyle
.GetSelectEntryLine2() / 100 ) );
953 // ============================================================================
955 // ============================================================================
957 // number of preset images to show
958 const USHORT SVX_BORDER_PRESET_COUNT
= 5;
960 // number of shadow images to show
961 const USHORT SVX_BORDER_SHADOW_COUNT
= 5;
963 // ----------------------------------------------------------------------------
965 USHORT
SvxBorderTabPage::GetPresetImageId( USHORT nValueSetIdx
) const
967 // table with all sets of predefined border styles
968 static const USHORT ppnImgIds
[][ SVX_BORDER_PRESET_COUNT
] =
970 // simple cell without diagonal frame borders
971 { IID_PRE_CELL_NONE
, IID_PRE_CELL_ALL
, IID_PRE_CELL_LR
, IID_PRE_CELL_TB
, IID_PRE_CELL_L
},
972 // simple cell with diagonal frame borders
973 { IID_PRE_CELL_NONE
, IID_PRE_CELL_ALL
, IID_PRE_CELL_LR
, IID_PRE_CELL_TB
, IID_PRE_CELL_DIAG
},
974 // with horizontal inner frame border
975 { IID_PRE_HOR_NONE
, IID_PRE_HOR_OUTER
, IID_PRE_HOR_HOR
, IID_PRE_HOR_ALL
, IID_PRE_HOR_OUTER2
},
976 // with vertical inner frame border
977 { IID_PRE_VER_NONE
, IID_PRE_VER_OUTER
, IID_PRE_VER_VER
, IID_PRE_VER_ALL
, IID_PRE_VER_OUTER2
},
978 // with horizontal and vertical inner frame borders
979 { IID_PRE_TABLE_NONE
, IID_PRE_TABLE_OUTER
, IID_PRE_TABLE_OUTERH
, IID_PRE_TABLE_ALL
, IID_PRE_TABLE_OUTER2
}
982 // find correct set of presets
984 if( !mbHorEnabled
&& !mbVerEnabled
)
985 nLine
= (mbTLBREnabled
|| mbBLTREnabled
) ? 1 : 0;
986 else if( mbHorEnabled
&& !mbVerEnabled
)
988 else if( !mbHorEnabled
&& mbVerEnabled
)
993 DBG_ASSERT( (1 <= nValueSetIdx
) && (nValueSetIdx
<= SVX_BORDER_PRESET_COUNT
),
994 "SvxBorderTabPage::GetPresetImageId - wrong index" );
995 return ppnImgIds
[ nLine
][ nValueSetIdx
- 1 ];
998 USHORT
SvxBorderTabPage::GetPresetStringId( USHORT nValueSetIdx
) const
1000 // string resource IDs for each image (in order of the IID_PRE_* image IDs)
1001 static const USHORT pnStrIds
[] =
1003 RID_SVXSTR_TABLE_PRESET_NONE
,
1004 RID_SVXSTR_PARA_PRESET_ALL
,
1005 RID_SVXSTR_PARA_PRESET_LEFTRIGHT
,
1006 RID_SVXSTR_PARA_PRESET_TOPBOTTOM
,
1007 RID_SVXSTR_PARA_PRESET_ONLYLEFT
,
1008 RID_SVXSTR_PARA_PRESET_DIAGONAL
,
1010 RID_SVXSTR_TABLE_PRESET_NONE
,
1011 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
1012 RID_SVXSTR_HOR_PRESET_ONLYHOR
,
1013 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
1014 RID_SVXSTR_TABLE_PRESET_OUTERINNER
,
1016 RID_SVXSTR_TABLE_PRESET_NONE
,
1017 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
1018 RID_SVXSTR_VER_PRESET_ONLYVER
,
1019 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
1020 RID_SVXSTR_TABLE_PRESET_OUTERINNER
,
1022 RID_SVXSTR_TABLE_PRESET_NONE
,
1023 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
1024 RID_SVXSTR_TABLE_PRESET_OUTERHORI
,
1025 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
1026 RID_SVXSTR_TABLE_PRESET_OUTERINNER
1028 return pnStrIds
[ GetPresetImageId( nValueSetIdx
) - 1 ];
1031 // ----------------------------------------------------------------------------
1033 void SvxBorderTabPage::FillPresetVS()
1035 // find correct image list
1036 bool bDark
= aWndPresets
.GetDisplayBackground().GetColor().IsDark();
1037 ImageList
& rImgList
= bDark
? aBorderImgLstH
: aBorderImgLst
;
1038 Size
aImgSize( rImgList
.GetImage( IID_PRE_CELL_NONE
).GetSizePixel() );
1040 // basic initialization of the ValueSet
1041 aWndPresets
.SetColCount( SVX_BORDER_PRESET_COUNT
);
1042 aWndPresets
.SetStyle( aWndPresets
.GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
1043 aWndPresets
.SetSizePixel( aWndPresets
.CalcWindowSizePixel( aImgSize
) );
1045 // insert images and help texts
1046 for( USHORT nVSIdx
= 1; nVSIdx
<= SVX_BORDER_PRESET_COUNT
; ++nVSIdx
)
1048 aWndPresets
.InsertItem( nVSIdx
);
1049 aWndPresets
.SetItemImage( nVSIdx
, rImgList
.GetImage( GetPresetImageId( nVSIdx
) ) );
1050 aWndPresets
.SetItemText( nVSIdx
, SVX_RESSTR( GetPresetStringId( nVSIdx
) ) );
1054 aWndPresets
.SetNoSelection();
1058 // ----------------------------------------------------------------------------
1060 void SvxBorderTabPage::FillShadowVS()
1062 // find correct image list
1063 bool bDark
= aWndShadows
.GetDisplayBackground().GetColor().IsDark();
1064 ImageList
& rImgList
= bDark
? aShadowImgLstH
: aShadowImgLst
;
1065 Size
aImgSize( rImgList
.GetImage( IID_SHADOWNONE
).GetSizePixel() );
1067 // basic initialization of the ValueSet
1068 aWndShadows
.SetColCount( SVX_BORDER_SHADOW_COUNT
);
1069 aWndShadows
.SetStyle( aWndShadows
.GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
1070 aWndShadows
.SetSizePixel( aWndShadows
.CalcWindowSizePixel( aImgSize
) );
1072 // image resource IDs
1073 static const USHORT pnImgIds
[ SVX_BORDER_SHADOW_COUNT
] =
1074 { IID_SHADOWNONE
, IID_SHADOW_BOT_RIGHT
, IID_SHADOW_TOP_RIGHT
, IID_SHADOW_BOT_LEFT
, IID_SHADOW_TOP_LEFT
};
1075 // string resource IDs for each image
1076 static const USHORT pnStrIds
[ SVX_BORDER_SHADOW_COUNT
] =
1077 { RID_SVXSTR_SHADOW_STYLE_NONE
, RID_SVXSTR_SHADOW_STYLE_BOTTOMRIGHT
, RID_SVXSTR_SHADOW_STYLE_TOPRIGHT
, RID_SVXSTR_SHADOW_STYLE_BOTTOMLEFT
, RID_SVXSTR_SHADOW_STYLE_TOPLEFT
};
1079 // insert images and help texts
1080 for( USHORT nVSIdx
= 1; nVSIdx
<= SVX_BORDER_SHADOW_COUNT
; ++nVSIdx
)
1082 aWndShadows
.InsertItem( nVSIdx
);
1083 aWndShadows
.SetItemImage( nVSIdx
, rImgList
.GetImage( pnImgIds
[ nVSIdx
- 1 ] ) );
1084 aWndShadows
.SetItemText( nVSIdx
, SVX_RESSTR( pnStrIds
[ nVSIdx
- 1 ] ) );
1088 aWndShadows
.SelectItem( 1 );
1092 // ----------------------------------------------------------------------------
1094 void SvxBorderTabPage::FillValueSets()
1100 // ============================================================================
1102 void SvxBorderTabPage::FillLineListBox_Impl()
1104 aLbLineStyle
.SetUnit( FUNIT_POINT
);
1105 aLbLineStyle
.SetSourceUnit( FUNIT_TWIP
);
1107 // Writer 2.0 Defaults:
1108 aLbLineStyle
.InsertEntry( SVX_RESSTR( STR_NONE
) );
1110 aLbLineStyle
.InsertEntry( LINE_WIDTH0
);
1111 aLbLineStyle
.InsertEntry( LINE_WIDTH5
);
1112 aLbLineStyle
.InsertEntry( LINE_WIDTH1
);
1113 aLbLineStyle
.InsertEntry( LINE_WIDTH2
);
1114 aLbLineStyle
.InsertEntry( LINE_WIDTH3
);
1115 aLbLineStyle
.InsertEntry( LINE_WIDTH4
);
1117 // OS: wenn hier neue Linienstaerken zugfuegt werden, dann
1118 // LINESTYLE_HTML_MAX anpassen
1120 aLbLineStyle
.InsertEntry( DLINE0_OUT
, DLINE0_IN
, DLINE0_DIST
);
1121 aLbLineStyle
.InsertEntry( DLINE7_OUT
, DLINE7_IN
, DLINE7_DIST
);
1122 aLbLineStyle
.InsertEntry( DLINE1_OUT
, DLINE1_IN
, DLINE1_DIST
);
1123 aLbLineStyle
.InsertEntry( DLINE2_OUT
, DLINE2_IN
, DLINE2_DIST
);
1124 aLbLineStyle
.InsertEntry( DLINE8_OUT
, DLINE8_IN
, DLINE8_DIST
);
1125 aLbLineStyle
.InsertEntry( DLINE9_OUT
, DLINE9_IN
, DLINE9_DIST
);
1126 aLbLineStyle
.InsertEntry( DLINE10_OUT
,DLINE10_IN
,DLINE10_DIST
);
1127 aLbLineStyle
.InsertEntry( DLINE3_OUT
, DLINE3_IN
, DLINE3_DIST
);
1128 aLbLineStyle
.InsertEntry( DLINE4_OUT
, DLINE4_IN
, DLINE4_DIST
);
1129 aLbLineStyle
.InsertEntry( DLINE5_OUT
, DLINE5_IN
, DLINE5_DIST
);
1130 aLbLineStyle
.InsertEntry( DLINE6_OUT
, DLINE6_IN
, DLINE6_DIST
);
1133 // -----------------------------------------------------------------------
1134 IMPL_LINK( SvxBorderTabPage
, LinesChanged_Impl
, void*, EMPTYARG
)
1136 if(!mbUseMarginItem
&& aLeftMF
.IsVisible())
1138 BOOL bLineSet
= aFrameSel
.IsAnyBorderVisible();
1139 BOOL bMinAllowed
= 0 != (nSWMode
& (SW_BORDER_MODE_FRAME
|SW_BORDER_MODE_TABLE
));
1140 BOOL bSpaceModified
= aLeftMF
.IsModified()||
1141 aRightMF
.IsModified()||
1142 aTopMF
.IsModified()||
1143 aBottomMF
.IsModified();
1149 aLeftMF
.SetFirst(nMinValue
);
1150 aRightMF
.SetFirst(nMinValue
);
1151 aTopMF
.SetFirst(nMinValue
);
1152 aBottomMF
.SetFirst(nMinValue
);
1156 aLeftMF
.SetValue(nMinValue
);
1157 aRightMF
.SetValue(nMinValue
);
1158 aTopMF
.SetValue(nMinValue
);
1159 aBottomMF
.SetValue(nMinValue
);
1165 aRightMF
.SetMin(0);
1167 aBottomMF
.SetMin(0);
1168 aLeftMF
.SetFirst(0);
1169 aRightMF
.SetFirst(0);
1170 aTopMF
.SetFirst(0);
1171 aBottomMF
.SetFirst(0);
1174 aLeftMF
.SetValue(0);
1175 aRightMF
.SetValue(0);
1176 aTopMF
.SetValue(0);
1177 aBottomMF
.SetValue(0);
1180 //fuer Tabellen ist alles erlaubt
1181 USHORT nValid
= VALID_TOP
|VALID_BOTTOM
|VALID_LEFT
|VALID_RIGHT
;
1183 //fuer Rahmen und Absatz wird das Edit disabled, wenn keine Border gesetzt ist
1184 if(nSWMode
& (SW_BORDER_MODE_FRAME
|SW_BORDER_MODE_PARA
))
1188 nValid
= (aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_TOP
) == svx::FRAMESTATE_SHOW
) ? VALID_TOP
: 0;
1189 nValid
|= (aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM
) == svx::FRAMESTATE_SHOW
) ? VALID_BOTTOM
: 0;
1190 nValid
|= (aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_LEFT
) == svx::FRAMESTATE_SHOW
) ? VALID_LEFT
: 0;
1191 nValid
|= (aFrameSel
.GetFrameBorderState( svx::FRAMEBORDER_RIGHT
) == svx::FRAMESTATE_SHOW
) ? VALID_RIGHT
: 0;
1196 aLeftFT
.Enable(0 != (nValid
&VALID_LEFT
));
1197 aRightFT
.Enable(0 != (nValid
&VALID_RIGHT
));
1198 aTopFT
.Enable(0 != (nValid
&VALID_TOP
));
1199 aBottomFT
.Enable(0 != (nValid
&VALID_BOTTOM
));
1200 aLeftMF
.Enable(0 != (nValid
&VALID_LEFT
));
1201 aRightMF
.Enable(0 != (nValid
&VALID_RIGHT
));
1202 aTopMF
.Enable(0 != (nValid
&VALID_TOP
));
1203 aBottomMF
.Enable(0 != (nValid
&VALID_BOTTOM
));
1204 aSynchronizeCB
.Enable( aRightMF
.IsEnabled() || aTopMF
.IsEnabled() ||
1205 aBottomMF
.IsEnabled() || aLeftMF
.IsEnabled() );
1210 // -----------------------------------------------------------------------
1212 IMPL_LINK( SvxBorderTabPage
, ModifyDistanceHdl_Impl
, MetricField
*, pField
)
1216 sal_Int64 nVal
= pField
->GetValue();
1217 if(pField
!= &aLeftMF
)
1218 aLeftMF
.SetValue(nVal
);
1219 if(pField
!= &aRightMF
)
1220 aRightMF
.SetValue(nVal
);
1221 if(pField
!= &aTopMF
)
1222 aTopMF
.SetValue(nVal
);
1223 if(pField
!= &aBottomMF
)
1224 aBottomMF
.SetValue(nVal
);
1229 IMPL_LINK( SvxBorderTabPage
, SyncHdl_Impl
, CheckBox
*, pBox
)
1231 bSync
= pBox
->IsChecked();
1235 /* -----------------------------03.06.2002 10:15------------------------------
1237 ---------------------------------------------------------------------------*/
1238 void SvxBorderTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
1240 if( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1243 SfxTabPage::DataChanged( rDCEvt
);
1246 void SvxBorderTabPage::PageCreated (SfxAllItemSet aSet
) //add CHINA001
1248 SFX_ITEMSET_ARG (&aSet
,pSWModeItem
,SfxUInt16Item
,SID_SWMODE_TYPE
,sal_False
);
1249 SFX_ITEMSET_ARG (&aSet
,pFlagItem
,SfxUInt32Item
,SID_FLAG_TYPE
,sal_False
);
1252 nSWMode
= pSWModeItem
->GetValue();
1253 // --> OD 2005-03-01 #i43593#
1254 // show checkbox <aMergeWithNextCB> for format.paragraph
1255 if ( nSWMode
== SW_BORDER_MODE_PARA
)
1257 aMergeWithNextCB
.Show();
1258 aPropertiesFL
.Show();
1260 // show checkbox <aMergeAdjacentBordersCB> for format.paragraph
1261 else if ( nSWMode
== SW_BORDER_MODE_TABLE
)
1263 aMergeAdjacentBordersCB
.Show();
1264 aPropertiesFL
.Show();
1269 if ( ( pFlagItem
->GetValue() & SVX_HIDESHADOWCTL
) == SVX_HIDESHADOWCTL
)
1270 HideShadowControls();
1273 // ============================================================================