bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / tabpages / paragrph.cxx
blob111dac960a4b492ebc0df67f9d4aca66105e237b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svl/style.hxx>
21 #include <sfx2/app.hxx>
22 #include <sfx2/dialoghelper.hxx>
23 #include <sfx2/objsh.hxx>
24 #include <sfx2/module.hxx>
25 #include <vcl/mnemonic.hxx>
26 #include <svx/dialogs.hrc>
28 #include <svl/languageoptions.hxx>
29 #include <svl/cjkoptions.hxx>
30 #include <editeng/pgrditem.hxx>
31 #include <cuires.hrc>
32 #include "paragrph.hrc"
33 #include "paragrph.hxx"
34 #include <editeng/frmdiritem.hxx>
35 #include <editeng/lspcitem.hxx>
36 #include <editeng/adjustitem.hxx>
37 #include <editeng/orphitem.hxx>
38 #include <editeng/widwitem.hxx>
39 #include <editeng/tstpitem.hxx>
40 #include <editeng/pmdlitem.hxx>
41 #include <editeng/spltitem.hxx>
42 #include <editeng/hyphenzoneitem.hxx>
43 #include <editeng/ulspitem.hxx>
44 #include <editeng/lrspitem.hxx>
45 #include <editeng/formatbreakitem.hxx>
46 #include <editeng/keepitem.hxx>
47 #include "svx/dlgutil.hxx"
48 #include <dialmgr.hxx>
49 #include <sfx2/htmlmode.hxx>
50 #include <editeng/paravertalignitem.hxx>
51 #include <svl/eitem.hxx>
52 #include <sfx2/request.hxx>
53 #include <svl/intitem.hxx>
54 #include <boost/scoped_ptr.hpp>
56 const sal_uInt16 SvxStdParagraphTabPage::pStdRanges[] =
58 SID_ATTR_PARA_LINESPACE, // 10033
59 SID_ATTR_PARA_LINESPACE,
60 SID_ATTR_LRSPACE, // 10048 -
61 SID_ATTR_ULSPACE, // 10049
62 SID_ATTR_PARA_REGISTER, // 10413
63 SID_ATTR_PARA_REGISTER,
67 const sal_uInt16 SvxParaAlignTabPage::pAlignRanges[] =
69 SID_ATTR_PARA_ADJUST, // 10027
70 SID_ATTR_PARA_ADJUST,
74 const sal_uInt16 SvxExtParagraphTabPage::pExtRanges[] =
76 SID_ATTR_PARA_PAGEBREAK, // 10037 -
77 SID_ATTR_PARA_WIDOWS, // 10041
78 SID_ATTR_PARA_MODEL, // 10065 -
79 SID_ATTR_PARA_KEEP, // 10066
83 #define MAX_DURCH 5670 // 10 cm makes sense as maximum interline lead
84 // according to BP
85 #define FIX_DIST_DEF 283 // standard fix distance 0,5 cm
87 enum LineSpaceList
89 LLINESPACE_1 = 0,
90 LLINESPACE_15 = 1,
91 LLINESPACE_2 = 2,
92 LLINESPACE_PROP = 3,
93 LLINESPACE_MIN = 4,
94 LLINESPACE_DURCH= 5,
95 LLINESPACE_FIX = 6,
96 LLINESPACE_END
99 void SetLineSpace_Impl( SvxLineSpacingItem&, int, long lValue = 0 );
101 void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
102 int eSpace, long lValue )
104 switch ( eSpace )
106 case LLINESPACE_1:
107 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
108 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
109 break;
111 case LLINESPACE_15:
112 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
113 rLineSpace.SetPropLineSpace( 150 );
114 break;
116 case LLINESPACE_2:
117 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
118 rLineSpace.SetPropLineSpace( 200 );
119 break;
121 case LLINESPACE_PROP:
122 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
123 rLineSpace.SetPropLineSpace( (sal_uInt8)lValue );
124 break;
126 case LLINESPACE_MIN:
127 rLineSpace.SetLineHeight( (sal_uInt16)lValue );
128 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
129 break;
131 case LLINESPACE_DURCH:
132 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
133 rLineSpace.SetInterLineSpace( (sal_uInt16)lValue );
134 break;
136 case LLINESPACE_FIX:
137 rLineSpace.SetLineHeight((sal_uInt16)lValue);
138 rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
139 rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
140 break;
144 sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
146 sal_uInt16 nHtmlMode = 0;
147 const SfxPoolItem* pItem = 0;
148 SfxObjectShell* pShell;
149 if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem) ||
150 ( 0 != (pShell = SfxObjectShell::Current()) &&
151 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
153 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
155 return nHtmlMode;
159 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl)
161 SfxItemPool* pPool = GetItemSet().GetPool();
162 DBG_ASSERT( pPool, "Wo ist der Pool" );
163 FieldUnit eUnit =
164 MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
166 sal_Int64 nL = m_pLeftIndent->Denormalize( m_pLeftIndent->GetValue( eUnit ) );
167 sal_Int64 nR = m_pRightIndent->Denormalize( m_pRightIndent->GetValue( eUnit ) );
168 OUString aTmp = m_pFLineIndent->GetText();
170 if( m_pLeftIndent->GetMin() < 0 )
171 m_pFLineIndent->SetMin( -99999, FUNIT_MM );
172 else
173 m_pFLineIndent->SetMin( m_pFLineIndent->Normalize( -nL ), eUnit );
175 // Check only for concrete width (Shell)
176 sal_Int64 nTmp = nWidth - nL - nR - MM50;
177 m_pFLineIndent->SetMax( m_pFLineIndent->Normalize( nTmp ), eUnit );
179 if ( aTmp.isEmpty() )
180 m_pFLineIndent->SetEmptyFieldValue();
181 // maximum left right
182 aTmp = m_pLeftIndent->GetText();
183 nTmp = nWidth - nR - MM50;
184 m_pLeftIndent->SetMax( m_pLeftIndent->Normalize( nTmp ), eUnit );
186 if ( aTmp.isEmpty() )
187 m_pLeftIndent->SetEmptyFieldValue();
188 aTmp = m_pRightIndent->GetText();
189 nTmp = nWidth - nL - MM50;
190 m_pRightIndent->SetMax( m_pRightIndent->Normalize( nTmp ), eUnit );
192 if ( aTmp.isEmpty() )
193 m_pRightIndent->SetEmptyFieldValue();
194 return 0;
197 VclPtr<SfxTabPage> SvxStdParagraphTabPage::Create( vcl::Window* pParent, const SfxItemSet* rSet)
199 return VclPtr<SvxStdParagraphTabPage>::Create( pParent, *rSet );
202 bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
204 SfxItemState eState = SfxItemState::UNKNOWN;
205 const SfxPoolItem* pOld = 0;
206 SfxItemPool* pPool = rOutSet->GetPool();
207 DBG_ASSERT( pPool, "Wo ist der Pool" );
209 bool bModified = false;
210 sal_uInt16 nWhich;
211 sal_Int32 nPos = m_pLineDist->GetSelectEntryPos();
213 if ( LISTBOX_ENTRY_NOTFOUND != nPos &&
214 ( m_pLineDist->IsValueChangedFromSaved() ||
215 m_pLineDistAtPercentBox->IsValueModified() ||
216 m_pLineDistAtMetricBox->IsValueModified() ) )
218 nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
219 SfxMapUnit eUnit = pPool->GetMetric( nWhich );
220 SvxLineSpacingItem aSpacing(
221 static_cast<const SvxLineSpacingItem&>(GetItemSet().Get( nWhich )) );
223 switch ( nPos )
225 case LLINESPACE_1:
226 case LLINESPACE_15:
227 case LLINESPACE_2:
228 SetLineSpace_Impl( aSpacing, nPos );
229 break;
231 case LLINESPACE_PROP:
232 SetLineSpace_Impl( aSpacing, nPos,
233 static_cast<long>(m_pLineDistAtPercentBox->Denormalize(
234 m_pLineDistAtPercentBox->GetValue() )) );
235 break;
237 case LLINESPACE_MIN:
238 case LLINESPACE_DURCH:
239 case LLINESPACE_FIX:
240 SetLineSpace_Impl( aSpacing, nPos,
241 GetCoreValue( *m_pLineDistAtMetricBox, eUnit ) );
242 break;
244 default:
245 OSL_FAIL( "unbekannter Type fuer Zeilenabstand." );
246 break;
248 eState = GetItemSet().GetItemState( nWhich );
249 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_LINESPACE );
251 if ( !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) ||
252 SfxItemState::DONTCARE == eState )
254 rOutSet->Put( aSpacing );
255 bModified = true;
259 if ( m_pTopDist->IsValueModified() || m_pBottomDist->IsValueModified()
260 || m_pContextualCB->IsValueChangedFromSaved())
262 nWhich = GetWhich( SID_ATTR_ULSPACE );
263 SfxMapUnit eUnit = pPool->GetMetric( nWhich );
264 pOld = GetOldItem( *rOutSet, SID_ATTR_ULSPACE );
265 SvxULSpaceItem aMargin( nWhich );
267 if ( bRelativeMode )
269 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
271 const SvxULSpaceItem& rOldItem =
272 static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
274 if ( m_pTopDist->IsRelative() )
275 aMargin.SetUpper( rOldItem.GetUpper(),
276 (sal_uInt16)m_pTopDist->GetValue() );
277 else
278 aMargin.SetUpper( (sal_uInt16)GetCoreValue( *m_pTopDist, eUnit ) );
280 if ( m_pBottomDist->IsRelative() )
281 aMargin.SetLower( rOldItem.GetLower(),
282 (sal_uInt16)m_pBottomDist->GetValue() );
283 else
284 aMargin.SetLower( (sal_uInt16)GetCoreValue( *m_pBottomDist, eUnit ) );
287 else
289 aMargin.SetUpper( (sal_uInt16)GetCoreValue( *m_pTopDist, eUnit ) );
290 aMargin.SetLower( (sal_uInt16)GetCoreValue( *m_pBottomDist, eUnit ) );
292 aMargin.SetContextValue(m_pContextualCB->IsChecked());
293 eState = GetItemSet().GetItemState( nWhich );
295 if ( !pOld || !( *static_cast<const SvxULSpaceItem*>(pOld) == aMargin ) ||
296 SfxItemState::DONTCARE == eState )
298 rOutSet->Put( aMargin );
299 bModified = true;
302 bool bNullTab = false;
304 if ( m_pLeftIndent->IsValueModified() ||
305 m_pFLineIndent->IsValueModified() ||
306 m_pRightIndent->IsValueModified() ||
307 m_pAutoCB->IsValueChangedFromSaved() )
309 nWhich = GetWhich( SID_ATTR_LRSPACE );
310 SfxMapUnit eUnit = pPool->GetMetric( nWhich );
311 SvxLRSpaceItem aMargin( nWhich );
312 pOld = GetOldItem( *rOutSet, SID_ATTR_LRSPACE );
314 if ( bRelativeMode )
316 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
318 const SvxLRSpaceItem& rOldItem =
319 static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
321 if ( m_pLeftIndent->IsRelative() )
322 aMargin.SetTextLeft( rOldItem.GetTextLeft(),
323 (sal_uInt16)m_pLeftIndent->GetValue() );
324 else
325 aMargin.SetTextLeft( GetCoreValue( *m_pLeftIndent, eUnit ) );
327 if ( m_pRightIndent->IsRelative() )
328 aMargin.SetRight( rOldItem.GetRight(),
329 (sal_uInt16)m_pRightIndent->GetValue() );
330 else
331 aMargin.SetRight( GetCoreValue( *m_pRightIndent, eUnit ) );
333 if ( m_pFLineIndent->IsRelative() )
334 aMargin.SetTextFirstLineOfst( rOldItem.GetTextFirstLineOfst(),
335 (sal_uInt16)m_pFLineIndent->GetValue() );
336 else
337 aMargin.SetTextFirstLineOfst(
338 (sal_uInt16)GetCoreValue( *m_pFLineIndent, eUnit ) );
340 else
342 aMargin.SetTextLeft( GetCoreValue( *m_pLeftIndent, eUnit ) );
343 aMargin.SetRight( GetCoreValue( *m_pRightIndent, eUnit ) );
344 aMargin.SetTextFirstLineOfst(
345 (sal_uInt16)GetCoreValue( *m_pFLineIndent, eUnit ) );
347 aMargin.SetAutoFirst(m_pAutoCB->IsChecked());
348 if ( aMargin.GetTextFirstLineOfst() < 0 )
349 bNullTab = true;
350 eState = GetItemSet().GetItemState( nWhich );
352 if ( !pOld || !( *static_cast<const SvxLRSpaceItem*>(pOld) == aMargin ) ||
353 SfxItemState::DONTCARE == eState )
355 rOutSet->Put( aMargin );
356 bModified = true;
360 if ( bNullTab )
362 MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
363 if ( MAP_100TH_MM != eUnit )
366 // negative first line indent -> set null default tabstob if applicable
367 sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
368 const SfxItemSet& rInSet = GetItemSet();
370 if ( rInSet.GetItemState( _nWhich ) >= SfxItemState::DEFAULT )
372 const SvxTabStopItem& rTabItem =
373 static_cast<const SvxTabStopItem&>(rInSet.Get( _nWhich ));
374 SvxTabStopItem aNullTab( rTabItem );
375 SvxTabStop aNull( 0, SVX_TAB_ADJUST_DEFAULT );
376 aNullTab.Insert( aNull );
377 rOutSet->Put( aNullTab );
381 if( m_pRegisterCB->IsVisible())
383 const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(GetOldItem(
384 *rOutSet, SID_ATTR_PARA_REGISTER));
385 if (!pBoolItem)
386 return bModified;
387 boost::scoped_ptr<SfxBoolItem> pRegItem(static_cast<SfxBoolItem*>(pBoolItem->Clone()));
388 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
389 bool bSet = pRegItem->GetValue();
391 if(m_pRegisterCB->IsChecked() != bSet )
393 pRegItem->SetValue(!bSet);
394 rOutSet->Put(*pRegItem);
395 bModified = true;
397 else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) )
398 rOutSet->ClearItem(_nWhich);
401 return bModified;
404 void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet )
406 SfxItemPool* pPool = rSet->GetPool();
407 DBG_ASSERT( pPool, "Wo ist der Pool?" );
409 // adjust metric
410 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
412 bool bApplyCharUnit = GetApplyCharUnit( *rSet );
414 SvtCJKOptions aCJKOptions;
415 if(aCJKOptions.IsAsianTypographyEnabled() && bApplyCharUnit )
416 eFUnit = FUNIT_CHAR;
418 SetFieldUnit( *m_pLeftIndent, eFUnit );
419 SetFieldUnit( *m_pRightIndent, eFUnit );
420 SetFieldUnit( *m_pFLineIndent, eFUnit );
421 if ( eFUnit == FUNIT_CHAR )
423 SetFieldUnit( *m_pTopDist, FUNIT_LINE );
424 SetFieldUnit( *m_pBottomDist, FUNIT_LINE );
425 SetFieldUnit( *m_pLineDistAtMetricBox, FUNIT_POINT );
427 else
429 SetFieldUnit( *m_pTopDist, eFUnit );
430 SetFieldUnit( *m_pBottomDist, eFUnit );
431 SetFieldUnit( *m_pLineDistAtMetricBox, eFUnit );
434 sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
435 SfxItemState eItemState = rSet->GetItemState( _nWhich );
437 if ( eItemState >= SfxItemState::DEFAULT )
439 SfxMapUnit eUnit = pPool->GetMetric( _nWhich );
441 if ( bRelativeMode )
443 const SvxLRSpaceItem& rOldItem =
444 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
446 if ( rOldItem.GetPropLeft() != 100 )
448 m_pLeftIndent->SetRelative( true );
449 m_pLeftIndent->SetValue( rOldItem.GetPropLeft() );
451 else
453 m_pLeftIndent->SetRelative();
454 SetFieldUnit( *m_pLeftIndent, eFUnit );
455 SetMetricValue( *m_pLeftIndent, rOldItem.GetTextLeft(), eUnit );
458 if ( rOldItem.GetPropRight() != 100 )
460 m_pRightIndent->SetRelative( true );
461 m_pRightIndent->SetValue( rOldItem.GetPropRight() );
463 else
465 m_pRightIndent->SetRelative();
466 SetFieldUnit( *m_pRightIndent, eFUnit );
467 SetMetricValue( *m_pRightIndent, rOldItem.GetRight(), eUnit );
470 if ( rOldItem.GetPropTextFirstLineOfst() != 100 )
472 m_pFLineIndent->SetRelative( true );
473 m_pFLineIndent->SetValue( rOldItem.GetPropTextFirstLineOfst() );
475 else
477 m_pFLineIndent->SetRelative();
478 m_pFLineIndent->SetMin(-9999);
479 SetFieldUnit( *m_pFLineIndent, eFUnit );
480 SetMetricValue( *m_pFLineIndent, rOldItem.GetTextFirstLineOfst(),
481 eUnit );
483 m_pAutoCB->Check(rOldItem.IsAutoFirst());
485 else
487 const SvxLRSpaceItem& rSpace =
488 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
490 SetMetricValue( *m_pLeftIndent, rSpace.GetTextLeft(), eUnit );
491 SetMetricValue( *m_pRightIndent, rSpace.GetRight(), eUnit );
492 SetMetricValue( *m_pFLineIndent, rSpace.GetTextFirstLineOfst(), eUnit );
493 m_pAutoCB->Check(rSpace.IsAutoFirst());
495 AutoHdl_Impl(m_pAutoCB);
497 else
499 m_pLeftIndent->SetEmptyFieldValue();
500 m_pRightIndent->SetEmptyFieldValue();
501 m_pFLineIndent->SetEmptyFieldValue();
504 _nWhich = GetWhich( SID_ATTR_ULSPACE );
505 eItemState = rSet->GetItemState( _nWhich );
507 if ( eItemState >= SfxItemState::DEFAULT )
509 SfxMapUnit eUnit = pPool->GetMetric( _nWhich );
511 const SvxULSpaceItem& rOldItem =
512 static_cast<const SvxULSpaceItem&>(rSet->Get( _nWhich ));
513 if ( bRelativeMode )
516 if ( rOldItem.GetPropUpper() != 100 )
518 m_pTopDist->SetRelative( true );
519 m_pTopDist->SetValue( rOldItem.GetPropUpper() );
521 else
523 m_pTopDist->SetRelative();
524 if ( eFUnit == FUNIT_CHAR )
525 SetFieldUnit( *m_pTopDist, FUNIT_LINE );
526 else
527 SetFieldUnit( *m_pTopDist, eFUnit );
528 SetMetricValue( *m_pTopDist, rOldItem.GetUpper(), eUnit );
531 if ( rOldItem.GetPropLower() != 100 )
533 m_pBottomDist->SetRelative( true );
534 m_pBottomDist->SetValue( rOldItem.GetPropLower() );
536 else
538 m_pBottomDist->SetRelative();
539 if ( eFUnit == FUNIT_CHAR )
540 SetFieldUnit( *m_pBottomDist, FUNIT_LINE );
541 else
542 SetFieldUnit( *m_pBottomDist, eFUnit );
543 SetMetricValue( *m_pBottomDist, rOldItem.GetLower(), eUnit );
546 else
548 SetMetricValue( *m_pTopDist, rOldItem.GetUpper(), eUnit );
549 SetMetricValue( *m_pBottomDist, rOldItem.GetLower(), eUnit );
551 m_pContextualCB->Check(rOldItem.GetContext());
553 else
555 m_pTopDist->SetEmptyFieldValue();
556 m_pBottomDist->SetEmptyFieldValue();
559 _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
560 eItemState = rSet->GetItemState( _nWhich );
562 if ( eItemState >= SfxItemState::DEFAULT )
563 SetLineSpacing_Impl( static_cast<const SvxLineSpacingItem &>(rSet->Get( _nWhich )) );
564 else
565 m_pLineDist->SetNoSelection();
567 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
568 eItemState = rSet->GetItemState( _nWhich );
570 if ( eItemState >= SfxItemState::DEFAULT )
571 m_pRegisterCB->Check( static_cast<const SfxBoolItem &>(rSet->Get( _nWhich )).GetValue());
572 m_pRegisterCB->SaveValue();
573 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
574 if(nHtmlMode & HTMLMODE_ON)
576 m_pRegisterFL->Hide();
577 m_pRegisterCB->Hide();
578 m_pAutoCB->Hide();
581 // this sets the min/max limits; do this _after_ setting the values,
582 // because for Impress the min of first-line indent depends on value of
583 // left-indent!
584 ELRLoseFocusHdl( NULL );
585 m_pAutoCB->SaveValue();
586 m_pContextualCB->SaveValue();
587 m_pLineDist->SaveValue();
590 void SvxStdParagraphTabPage::EnableRelativeMode()
592 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );
594 m_pLeftIndent->EnableRelativeMode( 0, 999 );
595 m_pFLineIndent->EnableRelativeMode( 0, 999 );
596 m_pRightIndent->EnableRelativeMode( 0, 999 );
597 m_pTopDist->EnableRelativeMode( 0, 999 );
598 m_pBottomDist->EnableRelativeMode( 0, 999 );
599 bRelativeMode = true;
602 SfxTabPage::sfxpg SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
604 ELRLoseFocusHdl( NULL );
606 if ( _pSet )
607 FillItemSet( _pSet );
608 return LEAVE_PAGE;
611 SvxStdParagraphTabPage::SvxStdParagraphTabPage( vcl::Window* pParent, const SfxItemSet& rAttr ) :
612 SfxTabPage( pParent, "ParaIndentSpacing","cui/ui/paraindentspacing.ui", &rAttr ),
614 nAbst ( MAX_DURCH ),
615 nWidth ( 11905 /*567 * 50*/ ),
616 nMinFixDist(0L),
618 bRelativeMode ( false ),
619 bNegativeIndents(false)
622 get(m_pLeftIndent,"spinED_LEFTINDENT");
623 get(m_pRightIndent,"spinED_RIGHTINDENT");
624 get(m_pRightLabel,"labelFT_RIGHTINDENT");
625 get(m_pFLineLabel,"labelFT_FLINEINDENT");
626 get(m_pFLineIndent,"spinED_FLINEINDENT");
627 get(m_pAutoCB,"checkCB_AUTO");
629 get(m_pTopDist,"spinED_TOPDIST");
630 get(m_pBottomDist,"spinED_BOTTOMDIST");
631 get(m_pContextualCB,"checkCB_CONTEXTUALSPACING");
633 get(m_pLineDist,"comboLB_LINEDIST");
634 get(m_pLineDistAtPercentBox,"spinED_LINEDISTPERCENT");
635 get(m_pLineDistAtMetricBox,"spinED_LINEDISTMETRIC");
636 get(m_pLineDistAtLabel,"labelFT_LINEDIST");
638 get(m_pAbsDist,"labelST_LINEDIST_ABS");
639 sAbsDist = m_pAbsDist->GetText();
641 get(m_pRegisterFL,"frameFL_REGISTER");
642 get(m_pRegisterCB,"checkCB_REGISTER");
644 get(m_pExampleWin,"drawingareaWN_EXAMPLE");
646 // this page needs ExchangeSupport
647 SetExchangeSupport();
649 m_pLineDistAtMetricBox->Hide();
651 Init_Impl();
652 m_pFLineIndent->SetMin(-9999); // is set to 0 on default
654 setPreviewsToSamePlace(pParent, this);
657 SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
659 disposeOnce();
662 void SvxStdParagraphTabPage::dispose()
664 m_pLeftIndent.clear();
665 m_pRightLabel.clear();
666 m_pRightIndent.clear();
667 m_pFLineLabel.clear();
668 m_pFLineIndent.clear();
669 m_pAutoCB.clear();
670 m_pTopDist.clear();
671 m_pBottomDist.clear();
672 m_pContextualCB.clear();
673 m_pLineDist.clear();
674 m_pLineDistAtLabel.clear();
675 m_pLineDistAtPercentBox.clear();
676 m_pLineDistAtMetricBox.clear();
677 m_pAbsDist.clear();
678 m_pExampleWin.clear();
679 m_pRegisterFL.clear();
680 m_pRegisterCB.clear();
681 SfxTabPage::dispose();
684 void SvxStdParagraphTabPage::EnableNegativeMode()
686 m_pLeftIndent->SetMin(-9999);
687 m_pRightIndent->SetMin(-9999);
688 m_pRightIndent->EnableNegativeMode();
689 m_pLeftIndent->EnableNegativeMode();
690 bNegativeIndents = true;
693 void SvxStdParagraphTabPage::SetLineSpacing_Impl
695 const SvxLineSpacingItem &rAttr
698 SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( rAttr.Which() );
700 switch( rAttr.GetLineSpaceRule() )
702 case SVX_LINE_SPACE_AUTO:
704 SvxInterLineSpace eInter = rAttr.GetInterLineSpaceRule();
706 switch( eInter )
708 // Default single line spacing
709 case SVX_INTER_LINE_SPACE_OFF:
710 m_pLineDist->SelectEntryPos( LLINESPACE_1 );
711 break;
713 // Default single line spacing
714 case SVX_INTER_LINE_SPACE_PROP:
715 if ( 100 == rAttr.GetPropLineSpace() )
717 m_pLineDist->SelectEntryPos( LLINESPACE_1 );
718 break;
720 // 1.5 line spacing
721 if ( 150 == rAttr.GetPropLineSpace() )
723 m_pLineDist->SelectEntryPos( LLINESPACE_15 );
724 break;
726 // double line spacing
727 if ( 200 == rAttr.GetPropLineSpace() )
729 m_pLineDist->SelectEntryPos( LLINESPACE_2 );
730 break;
732 // the set per cent value
733 m_pLineDistAtPercentBox->SetValue( m_pLineDistAtPercentBox->Normalize(rAttr.GetPropLineSpace() ) );
734 m_pLineDist->SelectEntryPos( LLINESPACE_PROP );
735 break;
737 case SVX_INTER_LINE_SPACE_FIX:
738 SetMetricValue( *m_pLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
739 m_pLineDist->SelectEntryPos( LLINESPACE_DURCH );
740 break;
741 default: ;//prevent warning
744 break;
745 case SVX_LINE_SPACE_FIX:
746 SetMetricValue(*m_pLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
747 m_pLineDist->SelectEntryPos( LLINESPACE_FIX );
748 break;
750 case SVX_LINE_SPACE_MIN:
751 SetMetricValue(*m_pLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
752 m_pLineDist->SelectEntryPos( LLINESPACE_MIN );
753 break;
754 default: ;//prevent warning
756 LineDistHdl_Impl( m_pLineDist );
759 IMPL_LINK( SvxStdParagraphTabPage, LineDistHdl_Impl, ListBox *, pBox )
761 switch( pBox->GetSelectEntryPos() )
763 case LLINESPACE_1:
764 case LLINESPACE_15:
765 case LLINESPACE_2:
766 m_pLineDistAtLabel->Enable(false);
767 m_pLineDistAtPercentBox->Enable(false);
768 m_pLineDistAtPercentBox->SetText( OUString() );
769 m_pLineDistAtMetricBox->Enable(false);
770 m_pLineDistAtMetricBox->SetText( OUString() );
771 break;
773 case LLINESPACE_DURCH:
774 // setting a sensible default?
775 // limit MS min(10, aPageSize)
776 m_pLineDistAtMetricBox->SetMin(0);
778 if ( m_pLineDistAtMetricBox->GetText().isEmpty() )
779 m_pLineDistAtMetricBox->SetValue( m_pLineDistAtMetricBox->Normalize( 1 ) );
780 m_pLineDistAtPercentBox->Hide();
781 m_pLineDistAtMetricBox->Show();
782 m_pLineDistAtMetricBox->Enable();
783 m_pLineDistAtLabel->Enable();
784 break;
786 case LLINESPACE_MIN:
787 m_pLineDistAtMetricBox->SetMin(0);
789 if ( m_pLineDistAtMetricBox->GetText().isEmpty() )
790 m_pLineDistAtMetricBox->SetValue( m_pLineDistAtMetricBox->Normalize( 10 ), FUNIT_TWIP );
791 m_pLineDistAtPercentBox->Hide();
792 m_pLineDistAtMetricBox->Show();
793 m_pLineDistAtMetricBox->Enable();
794 m_pLineDistAtLabel->Enable();
795 break;
797 case LLINESPACE_PROP:
799 if ( m_pLineDistAtPercentBox->GetText().isEmpty() )
800 m_pLineDistAtPercentBox->SetValue( m_pLineDistAtPercentBox->Normalize( 100 ), FUNIT_TWIP );
801 m_pLineDistAtMetricBox->Hide();
802 m_pLineDistAtPercentBox->Show();
803 m_pLineDistAtPercentBox->Enable();
804 m_pLineDistAtLabel->Enable();
805 break;
806 case LLINESPACE_FIX:
808 sal_Int64 nTemp = m_pLineDistAtMetricBox->GetValue();
809 m_pLineDistAtMetricBox->SetMin(m_pLineDistAtMetricBox->Normalize(nMinFixDist), FUNIT_TWIP);
811 // if the value has been changed at SetMin,
812 // it is time for the default
813 if ( m_pLineDistAtMetricBox->GetValue() != nTemp )
814 SetMetricValue( *m_pLineDistAtMetricBox, FIX_DIST_DEF, SFX_MAPUNIT_TWIP ); // fix is only in Writer
815 m_pLineDistAtPercentBox->Hide();
816 m_pLineDistAtMetricBox->Show();
817 m_pLineDistAtMetricBox->Enable();
818 m_pLineDistAtLabel->Enable();
820 break;
822 UpdateExample_Impl();
823 return 0;
826 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ModifyHdl_Impl)
828 UpdateExample_Impl();
829 return 0;
832 void SvxStdParagraphTabPage::Init_Impl()
834 m_pLineDist->SetSelectHdl(
835 LINK( this, SvxStdParagraphTabPage, LineDistHdl_Impl ) );
837 Link<> aLink = LINK( this, SvxStdParagraphTabPage, ELRLoseFocusHdl );
838 m_pFLineIndent->SetLoseFocusHdl( aLink );
839 m_pLeftIndent->SetLoseFocusHdl( aLink );
840 m_pRightIndent->SetLoseFocusHdl( aLink );
842 aLink = LINK( this, SvxStdParagraphTabPage, ModifyHdl_Impl );
843 m_pFLineIndent->SetModifyHdl( aLink );
844 m_pLeftIndent->SetModifyHdl( aLink );
845 m_pRightIndent->SetModifyHdl( aLink );
846 m_pTopDist->SetModifyHdl( aLink );
847 m_pBottomDist->SetModifyHdl( aLink );
849 m_pAutoCB->SetClickHdl( LINK( this, SvxStdParagraphTabPage, AutoHdl_Impl ));
850 SfxItemPool* pPool = GetItemSet().GetPool();
851 DBG_ASSERT( pPool, "Wo ist der Pool" );
852 FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
854 m_pTopDist->SetMax( m_pTopDist->Normalize( nAbst ), eUnit );
855 m_pBottomDist->SetMax( m_pBottomDist->Normalize( nAbst ), eUnit );
856 m_pLineDistAtMetricBox->SetMax( m_pLineDistAtMetricBox->Normalize( nAbst ), eUnit );
859 void SvxStdParagraphTabPage::UpdateExample_Impl()
861 m_pExampleWin->SetFirstLineOfst( (short)m_pFLineIndent->Denormalize( m_pFLineIndent->GetValue( FUNIT_TWIP ) ) );
862 m_pExampleWin->SetLeftMargin( static_cast<long>(m_pLeftIndent->Denormalize( m_pLeftIndent->GetValue( FUNIT_TWIP ) ) ) );
863 m_pExampleWin->SetRightMargin( static_cast<long>(m_pRightIndent->Denormalize( m_pRightIndent->GetValue( FUNIT_TWIP ) ) ) );
864 m_pExampleWin->SetUpper( (sal_uInt16)m_pTopDist->Denormalize( m_pTopDist->GetValue( FUNIT_TWIP ) ) );
865 m_pExampleWin->SetLower( (sal_uInt16)m_pBottomDist->Denormalize( m_pBottomDist->GetValue( FUNIT_TWIP ) ) );
867 sal_Int32 nPos = m_pLineDist->GetSelectEntryPos();
869 switch ( nPos )
871 case LLINESPACE_1:
872 case LLINESPACE_15:
873 case LLINESPACE_2:
874 m_pExampleWin->SetLineSpace( (SvxPrevLineSpace)nPos );
875 break;
877 case LLINESPACE_PROP:
878 m_pExampleWin->SetLineSpace( (SvxPrevLineSpace)nPos,
879 (sal_uInt16)m_pLineDistAtPercentBox->Denormalize( m_pLineDistAtPercentBox->GetValue() ) );
880 break;
882 case LLINESPACE_MIN:
883 case LLINESPACE_DURCH:
884 case LLINESPACE_FIX:
885 m_pExampleWin->SetLineSpace( (SvxPrevLineSpace)nPos,
886 (sal_uInt16)GetCoreValue( *m_pLineDistAtMetricBox, SFX_MAPUNIT_TWIP ) );
887 break;
889 m_pExampleWin->Invalidate();
892 void SvxStdParagraphTabPage::EnableRegisterMode()
894 m_pRegisterCB->Show();
895 m_pRegisterFL->Show();
898 void SvxStdParagraphTabPage::EnableContextualMode()
900 m_pContextualCB->Show();
903 IMPL_LINK( SvxStdParagraphTabPage, AutoHdl_Impl, CheckBox*, pBox )
905 bool bEnable = !pBox->IsChecked();
906 m_pFLineLabel->Enable(bEnable);
907 m_pFLineIndent->Enable(bEnable);
908 return 0;
911 void SvxStdParagraphTabPage::SetPageWidth( sal_uInt16 nPageWidth )
913 nWidth = nPageWidth;
916 void SvxStdParagraphTabPage::EnableAutoFirstLine()
918 m_pAutoCB->Show();
921 void SvxStdParagraphTabPage::EnableAbsLineDist(long nMinTwip)
923 m_pLineDist->InsertEntry(sAbsDist);
924 nMinFixDist = nMinTwip;
927 void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
930 /* different bit represent call to different method of SvxStdParagraphTabPage
931 0x0001 --->EnableRelativeMode()
932 0x0002 --->EnableRegisterMode()
933 0x0004 --->EnableAutoFirstLine()
934 0x0008 --->EnableNegativeMode()
935 0x0010 --->EnableContextualMode()
937 SFX_ITEMSET_ARG (&aSet,pPageWidthItem,SfxUInt16Item,SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,false);
938 SFX_ITEMSET_ARG (&aSet,pFlagSetItem,SfxUInt32Item,SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,false);
939 SFX_ITEMSET_ARG (&aSet,pLineDistItem,SfxUInt32Item,SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST,false);
941 if (pPageWidthItem)
942 SetPageWidth(pPageWidthItem->GetValue());
944 if (pFlagSetItem )
945 if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
946 EnableRelativeMode();
948 if (pFlagSetItem)
949 if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
950 EnableRegisterMode();
952 if (pFlagSetItem)
953 if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
954 EnableAutoFirstLine();
956 if(pLineDistItem)
957 EnableAbsLineDist(pLineDistItem->GetValue());
959 if (pFlagSetItem)
960 if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
961 EnableNegativeMode();
963 if (pFlagSetItem)
964 if (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
965 EnableContextualMode();
968 #define LASTLINEPOS_DEFAULT 0
969 #define LASTLINEPOS_LEFT 1
971 #define LASTLINECOUNT_OLD 3
972 #define LASTLINECOUNT_NEW 4
974 SvxParaAlignTabPage::SvxParaAlignTabPage( vcl::Window* pParent, const SfxItemSet& rSet )
976 : SfxTabPage(pParent, "ParaAlignPage", "cui/ui/paragalignpage.ui",&rSet)
978 get(m_pLeft,"radioBTN_LEFTALIGN");
979 get(m_pRight,"radioBTN_RIGHTALIGN");
980 get(m_pCenter,"radioBTN_CENTERALIGN");
981 get(m_pJustify,"radioBTN_JUSTIFYALIGN");
982 get(m_pLeftBottom,"labelST_LEFTALIGN_ASIAN");
983 get(m_pRightTop,"labelST_RIGHTALIGN_ASIAN");
985 get(m_pLastLineFT,"labelLB_LASTLINE");
986 get(m_pLastLineLB,"comboLB_LASTLINE");
987 get(m_pExpandCB,"checkCB_EXPAND");
988 get(m_pSnapToGridCB,"checkCB_SNAP");
989 get(m_pExampleWin,"drawingareaWN_EXAMPLE");
991 get(m_pVertAlignLB,"comboLB_VERTALIGN");
992 get(m_pVertAlignFL,"frameFL_VERTALIGN");
994 get(m_pPropertiesFL,"framePROPERTIES");
995 get(m_pTextDirectionLB,"comboLB_TEXTDIRECTION");
997 SvtLanguageOptions aLangOptions;
998 sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;
1000 if ( aLangOptions.IsAsianTypographyEnabled() )
1002 m_pLeft->SetText(m_pLeftBottom->GetText());
1003 m_pRight->SetText(m_pRightTop->GetText());
1005 OUString sLeft(m_pLeft->GetText());
1006 sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );
1008 if ( m_pLastLineLB->GetEntryCount() == LASTLINECOUNT_OLD )
1010 m_pLastLineLB->RemoveEntry( 0 );
1011 m_pLastLineLB->InsertEntry( sLeft, 0 );
1013 else
1014 nLastLinePos = LASTLINEPOS_LEFT;
1017 // remove "Default" or "Left" entry, depends on CJKOptions
1018 if ( m_pLastLineLB->GetEntryCount() == LASTLINECOUNT_NEW )
1019 m_pLastLineLB->RemoveEntry( nLastLinePos );
1021 Link<> aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
1022 m_pLeft->SetClickHdl( aLink );
1023 m_pRight->SetClickHdl( aLink );
1024 m_pCenter->SetClickHdl( aLink );
1025 m_pJustify->SetClickHdl( aLink );
1026 m_pLastLineLB->SetSelectHdl( LINK( this, SvxParaAlignTabPage, LastLineHdl_Impl ) );
1027 m_pTextDirectionLB->SetSelectHdl( LINK( this, SvxParaAlignTabPage, TextDirectionHdl_Impl ) );
1029 if( aLangOptions.IsCTLFontEnabled() )
1031 m_pTextDirectionLB->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_LTR ), FRMDIR_HORI_LEFT_TOP );
1032 m_pTextDirectionLB->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_RTL ), FRMDIR_HORI_RIGHT_TOP );
1033 m_pTextDirectionLB->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_SUPER ), FRMDIR_ENVIRONMENT );
1035 m_pPropertiesFL->Show();
1038 setPreviewsToSamePlace(pParent, this);
1041 SvxParaAlignTabPage::~SvxParaAlignTabPage()
1043 disposeOnce();
1046 void SvxParaAlignTabPage::dispose()
1048 m_pLeft.clear();
1049 m_pRight.clear();
1050 m_pCenter.clear();
1051 m_pJustify.clear();
1052 m_pLeftBottom.clear();
1053 m_pRightTop.clear();
1054 m_pLastLineFT.clear();
1055 m_pLastLineLB.clear();
1056 m_pExpandCB.clear();
1057 m_pSnapToGridCB.clear();
1058 m_pExampleWin.clear();
1059 m_pVertAlignFL.clear();
1060 m_pVertAlignLB.clear();
1061 m_pPropertiesFL.clear();
1062 m_pTextDirectionLB.clear();
1063 SfxTabPage::dispose();
1066 SfxTabPage::sfxpg SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
1068 if ( _pSet )
1069 FillItemSet( _pSet );
1070 return LEAVE_PAGE;
1073 VclPtr<SfxTabPage> SvxParaAlignTabPage::Create( vcl::Window* pParent, const SfxItemSet* rSet )
1075 return VclPtr<SvxParaAlignTabPage>::Create(pParent, *rSet);
1078 bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet )
1080 bool bModified = false;
1082 bool bAdj = false, bChecked = false;
1083 SvxAdjust eAdjust = SVX_ADJUST_LEFT;
1085 if ( m_pLeft->IsChecked() )
1087 eAdjust = SVX_ADJUST_LEFT;
1088 bAdj = !m_pLeft->GetSavedValue();
1089 bChecked = true;
1091 else if ( m_pRight->IsChecked() )
1093 eAdjust = SVX_ADJUST_RIGHT;
1094 bAdj = !m_pRight->GetSavedValue();
1095 bChecked = true;
1097 else if ( m_pCenter->IsChecked() )
1099 eAdjust = SVX_ADJUST_CENTER;
1100 bAdj = !m_pCenter->GetSavedValue();
1101 bChecked = true;
1103 else if ( m_pJustify->IsChecked() )
1105 eAdjust = SVX_ADJUST_BLOCK;
1106 bAdj = !m_pJustify->GetSavedValue() ||
1107 m_pExpandCB->IsValueChangedFromSaved() ||
1108 m_pLastLineLB->IsValueChangedFromSaved();
1109 bChecked = true;
1111 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1113 if ( bAdj )
1115 const SvxAdjustItem* pOld = static_cast<const SvxAdjustItem*>(GetOldItem( *rOutSet, SID_ATTR_PARA_ADJUST ));
1117 SvxAdjust eOneWord = m_pExpandCB->IsChecked() ? SVX_ADJUST_BLOCK : SVX_ADJUST_LEFT;
1119 sal_Int32 nLBPos = m_pLastLineLB->GetSelectEntryPos();
1120 SvxAdjust eLastBlock = SVX_ADJUST_LEFT;
1122 if ( 1 == nLBPos )
1123 eLastBlock = SVX_ADJUST_CENTER;
1124 else if ( 2 == nLBPos )
1125 eLastBlock = SVX_ADJUST_BLOCK;
1127 bool bNothingWasChecked =
1128 !m_pLeft->GetSavedValue() && !m_pRight->GetSavedValue() &&
1129 !m_pCenter->GetSavedValue() && !m_pJustify->GetSavedValue();
1131 if ( !pOld || pOld->GetAdjust() != eAdjust ||
1132 pOld->GetOneWord() != eOneWord ||
1133 pOld->GetLastBlock() != eLastBlock ||
1134 ( bChecked && bNothingWasChecked ) )
1136 bModified = true;
1137 SvxAdjustItem aAdj(
1138 static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) );
1139 aAdj.SetAdjust( eAdjust );
1140 aAdj.SetOneWord( eOneWord );
1141 aAdj.SetLastBlock( eLastBlock );
1142 rOutSet->Put( aAdj );
1145 if(m_pSnapToGridCB->IsValueChangedFromSaved())
1147 rOutSet->Put(SvxParaGridItem(m_pSnapToGridCB->IsChecked(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
1148 bModified = true;
1150 if(m_pVertAlignLB->IsValueChangedFromSaved())
1152 rOutSet->Put(SvxParaVertAlignItem(m_pVertAlignLB->GetSelectEntryPos(), GetWhich( SID_PARA_VERTALIGN )));
1153 bModified = true;
1156 if( m_pTextDirectionLB->IsVisible() )
1158 SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue();
1159 if( m_pTextDirectionLB->IsValueChangedFromSaved() )
1161 rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
1162 bModified = true;
1166 return bModified;
1169 void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet )
1171 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1172 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1174 sal_Int32 nLBSelect = 0;
1175 if ( eItemState >= SfxItemState::DEFAULT )
1177 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>(rSet->Get( _nWhich ));
1179 switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
1181 case SVX_ADJUST_LEFT: m_pLeft->Check(); break;
1183 case SVX_ADJUST_RIGHT: m_pRight->Check(); break;
1185 case SVX_ADJUST_CENTER: m_pCenter->Check(); break;
1187 case SVX_ADJUST_BLOCK: m_pJustify->Check(); break;
1188 default: ; //prevent warning
1190 bool bEnable = m_pJustify->IsChecked();
1191 m_pLastLineFT->Enable(bEnable);
1192 m_pLastLineLB->Enable(bEnable);
1194 switch(rAdj.GetLastBlock())
1196 case SVX_ADJUST_LEFT: nLBSelect = 0; break;
1198 case SVX_ADJUST_CENTER: nLBSelect = 1; break;
1200 case SVX_ADJUST_BLOCK: nLBSelect = 2; break;
1201 default: ; //prevent warning
1203 m_pExpandCB->Enable(bEnable && nLBSelect == 2);
1204 m_pExpandCB->Check(SVX_ADJUST_BLOCK == rAdj.GetOneWord());
1206 else
1208 m_pLeft->Check( false );
1209 m_pRight->Check( false );
1210 m_pCenter->Check( false );
1211 m_pJustify->Check( false );
1213 m_pLastLineLB->SelectEntryPos(nLBSelect);
1215 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
1216 if(nHtmlMode & HTMLMODE_ON)
1218 m_pLastLineLB->Hide();
1219 m_pLastLineFT->Hide();
1220 m_pExpandCB->Hide();
1221 if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
1222 m_pJustify->Disable();
1223 m_pSnapToGridCB->Show(false);
1225 _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
1226 eItemState = rSet->GetItemState( _nWhich );
1227 if ( eItemState >= SfxItemState::DEFAULT )
1229 const SvxParaGridItem& rSnap = static_cast<const SvxParaGridItem&>(rSet->Get( _nWhich ));
1230 m_pSnapToGridCB->Check(rSnap.GetValue());
1233 _nWhich = GetWhich( SID_PARA_VERTALIGN );
1234 eItemState = rSet->GetItemState( _nWhich );
1236 if ( eItemState >= SfxItemState::DEFAULT )
1238 m_pVertAlignFL->Show();
1240 const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich ));
1242 m_pVertAlignLB->SelectEntryPos(rAlign.GetValue());
1245 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
1246 //text direction
1247 if( SfxItemState::DEFAULT <= rSet->GetItemState( _nWhich ) )
1249 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet->Get( _nWhich ) );
1250 m_pTextDirectionLB->SelectEntryValue( (SvxFrameDirection)rFrameDirItem.GetValue() );
1251 m_pTextDirectionLB->SaveValue();
1254 m_pSnapToGridCB->SaveValue();
1255 m_pVertAlignLB->SaveValue();
1256 m_pLeft->SaveValue();
1257 m_pRight->SaveValue();
1258 m_pCenter->SaveValue();
1259 m_pJustify->SaveValue();
1260 m_pLastLineLB->SaveValue();
1261 m_pExpandCB->SaveValue();
1263 UpdateExample_Impl();
1266 IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl)
1268 bool bJustify = m_pJustify->IsChecked();
1269 m_pLastLineFT->Enable(bJustify);
1270 m_pLastLineLB->Enable(bJustify);
1271 bool bLastLineIsBlock = m_pLastLineLB->GetSelectEntryPos() == 2;
1272 m_pExpandCB->Enable(bJustify && bLastLineIsBlock);
1273 UpdateExample_Impl();
1274 return 0;
1277 IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl)
1279 //fdo#41350 only enable 'Expand last word' if last line is also justified
1280 bool bLastLineIsBlock = m_pLastLineLB->GetSelectEntryPos() == 2;
1281 m_pExpandCB->Enable(bLastLineIsBlock);
1282 UpdateExample_Impl();
1283 return 0;
1286 IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl)
1288 SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue();
1289 switch ( eDir )
1291 // check the default alignment for this text direction
1292 case FRMDIR_HORI_LEFT_TOP : m_pLeft->Check( true ); break;
1293 case FRMDIR_HORI_RIGHT_TOP : m_pRight->Check( true ); break;
1294 case FRMDIR_ENVIRONMENT : /* do nothing */ break;
1295 default:
1297 SAL_WARN( "cui.tabpages", "SvxParaAlignTabPage::TextDirectionHdl_Impl(): other directions not supported" );
1301 return 0;
1304 void SvxParaAlignTabPage::UpdateExample_Impl()
1306 if ( m_pLeft->IsChecked() )
1307 m_pExampleWin->SetAdjust( SVX_ADJUST_LEFT );
1308 else if ( m_pRight->IsChecked() )
1309 m_pExampleWin->SetAdjust( SVX_ADJUST_RIGHT );
1310 else if ( m_pCenter->IsChecked() )
1311 m_pExampleWin->SetAdjust( SVX_ADJUST_CENTER );
1312 else if ( m_pJustify->IsChecked() )
1314 m_pExampleWin->SetAdjust( SVX_ADJUST_BLOCK );
1315 SvxAdjust eLastBlock = SVX_ADJUST_LEFT;
1316 sal_Int32 nLBPos = m_pLastLineLB->GetSelectEntryPos();
1317 if(nLBPos == 1)
1318 eLastBlock = SVX_ADJUST_CENTER;
1319 else if(nLBPos == 2)
1320 eLastBlock = SVX_ADJUST_BLOCK;
1321 m_pExampleWin->SetLastLine( eLastBlock );
1324 m_pExampleWin->Invalidate();
1327 void SvxParaAlignTabPage::EnableJustifyExt()
1329 m_pLastLineFT->Show();
1330 m_pLastLineLB->Show();
1331 m_pExpandCB->Show();
1332 SvtLanguageOptions aCJKOptions;
1333 if(aCJKOptions.IsAsianTypographyEnabled())
1334 m_pSnapToGridCB->Show();
1338 void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet)
1340 SFX_ITEMSET_ARG (&aSet,pBoolItem,SfxBoolItem,SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,false);
1341 if (pBoolItem)
1342 if(pBoolItem->GetValue())
1343 EnableJustifyExt();
1346 VclPtr<SfxTabPage> SvxExtParagraphTabPage::Create( vcl::Window* pParent,
1347 const SfxItemSet* rSet )
1349 return VclPtr<SvxExtParagraphTabPage>::Create( pParent, *rSet );
1352 bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
1354 bool bModified = false;
1355 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1356 const TriState eHyphenState = m_pHyphenBox->GetState();
1357 const SfxPoolItem* pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_HYPHENZONE );
1359 if ( m_pHyphenBox->IsValueChangedFromSaved() ||
1360 m_pExtHyphenBeforeBox->IsValueModified() ||
1361 m_pExtHyphenAfterBox->IsValueModified() ||
1362 m_pMaxHyphenEdit->IsValueModified() )
1364 SvxHyphenZoneItem aHyphen(
1365 static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) );
1366 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1368 if ( eHyphenState == TRISTATE_TRUE )
1370 aHyphen.GetMinLead() = (sal_uInt8)m_pExtHyphenBeforeBox->GetValue();
1371 aHyphen.GetMinTrail() = (sal_uInt8)m_pExtHyphenAfterBox->GetValue();
1373 aHyphen.GetMaxHyphens() = (sal_uInt8)m_pMaxHyphenEdit->GetValue();
1375 if ( !pOld ||
1376 !( *static_cast<const SvxHyphenZoneItem*>(pOld) == aHyphen ) ||
1377 m_pHyphenBox->IsValueChangedFromSaved())
1379 rOutSet->Put( aHyphen );
1380 bModified = true;
1384 if (m_pPagenumEdit->IsEnabled() && m_pPagenumEdit->IsValueModified())
1386 SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM,
1387 (sal_uInt16)m_pPagenumEdit->GetValue() );
1389 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
1391 if ( !pOld || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != aPageNum.GetValue() )
1393 rOutSet->Put( aPageNum );
1394 bModified = true;
1398 // pagebreak
1400 TriState eState = m_pApplyCollBtn->GetState();
1401 bool bIsPageModel = false;
1403 _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1404 OUString sPage;
1405 if ( m_pApplyCollBtn->IsValueChangedFromSaved() ||
1406 ( TRISTATE_TRUE == eState &&
1407 m_pApplyCollBox->IsValueChangedFromSaved() ) )
1409 if ( eState == TRISTATE_TRUE )
1411 sPage = m_pApplyCollBox->GetSelectEntry();
1412 bIsPageModel = !sPage.isEmpty();
1414 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_MODEL );
1416 if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage )
1418 rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) );
1419 bModified = true;
1421 else
1422 bIsPageModel = false;
1424 else if(TRISTATE_TRUE == eState && m_pApplyCollBtn->IsEnabled())
1425 bIsPageModel = true;
1426 else
1427 rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) );
1429 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1431 if ( bIsPageModel )
1432 // if PageModel is turned on, always turn off PageBreak
1433 rOutSet->Put( SvxFormatBreakItem( SVX_BREAK_NONE, _nWhich ) );
1434 else
1436 eState = m_pPageBreakBox->GetState();
1437 SfxItemState eModelState = GetItemSet().GetItemState(SID_ATTR_PARA_MODEL, false);
1439 if ( (eModelState == SfxItemState::SET && TRISTATE_TRUE == m_pPageBreakBox->GetState()) ||
1440 m_pPageBreakBox->IsValueChangedFromSaved() ||
1441 m_pBreakTypeLB->IsValueChangedFromSaved() ||
1442 m_pBreakPositionLB->IsValueChangedFromSaved() )
1444 const SvxFormatBreakItem rOldBreak(
1445 static_cast<const SvxFormatBreakItem&>(GetItemSet().Get( _nWhich )));
1446 SvxFormatBreakItem aBreak(rOldBreak.GetBreak(), rOldBreak.Which());
1448 switch ( eState )
1450 case TRISTATE_TRUE:
1452 bool bBefore = m_pBreakPositionLB->GetSelectEntryPos() == 0;
1454 if ( m_pBreakTypeLB->GetSelectEntryPos() == 0 )
1456 if ( bBefore )
1457 aBreak.SetValue( SVX_BREAK_PAGE_BEFORE );
1458 else
1459 aBreak.SetValue( SVX_BREAK_PAGE_AFTER );
1461 else
1463 if ( bBefore )
1464 aBreak.SetValue( SVX_BREAK_COLUMN_BEFORE );
1465 else
1466 aBreak.SetValue( SVX_BREAK_COLUMN_AFTER );
1468 break;
1471 case TRISTATE_FALSE:
1472 aBreak.SetValue( SVX_BREAK_NONE );
1473 break;
1474 default: ; //prevent warning
1476 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGEBREAK );
1478 if ( eState != m_pPageBreakBox->GetSavedValue() ||
1479 !pOld || !( *static_cast<const SvxFormatBreakItem*>(pOld) == aBreak ) )
1481 bModified = true;
1482 rOutSet->Put( aBreak );
1487 // paragraph split
1488 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1489 eState = m_pKeepTogetherBox->GetState();
1491 if ( m_pKeepTogetherBox->IsValueChangedFromSaved() )
1493 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_SPLIT );
1495 if ( !pOld || static_cast<const SvxFormatSplitItem*>(pOld)->GetValue() !=
1496 ( eState == TRISTATE_FALSE ) )
1498 rOutSet->Put( SvxFormatSplitItem( eState == TRISTATE_FALSE, _nWhich ) );
1499 bModified = true;
1503 // keep paragraphs
1504 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1505 eState = m_pKeepParaBox->GetState();
1507 if ( m_pKeepParaBox->IsValueChangedFromSaved() )
1509 // if the status has changed, putting is necessary
1510 rOutSet->Put( SvxFormatKeepItem( eState == TRISTATE_TRUE, _nWhich ) );
1511 bModified = true;
1514 // widows and orphans
1515 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1516 eState = m_pWidowBox->GetState();
1518 if ( m_pWidowBox->IsValueChangedFromSaved() ||
1519 m_pWidowRowNo->IsValueModified() )
1521 SvxWidowsItem rItem( eState == TRISTATE_TRUE ?
1522 (sal_uInt8)m_pWidowRowNo->GetValue() : 0, _nWhich );
1523 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS );
1525 if ( m_pWidowBox->IsValueChangedFromSaved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) )
1527 rOutSet->Put( rItem );
1528 bModified = true;
1532 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1533 eState = m_pOrphanBox->GetState();
1535 if ( m_pOrphanBox->IsValueChangedFromSaved() ||
1536 m_pOrphanRowNo->IsValueModified() )
1538 SvxOrphansItem rItem( eState == TRISTATE_TRUE ?
1539 (sal_uInt8)m_pOrphanRowNo->GetValue() : 0, _nWhich );
1540 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS );
1542 if ( m_pOrphanBox->IsValueChangedFromSaved() ||
1543 !pOld ||
1544 !( *static_cast<const SvxOrphansItem*>(pOld) == rItem ) )
1546 rOutSet->Put( rItem );
1547 bModified = true;
1551 return bModified;
1554 void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
1556 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1557 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1559 bool bItemAvailable = eItemState >= SfxItemState::DEFAULT;
1560 bool bIsHyphen = false;
1561 if( !bHtmlMode && bItemAvailable )
1563 const SvxHyphenZoneItem& rHyphen =
1564 static_cast<const SvxHyphenZoneItem&>(rSet->Get( _nWhich ));
1565 m_pHyphenBox->EnableTriState( false );
1567 bIsHyphen = rHyphen.IsHyphen();
1568 m_pHyphenBox->SetState( bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE );
1570 m_pExtHyphenBeforeBox->SetValue( rHyphen.GetMinLead() );
1571 m_pExtHyphenAfterBox->SetValue( rHyphen.GetMinTrail() );
1572 m_pMaxHyphenEdit->SetValue( rHyphen.GetMaxHyphens() );
1574 else
1576 m_pHyphenBox->SetState( TRISTATE_INDET );
1578 bool bEnable = bItemAvailable && bIsHyphen;
1579 m_pExtHyphenBeforeBox->Enable(bEnable);
1580 m_pExtHyphenAfterBox->Enable(bEnable);
1581 m_pBeforeText->Enable(bEnable);
1582 m_pAfterText->Enable(bEnable);
1583 m_pMaxHyphenLabel->Enable(bEnable);
1584 m_pMaxHyphenEdit->Enable(bEnable);
1586 _nWhich = GetWhich( SID_ATTR_PARA_PAGENUM );
1588 if (rSet->GetItemState(_nWhich) >= SfxItemState::SET)
1590 const sal_uInt16 nPageNum =
1591 static_cast<const SfxUInt16Item&>(rSet->Get( _nWhich ) ).GetValue();
1592 m_pPagenumEdit->SetValue( nPageNum );
1595 if ( bPageBreak )
1597 // first handle PageModel
1598 _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1599 bool bIsPageModel = false;
1600 eItemState = rSet->GetItemState( _nWhich );
1602 if ( eItemState >= SfxItemState::SET )
1604 m_pApplyCollBtn->EnableTriState( false );
1606 const SvxPageModelItem& rModel =
1607 static_cast<const SvxPageModelItem&>(rSet->Get( _nWhich ));
1608 OUString aStr( rModel.GetValue() );
1610 if ( !aStr.isEmpty() &&
1611 m_pApplyCollBox->GetEntryPos( aStr ) != LISTBOX_ENTRY_NOTFOUND )
1613 m_pApplyCollBox->SelectEntry( aStr );
1614 m_pApplyCollBtn->SetState( TRISTATE_TRUE );
1615 bIsPageModel = true;
1617 m_pPageBreakBox->Enable();
1618 m_pPageBreakBox->EnableTriState( false );
1619 m_pBreakTypeFT->Enable();
1620 m_pBreakTypeLB->Enable();
1621 m_pBreakPositionFT->Enable();
1622 m_pBreakPositionLB->Enable();
1623 m_pApplyCollBtn->Enable();
1624 m_pPageBreakBox->SetState( TRISTATE_TRUE );
1626 //select page break
1627 m_pBreakTypeLB->SelectEntryPos(0);
1628 //select break before
1629 m_pBreakPositionLB->SelectEntryPos(0);
1631 else
1633 m_pApplyCollBox->SetNoSelection();
1634 m_pApplyCollBtn->SetState( TRISTATE_FALSE );
1637 else if ( SfxItemState::DONTCARE == eItemState )
1639 m_pApplyCollBtn->EnableTriState( true );
1640 m_pApplyCollBtn->SetState( TRISTATE_INDET );
1641 m_pApplyCollBox->SetNoSelection();
1643 else
1645 m_pApplyCollBtn->Enable(false);
1646 m_pApplyCollBox->Enable(false);
1647 m_pPagenumEdit->Enable(false);
1648 m_pPagenumText->Enable(false);
1651 if ( !bIsPageModel )
1653 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1654 eItemState = rSet->GetItemState( _nWhich );
1656 if ( eItemState >= SfxItemState::DEFAULT )
1658 const SvxFormatBreakItem& rPageBreak =
1659 static_cast<const SvxFormatBreakItem&>(rSet->Get( _nWhich ));
1661 SvxBreak eBreak = (SvxBreak)rPageBreak.GetValue();
1663 // PageBreak not via CTRL-RETURN,
1664 // then CheckBox can be freed
1665 m_pPageBreakBox->Enable();
1666 m_pPageBreakBox->EnableTriState( false );
1667 m_pBreakTypeFT->Enable();
1668 m_pBreakTypeLB->Enable();
1669 m_pBreakPositionFT->Enable();
1670 m_pBreakPositionLB->Enable();
1672 m_pPageBreakBox->SetState( TRISTATE_TRUE );
1674 bool _bEnable = eBreak != SVX_BREAK_NONE &&
1675 eBreak != SVX_BREAK_COLUMN_BEFORE &&
1676 eBreak != SVX_BREAK_COLUMN_AFTER;
1677 m_pApplyCollBtn->Enable(_bEnable);
1678 if(!_bEnable)
1680 m_pApplyCollBox->Enable(_bEnable);
1681 m_pPagenumEdit->Enable(_bEnable);
1684 if ( eBreak == SVX_BREAK_NONE )
1685 m_pPageBreakBox->SetState( TRISTATE_FALSE );
1687 sal_Int32 nType = 0; // selection position in break type ListBox : Page
1688 sal_Int32 nPosition = 0; // selection position in break position ListBox : Before
1689 switch ( eBreak )
1691 case SVX_BREAK_PAGE_BEFORE:
1692 break;
1693 case SVX_BREAK_PAGE_AFTER:
1694 nPosition = 1;
1695 break;
1696 case SVX_BREAK_COLUMN_BEFORE:
1697 nType = 1;
1698 break;
1699 case SVX_BREAK_COLUMN_AFTER:
1700 nType = 1;
1701 nPosition = 1;
1702 break;
1703 default: ;//prevent warning
1705 m_pBreakTypeLB->SelectEntryPos(nType);
1706 m_pBreakPositionLB->SelectEntryPos(nPosition);
1708 else if ( SfxItemState::DONTCARE == eItemState )
1709 m_pPageBreakBox->SetState( TRISTATE_INDET );
1710 else
1712 m_pPageBreakBox->Enable(false);
1713 m_pBreakTypeFT->Enable(false);
1714 m_pBreakTypeLB->Enable(false);
1715 m_pBreakPositionFT->Enable(false);
1716 m_pBreakPositionLB->Enable(false);
1720 PageBreakPosHdl_Impl( m_pBreakPositionLB );
1721 PageBreakHdl_Impl( m_pPageBreakBox );
1724 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1725 eItemState = rSet->GetItemState( _nWhich );
1727 if ( eItemState >= SfxItemState::DEFAULT )
1729 m_pKeepParaBox->EnableTriState( false );
1730 const SvxFormatKeepItem& rKeep =
1731 static_cast<const SvxFormatKeepItem&>(rSet->Get( _nWhich ));
1733 if ( rKeep.GetValue() )
1734 m_pKeepParaBox->SetState( TRISTATE_TRUE );
1735 else
1736 m_pKeepParaBox->SetState( TRISTATE_FALSE );
1738 else if ( SfxItemState::DONTCARE == eItemState )
1739 m_pKeepParaBox->SetState( TRISTATE_INDET );
1740 else
1741 m_pKeepParaBox->Enable(false);
1743 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1744 eItemState = rSet->GetItemState( _nWhich );
1746 if ( eItemState >= SfxItemState::DEFAULT )
1748 const SvxFormatSplitItem& rSplit =
1749 static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich ));
1750 m_pKeepTogetherBox->EnableTriState( false );
1752 if ( !rSplit.GetValue() )
1753 m_pKeepTogetherBox->SetState( TRISTATE_TRUE );
1754 else
1756 m_pKeepTogetherBox->SetState( TRISTATE_FALSE );
1758 // widows and orphans
1759 m_pWidowBox->Enable();
1760 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1761 SfxItemState eTmpState = rSet->GetItemState( _nWhich );
1763 if ( eTmpState >= SfxItemState::DEFAULT )
1765 const SvxWidowsItem& rWidow =
1766 static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich ));
1767 m_pWidowBox->EnableTriState( false );
1768 const sal_uInt16 nLines = rWidow.GetValue();
1770 bool _bEnable = nLines > 0;
1771 m_pWidowRowNo->SetValue( m_pWidowRowNo->Normalize( nLines ) );
1772 m_pWidowBox->SetState( _bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
1773 m_pWidowRowNo->Enable(_bEnable);
1774 //m_pWidowRowLabel->Enable(_bEnable);
1777 else if ( SfxItemState::DONTCARE == eTmpState )
1778 m_pWidowBox->SetState( TRISTATE_INDET );
1779 else
1780 m_pWidowBox->Enable(false);
1782 m_pOrphanBox->Enable();
1783 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1784 eTmpState = rSet->GetItemState( _nWhich );
1786 if ( eTmpState >= SfxItemState::DEFAULT )
1788 const SvxOrphansItem& rOrphan =
1789 static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich ));
1790 const sal_uInt16 nLines = rOrphan.GetValue();
1791 m_pOrphanBox->EnableTriState( false );
1793 bool _bEnable = nLines > 0;
1794 m_pOrphanBox->SetState( _bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
1795 m_pOrphanRowNo->SetValue( m_pOrphanRowNo->Normalize( nLines ) );
1796 m_pOrphanRowNo->Enable(_bEnable);
1797 m_pOrphanRowLabel->Enable(_bEnable);
1800 else if ( SfxItemState::DONTCARE == eTmpState )
1801 m_pOrphanBox->SetState( TRISTATE_INDET );
1802 else
1803 m_pOrphanBox->Enable(false);
1806 else if ( SfxItemState::DONTCARE == eItemState )
1807 m_pKeepTogetherBox->SetState( TRISTATE_INDET );
1808 else
1809 m_pKeepTogetherBox->Enable(false);
1811 // so that everything is enabled correctly
1812 KeepTogetherHdl_Impl( 0 );
1813 WidowHdl_Impl( 0 );
1814 OrphanHdl_Impl( 0 );
1816 m_pHyphenBox->SaveValue();
1817 m_pExtHyphenBeforeBox->SaveValue();
1818 m_pExtHyphenAfterBox->SaveValue();
1819 m_pMaxHyphenEdit->SaveValue();
1820 m_pPageBreakBox->SaveValue();
1821 m_pBreakPositionLB->SaveValue();
1822 m_pBreakTypeLB->SaveValue();
1823 m_pApplyCollBtn->SaveValue();
1824 m_pApplyCollBox->SaveValue();
1825 m_pPagenumEdit->SaveValue();
1826 m_pKeepTogetherBox->SaveValue();
1827 m_pKeepParaBox->SaveValue();
1828 m_pWidowBox->SaveValue();
1829 m_pOrphanBox->SaveValue();
1832 SfxTabPage::sfxpg SvxExtParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
1834 if ( _pSet )
1835 FillItemSet( _pSet );
1836 return LEAVE_PAGE;
1839 void SvxExtParagraphTabPage::DisablePageBreak()
1841 bPageBreak = false;
1842 m_pPageBreakBox->Enable(false);
1843 m_pBreakTypeLB->RemoveEntry(0);
1844 m_pBreakPositionFT->Enable(false);
1845 m_pBreakPositionLB->Enable(false);
1846 m_pApplyCollBtn->Enable(false);
1847 m_pApplyCollBox->Enable(false);
1848 m_pPagenumEdit->Enable(false);
1851 SvxExtParagraphTabPage::SvxExtParagraphTabPage( vcl::Window* pParent, const SfxItemSet& rAttr ) :
1852 SfxTabPage( pParent, "TextFlowPage","cui/ui/textflowpage.ui", &rAttr ),
1854 bPageBreak ( true ),
1855 bHtmlMode ( false ),
1856 nStdPos ( 0 )
1858 // Hyphenation
1859 get(m_pHyphenBox,"checkAuto");
1860 get(m_pExtHyphenBeforeBox,"spinLineEnd");
1861 get(m_pExtHyphenAfterBox,"spinLineBegin");
1862 get(m_pMaxHyphenEdit,"spinMaxNum");
1863 get(m_pBeforeText,"labelLineBegin");
1864 get(m_pAfterText,"labelLineEnd");
1865 get(m_pMaxHyphenLabel,"labelMaxNum");
1867 //Page break
1868 get(m_pPageBreakBox,"checkInsert");
1869 get(m_pBreakTypeLB,"comboBreakType");
1870 get(m_pBreakPositionLB,"comboBreakPosition");
1871 get(m_pApplyCollBtn,"checkPageStyle");
1872 get(m_pApplyCollBox,"comboPageStyle");
1873 get(m_pPagenumEdit,"spinPageNumber");
1874 get(m_pBreakTypeFT,"labelType");
1875 get(m_pBreakPositionFT,"labelPosition");
1876 get(m_pPagenumText,"labelPageNum");
1878 // Options
1879 get(m_pKeepTogetherBox,"checkSplitPara");
1880 get(m_pKeepParaBox,"checkKeepPara");
1882 get(m_pOrphanBox,"checkOrphan");
1883 get(m_pOrphanRowNo,"spinOrphan");
1884 get(m_pOrphanRowLabel,"labelOrphan");
1886 get(m_pWidowBox,"checkWidow");
1887 get(m_pWidowRowNo,"spinWidow");
1888 get(m_pWidowRowLabel,"labelWidow");
1890 m_pApplyCollBox->SetAccessibleRelationLabeledBy(m_pApplyCollBtn);
1891 m_pApplyCollBox->SetAccessibleName(CUI_RES(STR_PAGE_STYLE));
1893 m_pOrphanRowNo->SetAccessibleRelationLabeledBy(m_pOrphanBox);
1894 m_pWidowRowNo->SetAccessibleRelationLabeledBy(m_pWidowBox);
1896 // this page needs ExchangeSupport
1897 SetExchangeSupport();
1899 m_pHyphenBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, HyphenClickHdl_Impl ) );
1900 m_pPageBreakBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, PageBreakHdl_Impl ) );
1901 m_pKeepTogetherBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, KeepTogetherHdl_Impl ) );
1902 m_pWidowBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, WidowHdl_Impl ) );
1903 m_pOrphanBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, OrphanHdl_Impl ) );
1904 m_pApplyCollBtn->SetClickHdl( LINK( this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl ) );
1905 m_pBreakTypeLB->SetSelectHdl( LINK( this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl ) );
1906 m_pBreakPositionLB->SetSelectHdl( LINK( this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl ) );
1908 SfxObjectShell* pSh = SfxObjectShell::Current();
1909 if ( pSh )
1911 SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
1912 pPool->SetSearchMask( SFX_STYLE_FAMILY_PAGE );
1913 SfxStyleSheetBase* pStyle = pPool->First();
1914 OUString aStdName;
1916 while( pStyle )
1918 if ( aStdName.isEmpty() )
1919 // first style == standard style
1920 aStdName = pStyle->GetName();
1921 m_pApplyCollBox->InsertEntry( pStyle->GetName() );
1922 pStyle = pPool->Next();
1924 nStdPos = m_pApplyCollBox->GetEntryPos( aStdName );
1927 sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr );
1928 if ( nHtmlMode & HTMLMODE_ON )
1930 bHtmlMode = true;
1931 m_pHyphenBox ->Enable(false);
1932 m_pBeforeText ->Enable(false);
1933 m_pExtHyphenBeforeBox ->Enable(false);
1934 m_pAfterText ->Enable(false);
1935 m_pExtHyphenAfterBox ->Enable(false);
1936 m_pMaxHyphenLabel ->Enable(false);
1937 m_pMaxHyphenEdit ->Enable(false);
1938 m_pPagenumText ->Enable(false);
1939 m_pPagenumEdit ->Enable(false);
1940 // no column break in HTML
1941 m_pBreakTypeLB->RemoveEntry(1);
1945 SvxExtParagraphTabPage::~SvxExtParagraphTabPage()
1947 disposeOnce();
1950 void SvxExtParagraphTabPage::dispose()
1952 m_pHyphenBox.clear();
1953 m_pBeforeText.clear();
1954 m_pExtHyphenBeforeBox.clear();
1955 m_pAfterText.clear();
1956 m_pExtHyphenAfterBox.clear();
1957 m_pMaxHyphenLabel.clear();
1958 m_pMaxHyphenEdit.clear();
1959 m_pPageBreakBox.clear();
1960 m_pBreakTypeFT.clear();
1961 m_pBreakTypeLB.clear();
1962 m_pBreakPositionFT.clear();
1963 m_pBreakPositionLB.clear();
1964 m_pApplyCollBtn.clear();
1965 m_pApplyCollBox.clear();
1966 m_pPagenumText.clear();
1967 m_pPagenumEdit.clear();
1968 m_pKeepTogetherBox.clear();
1969 m_pKeepParaBox.clear();
1970 m_pOrphanBox.clear();
1971 m_pOrphanRowNo.clear();
1972 m_pOrphanRowLabel.clear();
1973 m_pWidowBox.clear();
1974 m_pWidowRowNo.clear();
1975 m_pWidowRowLabel.clear();
1976 SfxTabPage::dispose();
1979 IMPL_LINK_NOARG(SvxExtParagraphTabPage, PageBreakHdl_Impl)
1981 switch ( m_pPageBreakBox->GetState() )
1983 case TRISTATE_TRUE:
1984 m_pBreakTypeFT->Enable();
1985 m_pBreakTypeLB->Enable();
1986 m_pBreakPositionFT->Enable();
1987 m_pBreakPositionLB->Enable();
1989 if ( 0 == m_pBreakTypeLB->GetSelectEntryPos()&&
1990 0 == m_pBreakPositionLB->GetSelectEntryPos() )
1992 m_pApplyCollBtn->Enable();
1994 bool bEnable = TRISTATE_TRUE == m_pApplyCollBtn->GetState() &&
1995 m_pApplyCollBox->GetEntryCount();
1996 m_pApplyCollBox->Enable(bEnable);
1997 if(!bHtmlMode)
1999 m_pPagenumText->Enable(bEnable);
2000 m_pPagenumEdit->Enable(bEnable);
2003 break;
2005 case TRISTATE_FALSE:
2006 case TRISTATE_INDET:
2007 m_pApplyCollBtn->SetState( TRISTATE_FALSE );
2008 m_pApplyCollBtn->Enable(false);
2009 m_pApplyCollBox->Enable(false);
2010 m_pPagenumText->Enable(false);
2011 m_pPagenumEdit->Enable(false);
2012 m_pBreakTypeFT->Enable(false);
2013 m_pBreakTypeLB->Enable(false);
2014 m_pBreakPositionFT->Enable(false);
2015 m_pBreakPositionLB->Enable(false);
2016 break;
2018 return 0;
2021 IMPL_LINK_NOARG(SvxExtParagraphTabPage, KeepTogetherHdl_Impl)
2023 bool bEnable = m_pKeepTogetherBox->GetState() == TRISTATE_FALSE;
2024 m_pWidowBox->Enable(bEnable);
2025 m_pOrphanBox->Enable(bEnable);
2027 return 0;
2030 IMPL_LINK_NOARG(SvxExtParagraphTabPage, WidowHdl_Impl)
2032 switch ( m_pWidowBox->GetState() )
2034 case TRISTATE_TRUE:
2035 m_pWidowRowNo->Enable();
2036 m_pWidowRowLabel->Enable();
2037 m_pKeepTogetherBox->Enable(false);
2038 break;
2040 case TRISTATE_FALSE:
2041 if ( m_pOrphanBox->GetState() == TRISTATE_FALSE )
2042 m_pKeepTogetherBox->Enable();
2044 // no break
2045 case TRISTATE_INDET:
2046 m_pWidowRowNo->Enable(false);
2047 m_pWidowRowLabel->Enable(false);
2048 break;
2050 return 0;
2053 IMPL_LINK_NOARG(SvxExtParagraphTabPage, OrphanHdl_Impl)
2055 switch( m_pOrphanBox->GetState() )
2057 case TRISTATE_TRUE:
2058 m_pOrphanRowNo->Enable();
2059 m_pOrphanRowLabel->Enable();
2060 m_pKeepTogetherBox->Enable(false);
2061 break;
2063 case TRISTATE_FALSE:
2064 if ( m_pWidowBox->GetState() == TRISTATE_FALSE )
2065 m_pKeepTogetherBox->Enable();
2067 // no break
2068 case TRISTATE_INDET:
2069 m_pOrphanRowNo->Enable(false);
2070 m_pOrphanRowLabel->Enable(false);
2071 break;
2073 return 0;
2076 IMPL_LINK_NOARG(SvxExtParagraphTabPage, HyphenClickHdl_Impl)
2079 bool bEnable = m_pHyphenBox->GetState() == TRISTATE_TRUE;
2080 m_pBeforeText->Enable(bEnable);
2081 m_pExtHyphenBeforeBox->Enable(bEnable);
2082 m_pAfterText->Enable(bEnable);
2083 m_pExtHyphenAfterBox->Enable(bEnable);
2084 m_pMaxHyphenLabel->Enable(bEnable);
2085 m_pMaxHyphenEdit->Enable(bEnable);
2086 m_pHyphenBox->SetState( bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2088 return 0;
2091 IMPL_LINK_NOARG(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl)
2093 bool bEnable = false;
2094 if ( m_pApplyCollBtn->GetState() == TRISTATE_TRUE &&
2095 m_pApplyCollBox->GetEntryCount() )
2097 bEnable = true;
2098 m_pApplyCollBox->SelectEntryPos( nStdPos );
2100 else
2102 m_pApplyCollBox->SetNoSelection();
2104 m_pApplyCollBox->Enable(bEnable);
2105 if(!bHtmlMode)
2107 m_pPagenumText->Enable(bEnable);
2108 m_pPagenumEdit->Enable(bEnable);
2110 return 0;
2113 IMPL_LINK( SvxExtParagraphTabPage, PageBreakPosHdl_Impl, ListBox *, pListBox )
2115 if ( 0 == pListBox->GetSelectEntryPos() )
2117 m_pApplyCollBtn->Enable();
2119 bool bEnable = m_pApplyCollBtn->GetState() == TRISTATE_TRUE &&
2120 m_pApplyCollBox->GetEntryCount();
2122 m_pApplyCollBox->Enable(bEnable);
2123 if(!bHtmlMode)
2125 m_pPagenumText->Enable(bEnable);
2126 m_pPagenumEdit->Enable(bEnable);
2129 else if ( 1 == pListBox->GetSelectEntryPos() )
2131 m_pApplyCollBtn->SetState( TRISTATE_FALSE );
2132 m_pApplyCollBtn->Enable(false);
2133 m_pApplyCollBox->Enable(false);
2134 m_pPagenumText->Enable(false);
2135 m_pPagenumEdit->Enable(false);
2137 return 0;
2140 IMPL_LINK( SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, ListBox *, pListBox )
2142 //column break or break break after
2143 sal_Int32 nBreakPos = m_pBreakPositionLB->GetSelectEntryPos();
2144 if ( pListBox->GetSelectEntryPos() == 1 || 1 == nBreakPos)
2146 m_pApplyCollBtn->SetState( TRISTATE_FALSE );
2147 m_pApplyCollBtn->Enable(false);
2148 m_pApplyCollBox->Enable(false);
2149 m_pPagenumText->Enable(false);
2150 m_pPagenumEdit->Enable(false);
2152 else
2153 PageBreakPosHdl_Impl( m_pBreakPositionLB );
2154 return 0;
2157 void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
2159 SFX_ITEMSET_ARG (&aSet,pDisablePageBreakItem,SfxBoolItem,SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,false);
2161 if (pDisablePageBreakItem)
2162 if ( pDisablePageBreakItem->GetValue())
2163 DisablePageBreak();
2166 SvxAsianTabPage::SvxAsianTabPage( vcl::Window* pParent, const SfxItemSet& rSet ) :
2167 SfxTabPage(pParent, "AsianTypography","cui/ui/asiantypography.ui", &rSet)
2170 get(m_pForbiddenRulesCB,"checkForbidList");
2171 get(m_pHangingPunctCB,"checkHangPunct");
2172 get(m_pScriptSpaceCB,"checkApplySpacing");
2174 Link<> aLink = LINK( this, SvxAsianTabPage, ClickHdl_Impl );
2175 m_pHangingPunctCB->SetClickHdl( aLink );
2176 m_pScriptSpaceCB->SetClickHdl( aLink );
2177 m_pForbiddenRulesCB->SetClickHdl( aLink );
2181 SvxAsianTabPage::~SvxAsianTabPage()
2183 disposeOnce();
2186 void SvxAsianTabPage::dispose()
2188 m_pForbiddenRulesCB.clear();
2189 m_pHangingPunctCB.clear();
2190 m_pScriptSpaceCB.clear();
2191 SfxTabPage::dispose();
2194 VclPtr<SfxTabPage> SvxAsianTabPage::Create( vcl::Window* pParent, const SfxItemSet* rSet )
2196 return VclPtr<SvxAsianTabPage>::Create(pParent, *rSet);
2199 const sal_uInt16* SvxAsianTabPage::GetRanges()
2201 static const sal_uInt16 pRanges[] =
2203 SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES,
2206 return pRanges;
2209 bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet )
2211 bool bRet = false;
2212 SfxItemPool* pPool = rSet->GetPool();
2213 if (m_pScriptSpaceCB->IsEnabled() && m_pScriptSpaceCB->IsValueChangedFromSaved())
2215 boost::scoped_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2216 pPool->GetWhich(SID_ATTR_PARA_SCRIPTSPACE)).Clone()));
2217 pNewItem->SetValue(m_pScriptSpaceCB->IsChecked());
2218 rSet->Put(*pNewItem);
2219 bRet = true;
2221 if (m_pHangingPunctCB->IsEnabled() && m_pHangingPunctCB->IsValueChangedFromSaved())
2223 boost::scoped_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2224 pPool->GetWhich(SID_ATTR_PARA_HANGPUNCTUATION)).Clone()));
2225 pNewItem->SetValue(m_pHangingPunctCB->IsChecked());
2226 rSet->Put(*pNewItem);
2227 bRet = true;
2229 if (m_pForbiddenRulesCB->IsEnabled() && m_pForbiddenRulesCB->IsValueChangedFromSaved())
2231 boost::scoped_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2232 pPool->GetWhich(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone()));
2233 pNewItem->SetValue(m_pForbiddenRulesCB->IsChecked());
2234 rSet->Put(*pNewItem);
2235 bRet = true;
2237 return bRet;
2240 static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, CheckBox& rBox)
2242 sal_uInt16 _nWhich = rSet.GetPool()->GetWhich(nSlotId);
2243 SfxItemState eState = rSet.GetItemState(_nWhich, true);
2244 if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED )
2245 rBox.Enable(false);
2246 else if(eState >= SfxItemState::DEFAULT)
2248 rBox.EnableTriState( false );
2249 rBox.Check(static_cast<const SfxBoolItem&>(rSet.Get(_nWhich)).GetValue());
2251 else
2252 rBox.SetState( TRISTATE_INDET );
2253 rBox.SaveValue();
2256 void SvxAsianTabPage::Reset( const SfxItemSet* rSet )
2258 lcl_SetBox(*rSet, SID_ATTR_PARA_FORBIDDEN_RULES, *m_pForbiddenRulesCB );
2259 lcl_SetBox(*rSet, SID_ATTR_PARA_HANGPUNCTUATION, *m_pHangingPunctCB );
2261 //character distance not yet available
2262 lcl_SetBox(*rSet, SID_ATTR_PARA_SCRIPTSPACE, *m_pScriptSpaceCB );
2265 IMPL_STATIC_LINK( SvxAsianTabPage, ClickHdl_Impl, CheckBox*, pBox )
2267 pBox->EnableTriState( false );
2268 return 0;
2271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */