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