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