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/fileformat.h>
26 #include <comphelper/extract.hxx>
27 #include <osl/diagnose.h>
28 #include <unotools/localedatawrapper.hxx>
29 #include <unotools/syslocale.hxx>
30 #include <tools/mapunit.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/editids.hrc>
51 #include <editeng/itemtype.hxx>
52 #include <editeng/eerdll.hxx>
53 #include <editeng/paperinf.hxx>
54 #include <vcl/svapp.hxx>
57 using namespace ::com::sun::star
;
60 SfxPoolItem
* SvxLineSpacingItem::CreateDefault() { return new SvxLineSpacingItem(LINE_SPACE_DEFAULT_HEIGHT
, 0);}
61 SfxPoolItem
* SvxAdjustItem::CreateDefault() { return new SvxAdjustItem(SvxAdjust::Left
, 0);}
62 SfxPoolItem
* SvxWidowsItem::CreateDefault() { return new SvxWidowsItem(0, 0);}
63 SfxPoolItem
* SvxOrphansItem::CreateDefault() { return new SvxOrphansItem(0, 0);}
64 SfxPoolItem
* SvxHyphenZoneItem::CreateDefault() { return new SvxHyphenZoneItem(false, 0);}
65 SfxPoolItem
* SvxTabStopItem::CreateDefault() { return new SvxTabStopItem(0);}
66 SfxPoolItem
* SvxFormatSplitItem::CreateDefault() { return new SvxFormatSplitItem(false, 0);}
67 SfxPoolItem
* SvxPageModelItem::CreateDefault() { return new SvxPageModelItem(0);}
68 SfxPoolItem
* SvxParaVertAlignItem::CreateDefault() { return new SvxParaVertAlignItem(Align::Automatic
, 0);}
71 enum class SvxSpecialLineSpace
81 SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight
, const sal_uInt16 nId
)
82 : SfxEnumItemInterface( nId
)
86 nLineHeight
= nHeight
;
87 eLineSpaceRule
= SvxLineSpaceRule::Auto
;
88 eInterLineSpaceRule
= SvxInterLineSpaceRule::Off
;
92 bool SvxLineSpacingItem::operator==( const SfxPoolItem
& rAttr
) const
94 assert(SfxPoolItem::operator==(rAttr
));
96 const SvxLineSpacingItem
& rLineSpace
= static_cast<const SvxLineSpacingItem
&>(rAttr
);
98 // Same Linespacing Rule?
99 (eLineSpaceRule
== rLineSpace
.eLineSpaceRule
)
100 // For maximum and minimum Linespacing be the size must coincide.
101 && (eLineSpaceRule
== SvxLineSpaceRule::Auto
||
102 nLineHeight
== rLineSpace
.nLineHeight
)
103 // Same Linespacing Rule?
104 && ( eInterLineSpaceRule
== rLineSpace
.eInterLineSpaceRule
)
105 // Either set proportional or additive.
106 && (( eInterLineSpaceRule
== SvxInterLineSpaceRule::Off
)
107 || (eInterLineSpaceRule
== SvxInterLineSpaceRule::Prop
108 && nPropLineSpace
== rLineSpace
.nPropLineSpace
)
109 || (eInterLineSpaceRule
== SvxInterLineSpaceRule::Fix
110 && (nInterLineSpace
== rLineSpace
.nInterLineSpace
)));
113 /* Who does still know why the LineSpacingItem is so complicated?
114 We can not use it for UNO since there are only two values:
115 - a sal_uInt16 for the mode
116 - a sal_uInt32 for all values (distance, height, rel. detail)
118 bool SvxLineSpacingItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
120 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
121 nMemberId
&= ~CONVERT_TWIPS
;
123 style::LineSpacing aLSp
;
124 switch( eLineSpaceRule
)
126 case SvxLineSpaceRule::Auto
:
127 if(eInterLineSpaceRule
== SvxInterLineSpaceRule::Fix
)
129 aLSp
.Mode
= style::LineSpacingMode::LEADING
;
130 aLSp
.Height
= ( bConvert
? static_cast<short>(convertTwipToMm100(nInterLineSpace
)) : nInterLineSpace
);
132 else if(eInterLineSpaceRule
== SvxInterLineSpaceRule::Off
)
134 aLSp
.Mode
= style::LineSpacingMode::PROP
;
139 aLSp
.Mode
= style::LineSpacingMode::PROP
;
140 aLSp
.Height
= nPropLineSpace
;
143 case SvxLineSpaceRule::Fix
:
144 case SvxLineSpaceRule::Min
:
145 aLSp
.Mode
= eLineSpaceRule
== SvxLineSpaceRule::Fix
? style::LineSpacingMode::FIX
: style::LineSpacingMode::MINIMUM
;
146 aLSp
.Height
= ( bConvert
? static_cast<short>(convertTwipToMm100(nLineHeight
)) : nLineHeight
);
149 ;//prevent warning about SvxLineSpaceRule::End
154 case 0 : rVal
<<= aLSp
; break;
155 case MID_LINESPACE
: rVal
<<= aLSp
.Mode
; break;
156 case MID_HEIGHT
: rVal
<<= aLSp
.Height
; break;
157 default: OSL_FAIL("Wrong MemberId!"); break;
163 bool SvxLineSpacingItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
165 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
166 nMemberId
&= ~CONVERT_TWIPS
;
168 // fill with current data
169 style::LineSpacing aLSp
;
171 bool bRet
= QueryValue( aAny
, bConvert
? CONVERT_TWIPS
: 0 ) && ( aAny
>>= aLSp
);
176 case 0 : bRet
= (rVal
>>= aLSp
); break;
177 case MID_LINESPACE
: bRet
= (rVal
>>= aLSp
.Mode
); break;
178 case MID_HEIGHT
: bRet
= (rVal
>>= aLSp
.Height
); break;
179 default: OSL_FAIL("Wrong MemberId!"); break;
184 nLineHeight
= aLSp
.Height
;
187 case style::LineSpacingMode::LEADING
:
189 eInterLineSpaceRule
= SvxInterLineSpaceRule::Fix
;
190 eLineSpaceRule
= SvxLineSpaceRule::Auto
;
191 nInterLineSpace
= aLSp
.Height
;
193 nInterLineSpace
= static_cast<short>(convertMm100ToTwip(nInterLineSpace
));
197 case style::LineSpacingMode::PROP
:
199 eLineSpaceRule
= SvxLineSpaceRule::Auto
;
200 nPropLineSpace
= static_cast<sal_Int16
>(aLSp
.Height
);
201 if(100 == aLSp
.Height
)
202 eInterLineSpaceRule
= SvxInterLineSpaceRule::Off
;
204 eInterLineSpaceRule
= SvxInterLineSpaceRule::Prop
;
207 case style::LineSpacingMode::FIX
:
208 case style::LineSpacingMode::MINIMUM
:
210 eInterLineSpaceRule
= SvxInterLineSpaceRule::Off
;
211 eLineSpaceRule
= aLSp
.Mode
== style::LineSpacingMode::FIX
? SvxLineSpaceRule::Fix
: SvxLineSpaceRule::Min
;
212 nLineHeight
= aLSp
.Height
;
214 nLineHeight
= static_cast<sal_uInt16
>(convertMm100ToTwip(nLineHeight
));
224 SfxPoolItem
* SvxLineSpacingItem::Clone( SfxItemPool
* ) const
226 return new SvxLineSpacingItem( *this );
230 bool SvxLineSpacingItem::GetPresentation
232 SfxItemPresentation
/*ePres*/,
233 MapUnit
/*eCoreUnit*/,
234 MapUnit
/*ePresUnit*/,
235 OUString
& rText
, const IntlWrapper
&
239 rText
= "SvxLineSpacingItem";
247 sal_uInt16
SvxLineSpacingItem::GetValueCount() const
249 return sal_uInt16(SvxSpecialLineSpace::End
); // SvxSpecialLineSpace::TwoLines + 1
253 sal_uInt16
SvxLineSpacingItem::GetEnumValue() const
255 SvxSpecialLineSpace nVal
;
256 switch ( nPropLineSpace
)
258 case 100: nVal
= SvxSpecialLineSpace::OneLine
; break;
259 case 150: nVal
= SvxSpecialLineSpace::OnePointFiveLines
; break;
260 case 200: nVal
= SvxSpecialLineSpace::TwoLines
; break;
261 default: nVal
= SvxSpecialLineSpace::User
; break;
263 return static_cast<sal_uInt16
>(nVal
);
267 void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal
)
269 switch ( static_cast<SvxSpecialLineSpace
>(nVal
) )
271 case SvxSpecialLineSpace::OneLine
: nPropLineSpace
= 100; break;
272 case SvxSpecialLineSpace::OnePointFiveLines
: nPropLineSpace
= 150; break;
273 case SvxSpecialLineSpace::TwoLines
: nPropLineSpace
= 200; break;
278 // class SvxAdjustItem ---------------------------------------------------
280 SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst
, const sal_uInt16 nId
)
281 : SfxEnumItemInterface( nId
),
282 bOneBlock( false ), bLastCenter( false ), bLastBlock( false )
288 bool SvxAdjustItem::operator==( const SfxPoolItem
& rAttr
) const
290 assert(SfxPoolItem::operator==(rAttr
));
292 const SvxAdjustItem
& rItem
= static_cast<const SvxAdjustItem
&>(rAttr
);
293 return GetAdjust() == rItem
.GetAdjust() &&
294 bOneBlock
== rItem
.bOneBlock
&&
295 bLastCenter
== rItem
.bLastCenter
&&
296 bLastBlock
== rItem
.bLastBlock
;
299 bool SvxAdjustItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
301 nMemberId
&= ~CONVERT_TWIPS
;
304 case MID_PARA_ADJUST
: rVal
<<= static_cast<sal_Int16
>(GetAdjust()); break;
305 case MID_LAST_LINE_ADJUST
: rVal
<<= static_cast<sal_Int16
>(GetLastBlock()); break;
306 case MID_EXPAND_SINGLE
:
311 default: ;//prevent warning
316 bool SvxAdjustItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
318 nMemberId
&= ~CONVERT_TWIPS
;
321 case MID_PARA_ADJUST
:
322 case MID_LAST_LINE_ADJUST
:
324 sal_Int32 eVal
= - 1;
325 ::cppu::enum2int(eVal
,rVal
);
326 if(eVal
>= 0 && eVal
<= 4)
328 SvxAdjust eAdjust
= static_cast<SvxAdjust
>(eVal
);
329 if(MID_LAST_LINE_ADJUST
== nMemberId
&&
330 eAdjust
!= SvxAdjust::Left
&&
331 eAdjust
!= SvxAdjust::Block
&&
332 eAdjust
!= SvxAdjust::Center
)
334 nMemberId
== MID_PARA_ADJUST
? SetAdjust(eAdjust
) : SetLastBlock(eAdjust
);
338 case MID_EXPAND_SINGLE
:
339 bOneBlock
= Any2Bool(rVal
);
346 SfxPoolItem
* SvxAdjustItem::Clone( SfxItemPool
* ) const
348 return new SvxAdjustItem( *this );
352 bool SvxAdjustItem::GetPresentation
354 SfxItemPresentation ePres
,
355 MapUnit
/*eCoreUnit*/,
356 MapUnit
/*ePresUnit*/,
357 OUString
& rText
, const IntlWrapper
&
362 case SfxItemPresentation::Nameless
:
363 case SfxItemPresentation::Complete
:
364 rText
= GetValueTextByPos( static_cast<sal_uInt16
>(GetAdjust()) );
366 default: ;//prevent warning
372 sal_uInt16
SvxAdjustItem::GetValueCount() const
374 return sal_uInt16(SvxAdjust::End
); // SvxAdjust::BlockLine + 1
377 OUString
SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos
)
379 static const char* RID_SVXITEMS_ADJUST
[] =
381 RID_SVXITEMS_ADJUST_LEFT
,
382 RID_SVXITEMS_ADJUST_RIGHT
,
383 RID_SVXITEMS_ADJUST_BLOCK
,
384 RID_SVXITEMS_ADJUST_CENTER
,
385 RID_SVXITEMS_ADJUST_BLOCKLINE
387 static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_ADJUST
) - 1 == size_t(SvxAdjust::BlockLine
), "unexpected size");
388 assert(nPos
<= sal_uInt16(SvxAdjust::BlockLine
) && "enum overflow!");
389 return EditResId(RID_SVXITEMS_ADJUST
[nPos
]);
392 sal_uInt16
SvxAdjustItem::GetEnumValue() const
394 return static_cast<sal_uInt16
>(GetAdjust());
398 void SvxAdjustItem::SetEnumValue( sal_uInt16 nVal
)
400 SetAdjust( static_cast<SvxAdjust
>(nVal
) );
404 // class SvxWidowsItem ---------------------------------------------------
406 SvxWidowsItem::SvxWidowsItem(const sal_uInt8 nL
, const sal_uInt16 nId
) :
407 SfxByteItem( nId
, nL
)
412 SfxPoolItem
* SvxWidowsItem::Clone( SfxItemPool
* ) const
414 return new SvxWidowsItem( *this );
418 bool SvxWidowsItem::GetPresentation
420 SfxItemPresentation ePres
,
421 MapUnit
/*eCoreUnit*/,
422 MapUnit
/*ePresUnit*/,
423 OUString
& rText
, const IntlWrapper
&
428 case SfxItemPresentation::Nameless
:
430 rText
= EditResId(RID_SVXITEMS_LINES
);
434 case SfxItemPresentation::Complete
:
436 rText
= EditResId(RID_SVXITEMS_WIDOWS_COMPLETE
) + " " + EditResId(RID_SVXITEMS_LINES
);
442 SAL_WARN( "editeng.items", "SvxWidowsItem::GetPresentation(): unknown SfxItemPresentation" );
446 rText
= rText
.replaceFirst( "%1", OUString::number( GetValue() ) );
450 // class SvxOrphansItem --------------------------------------------------
452 SvxOrphansItem::SvxOrphansItem(const sal_uInt8 nL
, const sal_uInt16 nId
) :
453 SfxByteItem( nId
, nL
)
458 SfxPoolItem
* SvxOrphansItem::Clone( SfxItemPool
* ) const
460 return new SvxOrphansItem( *this );
464 bool SvxOrphansItem::GetPresentation
466 SfxItemPresentation ePres
,
467 MapUnit
/*eCoreUnit*/,
468 MapUnit
/*ePresUnit*/,
469 OUString
& rText
, const IntlWrapper
&
474 case SfxItemPresentation::Nameless
:
476 rText
= EditResId(RID_SVXITEMS_LINES
);
480 case SfxItemPresentation::Complete
:
482 rText
= EditResId(RID_SVXITEMS_ORPHANS_COMPLETE
) + " " + EditResId(RID_SVXITEMS_LINES
);
488 SAL_WARN( "editeng.items", "SvxOrphansItem::GetPresentation(): unknown SfxItemPresentation" );
492 rText
= rText
.replaceFirst( "%1", OUString::number( GetValue() ) );
496 // class SvxHyphenZoneItem -----------------------------------------------
498 SvxHyphenZoneItem::SvxHyphenZoneItem( const bool bHyph
, const sal_uInt16 nId
) :
509 bool SvxHyphenZoneItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
511 nMemberId
&= ~CONVERT_TWIPS
;
517 case MID_HYPHEN_MIN_LEAD
:
518 rVal
<<= static_cast<sal_Int16
>(nMinLead
);
520 case MID_HYPHEN_MIN_TRAIL
:
521 rVal
<<= static_cast<sal_Int16
>(nMinTrail
);
523 case MID_HYPHEN_MAX_HYPHENS
:
524 rVal
<<= static_cast<sal_Int16
>(nMaxHyphens
);
530 bool SvxHyphenZoneItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
532 nMemberId
&= ~CONVERT_TWIPS
;
533 sal_Int16 nNewVal
= 0;
535 if( nMemberId
!= MID_IS_HYPHEN
)
536 if(!(rVal
>>= nNewVal
))
542 bHyphen
= Any2Bool(rVal
);
544 case MID_HYPHEN_MIN_LEAD
:
545 nMinLead
= static_cast<sal_uInt8
>(nNewVal
);
547 case MID_HYPHEN_MIN_TRAIL
:
548 nMinTrail
= static_cast<sal_uInt8
>(nNewVal
);
550 case MID_HYPHEN_MAX_HYPHENS
:
551 nMaxHyphens
= static_cast<sal_uInt8
>(nNewVal
);
558 bool SvxHyphenZoneItem::operator==( const SfxPoolItem
& rAttr
) const
560 assert(SfxPoolItem::operator==(rAttr
));
562 const SvxHyphenZoneItem
& rItem
= static_cast<const SvxHyphenZoneItem
&>(rAttr
);
563 return ( rItem
.bHyphen
== bHyphen
564 && rItem
.bPageEnd
== bPageEnd
565 && rItem
.nMinLead
== nMinLead
566 && rItem
.nMinTrail
== nMinTrail
567 && rItem
.nMaxHyphens
== nMaxHyphens
);
571 SfxPoolItem
* SvxHyphenZoneItem::Clone( SfxItemPool
* ) const
573 return new SvxHyphenZoneItem( *this );
577 bool SvxHyphenZoneItem::GetPresentation
579 SfxItemPresentation ePres
,
580 MapUnit
/*eCoreUnit*/,
581 MapUnit
/*ePresUnit*/,
582 OUString
& rText
, const IntlWrapper
&
585 OUString
cpDelimTmp(cpDelim
);
588 case SfxItemPresentation::Nameless
:
590 const char* pId
= RID_SVXITEMS_HYPHEN_FALSE
;
593 pId
= RID_SVXITEMS_HYPHEN_TRUE
;
594 rText
= EditResId(pId
) + cpDelimTmp
;
595 pId
= RID_SVXITEMS_PAGE_END_FALSE
;
598 pId
= RID_SVXITEMS_PAGE_END_TRUE
;
599 rText
= rText
+ EditResId(pId
) + cpDelimTmp
+
600 OUString::number( nMinLead
) + cpDelimTmp
+
601 OUString::number( nMinTrail
) + cpDelimTmp
+
602 OUString::number( nMaxHyphens
);
605 case SfxItemPresentation::Complete
:
607 const char* pId
= RID_SVXITEMS_HYPHEN_FALSE
;
610 pId
= RID_SVXITEMS_HYPHEN_TRUE
;
611 rText
= EditResId(pId
) + cpDelimTmp
;
612 pId
= RID_SVXITEMS_PAGE_END_FALSE
;
615 pId
= RID_SVXITEMS_PAGE_END_TRUE
;
619 EditResId(RID_SVXITEMS_HYPHEN_MINLEAD
).replaceAll("%1", OUString::number(nMinLead
)) +
621 EditResId(RID_SVXITEMS_HYPHEN_MINTRAIL
).replaceAll("%1", OUString::number(nMinTrail
)) +
623 EditResId(RID_SVXITEMS_HYPHEN_MAX
).replaceAll("%1", OUString::number(nMaxHyphens
));
626 default: ;//prevent warning
632 // class SvxTabStop ------------------------------------------------------
634 SvxTabStop::SvxTabStop()
637 eAdjustment
= SvxTabAdjust::Left
;
638 m_cDecimal
= cDfltDecimalChar
;
639 cFill
= cDfltFillChar
;
643 SvxTabStop::SvxTabStop( const sal_Int32 nPos
, const SvxTabAdjust eAdjst
,
644 const sal_Unicode cDec
, const sal_Unicode cFil
)
647 eAdjustment
= eAdjst
;
652 void SvxTabStop::fillDecimal() const
654 if ( cDfltDecimalChar
== m_cDecimal
)
655 m_cDecimal
= SvtSysLocale().GetLocaleData().getNumDecimalSep()[0];
658 void SvxTabStop::dumpAsXml(xmlTextWriterPtr pWriter
) const
660 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTabStop"));
661 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nTabPos"),
662 BAD_CAST(OString::number(nTabPos
).getStr()));
663 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("eAdjustment"),
664 BAD_CAST(OString::number(static_cast<int>(eAdjustment
)).getStr()));
665 xmlTextWriterEndElement(pWriter
);
668 // class SvxTabStopItem --------------------------------------------------
670 SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich
) :
671 SfxPoolItem( _nWhich
),
674 const sal_uInt16 nTabs
= SVX_TAB_DEFCOUNT
, nDist
= SVX_TAB_DEFDIST
;
675 const SvxTabAdjust eAdjst
= SvxTabAdjust::Default
;
677 for (sal_uInt16 i
= 0; i
< nTabs
; ++i
)
679 SvxTabStop
aTab( (i
+ 1) * nDist
, eAdjst
);
680 maTabStops
.insert( aTab
);
685 SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs
,
686 const sal_uInt16 nDist
,
687 const SvxTabAdjust eAdjst
,
688 sal_uInt16 _nWhich
) :
689 SfxPoolItem( _nWhich
),
692 for ( sal_uInt16 i
= 0; i
< nTabs
; ++i
)
694 SvxTabStop
aTab( (i
+ 1) * nDist
, eAdjst
);
695 maTabStops
.insert( aTab
);
700 sal_uInt16
SvxTabStopItem::GetPos( const SvxTabStop
& rTab
) const
702 SvxTabStopArr::const_iterator it
= maTabStops
.find( rTab
);
703 return it
!= maTabStops
.end() ? it
- maTabStops
.begin() : SVX_TAB_NOTFOUND
;
707 sal_uInt16
SvxTabStopItem::GetPos( const sal_Int32 nPos
) const
709 SvxTabStopArr::const_iterator it
= maTabStops
.find( SvxTabStop( nPos
) );
710 return it
!= maTabStops
.end() ? it
- maTabStops
.begin() : SVX_TAB_NOTFOUND
;
714 bool SvxTabStopItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
716 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
717 nMemberId
&= ~CONVERT_TWIPS
;
722 sal_uInt16 nCount
= Count();
723 uno::Sequence
< style::TabStop
> aSeq(nCount
);
724 style::TabStop
* pArr
= aSeq
.getArray();
725 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
727 const SvxTabStop
& rTab
= (*this)[i
];
728 pArr
[i
].Position
= bConvert
? convertTwipToMm100(rTab
.GetTabPos()) : rTab
.GetTabPos();
729 switch(rTab
.GetAdjustment())
731 case SvxTabAdjust::Left
: pArr
[i
].Alignment
= style::TabAlign_LEFT
; break;
732 case SvxTabAdjust::Right
: pArr
[i
].Alignment
= style::TabAlign_RIGHT
; break;
733 case SvxTabAdjust::Decimal
: pArr
[i
].Alignment
= style::TabAlign_DECIMAL
; break;
734 case SvxTabAdjust::Center
: pArr
[i
].Alignment
= style::TabAlign_CENTER
; break;
735 default: //SvxTabAdjust::Default
736 pArr
[i
].Alignment
= style::TabAlign_DEFAULT
;
739 pArr
[i
].DecimalChar
= rTab
.GetDecimal();
740 pArr
[i
].FillChar
= rTab
.GetFill();
747 const SvxTabStop
&rTab
= maTabStops
.front();
748 rVal
<<= static_cast<sal_Int32
>(bConvert
? convertTwipToMm100(rTab
.GetTabPos()) : rTab
.GetTabPos());
755 bool SvxTabStopItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
757 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
758 nMemberId
&= ~CONVERT_TWIPS
;
763 uno::Sequence
< style::TabStop
> aSeq
;
766 uno::Sequence
< uno::Sequence
< uno::Any
> > aAnySeq
;
767 if (!(rVal
>>= aAnySeq
))
769 sal_Int32 nLength
= aAnySeq
.getLength();
770 aSeq
.realloc( nLength
);
771 for ( sal_Int32 n
=0; n
<nLength
; n
++ )
773 uno::Sequence
< uno::Any
>& rAnySeq
= aAnySeq
[n
];
774 if ( rAnySeq
.getLength() == 4 )
776 if (!(rAnySeq
[0] >>= aSeq
[n
].Position
)) return false;
777 if (!(rAnySeq
[1] >>= aSeq
[n
].Alignment
))
780 if (rAnySeq
[1] >>= nVal
)
781 aSeq
[n
].Alignment
= static_cast<css::style::TabAlign
>(nVal
);
785 if (!(rAnySeq
[2] >>= aSeq
[n
].DecimalChar
))
788 if ( (rAnySeq
[2] >>= aVal
) && aVal
.getLength() == 1 )
789 aSeq
[n
].DecimalChar
= aVal
.toChar();
793 if (!(rAnySeq
[3] >>= aSeq
[n
].FillChar
))
796 if ( (rAnySeq
[3] >>= aVal
) && aVal
.getLength() == 1 )
797 aSeq
[n
].FillChar
= aVal
.toChar();
808 const style::TabStop
* pArr
= aSeq
.getConstArray();
809 const sal_uInt16 nCount
= static_cast<sal_uInt16
>(aSeq
.getLength());
810 for(sal_uInt16 i
= 0; i
< nCount
; i
++)
812 SvxTabAdjust eAdjust
= SvxTabAdjust::Default
;
813 switch(pArr
[i
].Alignment
)
815 case style::TabAlign_LEFT
: eAdjust
= SvxTabAdjust::Left
; break;
816 case style::TabAlign_CENTER
: eAdjust
= SvxTabAdjust::Center
; break;
817 case style::TabAlign_RIGHT
: eAdjust
= SvxTabAdjust::Right
; break;
818 case style::TabAlign_DECIMAL
: eAdjust
= SvxTabAdjust::Decimal
; break;
819 default: ;//prevent warning
821 sal_Unicode cFill
= pArr
[i
].FillChar
;
822 sal_Unicode cDecimal
= pArr
[i
].DecimalChar
;
823 SvxTabStop
aTab( bConvert
? convertMm100ToTwip(pArr
[i
].Position
) : pArr
[i
].Position
,
833 sal_Int32 nNewPos
= 0;
834 if (!(rVal
>>= nNewPos
) )
837 nNewPos
= convertMm100ToTwip ( nNewPos
);
840 const SvxTabStop
& rTab
= maTabStops
.front();
841 SvxTabStop
aNewTab ( nNewPos
, rTab
.GetAdjustment(), rTab
.GetDecimal(), rTab
.GetFill() );
851 bool SvxTabStopItem::operator==( const SfxPoolItem
& rAttr
) const
853 assert(SfxPoolItem::operator==(rAttr
));
855 const SvxTabStopItem
& rTSI
= static_cast<const SvxTabStopItem
&>(rAttr
);
857 if ( Count() != rTSI
.Count() )
860 for ( sal_uInt16 i
= 0; i
< Count(); ++i
)
861 if( (*this)[i
] != rTSI
[i
] )
867 SfxPoolItem
* SvxTabStopItem::Clone( SfxItemPool
* ) const
869 return new SvxTabStopItem( *this );
873 bool SvxTabStopItem::GetPresentation
875 SfxItemPresentation ePres
,
878 OUString
& rText
, const IntlWrapper
& rIntl
885 for ( sal_uInt16 i
= 0; i
< Count(); ++i
)
887 if ( SvxTabAdjust::Default
!= ((*this)[i
]).GetAdjustment() )
891 rText
+= GetMetricText(
892 ((*this)[i
]).GetTabPos(), eCoreUnit
, ePresUnit
, &rIntl
);
893 if ( SfxItemPresentation::Complete
== ePres
)
895 rText
+= " " + EditResId(GetMetricId(ePresUnit
));
904 bool SvxTabStopItem::Insert( const SvxTabStop
& rTab
)
906 sal_uInt16 nTabPos
= GetPos(rTab
);
907 if(SVX_TAB_NOTFOUND
!= nTabPos
)
909 return maTabStops
.insert( rTab
).second
;
912 void SvxTabStopItem::Insert( const SvxTabStopItem
* pTabs
)
914 for( sal_uInt16 i
= 0; i
< pTabs
->Count(); i
++ )
916 const SvxTabStop
& rTab
= (*pTabs
)[i
];
917 sal_uInt16 nTabPos
= GetPos(rTab
);
918 if(SVX_TAB_NOTFOUND
!= nTabPos
)
921 for( sal_uInt16 i
= 0; i
< pTabs
->Count(); i
++ )
923 maTabStops
.insert( (*pTabs
)[i
] );
927 void SvxTabStopItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
929 xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxTabStopItem"));
930 for (const auto& rTabStop
: maTabStops
)
931 rTabStop
.dumpAsXml(pWriter
);
932 xmlTextWriterEndElement(pWriter
);
935 // class SvxFormatSplitItem -------------------------------------------------
936 SvxFormatSplitItem::~SvxFormatSplitItem()
940 SfxPoolItem
* SvxFormatSplitItem::Clone( SfxItemPool
* ) const
942 return new SvxFormatSplitItem( *this );
946 bool SvxFormatSplitItem::GetPresentation
948 SfxItemPresentation
/*ePres*/,
949 MapUnit
/*eCoreUnit*/,
950 MapUnit
/*ePresUnit*/,
951 OUString
& rText
, const IntlWrapper
&
954 const char* pId
= RID_SVXITEMS_FMTSPLIT_FALSE
;
957 pId
= RID_SVXITEMS_FMTSPLIT_TRUE
;
958 rText
= EditResId(pId
);
963 SfxPoolItem
* SvxPageModelItem::Clone( SfxItemPool
* ) const
965 return new SvxPageModelItem( *this );
969 bool SvxPageModelItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
) const
971 nMemberId
&= ~CONVERT_TWIPS
;
975 case MID_AUTO
: rVal
<<= bAuto
; break;
976 case MID_NAME
: rVal
<<= GetValue(); break;
977 default: OSL_FAIL("Wrong MemberId!"); return false;
983 bool SvxPageModelItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
985 nMemberId
&= ~CONVERT_TWIPS
;
990 case MID_AUTO
: bRet
= ( rVal
>>= bAuto
); break;
991 case MID_NAME
: bRet
= ( rVal
>>= aStr
); if ( bRet
) SetValue(aStr
); break;
992 default: OSL_FAIL("Wrong MemberId!"); return false;
998 bool SvxPageModelItem::operator==( const SfxPoolItem
& rAttr
) const
1000 assert(SfxPoolItem::operator==(rAttr
));
1002 return SfxStringItem::operator==(rAttr
) &&
1003 bAuto
== static_cast<const SvxPageModelItem
&>( rAttr
).bAuto
;
1006 bool SvxPageModelItem::GetPresentation
1008 SfxItemPresentation ePres
,
1009 MapUnit
/*eCoreUnit*/,
1010 MapUnit
/*ePresUnit*/,
1011 OUString
& rText
, const IntlWrapper
&
1015 bool bSet
= !GetValue().isEmpty();
1019 case SfxItemPresentation::Nameless
:
1024 case SfxItemPresentation::Complete
:
1027 rText
= EditResId(RID_SVXITEMS_PAGEMODEL_COMPLETE
) + GetValue();
1030 default: ;//prevent warning
1036 SvxScriptSpaceItem::SvxScriptSpaceItem( bool bOn
, const sal_uInt16 nId
)
1037 : SfxBoolItem( nId
, bOn
)
1041 SfxPoolItem
* SvxScriptSpaceItem::Clone( SfxItemPool
* ) const
1043 return new SvxScriptSpaceItem( *this );
1046 bool SvxScriptSpaceItem::GetPresentation(
1047 SfxItemPresentation
/*ePres*/,
1048 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1049 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1051 rText
= EditResId( !GetValue()
1052 ? RID_SVXITEMS_SCRPTSPC_OFF
1053 : RID_SVXITEMS_SCRPTSPC_ON
);
1058 SvxHangingPunctuationItem::SvxHangingPunctuationItem(
1059 bool bOn
, const sal_uInt16 nId
)
1060 : SfxBoolItem( nId
, bOn
)
1064 SfxPoolItem
* SvxHangingPunctuationItem::Clone( SfxItemPool
* ) const
1066 return new SvxHangingPunctuationItem( *this );
1069 bool SvxHangingPunctuationItem::GetPresentation(
1070 SfxItemPresentation
/*ePres*/,
1071 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1072 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1074 rText
= EditResId( !GetValue()
1075 ? RID_SVXITEMS_HNGPNCT_OFF
1076 : RID_SVXITEMS_HNGPNCT_ON
);
1081 SvxForbiddenRuleItem::SvxForbiddenRuleItem(
1082 bool bOn
, const sal_uInt16 nId
)
1083 : SfxBoolItem( nId
, bOn
)
1087 SfxPoolItem
* SvxForbiddenRuleItem::Clone( SfxItemPool
* ) const
1089 return new SvxForbiddenRuleItem( *this );
1092 bool SvxForbiddenRuleItem::GetPresentation(
1093 SfxItemPresentation
/*ePres*/,
1094 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1095 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1097 rText
= EditResId( !GetValue()
1098 ? RID_SVXITEMS_FORBIDDEN_RULE_OFF
1099 : RID_SVXITEMS_FORBIDDEN_RULE_ON
);
1103 /*************************************************************************
1104 |* class SvxParaVertAlignItem
1105 *************************************************************************/
1107 SvxParaVertAlignItem::SvxParaVertAlignItem( Align nValue
,
1108 const sal_uInt16 nW
)
1109 : SfxUInt16Item( nW
, static_cast<sal_uInt16
>(nValue
) )
1113 SfxPoolItem
* SvxParaVertAlignItem::Clone( SfxItemPool
* ) const
1115 return new SvxParaVertAlignItem( *this );
1118 bool SvxParaVertAlignItem::GetPresentation(
1119 SfxItemPresentation
/*ePres*/,
1120 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1121 OUString
&rText
, const IntlWrapper
& ) const
1124 switch( GetValue() )
1126 case Align::Automatic
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_AUTO
; break;
1127 case Align::Top
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_TOP
; break;
1128 case Align::Center
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_CENTER
; break;
1129 case Align::Bottom
: pTmp
= RID_SVXITEMS_PARAVERTALIGN_BOTTOM
; break;
1130 default: pTmp
= RID_SVXITEMS_PARAVERTALIGN_BASELINE
; break;
1132 rText
= EditResId(pTmp
);
1136 bool SvxParaVertAlignItem::QueryValue( css::uno::Any
& rVal
,
1137 sal_uInt8
/*nMemberId*/ ) const
1139 rVal
<<= static_cast<sal_Int16
>(GetValue());
1143 bool SvxParaVertAlignItem::PutValue( const css::uno::Any
& rVal
,
1144 sal_uInt8
/*nMemberId*/ )
1146 sal_Int16 nVal
= sal_Int16();
1147 if((rVal
>>= nVal
) && nVal
>=0 && nVal
<= sal_uInt16(Align::Bottom
) )
1149 SetValue( static_cast<Align
>(nVal
) );
1156 bool SvxParaVertAlignItem::operator==( const SfxPoolItem
& rItem
) const
1158 assert(SfxPoolItem::operator==(rItem
));
1159 return SfxUInt16Item::operator==( rItem
);
1163 SvxParaGridItem::SvxParaGridItem( bool bOn
, const sal_uInt16 nId
)
1164 : SfxBoolItem( nId
, bOn
)
1168 SfxPoolItem
* SvxParaGridItem::Clone( SfxItemPool
* ) const
1170 return new SvxParaGridItem( *this );
1173 bool SvxParaGridItem::GetPresentation(
1174 SfxItemPresentation
/*ePres*/,
1175 MapUnit
/*eCoreMetric*/, MapUnit
/*ePresMetric*/,
1176 OUString
&rText
, const IntlWrapper
& /*rIntl*/ ) const
1178 rText
= GetValue() ?
1179 EditResId( RID_SVXITEMS_PARASNAPTOGRID_ON
) :
1180 EditResId( RID_SVXITEMS_PARASNAPTOGRID_OFF
);
1186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */