Bump version to 4.3-4
[LibreOffice.git] / cui / source / tabpages / border.cxx
blob6e9e7783c443198b7fe02ca2e8124fb5a9aa0590
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
26 #include <cuires.hrc>
27 #include "border.hrc"
28 #include "helpid.hrc"
30 #include <svx/xtable.hxx>
31 #include <svx/drawitem.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <editeng/shaditem.hxx>
34 #include "border.hxx"
35 #include <svx/dlgutil.hxx>
36 #include <dialmgr.hxx>
37 #include <sfx2/htmlmode.hxx>
38 #include <vcl/msgbox.hxx>
39 #include <vcl/settings.hxx>
40 #include "svx/flagsdef.hxx"
41 #include <sfx2/request.hxx>
42 #include <svl/intitem.hxx>
43 #include <svl/ilstitem.hxx>
44 #include <svl/int64item.hxx>
45 #include <sfx2/itemconnect.hxx>
46 #include <sal/macros.h>
47 #include "borderconn.hxx"
49 using namespace ::editeng;
54 * [Description:]
55 * TabPage for setting the border attributes.
56 * Needs
57 * a SvxShadowItem: shadow
58 * a SvxBoxItem: lines left, right, top, bottom,
59 * a SvxBoxInfo: lines vertical, horizontal, distance, flags
61 * Lines can have three conditions:
62 * 1. Show ( -> valid values )
63 * 2. Hide ( -> NULL-Pointer )
64 * 3. DontCare ( -> special Valid-Flags in the InfoItem )
67 // static ----------------------------------------------------------------
69 static const sal_uInt16 pRanges[] =
71 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
72 SID_ATTR_ALIGN_MARGIN, SID_ATTR_ALIGN_MARGIN,
73 SID_ATTR_BORDER_CONNECT, SID_ATTR_BORDER_CONNECT,
74 SID_SW_COLLAPSING_BORDERS, SID_SW_COLLAPSING_BORDERS,
75 SID_ATTR_BORDER_DIAG_TLBR, SID_ATTR_BORDER_DIAG_BLTR,
80 static void lcl_SetDecimalDigitsTo1(MetricField& rField)
82 sal_Int64 nMin = rField.Denormalize( rField.GetMin( FUNIT_TWIP ) );
83 rField.SetDecimalDigits(1);
84 rField.SetMin( rField.Normalize( nMin ), FUNIT_TWIP );
88 SvxBorderTabPage::SvxBorderTabPage(Window* pParent, const SfxItemSet& rCoreAttrs)
89 : SfxTabPage(pParent, "BorderPage", "cui/ui/borderpage.ui", rCoreAttrs)
93 aShadowImgLst( CUI_RES(IL_SDW_BITMAPS)),
94 aBorderImgLst( CUI_RES(IL_PRE_BITMAPS)),
95 nMinValue(0),
96 nSWMode(0),
97 mbHorEnabled( false ),
98 mbVerEnabled( false ),
99 mbTLBREnabled( false ),
100 mbBLTREnabled( false ),
101 mbUseMarginItem( false ),
102 mbSync(true)
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 if ( GetDPIScaleFactor() > 1 )
136 for (short i = 0; i < aBorderImgLst.GetImageCount(); i++)
138 OUString rImageName = aBorderImgLst.GetImageName(i);
139 BitmapEx b = aBorderImgLst.GetImage(rImageName).GetBitmapEx();
140 b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST);
141 aBorderImgLst.ReplaceImage(rImageName, Image(b));
144 for (short i = 0; i < aShadowImgLst.GetImageCount(); i++)
146 OUString rImageName = aShadowImgLst.GetImageName(i);
147 BitmapEx b = aShadowImgLst.GetImage(rImageName).GetBitmapEx();
148 b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST);
149 aShadowImgLst.ReplaceImage(rImageName, Image(b));
153 // this page needs ExchangeSupport
154 SetExchangeSupport();
156 /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
157 -> Remember this state in mbUseMarginItem, because other special handling
158 is needed across various functions... */
159 mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN),true) != SFX_ITEM_UNKNOWN;
161 const SfxPoolItem* pItem = NULL;
162 if (rCoreAttrs.HasItem(SID_ATTR_BORDER_STYLES, &pItem))
164 const SfxIntegerListItem* p = static_cast<const SfxIntegerListItem*>(pItem);
165 std::vector<sal_Int32> aUsedStyles;
166 p->GetList(aUsedStyles);
167 for (size_t i = 0, n = aUsedStyles.size(); i < n; ++i)
168 maUsedBorderStyles.insert(static_cast<sal_Int16>(aUsedStyles[i]));
171 if (rCoreAttrs.HasItem(SID_ATTR_BORDER_DEFAULT_WIDTH, &pItem))
173 // The caller specifies default line width. Honor it.
174 const SfxInt64Item* p = static_cast<const SfxInt64Item*>(pItem);
175 m_pLineWidthMF->SetValue(p->GetValue());
178 // set metric
179 FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
181 if( mbUseMarginItem )
183 // copied from SvxAlignmentTabPage
184 switch ( eFUnit )
186 // #103396# the default value (1pt) can't be accurately represented in
187 // inches or pica with two decimals, so point is used instead.
188 case FUNIT_PICA:
189 case FUNIT_INCH:
190 case FUNIT_FOOT:
191 case FUNIT_MILE:
192 eFUnit = FUNIT_POINT;
193 break;
195 case FUNIT_CM:
196 case FUNIT_M:
197 case FUNIT_KM:
198 eFUnit = FUNIT_MM;
199 break;
200 default: ;//prevent warning
203 else
205 switch ( eFUnit )
207 case FUNIT_M:
208 case FUNIT_KM:
209 eFUnit = FUNIT_MM;
210 break;
211 default: ; //prevent warning
215 SetFieldUnit(*m_pEdShadowSize, eFUnit);
217 sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, false );
218 bool bIsDontCare = true;
220 if ( rCoreAttrs.GetItemState( nWhich, true ) >= SFX_ITEM_AVAILABLE )
222 // paragraph or table
223 const SvxBoxInfoItem* pBoxInfo =
224 (const SvxBoxInfoItem*)&( rCoreAttrs.Get( nWhich ) );
226 mbHorEnabled = pBoxInfo->IsHorEnabled();
227 mbVerEnabled = pBoxInfo->IsVerEnabled();
228 mbTLBREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR );
229 mbBLTREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR );
231 if(pBoxInfo->IsDist())
233 SetFieldUnit(*m_pLeftMF, eFUnit);
234 SetFieldUnit(*m_pRightMF, eFUnit);
235 SetFieldUnit(*m_pTopMF, eFUnit);
236 SetFieldUnit(*m_pBottomMF, eFUnit);
237 m_pSynchronizeCB->SetClickHdl(LINK(this, SvxBorderTabPage, SyncHdl_Impl));
238 m_pLeftMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
239 m_pRightMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
240 m_pTopMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
241 m_pBottomMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
243 else
245 m_pSpacingFrame->Hide();
247 bIsDontCare = !pBoxInfo->IsValid( VALID_DISABLE );
249 if(!mbUseMarginItem && eFUnit == FUNIT_MM && SFX_MAPUNIT_TWIP == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
251 //#i91548# changing the number of decimal digits changes the minimum values, too
252 lcl_SetDecimalDigitsTo1(*m_pLeftMF);
253 lcl_SetDecimalDigitsTo1(*m_pRightMF);
254 lcl_SetDecimalDigitsTo1(*m_pTopMF);
255 lcl_SetDecimalDigitsTo1(*m_pBottomMF);
256 lcl_SetDecimalDigitsTo1(*m_pEdShadowSize);
259 svx::FrameSelFlags nFlags = svx::FRAMESEL_OUTER;
260 if( mbHorEnabled )
261 nFlags |= svx::FRAMESEL_INNER_HOR;
262 if( mbVerEnabled )
263 nFlags |= svx::FRAMESEL_INNER_VER;
264 if( mbTLBREnabled )
265 nFlags |= svx::FRAMESEL_DIAG_TLBR;
266 if( mbBLTREnabled )
267 nFlags |= svx::FRAMESEL_DIAG_BLTR;
268 if( bIsDontCare )
269 nFlags |= svx::FRAMESEL_DONTCARE;
270 m_pFrameSel->Initialize( nFlags );
272 m_pFrameSel->SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
273 m_pLbLineStyle->SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
274 m_pLbLineColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
275 m_pLineWidthMF->SetModifyHdl( LINK( this, SvxBorderTabPage, ModifyWidthHdl_Impl ) );
276 m_pLbShadowColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
277 m_pWndPresets->SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
278 m_pWndShadows->SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
280 FillValueSets();
281 FillLineListBox_Impl();
283 // fill ColorBox out of the XColorList
284 SfxObjectShell* pDocSh = SfxObjectShell::Current();
285 XColorListRef pColorTable;
287 DBG_ASSERT( pDocSh, "DocShell not found!" );
289 if ( pDocSh )
291 pItem = pDocSh->GetItem( SID_COLOR_TABLE );
292 if ( pItem != NULL )
293 pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
296 DBG_ASSERT( pColorTable.is(), "ColorTable not found!" );
298 if ( pColorTable.is() )
300 // filling the line color box
301 m_pLbLineColor->SetUpdateMode( false );
303 for ( long i = 0; i < pColorTable->Count(); ++i )
305 XColorEntry* pEntry = pColorTable->GetColor(i);
306 m_pLbLineColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
308 m_pLbLineColor->SetUpdateMode( true );
310 m_pLbShadowColor->CopyEntries(*m_pLbLineColor);
313 // connections
315 bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW ) );
316 if( bSupportsShadow )
317 AddItemConnection( svx::CreateShadowConnection( rCoreAttrs, *m_pWndShadows, *m_pEdShadowSize, *m_pLbShadowColor ) );
318 else
319 HideShadowControls();
321 if( mbUseMarginItem )
322 AddItemConnection( svx::CreateMarginConnection( rCoreAttrs, *m_pLeftMF, *m_pRightMF, *m_pTopMF, *m_pBottomMF ) );
323 if( m_pFrameSel->IsBorderEnabled( svx::FRAMEBORDER_TLBR ) )
324 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR, *m_pFrameSel, svx::FRAMEBORDER_TLBR ) );
325 if( m_pFrameSel->IsBorderEnabled( svx::FRAMEBORDER_BLTR ) )
326 AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_BLTR, *m_pFrameSel, svx::FRAMEBORDER_BLTR ) );
327 // #i43593# - item connection doesn't work for Writer,
328 // because the Writer item sets contain these items
329 // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
330 AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, *m_pMergeWithNextCB, sfx::ITEMCONN_DEFAULT ) );
331 m_pMergeWithNextCB->Hide();
332 // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
333 AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, *m_pMergeAdjacentBordersCB, sfx::ITEMCONN_DEFAULT ) );
334 m_pMergeAdjacentBordersCB->Hide();
339 SvxBorderTabPage::~SvxBorderTabPage()
345 const sal_uInt16* SvxBorderTabPage::GetRanges()
347 return pRanges;
352 SfxTabPage* SvxBorderTabPage::Create( Window* pParent,
353 const SfxItemSet& rAttrSet )
355 return ( new SvxBorderTabPage( pParent, rAttrSet ) );
360 void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
362 if( m_pFrameSel->IsBorderEnabled( eBorder ) )
364 if( bValid )
365 m_pFrameSel->ShowBorder( eBorder, pCoreLine );
366 else
367 m_pFrameSel->SetBorderDontCare( eBorder );
371 bool SvxBorderTabPage::IsBorderLineStyleAllowed( sal_Int16 nStyle ) const
373 if (maUsedBorderStyles.empty())
374 // All border styles are allowed.
375 return true;
377 return maUsedBorderStyles.count(nStyle) > 0;
382 void SvxBorderTabPage::Reset( const SfxItemSet& rSet )
384 SfxTabPage::Reset( rSet );
386 const SvxBoxItem* pBoxItem;
387 const SvxBoxInfoItem* pBoxInfoItem;
388 sal_uInt16 nWhichBox = GetWhich(SID_ATTR_BORDER_OUTER);
389 SfxMapUnit eCoreUnit;
391 pBoxItem = (const SvxBoxItem*)GetItem( rSet, SID_ATTR_BORDER_OUTER );
393 pBoxInfoItem = (const SvxBoxInfoItem*)GetItem( rSet, SID_ATTR_BORDER_INNER, false );
395 eCoreUnit = rSet.GetPool()->GetMetric( nWhichBox );
397 if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
399 ResetFrameLine_Impl( svx::FRAMEBORDER_LEFT, pBoxItem->GetLeft(), pBoxInfoItem->IsValid( VALID_LEFT ) );
400 ResetFrameLine_Impl( svx::FRAMEBORDER_RIGHT, pBoxItem->GetRight(), pBoxInfoItem->IsValid( VALID_RIGHT ) );
401 ResetFrameLine_Impl( svx::FRAMEBORDER_TOP, pBoxItem->GetTop(), pBoxInfoItem->IsValid( VALID_TOP ) );
402 ResetFrameLine_Impl( svx::FRAMEBORDER_BOTTOM, pBoxItem->GetBottom(), pBoxInfoItem->IsValid( VALID_BOTTOM ) );
403 ResetFrameLine_Impl( svx::FRAMEBORDER_VER, pBoxInfoItem->GetVert(), pBoxInfoItem->IsValid( VALID_VERT ) );
404 ResetFrameLine_Impl( svx::FRAMEBORDER_HOR, pBoxInfoItem->GetHori(), pBoxInfoItem->IsValid( VALID_HORI ) );
407 // distance inside
409 if( !mbUseMarginItem )
411 if ( m_pLeftMF->IsVisible() )
413 SetMetricValue(*m_pLeftMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
414 SetMetricValue(*m_pRightMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
415 SetMetricValue(*m_pTopMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
416 SetMetricValue(*m_pBottomMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
418 nMinValue = static_cast<long>(m_pLeftMF->GetValue());
420 if ( pBoxInfoItem->IsMinDist() )
422 m_pLeftMF->SetFirst( nMinValue );
423 m_pRightMF->SetFirst( nMinValue );
424 m_pTopMF->SetFirst( nMinValue );
425 m_pBottomMF->SetFirst( nMinValue );
428 if ( pBoxInfoItem->IsDist() )
430 if( rSet.GetItemState( nWhichBox, true ) >= SFX_ITEM_DEFAULT )
432 bool bIsAnyBorderVisible = m_pFrameSel->IsAnyBorderVisible();
433 if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
435 m_pLeftMF->SetMin( 0 );
436 m_pLeftMF->SetFirst( 0 );
437 m_pRightMF->SetMin( 0 );
438 m_pRightMF->SetFirst( 0 );
439 m_pTopMF->SetMin( 0 );
440 m_pTopMF->SetFirst( 0 );
441 m_pBottomMF->SetMin( 0 );
442 m_pBottomMF->SetFirst( 0 );
444 long nLeftDist = pBoxItem->GetDistance( BOX_LINE_LEFT);
445 SetMetricValue(*m_pLeftMF, nLeftDist, eCoreUnit);
446 long nRightDist = pBoxItem->GetDistance( BOX_LINE_RIGHT);
447 SetMetricValue(*m_pRightMF, nRightDist, eCoreUnit);
448 long nTopDist = pBoxItem->GetDistance( BOX_LINE_TOP);
449 SetMetricValue( *m_pTopMF, nTopDist, eCoreUnit );
450 long nBottomDist = pBoxItem->GetDistance( BOX_LINE_BOTTOM);
451 SetMetricValue( *m_pBottomMF, nBottomDist, eCoreUnit );
453 // if the distance is set with no active border line
454 // or it is null with an active border line
455 // no automatic changes should be made
456 const long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
457 bool bDiffDist = (nDefDist != nLeftDist ||
458 nDefDist != nRightDist ||
459 nDefDist != nTopDist ||
460 nDefDist != nBottomDist);
461 if((pBoxItem->GetDistance() ||
462 bIsAnyBorderVisible) && bDiffDist )
464 m_pLeftMF->SetModifyFlag();
465 m_pRightMF->SetModifyFlag();
466 m_pTopMF->SetModifyFlag();
467 m_pBottomMF->SetModifyFlag();
470 else
472 // #106224# different margins -> do not fill the edits
473 m_pLeftMF->SetText( OUString() );
474 m_pRightMF->SetText( OUString() );
475 m_pTopMF->SetText( OUString() );
476 m_pBottomMF->SetText( OUString() );
479 m_pLeftMF->SaveValue();
480 m_pRightMF->SaveValue();
481 m_pTopMF->SaveValue();
482 m_pBottomMF->SaveValue();
486 else
488 // avoid ResetFrameLine-calls:
489 m_pFrameSel->HideAllBorders();
493 // depict line (color) in controllers if unambiguous:
496 // Do all visible lines show the same line widths?
497 long nWidth;
498 SvxBorderStyle nStyle;
499 bool bWidthEq = m_pFrameSel->GetVisibleWidth( nWidth, nStyle );
500 if( bWidthEq )
502 // Determine the width first as some styles can be missing depending on it
503 sal_Int64 nWidthPt = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
504 sal_Int64( nWidth ), m_pLineWidthMF->GetDecimalDigits( ),
505 MAP_TWIP,m_pLineWidthMF->GetUnit() ));
506 m_pLineWidthMF->SetValue( nWidthPt );
507 m_pLbLineStyle->SetWidth( nWidth );
509 // then set the style
510 m_pLbLineStyle->SelectEntry( nStyle );
512 else
513 m_pLbLineStyle->SelectEntryPos( 1 );
515 // Do all visible lines show the same line color?
516 Color aColor;
517 bool bColorEq = m_pFrameSel->GetVisibleColor( aColor );
518 if( !bColorEq )
519 aColor.SetColor( COL_BLACK );
521 sal_Int32 nSelPos = m_pLbLineColor->GetEntryPos( aColor );
522 if( nSelPos == LISTBOX_ENTRY_NOTFOUND )
523 nSelPos = m_pLbLineColor->InsertEntry( aColor, SVX_RESSTR( RID_SVXSTR_COLOR_USER ) );
525 m_pLbLineColor->SelectEntryPos( nSelPos );
526 m_pLbLineStyle->SetColor( aColor );
528 // Select all visible lines, if they are all equal.
529 if( bWidthEq && bColorEq )
530 m_pFrameSel->SelectAllVisibleBorders();
532 // set the current style and color (caches style in control even if nothing is selected)
533 SelStyleHdl_Impl(m_pLbLineStyle);
534 SelColHdl_Impl(m_pLbLineColor);
537 bool bEnable = m_pWndShadows->GetSelectItemId() > 1 ;
538 m_pFtShadowSize->Enable(bEnable);
539 m_pEdShadowSize->Enable(bEnable);
540 m_pFtShadowColor->Enable(bEnable);
541 m_pLbShadowColor->Enable(bEnable);
543 m_pWndPresets->SetNoSelection();
545 // - no line - should not be selected
547 if ( m_pLbLineStyle->GetSelectEntryPos() == 0 )
549 m_pLbLineStyle->SelectEntryPos( 1 );
550 SelStyleHdl_Impl(m_pLbLineStyle);
553 const SfxPoolItem* pItem;
554 SfxObjectShell* pShell;
555 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem) ||
556 ( 0 != (pShell = SfxObjectShell::Current()) &&
557 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
559 sal_uInt16 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
560 if(nHtmlMode & HTMLMODE_ON)
562 // there are no shadows in Html-mode and only complete borders
563 m_pShadowFrame->Disable();
565 if( !(nSWMode & SW_BORDER_MODE_TABLE) )
567 m_pUserDefFT->Disable();
568 m_pFrameSel->Disable();
569 m_pWndPresets->RemoveItem(3);
570 m_pWndPresets->RemoveItem(4);
571 m_pWndPresets->RemoveItem(5);
576 LinesChanged_Impl( 0 );
577 if(m_pLeftMF->GetValue() == m_pRightMF->GetValue() && m_pTopMF->GetValue() == m_pBottomMF->GetValue() && m_pTopMF->GetValue() == m_pLeftMF->GetValue())
578 mbSync = true;
579 else
580 mbSync = false;
581 m_pSynchronizeCB->Check(mbSync);
586 int SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
588 if ( _pSet )
589 FillItemSet( *_pSet );
591 return LEAVE_PAGE;
596 bool SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
598 bool bAttrsChanged = SfxTabPage::FillItemSet( rCoreAttrs );
600 bool bPut = true;
601 sal_uInt16 nBoxWhich = GetWhich( SID_ATTR_BORDER_OUTER );
602 sal_uInt16 nBoxInfoWhich = rCoreAttrs.GetPool()->GetWhich( SID_ATTR_BORDER_INNER, false );
603 const SfxItemSet& rOldSet = GetItemSet();
604 SvxBoxItem aBoxItem ( nBoxWhich );
605 SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich );
606 SvxBoxItem* pOldBoxItem = (SvxBoxItem*)GetOldItem( rCoreAttrs, SID_ATTR_BORDER_OUTER );
608 SfxMapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
611 // outer border:
613 typedef ::std::pair<svx::FrameBorderType,sal_uInt16> TBorderPair;
614 TBorderPair eTypes1[] = {
615 TBorderPair(svx::FRAMEBORDER_TOP,BOX_LINE_TOP),
616 TBorderPair(svx::FRAMEBORDER_BOTTOM,BOX_LINE_BOTTOM),
617 TBorderPair(svx::FRAMEBORDER_LEFT,BOX_LINE_LEFT),
618 TBorderPair(svx::FRAMEBORDER_RIGHT,BOX_LINE_RIGHT),
621 for (sal_uInt32 i=0; i < SAL_N_ELEMENTS(eTypes1); ++i)
622 aBoxItem.SetLine( m_pFrameSel->GetFrameBorderStyle( eTypes1[i].first ), eTypes1[i].second );
625 // border hor/ver and TableFlag
627 TBorderPair eTypes2[] = {
628 TBorderPair(svx::FRAMEBORDER_HOR,BOXINFO_LINE_HORI),
629 TBorderPair(svx::FRAMEBORDER_VER,BOXINFO_LINE_VERT)
631 for (sal_uInt32 j=0; j < SAL_N_ELEMENTS(eTypes2); ++j)
632 aBoxInfoItem.SetLine( m_pFrameSel->GetFrameBorderStyle( eTypes2[j].first ), eTypes2[j].second );
634 aBoxInfoItem.EnableHor( mbHorEnabled );
635 aBoxInfoItem.EnableVer( mbVerEnabled );
638 // inner distance
640 if( m_pLeftMF->IsVisible() )
642 // #i40405# enable distance controls for next dialog call
643 aBoxInfoItem.SetDist( true );
645 if( !mbUseMarginItem )
647 // #106224# all edits empty: do nothing
648 if( !m_pLeftMF->GetText().isEmpty() || !m_pRightMF->GetText().isEmpty() ||
649 !m_pTopMF->GetText().isEmpty() || !m_pBottomMF->GetText().isEmpty() )
651 if ( ((mbHorEnabled || mbVerEnabled || (nSWMode & SW_BORDER_MODE_TABLE)) &&
652 (m_pLeftMF->IsModified()||m_pRightMF->IsModified()||
653 m_pTopMF->IsModified()||m_pBottomMF->IsModified()) )||
654 m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_HIDE
655 || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_HIDE
656 || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_HIDE
657 || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_HIDE )
659 SvxBoxInfoItem* pOldBoxInfoItem = (SvxBoxInfoItem*)GetOldItem(
660 rCoreAttrs, SID_ATTR_BORDER_INNER );
661 if (
662 !pOldBoxItem ||
663 m_pLeftMF->IsValueChangedFromSaved() ||
664 m_pRightMF->IsValueChangedFromSaved() ||
665 m_pTopMF->IsValueChangedFromSaved() ||
666 m_pBottomMF->IsValueChangedFromSaved() ||
667 nMinValue == m_pLeftMF->GetValue() ||
668 nMinValue == m_pRightMF->GetValue() ||
669 nMinValue == m_pTopMF->GetValue() ||
670 nMinValue == m_pBottomMF->GetValue() ||
671 (pOldBoxInfoItem && !pOldBoxInfoItem->IsValid(VALID_DISTANCE))
674 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pLeftMF, eCoreUnit ), BOX_LINE_LEFT );
675 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pRightMF, eCoreUnit ), BOX_LINE_RIGHT );
676 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pTopMF, eCoreUnit ), BOX_LINE_TOP );
677 aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pBottomMF, eCoreUnit ), BOX_LINE_BOTTOM);
679 else
681 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_LEFT ), BOX_LINE_LEFT);
682 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_RIGHT), BOX_LINE_RIGHT);
683 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_TOP ), BOX_LINE_TOP);
684 aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_BOTTOM), BOX_LINE_BOTTOM);
686 aBoxInfoItem.SetValid( VALID_DISTANCE, true );
688 else
689 aBoxInfoItem.SetValid( VALID_DISTANCE, false );
695 // note Don't Care Status in the Info-Item:
697 aBoxInfoItem.SetValid( VALID_TOP, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_DONTCARE );
698 aBoxInfoItem.SetValid( VALID_BOTTOM, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_DONTCARE );
699 aBoxInfoItem.SetValid( VALID_LEFT, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_DONTCARE );
700 aBoxInfoItem.SetValid( VALID_RIGHT, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_DONTCARE );
701 aBoxInfoItem.SetValid( VALID_HORI, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_HOR ) != svx::FRAMESTATE_DONTCARE );
702 aBoxInfoItem.SetValid( VALID_VERT, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_VER ) != svx::FRAMESTATE_DONTCARE );
705 // Put or Clear of the border?
707 bPut = true;
709 if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxWhich, false ))
711 bPut = aBoxItem != (const SvxBoxItem&)(rOldSet.Get(nBoxWhich));
713 if( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, false ) )
715 const SvxBoxInfoItem& rOldBoxInfo = (const SvxBoxInfoItem&)
716 rOldSet.Get(nBoxInfoWhich);
718 aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
719 aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
720 bPut |= (aBoxInfoItem != rOldBoxInfo );
723 if ( bPut )
725 if ( !pOldBoxItem || !( *pOldBoxItem == aBoxItem ) )
727 rCoreAttrs.Put( aBoxItem );
728 bAttrsChanged |= true;
730 const SfxPoolItem* pOld = GetOldItem( rCoreAttrs, SID_ATTR_BORDER_INNER, false );
732 if ( !pOld || !( *(const SvxBoxInfoItem*)pOld == aBoxInfoItem ) )
734 rCoreAttrs.Put( aBoxInfoItem );
735 bAttrsChanged |= true;
738 else
740 rCoreAttrs.ClearItem( nBoxWhich );
741 rCoreAttrs.ClearItem( nBoxInfoWhich );
744 return bAttrsChanged;
749 void SvxBorderTabPage::HideShadowControls()
751 m_pShadowFrame->Hide();
756 IMPL_LINK_NOARG(SvxBorderTabPage, SelPreHdl_Impl)
758 const svx::FrameBorderState SHOW = svx::FRAMESTATE_SHOW;
759 const svx::FrameBorderState HIDE = svx::FRAMESTATE_HIDE;
760 const svx::FrameBorderState DONT = svx::FRAMESTATE_DONTCARE;
762 static const svx::FrameBorderState ppeStates[][ svx::FRAMEBORDERTYPE_COUNT ] =
763 { /* Left Right Top Bot Hor Ver TLBR BLTR */
764 /* ---------------------+--------------------------------------------------- */
765 /* IID_PRE_CELL_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
766 /* IID_PRE_CELL_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
767 /* IID_PRE_CELL_LR */ { SHOW, SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
768 /* IID_PRE_CELL_TB */ { HIDE, HIDE, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
769 /* IID_PRE_CELL_L */ { SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
770 /* IID_PRE_CELL_DIAG */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, SHOW, SHOW },
771 /* IID_PRE_HOR_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
772 /* IID_PRE_HOR_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
773 /* IID_PRE_HOR_HOR */ { HIDE, HIDE, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
774 /* IID_PRE_HOR_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
775 /* IID_PRE_HOR_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, HIDE, HIDE, HIDE },
776 /* IID_PRE_VER_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
777 /* IID_PRE_VER_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
778 /* IID_PRE_VER_VER */ { SHOW, SHOW, HIDE, HIDE, HIDE, SHOW, HIDE, HIDE },
779 /* IID_PRE_VER_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, SHOW, HIDE, HIDE },
780 /* IID_PRE_VER_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, HIDE, DONT, HIDE, HIDE },
781 /* IID_PRE_TABLE_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
782 /* IID_PRE_TABLE_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
783 /* IID_PRE_TABLE_OUTERH */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
784 /* IID_PRE_TABLE_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE },
785 /* IID_PRE_TABLE_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, DONT, HIDE, HIDE }
788 // first hide and deselect all frame borders
789 m_pFrameSel->HideAllBorders();
790 m_pFrameSel->DeselectAllBorders();
792 // Using image ID to find correct line in table above.
793 sal_uInt16 nLine = GetPresetImageId( m_pWndPresets->GetSelectItemId() ) - 1;
795 // Apply all styles from the table
796 for( int nBorder = 0; nBorder < svx::FRAMEBORDERTYPE_COUNT; ++nBorder )
798 svx::FrameBorderType eBorder = svx::GetFrameBorderTypeFromIndex( nBorder );
799 switch( ppeStates[ nLine ][ nBorder ] )
801 case SHOW: m_pFrameSel->SelectBorder( eBorder ); break;
802 case HIDE: /* nothing to do */ break;
803 case DONT: m_pFrameSel->SetBorderDontCare( eBorder ); break;
807 // Show all lines that have been selected above
808 if( m_pFrameSel->IsAnyBorderSelected() )
810 // any visible style, but "no-line" in line list box? -> use hair-line
811 if( (m_pLbLineStyle->GetSelectEntryPos() == 0) || (m_pLbLineStyle->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) )
812 m_pLbLineStyle->SelectEntryPos( 1 );
814 // set current style to all previously selected lines
815 SelStyleHdl_Impl(m_pLbLineStyle);
816 SelColHdl_Impl(m_pLbLineColor);
819 // Presets ValueSet does not show a selection (used as push buttons).
820 m_pWndPresets->SetNoSelection();
822 LinesChanged_Impl( 0 );
823 return 0;
828 IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl)
830 bool bEnable = m_pWndShadows->GetSelectItemId() > 1;
831 m_pFtShadowSize->Enable(bEnable);
832 m_pEdShadowSize->Enable(bEnable);
833 m_pFtShadowColor->Enable(bEnable);
834 m_pLbShadowColor->Enable(bEnable);
835 return 0;
840 IMPL_LINK( SvxBorderTabPage, SelColHdl_Impl, ListBox *, pLb )
842 ColorListBox* pColLb = (ColorListBox*)(pLb);
844 if (pLb == m_pLbLineColor)
846 m_pFrameSel->SetColorToSelection( pColLb->GetSelectEntryColor() );
847 m_pLbLineStyle->SetColor( pColLb->GetSelectEntryColor() );
850 return 0;
853 IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthHdl_Impl)
855 sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
856 m_pLineWidthMF->GetValue( ),
857 m_pLineWidthMF->GetDecimalDigits( ),
858 m_pLineWidthMF->GetUnit(), MAP_TWIP ));
859 m_pLbLineStyle->SetWidth( nVal );
861 m_pFrameSel->SetStyleToSelection( nVal,
862 SvxBorderStyle( m_pLbLineStyle->GetSelectEntryStyle() ) );
864 return 0;
869 IMPL_LINK( SvxBorderTabPage, SelStyleHdl_Impl, ListBox *, pLb )
871 if (pLb == m_pLbLineStyle)
873 sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
874 m_pLineWidthMF->GetValue( ),
875 m_pLineWidthMF->GetDecimalDigits( ),
876 m_pLineWidthMF->GetUnit(), MAP_TWIP ));
877 m_pFrameSel->SetStyleToSelection ( nVal,
878 SvxBorderStyle( m_pLbLineStyle->GetSelectEntryStyle() ) );
881 return 0;
885 // ValueSet handling
888 // number of preset images to show
889 const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5;
891 // number of shadow images to show
892 const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5;
896 sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
898 // table with all sets of predefined border styles
899 static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] =
901 // simple cell without diagonal frame borders
902 { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_L },
903 // simple cell with diagonal frame borders
904 { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_DIAG },
905 // with horizontal inner frame border
906 { IID_PRE_HOR_NONE, IID_PRE_HOR_OUTER, IID_PRE_HOR_HOR, IID_PRE_HOR_ALL, IID_PRE_HOR_OUTER2 },
907 // with vertical inner frame border
908 { IID_PRE_VER_NONE, IID_PRE_VER_OUTER, IID_PRE_VER_VER, IID_PRE_VER_ALL, IID_PRE_VER_OUTER2 },
909 // with horizontal and vertical inner frame borders
910 { IID_PRE_TABLE_NONE, IID_PRE_TABLE_OUTER, IID_PRE_TABLE_OUTERH, IID_PRE_TABLE_ALL, IID_PRE_TABLE_OUTER2 }
913 // find correct set of presets
914 int nLine = 0;
915 if( !mbHorEnabled && !mbVerEnabled )
916 nLine = (mbTLBREnabled || mbBLTREnabled) ? 1 : 0;
917 else if( mbHorEnabled && !mbVerEnabled )
918 nLine = 2;
919 else if( !mbHorEnabled && mbVerEnabled )
920 nLine = 3;
921 else
922 nLine = 4;
924 DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT),
925 "SvxBorderTabPage::GetPresetImageId - wrong index" );
926 return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
929 sal_uInt16 SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
931 // string resource IDs for each image (in order of the IID_PRE_* image IDs)
932 static const sal_uInt16 pnStrIds[] =
934 RID_SVXSTR_TABLE_PRESET_NONE,
935 RID_SVXSTR_PARA_PRESET_ALL,
936 RID_SVXSTR_PARA_PRESET_LEFTRIGHT,
937 RID_SVXSTR_PARA_PRESET_TOPBOTTOM,
938 RID_SVXSTR_PARA_PRESET_ONLYLEFT,
939 RID_SVXSTR_PARA_PRESET_DIAGONAL,
941 RID_SVXSTR_TABLE_PRESET_NONE,
942 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
943 RID_SVXSTR_HOR_PRESET_ONLYHOR,
944 RID_SVXSTR_TABLE_PRESET_OUTERALL,
945 RID_SVXSTR_TABLE_PRESET_OUTERINNER,
947 RID_SVXSTR_TABLE_PRESET_NONE,
948 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
949 RID_SVXSTR_VER_PRESET_ONLYVER,
950 RID_SVXSTR_TABLE_PRESET_OUTERALL,
951 RID_SVXSTR_TABLE_PRESET_OUTERINNER,
953 RID_SVXSTR_TABLE_PRESET_NONE,
954 RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
955 RID_SVXSTR_TABLE_PRESET_OUTERHORI,
956 RID_SVXSTR_TABLE_PRESET_OUTERALL,
957 RID_SVXSTR_TABLE_PRESET_OUTERINNER
959 return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
964 void SvxBorderTabPage::FillPresetVS()
966 ImageList& rImgList = aBorderImgLst;
968 // basic initialization of the ValueSet
969 m_pWndPresets->SetStyle( m_pWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
970 m_pWndPresets->SetColCount( SVX_BORDER_PRESET_COUNT );
972 // insert images and help texts
973 for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx )
975 m_pWndPresets->InsertItem( nVSIdx );
976 m_pWndPresets->SetItemImage( nVSIdx, rImgList.GetImage( GetPresetImageId( nVSIdx ) ) );
977 m_pWndPresets->SetItemText( nVSIdx, CUI_RESSTR( GetPresetStringId( nVSIdx ) ) );
980 // show the control
981 m_pWndPresets->SetNoSelection();
982 m_pWndPresets->Show();
987 void SvxBorderTabPage::FillShadowVS()
989 ImageList& rImgList = aShadowImgLst;
991 // basic initialization of the ValueSet
992 m_pWndShadows->SetStyle( m_pWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
993 m_pWndShadows->SetColCount( SVX_BORDER_SHADOW_COUNT );
995 // image resource IDs
996 static const sal_uInt16 pnImgIds[ SVX_BORDER_SHADOW_COUNT ] =
997 { IID_SHADOWNONE, IID_SHADOW_BOT_RIGHT, IID_SHADOW_TOP_RIGHT, IID_SHADOW_BOT_LEFT, IID_SHADOW_TOP_LEFT };
998 // string resource IDs for each image
999 static const sal_uInt16 pnStrIds[ SVX_BORDER_SHADOW_COUNT ] =
1000 { 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 };
1002 // insert images and help texts
1003 for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx )
1005 m_pWndShadows->InsertItem( nVSIdx );
1006 m_pWndShadows->SetItemImage( nVSIdx, rImgList.GetImage( pnImgIds[ nVSIdx - 1 ] ) );
1007 m_pWndShadows->SetItemText( nVSIdx, CUI_RESSTR( pnStrIds[ nVSIdx - 1 ] ) );
1010 // show the control
1011 m_pWndShadows->SelectItem( 1 );
1012 m_pWndShadows->Show();
1017 void SvxBorderTabPage::FillValueSets()
1019 FillPresetVS();
1020 FillShadowVS();
1024 static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1026 return SvxBorderLine::threeDMediumColor( aMain );
1029 void SvxBorderTabPage::FillLineListBox_Impl()
1031 using namespace ::com::sun::star::table::BorderLineStyle;
1033 struct {
1034 sal_Int16 mnStyle;
1035 long mnMinWidth;
1036 LineListBox::ColorFunc mpColor1Fn;
1037 LineListBox::ColorFunc mpColor2Fn;
1038 LineListBox::ColorDistFunc mpColorDistFn;
1039 } aLines[] = {
1040 // Simple lines
1041 { SOLID, 0, &sameColor, &sameColor, &sameDistColor },
1042 { DOTTED, 0, &sameColor, &sameColor, &sameDistColor },
1043 { DASHED, 0, &sameColor, &sameColor, &sameDistColor },
1044 { FINE_DASHED, 0, &sameColor, &sameColor, &sameDistColor },
1045 { DASH_DOT, 0, &sameColor, &sameColor, &sameDistColor },
1046 { DASH_DOT_DOT, 0, &sameColor, &sameColor, &sameDistColor },
1048 // Double lines
1049 { DOUBLE, 10, &sameColor, &sameColor, &sameDistColor },
1050 { DOUBLE_THIN, 10, &sameColor, &sameColor, &sameDistColor },
1051 { THINTHICK_SMALLGAP, 20, &sameColor, &sameColor, &sameDistColor },
1052 { THINTHICK_MEDIUMGAP, 0, &sameColor, &sameColor, &sameDistColor },
1053 { THINTHICK_LARGEGAP, 0, &sameColor, &sameColor, &sameDistColor },
1054 { THICKTHIN_SMALLGAP, 20, &sameColor, &sameColor, &sameDistColor },
1055 { THICKTHIN_MEDIUMGAP, 0, &sameColor, &sameColor, &sameDistColor },
1056 { THICKTHIN_LARGEGAP, 0, &sameColor, &sameColor, &sameDistColor },
1058 { EMBOSSED, 15, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor },
1059 { ENGRAVED, 15, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor },
1061 { OUTSET, 10, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor },
1062 { INSET, 10, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor }
1065 m_pLbLineStyle->SetSourceUnit( FUNIT_TWIP );
1067 m_pLbLineStyle->SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) );
1069 for (size_t i = 0, n = SAL_N_ELEMENTS(aLines); i < n; ++i)
1071 if (!IsBorderLineStyleAllowed(aLines[i].mnStyle))
1072 continue;
1074 m_pLbLineStyle->InsertEntry(
1075 SvxBorderLine::getWidthImpl(aLines[i].mnStyle), aLines[i].mnStyle,
1076 aLines[i].mnMinWidth, aLines[i].mpColor1Fn, aLines[i].mpColor2Fn, aLines[i].mpColorDistFn);
1079 sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
1080 m_pLineWidthMF->GetValue( ),
1081 m_pLineWidthMF->GetDecimalDigits( ),
1082 m_pLineWidthMF->GetUnit(), MAP_TWIP ));
1083 m_pLbLineStyle->SetWidth( nVal );
1087 IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl)
1089 if(!mbUseMarginItem && m_pLeftMF->IsVisible())
1091 bool bLineSet = m_pFrameSel->IsAnyBorderVisible();
1092 bool bMinAllowed = 0 != (nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_TABLE));
1093 bool bSpaceModified = m_pLeftMF->IsModified()||
1094 m_pRightMF->IsModified()||
1095 m_pTopMF->IsModified()||
1096 m_pBottomMF->IsModified();
1098 if(bLineSet)
1100 if(!bMinAllowed)
1102 m_pLeftMF->SetFirst(nMinValue);
1103 m_pRightMF->SetFirst(nMinValue);
1104 m_pTopMF->SetFirst(nMinValue);
1105 m_pBottomMF->SetFirst(nMinValue);
1107 if(!bSpaceModified)
1109 m_pLeftMF->SetValue(nMinValue);
1110 m_pRightMF->SetValue(nMinValue);
1111 m_pTopMF->SetValue(nMinValue);
1112 m_pBottomMF->SetValue(nMinValue);
1115 else
1117 m_pLeftMF->SetMin(0);
1118 m_pRightMF->SetMin(0);
1119 m_pTopMF->SetMin(0);
1120 m_pBottomMF->SetMin(0);
1121 m_pLeftMF->SetFirst(0);
1122 m_pRightMF->SetFirst(0);
1123 m_pTopMF->SetFirst(0);
1124 m_pBottomMF->SetFirst(0);
1125 if(!bSpaceModified)
1127 m_pLeftMF->SetValue(0);
1128 m_pRightMF->SetValue(0);
1129 m_pTopMF->SetValue(0);
1130 m_pBottomMF->SetValue(0);
1133 // for tables everything is allowed
1134 sal_uInt16 nValid = VALID_TOP|VALID_BOTTOM|VALID_LEFT|VALID_RIGHT;
1136 // for other objects (paragraph, page, frame, character) the edit is disabled, if there's no border set
1137 if(!(nSWMode & SW_BORDER_MODE_TABLE))
1139 if(bLineSet)
1141 nValid = (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP) == svx::FRAMESTATE_SHOW) ? VALID_TOP : 0;
1142 nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM) == svx::FRAMESTATE_SHOW) ? VALID_BOTTOM : 0;
1143 nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT) == svx::FRAMESTATE_SHOW) ? VALID_LEFT : 0;
1144 nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) == svx::FRAMESTATE_SHOW) ? VALID_RIGHT : 0;
1146 else
1147 nValid = 0;
1149 m_pLeftFT->Enable(0 != (nValid&VALID_LEFT));
1150 m_pRightFT->Enable(0 != (nValid&VALID_RIGHT));
1151 m_pTopFT->Enable(0 != (nValid&VALID_TOP));
1152 m_pBottomFT->Enable(0 != (nValid&VALID_BOTTOM));
1153 m_pLeftMF->Enable(0 != (nValid&VALID_LEFT));
1154 m_pRightMF->Enable(0 != (nValid&VALID_RIGHT));
1155 m_pTopMF->Enable(0 != (nValid&VALID_TOP));
1156 m_pBottomMF->Enable(0 != (nValid&VALID_BOTTOM));
1157 m_pSynchronizeCB->Enable( m_pRightMF->IsEnabled() || m_pTopMF->IsEnabled() ||
1158 m_pBottomMF->IsEnabled() || m_pLeftMF->IsEnabled() );
1160 return 0;
1165 IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, MetricField*, pField)
1167 if ( mbSync )
1169 sal_Int64 nVal = pField->GetValue();
1170 if(pField != m_pLeftMF)
1171 m_pLeftMF->SetValue(nVal);
1172 if(pField != m_pRightMF)
1173 m_pRightMF->SetValue(nVal);
1174 if(pField != m_pTopMF)
1175 m_pTopMF->SetValue(nVal);
1176 if(pField != m_pBottomMF)
1177 m_pBottomMF->SetValue(nVal);
1179 return 0;
1182 IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, CheckBox*, pBox)
1184 mbSync = pBox->IsChecked();
1185 return 0;
1188 void SvxBorderTabPage::DataChanged( const DataChangedEvent& rDCEvt )
1190 if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1191 FillValueSets();
1193 SfxTabPage::DataChanged( rDCEvt );
1196 void SvxBorderTabPage::PageCreated(const SfxAllItemSet& aSet)
1198 SFX_ITEMSET_ARG (&aSet,pSWModeItem,SfxUInt16Item,SID_SWMODE_TYPE,false);
1199 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false);
1200 if (pSWModeItem)
1202 nSWMode = pSWModeItem->GetValue();
1203 // #i43593#
1204 // show checkbox <m_pMergeWithNextCB> for format.paragraph
1205 if ( nSWMode == SW_BORDER_MODE_PARA )
1207 m_pMergeWithNextCB->Show();
1208 m_pPropertiesFrame->Show();
1210 // show checkbox <m_pMergeAdjacentBordersCB> for format.paragraph
1211 else if ( nSWMode == SW_BORDER_MODE_TABLE )
1213 m_pMergeAdjacentBordersCB->Show();
1214 m_pPropertiesFrame->Show();
1217 if (pFlagItem)
1218 if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
1219 HideShadowControls();
1222 void SvxBorderTabPage::SetTableMode()
1224 nSWMode = SW_BORDER_MODE_TABLE;
1227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */