1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <com/sun/star/style/TabStop.hpp>
21 #include <com/sun/star/style/LineSpacing.hpp>
22 #include <com/sun/star/style/LineSpacingMode.hpp>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <libxml/xmlwriter.h>
25 #include <comphelper/extract.hxx>
26 #include <osl/diagnose.h>
27 #include <unotools/localedatawrapper.hxx>
28 #include <unotools/syslocale.hxx>
29 #include <tools/mapunit.hxx>
30 #include <tools/UnitConversion.hxx>
31 #include <svl/itempool.hxx>
32 #include <svl/memberid.h>
33 #include <editeng/editrids.hrc>
34 #include <editeng/lspcitem.hxx>
35 #include <editeng/adjustitem.hxx>
36 #include <editeng/orphitem.hxx>
37 #include <editeng/widwitem.hxx>
38 #include <editeng/tstpitem.hxx>
39 #include <editeng/pmdlitem.hxx>
40 #include <editeng/spltitem.hxx>
41 #include <editeng/hyphenzoneitem.hxx>
42 #include <editeng/scriptspaceitem.hxx>
43 #include <editeng/hngpnctitem.hxx>
44 #include <editeng/forbiddenruleitem.hxx>
45 #include <editeng/paravertalignitem.hxx>
46 #include <editeng/pgrditem.hxx>
47 #include <rtl/ustring.hxx>
48 #include <sal/log.hxx>
49 #include <editeng/memberids.h>
50 #include <editeng/itemtype.hxx>
51 #include <editeng/eerdll.hxx>
53 using namespace ::com::sun::star
;
56 SfxPoolItem
* SvxLineSpacingItem::CreateDefault() { return new SvxLineSpacingItem(LINE_SPACE_DEFAULT_HEIGHT
, 0);}
57 SfxPoolItem
* SvxAdjustItem::CreateDefault() { return new SvxAdjustItem(SvxAdjust::Left
, 0);}
58 SfxPoolItem
* SvxWidowsItem::CreateDefault() { return new SvxWidowsItem(0, 0);}
59 SfxPoolItem
* SvxOrphansItem::CreateDefault() { return new SvxOrphansItem(0, 0);}
60 SfxPoolItem
* SvxHyphenZoneItem::CreateDefault() { return new SvxHyphenZoneItem(false, 0);}
61 SfxPoolItem
* SvxTabStopItem::CreateDefault() { return new SvxTabStopItem(0);}
62 SfxPoolItem
* SvxFormatSplitItem::CreateDefault() { return new SvxFormatSplitItem(false, 0);}
63 SfxPoolItem
* SvxPageModelItem::CreateDefault() { return new SvxPageModelItem(TypedWhichId
<SvxPageModelItem
>(0));}
64 SfxPoolItem
* SvxParaVertAlignItem::CreateDefault() { return new SvxParaVertAlignItem(Align::Automatic
, TypedWhichId
<SvxParaVertAlignItem
>(0));}
68 enum class SvxSpecialLineSpace
79 SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight
, const sal_uInt16 nId
)
80 : SfxEnumItemInterface( nId
)
84 nLineHeight
= nHeight
;
85 eLineSpaceRule
= SvxLineSpaceRule::Auto
;
86 eInterLineSpaceRule
= SvxInterLineSpaceRule::Off
;
90 bool SvxLineSpacingItem::operator==( const SfxPoolItem
& rAttr
) const
92 assert(SfxPoolItem::operator==(rAttr
));
94 const SvxLineSpacingItem
& rLineSpace
= static_cast<const SvxLineSpacingItem
&>(rAttr
);
96 // Same Linespacing Rule?
97 (eLineSpaceRule
== rLineSpace
.eLineSpaceRule
)
98 // For maximum and minimum Linespacing be the size must coincide.
99 && (eLineSpaceRule
== SvxLineSpaceRule::Auto
||
100 nLineHeight
== rLineSpace
.nLineHeight
)
101 // Same Linespacing Rule?
102 && ( eInterLineSpaceRule
== rLineSpace
.eInterLineSpaceRule
)
103 // Either set proportional or additive.
104 && (( eInterLineSpaceRule
== SvxInterLineSpaceRule::Off
)
105 || (eInterLineSpaceRule
== SvxInterLineSpaceRule::Prop
106 && nPropLineSpace
== rLineSpace
.nPropLineSpace
)
107 || (eInterLineSpaceRule
== SvxInterLineSpaceRule::Fix
108 && (nInterLineSpace
== rLineSpace
.nInterLineSpace
)));
111 /* Who does still know why the LineSpacingItem is so complicated?
112 We can not use it for UNO since there are only two values:
113 - a sal_uInt16 for the mode
114 - a sal_uInt32 for all values (distance, height, rel. detail)
116 bool SvxLineSpacingItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
118 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
119 nMemberId
&= ~CONVERT_TWIPS
;
121 style::LineSpacing aLSp
;
122 switch( eLineSpaceRule
)
124 case SvxLineSpaceRule::Auto
:
125 if(eInterLineSpaceRule
== SvxInterLineSpaceRule::Fix
)
127 aLSp
.Mode
= style::LineSpacingMode::LEADING
;
128 aLSp
.Height
= ( bConvert
? static_cast<short>(convertTwipToMm100(nInterLineSpace
)) : nInterLineSpace
);
130 else if(eInterLineSpaceRule
== SvxInterLineSpaceRule::Off
)
132 aLSp
.Mode
= style::LineSpacingMode::PROP
;
137 aLSp
.Mode
= style::LineSpacingMode::PROP
;
138 aLSp
.Height
= nPropLineSpace
;
141 case SvxLineSpaceRule::Fix
:
142 case SvxLineSpaceRule::Min
:
143 aLSp
.Mode
= eLineSpaceRule
== SvxLineSpaceRule::Fix
? style::LineSpacingMode::FIX
: style::LineSpacingMode::MINIMUM
;
144 aLSp
.Height
= ( bConvert
? static_cast<short>(convertTwipToMm100(nLineHeight
)) : nLineHeight
);
147 ;//prevent warning about SvxLineSpaceRule::End
152 case 0 : rVal
<<= aLSp
; break;
153 case MID_LINESPACE
: rVal
<<= aLSp
.Mode
; break;
154 case MID_HEIGHT
: rVal
<<= aLSp
.Height
; break;
155 default: OSL_FAIL("Wrong MemberId!"); break;
161 bool SvxLineSpacingItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
163 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
164 nMemberId
&= ~CONVERT_TWIPS
;
166 // fill with current data
167 style::LineSpacing aLSp
;
169 bool bRet
= QueryValue( aAny
, bConvert
? CONVERT_TWIPS
: 0 ) && ( aAny
>>= aLSp
);
174 case 0 : bRet
= (rVal
>>= aLSp
); break;
175 case MID_LINESPACE
: bRet
= (rVal
>>= aLSp
.Mode
); break;
176 case MID_HEIGHT
: bRet
= (rVal
>>= aLSp
.Height
); break;
177 default: OSL_FAIL("Wrong MemberId!"); break;
182 nLineHeight
= aLSp
.Height
;
185 case style::LineSpacingMode::LEADING
:
187 eInterLineSpaceRule
= SvxInterLineSpaceRule::Fix
;
188 eLineSpaceRule
= SvxLineSpaceRule::Auto
;
189 nInterLineSpace
= aLSp
.Height
;
191 nInterLineSpace
= o3tl::toTwips(nInterLineSpace
, o3tl::Length::mm100
);
195 case style::LineSpacingMode::PROP
:
197 eLineSpaceRule
= SvxLineSpaceRule::Auto
;
198 nPropLineSpace
= aLSp
.Height
;
199 if(100 == aLSp
.Height
)
200 eInterLineSpaceRule
= SvxInterLineSpaceRule::Off
;
202 eInterLineSpaceRule
= SvxInterLineSpaceRule::Prop
;
205 case style::LineSpacingMode::FIX
:
206 case style::LineSpacingMode::MINIMUM
:
208 eInterLineSpaceRule
= SvxInterLineSpaceRule::Off
;
209 eLineSpaceRule
= aLSp
.Mode
== style::LineSpacingMode::FIX
? SvxLineSpaceRule::Fix
: SvxLineSpaceRule::Min
;
210 nLineHeight
= aLSp
.Height
;
212 nLineHeight
= o3tl::toTwips(nLineHeight
, o3tl::Length::mm100
);
221 SvxLineSpacingItem
* SvxLineSpacingItem::Clone( SfxItemPool
* ) const
223 return new SvxLineSpacingItem( *this );
226 bool SvxLineSpacingItem::GetPresentation
228 SfxItemPresentation ePres
,
231 OUString
& rText
, const IntlWrapper
& rIntl
236 case SfxItemPresentation::Nameless
:
237 case SfxItemPresentation::Complete
:
239 switch( GetLineSpaceRule() )
241 case SvxLineSpaceRule::Auto
:
243 SvxInterLineSpaceRule eInter
= GetInterLineSpaceRule();
247 // Default single line spacing
248 case SvxInterLineSpaceRule::Off
:
249 rText
= EditResId(RID_SVXITEMS_LINESPACING_SINGLE
);
252 // Default single line spacing
253 case SvxInterLineSpaceRule::Prop
:
254 if ( 100 == GetPropLineSpace() )
256 rText
= EditResId(RID_SVXITEMS_LINESPACING_SINGLE
);
260 if ( 115 == GetPropLineSpace() )
262 rText
= EditResId(RID_SVXITEMS_LINESPACING_115
);
266 if ( 150 == GetPropLineSpace() )
268 rText
= EditResId(RID_SVXITEMS_LINESPACING_15
);
271 // double line spacing
272 if ( 200 == GetPropLineSpace() )
274 rText
= EditResId(RID_SVXITEMS_LINESPACING_DOUBLE
);
277 // the set per cent value
278 rText
= EditResId(RID_SVXITEMS_LINESPACING_PROPORTIONAL
) + " " + OUString::number(GetPropLineSpace()) + "%";
281 case SvxInterLineSpaceRule::Fix
:
282 rText
= EditResId(RID_SVXITEMS_LINESPACING_LEADING
) +
283 " " + GetMetricText(GetInterLineSpace(), eCoreUnit
, ePresUnit
, &rIntl
) +
284 " " + EditResId(GetMetricId(ePresUnit
));
286 default: ;//prevent warning
290 case SvxLineSpaceRule::Fix
:
291 rText
= EditResId(RID_SVXITEMS_LINESPACING_FIXED
) +
292 " " + GetMetricText(GetLineHeight(), eCoreUnit
, ePresUnit
, &rIntl
) +
293 " " + EditResId(GetMetricId(ePresUnit
));
296 case SvxLineSpaceRule::Min
:
297 rText
= EditResId(RID_SVXITEMS_LINESPACING_MIN
) +
298 " " + GetMetricText(GetLineHeight(), eCoreUnit
, ePresUnit
, &rIntl
) +
299 " " + EditResId(GetMetricId(ePresUnit
));
301 default: ;//prevent warning
308 sal_uInt16
SvxLineSpacingItem::GetValueCount() const
310 return sal_uInt16(SvxSpecialLineSpace::End
); // SvxSpecialLineSpace::TwoLines + 1
314 sal_uInt16
SvxLineSpacingItem::GetEnumValue() const
316 SvxSpecialLineSpace nVal
;
317 switch ( nPropLineSpace
)
319 case 100: nVal
= SvxSpecialLineSpace::OneLine
; break;
320 case 150: nVal
= SvxSpecialLineSpace::OnePointFiveLines
; break;
321 case 200: nVal
= SvxSpecialLineSpace::TwoLines
; break;
322 default: nVal
= SvxSpecialLineSpace::User
; break;
324 return static_cast<sal_uInt16
>(nVal
);
328 void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal
)
330 switch ( static_cast<SvxSpecialLineSpace
>(nVal
) )
332 case SvxSpecialLineSpace::OneLine
: nPropLineSpace
= 100; break;
333 case SvxSpecialLineSpace::OnePointFiveLines
: nPropLineSpace
= 150; break;
334 case SvxSpecialLineSpace::TwoLines
: nPropLineSpace
= 200; break;
339 // class SvxAdjustItem ---------------------------------------------------
341 SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst
, const sal_uInt16 nId
)
342 : SfxEnumItemInterface( nId
),
343 bOneBlock( false ), bLastCenter( false ), bLastBlock( false )
349 bool SvxAdjustItem::operator==( const SfxPoolItem
& rAttr
) const
351 assert(SfxPoolItem::operator==(rAttr
));
353 const SvxAdjustItem
& rItem
= static_cast<const SvxAdjustItem
&>(rAttr
);
354 return GetAdjust() == rItem
.GetAdjust() &&
355 bOneBlock
== rItem
.bOneBlock
&&
356 bLastCenter
== rItem
.bLastCenter
&&
357 bLastBlock
== rItem
.bLastBlock
;
360 bool SvxAdjustItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
362 nMemberId
&= ~CONVERT_TWIPS
;
365 case MID_PARA_ADJUST
: rVal
<<= static_cast<sal_Int16
>(GetAdjust()); break;
366 case MID_LAST_LINE_ADJUST
: rVal
<<= static_cast<sal_Int16
>(GetLastBlock()); break;
367 case MID_EXPAND_SINGLE
:
372 default: ;//prevent warning
377 bool SvxAdjustItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
379 nMemberId
&= ~CONVERT_TWIPS
;
382 case MID_PARA_ADJUST
:
383 case MID_LAST_LINE_ADJUST
:
385 sal_Int32 eVal
= - 1;
386 ::cppu::enum2int(eVal
,rVal
);
387 if(eVal
>= 0 && eVal
<= 4)
389 SvxAdjust eAdjust
= static_cast<SvxAdjust
>(eVal
);
390 if(MID_LAST_LINE_ADJUST
== nMemberId
&&
391 eAdjust
!= SvxAdjust::Left
&&
392 eAdjust
!= SvxAdjust::Block
&&
393 eAdjust
!= SvxAdjust::Center
)
395 nMemberId
== MID_PARA_ADJUST
? SetAdjust(eAdjust
) : SetLastBlock(eAdjust
);
399 case MID_EXPAND_SINGLE
:
400 bOneBlock
= Any2Bool(rVal
);
406 SvxAdjustItem
* SvxAdjustItem::Clone( SfxItemPool
* ) const
408 return new SvxAdjustItem( *this );
411 bool SvxAdjustItem::GetPresentation
413 SfxItemPresentation ePres
,
414 MapUnit
/*eCoreUnit*/,
415 MapUnit
/*ePresUnit*/,
416 OUString
& rText
, const IntlWrapper
&
421 case SfxItemPresentation::Nameless
:
422 case SfxItemPresentation::Complete
:
423 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetAdjust()) );
425 default: ;//prevent warning
431 sal_uInt16
SvxAdjustItem::GetValueCount() const
433 return sal_uInt16(SvxAdjust::End
); // SvxAdjust::BlockLine + 1
436 OUString
SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos
)
438 static TranslateId RID_SVXITEMS_ADJUST
[] =
440 RID_SVXITEMS_ADJUST_LEFT
,
441 RID_SVXITEMS_ADJUST_RIGHT
,
442 RID_SVXITEMS_ADJUST_BLOCK
,
443 RID_SVXITEMS_ADJUST_CENTER
,
444 RID_SVXITEMS_ADJUST_BLOCKLINE
446 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_ADJUST
) - 1 == size_t(SvxAdjust::BlockLine
), "unexpected size");
447 assert(nPos
<= sal_uInt16(SvxAdjust::BlockLine
) && "enum overflow!");
448 return EditResId(RID_SVXITEMS_ADJUST
[nPos
]);
451 sal_uInt16
SvxAdjustItem::GetEnumValue() const
453 return static_cast<sal_uInt16
>(GetAdjust());
457 void SvxAdjustItem::SetEnumValue( sal_uInt16 nVal
)
459 SetAdjust( static_cast<SvxAdjust
>(nVal
) );
463 // class SvxWidowsItem ---------------------------------------------------
465 SvxWidowsItem::SvxWidowsItem(const sal_uInt8 nL
, const sal_uInt16 nId
) :
466 SfxByteItem( nId
, nL
)
470 SvxWidowsItem
* SvxWidowsItem::Clone( SfxItemPool
* ) const
472 return new SvxWidowsItem( *this );
475 bool SvxWidowsItem::GetPresentation
477 SfxItemPresentation ePres
,
478 MapUnit
/*eCoreUnit*/,
479 MapUnit
/*ePresUnit*/,
480 OUString
& rText
, const IntlWrapper
&
485 case SfxItemPresentation::Nameless
:
487 rText
= EditResId(RID_SVXITEMS_LINES
);
491 case SfxItemPresentation::Complete
:
493 rText
= EditResId(RID_SVXITEMS_WIDOWS_COMPLETE
) + " " + EditResId(RID_SVXITEMS_LINES
);
499 SAL_WARN( "editeng.items", "SvxWidowsItem::GetPresentation(): unknown SfxItemPresentation" );
503 rText
= rText
.replaceFirst( "%1", OUString::number( GetValue() ) );
507 // class SvxOrphansItem --------------------------------------------------
509 SvxOrphansItem::SvxOrphansItem(const sal_uInt8 nL
, const sal_uInt16 nId
) :
510 SfxByteItem( nId
, nL
)
514 SvxOrphansItem
* SvxOrphansItem::Clone( SfxItemPool
* ) const
516 return new SvxOrphansItem( *this );
519 bool SvxOrphansItem::GetPresentation
521 SfxItemPresentation ePres
,
522 MapUnit
/*eCoreUnit*/,
523 MapUnit
/*ePresUnit*/,
524 OUString
& rText
, const IntlWrapper
&
529 case SfxItemPresentation::Nameless
:
531 rText
= EditResId(RID_SVXITEMS_LINES
);
535 case SfxItemPresentation::Complete
:
537 rText
= EditResId(RID_SVXITEMS_ORPHANS_COMPLETE
) + " " + EditResId(RID_SVXITEMS_LINES
);
543 SAL_WARN( "editeng.items", "SvxOrphansItem::GetPresentation(): unknown SfxItemPresentation" );
547 rText
= rText
.replaceFirst( "%1", OUString::number( GetValue() ) );
551 // class SvxHyphenZoneItem -----------------------------------------------
553 SvxHyphenZoneItem::SvxHyphenZoneItem( const bool bHyph
, const sal_uInt16 nId
) :
557 bNoCapsHyphenation(false),
558 bNoLastWordHyphenation(false),
568 bool SvxHyphenZoneItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
570 nMemberId
&= ~CONVERT_TWIPS
;
576 case MID_HYPHEN_MIN_LEAD
:
577 rVal
<<= static_cast<sal_Int16
>(nMinLead
);
579 case MID_HYPHEN_MIN_TRAIL
:
580 rVal
<<= static_cast<sal_Int16
>(nMinTrail
);
582 case MID_HYPHEN_MAX_HYPHENS
:
583 rVal
<<= static_cast<sal_Int16
>(nMaxHyphens
);
585 case MID_HYPHEN_NO_CAPS
:
586 rVal
<<= bNoCapsHyphenation
;
588 case MID_HYPHEN_NO_LAST_WORD
:
589 rVal
<<= bNoLastWordHyphenation
;
591 case MID_HYPHEN_MIN_WORD_LENGTH
:
592 rVal
<<= static_cast<sal_Int16
>(nMinWordLength
);
594 case MID_HYPHEN_ZONE
:
595 rVal
<<= static_cast<sal_Int16
>(nTextHyphenZone
);
601 bool SvxHyphenZoneItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
603 nMemberId
&= ~CONVERT_TWIPS
;
604 sal_Int16 nNewVal
= 0;
606 if( nMemberId
!= MID_IS_HYPHEN
&& nMemberId
!= MID_HYPHEN_NO_CAPS
&&
607 nMemberId
!= MID_HYPHEN_NO_LAST_WORD
)
609 if(!(rVal
>>= nNewVal
))
616 bHyphen
= Any2Bool(rVal
);
618 case MID_HYPHEN_MIN_LEAD
:
619 nMinLead
= static_cast<sal_uInt8
>(nNewVal
);
621 case MID_HYPHEN_MIN_TRAIL
:
622 nMinTrail
= static_cast<sal_uInt8
>(nNewVal
);
624 case MID_HYPHEN_MAX_HYPHENS
:
625 nMaxHyphens
= static_cast<sal_uInt8
>(nNewVal
);
627 case MID_HYPHEN_NO_CAPS
:
628 bNoCapsHyphenation
= Any2Bool(rVal
);
630 case MID_HYPHEN_NO_LAST_WORD
:
631 bNoLastWordHyphenation
= Any2Bool(rVal
);
633 case MID_HYPHEN_MIN_WORD_LENGTH
:
634 nMinWordLength
= static_cast<sal_uInt8
>(nNewVal
);
636 case MID_HYPHEN_ZONE
:
637 nTextHyphenZone
= nNewVal
;
644 bool SvxHyphenZoneItem::operator==( const SfxPoolItem
& rAttr
) const
646 assert(SfxPoolItem::operator==(rAttr
));
648 const SvxHyphenZoneItem
& rItem
= static_cast<const SvxHyphenZoneItem
&>(rAttr
);
649 return ( rItem
.bHyphen
== bHyphen
650 && rItem
.bNoCapsHyphenation
== bNoCapsHyphenation
651 && rItem
.bNoLastWordHyphenation
== bNoLastWordHyphenation
652 && rItem
.bPageEnd
== bPageEnd
653 && rItem
.nMinLead
== nMinLead
654 && rItem
.nMinTrail
== nMinTrail
655 && rItem
.nMaxHyphens
== nMaxHyphens
656 && rItem
.nMinWordLength
== nMinWordLength
657 && rItem
.nTextHyphenZone
== nTextHyphenZone
);
660 SvxHyphenZoneItem
* SvxHyphenZoneItem::Clone( SfxItemPool
* ) const
662 return new SvxHyphenZoneItem( *this );
665 bool SvxHyphenZoneItem::GetPresentation
667 SfxItemPresentation ePres
,
670 OUString
& rText
, const IntlWrapper
& rIntl
673 OUString
cpDelimTmp(cpDelim
);
676 case SfxItemPresentation::Nameless
:
678 TranslateId pId
= RID_SVXITEMS_HYPHEN_FALSE
;
681 pId
= RID_SVXITEMS_HYPHEN_TRUE
;
682 rText
= EditResId(pId
) + cpDelimTmp
;
683 pId
= RID_SVXITEMS_PAGE_END_FALSE
;
686 pId
= RID_SVXITEMS_PAGE_END_TRUE
;
687 rText
+= EditResId(pId
) + cpDelimTmp
+
688 OUString::number( nMinLead
) + cpDelimTmp
+
689 OUString::number( nMinTrail
) + cpDelimTmp
+
690 OUString::number( nMaxHyphens
) + cpDelimTmp
+
691 OUString::number( nMinWordLength
) + cpDelimTmp
+
692 GetMetricText( nTextHyphenZone
, eCoreUnit
, ePresUnit
, &rIntl
) +
693 " " + EditResId(GetMetricId(ePresUnit
));
695 if ( bNoCapsHyphenation
)
696 rText
+= cpDelimTmp
+ EditResId(RID_SVXITEMS_HYPHEN_NO_CAPS_TRUE
);
698 if ( bNoLastWordHyphenation
)
699 rText
+= cpDelimTmp
+ EditResId(RID_SVXITEMS_HYPHEN_LAST_WORD_TRUE
);
703 case SfxItemPresentation::Complete
:
705 TranslateId pId
= RID_SVXITEMS_HYPHEN_FALSE
;
708 pId
= RID_SVXITEMS_HYPHEN_TRUE
;
709 rText
= EditResId(pId
) + cpDelimTmp
;
710 pId
= RID_SVXITEMS_PAGE_END_FALSE
;
713 pId
= RID_SVXITEMS_PAGE_END_TRUE
;
714 rText
+= EditResId(pId
) +
716 EditResId(RID_SVXITEMS_HYPHEN_MINLEAD
).replaceAll("%1", OUString::number(nMinLead
)) +
718 EditResId(RID_SVXITEMS_HYPHEN_MINTRAIL
).replaceAll("%1", OUString::number(nMinTrail
)) +
720 EditResId(RID_SVXITEMS_HYPHEN_MAX
).replaceAll("%1", OUString::number(nMaxHyphens
)) +
722 EditResId(RID_SVXITEMS_HYPHEN_MINWORDLEN
).replaceAll("%1", OUString::number(nMinWordLength
));
724 if ( nTextHyphenZone
> 0 )
726 rText
+= cpDelimTmp
+ EditResId(RID_SVXITEMS_HYPHEN_ZONE
) +
727 GetMetricText( nTextHyphenZone
, eCoreUnit
, ePresUnit
, &rIntl
) +
728 " " + EditResId(GetMetricId(ePresUnit
));
731 if ( bNoCapsHyphenation
)
732 rText
+= cpDelimTmp
+ EditResId(RID_SVXITEMS_HYPHEN_NO_CAPS_TRUE
);
734 if ( bNoLastWordHyphenation
)
735 rText
+= cpDelimTmp
+ EditResId(RID_SVXITEMS_HYPHEN_LAST_WORD_TRUE
);
739 default: ;//prevent warning
745 // class SvxTabStop ------------------------------------------------------
747 SvxTabStop::SvxTabStop()
750 eAdjustment
= SvxTabAdjust::Left
;
751 m_cDecimal
= cDfltDecimalChar
;
752 cFill
= cDfltFillChar
;
756 SvxTabStop::SvxTabStop( const sal_Int32 nPos
, const SvxTabAdjust eAdjst
,
757 const sal_Unicode cDec
, const sal_Unicode cFil
)
760 eAdjustment
= eAdjst
;
765 void SvxTabStop::fillDecimal() const
767 if ( cDfltDecimalChar
== m_cDecimal
)
768 m_cDecimal
= SvtSysLocale().GetLocaleData().getNumDecimalSep()[0];
771 void SvxTabStop::dumpAsXml(xmlTextWriterPtr pWriter
) const
773 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTabStop"));
774 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nTabPos"),
775 BAD_CAST(OString::number(nTabPos
).getStr()));
776 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("eAdjustment"),
777 BAD_CAST(OString::number(static_cast<int>(eAdjustment
)).getStr()));
778 (void)xmlTextWriterEndElement(pWriter
);
781 // class SvxTabStopItem --------------------------------------------------
783 SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich
) :
784 SfxPoolItem( _nWhich
)
786 const sal_uInt16 nTabs
= SVX_TAB_DEFCOUNT
, nDist
= SVX_TAB_DEFDIST
;
787 const SvxTabAdjust eAdjst
= SvxTabAdjust::Default
;
789 for (sal_uInt16 i
= 0; i
< nTabs
; ++i
)
791 SvxTabStop
aTab( (i
+ 1) * nDist
, eAdjst
);
792 maTabStops
.insert( aTab
);
797 SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs
,
798 const sal_uInt16 nDist
,
799 const SvxTabAdjust eAdjst
,
800 sal_uInt16 _nWhich
) :
801 SfxPoolItem( _nWhich
)
803 for ( sal_uInt16 i
= 0; i
< nTabs
; ++i
)
805 SvxTabStop
aTab( (i
+ 1) * nDist
, eAdjst
);
806 maTabStops
.insert( aTab
);
811 sal_uInt16
SvxTabStopItem::GetPos( const SvxTabStop
& rTab
) const
813 SvxTabStopArr::const_iterator it
= maTabStops
.find( rTab
);
814 return it
!= maTabStops
.end() ? it
- maTabStops
.begin() : SVX_TAB_NOTFOUND
;
818 sal_uInt16
SvxTabStopItem::GetPos( const sal_Int32 nPos
) const
820 SvxTabStopArr::const_iterator it
= maTabStops
.find( SvxTabStop( nPos
) );
821 return it
!= maTabStops
.end() ? it
- maTabStops
.begin() : SVX_TAB_NOTFOUND
;
824 void SvxTabStopItem::SetDefaultDistance(sal_Int32 nDefaultDistance
)
826 mnDefaultDistance
= nDefaultDistance
;
829 sal_Int32
SvxTabStopItem::GetDefaultDistance() const
831 return mnDefaultDistance
;
834 bool SvxTabStopItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
836 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
837 nMemberId
&= ~CONVERT_TWIPS
;
842 sal_uInt16 nCount
= Count();
843 uno::Sequence
< style::TabStop
> aSeq(nCount
);
844 style::TabStop
* pArr
= aSeq
.getArray();
845 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
847 const SvxTabStop
& rTab
= (*this)[i
];
848 pArr
[i
].Position
= bConvert
? convertTwipToMm100(rTab
.GetTabPos()) : rTab
.GetTabPos();
849 switch(rTab
.GetAdjustment())
851 case SvxTabAdjust::Left
: pArr
[i
].Alignment
= style::TabAlign_LEFT
; break;
852 case SvxTabAdjust::Right
: pArr
[i
].Alignment
= style::TabAlign_RIGHT
; break;
853 case SvxTabAdjust::Decimal
: pArr
[i
].Alignment
= style::TabAlign_DECIMAL
; break;
854 case SvxTabAdjust::Center
: pArr
[i
].Alignment
= style::TabAlign_CENTER
; break;
855 default: //SvxTabAdjust::Default
856 pArr
[i
].Alignment
= style::TabAlign_DEFAULT
;
859 pArr
[i
].DecimalChar
= rTab
.GetDecimal();
860 pArr
[i
].FillChar
= rTab
.GetFill();
867 const SvxTabStop
&rTab
= maTabStops
.front();
868 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(rTab
.GetTabPos()) : rTab
.GetTabPos());
871 case MID_TABSTOP_DEFAULT_DISTANCE
:
873 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(mnDefaultDistance
) : mnDefaultDistance
);
880 bool SvxTabStopItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
882 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
883 nMemberId
&= ~CONVERT_TWIPS
;
888 uno::Sequence
< style::TabStop
> aSeq
;
891 uno::Sequence
< uno::Sequence
< uno::Any
> > aAnySeq
;
892 if (!(rVal
>>= aAnySeq
))
894 auto aAnySeqRange
= asNonConstRange(aAnySeq
);
895 sal_Int32 nLength
= aAnySeq
.getLength();
896 aSeq
.realloc( nLength
);
897 auto pSeq
= aSeq
.getArray();
898 for ( sal_Int32 n
=0; n
<nLength
; n
++ )
900 uno::Sequence
< uno::Any
>& rAnySeq
= aAnySeqRange
[n
];
901 if ( rAnySeq
.getLength() == 4 )
903 if (!(rAnySeq
[0] >>= pSeq
[n
].Position
)) return false;
904 if (!(rAnySeq
[1] >>= pSeq
[n
].Alignment
))
907 if (rAnySeq
[1] >>= nVal
)
908 pSeq
[n
].Alignment
= static_cast<css::style::TabAlign
>(nVal
);
912 if (!(rAnySeq
[2] >>= pSeq
[n
].DecimalChar
))
915 if ( (rAnySeq
[2] >>= aVal
) && aVal
.getLength() == 1 )
916 pSeq
[n
].DecimalChar
= aVal
.toChar();
920 if (!(rAnySeq
[3] >>= pSeq
[n
].FillChar
))
923 if ( (rAnySeq
[3] >>= aVal
) && aVal
.getLength() == 1 )
924 pSeq
[n
].FillChar
= aVal
.toChar();
935 const style::TabStop
* pArr
= aSeq
.getConstArray();
936 const sal_uInt16 nCount
= static_cast<sal_uInt16
>(aSeq
.getLength());
937 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
939 SvxTabAdjust eAdjust
= SvxTabAdjust::Default
;
940 switch(pArr
[i
].Alignment
)
942 case style::TabAlign_LEFT
: eAdjust
= SvxTabAdjust::Left
; break;
943 case style::TabAlign_CENTER
: eAdjust
= SvxTabAdjust::Center
; break;
944 case style::TabAlign_RIGHT
: eAdjust
= SvxTabAdjust::Right
; break;
945 case style::TabAlign_DECIMAL
: eAdjust
= SvxTabAdjust::Decimal
; break;
946 default: ;//prevent warning
948 sal_Unicode cFill
= pArr
[i
].FillChar
;
949 sal_Unicode cDecimal
= pArr
[i
].DecimalChar
;
950 SvxTabStop
aTab( bConvert
? o3tl::toTwips(pArr
[i
].Position
, o3tl::Length::mm100
) : pArr
[i
].Position
,
960 sal_Int32 nNewPos
= 0;
961 if (!(rVal
>>= nNewPos
) )
964 nNewPos
= o3tl::toTwips(nNewPos
, o3tl::Length::mm100
);
967 const SvxTabStop
& rTab
= maTabStops
.front();
968 SvxTabStop
aNewTab ( nNewPos
, rTab
.GetAdjustment(), rTab
.GetDecimal(), rTab
.GetFill() );
973 case MID_TABSTOP_DEFAULT_DISTANCE
:
975 sal_Int32 nNewDefaultDistance
= 0;
976 if (!(rVal
>>= nNewDefaultDistance
))
979 nNewDefaultDistance
= o3tl::toTwips(nNewDefaultDistance
, o3tl::Length::mm100
);
980 if (nNewDefaultDistance
< 0)
982 mnDefaultDistance
= nNewDefaultDistance
;
990 bool SvxTabStopItem::operator==( const SfxPoolItem
& rAttr
) const
992 assert(SfxPoolItem::operator==(rAttr
));
994 const SvxTabStopItem
& rTSI
= static_cast<const SvxTabStopItem
&>(rAttr
);
996 if ( mnDefaultDistance
!= rTSI
.GetDefaultDistance() )
999 if ( Count() != rTSI
.Count() )
1002 for ( sal_uInt16 i
= 0; i
< Count(); ++i
)
1003 if( (*this)[i
] != rTSI
[i
] )
1008 SvxTabStopItem
* SvxTabStopItem::Clone( SfxItemPool
* ) const
1010 return new SvxTabStopItem( *this );
1013 bool SvxTabStopItem::GetPresentation
1015 SfxItemPresentation ePres
,
1018 OUString
& rText
, const IntlWrapper
& rIntl
1022 // TODO also consider mnDefaultTabDistance here
1024 bool bComma
= false;
1026 for ( sal_uInt16 i
= 0; i
< Count(); ++i
)
1028 if ( SvxTabAdjust::Default
!= ((*this)[i
]).GetAdjustment() )
1032 rText
+= GetMetricText(
1033 ((*this)[i
]).GetTabPos(), eCoreUnit
, ePresUnit
, &rIntl
);
1034 if ( SfxItemPresentation::Complete
== ePres
)
1036 rText
+= " " + EditResId(GetMetricId(ePresUnit
));
1045 bool SvxTabStopItem::Insert( const SvxTabStop
& rTab
)
1047 sal_uInt16 nTabPos
= GetPos(rTab
);
1048 if(SVX_TAB_NOTFOUND
!= nTabPos
)
1050 return maTabStops
.insert( rTab
).second
;
1053 void SvxTabStopItem::Insert( const SvxTabStopItem
* pTabs
)
1055 for( sal_uInt16 i
= 0; i
< pTabs
->Count(); i
++ )
1057 const SvxTabStop
& rTab
= (*pTabs
)[i
];
1058 sal_uInt16 nTabPos
= GetPos(rTab
);
1059 if(SVX_TAB_NOTFOUND
!= nTabPos
)
1062 for( sal_uInt16 i
= 0; i
< pTabs
->Count(); i
++ )
1064 maTabStops
.insert( (*pTabs
)[i
] );
1068 void SvxTabStopItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1070 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTabStopItem"));
1071 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("mnDefaultDistance"),
1072 BAD_CAST(OString::number(mnDefaultDistance
).getStr()));
1073 for (const auto& rTabStop
: maTabStops
)
1074 rTabStop
.dumpAsXml(pWriter
);
1075 (void)xmlTextWriterEndElement(pWriter
);
1078 // class SvxFormatSplitItem -------------------------------------------------
1079 SvxFormatSplitItem::~SvxFormatSplitItem()
1083 SvxFormatSplitItem
* SvxFormatSplitItem::Clone( SfxItemPool
* ) const
1085 return new SvxFormatSplitItem( *this );
1088 bool SvxFormatSplitItem::GetPresentation
1090 SfxItemPresentation
/*ePres*/,
1091 MapUnit
/*eCoreUnit*/,
1092 MapUnit
/*ePresUnit*/,
1093 OUString
& rText
, const IntlWrapper
&
1096 TranslateId pId
= RID_SVXITEMS_FMTSPLIT_FALSE
;
1099 pId
= RID_SVXITEMS_FMTSPLIT_TRUE
;
1100 rText
= EditResId(pId
);
1104 SvxPageModelItem
* SvxPageModelItem::Clone( SfxItemPool
* ) const
1106 return new SvxPageModelItem( *this );
1109 bool SvxPageModelItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1111 nMemberId
&= ~CONVERT_TWIPS
;
1113 switch ( nMemberId
)
1115 case MID_AUTO
: rVal
<<= bAuto
; break;
1116 case MID_NAME
: rVal
<<= GetValue(); break;
1117 default: OSL_FAIL("Wrong MemberId!"); return false;
1123 bool SvxPageModelItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
1125 nMemberId
&= ~CONVERT_TWIPS
;
1128 switch ( nMemberId
)
1130 case MID_AUTO
: bRet
= ( rVal
>>= bAuto
); break;
1131 case MID_NAME
: bRet
= ( rVal
>>= aStr
); if ( bRet
) SetValue(aStr
); break;
1132 default: OSL_FAIL("Wrong MemberId!"); return false;
1138 bool SvxPageModelItem::operator==( const SfxPoolItem
& rAttr
) const
1140 return SfxStringItem::operator==(rAttr
) &&
1141 bAuto
== static_cast<const SvxPageModelItem
&>( rAttr
).bAuto
;
1144 bool SvxPageModelItem::GetPresentation
1146 SfxItemPresentation ePres
,
1147 MapUnit
/*eCoreUnit*/,
1148 MapUnit
/*ePresUnit*/,
1149 OUString
& rText
, const IntlWrapper
&
1153 bool bSet
= !GetValue().isEmpty();
1157 case SfxItemPresentation::Nameless
:
1162 case SfxItemPresentation::Complete
:
1165 rText
= EditResId(RID_SVXITEMS_PAGEMODEL_COMPLETE
) + GetValue();
1168 default: ;//prevent warning
1174 SvxScriptSpaceItem::SvxScriptSpaceItem( bool bOn
, const sal_uInt16 nId
)
1175 : SfxBoolItem( nId
, bOn
)
1179 SvxScriptSpaceItem
* SvxScriptSpaceItem::Clone( SfxItemPool
* ) const
1181 return new SvxScriptSpaceItem( *this );
1184 bool SvxScriptSpaceItem::GetPresentation(
1185 SfxItemPresentation
/*ePres*/,
1186 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1187 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1189 rText
= EditResId( !GetValue()
1190 ? RID_SVXITEMS_SCRPTSPC_OFF
1191 : RID_SVXITEMS_SCRPTSPC_ON
);
1196 SvxHangingPunctuationItem::SvxHangingPunctuationItem(
1197 bool bOn
, const sal_uInt16 nId
)
1198 : SfxBoolItem( nId
, bOn
)
1202 SvxHangingPunctuationItem
* SvxHangingPunctuationItem::Clone( SfxItemPool
* ) const
1204 return new SvxHangingPunctuationItem( *this );
1207 bool SvxHangingPunctuationItem::GetPresentation(
1208 SfxItemPresentation
/*ePres*/,
1209 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1210 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1212 rText
= EditResId( !GetValue()
1213 ? RID_SVXITEMS_HNGPNCT_OFF
1214 : RID_SVXITEMS_HNGPNCT_ON
);
1219 SvxForbiddenRuleItem::SvxForbiddenRuleItem(
1220 bool bOn
, const sal_uInt16 nId
)
1221 : SfxBoolItem( nId
, bOn
)
1225 SvxForbiddenRuleItem
* SvxForbiddenRuleItem::Clone( SfxItemPool
* ) const
1227 return new SvxForbiddenRuleItem( *this );
1230 bool SvxForbiddenRuleItem::GetPresentation(
1231 SfxItemPresentation
/*ePres*/,
1232 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1233 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1235 rText
= EditResId( !GetValue()
1236 ? RID_SVXITEMS_FORBIDDEN_RULE_OFF
1237 : RID_SVXITEMS_FORBIDDEN_RULE_ON
);
1241 /*************************************************************************
1242 |* class SvxParaVertAlignItem
1243 *************************************************************************/
1245 SvxParaVertAlignItem::SvxParaVertAlignItem( Align nValue
,
1246 TypedWhichId
<SvxParaVertAlignItem
> nW
)
1247 : SfxUInt16Item( nW
, static_cast<sal_uInt16
>(nValue
) )
1251 SvxParaVertAlignItem
* SvxParaVertAlignItem::Clone( SfxItemPool
* ) const
1253 return new SvxParaVertAlignItem( *this );
1256 bool SvxParaVertAlignItem::GetPresentation(
1257 SfxItemPresentation
/*ePres*/,
1258 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1259 OUString
&rText
, const IntlWrapper
& ) const
1262 switch( GetValue() )
1264 case Align::Automatic
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_AUTO
; break;
1265 case Align::Top
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_TOP
; break;
1266 case Align::Center
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_CENTER
; break;
1267 case Align::Bottom
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_BOTTOM
; break;
1268 default: pTmp
= RID_SVXITEMS_PARAVERTALIGN_BASELINE
; break;
1270 rText
= EditResId(pTmp
);
1274 bool SvxParaVertAlignItem::QueryValue( css::uno::Any
& rVal
,
1275 sal_uInt8
/*nMemberId*/ ) const
1277 rVal
<<= static_cast<sal_Int16
>(GetValue());
1281 bool SvxParaVertAlignItem::PutValue( const css::uno::Any
& rVal
,
1282 sal_uInt8
/*nMemberId*/ )
1284 sal_Int16 nVal
= sal_Int16();
1285 if((rVal
>>= nVal
) && nVal
>=0 && nVal
<= sal_uInt16(Align::Bottom
) )
1287 SetValue( static_cast<Align
>(nVal
) );
1294 SvxParaGridItem::SvxParaGridItem( bool bOn
, const sal_uInt16 nId
)
1295 : SfxBoolItem( nId
, bOn
)
1299 SvxParaGridItem
* SvxParaGridItem::Clone( SfxItemPool
* ) const
1301 return new SvxParaGridItem( *this );
1304 bool SvxParaGridItem::GetPresentation(
1305 SfxItemPresentation
/*ePres*/,
1306 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1307 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1309 rText
= GetValue() ?
1310 EditResId( RID_SVXITEMS_PARASNAPTOGRID_ON
) :
1311 EditResId( RID_SVXITEMS_PARASNAPTOGRID_OFF
);
1317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */