1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/app.hxx>
21 #include <sfx2/objsh.hxx>
22 #include <sfx2/module.hxx>
23 #include <svx/dialogs.hrc>
24 #include <svx/dialmgr.hxx>
30 #include <svx/xtable.hxx> // XColorList
31 #include <svx/drawitem.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <editeng/shaditem.hxx>
35 #include <svx/dlgutil.hxx>
36 #include <dialmgr.hxx>
37 #include <sfx2/htmlmode.hxx>
38 #include <vcl/msgbox.hxx>
39 #include "svx/flagsdef.hxx"
40 #include <sfx2/request.hxx>
41 #include <svl/intitem.hxx>
42 #include <sfx2/itemconnect.hxx>
43 #include <sal/macros.h>
44 #include "borderconn.hxx"
46 using namespace ::editeng
;
48 // -----------------------------------------------------------------------
52 * TabPage for setting the border attributes.
54 * a SvxShadowItem: shadow
55 * a SvxBoxItem: lines left, right, top, bottom,
56 * a SvxBoxInfo: lines vertical, horizontal, distance, flags
58 * Lines can have three conditions:
59 * 1. Show ( -> valid values )
60 * 2. Hide ( -> NULL-Pointer )
61 * 3. DontCare ( -> special Valid-Flags in the InfoItem )
64 // static ----------------------------------------------------------------
66 static sal_uInt16 pRanges
[] =
68 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_SHADOW
,
69 SID_ATTR_ALIGN_MARGIN
, SID_ATTR_ALIGN_MARGIN
,
70 SID_ATTR_BORDER_CONNECT
, SID_ATTR_BORDER_CONNECT
,
71 SID_SW_COLLAPSING_BORDERS
, SID_SW_COLLAPSING_BORDERS
,
72 SID_ATTR_BORDER_DIAG_TLBR
, SID_ATTR_BORDER_DIAG_BLTR
,
76 // -----------------------------------------------------------------------
77 static void lcl_SetDecimalDigitsTo1(MetricField
& rField
)
79 sal_Int64 nMin
= rField
.Denormalize( rField
.GetMin( FUNIT_TWIP
) );
80 rField
.SetDecimalDigits(1);
81 rField
.SetMin( rField
.Normalize( nMin
), FUNIT_TWIP
);
83 // -----------------------------------------------------------------------
85 SvxBorderTabPage::SvxBorderTabPage(Window
* pParent
, const SfxItemSet
& rCoreAttrs
)
86 : SfxTabPage(pParent
, "BorderPage", "cui/ui/borderpage.ui", rCoreAttrs
)
93 aShadowImgLst( CUI_RES(IL_SDW_BITMAPS
)),
94 aBorderImgLst( CUI_RES(IL_PRE_BITMAPS
)),
97 mbHorEnabled( false ),
98 mbVerEnabled( false ),
99 mbTLBREnabled( false ),
100 mbBLTREnabled( false ),
101 mbUseMarginItem( false ),
105 get(m_pWndPresets
, "presets");
106 get(m_pUserDefFT
, "userdefft");
107 get(m_pFrameSel
, "framesel");
108 get(m_pLbLineStyle
, "linestylelb");
109 get(m_pLbLineColor
, "linecolorlb");
110 get(m_pLineWidthMF
, "linewidthmf");
112 get(m_pSpacingFrame
, "spacing");
113 get(m_pLeftFT
, "leftft");
114 get(m_pLeftMF
, "leftmf");
115 get(m_pRightFT
, "rightft");
116 get(m_pRightMF
, "rightmf");
117 get(m_pTopFT
, "topft");
118 get(m_pTopMF
, "topmf");
119 get(m_pBottomFT
, "bottomft");
120 get(m_pBottomMF
, "bottommf");
121 get(m_pSynchronizeCB
, "sync");
123 get(m_pShadowFrame
, "shadow");
124 get(m_pWndShadows
, "shadows");
125 get(m_pFtShadowSize
, "distanceft");
126 get(m_pEdShadowSize
, "distancemf");
127 get(m_pFtShadowColor
, "shadowcolorft");
128 get(m_pLbShadowColor
, "shadowcolorlb");
130 get(m_pPropertiesFrame
, "properties");
131 get(m_pMergeWithNextCB
, "mergewithnext");
132 get(m_pMergeAdjacentBordersCB
, "mergeadjacent");
134 // this page needs ExchangeSupport
135 SetExchangeSupport();
137 /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
138 -> Remember this state in mbUseMarginItem, because other special handling
139 is needed across various functions... */
140 mbUseMarginItem
= rCoreAttrs
.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN
),sal_True
) != SFX_ITEM_UNKNOWN
;
143 FieldUnit eFUnit
= GetModuleFieldUnit( rCoreAttrs
);
145 if( mbUseMarginItem
)
147 // copied from SvxAlignmentTabPage
150 // #103396# the default value (1pt) can't be accurately represented in
151 // inches or pica with two decimals, so point is used instead.
156 eFUnit
= FUNIT_POINT
;
164 default: ;//prevent warning
175 default: ; //prevent warning
179 SetFieldUnit(*m_pEdShadowSize
, eFUnit
);
181 sal_uInt16 nWhich
= GetWhich( SID_ATTR_BORDER_INNER
, sal_False
);
182 sal_Bool bIsDontCare
= sal_True
;
184 if ( rCoreAttrs
.GetItemState( nWhich
, sal_True
) >= SFX_ITEM_AVAILABLE
)
186 // paragraph or table
187 const SvxBoxInfoItem
* pBoxInfo
=
188 (const SvxBoxInfoItem
*)&( rCoreAttrs
.Get( nWhich
) );
190 mbHorEnabled
= pBoxInfo
->IsHorEnabled();
191 mbVerEnabled
= pBoxInfo
->IsVerEnabled();
192 mbTLBREnabled
= sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs
, SID_ATTR_BORDER_DIAG_TLBR
);
193 mbBLTREnabled
= sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs
, SID_ATTR_BORDER_DIAG_BLTR
);
195 if(pBoxInfo
->IsDist())
197 SetFieldUnit(*m_pLeftMF
, eFUnit
);
198 SetFieldUnit(*m_pRightMF
, eFUnit
);
199 SetFieldUnit(*m_pTopMF
, eFUnit
);
200 SetFieldUnit(*m_pBottomMF
, eFUnit
);
201 m_pSynchronizeCB
->SetClickHdl(LINK(this, SvxBorderTabPage
, SyncHdl_Impl
));
202 m_pLeftMF
->SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
203 m_pRightMF
->SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
204 m_pTopMF
->SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
205 m_pBottomMF
->SetModifyHdl(LINK(this, SvxBorderTabPage
, ModifyDistanceHdl_Impl
));
209 m_pSpacingFrame
->Hide();
211 bIsDontCare
= !pBoxInfo
->IsValid( VALID_DISABLE
);
213 if(!mbUseMarginItem
&& eFUnit
== FUNIT_MM
&& SFX_MAPUNIT_TWIP
== rCoreAttrs
.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER
) ))
215 //#i91548# changing the number of decimal digits changes the minimum values, too
216 lcl_SetDecimalDigitsTo1(*m_pLeftMF
);
217 lcl_SetDecimalDigitsTo1(*m_pRightMF
);
218 lcl_SetDecimalDigitsTo1(*m_pTopMF
);
219 lcl_SetDecimalDigitsTo1(*m_pBottomMF
);
220 lcl_SetDecimalDigitsTo1(*m_pEdShadowSize
);
223 svx::FrameSelFlags nFlags
= svx::FRAMESEL_OUTER
;
225 nFlags
|= svx::FRAMESEL_INNER_HOR
;
227 nFlags
|= svx::FRAMESEL_INNER_VER
;
229 nFlags
|= svx::FRAMESEL_DIAG_TLBR
;
231 nFlags
|= svx::FRAMESEL_DIAG_BLTR
;
233 nFlags
|= svx::FRAMESEL_DONTCARE
;
234 m_pFrameSel
->Initialize( nFlags
);
236 m_pFrameSel
->SetSelectHdl(LINK(this, SvxBorderTabPage
, LinesChanged_Impl
));
237 m_pLbLineStyle
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelStyleHdl_Impl
) );
238 m_pLbLineColor
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelColHdl_Impl
) );
239 m_pLineWidthMF
->SetModifyHdl( LINK( this, SvxBorderTabPage
, ModifyWidthHdl_Impl
) );
240 m_pLbShadowColor
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelColHdl_Impl
) );
241 m_pWndPresets
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelPreHdl_Impl
) );
242 m_pWndShadows
->SetSelectHdl( LINK( this, SvxBorderTabPage
, SelSdwHdl_Impl
) );
245 FillLineListBox_Impl();
247 // fill ColorBox out of the XColorList
248 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
249 XColorListRef pColorTable
;
251 DBG_ASSERT( pDocSh
, "DocShell not found!" );
255 const SfxPoolItem
* pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
257 pColorTable
= ( (SvxColorListItem
*)pItem
)->GetColorList();
260 DBG_ASSERT( pColorTable
.is(), "ColorTable not found!" );
262 if ( pColorTable
.is() )
264 // filling the line color box
265 m_pLbLineColor
->SetUpdateMode( sal_False
);
267 for ( long i
= 0; i
< pColorTable
->Count(); ++i
)
269 XColorEntry
* pEntry
= pColorTable
->GetColor(i
);
270 m_pLbLineColor
->InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
272 m_pLbLineColor
->SetUpdateMode( sal_True
);
274 m_pLbShadowColor
->CopyEntries(*m_pLbLineColor
);
279 bool bSupportsShadow
= !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW
) );
280 if( bSupportsShadow
)
281 AddItemConnection( svx::CreateShadowConnection( rCoreAttrs
, *m_pWndShadows
, *m_pEdShadowSize
, *m_pLbShadowColor
) );
283 HideShadowControls();
285 if( mbUseMarginItem
)
286 AddItemConnection( svx::CreateMarginConnection( rCoreAttrs
, *m_pLeftMF
, *m_pRightMF
, *m_pTopMF
, *m_pBottomMF
) );
287 if( m_pFrameSel
->IsBorderEnabled( svx::FRAMEBORDER_TLBR
) )
288 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR
, *m_pFrameSel
, svx::FRAMEBORDER_TLBR
) );
289 if( m_pFrameSel
->IsBorderEnabled( svx::FRAMEBORDER_BLTR
) )
290 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_BLTR
, *m_pFrameSel
, svx::FRAMEBORDER_BLTR
) );
291 // #i43593# - item connection doesn't work for Writer,
292 // because the Writer item sets contain these items
293 // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
294 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT
, *m_pMergeWithNextCB
, sfx::ITEMCONN_DEFAULT
) );
295 m_pMergeWithNextCB
->Hide();
296 // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
297 AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS
, *m_pMergeAdjacentBordersCB
, sfx::ITEMCONN_DEFAULT
) );
298 m_pMergeAdjacentBordersCB
->Hide();
301 // -----------------------------------------------------------------------
303 SvxBorderTabPage::~SvxBorderTabPage()
307 // -----------------------------------------------------------------------
309 sal_uInt16
* SvxBorderTabPage::GetRanges()
314 // -----------------------------------------------------------------------
316 SfxTabPage
* SvxBorderTabPage::Create( Window
* pParent
,
317 const SfxItemSet
& rAttrSet
)
319 return ( new SvxBorderTabPage( pParent
, rAttrSet
) );
322 // -----------------------------------------------------------------------
324 void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder
, const SvxBorderLine
* pCoreLine
, bool bValid
)
326 if( m_pFrameSel
->IsBorderEnabled( eBorder
) )
329 m_pFrameSel
->ShowBorder( eBorder
, pCoreLine
);
331 m_pFrameSel
->SetBorderDontCare( eBorder
);
335 // -----------------------------------------------------------------------
337 void SvxBorderTabPage::Reset( const SfxItemSet
& rSet
)
339 SfxTabPage::Reset( rSet
);
341 const SvxBoxItem
* pBoxItem
;
342 const SvxBoxInfoItem
* pBoxInfoItem
;
343 sal_uInt16 nWhichBox
= GetWhich(SID_ATTR_BORDER_OUTER
);
344 SfxMapUnit eCoreUnit
;
346 pBoxItem
= (const SvxBoxItem
*)GetItem( rSet
, SID_ATTR_BORDER_OUTER
);
348 pBoxInfoItem
= (const SvxBoxInfoItem
*)GetItem( rSet
, SID_ATTR_BORDER_INNER
, sal_False
);
350 eCoreUnit
= rSet
.GetPool()->GetMetric( nWhichBox
);
352 if ( pBoxItem
&& pBoxInfoItem
) // -> Don't Care
354 ResetFrameLine_Impl( svx::FRAMEBORDER_LEFT
, pBoxItem
->GetLeft(), pBoxInfoItem
->IsValid( VALID_LEFT
) );
355 ResetFrameLine_Impl( svx::FRAMEBORDER_RIGHT
, pBoxItem
->GetRight(), pBoxInfoItem
->IsValid( VALID_RIGHT
) );
356 ResetFrameLine_Impl( svx::FRAMEBORDER_TOP
, pBoxItem
->GetTop(), pBoxInfoItem
->IsValid( VALID_TOP
) );
357 ResetFrameLine_Impl( svx::FRAMEBORDER_BOTTOM
, pBoxItem
->GetBottom(), pBoxInfoItem
->IsValid( VALID_BOTTOM
) );
358 ResetFrameLine_Impl( svx::FRAMEBORDER_VER
, pBoxInfoItem
->GetVert(), pBoxInfoItem
->IsValid( VALID_VERT
) );
359 ResetFrameLine_Impl( svx::FRAMEBORDER_HOR
, pBoxInfoItem
->GetHori(), pBoxInfoItem
->IsValid( VALID_HORI
) );
361 //-------------------
363 //-------------------
364 if( !mbUseMarginItem
)
366 if ( m_pLeftMF
->IsVisible() )
368 SetMetricValue(*m_pLeftMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
369 SetMetricValue(*m_pRightMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
370 SetMetricValue(*m_pTopMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
371 SetMetricValue(*m_pBottomMF
, pBoxInfoItem
->GetDefDist(), eCoreUnit
);
373 nMinValue
= static_cast<long>(m_pLeftMF
->GetValue());
375 if ( pBoxInfoItem
->IsMinDist() )
377 m_pLeftMF
->SetFirst( nMinValue
);
378 m_pRightMF
->SetFirst( nMinValue
);
379 m_pTopMF
->SetFirst( nMinValue
);
380 m_pBottomMF
->SetFirst( nMinValue
);
383 if ( pBoxInfoItem
->IsDist() )
385 if( rSet
.GetItemState( nWhichBox
, sal_True
) >= SFX_ITEM_DEFAULT
)
387 sal_Bool bIsAnyBorderVisible
= m_pFrameSel
->IsAnyBorderVisible();
388 if( !bIsAnyBorderVisible
|| !pBoxInfoItem
->IsMinDist() )
390 m_pLeftMF
->SetMin( 0 );
391 m_pLeftMF
->SetFirst( 0 );
392 m_pRightMF
->SetMin( 0 );
393 m_pRightMF
->SetFirst( 0 );
394 m_pTopMF
->SetMin( 0 );
395 m_pTopMF
->SetFirst( 0 );
396 m_pBottomMF
->SetMin( 0 );
397 m_pBottomMF
->SetFirst( 0 );
399 long nLeftDist
= pBoxItem
->GetDistance( BOX_LINE_LEFT
);
400 SetMetricValue(*m_pLeftMF
, nLeftDist
, eCoreUnit
);
401 long nRightDist
= pBoxItem
->GetDistance( BOX_LINE_RIGHT
);
402 SetMetricValue(*m_pRightMF
, nRightDist
, eCoreUnit
);
403 long nTopDist
= pBoxItem
->GetDistance( BOX_LINE_TOP
);
404 SetMetricValue( *m_pTopMF
, nTopDist
, eCoreUnit
);
405 long nBottomDist
= pBoxItem
->GetDistance( BOX_LINE_BOTTOM
);
406 SetMetricValue( *m_pBottomMF
, nBottomDist
, eCoreUnit
);
408 // if the distance is set with no active border line
409 // or it is null with an active border line
410 // no automatic changes should be made
411 const long nDefDist
= bIsAnyBorderVisible
? pBoxInfoItem
->GetDefDist() : 0;
412 sal_Bool bDiffDist
= (nDefDist
!= nLeftDist
||
413 nDefDist
!= nRightDist
||
414 nDefDist
!= nTopDist
||
415 nDefDist
!= nBottomDist
);
416 if((pBoxItem
->GetDistance() ||
417 bIsAnyBorderVisible
) && bDiffDist
)
419 m_pLeftMF
->SetModifyFlag();
420 m_pRightMF
->SetModifyFlag();
421 m_pTopMF
->SetModifyFlag();
422 m_pBottomMF
->SetModifyFlag();
427 // #106224# different margins -> do not fill the edits
428 m_pLeftMF
->SetText( String() );
429 m_pRightMF
->SetText( String() );
430 m_pTopMF
->SetText( String() );
431 m_pBottomMF
->SetText( String() );
434 m_pLeftMF
->SaveValue();
435 m_pRightMF
->SaveValue();
436 m_pTopMF
->SaveValue();
437 m_pBottomMF
->SaveValue();
443 // avoid ResetFrameLine-calls:
444 m_pFrameSel
->HideAllBorders();
447 //-------------------------------------------------------------
448 // depict line (color) in controllers if unambiguous:
449 //-------------------------------------------------------------
451 // Do all visible lines show the same line widths?
453 SvxBorderStyle nStyle
;
454 bool bWidthEq
= m_pFrameSel
->GetVisibleWidth( nWidth
, nStyle
);
457 // Determine the width first as some styles can be missing depending on it
458 sal_Int64 nWidthPt
= static_cast<sal_Int64
>(MetricField::ConvertDoubleValue(
459 sal_Int64( nWidth
), m_pLineWidthMF
->GetDecimalDigits( ),
460 MAP_TWIP
,m_pLineWidthMF
->GetUnit() ));
461 m_pLineWidthMF
->SetValue( nWidthPt
);
462 m_pLbLineStyle
->SetWidth( nWidth
);
464 // then set the style
465 m_pLbLineStyle
->SelectEntry( nStyle
);
468 m_pLbLineStyle
->SelectEntryPos( 1 );
470 // Do all visible lines show the same line color?
472 bool bColorEq
= m_pFrameSel
->GetVisibleColor( aColor
);
474 aColor
.SetColor( COL_BLACK
);
476 sal_uInt16 nSelPos
= m_pLbLineColor
->GetEntryPos( aColor
);
477 if( nSelPos
== LISTBOX_ENTRY_NOTFOUND
)
478 nSelPos
= m_pLbLineColor
->InsertEntry( aColor
, SVX_RESSTR( RID_SVXSTR_COLOR_USER
) );
480 m_pLbLineColor
->SelectEntryPos( nSelPos
);
481 m_pLbLineStyle
->SetColor( aColor
);
483 // Select all visible lines, if they are all equal.
484 if( bWidthEq
&& bColorEq
)
485 m_pFrameSel
->SelectAllVisibleBorders();
487 // set the current style and color (caches style in control even if nothing is selected)
488 SelStyleHdl_Impl(m_pLbLineStyle
);
489 SelColHdl_Impl(m_pLbLineColor
);
492 sal_Bool bEnable
= m_pWndShadows
->GetSelectItemId() > 1 ;
493 m_pFtShadowSize
->Enable(bEnable
);
494 m_pEdShadowSize
->Enable(bEnable
);
495 m_pFtShadowColor
->Enable(bEnable
);
496 m_pLbShadowColor
->Enable(bEnable
);
498 m_pWndPresets
->SetNoSelection();
500 // - no line - should not be selected
502 if ( m_pLbLineStyle
->GetSelectEntryPos() == 0 )
504 m_pLbLineStyle
->SelectEntryPos( 1 );
505 SelStyleHdl_Impl(m_pLbLineStyle
);
508 const SfxPoolItem
* pItem
;
509 SfxObjectShell
* pShell
;
510 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_HTML_MODE
, sal_False
, &pItem
) ||
511 ( 0 != (pShell
= SfxObjectShell::Current()) &&
512 0 != (pItem
= pShell
->GetItem(SID_HTML_MODE
))))
514 sal_uInt16 nHtmlMode
= ((SfxUInt16Item
*)pItem
)->GetValue();
515 if(nHtmlMode
& HTMLMODE_ON
)
517 // there are no shadows in Html-mode and only complete borders
518 m_pShadowFrame
->Disable();
520 if( !(nSWMode
& SW_BORDER_MODE_TABLE
) )
522 m_pUserDefFT
->Disable();
523 m_pFrameSel
->Disable();
524 m_pWndPresets
->RemoveItem(3);
525 m_pWndPresets
->RemoveItem(4);
526 m_pWndPresets
->RemoveItem(5);
531 LinesChanged_Impl( 0 );
532 if(m_pLeftMF
->GetValue() == m_pRightMF
->GetValue() && m_pTopMF
->GetValue() == m_pBottomMF
->GetValue() && m_pTopMF
->GetValue() == m_pLeftMF
->GetValue())
536 m_pSynchronizeCB
->Check(mbSync
);
539 // -----------------------------------------------------------------------
541 int SvxBorderTabPage::DeactivatePage( SfxItemSet
* _pSet
)
544 FillItemSet( *_pSet
);
549 // -----------------------------------------------------------------------
551 sal_Bool
SvxBorderTabPage::FillItemSet( SfxItemSet
& rCoreAttrs
)
553 bool bAttrsChanged
= SfxTabPage::FillItemSet( rCoreAttrs
);
555 sal_Bool bPut
= sal_True
;
556 sal_uInt16 nBoxWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
557 sal_uInt16 nBoxInfoWhich
= rCoreAttrs
.GetPool()->GetWhich( SID_ATTR_BORDER_INNER
, sal_False
);
558 const SfxItemSet
& rOldSet
= GetItemSet();
559 SvxBoxItem
aBoxItem ( nBoxWhich
);
560 SvxBoxInfoItem
aBoxInfoItem ( nBoxInfoWhich
);
561 SvxBoxItem
* pOldBoxItem
= (SvxBoxItem
*)GetOldItem( rCoreAttrs
, SID_ATTR_BORDER_OUTER
);
563 SfxMapUnit eCoreUnit
= rOldSet
.GetPool()->GetMetric( nBoxWhich
);
568 typedef ::std::pair
<svx::FrameBorderType
,sal_uInt16
> TBorderPair
;
569 TBorderPair eTypes1
[] = {
570 TBorderPair(svx::FRAMEBORDER_TOP
,BOX_LINE_TOP
),
571 TBorderPair(svx::FRAMEBORDER_BOTTOM
,BOX_LINE_BOTTOM
),
572 TBorderPair(svx::FRAMEBORDER_LEFT
,BOX_LINE_LEFT
),
573 TBorderPair(svx::FRAMEBORDER_RIGHT
,BOX_LINE_RIGHT
),
576 for (sal_uInt32 i
=0; i
< SAL_N_ELEMENTS(eTypes1
); ++i
)
577 aBoxItem
.SetLine( m_pFrameSel
->GetFrameBorderStyle( eTypes1
[i
].first
), eTypes1
[i
].second
);
579 //--------------------------------
580 // border hor/ver and TableFlag
581 //--------------------------------
582 TBorderPair eTypes2
[] = {
583 TBorderPair(svx::FRAMEBORDER_HOR
,BOXINFO_LINE_HORI
),
584 TBorderPair(svx::FRAMEBORDER_VER
,BOXINFO_LINE_VERT
)
586 for (sal_uInt32 j
=0; j
< SAL_N_ELEMENTS(eTypes2
); ++j
)
587 aBoxInfoItem
.SetLine( m_pFrameSel
->GetFrameBorderStyle( eTypes2
[j
].first
), eTypes2
[j
].second
);
589 aBoxInfoItem
.EnableHor( mbHorEnabled
);
590 aBoxInfoItem
.EnableVer( mbVerEnabled
);
592 //-------------------
594 //-------------------
595 if( m_pLeftMF
->IsVisible() )
597 // #i40405# enable distance controls for next dialog call
598 aBoxInfoItem
.SetDist( sal_True
);
600 if( !mbUseMarginItem
)
602 // #106224# all edits empty: do nothing
603 if( !m_pLeftMF
->GetText().isEmpty() || !m_pRightMF
->GetText().isEmpty() ||
604 !m_pTopMF
->GetText().isEmpty() || !m_pBottomMF
->GetText().isEmpty() )
606 if ( ((mbHorEnabled
|| mbVerEnabled
|| (nSWMode
& SW_BORDER_MODE_TABLE
)) &&
607 (m_pLeftMF
->IsModified()||m_pRightMF
->IsModified()||
608 m_pTopMF
->IsModified()||m_pBottomMF
->IsModified()) )||
609 m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_TOP
) != svx::FRAMESTATE_HIDE
610 || m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM
) != svx::FRAMESTATE_HIDE
611 || m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_LEFT
) != svx::FRAMESTATE_HIDE
612 || m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_RIGHT
) != svx::FRAMESTATE_HIDE
)
614 SvxBoxInfoItem
* pOldBoxInfoItem
= (SvxBoxInfoItem
*)GetOldItem(
615 rCoreAttrs
, SID_ATTR_BORDER_INNER
);
618 m_pLeftMF
->GetText() != m_pLeftMF
->GetSavedValue() ||
619 m_pRightMF
->GetText() != m_pRightMF
->GetSavedValue() ||
620 m_pTopMF
->GetText() != m_pTopMF
->GetSavedValue() ||
621 m_pBottomMF
->GetText() != m_pBottomMF
->GetSavedValue() ||
622 nMinValue
== m_pLeftMF
->GetValue() ||
623 nMinValue
== m_pRightMF
->GetValue() ||
624 nMinValue
== m_pTopMF
->GetValue() ||
625 nMinValue
== m_pBottomMF
->GetValue() ||
626 (pOldBoxInfoItem
&& !pOldBoxInfoItem
->IsValid(VALID_DISTANCE
))
629 aBoxItem
.SetDistance( (sal_uInt16
)GetCoreValue(*m_pLeftMF
, eCoreUnit
), BOX_LINE_LEFT
);
630 aBoxItem
.SetDistance( (sal_uInt16
)GetCoreValue(*m_pRightMF
, eCoreUnit
), BOX_LINE_RIGHT
);
631 aBoxItem
.SetDistance( (sal_uInt16
)GetCoreValue(*m_pTopMF
, eCoreUnit
), BOX_LINE_TOP
);
632 aBoxItem
.SetDistance( (sal_uInt16
)GetCoreValue(*m_pBottomMF
, eCoreUnit
), BOX_LINE_BOTTOM
);
636 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_LEFT
), BOX_LINE_LEFT
);
637 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_RIGHT
), BOX_LINE_RIGHT
);
638 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_TOP
), BOX_LINE_TOP
);
639 aBoxItem
.SetDistance(pOldBoxItem
->GetDistance(BOX_LINE_BOTTOM
), BOX_LINE_BOTTOM
);
641 aBoxInfoItem
.SetValid( VALID_DISTANCE
, sal_True
);
644 aBoxInfoItem
.SetValid( VALID_DISTANCE
, sal_False
);
649 //------------------------------------------
650 // note Don't Care Status in the Info-Item:
651 //------------------------------------------
652 aBoxInfoItem
.SetValid( VALID_TOP
, m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_TOP
) != svx::FRAMESTATE_DONTCARE
);
653 aBoxInfoItem
.SetValid( VALID_BOTTOM
, m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM
) != svx::FRAMESTATE_DONTCARE
);
654 aBoxInfoItem
.SetValid( VALID_LEFT
, m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_LEFT
) != svx::FRAMESTATE_DONTCARE
);
655 aBoxInfoItem
.SetValid( VALID_RIGHT
, m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_RIGHT
) != svx::FRAMESTATE_DONTCARE
);
656 aBoxInfoItem
.SetValid( VALID_HORI
, m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_HOR
) != svx::FRAMESTATE_DONTCARE
);
657 aBoxInfoItem
.SetValid( VALID_VERT
, m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_VER
) != svx::FRAMESTATE_DONTCARE
);
660 // Put or Clear of the border?
664 if ( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nBoxWhich
, sal_False
))
666 bPut
= aBoxItem
!= (const SvxBoxItem
&)(rOldSet
.Get(nBoxWhich
)) ? sal_True
: sal_False
;
668 if( SFX_ITEM_DEFAULT
== rOldSet
.GetItemState( nBoxInfoWhich
, sal_False
) )
670 const SvxBoxInfoItem
& rOldBoxInfo
= (const SvxBoxInfoItem
&)
671 rOldSet
.Get(nBoxInfoWhich
);
673 aBoxInfoItem
.SetMinDist( rOldBoxInfo
.IsMinDist() );
674 aBoxInfoItem
.SetDefDist( rOldBoxInfo
.GetDefDist() );
675 bPut
|= (aBoxInfoItem
!= rOldBoxInfo
);
680 if ( !pOldBoxItem
|| !( *pOldBoxItem
== aBoxItem
) )
682 rCoreAttrs
.Put( aBoxItem
);
683 bAttrsChanged
|= sal_True
;
685 const SfxPoolItem
* pOld
= GetOldItem( rCoreAttrs
, SID_ATTR_BORDER_INNER
, sal_False
);
687 if ( !pOld
|| !( *(const SvxBoxInfoItem
*)pOld
== aBoxInfoItem
) )
689 rCoreAttrs
.Put( aBoxInfoItem
);
690 bAttrsChanged
|= sal_True
;
695 rCoreAttrs
.ClearItem( nBoxWhich
);
696 rCoreAttrs
.ClearItem( nBoxInfoWhich
);
699 return bAttrsChanged
;
702 // -----------------------------------------------------------------------
704 void SvxBorderTabPage::HideShadowControls()
706 m_pShadowFrame
->Hide();
709 // -----------------------------------------------------------------------
711 IMPL_LINK_NOARG(SvxBorderTabPage
, SelPreHdl_Impl
)
713 const svx::FrameBorderState SHOW
= svx::FRAMESTATE_SHOW
;
714 const svx::FrameBorderState HIDE
= svx::FRAMESTATE_HIDE
;
715 const svx::FrameBorderState DONT
= svx::FRAMESTATE_DONTCARE
;
717 static const svx::FrameBorderState ppeStates
[][ svx::FRAMEBORDERTYPE_COUNT
] =
718 { /* Left Right Top Bot Hor Ver TLBR BLTR */
719 /* ---------------------+--------------------------------------------------- */
720 /* IID_PRE_CELL_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
721 /* IID_PRE_CELL_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
722 /* IID_PRE_CELL_LR */ { SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
723 /* IID_PRE_CELL_TB */ { HIDE
, HIDE
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
724 /* IID_PRE_CELL_L */ { SHOW
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
725 /* IID_PRE_CELL_DIAG */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, SHOW
, SHOW
},
726 /* IID_PRE_HOR_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
727 /* IID_PRE_HOR_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
728 /* IID_PRE_HOR_HOR */ { HIDE
, HIDE
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
729 /* IID_PRE_HOR_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
730 /* IID_PRE_HOR_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, DONT
, HIDE
, HIDE
, HIDE
},
731 /* IID_PRE_VER_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
732 /* IID_PRE_VER_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
733 /* IID_PRE_VER_VER */ { SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, SHOW
, HIDE
, HIDE
},
734 /* IID_PRE_VER_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, SHOW
, HIDE
, HIDE
},
735 /* IID_PRE_VER_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, DONT
, HIDE
, HIDE
},
736 /* IID_PRE_TABLE_NONE */ { HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
, HIDE
},
737 /* IID_PRE_TABLE_OUTER */ { SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
, HIDE
},
738 /* IID_PRE_TABLE_OUTERH */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
, HIDE
},
739 /* IID_PRE_TABLE_ALL */ { SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, SHOW
, HIDE
, HIDE
},
740 /* IID_PRE_TABLE_OUTER2 */ { SHOW
, SHOW
, SHOW
, SHOW
, DONT
, DONT
, HIDE
, HIDE
}
743 // first hide and deselect all frame borders
744 m_pFrameSel
->HideAllBorders();
745 m_pFrameSel
->DeselectAllBorders();
747 // Using image ID to find correct line in table above.
748 sal_uInt16 nLine
= GetPresetImageId( m_pWndPresets
->GetSelectItemId() ) - 1;
750 // Apply all styles from the table
751 for( int nBorder
= 0; nBorder
< svx::FRAMEBORDERTYPE_COUNT
; ++nBorder
)
753 svx::FrameBorderType eBorder
= svx::GetFrameBorderTypeFromIndex( nBorder
);
754 switch( ppeStates
[ nLine
][ nBorder
] )
756 case SHOW
: m_pFrameSel
->SelectBorder( eBorder
); break;
757 case HIDE
: /* nothing to do */ break;
758 case DONT
: m_pFrameSel
->SetBorderDontCare( eBorder
); break;
762 // Show all lines that have been selected above
763 if( m_pFrameSel
->IsAnyBorderSelected() )
765 // any visible style, but "no-line" in line list box? -> use hair-line
766 if( (m_pLbLineStyle
->GetSelectEntryPos() == 0) || (m_pLbLineStyle
->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND
) )
767 m_pLbLineStyle
->SelectEntryPos( 1 );
769 // set current style to all previously selected lines
770 SelStyleHdl_Impl(m_pLbLineStyle
);
771 SelColHdl_Impl(m_pLbLineColor
);
774 // Presets ValueSet does not show a selection (used as push buttons).
775 m_pWndPresets
->SetNoSelection();
777 LinesChanged_Impl( 0 );
781 // -----------------------------------------------------------------------
783 IMPL_LINK_NOARG(SvxBorderTabPage
, SelSdwHdl_Impl
)
785 sal_Bool bEnable
= m_pWndShadows
->GetSelectItemId() > 1;
786 m_pFtShadowSize
->Enable(bEnable
);
787 m_pEdShadowSize
->Enable(bEnable
);
788 m_pFtShadowColor
->Enable(bEnable
);
789 m_pLbShadowColor
->Enable(bEnable
);
793 // -----------------------------------------------------------------------
795 IMPL_LINK( SvxBorderTabPage
, SelColHdl_Impl
, ListBox
*, pLb
)
797 ColorListBox
* pColLb
= (ColorListBox
*)(pLb
);
799 if (pLb
== m_pLbLineColor
)
801 m_pFrameSel
->SetColorToSelection( pColLb
->GetSelectEntryColor() );
802 m_pLbLineStyle
->SetColor( pColLb
->GetSelectEntryColor() );
808 IMPL_LINK_NOARG(SvxBorderTabPage
, ModifyWidthHdl_Impl
)
810 sal_Int64 nVal
= static_cast<sal_Int64
>(MetricField::ConvertDoubleValue(
811 m_pLineWidthMF
->GetValue( ),
812 m_pLineWidthMF
->GetDecimalDigits( ),
813 m_pLineWidthMF
->GetUnit(), MAP_TWIP
));
814 m_pLbLineStyle
->SetWidth( nVal
);
816 m_pFrameSel
->SetStyleToSelection( nVal
,
817 SvxBorderStyle( m_pLbLineStyle
->GetSelectEntryStyle() ) );
822 // -----------------------------------------------------------------------
824 IMPL_LINK( SvxBorderTabPage
, SelStyleHdl_Impl
, ListBox
*, pLb
)
826 if (pLb
== m_pLbLineStyle
)
828 sal_Int64 nVal
= static_cast<sal_Int64
>(MetricField::ConvertDoubleValue(
829 m_pLineWidthMF
->GetValue( ),
830 m_pLineWidthMF
->GetDecimalDigits( ),
831 m_pLineWidthMF
->GetUnit(), MAP_TWIP
));
832 m_pFrameSel
->SetStyleToSelection ( nVal
,
833 SvxBorderStyle( m_pLbLineStyle
->GetSelectEntryStyle() ) );
839 // ============================================================================
841 // ============================================================================
843 // number of preset images to show
844 const sal_uInt16 SVX_BORDER_PRESET_COUNT
= 5;
846 // number of shadow images to show
847 const sal_uInt16 SVX_BORDER_SHADOW_COUNT
= 5;
849 // ----------------------------------------------------------------------------
851 sal_uInt16
SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx
) const
853 // table with all sets of predefined border styles
854 static const sal_uInt16 ppnImgIds
[][ SVX_BORDER_PRESET_COUNT
] =
856 // simple cell without diagonal frame borders
857 { IID_PRE_CELL_NONE
, IID_PRE_CELL_ALL
, IID_PRE_CELL_LR
, IID_PRE_CELL_TB
, IID_PRE_CELL_L
},
858 // simple cell with diagonal frame borders
859 { IID_PRE_CELL_NONE
, IID_PRE_CELL_ALL
, IID_PRE_CELL_LR
, IID_PRE_CELL_TB
, IID_PRE_CELL_DIAG
},
860 // with horizontal inner frame border
861 { IID_PRE_HOR_NONE
, IID_PRE_HOR_OUTER
, IID_PRE_HOR_HOR
, IID_PRE_HOR_ALL
, IID_PRE_HOR_OUTER2
},
862 // with vertical inner frame border
863 { IID_PRE_VER_NONE
, IID_PRE_VER_OUTER
, IID_PRE_VER_VER
, IID_PRE_VER_ALL
, IID_PRE_VER_OUTER2
},
864 // with horizontal and vertical inner frame borders
865 { IID_PRE_TABLE_NONE
, IID_PRE_TABLE_OUTER
, IID_PRE_TABLE_OUTERH
, IID_PRE_TABLE_ALL
, IID_PRE_TABLE_OUTER2
}
868 // find correct set of presets
870 if( !mbHorEnabled
&& !mbVerEnabled
)
871 nLine
= (mbTLBREnabled
|| mbBLTREnabled
) ? 1 : 0;
872 else if( mbHorEnabled
&& !mbVerEnabled
)
874 else if( !mbHorEnabled
&& mbVerEnabled
)
879 DBG_ASSERT( (1 <= nValueSetIdx
) && (nValueSetIdx
<= SVX_BORDER_PRESET_COUNT
),
880 "SvxBorderTabPage::GetPresetImageId - wrong index" );
881 return ppnImgIds
[ nLine
][ nValueSetIdx
- 1 ];
884 sal_uInt16
SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx
) const
886 // string resource IDs for each image (in order of the IID_PRE_* image IDs)
887 static const sal_uInt16 pnStrIds
[] =
889 RID_SVXSTR_TABLE_PRESET_NONE
,
890 RID_SVXSTR_PARA_PRESET_ALL
,
891 RID_SVXSTR_PARA_PRESET_LEFTRIGHT
,
892 RID_SVXSTR_PARA_PRESET_TOPBOTTOM
,
893 RID_SVXSTR_PARA_PRESET_ONLYLEFT
,
894 RID_SVXSTR_PARA_PRESET_DIAGONAL
,
896 RID_SVXSTR_TABLE_PRESET_NONE
,
897 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
898 RID_SVXSTR_HOR_PRESET_ONLYHOR
,
899 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
900 RID_SVXSTR_TABLE_PRESET_OUTERINNER
,
902 RID_SVXSTR_TABLE_PRESET_NONE
,
903 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
904 RID_SVXSTR_VER_PRESET_ONLYVER
,
905 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
906 RID_SVXSTR_TABLE_PRESET_OUTERINNER
,
908 RID_SVXSTR_TABLE_PRESET_NONE
,
909 RID_SVXSTR_TABLE_PRESET_ONLYOUTER
,
910 RID_SVXSTR_TABLE_PRESET_OUTERHORI
,
911 RID_SVXSTR_TABLE_PRESET_OUTERALL
,
912 RID_SVXSTR_TABLE_PRESET_OUTERINNER
914 return pnStrIds
[ GetPresetImageId( nValueSetIdx
) - 1 ];
917 // ----------------------------------------------------------------------------
919 void SvxBorderTabPage::FillPresetVS()
921 ImageList
& rImgList
= aBorderImgLst
;
923 // basic initialization of the ValueSet
924 m_pWndPresets
->SetStyle( m_pWndPresets
->GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
925 m_pWndPresets
->SetColCount( SVX_BORDER_PRESET_COUNT
);
927 // insert images and help texts
928 for( sal_uInt16 nVSIdx
= 1; nVSIdx
<= SVX_BORDER_PRESET_COUNT
; ++nVSIdx
)
930 m_pWndPresets
->InsertItem( nVSIdx
);
931 m_pWndPresets
->SetItemImage( nVSIdx
, rImgList
.GetImage( GetPresetImageId( nVSIdx
) ) );
932 m_pWndPresets
->SetItemText( nVSIdx
, CUI_RESSTR( GetPresetStringId( nVSIdx
) ) );
936 m_pWndPresets
->SetNoSelection();
937 m_pWndPresets
->Show();
940 // ----------------------------------------------------------------------------
942 void SvxBorderTabPage::FillShadowVS()
944 ImageList
& rImgList
= aShadowImgLst
;
946 // basic initialization of the ValueSet
947 m_pWndShadows
->SetStyle( m_pWndShadows
->GetStyle() | WB_ITEMBORDER
| WB_DOUBLEBORDER
);
948 m_pWndShadows
->SetColCount( SVX_BORDER_SHADOW_COUNT
);
950 // image resource IDs
951 static const sal_uInt16 pnImgIds
[ SVX_BORDER_SHADOW_COUNT
] =
952 { IID_SHADOWNONE
, IID_SHADOW_BOT_RIGHT
, IID_SHADOW_TOP_RIGHT
, IID_SHADOW_BOT_LEFT
, IID_SHADOW_TOP_LEFT
};
953 // string resource IDs for each image
954 static const sal_uInt16 pnStrIds
[ SVX_BORDER_SHADOW_COUNT
] =
955 { 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
};
957 // insert images and help texts
958 for( sal_uInt16 nVSIdx
= 1; nVSIdx
<= SVX_BORDER_SHADOW_COUNT
; ++nVSIdx
)
960 m_pWndShadows
->InsertItem( nVSIdx
);
961 m_pWndShadows
->SetItemImage( nVSIdx
, rImgList
.GetImage( pnImgIds
[ nVSIdx
- 1 ] ) );
962 m_pWndShadows
->SetItemText( nVSIdx
, CUI_RESSTR( pnStrIds
[ nVSIdx
- 1 ] ) );
966 m_pWndShadows
->SelectItem( 1 );
967 m_pWndShadows
->Show();
970 // ----------------------------------------------------------------------------
972 void SvxBorderTabPage::FillValueSets()
978 // ============================================================================
979 static Color
lcl_mediumColor( Color aMain
, Color
/*aDefault*/ )
981 return SvxBorderLine::threeDMediumColor( aMain
);
984 void SvxBorderTabPage::FillLineListBox_Impl()
986 using namespace ::com::sun::star::table::BorderLineStyle
;
988 m_pLbLineStyle
->SetSourceUnit( FUNIT_TWIP
);
990 m_pLbLineStyle
->SetNone( SVX_RESSTR( RID_SVXSTR_NONE
) );
993 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( SOLID
), SOLID
);
994 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( DOTTED
), DOTTED
);
995 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( DASHED
), DASHED
);
998 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( DOUBLE
), DOUBLE
);
999 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_SMALLGAP
), THINTHICK_SMALLGAP
, 20 );
1000 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_MEDIUMGAP
), THINTHICK_MEDIUMGAP
);
1001 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_LARGEGAP
), THINTHICK_LARGEGAP
);
1002 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_SMALLGAP
), THICKTHIN_SMALLGAP
, 20 );
1003 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_MEDIUMGAP
), THICKTHIN_MEDIUMGAP
);
1004 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_LARGEGAP
), THICKTHIN_LARGEGAP
);
1006 // Engraved / Embossed
1007 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( EMBOSSED
), EMBOSSED
, 15,
1008 &SvxBorderLine::threeDLightColor
, &SvxBorderLine::threeDDarkColor
,
1010 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( ENGRAVED
), ENGRAVED
, 15,
1011 &SvxBorderLine::threeDDarkColor
, &SvxBorderLine::threeDLightColor
,
1015 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( OUTSET
), OUTSET
, 10,
1016 &SvxBorderLine::lightColor
, &SvxBorderLine::darkColor
);
1017 m_pLbLineStyle
->InsertEntry( SvxBorderLine::getWidthImpl( INSET
), INSET
, 10,
1018 &SvxBorderLine::darkColor
, &SvxBorderLine::lightColor
);
1020 sal_Int64 nVal
= static_cast<sal_Int64
>(MetricField::ConvertDoubleValue(
1021 m_pLineWidthMF
->GetValue( ),
1022 m_pLineWidthMF
->GetDecimalDigits( ),
1023 m_pLineWidthMF
->GetUnit(), MAP_TWIP
));
1024 m_pLbLineStyle
->SetWidth( nVal
);
1027 // -----------------------------------------------------------------------
1028 IMPL_LINK_NOARG(SvxBorderTabPage
, LinesChanged_Impl
)
1030 if(!mbUseMarginItem
&& m_pLeftMF
->IsVisible())
1032 sal_Bool bLineSet
= m_pFrameSel
->IsAnyBorderVisible();
1033 sal_Bool bMinAllowed
= 0 != (nSWMode
& (SW_BORDER_MODE_FRAME
|SW_BORDER_MODE_TABLE
));
1034 sal_Bool bSpaceModified
= m_pLeftMF
->IsModified()||
1035 m_pRightMF
->IsModified()||
1036 m_pTopMF
->IsModified()||
1037 m_pBottomMF
->IsModified();
1043 m_pLeftMF
->SetFirst(nMinValue
);
1044 m_pRightMF
->SetFirst(nMinValue
);
1045 m_pTopMF
->SetFirst(nMinValue
);
1046 m_pBottomMF
->SetFirst(nMinValue
);
1050 m_pLeftMF
->SetValue(nMinValue
);
1051 m_pRightMF
->SetValue(nMinValue
);
1052 m_pTopMF
->SetValue(nMinValue
);
1053 m_pBottomMF
->SetValue(nMinValue
);
1058 m_pLeftMF
->SetMin(0);
1059 m_pRightMF
->SetMin(0);
1060 m_pTopMF
->SetMin(0);
1061 m_pBottomMF
->SetMin(0);
1062 m_pLeftMF
->SetFirst(0);
1063 m_pRightMF
->SetFirst(0);
1064 m_pTopMF
->SetFirst(0);
1065 m_pBottomMF
->SetFirst(0);
1068 m_pLeftMF
->SetValue(0);
1069 m_pRightMF
->SetValue(0);
1070 m_pTopMF
->SetValue(0);
1071 m_pBottomMF
->SetValue(0);
1074 // for tables everything is allowed
1075 sal_uInt16 nValid
= VALID_TOP
|VALID_BOTTOM
|VALID_LEFT
|VALID_RIGHT
;
1077 // for border and paragraph the edit is disabled, if there's no border set
1078 if(nSWMode
& (SW_BORDER_MODE_FRAME
|SW_BORDER_MODE_PARA
))
1082 nValid
= (m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_TOP
) == svx::FRAMESTATE_SHOW
) ? VALID_TOP
: 0;
1083 nValid
|= (m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM
) == svx::FRAMESTATE_SHOW
) ? VALID_BOTTOM
: 0;
1084 nValid
|= (m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_LEFT
) == svx::FRAMESTATE_SHOW
) ? VALID_LEFT
: 0;
1085 nValid
|= (m_pFrameSel
->GetFrameBorderState( svx::FRAMEBORDER_RIGHT
) == svx::FRAMESTATE_SHOW
) ? VALID_RIGHT
: 0;
1090 m_pLeftFT
->Enable(0 != (nValid
&VALID_LEFT
));
1091 m_pRightFT
->Enable(0 != (nValid
&VALID_RIGHT
));
1092 m_pTopFT
->Enable(0 != (nValid
&VALID_TOP
));
1093 m_pBottomFT
->Enable(0 != (nValid
&VALID_BOTTOM
));
1094 m_pLeftMF
->Enable(0 != (nValid
&VALID_LEFT
));
1095 m_pRightMF
->Enable(0 != (nValid
&VALID_RIGHT
));
1096 m_pTopMF
->Enable(0 != (nValid
&VALID_TOP
));
1097 m_pBottomMF
->Enable(0 != (nValid
&VALID_BOTTOM
));
1098 m_pSynchronizeCB
->Enable( m_pRightMF
->IsEnabled() || m_pTopMF
->IsEnabled() ||
1099 m_pBottomMF
->IsEnabled() || m_pLeftMF
->IsEnabled() );
1104 // -----------------------------------------------------------------------
1106 IMPL_LINK( SvxBorderTabPage
, ModifyDistanceHdl_Impl
, MetricField
*, pField
)
1110 sal_Int64 nVal
= pField
->GetValue();
1111 if(pField
!= m_pLeftMF
)
1112 m_pLeftMF
->SetValue(nVal
);
1113 if(pField
!= m_pRightMF
)
1114 m_pRightMF
->SetValue(nVal
);
1115 if(pField
!= m_pTopMF
)
1116 m_pTopMF
->SetValue(nVal
);
1117 if(pField
!= m_pBottomMF
)
1118 m_pBottomMF
->SetValue(nVal
);
1123 IMPL_LINK( SvxBorderTabPage
, SyncHdl_Impl
, CheckBox
*, pBox
)
1125 mbSync
= pBox
->IsChecked();
1129 void SvxBorderTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
1131 if( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
1134 SfxTabPage::DataChanged( rDCEvt
);
1137 void SvxBorderTabPage::PageCreated (SfxAllItemSet aSet
)
1139 SFX_ITEMSET_ARG (&aSet
,pSWModeItem
,SfxUInt16Item
,SID_SWMODE_TYPE
,sal_False
);
1140 SFX_ITEMSET_ARG (&aSet
,pFlagItem
,SfxUInt32Item
,SID_FLAG_TYPE
,sal_False
);
1143 nSWMode
= pSWModeItem
->GetValue();
1145 // show checkbox <m_pMergeWithNextCB> for format.paragraph
1146 if ( nSWMode
== SW_BORDER_MODE_PARA
)
1148 m_pMergeWithNextCB
->Show();
1149 m_pPropertiesFrame
->Show();
1151 // show checkbox <m_pMergeAdjacentBordersCB> for format.paragraph
1152 else if ( nSWMode
== SW_BORDER_MODE_TABLE
)
1154 m_pMergeAdjacentBordersCB
->Show();
1155 m_pPropertiesFrame
->Show();
1159 if ( ( pFlagItem
->GetValue() & SVX_HIDESHADOWCTL
) == SVX_HIDESHADOWCTL
)
1160 HideShadowControls();
1163 // ============================================================================
1165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */