Bump version to 4.1-6
[LibreOffice.git] / editeng / source / items / paraitem.cxx
blob8210fbbe72b5057ba6c61de30c1bf78369a2b262
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <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 <comphelper/processfactory.hxx>
25 #include <unotools/syslocale.hxx>
26 #include <comphelper/types.hxx>
27 #include <tools/rtti.hxx>
28 #include <svl/itempool.hxx>
29 #include <svl/memberid.hrc>
30 #include <editeng/editrids.hrc>
31 #include <editeng/lspcitem.hxx>
32 #include <editeng/adjustitem.hxx>
33 #include <editeng/orphitem.hxx>
34 #include <editeng/widwitem.hxx>
35 #include <editeng/tstpitem.hxx>
36 #include <editeng/pmdlitem.hxx>
37 #include <editeng/spltitem.hxx>
38 #include <editeng/hyphenzoneitem.hxx>
39 #include <editeng/scriptspaceitem.hxx>
40 #include <editeng/hngpnctitem.hxx>
41 #include <editeng/forbiddenruleitem.hxx>
42 #include <editeng/paravertalignitem.hxx>
43 #include <editeng/pgrditem.hxx>
44 #include <rtl/ustring.hxx>
45 #include <editeng/memberids.hrc>
46 #include <editeng/editids.hrc>
47 #include <editeng/itemtype.hxx>
48 #include <editeng/eerdll.hxx>
49 #include <editeng/paperinf.hxx>
50 #include <vcl/svapp.hxx>
51 #include <algorithm>
53 using namespace ::rtl;
54 using namespace ::com::sun::star;
56 // Konvertierung fuer UNO
57 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
58 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
59 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
60 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
63 // STATIC DATA -----------------------------------------------------------
66 // -----------------------------------------------------------------------
69 TYPEINIT1_FACTORY(SvxLineSpacingItem, SfxPoolItem , new SvxLineSpacingItem(LINE_SPACE_DEFAULT_HEIGHT, 0));
70 TYPEINIT1_FACTORY(SvxAdjustItem, SfxPoolItem, new SvxAdjustItem(SVX_ADJUST_LEFT, 0));
71 TYPEINIT1_FACTORY(SvxWidowsItem, SfxByteItem, new SvxWidowsItem(0, 0));
72 TYPEINIT1_FACTORY(SvxOrphansItem, SfxByteItem, new SvxOrphansItem(0, 0));
73 TYPEINIT1_FACTORY(SvxHyphenZoneItem, SfxPoolItem, new SvxHyphenZoneItem(sal_False, 0));
74 TYPEINIT1_FACTORY(SvxTabStopItem, SfxPoolItem, new SvxTabStopItem(0));
75 TYPEINIT1_FACTORY(SvxFmtSplitItem, SfxBoolItem, new SvxFmtSplitItem(sal_False, 0));
76 TYPEINIT1_FACTORY(SvxPageModelItem, SfxStringItem, new SvxPageModelItem(0));
77 TYPEINIT1_FACTORY(SvxScriptSpaceItem, SfxBoolItem, new SvxScriptSpaceItem(sal_False, 0));
78 TYPEINIT1_FACTORY(SvxHangingPunctuationItem, SfxBoolItem, new SvxHangingPunctuationItem(sal_False, 0));
79 TYPEINIT1_FACTORY(SvxForbiddenRuleItem, SfxBoolItem, new SvxForbiddenRuleItem(sal_False, 0));
80 TYPEINIT1_FACTORY(SvxParaVertAlignItem, SfxUInt16Item, new SvxParaVertAlignItem(0, 0));
81 TYPEINIT1_FACTORY(SvxParaGridItem, SfxBoolItem, new SvxParaGridItem(sal_True, 0));
83 // -----------------------------------------------------------------------
85 SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight, const sal_uInt16 nId )
86 : SfxEnumItemInterface( nId )
88 nPropLineSpace = 100;
89 nInterLineSpace = 0;
90 nLineHeight = nHeight;
91 eLineSpace = SVX_LINE_SPACE_AUTO;
92 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF;
95 // -----------------------------------------------------------------------
97 int SvxLineSpacingItem::operator==( const SfxPoolItem& rAttr ) const
99 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
101 const SvxLineSpacingItem& rLineSpace = (const SvxLineSpacingItem&)rAttr;
102 return (
103 // Same Linespacing Rule?
104 (eLineSpace == rLineSpace.eLineSpace)
105 // For maximum and minimum Linespacing be the size must coincide.
106 && (eLineSpace == SVX_LINE_SPACE_AUTO ||
107 nLineHeight == rLineSpace.nLineHeight)
108 // Same Linespacing Rule?
109 && ( eInterLineSpace == rLineSpace.eInterLineSpace )
110 // Either set proportional or additive.
111 && (( eInterLineSpace == SVX_INTER_LINE_SPACE_OFF)
112 || (eInterLineSpace == SVX_INTER_LINE_SPACE_PROP
113 && nPropLineSpace == rLineSpace.nPropLineSpace)
114 || (eInterLineSpace == SVX_INTER_LINE_SPACE_FIX
115 && (nInterLineSpace == rLineSpace.nInterLineSpace)))) ?
116 1 : 0;
119 /* Who does still know why the LineSpacingItem is so complicated?
120 We can not use it for UNO since there are only two values:
121 - ein sal_uInt16 for the mode
122 - ein sal_uInt32 for all values (distance, height, rel. detail)
124 bool SvxLineSpacingItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
126 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
127 nMemberId &= ~CONVERT_TWIPS;
129 style::LineSpacing aLSp;
130 switch( eLineSpace )
132 case SVX_LINE_SPACE_AUTO:
133 if(eInterLineSpace == SVX_INTER_LINE_SPACE_FIX)
135 aLSp.Mode = style::LineSpacingMode::LEADING;
136 aLSp.Height = ( bConvert ? (short)TWIP_TO_MM100(nInterLineSpace) : nInterLineSpace);
138 else if(eInterLineSpace == SVX_INTER_LINE_SPACE_OFF)
140 aLSp.Mode = style::LineSpacingMode::PROP;
141 aLSp.Height = 100;
143 else
145 aLSp.Mode = style::LineSpacingMode::PROP;
146 aLSp.Height = nPropLineSpace;
148 break;
149 case SVX_LINE_SPACE_FIX :
150 case SVX_LINE_SPACE_MIN :
151 aLSp.Mode = eLineSpace == SVX_LINE_SPACE_FIX ? style::LineSpacingMode::FIX : style::LineSpacingMode::MINIMUM;
152 aLSp.Height = ( bConvert ? (short)TWIP_TO_MM100_UNSIGNED(nLineHeight) : nLineHeight );
153 break;
154 default:
155 ;//prevent warning about SVX_LINE_SPACE_END
158 switch ( nMemberId )
160 case 0 : rVal <<= aLSp; break;
161 case MID_LINESPACE : rVal <<= aLSp.Mode; break;
162 case MID_HEIGHT : rVal <<= aLSp.Height; break;
163 default: OSL_FAIL("Wrong MemberId!"); break;
166 return true;
169 bool SvxLineSpacingItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
171 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
172 nMemberId &= ~CONVERT_TWIPS;
174 // fill with current data
175 style::LineSpacing aLSp;
176 uno::Any aAny;
177 sal_Bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aLSp );
179 // get new data
180 switch ( nMemberId )
182 case 0 : bRet = (rVal >>= aLSp); break;
183 case MID_LINESPACE : bRet = (rVal >>= aLSp.Mode); break;
184 case MID_HEIGHT : bRet = (rVal >>= aLSp.Height); break;
185 default: OSL_FAIL("Wrong MemberId!"); break;
188 if( bRet )
190 nLineHeight = aLSp.Height;
191 switch( aLSp.Mode )
193 case style::LineSpacingMode::LEADING:
195 eInterLineSpace = SVX_INTER_LINE_SPACE_FIX;
196 eLineSpace = SVX_LINE_SPACE_AUTO;
197 nInterLineSpace = aLSp.Height;
198 if(bConvert)
199 nInterLineSpace = (short)MM100_TO_TWIP(nInterLineSpace);
202 break;
203 case style::LineSpacingMode::PROP:
205 eLineSpace = SVX_LINE_SPACE_AUTO;
206 nPropLineSpace = (sal_Int8)std::min(aLSp.Height, (short)0xFF);
207 if(100 == aLSp.Height)
208 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF;
209 else
210 eInterLineSpace = SVX_INTER_LINE_SPACE_PROP;
212 break;
213 case style::LineSpacingMode::FIX:
214 case style::LineSpacingMode::MINIMUM:
216 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF;
217 eLineSpace = aLSp.Mode == style::LineSpacingMode::FIX ? SVX_LINE_SPACE_FIX : SVX_LINE_SPACE_MIN;
218 nLineHeight = aLSp.Height;
219 if(bConvert)
220 nLineHeight = (sal_uInt16)MM100_TO_TWIP_UNSIGNED(nLineHeight);
222 break;
226 return bRet;
229 // -----------------------------------------------------------------------
231 SfxPoolItem* SvxLineSpacingItem::Clone( SfxItemPool * ) const
233 return new SvxLineSpacingItem( *this );
236 //------------------------------------------------------------------------
238 SfxItemPresentation SvxLineSpacingItem::GetPresentation
240 SfxItemPresentation /*ePres*/,
241 SfxMapUnit /*eCoreUnit*/,
242 SfxMapUnit /*ePresUnit*/,
243 OUString& rText, const IntlWrapper *
244 ) const
246 #ifdef DBG_UTIL
247 rText = "SvxLineSpacingItem";
248 #else
249 rText = OUString();
250 #endif
251 return SFX_ITEM_PRESENTATION_NONE;
254 // -----------------------------------------------------------------------
256 SfxPoolItem* SvxLineSpacingItem::Create(SvStream& rStrm, sal_uInt16) const
258 sal_Int8 nPropSpace;
259 short nInterSpace;
260 sal_uInt16 nHeight;
261 sal_Int8 nRule, nInterRule;
263 rStrm >> nPropSpace
264 >> nInterSpace
265 >> nHeight
266 >> nRule
267 >> nInterRule;
269 SvxLineSpacingItem* pAttr = new SvxLineSpacingItem( nHeight, Which() );
270 pAttr->SetInterLineSpace( nInterSpace );
271 pAttr->SetPropLineSpace( nPropSpace );
272 pAttr->GetLineSpaceRule() = (SvxLineSpace)nRule;
273 pAttr->GetInterLineSpaceRule() = (SvxInterLineSpace)nInterRule;
274 return pAttr;
277 // -----------------------------------------------------------------------
279 SvStream& SvxLineSpacingItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
281 rStrm << (sal_Int8) GetPropLineSpace()
282 << (short) GetInterLineSpace()
283 << (sal_uInt16) GetLineHeight()
284 << (sal_Int8) GetLineSpaceRule()
285 << (sal_Int8) GetInterLineSpaceRule();
286 return rStrm;
289 // -----------------------------------------------------------------------
291 sal_uInt16 SvxLineSpacingItem::GetValueCount() const
293 return SVX_LINESPACE_END; // SVX_LINESPACE_TWO_LINES + 1
296 // -----------------------------------------------------------------------
298 OUString SvxLineSpacingItem::GetValueTextByPos( sal_uInt16 nPos ) const
300 //! load strings from resource
301 OUString aText;
302 switch ( nPos )
304 case SVX_LINESPACE_USER:
305 aText = "User";
306 break;
307 case SVX_LINESPACE_ONE_LINE:
308 aText = "One line";
309 break;
310 case SVX_LINESPACE_ONE_POINT_FIVE_LINES:
311 aText = "1.5 line";
312 break;
313 case SVX_LINESPACE_TWO_LINES:
314 aText = "Two lines";
315 break;
317 return aText;
320 // -----------------------------------------------------------------------
322 sal_uInt16 SvxLineSpacingItem::GetEnumValue() const
324 sal_uInt16 nVal;
325 switch ( nPropLineSpace )
327 case 100: nVal = SVX_LINESPACE_ONE_LINE; break;
328 case 150: nVal = SVX_LINESPACE_ONE_POINT_FIVE_LINES; break;
329 case 200: nVal = SVX_LINESPACE_TWO_LINES; break;
330 default: nVal = SVX_LINESPACE_USER; break;
332 return nVal;
335 // -----------------------------------------------------------------------
337 void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal )
339 switch ( nVal )
341 case SVX_LINESPACE_ONE_LINE: nPropLineSpace = 100; break;
342 case SVX_LINESPACE_ONE_POINT_FIVE_LINES: nPropLineSpace = 150; break;
343 case SVX_LINESPACE_TWO_LINES: nPropLineSpace = 200; break;
347 // class SvxAdjustItem ---------------------------------------------------
349 SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst, const sal_uInt16 nId )
350 : SfxEnumItemInterface( nId ),
351 bOneBlock( sal_False ), bLastCenter( sal_False ), bLastBlock( sal_False )
353 SetAdjust( eAdjst );
356 // -----------------------------------------------------------------------
358 int SvxAdjustItem::operator==( const SfxPoolItem& rAttr ) const
360 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
362 return( ( GetAdjust() == ((SvxAdjustItem&)rAttr).GetAdjust() &&
363 bOneBlock == ((SvxAdjustItem&)rAttr).bOneBlock &&
364 bLastCenter == ((SvxAdjustItem&)rAttr).bLastCenter &&
365 bLastBlock == ((SvxAdjustItem&)rAttr).bLastBlock )
366 ? 1 : 0 );
369 bool SvxAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
371 nMemberId &= ~CONVERT_TWIPS;
372 switch( nMemberId )
374 case MID_PARA_ADJUST : rVal <<= (sal_Int16)GetAdjust(); break;
375 case MID_LAST_LINE_ADJUST : rVal <<= (sal_Int16)GetLastBlock(); break;
376 case MID_EXPAND_SINGLE :
378 sal_Bool bValue = bOneBlock;
379 rVal.setValue( &bValue, ::getCppuBooleanType() );
380 break;
382 default: ;//prevent warning
384 return true;
387 bool SvxAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
389 nMemberId &= ~CONVERT_TWIPS;
390 switch( nMemberId )
392 case MID_PARA_ADJUST :
393 case MID_LAST_LINE_ADJUST :
395 sal_Int32 eVal = - 1;
398 eVal = ::comphelper::getEnumAsINT32(rVal);
400 catch(...) {}
401 if(eVal >= 0 && eVal <= 4)
403 if(MID_LAST_LINE_ADJUST == nMemberId &&
404 eVal != SVX_ADJUST_LEFT &&
405 eVal != SVX_ADJUST_BLOCK &&
406 eVal != SVX_ADJUST_CENTER)
407 return sal_False;
408 if(eVal < (sal_uInt16)SVX_ADJUST_END)
409 nMemberId == MID_PARA_ADJUST ?
410 SetAdjust((SvxAdjust)eVal) :
411 SetLastBlock((SvxAdjust)eVal);
414 break;
415 case MID_EXPAND_SINGLE :
416 bOneBlock = Any2Bool(rVal);
417 break;
419 return true;
422 // -----------------------------------------------------------------------
424 SfxPoolItem* SvxAdjustItem::Clone( SfxItemPool * ) const
426 return new SvxAdjustItem( *this );
429 //------------------------------------------------------------------------
431 SfxItemPresentation SvxAdjustItem::GetPresentation
433 SfxItemPresentation ePres,
434 SfxMapUnit /*eCoreUnit*/,
435 SfxMapUnit /*ePresUnit*/,
436 OUString& rText, const IntlWrapper *
437 ) const
439 switch ( ePres )
441 case SFX_ITEM_PRESENTATION_NONE:
442 rText = OUString();
443 return SFX_ITEM_PRESENTATION_NONE;
444 case SFX_ITEM_PRESENTATION_NAMELESS:
445 case SFX_ITEM_PRESENTATION_COMPLETE:
446 rText = GetValueTextByPos( (sal_uInt16)GetAdjust() );
447 return ePres;
448 default: ;//prevent warning
450 return SFX_ITEM_PRESENTATION_NONE;
453 // -----------------------------------------------------------------------
455 sal_uInt16 SvxAdjustItem::GetValueCount() const
457 return SVX_ADJUST_END; // SVX_ADJUST_BLOCKLINE + 1
460 // -----------------------------------------------------------------------
462 OUString SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos ) const
464 DBG_ASSERT( nPos <= (sal_uInt16)SVX_ADJUST_BLOCKLINE, "enum overflow!" );
465 return EE_RESSTR(RID_SVXITEMS_ADJUST_BEGIN + nPos);
468 // -----------------------------------------------------------------------
470 sal_uInt16 SvxAdjustItem::GetEnumValue() const
472 return (sal_uInt16)GetAdjust();
475 // -----------------------------------------------------------------------
477 void SvxAdjustItem::SetEnumValue( sal_uInt16 nVal )
479 SetAdjust( (const SvxAdjust)nVal );
482 // -----------------------------------------------------------------------
484 sal_uInt16 SvxAdjustItem::GetVersion( sal_uInt16 nFileVersion ) const
486 return (nFileVersion == SOFFICE_FILEFORMAT_31)
487 ? 0 : ADJUST_LASTBLOCK_VERSION;
490 // -----------------------------------------------------------------------
492 SfxPoolItem* SvxAdjustItem::Create(SvStream& rStrm, sal_uInt16 nVersion) const
494 char eAdjustment;
495 rStrm >> eAdjustment;
496 SvxAdjustItem *pRet = new SvxAdjustItem( (SvxAdjust)eAdjustment, Which() );
497 if( nVersion >= ADJUST_LASTBLOCK_VERSION )
499 sal_Int8 nFlags;
500 rStrm >> nFlags;
501 pRet->bOneBlock = 0 != (nFlags & 0x0001);
502 pRet->bLastCenter = 0 != (nFlags & 0x0002);
503 pRet->bLastBlock = 0 != (nFlags & 0x0004);
505 return pRet;
508 // -----------------------------------------------------------------------
510 SvStream& SvxAdjustItem::Store( SvStream& rStrm, sal_uInt16 nItemVersion ) const
512 rStrm << (char)GetAdjust();
513 if ( nItemVersion >= ADJUST_LASTBLOCK_VERSION )
515 sal_Int8 nFlags = 0;
516 if ( bOneBlock )
517 nFlags |= 0x0001;
518 if ( bLastCenter )
519 nFlags |= 0x0002;
520 if ( bLastBlock )
521 nFlags |= 0x0004;
522 rStrm << (sal_Int8) nFlags;
524 return rStrm;
527 // class SvxWidowsItem ---------------------------------------------------
529 SvxWidowsItem::SvxWidowsItem(const sal_uInt8 nL, const sal_uInt16 nId ) :
530 SfxByteItem( nId, nL )
534 // -----------------------------------------------------------------------
536 SfxPoolItem* SvxWidowsItem::Clone( SfxItemPool * ) const
538 return new SvxWidowsItem( *this );
541 // -----------------------------------------------------------------------
543 SfxPoolItem* SvxWidowsItem::Create(SvStream& rStrm, sal_uInt16) const
545 sal_Int8 nLines;
546 rStrm >> nLines;
547 return new SvxWidowsItem( nLines, Which() );
550 // -----------------------------------------------------------------------
552 SvStream& SvxWidowsItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
554 rStrm << (sal_Int8)GetValue();
555 return rStrm;
558 //------------------------------------------------------------------------
560 SfxItemPresentation SvxWidowsItem::GetPresentation
562 SfxItemPresentation ePres,
563 SfxMapUnit /*eCoreUnit*/,
564 SfxMapUnit /*ePresUnit*/,
565 OUString& rText, const IntlWrapper *
566 ) const
568 switch ( ePres )
570 case SFX_ITEM_PRESENTATION_NONE:
572 rText = OUString();
573 break;
576 case SFX_ITEM_PRESENTATION_NAMELESS:
578 rText = EE_RESSTR(RID_SVXITEMS_LINES);
579 break;
582 case SFX_ITEM_PRESENTATION_COMPLETE:
584 rText = EE_RESSTR(RID_SVXITEMS_WIDOWS_COMPLETE) + " " + EE_RESSTR(RID_SVXITEMS_LINES);
587 default:
589 SAL_WARN( "editeng.items", "SvxWidowsItem::GetPresentation(): unknown SfxItemPresentation" );
593 rText = rText.replaceFirst( "%1", OUString::number( GetValue() ) );
594 return ePres;
597 // class SvxOrphansItem --------------------------------------------------
599 SvxOrphansItem::SvxOrphansItem(const sal_uInt8 nL, const sal_uInt16 nId ) :
600 SfxByteItem( nId, nL )
604 // -----------------------------------------------------------------------
606 SfxPoolItem* SvxOrphansItem::Clone( SfxItemPool * ) const
608 return new SvxOrphansItem( *this );
611 // -----------------------------------------------------------------------
613 SfxPoolItem* SvxOrphansItem::Create(SvStream& rStrm, sal_uInt16) const
615 sal_Int8 nLines;
616 rStrm >> nLines;
617 return new SvxOrphansItem( nLines, Which() );
620 // -----------------------------------------------------------------------
622 SvStream& SvxOrphansItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
624 rStrm << (sal_Int8) GetValue();
625 return rStrm;
628 //------------------------------------------------------------------------
630 SfxItemPresentation SvxOrphansItem::GetPresentation
632 SfxItemPresentation ePres,
633 SfxMapUnit /*eCoreUnit*/,
634 SfxMapUnit /*ePresUnit*/,
635 OUString& rText, const IntlWrapper *
636 ) const
638 switch ( ePres )
640 case SFX_ITEM_PRESENTATION_NONE:
642 rText = OUString();
643 break;
646 case SFX_ITEM_PRESENTATION_NAMELESS:
648 rText = EE_RESSTR(RID_SVXITEMS_LINES);
649 break;
652 case SFX_ITEM_PRESENTATION_COMPLETE:
654 rText = EE_RESSTR(RID_SVXITEMS_ORPHANS_COMPLETE) + " " + EE_RESSTR(RID_SVXITEMS_LINES);
657 default:
659 SAL_WARN( "editeng.items", "SvxOrphansItem::GetPresentation(): unknown SfxItemPresentation" );
663 rText = rText.replaceFirst( "%1", OUString::number( GetValue() ) );
664 return ePres;
667 // class SvxHyphenZoneItem -----------------------------------------------
669 SvxHyphenZoneItem::SvxHyphenZoneItem( const sal_Bool bHyph, const sal_uInt16 nId ) :
670 SfxPoolItem( nId )
672 bHyphen = bHyph;
673 bPageEnd = sal_True;
674 nMinLead = nMinTrail = 0;
675 nMaxHyphens = 255;
678 // -----------------------------------------------------------------------
679 bool SvxHyphenZoneItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
681 nMemberId &= ~CONVERT_TWIPS;
682 switch(nMemberId)
684 case MID_IS_HYPHEN:
685 rVal = Bool2Any(bHyphen);
686 break;
687 case MID_HYPHEN_MIN_LEAD:
688 rVal <<= (sal_Int16)nMinLead;
689 break;
690 case MID_HYPHEN_MIN_TRAIL:
691 rVal <<= (sal_Int16)nMinTrail;
692 break;
693 case MID_HYPHEN_MAX_HYPHENS:
694 rVal <<= (sal_Int16)nMaxHyphens;
695 break;
697 return true;
699 // -----------------------------------------------------------------------
700 bool SvxHyphenZoneItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
702 nMemberId &= ~CONVERT_TWIPS;
703 sal_Int16 nNewVal = 0;
705 if( nMemberId != MID_IS_HYPHEN )
706 if(!(rVal >>= nNewVal))
707 return false;
709 switch(nMemberId)
711 case MID_IS_HYPHEN:
712 bHyphen = Any2Bool(rVal);
713 break;
714 case MID_HYPHEN_MIN_LEAD:
715 nMinLead = (sal_uInt8)nNewVal;
716 break;
717 case MID_HYPHEN_MIN_TRAIL:
718 nMinTrail = (sal_uInt8)nNewVal;
719 break;
720 case MID_HYPHEN_MAX_HYPHENS:
721 nMaxHyphens = (sal_uInt8)nNewVal;
722 break;
724 return true;
727 // -----------------------------------------------------------------------
729 int SvxHyphenZoneItem::operator==( const SfxPoolItem& rAttr ) const
731 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
733 return ( (((SvxHyphenZoneItem&)rAttr).bHyphen == bHyphen)
734 && (((SvxHyphenZoneItem&)rAttr).bPageEnd == bPageEnd)
735 && (((SvxHyphenZoneItem&)rAttr).nMinLead == nMinLead)
736 && (((SvxHyphenZoneItem&)rAttr).nMinTrail == nMinTrail)
737 && (((SvxHyphenZoneItem&)rAttr).nMaxHyphens == nMaxHyphens) );
740 // -----------------------------------------------------------------------
742 SfxPoolItem* SvxHyphenZoneItem::Clone( SfxItemPool * ) const
744 return new SvxHyphenZoneItem( *this );
747 //------------------------------------------------------------------------
749 SfxItemPresentation SvxHyphenZoneItem::GetPresentation
751 SfxItemPresentation ePres,
752 SfxMapUnit /*eCoreUnit*/,
753 SfxMapUnit /*ePresUnit*/,
754 OUString& rText, const IntlWrapper *
755 ) const
757 OUString cpDelimTmp(cpDelim);
758 switch ( ePres )
760 case SFX_ITEM_PRESENTATION_NONE:
761 rText = OUString();
762 return SFX_ITEM_PRESENTATION_NONE;
763 case SFX_ITEM_PRESENTATION_NAMELESS:
765 sal_uInt16 nId = RID_SVXITEMS_HYPHEN_FALSE;
767 if ( bHyphen )
768 nId = RID_SVXITEMS_HYPHEN_TRUE;
769 rText = EE_RESSTR(nId) + cpDelimTmp;
770 nId = RID_SVXITEMS_PAGE_END_FALSE;
772 if ( bPageEnd )
773 nId = RID_SVXITEMS_PAGE_END_TRUE;
774 rText = rText + EE_RESSTR(nId) + cpDelimTmp +
775 OUString::number( nMinLead ) + cpDelimTmp +
776 OUString::number( nMinTrail ) + cpDelimTmp +
777 OUString::number( nMaxHyphens );
778 return SFX_ITEM_PRESENTATION_COMPLETE;
780 case SFX_ITEM_PRESENTATION_COMPLETE:
782 sal_uInt16 nId = RID_SVXITEMS_HYPHEN_FALSE;
784 if ( bHyphen )
785 nId = RID_SVXITEMS_HYPHEN_TRUE;
786 rText = EE_RESSTR(nId) + cpDelimTmp;
787 nId = RID_SVXITEMS_PAGE_END_FALSE;
789 if ( bPageEnd )
790 nId = RID_SVXITEMS_PAGE_END_TRUE;
791 rText = rText +
792 EE_RESSTR(nId) +
793 cpDelimTmp +
794 EE_RESSTR(RID_SVXITEMS_HYPHEN_MINLEAD).replaceAll("%1", OUString::number(nMinLead)) +
795 cpDelimTmp +
796 EE_RESSTR(RID_SVXITEMS_HYPHEN_MINTRAIL).replaceAll("%1", OUString::number(nMinTrail)) +
797 cpDelimTmp +
798 EE_RESSTR(RID_SVXITEMS_HYPHEN_MAX).replaceAll("%1", OUString::number(nMaxHyphens));
799 return SFX_ITEM_PRESENTATION_COMPLETE;
801 default: ;//prevent warning
803 return SFX_ITEM_PRESENTATION_NONE;
806 // -----------------------------------------------------------------------
808 SfxPoolItem* SvxHyphenZoneItem::Create(SvStream& rStrm, sal_uInt16) const
810 sal_Int8 _bHyphen, _bHyphenPageEnd;
811 sal_Int8 _nMinLead, _nMinTrail, _nMaxHyphens;
812 rStrm >> _bHyphen >> _bHyphenPageEnd >> _nMinLead >> _nMinTrail >> _nMaxHyphens;
813 SvxHyphenZoneItem* pAttr = new SvxHyphenZoneItem( sal_False, Which() );
814 pAttr->SetHyphen( sal_Bool( _bHyphen != 0 ) );
815 pAttr->SetPageEnd( sal_Bool( _bHyphenPageEnd != 0 ) );
816 pAttr->GetMinLead() = _nMinLead;
817 pAttr->GetMinTrail() = _nMinTrail;
818 pAttr->GetMaxHyphens() = _nMaxHyphens;
819 return pAttr;
822 // -----------------------------------------------------------------------
824 SvStream& SvxHyphenZoneItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
826 rStrm << (sal_Int8) IsHyphen()
827 << (sal_Int8) IsPageEnd()
828 << (sal_Int8) GetMinLead()
829 << (sal_Int8) GetMinTrail()
830 << (sal_Int8) GetMaxHyphens();
831 return rStrm;
834 // class SvxTabStop ------------------------------------------------------
836 SvxTabStop::SvxTabStop()
838 nTabPos = 0;
839 eAdjustment = SVX_TAB_ADJUST_LEFT;
840 m_cDecimal = cDfltDecimalChar;
841 cFill = cDfltFillChar;
844 // -----------------------------------------------------------------------
846 SvxTabStop::SvxTabStop( const sal_Int32 nPos, const SvxTabAdjust eAdjst,
847 const sal_Unicode cDec, const sal_Unicode cFil )
849 nTabPos = nPos;
850 eAdjustment = eAdjst;
851 m_cDecimal = cDec;
852 cFill = cFil;
854 // -----------------------------------------------------------------------------
855 void SvxTabStop::fillDecimal() const
857 if ( cDfltDecimalChar == m_cDecimal )
858 m_cDecimal = SvtSysLocale().GetLocaleData().getNumDecimalSep()[0];
860 // -----------------------------------------------------------------------
862 XubString SvxTabStop::GetValueString() const
864 XubString aStr;
866 aStr += sal_Unicode( '(' );
867 aStr += OUString::number(nTabPos);
868 aStr += cpDelim;
869 aStr += EE_RESSTR(RID_SVXITEMS_TAB_ADJUST_BEGIN + (sal_uInt16)eAdjustment);
871 aStr += cpDelim;
872 aStr += sal_Unicode('[');
873 aStr += EE_RESSTR(RID_SVXITEMS_TAB_DECIMAL_CHAR);
874 aStr += GetDecimal();
875 aStr += sal_Unicode(']');
876 aStr += cpDelim;
877 aStr += cpDelim;
878 aStr += sal_Unicode('[');
879 aStr += EE_RESSTR(RID_SVXITEMS_TAB_FILL_CHAR);
880 aStr += cFill;
881 aStr += sal_Unicode(']');
882 aStr += sal_Unicode(')');
884 return aStr;
887 // class SvxTabStopItem --------------------------------------------------
889 SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich ) :
890 SfxPoolItem( _nWhich ),
891 maTabStops()
893 const sal_uInt16 nTabs = SVX_TAB_DEFCOUNT, nDist = SVX_TAB_DEFDIST;
894 const SvxTabAdjust eAdjst= SVX_TAB_ADJUST_DEFAULT;
896 for (sal_uInt16 i = 0; i < nTabs; ++i)
898 SvxTabStop aTab( (i + 1) * nDist, eAdjst );
899 maTabStops.insert( aTab );
903 // -----------------------------------------------------------------------
905 SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs,
906 const sal_uInt16 nDist,
907 const SvxTabAdjust eAdjst,
908 sal_uInt16 _nWhich ) :
909 SfxPoolItem( _nWhich ),
910 maTabStops()
912 for ( sal_uInt16 i = 0; i < nTabs; ++i )
914 SvxTabStop aTab( (i + 1) * nDist, eAdjst );
915 maTabStops.insert( aTab );
919 // -----------------------------------------------------------------------
921 SvxTabStopItem::SvxTabStopItem( const SvxTabStopItem& rTSI ) :
922 SfxPoolItem( rTSI.Which() ),
923 maTabStops( rTSI.maTabStops )
927 // -----------------------------------------------------------------------
929 sal_uInt16 SvxTabStopItem::GetPos( const SvxTabStop& rTab ) const
931 SvxTabStopArr::const_iterator it = maTabStops.find( rTab );
932 return it != maTabStops.end() ? it - maTabStops.begin() : SVX_TAB_NOTFOUND;
935 // -----------------------------------------------------------------------
937 sal_uInt16 SvxTabStopItem::GetPos( const sal_Int32 nPos ) const
939 SvxTabStopArr::const_iterator it = maTabStops.find( SvxTabStop( nPos ) );
940 return it != maTabStops.end() ? it - maTabStops.begin() : SVX_TAB_NOTFOUND;
943 // -----------------------------------------------------------------------
945 SvxTabStopItem& SvxTabStopItem::operator=( const SvxTabStopItem& rTSI )
947 maTabStops = rTSI.maTabStops;
948 return *this;
951 bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
953 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
954 nMemberId &= ~CONVERT_TWIPS;
955 switch ( nMemberId )
957 case MID_TABSTOPS:
959 sal_uInt16 nCount = Count();
960 uno::Sequence< style::TabStop> aSeq(nCount);
961 style::TabStop* pArr = aSeq.getArray();
962 for(sal_uInt16 i = 0; i < nCount; i++)
964 const SvxTabStop& rTab = (*this)[i];
965 pArr[i].Position = bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos();
966 switch(rTab.GetAdjustment())
968 case SVX_TAB_ADJUST_LEFT : pArr[i].Alignment = style::TabAlign_LEFT; break;
969 case SVX_TAB_ADJUST_RIGHT : pArr[i].Alignment = style::TabAlign_RIGHT; break;
970 case SVX_TAB_ADJUST_DECIMAL: pArr[i].Alignment = style::TabAlign_DECIMAL; break;
971 case SVX_TAB_ADJUST_CENTER : pArr[i].Alignment = style::TabAlign_CENTER; break;
972 default: //SVX_TAB_ADJUST_DEFAULT
973 pArr[i].Alignment = style::TabAlign_DEFAULT;
976 pArr[i].DecimalChar = rTab.GetDecimal();
977 pArr[i].FillChar = rTab.GetFill();
979 rVal <<= aSeq;
980 break;
982 case MID_STD_TAB:
984 const SvxTabStop &rTab = maTabStops.front();
985 rVal <<= (static_cast<sal_Int32>(bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos()));
986 break;
989 return sal_True;
992 bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
994 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
995 nMemberId &= ~CONVERT_TWIPS;
996 switch ( nMemberId )
998 case MID_TABSTOPS:
1000 uno::Sequence< style::TabStop> aSeq;
1001 if(!(rVal >>= aSeq))
1003 uno::Sequence < uno::Sequence < uno::Any > > aAnySeq;
1004 if (!(rVal >>= aAnySeq))
1005 return sal_False;
1006 sal_Int32 nLength = aAnySeq.getLength();
1007 aSeq.realloc( nLength );
1008 for ( sal_Int32 n=0; n<nLength; n++ )
1010 uno::Sequence < uno::Any >& rAnySeq = aAnySeq[n];
1011 if ( rAnySeq.getLength() == 4 )
1013 if (!(rAnySeq[0] >>= aSeq[n].Position)) return sal_False;
1014 if (!(rAnySeq[1] >>= aSeq[n].Alignment))
1016 sal_Int32 nVal = 0;
1017 if (rAnySeq[1] >>= nVal)
1018 aSeq[n].Alignment = (com::sun::star::style::TabAlign) nVal;
1019 else
1020 return sal_False;
1022 if (!(rAnySeq[2] >>= aSeq[n].DecimalChar))
1024 OUString aVal;
1025 if ( (rAnySeq[2] >>= aVal) && aVal.getLength() == 1 )
1026 aSeq[n].DecimalChar = aVal.toChar();
1027 else
1028 return sal_False;
1030 if (!(rAnySeq[3] >>= aSeq[n].FillChar))
1032 OUString aVal;
1033 if ( (rAnySeq[3] >>= aVal) && aVal.getLength() == 1 )
1034 aSeq[n].FillChar = aVal.toChar();
1035 else
1036 return sal_False;
1039 else
1040 return sal_False;
1044 maTabStops.clear();
1045 const style::TabStop* pArr = aSeq.getConstArray();
1046 const sal_uInt16 nCount = (sal_uInt16)aSeq.getLength();
1047 for(sal_uInt16 i = 0; i < nCount ; i++)
1049 SvxTabAdjust eAdjust = SVX_TAB_ADJUST_DEFAULT;
1050 switch(pArr[i].Alignment)
1052 case style::TabAlign_LEFT : eAdjust = SVX_TAB_ADJUST_LEFT; break;
1053 case style::TabAlign_CENTER : eAdjust = SVX_TAB_ADJUST_CENTER; break;
1054 case style::TabAlign_RIGHT : eAdjust = SVX_TAB_ADJUST_RIGHT; break;
1055 case style::TabAlign_DECIMAL: eAdjust = SVX_TAB_ADJUST_DECIMAL; break;
1056 default: ;//prevent warning
1058 sal_Unicode cFill = pArr[i].FillChar;
1059 sal_Unicode cDecimal = pArr[i].DecimalChar;
1060 SvxTabStop aTab( bConvert ? MM100_TO_TWIP(pArr[i].Position) : pArr[i].Position,
1061 eAdjust,
1062 cDecimal,
1063 cFill );
1064 Insert(aTab);
1066 break;
1068 case MID_STD_TAB:
1070 sal_Int32 nNewPos = 0;
1071 if (!(rVal >>= nNewPos) )
1072 return sal_False;
1073 if (bConvert)
1074 nNewPos = MM100_TO_TWIP ( nNewPos );
1075 if (nNewPos <= 0)
1076 return sal_False;
1077 const SvxTabStop& rTab = maTabStops.front();
1078 SvxTabStop aNewTab ( nNewPos, rTab.GetAdjustment(), rTab.GetDecimal(), rTab.GetFill() );
1079 Remove( 0 );
1080 Insert( aNewTab );
1081 break;
1084 return sal_True;
1086 // -----------------------------------------------------------------------
1088 int SvxTabStopItem::operator==( const SfxPoolItem& rAttr ) const
1090 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1092 const SvxTabStopItem& rTSI = (SvxTabStopItem&)rAttr;
1094 if ( Count() != rTSI.Count() )
1095 return 0;
1097 for ( sal_uInt16 i = 0; i < Count(); ++i )
1098 if( !(*this)[i].IsEqual( rTSI[i] ) )
1099 return 0;
1100 return 1;
1103 // -----------------------------------------------------------------------
1105 SfxPoolItem* SvxTabStopItem::Clone( SfxItemPool * ) const
1107 return new SvxTabStopItem( *this );
1110 //------------------------------------------------------------------------
1112 SfxItemPresentation SvxTabStopItem::GetPresentation
1114 SfxItemPresentation ePres,
1115 SfxMapUnit eCoreUnit,
1116 SfxMapUnit ePresUnit,
1117 OUString& rText, const IntlWrapper *pIntl
1118 ) const
1120 rText = OUString();
1122 if ( ePres > SFX_ITEM_PRESENTATION_NONE )
1124 sal_Bool bComma = sal_False;
1126 for ( sal_uInt16 i = 0; i < Count(); ++i )
1128 if ( SVX_TAB_ADJUST_DEFAULT != ((*this)[i]).GetAdjustment() )
1130 if ( bComma )
1131 rText += ",";
1132 rText += GetMetricText(
1133 ((*this)[i]).GetTabPos(), eCoreUnit, ePresUnit, pIntl );
1134 if ( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
1135 rText += EE_RESSTR(GetMetricId(ePresUnit));
1136 bComma = sal_True;
1140 return ePres;
1143 // -----------------------------------------------------------------------
1145 SfxPoolItem* SvxTabStopItem::Create( SvStream& rStrm, sal_uInt16 ) const
1147 sal_Int8 nTabs;
1148 rStrm >> nTabs;
1149 SvxTabStopItem* pAttr =
1150 new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_DEFAULT, Which() );
1152 for ( sal_Int8 i = 0; i < nTabs; i++ )
1154 sal_Int32 nPos(0);
1155 sal_Int8 eAdjust;
1156 unsigned char cDecimal, cFill;
1157 rStrm >> nPos >> eAdjust >> cDecimal >> cFill;
1158 if( !i || SVX_TAB_ADJUST_DEFAULT != eAdjust )
1159 pAttr->Insert( SvxTabStop
1160 ( nPos, (SvxTabAdjust)eAdjust, sal_Unicode(cDecimal), sal_Unicode(cFill) ) );
1162 return pAttr;
1165 // -----------------------------------------------------------------------
1167 SvStream& SvxTabStopItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
1169 // Default-Tabs are only expanded for the default Attribute. For complete
1170 // backward compabillity (<=304) all tabs have to be expanded, this makes
1171 // the files grow large in size. All only SWG!
1173 const SfxItemPool *pPool = SfxItemPool::GetStoringPool();
1174 const bool bStoreDefTabs = pPool
1175 && pPool->GetName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SWG"))
1176 && ::IsDefaultItem( this );
1178 const short nTabs = Count();
1179 sal_uInt16 nCount = 0, nDefDist = 0;
1180 sal_Int32 nNew = 0;
1182 if( bStoreDefTabs )
1184 const SvxTabStopItem& rDefTab = (const SvxTabStopItem &)
1185 pPool->GetDefaultItem( pPool->GetWhich( SID_ATTR_TABSTOP, sal_False ) );
1186 nDefDist = sal_uInt16( rDefTab.maTabStops.front().GetTabPos() );
1187 const sal_Int32 nPos = nTabs > 0 ? (*this)[nTabs-1].GetTabPos() : 0;
1188 nCount = (sal_uInt16)(nPos / nDefDist);
1189 nNew = (nCount + 1) * nDefDist;
1191 if( nNew <= nPos + 50 )
1192 nNew += nDefDist;
1194 sal_Int32 lA3Width = SvxPaperInfo::GetPaperSize(PAPER_A3).Width();
1195 nCount = (sal_uInt16)(nNew < lA3Width ? ( lA3Width - nNew ) / nDefDist + 1 : 0);
1198 rStrm << (sal_Int8) ( nTabs + nCount );
1199 for ( short i = 0; i < nTabs; i++ )
1201 const SvxTabStop& rTab = (*this)[ i ];
1202 rStrm << rTab.GetTabPos()
1203 << (sal_Int8) rTab.GetAdjustment()
1204 << (unsigned char) rTab.GetDecimal()
1205 << (unsigned char) rTab.GetFill();
1208 if ( bStoreDefTabs )
1209 for( ; nCount; --nCount )
1211 SvxTabStop aSwTabStop(nNew, SVX_TAB_ADJUST_DEFAULT);
1212 rStrm << aSwTabStop.GetTabPos()
1213 << (sal_Int8) aSwTabStop.GetAdjustment()
1214 << (unsigned char) aSwTabStop.GetDecimal()
1215 << (unsigned char) aSwTabStop.GetFill();
1216 nNew += nDefDist;
1219 return rStrm;
1222 // -----------------------------------------------------------------------
1223 bool SvxTabStopItem::Insert( const SvxTabStop& rTab )
1225 sal_uInt16 nTabPos = GetPos(rTab);
1226 if(SVX_TAB_NOTFOUND != nTabPos )
1227 Remove(nTabPos);
1228 return maTabStops.insert( rTab ).second;
1230 // -----------------------------------------------------------------------
1231 void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart,
1232 sal_uInt16 nEnd )
1234 for( sal_uInt16 i = nStart; i < nEnd && i < pTabs->Count(); i++ )
1236 const SvxTabStop& rTab = (*pTabs)[i];
1237 sal_uInt16 nTabPos = GetPos(rTab);
1238 if(SVX_TAB_NOTFOUND != nTabPos)
1239 Remove(nTabPos);
1241 for( sal_uInt16 i = nStart; i < nEnd && i < pTabs->Count(); i++ )
1243 maTabStops.insert( (*pTabs)[i] );
1249 // class SvxFmtSplitItem -------------------------------------------------
1250 SvxFmtSplitItem::~SvxFmtSplitItem()
1253 // -----------------------------------------------------------------------
1254 SfxPoolItem* SvxFmtSplitItem::Clone( SfxItemPool * ) const
1256 return new SvxFmtSplitItem( *this );
1259 // -----------------------------------------------------------------------
1261 SvStream& SvxFmtSplitItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
1263 rStrm << (sal_Int8)GetValue();
1264 return rStrm;
1267 // -----------------------------------------------------------------------
1269 SfxPoolItem* SvxFmtSplitItem::Create( SvStream& rStrm, sal_uInt16 ) const
1271 sal_Int8 bIsSplit;
1272 rStrm >> bIsSplit;
1273 return new SvxFmtSplitItem( sal_Bool( bIsSplit != 0 ), Which() );
1276 //------------------------------------------------------------------------
1278 SfxItemPresentation SvxFmtSplitItem::GetPresentation
1280 SfxItemPresentation ePres,
1281 SfxMapUnit /*eCoreUnit*/,
1282 SfxMapUnit /*ePresUnit*/,
1283 OUString& rText, const IntlWrapper *
1284 ) const
1286 switch ( ePres )
1288 case SFX_ITEM_PRESENTATION_NONE:
1289 rText = OUString();
1290 return SFX_ITEM_PRESENTATION_NONE;
1291 case SFX_ITEM_PRESENTATION_NAMELESS:
1292 case SFX_ITEM_PRESENTATION_COMPLETE:
1294 sal_uInt16 nId = RID_SVXITEMS_FMTSPLIT_FALSE;
1296 if ( GetValue() )
1297 nId = RID_SVXITEMS_FMTSPLIT_TRUE;
1298 rText = EE_RESSTR(nId);
1299 return ePres;
1301 default: ;//prevent warning
1303 return SFX_ITEM_PRESENTATION_NONE;
1306 // --------------------------------------------------------------------
1308 SfxPoolItem* SvxPageModelItem::Clone( SfxItemPool* ) const
1310 return new SvxPageModelItem( *this );
1313 //------------------------------------------------------------------------
1315 bool SvxPageModelItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
1317 nMemberId &= ~CONVERT_TWIPS;
1319 switch ( nMemberId )
1321 case MID_AUTO: rVal <<= (sal_Bool) bAuto; break;
1322 case MID_NAME: rVal <<= OUString( GetValue() ); break;
1323 default: OSL_FAIL("Wrong MemberId!"); return sal_False;
1326 return sal_True;
1329 bool SvxPageModelItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
1331 nMemberId &= ~CONVERT_TWIPS;
1332 sal_Bool bRet;
1333 OUString aStr;
1334 switch ( nMemberId )
1336 case MID_AUTO: bRet = ( rVal >>= bAuto ); break;
1337 case MID_NAME: bRet = ( rVal >>= aStr ); if ( bRet ) SetValue(aStr); break;
1338 default: OSL_FAIL("Wrong MemberId!"); return sal_False;
1341 return bRet;
1344 SfxItemPresentation SvxPageModelItem::GetPresentation
1346 SfxItemPresentation ePres,
1347 SfxMapUnit /*eCoreUnit*/,
1348 SfxMapUnit /*ePresUnit*/,
1349 OUString& rText, const IntlWrapper *
1350 ) const
1352 rText = OUString();
1353 bool bSet = !GetValue().isEmpty();
1355 switch ( ePres )
1357 case SFX_ITEM_PRESENTATION_NONE:
1358 return SFX_ITEM_PRESENTATION_NONE;
1360 case SFX_ITEM_PRESENTATION_NAMELESS:
1361 if ( bSet )
1362 rText = GetValue();
1363 return SFX_ITEM_PRESENTATION_NAMELESS;
1365 case SFX_ITEM_PRESENTATION_COMPLETE:
1366 if ( bSet )
1368 rText = EE_RESSTR(RID_SVXITEMS_PAGEMODEL_COMPLETE) + GetValue();
1370 return SFX_ITEM_PRESENTATION_COMPLETE;
1371 default: ;//prevent warning
1373 return SFX_ITEM_PRESENTATION_NONE;
1376 //------------------------------------------------------------------------
1378 SvxScriptSpaceItem::SvxScriptSpaceItem( sal_Bool bOn, const sal_uInt16 nId )
1379 : SfxBoolItem( nId, bOn )
1383 SfxPoolItem* SvxScriptSpaceItem::Clone( SfxItemPool * ) const
1385 return new SvxScriptSpaceItem( GetValue(), Which() );
1388 SfxPoolItem* SvxScriptSpaceItem::Create(SvStream & rStrm, sal_uInt16) const
1390 sal_Bool bFlag;
1391 rStrm >> bFlag;
1392 return new SvxScriptSpaceItem( bFlag, Which() );
1395 sal_uInt16 SvxScriptSpaceItem::GetVersion( sal_uInt16 nFFVer ) const
1397 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1398 SOFFICE_FILEFORMAT_40==nFFVer ||
1399 SOFFICE_FILEFORMAT_50==nFFVer,
1400 "SvxTwoLinesItem: Is there a new file format? ");
1402 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1405 SfxItemPresentation SvxScriptSpaceItem::GetPresentation(
1406 SfxItemPresentation ePres,
1407 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1408 OUString &rText, const IntlWrapper* /*pIntl*/ ) const
1410 switch( ePres )
1412 case SFX_ITEM_PRESENTATION_NONE:
1413 rText = OUString();
1414 break;
1415 case SFX_ITEM_PRESENTATION_NAMELESS:
1416 case SFX_ITEM_PRESENTATION_COMPLETE:
1418 rText = EE_RESSTR( !GetValue()
1419 ? RID_SVXITEMS_SCRPTSPC_OFF
1420 : RID_SVXITEMS_SCRPTSPC_ON );
1421 return ePres;
1423 default: ;//prevent warning
1425 return SFX_ITEM_PRESENTATION_NONE;
1428 //------------------------------------------------------------------------
1430 SvxHangingPunctuationItem::SvxHangingPunctuationItem(
1431 sal_Bool bOn, const sal_uInt16 nId )
1432 : SfxBoolItem( nId, bOn )
1436 SfxPoolItem* SvxHangingPunctuationItem::Clone( SfxItemPool * ) const
1438 return new SvxHangingPunctuationItem( GetValue(), Which() );
1441 SfxPoolItem* SvxHangingPunctuationItem::Create(SvStream & rStrm, sal_uInt16) const
1443 sal_Bool nValue;
1444 rStrm >> nValue;
1445 return new SvxHangingPunctuationItem( nValue, Which() );
1448 sal_uInt16 SvxHangingPunctuationItem::GetVersion( sal_uInt16 nFFVer ) const
1450 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1451 SOFFICE_FILEFORMAT_40==nFFVer ||
1452 SOFFICE_FILEFORMAT_50==nFFVer,
1453 "SvxHangingPunctuationItem: Is there a new file format? ");
1455 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1458 SfxItemPresentation SvxHangingPunctuationItem::GetPresentation(
1459 SfxItemPresentation ePres,
1460 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1461 OUString &rText, const IntlWrapper* /*pIntl*/ ) const
1463 switch( ePres )
1465 case SFX_ITEM_PRESENTATION_NONE:
1466 rText = OUString();
1467 break;
1468 case SFX_ITEM_PRESENTATION_NAMELESS:
1469 case SFX_ITEM_PRESENTATION_COMPLETE:
1471 rText = EE_RESSTR( !GetValue()
1472 ? RID_SVXITEMS_HNGPNCT_OFF
1473 : RID_SVXITEMS_HNGPNCT_ON );
1474 return ePres;
1476 default: ;//prevent warning
1477 break;
1479 return SFX_ITEM_PRESENTATION_NONE;
1481 //------------------------------------------------------------------------
1483 SvxForbiddenRuleItem::SvxForbiddenRuleItem(
1484 sal_Bool bOn, const sal_uInt16 nId )
1485 : SfxBoolItem( nId, bOn )
1489 SfxPoolItem* SvxForbiddenRuleItem::Clone( SfxItemPool * ) const
1491 return new SvxForbiddenRuleItem( GetValue(), Which() );
1494 SfxPoolItem* SvxForbiddenRuleItem::Create(SvStream & rStrm, sal_uInt16) const
1496 sal_Bool nValue;
1497 rStrm >> nValue;
1498 return new SvxForbiddenRuleItem( nValue, Which() );
1501 sal_uInt16 SvxForbiddenRuleItem::GetVersion( sal_uInt16 nFFVer ) const
1503 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1504 SOFFICE_FILEFORMAT_40==nFFVer ||
1505 SOFFICE_FILEFORMAT_50==nFFVer,
1506 "SvxForbiddenRuleItem: Is there a new file format? ");
1508 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1511 SfxItemPresentation SvxForbiddenRuleItem::GetPresentation(
1512 SfxItemPresentation ePres,
1513 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1514 OUString &rText, const IntlWrapper* /*pIntl*/ ) const
1516 switch( ePres )
1518 case SFX_ITEM_PRESENTATION_NONE:
1519 rText = OUString();
1520 break;
1521 case SFX_ITEM_PRESENTATION_NAMELESS:
1522 case SFX_ITEM_PRESENTATION_COMPLETE:
1524 rText = EE_RESSTR( !GetValue()
1525 ? RID_SVXITEMS_FORBIDDEN_RULE_OFF
1526 : RID_SVXITEMS_FORBIDDEN_RULE_ON );
1527 return ePres;
1529 default: ;//prevent warning
1530 break;
1532 return SFX_ITEM_PRESENTATION_NONE;
1535 /*************************************************************************
1536 |* class SvxParaVertAlignItem
1537 *************************************************************************/
1539 SvxParaVertAlignItem::SvxParaVertAlignItem( sal_uInt16 nValue,
1540 const sal_uInt16 nW )
1541 : SfxUInt16Item( nW, nValue )
1545 SfxPoolItem* SvxParaVertAlignItem::Clone( SfxItemPool* ) const
1547 return new SvxParaVertAlignItem( GetValue(), Which() );
1550 SfxPoolItem* SvxParaVertAlignItem::Create( SvStream& rStrm, sal_uInt16 ) const
1552 sal_uInt16 nVal;
1553 rStrm >> nVal;
1554 return new SvxParaVertAlignItem( nVal, Which() );
1557 SvStream& SvxParaVertAlignItem::Store( SvStream & rStrm, sal_uInt16 ) const
1559 rStrm << GetValue();
1560 return rStrm;
1563 sal_uInt16 SvxParaVertAlignItem::GetVersion( sal_uInt16 nFFVer ) const
1565 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1568 SfxItemPresentation SvxParaVertAlignItem::GetPresentation(
1569 SfxItemPresentation ePres,
1570 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1571 OUString &rText, const IntlWrapper* ) const
1573 switch( ePres )
1575 case SFX_ITEM_PRESENTATION_NONE:
1576 rText = OUString();
1577 break;
1578 case SFX_ITEM_PRESENTATION_NAMELESS:
1579 case SFX_ITEM_PRESENTATION_COMPLETE:
1581 sal_uInt16 nTmp;
1582 switch( GetValue() )
1584 case AUTOMATIC: nTmp = RID_SVXITEMS_PARAVERTALIGN_AUTO; break;
1585 case TOP: nTmp = RID_SVXITEMS_PARAVERTALIGN_TOP; break;
1586 case CENTER: nTmp = RID_SVXITEMS_PARAVERTALIGN_CENTER; break;
1587 case BOTTOM: nTmp = RID_SVXITEMS_PARAVERTALIGN_BOTTOM; break;
1588 default: nTmp = RID_SVXITEMS_PARAVERTALIGN_BASELINE; break;
1590 rText = EE_RESSTR( nTmp );
1591 return ePres;
1593 default: ;//prevent warning
1594 break;
1596 return SFX_ITEM_PRESENTATION_NONE;
1599 bool SvxParaVertAlignItem::QueryValue( com::sun::star::uno::Any& rVal,
1600 sal_uInt8 /*nMemberId*/ ) const
1602 rVal <<= (sal_Int16)GetValue();
1603 return sal_True;
1606 bool SvxParaVertAlignItem::PutValue( const com::sun::star::uno::Any& rVal,
1607 sal_uInt8 /*nMemberId*/ )
1609 sal_Int16 nVal = sal_Int16();
1610 if((rVal >>= nVal) && nVal >=0 && nVal <= BOTTOM )
1612 SetValue( (sal_uInt16)nVal );
1613 return sal_True;
1615 else
1616 return sal_False;
1619 int SvxParaVertAlignItem::operator==( const SfxPoolItem& rItem ) const
1621 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1622 return SfxUInt16Item::operator==( rItem );
1626 SvxParaGridItem::SvxParaGridItem( sal_Bool bOn, const sal_uInt16 nId )
1627 : SfxBoolItem( nId, bOn )
1631 SfxPoolItem* SvxParaGridItem::Clone( SfxItemPool * ) const
1633 return new SvxParaGridItem( GetValue(), Which() );
1636 SfxPoolItem* SvxParaGridItem::Create(SvStream & rStrm, sal_uInt16) const
1638 sal_Bool bFlag;
1639 rStrm >> bFlag;
1640 return new SvxParaGridItem( bFlag, Which() );
1643 sal_uInt16 SvxParaGridItem::GetVersion( sal_uInt16 nFFVer ) const
1645 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1646 SOFFICE_FILEFORMAT_40==nFFVer ||
1647 SOFFICE_FILEFORMAT_50==nFFVer,
1648 "SvxParaGridItem: Is there a new file format? ");
1650 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1653 SfxItemPresentation SvxParaGridItem::GetPresentation(
1654 SfxItemPresentation ePres,
1655 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1656 OUString &rText, const IntlWrapper* /*pIntl*/ ) const
1658 switch( ePres )
1660 case SFX_ITEM_PRESENTATION_NONE:
1661 rText = OUString();
1662 break;
1663 case SFX_ITEM_PRESENTATION_NAMELESS:
1664 case SFX_ITEM_PRESENTATION_COMPLETE:
1666 rText = GetValue() ?
1667 EE_RESSTR( RID_SVXITEMS_PARASNAPTOGRID_ON ) :
1668 EE_RESSTR( RID_SVXITEMS_PARASNAPTOGRID_OFF );
1670 return ePres;
1672 default: ;//prevent warning
1673 break;
1675 return SFX_ITEM_PRESENTATION_NONE;
1679 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */