138d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 338d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 438d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 538d50f7bSAndrew Rist * distributed with this work for additional information 638d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 738d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 838d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 938d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 1038d50f7bSAndrew Rist * 1138d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1238d50f7bSAndrew Rist * 1338d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 1438d50f7bSAndrew Rist * software distributed under the License is distributed on an 1538d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1638d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 1738d50f7bSAndrew Rist * specific language governing permissions and limitations 1838d50f7bSAndrew Rist * under the License. 1938d50f7bSAndrew Rist * 2038d50f7bSAndrew Rist *************************************************************/ 2138d50f7bSAndrew Rist 22cdf0e10cSrcweir #ifndef SC_SCPATATR_HXX 23cdf0e10cSrcweir #define SC_SCPATATR_HXX 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <svl/poolitem.hxx> 26cdf0e10cSrcweir #include <svl/itemset.hxx> 273a02adb1SWang Lei #include <svl/brdcst.hxx> 28cdf0e10cSrcweir #include <unotools/fontcvt.hxx> 29cdf0e10cSrcweir #include <editeng/svxenum.hxx> 30cdf0e10cSrcweir #include "scdllapi.h" 31cdf0e10cSrcweir 32cdf0e10cSrcweir class Font; 33cdf0e10cSrcweir class OutputDevice; 34cdf0e10cSrcweir class Fraction; 35cdf0e10cSrcweir class ScStyleSheet; 36cdf0e10cSrcweir class SvNumberFormatter; 37cdf0e10cSrcweir class ScDocument; 38cdf0e10cSrcweir 39cdf0e10cSrcweir // how to treat COL_AUTO in GetFont: 40cdf0e10cSrcweir 41cdf0e10cSrcweir enum ScAutoFontColorMode 42cdf0e10cSrcweir { 43cdf0e10cSrcweir SC_AUTOCOL_RAW, // COL_AUTO is returned 44cdf0e10cSrcweir SC_AUTOCOL_BLACK, // always use black 45cdf0e10cSrcweir SC_AUTOCOL_PRINT, // black or white, depending on background 46cdf0e10cSrcweir SC_AUTOCOL_DISPLAY, // from style settings, or black/white if needed 47cdf0e10cSrcweir SC_AUTOCOL_IGNOREFONT, // like DISPLAY, but ignore stored font color (assume COL_AUTO) 48cdf0e10cSrcweir SC_AUTOCOL_IGNOREBACK, // like DISPLAY, but ignore stored background color (use configured color) 49cdf0e10cSrcweir SC_AUTOCOL_IGNOREALL // like DISPLAY, but ignore stored font and background colors 50cdf0e10cSrcweir }; 51cdf0e10cSrcweir 52cdf0e10cSrcweir 533a02adb1SWang Lei class SC_DLLPUBLIC ScPatternAttr: public SfxSetItem, public SfxBroadcaster 54cdf0e10cSrcweir { 55cdf0e10cSrcweir String* pName; 56cdf0e10cSrcweir ScStyleSheet* pStyle; 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir static ScDocument* pDoc; 59cdf0e10cSrcweir ScPatternAttr(SfxItemSet* pItemSet, const String& rStyleName); 60cdf0e10cSrcweir ScPatternAttr(SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet = NULL); 61cdf0e10cSrcweir ScPatternAttr(SfxItemPool* pItemPool); 62cdf0e10cSrcweir ScPatternAttr(const ScPatternAttr& rPatternAttr); 63cdf0e10cSrcweir 64cdf0e10cSrcweir ~ScPatternAttr(); 65cdf0e10cSrcweir 66cdf0e10cSrcweir virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; 67cdf0e10cSrcweir virtual SfxPoolItem* Create(SvStream& rStream, sal_uInt16 nVersion) const; 68cdf0e10cSrcweir virtual SvStream& Store(SvStream& rStream, sal_uInt16 nItemVersion) const; 69cdf0e10cSrcweir 70cdf0e10cSrcweir virtual int operator==(const SfxPoolItem& rCmp) const; 71cdf0e10cSrcweir GetItem(sal_uInt16 nWhichP) const72cdf0e10cSrcweir const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const 73cdf0e10cSrcweir { return GetItemSet().Get(nWhichP); } 74cdf0e10cSrcweir 75cdf0e10cSrcweir static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ); 76cdf0e10cSrcweir const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const; 77cdf0e10cSrcweir 78cdf0e10cSrcweir // pWhich sind keine Ranges, sondern einzelne IDs, 0-terminiert 79cdf0e10cSrcweir sal_Bool HasItemsSet( const sal_uInt16* pWhich ) const; 80cdf0e10cSrcweir void ClearItems( const sal_uInt16* pWhich ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir void DeleteUnchanged( const ScPatternAttr* pOldAttrs ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet = 0 ); 85cdf0e10cSrcweir SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = 0 ) const; 86cdf0e10cSrcweir 87cdf0e10cSrcweir /** Static helper function to fill a font object from the passed item set. */ 88cdf0e10cSrcweir static void GetFont( Font& rFont, const SfxItemSet& rItemSet, 89cdf0e10cSrcweir ScAutoFontColorMode eAutoMode, 90cdf0e10cSrcweir OutputDevice* pOutDev = NULL, 91cdf0e10cSrcweir const Fraction* pScale = NULL, 92cdf0e10cSrcweir const SfxItemSet* pCondSet = NULL, 93cdf0e10cSrcweir sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, 94cdf0e10cSrcweir const Color* pTextConfigColor = NULL ); 95cdf0e10cSrcweir /** Fills a font object from the own item set. */ 96cdf0e10cSrcweir void GetFont( Font& rFont, ScAutoFontColorMode eAutoMode, 97cdf0e10cSrcweir OutputDevice* pOutDev = NULL, 98cdf0e10cSrcweir const Fraction* pScale = NULL, 99cdf0e10cSrcweir const SfxItemSet* pCondSet = NULL, 100cdf0e10cSrcweir sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, 101cdf0e10cSrcweir const Color* pTextConfigColor = NULL ) const; 102cdf0e10cSrcweir 103cdf0e10cSrcweir /** Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet. */ 104cdf0e10cSrcweir static void FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = NULL ); 105cdf0e10cSrcweir /** Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSet. */ 106cdf0e10cSrcweir void FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet = NULL ) const; 107cdf0e10cSrcweir 108cdf0e10cSrcweir /** Converts all edit engine items contained in rEditSet to Calc items and puts them into rDestSet. */ 109cdf0e10cSrcweir static void GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet ); 110cdf0e10cSrcweir /** Converts all edit engine items contained in pEditSet to Calc items and puts them into the own item set. */ 111cdf0e10cSrcweir void GetFromEditItemSet( const SfxItemSet* pEditSet ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir void FillEditParaItems( SfxItemSet* pSet ) const; 114cdf0e10cSrcweir 115cdf0e10cSrcweir ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const; 116cdf0e10cSrcweir 117cdf0e10cSrcweir void SetStyleSheet(ScStyleSheet* pNewStyle); GetStyleSheet() const118cdf0e10cSrcweir const ScStyleSheet* GetStyleSheet() const { return pStyle; } 119cdf0e10cSrcweir const String* GetStyleName() const; 120cdf0e10cSrcweir void UpdateStyleSheet(); 121cdf0e10cSrcweir void StyleToName(); 122cdf0e10cSrcweir 123cdf0e10cSrcweir sal_Bool IsVisible() const; 124cdf0e10cSrcweir sal_Bool IsVisibleEqual( const ScPatternAttr& rOther ) const; 125*6a261b58SHerbert Dürr sal_Bool IsEqual( const ScPatternAttr& rOther ) const; 126cdf0e10cSrcweir 127cdf0e10cSrcweir /** If font is an old symbol font StarBats/StarMath 128cdf0e10cSrcweir with text encoding RTL_TEXTENC_SYMBOL */ 129cdf0e10cSrcweir sal_Bool IsSymbolFont() const; 130cdf0e10cSrcweir 131cdf0e10cSrcweir //UNUSED2008-05 /** Create a FontToSubsFontConverter if needed for 132cdf0e10cSrcweir //UNUSED2008-05 this pattern, else return 0. 133cdf0e10cSrcweir //UNUSED2008-05 134cdf0e10cSrcweir //UNUSED2008-05 @param nFlags is the bit mask which shall be 135cdf0e10cSrcweir //UNUSED2008-05 used for CreateFontToSubsFontConverter(). 136cdf0e10cSrcweir //UNUSED2008-05 137cdf0e10cSrcweir //UNUSED2008-05 The converter must be destroyed by the caller 138cdf0e10cSrcweir //UNUSED2008-05 using DestroyFontToSubsFontConverter() which 139cdf0e10cSrcweir //UNUSED2008-05 should be accomplished using the 140cdf0e10cSrcweir //UNUSED2008-05 ScFontToSubsFontConverter_AutoPtr 141cdf0e10cSrcweir //UNUSED2008-05 */ 142cdf0e10cSrcweir //UNUSED2008-05 FontToSubsFontConverter GetSubsFontConverter( sal_uLong nFlags ) const; 143cdf0e10cSrcweir 144cdf0e10cSrcweir sal_uLong GetNumberFormat( SvNumberFormatter* ) const; 145cdf0e10cSrcweir sal_uLong GetNumberFormat( SvNumberFormatter* pFormatter, 146cdf0e10cSrcweir const SfxItemSet* pCondSet ) const; 147cdf0e10cSrcweir 148cdf0e10cSrcweir long GetRotateVal( const SfxItemSet* pCondSet ) const; 149cdf0e10cSrcweir sal_uInt8 GetRotateDir( const SfxItemSet* pCondSet ) const; 150cdf0e10cSrcweir }; 151cdf0e10cSrcweir 152cdf0e10cSrcweir 153cdf0e10cSrcweir class ScFontToSubsFontConverter_AutoPtr 154cdf0e10cSrcweir { 155cdf0e10cSrcweir FontToSubsFontConverter h; 156cdf0e10cSrcweir release()157cdf0e10cSrcweir void release() 158cdf0e10cSrcweir { 159cdf0e10cSrcweir if ( h ) 160cdf0e10cSrcweir DestroyFontToSubsFontConverter( h ); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir // prevent usage 164cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr( const ScFontToSubsFontConverter_AutoPtr& ); 165cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr& operator=( const ScFontToSubsFontConverter_AutoPtr& ); 166cdf0e10cSrcweir 167cdf0e10cSrcweir public: ScFontToSubsFontConverter_AutoPtr()168cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr() 169cdf0e10cSrcweir : h(0) 170cdf0e10cSrcweir {} ~ScFontToSubsFontConverter_AutoPtr()171cdf0e10cSrcweir ~ScFontToSubsFontConverter_AutoPtr() 172cdf0e10cSrcweir { 173cdf0e10cSrcweir release(); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir operator =(FontToSubsFontConverter hN)176cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr& operator=( FontToSubsFontConverter hN ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir release(); 179cdf0e10cSrcweir h = hN; 180cdf0e10cSrcweir return *this; 181cdf0e10cSrcweir } 182cdf0e10cSrcweir operator FontToSubsFontConverter() const183cdf0e10cSrcweir operator FontToSubsFontConverter() const 184cdf0e10cSrcweir { return h; } 185cdf0e10cSrcweir }; 186cdf0e10cSrcweir 187cdf0e10cSrcweir 188cdf0e10cSrcweir #endif 189