workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / cui / source / tabpages / paragrph.cxx
blob56b697a046a67f5aba6007171b415b9da4320b17
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>
28 #include <svx/sdtaitm.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 <editeng/scriptspaceitem.hxx>
49 #include <editeng/hngpnctitem.hxx>
50 #include <editeng/forbiddenruleitem.hxx>
51 #include <i18nlangtag/languagetag.hxx>
52 #include <i18nlangtag/mslangid.hxx>
53 #include <svx/dlgutil.hxx>
54 #include <sfx2/htmlmode.hxx>
55 #include <editeng/paravertalignitem.hxx>
56 #include <svl/eitem.hxx>
57 #include <svl/intitem.hxx>
58 #include <unotools/syslocaleoptions.hxx>
59 #include <com/sun/star/text/ParagraphHyphenationKeepType.hpp>
61 const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges(
62 svl::Items<
63 SID_ATTR_PARA_LINESPACE, SID_ATTR_PARA_LINESPACE, // 10033
64 SID_ATTR_PARA_LEFTSPACE, SID_ATTR_PARA_FIRSTLINESPACE,
65 SID_ATTR_LRSPACE, SID_ATTR_ULSPACE, // 10048 - 10049
66 SID_ATTR_PARA_REGISTER, SID_ATTR_PARA_REGISTER // 10413
67 >);
69 const WhichRangesContainer SvxParaAlignTabPage::pAlignRanges(
70 svl::Items<
71 SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST, // 10027
72 // tdf#154543 - reset snap to grid to parent
73 SID_ATTR_PARA_SNAPTOGRID, SID_ATTR_PARA_SNAPTOGRID // 10945
74 >);
76 const WhichRangesContainer SvxParaAlignTabPage::pSdrAlignRanges(
77 svl::Items<
78 SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, // 1076
79 SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST , // 10027
80 SID_ATTR_FRAMEDIRECTION, SID_ATTR_FRAMEDIRECTION // 10944
81 >);
83 const WhichRangesContainer SvxExtParagraphTabPage::pExtRanges(svl::Items<
84 SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS, // 10037 - 10041
85 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP // 10065 - 10066
86 >);
88 #define MAX_DURCH 31680 // tdf#68335: 1584 pt for UX interoperability with Word
89 #define FIX_DIST_DEF 283 // standard fix distance 0,5 cm
91 namespace {
93 enum LineSpaceList
95 LLINESPACE_1 = 0,
96 LLINESPACE_115 = 1,
97 LLINESPACE_15 = 2,
98 LLINESPACE_2 = 3,
99 LLINESPACE_PROP = 4,
100 LLINESPACE_MIN = 5,
101 LLINESPACE_DURCH= 6,
102 LLINESPACE_FIX = 7
107 static void SetLineSpace_Impl( SvxLineSpacingItem&, int, tools::Long lValue = 0 );
109 void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
110 int eSpace, tools::Long lValue )
112 switch ( eSpace )
114 case LLINESPACE_1:
115 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
116 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
117 break;
119 case LLINESPACE_115:
120 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
121 rLineSpace.SetPropLineSpace( 115 );
122 break;
124 case LLINESPACE_15:
125 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
126 rLineSpace.SetPropLineSpace( 150 );
127 break;
129 case LLINESPACE_2:
130 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
131 rLineSpace.SetPropLineSpace( 200 );
132 break;
134 case LLINESPACE_PROP:
135 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
136 rLineSpace.SetPropLineSpace( static_cast<sal_uInt16>(lValue) );
137 break;
139 case LLINESPACE_MIN:
140 rLineSpace.SetLineHeight( static_cast<sal_uInt16>(lValue) );
141 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
142 break;
144 case LLINESPACE_DURCH:
145 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
146 rLineSpace.SetInterLineSpace( static_cast<sal_uInt16>(lValue) );
147 break;
149 case LLINESPACE_FIX:
150 rLineSpace.SetLineHeight(static_cast<sal_uInt16>(lValue));
151 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Fix );
152 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
153 break;
157 static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
159 sal_uInt16 nHtmlMode = 0;
160 const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false);
161 if (!pItem)
163 if (SfxObjectShell* pShell = SfxObjectShell::Current())
164 pItem = pShell->GetItem(SID_HTML_MODE);
166 if(pItem)
168 nHtmlMode = pItem->GetValue();
170 return nHtmlMode;
174 void SvxStdParagraphTabPage::ELRLoseFocus()
176 SfxItemPool* pPool = GetItemSet().GetPool();
177 assert(pPool && "Where is the pool?");
178 FieldUnit eUnit =
179 MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
181 sal_Int64 nL = m_aLeftIndent.denormalize(m_aLeftIndent.get_value(eUnit));
182 sal_Int64 nR = m_aRightIndent.denormalize(m_aRightIndent.get_value(eUnit));
183 OUString aTmp = m_aFLineIndent.get_text();
185 if (m_aLeftIndent.get_min(FieldUnit::NONE) < 0)
186 m_aFLineIndent.set_min(-99999, FieldUnit::MM);
187 else
188 m_aFLineIndent.set_min(m_aFLineIndent.normalize(-nL), eUnit);
190 // Check only for concrete width (Shell)
191 sal_Int64 nTmp = nWidth - nL - nR - MM50;
192 m_aFLineIndent.set_max(m_aFLineIndent.normalize(nTmp), eUnit);
194 if (aTmp.isEmpty())
195 m_aFLineIndent.set_text(OUString());
196 // maximum left right
197 aTmp = m_aLeftIndent.get_text();
198 nTmp = nWidth - nR - MM50;
199 m_aLeftIndent.set_max(m_aLeftIndent.normalize(nTmp), eUnit);
201 if ( aTmp.isEmpty() )
202 m_aLeftIndent.set_text(OUString());
203 aTmp = m_aRightIndent.get_text();
204 nTmp = nWidth - nL - MM50;
205 m_aRightIndent.set_max(m_aRightIndent.normalize(nTmp), eUnit);
207 if ( aTmp.isEmpty() )
208 m_aRightIndent.set_text(OUString());
210 UpdateExample_Impl();
213 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl, weld::MetricSpinButton&, void)
215 ELRLoseFocus();
218 std::unique_ptr<SfxTabPage> SvxStdParagraphTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
220 return std::make_unique<SvxStdParagraphTabPage>(pPage, pController, *rSet);
223 bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
225 const SfxPoolItem* pOld = nullptr;
226 SfxItemPool* pPool = rOutSet->GetPool();
227 DBG_ASSERT( pPool, "Where is the pool?" );
229 bool bModified = false;
230 sal_uInt16 nWhich;
231 int nPos = m_xLineDist->get_active();
233 if ( nPos != -1 &&
234 ( m_bLineDistToggled ||
235 m_xLineDist->get_value_changed_from_saved() ||
236 m_xLineDistAtPercentBox->get_value_changed_from_saved() ||
237 m_xLineDistAtMetricBox->get_value_changed_from_saved() ) )
239 nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
240 MapUnit eUnit = pPool->GetMetric( nWhich );
241 SvxLineSpacingItem aSpacing(
242 static_cast<const SvxLineSpacingItem&>(GetItemSet().Get( nWhich )) );
244 switch ( nPos )
246 case LLINESPACE_1:
247 case LLINESPACE_115:
248 case LLINESPACE_15:
249 case LLINESPACE_2:
250 SetLineSpace_Impl( aSpacing, nPos );
251 break;
253 case LLINESPACE_PROP:
254 SetLineSpace_Impl( aSpacing, nPos,
255 static_cast<tools::Long>(m_xLineDistAtPercentBox->denormalize(
256 m_xLineDistAtPercentBox->get_value(FieldUnit::NONE) )) );
257 break;
259 case LLINESPACE_MIN:
260 case LLINESPACE_DURCH:
261 case LLINESPACE_FIX:
262 SetLineSpace_Impl( aSpacing, nPos,
263 GetCoreValue( *m_xLineDistAtMetricBox, eUnit ) );
264 break;
266 default:
267 OSL_FAIL( "unknown LineDist entry" );
268 break;
270 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_LINESPACE );
272 if ( m_bLineDistToggled ||
273 !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) ||
274 SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
276 rOutSet->Put( aSpacing );
277 bModified = true;
281 if ( m_aTopDist.get_value_changed_from_saved() || m_aBottomDist.get_value_changed_from_saved()
282 || m_xContextualCB->get_state_changed_from_saved())
284 nWhich = GetWhich( SID_ATTR_ULSPACE );
285 MapUnit eUnit = pPool->GetMetric( nWhich );
286 pOld = GetOldItem( *rOutSet, SID_ATTR_ULSPACE );
287 SvxULSpaceItem aMargin( nWhich );
289 if ( bRelativeMode )
291 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
293 const SvxULSpaceItem& rOldItem =
294 static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
296 if ( m_aTopDist.IsRelative() )
297 aMargin.SetUpper( rOldItem.GetUpper(),
298 static_cast<sal_uInt16>(m_aTopDist.get_value(FieldUnit::NONE)) );
299 else
300 aMargin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)) );
302 if ( m_aBottomDist.IsRelative() )
303 aMargin.SetLower( rOldItem.GetLower(),
304 static_cast<sal_uInt16>(m_aBottomDist.get_value(FieldUnit::NONE)) );
305 else
306 aMargin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)) );
309 else
311 aMargin.SetUpper(static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)));
312 aMargin.SetLower(static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)));
314 aMargin.SetContextValue(m_xContextualCB->get_active());
316 if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin ||
317 SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
319 rOutSet->Put( aMargin );
320 bModified = true;
323 bool bNullTab = false;
325 if (m_bSplitLRSpace && m_aLeftIndent.get_value_changed_from_saved())
327 nWhich = GetWhich(SID_ATTR_PARA_LEFTSPACE);
328 MapUnit const eUnit = pPool->GetMetric(nWhich);
329 SvxTextLeftMarginItem item(nWhich);
330 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_LEFTSPACE);
332 if (bRelativeMode)
334 assert(GetItemSet().GetParent());
336 const SvxTextLeftMarginItem & rOldItem(
337 static_cast<const SvxTextLeftMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));
339 if (m_aLeftIndent.IsRelative())
341 item.SetTextLeft(rOldItem.GetTextLeft(),
342 static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)));
344 else
346 item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
349 else
351 item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
353 if (!pOld || *static_cast<const SvxTextLeftMarginItem*>(pOld) != item
354 || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
356 rOutSet->Put(item);
357 bModified = true;
361 if (m_bSplitLRSpace && m_aRightIndent.get_value_changed_from_saved())
363 nWhich = GetWhich(SID_ATTR_PARA_RIGHTSPACE);
364 MapUnit const eUnit = pPool->GetMetric(nWhich);
365 SvxRightMarginItem item(nWhich);
366 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_RIGHTSPACE);
368 if (bRelativeMode)
370 assert(GetItemSet().GetParent());
372 const SvxRightMarginItem & rOldItem(
373 static_cast<const SvxRightMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));
375 if (m_aRightIndent.IsRelative())
377 item.SetRight(rOldItem.GetRight(),
378 static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)));
380 else
382 item.SetRight(m_aRightIndent.GetCoreValue(eUnit));
385 else
387 item.SetRight(m_aRightIndent.GetCoreValue(eUnit));
389 if (!pOld || *static_cast<const SvxRightMarginItem*>(pOld) != item
390 || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
392 rOutSet->Put(item);
393 bModified = true;
397 if (m_bSplitLRSpace && (m_aFLineIndent.get_value_changed_from_saved()
398 || m_xAutoCB->get_state_changed_from_saved()))
400 nWhich = GetWhich(SID_ATTR_PARA_FIRSTLINESPACE);
401 MapUnit const eUnit = pPool->GetMetric(nWhich);
402 SvxFirstLineIndentItem item(nWhich);
403 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_FIRSTLINESPACE);
405 if (bRelativeMode)
407 assert(GetItemSet().GetParent());
409 const SvxFirstLineIndentItem & rOldItem(
410 static_cast<const SvxFirstLineIndentItem&>(GetItemSet().GetParent()->Get(nWhich)));
412 if (m_aFLineIndent.IsRelative())
414 item.SetTextFirstLineOffset(rOldItem.GetTextFirstLineOffset(),
415 static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)));
417 else
419 item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
422 else
424 item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
426 item.SetAutoFirst(m_xAutoCB->get_active());
427 if (item.GetTextFirstLineOffset() < 0)
429 bNullTab = true;
432 if (!pOld || *static_cast<const SvxFirstLineIndentItem*>(pOld) != item
433 || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
435 rOutSet->Put(item);
436 bModified = true;
440 if (!m_bSplitLRSpace &&
441 (m_aLeftIndent.get_value_changed_from_saved() ||
442 m_aFLineIndent.get_value_changed_from_saved() ||
443 m_aRightIndent.get_value_changed_from_saved() ||
444 m_xAutoCB->get_state_changed_from_saved()))
446 nWhich = GetWhich( SID_ATTR_LRSPACE );
447 MapUnit eUnit = pPool->GetMetric( nWhich );
448 SvxLRSpaceItem aMargin( nWhich );
449 pOld = GetOldItem( *rOutSet, SID_ATTR_LRSPACE );
451 if ( bRelativeMode )
453 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
455 const SvxLRSpaceItem& rOldItem =
456 static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
458 if (m_aLeftIndent.IsRelative())
459 aMargin.SetTextLeft( rOldItem.GetTextLeft(),
460 static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)) );
461 else
462 aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
464 if ( m_aRightIndent.IsRelative() )
465 aMargin.SetRight( rOldItem.GetRight(),
466 static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)) );
467 else
468 aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit));
470 if ( m_aFLineIndent.IsRelative() )
471 aMargin.SetTextFirstLineOffset( rOldItem.GetTextFirstLineOffset(),
472 static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)) );
473 else
474 aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
476 else
478 aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
479 aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit));
480 aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
482 aMargin.SetAutoFirst(m_xAutoCB->get_active());
483 if ( aMargin.GetTextFirstLineOffset() < 0 )
484 bNullTab = true;
486 if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin ||
487 SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
489 rOutSet->Put( aMargin );
490 bModified = true;
494 if ( bNullTab )
496 MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
497 if ( MapUnit::Map100thMM != eUnit )
500 // negative first line indent -> set null default tabstob if applicable
501 sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
502 const SfxItemSet& rInSet = GetItemSet();
504 if ( rInSet.GetItemState( _nWhich ) >= SfxItemState::DEFAULT )
506 const SvxTabStopItem& rTabItem =
507 static_cast<const SvxTabStopItem&>(rInSet.Get( _nWhich ));
508 SvxTabStopItem aNullTab( rTabItem );
509 SvxTabStop aNull( 0, SvxTabAdjust::Default );
510 aNullTab.Insert( aNull );
511 rOutSet->Put( aNullTab );
515 if (m_xRegisterCB->get_visible())
517 const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(GetOldItem(
518 *rOutSet, SID_ATTR_PARA_REGISTER));
519 if (!pBoolItem)
520 return bModified;
521 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
522 bool bSet = pBoolItem->GetValue();
524 if (m_xRegisterCB->get_active() != bSet)
526 std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone());
527 pRegItem->SetValue(!bSet);
528 rOutSet->Put(std::move(pRegItem));
529 bModified = true;
531 else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) )
532 rOutSet->ClearItem(_nWhich);
535 return bModified;
538 static bool UseCharUnitInUI(const SfxItemSet& rSet)
540 const bool bApplyCharUnit = GetApplyCharUnit(rSet);
541 if (!bApplyCharUnit)
542 return false;
543 if (!SvtCJKOptions::IsAsianTypographyEnabled())
544 return false;
545 // tdf#101895 Given that we choose to show cm vs inch based on this Locale
546 // setting, also choose to use ch[ar] and line based on that locale when
547 // bApplyCharUnit is enabled.
548 return MsLangId::isCJK(SvtSysLocaleOptions().GetRealLanguageTag().getLanguageType());
551 void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet )
553 SfxItemPool* pPool = rSet->GetPool();
554 DBG_ASSERT( pPool, "Where is the pool?" );
556 // adjust metric
557 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
558 if (UseCharUnitInUI(*rSet))
559 eFUnit = FieldUnit::CHAR;
561 m_aLeftIndent.SetFieldUnit(eFUnit);
562 m_aRightIndent.SetFieldUnit(eFUnit);
563 m_aFLineIndent.SetFieldUnit(eFUnit);
564 if ( eFUnit == FieldUnit::CHAR )
566 m_aTopDist.SetFieldUnit(FieldUnit::LINE);
567 m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
568 SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT);
570 else
572 m_aTopDist.SetFieldUnit(eFUnit);
573 m_aBottomDist.SetFieldUnit(eFUnit);
574 SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit);
577 sal_uInt16 const nWhichFL(GetWhich(SID_ATTR_PARA_FIRSTLINESPACE));
578 m_bSplitLRSpace = (nWhichFL != SID_ATTR_PARA_FIRSTLINESPACE);
579 SfxItemState const eItemStateFL(rSet->GetItemState(nWhichFL));
580 sal_uInt16 const nWhichLM(GetWhich(SID_ATTR_PARA_LEFTSPACE));
581 SfxItemState const eItemStateLM(rSet->GetItemState(nWhichLM));
582 sal_uInt16 const nWhichRM(GetWhich(SID_ATTR_PARA_RIGHTSPACE));
583 SfxItemState const eItemStateRM(rSet->GetItemState(nWhichRM));
585 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateLM)
587 const SvxTextLeftMarginItem & rOldLeftMargin(
588 static_cast<const SvxTextLeftMarginItem &>(rSet->Get(nWhichLM)));
590 MapUnit const eUnit = pPool->GetMetric(nWhichLM);
592 if (bRelativeMode)
594 if (rOldLeftMargin.GetPropLeft() != 100)
596 m_aLeftIndent.SetRelative( true );
597 m_aLeftIndent.set_value(rOldLeftMargin.GetPropLeft(), FieldUnit::NONE);
599 else
601 m_aLeftIndent.SetRelative(false);
602 m_aLeftIndent.SetFieldUnit(eFUnit);
603 m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit);
606 else
608 m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit);
611 else if (m_bSplitLRSpace)
613 m_aLeftIndent.set_text(OUString());
616 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateRM)
618 const SvxRightMarginItem & rOldRightMargin(
619 static_cast<const SvxRightMarginItem &>(rSet->Get(nWhichRM)));
621 MapUnit const eUnit = pPool->GetMetric(nWhichRM);
623 if (bRelativeMode)
625 if (rOldRightMargin.GetPropRight() != 100)
627 m_aRightIndent.SetRelative( true );
628 m_aRightIndent.set_value(rOldRightMargin.GetPropRight(), FieldUnit::NONE);
630 else
632 m_aRightIndent.SetRelative(false);
633 m_aRightIndent.SetFieldUnit(eFUnit);
634 m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit);
637 else
639 m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit);
642 else if (m_bSplitLRSpace)
644 m_aRightIndent.set_text(OUString());
647 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateFL)
649 const SvxFirstLineIndentItem & rOldFirstLine(
650 static_cast<const SvxFirstLineIndentItem &>(rSet->Get(nWhichFL)));
652 MapUnit const eUnit = pPool->GetMetric(nWhichFL);
654 if (bRelativeMode)
656 if (rOldFirstLine.GetPropTextFirstLineOffset() != 100)
658 m_aFLineIndent.SetRelative(true);
659 m_aFLineIndent.set_value(rOldFirstLine.GetPropTextFirstLineOffset(), FieldUnit::NONE);
661 else
663 m_aFLineIndent.SetRelative(false);
664 m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
665 m_aFLineIndent.SetFieldUnit(eFUnit);
666 m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit);
668 m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
670 else
672 m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit);
673 m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
675 AutoHdl_Impl(*m_xAutoCB);
677 else if (m_bSplitLRSpace)
679 m_aFLineIndent.set_text(OUString());
682 sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
683 SfxItemState eItemState = rSet->GetItemState( _nWhich );
685 if (!m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemState)
687 MapUnit eUnit = pPool->GetMetric( _nWhich );
689 if ( bRelativeMode )
691 const SvxLRSpaceItem& rOldItem =
692 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
694 if ( rOldItem.GetPropLeft() != 100 )
696 m_aLeftIndent.SetRelative( true );
697 m_aLeftIndent.set_value(rOldItem.GetPropLeft(), FieldUnit::NONE);
699 else
701 m_aLeftIndent.SetRelative(false);
702 m_aLeftIndent.SetFieldUnit(eFUnit);
703 m_aLeftIndent.SetMetricValue(rOldItem.GetTextLeft(), eUnit);
706 if ( rOldItem.GetPropRight() != 100 )
708 m_aRightIndent.SetRelative( true );
709 m_aRightIndent.set_value(rOldItem.GetPropRight(), FieldUnit::NONE);
711 else
713 m_aRightIndent.SetRelative(false);
714 m_aRightIndent.SetFieldUnit(eFUnit);
715 m_aRightIndent.SetMetricValue(rOldItem.GetRight(), eUnit);
718 if ( rOldItem.GetPropTextFirstLineOffset() != 100 )
720 m_aFLineIndent.SetRelative(true);
721 m_aFLineIndent.set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE);
723 else
725 m_aFLineIndent.SetRelative(false);
726 m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
727 m_aFLineIndent.SetFieldUnit(eFUnit);
728 m_aFLineIndent.SetMetricValue(rOldItem.GetTextFirstLineOffset(), eUnit);
730 m_xAutoCB->set_active(rOldItem.IsAutoFirst());
732 else
734 const SvxLRSpaceItem& rSpace =
735 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
737 m_aLeftIndent.SetMetricValue(rSpace.GetTextLeft(), eUnit);
738 m_aRightIndent.SetMetricValue(rSpace.GetRight(), eUnit);
739 m_aFLineIndent.SetMetricValue(rSpace.GetTextFirstLineOffset(), eUnit);
740 m_xAutoCB->set_active(rSpace.IsAutoFirst());
742 AutoHdl_Impl(*m_xAutoCB);
744 else if (!m_bSplitLRSpace)
746 m_aLeftIndent.set_text(OUString());
747 m_aRightIndent.set_text(OUString());
748 m_aFLineIndent.set_text(OUString());
751 _nWhich = GetWhich( SID_ATTR_ULSPACE );
752 eItemState = rSet->GetItemState( _nWhich );
754 if ( eItemState >= SfxItemState::DEFAULT )
756 MapUnit eUnit = pPool->GetMetric( _nWhich );
758 const SvxULSpaceItem& rOldItem =
759 static_cast<const SvxULSpaceItem&>(rSet->Get( _nWhich ));
760 if ( bRelativeMode )
763 if ( rOldItem.GetPropUpper() != 100 )
765 m_aTopDist.SetRelative( true );
766 m_aTopDist.set_value(rOldItem.GetPropUpper(), FieldUnit::NONE);
768 else
770 m_aTopDist.SetRelative(false);
771 if (eFUnit == FieldUnit::CHAR)
772 m_aTopDist.SetFieldUnit(FieldUnit::LINE);
773 else
774 m_aTopDist.SetFieldUnit(eFUnit);
775 m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
778 if ( rOldItem.GetPropLower() != 100 )
780 m_aBottomDist.SetRelative( true );
781 m_aBottomDist.set_value(rOldItem.GetPropLower(), FieldUnit::NONE);
783 else
785 m_aBottomDist.SetRelative(false);
786 if (eFUnit == FieldUnit::CHAR)
787 m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
788 else
789 m_aBottomDist.SetFieldUnit(eFUnit);
790 m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
793 else
795 m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
796 m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
798 m_xContextualCB->set_active(rOldItem.GetContext());
800 else
802 m_aTopDist.set_text(OUString());
803 m_aBottomDist.set_text(OUString());
806 _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
807 eItemState = rSet->GetItemState( _nWhich );
809 if ( eItemState >= SfxItemState::DEFAULT )
810 SetLineSpacing_Impl( static_cast<const SvxLineSpacingItem &>(rSet->Get( _nWhich )) );
811 else
812 m_xLineDist->set_active(-1);
814 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
815 eItemState = rSet->GetItemState( _nWhich );
817 if ( eItemState >= SfxItemState::DEFAULT )
818 m_xRegisterCB->set_active( static_cast<const SfxBoolItem &>(rSet->Get( _nWhich )).GetValue());
819 m_xRegisterCB->save_state();
820 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
821 if(nHtmlMode & HTMLMODE_ON)
823 m_xRegisterCB->hide();
824 m_xAutoCB->hide();
827 // this sets the min/max limits; do this _after_ setting the values,
828 // because for Impress the min of first-line indent depends on value of
829 // left-indent!
830 ELRLoseFocus();
831 ChangesApplied();
834 void SvxStdParagraphTabPage::ChangesApplied()
836 m_aLeftIndent.save_value();
837 m_aRightIndent.save_value();
838 m_aFLineIndent.save_value();
839 m_xLineDist->save_value();
840 m_xLineDistAtPercentBox->save_value();
841 m_xLineDistAtMetricBox->save_value();
842 m_xRegisterCB->save_state();
843 m_aTopDist.save_value();
844 m_aBottomDist.save_value();
845 m_xContextualCB->save_state();
846 m_xAutoCB->save_state();
849 void SvxStdParagraphTabPage::EnableRelativeMode()
851 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );
853 m_aLeftIndent.EnableRelativeMode( 0, 999 );
854 m_aFLineIndent.EnableRelativeMode( 0, 999 );
855 m_aRightIndent.EnableRelativeMode( 0, 999 );
856 m_aTopDist.EnableRelativeMode( 0, 999 );
857 m_aBottomDist.EnableRelativeMode( 0, 999 );
858 bRelativeMode = true;
861 void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet )
863 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
864 SfxItemState eItemState = rSet.GetItemState( _nWhich );
866 if ( eItemState < SfxItemState::DEFAULT )
867 return;
869 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>( rSet.Get( _nWhich ) );
870 SvxAdjust eAdjust = rAdj.GetAdjust();
871 if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block )
873 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
874 eItemState = rSet.GetItemState( _nWhich );
876 if ( eItemState >= SfxItemState::DEFAULT )
878 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet.Get( _nWhich ) );
879 SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue();
881 m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection );
883 if ( eAdjust == SvxAdjust::Block )
884 m_aExampleWin.SetLastLine( rAdj.GetLastBlock() );
887 else
889 m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right );
890 eAdjust = SvxAdjust::Left; //required for correct preview display
891 m_aExampleWin.SetLastLine( eAdjust );
893 m_aExampleWin.SetAdjust( eAdjust );
895 UpdateExample_Impl();
898 DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
900 ELRLoseFocus();
902 if ( _pSet )
903 FillItemSet( _pSet );
904 return DeactivateRC::LeavePage;
907 SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
908 : SfxTabPage(pPage, pController, u"cui/ui/paraindentspacing.ui"_ustr, u"ParaIndentSpacing"_ustr, &rAttr)
909 , nWidth(11905 /*567 * 50*/)
910 , nMinFixDist(0)
911 , bRelativeMode(false)
912 , m_aLeftIndent(m_xBuilder->weld_metric_spin_button(u"spinED_LEFTINDENT"_ustr, FieldUnit::CM))
913 , m_aRightIndent(m_xBuilder->weld_metric_spin_button(u"spinED_RIGHTINDENT"_ustr, FieldUnit::CM))
914 , m_xFLineLabel(m_xBuilder->weld_label(u"labelFT_FLINEINDENT"_ustr))
915 , m_aFLineIndent(m_xBuilder->weld_metric_spin_button(u"spinED_FLINEINDENT"_ustr, FieldUnit::CM))
916 , m_xAutoCB(m_xBuilder->weld_check_button(u"checkCB_AUTO"_ustr))
917 , m_aTopDist(m_xBuilder->weld_metric_spin_button(u"spinED_TOPDIST"_ustr, FieldUnit::CM))
918 , m_aBottomDist(m_xBuilder->weld_metric_spin_button(u"spinED_BOTTOMDIST"_ustr, FieldUnit::CM))
919 , m_xContextualCB(m_xBuilder->weld_check_button(u"checkCB_CONTEXTUALSPACING"_ustr))
920 , m_xLineDist(m_xBuilder->weld_combo_box(u"comboLB_LINEDIST"_ustr))
921 , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button(u"spinED_LINEDISTPERCENT"_ustr, FieldUnit::PERCENT))
922 , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button(u"spinED_LINEDISTMETRIC"_ustr, FieldUnit::CM))
923 , m_xLineDistAtPlaceHolderBox(m_xBuilder->weld_metric_spin_button(u"spinED_BLANK"_ustr, FieldUnit::CM))
924 , m_xLineDistAtLabel(m_xBuilder->weld_label(u"labelFT_LINEDIST"_ustr))
925 , m_xAbsDist(m_xBuilder->weld_label(u"labelST_LINEDIST_ABS"_ustr))
926 , m_xRegisterCB(m_xBuilder->weld_check_button(u"checkCB_REGISTER"_ustr))
927 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, u"drawingareaWN_EXAMPLE"_ustr, m_aExampleWin))
929 // this page needs ExchangeSupport
930 SetExchangeSupport();
932 m_xLineDistAtMetricBox->hide();
933 m_xLineDistAtPlaceHolderBox->hide();
934 m_xLineDistAtPlaceHolderBox->set_text(OUString());
936 Init_Impl();
937 m_aFLineIndent.set_min(-9999, FieldUnit::NONE); // is set to 0 on default
940 SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
944 void SvxStdParagraphTabPage::EnableNegativeMode()
946 m_aLeftIndent.set_min(-9999, FieldUnit::NONE);
947 m_aRightIndent.set_min(-9999, FieldUnit::NONE);
948 m_aRightIndent.EnableNegativeMode();
949 m_aLeftIndent.EnableNegativeMode();
952 void SvxStdParagraphTabPage::SetLineSpacing_Impl
954 const SvxLineSpacingItem &rAttr
957 MapUnit eUnit = GetItemSet().GetPool()->GetMetric( rAttr.Which() );
959 switch( rAttr.GetLineSpaceRule() )
961 case SvxLineSpaceRule::Auto:
963 SvxInterLineSpaceRule eInter = rAttr.GetInterLineSpaceRule();
965 switch( eInter )
967 // Default single line spacing
968 case SvxInterLineSpaceRule::Off:
969 m_xLineDist->set_active( LLINESPACE_1 );
970 break;
972 // Default single line spacing
973 case SvxInterLineSpaceRule::Prop:
974 if ( 100 == rAttr.GetPropLineSpace() )
976 m_xLineDist->set_active( LLINESPACE_1 );
977 break;
979 // 1.15 line spacing
980 if ( 115 == rAttr.GetPropLineSpace() )
982 m_xLineDist->set_active( LLINESPACE_115 );
983 break;
985 // 1.5 line spacing
986 if ( 150 == rAttr.GetPropLineSpace() )
988 m_xLineDist->set_active( LLINESPACE_15 );
989 break;
991 // double line spacing
992 if ( 200 == rAttr.GetPropLineSpace() )
994 m_xLineDist->set_active( LLINESPACE_2 );
995 break;
997 // the set per cent value
998 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(rAttr.GetPropLineSpace()), FieldUnit::NONE);
999 m_xLineDist->set_active( LLINESPACE_PROP );
1000 break;
1002 case SvxInterLineSpaceRule::Fix:
1003 SetMetricValue( *m_xLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
1004 m_xLineDist->set_active( LLINESPACE_DURCH );
1005 break;
1006 default: ;//prevent warning
1009 break;
1010 case SvxLineSpaceRule::Fix:
1011 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
1012 m_xLineDist->set_active( LLINESPACE_FIX );
1013 break;
1015 case SvxLineSpaceRule::Min:
1016 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
1017 m_xLineDist->set_active( LLINESPACE_MIN );
1018 break;
1019 default: ;//prevent warning
1021 LineDistHdl_Impl( *m_xLineDist );
1024 IMPL_LINK_NOARG(SvxStdParagraphTabPage, LineDistPopupHdl_Impl, weld::ComboBox&, void)
1026 m_bLineDistToggled = true;
1029 IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void)
1031 switch (rBox.get_active())
1033 case LLINESPACE_1:
1034 case LLINESPACE_115:
1035 case LLINESPACE_15:
1036 case LLINESPACE_2:
1037 m_xLineDistAtLabel->set_sensitive(false);
1038 m_xLineDistAtPercentBox->hide();
1039 m_xLineDistAtMetricBox->hide();
1040 m_xLineDistAtPlaceHolderBox->show();
1041 break;
1043 case LLINESPACE_DURCH:
1044 // setting a sensible default?
1045 // limit MS min(10, aPageSize)
1046 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
1048 if (m_xLineDistAtPlaceHolderBox->get_visible())
1049 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE);
1050 m_xLineDistAtPlaceHolderBox->hide();
1051 m_xLineDistAtPercentBox->hide();
1052 m_xLineDistAtMetricBox->show();
1053 m_xLineDistAtLabel->set_sensitive(true);
1054 break;
1056 case LLINESPACE_MIN:
1057 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
1059 if (m_xLineDistAtPlaceHolderBox->get_visible())
1060 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP);
1061 m_xLineDistAtPlaceHolderBox->hide();
1062 m_xLineDistAtPercentBox->hide();
1063 m_xLineDistAtMetricBox->show();
1064 m_xLineDistAtLabel->set_sensitive(true);
1065 break;
1067 case LLINESPACE_PROP:
1069 if (m_xLineDistAtPlaceHolderBox->get_visible())
1070 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP);
1071 m_xLineDistAtPlaceHolderBox->hide();
1072 m_xLineDistAtMetricBox->hide();
1073 m_xLineDistAtPercentBox->show();
1074 m_xLineDistAtLabel->set_sensitive(true);
1075 break;
1076 case LLINESPACE_FIX:
1078 auto nTemp = m_xLineDistAtMetricBox->get_value(FieldUnit::NONE);
1079 m_xLineDistAtMetricBox->set_min(m_xLineDistAtMetricBox->normalize(nMinFixDist), FieldUnit::TWIP);
1081 // if the value has been changed at SetMin,
1082 // it is time for the default
1083 if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp)
1084 SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer
1085 m_xLineDistAtPlaceHolderBox->hide();
1086 m_xLineDistAtPercentBox->hide();
1087 m_xLineDistAtMetricBox->show();
1088 m_xLineDistAtLabel->set_sensitive(true);
1090 break;
1092 UpdateExample_Impl();
1095 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ModifyHdl_Impl, weld::MetricSpinButton&, void)
1097 UpdateExample_Impl();
1100 void SvxStdParagraphTabPage::Init_Impl()
1102 m_xLineDist->connect_popup_toggled(LINK(this, SvxStdParagraphTabPage, LineDistPopupHdl_Impl));
1103 m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl));
1105 Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl);
1106 m_aFLineIndent.connect_value_changed(aLink2);
1107 m_aLeftIndent.connect_value_changed(aLink2);
1108 m_aRightIndent.connect_value_changed(aLink2);
1110 Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl);
1111 m_aTopDist.connect_value_changed(aLink);
1112 m_aBottomDist.connect_value_changed(aLink);
1114 m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl));
1115 SfxItemPool* pPool = GetItemSet().GetPool();
1116 assert(pPool && "Where is the pool?");
1117 FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
1119 m_aTopDist.set_max( m_aTopDist.normalize( MAX_DURCH ), eUnit );
1120 m_aBottomDist.set_max( m_aBottomDist.normalize( MAX_DURCH ), eUnit );
1121 m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit );
1124 void SvxStdParagraphTabPage::UpdateExample_Impl()
1126 m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_aFLineIndent.denormalize( m_aFLineIndent.get_value( FieldUnit::TWIP ) )) );
1127 m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_aLeftIndent.denormalize( m_aLeftIndent.get_value( FieldUnit::TWIP ) ) ) );
1128 m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_aRightIndent.denormalize( m_aRightIndent.get_value( FieldUnit::TWIP ) ) ) );
1129 m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.denormalize( m_aTopDist.get_value( FieldUnit::TWIP ) )) );
1130 m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.denormalize( m_aBottomDist.get_value( FieldUnit::TWIP ) )) );
1132 int nPos = m_xLineDist->get_active();
1134 switch ( nPos )
1136 case LLINESPACE_1:
1137 case LLINESPACE_115:
1138 case LLINESPACE_15:
1139 case LLINESPACE_2:
1140 case LLINESPACE_PROP:
1141 case LLINESPACE_MIN:
1142 case LLINESPACE_DURCH:
1143 case LLINESPACE_FIX:
1144 m_aExampleWin.SetLineSpace( static_cast<SvxPrevLineSpace>(nPos) );
1145 break;
1147 m_aExampleWin.Invalidate();
1150 void SvxStdParagraphTabPage::EnableRegisterMode()
1152 m_xRegisterCB->show();
1155 void SvxStdParagraphTabPage::EnableContextualMode()
1157 m_xContextualCB->show();
1160 IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::Toggleable&, rBox, void)
1162 bool bEnable = !rBox.get_active();
1163 m_xFLineLabel->set_sensitive(bEnable);
1164 m_aFLineIndent.set_sensitive(bEnable);
1167 void SvxStdParagraphTabPage::EnableAutoFirstLine()
1169 m_xAutoCB->show();
1172 void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
1175 /* different bit represent call to different method of SvxStdParagraphTabPage
1176 0x0001 --->EnableRelativeMode()
1177 0x0002 --->EnableRegisterMode()
1178 0x0004 --->EnableAutoFirstLine()
1179 0x0008 --->EnableNegativeMode()
1180 0x0010 --->EnableContextualMode()
1182 const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false);
1183 const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false);
1185 if (pPageWidthItem)
1186 nWidth = pPageWidthItem->GetValue();
1188 if (pFlagSetItem )
1190 if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
1191 EnableRelativeMode();
1193 if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
1194 EnableRegisterMode();
1196 if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
1197 EnableAutoFirstLine();
1200 if (pFlagSetItem)
1202 if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
1203 EnableNegativeMode();
1205 if (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
1206 EnableContextualMode();
1210 #define LASTLINEPOS_DEFAULT 0
1211 #define LASTLINEPOS_LEFT 1
1213 #define LASTLINECOUNT_OLD 3
1214 #define LASTLINECOUNT_NEW 4
1216 SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
1217 : SfxTabPage(pPage, pController, u"cui/ui/paragalignpage.ui"_ustr, u"ParaAlignPage"_ustr, &rSet)
1218 , m_bSdrVertAlign(false)
1219 , m_xLeft(m_xBuilder->weld_radio_button(u"radioBTN_LEFTALIGN"_ustr))
1220 , m_xRight(m_xBuilder->weld_radio_button(u"radioBTN_RIGHTALIGN"_ustr))
1221 , m_xCenter(m_xBuilder->weld_radio_button(u"radioBTN_CENTERALIGN"_ustr))
1222 , m_xJustify(m_xBuilder->weld_radio_button(u"radioBTN_JUSTIFYALIGN"_ustr))
1223 , m_xLeftBottom(m_xBuilder->weld_label(u"labelST_LEFTALIGN_ASIAN"_ustr))
1224 , m_xRightTop(m_xBuilder->weld_label(u"labelST_RIGHTALIGN_ASIAN"_ustr))
1225 , m_xLastLineFT(m_xBuilder->weld_label(u"labelLB_LASTLINE"_ustr))
1226 , m_xLastLineLB(m_xBuilder->weld_combo_box(u"comboLB_LASTLINE"_ustr))
1227 , m_xExpandCB(m_xBuilder->weld_check_button(u"checkCB_EXPAND"_ustr))
1228 , m_xSnapToGridCB(m_xBuilder->weld_check_button(u"checkCB_SNAP"_ustr))
1229 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, u"drawingareaWN_EXAMPLE"_ustr, m_aExampleWin))
1230 , m_xVertAlignFL(m_xBuilder->weld_widget(u"frameFL_VERTALIGN"_ustr))
1231 , m_xVertAlignLB(m_xBuilder->weld_combo_box(u"comboLB_VERTALIGN"_ustr))
1232 , m_xVertAlign(m_xBuilder->weld_label(u"labelFL_VERTALIGN"_ustr))
1233 , m_xVertAlignSdr(m_xBuilder->weld_label(u"labelST_VERTALIGN_SDR"_ustr))
1234 , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box(u"comboLB_TEXTDIRECTION"_ustr)))
1236 SetExchangeSupport();
1238 sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;
1240 if ( SvtCJKOptions::IsAsianTypographyEnabled() )
1242 m_xLeft->set_label(m_xLeftBottom->get_label());
1243 m_xRight->set_label(m_xRightTop->get_label());
1245 OUString sLeft(m_xLeft->get_label());
1246 sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );
1248 if (m_xLastLineLB->get_count() == LASTLINECOUNT_OLD)
1250 m_xLastLineLB->remove(0);
1251 m_xLastLineLB->insert_text(0, sLeft);
1253 else
1254 nLastLinePos = LASTLINEPOS_LEFT;
1257 // remove "Default" or "Left" entry, depends on CJKOptions
1258 if (m_xLastLineLB->get_count() == LASTLINECOUNT_NEW)
1259 m_xLastLineLB->remove(nLastLinePos);
1261 Link<weld::Toggleable&, void> aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
1262 m_xLeft->connect_toggled(aLink);
1263 m_xRight->connect_toggled(aLink);
1264 m_xCenter->connect_toggled(aLink);
1265 m_xJustify->connect_toggled(aLink);
1266 m_xLastLineLB->connect_changed(LINK(this, SvxParaAlignTabPage, LastLineHdl_Impl));
1267 m_xTextDirectionLB->connect_changed(LINK(this, SvxParaAlignTabPage, TextDirectionHdl_Impl));
1269 m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
1270 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
1271 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
1274 SvxParaAlignTabPage::~SvxParaAlignTabPage()
1278 DeactivateRC SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
1280 if ( _pSet )
1281 FillItemSet( _pSet );
1282 return DeactivateRC::LeavePage;
1285 std::unique_ptr<SfxTabPage> SvxParaAlignTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1287 return std::make_unique<SvxParaAlignTabPage>(pPage, pController, *rSet);
1290 bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet )
1292 bool bModified = false;
1294 bool bAdj = false;
1295 SvxAdjust eAdjust = SvxAdjust::Left;
1297 if (m_xLeft->get_active())
1299 eAdjust = SvxAdjust::Left;
1300 bAdj = m_xLeft->get_saved_state() == TRISTATE_FALSE;
1302 else if (m_xRight->get_active())
1304 eAdjust = SvxAdjust::Right;
1305 bAdj = m_xRight->get_saved_state() == TRISTATE_FALSE;
1307 else if (m_xCenter->get_active())
1309 eAdjust = SvxAdjust::Center;
1310 bAdj = m_xCenter->get_saved_state() == TRISTATE_FALSE;
1312 else if (m_xJustify->get_active())
1314 eAdjust = SvxAdjust::Block;
1315 bAdj = m_xJustify->get_saved_state() == TRISTATE_FALSE ||
1316 m_xExpandCB->get_state_changed_from_saved() ||
1317 m_xLastLineLB->get_value_changed_from_saved();
1320 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1322 if (bAdj)
1324 SvxAdjust eOneWord = m_xExpandCB->get_active() ? SvxAdjust::Block : SvxAdjust::Left;
1326 int nLBPos = m_xLastLineLB->get_active();
1327 SvxAdjust eLastBlock = SvxAdjust::Left;
1328 if ( 1 == nLBPos )
1329 eLastBlock = SvxAdjust::Center;
1330 else if ( 2 == nLBPos )
1331 eLastBlock = SvxAdjust::Block;
1333 SvxAdjustItem aAdj( static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) );
1334 aAdj.SetAdjust( eAdjust );
1335 aAdj.SetOneWord( eOneWord );
1336 aAdj.SetLastBlock( eLastBlock );
1337 rOutSet->Put( aAdj );
1338 bModified = true;
1341 if (m_xSnapToGridCB->get_state_changed_from_saved())
1343 rOutSet->Put(SvxParaGridItem(m_xSnapToGridCB->get_active(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
1344 bModified = true;
1347 if (m_xVertAlignLB->get_value_changed_from_saved())
1349 if (m_bSdrVertAlign)
1350 rOutSet->Put(SdrTextVertAdjustItem(static_cast<SdrTextVertAdjust>(m_xVertAlignLB->get_active())));
1351 else
1352 rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN )));
1353 bModified = true;
1356 if (m_xTextDirectionLB->get_visible())
1358 if (m_xTextDirectionLB->get_value_changed_from_saved())
1360 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1361 rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
1362 bModified = true;
1366 return bModified;
1369 void SvxParaAlignTabPage::ActivatePage( const SfxItemSet& rSet )
1371 Reset( &rSet );
1374 void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet )
1376 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1377 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1379 sal_Int32 nLBSelect = 0;
1380 if ( eItemState >= SfxItemState::DEFAULT )
1382 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>(rSet->Get( _nWhich ));
1384 switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
1386 case SvxAdjust::Left: m_xLeft->set_active(true); break;
1388 case SvxAdjust::Right: m_xRight->set_active(true); break;
1390 case SvxAdjust::Center: m_xCenter->set_active(true); break;
1392 case SvxAdjust::Block: m_xJustify->set_active(true); break;
1393 default: ; //prevent warning
1395 bool bEnable = m_xJustify->get_active();
1396 m_xLastLineFT->set_sensitive(bEnable);
1397 m_xLastLineLB->set_sensitive(bEnable);
1399 switch(rAdj.GetLastBlock())
1401 case SvxAdjust::Left: nLBSelect = 0; break;
1403 case SvxAdjust::Center: nLBSelect = 1; break;
1405 case SvxAdjust::Block: nLBSelect = 2; break;
1406 default: ; //prevent warning
1408 m_xExpandCB->set_sensitive(bEnable && nLBSelect == 2);
1409 m_xExpandCB->set_active(SvxAdjust::Block == rAdj.GetOneWord());
1411 else
1413 m_xLeft->set_active(false);
1414 m_xRight->set_active(false);
1415 m_xCenter->set_active(false);
1416 m_xJustify->set_active(false);
1418 m_xLastLineLB->set_active(nLBSelect);
1420 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
1421 if(nHtmlMode & HTMLMODE_ON)
1423 m_xLastLineLB->hide();
1424 m_xLastLineFT->hide();
1425 m_xExpandCB->hide();
1426 if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
1427 m_xJustify->set_sensitive(false);
1428 m_xSnapToGridCB->hide();
1430 _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
1431 eItemState = rSet->GetItemState( _nWhich );
1432 if ( eItemState >= SfxItemState::DEFAULT )
1434 const SvxParaGridItem& rSnap = static_cast<const SvxParaGridItem&>(rSet->Get( _nWhich ));
1435 m_xSnapToGridCB->set_active(rSnap.GetValue());
1438 _nWhich = m_bSdrVertAlign ? SDRATTR_TEXT_VERTADJUST : GetWhich( SID_PARA_VERTALIGN );
1439 eItemState = rSet->GetItemState( _nWhich );
1441 if ( eItemState >= SfxItemState::DEFAULT )
1443 m_xVertAlignFL->show();
1445 if (m_bSdrVertAlign)
1447 const SdrTextVertAdjustItem& rAlign = static_cast<const SdrTextVertAdjustItem&>(rSet->Get( _nWhich ));
1448 m_xVertAlignLB->set_active(rAlign.GetValue());
1450 else
1452 const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich ));
1453 m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue()));
1457 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
1458 //text direction
1459 if( SfxItemState::DEFAULT <= rSet->GetItemState( _nWhich ) )
1461 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet->Get( _nWhich ) );
1462 m_xTextDirectionLB->set_active_id(rFrameDirItem.GetValue());
1463 m_xTextDirectionLB->save_value();
1466 m_xSnapToGridCB->save_state();
1467 m_xVertAlignLB->save_value();
1468 m_xLeft->save_state();
1469 m_xRight->save_state();
1470 m_xCenter->save_state();
1471 m_xJustify->save_state();
1472 m_xLastLineLB->save_value();
1473 m_xExpandCB->save_state();
1475 UpdateExample_Impl();
1478 void SvxParaAlignTabPage::ChangesApplied()
1480 m_xTextDirectionLB->save_value();
1481 m_xSnapToGridCB->save_state();
1482 m_xVertAlignLB->save_value();
1483 m_xLeft->save_state();
1484 m_xRight->save_state();
1485 m_xCenter->save_state();
1486 m_xJustify->save_state();
1487 m_xLastLineLB->save_value();
1488 m_xExpandCB->save_state();
1491 IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl, weld::Toggleable&, void)
1493 bool bJustify = m_xJustify->get_active();
1494 m_xLastLineFT->set_sensitive(bJustify);
1495 m_xLastLineLB->set_sensitive(bJustify);
1496 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1497 m_xExpandCB->set_sensitive(bJustify && bLastLineIsBlock);
1498 //set last line listbox to entry position 0 if not enabled
1499 if (!m_xLastLineLB->get_sensitive())
1500 m_xLastLineLB->set_active(0);
1501 //uncheck 'Expand ... word' when check box is not enabled
1502 if (!m_xExpandCB->get_sensitive())
1503 m_xExpandCB->set_active(false);
1504 UpdateExample_Impl();
1507 IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl, weld::ComboBox&, void)
1509 //fdo#41350 only enable 'Expand last word' if last line is also justified
1510 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1511 m_xExpandCB->set_sensitive(bLastLineIsBlock);
1512 //uncheck 'Expand ... word' when check box is not enabled
1513 if (!m_xExpandCB->get_sensitive())
1514 m_xExpandCB->set_active(false);
1515 UpdateExample_Impl();
1518 IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl, weld::ComboBox&, void)
1520 UpdateExample_Impl();
1523 void SvxParaAlignTabPage::UpdateExample_Impl()
1525 if (m_xLeft->get_active())
1527 m_aExampleWin.EnableRTL(false);
1528 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1529 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1531 else if (m_xRight->get_active())
1533 m_aExampleWin.EnableRTL(true);
1534 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1535 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1537 else
1539 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1540 switch ( eDir )
1542 case SvxFrameDirection::Environment :
1543 if ( !m_xRight->get_active() )
1544 m_aExampleWin.EnableRTL( AllSettings::GetLayoutRTL() );
1545 break;
1546 case SvxFrameDirection::Horizontal_RL_TB :
1547 if ( !m_xLeft->get_active() )
1548 m_aExampleWin.EnableRTL( true );
1549 break;
1550 case SvxFrameDirection::Horizontal_LR_TB :
1551 if ( !m_xRight->get_active() )
1552 m_aExampleWin.EnableRTL( false );
1553 break;
1554 default: ; //prevent warning
1556 if (m_xCenter->get_active())
1557 m_aExampleWin.SetAdjust( SvxAdjust::Center );
1558 else if (m_xJustify->get_active())
1560 m_aExampleWin.SetAdjust( SvxAdjust::Block );
1561 int nLBPos = m_xLastLineLB->get_active();
1562 if (nLBPos == 0)
1563 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1564 else if (nLBPos == 1)
1565 m_aExampleWin.SetLastLine(SvxAdjust::Center);
1566 else if (nLBPos == 2)
1567 m_aExampleWin.SetLastLine(SvxAdjust::Block);
1571 m_aExampleWin.Invalidate();
1574 void SvxParaAlignTabPage::EnableJustifyExt()
1576 m_xLastLineFT->show();
1577 m_xLastLineLB->show();
1578 m_xExpandCB->show();
1579 if (SvtCJKOptions::IsAsianTypographyEnabled())
1580 m_xSnapToGridCB->show();
1584 void SvxParaAlignTabPage::EnableSdrVertAlign()
1586 m_bSdrVertAlign = true;
1588 m_xVertAlignLB->remove_id(u"0"_ustr);
1589 m_xVertAlignLB->remove_id(u"1"_ustr);
1590 m_xVertAlign->set_label(m_xVertAlignSdr->get_label());
1593 void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet)
1595 const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false);
1596 if (pBoolItem && pBoolItem->GetValue())
1597 EnableJustifyExt();
1600 std::unique_ptr<SfxTabPage> SvxExtParagraphTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1602 return std::make_unique<SvxExtParagraphTabPage>(pPage, pController, *rSet);
1605 bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
1607 bool bModified = false;
1608 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1609 const TriState eHyphenState = m_xHyphenBox->get_state();
1610 const SfxPoolItem* pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_HYPHENZONE );
1612 if ( m_xHyphenBox->get_state_changed_from_saved() ||
1613 m_xHyphenNoCapsBox->get_state_changed_from_saved() ||
1614 m_xHyphenNoLastWordBox->get_state_changed_from_saved() ||
1615 m_xExtHyphenBeforeBox->get_value_changed_from_saved() ||
1616 m_xExtHyphenAfterBox->get_value_changed_from_saved() ||
1617 m_xExtCompoundHyphenBeforeBox->get_value_changed_from_saved() ||
1618 m_xMaxHyphenEdit->get_value_changed_from_saved() ||
1619 m_xMinWordLength->get_value_changed_from_saved() ||
1620 m_aHyphenZone.get_value_changed_from_saved() ||
1621 m_xAcrossParagraphBox->get_state_changed_from_saved() ||
1622 m_xAcrossColumnBox->get_state_changed_from_saved() ||
1623 m_xAcrossPageBox->get_state_changed_from_saved() ||
1624 m_xAcrossSpreadBox->get_state_changed_from_saved() )
1626 SvxHyphenZoneItem aHyphen(
1627 static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) );
1628 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1629 aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() != TRISTATE_TRUE);
1630 aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE);
1632 if ( eHyphenState == TRISTATE_TRUE )
1634 aHyphen.GetMinLead() = static_cast<sal_uInt8>(m_xExtHyphenBeforeBox->get_value());
1635 aHyphen.GetMinTrail() = static_cast<sal_uInt8>(m_xExtHyphenAfterBox->get_value());
1636 aHyphen.GetCompoundMinLead() = static_cast<sal_uInt8>(m_xExtCompoundHyphenBeforeBox->get_value());
1637 aHyphen.GetMinWordLength() = static_cast<sal_uInt8>(m_xMinWordLength->get_value());
1639 aHyphen.GetMaxHyphens() = static_cast<sal_uInt8>(m_xMaxHyphenEdit->get_value());
1641 SfxItemPool* pPool = GetItemSet().GetPool();
1642 DBG_ASSERT( pPool, "Where is the pool?" );
1643 MapUnit eUnit = pPool->GetMetric( _nWhich );
1644 aHyphen.GetTextHyphenZone() = static_cast<sal_uInt16>(m_aHyphenZone.GetCoreValue(eUnit));
1645 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1646 aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE);
1647 const TriState eAcrossParagraphState = m_xAcrossParagraphBox->get_state();
1648 const TriState eAcrossColumnState = m_xAcrossColumnBox->get_state();
1649 const TriState eAcrossPageState = m_xAcrossPageBox->get_state();
1650 const TriState eAcrossSpreadState = m_xAcrossSpreadBox->get_state();
1651 aHyphen.SetKeep( eAcrossSpreadState != TRISTATE_TRUE );
1652 if ( eAcrossSpreadState == TRISTATE_TRUE )
1654 // hyphenate across column, page and spread -> ParaHyphenationKeep = false and
1655 // set default value 3 (COLUMN)
1656 aHyphen.GetKeepType() =
1657 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN);
1659 else if ( eAcrossPageState == TRISTATE_TRUE )
1661 // hyphenate across column and page, but not spread -> 1 (SPREAD)
1662 aHyphen.GetKeepType() =
1663 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::SPREAD);
1665 else if ( eAcrossColumnState == TRISTATE_TRUE )
1667 // hyphenate across column, but not page and spread -> 2 (PAGE)
1668 aHyphen.GetKeepType() =
1669 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::PAGE);
1671 else if ( eAcrossParagraphState == TRISTATE_TRUE )
1673 // hyphenate across last full paragraph line, but not page and spread -> 2 (PAGE)
1674 aHyphen.GetKeepType() =
1675 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN);
1677 else
1679 // don't hyphenate across last full paragraph line,
1680 // also column, page and spread -> 4 (COLUMN)
1681 aHyphen.GetKeepType() =
1682 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::ALWAYS);
1685 if ( !pOld ||
1686 *static_cast<const SvxHyphenZoneItem*>(pOld) != aHyphen ||
1687 m_xHyphenBox->get_state_changed_from_saved())
1689 rOutSet->Put( aHyphen );
1690 bModified = true;
1694 if (m_xPageNumBox->get_sensitive()
1695 && (m_xPageNumBox->get_state_changed_from_saved() || m_xPagenumEdit->get_value_changed_from_saved()))
1697 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
1699 if (TRISTATE_TRUE == m_xPageNumBox->get_state()
1700 && (!pOld || IsInvalidItem(pOld)
1701 || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != m_xPagenumEdit->get_value()))
1703 SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM,
1704 static_cast<sal_uInt16>(m_xPagenumEdit->get_value()));
1705 rOutSet->Put( aPageNum );
1706 bModified = true;
1708 else if (TRISTATE_FALSE == m_xPageNumBox->get_state()
1709 && (pOld || IsInvalidItem(pOld)))
1711 // need to tell sw to remove the item
1712 rOutSet->DisableItem(SID_ATTR_PARA_PAGENUM);
1713 bModified = true;
1717 // pagebreak
1719 TriState eState = m_xApplyCollBtn->get_state();
1720 bool bIsPageModel = false;
1722 OUString sPage;
1723 if ( m_xApplyCollBtn->get_state_changed_from_saved() ||
1724 ( TRISTATE_TRUE == eState &&
1725 m_xApplyCollBox->get_value_changed_from_saved() ) )
1727 if ( eState == TRISTATE_TRUE )
1729 sPage = m_xApplyCollBox->get_active_text();
1730 bIsPageModel = !sPage.isEmpty();
1732 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_MODEL );
1734 if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage )
1736 rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) );
1737 bModified = true;
1739 else
1740 bIsPageModel = false;
1742 else if(TRISTATE_TRUE == eState && m_xApplyCollBtn->get_sensitive())
1743 bIsPageModel = true;
1744 else
1745 rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) );
1747 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1749 if ( bIsPageModel )
1750 // if PageModel is turned on, always turn off PageBreak
1751 rOutSet->Put( SvxFormatBreakItem( SvxBreak::NONE, _nWhich ) );
1752 else
1754 eState = m_xPageBreakBox->get_state();
1755 SfxItemState eModelState = GetItemSet().GetItemState(SID_ATTR_PARA_MODEL, false);
1757 if ( (eModelState == SfxItemState::SET && TRISTATE_TRUE == m_xPageBreakBox->get_state()) ||
1758 m_xPageBreakBox->get_state_changed_from_saved() ||
1759 m_xBreakTypeLB->get_value_changed_from_saved() ||
1760 m_xBreakPositionLB->get_value_changed_from_saved() )
1762 const SvxFormatBreakItem rOldBreak(
1763 static_cast<const SvxFormatBreakItem&>(GetItemSet().Get( _nWhich )));
1764 SvxFormatBreakItem aBreak(rOldBreak.GetBreak(), rOldBreak.Which());
1766 switch ( eState )
1768 case TRISTATE_TRUE:
1770 bool bBefore = m_xBreakPositionLB->get_active() == 0;
1772 if (m_xBreakTypeLB->get_active() == 0)
1774 if ( bBefore )
1775 aBreak.SetValue( SvxBreak::PageBefore );
1776 else
1777 aBreak.SetValue( SvxBreak::PageAfter );
1779 else
1781 if ( bBefore )
1782 aBreak.SetValue( SvxBreak::ColumnBefore );
1783 else
1784 aBreak.SetValue( SvxBreak::ColumnAfter );
1786 break;
1789 case TRISTATE_FALSE:
1790 aBreak.SetValue( SvxBreak::NONE );
1791 break;
1792 default: ; //prevent warning
1794 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGEBREAK );
1796 if ( eState != m_xPageBreakBox->get_saved_state() ||
1797 !pOld || !( *static_cast<const SvxFormatBreakItem*>(pOld) == aBreak ) )
1799 bModified = true;
1800 rOutSet->Put( aBreak );
1805 // paragraph split
1806 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1807 eState = m_xAllowSplitBox->get_state();
1809 if (m_xAllowSplitBox->get_state_changed_from_saved())
1811 rOutSet->Put( SvxFormatSplitItem( eState == TRISTATE_TRUE, _nWhich ) );
1812 bModified = true;
1815 // keep paragraphs
1816 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1817 eState = m_xKeepParaBox->get_state();
1819 if (m_xKeepParaBox->get_state_changed_from_saved())
1821 // if the status has changed, putting is necessary
1822 rOutSet->Put( SvxFormatKeepItem( eState == TRISTATE_TRUE, _nWhich ) );
1823 bModified = true;
1826 // widows and orphans
1827 TypedWhichId<SvxWidowsItem> nWidowsWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1828 eState = m_xWidowBox->get_state();
1830 if ( m_xWidowBox->get_state_changed_from_saved() ||
1831 m_xWidowRowNo->get_value_changed_from_saved() )
1833 SvxWidowsItem rItem( eState == TRISTATE_TRUE ?
1834 static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, nWidowsWhich );
1835 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS );
1837 if ( m_xWidowBox->get_state_changed_from_saved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) )
1839 rOutSet->Put( rItem );
1840 bModified = true;
1844 TypedWhichId<SvxOrphansItem> nOrphansWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1845 eState = m_xOrphanBox->get_state();
1847 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1848 m_xOrphanRowNo->get_value_changed_from_saved() )
1850 SvxOrphansItem rItem( eState == TRISTATE_TRUE ?
1851 static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, nOrphansWhich );
1852 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS );
1854 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1855 !pOld ||
1856 !( *static_cast<const SvxOrphansItem*>(pOld) == rItem ) )
1858 rOutSet->Put( rItem );
1859 bModified = true;
1863 return bModified;
1865 void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
1867 SfxItemPool* pPool = rSet->GetPool();
1868 DBG_ASSERT( pPool, "Where is the pool?" );
1870 // adjust metric
1871 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
1872 if (UseCharUnitInUI(*rSet))
1873 eFUnit = FieldUnit::CHAR;
1875 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1876 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1878 bool bItemAvailable = eItemState >= SfxItemState::DEFAULT;
1879 bool bIsHyphen = false;
1880 if( !bHtmlMode && bItemAvailable )
1882 const SvxHyphenZoneItem& rHyphen =
1883 static_cast<const SvxHyphenZoneItem&>(rSet->Get( _nWhich ));
1884 aHyphenState.bTriStateEnabled = false;
1886 bIsHyphen = rHyphen.IsHyphen();
1887 m_xHyphenBox->set_state(bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE);
1888 m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE);
1889 m_xHyphenNoLastWordBox->set_state(rHyphen.IsNoLastWordHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE);
1891 m_xExtHyphenBeforeBox->set_value(rHyphen.GetMinLead());
1892 m_xExtHyphenAfterBox->set_value(rHyphen.GetMinTrail());
1893 m_xExtCompoundHyphenBeforeBox->set_value(rHyphen.GetCompoundMinLead());
1894 m_xMaxHyphenEdit->set_value(rHyphen.GetMaxHyphens());
1895 m_xMinWordLength->set_value(rHyphen.GetMinWordLength());
1896 m_aHyphenZone.SetFieldUnit(eFUnit);
1897 m_aHyphenZone.SetMetricValue(rHyphen.GetTextHyphenZone(), MapUnit::MapTwip);
1898 m_xAcrossParagraphBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 4 ? TRISTATE_TRUE : TRISTATE_FALSE);
1899 m_xAcrossColumnBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 3 ? TRISTATE_TRUE : TRISTATE_FALSE);
1900 m_xAcrossPageBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 2 ? TRISTATE_TRUE : TRISTATE_FALSE);
1901 m_xAcrossSpreadBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() == 0 ? TRISTATE_TRUE : TRISTATE_FALSE);
1902 aAcrossParagraphState.bTriStateEnabled = false;
1903 aAcrossColumnState.bTriStateEnabled = false;
1904 aAcrossPageState.bTriStateEnabled = false;
1905 aAcrossSpreadState.bTriStateEnabled = false;
1907 else
1909 m_xHyphenBox->set_state(TRISTATE_INDET);
1910 m_xHyphenNoCapsBox->set_state(TRISTATE_INDET);
1911 m_xHyphenNoLastWordBox->set_state(TRISTATE_INDET);
1913 bool bEnable = bItemAvailable && bIsHyphen;
1914 m_xHyphenNoCapsBox->set_sensitive(bEnable);
1915 m_xHyphenNoLastWordBox->set_sensitive(bEnable);
1916 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
1917 m_xExtHyphenAfterBox->set_sensitive(bEnable);
1918 m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable);
1919 m_xBeforeText->set_sensitive(bEnable);
1920 m_xAfterText->set_sensitive(bEnable);
1921 m_xCompoundBeforeText->set_sensitive(bEnable);
1922 m_xMaxHyphenLabel->set_sensitive(bEnable);
1923 m_xMaxHyphenEdit->set_sensitive(bEnable);
1924 m_xMinWordLabel->set_sensitive(bEnable);
1925 m_xMinWordLength->set_sensitive(bEnable);
1926 m_xHyphenZoneLabel->set_sensitive(bEnable);
1927 m_aHyphenZone.set_sensitive(bEnable);
1928 m_xAcrossText->set_sensitive(bEnable);
1929 m_xAcrossParagraphBox->set_sensitive(bEnable);
1930 m_xAcrossColumnBox->set_sensitive(bEnable);
1931 m_xAcrossPageBox->set_sensitive(bEnable);
1932 m_xAcrossSpreadBox->set_sensitive(bEnable);
1934 switch (rSet->GetItemState(SID_ATTR_PARA_PAGENUM))
1936 case SfxItemState::SET:
1938 aPageNumState.bTriStateEnabled = false;
1939 m_xPageNumBox->set_state(TRISTATE_TRUE);
1940 SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(SID_ATTR_PARA_PAGENUM));
1941 const sal_uInt16 nPageNum(pItem->GetValue());
1942 m_xPagenumEdit->set_value(nPageNum);
1943 break;
1945 case SfxItemState::INVALID:
1947 aPageNumState.bTriStateEnabled = true;
1948 m_xPageNumBox->set_state(TRISTATE_INDET);
1949 break;
1951 case SfxItemState::UNKNOWN:
1952 case SfxItemState::DEFAULT:
1953 case SfxItemState::DISABLED:
1955 aPageNumState.bTriStateEnabled = false;
1956 m_xPageNumBox->set_state(TRISTATE_FALSE);
1957 break;
1959 default:
1960 assert(false); // unexpected
1961 break;
1964 if ( bPageBreak )
1966 // first handle PageModel
1967 bool bIsPageModel = false;
1968 eItemState = rSet->GetItemState( SID_ATTR_PARA_MODEL );
1970 if ( eItemState >= SfxItemState::SET )
1972 aApplyCollState.bTriStateEnabled = false;
1974 const SvxPageModelItem& rModel = rSet->Get( SID_ATTR_PARA_MODEL );
1975 const OUString& aStr( rModel.GetValue() );
1977 if (!aStr.isEmpty() && m_xApplyCollBox->find_text(aStr) != -1)
1979 m_xApplyCollBox->set_active_text(aStr);
1980 m_xApplyCollBtn->set_state(TRISTATE_TRUE);
1981 bIsPageModel = true;
1983 m_xPageBreakBox->set_sensitive(true);
1984 aPageBreakState.bTriStateEnabled = false;
1985 m_xBreakTypeFT->set_sensitive(true);
1986 m_xBreakTypeLB->set_sensitive(true);
1987 m_xBreakPositionFT->set_sensitive(true);
1988 m_xBreakPositionLB->set_sensitive(true);
1989 m_xApplyCollBtn->set_sensitive(false);
1990 m_xPageBreakBox->set_state(TRISTATE_TRUE);
1992 //select page break
1993 m_xBreakTypeLB->set_active(0);
1994 //select break before
1995 m_xBreakPositionLB->set_active(0);
1997 else
1999 m_xApplyCollBox->set_active(-1);
2000 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2003 else if ( SfxItemState::INVALID == eItemState )
2005 aApplyCollState.bTriStateEnabled = true;
2006 m_xApplyCollBtn->set_state(TRISTATE_INDET);
2007 m_xApplyCollBox->set_active(-1);
2009 else
2011 m_xApplyCollBtn->set_sensitive(false);
2012 m_xApplyCollBox->set_sensitive(false);
2013 m_xPagenumEdit->set_sensitive(false);
2014 m_xPageNumBox->set_sensitive(false);
2017 if ( !bIsPageModel )
2019 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
2020 eItemState = rSet->GetItemState( _nWhich );
2022 if ( eItemState >= SfxItemState::DEFAULT )
2024 const SvxFormatBreakItem& rPageBreak =
2025 static_cast<const SvxFormatBreakItem&>(rSet->Get( _nWhich ));
2027 SvxBreak eBreak = rPageBreak.GetBreak();
2029 // PageBreak not via CTRL-RETURN,
2030 // then CheckBox can be freed
2031 m_xPageBreakBox->set_sensitive(true);
2032 aPageBreakState.bTriStateEnabled = false;
2033 m_xBreakTypeFT->set_sensitive(true);
2034 m_xBreakTypeLB->set_sensitive(true);
2035 m_xBreakPositionFT->set_sensitive(true);
2036 m_xBreakPositionLB->set_sensitive(true);
2038 m_xPageBreakBox->set_state(TRISTATE_TRUE);
2040 bool _bEnable = eBreak != SvxBreak::NONE &&
2041 eBreak != SvxBreak::ColumnBefore &&
2042 eBreak != SvxBreak::ColumnAfter;
2043 m_xApplyCollBtn->set_sensitive(_bEnable);
2044 if (!_bEnable)
2046 m_xApplyCollBox->set_sensitive(_bEnable);
2047 m_xPageNumBox->set_sensitive(false);
2048 m_xPagenumEdit->set_sensitive(_bEnable);
2051 if ( eBreak == SvxBreak::NONE )
2052 m_xPageBreakBox->set_state(TRISTATE_FALSE);
2054 sal_Int32 nType = 0; // selection position in break type ListBox : Page
2055 sal_Int32 nPosition = 0; // selection position in break position ListBox : Before
2056 switch ( eBreak )
2058 case SvxBreak::PageBefore:
2059 break;
2060 case SvxBreak::PageAfter:
2061 nPosition = 1;
2062 break;
2063 case SvxBreak::ColumnBefore:
2064 nType = 1;
2065 break;
2066 case SvxBreak::ColumnAfter:
2067 nType = 1;
2068 nPosition = 1;
2069 break;
2070 default: ;//prevent warning
2072 m_xBreakTypeLB->set_active(nType);
2073 m_xBreakPositionLB->set_active(nPosition);
2075 else if ( SfxItemState::INVALID == eItemState )
2076 m_xPageBreakBox->set_state(TRISTATE_INDET);
2077 else
2079 m_xPageBreakBox->set_sensitive(false);
2080 m_xBreakTypeFT->set_sensitive(false);
2081 m_xBreakTypeLB->set_sensitive(false);
2082 m_xBreakPositionFT->set_sensitive(false);
2083 m_xBreakPositionLB->set_sensitive(false);
2087 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2088 PageBreakHdl();
2091 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
2092 eItemState = rSet->GetItemState( _nWhich );
2094 if ( eItemState >= SfxItemState::DEFAULT )
2096 aKeepParaState.bTriStateEnabled = false;
2097 const SvxFormatKeepItem& rKeep =
2098 static_cast<const SvxFormatKeepItem&>(rSet->Get( _nWhich ));
2100 if ( rKeep.GetValue() )
2101 m_xKeepParaBox->set_state(TRISTATE_TRUE);
2102 else
2103 m_xKeepParaBox->set_state(TRISTATE_FALSE);
2105 else if ( SfxItemState::INVALID == eItemState )
2106 m_xKeepParaBox->set_state(TRISTATE_INDET);
2107 else
2108 m_xKeepParaBox->set_sensitive(false);
2110 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
2111 eItemState = rSet->GetItemState( _nWhich );
2113 if ( eItemState >= SfxItemState::DEFAULT )
2115 const SvxFormatSplitItem& rSplit =
2116 static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich ));
2117 aAllowSplitState.bTriStateEnabled = false;
2119 if ( !rSplit.GetValue() )
2120 m_xAllowSplitBox->set_state(TRISTATE_FALSE);
2121 else
2123 m_xAllowSplitBox->set_state(TRISTATE_TRUE);
2124 // default widows and orphans to enabled
2125 m_xWidowBox->set_sensitive(true);
2126 m_xOrphanBox->set_sensitive(true);
2129 // widows and orphans
2130 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
2131 SfxItemState eTmpState = rSet->GetItemState( _nWhich );
2133 if ( eTmpState >= SfxItemState::DEFAULT )
2135 const SvxWidowsItem& rWidow =
2136 static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich ));
2137 aWidowState.bTriStateEnabled = false;
2138 const sal_uInt16 nLines = rWidow.GetValue();
2140 bool _bEnable = nLines > 0;
2141 m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines));
2142 m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2143 m_xWidowRowNo->set_sensitive(_bEnable);
2145 else if ( SfxItemState::INVALID == eTmpState )
2146 m_xWidowBox->set_state( TRISTATE_INDET );
2147 else
2148 m_xWidowBox->set_sensitive(false);
2150 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
2151 eTmpState = rSet->GetItemState( _nWhich );
2153 if ( eTmpState >= SfxItemState::DEFAULT )
2155 const SvxOrphansItem& rOrphan =
2156 static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich ));
2157 const sal_uInt16 nLines = rOrphan.GetValue();
2158 aOrphanState.bTriStateEnabled = false;
2160 bool _bEnable = nLines > 0;
2161 m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2162 m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines));
2163 m_xOrphanRowNo->set_sensitive(_bEnable);
2164 m_xOrphanRowLabel->set_sensitive(_bEnable);
2167 else if ( SfxItemState::INVALID == eTmpState )
2168 m_xOrphanBox->set_state(TRISTATE_INDET);
2169 else
2170 m_xOrphanBox->set_sensitive(false);
2171 aOrphanState.eState = m_xOrphanBox->get_state();
2173 else if ( SfxItemState::INVALID == eItemState )
2174 m_xAllowSplitBox->set_state(TRISTATE_INDET);
2175 else
2176 m_xAllowSplitBox->set_sensitive(false);
2178 // so that everything is enabled correctly
2179 AllowSplitHdl();
2180 WidowHdl();
2181 OrphanHdl();
2182 ChangesApplied();
2184 void SvxExtParagraphTabPage::ChangesApplied()
2186 m_xHyphenBox->save_state();
2187 m_xHyphenNoCapsBox->save_state();
2188 m_xHyphenNoLastWordBox->save_state();
2189 m_xExtHyphenBeforeBox->save_value();
2190 m_xExtHyphenAfterBox->save_value();
2191 m_xExtCompoundHyphenBeforeBox->save_value();
2192 m_xMaxHyphenEdit->save_value();
2193 m_xMinWordLength->save_value();
2194 m_aHyphenZone.save_value();
2195 m_xAcrossParagraphBox->save_state();
2196 m_xAcrossColumnBox->save_state();
2197 m_xAcrossPageBox->save_state();
2198 m_xAcrossSpreadBox->save_state();
2199 m_xPageBreakBox->save_state();
2200 m_xBreakPositionLB->save_value();
2201 m_xBreakTypeLB->save_value();
2202 m_xApplyCollBtn->save_state();
2203 m_xApplyCollBox->save_value();
2204 m_xPageNumBox->save_state();
2205 m_xPagenumEdit->save_value();
2206 m_xAllowSplitBox->save_state();
2207 m_xKeepParaBox->save_state();
2208 m_xWidowBox->save_state();
2209 m_xOrphanBox->save_state();
2210 m_xOrphanRowNo->save_value();
2211 m_xWidowRowNo->save_value();
2214 DeactivateRC SvxExtParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
2216 if ( _pSet )
2217 FillItemSet( _pSet );
2218 return DeactivateRC::LeavePage;
2221 void SvxExtParagraphTabPage::DisablePageBreak()
2223 bPageBreak = false;
2224 m_xPageBreakBox->set_sensitive(false);
2225 m_xBreakTypeLB->remove(0);
2226 m_xBreakPositionFT->set_sensitive(false);
2227 m_xBreakPositionLB->set_sensitive(false);
2228 m_xApplyCollBtn->set_sensitive(false);
2229 m_xApplyCollBox->set_sensitive(false);
2230 m_xPageNumBox->set_sensitive(false);
2231 m_xPagenumEdit->set_sensitive(false);
2234 SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
2235 : SfxTabPage(pPage, pController, u"cui/ui/textflowpage.ui"_ustr, u"TextFlowPage"_ustr, &rAttr)
2236 , bPageBreak(true)
2237 , bHtmlMode(false)
2238 , nStdPos(0)
2239 // Hyphenation
2240 , m_xHyphenBox(m_xBuilder->weld_check_button(u"checkAuto"_ustr))
2241 , m_xHyphenNoCapsBox(m_xBuilder->weld_check_button(u"checkNoCaps"_ustr))
2242 , m_xHyphenNoLastWordBox(m_xBuilder->weld_check_button(u"checkNoLastWord"_ustr))
2243 , m_xBeforeText(m_xBuilder->weld_label(u"labelLineBegin"_ustr))
2244 , m_xExtHyphenBeforeBox(m_xBuilder->weld_spin_button(u"spinLineEnd"_ustr))
2245 , m_xAfterText(m_xBuilder->weld_label(u"labelLineEnd"_ustr))
2246 , m_xExtHyphenAfterBox(m_xBuilder->weld_spin_button(u"spinLineBegin"_ustr))
2247 , m_xCompoundBeforeText(m_xBuilder->weld_label(u"labelCompoundLineEnd"_ustr))
2248 , m_xExtCompoundHyphenBeforeBox(m_xBuilder->weld_spin_button(u"spinCompoundLineEnd"_ustr))
2249 , m_xMaxHyphenLabel(m_xBuilder->weld_label(u"labelMaxNum"_ustr))
2250 , m_xMaxHyphenEdit(m_xBuilder->weld_spin_button(u"spinMaxNum"_ustr))
2251 , m_xMinWordLabel(m_xBuilder->weld_label(u"labelMinLen"_ustr))
2252 , m_xMinWordLength(m_xBuilder->weld_spin_button(u"spinMinLen"_ustr))
2253 , m_xHyphenZoneLabel(m_xBuilder->weld_label(u"labelHyphenZone"_ustr))
2254 , m_aHyphenZone(m_xBuilder->weld_metric_spin_button(u"spinHyphenZone"_ustr, FieldUnit::CM))
2255 //Page break
2256 , m_xPageBreakBox(m_xBuilder->weld_check_button(u"checkInsert"_ustr))
2257 , m_xBreakTypeFT(m_xBuilder->weld_label(u"labelType"_ustr))
2258 , m_xBreakTypeLB(m_xBuilder->weld_combo_box(u"comboBreakType"_ustr))
2259 , m_xBreakPositionFT(m_xBuilder->weld_label(u"labelPosition"_ustr))
2260 , m_xBreakPositionLB(m_xBuilder->weld_combo_box(u"comboBreakPosition"_ustr))
2261 , m_xApplyCollBtn(m_xBuilder->weld_check_button(u"checkPageStyle"_ustr))
2262 , m_xApplyCollBox(m_xBuilder->weld_combo_box(u"comboPageStyle"_ustr))
2263 , m_xPageNumBox(m_xBuilder->weld_check_button(u"labelPageNum"_ustr))
2264 , m_xPagenumEdit(m_xBuilder->weld_spin_button(u"spinPageNumber"_ustr))
2265 // Options
2266 , m_xAllowSplitBox(m_xBuilder->weld_check_button(u"checkSplitPara"_ustr))
2267 , m_xKeepParaBox(m_xBuilder->weld_check_button(u"checkKeepPara"_ustr))
2268 , m_xOrphanBox(m_xBuilder->weld_check_button(u"checkOrphan"_ustr))
2269 , m_xOrphanRowNo(m_xBuilder->weld_spin_button(u"spinOrphan"_ustr))
2270 , m_xOrphanRowLabel(m_xBuilder->weld_label(u"labelOrphan"_ustr))
2271 , m_xWidowBox(m_xBuilder->weld_check_button(u"checkWidow"_ustr))
2272 , m_xWidowRowNo(m_xBuilder->weld_spin_button(u"spinWidow"_ustr))
2273 , m_xWidowRowLabel(m_xBuilder->weld_label(u"labelWidow"_ustr))
2274 // Avoid hyphenation across
2275 , m_xAcrossText(m_xBuilder->weld_label(u"labelHyphenAcross"_ustr))
2276 , m_xAcrossParagraphBox(m_xBuilder->weld_check_button(u"checkAcrossParagraph"_ustr))
2277 , m_xAcrossColumnBox(m_xBuilder->weld_check_button(u"checkAcrossColumn"_ustr))
2278 , m_xAcrossPageBox(m_xBuilder->weld_check_button(u"checkAcrossPage"_ustr))
2279 , m_xAcrossSpreadBox(m_xBuilder->weld_check_button(u"checkAcrossSpread"_ustr))
2281 // this page needs ExchangeSupport
2282 SetExchangeSupport();
2284 m_xHyphenBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, HyphenClickHdl_Impl));
2285 m_xPageBreakBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageBreakHdl_Impl));
2286 m_xAllowSplitBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AllowSplitHdl_Impl));
2287 m_xWidowBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, WidowHdl_Impl));
2288 m_xOrphanBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, OrphanHdl_Impl));
2289 m_xApplyCollBtn->connect_toggled(LINK(this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl));
2290 m_xBreakTypeLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl));
2291 m_xBreakPositionLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl));
2292 m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl));
2293 m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl));
2294 m_xAcrossParagraphBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossParagraphHdl_Impl));
2295 m_xAcrossColumnBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossColumnHdl_Impl));
2296 m_xAcrossPageBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossPageHdl_Impl));
2297 m_xAcrossSpreadBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossSpreadHdl_Impl));
2299 if (SfxObjectShell* pSh = SfxObjectShell::Current())
2301 SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
2302 SfxStyleSheetBase* pStyle = pPool->First(SfxStyleFamily::Page);
2303 OUString aStdName;
2305 // tdf139131 - sort page styles
2306 m_xApplyCollBox->make_sorted();
2307 while( pStyle )
2309 if ( aStdName.isEmpty() )
2310 // first style == standard style
2311 aStdName = pStyle->GetName();
2312 m_xApplyCollBox->append_text(pStyle->GetName());
2313 pStyle = pPool->Next();
2315 nStdPos = m_xApplyCollBox->find_text(aStdName);
2318 sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr );
2319 if ( !(nHtmlMode & HTMLMODE_ON) )
2320 return;
2322 bHtmlMode = true;
2323 m_xHyphenBox->set_sensitive(false);
2324 m_xHyphenNoCapsBox->set_sensitive(false);
2325 m_xHyphenNoLastWordBox->set_sensitive(false);
2326 m_xBeforeText->set_sensitive(false);
2327 m_xExtHyphenBeforeBox->set_sensitive(false);
2328 m_xAfterText->set_sensitive(false);
2329 m_xExtHyphenAfterBox->set_sensitive(false);
2330 m_xCompoundBeforeText->set_sensitive(false);
2331 m_xExtCompoundHyphenBeforeBox->set_sensitive(false);
2332 m_xMaxHyphenLabel->set_sensitive(false);
2333 m_xMaxHyphenEdit->set_sensitive(false);
2334 m_xMinWordLabel->set_sensitive(false);
2335 m_xMinWordLength->set_sensitive(false);
2336 m_xHyphenZoneLabel->set_sensitive(false);
2337 m_aHyphenZone.set_sensitive(false);
2338 m_xPageNumBox->set_sensitive(false);
2339 m_xPagenumEdit->set_sensitive(false);
2340 m_xAcrossText->set_sensitive(false);
2341 m_xAcrossParagraphBox->set_sensitive(false);
2342 m_xAcrossColumnBox->set_sensitive(false);
2343 m_xAcrossPageBox->set_sensitive(false);
2344 m_xAcrossSpreadBox->set_sensitive(false);
2345 // no column break in HTML
2346 m_xBreakTypeLB->remove(1);
2349 SvxExtParagraphTabPage::~SvxExtParagraphTabPage()
2353 void SvxExtParagraphTabPage::PageBreakHdl()
2355 switch (m_xPageBreakBox->get_state())
2357 case TRISTATE_TRUE:
2358 m_xBreakTypeFT->set_sensitive(true);
2359 m_xBreakTypeLB->set_sensitive(true);
2360 m_xBreakPositionFT->set_sensitive(true);
2361 m_xBreakPositionLB->set_sensitive(true);
2363 if (0 == m_xBreakTypeLB->get_active() && 0 == m_xBreakPositionLB->get_active())
2365 m_xApplyCollBtn->set_sensitive(true);
2367 bool bEnable = TRISTATE_TRUE == m_xApplyCollBtn->get_state() &&
2368 m_xApplyCollBox->get_count();
2369 m_xApplyCollBox->set_sensitive(bEnable);
2370 if(!bHtmlMode)
2372 m_xPageNumBox->set_sensitive(bEnable);
2373 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2376 break;
2378 case TRISTATE_FALSE:
2379 case TRISTATE_INDET:
2380 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2381 m_xApplyCollBtn->set_sensitive(false);
2382 m_xApplyCollBox->set_sensitive(false);
2383 m_xPageNumBox->set_sensitive(false);
2384 m_xPagenumEdit->set_sensitive(false);
2385 m_xBreakTypeFT->set_sensitive(false);
2386 m_xBreakTypeLB->set_sensitive(false);
2387 m_xBreakPositionFT->set_sensitive(false);
2388 m_xBreakPositionLB->set_sensitive(false);
2389 break;
2393 IMPL_LINK(SvxExtParagraphTabPage, PageBreakHdl_Impl, weld::Toggleable&, rToggle, void)
2395 aPageBreakState.ButtonToggled(rToggle);
2396 PageBreakHdl();
2399 void SvxExtParagraphTabPage::AllowSplitHdl()
2401 bool bEnable = m_xAllowSplitBox->get_state() == TRISTATE_TRUE;
2402 m_xWidowBox->set_sensitive(bEnable);
2403 m_xOrphanBox->set_sensitive(bEnable);
2406 IMPL_LINK(SvxExtParagraphTabPage, AllowSplitHdl_Impl, weld::Toggleable&, rToggle, void)
2408 aAllowSplitState.ButtonToggled(rToggle);
2409 AllowSplitHdl();
2412 void SvxExtParagraphTabPage::WidowHdl()
2414 switch (m_xWidowBox->get_state())
2416 case TRISTATE_TRUE:
2417 m_xWidowRowNo->set_sensitive(true);
2418 m_xWidowRowLabel->set_sensitive(true);
2419 m_xAllowSplitBox->set_sensitive(true);
2420 break;
2421 case TRISTATE_FALSE:
2422 if (m_xOrphanBox->get_state() == TRISTATE_FALSE)
2423 m_xAllowSplitBox->set_sensitive(false);
2424 [[fallthrough]];
2425 case TRISTATE_INDET:
2426 m_xWidowRowNo->set_sensitive(false);
2427 m_xWidowRowLabel->set_sensitive(false);
2428 break;
2432 IMPL_LINK(SvxExtParagraphTabPage, WidowHdl_Impl, weld::Toggleable&, rToggle, void)
2434 aWidowState.ButtonToggled(rToggle);
2435 WidowHdl();
2438 IMPL_LINK(SvxExtParagraphTabPage, OrphanHdl_Impl, weld::Toggleable&, rToggle, void)
2440 aOrphanState.ButtonToggled(rToggle);
2441 OrphanHdl();
2444 void SvxExtParagraphTabPage::OrphanHdl()
2446 switch (m_xOrphanBox->get_state())
2448 case TRISTATE_TRUE:
2449 m_xOrphanRowNo->set_sensitive(true);
2450 m_xOrphanRowLabel->set_sensitive(true);
2451 m_xAllowSplitBox->set_sensitive(true);
2452 break;
2454 case TRISTATE_FALSE:
2455 if (m_xWidowBox->get_state() == TRISTATE_FALSE)
2456 m_xAllowSplitBox->set_sensitive(true);
2457 [[fallthrough]];
2458 case TRISTATE_INDET:
2459 m_xOrphanRowNo->set_sensitive(false);
2460 m_xOrphanRowLabel->set_sensitive(false);
2461 break;
2465 void SvxExtParagraphTabPage::HyphenClickHdl()
2467 bool bEnable = m_xHyphenBox->get_state() == TRISTATE_TRUE;
2468 m_xHyphenNoCapsBox->set_sensitive(bEnable);
2469 m_xHyphenNoLastWordBox->set_sensitive(bEnable);
2470 m_xBeforeText->set_sensitive(bEnable);
2471 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
2472 m_xAfterText->set_sensitive(bEnable);
2473 m_xExtHyphenAfterBox->set_sensitive(bEnable);
2474 m_xCompoundBeforeText->set_sensitive(bEnable);
2475 m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable);
2476 m_xMaxHyphenLabel->set_sensitive(bEnable);
2477 m_xMaxHyphenEdit->set_sensitive(bEnable);
2478 m_xMinWordLabel->set_sensitive(bEnable);
2479 m_xMinWordLength->set_sensitive(bEnable);
2480 m_xHyphenZoneLabel->set_sensitive(bEnable);
2481 m_aHyphenZone.set_sensitive(bEnable);
2482 m_xAcrossText->set_sensitive(bEnable);
2483 m_xAcrossParagraphBox->set_sensitive(bEnable);
2484 m_xAcrossColumnBox->set_sensitive(bEnable);
2485 m_xAcrossPageBox->set_sensitive(bEnable);
2486 m_xAcrossSpreadBox->set_sensitive(bEnable);
2487 m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2490 IMPL_LINK(SvxExtParagraphTabPage, HyphenClickHdl_Impl, weld::Toggleable&, rToggle, void)
2492 aHyphenState.ButtonToggled(rToggle);
2493 HyphenClickHdl();
2496 void SvxExtParagraphTabPage::ApplyCollClickHdl()
2498 bool bEnable = false;
2499 if (m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count())
2501 bEnable = true;
2502 m_xApplyCollBox->set_active(nStdPos);
2504 else
2506 m_xApplyCollBox->set_active(-1);
2508 m_xApplyCollBox->set_sensitive(bEnable);
2509 if (!bHtmlMode)
2511 m_xPageNumBox->set_sensitive(bEnable);
2512 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2516 IMPL_LINK(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl, weld::Toggleable&, rToggle, void)
2518 aApplyCollState.ButtonToggled(rToggle);
2519 ApplyCollClickHdl();
2522 IMPL_LINK(SvxExtParagraphTabPage, PageBreakPosHdl_Impl, weld::ComboBox&, rListBox, void)
2524 if (0 == rListBox.get_active())
2526 m_xApplyCollBtn->set_sensitive(true);
2528 bool bEnable = m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count();
2530 m_xApplyCollBox->set_sensitive(bEnable);
2531 if (!bHtmlMode)
2533 m_xPageNumBox->set_sensitive(bEnable);
2534 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2537 else if (1 == rListBox.get_active())
2539 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2540 m_xApplyCollBtn->set_sensitive(false);
2541 m_xApplyCollBox->set_sensitive(false);
2542 m_xPageNumBox->set_sensitive(false);
2543 m_xPagenumEdit->set_sensitive(false);
2547 IMPL_LINK(SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, weld::ComboBox&, rListBox, void)
2549 //column break or break after
2550 int nBreakPos = m_xBreakPositionLB->get_active();
2551 if (rListBox.get_active() == 1 || 1 == nBreakPos)
2553 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2554 m_xApplyCollBtn->set_sensitive(false);
2555 m_xApplyCollBox->set_sensitive(false);
2556 m_xPageNumBox->set_sensitive(false);
2557 m_xPagenumEdit->set_sensitive(false);
2559 else
2560 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2563 void SvxExtParagraphTabPage::PageNumBoxClickHdl()
2565 m_xPagenumEdit->set_sensitive(m_xPageNumBox->get_state() == TRISTATE_TRUE);
2568 IMPL_LINK(SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl, weld::Toggleable&, rToggle, void)
2570 aPageNumState.ButtonToggled(rToggle);
2571 PageNumBoxClickHdl();
2574 IMPL_LINK(SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl, weld::Toggleable&, rToggle, void)
2576 aKeepParaState.ButtonToggled(rToggle);
2579 void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
2581 const SfxBoolItem* pDisablePageBreakItem = aSet.GetItem<SfxBoolItem>(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false);
2583 if (pDisablePageBreakItem)
2584 if ( pDisablePageBreakItem->GetValue())
2585 DisablePageBreak();
2588 IMPL_LINK(SvxExtParagraphTabPage, AcrossParagraphHdl_Impl, weld::Toggleable&, rToggle, void)
2590 aAcrossParagraphState.ButtonToggled(rToggle);
2591 if (m_xAcrossParagraphBox->get_state() != TRISTATE_TRUE )
2593 m_xAcrossColumnBox->set_state( TRISTATE_FALSE );
2594 m_xAcrossPageBox->set_state( TRISTATE_FALSE );
2595 m_xAcrossSpreadBox->set_state( TRISTATE_FALSE );
2599 IMPL_LINK(SvxExtParagraphTabPage, AcrossColumnHdl_Impl, weld::Toggleable&, rToggle, void)
2601 aAcrossColumnState.ButtonToggled(rToggle);
2602 if (m_xAcrossColumnBox->get_state() != TRISTATE_TRUE )
2604 m_xAcrossPageBox->set_state( TRISTATE_FALSE );
2605 m_xAcrossSpreadBox->set_state( TRISTATE_FALSE );
2607 else
2608 m_xAcrossParagraphBox->set_state( TRISTATE_TRUE );
2611 IMPL_LINK(SvxExtParagraphTabPage, AcrossPageHdl_Impl, weld::Toggleable&, rToggle, void)
2613 aAcrossPageState.ButtonToggled(rToggle);
2614 if (m_xAcrossPageBox->get_state() == TRISTATE_TRUE )
2616 m_xAcrossParagraphBox->set_state( TRISTATE_TRUE );
2617 m_xAcrossColumnBox->set_state( TRISTATE_TRUE );
2619 else
2620 m_xAcrossSpreadBox->set_state( TRISTATE_FALSE );
2623 IMPL_LINK(SvxExtParagraphTabPage, AcrossSpreadHdl_Impl, weld::Toggleable&, rToggle, void)
2625 aAcrossSpreadState.ButtonToggled(rToggle);
2626 if (m_xAcrossSpreadBox->get_state() == TRISTATE_TRUE )
2628 m_xAcrossParagraphBox->set_state( TRISTATE_TRUE );
2629 m_xAcrossColumnBox->set_state( TRISTATE_TRUE );
2630 m_xAcrossPageBox->set_state( TRISTATE_TRUE );
2634 SvxAsianTabPage::SvxAsianTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
2635 : SfxTabPage(pPage, pController, u"cui/ui/asiantypography.ui"_ustr, u"AsianTypography"_ustr, &rSet)
2636 , m_xForbiddenRulesCB(m_xBuilder->weld_check_button(u"checkForbidList"_ustr))
2637 , m_xHangingPunctCB(m_xBuilder->weld_check_button(u"checkHangPunct"_ustr))
2638 , m_xScriptSpaceCB(m_xBuilder->weld_check_button(u"checkApplySpacing"_ustr))
2642 SvxAsianTabPage::~SvxAsianTabPage()
2646 std::unique_ptr<SfxTabPage> SvxAsianTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2648 return std::make_unique<SvxAsianTabPage>(pPage, pController, *rSet);
2651 WhichRangesContainer SvxAsianTabPage::GetRanges()
2653 return WhichRangesContainer(svl::Items<SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES>);
2656 bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet )
2658 bool bRet = false;
2659 SfxItemPool* pPool = rSet->GetPool();
2660 if (m_xScriptSpaceCB->get_sensitive() && m_xScriptSpaceCB->get_state_changed_from_saved())
2662 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2663 pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_SCRIPTSPACE)).Clone()));
2664 pNewItem->SetValue(m_xScriptSpaceCB->get_active());
2665 rSet->Put(std::move(pNewItem));
2666 bRet = true;
2668 if (m_xHangingPunctCB->get_sensitive() && m_xHangingPunctCB->get_state_changed_from_saved())
2670 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2671 pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_HANGPUNCTUATION)).Clone()));
2672 pNewItem->SetValue(m_xHangingPunctCB->get_active());
2673 rSet->Put(std::move(pNewItem));
2674 bRet = true;
2676 if (m_xForbiddenRulesCB->get_sensitive() && m_xForbiddenRulesCB->get_state_changed_from_saved())
2678 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2679 pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone()));
2680 pNewItem->SetValue(m_xForbiddenRulesCB->get_active());
2681 rSet->Put(std::move(pNewItem));
2682 bRet = true;
2684 return bRet;
2687 static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, weld::CheckButton& rBox)
2689 sal_uInt16 _nWhich = rSet.GetPool()->GetWhichIDFromSlotID(nSlotId);
2690 SfxItemState eState = rSet.GetItemState(_nWhich);
2691 if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED )
2692 rBox.set_sensitive(false);
2693 else if(eState >= SfxItemState::DEFAULT)
2694 rBox.set_active(static_cast<const SfxBoolItem&>(rSet.Get(_nWhich)).GetValue());
2695 else
2696 rBox.set_state(TRISTATE_INDET);
2697 rBox.save_state();
2700 void SvxAsianTabPage::Reset( const SfxItemSet* rSet )
2702 lcl_SetBox(*rSet, SID_ATTR_PARA_FORBIDDEN_RULES, *m_xForbiddenRulesCB );
2703 lcl_SetBox(*rSet, SID_ATTR_PARA_HANGPUNCTUATION, *m_xHangingPunctCB );
2705 //character distance not yet available
2706 lcl_SetBox(*rSet, SID_ATTR_PARA_SCRIPTSPACE, *m_xScriptSpaceCB );
2709 void SvxAsianTabPage::ChangesApplied()
2711 m_xForbiddenRulesCB->save_state();
2712 m_xHangingPunctCB->save_state();
2713 m_xScriptSpaceCB->save_state();
2716 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */