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_sc.hxx" 30 31 32 // INCLUDE --------------------------------------------------------------- 33 34 #include "scitems.hxx" 35 #include <editeng/adjitem.hxx> 36 #include <svx/algitem.hxx> 37 #include <editeng/boxitem.hxx> 38 #include <editeng/bolnitem.hxx> 39 #include <editeng/brshitem.hxx> 40 #include <editeng/charreliefitem.hxx> 41 #include <editeng/cntritem.hxx> 42 #include <svtools/colorcfg.hxx> 43 #include <editeng/colritem.hxx> 44 #include <editeng/crsditem.hxx> 45 #include <editeng/emphitem.hxx> 46 #include <editeng/fhgtitem.hxx> 47 #include <editeng/fontitem.hxx> 48 #include <editeng/forbiddenruleitem.hxx> 49 #include <editeng/frmdiritem.hxx> 50 #include <editeng/langitem.hxx> 51 #include <editeng/postitem.hxx> 52 #include <svx/rotmodit.hxx> 53 #include <editeng/scriptspaceitem.hxx> 54 #include <editeng/scripttypeitem.hxx> 55 #include <editeng/shaditem.hxx> 56 #include <editeng/shdditem.hxx> 57 #include <editeng/udlnitem.hxx> 58 #include <editeng/wghtitem.hxx> 59 #include <editeng/wrlmitem.hxx> 60 #include <svl/intitem.hxx> 61 #include <svl/zforlist.hxx> 62 #include <vcl/outdev.hxx> 63 #include <vcl/svapp.hxx> 64 65 #include "patattr.hxx" 66 #include "docpool.hxx" 67 #include "stlsheet.hxx" 68 #include "stlpool.hxx" 69 #include "document.hxx" 70 #include "global.hxx" 71 #include "globstr.hrc" 72 #include "conditio.hxx" 73 #include "validat.hxx" 74 #include "scmod.hxx" 75 #include "fillinfo.hxx" 76 77 // STATIC DATA ----------------------------------------------------------- 78 79 ScDocument* ScPatternAttr::pDoc = NULL; 80 81 // ----------------------------------------------------------------------- 82 83 //! move to some header file 84 inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; } 85 inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; } 86 87 // ----------------------------------------------------------------------- 88 89 ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, const String& rStyleName ) 90 : SfxSetItem ( ATTR_PATTERN, pItemSet ), 91 pName ( new String( rStyleName ) ), 92 pStyle ( NULL ) 93 { 94 } 95 96 ScPatternAttr::ScPatternAttr( SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet ) 97 : SfxSetItem ( ATTR_PATTERN, pItemSet ), 98 pName ( NULL ), 99 pStyle ( pStyleSheet ) 100 { 101 if ( pStyleSheet ) 102 GetItemSet().SetParent( &pStyleSheet->GetItemSet() ); 103 } 104 105 ScPatternAttr::ScPatternAttr( SfxItemPool* pItemPool ) 106 : SfxSetItem ( ATTR_PATTERN, new SfxItemSet( *pItemPool, ATTR_PATTERN_START, ATTR_PATTERN_END ) ), 107 pName ( NULL ), 108 pStyle ( NULL ) 109 { 110 } 111 112 ScPatternAttr::ScPatternAttr( const ScPatternAttr& rPatternAttr ) 113 : SfxSetItem ( rPatternAttr ), 114 pStyle ( rPatternAttr.pStyle ) 115 { 116 if (rPatternAttr.pName) 117 pName = new String(*rPatternAttr.pName); 118 else 119 pName = NULL; 120 } 121 122 __EXPORT ScPatternAttr::~ScPatternAttr() 123 { 124 delete pName; 125 } 126 127 SfxPoolItem* __EXPORT ScPatternAttr::Clone( SfxItemPool *pPool ) const 128 { 129 ScPatternAttr* pPattern = new ScPatternAttr( GetItemSet().Clone(sal_True, pPool) ); 130 131 pPattern->pStyle = pStyle; 132 pPattern->pName = pName ? new String(*pName) : NULL; 133 134 return pPattern; 135 } 136 137 inline int StrCmp( const String* pStr1, const String* pStr2 ) 138 { 139 return ( pStr1 ? ( pStr2 ? ( *pStr1 == *pStr2 ) : sal_False ) : ( pStr2 ? sal_False : sal_True ) ); 140 } 141 142 inline bool EqualPatternSets( const SfxItemSet& rSet1, const SfxItemSet& rSet2 ) 143 { 144 // #i62090# The SfxItemSet in the SfxSetItem base class always has the same ranges 145 // (single range from ATTR_PATTERN_START to ATTR_PATTERN_END), and the items are pooled, 146 // so it's enough to compare just the pointers (Count just because it's even faster). 147 148 if ( rSet1.Count() != rSet2.Count() ) 149 return false; 150 151 SfxItemArray pItems1 = rSet1.GetItems_Impl(); // inline method of SfxItemSet 152 SfxItemArray pItems2 = rSet2.GetItems_Impl(); 153 154 return ( 0 == memcmp( pItems1, pItems2, (ATTR_PATTERN_END - ATTR_PATTERN_START + 1) * sizeof(pItems1[0]) ) ); 155 } 156 157 int __EXPORT ScPatternAttr::operator==( const SfxPoolItem& rCmp ) const 158 { 159 // #i62090# Use quick comparison between ScPatternAttr's ItemSets 160 161 return ( EqualPatternSets( GetItemSet(), static_cast<const ScPatternAttr&>(rCmp).GetItemSet() ) && 162 StrCmp( GetStyleName(), static_cast<const ScPatternAttr&>(rCmp).GetStyleName() ) ); 163 } 164 165 SfxPoolItem* __EXPORT ScPatternAttr::Create( SvStream& rStream, sal_uInt16 /* nVersion */ ) const 166 { 167 String* pStr; 168 sal_Bool bHasStyle; 169 short eFamDummy; 170 171 rStream >> bHasStyle; 172 173 if ( bHasStyle ) 174 { 175 pStr = new String; 176 rStream.ReadByteString( *pStr, rStream.GetStreamCharSet() ); 177 rStream >> eFamDummy; // wg. altem Dateiformat 178 } 179 else 180 pStr = new String( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ); 181 182 SfxItemSet *pNewSet = new SfxItemSet( *GetItemSet().GetPool(), 183 ATTR_PATTERN_START, ATTR_PATTERN_END ); 184 pNewSet->Load( rStream ); 185 186 ScPatternAttr* pPattern = new ScPatternAttr( pNewSet ); 187 188 pPattern->pName = pStr; 189 190 return pPattern; 191 } 192 193 SvStream& __EXPORT ScPatternAttr::Store(SvStream& rStream, sal_uInt16 /* nItemVersion */) const 194 { 195 rStream << (sal_Bool)sal_True; 196 197 if ( pStyle ) 198 rStream.WriteByteString( pStyle->GetName(), rStream.GetStreamCharSet() ); 199 else if ( pName ) // wenn Style geloescht ist/war 200 rStream.WriteByteString( *pName, rStream.GetStreamCharSet() ); 201 else 202 rStream.WriteByteString( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), 203 rStream.GetStreamCharSet() ); 204 205 rStream << (short)SFX_STYLE_FAMILY_PARA; // wg. altem Dateiformat 206 207 GetItemSet().Store( rStream ); 208 209 return rStream; 210 } 211 212 SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ) 213 { 214 SvxCellOrientation eOrient = SVX_ORIENTATION_STANDARD; 215 216 if( ((const SfxBoolItem&)GetItem( ATTR_STACKED, rItemSet, pCondSet )).GetValue() ) 217 { 218 eOrient = SVX_ORIENTATION_STACKED; 219 } 220 else 221 { 222 sal_Int32 nAngle = ((const SfxInt32Item&)GetItem( ATTR_ROTATE_VALUE, rItemSet, pCondSet )).GetValue(); 223 if( nAngle == 9000 ) 224 eOrient = SVX_ORIENTATION_BOTTOMTOP; 225 else if( nAngle == 27000 ) 226 eOrient = SVX_ORIENTATION_TOPBOTTOM; 227 } 228 229 return eOrient; 230 } 231 232 SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet* pCondSet ) const 233 { 234 return GetCellOrientation( GetItemSet(), pCondSet ); 235 } 236 237 void ScPatternAttr::GetFont( 238 Font& rFont, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, 239 OutputDevice* pOutDev, const Fraction* pScale, 240 const SfxItemSet* pCondSet, sal_uInt8 nScript, 241 const Color* pBackConfigColor, const Color* pTextConfigColor ) 242 { 243 // Items auslesen 244 245 const SvxFontItem* pFontAttr; 246 sal_uInt32 nFontHeight; 247 FontWeight eWeight; 248 FontItalic eItalic; 249 FontUnderline eUnder; 250 FontUnderline eOver; 251 sal_Bool bWordLine; 252 FontStrikeout eStrike; 253 sal_Bool bOutline; 254 sal_Bool bShadow; 255 FontEmphasisMark eEmphasis; 256 FontRelief eRelief; 257 Color aColor; 258 LanguageType eLang; 259 260 sal_uInt16 nFontId, nHeightId, nWeightId, nPostureId, nLangId; 261 if ( nScript == SCRIPTTYPE_ASIAN ) 262 { 263 nFontId = ATTR_CJK_FONT; 264 nHeightId = ATTR_CJK_FONT_HEIGHT; 265 nWeightId = ATTR_CJK_FONT_WEIGHT; 266 nPostureId = ATTR_CJK_FONT_POSTURE; 267 nLangId = ATTR_CJK_FONT_LANGUAGE; 268 } 269 else if ( nScript == SCRIPTTYPE_COMPLEX ) 270 { 271 nFontId = ATTR_CTL_FONT; 272 nHeightId = ATTR_CTL_FONT_HEIGHT; 273 nWeightId = ATTR_CTL_FONT_WEIGHT; 274 nPostureId = ATTR_CTL_FONT_POSTURE; 275 nLangId = ATTR_CTL_FONT_LANGUAGE; 276 } 277 else 278 { 279 nFontId = ATTR_FONT; 280 nHeightId = ATTR_FONT_HEIGHT; 281 nWeightId = ATTR_FONT_WEIGHT; 282 nPostureId = ATTR_FONT_POSTURE; 283 nLangId = ATTR_FONT_LANGUAGE; 284 } 285 286 if ( pCondSet ) 287 { 288 const SfxPoolItem* pItem; 289 290 if ( pCondSet->GetItemState( nFontId, sal_True, &pItem ) != SFX_ITEM_SET ) 291 pItem = &rItemSet.Get( nFontId ); 292 pFontAttr = (const SvxFontItem*) pItem; 293 294 if ( pCondSet->GetItemState( nHeightId, sal_True, &pItem ) != SFX_ITEM_SET ) 295 pItem = &rItemSet.Get( nHeightId ); 296 nFontHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); 297 298 if ( pCondSet->GetItemState( nWeightId, sal_True, &pItem ) != SFX_ITEM_SET ) 299 pItem = &rItemSet.Get( nWeightId ); 300 eWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); 301 302 if ( pCondSet->GetItemState( nPostureId, sal_True, &pItem ) != SFX_ITEM_SET ) 303 pItem = &rItemSet.Get( nPostureId ); 304 eItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); 305 306 if ( pCondSet->GetItemState( ATTR_FONT_UNDERLINE, sal_True, &pItem ) != SFX_ITEM_SET ) 307 pItem = &rItemSet.Get( ATTR_FONT_UNDERLINE ); 308 eUnder = (FontUnderline)((const SvxUnderlineItem*)pItem)->GetValue(); 309 310 if ( pCondSet->GetItemState( ATTR_FONT_OVERLINE, sal_True, &pItem ) != SFX_ITEM_SET ) 311 pItem = &rItemSet.Get( ATTR_FONT_OVERLINE ); 312 eOver = (FontUnderline)((const SvxOverlineItem*)pItem)->GetValue(); 313 314 if ( pCondSet->GetItemState( ATTR_FONT_WORDLINE, sal_True, &pItem ) != SFX_ITEM_SET ) 315 pItem = &rItemSet.Get( ATTR_FONT_WORDLINE ); 316 bWordLine = ((const SvxWordLineModeItem*)pItem)->GetValue(); 317 318 if ( pCondSet->GetItemState( ATTR_FONT_CROSSEDOUT, sal_True, &pItem ) != SFX_ITEM_SET ) 319 pItem = &rItemSet.Get( ATTR_FONT_CROSSEDOUT ); 320 eStrike = (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(); 321 322 if ( pCondSet->GetItemState( ATTR_FONT_CONTOUR, sal_True, &pItem ) != SFX_ITEM_SET ) 323 pItem = &rItemSet.Get( ATTR_FONT_CONTOUR ); 324 bOutline = ((const SvxContourItem*)pItem)->GetValue(); 325 326 if ( pCondSet->GetItemState( ATTR_FONT_SHADOWED, sal_True, &pItem ) != SFX_ITEM_SET ) 327 pItem = &rItemSet.Get( ATTR_FONT_SHADOWED ); 328 bShadow = ((const SvxShadowedItem*)pItem)->GetValue(); 329 330 if ( pCondSet->GetItemState( ATTR_FONT_EMPHASISMARK, sal_True, &pItem ) != SFX_ITEM_SET ) 331 pItem = &rItemSet.Get( ATTR_FONT_EMPHASISMARK ); 332 eEmphasis = ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(); 333 334 if ( pCondSet->GetItemState( ATTR_FONT_RELIEF, sal_True, &pItem ) != SFX_ITEM_SET ) 335 pItem = &rItemSet.Get( ATTR_FONT_RELIEF ); 336 eRelief = (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(); 337 338 if ( pCondSet->GetItemState( ATTR_FONT_COLOR, sal_True, &pItem ) != SFX_ITEM_SET ) 339 pItem = &rItemSet.Get( ATTR_FONT_COLOR ); 340 aColor = ((const SvxColorItem*)pItem)->GetValue(); 341 342 if ( pCondSet->GetItemState( nLangId, sal_True, &pItem ) != SFX_ITEM_SET ) 343 pItem = &rItemSet.Get( nLangId ); 344 eLang = ((const SvxLanguageItem*)pItem)->GetLanguage(); 345 } 346 else // alles aus rItemSet 347 { 348 pFontAttr = &(const SvxFontItem&)rItemSet.Get( nFontId ); 349 nFontHeight = ((const SvxFontHeightItem&) 350 rItemSet.Get( nHeightId )).GetHeight(); 351 eWeight = (FontWeight)((const SvxWeightItem&) 352 rItemSet.Get( nWeightId )).GetValue(); 353 eItalic = (FontItalic)((const SvxPostureItem&) 354 rItemSet.Get( nPostureId )).GetValue(); 355 eUnder = (FontUnderline)((const SvxUnderlineItem&) 356 rItemSet.Get( ATTR_FONT_UNDERLINE )).GetValue(); 357 eOver = (FontUnderline)((const SvxOverlineItem&) 358 rItemSet.Get( ATTR_FONT_OVERLINE )).GetValue(); 359 bWordLine = ((const SvxWordLineModeItem&) 360 rItemSet.Get( ATTR_FONT_WORDLINE )).GetValue(); 361 eStrike = (FontStrikeout)((const SvxCrossedOutItem&) 362 rItemSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue(); 363 bOutline = ((const SvxContourItem&) 364 rItemSet.Get( ATTR_FONT_CONTOUR )).GetValue(); 365 bShadow = ((const SvxShadowedItem&) 366 rItemSet.Get( ATTR_FONT_SHADOWED )).GetValue(); 367 eEmphasis = ((const SvxEmphasisMarkItem&) 368 rItemSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark(); 369 eRelief = (FontRelief)((const SvxCharReliefItem&) 370 rItemSet.Get( ATTR_FONT_RELIEF )).GetValue(); 371 aColor = ((const SvxColorItem&) 372 rItemSet.Get( ATTR_FONT_COLOR )).GetValue(); 373 // for graphite language features 374 eLang = 375 ((const SvxLanguageItem&)rItemSet.Get( nLangId )).GetLanguage(); 376 } 377 DBG_ASSERT(pFontAttr,"nanu?"); 378 379 // auswerten 380 381 // FontItem: 382 383 if (rFont.GetName() != pFontAttr->GetFamilyName()) 384 rFont.SetName( pFontAttr->GetFamilyName() ); 385 if (rFont.GetStyleName() != pFontAttr->GetStyleName()) 386 rFont.SetStyleName( pFontAttr->GetStyleName() ); 387 388 rFont.SetFamily( pFontAttr->GetFamily() ); 389 rFont.SetCharSet( pFontAttr->GetCharSet() ); 390 rFont.SetPitch( pFontAttr->GetPitch() ); 391 392 rFont.SetLanguage(eLang); 393 394 // Groesse 395 396 if ( pOutDev != NULL ) 397 { 398 Size aEffSize; 399 Fraction aFraction( 1,1 ); 400 if (pScale) 401 aFraction = *pScale; 402 Size aSize( 0, (long) nFontHeight ); 403 MapMode aDestMode = pOutDev->GetMapMode(); 404 MapMode aSrcMode( MAP_TWIP, Point(), aFraction, aFraction ); 405 if (aDestMode.GetMapUnit() == MAP_PIXEL) 406 aEffSize = pOutDev->LogicToPixel( aSize, aSrcMode ); 407 else 408 { 409 Fraction aFractOne(1,1); 410 aDestMode.SetScaleX( aFractOne ); 411 aDestMode.SetScaleY( aFractOne ); 412 aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode ); 413 } 414 rFont.SetSize( aEffSize ); 415 } 416 else /* if pOutDev != NULL */ 417 { 418 rFont.SetSize( Size( 0, (long) nFontHeight ) ); 419 } 420 421 // determine effective font color 422 423 if ( ( aColor.GetColor() == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW ) || 424 eAutoMode == SC_AUTOCOL_IGNOREFONT || eAutoMode == SC_AUTOCOL_IGNOREALL ) 425 { 426 if ( eAutoMode == SC_AUTOCOL_BLACK ) 427 aColor.SetColor( COL_BLACK ); 428 else 429 { 430 // get background color from conditional or own set 431 Color aBackColor; 432 if ( pCondSet ) 433 { 434 const SfxPoolItem* pItem; 435 if ( pCondSet->GetItemState( ATTR_BACKGROUND, sal_True, &pItem ) != SFX_ITEM_SET ) 436 pItem = &rItemSet.Get( ATTR_BACKGROUND ); 437 aBackColor = ((const SvxBrushItem*)pItem)->GetColor(); 438 } 439 else 440 aBackColor = ((const SvxBrushItem&)rItemSet.Get( ATTR_BACKGROUND )).GetColor(); 441 442 // if background color attribute is transparent, use window color for brightness comparisons 443 if ( aBackColor == COL_TRANSPARENT || 444 eAutoMode == SC_AUTOCOL_IGNOREBACK || eAutoMode == SC_AUTOCOL_IGNOREALL ) 445 { 446 if ( eAutoMode == SC_AUTOCOL_PRINT ) 447 aBackColor.SetColor( COL_WHITE ); 448 else if ( pBackConfigColor ) 449 { 450 // pBackConfigColor can be used to avoid repeated lookup of the configured color 451 aBackColor = *pBackConfigColor; 452 } 453 else 454 aBackColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor ); 455 } 456 457 // get system text color for comparison 458 Color aSysTextColor; 459 if ( eAutoMode == SC_AUTOCOL_PRINT ) 460 aSysTextColor.SetColor( COL_BLACK ); 461 else if ( pTextConfigColor ) 462 { 463 // pTextConfigColor can be used to avoid repeated lookup of the configured color 464 aSysTextColor = *pTextConfigColor; 465 } 466 else 467 aSysTextColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); 468 469 // select the resulting color 470 if ( aBackColor.IsDark() && aSysTextColor.IsDark() ) 471 { 472 // use white instead of dark on dark 473 aColor.SetColor( COL_WHITE ); 474 } 475 else if ( aBackColor.IsBright() && aSysTextColor.IsBright() ) 476 { 477 // use black instead of bright on bright 478 aColor.SetColor( COL_BLACK ); 479 } 480 else 481 { 482 // use aSysTextColor (black for SC_AUTOCOL_PRINT, from style settings otherwise) 483 aColor = aSysTextColor; 484 } 485 } 486 } 487 488 // set font effects 489 rFont.SetWeight( eWeight ); 490 rFont.SetItalic( eItalic ); 491 rFont.SetUnderline( eUnder ); 492 rFont.SetOverline( eOver ); 493 rFont.SetWordLineMode( bWordLine ); 494 rFont.SetStrikeout( eStrike ); 495 rFont.SetOutline( bOutline ); 496 rFont.SetShadow( bShadow ); 497 rFont.SetEmphasisMark( eEmphasis ); 498 rFont.SetRelief( eRelief ); 499 rFont.SetColor( aColor ); 500 rFont.SetTransparent( sal_True ); 501 } 502 503 void ScPatternAttr::GetFont( 504 Font& rFont, ScAutoFontColorMode eAutoMode, 505 OutputDevice* pOutDev, const Fraction* pScale, 506 const SfxItemSet* pCondSet, sal_uInt8 nScript, 507 const Color* pBackConfigColor, const Color* pTextConfigColor ) const 508 { 509 GetFont( rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor ); 510 } 511 512 513 void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet ) 514 { 515 // Items auslesen 516 517 SvxColorItem aColorItem(EE_CHAR_COLOR); // use item as-is 518 SvxFontItem aFontItem(EE_CHAR_FONTINFO); // use item as-is 519 SvxFontItem aCjkFontItem(EE_CHAR_FONTINFO_CJK); 520 SvxFontItem aCtlFontItem(EE_CHAR_FONTINFO_CTL); 521 long nTHeight, nCjkTHeight, nCtlTHeight; // Twips 522 FontWeight eWeight, eCjkWeight, eCtlWeight; 523 SvxUnderlineItem aUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE); 524 SvxOverlineItem aOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE); 525 sal_Bool bWordLine; 526 FontStrikeout eStrike; 527 FontItalic eItalic, eCjkItalic, eCtlItalic; 528 sal_Bool bOutline; 529 sal_Bool bShadow; 530 sal_Bool bForbidden; 531 FontEmphasisMark eEmphasis; 532 FontRelief eRelief; 533 LanguageType eLang, eCjkLang, eCtlLang; 534 sal_Bool bHyphenate; 535 SvxFrameDirection eDirection; 536 537 //! additional parameter to control if language is needed? 538 539 if ( pCondSet ) 540 { 541 const SfxPoolItem* pItem; 542 543 if ( pCondSet->GetItemState( ATTR_FONT_COLOR, sal_True, &pItem ) != SFX_ITEM_SET ) 544 pItem = &rSrcSet.Get( ATTR_FONT_COLOR ); 545 aColorItem = *(const SvxColorItem*)pItem; 546 547 if ( pCondSet->GetItemState( ATTR_FONT, sal_True, &pItem ) != SFX_ITEM_SET ) 548 pItem = &rSrcSet.Get( ATTR_FONT ); 549 aFontItem = *(const SvxFontItem*)pItem; 550 if ( pCondSet->GetItemState( ATTR_CJK_FONT, sal_True, &pItem ) != SFX_ITEM_SET ) 551 pItem = &rSrcSet.Get( ATTR_CJK_FONT ); 552 aCjkFontItem = *(const SvxFontItem*)pItem; 553 if ( pCondSet->GetItemState( ATTR_CTL_FONT, sal_True, &pItem ) != SFX_ITEM_SET ) 554 pItem = &rSrcSet.Get( ATTR_CTL_FONT ); 555 aCtlFontItem = *(const SvxFontItem*)pItem; 556 557 if ( pCondSet->GetItemState( ATTR_FONT_HEIGHT, sal_True, &pItem ) != SFX_ITEM_SET ) 558 pItem = &rSrcSet.Get( ATTR_FONT_HEIGHT ); 559 nTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); 560 if ( pCondSet->GetItemState( ATTR_CJK_FONT_HEIGHT, sal_True, &pItem ) != SFX_ITEM_SET ) 561 pItem = &rSrcSet.Get( ATTR_CJK_FONT_HEIGHT ); 562 nCjkTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); 563 if ( pCondSet->GetItemState( ATTR_CTL_FONT_HEIGHT, sal_True, &pItem ) != SFX_ITEM_SET ) 564 pItem = &rSrcSet.Get( ATTR_CTL_FONT_HEIGHT ); 565 nCtlTHeight = ((const SvxFontHeightItem*)pItem)->GetHeight(); 566 567 if ( pCondSet->GetItemState( ATTR_FONT_WEIGHT, sal_True, &pItem ) != SFX_ITEM_SET ) 568 pItem = &rSrcSet.Get( ATTR_FONT_WEIGHT ); 569 eWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); 570 if ( pCondSet->GetItemState( ATTR_CJK_FONT_WEIGHT, sal_True, &pItem ) != SFX_ITEM_SET ) 571 pItem = &rSrcSet.Get( ATTR_CJK_FONT_WEIGHT ); 572 eCjkWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); 573 if ( pCondSet->GetItemState( ATTR_CTL_FONT_WEIGHT, sal_True, &pItem ) != SFX_ITEM_SET ) 574 pItem = &rSrcSet.Get( ATTR_CTL_FONT_WEIGHT ); 575 eCtlWeight = (FontWeight)((const SvxWeightItem*)pItem)->GetValue(); 576 577 if ( pCondSet->GetItemState( ATTR_FONT_POSTURE, sal_True, &pItem ) != SFX_ITEM_SET ) 578 pItem = &rSrcSet.Get( ATTR_FONT_POSTURE ); 579 eItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); 580 if ( pCondSet->GetItemState( ATTR_CJK_FONT_POSTURE, sal_True, &pItem ) != SFX_ITEM_SET ) 581 pItem = &rSrcSet.Get( ATTR_CJK_FONT_POSTURE ); 582 eCjkItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); 583 if ( pCondSet->GetItemState( ATTR_CTL_FONT_POSTURE, sal_True, &pItem ) != SFX_ITEM_SET ) 584 pItem = &rSrcSet.Get( ATTR_CTL_FONT_POSTURE ); 585 eCtlItalic = (FontItalic)((const SvxPostureItem*)pItem)->GetValue(); 586 587 if ( pCondSet->GetItemState( ATTR_FONT_UNDERLINE, sal_True, &pItem ) != SFX_ITEM_SET ) 588 pItem = &rSrcSet.Get( ATTR_FONT_UNDERLINE ); 589 aUnderlineItem = *(const SvxUnderlineItem*)pItem; 590 591 if ( pCondSet->GetItemState( ATTR_FONT_OVERLINE, sal_True, &pItem ) != SFX_ITEM_SET ) 592 pItem = &rSrcSet.Get( ATTR_FONT_OVERLINE ); 593 aOverlineItem = *(const SvxOverlineItem*)pItem; 594 595 if ( pCondSet->GetItemState( ATTR_FONT_WORDLINE, sal_True, &pItem ) != SFX_ITEM_SET ) 596 pItem = &rSrcSet.Get( ATTR_FONT_WORDLINE ); 597 bWordLine = ((const SvxWordLineModeItem*)pItem)->GetValue(); 598 599 if ( pCondSet->GetItemState( ATTR_FONT_CROSSEDOUT, sal_True, &pItem ) != SFX_ITEM_SET ) 600 pItem = &rSrcSet.Get( ATTR_FONT_CROSSEDOUT ); 601 eStrike = (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(); 602 603 if ( pCondSet->GetItemState( ATTR_FONT_CONTOUR, sal_True, &pItem ) != SFX_ITEM_SET ) 604 pItem = &rSrcSet.Get( ATTR_FONT_CONTOUR ); 605 bOutline = ((const SvxContourItem*)pItem)->GetValue(); 606 607 if ( pCondSet->GetItemState( ATTR_FONT_SHADOWED, sal_True, &pItem ) != SFX_ITEM_SET ) 608 pItem = &rSrcSet.Get( ATTR_FONT_SHADOWED ); 609 bShadow = ((const SvxShadowedItem*)pItem)->GetValue(); 610 611 if ( pCondSet->GetItemState( ATTR_FORBIDDEN_RULES, sal_True, &pItem ) != SFX_ITEM_SET ) 612 pItem = &rSrcSet.Get( ATTR_FORBIDDEN_RULES ); 613 bForbidden = ((const SvxForbiddenRuleItem*)pItem)->GetValue(); 614 615 if ( pCondSet->GetItemState( ATTR_FONT_EMPHASISMARK, sal_True, &pItem ) != SFX_ITEM_SET ) 616 pItem = &rSrcSet.Get( ATTR_FONT_EMPHASISMARK ); 617 eEmphasis = ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(); 618 if ( pCondSet->GetItemState( ATTR_FONT_RELIEF, sal_True, &pItem ) != SFX_ITEM_SET ) 619 pItem = &rSrcSet.Get( ATTR_FONT_RELIEF ); 620 eRelief = (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(); 621 622 if ( pCondSet->GetItemState( ATTR_FONT_LANGUAGE, sal_True, &pItem ) != SFX_ITEM_SET ) 623 pItem = &rSrcSet.Get( ATTR_FONT_LANGUAGE ); 624 eLang = ((const SvxLanguageItem*)pItem)->GetLanguage(); 625 if ( pCondSet->GetItemState( ATTR_CJK_FONT_LANGUAGE, sal_True, &pItem ) != SFX_ITEM_SET ) 626 pItem = &rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE ); 627 eCjkLang = ((const SvxLanguageItem*)pItem)->GetLanguage(); 628 if ( pCondSet->GetItemState( ATTR_CTL_FONT_LANGUAGE, sal_True, &pItem ) != SFX_ITEM_SET ) 629 pItem = &rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE ); 630 eCtlLang = ((const SvxLanguageItem*)pItem)->GetLanguage(); 631 632 if ( pCondSet->GetItemState( ATTR_HYPHENATE, sal_True, &pItem ) != SFX_ITEM_SET ) 633 pItem = &rSrcSet.Get( ATTR_HYPHENATE ); 634 bHyphenate = ((const SfxBoolItem*)pItem)->GetValue(); 635 636 if ( pCondSet->GetItemState( ATTR_WRITINGDIR, sal_True, &pItem ) != SFX_ITEM_SET ) 637 pItem = &rSrcSet.Get( ATTR_WRITINGDIR ); 638 eDirection = (SvxFrameDirection)((const SvxFrameDirectionItem*)pItem)->GetValue(); 639 } 640 else // alles direkt aus Pattern 641 { 642 aColorItem = (const SvxColorItem&) rSrcSet.Get( ATTR_FONT_COLOR ); 643 aFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_FONT ); 644 aCjkFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CJK_FONT ); 645 aCtlFontItem = (const SvxFontItem&) rSrcSet.Get( ATTR_CTL_FONT ); 646 nTHeight = ((const SvxFontHeightItem&) 647 rSrcSet.Get( ATTR_FONT_HEIGHT )).GetHeight(); 648 nCjkTHeight = ((const SvxFontHeightItem&) 649 rSrcSet.Get( ATTR_CJK_FONT_HEIGHT )).GetHeight(); 650 nCtlTHeight = ((const SvxFontHeightItem&) 651 rSrcSet.Get( ATTR_CTL_FONT_HEIGHT )).GetHeight(); 652 eWeight = (FontWeight)((const SvxWeightItem&) 653 rSrcSet.Get( ATTR_FONT_WEIGHT )).GetValue(); 654 eCjkWeight = (FontWeight)((const SvxWeightItem&) 655 rSrcSet.Get( ATTR_CJK_FONT_WEIGHT )).GetValue(); 656 eCtlWeight = (FontWeight)((const SvxWeightItem&) 657 rSrcSet.Get( ATTR_CTL_FONT_WEIGHT )).GetValue(); 658 eItalic = (FontItalic)((const SvxPostureItem&) 659 rSrcSet.Get( ATTR_FONT_POSTURE )).GetValue(); 660 eCjkItalic = (FontItalic)((const SvxPostureItem&) 661 rSrcSet.Get( ATTR_CJK_FONT_POSTURE )).GetValue(); 662 eCtlItalic = (FontItalic)((const SvxPostureItem&) 663 rSrcSet.Get( ATTR_CTL_FONT_POSTURE )).GetValue(); 664 aUnderlineItem = (const SvxUnderlineItem&) rSrcSet.Get( ATTR_FONT_UNDERLINE ); 665 aOverlineItem = (const SvxOverlineItem&) rSrcSet.Get( ATTR_FONT_OVERLINE ); 666 bWordLine = ((const SvxWordLineModeItem&) 667 rSrcSet.Get( ATTR_FONT_WORDLINE )).GetValue(); 668 eStrike = (FontStrikeout)((const SvxCrossedOutItem&) 669 rSrcSet.Get( ATTR_FONT_CROSSEDOUT )).GetValue(); 670 bOutline = ((const SvxContourItem&) 671 rSrcSet.Get( ATTR_FONT_CONTOUR )).GetValue(); 672 bShadow = ((const SvxShadowedItem&) 673 rSrcSet.Get( ATTR_FONT_SHADOWED )).GetValue(); 674 bForbidden = ((const SvxForbiddenRuleItem&) 675 rSrcSet.Get( ATTR_FORBIDDEN_RULES )).GetValue(); 676 eEmphasis = ((const SvxEmphasisMarkItem&) 677 rSrcSet.Get( ATTR_FONT_EMPHASISMARK )).GetEmphasisMark(); 678 eRelief = (FontRelief)((const SvxCharReliefItem&) 679 rSrcSet.Get( ATTR_FONT_RELIEF )).GetValue(); 680 eLang = ((const SvxLanguageItem&) 681 rSrcSet.Get( ATTR_FONT_LANGUAGE )).GetLanguage(); 682 eCjkLang = ((const SvxLanguageItem&) 683 rSrcSet.Get( ATTR_CJK_FONT_LANGUAGE )).GetLanguage(); 684 eCtlLang = ((const SvxLanguageItem&) 685 rSrcSet.Get( ATTR_CTL_FONT_LANGUAGE )).GetLanguage(); 686 bHyphenate = ((const SfxBoolItem&) 687 rSrcSet.Get( ATTR_HYPHENATE )).GetValue(); 688 eDirection = (SvxFrameDirection)((const SvxFrameDirectionItem&) 689 rSrcSet.Get( ATTR_WRITINGDIR )).GetValue(); 690 } 691 692 // kompatibel zu LogicToLogic rechnen, also 2540/1440 = 127/72, und runden 693 694 long nHeight = TwipsToHMM(nTHeight); 695 long nCjkHeight = TwipsToHMM(nCjkTHeight); 696 long nCtlHeight = TwipsToHMM(nCtlTHeight); 697 698 // put items into EditEngine ItemSet 699 700 if ( aColorItem.GetValue().GetColor() == COL_AUTO ) 701 { 702 // #108979# When cell attributes are converted to EditEngine paragraph attributes, 703 // don't create a hard item for automatic color, because that would be converted 704 // to black when the item's Store method is used in CreateTransferable/WriteBin. 705 // COL_AUTO is the EditEngine's pool default, so ClearItem will result in automatic 706 // color, too, without having to store the item. 707 rEditSet.ClearItem( EE_CHAR_COLOR ); 708 } 709 else 710 rEditSet.Put( aColorItem ); 711 rEditSet.Put( aFontItem ); 712 rEditSet.Put( aCjkFontItem ); 713 rEditSet.Put( aCtlFontItem ); 714 rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) ); 715 rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) ); 716 rEditSet.Put( SvxFontHeightItem( nCtlHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) ); 717 rEditSet.Put( SvxWeightItem ( eWeight, EE_CHAR_WEIGHT ) ); 718 rEditSet.Put( SvxWeightItem ( eCjkWeight, EE_CHAR_WEIGHT_CJK ) ); 719 rEditSet.Put( SvxWeightItem ( eCtlWeight, EE_CHAR_WEIGHT_CTL ) ); 720 rEditSet.Put( aUnderlineItem ); 721 rEditSet.Put( aOverlineItem ); 722 rEditSet.Put( SvxWordLineModeItem( bWordLine, EE_CHAR_WLM ) ); 723 rEditSet.Put( SvxCrossedOutItem( eStrike, EE_CHAR_STRIKEOUT ) ); 724 rEditSet.Put( SvxPostureItem ( eItalic, EE_CHAR_ITALIC ) ); 725 rEditSet.Put( SvxPostureItem ( eCjkItalic, EE_CHAR_ITALIC_CJK ) ); 726 rEditSet.Put( SvxPostureItem ( eCtlItalic, EE_CHAR_ITALIC_CTL ) ); 727 rEditSet.Put( SvxContourItem ( bOutline, EE_CHAR_OUTLINE ) ); 728 rEditSet.Put( SvxShadowedItem ( bShadow, EE_CHAR_SHADOW ) ); 729 rEditSet.Put( SfxBoolItem ( EE_PARA_FORBIDDENRULES, bForbidden ) ); 730 rEditSet.Put( SvxEmphasisMarkItem( eEmphasis, EE_CHAR_EMPHASISMARK ) ); 731 rEditSet.Put( SvxCharReliefItem( eRelief, EE_CHAR_RELIEF ) ); 732 rEditSet.Put( SvxLanguageItem ( eLang, EE_CHAR_LANGUAGE ) ); 733 rEditSet.Put( SvxLanguageItem ( eCjkLang, EE_CHAR_LANGUAGE_CJK ) ); 734 rEditSet.Put( SvxLanguageItem ( eCtlLang, EE_CHAR_LANGUAGE_CTL ) ); 735 rEditSet.Put( SfxBoolItem ( EE_PARA_HYPHENATE, bHyphenate ) ); 736 rEditSet.Put( SvxFrameDirectionItem( eDirection, EE_PARA_WRITINGDIR ) ); 737 738 // #111216# Script spacing is always off. 739 // The cell attribute isn't used here as long as there is no UI to set it 740 // (don't evaluate attributes that can't be changed). 741 // If a locale-dependent default is needed, it has to go into the cell 742 // style, like the fonts. 743 rEditSet.Put( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) ); 744 } 745 746 void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet ) const 747 { 748 if( pEditSet ) 749 FillToEditItemSet( *pEditSet, GetItemSet(), pCondSet ); 750 } 751 752 753 void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet ) 754 { 755 const SfxPoolItem* pItem; 756 757 if (rEditSet.GetItemState(EE_CHAR_COLOR,sal_True,&pItem) == SFX_ITEM_SET) 758 rDestSet.Put( SvxColorItem(ATTR_FONT_COLOR) = *(const SvxColorItem*)pItem ); 759 760 if (rEditSet.GetItemState(EE_CHAR_FONTINFO,sal_True,&pItem) == SFX_ITEM_SET) 761 rDestSet.Put( SvxFontItem(ATTR_FONT) = *(const SvxFontItem*)pItem ); 762 if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CJK,sal_True,&pItem) == SFX_ITEM_SET) 763 rDestSet.Put( SvxFontItem(ATTR_CJK_FONT) = *(const SvxFontItem*)pItem ); 764 if (rEditSet.GetItemState(EE_CHAR_FONTINFO_CTL,sal_True,&pItem) == SFX_ITEM_SET) 765 rDestSet.Put( SvxFontItem(ATTR_CTL_FONT) = *(const SvxFontItem*)pItem ); 766 767 if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT,sal_True,&pItem) == SFX_ITEM_SET) 768 rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ), 769 100, ATTR_FONT_HEIGHT ) ); 770 if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CJK,sal_True,&pItem) == SFX_ITEM_SET) 771 rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ), 772 100, ATTR_CJK_FONT_HEIGHT ) ); 773 if (rEditSet.GetItemState(EE_CHAR_FONTHEIGHT_CTL,sal_True,&pItem) == SFX_ITEM_SET) 774 rDestSet.Put( SvxFontHeightItem( HMMToTwips( ((const SvxFontHeightItem*)pItem)->GetHeight() ), 775 100, ATTR_CTL_FONT_HEIGHT ) ); 776 777 if (rEditSet.GetItemState(EE_CHAR_WEIGHT,sal_True,&pItem) == SFX_ITEM_SET) 778 rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(), 779 ATTR_FONT_WEIGHT) ); 780 if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CJK,sal_True,&pItem) == SFX_ITEM_SET) 781 rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(), 782 ATTR_CJK_FONT_WEIGHT) ); 783 if (rEditSet.GetItemState(EE_CHAR_WEIGHT_CTL,sal_True,&pItem) == SFX_ITEM_SET) 784 rDestSet.Put( SvxWeightItem( (FontWeight)((const SvxWeightItem*)pItem)->GetValue(), 785 ATTR_CTL_FONT_WEIGHT) ); 786 787 // SvxTextLineItem contains enum and color 788 if (rEditSet.GetItemState(EE_CHAR_UNDERLINE,sal_True,&pItem) == SFX_ITEM_SET) 789 rDestSet.Put( SvxUnderlineItem(UNDERLINE_NONE,ATTR_FONT_UNDERLINE) = *(const SvxUnderlineItem*)pItem ); 790 if (rEditSet.GetItemState(EE_CHAR_OVERLINE,sal_True,&pItem) == SFX_ITEM_SET) 791 rDestSet.Put( SvxOverlineItem(UNDERLINE_NONE,ATTR_FONT_OVERLINE) = *(const SvxOverlineItem*)pItem ); 792 if (rEditSet.GetItemState(EE_CHAR_WLM,sal_True,&pItem) == SFX_ITEM_SET) 793 rDestSet.Put( SvxWordLineModeItem( ((const SvxWordLineModeItem*)pItem)->GetValue(), 794 ATTR_FONT_WORDLINE) ); 795 796 if (rEditSet.GetItemState(EE_CHAR_STRIKEOUT,sal_True,&pItem) == SFX_ITEM_SET) 797 rDestSet.Put( SvxCrossedOutItem( (FontStrikeout)((const SvxCrossedOutItem*)pItem)->GetValue(), 798 ATTR_FONT_CROSSEDOUT) ); 799 800 if (rEditSet.GetItemState(EE_CHAR_ITALIC,sal_True,&pItem) == SFX_ITEM_SET) 801 rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(), 802 ATTR_FONT_POSTURE) ); 803 if (rEditSet.GetItemState(EE_CHAR_ITALIC_CJK,sal_True,&pItem) == SFX_ITEM_SET) 804 rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(), 805 ATTR_CJK_FONT_POSTURE) ); 806 if (rEditSet.GetItemState(EE_CHAR_ITALIC_CTL,sal_True,&pItem) == SFX_ITEM_SET) 807 rDestSet.Put( SvxPostureItem( (FontItalic)((const SvxPostureItem*)pItem)->GetValue(), 808 ATTR_CTL_FONT_POSTURE) ); 809 810 if (rEditSet.GetItemState(EE_CHAR_OUTLINE,sal_True,&pItem) == SFX_ITEM_SET) 811 rDestSet.Put( SvxContourItem( ((const SvxContourItem*)pItem)->GetValue(), 812 ATTR_FONT_CONTOUR) ); 813 if (rEditSet.GetItemState(EE_CHAR_SHADOW,sal_True,&pItem) == SFX_ITEM_SET) 814 rDestSet.Put( SvxShadowedItem( ((const SvxShadowedItem*)pItem)->GetValue(), 815 ATTR_FONT_SHADOWED) ); 816 if (rEditSet.GetItemState(EE_CHAR_EMPHASISMARK,sal_True,&pItem) == SFX_ITEM_SET) 817 rDestSet.Put( SvxEmphasisMarkItem( ((const SvxEmphasisMarkItem*)pItem)->GetEmphasisMark(), 818 ATTR_FONT_EMPHASISMARK) ); 819 if (rEditSet.GetItemState(EE_CHAR_RELIEF,sal_True,&pItem) == SFX_ITEM_SET) 820 rDestSet.Put( SvxCharReliefItem( (FontRelief)((const SvxCharReliefItem*)pItem)->GetValue(), 821 ATTR_FONT_RELIEF) ); 822 823 if (rEditSet.GetItemState(EE_CHAR_LANGUAGE,sal_True,&pItem) == SFX_ITEM_SET) 824 rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_FONT_LANGUAGE) ); 825 if (rEditSet.GetItemState(EE_CHAR_LANGUAGE_CJK,sal_True,&pItem) == SFX_ITEM_SET) 826 rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_CJK_FONT_LANGUAGE) ); 827 if (rEditSet.GetItemState(EE_CHAR_LANGUAGE_CTL,sal_True,&pItem) == SFX_ITEM_SET) 828 rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_CTL_FONT_LANGUAGE) ); 829 830 if (rEditSet.GetItemState(EE_PARA_JUST,sal_True,&pItem) == SFX_ITEM_SET) 831 { 832 SvxCellHorJustify eVal; 833 switch ( ((const SvxAdjustItem*)pItem)->GetAdjust() ) 834 { 835 case SVX_ADJUST_LEFT: 836 // #30154# EditEngine Default ist bei dem GetAttribs() ItemSet 837 // immer gesetzt! 838 // ob links oder rechts entscheiden wir selbst bei Text/Zahl 839 eVal = SVX_HOR_JUSTIFY_STANDARD; 840 break; 841 case SVX_ADJUST_RIGHT: 842 eVal = SVX_HOR_JUSTIFY_RIGHT; 843 break; 844 case SVX_ADJUST_BLOCK: 845 eVal = SVX_HOR_JUSTIFY_BLOCK; 846 break; 847 case SVX_ADJUST_CENTER: 848 eVal = SVX_HOR_JUSTIFY_CENTER; 849 break; 850 case SVX_ADJUST_BLOCKLINE: 851 eVal = SVX_HOR_JUSTIFY_BLOCK; 852 break; 853 case SVX_ADJUST_END: 854 eVal = SVX_HOR_JUSTIFY_RIGHT; 855 break; 856 default: 857 eVal = SVX_HOR_JUSTIFY_STANDARD; 858 } 859 if ( eVal != SVX_HOR_JUSTIFY_STANDARD ) 860 rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) ); 861 } 862 } 863 864 void ScPatternAttr::GetFromEditItemSet( const SfxItemSet* pEditSet ) 865 { 866 if( pEditSet ) 867 GetFromEditItemSet( GetItemSet(), *pEditSet ); 868 } 869 870 void ScPatternAttr::FillEditParaItems( SfxItemSet* pEditSet ) const 871 { 872 // in GetFromEditItemSet schon dabei, in FillEditItemSet aber nicht 873 // Hor. Ausrichtung Standard wird immer als "links" umgesetzt 874 875 const SfxItemSet& rMySet = GetItemSet(); 876 877 SvxCellHorJustify eHorJust = (SvxCellHorJustify) 878 ((const SvxHorJustifyItem&)rMySet.Get(ATTR_HOR_JUSTIFY)).GetValue(); 879 880 SvxAdjust eSvxAdjust; 881 switch (eHorJust) 882 { 883 case SVX_HOR_JUSTIFY_RIGHT: eSvxAdjust = SVX_ADJUST_RIGHT; break; 884 case SVX_HOR_JUSTIFY_CENTER: eSvxAdjust = SVX_ADJUST_CENTER; break; 885 case SVX_HOR_JUSTIFY_BLOCK: eSvxAdjust = SVX_ADJUST_BLOCK; break; 886 default: eSvxAdjust = SVX_ADJUST_LEFT; break; 887 } 888 pEditSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); 889 } 890 891 void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* pOldAttrs ) 892 { 893 SfxItemSet& rThisSet = GetItemSet(); 894 const SfxItemSet& rOldSet = pOldAttrs->GetItemSet(); 895 896 const SfxPoolItem* pThisItem; 897 const SfxPoolItem* pOldItem; 898 899 for ( sal_uInt16 nSubWhich=ATTR_PATTERN_START; nSubWhich<=ATTR_PATTERN_END; nSubWhich++ ) 900 { 901 // only items that are set are interesting 902 if ( rThisSet.GetItemState( nSubWhich, sal_False, &pThisItem ) == SFX_ITEM_SET ) 903 { 904 SfxItemState eOldState = rOldSet.GetItemState( nSubWhich, sal_True, &pOldItem ); 905 if ( eOldState == SFX_ITEM_SET ) 906 { 907 // item is set in OldAttrs (or its parent) -> compare pointers 908 if ( pThisItem == pOldItem ) 909 rThisSet.ClearItem( nSubWhich ); 910 } 911 else if ( eOldState != SFX_ITEM_DONTCARE ) 912 { 913 // not set in OldAttrs -> compare item value to default item 914 if ( *pThisItem == rThisSet.GetPool()->GetDefaultItem( nSubWhich ) ) 915 rThisSet.ClearItem( nSubWhich ); 916 } 917 } 918 } 919 } 920 921 sal_Bool ScPatternAttr::HasItemsSet( const sal_uInt16* pWhich ) const 922 { 923 const SfxItemSet& rSet = GetItemSet(); 924 for (sal_uInt16 i=0; pWhich[i]; i++) 925 if ( rSet.GetItemState( pWhich[i], sal_False ) == SFX_ITEM_SET ) 926 return sal_True; 927 return sal_False; 928 } 929 930 void ScPatternAttr::ClearItems( const sal_uInt16* pWhich ) 931 { 932 SfxItemSet& rSet = GetItemSet(); 933 for (sal_uInt16 i=0; pWhich[i]; i++) 934 rSet.ClearItem(pWhich[i]); 935 } 936 937 SfxStyleSheetBase* lcl_CopyStyleToPool 938 ( 939 SfxStyleSheetBase* pSrcStyle, 940 SfxStyleSheetBasePool* pSrcPool, 941 SfxStyleSheetBasePool* pDestPool, 942 const SvNumberFormatterIndexTable* pFormatExchangeList 943 ) 944 { 945 if ( !pSrcStyle || !pDestPool || !pSrcPool ) 946 { 947 DBG_ERROR( "CopyStyleToPool: Invalid Arguments :-/" ); 948 return NULL; 949 } 950 951 //-------------------------------------------------------- 952 953 const String aStrSrcStyle = pSrcStyle->GetName(); 954 const SfxStyleFamily eFamily = pSrcStyle->GetFamily(); 955 SfxStyleSheetBase* pDestStyle = pDestPool->Find( aStrSrcStyle, eFamily ); 956 957 if ( !pDestStyle ) 958 { 959 const String aStrParent = pSrcStyle->GetParent(); 960 const SfxItemSet& rSrcSet = pSrcStyle->GetItemSet(); 961 962 pDestStyle = &pDestPool->Make( aStrSrcStyle, eFamily, SFXSTYLEBIT_USERDEF ); 963 SfxItemSet& rDestSet = pDestStyle->GetItemSet(); 964 rDestSet.Put( rSrcSet ); 965 966 // #b5017505# number format exchange list has to be handled here, too 967 // (only called for cell styles) 968 969 const SfxPoolItem* pSrcItem; 970 if ( pFormatExchangeList && 971 rSrcSet.GetItemState( ATTR_VALUE_FORMAT, sal_False, &pSrcItem ) == SFX_ITEM_SET ) 972 { 973 sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pSrcItem)->GetValue(); 974 sal_uInt32* pNewFormat = static_cast<sal_uInt32*>(pFormatExchangeList->Get( nOldFormat )); 975 if (pNewFormat) 976 rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, *pNewFormat ) ); 977 } 978 979 // ggF. abgeleitete Styles erzeugen, wenn nicht vorhanden: 980 981 if ( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != aStrParent && 982 aStrSrcStyle != aStrParent && 983 !pDestPool->Find( aStrParent, eFamily ) ) 984 { 985 lcl_CopyStyleToPool( pSrcPool->Find( aStrParent, eFamily ), 986 pSrcPool, pDestPool, pFormatExchangeList ); 987 } 988 989 pDestStyle->SetParent( aStrParent ); 990 } 991 992 return pDestStyle; 993 } 994 995 ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const 996 { 997 const SfxItemSet* pSrcSet = &GetItemSet(); 998 999 ScPatternAttr* pDestPattern = new ScPatternAttr(pDestDoc->GetPool()); 1000 SfxItemSet* pDestSet = &pDestPattern->GetItemSet(); 1001 1002 // Zellformatvorlage in anderes Dokument kopieren: 1003 1004 if ( pDestDoc != pSrcDoc ) 1005 { 1006 DBG_ASSERT( pStyle, "Missing Pattern-Style! :-/" ); 1007 1008 // wenn Vorlage im DestDoc vorhanden, dieses benutzen, sonst Style 1009 // mit Parent-Vorlagen kopieren/ggF. erzeugen und dem DestDoc hinzufuegen 1010 1011 SfxStyleSheetBase* pStyleCpy = lcl_CopyStyleToPool( pStyle, 1012 pSrcDoc->GetStyleSheetPool(), 1013 pDestDoc->GetStyleSheetPool(), 1014 pDestDoc->GetFormatExchangeList() ); 1015 1016 pDestPattern->SetStyleSheet( (ScStyleSheet*)pStyleCpy ); 1017 } 1018 1019 for ( sal_uInt16 nAttrId = ATTR_PATTERN_START; nAttrId <= ATTR_PATTERN_END; nAttrId++ ) 1020 { 1021 const SfxPoolItem* pSrcItem; 1022 SfxItemState eItemState = pSrcSet->GetItemState( nAttrId, sal_False, &pSrcItem ); 1023 if (eItemState==SFX_ITEM_ON) 1024 { 1025 SfxPoolItem* pNewItem = NULL; 1026 1027 if ( nAttrId == ATTR_CONDITIONAL ) 1028 { 1029 // Bedingte Formate ins neue Dokument kopieren 1030 1031 sal_uLong nNewIndex = 0; 1032 ScConditionalFormatList* pSrcList = pSrcDoc->GetCondFormList(); 1033 if ( pSrcList ) 1034 { 1035 sal_uLong nOldIndex = ((const SfxUInt32Item*)pSrcItem)->GetValue(); 1036 const ScConditionalFormat* pOldData = pSrcList->GetFormat( nOldIndex ); 1037 if ( pOldData ) 1038 { 1039 nNewIndex = pDestDoc->AddCondFormat( *pOldData ); 1040 1041 // zugehoerige Styles auch mitkopieren 1042 //! nur wenn Format bei Add neu angelegt 1043 1044 ScStyleSheetPool* pSrcSPool = pSrcDoc->GetStyleSheetPool(); 1045 ScStyleSheetPool* pDestSPool = pDestDoc->GetStyleSheetPool(); 1046 const SvNumberFormatterIndexTable* pFormatExchangeList = pDestDoc->GetFormatExchangeList(); 1047 sal_uInt16 nStlCnt = pOldData->Count(); 1048 for (sal_uInt16 i=0; i<nStlCnt; i++) 1049 { 1050 String aName = pOldData->GetEntry(i)->GetStyle(); 1051 SfxStyleSheetBase* pSrcStl = 1052 pSrcDoc->GetStyleSheetPool()->Find(aName, SFX_STYLE_FAMILY_PARA); 1053 lcl_CopyStyleToPool( pSrcStl, pSrcSPool, pDestSPool, pFormatExchangeList ); 1054 } 1055 } 1056 } 1057 pNewItem = new SfxUInt32Item( ATTR_CONDITIONAL, nNewIndex ); 1058 } 1059 else if ( nAttrId == ATTR_VALIDDATA ) 1060 { 1061 // Gueltigkeit ins neue Dokument kopieren 1062 1063 sal_uLong nNewIndex = 0; 1064 ScValidationDataList* pSrcList = pSrcDoc->GetValidationList(); 1065 if ( pSrcList ) 1066 { 1067 sal_uLong nOldIndex = ((const SfxUInt32Item*)pSrcItem)->GetValue(); 1068 const ScValidationData* pOldData = pSrcList->GetData( nOldIndex ); 1069 if ( pOldData ) 1070 nNewIndex = pDestDoc->AddValidationEntry( *pOldData ); 1071 } 1072 pNewItem = new SfxUInt32Item( ATTR_VALIDDATA, nNewIndex ); 1073 } 1074 else if ( nAttrId == ATTR_VALUE_FORMAT && pDestDoc->GetFormatExchangeList() ) 1075 { 1076 // Zahlformate nach Exchange-Liste 1077 1078 sal_uLong nOldFormat = ((const SfxUInt32Item*)pSrcItem)->GetValue(); 1079 sal_uInt32* pNewFormat = static_cast<sal_uInt32*>(pDestDoc->GetFormatExchangeList()->Get(nOldFormat)); 1080 if (pNewFormat) 1081 pNewItem = new SfxUInt32Item( ATTR_VALUE_FORMAT, (sal_uInt32) (*pNewFormat) ); 1082 } 1083 1084 if ( pNewItem ) 1085 { 1086 pDestSet->Put(*pNewItem); 1087 delete pNewItem; 1088 } 1089 else 1090 pDestSet->Put(*pSrcItem); 1091 } 1092 } 1093 1094 ScPatternAttr* pPatternAttr = 1095 (ScPatternAttr*) &pDestDoc->GetPool()->Put(*pDestPattern); 1096 delete pDestPattern; 1097 return pPatternAttr; 1098 } 1099 1100 sal_Bool ScPatternAttr::IsVisible() const 1101 { 1102 const SfxItemSet& rSet = GetItemSet(); 1103 1104 const SfxPoolItem* pItem; 1105 SfxItemState eState; 1106 1107 eState = rSet.GetItemState( ATTR_BACKGROUND, sal_True, &pItem ); 1108 if ( eState == SFX_ITEM_SET ) 1109 if ( ((const SvxBrushItem*)pItem)->GetColor().GetColor() != COL_TRANSPARENT ) 1110 return sal_True; 1111 1112 eState = rSet.GetItemState( ATTR_BORDER, sal_True, &pItem ); 1113 if ( eState == SFX_ITEM_SET ) 1114 { 1115 const SvxBoxItem* pBoxItem = (SvxBoxItem*) pItem; 1116 if ( pBoxItem->GetTop() || pBoxItem->GetBottom() || 1117 pBoxItem->GetLeft() || pBoxItem->GetRight() ) 1118 return sal_True; 1119 } 1120 1121 eState = rSet.GetItemState( ATTR_BORDER_TLBR, sal_True, &pItem ); 1122 if ( eState == SFX_ITEM_SET ) 1123 if( static_cast< const SvxLineItem* >( pItem )->GetLine() ) 1124 return sal_True; 1125 1126 eState = rSet.GetItemState( ATTR_BORDER_BLTR, sal_True, &pItem ); 1127 if ( eState == SFX_ITEM_SET ) 1128 if( static_cast< const SvxLineItem* >( pItem )->GetLine() ) 1129 return sal_True; 1130 1131 eState = rSet.GetItemState( ATTR_SHADOW, sal_True, &pItem ); 1132 if ( eState == SFX_ITEM_SET ) 1133 if ( ((const SvxShadowItem*)pItem)->GetLocation() != SVX_SHADOW_NONE ) 1134 return sal_True; 1135 1136 return sal_False; 1137 } 1138 1139 inline sal_Bool OneEqual( const SfxItemSet& rSet1, const SfxItemSet& rSet2, sal_uInt16 nId ) 1140 { 1141 const SfxPoolItem* pItem1 = &rSet1.Get(nId); 1142 const SfxPoolItem* pItem2 = &rSet2.Get(nId); 1143 return ( pItem1 == pItem2 || *pItem1 == *pItem2 ); 1144 } 1145 1146 sal_Bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const 1147 { 1148 const SfxItemSet& rThisSet = GetItemSet(); 1149 const SfxItemSet& rOtherSet = rOther.GetItemSet(); 1150 1151 return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) && 1152 OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) && 1153 OneEqual( rThisSet, rOtherSet, ATTR_BORDER_TLBR ) && 1154 OneEqual( rThisSet, rOtherSet, ATTR_BORDER_BLTR ) && 1155 OneEqual( rThisSet, rOtherSet, ATTR_SHADOW ); 1156 1157 //! auch hier nur wirklich sichtbare Werte testen !!! 1158 } 1159 1160 const String* ScPatternAttr::GetStyleName() const 1161 { 1162 return pName ? pName : ( pStyle ? &pStyle->GetName() : NULL ); 1163 } 1164 1165 1166 void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle ) 1167 { 1168 if (pNewStyle) 1169 { 1170 SfxItemSet& rPatternSet = GetItemSet(); 1171 const SfxItemSet& rStyleSet = pNewStyle->GetItemSet(); 1172 1173 for (sal_uInt16 i=ATTR_PATTERN_START; i<=ATTR_PATTERN_END; i++) 1174 { 1175 if (rStyleSet.GetItemState(i, sal_True) == SFX_ITEM_SET) 1176 rPatternSet.ClearItem(i); 1177 } 1178 rPatternSet.SetParent(&pNewStyle->GetItemSet()); 1179 pStyle = pNewStyle; 1180 DELETEZ( pName ); 1181 } 1182 else 1183 { 1184 DBG_ERROR( "ScPatternAttr::SetStyleSheet( NULL ) :-|" ); 1185 GetItemSet().SetParent(NULL); 1186 pStyle = NULL; 1187 } 1188 } 1189 1190 void ScPatternAttr::UpdateStyleSheet() 1191 { 1192 if (pName) 1193 { 1194 pStyle = (ScStyleSheet*)pDoc->GetStyleSheetPool()->Find(*pName, SFX_STYLE_FAMILY_PARA); 1195 1196 // wenn Style nicht gefunden, Standard nehmen, 1197 // damit keine leere Anzeige im Toolbox-Controller 1198 //! es wird vorausgesetzt, dass "Standard" immer der erste Eintrag ist! 1199 if (!pStyle) 1200 { 1201 SfxStyleSheetIterator* pIter = pDoc->GetStyleSheetPool()->CreateIterator( 1202 SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL ); 1203 pStyle = (ScStyleSheet*)pIter->First(); 1204 } 1205 1206 if (pStyle) 1207 { 1208 GetItemSet().SetParent(&pStyle->GetItemSet()); 1209 DELETEZ( pName ); 1210 } 1211 } 1212 else 1213 pStyle = NULL; 1214 } 1215 1216 void ScPatternAttr::StyleToName() 1217 { 1218 // Style wurde geloescht, Namen merken: 1219 1220 if ( pStyle ) 1221 { 1222 if ( pName ) 1223 *pName = pStyle->GetName(); 1224 else 1225 pName = new String( pStyle->GetName() ); 1226 1227 pStyle = NULL; 1228 GetItemSet().SetParent( NULL ); 1229 } 1230 } 1231 1232 sal_Bool ScPatternAttr::IsSymbolFont() const 1233 { 1234 const SfxPoolItem* pItem; 1235 if( GetItemSet().GetItemState( ATTR_FONT, sal_True, &pItem ) == SFX_ITEM_SET ) 1236 return sal_Bool( ((const SvxFontItem*) pItem)->GetCharSet() 1237 == RTL_TEXTENCODING_SYMBOL ); 1238 else 1239 return sal_False; 1240 } 1241 1242 //UNUSED2008-05 FontToSubsFontConverter ScPatternAttr::GetSubsFontConverter( sal_uLong nFlags ) const 1243 //UNUSED2008-05 { 1244 //UNUSED2008-05 const SfxPoolItem* pItem; 1245 //UNUSED2008-05 if( GetItemSet().GetItemState( ATTR_FONT, sal_True, &pItem ) == SFX_ITEM_SET ) 1246 //UNUSED2008-05 return CreateFontToSubsFontConverter( 1247 //UNUSED2008-05 ((const SvxFontItem*) pItem)->GetFamilyName(), nFlags ); 1248 //UNUSED2008-05 else 1249 //UNUSED2008-05 return 0; 1250 //UNUSED2008-05 } 1251 1252 1253 sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter ) const 1254 { 1255 sal_uLong nFormat = 1256 ((SfxUInt32Item*)&GetItemSet().Get( ATTR_VALUE_FORMAT ))->GetValue(); 1257 LanguageType eLang = 1258 ((SvxLanguageItem*)&GetItemSet().Get( ATTR_LANGUAGE_FORMAT ))->GetLanguage(); 1259 if ( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && eLang == LANGUAGE_SYSTEM ) 1260 ; // es bleibt wie es ist 1261 else if ( pFormatter ) 1262 nFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nFormat, eLang ); 1263 return nFormat; 1264 } 1265 1266 // dasselbe, wenn bedingte Formatierung im Spiel ist: 1267 1268 sal_uLong ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter, 1269 const SfxItemSet* pCondSet ) const 1270 { 1271 DBG_ASSERT(pFormatter,"GetNumberFormat ohne Formatter"); 1272 1273 const SfxPoolItem* pFormItem; 1274 if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,sal_True,&pFormItem) != SFX_ITEM_SET ) 1275 pFormItem = &GetItemSet().Get(ATTR_VALUE_FORMAT); 1276 1277 const SfxPoolItem* pLangItem; 1278 if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,sal_True,&pLangItem) != SFX_ITEM_SET ) 1279 pLangItem = &GetItemSet().Get(ATTR_LANGUAGE_FORMAT); 1280 1281 return pFormatter->GetFormatForLanguageIfBuiltIn( 1282 ((SfxUInt32Item*)pFormItem)->GetValue(), 1283 ((SvxLanguageItem*)pLangItem)->GetLanguage() ); 1284 } 1285 1286 const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ) 1287 { 1288 const SfxPoolItem* pCondItem; 1289 if ( pCondSet && pCondSet->GetItemState( nWhich, sal_True, &pCondItem ) == SFX_ITEM_SET ) 1290 return *pCondItem; 1291 return rItemSet.Get(nWhich); 1292 } 1293 1294 const SfxPoolItem& ScPatternAttr::GetItem( sal_uInt16 nSubWhich, const SfxItemSet* pCondSet ) const 1295 { 1296 return GetItem( nSubWhich, GetItemSet(), pCondSet ); 1297 } 1298 1299 // GetRotateVal testet vorher ATTR_ORIENTATION 1300 1301 long ScPatternAttr::GetRotateVal( const SfxItemSet* pCondSet ) const 1302 { 1303 long nAttrRotate = 0; 1304 if ( GetCellOrientation() == SVX_ORIENTATION_STANDARD ) 1305 { 1306 sal_Bool bRepeat = ( static_cast<const SvxHorJustifyItem&>(GetItem(ATTR_HOR_JUSTIFY, pCondSet)). 1307 GetValue() == SVX_HOR_JUSTIFY_REPEAT ); 1308 // ignore orientation/rotation if "repeat" is active 1309 if ( !bRepeat ) 1310 nAttrRotate = ((const SfxInt32Item&)GetItem( ATTR_ROTATE_VALUE, pCondSet )).GetValue(); 1311 } 1312 return nAttrRotate; 1313 } 1314 1315 sal_uInt8 ScPatternAttr::GetRotateDir( const SfxItemSet* pCondSet ) const 1316 { 1317 sal_uInt8 nRet = SC_ROTDIR_NONE; 1318 1319 long nAttrRotate = GetRotateVal( pCondSet ); 1320 if ( nAttrRotate ) 1321 { 1322 SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&) 1323 GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue(); 1324 1325 if ( eRotMode == SVX_ROTATE_MODE_STANDARD || nAttrRotate == 18000 ) 1326 nRet = SC_ROTDIR_STANDARD; 1327 else if ( eRotMode == SVX_ROTATE_MODE_CENTER ) 1328 nRet = SC_ROTDIR_CENTER; 1329 else if ( eRotMode == SVX_ROTATE_MODE_TOP || eRotMode == SVX_ROTATE_MODE_BOTTOM ) 1330 { 1331 long nRot180 = nAttrRotate % 18000; // 1/100 Grad 1332 if ( nRot180 == 9000 ) 1333 nRet = SC_ROTDIR_CENTER; 1334 else if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nRot180 < 9000 ) || 1335 ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nRot180 > 9000 ) ) 1336 nRet = SC_ROTDIR_LEFT; 1337 else 1338 nRet = SC_ROTDIR_RIGHT; 1339 } 1340 } 1341 1342 return nRet; 1343 } 1344 1345 1346 1347 1348