Bump for 3.6-28
[LibreOffice.git] / editeng / source / items / paraitem.cxx
blobb03ce0d648f1d8317f9ea4dc9c195d61eaa87d6c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
31 #include <com/sun/star/style/TabStop.hpp>
32 #include <com/sun/star/style/LineSpacing.hpp>
33 #include <com/sun/star/style/LineSpacingMode.hpp>
34 #include <com/sun/star/uno/Sequence.hxx>
35 #include <comphelper/processfactory.hxx>
36 #include <unotools/syslocale.hxx>
37 #include <comphelper/types.hxx>
39 using namespace ::rtl;
40 using namespace ::com::sun::star;
42 #include <tools/rtti.hxx>
44 #define _SVX_PARAITEM_CXX
45 #include <svl/itempool.hxx>
47 #include <svl/memberid.hrc>
48 #include <editeng/editrids.hrc>
50 #include <editeng/lspcitem.hxx>
51 #include <editeng/adjitem.hxx>
52 #include <editeng/orphitem.hxx>
53 #include <editeng/widwitem.hxx>
54 #include <editeng/tstpitem.hxx>
55 #include <editeng/pmdlitem.hxx>
56 #include <editeng/spltitem.hxx>
57 #include <editeng/hyznitem.hxx>
58 #include <editeng/scriptspaceitem.hxx>
59 #include <editeng/hngpnctitem.hxx>
60 #include <editeng/forbiddenruleitem.hxx>
61 #include <editeng/paravertalignitem.hxx>
62 #include <editeng/pgrditem.hxx>
63 #include <rtl/ustring.hxx>
64 #include <editeng/memberids.hrc>
65 #include <editeng/editids.hrc>
66 #include <editeng/itemtype.hxx>
67 #include <editeng/eerdll.hxx>
68 #include <editeng/paperinf.hxx>
69 #include <vcl/svapp.hxx>
70 #include <algorithm>
72 using namespace ::rtl;
73 using namespace ::com::sun::star;
75 // Konvertierung fuer UNO
76 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
77 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
78 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
79 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
82 // STATIC DATA -----------------------------------------------------------
85 // -----------------------------------------------------------------------
88 TYPEINIT1_FACTORY(SvxLineSpacingItem, SfxPoolItem , new SvxLineSpacingItem(LINE_SPACE_DEFAULT_HEIGHT, 0));
89 TYPEINIT1_FACTORY(SvxAdjustItem, SfxPoolItem, new SvxAdjustItem(SVX_ADJUST_LEFT, 0));
90 TYPEINIT1_FACTORY(SvxWidowsItem, SfxByteItem, new SvxWidowsItem(0, 0));
91 TYPEINIT1_FACTORY(SvxOrphansItem, SfxByteItem, new SvxOrphansItem(0, 0));
92 TYPEINIT1_FACTORY(SvxHyphenZoneItem, SfxPoolItem, new SvxHyphenZoneItem(sal_False, 0));
93 TYPEINIT1_FACTORY(SvxTabStopItem, SfxPoolItem, new SvxTabStopItem(0));
94 TYPEINIT1_FACTORY(SvxFmtSplitItem, SfxBoolItem, new SvxFmtSplitItem(sal_False, 0));
95 TYPEINIT1_FACTORY(SvxPageModelItem, SfxStringItem, new SvxPageModelItem(0));
96 TYPEINIT1_FACTORY(SvxScriptSpaceItem, SfxBoolItem, new SvxScriptSpaceItem(sal_False, 0));
97 TYPEINIT1_FACTORY(SvxHangingPunctuationItem, SfxBoolItem, new SvxHangingPunctuationItem(sal_False, 0));
98 TYPEINIT1_FACTORY(SvxForbiddenRuleItem, SfxBoolItem, new SvxForbiddenRuleItem(sal_False, 0));
99 TYPEINIT1_FACTORY(SvxParaVertAlignItem, SfxUInt16Item, new SvxParaVertAlignItem(0, 0));
100 TYPEINIT1_FACTORY(SvxParaGridItem, SfxBoolItem, new SvxParaGridItem(sal_True, 0));
102 SV_IMPL_VARARR_SORT( SvxTabStopArr, SvxTabStop )
104 // -----------------------------------------------------------------------
106 SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight, const sal_uInt16 nId )
107 : SfxEnumItemInterface( nId )
109 nPropLineSpace = 100;
110 nInterLineSpace = 0;
111 nLineHeight = nHeight;
112 eLineSpace = SVX_LINE_SPACE_AUTO;
113 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF;
116 // -----------------------------------------------------------------------
118 int SvxLineSpacingItem::operator==( const SfxPoolItem& rAttr ) const
120 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
122 const SvxLineSpacingItem& rLineSpace = (const SvxLineSpacingItem&)rAttr;
123 return (
124 // Same Linespacing Rule?
125 (eLineSpace == rLineSpace.eLineSpace)
126 // For maximum and minimum Linespacing be the size must coincide.
127 && (eLineSpace == SVX_LINE_SPACE_AUTO ||
128 nLineHeight == rLineSpace.nLineHeight)
129 // Same Linespacing Rule?
130 && ( eInterLineSpace == rLineSpace.eInterLineSpace )
131 // Either set proportional or additive.
132 && (( eInterLineSpace == SVX_INTER_LINE_SPACE_OFF)
133 || (eInterLineSpace == SVX_INTER_LINE_SPACE_PROP
134 && nPropLineSpace == rLineSpace.nPropLineSpace)
135 || (eInterLineSpace == SVX_INTER_LINE_SPACE_FIX
136 && (nInterLineSpace == rLineSpace.nInterLineSpace)))) ?
137 1 : 0;
140 /* Who does still know why the LineSpacingItem is so complicated?
141 We can not use it for UNO since there are only two values:
142 - ein sal_uInt16 for the mode
143 - ein sal_uInt32 for all values (distance, height, rel. detail)
145 bool SvxLineSpacingItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
147 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
148 nMemberId &= ~CONVERT_TWIPS;
150 style::LineSpacing aLSp;
151 switch( eLineSpace )
153 case SVX_LINE_SPACE_AUTO:
154 if(eInterLineSpace == SVX_INTER_LINE_SPACE_FIX)
156 aLSp.Mode = style::LineSpacingMode::LEADING;
157 aLSp.Height = ( bConvert ? (short)TWIP_TO_MM100(nInterLineSpace) : nInterLineSpace);
159 else if(eInterLineSpace == SVX_INTER_LINE_SPACE_OFF)
161 aLSp.Mode = style::LineSpacingMode::PROP;
162 aLSp.Height = 100;
164 else
166 aLSp.Mode = style::LineSpacingMode::PROP;
167 aLSp.Height = nPropLineSpace;
169 break;
170 case SVX_LINE_SPACE_FIX :
171 case SVX_LINE_SPACE_MIN :
172 aLSp.Mode = eLineSpace == SVX_LINE_SPACE_FIX ? style::LineSpacingMode::FIX : style::LineSpacingMode::MINIMUM;
173 aLSp.Height = ( bConvert ? (short)TWIP_TO_MM100_UNSIGNED(nLineHeight) : nLineHeight );
174 break;
175 default:
176 ;//prevent warning about SVX_LINE_SPACE_END
179 switch ( nMemberId )
181 case 0 : rVal <<= aLSp; break;
182 case MID_LINESPACE : rVal <<= aLSp.Mode; break;
183 case MID_HEIGHT : rVal <<= aLSp.Height; break;
184 default: OSL_FAIL("Wrong MemberId!"); break;
187 return true;
190 bool SvxLineSpacingItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
192 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
193 nMemberId &= ~CONVERT_TWIPS;
195 // fill with current data
196 style::LineSpacing aLSp;
197 uno::Any aAny;
198 sal_Bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aLSp );
200 // get new data
201 switch ( nMemberId )
203 case 0 : bRet = (rVal >>= aLSp); break;
204 case MID_LINESPACE : bRet = (rVal >>= aLSp.Mode); break;
205 case MID_HEIGHT : bRet = (rVal >>= aLSp.Height); break;
206 default: OSL_FAIL("Wrong MemberId!"); break;
209 if( bRet )
211 nLineHeight = aLSp.Height;
212 switch( aLSp.Mode )
214 case style::LineSpacingMode::LEADING:
216 eInterLineSpace = SVX_INTER_LINE_SPACE_FIX;
217 eLineSpace = SVX_LINE_SPACE_AUTO;
218 nInterLineSpace = aLSp.Height;
219 if(bConvert)
220 nInterLineSpace = (short)MM100_TO_TWIP(nInterLineSpace);
223 break;
224 case style::LineSpacingMode::PROP:
226 eLineSpace = SVX_LINE_SPACE_AUTO;
227 nPropLineSpace = (sal_Int8)std::min(aLSp.Height, (short)0xFF);
228 if(100 == aLSp.Height)
229 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF;
230 else
231 eInterLineSpace = SVX_INTER_LINE_SPACE_PROP;
233 break;
234 case style::LineSpacingMode::FIX:
235 case style::LineSpacingMode::MINIMUM:
237 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF;
238 eLineSpace = aLSp.Mode == style::LineSpacingMode::FIX ? SVX_LINE_SPACE_FIX : SVX_LINE_SPACE_MIN;
239 nLineHeight = aLSp.Height;
240 if(bConvert)
241 nLineHeight = (sal_uInt16)MM100_TO_TWIP_UNSIGNED(nLineHeight);
243 break;
247 return bRet;
250 // -----------------------------------------------------------------------
252 SfxPoolItem* SvxLineSpacingItem::Clone( SfxItemPool * ) const
254 return new SvxLineSpacingItem( *this );
257 //------------------------------------------------------------------------
259 SfxItemPresentation SvxLineSpacingItem::GetPresentation
261 SfxItemPresentation /*ePres*/,
262 SfxMapUnit /*eCoreUnit*/,
263 SfxMapUnit /*ePresUnit*/,
264 XubString& rText, const IntlWrapper *
265 ) const
267 #ifdef DBG_UTIL
268 rText.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "SvxLineSpacingItem" ));
269 #else
270 rText.Erase();
271 #endif
272 return SFX_ITEM_PRESENTATION_NONE;
275 // -----------------------------------------------------------------------
277 SfxPoolItem* SvxLineSpacingItem::Create(SvStream& rStrm, sal_uInt16) const
279 sal_Int8 nPropSpace;
280 short nInterSpace;
281 sal_uInt16 nHeight;
282 sal_Int8 nRule, nInterRule;
284 rStrm >> nPropSpace
285 >> nInterSpace
286 >> nHeight
287 >> nRule
288 >> nInterRule;
290 SvxLineSpacingItem* pAttr = new SvxLineSpacingItem( nHeight, Which() );
291 pAttr->SetInterLineSpace( nInterSpace );
292 pAttr->SetPropLineSpace( nPropSpace );
293 pAttr->GetLineSpaceRule() = (SvxLineSpace)nRule;
294 pAttr->GetInterLineSpaceRule() = (SvxInterLineSpace)nInterRule;
295 return pAttr;
298 // -----------------------------------------------------------------------
300 SvStream& SvxLineSpacingItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
302 rStrm << (sal_Int8) GetPropLineSpace()
303 << (short) GetInterLineSpace()
304 << (sal_uInt16) GetLineHeight()
305 << (sal_Int8) GetLineSpaceRule()
306 << (sal_Int8) GetInterLineSpaceRule();
307 return rStrm;
310 // -----------------------------------------------------------------------
312 sal_uInt16 SvxLineSpacingItem::GetValueCount() const
314 return SVX_LINESPACE_END; // SVX_LINESPACE_TWO_LINES + 1
317 // -----------------------------------------------------------------------
319 rtl::OUString SvxLineSpacingItem::GetValueTextByPos( sal_uInt16 nPos ) const
321 //! load strings from resource
322 rtl::OUString aText;
323 switch ( nPos )
325 case SVX_LINESPACE_USER:
326 aText = "User";
327 break;
328 case SVX_LINESPACE_ONE_LINE:
329 aText = "One line";
330 break;
331 case SVX_LINESPACE_ONE_POINT_FIVE_LINES:
332 aText = "1.5 line";
333 break;
334 case SVX_LINESPACE_TWO_LINES:
335 aText = "Two lines";
336 break;
338 return aText;
341 // -----------------------------------------------------------------------
343 sal_uInt16 SvxLineSpacingItem::GetEnumValue() const
345 sal_uInt16 nVal;
346 switch ( nPropLineSpace )
348 case 100: nVal = SVX_LINESPACE_ONE_LINE; break;
349 case 150: nVal = SVX_LINESPACE_ONE_POINT_FIVE_LINES; break;
350 case 200: nVal = SVX_LINESPACE_TWO_LINES; break;
351 default: nVal = SVX_LINESPACE_USER; break;
353 return nVal;
356 // -----------------------------------------------------------------------
358 void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal )
360 switch ( nVal )
362 case SVX_LINESPACE_ONE_LINE: nPropLineSpace = 100; break;
363 case SVX_LINESPACE_ONE_POINT_FIVE_LINES: nPropLineSpace = 150; break;
364 case SVX_LINESPACE_TWO_LINES: nPropLineSpace = 200; break;
368 // class SvxAdjustItem ---------------------------------------------------
370 SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst, const sal_uInt16 nId )
371 : SfxEnumItemInterface( nId ),
372 bOneBlock( sal_False ), bLastCenter( sal_False ), bLastBlock( sal_False )
374 SetAdjust( eAdjst );
377 // -----------------------------------------------------------------------
379 int SvxAdjustItem::operator==( const SfxPoolItem& rAttr ) const
381 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
383 return( ( GetAdjust() == ((SvxAdjustItem&)rAttr).GetAdjust() &&
384 bOneBlock == ((SvxAdjustItem&)rAttr).bOneBlock &&
385 bLastCenter == ((SvxAdjustItem&)rAttr).bLastCenter &&
386 bLastBlock == ((SvxAdjustItem&)rAttr).bLastBlock )
387 ? 1 : 0 );
390 bool SvxAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
392 nMemberId &= ~CONVERT_TWIPS;
393 switch( nMemberId )
395 case MID_PARA_ADJUST : rVal <<= (sal_Int16)GetAdjust(); break;
396 case MID_LAST_LINE_ADJUST : rVal <<= (sal_Int16)GetLastBlock(); break;
397 case MID_EXPAND_SINGLE :
399 sal_Bool bValue = bOneBlock;
400 rVal.setValue( &bValue, ::getCppuBooleanType() );
401 break;
403 default: ;//prevent warning
405 return true;
408 bool SvxAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
410 nMemberId &= ~CONVERT_TWIPS;
411 switch( nMemberId )
413 case MID_PARA_ADJUST :
414 case MID_LAST_LINE_ADJUST :
416 sal_Int32 eVal = - 1;
419 eVal = ::comphelper::getEnumAsINT32(rVal);
421 catch(...) {}
422 if(eVal >= 0 && eVal <= 4)
424 if(MID_LAST_LINE_ADJUST == nMemberId &&
425 eVal != SVX_ADJUST_LEFT &&
426 eVal != SVX_ADJUST_BLOCK &&
427 eVal != SVX_ADJUST_CENTER)
428 return sal_False;
429 if(eVal < (sal_uInt16)SVX_ADJUST_END)
430 nMemberId == MID_PARA_ADJUST ?
431 SetAdjust((SvxAdjust)eVal) :
432 SetLastBlock((SvxAdjust)eVal);
435 break;
436 case MID_EXPAND_SINGLE :
437 bOneBlock = Any2Bool(rVal);
438 break;
440 return true;
443 // -----------------------------------------------------------------------
445 SfxPoolItem* SvxAdjustItem::Clone( SfxItemPool * ) const
447 return new SvxAdjustItem( *this );
450 //------------------------------------------------------------------------
452 SfxItemPresentation SvxAdjustItem::GetPresentation
454 SfxItemPresentation ePres,
455 SfxMapUnit /*eCoreUnit*/,
456 SfxMapUnit /*ePresUnit*/,
457 XubString& rText, const IntlWrapper *
458 ) const
460 switch ( ePres )
462 case SFX_ITEM_PRESENTATION_NONE:
463 rText.Erase();
464 return SFX_ITEM_PRESENTATION_NONE;
465 case SFX_ITEM_PRESENTATION_NAMELESS:
466 case SFX_ITEM_PRESENTATION_COMPLETE:
467 rText = GetValueTextByPos( (sal_uInt16)GetAdjust() );
468 return ePres;
469 default: ;//prevent warning
471 return SFX_ITEM_PRESENTATION_NONE;
474 // -----------------------------------------------------------------------
476 sal_uInt16 SvxAdjustItem::GetValueCount() const
478 return SVX_ADJUST_END; // SVX_ADJUST_BLOCKLINE + 1
481 // -----------------------------------------------------------------------
483 rtl::OUString SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos ) const
485 DBG_ASSERT( nPos <= (sal_uInt16)SVX_ADJUST_BLOCKLINE, "enum overflow!" );
486 return EE_RESSTR(RID_SVXITEMS_ADJUST_BEGIN + nPos);
489 // -----------------------------------------------------------------------
491 sal_uInt16 SvxAdjustItem::GetEnumValue() const
493 return (sal_uInt16)GetAdjust();
496 // -----------------------------------------------------------------------
498 void SvxAdjustItem::SetEnumValue( sal_uInt16 nVal )
500 SetAdjust( (const SvxAdjust)nVal );
503 // -----------------------------------------------------------------------
505 sal_uInt16 SvxAdjustItem::GetVersion( sal_uInt16 nFileVersion ) const
507 return (nFileVersion == SOFFICE_FILEFORMAT_31)
508 ? 0 : ADJUST_LASTBLOCK_VERSION;
511 // -----------------------------------------------------------------------
513 SfxPoolItem* SvxAdjustItem::Create(SvStream& rStrm, sal_uInt16 nVersion) const
515 char eAdjustment;
516 rStrm >> eAdjustment;
517 SvxAdjustItem *pRet = new SvxAdjustItem( (SvxAdjust)eAdjustment, Which() );
518 if( nVersion >= ADJUST_LASTBLOCK_VERSION )
520 sal_Int8 nFlags;
521 rStrm >> nFlags;
522 pRet->bOneBlock = 0 != (nFlags & 0x0001);
523 pRet->bLastCenter = 0 != (nFlags & 0x0002);
524 pRet->bLastBlock = 0 != (nFlags & 0x0004);
526 return pRet;
529 // -----------------------------------------------------------------------
531 SvStream& SvxAdjustItem::Store( SvStream& rStrm, sal_uInt16 nItemVersion ) const
533 rStrm << (char)GetAdjust();
534 if ( nItemVersion >= ADJUST_LASTBLOCK_VERSION )
536 sal_Int8 nFlags = 0;
537 if ( bOneBlock )
538 nFlags |= 0x0001;
539 if ( bLastCenter )
540 nFlags |= 0x0002;
541 if ( bLastBlock )
542 nFlags |= 0x0004;
543 rStrm << (sal_Int8) nFlags;
545 return rStrm;
548 // class SvxWidowsItem ---------------------------------------------------
550 SvxWidowsItem::SvxWidowsItem(const sal_uInt8 nL, const sal_uInt16 nId ) :
551 SfxByteItem( nId, nL )
555 // -----------------------------------------------------------------------
557 SfxPoolItem* SvxWidowsItem::Clone( SfxItemPool * ) const
559 return new SvxWidowsItem( *this );
562 // -----------------------------------------------------------------------
564 SfxPoolItem* SvxWidowsItem::Create(SvStream& rStrm, sal_uInt16) const
566 sal_Int8 nLines;
567 rStrm >> nLines;
568 return new SvxWidowsItem( nLines, Which() );
571 // -----------------------------------------------------------------------
573 SvStream& SvxWidowsItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
575 rStrm << (sal_Int8)GetValue();
576 return rStrm;
579 //------------------------------------------------------------------------
581 SfxItemPresentation SvxWidowsItem::GetPresentation
583 SfxItemPresentation ePres,
584 SfxMapUnit /*eCoreUnit*/,
585 SfxMapUnit /*ePresUnit*/,
586 XubString& rText, const IntlWrapper *
587 ) const
589 switch ( ePres )
591 case SFX_ITEM_PRESENTATION_NONE:
593 rText.Erase();
594 break;
597 case SFX_ITEM_PRESENTATION_NAMELESS:
599 rText = EE_RESSTR(RID_SVXITEMS_LINES);
600 break;
603 case SFX_ITEM_PRESENTATION_COMPLETE:
605 rText = EE_RESSTR(RID_SVXITEMS_WIDOWS_COMPLETE);
606 rText += ' ';
607 rText += EE_RESSTR(RID_SVXITEMS_LINES);
610 default:
612 SAL_WARN( "editeng.items", "SvxWidowsItem::GetPresentation(): unknown SfxItemPresentation" );
616 rText.SearchAndReplace( String::CreateFromAscii( "%1" ), String::CreateFromInt32( GetValue() ) );
617 return ePres;
620 // class SvxOrphansItem --------------------------------------------------
622 SvxOrphansItem::SvxOrphansItem(const sal_uInt8 nL, const sal_uInt16 nId ) :
623 SfxByteItem( nId, nL )
627 // -----------------------------------------------------------------------
629 SfxPoolItem* SvxOrphansItem::Clone( SfxItemPool * ) const
631 return new SvxOrphansItem( *this );
634 // -----------------------------------------------------------------------
636 SfxPoolItem* SvxOrphansItem::Create(SvStream& rStrm, sal_uInt16) const
638 sal_Int8 nLines;
639 rStrm >> nLines;
640 return new SvxOrphansItem( nLines, Which() );
643 // -----------------------------------------------------------------------
645 SvStream& SvxOrphansItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
647 rStrm << (sal_Int8) GetValue();
648 return rStrm;
651 //------------------------------------------------------------------------
653 SfxItemPresentation SvxOrphansItem::GetPresentation
655 SfxItemPresentation ePres,
656 SfxMapUnit /*eCoreUnit*/,
657 SfxMapUnit /*ePresUnit*/,
658 XubString& rText, const IntlWrapper *
659 ) const
661 switch ( ePres )
663 case SFX_ITEM_PRESENTATION_NONE:
665 rText.Erase();
666 break;
669 case SFX_ITEM_PRESENTATION_NAMELESS:
671 rText = EE_RESSTR(RID_SVXITEMS_LINES);
672 break;
675 case SFX_ITEM_PRESENTATION_COMPLETE:
677 rText = EE_RESSTR(RID_SVXITEMS_ORPHANS_COMPLETE);
678 rText += ' ';
679 rText += EE_RESSTR(RID_SVXITEMS_LINES);
682 default:
684 SAL_WARN( "editeng.items", "SvxOrphansItem::GetPresentation(): unknown SfxItemPresentation" );
688 rText.SearchAndReplace( String::CreateFromAscii( "%1" ), String::CreateFromInt32( GetValue() ) );
689 return ePres;
692 // class SvxHyphenZoneItem -----------------------------------------------
694 SvxHyphenZoneItem::SvxHyphenZoneItem( const sal_Bool bHyph, const sal_uInt16 nId ) :
695 SfxPoolItem( nId )
697 bHyphen = bHyph;
698 bPageEnd = sal_True;
699 nMinLead = nMinTrail = 0;
700 nMaxHyphens = 255;
703 // -----------------------------------------------------------------------
704 bool SvxHyphenZoneItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
706 nMemberId &= ~CONVERT_TWIPS;
707 switch(nMemberId)
709 case MID_IS_HYPHEN:
710 rVal = Bool2Any(bHyphen);
711 break;
712 case MID_HYPHEN_MIN_LEAD:
713 rVal <<= (sal_Int16)nMinLead;
714 break;
715 case MID_HYPHEN_MIN_TRAIL:
716 rVal <<= (sal_Int16)nMinTrail;
717 break;
718 case MID_HYPHEN_MAX_HYPHENS:
719 rVal <<= (sal_Int16)nMaxHyphens;
720 break;
722 return true;
724 // -----------------------------------------------------------------------
725 bool SvxHyphenZoneItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
727 nMemberId &= ~CONVERT_TWIPS;
728 sal_Int16 nNewVal = 0;
730 if( nMemberId != MID_IS_HYPHEN )
731 if(!(rVal >>= nNewVal))
732 return false;
734 switch(nMemberId)
736 case MID_IS_HYPHEN:
737 bHyphen = Any2Bool(rVal);
738 break;
739 case MID_HYPHEN_MIN_LEAD:
740 nMinLead = (sal_uInt8)nNewVal;
741 break;
742 case MID_HYPHEN_MIN_TRAIL:
743 nMinTrail = (sal_uInt8)nNewVal;
744 break;
745 case MID_HYPHEN_MAX_HYPHENS:
746 nMaxHyphens = (sal_uInt8)nNewVal;
747 break;
749 return true;
752 // -----------------------------------------------------------------------
754 int SvxHyphenZoneItem::operator==( const SfxPoolItem& rAttr ) const
756 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
758 return ( (((SvxHyphenZoneItem&)rAttr).bHyphen == bHyphen)
759 && (((SvxHyphenZoneItem&)rAttr).bPageEnd == bPageEnd)
760 && (((SvxHyphenZoneItem&)rAttr).nMinLead == nMinLead)
761 && (((SvxHyphenZoneItem&)rAttr).nMinTrail == nMinTrail)
762 && (((SvxHyphenZoneItem&)rAttr).nMaxHyphens == nMaxHyphens) );
765 // -----------------------------------------------------------------------
767 SfxPoolItem* SvxHyphenZoneItem::Clone( SfxItemPool * ) const
769 return new SvxHyphenZoneItem( *this );
772 //------------------------------------------------------------------------
774 SfxItemPresentation SvxHyphenZoneItem::GetPresentation
776 SfxItemPresentation ePres,
777 SfxMapUnit /*eCoreUnit*/,
778 SfxMapUnit /*ePresUnit*/,
779 XubString& rText, const IntlWrapper *
780 ) const
782 switch ( ePres )
784 case SFX_ITEM_PRESENTATION_NONE:
785 rText.Erase();
786 return SFX_ITEM_PRESENTATION_NONE;
787 case SFX_ITEM_PRESENTATION_NAMELESS:
789 sal_uInt16 nId = RID_SVXITEMS_HYPHEN_FALSE;
791 if ( bHyphen )
792 nId = RID_SVXITEMS_HYPHEN_TRUE;
793 rText = EE_RESSTR(nId);
794 rText += cpDelim;
795 nId = RID_SVXITEMS_PAGE_END_FALSE;
797 if ( bPageEnd )
798 nId = RID_SVXITEMS_PAGE_END_TRUE;
799 rText += EE_RESSTR(nId);
800 rText += cpDelim;
801 rText += String::CreateFromInt32( nMinLead );
802 rText += cpDelim;
803 rText += String::CreateFromInt32( nMinTrail );
804 rText += cpDelim;
805 rText += String::CreateFromInt32( nMaxHyphens );
806 return SFX_ITEM_PRESENTATION_COMPLETE;
808 case SFX_ITEM_PRESENTATION_COMPLETE:
810 sal_uInt16 nId = RID_SVXITEMS_HYPHEN_FALSE;
812 if ( bHyphen )
813 nId = RID_SVXITEMS_HYPHEN_TRUE;
814 rText = EE_RESSTR(nId);
815 rText += cpDelim;
816 nId = RID_SVXITEMS_PAGE_END_FALSE;
818 if ( bPageEnd )
819 nId = RID_SVXITEMS_PAGE_END_TRUE;
820 rText += EE_RESSTR(nId);
821 rText += cpDelim;
822 rText += String::CreateFromInt32(nMinLead);
823 rText += EE_RESSTR(RID_SVXITEMS_HYPHEN_MINLEAD);
824 rText += cpDelim;
825 rText += String::CreateFromInt32(nMinTrail);
826 rText += EE_RESSTR(RID_SVXITEMS_HYPHEN_MINTRAIL);
827 rText += cpDelim;
828 rText += String::CreateFromInt32(nMaxHyphens);
829 rText += EE_RESSTR(RID_SVXITEMS_HYPHEN_MAX);
830 return SFX_ITEM_PRESENTATION_COMPLETE;
832 default: ;//prevent warning
834 return SFX_ITEM_PRESENTATION_NONE;
837 // -----------------------------------------------------------------------
839 SfxPoolItem* SvxHyphenZoneItem::Create(SvStream& rStrm, sal_uInt16) const
841 sal_Int8 _bHyphen, _bHyphenPageEnd;
842 sal_Int8 _nMinLead, _nMinTrail, _nMaxHyphens;
843 rStrm >> _bHyphen >> _bHyphenPageEnd >> _nMinLead >> _nMinTrail >> _nMaxHyphens;
844 SvxHyphenZoneItem* pAttr = new SvxHyphenZoneItem( sal_False, Which() );
845 pAttr->SetHyphen( sal_Bool( _bHyphen != 0 ) );
846 pAttr->SetPageEnd( sal_Bool( _bHyphenPageEnd != 0 ) );
847 pAttr->GetMinLead() = _nMinLead;
848 pAttr->GetMinTrail() = _nMinTrail;
849 pAttr->GetMaxHyphens() = _nMaxHyphens;
850 return pAttr;
853 // -----------------------------------------------------------------------
855 SvStream& SvxHyphenZoneItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
857 rStrm << (sal_Int8) IsHyphen()
858 << (sal_Int8) IsPageEnd()
859 << (sal_Int8) GetMinLead()
860 << (sal_Int8) GetMinTrail()
861 << (sal_Int8) GetMaxHyphens();
862 return rStrm;
865 // class SvxTabStop ------------------------------------------------------
867 SvxTabStop::SvxTabStop()
869 nTabPos = 0;
870 eAdjustment = SVX_TAB_ADJUST_LEFT;
871 m_cDecimal = cDfltDecimalChar;
872 cFill = cDfltFillChar;
875 // -----------------------------------------------------------------------
877 SvxTabStop::SvxTabStop( const sal_Int32 nPos, const SvxTabAdjust eAdjst,
878 const sal_Unicode cDec, const sal_Unicode cFil )
880 nTabPos = nPos;
881 eAdjustment = eAdjst;
882 m_cDecimal = cDec;
883 cFill = cFil;
885 // -----------------------------------------------------------------------------
886 void SvxTabStop::fillDecimal() const
888 if ( cDfltDecimalChar == m_cDecimal )
889 m_cDecimal = SvtSysLocale().GetLocaleData().getNumDecimalSep().GetChar(0);
891 // -----------------------------------------------------------------------
893 XubString SvxTabStop::GetValueString() const
895 XubString aStr;
897 aStr += sal_Unicode( '(' );
898 aStr += rtl::OUString::valueOf(static_cast<sal_Int32>(nTabPos));
899 aStr += cpDelim;
900 aStr += EE_RESSTR(RID_SVXITEMS_TAB_ADJUST_BEGIN + (sal_uInt16)eAdjustment);
902 aStr += cpDelim;
903 aStr += sal_Unicode('[');
904 aStr += EE_RESSTR(RID_SVXITEMS_TAB_DECIMAL_CHAR);
905 aStr += GetDecimal();
906 aStr += sal_Unicode(']');
907 aStr += cpDelim;
908 aStr += cpDelim;
909 aStr += sal_Unicode('[');
910 aStr += EE_RESSTR(RID_SVXITEMS_TAB_FILL_CHAR);
911 aStr += cFill;
912 aStr += sal_Unicode(']');
913 aStr += sal_Unicode(')');
915 return aStr;
918 // class SvxTabStopItem --------------------------------------------------
920 SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich ) :
921 SfxPoolItem( _nWhich ),
922 SvxTabStopArr( sal_Int8(SVX_TAB_DEFCOUNT) )
924 const sal_uInt16 nTabs = SVX_TAB_DEFCOUNT, nDist = SVX_TAB_DEFDIST;
925 const SvxTabAdjust eAdjst= SVX_TAB_ADJUST_DEFAULT;
927 for (sal_uInt16 i = 0; i < nTabs; ++i)
929 SvxTabStop aTab( (i + 1) * nDist, eAdjst );
930 SvxTabStopArr::Insert( aTab );
934 // -----------------------------------------------------------------------
936 SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs,
937 const sal_uInt16 nDist,
938 const SvxTabAdjust eAdjst,
939 sal_uInt16 _nWhich ) :
940 SfxPoolItem( _nWhich ),
941 SvxTabStopArr( sal_Int8(nTabs) )
943 for ( sal_uInt16 i = 0; i < nTabs; ++i )
945 SvxTabStop aTab( (i + 1) * nDist, eAdjst );
946 SvxTabStopArr::Insert( aTab );
950 // -----------------------------------------------------------------------
952 SvxTabStopItem::SvxTabStopItem( const SvxTabStopItem& rTSI ) :
953 SfxPoolItem( rTSI.Which() ),
954 SvxTabStopArr( (sal_Int8)rTSI.Count() )
956 SvxTabStopArr::Insert( &rTSI );
959 // -----------------------------------------------------------------------
961 sal_uInt16 SvxTabStopItem::GetPos( const SvxTabStop& rTab ) const
963 sal_uInt16 nFound;
964 return Seek_Entry( rTab, &nFound ) ? nFound : SVX_TAB_NOTFOUND;
967 // -----------------------------------------------------------------------
969 sal_uInt16 SvxTabStopItem::GetPos( const sal_Int32 nPos ) const
971 sal_uInt16 nFound;
972 return Seek_Entry( SvxTabStop( nPos ), &nFound ) ? nFound : SVX_TAB_NOTFOUND;
975 // -----------------------------------------------------------------------
977 SvxTabStopItem& SvxTabStopItem::operator=( const SvxTabStopItem& rTSI )
979 Remove( 0, Count() );
980 SvxTabStopArr::Insert( &rTSI );
981 return *this;
984 bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
986 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
987 nMemberId &= ~CONVERT_TWIPS;
988 switch ( nMemberId )
990 case MID_TABSTOPS:
992 sal_uInt16 nCount = Count();
993 uno::Sequence< style::TabStop> aSeq(nCount);
994 style::TabStop* pArr = aSeq.getArray();
995 for(sal_uInt16 i = 0; i < nCount; i++)
997 const SvxTabStop& rTab = *(GetStart() + i);
998 pArr[i].Position = bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos();
999 switch(rTab.GetAdjustment())
1001 case SVX_TAB_ADJUST_LEFT : pArr[i].Alignment = style::TabAlign_LEFT; break;
1002 case SVX_TAB_ADJUST_RIGHT : pArr[i].Alignment = style::TabAlign_RIGHT; break;
1003 case SVX_TAB_ADJUST_DECIMAL: pArr[i].Alignment = style::TabAlign_DECIMAL; break;
1004 case SVX_TAB_ADJUST_CENTER : pArr[i].Alignment = style::TabAlign_CENTER; break;
1005 default: //SVX_TAB_ADJUST_DEFAULT
1006 pArr[i].Alignment = style::TabAlign_DEFAULT;
1009 pArr[i].DecimalChar = rTab.GetDecimal();
1010 pArr[i].FillChar = rTab.GetFill();
1012 rVal <<= aSeq;
1013 break;
1015 case MID_STD_TAB:
1017 const SvxTabStop &rTab = *(GetStart());
1018 rVal <<= (static_cast<sal_Int32>(bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos()));
1019 break;
1022 return sal_True;
1025 bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1027 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1028 nMemberId &= ~CONVERT_TWIPS;
1029 switch ( nMemberId )
1031 case MID_TABSTOPS:
1033 uno::Sequence< style::TabStop> aSeq;
1034 if(!(rVal >>= aSeq))
1036 uno::Sequence < uno::Sequence < uno::Any > > aAnySeq;
1037 if (!(rVal >>= aAnySeq))
1038 return sal_False;
1039 sal_Int32 nLength = aAnySeq.getLength();
1040 aSeq.realloc( nLength );
1041 for ( sal_Int32 n=0; n<nLength; n++ )
1043 uno::Sequence < uno::Any >& rAnySeq = aAnySeq[n];
1044 if ( rAnySeq.getLength() == 4 )
1046 if (!(rAnySeq[0] >>= aSeq[n].Position)) return sal_False;
1047 if (!(rAnySeq[1] >>= aSeq[n].Alignment))
1049 sal_Int32 nVal = 0;
1050 if (rAnySeq[1] >>= nVal)
1051 aSeq[n].Alignment = (com::sun::star::style::TabAlign) nVal;
1052 else
1053 return sal_False;
1055 if (!(rAnySeq[2] >>= aSeq[n].DecimalChar))
1057 ::rtl::OUString aVal;
1058 if ( (rAnySeq[2] >>= aVal) && aVal.getLength() == 1 )
1059 aSeq[n].DecimalChar = aVal.toChar();
1060 else
1061 return sal_False;
1063 if (!(rAnySeq[3] >>= aSeq[n].FillChar))
1065 ::rtl::OUString aVal;
1066 if ( (rAnySeq[3] >>= aVal) && aVal.getLength() == 1 )
1067 aSeq[n].FillChar = aVal.toChar();
1068 else
1069 return sal_False;
1072 else
1073 return sal_False;
1077 SvxTabStopArr::Remove( 0, Count() );
1078 const style::TabStop* pArr = aSeq.getConstArray();
1079 const sal_uInt16 nCount = (sal_uInt16)aSeq.getLength();
1080 for(sal_uInt16 i = 0; i < nCount ; i++)
1082 SvxTabAdjust eAdjust = SVX_TAB_ADJUST_DEFAULT;
1083 switch(pArr[i].Alignment)
1085 case style::TabAlign_LEFT : eAdjust = SVX_TAB_ADJUST_LEFT; break;
1086 case style::TabAlign_CENTER : eAdjust = SVX_TAB_ADJUST_CENTER; break;
1087 case style::TabAlign_RIGHT : eAdjust = SVX_TAB_ADJUST_RIGHT; break;
1088 case style::TabAlign_DECIMAL: eAdjust = SVX_TAB_ADJUST_DECIMAL; break;
1089 default: ;//prevent warning
1091 sal_Unicode cFill = pArr[i].FillChar;
1092 sal_Unicode cDecimal = pArr[i].DecimalChar;
1093 SvxTabStop aTab( bConvert ? MM100_TO_TWIP(pArr[i].Position) : pArr[i].Position,
1094 eAdjust,
1095 cDecimal,
1096 cFill );
1097 Insert(aTab);
1099 break;
1101 case MID_STD_TAB:
1103 sal_Int32 nNewPos = 0;
1104 if (!(rVal >>= nNewPos) )
1105 return sal_False;
1106 if (bConvert)
1107 nNewPos = MM100_TO_TWIP ( nNewPos );
1108 if (nNewPos <= 0)
1109 return sal_False;
1110 const SvxTabStop& rTab = *(GetStart());
1111 SvxTabStop aNewTab ( nNewPos, rTab.GetAdjustment(), rTab.GetDecimal(), rTab.GetFill() );
1112 Remove ( 0 );
1113 Insert( aNewTab );
1114 break;
1117 return sal_True;
1119 // -----------------------------------------------------------------------
1121 int SvxTabStopItem::operator==( const SfxPoolItem& rAttr ) const
1123 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1125 const SvxTabStopItem& rTSI = (SvxTabStopItem&)rAttr;
1127 if ( Count() != rTSI.Count() )
1128 return 0;
1130 for ( sal_uInt16 i = 0; i < Count(); ++i )
1131 if( !(*this)[i].IsEqual( rTSI[i] ) )
1132 return 0;
1133 return 1;
1136 // -----------------------------------------------------------------------
1138 SfxPoolItem* SvxTabStopItem::Clone( SfxItemPool * ) const
1140 return new SvxTabStopItem( *this );
1143 //------------------------------------------------------------------------
1145 SfxItemPresentation SvxTabStopItem::GetPresentation
1147 SfxItemPresentation ePres,
1148 SfxMapUnit eCoreUnit,
1149 SfxMapUnit ePresUnit,
1150 XubString& rText, const IntlWrapper *pIntl
1151 ) const
1153 rText.Erase();
1155 if ( ePres > SFX_ITEM_PRESENTATION_NONE )
1157 sal_Bool bComma = sal_False;
1159 for ( sal_uInt16 i = 0; i < Count(); ++i )
1161 if ( SVX_TAB_ADJUST_DEFAULT != ((*this)[i]).GetAdjustment() )
1163 if ( bComma )
1164 rText += sal_Unicode(',');
1165 rText += GetMetricText(
1166 ((*this)[i]).GetTabPos(), eCoreUnit, ePresUnit, pIntl );
1167 if ( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
1168 rText += EE_RESSTR(GetMetricId(ePresUnit));
1169 bComma = sal_True;
1173 return ePres;
1176 // -----------------------------------------------------------------------
1178 SfxPoolItem* SvxTabStopItem::Create( SvStream& rStrm, sal_uInt16 ) const
1180 sal_Int8 nTabs;
1181 rStrm >> nTabs;
1182 SvxTabStopItem* pAttr =
1183 new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_DEFAULT, Which() );
1185 for ( sal_Int8 i = 0; i < nTabs; i++ )
1187 sal_Int32 nPos(0);
1188 sal_Int8 eAdjust;
1189 unsigned char cDecimal, cFill;
1190 rStrm >> nPos >> eAdjust >> cDecimal >> cFill;
1191 if( !i || SVX_TAB_ADJUST_DEFAULT != eAdjust )
1192 pAttr->Insert( SvxTabStop
1193 ( nPos, (SvxTabAdjust)eAdjust, sal_Unicode(cDecimal), sal_Unicode(cFill) ) );
1195 return pAttr;
1198 // -----------------------------------------------------------------------
1200 SvStream& SvxTabStopItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
1202 // Default-Tabs are only expanded for the default Attribute. For complete
1203 // backward compabillity (<=304) all tabs have to be expanded, this makes
1204 // the files grow large in size. All only SWG!
1206 const SfxItemPool *pPool = SfxItemPool::GetStoringPool();
1207 const bool bStoreDefTabs = pPool
1208 && pPool->GetName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SWG"))
1209 && ::IsDefaultItem( this );
1211 const short nTabs = Count();
1212 sal_uInt16 nCount = 0, nDefDist = 0;
1213 sal_Int32 nNew = 0;
1215 if( bStoreDefTabs )
1217 const SvxTabStopItem& rDefTab = (const SvxTabStopItem &)
1218 pPool->GetDefaultItem( pPool->GetWhich( SID_ATTR_TABSTOP, sal_False ) );
1219 nDefDist = sal_uInt16( rDefTab.GetStart()->GetTabPos() );
1220 const sal_Int32 nPos = nTabs > 0 ? (*this)[nTabs-1].GetTabPos() : 0;
1221 nCount = (sal_uInt16)(nPos / nDefDist);
1222 nNew = (nCount + 1) * nDefDist;
1224 if( nNew <= nPos + 50 )
1225 nNew += nDefDist;
1227 sal_Int32 lA3Width = SvxPaperInfo::GetPaperSize(PAPER_A3).Width();
1228 nCount = (sal_uInt16)(nNew < lA3Width ? ( lA3Width - nNew ) / nDefDist + 1 : 0);
1231 rStrm << (sal_Int8) ( nTabs + nCount );
1232 for ( short i = 0; i < nTabs; i++ )
1234 const SvxTabStop& rTab = (*this)[ i ];
1235 rStrm << rTab.GetTabPos()
1236 << (sal_Int8) rTab.GetAdjustment()
1237 << (unsigned char) rTab.GetDecimal()
1238 << (unsigned char) rTab.GetFill();
1241 if ( bStoreDefTabs )
1242 for( ; nCount; --nCount )
1244 SvxTabStop aSwTabStop(nNew, SVX_TAB_ADJUST_DEFAULT);
1245 rStrm << aSwTabStop.GetTabPos()
1246 << (sal_Int8) aSwTabStop.GetAdjustment()
1247 << (unsigned char) aSwTabStop.GetDecimal()
1248 << (unsigned char) aSwTabStop.GetFill();
1249 nNew += nDefDist;
1252 return rStrm;
1255 // -----------------------------------------------------------------------
1256 sal_Bool SvxTabStopItem::Insert( const SvxTabStop& rTab )
1258 sal_uInt16 nTabPos = GetPos(rTab);
1259 if(SVX_TAB_NOTFOUND != nTabPos )
1260 Remove(nTabPos);
1261 return SvxTabStopArr::Insert( rTab );
1263 // -----------------------------------------------------------------------
1264 void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart,
1265 sal_uInt16 nEnd )
1267 for( sal_uInt16 i = nStart; i < nEnd && i < pTabs->Count(); i++ )
1269 const SvxTabStop& rTab = (*pTabs)[i];
1270 sal_uInt16 nTabPos = GetPos(rTab);
1271 if(SVX_TAB_NOTFOUND != nTabPos)
1272 Remove(nTabPos);
1274 SvxTabStopArr::Insert( pTabs, nStart, nEnd );
1279 // class SvxFmtSplitItem -------------------------------------------------
1280 SvxFmtSplitItem::~SvxFmtSplitItem()
1283 // -----------------------------------------------------------------------
1284 SfxPoolItem* SvxFmtSplitItem::Clone( SfxItemPool * ) const
1286 return new SvxFmtSplitItem( *this );
1289 // -----------------------------------------------------------------------
1291 SvStream& SvxFmtSplitItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
1293 rStrm << (sal_Int8)GetValue();
1294 return rStrm;
1297 // -----------------------------------------------------------------------
1299 SfxPoolItem* SvxFmtSplitItem::Create( SvStream& rStrm, sal_uInt16 ) const
1301 sal_Int8 bIsSplit;
1302 rStrm >> bIsSplit;
1303 return new SvxFmtSplitItem( sal_Bool( bIsSplit != 0 ), Which() );
1306 //------------------------------------------------------------------------
1308 SfxItemPresentation SvxFmtSplitItem::GetPresentation
1310 SfxItemPresentation ePres,
1311 SfxMapUnit /*eCoreUnit*/,
1312 SfxMapUnit /*ePresUnit*/,
1313 XubString& rText, const IntlWrapper *
1314 ) const
1316 switch ( ePres )
1318 case SFX_ITEM_PRESENTATION_NONE:
1319 rText.Erase();
1320 return SFX_ITEM_PRESENTATION_NONE;
1321 case SFX_ITEM_PRESENTATION_NAMELESS:
1322 case SFX_ITEM_PRESENTATION_COMPLETE:
1324 sal_uInt16 nId = RID_SVXITEMS_FMTSPLIT_FALSE;
1326 if ( GetValue() )
1327 nId = RID_SVXITEMS_FMTSPLIT_TRUE;
1328 rText = EE_RESSTR(nId);
1329 return ePres;
1331 default: ;//prevent warning
1333 return SFX_ITEM_PRESENTATION_NONE;
1336 // --------------------------------------------------------------------
1338 SfxPoolItem* SvxPageModelItem::Clone( SfxItemPool* ) const
1340 return new SvxPageModelItem( *this );
1343 //------------------------------------------------------------------------
1345 bool SvxPageModelItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
1347 nMemberId &= ~CONVERT_TWIPS;
1349 switch ( nMemberId )
1351 case MID_AUTO: rVal <<= (sal_Bool) bAuto; break;
1352 case MID_NAME: rVal <<= ::rtl::OUString( GetValue() ); break;
1353 default: OSL_FAIL("Wrong MemberId!"); return sal_False;
1356 return sal_True;
1359 bool SvxPageModelItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
1361 nMemberId &= ~CONVERT_TWIPS;
1362 sal_Bool bRet;
1363 ::rtl::OUString aStr;
1364 switch ( nMemberId )
1366 case MID_AUTO: bRet = ( rVal >>= bAuto ); break;
1367 case MID_NAME: bRet = ( rVal >>= aStr ); if ( bRet ) SetValue(aStr); break;
1368 default: OSL_FAIL("Wrong MemberId!"); return sal_False;
1371 return bRet;
1374 SfxItemPresentation SvxPageModelItem::GetPresentation
1376 SfxItemPresentation ePres,
1377 SfxMapUnit /*eCoreUnit*/,
1378 SfxMapUnit /*ePresUnit*/,
1379 XubString& rText, const IntlWrapper *
1380 ) const
1382 rText.Erase();
1383 bool bSet = ( GetValue().Len() > 0 );
1385 switch ( ePres )
1387 case SFX_ITEM_PRESENTATION_NONE:
1388 return SFX_ITEM_PRESENTATION_NONE;
1390 case SFX_ITEM_PRESENTATION_NAMELESS:
1391 if ( bSet )
1392 rText = GetValue();
1393 return SFX_ITEM_PRESENTATION_NAMELESS;
1395 case SFX_ITEM_PRESENTATION_COMPLETE:
1396 if ( bSet )
1398 rText = EE_RESSTR(RID_SVXITEMS_PAGEMODEL_COMPLETE);
1399 rText += GetValue();
1401 return SFX_ITEM_PRESENTATION_COMPLETE;
1402 default: ;//prevent warning
1404 return SFX_ITEM_PRESENTATION_NONE;
1407 //------------------------------------------------------------------------
1409 SvxScriptSpaceItem::SvxScriptSpaceItem( sal_Bool bOn, const sal_uInt16 nId )
1410 : SfxBoolItem( nId, bOn )
1414 SfxPoolItem* SvxScriptSpaceItem::Clone( SfxItemPool * ) const
1416 return new SvxScriptSpaceItem( GetValue(), Which() );
1419 SfxPoolItem* SvxScriptSpaceItem::Create(SvStream & rStrm, sal_uInt16) const
1421 sal_Bool bFlag;
1422 rStrm >> bFlag;
1423 return new SvxScriptSpaceItem( bFlag, Which() );
1426 sal_uInt16 SvxScriptSpaceItem::GetVersion( sal_uInt16 nFFVer ) const
1428 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1429 SOFFICE_FILEFORMAT_40==nFFVer ||
1430 SOFFICE_FILEFORMAT_50==nFFVer,
1431 "SvxTwoLinesItem: Is there a new file format? ");
1433 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1436 SfxItemPresentation SvxScriptSpaceItem::GetPresentation(
1437 SfxItemPresentation ePres,
1438 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1439 String &rText, const IntlWrapper* /*pIntl*/ ) const
1441 switch( ePres )
1443 case SFX_ITEM_PRESENTATION_NONE:
1444 rText.Erase();
1445 break;
1446 case SFX_ITEM_PRESENTATION_NAMELESS:
1447 case SFX_ITEM_PRESENTATION_COMPLETE:
1449 rText = EE_RESSTR( !GetValue()
1450 ? RID_SVXITEMS_SCRPTSPC_OFF
1451 : RID_SVXITEMS_SCRPTSPC_ON );
1452 return ePres;
1454 default: ;//prevent warning
1456 return SFX_ITEM_PRESENTATION_NONE;
1459 //------------------------------------------------------------------------
1461 SvxHangingPunctuationItem::SvxHangingPunctuationItem(
1462 sal_Bool bOn, const sal_uInt16 nId )
1463 : SfxBoolItem( nId, bOn )
1467 SfxPoolItem* SvxHangingPunctuationItem::Clone( SfxItemPool * ) const
1469 return new SvxHangingPunctuationItem( GetValue(), Which() );
1472 SfxPoolItem* SvxHangingPunctuationItem::Create(SvStream & rStrm, sal_uInt16) const
1474 sal_Bool nValue;
1475 rStrm >> nValue;
1476 return new SvxHangingPunctuationItem( nValue, Which() );
1479 sal_uInt16 SvxHangingPunctuationItem::GetVersion( sal_uInt16 nFFVer ) const
1481 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1482 SOFFICE_FILEFORMAT_40==nFFVer ||
1483 SOFFICE_FILEFORMAT_50==nFFVer,
1484 "SvxHangingPunctuationItem: Is there a new file format? ");
1486 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1489 SfxItemPresentation SvxHangingPunctuationItem::GetPresentation(
1490 SfxItemPresentation ePres,
1491 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1492 String &rText, const IntlWrapper* /*pIntl*/ ) const
1494 switch( ePres )
1496 case SFX_ITEM_PRESENTATION_NONE:
1497 rText.Erase();
1498 break;
1499 case SFX_ITEM_PRESENTATION_NAMELESS:
1500 case SFX_ITEM_PRESENTATION_COMPLETE:
1502 rText = EE_RESSTR( !GetValue()
1503 ? RID_SVXITEMS_HNGPNCT_OFF
1504 : RID_SVXITEMS_HNGPNCT_ON );
1505 return ePres;
1507 default: ;//prevent warning
1508 break;
1510 return SFX_ITEM_PRESENTATION_NONE;
1512 //------------------------------------------------------------------------
1514 SvxForbiddenRuleItem::SvxForbiddenRuleItem(
1515 sal_Bool bOn, const sal_uInt16 nId )
1516 : SfxBoolItem( nId, bOn )
1520 SfxPoolItem* SvxForbiddenRuleItem::Clone( SfxItemPool * ) const
1522 return new SvxForbiddenRuleItem( GetValue(), Which() );
1525 SfxPoolItem* SvxForbiddenRuleItem::Create(SvStream & rStrm, sal_uInt16) const
1527 sal_Bool nValue;
1528 rStrm >> nValue;
1529 return new SvxForbiddenRuleItem( nValue, Which() );
1532 sal_uInt16 SvxForbiddenRuleItem::GetVersion( sal_uInt16 nFFVer ) const
1534 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1535 SOFFICE_FILEFORMAT_40==nFFVer ||
1536 SOFFICE_FILEFORMAT_50==nFFVer,
1537 "SvxForbiddenRuleItem: Is there a new file format? ");
1539 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1542 SfxItemPresentation SvxForbiddenRuleItem::GetPresentation(
1543 SfxItemPresentation ePres,
1544 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1545 String &rText, const IntlWrapper* /*pIntl*/ ) const
1547 switch( ePres )
1549 case SFX_ITEM_PRESENTATION_NONE:
1550 rText.Erase();
1551 break;
1552 case SFX_ITEM_PRESENTATION_NAMELESS:
1553 case SFX_ITEM_PRESENTATION_COMPLETE:
1555 rText = EE_RESSTR( !GetValue()
1556 ? RID_SVXITEMS_FORBIDDEN_RULE_OFF
1557 : RID_SVXITEMS_FORBIDDEN_RULE_ON );
1558 return ePres;
1560 default: ;//prevent warning
1561 break;
1563 return SFX_ITEM_PRESENTATION_NONE;
1566 /*************************************************************************
1567 |* class SvxParaVertAlignItem
1568 *************************************************************************/
1570 SvxParaVertAlignItem::SvxParaVertAlignItem( sal_uInt16 nValue,
1571 const sal_uInt16 nW )
1572 : SfxUInt16Item( nW, nValue )
1576 SfxPoolItem* SvxParaVertAlignItem::Clone( SfxItemPool* ) const
1578 return new SvxParaVertAlignItem( GetValue(), Which() );
1581 SfxPoolItem* SvxParaVertAlignItem::Create( SvStream& rStrm, sal_uInt16 ) const
1583 sal_uInt16 nVal;
1584 rStrm >> nVal;
1585 return new SvxParaVertAlignItem( nVal, Which() );
1588 SvStream& SvxParaVertAlignItem::Store( SvStream & rStrm, sal_uInt16 ) const
1590 rStrm << GetValue();
1591 return rStrm;
1594 sal_uInt16 SvxParaVertAlignItem::GetVersion( sal_uInt16 nFFVer ) const
1596 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1599 SfxItemPresentation SvxParaVertAlignItem::GetPresentation(
1600 SfxItemPresentation ePres,
1601 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1602 String &rText, const IntlWrapper* ) const
1604 switch( ePres )
1606 case SFX_ITEM_PRESENTATION_NONE:
1607 rText.Erase();
1608 break;
1609 case SFX_ITEM_PRESENTATION_NAMELESS:
1610 case SFX_ITEM_PRESENTATION_COMPLETE:
1612 sal_uInt16 nTmp;
1613 switch( GetValue() )
1615 case AUTOMATIC: nTmp = RID_SVXITEMS_PARAVERTALIGN_AUTO; break;
1616 case TOP: nTmp = RID_SVXITEMS_PARAVERTALIGN_TOP; break;
1617 case CENTER: nTmp = RID_SVXITEMS_PARAVERTALIGN_CENTER; break;
1618 case BOTTOM: nTmp = RID_SVXITEMS_PARAVERTALIGN_BOTTOM; break;
1619 default: nTmp = RID_SVXITEMS_PARAVERTALIGN_BASELINE; break;
1621 rText = EE_RESSTR( nTmp );
1622 return ePres;
1624 default: ;//prevent warning
1625 break;
1627 return SFX_ITEM_PRESENTATION_NONE;
1630 bool SvxParaVertAlignItem::QueryValue( com::sun::star::uno::Any& rVal,
1631 sal_uInt8 /*nMemberId*/ ) const
1633 rVal <<= (sal_Int16)GetValue();
1634 return sal_True;
1637 bool SvxParaVertAlignItem::PutValue( const com::sun::star::uno::Any& rVal,
1638 sal_uInt8 /*nMemberId*/ )
1640 sal_Int16 nVal = sal_Int16();
1641 if((rVal >>= nVal) && nVal >=0 && nVal <= BOTTOM )
1643 SetValue( (sal_uInt16)nVal );
1644 return sal_True;
1646 else
1647 return sal_False;
1650 int SvxParaVertAlignItem::operator==( const SfxPoolItem& rItem ) const
1652 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
1653 return SfxUInt16Item::operator==( rItem );
1657 SvxParaGridItem::SvxParaGridItem( sal_Bool bOn, const sal_uInt16 nId )
1658 : SfxBoolItem( nId, bOn )
1662 SfxPoolItem* SvxParaGridItem::Clone( SfxItemPool * ) const
1664 return new SvxParaGridItem( GetValue(), Which() );
1667 SfxPoolItem* SvxParaGridItem::Create(SvStream & rStrm, sal_uInt16) const
1669 sal_Bool bFlag;
1670 rStrm >> bFlag;
1671 return new SvxParaGridItem( bFlag, Which() );
1674 sal_uInt16 SvxParaGridItem::GetVersion( sal_uInt16 nFFVer ) const
1676 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
1677 SOFFICE_FILEFORMAT_40==nFFVer ||
1678 SOFFICE_FILEFORMAT_50==nFFVer,
1679 "SvxParaGridItem: Is there a new file format? ");
1681 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0;
1684 SfxItemPresentation SvxParaGridItem::GetPresentation(
1685 SfxItemPresentation ePres,
1686 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
1687 String &rText, const IntlWrapper* /*pIntl*/ ) const
1689 switch( ePres )
1691 case SFX_ITEM_PRESENTATION_NONE:
1692 rText.Erase();
1693 break;
1694 case SFX_ITEM_PRESENTATION_NAMELESS:
1695 case SFX_ITEM_PRESENTATION_COMPLETE:
1697 rText = GetValue() ?
1698 EE_RESSTR( RID_SVXITEMS_PARASNAPTOGRID_ON ) :
1699 EE_RESSTR( RID_SVXITEMS_PARASNAPTOGRID_OFF );
1701 return ePres;
1703 default: ;//prevent warning
1704 break;
1706 return SFX_ITEM_PRESENTATION_NONE;
1710 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */