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