1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_editeng.hxx" 30 31 // include --------------------------------------------------------------- 32 #include <com/sun/star/style/TabStop.hpp> 33 #include <com/sun/star/style/LineSpacing.hpp> 34 #include <com/sun/star/style/LineSpacingMode.hpp> 35 #include <com/sun/star/uno/Sequence.hxx> 36 #include <comphelper/processfactory.hxx> 37 #include <unotools/syslocale.hxx> 38 #include <comphelper/types.hxx> 39 40 using namespace ::rtl; 41 using namespace ::com::sun::star; 42 43 #include <tools/rtti.hxx> 44 #define GLOBALOVERFLOW3 45 46 #define _SVX_PARAITEM_CXX 47 #include <svl/itempool.hxx> 48 49 #include <svl/memberid.hrc> 50 #include <editeng/editrids.hrc> 51 52 #include <editeng/lspcitem.hxx> 53 #include <editeng/adjitem.hxx> 54 #include <editeng/orphitem.hxx> 55 #include <editeng/widwitem.hxx> 56 #include <editeng/tstpitem.hxx> 57 #include <editeng/pmdlitem.hxx> 58 #include <editeng/spltitem.hxx> 59 #include <editeng/hyznitem.hxx> 60 #include <editeng/scriptspaceitem.hxx> 61 #include <editeng/hngpnctitem.hxx> 62 #include <editeng/forbiddenruleitem.hxx> 63 #include <editeng/paravertalignitem.hxx> 64 #include <editeng/pgrditem.hxx> 65 #include <rtl/ustring.hxx> 66 #include <editeng/memberids.hrc> 67 #include <editeng/editids.hrc> 68 #include <editeng/itemtype.hxx> 69 #include <editeng/eerdll.hxx> 70 #include <editeng/paperinf.hxx> 71 #include <vcl/svapp.hxx> 72 #include <algorithm> 73 74 using namespace ::rtl; 75 using namespace ::com::sun::star; 76 77 // Konvertierung fuer UNO 78 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) 79 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L)) 80 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L)) 81 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L)) 82 83 84 // STATIC DATA ----------------------------------------------------------- 85 86 87 // ----------------------------------------------------------------------- 88 89 90 TYPEINIT1_FACTORY(SvxLineSpacingItem, SfxPoolItem , new SvxLineSpacingItem(LINE_SPACE_DEFAULT_HEIGHT, 0)); 91 TYPEINIT1_FACTORY(SvxAdjustItem, SfxPoolItem, new SvxAdjustItem(SVX_ADJUST_LEFT, 0)); 92 TYPEINIT1_FACTORY(SvxWidowsItem, SfxByteItem, new SvxWidowsItem(0, 0)); 93 TYPEINIT1_FACTORY(SvxOrphansItem, SfxByteItem, new SvxOrphansItem(0, 0)); 94 TYPEINIT1_FACTORY(SvxHyphenZoneItem, SfxPoolItem, new SvxHyphenZoneItem(sal_False, 0)); 95 TYPEINIT1_FACTORY(SvxTabStopItem, SfxPoolItem, new SvxTabStopItem(0)); 96 TYPEINIT1_FACTORY(SvxFmtSplitItem, SfxBoolItem, new SvxFmtSplitItem(sal_False, 0)); 97 TYPEINIT1_FACTORY(SvxPageModelItem, SfxStringItem, new SvxPageModelItem(0)); 98 TYPEINIT1_FACTORY(SvxScriptSpaceItem, SfxBoolItem, new SvxScriptSpaceItem(sal_False, 0)); 99 TYPEINIT1_FACTORY(SvxHangingPunctuationItem, SfxBoolItem, new SvxHangingPunctuationItem(sal_False, 0)); 100 TYPEINIT1_FACTORY(SvxForbiddenRuleItem, SfxBoolItem, new SvxForbiddenRuleItem(sal_False, 0)); 101 TYPEINIT1_FACTORY(SvxParaVertAlignItem, SfxUInt16Item, new SvxParaVertAlignItem(0, 0)); 102 TYPEINIT1_FACTORY(SvxParaGridItem, SfxBoolItem, new SvxParaGridItem(sal_True, 0)); 103 104 SV_IMPL_VARARR_SORT( SvxTabStopArr, SvxTabStop ) 105 106 // ----------------------------------------------------------------------- 107 108 SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight, const sal_uInt16 nId ) 109 : SfxEnumItemInterface( nId ) 110 { 111 nPropLineSpace = 100; 112 nInterLineSpace = 0; 113 nLineHeight = nHeight; 114 eLineSpace = SVX_LINE_SPACE_AUTO; 115 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF; 116 } 117 118 // ----------------------------------------------------------------------- 119 120 int SvxLineSpacingItem::operator==( const SfxPoolItem& rAttr ) const 121 { 122 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 123 124 const SvxLineSpacingItem& rLineSpace = (const SvxLineSpacingItem&)rAttr; 125 return ( 126 // Gleiche Linespacing Rule? 127 (eLineSpace == rLineSpace.eLineSpace) 128 // Bei maximalem und minimalem Linespacing muss das Mass 129 // uebereinstimmen. 130 && (eLineSpace == SVX_LINE_SPACE_AUTO || 131 nLineHeight == rLineSpace.nLineHeight) 132 // Gleiche Interlinespacing Rule? 133 && ( eInterLineSpace == rLineSpace.eInterLineSpace ) 134 // Entweder proportional oder draufaddieren eingestellt. 135 && (( eInterLineSpace == SVX_INTER_LINE_SPACE_OFF) 136 || (eInterLineSpace == SVX_INTER_LINE_SPACE_PROP 137 && nPropLineSpace == rLineSpace.nPropLineSpace) 138 || (eInterLineSpace == SVX_INTER_LINE_SPACE_FIX 139 && (nInterLineSpace == rLineSpace.nInterLineSpace)))) ? 140 1 : 0; 141 } 142 143 /*-----------------18.03.98 16:32------------------- 144 os: wer weiss noch, wieso das LineSpacingItem so 145 kompliziert ist? Fuer UNO koennen wir das nicht 146 gebrauchen. Da gibt es nur zwei Werte: 147 - ein sal_uInt16 fuer den Modus 148 - ein sal_uInt32 fuer alle Werte (Abstand, Hoehe, rel. Angaben) 149 150 --------------------------------------------------*/ 151 sal_Bool SvxLineSpacingItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 152 { 153 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 154 nMemberId &= ~CONVERT_TWIPS; 155 156 style::LineSpacing aLSp; 157 switch( eLineSpace ) 158 { 159 case SVX_LINE_SPACE_AUTO: 160 if(eInterLineSpace == SVX_INTER_LINE_SPACE_FIX) 161 { 162 aLSp.Mode = style::LineSpacingMode::LEADING; 163 aLSp.Height = ( bConvert ? (short)TWIP_TO_MM100(nInterLineSpace) : nInterLineSpace); 164 } 165 else if(eInterLineSpace == SVX_INTER_LINE_SPACE_OFF) 166 { 167 aLSp.Mode = style::LineSpacingMode::PROP; 168 aLSp.Height = 100; 169 } 170 else 171 { 172 aLSp.Mode = style::LineSpacingMode::PROP; 173 aLSp.Height = nPropLineSpace; 174 } 175 break; 176 case SVX_LINE_SPACE_FIX : 177 case SVX_LINE_SPACE_MIN : 178 aLSp.Mode = eLineSpace == SVX_LINE_SPACE_FIX ? style::LineSpacingMode::FIX : style::LineSpacingMode::MINIMUM; 179 aLSp.Height = ( bConvert ? (short)TWIP_TO_MM100_UNSIGNED(nLineHeight) : nLineHeight ); 180 break; 181 default: 182 ;//prevent warning about SVX_LINE_SPACE_END 183 } 184 185 switch ( nMemberId ) 186 { 187 case 0 : rVal <<= aLSp; break; 188 case MID_LINESPACE : rVal <<= aLSp.Mode; break; 189 case MID_HEIGHT : rVal <<= aLSp.Height; break; 190 default: DBG_ERROR("Wrong MemberId!"); break; 191 } 192 193 return sal_True; 194 } 195 /*-----------------18.03.98 16:32------------------- 196 197 --------------------------------------------------*/ 198 sal_Bool SvxLineSpacingItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 199 { 200 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 201 nMemberId &= ~CONVERT_TWIPS; 202 203 // fill with current data 204 style::LineSpacing aLSp; 205 uno::Any aAny; 206 sal_Bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aLSp ); 207 208 // get new data 209 switch ( nMemberId ) 210 { 211 case 0 : bRet = (rVal >>= aLSp); break; 212 case MID_LINESPACE : bRet = (rVal >>= aLSp.Mode); break; 213 case MID_HEIGHT : bRet = (rVal >>= aLSp.Height); break; 214 default: DBG_ERROR("Wrong MemberId!"); break; 215 } 216 217 if( bRet ) 218 { 219 nLineHeight = aLSp.Height; 220 switch( aLSp.Mode ) 221 { 222 case style::LineSpacingMode::LEADING: 223 { 224 eInterLineSpace = SVX_INTER_LINE_SPACE_FIX; 225 eLineSpace = SVX_LINE_SPACE_AUTO; 226 nInterLineSpace = aLSp.Height; 227 if(bConvert) 228 nInterLineSpace = (short)MM100_TO_TWIP(nInterLineSpace); 229 230 } 231 break; 232 case style::LineSpacingMode::PROP: 233 { 234 eLineSpace = SVX_LINE_SPACE_AUTO; 235 nPropLineSpace = (sal_Int8)std::min(aLSp.Height, (short)0xFF); 236 if(100 == aLSp.Height) 237 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF; 238 else 239 eInterLineSpace = SVX_INTER_LINE_SPACE_PROP; 240 } 241 break; 242 case style::LineSpacingMode::FIX: 243 case style::LineSpacingMode::MINIMUM: 244 { 245 eInterLineSpace = SVX_INTER_LINE_SPACE_OFF; 246 eLineSpace = aLSp.Mode == style::LineSpacingMode::FIX ? SVX_LINE_SPACE_FIX : SVX_LINE_SPACE_MIN; 247 nLineHeight = aLSp.Height; 248 if(bConvert) 249 nLineHeight = (sal_uInt16)MM100_TO_TWIP_UNSIGNED(nLineHeight); 250 } 251 break; 252 } 253 } 254 255 return bRet; 256 } 257 258 // ----------------------------------------------------------------------- 259 260 SfxPoolItem* SvxLineSpacingItem::Clone( SfxItemPool * ) const 261 { 262 return new SvxLineSpacingItem( *this ); 263 } 264 265 //------------------------------------------------------------------------ 266 267 SfxItemPresentation SvxLineSpacingItem::GetPresentation 268 ( 269 SfxItemPresentation /*ePres*/, 270 SfxMapUnit /*eCoreUnit*/, 271 SfxMapUnit /*ePresUnit*/, 272 XubString& rText, const IntlWrapper * 273 ) const 274 { 275 #ifdef DBG_UTIL 276 rText.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "SvxLineSpacingItem" )); 277 #else 278 rText.Erase(); 279 #endif 280 return SFX_ITEM_PRESENTATION_NONE; 281 } 282 283 // ----------------------------------------------------------------------- 284 285 SfxPoolItem* SvxLineSpacingItem::Create(SvStream& rStrm, sal_uInt16) const 286 { 287 sal_Int8 nPropSpace; 288 short nInterSpace; 289 sal_uInt16 nHeight; 290 sal_Int8 nRule, nInterRule; 291 292 rStrm >> nPropSpace 293 >> nInterSpace 294 >> nHeight 295 >> nRule 296 >> nInterRule; 297 298 SvxLineSpacingItem* pAttr = new SvxLineSpacingItem( nHeight, Which() ); 299 pAttr->SetInterLineSpace( nInterSpace ); 300 pAttr->SetPropLineSpace( nPropSpace ); 301 pAttr->GetLineSpaceRule() = (SvxLineSpace)nRule; 302 pAttr->GetInterLineSpaceRule() = (SvxInterLineSpace)nInterRule; 303 return pAttr; 304 } 305 306 // ----------------------------------------------------------------------- 307 308 SvStream& SvxLineSpacingItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const 309 { 310 rStrm << (sal_Int8) GetPropLineSpace() 311 << (short) GetInterLineSpace() 312 << (sal_uInt16) GetLineHeight() 313 << (sal_Int8) GetLineSpaceRule() 314 << (sal_Int8) GetInterLineSpaceRule(); 315 return rStrm; 316 } 317 318 // ----------------------------------------------------------------------- 319 320 sal_uInt16 SvxLineSpacingItem::GetValueCount() const 321 { 322 return SVX_LINESPACE_END; // SVX_LINESPACE_TWO_LINES + 1 323 } 324 325 // ----------------------------------------------------------------------- 326 327 XubString SvxLineSpacingItem::GetValueTextByPos( sal_uInt16 nPos ) const 328 { 329 //! Strings demnaechst aus Resource laden 330 XubString aText; 331 switch ( nPos ) 332 { 333 case SVX_LINESPACE_USER : aText.AppendAscii( "Benutzer" ); break; 334 case SVX_LINESPACE_ONE_LINE : aText.AppendAscii( "Einzeilig" ); break; 335 case SVX_LINESPACE_ONE_POINT_FIVE_LINES : aText.AppendAscii( "1,5zeilig" ); break; 336 case SVX_LINESPACE_TWO_LINES : aText.AppendAscii( "Zweizeilig" ); break; 337 } 338 return aText; 339 } 340 341 // ----------------------------------------------------------------------- 342 343 sal_uInt16 SvxLineSpacingItem::GetEnumValue() const 344 { 345 sal_uInt16 nVal; 346 switch ( nPropLineSpace ) 347 { 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; 352 } 353 return nVal; 354 } 355 356 // ----------------------------------------------------------------------- 357 358 void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal ) 359 { 360 switch ( nVal ) 361 { 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; 365 } 366 } 367 368 // class SvxAdjustItem --------------------------------------------------- 369 370 SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst, const sal_uInt16 nId ) 371 : SfxEnumItemInterface( nId ), 372 bOneBlock( sal_False ), bLastCenter( sal_False ), bLastBlock( sal_False ) 373 { 374 SetAdjust( eAdjst ); 375 } 376 377 // ----------------------------------------------------------------------- 378 379 int SvxAdjustItem::operator==( const SfxPoolItem& rAttr ) const 380 { 381 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 382 383 return( ( GetAdjust() == ((SvxAdjustItem&)rAttr).GetAdjust() && 384 bOneBlock == ((SvxAdjustItem&)rAttr).bOneBlock && 385 bLastCenter == ((SvxAdjustItem&)rAttr).bLastCenter && 386 bLastBlock == ((SvxAdjustItem&)rAttr).bLastBlock ) 387 ? 1 : 0 ); 388 } 389 390 /*-----------------18.03.98 16:15------------------- 391 392 --------------------------------------------------*/ 393 sal_Bool SvxAdjustItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 394 { 395 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 396 nMemberId &= ~CONVERT_TWIPS; 397 switch( nMemberId ) 398 { 399 case MID_PARA_ADJUST : rVal <<= (sal_Int16)GetAdjust(); break; 400 case MID_LAST_LINE_ADJUST : rVal <<= (sal_Int16)GetLastBlock(); break; 401 case MID_EXPAND_SINGLE : 402 { 403 sal_Bool bValue = bOneBlock; 404 rVal.setValue( &bValue, ::getCppuBooleanType() ); 405 break; 406 } 407 default: ;//prevent warning 408 } 409 return sal_True; 410 } 411 /*-----------------18.03.98 16:15------------------- 412 413 --------------------------------------------------*/ 414 415 sal_Bool SvxAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 416 { 417 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 418 nMemberId &= ~CONVERT_TWIPS; 419 switch( nMemberId ) 420 { 421 case MID_PARA_ADJUST : 422 case MID_LAST_LINE_ADJUST : 423 { 424 sal_Int32 eVal = - 1; 425 try 426 { 427 eVal = ::comphelper::getEnumAsINT32(rVal); 428 } 429 catch(...) {} 430 if(eVal >= 0 && eVal <= 4) 431 { 432 if(MID_LAST_LINE_ADJUST == nMemberId && 433 eVal != SVX_ADJUST_LEFT && 434 eVal != SVX_ADJUST_BLOCK && 435 eVal != SVX_ADJUST_CENTER) 436 return sal_False; 437 if(eVal < (sal_uInt16)SVX_ADJUST_END) 438 nMemberId == MID_PARA_ADJUST ? 439 SetAdjust((SvxAdjust)eVal) : 440 SetLastBlock((SvxAdjust)eVal); 441 } 442 } 443 break; 444 case MID_EXPAND_SINGLE : 445 bOneBlock = Any2Bool(rVal); 446 break; 447 } 448 return sal_True; 449 } 450 451 // ----------------------------------------------------------------------- 452 453 SfxPoolItem* SvxAdjustItem::Clone( SfxItemPool * ) const 454 { 455 return new SvxAdjustItem( *this ); 456 } 457 458 //------------------------------------------------------------------------ 459 460 SfxItemPresentation SvxAdjustItem::GetPresentation 461 ( 462 SfxItemPresentation ePres, 463 SfxMapUnit /*eCoreUnit*/, 464 SfxMapUnit /*ePresUnit*/, 465 XubString& rText, const IntlWrapper * 466 ) const 467 { 468 switch ( ePres ) 469 { 470 case SFX_ITEM_PRESENTATION_NONE: 471 rText.Erase(); 472 return SFX_ITEM_PRESENTATION_NONE; 473 case SFX_ITEM_PRESENTATION_NAMELESS: 474 case SFX_ITEM_PRESENTATION_COMPLETE: 475 rText = GetValueTextByPos( (sal_uInt16)GetAdjust() ); 476 return ePres; 477 default: ;//prevent warning 478 } 479 return SFX_ITEM_PRESENTATION_NONE; 480 } 481 482 // ----------------------------------------------------------------------- 483 484 sal_uInt16 SvxAdjustItem::GetValueCount() const 485 { 486 return SVX_ADJUST_END; // SVX_ADJUST_BLOCKLINE + 1 487 } 488 489 // ----------------------------------------------------------------------- 490 491 XubString SvxAdjustItem::GetValueTextByPos( sal_uInt16 nPos ) const 492 { 493 DBG_ASSERT( nPos <= (sal_uInt16)SVX_ADJUST_BLOCKLINE, "enum overflow!" ); 494 return EE_RESSTR(RID_SVXITEMS_ADJUST_BEGIN + nPos); 495 } 496 497 // ----------------------------------------------------------------------- 498 499 sal_uInt16 SvxAdjustItem::GetEnumValue() const 500 { 501 return (sal_uInt16)GetAdjust(); 502 } 503 504 // ----------------------------------------------------------------------- 505 506 void SvxAdjustItem::SetEnumValue( sal_uInt16 nVal ) 507 { 508 SetAdjust( (const SvxAdjust)nVal ); 509 } 510 511 // ----------------------------------------------------------------------- 512 513 sal_uInt16 SvxAdjustItem::GetVersion( sal_uInt16 nFileVersion ) const 514 { 515 return (nFileVersion == SOFFICE_FILEFORMAT_31) 516 ? 0 : ADJUST_LASTBLOCK_VERSION; 517 } 518 519 // ----------------------------------------------------------------------- 520 521 SfxPoolItem* SvxAdjustItem::Create(SvStream& rStrm, sal_uInt16 nVersion) const 522 { 523 char eAdjustment; 524 rStrm >> eAdjustment; 525 SvxAdjustItem *pRet = new SvxAdjustItem( (SvxAdjust)eAdjustment, Which() ); 526 if( nVersion >= ADJUST_LASTBLOCK_VERSION ) 527 { 528 sal_Int8 nFlags; 529 rStrm >> nFlags; 530 pRet->bOneBlock = 0 != (nFlags & 0x0001); 531 pRet->bLastCenter = 0 != (nFlags & 0x0002); 532 pRet->bLastBlock = 0 != (nFlags & 0x0004); 533 } 534 return pRet; 535 } 536 537 // ----------------------------------------------------------------------- 538 539 SvStream& SvxAdjustItem::Store( SvStream& rStrm, sal_uInt16 nItemVersion ) const 540 { 541 rStrm << (char)GetAdjust(); 542 if ( nItemVersion >= ADJUST_LASTBLOCK_VERSION ) 543 { 544 sal_Int8 nFlags = 0; 545 if ( bOneBlock ) 546 nFlags |= 0x0001; 547 if ( bLastCenter ) 548 nFlags |= 0x0002; 549 if ( bLastBlock ) 550 nFlags |= 0x0004; 551 rStrm << (sal_Int8) nFlags; 552 } 553 return rStrm; 554 } 555 556 // class SvxWidowsItem --------------------------------------------------- 557 558 SvxWidowsItem::SvxWidowsItem(const sal_uInt8 nL, const sal_uInt16 nId ) : 559 SfxByteItem( nId, nL ) 560 { 561 } 562 563 // ----------------------------------------------------------------------- 564 565 SfxPoolItem* SvxWidowsItem::Clone( SfxItemPool * ) const 566 { 567 return new SvxWidowsItem( *this ); 568 } 569 570 // ----------------------------------------------------------------------- 571 572 SfxPoolItem* SvxWidowsItem::Create(SvStream& rStrm, sal_uInt16) const 573 { 574 sal_Int8 nLines; 575 rStrm >> nLines; 576 return new SvxWidowsItem( nLines, Which() ); 577 } 578 579 // ----------------------------------------------------------------------- 580 581 SvStream& SvxWidowsItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const 582 { 583 rStrm << (sal_Int8)GetValue(); 584 return rStrm; 585 } 586 587 //------------------------------------------------------------------------ 588 589 SfxItemPresentation SvxWidowsItem::GetPresentation 590 ( 591 SfxItemPresentation ePres, 592 SfxMapUnit /*eCoreUnit*/, 593 SfxMapUnit /*ePresUnit*/, 594 XubString& rText, const IntlWrapper * 595 ) const 596 { 597 switch ( ePres ) 598 { 599 case SFX_ITEM_PRESENTATION_NONE: 600 { 601 rText.Erase(); 602 break; 603 } 604 605 case SFX_ITEM_PRESENTATION_NAMELESS: 606 { 607 rText = EE_RESSTR(RID_SVXITEMS_LINES); 608 break; 609 } 610 611 case SFX_ITEM_PRESENTATION_COMPLETE: 612 { 613 rText = EE_RESSTR(RID_SVXITEMS_WIDOWS_COMPLETE); 614 rText += ' '; 615 rText += EE_RESSTR(RID_SVXITEMS_LINES); 616 } 617 618 default: 619 { 620 DBG_ERRORFILE( "SvxWidowsItem::GetPresentation(): unknown SfxItemPresentation" ); 621 } 622 } 623 624 rText.SearchAndReplace( String::CreateFromAscii( "%1" ), String::CreateFromInt32( GetValue() ) ); 625 return ePres; 626 } 627 628 // class SvxOrphansItem -------------------------------------------------- 629 630 SvxOrphansItem::SvxOrphansItem(const sal_uInt8 nL, const sal_uInt16 nId ) : 631 SfxByteItem( nId, nL ) 632 { 633 } 634 635 // ----------------------------------------------------------------------- 636 637 SfxPoolItem* SvxOrphansItem::Clone( SfxItemPool * ) const 638 { 639 return new SvxOrphansItem( *this ); 640 } 641 642 // ----------------------------------------------------------------------- 643 644 SfxPoolItem* SvxOrphansItem::Create(SvStream& rStrm, sal_uInt16) const 645 { 646 sal_Int8 nLines; 647 rStrm >> nLines; 648 return new SvxOrphansItem( nLines, Which() ); 649 } 650 651 // ----------------------------------------------------------------------- 652 653 SvStream& SvxOrphansItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const 654 { 655 rStrm << (sal_Int8) GetValue(); 656 return rStrm; 657 } 658 659 //------------------------------------------------------------------------ 660 661 SfxItemPresentation SvxOrphansItem::GetPresentation 662 ( 663 SfxItemPresentation ePres, 664 SfxMapUnit /*eCoreUnit*/, 665 SfxMapUnit /*ePresUnit*/, 666 XubString& rText, const IntlWrapper * 667 ) const 668 { 669 switch ( ePres ) 670 { 671 case SFX_ITEM_PRESENTATION_NONE: 672 { 673 rText.Erase(); 674 break; 675 } 676 677 case SFX_ITEM_PRESENTATION_NAMELESS: 678 { 679 rText = EE_RESSTR(RID_SVXITEMS_LINES); 680 break; 681 } 682 683 case SFX_ITEM_PRESENTATION_COMPLETE: 684 { 685 rText = EE_RESSTR(RID_SVXITEMS_ORPHANS_COMPLETE); 686 rText += ' '; 687 rText += EE_RESSTR(RID_SVXITEMS_LINES); 688 } 689 690 default: 691 { 692 DBG_ERRORFILE( "SvxOrphansItem::GetPresentation(): unknown SfxItemPresentation" ); 693 } 694 } 695 696 rText.SearchAndReplace( String::CreateFromAscii( "%1" ), String::CreateFromInt32( GetValue() ) ); 697 return ePres; 698 } 699 700 // class SvxHyphenZoneItem ----------------------------------------------- 701 702 SvxHyphenZoneItem::SvxHyphenZoneItem( const sal_Bool bHyph, const sal_uInt16 nId ) : 703 SfxPoolItem( nId ) 704 { 705 bHyphen = bHyph; 706 bPageEnd = sal_True; 707 nMinLead = nMinTrail = 0; 708 nMaxHyphens = 255; 709 } 710 711 // ----------------------------------------------------------------------- 712 sal_Bool SvxHyphenZoneItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 713 { 714 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 715 nMemberId &= ~CONVERT_TWIPS; 716 switch(nMemberId) 717 { 718 case MID_IS_HYPHEN: 719 rVal = Bool2Any(bHyphen); 720 break; 721 case MID_HYPHEN_MIN_LEAD: 722 rVal <<= (sal_Int16)nMinLead; 723 break; 724 case MID_HYPHEN_MIN_TRAIL: 725 rVal <<= (sal_Int16)nMinTrail; 726 break; 727 case MID_HYPHEN_MAX_HYPHENS: 728 rVal <<= (sal_Int16)nMaxHyphens; 729 break; 730 } 731 return sal_True; 732 } 733 // ----------------------------------------------------------------------- 734 sal_Bool SvxHyphenZoneItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 735 { 736 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 737 nMemberId &= ~CONVERT_TWIPS; 738 sal_Int16 nNewVal = 0; 739 740 if( nMemberId != MID_IS_HYPHEN ) 741 if(!(rVal >>= nNewVal)) 742 return sal_False; 743 744 switch(nMemberId) 745 { 746 case MID_IS_HYPHEN: 747 bHyphen = Any2Bool(rVal); 748 break; 749 case MID_HYPHEN_MIN_LEAD: 750 nMinLead = (sal_uInt8)nNewVal; 751 break; 752 case MID_HYPHEN_MIN_TRAIL: 753 nMinTrail = (sal_uInt8)nNewVal; 754 break; 755 case MID_HYPHEN_MAX_HYPHENS: 756 nMaxHyphens = (sal_uInt8)nNewVal; 757 break; 758 } 759 return sal_True; 760 } 761 762 // ----------------------------------------------------------------------- 763 764 int SvxHyphenZoneItem::operator==( const SfxPoolItem& rAttr ) const 765 { 766 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 767 768 return ( (((SvxHyphenZoneItem&)rAttr).bHyphen == bHyphen) 769 && (((SvxHyphenZoneItem&)rAttr).bPageEnd == bPageEnd) 770 && (((SvxHyphenZoneItem&)rAttr).nMinLead == nMinLead) 771 && (((SvxHyphenZoneItem&)rAttr).nMinTrail == nMinTrail) 772 && (((SvxHyphenZoneItem&)rAttr).nMaxHyphens == nMaxHyphens) ); 773 } 774 775 // ----------------------------------------------------------------------- 776 777 SfxPoolItem* SvxHyphenZoneItem::Clone( SfxItemPool * ) const 778 { 779 return new SvxHyphenZoneItem( *this ); 780 } 781 782 //------------------------------------------------------------------------ 783 784 SfxItemPresentation SvxHyphenZoneItem::GetPresentation 785 ( 786 SfxItemPresentation ePres, 787 SfxMapUnit /*eCoreUnit*/, 788 SfxMapUnit /*ePresUnit*/, 789 XubString& rText, const IntlWrapper * 790 ) const 791 { 792 switch ( ePres ) 793 { 794 case SFX_ITEM_PRESENTATION_NONE: 795 rText.Erase(); 796 return SFX_ITEM_PRESENTATION_NONE; 797 case SFX_ITEM_PRESENTATION_NAMELESS: 798 { 799 sal_uInt16 nId = RID_SVXITEMS_HYPHEN_FALSE; 800 801 if ( bHyphen ) 802 nId = RID_SVXITEMS_HYPHEN_TRUE; 803 rText = EE_RESSTR(nId); 804 rText += cpDelim; 805 nId = RID_SVXITEMS_PAGE_END_FALSE; 806 807 if ( bPageEnd ) 808 nId = RID_SVXITEMS_PAGE_END_TRUE; 809 rText += EE_RESSTR(nId); 810 rText += cpDelim; 811 rText += String::CreateFromInt32( nMinLead ); 812 rText += cpDelim; 813 rText += String::CreateFromInt32( nMinTrail ); 814 rText += cpDelim; 815 rText += String::CreateFromInt32( nMaxHyphens ); 816 return SFX_ITEM_PRESENTATION_COMPLETE; 817 } 818 case SFX_ITEM_PRESENTATION_COMPLETE: 819 { 820 sal_uInt16 nId = RID_SVXITEMS_HYPHEN_FALSE; 821 822 if ( bHyphen ) 823 nId = RID_SVXITEMS_HYPHEN_TRUE; 824 rText = EE_RESSTR(nId); 825 rText += cpDelim; 826 nId = RID_SVXITEMS_PAGE_END_FALSE; 827 828 if ( bPageEnd ) 829 nId = RID_SVXITEMS_PAGE_END_TRUE; 830 rText += EE_RESSTR(nId); 831 rText += cpDelim; 832 rText += String::CreateFromInt32(nMinLead); 833 rText += EE_RESSTR(RID_SVXITEMS_HYPHEN_MINLEAD); 834 rText += cpDelim; 835 rText += String::CreateFromInt32(nMinTrail); 836 rText += EE_RESSTR(RID_SVXITEMS_HYPHEN_MINTRAIL); 837 rText += cpDelim; 838 rText += String::CreateFromInt32(nMaxHyphens); 839 rText += EE_RESSTR(RID_SVXITEMS_HYPHEN_MAX); 840 return SFX_ITEM_PRESENTATION_COMPLETE; 841 } 842 default: ;//prevent warning 843 } 844 return SFX_ITEM_PRESENTATION_NONE; 845 } 846 847 // ----------------------------------------------------------------------- 848 849 SfxPoolItem* SvxHyphenZoneItem::Create(SvStream& rStrm, sal_uInt16) const 850 { 851 sal_Int8 _bHyphen, _bHyphenPageEnd; 852 sal_Int8 _nMinLead, _nMinTrail, _nMaxHyphens; 853 rStrm >> _bHyphen >> _bHyphenPageEnd >> _nMinLead >> _nMinTrail >> _nMaxHyphens; 854 SvxHyphenZoneItem* pAttr = new SvxHyphenZoneItem( sal_False, Which() ); 855 pAttr->SetHyphen( sal_Bool( _bHyphen != 0 ) ); 856 pAttr->SetPageEnd( sal_Bool( _bHyphenPageEnd != 0 ) ); 857 pAttr->GetMinLead() = _nMinLead; 858 pAttr->GetMinTrail() = _nMinTrail; 859 pAttr->GetMaxHyphens() = _nMaxHyphens; 860 return pAttr; 861 } 862 863 // ----------------------------------------------------------------------- 864 865 SvStream& SvxHyphenZoneItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const 866 { 867 rStrm << (sal_Int8) IsHyphen() 868 << (sal_Int8) IsPageEnd() 869 << (sal_Int8) GetMinLead() 870 << (sal_Int8) GetMinTrail() 871 << (sal_Int8) GetMaxHyphens(); 872 return rStrm; 873 } 874 875 // class SvxTabStop ------------------------------------------------------ 876 877 SvxTabStop::SvxTabStop() 878 { 879 nTabPos = 0; 880 eAdjustment = SVX_TAB_ADJUST_LEFT; 881 m_cDecimal = cDfltDecimalChar; 882 cFill = cDfltFillChar; 883 } 884 885 // ----------------------------------------------------------------------- 886 887 SvxTabStop::SvxTabStop( const long nPos, const SvxTabAdjust eAdjst, 888 const sal_Unicode cDec, const sal_Unicode cFil ) 889 { 890 nTabPos = nPos; 891 eAdjustment = eAdjst; 892 m_cDecimal = cDec; 893 cFill = cFil; 894 } 895 // ----------------------------------------------------------------------------- 896 void SvxTabStop::fillDecimal() const 897 { 898 if ( cDfltDecimalChar == m_cDecimal ) 899 m_cDecimal = SvtSysLocale().GetLocaleData().getNumDecimalSep().GetChar(0); 900 } 901 // ----------------------------------------------------------------------- 902 903 XubString SvxTabStop::GetValueString() const 904 { 905 XubString aStr; 906 907 aStr += sal_Unicode( '(' ); 908 aStr += UniString::CreateFromInt32(nTabPos); 909 aStr += cpDelim; 910 aStr += XubString( EditResId( RID_SVXITEMS_TAB_ADJUST_BEGIN + (sal_uInt16)eAdjustment ) ); 911 912 aStr += cpDelim; 913 aStr += sal_Unicode('['); 914 aStr += XubString( EditResId( RID_SVXITEMS_TAB_DECIMAL_CHAR ) ); 915 aStr += GetDecimal(); 916 aStr += sal_Unicode(']'); 917 aStr += cpDelim; 918 aStr += cpDelim; 919 aStr += sal_Unicode('['); 920 aStr += XubString( EditResId( RID_SVXITEMS_TAB_FILL_CHAR ) ); 921 aStr += cFill; 922 aStr += sal_Unicode(']'); 923 aStr += sal_Unicode(')'); 924 925 return aStr; 926 } 927 928 // class SvxTabStopItem -------------------------------------------------- 929 930 SvxTabStopItem::SvxTabStopItem( sal_uInt16 _nWhich ) : 931 SfxPoolItem( _nWhich ), 932 SvxTabStopArr( sal_Int8(SVX_TAB_DEFCOUNT) ) 933 { 934 const sal_uInt16 nTabs = SVX_TAB_DEFCOUNT, nDist = SVX_TAB_DEFDIST; 935 const SvxTabAdjust eAdjst= SVX_TAB_ADJUST_DEFAULT; 936 937 for (sal_uInt16 i = 0; i < nTabs; ++i) 938 { 939 SvxTabStop aTab( (i + 1) * nDist, eAdjst ); 940 SvxTabStopArr::Insert( aTab ); 941 } 942 } 943 944 // ----------------------------------------------------------------------- 945 946 SvxTabStopItem::SvxTabStopItem( const sal_uInt16 nTabs, 947 const sal_uInt16 nDist, 948 const SvxTabAdjust eAdjst, 949 sal_uInt16 _nWhich ) : 950 SfxPoolItem( _nWhich ), 951 SvxTabStopArr( sal_Int8(nTabs) ) 952 { 953 for ( sal_uInt16 i = 0; i < nTabs; ++i ) 954 { 955 SvxTabStop aTab( (i + 1) * nDist, eAdjst ); 956 SvxTabStopArr::Insert( aTab ); 957 } 958 } 959 960 // ----------------------------------------------------------------------- 961 962 SvxTabStopItem::SvxTabStopItem( const SvxTabStopItem& rTSI ) : 963 SfxPoolItem( rTSI.Which() ), 964 SvxTabStopArr( (sal_Int8)rTSI.Count() ) 965 { 966 SvxTabStopArr::Insert( &rTSI ); 967 } 968 969 // ----------------------------------------------------------------------- 970 971 sal_uInt16 SvxTabStopItem::GetPos( const SvxTabStop& rTab ) const 972 { 973 sal_uInt16 nFound; 974 return Seek_Entry( rTab, &nFound ) ? nFound : SVX_TAB_NOTFOUND; 975 } 976 977 // ----------------------------------------------------------------------- 978 979 sal_uInt16 SvxTabStopItem::GetPos( const long nPos ) const 980 { 981 sal_uInt16 nFound; 982 return Seek_Entry( SvxTabStop( nPos ), &nFound ) ? nFound : SVX_TAB_NOTFOUND; 983 } 984 985 // ----------------------------------------------------------------------- 986 987 SvxTabStopItem& SvxTabStopItem::operator=( const SvxTabStopItem& rTSI ) 988 { 989 Remove( 0, Count() ); 990 SvxTabStopArr::Insert( &rTSI ); 991 return *this; 992 } 993 994 995 /* 996 enum ::com::sun::star::style::TabAlign 997 { 998 TABALIGN_LEFT, 999 TABALIGN_CENTER, 1000 TABALIGN_RIGHT, 1001 TABALIGN_DECIMAL 1002 }; 1003 1004 struct ::com::sun::star::style::TabStop 1005 { 1006 long Position; 1007 ::com::sun::star::style::TabAlign ::com::sun::star::drawing::Alignment; 1008 unsigned short DecimalChar; 1009 unsigned short FillChar; 1010 }; 1011 typedef sequence ::com::sun::star::style::TabStop> TabSTopSequence; 1012 1013 */ 1014 /*-----------------19.03.98 08:50------------------- 1015 1016 --------------------------------------------------*/ 1017 1018 sal_Bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 1019 { 1020 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 1021 nMemberId &= ~CONVERT_TWIPS; 1022 switch ( nMemberId ) 1023 { 1024 case MID_TABSTOPS: 1025 { 1026 sal_uInt16 nCount = Count(); 1027 uno::Sequence< style::TabStop> aSeq(nCount); 1028 style::TabStop* pArr = aSeq.getArray(); 1029 for(sal_uInt16 i = 0; i < nCount; i++) 1030 { 1031 const SvxTabStop& rTab = *(GetStart() + i); 1032 pArr[i].Position = bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos(); 1033 switch(rTab.GetAdjustment()) 1034 { 1035 case SVX_TAB_ADJUST_LEFT : pArr[i].Alignment = style::TabAlign_LEFT; break; 1036 case SVX_TAB_ADJUST_RIGHT : pArr[i].Alignment = style::TabAlign_RIGHT; break; 1037 case SVX_TAB_ADJUST_DECIMAL: pArr[i].Alignment = style::TabAlign_DECIMAL; break; 1038 case SVX_TAB_ADJUST_CENTER : pArr[i].Alignment = style::TabAlign_CENTER; break; 1039 default: //SVX_TAB_ADJUST_DEFAULT 1040 pArr[i].Alignment = style::TabAlign_DEFAULT; 1041 1042 } 1043 pArr[i].DecimalChar = rTab.GetDecimal(); 1044 pArr[i].FillChar = rTab.GetFill(); 1045 } 1046 rVal <<= aSeq; 1047 break; 1048 } 1049 case MID_STD_TAB: 1050 { 1051 const SvxTabStop &rTab = *(GetStart()); 1052 rVal <<= static_cast<sal_Int32>(bConvert ? TWIP_TO_MM100(rTab.GetTabPos()) : rTab.GetTabPos()); 1053 break; 1054 } 1055 } 1056 return sal_True; 1057 } 1058 /*-----------------19.03.98 08:50------------------- 1059 1060 --------------------------------------------------*/ 1061 1062 sal_Bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 1063 { 1064 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 1065 nMemberId &= ~CONVERT_TWIPS; 1066 switch ( nMemberId ) 1067 { 1068 case MID_TABSTOPS: 1069 { 1070 uno::Sequence< style::TabStop> aSeq; 1071 if(!(rVal >>= aSeq)) 1072 { 1073 uno::Sequence < uno::Sequence < uno::Any > > aAnySeq; 1074 if (!(rVal >>= aAnySeq)) 1075 return sal_False; 1076 sal_Int32 nLength = aAnySeq.getLength(); 1077 aSeq.realloc( nLength ); 1078 for ( sal_Int32 n=0; n<nLength; n++ ) 1079 { 1080 uno::Sequence < uno::Any >& rAnySeq = aAnySeq[n]; 1081 if ( rAnySeq.getLength() == 4 ) 1082 { 1083 if (!(rAnySeq[0] >>= aSeq[n].Position)) return sal_False; 1084 if (!(rAnySeq[1] >>= aSeq[n].Alignment)) 1085 { 1086 sal_Int32 nVal = 0; 1087 if (rAnySeq[1] >>= nVal) 1088 aSeq[n].Alignment = (com::sun::star::style::TabAlign) nVal; 1089 else 1090 return sal_False; 1091 } 1092 if (!(rAnySeq[2] >>= aSeq[n].DecimalChar)) 1093 { 1094 ::rtl::OUString aVal; 1095 if ( (rAnySeq[2] >>= aVal) && aVal.getLength() == 1 ) 1096 aSeq[n].DecimalChar = aVal.toChar(); 1097 else 1098 return sal_False; 1099 } 1100 if (!(rAnySeq[3] >>= aSeq[n].FillChar)) 1101 { 1102 ::rtl::OUString aVal; 1103 if ( (rAnySeq[3] >>= aVal) && aVal.getLength() == 1 ) 1104 aSeq[n].FillChar = aVal.toChar(); 1105 else 1106 return sal_False; 1107 } 1108 } 1109 else 1110 return sal_False; 1111 } 1112 } 1113 1114 SvxTabStopArr::Remove( 0, Count() ); 1115 const style::TabStop* pArr = aSeq.getConstArray(); 1116 const sal_uInt16 nCount = (sal_uInt16)aSeq.getLength(); 1117 for(sal_uInt16 i = 0; i < nCount ; i++) 1118 { 1119 SvxTabAdjust eAdjust = SVX_TAB_ADJUST_DEFAULT; 1120 switch(pArr[i].Alignment) 1121 { 1122 case style::TabAlign_LEFT : eAdjust = SVX_TAB_ADJUST_LEFT; break; 1123 case style::TabAlign_CENTER : eAdjust = SVX_TAB_ADJUST_CENTER; break; 1124 case style::TabAlign_RIGHT : eAdjust = SVX_TAB_ADJUST_RIGHT; break; 1125 case style::TabAlign_DECIMAL: eAdjust = SVX_TAB_ADJUST_DECIMAL; break; 1126 default: ;//prevent warning 1127 } 1128 sal_Unicode cFill = pArr[i].FillChar; 1129 sal_Unicode cDecimal = pArr[i].DecimalChar; 1130 SvxTabStop aTab( bConvert ? MM100_TO_TWIP(pArr[i].Position) : pArr[i].Position, 1131 eAdjust, 1132 cDecimal, 1133 cFill ); 1134 Insert(aTab); 1135 } 1136 break; 1137 } 1138 case MID_STD_TAB: 1139 { 1140 sal_Int32 nNewPos = 0; 1141 if (!(rVal >>= nNewPos) ) 1142 return sal_False; 1143 const SvxTabStop& rTab = *(GetStart()); 1144 SvxTabStop aNewTab ( bConvert ? MM100_TO_TWIP ( nNewPos ) : nNewPos, 1145 rTab.GetAdjustment(), rTab.GetDecimal(), rTab.GetFill() ); 1146 Remove ( 0 ); 1147 Insert( aNewTab ); 1148 break; 1149 } 1150 } 1151 return sal_True; 1152 } 1153 // ----------------------------------------------------------------------- 1154 1155 int SvxTabStopItem::operator==( const SfxPoolItem& rAttr ) const 1156 { 1157 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 1158 1159 const SvxTabStopItem& rTSI = (SvxTabStopItem&)rAttr; 1160 1161 if ( Count() != rTSI.Count() ) 1162 return 0; 1163 1164 for ( sal_uInt16 i = 0; i < Count(); ++i ) 1165 if( !(*this)[i].IsEqual( rTSI[i] ) ) 1166 return 0; 1167 return 1; 1168 } 1169 1170 // ----------------------------------------------------------------------- 1171 1172 SfxPoolItem* SvxTabStopItem::Clone( SfxItemPool * ) const 1173 { 1174 return new SvxTabStopItem( *this ); 1175 } 1176 1177 //------------------------------------------------------------------------ 1178 1179 SfxItemPresentation SvxTabStopItem::GetPresentation 1180 ( 1181 SfxItemPresentation ePres, 1182 SfxMapUnit eCoreUnit, 1183 SfxMapUnit ePresUnit, 1184 XubString& rText, const IntlWrapper *pIntl 1185 ) const 1186 { 1187 rText.Erase(); 1188 1189 if ( ePres > SFX_ITEM_PRESENTATION_NONE ) 1190 { 1191 #ifndef SVX_LIGHT 1192 sal_Bool bComma = sal_False; 1193 1194 for ( sal_uInt16 i = 0; i < Count(); ++i ) 1195 { 1196 if ( SVX_TAB_ADJUST_DEFAULT != ((*this)[i]).GetAdjustment() ) 1197 { 1198 if ( bComma ) 1199 rText += sal_Unicode(','); 1200 rText += GetMetricText( 1201 (long)((*this)[i]).GetTabPos(), eCoreUnit, ePresUnit, pIntl ); 1202 if ( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) 1203 rText += EE_RESSTR(GetMetricId(ePresUnit)); 1204 bComma = sal_True; 1205 } 1206 } 1207 #endif 1208 } 1209 return ePres; 1210 } 1211 1212 // ----------------------------------------------------------------------- 1213 1214 SfxPoolItem* SvxTabStopItem::Create( SvStream& rStrm, sal_uInt16 ) const 1215 { 1216 sal_Int8 nTabs; 1217 rStrm >> nTabs; 1218 SvxTabStopItem* pAttr = 1219 new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_DEFAULT, Which() ); 1220 1221 for ( sal_Int8 i = 0; i < nTabs; i++ ) 1222 { 1223 long nPos; 1224 sal_Int8 eAdjust; 1225 unsigned char cDecimal, cFill; 1226 rStrm >> nPos >> eAdjust >> cDecimal >> cFill; 1227 if( !i || SVX_TAB_ADJUST_DEFAULT != eAdjust ) 1228 pAttr->Insert( SvxTabStop 1229 ( nPos, (SvxTabAdjust)eAdjust, sal_Unicode(cDecimal), sal_Unicode(cFill) ) ); 1230 } 1231 return pAttr; 1232 } 1233 1234 // ----------------------------------------------------------------------- 1235 1236 SvStream& SvxTabStopItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const 1237 { 1238 //MA 05. Sep. 96: Default-Tabs werden nur noch fuer das default-Attr 1239 //expandiert. Fuer vollstaendige Rueckwaertskompatibilitaet (<=304) 1240 //muessten alle Tabs expandiert werden, dass blaeht aber das File u.U. 1241 //enorm auf. 1242 //Alles nur SWG! 1243 1244 const SfxItemPool *pPool = SfxItemPool::GetStoringPool(); 1245 const FASTBOOL bStoreDefTabs = pPool 1246 && pPool->GetName().EqualsAscii("SWG") 1247 && ::IsDefaultItem( this ); 1248 1249 const short nTabs = Count(); 1250 sal_uInt16 nCount = 0, nDefDist = 0; 1251 long nNew = 0; 1252 1253 if( bStoreDefTabs ) 1254 { 1255 const SvxTabStopItem& rDefTab = (const SvxTabStopItem &) 1256 pPool->GetDefaultItem( pPool->GetWhich( SID_ATTR_TABSTOP, sal_False ) ); 1257 nDefDist = sal_uInt16( rDefTab.GetStart()->GetTabPos() ); 1258 const long nPos = nTabs > 0 ? (*this)[nTabs-1].GetTabPos() : 0; 1259 nCount = (sal_uInt16)(nPos / nDefDist); 1260 nNew = (nCount + 1) * nDefDist; 1261 1262 if( nNew <= nPos + 50 ) 1263 nNew += nDefDist; 1264 1265 long lA3Width = SvxPaperInfo::GetPaperSize(PAPER_A3).Width(); 1266 nCount = (sal_uInt16)(nNew < lA3Width ? ( lA3Width - nNew ) / nDefDist + 1 : 0); 1267 } 1268 1269 rStrm << (sal_Int8) ( nTabs + nCount ); 1270 for ( short i = 0; i < nTabs; i++ ) 1271 { 1272 const SvxTabStop& rTab = (*this)[ i ]; 1273 rStrm << (long) rTab.GetTabPos() 1274 << (sal_Int8) rTab.GetAdjustment() 1275 << (unsigned char) rTab.GetDecimal() 1276 << (unsigned char) rTab.GetFill(); 1277 } 1278 1279 if ( bStoreDefTabs ) 1280 for( ; nCount; --nCount ) 1281 { 1282 SvxTabStop aSwTabStop(nNew, SVX_TAB_ADJUST_DEFAULT); 1283 rStrm << (long) aSwTabStop.GetTabPos() 1284 << (sal_Int8) aSwTabStop.GetAdjustment() 1285 << (unsigned char) aSwTabStop.GetDecimal() 1286 << (unsigned char) aSwTabStop.GetFill(); 1287 nNew += nDefDist; 1288 } 1289 1290 return rStrm; 1291 } 1292 1293 // ----------------------------------------------------------------------- 1294 sal_Bool SvxTabStopItem::Insert( const SvxTabStop& rTab ) 1295 { 1296 sal_uInt16 nTabPos = GetPos(rTab); 1297 if(SVX_TAB_NOTFOUND != nTabPos ) 1298 Remove(nTabPos); 1299 return SvxTabStopArr::Insert( rTab ); 1300 } 1301 // ----------------------------------------------------------------------- 1302 void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart, 1303 sal_uInt16 nEnd ) 1304 { 1305 for( sal_uInt16 i = nStart; i < nEnd && i < pTabs->Count(); i++ ) 1306 { 1307 const SvxTabStop& rTab = (*pTabs)[i]; 1308 sal_uInt16 nTabPos = GetPos(rTab); 1309 if(SVX_TAB_NOTFOUND != nTabPos) 1310 Remove(nTabPos); 1311 } 1312 SvxTabStopArr::Insert( pTabs, nStart, nEnd ); 1313 } 1314 1315 1316 1317 // class SvxFmtSplitItem ------------------------------------------------- 1318 SvxFmtSplitItem::~SvxFmtSplitItem() 1319 { 1320 } 1321 // ----------------------------------------------------------------------- 1322 SfxPoolItem* SvxFmtSplitItem::Clone( SfxItemPool * ) const 1323 { 1324 return new SvxFmtSplitItem( *this ); 1325 } 1326 1327 // ----------------------------------------------------------------------- 1328 1329 SvStream& SvxFmtSplitItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const 1330 { 1331 rStrm << (sal_Int8)GetValue(); 1332 return rStrm; 1333 } 1334 1335 // ----------------------------------------------------------------------- 1336 1337 SfxPoolItem* SvxFmtSplitItem::Create( SvStream& rStrm, sal_uInt16 ) const 1338 { 1339 sal_Int8 bIsSplit; 1340 rStrm >> bIsSplit; 1341 return new SvxFmtSplitItem( sal_Bool( bIsSplit != 0 ), Which() ); 1342 } 1343 1344 //------------------------------------------------------------------------ 1345 1346 SfxItemPresentation SvxFmtSplitItem::GetPresentation 1347 ( 1348 SfxItemPresentation ePres, 1349 SfxMapUnit /*eCoreUnit*/, 1350 SfxMapUnit /*ePresUnit*/, 1351 XubString& rText, const IntlWrapper * 1352 ) const 1353 { 1354 switch ( ePres ) 1355 { 1356 case SFX_ITEM_PRESENTATION_NONE: 1357 rText.Erase(); 1358 return SFX_ITEM_PRESENTATION_NONE; 1359 case SFX_ITEM_PRESENTATION_NAMELESS: 1360 case SFX_ITEM_PRESENTATION_COMPLETE: 1361 { 1362 sal_uInt16 nId = RID_SVXITEMS_FMTSPLIT_FALSE; 1363 1364 if ( GetValue() ) 1365 nId = RID_SVXITEMS_FMTSPLIT_TRUE; 1366 rText = EE_RESSTR(nId); 1367 return ePres; 1368 } 1369 default: ;//prevent warning 1370 } 1371 return SFX_ITEM_PRESENTATION_NONE; 1372 } 1373 1374 // -------------------------------------------------------------------- 1375 1376 SfxPoolItem* SvxPageModelItem::Clone( SfxItemPool* ) const 1377 { 1378 return new SvxPageModelItem( *this ); 1379 } 1380 1381 //------------------------------------------------------------------------ 1382 1383 sal_Bool SvxPageModelItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const 1384 { 1385 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 1386 nMemberId &= ~CONVERT_TWIPS; 1387 1388 switch ( nMemberId ) 1389 { 1390 case MID_AUTO: rVal <<= (sal_Bool) bAuto; break; 1391 case MID_NAME: rVal <<= ::rtl::OUString( GetValue() ); break; 1392 default: DBG_ERROR("Wrong MemberId!"); return sal_False; 1393 } 1394 1395 return sal_True; 1396 } 1397 1398 sal_Bool SvxPageModelItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) 1399 { 1400 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 1401 nMemberId &= ~CONVERT_TWIPS; 1402 sal_Bool bRet; 1403 ::rtl::OUString aStr; 1404 switch ( nMemberId ) 1405 { 1406 case MID_AUTO: bRet = ( rVal >>= bAuto ); break; 1407 case MID_NAME: bRet = ( rVal >>= aStr ); if ( bRet ) SetValue(aStr); break; 1408 default: DBG_ERROR("Wrong MemberId!"); return sal_False; 1409 } 1410 1411 return bRet; 1412 } 1413 1414 SfxItemPresentation SvxPageModelItem::GetPresentation 1415 ( 1416 SfxItemPresentation ePres, 1417 SfxMapUnit /*eCoreUnit*/, 1418 SfxMapUnit /*ePresUnit*/, 1419 XubString& rText, const IntlWrapper * 1420 ) const 1421 { 1422 rText.Erase(); 1423 FASTBOOL bSet = ( GetValue().Len() > 0 ); 1424 1425 switch ( ePres ) 1426 { 1427 case SFX_ITEM_PRESENTATION_NONE: 1428 return SFX_ITEM_PRESENTATION_NONE; 1429 1430 case SFX_ITEM_PRESENTATION_NAMELESS: 1431 if ( bSet ) 1432 rText = GetValue(); 1433 return SFX_ITEM_PRESENTATION_NAMELESS; 1434 1435 case SFX_ITEM_PRESENTATION_COMPLETE: 1436 if ( bSet ) 1437 { 1438 rText = EE_RESSTR(RID_SVXITEMS_PAGEMODEL_COMPLETE); 1439 rText += GetValue(); 1440 } 1441 return SFX_ITEM_PRESENTATION_COMPLETE; 1442 default: ;//prevent warning 1443 } 1444 return SFX_ITEM_PRESENTATION_NONE; 1445 } 1446 1447 //------------------------------------------------------------------------ 1448 1449 SvxScriptSpaceItem::SvxScriptSpaceItem( sal_Bool bOn, const sal_uInt16 nId ) 1450 : SfxBoolItem( nId, bOn ) 1451 { 1452 } 1453 1454 SfxPoolItem* SvxScriptSpaceItem::Clone( SfxItemPool * ) const 1455 { 1456 return new SvxScriptSpaceItem( GetValue(), Which() ); 1457 } 1458 1459 SfxPoolItem* SvxScriptSpaceItem::Create(SvStream & rStrm, sal_uInt16) const 1460 { 1461 sal_Bool bFlag; 1462 rStrm >> bFlag; 1463 return new SvxScriptSpaceItem( bFlag, Which() ); 1464 } 1465 1466 sal_uInt16 SvxScriptSpaceItem::GetVersion( sal_uInt16 nFFVer ) const 1467 { 1468 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer || 1469 SOFFICE_FILEFORMAT_40==nFFVer || 1470 SOFFICE_FILEFORMAT_50==nFFVer, 1471 "SvxTwoLinesItem: Gibt es ein neues Fileformat?" ); 1472 1473 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0; 1474 } 1475 1476 SfxItemPresentation SvxScriptSpaceItem::GetPresentation( 1477 SfxItemPresentation ePres, 1478 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, 1479 String &rText, const IntlWrapper* /*pIntl*/ ) const 1480 { 1481 switch( ePres ) 1482 { 1483 case SFX_ITEM_PRESENTATION_NONE: 1484 rText.Erase(); 1485 break; 1486 case SFX_ITEM_PRESENTATION_NAMELESS: 1487 case SFX_ITEM_PRESENTATION_COMPLETE: 1488 { 1489 rText = EE_RESSTR( !GetValue() 1490 ? RID_SVXITEMS_SCRPTSPC_OFF 1491 : RID_SVXITEMS_SCRPTSPC_ON ); 1492 return ePres; 1493 } 1494 default: ;//prevent warning 1495 } 1496 return SFX_ITEM_PRESENTATION_NONE; 1497 } 1498 1499 //------------------------------------------------------------------------ 1500 1501 SvxHangingPunctuationItem::SvxHangingPunctuationItem( 1502 sal_Bool bOn, const sal_uInt16 nId ) 1503 : SfxBoolItem( nId, bOn ) 1504 { 1505 } 1506 1507 SfxPoolItem* SvxHangingPunctuationItem::Clone( SfxItemPool * ) const 1508 { 1509 return new SvxHangingPunctuationItem( GetValue(), Which() ); 1510 } 1511 1512 SfxPoolItem* SvxHangingPunctuationItem::Create(SvStream & rStrm, sal_uInt16) const 1513 { 1514 sal_Bool nValue; 1515 rStrm >> nValue; 1516 return new SvxHangingPunctuationItem( nValue, Which() ); 1517 } 1518 1519 sal_uInt16 SvxHangingPunctuationItem::GetVersion( sal_uInt16 nFFVer ) const 1520 { 1521 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer || 1522 SOFFICE_FILEFORMAT_40==nFFVer || 1523 SOFFICE_FILEFORMAT_50==nFFVer, 1524 "SvxHangingPunctuationItem: Gibt es ein neues Fileformat?" ); 1525 1526 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0; 1527 } 1528 1529 SfxItemPresentation SvxHangingPunctuationItem::GetPresentation( 1530 SfxItemPresentation ePres, 1531 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, 1532 String &rText, const IntlWrapper* /*pIntl*/ ) const 1533 { 1534 switch( ePres ) 1535 { 1536 case SFX_ITEM_PRESENTATION_NONE: 1537 rText.Erase(); 1538 break; 1539 case SFX_ITEM_PRESENTATION_NAMELESS: 1540 case SFX_ITEM_PRESENTATION_COMPLETE: 1541 { 1542 rText = EE_RESSTR( !GetValue() 1543 ? RID_SVXITEMS_HNGPNCT_OFF 1544 : RID_SVXITEMS_HNGPNCT_ON ); 1545 return ePres; 1546 } 1547 default: ;//prevent warning 1548 break; 1549 } 1550 return SFX_ITEM_PRESENTATION_NONE; 1551 } 1552 //------------------------------------------------------------------------ 1553 1554 SvxForbiddenRuleItem::SvxForbiddenRuleItem( 1555 sal_Bool bOn, const sal_uInt16 nId ) 1556 : SfxBoolItem( nId, bOn ) 1557 { 1558 } 1559 /* -----------------------------29.11.00 11:23-------------------------------- 1560 1561 ---------------------------------------------------------------------------*/ 1562 SfxPoolItem* SvxForbiddenRuleItem::Clone( SfxItemPool * ) const 1563 { 1564 return new SvxForbiddenRuleItem( GetValue(), Which() ); 1565 } 1566 /* -----------------------------29.11.00 11:23-------------------------------- 1567 1568 ---------------------------------------------------------------------------*/ 1569 SfxPoolItem* SvxForbiddenRuleItem::Create(SvStream & rStrm, sal_uInt16) const 1570 { 1571 sal_Bool nValue; 1572 rStrm >> nValue; 1573 return new SvxForbiddenRuleItem( nValue, Which() ); 1574 } 1575 /* -----------------------------29.11.00 11:23-------------------------------- 1576 1577 ---------------------------------------------------------------------------*/ 1578 sal_uInt16 SvxForbiddenRuleItem::GetVersion( sal_uInt16 nFFVer ) const 1579 { 1580 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer || 1581 SOFFICE_FILEFORMAT_40==nFFVer || 1582 SOFFICE_FILEFORMAT_50==nFFVer, 1583 "SvxForbiddenRuleItem: Gibt es ein neues Fileformat?" ); 1584 1585 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0; 1586 } 1587 /* -----------------------------29.11.00 11:23-------------------------------- 1588 1589 ---------------------------------------------------------------------------*/ 1590 SfxItemPresentation SvxForbiddenRuleItem::GetPresentation( 1591 SfxItemPresentation ePres, 1592 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, 1593 String &rText, const IntlWrapper* /*pIntl*/ ) const 1594 { 1595 switch( ePres ) 1596 { 1597 case SFX_ITEM_PRESENTATION_NONE: 1598 rText.Erase(); 1599 break; 1600 case SFX_ITEM_PRESENTATION_NAMELESS: 1601 case SFX_ITEM_PRESENTATION_COMPLETE: 1602 { 1603 rText = EE_RESSTR( !GetValue() 1604 ? RID_SVXITEMS_FORBIDDEN_RULE_OFF 1605 : RID_SVXITEMS_FORBIDDEN_RULE_ON ); 1606 return ePres; 1607 } 1608 default: ;//prevent warning 1609 break; 1610 } 1611 return SFX_ITEM_PRESENTATION_NONE; 1612 } 1613 1614 /************************************************************************* 1615 |* class SvxParaVertAlignItem 1616 *************************************************************************/ 1617 1618 SvxParaVertAlignItem::SvxParaVertAlignItem( sal_uInt16 nValue, 1619 const sal_uInt16 nW ) 1620 : SfxUInt16Item( nW, nValue ) 1621 { 1622 } 1623 1624 SfxPoolItem* SvxParaVertAlignItem::Clone( SfxItemPool* ) const 1625 { 1626 return new SvxParaVertAlignItem( GetValue(), Which() ); 1627 } 1628 1629 SfxPoolItem* SvxParaVertAlignItem::Create( SvStream& rStrm, sal_uInt16 ) const 1630 { 1631 sal_uInt16 nVal; 1632 rStrm >> nVal; 1633 return new SvxParaVertAlignItem( nVal, Which() ); 1634 } 1635 1636 SvStream& SvxParaVertAlignItem::Store( SvStream & rStrm, sal_uInt16 ) const 1637 { 1638 rStrm << GetValue(); 1639 return rStrm; 1640 } 1641 1642 sal_uInt16 SvxParaVertAlignItem::GetVersion( sal_uInt16 nFFVer ) const 1643 { 1644 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0; 1645 } 1646 1647 SfxItemPresentation SvxParaVertAlignItem::GetPresentation( 1648 SfxItemPresentation ePres, 1649 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, 1650 String &rText, const IntlWrapper* ) const 1651 { 1652 switch( ePres ) 1653 { 1654 case SFX_ITEM_PRESENTATION_NONE: 1655 rText.Erase(); 1656 break; 1657 case SFX_ITEM_PRESENTATION_NAMELESS: 1658 case SFX_ITEM_PRESENTATION_COMPLETE: 1659 { 1660 sal_uInt16 nTmp; 1661 switch( GetValue() ) 1662 { 1663 case AUTOMATIC: nTmp = RID_SVXITEMS_PARAVERTALIGN_AUTO; break; 1664 case TOP: nTmp = RID_SVXITEMS_PARAVERTALIGN_TOP; break; 1665 case CENTER: nTmp = RID_SVXITEMS_PARAVERTALIGN_CENTER; break; 1666 case BOTTOM: nTmp = RID_SVXITEMS_PARAVERTALIGN_BOTTOM; break; 1667 default: nTmp = RID_SVXITEMS_PARAVERTALIGN_BASELINE; break; 1668 } 1669 rText = EE_RESSTR( nTmp ); 1670 return ePres; 1671 } 1672 default: ;//prevent warning 1673 break; 1674 } 1675 return SFX_ITEM_PRESENTATION_NONE; 1676 } 1677 1678 sal_Bool SvxParaVertAlignItem::QueryValue( com::sun::star::uno::Any& rVal, 1679 sal_uInt8 /*nMemberId*/ ) const 1680 { 1681 rVal <<= (sal_Int16)GetValue(); 1682 return sal_True; 1683 } 1684 1685 sal_Bool SvxParaVertAlignItem::PutValue( const com::sun::star::uno::Any& rVal, 1686 sal_uInt8 /*nMemberId*/ ) 1687 { 1688 sal_Int16 nVal = sal_Int16(); 1689 if((rVal >>= nVal) && nVal >=0 && nVal <= BOTTOM ) 1690 { 1691 SetValue( (sal_uInt16)nVal ); 1692 return sal_True; 1693 } 1694 else 1695 return sal_False; 1696 } 1697 1698 int SvxParaVertAlignItem::operator==( const SfxPoolItem& rItem ) const 1699 { 1700 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" ); 1701 return SfxUInt16Item::operator==( rItem ); 1702 } 1703 1704 1705 SvxParaGridItem::SvxParaGridItem( sal_Bool bOn, const sal_uInt16 nId ) 1706 : SfxBoolItem( nId, bOn ) 1707 { 1708 } 1709 1710 SfxPoolItem* SvxParaGridItem::Clone( SfxItemPool * ) const 1711 { 1712 return new SvxParaGridItem( GetValue(), Which() ); 1713 } 1714 1715 SfxPoolItem* SvxParaGridItem::Create(SvStream & rStrm, sal_uInt16) const 1716 { 1717 sal_Bool bFlag; 1718 rStrm >> bFlag; 1719 return new SvxParaGridItem( bFlag, Which() ); 1720 } 1721 1722 sal_uInt16 SvxParaGridItem::GetVersion( sal_uInt16 nFFVer ) const 1723 { 1724 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer || 1725 SOFFICE_FILEFORMAT_40==nFFVer || 1726 SOFFICE_FILEFORMAT_50==nFFVer, 1727 "SvxParaGridItem: Gibt es ein neues Fileformat?" ); 1728 1729 return SOFFICE_FILEFORMAT_50 > nFFVer ? USHRT_MAX : 0; 1730 } 1731 1732 SfxItemPresentation SvxParaGridItem::GetPresentation( 1733 SfxItemPresentation ePres, 1734 SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, 1735 String &rText, const IntlWrapper* /*pIntl*/ ) const 1736 { 1737 switch( ePres ) 1738 { 1739 case SFX_ITEM_PRESENTATION_NONE: 1740 rText.Erase(); 1741 break; 1742 case SFX_ITEM_PRESENTATION_NAMELESS: 1743 case SFX_ITEM_PRESENTATION_COMPLETE: 1744 { 1745 rText = GetValue() ? 1746 EE_RESSTR( RID_SVXITEMS_PARASNAPTOGRID_ON ) : 1747 EE_RESSTR( RID_SVXITEMS_PARASNAPTOGRID_OFF ); 1748 1749 return ePres; 1750 } 1751 default: ;//prevent warning 1752 break; 1753 } 1754 return SFX_ITEM_PRESENTATION_NONE; 1755 } 1756 1757 1758