cid#1607257 Overflowed constant
[LibreOffice.git] / cui / source / tabpages / paragrph.cxx
blobea8b6a4def38c969115ec9d767b795f080284520
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
105 SvxIndentValue lcl_GetFontRelativeValue(SvxRelativeField& rField, MapUnit eUnit)
107 switch (rField.GetCurrentUnit())
109 case FieldUnit::FONT_EM:
110 return SvxIndentValue{ static_cast<double>(rField.get_value(FieldUnit::NONE)) / 100.0,
111 css::util::MeasureUnit::FONT_EM };
113 case FieldUnit::FONT_CJK_ADVANCE:
114 return SvxIndentValue{ static_cast<double>(rField.get_value(FieldUnit::NONE)) / 100.0,
115 css::util::MeasureUnit::FONT_CJK_ADVANCE };
117 default:
118 return SvxIndentValue::twips(static_cast<double>(rField.GetCoreValue(eUnit)));
122 void lcl_SetFontRelativeValue(SvxRelativeField& rField, const SvxIndentValue& rValue, MapUnit eUnit)
124 switch (rValue.m_nUnit)
126 case css::util::MeasureUnit::FONT_EM:
127 rField.SetFontRelative(FieldUnit::FONT_EM);
128 rField.set_value(static_cast<sal_Int64>(std::llround(rValue.m_dValue * 100.0)),
129 FieldUnit::FONT_EM);
130 break;
132 case css::util::MeasureUnit::FONT_CJK_ADVANCE:
133 rField.SetFontRelative(FieldUnit::FONT_CJK_ADVANCE);
134 rField.set_value(static_cast<sal_Int64>(std::llround(rValue.m_dValue * 100.0)),
135 FieldUnit::FONT_CJK_ADVANCE);
136 break;
138 default:
139 rField.SetMetricValue(static_cast<sal_Int64>(std::llround(rValue.m_dValue)), eUnit);
140 break;
145 static void SetLineSpace_Impl( SvxLineSpacingItem&, int, tools::Long lValue = 0 );
147 void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
148 int eSpace, tools::Long lValue )
150 switch ( eSpace )
152 case LLINESPACE_1:
153 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
154 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
155 break;
157 case LLINESPACE_115:
158 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
159 rLineSpace.SetPropLineSpace( 115 );
160 break;
162 case LLINESPACE_15:
163 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
164 rLineSpace.SetPropLineSpace( 150 );
165 break;
167 case LLINESPACE_2:
168 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
169 rLineSpace.SetPropLineSpace( 200 );
170 break;
172 case LLINESPACE_PROP:
173 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
174 rLineSpace.SetPropLineSpace( static_cast<sal_uInt16>(lValue) );
175 break;
177 case LLINESPACE_MIN:
178 rLineSpace.SetLineHeight( static_cast<sal_uInt16>(lValue) );
179 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
180 break;
182 case LLINESPACE_DURCH:
183 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
184 rLineSpace.SetInterLineSpace( static_cast<sal_uInt16>(lValue) );
185 break;
187 case LLINESPACE_FIX:
188 rLineSpace.SetLineHeight(static_cast<sal_uInt16>(lValue));
189 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Fix );
190 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
191 break;
195 static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
197 sal_uInt16 nHtmlMode = 0;
198 const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false);
199 if (!pItem)
201 if (SfxObjectShell* pShell = SfxObjectShell::Current())
202 pItem = pShell->GetItem(SID_HTML_MODE);
204 if(pItem)
206 nHtmlMode = pItem->GetValue();
208 return nHtmlMode;
212 void SvxStdParagraphTabPage::ELRLoseFocus()
214 SfxItemPool* pPool = GetItemSet().GetPool();
215 assert(pPool && "Where is the pool?");
216 FieldUnit eUnit =
217 MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
219 sal_Int64 nL = m_aLeftIndent.denormalize(m_aLeftIndent.get_value(eUnit));
220 sal_Int64 nR = m_aRightIndent.denormalize(m_aRightIndent.get_value(eUnit));
221 OUString aTmp = m_aFLineIndent.get_text();
223 if (m_aLeftIndent.get_min(FieldUnit::NONE) < 0)
224 m_aFLineIndent.set_min(-99999, FieldUnit::MM);
225 else
226 m_aFLineIndent.set_min(m_aFLineIndent.normalize(-nL), eUnit);
228 // Check only for concrete width (Shell)
229 sal_Int64 nTmp = nWidth - nL - nR - MM50;
230 m_aFLineIndent.set_max(m_aFLineIndent.normalize(nTmp), eUnit);
232 if (aTmp.isEmpty())
233 m_aFLineIndent.set_text(OUString());
234 // maximum left right
235 aTmp = m_aLeftIndent.get_text();
236 nTmp = nWidth - nR - MM50;
237 m_aLeftIndent.set_max(m_aLeftIndent.normalize(nTmp), eUnit);
239 if ( aTmp.isEmpty() )
240 m_aLeftIndent.set_text(OUString());
241 aTmp = m_aRightIndent.get_text();
242 nTmp = nWidth - nL - MM50;
243 m_aRightIndent.set_max(m_aRightIndent.normalize(nTmp), eUnit);
245 if ( aTmp.isEmpty() )
246 m_aRightIndent.set_text(OUString());
248 UpdateExample_Impl();
251 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl, weld::MetricSpinButton&, void)
253 ELRLoseFocus();
256 std::unique_ptr<SfxTabPage> SvxStdParagraphTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
258 return std::make_unique<SvxStdParagraphTabPage>(pPage, pController, *rSet);
261 bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
263 const SfxPoolItem* pOld = nullptr;
264 SfxItemPool* pPool = rOutSet->GetPool();
265 DBG_ASSERT( pPool, "Where is the pool?" );
267 bool bModified = false;
268 sal_uInt16 nWhich;
269 int nPos = m_xLineDist->get_active();
271 if ( nPos != -1 &&
272 ( m_bLineDistToggled ||
273 m_xLineDist->get_value_changed_from_saved() ||
274 m_xLineDistAtPercentBox->get_value_changed_from_saved() ||
275 m_xLineDistAtMetricBox->get_value_changed_from_saved() ) )
277 nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
278 MapUnit eUnit = pPool->GetMetric( nWhich );
279 SvxLineSpacingItem aSpacing(
280 static_cast<const SvxLineSpacingItem&>(GetItemSet().Get( nWhich )) );
282 switch ( nPos )
284 case LLINESPACE_1:
285 case LLINESPACE_115:
286 case LLINESPACE_15:
287 case LLINESPACE_2:
288 SetLineSpace_Impl( aSpacing, nPos );
289 break;
291 case LLINESPACE_PROP:
292 SetLineSpace_Impl( aSpacing, nPos,
293 static_cast<tools::Long>(m_xLineDistAtPercentBox->denormalize(
294 m_xLineDistAtPercentBox->get_value(FieldUnit::NONE) )) );
295 break;
297 case LLINESPACE_MIN:
298 case LLINESPACE_DURCH:
299 case LLINESPACE_FIX:
300 SetLineSpace_Impl( aSpacing, nPos,
301 GetCoreValue( *m_xLineDistAtMetricBox, eUnit ) );
302 break;
304 default:
305 OSL_FAIL( "unknown LineDist entry" );
306 break;
308 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_LINESPACE );
310 if ( m_bLineDistToggled ||
311 !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) ||
312 SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
314 rOutSet->Put( aSpacing );
315 bModified = true;
319 if ( m_aTopDist.get_value_changed_from_saved() || m_aBottomDist.get_value_changed_from_saved()
320 || m_xContextualCB->get_state_changed_from_saved())
322 nWhich = GetWhich( SID_ATTR_ULSPACE );
323 MapUnit eUnit = pPool->GetMetric( nWhich );
324 pOld = GetOldItem( *rOutSet, SID_ATTR_ULSPACE );
325 SvxULSpaceItem aMargin( nWhich );
327 if ( bRelativeMode )
329 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
331 const SvxULSpaceItem& rOldItem =
332 static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
334 if ( m_aTopDist.IsRelative() )
335 aMargin.SetUpper( rOldItem.GetUpper(),
336 static_cast<sal_uInt16>(m_aTopDist.get_value(FieldUnit::NONE)) );
337 else
338 aMargin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)) );
340 if ( m_aBottomDist.IsRelative() )
341 aMargin.SetLower( rOldItem.GetLower(),
342 static_cast<sal_uInt16>(m_aBottomDist.get_value(FieldUnit::NONE)) );
343 else
344 aMargin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)) );
347 else
349 aMargin.SetUpper(static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)));
350 aMargin.SetLower(static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)));
352 aMargin.SetContextValue(m_xContextualCB->get_active());
354 if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin ||
355 SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
357 rOutSet->Put( aMargin );
358 bModified = true;
361 bool bNullTab = false;
363 if (m_bSplitLRSpace && m_aLeftIndent.get_value_changed_from_saved())
365 nWhich = GetWhich(SID_ATTR_PARA_LEFTSPACE);
366 MapUnit const eUnit = pPool->GetMetric(nWhich);
367 SvxTextLeftMarginItem item(nWhich);
368 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_LEFTSPACE);
370 if (bRelativeMode)
372 assert(GetItemSet().GetParent());
374 const SvxTextLeftMarginItem & rOldItem(
375 static_cast<const SvxTextLeftMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));
377 if (m_aLeftIndent.IsRelative())
379 item.SetTextLeft(rOldItem.GetTextLeft(),
380 static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)));
382 else
384 item.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));
387 else
389 item.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));
391 if (!pOld || *static_cast<const SvxTextLeftMarginItem*>(pOld) != item
392 || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
394 rOutSet->Put(item);
395 bModified = true;
399 if (m_bSplitLRSpace && m_aRightIndent.get_value_changed_from_saved())
401 nWhich = GetWhich(SID_ATTR_PARA_RIGHTSPACE);
402 MapUnit const eUnit = pPool->GetMetric(nWhich);
403 SvxRightMarginItem item(nWhich);
404 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_RIGHTSPACE);
406 if (bRelativeMode)
408 assert(GetItemSet().GetParent());
410 const SvxRightMarginItem & rOldItem(
411 static_cast<const SvxRightMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));
413 if (m_aRightIndent.IsRelative())
415 item.SetRight(rOldItem.GetRight(),
416 static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)));
418 else
420 item.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));
423 else
425 item.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));
427 if (!pOld || *static_cast<const SvxRightMarginItem*>(pOld) != item
428 || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
430 rOutSet->Put(item);
431 bModified = true;
435 if (m_bSplitLRSpace && (m_aFLineIndent.get_value_changed_from_saved()
436 || m_xAutoCB->get_state_changed_from_saved()))
438 nWhich = GetWhich(SID_ATTR_PARA_FIRSTLINESPACE);
439 MapUnit const eUnit = pPool->GetMetric(nWhich);
440 SvxFirstLineIndentItem item(nWhich);
441 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_FIRSTLINESPACE);
443 if (bRelativeMode)
445 assert(GetItemSet().GetParent());
447 const SvxFirstLineIndentItem & rOldItem(
448 static_cast<const SvxFirstLineIndentItem&>(GetItemSet().GetParent()->Get(nWhich)));
450 if (m_aFLineIndent.IsRelative())
452 item.SetTextFirstLineOffset(
453 rOldItem.GetTextFirstLineOffset(),
454 static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)));
456 else
458 item.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
461 else
463 item.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
465 item.SetAutoFirst(m_xAutoCB->get_active());
466 if (item.GetTextFirstLineOffset().m_dValue < 0.0)
468 bNullTab = true;
471 if (!pOld || *static_cast<const SvxFirstLineIndentItem*>(pOld) != item
472 || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
474 rOutSet->Put(item);
475 bModified = true;
479 if (!m_bSplitLRSpace &&
480 (m_aLeftIndent.get_value_changed_from_saved() ||
481 m_aFLineIndent.get_value_changed_from_saved() ||
482 m_aRightIndent.get_value_changed_from_saved() ||
483 m_xAutoCB->get_state_changed_from_saved()))
485 nWhich = GetWhich( SID_ATTR_LRSPACE );
486 MapUnit eUnit = pPool->GetMetric( nWhich );
487 SvxLRSpaceItem aMargin( nWhich );
488 pOld = GetOldItem( *rOutSet, SID_ATTR_LRSPACE );
490 if ( bRelativeMode )
492 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
494 const SvxLRSpaceItem& rOldItem =
495 static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
497 if (m_aLeftIndent.IsRelative())
498 aMargin.SetTextLeft( rOldItem.GetTextLeft(),
499 static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)) );
500 else
501 aMargin.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));
503 if ( m_aRightIndent.IsRelative() )
504 aMargin.SetRight( rOldItem.GetRight(),
505 static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)) );
506 else
507 aMargin.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));
509 if ( m_aFLineIndent.IsRelative() )
510 aMargin.SetTextFirstLineOffset(
511 rOldItem.GetTextFirstLineOffset(),
512 static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)));
513 else
515 aMargin.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
518 else
520 aMargin.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));
521 aMargin.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));
522 aMargin.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
524 aMargin.SetAutoFirst(m_xAutoCB->get_active());
525 if (aMargin.GetTextFirstLineOffset().m_dValue < 0.0)
526 bNullTab = true;
528 if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin ||
529 SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
531 rOutSet->Put( aMargin );
532 bModified = true;
536 if ( bNullTab )
538 MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
539 if ( MapUnit::Map100thMM != eUnit )
542 // negative first line indent -> set null default tabstob if applicable
543 sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
544 const SfxItemSet& rInSet = GetItemSet();
546 if ( rInSet.GetItemState( _nWhich ) >= SfxItemState::DEFAULT )
548 const SvxTabStopItem& rTabItem =
549 static_cast<const SvxTabStopItem&>(rInSet.Get( _nWhich ));
550 SvxTabStopItem aNullTab( rTabItem );
551 SvxTabStop aNull( 0, SvxTabAdjust::Default );
552 aNullTab.Insert( aNull );
553 rOutSet->Put( aNullTab );
557 if (m_xRegisterCB->get_visible())
559 const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(GetOldItem(
560 *rOutSet, SID_ATTR_PARA_REGISTER));
561 if (!pBoolItem)
562 return bModified;
563 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
564 bool bSet = pBoolItem->GetValue();
566 if (m_xRegisterCB->get_active() != bSet)
568 std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone());
569 pRegItem->SetValue(!bSet);
570 rOutSet->Put(std::move(pRegItem));
571 bModified = true;
573 else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) )
574 rOutSet->ClearItem(_nWhich);
577 return bModified;
580 static bool UseCharUnitInUI(const SfxItemSet& rSet)
582 const bool bApplyCharUnit = GetApplyCharUnit(rSet);
583 if (!bApplyCharUnit)
584 return false;
585 if (!SvtCJKOptions::IsAsianTypographyEnabled())
586 return false;
587 // tdf#101895 Given that we choose to show cm vs inch based on this Locale
588 // setting, also choose to use ch[ar] and line based on that locale when
589 // bApplyCharUnit is enabled.
590 return MsLangId::isCJK(SvtSysLocaleOptions().GetRealLanguageTag().getLanguageType());
593 void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet )
595 SfxItemPool* pPool = rSet->GetPool();
596 DBG_ASSERT( pPool, "Where is the pool?" );
598 // adjust metric
599 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
600 if (UseCharUnitInUI(*rSet))
601 eFUnit = FieldUnit::CHAR;
603 m_aLeftIndent.SetFieldUnit(eFUnit);
604 m_aRightIndent.SetFieldUnit(eFUnit);
605 m_aFLineIndent.SetFieldUnit(eFUnit);
606 if ( eFUnit == FieldUnit::CHAR )
608 m_aTopDist.SetFieldUnit(FieldUnit::LINE);
609 m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
610 SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT);
612 else
614 m_aTopDist.SetFieldUnit(eFUnit);
615 m_aBottomDist.SetFieldUnit(eFUnit);
616 SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit);
619 sal_uInt16 const nWhichFL(GetWhich(SID_ATTR_PARA_FIRSTLINESPACE));
620 m_bSplitLRSpace = (nWhichFL != SID_ATTR_PARA_FIRSTLINESPACE);
621 SfxItemState const eItemStateFL(rSet->GetItemState(nWhichFL));
622 sal_uInt16 const nWhichLM(GetWhich(SID_ATTR_PARA_LEFTSPACE));
623 SfxItemState const eItemStateLM(rSet->GetItemState(nWhichLM));
624 sal_uInt16 const nWhichRM(GetWhich(SID_ATTR_PARA_RIGHTSPACE));
625 SfxItemState const eItemStateRM(rSet->GetItemState(nWhichRM));
627 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateLM)
629 const SvxTextLeftMarginItem & rOldLeftMargin(
630 static_cast<const SvxTextLeftMarginItem &>(rSet->Get(nWhichLM)));
632 MapUnit const eUnit = pPool->GetMetric(nWhichLM);
634 if (bRelativeMode)
636 if (rOldLeftMargin.GetPropLeft() != 100)
638 m_aLeftIndent.SetRelative( true );
639 m_aLeftIndent.set_value(rOldLeftMargin.GetPropLeft(), FieldUnit::NONE);
641 else
643 m_aLeftIndent.SetRelative(false);
644 m_aLeftIndent.SetFieldUnit(eFUnit);
645 lcl_SetFontRelativeValue(m_aLeftIndent, rOldLeftMargin.GetTextLeft(), eUnit);
648 else
650 lcl_SetFontRelativeValue(m_aLeftIndent, rOldLeftMargin.GetTextLeft(), eUnit);
653 else if (m_bSplitLRSpace)
655 m_aLeftIndent.set_text(OUString());
658 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateRM)
660 const SvxRightMarginItem & rOldRightMargin(
661 static_cast<const SvxRightMarginItem &>(rSet->Get(nWhichRM)));
663 MapUnit const eUnit = pPool->GetMetric(nWhichRM);
665 if (bRelativeMode)
667 if (rOldRightMargin.GetPropRight() != 100)
669 m_aRightIndent.SetRelative( true );
670 m_aRightIndent.set_value(rOldRightMargin.GetPropRight(), FieldUnit::NONE);
672 else
674 m_aRightIndent.SetRelative(false);
675 m_aRightIndent.SetFieldUnit(eFUnit);
676 lcl_SetFontRelativeValue(m_aRightIndent, rOldRightMargin.GetRight(), eUnit);
679 else
681 lcl_SetFontRelativeValue(m_aRightIndent, rOldRightMargin.GetRight(), eUnit);
684 else if (m_bSplitLRSpace)
686 m_aRightIndent.set_text(OUString());
689 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateFL)
691 const SvxFirstLineIndentItem & rOldFirstLine(
692 static_cast<const SvxFirstLineIndentItem &>(rSet->Get(nWhichFL)));
694 MapUnit const eUnit = pPool->GetMetric(nWhichFL);
696 if (bRelativeMode)
698 if (rOldFirstLine.GetPropTextFirstLineOffset() != 100)
700 m_aFLineIndent.SetRelative(true);
701 m_aFLineIndent.set_value(rOldFirstLine.GetPropTextFirstLineOffset(), FieldUnit::NONE);
703 else
705 m_aFLineIndent.SetRelative(false);
706 m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
707 m_aFLineIndent.SetFieldUnit(eFUnit);
708 lcl_SetFontRelativeValue(m_aFLineIndent, rOldFirstLine.GetTextFirstLineOffset(),
709 eUnit);
711 m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
713 else
715 lcl_SetFontRelativeValue(m_aFLineIndent, rOldFirstLine.GetTextFirstLineOffset(), eUnit);
716 m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
718 AutoHdl_Impl(*m_xAutoCB);
720 else if (m_bSplitLRSpace)
722 m_aFLineIndent.set_text(OUString());
725 sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
726 SfxItemState eItemState = rSet->GetItemState( _nWhich );
728 if (!m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemState)
730 MapUnit eUnit = pPool->GetMetric( _nWhich );
732 if ( bRelativeMode )
734 const SvxLRSpaceItem& rOldItem =
735 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
737 if ( rOldItem.GetPropLeft() != 100 )
739 m_aLeftIndent.SetRelative( true );
740 m_aLeftIndent.set_value(rOldItem.GetPropLeft(), FieldUnit::NONE);
742 else
744 m_aLeftIndent.SetRelative(false);
745 m_aLeftIndent.SetFieldUnit(eFUnit);
746 lcl_SetFontRelativeValue(m_aLeftIndent, rOldItem.GetTextLeft(), eUnit);
749 if ( rOldItem.GetPropRight() != 100 )
751 m_aRightIndent.SetRelative( true );
752 m_aRightIndent.set_value(rOldItem.GetPropRight(), FieldUnit::NONE);
754 else
756 m_aRightIndent.SetRelative(false);
757 m_aRightIndent.SetFieldUnit(eFUnit);
758 lcl_SetFontRelativeValue(m_aRightIndent, rOldItem.GetRight(), eUnit);
761 if ( rOldItem.GetPropTextFirstLineOffset() != 100 )
763 m_aFLineIndent.SetRelative(true);
764 m_aFLineIndent.set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE);
766 else
768 m_aFLineIndent.SetRelative(false);
769 m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
770 m_aFLineIndent.SetFieldUnit(eFUnit);
771 lcl_SetFontRelativeValue(m_aFLineIndent, rOldItem.GetTextFirstLineOffset(), eUnit);
773 m_xAutoCB->set_active(rOldItem.IsAutoFirst());
775 else
777 const SvxLRSpaceItem& rSpace =
778 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
780 lcl_SetFontRelativeValue(m_aLeftIndent, rSpace.GetTextLeft(), eUnit);
781 lcl_SetFontRelativeValue(m_aRightIndent, rSpace.GetRight(), eUnit);
782 lcl_SetFontRelativeValue(m_aFLineIndent, rSpace.GetTextFirstLineOffset(), eUnit);
783 m_xAutoCB->set_active(rSpace.IsAutoFirst());
785 AutoHdl_Impl(*m_xAutoCB);
787 else if (!m_bSplitLRSpace)
789 m_aLeftIndent.set_text(OUString());
790 m_aRightIndent.set_text(OUString());
791 m_aFLineIndent.set_text(OUString());
794 _nWhich = GetWhich( SID_ATTR_ULSPACE );
795 eItemState = rSet->GetItemState( _nWhich );
797 if ( eItemState >= SfxItemState::DEFAULT )
799 MapUnit eUnit = pPool->GetMetric( _nWhich );
801 const SvxULSpaceItem& rOldItem =
802 static_cast<const SvxULSpaceItem&>(rSet->Get( _nWhich ));
803 if ( bRelativeMode )
806 if ( rOldItem.GetPropUpper() != 100 )
808 m_aTopDist.SetRelative( true );
809 m_aTopDist.set_value(rOldItem.GetPropUpper(), FieldUnit::NONE);
811 else
813 m_aTopDist.SetRelative(false);
814 if (eFUnit == FieldUnit::CHAR)
815 m_aTopDist.SetFieldUnit(FieldUnit::LINE);
816 else
817 m_aTopDist.SetFieldUnit(eFUnit);
818 m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
821 if ( rOldItem.GetPropLower() != 100 )
823 m_aBottomDist.SetRelative( true );
824 m_aBottomDist.set_value(rOldItem.GetPropLower(), FieldUnit::NONE);
826 else
828 m_aBottomDist.SetRelative(false);
829 if (eFUnit == FieldUnit::CHAR)
830 m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
831 else
832 m_aBottomDist.SetFieldUnit(eFUnit);
833 m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
836 else
838 m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
839 m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
841 m_xContextualCB->set_active(rOldItem.GetContext());
843 else
845 m_aTopDist.set_text(OUString());
846 m_aBottomDist.set_text(OUString());
849 _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
850 eItemState = rSet->GetItemState( _nWhich );
852 if ( eItemState >= SfxItemState::DEFAULT )
853 SetLineSpacing_Impl( static_cast<const SvxLineSpacingItem &>(rSet->Get( _nWhich )) );
854 else
855 m_xLineDist->set_active(-1);
857 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
858 eItemState = rSet->GetItemState( _nWhich );
860 if ( eItemState >= SfxItemState::DEFAULT )
861 m_xRegisterCB->set_active( static_cast<const SfxBoolItem &>(rSet->Get( _nWhich )).GetValue());
862 m_xRegisterCB->save_state();
863 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
864 if(nHtmlMode & HTMLMODE_ON)
866 m_xRegisterCB->hide();
867 m_xAutoCB->hide();
870 // this sets the min/max limits; do this _after_ setting the values,
871 // because for Impress the min of first-line indent depends on value of
872 // left-indent!
873 ELRLoseFocus();
874 ChangesApplied();
877 void SvxStdParagraphTabPage::ChangesApplied()
879 m_aLeftIndent.save_value();
880 m_aRightIndent.save_value();
881 m_aFLineIndent.save_value();
882 m_xLineDist->save_value();
883 m_xLineDistAtPercentBox->save_value();
884 m_xLineDistAtMetricBox->save_value();
885 m_xRegisterCB->save_state();
886 m_aTopDist.save_value();
887 m_aBottomDist.save_value();
888 m_xContextualCB->save_state();
889 m_xAutoCB->save_state();
892 void SvxStdParagraphTabPage::EnableRelativeMode()
894 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );
896 m_aLeftIndent.EnableRelativeMode( 0, 999 );
897 m_aFLineIndent.EnableRelativeMode( 0, 999 );
898 m_aRightIndent.EnableRelativeMode( 0, 999 );
899 m_aTopDist.EnableRelativeMode( 0, 999 );
900 m_aBottomDist.EnableRelativeMode( 0, 999 );
901 bRelativeMode = true;
904 void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet )
906 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
907 SfxItemState eItemState = rSet.GetItemState( _nWhich );
909 if ( eItemState < SfxItemState::DEFAULT )
910 return;
912 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>( rSet.Get( _nWhich ) );
913 SvxAdjust eAdjust = rAdj.GetAdjust();
914 if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block )
916 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
917 eItemState = rSet.GetItemState( _nWhich );
919 if ( eItemState >= SfxItemState::DEFAULT )
921 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet.Get( _nWhich ) );
922 SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue();
924 m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection );
926 if ( eAdjust == SvxAdjust::Block )
927 m_aExampleWin.SetLastLine( rAdj.GetLastBlock() );
930 else
932 m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right );
933 eAdjust = SvxAdjust::Left; //required for correct preview display
934 m_aExampleWin.SetLastLine( eAdjust );
936 m_aExampleWin.SetAdjust( eAdjust );
938 UpdateExample_Impl();
941 DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
943 ELRLoseFocus();
945 if ( _pSet )
946 FillItemSet( _pSet );
947 return DeactivateRC::LeavePage;
950 SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
951 : SfxTabPage(pPage, pController, u"cui/ui/paraindentspacing.ui"_ustr, u"ParaIndentSpacing"_ustr, &rAttr)
952 , nWidth(11905 /*567 * 50*/)
953 , nMinFixDist(0)
954 , bRelativeMode(false)
955 , m_aLeftIndent(m_xBuilder->weld_metric_spin_button(u"spinED_LEFTINDENT"_ustr, FieldUnit::CM))
956 , m_aRightIndent(m_xBuilder->weld_metric_spin_button(u"spinED_RIGHTINDENT"_ustr, FieldUnit::CM))
957 , m_xFLineLabel(m_xBuilder->weld_label(u"labelFT_FLINEINDENT"_ustr))
958 , m_aFLineIndent(m_xBuilder->weld_metric_spin_button(u"spinED_FLINEINDENT"_ustr, FieldUnit::CM))
959 , m_xAutoCB(m_xBuilder->weld_check_button(u"checkCB_AUTO"_ustr))
960 , m_aTopDist(m_xBuilder->weld_metric_spin_button(u"spinED_TOPDIST"_ustr, FieldUnit::CM))
961 , m_aBottomDist(m_xBuilder->weld_metric_spin_button(u"spinED_BOTTOMDIST"_ustr, FieldUnit::CM))
962 , m_xContextualCB(m_xBuilder->weld_check_button(u"checkCB_CONTEXTUALSPACING"_ustr))
963 , m_xLineDist(m_xBuilder->weld_combo_box(u"comboLB_LINEDIST"_ustr))
964 , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button(u"spinED_LINEDISTPERCENT"_ustr, FieldUnit::PERCENT))
965 , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button(u"spinED_LINEDISTMETRIC"_ustr, FieldUnit::CM))
966 , m_xLineDistAtPlaceHolderBox(m_xBuilder->weld_metric_spin_button(u"spinED_BLANK"_ustr, FieldUnit::CM))
967 , m_xLineDistAtLabel(m_xBuilder->weld_label(u"labelFT_LINEDIST"_ustr))
968 , m_xAbsDist(m_xBuilder->weld_label(u"labelST_LINEDIST_ABS"_ustr))
969 , m_xRegisterCB(m_xBuilder->weld_check_button(u"checkCB_REGISTER"_ustr))
970 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, u"drawingareaWN_EXAMPLE"_ustr, m_aExampleWin))
972 // this page needs ExchangeSupport
973 SetExchangeSupport();
975 m_xLineDistAtMetricBox->hide();
976 m_xLineDistAtPlaceHolderBox->hide();
977 m_xLineDistAtPlaceHolderBox->set_text(OUString());
979 Init_Impl();
980 m_aFLineIndent.set_min(-9999, FieldUnit::NONE); // is set to 0 on default
981 m_aFLineIndent.EnableFontRelativeMode();
983 m_aLeftIndent.EnableFontRelativeMode();
984 m_aRightIndent.EnableFontRelativeMode();
987 SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
991 void SvxStdParagraphTabPage::EnableNegativeMode()
993 m_aLeftIndent.set_min(-9999, FieldUnit::NONE);
994 m_aRightIndent.set_min(-9999, FieldUnit::NONE);
995 m_aRightIndent.EnableNegativeMode();
996 m_aLeftIndent.EnableNegativeMode();
999 void SvxStdParagraphTabPage::SetLineSpacing_Impl
1001 const SvxLineSpacingItem &rAttr
1004 MapUnit eUnit = GetItemSet().GetPool()->GetMetric( rAttr.Which() );
1006 switch( rAttr.GetLineSpaceRule() )
1008 case SvxLineSpaceRule::Auto:
1010 SvxInterLineSpaceRule eInter = rAttr.GetInterLineSpaceRule();
1012 switch( eInter )
1014 // Default single line spacing
1015 case SvxInterLineSpaceRule::Off:
1016 m_xLineDist->set_active( LLINESPACE_1 );
1017 break;
1019 // Default single line spacing
1020 case SvxInterLineSpaceRule::Prop:
1021 if ( 100 == rAttr.GetPropLineSpace() )
1023 m_xLineDist->set_active( LLINESPACE_1 );
1024 break;
1026 // 1.15 line spacing
1027 if ( 115 == rAttr.GetPropLineSpace() )
1029 m_xLineDist->set_active( LLINESPACE_115 );
1030 break;
1032 // 1.5 line spacing
1033 if ( 150 == rAttr.GetPropLineSpace() )
1035 m_xLineDist->set_active( LLINESPACE_15 );
1036 break;
1038 // double line spacing
1039 if ( 200 == rAttr.GetPropLineSpace() )
1041 m_xLineDist->set_active( LLINESPACE_2 );
1042 break;
1044 // the set per cent value
1045 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(rAttr.GetPropLineSpace()), FieldUnit::NONE);
1046 m_xLineDist->set_active( LLINESPACE_PROP );
1047 break;
1049 case SvxInterLineSpaceRule::Fix:
1050 SetMetricValue( *m_xLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
1051 m_xLineDist->set_active( LLINESPACE_DURCH );
1052 break;
1053 default: ;//prevent warning
1056 break;
1057 case SvxLineSpaceRule::Fix:
1058 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
1059 m_xLineDist->set_active( LLINESPACE_FIX );
1060 break;
1062 case SvxLineSpaceRule::Min:
1063 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
1064 m_xLineDist->set_active( LLINESPACE_MIN );
1065 break;
1066 default: ;//prevent warning
1068 LineDistHdl_Impl( *m_xLineDist );
1071 IMPL_LINK_NOARG(SvxStdParagraphTabPage, LineDistPopupHdl_Impl, weld::ComboBox&, void)
1073 m_bLineDistToggled = true;
1076 IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void)
1078 switch (rBox.get_active())
1080 case LLINESPACE_1:
1081 case LLINESPACE_115:
1082 case LLINESPACE_15:
1083 case LLINESPACE_2:
1084 m_xLineDistAtLabel->set_sensitive(false);
1085 m_xLineDistAtPercentBox->hide();
1086 m_xLineDistAtMetricBox->hide();
1087 m_xLineDistAtPlaceHolderBox->show();
1088 break;
1090 case LLINESPACE_DURCH:
1091 // setting a sensible default?
1092 // limit MS min(10, aPageSize)
1093 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
1095 if (m_xLineDistAtPlaceHolderBox->get_visible())
1096 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE);
1097 m_xLineDistAtPlaceHolderBox->hide();
1098 m_xLineDistAtPercentBox->hide();
1099 m_xLineDistAtMetricBox->show();
1100 m_xLineDistAtLabel->set_sensitive(true);
1101 break;
1103 case LLINESPACE_MIN:
1104 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
1106 if (m_xLineDistAtPlaceHolderBox->get_visible())
1107 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP);
1108 m_xLineDistAtPlaceHolderBox->hide();
1109 m_xLineDistAtPercentBox->hide();
1110 m_xLineDistAtMetricBox->show();
1111 m_xLineDistAtLabel->set_sensitive(true);
1112 break;
1114 case LLINESPACE_PROP:
1116 if (m_xLineDistAtPlaceHolderBox->get_visible())
1117 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP);
1118 m_xLineDistAtPlaceHolderBox->hide();
1119 m_xLineDistAtMetricBox->hide();
1120 m_xLineDistAtPercentBox->show();
1121 m_xLineDistAtLabel->set_sensitive(true);
1122 break;
1123 case LLINESPACE_FIX:
1125 auto nTemp = m_xLineDistAtMetricBox->get_value(FieldUnit::NONE);
1126 m_xLineDistAtMetricBox->set_min(m_xLineDistAtMetricBox->normalize(nMinFixDist), FieldUnit::TWIP);
1128 // if the value has been changed at SetMin,
1129 // it is time for the default
1130 if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp)
1131 SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer
1132 m_xLineDistAtPlaceHolderBox->hide();
1133 m_xLineDistAtPercentBox->hide();
1134 m_xLineDistAtMetricBox->show();
1135 m_xLineDistAtLabel->set_sensitive(true);
1137 break;
1139 UpdateExample_Impl();
1142 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ModifyHdl_Impl, weld::MetricSpinButton&, void)
1144 UpdateExample_Impl();
1147 void SvxStdParagraphTabPage::Init_Impl()
1149 m_xLineDist->connect_popup_toggled(LINK(this, SvxStdParagraphTabPage, LineDistPopupHdl_Impl));
1150 m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl));
1152 Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl);
1153 m_aFLineIndent.connect_value_changed(aLink2);
1154 m_aLeftIndent.connect_value_changed(aLink2);
1155 m_aRightIndent.connect_value_changed(aLink2);
1157 Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl);
1158 m_aTopDist.connect_value_changed(aLink);
1159 m_aBottomDist.connect_value_changed(aLink);
1161 m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl));
1162 SfxItemPool* pPool = GetItemSet().GetPool();
1163 assert(pPool && "Where is the pool?");
1164 FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
1166 m_aTopDist.set_max( m_aTopDist.normalize( MAX_DURCH ), eUnit );
1167 m_aBottomDist.set_max( m_aBottomDist.normalize( MAX_DURCH ), eUnit );
1168 m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit );
1171 void SvxStdParagraphTabPage::UpdateExample_Impl()
1173 m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_aFLineIndent.denormalize( m_aFLineIndent.get_value( FieldUnit::TWIP ) )) );
1174 m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_aLeftIndent.denormalize( m_aLeftIndent.get_value( FieldUnit::TWIP ) ) ) );
1175 m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_aRightIndent.denormalize( m_aRightIndent.get_value( FieldUnit::TWIP ) ) ) );
1176 m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.denormalize( m_aTopDist.get_value( FieldUnit::TWIP ) )) );
1177 m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.denormalize( m_aBottomDist.get_value( FieldUnit::TWIP ) )) );
1179 int nPos = m_xLineDist->get_active();
1181 switch ( nPos )
1183 case LLINESPACE_1:
1184 case LLINESPACE_115:
1185 case LLINESPACE_15:
1186 case LLINESPACE_2:
1187 case LLINESPACE_PROP:
1188 case LLINESPACE_MIN:
1189 case LLINESPACE_DURCH:
1190 case LLINESPACE_FIX:
1191 m_aExampleWin.SetLineSpace( static_cast<SvxPrevLineSpace>(nPos) );
1192 break;
1194 m_aExampleWin.Invalidate();
1197 void SvxStdParagraphTabPage::EnableRegisterMode()
1199 m_xRegisterCB->show();
1202 void SvxStdParagraphTabPage::EnableContextualMode()
1204 m_xContextualCB->show();
1207 IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::Toggleable&, rBox, void)
1209 bool bEnable = !rBox.get_active();
1210 m_xFLineLabel->set_sensitive(bEnable);
1211 m_aFLineIndent.set_sensitive(bEnable);
1214 void SvxStdParagraphTabPage::EnableAutoFirstLine()
1216 m_xAutoCB->show();
1219 void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
1222 /* different bit represent call to different method of SvxStdParagraphTabPage
1223 0x0001 --->EnableRelativeMode()
1224 0x0002 --->EnableRegisterMode()
1225 0x0004 --->EnableAutoFirstLine()
1226 0x0008 --->EnableNegativeMode()
1227 0x0010 --->EnableContextualMode()
1229 const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false);
1230 const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false);
1232 if (pPageWidthItem)
1233 nWidth = pPageWidthItem->GetValue();
1235 if (pFlagSetItem )
1237 if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
1238 EnableRelativeMode();
1240 if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
1241 EnableRegisterMode();
1243 if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
1244 EnableAutoFirstLine();
1247 if (pFlagSetItem)
1249 if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
1250 EnableNegativeMode();
1252 if (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
1253 EnableContextualMode();
1257 #define LASTLINEPOS_DEFAULT 0
1258 #define LASTLINEPOS_LEFT 1
1260 #define LASTLINECOUNT_OLD 3
1261 #define LASTLINECOUNT_NEW 4
1263 SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
1264 : SfxTabPage(pPage, pController, u"cui/ui/paragalignpage.ui"_ustr, u"ParaAlignPage"_ustr, &rSet)
1265 , m_bSdrVertAlign(false)
1266 , m_xLeft(m_xBuilder->weld_radio_button(u"radioBTN_LEFTALIGN"_ustr))
1267 , m_xRight(m_xBuilder->weld_radio_button(u"radioBTN_RIGHTALIGN"_ustr))
1268 , m_xCenter(m_xBuilder->weld_radio_button(u"radioBTN_CENTERALIGN"_ustr))
1269 , m_xJustify(m_xBuilder->weld_radio_button(u"radioBTN_JUSTIFYALIGN"_ustr))
1270 , m_xLeftBottom(m_xBuilder->weld_label(u"labelST_LEFTALIGN_ASIAN"_ustr))
1271 , m_xRightTop(m_xBuilder->weld_label(u"labelST_RIGHTALIGN_ASIAN"_ustr))
1272 , m_xLastLineFT(m_xBuilder->weld_label(u"labelLB_LASTLINE"_ustr))
1273 , m_xLastLineLB(m_xBuilder->weld_combo_box(u"comboLB_LASTLINE"_ustr))
1274 , m_xExpandCB(m_xBuilder->weld_check_button(u"checkCB_EXPAND"_ustr))
1275 , m_xSnapToGridCB(m_xBuilder->weld_check_button(u"checkCB_SNAP"_ustr))
1276 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, u"drawingareaWN_EXAMPLE"_ustr, m_aExampleWin))
1277 , m_xVertAlignFL(m_xBuilder->weld_widget(u"frameFL_VERTALIGN"_ustr))
1278 , m_xVertAlignLB(m_xBuilder->weld_combo_box(u"comboLB_VERTALIGN"_ustr))
1279 , m_xVertAlign(m_xBuilder->weld_label(u"labelFL_VERTALIGN"_ustr))
1280 , m_xVertAlignSdr(m_xBuilder->weld_label(u"labelST_VERTALIGN_SDR"_ustr))
1281 , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box(u"comboLB_TEXTDIRECTION"_ustr)))
1283 SetExchangeSupport();
1285 sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;
1287 if ( SvtCJKOptions::IsAsianTypographyEnabled() )
1289 m_xLeft->set_label(m_xLeftBottom->get_label());
1290 m_xRight->set_label(m_xRightTop->get_label());
1292 OUString sLeft(m_xLeft->get_label());
1293 sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );
1295 if (m_xLastLineLB->get_count() == LASTLINECOUNT_OLD)
1297 m_xLastLineLB->remove(0);
1298 m_xLastLineLB->insert_text(0, sLeft);
1300 else
1301 nLastLinePos = LASTLINEPOS_LEFT;
1304 // remove "Default" or "Left" entry, depends on CJKOptions
1305 if (m_xLastLineLB->get_count() == LASTLINECOUNT_NEW)
1306 m_xLastLineLB->remove(nLastLinePos);
1308 Link<weld::Toggleable&, void> aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
1309 m_xLeft->connect_toggled(aLink);
1310 m_xRight->connect_toggled(aLink);
1311 m_xCenter->connect_toggled(aLink);
1312 m_xJustify->connect_toggled(aLink);
1313 m_xLastLineLB->connect_changed(LINK(this, SvxParaAlignTabPage, LastLineHdl_Impl));
1314 m_xTextDirectionLB->connect_changed(LINK(this, SvxParaAlignTabPage, TextDirectionHdl_Impl));
1316 m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
1317 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
1318 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
1321 SvxParaAlignTabPage::~SvxParaAlignTabPage()
1325 DeactivateRC SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
1327 if ( _pSet )
1328 FillItemSet( _pSet );
1329 return DeactivateRC::LeavePage;
1332 std::unique_ptr<SfxTabPage> SvxParaAlignTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1334 return std::make_unique<SvxParaAlignTabPage>(pPage, pController, *rSet);
1337 bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet )
1339 bool bModified = false;
1341 bool bAdj = false;
1342 SvxAdjust eAdjust = SvxAdjust::Left;
1344 if (m_xLeft->get_active())
1346 eAdjust = SvxAdjust::Left;
1347 bAdj = m_xLeft->get_saved_state() == TRISTATE_FALSE;
1349 else if (m_xRight->get_active())
1351 eAdjust = SvxAdjust::Right;
1352 bAdj = m_xRight->get_saved_state() == TRISTATE_FALSE;
1354 else if (m_xCenter->get_active())
1356 eAdjust = SvxAdjust::Center;
1357 bAdj = m_xCenter->get_saved_state() == TRISTATE_FALSE;
1359 else if (m_xJustify->get_active())
1361 eAdjust = SvxAdjust::Block;
1362 bAdj = m_xJustify->get_saved_state() == TRISTATE_FALSE ||
1363 m_xExpandCB->get_state_changed_from_saved() ||
1364 m_xLastLineLB->get_value_changed_from_saved();
1367 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1369 if (bAdj)
1371 SvxAdjust eOneWord = m_xExpandCB->get_active() ? SvxAdjust::Block : SvxAdjust::Left;
1373 int nLBPos = m_xLastLineLB->get_active();
1374 SvxAdjust eLastBlock = SvxAdjust::Left;
1375 if ( 1 == nLBPos )
1376 eLastBlock = SvxAdjust::Center;
1377 else if ( 2 == nLBPos )
1378 eLastBlock = SvxAdjust::Block;
1380 SvxAdjustItem aAdj( static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) );
1381 aAdj.SetAdjust( eAdjust );
1382 aAdj.SetOneWord( eOneWord );
1383 aAdj.SetLastBlock( eLastBlock );
1384 rOutSet->Put( aAdj );
1385 bModified = true;
1388 if (m_xSnapToGridCB->get_state_changed_from_saved())
1390 rOutSet->Put(SvxParaGridItem(m_xSnapToGridCB->get_active(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
1391 bModified = true;
1394 if (m_xVertAlignLB->get_value_changed_from_saved())
1396 if (m_bSdrVertAlign)
1397 rOutSet->Put(SdrTextVertAdjustItem(static_cast<SdrTextVertAdjust>(m_xVertAlignLB->get_active())));
1398 else
1399 rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN )));
1400 bModified = true;
1403 if (m_xTextDirectionLB->get_visible())
1405 if (m_xTextDirectionLB->get_value_changed_from_saved())
1407 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1408 rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
1409 bModified = true;
1413 return bModified;
1416 void SvxParaAlignTabPage::ActivatePage( const SfxItemSet& rSet )
1418 Reset( &rSet );
1421 void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet )
1423 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1424 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1426 sal_Int32 nLBSelect = 0;
1427 if ( eItemState >= SfxItemState::DEFAULT )
1429 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>(rSet->Get( _nWhich ));
1431 switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
1433 case SvxAdjust::Left: m_xLeft->set_active(true); break;
1435 case SvxAdjust::Right: m_xRight->set_active(true); break;
1437 case SvxAdjust::Center: m_xCenter->set_active(true); break;
1439 case SvxAdjust::Block: m_xJustify->set_active(true); break;
1440 default: ; //prevent warning
1442 bool bEnable = m_xJustify->get_active();
1443 m_xLastLineFT->set_sensitive(bEnable);
1444 m_xLastLineLB->set_sensitive(bEnable);
1446 switch(rAdj.GetLastBlock())
1448 case SvxAdjust::Left: nLBSelect = 0; break;
1450 case SvxAdjust::Center: nLBSelect = 1; break;
1452 case SvxAdjust::Block: nLBSelect = 2; break;
1453 default: ; //prevent warning
1455 m_xExpandCB->set_sensitive(bEnable && nLBSelect == 2);
1456 m_xExpandCB->set_active(SvxAdjust::Block == rAdj.GetOneWord());
1458 else
1460 m_xLeft->set_active(false);
1461 m_xRight->set_active(false);
1462 m_xCenter->set_active(false);
1463 m_xJustify->set_active(false);
1465 m_xLastLineLB->set_active(nLBSelect);
1467 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
1468 if(nHtmlMode & HTMLMODE_ON)
1470 m_xLastLineLB->hide();
1471 m_xLastLineFT->hide();
1472 m_xExpandCB->hide();
1473 if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
1474 m_xJustify->set_sensitive(false);
1475 m_xSnapToGridCB->hide();
1477 _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
1478 eItemState = rSet->GetItemState( _nWhich );
1479 if ( eItemState >= SfxItemState::DEFAULT )
1481 const SvxParaGridItem& rSnap = static_cast<const SvxParaGridItem&>(rSet->Get( _nWhich ));
1482 m_xSnapToGridCB->set_active(rSnap.GetValue());
1485 _nWhich = m_bSdrVertAlign ? SDRATTR_TEXT_VERTADJUST : GetWhich( SID_PARA_VERTALIGN );
1486 eItemState = rSet->GetItemState( _nWhich );
1488 if ( eItemState >= SfxItemState::DEFAULT )
1490 m_xVertAlignFL->show();
1492 if (m_bSdrVertAlign)
1494 const SdrTextVertAdjustItem& rAlign = static_cast<const SdrTextVertAdjustItem&>(rSet->Get( _nWhich ));
1495 m_xVertAlignLB->set_active(rAlign.GetValue());
1497 else
1499 const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich ));
1500 m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue()));
1504 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
1505 //text direction
1506 if( SfxItemState::DEFAULT <= rSet->GetItemState( _nWhich ) )
1508 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet->Get( _nWhich ) );
1509 m_xTextDirectionLB->set_active_id(rFrameDirItem.GetValue());
1510 m_xTextDirectionLB->save_value();
1513 m_xSnapToGridCB->save_state();
1514 m_xVertAlignLB->save_value();
1515 m_xLeft->save_state();
1516 m_xRight->save_state();
1517 m_xCenter->save_state();
1518 m_xJustify->save_state();
1519 m_xLastLineLB->save_value();
1520 m_xExpandCB->save_state();
1522 UpdateExample_Impl();
1525 void SvxParaAlignTabPage::ChangesApplied()
1527 m_xTextDirectionLB->save_value();
1528 m_xSnapToGridCB->save_state();
1529 m_xVertAlignLB->save_value();
1530 m_xLeft->save_state();
1531 m_xRight->save_state();
1532 m_xCenter->save_state();
1533 m_xJustify->save_state();
1534 m_xLastLineLB->save_value();
1535 m_xExpandCB->save_state();
1538 IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl, weld::Toggleable&, void)
1540 bool bJustify = m_xJustify->get_active();
1541 m_xLastLineFT->set_sensitive(bJustify);
1542 m_xLastLineLB->set_sensitive(bJustify);
1543 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1544 m_xExpandCB->set_sensitive(bJustify && bLastLineIsBlock);
1545 //set last line listbox to entry position 0 if not enabled
1546 if (!m_xLastLineLB->get_sensitive())
1547 m_xLastLineLB->set_active(0);
1548 //uncheck 'Expand ... word' when check box is not enabled
1549 if (!m_xExpandCB->get_sensitive())
1550 m_xExpandCB->set_active(false);
1551 UpdateExample_Impl();
1554 IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl, weld::ComboBox&, void)
1556 //fdo#41350 only enable 'Expand last word' if last line is also justified
1557 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1558 m_xExpandCB->set_sensitive(bLastLineIsBlock);
1559 //uncheck 'Expand ... word' when check box is not enabled
1560 if (!m_xExpandCB->get_sensitive())
1561 m_xExpandCB->set_active(false);
1562 UpdateExample_Impl();
1565 IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl, weld::ComboBox&, void)
1567 UpdateExample_Impl();
1570 void SvxParaAlignTabPage::UpdateExample_Impl()
1572 if (m_xLeft->get_active())
1574 m_aExampleWin.EnableRTL(false);
1575 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1576 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1578 else if (m_xRight->get_active())
1580 m_aExampleWin.EnableRTL(true);
1581 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1582 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1584 else
1586 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1587 switch ( eDir )
1589 case SvxFrameDirection::Environment :
1590 if ( !m_xRight->get_active() )
1591 m_aExampleWin.EnableRTL( AllSettings::GetLayoutRTL() );
1592 break;
1593 case SvxFrameDirection::Horizontal_RL_TB :
1594 if ( !m_xLeft->get_active() )
1595 m_aExampleWin.EnableRTL( true );
1596 break;
1597 case SvxFrameDirection::Horizontal_LR_TB :
1598 if ( !m_xRight->get_active() )
1599 m_aExampleWin.EnableRTL( false );
1600 break;
1601 default: ; //prevent warning
1603 if (m_xCenter->get_active())
1604 m_aExampleWin.SetAdjust( SvxAdjust::Center );
1605 else if (m_xJustify->get_active())
1607 m_aExampleWin.SetAdjust( SvxAdjust::Block );
1608 int nLBPos = m_xLastLineLB->get_active();
1609 if (nLBPos == 0)
1610 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1611 else if (nLBPos == 1)
1612 m_aExampleWin.SetLastLine(SvxAdjust::Center);
1613 else if (nLBPos == 2)
1614 m_aExampleWin.SetLastLine(SvxAdjust::Block);
1618 m_aExampleWin.Invalidate();
1621 void SvxParaAlignTabPage::EnableJustifyExt()
1623 m_xLastLineFT->show();
1624 m_xLastLineLB->show();
1625 m_xExpandCB->show();
1626 if (SvtCJKOptions::IsAsianTypographyEnabled())
1627 m_xSnapToGridCB->show();
1631 void SvxParaAlignTabPage::EnableSdrVertAlign()
1633 m_bSdrVertAlign = true;
1635 m_xVertAlignLB->remove_id(u"0"_ustr);
1636 m_xVertAlignLB->remove_id(u"1"_ustr);
1637 m_xVertAlign->set_label(m_xVertAlignSdr->get_label());
1640 void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet)
1642 const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false);
1643 if (pBoolItem && pBoolItem->GetValue())
1644 EnableJustifyExt();
1647 std::unique_ptr<SfxTabPage> SvxExtParagraphTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1649 return std::make_unique<SvxExtParagraphTabPage>(pPage, pController, *rSet);
1652 bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
1654 bool bModified = false;
1655 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1656 const TriState eHyphenState = m_xHyphenBox->get_state();
1657 const SfxPoolItem* pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_HYPHENZONE );
1659 if ( m_xHyphenBox->get_state_changed_from_saved() ||
1660 m_xHyphenNoCapsBox->get_state_changed_from_saved() ||
1661 m_xHyphenNoLastWordBox->get_state_changed_from_saved() ||
1662 m_xExtHyphenBeforeBox->get_value_changed_from_saved() ||
1663 m_xExtHyphenAfterBox->get_value_changed_from_saved() ||
1664 m_xExtCompoundHyphenBeforeBox->get_value_changed_from_saved() ||
1665 m_xMaxHyphenEdit->get_value_changed_from_saved() ||
1666 m_xMinWordLength->get_value_changed_from_saved() ||
1667 m_aHyphenZone.get_value_changed_from_saved() ||
1668 m_xAcrossParagraphBox->get_state_changed_from_saved() ||
1669 m_xAcrossColumnBox->get_state_changed_from_saved() ||
1670 m_xAcrossPageBox->get_state_changed_from_saved() ||
1671 m_xAcrossSpreadBox->get_state_changed_from_saved() )
1673 SvxHyphenZoneItem aHyphen(
1674 static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) );
1675 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1676 aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() != TRISTATE_TRUE);
1677 aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE);
1679 if ( eHyphenState == TRISTATE_TRUE )
1681 aHyphen.GetMinLead() = static_cast<sal_uInt8>(m_xExtHyphenBeforeBox->get_value());
1682 aHyphen.GetMinTrail() = static_cast<sal_uInt8>(m_xExtHyphenAfterBox->get_value());
1683 aHyphen.GetCompoundMinLead() = static_cast<sal_uInt8>(m_xExtCompoundHyphenBeforeBox->get_value());
1684 aHyphen.GetMinWordLength() = static_cast<sal_uInt8>(m_xMinWordLength->get_value());
1686 aHyphen.GetMaxHyphens() = static_cast<sal_uInt8>(m_xMaxHyphenEdit->get_value());
1688 SfxItemPool* pPool = GetItemSet().GetPool();
1689 DBG_ASSERT( pPool, "Where is the pool?" );
1690 MapUnit eUnit = pPool->GetMetric( _nWhich );
1691 aHyphen.GetTextHyphenZone() = static_cast<sal_uInt16>(m_aHyphenZone.GetCoreValue(eUnit));
1692 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1693 aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE);
1694 const TriState eAcrossParagraphState = m_xAcrossParagraphBox->get_state();
1695 const TriState eAcrossColumnState = m_xAcrossColumnBox->get_state();
1696 const TriState eAcrossPageState = m_xAcrossPageBox->get_state();
1697 const TriState eAcrossSpreadState = m_xAcrossSpreadBox->get_state();
1698 aHyphen.SetKeep( eAcrossSpreadState != TRISTATE_TRUE );
1699 if ( eAcrossSpreadState == TRISTATE_TRUE )
1701 // hyphenate across column, page and spread -> ParaHyphenationKeep = false and
1702 // set default value 3 (COLUMN)
1703 aHyphen.GetKeepType() =
1704 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN);
1706 else if ( eAcrossPageState == TRISTATE_TRUE )
1708 // hyphenate across column and page, but not spread -> 1 (SPREAD)
1709 aHyphen.GetKeepType() =
1710 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::SPREAD);
1712 else if ( eAcrossColumnState == TRISTATE_TRUE )
1714 // hyphenate across column, but not page and spread -> 2 (PAGE)
1715 aHyphen.GetKeepType() =
1716 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::PAGE);
1718 else if ( eAcrossParagraphState == TRISTATE_TRUE )
1720 // hyphenate across last full paragraph line, but not page and spread -> 2 (PAGE)
1721 aHyphen.GetKeepType() =
1722 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN);
1724 else
1726 // don't hyphenate across last full paragraph line,
1727 // also column, page and spread -> 4 (COLUMN)
1728 aHyphen.GetKeepType() =
1729 static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::ALWAYS);
1732 if ( !pOld ||
1733 *static_cast<const SvxHyphenZoneItem*>(pOld) != aHyphen ||
1734 m_xHyphenBox->get_state_changed_from_saved())
1736 rOutSet->Put( aHyphen );
1737 bModified = true;
1741 if (m_xPageNumBox->get_sensitive()
1742 && (m_xPageNumBox->get_state_changed_from_saved() || m_xPagenumEdit->get_value_changed_from_saved()))
1744 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
1746 if (TRISTATE_TRUE == m_xPageNumBox->get_state()
1747 && (!pOld || IsInvalidItem(pOld)
1748 || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != m_xPagenumEdit->get_value()))
1750 SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM,
1751 static_cast<sal_uInt16>(m_xPagenumEdit->get_value()));
1752 rOutSet->Put( aPageNum );
1753 bModified = true;
1755 else if (TRISTATE_FALSE == m_xPageNumBox->get_state()
1756 && (pOld || IsInvalidItem(pOld)))
1758 // need to tell sw to remove the item
1759 rOutSet->DisableItem(SID_ATTR_PARA_PAGENUM);
1760 bModified = true;
1764 // pagebreak
1766 TriState eState = m_xApplyCollBtn->get_state();
1767 bool bIsPageModel = false;
1769 OUString sPage;
1770 if ( m_xApplyCollBtn->get_state_changed_from_saved() ||
1771 ( TRISTATE_TRUE == eState &&
1772 m_xApplyCollBox->get_value_changed_from_saved() ) )
1774 if ( eState == TRISTATE_TRUE )
1776 sPage = m_xApplyCollBox->get_active_text();
1777 bIsPageModel = !sPage.isEmpty();
1779 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_MODEL );
1781 if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage )
1783 rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) );
1784 bModified = true;
1786 else
1787 bIsPageModel = false;
1789 else if(TRISTATE_TRUE == eState && m_xApplyCollBtn->get_sensitive())
1790 bIsPageModel = true;
1791 else
1792 rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) );
1794 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1796 if ( bIsPageModel )
1797 // if PageModel is turned on, always turn off PageBreak
1798 rOutSet->Put( SvxFormatBreakItem( SvxBreak::NONE, _nWhich ) );
1799 else
1801 eState = m_xPageBreakBox->get_state();
1802 SfxItemState eModelState = GetItemSet().GetItemState(SID_ATTR_PARA_MODEL, false);
1804 if ( (eModelState == SfxItemState::SET && TRISTATE_TRUE == m_xPageBreakBox->get_state()) ||
1805 m_xPageBreakBox->get_state_changed_from_saved() ||
1806 m_xBreakTypeLB->get_value_changed_from_saved() ||
1807 m_xBreakPositionLB->get_value_changed_from_saved() )
1809 const SvxFormatBreakItem rOldBreak(
1810 static_cast<const SvxFormatBreakItem&>(GetItemSet().Get( _nWhich )));
1811 SvxFormatBreakItem aBreak(rOldBreak.GetBreak(), rOldBreak.Which());
1813 switch ( eState )
1815 case TRISTATE_TRUE:
1817 bool bBefore = m_xBreakPositionLB->get_active() == 0;
1819 if (m_xBreakTypeLB->get_active() == 0)
1821 if ( bBefore )
1822 aBreak.SetValue( SvxBreak::PageBefore );
1823 else
1824 aBreak.SetValue( SvxBreak::PageAfter );
1826 else
1828 if ( bBefore )
1829 aBreak.SetValue( SvxBreak::ColumnBefore );
1830 else
1831 aBreak.SetValue( SvxBreak::ColumnAfter );
1833 break;
1836 case TRISTATE_FALSE:
1837 aBreak.SetValue( SvxBreak::NONE );
1838 break;
1839 default: ; //prevent warning
1841 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGEBREAK );
1843 if ( eState != m_xPageBreakBox->get_saved_state() ||
1844 !pOld || !( *static_cast<const SvxFormatBreakItem*>(pOld) == aBreak ) )
1846 bModified = true;
1847 rOutSet->Put( aBreak );
1852 // paragraph split
1853 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1854 eState = m_xAllowSplitBox->get_state();
1856 if (m_xAllowSplitBox->get_state_changed_from_saved())
1858 rOutSet->Put( SvxFormatSplitItem( eState == TRISTATE_TRUE, _nWhich ) );
1859 bModified = true;
1862 // keep paragraphs
1863 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1864 eState = m_xKeepParaBox->get_state();
1866 if (m_xKeepParaBox->get_state_changed_from_saved())
1868 // if the status has changed, putting is necessary
1869 rOutSet->Put( SvxFormatKeepItem( eState == TRISTATE_TRUE, _nWhich ) );
1870 bModified = true;
1873 // widows and orphans
1874 TypedWhichId<SvxWidowsItem> nWidowsWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1875 eState = m_xWidowBox->get_state();
1877 if ( m_xWidowBox->get_state_changed_from_saved() ||
1878 m_xWidowRowNo->get_value_changed_from_saved() )
1880 SvxWidowsItem rItem( eState == TRISTATE_TRUE ?
1881 static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, nWidowsWhich );
1882 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS );
1884 if ( m_xWidowBox->get_state_changed_from_saved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) )
1886 rOutSet->Put( rItem );
1887 bModified = true;
1891 TypedWhichId<SvxOrphansItem> nOrphansWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1892 eState = m_xOrphanBox->get_state();
1894 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1895 m_xOrphanRowNo->get_value_changed_from_saved() )
1897 SvxOrphansItem rItem( eState == TRISTATE_TRUE ?
1898 static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, nOrphansWhich );
1899 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS );
1901 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1902 !pOld ||
1903 !( *static_cast<const SvxOrphansItem*>(pOld) == rItem ) )
1905 rOutSet->Put( rItem );
1906 bModified = true;
1910 return bModified;
1912 void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
1914 SfxItemPool* pPool = rSet->GetPool();
1915 DBG_ASSERT( pPool, "Where is the pool?" );
1917 // adjust metric
1918 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
1919 if (UseCharUnitInUI(*rSet))
1920 eFUnit = FieldUnit::CHAR;
1922 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1923 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1925 bool bItemAvailable = eItemState >= SfxItemState::DEFAULT;
1926 bool bIsHyphen = false;
1927 if( !bHtmlMode && bItemAvailable )
1929 const SvxHyphenZoneItem& rHyphen =
1930 static_cast<const SvxHyphenZoneItem&>(rSet->Get( _nWhich ));
1931 aHyphenState.bTriStateEnabled = false;
1933 bIsHyphen = rHyphen.IsHyphen();
1934 m_xHyphenBox->set_state(bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE);
1935 m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE);
1936 m_xHyphenNoLastWordBox->set_state(rHyphen.IsNoLastWordHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE);
1938 m_xExtHyphenBeforeBox->set_value(rHyphen.GetMinLead());
1939 m_xExtHyphenAfterBox->set_value(rHyphen.GetMinTrail());
1940 m_xExtCompoundHyphenBeforeBox->set_value(rHyphen.GetCompoundMinLead());
1941 m_xMaxHyphenEdit->set_value(rHyphen.GetMaxHyphens());
1942 m_xMinWordLength->set_value(rHyphen.GetMinWordLength());
1943 m_aHyphenZone.SetFieldUnit(eFUnit);
1944 m_aHyphenZone.SetMetricValue(rHyphen.GetTextHyphenZone(), MapUnit::MapTwip);
1945 m_xAcrossParagraphBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 4 ? TRISTATE_TRUE : TRISTATE_FALSE);
1946 m_xAcrossColumnBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 3 ? TRISTATE_TRUE : TRISTATE_FALSE);
1947 m_xAcrossPageBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 2 ? TRISTATE_TRUE : TRISTATE_FALSE);
1948 m_xAcrossSpreadBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() == 0 ? TRISTATE_TRUE : TRISTATE_FALSE);
1949 aAcrossParagraphState.bTriStateEnabled = false;
1950 aAcrossColumnState.bTriStateEnabled = false;
1951 aAcrossPageState.bTriStateEnabled = false;
1952 aAcrossSpreadState.bTriStateEnabled = false;
1954 else
1956 m_xHyphenBox->set_state(TRISTATE_INDET);
1957 m_xHyphenNoCapsBox->set_state(TRISTATE_INDET);
1958 m_xHyphenNoLastWordBox->set_state(TRISTATE_INDET);
1960 bool bEnable = bItemAvailable && bIsHyphen;
1961 m_xHyphenNoCapsBox->set_sensitive(bEnable);
1962 m_xHyphenNoLastWordBox->set_sensitive(bEnable);
1963 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
1964 m_xExtHyphenAfterBox->set_sensitive(bEnable);
1965 m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable);
1966 m_xBeforeText->set_sensitive(bEnable);
1967 m_xAfterText->set_sensitive(bEnable);
1968 m_xCompoundBeforeText->set_sensitive(bEnable);
1969 m_xMaxHyphenLabel->set_sensitive(bEnable);
1970 m_xMaxHyphenEdit->set_sensitive(bEnable);
1971 m_xMinWordLabel->set_sensitive(bEnable);
1972 m_xMinWordLength->set_sensitive(bEnable);
1973 m_xHyphenZoneLabel->set_sensitive(bEnable);
1974 m_aHyphenZone.set_sensitive(bEnable);
1975 m_xAcrossText->set_sensitive(bEnable);
1976 m_xAcrossParagraphBox->set_sensitive(bEnable);
1977 m_xAcrossColumnBox->set_sensitive(bEnable);
1978 m_xAcrossPageBox->set_sensitive(bEnable);
1979 m_xAcrossSpreadBox->set_sensitive(bEnable);
1981 switch (rSet->GetItemState(SID_ATTR_PARA_PAGENUM))
1983 case SfxItemState::SET:
1985 aPageNumState.bTriStateEnabled = false;
1986 m_xPageNumBox->set_state(TRISTATE_TRUE);
1987 SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(SID_ATTR_PARA_PAGENUM));
1988 const sal_uInt16 nPageNum(pItem->GetValue());
1989 m_xPagenumEdit->set_value(nPageNum);
1990 break;
1992 case SfxItemState::INVALID:
1994 aPageNumState.bTriStateEnabled = true;
1995 m_xPageNumBox->set_state(TRISTATE_INDET);
1996 break;
1998 case SfxItemState::UNKNOWN:
1999 case SfxItemState::DEFAULT:
2000 case SfxItemState::DISABLED:
2002 aPageNumState.bTriStateEnabled = false;
2003 m_xPageNumBox->set_state(TRISTATE_FALSE);
2004 break;
2006 default:
2007 assert(false); // unexpected
2008 break;
2011 if ( bPageBreak )
2013 // first handle PageModel
2014 bool bIsPageModel = false;
2015 eItemState = rSet->GetItemState( SID_ATTR_PARA_MODEL );
2017 if ( eItemState >= SfxItemState::SET )
2019 aApplyCollState.bTriStateEnabled = false;
2021 const SvxPageModelItem& rModel = rSet->Get( SID_ATTR_PARA_MODEL );
2022 const OUString& aStr( rModel.GetValue() );
2024 if (!aStr.isEmpty() && m_xApplyCollBox->find_text(aStr) != -1)
2026 m_xApplyCollBox->set_active_text(aStr);
2027 m_xApplyCollBtn->set_state(TRISTATE_TRUE);
2028 bIsPageModel = true;
2030 m_xPageBreakBox->set_sensitive(true);
2031 aPageBreakState.bTriStateEnabled = false;
2032 m_xBreakTypeFT->set_sensitive(true);
2033 m_xBreakTypeLB->set_sensitive(true);
2034 m_xBreakPositionFT->set_sensitive(true);
2035 m_xBreakPositionLB->set_sensitive(true);
2036 m_xApplyCollBtn->set_sensitive(false);
2037 m_xPageBreakBox->set_state(TRISTATE_TRUE);
2039 //select page break
2040 m_xBreakTypeLB->set_active(0);
2041 //select break before
2042 m_xBreakPositionLB->set_active(0);
2044 else
2046 m_xApplyCollBox->set_active(-1);
2047 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2050 else if ( SfxItemState::INVALID == eItemState )
2052 aApplyCollState.bTriStateEnabled = true;
2053 m_xApplyCollBtn->set_state(TRISTATE_INDET);
2054 m_xApplyCollBox->set_active(-1);
2056 else
2058 m_xApplyCollBtn->set_sensitive(false);
2059 m_xApplyCollBox->set_sensitive(false);
2060 m_xPagenumEdit->set_sensitive(false);
2061 m_xPageNumBox->set_sensitive(false);
2064 if ( !bIsPageModel )
2066 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
2067 eItemState = rSet->GetItemState( _nWhich );
2069 if ( eItemState >= SfxItemState::DEFAULT )
2071 const SvxFormatBreakItem& rPageBreak =
2072 static_cast<const SvxFormatBreakItem&>(rSet->Get( _nWhich ));
2074 SvxBreak eBreak = rPageBreak.GetBreak();
2076 // PageBreak not via CTRL-RETURN,
2077 // then CheckBox can be freed
2078 m_xPageBreakBox->set_sensitive(true);
2079 aPageBreakState.bTriStateEnabled = false;
2080 m_xBreakTypeFT->set_sensitive(true);
2081 m_xBreakTypeLB->set_sensitive(true);
2082 m_xBreakPositionFT->set_sensitive(true);
2083 m_xBreakPositionLB->set_sensitive(true);
2085 m_xPageBreakBox->set_state(TRISTATE_TRUE);
2087 bool _bEnable = eBreak != SvxBreak::NONE &&
2088 eBreak != SvxBreak::ColumnBefore &&
2089 eBreak != SvxBreak::ColumnAfter;
2090 m_xApplyCollBtn->set_sensitive(_bEnable);
2091 if (!_bEnable)
2093 m_xApplyCollBox->set_sensitive(_bEnable);
2094 m_xPageNumBox->set_sensitive(false);
2095 m_xPagenumEdit->set_sensitive(_bEnable);
2098 if ( eBreak == SvxBreak::NONE )
2099 m_xPageBreakBox->set_state(TRISTATE_FALSE);
2101 sal_Int32 nType = 0; // selection position in break type ListBox : Page
2102 sal_Int32 nPosition = 0; // selection position in break position ListBox : Before
2103 switch ( eBreak )
2105 case SvxBreak::PageBefore:
2106 break;
2107 case SvxBreak::PageAfter:
2108 nPosition = 1;
2109 break;
2110 case SvxBreak::ColumnBefore:
2111 nType = 1;
2112 break;
2113 case SvxBreak::ColumnAfter:
2114 nType = 1;
2115 nPosition = 1;
2116 break;
2117 default: ;//prevent warning
2119 m_xBreakTypeLB->set_active(nType);
2120 m_xBreakPositionLB->set_active(nPosition);
2122 else if ( SfxItemState::INVALID == eItemState )
2123 m_xPageBreakBox->set_state(TRISTATE_INDET);
2124 else
2126 m_xPageBreakBox->set_sensitive(false);
2127 m_xBreakTypeFT->set_sensitive(false);
2128 m_xBreakTypeLB->set_sensitive(false);
2129 m_xBreakPositionFT->set_sensitive(false);
2130 m_xBreakPositionLB->set_sensitive(false);
2134 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2135 PageBreakHdl();
2138 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
2139 eItemState = rSet->GetItemState( _nWhich );
2141 if ( eItemState >= SfxItemState::DEFAULT )
2143 aKeepParaState.bTriStateEnabled = false;
2144 const SvxFormatKeepItem& rKeep =
2145 static_cast<const SvxFormatKeepItem&>(rSet->Get( _nWhich ));
2147 if ( rKeep.GetValue() )
2148 m_xKeepParaBox->set_state(TRISTATE_TRUE);
2149 else
2150 m_xKeepParaBox->set_state(TRISTATE_FALSE);
2152 else if ( SfxItemState::INVALID == eItemState )
2153 m_xKeepParaBox->set_state(TRISTATE_INDET);
2154 else
2155 m_xKeepParaBox->set_sensitive(false);
2157 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
2158 eItemState = rSet->GetItemState( _nWhich );
2160 if ( eItemState >= SfxItemState::DEFAULT )
2162 const SvxFormatSplitItem& rSplit =
2163 static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich ));
2164 aAllowSplitState.bTriStateEnabled = false;
2166 if ( !rSplit.GetValue() )
2167 m_xAllowSplitBox->set_state(TRISTATE_FALSE);
2168 else
2170 m_xAllowSplitBox->set_state(TRISTATE_TRUE);
2171 // default widows and orphans to enabled
2172 m_xWidowBox->set_sensitive(true);
2173 m_xOrphanBox->set_sensitive(true);
2176 // widows and orphans
2177 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
2178 SfxItemState eTmpState = rSet->GetItemState( _nWhich );
2180 if ( eTmpState >= SfxItemState::DEFAULT )
2182 const SvxWidowsItem& rWidow =
2183 static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich ));
2184 aWidowState.bTriStateEnabled = false;
2185 const sal_uInt16 nLines = rWidow.GetValue();
2187 bool _bEnable = nLines > 0;
2188 m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines));
2189 m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2190 m_xWidowRowNo->set_sensitive(_bEnable);
2192 else if ( SfxItemState::INVALID == eTmpState )
2193 m_xWidowBox->set_state( TRISTATE_INDET );
2194 else
2195 m_xWidowBox->set_sensitive(false);
2197 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
2198 eTmpState = rSet->GetItemState( _nWhich );
2200 if ( eTmpState >= SfxItemState::DEFAULT )
2202 const SvxOrphansItem& rOrphan =
2203 static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich ));
2204 const sal_uInt16 nLines = rOrphan.GetValue();
2205 aOrphanState.bTriStateEnabled = false;
2207 bool _bEnable = nLines > 0;
2208 m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2209 m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines));
2210 m_xOrphanRowNo->set_sensitive(_bEnable);
2211 m_xOrphanRowLabel->set_sensitive(_bEnable);
2214 else if ( SfxItemState::INVALID == eTmpState )
2215 m_xOrphanBox->set_state(TRISTATE_INDET);
2216 else
2217 m_xOrphanBox->set_sensitive(false);
2218 aOrphanState.eState = m_xOrphanBox->get_state();
2220 else if ( SfxItemState::INVALID == eItemState )
2221 m_xAllowSplitBox->set_state(TRISTATE_INDET);
2222 else
2223 m_xAllowSplitBox->set_sensitive(false);
2225 // so that everything is enabled correctly
2226 AllowSplitHdl();
2227 WidowHdl();
2228 OrphanHdl();
2229 ChangesApplied();
2231 void SvxExtParagraphTabPage::ChangesApplied()
2233 m_xHyphenBox->save_state();
2234 m_xHyphenNoCapsBox->save_state();
2235 m_xHyphenNoLastWordBox->save_state();
2236 m_xExtHyphenBeforeBox->save_value();
2237 m_xExtHyphenAfterBox->save_value();
2238 m_xExtCompoundHyphenBeforeBox->save_value();
2239 m_xMaxHyphenEdit->save_value();
2240 m_xMinWordLength->save_value();
2241 m_aHyphenZone.save_value();
2242 m_xAcrossParagraphBox->save_state();
2243 m_xAcrossColumnBox->save_state();
2244 m_xAcrossPageBox->save_state();
2245 m_xAcrossSpreadBox->save_state();
2246 m_xPageBreakBox->save_state();
2247 m_xBreakPositionLB->save_value();
2248 m_xBreakTypeLB->save_value();
2249 m_xApplyCollBtn->save_state();
2250 m_xApplyCollBox->save_value();
2251 m_xPageNumBox->save_state();
2252 m_xPagenumEdit->save_value();
2253 m_xAllowSplitBox->save_state();
2254 m_xKeepParaBox->save_state();
2255 m_xWidowBox->save_state();
2256 m_xOrphanBox->save_state();
2257 m_xOrphanRowNo->save_value();
2258 m_xWidowRowNo->save_value();
2261 DeactivateRC SvxExtParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
2263 if ( _pSet )
2264 FillItemSet( _pSet );
2265 return DeactivateRC::LeavePage;
2268 void SvxExtParagraphTabPage::DisablePageBreak()
2270 bPageBreak = false;
2271 m_xPageBreakBox->set_sensitive(false);
2272 m_xBreakTypeLB->remove(0);
2273 m_xBreakPositionFT->set_sensitive(false);
2274 m_xBreakPositionLB->set_sensitive(false);
2275 m_xApplyCollBtn->set_sensitive(false);
2276 m_xApplyCollBox->set_sensitive(false);
2277 m_xPageNumBox->set_sensitive(false);
2278 m_xPagenumEdit->set_sensitive(false);
2281 SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
2282 : SfxTabPage(pPage, pController, u"cui/ui/textflowpage.ui"_ustr, u"TextFlowPage"_ustr, &rAttr)
2283 , bPageBreak(true)
2284 , bHtmlMode(false)
2285 , nStdPos(0)
2286 // Hyphenation
2287 , m_xHyphenBox(m_xBuilder->weld_check_button(u"checkAuto"_ustr))
2288 , m_xHyphenNoCapsBox(m_xBuilder->weld_check_button(u"checkNoCaps"_ustr))
2289 , m_xHyphenNoLastWordBox(m_xBuilder->weld_check_button(u"checkNoLastWord"_ustr))
2290 , m_xBeforeText(m_xBuilder->weld_label(u"labelLineBegin"_ustr))
2291 , m_xExtHyphenBeforeBox(m_xBuilder->weld_spin_button(u"spinLineEnd"_ustr))
2292 , m_xAfterText(m_xBuilder->weld_label(u"labelLineEnd"_ustr))
2293 , m_xExtHyphenAfterBox(m_xBuilder->weld_spin_button(u"spinLineBegin"_ustr))
2294 , m_xCompoundBeforeText(m_xBuilder->weld_label(u"labelCompoundLineEnd"_ustr))
2295 , m_xExtCompoundHyphenBeforeBox(m_xBuilder->weld_spin_button(u"spinCompoundLineEnd"_ustr))
2296 , m_xMaxHyphenLabel(m_xBuilder->weld_label(u"labelMaxNum"_ustr))
2297 , m_xMaxHyphenEdit(m_xBuilder->weld_spin_button(u"spinMaxNum"_ustr))
2298 , m_xMinWordLabel(m_xBuilder->weld_label(u"labelMinLen"_ustr))
2299 , m_xMinWordLength(m_xBuilder->weld_spin_button(u"spinMinLen"_ustr))
2300 , m_xHyphenZoneLabel(m_xBuilder->weld_label(u"labelHyphenZone"_ustr))
2301 , m_aHyphenZone(m_xBuilder->weld_metric_spin_button(u"spinHyphenZone"_ustr, FieldUnit::CM))
2302 //Page break
2303 , m_xPageBreakBox(m_xBuilder->weld_check_button(u"checkInsert"_ustr))
2304 , m_xBreakTypeFT(m_xBuilder->weld_label(u"labelType"_ustr))
2305 , m_xBreakTypeLB(m_xBuilder->weld_combo_box(u"comboBreakType"_ustr))
2306 , m_xBreakPositionFT(m_xBuilder->weld_label(u"labelPosition"_ustr))
2307 , m_xBreakPositionLB(m_xBuilder->weld_combo_box(u"comboBreakPosition"_ustr))
2308 , m_xApplyCollBtn(m_xBuilder->weld_check_button(u"checkPageStyle"_ustr))
2309 , m_xApplyCollBox(m_xBuilder->weld_combo_box(u"comboPageStyle"_ustr))
2310 , m_xPageNumBox(m_xBuilder->weld_check_button(u"labelPageNum"_ustr))
2311 , m_xPagenumEdit(m_xBuilder->weld_spin_button(u"spinPageNumber"_ustr))
2312 // Options
2313 , m_xAllowSplitBox(m_xBuilder->weld_check_button(u"checkSplitPara"_ustr))
2314 , m_xKeepParaBox(m_xBuilder->weld_check_button(u"checkKeepPara"_ustr))
2315 , m_xOrphanBox(m_xBuilder->weld_check_button(u"checkOrphan"_ustr))
2316 , m_xOrphanRowNo(m_xBuilder->weld_spin_button(u"spinOrphan"_ustr))
2317 , m_xOrphanRowLabel(m_xBuilder->weld_label(u"labelOrphan"_ustr))
2318 , m_xWidowBox(m_xBuilder->weld_check_button(u"checkWidow"_ustr))
2319 , m_xWidowRowNo(m_xBuilder->weld_spin_button(u"spinWidow"_ustr))
2320 , m_xWidowRowLabel(m_xBuilder->weld_label(u"labelWidow"_ustr))
2321 // Avoid hyphenation across
2322 , m_xAcrossText(m_xBuilder->weld_label(u"labelHyphenAcross"_ustr))
2323 , m_xAcrossParagraphBox(m_xBuilder->weld_check_button(u"checkAcrossParagraph"_ustr))
2324 , m_xAcrossColumnBox(m_xBuilder->weld_check_button(u"checkAcrossColumn"_ustr))
2325 , m_xAcrossPageBox(m_xBuilder->weld_check_button(u"checkAcrossPage"_ustr))
2326 , m_xAcrossSpreadBox(m_xBuilder->weld_check_button(u"checkAcrossSpread"_ustr))
2328 // this page needs ExchangeSupport
2329 SetExchangeSupport();
2331 m_xHyphenBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, HyphenClickHdl_Impl));
2332 m_xPageBreakBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageBreakHdl_Impl));
2333 m_xAllowSplitBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AllowSplitHdl_Impl));
2334 m_xWidowBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, WidowHdl_Impl));
2335 m_xOrphanBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, OrphanHdl_Impl));
2336 m_xApplyCollBtn->connect_toggled(LINK(this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl));
2337 m_xBreakTypeLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl));
2338 m_xBreakPositionLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl));
2339 m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl));
2340 m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl));
2341 m_xAcrossParagraphBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossParagraphHdl_Impl));
2342 m_xAcrossColumnBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossColumnHdl_Impl));
2343 m_xAcrossPageBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossPageHdl_Impl));
2344 m_xAcrossSpreadBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossSpreadHdl_Impl));
2346 if (SfxObjectShell* pSh = SfxObjectShell::Current())
2348 SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
2349 SfxStyleSheetBase* pStyle = pPool->First(SfxStyleFamily::Page);
2350 OUString aStdName;
2352 // tdf139131 - sort page styles
2353 m_xApplyCollBox->make_sorted();
2354 while( pStyle )
2356 if ( aStdName.isEmpty() )
2357 // first style == standard style
2358 aStdName = pStyle->GetName();
2359 m_xApplyCollBox->append_text(pStyle->GetName());
2360 pStyle = pPool->Next();
2362 nStdPos = m_xApplyCollBox->find_text(aStdName);
2365 sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr );
2366 if ( !(nHtmlMode & HTMLMODE_ON) )
2367 return;
2369 bHtmlMode = true;
2370 m_xHyphenBox->set_sensitive(false);
2371 m_xHyphenNoCapsBox->set_sensitive(false);
2372 m_xHyphenNoLastWordBox->set_sensitive(false);
2373 m_xBeforeText->set_sensitive(false);
2374 m_xExtHyphenBeforeBox->set_sensitive(false);
2375 m_xAfterText->set_sensitive(false);
2376 m_xExtHyphenAfterBox->set_sensitive(false);
2377 m_xCompoundBeforeText->set_sensitive(false);
2378 m_xExtCompoundHyphenBeforeBox->set_sensitive(false);
2379 m_xMaxHyphenLabel->set_sensitive(false);
2380 m_xMaxHyphenEdit->set_sensitive(false);
2381 m_xMinWordLabel->set_sensitive(false);
2382 m_xMinWordLength->set_sensitive(false);
2383 m_xHyphenZoneLabel->set_sensitive(false);
2384 m_aHyphenZone.set_sensitive(false);
2385 m_xPageNumBox->set_sensitive(false);
2386 m_xPagenumEdit->set_sensitive(false);
2387 m_xAcrossText->set_sensitive(false);
2388 m_xAcrossParagraphBox->set_sensitive(false);
2389 m_xAcrossColumnBox->set_sensitive(false);
2390 m_xAcrossPageBox->set_sensitive(false);
2391 m_xAcrossSpreadBox->set_sensitive(false);
2392 // no column break in HTML
2393 m_xBreakTypeLB->remove(1);
2396 SvxExtParagraphTabPage::~SvxExtParagraphTabPage()
2400 void SvxExtParagraphTabPage::PageBreakHdl()
2402 switch (m_xPageBreakBox->get_state())
2404 case TRISTATE_TRUE:
2405 m_xBreakTypeFT->set_sensitive(true);
2406 m_xBreakTypeLB->set_sensitive(true);
2407 m_xBreakPositionFT->set_sensitive(true);
2408 m_xBreakPositionLB->set_sensitive(true);
2410 if (0 == m_xBreakTypeLB->get_active() && 0 == m_xBreakPositionLB->get_active())
2412 m_xApplyCollBtn->set_sensitive(true);
2414 bool bEnable = TRISTATE_TRUE == m_xApplyCollBtn->get_state() &&
2415 m_xApplyCollBox->get_count();
2416 m_xApplyCollBox->set_sensitive(bEnable);
2417 if(!bHtmlMode)
2419 m_xPageNumBox->set_sensitive(bEnable);
2420 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2423 break;
2425 case TRISTATE_FALSE:
2426 case TRISTATE_INDET:
2427 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2428 m_xApplyCollBtn->set_sensitive(false);
2429 m_xApplyCollBox->set_sensitive(false);
2430 m_xPageNumBox->set_sensitive(false);
2431 m_xPagenumEdit->set_sensitive(false);
2432 m_xBreakTypeFT->set_sensitive(false);
2433 m_xBreakTypeLB->set_sensitive(false);
2434 m_xBreakPositionFT->set_sensitive(false);
2435 m_xBreakPositionLB->set_sensitive(false);
2436 break;
2440 IMPL_LINK(SvxExtParagraphTabPage, PageBreakHdl_Impl, weld::Toggleable&, rToggle, void)
2442 aPageBreakState.ButtonToggled(rToggle);
2443 PageBreakHdl();
2446 void SvxExtParagraphTabPage::AllowSplitHdl()
2448 bool bEnable = m_xAllowSplitBox->get_state() == TRISTATE_TRUE;
2449 m_xWidowBox->set_sensitive(bEnable);
2450 m_xOrphanBox->set_sensitive(bEnable);
2453 IMPL_LINK(SvxExtParagraphTabPage, AllowSplitHdl_Impl, weld::Toggleable&, rToggle, void)
2455 aAllowSplitState.ButtonToggled(rToggle);
2456 AllowSplitHdl();
2459 void SvxExtParagraphTabPage::WidowHdl()
2461 switch (m_xWidowBox->get_state())
2463 case TRISTATE_TRUE:
2464 m_xWidowRowNo->set_sensitive(true);
2465 m_xWidowRowLabel->set_sensitive(true);
2466 m_xAllowSplitBox->set_sensitive(true);
2467 break;
2468 case TRISTATE_FALSE:
2469 if (m_xOrphanBox->get_state() == TRISTATE_FALSE)
2470 m_xAllowSplitBox->set_sensitive(false);
2471 [[fallthrough]];
2472 case TRISTATE_INDET:
2473 m_xWidowRowNo->set_sensitive(false);
2474 m_xWidowRowLabel->set_sensitive(false);
2475 break;
2479 IMPL_LINK(SvxExtParagraphTabPage, WidowHdl_Impl, weld::Toggleable&, rToggle, void)
2481 aWidowState.ButtonToggled(rToggle);
2482 WidowHdl();
2485 IMPL_LINK(SvxExtParagraphTabPage, OrphanHdl_Impl, weld::Toggleable&, rToggle, void)
2487 aOrphanState.ButtonToggled(rToggle);
2488 OrphanHdl();
2491 void SvxExtParagraphTabPage::OrphanHdl()
2493 switch (m_xOrphanBox->get_state())
2495 case TRISTATE_TRUE:
2496 m_xOrphanRowNo->set_sensitive(true);
2497 m_xOrphanRowLabel->set_sensitive(true);
2498 m_xAllowSplitBox->set_sensitive(true);
2499 break;
2501 case TRISTATE_FALSE:
2502 if (m_xWidowBox->get_state() == TRISTATE_FALSE)
2503 m_xAllowSplitBox->set_sensitive(true);
2504 [[fallthrough]];
2505 case TRISTATE_INDET:
2506 m_xOrphanRowNo->set_sensitive(false);
2507 m_xOrphanRowLabel->set_sensitive(false);
2508 break;
2512 void SvxExtParagraphTabPage::HyphenClickHdl()
2514 bool bEnable = m_xHyphenBox->get_state() == TRISTATE_TRUE;
2515 m_xHyphenNoCapsBox->set_sensitive(bEnable);
2516 m_xHyphenNoLastWordBox->set_sensitive(bEnable);
2517 m_xBeforeText->set_sensitive(bEnable);
2518 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
2519 m_xAfterText->set_sensitive(bEnable);
2520 m_xExtHyphenAfterBox->set_sensitive(bEnable);
2521 m_xCompoundBeforeText->set_sensitive(bEnable);
2522 m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable);
2523 m_xMaxHyphenLabel->set_sensitive(bEnable);
2524 m_xMaxHyphenEdit->set_sensitive(bEnable);
2525 m_xMinWordLabel->set_sensitive(bEnable);
2526 m_xMinWordLength->set_sensitive(bEnable);
2527 m_xHyphenZoneLabel->set_sensitive(bEnable);
2528 m_aHyphenZone.set_sensitive(bEnable);
2529 m_xAcrossText->set_sensitive(bEnable);
2530 m_xAcrossParagraphBox->set_sensitive(bEnable);
2531 m_xAcrossColumnBox->set_sensitive(bEnable);
2532 m_xAcrossPageBox->set_sensitive(bEnable);
2533 m_xAcrossSpreadBox->set_sensitive(bEnable);
2534 m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2537 IMPL_LINK(SvxExtParagraphTabPage, HyphenClickHdl_Impl, weld::Toggleable&, rToggle, void)
2539 aHyphenState.ButtonToggled(rToggle);
2540 HyphenClickHdl();
2543 void SvxExtParagraphTabPage::ApplyCollClickHdl()
2545 bool bEnable = false;
2546 if (m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count())
2548 bEnable = true;
2549 m_xApplyCollBox->set_active(nStdPos);
2551 else
2553 m_xApplyCollBox->set_active(-1);
2555 m_xApplyCollBox->set_sensitive(bEnable);
2556 if (!bHtmlMode)
2558 m_xPageNumBox->set_sensitive(bEnable);
2559 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2563 IMPL_LINK(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl, weld::Toggleable&, rToggle, void)
2565 aApplyCollState.ButtonToggled(rToggle);
2566 ApplyCollClickHdl();
2569 IMPL_LINK(SvxExtParagraphTabPage, PageBreakPosHdl_Impl, weld::ComboBox&, rListBox, void)
2571 if (0 == rListBox.get_active())
2573 m_xApplyCollBtn->set_sensitive(true);
2575 bool bEnable = m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count();
2577 m_xApplyCollBox->set_sensitive(bEnable);
2578 if (!bHtmlMode)
2580 m_xPageNumBox->set_sensitive(bEnable);
2581 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2584 else if (1 == rListBox.get_active())
2586 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2587 m_xApplyCollBtn->set_sensitive(false);
2588 m_xApplyCollBox->set_sensitive(false);
2589 m_xPageNumBox->set_sensitive(false);
2590 m_xPagenumEdit->set_sensitive(false);
2594 IMPL_LINK(SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, weld::ComboBox&, rListBox, void)
2596 //column break or break after
2597 int nBreakPos = m_xBreakPositionLB->get_active();
2598 if (rListBox.get_active() == 1 || 1 == nBreakPos)
2600 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2601 m_xApplyCollBtn->set_sensitive(false);
2602 m_xApplyCollBox->set_sensitive(false);
2603 m_xPageNumBox->set_sensitive(false);
2604 m_xPagenumEdit->set_sensitive(false);
2606 else
2607 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2610 void SvxExtParagraphTabPage::PageNumBoxClickHdl()
2612 m_xPagenumEdit->set_sensitive(m_xPageNumBox->get_state() == TRISTATE_TRUE);
2615 IMPL_LINK(SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl, weld::Toggleable&, rToggle, void)
2617 aPageNumState.ButtonToggled(rToggle);
2618 PageNumBoxClickHdl();
2621 IMPL_LINK(SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl, weld::Toggleable&, rToggle, void)
2623 aKeepParaState.ButtonToggled(rToggle);
2626 void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
2628 const SfxBoolItem* pDisablePageBreakItem = aSet.GetItem<SfxBoolItem>(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false);
2630 if (pDisablePageBreakItem)
2631 if ( pDisablePageBreakItem->GetValue())
2632 DisablePageBreak();
2635 IMPL_LINK(SvxExtParagraphTabPage, AcrossParagraphHdl_Impl, weld::Toggleable&, rToggle, void)
2637 aAcrossParagraphState.ButtonToggled(rToggle);
2638 if (m_xAcrossParagraphBox->get_state() != TRISTATE_TRUE )
2640 m_xAcrossColumnBox->set_state( TRISTATE_FALSE );
2641 m_xAcrossPageBox->set_state( TRISTATE_FALSE );
2642 m_xAcrossSpreadBox->set_state( TRISTATE_FALSE );
2646 IMPL_LINK(SvxExtParagraphTabPage, AcrossColumnHdl_Impl, weld::Toggleable&, rToggle, void)
2648 aAcrossColumnState.ButtonToggled(rToggle);
2649 if (m_xAcrossColumnBox->get_state() != TRISTATE_TRUE )
2651 m_xAcrossPageBox->set_state( TRISTATE_FALSE );
2652 m_xAcrossSpreadBox->set_state( TRISTATE_FALSE );
2654 else
2655 m_xAcrossParagraphBox->set_state( TRISTATE_TRUE );
2658 IMPL_LINK(SvxExtParagraphTabPage, AcrossPageHdl_Impl, weld::Toggleable&, rToggle, void)
2660 aAcrossPageState.ButtonToggled(rToggle);
2661 if (m_xAcrossPageBox->get_state() == TRISTATE_TRUE )
2663 m_xAcrossParagraphBox->set_state( TRISTATE_TRUE );
2664 m_xAcrossColumnBox->set_state( TRISTATE_TRUE );
2666 else
2667 m_xAcrossSpreadBox->set_state( TRISTATE_FALSE );
2670 IMPL_LINK(SvxExtParagraphTabPage, AcrossSpreadHdl_Impl, weld::Toggleable&, rToggle, void)
2672 aAcrossSpreadState.ButtonToggled(rToggle);
2673 if (m_xAcrossSpreadBox->get_state() == TRISTATE_TRUE )
2675 m_xAcrossParagraphBox->set_state( TRISTATE_TRUE );
2676 m_xAcrossColumnBox->set_state( TRISTATE_TRUE );
2677 m_xAcrossPageBox->set_state( TRISTATE_TRUE );
2681 SvxAsianTabPage::SvxAsianTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
2682 : SfxTabPage(pPage, pController, u"cui/ui/asiantypography.ui"_ustr, u"AsianTypography"_ustr, &rSet)
2683 , m_xForbiddenRulesCB(m_xBuilder->weld_check_button(u"checkForbidList"_ustr))
2684 , m_xHangingPunctCB(m_xBuilder->weld_check_button(u"checkHangPunct"_ustr))
2685 , m_xScriptSpaceCB(m_xBuilder->weld_check_button(u"checkApplySpacing"_ustr))
2689 SvxAsianTabPage::~SvxAsianTabPage()
2693 std::unique_ptr<SfxTabPage> SvxAsianTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2695 return std::make_unique<SvxAsianTabPage>(pPage, pController, *rSet);
2698 const WhichRangesContainer & SvxAsianTabPage::GetRanges()
2700 static const auto gRanges = WhichRangesContainer(svl::Items<SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES>);
2701 return gRanges;
2704 bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet )
2706 bool bRet = false;
2707 SfxItemPool* pPool = rSet->GetPool();
2708 if (m_xScriptSpaceCB->get_sensitive() && m_xScriptSpaceCB->get_state_changed_from_saved())
2710 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2711 pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_SCRIPTSPACE)).Clone()));
2712 pNewItem->SetValue(m_xScriptSpaceCB->get_active());
2713 rSet->Put(std::move(pNewItem));
2714 bRet = true;
2716 if (m_xHangingPunctCB->get_sensitive() && m_xHangingPunctCB->get_state_changed_from_saved())
2718 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2719 pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_HANGPUNCTUATION)).Clone()));
2720 pNewItem->SetValue(m_xHangingPunctCB->get_active());
2721 rSet->Put(std::move(pNewItem));
2722 bRet = true;
2724 if (m_xForbiddenRulesCB->get_sensitive() && m_xForbiddenRulesCB->get_state_changed_from_saved())
2726 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2727 pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone()));
2728 pNewItem->SetValue(m_xForbiddenRulesCB->get_active());
2729 rSet->Put(std::move(pNewItem));
2730 bRet = true;
2732 return bRet;
2735 static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, weld::CheckButton& rBox)
2737 sal_uInt16 _nWhich = rSet.GetPool()->GetWhichIDFromSlotID(nSlotId);
2738 SfxItemState eState = rSet.GetItemState(_nWhich);
2739 if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED )
2740 rBox.set_sensitive(false);
2741 else if(eState >= SfxItemState::DEFAULT)
2742 rBox.set_active(static_cast<const SfxBoolItem&>(rSet.Get(_nWhich)).GetValue());
2743 else
2744 rBox.set_state(TRISTATE_INDET);
2745 rBox.save_state();
2748 void SvxAsianTabPage::Reset( const SfxItemSet* rSet )
2750 lcl_SetBox(*rSet, SID_ATTR_PARA_FORBIDDEN_RULES, *m_xForbiddenRulesCB );
2751 lcl_SetBox(*rSet, SID_ATTR_PARA_HANGPUNCTUATION, *m_xHangingPunctCB );
2753 //character distance not yet available
2754 lcl_SetBox(*rSet, SID_ATTR_PARA_SCRIPTSPACE, *m_xScriptSpaceCB );
2757 void SvxAsianTabPage::ChangesApplied()
2759 m_xForbiddenRulesCB->save_state();
2760 m_xHangingPunctCB->save_state();
2761 m_xScriptSpaceCB->save_state();
2764 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */