1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tblafmt.cxx,v $
10 * $Revision: 1.22.210.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <tools/resid.hxx>
36 #include <tools/stream.hxx>
37 #include <tools/shl.hxx>
38 #include <vcl/svapp.hxx>
39 #include <sfx2/docfile.hxx>
40 #include <svtools/urihelper.hxx>
41 #include <svtools/zforlist.hxx>
42 #include <svtools/zformat.hxx>
43 #include <svtools/pathoptions.hxx>
44 #include <sfx2/app.hxx>
45 #include <svx/dialmgr.hxx>
46 #ifndef _SVX_DIALOGS_HRC
47 #include <svx/dialogs.hrc>
50 #define READ_OLDVERS // erstmal noch alte Versionen lesen
51 #include <swtypes.hxx>
53 #include <poolfmt.hxx>
54 #include <tblafmt.hxx>
55 #include <cellatr.hxx>
56 #include <SwStyleNameMapper.hxx>
59 const USHORT AUTOFORMAT_ID_X
= 9501;
60 const USHORT AUTOFORMAT_ID_358
= 9601;
61 const USHORT AUTOFORMAT_DATA_ID_X
= 9502;
64 //! in nachfolgenden Versionen muss der Betrag dieser IDs groesser sein
65 const USHORT AUTOFORMAT_ID_504
= 9801;
66 const USHORT AUTOFORMAT_DATA_ID_504
= 9802;
68 const USHORT AUTOFORMAT_ID_552
= 9901;
69 const USHORT AUTOFORMAT_DATA_ID_552
= 9902;
71 // --- from 641 on: CJK and CTL font settings
72 const USHORT AUTOFORMAT_ID_641
= 10001;
73 const USHORT AUTOFORMAT_DATA_ID_641
= 10002;
75 // --- from 680/dr14 on: diagonal frame lines
76 const USHORT AUTOFORMAT_ID_680DR14
= 10011;
77 const USHORT AUTOFORMAT_DATA_ID_680DR14
= 10012;
79 // --- from 680/dr25 on: #21549# store strings as UTF-8
80 const USHORT AUTOFORMAT_ID_680DR25
= 10021;
81 const USHORT AUTOFORMAT_DATA_ID_680DR25
= 10022;
83 // --- from DEV300/overline2 on: #5991# overline
84 const USHORT AUTOFORMAT_ID_300OVRLN
= 10031;
85 const USHORT AUTOFORMAT_DATA_ID_300OVRLN
= 10032;
88 const USHORT AUTOFORMAT_ID
= AUTOFORMAT_ID_300OVRLN
;
89 const USHORT AUTOFORMAT_DATA_ID
= AUTOFORMAT_DATA_ID_300OVRLN
;
93 const USHORT AUTOFORMAT_OLD_ID
= 8201;
94 const USHORT AUTOFORMAT_OLD_ID1
= 8301;
95 const USHORT AUTOFORMAT_OLD_DATA_ID
= 8202;
99 SwBoxAutoFmt
* SwTableAutoFmt::pDfltBoxAutoFmt
= 0;
101 #define sAutoTblFmtName "autotbl.fmt"
103 // SwTable Auto-Format-Tabelle
104 SV_IMPL_PTRARR( _SwTableAutoFmtTbl
, SwTableAutoFmt
* )
107 // Struct mit Versionsnummern der Items
113 USHORT nFontHeightVersion
;
114 USHORT nWeightVersion
;
115 USHORT nPostureVersion
;
116 USHORT nUnderlineVersion
;
117 USHORT nOverlineVersion
;
118 USHORT nCrossedOutVersion
;
119 USHORT nContourVersion
;
120 USHORT nShadowedVersion
;
121 USHORT nColorVersion
;
124 USHORT nBrushVersion
;
126 USHORT nAdjustVersion
;
128 USHORT nHorJustifyVersion
;
129 USHORT nVerJustifyVersion
;
130 USHORT nOrientationVersion
;
131 USHORT nMarginVersion
;
133 USHORT nInt32Version
;
134 USHORT nRotateModeVersion
;
136 USHORT nNumFmtVersion
;
139 void Load( SvStream
& rStream
, USHORT nVer
);
142 SwAfVersions::SwAfVersions() :
144 nFontHeightVersion(0),
147 nUnderlineVersion(0),
149 nCrossedOutVersion(0),
157 nHorJustifyVersion(0),
158 nVerJustifyVersion(0),
159 nOrientationVersion(0),
163 nRotateModeVersion(0),
168 void SwAfVersions::Load( SvStream
& rStream
, USHORT nVer
)
170 rStream
>> nFontVersion
;
171 rStream
>> nFontHeightVersion
;
172 rStream
>> nWeightVersion
;
173 rStream
>> nPostureVersion
;
174 rStream
>> nUnderlineVersion
;
175 if ( nVer
>= AUTOFORMAT_ID_300OVRLN
)
176 rStream
>> nOverlineVersion
;
177 rStream
>> nCrossedOutVersion
;
178 rStream
>> nContourVersion
;
179 rStream
>> nShadowedVersion
;
180 rStream
>> nColorVersion
;
181 rStream
>> nBoxVersion
;
182 if ( nVer
>= AUTOFORMAT_ID_680DR14
)
183 rStream
>> nLineVersion
;
184 rStream
>> nBrushVersion
;
185 rStream
>> nAdjustVersion
;
186 rStream
>> nHorJustifyVersion
;
187 rStream
>> nVerJustifyVersion
;
188 rStream
>> nOrientationVersion
;
189 rStream
>> nMarginVersion
;
190 rStream
>> nBoolVersion
;
191 if ( nVer
>= AUTOFORMAT_ID_504
)
193 rStream
>> nInt32Version
;
194 rStream
>> nRotateModeVersion
;
196 rStream
>> nNumFmtVersion
;
199 // ---------------------------------------------------------------------------
201 SwBoxAutoFmt::SwBoxAutoFmt()
202 : aFont( *(SvxFontItem
*)GetDfltAttr( RES_CHRATR_FONT
) ),
203 aHeight( 240, 100, RES_CHRATR_FONTSIZE
),
204 aWeight( WEIGHT_NORMAL
, RES_CHRATR_WEIGHT
),
205 aPosture( ITALIC_NONE
, RES_CHRATR_POSTURE
),
207 aCJKFont( *(SvxFontItem
*)GetDfltAttr( RES_CHRATR_CJK_FONT
) ),
208 aCJKHeight( 240, 100, RES_CHRATR_CJK_FONTSIZE
),
209 aCJKWeight( WEIGHT_NORMAL
, RES_CHRATR_CJK_WEIGHT
),
210 aCJKPosture( ITALIC_NONE
, RES_CHRATR_CJK_POSTURE
),
212 aCTLFont( *(SvxFontItem
*)GetDfltAttr( RES_CHRATR_CTL_FONT
) ),
213 aCTLHeight( 240, 100, RES_CHRATR_CTL_FONTSIZE
),
214 aCTLWeight( WEIGHT_NORMAL
, RES_CHRATR_CTL_WEIGHT
),
215 aCTLPosture( ITALIC_NONE
, RES_CHRATR_CTL_POSTURE
),
217 aUnderline( UNDERLINE_NONE
, RES_CHRATR_UNDERLINE
),
218 aOverline( UNDERLINE_NONE
, RES_CHRATR_OVERLINE
),
219 aCrossedOut( STRIKEOUT_NONE
, RES_CHRATR_CROSSEDOUT
),
220 aContour( sal_False
, RES_CHRATR_CONTOUR
),
221 aShadowed( sal_False
, RES_CHRATR_SHADOWED
),
222 aColor( RES_CHRATR_COLOR
),
226 aBackground( RES_BACKGROUND
),
227 aAdjust( SVX_ADJUST_LEFT
, RES_PARATR_ADJUST
),
228 aHorJustify( SVX_HOR_JUSTIFY_STANDARD
, 0),
229 aVerJustify( SVX_VER_JUSTIFY_STANDARD
, 0),
235 // FIXME - add attribute IDs for the diagonal line items
238 aRotateMode( SVX_ROTATE_MODE_STANDARD
, 0 )
240 eSysLanguage
= eNumFmtLanguage
= static_cast<LanguageType
>(::GetAppLanguage());
241 aBox
.SetDistance( 55 );
245 SwBoxAutoFmt::SwBoxAutoFmt( const SwBoxAutoFmt
& rNew
)
246 : aFont( rNew
.aFont
),
247 aHeight( rNew
.aHeight
),
248 aWeight( rNew
.aWeight
),
249 aPosture( rNew
.aPosture
),
250 aCJKFont( rNew
.aCJKFont
),
251 aCJKHeight( rNew
.aCJKHeight
),
252 aCJKWeight( rNew
.aCJKWeight
),
253 aCJKPosture( rNew
.aCJKPosture
),
254 aCTLFont( rNew
.aCTLFont
),
255 aCTLHeight( rNew
.aCTLHeight
),
256 aCTLWeight( rNew
.aCTLWeight
),
257 aCTLPosture( rNew
.aCTLPosture
),
258 aUnderline( rNew
.aUnderline
),
259 aOverline( rNew
.aOverline
),
260 aCrossedOut( rNew
.aCrossedOut
),
261 aContour( rNew
.aContour
),
262 aShadowed( rNew
.aShadowed
),
263 aColor( rNew
.aColor
),
267 aBackground( rNew
.aBackground
),
268 aAdjust( rNew
.aAdjust
),
269 aHorJustify( rNew
.aHorJustify
),
270 aVerJustify( rNew
.aVerJustify
),
271 aStacked( rNew
.aStacked
),
272 aMargin( rNew
.aMargin
),
273 aLinebreak( rNew
.aLinebreak
),
274 aRotateAngle( rNew
.aRotateAngle
),
275 aRotateMode( rNew
.aRotateMode
),
276 sNumFmtString( rNew
.sNumFmtString
),
277 eSysLanguage( rNew
.eSysLanguage
),
278 eNumFmtLanguage( rNew
.eNumFmtLanguage
)
283 SwBoxAutoFmt::~SwBoxAutoFmt()
287 SwBoxAutoFmt
& SwBoxAutoFmt::operator=( const SwBoxAutoFmt
& rNew
)
290 aHeight
= rNew
.aHeight
;
291 aWeight
= rNew
.aWeight
;
292 aPosture
= rNew
.aPosture
;
293 aCJKFont
= rNew
.aCJKFont
;
294 aCJKHeight
= rNew
.aCJKHeight
;
295 aCJKWeight
= rNew
.aCJKWeight
;
296 aCJKPosture
= rNew
.aCJKPosture
;
297 aCTLFont
= rNew
.aCTLFont
;
298 aCTLHeight
= rNew
.aCTLHeight
;
299 aCTLWeight
= rNew
.aCTLWeight
;
300 aCTLPosture
= rNew
.aCTLPosture
;
301 aUnderline
= rNew
.aUnderline
;
302 aOverline
= rNew
.aOverline
;
303 aCrossedOut
= rNew
.aCrossedOut
;
304 aContour
= rNew
.aContour
;
305 aShadowed
= rNew
.aShadowed
;
306 aColor
= rNew
.aColor
;
307 SetAdjust( rNew
.aAdjust
);
311 aBackground
= rNew
.aBackground
;
313 aHorJustify
= rNew
.aHorJustify
;
314 aVerJustify
= rNew
.aVerJustify
;
315 aStacked
.SetValue( rNew
.aStacked
.GetValue() );
316 aMargin
= rNew
.aMargin
;
317 aLinebreak
.SetValue( rNew
.aLinebreak
.GetValue() );
318 aRotateAngle
.SetValue( rNew
.aRotateAngle
.GetValue() );
319 aRotateMode
.SetValue( rNew
.aRotateMode
.GetValue() );
321 sNumFmtString
= rNew
.sNumFmtString
;
322 eSysLanguage
= rNew
.eSysLanguage
;
323 eNumFmtLanguage
= rNew
.eNumFmtLanguage
;
329 #define READ( aItem, aItemType, nVers )\
330 pNew = aItem.Create(rStream, nVers ); \
331 aItem = *(aItemType*)pNew; \
334 BOOL
SwBoxAutoFmt::Load( SvStream
& rStream
, const SwAfVersions
& rVersions
, USHORT nVer
)
337 SvxOrientationItem
aOrientation( SVX_ORIENTATION_STANDARD
, 0);
339 READ( aFont
, SvxFontItem
, rVersions
.nFontVersion
)
341 if( rStream
.GetStreamCharSet() == aFont
.GetCharSet() )
342 aFont
.GetCharSet() = ::gsl_getSystemTextEncoding();
344 READ( aHeight
, SvxFontHeightItem
, rVersions
.nFontHeightVersion
)
345 READ( aWeight
, SvxWeightItem
, rVersions
.nWeightVersion
)
346 READ( aPosture
, SvxPostureItem
, rVersions
.nPostureVersion
)
347 // --- from 641 on: CJK and CTL font settings
348 if( AUTOFORMAT_DATA_ID_641
<= nVer
)
350 READ( aCJKFont
, SvxFontItem
, rVersions
.nFontVersion
)
351 READ( aCJKHeight
, SvxFontHeightItem
, rVersions
.nFontHeightVersion
)
352 READ( aCJKWeight
, SvxWeightItem
, rVersions
.nWeightVersion
)
353 READ( aCJKPosture
, SvxPostureItem
, rVersions
.nPostureVersion
)
354 READ( aCTLFont
, SvxFontItem
, rVersions
.nFontVersion
)
355 READ( aCTLHeight
, SvxFontHeightItem
, rVersions
.nFontHeightVersion
)
356 READ( aCTLWeight
, SvxWeightItem
, rVersions
.nWeightVersion
)
357 READ( aCTLPosture
, SvxPostureItem
, rVersions
.nPostureVersion
)
359 READ( aUnderline
, SvxUnderlineItem
, rVersions
.nUnderlineVersion
)
360 if( nVer
>= AUTOFORMAT_DATA_ID_300OVRLN
)
362 READ( aOverline
, SvxOverlineItem
, rVersions
.nOverlineVersion
)
364 READ( aCrossedOut
, SvxCrossedOutItem
, rVersions
.nCrossedOutVersion
)
365 READ( aContour
, SvxContourItem
, rVersions
.nContourVersion
)
366 READ( aShadowed
, SvxShadowedItem
, rVersions
.nShadowedVersion
)
367 READ( aColor
, SvxColorItem
, rVersions
.nColorVersion
)
369 READ( aBox
, SvxBoxItem
, rVersions
.nBoxVersion
)
371 // --- from 680/dr14 on: diagonal frame lines
372 if( nVer
>= AUTOFORMAT_DATA_ID_680DR14
)
374 READ( aTLBR
, SvxLineItem
, rVersions
.nLineVersion
)
375 READ( aBLTR
, SvxLineItem
, rVersions
.nLineVersion
)
378 READ( aBackground
, SvxBrushItem
, rVersions
.nBrushVersion
)
380 pNew
= aAdjust
.Create(rStream
, rVersions
.nAdjustVersion
);
381 SetAdjust( *(SvxAdjustItem
*)pNew
);
384 READ( aHorJustify
, SvxHorJustifyItem
, rVersions
.nHorJustifyVersion
)
385 READ( aVerJustify
, SvxVerJustifyItem
, rVersions
.nVerJustifyVersion
)
386 READ( aOrientation
, SvxOrientationItem
, rVersions
.nOrientationVersion
)
387 READ( aMargin
, SvxMarginItem
, rVersions
.nMarginVersion
)
389 pNew
= aLinebreak
.Create(rStream
, rVersions
.nBoolVersion
);
390 aLinebreak
.SetValue( ((SfxBoolItem
*)pNew
)->GetValue() );
393 if ( nVer
>= AUTOFORMAT_DATA_ID_504
)
395 pNew
= aRotateAngle
.Create( rStream
, rVersions
.nInt32Version
);
396 aRotateAngle
.SetValue( ((SfxInt32Item
*)pNew
)->GetValue() );
398 pNew
= aRotateMode
.Create( rStream
, rVersions
.nRotateModeVersion
);
399 aRotateMode
.SetValue( ((SvxRotateModeItem
*)pNew
)->GetValue() );
403 if( 0 == rVersions
.nNumFmtVersion
)
406 // --- from 680/dr25 on: #21549# store strings as UTF-8
407 CharSet eCharSet
= (nVer
>= AUTOFORMAT_ID_680DR25
) ? RTL_TEXTENCODING_UTF8
: rStream
.GetStreamCharSet();
408 rStream
.ReadByteString( sNumFmtString
, eCharSet
)
410 eSysLanguage
= (LanguageType
) eSys
;
411 eNumFmtLanguage
= (LanguageType
) eLge
;
412 if ( eSysLanguage
== LANGUAGE_SYSTEM
) // von alten Versionen (Calc)
413 eSysLanguage
= static_cast<LanguageType
>(::GetAppLanguage());
416 aStacked
.SetValue( aOrientation
.IsStacked() );
417 aRotateAngle
.SetValue( aOrientation
.GetRotation( aRotateAngle
.GetValue() ) );
419 return 0 == rStream
.GetError();
424 BOOL
SwBoxAutoFmt::LoadOld( SvStream
& rStream
, USHORT aLoadVer
[] )
427 READ( aFont
, SvxFontItem
, 0)
429 if( rStream
.GetStreamCharSet() == aFont
.GetCharSet() )
430 aFont
.GetCharSet() = ::gsl_getSystemTextEncoding();
432 READ( aHeight
, SvxFontHeightItem
, 1)
433 READ( aWeight
, SvxWeightItem
, 2)
434 READ( aPosture
, SvxPostureItem
, 3)
435 READ( aUnderline
, SvxUnderlineItem
, 4)
436 READ( aCrossedOut
, SvxCrossedOutItem
, 5)
437 READ( aContour
, SvxContourItem
, 6)
438 READ( aShadowed
, SvxShadowedItem
, 7)
439 READ( aColor
, SvxColorItem
, 8)
441 pNew
= aAdjust
.Create(rStream
, aLoadVer
[ 9 ] );
442 SetAdjust( *(SvxAdjustItem
*)pNew
);
445 READ( aBox
, SvxBoxItem
, 10)
446 READ( aBackground
, SvxBrushItem
, 11)
448 return 0 == rStream
.GetError();
454 BOOL
SwBoxAutoFmt::Save( SvStream
& rStream
) const
456 SvxOrientationItem
aOrientation( aRotateAngle
.GetValue(), aStacked
.GetValue(), 0 );
458 aFont
.Store( rStream
, aFont
.GetVersion(SOFFICE_FILEFORMAT_40
) );
459 aHeight
.Store( rStream
, aHeight
.GetVersion(SOFFICE_FILEFORMAT_40
) );
460 aWeight
.Store( rStream
, aWeight
.GetVersion(SOFFICE_FILEFORMAT_40
) );
461 aPosture
.Store( rStream
, aPosture
.GetVersion(SOFFICE_FILEFORMAT_40
) );
462 aCJKFont
.Store( rStream
, aCJKFont
.GetVersion(SOFFICE_FILEFORMAT_40
) );
463 aCJKHeight
.Store( rStream
, aCJKHeight
.GetVersion(SOFFICE_FILEFORMAT_40
) );
464 aCJKWeight
.Store( rStream
, aCJKWeight
.GetVersion(SOFFICE_FILEFORMAT_40
) );
465 aCJKPosture
.Store( rStream
, aCJKPosture
.GetVersion(SOFFICE_FILEFORMAT_40
) );
466 aCTLFont
.Store( rStream
, aCTLFont
.GetVersion(SOFFICE_FILEFORMAT_40
) );
467 aCTLHeight
.Store( rStream
, aCTLHeight
.GetVersion(SOFFICE_FILEFORMAT_40
) );
468 aCTLWeight
.Store( rStream
, aCTLWeight
.GetVersion(SOFFICE_FILEFORMAT_40
) );
469 aCTLPosture
.Store( rStream
, aCTLPosture
.GetVersion(SOFFICE_FILEFORMAT_40
) );
470 aUnderline
.Store( rStream
, aUnderline
.GetVersion(SOFFICE_FILEFORMAT_40
) );
471 aOverline
.Store( rStream
, aOverline
.GetVersion(SOFFICE_FILEFORMAT_40
) );
472 aCrossedOut
.Store( rStream
, aCrossedOut
.GetVersion(SOFFICE_FILEFORMAT_40
) );
473 aContour
.Store( rStream
, aContour
.GetVersion(SOFFICE_FILEFORMAT_40
) );
474 aShadowed
.Store( rStream
, aShadowed
.GetVersion(SOFFICE_FILEFORMAT_40
) );
475 aColor
.Store( rStream
, aColor
.GetVersion(SOFFICE_FILEFORMAT_40
) );
476 aBox
.Store( rStream
, aBox
.GetVersion(SOFFICE_FILEFORMAT_40
) );
477 aTLBR
.Store( rStream
, aTLBR
.GetVersion(SOFFICE_FILEFORMAT_40
) );
478 aBLTR
.Store( rStream
, aBLTR
.GetVersion(SOFFICE_FILEFORMAT_40
) );
479 aBackground
.Store( rStream
, aBackground
.GetVersion(SOFFICE_FILEFORMAT_40
) );
481 aAdjust
.Store( rStream
, aAdjust
.GetVersion(SOFFICE_FILEFORMAT_40
) );
483 aHorJustify
.Store( rStream
, aHorJustify
.GetVersion(SOFFICE_FILEFORMAT_40
) );
484 aVerJustify
.Store( rStream
, aVerJustify
.GetVersion(SOFFICE_FILEFORMAT_40
) );
485 aOrientation
.Store( rStream
, aOrientation
.GetVersion(SOFFICE_FILEFORMAT_40
) );
486 aMargin
.Store( rStream
, aMargin
.GetVersion(SOFFICE_FILEFORMAT_40
) );
487 aLinebreak
.Store( rStream
, aLinebreak
.GetVersion(SOFFICE_FILEFORMAT_40
) );
488 // Calc Rotation ab SO5
489 aRotateAngle
.Store( rStream
, aRotateAngle
.GetVersion(SOFFICE_FILEFORMAT_40
) );
490 aRotateMode
.Store( rStream
, aRotateMode
.GetVersion(SOFFICE_FILEFORMAT_40
) );
492 // --- from 680/dr25 on: #21549# store strings as UTF-8
493 rStream
.WriteByteString( sNumFmtString
, RTL_TEXTENCODING_UTF8
)
494 << (USHORT
)eSysLanguage
<< (USHORT
)eNumFmtLanguage
;
496 return 0 == rStream
.GetError();
500 BOOL
SwBoxAutoFmt::SaveVerionNo( SvStream
& rStream
) const
502 rStream
<< aFont
.GetVersion( SOFFICE_FILEFORMAT_40
);
503 rStream
<< aHeight
.GetVersion( SOFFICE_FILEFORMAT_40
);
504 rStream
<< aWeight
.GetVersion( SOFFICE_FILEFORMAT_40
);
505 rStream
<< aPosture
.GetVersion( SOFFICE_FILEFORMAT_40
);
506 rStream
<< aUnderline
.GetVersion( SOFFICE_FILEFORMAT_40
);
507 rStream
<< aOverline
.GetVersion( SOFFICE_FILEFORMAT_40
);
508 rStream
<< aCrossedOut
.GetVersion( SOFFICE_FILEFORMAT_40
);
509 rStream
<< aContour
.GetVersion( SOFFICE_FILEFORMAT_40
);
510 rStream
<< aShadowed
.GetVersion( SOFFICE_FILEFORMAT_40
);
511 rStream
<< aColor
.GetVersion( SOFFICE_FILEFORMAT_40
);
512 rStream
<< aBox
.GetVersion( SOFFICE_FILEFORMAT_40
);
513 rStream
<< aTLBR
.GetVersion( SOFFICE_FILEFORMAT_40
);
514 rStream
<< aBackground
.GetVersion( SOFFICE_FILEFORMAT_40
);
516 rStream
<< aAdjust
.GetVersion( SOFFICE_FILEFORMAT_40
);
518 rStream
<< aHorJustify
.GetVersion( SOFFICE_FILEFORMAT_40
);
519 rStream
<< aVerJustify
.GetVersion( SOFFICE_FILEFORMAT_40
);
520 rStream
<< SvxOrientationItem(SVX_ORIENTATION_STANDARD
, 0).GetVersion( SOFFICE_FILEFORMAT_40
);
521 rStream
<< aMargin
.GetVersion( SOFFICE_FILEFORMAT_40
);
522 rStream
<< aLinebreak
.GetVersion( SOFFICE_FILEFORMAT_40
);
523 rStream
<< aRotateAngle
.GetVersion( SOFFICE_FILEFORMAT_40
);
524 rStream
<< aRotateMode
.GetVersion( SOFFICE_FILEFORMAT_40
);
526 rStream
<< (USHORT
)0; // NumberFormat
528 return 0 == rStream
.GetError();
534 SwTableAutoFmt::SwTableAutoFmt( const String
& rName
)
535 : aName( rName
), nStrResId( USHRT_MAX
)
540 bInclBackground
= TRUE
;
541 bInclValueFormat
= TRUE
;
542 bInclWidthHeight
= TRUE
;
544 memset( aBoxAutoFmt
, 0, sizeof( aBoxAutoFmt
) );
548 SwTableAutoFmt::SwTableAutoFmt( const SwTableAutoFmt
& rNew
)
550 for( BYTE n
= 0; n
< 16; ++n
)
551 aBoxAutoFmt
[ n
] = 0;
555 SwTableAutoFmt
& SwTableAutoFmt::operator=( const SwTableAutoFmt
& rNew
)
557 for( BYTE n
= 0; n
< 16; ++n
)
559 if( aBoxAutoFmt
[ n
] )
560 delete aBoxAutoFmt
[ n
];
562 SwBoxAutoFmt
* pFmt
= rNew
.aBoxAutoFmt
[ n
];
563 if( pFmt
) // ist gesetzt -> kopieren
564 aBoxAutoFmt
[ n
] = new SwBoxAutoFmt( *pFmt
);
565 else // sonst default
566 aBoxAutoFmt
[ n
] = 0;
570 nStrResId
= rNew
.nStrResId
;
571 bInclFont
= rNew
.bInclFont
;
572 bInclJustify
= rNew
.bInclJustify
;
573 bInclFrame
= rNew
.bInclFrame
;
574 bInclBackground
= rNew
.bInclBackground
;
575 bInclValueFormat
= rNew
.bInclValueFormat
;
576 bInclWidthHeight
= rNew
.bInclWidthHeight
;
582 SwTableAutoFmt::~SwTableAutoFmt()
584 SwBoxAutoFmt
** ppFmt
= aBoxAutoFmt
;
585 for( BYTE n
= 0; n
< 16; ++n
, ++ppFmt
)
591 void SwTableAutoFmt::SetBoxFmt( const SwBoxAutoFmt
& rNew
, BYTE nPos
)
593 ASSERT( nPos
< 16, "falscher Bereich" );
595 SwBoxAutoFmt
* pFmt
= aBoxAutoFmt
[ nPos
];
596 if( pFmt
) // ist gesetzt -> kopieren
597 *aBoxAutoFmt
[ nPos
] = rNew
;
598 else // sonst neu setzen
599 aBoxAutoFmt
[ nPos
] = new SwBoxAutoFmt( rNew
);
603 const SwBoxAutoFmt
& SwTableAutoFmt::GetBoxFmt( BYTE nPos
) const
605 ASSERT( nPos
< 16, "falscher Bereich" );
607 SwBoxAutoFmt
* pFmt
= aBoxAutoFmt
[ nPos
];
608 if( pFmt
) // ist gesetzt -> kopieren
610 else // sonst den default returnen
612 // falls noch nicht vorhanden:
613 if( !pDfltBoxAutoFmt
)
614 pDfltBoxAutoFmt
= new SwBoxAutoFmt
;
615 return *pDfltBoxAutoFmt
;
621 SwBoxAutoFmt
& SwTableAutoFmt::UpdateFromSet( BYTE nPos
,
622 const SfxItemSet
& rSet
,
624 SvNumberFormatter
* pNFmtr
)
626 ASSERT( nPos
< 16, "falscher Bereich" );
628 SwBoxAutoFmt
* pFmt
= aBoxAutoFmt
[ nPos
];
629 if( !pFmt
) // ist gesetzt -> kopieren
631 pFmt
= new SwBoxAutoFmt
;
632 aBoxAutoFmt
[ nPos
] = pFmt
;
635 if( UPDATE_CHAR
& eFlags
)
637 pFmt
->SetFont( (SvxFontItem
&)rSet
.Get( RES_CHRATR_FONT
) );
638 pFmt
->SetHeight( (SvxFontHeightItem
&)rSet
.Get( RES_CHRATR_FONTSIZE
) );
639 pFmt
->SetWeight( (SvxWeightItem
&)rSet
.Get( RES_CHRATR_WEIGHT
) );
640 pFmt
->SetPosture( (SvxPostureItem
&)rSet
.Get( RES_CHRATR_POSTURE
) );
641 pFmt
->SetCJKFont( (SvxFontItem
&)rSet
.Get( RES_CHRATR_CJK_FONT
) );
642 pFmt
->SetCJKHeight( (SvxFontHeightItem
&)rSet
.Get( RES_CHRATR_CJK_FONTSIZE
) );
643 pFmt
->SetCJKWeight( (SvxWeightItem
&)rSet
.Get( RES_CHRATR_CJK_WEIGHT
) );
644 pFmt
->SetCJKPosture( (SvxPostureItem
&)rSet
.Get( RES_CHRATR_CJK_POSTURE
) );
645 pFmt
->SetCTLFont( (SvxFontItem
&)rSet
.Get( RES_CHRATR_CTL_FONT
) );
646 pFmt
->SetCTLHeight( (SvxFontHeightItem
&)rSet
.Get( RES_CHRATR_CTL_FONTSIZE
) );
647 pFmt
->SetCTLWeight( (SvxWeightItem
&)rSet
.Get( RES_CHRATR_CTL_WEIGHT
) );
648 pFmt
->SetCTLPosture( (SvxPostureItem
&)rSet
.Get( RES_CHRATR_CTL_POSTURE
) );
649 pFmt
->SetUnderline( (SvxUnderlineItem
&)rSet
.Get( RES_CHRATR_UNDERLINE
) );
650 pFmt
->SetOverline( (SvxOverlineItem
&)rSet
.Get( RES_CHRATR_OVERLINE
) );
651 pFmt
->SetCrossedOut( (SvxCrossedOutItem
&)rSet
.Get( RES_CHRATR_CROSSEDOUT
) );
652 pFmt
->SetContour( (SvxContourItem
&)rSet
.Get( RES_CHRATR_CONTOUR
) );
653 pFmt
->SetShadowed( (SvxShadowedItem
&)rSet
.Get( RES_CHRATR_SHADOWED
) );
654 pFmt
->SetColor( (SvxColorItem
&)rSet
.Get( RES_CHRATR_COLOR
) );
655 pFmt
->SetAdjust( (SvxAdjustItem
&)rSet
.Get( RES_PARATR_ADJUST
) );
657 if( UPDATE_BOX
& eFlags
)
659 pFmt
->SetBox( (SvxBoxItem
&)rSet
.Get( RES_BOX
) );
660 // FIXME - add attribute IDs for the diagonal line items
661 // pFmt->SetTLBR( (SvxLineItem&)rSet.Get( RES_... ) );
662 // pFmt->SetBLTR( (SvxLineItem&)rSet.Get( RES_... ) );
663 pFmt
->SetBackground( (SvxBrushItem
&)rSet
.Get( RES_BACKGROUND
) );
665 const SwTblBoxNumFormat
* pNumFmtItem
;
666 const SvNumberformat
* pNumFormat
= 0;
667 if( SFX_ITEM_SET
== rSet
.GetItemState( RES_BOXATR_FORMAT
, TRUE
,
668 (const SfxPoolItem
**)&pNumFmtItem
) && pNFmtr
&&
669 0 != (pNumFormat
= pNFmtr
->GetEntry( pNumFmtItem
->GetValue() )) )
670 pFmt
->SetValueFormat( ((SvNumberformat
*)pNumFormat
)->GetFormatstring(),
671 pNumFormat
->GetLanguage(),
672 static_cast<LanguageType
>(::GetAppLanguage()));
676 pFmt
->SetValueFormat( aEmptyStr
, LANGUAGE_SYSTEM
,
677 static_cast<LanguageType
>(::GetAppLanguage() ));
680 // den Rest koennen wir nicht, StarCalc spezifisch
686 void SwTableAutoFmt::UpdateToSet( BYTE nPos
, SfxItemSet
& rSet
,
687 UpdateFlags eFlags
, SvNumberFormatter
* pNFmtr
) const
689 const SwBoxAutoFmt
& rChg
= GetBoxFmt( nPos
);
691 if( UPDATE_CHAR
& eFlags
)
695 rSet
.Put( rChg
.GetFont() );
696 rSet
.Put( rChg
.GetHeight() );
697 rSet
.Put( rChg
.GetWeight() );
698 rSet
.Put( rChg
.GetPosture() );
699 // #103065# do not insert empty CJK font
700 const SvxFontItem
& rCJKFont
= rChg
.GetCJKFont();
701 if( rCJKFont
.GetStyleName().Len() )
703 rSet
.Put( rChg
.GetCJKFont() );
704 rSet
.Put( rChg
.GetCJKHeight() );
705 rSet
.Put( rChg
.GetCJKWeight() );
706 rSet
.Put( rChg
.GetCJKPosture() );
710 rSet
.Put( rChg
.GetHeight(), RES_CHRATR_CJK_FONTSIZE
);
711 rSet
.Put( rChg
.GetWeight(), RES_CHRATR_CJK_WEIGHT
);
712 rSet
.Put( rChg
.GetPosture(), RES_CHRATR_CJK_POSTURE
);
714 // #103065# do not insert empty CTL font
715 const SvxFontItem
& rCTLFont
= rChg
.GetCTLFont();
716 if( rCTLFont
.GetStyleName().Len() )
718 rSet
.Put( rChg
.GetCTLFont() );
719 rSet
.Put( rChg
.GetCTLHeight() );
720 rSet
.Put( rChg
.GetCTLWeight() );
721 rSet
.Put( rChg
.GetCTLPosture() );
725 rSet
.Put( rChg
.GetHeight(), RES_CHRATR_CTL_FONTSIZE
);
726 rSet
.Put( rChg
.GetWeight(), RES_CHRATR_CTL_WEIGHT
);
727 rSet
.Put( rChg
.GetPosture(), RES_CHRATR_CTL_POSTURE
);
729 rSet
.Put( rChg
.GetUnderline() );
730 rSet
.Put( rChg
.GetOverline() );
731 rSet
.Put( rChg
.GetCrossedOut() );
732 rSet
.Put( rChg
.GetContour() );
733 rSet
.Put( rChg
.GetShadowed() );
734 rSet
.Put( rChg
.GetColor() );
737 rSet
.Put( rChg
.GetAdjust() );
740 if( UPDATE_BOX
& eFlags
)
744 rSet
.Put( rChg
.GetBox() );
745 // FIXME - uncomment the lines to put the diagonal line items
746 // rSet.Put( rChg.GetTLBR() );
747 // rSet.Put( rChg.GetBLTR() );
750 rSet
.Put( rChg
.GetBackground() );
752 if( IsValueFormat() && pNFmtr
)
754 String sFmt
; LanguageType eLng
, eSys
;
755 rChg
.GetValueFormat( sFmt
, eLng
, eSys
);
760 xub_StrLen nCheckPos
;
761 sal_uInt32 nKey
= pNFmtr
->GetIndexPuttingAndConverting( sFmt
, eLng
,
762 eSys
, nType
, bNew
, nCheckPos
);
763 rSet
.Put( SwTblBoxNumFormat( nKey
));
766 rSet
.ClearItem( RES_BOXATR_FORMAT
);
770 // den Rest koennen wir nicht, StarCalc spezifisch
774 BOOL
SwTableAutoFmt::Load( SvStream
& rStream
, const SwAfVersions
& rVersions
)
779 bRet
= 0 == rStream
.GetError();
781 if( bRet
&& (nVal
== AUTOFORMAT_DATA_ID_X
||
782 (AUTOFORMAT_DATA_ID_504
<= nVal
&& nVal
<= AUTOFORMAT_DATA_ID
)) )
785 // --- from 680/dr25 on: #21549# store strings as UTF-8
786 CharSet eCharSet
= (nVal
>= AUTOFORMAT_ID_680DR25
) ? RTL_TEXTENCODING_UTF8
: rStream
.GetStreamCharSet();
787 rStream
.ReadByteString( aName
, eCharSet
);
788 if( AUTOFORMAT_DATA_ID_552
<= nVal
)
790 rStream
>> nStrResId
;
791 USHORT nId
= RID_SVXSTR_TBLAFMT_BEGIN
+ nStrResId
;
792 if( RID_SVXSTR_TBLAFMT_BEGIN
<= nId
&&
793 nId
< RID_SVXSTR_TBLAFMT_END
)
795 aName
= SVX_RESSTR( nId
);
798 nStrResId
= USHRT_MAX
;
800 rStream
>> b
; bInclFont
= b
;
801 rStream
>> b
; bInclJustify
= b
;
802 rStream
>> b
; bInclFrame
= b
;
803 rStream
>> b
; bInclBackground
= b
;
804 rStream
>> b
; bInclValueFormat
= b
;
805 rStream
>> b
; bInclWidthHeight
= b
;
807 bRet
= 0 == rStream
.GetError();
809 for( BYTE i
= 0; i
< 16; ++i
)
811 SwBoxAutoFmt
* pFmt
= new SwBoxAutoFmt
;
812 bRet
= pFmt
->Load( rStream
, rVersions
, nVal
);
814 aBoxAutoFmt
[ i
] = pFmt
;
827 BOOL
SwTableAutoFmt::LoadOld( SvStream
& rStream
, USHORT aLoadVer
[] )
832 bRet
= 0 == rStream
.GetError();
834 if( bRet
&& ( AUTOFORMAT_OLD_DATA_ID
== nVal
))
837 rStream
.ReadByteString( aName
, rStream
.GetStreamCharSet() );
838 rStream
>> b
; bInclFont
= b
;
839 rStream
>> b
; bInclJustify
= b
;
840 rStream
>> b
; bInclFrame
= b
;
841 rStream
>> b
; bInclBackground
= b
;
842 bRet
= (rStream
.GetError() == 0);
844 for( int i
= 0; i
< 16; i
++)
846 SwBoxAutoFmt
* pFmt
= new SwBoxAutoFmt
;
847 bRet
= pFmt
->LoadOld( rStream
, aLoadVer
);
849 aBoxAutoFmt
[ i
] = pFmt
;
862 BOOL
SwTableAutoFmt::Save( SvStream
& rStream
) const
864 USHORT nVal
= AUTOFORMAT_DATA_ID
;
867 // --- from 680/dr25 on: #21549# store strings as UTF-8
868 rStream
.WriteByteString( aName
, RTL_TEXTENCODING_UTF8
);
869 rStream
<< nStrResId
;
870 rStream
<< ( b
= bInclFont
);
871 rStream
<< ( b
= bInclJustify
);
872 rStream
<< ( b
= bInclFrame
);
873 rStream
<< ( b
= bInclBackground
);
874 rStream
<< ( b
= bInclValueFormat
);
875 rStream
<< ( b
= bInclWidthHeight
);
877 BOOL bRet
= 0 == rStream
.GetError();
879 for( int i
= 0; bRet
&& i
< 16; ++i
)
881 SwBoxAutoFmt
* pFmt
= aBoxAutoFmt
[ i
];
882 if( !pFmt
) // nicht gesetzt -> default schreiben
884 // falls noch nicht vorhanden:
885 if( !pDfltBoxAutoFmt
)
886 pDfltBoxAutoFmt
= new SwBoxAutoFmt
;
887 pFmt
= pDfltBoxAutoFmt
;
889 bRet
= pFmt
->Save( rStream
);
895 SwTableAutoFmtTbl::SwTableAutoFmtTbl()
898 SwTableAutoFmt
* pNew
= new SwTableAutoFmt(
899 SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD
, sNm
) );
905 Color
aColor( COL_BLUE
);
906 SvxBrushItem
aBrushItem( aColor
, RES_BACKGROUND
);
907 aNew
.SetBackground( aBrushItem
);
908 aNew
.SetColor( SvxColorItem(Color( COL_WHITE
), RES_CHRATR_COLOR
) );
910 for( i
= 0; i
< 4; ++i
)
911 pNew
->SetBoxFmt( aNew
, i
);
914 aBrushItem
.SetColor( RGB_COLORDATA( 0x4d, 0x4d, 0x4d ) );
915 aNew
.SetBackground( aBrushItem
);
916 for( i
= 4; i
<= 12; i
+= 4 )
917 pNew
->SetBoxFmt( aNew
, i
);
920 aBrushItem
.SetColor( RGB_COLORDATA( 0xcc, 0xcc, 0xcc ) );
921 aNew
.SetBackground( aBrushItem
);
922 aColor
.SetColor( COL_BLACK
);
923 aNew
.SetColor( SvxColorItem( aColor
, RES_CHRATR_COLOR
) );
924 for( i
= 7; i
<= 15; i
+= 4 )
925 pNew
->SetBoxFmt( aNew
, i
);
926 for( i
= 13; i
<= 14; ++i
)
927 pNew
->SetBoxFmt( aNew
, i
);
929 aBrushItem
.SetColor( Color( COL_WHITE
) );
930 aNew
.SetBackground( aBrushItem
);
931 for( i
= 5; i
<= 6; ++i
)
932 pNew
->SetBoxFmt( aNew
, i
);
933 for( i
= 9; i
<= 10; ++i
)
934 pNew
->SetBoxFmt( aNew
, i
);
937 SvxBoxItem
aBox( RES_BOX
);
938 aBox
.SetDistance( 55 );
939 SvxBorderLine
aLn( &aColor
, DEF_LINE_WIDTH_0
);
940 aBox
.SetLine( &aLn
, BOX_LINE_LEFT
);
941 aBox
.SetLine( &aLn
, BOX_LINE_BOTTOM
);
943 for( i
= 0; i
<= 15; ++i
)
945 aBox
.SetLine( i
<= 3 ? &aLn
: 0, BOX_LINE_TOP
);
946 aBox
.SetLine( (3 == ( i
& 3 )) ? &aLn
: 0, BOX_LINE_RIGHT
);
947 ((SwBoxAutoFmt
&)pNew
->GetBoxFmt( i
)).SetBox( aBox
);
950 Insert( pNew
, Count() );
953 BOOL
SwTableAutoFmtTbl::Load()
956 String
sNm( String::CreateFromAscii(
957 RTL_CONSTASCII_STRINGPARAM( sAutoTblFmtName
)));
959 if( aOpt
.SearchFile( sNm
, SvtPathOptions::PATH_USERCONFIG
))
961 SfxMedium
aStream( sNm
, STREAM_STD_READ
, TRUE
);
962 bRet
= Load( *aStream
.GetInStream() );
969 BOOL
SwTableAutoFmtTbl::Save() const
971 SvtPathOptions aPathOpt
;
972 String
sNm( aPathOpt
.GetUserConfigPath() );
973 sNm
+= INET_PATH_TOKEN
;
974 sNm
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( sAutoTblFmtName
));
975 SfxMedium
aStream(sNm
, STREAM_STD_WRITE
, TRUE
);
976 return Save( *aStream
.GetOutStream() ) && aStream
.Commit();
979 BOOL
SwTableAutoFmtTbl::Load( SvStream
& rStream
)
981 BOOL bRet
= 0 == rStream
.GetError();
984 // Achtung hier muss ein allgemeiner Header gelesen werden
987 bRet
= 0 == rStream
.GetError();
991 SwAfVersions aVersions
;
993 if( nVal
== AUTOFORMAT_ID_358
||
994 (AUTOFORMAT_ID_504
<= nVal
&& nVal
<= AUTOFORMAT_ID
) )
996 UINT16 nFileVers
= SOFFICE_FILEFORMAT_40
;
998 long nPos
= rStream
.Tell();
999 rStream
>> nCnt
>> nChrSet
;
1001 // rStream >> nFileVers;
1002 if( rStream
.Tell() != ULONG(nPos
+ nCnt
) )
1004 ASSERT( !this, "Der Header enthaelt mehr/neuere Daten" );
1005 rStream
.Seek( nPos
+ nCnt
);
1007 rStream
.SetStreamCharSet( (CharSet
)nChrSet
);
1008 rStream
.SetVersion( nFileVers
);
1011 if( nVal
== AUTOFORMAT_ID_358
|| nVal
== AUTOFORMAT_ID_X
||
1012 (AUTOFORMAT_ID_504
<= nVal
&& nVal
<= AUTOFORMAT_ID
) )
1014 aVersions
.Load( rStream
, nVal
); // Item-Versionen
1016 SwTableAutoFmt
* pNew
;
1020 bRet
= 0 == rStream
.GetError();
1022 for( USHORT i
= 0; i
< nAnz
; ++i
)
1024 pNew
= new SwTableAutoFmt( aEmptyStr
);
1025 bRet
= pNew
->Load( rStream
, aVersions
);
1028 Insert( pNew
, Count() );
1038 else if( AUTOFORMAT_OLD_ID
== nVal
|| AUTOFORMAT_OLD_ID1
== nVal
)
1040 SwTableAutoFmt
* pNew
;
1045 memset( aArr
, 0, 12 * sizeof( USHORT
) );
1046 if( AUTOFORMAT_OLD_ID1
== nVal
)
1047 for( USHORT n
= 0; n
< 12; ++n
)
1048 rStream
>> aArr
[ n
];
1050 bRet
= 0 == rStream
.GetError();
1052 for( USHORT i
= 0; i
< nAnz
; ++i
)
1054 pNew
= new SwTableAutoFmt( aEmptyStr
);
1055 bRet
= pNew
->LoadOld( rStream
, aArr
);
1058 Insert( pNew
, Count() );
1074 BOOL
SwTableAutoFmtTbl::Save( SvStream
& rStream
) const
1076 BOOL bRet
= 0 == rStream
.GetError();
1079 rStream
.SetVersion( SOFFICE_FILEFORMAT_40
);
1081 // Achtung hier muss ein allgemeiner Header gespeichert werden
1082 USHORT nVal
= AUTOFORMAT_ID
;
1084 << (BYTE
)2 // Anzahl von Zeichen des Headers incl. diesem
1085 << (BYTE
)GetStoreCharSet( ::gsl_getSystemTextEncoding() );
1086 // << (BYTE)4 // Anzahl von Zeichen des Headers incl. diesem
1087 // << (BYTE)::GetSystemCharSet()
1088 // << (UNIT16)SOFFICE_FILEFORMAT_NOW;
1089 bRet
= 0 == rStream
.GetError();
1091 //-----------------------------------------------------------
1092 // die VersionsNummer fuer alle Attribute schreiben
1093 (*this)[ 0 ]->GetBoxFmt( 0 ).SaveVerionNo( rStream
);
1095 rStream
<< (USHORT
)(Count() - 1);
1096 bRet
= 0 == rStream
.GetError();
1098 for( USHORT i
= 1; bRet
&& i
< Count(); ++i
)
1100 SwTableAutoFmt
* pFmt
= (*this)[ i
];
1101 bRet
= pFmt
->Save( rStream
);