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