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 : #define _SVX_BORDER_CXX
26 :
27 : #include <cuires.hrc>
28 : #include "border.hrc"
29 : #include "helpid.hrc"
30 :
31 : #include <svx/xtable.hxx> // XColorList
32 : #include <svx/drawitem.hxx>
33 : #include <editeng/boxitem.hxx>
34 : #include <editeng/shaditem.hxx>
35 : #include "border.hxx"
36 : #include <svx/dlgutil.hxx>
37 : #include <dialmgr.hxx>
38 : #include "svx/htmlmode.hxx"
39 : #include <vcl/msgbox.hxx>
40 : #include "svx/flagsdef.hxx"
41 : #include <sfx2/request.hxx>
42 : #include <svl/intitem.hxx>
43 : #include <sfx2/itemconnect.hxx>
44 : #include <sal/macros.h>
45 : #include "borderconn.hxx"
46 :
47 : using namespace ::editeng;
48 :
49 : // -----------------------------------------------------------------------
50 :
51 : /*
52 : * [Description:]
53 : * TabPage for setting the border attributes.
54 : * Needs
55 : * a SvxShadowItem: shadow
56 : * a SvxBoxItem: lines left, right, top, bottom,
57 : * a SvxBoxInfo: lines vertical, horizontal, distance, flags
58 : *
59 : * Lines can have three conditions:
60 : * 1. Show ( -> valid values )
61 : * 2. Hide ( -> NULL-Pointer )
62 : * 3. DontCare ( -> special Valid-Flags in the InfoItem )
63 : */
64 :
65 : // static ----------------------------------------------------------------
66 :
67 : static sal_uInt16 pRanges[] =
68 : {
69 : SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
70 : SID_ATTR_ALIGN_MARGIN, SID_ATTR_ALIGN_MARGIN,
71 : SID_ATTR_BORDER_CONNECT, SID_ATTR_BORDER_CONNECT,
72 : SID_SW_COLLAPSING_BORDERS, SID_SW_COLLAPSING_BORDERS,
73 : SID_ATTR_BORDER_DIAG_TLBR, SID_ATTR_BORDER_DIAG_BLTR,
74 : 0
75 : };
76 :
77 : // -----------------------------------------------------------------------
78 0 : static void lcl_SetDecimalDigitsTo1(MetricField& rField)
79 : {
80 0 : sal_Int64 nMin = rField.Denormalize( rField.GetMin( FUNIT_TWIP ) );
81 0 : rField.SetDecimalDigits(1);
82 0 : rField.SetMin( rField.Normalize( nMin ), FUNIT_TWIP );
83 0 : }
84 : // -----------------------------------------------------------------------
85 :
86 0 : SvxBorderTabPage::SvxBorderTabPage( Window* pParent,
87 : const SfxItemSet& rCoreAttrs )
88 :
89 0 : : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_BORDER ), rCoreAttrs ),
90 :
91 0 : aFlBorder ( this, CUI_RES( FL_BORDER ) ),
92 0 : aDefaultFT ( this, CUI_RES( FT_DEFAULT ) ),
93 0 : aWndPresets ( this, CUI_RES( WIN_PRESETS ) ),
94 0 : aUserDefFT ( this, CUI_RES( FT_USERDEF ) ),
95 0 : aFrameSel ( this, CUI_RES( WIN_FRAMESEL ) ),
96 :
97 0 : aFlSep1 ( this, CUI_RES( FL_SEPARATOR1 ) ),
98 0 : aFlLine ( this, CUI_RES( FL_LINE ) ),
99 0 : aStyleFT ( this, CUI_RES( FT_STYLE ) ),
100 0 : aLbLineStyle ( this, CUI_RES( LB_LINESTYLE ) ),
101 0 : aColorFT ( this, CUI_RES( FT_COLOR ) ),
102 0 : aLbLineColor ( this, CUI_RES( LB_LINECOLOR ) ),
103 0 : aWidthFT ( this, CUI_RES( FT_WIDTH ) ),
104 0 : aLineWidthMF ( this, CUI_RES( MF_LINEWIDTH ) ),
105 :
106 0 : aFlSep2 ( this, CUI_RES( FL_SEPARATOR2 ) ),
107 0 : aDistanceFL ( this, CUI_RES( FL_DISTANCE ) ),
108 0 : aLeftFT ( this, CUI_RES( FT_LEFT ) ),
109 0 : aLeftMF ( this, CUI_RES( MF_LEFT ) ),
110 0 : aRightFT ( this, CUI_RES( FT_RIGHT ) ),
111 0 : aRightMF ( this, CUI_RES( MF_RIGHT ) ),
112 0 : aTopFT ( this, CUI_RES( FT_TOP ) ),
113 0 : aTopMF ( this, CUI_RES( MF_TOP ) ),
114 0 : aBottomFT ( this, CUI_RES( FT_BOTTOM ) ),
115 0 : aBottomMF ( this, CUI_RES( MF_BOTTOM ) ),
116 0 : aSynchronizeCB ( this, CUI_RES( CB_SYNC ) ),
117 :
118 0 : aFlShadow ( this, CUI_RES( FL_SHADOW ) ),
119 0 : aFtShadowPos ( this, CUI_RES( FT_SHADOWPOS ) ),
120 0 : aWndShadows ( this, CUI_RES( WIN_SHADOWS ) ),
121 0 : aFtShadowSize ( this, CUI_RES( FT_SHADOWSIZE ) ),
122 0 : aEdShadowSize ( this, CUI_RES( ED_SHADOWSIZE ) ),
123 0 : aFtShadowColor ( this, CUI_RES( FT_SHADOWCOLOR ) ),
124 0 : aLbShadowColor ( this, CUI_RES( LB_SHADOWCOLOR ) ),
125 0 : aPropertiesFL ( this, CUI_RES( FL_PROPERTIES ) ),
126 0 : aMergeWithNextCB( this, CUI_RES( CB_MERGEWITHNEXT ) ),
127 0 : aMergeAdjacentBordersCB( this, CUI_RES( CB_MERGEADJACENTBORDERS ) ),
128 0 : aShadowImgLst( CUI_RES(IL_SDW_BITMAPS)),
129 0 : aBorderImgLst( CUI_RES(IL_PRE_BITMAPS)),
130 : nMinValue(0),
131 : nSWMode(0),
132 : mbHorEnabled( false ),
133 : mbVerEnabled( false ),
134 : mbTLBREnabled( false ),
135 : mbBLTREnabled( false ),
136 : mbUseMarginItem( false ),
137 0 : mbSync(true)
138 :
139 : {
140 : // this page needs ExchangeSupport
141 0 : SetExchangeSupport();
142 :
143 : /* Use SvxMarginItem instead of margins from SvxBoxItem, if present.
144 : -> Remember this state in mbUseMarginItem, because other special handling
145 : is needed across various functions... */
146 0 : mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN),sal_True) != SFX_ITEM_UNKNOWN;
147 :
148 : // set metric
149 0 : FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs );
150 :
151 0 : if( mbUseMarginItem )
152 : {
153 : // copied from SvxAlignmentTabPage
154 0 : switch ( eFUnit )
155 : {
156 : // #103396# the default value (1pt) can't be accurately represented in
157 : // inches or pica with two decimals, so point is used instead.
158 : case FUNIT_PICA:
159 : case FUNIT_INCH:
160 : case FUNIT_FOOT:
161 : case FUNIT_MILE:
162 0 : eFUnit = FUNIT_POINT;
163 0 : break;
164 :
165 : case FUNIT_CM:
166 : case FUNIT_M:
167 : case FUNIT_KM:
168 0 : eFUnit = FUNIT_MM;
169 0 : break;
170 : default: ;//prevent warning
171 : }
172 : }
173 : else
174 : {
175 0 : switch ( eFUnit )
176 : {
177 : case FUNIT_M:
178 : case FUNIT_KM:
179 0 : eFUnit = FUNIT_MM;
180 0 : break;
181 : default: ; //prevent warning
182 : }
183 : }
184 :
185 0 : SetFieldUnit( aEdShadowSize, eFUnit );
186 :
187 0 : sal_uInt16 nWhich = GetWhich( SID_ATTR_BORDER_INNER, sal_False );
188 0 : sal_Bool bIsDontCare = sal_True;
189 :
190 0 : if ( rCoreAttrs.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
191 : {
192 : // paragraph or table
193 : const SvxBoxInfoItem* pBoxInfo =
194 0 : (const SvxBoxInfoItem*)&( rCoreAttrs.Get( nWhich ) );
195 :
196 0 : mbHorEnabled = pBoxInfo->IsHorEnabled();
197 0 : mbVerEnabled = pBoxInfo->IsVerEnabled();
198 0 : mbTLBREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_TLBR );
199 0 : mbBLTREnabled = sfx::ItemWrapperHelper::IsKnownItem( rCoreAttrs, SID_ATTR_BORDER_DIAG_BLTR );
200 :
201 0 : if(pBoxInfo->IsDist())
202 : {
203 0 : SetFieldUnit(aLeftMF, eFUnit);
204 0 : SetFieldUnit(aRightMF, eFUnit);
205 0 : SetFieldUnit(aTopMF, eFUnit);
206 0 : SetFieldUnit(aBottomMF, eFUnit);
207 0 : aSynchronizeCB.SetClickHdl(LINK(this, SvxBorderTabPage, SyncHdl_Impl));
208 0 : aLeftMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
209 0 : aRightMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
210 0 : aTopMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
211 0 : aBottomMF.SetModifyHdl(LINK(this, SvxBorderTabPage, ModifyDistanceHdl_Impl));
212 : }
213 : else
214 : {
215 0 : aFlSep2.Hide();
216 0 : aDistanceFL.Hide();
217 0 : aLeftFT.Hide();
218 0 : aLeftMF.Hide();
219 0 : aRightFT.Hide();
220 0 : aRightMF.Hide();
221 0 : aTopFT.Hide();
222 0 : aTopMF.Hide();
223 0 : aBottomFT.Hide();
224 0 : aBottomMF.Hide();
225 0 : aSynchronizeCB.Hide();
226 : }
227 0 : bIsDontCare = !pBoxInfo->IsValid( VALID_DISABLE );
228 : }
229 0 : if(!mbUseMarginItem && eFUnit == FUNIT_MM && SFX_MAPUNIT_TWIP == rCoreAttrs.GetPool()->GetMetric( GetWhich( SID_ATTR_BORDER_INNER ) ))
230 : {
231 : //#i91548# changing the number of decimal digits changes the minimum values, too
232 0 : lcl_SetDecimalDigitsTo1(aLeftMF);
233 0 : lcl_SetDecimalDigitsTo1(aRightMF);
234 0 : lcl_SetDecimalDigitsTo1(aTopMF);
235 0 : lcl_SetDecimalDigitsTo1(aBottomMF);
236 0 : lcl_SetDecimalDigitsTo1(aEdShadowSize);
237 : }
238 :
239 0 : svx::FrameSelFlags nFlags = svx::FRAMESEL_OUTER;
240 0 : if( mbHorEnabled )
241 0 : nFlags |= svx::FRAMESEL_INNER_HOR;
242 0 : if( mbVerEnabled )
243 0 : nFlags |= svx::FRAMESEL_INNER_VER;
244 0 : if( mbTLBREnabled )
245 0 : nFlags |= svx::FRAMESEL_DIAG_TLBR;
246 0 : if( mbBLTREnabled )
247 0 : nFlags |= svx::FRAMESEL_DIAG_BLTR;
248 0 : if( bIsDontCare )
249 0 : nFlags |= svx::FRAMESEL_DONTCARE;
250 0 : aFrameSel.Initialize( nFlags );
251 :
252 0 : aFrameSel.SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
253 0 : aLbLineStyle.SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
254 0 : aLbLineColor.SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
255 0 : aLineWidthMF.SetModifyHdl( LINK( this, SvxBorderTabPage, ModifyWidthHdl_Impl ) );
256 0 : aLbShadowColor.SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
257 0 : aWndPresets.SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
258 0 : aWndShadows.SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
259 :
260 0 : FillValueSets();
261 0 : FillLineListBox_Impl();
262 :
263 : // fill ColorBox out of the XColorList
264 0 : SfxObjectShell* pDocSh = SfxObjectShell::Current();
265 0 : const SfxPoolItem* pItem = NULL;
266 0 : XColorListRef pColorTable;
267 :
268 : DBG_ASSERT( pDocSh, "DocShell not found!" );
269 :
270 0 : if ( pDocSh )
271 : {
272 0 : pItem = pDocSh->GetItem( SID_COLOR_TABLE );
273 0 : if ( pItem != NULL )
274 0 : pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
275 : }
276 :
277 : DBG_ASSERT( pColorTable.is(), "ColorTable not found!" );
278 :
279 0 : if ( pColorTable.is() )
280 : {
281 : // filling the line color box
282 0 : aLbLineColor.SetUpdateMode( sal_False );
283 :
284 0 : for ( long i = 0; i < pColorTable->Count(); ++i )
285 : {
286 0 : XColorEntry* pEntry = pColorTable->GetColor(i);
287 0 : aLbLineColor.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
288 : }
289 0 : aLbLineColor.SetUpdateMode( sal_True );
290 :
291 0 : aLbShadowColor.CopyEntries( aLbLineColor );
292 : }
293 0 : FreeResource();
294 :
295 : // connections
296 :
297 0 : bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW ) );
298 0 : if( bSupportsShadow )
299 0 : AddItemConnection( svx::CreateShadowConnection( rCoreAttrs, aWndShadows, aEdShadowSize, aLbShadowColor ) );
300 : else
301 0 : HideShadowControls();
302 :
303 0 : if( mbUseMarginItem )
304 0 : AddItemConnection( svx::CreateMarginConnection( rCoreAttrs, aLeftMF, aRightMF, aTopMF, aBottomMF ) );
305 0 : if( aFrameSel.IsBorderEnabled( svx::FRAMEBORDER_TLBR ) )
306 0 : AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR, aFrameSel, svx::FRAMEBORDER_TLBR ) );
307 0 : if( aFrameSel.IsBorderEnabled( svx::FRAMEBORDER_BLTR ) )
308 0 : AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_BLTR, aFrameSel, svx::FRAMEBORDER_BLTR ) );
309 : // #i43593# - item connection doesn't work for Writer,
310 : // because the Writer item sets contain these items
311 : // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
312 0 : AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, aMergeWithNextCB, sfx::ITEMCONN_DEFAULT ) );
313 0 : aMergeWithNextCB.Hide();
314 : // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
315 0 : AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, aMergeAdjacentBordersCB, sfx::ITEMCONN_DEFAULT ) );
316 0 : aMergeAdjacentBordersCB.Hide();
317 0 : }
318 :
319 : // -----------------------------------------------------------------------
320 :
321 0 : SvxBorderTabPage::~SvxBorderTabPage()
322 : {
323 0 : }
324 :
325 : // -----------------------------------------------------------------------
326 :
327 0 : sal_uInt16* SvxBorderTabPage::GetRanges()
328 : {
329 0 : return pRanges;
330 : }
331 :
332 : // -----------------------------------------------------------------------
333 :
334 0 : SfxTabPage* SvxBorderTabPage::Create( Window* pParent,
335 : const SfxItemSet& rAttrSet )
336 : {
337 0 : return ( new SvxBorderTabPage( pParent, rAttrSet ) );
338 : }
339 :
340 : // -----------------------------------------------------------------------
341 :
342 0 : void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const SvxBorderLine* pCoreLine, bool bValid )
343 : {
344 0 : if( aFrameSel.IsBorderEnabled( eBorder ) )
345 : {
346 0 : if( bValid )
347 0 : aFrameSel.ShowBorder( eBorder, pCoreLine );
348 : else
349 0 : aFrameSel.SetBorderDontCare( eBorder );
350 : }
351 0 : }
352 :
353 : // -----------------------------------------------------------------------
354 :
355 0 : void SvxBorderTabPage::Reset( const SfxItemSet& rSet )
356 : {
357 0 : SfxTabPage::Reset( rSet );
358 :
359 : const SvxBoxItem* pBoxItem;
360 : const SvxBoxInfoItem* pBoxInfoItem;
361 0 : sal_uInt16 nWhichBox = GetWhich(SID_ATTR_BORDER_OUTER);
362 : SfxMapUnit eCoreUnit;
363 :
364 0 : pBoxItem = (const SvxBoxItem*)GetItem( rSet, SID_ATTR_BORDER_OUTER );
365 :
366 0 : pBoxInfoItem = (const SvxBoxInfoItem*)GetItem( rSet, SID_ATTR_BORDER_INNER, sal_False );
367 :
368 0 : eCoreUnit = rSet.GetPool()->GetMetric( nWhichBox );
369 :
370 0 : if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
371 : {
372 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_LEFT, pBoxItem->GetLeft(), pBoxInfoItem->IsValid( VALID_LEFT ) );
373 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_RIGHT, pBoxItem->GetRight(), pBoxInfoItem->IsValid( VALID_RIGHT ) );
374 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_TOP, pBoxItem->GetTop(), pBoxInfoItem->IsValid( VALID_TOP ) );
375 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_BOTTOM, pBoxItem->GetBottom(), pBoxInfoItem->IsValid( VALID_BOTTOM ) );
376 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_VER, pBoxInfoItem->GetVert(), pBoxInfoItem->IsValid( VALID_VERT ) );
377 0 : ResetFrameLine_Impl( svx::FRAMEBORDER_HOR, pBoxInfoItem->GetHori(), pBoxInfoItem->IsValid( VALID_HORI ) );
378 :
379 : //-------------------
380 : // distance inside
381 : //-------------------
382 0 : if( !mbUseMarginItem )
383 : {
384 0 : if ( aLeftMF.IsVisible() )
385 : {
386 0 : SetMetricValue( aLeftMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
387 0 : SetMetricValue( aRightMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
388 0 : SetMetricValue( aTopMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
389 0 : SetMetricValue( aBottomMF, pBoxInfoItem->GetDefDist(), eCoreUnit );
390 :
391 0 : nMinValue = static_cast<long>(aLeftMF.GetValue());
392 :
393 0 : if ( pBoxInfoItem->IsMinDist() )
394 : {
395 0 : aLeftMF.SetFirst( nMinValue );
396 0 : aRightMF.SetFirst( nMinValue );
397 0 : aTopMF.SetFirst( nMinValue );
398 0 : aBottomMF.SetFirst( nMinValue );
399 : }
400 :
401 0 : if ( pBoxInfoItem->IsDist() )
402 : {
403 0 : if( rSet.GetItemState( nWhichBox, sal_True ) >= SFX_ITEM_DEFAULT )
404 : {
405 0 : sal_Bool bIsAnyBorderVisible = aFrameSel.IsAnyBorderVisible();
406 0 : if( !bIsAnyBorderVisible || !pBoxInfoItem->IsMinDist() )
407 : {
408 0 : aLeftMF.SetMin( 0 );
409 0 : aLeftMF.SetFirst( 0 );
410 0 : aRightMF.SetMin( 0 );
411 0 : aRightMF.SetFirst( 0 );
412 0 : aTopMF.SetMin( 0 );
413 0 : aTopMF.SetFirst( 0 );
414 0 : aBottomMF.SetMin( 0 );
415 0 : aBottomMF.SetFirst( 0 );
416 : }
417 0 : long nLeftDist = pBoxItem->GetDistance( BOX_LINE_LEFT);
418 0 : SetMetricValue( aLeftMF, nLeftDist, eCoreUnit );
419 0 : long nRightDist = pBoxItem->GetDistance( BOX_LINE_RIGHT);
420 0 : SetMetricValue( aRightMF, nRightDist, eCoreUnit );
421 0 : long nTopDist = pBoxItem->GetDistance( BOX_LINE_TOP);
422 0 : SetMetricValue( aTopMF, nTopDist, eCoreUnit );
423 0 : long nBottomDist = pBoxItem->GetDistance( BOX_LINE_BOTTOM);
424 0 : SetMetricValue( aBottomMF, nBottomDist, eCoreUnit );
425 :
426 : // if the distance is set with no active border line
427 : // or it is null with an active border line
428 : // no automatic changes should be made
429 0 : const long nDefDist = bIsAnyBorderVisible ? pBoxInfoItem->GetDefDist() : 0;
430 : sal_Bool bDiffDist = (nDefDist != nLeftDist ||
431 : nDefDist != nRightDist ||
432 : nDefDist != nTopDist ||
433 0 : nDefDist != nBottomDist);
434 0 : if((pBoxItem->GetDistance() ||
435 : bIsAnyBorderVisible) && bDiffDist )
436 : {
437 0 : aLeftMF.SetModifyFlag();
438 0 : aRightMF.SetModifyFlag();
439 0 : aTopMF.SetModifyFlag();
440 0 : aBottomMF.SetModifyFlag();
441 : }
442 : }
443 : else
444 : {
445 : // #106224# different margins -> do not fill the edits
446 0 : aLeftMF.SetText( String() );
447 0 : aRightMF.SetText( String() );
448 0 : aTopMF.SetText( String() );
449 0 : aBottomMF.SetText( String() );
450 : }
451 : }
452 0 : aLeftMF.SaveValue();
453 0 : aRightMF.SaveValue();
454 0 : aTopMF.SaveValue();
455 0 : aBottomMF.SaveValue();
456 : }
457 0 : }
458 : }
459 : else
460 : {
461 : // avoid ResetFrameLine-calls:
462 0 : aFrameSel.HideAllBorders();
463 : }
464 :
465 : //-------------------------------------------------------------
466 : // depict line (color) in controllers if unambiguous:
467 : //-------------------------------------------------------------
468 : {
469 : // Do all visible lines show the same line widths?
470 : long nWidth;
471 : SvxBorderStyle nStyle;
472 0 : bool bWidthEq = aFrameSel.GetVisibleWidth( nWidth, nStyle );
473 0 : if( bWidthEq )
474 : {
475 : // Determine the width first as some styles can be missing depending on it
476 : sal_Int64 nWidthPt = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
477 0 : sal_Int64( nWidth ), aLineWidthMF.GetDecimalDigits( ),
478 0 : MAP_TWIP,aLineWidthMF.GetUnit() ));
479 0 : aLineWidthMF.SetValue( nWidthPt );
480 0 : aLbLineStyle.SetWidth( nWidth );
481 :
482 : // then set the style
483 0 : aLbLineStyle.SelectEntry( nStyle );
484 : }
485 : else
486 0 : aLbLineStyle.SelectEntryPos( 1 );
487 :
488 : // Do all visible lines show the same line color?
489 0 : Color aColor;
490 0 : bool bColorEq = aFrameSel.GetVisibleColor( aColor );
491 0 : if( !bColorEq )
492 0 : aColor.SetColor( COL_BLACK );
493 :
494 0 : sal_uInt16 nSelPos = aLbLineColor.GetEntryPos( aColor );
495 0 : if( nSelPos == LISTBOX_ENTRY_NOTFOUND )
496 0 : nSelPos = aLbLineColor.InsertEntry( aColor, SVX_RESSTR( RID_SVXSTR_COLOR_USER ) );
497 :
498 0 : aLbLineColor.SelectEntryPos( nSelPos );
499 0 : aLbLineStyle.SetColor( aColor );
500 :
501 : // Select all visible lines, if they are all equal.
502 0 : if( bWidthEq && bColorEq )
503 0 : aFrameSel.SelectAllVisibleBorders();
504 :
505 : // set the current style and color (caches style in control even if nothing is selected)
506 0 : SelStyleHdl_Impl( &aLbLineStyle );
507 0 : SelColHdl_Impl( &aLbLineColor );
508 : }
509 :
510 0 : sal_Bool bEnable = aWndShadows.GetSelectItemId() > 1 ;
511 0 : aFtShadowSize.Enable(bEnable);
512 0 : aEdShadowSize.Enable(bEnable);
513 0 : aFtShadowColor.Enable(bEnable);
514 0 : aLbShadowColor.Enable(bEnable);
515 :
516 0 : aWndPresets.SetNoSelection();
517 :
518 : // - no line - should not be selected
519 :
520 0 : if ( aLbLineStyle.GetSelectEntryPos() == 0 )
521 : {
522 0 : aLbLineStyle.SelectEntryPos( 1 );
523 0 : SelStyleHdl_Impl( &aLbLineStyle );
524 : }
525 :
526 : const SfxPoolItem* pItem;
527 : SfxObjectShell* pShell;
528 0 : if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
529 : ( 0 != (pShell = SfxObjectShell::Current()) &&
530 0 : 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
531 : {
532 0 : sal_uInt16 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
533 0 : if(nHtmlMode & HTMLMODE_ON)
534 : {
535 : // there are no shadows in Html-mode and only complete borders
536 0 : aFtShadowPos .Disable();
537 0 : aWndShadows .Disable();
538 0 : aFtShadowSize .Disable();
539 0 : aEdShadowSize .Disable();
540 0 : aFtShadowColor.Disable();
541 0 : aLbShadowColor.Disable();
542 0 : aFlShadow .Disable();
543 :
544 0 : if( !(nSWMode & SW_BORDER_MODE_TABLE) )
545 : {
546 0 : aUserDefFT.Disable();
547 0 : aFrameSel.Disable();
548 0 : aWndPresets.RemoveItem(3);
549 0 : aWndPresets.RemoveItem(4);
550 0 : aWndPresets.RemoveItem(5);
551 : }
552 : }
553 : }
554 :
555 0 : LinesChanged_Impl( 0 );
556 0 : if(aLeftMF.GetValue() == aRightMF.GetValue() && aTopMF.GetValue() == aBottomMF.GetValue() && aTopMF.GetValue() == aLeftMF.GetValue())
557 0 : mbSync = true;
558 : else
559 0 : mbSync = false;
560 0 : aSynchronizeCB.Check(mbSync);
561 0 : }
562 :
563 : // -----------------------------------------------------------------------
564 :
565 0 : int SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
566 : {
567 0 : if ( _pSet )
568 0 : FillItemSet( *_pSet );
569 :
570 0 : return LEAVE_PAGE;
571 : }
572 :
573 : // -----------------------------------------------------------------------
574 :
575 0 : sal_Bool SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
576 : {
577 0 : bool bAttrsChanged = SfxTabPage::FillItemSet( rCoreAttrs );
578 :
579 0 : sal_Bool bPut = sal_True;
580 0 : sal_uInt16 nBoxWhich = GetWhich( SID_ATTR_BORDER_OUTER );
581 0 : sal_uInt16 nBoxInfoWhich = rCoreAttrs.GetPool()->GetWhich( SID_ATTR_BORDER_INNER, sal_False );
582 0 : const SfxItemSet& rOldSet = GetItemSet();
583 0 : SvxBoxItem aBoxItem ( nBoxWhich );
584 0 : SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich );
585 0 : SvxBoxItem* pOldBoxItem = (SvxBoxItem*)GetOldItem( rCoreAttrs, SID_ATTR_BORDER_OUTER );
586 :
587 0 : SfxMapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich );
588 0 : const SfxPoolItem* pOld = 0;
589 :
590 : //------------------
591 : // outer border:
592 : //------------------
593 : typedef ::std::pair<svx::FrameBorderType,sal_uInt16> TBorderPair;
594 : TBorderPair eTypes1[] = {
595 : TBorderPair(svx::FRAMEBORDER_TOP,BOX_LINE_TOP),
596 : TBorderPair(svx::FRAMEBORDER_BOTTOM,BOX_LINE_BOTTOM),
597 : TBorderPair(svx::FRAMEBORDER_LEFT,BOX_LINE_LEFT),
598 : TBorderPair(svx::FRAMEBORDER_RIGHT,BOX_LINE_RIGHT),
599 0 : };
600 :
601 0 : for (sal_uInt32 i=0; i < SAL_N_ELEMENTS(eTypes1); ++i)
602 0 : aBoxItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes1[i].first ), eTypes1[i].second );
603 :
604 : //--------------------------------
605 : // border hor/ver and TableFlag
606 : //--------------------------------
607 : TBorderPair eTypes2[] = {
608 : TBorderPair(svx::FRAMEBORDER_HOR,BOXINFO_LINE_HORI),
609 : TBorderPair(svx::FRAMEBORDER_VER,BOXINFO_LINE_VERT)
610 0 : };
611 0 : for (sal_uInt32 j=0; j < SAL_N_ELEMENTS(eTypes2); ++j)
612 0 : aBoxInfoItem.SetLine( aFrameSel.GetFrameBorderStyle( eTypes2[j].first ), eTypes2[j].second );
613 :
614 0 : aBoxInfoItem.EnableHor( mbHorEnabled );
615 0 : aBoxInfoItem.EnableVer( mbVerEnabled );
616 :
617 : //-------------------
618 : // inner distance
619 : //-------------------
620 0 : if( aLeftMF.IsVisible() )
621 : {
622 : // #i40405# enable distance controls for next dialog call
623 0 : aBoxInfoItem.SetDist( sal_True );
624 :
625 0 : if( !mbUseMarginItem )
626 : {
627 : // #106224# all edits empty: do nothing
628 0 : if( aLeftMF.GetText().Len() || aRightMF.GetText().Len() ||
629 0 : aTopMF.GetText().Len() || aBottomMF.GetText().Len() )
630 : {
631 0 : if ( ((mbHorEnabled || mbVerEnabled || (nSWMode & SW_BORDER_MODE_TABLE)) &&
632 0 : (aLeftMF.IsModified()||aRightMF.IsModified()||
633 0 : aTopMF.IsModified()||aBottomMF.IsModified()) )||
634 0 : aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_HIDE
635 0 : || aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_HIDE
636 0 : || aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_HIDE
637 0 : || aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_HIDE )
638 : {
639 : SvxBoxInfoItem* pOldBoxInfoItem = (SvxBoxInfoItem*)GetOldItem(
640 0 : rCoreAttrs, SID_ATTR_BORDER_INNER );
641 0 : if (
642 : !pOldBoxItem ||
643 0 : aLeftMF .GetText() != aLeftMF .GetSavedValue() ||
644 0 : aRightMF .GetText() != aRightMF .GetSavedValue() ||
645 0 : aTopMF .GetText() != aTopMF .GetSavedValue() ||
646 0 : aBottomMF.GetText() != aBottomMF.GetSavedValue() ||
647 0 : nMinValue == aLeftMF .GetValue() ||
648 0 : nMinValue == aRightMF .GetValue() ||
649 0 : nMinValue == aTopMF .GetValue() ||
650 0 : nMinValue == aBottomMF.GetValue() ||
651 0 : (pOldBoxInfoItem && !pOldBoxInfoItem->IsValid(VALID_DISTANCE))
652 : )
653 : {
654 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aLeftMF, eCoreUnit ), BOX_LINE_LEFT );
655 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aRightMF, eCoreUnit ), BOX_LINE_RIGHT );
656 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aTopMF, eCoreUnit ), BOX_LINE_TOP );
657 0 : aBoxItem.SetDistance( (sal_uInt16)GetCoreValue( aBottomMF, eCoreUnit ), BOX_LINE_BOTTOM);
658 : }
659 : else
660 : {
661 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_LEFT ), BOX_LINE_LEFT);
662 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_RIGHT), BOX_LINE_RIGHT);
663 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_TOP ), BOX_LINE_TOP);
664 0 : aBoxItem.SetDistance(pOldBoxItem->GetDistance(BOX_LINE_BOTTOM), BOX_LINE_BOTTOM);
665 : }
666 0 : aBoxInfoItem.SetValid( VALID_DISTANCE, sal_True );
667 : }
668 : else
669 0 : aBoxInfoItem.SetValid( VALID_DISTANCE, sal_False );
670 : }
671 : }
672 : }
673 :
674 : //------------------------------------------
675 : // note Don't Care Status in the Info-Item:
676 : //------------------------------------------
677 0 : aBoxInfoItem.SetValid( VALID_TOP, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_TOP ) != svx::FRAMESTATE_DONTCARE );
678 0 : aBoxInfoItem.SetValid( VALID_BOTTOM, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM ) != svx::FRAMESTATE_DONTCARE );
679 0 : aBoxInfoItem.SetValid( VALID_LEFT, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_LEFT ) != svx::FRAMESTATE_DONTCARE );
680 0 : aBoxInfoItem.SetValid( VALID_RIGHT, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) != svx::FRAMESTATE_DONTCARE );
681 0 : aBoxInfoItem.SetValid( VALID_HORI, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_HOR ) != svx::FRAMESTATE_DONTCARE );
682 0 : aBoxInfoItem.SetValid( VALID_VERT, aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_VER ) != svx::FRAMESTATE_DONTCARE );
683 :
684 : //
685 : // Put or Clear of the border?
686 : //
687 0 : bPut = sal_True;
688 :
689 0 : if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxWhich, sal_False ))
690 : {
691 0 : bPut = aBoxItem != (const SvxBoxItem&)(rOldSet.Get(nBoxWhich)) ? sal_True : sal_False;
692 : }
693 0 : if( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nBoxInfoWhich, sal_False ) )
694 : {
695 : const SvxBoxInfoItem& rOldBoxInfo = (const SvxBoxInfoItem&)
696 0 : rOldSet.Get(nBoxInfoWhich);
697 :
698 0 : aBoxInfoItem.SetMinDist( rOldBoxInfo.IsMinDist() );
699 0 : aBoxInfoItem.SetDefDist( rOldBoxInfo.GetDefDist() );
700 0 : bPut |= (aBoxInfoItem != rOldBoxInfo );
701 : }
702 :
703 0 : if ( bPut )
704 : {
705 0 : if ( !pOldBoxItem || !( *pOldBoxItem == aBoxItem ) )
706 : {
707 0 : rCoreAttrs.Put( aBoxItem );
708 0 : bAttrsChanged |= sal_True;
709 : }
710 0 : pOld = GetOldItem( rCoreAttrs, SID_ATTR_BORDER_INNER, sal_False );
711 :
712 0 : if ( !pOld || !( *(const SvxBoxInfoItem*)pOld == aBoxInfoItem ) )
713 : {
714 0 : rCoreAttrs.Put( aBoxInfoItem );
715 0 : bAttrsChanged |= sal_True;
716 : }
717 : }
718 : else
719 : {
720 0 : rCoreAttrs.ClearItem( nBoxWhich );
721 0 : rCoreAttrs.ClearItem( nBoxInfoWhich );
722 : }
723 :
724 0 : return bAttrsChanged;
725 : }
726 :
727 : // -----------------------------------------------------------------------
728 :
729 0 : void SvxBorderTabPage::HideShadowControls()
730 : {
731 0 : aFtShadowPos.Hide();
732 0 : aWndShadows.Hide();
733 0 : aFtShadowSize.Hide();
734 0 : aEdShadowSize.Hide();
735 0 : aFtShadowColor.Hide();
736 0 : aLbShadowColor.Hide();
737 0 : aFlShadow.Hide();
738 0 : }
739 :
740 : // -----------------------------------------------------------------------
741 :
742 0 : IMPL_LINK_NOARG(SvxBorderTabPage, SelPreHdl_Impl)
743 : {
744 0 : const svx::FrameBorderState SHOW = svx::FRAMESTATE_SHOW;
745 0 : const svx::FrameBorderState HIDE = svx::FRAMESTATE_HIDE;
746 0 : const svx::FrameBorderState DONT = svx::FRAMESTATE_DONTCARE;
747 :
748 : static const svx::FrameBorderState ppeStates[][ svx::FRAMEBORDERTYPE_COUNT ] =
749 : { /* Left Right Top Bot Hor Ver TLBR BLTR */
750 : /* ---------------------+--------------------------------------------------- */
751 : /* IID_PRE_CELL_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
752 : /* IID_PRE_CELL_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
753 : /* IID_PRE_CELL_LR */ { SHOW, SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
754 : /* IID_PRE_CELL_TB */ { HIDE, HIDE, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
755 : /* IID_PRE_CELL_L */ { SHOW, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
756 : /* IID_PRE_CELL_DIAG */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, SHOW, SHOW },
757 : /* IID_PRE_HOR_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
758 : /* IID_PRE_HOR_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
759 : /* IID_PRE_HOR_HOR */ { HIDE, HIDE, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
760 : /* IID_PRE_HOR_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
761 : /* IID_PRE_HOR_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, HIDE, HIDE, HIDE },
762 : /* IID_PRE_VER_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
763 : /* IID_PRE_VER_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
764 : /* IID_PRE_VER_VER */ { SHOW, SHOW, HIDE, HIDE, HIDE, SHOW, HIDE, HIDE },
765 : /* IID_PRE_VER_ALL */ { SHOW, SHOW, SHOW, SHOW, HIDE, SHOW, HIDE, HIDE },
766 : /* IID_PRE_VER_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, HIDE, DONT, HIDE, HIDE },
767 : /* IID_PRE_TABLE_NONE */ { HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE, HIDE },
768 : /* IID_PRE_TABLE_OUTER */ { SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE, HIDE },
769 : /* IID_PRE_TABLE_OUTERH */ { SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE, HIDE },
770 : /* IID_PRE_TABLE_ALL */ { SHOW, SHOW, SHOW, SHOW, SHOW, SHOW, HIDE, HIDE },
771 : /* IID_PRE_TABLE_OUTER2 */ { SHOW, SHOW, SHOW, SHOW, DONT, DONT, HIDE, HIDE }
772 : };
773 :
774 : // first hide and deselect all frame borders
775 0 : aFrameSel.HideAllBorders();
776 0 : aFrameSel.DeselectAllBorders();
777 :
778 : // Using image ID to find correct line in table above.
779 0 : sal_uInt16 nLine = GetPresetImageId( aWndPresets.GetSelectItemId() ) - 1;
780 :
781 : // Apply all styles from the table
782 0 : for( int nBorder = 0; nBorder < svx::FRAMEBORDERTYPE_COUNT; ++nBorder )
783 : {
784 0 : svx::FrameBorderType eBorder = svx::GetFrameBorderTypeFromIndex( nBorder );
785 0 : switch( ppeStates[ nLine ][ nBorder ] )
786 : {
787 0 : case SHOW: aFrameSel.SelectBorder( eBorder ); break;
788 0 : case HIDE: /* nothing to do */ break;
789 0 : case DONT: aFrameSel.SetBorderDontCare( eBorder ); break;
790 : }
791 : }
792 :
793 : // Show all lines that have been selected above
794 0 : if( aFrameSel.IsAnyBorderSelected() )
795 : {
796 : // any visible style, but "no-line" in line list box? -> use hair-line
797 0 : if( (aLbLineStyle.GetSelectEntryPos() == 0) || (aLbLineStyle.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) )
798 0 : aLbLineStyle.SelectEntryPos( 1 );
799 :
800 : // set current style to all previously selected lines
801 0 : SelStyleHdl_Impl( &aLbLineStyle );
802 0 : SelColHdl_Impl( &aLbLineColor );
803 : }
804 :
805 : // Presets ValueSet does not show a selection (used as push buttons).
806 0 : aWndPresets.SetNoSelection();
807 :
808 0 : LinesChanged_Impl( 0 );
809 0 : return 0;
810 : }
811 :
812 : // -----------------------------------------------------------------------
813 :
814 0 : IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl)
815 : {
816 0 : sal_Bool bEnable = aWndShadows.GetSelectItemId() > 1;
817 0 : aFtShadowSize.Enable(bEnable);
818 0 : aEdShadowSize.Enable(bEnable);
819 0 : aFtShadowColor.Enable(bEnable);
820 0 : aLbShadowColor.Enable(bEnable);
821 0 : return 0;
822 : }
823 :
824 : // -----------------------------------------------------------------------
825 :
826 0 : IMPL_LINK( SvxBorderTabPage, SelColHdl_Impl, ListBox *, pLb )
827 : {
828 0 : ColorListBox* pColLb = (ColorListBox*)pLb;
829 :
830 0 : if ( pLb == &aLbLineColor )
831 : {
832 0 : aFrameSel.SetColorToSelection( pColLb->GetSelectEntryColor() );
833 0 : aLbLineStyle.SetColor( pColLb->GetSelectEntryColor() );
834 : }
835 :
836 0 : return 0;
837 : }
838 :
839 0 : IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthHdl_Impl)
840 : {
841 : sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
842 : aLineWidthMF.GetValue( ),
843 0 : aLineWidthMF.GetDecimalDigits( ),
844 0 : aLineWidthMF.GetUnit(), MAP_TWIP ));
845 0 : aLbLineStyle.SetWidth( nVal );
846 :
847 : aFrameSel.SetStyleToSelection( nVal,
848 0 : SvxBorderStyle( aLbLineStyle.GetSelectEntryStyle() ) );
849 :
850 0 : return 0;
851 : }
852 :
853 : // -----------------------------------------------------------------------
854 :
855 0 : IMPL_LINK( SvxBorderTabPage, SelStyleHdl_Impl, ListBox *, pLb )
856 : {
857 0 : if ( pLb == &aLbLineStyle )
858 : {
859 : sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
860 : aLineWidthMF.GetValue( ),
861 0 : aLineWidthMF.GetDecimalDigits( ),
862 0 : aLineWidthMF.GetUnit(), MAP_TWIP ));
863 : aFrameSel.SetStyleToSelection ( nVal,
864 0 : SvxBorderStyle( aLbLineStyle.GetSelectEntryStyle() ) );
865 : }
866 :
867 0 : return 0;
868 : }
869 :
870 : // ============================================================================
871 : // ValueSet handling
872 : // ============================================================================
873 :
874 : // number of preset images to show
875 : const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5;
876 :
877 : // number of shadow images to show
878 : const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5;
879 :
880 : // ----------------------------------------------------------------------------
881 :
882 0 : sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
883 : {
884 : // table with all sets of predefined border styles
885 : static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] =
886 : {
887 : // simple cell without diagonal frame borders
888 : { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_L },
889 : // simple cell with diagonal frame borders
890 : { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_DIAG },
891 : // with horizontal inner frame border
892 : { IID_PRE_HOR_NONE, IID_PRE_HOR_OUTER, IID_PRE_HOR_HOR, IID_PRE_HOR_ALL, IID_PRE_HOR_OUTER2 },
893 : // with vertical inner frame border
894 : { IID_PRE_VER_NONE, IID_PRE_VER_OUTER, IID_PRE_VER_VER, IID_PRE_VER_ALL, IID_PRE_VER_OUTER2 },
895 : // with horizontal and vertical inner frame borders
896 : { IID_PRE_TABLE_NONE, IID_PRE_TABLE_OUTER, IID_PRE_TABLE_OUTERH, IID_PRE_TABLE_ALL, IID_PRE_TABLE_OUTER2 }
897 : };
898 :
899 : // find correct set of presets
900 0 : int nLine = 0;
901 0 : if( !mbHorEnabled && !mbVerEnabled )
902 0 : nLine = (mbTLBREnabled || mbBLTREnabled) ? 1 : 0;
903 0 : else if( mbHorEnabled && !mbVerEnabled )
904 0 : nLine = 2;
905 0 : else if( !mbHorEnabled && mbVerEnabled )
906 0 : nLine = 3;
907 : else
908 0 : nLine = 4;
909 :
910 : DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT),
911 : "SvxBorderTabPage::GetPresetImageId - wrong index" );
912 0 : return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
913 : }
914 :
915 0 : sal_uInt16 SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
916 : {
917 : // string resource IDs for each image (in order of the IID_PRE_* image IDs)
918 : static const sal_uInt16 pnStrIds[] =
919 : {
920 : RID_SVXSTR_TABLE_PRESET_NONE,
921 : RID_SVXSTR_PARA_PRESET_ALL,
922 : RID_SVXSTR_PARA_PRESET_LEFTRIGHT,
923 : RID_SVXSTR_PARA_PRESET_TOPBOTTOM,
924 : RID_SVXSTR_PARA_PRESET_ONLYLEFT,
925 : RID_SVXSTR_PARA_PRESET_DIAGONAL,
926 :
927 : RID_SVXSTR_TABLE_PRESET_NONE,
928 : RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
929 : RID_SVXSTR_HOR_PRESET_ONLYHOR,
930 : RID_SVXSTR_TABLE_PRESET_OUTERALL,
931 : RID_SVXSTR_TABLE_PRESET_OUTERINNER,
932 :
933 : RID_SVXSTR_TABLE_PRESET_NONE,
934 : RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
935 : RID_SVXSTR_VER_PRESET_ONLYVER,
936 : RID_SVXSTR_TABLE_PRESET_OUTERALL,
937 : RID_SVXSTR_TABLE_PRESET_OUTERINNER,
938 :
939 : RID_SVXSTR_TABLE_PRESET_NONE,
940 : RID_SVXSTR_TABLE_PRESET_ONLYOUTER,
941 : RID_SVXSTR_TABLE_PRESET_OUTERHORI,
942 : RID_SVXSTR_TABLE_PRESET_OUTERALL,
943 : RID_SVXSTR_TABLE_PRESET_OUTERINNER
944 : };
945 0 : return pnStrIds[ GetPresetImageId( nValueSetIdx ) - 1 ];
946 : }
947 :
948 : // ----------------------------------------------------------------------------
949 :
950 0 : void SvxBorderTabPage::FillPresetVS()
951 : {
952 0 : ImageList& rImgList = aBorderImgLst;
953 0 : Size aImgSize( rImgList.GetImage( IID_PRE_CELL_NONE ).GetSizePixel() );
954 :
955 : // basic initialization of the ValueSet
956 0 : aWndPresets.SetColCount( SVX_BORDER_PRESET_COUNT );
957 0 : aWndPresets.SetStyle( aWndPresets.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
958 0 : aWndPresets.SetSizePixel( aWndPresets.CalcWindowSizePixel( aImgSize ) );
959 :
960 : // insert images and help texts
961 0 : for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx )
962 : {
963 0 : aWndPresets.InsertItem( nVSIdx );
964 0 : aWndPresets.SetItemImage( nVSIdx, rImgList.GetImage( GetPresetImageId( nVSIdx ) ) );
965 0 : aWndPresets.SetItemText( nVSIdx, CUI_RESSTR( GetPresetStringId( nVSIdx ) ) );
966 : }
967 :
968 : // show the control
969 0 : aWndPresets.SetNoSelection();
970 0 : aWndPresets.Show();
971 0 : }
972 :
973 : // ----------------------------------------------------------------------------
974 :
975 0 : void SvxBorderTabPage::FillShadowVS()
976 : {
977 0 : ImageList& rImgList = aShadowImgLst;
978 0 : Size aImgSize( rImgList.GetImage( IID_SHADOWNONE ).GetSizePixel() );
979 :
980 : // basic initialization of the ValueSet
981 0 : aWndShadows.SetColCount( SVX_BORDER_SHADOW_COUNT );
982 0 : aWndShadows.SetStyle( aWndShadows.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
983 0 : aWndShadows.SetSizePixel( aWndShadows.CalcWindowSizePixel( aImgSize ) );
984 :
985 : // image resource IDs
986 : static const sal_uInt16 pnImgIds[ SVX_BORDER_SHADOW_COUNT ] =
987 : { IID_SHADOWNONE, IID_SHADOW_BOT_RIGHT, IID_SHADOW_TOP_RIGHT, IID_SHADOW_BOT_LEFT, IID_SHADOW_TOP_LEFT };
988 : // string resource IDs for each image
989 : static const sal_uInt16 pnStrIds[ SVX_BORDER_SHADOW_COUNT ] =
990 : { 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 };
991 :
992 : // insert images and help texts
993 0 : for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx )
994 : {
995 0 : aWndShadows.InsertItem( nVSIdx );
996 0 : aWndShadows.SetItemImage( nVSIdx, rImgList.GetImage( pnImgIds[ nVSIdx - 1 ] ) );
997 0 : aWndShadows.SetItemText( nVSIdx, CUI_RESSTR( pnStrIds[ nVSIdx - 1 ] ) );
998 : }
999 :
1000 : // show the control
1001 0 : aWndShadows.SelectItem( 1 );
1002 0 : aWndShadows.Show();
1003 0 : }
1004 :
1005 : // ----------------------------------------------------------------------------
1006 :
1007 0 : void SvxBorderTabPage::FillValueSets()
1008 : {
1009 0 : FillPresetVS();
1010 0 : FillShadowVS();
1011 0 : }
1012 :
1013 : // ============================================================================
1014 0 : static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
1015 : {
1016 0 : return SvxBorderLine::threeDMediumColor( aMain );
1017 : }
1018 :
1019 0 : void SvxBorderTabPage::FillLineListBox_Impl()
1020 : {
1021 : using namespace ::com::sun::star::table::BorderLineStyle;
1022 :
1023 0 : aLbLineStyle.SetSourceUnit( FUNIT_TWIP );
1024 :
1025 0 : aLbLineStyle.SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) );
1026 :
1027 : // Simple lines
1028 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( SOLID ), SOLID );
1029 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( DOTTED ), DOTTED );
1030 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( DASHED ), DASHED );
1031 :
1032 : // Double lines
1033 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( DOUBLE ), DOUBLE );
1034 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_SMALLGAP ), THINTHICK_SMALLGAP, 20 );
1035 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_MEDIUMGAP ), THINTHICK_MEDIUMGAP );
1036 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_LARGEGAP ), THINTHICK_LARGEGAP );
1037 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_SMALLGAP ), THICKTHIN_SMALLGAP, 20 );
1038 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_MEDIUMGAP ), THICKTHIN_MEDIUMGAP );
1039 0 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_LARGEGAP ), THICKTHIN_LARGEGAP );
1040 :
1041 : // Engraved / Embossed
1042 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( EMBOSSED ), EMBOSSED, 15,
1043 : &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor,
1044 0 : &lcl_mediumColor );
1045 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( ENGRAVED ), ENGRAVED, 15,
1046 : &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor,
1047 0 : &lcl_mediumColor );
1048 :
1049 : // Inset / Outset
1050 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( OUTSET ), OUTSET, 10,
1051 0 : &SvxBorderLine::lightColor, &SvxBorderLine::darkColor );
1052 : aLbLineStyle.InsertEntry( SvxBorderLine::getWidthImpl( INSET ), INSET, 10,
1053 0 : &SvxBorderLine::darkColor, &SvxBorderLine::lightColor );
1054 :
1055 : sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue(
1056 : aLineWidthMF.GetValue( ),
1057 0 : aLineWidthMF.GetDecimalDigits( ),
1058 0 : aLineWidthMF.GetUnit(), MAP_TWIP ));
1059 0 : aLbLineStyle.SetWidth( nVal );
1060 0 : }
1061 :
1062 : // -----------------------------------------------------------------------
1063 0 : IMPL_LINK_NOARG(SvxBorderTabPage, LinesChanged_Impl)
1064 : {
1065 0 : if(!mbUseMarginItem && aLeftMF.IsVisible())
1066 : {
1067 0 : sal_Bool bLineSet = aFrameSel.IsAnyBorderVisible();
1068 0 : sal_Bool bMinAllowed = 0 != (nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_TABLE));
1069 0 : sal_Bool bSpaceModified = aLeftMF .IsModified()||
1070 0 : aRightMF .IsModified()||
1071 0 : aTopMF .IsModified()||
1072 0 : aBottomMF.IsModified();
1073 :
1074 0 : if(bLineSet)
1075 : {
1076 0 : if(!bMinAllowed)
1077 : {
1078 0 : aLeftMF .SetFirst(nMinValue);
1079 0 : aRightMF .SetFirst(nMinValue);
1080 0 : aTopMF .SetFirst(nMinValue);
1081 0 : aBottomMF.SetFirst(nMinValue);
1082 : }
1083 0 : if(!bSpaceModified)
1084 : {
1085 0 : aLeftMF .SetValue(nMinValue);
1086 0 : aRightMF .SetValue(nMinValue);
1087 0 : aTopMF .SetValue(nMinValue);
1088 0 : aBottomMF.SetValue(nMinValue);
1089 : }
1090 : }
1091 : else
1092 : {
1093 0 : aLeftMF .SetMin(0);
1094 0 : aRightMF .SetMin(0);
1095 0 : aTopMF .SetMin(0);
1096 0 : aBottomMF.SetMin(0);
1097 0 : aLeftMF .SetFirst(0);
1098 0 : aRightMF .SetFirst(0);
1099 0 : aTopMF .SetFirst(0);
1100 0 : aBottomMF.SetFirst(0);
1101 0 : if(!bSpaceModified)
1102 : {
1103 0 : aLeftMF .SetValue(0);
1104 0 : aRightMF .SetValue(0);
1105 0 : aTopMF .SetValue(0);
1106 0 : aBottomMF.SetValue(0);
1107 : }
1108 : }
1109 : // for tables everything is allowed
1110 0 : sal_uInt16 nValid = VALID_TOP|VALID_BOTTOM|VALID_LEFT|VALID_RIGHT;
1111 :
1112 : // for border and paragraph the edit is disabled, if there's no border set
1113 0 : if(nSWMode & (SW_BORDER_MODE_FRAME|SW_BORDER_MODE_PARA))
1114 : {
1115 0 : if(bLineSet)
1116 : {
1117 0 : nValid = (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_TOP) == svx::FRAMESTATE_SHOW) ? VALID_TOP : 0;
1118 0 : nValid |= (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_BOTTOM) == svx::FRAMESTATE_SHOW) ? VALID_BOTTOM : 0;
1119 0 : nValid |= (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_LEFT) == svx::FRAMESTATE_SHOW) ? VALID_LEFT : 0;
1120 0 : nValid |= (aFrameSel.GetFrameBorderState( svx::FRAMEBORDER_RIGHT ) == svx::FRAMESTATE_SHOW) ? VALID_RIGHT : 0;
1121 : }
1122 : else
1123 0 : nValid = 0;
1124 : }
1125 0 : aLeftFT.Enable(0 != (nValid&VALID_LEFT));
1126 0 : aRightFT.Enable(0 != (nValid&VALID_RIGHT));
1127 0 : aTopFT.Enable(0 != (nValid&VALID_TOP));
1128 0 : aBottomFT.Enable(0 != (nValid&VALID_BOTTOM));
1129 0 : aLeftMF.Enable(0 != (nValid&VALID_LEFT));
1130 0 : aRightMF.Enable(0 != (nValid&VALID_RIGHT));
1131 0 : aTopMF.Enable(0 != (nValid&VALID_TOP));
1132 0 : aBottomMF.Enable(0 != (nValid&VALID_BOTTOM));
1133 0 : aSynchronizeCB.Enable( aRightMF.IsEnabled() || aTopMF.IsEnabled() ||
1134 0 : aBottomMF.IsEnabled() || aLeftMF.IsEnabled() );
1135 : }
1136 0 : return 0;
1137 : }
1138 :
1139 : // -----------------------------------------------------------------------
1140 :
1141 0 : IMPL_LINK( SvxBorderTabPage, ModifyDistanceHdl_Impl, MetricField*, pField)
1142 : {
1143 0 : if ( mbSync )
1144 : {
1145 0 : sal_Int64 nVal = pField->GetValue();
1146 0 : if(pField != &aLeftMF)
1147 0 : aLeftMF.SetValue(nVal);
1148 0 : if(pField != &aRightMF)
1149 0 : aRightMF.SetValue(nVal);
1150 0 : if(pField != &aTopMF)
1151 0 : aTopMF.SetValue(nVal);
1152 0 : if(pField != &aBottomMF)
1153 0 : aBottomMF.SetValue(nVal);
1154 : }
1155 0 : return 0;
1156 : }
1157 :
1158 0 : IMPL_LINK( SvxBorderTabPage, SyncHdl_Impl, CheckBox*, pBox)
1159 : {
1160 0 : mbSync = pBox->IsChecked();
1161 0 : return 0;
1162 : }
1163 :
1164 0 : void SvxBorderTabPage::DataChanged( const DataChangedEvent& rDCEvt )
1165 : {
1166 0 : if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1167 0 : FillValueSets();
1168 :
1169 0 : SfxTabPage::DataChanged( rDCEvt );
1170 0 : }
1171 :
1172 0 : void SvxBorderTabPage::PageCreated (SfxAllItemSet aSet)
1173 : {
1174 0 : SFX_ITEMSET_ARG (&aSet,pSWModeItem,SfxUInt16Item,SID_SWMODE_TYPE,sal_False);
1175 0 : SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_FLAG_TYPE,sal_False);
1176 0 : if (pSWModeItem)
1177 : {
1178 0 : nSWMode = pSWModeItem->GetValue();
1179 : // #i43593#
1180 : // show checkbox <aMergeWithNextCB> for format.paragraph
1181 0 : if ( nSWMode == SW_BORDER_MODE_PARA )
1182 : {
1183 0 : aMergeWithNextCB.Show();
1184 0 : aPropertiesFL.Show();
1185 : }
1186 : // show checkbox <aMergeAdjacentBordersCB> for format.paragraph
1187 0 : else if ( nSWMode == SW_BORDER_MODE_TABLE )
1188 : {
1189 0 : aMergeAdjacentBordersCB.Show();
1190 0 : aPropertiesFL.Show();
1191 : }
1192 : }
1193 0 : if (pFlagItem)
1194 0 : if ( ( pFlagItem->GetValue() & SVX_HIDESHADOWCTL ) == SVX_HIDESHADOWCTL )
1195 0 : HideShadowControls();
1196 3 : }
1197 :
1198 : // ============================================================================
1199 :
1200 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|