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