1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
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>
52 
53 using namespace ::com::sun::star;
54 
55 
CreateDefault()56 SfxPoolItem* SvxLineSpacingItem::CreateDefault() { return new  SvxLineSpacingItem(LINE_SPACE_DEFAULT_HEIGHT, 0);}
CreateDefault()57 SfxPoolItem* SvxAdjustItem::CreateDefault() { return new  SvxAdjustItem(SvxAdjust::Left, 0);}
CreateDefault()58 SfxPoolItem* SvxWidowsItem::CreateDefault() { return new  SvxWidowsItem(0, 0);}
CreateDefault()59 SfxPoolItem* SvxOrphansItem::CreateDefault() { return new  SvxOrphansItem(0, 0);}
CreateDefault()60 SfxPoolItem* SvxHyphenZoneItem::CreateDefault() { return new  SvxHyphenZoneItem(false, 0);}
CreateDefault()61 SfxPoolItem* SvxTabStopItem::CreateDefault() { return new  SvxTabStopItem(0);}
CreateDefault()62 SfxPoolItem* SvxFormatSplitItem::CreateDefault() { return new  SvxFormatSplitItem(false, 0);}
CreateDefault()63 SfxPoolItem* SvxPageModelItem::CreateDefault() { return new  SvxPageModelItem(0);}
CreateDefault()64 SfxPoolItem* SvxParaVertAlignItem::CreateDefault() { return new  SvxParaVertAlignItem(Align::Automatic, 0);}
65 
66 namespace {
67 
68 enum class SvxSpecialLineSpace
69 {
70     User,
71     OneLine,
72     OnePointFiveLines,
73     TwoLines,
74     End
75 };
76 
77 }
78 
SvxLineSpacingItem(sal_uInt16 nHeight,const sal_uInt16 nId)79 SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight, const sal_uInt16 nId )
80     : SfxEnumItemInterface( nId )
81 {
82     nPropLineSpace = 100;
83     nInterLineSpace = 0;
84     nLineHeight = nHeight;
85     eLineSpaceRule = SvxLineSpaceRule::Auto;
86     eInterLineSpaceRule = SvxInterLineSpaceRule::Off;
87 }
88 
89 
operator ==(const SfxPoolItem & rAttr) const90 bool SvxLineSpacingItem::operator==( const SfxPoolItem& rAttr ) const
91 {
92     assert(SfxPoolItem::operator==(rAttr));
93 
94     const SvxLineSpacingItem& rLineSpace = static_cast<const SvxLineSpacingItem&>(rAttr);
95     return
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)));
109 }
110 
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)
115 */
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const116 bool SvxLineSpacingItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
117 {
118     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
119     nMemberId &= ~CONVERT_TWIPS;
120 
121     style::LineSpacing aLSp;
122     switch( eLineSpaceRule )
123     {
124         case SvxLineSpaceRule::Auto:
125             if(eInterLineSpaceRule == SvxInterLineSpaceRule::Fix)
126             {
127                 aLSp.Mode = style::LineSpacingMode::LEADING;
128                 aLSp.Height = ( bConvert ? static_cast<short>(convertTwipToMm100(nInterLineSpace)) : nInterLineSpace);
129             }
130             else if(eInterLineSpaceRule == SvxInterLineSpaceRule::Off)
131             {
132                 aLSp.Mode = style::LineSpacingMode::PROP;
133                 aLSp.Height = 100;
134             }
135             else
136             {
137                 aLSp.Mode = style::LineSpacingMode::PROP;
138                 aLSp.Height = nPropLineSpace;
139             }
140         break;
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 );
145         break;
146         default:
147             ;//prevent warning about SvxLineSpaceRule::End
148     }
149 
150     switch ( nMemberId )
151     {
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;
156     }
157 
158     return true;
159 }
160 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)161 bool SvxLineSpacingItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
162 {
163     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
164     nMemberId &= ~CONVERT_TWIPS;
165 
166     // fill with current data
167     style::LineSpacing aLSp;
168     uno::Any aAny;
169     bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aLSp );
170 
171     // get new data
172     switch ( nMemberId )
173     {
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;
178     }
179 
180     if( bRet )
181     {
182         nLineHeight = aLSp.Height;
183         switch( aLSp.Mode )
184         {
185             case style::LineSpacingMode::LEADING:
186             {
187                 eInterLineSpaceRule = SvxInterLineSpaceRule::Fix;
188                 eLineSpaceRule = SvxLineSpaceRule::Auto;
189                 nInterLineSpace = aLSp.Height;
190                 if(bConvert)
191                     nInterLineSpace = static_cast<short>(convertMm100ToTwip(nInterLineSpace));
192 
193             }
194             break;
195             case style::LineSpacingMode::PROP:
196             {
197                 eLineSpaceRule = SvxLineSpaceRule::Auto;
198                 nPropLineSpace = aLSp.Height;
199                 if(100 == aLSp.Height)
200                     eInterLineSpaceRule = SvxInterLineSpaceRule::Off;
201                 else
202                     eInterLineSpaceRule = SvxInterLineSpaceRule::Prop;
203             }
204             break;
205             case style::LineSpacingMode::FIX:
206             case style::LineSpacingMode::MINIMUM:
207             {
208                 eInterLineSpaceRule =  SvxInterLineSpaceRule::Off;
209                 eLineSpaceRule = aLSp.Mode == style::LineSpacingMode::FIX ? SvxLineSpaceRule::Fix : SvxLineSpaceRule::Min;
210                 nLineHeight = aLSp.Height;
211                 if(bConvert)
212                     nLineHeight = static_cast<sal_uInt16>(convertMm100ToTwip(nLineHeight));
213             }
214             break;
215         }
216     }
217 
218     return bRet;
219 }
220 
Clone(SfxItemPool *) const221 SvxLineSpacingItem* SvxLineSpacingItem::Clone( SfxItemPool * ) const
222 {
223     return new SvxLineSpacingItem( *this );
224 }
225 
GetPresentation(SfxItemPresentation ePres,MapUnit eCoreUnit,MapUnit ePresUnit,OUString & rText,const IntlWrapper & rIntl) const226 bool SvxLineSpacingItem::GetPresentation
227 (
228     SfxItemPresentation ePres,
229     MapUnit             eCoreUnit,
230     MapUnit             ePresUnit,
231     OUString&           rText, const IntlWrapper& rIntl
232 )   const
233 {
234     switch ( ePres )
235     {
236         case SfxItemPresentation::Nameless:
237         case SfxItemPresentation::Complete:
238         {
239             switch( GetLineSpaceRule() )
240             {
241                 case SvxLineSpaceRule::Auto:
242                 {
243                     SvxInterLineSpaceRule eInter = GetInterLineSpaceRule();
244 
245                     switch( eInter )
246                     {
247                         // Default single line spacing
248                         case SvxInterLineSpaceRule::Off:
249                             rText = EditResId(RID_SVXITEMS_LINESPACING_SINGLE);
250                             break;
251 
252                         // Default single line spacing
253                         case SvxInterLineSpaceRule::Prop:
254                             if ( 100 == GetPropLineSpace() )
255                             {
256                                 rText = EditResId(RID_SVXITEMS_LINESPACING_SINGLE);
257                                 break;
258                             }
259                             // 1.15 line spacing
260                             if ( 115 == GetPropLineSpace() )
261                             {
262                                 rText = EditResId(RID_SVXITEMS_LINESPACING_115);
263                                 break;
264                             }
265                             // 1.5 line spacing
266                             if ( 150 == GetPropLineSpace() )
267                             {
268                                 rText = EditResId(RID_SVXITEMS_LINESPACING_15);
269                                 break;
270                             }
271                             // double line spacing
272                             if ( 200 == GetPropLineSpace() )
273                             {
274                                 rText = EditResId(RID_SVXITEMS_LINESPACING_DOUBLE);
275                                 break;
276                             }
277                             // the set per cent value
278                             rText = EditResId(RID_SVXITEMS_LINESPACING_PROPORTIONAL) + " " + OUString::number(GetPropLineSpace()) + "%";
279                             break;
280 
281                         case SvxInterLineSpaceRule::Fix:
282                             rText = EditResId(RID_SVXITEMS_LINESPACING_LEADING)  +
283                                     " " + GetMetricText(GetInterLineSpace(), eCoreUnit, ePresUnit, &rIntl) +
284                                     " " + EditResId(GetMetricId(ePresUnit));
285                             break;
286                         default: ;//prevent warning
287                     }
288                 }
289                 break;
290                 case SvxLineSpaceRule::Fix:
291                     rText = EditResId(RID_SVXITEMS_LINESPACING_FIXED)  +
292                             " " + GetMetricText(GetLineHeight(), eCoreUnit, ePresUnit, &rIntl) +
293                             " " + EditResId(GetMetricId(ePresUnit));
294                     break;
295 
296                 case SvxLineSpaceRule::Min:
297                     rText = EditResId(RID_SVXITEMS_LINESPACING_MIN) +
298                             " " + GetMetricText(GetLineHeight(), eCoreUnit, ePresUnit, &rIntl) +
299                             " " + EditResId(GetMetricId(ePresUnit));
300                     break;
301                 default: ;//prevent warning
302             }
303         }
304     }
305     return true;
306 }
307 
GetValueCount() const308 sal_uInt16 SvxLineSpacingItem::GetValueCount() const
309 {
310     return sal_uInt16(SvxSpecialLineSpace::End);   // SvxSpecialLineSpace::TwoLines + 1
311 }
312 
313 
GetEnumValue() const314 sal_uInt16 SvxLineSpacingItem::GetEnumValue() const
315 {
316     SvxSpecialLineSpace nVal;
317     switch ( nPropLineSpace )
318     {
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;
323     }
324     return static_cast<sal_uInt16>(nVal);
325 }
326 
327 
SetEnumValue(sal_uInt16 nVal)328 void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal )
329 {
330     switch ( static_cast<SvxSpecialLineSpace>(nVal) )
331     {
332         case SvxSpecialLineSpace::OneLine:           nPropLineSpace = 100; break;
333         case SvxSpecialLineSpace::OnePointFiveLines: nPropLineSpace = 150; break;
334         case SvxSpecialLineSpace::TwoLines:          nPropLineSpace = 200; break;
335         default: break;
336     }
337 }
338 
339 // class SvxAdjustItem ---------------------------------------------------
340 
SvxAdjustItem(const SvxAdjust eAdjst,const sal_uInt16 nId)341 SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst, const sal_uInt16 nId )
342     : SfxEnumItemInterface( nId ),
343     bOneBlock( false ), bLastCenter( false ), bLastBlock( false )
344 {
345     SetAdjust( eAdjst );
346 }
347 
348 
operator ==(const SfxPoolItem & rAttr) const349 bool SvxAdjustItem::operator==( const SfxPoolItem& rAttr ) const
350 {
351     assert(SfxPoolItem::operator==(rAttr));
352 
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;
358 }
359 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const360 bool SvxAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
361 {
362     nMemberId &= ~CONVERT_TWIPS;
363     switch( nMemberId )
364     {
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    :
368         {
369             rVal <<= bOneBlock;
370             break;
371         }
372         default: ;//prevent warning
373     }
374     return true;
375 }
376 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)377 bool SvxAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
378 {
379     nMemberId &= ~CONVERT_TWIPS;
380     switch( nMemberId )
381     {
382         case MID_PARA_ADJUST              :
383         case MID_LAST_LINE_ADJUST :
384         {
385             sal_Int32 eVal = - 1;
386             ::cppu::enum2int(eVal,rVal);
387             if(eVal >= 0 && eVal <= 4)
388             {
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)
394                         return false;
395                 nMemberId == MID_PARA_ADJUST ? SetAdjust(eAdjust) : SetLastBlock(eAdjust);
396             }
397         }
398         break;
399         case MID_EXPAND_SINGLE :
400             bOneBlock = Any2Bool(rVal);
401             break;
402     }
403     return true;
404 }
405 
Clone(SfxItemPool *) const406 SvxAdjustItem* SvxAdjustItem::Clone( SfxItemPool * ) const
407 {
408     return new SvxAdjustItem( *this );
409 }
410 
GetPresentation(SfxItemPresentation ePres,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const411 bool SvxAdjustItem::GetPresentation
412 (
413     SfxItemPresentation ePres,
414     MapUnit             /*eCoreUnit*/,
415     MapUnit             /*ePresUnit*/,
416     OUString&           rText, const IntlWrapper&
417 )   const
418 {
419     switch ( ePres )
420     {
421         case SfxItemPresentation::Nameless:
422         case SfxItemPresentation::Complete:
423             rText = GetValueTextByPos( static_cast<sal_uInt16>(GetAdjust()) );
424             return true;
425         default: ;//prevent warning
426     }
427     return false;
428 }
429 
430 
GetValueCount() const431 sal_uInt16 SvxAdjustItem::GetValueCount() const
432 {
433     return sal_uInt16(SvxAdjust::End);  // SvxAdjust::BlockLine + 1
434 }
435 
GetValueTextByPos(sal_uInt16 nPos)436 OUString SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos )
437 {
438     static const char* RID_SVXITEMS_ADJUST[] =
439     {
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
445     };
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]);
449 }
450 
GetEnumValue() const451 sal_uInt16 SvxAdjustItem::GetEnumValue() const
452 {
453     return static_cast<sal_uInt16>(GetAdjust());
454 }
455 
456 
SetEnumValue(sal_uInt16 nVal)457 void SvxAdjustItem::SetEnumValue( sal_uInt16 nVal )
458 {
459     SetAdjust( static_cast<SvxAdjust>(nVal) );
460 }
461 
462 
463 // class SvxWidowsItem ---------------------------------------------------
464 
SvxWidowsItem(const sal_uInt8 nL,const sal_uInt16 nId)465 SvxWidowsItem::SvxWidowsItem(const sal_uInt8 nL, const sal_uInt16 nId ) :
466     SfxByteItem( nId, nL )
467 {
468 }
469 
Clone(SfxItemPool *) const470 SvxWidowsItem* SvxWidowsItem::Clone( SfxItemPool * ) const
471 {
472     return new SvxWidowsItem( *this );
473 }
474 
GetPresentation(SfxItemPresentation ePres,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const475 bool SvxWidowsItem::GetPresentation
476 (
477     SfxItemPresentation ePres,
478     MapUnit             /*eCoreUnit*/,
479     MapUnit             /*ePresUnit*/,
480     OUString&           rText, const IntlWrapper&
481 )   const
482 {
483     switch ( ePres )
484     {
485         case SfxItemPresentation::Nameless:
486         {
487             rText = EditResId(RID_SVXITEMS_LINES);
488             break;
489         }
490 
491         case SfxItemPresentation::Complete:
492         {
493             rText = EditResId(RID_SVXITEMS_WIDOWS_COMPLETE) + " " + EditResId(RID_SVXITEMS_LINES);
494             break;
495         }
496 
497         default:
498         {
499             SAL_WARN( "editeng.items", "SvxWidowsItem::GetPresentation(): unknown SfxItemPresentation" );
500         }
501     }
502 
503     rText = rText.replaceFirst( "%1", OUString::number( GetValue() ) );
504     return true;
505 }
506 
507 // class SvxOrphansItem --------------------------------------------------
508 
SvxOrphansItem(const sal_uInt8 nL,const sal_uInt16 nId)509 SvxOrphansItem::SvxOrphansItem(const sal_uInt8 nL, const sal_uInt16 nId ) :
510     SfxByteItem( nId, nL )
511 {
512 }
513 
Clone(SfxItemPool *) const514 SvxOrphansItem* SvxOrphansItem::Clone( SfxItemPool * ) const
515 {
516     return new SvxOrphansItem( *this );
517 }
518 
GetPresentation(SfxItemPresentation ePres,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const519 bool SvxOrphansItem::GetPresentation
520 (
521     SfxItemPresentation ePres,
522     MapUnit             /*eCoreUnit*/,
523     MapUnit             /*ePresUnit*/,
524     OUString&           rText, const IntlWrapper&
525 )   const
526 {
527     switch ( ePres )
528     {
529         case SfxItemPresentation::Nameless:
530         {
531             rText = EditResId(RID_SVXITEMS_LINES);
532             break;
533         }
534 
535         case SfxItemPresentation::Complete:
536         {
537             rText = EditResId(RID_SVXITEMS_ORPHANS_COMPLETE) + " " + EditResId(RID_SVXITEMS_LINES);
538             break;
539         }
540 
541         default:
542         {
543             SAL_WARN( "editeng.items", "SvxOrphansItem::GetPresentation(): unknown SfxItemPresentation" );
544         }
545     }
546 
547     rText = rText.replaceFirst( "%1", OUString::number( GetValue() ) );
548     return true;
549 }
550 
551 // class SvxHyphenZoneItem -----------------------------------------------
552 
SvxHyphenZoneItem(const bool bHyph,const sal_uInt16 nId)553 SvxHyphenZoneItem::SvxHyphenZoneItem( const bool bHyph, const sal_uInt16 nId ) :
554     SfxPoolItem( nId ),
555     bHyphen(bHyph),
556     bPageEnd(true),
557     bNoCapsHyphenation(false),
558     nMinLead(0),
559     nMinTrail(0),
560     nMaxHyphens(255)
561 {
562 }
563 
564 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const565 bool    SvxHyphenZoneItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
566 {
567     nMemberId &= ~CONVERT_TWIPS;
568     switch(nMemberId)
569     {
570         case  MID_IS_HYPHEN:
571             rVal <<= bHyphen;
572         break;
573         case MID_HYPHEN_MIN_LEAD:
574             rVal <<= static_cast<sal_Int16>(nMinLead);
575         break;
576         case MID_HYPHEN_MIN_TRAIL:
577             rVal <<= static_cast<sal_Int16>(nMinTrail);
578         break;
579         case MID_HYPHEN_MAX_HYPHENS:
580             rVal <<= static_cast<sal_Int16>(nMaxHyphens);
581         break;
582         case MID_HYPHEN_NO_CAPS:
583             rVal <<= bNoCapsHyphenation;
584         break;
585     }
586     return true;
587 }
588 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)589 bool SvxHyphenZoneItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
590 {
591     nMemberId &= ~CONVERT_TWIPS;
592     sal_Int16 nNewVal = 0;
593 
594     if( nMemberId != MID_IS_HYPHEN && nMemberId != MID_HYPHEN_NO_CAPS )
595         if(!(rVal >>= nNewVal))
596             return false;
597 
598     switch(nMemberId)
599     {
600         case  MID_IS_HYPHEN:
601             bHyphen = Any2Bool(rVal);
602         break;
603         case MID_HYPHEN_MIN_LEAD:
604             nMinLead = static_cast<sal_uInt8>(nNewVal);
605         break;
606         case MID_HYPHEN_MIN_TRAIL:
607             nMinTrail = static_cast<sal_uInt8>(nNewVal);
608         break;
609         case MID_HYPHEN_MAX_HYPHENS:
610             nMaxHyphens = static_cast<sal_uInt8>(nNewVal);
611         break;
612         case MID_HYPHEN_NO_CAPS:
613             bNoCapsHyphenation = Any2Bool(rVal);
614         break;
615     }
616     return true;
617 }
618 
619 
operator ==(const SfxPoolItem & rAttr) const620 bool SvxHyphenZoneItem::operator==( const SfxPoolItem& rAttr ) const
621 {
622     assert(SfxPoolItem::operator==(rAttr));
623 
624     const SvxHyphenZoneItem& rItem = static_cast<const SvxHyphenZoneItem&>(rAttr);
625     return ( rItem.bHyphen == bHyphen
626             && rItem.bNoCapsHyphenation == bNoCapsHyphenation
627             && rItem.bPageEnd == bPageEnd
628             && rItem.nMinLead == nMinLead
629             && rItem.nMinTrail == nMinTrail
630             && rItem.nMaxHyphens == nMaxHyphens );
631 }
632 
Clone(SfxItemPool *) const633 SvxHyphenZoneItem* SvxHyphenZoneItem::Clone( SfxItemPool * ) const
634 {
635     return new SvxHyphenZoneItem( *this );
636 }
637 
GetPresentation(SfxItemPresentation ePres,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const638 bool SvxHyphenZoneItem::GetPresentation
639 (
640     SfxItemPresentation ePres,
641     MapUnit             /*eCoreUnit*/,
642     MapUnit             /*ePresUnit*/,
643     OUString&           rText, const IntlWrapper&
644 )   const
645 {
646     OUString cpDelimTmp(cpDelim);
647     switch ( ePres )
648     {
649         case SfxItemPresentation::Nameless:
650         {
651             const char* pId = RID_SVXITEMS_HYPHEN_FALSE;
652 
653             if ( bHyphen )
654                 pId = RID_SVXITEMS_HYPHEN_TRUE;
655             rText = EditResId(pId) + cpDelimTmp;
656             pId = RID_SVXITEMS_PAGE_END_FALSE;
657 
658             if ( bPageEnd )
659                 pId = RID_SVXITEMS_PAGE_END_TRUE;
660             rText += EditResId(pId) + cpDelimTmp +
661                     OUString::number( nMinLead ) + cpDelimTmp +
662                     OUString::number( nMinTrail ) + cpDelimTmp +
663                     OUString::number( nMaxHyphens );
664             return true;
665         }
666         case SfxItemPresentation::Complete:
667         {
668             const char* pId = RID_SVXITEMS_HYPHEN_FALSE;
669 
670             if ( bHyphen )
671                 pId = RID_SVXITEMS_HYPHEN_TRUE;
672             rText = EditResId(pId) + cpDelimTmp;
673             pId = RID_SVXITEMS_PAGE_END_FALSE;
674 
675             if ( bPageEnd )
676                 pId = RID_SVXITEMS_PAGE_END_TRUE;
677             rText += EditResId(pId) +
678                     cpDelimTmp +
679                     EditResId(RID_SVXITEMS_HYPHEN_MINLEAD).replaceAll("%1", OUString::number(nMinLead)) +
680                     cpDelimTmp +
681                     EditResId(RID_SVXITEMS_HYPHEN_MINTRAIL).replaceAll("%1", OUString::number(nMinTrail)) +
682                     cpDelimTmp +
683                     EditResId(RID_SVXITEMS_HYPHEN_MAX).replaceAll("%1", OUString::number(nMaxHyphens));
684             return true;
685         }
686         default: ;//prevent warning
687     }
688     return false;
689 }
690 
691 
692 // class SvxTabStop ------------------------------------------------------
693 
SvxTabStop()694 SvxTabStop::SvxTabStop()
695 {
696     nTabPos = 0;
697     eAdjustment = SvxTabAdjust::Left;
698     m_cDecimal = cDfltDecimalChar;
699     cFill = cDfltFillChar;
700 }
701 
702 
SvxTabStop(const sal_Int32 nPos,const SvxTabAdjust eAdjst,const sal_Unicode cDec,const sal_Unicode cFil)703 SvxTabStop::SvxTabStop( const sal_Int32 nPos, const SvxTabAdjust eAdjst,
704                         const sal_Unicode cDec, const sal_Unicode cFil )
705 {
706     nTabPos = nPos;
707     eAdjustment = eAdjst;
708     m_cDecimal = cDec;
709     cFill = cFil;
710 }
711 
fillDecimal() const712 void SvxTabStop::fillDecimal() const
713 {
714     if ( cDfltDecimalChar == m_cDecimal )
715         m_cDecimal = SvtSysLocale().GetLocaleData().getNumDecimalSep()[0];
716 }
717 
dumpAsXml(xmlTextWriterPtr pWriter) const718 void SvxTabStop::dumpAsXml(xmlTextWriterPtr pWriter) const
719 {
720     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTabStop"));
721     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nTabPos"),
722                                 BAD_CAST(OString::number(nTabPos).getStr()));
723     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("eAdjustment"),
724                                 BAD_CAST(OString::number(static_cast<int>(eAdjustment)).getStr()));
725     (void)xmlTextWriterEndElement(pWriter);
726 }
727 
728 // class SvxTabStopItem --------------------------------------------------
729 
SvxTabStopItem(sal_uInt16 _nWhich)730 SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich ) :
731     SfxPoolItem( _nWhich ),
732     maTabStops()
733 {
734     const sal_uInt16 nTabs = SVX_TAB_DEFCOUNT, nDist = SVX_TAB_DEFDIST;
735     const SvxTabAdjust eAdjst= SvxTabAdjust::Default;
736 
737     for (sal_uInt16 i = 0; i < nTabs; ++i)
738     {
739         SvxTabStop aTab( (i + 1) * nDist, eAdjst );
740         maTabStops.insert( aTab );
741     }
742 }
743 
744 
SvxTabStopItem(const sal_uInt16 nTabs,const sal_uInt16 nDist,const SvxTabAdjust eAdjst,sal_uInt16 _nWhich)745 SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs,
746                                 const sal_uInt16 nDist,
747                                 const SvxTabAdjust eAdjst,
748                                 sal_uInt16 _nWhich ) :
749     SfxPoolItem( _nWhich ),
750     maTabStops()
751 {
752     for ( sal_uInt16 i = 0; i < nTabs; ++i )
753     {
754         SvxTabStop aTab( (i + 1) * nDist, eAdjst );
755         maTabStops.insert( aTab );
756     }
757 }
758 
759 
GetPos(const SvxTabStop & rTab) const760 sal_uInt16 SvxTabStopItem::GetPos( const SvxTabStop& rTab ) const
761 {
762     SvxTabStopArr::const_iterator it = maTabStops.find( rTab );
763     return it != maTabStops.end() ? it - maTabStops.begin() : SVX_TAB_NOTFOUND;
764 }
765 
766 
GetPos(const sal_Int32 nPos) const767 sal_uInt16 SvxTabStopItem::GetPos( const sal_Int32 nPos ) const
768 {
769     SvxTabStopArr::const_iterator it = maTabStops.find( SvxTabStop( nPos ) );
770     return it != maTabStops.end() ? it - maTabStops.begin() : SVX_TAB_NOTFOUND;
771 }
772 
773 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const774 bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
775 {
776     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
777     nMemberId &= ~CONVERT_TWIPS;
778     switch ( nMemberId )
779     {
780         case MID_TABSTOPS:
781         {
782             sal_uInt16 nCount = Count();
783             uno::Sequence< style::TabStop> aSeq(nCount);
784             style::TabStop* pArr = aSeq.getArray();
785             for(sal_uInt16 i = 0; i < nCount; i++)
786             {
787                 const SvxTabStop& rTab = (*this)[i];
788                 pArr[i].Position        = bConvert ? convertTwipToMm100(rTab.GetTabPos()) : rTab.GetTabPos();
789                 switch(rTab.GetAdjustment())
790                 {
791                 case  SvxTabAdjust::Left   : pArr[i].Alignment = style::TabAlign_LEFT; break;
792                 case  SvxTabAdjust::Right  : pArr[i].Alignment = style::TabAlign_RIGHT; break;
793                 case  SvxTabAdjust::Decimal: pArr[i].Alignment = style::TabAlign_DECIMAL; break;
794                 case  SvxTabAdjust::Center : pArr[i].Alignment = style::TabAlign_CENTER; break;
795                     default: //SvxTabAdjust::Default
796                         pArr[i].Alignment = style::TabAlign_DEFAULT;
797 
798                 }
799                 pArr[i].DecimalChar     = rTab.GetDecimal();
800                 pArr[i].FillChar        = rTab.GetFill();
801             }
802             rVal <<= aSeq;
803             break;
804         }
805         case MID_STD_TAB:
806         {
807             const SvxTabStop &rTab = maTabStops.front();
808             rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(rTab.GetTabPos()) : rTab.GetTabPos());
809             break;
810         }
811     }
812     return true;
813 }
814 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)815 bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
816 {
817     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
818     nMemberId &= ~CONVERT_TWIPS;
819     switch ( nMemberId )
820     {
821         case MID_TABSTOPS:
822         {
823             uno::Sequence< style::TabStop> aSeq;
824             if(!(rVal >>= aSeq))
825             {
826                 uno::Sequence < uno::Sequence < uno::Any >  > aAnySeq;
827                 if (!(rVal >>= aAnySeq))
828                     return false;
829                 sal_Int32 nLength = aAnySeq.getLength();
830                 aSeq.realloc( nLength );
831                 for ( sal_Int32 n=0; n<nLength; n++ )
832                 {
833                     uno::Sequence < uno::Any >& rAnySeq = aAnySeq[n];
834                     if ( rAnySeq.getLength() == 4 )
835                     {
836                         if (!(rAnySeq[0] >>= aSeq[n].Position)) return false;
837                         if (!(rAnySeq[1] >>= aSeq[n].Alignment))
838                         {
839                             sal_Int32 nVal = 0;
840                             if (rAnySeq[1] >>= nVal)
841                                 aSeq[n].Alignment = static_cast<css::style::TabAlign>(nVal);
842                             else
843                                 return false;
844                         }
845                         if (!(rAnySeq[2] >>= aSeq[n].DecimalChar))
846                         {
847                             OUString aVal;
848                             if ( (rAnySeq[2] >>= aVal) && aVal.getLength() == 1 )
849                                 aSeq[n].DecimalChar = aVal.toChar();
850                             else
851                                 return false;
852                         }
853                         if (!(rAnySeq[3] >>= aSeq[n].FillChar))
854                         {
855                             OUString aVal;
856                             if ( (rAnySeq[3] >>= aVal) && aVal.getLength() == 1 )
857                                 aSeq[n].FillChar = aVal.toChar();
858                             else
859                                 return false;
860                         }
861                     }
862                     else
863                         return false;
864                 }
865             }
866 
867             maTabStops.clear();
868             const style::TabStop* pArr = aSeq.getConstArray();
869             const sal_uInt16 nCount = static_cast<sal_uInt16>(aSeq.getLength());
870             for(sal_uInt16 i = 0; i < nCount ; i++)
871             {
872                 SvxTabAdjust eAdjust = SvxTabAdjust::Default;
873                 switch(pArr[i].Alignment)
874                 {
875                 case style::TabAlign_LEFT   : eAdjust = SvxTabAdjust::Left; break;
876                 case style::TabAlign_CENTER : eAdjust = SvxTabAdjust::Center; break;
877                 case style::TabAlign_RIGHT  : eAdjust = SvxTabAdjust::Right; break;
878                 case style::TabAlign_DECIMAL: eAdjust = SvxTabAdjust::Decimal; break;
879                 default: ;//prevent warning
880                 }
881                 sal_Unicode cFill = pArr[i].FillChar;
882                 sal_Unicode cDecimal = pArr[i].DecimalChar;
883                 SvxTabStop aTab( bConvert ? convertMm100ToTwip(pArr[i].Position) : pArr[i].Position,
884                                     eAdjust,
885                                     cDecimal,
886                                     cFill );
887                 Insert(aTab);
888             }
889             break;
890         }
891         case MID_STD_TAB:
892         {
893             sal_Int32 nNewPos = 0;
894             if (!(rVal >>= nNewPos) )
895                 return false;
896             if (bConvert)
897                 nNewPos = convertMm100ToTwip ( nNewPos );
898             if (nNewPos <= 0)
899                 return false;
900             const SvxTabStop& rTab = maTabStops.front();
901             SvxTabStop aNewTab ( nNewPos, rTab.GetAdjustment(), rTab.GetDecimal(), rTab.GetFill() );
902             Remove( 0 );
903             Insert( aNewTab );
904             break;
905         }
906     }
907     return true;
908 }
909 
910 
operator ==(const SfxPoolItem & rAttr) const911 bool SvxTabStopItem::operator==( const SfxPoolItem& rAttr ) const
912 {
913     assert(SfxPoolItem::operator==(rAttr));
914 
915     const SvxTabStopItem& rTSI = static_cast<const SvxTabStopItem&>(rAttr);
916 
917     if ( Count() != rTSI.Count() )
918         return false;
919 
920     for ( sal_uInt16 i = 0; i < Count(); ++i )
921         if( (*this)[i] != rTSI[i] )
922             return false;
923     return true;
924 }
925 
Clone(SfxItemPool *) const926 SvxTabStopItem* SvxTabStopItem::Clone( SfxItemPool * ) const
927 {
928     return new SvxTabStopItem( *this );
929 }
930 
GetPresentation(SfxItemPresentation ePres,MapUnit eCoreUnit,MapUnit ePresUnit,OUString & rText,const IntlWrapper & rIntl) const931 bool SvxTabStopItem::GetPresentation
932 (
933     SfxItemPresentation ePres,
934     MapUnit             eCoreUnit,
935     MapUnit             ePresUnit,
936     OUString&           rText, const IntlWrapper& rIntl
937 )   const
938 {
939     rText.clear();
940 
941     bool bComma = false;
942 
943     for ( sal_uInt16 i = 0; i < Count(); ++i )
944     {
945         if ( SvxTabAdjust::Default != ((*this)[i]).GetAdjustment() )
946         {
947             if ( bComma )
948                 rText += ",";
949             rText += GetMetricText(
950                 ((*this)[i]).GetTabPos(), eCoreUnit, ePresUnit, &rIntl );
951             if ( SfxItemPresentation::Complete == ePres )
952             {
953                 rText += " " + EditResId(GetMetricId(ePresUnit));
954             }
955             bComma = true;
956         }
957     }
958     return true;
959 }
960 
961 
Insert(const SvxTabStop & rTab)962 bool SvxTabStopItem::Insert( const SvxTabStop& rTab )
963 {
964     sal_uInt16 nTabPos = GetPos(rTab);
965     if(SVX_TAB_NOTFOUND != nTabPos )
966         Remove(nTabPos);
967     return maTabStops.insert( rTab ).second;
968 }
969 
Insert(const SvxTabStopItem * pTabs)970 void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs )
971 {
972     for( sal_uInt16 i = 0; i < pTabs->Count(); i++ )
973     {
974         const SvxTabStop& rTab = (*pTabs)[i];
975         sal_uInt16 nTabPos = GetPos(rTab);
976         if(SVX_TAB_NOTFOUND != nTabPos)
977             Remove(nTabPos);
978     }
979     for( sal_uInt16 i = 0; i < pTabs->Count(); i++ )
980     {
981         maTabStops.insert( (*pTabs)[i] );
982     }
983 }
984 
dumpAsXml(xmlTextWriterPtr pWriter) const985 void SvxTabStopItem::dumpAsXml(xmlTextWriterPtr pWriter) const
986 {
987     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTabStopItem"));
988     for (const auto& rTabStop : maTabStops)
989         rTabStop.dumpAsXml(pWriter);
990     (void)xmlTextWriterEndElement(pWriter);
991 }
992 
993 // class SvxFormatSplitItem -------------------------------------------------
~SvxFormatSplitItem()994 SvxFormatSplitItem::~SvxFormatSplitItem()
995 {
996 }
997 
Clone(SfxItemPool *) const998 SvxFormatSplitItem* SvxFormatSplitItem::Clone( SfxItemPool * ) const
999 {
1000     return new SvxFormatSplitItem( *this );
1001 }
1002 
GetPresentation(SfxItemPresentation,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const1003 bool SvxFormatSplitItem::GetPresentation
1004 (
1005     SfxItemPresentation /*ePres*/,
1006     MapUnit             /*eCoreUnit*/,
1007     MapUnit             /*ePresUnit*/,
1008     OUString&           rText, const IntlWrapper&
1009 )   const
1010 {
1011     const char* pId = RID_SVXITEMS_FMTSPLIT_FALSE;
1012 
1013     if ( GetValue() )
1014         pId = RID_SVXITEMS_FMTSPLIT_TRUE;
1015     rText = EditResId(pId);
1016     return true;
1017 }
1018 
Clone(SfxItemPool *) const1019 SvxPageModelItem* SvxPageModelItem::Clone( SfxItemPool* ) const
1020 {
1021     return new SvxPageModelItem( *this );
1022 }
1023 
QueryValue(css::uno::Any & rVal,sal_uInt8 nMemberId) const1024 bool SvxPageModelItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) const
1025 {
1026     nMemberId &= ~CONVERT_TWIPS;
1027 
1028     switch ( nMemberId )
1029     {
1030         case MID_AUTO: rVal <<= bAuto; break;
1031         case MID_NAME: rVal <<= GetValue(); break;
1032         default: OSL_FAIL("Wrong MemberId!"); return false;
1033     }
1034 
1035     return true;
1036 }
1037 
PutValue(const css::uno::Any & rVal,sal_uInt8 nMemberId)1038 bool SvxPageModelItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
1039 {
1040     nMemberId &= ~CONVERT_TWIPS;
1041     bool bRet;
1042     OUString aStr;
1043     switch ( nMemberId )
1044     {
1045         case MID_AUTO: bRet = ( rVal >>= bAuto ); break;
1046         case MID_NAME: bRet = ( rVal >>= aStr ); if ( bRet ) SetValue(aStr); break;
1047         default: OSL_FAIL("Wrong MemberId!"); return false;
1048     }
1049 
1050     return bRet;
1051 }
1052 
operator ==(const SfxPoolItem & rAttr) const1053 bool SvxPageModelItem::operator==( const SfxPoolItem& rAttr ) const
1054 {
1055     return SfxStringItem::operator==(rAttr) &&
1056            bAuto == static_cast<const SvxPageModelItem&>( rAttr ).bAuto;
1057 }
1058 
GetPresentation(SfxItemPresentation ePres,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const1059 bool SvxPageModelItem::GetPresentation
1060 (
1061     SfxItemPresentation ePres,
1062     MapUnit             /*eCoreUnit*/,
1063     MapUnit             /*ePresUnit*/,
1064     OUString&           rText, const IntlWrapper&
1065 )   const
1066 {
1067     rText.clear();
1068     bool bSet = !GetValue().isEmpty();
1069 
1070     switch ( ePres )
1071     {
1072         case SfxItemPresentation::Nameless:
1073             if ( bSet )
1074                 rText = GetValue();
1075             return true;
1076 
1077         case SfxItemPresentation::Complete:
1078             if ( bSet )
1079             {
1080                 rText = EditResId(RID_SVXITEMS_PAGEMODEL_COMPLETE) + GetValue();
1081             }
1082             return true;
1083         default: ;//prevent warning
1084     }
1085     return false;
1086 }
1087 
1088 
SvxScriptSpaceItem(bool bOn,const sal_uInt16 nId)1089 SvxScriptSpaceItem::SvxScriptSpaceItem( bool bOn, const sal_uInt16 nId )
1090     : SfxBoolItem( nId, bOn )
1091 {
1092 }
1093 
Clone(SfxItemPool *) const1094 SvxScriptSpaceItem* SvxScriptSpaceItem::Clone( SfxItemPool * ) const
1095 {
1096     return new SvxScriptSpaceItem( *this );
1097 }
1098 
GetPresentation(SfxItemPresentation,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const1099 bool SvxScriptSpaceItem::GetPresentation(
1100         SfxItemPresentation /*ePres*/,
1101         MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
1102         OUString &rText, const IntlWrapper& /*rIntl*/ ) const
1103 {
1104     rText = EditResId( !GetValue()
1105                             ? RID_SVXITEMS_SCRPTSPC_OFF
1106                             : RID_SVXITEMS_SCRPTSPC_ON );
1107     return true;
1108 }
1109 
1110 
SvxHangingPunctuationItem(bool bOn,const sal_uInt16 nId)1111 SvxHangingPunctuationItem::SvxHangingPunctuationItem(
1112                                     bool bOn, const sal_uInt16 nId )
1113     : SfxBoolItem( nId, bOn )
1114 {
1115 }
1116 
Clone(SfxItemPool *) const1117 SvxHangingPunctuationItem* SvxHangingPunctuationItem::Clone( SfxItemPool * ) const
1118 {
1119     return new SvxHangingPunctuationItem( *this );
1120 }
1121 
GetPresentation(SfxItemPresentation,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const1122 bool SvxHangingPunctuationItem::GetPresentation(
1123         SfxItemPresentation /*ePres*/,
1124         MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
1125         OUString &rText, const IntlWrapper& /*rIntl*/ ) const
1126 {
1127     rText = EditResId( !GetValue()
1128                             ? RID_SVXITEMS_HNGPNCT_OFF
1129                             : RID_SVXITEMS_HNGPNCT_ON );
1130     return true;
1131 }
1132 
1133 
SvxForbiddenRuleItem(bool bOn,const sal_uInt16 nId)1134 SvxForbiddenRuleItem::SvxForbiddenRuleItem(
1135                                     bool bOn, const sal_uInt16 nId )
1136     : SfxBoolItem( nId, bOn )
1137 {
1138 }
1139 
Clone(SfxItemPool *) const1140 SvxForbiddenRuleItem* SvxForbiddenRuleItem::Clone( SfxItemPool * ) const
1141 {
1142     return new SvxForbiddenRuleItem( *this );
1143 }
1144 
GetPresentation(SfxItemPresentation,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const1145 bool SvxForbiddenRuleItem::GetPresentation(
1146         SfxItemPresentation /*ePres*/,
1147         MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
1148         OUString &rText, const IntlWrapper& /*rIntl*/ ) const
1149 {
1150     rText = EditResId( !GetValue()
1151                             ? RID_SVXITEMS_FORBIDDEN_RULE_OFF
1152                             : RID_SVXITEMS_FORBIDDEN_RULE_ON );
1153     return true;
1154 }
1155 
1156 /*************************************************************************
1157 |*    class SvxParaVertAlignItem
1158 *************************************************************************/
1159 
SvxParaVertAlignItem(Align nValue,const sal_uInt16 nW)1160 SvxParaVertAlignItem::SvxParaVertAlignItem( Align nValue,
1161     const sal_uInt16 nW )
1162     : SfxUInt16Item( nW, static_cast<sal_uInt16>(nValue) )
1163 {
1164 }
1165 
Clone(SfxItemPool *) const1166 SvxParaVertAlignItem* SvxParaVertAlignItem::Clone( SfxItemPool* ) const
1167 {
1168     return new SvxParaVertAlignItem( *this );
1169 }
1170 
GetPresentation(SfxItemPresentation,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const1171 bool SvxParaVertAlignItem::GetPresentation(
1172         SfxItemPresentation /*ePres*/,
1173         MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
1174         OUString &rText, const IntlWrapper& ) const
1175 {
1176     const char* pTmp;
1177     switch( GetValue() )
1178     {
1179         case Align::Automatic: pTmp = RID_SVXITEMS_PARAVERTALIGN_AUTO; break;
1180         case Align::Top:       pTmp = RID_SVXITEMS_PARAVERTALIGN_TOP; break;
1181         case Align::Center:    pTmp = RID_SVXITEMS_PARAVERTALIGN_CENTER; break;
1182         case Align::Bottom:    pTmp = RID_SVXITEMS_PARAVERTALIGN_BOTTOM; break;
1183         default:    pTmp = RID_SVXITEMS_PARAVERTALIGN_BASELINE; break;
1184     }
1185     rText = EditResId(pTmp);
1186     return true;
1187 }
1188 
QueryValue(css::uno::Any & rVal,sal_uInt8) const1189 bool SvxParaVertAlignItem::QueryValue( css::uno::Any& rVal,
1190                                            sal_uInt8 /*nMemberId*/ ) const
1191 {
1192     rVal <<= static_cast<sal_Int16>(GetValue());
1193     return true;
1194 }
1195 
PutValue(const css::uno::Any & rVal,sal_uInt8)1196 bool SvxParaVertAlignItem::PutValue( const css::uno::Any& rVal,
1197                                          sal_uInt8 /*nMemberId*/ )
1198 {
1199     sal_Int16 nVal = sal_Int16();
1200     if((rVal >>= nVal) && nVal >=0 && nVal <= sal_uInt16(Align::Bottom) )
1201     {
1202         SetValue( static_cast<Align>(nVal) );
1203         return true;
1204     }
1205     else
1206         return false;
1207 }
1208 
SvxParaGridItem(bool bOn,const sal_uInt16 nId)1209 SvxParaGridItem::SvxParaGridItem( bool bOn, const sal_uInt16 nId )
1210     : SfxBoolItem( nId, bOn )
1211 {
1212 }
1213 
Clone(SfxItemPool *) const1214 SvxParaGridItem* SvxParaGridItem::Clone( SfxItemPool * ) const
1215 {
1216     return new SvxParaGridItem( *this );
1217 }
1218 
GetPresentation(SfxItemPresentation,MapUnit,MapUnit,OUString & rText,const IntlWrapper &) const1219 bool SvxParaGridItem::GetPresentation(
1220         SfxItemPresentation /*ePres*/,
1221         MapUnit /*eCoreMetric*/, MapUnit /*ePresMetric*/,
1222         OUString &rText, const IntlWrapper& /*rIntl*/ ) const
1223 {
1224     rText = GetValue() ?
1225             EditResId( RID_SVXITEMS_PARASNAPTOGRID_ON ) :
1226             EditResId( RID_SVXITEMS_PARASNAPTOGRID_OFF );
1227 
1228     return true;
1229 }
1230 
1231 
1232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1233