masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / tabpages / border.cxx
blob9140a2f0e4c295ef2b7c30c788c7c7cd7f73f223
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <sfx2/app.hxx>
33 #include <sfx2/objsh.hxx>
34 #include <sfx2/module.hxx>
35 #include <svx/dialogs.hrc>
36 #include <svx/dialmgr.hxx>
37 #define _SVX_BORDER_CXX
39 #include <cuires.hrc>
40 #include "border.hrc"
41 #include "helpid.hrc"
43 #define LINESTYLE_HTML_MAX 5
45 #include <svx/xtable.hxx> // XColorTable
46 #include <svx/drawitem.hxx>
47 #include <editeng/boxitem.hxx>
48 #include <editeng/shaditem.hxx>
49 #include "border.hxx"
50 #include <svx/dlgutil.hxx>
51 #include <dialmgr.hxx>
52 #include "svx/htmlmode.hxx"
53 #include <vcl/msgbox.hxx>
54 #include "svx/flagsdef.hxx" //CHINA001
55 #include <sfx2/request.hxx>
56 #include <svl/intitem.hxx> //CHINA001
57 #include <sfx2/itemconnect.hxx>
58 #include "borderconn.hxx"
60 // -----------------------------------------------------------------------
63 * [Beschreibung:]
64 * TabPage zum Einstellen der Rahmen-Attribute.
65 * Benoetigt
66 * ein SvxShadowItem: Schatten
67 * ein SvxBoxItem: Linien links,rechts,oben,unten ),
68 * ein SvxBoxInfo: Linien vertikal,horizontal, Abstaende, Flags )
70 * Linien koennen drei Zustaende haben.
71 * 1. Show ( -> gueltige Werte )
72 * 2. Hide ( -> NULL-Pointer )
73 * 3. DontCare ( -> gesonderte Valid-Flags im InfoItem )
76 // static ----------------------------------------------------------------
78 static sal_uInt16 pRanges[] =
80 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
81 SID_ATTR_ALIGN_MARGIN, SID_ATTR_ALIGN_MARGIN,
82 SID_ATTR_BORDER_CONNECT, SID_ATTR_BORDER_CONNECT,
83 SID_SW_COLLAPSING_BORDERS, SID_SW_COLLAPSING_BORDERS,
84 SID_ATTR_BORDER_DIAG_TLBR, SID_ATTR_BORDER_DIAG_BLTR,
88 sal_Bool SvxBorderTabPage::bSync = sal_True;
91 //------------------------------------------------------------------------
93 #define LINE_WIDTH0 (DEF_LINE_WIDTH_0 *100)
94 #define LINE_WIDTH1 (DEF_LINE_WIDTH_1 *100)
95 #define LINE_WIDTH2 (DEF_LINE_WIDTH_2 *100)
96 #define LINE_WIDTH3 (DEF_LINE_WIDTH_3 *100)
97 #define LINE_WIDTH4 (DEF_LINE_WIDTH_4 *100)
98 #define LINE_WIDTH5 (DEF_LINE_WIDTH_5 *100)
100 #define DLINE0_OUT (DEF_DOUBLE_LINE0_OUT *100)
101 #define DLINE0_IN (DEF_DOUBLE_LINE0_IN *100)
102 #define DLINE0_DIST (DEF_DOUBLE_LINE0_DIST *100)
104 #define DLINE1_OUT (DEF_DOUBLE_LINE1_OUT *100)
105 #define DLINE1_IN (DEF_DOUBLE_LINE1_IN *100)
106 #define DLINE1_DIST (DEF_DOUBLE_LINE1_DIST *100)
108 #define DLINE2_OUT (DEF_DOUBLE_LINE2_OUT *100)
109 #define DLINE2_IN (DEF_DOUBLE_LINE2_IN *100)
110 #define DLINE2_DIST (DEF_DOUBLE_LINE2_DIST *100)
112 #define DLINE3_OUT (DEF_DOUBLE_LINE3_OUT *100)
113 #define DLINE3_IN (DEF_DOUBLE_LINE3_IN *100)
114 #define DLINE3_DIST (DEF_DOUBLE_LINE3_DIST *100)
116 #define DLINE4_OUT (DEF_DOUBLE_LINE4_OUT *100)
117 #define DLINE4_IN (DEF_DOUBLE_LINE4_IN *100)
118 #define DLINE4_DIST (DEF_DOUBLE_LINE4_DIST *100)
120 #define DLINE5_OUT (DEF_DOUBLE_LINE5_OUT *100)
121 #define DLINE5_IN (DEF_DOUBLE_LINE5_IN *100)
122 #define DLINE5_DIST (DEF_DOUBLE_LINE5_DIST *100)
124 #define DLINE6_OUT (DEF_DOUBLE_LINE6_OUT *100)
125 #define DLINE6_IN (DEF_DOUBLE_LINE6_IN *100)
126 #define DLINE6_DIST (DEF_DOUBLE_LINE6_DIST *100)
128 #define DLINE7_OUT (DEF_DOUBLE_LINE7_OUT *100)
129 #define DLINE7_IN (DEF_DOUBLE_LINE7_IN *100)
130 #define DLINE7_DIST (DEF_DOUBLE_LINE7_DIST *100)
132 #define DLINE8_OUT (DEF_DOUBLE_LINE8_OUT *100)
133 #define DLINE8_IN (DEF_DOUBLE_LINE8_IN *100)
134 #define DLINE8_DIST (DEF_DOUBLE_LINE8_DIST *100)
136 #define DLINE9_OUT (DEF_DOUBLE_LINE9_OUT *100)
137 #define DLINE9_IN (DEF_DOUBLE_LINE9_IN *100)
138 #define DLINE9_DIST (DEF_DOUBLE_LINE9_DIST *100)
140 #define DLINE10_OUT (DEF_DOUBLE_LINE10_OUT *100)
141 #define DLINE10_IN (DEF_DOUBLE_LINE10_IN *100)
142 #define DLINE10_DIST (DEF_DOUBLE_LINE10_DIST*100)
144 #define RGBCOL(eColorName) (TpBorderRGBColor(eColorName))
146 // LOKALE FUNKTION
147 // Konvertiert in echte RGB-Farben, damit in den Listboxen
148 // endlich mal richtig selektiert werden kann.
150 Color TpBorderRGBColor( ColorData aColorData )
152 Color aRGBColor( aColorData );
154 return( aRGBColor );
157 // -----------------------------------------------------------------------
158 void lcl_SetDecimalDigitsTo1(MetricField& rField)
160 sal_Int64 nMin = rField.Denormalize( rField.GetMin( FUNIT_TWIP ) );
161 rField.SetDecimalDigits(1);
162 rField.SetMin( rField.Normalize( nMin ), FUNIT_TWIP );
164 // -----------------------------------------------------------------------
166 SvxBorderTabPage::SvxBorderTabPage( Window* pParent,
167 const SfxItemSet& rCoreAttrs )
169 : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_BORDER ), rCoreAttrs ),
171 aFlBorder ( this, CUI_RES( FL_BORDER ) ),
172 aDefaultFT ( this, CUI_RES( FT_DEFAULT ) ),
173 aWndPresets ( this, CUI_RES( WIN_PRESETS ) ),
174 aUserDefFT ( this, CUI_RES( FT_USERDEF ) ),
175 aFrameSel ( this, CUI_RES( WIN_FRAMESEL ) ),
177 aFlSep1 ( this, CUI_RES( FL_SEPARATOR1 ) ),
178 aFlLine ( this, CUI_RES( FL_LINE ) ),
179 aStyleFT ( this, CUI_RES( FT_STYLE ) ),
180 aLbLineStyle ( this, CUI_RES( LB_LINESTYLE ) ),
181 aColorFT ( this, CUI_RES( FT_COLOR ) ),
182 aLbLineColor ( this, CUI_RES( LB_LINECOLOR ) ),
184 aFlSep2 ( this, CUI_RES( FL_SEPARATOR2 ) ),
185 aDistanceFL ( this, CUI_RES( FL_DISTANCE ) ),
186 aLeftFT ( this, CUI_RES( FT_LEFT ) ),
187 aLeftMF ( this, CUI_RES( MF_LEFT ) ),
188 aRightFT ( this, CUI_RES( FT_RIGHT ) ),
189 aRightMF ( this, CUI_RES( MF_RIGHT ) ),
190 aTopFT ( this, CUI_RES( FT_TOP ) ),
191 aTopMF ( this, CUI_RES( MF_TOP ) ),
192 aBottomFT ( this, CUI_RES( FT_BOTTOM ) ),
193 aBottomMF ( this, CUI_RES( MF_BOTTOM ) ),
194 aSynchronizeCB ( this, CUI_RES( CB_SYNC ) ),
196 aFlShadow ( this, CUI_RES( FL_SHADOW ) ),
197 aFtShadowPos ( this, CUI_RES( FT_SHADOWPOS ) ),
198 aWndShadows ( this, CUI_RES( WIN_SHADOWS ) ),
199 aFtShadowSize ( this, CUI_RES( FT_SHADOWSIZE ) ),
200 aEdShadowSize ( this, CUI_RES( ED_SHADOWSIZE ) ),
201 aFtShadowColor ( this, CUI_RES( FT_SHADOWCOLOR ) ),
202 aLbShadowColor ( this, CUI_RES( LB_SHADOWCOLOR ) ),
203 aPropertiesFL ( this, CUI_RES( FL_PROPERTIES ) ),
204 aMergeWithNextCB( this, CUI_RES( CB_MERGEWITHNEXT ) ),
205 aMergeAdjacentBordersCB( this, CUI_RES( CB_MERGEADJACENTBORDERS ) ),
206 aShadowImgLstH( CUI_RES(ILH_SDW_BITMAPS)),
207 aShadowImgLst( CUI_RES(IL_SDW_BITMAPS)),
208 aBorderImgLstH( CUI_RES(ILH_PRE_BITMAPS)),
209 aBorderImgLst( CUI_RES(IL_PRE_BITMAPS)),
210 nMinValue(0),
211 nSWMode(0),
212 mbHorEnabled( false ),
213 mbVerEnabled( false ),
214 mbTLBREnabled( false ),
215 mbBLTREnabled( false ),
216 mbUseMarginItem( false )
219 // diese Page braucht ExchangeSupport
220 SetExchangeSupport();
222 /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
223 -> Remember this state in mbUseMarginItem, because other special handling
224 is needed across various functions... */
225 mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN),sal_True) != SFX_ITEM_UNKNOWN;
227 // Metrik einstellen
228 FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
230 if( mbUseMarginItem )
232 // copied from SvxAlignmentTabPage
233 switch ( eFUnit )
235 // #103396# the default value (1pt) can't be accurately represented in
236 // inches or pica with two decimals, so point is used instead.
237 case FUNIT_PICA:
238 case FUNIT_INCH:
239 case FUNIT_FOOT:
240 case FUNIT_MILE:
241 eFUnit = FUNIT_POINT;
242 break;
244 case FUNIT_CM:
245 case FUNIT_M:
246 case FUNIT_KM:
247 eFUnit = FUNIT_MM;
248 break;
249 default: ;//prevent warning
252 else
254 switch ( eFUnit )
256 case FUNIT_M:
257 case FUNIT_KM:
258 eFUnit = FUNIT_MM;
259 break;
260 default: ; //prevent warning
264 SetFieldUnit( aEdShadowSize, eFUnit );
266 sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, sal_False );
267 sal_Bool bIsDontCare = sal_True;
269 if ( rCoreAttrs.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
271 // Absatz oder Tabelle
272 const SvxBoxInfoItem* pBoxInfo =
273 (const SvxBoxInfoItem*)&( rCoreAttrs.Get( nWhich ) );
275 mbHorEnabled = pBoxInfo->IsHorEnabled();
276 mbVerEnabled = pBoxInfo->IsVerEnabled();
277 mbTLBREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR );
278 mbBLTREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR );
280 if(pBoxInfo->IsDist())
282 SetFieldUnit(aLeftMF, eFUnit);
283 SetFieldUnit(aRightMF, eFUnit);
284 SetFieldUnit(aTopMF, eFUnit);
285 SetFieldUnit(aBottomMF, eFUnit);
286 aSynchronizeCB.Check(bSync);
287 aSynchronizeCB.SetClickHdl(LINK(this, SvxBorderTabPage, SyncHdl_Impl));
288 aLeftMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
289 aRightMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
290 aTopMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
291 aBottomMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
293 else
295 aFlSep2.Hide();
296 aDistanceFL.Hide();
297 aLeftFT.Hide();
298 aLeftMF.Hide();
299 aRightFT.Hide();
300 aRightMF.Hide();
301 aTopFT.Hide();
302 aTopMF.Hide();
303 aBottomFT.Hide();
304 aBottomMF.Hide();
305 aSynchronizeCB.Hide();
307 bIsDontCare = !pBoxInfo->IsValid( VALID_DISABLE );
309 if(!mbUseMarginItem && eFUnit == FUNIT_MM && SFX_MAPUNIT_TWIP == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
311 //#i91548# changing the number of decimal digits changes the minimum values, too
312 lcl_SetDecimalDigitsTo1(aLeftMF);
313 lcl_SetDecimalDigitsTo1(aRightMF);
314 lcl_SetDecimalDigitsTo1(aTopMF);
315 lcl_SetDecimalDigitsTo1(aBottomMF);
316 lcl_SetDecimalDigitsTo1(aEdShadowSize);
319 svx::FrameSelFlags nFlags = svx::FRAMESEL_OUTER;
320 if( mbHorEnabled )
321 nFlags |= svx::FRAMESEL_INNER_HOR;
322 if( mbVerEnabled )
323 nFlags |= svx::FRAMESEL_INNER_VER;
324 if( mbTLBREnabled )
325 nFlags |= svx::FRAMESEL_DIAG_TLBR;
326 if( mbBLTREnabled )
327 nFlags |= svx::FRAMESEL_DIAG_BLTR;
328 if( bIsDontCare )
329 nFlags |= svx::FRAMESEL_DONTCARE;
330 aFrameSel.Initialize( nFlags );
332 aFrameSel.SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
333 aLbLineStyle.SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
334 aLbLineColor.SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
335 aLbShadowColor.SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
336 aWndPresets.SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
337 aWndShadows.SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
339 FillValueSets();
340 FillLineListBox_Impl();
342 // ColorBox aus der XColorTable fuellen.
343 SfxObjectShell* pDocSh = SfxObjectShell::Current();
344 const SfxPoolItem* pItem = NULL;
345 XColorTable* pColorTable = NULL;
347 DBG_ASSERT( pDocSh, "DocShell not found!" );
349 if ( pDocSh )
351 pItem = pDocSh->GetItem( SID_COLOR_TABLE );
352 if ( pItem != NULL )
353 pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
356 DBG_ASSERT( pColorTable, "ColorTable not found!" );
358 if ( pColorTable )
360 // fuellen der Linienfarben-Box
361 aLbLineColor.SetUpdateMode( sal_False );
363 for ( long i = 0; i < pColorTable->Count(); ++i )
365 XColorEntry* pEntry = pColorTable->GetColor(i);
366 aLbLineColor.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
368 aLbLineColor.SetUpdateMode( sal_True );
369 // dann nur noch in die Schattenfarben-Box kopieren
370 aLbShadowColor.CopyEntries( aLbLineColor );
372 FreeResource();
374 // connections
376 bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW ) );
377 if( bSupportsShadow )
378 AddItemConnection( svx::CreateShadowConnection( rCoreAttrs, aWndShadows, aEdShadowSize, aLbShadowColor ) );
379 else
380 HideShadowControls();
382 if( mbUseMarginItem )
383 AddItemConnection( svx::CreateMarginConnection( rCoreAttrs, aLeftMF, aRightMF, aTopMF, aBottomMF ) );
384 if( aFrameSel.IsBorderEnabled( svx::FRAMEBORDER_TLBR ) )
385 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR, aFrameSel, svx::FRAMEBORDER_TLBR ) );
386 if( aFrameSel.IsBorderEnabled( svx::FRAMEBORDER_BLTR ) )
387 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_BLTR, aFrameSel, svx::FRAMEBORDER_BLTR ) );
388 // --> OD 2005-03-01 #i43593# - item connection doesn't work for Writer,
389 // because the Writer item sets contain these items
390 // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
391 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, aMergeWithNextCB, sfx::ITEMCONN_DEFAULT ) );
392 aMergeWithNextCB.Hide();
393 // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
394 AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, aMergeAdjacentBordersCB, sfx::ITEMCONN_DEFAULT ) );
395 aMergeAdjacentBordersCB.Hide();
396 // <--
399 // -----------------------------------------------------------------------
401 SvxBorderTabPage::~SvxBorderTabPage()
405 // -----------------------------------------------------------------------
407 sal_uInt16* SvxBorderTabPage::GetRanges()
409 return pRanges;
412 // -----------------------------------------------------------------------
414 SfxTabPage* SvxBorderTabPage::Create( Window* pParent,
415 const SfxItemSet& rAttrSet )
417 return ( new SvxBorderTabPage( pParent, rAttrSet ) );
420 // -----------------------------------------------------------------------
422 void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
424 if( aFrameSel.IsBorderEnabled( eBorder ) )
426 if( bValid )
427 aFrameSel.ShowBorder( eBorder, pCoreLine );
428 else
429 aFrameSel.SetBorderDontCare( eBorder );
433 // -----------------------------------------------------------------------
435 void SvxBorderTabPage::Reset( const SfxItemSet& rSet )
437 SfxTabPage::Reset( rSet );
439 const SvxBoxItem* pBoxItem;
440 const SvxBoxInfoItem* pBoxInfoItem;
441 sal_uInt16 nWhichBox = GetWhich(SID_ATTR_BORDER_OUTER);
442 SfxMapUnit eCoreUnit;
443 const Color aColBlack = RGBCOL(COL_BLACK);
445 pBoxItem = (const SvxBoxItem*)GetItem( rSet, SID_ATTR_BORDER_OUTER );
448 pBoxInfoItem = (const SvxBoxInfoItem*)GetItem( rSet, SID_ATTR_BORDER_INNER, sal_False );
450 eCoreUnit = rSet.GetPool()->GetMetric( nWhichBox );
452 if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
454 ResetFrameLine_Impl( svx::FRAMEBORDER_LEFT, pBoxItem->GetLeft(), pBoxInfoItem->IsValid( VALID_LEFT ) );
455 ResetFrameLine_Impl( svx::FRAMEBORDER_RIGHT, pBoxItem->GetRight(), pBoxInfoItem->IsValid( VALID_RIGHT ) );
456 ResetFrameLine_Impl( svx::FRAMEBORDER_TOP, pBoxItem->GetTop(), pBoxInfoItem->IsValid( VALID_TOP ) );
457 ResetFrameLine_Impl( svx::FRAMEBORDER_BOTTOM, pBoxItem->GetBottom(), pBoxInfoItem->IsValid( VALID_BOTTOM ) );
458 ResetFrameLine_Impl( svx::FRAMEBORDER_VER, pBoxInfoItem->GetVert(), pBoxInfoItem->IsValid( VALID_VERT ) );
459 ResetFrameLine_Impl( svx::FRAMEBORDER_HOR, pBoxInfoItem->GetHori(), pBoxInfoItem->IsValid( VALID_HORI ) );
461 //-------------------
462 // Abstand nach innen
463 //-------------------
464 if( !mbUseMarginItem )
466 if ( aLeftMF.IsVisible() )
468 SetMetricValue( aLeftMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
469 SetMetricValue( aRightMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
470 SetMetricValue( aTopMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
471 SetMetricValue( aBottomMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
473 nMinValue = static_cast<long>(aLeftMF.GetValue());
475 if ( pBoxInfoItem->IsMinDist() )
477 aLeftMF.SetFirst( nMinValue );
478 aRightMF.SetFirst( nMinValue );
479 aTopMF.SetFirst( nMinValue );
480 aBottomMF.SetFirst( nMinValue );
483 if ( pBoxInfoItem->IsDist() )
485 if( rSet.GetItemState( nWhichBox, sal_True ) >= SFX_ITEM_DEFAULT )
487 sal_Bool bIsAnyBorderVisible = aFrameSel.IsAnyBorderVisible();
488 if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
490 aLeftMF.SetMin( 0 );
491 aLeftMF.SetFirst( 0 );
492 aRightMF.SetMin( 0 );
493 aRightMF.SetFirst( 0 );
494 aTopMF.SetMin( 0 );
495 aTopMF.SetFirst( 0 );
496 aBottomMF.SetMin( 0 );
497 aBottomMF.SetFirst( 0 );
499 long nLeftDist = pBoxItem->GetDistance( BOX_LINE_LEFT);
500 SetMetricValue( aLeftMF, nLeftDist, eCoreUnit );
501 long nRightDist = pBoxItem->GetDistance( BOX_LINE_RIGHT);
502 SetMetricValue( aRightMF, nRightDist, eCoreUnit );
503 long nTopDist = pBoxItem->GetDistance( BOX_LINE_TOP);
504 SetMetricValue( aTopMF, nTopDist, eCoreUnit );
505 long nBottomDist = pBoxItem->GetDistance( BOX_LINE_BOTTOM);
506 SetMetricValue( aBottomMF, nBottomDist, eCoreUnit );
508 // ist der Abstand auf nicht-default gesetzt,
509 // dann soll der Wert auch nicht
510 // mehr autom. veraendert werden
512 // if the distance is set with no active border line
513 // or it is null with an active border line
514 // no automatic changes should be made
515 const long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
516 sal_Bool bDiffDist = (nDefDist != nLeftDist ||
517 nDefDist != nRightDist ||
518 nDefDist != nTopDist ||
519 nDefDist != nBottomDist);
520 if((pBoxItem->GetDistance() ||
521 bIsAnyBorderVisible) && bDiffDist )
523 aLeftMF.SetModifyFlag();
524 aRightMF.SetModifyFlag();
525 aTopMF.SetModifyFlag();
526 aBottomMF.SetModifyFlag();
529 else
531 // #106224# different margins -> do not fill the edits
532 aLeftMF.SetText( String() );
533 aRightMF.SetText( String() );
534 aTopMF.SetText( String() );
535 aBottomMF.SetText( String() );
538 aLeftMF.SaveValue();
539 aRightMF.SaveValue();
540 aTopMF.SaveValue();
541 aBottomMF.SaveValue();
545 else
547 // ResetFrameLine-Aufrufe einsparen:
548 aFrameSel.HideAllBorders();
551 //-------------------------------------------------------------
552 // Linie/Linienfarbe in Controllern darstellen, wenn eindeutig:
553 //-------------------------------------------------------------
555 // Do all visible lines show the same line widths?
556 sal_uInt16 nPrim, nDist, nSecn;
557 bool bWidthEq = aFrameSel.GetVisibleWidth( nPrim, nDist, nSecn );
558 if( bWidthEq )
559 aLbLineStyle.SelectEntry( nPrim * 100, nSecn * 100, nDist * 100 );
560 else
561 aLbLineStyle.SelectEntryPos( 1 );
563 // Do all visible lines show the same line color?
564 Color aColor;
565 bool bColorEq = aFrameSel.GetVisibleColor( aColor );
566 if( !bColorEq )
567 aColor.SetColor( COL_BLACK );
569 sal_uInt16 nSelPos = aLbLineColor.GetEntryPos( aColor );
570 if( nSelPos == LISTBOX_ENTRY_NOTFOUND )
571 nSelPos = aLbLineColor.InsertEntry( aColor, SVX_RESSTR( RID_SVXSTR_COLOR_USER ) );
573 aLbLineColor.SelectEntryPos( nSelPos );
574 aLbLineStyle.SetColor( aColor );
576 // Select all visible lines, if they are all equal.
577 if( bWidthEq && bColorEq )
578 aFrameSel.SelectAllVisibleBorders();
580 // set the current style and color (caches style in control even if nothing is selected)
581 SelStyleHdl_Impl( &aLbLineStyle );
582 SelColHdl_Impl( &aLbLineColor );
585 sal_Bool bEnable = aWndShadows.GetSelectItemId() > 1 ;
586 aFtShadowSize.Enable(bEnable);
587 aEdShadowSize.Enable(bEnable);
588 aFtShadowColor.Enable(bEnable);
589 aLbShadowColor.Enable(bEnable);
591 aWndPresets.SetNoSelection();
593 // - keine Line - sollte nicht selektiert sein
595 if ( aLbLineStyle.GetSelectEntryPos() == 0 )
597 aLbLineStyle.SelectEntryPos( 1 );
598 SelStyleHdl_Impl( &aLbLineStyle );
601 const SfxPoolItem* pItem;
602 SfxObjectShell* pShell;
603 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
604 ( 0 != (pShell = SfxObjectShell::Current()) &&
605 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
607 sal_uInt16 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
608 if(nHtmlMode & HTMLMODE_ON)
610 //Im Html-Mode gibt es keinen Schatten und nur komplette Umrandungen
611 aFtShadowPos .Disable();
612 aWndShadows .Disable();
613 aFtShadowSize .Disable();
614 aEdShadowSize .Disable();
615 aFtShadowColor.Disable();
616 aLbShadowColor.Disable();
617 aFlShadow .Disable();
619 sal_uInt16 nLBCount = aLbLineStyle.GetEntryCount();
620 // ist es ein Absatzdialog, dann alle Linien fuer
621 // Sw-Export, sonst ist die Page nicht da
622 if(!(mbHorEnabled || mbVerEnabled)
623 && 0 == (nHtmlMode & HTMLMODE_FULL_ABS_POS) &&
624 SFX_ITEM_AVAILABLE > rSet.GetItemState(GetWhich( SID_ATTR_PARA_LINESPACE )))
626 for( sal_uInt16 i = nLBCount - 1; i > LINESTYLE_HTML_MAX; --i)
627 aLbLineStyle.RemoveEntry(i);
630 if( !(nSWMode & SW_BORDER_MODE_TABLE) )
632 aUserDefFT.Disable();
633 aFrameSel.Disable();
634 aWndPresets.RemoveItem(3);
635 aWndPresets.RemoveItem(4);
636 aWndPresets.RemoveItem(5);
641 LinesChanged_Impl( 0 );
644 // -----------------------------------------------------------------------
646 int SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
648 if ( _pSet )
649 FillItemSet( *_pSet );
651 return LEAVE_PAGE;
654 // -----------------------------------------------------------------------
656 #define IS_DONT_CARE(a) ((a).GetState() == svx::FRAMESTATE_DONTCARE )
658 sal_Bool SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
660 bool bAttrsChanged = SfxTabPage::FillItemSet( rCoreAttrs );
662 sal_Bool bPut = sal_True;
663 sal_uInt16 nBoxWhich = GetWhich( SID_ATTR_BORDER_OUTER );
664 sal_uInt16 nBoxInfoWhich = rCoreAttrs.GetPool()->GetWhich( SID_ATTR_BORDER_INNER, sal_False );
665 const SfxItemSet& rOldSet = GetItemSet();
666 SvxBoxItem aBoxItem ( nBoxWhich );
667 SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich );
668 SvxBoxItem* pOldBoxItem = (SvxBoxItem*)GetOldItem( rCoreAttrs, SID_ATTR_BORDER_OUTER );
670 SfxMapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
671 const SfxPoolItem* pOld = 0;
673 //------------------
674 // Umrandung aussen:
675 //------------------
676 typedef ::std::pair<svx::FrameBorderType,sal_uInt16> TBorderPair;
677 TBorderPair eTypes1[] = {
678 TBorderPair(svx::FRAMEBORDER_TOP,BOX_LINE_TOP),
679 TBorderPair(svx::FRAMEBORDER_BOTTOM,BOX_LINE_BOTTOM),
680 TBorderPair(svx::FRAMEBORDER_LEFT,BOX_LINE_LEFT),
681 TBorderPair(svx::FRAMEBORDER_RIGHT,BOX_LINE_RIGHT),
684 for (sal_uInt32 i=0; i < sizeof(eTypes1)/sizeof(TBorderPair); ++i)
685 aBoxItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes1[i].first ), eTypes1[i].second );
687 //--------------------------------
688 // Umrandung hor/ver und TableFlag
689 //--------------------------------
690 TBorderPair eTypes2[] = {
691 TBorderPair(svx::FRAMEBORDER_HOR,BOXINFO_LINE_HORI),
692 TBorderPair(svx::FRAMEBORDER_VER,BOXINFO_LINE_VERT)
694 for (sal_uInt32 j=0; j < sizeof(eTypes2)/sizeof(TBorderPair); ++j)
695 aBoxInfoItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes2[j].first ), eTypes2[j].second );
697 aBoxInfoItem.EnableHor( mbHorEnabled );
698 aBoxInfoItem.EnableVer( mbVerEnabled );
700 //-------------------
701 // Abstand nach Innen
702 //-------------------
703 if( aLeftMF.IsVisible() )
705 // #i40405# enable distance controls for next dialog call
706 aBoxInfoItem.SetDist( sal_True );
708 if( !mbUseMarginItem )
710 // #106224# all edits empty: do nothing
711 if( aLeftMF.GetText().Len() || aRightMF.GetText().Len() ||
712 aTopMF.GetText().Len() || aBottomMF.GetText().Len() )
714 if ( ((mbHorEnabled || mbVerEnabled || (nSWMode & SW_BORDER_MODE_TABLE)) &&
715 (aLeftMF.IsModified()||aRightMF.IsModified()||
716 aTopMF.IsModified()||aBottomMF.IsModified()) )||
717 aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_HIDE
718 || aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_HIDE
719 || aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_HIDE
720 || aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_HIDE )
722 SvxBoxInfoItem* pOldBoxInfoItem = (SvxBoxInfoItem*)GetOldItem(
723 rCoreAttrs, SID_ATTR_BORDER_INNER );
724 if (
725 !pOldBoxItem ||
726 aLeftMF .GetText() != aLeftMF .GetSavedValue() ||
727 aRightMF .GetText() != aRightMF .GetSavedValue() ||
728 aTopMF .GetText() != aTopMF .GetSavedValue() ||
729 aBottomMF.GetText() != aBottomMF.GetSavedValue() ||
730 nMinValue == aLeftMF .GetValue() ||
731 nMinValue == aRightMF .GetValue() ||
732 nMinValue == aTopMF .GetValue() ||
733 nMinValue == aBottomMF.GetValue() ||
734 (pOldBoxInfoItem && !pOldBoxInfoItem->IsValid(VALID_DISTANCE))
737 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aLeftMF, eCoreUnit ), BOX_LINE_LEFT );
738 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aRightMF, eCoreUnit ), BOX_LINE_RIGHT );
739 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aTopMF, eCoreUnit ), BOX_LINE_TOP );
740 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aBottomMF, eCoreUnit ), BOX_LINE_BOTTOM);
742 else
744 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_LEFT ), BOX_LINE_LEFT);
745 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_RIGHT), BOX_LINE_RIGHT);
746 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_TOP ), BOX_LINE_TOP);
747 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_BOTTOM), BOX_LINE_BOTTOM);
749 aBoxInfoItem.SetValid( VALID_DISTANCE, sal_True );
751 else
752 aBoxInfoItem.SetValid( VALID_DISTANCE, sal_False );
757 //------------------------------------------
758 // Don't Care Status im Info-Item vermerken:
759 //------------------------------------------
760 aBoxInfoItem.SetValid( VALID_TOP, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_DONTCARE );
761 aBoxInfoItem.SetValid( VALID_BOTTOM, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_DONTCARE );
762 aBoxInfoItem.SetValid( VALID_LEFT, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_DONTCARE );
763 aBoxInfoItem.SetValid( VALID_RIGHT, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_DONTCARE );
764 aBoxInfoItem.SetValid( VALID_HORI, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_HOR ) != svx::FRAMESTATE_DONTCARE );
765 aBoxInfoItem.SetValid( VALID_VERT, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_VER ) != svx::FRAMESTATE_DONTCARE );
768 // Put oder Clear der Umrandung?
770 bPut = sal_True;
772 if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxWhich, sal_False ))
774 bPut = aBoxItem != (const SvxBoxItem&)(rOldSet.Get(nBoxWhich)) ? sal_True : sal_False;
776 if( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, sal_False ) )
778 const SvxBoxInfoItem& rOldBoxInfo = (const SvxBoxInfoItem&)
779 rOldSet.Get(nBoxInfoWhich);
781 aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
782 aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
783 bPut |= (aBoxInfoItem != rOldBoxInfo );
786 if ( bPut )
788 if ( !pOldBoxItem || !( *pOldBoxItem == aBoxItem ) )
790 rCoreAttrs.Put( aBoxItem );
791 bAttrsChanged |= sal_True;
793 pOld = GetOldItem( rCoreAttrs, SID_ATTR_BORDER_INNER, sal_False );
795 if ( !pOld || !( *(const SvxBoxInfoItem*)pOld == aBoxInfoItem ) )
797 rCoreAttrs.Put( aBoxInfoItem );
798 bAttrsChanged |= sal_True;
801 else
803 rCoreAttrs.ClearItem( nBoxWhich );
804 rCoreAttrs.ClearItem( nBoxInfoWhich );
807 return bAttrsChanged;
810 // -----------------------------------------------------------------------
812 void SvxBorderTabPage::HideShadowControls()
814 aFtShadowPos.Hide();
815 aWndShadows.Hide();
816 aFtShadowSize.Hide();
817 aEdShadowSize.Hide();
818 aFtShadowColor.Hide();
819 aLbShadowColor.Hide();
820 aFlShadow.Hide();
823 // -----------------------------------------------------------------------
825 IMPL_LINK( SvxBorderTabPage, SelPreHdl_Impl, void *, EMPTYARG )
827 const svx::FrameBorderState SHOW = svx::FRAMESTATE_SHOW;
828 const svx::FrameBorderState HIDE = svx::FRAMESTATE_HIDE;
829 const svx::FrameBorderState DONT = svx::FRAMESTATE_DONTCARE;
831 static const svx::FrameBorderState ppeStates[][ svx::FRAMEBORDERTYPE_COUNT ] =
832 { /* Left Right Top Bot Hor Ver TLBR BLTR */
833 /* ---------------------+--------------------------------------------------- */
834 /* IID_PRE_CELL_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
835 /* IID_PRE_CELL_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
836 /* IID_PRE_CELL_LR */ { SHOW, SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
837 /* IID_PRE_CELL_TB */ { HIDE, HIDE, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
838 /* IID_PRE_CELL_L */ { SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
839 /* IID_PRE_CELL_DIAG */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, SHOW, SHOW },
840 /* IID_PRE_HOR_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
841 /* IID_PRE_HOR_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
842 /* IID_PRE_HOR_HOR */ { HIDE, HIDE, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
843 /* IID_PRE_HOR_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
844 /* IID_PRE_HOR_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, HIDE, HIDE, HIDE },
845 /* IID_PRE_VER_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
846 /* IID_PRE_VER_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
847 /* IID_PRE_VER_VER */ { SHOW, SHOW, HIDE, HIDE, HIDE, SHOW, HIDE, HIDE },
848 /* IID_PRE_VER_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, SHOW, HIDE, HIDE },
849 /* IID_PRE_VER_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, HIDE, DONT, HIDE, HIDE },
850 /* IID_PRE_TABLE_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
851 /* IID_PRE_TABLE_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
852 /* IID_PRE_TABLE_OUTERH */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
853 /* IID_PRE_TABLE_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE },
854 /* IID_PRE_TABLE_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, DONT, HIDE, HIDE }
857 // first hide and deselect all frame borders
858 aFrameSel.HideAllBorders();
859 aFrameSel.DeselectAllBorders();
861 // Using image ID to find correct line in table above.
862 sal_uInt16 nLine = GetPresetImageId( aWndPresets.GetSelectItemId() ) - 1;
864 // Apply all styles from the table
865 for( int nBorder = 0; nBorder < svx::FRAMEBORDERTYPE_COUNT; ++nBorder )
867 svx::FrameBorderType eBorder = svx::GetFrameBorderTypeFromIndex( nBorder );
868 switch( ppeStates[ nLine ][ nBorder ] )
870 case SHOW: aFrameSel.SelectBorder( eBorder ); break;
871 case HIDE: /* nothing to do */ break;
872 case DONT: aFrameSel.SetBorderDontCare( eBorder ); break;
876 // Show all lines that have been selected above
877 if( aFrameSel.IsAnyBorderSelected() )
879 // any visible style, but "no-line" in line list box? -> use hair-line
880 if( (aLbLineStyle.GetSelectEntryPos() == 0) || (aLbLineStyle.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) )
881 aLbLineStyle.SelectEntryPos( 1 );
883 // set current style to all previously selected lines
884 SelStyleHdl_Impl( &aLbLineStyle );
885 SelColHdl_Impl( &aLbLineColor );
888 // Presets ValueSet does not show a selection (used as push buttons).
889 aWndPresets.SetNoSelection();
891 LinesChanged_Impl( 0 );
892 return 0;
895 // -----------------------------------------------------------------------
897 IMPL_LINK( SvxBorderTabPage, SelSdwHdl_Impl, void *, EMPTYARG )
899 sal_Bool bEnable = aWndShadows.GetSelectItemId() > 1;
900 aFtShadowSize.Enable(bEnable);
901 aEdShadowSize.Enable(bEnable);
902 aFtShadowColor.Enable(bEnable);
903 aLbShadowColor.Enable(bEnable);
904 return 0;
907 // -----------------------------------------------------------------------
909 IMPL_LINK( SvxBorderTabPage, SelColHdl_Impl, ListBox *, pLb )
911 ColorListBox* pColLb = (ColorListBox*)pLb;
913 if ( pLb == &aLbLineColor )
915 aFrameSel.SetColorToSelection( pColLb->GetSelectEntryColor() );
916 aLbLineStyle.SetColor( pColLb->GetSelectEntryColor() );
919 return 0;
922 // -----------------------------------------------------------------------
924 IMPL_LINK( SvxBorderTabPage, SelStyleHdl_Impl, ListBox *, pLb )
926 if ( pLb == &aLbLineStyle )
927 aFrameSel.SetStyleToSelection(
928 static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryLine1() / 100 ),
929 static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryDistance() / 100 ),
930 static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryLine2() / 100 ) );
932 return 0;
935 // ============================================================================
936 // ValueSet handling
937 // ============================================================================
939 // number of preset images to show
940 const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5;
942 // number of shadow images to show
943 const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5;
945 // ----------------------------------------------------------------------------
947 sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
949 // table with all sets of predefined border styles
950 static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] =
952 // simple cell without diagonal frame borders
953 { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_L },
954 // simple cell with diagonal frame borders
955 { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_DIAG },
956 // with horizontal inner frame border
957 { IID_PRE_HOR_NONE, IID_PRE_HOR_OUTER, IID_PRE_HOR_HOR, IID_PRE_HOR_ALL, IID_PRE_HOR_OUTER2 },
958 // with vertical inner frame border
959 { IID_PRE_VER_NONE, IID_PRE_VER_OUTER, IID_PRE_VER_VER, IID_PRE_VER_ALL, IID_PRE_VER_OUTER2 },
960 // with horizontal and vertical inner frame borders
961 { IID_PRE_TABLE_NONE, IID_PRE_TABLE_OUTER, IID_PRE_TABLE_OUTERH, IID_PRE_TABLE_ALL, IID_PRE_TABLE_OUTER2 }
964 // find correct set of presets
965 int nLine = 0;
966 if( !mbHorEnabled && !mbVerEnabled )
967 nLine = (mbTLBREnabled || mbBLTREnabled) ? 1 : 0;
968 else if( mbHorEnabled && !mbVerEnabled )
969 nLine = 2;
970 else if( !mbHorEnabled && mbVerEnabled )
971 nLine = 3;
972 else
973 nLine = 4;
975 DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT),
976 "SvxBorderTabPage::GetPresetImageId - wrong index" );
977 return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
980 sal_uInt16 SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
982 // string resource IDs for each image (in order of the IID_PRE_* image IDs)
983 static const sal_uInt16 pnStrIds[] =
985 RID_SVXSTR_TABLE_PRESET_NONE,
986 RID_SVXSTR_PARA_PRESET_ALL,
987 RID_SVXSTR_PARA_PRESET_LEFTRIGHT,
988 RID_SVXSTR_PARA_PRESET_TOPBOTTOM,
989 RID_SVXSTR_PARA_PRESET_ONLYLEFT,
990 RID_SVXSTR_PARA_PRESET_DIAGONAL,
992 RID_SVXSTR_TABLE_PRESET_NONE,
993 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
994 RID_SVXSTR_HOR_PRESET_ONLYHOR,
995 RID_SVXSTR_TABLE_PRESET_OUTERALL,
996 RID_SVXSTR_TABLE_PRESET_OUTERINNER,
998 RID_SVXSTR_TABLE_PRESET_NONE,
999 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1000 RID_SVXSTR_VER_PRESET_ONLYVER,
1001 RID_SVXSTR_TABLE_PRESET_OUTERALL,
1002 RID_SVXSTR_TABLE_PRESET_OUTERINNER,
1004 RID_SVXSTR_TABLE_PRESET_NONE,
1005 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
1006 RID_SVXSTR_TABLE_PRESET_OUTERHORI,
1007 RID_SVXSTR_TABLE_PRESET_OUTERALL,
1008 RID_SVXSTR_TABLE_PRESET_OUTERINNER
1010 return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
1013 // ----------------------------------------------------------------------------
1015 void SvxBorderTabPage::FillPresetVS()
1017 // find correct image list
1018 bool bHC = aWndPresets.GetSettings().GetStyleSettings().GetHighContrastMode();
1019 ImageList& rImgList = bHC ? aBorderImgLstH : aBorderImgLst;
1020 Size aImgSize( rImgList.GetImage( IID_PRE_CELL_NONE ).GetSizePixel() );
1022 // basic initialization of the ValueSet
1023 aWndPresets.SetColCount( SVX_BORDER_PRESET_COUNT );
1024 aWndPresets.SetStyle( aWndPresets.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1025 aWndPresets.SetSizePixel( aWndPresets.CalcWindowSizePixel( aImgSize ) );
1027 // insert images and help texts
1028 for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx )
1030 aWndPresets.InsertItem( nVSIdx );
1031 aWndPresets.SetItemImage( nVSIdx, rImgList.GetImage( GetPresetImageId( nVSIdx ) ) );
1032 aWndPresets.SetItemText( nVSIdx, CUI_RESSTR( GetPresetStringId( nVSIdx ) ) );
1035 // show the control
1036 aWndPresets.SetNoSelection();
1037 aWndPresets.Show();
1040 // ----------------------------------------------------------------------------
1042 void SvxBorderTabPage::FillShadowVS()
1044 // find correct image list
1045 bool bHC = aWndPresets.GetSettings().GetStyleSettings().GetHighContrastMode();
1046 ImageList& rImgList = bHC ? aShadowImgLstH : aShadowImgLst;
1047 Size aImgSize( rImgList.GetImage( IID_SHADOWNONE ).GetSizePixel() );
1049 // basic initialization of the ValueSet
1050 aWndShadows.SetColCount( SVX_BORDER_SHADOW_COUNT );
1051 aWndShadows.SetStyle( aWndShadows.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
1052 aWndShadows.SetSizePixel( aWndShadows.CalcWindowSizePixel( aImgSize ) );
1054 // image resource IDs
1055 static const sal_uInt16 pnImgIds[ SVX_BORDER_SHADOW_COUNT ] =
1056 { IID_SHADOWNONE, IID_SHADOW_BOT_RIGHT, IID_SHADOW_TOP_RIGHT, IID_SHADOW_BOT_LEFT, IID_SHADOW_TOP_LEFT };
1057 // string resource IDs for each image
1058 static const sal_uInt16 pnStrIds[ SVX_BORDER_SHADOW_COUNT ] =
1059 { 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 };
1061 // insert images and help texts
1062 for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx )
1064 aWndShadows.InsertItem( nVSIdx );
1065 aWndShadows.SetItemImage( nVSIdx, rImgList.GetImage( pnImgIds[ nVSIdx - 1 ] ) );
1066 aWndShadows.SetItemText( nVSIdx, CUI_RESSTR( pnStrIds[ nVSIdx - 1 ] ) );
1069 // show the control
1070 aWndShadows.SelectItem( 1 );
1071 aWndShadows.Show();
1074 // ----------------------------------------------------------------------------
1076 void SvxBorderTabPage::FillValueSets()
1078 FillPresetVS();
1079 FillShadowVS();
1082 // ============================================================================
1084 void SvxBorderTabPage::FillLineListBox_Impl()
1086 aLbLineStyle.SetUnit( FUNIT_POINT );
1087 aLbLineStyle.SetSourceUnit( FUNIT_TWIP );
1089 // Writer 2.0 Defaults:
1090 aLbLineStyle.InsertEntry( SVX_RESSTR( RID_SVXSTR_NONE ) );
1092 aLbLineStyle.InsertEntry( LINE_WIDTH0 );
1093 aLbLineStyle.InsertEntry( LINE_WIDTH5 );
1094 aLbLineStyle.InsertEntry( LINE_WIDTH1 );
1095 aLbLineStyle.InsertEntry( LINE_WIDTH2 );
1096 aLbLineStyle.InsertEntry( LINE_WIDTH3 );
1097 aLbLineStyle.InsertEntry( LINE_WIDTH4 );
1099 // OS: wenn hier neue Linienstaerken zugfuegt werden, dann
1100 // LINESTYLE_HTML_MAX anpassen
1102 aLbLineStyle.InsertEntry( DLINE0_OUT, DLINE0_IN, DLINE0_DIST );
1103 aLbLineStyle.InsertEntry( DLINE7_OUT, DLINE7_IN, DLINE7_DIST );
1104 aLbLineStyle.InsertEntry( DLINE1_OUT, DLINE1_IN, DLINE1_DIST );
1105 aLbLineStyle.InsertEntry( DLINE2_OUT, DLINE2_IN, DLINE2_DIST );
1106 aLbLineStyle.InsertEntry( DLINE8_OUT, DLINE8_IN, DLINE8_DIST );
1107 aLbLineStyle.InsertEntry( DLINE9_OUT, DLINE9_IN, DLINE9_DIST );
1108 aLbLineStyle.InsertEntry( DLINE10_OUT,DLINE10_IN,DLINE10_DIST);
1109 aLbLineStyle.InsertEntry( DLINE3_OUT, DLINE3_IN, DLINE3_DIST );
1110 aLbLineStyle.InsertEntry( DLINE4_OUT, DLINE4_IN, DLINE4_DIST );
1111 aLbLineStyle.InsertEntry( DLINE5_OUT, DLINE5_IN, DLINE5_DIST );
1112 aLbLineStyle.InsertEntry( DLINE6_OUT, DLINE6_IN, DLINE6_DIST );
1115 // -----------------------------------------------------------------------
1116 IMPL_LINK( SvxBorderTabPage, LinesChanged_Impl, void*, EMPTYARG )
1118 if(!mbUseMarginItem && aLeftMF.IsVisible())
1120 sal_Bool bLineSet = aFrameSel.IsAnyBorderVisible();
1121 sal_Bool bMinAllowed = 0 != (nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_TABLE));
1122 sal_Bool bSpaceModified = aLeftMF .IsModified()||
1123 aRightMF .IsModified()||
1124 aTopMF .IsModified()||
1125 aBottomMF.IsModified();
1127 if(bLineSet)
1129 if(!bMinAllowed)
1131 aLeftMF .SetFirst(nMinValue);
1132 aRightMF .SetFirst(nMinValue);
1133 aTopMF .SetFirst(nMinValue);
1134 aBottomMF.SetFirst(nMinValue);
1136 if(!bSpaceModified)
1138 aLeftMF .SetValue(nMinValue);
1139 aRightMF .SetValue(nMinValue);
1140 aTopMF .SetValue(nMinValue);
1141 aBottomMF.SetValue(nMinValue);
1144 else
1146 aLeftMF .SetMin(0);
1147 aRightMF .SetMin(0);
1148 aTopMF .SetMin(0);
1149 aBottomMF.SetMin(0);
1150 aLeftMF .SetFirst(0);
1151 aRightMF .SetFirst(0);
1152 aTopMF .SetFirst(0);
1153 aBottomMF.SetFirst(0);
1154 if(!bSpaceModified)
1156 aLeftMF .SetValue(0);
1157 aRightMF .SetValue(0);
1158 aTopMF .SetValue(0);
1159 aBottomMF.SetValue(0);
1162 //fuer Tabellen ist alles erlaubt
1163 sal_uInt16 nValid = VALID_TOP|VALID_BOTTOM|VALID_LEFT|VALID_RIGHT;
1165 //fuer Rahmen und Absatz wird das Edit disabled, wenn keine Border gesetzt ist
1166 if(nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_PARA))
1168 if(bLineSet)
1170 nValid = (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_TOP) == svx::FRAMESTATE_SHOW) ? VALID_TOP : 0;
1171 nValid |= (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM) == svx::FRAMESTATE_SHOW) ? VALID_BOTTOM : 0;
1172 nValid |= (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_LEFT) == svx::FRAMESTATE_SHOW) ? VALID_LEFT : 0;
1173 nValid |= (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) == svx::FRAMESTATE_SHOW) ? VALID_RIGHT : 0;
1175 else
1176 nValid = 0;
1178 aLeftFT.Enable(0 != (nValid&VALID_LEFT));
1179 aRightFT.Enable(0 != (nValid&VALID_RIGHT));
1180 aTopFT.Enable(0 != (nValid&VALID_TOP));
1181 aBottomFT.Enable(0 != (nValid&VALID_BOTTOM));
1182 aLeftMF.Enable(0 != (nValid&VALID_LEFT));
1183 aRightMF.Enable(0 != (nValid&VALID_RIGHT));
1184 aTopMF.Enable(0 != (nValid&VALID_TOP));
1185 aBottomMF.Enable(0 != (nValid&VALID_BOTTOM));
1186 aSynchronizeCB.Enable( aRightMF.IsEnabled() || aTopMF.IsEnabled() ||
1187 aBottomMF.IsEnabled() || aLeftMF.IsEnabled() );
1189 return 0;
1192 // -----------------------------------------------------------------------
1194 IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, MetricField*, pField)
1196 if ( bSync )
1198 sal_Int64 nVal = pField->GetValue();
1199 if(pField != &aLeftMF)
1200 aLeftMF.SetValue(nVal);
1201 if(pField != &aRightMF)
1202 aRightMF.SetValue(nVal);
1203 if(pField != &aTopMF)
1204 aTopMF.SetValue(nVal);
1205 if(pField != &aBottomMF)
1206 aBottomMF.SetValue(nVal);
1208 return 0;
1211 IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, CheckBox*, pBox)
1213 bSync = pBox->IsChecked();
1214 return 0;
1217 /* -----------------------------03.06.2002 10:15------------------------------
1219 ---------------------------------------------------------------------------*/
1220 void SvxBorderTabPage::DataChanged( const DataChangedEvent& rDCEvt )
1222 if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1223 FillValueSets();
1225 SfxTabPage::DataChanged( rDCEvt );
1228 void SvxBorderTabPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
1230 SFX_ITEMSET_ARG (&aSet,pSWModeItem,SfxUInt16Item,SID_SWMODE_TYPE,sal_False);
1231 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
1232 if (pSWModeItem)
1234 nSWMode = pSWModeItem->GetValue();
1235 // --> OD 2005-03-01 #i43593#
1236 // show checkbox <aMergeWithNextCB> for format.paragraph
1237 if ( nSWMode == SW_BORDER_MODE_PARA )
1239 aMergeWithNextCB.Show();
1240 aPropertiesFL.Show();
1242 // show checkbox <aMergeAdjacentBordersCB> for format.paragraph
1243 else if ( nSWMode == SW_BORDER_MODE_TABLE )
1245 aMergeAdjacentBordersCB.Show();
1246 aPropertiesFL.Show();
1248 // <--
1250 if (pFlagItem)
1251 if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
1252 HideShadowControls();
1255 // ============================================================================