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 2238d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_SCPATATR_HXX 25cdf0e10cSrcweir #define SC_SCPATATR_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svl/poolitem.hxx> 28cdf0e10cSrcweir #include <svl/itemset.hxx> 29*3a02adb1SWang Lei #include <svl/brdcst.hxx> 30cdf0e10cSrcweir #include <unotools/fontcvt.hxx> 31cdf0e10cSrcweir #include <editeng/svxenum.hxx> 32cdf0e10cSrcweir #include "scdllapi.h" 33cdf0e10cSrcweir 34cdf0e10cSrcweir class Font; 35cdf0e10cSrcweir class OutputDevice; 36cdf0e10cSrcweir class Fraction; 37cdf0e10cSrcweir class ScStyleSheet; 38cdf0e10cSrcweir class SvNumberFormatter; 39cdf0e10cSrcweir class ScDocument; 40cdf0e10cSrcweir 41cdf0e10cSrcweir 42cdf0e10cSrcweir // how to treat COL_AUTO in GetFont: 43cdf0e10cSrcweir 44cdf0e10cSrcweir enum ScAutoFontColorMode 45cdf0e10cSrcweir { 46cdf0e10cSrcweir SC_AUTOCOL_RAW, // COL_AUTO is returned 47cdf0e10cSrcweir SC_AUTOCOL_BLACK, // always use black 48cdf0e10cSrcweir SC_AUTOCOL_PRINT, // black or white, depending on background 49cdf0e10cSrcweir SC_AUTOCOL_DISPLAY, // from style settings, or black/white if needed 50cdf0e10cSrcweir SC_AUTOCOL_IGNOREFONT, // like DISPLAY, but ignore stored font color (assume COL_AUTO) 51cdf0e10cSrcweir SC_AUTOCOL_IGNOREBACK, // like DISPLAY, but ignore stored background color (use configured color) 52cdf0e10cSrcweir SC_AUTOCOL_IGNOREALL // like DISPLAY, but ignore stored font and background colors 53cdf0e10cSrcweir }; 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56*3a02adb1SWang Lei class SC_DLLPUBLIC ScPatternAttr: public SfxSetItem, public SfxBroadcaster 57cdf0e10cSrcweir { 58cdf0e10cSrcweir String* pName; 59cdf0e10cSrcweir ScStyleSheet* pStyle; 60cdf0e10cSrcweir public: 61cdf0e10cSrcweir static ScDocument* pDoc; 62cdf0e10cSrcweir ScPatternAttr(SfxItemSet* pItemSet, const String& rStyleName); 63cdf0e10cSrcweir ScPatternAttr(SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet = NULL); 64cdf0e10cSrcweir ScPatternAttr(SfxItemPool* pItemPool); 65cdf0e10cSrcweir ScPatternAttr(const ScPatternAttr& rPatternAttr); 66cdf0e10cSrcweir 67cdf0e10cSrcweir ~ScPatternAttr(); 68cdf0e10cSrcweir 69cdf0e10cSrcweir virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; 70cdf0e10cSrcweir virtual SfxPoolItem* Create(SvStream& rStream, sal_uInt16 nVersion) const; 71cdf0e10cSrcweir virtual SvStream& Store(SvStream& rStream, sal_uInt16 nItemVersion) const; 72cdf0e10cSrcweir 73cdf0e10cSrcweir virtual int operator==(const SfxPoolItem& rCmp) const; 74cdf0e10cSrcweir 75cdf0e10cSrcweir const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const 76cdf0e10cSrcweir { return GetItemSet().Get(nWhichP); } 77cdf0e10cSrcweir 78cdf0e10cSrcweir static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ); 79cdf0e10cSrcweir const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const; 80cdf0e10cSrcweir 81cdf0e10cSrcweir // pWhich sind keine Ranges, sondern einzelne IDs, 0-terminiert 82cdf0e10cSrcweir sal_Bool HasItemsSet( const sal_uInt16* pWhich ) const; 83cdf0e10cSrcweir void ClearItems( const sal_uInt16* pWhich ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir void DeleteUnchanged( const ScPatternAttr* pOldAttrs ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet = 0 ); 88cdf0e10cSrcweir SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = 0 ) const; 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** Static helper function to fill a font object from the passed item set. */ 91cdf0e10cSrcweir static void GetFont( Font& rFont, const SfxItemSet& rItemSet, 92cdf0e10cSrcweir ScAutoFontColorMode eAutoMode, 93cdf0e10cSrcweir OutputDevice* pOutDev = NULL, 94cdf0e10cSrcweir const Fraction* pScale = NULL, 95cdf0e10cSrcweir const SfxItemSet* pCondSet = NULL, 96cdf0e10cSrcweir sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, 97cdf0e10cSrcweir const Color* pTextConfigColor = NULL ); 98cdf0e10cSrcweir /** Fills a font object from the own item set. */ 99cdf0e10cSrcweir void GetFont( Font& rFont, ScAutoFontColorMode eAutoMode, 100cdf0e10cSrcweir OutputDevice* pOutDev = NULL, 101cdf0e10cSrcweir const Fraction* pScale = NULL, 102cdf0e10cSrcweir const SfxItemSet* pCondSet = NULL, 103cdf0e10cSrcweir sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, 104cdf0e10cSrcweir const Color* pTextConfigColor = NULL ) const; 105cdf0e10cSrcweir 106cdf0e10cSrcweir /** Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet. */ 107cdf0e10cSrcweir static void FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = NULL ); 108cdf0e10cSrcweir /** Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSet. */ 109cdf0e10cSrcweir void FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet = NULL ) const; 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** Converts all edit engine items contained in rEditSet to Calc items and puts them into rDestSet. */ 112cdf0e10cSrcweir static void GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet ); 113cdf0e10cSrcweir /** Converts all edit engine items contained in pEditSet to Calc items and puts them into the own item set. */ 114cdf0e10cSrcweir void GetFromEditItemSet( const SfxItemSet* pEditSet ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir void FillEditParaItems( SfxItemSet* pSet ) const; 117cdf0e10cSrcweir 118cdf0e10cSrcweir ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const; 119cdf0e10cSrcweir 120cdf0e10cSrcweir void SetStyleSheet(ScStyleSheet* pNewStyle); 121cdf0e10cSrcweir const ScStyleSheet* GetStyleSheet() const { return pStyle; } 122cdf0e10cSrcweir const String* GetStyleName() const; 123cdf0e10cSrcweir void UpdateStyleSheet(); 124cdf0e10cSrcweir void StyleToName(); 125cdf0e10cSrcweir 126cdf0e10cSrcweir sal_Bool IsVisible() const; 127cdf0e10cSrcweir sal_Bool IsVisibleEqual( const ScPatternAttr& rOther ) const; 128cdf0e10cSrcweir 129cdf0e10cSrcweir /** If font is an old symbol font StarBats/StarMath 130cdf0e10cSrcweir with text encoding RTL_TEXTENC_SYMBOL */ 131cdf0e10cSrcweir sal_Bool IsSymbolFont() const; 132cdf0e10cSrcweir 133cdf0e10cSrcweir //UNUSED2008-05 /** Create a FontToSubsFontConverter if needed for 134cdf0e10cSrcweir //UNUSED2008-05 this pattern, else return 0. 135cdf0e10cSrcweir //UNUSED2008-05 136cdf0e10cSrcweir //UNUSED2008-05 @param nFlags is the bit mask which shall be 137cdf0e10cSrcweir //UNUSED2008-05 used for CreateFontToSubsFontConverter(). 138cdf0e10cSrcweir //UNUSED2008-05 139cdf0e10cSrcweir //UNUSED2008-05 The converter must be destroyed by the caller 140cdf0e10cSrcweir //UNUSED2008-05 using DestroyFontToSubsFontConverter() which 141cdf0e10cSrcweir //UNUSED2008-05 should be accomplished using the 142cdf0e10cSrcweir //UNUSED2008-05 ScFontToSubsFontConverter_AutoPtr 143cdf0e10cSrcweir //UNUSED2008-05 */ 144cdf0e10cSrcweir //UNUSED2008-05 FontToSubsFontConverter GetSubsFontConverter( sal_uLong nFlags ) const; 145cdf0e10cSrcweir 146cdf0e10cSrcweir sal_uLong GetNumberFormat( SvNumberFormatter* ) const; 147cdf0e10cSrcweir sal_uLong GetNumberFormat( SvNumberFormatter* pFormatter, 148cdf0e10cSrcweir const SfxItemSet* pCondSet ) const; 149cdf0e10cSrcweir 150cdf0e10cSrcweir long GetRotateVal( const SfxItemSet* pCondSet ) const; 151cdf0e10cSrcweir sal_uInt8 GetRotateDir( const SfxItemSet* pCondSet ) const; 152cdf0e10cSrcweir }; 153cdf0e10cSrcweir 154cdf0e10cSrcweir 155cdf0e10cSrcweir class ScFontToSubsFontConverter_AutoPtr 156cdf0e10cSrcweir { 157cdf0e10cSrcweir FontToSubsFontConverter h; 158cdf0e10cSrcweir 159cdf0e10cSrcweir void release() 160cdf0e10cSrcweir { 161cdf0e10cSrcweir if ( h ) 162cdf0e10cSrcweir DestroyFontToSubsFontConverter( h ); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir // prevent usage 166cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr( const ScFontToSubsFontConverter_AutoPtr& ); 167cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr& operator=( const ScFontToSubsFontConverter_AutoPtr& ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir public: 170cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr() 171cdf0e10cSrcweir : h(0) 172cdf0e10cSrcweir {} 173cdf0e10cSrcweir ~ScFontToSubsFontConverter_AutoPtr() 174cdf0e10cSrcweir { 175cdf0e10cSrcweir release(); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir ScFontToSubsFontConverter_AutoPtr& operator=( FontToSubsFontConverter hN ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir release(); 181cdf0e10cSrcweir h = hN; 182cdf0e10cSrcweir return *this; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir operator FontToSubsFontConverter() const 186cdf0e10cSrcweir { return h; } 187cdf0e10cSrcweir }; 188cdf0e10cSrcweir 189cdf0e10cSrcweir 190cdf0e10cSrcweir #endif 191