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