bump product version to 6.3.0.0.beta1
[LibreOffice.git] / cui / source / tabpages / paragrph.cxx
blob9c9bca1963c88cb71b883036de1f505e8c72988d
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 <memory>
21 #include <osl/diagnose.h>
22 #include <svl/style.hxx>
23 #include <sfx2/app.hxx>
24 #include <sfx2/dialoghelper.hxx>
25 #include <sfx2/objsh.hxx>
26 #include <sfx2/module.hxx>
27 #include <vcl/mnemonic.hxx>
28 #include <svx/dialogs.hrc>
29 #include <svx/svxids.hrc>
31 #include <svl/languageoptions.hxx>
32 #include <svl/cjkoptions.hxx>
33 #include <editeng/pgrditem.hxx>
34 #include <svx/strings.hrc>
35 #include <svx/dialmgr.hxx>
36 #include <paragrph.hxx>
37 #include <editeng/frmdiritem.hxx>
38 #include <editeng/lspcitem.hxx>
39 #include <editeng/adjustitem.hxx>
40 #include <editeng/orphitem.hxx>
41 #include <editeng/widwitem.hxx>
42 #include <editeng/tstpitem.hxx>
43 #include <editeng/pmdlitem.hxx>
44 #include <editeng/spltitem.hxx>
45 #include <editeng/hyphenzoneitem.hxx>
46 #include <editeng/ulspitem.hxx>
47 #include <editeng/lrspitem.hxx>
48 #include <editeng/formatbreakitem.hxx>
49 #include <editeng/keepitem.hxx>
50 #include <svx/dlgutil.hxx>
51 #include <sfx2/htmlmode.hxx>
52 #include <editeng/paravertalignitem.hxx>
53 #include <svl/eitem.hxx>
54 #include <sfx2/request.hxx>
55 #include <svl/intitem.hxx>
57 const sal_uInt16 SvxStdParagraphTabPage::pStdRanges[] =
59 SID_ATTR_PARA_LINESPACE, // 10033
60 SID_ATTR_PARA_LINESPACE,
61 SID_ATTR_LRSPACE, // 10048 -
62 SID_ATTR_ULSPACE, // 10049
63 SID_ATTR_PARA_REGISTER, // 10413
64 SID_ATTR_PARA_REGISTER,
68 const sal_uInt16 SvxParaAlignTabPage::pAlignRanges[] =
70 SID_ATTR_PARA_ADJUST, // 10027
71 SID_ATTR_PARA_ADJUST,
75 const sal_uInt16 SvxExtParagraphTabPage::pExtRanges[] =
77 SID_ATTR_PARA_PAGEBREAK, // 10037 -
78 SID_ATTR_PARA_WIDOWS, // 10041
79 SID_ATTR_PARA_MODEL, // 10065 -
80 SID_ATTR_PARA_KEEP, // 10066
84 #define MAX_DURCH 5670 // 10 cm makes sense as maximum interline lead
85 // according to BP
86 #define FIX_DIST_DEF 283 // standard fix distance 0,5 cm
88 enum LineSpaceList
90 LLINESPACE_1 = 0,
91 LLINESPACE_115 = 1,
92 LLINESPACE_15 = 2,
93 LLINESPACE_2 = 3,
94 LLINESPACE_PROP = 4,
95 LLINESPACE_MIN = 5,
96 LLINESPACE_DURCH= 6,
97 LLINESPACE_FIX = 7
100 static void SetLineSpace_Impl( SvxLineSpacingItem&, int, long lValue = 0 );
102 void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
103 int eSpace, long lValue )
105 switch ( eSpace )
107 case LLINESPACE_1:
108 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
109 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
110 break;
112 case LLINESPACE_115:
113 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
114 rLineSpace.SetPropLineSpace( 115 );
115 break;
117 case LLINESPACE_15:
118 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
119 rLineSpace.SetPropLineSpace( 150 );
120 break;
122 case LLINESPACE_2:
123 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
124 rLineSpace.SetPropLineSpace( 200 );
125 break;
127 case LLINESPACE_PROP:
128 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
129 rLineSpace.SetPropLineSpace( static_cast<sal_uInt16>(lValue) );
130 break;
132 case LLINESPACE_MIN:
133 rLineSpace.SetLineHeight( static_cast<sal_uInt16>(lValue) );
134 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
135 break;
137 case LLINESPACE_DURCH:
138 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
139 rLineSpace.SetInterLineSpace( static_cast<sal_uInt16>(lValue) );
140 break;
142 case LLINESPACE_FIX:
143 rLineSpace.SetLineHeight(static_cast<sal_uInt16>(lValue));
144 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Fix );
145 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
146 break;
150 static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
152 sal_uInt16 nHtmlMode = 0;
153 const SfxPoolItem* pItem = nullptr;
154 SfxObjectShell* pShell;
155 if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem) ||
156 ( nullptr != (pShell = SfxObjectShell::Current()) &&
157 nullptr != (pItem = pShell->GetItem(SID_HTML_MODE))))
159 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
161 return nHtmlMode;
165 void SvxStdParagraphTabPage::ELRLoseFocus()
167 SfxItemPool* pPool = GetItemSet().GetPool();
168 DBG_ASSERT( pPool, "Where is the pool?" );
169 FieldUnit eUnit =
170 MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
172 sal_Int64 nL = m_xLeftIndent->denormalize(m_xLeftIndent->get_value(eUnit));
173 sal_Int64 nR = m_xRightIndent->denormalize(m_xRightIndent->get_value(eUnit));
174 OUString aTmp = m_xFLineIndent->get_text();
176 if (m_xLeftIndent->get_min(FieldUnit::NONE) < 0)
177 m_xFLineIndent->set_min(-99999, FieldUnit::MM);
178 else
179 m_xFLineIndent->set_min(m_xFLineIndent->normalize(-nL), eUnit);
181 // Check only for concrete width (Shell)
182 sal_Int64 nTmp = nWidth - nL - nR - MM50;
183 m_xFLineIndent->set_max(m_xFLineIndent->normalize(nTmp), eUnit);
185 if (aTmp.isEmpty())
186 m_xFLineIndent->set_text(OUString());
187 // maximum left right
188 aTmp = m_xLeftIndent->get_text();
189 nTmp = nWidth - nR - MM50;
190 m_xLeftIndent->set_max(m_xLeftIndent->normalize(nTmp), eUnit);
192 if ( aTmp.isEmpty() )
193 m_xLeftIndent->set_text(OUString());
194 aTmp = m_xRightIndent->get_text();
195 nTmp = nWidth - nL - MM50;
196 m_xRightIndent->set_max(m_xRightIndent->normalize(nTmp), eUnit);
198 if ( aTmp.isEmpty() )
199 m_xRightIndent->set_text(OUString());
201 UpdateExample_Impl();
204 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl, weld::MetricSpinButton&, void)
206 ELRLoseFocus();
209 VclPtr<SfxTabPage> SvxStdParagraphTabPage::Create( TabPageParent pParent, const SfxItemSet* rSet)
211 return VclPtr<SvxStdParagraphTabPage>::Create(pParent, *rSet);
214 bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
216 SfxItemState eState = SfxItemState::UNKNOWN;
217 const SfxPoolItem* pOld = nullptr;
218 SfxItemPool* pPool = rOutSet->GetPool();
219 DBG_ASSERT( pPool, "Where is the pool?" );
221 bool bModified = false;
222 sal_uInt16 nWhich;
223 int nPos = m_xLineDist->get_active();
225 if ( nPos != -1 &&
226 ( m_xLineDist->get_value_changed_from_saved() ||
227 m_xLineDistAtPercentBox->get_value_changed_from_saved() ||
228 m_xLineDistAtMetricBox->get_value_changed_from_saved() ) )
230 nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
231 MapUnit eUnit = pPool->GetMetric( nWhich );
232 SvxLineSpacingItem aSpacing(
233 static_cast<const SvxLineSpacingItem&>(GetItemSet().Get( nWhich )) );
235 switch ( nPos )
237 case LLINESPACE_1:
238 case LLINESPACE_115:
239 case LLINESPACE_15:
240 case LLINESPACE_2:
241 SetLineSpace_Impl( aSpacing, nPos );
242 break;
244 case LLINESPACE_PROP:
245 SetLineSpace_Impl( aSpacing, nPos,
246 static_cast<long>(m_xLineDistAtPercentBox->denormalize(
247 m_xLineDistAtPercentBox->get_value(FieldUnit::NONE) )) );
248 break;
250 case LLINESPACE_MIN:
251 case LLINESPACE_DURCH:
252 case LLINESPACE_FIX:
253 SetLineSpace_Impl( aSpacing, nPos,
254 GetCoreValue( *m_xLineDistAtMetricBox, eUnit ) );
255 break;
257 default:
258 OSL_FAIL( "unknown LineDist entry" );
259 break;
261 eState = GetItemSet().GetItemState( nWhich );
262 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_LINESPACE );
264 if ( !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) ||
265 SfxItemState::DONTCARE == eState )
267 rOutSet->Put( aSpacing );
268 bModified = true;
272 if ( m_xTopDist->get_value_changed_from_saved() || m_xBottomDist->get_value_changed_from_saved()
273 || m_xContextualCB->get_state_changed_from_saved())
275 nWhich = GetWhich( SID_ATTR_ULSPACE );
276 MapUnit eUnit = pPool->GetMetric( nWhich );
277 pOld = GetOldItem( *rOutSet, SID_ATTR_ULSPACE );
278 SvxULSpaceItem aMargin( nWhich );
280 if ( bRelativeMode )
282 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
284 const SvxULSpaceItem& rOldItem =
285 static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
287 if ( m_xTopDist->IsRelative() )
288 aMargin.SetUpper( rOldItem.GetUpper(),
289 static_cast<sal_uInt16>(m_xTopDist->get_value(FieldUnit::NONE)) );
290 else
291 aMargin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit)) );
293 if ( m_xBottomDist->IsRelative() )
294 aMargin.SetLower( rOldItem.GetLower(),
295 static_cast<sal_uInt16>(m_xBottomDist->get_value(FieldUnit::NONE)) );
296 else
297 aMargin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit)) );
300 else
302 aMargin.SetUpper(static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit)));
303 aMargin.SetLower(static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit)));
305 aMargin.SetContextValue(m_xContextualCB->get_active());
306 eState = GetItemSet().GetItemState( nWhich );
308 if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin ||
309 SfxItemState::DONTCARE == eState )
311 rOutSet->Put( aMargin );
312 bModified = true;
315 bool bNullTab = false;
317 if ( m_xLeftIndent->get_value_changed_from_saved() ||
318 m_xFLineIndent->get_value_changed_from_saved() ||
319 m_xRightIndent->get_value_changed_from_saved() ||
320 m_xAutoCB->get_state_changed_from_saved() )
322 nWhich = GetWhich( SID_ATTR_LRSPACE );
323 MapUnit eUnit = pPool->GetMetric( nWhich );
324 SvxLRSpaceItem aMargin( nWhich );
325 pOld = GetOldItem( *rOutSet, SID_ATTR_LRSPACE );
327 if ( bRelativeMode )
329 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
331 const SvxLRSpaceItem& rOldItem =
332 static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
334 if (m_xLeftIndent->IsRelative())
335 aMargin.SetTextLeft( rOldItem.GetTextLeft(),
336 static_cast<sal_uInt16>(m_xLeftIndent->get_value(FieldUnit::NONE)) );
337 else
338 aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit));
340 if ( m_xRightIndent->IsRelative() )
341 aMargin.SetRight( rOldItem.GetRight(),
342 static_cast<sal_uInt16>(m_xRightIndent->get_value(FieldUnit::NONE)) );
343 else
344 aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit));
346 if ( m_xFLineIndent->IsRelative() )
347 aMargin.SetTextFirstLineOfst( rOldItem.GetTextFirstLineOfst(),
348 static_cast<sal_uInt16>(m_xFLineIndent->get_value(FieldUnit::NONE)) );
349 else
350 aMargin.SetTextFirstLineOfst(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit)));
352 else
354 aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit));
355 aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit));
356 aMargin.SetTextFirstLineOfst(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit)));
358 aMargin.SetAutoFirst(m_xAutoCB->get_active());
359 if ( aMargin.GetTextFirstLineOfst() < 0 )
360 bNullTab = true;
361 eState = GetItemSet().GetItemState( nWhich );
363 if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin ||
364 SfxItemState::DONTCARE == eState )
366 rOutSet->Put( aMargin );
367 bModified = true;
371 if ( bNullTab )
373 MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
374 if ( MapUnit::Map100thMM != eUnit )
377 // negative first line indent -> set null default tabstob if applicable
378 sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
379 const SfxItemSet& rInSet = GetItemSet();
381 if ( rInSet.GetItemState( _nWhich ) >= SfxItemState::DEFAULT )
383 const SvxTabStopItem& rTabItem =
384 static_cast<const SvxTabStopItem&>(rInSet.Get( _nWhich ));
385 SvxTabStopItem aNullTab( rTabItem );
386 SvxTabStop aNull( 0, SvxTabAdjust::Default );
387 aNullTab.Insert( aNull );
388 rOutSet->Put( aNullTab );
392 if (m_xRegisterCB->get_visible())
394 const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(GetOldItem(
395 *rOutSet, SID_ATTR_PARA_REGISTER));
396 if (!pBoolItem)
397 return bModified;
398 std::unique_ptr<SfxBoolItem> pRegItem(static_cast<SfxBoolItem*>(pBoolItem->Clone()));
399 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
400 bool bSet = pRegItem->GetValue();
402 if (m_xRegisterCB->get_active() != bSet)
404 pRegItem->SetValue(!bSet);
405 rOutSet->Put(*pRegItem);
406 bModified = true;
408 else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) )
409 rOutSet->ClearItem(_nWhich);
412 return bModified;
415 void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet )
417 SfxItemPool* pPool = rSet->GetPool();
418 DBG_ASSERT( pPool, "Where is the pool?" );
420 // adjust metric
421 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
423 bool bApplyCharUnit = GetApplyCharUnit( *rSet );
425 SvtCJKOptions aCJKOptions;
426 if(aCJKOptions.IsAsianTypographyEnabled() && bApplyCharUnit )
427 eFUnit = FieldUnit::CHAR;
429 m_xLeftIndent->SetFieldUnit(eFUnit);
430 m_xRightIndent->SetFieldUnit(eFUnit);
431 m_xFLineIndent->SetFieldUnit(eFUnit);
432 if ( eFUnit == FieldUnit::CHAR )
434 m_xTopDist->SetFieldUnit(FieldUnit::LINE);
435 m_xBottomDist->SetFieldUnit(FieldUnit::LINE);
436 SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT);
438 else
440 m_xTopDist->SetFieldUnit(eFUnit);
441 m_xBottomDist->SetFieldUnit(eFUnit);
442 SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit);
445 sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
446 SfxItemState eItemState = rSet->GetItemState( _nWhich );
448 if ( eItemState >= SfxItemState::DEFAULT )
450 MapUnit eUnit = pPool->GetMetric( _nWhich );
452 if ( bRelativeMode )
454 const SvxLRSpaceItem& rOldItem =
455 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
457 if ( rOldItem.GetPropLeft() != 100 )
459 m_xLeftIndent->SetRelative( true );
460 m_xLeftIndent->set_value(rOldItem.GetPropLeft(), FieldUnit::NONE);
462 else
464 m_xLeftIndent->SetRelative(false);
465 m_xLeftIndent->SetFieldUnit(eFUnit);
466 m_xLeftIndent->SetMetricValue(rOldItem.GetTextLeft(), eUnit);
469 if ( rOldItem.GetPropRight() != 100 )
471 m_xRightIndent->SetRelative( true );
472 m_xRightIndent->set_value(rOldItem.GetPropRight(), FieldUnit::NONE);
474 else
476 m_xRightIndent->SetRelative(false);
477 m_xRightIndent->SetFieldUnit(eFUnit);
478 m_xRightIndent->SetMetricValue(rOldItem.GetRight(), eUnit);
481 if ( rOldItem.GetPropTextFirstLineOfst() != 100 )
483 m_xFLineIndent->SetRelative(true);
484 m_xFLineIndent->set_value(rOldItem.GetPropTextFirstLineOfst(), FieldUnit::NONE);
486 else
488 m_xFLineIndent->SetRelative(false);
489 m_xFLineIndent->set_min(-9999, FieldUnit::NONE);
490 m_xFLineIndent->SetFieldUnit(eFUnit);
491 m_xFLineIndent->SetMetricValue(rOldItem.GetTextFirstLineOfst(), eUnit);
493 m_xAutoCB->set_active(rOldItem.IsAutoFirst());
495 else
497 const SvxLRSpaceItem& rSpace =
498 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
500 m_xLeftIndent->SetMetricValue(rSpace.GetTextLeft(), eUnit);
501 m_xRightIndent->SetMetricValue(rSpace.GetRight(), eUnit);
502 m_xFLineIndent->SetMetricValue(rSpace.GetTextFirstLineOfst(), eUnit);
503 m_xAutoCB->set_active(rSpace.IsAutoFirst());
505 AutoHdl_Impl(*m_xAutoCB);
507 else
509 m_xLeftIndent->set_text(OUString());
510 m_xRightIndent->set_text(OUString());
511 m_xFLineIndent->set_text(OUString());
514 _nWhich = GetWhich( SID_ATTR_ULSPACE );
515 eItemState = rSet->GetItemState( _nWhich );
517 if ( eItemState >= SfxItemState::DEFAULT )
519 MapUnit eUnit = pPool->GetMetric( _nWhich );
521 const SvxULSpaceItem& rOldItem =
522 static_cast<const SvxULSpaceItem&>(rSet->Get( _nWhich ));
523 if ( bRelativeMode )
526 if ( rOldItem.GetPropUpper() != 100 )
528 m_xTopDist->SetRelative( true );
529 m_xTopDist->set_value(rOldItem.GetPropUpper(), FieldUnit::NONE);
531 else
533 m_xTopDist->SetRelative(false);
534 if (eFUnit == FieldUnit::CHAR)
535 m_xTopDist->SetFieldUnit(FieldUnit::LINE);
536 else
537 m_xTopDist->SetFieldUnit(eFUnit);
538 m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit);
541 if ( rOldItem.GetPropLower() != 100 )
543 m_xBottomDist->SetRelative( true );
544 m_xBottomDist->set_value(rOldItem.GetPropLower(), FieldUnit::NONE);
546 else
548 m_xBottomDist->SetRelative(false);
549 if (eFUnit == FieldUnit::CHAR)
550 m_xBottomDist->SetFieldUnit(FieldUnit::LINE);
551 else
552 m_xBottomDist->SetFieldUnit(eFUnit);
553 m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit);
556 else
558 m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit);
559 m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit);
561 m_xContextualCB->set_active(rOldItem.GetContext());
563 else
565 m_xTopDist->set_text(OUString());
566 m_xBottomDist->set_text(OUString());
569 _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
570 eItemState = rSet->GetItemState( _nWhich );
572 if ( eItemState >= SfxItemState::DEFAULT )
573 SetLineSpacing_Impl( static_cast<const SvxLineSpacingItem &>(rSet->Get( _nWhich )) );
574 else
575 m_xLineDist->set_active(-1);
577 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
578 eItemState = rSet->GetItemState( _nWhich );
580 if ( eItemState >= SfxItemState::DEFAULT )
581 m_xRegisterCB->set_active( static_cast<const SfxBoolItem &>(rSet->Get( _nWhich )).GetValue());
582 m_xRegisterCB->save_state();
583 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
584 if(nHtmlMode & HTMLMODE_ON)
586 m_xRegisterFL->hide();
587 m_xRegisterCB->hide();
588 m_xAutoCB->hide();
591 // this sets the min/max limits; do this _after_ setting the values,
592 // because for Impress the min of first-line indent depends on value of
593 // left-indent!
594 ELRLoseFocus();
595 ChangesApplied();
598 void SvxStdParagraphTabPage::ChangesApplied()
600 m_xLeftIndent->save_value();
601 m_xRightIndent->save_value();
602 m_xFLineIndent->save_value();
603 m_xLineDist->save_value();
604 m_xLineDistAtPercentBox->save_value();
605 m_xLineDistAtMetricBox->save_value();
606 m_xRegisterCB->save_state();
607 m_xTopDist->save_value();
608 m_xBottomDist->save_value();
609 m_xContextualCB->save_state();
610 m_xAutoCB->save_state();
613 void SvxStdParagraphTabPage::EnableRelativeMode()
615 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );
617 m_xLeftIndent->EnableRelativeMode( 0, 999 );
618 m_xFLineIndent->EnableRelativeMode( 0, 999 );
619 m_xRightIndent->EnableRelativeMode( 0, 999 );
620 m_xTopDist->EnableRelativeMode( 0, 999 );
621 m_xBottomDist->EnableRelativeMode( 0, 999 );
622 bRelativeMode = true;
625 void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet )
627 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
628 SfxItemState eItemState = rSet.GetItemState( _nWhich );
630 if ( eItemState >= SfxItemState::DEFAULT )
632 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>( rSet.Get( _nWhich ) );
633 SvxAdjust eAdjust = rAdj.GetAdjust();
634 if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block )
636 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
637 eItemState = rSet.GetItemState( _nWhich );
639 if ( eItemState >= SfxItemState::DEFAULT )
641 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet.Get( _nWhich ) );
642 SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue();
644 m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection );
646 if ( eAdjust == SvxAdjust::Block )
647 m_aExampleWin.SetLastLine( rAdj.GetLastBlock() );
650 else
652 m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right );
653 eAdjust = SvxAdjust::Left; //required for correct preview display
654 m_aExampleWin.SetLastLine( eAdjust );
656 m_aExampleWin.SetAdjust( eAdjust );
658 UpdateExample_Impl();
662 DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
664 ELRLoseFocus();
666 if ( _pSet )
667 FillItemSet( _pSet );
668 return DeactivateRC::LeavePage;
671 SvxStdParagraphTabPage::SvxStdParagraphTabPage(TabPageParent pParent, const SfxItemSet& rAttr)
672 : SfxTabPage(pParent, "cui/ui/paraindentspacing.ui", "ParaIndentSpacing", &rAttr)
673 , nWidth(11905 /*567 * 50*/)
674 , nMinFixDist(0)
675 , bRelativeMode(false)
676 , m_xLeftIndent(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_LEFTINDENT", FieldUnit::CM)))
677 , m_xRightLabel(m_xBuilder->weld_label("labelFT_RIGHTINDENT"))
678 , m_xRightIndent(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_RIGHTINDENT", FieldUnit::CM)))
679 , m_xFLineLabel(m_xBuilder->weld_label("labelFT_FLINEINDENT"))
680 , m_xFLineIndent(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_FLINEINDENT", FieldUnit::CM)))
681 , m_xAutoCB(m_xBuilder->weld_check_button("checkCB_AUTO"))
682 , m_xTopDist(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_TOPDIST", FieldUnit::CM)))
683 , m_xBottomDist(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_BOTTOMDIST", FieldUnit::CM)))
684 , m_xContextualCB(m_xBuilder->weld_check_button("checkCB_CONTEXTUALSPACING"))
685 , m_xLineDist(m_xBuilder->weld_combo_box("comboLB_LINEDIST"))
686 , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTPERCENT", FieldUnit::PERCENT))
687 , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTMETRIC", FieldUnit::CM))
688 , m_xLineDistAtLabel(m_xBuilder->weld_label("labelFT_LINEDIST"))
689 , m_xAbsDist(m_xBuilder->weld_label("labelST_LINEDIST_ABS"))
690 , m_xRegisterFL(m_xBuilder->weld_widget("frameFL_REGISTER"))
691 , m_xRegisterCB(m_xBuilder->weld_check_button("checkCB_REGISTER"))
692 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin))
694 sAbsDist = m_xAbsDist->get_label();
696 // this page needs ExchangeSupport
697 SetExchangeSupport();
699 m_xLineDistAtMetricBox->hide();
701 Init_Impl();
702 m_xFLineIndent->set_min(-9999, FieldUnit::NONE); // is set to 0 on default
705 SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
709 void SvxStdParagraphTabPage::EnableNegativeMode()
711 m_xLeftIndent->set_min(-9999, FieldUnit::NONE);
712 m_xRightIndent->set_min(-9999, FieldUnit::NONE);
713 m_xRightIndent->EnableNegativeMode();
714 m_xLeftIndent->EnableNegativeMode();
717 void SvxStdParagraphTabPage::SetLineSpacing_Impl
719 const SvxLineSpacingItem &rAttr
722 MapUnit eUnit = GetItemSet().GetPool()->GetMetric( rAttr.Which() );
724 switch( rAttr.GetLineSpaceRule() )
726 case SvxLineSpaceRule::Auto:
728 SvxInterLineSpaceRule eInter = rAttr.GetInterLineSpaceRule();
730 switch( eInter )
732 // Default single line spacing
733 case SvxInterLineSpaceRule::Off:
734 m_xLineDist->set_active( LLINESPACE_1 );
735 break;
737 // Default single line spacing
738 case SvxInterLineSpaceRule::Prop:
739 if ( 100 == rAttr.GetPropLineSpace() )
741 m_xLineDist->set_active( LLINESPACE_1 );
742 break;
744 // 1.15 line spacing
745 if ( 115 == rAttr.GetPropLineSpace() )
747 m_xLineDist->set_active( LLINESPACE_115 );
748 break;
750 // 1.5 line spacing
751 if ( 150 == rAttr.GetPropLineSpace() )
753 m_xLineDist->set_active( LLINESPACE_15 );
754 break;
756 // double line spacing
757 if ( 200 == rAttr.GetPropLineSpace() )
759 m_xLineDist->set_active( LLINESPACE_2 );
760 break;
762 // the set per cent value
763 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(rAttr.GetPropLineSpace()), FieldUnit::NONE);
764 m_xLineDist->set_active( LLINESPACE_PROP );
765 break;
767 case SvxInterLineSpaceRule::Fix:
768 SetMetricValue( *m_xLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
769 m_xLineDist->set_active( LLINESPACE_DURCH );
770 break;
771 default: ;//prevent warning
774 break;
775 case SvxLineSpaceRule::Fix:
776 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
777 m_xLineDist->set_active( LLINESPACE_FIX );
778 break;
780 case SvxLineSpaceRule::Min:
781 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
782 m_xLineDist->set_active( LLINESPACE_MIN );
783 break;
784 default: ;//prevent warning
786 LineDistHdl_Impl( *m_xLineDist );
789 IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void)
791 switch (rBox.get_active())
793 case LLINESPACE_1:
794 case LLINESPACE_115:
795 case LLINESPACE_15:
796 case LLINESPACE_2:
797 m_xLineDistAtLabel->set_sensitive(false);
798 m_xLineDistAtPercentBox->set_sensitive(false);
799 m_xLineDistAtPercentBox->set_text(OUString());
800 m_xLineDistAtMetricBox->set_sensitive(false);
801 m_xLineDistAtMetricBox->set_text(OUString());
802 break;
804 case LLINESPACE_DURCH:
805 // setting a sensible default?
806 // limit MS min(10, aPageSize)
807 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
809 if (m_xLineDistAtMetricBox->get_text().isEmpty())
810 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE);
811 m_xLineDistAtPercentBox->hide();
812 m_xLineDistAtMetricBox->show();
813 m_xLineDistAtMetricBox->set_sensitive(true);
814 m_xLineDistAtLabel->set_sensitive(true);
815 break;
817 case LLINESPACE_MIN:
818 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
820 if (m_xLineDistAtMetricBox->get_text().isEmpty())
821 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP);
822 m_xLineDistAtPercentBox->hide();
823 m_xLineDistAtMetricBox->show();
824 m_xLineDistAtMetricBox->set_sensitive(true);
825 m_xLineDistAtLabel->set_sensitive(true);
826 break;
828 case LLINESPACE_PROP:
830 if (m_xLineDistAtPercentBox->get_text().isEmpty())
831 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP);
832 m_xLineDistAtMetricBox->hide();
833 m_xLineDistAtPercentBox->show();
834 m_xLineDistAtPercentBox->set_sensitive(true);
835 m_xLineDistAtLabel->set_sensitive(true);
836 break;
837 case LLINESPACE_FIX:
839 auto nTemp = m_xLineDistAtMetricBox->get_value(FieldUnit::NONE);
840 m_xLineDistAtMetricBox->set_min(m_xLineDistAtMetricBox->normalize(nMinFixDist), FieldUnit::TWIP);
842 // if the value has been changed at SetMin,
843 // it is time for the default
844 if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp)
845 SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer
846 m_xLineDistAtPercentBox->hide();
847 m_xLineDistAtMetricBox->show();
848 m_xLineDistAtMetricBox->set_sensitive(true);
849 m_xLineDistAtLabel->set_sensitive(true);
851 break;
853 UpdateExample_Impl();
856 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ModifyHdl_Impl, weld::MetricSpinButton&, void)
858 UpdateExample_Impl();
861 void SvxStdParagraphTabPage::Init_Impl()
863 m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl));
865 Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl);
866 m_xFLineIndent->connect_value_changed(aLink2);
867 m_xLeftIndent->connect_value_changed(aLink2);
868 m_xRightIndent->connect_value_changed(aLink2);
870 Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl);
871 m_xTopDist->connect_value_changed(aLink);
872 m_xBottomDist->connect_value_changed(aLink);
874 m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl));
875 SfxItemPool* pPool = GetItemSet().GetPool();
876 DBG_ASSERT( pPool, "Where is the pool?" );
877 FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
879 m_xTopDist->set_max( m_xTopDist->normalize( MAX_DURCH ), eUnit );
880 m_xBottomDist->set_max( m_xBottomDist->normalize( MAX_DURCH ), eUnit );
881 m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit );
884 void SvxStdParagraphTabPage::UpdateExample_Impl()
886 m_aExampleWin.SetFirstLineOfst( static_cast<short>(m_xFLineIndent->denormalize( m_xFLineIndent->get_value( FieldUnit::TWIP ) )) );
887 m_aExampleWin.SetLeftMargin( static_cast<long>(m_xLeftIndent->denormalize( m_xLeftIndent->get_value( FieldUnit::TWIP ) ) ) );
888 m_aExampleWin.SetRightMargin( static_cast<long>(m_xRightIndent->denormalize( m_xRightIndent->get_value( FieldUnit::TWIP ) ) ) );
889 m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->denormalize( m_xTopDist->get_value( FieldUnit::TWIP ) )) );
890 m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->denormalize( m_xBottomDist->get_value( FieldUnit::TWIP ) )) );
892 int nPos = m_xLineDist->get_active();
894 switch ( nPos )
896 case LLINESPACE_1:
897 case LLINESPACE_115:
898 case LLINESPACE_15:
899 case LLINESPACE_2:
900 case LLINESPACE_PROP:
901 case LLINESPACE_MIN:
902 case LLINESPACE_DURCH:
903 case LLINESPACE_FIX:
904 m_aExampleWin.SetLineSpace( static_cast<SvxPrevLineSpace>(nPos) );
905 break;
907 m_aExampleWin.Invalidate();
910 void SvxStdParagraphTabPage::EnableRegisterMode()
912 m_xRegisterCB->show();
913 m_xRegisterFL->show();
916 void SvxStdParagraphTabPage::EnableContextualMode()
918 m_xContextualCB->show();
921 IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::ToggleButton&, rBox, void)
923 bool bEnable = !rBox.get_active();
924 m_xFLineLabel->set_sensitive(bEnable);
925 m_xFLineIndent->set_sensitive(bEnable);
928 void SvxStdParagraphTabPage::EnableAutoFirstLine()
930 m_xAutoCB->show();
933 void SvxStdParagraphTabPage::EnableAbsLineDist(long nMinTwip)
935 m_xLineDist->append_text(sAbsDist);
936 nMinFixDist = nMinTwip;
939 void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
942 /* different bit represent call to different method of SvxStdParagraphTabPage
943 0x0001 --->EnableRelativeMode()
944 0x0002 --->EnableRegisterMode()
945 0x0004 --->EnableAutoFirstLine()
946 0x0008 --->EnableNegativeMode()
947 0x0010 --->EnableContextualMode()
949 const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false);
950 const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false);
951 const SfxUInt32Item* pLineDistItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, false);
953 if (pPageWidthItem)
954 nWidth = pPageWidthItem->GetValue();
956 if (pFlagSetItem )
958 if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
959 EnableRelativeMode();
961 if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
962 EnableRegisterMode();
964 if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
965 EnableAutoFirstLine();
968 if(pLineDistItem)
969 EnableAbsLineDist(pLineDistItem->GetValue());
971 if (pFlagSetItem)
973 if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
974 EnableNegativeMode();
976 if (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
977 EnableContextualMode();
981 #define LASTLINEPOS_DEFAULT 0
982 #define LASTLINEPOS_LEFT 1
984 #define LASTLINECOUNT_OLD 3
985 #define LASTLINECOUNT_NEW 4
987 SvxParaAlignTabPage::SvxParaAlignTabPage(TabPageParent pParent, const SfxItemSet& rSet)
988 : SfxTabPage(pParent, "cui/ui/paragalignpage.ui", "ParaAlignPage", &rSet)
989 , m_xLeft(m_xBuilder->weld_radio_button("radioBTN_LEFTALIGN"))
990 , m_xRight(m_xBuilder->weld_radio_button("radioBTN_RIGHTALIGN"))
991 , m_xCenter(m_xBuilder->weld_radio_button("radioBTN_CENTERALIGN"))
992 , m_xJustify(m_xBuilder->weld_radio_button("radioBTN_JUSTIFYALIGN"))
993 , m_xLeftBottom(m_xBuilder->weld_label("labelST_LEFTALIGN_ASIAN"))
994 , m_xRightTop(m_xBuilder->weld_label("labelST_RIGHTALIGN_ASIAN"))
995 , m_xLastLineFT(m_xBuilder->weld_label("labelLB_LASTLINE"))
996 , m_xLastLineLB(m_xBuilder->weld_combo_box("comboLB_LASTLINE"))
997 , m_xExpandCB(m_xBuilder->weld_check_button("checkCB_EXPAND"))
998 , m_xSnapToGridCB(m_xBuilder->weld_check_button("checkCB_SNAP"))
999 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin))
1000 , m_xVertAlignFL(m_xBuilder->weld_widget("frameFL_VERTALIGN"))
1001 , m_xVertAlignLB(m_xBuilder->weld_combo_box("comboLB_VERTALIGN"))
1002 , m_xPropertiesFL(m_xBuilder->weld_widget("framePROPERTIES"))
1003 , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboLB_TEXTDIRECTION")))
1005 SetExchangeSupport();
1007 SvtLanguageOptions aLangOptions;
1008 sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;
1010 if ( aLangOptions.IsAsianTypographyEnabled() )
1012 m_xLeft->set_label(m_xLeftBottom->get_label());
1013 m_xRight->set_label(m_xRightTop->get_label());
1015 OUString sLeft(m_xLeft->get_label());
1016 sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );
1018 if (m_xLastLineLB->get_count() == LASTLINECOUNT_OLD)
1020 m_xLastLineLB->remove(0);
1021 m_xLastLineLB->insert_text(0, sLeft);
1023 else
1024 nLastLinePos = LASTLINEPOS_LEFT;
1027 // remove "Default" or "Left" entry, depends on CJKOptions
1028 if (m_xLastLineLB->get_count() == LASTLINECOUNT_NEW)
1029 m_xLastLineLB->remove(nLastLinePos);
1031 Link<weld::ToggleButton&, void> aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
1032 m_xLeft->connect_toggled(aLink);
1033 m_xRight->connect_toggled(aLink);
1034 m_xCenter->connect_toggled(aLink);
1035 m_xJustify->connect_toggled(aLink);
1036 m_xLastLineLB->connect_changed(LINK(this, SvxParaAlignTabPage, LastLineHdl_Impl));
1037 m_xTextDirectionLB->connect_changed(LINK(this, SvxParaAlignTabPage, TextDirectionHdl_Impl));
1039 m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
1040 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
1041 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
1044 SvxParaAlignTabPage::~SvxParaAlignTabPage()
1048 DeactivateRC SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
1050 if ( _pSet )
1051 FillItemSet( _pSet );
1052 return DeactivateRC::LeavePage;
1055 VclPtr<SfxTabPage> SvxParaAlignTabPage::Create(TabPageParent pParent, const SfxItemSet* rSet)
1057 return VclPtr<SvxParaAlignTabPage>::Create(pParent, *rSet);
1060 bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet )
1062 bool bModified = false;
1064 bool bAdj = false;
1065 SvxAdjust eAdjust = SvxAdjust::Left;
1067 if (m_xLeft->get_active())
1069 eAdjust = SvxAdjust::Left;
1070 bAdj = m_xLeft->get_saved_state() == TRISTATE_FALSE;
1072 else if (m_xRight->get_active())
1074 eAdjust = SvxAdjust::Right;
1075 bAdj = m_xRight->get_saved_state() == TRISTATE_FALSE;
1077 else if (m_xCenter->get_active())
1079 eAdjust = SvxAdjust::Center;
1080 bAdj = m_xCenter->get_saved_state() == TRISTATE_FALSE;
1082 else if (m_xJustify->get_active())
1084 eAdjust = SvxAdjust::Block;
1085 bAdj = m_xJustify->get_saved_state() == TRISTATE_FALSE ||
1086 m_xExpandCB->get_state_changed_from_saved() ||
1087 m_xLastLineLB->get_value_changed_from_saved();
1090 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1092 if (bAdj)
1094 SvxAdjust eOneWord = m_xExpandCB->get_active() ? SvxAdjust::Block : SvxAdjust::Left;
1096 int nLBPos = m_xLastLineLB->get_active();
1097 SvxAdjust eLastBlock = SvxAdjust::Left;
1098 if ( 1 == nLBPos )
1099 eLastBlock = SvxAdjust::Center;
1100 else if ( 2 == nLBPos )
1101 eLastBlock = SvxAdjust::Block;
1103 SvxAdjustItem aAdj( static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) );
1104 aAdj.SetAdjust( eAdjust );
1105 aAdj.SetOneWord( eOneWord );
1106 aAdj.SetLastBlock( eLastBlock );
1107 rOutSet->Put( aAdj );
1108 bModified = true;
1111 if (m_xSnapToGridCB->get_state_changed_from_saved())
1113 rOutSet->Put(SvxParaGridItem(m_xSnapToGridCB->get_active(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
1114 bModified = true;
1117 if (m_xVertAlignLB->get_value_changed_from_saved())
1119 rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN )));
1120 bModified = true;
1123 if (m_xTextDirectionLB->get_visible())
1125 if (m_xTextDirectionLB->get_value_changed_from_saved())
1127 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1128 rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
1129 bModified = true;
1133 return bModified;
1136 void SvxParaAlignTabPage::ActivatePage( const SfxItemSet& rSet )
1138 Reset( &rSet );
1141 void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet )
1143 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1144 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1146 sal_Int32 nLBSelect = 0;
1147 if ( eItemState >= SfxItemState::DEFAULT )
1149 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>(rSet->Get( _nWhich ));
1151 switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
1153 case SvxAdjust::Left: m_xLeft->set_active(true); break;
1155 case SvxAdjust::Right: m_xRight->set_active(true); break;
1157 case SvxAdjust::Center: m_xCenter->set_active(true); break;
1159 case SvxAdjust::Block: m_xJustify->set_active(true); break;
1160 default: ; //prevent warning
1162 bool bEnable = m_xJustify->get_active();
1163 m_xLastLineFT->set_sensitive(bEnable);
1164 m_xLastLineLB->set_sensitive(bEnable);
1166 switch(rAdj.GetLastBlock())
1168 case SvxAdjust::Left: nLBSelect = 0; break;
1170 case SvxAdjust::Center: nLBSelect = 1; break;
1172 case SvxAdjust::Block: nLBSelect = 2; break;
1173 default: ; //prevent warning
1175 m_xExpandCB->set_sensitive(bEnable && nLBSelect == 2);
1176 m_xExpandCB->set_active(SvxAdjust::Block == rAdj.GetOneWord());
1178 else
1180 m_xLeft->set_active(false);
1181 m_xRight->set_active(false);
1182 m_xCenter->set_active(false);
1183 m_xJustify->set_active(false);
1185 m_xLastLineLB->set_active(nLBSelect);
1187 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
1188 if(nHtmlMode & HTMLMODE_ON)
1190 m_xLastLineLB->hide();
1191 m_xLastLineFT->hide();
1192 m_xExpandCB->hide();
1193 if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
1194 m_xJustify->set_sensitive(false);
1195 m_xSnapToGridCB->hide();
1197 _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
1198 eItemState = rSet->GetItemState( _nWhich );
1199 if ( eItemState >= SfxItemState::DEFAULT )
1201 const SvxParaGridItem& rSnap = static_cast<const SvxParaGridItem&>(rSet->Get( _nWhich ));
1202 m_xSnapToGridCB->set_active(rSnap.GetValue());
1205 _nWhich = GetWhich( SID_PARA_VERTALIGN );
1206 eItemState = rSet->GetItemState( _nWhich );
1208 if ( eItemState >= SfxItemState::DEFAULT )
1210 m_xVertAlignFL->show();
1212 const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich ));
1214 m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue()));
1217 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
1218 //text direction
1219 if( SfxItemState::DEFAULT <= rSet->GetItemState( _nWhich ) )
1221 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet->Get( _nWhich ) );
1222 m_xTextDirectionLB->set_active_id(rFrameDirItem.GetValue());
1223 m_xTextDirectionLB->save_value();
1226 m_xSnapToGridCB->save_state();
1227 m_xVertAlignLB->save_value();
1228 m_xLeft->save_state();
1229 m_xRight->save_state();
1230 m_xCenter->save_state();
1231 m_xJustify->save_state();
1232 m_xLastLineLB->save_value();
1233 m_xExpandCB->save_state();
1235 UpdateExample_Impl();
1238 void SvxParaAlignTabPage::ChangesApplied()
1240 m_xTextDirectionLB->save_value();
1241 m_xSnapToGridCB->save_state();
1242 m_xVertAlignLB->save_value();
1243 m_xLeft->save_state();
1244 m_xRight->save_state();
1245 m_xCenter->save_state();
1246 m_xJustify->save_state();
1247 m_xLastLineLB->save_value();
1248 m_xExpandCB->save_state();
1251 IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl, weld::ToggleButton&, void)
1253 bool bJustify = m_xJustify->get_active();
1254 m_xLastLineFT->set_sensitive(bJustify);
1255 m_xLastLineLB->set_sensitive(bJustify);
1256 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1257 m_xExpandCB->set_sensitive(bJustify && bLastLineIsBlock);
1258 //set last line listbox to entry position 0 if not enabled
1259 if (!m_xLastLineLB->get_sensitive())
1260 m_xLastLineLB->set_active(0);
1261 //uncheck 'Expand ... word' when check box is not enabled
1262 if (!m_xExpandCB->get_sensitive())
1263 m_xExpandCB->set_active(false);
1264 UpdateExample_Impl();
1267 IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl, weld::ComboBox&, void)
1269 //fdo#41350 only enable 'Expand last word' if last line is also justified
1270 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1271 m_xExpandCB->set_sensitive(bLastLineIsBlock);
1272 //uncheck 'Expand ... word' when check box is not enabled
1273 if (!m_xExpandCB->get_sensitive())
1274 m_xExpandCB->set_active(false);
1275 UpdateExample_Impl();
1278 IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl, weld::ComboBox&, void)
1280 UpdateExample_Impl();
1283 void SvxParaAlignTabPage::UpdateExample_Impl()
1285 if (m_xLeft->get_active())
1287 m_aExampleWin.EnableRTL(false);
1288 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1289 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1291 else if (m_xRight->get_active())
1293 m_aExampleWin.EnableRTL(true);
1294 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1295 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1297 else
1299 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1300 switch ( eDir )
1302 case SvxFrameDirection::Environment :
1303 if ( !m_xRight->get_active() )
1304 m_aExampleWin.EnableRTL( IsRTLEnabled() /*false*/ );
1305 break;
1306 case SvxFrameDirection::Horizontal_RL_TB :
1307 if ( !m_xLeft->get_active() )
1308 m_aExampleWin.EnableRTL( true );
1309 break;
1310 case SvxFrameDirection::Horizontal_LR_TB :
1311 if ( !m_xRight->get_active() )
1312 m_aExampleWin.EnableRTL( false );
1313 break;
1314 default: ; //prevent warning
1316 if (m_xCenter->get_active())
1317 m_aExampleWin.SetAdjust( SvxAdjust::Center );
1318 else if (m_xJustify->get_active())
1320 m_aExampleWin.SetAdjust( SvxAdjust::Block );
1321 int nLBPos = m_xLastLineLB->get_active();
1322 if (nLBPos == 0)
1323 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1324 else if (nLBPos == 1)
1325 m_aExampleWin.SetLastLine(SvxAdjust::Center);
1326 else if (nLBPos == 2)
1327 m_aExampleWin.SetLastLine(SvxAdjust::Block);
1331 m_aExampleWin.Invalidate();
1334 void SvxParaAlignTabPage::EnableJustifyExt()
1336 m_xLastLineFT->show();
1337 m_xLastLineLB->show();
1338 m_xExpandCB->show();
1339 SvtLanguageOptions aCJKOptions;
1340 if (aCJKOptions.IsAsianTypographyEnabled())
1341 m_xSnapToGridCB->show();
1345 void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet)
1347 const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false);
1348 if (pBoolItem && pBoolItem->GetValue())
1349 EnableJustifyExt();
1352 VclPtr<SfxTabPage> SvxExtParagraphTabPage::Create(TabPageParent pParent, const SfxItemSet* rSet)
1354 return VclPtr<SvxExtParagraphTabPage>::Create(pParent, *rSet);
1357 bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
1359 bool bModified = false;
1360 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1361 const TriState eHyphenState = m_xHyphenBox->get_state();
1362 const SfxPoolItem* pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_HYPHENZONE );
1364 if ( m_xHyphenBox->get_state_changed_from_saved() ||
1365 m_xExtHyphenBeforeBox->get_value_changed_from_saved() ||
1366 m_xExtHyphenAfterBox->get_value_changed_from_saved() ||
1367 m_xMaxHyphenEdit->get_value_changed_from_saved() )
1369 SvxHyphenZoneItem aHyphen(
1370 static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) );
1371 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1373 if ( eHyphenState == TRISTATE_TRUE )
1375 aHyphen.GetMinLead() = static_cast<sal_uInt8>(m_xExtHyphenBeforeBox->get_value());
1376 aHyphen.GetMinTrail() = static_cast<sal_uInt8>(m_xExtHyphenAfterBox->get_value());
1378 aHyphen.GetMaxHyphens() = static_cast<sal_uInt8>(m_xMaxHyphenEdit->get_value());
1380 if ( !pOld ||
1381 *static_cast<const SvxHyphenZoneItem*>(pOld) != aHyphen ||
1382 m_xHyphenBox->get_state_changed_from_saved())
1384 rOutSet->Put( aHyphen );
1385 bModified = true;
1389 if (m_xPageNumBox->get_sensitive()
1390 && (m_xPageNumBox->get_state_changed_from_saved() || m_xPagenumEdit->get_value_changed_from_saved()))
1392 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
1394 if (TRISTATE_TRUE == m_xPageNumBox->get_state()
1395 && (!pOld || IsInvalidItem(pOld)
1396 || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != m_xPagenumEdit->get_value()))
1398 SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM,
1399 static_cast<sal_uInt16>(m_xPagenumEdit->get_value()));
1400 rOutSet->Put( aPageNum );
1401 bModified = true;
1403 else if (TRISTATE_FALSE == m_xPageNumBox->get_state()
1404 && (pOld || IsInvalidItem(pOld)))
1406 // need to tell sw to remove the item
1407 rOutSet->DisableItem(SID_ATTR_PARA_PAGENUM);
1408 bModified = true;
1412 // pagebreak
1414 TriState eState = m_xApplyCollBtn->get_state();
1415 bool bIsPageModel = false;
1417 _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1418 OUString sPage;
1419 if ( m_xApplyCollBtn->get_state_changed_from_saved() ||
1420 ( TRISTATE_TRUE == eState &&
1421 m_xApplyCollBox->get_value_changed_from_saved() ) )
1423 if ( eState == TRISTATE_TRUE )
1425 sPage = m_xApplyCollBox->get_active_text();
1426 bIsPageModel = !sPage.isEmpty();
1428 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_MODEL );
1430 if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage )
1432 rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) );
1433 bModified = true;
1435 else
1436 bIsPageModel = false;
1438 else if(TRISTATE_TRUE == eState && m_xApplyCollBtn->get_sensitive())
1439 bIsPageModel = true;
1440 else
1441 rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) );
1443 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1445 if ( bIsPageModel )
1446 // if PageModel is turned on, always turn off PageBreak
1447 rOutSet->Put( SvxFormatBreakItem( SvxBreak::NONE, _nWhich ) );
1448 else
1450 eState = m_xPageBreakBox->get_state();
1451 SfxItemState eModelState = GetItemSet().GetItemState(SID_ATTR_PARA_MODEL, false);
1453 if ( (eModelState == SfxItemState::SET && TRISTATE_TRUE == m_xPageBreakBox->get_state()) ||
1454 m_xPageBreakBox->get_state_changed_from_saved() ||
1455 m_xBreakTypeLB->get_value_changed_from_saved() ||
1456 m_xBreakPositionLB->get_value_changed_from_saved() )
1458 const SvxFormatBreakItem rOldBreak(
1459 static_cast<const SvxFormatBreakItem&>(GetItemSet().Get( _nWhich )));
1460 SvxFormatBreakItem aBreak(rOldBreak.GetBreak(), rOldBreak.Which());
1462 switch ( eState )
1464 case TRISTATE_TRUE:
1466 bool bBefore = m_xBreakPositionLB->get_active() == 0;
1468 if (m_xBreakTypeLB->get_active() == 0)
1470 if ( bBefore )
1471 aBreak.SetValue( SvxBreak::PageBefore );
1472 else
1473 aBreak.SetValue( SvxBreak::PageAfter );
1475 else
1477 if ( bBefore )
1478 aBreak.SetValue( SvxBreak::ColumnBefore );
1479 else
1480 aBreak.SetValue( SvxBreak::ColumnAfter );
1482 break;
1485 case TRISTATE_FALSE:
1486 aBreak.SetValue( SvxBreak::NONE );
1487 break;
1488 default: ; //prevent warning
1490 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGEBREAK );
1492 if ( eState != m_xPageBreakBox->get_saved_state() ||
1493 !pOld || !( *static_cast<const SvxFormatBreakItem*>(pOld) == aBreak ) )
1495 bModified = true;
1496 rOutSet->Put( aBreak );
1501 // paragraph split
1502 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1503 eState = m_xKeepTogetherBox->get_state();
1505 if (m_xKeepTogetherBox->get_state_changed_from_saved())
1507 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_SPLIT );
1509 if ( !pOld || static_cast<const SvxFormatSplitItem*>(pOld)->GetValue() !=
1510 ( eState == TRISTATE_FALSE ) )
1512 rOutSet->Put( SvxFormatSplitItem( eState == TRISTATE_FALSE, _nWhich ) );
1513 bModified = true;
1517 // keep paragraphs
1518 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1519 eState = m_xKeepParaBox->get_state();
1521 if (m_xKeepParaBox->get_state_changed_from_saved())
1523 // if the status has changed, putting is necessary
1524 rOutSet->Put( SvxFormatKeepItem( eState == TRISTATE_TRUE, _nWhich ) );
1525 bModified = true;
1528 // widows and orphans
1529 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1530 eState = m_xWidowBox->get_state();
1532 if ( m_xWidowBox->get_state_changed_from_saved() ||
1533 m_xWidowRowNo->get_value_changed_from_saved() )
1535 SvxWidowsItem rItem( eState == TRISTATE_TRUE ?
1536 static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, _nWhich );
1537 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS );
1539 if ( m_xWidowBox->get_state_changed_from_saved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) )
1541 rOutSet->Put( rItem );
1542 bModified = true;
1546 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1547 eState = m_xOrphanBox->get_state();
1549 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1550 m_xOrphanRowNo->get_value_changed_from_saved() )
1552 SvxOrphansItem rItem( eState == TRISTATE_TRUE ?
1553 static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, _nWhich );
1554 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS );
1556 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1557 !pOld ||
1558 !( *static_cast<const SvxOrphansItem*>(pOld) == rItem ) )
1560 rOutSet->Put( rItem );
1561 bModified = true;
1565 return bModified;
1567 void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
1569 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1570 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1572 bool bItemAvailable = eItemState >= SfxItemState::DEFAULT;
1573 bool bIsHyphen = false;
1574 if( !bHtmlMode && bItemAvailable )
1576 const SvxHyphenZoneItem& rHyphen =
1577 static_cast<const SvxHyphenZoneItem&>(rSet->Get( _nWhich ));
1578 aHyphenState.bTriStateEnabled = false;
1580 bIsHyphen = rHyphen.IsHyphen();
1581 m_xHyphenBox->set_state(bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE);
1583 m_xExtHyphenBeforeBox->set_value(rHyphen.GetMinLead());
1584 m_xExtHyphenAfterBox->set_value(rHyphen.GetMinTrail());
1585 m_xMaxHyphenEdit->set_value(rHyphen.GetMaxHyphens());
1587 else
1589 m_xHyphenBox->set_state(TRISTATE_INDET);
1591 bool bEnable = bItemAvailable && bIsHyphen;
1592 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
1593 m_xExtHyphenAfterBox->set_sensitive(bEnable);
1594 m_xBeforeText->set_sensitive(bEnable);
1595 m_xAfterText->set_sensitive(bEnable);
1596 m_xMaxHyphenLabel->set_sensitive(bEnable);
1597 m_xMaxHyphenEdit->set_sensitive(bEnable);
1599 _nWhich = GetWhich( SID_ATTR_PARA_PAGENUM );
1601 switch (rSet->GetItemState(_nWhich))
1603 case SfxItemState::SET:
1605 aPageNumState.bTriStateEnabled = false;
1606 m_xPageNumBox->set_state(TRISTATE_TRUE);
1607 SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(_nWhich));
1608 const sal_uInt16 nPageNum(pItem->GetValue());
1609 m_xPagenumEdit->set_value(nPageNum);
1610 break;
1612 case SfxItemState::DONTCARE:
1614 aPageNumState.bTriStateEnabled = true;
1615 m_xPageNumBox->set_state(TRISTATE_INDET);
1616 break;
1618 case SfxItemState::UNKNOWN:
1619 case SfxItemState::DEFAULT:
1620 case SfxItemState::DISABLED:
1622 aPageNumState.bTriStateEnabled = false;
1623 m_xPageNumBox->set_state(TRISTATE_FALSE);
1624 break;
1626 default:
1627 assert(false); // unexpected
1628 break;
1631 if ( bPageBreak )
1633 // first handle PageModel
1634 _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1635 bool bIsPageModel = false;
1636 eItemState = rSet->GetItemState( _nWhich );
1638 if ( eItemState >= SfxItemState::SET )
1640 aApplyCollState.bTriStateEnabled = false;
1642 const SvxPageModelItem& rModel =
1643 static_cast<const SvxPageModelItem&>(rSet->Get( _nWhich ));
1644 const OUString& aStr( rModel.GetValue() );
1646 if (!aStr.isEmpty() && m_xApplyCollBox->find_text(aStr) != -1)
1648 m_xApplyCollBox->set_active_text(aStr);
1649 m_xApplyCollBtn->set_state(TRISTATE_TRUE);
1650 bIsPageModel = true;
1652 m_xPageBreakBox->set_sensitive(true);
1653 aPageBreakState.bTriStateEnabled = false;
1654 m_xBreakTypeFT->set_sensitive(true);
1655 m_xBreakTypeLB->set_sensitive(true);
1656 m_xBreakPositionFT->set_sensitive(true);
1657 m_xBreakPositionLB->set_sensitive(true);
1658 m_xApplyCollBtn->set_sensitive(false);
1659 m_xPageBreakBox->set_state(TRISTATE_TRUE);
1661 //select page break
1662 m_xBreakTypeLB->set_active(0);
1663 //select break before
1664 m_xBreakPositionLB->set_active(0);
1666 else
1668 m_xApplyCollBox->set_active(-1);
1669 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
1672 else if ( SfxItemState::DONTCARE == eItemState )
1674 aApplyCollState.bTriStateEnabled = true;
1675 m_xApplyCollBtn->set_state(TRISTATE_INDET);
1676 m_xApplyCollBox->set_active(-1);
1678 else
1680 m_xApplyCollBtn->set_sensitive(false);
1681 m_xApplyCollBox->set_sensitive(false);
1682 m_xPagenumEdit->set_sensitive(false);
1683 m_xPageNumBox->set_sensitive(false);
1686 if ( !bIsPageModel )
1688 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1689 eItemState = rSet->GetItemState( _nWhich );
1691 if ( eItemState >= SfxItemState::DEFAULT )
1693 const SvxFormatBreakItem& rPageBreak =
1694 static_cast<const SvxFormatBreakItem&>(rSet->Get( _nWhich ));
1696 SvxBreak eBreak = rPageBreak.GetBreak();
1698 // PageBreak not via CTRL-RETURN,
1699 // then CheckBox can be freed
1700 m_xPageBreakBox->set_sensitive(true);
1701 aPageBreakState.bTriStateEnabled = false;
1702 m_xBreakTypeFT->set_sensitive(true);
1703 m_xBreakTypeLB->set_sensitive(true);
1704 m_xBreakPositionFT->set_sensitive(true);
1705 m_xBreakPositionLB->set_sensitive(true);
1707 m_xPageBreakBox->set_state(TRISTATE_TRUE);
1709 bool _bEnable = eBreak != SvxBreak::NONE &&
1710 eBreak != SvxBreak::ColumnBefore &&
1711 eBreak != SvxBreak::ColumnAfter;
1712 m_xApplyCollBtn->set_sensitive(_bEnable);
1713 if (!_bEnable)
1715 m_xApplyCollBox->set_sensitive(_bEnable);
1716 m_xPageNumBox->set_sensitive(false);
1717 m_xPagenumEdit->set_sensitive(_bEnable);
1720 if ( eBreak == SvxBreak::NONE )
1721 m_xPageBreakBox->set_state(TRISTATE_FALSE);
1723 sal_Int32 nType = 0; // selection position in break type ListBox : Page
1724 sal_Int32 nPosition = 0; // selection position in break position ListBox : Before
1725 switch ( eBreak )
1727 case SvxBreak::PageBefore:
1728 break;
1729 case SvxBreak::PageAfter:
1730 nPosition = 1;
1731 break;
1732 case SvxBreak::ColumnBefore:
1733 nType = 1;
1734 break;
1735 case SvxBreak::ColumnAfter:
1736 nType = 1;
1737 nPosition = 1;
1738 break;
1739 default: ;//prevent warning
1741 m_xBreakTypeLB->set_active(nType);
1742 m_xBreakPositionLB->set_active(nPosition);
1744 else if ( SfxItemState::DONTCARE == eItemState )
1745 m_xPageBreakBox->set_state(TRISTATE_INDET);
1746 else
1748 m_xPageBreakBox->set_sensitive(false);
1749 m_xBreakTypeFT->set_sensitive(false);
1750 m_xBreakTypeLB->set_sensitive(false);
1751 m_xBreakPositionFT->set_sensitive(false);
1752 m_xBreakPositionLB->set_sensitive(false);
1756 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
1757 PageBreakHdl();
1760 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1761 eItemState = rSet->GetItemState( _nWhich );
1763 if ( eItemState >= SfxItemState::DEFAULT )
1765 aKeepParaState.bTriStateEnabled = false;
1766 const SvxFormatKeepItem& rKeep =
1767 static_cast<const SvxFormatKeepItem&>(rSet->Get( _nWhich ));
1769 if ( rKeep.GetValue() )
1770 m_xKeepParaBox->set_state(TRISTATE_TRUE);
1771 else
1772 m_xKeepParaBox->set_state(TRISTATE_FALSE);
1774 else if ( SfxItemState::DONTCARE == eItemState )
1775 m_xKeepParaBox->set_state(TRISTATE_INDET);
1776 else
1777 m_xKeepParaBox->set_sensitive(false);
1779 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1780 eItemState = rSet->GetItemState( _nWhich );
1782 if ( eItemState >= SfxItemState::DEFAULT )
1784 const SvxFormatSplitItem& rSplit =
1785 static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich ));
1786 aKeepTogetherState.bTriStateEnabled = false;
1788 if ( !rSplit.GetValue() )
1789 m_xKeepTogetherBox->set_state(TRISTATE_TRUE);
1790 else
1792 m_xKeepTogetherBox->set_state(TRISTATE_FALSE);
1794 // widows and orphans
1795 m_xWidowBox->set_sensitive(true);
1796 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1797 SfxItemState eTmpState = rSet->GetItemState( _nWhich );
1799 if ( eTmpState >= SfxItemState::DEFAULT )
1801 const SvxWidowsItem& rWidow =
1802 static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich ));
1803 aWidowState.bTriStateEnabled = false;
1804 const sal_uInt16 nLines = rWidow.GetValue();
1806 bool _bEnable = nLines > 0;
1807 m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines));
1808 m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
1809 m_xWidowRowNo->set_sensitive(_bEnable);
1810 //m_xWidowRowLabel->set_sensitive(_bEnable);
1813 else if ( SfxItemState::DONTCARE == eTmpState )
1814 m_xWidowBox->set_state( TRISTATE_INDET );
1815 else
1816 m_xWidowBox->set_sensitive(false);
1818 m_xOrphanBox->set_sensitive(true);
1819 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1820 eTmpState = rSet->GetItemState( _nWhich );
1822 if ( eTmpState >= SfxItemState::DEFAULT )
1824 const SvxOrphansItem& rOrphan =
1825 static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich ));
1826 const sal_uInt16 nLines = rOrphan.GetValue();
1827 aOrphanState.bTriStateEnabled = false;
1829 bool _bEnable = nLines > 0;
1830 m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
1831 m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines));
1832 m_xOrphanRowNo->set_sensitive(_bEnable);
1833 m_xOrphanRowLabel->set_sensitive(_bEnable);
1836 else if ( SfxItemState::DONTCARE == eTmpState )
1837 m_xOrphanBox->set_state(TRISTATE_INDET);
1838 else
1839 m_xOrphanBox->set_sensitive(false);
1840 aOrphanState.eState = m_xOrphanBox->get_state();
1843 else if ( SfxItemState::DONTCARE == eItemState )
1844 m_xKeepTogetherBox->set_state(TRISTATE_INDET);
1845 else
1846 m_xKeepTogetherBox->set_sensitive(false);
1848 // so that everything is enabled correctly
1849 KeepTogetherHdl();
1850 WidowHdl();
1851 OrphanHdl();
1852 ChangesApplied();
1854 void SvxExtParagraphTabPage::ChangesApplied()
1856 m_xHyphenBox->save_state();
1857 m_xExtHyphenBeforeBox->set_value(m_xExtHyphenBeforeBox->get_value());
1858 m_xExtHyphenAfterBox->set_value(m_xExtHyphenAfterBox->get_value());
1859 m_xMaxHyphenEdit->set_value(m_xMaxHyphenEdit->get_value());
1860 m_xPageBreakBox->save_state();
1861 m_xBreakPositionLB->save_value();
1862 m_xBreakTypeLB->save_value();
1863 m_xApplyCollBtn->save_state();
1864 m_xApplyCollBox->save_value();
1865 m_xPageNumBox->save_state();
1866 m_xPagenumEdit->save_value();
1867 m_xKeepTogetherBox->save_state();
1868 m_xKeepParaBox->save_state();
1869 m_xWidowBox->save_state();
1870 m_xOrphanBox->save_state();
1871 m_xOrphanRowNo->set_value(m_xOrphanRowNo->get_value());
1872 m_xWidowRowNo->set_value(m_xWidowRowNo->get_value());
1875 DeactivateRC SvxExtParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
1877 if ( _pSet )
1878 FillItemSet( _pSet );
1879 return DeactivateRC::LeavePage;
1882 void SvxExtParagraphTabPage::DisablePageBreak()
1884 bPageBreak = false;
1885 m_xPageBreakBox->set_sensitive(false);
1886 m_xBreakTypeLB->remove(0);
1887 m_xBreakPositionFT->set_sensitive(false);
1888 m_xBreakPositionLB->set_sensitive(false);
1889 m_xApplyCollBtn->set_sensitive(false);
1890 m_xApplyCollBox->set_sensitive(false);
1891 m_xPageNumBox->set_sensitive(false);
1892 m_xPagenumEdit->set_sensitive(false);
1895 SvxExtParagraphTabPage::SvxExtParagraphTabPage(TabPageParent pParent, const SfxItemSet& rAttr)
1896 : SfxTabPage(pParent, "cui/ui/textflowpage.ui", "TextFlowPage", &rAttr)
1897 , bPageBreak(true)
1898 , bHtmlMode(false)
1899 , nStdPos(0)
1900 // Hyphenation
1901 , m_xHyphenBox(m_xBuilder->weld_check_button("checkAuto"))
1902 , m_xBeforeText(m_xBuilder->weld_label("labelLineBegin"))
1903 , m_xExtHyphenBeforeBox(m_xBuilder->weld_spin_button("spinLineEnd"))
1904 , m_xAfterText(m_xBuilder->weld_label("labelLineEnd"))
1905 , m_xExtHyphenAfterBox(m_xBuilder->weld_spin_button("spinLineBegin"))
1906 , m_xMaxHyphenLabel(m_xBuilder->weld_label("labelMaxNum"))
1907 , m_xMaxHyphenEdit(m_xBuilder->weld_spin_button("spinMaxNum"))
1908 //Page break
1909 , m_xPageBreakBox(m_xBuilder->weld_check_button("checkInsert"))
1910 , m_xBreakTypeFT(m_xBuilder->weld_label("labelType"))
1911 , m_xBreakTypeLB(m_xBuilder->weld_combo_box("comboBreakType"))
1912 , m_xBreakPositionFT(m_xBuilder->weld_label("labelPosition"))
1913 , m_xBreakPositionLB(m_xBuilder->weld_combo_box("comboBreakPosition"))
1914 , m_xApplyCollBtn(m_xBuilder->weld_check_button("checkPageStyle"))
1915 , m_xApplyCollBox(m_xBuilder->weld_combo_box("comboPageStyle"))
1916 , m_xPageNumBox(m_xBuilder->weld_check_button("labelPageNum"))
1917 , m_xPagenumEdit(m_xBuilder->weld_spin_button("spinPageNumber"))
1918 // Options
1919 , m_xKeepTogetherBox(m_xBuilder->weld_check_button("checkSplitPara"))
1920 , m_xKeepParaBox(m_xBuilder->weld_check_button("checkKeepPara"))
1921 , m_xOrphanBox(m_xBuilder->weld_check_button("checkOrphan"))
1922 , m_xOrphanRowNo(m_xBuilder->weld_spin_button("spinOrphan"))
1923 , m_xOrphanRowLabel(m_xBuilder->weld_label("labelOrphan"))
1924 , m_xWidowBox(m_xBuilder->weld_check_button("checkWidow"))
1925 , m_xWidowRowNo(m_xBuilder->weld_spin_button("spinWidow"))
1926 , m_xWidowRowLabel(m_xBuilder->weld_label("labelWidow"))
1928 // this page needs ExchangeSupport
1929 SetExchangeSupport();
1931 m_xHyphenBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, HyphenClickHdl_Impl));
1932 m_xPageBreakBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageBreakHdl_Impl));
1933 m_xKeepTogetherBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepTogetherHdl_Impl));
1934 m_xWidowBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, WidowHdl_Impl));
1935 m_xOrphanBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, OrphanHdl_Impl));
1936 m_xApplyCollBtn->connect_toggled(LINK(this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl));
1937 m_xBreakTypeLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl));
1938 m_xBreakPositionLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl));
1939 m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl));
1940 m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl));
1942 SfxObjectShell* pSh = SfxObjectShell::Current();
1943 if ( pSh )
1945 SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
1946 pPool->SetSearchMask( SfxStyleFamily::Page );
1947 SfxStyleSheetBase* pStyle = pPool->First();
1948 OUString aStdName;
1950 while( pStyle )
1952 if ( aStdName.isEmpty() )
1953 // first style == standard style
1954 aStdName = pStyle->GetName();
1955 m_xApplyCollBox->append_text(pStyle->GetName());
1956 pStyle = pPool->Next();
1958 nStdPos = m_xApplyCollBox->find_text(aStdName);
1961 sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr );
1962 if ( nHtmlMode & HTMLMODE_ON )
1964 bHtmlMode = true;
1965 m_xHyphenBox->set_sensitive(false);
1966 m_xBeforeText->set_sensitive(false);
1967 m_xExtHyphenBeforeBox->set_sensitive(false);
1968 m_xAfterText->set_sensitive(false);
1969 m_xExtHyphenAfterBox->set_sensitive(false);
1970 m_xMaxHyphenLabel->set_sensitive(false);
1971 m_xMaxHyphenEdit->set_sensitive(false);
1972 m_xPageNumBox->set_sensitive(false);
1973 m_xPagenumEdit->set_sensitive(false);
1974 // no column break in HTML
1975 m_xBreakTypeLB->remove(1);
1979 SvxExtParagraphTabPage::~SvxExtParagraphTabPage()
1983 void SvxExtParagraphTabPage::PageBreakHdl()
1985 switch (m_xPageBreakBox->get_state())
1987 case TRISTATE_TRUE:
1988 m_xBreakTypeFT->set_sensitive(true);
1989 m_xBreakTypeLB->set_sensitive(true);
1990 m_xBreakPositionFT->set_sensitive(true);
1991 m_xBreakPositionLB->set_sensitive(true);
1993 if (0 == m_xBreakTypeLB->get_active() && 0 == m_xBreakPositionLB->get_active())
1995 m_xApplyCollBtn->set_sensitive(true);
1997 bool bEnable = TRISTATE_TRUE == m_xApplyCollBtn->get_state() &&
1998 m_xApplyCollBox->get_count();
1999 m_xApplyCollBox->set_sensitive(bEnable);
2000 if(!bHtmlMode)
2002 m_xPageNumBox->set_sensitive(bEnable);
2003 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2006 break;
2008 case TRISTATE_FALSE:
2009 case TRISTATE_INDET:
2010 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2011 m_xApplyCollBtn->set_sensitive(false);
2012 m_xApplyCollBox->set_sensitive(false);
2013 m_xPageNumBox->set_sensitive(false);
2014 m_xPagenumEdit->set_sensitive(false);
2015 m_xBreakTypeFT->set_sensitive(false);
2016 m_xBreakTypeLB->set_sensitive(false);
2017 m_xBreakPositionFT->set_sensitive(false);
2018 m_xBreakPositionLB->set_sensitive(false);
2019 break;
2023 IMPL_LINK(SvxExtParagraphTabPage, PageBreakHdl_Impl, weld::ToggleButton&, rToggle, void)
2025 aPageBreakState.ButtonToggled(rToggle);
2026 PageBreakHdl();
2029 void SvxExtParagraphTabPage::KeepTogetherHdl()
2031 bool bEnable = m_xKeepTogetherBox->get_state() == TRISTATE_FALSE;
2032 m_xWidowBox->set_sensitive(bEnable);
2033 m_xOrphanBox->set_sensitive(bEnable);
2036 IMPL_LINK(SvxExtParagraphTabPage, KeepTogetherHdl_Impl, weld::ToggleButton&, rToggle, void)
2038 aKeepTogetherState.ButtonToggled(rToggle);
2039 KeepTogetherHdl();
2042 void SvxExtParagraphTabPage::WidowHdl()
2044 switch (m_xWidowBox->get_state())
2046 case TRISTATE_TRUE:
2047 m_xWidowRowNo->set_sensitive(true);
2048 m_xWidowRowLabel->set_sensitive(true);
2049 m_xKeepTogetherBox->set_sensitive(false);
2050 break;
2051 case TRISTATE_FALSE:
2052 if (m_xOrphanBox->get_state() == TRISTATE_FALSE)
2053 m_xKeepTogetherBox->set_sensitive(true);
2054 [[fallthrough]];
2055 case TRISTATE_INDET:
2056 m_xWidowRowNo->set_sensitive(false);
2057 m_xWidowRowLabel->set_sensitive(false);
2058 break;
2062 IMPL_LINK(SvxExtParagraphTabPage, WidowHdl_Impl, weld::ToggleButton&, rToggle, void)
2064 aWidowState.ButtonToggled(rToggle);
2065 WidowHdl();
2068 IMPL_LINK(SvxExtParagraphTabPage, OrphanHdl_Impl, weld::ToggleButton&, rToggle, void)
2070 aOrphanState.ButtonToggled(rToggle);
2071 OrphanHdl();
2074 void SvxExtParagraphTabPage::OrphanHdl()
2076 switch (m_xOrphanBox->get_state())
2078 case TRISTATE_TRUE:
2079 m_xOrphanRowNo->set_sensitive(true);
2080 m_xOrphanRowLabel->set_sensitive(true);
2081 m_xKeepTogetherBox->set_sensitive(false);
2082 break;
2084 case TRISTATE_FALSE:
2085 if (m_xWidowBox->get_state() == TRISTATE_FALSE)
2086 m_xKeepTogetherBox->set_sensitive(true);
2087 [[fallthrough]];
2088 case TRISTATE_INDET:
2089 m_xOrphanRowNo->set_sensitive(false);
2090 m_xOrphanRowLabel->set_sensitive(false);
2091 break;
2095 void SvxExtParagraphTabPage::HyphenClickHdl()
2097 bool bEnable = m_xHyphenBox->get_state() == TRISTATE_TRUE;
2098 m_xBeforeText->set_sensitive(bEnable);
2099 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
2100 m_xAfterText->set_sensitive(bEnable);
2101 m_xExtHyphenAfterBox->set_sensitive(bEnable);
2102 m_xMaxHyphenLabel->set_sensitive(bEnable);
2103 m_xMaxHyphenEdit->set_sensitive(bEnable);
2104 m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2107 IMPL_LINK(SvxExtParagraphTabPage, HyphenClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2109 aHyphenState.ButtonToggled(rToggle);
2110 HyphenClickHdl();
2113 void SvxExtParagraphTabPage::ApplyCollClickHdl()
2115 bool bEnable = false;
2116 if (m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count())
2118 bEnable = true;
2119 m_xApplyCollBox->set_active(nStdPos);
2121 else
2123 m_xApplyCollBox->set_active(-1);
2125 m_xApplyCollBox->set_sensitive(bEnable);
2126 if (!bHtmlMode)
2128 m_xPageNumBox->set_sensitive(bEnable);
2129 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2133 IMPL_LINK(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2135 aApplyCollState.ButtonToggled(rToggle);
2136 ApplyCollClickHdl();
2139 IMPL_LINK(SvxExtParagraphTabPage, PageBreakPosHdl_Impl, weld::ComboBox&, rListBox, void)
2141 if (0 == rListBox.get_active())
2143 m_xApplyCollBtn->set_sensitive(true);
2145 bool bEnable = m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count();
2147 m_xApplyCollBox->set_sensitive(bEnable);
2148 if (!bHtmlMode)
2150 m_xPageNumBox->set_sensitive(bEnable);
2151 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2154 else if (1 == rListBox.get_active())
2156 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2157 m_xApplyCollBtn->set_sensitive(false);
2158 m_xApplyCollBox->set_sensitive(false);
2159 m_xPageNumBox->set_sensitive(false);
2160 m_xPagenumEdit->set_sensitive(false);
2164 IMPL_LINK(SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, weld::ComboBox&, rListBox, void)
2166 //column break or break after
2167 int nBreakPos = m_xBreakPositionLB->get_active();
2168 if (rListBox.get_active() == 1 || 1 == nBreakPos)
2170 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2171 m_xApplyCollBtn->set_sensitive(false);
2172 m_xApplyCollBox->set_sensitive(false);
2173 m_xPageNumBox->set_sensitive(false);
2174 m_xPagenumEdit->set_sensitive(false);
2176 else
2177 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2180 void SvxExtParagraphTabPage::PageNumBoxClickHdl()
2182 m_xPagenumEdit->set_sensitive(m_xPageNumBox->get_state() == TRISTATE_TRUE);
2185 IMPL_LINK(SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2187 aPageNumState.ButtonToggled(rToggle);
2188 PageNumBoxClickHdl();
2191 IMPL_LINK(SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2193 aKeepParaState.ButtonToggled(rToggle);
2196 void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
2198 const SfxBoolItem* pDisablePageBreakItem = aSet.GetItem<SfxBoolItem>(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false);
2200 if (pDisablePageBreakItem)
2201 if ( pDisablePageBreakItem->GetValue())
2202 DisablePageBreak();
2205 SvxAsianTabPage::SvxAsianTabPage(TabPageParent pParent, const SfxItemSet& rSet)
2206 : SfxTabPage(pParent, "cui/ui/asiantypography.ui", "AsianTypography", &rSet)
2207 , m_xForbiddenRulesCB(m_xBuilder->weld_check_button("checkForbidList"))
2208 , m_xHangingPunctCB(m_xBuilder->weld_check_button("checkHangPunct"))
2209 , m_xScriptSpaceCB(m_xBuilder->weld_check_button("checkApplySpacing"))
2213 SvxAsianTabPage::~SvxAsianTabPage()
2217 VclPtr<SfxTabPage> SvxAsianTabPage::Create(TabPageParent pParent, const SfxItemSet* rSet)
2219 return VclPtr<SvxAsianTabPage>::Create(pParent, *rSet);
2222 const sal_uInt16* SvxAsianTabPage::GetRanges()
2224 static const sal_uInt16 pRanges[] =
2226 SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES,
2229 return pRanges;
2232 bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet )
2234 bool bRet = false;
2235 SfxItemPool* pPool = rSet->GetPool();
2236 if (m_xScriptSpaceCB->get_sensitive() && m_xScriptSpaceCB->get_state_changed_from_saved())
2238 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2239 pPool->GetWhich(SID_ATTR_PARA_SCRIPTSPACE)).Clone()));
2240 pNewItem->SetValue(m_xScriptSpaceCB->get_active());
2241 rSet->Put(std::move(pNewItem));
2242 bRet = true;
2244 if (m_xHangingPunctCB->get_sensitive() && m_xHangingPunctCB->get_state_changed_from_saved())
2246 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2247 pPool->GetWhich(SID_ATTR_PARA_HANGPUNCTUATION)).Clone()));
2248 pNewItem->SetValue(m_xHangingPunctCB->get_active());
2249 rSet->Put(std::move(pNewItem));
2250 bRet = true;
2252 if (m_xForbiddenRulesCB->get_sensitive() && m_xForbiddenRulesCB->get_state_changed_from_saved())
2254 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2255 pPool->GetWhich(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone()));
2256 pNewItem->SetValue(m_xForbiddenRulesCB->get_active());
2257 rSet->Put(std::move(pNewItem));
2258 bRet = true;
2260 return bRet;
2263 static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, weld::CheckButton& rBox)
2265 sal_uInt16 _nWhich = rSet.GetPool()->GetWhich(nSlotId);
2266 SfxItemState eState = rSet.GetItemState(_nWhich);
2267 if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED )
2268 rBox.set_sensitive(false);
2269 else if(eState >= SfxItemState::DEFAULT)
2270 rBox.set_active(static_cast<const SfxBoolItem&>(rSet.Get(_nWhich)).GetValue());
2271 else
2272 rBox.set_state(TRISTATE_INDET);
2273 rBox.save_state();
2276 void SvxAsianTabPage::Reset( const SfxItemSet* rSet )
2278 lcl_SetBox(*rSet, SID_ATTR_PARA_FORBIDDEN_RULES, *m_xForbiddenRulesCB );
2279 lcl_SetBox(*rSet, SID_ATTR_PARA_HANGPUNCTUATION, *m_xHangingPunctCB );
2281 //character distance not yet available
2282 lcl_SetBox(*rSet, SID_ATTR_PARA_SCRIPTSPACE, *m_xScriptSpaceCB );
2285 void SvxAsianTabPage::ChangesApplied()
2287 m_xForbiddenRulesCB->save_state();
2288 m_xHangingPunctCB->save_state();
2289 m_xScriptSpaceCB->save_state();
2292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */