1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_SCPATATR_HXX 29 #define SC_SCPATATR_HXX 30 31 #include <svl/poolitem.hxx> 32 #include <svl/itemset.hxx> 33 #include <unotools/fontcvt.hxx> 34 #include <editeng/svxenum.hxx> 35 #include "scdllapi.h" 36 37 class Font; 38 class OutputDevice; 39 class Fraction; 40 class ScStyleSheet; 41 class SvNumberFormatter; 42 class ScDocument; 43 44 45 // how to treat COL_AUTO in GetFont: 46 47 enum ScAutoFontColorMode 48 { 49 SC_AUTOCOL_RAW, // COL_AUTO is returned 50 SC_AUTOCOL_BLACK, // always use black 51 SC_AUTOCOL_PRINT, // black or white, depending on background 52 SC_AUTOCOL_DISPLAY, // from style settings, or black/white if needed 53 SC_AUTOCOL_IGNOREFONT, // like DISPLAY, but ignore stored font color (assume COL_AUTO) 54 SC_AUTOCOL_IGNOREBACK, // like DISPLAY, but ignore stored background color (use configured color) 55 SC_AUTOCOL_IGNOREALL // like DISPLAY, but ignore stored font and background colors 56 }; 57 58 59 class SC_DLLPUBLIC ScPatternAttr: public SfxSetItem 60 { 61 String* pName; 62 ScStyleSheet* pStyle; 63 public: 64 static ScDocument* pDoc; 65 ScPatternAttr(SfxItemSet* pItemSet, const String& rStyleName); 66 ScPatternAttr(SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet = NULL); 67 ScPatternAttr(SfxItemPool* pItemPool); 68 ScPatternAttr(const ScPatternAttr& rPatternAttr); 69 70 ~ScPatternAttr(); 71 72 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; 73 virtual SfxPoolItem* Create(SvStream& rStream, sal_uInt16 nVersion) const; 74 virtual SvStream& Store(SvStream& rStream, sal_uInt16 nItemVersion) const; 75 76 virtual int operator==(const SfxPoolItem& rCmp) const; 77 78 const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const 79 { return GetItemSet().Get(nWhichP); } 80 81 static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ); 82 const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const; 83 84 // pWhich sind keine Ranges, sondern einzelne IDs, 0-terminiert 85 sal_Bool HasItemsSet( const sal_uInt16* pWhich ) const; 86 void ClearItems( const sal_uInt16* pWhich ); 87 88 void DeleteUnchanged( const ScPatternAttr* pOldAttrs ); 89 90 static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet = 0 ); 91 SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = 0 ) const; 92 93 /** Static helper function to fill a font object from the passed item set. */ 94 static void GetFont( Font& rFont, const SfxItemSet& rItemSet, 95 ScAutoFontColorMode eAutoMode, 96 OutputDevice* pOutDev = NULL, 97 const Fraction* pScale = NULL, 98 const SfxItemSet* pCondSet = NULL, 99 sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, 100 const Color* pTextConfigColor = NULL ); 101 /** Fills a font object from the own item set. */ 102 void GetFont( Font& rFont, ScAutoFontColorMode eAutoMode, 103 OutputDevice* pOutDev = NULL, 104 const Fraction* pScale = NULL, 105 const SfxItemSet* pCondSet = NULL, 106 sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL, 107 const Color* pTextConfigColor = NULL ) const; 108 109 /** Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet. */ 110 static void FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = NULL ); 111 /** Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSet. */ 112 void FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet = NULL ) const; 113 114 /** Converts all edit engine items contained in rEditSet to Calc items and puts them into rDestSet. */ 115 static void GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet ); 116 /** Converts all edit engine items contained in pEditSet to Calc items and puts them into the own item set. */ 117 void GetFromEditItemSet( const SfxItemSet* pEditSet ); 118 119 void FillEditParaItems( SfxItemSet* pSet ) const; 120 121 ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const; 122 123 void SetStyleSheet(ScStyleSheet* pNewStyle); 124 const ScStyleSheet* GetStyleSheet() const { return pStyle; } 125 const String* GetStyleName() const; 126 void UpdateStyleSheet(); 127 void StyleToName(); 128 129 sal_Bool IsVisible() const; 130 sal_Bool IsVisibleEqual( const ScPatternAttr& rOther ) const; 131 132 /** If font is an old symbol font StarBats/StarMath 133 with text encoding RTL_TEXTENC_SYMBOL */ 134 sal_Bool IsSymbolFont() const; 135 136 //UNUSED2008-05 /** Create a FontToSubsFontConverter if needed for 137 //UNUSED2008-05 this pattern, else return 0. 138 //UNUSED2008-05 139 //UNUSED2008-05 @param nFlags is the bit mask which shall be 140 //UNUSED2008-05 used for CreateFontToSubsFontConverter(). 141 //UNUSED2008-05 142 //UNUSED2008-05 The converter must be destroyed by the caller 143 //UNUSED2008-05 using DestroyFontToSubsFontConverter() which 144 //UNUSED2008-05 should be accomplished using the 145 //UNUSED2008-05 ScFontToSubsFontConverter_AutoPtr 146 //UNUSED2008-05 */ 147 //UNUSED2008-05 FontToSubsFontConverter GetSubsFontConverter( sal_uLong nFlags ) const; 148 149 sal_uLong GetNumberFormat( SvNumberFormatter* ) const; 150 sal_uLong GetNumberFormat( SvNumberFormatter* pFormatter, 151 const SfxItemSet* pCondSet ) const; 152 153 long GetRotateVal( const SfxItemSet* pCondSet ) const; 154 sal_uInt8 GetRotateDir( const SfxItemSet* pCondSet ) const; 155 }; 156 157 158 class ScFontToSubsFontConverter_AutoPtr 159 { 160 FontToSubsFontConverter h; 161 162 void release() 163 { 164 if ( h ) 165 DestroyFontToSubsFontConverter( h ); 166 } 167 168 // prevent usage 169 ScFontToSubsFontConverter_AutoPtr( const ScFontToSubsFontConverter_AutoPtr& ); 170 ScFontToSubsFontConverter_AutoPtr& operator=( const ScFontToSubsFontConverter_AutoPtr& ); 171 172 public: 173 ScFontToSubsFontConverter_AutoPtr() 174 : h(0) 175 {} 176 ~ScFontToSubsFontConverter_AutoPtr() 177 { 178 release(); 179 } 180 181 ScFontToSubsFontConverter_AutoPtr& operator=( FontToSubsFontConverter hN ) 182 { 183 release(); 184 h = hN; 185 return *this; 186 } 187 188 operator FontToSubsFontConverter() const 189 { return h; } 190 }; 191 192 193 #endif 194