LCOV - code coverage report
Current view: top level - sc/source/core/data - patattr.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 557 674 82.6 %
Date: 2014-04-11 Functions: 35 40 87.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10