bump product version to 6.4.0.3
[LibreOffice.git] / cui / source / tabpages / paragrph.cxx
blobdba1ea03caa82923974d3a6661bbc627ff5726d1
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/objsh.hxx>
24 #include <vcl/mnemonic.hxx>
25 #include <vcl/settings.hxx>
26 #include <svx/flagsdef.hxx>
27 #include <svx/svxids.hrc>
29 #include <svl/languageoptions.hxx>
30 #include <svl/cjkoptions.hxx>
31 #include <editeng/pgrditem.hxx>
32 #include <svx/strings.hrc>
33 #include <svx/dialmgr.hxx>
34 #include <paragrph.hxx>
35 #include <editeng/frmdiritem.hxx>
36 #include <editeng/lspcitem.hxx>
37 #include <editeng/adjustitem.hxx>
38 #include <editeng/orphitem.hxx>
39 #include <editeng/widwitem.hxx>
40 #include <editeng/tstpitem.hxx>
41 #include <editeng/pmdlitem.hxx>
42 #include <editeng/spltitem.hxx>
43 #include <editeng/hyphenzoneitem.hxx>
44 #include <editeng/ulspitem.hxx>
45 #include <editeng/lrspitem.hxx>
46 #include <editeng/formatbreakitem.hxx>
47 #include <editeng/keepitem.hxx>
48 #include <svx/dlgutil.hxx>
49 #include <sfx2/htmlmode.hxx>
50 #include <editeng/paravertalignitem.hxx>
51 #include <svl/eitem.hxx>
52 #include <svl/intitem.hxx>
54 #include <sfx2/viewfrm.hxx>
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_115 = 1,
91 LLINESPACE_15 = 2,
92 LLINESPACE_2 = 3,
93 LLINESPACE_PROP = 4,
94 LLINESPACE_MIN = 5,
95 LLINESPACE_DURCH= 6,
96 LLINESPACE_FIX = 7
99 static 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.SetLineSpaceRule( SvxLineSpaceRule::Auto );
108 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
109 break;
111 case LLINESPACE_115:
112 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
113 rLineSpace.SetPropLineSpace( 115 );
114 break;
116 case LLINESPACE_15:
117 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
118 rLineSpace.SetPropLineSpace( 150 );
119 break;
121 case LLINESPACE_2:
122 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
123 rLineSpace.SetPropLineSpace( 200 );
124 break;
126 case LLINESPACE_PROP:
127 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
128 rLineSpace.SetPropLineSpace( static_cast<sal_uInt16>(lValue) );
129 break;
131 case LLINESPACE_MIN:
132 rLineSpace.SetLineHeight( static_cast<sal_uInt16>(lValue) );
133 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
134 break;
136 case LLINESPACE_DURCH:
137 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
138 rLineSpace.SetInterLineSpace( static_cast<sal_uInt16>(lValue) );
139 break;
141 case LLINESPACE_FIX:
142 rLineSpace.SetLineHeight(static_cast<sal_uInt16>(lValue));
143 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Fix );
144 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
145 break;
149 static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
151 sal_uInt16 nHtmlMode = 0;
152 const SfxPoolItem* pItem = nullptr;
153 SfxObjectShell* pShell;
154 if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem) ||
155 ( nullptr != (pShell = SfxObjectShell::Current()) &&
156 nullptr != (pItem = pShell->GetItem(SID_HTML_MODE))))
158 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
160 return nHtmlMode;
164 void SvxStdParagraphTabPage::ELRLoseFocus()
166 SfxItemPool* pPool = GetItemSet().GetPool();
167 DBG_ASSERT( pPool, "Where is the pool?" );
168 FieldUnit eUnit =
169 MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
171 sal_Int64 nL = m_xLeftIndent->denormalize(m_xLeftIndent->get_value(eUnit));
172 sal_Int64 nR = m_xRightIndent->denormalize(m_xRightIndent->get_value(eUnit));
173 OUString aTmp = m_xFLineIndent->get_text();
175 if (m_xLeftIndent->get_min(FieldUnit::NONE) < 0)
176 m_xFLineIndent->set_min(-99999, FieldUnit::MM);
177 else
178 m_xFLineIndent->set_min(m_xFLineIndent->normalize(-nL), eUnit);
180 // Check only for concrete width (Shell)
181 sal_Int64 nTmp = nWidth - nL - nR - MM50;
182 m_xFLineIndent->set_max(m_xFLineIndent->normalize(nTmp), eUnit);
184 if (aTmp.isEmpty())
185 m_xFLineIndent->set_text(OUString());
186 // maximum left right
187 aTmp = m_xLeftIndent->get_text();
188 nTmp = nWidth - nR - MM50;
189 m_xLeftIndent->set_max(m_xLeftIndent->normalize(nTmp), eUnit);
191 if ( aTmp.isEmpty() )
192 m_xLeftIndent->set_text(OUString());
193 aTmp = m_xRightIndent->get_text();
194 nTmp = nWidth - nL - MM50;
195 m_xRightIndent->set_max(m_xRightIndent->normalize(nTmp), eUnit);
197 if ( aTmp.isEmpty() )
198 m_xRightIndent->set_text(OUString());
200 UpdateExample_Impl();
203 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl, weld::MetricSpinButton&, void)
205 ELRLoseFocus();
208 std::unique_ptr<SfxTabPage> SvxStdParagraphTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
210 return std::make_unique<SvxStdParagraphTabPage>(pPage, pController, *rSet);
213 bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
215 SfxItemState eState = SfxItemState::UNKNOWN;
216 const SfxPoolItem* pOld = nullptr;
217 SfxItemPool* pPool = rOutSet->GetPool();
218 DBG_ASSERT( pPool, "Where is the pool?" );
220 bool bModified = false;
221 sal_uInt16 nWhich;
222 int nPos = m_xLineDist->get_active();
224 if ( nPos != -1 &&
225 ( m_bLineDistToggled ||
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 = SfxViewFrame::Current()->GetPool().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 ( m_bLineDistToggled ||
265 !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) ||
266 SfxItemState::DONTCARE == eState )
268 rOutSet->Put( aSpacing );
269 bModified = true;
273 if ( m_xTopDist->get_value_changed_from_saved() || m_xBottomDist->get_value_changed_from_saved()
274 || m_xContextualCB->get_state_changed_from_saved())
276 nWhich = GetWhich( SID_ATTR_ULSPACE );
277 MapUnit eUnit = pPool->GetMetric( nWhich );
278 pOld = GetOldItem( *rOutSet, SID_ATTR_ULSPACE );
279 SvxULSpaceItem aMargin( nWhich );
281 if ( bRelativeMode )
283 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
285 const SvxULSpaceItem& rOldItem =
286 static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
288 if ( m_xTopDist->IsRelative() )
289 aMargin.SetUpper( rOldItem.GetUpper(),
290 static_cast<sal_uInt16>(m_xTopDist->get_value(FieldUnit::NONE)) );
291 else
292 aMargin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit)) );
294 if ( m_xBottomDist->IsRelative() )
295 aMargin.SetLower( rOldItem.GetLower(),
296 static_cast<sal_uInt16>(m_xBottomDist->get_value(FieldUnit::NONE)) );
297 else
298 aMargin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit)) );
301 else
303 aMargin.SetUpper(static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit)));
304 aMargin.SetLower(static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit)));
306 aMargin.SetContextValue(m_xContextualCB->get_active());
307 eState = GetItemSet().GetItemState( nWhich );
309 if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin ||
310 SfxItemState::DONTCARE == eState )
312 rOutSet->Put( aMargin );
313 bModified = true;
316 bool bNullTab = false;
318 if ( m_xLeftIndent->get_value_changed_from_saved() ||
319 m_xFLineIndent->get_value_changed_from_saved() ||
320 m_xRightIndent->get_value_changed_from_saved() ||
321 m_xAutoCB->get_state_changed_from_saved() )
323 nWhich = GetWhich( SID_ATTR_LRSPACE );
324 MapUnit eUnit = pPool->GetMetric( nWhich );
325 SvxLRSpaceItem aMargin( nWhich );
326 pOld = GetOldItem( *rOutSet, SID_ATTR_LRSPACE );
328 if ( bRelativeMode )
330 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
332 const SvxLRSpaceItem& rOldItem =
333 static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
335 if (m_xLeftIndent->IsRelative())
336 aMargin.SetTextLeft( rOldItem.GetTextLeft(),
337 static_cast<sal_uInt16>(m_xLeftIndent->get_value(FieldUnit::NONE)) );
338 else
339 aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit));
341 if ( m_xRightIndent->IsRelative() )
342 aMargin.SetRight( rOldItem.GetRight(),
343 static_cast<sal_uInt16>(m_xRightIndent->get_value(FieldUnit::NONE)) );
344 else
345 aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit));
347 if ( m_xFLineIndent->IsRelative() )
348 aMargin.SetTextFirstLineOfst( rOldItem.GetTextFirstLineOfst(),
349 static_cast<sal_uInt16>(m_xFLineIndent->get_value(FieldUnit::NONE)) );
350 else
351 aMargin.SetTextFirstLineOfst(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit)));
353 else
355 aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit));
356 aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit));
357 aMargin.SetTextFirstLineOfst(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit)));
359 aMargin.SetAutoFirst(m_xAutoCB->get_active());
360 if ( aMargin.GetTextFirstLineOfst() < 0 )
361 bNullTab = true;
362 eState = GetItemSet().GetItemState( nWhich );
364 if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin ||
365 SfxItemState::DONTCARE == eState )
367 rOutSet->Put( aMargin );
368 bModified = true;
372 if ( bNullTab )
374 MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
375 if ( MapUnit::Map100thMM != eUnit )
378 // negative first line indent -> set null default tabstob if applicable
379 sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
380 const SfxItemSet& rInSet = GetItemSet();
382 if ( rInSet.GetItemState( _nWhich ) >= SfxItemState::DEFAULT )
384 const SvxTabStopItem& rTabItem =
385 static_cast<const SvxTabStopItem&>(rInSet.Get( _nWhich ));
386 SvxTabStopItem aNullTab( rTabItem );
387 SvxTabStop aNull( 0, SvxTabAdjust::Default );
388 aNullTab.Insert( aNull );
389 rOutSet->Put( aNullTab );
393 if (m_xRegisterCB->get_visible())
395 const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(GetOldItem(
396 *rOutSet, SID_ATTR_PARA_REGISTER));
397 if (!pBoolItem)
398 return bModified;
399 std::unique_ptr<SfxBoolItem> pRegItem(static_cast<SfxBoolItem*>(pBoolItem->Clone()));
400 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
401 bool bSet = pRegItem->GetValue();
403 if (m_xRegisterCB->get_active() != bSet)
405 pRegItem->SetValue(!bSet);
406 rOutSet->Put(*pRegItem);
407 bModified = true;
409 else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) )
410 rOutSet->ClearItem(_nWhich);
413 return bModified;
416 void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet )
418 SfxItemPool* pPool = rSet->GetPool();
419 DBG_ASSERT( pPool, "Where is the pool?" );
421 // adjust metric
422 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
424 bool bApplyCharUnit = GetApplyCharUnit( *rSet );
426 SvtCJKOptions aCJKOptions;
427 if(aCJKOptions.IsAsianTypographyEnabled() && bApplyCharUnit )
428 eFUnit = FieldUnit::CHAR;
430 m_xLeftIndent->SetFieldUnit(eFUnit);
431 m_xRightIndent->SetFieldUnit(eFUnit);
432 m_xFLineIndent->SetFieldUnit(eFUnit);
433 if ( eFUnit == FieldUnit::CHAR )
435 m_xTopDist->SetFieldUnit(FieldUnit::LINE);
436 m_xBottomDist->SetFieldUnit(FieldUnit::LINE);
437 SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT);
439 else
441 m_xTopDist->SetFieldUnit(eFUnit);
442 m_xBottomDist->SetFieldUnit(eFUnit);
443 SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit);
446 sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
447 SfxItemState eItemState = rSet->GetItemState( _nWhich );
449 if ( eItemState >= SfxItemState::DEFAULT )
451 MapUnit eUnit = pPool->GetMetric( _nWhich );
453 if ( bRelativeMode )
455 const SvxLRSpaceItem& rOldItem =
456 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
458 if ( rOldItem.GetPropLeft() != 100 )
460 m_xLeftIndent->SetRelative( true );
461 m_xLeftIndent->set_value(rOldItem.GetPropLeft(), FieldUnit::NONE);
463 else
465 m_xLeftIndent->SetRelative(false);
466 m_xLeftIndent->SetFieldUnit(eFUnit);
467 m_xLeftIndent->SetMetricValue(rOldItem.GetTextLeft(), eUnit);
470 if ( rOldItem.GetPropRight() != 100 )
472 m_xRightIndent->SetRelative( true );
473 m_xRightIndent->set_value(rOldItem.GetPropRight(), FieldUnit::NONE);
475 else
477 m_xRightIndent->SetRelative(false);
478 m_xRightIndent->SetFieldUnit(eFUnit);
479 m_xRightIndent->SetMetricValue(rOldItem.GetRight(), eUnit);
482 if ( rOldItem.GetPropTextFirstLineOfst() != 100 )
484 m_xFLineIndent->SetRelative(true);
485 m_xFLineIndent->set_value(rOldItem.GetPropTextFirstLineOfst(), FieldUnit::NONE);
487 else
489 m_xFLineIndent->SetRelative(false);
490 m_xFLineIndent->set_min(-9999, FieldUnit::NONE);
491 m_xFLineIndent->SetFieldUnit(eFUnit);
492 m_xFLineIndent->SetMetricValue(rOldItem.GetTextFirstLineOfst(), eUnit);
494 m_xAutoCB->set_active(rOldItem.IsAutoFirst());
496 else
498 const SvxLRSpaceItem& rSpace =
499 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
501 m_xLeftIndent->SetMetricValue(rSpace.GetTextLeft(), eUnit);
502 m_xRightIndent->SetMetricValue(rSpace.GetRight(), eUnit);
503 m_xFLineIndent->SetMetricValue(rSpace.GetTextFirstLineOfst(), eUnit);
504 m_xAutoCB->set_active(rSpace.IsAutoFirst());
506 AutoHdl_Impl(*m_xAutoCB);
508 else
510 m_xLeftIndent->set_text(OUString());
511 m_xRightIndent->set_text(OUString());
512 m_xFLineIndent->set_text(OUString());
515 _nWhich = GetWhich( SID_ATTR_ULSPACE );
516 eItemState = rSet->GetItemState( _nWhich );
518 if ( eItemState >= SfxItemState::DEFAULT )
520 MapUnit eUnit = pPool->GetMetric( _nWhich );
522 const SvxULSpaceItem& rOldItem =
523 static_cast<const SvxULSpaceItem&>(rSet->Get( _nWhich ));
524 if ( bRelativeMode )
527 if ( rOldItem.GetPropUpper() != 100 )
529 m_xTopDist->SetRelative( true );
530 m_xTopDist->set_value(rOldItem.GetPropUpper(), FieldUnit::NONE);
532 else
534 m_xTopDist->SetRelative(false);
535 if (eFUnit == FieldUnit::CHAR)
536 m_xTopDist->SetFieldUnit(FieldUnit::LINE);
537 else
538 m_xTopDist->SetFieldUnit(eFUnit);
539 m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit);
542 if ( rOldItem.GetPropLower() != 100 )
544 m_xBottomDist->SetRelative( true );
545 m_xBottomDist->set_value(rOldItem.GetPropLower(), FieldUnit::NONE);
547 else
549 m_xBottomDist->SetRelative(false);
550 if (eFUnit == FieldUnit::CHAR)
551 m_xBottomDist->SetFieldUnit(FieldUnit::LINE);
552 else
553 m_xBottomDist->SetFieldUnit(eFUnit);
554 m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit);
557 else
559 m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit);
560 m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit);
562 m_xContextualCB->set_active(rOldItem.GetContext());
564 else
566 m_xTopDist->set_text(OUString());
567 m_xBottomDist->set_text(OUString());
570 _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
571 eItemState = rSet->GetItemState( _nWhich );
573 if ( eItemState >= SfxItemState::DEFAULT )
574 SetLineSpacing_Impl( static_cast<const SvxLineSpacingItem &>(rSet->Get( _nWhich )) );
575 else
576 m_xLineDist->set_active(-1);
578 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
579 eItemState = rSet->GetItemState( _nWhich );
581 if ( eItemState >= SfxItemState::DEFAULT )
582 m_xRegisterCB->set_active( static_cast<const SfxBoolItem &>(rSet->Get( _nWhich )).GetValue());
583 m_xRegisterCB->save_state();
584 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
585 if(nHtmlMode & HTMLMODE_ON)
587 m_xRegisterFL->hide();
588 m_xRegisterCB->hide();
589 m_xAutoCB->hide();
592 // this sets the min/max limits; do this _after_ setting the values,
593 // because for Impress the min of first-line indent depends on value of
594 // left-indent!
595 ELRLoseFocus();
596 ChangesApplied();
599 void SvxStdParagraphTabPage::ChangesApplied()
601 m_xLeftIndent->save_value();
602 m_xRightIndent->save_value();
603 m_xFLineIndent->save_value();
604 m_xLineDist->save_value();
605 m_xLineDistAtPercentBox->save_value();
606 m_xLineDistAtMetricBox->save_value();
607 m_xRegisterCB->save_state();
608 m_xTopDist->save_value();
609 m_xBottomDist->save_value();
610 m_xContextualCB->save_state();
611 m_xAutoCB->save_state();
614 void SvxStdParagraphTabPage::EnableRelativeMode()
616 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );
618 m_xLeftIndent->EnableRelativeMode( 0, 999 );
619 m_xFLineIndent->EnableRelativeMode( 0, 999 );
620 m_xRightIndent->EnableRelativeMode( 0, 999 );
621 m_xTopDist->EnableRelativeMode( 0, 999 );
622 m_xBottomDist->EnableRelativeMode( 0, 999 );
623 bRelativeMode = true;
626 void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet )
628 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
629 SfxItemState eItemState = rSet.GetItemState( _nWhich );
631 if ( eItemState >= SfxItemState::DEFAULT )
633 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>( rSet.Get( _nWhich ) );
634 SvxAdjust eAdjust = rAdj.GetAdjust();
635 if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block )
637 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
638 eItemState = rSet.GetItemState( _nWhich );
640 if ( eItemState >= SfxItemState::DEFAULT )
642 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet.Get( _nWhich ) );
643 SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue();
645 m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection );
647 if ( eAdjust == SvxAdjust::Block )
648 m_aExampleWin.SetLastLine( rAdj.GetLastBlock() );
651 else
653 m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right );
654 eAdjust = SvxAdjust::Left; //required for correct preview display
655 m_aExampleWin.SetLastLine( eAdjust );
657 m_aExampleWin.SetAdjust( eAdjust );
659 UpdateExample_Impl();
663 DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
665 ELRLoseFocus();
667 if ( _pSet )
668 FillItemSet( _pSet );
669 return DeactivateRC::LeavePage;
672 SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
673 : SfxTabPage(pPage, pController, "cui/ui/paraindentspacing.ui", "ParaIndentSpacing", &rAttr)
674 , nWidth(11905 /*567 * 50*/)
675 , nMinFixDist(0)
676 , bRelativeMode(false)
677 , m_xLeftIndent(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_LEFTINDENT", FieldUnit::CM)))
678 , m_xRightLabel(m_xBuilder->weld_label("labelFT_RIGHTINDENT"))
679 , m_xRightIndent(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_RIGHTINDENT", FieldUnit::CM)))
680 , m_xFLineLabel(m_xBuilder->weld_label("labelFT_FLINEINDENT"))
681 , m_xFLineIndent(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_FLINEINDENT", FieldUnit::CM)))
682 , m_xAutoCB(m_xBuilder->weld_check_button("checkCB_AUTO"))
683 , m_xTopDist(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_TOPDIST", FieldUnit::CM)))
684 , m_xBottomDist(new RelativeField(m_xBuilder->weld_metric_spin_button("spinED_BOTTOMDIST", FieldUnit::CM)))
685 , m_xContextualCB(m_xBuilder->weld_check_button("checkCB_CONTEXTUALSPACING"))
686 , m_xLineDist(m_xBuilder->weld_combo_box("comboLB_LINEDIST"))
687 , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTPERCENT", FieldUnit::PERCENT))
688 , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTMETRIC", FieldUnit::CM))
689 , m_xLineDistAtLabel(m_xBuilder->weld_label("labelFT_LINEDIST"))
690 , m_xAbsDist(m_xBuilder->weld_label("labelST_LINEDIST_ABS"))
691 , m_xRegisterFL(m_xBuilder->weld_widget("frameFL_REGISTER"))
692 , m_xRegisterCB(m_xBuilder->weld_check_button("checkCB_REGISTER"))
693 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin))
695 sAbsDist = m_xAbsDist->get_label();
697 // this page needs ExchangeSupport
698 SetExchangeSupport();
700 m_xLineDistAtMetricBox->hide();
702 Init_Impl();
703 m_xFLineIndent->set_min(-9999, FieldUnit::NONE); // is set to 0 on default
706 SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
710 void SvxStdParagraphTabPage::EnableNegativeMode()
712 m_xLeftIndent->set_min(-9999, FieldUnit::NONE);
713 m_xRightIndent->set_min(-9999, FieldUnit::NONE);
714 m_xRightIndent->EnableNegativeMode();
715 m_xLeftIndent->EnableNegativeMode();
718 void SvxStdParagraphTabPage::SetLineSpacing_Impl
720 const SvxLineSpacingItem &rAttr
723 MapUnit eUnit = SfxViewFrame::Current()->GetPool().GetMetric( rAttr.Which() );
725 switch( rAttr.GetLineSpaceRule() )
727 case SvxLineSpaceRule::Auto:
729 SvxInterLineSpaceRule eInter = rAttr.GetInterLineSpaceRule();
731 switch( eInter )
733 // Default single line spacing
734 case SvxInterLineSpaceRule::Off:
735 m_xLineDist->set_active( LLINESPACE_1 );
736 break;
738 // Default single line spacing
739 case SvxInterLineSpaceRule::Prop:
740 if ( 100 == rAttr.GetPropLineSpace() )
742 m_xLineDist->set_active( LLINESPACE_1 );
743 break;
745 // 1.15 line spacing
746 if ( 115 == rAttr.GetPropLineSpace() )
748 m_xLineDist->set_active( LLINESPACE_115 );
749 break;
751 // 1.5 line spacing
752 if ( 150 == rAttr.GetPropLineSpace() )
754 m_xLineDist->set_active( LLINESPACE_15 );
755 break;
757 // double line spacing
758 if ( 200 == rAttr.GetPropLineSpace() )
760 m_xLineDist->set_active( LLINESPACE_2 );
761 break;
763 // the set per cent value
764 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(rAttr.GetPropLineSpace()), FieldUnit::NONE);
765 m_xLineDist->set_active( LLINESPACE_PROP );
766 break;
768 case SvxInterLineSpaceRule::Fix:
769 SetMetricValue( *m_xLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
770 m_xLineDist->set_active( LLINESPACE_DURCH );
771 break;
772 default: ;//prevent warning
775 break;
776 case SvxLineSpaceRule::Fix:
777 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
778 m_xLineDist->set_active( LLINESPACE_FIX );
779 break;
781 case SvxLineSpaceRule::Min:
782 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
783 m_xLineDist->set_active( LLINESPACE_MIN );
784 break;
785 default: ;//prevent warning
787 LineDistHdl_Impl( *m_xLineDist );
790 IMPL_LINK_NOARG(SvxStdParagraphTabPage, LineDistPopupHdl_Impl, weld::ComboBox&, void)
792 m_bLineDistToggled = true;
795 IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void)
797 switch (rBox.get_active())
799 case LLINESPACE_1:
800 case LLINESPACE_115:
801 case LLINESPACE_15:
802 case LLINESPACE_2:
803 m_xLineDistAtLabel->set_sensitive(false);
804 m_xLineDistAtPercentBox->set_sensitive(false);
805 m_xLineDistAtPercentBox->set_text(OUString());
806 m_xLineDistAtMetricBox->set_sensitive(false);
807 m_xLineDistAtMetricBox->set_text(OUString());
808 break;
810 case LLINESPACE_DURCH:
811 // setting a sensible default?
812 // limit MS min(10, aPageSize)
813 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
815 if (m_xLineDistAtMetricBox->get_text().isEmpty())
816 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE);
817 m_xLineDistAtPercentBox->hide();
818 m_xLineDistAtMetricBox->show();
819 m_xLineDistAtMetricBox->set_sensitive(true);
820 m_xLineDistAtLabel->set_sensitive(true);
821 break;
823 case LLINESPACE_MIN:
824 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
826 if (m_xLineDistAtMetricBox->get_text().isEmpty())
827 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP);
828 m_xLineDistAtPercentBox->hide();
829 m_xLineDistAtMetricBox->show();
830 m_xLineDistAtMetricBox->set_sensitive(true);
831 m_xLineDistAtLabel->set_sensitive(true);
832 break;
834 case LLINESPACE_PROP:
836 if (m_xLineDistAtPercentBox->get_text().isEmpty())
837 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP);
838 m_xLineDistAtMetricBox->hide();
839 m_xLineDistAtPercentBox->show();
840 m_xLineDistAtPercentBox->set_sensitive(true);
841 m_xLineDistAtLabel->set_sensitive(true);
842 break;
843 case LLINESPACE_FIX:
845 auto nTemp = m_xLineDistAtMetricBox->get_value(FieldUnit::NONE);
846 m_xLineDistAtMetricBox->set_min(m_xLineDistAtMetricBox->normalize(nMinFixDist), FieldUnit::TWIP);
848 // if the value has been changed at SetMin,
849 // it is time for the default
850 if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp)
851 SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer
852 m_xLineDistAtPercentBox->hide();
853 m_xLineDistAtMetricBox->show();
854 m_xLineDistAtMetricBox->set_sensitive(true);
855 m_xLineDistAtLabel->set_sensitive(true);
857 break;
859 UpdateExample_Impl();
862 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ModifyHdl_Impl, weld::MetricSpinButton&, void)
864 UpdateExample_Impl();
867 void SvxStdParagraphTabPage::Init_Impl()
869 m_xLineDist->connect_popup_toggled(LINK(this, SvxStdParagraphTabPage, LineDistPopupHdl_Impl));
870 m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl));
872 Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl);
873 m_xFLineIndent->connect_value_changed(aLink2);
874 m_xLeftIndent->connect_value_changed(aLink2);
875 m_xRightIndent->connect_value_changed(aLink2);
877 Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl);
878 m_xTopDist->connect_value_changed(aLink);
879 m_xBottomDist->connect_value_changed(aLink);
881 m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl));
882 SfxItemPool* pPool = GetItemSet().GetPool();
883 DBG_ASSERT( pPool, "Where is the pool?" );
884 FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
886 m_xTopDist->set_max( m_xTopDist->normalize( MAX_DURCH ), eUnit );
887 m_xBottomDist->set_max( m_xBottomDist->normalize( MAX_DURCH ), eUnit );
888 m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit );
891 void SvxStdParagraphTabPage::UpdateExample_Impl()
893 m_aExampleWin.SetFirstLineOfst( static_cast<short>(m_xFLineIndent->denormalize( m_xFLineIndent->get_value( FieldUnit::TWIP ) )) );
894 m_aExampleWin.SetLeftMargin( static_cast<long>(m_xLeftIndent->denormalize( m_xLeftIndent->get_value( FieldUnit::TWIP ) ) ) );
895 m_aExampleWin.SetRightMargin( static_cast<long>(m_xRightIndent->denormalize( m_xRightIndent->get_value( FieldUnit::TWIP ) ) ) );
896 m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->denormalize( m_xTopDist->get_value( FieldUnit::TWIP ) )) );
897 m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->denormalize( m_xBottomDist->get_value( FieldUnit::TWIP ) )) );
899 int nPos = m_xLineDist->get_active();
901 switch ( nPos )
903 case LLINESPACE_1:
904 case LLINESPACE_115:
905 case LLINESPACE_15:
906 case LLINESPACE_2:
907 case LLINESPACE_PROP:
908 case LLINESPACE_MIN:
909 case LLINESPACE_DURCH:
910 case LLINESPACE_FIX:
911 m_aExampleWin.SetLineSpace( static_cast<SvxPrevLineSpace>(nPos) );
912 break;
914 m_aExampleWin.Invalidate();
917 void SvxStdParagraphTabPage::EnableRegisterMode()
919 m_xRegisterCB->show();
920 m_xRegisterFL->show();
923 void SvxStdParagraphTabPage::EnableContextualMode()
925 m_xContextualCB->show();
928 IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::ToggleButton&, rBox, void)
930 bool bEnable = !rBox.get_active();
931 m_xFLineLabel->set_sensitive(bEnable);
932 m_xFLineIndent->set_sensitive(bEnable);
935 void SvxStdParagraphTabPage::EnableAutoFirstLine()
937 m_xAutoCB->show();
940 void SvxStdParagraphTabPage::EnableAbsLineDist(long nMinTwip)
942 m_xLineDist->append_text(sAbsDist);
943 nMinFixDist = nMinTwip;
946 void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
949 /* different bit represent call to different method of SvxStdParagraphTabPage
950 0x0001 --->EnableRelativeMode()
951 0x0002 --->EnableRegisterMode()
952 0x0004 --->EnableAutoFirstLine()
953 0x0008 --->EnableNegativeMode()
954 0x0010 --->EnableContextualMode()
956 const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false);
957 const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false);
958 const SfxUInt32Item* pLineDistItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, false);
960 if (pPageWidthItem)
961 nWidth = pPageWidthItem->GetValue();
963 if (pFlagSetItem )
965 if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
966 EnableRelativeMode();
968 if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
969 EnableRegisterMode();
971 if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
972 EnableAutoFirstLine();
975 if(pLineDistItem)
976 EnableAbsLineDist(pLineDistItem->GetValue());
978 if (pFlagSetItem)
980 if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
981 EnableNegativeMode();
983 if (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
984 EnableContextualMode();
988 #define LASTLINEPOS_DEFAULT 0
989 #define LASTLINEPOS_LEFT 1
991 #define LASTLINECOUNT_OLD 3
992 #define LASTLINECOUNT_NEW 4
994 SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
995 : SfxTabPage(pPage, pController, "cui/ui/paragalignpage.ui", "ParaAlignPage", &rSet)
996 , m_xLeft(m_xBuilder->weld_radio_button("radioBTN_LEFTALIGN"))
997 , m_xRight(m_xBuilder->weld_radio_button("radioBTN_RIGHTALIGN"))
998 , m_xCenter(m_xBuilder->weld_radio_button("radioBTN_CENTERALIGN"))
999 , m_xJustify(m_xBuilder->weld_radio_button("radioBTN_JUSTIFYALIGN"))
1000 , m_xLeftBottom(m_xBuilder->weld_label("labelST_LEFTALIGN_ASIAN"))
1001 , m_xRightTop(m_xBuilder->weld_label("labelST_RIGHTALIGN_ASIAN"))
1002 , m_xLastLineFT(m_xBuilder->weld_label("labelLB_LASTLINE"))
1003 , m_xLastLineLB(m_xBuilder->weld_combo_box("comboLB_LASTLINE"))
1004 , m_xExpandCB(m_xBuilder->weld_check_button("checkCB_EXPAND"))
1005 , m_xSnapToGridCB(m_xBuilder->weld_check_button("checkCB_SNAP"))
1006 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin))
1007 , m_xVertAlignFL(m_xBuilder->weld_widget("frameFL_VERTALIGN"))
1008 , m_xVertAlignLB(m_xBuilder->weld_combo_box("comboLB_VERTALIGN"))
1009 , m_xPropertiesFL(m_xBuilder->weld_widget("framePROPERTIES"))
1010 , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboLB_TEXTDIRECTION")))
1012 SetExchangeSupport();
1014 SvtLanguageOptions aLangOptions;
1015 sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;
1017 if ( aLangOptions.IsAsianTypographyEnabled() )
1019 m_xLeft->set_label(m_xLeftBottom->get_label());
1020 m_xRight->set_label(m_xRightTop->get_label());
1022 OUString sLeft(m_xLeft->get_label());
1023 sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );
1025 if (m_xLastLineLB->get_count() == LASTLINECOUNT_OLD)
1027 m_xLastLineLB->remove(0);
1028 m_xLastLineLB->insert_text(0, sLeft);
1030 else
1031 nLastLinePos = LASTLINEPOS_LEFT;
1034 // remove "Default" or "Left" entry, depends on CJKOptions
1035 if (m_xLastLineLB->get_count() == LASTLINECOUNT_NEW)
1036 m_xLastLineLB->remove(nLastLinePos);
1038 Link<weld::ToggleButton&, void> aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
1039 m_xLeft->connect_toggled(aLink);
1040 m_xRight->connect_toggled(aLink);
1041 m_xCenter->connect_toggled(aLink);
1042 m_xJustify->connect_toggled(aLink);
1043 m_xLastLineLB->connect_changed(LINK(this, SvxParaAlignTabPage, LastLineHdl_Impl));
1044 m_xTextDirectionLB->connect_changed(LINK(this, SvxParaAlignTabPage, TextDirectionHdl_Impl));
1046 m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
1047 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
1048 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
1051 SvxParaAlignTabPage::~SvxParaAlignTabPage()
1055 DeactivateRC SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
1057 if ( _pSet )
1058 FillItemSet( _pSet );
1059 return DeactivateRC::LeavePage;
1062 std::unique_ptr<SfxTabPage> SvxParaAlignTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1064 return std::make_unique<SvxParaAlignTabPage>(pPage, pController, *rSet);
1067 bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet )
1069 bool bModified = false;
1071 bool bAdj = false;
1072 SvxAdjust eAdjust = SvxAdjust::Left;
1074 if (m_xLeft->get_active())
1076 eAdjust = SvxAdjust::Left;
1077 bAdj = m_xLeft->get_saved_state() == TRISTATE_FALSE;
1079 else if (m_xRight->get_active())
1081 eAdjust = SvxAdjust::Right;
1082 bAdj = m_xRight->get_saved_state() == TRISTATE_FALSE;
1084 else if (m_xCenter->get_active())
1086 eAdjust = SvxAdjust::Center;
1087 bAdj = m_xCenter->get_saved_state() == TRISTATE_FALSE;
1089 else if (m_xJustify->get_active())
1091 eAdjust = SvxAdjust::Block;
1092 bAdj = m_xJustify->get_saved_state() == TRISTATE_FALSE ||
1093 m_xExpandCB->get_state_changed_from_saved() ||
1094 m_xLastLineLB->get_value_changed_from_saved();
1097 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1099 if (bAdj)
1101 SvxAdjust eOneWord = m_xExpandCB->get_active() ? SvxAdjust::Block : SvxAdjust::Left;
1103 int nLBPos = m_xLastLineLB->get_active();
1104 SvxAdjust eLastBlock = SvxAdjust::Left;
1105 if ( 1 == nLBPos )
1106 eLastBlock = SvxAdjust::Center;
1107 else if ( 2 == nLBPos )
1108 eLastBlock = SvxAdjust::Block;
1110 SvxAdjustItem aAdj( static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) );
1111 aAdj.SetAdjust( eAdjust );
1112 aAdj.SetOneWord( eOneWord );
1113 aAdj.SetLastBlock( eLastBlock );
1114 rOutSet->Put( aAdj );
1115 bModified = true;
1118 if (m_xSnapToGridCB->get_state_changed_from_saved())
1120 rOutSet->Put(SvxParaGridItem(m_xSnapToGridCB->get_active(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
1121 bModified = true;
1124 if (m_xVertAlignLB->get_value_changed_from_saved())
1126 rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN )));
1127 bModified = true;
1130 if (m_xTextDirectionLB->get_visible())
1132 if (m_xTextDirectionLB->get_value_changed_from_saved())
1134 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1135 rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
1136 bModified = true;
1140 return bModified;
1143 void SvxParaAlignTabPage::ActivatePage( const SfxItemSet& rSet )
1145 Reset( &rSet );
1148 void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet )
1150 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1151 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1153 sal_Int32 nLBSelect = 0;
1154 if ( eItemState >= SfxItemState::DEFAULT )
1156 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>(rSet->Get( _nWhich ));
1158 switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
1160 case SvxAdjust::Left: m_xLeft->set_active(true); break;
1162 case SvxAdjust::Right: m_xRight->set_active(true); break;
1164 case SvxAdjust::Center: m_xCenter->set_active(true); break;
1166 case SvxAdjust::Block: m_xJustify->set_active(true); break;
1167 default: ; //prevent warning
1169 bool bEnable = m_xJustify->get_active();
1170 m_xLastLineFT->set_sensitive(bEnable);
1171 m_xLastLineLB->set_sensitive(bEnable);
1173 switch(rAdj.GetLastBlock())
1175 case SvxAdjust::Left: nLBSelect = 0; break;
1177 case SvxAdjust::Center: nLBSelect = 1; break;
1179 case SvxAdjust::Block: nLBSelect = 2; break;
1180 default: ; //prevent warning
1182 m_xExpandCB->set_sensitive(bEnable && nLBSelect == 2);
1183 m_xExpandCB->set_active(SvxAdjust::Block == rAdj.GetOneWord());
1185 else
1187 m_xLeft->set_active(false);
1188 m_xRight->set_active(false);
1189 m_xCenter->set_active(false);
1190 m_xJustify->set_active(false);
1192 m_xLastLineLB->set_active(nLBSelect);
1194 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
1195 if(nHtmlMode & HTMLMODE_ON)
1197 m_xLastLineLB->hide();
1198 m_xLastLineFT->hide();
1199 m_xExpandCB->hide();
1200 if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
1201 m_xJustify->set_sensitive(false);
1202 m_xSnapToGridCB->hide();
1204 _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
1205 eItemState = rSet->GetItemState( _nWhich );
1206 if ( eItemState >= SfxItemState::DEFAULT )
1208 const SvxParaGridItem& rSnap = static_cast<const SvxParaGridItem&>(rSet->Get( _nWhich ));
1209 m_xSnapToGridCB->set_active(rSnap.GetValue());
1212 _nWhich = GetWhich( SID_PARA_VERTALIGN );
1213 eItemState = rSet->GetItemState( _nWhich );
1215 if ( eItemState >= SfxItemState::DEFAULT )
1217 m_xVertAlignFL->show();
1219 const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich ));
1221 m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue()));
1224 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
1225 //text direction
1226 if( SfxItemState::DEFAULT <= rSet->GetItemState( _nWhich ) )
1228 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet->Get( _nWhich ) );
1229 m_xTextDirectionLB->set_active_id(rFrameDirItem.GetValue());
1230 m_xTextDirectionLB->save_value();
1233 m_xSnapToGridCB->save_state();
1234 m_xVertAlignLB->save_value();
1235 m_xLeft->save_state();
1236 m_xRight->save_state();
1237 m_xCenter->save_state();
1238 m_xJustify->save_state();
1239 m_xLastLineLB->save_value();
1240 m_xExpandCB->save_state();
1242 UpdateExample_Impl();
1245 void SvxParaAlignTabPage::ChangesApplied()
1247 m_xTextDirectionLB->save_value();
1248 m_xSnapToGridCB->save_state();
1249 m_xVertAlignLB->save_value();
1250 m_xLeft->save_state();
1251 m_xRight->save_state();
1252 m_xCenter->save_state();
1253 m_xJustify->save_state();
1254 m_xLastLineLB->save_value();
1255 m_xExpandCB->save_state();
1258 IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl, weld::ToggleButton&, void)
1260 bool bJustify = m_xJustify->get_active();
1261 m_xLastLineFT->set_sensitive(bJustify);
1262 m_xLastLineLB->set_sensitive(bJustify);
1263 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1264 m_xExpandCB->set_sensitive(bJustify && bLastLineIsBlock);
1265 //set last line listbox to entry position 0 if not enabled
1266 if (!m_xLastLineLB->get_sensitive())
1267 m_xLastLineLB->set_active(0);
1268 //uncheck 'Expand ... word' when check box is not enabled
1269 if (!m_xExpandCB->get_sensitive())
1270 m_xExpandCB->set_active(false);
1271 UpdateExample_Impl();
1274 IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl, weld::ComboBox&, void)
1276 //fdo#41350 only enable 'Expand last word' if last line is also justified
1277 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1278 m_xExpandCB->set_sensitive(bLastLineIsBlock);
1279 //uncheck 'Expand ... word' when check box is not enabled
1280 if (!m_xExpandCB->get_sensitive())
1281 m_xExpandCB->set_active(false);
1282 UpdateExample_Impl();
1285 IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl, weld::ComboBox&, void)
1287 UpdateExample_Impl();
1290 void SvxParaAlignTabPage::UpdateExample_Impl()
1292 if (m_xLeft->get_active())
1294 m_aExampleWin.EnableRTL(false);
1295 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1296 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1298 else if (m_xRight->get_active())
1300 m_aExampleWin.EnableRTL(true);
1301 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1302 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1304 else
1306 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1307 switch ( eDir )
1309 case SvxFrameDirection::Environment :
1310 if ( !m_xRight->get_active() )
1311 m_aExampleWin.EnableRTL( AllSettings::GetLayoutRTL() );
1312 break;
1313 case SvxFrameDirection::Horizontal_RL_TB :
1314 if ( !m_xLeft->get_active() )
1315 m_aExampleWin.EnableRTL( true );
1316 break;
1317 case SvxFrameDirection::Horizontal_LR_TB :
1318 if ( !m_xRight->get_active() )
1319 m_aExampleWin.EnableRTL( false );
1320 break;
1321 default: ; //prevent warning
1323 if (m_xCenter->get_active())
1324 m_aExampleWin.SetAdjust( SvxAdjust::Center );
1325 else if (m_xJustify->get_active())
1327 m_aExampleWin.SetAdjust( SvxAdjust::Block );
1328 int nLBPos = m_xLastLineLB->get_active();
1329 if (nLBPos == 0)
1330 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1331 else if (nLBPos == 1)
1332 m_aExampleWin.SetLastLine(SvxAdjust::Center);
1333 else if (nLBPos == 2)
1334 m_aExampleWin.SetLastLine(SvxAdjust::Block);
1338 m_aExampleWin.Invalidate();
1341 void SvxParaAlignTabPage::EnableJustifyExt()
1343 m_xLastLineFT->show();
1344 m_xLastLineLB->show();
1345 m_xExpandCB->show();
1346 SvtLanguageOptions aCJKOptions;
1347 if (aCJKOptions.IsAsianTypographyEnabled())
1348 m_xSnapToGridCB->show();
1352 void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet)
1354 const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false);
1355 if (pBoolItem && pBoolItem->GetValue())
1356 EnableJustifyExt();
1359 std::unique_ptr<SfxTabPage> SvxExtParagraphTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1361 return std::make_unique<SvxExtParagraphTabPage>(pPage, pController, *rSet);
1364 bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
1366 bool bModified = false;
1367 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1368 const TriState eHyphenState = m_xHyphenBox->get_state();
1369 const SfxPoolItem* pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_HYPHENZONE );
1371 if ( m_xHyphenBox->get_state_changed_from_saved() ||
1372 m_xHyphenNoCapsBox->get_state_changed_from_saved() ||
1373 m_xExtHyphenBeforeBox->get_value_changed_from_saved() ||
1374 m_xExtHyphenAfterBox->get_value_changed_from_saved() ||
1375 m_xMaxHyphenEdit->get_value_changed_from_saved() )
1377 SvxHyphenZoneItem aHyphen(
1378 static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) );
1379 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1380 aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() == TRISTATE_TRUE);
1382 if ( eHyphenState == TRISTATE_TRUE )
1384 aHyphen.GetMinLead() = static_cast<sal_uInt8>(m_xExtHyphenBeforeBox->get_value());
1385 aHyphen.GetMinTrail() = static_cast<sal_uInt8>(m_xExtHyphenAfterBox->get_value());
1387 aHyphen.GetMaxHyphens() = static_cast<sal_uInt8>(m_xMaxHyphenEdit->get_value());
1389 if ( !pOld ||
1390 *static_cast<const SvxHyphenZoneItem*>(pOld) != aHyphen ||
1391 m_xHyphenBox->get_state_changed_from_saved())
1393 rOutSet->Put( aHyphen );
1394 bModified = true;
1398 if (m_xPageNumBox->get_sensitive()
1399 && (m_xPageNumBox->get_state_changed_from_saved() || m_xPagenumEdit->get_value_changed_from_saved()))
1401 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
1403 if (TRISTATE_TRUE == m_xPageNumBox->get_state()
1404 && (!pOld || IsInvalidItem(pOld)
1405 || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != m_xPagenumEdit->get_value()))
1407 SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM,
1408 static_cast<sal_uInt16>(m_xPagenumEdit->get_value()));
1409 rOutSet->Put( aPageNum );
1410 bModified = true;
1412 else if (TRISTATE_FALSE == m_xPageNumBox->get_state()
1413 && (pOld || IsInvalidItem(pOld)))
1415 // need to tell sw to remove the item
1416 rOutSet->DisableItem(SID_ATTR_PARA_PAGENUM);
1417 bModified = true;
1421 // pagebreak
1423 TriState eState = m_xApplyCollBtn->get_state();
1424 bool bIsPageModel = false;
1426 _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1427 OUString sPage;
1428 if ( m_xApplyCollBtn->get_state_changed_from_saved() ||
1429 ( TRISTATE_TRUE == eState &&
1430 m_xApplyCollBox->get_value_changed_from_saved() ) )
1432 if ( eState == TRISTATE_TRUE )
1434 sPage = m_xApplyCollBox->get_active_text();
1435 bIsPageModel = !sPage.isEmpty();
1437 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_MODEL );
1439 if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage )
1441 rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) );
1442 bModified = true;
1444 else
1445 bIsPageModel = false;
1447 else if(TRISTATE_TRUE == eState && m_xApplyCollBtn->get_sensitive())
1448 bIsPageModel = true;
1449 else
1450 rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) );
1452 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1454 if ( bIsPageModel )
1455 // if PageModel is turned on, always turn off PageBreak
1456 rOutSet->Put( SvxFormatBreakItem( SvxBreak::NONE, _nWhich ) );
1457 else
1459 eState = m_xPageBreakBox->get_state();
1460 SfxItemState eModelState = GetItemSet().GetItemState(SID_ATTR_PARA_MODEL, false);
1462 if ( (eModelState == SfxItemState::SET && TRISTATE_TRUE == m_xPageBreakBox->get_state()) ||
1463 m_xPageBreakBox->get_state_changed_from_saved() ||
1464 m_xBreakTypeLB->get_value_changed_from_saved() ||
1465 m_xBreakPositionLB->get_value_changed_from_saved() )
1467 const SvxFormatBreakItem rOldBreak(
1468 static_cast<const SvxFormatBreakItem&>(GetItemSet().Get( _nWhich )));
1469 SvxFormatBreakItem aBreak(rOldBreak.GetBreak(), rOldBreak.Which());
1471 switch ( eState )
1473 case TRISTATE_TRUE:
1475 bool bBefore = m_xBreakPositionLB->get_active() == 0;
1477 if (m_xBreakTypeLB->get_active() == 0)
1479 if ( bBefore )
1480 aBreak.SetValue( SvxBreak::PageBefore );
1481 else
1482 aBreak.SetValue( SvxBreak::PageAfter );
1484 else
1486 if ( bBefore )
1487 aBreak.SetValue( SvxBreak::ColumnBefore );
1488 else
1489 aBreak.SetValue( SvxBreak::ColumnAfter );
1491 break;
1494 case TRISTATE_FALSE:
1495 aBreak.SetValue( SvxBreak::NONE );
1496 break;
1497 default: ; //prevent warning
1499 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGEBREAK );
1501 if ( eState != m_xPageBreakBox->get_saved_state() ||
1502 !pOld || !( *static_cast<const SvxFormatBreakItem*>(pOld) == aBreak ) )
1504 bModified = true;
1505 rOutSet->Put( aBreak );
1510 // paragraph split
1511 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1512 eState = m_xKeepTogetherBox->get_state();
1514 if (m_xKeepTogetherBox->get_state_changed_from_saved())
1516 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_SPLIT );
1518 if ( !pOld || static_cast<const SvxFormatSplitItem*>(pOld)->GetValue() !=
1519 ( eState == TRISTATE_FALSE ) )
1521 rOutSet->Put( SvxFormatSplitItem( eState == TRISTATE_FALSE, _nWhich ) );
1522 bModified = true;
1526 // keep paragraphs
1527 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1528 eState = m_xKeepParaBox->get_state();
1530 if (m_xKeepParaBox->get_state_changed_from_saved())
1532 // if the status has changed, putting is necessary
1533 rOutSet->Put( SvxFormatKeepItem( eState == TRISTATE_TRUE, _nWhich ) );
1534 bModified = true;
1537 // widows and orphans
1538 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1539 eState = m_xWidowBox->get_state();
1541 if ( m_xWidowBox->get_state_changed_from_saved() ||
1542 m_xWidowRowNo->get_value_changed_from_saved() )
1544 SvxWidowsItem rItem( eState == TRISTATE_TRUE ?
1545 static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, _nWhich );
1546 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS );
1548 if ( m_xWidowBox->get_state_changed_from_saved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) )
1550 rOutSet->Put( rItem );
1551 bModified = true;
1555 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1556 eState = m_xOrphanBox->get_state();
1558 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1559 m_xOrphanRowNo->get_value_changed_from_saved() )
1561 SvxOrphansItem rItem( eState == TRISTATE_TRUE ?
1562 static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, _nWhich );
1563 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS );
1565 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1566 !pOld ||
1567 !( *static_cast<const SvxOrphansItem*>(pOld) == rItem ) )
1569 rOutSet->Put( rItem );
1570 bModified = true;
1574 return bModified;
1576 void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
1578 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1579 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1581 bool bItemAvailable = eItemState >= SfxItemState::DEFAULT;
1582 bool bIsHyphen = false;
1583 if( !bHtmlMode && bItemAvailable )
1585 const SvxHyphenZoneItem& rHyphen =
1586 static_cast<const SvxHyphenZoneItem&>(rSet->Get( _nWhich ));
1587 aHyphenState.bTriStateEnabled = false;
1589 bIsHyphen = rHyphen.IsHyphen();
1590 m_xHyphenBox->set_state(bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE);
1591 m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_TRUE : TRISTATE_FALSE);
1593 m_xExtHyphenBeforeBox->set_value(rHyphen.GetMinLead());
1594 m_xExtHyphenAfterBox->set_value(rHyphen.GetMinTrail());
1595 m_xMaxHyphenEdit->set_value(rHyphen.GetMaxHyphens());
1597 else
1599 m_xHyphenBox->set_state(TRISTATE_INDET);
1600 m_xHyphenNoCapsBox->set_state(TRISTATE_INDET);
1602 bool bEnable = bItemAvailable && bIsHyphen;
1603 m_xHyphenNoCapsBox->set_sensitive(bEnable);
1604 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
1605 m_xExtHyphenAfterBox->set_sensitive(bEnable);
1606 m_xBeforeText->set_sensitive(bEnable);
1607 m_xAfterText->set_sensitive(bEnable);
1608 m_xMaxHyphenLabel->set_sensitive(bEnable);
1609 m_xMaxHyphenEdit->set_sensitive(bEnable);
1611 _nWhich = GetWhich( SID_ATTR_PARA_PAGENUM );
1613 switch (rSet->GetItemState(_nWhich))
1615 case SfxItemState::SET:
1617 aPageNumState.bTriStateEnabled = false;
1618 m_xPageNumBox->set_state(TRISTATE_TRUE);
1619 SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(_nWhich));
1620 const sal_uInt16 nPageNum(pItem->GetValue());
1621 m_xPagenumEdit->set_value(nPageNum);
1622 break;
1624 case SfxItemState::DONTCARE:
1626 aPageNumState.bTriStateEnabled = true;
1627 m_xPageNumBox->set_state(TRISTATE_INDET);
1628 break;
1630 case SfxItemState::UNKNOWN:
1631 case SfxItemState::DEFAULT:
1632 case SfxItemState::DISABLED:
1634 aPageNumState.bTriStateEnabled = false;
1635 m_xPageNumBox->set_state(TRISTATE_FALSE);
1636 break;
1638 default:
1639 assert(false); // unexpected
1640 break;
1643 if ( bPageBreak )
1645 // first handle PageModel
1646 _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1647 bool bIsPageModel = false;
1648 eItemState = rSet->GetItemState( _nWhich );
1650 if ( eItemState >= SfxItemState::SET )
1652 aApplyCollState.bTriStateEnabled = false;
1654 const SvxPageModelItem& rModel =
1655 static_cast<const SvxPageModelItem&>(rSet->Get( _nWhich ));
1656 const OUString& aStr( rModel.GetValue() );
1658 if (!aStr.isEmpty() && m_xApplyCollBox->find_text(aStr) != -1)
1660 m_xApplyCollBox->set_active_text(aStr);
1661 m_xApplyCollBtn->set_state(TRISTATE_TRUE);
1662 bIsPageModel = true;
1664 m_xPageBreakBox->set_sensitive(true);
1665 aPageBreakState.bTriStateEnabled = false;
1666 m_xBreakTypeFT->set_sensitive(true);
1667 m_xBreakTypeLB->set_sensitive(true);
1668 m_xBreakPositionFT->set_sensitive(true);
1669 m_xBreakPositionLB->set_sensitive(true);
1670 m_xApplyCollBtn->set_sensitive(false);
1671 m_xPageBreakBox->set_state(TRISTATE_TRUE);
1673 //select page break
1674 m_xBreakTypeLB->set_active(0);
1675 //select break before
1676 m_xBreakPositionLB->set_active(0);
1678 else
1680 m_xApplyCollBox->set_active(-1);
1681 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
1684 else if ( SfxItemState::DONTCARE == eItemState )
1686 aApplyCollState.bTriStateEnabled = true;
1687 m_xApplyCollBtn->set_state(TRISTATE_INDET);
1688 m_xApplyCollBox->set_active(-1);
1690 else
1692 m_xApplyCollBtn->set_sensitive(false);
1693 m_xApplyCollBox->set_sensitive(false);
1694 m_xPagenumEdit->set_sensitive(false);
1695 m_xPageNumBox->set_sensitive(false);
1698 if ( !bIsPageModel )
1700 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1701 eItemState = rSet->GetItemState( _nWhich );
1703 if ( eItemState >= SfxItemState::DEFAULT )
1705 const SvxFormatBreakItem& rPageBreak =
1706 static_cast<const SvxFormatBreakItem&>(rSet->Get( _nWhich ));
1708 SvxBreak eBreak = rPageBreak.GetBreak();
1710 // PageBreak not via CTRL-RETURN,
1711 // then CheckBox can be freed
1712 m_xPageBreakBox->set_sensitive(true);
1713 aPageBreakState.bTriStateEnabled = false;
1714 m_xBreakTypeFT->set_sensitive(true);
1715 m_xBreakTypeLB->set_sensitive(true);
1716 m_xBreakPositionFT->set_sensitive(true);
1717 m_xBreakPositionLB->set_sensitive(true);
1719 m_xPageBreakBox->set_state(TRISTATE_TRUE);
1721 bool _bEnable = eBreak != SvxBreak::NONE &&
1722 eBreak != SvxBreak::ColumnBefore &&
1723 eBreak != SvxBreak::ColumnAfter;
1724 m_xApplyCollBtn->set_sensitive(_bEnable);
1725 if (!_bEnable)
1727 m_xApplyCollBox->set_sensitive(_bEnable);
1728 m_xPageNumBox->set_sensitive(false);
1729 m_xPagenumEdit->set_sensitive(_bEnable);
1732 if ( eBreak == SvxBreak::NONE )
1733 m_xPageBreakBox->set_state(TRISTATE_FALSE);
1735 sal_Int32 nType = 0; // selection position in break type ListBox : Page
1736 sal_Int32 nPosition = 0; // selection position in break position ListBox : Before
1737 switch ( eBreak )
1739 case SvxBreak::PageBefore:
1740 break;
1741 case SvxBreak::PageAfter:
1742 nPosition = 1;
1743 break;
1744 case SvxBreak::ColumnBefore:
1745 nType = 1;
1746 break;
1747 case SvxBreak::ColumnAfter:
1748 nType = 1;
1749 nPosition = 1;
1750 break;
1751 default: ;//prevent warning
1753 m_xBreakTypeLB->set_active(nType);
1754 m_xBreakPositionLB->set_active(nPosition);
1756 else if ( SfxItemState::DONTCARE == eItemState )
1757 m_xPageBreakBox->set_state(TRISTATE_INDET);
1758 else
1760 m_xPageBreakBox->set_sensitive(false);
1761 m_xBreakTypeFT->set_sensitive(false);
1762 m_xBreakTypeLB->set_sensitive(false);
1763 m_xBreakPositionFT->set_sensitive(false);
1764 m_xBreakPositionLB->set_sensitive(false);
1768 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
1769 PageBreakHdl();
1772 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1773 eItemState = rSet->GetItemState( _nWhich );
1775 if ( eItemState >= SfxItemState::DEFAULT )
1777 aKeepParaState.bTriStateEnabled = false;
1778 const SvxFormatKeepItem& rKeep =
1779 static_cast<const SvxFormatKeepItem&>(rSet->Get( _nWhich ));
1781 if ( rKeep.GetValue() )
1782 m_xKeepParaBox->set_state(TRISTATE_TRUE);
1783 else
1784 m_xKeepParaBox->set_state(TRISTATE_FALSE);
1786 else if ( SfxItemState::DONTCARE == eItemState )
1787 m_xKeepParaBox->set_state(TRISTATE_INDET);
1788 else
1789 m_xKeepParaBox->set_sensitive(false);
1791 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1792 eItemState = rSet->GetItemState( _nWhich );
1794 if ( eItemState >= SfxItemState::DEFAULT )
1796 const SvxFormatSplitItem& rSplit =
1797 static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich ));
1798 aKeepTogetherState.bTriStateEnabled = false;
1800 if ( !rSplit.GetValue() )
1801 m_xKeepTogetherBox->set_state(TRISTATE_TRUE);
1802 else
1804 m_xKeepTogetherBox->set_state(TRISTATE_FALSE);
1806 // widows and orphans
1807 m_xWidowBox->set_sensitive(true);
1808 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1809 SfxItemState eTmpState = rSet->GetItemState( _nWhich );
1811 if ( eTmpState >= SfxItemState::DEFAULT )
1813 const SvxWidowsItem& rWidow =
1814 static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich ));
1815 aWidowState.bTriStateEnabled = false;
1816 const sal_uInt16 nLines = rWidow.GetValue();
1818 bool _bEnable = nLines > 0;
1819 m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines));
1820 m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
1821 m_xWidowRowNo->set_sensitive(_bEnable);
1822 //m_xWidowRowLabel->set_sensitive(_bEnable);
1825 else if ( SfxItemState::DONTCARE == eTmpState )
1826 m_xWidowBox->set_state( TRISTATE_INDET );
1827 else
1828 m_xWidowBox->set_sensitive(false);
1830 m_xOrphanBox->set_sensitive(true);
1831 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1832 eTmpState = rSet->GetItemState( _nWhich );
1834 if ( eTmpState >= SfxItemState::DEFAULT )
1836 const SvxOrphansItem& rOrphan =
1837 static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich ));
1838 const sal_uInt16 nLines = rOrphan.GetValue();
1839 aOrphanState.bTriStateEnabled = false;
1841 bool _bEnable = nLines > 0;
1842 m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
1843 m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines));
1844 m_xOrphanRowNo->set_sensitive(_bEnable);
1845 m_xOrphanRowLabel->set_sensitive(_bEnable);
1848 else if ( SfxItemState::DONTCARE == eTmpState )
1849 m_xOrphanBox->set_state(TRISTATE_INDET);
1850 else
1851 m_xOrphanBox->set_sensitive(false);
1852 aOrphanState.eState = m_xOrphanBox->get_state();
1855 else if ( SfxItemState::DONTCARE == eItemState )
1856 m_xKeepTogetherBox->set_state(TRISTATE_INDET);
1857 else
1858 m_xKeepTogetherBox->set_sensitive(false);
1860 // so that everything is enabled correctly
1861 KeepTogetherHdl();
1862 WidowHdl();
1863 OrphanHdl();
1864 ChangesApplied();
1866 void SvxExtParagraphTabPage::ChangesApplied()
1868 m_xHyphenBox->save_state();
1869 m_xHyphenNoCapsBox->save_state();
1870 m_xExtHyphenBeforeBox->set_value(m_xExtHyphenBeforeBox->get_value());
1871 m_xExtHyphenAfterBox->set_value(m_xExtHyphenAfterBox->get_value());
1872 m_xMaxHyphenEdit->set_value(m_xMaxHyphenEdit->get_value());
1873 m_xPageBreakBox->save_state();
1874 m_xBreakPositionLB->save_value();
1875 m_xBreakTypeLB->save_value();
1876 m_xApplyCollBtn->save_state();
1877 m_xApplyCollBox->save_value();
1878 m_xPageNumBox->save_state();
1879 m_xPagenumEdit->save_value();
1880 m_xKeepTogetherBox->save_state();
1881 m_xKeepParaBox->save_state();
1882 m_xWidowBox->save_state();
1883 m_xOrphanBox->save_state();
1884 m_xOrphanRowNo->save_value();
1885 m_xWidowRowNo->save_value();
1888 DeactivateRC SvxExtParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
1890 if ( _pSet )
1891 FillItemSet( _pSet );
1892 return DeactivateRC::LeavePage;
1895 void SvxExtParagraphTabPage::DisablePageBreak()
1897 bPageBreak = false;
1898 m_xPageBreakBox->set_sensitive(false);
1899 m_xBreakTypeLB->remove(0);
1900 m_xBreakPositionFT->set_sensitive(false);
1901 m_xBreakPositionLB->set_sensitive(false);
1902 m_xApplyCollBtn->set_sensitive(false);
1903 m_xApplyCollBox->set_sensitive(false);
1904 m_xPageNumBox->set_sensitive(false);
1905 m_xPagenumEdit->set_sensitive(false);
1908 SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
1909 : SfxTabPage(pPage, pController, "cui/ui/textflowpage.ui", "TextFlowPage", &rAttr)
1910 , bPageBreak(true)
1911 , bHtmlMode(false)
1912 , nStdPos(0)
1913 // Hyphenation
1914 , m_xHyphenBox(m_xBuilder->weld_check_button("checkAuto"))
1915 , m_xHyphenNoCapsBox(m_xBuilder->weld_check_button("checkNoCaps"))
1916 , m_xBeforeText(m_xBuilder->weld_label("labelLineBegin"))
1917 , m_xExtHyphenBeforeBox(m_xBuilder->weld_spin_button("spinLineEnd"))
1918 , m_xAfterText(m_xBuilder->weld_label("labelLineEnd"))
1919 , m_xExtHyphenAfterBox(m_xBuilder->weld_spin_button("spinLineBegin"))
1920 , m_xMaxHyphenLabel(m_xBuilder->weld_label("labelMaxNum"))
1921 , m_xMaxHyphenEdit(m_xBuilder->weld_spin_button("spinMaxNum"))
1922 //Page break
1923 , m_xPageBreakBox(m_xBuilder->weld_check_button("checkInsert"))
1924 , m_xBreakTypeFT(m_xBuilder->weld_label("labelType"))
1925 , m_xBreakTypeLB(m_xBuilder->weld_combo_box("comboBreakType"))
1926 , m_xBreakPositionFT(m_xBuilder->weld_label("labelPosition"))
1927 , m_xBreakPositionLB(m_xBuilder->weld_combo_box("comboBreakPosition"))
1928 , m_xApplyCollBtn(m_xBuilder->weld_check_button("checkPageStyle"))
1929 , m_xApplyCollBox(m_xBuilder->weld_combo_box("comboPageStyle"))
1930 , m_xPageNumBox(m_xBuilder->weld_check_button("labelPageNum"))
1931 , m_xPagenumEdit(m_xBuilder->weld_spin_button("spinPageNumber"))
1932 // Options
1933 , m_xKeepTogetherBox(m_xBuilder->weld_check_button("checkSplitPara"))
1934 , m_xKeepParaBox(m_xBuilder->weld_check_button("checkKeepPara"))
1935 , m_xOrphanBox(m_xBuilder->weld_check_button("checkOrphan"))
1936 , m_xOrphanRowNo(m_xBuilder->weld_spin_button("spinOrphan"))
1937 , m_xOrphanRowLabel(m_xBuilder->weld_label("labelOrphan"))
1938 , m_xWidowBox(m_xBuilder->weld_check_button("checkWidow"))
1939 , m_xWidowRowNo(m_xBuilder->weld_spin_button("spinWidow"))
1940 , m_xWidowRowLabel(m_xBuilder->weld_label("labelWidow"))
1942 // this page needs ExchangeSupport
1943 SetExchangeSupport();
1945 m_xHyphenBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, HyphenClickHdl_Impl));
1946 m_xPageBreakBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageBreakHdl_Impl));
1947 m_xKeepTogetherBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepTogetherHdl_Impl));
1948 m_xWidowBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, WidowHdl_Impl));
1949 m_xOrphanBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, OrphanHdl_Impl));
1950 m_xApplyCollBtn->connect_toggled(LINK(this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl));
1951 m_xBreakTypeLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl));
1952 m_xBreakPositionLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl));
1953 m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl));
1954 m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl));
1956 SfxObjectShell* pSh = SfxObjectShell::Current();
1957 if ( pSh )
1959 SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
1960 pPool->SetSearchMask( SfxStyleFamily::Page );
1961 SfxStyleSheetBase* pStyle = pPool->First();
1962 OUString aStdName;
1964 while( pStyle )
1966 if ( aStdName.isEmpty() )
1967 // first style == standard style
1968 aStdName = pStyle->GetName();
1969 m_xApplyCollBox->append_text(pStyle->GetName());
1970 pStyle = pPool->Next();
1972 nStdPos = m_xApplyCollBox->find_text(aStdName);
1975 sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr );
1976 if ( nHtmlMode & HTMLMODE_ON )
1978 bHtmlMode = true;
1979 m_xHyphenBox->set_sensitive(false);
1980 m_xHyphenNoCapsBox->set_sensitive(false);
1981 m_xBeforeText->set_sensitive(false);
1982 m_xExtHyphenBeforeBox->set_sensitive(false);
1983 m_xAfterText->set_sensitive(false);
1984 m_xExtHyphenAfterBox->set_sensitive(false);
1985 m_xMaxHyphenLabel->set_sensitive(false);
1986 m_xMaxHyphenEdit->set_sensitive(false);
1987 m_xPageNumBox->set_sensitive(false);
1988 m_xPagenumEdit->set_sensitive(false);
1989 // no column break in HTML
1990 m_xBreakTypeLB->remove(1);
1994 SvxExtParagraphTabPage::~SvxExtParagraphTabPage()
1998 void SvxExtParagraphTabPage::PageBreakHdl()
2000 switch (m_xPageBreakBox->get_state())
2002 case TRISTATE_TRUE:
2003 m_xBreakTypeFT->set_sensitive(true);
2004 m_xBreakTypeLB->set_sensitive(true);
2005 m_xBreakPositionFT->set_sensitive(true);
2006 m_xBreakPositionLB->set_sensitive(true);
2008 if (0 == m_xBreakTypeLB->get_active() && 0 == m_xBreakPositionLB->get_active())
2010 m_xApplyCollBtn->set_sensitive(true);
2012 bool bEnable = TRISTATE_TRUE == m_xApplyCollBtn->get_state() &&
2013 m_xApplyCollBox->get_count();
2014 m_xApplyCollBox->set_sensitive(bEnable);
2015 if(!bHtmlMode)
2017 m_xPageNumBox->set_sensitive(bEnable);
2018 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2021 break;
2023 case TRISTATE_FALSE:
2024 case TRISTATE_INDET:
2025 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2026 m_xApplyCollBtn->set_sensitive(false);
2027 m_xApplyCollBox->set_sensitive(false);
2028 m_xPageNumBox->set_sensitive(false);
2029 m_xPagenumEdit->set_sensitive(false);
2030 m_xBreakTypeFT->set_sensitive(false);
2031 m_xBreakTypeLB->set_sensitive(false);
2032 m_xBreakPositionFT->set_sensitive(false);
2033 m_xBreakPositionLB->set_sensitive(false);
2034 break;
2038 IMPL_LINK(SvxExtParagraphTabPage, PageBreakHdl_Impl, weld::ToggleButton&, rToggle, void)
2040 aPageBreakState.ButtonToggled(rToggle);
2041 PageBreakHdl();
2044 void SvxExtParagraphTabPage::KeepTogetherHdl()
2046 bool bEnable = m_xKeepTogetherBox->get_state() == TRISTATE_FALSE;
2047 m_xWidowBox->set_sensitive(bEnable);
2048 m_xOrphanBox->set_sensitive(bEnable);
2051 IMPL_LINK(SvxExtParagraphTabPage, KeepTogetherHdl_Impl, weld::ToggleButton&, rToggle, void)
2053 aKeepTogetherState.ButtonToggled(rToggle);
2054 KeepTogetherHdl();
2057 void SvxExtParagraphTabPage::WidowHdl()
2059 switch (m_xWidowBox->get_state())
2061 case TRISTATE_TRUE:
2062 m_xWidowRowNo->set_sensitive(true);
2063 m_xWidowRowLabel->set_sensitive(true);
2064 m_xKeepTogetherBox->set_sensitive(false);
2065 break;
2066 case TRISTATE_FALSE:
2067 if (m_xOrphanBox->get_state() == TRISTATE_FALSE)
2068 m_xKeepTogetherBox->set_sensitive(true);
2069 [[fallthrough]];
2070 case TRISTATE_INDET:
2071 m_xWidowRowNo->set_sensitive(false);
2072 m_xWidowRowLabel->set_sensitive(false);
2073 break;
2077 IMPL_LINK(SvxExtParagraphTabPage, WidowHdl_Impl, weld::ToggleButton&, rToggle, void)
2079 aWidowState.ButtonToggled(rToggle);
2080 WidowHdl();
2083 IMPL_LINK(SvxExtParagraphTabPage, OrphanHdl_Impl, weld::ToggleButton&, rToggle, void)
2085 aOrphanState.ButtonToggled(rToggle);
2086 OrphanHdl();
2089 void SvxExtParagraphTabPage::OrphanHdl()
2091 switch (m_xOrphanBox->get_state())
2093 case TRISTATE_TRUE:
2094 m_xOrphanRowNo->set_sensitive(true);
2095 m_xOrphanRowLabel->set_sensitive(true);
2096 m_xKeepTogetherBox->set_sensitive(false);
2097 break;
2099 case TRISTATE_FALSE:
2100 if (m_xWidowBox->get_state() == TRISTATE_FALSE)
2101 m_xKeepTogetherBox->set_sensitive(true);
2102 [[fallthrough]];
2103 case TRISTATE_INDET:
2104 m_xOrphanRowNo->set_sensitive(false);
2105 m_xOrphanRowLabel->set_sensitive(false);
2106 break;
2110 void SvxExtParagraphTabPage::HyphenClickHdl()
2112 bool bEnable = m_xHyphenBox->get_state() == TRISTATE_TRUE;
2113 m_xHyphenNoCapsBox->set_sensitive(bEnable);
2114 m_xBeforeText->set_sensitive(bEnable);
2115 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
2116 m_xAfterText->set_sensitive(bEnable);
2117 m_xExtHyphenAfterBox->set_sensitive(bEnable);
2118 m_xMaxHyphenLabel->set_sensitive(bEnable);
2119 m_xMaxHyphenEdit->set_sensitive(bEnable);
2120 m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2123 IMPL_LINK(SvxExtParagraphTabPage, HyphenClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2125 aHyphenState.ButtonToggled(rToggle);
2126 HyphenClickHdl();
2129 void SvxExtParagraphTabPage::ApplyCollClickHdl()
2131 bool bEnable = false;
2132 if (m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count())
2134 bEnable = true;
2135 m_xApplyCollBox->set_active(nStdPos);
2137 else
2139 m_xApplyCollBox->set_active(-1);
2141 m_xApplyCollBox->set_sensitive(bEnable);
2142 if (!bHtmlMode)
2144 m_xPageNumBox->set_sensitive(bEnable);
2145 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2149 IMPL_LINK(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2151 aApplyCollState.ButtonToggled(rToggle);
2152 ApplyCollClickHdl();
2155 IMPL_LINK(SvxExtParagraphTabPage, PageBreakPosHdl_Impl, weld::ComboBox&, rListBox, void)
2157 if (0 == rListBox.get_active())
2159 m_xApplyCollBtn->set_sensitive(true);
2161 bool bEnable = m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count();
2163 m_xApplyCollBox->set_sensitive(bEnable);
2164 if (!bHtmlMode)
2166 m_xPageNumBox->set_sensitive(bEnable);
2167 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2170 else if (1 == rListBox.get_active())
2172 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2173 m_xApplyCollBtn->set_sensitive(false);
2174 m_xApplyCollBox->set_sensitive(false);
2175 m_xPageNumBox->set_sensitive(false);
2176 m_xPagenumEdit->set_sensitive(false);
2180 IMPL_LINK(SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, weld::ComboBox&, rListBox, void)
2182 //column break or break after
2183 int nBreakPos = m_xBreakPositionLB->get_active();
2184 if (rListBox.get_active() == 1 || 1 == nBreakPos)
2186 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2187 m_xApplyCollBtn->set_sensitive(false);
2188 m_xApplyCollBox->set_sensitive(false);
2189 m_xPageNumBox->set_sensitive(false);
2190 m_xPagenumEdit->set_sensitive(false);
2192 else
2193 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2196 void SvxExtParagraphTabPage::PageNumBoxClickHdl()
2198 m_xPagenumEdit->set_sensitive(m_xPageNumBox->get_state() == TRISTATE_TRUE);
2201 IMPL_LINK(SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2203 aPageNumState.ButtonToggled(rToggle);
2204 PageNumBoxClickHdl();
2207 IMPL_LINK(SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl, weld::ToggleButton&, rToggle, void)
2209 aKeepParaState.ButtonToggled(rToggle);
2212 void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
2214 const SfxBoolItem* pDisablePageBreakItem = aSet.GetItem<SfxBoolItem>(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false);
2216 if (pDisablePageBreakItem)
2217 if ( pDisablePageBreakItem->GetValue())
2218 DisablePageBreak();
2221 SvxAsianTabPage::SvxAsianTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
2222 : SfxTabPage(pPage, pController, "cui/ui/asiantypography.ui", "AsianTypography", &rSet)
2223 , m_xForbiddenRulesCB(m_xBuilder->weld_check_button("checkForbidList"))
2224 , m_xHangingPunctCB(m_xBuilder->weld_check_button("checkHangPunct"))
2225 , m_xScriptSpaceCB(m_xBuilder->weld_check_button("checkApplySpacing"))
2229 SvxAsianTabPage::~SvxAsianTabPage()
2233 std::unique_ptr<SfxTabPage> SvxAsianTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2235 return std::make_unique<SvxAsianTabPage>(pPage, pController, *rSet);
2238 const sal_uInt16* SvxAsianTabPage::GetRanges()
2240 static const sal_uInt16 pRanges[] =
2242 SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES,
2245 return pRanges;
2248 bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet )
2250 bool bRet = false;
2251 SfxItemPool* pPool = rSet->GetPool();
2252 if (m_xScriptSpaceCB->get_sensitive() && m_xScriptSpaceCB->get_state_changed_from_saved())
2254 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2255 pPool->GetWhich(SID_ATTR_PARA_SCRIPTSPACE)).Clone()));
2256 pNewItem->SetValue(m_xScriptSpaceCB->get_active());
2257 rSet->Put(std::move(pNewItem));
2258 bRet = true;
2260 if (m_xHangingPunctCB->get_sensitive() && m_xHangingPunctCB->get_state_changed_from_saved())
2262 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2263 pPool->GetWhich(SID_ATTR_PARA_HANGPUNCTUATION)).Clone()));
2264 pNewItem->SetValue(m_xHangingPunctCB->get_active());
2265 rSet->Put(std::move(pNewItem));
2266 bRet = true;
2268 if (m_xForbiddenRulesCB->get_sensitive() && m_xForbiddenRulesCB->get_state_changed_from_saved())
2270 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2271 pPool->GetWhich(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone()));
2272 pNewItem->SetValue(m_xForbiddenRulesCB->get_active());
2273 rSet->Put(std::move(pNewItem));
2274 bRet = true;
2276 return bRet;
2279 static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, weld::CheckButton& rBox)
2281 sal_uInt16 _nWhich = rSet.GetPool()->GetWhich(nSlotId);
2282 SfxItemState eState = rSet.GetItemState(_nWhich);
2283 if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED )
2284 rBox.set_sensitive(false);
2285 else if(eState >= SfxItemState::DEFAULT)
2286 rBox.set_active(static_cast<const SfxBoolItem&>(rSet.Get(_nWhich)).GetValue());
2287 else
2288 rBox.set_state(TRISTATE_INDET);
2289 rBox.save_state();
2292 void SvxAsianTabPage::Reset( const SfxItemSet* rSet )
2294 lcl_SetBox(*rSet, SID_ATTR_PARA_FORBIDDEN_RULES, *m_xForbiddenRulesCB );
2295 lcl_SetBox(*rSet, SID_ATTR_PARA_HANGPUNCTUATION, *m_xHangingPunctCB );
2297 //character distance not yet available
2298 lcl_SetBox(*rSet, SID_ATTR_PARA_SCRIPTSPACE, *m_xScriptSpaceCB );
2301 void SvxAsianTabPage::ChangesApplied()
2303 m_xForbiddenRulesCB->save_state();
2304 m_xHangingPunctCB->save_state();
2305 m_xScriptSpaceCB->save_state();
2308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */