xref: /aoo41x/main/sw/source/core/doc/tblafmt.cxx (revision 79aad27f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <tools/resid.hxx>
29cdf0e10cSrcweir #include <tools/stream.hxx>
30cdf0e10cSrcweir #include <tools/shl.hxx>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <sfx2/docfile.hxx>
33cdf0e10cSrcweir #include <svl/urihelper.hxx>
34cdf0e10cSrcweir #include <svl/zforlist.hxx>
35cdf0e10cSrcweir #include <svl/zformat.hxx>
36cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
37cdf0e10cSrcweir #include <sfx2/app.hxx>
38cdf0e10cSrcweir #include <svx/dialmgr.hxx>
39cdf0e10cSrcweir #ifndef _SVX_DIALOGS_HRC
40cdf0e10cSrcweir #include <svx/dialogs.hrc>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define READ_OLDVERS		// erstmal noch alte Versionen lesen
44cdf0e10cSrcweir #include <swtypes.hxx>
45cdf0e10cSrcweir #include <doc.hxx>
46cdf0e10cSrcweir #include <poolfmt.hxx>
47cdf0e10cSrcweir #include <tblafmt.hxx>
48cdf0e10cSrcweir #include <cellatr.hxx>
49cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // bis SO5PF
52cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_X		= 9501;
53cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_358		= 9601;
54cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_X	= 9502;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // ab SO5
57cdf0e10cSrcweir //! in nachfolgenden Versionen muss der Betrag dieser IDs groesser sein
58cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_504		= 9801;
59cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_504	= 9802;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_552		= 9901;
62cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_552	= 9902;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // --- from 641 on: CJK and CTL font settings
65cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_641      = 10001;
66cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_641 = 10002;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir // --- from 680/dr14 on: diagonal frame lines
69cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_680DR14      = 10011;
70cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_680DR14 = 10012;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // --- from 680/dr25 on: #21549# store strings as UTF-8
73cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_680DR25      = 10021;
74cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_680DR25 = 10022;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir // --- from DEV300/overline2 on: #5991# overline
77cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_300OVRLN      = 10031;
78cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_300OVRLN = 10032;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // current version
81cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_300OVRLN;
82cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_300OVRLN;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir #ifdef READ_OLDVERS
86cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_OLD_ID		= 8201;
87cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_OLD_ID1		= 8301;
88cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_OLD_DATA_ID	= 8202;
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir SwBoxAutoFmt* SwTableAutoFmt::pDfltBoxAutoFmt = 0;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #define sAutoTblFmtName "autotbl.fmt"
95cdf0e10cSrcweir 
96cdf0e10cSrcweir // SwTable Auto-Format-Tabelle
97cdf0e10cSrcweir SV_IMPL_PTRARR( _SwTableAutoFmtTbl, SwTableAutoFmt* )
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir //	Struct mit Versionsnummern der Items
101cdf0e10cSrcweir 
102cdf0e10cSrcweir struct SwAfVersions
103cdf0e10cSrcweir {
104cdf0e10cSrcweir public:
105cdf0e10cSrcweir 	sal_uInt16 nFontVersion;
106cdf0e10cSrcweir 	sal_uInt16 nFontHeightVersion;
107cdf0e10cSrcweir 	sal_uInt16 nWeightVersion;
108cdf0e10cSrcweir 	sal_uInt16 nPostureVersion;
109cdf0e10cSrcweir 	sal_uInt16 nUnderlineVersion;
110cdf0e10cSrcweir 	sal_uInt16 nOverlineVersion;
111cdf0e10cSrcweir 	sal_uInt16 nCrossedOutVersion;
112cdf0e10cSrcweir 	sal_uInt16 nContourVersion;
113cdf0e10cSrcweir 	sal_uInt16 nShadowedVersion;
114cdf0e10cSrcweir 	sal_uInt16 nColorVersion;
115cdf0e10cSrcweir 	sal_uInt16 nBoxVersion;
116cdf0e10cSrcweir     sal_uInt16 nLineVersion;
117cdf0e10cSrcweir 	sal_uInt16 nBrushVersion;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	sal_uInt16 nAdjustVersion;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	sal_uInt16 nHorJustifyVersion;
122cdf0e10cSrcweir 	sal_uInt16 nVerJustifyVersion;
123cdf0e10cSrcweir 	sal_uInt16 nOrientationVersion;
124cdf0e10cSrcweir 	sal_uInt16 nMarginVersion;
125cdf0e10cSrcweir 	sal_uInt16 nBoolVersion;
126cdf0e10cSrcweir 	sal_uInt16 nInt32Version;
127cdf0e10cSrcweir 	sal_uInt16 nRotateModeVersion;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	sal_uInt16 nNumFmtVersion;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	SwAfVersions();
132cdf0e10cSrcweir 	void Load( SvStream& rStream, sal_uInt16 nVer );
133cdf0e10cSrcweir };
134cdf0e10cSrcweir 
SwAfVersions()135cdf0e10cSrcweir SwAfVersions::SwAfVersions() :
136cdf0e10cSrcweir 	nFontVersion(0),
137cdf0e10cSrcweir 	nFontHeightVersion(0),
138cdf0e10cSrcweir 	nWeightVersion(0),
139cdf0e10cSrcweir 	nPostureVersion(0),
140cdf0e10cSrcweir 	nUnderlineVersion(0),
141cdf0e10cSrcweir 	nOverlineVersion(0),
142cdf0e10cSrcweir 	nCrossedOutVersion(0),
143cdf0e10cSrcweir 	nContourVersion(0),
144cdf0e10cSrcweir 	nShadowedVersion(0),
145cdf0e10cSrcweir 	nColorVersion(0),
146cdf0e10cSrcweir 	nBoxVersion(0),
147cdf0e10cSrcweir     nLineVersion(0),
148cdf0e10cSrcweir 	nBrushVersion(0),
149cdf0e10cSrcweir 	nAdjustVersion(0),
150cdf0e10cSrcweir 	nHorJustifyVersion(0),
151cdf0e10cSrcweir 	nVerJustifyVersion(0),
152cdf0e10cSrcweir 	nOrientationVersion(0),
153cdf0e10cSrcweir 	nMarginVersion(0),
154cdf0e10cSrcweir 	nBoolVersion(0),
155cdf0e10cSrcweir 	nInt32Version(0),
156cdf0e10cSrcweir 	nRotateModeVersion(0),
157cdf0e10cSrcweir 	nNumFmtVersion(0)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
Load(SvStream & rStream,sal_uInt16 nVer)161cdf0e10cSrcweir void SwAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir 	rStream >> nFontVersion;
164cdf0e10cSrcweir 	rStream >> nFontHeightVersion;
165cdf0e10cSrcweir 	rStream >> nWeightVersion;
166cdf0e10cSrcweir 	rStream >> nPostureVersion;
167cdf0e10cSrcweir 	rStream >> nUnderlineVersion;
168cdf0e10cSrcweir     if ( nVer >= AUTOFORMAT_ID_300OVRLN )
169cdf0e10cSrcweir     	rStream >> nOverlineVersion;
170cdf0e10cSrcweir 	rStream >> nCrossedOutVersion;
171cdf0e10cSrcweir 	rStream >> nContourVersion;
172cdf0e10cSrcweir 	rStream >> nShadowedVersion;
173cdf0e10cSrcweir 	rStream >> nColorVersion;
174cdf0e10cSrcweir 	rStream >> nBoxVersion;
175cdf0e10cSrcweir     if ( nVer >= AUTOFORMAT_ID_680DR14 )
176cdf0e10cSrcweir         rStream >> nLineVersion;
177cdf0e10cSrcweir 	rStream >> nBrushVersion;
178cdf0e10cSrcweir 	rStream >> nAdjustVersion;
179cdf0e10cSrcweir 	rStream >> nHorJustifyVersion;
180cdf0e10cSrcweir 	rStream >> nVerJustifyVersion;
181cdf0e10cSrcweir 	rStream >> nOrientationVersion;
182cdf0e10cSrcweir 	rStream >> nMarginVersion;
183cdf0e10cSrcweir 	rStream >> nBoolVersion;
184cdf0e10cSrcweir 	if ( nVer >= AUTOFORMAT_ID_504 )
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir 		rStream >> nInt32Version;
187cdf0e10cSrcweir 		rStream >> nRotateModeVersion;
188cdf0e10cSrcweir 	}
189cdf0e10cSrcweir 	rStream >> nNumFmtVersion;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir //	---------------------------------------------------------------------------
193cdf0e10cSrcweir 
SwBoxAutoFmt()194cdf0e10cSrcweir SwBoxAutoFmt::SwBoxAutoFmt()
195cdf0e10cSrcweir 	: aFont( *(SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT ) ),
196cdf0e10cSrcweir     aHeight( 240, 100, RES_CHRATR_FONTSIZE ),
197cdf0e10cSrcweir     aWeight( WEIGHT_NORMAL, RES_CHRATR_WEIGHT ),
198cdf0e10cSrcweir     aPosture( ITALIC_NONE, RES_CHRATR_POSTURE ),
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     aCJKFont( *(SvxFontItem*)GetDfltAttr( RES_CHRATR_CJK_FONT ) ),
201cdf0e10cSrcweir     aCJKHeight( 240, 100, RES_CHRATR_CJK_FONTSIZE ),
202cdf0e10cSrcweir     aCJKWeight( WEIGHT_NORMAL, RES_CHRATR_CJK_WEIGHT ),
203cdf0e10cSrcweir     aCJKPosture( ITALIC_NONE, RES_CHRATR_CJK_POSTURE ),
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     aCTLFont( *(SvxFontItem*)GetDfltAttr( RES_CHRATR_CTL_FONT ) ),
206cdf0e10cSrcweir     aCTLHeight( 240, 100, RES_CHRATR_CTL_FONTSIZE ),
207cdf0e10cSrcweir     aCTLWeight( WEIGHT_NORMAL, RES_CHRATR_CTL_WEIGHT ),
208cdf0e10cSrcweir     aCTLPosture( ITALIC_NONE, RES_CHRATR_CTL_POSTURE ),
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     aUnderline( UNDERLINE_NONE, RES_CHRATR_UNDERLINE ),
211cdf0e10cSrcweir     aOverline( UNDERLINE_NONE, RES_CHRATR_OVERLINE ),
212cdf0e10cSrcweir     aCrossedOut( STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT ),
213cdf0e10cSrcweir     aContour( sal_False, RES_CHRATR_CONTOUR ),
214cdf0e10cSrcweir     aShadowed( sal_False, RES_CHRATR_SHADOWED ),
215cdf0e10cSrcweir     aColor( RES_CHRATR_COLOR ),
216cdf0e10cSrcweir     aBox( RES_BOX ),
217cdf0e10cSrcweir     aTLBR( 0 ),
218cdf0e10cSrcweir     aBLTR( 0 ),
219cdf0e10cSrcweir     aBackground( RES_BACKGROUND ),
220cdf0e10cSrcweir     aAdjust( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ),
221cdf0e10cSrcweir     aHorJustify( SVX_HOR_JUSTIFY_STANDARD, 0),
222cdf0e10cSrcweir     aVerJustify( SVX_VER_JUSTIFY_STANDARD, 0),
223cdf0e10cSrcweir     aStacked( 0 ),
224cdf0e10cSrcweir     aMargin( 0 ),
225cdf0e10cSrcweir     aLinebreak( 0 ),
226cdf0e10cSrcweir     aRotateAngle( 0 ),
227cdf0e10cSrcweir 
228cdf0e10cSrcweir // FIXME - add attribute IDs for the diagonal line items
229cdf0e10cSrcweir //    aTLBR( RES_... ),
230cdf0e10cSrcweir //    aBLTR( RES_... ),
231cdf0e10cSrcweir 	aRotateMode( SVX_ROTATE_MODE_STANDARD, 0 )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	eSysLanguage = eNumFmtLanguage = static_cast<LanguageType>(::GetAppLanguage());
234cdf0e10cSrcweir 	aBox.SetDistance( 55 );
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
SwBoxAutoFmt(const SwBoxAutoFmt & rNew)238cdf0e10cSrcweir SwBoxAutoFmt::SwBoxAutoFmt( const SwBoxAutoFmt& rNew )
239cdf0e10cSrcweir 	: aFont( rNew.aFont ),
240cdf0e10cSrcweir 	aHeight( rNew.aHeight ),
241cdf0e10cSrcweir 	aWeight( rNew.aWeight ),
242cdf0e10cSrcweir 	aPosture( rNew.aPosture ),
243cdf0e10cSrcweir     aCJKFont( rNew.aCJKFont ),
244cdf0e10cSrcweir     aCJKHeight( rNew.aCJKHeight ),
245cdf0e10cSrcweir     aCJKWeight( rNew.aCJKWeight ),
246cdf0e10cSrcweir     aCJKPosture( rNew.aCJKPosture ),
247cdf0e10cSrcweir     aCTLFont( rNew.aCTLFont ),
248cdf0e10cSrcweir     aCTLHeight( rNew.aCTLHeight ),
249cdf0e10cSrcweir     aCTLWeight( rNew.aCTLWeight ),
250cdf0e10cSrcweir     aCTLPosture( rNew.aCTLPosture ),
251cdf0e10cSrcweir 	aUnderline( rNew.aUnderline ),
252cdf0e10cSrcweir 	aOverline( rNew.aOverline ),
253cdf0e10cSrcweir 	aCrossedOut( rNew.aCrossedOut ),
254cdf0e10cSrcweir 	aContour( rNew.aContour ),
255cdf0e10cSrcweir 	aShadowed( rNew.aShadowed ),
256cdf0e10cSrcweir 	aColor( rNew.aColor ),
257cdf0e10cSrcweir 	aBox( rNew.aBox ),
258cdf0e10cSrcweir     aTLBR( rNew.aTLBR ),
259cdf0e10cSrcweir     aBLTR( rNew.aBLTR ),
260cdf0e10cSrcweir 	aBackground( rNew.aBackground ),
261cdf0e10cSrcweir 	aAdjust( rNew.aAdjust ),
262cdf0e10cSrcweir 	aHorJustify( rNew.aHorJustify ),
263cdf0e10cSrcweir 	aVerJustify( rNew.aVerJustify ),
264cdf0e10cSrcweir     aStacked( rNew.aStacked ),
265cdf0e10cSrcweir 	aMargin( rNew.aMargin ),
266cdf0e10cSrcweir 	aLinebreak( rNew.aLinebreak ),
267cdf0e10cSrcweir 	aRotateAngle( rNew.aRotateAngle ),
268cdf0e10cSrcweir 	aRotateMode( rNew.aRotateMode ),
269cdf0e10cSrcweir 	sNumFmtString( rNew.sNumFmtString ),
270cdf0e10cSrcweir 	eSysLanguage( rNew.eSysLanguage ),
271cdf0e10cSrcweir 	eNumFmtLanguage( rNew.eNumFmtLanguage )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 
~SwBoxAutoFmt()276cdf0e10cSrcweir SwBoxAutoFmt::~SwBoxAutoFmt()
277cdf0e10cSrcweir {
278cdf0e10cSrcweir }
279cdf0e10cSrcweir 
operator =(const SwBoxAutoFmt & rNew)280cdf0e10cSrcweir SwBoxAutoFmt& SwBoxAutoFmt::operator=( const SwBoxAutoFmt& rNew )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir 	aFont = rNew.aFont;
283cdf0e10cSrcweir 	aHeight = rNew.aHeight;
284cdf0e10cSrcweir 	aWeight = rNew.aWeight;
285cdf0e10cSrcweir 	aPosture = rNew.aPosture;
286cdf0e10cSrcweir     aCJKFont = rNew.aCJKFont;
287cdf0e10cSrcweir     aCJKHeight = rNew.aCJKHeight;
288cdf0e10cSrcweir     aCJKWeight = rNew.aCJKWeight;
289cdf0e10cSrcweir     aCJKPosture = rNew.aCJKPosture;
290cdf0e10cSrcweir     aCTLFont = rNew.aCTLFont;
291cdf0e10cSrcweir     aCTLHeight = rNew.aCTLHeight;
292cdf0e10cSrcweir     aCTLWeight = rNew.aCTLWeight;
293cdf0e10cSrcweir     aCTLPosture = rNew.aCTLPosture;
294cdf0e10cSrcweir 	aUnderline = rNew.aUnderline;
295cdf0e10cSrcweir 	aOverline = rNew.aOverline;
296cdf0e10cSrcweir 	aCrossedOut = rNew.aCrossedOut;
297cdf0e10cSrcweir 	aContour = rNew.aContour;
298cdf0e10cSrcweir 	aShadowed = rNew.aShadowed;
299cdf0e10cSrcweir 	aColor = rNew.aColor;
300cdf0e10cSrcweir 	SetAdjust( rNew.aAdjust );
301cdf0e10cSrcweir 	aBox = rNew.aBox;
302cdf0e10cSrcweir     aTLBR = rNew.aTLBR;
303cdf0e10cSrcweir     aBLTR = rNew.aBLTR;
304cdf0e10cSrcweir 	aBackground = rNew.aBackground;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	aHorJustify = rNew.aHorJustify;
307cdf0e10cSrcweir 	aVerJustify = rNew.aVerJustify;
308cdf0e10cSrcweir     aStacked.SetValue( rNew.aStacked.GetValue() );
309cdf0e10cSrcweir 	aMargin = rNew.aMargin;
310cdf0e10cSrcweir 	aLinebreak.SetValue( rNew.aLinebreak.GetValue() );
311cdf0e10cSrcweir 	aRotateAngle.SetValue( rNew.aRotateAngle.GetValue() );
312cdf0e10cSrcweir 	aRotateMode.SetValue( rNew.aRotateMode.GetValue() );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	sNumFmtString = rNew.sNumFmtString;
315cdf0e10cSrcweir 	eSysLanguage = rNew.eSysLanguage;
316cdf0e10cSrcweir 	eNumFmtLanguage = rNew.eNumFmtLanguage;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	return *this;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 
322cdf0e10cSrcweir #define READ( aItem, aItemType, nVers )\
323cdf0e10cSrcweir 	pNew = aItem.Create(rStream, nVers ); \
324cdf0e10cSrcweir 	aItem = *(aItemType*)pNew; \
325cdf0e10cSrcweir 	delete pNew;
326cdf0e10cSrcweir 
Load(SvStream & rStream,const SwAfVersions & rVersions,sal_uInt16 nVer)327cdf0e10cSrcweir sal_Bool SwBoxAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	SfxPoolItem* pNew;
330cdf0e10cSrcweir     SvxOrientationItem aOrientation( SVX_ORIENTATION_STANDARD, 0);
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     READ( aFont,        SvxFontItem            , rVersions.nFontVersion)
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	if( rStream.GetStreamCharSet() == aFont.GetCharSet() )
335cdf0e10cSrcweir         aFont.SetCharSet(::gsl_getSystemTextEncoding());
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     READ( aHeight,      SvxFontHeightItem  , rVersions.nFontHeightVersion)
338cdf0e10cSrcweir     READ( aWeight,      SvxWeightItem      , rVersions.nWeightVersion)
339cdf0e10cSrcweir     READ( aPosture,     SvxPostureItem     , rVersions.nPostureVersion)
340cdf0e10cSrcweir     // --- from 641 on: CJK and CTL font settings
341cdf0e10cSrcweir     if( AUTOFORMAT_DATA_ID_641 <= nVer )
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir         READ( aCJKFont,                        SvxFontItem         , rVersions.nFontVersion)
344cdf0e10cSrcweir         READ( aCJKHeight,       SvxFontHeightItem   , rVersions.nFontHeightVersion)
345cdf0e10cSrcweir         READ( aCJKWeight,     SvxWeightItem       , rVersions.nWeightVersion)
346cdf0e10cSrcweir         READ( aCJKPosture,   SvxPostureItem      , rVersions.nPostureVersion)
347cdf0e10cSrcweir         READ( aCTLFont,                        SvxFontItem         , rVersions.nFontVersion)
348cdf0e10cSrcweir         READ( aCTLHeight,        SvxFontHeightItem   , rVersions.nFontHeightVersion)
349cdf0e10cSrcweir         READ( aCTLWeight,       SvxWeightItem       , rVersions.nWeightVersion)
350cdf0e10cSrcweir         READ( aCTLPosture,   SvxPostureItem      , rVersions.nPostureVersion)
351cdf0e10cSrcweir     }
352cdf0e10cSrcweir     READ( aUnderline,   SvxUnderlineItem   , rVersions.nUnderlineVersion)
353cdf0e10cSrcweir     if( nVer >= AUTOFORMAT_DATA_ID_300OVRLN )
354cdf0e10cSrcweir     {
355cdf0e10cSrcweir         READ( aOverline,       SvxOverlineItem     , rVersions.nOverlineVersion)
356cdf0e10cSrcweir     }
357cdf0e10cSrcweir     READ( aCrossedOut,  SvxCrossedOutItem  , rVersions.nCrossedOutVersion)
358cdf0e10cSrcweir     READ( aContour,     SvxContourItem     , rVersions.nContourVersion)
359cdf0e10cSrcweir     READ( aShadowed,    SvxShadowedItem       , rVersions.nShadowedVersion)
360cdf0e10cSrcweir     READ( aColor,       SvxColorItem       , rVersions.nColorVersion)
361cdf0e10cSrcweir 
362cdf0e10cSrcweir     READ( aBox,         SvxBoxItem         , rVersions.nBoxVersion)
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     // --- from 680/dr14 on: diagonal frame lines
365cdf0e10cSrcweir     if( nVer >= AUTOFORMAT_DATA_ID_680DR14 )
366cdf0e10cSrcweir     {
367cdf0e10cSrcweir         READ( aTLBR, SvxLineItem, rVersions.nLineVersion)
368cdf0e10cSrcweir         READ( aBLTR, SvxLineItem, rVersions.nLineVersion)
369cdf0e10cSrcweir     }
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	READ( aBackground,  SvxBrushItem		, rVersions.nBrushVersion)
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	pNew = aAdjust.Create(rStream, rVersions.nAdjustVersion );
374cdf0e10cSrcweir 	SetAdjust( *(SvxAdjustItem*)pNew );
375cdf0e10cSrcweir 	delete pNew;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     READ( aHorJustify,  SvxHorJustifyItem , rVersions.nHorJustifyVersion)
378cdf0e10cSrcweir     READ( aVerJustify,  SvxVerJustifyItem   , rVersions.nVerJustifyVersion)
379cdf0e10cSrcweir     READ( aOrientation, SvxOrientationItem  , rVersions.nOrientationVersion)
380cdf0e10cSrcweir     READ( aMargin, SvxMarginItem       , rVersions.nMarginVersion)
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 	pNew = aLinebreak.Create(rStream, rVersions.nBoolVersion );
383cdf0e10cSrcweir 	aLinebreak.SetValue( ((SfxBoolItem*)pNew)->GetValue() );
384cdf0e10cSrcweir 	delete pNew;
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	if ( nVer >= AUTOFORMAT_DATA_ID_504 )
387cdf0e10cSrcweir 	{
388cdf0e10cSrcweir 		pNew = aRotateAngle.Create( rStream, rVersions.nInt32Version );
389cdf0e10cSrcweir 		aRotateAngle.SetValue( ((SfxInt32Item*)pNew)->GetValue() );
390cdf0e10cSrcweir 		delete pNew;
391cdf0e10cSrcweir 		pNew = aRotateMode.Create( rStream, rVersions.nRotateModeVersion );
392cdf0e10cSrcweir 		aRotateMode.SetValue( ((SvxRotateModeItem*)pNew)->GetValue() );
393cdf0e10cSrcweir 		delete pNew;
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	if( 0 == rVersions.nNumFmtVersion )
397cdf0e10cSrcweir 	{
398cdf0e10cSrcweir 		sal_uInt16 eSys, eLge;
399cdf0e10cSrcweir         // --- from 680/dr25 on: #21549# store strings as UTF-8
400cdf0e10cSrcweir         CharSet eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
401cdf0e10cSrcweir         rStream.ReadByteString( sNumFmtString, eCharSet )
402cdf0e10cSrcweir 				>> eSys >> eLge;
403cdf0e10cSrcweir 		eSysLanguage = (LanguageType) eSys;
404cdf0e10cSrcweir 		eNumFmtLanguage = (LanguageType) eLge;
405cdf0e10cSrcweir 		if ( eSysLanguage == LANGUAGE_SYSTEM )		// von alten Versionen (Calc)
406cdf0e10cSrcweir 			eSysLanguage = static_cast<LanguageType>(::GetAppLanguage());
407cdf0e10cSrcweir 	}
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     aStacked.SetValue( aOrientation.IsStacked() );
410cdf0e10cSrcweir     aRotateAngle.SetValue( aOrientation.GetRotation( aRotateAngle.GetValue() ) );
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 	return 0 == rStream.GetError();
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir #ifdef READ_OLDVERS
416cdf0e10cSrcweir 
LoadOld(SvStream & rStream,sal_uInt16 aLoadVer[])417cdf0e10cSrcweir sal_Bool SwBoxAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] )
418cdf0e10cSrcweir {
419cdf0e10cSrcweir 	SfxPoolItem* pNew;
420cdf0e10cSrcweir 	READ( aFont,        SvxFontItem			, 0)
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	if( rStream.GetStreamCharSet() == aFont.GetCharSet() )
423cdf0e10cSrcweir         aFont.SetCharSet(::gsl_getSystemTextEncoding());
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 	READ( aHeight,      SvxFontHeightItem	, 1)
426cdf0e10cSrcweir 	READ( aWeight,      SvxWeightItem		, 2)
427cdf0e10cSrcweir 	READ( aPosture,     SvxPostureItem	    , 3)
428cdf0e10cSrcweir 	READ( aUnderline,   SvxUnderlineItem	, 4)
429cdf0e10cSrcweir 	READ( aCrossedOut,  SvxCrossedOutItem	, 5)
430cdf0e10cSrcweir 	READ( aContour,     SvxContourItem	    , 6)
431cdf0e10cSrcweir 	READ( aShadowed,    SvxShadowedItem	    , 7)
432cdf0e10cSrcweir 	READ( aColor,       SvxColorItem		, 8)
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	pNew = aAdjust.Create(rStream, aLoadVer[ 9 ] );
435cdf0e10cSrcweir 	SetAdjust( *(SvxAdjustItem*)pNew );
436cdf0e10cSrcweir 	delete pNew;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 	READ( aBox,         SvxBoxItem		    , 10)
439cdf0e10cSrcweir 	READ( aBackground,  SvxBrushItem		, 11)
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 	return 0 == rStream.GetError();
442cdf0e10cSrcweir }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir #endif
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 
Save(SvStream & rStream) const447cdf0e10cSrcweir sal_Bool SwBoxAutoFmt::Save( SvStream& rStream ) const
448cdf0e10cSrcweir {
449cdf0e10cSrcweir     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 	aFont.Store( rStream, aFont.GetVersion(SOFFICE_FILEFORMAT_40)  );
452cdf0e10cSrcweir 	aHeight.Store( rStream, aHeight.GetVersion(SOFFICE_FILEFORMAT_40) );
453cdf0e10cSrcweir 	aWeight.Store( rStream, aWeight.GetVersion(SOFFICE_FILEFORMAT_40) );
454cdf0e10cSrcweir 	aPosture.Store( rStream, aPosture.GetVersion(SOFFICE_FILEFORMAT_40) );
455cdf0e10cSrcweir     aCJKFont.Store( rStream, aCJKFont.GetVersion(SOFFICE_FILEFORMAT_40)  );
456cdf0e10cSrcweir     aCJKHeight.Store( rStream, aCJKHeight.GetVersion(SOFFICE_FILEFORMAT_40) );
457cdf0e10cSrcweir     aCJKWeight.Store( rStream, aCJKWeight.GetVersion(SOFFICE_FILEFORMAT_40) );
458cdf0e10cSrcweir     aCJKPosture.Store( rStream, aCJKPosture.GetVersion(SOFFICE_FILEFORMAT_40) );
459cdf0e10cSrcweir     aCTLFont.Store( rStream, aCTLFont.GetVersion(SOFFICE_FILEFORMAT_40)  );
460cdf0e10cSrcweir     aCTLHeight.Store( rStream, aCTLHeight.GetVersion(SOFFICE_FILEFORMAT_40) );
461cdf0e10cSrcweir     aCTLWeight.Store( rStream, aCTLWeight.GetVersion(SOFFICE_FILEFORMAT_40) );
462cdf0e10cSrcweir     aCTLPosture.Store( rStream, aCTLPosture.GetVersion(SOFFICE_FILEFORMAT_40) );
463cdf0e10cSrcweir 	aUnderline.Store( rStream, aUnderline.GetVersion(SOFFICE_FILEFORMAT_40) );
464cdf0e10cSrcweir 	aOverline.Store( rStream, aOverline.GetVersion(SOFFICE_FILEFORMAT_40) );
465cdf0e10cSrcweir 	aCrossedOut.Store( rStream, aCrossedOut.GetVersion(SOFFICE_FILEFORMAT_40) );
466cdf0e10cSrcweir 	aContour.Store( rStream, aContour.GetVersion(SOFFICE_FILEFORMAT_40) );
467cdf0e10cSrcweir 	aShadowed.Store( rStream, aShadowed.GetVersion(SOFFICE_FILEFORMAT_40) );
468cdf0e10cSrcweir 	aColor.Store( rStream, aColor.GetVersion(SOFFICE_FILEFORMAT_40) );
469cdf0e10cSrcweir 	aBox.Store( rStream, aBox.GetVersion(SOFFICE_FILEFORMAT_40) );
470cdf0e10cSrcweir     aTLBR.Store( rStream, aTLBR.GetVersion(SOFFICE_FILEFORMAT_40) );
471cdf0e10cSrcweir     aBLTR.Store( rStream, aBLTR.GetVersion(SOFFICE_FILEFORMAT_40) );
472cdf0e10cSrcweir 	aBackground.Store( rStream, aBackground.GetVersion(SOFFICE_FILEFORMAT_40) );
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 	aAdjust.Store( rStream, aAdjust.GetVersion(SOFFICE_FILEFORMAT_40) );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	aHorJustify.Store( rStream, aHorJustify.GetVersion(SOFFICE_FILEFORMAT_40) );
477cdf0e10cSrcweir 	aVerJustify.Store( rStream, aVerJustify.GetVersion(SOFFICE_FILEFORMAT_40) );
478cdf0e10cSrcweir 	aOrientation.Store( rStream, aOrientation.GetVersion(SOFFICE_FILEFORMAT_40) );
479cdf0e10cSrcweir 	aMargin.Store( rStream, aMargin.GetVersion(SOFFICE_FILEFORMAT_40) );
480cdf0e10cSrcweir 	aLinebreak.Store( rStream, aLinebreak.GetVersion(SOFFICE_FILEFORMAT_40) );
481cdf0e10cSrcweir 	// Calc Rotation ab SO5
482cdf0e10cSrcweir 	aRotateAngle.Store( rStream, aRotateAngle.GetVersion(SOFFICE_FILEFORMAT_40) );
483cdf0e10cSrcweir 	aRotateMode.Store( rStream, aRotateMode.GetVersion(SOFFICE_FILEFORMAT_40) );
484cdf0e10cSrcweir 
485cdf0e10cSrcweir     // --- from 680/dr25 on: #21549# store strings as UTF-8
486cdf0e10cSrcweir     rStream.WriteByteString( sNumFmtString, RTL_TEXTENCODING_UTF8 )
487cdf0e10cSrcweir 		<< (sal_uInt16)eSysLanguage << (sal_uInt16)eNumFmtLanguage;
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 	return 0 == rStream.GetError();
490cdf0e10cSrcweir }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 
SaveVerionNo(SvStream & rStream) const493cdf0e10cSrcweir sal_Bool SwBoxAutoFmt::SaveVerionNo( SvStream& rStream ) const
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	rStream << aFont.GetVersion( SOFFICE_FILEFORMAT_40 );
496cdf0e10cSrcweir 	rStream << aHeight.GetVersion( SOFFICE_FILEFORMAT_40 );
497cdf0e10cSrcweir 	rStream << aWeight.GetVersion( SOFFICE_FILEFORMAT_40 );
498cdf0e10cSrcweir 	rStream << aPosture.GetVersion( SOFFICE_FILEFORMAT_40 );
499cdf0e10cSrcweir 	rStream << aUnderline.GetVersion( SOFFICE_FILEFORMAT_40 );
500cdf0e10cSrcweir 	rStream << aOverline.GetVersion( SOFFICE_FILEFORMAT_40 );
501cdf0e10cSrcweir 	rStream << aCrossedOut.GetVersion( SOFFICE_FILEFORMAT_40 );
502cdf0e10cSrcweir 	rStream << aContour.GetVersion( SOFFICE_FILEFORMAT_40 );
503cdf0e10cSrcweir 	rStream << aShadowed.GetVersion( SOFFICE_FILEFORMAT_40 );
504cdf0e10cSrcweir 	rStream << aColor.GetVersion( SOFFICE_FILEFORMAT_40 );
505cdf0e10cSrcweir 	rStream << aBox.GetVersion( SOFFICE_FILEFORMAT_40 );
506cdf0e10cSrcweir     rStream << aTLBR.GetVersion( SOFFICE_FILEFORMAT_40 );
507cdf0e10cSrcweir 	rStream << aBackground.GetVersion( SOFFICE_FILEFORMAT_40 );
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 	rStream << aAdjust.GetVersion( SOFFICE_FILEFORMAT_40 );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 	rStream << aHorJustify.GetVersion( SOFFICE_FILEFORMAT_40 );
512cdf0e10cSrcweir 	rStream << aVerJustify.GetVersion( SOFFICE_FILEFORMAT_40 );
513cdf0e10cSrcweir     rStream << SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion( SOFFICE_FILEFORMAT_40 );
514cdf0e10cSrcweir 	rStream << aMargin.GetVersion( SOFFICE_FILEFORMAT_40 );
515cdf0e10cSrcweir 	rStream << aLinebreak.GetVersion( SOFFICE_FILEFORMAT_40 );
516cdf0e10cSrcweir 	rStream << aRotateAngle.GetVersion( SOFFICE_FILEFORMAT_40 );
517cdf0e10cSrcweir 	rStream << aRotateMode.GetVersion( SOFFICE_FILEFORMAT_40 );
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 	rStream << (sal_uInt16)0;		// NumberFormat
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 	return 0 == rStream.GetError();
522cdf0e10cSrcweir }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir /*  */
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 
SwTableAutoFmt(const String & rName)527cdf0e10cSrcweir SwTableAutoFmt::SwTableAutoFmt( const String& rName )
528cdf0e10cSrcweir 	: aName( rName ), nStrResId( USHRT_MAX )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir 	bInclFont = sal_True;
531cdf0e10cSrcweir 	bInclJustify = sal_True;
532cdf0e10cSrcweir 	bInclFrame = sal_True;
533cdf0e10cSrcweir 	bInclBackground = sal_True;
534cdf0e10cSrcweir 	bInclValueFormat = sal_True;
535cdf0e10cSrcweir 	bInclWidthHeight = sal_True;
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 	memset( aBoxAutoFmt, 0, sizeof( aBoxAutoFmt ) );
538cdf0e10cSrcweir }
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 
SwTableAutoFmt(const SwTableAutoFmt & rNew)541cdf0e10cSrcweir SwTableAutoFmt::SwTableAutoFmt( const SwTableAutoFmt& rNew )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir 	for( sal_uInt8 n = 0; n < 16; ++n )
544cdf0e10cSrcweir 		aBoxAutoFmt[ n ] = 0;
545cdf0e10cSrcweir 	*this = rNew;
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
operator =(const SwTableAutoFmt & rNew)548cdf0e10cSrcweir SwTableAutoFmt& SwTableAutoFmt::operator=( const SwTableAutoFmt& rNew )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir 	for( sal_uInt8 n = 0; n < 16; ++n )
551cdf0e10cSrcweir 	{
552cdf0e10cSrcweir 		if( aBoxAutoFmt[ n ] )
553cdf0e10cSrcweir 			delete aBoxAutoFmt[ n ];
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 		SwBoxAutoFmt* pFmt = rNew.aBoxAutoFmt[ n ];
556cdf0e10cSrcweir 		if( pFmt )		// ist gesetzt -> kopieren
557cdf0e10cSrcweir 			aBoxAutoFmt[ n ] = new SwBoxAutoFmt( *pFmt );
558cdf0e10cSrcweir 		else			// sonst default
559cdf0e10cSrcweir 			aBoxAutoFmt[ n ] = 0;
560cdf0e10cSrcweir 	}
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 	aName = rNew.aName;
563cdf0e10cSrcweir 	nStrResId = rNew.nStrResId;
564cdf0e10cSrcweir 	bInclFont = rNew.bInclFont;
565cdf0e10cSrcweir 	bInclJustify = rNew.bInclJustify;
566cdf0e10cSrcweir 	bInclFrame = rNew.bInclFrame;
567cdf0e10cSrcweir 	bInclBackground = rNew.bInclBackground;
568cdf0e10cSrcweir 	bInclValueFormat = rNew.bInclValueFormat;
569cdf0e10cSrcweir 	bInclWidthHeight = rNew.bInclWidthHeight;
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 	return *this;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 
~SwTableAutoFmt()575cdf0e10cSrcweir SwTableAutoFmt::~SwTableAutoFmt()
576cdf0e10cSrcweir {
577cdf0e10cSrcweir 	SwBoxAutoFmt** ppFmt = aBoxAutoFmt;
578cdf0e10cSrcweir 	for( sal_uInt8 n = 0; n < 16; ++n, ++ppFmt )
579cdf0e10cSrcweir 		if( *ppFmt )
580cdf0e10cSrcweir 			delete *ppFmt;
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 
SetBoxFmt(const SwBoxAutoFmt & rNew,sal_uInt8 nPos)584cdf0e10cSrcweir void SwTableAutoFmt::SetBoxFmt( const SwBoxAutoFmt& rNew, sal_uInt8 nPos )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir 	ASSERT( nPos < 16, "falscher Bereich" );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	SwBoxAutoFmt* pFmt = aBoxAutoFmt[ nPos ];
589cdf0e10cSrcweir 	if( pFmt )		// ist gesetzt -> kopieren
590cdf0e10cSrcweir 		*aBoxAutoFmt[ nPos ] = rNew;
591cdf0e10cSrcweir 	else			// sonst neu setzen
592cdf0e10cSrcweir 		aBoxAutoFmt[ nPos ] = new SwBoxAutoFmt( rNew );
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 
GetBoxFmt(sal_uInt8 nPos) const596cdf0e10cSrcweir const SwBoxAutoFmt& SwTableAutoFmt::GetBoxFmt( sal_uInt8 nPos ) const
597cdf0e10cSrcweir {
598cdf0e10cSrcweir 	ASSERT( nPos < 16, "falscher Bereich" );
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 	SwBoxAutoFmt* pFmt = aBoxAutoFmt[ nPos ];
601cdf0e10cSrcweir 	if( pFmt )		// ist gesetzt -> kopieren
602cdf0e10cSrcweir 		return *pFmt;
603cdf0e10cSrcweir 	else			// sonst den default returnen
604cdf0e10cSrcweir 	{
605cdf0e10cSrcweir 		// falls noch nicht vorhanden:
606cdf0e10cSrcweir 		if( !pDfltBoxAutoFmt )
607cdf0e10cSrcweir 			pDfltBoxAutoFmt = new SwBoxAutoFmt;
608cdf0e10cSrcweir 		return *pDfltBoxAutoFmt;
609cdf0e10cSrcweir 	}
610cdf0e10cSrcweir }
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 
UpdateFromSet(sal_uInt8 nPos,const SfxItemSet & rSet,UpdateFlags eFlags,SvNumberFormatter * pNFmtr)614cdf0e10cSrcweir SwBoxAutoFmt& SwTableAutoFmt::UpdateFromSet( sal_uInt8 nPos,
615cdf0e10cSrcweir 											const SfxItemSet& rSet,
616cdf0e10cSrcweir 											UpdateFlags eFlags,
617cdf0e10cSrcweir 											SvNumberFormatter* pNFmtr )
618cdf0e10cSrcweir {
619cdf0e10cSrcweir 	ASSERT( nPos < 16, "falscher Bereich" );
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 	SwBoxAutoFmt* pFmt = aBoxAutoFmt[ nPos ];
622cdf0e10cSrcweir 	if( !pFmt )		// ist gesetzt -> kopieren
623cdf0e10cSrcweir 	{
624cdf0e10cSrcweir 		pFmt = new SwBoxAutoFmt;
625cdf0e10cSrcweir 		aBoxAutoFmt[ nPos ] = pFmt;
626cdf0e10cSrcweir 	}
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 	if( UPDATE_CHAR & eFlags )
629cdf0e10cSrcweir 	{
630cdf0e10cSrcweir 		pFmt->SetFont( (SvxFontItem&)rSet.Get( RES_CHRATR_FONT ) );
631cdf0e10cSrcweir 		pFmt->SetHeight( (SvxFontHeightItem&)rSet.Get( RES_CHRATR_FONTSIZE ) );
632cdf0e10cSrcweir 		pFmt->SetWeight( (SvxWeightItem&)rSet.Get( RES_CHRATR_WEIGHT ) );
633cdf0e10cSrcweir 		pFmt->SetPosture( (SvxPostureItem&)rSet.Get( RES_CHRATR_POSTURE ) );
634cdf0e10cSrcweir         pFmt->SetCJKFont( (SvxFontItem&)rSet.Get( RES_CHRATR_CJK_FONT ) );
635cdf0e10cSrcweir         pFmt->SetCJKHeight( (SvxFontHeightItem&)rSet.Get( RES_CHRATR_CJK_FONTSIZE ) );
636cdf0e10cSrcweir         pFmt->SetCJKWeight( (SvxWeightItem&)rSet.Get( RES_CHRATR_CJK_WEIGHT ) );
637cdf0e10cSrcweir         pFmt->SetCJKPosture( (SvxPostureItem&)rSet.Get( RES_CHRATR_CJK_POSTURE ) );
638cdf0e10cSrcweir         pFmt->SetCTLFont( (SvxFontItem&)rSet.Get( RES_CHRATR_CTL_FONT ) );
639cdf0e10cSrcweir         pFmt->SetCTLHeight( (SvxFontHeightItem&)rSet.Get( RES_CHRATR_CTL_FONTSIZE ) );
640cdf0e10cSrcweir         pFmt->SetCTLWeight( (SvxWeightItem&)rSet.Get( RES_CHRATR_CTL_WEIGHT ) );
641cdf0e10cSrcweir         pFmt->SetCTLPosture( (SvxPostureItem&)rSet.Get( RES_CHRATR_CTL_POSTURE ) );
642cdf0e10cSrcweir 		pFmt->SetUnderline( (SvxUnderlineItem&)rSet.Get( RES_CHRATR_UNDERLINE ) );
643cdf0e10cSrcweir 		pFmt->SetOverline( (SvxOverlineItem&)rSet.Get( RES_CHRATR_OVERLINE ) );
644cdf0e10cSrcweir 		pFmt->SetCrossedOut( (SvxCrossedOutItem&)rSet.Get( RES_CHRATR_CROSSEDOUT ) );
645cdf0e10cSrcweir 		pFmt->SetContour( (SvxContourItem&)rSet.Get( RES_CHRATR_CONTOUR ) );
646cdf0e10cSrcweir 		pFmt->SetShadowed( (SvxShadowedItem&)rSet.Get( RES_CHRATR_SHADOWED ) );
647cdf0e10cSrcweir 		pFmt->SetColor( (SvxColorItem&)rSet.Get( RES_CHRATR_COLOR ) );
648cdf0e10cSrcweir 		pFmt->SetAdjust( (SvxAdjustItem&)rSet.Get( RES_PARATR_ADJUST ) );
649cdf0e10cSrcweir 	}
650cdf0e10cSrcweir 	if( UPDATE_BOX & eFlags )
651cdf0e10cSrcweir 	{
652cdf0e10cSrcweir 		pFmt->SetBox( (SvxBoxItem&)rSet.Get( RES_BOX ) );
653cdf0e10cSrcweir // FIXME - add attribute IDs for the diagonal line items
654cdf0e10cSrcweir //        pFmt->SetTLBR( (SvxLineItem&)rSet.Get( RES_... ) );
655cdf0e10cSrcweir //        pFmt->SetBLTR( (SvxLineItem&)rSet.Get( RES_... ) );
656cdf0e10cSrcweir 		pFmt->SetBackground( (SvxBrushItem&)rSet.Get( RES_BACKGROUND ) );
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 		const SwTblBoxNumFormat* pNumFmtItem;
659cdf0e10cSrcweir 		const SvNumberformat* pNumFormat = 0;
660cdf0e10cSrcweir 		if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMAT, sal_True,
661cdf0e10cSrcweir 			(const SfxPoolItem**)&pNumFmtItem ) && pNFmtr &&
662cdf0e10cSrcweir 			0 != (pNumFormat = pNFmtr->GetEntry( pNumFmtItem->GetValue() )) )
663cdf0e10cSrcweir 			pFmt->SetValueFormat( ((SvNumberformat*)pNumFormat)->GetFormatstring(),
664cdf0e10cSrcweir 									pNumFormat->GetLanguage(),
665cdf0e10cSrcweir 									static_cast<LanguageType>(::GetAppLanguage()));
666cdf0e10cSrcweir 		else
667cdf0e10cSrcweir 		{
668cdf0e10cSrcweir 			// defaulten
669cdf0e10cSrcweir 			pFmt->SetValueFormat( aEmptyStr, LANGUAGE_SYSTEM,
670cdf0e10cSrcweir 								  static_cast<LanguageType>(::GetAppLanguage() ));
671cdf0e10cSrcweir 		}
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir 	// den Rest koennen wir nicht, StarCalc spezifisch
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 	return *pFmt;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 
UpdateToSet(sal_uInt8 nPos,SfxItemSet & rSet,UpdateFlags eFlags,SvNumberFormatter * pNFmtr) const679cdf0e10cSrcweir void SwTableAutoFmt::UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet,
680cdf0e10cSrcweir 				UpdateFlags eFlags, SvNumberFormatter* pNFmtr ) const
681cdf0e10cSrcweir {
682cdf0e10cSrcweir 	const SwBoxAutoFmt& rChg = GetBoxFmt( nPos );
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	if( UPDATE_CHAR & eFlags )
685cdf0e10cSrcweir 	{
686cdf0e10cSrcweir 		if( IsFont() )
687cdf0e10cSrcweir 		{
688cdf0e10cSrcweir 			rSet.Put( rChg.GetFont() );
689cdf0e10cSrcweir 			rSet.Put( rChg.GetHeight() );
690cdf0e10cSrcweir 			rSet.Put( rChg.GetWeight() );
691cdf0e10cSrcweir 			rSet.Put( rChg.GetPosture() );
692cdf0e10cSrcweir             // #103065# do not insert empty CJK font
693cdf0e10cSrcweir             const SvxFontItem& rCJKFont = rChg.GetCJKFont();
694cdf0e10cSrcweir             if( rCJKFont.GetStyleName().Len() )
695cdf0e10cSrcweir             {
696cdf0e10cSrcweir                 rSet.Put( rChg.GetCJKFont() );
697cdf0e10cSrcweir                 rSet.Put( rChg.GetCJKHeight() );
698cdf0e10cSrcweir                 rSet.Put( rChg.GetCJKWeight() );
699cdf0e10cSrcweir                 rSet.Put( rChg.GetCJKPosture() );
700cdf0e10cSrcweir             }
701cdf0e10cSrcweir             else
702cdf0e10cSrcweir             {
703cdf0e10cSrcweir                 rSet.Put( rChg.GetHeight(), RES_CHRATR_CJK_FONTSIZE );
704cdf0e10cSrcweir                 rSet.Put( rChg.GetWeight(), RES_CHRATR_CJK_WEIGHT );
705cdf0e10cSrcweir                 rSet.Put( rChg.GetPosture(), RES_CHRATR_CJK_POSTURE );
706cdf0e10cSrcweir             }
707cdf0e10cSrcweir             // #103065# do not insert empty CTL font
708cdf0e10cSrcweir             const SvxFontItem& rCTLFont = rChg.GetCTLFont();
709cdf0e10cSrcweir             if( rCTLFont.GetStyleName().Len() )
710cdf0e10cSrcweir             {
711cdf0e10cSrcweir                 rSet.Put( rChg.GetCTLFont() );
712cdf0e10cSrcweir                 rSet.Put( rChg.GetCTLHeight() );
713cdf0e10cSrcweir                 rSet.Put( rChg.GetCTLWeight() );
714cdf0e10cSrcweir                 rSet.Put( rChg.GetCTLPosture() );
715cdf0e10cSrcweir             }
716cdf0e10cSrcweir             else
717cdf0e10cSrcweir             {
718cdf0e10cSrcweir                 rSet.Put( rChg.GetHeight(), RES_CHRATR_CTL_FONTSIZE );
719cdf0e10cSrcweir                 rSet.Put( rChg.GetWeight(), RES_CHRATR_CTL_WEIGHT );
720cdf0e10cSrcweir                 rSet.Put( rChg.GetPosture(), RES_CHRATR_CTL_POSTURE );
721cdf0e10cSrcweir             }
722cdf0e10cSrcweir 			rSet.Put( rChg.GetUnderline() );
723cdf0e10cSrcweir 			rSet.Put( rChg.GetOverline() );
724cdf0e10cSrcweir 			rSet.Put( rChg.GetCrossedOut() );
725cdf0e10cSrcweir 			rSet.Put( rChg.GetContour() );
726cdf0e10cSrcweir 			rSet.Put( rChg.GetShadowed() );
727cdf0e10cSrcweir 			rSet.Put( rChg.GetColor() );
728cdf0e10cSrcweir 		}
729cdf0e10cSrcweir 		if( IsJustify() )
730cdf0e10cSrcweir 			rSet.Put( rChg.GetAdjust() );
731cdf0e10cSrcweir 	}
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 	if( UPDATE_BOX & eFlags )
734cdf0e10cSrcweir 	{
735cdf0e10cSrcweir 		if( IsFrame() )
736cdf0e10cSrcweir         {
737cdf0e10cSrcweir 			rSet.Put( rChg.GetBox() );
738cdf0e10cSrcweir // FIXME - uncomment the lines to put the diagonal line items
739cdf0e10cSrcweir //            rSet.Put( rChg.GetTLBR() );
740cdf0e10cSrcweir //            rSet.Put( rChg.GetBLTR() );
741cdf0e10cSrcweir         }
742cdf0e10cSrcweir 		if( IsBackground() )
743cdf0e10cSrcweir 			rSet.Put( rChg.GetBackground() );
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 		if( IsValueFormat() && pNFmtr )
746cdf0e10cSrcweir 		{
747cdf0e10cSrcweir 			String sFmt; LanguageType eLng, eSys;
748cdf0e10cSrcweir 			rChg.GetValueFormat( sFmt, eLng, eSys );
749cdf0e10cSrcweir 			if( sFmt.Len() )
750cdf0e10cSrcweir 			{
751cdf0e10cSrcweir                 short nType;
752cdf0e10cSrcweir                 sal_Bool bNew;
753cdf0e10cSrcweir                 xub_StrLen nCheckPos;
754cdf0e10cSrcweir                 sal_uInt32 nKey = pNFmtr->GetIndexPuttingAndConverting( sFmt, eLng,
755cdf0e10cSrcweir                         eSys, nType, bNew, nCheckPos);
756cdf0e10cSrcweir 				rSet.Put( SwTblBoxNumFormat( nKey ));
757cdf0e10cSrcweir 			}
758cdf0e10cSrcweir 			else
759cdf0e10cSrcweir 				rSet.ClearItem( RES_BOXATR_FORMAT );
760cdf0e10cSrcweir 		}
761cdf0e10cSrcweir 	}
762cdf0e10cSrcweir 
763cdf0e10cSrcweir 	// den Rest koennen wir nicht, StarCalc spezifisch
764cdf0e10cSrcweir }
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 
Load(SvStream & rStream,const SwAfVersions & rVersions)767cdf0e10cSrcweir sal_Bool SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir 	sal_Bool	bRet = sal_True;
770cdf0e10cSrcweir 	sal_uInt16	nVal = 0;
771cdf0e10cSrcweir 	rStream >> nVal;
772cdf0e10cSrcweir 	bRet = 0 == rStream.GetError();
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 	if( bRet && (nVal == AUTOFORMAT_DATA_ID_X ||
775cdf0e10cSrcweir 			(AUTOFORMAT_DATA_ID_504 <= nVal && nVal <= AUTOFORMAT_DATA_ID)) )
776cdf0e10cSrcweir 	{
777cdf0e10cSrcweir 		sal_Bool b;
778cdf0e10cSrcweir         // --- from 680/dr25 on: #21549# store strings as UTF-8
779cdf0e10cSrcweir         CharSet eCharSet = (nVal >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
780cdf0e10cSrcweir         rStream.ReadByteString( aName, eCharSet );
781cdf0e10cSrcweir 		if( AUTOFORMAT_DATA_ID_552 <= nVal )
782cdf0e10cSrcweir 		{
783cdf0e10cSrcweir 			rStream >> nStrResId;
784cdf0e10cSrcweir 			sal_uInt16 nId = RID_SVXSTR_TBLAFMT_BEGIN + nStrResId;
785cdf0e10cSrcweir 			if( RID_SVXSTR_TBLAFMT_BEGIN <= nId &&
786cdf0e10cSrcweir 				nId < RID_SVXSTR_TBLAFMT_END )
787cdf0e10cSrcweir 			{
788cdf0e10cSrcweir 				aName = SVX_RESSTR( nId );
789cdf0e10cSrcweir 			}
790cdf0e10cSrcweir 			else
791cdf0e10cSrcweir 				nStrResId = USHRT_MAX;
792cdf0e10cSrcweir 		}
793cdf0e10cSrcweir 		rStream >> b; bInclFont = b;
794cdf0e10cSrcweir 		rStream >> b; bInclJustify = b;
795cdf0e10cSrcweir 		rStream >> b; bInclFrame = b;
796cdf0e10cSrcweir 		rStream >> b; bInclBackground = b;
797cdf0e10cSrcweir 		rStream >> b; bInclValueFormat = b;
798cdf0e10cSrcweir 		rStream >> b; bInclWidthHeight = b;
799cdf0e10cSrcweir 
800cdf0e10cSrcweir 		bRet = 0 == rStream.GetError();
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 		for( sal_uInt8 i = 0; i < 16; ++i )
803cdf0e10cSrcweir 		{
804cdf0e10cSrcweir 			SwBoxAutoFmt* pFmt = new SwBoxAutoFmt;
805cdf0e10cSrcweir 			bRet = pFmt->Load( rStream, rVersions, nVal );
806cdf0e10cSrcweir 			if( bRet )
807cdf0e10cSrcweir 				aBoxAutoFmt[ i ] = pFmt;
808cdf0e10cSrcweir 			else
809cdf0e10cSrcweir 			{
810cdf0e10cSrcweir 				delete pFmt;
811cdf0e10cSrcweir 				break;
812cdf0e10cSrcweir 			}
813cdf0e10cSrcweir 		}
814cdf0e10cSrcweir 	}
815cdf0e10cSrcweir 	return bRet;
816cdf0e10cSrcweir }
817cdf0e10cSrcweir 
818cdf0e10cSrcweir #ifdef READ_OLDVERS
819cdf0e10cSrcweir 
LoadOld(SvStream & rStream,sal_uInt16 aLoadVer[])820cdf0e10cSrcweir sal_Bool SwTableAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir 	sal_Bool	bRet = sal_True;
823cdf0e10cSrcweir 	sal_uInt16	nVal = 0;
824cdf0e10cSrcweir 	rStream >> nVal;
825cdf0e10cSrcweir 	bRet = 0 == rStream.GetError();
826cdf0e10cSrcweir 
827cdf0e10cSrcweir 	if( bRet && ( AUTOFORMAT_OLD_DATA_ID == nVal ))
828cdf0e10cSrcweir 	{
829cdf0e10cSrcweir 		sal_Bool b;
830cdf0e10cSrcweir 		rStream.ReadByteString( aName, rStream.GetStreamCharSet() );
831cdf0e10cSrcweir 		rStream >> b; bInclFont = b;
832cdf0e10cSrcweir 		rStream >> b; bInclJustify = b;
833cdf0e10cSrcweir 		rStream >> b; bInclFrame = b;
834cdf0e10cSrcweir 		rStream >> b; bInclBackground = b;
835cdf0e10cSrcweir 		bRet = (rStream.GetError() == 0);
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 		for( int i = 0; i < 16; i++)
838cdf0e10cSrcweir 		{
839cdf0e10cSrcweir 			SwBoxAutoFmt* pFmt = new SwBoxAutoFmt;
840cdf0e10cSrcweir 			bRet = pFmt->LoadOld( rStream, aLoadVer );
841cdf0e10cSrcweir 			if( bRet )
842cdf0e10cSrcweir 				aBoxAutoFmt[ i ] = pFmt;
843cdf0e10cSrcweir 			else
844cdf0e10cSrcweir 			{
845cdf0e10cSrcweir 				delete pFmt;
846cdf0e10cSrcweir 				break;
847cdf0e10cSrcweir 			}
848cdf0e10cSrcweir 		}
849cdf0e10cSrcweir 	}
850cdf0e10cSrcweir 	return bRet;
851cdf0e10cSrcweir }
852cdf0e10cSrcweir #endif
853cdf0e10cSrcweir 
854cdf0e10cSrcweir 
Save(SvStream & rStream) const855cdf0e10cSrcweir sal_Bool SwTableAutoFmt::Save( SvStream& rStream ) const
856cdf0e10cSrcweir {
857cdf0e10cSrcweir 	sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
858cdf0e10cSrcweir 	sal_Bool b;
859cdf0e10cSrcweir 	rStream << nVal;
860cdf0e10cSrcweir     // --- from 680/dr25 on: #21549# store strings as UTF-8
861cdf0e10cSrcweir     rStream.WriteByteString( aName, RTL_TEXTENCODING_UTF8 );
862cdf0e10cSrcweir 	rStream << nStrResId;
863cdf0e10cSrcweir 	rStream << ( b = bInclFont );
864cdf0e10cSrcweir 	rStream << ( b = bInclJustify );
865cdf0e10cSrcweir 	rStream << ( b = bInclFrame );
866cdf0e10cSrcweir 	rStream << ( b = bInclBackground );
867cdf0e10cSrcweir 	rStream << ( b = bInclValueFormat );
868cdf0e10cSrcweir 	rStream << ( b = bInclWidthHeight );
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 	sal_Bool bRet = 0 == rStream.GetError();
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 	for( int i = 0; bRet && i < 16; ++i )
873cdf0e10cSrcweir 	{
874cdf0e10cSrcweir 		SwBoxAutoFmt* pFmt = aBoxAutoFmt[ i ];
875cdf0e10cSrcweir 		if( !pFmt )		// nicht gesetzt -> default schreiben
876cdf0e10cSrcweir 		{
877cdf0e10cSrcweir 			// falls noch nicht vorhanden:
878cdf0e10cSrcweir 			if( !pDfltBoxAutoFmt )
879cdf0e10cSrcweir 				pDfltBoxAutoFmt = new SwBoxAutoFmt;
880cdf0e10cSrcweir 			pFmt = pDfltBoxAutoFmt;
881cdf0e10cSrcweir 		}
882cdf0e10cSrcweir 		bRet = pFmt->Save( rStream );
883cdf0e10cSrcweir 	}
884cdf0e10cSrcweir 	return bRet;
885cdf0e10cSrcweir }
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 
SwTableAutoFmtTbl()888cdf0e10cSrcweir SwTableAutoFmtTbl::SwTableAutoFmtTbl()
889cdf0e10cSrcweir {
890cdf0e10cSrcweir 	String sNm;
891cdf0e10cSrcweir 	SwTableAutoFmt* pNew = new SwTableAutoFmt(
892cdf0e10cSrcweir 							SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD, sNm ) );
893cdf0e10cSrcweir 
894cdf0e10cSrcweir 	SwBoxAutoFmt aNew;
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 	sal_uInt8 i;
897cdf0e10cSrcweir 
898cdf0e10cSrcweir 	Color aColor( COL_BLUE );
899cdf0e10cSrcweir     SvxBrushItem aBrushItem( aColor, RES_BACKGROUND );
900cdf0e10cSrcweir 	aNew.SetBackground( aBrushItem );
901cdf0e10cSrcweir     aNew.SetColor( SvxColorItem(Color( COL_WHITE ), RES_CHRATR_COLOR) );
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 	for( i = 0; i < 4; ++i )
904cdf0e10cSrcweir 		pNew->SetBoxFmt( aNew, i );
905cdf0e10cSrcweir 
906cdf0e10cSrcweir 	// 70% Grau
907cdf0e10cSrcweir 	aBrushItem.SetColor( RGB_COLORDATA( 0x4d, 0x4d, 0x4d ) );
908cdf0e10cSrcweir 	aNew.SetBackground( aBrushItem );
909cdf0e10cSrcweir 	for( i = 4; i <= 12; i += 4 )
910cdf0e10cSrcweir 		pNew->SetBoxFmt( aNew, i );
911cdf0e10cSrcweir 
912cdf0e10cSrcweir 	// 20% Grau
913cdf0e10cSrcweir 	aBrushItem.SetColor( RGB_COLORDATA( 0xcc, 0xcc, 0xcc ) );
914cdf0e10cSrcweir 	aNew.SetBackground( aBrushItem );
915cdf0e10cSrcweir 	aColor.SetColor( COL_BLACK );
916cdf0e10cSrcweir     aNew.SetColor( SvxColorItem( aColor, RES_CHRATR_COLOR) );
917cdf0e10cSrcweir 	for( i = 7; i <= 15; i += 4 )
918cdf0e10cSrcweir 		pNew->SetBoxFmt( aNew, i );
919cdf0e10cSrcweir 	for( i = 13; i <= 14; ++i )
920cdf0e10cSrcweir 		pNew->SetBoxFmt( aNew, i );
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 	aBrushItem.SetColor( Color( COL_WHITE ) );
923cdf0e10cSrcweir 	aNew.SetBackground( aBrushItem );
924cdf0e10cSrcweir 	for( i = 5; i <= 6; ++i )
925cdf0e10cSrcweir 		pNew->SetBoxFmt( aNew, i );
926cdf0e10cSrcweir 	for( i = 9; i <= 10; ++i )
927cdf0e10cSrcweir 		pNew->SetBoxFmt( aNew, i );
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 
930cdf0e10cSrcweir     SvxBoxItem aBox( RES_BOX );
931cdf0e10cSrcweir 	aBox.SetDistance( 55 );
932cdf0e10cSrcweir 	SvxBorderLine aLn( &aColor, DEF_LINE_WIDTH_0 );
933cdf0e10cSrcweir 	aBox.SetLine( &aLn, BOX_LINE_LEFT );
934cdf0e10cSrcweir 	aBox.SetLine( &aLn, BOX_LINE_BOTTOM );
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 	for( i = 0; i <= 15; ++i )
937cdf0e10cSrcweir 	{
938cdf0e10cSrcweir 		aBox.SetLine( i <= 3 ? &aLn : 0, BOX_LINE_TOP );
939cdf0e10cSrcweir 		aBox.SetLine( (3 == ( i & 3 )) ? &aLn : 0, BOX_LINE_RIGHT );
940cdf0e10cSrcweir 		((SwBoxAutoFmt&)pNew->GetBoxFmt( i )).SetBox( aBox );
941cdf0e10cSrcweir 	}
942cdf0e10cSrcweir 
943cdf0e10cSrcweir 	Insert( pNew, Count() );
944cdf0e10cSrcweir }
945cdf0e10cSrcweir 
Load()946cdf0e10cSrcweir sal_Bool SwTableAutoFmtTbl::Load()
947cdf0e10cSrcweir {
948cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
949cdf0e10cSrcweir 	String sNm( String::CreateFromAscii(
950cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( sAutoTblFmtName )));
951cdf0e10cSrcweir 	SvtPathOptions aOpt;
952cdf0e10cSrcweir 	if( aOpt.SearchFile( sNm, SvtPathOptions::PATH_USERCONFIG ))
953cdf0e10cSrcweir 	{
954cdf0e10cSrcweir 		SfxMedium aStream( sNm, STREAM_STD_READ, sal_True );
955cdf0e10cSrcweir 		bRet = Load( *aStream.GetInStream() );
956cdf0e10cSrcweir 	}
957cdf0e10cSrcweir 	else
958cdf0e10cSrcweir 		bRet = sal_False;
959cdf0e10cSrcweir 	return bRet;
960cdf0e10cSrcweir }
961cdf0e10cSrcweir 
Save() const962cdf0e10cSrcweir sal_Bool SwTableAutoFmtTbl::Save() const
963cdf0e10cSrcweir {
964cdf0e10cSrcweir 	SvtPathOptions aPathOpt;
965cdf0e10cSrcweir     String sNm( aPathOpt.GetUserConfigPath() );
966cdf0e10cSrcweir 	sNm += INET_PATH_TOKEN;
967cdf0e10cSrcweir 	sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( sAutoTblFmtName ));
968cdf0e10cSrcweir 	SfxMedium aStream(sNm, STREAM_STD_WRITE, sal_True );
969cdf0e10cSrcweir 	return Save( *aStream.GetOutStream() ) && aStream.Commit();
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
Load(SvStream & rStream)972cdf0e10cSrcweir sal_Bool SwTableAutoFmtTbl::Load( SvStream& rStream )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir 	sal_Bool bRet = 0 == rStream.GetError();
975cdf0e10cSrcweir 	if (bRet)
976cdf0e10cSrcweir 	{
977cdf0e10cSrcweir 		// Achtung hier muss ein allgemeiner Header gelesen werden
978cdf0e10cSrcweir 		sal_uInt16 nVal = 0;
979cdf0e10cSrcweir 		rStream >> nVal;
980cdf0e10cSrcweir 		bRet = 0 == rStream.GetError();
981cdf0e10cSrcweir 
982cdf0e10cSrcweir 		if( bRet )
983cdf0e10cSrcweir 		{
984cdf0e10cSrcweir 			SwAfVersions aVersions;
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 			if( nVal == AUTOFORMAT_ID_358 ||
987cdf0e10cSrcweir 					(AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
988cdf0e10cSrcweir 			{
989cdf0e10cSrcweir 				sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_40;
990cdf0e10cSrcweir 				sal_uInt8 nChrSet, nCnt;
991cdf0e10cSrcweir 				long nPos = rStream.Tell();
992cdf0e10cSrcweir 				rStream >> nCnt >> nChrSet;
993cdf0e10cSrcweir //				if( 4 <= nCnt )
994cdf0e10cSrcweir //					rStream >> nFileVers;
995cdf0e10cSrcweir 				if( rStream.Tell() != sal_uLong(nPos + nCnt) )
996cdf0e10cSrcweir 				{
997cdf0e10cSrcweir 					ASSERT( !this, "Der Header enthaelt mehr/neuere Daten" );
998cdf0e10cSrcweir 					rStream.Seek( nPos + nCnt );
999cdf0e10cSrcweir 				}
1000cdf0e10cSrcweir 				rStream.SetStreamCharSet( (CharSet)nChrSet );
1001cdf0e10cSrcweir 				rStream.SetVersion( nFileVers );
1002cdf0e10cSrcweir 			}
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 			if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
1005cdf0e10cSrcweir 					(AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
1006cdf0e10cSrcweir 			{
1007cdf0e10cSrcweir 				aVersions.Load( rStream, nVal );		// Item-Versionen
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 				SwTableAutoFmt* pNew;
1010cdf0e10cSrcweir 				sal_uInt16 nAnz = 0;
1011cdf0e10cSrcweir 				rStream >> nAnz;
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 				bRet = 0 == rStream.GetError();
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir 				for( sal_uInt16 i = 0; i < nAnz; ++i )
1016cdf0e10cSrcweir 				{
1017cdf0e10cSrcweir 					pNew = new SwTableAutoFmt( aEmptyStr );
1018cdf0e10cSrcweir 					bRet = pNew->Load( rStream, aVersions );
1019cdf0e10cSrcweir 					if( bRet )
1020cdf0e10cSrcweir 					{
1021cdf0e10cSrcweir 						Insert( pNew, Count() );
1022cdf0e10cSrcweir 					}
1023cdf0e10cSrcweir 					else
1024cdf0e10cSrcweir 					{
1025cdf0e10cSrcweir 						delete pNew;
1026cdf0e10cSrcweir 						break;
1027cdf0e10cSrcweir 					}
1028cdf0e10cSrcweir 				}
1029cdf0e10cSrcweir 			}
1030cdf0e10cSrcweir #ifdef READ_OLDVERS
1031cdf0e10cSrcweir 			else if( AUTOFORMAT_OLD_ID == nVal || AUTOFORMAT_OLD_ID1 == nVal )
1032cdf0e10cSrcweir 			{
1033cdf0e10cSrcweir 				SwTableAutoFmt* pNew;
1034cdf0e10cSrcweir 				sal_uInt16 nAnz = 0;
1035cdf0e10cSrcweir 				rStream >> nAnz;
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 				sal_uInt16 aArr[ 12 ];
1038cdf0e10cSrcweir 				memset( aArr, 0, 12 * sizeof( sal_uInt16 ) );
1039cdf0e10cSrcweir 				if( AUTOFORMAT_OLD_ID1 == nVal )
1040cdf0e10cSrcweir 					for( sal_uInt16 n = 0; n < 12; ++n )
1041cdf0e10cSrcweir 						rStream >> aArr[ n ];
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 				bRet = 0 == rStream.GetError();
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir 				for( sal_uInt16 i = 0; i < nAnz; ++i )
1046cdf0e10cSrcweir 				{
1047cdf0e10cSrcweir 					pNew = new SwTableAutoFmt( aEmptyStr );
1048cdf0e10cSrcweir 					bRet = pNew->LoadOld( rStream, aArr );
1049cdf0e10cSrcweir 					if( bRet )
1050cdf0e10cSrcweir 					{
1051cdf0e10cSrcweir 						Insert( pNew, Count() );
1052cdf0e10cSrcweir 					}
1053cdf0e10cSrcweir 					else
1054cdf0e10cSrcweir 					{
1055cdf0e10cSrcweir 						delete pNew;
1056cdf0e10cSrcweir 						break;
1057cdf0e10cSrcweir 					}
1058cdf0e10cSrcweir 				}
1059cdf0e10cSrcweir 			}
1060cdf0e10cSrcweir #endif
1061cdf0e10cSrcweir 		}
1062cdf0e10cSrcweir 	}
1063cdf0e10cSrcweir 	return bRet;
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 
Save(SvStream & rStream) const1067cdf0e10cSrcweir sal_Bool SwTableAutoFmtTbl::Save( SvStream& rStream ) const
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir 	sal_Bool bRet = 0 == rStream.GetError();
1070cdf0e10cSrcweir 	if (bRet)
1071cdf0e10cSrcweir 	{
1072cdf0e10cSrcweir 		rStream.SetVersion( SOFFICE_FILEFORMAT_40 );
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir 		// Achtung hier muss ein allgemeiner Header gespeichert werden
1075cdf0e10cSrcweir 		sal_uInt16 nVal = AUTOFORMAT_ID;
1076cdf0e10cSrcweir 		rStream << nVal
1077cdf0e10cSrcweir 				<< (sal_uInt8)2 		// Anzahl von Zeichen des Headers incl. diesem
1078cdf0e10cSrcweir 				<< (sal_uInt8)GetStoreCharSet( ::gsl_getSystemTextEncoding() );
1079cdf0e10cSrcweir //				<< (sal_uInt8)4 		// Anzahl von Zeichen des Headers incl. diesem
1080cdf0e10cSrcweir //				<< (sal_uInt8)::GetSystemCharSet()
1081cdf0e10cSrcweir //				<< (UNIT16)SOFFICE_FILEFORMAT_NOW;
1082cdf0e10cSrcweir 		bRet = 0 == rStream.GetError();
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir 		//-----------------------------------------------------------
1085cdf0e10cSrcweir 		// die VersionsNummer fuer alle Attribute schreiben
1086cdf0e10cSrcweir 		(*this)[ 0 ]->GetBoxFmt( 0 ).SaveVerionNo( rStream );
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir 		rStream << (sal_uInt16)(Count() - 1);
1089cdf0e10cSrcweir 		bRet = 0 == rStream.GetError();
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 		for( sal_uInt16 i = 1; bRet && i < Count(); ++i )
1092cdf0e10cSrcweir 		{
1093cdf0e10cSrcweir 			SwTableAutoFmt* pFmt = (*this)[ i ];
1094cdf0e10cSrcweir 			bRet = pFmt->Save( rStream );
1095cdf0e10cSrcweir 		}
1096cdf0e10cSrcweir 	}
1097cdf0e10cSrcweir 	rStream.Flush();
1098cdf0e10cSrcweir 	return bRet;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir 
1103