xref: /trunk/main/sw/inc/tblafmt.hxx (revision 19a30862)
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 _TBLAFMT_HXX
25 #define _TBLAFMT_HXX
26 /*************************************************************************
27 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 
29 JP 20.07.95:
30 
31 	Die akt. Struktur der Autoformatierung darf nicht mehr veraendert werden.
32 	Diese wird durch unterschiedlichen Code von Writer und Calc
33 	eingelesen/geschrieben.
34 	Sollte sich doch mal eine Änderung nicht vermeiden lassen, dann auf
35 	jeden Fall in beiden Applikationen ändern.
36 
37 	The structure of table auto formatting should not changed. It is used
38 	by different code of Writer and Calc. If a change is necessary, the
39 	source code of both applications must be changed!
40 
41 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 **************************************************************************/
43 
44 #include <svl/svarray.hxx>
45 #include "hintids.hxx"			//_immmer_ vor den solar-items!
46 #include <svx/algitem.hxx>
47 #include <editeng/fontitem.hxx>
48 #include <editeng/fhgtitem.hxx>
49 #include <editeng/wghtitem.hxx>
50 #include <editeng/postitem.hxx>
51 #include <editeng/udlnitem.hxx>
52 #include <editeng/crsditem.hxx>
53 #ifndef _SVX_CNTRTITEM_HXX //autogen
54 #include <editeng/cntritem.hxx>
55 #endif
56 #include <editeng/shdditem.hxx>
57 #include <editeng/colritem.hxx>
58 #include <editeng/boxitem.hxx>
59 #include <editeng/brshitem.hxx>
60 #include <editeng/adjitem.hxx>
61 #include <svx/rotmodit.hxx>
62 #include <svl/intitem.hxx>
63 #include <editeng/bolnitem.hxx>
64 #include "swdllapi.h"
65 
66 struct SwAfVersions;
67 
68 class SvNumberFormatter;
69 
70 class SwBoxAutoFmt
71 {
72 	// common attributes of Calc and Writer
73 	// --- from 641 on: CJK and CTL font settings
74 	SvxFontItem			aFont;
75 	SvxFontHeightItem	aHeight;
76 	SvxWeightItem		aWeight;
77 	SvxPostureItem		aPosture;
78 
79 	SvxFontItem			aCJKFont;
80 	SvxFontHeightItem	aCJKHeight;
81 	SvxWeightItem		aCJKWeight;
82 	SvxPostureItem		aCJKPosture;
83 
84 	SvxFontItem			aCTLFont;
85 	SvxFontHeightItem	aCTLHeight;
86 	SvxWeightItem		aCTLWeight;
87 	SvxPostureItem		aCTLPosture;
88 
89 	SvxUnderlineItem	aUnderline;
90 	SvxOverlineItem		aOverline;
91 	SvxCrossedOutItem	aCrossedOut;
92 	SvxContourItem		aContour;
93 	SvxShadowedItem		aShadowed;
94 	SvxColorItem		aColor;
95 	SvxBoxItem			aBox;
96 	SvxLineItem			aTLBR;
97 	SvxLineItem			aBLTR;
98 	SvxBrushItem		aBackground;
99 
100 	// Writer specific
101 	SvxAdjustItem		aAdjust;
102 
103 	// Calc specific
104 	SvxHorJustifyItem	aHorJustify;
105 	SvxVerJustifyItem	aVerJustify;
106 	SfxBoolItem			aStacked;
107 	SvxMarginItem		aMargin;
108 	SfxBoolItem			aLinebreak;
109 	SfxInt32Item		aRotateAngle;
110 	SvxRotateModeItem	aRotateMode;
111 
112 	// number format
113 	String				sNumFmtString;
114 	LanguageType		eSysLanguage, eNumFmtLanguage;
115 
116 public:
117 	SwBoxAutoFmt();
118 	SwBoxAutoFmt( const SwBoxAutoFmt& rNew );
119 	~SwBoxAutoFmt();
120 
121 	int operator==( const SwBoxAutoFmt& rCmp ) const;
122 	SwBoxAutoFmt& operator=( const SwBoxAutoFmt& rNew );
123 
124 	// die Get-Methoden
GetFont() const125 	const SvxFontItem		&GetFont() const		{ return aFont; }
GetHeight() const126 	const SvxFontHeightItem	&GetHeight() const		{ return aHeight; }
GetWeight() const127 	const SvxWeightItem		&GetWeight() const		{ return aWeight; }
GetPosture() const128 	const SvxPostureItem	&GetPosture() const		{ return aPosture; }
GetCJKFont() const129 	const SvxFontItem		&GetCJKFont() const		{ return aCJKFont; }
GetCJKHeight() const130 	const SvxFontHeightItem	&GetCJKHeight() const	{ return aCJKHeight; }
GetCJKWeight() const131 	const SvxWeightItem		&GetCJKWeight() const	{ return aCJKWeight; }
GetCJKPosture() const132 	const SvxPostureItem	&GetCJKPosture() const	{ return aCJKPosture; }
GetCTLFont() const133 	const SvxFontItem		&GetCTLFont() const		{ return aCTLFont; }
GetCTLHeight() const134 	const SvxFontHeightItem	&GetCTLHeight() const	{ return aCTLHeight; }
GetCTLWeight() const135 	const SvxWeightItem		&GetCTLWeight() const	{ return aCTLWeight; }
GetCTLPosture() const136 	const SvxPostureItem	&GetCTLPosture() const	{ return aCTLPosture; }
GetUnderline() const137 	const SvxUnderlineItem	&GetUnderline() const	{ return aUnderline; }
GetOverline() const138 	const SvxOverlineItem	&GetOverline() const	{ return aOverline; }
GetCrossedOut() const139 	const SvxCrossedOutItem	&GetCrossedOut() const	{ return aCrossedOut; }
GetContour() const140 	const SvxContourItem	&GetContour() const		{ return aContour; }
GetShadowed() const141 	const SvxShadowedItem	&GetShadowed() const	{ return aShadowed; }
GetColor() const142 	const SvxColorItem		&GetColor() const		{ return aColor; }
GetAdjust() const143 	const SvxAdjustItem		&GetAdjust() const		{ return aAdjust; }
GetBox() const144 	const SvxBoxItem		&GetBox() const			{ return aBox; }
GetTLBR() const145 	const SvxLineItem		&GetTLBR() const		{ return aTLBR; }
GetBLTR() const146 	const SvxLineItem		&GetBLTR() const		{ return aBLTR; }
GetBackground() const147 	const SvxBrushItem		&GetBackground() const	{ return aBackground; }
GetValueFormat(String & rFmt,LanguageType & rLng,LanguageType & rSys) const148 	void GetValueFormat( String& rFmt, LanguageType& rLng, LanguageType& rSys ) const
149 		{ rFmt = sNumFmtString; rLng = eNumFmtLanguage; rSys = eSysLanguage; }
150 
151 	// die SetMethoden
SetFont(const SvxFontItem & rNew)152 	void SetFont( const SvxFontItem& rNew )				{ aFont = rNew; }
SetHeight(const SvxFontHeightItem & rNew)153 	void SetHeight( const SvxFontHeightItem& rNew )		{ aHeight = rNew; }
SetWeight(const SvxWeightItem & rNew)154 	void SetWeight( const SvxWeightItem& rNew )			{ aWeight = rNew; }
SetPosture(const SvxPostureItem & rNew)155 	void SetPosture( const SvxPostureItem& rNew )		{ aPosture = rNew; }
SetCJKFont(const SvxFontItem & rNew)156 	void SetCJKFont( const SvxFontItem& rNew )			{ aCJKFont = rNew; }
SetCJKHeight(const SvxFontHeightItem & rNew)157 	void SetCJKHeight( const SvxFontHeightItem& rNew )	{ aCJKHeight = rNew; }
SetCJKWeight(const SvxWeightItem & rNew)158 	void SetCJKWeight( const SvxWeightItem& rNew )		{ aCJKWeight = rNew; }
SetCJKPosture(const SvxPostureItem & rNew)159 	void SetCJKPosture( const SvxPostureItem& rNew )	{ aCJKPosture = rNew; }
SetCTLFont(const SvxFontItem & rNew)160 	void SetCTLFont( const SvxFontItem& rNew )			{ aCTLFont = rNew; }
SetCTLHeight(const SvxFontHeightItem & rNew)161 	void SetCTLHeight( const SvxFontHeightItem& rNew )	{ aCTLHeight = rNew; }
SetCTLWeight(const SvxWeightItem & rNew)162 	void SetCTLWeight( const SvxWeightItem& rNew )		{ aCTLWeight = rNew; }
SetCTLPosture(const SvxPostureItem & rNew)163 	void SetCTLPosture( const SvxPostureItem& rNew )	{ aCTLPosture = rNew; }
SetUnderline(const SvxUnderlineItem & rNew)164 	void SetUnderline( const SvxUnderlineItem& rNew )	{ aUnderline = rNew; }
SetOverline(const SvxOverlineItem & rNew)165 	void SetOverline( const SvxOverlineItem& rNew )		{ aOverline = rNew; }
SetCrossedOut(const SvxCrossedOutItem & rNew)166 	void SetCrossedOut( const SvxCrossedOutItem& rNew )	{ aCrossedOut = rNew; }
SetContour(const SvxContourItem & rNew)167 	void SetContour( const SvxContourItem& rNew )		{ aContour = rNew; }
SetShadowed(const SvxShadowedItem & rNew)168 	void SetShadowed( const SvxShadowedItem& rNew )		{ aShadowed = rNew; }
SetColor(const SvxColorItem & rNew)169 	void SetColor( const SvxColorItem& rNew )			{ aColor = rNew; }
SetAdjust(const SvxAdjustItem & rNew)170 	void SetAdjust( const SvxAdjustItem& rNew )
171 		{
172 			aAdjust.SetAdjust( rNew.GetAdjust() );
173 			aAdjust.SetOneWord( rNew.GetOneWord() );
174 			aAdjust.SetLastBlock( rNew.GetLastBlock() );
175 		}
SetBox(const SvxBoxItem & rNew)176 	void SetBox( const SvxBoxItem& rNew )				{ aBox = rNew; }
SetBackground(const SvxBrushItem & rNew)177 	void SetBackground( const SvxBrushItem& rNew )		{ aBackground = rNew; }
SetValueFormat(const String & rFmt,LanguageType eLng,LanguageType eSys)178 	void SetValueFormat( const String& rFmt, LanguageType eLng, LanguageType eSys )
179 		{ sNumFmtString = rFmt; eNumFmtLanguage = eLng; eSysLanguage = eSys; }
180 
181 	sal_Bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer );
182 	sal_Bool Save( SvStream& rStream ) const;
183 	sal_Bool SaveVersionNo( SvStream& rStream ) const;
184 
185 #ifdef READ_OLDVERS
186 	// lade alte Version
187 	sal_Bool LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] );
188 #endif
189 };
190 
191 class SW_DLLPUBLIC SwTableAutoFmt
192 {
193 	friend void _FinitCore();		// zum Zerstoeren des dflt. Pointers
194 	static SwBoxAutoFmt* pDfltBoxAutoFmt;
195 
196 	String aName;
197 	sal_uInt16 nStrResId;
198 
199 	// common flags of Calc and Writer
200 	sal_Bool bInclFont : 1;
201 	sal_Bool bInclJustify : 1;
202 	sal_Bool bInclFrame : 1;
203 	sal_Bool bInclBackground : 1;
204 	sal_Bool bInclValueFormat : 1;
205 
206 	// Calc specific flags
207 	sal_Bool bInclWidthHeight : 1;
208 
209 	SwBoxAutoFmt* aBoxAutoFmt[ 16 ];
210 
211 public:
212 	SwTableAutoFmt( const String& rName );
213 	SwTableAutoFmt( const SwTableAutoFmt& rNew );
214 	~SwTableAutoFmt();
215 
216 	SwTableAutoFmt& operator=( const SwTableAutoFmt& rNew );
217 
218 	void SetBoxFmt( const SwBoxAutoFmt& rNew, sal_uInt8 nPos );
219 	const SwBoxAutoFmt& GetBoxFmt( sal_uInt8 nPos ) const;
220 
SetName(const String & rNew)221 	void SetName( const String& rNew ) { aName = rNew; nStrResId = USHRT_MAX; }
GetName() const222 	const String& GetName() const { return aName; }
223 
224 	enum UpdateFlags { UPDATE_CHAR = 1, UPDATE_BOX = 2, UPDATE_ALL = 3 };
225 	SwBoxAutoFmt& UpdateFromSet( sal_uInt8 nPos, const SfxItemSet& rSet,
226 								UpdateFlags eFlags, SvNumberFormatter* );
227 	void UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet, UpdateFlags eFlags,
228 						SvNumberFormatter* ) const ;
229 
IsFont() const230 	sal_Bool IsFont() const			{ return bInclFont; }
IsJustify() const231 	sal_Bool IsJustify() const		{ return bInclJustify; }
IsFrame() const232 	sal_Bool IsFrame() const		{ return bInclFrame; }
IsBackground() const233 	sal_Bool IsBackground() const	{ return bInclBackground; }
IsValueFormat() const234 	sal_Bool IsValueFormat() const	{ return bInclValueFormat; }
235 
SetFont(const sal_Bool bNew)236 	void SetFont( const sal_Bool bNew )			{ bInclFont = bNew; }
SetJustify(const sal_Bool bNew)237 	void SetJustify( const sal_Bool bNew )		{ bInclJustify = bNew; }
SetFrame(const sal_Bool bNew)238 	void SetFrame( const sal_Bool bNew )		{ bInclFrame = bNew; }
SetBackground(const sal_Bool bNew)239 	void SetBackground( const sal_Bool bNew )	{ bInclBackground = bNew; }
SetValueFormat(const sal_Bool bNew)240 	void SetValueFormat( const sal_Bool bNew )	{ bInclValueFormat = bNew; }
SetWidthHeight(const sal_Bool bNew)241 	void SetWidthHeight( const sal_Bool bNew )	{ bInclWidthHeight = bNew; }
242 
243 	sal_Bool Load( SvStream& rStream, const SwAfVersions& );
244 	sal_Bool Save( SvStream& rStream ) const;
245 
246 #ifdef READ_OLDVERS
247 	// lade alte Version
248 	sal_Bool LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] );
249 #endif
250 };
251 
252 typedef SwTableAutoFmt* SwTableAutoFmtPtr ;
253 SV_DECL_PTRARR_DEL( _SwTableAutoFmtTbl, SwTableAutoFmtPtr, 1, 5 )
254 
255 class SW_DLLPUBLIC SwTableAutoFmtTbl : public _SwTableAutoFmtTbl
256 {
257 	SW_DLLPRIVATE sal_Bool Load( SvStream& rStream );
258 	SW_DLLPRIVATE sal_Bool Save( SvStream& rStream ) const;
259 
260 public:
261 	SwTableAutoFmtTbl();
262 
263 	sal_Bool Load();
264 	sal_Bool Save() const;
265 };
266 
267 #endif
268