xref: /AOO41X/main/sc/inc/autoform.hxx (revision 05236b1a0a8122ee73deabdbaef6d40a9b9d7792)
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_AUTOFORM_HXX
25 #define SC_AUTOFORM_HXX
26 
27 /*************************************************************************
28 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 
30 JP 20.07.95:
31 
32 	Die akt. Struktur der Autoformatierung darf nicht mehr veraendert werden.
33 	Diese wird durch unterschiedlichen Code vom StartWriter und vom StarCalc
34 	eingelesen/geschrieben.
35 	Sollte sich doch mal eine Aenderung nicht vermeiden lassen, dann auf
36 	jedenfall in beiden Applikationen aendern.
37 
38     The structure of table auto formatting should not changed. It is used
39     by different code of Writer and Calc. If a change is necessary, the
40     source code of both applications must be changed!
41 
42 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43 **************************************************************************/
44 
45 #include "scitems.hxx"
46 #include <editeng/adjitem.hxx>
47 #include <svx/algitem.hxx>
48 #include <editeng/boxitem.hxx>
49 #include <editeng/brshitem.hxx>
50 #include <editeng/cntritem.hxx>
51 #include <editeng/colritem.hxx>
52 #include <editeng/crsditem.hxx>
53 #include <editeng/fhgtitem.hxx>
54 #include <editeng/fontitem.hxx>
55 #include <editeng/postitem.hxx>
56 #include <editeng/shdditem.hxx>
57 #include <editeng/udlnitem.hxx>
58 #include <editeng/wghtitem.hxx>
59 #include <svx/rotmodit.hxx>
60 #include <svl/intitem.hxx>
61 #include <editeng/bolnitem.hxx>
62 #include "scdllapi.h"
63 #include "collect.hxx"
64 #include "global.hxx"
65 #include "zforauto.hxx"
66 
67 
68 struct ScAfVersions;
69 
70 
71 /// Contains all items for one cell of a table autoformat.
72 class ScAutoFormatDataField
73 {
74 private:
75     SvxFontItem                 aFont;
76     SvxFontHeightItem           aHeight;
77     SvxWeightItem               aWeight;
78     SvxPostureItem              aPosture;
79 
80     SvxFontItem                 aCJKFont;
81     SvxFontHeightItem           aCJKHeight;
82     SvxWeightItem               aCJKWeight;
83     SvxPostureItem              aCJKPosture;
84 
85     SvxFontItem                 aCTLFont;
86     SvxFontHeightItem           aCTLHeight;
87     SvxWeightItem               aCTLWeight;
88     SvxPostureItem              aCTLPosture;
89 
90     SvxUnderlineItem            aUnderline;
91     SvxOverlineItem             aOverline;
92     SvxCrossedOutItem           aCrossedOut;
93     SvxContourItem              aContour;
94     SvxShadowedItem             aShadowed;
95     SvxColorItem                aColor;
96     SvxBoxItem                  aBox;
97     SvxLineItem                 aTLBR;
98     SvxLineItem                 aBLTR;
99     SvxBrushItem                aBackground;
100 
101     // Writer specific
102     SvxAdjustItem               aAdjust;
103 
104     // Calc specific
105     SvxHorJustifyItem           aHorJustify;
106     SvxVerJustifyItem           aVerJustify;
107     SfxBoolItem                 aStacked;
108     SvxMarginItem               aMargin;
109     SfxBoolItem                 aLinebreak;
110     // from SO5, 504k on, rotated text
111     SfxInt32Item                aRotateAngle;
112     SvxRotateModeItem           aRotateMode;
113 
114     // number format
115     ScNumFormatAbbrev           aNumFormat;
116 
117 public:
118                                 ScAutoFormatDataField();
119                                 ScAutoFormatDataField( const ScAutoFormatDataField& rCopy );
120                                 ~ScAutoFormatDataField();
121 
122     const ScNumFormatAbbrev&    GetNumFormat() const    { return aNumFormat; }
123     const SvxFontItem&          GetFont() const         { return aFont; }
124     const SvxFontHeightItem&    GetHeight() const       { return aHeight; }
125     const SvxWeightItem&        GetWeight() const       { return aWeight; }
126     const SvxPostureItem&       GetPosture() const      { return aPosture; }
127     const SvxFontItem&          GetCJKFont() const      { return aCJKFont; }
128     const SvxFontHeightItem&    GetCJKHeight() const    { return aCJKHeight; }
129     const SvxWeightItem&        GetCJKWeight() const    { return aCJKWeight; }
130     const SvxPostureItem&       GetCJKPosture() const   { return aCJKPosture; }
131     const SvxFontItem&          GetCTLFont() const      { return aCTLFont; }
132     const SvxFontHeightItem&    GetCTLHeight() const    { return aCTLHeight; }
133     const SvxWeightItem&        GetCTLWeight() const    { return aCTLWeight; }
134     const SvxPostureItem&       GetCTLPosture() const   { return aCTLPosture; }
135     const SvxUnderlineItem&     GetUnderline() const    { return aUnderline; }
136     const SvxOverlineItem&      GetOverline() const     { return aOverline; }
137     const SvxCrossedOutItem&    GetCrossedOut() const   { return aCrossedOut; }
138     const SvxContourItem&       GetContour() const      { return aContour; }
139     const SvxShadowedItem&      GetShadowed() const     { return aShadowed; }
140     const SvxColorItem&         GetColor() const        { return aColor; }
141     const SvxHorJustifyItem&    GetHorJustify() const   { return aHorJustify; }
142     const SvxVerJustifyItem&    GetVerJustify() const   { return aVerJustify; }
143     const SfxBoolItem&          GetStacked() const      { return aStacked; }
144     const SfxBoolItem&          GetLinebreak() const    { return aLinebreak; }
145     const SvxMarginItem&        GetMargin() const       { return aMargin; }
146     const SvxBoxItem&           GetBox() const          { return aBox; }
147     const SvxLineItem&          GetTLBR() const         { return aTLBR; }
148     const SvxLineItem&          GetBLTR() const         { return aBLTR; }
149     const SvxBrushItem&         GetBackground() const   { return aBackground; }
150     const SvxAdjustItem&        GetAdjust() const       { return aAdjust; }
151     const SfxInt32Item&         GetRotateAngle() const  { return aRotateAngle; }
152     const SvxRotateModeItem&    GetRotateMode() const   { return aRotateMode; }
153 
154     void    SetNumFormat( const ScNumFormatAbbrev& rNumFormat )     { aNumFormat = rNumFormat; }
155     void    SetFont( const SvxFontItem& rFont )                     { aFont = rFont; }
156     void    SetHeight( const SvxFontHeightItem& rHeight )           { aHeight = rHeight; }
157     void    SetWeight( const SvxWeightItem& rWeight )               { aWeight = rWeight; }
158     void    SetPosture( const SvxPostureItem& rPosture )            { aPosture = rPosture; }
159     void    SetCJKFont( const SvxFontItem& rCJKFont )               { aCJKFont = rCJKFont; }
160     void    SetCJKHeight( const SvxFontHeightItem& rCJKHeight )     { aCJKHeight = rCJKHeight; }
161     void    SetCJKWeight( const SvxWeightItem& rCJKWeight )         { aCJKWeight = rCJKWeight; }
162     void    SetCJKPosture( const SvxPostureItem& rCJKPosture )      { aCJKPosture = rCJKPosture; }
163     void    SetCTLFont( const SvxFontItem& rCTLFont )               { aCTLFont = rCTLFont; }
164     void    SetCTLHeight( const SvxFontHeightItem& rCTLHeight )     { aCTLHeight = rCTLHeight; }
165     void    SetCTLWeight( const SvxWeightItem& rCTLWeight )         { aCTLWeight = rCTLWeight; }
166     void    SetCTLPosture( const SvxPostureItem& rCTLPosture )      { aCTLPosture = rCTLPosture; }
167     void    SetUnderline( const SvxUnderlineItem& rUnderline )      { aUnderline = rUnderline; }
168     void    SetOverline( const SvxOverlineItem& rOverline )         { aOverline = rOverline; }
169     void    SetCrossedOut( const SvxCrossedOutItem& rCrossedOut )   { aCrossedOut = rCrossedOut; }
170     void    SetContour( const SvxContourItem& rContour )            { aContour = rContour; }
171     void    SetShadowed( const SvxShadowedItem& rShadowed )         { aShadowed = rShadowed; }
172     void    SetColor( const SvxColorItem& rColor )                  { aColor = rColor; }
173     void    SetHorJustify( const SvxHorJustifyItem& rHorJustify )   { aHorJustify = rHorJustify; }
174     void    SetVerJustify( const SvxVerJustifyItem& rVerJustify )   { aVerJustify = rVerJustify; }
175     void    SetStacked( const SfxBoolItem& rStacked )               { aStacked.SetValue( rStacked.GetValue() ); }
176     void    SetLinebreak( const SfxBoolItem& rLinebreak )           { aLinebreak.SetValue( rLinebreak.GetValue() ); }
177     void    SetMargin( const SvxMarginItem& rMargin )               { aMargin = rMargin; }
178     void    SetBox( const SvxBoxItem& rBox )                        { aBox = rBox; }
179     void    SetTLBR( const SvxLineItem& rTLBR )                     { aTLBR = rTLBR; }
180     void    SetBLTR( const SvxLineItem& rBLTR )                     { aBLTR = rBLTR; }
181     void    SetBackground( const SvxBrushItem& rBackground )        { aBackground = rBackground; }
182     void    SetAdjust( const SvxAdjustItem& rAdjust );
183     void    SetRotateAngle( const SfxInt32Item& rRotateAngle )      { aRotateAngle.SetValue( rRotateAngle.GetValue() ); }
184     void    SetRotateMode( const SvxRotateModeItem& rRotateMode )   { aRotateMode.SetValue( rRotateMode.GetValue() ); }
185 
186     sal_Bool                        Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
187     sal_Bool                        Save( SvStream& rStream );
188 
189 #ifdef READ_OLDVERS
190     sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
191 #endif
192 };
193 
194 
195 class SC_DLLPUBLIC ScAutoFormatData : public ScDataObject
196 {
197 private:
198     String                      aName;
199     sal_uInt16                      nStrResId;
200     // common flags of Calc and Writer
201     sal_Bool                        bIncludeFont : 1;
202     sal_Bool                        bIncludeJustify : 1;
203     sal_Bool                        bIncludeFrame : 1;
204     sal_Bool                        bIncludeBackground : 1;
205 
206     // Calc specific flags
207     sal_Bool                        bIncludeValueFormat : 1;
208     sal_Bool                        bIncludeWidthHeight : 1;
209 
210     ScAutoFormatDataField**     ppDataField;
211 
212     SC_DLLPRIVATE ScAutoFormatDataField&       GetField( sal_uInt16 nIndex );
213     SC_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
214 
215 public:
216                     ScAutoFormatData();
217                     ScAutoFormatData( const ScAutoFormatData& rData );
218     virtual         ~ScAutoFormatData();
219 
220     virtual         ScDataObject* Clone() const { return new ScAutoFormatData( *this ); }
221 
222     void            SetName( const String& rName )              { aName = rName; nStrResId = USHRT_MAX; }
223     void            GetName( String& rName ) const              { rName = aName; }
224 
225     sal_Bool            GetIncludeValueFormat() const               { return bIncludeValueFormat; }
226     sal_Bool            GetIncludeFont() const                      { return bIncludeFont; }
227     sal_Bool            GetIncludeJustify() const                   { return bIncludeJustify; }
228     sal_Bool            GetIncludeFrame() const                     { return bIncludeFrame; }
229     sal_Bool            GetIncludeBackground() const                { return bIncludeBackground; }
230     sal_Bool            GetIncludeWidthHeight() const               { return bIncludeWidthHeight; }
231 
232     void            SetIncludeValueFormat( sal_Bool bValueFormat )  { bIncludeValueFormat = bValueFormat; }
233     void            SetIncludeFont( sal_Bool bFont )                { bIncludeFont = bFont; }
234     void            SetIncludeJustify( sal_Bool bJustify )          { bIncludeJustify = bJustify; }
235     void            SetIncludeFrame( sal_Bool bFrame )              { bIncludeFrame = bFrame; }
236     void            SetIncludeBackground( sal_Bool bBackground )    { bIncludeBackground = bBackground; }
237     void            SetIncludeWidthHeight( sal_Bool bWidthHeight )  { bIncludeWidthHeight = bWidthHeight; }
238 
239     const SfxPoolItem*          GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
240     void                        PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
241     void                        CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
242 
243     const ScNumFormatAbbrev&    GetNumFormat( sal_uInt16 nIndex ) const;
244 
245     sal_Bool                        IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const;
246 
247     void                        FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, ScDocument& rDoc ) const;
248     void                        GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
249 
250     sal_Bool                        Load( SvStream& rStream, const ScAfVersions& rVersions );
251     sal_Bool                        Save( SvStream& rStream );
252 
253 #ifdef READ_OLDVERS
254     sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
255 #endif
256 };
257 
258 class SC_DLLPUBLIC ScAutoFormat : public ScSortedCollection
259 {
260 private:
261     sal_Bool                        bSaveLater;
262 
263 public:
264                                 ScAutoFormat( sal_uInt16 nLim = 4, sal_uInt16 nDel = 4, sal_Bool bDup = sal_False );
265                                 ScAutoFormat( const ScAutoFormat& AutoFormat );
266     virtual                     ~ScAutoFormat();
267     virtual                     ScDataObject*         Clone() const { return new ScAutoFormat( *this ); }
268                                 ScAutoFormatData*   operator[]( const sal_uInt16 nIndex ) const {return (ScAutoFormatData*)At( nIndex );}
269     virtual short               Compare( ScDataObject* pKey1, ScDataObject* pKey2 ) const;
270     sal_Bool                        Load();
271     sal_Bool                        Save();
272     sal_uInt16                      FindIndexPerName( const String& rName ) const;
273     void                        SetSaveLater( sal_Bool bSet );
274     sal_Bool                        IsSaveLater() const         { return bSaveLater; }
275 };
276 
277 
278 #endif
279