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