android: Update app-specific/MIME type icons
[LibreOffice.git] / cui / source / tabpages / paragrph.cxx
blobff06ee623c8e1c6d08844cbecfa98df97121961e
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 <svx/dlgutil.hxx>
52 #include <sfx2/htmlmode.hxx>
53 #include <editeng/paravertalignitem.hxx>
54 #include <svl/eitem.hxx>
55 #include <svl/intitem.hxx>
57 const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges(
58 svl::Items<
59 SID_ATTR_PARA_LINESPACE, SID_ATTR_PARA_LINESPACE, // 10033
60 SID_ATTR_PARA_LEFTSPACE, SID_ATTR_PARA_FIRSTLINESPACE,
61 SID_ATTR_LRSPACE, SID_ATTR_ULSPACE, // 10048 - 10049
62 SID_ATTR_PARA_REGISTER, SID_ATTR_PARA_REGISTER // 10413
63 >);
65 const WhichRangesContainer SvxParaAlignTabPage::pAlignRanges(
66 svl::Items<SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST>); // 10027
68 const WhichRangesContainer SvxParaAlignTabPage::pSdrAlignRanges(
69 svl::Items<
70 SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, // 1076
71 SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST , // 10027
72 SID_ATTR_FRAMEDIRECTION, SID_ATTR_FRAMEDIRECTION // 10944
73 >);
75 const WhichRangesContainer SvxExtParagraphTabPage::pExtRanges(svl::Items<
76 SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS, // 10037 - 10041
77 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP // 10065 - 10066
78 >);
80 #define MAX_DURCH 31680 // tdf#68335: 1584 pt for UX interoperability with Word
81 #define FIX_DIST_DEF 283 // standard fix distance 0,5 cm
83 namespace {
85 enum LineSpaceList
87 LLINESPACE_1 = 0,
88 LLINESPACE_115 = 1,
89 LLINESPACE_15 = 2,
90 LLINESPACE_2 = 3,
91 LLINESPACE_PROP = 4,
92 LLINESPACE_MIN = 5,
93 LLINESPACE_DURCH= 6,
94 LLINESPACE_FIX = 7
99 static void SetLineSpace_Impl( SvxLineSpacingItem&, int, tools::Long lValue = 0 );
101 void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
102 int eSpace, tools::Long lValue )
104 switch ( eSpace )
106 case LLINESPACE_1:
107 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
108 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
109 break;
111 case LLINESPACE_115:
112 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
113 rLineSpace.SetPropLineSpace( 115 );
114 break;
116 case LLINESPACE_15:
117 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
118 rLineSpace.SetPropLineSpace( 150 );
119 break;
121 case LLINESPACE_2:
122 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
123 rLineSpace.SetPropLineSpace( 200 );
124 break;
126 case LLINESPACE_PROP:
127 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
128 rLineSpace.SetPropLineSpace( static_cast<sal_uInt16>(lValue) );
129 break;
131 case LLINESPACE_MIN:
132 rLineSpace.SetLineHeight( static_cast<sal_uInt16>(lValue) );
133 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
134 break;
136 case LLINESPACE_DURCH:
137 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
138 rLineSpace.SetInterLineSpace( static_cast<sal_uInt16>(lValue) );
139 break;
141 case LLINESPACE_FIX:
142 rLineSpace.SetLineHeight(static_cast<sal_uInt16>(lValue));
143 rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Fix );
144 rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
145 break;
149 static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
151 sal_uInt16 nHtmlMode = 0;
152 const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false);
153 if (!pItem)
155 if (SfxObjectShell* pShell = SfxObjectShell::Current())
156 pItem = pShell->GetItem(SID_HTML_MODE);
158 if(pItem)
160 nHtmlMode = pItem->GetValue();
162 return nHtmlMode;
166 void SvxStdParagraphTabPage::ELRLoseFocus()
168 SfxItemPool* pPool = GetItemSet().GetPool();
169 DBG_ASSERT( pPool, "Where is the pool?" );
170 FieldUnit eUnit =
171 MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
173 sal_Int64 nL = m_aLeftIndent.denormalize(m_aLeftIndent.get_value(eUnit));
174 sal_Int64 nR = m_aRightIndent.denormalize(m_aRightIndent.get_value(eUnit));
175 OUString aTmp = m_aFLineIndent.get_text();
177 if (m_aLeftIndent.get_min(FieldUnit::NONE) < 0)
178 m_aFLineIndent.set_min(-99999, FieldUnit::MM);
179 else
180 m_aFLineIndent.set_min(m_aFLineIndent.normalize(-nL), eUnit);
182 // Check only for concrete width (Shell)
183 sal_Int64 nTmp = nWidth - nL - nR - MM50;
184 m_aFLineIndent.set_max(m_aFLineIndent.normalize(nTmp), eUnit);
186 if (aTmp.isEmpty())
187 m_aFLineIndent.set_text(OUString());
188 // maximum left right
189 aTmp = m_aLeftIndent.get_text();
190 nTmp = nWidth - nR - MM50;
191 m_aLeftIndent.set_max(m_aLeftIndent.normalize(nTmp), eUnit);
193 if ( aTmp.isEmpty() )
194 m_aLeftIndent.set_text(OUString());
195 aTmp = m_aRightIndent.get_text();
196 nTmp = nWidth - nL - MM50;
197 m_aRightIndent.set_max(m_aRightIndent.normalize(nTmp), eUnit);
199 if ( aTmp.isEmpty() )
200 m_aRightIndent.set_text(OUString());
202 UpdateExample_Impl();
205 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl, weld::MetricSpinButton&, void)
207 ELRLoseFocus();
210 std::unique_ptr<SfxTabPage> SvxStdParagraphTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
212 return std::make_unique<SvxStdParagraphTabPage>(pPage, pController, *rSet);
215 bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
217 const SfxPoolItem* pOld = nullptr;
218 SfxItemPool* pPool = rOutSet->GetPool();
219 DBG_ASSERT( pPool, "Where is the pool?" );
221 bool bModified = false;
222 sal_uInt16 nWhich;
223 int nPos = m_xLineDist->get_active();
225 if ( nPos != -1 &&
226 ( m_bLineDistToggled ||
227 m_xLineDist->get_value_changed_from_saved() ||
228 m_xLineDistAtPercentBox->get_value_changed_from_saved() ||
229 m_xLineDistAtMetricBox->get_value_changed_from_saved() ) )
231 nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
232 MapUnit eUnit = pPool->GetMetric( nWhich );
233 SvxLineSpacingItem aSpacing(
234 static_cast<const SvxLineSpacingItem&>(GetItemSet().Get( nWhich )) );
236 switch ( nPos )
238 case LLINESPACE_1:
239 case LLINESPACE_115:
240 case LLINESPACE_15:
241 case LLINESPACE_2:
242 SetLineSpace_Impl( aSpacing, nPos );
243 break;
245 case LLINESPACE_PROP:
246 SetLineSpace_Impl( aSpacing, nPos,
247 static_cast<tools::Long>(m_xLineDistAtPercentBox->denormalize(
248 m_xLineDistAtPercentBox->get_value(FieldUnit::NONE) )) );
249 break;
251 case LLINESPACE_MIN:
252 case LLINESPACE_DURCH:
253 case LLINESPACE_FIX:
254 SetLineSpace_Impl( aSpacing, nPos,
255 GetCoreValue( *m_xLineDistAtMetricBox, eUnit ) );
256 break;
258 default:
259 OSL_FAIL( "unknown LineDist entry" );
260 break;
262 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_LINESPACE );
264 if ( m_bLineDistToggled ||
265 !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) ||
266 SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) )
268 rOutSet->Put( aSpacing );
269 bModified = true;
273 if ( m_aTopDist.get_value_changed_from_saved() || m_aBottomDist.get_value_changed_from_saved()
274 || m_xContextualCB->get_state_changed_from_saved())
276 nWhich = GetWhich( SID_ATTR_ULSPACE );
277 MapUnit eUnit = pPool->GetMetric( nWhich );
278 pOld = GetOldItem( *rOutSet, SID_ATTR_ULSPACE );
279 SvxULSpaceItem aMargin( nWhich );
281 if ( bRelativeMode )
283 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
285 const SvxULSpaceItem& rOldItem =
286 static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
288 if ( m_aTopDist.IsRelative() )
289 aMargin.SetUpper( rOldItem.GetUpper(),
290 static_cast<sal_uInt16>(m_aTopDist.get_value(FieldUnit::NONE)) );
291 else
292 aMargin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)) );
294 if ( m_aBottomDist.IsRelative() )
295 aMargin.SetLower( rOldItem.GetLower(),
296 static_cast<sal_uInt16>(m_aBottomDist.get_value(FieldUnit::NONE)) );
297 else
298 aMargin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)) );
301 else
303 aMargin.SetUpper(static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)));
304 aMargin.SetLower(static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)));
306 aMargin.SetContextValue(m_xContextualCB->get_active());
308 if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin ||
309 SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) )
311 rOutSet->Put( aMargin );
312 bModified = true;
315 bool bNullTab = false;
317 if (m_bSplitLRSpace && m_aLeftIndent.get_value_changed_from_saved())
319 nWhich = GetWhich(SID_ATTR_PARA_LEFTSPACE);
320 MapUnit const eUnit = pPool->GetMetric(nWhich);
321 SvxTextLeftMarginItem item(nWhich);
322 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_LEFTSPACE);
324 if (bRelativeMode)
326 assert(GetItemSet().GetParent());
328 const SvxTextLeftMarginItem & rOldItem(
329 static_cast<const SvxTextLeftMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));
331 if (m_aLeftIndent.IsRelative())
333 item.SetTextLeft(rOldItem.GetTextLeft(),
334 static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)));
336 else
338 item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
341 else
343 item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
345 if (!pOld || *static_cast<const SvxTextLeftMarginItem*>(pOld) != item
346 || SfxItemState::DONTCARE == GetItemSet().GetItemState(nWhich))
348 rOutSet->Put(item);
349 bModified = true;
353 if (m_bSplitLRSpace && m_aRightIndent.get_value_changed_from_saved())
355 nWhich = GetWhich(SID_ATTR_PARA_RIGHTSPACE);
356 MapUnit const eUnit = pPool->GetMetric(nWhich);
357 SvxRightMarginItem item(nWhich);
358 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_RIGHTSPACE);
360 if (bRelativeMode)
362 assert(GetItemSet().GetParent());
364 const SvxRightMarginItem & rOldItem(
365 static_cast<const SvxRightMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));
367 if (m_aRightIndent.IsRelative())
369 item.SetRight(rOldItem.GetRight(),
370 static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)));
372 else
374 item.SetRight(m_aRightIndent.GetCoreValue(eUnit));
377 else
379 item.SetRight(m_aRightIndent.GetCoreValue(eUnit));
381 if (!pOld || *static_cast<const SvxRightMarginItem*>(pOld) != item
382 || SfxItemState::DONTCARE == GetItemSet().GetItemState(nWhich))
384 rOutSet->Put(item);
385 bModified = true;
389 if (m_bSplitLRSpace && (m_aFLineIndent.get_value_changed_from_saved()
390 || m_xAutoCB->get_state_changed_from_saved()))
392 nWhich = GetWhich(SID_ATTR_PARA_FIRSTLINESPACE);
393 MapUnit const eUnit = pPool->GetMetric(nWhich);
394 SvxFirstLineIndentItem item(nWhich);
395 pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_FIRSTLINESPACE);
397 if (bRelativeMode)
399 assert(GetItemSet().GetParent());
401 const SvxFirstLineIndentItem & rOldItem(
402 static_cast<const SvxFirstLineIndentItem&>(GetItemSet().GetParent()->Get(nWhich)));
404 if (m_aFLineIndent.IsRelative())
406 item.SetTextFirstLineOffset(rOldItem.GetTextFirstLineOffset(),
407 static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)));
409 else
411 item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
414 else
416 item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
418 item.SetAutoFirst(m_xAutoCB->get_active());
419 if (item.GetTextFirstLineOffset() < 0)
421 bNullTab = true;
424 if (!pOld || *static_cast<const SvxFirstLineIndentItem*>(pOld) != item
425 || SfxItemState::DONTCARE == GetItemSet().GetItemState(nWhich))
427 rOutSet->Put(item);
428 bModified = true;
432 if (!m_bSplitLRSpace &&
433 (m_aLeftIndent.get_value_changed_from_saved() ||
434 m_aFLineIndent.get_value_changed_from_saved() ||
435 m_aRightIndent.get_value_changed_from_saved() ||
436 m_xAutoCB->get_state_changed_from_saved()))
438 nWhich = GetWhich( SID_ATTR_LRSPACE );
439 MapUnit eUnit = pPool->GetMetric( nWhich );
440 SvxLRSpaceItem aMargin( nWhich );
441 pOld = GetOldItem( *rOutSet, SID_ATTR_LRSPACE );
443 if ( bRelativeMode )
445 DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
447 const SvxLRSpaceItem& rOldItem =
448 static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));
450 if (m_aLeftIndent.IsRelative())
451 aMargin.SetTextLeft( rOldItem.GetTextLeft(),
452 static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)) );
453 else
454 aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
456 if ( m_aRightIndent.IsRelative() )
457 aMargin.SetRight( rOldItem.GetRight(),
458 static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)) );
459 else
460 aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit));
462 if ( m_aFLineIndent.IsRelative() )
463 aMargin.SetTextFirstLineOffset( rOldItem.GetTextFirstLineOffset(),
464 static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)) );
465 else
466 aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
468 else
470 aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit));
471 aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit));
472 aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit)));
474 aMargin.SetAutoFirst(m_xAutoCB->get_active());
475 if ( aMargin.GetTextFirstLineOffset() < 0 )
476 bNullTab = true;
478 if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin ||
479 SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) )
481 rOutSet->Put( aMargin );
482 bModified = true;
486 if ( bNullTab )
488 MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
489 if ( MapUnit::Map100thMM != eUnit )
492 // negative first line indent -> set null default tabstob if applicable
493 sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
494 const SfxItemSet& rInSet = GetItemSet();
496 if ( rInSet.GetItemState( _nWhich ) >= SfxItemState::DEFAULT )
498 const SvxTabStopItem& rTabItem =
499 static_cast<const SvxTabStopItem&>(rInSet.Get( _nWhich ));
500 SvxTabStopItem aNullTab( rTabItem );
501 SvxTabStop aNull( 0, SvxTabAdjust::Default );
502 aNullTab.Insert( aNull );
503 rOutSet->Put( aNullTab );
507 if (m_xRegisterCB->get_visible())
509 const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(GetOldItem(
510 *rOutSet, SID_ATTR_PARA_REGISTER));
511 if (!pBoolItem)
512 return bModified;
513 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
514 bool bSet = pBoolItem->GetValue();
516 if (m_xRegisterCB->get_active() != bSet)
518 std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone());
519 pRegItem->SetValue(!bSet);
520 rOutSet->Put(std::move(pRegItem));
521 bModified = true;
523 else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) )
524 rOutSet->ClearItem(_nWhich);
527 return bModified;
530 void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet )
532 SfxItemPool* pPool = rSet->GetPool();
533 DBG_ASSERT( pPool, "Where is the pool?" );
535 // adjust metric
536 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
538 bool bApplyCharUnit = GetApplyCharUnit( *rSet );
540 if(SvtCJKOptions::IsAsianTypographyEnabled() && bApplyCharUnit )
541 eFUnit = FieldUnit::CHAR;
543 m_aLeftIndent.SetFieldUnit(eFUnit);
544 m_aRightIndent.SetFieldUnit(eFUnit);
545 m_aFLineIndent.SetFieldUnit(eFUnit);
546 if ( eFUnit == FieldUnit::CHAR )
548 m_aTopDist.SetFieldUnit(FieldUnit::LINE);
549 m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
550 SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT);
552 else
554 m_aTopDist.SetFieldUnit(eFUnit);
555 m_aBottomDist.SetFieldUnit(eFUnit);
556 SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit);
559 sal_uInt16 const nWhichFL(GetWhich(SID_ATTR_PARA_FIRSTLINESPACE));
560 m_bSplitLRSpace = (nWhichFL != SID_ATTR_PARA_FIRSTLINESPACE);
561 SfxItemState const eItemStateFL(rSet->GetItemState(nWhichFL));
562 sal_uInt16 const nWhichLM(GetWhich(SID_ATTR_PARA_LEFTSPACE));
563 SfxItemState const eItemStateLM(rSet->GetItemState(nWhichLM));
564 sal_uInt16 const nWhichRM(GetWhich(SID_ATTR_PARA_RIGHTSPACE));
565 SfxItemState const eItemStateRM(rSet->GetItemState(nWhichRM));
567 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateLM)
569 const SvxTextLeftMarginItem & rOldLeftMargin(
570 static_cast<const SvxTextLeftMarginItem &>(rSet->Get(nWhichLM)));
572 MapUnit const eUnit = pPool->GetMetric(nWhichLM);
574 if (bRelativeMode)
576 if (rOldLeftMargin.GetPropLeft() != 100)
578 m_aLeftIndent.SetRelative( true );
579 m_aLeftIndent.set_value(rOldLeftMargin.GetPropLeft(), FieldUnit::NONE);
581 else
583 m_aLeftIndent.SetRelative(false);
584 m_aLeftIndent.SetFieldUnit(eFUnit);
585 m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit);
588 else
590 m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit);
593 else if (m_bSplitLRSpace)
595 m_aLeftIndent.set_text(OUString());
598 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateRM)
600 const SvxRightMarginItem & rOldRightMargin(
601 static_cast<const SvxRightMarginItem &>(rSet->Get(nWhichRM)));
603 MapUnit const eUnit = pPool->GetMetric(nWhichRM);
605 if (bRelativeMode)
607 if (rOldRightMargin.GetPropRight() != 100)
609 m_aRightIndent.SetRelative( true );
610 m_aRightIndent.set_value(rOldRightMargin.GetPropRight(), FieldUnit::NONE);
612 else
614 m_aRightIndent.SetRelative(false);
615 m_aRightIndent.SetFieldUnit(eFUnit);
616 m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit);
619 else
621 m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit);
624 else if (m_bSplitLRSpace)
626 m_aRightIndent.set_text(OUString());
629 if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateFL)
631 const SvxFirstLineIndentItem & rOldFirstLine(
632 static_cast<const SvxFirstLineIndentItem &>(rSet->Get(nWhichFL)));
634 MapUnit const eUnit = pPool->GetMetric(nWhichFL);
636 if (bRelativeMode)
638 if (rOldFirstLine.GetPropTextFirstLineOffset() != 100)
640 m_aFLineIndent.SetRelative(true);
641 m_aFLineIndent.set_value(rOldFirstLine.GetPropTextFirstLineOffset(), FieldUnit::NONE);
643 else
645 m_aFLineIndent.SetRelative(false);
646 m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
647 m_aFLineIndent.SetFieldUnit(eFUnit);
648 m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit);
650 m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
652 else
654 m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit);
655 m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
657 AutoHdl_Impl(*m_xAutoCB);
659 else if (m_bSplitLRSpace)
661 m_aFLineIndent.set_text(OUString());
664 sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
665 SfxItemState eItemState = rSet->GetItemState( _nWhich );
667 if (!m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemState)
669 MapUnit eUnit = pPool->GetMetric( _nWhich );
671 if ( bRelativeMode )
673 const SvxLRSpaceItem& rOldItem =
674 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
676 if ( rOldItem.GetPropLeft() != 100 )
678 m_aLeftIndent.SetRelative( true );
679 m_aLeftIndent.set_value(rOldItem.GetPropLeft(), FieldUnit::NONE);
681 else
683 m_aLeftIndent.SetRelative(false);
684 m_aLeftIndent.SetFieldUnit(eFUnit);
685 m_aLeftIndent.SetMetricValue(rOldItem.GetTextLeft(), eUnit);
688 if ( rOldItem.GetPropRight() != 100 )
690 m_aRightIndent.SetRelative( true );
691 m_aRightIndent.set_value(rOldItem.GetPropRight(), FieldUnit::NONE);
693 else
695 m_aRightIndent.SetRelative(false);
696 m_aRightIndent.SetFieldUnit(eFUnit);
697 m_aRightIndent.SetMetricValue(rOldItem.GetRight(), eUnit);
700 if ( rOldItem.GetPropTextFirstLineOffset() != 100 )
702 m_aFLineIndent.SetRelative(true);
703 m_aFLineIndent.set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE);
705 else
707 m_aFLineIndent.SetRelative(false);
708 m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
709 m_aFLineIndent.SetFieldUnit(eFUnit);
710 m_aFLineIndent.SetMetricValue(rOldItem.GetTextFirstLineOffset(), eUnit);
712 m_xAutoCB->set_active(rOldItem.IsAutoFirst());
714 else
716 const SvxLRSpaceItem& rSpace =
717 static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));
719 m_aLeftIndent.SetMetricValue(rSpace.GetTextLeft(), eUnit);
720 m_aRightIndent.SetMetricValue(rSpace.GetRight(), eUnit);
721 m_aFLineIndent.SetMetricValue(rSpace.GetTextFirstLineOffset(), eUnit);
722 m_xAutoCB->set_active(rSpace.IsAutoFirst());
724 AutoHdl_Impl(*m_xAutoCB);
726 else if (!m_bSplitLRSpace)
728 m_aLeftIndent.set_text(OUString());
729 m_aRightIndent.set_text(OUString());
730 m_aFLineIndent.set_text(OUString());
733 _nWhich = GetWhich( SID_ATTR_ULSPACE );
734 eItemState = rSet->GetItemState( _nWhich );
736 if ( eItemState >= SfxItemState::DEFAULT )
738 MapUnit eUnit = pPool->GetMetric( _nWhich );
740 const SvxULSpaceItem& rOldItem =
741 static_cast<const SvxULSpaceItem&>(rSet->Get( _nWhich ));
742 if ( bRelativeMode )
745 if ( rOldItem.GetPropUpper() != 100 )
747 m_aTopDist.SetRelative( true );
748 m_aTopDist.set_value(rOldItem.GetPropUpper(), FieldUnit::NONE);
750 else
752 m_aTopDist.SetRelative(false);
753 if (eFUnit == FieldUnit::CHAR)
754 m_aTopDist.SetFieldUnit(FieldUnit::LINE);
755 else
756 m_aTopDist.SetFieldUnit(eFUnit);
757 m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
760 if ( rOldItem.GetPropLower() != 100 )
762 m_aBottomDist.SetRelative( true );
763 m_aBottomDist.set_value(rOldItem.GetPropLower(), FieldUnit::NONE);
765 else
767 m_aBottomDist.SetRelative(false);
768 if (eFUnit == FieldUnit::CHAR)
769 m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
770 else
771 m_aBottomDist.SetFieldUnit(eFUnit);
772 m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
775 else
777 m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
778 m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
780 m_xContextualCB->set_active(rOldItem.GetContext());
782 else
784 m_aTopDist.set_text(OUString());
785 m_aBottomDist.set_text(OUString());
788 _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
789 eItemState = rSet->GetItemState( _nWhich );
791 if ( eItemState >= SfxItemState::DEFAULT )
792 SetLineSpacing_Impl( static_cast<const SvxLineSpacingItem &>(rSet->Get( _nWhich )) );
793 else
794 m_xLineDist->set_active(-1);
796 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
797 eItemState = rSet->GetItemState( _nWhich );
799 if ( eItemState >= SfxItemState::DEFAULT )
800 m_xRegisterCB->set_active( static_cast<const SfxBoolItem &>(rSet->Get( _nWhich )).GetValue());
801 m_xRegisterCB->save_state();
802 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
803 if(nHtmlMode & HTMLMODE_ON)
805 m_xRegisterCB->hide();
806 m_xAutoCB->hide();
809 // this sets the min/max limits; do this _after_ setting the values,
810 // because for Impress the min of first-line indent depends on value of
811 // left-indent!
812 ELRLoseFocus();
813 ChangesApplied();
816 void SvxStdParagraphTabPage::ChangesApplied()
818 m_aLeftIndent.save_value();
819 m_aRightIndent.save_value();
820 m_aFLineIndent.save_value();
821 m_xLineDist->save_value();
822 m_xLineDistAtPercentBox->save_value();
823 m_xLineDistAtMetricBox->save_value();
824 m_xRegisterCB->save_state();
825 m_aTopDist.save_value();
826 m_aBottomDist.save_value();
827 m_xContextualCB->save_state();
828 m_xAutoCB->save_state();
831 void SvxStdParagraphTabPage::EnableRelativeMode()
833 DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );
835 m_aLeftIndent.EnableRelativeMode( 0, 999 );
836 m_aFLineIndent.EnableRelativeMode( 0, 999 );
837 m_aRightIndent.EnableRelativeMode( 0, 999 );
838 m_aTopDist.EnableRelativeMode( 0, 999 );
839 m_aBottomDist.EnableRelativeMode( 0, 999 );
840 bRelativeMode = true;
843 void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet )
845 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
846 SfxItemState eItemState = rSet.GetItemState( _nWhich );
848 if ( eItemState < SfxItemState::DEFAULT )
849 return;
851 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>( rSet.Get( _nWhich ) );
852 SvxAdjust eAdjust = rAdj.GetAdjust();
853 if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block )
855 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
856 eItemState = rSet.GetItemState( _nWhich );
858 if ( eItemState >= SfxItemState::DEFAULT )
860 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet.Get( _nWhich ) );
861 SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue();
863 m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection );
865 if ( eAdjust == SvxAdjust::Block )
866 m_aExampleWin.SetLastLine( rAdj.GetLastBlock() );
869 else
871 m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right );
872 eAdjust = SvxAdjust::Left; //required for correct preview display
873 m_aExampleWin.SetLastLine( eAdjust );
875 m_aExampleWin.SetAdjust( eAdjust );
877 UpdateExample_Impl();
880 DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
882 ELRLoseFocus();
884 if ( _pSet )
885 FillItemSet( _pSet );
886 return DeactivateRC::LeavePage;
889 SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
890 : SfxTabPage(pPage, pController, "cui/ui/paraindentspacing.ui", "ParaIndentSpacing", &rAttr)
891 , nWidth(11905 /*567 * 50*/)
892 , nMinFixDist(0)
893 , bRelativeMode(false)
894 , m_aLeftIndent(m_xBuilder->weld_metric_spin_button("spinED_LEFTINDENT", FieldUnit::CM))
895 , m_aRightIndent(m_xBuilder->weld_metric_spin_button("spinED_RIGHTINDENT", FieldUnit::CM))
896 , m_xFLineLabel(m_xBuilder->weld_label("labelFT_FLINEINDENT"))
897 , m_aFLineIndent(m_xBuilder->weld_metric_spin_button("spinED_FLINEINDENT", FieldUnit::CM))
898 , m_xAutoCB(m_xBuilder->weld_check_button("checkCB_AUTO"))
899 , m_aTopDist(m_xBuilder->weld_metric_spin_button("spinED_TOPDIST", FieldUnit::CM))
900 , m_aBottomDist(m_xBuilder->weld_metric_spin_button("spinED_BOTTOMDIST", FieldUnit::CM))
901 , m_xContextualCB(m_xBuilder->weld_check_button("checkCB_CONTEXTUALSPACING"))
902 , m_xLineDist(m_xBuilder->weld_combo_box("comboLB_LINEDIST"))
903 , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTPERCENT", FieldUnit::PERCENT))
904 , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTMETRIC", FieldUnit::CM))
905 , m_xLineDistAtPlaceHolderBox(m_xBuilder->weld_metric_spin_button("spinED_BLANK", FieldUnit::CM))
906 , m_xLineDistAtLabel(m_xBuilder->weld_label("labelFT_LINEDIST"))
907 , m_xAbsDist(m_xBuilder->weld_label("labelST_LINEDIST_ABS"))
908 , m_xRegisterCB(m_xBuilder->weld_check_button("checkCB_REGISTER"))
909 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin))
911 sAbsDist = m_xAbsDist->get_label();
913 // this page needs ExchangeSupport
914 SetExchangeSupport();
916 m_xLineDistAtMetricBox->hide();
917 m_xLineDistAtPlaceHolderBox->hide();
918 m_xLineDistAtPlaceHolderBox->set_text(OUString());
920 Init_Impl();
921 m_aFLineIndent.set_min(-9999, FieldUnit::NONE); // is set to 0 on default
924 SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
928 void SvxStdParagraphTabPage::EnableNegativeMode()
930 m_aLeftIndent.set_min(-9999, FieldUnit::NONE);
931 m_aRightIndent.set_min(-9999, FieldUnit::NONE);
932 m_aRightIndent.EnableNegativeMode();
933 m_aLeftIndent.EnableNegativeMode();
936 void SvxStdParagraphTabPage::SetLineSpacing_Impl
938 const SvxLineSpacingItem &rAttr
941 MapUnit eUnit = GetItemSet().GetPool()->GetMetric( rAttr.Which() );
943 switch( rAttr.GetLineSpaceRule() )
945 case SvxLineSpaceRule::Auto:
947 SvxInterLineSpaceRule eInter = rAttr.GetInterLineSpaceRule();
949 switch( eInter )
951 // Default single line spacing
952 case SvxInterLineSpaceRule::Off:
953 m_xLineDist->set_active( LLINESPACE_1 );
954 break;
956 // Default single line spacing
957 case SvxInterLineSpaceRule::Prop:
958 if ( 100 == rAttr.GetPropLineSpace() )
960 m_xLineDist->set_active( LLINESPACE_1 );
961 break;
963 // 1.15 line spacing
964 if ( 115 == rAttr.GetPropLineSpace() )
966 m_xLineDist->set_active( LLINESPACE_115 );
967 break;
969 // 1.5 line spacing
970 if ( 150 == rAttr.GetPropLineSpace() )
972 m_xLineDist->set_active( LLINESPACE_15 );
973 break;
975 // double line spacing
976 if ( 200 == rAttr.GetPropLineSpace() )
978 m_xLineDist->set_active( LLINESPACE_2 );
979 break;
981 // the set per cent value
982 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(rAttr.GetPropLineSpace()), FieldUnit::NONE);
983 m_xLineDist->set_active( LLINESPACE_PROP );
984 break;
986 case SvxInterLineSpaceRule::Fix:
987 SetMetricValue( *m_xLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
988 m_xLineDist->set_active( LLINESPACE_DURCH );
989 break;
990 default: ;//prevent warning
993 break;
994 case SvxLineSpaceRule::Fix:
995 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
996 m_xLineDist->set_active( LLINESPACE_FIX );
997 break;
999 case SvxLineSpaceRule::Min:
1000 SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
1001 m_xLineDist->set_active( LLINESPACE_MIN );
1002 break;
1003 default: ;//prevent warning
1005 LineDistHdl_Impl( *m_xLineDist );
1008 IMPL_LINK_NOARG(SvxStdParagraphTabPage, LineDistPopupHdl_Impl, weld::ComboBox&, void)
1010 m_bLineDistToggled = true;
1013 IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void)
1015 switch (rBox.get_active())
1017 case LLINESPACE_1:
1018 case LLINESPACE_115:
1019 case LLINESPACE_15:
1020 case LLINESPACE_2:
1021 m_xLineDistAtLabel->set_sensitive(false);
1022 m_xLineDistAtPercentBox->hide();
1023 m_xLineDistAtMetricBox->hide();
1024 m_xLineDistAtPlaceHolderBox->show();
1025 break;
1027 case LLINESPACE_DURCH:
1028 // setting a sensible default?
1029 // limit MS min(10, aPageSize)
1030 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
1032 if (m_xLineDistAtPlaceHolderBox->get_visible())
1033 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE);
1034 m_xLineDistAtPlaceHolderBox->hide();
1035 m_xLineDistAtPercentBox->hide();
1036 m_xLineDistAtMetricBox->show();
1037 m_xLineDistAtLabel->set_sensitive(true);
1038 break;
1040 case LLINESPACE_MIN:
1041 m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);
1043 if (m_xLineDistAtPlaceHolderBox->get_visible())
1044 m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP);
1045 m_xLineDistAtPlaceHolderBox->hide();
1046 m_xLineDistAtPercentBox->hide();
1047 m_xLineDistAtMetricBox->show();
1048 m_xLineDistAtLabel->set_sensitive(true);
1049 break;
1051 case LLINESPACE_PROP:
1053 if (m_xLineDistAtPlaceHolderBox->get_visible())
1054 m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP);
1055 m_xLineDistAtPlaceHolderBox->hide();
1056 m_xLineDistAtMetricBox->hide();
1057 m_xLineDistAtPercentBox->show();
1058 m_xLineDistAtLabel->set_sensitive(true);
1059 break;
1060 case LLINESPACE_FIX:
1062 auto nTemp = m_xLineDistAtMetricBox->get_value(FieldUnit::NONE);
1063 m_xLineDistAtMetricBox->set_min(m_xLineDistAtMetricBox->normalize(nMinFixDist), FieldUnit::TWIP);
1065 // if the value has been changed at SetMin,
1066 // it is time for the default
1067 if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp)
1068 SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer
1069 m_xLineDistAtPlaceHolderBox->hide();
1070 m_xLineDistAtPercentBox->hide();
1071 m_xLineDistAtMetricBox->show();
1072 m_xLineDistAtLabel->set_sensitive(true);
1074 break;
1076 UpdateExample_Impl();
1079 IMPL_LINK_NOARG(SvxStdParagraphTabPage, ModifyHdl_Impl, weld::MetricSpinButton&, void)
1081 UpdateExample_Impl();
1084 void SvxStdParagraphTabPage::Init_Impl()
1086 m_xLineDist->connect_popup_toggled(LINK(this, SvxStdParagraphTabPage, LineDistPopupHdl_Impl));
1087 m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl));
1089 Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl);
1090 m_aFLineIndent.connect_value_changed(aLink2);
1091 m_aLeftIndent.connect_value_changed(aLink2);
1092 m_aRightIndent.connect_value_changed(aLink2);
1094 Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl);
1095 m_aTopDist.connect_value_changed(aLink);
1096 m_aBottomDist.connect_value_changed(aLink);
1098 m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl));
1099 SfxItemPool* pPool = GetItemSet().GetPool();
1100 DBG_ASSERT( pPool, "Where is the pool?" );
1101 FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
1103 m_aTopDist.set_max( m_aTopDist.normalize( MAX_DURCH ), eUnit );
1104 m_aBottomDist.set_max( m_aBottomDist.normalize( MAX_DURCH ), eUnit );
1105 m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit );
1108 void SvxStdParagraphTabPage::UpdateExample_Impl()
1110 m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_aFLineIndent.denormalize( m_aFLineIndent.get_value( FieldUnit::TWIP ) )) );
1111 m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_aLeftIndent.denormalize( m_aLeftIndent.get_value( FieldUnit::TWIP ) ) ) );
1112 m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_aRightIndent.denormalize( m_aRightIndent.get_value( FieldUnit::TWIP ) ) ) );
1113 m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.denormalize( m_aTopDist.get_value( FieldUnit::TWIP ) )) );
1114 m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.denormalize( m_aBottomDist.get_value( FieldUnit::TWIP ) )) );
1116 int nPos = m_xLineDist->get_active();
1118 switch ( nPos )
1120 case LLINESPACE_1:
1121 case LLINESPACE_115:
1122 case LLINESPACE_15:
1123 case LLINESPACE_2:
1124 case LLINESPACE_PROP:
1125 case LLINESPACE_MIN:
1126 case LLINESPACE_DURCH:
1127 case LLINESPACE_FIX:
1128 m_aExampleWin.SetLineSpace( static_cast<SvxPrevLineSpace>(nPos) );
1129 break;
1131 m_aExampleWin.Invalidate();
1134 void SvxStdParagraphTabPage::EnableRegisterMode()
1136 m_xRegisterCB->show();
1139 void SvxStdParagraphTabPage::EnableContextualMode()
1141 m_xContextualCB->show();
1144 IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::Toggleable&, rBox, void)
1146 bool bEnable = !rBox.get_active();
1147 m_xFLineLabel->set_sensitive(bEnable);
1148 m_aFLineIndent.set_sensitive(bEnable);
1151 void SvxStdParagraphTabPage::EnableAutoFirstLine()
1153 m_xAutoCB->show();
1156 void SvxStdParagraphTabPage::EnableAbsLineDist(tools::Long nMinTwip)
1158 m_xLineDist->append_text(sAbsDist);
1159 nMinFixDist = nMinTwip;
1162 void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
1165 /* different bit represent call to different method of SvxStdParagraphTabPage
1166 0x0001 --->EnableRelativeMode()
1167 0x0002 --->EnableRegisterMode()
1168 0x0004 --->EnableAutoFirstLine()
1169 0x0008 --->EnableNegativeMode()
1170 0x0010 --->EnableContextualMode()
1172 const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false);
1173 const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false);
1174 const SfxUInt32Item* pLineDistItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, false);
1176 if (pPageWidthItem)
1177 nWidth = pPageWidthItem->GetValue();
1179 if (pFlagSetItem )
1181 if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
1182 EnableRelativeMode();
1184 if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
1185 EnableRegisterMode();
1187 if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
1188 EnableAutoFirstLine();
1191 if(pLineDistItem)
1192 EnableAbsLineDist(pLineDistItem->GetValue());
1194 if (pFlagSetItem)
1196 if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
1197 EnableNegativeMode();
1199 if (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
1200 EnableContextualMode();
1204 #define LASTLINEPOS_DEFAULT 0
1205 #define LASTLINEPOS_LEFT 1
1207 #define LASTLINECOUNT_OLD 3
1208 #define LASTLINECOUNT_NEW 4
1210 SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
1211 : SfxTabPage(pPage, pController, "cui/ui/paragalignpage.ui", "ParaAlignPage", &rSet)
1212 , m_bSdrVertAlign(false)
1213 , m_xLeft(m_xBuilder->weld_radio_button("radioBTN_LEFTALIGN"))
1214 , m_xRight(m_xBuilder->weld_radio_button("radioBTN_RIGHTALIGN"))
1215 , m_xCenter(m_xBuilder->weld_radio_button("radioBTN_CENTERALIGN"))
1216 , m_xJustify(m_xBuilder->weld_radio_button("radioBTN_JUSTIFYALIGN"))
1217 , m_xLeftBottom(m_xBuilder->weld_label("labelST_LEFTALIGN_ASIAN"))
1218 , m_xRightTop(m_xBuilder->weld_label("labelST_RIGHTALIGN_ASIAN"))
1219 , m_xLastLineFT(m_xBuilder->weld_label("labelLB_LASTLINE"))
1220 , m_xLastLineLB(m_xBuilder->weld_combo_box("comboLB_LASTLINE"))
1221 , m_xExpandCB(m_xBuilder->weld_check_button("checkCB_EXPAND"))
1222 , m_xSnapToGridCB(m_xBuilder->weld_check_button("checkCB_SNAP"))
1223 , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin))
1224 , m_xVertAlignFL(m_xBuilder->weld_widget("frameFL_VERTALIGN"))
1225 , m_xVertAlignLB(m_xBuilder->weld_combo_box("comboLB_VERTALIGN"))
1226 , m_xVertAlign(m_xBuilder->weld_label("labelFL_VERTALIGN"))
1227 , m_xVertAlignSdr(m_xBuilder->weld_label("labelST_VERTALIGN_SDR"))
1228 , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboLB_TEXTDIRECTION")))
1230 SetExchangeSupport();
1232 sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;
1234 if ( SvtCJKOptions::IsAsianTypographyEnabled() )
1236 m_xLeft->set_label(m_xLeftBottom->get_label());
1237 m_xRight->set_label(m_xRightTop->get_label());
1239 OUString sLeft(m_xLeft->get_label());
1240 sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );
1242 if (m_xLastLineLB->get_count() == LASTLINECOUNT_OLD)
1244 m_xLastLineLB->remove(0);
1245 m_xLastLineLB->insert_text(0, sLeft);
1247 else
1248 nLastLinePos = LASTLINEPOS_LEFT;
1251 // remove "Default" or "Left" entry, depends on CJKOptions
1252 if (m_xLastLineLB->get_count() == LASTLINECOUNT_NEW)
1253 m_xLastLineLB->remove(nLastLinePos);
1255 Link<weld::Toggleable&, void> aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
1256 m_xLeft->connect_toggled(aLink);
1257 m_xRight->connect_toggled(aLink);
1258 m_xCenter->connect_toggled(aLink);
1259 m_xJustify->connect_toggled(aLink);
1260 m_xLastLineLB->connect_changed(LINK(this, SvxParaAlignTabPage, LastLineHdl_Impl));
1261 m_xTextDirectionLB->connect_changed(LINK(this, SvxParaAlignTabPage, TextDirectionHdl_Impl));
1263 m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
1264 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
1265 m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));
1268 SvxParaAlignTabPage::~SvxParaAlignTabPage()
1272 DeactivateRC SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
1274 if ( _pSet )
1275 FillItemSet( _pSet );
1276 return DeactivateRC::LeavePage;
1279 std::unique_ptr<SfxTabPage> SvxParaAlignTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1281 return std::make_unique<SvxParaAlignTabPage>(pPage, pController, *rSet);
1284 bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet )
1286 bool bModified = false;
1288 bool bAdj = false;
1289 SvxAdjust eAdjust = SvxAdjust::Left;
1291 if (m_xLeft->get_active())
1293 eAdjust = SvxAdjust::Left;
1294 bAdj = m_xLeft->get_saved_state() == TRISTATE_FALSE;
1296 else if (m_xRight->get_active())
1298 eAdjust = SvxAdjust::Right;
1299 bAdj = m_xRight->get_saved_state() == TRISTATE_FALSE;
1301 else if (m_xCenter->get_active())
1303 eAdjust = SvxAdjust::Center;
1304 bAdj = m_xCenter->get_saved_state() == TRISTATE_FALSE;
1306 else if (m_xJustify->get_active())
1308 eAdjust = SvxAdjust::Block;
1309 bAdj = m_xJustify->get_saved_state() == TRISTATE_FALSE ||
1310 m_xExpandCB->get_state_changed_from_saved() ||
1311 m_xLastLineLB->get_value_changed_from_saved();
1314 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1316 if (bAdj)
1318 SvxAdjust eOneWord = m_xExpandCB->get_active() ? SvxAdjust::Block : SvxAdjust::Left;
1320 int nLBPos = m_xLastLineLB->get_active();
1321 SvxAdjust eLastBlock = SvxAdjust::Left;
1322 if ( 1 == nLBPos )
1323 eLastBlock = SvxAdjust::Center;
1324 else if ( 2 == nLBPos )
1325 eLastBlock = SvxAdjust::Block;
1327 SvxAdjustItem aAdj( static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) );
1328 aAdj.SetAdjust( eAdjust );
1329 aAdj.SetOneWord( eOneWord );
1330 aAdj.SetLastBlock( eLastBlock );
1331 rOutSet->Put( aAdj );
1332 bModified = true;
1335 if (m_xSnapToGridCB->get_state_changed_from_saved())
1337 rOutSet->Put(SvxParaGridItem(m_xSnapToGridCB->get_active(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
1338 bModified = true;
1341 if (m_xVertAlignLB->get_value_changed_from_saved())
1343 if (m_bSdrVertAlign)
1344 rOutSet->Put(SdrTextVertAdjustItem(static_cast<SdrTextVertAdjust>(m_xVertAlignLB->get_active())));
1345 else
1346 rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN )));
1347 bModified = true;
1350 if (m_xTextDirectionLB->get_visible())
1352 if (m_xTextDirectionLB->get_value_changed_from_saved())
1354 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1355 rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
1356 bModified = true;
1360 return bModified;
1363 void SvxParaAlignTabPage::ActivatePage( const SfxItemSet& rSet )
1365 Reset( &rSet );
1368 void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet )
1370 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1371 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1373 sal_Int32 nLBSelect = 0;
1374 if ( eItemState >= SfxItemState::DEFAULT )
1376 const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>(rSet->Get( _nWhich ));
1378 switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
1380 case SvxAdjust::Left: m_xLeft->set_active(true); break;
1382 case SvxAdjust::Right: m_xRight->set_active(true); break;
1384 case SvxAdjust::Center: m_xCenter->set_active(true); break;
1386 case SvxAdjust::Block: m_xJustify->set_active(true); break;
1387 default: ; //prevent warning
1389 bool bEnable = m_xJustify->get_active();
1390 m_xLastLineFT->set_sensitive(bEnable);
1391 m_xLastLineLB->set_sensitive(bEnable);
1393 switch(rAdj.GetLastBlock())
1395 case SvxAdjust::Left: nLBSelect = 0; break;
1397 case SvxAdjust::Center: nLBSelect = 1; break;
1399 case SvxAdjust::Block: nLBSelect = 2; break;
1400 default: ; //prevent warning
1402 m_xExpandCB->set_sensitive(bEnable && nLBSelect == 2);
1403 m_xExpandCB->set_active(SvxAdjust::Block == rAdj.GetOneWord());
1405 else
1407 m_xLeft->set_active(false);
1408 m_xRight->set_active(false);
1409 m_xCenter->set_active(false);
1410 m_xJustify->set_active(false);
1412 m_xLastLineLB->set_active(nLBSelect);
1414 sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
1415 if(nHtmlMode & HTMLMODE_ON)
1417 m_xLastLineLB->hide();
1418 m_xLastLineFT->hide();
1419 m_xExpandCB->hide();
1420 if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
1421 m_xJustify->set_sensitive(false);
1422 m_xSnapToGridCB->hide();
1424 _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
1425 eItemState = rSet->GetItemState( _nWhich );
1426 if ( eItemState >= SfxItemState::DEFAULT )
1428 const SvxParaGridItem& rSnap = static_cast<const SvxParaGridItem&>(rSet->Get( _nWhich ));
1429 m_xSnapToGridCB->set_active(rSnap.GetValue());
1432 _nWhich = m_bSdrVertAlign ? SDRATTR_TEXT_VERTADJUST : GetWhich( SID_PARA_VERTALIGN );
1433 eItemState = rSet->GetItemState( _nWhich );
1435 if ( eItemState >= SfxItemState::DEFAULT )
1437 m_xVertAlignFL->show();
1439 if (m_bSdrVertAlign)
1441 const SdrTextVertAdjustItem& rAlign = static_cast<const SdrTextVertAdjustItem&>(rSet->Get( _nWhich ));
1442 m_xVertAlignLB->set_active(rAlign.GetValue());
1444 else
1446 const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich ));
1447 m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue()));
1451 _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
1452 //text direction
1453 if( SfxItemState::DEFAULT <= rSet->GetItemState( _nWhich ) )
1455 const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet->Get( _nWhich ) );
1456 m_xTextDirectionLB->set_active_id(rFrameDirItem.GetValue());
1457 m_xTextDirectionLB->save_value();
1460 m_xSnapToGridCB->save_state();
1461 m_xVertAlignLB->save_value();
1462 m_xLeft->save_state();
1463 m_xRight->save_state();
1464 m_xCenter->save_state();
1465 m_xJustify->save_state();
1466 m_xLastLineLB->save_value();
1467 m_xExpandCB->save_state();
1469 UpdateExample_Impl();
1472 void SvxParaAlignTabPage::ChangesApplied()
1474 m_xTextDirectionLB->save_value();
1475 m_xSnapToGridCB->save_state();
1476 m_xVertAlignLB->save_value();
1477 m_xLeft->save_state();
1478 m_xRight->save_state();
1479 m_xCenter->save_state();
1480 m_xJustify->save_state();
1481 m_xLastLineLB->save_value();
1482 m_xExpandCB->save_state();
1485 IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl, weld::Toggleable&, void)
1487 bool bJustify = m_xJustify->get_active();
1488 m_xLastLineFT->set_sensitive(bJustify);
1489 m_xLastLineLB->set_sensitive(bJustify);
1490 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1491 m_xExpandCB->set_sensitive(bJustify && bLastLineIsBlock);
1492 //set last line listbox to entry position 0 if not enabled
1493 if (!m_xLastLineLB->get_sensitive())
1494 m_xLastLineLB->set_active(0);
1495 //uncheck 'Expand ... word' when check box is not enabled
1496 if (!m_xExpandCB->get_sensitive())
1497 m_xExpandCB->set_active(false);
1498 UpdateExample_Impl();
1501 IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl, weld::ComboBox&, void)
1503 //fdo#41350 only enable 'Expand last word' if last line is also justified
1504 bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
1505 m_xExpandCB->set_sensitive(bLastLineIsBlock);
1506 //uncheck 'Expand ... word' when check box is not enabled
1507 if (!m_xExpandCB->get_sensitive())
1508 m_xExpandCB->set_active(false);
1509 UpdateExample_Impl();
1512 IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl, weld::ComboBox&, void)
1514 UpdateExample_Impl();
1517 void SvxParaAlignTabPage::UpdateExample_Impl()
1519 if (m_xLeft->get_active())
1521 m_aExampleWin.EnableRTL(false);
1522 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1523 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1525 else if (m_xRight->get_active())
1527 m_aExampleWin.EnableRTL(true);
1528 m_aExampleWin.SetAdjust(SvxAdjust::Left);
1529 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1531 else
1533 SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
1534 switch ( eDir )
1536 case SvxFrameDirection::Environment :
1537 if ( !m_xRight->get_active() )
1538 m_aExampleWin.EnableRTL( AllSettings::GetLayoutRTL() );
1539 break;
1540 case SvxFrameDirection::Horizontal_RL_TB :
1541 if ( !m_xLeft->get_active() )
1542 m_aExampleWin.EnableRTL( true );
1543 break;
1544 case SvxFrameDirection::Horizontal_LR_TB :
1545 if ( !m_xRight->get_active() )
1546 m_aExampleWin.EnableRTL( false );
1547 break;
1548 default: ; //prevent warning
1550 if (m_xCenter->get_active())
1551 m_aExampleWin.SetAdjust( SvxAdjust::Center );
1552 else if (m_xJustify->get_active())
1554 m_aExampleWin.SetAdjust( SvxAdjust::Block );
1555 int nLBPos = m_xLastLineLB->get_active();
1556 if (nLBPos == 0)
1557 m_aExampleWin.SetLastLine(SvxAdjust::Left);
1558 else if (nLBPos == 1)
1559 m_aExampleWin.SetLastLine(SvxAdjust::Center);
1560 else if (nLBPos == 2)
1561 m_aExampleWin.SetLastLine(SvxAdjust::Block);
1565 m_aExampleWin.Invalidate();
1568 void SvxParaAlignTabPage::EnableJustifyExt()
1570 m_xLastLineFT->show();
1571 m_xLastLineLB->show();
1572 m_xExpandCB->show();
1573 if (SvtCJKOptions::IsAsianTypographyEnabled())
1574 m_xSnapToGridCB->show();
1578 void SvxParaAlignTabPage::EnableSdrVertAlign()
1580 m_bSdrVertAlign = true;
1582 m_xVertAlignLB->remove_id("0");
1583 m_xVertAlignLB->remove_id("1");
1584 m_xVertAlign->set_label(m_xVertAlignSdr->get_label());
1587 void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet)
1589 const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false);
1590 if (pBoolItem && pBoolItem->GetValue())
1591 EnableJustifyExt();
1594 std::unique_ptr<SfxTabPage> SvxExtParagraphTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1596 return std::make_unique<SvxExtParagraphTabPage>(pPage, pController, *rSet);
1599 bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
1601 bool bModified = false;
1602 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1603 const TriState eHyphenState = m_xHyphenBox->get_state();
1604 const SfxPoolItem* pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_HYPHENZONE );
1606 if ( m_xHyphenBox->get_state_changed_from_saved() ||
1607 m_xHyphenNoCapsBox->get_state_changed_from_saved() ||
1608 m_xHyphenNoLastWordBox->get_state_changed_from_saved() ||
1609 m_xExtHyphenBeforeBox->get_value_changed_from_saved() ||
1610 m_xExtHyphenAfterBox->get_value_changed_from_saved() ||
1611 m_xMaxHyphenEdit->get_value_changed_from_saved() ||
1612 m_xMinWordLength->get_value_changed_from_saved() ||
1613 m_aHyphenZone.get_value_changed_from_saved() )
1615 SvxHyphenZoneItem aHyphen(
1616 static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) );
1617 aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE );
1618 aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() == TRISTATE_TRUE);
1619 aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() == TRISTATE_TRUE);
1621 if ( eHyphenState == TRISTATE_TRUE )
1623 aHyphen.GetMinLead() = static_cast<sal_uInt8>(m_xExtHyphenBeforeBox->get_value());
1624 aHyphen.GetMinTrail() = static_cast<sal_uInt8>(m_xExtHyphenAfterBox->get_value());
1625 aHyphen.GetMinWordLength() = static_cast<sal_uInt8>(m_xMinWordLength->get_value());
1627 aHyphen.GetMaxHyphens() = static_cast<sal_uInt8>(m_xMaxHyphenEdit->get_value());
1629 SfxItemPool* pPool = GetItemSet().GetPool();
1630 DBG_ASSERT( pPool, "Where is the pool?" );
1631 MapUnit eUnit = pPool->GetMetric( _nWhich );
1632 aHyphen.GetTextHyphenZone() = static_cast<sal_uInt16>(m_aHyphenZone.GetCoreValue(eUnit));
1634 if ( !pOld ||
1635 *static_cast<const SvxHyphenZoneItem*>(pOld) != aHyphen ||
1636 m_xHyphenBox->get_state_changed_from_saved())
1638 rOutSet->Put( aHyphen );
1639 bModified = true;
1643 if (m_xPageNumBox->get_sensitive()
1644 && (m_xPageNumBox->get_state_changed_from_saved() || m_xPagenumEdit->get_value_changed_from_saved()))
1646 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
1648 if (TRISTATE_TRUE == m_xPageNumBox->get_state()
1649 && (!pOld || IsInvalidItem(pOld)
1650 || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != m_xPagenumEdit->get_value()))
1652 SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM,
1653 static_cast<sal_uInt16>(m_xPagenumEdit->get_value()));
1654 rOutSet->Put( aPageNum );
1655 bModified = true;
1657 else if (TRISTATE_FALSE == m_xPageNumBox->get_state()
1658 && (pOld || IsInvalidItem(pOld)))
1660 // need to tell sw to remove the item
1661 rOutSet->DisableItem(SID_ATTR_PARA_PAGENUM);
1662 bModified = true;
1666 // pagebreak
1668 TriState eState = m_xApplyCollBtn->get_state();
1669 bool bIsPageModel = false;
1671 OUString sPage;
1672 if ( m_xApplyCollBtn->get_state_changed_from_saved() ||
1673 ( TRISTATE_TRUE == eState &&
1674 m_xApplyCollBox->get_value_changed_from_saved() ) )
1676 if ( eState == TRISTATE_TRUE )
1678 sPage = m_xApplyCollBox->get_active_text();
1679 bIsPageModel = !sPage.isEmpty();
1681 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_MODEL );
1683 if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage )
1685 rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) );
1686 bModified = true;
1688 else
1689 bIsPageModel = false;
1691 else if(TRISTATE_TRUE == eState && m_xApplyCollBtn->get_sensitive())
1692 bIsPageModel = true;
1693 else
1694 rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) );
1696 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1698 if ( bIsPageModel )
1699 // if PageModel is turned on, always turn off PageBreak
1700 rOutSet->Put( SvxFormatBreakItem( SvxBreak::NONE, _nWhich ) );
1701 else
1703 eState = m_xPageBreakBox->get_state();
1704 SfxItemState eModelState = GetItemSet().GetItemState(SID_ATTR_PARA_MODEL, false);
1706 if ( (eModelState == SfxItemState::SET && TRISTATE_TRUE == m_xPageBreakBox->get_state()) ||
1707 m_xPageBreakBox->get_state_changed_from_saved() ||
1708 m_xBreakTypeLB->get_value_changed_from_saved() ||
1709 m_xBreakPositionLB->get_value_changed_from_saved() )
1711 const SvxFormatBreakItem rOldBreak(
1712 static_cast<const SvxFormatBreakItem&>(GetItemSet().Get( _nWhich )));
1713 SvxFormatBreakItem aBreak(rOldBreak.GetBreak(), rOldBreak.Which());
1715 switch ( eState )
1717 case TRISTATE_TRUE:
1719 bool bBefore = m_xBreakPositionLB->get_active() == 0;
1721 if (m_xBreakTypeLB->get_active() == 0)
1723 if ( bBefore )
1724 aBreak.SetValue( SvxBreak::PageBefore );
1725 else
1726 aBreak.SetValue( SvxBreak::PageAfter );
1728 else
1730 if ( bBefore )
1731 aBreak.SetValue( SvxBreak::ColumnBefore );
1732 else
1733 aBreak.SetValue( SvxBreak::ColumnAfter );
1735 break;
1738 case TRISTATE_FALSE:
1739 aBreak.SetValue( SvxBreak::NONE );
1740 break;
1741 default: ; //prevent warning
1743 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGEBREAK );
1745 if ( eState != m_xPageBreakBox->get_saved_state() ||
1746 !pOld || !( *static_cast<const SvxFormatBreakItem*>(pOld) == aBreak ) )
1748 bModified = true;
1749 rOutSet->Put( aBreak );
1754 // paragraph split
1755 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1756 eState = m_xKeepTogetherBox->get_state();
1758 if (m_xKeepTogetherBox->get_state_changed_from_saved())
1760 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_SPLIT );
1762 if ( !pOld || static_cast<const SvxFormatSplitItem*>(pOld)->GetValue() !=
1763 ( eState == TRISTATE_FALSE ) )
1765 rOutSet->Put( SvxFormatSplitItem( eState == TRISTATE_FALSE, _nWhich ) );
1766 bModified = true;
1770 // keep paragraphs
1771 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1772 eState = m_xKeepParaBox->get_state();
1774 if (m_xKeepParaBox->get_state_changed_from_saved())
1776 // if the status has changed, putting is necessary
1777 rOutSet->Put( SvxFormatKeepItem( eState == TRISTATE_TRUE, _nWhich ) );
1778 bModified = true;
1781 // widows and orphans
1782 TypedWhichId<SvxWidowsItem> nWidowsWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1783 eState = m_xWidowBox->get_state();
1785 if ( m_xWidowBox->get_state_changed_from_saved() ||
1786 m_xWidowRowNo->get_value_changed_from_saved() )
1788 SvxWidowsItem rItem( eState == TRISTATE_TRUE ?
1789 static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, nWidowsWhich );
1790 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS );
1792 if ( m_xWidowBox->get_state_changed_from_saved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) )
1794 rOutSet->Put( rItem );
1795 bModified = true;
1799 TypedWhichId<SvxOrphansItem> nOrphansWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1800 eState = m_xOrphanBox->get_state();
1802 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1803 m_xOrphanRowNo->get_value_changed_from_saved() )
1805 SvxOrphansItem rItem( eState == TRISTATE_TRUE ?
1806 static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, nOrphansWhich );
1807 pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS );
1809 if ( m_xOrphanBox->get_state_changed_from_saved() ||
1810 !pOld ||
1811 !( *static_cast<const SvxOrphansItem*>(pOld) == rItem ) )
1813 rOutSet->Put( rItem );
1814 bModified = true;
1818 return bModified;
1820 void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
1822 SfxItemPool* pPool = rSet->GetPool();
1823 DBG_ASSERT( pPool, "Where is the pool?" );
1825 // adjust metric
1826 FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
1828 bool bApplyCharUnit = GetApplyCharUnit( *rSet );
1830 if( SvtCJKOptions::IsAsianTypographyEnabled() && bApplyCharUnit )
1831 eFUnit = FieldUnit::CHAR;
1833 sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1834 SfxItemState eItemState = rSet->GetItemState( _nWhich );
1836 bool bItemAvailable = eItemState >= SfxItemState::DEFAULT;
1837 bool bIsHyphen = false;
1838 if( !bHtmlMode && bItemAvailable )
1840 const SvxHyphenZoneItem& rHyphen =
1841 static_cast<const SvxHyphenZoneItem&>(rSet->Get( _nWhich ));
1842 aHyphenState.bTriStateEnabled = false;
1844 bIsHyphen = rHyphen.IsHyphen();
1845 m_xHyphenBox->set_state(bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE);
1846 m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_TRUE : TRISTATE_FALSE);
1847 m_xHyphenNoLastWordBox->set_state(rHyphen.IsNoLastWordHyphenation() ? TRISTATE_TRUE : TRISTATE_FALSE);
1849 m_xExtHyphenBeforeBox->set_value(rHyphen.GetMinLead());
1850 m_xExtHyphenAfterBox->set_value(rHyphen.GetMinTrail());
1851 m_xMaxHyphenEdit->set_value(rHyphen.GetMaxHyphens());
1852 m_xMinWordLength->set_value(rHyphen.GetMinWordLength());
1853 m_aHyphenZone.SetFieldUnit(eFUnit);
1854 m_aHyphenZone.SetMetricValue(rHyphen.GetTextHyphenZone(), MapUnit::MapTwip);
1856 else
1858 m_xHyphenBox->set_state(TRISTATE_INDET);
1859 m_xHyphenNoCapsBox->set_state(TRISTATE_INDET);
1860 m_xHyphenNoLastWordBox->set_state(TRISTATE_INDET);
1862 bool bEnable = bItemAvailable && bIsHyphen;
1863 m_xHyphenNoCapsBox->set_sensitive(bEnable);
1864 m_xHyphenNoLastWordBox->set_sensitive(bEnable);
1865 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
1866 m_xExtHyphenAfterBox->set_sensitive(bEnable);
1867 m_xBeforeText->set_sensitive(bEnable);
1868 m_xAfterText->set_sensitive(bEnable);
1869 m_xMaxHyphenLabel->set_sensitive(bEnable);
1870 m_xMaxHyphenEdit->set_sensitive(bEnable);
1871 m_xMinWordLabel->set_sensitive(bEnable);
1872 m_xMinWordLength->set_sensitive(bEnable);
1873 m_xHyphenZoneLabel->set_sensitive(bEnable);
1874 m_aHyphenZone.set_sensitive(bEnable);
1876 switch (rSet->GetItemState(SID_ATTR_PARA_PAGENUM))
1878 case SfxItemState::SET:
1880 aPageNumState.bTriStateEnabled = false;
1881 m_xPageNumBox->set_state(TRISTATE_TRUE);
1882 SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(SID_ATTR_PARA_PAGENUM));
1883 const sal_uInt16 nPageNum(pItem->GetValue());
1884 m_xPagenumEdit->set_value(nPageNum);
1885 break;
1887 case SfxItemState::DONTCARE:
1889 aPageNumState.bTriStateEnabled = true;
1890 m_xPageNumBox->set_state(TRISTATE_INDET);
1891 break;
1893 case SfxItemState::UNKNOWN:
1894 case SfxItemState::DEFAULT:
1895 case SfxItemState::DISABLED:
1897 aPageNumState.bTriStateEnabled = false;
1898 m_xPageNumBox->set_state(TRISTATE_FALSE);
1899 break;
1901 default:
1902 assert(false); // unexpected
1903 break;
1906 if ( bPageBreak )
1908 // first handle PageModel
1909 bool bIsPageModel = false;
1910 eItemState = rSet->GetItemState( SID_ATTR_PARA_MODEL );
1912 if ( eItemState >= SfxItemState::SET )
1914 aApplyCollState.bTriStateEnabled = false;
1916 const SvxPageModelItem& rModel = rSet->Get( SID_ATTR_PARA_MODEL );
1917 const OUString& aStr( rModel.GetValue() );
1919 if (!aStr.isEmpty() && m_xApplyCollBox->find_text(aStr) != -1)
1921 m_xApplyCollBox->set_active_text(aStr);
1922 m_xApplyCollBtn->set_state(TRISTATE_TRUE);
1923 bIsPageModel = true;
1925 m_xPageBreakBox->set_sensitive(true);
1926 aPageBreakState.bTriStateEnabled = false;
1927 m_xBreakTypeFT->set_sensitive(true);
1928 m_xBreakTypeLB->set_sensitive(true);
1929 m_xBreakPositionFT->set_sensitive(true);
1930 m_xBreakPositionLB->set_sensitive(true);
1931 m_xApplyCollBtn->set_sensitive(false);
1932 m_xPageBreakBox->set_state(TRISTATE_TRUE);
1934 //select page break
1935 m_xBreakTypeLB->set_active(0);
1936 //select break before
1937 m_xBreakPositionLB->set_active(0);
1939 else
1941 m_xApplyCollBox->set_active(-1);
1942 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
1945 else if ( SfxItemState::DONTCARE == eItemState )
1947 aApplyCollState.bTriStateEnabled = true;
1948 m_xApplyCollBtn->set_state(TRISTATE_INDET);
1949 m_xApplyCollBox->set_active(-1);
1951 else
1953 m_xApplyCollBtn->set_sensitive(false);
1954 m_xApplyCollBox->set_sensitive(false);
1955 m_xPagenumEdit->set_sensitive(false);
1956 m_xPageNumBox->set_sensitive(false);
1959 if ( !bIsPageModel )
1961 _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1962 eItemState = rSet->GetItemState( _nWhich );
1964 if ( eItemState >= SfxItemState::DEFAULT )
1966 const SvxFormatBreakItem& rPageBreak =
1967 static_cast<const SvxFormatBreakItem&>(rSet->Get( _nWhich ));
1969 SvxBreak eBreak = rPageBreak.GetBreak();
1971 // PageBreak not via CTRL-RETURN,
1972 // then CheckBox can be freed
1973 m_xPageBreakBox->set_sensitive(true);
1974 aPageBreakState.bTriStateEnabled = false;
1975 m_xBreakTypeFT->set_sensitive(true);
1976 m_xBreakTypeLB->set_sensitive(true);
1977 m_xBreakPositionFT->set_sensitive(true);
1978 m_xBreakPositionLB->set_sensitive(true);
1980 m_xPageBreakBox->set_state(TRISTATE_TRUE);
1982 bool _bEnable = eBreak != SvxBreak::NONE &&
1983 eBreak != SvxBreak::ColumnBefore &&
1984 eBreak != SvxBreak::ColumnAfter;
1985 m_xApplyCollBtn->set_sensitive(_bEnable);
1986 if (!_bEnable)
1988 m_xApplyCollBox->set_sensitive(_bEnable);
1989 m_xPageNumBox->set_sensitive(false);
1990 m_xPagenumEdit->set_sensitive(_bEnable);
1993 if ( eBreak == SvxBreak::NONE )
1994 m_xPageBreakBox->set_state(TRISTATE_FALSE);
1996 sal_Int32 nType = 0; // selection position in break type ListBox : Page
1997 sal_Int32 nPosition = 0; // selection position in break position ListBox : Before
1998 switch ( eBreak )
2000 case SvxBreak::PageBefore:
2001 break;
2002 case SvxBreak::PageAfter:
2003 nPosition = 1;
2004 break;
2005 case SvxBreak::ColumnBefore:
2006 nType = 1;
2007 break;
2008 case SvxBreak::ColumnAfter:
2009 nType = 1;
2010 nPosition = 1;
2011 break;
2012 default: ;//prevent warning
2014 m_xBreakTypeLB->set_active(nType);
2015 m_xBreakPositionLB->set_active(nPosition);
2017 else if ( SfxItemState::DONTCARE == eItemState )
2018 m_xPageBreakBox->set_state(TRISTATE_INDET);
2019 else
2021 m_xPageBreakBox->set_sensitive(false);
2022 m_xBreakTypeFT->set_sensitive(false);
2023 m_xBreakTypeLB->set_sensitive(false);
2024 m_xBreakPositionFT->set_sensitive(false);
2025 m_xBreakPositionLB->set_sensitive(false);
2029 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2030 PageBreakHdl();
2033 _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
2034 eItemState = rSet->GetItemState( _nWhich );
2036 if ( eItemState >= SfxItemState::DEFAULT )
2038 aKeepParaState.bTriStateEnabled = false;
2039 const SvxFormatKeepItem& rKeep =
2040 static_cast<const SvxFormatKeepItem&>(rSet->Get( _nWhich ));
2042 if ( rKeep.GetValue() )
2043 m_xKeepParaBox->set_state(TRISTATE_TRUE);
2044 else
2045 m_xKeepParaBox->set_state(TRISTATE_FALSE);
2047 else if ( SfxItemState::DONTCARE == eItemState )
2048 m_xKeepParaBox->set_state(TRISTATE_INDET);
2049 else
2050 m_xKeepParaBox->set_sensitive(false);
2052 _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
2053 eItemState = rSet->GetItemState( _nWhich );
2055 if ( eItemState >= SfxItemState::DEFAULT )
2057 const SvxFormatSplitItem& rSplit =
2058 static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich ));
2059 aKeepTogetherState.bTriStateEnabled = false;
2061 if ( !rSplit.GetValue() )
2062 m_xKeepTogetherBox->set_state(TRISTATE_TRUE);
2063 else
2065 m_xKeepTogetherBox->set_state(TRISTATE_FALSE);
2066 // default widows and orphans to enabled
2067 m_xWidowBox->set_sensitive(true);
2068 m_xOrphanBox->set_sensitive(true);
2071 // widows and orphans
2072 _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
2073 SfxItemState eTmpState = rSet->GetItemState( _nWhich );
2075 if ( eTmpState >= SfxItemState::DEFAULT )
2077 const SvxWidowsItem& rWidow =
2078 static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich ));
2079 aWidowState.bTriStateEnabled = false;
2080 const sal_uInt16 nLines = rWidow.GetValue();
2082 bool _bEnable = nLines > 0;
2083 m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines));
2084 m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2085 m_xWidowRowNo->set_sensitive(_bEnable);
2087 else if ( SfxItemState::DONTCARE == eTmpState )
2088 m_xWidowBox->set_state( TRISTATE_INDET );
2089 else
2090 m_xWidowBox->set_sensitive(false);
2092 _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
2093 eTmpState = rSet->GetItemState( _nWhich );
2095 if ( eTmpState >= SfxItemState::DEFAULT )
2097 const SvxOrphansItem& rOrphan =
2098 static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich ));
2099 const sal_uInt16 nLines = rOrphan.GetValue();
2100 aOrphanState.bTriStateEnabled = false;
2102 bool _bEnable = nLines > 0;
2103 m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2104 m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines));
2105 m_xOrphanRowNo->set_sensitive(_bEnable);
2106 m_xOrphanRowLabel->set_sensitive(_bEnable);
2109 else if ( SfxItemState::DONTCARE == eTmpState )
2110 m_xOrphanBox->set_state(TRISTATE_INDET);
2111 else
2112 m_xOrphanBox->set_sensitive(false);
2113 aOrphanState.eState = m_xOrphanBox->get_state();
2115 else if ( SfxItemState::DONTCARE == eItemState )
2116 m_xKeepTogetherBox->set_state(TRISTATE_INDET);
2117 else
2118 m_xKeepTogetherBox->set_sensitive(false);
2120 // so that everything is enabled correctly
2121 KeepTogetherHdl();
2122 WidowHdl();
2123 OrphanHdl();
2124 ChangesApplied();
2126 void SvxExtParagraphTabPage::ChangesApplied()
2128 m_xHyphenBox->save_state();
2129 m_xHyphenNoCapsBox->save_state();
2130 m_xHyphenNoLastWordBox->save_state();
2131 m_xExtHyphenBeforeBox->set_value(m_xExtHyphenBeforeBox->get_value());
2132 m_xExtHyphenAfterBox->set_value(m_xExtHyphenAfterBox->get_value());
2133 m_xMaxHyphenEdit->set_value(m_xMaxHyphenEdit->get_value());
2134 m_xMinWordLength->set_value(m_xMinWordLength->get_value());
2135 SfxItemPool* pPool = GetItemSet().GetPool();
2136 DBG_ASSERT( pPool, "Where is the pool?" );
2137 FieldUnit eUnit =
2138 MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_PARA_HYPHENZONE ) ) );
2139 m_aHyphenZone.set_value(m_aHyphenZone.get_value(eUnit), eUnit);
2140 m_xPageBreakBox->save_state();
2141 m_xBreakPositionLB->save_value();
2142 m_xBreakTypeLB->save_value();
2143 m_xApplyCollBtn->save_state();
2144 m_xApplyCollBox->save_value();
2145 m_xPageNumBox->save_state();
2146 m_xPagenumEdit->save_value();
2147 m_xKeepTogetherBox->save_state();
2148 m_xKeepParaBox->save_state();
2149 m_xWidowBox->save_state();
2150 m_xOrphanBox->save_state();
2151 m_xOrphanRowNo->save_value();
2152 m_xWidowRowNo->save_value();
2155 DeactivateRC SvxExtParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
2157 if ( _pSet )
2158 FillItemSet( _pSet );
2159 return DeactivateRC::LeavePage;
2162 void SvxExtParagraphTabPage::DisablePageBreak()
2164 bPageBreak = false;
2165 m_xPageBreakBox->set_sensitive(false);
2166 m_xBreakTypeLB->remove(0);
2167 m_xBreakPositionFT->set_sensitive(false);
2168 m_xBreakPositionLB->set_sensitive(false);
2169 m_xApplyCollBtn->set_sensitive(false);
2170 m_xApplyCollBox->set_sensitive(false);
2171 m_xPageNumBox->set_sensitive(false);
2172 m_xPagenumEdit->set_sensitive(false);
2175 SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
2176 : SfxTabPage(pPage, pController, "cui/ui/textflowpage.ui", "TextFlowPage", &rAttr)
2177 , bPageBreak(true)
2178 , bHtmlMode(false)
2179 , nStdPos(0)
2180 // Hyphenation
2181 , m_xHyphenBox(m_xBuilder->weld_check_button("checkAuto"))
2182 , m_xHyphenNoCapsBox(m_xBuilder->weld_check_button("checkNoCaps"))
2183 , m_xHyphenNoLastWordBox(m_xBuilder->weld_check_button("checkNoLastWord"))
2184 , m_xBeforeText(m_xBuilder->weld_label("labelLineBegin"))
2185 , m_xExtHyphenBeforeBox(m_xBuilder->weld_spin_button("spinLineEnd"))
2186 , m_xAfterText(m_xBuilder->weld_label("labelLineEnd"))
2187 , m_xExtHyphenAfterBox(m_xBuilder->weld_spin_button("spinLineBegin"))
2188 , m_xMaxHyphenLabel(m_xBuilder->weld_label("labelMaxNum"))
2189 , m_xMaxHyphenEdit(m_xBuilder->weld_spin_button("spinMaxNum"))
2190 , m_xMinWordLabel(m_xBuilder->weld_label("labelMinLen"))
2191 , m_xMinWordLength(m_xBuilder->weld_spin_button("spinMinLen"))
2192 , m_xHyphenZoneLabel(m_xBuilder->weld_label("labelHyphenZone"))
2193 , m_aHyphenZone(m_xBuilder->weld_metric_spin_button("spinHyphenZone", FieldUnit::CM))
2194 //Page break
2195 , m_xPageBreakBox(m_xBuilder->weld_check_button("checkInsert"))
2196 , m_xBreakTypeFT(m_xBuilder->weld_label("labelType"))
2197 , m_xBreakTypeLB(m_xBuilder->weld_combo_box("comboBreakType"))
2198 , m_xBreakPositionFT(m_xBuilder->weld_label("labelPosition"))
2199 , m_xBreakPositionLB(m_xBuilder->weld_combo_box("comboBreakPosition"))
2200 , m_xApplyCollBtn(m_xBuilder->weld_check_button("checkPageStyle"))
2201 , m_xApplyCollBox(m_xBuilder->weld_combo_box("comboPageStyle"))
2202 , m_xPageNumBox(m_xBuilder->weld_check_button("labelPageNum"))
2203 , m_xPagenumEdit(m_xBuilder->weld_spin_button("spinPageNumber"))
2204 // Options
2205 , m_xKeepTogetherBox(m_xBuilder->weld_check_button("checkSplitPara"))
2206 , m_xKeepParaBox(m_xBuilder->weld_check_button("checkKeepPara"))
2207 , m_xOrphanBox(m_xBuilder->weld_check_button("checkOrphan"))
2208 , m_xOrphanRowNo(m_xBuilder->weld_spin_button("spinOrphan"))
2209 , m_xOrphanRowLabel(m_xBuilder->weld_label("labelOrphan"))
2210 , m_xWidowBox(m_xBuilder->weld_check_button("checkWidow"))
2211 , m_xWidowRowNo(m_xBuilder->weld_spin_button("spinWidow"))
2212 , m_xWidowRowLabel(m_xBuilder->weld_label("labelWidow"))
2214 // this page needs ExchangeSupport
2215 SetExchangeSupport();
2217 m_xHyphenBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, HyphenClickHdl_Impl));
2218 m_xPageBreakBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageBreakHdl_Impl));
2219 m_xKeepTogetherBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepTogetherHdl_Impl));
2220 m_xWidowBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, WidowHdl_Impl));
2221 m_xOrphanBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, OrphanHdl_Impl));
2222 m_xApplyCollBtn->connect_toggled(LINK(this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl));
2223 m_xBreakTypeLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl));
2224 m_xBreakPositionLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl));
2225 m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl));
2226 m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl));
2228 if (SfxObjectShell* pSh = SfxObjectShell::Current())
2230 SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
2231 SfxStyleSheetBase* pStyle = pPool->First(SfxStyleFamily::Page);
2232 OUString aStdName;
2234 // tdf139131 - sort page styles
2235 m_xApplyCollBox->make_sorted();
2236 while( pStyle )
2238 if ( aStdName.isEmpty() )
2239 // first style == standard style
2240 aStdName = pStyle->GetName();
2241 m_xApplyCollBox->append_text(pStyle->GetName());
2242 pStyle = pPool->Next();
2244 nStdPos = m_xApplyCollBox->find_text(aStdName);
2247 sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr );
2248 if ( !(nHtmlMode & HTMLMODE_ON) )
2249 return;
2251 bHtmlMode = true;
2252 m_xHyphenBox->set_sensitive(false);
2253 m_xHyphenNoCapsBox->set_sensitive(false);
2254 m_xHyphenNoLastWordBox->set_sensitive(false);
2255 m_xBeforeText->set_sensitive(false);
2256 m_xExtHyphenBeforeBox->set_sensitive(false);
2257 m_xAfterText->set_sensitive(false);
2258 m_xExtHyphenAfterBox->set_sensitive(false);
2259 m_xMaxHyphenLabel->set_sensitive(false);
2260 m_xMaxHyphenEdit->set_sensitive(false);
2261 m_xMinWordLabel->set_sensitive(false);
2262 m_xMinWordLength->set_sensitive(false);
2263 m_xHyphenZoneLabel->set_sensitive(false);
2264 m_aHyphenZone.set_sensitive(false);
2265 m_xPageNumBox->set_sensitive(false);
2266 m_xPagenumEdit->set_sensitive(false);
2267 // no column break in HTML
2268 m_xBreakTypeLB->remove(1);
2271 SvxExtParagraphTabPage::~SvxExtParagraphTabPage()
2275 void SvxExtParagraphTabPage::PageBreakHdl()
2277 switch (m_xPageBreakBox->get_state())
2279 case TRISTATE_TRUE:
2280 m_xBreakTypeFT->set_sensitive(true);
2281 m_xBreakTypeLB->set_sensitive(true);
2282 m_xBreakPositionFT->set_sensitive(true);
2283 m_xBreakPositionLB->set_sensitive(true);
2285 if (0 == m_xBreakTypeLB->get_active() && 0 == m_xBreakPositionLB->get_active())
2287 m_xApplyCollBtn->set_sensitive(true);
2289 bool bEnable = TRISTATE_TRUE == m_xApplyCollBtn->get_state() &&
2290 m_xApplyCollBox->get_count();
2291 m_xApplyCollBox->set_sensitive(bEnable);
2292 if(!bHtmlMode)
2294 m_xPageNumBox->set_sensitive(bEnable);
2295 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2298 break;
2300 case TRISTATE_FALSE:
2301 case TRISTATE_INDET:
2302 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2303 m_xApplyCollBtn->set_sensitive(false);
2304 m_xApplyCollBox->set_sensitive(false);
2305 m_xPageNumBox->set_sensitive(false);
2306 m_xPagenumEdit->set_sensitive(false);
2307 m_xBreakTypeFT->set_sensitive(false);
2308 m_xBreakTypeLB->set_sensitive(false);
2309 m_xBreakPositionFT->set_sensitive(false);
2310 m_xBreakPositionLB->set_sensitive(false);
2311 break;
2315 IMPL_LINK(SvxExtParagraphTabPage, PageBreakHdl_Impl, weld::Toggleable&, rToggle, void)
2317 aPageBreakState.ButtonToggled(rToggle);
2318 PageBreakHdl();
2321 void SvxExtParagraphTabPage::KeepTogetherHdl()
2323 bool bEnable = m_xKeepTogetherBox->get_state() == TRISTATE_FALSE;
2324 m_xWidowBox->set_sensitive(bEnable);
2325 m_xOrphanBox->set_sensitive(bEnable);
2328 IMPL_LINK(SvxExtParagraphTabPage, KeepTogetherHdl_Impl, weld::Toggleable&, rToggle, void)
2330 aKeepTogetherState.ButtonToggled(rToggle);
2331 KeepTogetherHdl();
2334 void SvxExtParagraphTabPage::WidowHdl()
2336 switch (m_xWidowBox->get_state())
2338 case TRISTATE_TRUE:
2339 m_xWidowRowNo->set_sensitive(true);
2340 m_xWidowRowLabel->set_sensitive(true);
2341 m_xKeepTogetherBox->set_sensitive(false);
2342 break;
2343 case TRISTATE_FALSE:
2344 if (m_xOrphanBox->get_state() == TRISTATE_FALSE)
2345 m_xKeepTogetherBox->set_sensitive(true);
2346 [[fallthrough]];
2347 case TRISTATE_INDET:
2348 m_xWidowRowNo->set_sensitive(false);
2349 m_xWidowRowLabel->set_sensitive(false);
2350 break;
2354 IMPL_LINK(SvxExtParagraphTabPage, WidowHdl_Impl, weld::Toggleable&, rToggle, void)
2356 aWidowState.ButtonToggled(rToggle);
2357 WidowHdl();
2360 IMPL_LINK(SvxExtParagraphTabPage, OrphanHdl_Impl, weld::Toggleable&, rToggle, void)
2362 aOrphanState.ButtonToggled(rToggle);
2363 OrphanHdl();
2366 void SvxExtParagraphTabPage::OrphanHdl()
2368 switch (m_xOrphanBox->get_state())
2370 case TRISTATE_TRUE:
2371 m_xOrphanRowNo->set_sensitive(true);
2372 m_xOrphanRowLabel->set_sensitive(true);
2373 m_xKeepTogetherBox->set_sensitive(false);
2374 break;
2376 case TRISTATE_FALSE:
2377 if (m_xWidowBox->get_state() == TRISTATE_FALSE)
2378 m_xKeepTogetherBox->set_sensitive(true);
2379 [[fallthrough]];
2380 case TRISTATE_INDET:
2381 m_xOrphanRowNo->set_sensitive(false);
2382 m_xOrphanRowLabel->set_sensitive(false);
2383 break;
2387 void SvxExtParagraphTabPage::HyphenClickHdl()
2389 bool bEnable = m_xHyphenBox->get_state() == TRISTATE_TRUE;
2390 m_xHyphenNoCapsBox->set_sensitive(bEnable);
2391 m_xHyphenNoLastWordBox->set_sensitive(bEnable);
2392 m_xBeforeText->set_sensitive(bEnable);
2393 m_xExtHyphenBeforeBox->set_sensitive(bEnable);
2394 m_xAfterText->set_sensitive(bEnable);
2395 m_xExtHyphenAfterBox->set_sensitive(bEnable);
2396 m_xMaxHyphenLabel->set_sensitive(bEnable);
2397 m_xMaxHyphenEdit->set_sensitive(bEnable);
2398 m_xMinWordLabel->set_sensitive(bEnable);
2399 m_xMinWordLength->set_sensitive(bEnable);
2400 m_xHyphenZoneLabel->set_sensitive(bEnable);
2401 m_aHyphenZone.set_sensitive(bEnable);
2402 m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE);
2405 IMPL_LINK(SvxExtParagraphTabPage, HyphenClickHdl_Impl, weld::Toggleable&, rToggle, void)
2407 aHyphenState.ButtonToggled(rToggle);
2408 HyphenClickHdl();
2411 void SvxExtParagraphTabPage::ApplyCollClickHdl()
2413 bool bEnable = false;
2414 if (m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count())
2416 bEnable = true;
2417 m_xApplyCollBox->set_active(nStdPos);
2419 else
2421 m_xApplyCollBox->set_active(-1);
2423 m_xApplyCollBox->set_sensitive(bEnable);
2424 if (!bHtmlMode)
2426 m_xPageNumBox->set_sensitive(bEnable);
2427 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2431 IMPL_LINK(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl, weld::Toggleable&, rToggle, void)
2433 aApplyCollState.ButtonToggled(rToggle);
2434 ApplyCollClickHdl();
2437 IMPL_LINK(SvxExtParagraphTabPage, PageBreakPosHdl_Impl, weld::ComboBox&, rListBox, void)
2439 if (0 == rListBox.get_active())
2441 m_xApplyCollBtn->set_sensitive(true);
2443 bool bEnable = m_xApplyCollBtn->get_state() == TRISTATE_TRUE && m_xApplyCollBox->get_count();
2445 m_xApplyCollBox->set_sensitive(bEnable);
2446 if (!bHtmlMode)
2448 m_xPageNumBox->set_sensitive(bEnable);
2449 m_xPagenumEdit->set_sensitive(bEnable && m_xPageNumBox->get_state() == TRISTATE_TRUE);
2452 else if (1 == rListBox.get_active())
2454 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2455 m_xApplyCollBtn->set_sensitive(false);
2456 m_xApplyCollBox->set_sensitive(false);
2457 m_xPageNumBox->set_sensitive(false);
2458 m_xPagenumEdit->set_sensitive(false);
2462 IMPL_LINK(SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, weld::ComboBox&, rListBox, void)
2464 //column break or break after
2465 int nBreakPos = m_xBreakPositionLB->get_active();
2466 if (rListBox.get_active() == 1 || 1 == nBreakPos)
2468 m_xApplyCollBtn->set_state(TRISTATE_FALSE);
2469 m_xApplyCollBtn->set_sensitive(false);
2470 m_xApplyCollBox->set_sensitive(false);
2471 m_xPageNumBox->set_sensitive(false);
2472 m_xPagenumEdit->set_sensitive(false);
2474 else
2475 PageBreakPosHdl_Impl(*m_xBreakPositionLB);
2478 void SvxExtParagraphTabPage::PageNumBoxClickHdl()
2480 m_xPagenumEdit->set_sensitive(m_xPageNumBox->get_state() == TRISTATE_TRUE);
2483 IMPL_LINK(SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl, weld::Toggleable&, rToggle, void)
2485 aPageNumState.ButtonToggled(rToggle);
2486 PageNumBoxClickHdl();
2489 IMPL_LINK(SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl, weld::Toggleable&, rToggle, void)
2491 aKeepParaState.ButtonToggled(rToggle);
2494 void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
2496 const SfxBoolItem* pDisablePageBreakItem = aSet.GetItem<SfxBoolItem>(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false);
2498 if (pDisablePageBreakItem)
2499 if ( pDisablePageBreakItem->GetValue())
2500 DisablePageBreak();
2503 SvxAsianTabPage::SvxAsianTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
2504 : SfxTabPage(pPage, pController, "cui/ui/asiantypography.ui", "AsianTypography", &rSet)
2505 , m_xForbiddenRulesCB(m_xBuilder->weld_check_button("checkForbidList"))
2506 , m_xHangingPunctCB(m_xBuilder->weld_check_button("checkHangPunct"))
2507 , m_xScriptSpaceCB(m_xBuilder->weld_check_button("checkApplySpacing"))
2511 SvxAsianTabPage::~SvxAsianTabPage()
2515 std::unique_ptr<SfxTabPage> SvxAsianTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2517 return std::make_unique<SvxAsianTabPage>(pPage, pController, *rSet);
2520 WhichRangesContainer SvxAsianTabPage::GetRanges()
2522 return WhichRangesContainer(svl::Items<SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES>);
2525 bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet )
2527 bool bRet = false;
2528 SfxItemPool* pPool = rSet->GetPool();
2529 if (m_xScriptSpaceCB->get_sensitive() && m_xScriptSpaceCB->get_state_changed_from_saved())
2531 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2532 pPool->GetWhich(SID_ATTR_PARA_SCRIPTSPACE)).Clone()));
2533 pNewItem->SetValue(m_xScriptSpaceCB->get_active());
2534 rSet->Put(std::move(pNewItem));
2535 bRet = true;
2537 if (m_xHangingPunctCB->get_sensitive() && m_xHangingPunctCB->get_state_changed_from_saved())
2539 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2540 pPool->GetWhich(SID_ATTR_PARA_HANGPUNCTUATION)).Clone()));
2541 pNewItem->SetValue(m_xHangingPunctCB->get_active());
2542 rSet->Put(std::move(pNewItem));
2543 bRet = true;
2545 if (m_xForbiddenRulesCB->get_sensitive() && m_xForbiddenRulesCB->get_state_changed_from_saved())
2547 std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get(
2548 pPool->GetWhich(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone()));
2549 pNewItem->SetValue(m_xForbiddenRulesCB->get_active());
2550 rSet->Put(std::move(pNewItem));
2551 bRet = true;
2553 return bRet;
2556 static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, weld::CheckButton& rBox)
2558 sal_uInt16 _nWhich = rSet.GetPool()->GetWhich(nSlotId);
2559 SfxItemState eState = rSet.GetItemState(_nWhich);
2560 if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED )
2561 rBox.set_sensitive(false);
2562 else if(eState >= SfxItemState::DEFAULT)
2563 rBox.set_active(static_cast<const SfxBoolItem&>(rSet.Get(_nWhich)).GetValue());
2564 else
2565 rBox.set_state(TRISTATE_INDET);
2566 rBox.save_state();
2569 void SvxAsianTabPage::Reset( const SfxItemSet* rSet )
2571 lcl_SetBox(*rSet, SID_ATTR_PARA_FORBIDDEN_RULES, *m_xForbiddenRulesCB );
2572 lcl_SetBox(*rSet, SID_ATTR_PARA_HANGPUNCTUATION, *m_xHangingPunctCB );
2574 //character distance not yet available
2575 lcl_SetBox(*rSet, SID_ATTR_PARA_SCRIPTSPACE, *m_xScriptSpaceCB );
2578 void SvxAsianTabPage::ChangesApplied()
2580 m_xForbiddenRulesCB->save_state();
2581 m_xHangingPunctCB->save_state();
2582 m_xScriptSpaceCB->save_state();
2585 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */