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