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