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