Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
25 :
26 : #include <cuires.hrc>
27 : #include "border.hrc"
28 : #include "helpid.hrc"
29 :
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"
48 :
49 : using namespace ::editeng;
50 :
51 :
52 :
53 : /*
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
60 : *
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 )
65 : */
66 :
67 : // static ----------------------------------------------------------------
68 :
69 : static const sal_uInt16 pRanges[] =
70 : {
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,
76 : 0
77 : };
78 :
79 :
80 0 : static void lcl_SetDecimalDigitsTo1(MetricField& rField)
81 : {
82 0 : sal_Int64 nMin = rField.Denormalize( rField.GetMin( FUNIT_TWIP ) );
83 0 : rField.SetDecimalDigits(1);
84 0 : rField.SetMin( rField.Normalize( nMin ), FUNIT_TWIP );
85 0 : }
86 :
87 :
88 0 : SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCoreAttrs)
89 : : SfxTabPage(pParent, "BorderPage", "cui/ui/borderpage.ui", &rCoreAttrs)
90 :
91 : ,
92 :
93 0 : aShadowImgLst( CUI_RES(IL_SDW_BITMAPS)),
94 0 : 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 0 : mbSync(true)
103 :
104 : {
105 0 : get(m_pWndPresets, "presets");
106 0 : get(m_pUserDefFT, "userdefft");
107 0 : get(m_pFrameSel, "framesel");
108 0 : get(m_pLbLineStyle, "linestylelb");
109 0 : get(m_pLbLineColor, "linecolorlb");
110 0 : get(m_pLineWidthMF, "linewidthmf");
111 :
112 0 : get(m_pSpacingFrame, "spacing");
113 0 : get(m_pLeftFT, "leftft");
114 0 : get(m_pLeftMF, "leftmf");
115 0 : get(m_pRightFT, "rightft");
116 0 : get(m_pRightMF, "rightmf");
117 0 : get(m_pTopFT, "topft");
118 0 : get(m_pTopMF, "topmf");
119 0 : get(m_pBottomFT, "bottomft");
120 0 : get(m_pBottomMF, "bottommf");
121 0 : get(m_pSynchronizeCB, "sync");
122 :
123 0 : get(m_pShadowFrame, "shadow");
124 0 : get(m_pWndShadows, "shadows");
125 0 : get(m_pFtShadowSize, "distanceft");
126 0 : get(m_pEdShadowSize, "distancemf");
127 0 : get(m_pFtShadowColor, "shadowcolorft");
128 0 : get(m_pLbShadowColor, "shadowcolorlb");
129 :
130 0 : get(m_pPropertiesFrame, "properties");
131 0 : get(m_pMergeWithNextCB, "mergewithnext");
132 0 : get(m_pMergeAdjacentBordersCB, "mergeadjacent");
133 :
134 0 : if ( GetDPIScaleFactor() > 1 )
135 : {
136 0 : for (short i = 0; i < aBorderImgLst.GetImageCount(); i++)
137 : {
138 0 : OUString rImageName = aBorderImgLst.GetImageName(i);
139 0 : BitmapEx b = aBorderImgLst.GetImage(rImageName).GetBitmapEx();
140 0 : b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST);
141 0 : aBorderImgLst.ReplaceImage(rImageName, Image(b));
142 0 : }
143 :
144 0 : for (short i = 0; i < aShadowImgLst.GetImageCount(); i++)
145 : {
146 0 : OUString rImageName = aShadowImgLst.GetImageName(i);
147 0 : BitmapEx b = aShadowImgLst.GetImage(rImageName).GetBitmapEx();
148 0 : b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_FAST);
149 0 : aShadowImgLst.ReplaceImage(rImageName, Image(b));
150 0 : }
151 : }
152 :
153 : // this page needs ExchangeSupport
154 0 : SetExchangeSupport();
155 :
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 0 : mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN),true) != SfxItemState::UNKNOWN;
160 :
161 0 : const SfxPoolItem* pItem = NULL;
162 0 : if (rCoreAttrs.HasItem(SID_ATTR_BORDER_STYLES, &pItem))
163 : {
164 0 : const SfxIntegerListItem* p = static_cast<const SfxIntegerListItem*>(pItem);
165 0 : std::vector<sal_Int32> aUsedStyles;
166 0 : p->GetList(aUsedStyles);
167 0 : for (size_t i = 0, n = aUsedStyles.size(); i < n; ++i)
168 0 : maUsedBorderStyles.insert(static_cast<sal_Int16>(aUsedStyles[i]));
169 : }
170 :
171 0 : if (rCoreAttrs.HasItem(SID_ATTR_BORDER_DEFAULT_WIDTH, &pItem))
172 : {
173 : // The caller specifies default line width. Honor it.
174 0 : const SfxInt64Item* p = static_cast<const SfxInt64Item*>(pItem);
175 0 : m_pLineWidthMF->SetValue(p->GetValue());
176 : }
177 :
178 : // set metric
179 0 : FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
180 :
181 0 : if( mbUseMarginItem )
182 : {
183 : // copied from SvxAlignmentTabPage
184 0 : switch ( eFUnit )
185 : {
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 0 : eFUnit = FUNIT_POINT;
193 0 : break;
194 :
195 : case FUNIT_CM:
196 : case FUNIT_M:
197 : case FUNIT_KM:
198 0 : eFUnit = FUNIT_MM;
199 0 : break;
200 : default: ;//prevent warning
201 : }
202 : }
203 : else
204 : {
205 0 : switch ( eFUnit )
206 : {
207 : case FUNIT_M:
208 : case FUNIT_KM:
209 0 : eFUnit = FUNIT_MM;
210 0 : break;
211 : default: ; //prevent warning
212 : }
213 : }
214 :
215 0 : SetFieldUnit(*m_pEdShadowSize, eFUnit);
216 :
217 0 : sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, false );
218 0 : bool bIsDontCare = true;
219 :
220 0 : if ( rCoreAttrs.GetItemState( nWhich, true ) >= SfxItemState::DEFAULT )
221 : {
222 : // paragraph or table
223 : const SvxBoxInfoItem* pBoxInfo =
224 0 : static_cast<const SvxBoxInfoItem*>(&( rCoreAttrs.Get( nWhich ) ));
225 :
226 0 : mbHorEnabled = pBoxInfo->IsHorEnabled();
227 0 : mbVerEnabled = pBoxInfo->IsVerEnabled();
228 0 : mbTLBREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR );
229 0 : mbBLTREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR );
230 :
231 0 : if(pBoxInfo->IsDist())
232 : {
233 0 : SetFieldUnit(*m_pLeftMF, eFUnit);
234 0 : SetFieldUnit(*m_pRightMF, eFUnit);
235 0 : SetFieldUnit(*m_pTopMF, eFUnit);
236 0 : SetFieldUnit(*m_pBottomMF, eFUnit);
237 0 : m_pSynchronizeCB->SetClickHdl(LINK(this, SvxBorderTabPage, SyncHdl_Impl));
238 0 : m_pLeftMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
239 0 : m_pRightMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
240 0 : m_pTopMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
241 0 : m_pBottomMF->SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
242 : }
243 : else
244 : {
245 0 : m_pSpacingFrame->Hide();
246 : }
247 0 : bIsDontCare = !pBoxInfo->IsValid( VALID_DISABLE );
248 : }
249 0 : if(!mbUseMarginItem && eFUnit == FUNIT_MM && SFX_MAPUNIT_TWIP == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
250 : {
251 : //#i91548# changing the number of decimal digits changes the minimum values, too
252 0 : lcl_SetDecimalDigitsTo1(*m_pLeftMF);
253 0 : lcl_SetDecimalDigitsTo1(*m_pRightMF);
254 0 : lcl_SetDecimalDigitsTo1(*m_pTopMF);
255 0 : lcl_SetDecimalDigitsTo1(*m_pBottomMF);
256 0 : lcl_SetDecimalDigitsTo1(*m_pEdShadowSize);
257 : }
258 :
259 0 : svx::FrameSelFlags nFlags = svx::FRAMESEL_OUTER;
260 0 : if( mbHorEnabled )
261 0 : nFlags |= svx::FRAMESEL_INNER_HOR;
262 0 : if( mbVerEnabled )
263 0 : nFlags |= svx::FRAMESEL_INNER_VER;
264 0 : if( mbTLBREnabled )
265 0 : nFlags |= svx::FRAMESEL_DIAG_TLBR;
266 0 : if( mbBLTREnabled )
267 0 : nFlags |= svx::FRAMESEL_DIAG_BLTR;
268 0 : if( bIsDontCare )
269 0 : nFlags |= svx::FRAMESEL_DONTCARE;
270 0 : m_pFrameSel->Initialize( nFlags );
271 :
272 0 : m_pFrameSel->SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
273 0 : m_pLbLineStyle->SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
274 0 : m_pLbLineColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
275 0 : m_pLineWidthMF->SetModifyHdl( LINK( this, SvxBorderTabPage, ModifyWidthHdl_Impl ) );
276 0 : m_pLbShadowColor->SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
277 0 : m_pWndPresets->SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
278 0 : m_pWndShadows->SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
279 :
280 0 : FillValueSets();
281 0 : FillLineListBox_Impl();
282 :
283 : // fill ColorBox out of the XColorList
284 0 : SfxObjectShell* pDocSh = SfxObjectShell::Current();
285 0 : XColorListRef pColorTable;
286 :
287 : DBG_ASSERT( pDocSh, "DocShell not found!" );
288 :
289 0 : if ( pDocSh )
290 : {
291 0 : pItem = pDocSh->GetItem( SID_COLOR_TABLE );
292 0 : if ( pItem != NULL )
293 0 : pColorTable = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
294 : }
295 :
296 : DBG_ASSERT( pColorTable.is(), "ColorTable not found!" );
297 :
298 0 : if ( pColorTable.is() )
299 : {
300 : // filling the line color box
301 0 : m_pLbLineColor->SetUpdateMode( false );
302 :
303 0 : for ( long i = 0; i < pColorTable->Count(); ++i )
304 : {
305 0 : XColorEntry* pEntry = pColorTable->GetColor(i);
306 0 : m_pLbLineColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
307 : }
308 0 : m_pLbLineColor->SetUpdateMode( true );
309 :
310 0 : m_pLbShadowColor->CopyEntries(*m_pLbLineColor);
311 : }
312 :
313 : // connections
314 :
315 0 : bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW ) );
316 0 : if( bSupportsShadow )
317 0 : AddItemConnection( svx::CreateShadowConnection( rCoreAttrs, *m_pWndShadows, *m_pEdShadowSize, *m_pLbShadowColor ) );
318 : else
319 0 : HideShadowControls();
320 :
321 0 : if( mbUseMarginItem )
322 0 : AddItemConnection( svx::CreateMarginConnection( rCoreAttrs, *m_pLeftMF, *m_pRightMF, *m_pTopMF, *m_pBottomMF ) );
323 0 : if( m_pFrameSel->IsBorderEnabled( svx::FRAMEBORDER_TLBR ) )
324 0 : AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR, *m_pFrameSel, svx::FRAMEBORDER_TLBR ) );
325 0 : if( m_pFrameSel->IsBorderEnabled( svx::FRAMEBORDER_BLTR ) )
326 0 : 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 0 : AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, *m_pMergeWithNextCB, sfx::ITEMCONN_DEFAULT ) );
331 0 : m_pMergeWithNextCB->Hide();
332 : // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
333 0 : AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, *m_pMergeAdjacentBordersCB, sfx::ITEMCONN_DEFAULT ) );
334 0 : m_pMergeAdjacentBordersCB->Hide();
335 0 : }
336 :
337 :
338 :
339 0 : SvxBorderTabPage::~SvxBorderTabPage()
340 : {
341 0 : }
342 :
343 :
344 :
345 0 : const sal_uInt16* SvxBorderTabPage::GetRanges()
346 : {
347 0 : return pRanges;
348 : }
349 :
350 :
351 :
352 0 : SfxTabPage* SvxBorderTabPage::Create( vcl::Window* pParent,
353 : const SfxItemSet* rAttrSet )
354 : {
355 0 : return ( new SvxBorderTabPage( pParent, *rAttrSet ) );
356 : }
357 :
358 :
359 :
360 0 : void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
361 : {
362 0 : if( m_pFrameSel->IsBorderEnabled( eBorder ) )
363 : {
364 0 : if( bValid )
365 0 : m_pFrameSel->ShowBorder( eBorder, pCoreLine );
366 : else
367 0 : m_pFrameSel->SetBorderDontCare( eBorder );
368 : }
369 0 : }
370 :
371 0 : bool SvxBorderTabPage::IsBorderLineStyleAllowed( sal_Int16 nStyle ) const
372 : {
373 0 : if (maUsedBorderStyles.empty())
374 : // All border styles are allowed.
375 0 : return true;
376 :
377 0 : return maUsedBorderStyles.count(nStyle) > 0;
378 : }
379 :
380 :
381 :
382 0 : void SvxBorderTabPage::Reset( const SfxItemSet* rSet )
383 : {
384 0 : SfxTabPage::Reset( rSet );
385 :
386 : const SvxBoxItem* pBoxItem;
387 : const SvxBoxInfoItem* pBoxInfoItem;
388 0 : sal_uInt16 nWhichBox = GetWhich(SID_ATTR_BORDER_OUTER);
389 : SfxMapUnit eCoreUnit;
390 :
391 0 : pBoxItem = static_cast<const SvxBoxItem*>(GetItem( *rSet, SID_ATTR_BORDER_OUTER ));
392 :
393 0 : pBoxInfoItem = static_cast<const SvxBoxInfoItem*>(GetItem( *rSet, SID_ATTR_BORDER_INNER, false ));
394 :
395 0 : eCoreUnit = rSet->GetPool()->GetMetric( nWhichBox );
396 :
397 0 : if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
398 : {
399 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_LEFT, pBoxItem->GetLeft(), pBoxInfoItem->IsValid( VALID_LEFT ) );
400 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_RIGHT, pBoxItem->GetRight(), pBoxInfoItem->IsValid( VALID_RIGHT ) );
401 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_TOP, pBoxItem->GetTop(), pBoxInfoItem->IsValid( VALID_TOP ) );
402 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_BOTTOM, pBoxItem->GetBottom(), pBoxInfoItem->IsValid( VALID_BOTTOM ) );
403 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_VER, pBoxInfoItem->GetVert(), pBoxInfoItem->IsValid( VALID_VERT ) );
404 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_HOR, pBoxInfoItem->GetHori(), pBoxInfoItem->IsValid( VALID_HORI ) );
405 :
406 :
407 : // distance inside
408 :
409 0 : if( !mbUseMarginItem )
410 : {
411 0 : if ( m_pLeftMF->IsVisible() )
412 : {
413 0 : SetMetricValue(*m_pLeftMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
414 0 : SetMetricValue(*m_pRightMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
415 0 : SetMetricValue(*m_pTopMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
416 0 : SetMetricValue(*m_pBottomMF, pBoxInfoItem->GetDefDist(), eCoreUnit);
417 :
418 0 : nMinValue = static_cast<long>(m_pLeftMF->GetValue());
419 :
420 0 : if ( pBoxInfoItem->IsMinDist() )
421 : {
422 0 : m_pLeftMF->SetFirst( nMinValue );
423 0 : m_pRightMF->SetFirst( nMinValue );
424 0 : m_pTopMF->SetFirst( nMinValue );
425 0 : m_pBottomMF->SetFirst( nMinValue );
426 : }
427 :
428 0 : if ( pBoxInfoItem->IsDist() )
429 : {
430 0 : if( rSet->GetItemState( nWhichBox, true ) >= SfxItemState::DEFAULT )
431 : {
432 0 : bool bIsAnyBorderVisible = m_pFrameSel->IsAnyBorderVisible();
433 0 : if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
434 : {
435 0 : m_pLeftMF->SetMin( 0 );
436 0 : m_pLeftMF->SetFirst( 0 );
437 0 : m_pRightMF->SetMin( 0 );
438 0 : m_pRightMF->SetFirst( 0 );
439 0 : m_pTopMF->SetMin( 0 );
440 0 : m_pTopMF->SetFirst( 0 );
441 0 : m_pBottomMF->SetMin( 0 );
442 0 : m_pBottomMF->SetFirst( 0 );
443 : }
444 0 : long nLeftDist = pBoxItem->GetDistance( BOX_LINE_LEFT);
445 0 : SetMetricValue(*m_pLeftMF, nLeftDist, eCoreUnit);
446 0 : long nRightDist = pBoxItem->GetDistance( BOX_LINE_RIGHT);
447 0 : SetMetricValue(*m_pRightMF, nRightDist, eCoreUnit);
448 0 : long nTopDist = pBoxItem->GetDistance( BOX_LINE_TOP);
449 0 : SetMetricValue( *m_pTopMF, nTopDist, eCoreUnit );
450 0 : long nBottomDist = pBoxItem->GetDistance( BOX_LINE_BOTTOM);
451 0 : SetMetricValue( *m_pBottomMF, nBottomDist, eCoreUnit );
452 :
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 0 : const long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
457 0 : bool bDiffDist = (nDefDist != nLeftDist ||
458 0 : nDefDist != nRightDist ||
459 0 : nDefDist != nTopDist ||
460 0 : nDefDist != nBottomDist);
461 0 : if((pBoxItem->GetDistance() ||
462 0 : bIsAnyBorderVisible) && bDiffDist )
463 : {
464 0 : m_pLeftMF->SetModifyFlag();
465 0 : m_pRightMF->SetModifyFlag();
466 0 : m_pTopMF->SetModifyFlag();
467 0 : m_pBottomMF->SetModifyFlag();
468 : }
469 : }
470 : else
471 : {
472 : // #106224# different margins -> do not fill the edits
473 0 : m_pLeftMF->SetText( OUString() );
474 0 : m_pRightMF->SetText( OUString() );
475 0 : m_pTopMF->SetText( OUString() );
476 0 : m_pBottomMF->SetText( OUString() );
477 : }
478 : }
479 0 : m_pLeftMF->SaveValue();
480 0 : m_pRightMF->SaveValue();
481 0 : m_pTopMF->SaveValue();
482 0 : m_pBottomMF->SaveValue();
483 : }
484 0 : }
485 : }
486 : else
487 : {
488 : // avoid ResetFrameLine-calls:
489 0 : m_pFrameSel->HideAllBorders();
490 : }
491 :
492 :
493 : // depict line (color) in controllers if unambiguous:
494 :
495 : {
496 : // Do all visible lines show the same line widths?
497 : long nWidth;
498 : SvxBorderStyle nStyle;
499 0 : bool bWidthEq = m_pFrameSel->GetVisibleWidth( nWidth, nStyle );
500 0 : if( bWidthEq )
501 : {
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 0 : sal_Int64( nWidth ), m_pLineWidthMF->GetDecimalDigits( ),
505 0 : MAP_TWIP,m_pLineWidthMF->GetUnit() ));
506 0 : m_pLineWidthMF->SetValue( nWidthPt );
507 0 : m_pLbLineStyle->SetWidth( nWidth );
508 :
509 : // then set the style
510 0 : m_pLbLineStyle->SelectEntry( nStyle );
511 : }
512 : else
513 0 : m_pLbLineStyle->SelectEntryPos( 1 );
514 :
515 : // Do all visible lines show the same line color?
516 0 : Color aColor;
517 0 : bool bColorEq = m_pFrameSel->GetVisibleColor( aColor );
518 0 : if( !bColorEq )
519 0 : aColor.SetColor( COL_BLACK );
520 :
521 0 : sal_Int32 nSelPos = m_pLbLineColor->GetEntryPos( aColor );
522 0 : if( nSelPos == LISTBOX_ENTRY_NOTFOUND )
523 0 : nSelPos = m_pLbLineColor->InsertEntry( aColor, SVX_RESSTR( RID_SVXSTR_COLOR_USER ) );
524 :
525 0 : m_pLbLineColor->SelectEntryPos( nSelPos );
526 0 : m_pLbLineStyle->SetColor( aColor );
527 :
528 : // Select all visible lines, if they are all equal.
529 0 : if( bWidthEq && bColorEq )
530 0 : m_pFrameSel->SelectAllVisibleBorders();
531 :
532 : // set the current style and color (caches style in control even if nothing is selected)
533 0 : SelStyleHdl_Impl(m_pLbLineStyle);
534 0 : SelColHdl_Impl(m_pLbLineColor);
535 : }
536 :
537 0 : bool bEnable = m_pWndShadows->GetSelectItemId() > 1 ;
538 0 : m_pFtShadowSize->Enable(bEnable);
539 0 : m_pEdShadowSize->Enable(bEnable);
540 0 : m_pFtShadowColor->Enable(bEnable);
541 0 : m_pLbShadowColor->Enable(bEnable);
542 :
543 0 : m_pWndPresets->SetNoSelection();
544 :
545 : // - no line - should not be selected
546 :
547 0 : if ( m_pLbLineStyle->GetSelectEntryPos() == 0 )
548 : {
549 0 : m_pLbLineStyle->SelectEntryPos( 1 );
550 0 : SelStyleHdl_Impl(m_pLbLineStyle);
551 : }
552 :
553 : const SfxPoolItem* pItem;
554 : SfxObjectShell* pShell;
555 0 : if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem) ||
556 0 : ( 0 != (pShell = SfxObjectShell::Current()) &&
557 0 : 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
558 : {
559 0 : sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
560 0 : if(nHtmlMode & HTMLMODE_ON)
561 : {
562 : // there are no shadows in Html-mode and only complete borders
563 0 : m_pShadowFrame->Disable();
564 :
565 0 : if( !(nSWMode & SW_BORDER_MODE_TABLE) )
566 : {
567 0 : m_pUserDefFT->Disable();
568 0 : m_pFrameSel->Disable();
569 0 : m_pWndPresets->RemoveItem(3);
570 0 : m_pWndPresets->RemoveItem(4);
571 0 : m_pWndPresets->RemoveItem(5);
572 : }
573 : }
574 : }
575 :
576 0 : LinesChanged_Impl( 0 );
577 0 : if(m_pLeftMF->GetValue() == m_pRightMF->GetValue() && m_pTopMF->GetValue() == m_pBottomMF->GetValue() && m_pTopMF->GetValue() == m_pLeftMF->GetValue())
578 0 : mbSync = true;
579 : else
580 0 : mbSync = false;
581 0 : m_pSynchronizeCB->Check(mbSync);
582 0 : }
583 :
584 :
585 :
586 0 : int SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
587 : {
588 0 : if ( _pSet )
589 0 : FillItemSet( _pSet );
590 :
591 0 : return LEAVE_PAGE;
592 : }
593 :
594 :
595 :
596 0 : bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
597 : {
598 0 : bool bAttrsChanged = SfxTabPage::FillItemSet( rCoreAttrs );
599 :
600 0 : bool bPut = true;
601 0 : sal_uInt16 nBoxWhich = GetWhich( SID_ATTR_BORDER_OUTER );
602 0 : sal_uInt16 nBoxInfoWhich = rCoreAttrs->GetPool()->GetWhich( SID_ATTR_BORDER_INNER, false );
603 0 : const SfxItemSet& rOldSet = GetItemSet();
604 0 : SvxBoxItem aBoxItem ( nBoxWhich );
605 0 : SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich );
606 0 : const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_OUTER ));
607 :
608 0 : SfxMapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
609 :
610 :
611 : // outer border:
612 :
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),
619 0 : };
620 :
621 0 : for (sal_uInt32 i=0; i < SAL_N_ELEMENTS(eTypes1); ++i)
622 0 : aBoxItem.SetLine( m_pFrameSel->GetFrameBorderStyle( eTypes1[i].first ), eTypes1[i].second );
623 :
624 :
625 : // border hor/ver and TableFlag
626 :
627 : TBorderPair eTypes2[] = {
628 : TBorderPair(svx::FRAMEBORDER_HOR,BOXINFO_LINE_HORI),
629 : TBorderPair(svx::FRAMEBORDER_VER,BOXINFO_LINE_VERT)
630 0 : };
631 0 : for (sal_uInt32 j=0; j < SAL_N_ELEMENTS(eTypes2); ++j)
632 0 : aBoxInfoItem.SetLine( m_pFrameSel->GetFrameBorderStyle( eTypes2[j].first ), eTypes2[j].second );
633 :
634 0 : aBoxInfoItem.EnableHor( mbHorEnabled );
635 0 : aBoxInfoItem.EnableVer( mbVerEnabled );
636 :
637 :
638 : // inner distance
639 :
640 0 : if( m_pLeftMF->IsVisible() )
641 : {
642 : // #i40405# enable distance controls for next dialog call
643 0 : aBoxInfoItem.SetDist( true );
644 :
645 0 : if( !mbUseMarginItem )
646 : {
647 : // #106224# all edits empty: do nothing
648 0 : if( !m_pLeftMF->GetText().isEmpty() || !m_pRightMF->GetText().isEmpty() ||
649 0 : !m_pTopMF->GetText().isEmpty() || !m_pBottomMF->GetText().isEmpty() )
650 : {
651 0 : if ( ((mbHorEnabled || mbVerEnabled || (nSWMode & SW_BORDER_MODE_TABLE)) &&
652 0 : (m_pLeftMF->IsModified()||m_pRightMF->IsModified()||
653 0 : m_pTopMF->IsModified()||m_pBottomMF->IsModified()) )||
654 0 : m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_HIDE
655 0 : || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_HIDE
656 0 : || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_HIDE
657 0 : || m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_HIDE )
658 : {
659 : const SvxBoxInfoItem* pOldBoxInfoItem = static_cast<const SvxBoxInfoItem*>(GetOldItem(
660 0 : *rCoreAttrs, SID_ATTR_BORDER_INNER ));
661 0 : if (
662 0 : !pOldBoxItem ||
663 0 : m_pLeftMF->IsValueChangedFromSaved() ||
664 0 : m_pRightMF->IsValueChangedFromSaved() ||
665 0 : m_pTopMF->IsValueChangedFromSaved() ||
666 0 : m_pBottomMF->IsValueChangedFromSaved() ||
667 0 : nMinValue == m_pLeftMF->GetValue() ||
668 0 : nMinValue == m_pRightMF->GetValue() ||
669 0 : nMinValue == m_pTopMF->GetValue() ||
670 0 : nMinValue == m_pBottomMF->GetValue() ||
671 0 : (pOldBoxInfoItem && !pOldBoxInfoItem->IsValid(VALID_DISTANCE))
672 : )
673 : {
674 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pLeftMF, eCoreUnit ), BOX_LINE_LEFT );
675 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pRightMF, eCoreUnit ), BOX_LINE_RIGHT );
676 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pTopMF, eCoreUnit ), BOX_LINE_TOP );
677 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue(*m_pBottomMF, eCoreUnit ), BOX_LINE_BOTTOM);
678 : }
679 : else
680 : {
681 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_LEFT ), BOX_LINE_LEFT);
682 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_RIGHT), BOX_LINE_RIGHT);
683 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_TOP ), BOX_LINE_TOP);
684 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_BOTTOM), BOX_LINE_BOTTOM);
685 : }
686 0 : aBoxInfoItem.SetValid( VALID_DISTANCE, true );
687 : }
688 : else
689 0 : aBoxInfoItem.SetValid( VALID_DISTANCE, false );
690 : }
691 : }
692 : }
693 :
694 :
695 : // note Don't Care Status in the Info-Item:
696 :
697 0 : aBoxInfoItem.SetValid( VALID_TOP, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_DONTCARE );
698 0 : aBoxInfoItem.SetValid( VALID_BOTTOM, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_DONTCARE );
699 0 : aBoxInfoItem.SetValid( VALID_LEFT, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_DONTCARE );
700 0 : aBoxInfoItem.SetValid( VALID_RIGHT, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_DONTCARE );
701 0 : aBoxInfoItem.SetValid( VALID_HORI, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_HOR ) != svx::FRAMESTATE_DONTCARE );
702 0 : aBoxInfoItem.SetValid( VALID_VERT, m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_VER ) != svx::FRAMESTATE_DONTCARE );
703 :
704 :
705 : // Put or Clear of the border?
706 :
707 0 : bPut = true;
708 :
709 0 : if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxWhich, false ))
710 : {
711 0 : bPut = aBoxItem != static_cast<const SvxBoxItem&>(rOldSet.Get(nBoxWhich));
712 : }
713 0 : if( SfxItemState::DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, false ) )
714 : {
715 : const SvxBoxInfoItem& rOldBoxInfo = static_cast<const SvxBoxInfoItem&>(
716 0 : rOldSet.Get(nBoxInfoWhich));
717 :
718 0 : aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
719 0 : aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
720 0 : bPut |= (aBoxInfoItem != rOldBoxInfo );
721 : }
722 :
723 0 : if ( bPut )
724 : {
725 0 : if ( !pOldBoxItem || !( *pOldBoxItem == aBoxItem ) )
726 : {
727 0 : rCoreAttrs->Put( aBoxItem );
728 0 : bAttrsChanged |= true;
729 : }
730 0 : const SfxPoolItem* pOld = GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_INNER, false );
731 :
732 0 : if ( !pOld || !( *static_cast<const SvxBoxInfoItem*>(pOld) == aBoxInfoItem ) )
733 : {
734 0 : rCoreAttrs->Put( aBoxInfoItem );
735 0 : bAttrsChanged |= true;
736 : }
737 : }
738 : else
739 : {
740 0 : rCoreAttrs->ClearItem( nBoxWhich );
741 0 : rCoreAttrs->ClearItem( nBoxInfoWhich );
742 : }
743 :
744 0 : return bAttrsChanged;
745 : }
746 :
747 :
748 :
749 0 : void SvxBorderTabPage::HideShadowControls()
750 : {
751 0 : m_pShadowFrame->Hide();
752 0 : }
753 :
754 :
755 :
756 0 : IMPL_LINK_NOARG(SvxBorderTabPage, SelPreHdl_Impl)
757 : {
758 0 : const svx::FrameBorderState SHOW = svx::FRAMESTATE_SHOW;
759 0 : const svx::FrameBorderState HIDE = svx::FRAMESTATE_HIDE;
760 0 : const svx::FrameBorderState DONT = svx::FRAMESTATE_DONTCARE;
761 :
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 }
786 : };
787 :
788 : // first hide and deselect all frame borders
789 0 : m_pFrameSel->HideAllBorders();
790 0 : m_pFrameSel->DeselectAllBorders();
791 :
792 : // Using image ID to find correct line in table above.
793 0 : sal_uInt16 nLine = GetPresetImageId( m_pWndPresets->GetSelectItemId() ) - 1;
794 :
795 : // Apply all styles from the table
796 0 : for( int nBorder = 0; nBorder < svx::FRAMEBORDERTYPE_COUNT; ++nBorder )
797 : {
798 0 : svx::FrameBorderType eBorder = svx::GetFrameBorderTypeFromIndex( nBorder );
799 0 : switch( ppeStates[ nLine ][ nBorder ] )
800 : {
801 0 : case SHOW: m_pFrameSel->SelectBorder( eBorder ); break;
802 0 : case HIDE: /* nothing to do */ break;
803 0 : case DONT: m_pFrameSel->SetBorderDontCare( eBorder ); break;
804 : }
805 : }
806 :
807 : // Show all lines that have been selected above
808 0 : if( m_pFrameSel->IsAnyBorderSelected() )
809 : {
810 : // any visible style, but "no-line" in line list box? -> use hair-line
811 0 : if( (m_pLbLineStyle->GetSelectEntryPos() == 0) || (m_pLbLineStyle->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) )
812 0 : m_pLbLineStyle->SelectEntryPos( 1 );
813 :
814 : // set current style to all previously selected lines
815 0 : SelStyleHdl_Impl(m_pLbLineStyle);
816 0 : SelColHdl_Impl(m_pLbLineColor);
817 : }
818 :
819 : // Presets ValueSet does not show a selection (used as push buttons).
820 0 : m_pWndPresets->SetNoSelection();
821 :
822 0 : LinesChanged_Impl( 0 );
823 0 : return 0;
824 : }
825 :
826 :
827 :
828 0 : IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl)
829 : {
830 0 : bool bEnable = m_pWndShadows->GetSelectItemId() > 1;
831 0 : m_pFtShadowSize->Enable(bEnable);
832 0 : m_pEdShadowSize->Enable(bEnable);
833 0 : m_pFtShadowColor->Enable(bEnable);
834 0 : m_pLbShadowColor->Enable(bEnable);
835 0 : return 0;
836 : }
837 :
838 :
839 :
840 0 : IMPL_LINK( SvxBorderTabPage, SelColHdl_Impl, ListBox *, pLb )
841 : {
842 0 : ColorListBox* pColLb = static_cast<ColorListBox*>(pLb);
843 :
844 0 : if (pLb == m_pLbLineColor)
845 : {
846 0 : m_pFrameSel->SetColorToSelection( pColLb->GetSelectEntryColor() );
847 0 : m_pLbLineStyle->SetColor( pColLb->GetSelectEntryColor() );
848 : }
849 :
850 0 : return 0;
851 : }
852 :
853 0 : IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthHdl_Impl)
854 : {
855 : sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
856 0 : m_pLineWidthMF->GetValue( ),
857 0 : m_pLineWidthMF->GetDecimalDigits( ),
858 0 : m_pLineWidthMF->GetUnit(), MAP_TWIP ));
859 0 : m_pLbLineStyle->SetWidth( nVal );
860 :
861 : m_pFrameSel->SetStyleToSelection( nVal,
862 0 : SvxBorderStyle( m_pLbLineStyle->GetSelectEntryStyle() ) );
863 :
864 0 : return 0;
865 : }
866 :
867 :
868 :
869 0 : IMPL_LINK( SvxBorderTabPage, SelStyleHdl_Impl, ListBox *, pLb )
870 : {
871 0 : if (pLb == m_pLbLineStyle)
872 : {
873 : sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
874 0 : m_pLineWidthMF->GetValue( ),
875 0 : m_pLineWidthMF->GetDecimalDigits( ),
876 0 : m_pLineWidthMF->GetUnit(), MAP_TWIP ));
877 : m_pFrameSel->SetStyleToSelection ( nVal,
878 0 : SvxBorderStyle( m_pLbLineStyle->GetSelectEntryStyle() ) );
879 : }
880 :
881 0 : return 0;
882 : }
883 :
884 :
885 : // ValueSet handling
886 :
887 :
888 : // number of preset images to show
889 : const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5;
890 :
891 : // number of shadow images to show
892 : const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5;
893 :
894 :
895 :
896 0 : sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
897 : {
898 : // table with all sets of predefined border styles
899 : static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] =
900 : {
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 }
911 : };
912 :
913 : // find correct set of presets
914 0 : int nLine = 0;
915 0 : if( !mbHorEnabled && !mbVerEnabled )
916 0 : nLine = (mbTLBREnabled || mbBLTREnabled) ? 1 : 0;
917 0 : else if( mbHorEnabled && !mbVerEnabled )
918 0 : nLine = 2;
919 0 : else if( !mbHorEnabled && mbVerEnabled )
920 0 : nLine = 3;
921 : else
922 0 : nLine = 4;
923 :
924 : DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT),
925 : "SvxBorderTabPage::GetPresetImageId - wrong index" );
926 0 : return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
927 : }
928 :
929 0 : sal_uInt16 SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
930 : {
931 : // string resource IDs for each image (in order of the IID_PRE_* image IDs)
932 : static const sal_uInt16 pnStrIds[] =
933 : {
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,
940 :
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,
946 :
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,
952 :
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
958 : };
959 0 : return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
960 : }
961 :
962 :
963 :
964 0 : void SvxBorderTabPage::FillPresetVS()
965 : {
966 0 : ImageList& rImgList = aBorderImgLst;
967 :
968 : // basic initialization of the ValueSet
969 0 : m_pWndPresets->SetStyle( m_pWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
970 0 : m_pWndPresets->SetColCount( SVX_BORDER_PRESET_COUNT );
971 :
972 : // insert images and help texts
973 0 : for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx )
974 : {
975 0 : m_pWndPresets->InsertItem( nVSIdx );
976 0 : m_pWndPresets->SetItemImage( nVSIdx, rImgList.GetImage( GetPresetImageId( nVSIdx ) ) );
977 0 : m_pWndPresets->SetItemText( nVSIdx, CUI_RESSTR( GetPresetStringId( nVSIdx ) ) );
978 : }
979 :
980 : // show the control
981 0 : m_pWndPresets->SetNoSelection();
982 0 : m_pWndPresets->Show();
983 0 : }
984 :
985 :
986 :
987 0 : void SvxBorderTabPage::FillShadowVS()
988 : {
989 0 : ImageList& rImgList = aShadowImgLst;
990 :
991 : // basic initialization of the ValueSet
992 0 : m_pWndShadows->SetStyle( m_pWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
993 0 : m_pWndShadows->SetColCount( SVX_BORDER_SHADOW_COUNT );
994 :
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 };
1001 :
1002 : // insert images and help texts
1003 0 : for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx )
1004 : {
1005 0 : m_pWndShadows->InsertItem( nVSIdx );
1006 0 : m_pWndShadows->SetItemImage( nVSIdx, rImgList.GetImage( pnImgIds[ nVSIdx - 1 ] ) );
1007 0 : m_pWndShadows->SetItemText( nVSIdx, CUI_RESSTR( pnStrIds[ nVSIdx - 1 ] ) );
1008 : }
1009 :
1010 : // show the control
1011 0 : m_pWndShadows->SelectItem( 1 );
1012 0 : m_pWndShadows->Show();
1013 0 : }
1014 :
1015 :
1016 :
1017 0 : void SvxBorderTabPage::FillValueSets()
1018 : {
1019 0 : FillPresetVS();
1020 0 : FillShadowVS();
1021 0 : }
1022 :
1023 :
1024 0 : static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1025 : {
1026 0 : return SvxBorderLine::threeDMediumColor( aMain );
1027 : }
1028 :
1029 0 : void SvxBorderTabPage::FillLineListBox_Impl()
1030 : {
1031 : using namespace ::com::sun::star::table::BorderLineStyle;
1032 :
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 },
1047 :
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 },
1057 :
1058 : { EMBOSSED, 15, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor },
1059 : { ENGRAVED, 15, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor },
1060 :
1061 : { OUTSET, 10, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor },
1062 : { INSET, 10, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor }
1063 0 : };
1064 :
1065 0 : m_pLbLineStyle->SetSourceUnit( FUNIT_TWIP );
1066 :
1067 0 : m_pLbLineStyle->SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) );
1068 :
1069 0 : for (size_t i = 0, n = SAL_N_ELEMENTS(aLines); i < n; ++i)
1070 : {
1071 0 : if (!IsBorderLineStyleAllowed(aLines[i].mnStyle))
1072 0 : continue;
1073 :
1074 : m_pLbLineStyle->InsertEntry(
1075 : SvxBorderLine::getWidthImpl(aLines[i].mnStyle), aLines[i].mnStyle,
1076 0 : aLines[i].mnMinWidth, aLines[i].mpColor1Fn, aLines[i].mpColor2Fn, aLines[i].mpColorDistFn);
1077 : }
1078 :
1079 : sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
1080 0 : m_pLineWidthMF->GetValue( ),
1081 0 : m_pLineWidthMF->GetDecimalDigits( ),
1082 0 : m_pLineWidthMF->GetUnit(), MAP_TWIP ));
1083 0 : m_pLbLineStyle->SetWidth( nVal );
1084 0 : }
1085 :
1086 :
1087 0 : IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl)
1088 : {
1089 0 : if(!mbUseMarginItem && m_pLeftMF->IsVisible())
1090 : {
1091 0 : bool bLineSet = m_pFrameSel->IsAnyBorderVisible();
1092 0 : bool bMinAllowed = 0 != (nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_TABLE));
1093 0 : bool bSpaceModified = m_pLeftMF->IsModified()||
1094 0 : m_pRightMF->IsModified()||
1095 0 : m_pTopMF->IsModified()||
1096 0 : m_pBottomMF->IsModified();
1097 :
1098 0 : if(bLineSet)
1099 : {
1100 0 : if(!bMinAllowed)
1101 : {
1102 0 : m_pLeftMF->SetFirst(nMinValue);
1103 0 : m_pRightMF->SetFirst(nMinValue);
1104 0 : m_pTopMF->SetFirst(nMinValue);
1105 0 : m_pBottomMF->SetFirst(nMinValue);
1106 : }
1107 0 : if(!bSpaceModified)
1108 : {
1109 0 : m_pLeftMF->SetValue(nMinValue);
1110 0 : m_pRightMF->SetValue(nMinValue);
1111 0 : m_pTopMF->SetValue(nMinValue);
1112 0 : m_pBottomMF->SetValue(nMinValue);
1113 : }
1114 : }
1115 : else
1116 : {
1117 0 : m_pLeftMF->SetMin(0);
1118 0 : m_pRightMF->SetMin(0);
1119 0 : m_pTopMF->SetMin(0);
1120 0 : m_pBottomMF->SetMin(0);
1121 0 : m_pLeftMF->SetFirst(0);
1122 0 : m_pRightMF->SetFirst(0);
1123 0 : m_pTopMF->SetFirst(0);
1124 0 : m_pBottomMF->SetFirst(0);
1125 0 : if(!bSpaceModified)
1126 : {
1127 0 : m_pLeftMF->SetValue(0);
1128 0 : m_pRightMF->SetValue(0);
1129 0 : m_pTopMF->SetValue(0);
1130 0 : m_pBottomMF->SetValue(0);
1131 : }
1132 : }
1133 : // for tables everything is allowed
1134 0 : sal_uInt16 nValid = VALID_TOP|VALID_BOTTOM|VALID_LEFT|VALID_RIGHT;
1135 :
1136 : // for other objects (paragraph, page, frame, character) the edit is disabled, if there's no border set
1137 0 : if(!(nSWMode & SW_BORDER_MODE_TABLE))
1138 : {
1139 0 : if(bLineSet)
1140 : {
1141 0 : nValid = (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_TOP) == svx::FRAMESTATE_SHOW) ? VALID_TOP : 0;
1142 0 : nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_BOTTOM) == svx::FRAMESTATE_SHOW) ? VALID_BOTTOM : 0;
1143 0 : nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_LEFT) == svx::FRAMESTATE_SHOW) ? VALID_LEFT : 0;
1144 0 : nValid |= (m_pFrameSel->GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) == svx::FRAMESTATE_SHOW) ? VALID_RIGHT : 0;
1145 : }
1146 : else
1147 0 : nValid = 0;
1148 : }
1149 0 : m_pLeftFT->Enable(0 != (nValid&VALID_LEFT));
1150 0 : m_pRightFT->Enable(0 != (nValid&VALID_RIGHT));
1151 0 : m_pTopFT->Enable(0 != (nValid&VALID_TOP));
1152 0 : m_pBottomFT->Enable(0 != (nValid&VALID_BOTTOM));
1153 0 : m_pLeftMF->Enable(0 != (nValid&VALID_LEFT));
1154 0 : m_pRightMF->Enable(0 != (nValid&VALID_RIGHT));
1155 0 : m_pTopMF->Enable(0 != (nValid&VALID_TOP));
1156 0 : m_pBottomMF->Enable(0 != (nValid&VALID_BOTTOM));
1157 0 : m_pSynchronizeCB->Enable( m_pRightMF->IsEnabled() || m_pTopMF->IsEnabled() ||
1158 0 : m_pBottomMF->IsEnabled() || m_pLeftMF->IsEnabled() );
1159 : }
1160 0 : return 0;
1161 : }
1162 :
1163 :
1164 :
1165 0 : IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, MetricField*, pField)
1166 : {
1167 0 : if ( mbSync )
1168 : {
1169 0 : sal_Int64 nVal = pField->GetValue();
1170 0 : if(pField != m_pLeftMF)
1171 0 : m_pLeftMF->SetValue(nVal);
1172 0 : if(pField != m_pRightMF)
1173 0 : m_pRightMF->SetValue(nVal);
1174 0 : if(pField != m_pTopMF)
1175 0 : m_pTopMF->SetValue(nVal);
1176 0 : if(pField != m_pBottomMF)
1177 0 : m_pBottomMF->SetValue(nVal);
1178 : }
1179 0 : return 0;
1180 : }
1181 :
1182 0 : IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, CheckBox*, pBox)
1183 : {
1184 0 : mbSync = pBox->IsChecked();
1185 0 : return 0;
1186 : }
1187 :
1188 0 : void SvxBorderTabPage::DataChanged( const DataChangedEvent& rDCEvt )
1189 : {
1190 0 : if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1191 0 : FillValueSets();
1192 :
1193 0 : SfxTabPage::DataChanged( rDCEvt );
1194 0 : }
1195 :
1196 0 : void SvxBorderTabPage::PageCreated(const SfxAllItemSet& aSet)
1197 : {
1198 0 : SFX_ITEMSET_ARG (&aSet,pSWModeItem,SfxUInt16Item,SID_SWMODE_TYPE,false);
1199 0 : SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,false);
1200 0 : if (pSWModeItem)
1201 : {
1202 0 : nSWMode = pSWModeItem->GetValue();
1203 : // #i43593#
1204 : // show checkbox <m_pMergeWithNextCB> for format.paragraph
1205 0 : if ( nSWMode == SW_BORDER_MODE_PARA )
1206 : {
1207 0 : m_pMergeWithNextCB->Show();
1208 0 : m_pPropertiesFrame->Show();
1209 : }
1210 : // show checkbox <m_pMergeAdjacentBordersCB> for format.paragraph
1211 0 : else if ( nSWMode == SW_BORDER_MODE_TABLE )
1212 : {
1213 0 : m_pMergeAdjacentBordersCB->Show();
1214 0 : m_pPropertiesFrame->Show();
1215 : }
1216 : }
1217 0 : if (pFlagItem)
1218 0 : if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
1219 0 : HideShadowControls();
1220 0 : }
1221 :
1222 0 : void SvxBorderTabPage::SetTableMode()
1223 : {
1224 0 : nSWMode = SW_BORDER_MODE_TABLE;
1225 0 : }
1226 :
1227 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|