xref: /AOO41X/main/sc/source/core/tool/autoform.cxx (revision 79aad27f7f29270c03e208e3d687e8e3850af11d)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #define READ_OLDVERS
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "autoform.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <sfx2/app.hxx>
34cdf0e10cSrcweir #include <sfx2/docfile.hxx>
35cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
36cdf0e10cSrcweir #include <svl/itemset.hxx>
37cdf0e10cSrcweir #include <tools/shl.hxx>
38cdf0e10cSrcweir #include <vcl/svapp.hxx>
39cdf0e10cSrcweir #include <vcl/outdev.hxx>
40cdf0e10cSrcweir #include <svx/dialmgr.hxx>
41cdf0e10cSrcweir #include <svx/dialogs.hrc>
42cdf0e10cSrcweir #include <editeng/langitem.hxx>
43cdf0e10cSrcweir #include <tools/urlobj.hxx>
44cdf0e10cSrcweir #include <unotools/transliterationwrapper.hxx>
45cdf0e10cSrcweir #include <tools/tenccvt.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "globstr.hrc"
48cdf0e10cSrcweir #include "document.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //------------------------------------------------------------------------
51cdf0e10cSrcweir 
52cdf0e10cSrcweir const sal_Char *linker_dummy = "";
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //	Standard-Name ist jetzt STR_STYLENAME_STANDARD (wie Vorlagen)
55cdf0e10cSrcweir //static const sal_Char __FAR_DATA cStandardName[] = "Standard";
56cdf0e10cSrcweir 
57cdf0e10cSrcweir static const sal_Char __FAR_DATA sAutoTblFmtName[] = "autotbl.fmt";
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // bis SO5PF
60cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_X		= 9501;
61cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_358		= 9601;
62cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_X	= 9502;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // ab SO5
65cdf0e10cSrcweir //! in nachfolgenden Versionen muss der Betrag dieser IDs groesser sein
66cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_504		= 9801;
67cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_504	= 9802;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_552		= 9901;
70cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_552	= 9902;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // --- from 641 on: CJK and CTL font settings
73cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_641      = 10001;
74cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_641 = 10002;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir // --- from 680/dr14 on: diagonal frame lines
77cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_680DR14      = 10011;
78cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_680DR14 = 10012;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // --- from 680/dr25 on: #21549# store strings as UTF-8
81cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_680DR25      = 10021;
82cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_680DR25 = 10022;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir // --- from DEV300/overline2 on: #5991# overline support
85cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID_300OVRLN      = 10031;
86cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID_300OVRLN = 10032;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir // aktuelle Version
89cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_300OVRLN;
90cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_300OVRLN;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir #ifdef READ_OLDVERS
94cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_OLD_ID_OLD	= 4201;
95cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_OLD_DATA_ID	= 4202;
96cdf0e10cSrcweir const sal_uInt16 AUTOFORMAT_OLD_ID_NEW 	= 4203;
97cdf0e10cSrcweir #endif
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir //	Struct mit Versionsnummern der Items
101cdf0e10cSrcweir 
102cdf0e10cSrcweir struct ScAfVersions
103cdf0e10cSrcweir {
104cdf0e10cSrcweir public:
105cdf0e10cSrcweir 	sal_uInt16 nFontVersion;
106cdf0e10cSrcweir 	sal_uInt16 nFontHeightVersion;
107cdf0e10cSrcweir 	sal_uInt16 nWeightVersion;
108cdf0e10cSrcweir 	sal_uInt16 nPostureVersion;
109cdf0e10cSrcweir 	sal_uInt16 nUnderlineVersion;
110cdf0e10cSrcweir 	sal_uInt16 nOverlineVersion;
111cdf0e10cSrcweir 	sal_uInt16 nCrossedOutVersion;
112cdf0e10cSrcweir 	sal_uInt16 nContourVersion;
113cdf0e10cSrcweir 	sal_uInt16 nShadowedVersion;
114cdf0e10cSrcweir 	sal_uInt16 nColorVersion;
115cdf0e10cSrcweir 	sal_uInt16 nBoxVersion;
116cdf0e10cSrcweir     sal_uInt16 nLineVersion;
117cdf0e10cSrcweir 	sal_uInt16 nBrushVersion;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	sal_uInt16 nAdjustVersion;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	sal_uInt16 nHorJustifyVersion;
122cdf0e10cSrcweir 	sal_uInt16 nVerJustifyVersion;
123cdf0e10cSrcweir 	sal_uInt16 nOrientationVersion;
124cdf0e10cSrcweir 	sal_uInt16 nMarginVersion;
125cdf0e10cSrcweir 	sal_uInt16 nBoolVersion;
126cdf0e10cSrcweir 	sal_uInt16 nInt32Version;
127cdf0e10cSrcweir 	sal_uInt16 nRotateModeVersion;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	sal_uInt16 nNumFmtVersion;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	ScAfVersions();
132cdf0e10cSrcweir 	void Load( SvStream& rStream, sal_uInt16 nVer );
133cdf0e10cSrcweir 	static void Write(SvStream& rStream);
134cdf0e10cSrcweir };
135cdf0e10cSrcweir 
ScAfVersions()136cdf0e10cSrcweir ScAfVersions::ScAfVersions() :
137cdf0e10cSrcweir 	nFontVersion(0),
138cdf0e10cSrcweir 	nFontHeightVersion(0),
139cdf0e10cSrcweir 	nWeightVersion(0),
140cdf0e10cSrcweir 	nPostureVersion(0),
141cdf0e10cSrcweir 	nUnderlineVersion(0),
142cdf0e10cSrcweir 	nOverlineVersion(0),
143cdf0e10cSrcweir 	nCrossedOutVersion(0),
144cdf0e10cSrcweir 	nContourVersion(0),
145cdf0e10cSrcweir 	nShadowedVersion(0),
146cdf0e10cSrcweir 	nColorVersion(0),
147cdf0e10cSrcweir 	nBoxVersion(0),
148cdf0e10cSrcweir     nLineVersion(0),
149cdf0e10cSrcweir 	nBrushVersion(0),
150cdf0e10cSrcweir 	nAdjustVersion(0),
151cdf0e10cSrcweir 	nHorJustifyVersion(0),
152cdf0e10cSrcweir 	nVerJustifyVersion(0),
153cdf0e10cSrcweir 	nOrientationVersion(0),
154cdf0e10cSrcweir 	nMarginVersion(0),
155cdf0e10cSrcweir 	nBoolVersion(0),
156cdf0e10cSrcweir 	nInt32Version(0),
157cdf0e10cSrcweir 	nRotateModeVersion(0),
158cdf0e10cSrcweir 	nNumFmtVersion(0)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
Load(SvStream & rStream,sal_uInt16 nVer)162cdf0e10cSrcweir void ScAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 	rStream >> nFontVersion;
165cdf0e10cSrcweir 	rStream >> nFontHeightVersion;
166cdf0e10cSrcweir 	rStream >> nWeightVersion;
167cdf0e10cSrcweir 	rStream >> nPostureVersion;
168cdf0e10cSrcweir 	rStream >> nUnderlineVersion;
169cdf0e10cSrcweir     if ( nVer >= AUTOFORMAT_ID_300OVRLN )
170cdf0e10cSrcweir 		rStream >> nOverlineVersion;
171cdf0e10cSrcweir 	rStream >> nCrossedOutVersion;
172cdf0e10cSrcweir 	rStream >> nContourVersion;
173cdf0e10cSrcweir 	rStream >> nShadowedVersion;
174cdf0e10cSrcweir 	rStream >> nColorVersion;
175cdf0e10cSrcweir 	rStream >> nBoxVersion;
176cdf0e10cSrcweir     if ( nVer >= AUTOFORMAT_ID_680DR14 )
177cdf0e10cSrcweir         rStream >> nLineVersion;
178cdf0e10cSrcweir 	rStream >> nBrushVersion;
179cdf0e10cSrcweir 	rStream >> nAdjustVersion;
180cdf0e10cSrcweir 	rStream >> nHorJustifyVersion;
181cdf0e10cSrcweir 	rStream >> nVerJustifyVersion;
182cdf0e10cSrcweir 	rStream >> nOrientationVersion;
183cdf0e10cSrcweir 	rStream >> nMarginVersion;
184cdf0e10cSrcweir 	rStream >> nBoolVersion;
185cdf0e10cSrcweir 	if ( nVer >= AUTOFORMAT_ID_504 )
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		rStream >> nInt32Version;
188cdf0e10cSrcweir 		rStream >> nRotateModeVersion;
189cdf0e10cSrcweir 	}
190cdf0e10cSrcweir 	rStream >> nNumFmtVersion;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
Write(SvStream & rStream)193cdf0e10cSrcweir void ScAfVersions::Write(SvStream& rStream)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     rStream << SvxFontItem(ATTR_FONT).GetVersion(SOFFICE_FILEFORMAT_40);
196cdf0e10cSrcweir     rStream << SvxFontHeightItem(240, 100, ATTR_FONT_HEIGHT).GetVersion(SOFFICE_FILEFORMAT_40);
197cdf0e10cSrcweir     rStream << SvxWeightItem(WEIGHT_NORMAL, ATTR_FONT_WEIGHT).GetVersion(SOFFICE_FILEFORMAT_40);
198cdf0e10cSrcweir     rStream << SvxPostureItem(ITALIC_NONE, ATTR_FONT_POSTURE).GetVersion(SOFFICE_FILEFORMAT_40);
199cdf0e10cSrcweir     rStream << SvxUnderlineItem(UNDERLINE_NONE, ATTR_FONT_UNDERLINE).GetVersion(SOFFICE_FILEFORMAT_40);
200cdf0e10cSrcweir     rStream << SvxOverlineItem(UNDERLINE_NONE, ATTR_FONT_OVERLINE).GetVersion(SOFFICE_FILEFORMAT_40);
201cdf0e10cSrcweir     rStream << SvxCrossedOutItem(STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT).GetVersion(SOFFICE_FILEFORMAT_40);
202cdf0e10cSrcweir     rStream << SvxContourItem(sal_False, ATTR_FONT_CONTOUR).GetVersion(SOFFICE_FILEFORMAT_40);
203cdf0e10cSrcweir     rStream << SvxShadowedItem(sal_False, ATTR_FONT_SHADOWED).GetVersion(SOFFICE_FILEFORMAT_40);
204cdf0e10cSrcweir     rStream << SvxColorItem(ATTR_FONT_COLOR).GetVersion(SOFFICE_FILEFORMAT_40);
205cdf0e10cSrcweir     rStream << SvxBoxItem(ATTR_BORDER).GetVersion(SOFFICE_FILEFORMAT_40);
206cdf0e10cSrcweir     rStream << SvxLineItem(SID_FRAME_LINESTYLE).GetVersion(SOFFICE_FILEFORMAT_40);
207cdf0e10cSrcweir     rStream << SvxBrushItem(ATTR_BACKGROUND).GetVersion(SOFFICE_FILEFORMAT_40);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     rStream << SvxAdjustItem(SVX_ADJUST_LEFT, 0).GetVersion(SOFFICE_FILEFORMAT_40);
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     rStream << SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY).GetVersion(SOFFICE_FILEFORMAT_40);
212cdf0e10cSrcweir     rStream << SvxVerJustifyItem(SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY).GetVersion(SOFFICE_FILEFORMAT_40);
213cdf0e10cSrcweir     rStream << SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion(SOFFICE_FILEFORMAT_40);
214cdf0e10cSrcweir     rStream << SvxMarginItem(ATTR_MARGIN).GetVersion(SOFFICE_FILEFORMAT_40);
215cdf0e10cSrcweir 	rStream << SfxBoolItem(ATTR_LINEBREAK).GetVersion(SOFFICE_FILEFORMAT_40);
216cdf0e10cSrcweir 	rStream << SfxInt32Item(ATTR_ROTATE_VALUE).GetVersion(SOFFICE_FILEFORMAT_40);
217cdf0e10cSrcweir 	rStream << SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD,0).GetVersion(SOFFICE_FILEFORMAT_40);
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	rStream << (sal_uInt16)0;		// Num-Format
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir //	---------------------------------------------------------------------------
223cdf0e10cSrcweir 
ScAutoFormatDataField()224cdf0e10cSrcweir ScAutoFormatDataField::ScAutoFormatDataField() :
225cdf0e10cSrcweir     aFont( ATTR_FONT ),
226cdf0e10cSrcweir     aHeight( 240, 100, ATTR_FONT_HEIGHT ),
227cdf0e10cSrcweir     aWeight( WEIGHT_NORMAL, ATTR_FONT_WEIGHT ),
228cdf0e10cSrcweir     aPosture( ITALIC_NONE, ATTR_FONT_POSTURE ),
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     aCJKFont( ATTR_CJK_FONT ),
231cdf0e10cSrcweir     aCJKHeight( 240, 100, ATTR_CJK_FONT_HEIGHT ),
232cdf0e10cSrcweir     aCJKWeight( WEIGHT_NORMAL, ATTR_CJK_FONT_WEIGHT ),
233cdf0e10cSrcweir     aCJKPosture( ITALIC_NONE, ATTR_CJK_FONT_POSTURE ),
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     aCTLFont( ATTR_CTL_FONT ),
236cdf0e10cSrcweir     aCTLHeight( 240, 100, ATTR_CTL_FONT_HEIGHT ),
237cdf0e10cSrcweir     aCTLWeight( WEIGHT_NORMAL, ATTR_CTL_FONT_WEIGHT ),
238cdf0e10cSrcweir     aCTLPosture( ITALIC_NONE, ATTR_CTL_FONT_POSTURE ),
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     aUnderline( UNDERLINE_NONE,ATTR_FONT_UNDERLINE ),
241cdf0e10cSrcweir     aOverline( UNDERLINE_NONE,ATTR_FONT_OVERLINE ),
242cdf0e10cSrcweir     aCrossedOut( STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT ),
243cdf0e10cSrcweir     aContour( sal_False, ATTR_FONT_CONTOUR ),
244cdf0e10cSrcweir     aShadowed( sal_False, ATTR_FONT_SHADOWED ),
245cdf0e10cSrcweir     aColor( ATTR_FONT_COLOR ),
246cdf0e10cSrcweir     aBox( ATTR_BORDER ),
247cdf0e10cSrcweir     aTLBR( ATTR_BORDER_TLBR ),
248cdf0e10cSrcweir     aBLTR( ATTR_BORDER_BLTR ),
249cdf0e10cSrcweir     aBackground( ATTR_BACKGROUND ),
250cdf0e10cSrcweir     aAdjust( SVX_ADJUST_LEFT, 0 ),
251cdf0e10cSrcweir     aHorJustify( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY ),
252cdf0e10cSrcweir     aVerJustify( SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY ),
253cdf0e10cSrcweir     aMargin( ATTR_MARGIN ),
254cdf0e10cSrcweir     aLinebreak( ATTR_LINEBREAK ),
255cdf0e10cSrcweir     aRotateAngle( ATTR_ROTATE_VALUE ),
256cdf0e10cSrcweir     aRotateMode( SVX_ROTATE_MODE_STANDARD, ATTR_ROTATE_MODE )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
ScAutoFormatDataField(const ScAutoFormatDataField & rCopy)260cdf0e10cSrcweir ScAutoFormatDataField::ScAutoFormatDataField( const ScAutoFormatDataField& rCopy ) :
261cdf0e10cSrcweir     aFont( rCopy.aFont ),
262cdf0e10cSrcweir     aHeight( rCopy.aHeight ),
263cdf0e10cSrcweir     aWeight( rCopy.aWeight ),
264cdf0e10cSrcweir     aPosture( rCopy.aPosture ),
265cdf0e10cSrcweir     aCJKFont( rCopy.aCJKFont ),
266cdf0e10cSrcweir     aCJKHeight( rCopy.aCJKHeight ),
267cdf0e10cSrcweir     aCJKWeight( rCopy.aCJKWeight ),
268cdf0e10cSrcweir     aCJKPosture( rCopy.aCJKPosture ),
269cdf0e10cSrcweir     aCTLFont( rCopy.aCTLFont ),
270cdf0e10cSrcweir     aCTLHeight( rCopy.aCTLHeight ),
271cdf0e10cSrcweir     aCTLWeight( rCopy.aCTLWeight ),
272cdf0e10cSrcweir     aCTLPosture( rCopy.aCTLPosture ),
273cdf0e10cSrcweir     aUnderline( rCopy.aUnderline ),
274cdf0e10cSrcweir     aOverline( rCopy.aOverline ),
275cdf0e10cSrcweir     aCrossedOut( rCopy.aCrossedOut ),
276cdf0e10cSrcweir     aContour( rCopy.aContour ),
277cdf0e10cSrcweir     aShadowed( rCopy.aShadowed ),
278cdf0e10cSrcweir     aColor( rCopy.aColor ),
279cdf0e10cSrcweir     aBox( rCopy.aBox ),
280cdf0e10cSrcweir     aTLBR( rCopy.aTLBR ),
281cdf0e10cSrcweir     aBLTR( rCopy.aBLTR ),
282cdf0e10cSrcweir     aBackground( rCopy.aBackground ),
283cdf0e10cSrcweir     aAdjust( rCopy.aAdjust ),
284cdf0e10cSrcweir     aHorJustify( rCopy.aHorJustify ),
285cdf0e10cSrcweir     aVerJustify( rCopy.aVerJustify ),
286cdf0e10cSrcweir     aStacked( rCopy.aStacked ),
287cdf0e10cSrcweir     aMargin( rCopy.aMargin ),
288cdf0e10cSrcweir     aLinebreak( rCopy.aLinebreak ),
289cdf0e10cSrcweir     aRotateAngle( rCopy.aRotateAngle ),
290cdf0e10cSrcweir     aRotateMode( rCopy.aRotateMode ),
291cdf0e10cSrcweir     aNumFormat( rCopy.aNumFormat )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
~ScAutoFormatDataField()295cdf0e10cSrcweir ScAutoFormatDataField::~ScAutoFormatDataField()
296cdf0e10cSrcweir {
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
SetAdjust(const SvxAdjustItem & rAdjust)299cdf0e10cSrcweir void ScAutoFormatDataField::SetAdjust( const SvxAdjustItem& rAdjust )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir     aAdjust.SetAdjust( rAdjust.GetAdjust() );
302cdf0e10cSrcweir     aAdjust.SetOneWord( rAdjust.GetOneWord() );
303cdf0e10cSrcweir     aAdjust.SetLastBlock( rAdjust.GetLastBlock() );
304cdf0e10cSrcweir }
305cdf0e10cSrcweir 
306cdf0e10cSrcweir #define READ( aItem, ItemType, nVers )      \
307cdf0e10cSrcweir     pNew = aItem.Create( rStream, nVers );  \
308cdf0e10cSrcweir     aItem = *(ItemType*)pNew;               \
309cdf0e10cSrcweir 	delete pNew;
310cdf0e10cSrcweir 
Load(SvStream & rStream,const ScAfVersions & rVersions,sal_uInt16 nVer)311cdf0e10cSrcweir sal_Bool ScAutoFormatDataField::Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir     SfxPoolItem* pNew;
314cdf0e10cSrcweir     SvxOrientationItem aOrientation( SVX_ORIENTATION_STANDARD, 0 );
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     READ( aFont,        SvxFontItem,        rVersions.nFontVersion)
317cdf0e10cSrcweir     READ( aHeight,      SvxFontHeightItem,  rVersions.nFontHeightVersion)
318cdf0e10cSrcweir     READ( aWeight,      SvxWeightItem,      rVersions.nWeightVersion)
319cdf0e10cSrcweir     READ( aPosture,     SvxPostureItem,     rVersions.nPostureVersion)
320cdf0e10cSrcweir     // --- from 641 on: CJK and CTL font settings
321cdf0e10cSrcweir     if( AUTOFORMAT_DATA_ID_641 <= nVer )
322cdf0e10cSrcweir     {
323cdf0e10cSrcweir         READ( aCJKFont,     SvxFontItem,        rVersions.nFontVersion)
324cdf0e10cSrcweir         READ( aCJKHeight,   SvxFontHeightItem,  rVersions.nFontHeightVersion)
325cdf0e10cSrcweir         READ( aCJKWeight,   SvxWeightItem,      rVersions.nWeightVersion)
326cdf0e10cSrcweir         READ( aCJKPosture,  SvxPostureItem,     rVersions.nPostureVersion)
327cdf0e10cSrcweir         READ( aCTLFont,     SvxFontItem,        rVersions.nFontVersion)
328cdf0e10cSrcweir         READ( aCTLHeight,   SvxFontHeightItem,  rVersions.nFontHeightVersion)
329cdf0e10cSrcweir         READ( aCTLWeight,   SvxWeightItem,      rVersions.nWeightVersion)
330cdf0e10cSrcweir         READ( aCTLPosture,  SvxPostureItem,     rVersions.nPostureVersion)
331cdf0e10cSrcweir     }
332cdf0e10cSrcweir     READ( aUnderline,   SvxUnderlineItem,   rVersions.nUnderlineVersion)
333cdf0e10cSrcweir     if ( nVer >= AUTOFORMAT_DATA_ID_300OVRLN )
334cdf0e10cSrcweir     {
335cdf0e10cSrcweir 		READ( aOverline,    SvxOverlineItem,    rVersions.nOverlineVersion)
336cdf0e10cSrcweir     }
337cdf0e10cSrcweir     READ( aCrossedOut,  SvxCrossedOutItem,  rVersions.nCrossedOutVersion)
338cdf0e10cSrcweir     READ( aContour,     SvxContourItem,     rVersions.nContourVersion)
339cdf0e10cSrcweir     READ( aShadowed,    SvxShadowedItem,    rVersions.nShadowedVersion)
340cdf0e10cSrcweir     READ( aColor,       SvxColorItem,       rVersions.nColorVersion)
341cdf0e10cSrcweir     READ( aBox,         SvxBoxItem,         rVersions.nBoxVersion)
342cdf0e10cSrcweir 
343cdf0e10cSrcweir     // --- from 680/dr14 on: diagonal frame lines
344cdf0e10cSrcweir     if( AUTOFORMAT_DATA_ID_680DR14 <= nVer )
345cdf0e10cSrcweir     {
346cdf0e10cSrcweir         READ( aTLBR, SvxLineItem, rVersions.nLineVersion)
347cdf0e10cSrcweir         READ( aBLTR, SvxLineItem, rVersions.nLineVersion)
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     READ( aBackground,  SvxBrushItem,       rVersions.nBrushVersion)
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     pNew = aAdjust.Create( rStream, rVersions.nAdjustVersion );
353cdf0e10cSrcweir     SetAdjust( *(SvxAdjustItem*)pNew );
354cdf0e10cSrcweir     delete pNew;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     READ( aHorJustify,   SvxHorJustifyItem,  rVersions.nHorJustifyVersion)
357cdf0e10cSrcweir     READ( aVerJustify,   SvxVerJustifyItem,  rVersions.nVerJustifyVersion)
358cdf0e10cSrcweir     READ( aOrientation,  SvxOrientationItem, rVersions.nOrientationVersion)
359cdf0e10cSrcweir     READ( aMargin,       SvxMarginItem,      rVersions.nMarginVersion)
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     pNew = aLinebreak.Create( rStream, rVersions.nBoolVersion );
362cdf0e10cSrcweir     SetLinebreak( *(SfxBoolItem*)pNew );
363cdf0e10cSrcweir     delete pNew;
364cdf0e10cSrcweir 
365cdf0e10cSrcweir     if ( nVer >= AUTOFORMAT_DATA_ID_504 )
366cdf0e10cSrcweir     {
367cdf0e10cSrcweir         pNew = aRotateAngle.Create( rStream, rVersions.nInt32Version );
368cdf0e10cSrcweir         SetRotateAngle( *(SfxInt32Item*)pNew );
369cdf0e10cSrcweir         delete pNew;
370cdf0e10cSrcweir         pNew = aRotateMode.Create( rStream, rVersions.nRotateModeVersion );
371cdf0e10cSrcweir         SetRotateMode( *(SvxRotateModeItem*)pNew );
372cdf0e10cSrcweir         delete pNew;
373cdf0e10cSrcweir     }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     if( 0 == rVersions.nNumFmtVersion )
376cdf0e10cSrcweir     {
377cdf0e10cSrcweir         // --- from 680/dr25 on: #21549# store strings as UTF-8
378cdf0e10cSrcweir         CharSet eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
379cdf0e10cSrcweir         aNumFormat.Load( rStream, eCharSet );
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     //  adjust charset in font
383cdf0e10cSrcweir     CharSet eSysSet = gsl_getSystemTextEncoding();
384cdf0e10cSrcweir     CharSet eSrcSet = rStream.GetStreamCharSet();
385cdf0e10cSrcweir     if( eSrcSet != eSysSet && aFont.GetCharSet() == eSrcSet )
386cdf0e10cSrcweir         aFont.SetCharSet(eSysSet);
387cdf0e10cSrcweir 
388cdf0e10cSrcweir     aStacked.SetValue( aOrientation.IsStacked() );
389cdf0e10cSrcweir     aRotateAngle.SetValue( aOrientation.GetRotation( aRotateAngle.GetValue() ) );
390cdf0e10cSrcweir 
391cdf0e10cSrcweir     return (rStream.GetError() == 0);
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir #ifdef READ_OLDVERS
LoadOld(SvStream & rStream,const ScAfVersions & rVersions)395cdf0e10cSrcweir sal_Bool ScAutoFormatDataField::LoadOld( SvStream& rStream, const ScAfVersions& rVersions )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir     SfxPoolItem* pNew;
398cdf0e10cSrcweir     SvxOrientationItem aOrientation( SVX_ORIENTATION_STANDARD, 0 );
399cdf0e10cSrcweir 
400cdf0e10cSrcweir     aNumFormat.Load(rStream, rStream.GetStreamCharSet());
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     READ( aFont,        SvxFontItem,        rVersions.nFontVersion)
403cdf0e10cSrcweir     READ( aHeight,      SvxFontHeightItem,  rVersions.nFontHeightVersion)
404cdf0e10cSrcweir     READ( aWeight,      SvxWeightItem,      rVersions.nWeightVersion)
405cdf0e10cSrcweir     READ( aPosture,     SvxPostureItem,     rVersions.nPostureVersion)
406cdf0e10cSrcweir     READ( aUnderline,   SvxUnderlineItem,   rVersions.nUnderlineVersion)
407cdf0e10cSrcweir     READ( aCrossedOut,  SvxCrossedOutItem,  rVersions.nCrossedOutVersion)
408cdf0e10cSrcweir     READ( aContour,     SvxContourItem,     rVersions.nContourVersion)
409cdf0e10cSrcweir     READ( aShadowed,    SvxShadowedItem,    rVersions.nShadowedVersion)
410cdf0e10cSrcweir     READ( aColor,       SvxColorItem,       rVersions.nColorVersion)
411cdf0e10cSrcweir     READ( aHorJustify,  SvxHorJustifyItem,  rVersions.nHorJustifyVersion)
412cdf0e10cSrcweir     READ( aVerJustify,  SvxVerJustifyItem,  rVersions.nVerJustifyVersion)
413cdf0e10cSrcweir     READ( aOrientation, SvxOrientationItem, rVersions.nOrientationVersion)
414cdf0e10cSrcweir     pNew = aLinebreak.Create( rStream, rVersions.nBoolVersion );
415cdf0e10cSrcweir     SetLinebreak( *(SfxBoolItem*)pNew );
416cdf0e10cSrcweir     delete pNew;
417cdf0e10cSrcweir     READ( aMargin,      SvxMarginItem,      rVersions.nMarginVersion)
418cdf0e10cSrcweir     READ( aBox,         SvxBoxItem,         rVersions.nBoxVersion)
419cdf0e10cSrcweir     READ( aBackground,  SvxBrushItem,       rVersions.nBrushVersion)
420cdf0e10cSrcweir 
421cdf0e10cSrcweir     aStacked.SetValue( aOrientation.IsStacked() );
422cdf0e10cSrcweir     aRotateAngle.SetValue( aOrientation.GetRotation( aRotateAngle.GetValue() ) );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     return (rStream.GetError() == 0);
425cdf0e10cSrcweir }
426cdf0e10cSrcweir #endif
427cdf0e10cSrcweir 
Save(SvStream & rStream)428cdf0e10cSrcweir sal_Bool ScAutoFormatDataField::Save( SvStream& rStream )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
431cdf0e10cSrcweir 
432cdf0e10cSrcweir     aFont.Store         ( rStream, aFont.GetVersion( SOFFICE_FILEFORMAT_40 ) );
433cdf0e10cSrcweir     aHeight.Store       ( rStream, aHeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
434cdf0e10cSrcweir     aWeight.Store       ( rStream, aWeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
435cdf0e10cSrcweir     aPosture.Store      ( rStream, aPosture.GetVersion( SOFFICE_FILEFORMAT_40 ) );
436cdf0e10cSrcweir     // --- from 641 on: CJK and CTL font settings
437cdf0e10cSrcweir     aCJKFont.Store      ( rStream, aCJKFont.GetVersion( SOFFICE_FILEFORMAT_40 ) );
438cdf0e10cSrcweir     aCJKHeight.Store    ( rStream, aCJKHeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
439cdf0e10cSrcweir     aCJKWeight.Store    ( rStream, aCJKWeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
440cdf0e10cSrcweir     aCJKPosture.Store   ( rStream, aCJKPosture.GetVersion( SOFFICE_FILEFORMAT_40 ) );
441cdf0e10cSrcweir     aCTLFont.Store      ( rStream, aCTLFont.GetVersion( SOFFICE_FILEFORMAT_40 ) );
442cdf0e10cSrcweir     aCTLHeight.Store    ( rStream, aCTLHeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
443cdf0e10cSrcweir     aCTLWeight.Store    ( rStream, aCTLWeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
444cdf0e10cSrcweir     aCTLPosture.Store   ( rStream, aCTLPosture.GetVersion( SOFFICE_FILEFORMAT_40 ) );
445cdf0e10cSrcweir 
446cdf0e10cSrcweir     aUnderline.Store    ( rStream, aUnderline.GetVersion( SOFFICE_FILEFORMAT_40 ) );
447cdf0e10cSrcweir     // --- from DEV300/overline2 on: overline support
448cdf0e10cSrcweir     aOverline.Store     ( rStream, aOverline.GetVersion( SOFFICE_FILEFORMAT_40 ) );
449cdf0e10cSrcweir     aCrossedOut.Store   ( rStream, aCrossedOut.GetVersion( SOFFICE_FILEFORMAT_40 ) );
450cdf0e10cSrcweir     aContour.Store      ( rStream, aContour.GetVersion( SOFFICE_FILEFORMAT_40 ) );
451cdf0e10cSrcweir     aShadowed.Store     ( rStream, aShadowed.GetVersion( SOFFICE_FILEFORMAT_40 ) );
452cdf0e10cSrcweir     aColor.Store        ( rStream, aColor.GetVersion( SOFFICE_FILEFORMAT_40 ) );
453cdf0e10cSrcweir     aBox.Store          ( rStream, aBox.GetVersion( SOFFICE_FILEFORMAT_40 ) );
454cdf0e10cSrcweir 
455cdf0e10cSrcweir     // --- from 680/dr14 on: diagonal frame lines
456cdf0e10cSrcweir     aTLBR.Store         ( rStream, aTLBR.GetVersion( SOFFICE_FILEFORMAT_40 ) );
457cdf0e10cSrcweir     aBLTR.Store         ( rStream, aBLTR.GetVersion( SOFFICE_FILEFORMAT_40 ) );
458cdf0e10cSrcweir 
459cdf0e10cSrcweir     aBackground.Store   ( rStream, aBackground.GetVersion( SOFFICE_FILEFORMAT_40 ) );
460cdf0e10cSrcweir 
461cdf0e10cSrcweir     aAdjust.Store       ( rStream, aAdjust.GetVersion( SOFFICE_FILEFORMAT_40 ) );
462cdf0e10cSrcweir 
463cdf0e10cSrcweir     aHorJustify.Store   ( rStream, aHorJustify.GetVersion( SOFFICE_FILEFORMAT_40 ) );
464cdf0e10cSrcweir     aVerJustify.Store   ( rStream, aVerJustify.GetVersion( SOFFICE_FILEFORMAT_40 ) );
465cdf0e10cSrcweir     aOrientation.Store  ( rStream, aOrientation.GetVersion( SOFFICE_FILEFORMAT_40 ) );
466cdf0e10cSrcweir     aMargin.Store       ( rStream, aMargin.GetVersion( SOFFICE_FILEFORMAT_40 ) );
467cdf0e10cSrcweir     aLinebreak.Store    ( rStream, aLinebreak.GetVersion( SOFFICE_FILEFORMAT_40 ) );
468cdf0e10cSrcweir     // Rotation ab SO5
469cdf0e10cSrcweir     aRotateAngle.Store  ( rStream, aRotateAngle.GetVersion( SOFFICE_FILEFORMAT_40 ) );
470cdf0e10cSrcweir     aRotateMode.Store   ( rStream, aRotateMode.GetVersion( SOFFICE_FILEFORMAT_40 ) );
471cdf0e10cSrcweir 
472cdf0e10cSrcweir     // --- from 680/dr25 on: #21549# store strings as UTF-8
473cdf0e10cSrcweir     aNumFormat.Save( rStream, RTL_TEXTENCODING_UTF8 );
474cdf0e10cSrcweir 
475cdf0e10cSrcweir     return (rStream.GetError() == 0);
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 
479cdf0e10cSrcweir //	---------------------------------------------------------------------------
480cdf0e10cSrcweir 
ScAutoFormatData()481cdf0e10cSrcweir ScAutoFormatData::ScAutoFormatData()
482cdf0e10cSrcweir {
483cdf0e10cSrcweir 	nStrResId = USHRT_MAX;
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	bIncludeValueFormat =
486cdf0e10cSrcweir 	bIncludeFont =
487cdf0e10cSrcweir 	bIncludeJustify =
488cdf0e10cSrcweir 	bIncludeFrame =
489cdf0e10cSrcweir 	bIncludeBackground =
490cdf0e10cSrcweir 	bIncludeWidthHeight = sal_True;
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     ppDataField = new ScAutoFormatDataField*[ 16 ];
493cdf0e10cSrcweir     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
494cdf0e10cSrcweir         ppDataField[ nIndex ] = new ScAutoFormatDataField;
495cdf0e10cSrcweir }
496cdf0e10cSrcweir 
ScAutoFormatData(const ScAutoFormatData & rData)497cdf0e10cSrcweir ScAutoFormatData::ScAutoFormatData( const ScAutoFormatData& rData ) :
498cdf0e10cSrcweir         ScDataObject(),
499cdf0e10cSrcweir 		aName( rData.aName ),
500cdf0e10cSrcweir 		nStrResId( rData.nStrResId ),
501cdf0e10cSrcweir 		bIncludeFont( rData.bIncludeFont ),
502cdf0e10cSrcweir 		bIncludeJustify( rData.bIncludeJustify ),
503cdf0e10cSrcweir 		bIncludeFrame( rData.bIncludeFrame ),
504cdf0e10cSrcweir 		bIncludeBackground( rData.bIncludeBackground ),
505cdf0e10cSrcweir 		bIncludeValueFormat( rData.bIncludeValueFormat ),
506cdf0e10cSrcweir 		bIncludeWidthHeight( rData.bIncludeWidthHeight )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir     ppDataField = new ScAutoFormatDataField*[ 16 ];
509cdf0e10cSrcweir     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
510cdf0e10cSrcweir         ppDataField[ nIndex ] = new ScAutoFormatDataField( rData.GetField( nIndex ) );
511cdf0e10cSrcweir }
512cdf0e10cSrcweir 
~ScAutoFormatData()513cdf0e10cSrcweir ScAutoFormatData::~ScAutoFormatData()
514cdf0e10cSrcweir {
515cdf0e10cSrcweir     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
516cdf0e10cSrcweir         delete ppDataField[ nIndex ];
517cdf0e10cSrcweir     delete[] ppDataField;
518cdf0e10cSrcweir }
519cdf0e10cSrcweir 
GetField(sal_uInt16 nIndex)520cdf0e10cSrcweir ScAutoFormatDataField& ScAutoFormatData::GetField( sal_uInt16 nIndex )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir     DBG_ASSERT( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
523cdf0e10cSrcweir     DBG_ASSERT( ppDataField && ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
524cdf0e10cSrcweir     return *ppDataField[ nIndex ];
525cdf0e10cSrcweir }
526cdf0e10cSrcweir 
GetField(sal_uInt16 nIndex) const527cdf0e10cSrcweir const ScAutoFormatDataField& ScAutoFormatData::GetField( sal_uInt16 nIndex ) const
528cdf0e10cSrcweir {
529cdf0e10cSrcweir     DBG_ASSERT( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
530cdf0e10cSrcweir     DBG_ASSERT( ppDataField && ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
531cdf0e10cSrcweir     return *ppDataField[ nIndex ];
532cdf0e10cSrcweir }
533cdf0e10cSrcweir 
GetItem(sal_uInt16 nIndex,sal_uInt16 nWhich) const534cdf0e10cSrcweir const SfxPoolItem* ScAutoFormatData::GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const
535cdf0e10cSrcweir {
536cdf0e10cSrcweir     const ScAutoFormatDataField& rField = GetField( nIndex );
537cdf0e10cSrcweir     switch( nWhich )
538cdf0e10cSrcweir 	{
539cdf0e10cSrcweir         case ATTR_FONT:             return &rField.GetFont();
540cdf0e10cSrcweir         case ATTR_FONT_HEIGHT:      return &rField.GetHeight();
541cdf0e10cSrcweir         case ATTR_FONT_WEIGHT:      return &rField.GetWeight();
542cdf0e10cSrcweir         case ATTR_FONT_POSTURE:     return &rField.GetPosture();
543cdf0e10cSrcweir         case ATTR_CJK_FONT:         return &rField.GetCJKFont();
544cdf0e10cSrcweir         case ATTR_CJK_FONT_HEIGHT:  return &rField.GetCJKHeight();
545cdf0e10cSrcweir         case ATTR_CJK_FONT_WEIGHT:  return &rField.GetCJKWeight();
546cdf0e10cSrcweir         case ATTR_CJK_FONT_POSTURE: return &rField.GetCJKPosture();
547cdf0e10cSrcweir         case ATTR_CTL_FONT:         return &rField.GetCTLFont();
548cdf0e10cSrcweir         case ATTR_CTL_FONT_HEIGHT:  return &rField.GetCTLHeight();
549cdf0e10cSrcweir         case ATTR_CTL_FONT_WEIGHT:  return &rField.GetCTLWeight();
550cdf0e10cSrcweir         case ATTR_CTL_FONT_POSTURE: return &rField.GetCTLPosture();
551cdf0e10cSrcweir         case ATTR_FONT_UNDERLINE:   return &rField.GetUnderline();
552cdf0e10cSrcweir         case ATTR_FONT_OVERLINE:    return &rField.GetOverline();
553cdf0e10cSrcweir         case ATTR_FONT_CROSSEDOUT:  return &rField.GetCrossedOut();
554cdf0e10cSrcweir         case ATTR_FONT_CONTOUR:     return &rField.GetContour();
555cdf0e10cSrcweir         case ATTR_FONT_SHADOWED:    return &rField.GetShadowed();
556cdf0e10cSrcweir         case ATTR_FONT_COLOR:       return &rField.GetColor();
557cdf0e10cSrcweir         case ATTR_BORDER:           return &rField.GetBox();
558cdf0e10cSrcweir         case ATTR_BORDER_TLBR:      return &rField.GetTLBR();
559cdf0e10cSrcweir         case ATTR_BORDER_BLTR:      return &rField.GetBLTR();
560cdf0e10cSrcweir         case ATTR_BACKGROUND:       return &rField.GetBackground();
561cdf0e10cSrcweir         case ATTR_HOR_JUSTIFY:      return &rField.GetHorJustify();
562cdf0e10cSrcweir         case ATTR_VER_JUSTIFY:      return &rField.GetVerJustify();
563cdf0e10cSrcweir         case ATTR_STACKED:          return &rField.GetStacked();
564cdf0e10cSrcweir         case ATTR_MARGIN:           return &rField.GetMargin();
565cdf0e10cSrcweir         case ATTR_LINEBREAK:        return &rField.GetLinebreak();
566cdf0e10cSrcweir         case ATTR_ROTATE_VALUE:     return &rField.GetRotateAngle();
567cdf0e10cSrcweir         case ATTR_ROTATE_MODE:      return &rField.GetRotateMode();
568cdf0e10cSrcweir 	}
569cdf0e10cSrcweir 	return NULL;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir 
PutItem(sal_uInt16 nIndex,const SfxPoolItem & rItem)572cdf0e10cSrcweir void ScAutoFormatData::PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir     ScAutoFormatDataField& rField = GetField( nIndex );
575cdf0e10cSrcweir     switch( rItem.Which() )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir         case ATTR_FONT:             rField.SetFont( (const SvxFontItem&)rItem );              break;
578cdf0e10cSrcweir         case ATTR_FONT_HEIGHT:      rField.SetHeight( (const SvxFontHeightItem&)rItem );      break;
579cdf0e10cSrcweir         case ATTR_FONT_WEIGHT:      rField.SetWeight( (const SvxWeightItem&)rItem );          break;
580cdf0e10cSrcweir         case ATTR_FONT_POSTURE:     rField.SetPosture( (const SvxPostureItem&)rItem );        break;
581cdf0e10cSrcweir         case ATTR_CJK_FONT:         rField.SetCJKFont( (const SvxFontItem&)rItem );           break;
582cdf0e10cSrcweir         case ATTR_CJK_FONT_HEIGHT:  rField.SetCJKHeight( (const SvxFontHeightItem&)rItem );   break;
583cdf0e10cSrcweir         case ATTR_CJK_FONT_WEIGHT:  rField.SetCJKWeight( (const SvxWeightItem&)rItem );       break;
584cdf0e10cSrcweir         case ATTR_CJK_FONT_POSTURE: rField.SetCJKPosture( (const SvxPostureItem&)rItem );     break;
585cdf0e10cSrcweir         case ATTR_CTL_FONT:         rField.SetCTLFont( (const SvxFontItem&)rItem );           break;
586cdf0e10cSrcweir         case ATTR_CTL_FONT_HEIGHT:  rField.SetCTLHeight( (const SvxFontHeightItem&)rItem );   break;
587cdf0e10cSrcweir         case ATTR_CTL_FONT_WEIGHT:  rField.SetCTLWeight( (const SvxWeightItem&)rItem );       break;
588cdf0e10cSrcweir         case ATTR_CTL_FONT_POSTURE: rField.SetCTLPosture( (const SvxPostureItem&)rItem );     break;
589cdf0e10cSrcweir         case ATTR_FONT_UNDERLINE:   rField.SetUnderline( (const SvxUnderlineItem&)rItem );    break;
590cdf0e10cSrcweir         case ATTR_FONT_OVERLINE:    rField.SetOverline( (const SvxOverlineItem&)rItem );      break;
591cdf0e10cSrcweir         case ATTR_FONT_CROSSEDOUT:  rField.SetCrossedOut( (const SvxCrossedOutItem&)rItem );  break;
592cdf0e10cSrcweir         case ATTR_FONT_CONTOUR:     rField.SetContour( (const SvxContourItem&)rItem );        break;
593cdf0e10cSrcweir         case ATTR_FONT_SHADOWED:    rField.SetShadowed( (const SvxShadowedItem&)rItem );      break;
594cdf0e10cSrcweir         case ATTR_FONT_COLOR:       rField.SetColor( (const SvxColorItem&)rItem );            break;
595cdf0e10cSrcweir         case ATTR_BORDER:           rField.SetBox( (const SvxBoxItem&)rItem );                break;
596cdf0e10cSrcweir         case ATTR_BORDER_TLBR:      rField.SetTLBR( (const SvxLineItem&)rItem );              break;
597cdf0e10cSrcweir         case ATTR_BORDER_BLTR:      rField.SetBLTR( (const SvxLineItem&)rItem );              break;
598cdf0e10cSrcweir         case ATTR_BACKGROUND:       rField.SetBackground( (const SvxBrushItem&)rItem );       break;
599cdf0e10cSrcweir         case ATTR_HOR_JUSTIFY:      rField.SetHorJustify( (const SvxHorJustifyItem&)rItem );  break;
600cdf0e10cSrcweir         case ATTR_VER_JUSTIFY:      rField.SetVerJustify( (const SvxVerJustifyItem&)rItem );  break;
601cdf0e10cSrcweir         case ATTR_STACKED:          rField.SetStacked( (const SfxBoolItem&)rItem );           break;
602cdf0e10cSrcweir         case ATTR_MARGIN:           rField.SetMargin( (const SvxMarginItem&)rItem );          break;
603cdf0e10cSrcweir         case ATTR_LINEBREAK:        rField.SetLinebreak( (const SfxBoolItem&)rItem );         break;
604cdf0e10cSrcweir         case ATTR_ROTATE_VALUE:     rField.SetRotateAngle( (const SfxInt32Item&)rItem );      break;
605cdf0e10cSrcweir         case ATTR_ROTATE_MODE:      rField.SetRotateMode( (const SvxRotateModeItem&)rItem );  break;
606cdf0e10cSrcweir 	}
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
CopyItem(sal_uInt16 nToIndex,sal_uInt16 nFromIndex,sal_uInt16 nWhich)609cdf0e10cSrcweir void ScAutoFormatData::CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir     const SfxPoolItem* pItem = GetItem( nFromIndex, nWhich );
612cdf0e10cSrcweir     if( pItem )
613cdf0e10cSrcweir         PutItem( nToIndex, *pItem );
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
GetNumFormat(sal_uInt16 nIndex) const616cdf0e10cSrcweir const ScNumFormatAbbrev& ScAutoFormatData::GetNumFormat( sal_uInt16 nIndex ) const
617cdf0e10cSrcweir {
618cdf0e10cSrcweir     return GetField( nIndex ).GetNumFormat();
619cdf0e10cSrcweir }
620cdf0e10cSrcweir 
IsEqualData(sal_uInt16 nIndex1,sal_uInt16 nIndex2) const621cdf0e10cSrcweir sal_Bool ScAutoFormatData::IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const
622cdf0e10cSrcweir {
623cdf0e10cSrcweir 	sal_Bool bEqual = sal_True;
624cdf0e10cSrcweir     const ScAutoFormatDataField& rField1 = GetField( nIndex1 );
625cdf0e10cSrcweir     const ScAutoFormatDataField& rField2 = GetField( nIndex2 );
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     if( bIncludeValueFormat )
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir         bEqual = bEqual
630cdf0e10cSrcweir             && (rField1.GetNumFormat()      == rField2.GetNumFormat());
631cdf0e10cSrcweir 	}
632cdf0e10cSrcweir     if( bIncludeFont )
633cdf0e10cSrcweir 	{
634cdf0e10cSrcweir         bEqual = bEqual
635cdf0e10cSrcweir             && (rField1.GetFont()           == rField2.GetFont())
636cdf0e10cSrcweir             && (rField1.GetHeight()         == rField2.GetHeight())
637cdf0e10cSrcweir             && (rField1.GetWeight()         == rField2.GetWeight())
638cdf0e10cSrcweir             && (rField1.GetPosture()        == rField2.GetPosture())
639cdf0e10cSrcweir             && (rField1.GetCJKFont()        == rField2.GetCJKFont())
640cdf0e10cSrcweir             && (rField1.GetCJKHeight()      == rField2.GetCJKHeight())
641cdf0e10cSrcweir             && (rField1.GetCJKWeight()      == rField2.GetCJKWeight())
642cdf0e10cSrcweir             && (rField1.GetCJKPosture()     == rField2.GetCJKPosture())
643cdf0e10cSrcweir             && (rField1.GetCTLFont()        == rField2.GetCTLFont())
644cdf0e10cSrcweir             && (rField1.GetCTLHeight()      == rField2.GetCTLHeight())
645cdf0e10cSrcweir             && (rField1.GetCTLWeight()      == rField2.GetCTLWeight())
646cdf0e10cSrcweir             && (rField1.GetCTLPosture()     == rField2.GetCTLPosture())
647cdf0e10cSrcweir             && (rField1.GetUnderline()      == rField2.GetUnderline())
648cdf0e10cSrcweir             && (rField1.GetOverline()       == rField2.GetOverline())
649cdf0e10cSrcweir             && (rField1.GetCrossedOut()     == rField2.GetCrossedOut())
650cdf0e10cSrcweir             && (rField1.GetContour()        == rField2.GetContour())
651cdf0e10cSrcweir             && (rField1.GetShadowed()       == rField2.GetShadowed())
652cdf0e10cSrcweir             && (rField1.GetColor()          == rField2.GetColor());
653cdf0e10cSrcweir 	}
654cdf0e10cSrcweir     if( bIncludeJustify )
655cdf0e10cSrcweir 	{
656cdf0e10cSrcweir         bEqual = bEqual
657cdf0e10cSrcweir             && (rField1.GetHorJustify()     == rField2.GetHorJustify())
658cdf0e10cSrcweir             && (rField1.GetVerJustify()     == rField2.GetVerJustify())
659cdf0e10cSrcweir             && (rField1.GetStacked()        == rField2.GetStacked())
660cdf0e10cSrcweir             && (rField1.GetLinebreak()      == rField2.GetLinebreak())
661cdf0e10cSrcweir             && (rField1.GetMargin()         == rField2.GetMargin())
662cdf0e10cSrcweir             && (rField1.GetRotateAngle()    == rField2.GetRotateAngle())
663cdf0e10cSrcweir             && (rField1.GetRotateMode()     == rField2.GetRotateMode());
664cdf0e10cSrcweir 	}
665cdf0e10cSrcweir     if( bIncludeFrame )
666cdf0e10cSrcweir     {
667cdf0e10cSrcweir         bEqual = bEqual
668cdf0e10cSrcweir             && (rField1.GetBox()            == rField2.GetBox())
669cdf0e10cSrcweir             && (rField1.GetTLBR()           == rField2.GetTLBR())
670cdf0e10cSrcweir             && (rField1.GetBLTR()           == rField2.GetBLTR());
671cdf0e10cSrcweir     }
672cdf0e10cSrcweir     if( bIncludeBackground )
673cdf0e10cSrcweir     {
674cdf0e10cSrcweir         bEqual = bEqual
675cdf0e10cSrcweir             && (rField1.GetBackground()     == rField2.GetBackground());
676cdf0e10cSrcweir     }
677cdf0e10cSrcweir 	return bEqual;
678cdf0e10cSrcweir }
679cdf0e10cSrcweir 
FillToItemSet(sal_uInt16 nIndex,SfxItemSet & rItemSet,ScDocument & rDoc) const680cdf0e10cSrcweir void ScAutoFormatData::FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, ScDocument& rDoc ) const
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     const ScAutoFormatDataField& rField = GetField( nIndex );
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     if( bIncludeValueFormat )
685cdf0e10cSrcweir     {
686cdf0e10cSrcweir         ScNumFormatAbbrev& rNumFormat = (ScNumFormatAbbrev&)rField.GetNumFormat();
687cdf0e10cSrcweir         SfxUInt32Item aValueFormat( ATTR_VALUE_FORMAT, 0 );
688cdf0e10cSrcweir         aValueFormat.SetValue( rNumFormat.GetFormatIndex( *rDoc.GetFormatTable() ) );
689cdf0e10cSrcweir         rItemSet.Put( aValueFormat );
690cdf0e10cSrcweir         rItemSet.Put( SvxLanguageItem( rNumFormat.GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
691cdf0e10cSrcweir     }
692cdf0e10cSrcweir     if( bIncludeFont )
693cdf0e10cSrcweir     {
694cdf0e10cSrcweir         rItemSet.Put( rField.GetFont() );
695cdf0e10cSrcweir         rItemSet.Put( rField.GetHeight() );
696cdf0e10cSrcweir         rItemSet.Put( rField.GetWeight() );
697cdf0e10cSrcweir         rItemSet.Put( rField.GetPosture() );
698cdf0e10cSrcweir         // #103065# do not insert empty CJK font
699cdf0e10cSrcweir         const SvxFontItem& rCJKFont = rField.GetCJKFont();
700cdf0e10cSrcweir         if( rCJKFont.GetStyleName().Len() )
701cdf0e10cSrcweir         {
702cdf0e10cSrcweir             rItemSet.Put( rCJKFont );
703cdf0e10cSrcweir             rItemSet.Put( rField.GetCJKHeight() );
704cdf0e10cSrcweir             rItemSet.Put( rField.GetCJKWeight() );
705cdf0e10cSrcweir             rItemSet.Put( rField.GetCJKPosture() );
706cdf0e10cSrcweir         }
707cdf0e10cSrcweir         else
708cdf0e10cSrcweir         {
709cdf0e10cSrcweir             rItemSet.Put( rField.GetHeight(), ATTR_CJK_FONT_HEIGHT );
710cdf0e10cSrcweir             rItemSet.Put( rField.GetWeight(), ATTR_CJK_FONT_WEIGHT );
711cdf0e10cSrcweir             rItemSet.Put( rField.GetPosture(), ATTR_CJK_FONT_POSTURE );
712cdf0e10cSrcweir         }
713cdf0e10cSrcweir         // #103065# do not insert empty CTL font
714cdf0e10cSrcweir         const SvxFontItem& rCTLFont = rField.GetCTLFont();
715cdf0e10cSrcweir         if( rCTLFont.GetStyleName().Len() )
716cdf0e10cSrcweir         {
717cdf0e10cSrcweir             rItemSet.Put( rCTLFont );
718cdf0e10cSrcweir             rItemSet.Put( rField.GetCTLHeight() );
719cdf0e10cSrcweir             rItemSet.Put( rField.GetCTLWeight() );
720cdf0e10cSrcweir             rItemSet.Put( rField.GetCTLPosture() );
721cdf0e10cSrcweir         }
722cdf0e10cSrcweir         else
723cdf0e10cSrcweir         {
724cdf0e10cSrcweir             rItemSet.Put( rField.GetHeight(), ATTR_CTL_FONT_HEIGHT );
725cdf0e10cSrcweir             rItemSet.Put( rField.GetWeight(), ATTR_CTL_FONT_WEIGHT );
726cdf0e10cSrcweir             rItemSet.Put( rField.GetPosture(), ATTR_CTL_FONT_POSTURE );
727cdf0e10cSrcweir         }
728cdf0e10cSrcweir         rItemSet.Put( rField.GetUnderline() );
729cdf0e10cSrcweir         rItemSet.Put( rField.GetOverline() );
730cdf0e10cSrcweir         rItemSet.Put( rField.GetCrossedOut() );
731cdf0e10cSrcweir         rItemSet.Put( rField.GetContour() );
732cdf0e10cSrcweir         rItemSet.Put( rField.GetShadowed() );
733cdf0e10cSrcweir         rItemSet.Put( rField.GetColor() );
734cdf0e10cSrcweir     }
735cdf0e10cSrcweir     if( bIncludeJustify )
736cdf0e10cSrcweir     {
737cdf0e10cSrcweir         rItemSet.Put( rField.GetHorJustify() );
738cdf0e10cSrcweir         rItemSet.Put( rField.GetVerJustify() );
739cdf0e10cSrcweir         rItemSet.Put( rField.GetStacked() );
740cdf0e10cSrcweir         rItemSet.Put( rField.GetLinebreak() );
741cdf0e10cSrcweir         rItemSet.Put( rField.GetMargin() );
742cdf0e10cSrcweir         rItemSet.Put( rField.GetRotateAngle() );
743cdf0e10cSrcweir         rItemSet.Put( rField.GetRotateMode() );
744cdf0e10cSrcweir     }
745cdf0e10cSrcweir     if( bIncludeFrame )
746cdf0e10cSrcweir     {
747cdf0e10cSrcweir         rItemSet.Put( rField.GetBox() );
748cdf0e10cSrcweir         rItemSet.Put( rField.GetTLBR() );
749cdf0e10cSrcweir         rItemSet.Put( rField.GetBLTR() );
750cdf0e10cSrcweir     }
751cdf0e10cSrcweir     if( bIncludeBackground )
752cdf0e10cSrcweir         rItemSet.Put( rField.GetBackground() );
753cdf0e10cSrcweir }
754cdf0e10cSrcweir 
GetFromItemSet(sal_uInt16 nIndex,const SfxItemSet & rItemSet,const ScNumFormatAbbrev & rNumFormat)755cdf0e10cSrcweir void ScAutoFormatData::GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat )
756cdf0e10cSrcweir {
757cdf0e10cSrcweir     ScAutoFormatDataField& rField = GetField( nIndex );
758cdf0e10cSrcweir 
759cdf0e10cSrcweir     rField.SetNumFormat     ( rNumFormat);
760cdf0e10cSrcweir     rField.SetFont          ( (const SvxFontItem&)          rItemSet.Get( ATTR_FONT ) );
761cdf0e10cSrcweir     rField.SetHeight        ( (const SvxFontHeightItem&)    rItemSet.Get( ATTR_FONT_HEIGHT ) );
762cdf0e10cSrcweir     rField.SetWeight        ( (const SvxWeightItem&)        rItemSet.Get( ATTR_FONT_WEIGHT ) );
763cdf0e10cSrcweir     rField.SetPosture       ( (const SvxPostureItem&)       rItemSet.Get( ATTR_FONT_POSTURE ) );
764cdf0e10cSrcweir     rField.SetCJKFont       ( (const SvxFontItem&)          rItemSet.Get( ATTR_CJK_FONT ) );
765cdf0e10cSrcweir     rField.SetCJKHeight     ( (const SvxFontHeightItem&)    rItemSet.Get( ATTR_CJK_FONT_HEIGHT ) );
766cdf0e10cSrcweir     rField.SetCJKWeight     ( (const SvxWeightItem&)        rItemSet.Get( ATTR_CJK_FONT_WEIGHT ) );
767cdf0e10cSrcweir     rField.SetCJKPosture    ( (const SvxPostureItem&)       rItemSet.Get( ATTR_CJK_FONT_POSTURE ) );
768cdf0e10cSrcweir     rField.SetCTLFont       ( (const SvxFontItem&)          rItemSet.Get( ATTR_CTL_FONT ) );
769cdf0e10cSrcweir     rField.SetCTLHeight     ( (const SvxFontHeightItem&)    rItemSet.Get( ATTR_CTL_FONT_HEIGHT ) );
770cdf0e10cSrcweir     rField.SetCTLWeight     ( (const SvxWeightItem&)        rItemSet.Get( ATTR_CTL_FONT_WEIGHT ) );
771cdf0e10cSrcweir     rField.SetCTLPosture    ( (const SvxPostureItem&)       rItemSet.Get( ATTR_CTL_FONT_POSTURE ) );
772cdf0e10cSrcweir     rField.SetUnderline     ( (const SvxUnderlineItem&)     rItemSet.Get( ATTR_FONT_UNDERLINE ) );
773cdf0e10cSrcweir     rField.SetOverline      ( (const SvxOverlineItem&)      rItemSet.Get( ATTR_FONT_OVERLINE ) );
774cdf0e10cSrcweir     rField.SetCrossedOut    ( (const SvxCrossedOutItem&)    rItemSet.Get( ATTR_FONT_CROSSEDOUT ) );
775cdf0e10cSrcweir     rField.SetContour       ( (const SvxContourItem&)       rItemSet.Get( ATTR_FONT_CONTOUR ) );
776cdf0e10cSrcweir     rField.SetShadowed      ( (const SvxShadowedItem&)      rItemSet.Get( ATTR_FONT_SHADOWED ) );
777cdf0e10cSrcweir     rField.SetColor         ( (const SvxColorItem&)         rItemSet.Get( ATTR_FONT_COLOR ) );
778cdf0e10cSrcweir     rField.SetTLBR          ( (const SvxLineItem&)          rItemSet.Get( ATTR_BORDER_TLBR ) );
779cdf0e10cSrcweir     rField.SetBLTR          ( (const SvxLineItem&)          rItemSet.Get( ATTR_BORDER_BLTR ) );
780cdf0e10cSrcweir     rField.SetHorJustify    ( (const SvxHorJustifyItem&)    rItemSet.Get( ATTR_HOR_JUSTIFY ) );
781cdf0e10cSrcweir     rField.SetVerJustify    ( (const SvxVerJustifyItem&)    rItemSet.Get( ATTR_VER_JUSTIFY ) );
782cdf0e10cSrcweir     rField.SetStacked       ( (const SfxBoolItem&)          rItemSet.Get( ATTR_STACKED ) );
783cdf0e10cSrcweir     rField.SetLinebreak     ( (const SfxBoolItem&)          rItemSet.Get( ATTR_LINEBREAK ) );
784cdf0e10cSrcweir     rField.SetMargin        ( (const SvxMarginItem&)        rItemSet.Get( ATTR_MARGIN ) );
785cdf0e10cSrcweir     rField.SetBackground    ( (const SvxBrushItem&)         rItemSet.Get( ATTR_BACKGROUND ) );
786cdf0e10cSrcweir     rField.SetRotateAngle   ( (const SfxInt32Item&)         rItemSet.Get( ATTR_ROTATE_VALUE ) );
787cdf0e10cSrcweir     rField.SetRotateMode    ( (const SvxRotateModeItem&)    rItemSet.Get( ATTR_ROTATE_MODE ) );
788cdf0e10cSrcweir }
789cdf0e10cSrcweir 
Load(SvStream & rStream,const ScAfVersions & rVersions)790cdf0e10cSrcweir sal_Bool ScAutoFormatData::Load( SvStream& rStream, const ScAfVersions& rVersions )
791cdf0e10cSrcweir {
792cdf0e10cSrcweir 	sal_Bool    bRet = sal_True;
793cdf0e10cSrcweir     sal_uInt16  nVer = 0;
794cdf0e10cSrcweir     rStream >> nVer;
795cdf0e10cSrcweir 	bRet = 0 == rStream.GetError();
796cdf0e10cSrcweir     if( bRet && (nVer == AUTOFORMAT_DATA_ID_X ||
797cdf0e10cSrcweir             (AUTOFORMAT_DATA_ID_504 <= nVer && nVer <= AUTOFORMAT_DATA_ID)) )
798cdf0e10cSrcweir 	{
799cdf0e10cSrcweir         // --- from 680/dr25 on: #21549# store strings as UTF-8
800cdf0e10cSrcweir         CharSet eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
801cdf0e10cSrcweir         rStream.ReadByteString( aName, eCharSet );
802cdf0e10cSrcweir         if( AUTOFORMAT_DATA_ID_552 <= nVer )
803cdf0e10cSrcweir 		{
804cdf0e10cSrcweir 			rStream >> nStrResId;
805cdf0e10cSrcweir 			sal_uInt16 nId = RID_SVXSTR_TBLAFMT_BEGIN + nStrResId;
806cdf0e10cSrcweir 			if( RID_SVXSTR_TBLAFMT_BEGIN <= nId &&
807cdf0e10cSrcweir 				nId < RID_SVXSTR_TBLAFMT_END )
808cdf0e10cSrcweir 			{
809cdf0e10cSrcweir 				aName = SVX_RESSTR( nId );
810cdf0e10cSrcweir 			}
811cdf0e10cSrcweir 			else
812cdf0e10cSrcweir 				nStrResId = USHRT_MAX;
813cdf0e10cSrcweir 		}
814cdf0e10cSrcweir 
815cdf0e10cSrcweir         sal_Bool b;
816cdf0e10cSrcweir 		rStream >> b; bIncludeFont = b;
817cdf0e10cSrcweir 		rStream >> b; bIncludeJustify = b;
818cdf0e10cSrcweir 		rStream >> b; bIncludeFrame = b;
819cdf0e10cSrcweir 		rStream >> b; bIncludeBackground = b;
820cdf0e10cSrcweir 		rStream >> b; bIncludeValueFormat = b;
821cdf0e10cSrcweir 		rStream >> b; bIncludeWidthHeight = b;
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 		bRet = 0 == rStream.GetError();
824cdf0e10cSrcweir 		for( sal_uInt16 i = 0; bRet && i < 16; ++i )
825cdf0e10cSrcweir             bRet = GetField( i ).Load( rStream, rVersions, nVer );
826cdf0e10cSrcweir 	}
827cdf0e10cSrcweir 	else
828cdf0e10cSrcweir 		bRet = sal_False;
829cdf0e10cSrcweir 	return bRet;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir 
832cdf0e10cSrcweir #ifdef READ_OLDVERS
LoadOld(SvStream & rStream,const ScAfVersions & rVersions)833cdf0e10cSrcweir sal_Bool ScAutoFormatData::LoadOld( SvStream& rStream, const ScAfVersions& rVersions )
834cdf0e10cSrcweir {
835cdf0e10cSrcweir 	sal_Bool    bRet = sal_True;
836cdf0e10cSrcweir 	sal_uInt16  nVal = 0;
837cdf0e10cSrcweir 	rStream >> nVal;
838cdf0e10cSrcweir 	bRet = (rStream.GetError() == 0);
839cdf0e10cSrcweir 	if (bRet && (nVal == AUTOFORMAT_OLD_DATA_ID))
840cdf0e10cSrcweir 	{
841cdf0e10cSrcweir 		rStream.ReadByteString( aName, rStream.GetStreamCharSet() );
842cdf0e10cSrcweir 		sal_Bool b;
843cdf0e10cSrcweir 		rStream >> b; bIncludeFont = b;
844cdf0e10cSrcweir 		rStream >> b; bIncludeJustify = b;
845cdf0e10cSrcweir 		rStream >> b; bIncludeFrame = b;
846cdf0e10cSrcweir 		rStream >> b; bIncludeBackground = b;
847cdf0e10cSrcweir 		rStream >> b; bIncludeValueFormat = b;
848cdf0e10cSrcweir 		rStream >> b; bIncludeWidthHeight = b;
849cdf0e10cSrcweir 
850cdf0e10cSrcweir 		bRet = 0 == rStream.GetError();
851cdf0e10cSrcweir 		for (sal_uInt16 i=0; bRet && i < 16; i++)
852cdf0e10cSrcweir             bRet = GetField( i ).LoadOld( rStream, rVersions );
853cdf0e10cSrcweir 	}
854cdf0e10cSrcweir 	else
855cdf0e10cSrcweir 		bRet = sal_False;
856cdf0e10cSrcweir 	return bRet;
857cdf0e10cSrcweir }
858cdf0e10cSrcweir #endif
859cdf0e10cSrcweir 
Save(SvStream & rStream)860cdf0e10cSrcweir sal_Bool ScAutoFormatData::Save(SvStream& rStream)
861cdf0e10cSrcweir {
862cdf0e10cSrcweir 	sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
863cdf0e10cSrcweir 	sal_Bool b;
864cdf0e10cSrcweir 	rStream << nVal;
865cdf0e10cSrcweir     // --- from 680/dr25 on: #21549# store strings as UTF-8
866cdf0e10cSrcweir     rStream.WriteByteString( aName, RTL_TEXTENCODING_UTF8 );
867cdf0e10cSrcweir 
868cdf0e10cSrcweir #if 0
869cdf0e10cSrcweir 	//	This was an internal flag to allow creating AutoFormats with localized names
870cdf0e10cSrcweir 
871cdf0e10cSrcweir 	if ( USHRT_MAX == nStrResId )
872cdf0e10cSrcweir 	{
873cdf0e10cSrcweir 		String aIniVal( SFX_APP()->GetIniManager()->Get(
874cdf0e10cSrcweir 			SFX_GROUP_WORKINGSET_IMPL,
875cdf0e10cSrcweir 			String( RTL_CONSTASCII_USTRINGPARAM( "SaveTableAutoFmtNameId" ))));
876cdf0e10cSrcweir 		if( 0 != aIniVal.ToInt32() )
877cdf0e10cSrcweir 		{
878cdf0e10cSrcweir 			// check Name for ResId
879cdf0e10cSrcweir 			for( sal_uInt16 nId = RID_SVXSTR_TBLAFMT_BEGIN;
880cdf0e10cSrcweir 						RID_SVXSTR_TBLAFMT_END > nId; ++nId )
881cdf0e10cSrcweir 			{
882cdf0e10cSrcweir 				String s( SVX_RES( nId ) );
883cdf0e10cSrcweir 				if( s == aName )
884cdf0e10cSrcweir 				{
885cdf0e10cSrcweir 					nStrResId = nId - RID_SVXSTR_TBLAFMT_BEGIN;
886cdf0e10cSrcweir 					break;
887cdf0e10cSrcweir 				}
888cdf0e10cSrcweir 			}
889cdf0e10cSrcweir 		}
890cdf0e10cSrcweir 	}
891cdf0e10cSrcweir #endif
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 	rStream << nStrResId;
894cdf0e10cSrcweir 	rStream << ( b = bIncludeFont );
895cdf0e10cSrcweir 	rStream << ( b = bIncludeJustify );
896cdf0e10cSrcweir 	rStream << ( b = bIncludeFrame );
897cdf0e10cSrcweir 	rStream << ( b = bIncludeBackground );
898cdf0e10cSrcweir 	rStream << ( b = bIncludeValueFormat );
899cdf0e10cSrcweir 	rStream << ( b = bIncludeWidthHeight );
900cdf0e10cSrcweir 
901cdf0e10cSrcweir     sal_Bool bRet = 0 == rStream.GetError();
902cdf0e10cSrcweir 	for (sal_uInt16 i = 0; bRet && (i < 16); i++)
903cdf0e10cSrcweir         bRet = GetField( i ).Save( rStream );
904cdf0e10cSrcweir 
905cdf0e10cSrcweir 	return bRet;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir //---------------------------------------------------------------------------------------
909cdf0e10cSrcweir //---------------------------------------------------------------------------------------
910cdf0e10cSrcweir 
ScAutoFormat(sal_uInt16 nLim,sal_uInt16 nDel,sal_Bool bDup)911cdf0e10cSrcweir ScAutoFormat::ScAutoFormat(sal_uInt16 nLim, sal_uInt16 nDel, sal_Bool bDup):
912cdf0e10cSrcweir 	ScSortedCollection        (nLim, nDel, bDup),
913cdf0e10cSrcweir 	bSaveLater				(sal_False)
914cdf0e10cSrcweir {
915cdf0e10cSrcweir     //  create default autoformat
916cdf0e10cSrcweir     ScAutoFormatData* pData = new ScAutoFormatData;
917cdf0e10cSrcweir 	String aName(ScGlobal::GetRscString(STR_STYLENAME_STANDARD));
918cdf0e10cSrcweir 	pData->SetName(aName);
919cdf0e10cSrcweir 
920cdf0e10cSrcweir     //  default font, default height
921cdf0e10cSrcweir     Font aStdFont = OutputDevice::GetDefaultFont(
922cdf0e10cSrcweir         DEFAULTFONT_LATIN_SPREADSHEET, LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE );
923cdf0e10cSrcweir     SvxFontItem aFontItem(
924cdf0e10cSrcweir         aStdFont.GetFamily(), aStdFont.GetName(), aStdFont.GetStyleName(),
925cdf0e10cSrcweir         aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_FONT );
926cdf0e10cSrcweir 
927cdf0e10cSrcweir     aStdFont = OutputDevice::GetDefaultFont(
928cdf0e10cSrcweir         DEFAULTFONT_CJK_SPREADSHEET, LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE );
929cdf0e10cSrcweir     SvxFontItem aCJKFontItem(
930cdf0e10cSrcweir         aStdFont.GetFamily(), aStdFont.GetName(), aStdFont.GetStyleName(),
931cdf0e10cSrcweir         aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_CJK_FONT );
932cdf0e10cSrcweir 
933cdf0e10cSrcweir     aStdFont = OutputDevice::GetDefaultFont(
934cdf0e10cSrcweir         DEFAULTFONT_CTL_SPREADSHEET, LANGUAGE_ENGLISH_US, DEFAULTFONT_FLAGS_ONLYONE );
935cdf0e10cSrcweir     SvxFontItem aCTLFontItem(
936cdf0e10cSrcweir         aStdFont.GetFamily(), aStdFont.GetName(), aStdFont.GetStyleName(),
937cdf0e10cSrcweir         aStdFont.GetPitch(), aStdFont.GetCharSet(), ATTR_CTL_FONT );
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     SvxFontHeightItem aHeight( 200, 100, ATTR_FONT_HEIGHT );      // 10 pt;
940cdf0e10cSrcweir 
941cdf0e10cSrcweir     //  black thin border
942cdf0e10cSrcweir 	Color aBlack( COL_BLACK );
943cdf0e10cSrcweir 	SvxBorderLine aLine( &aBlack, DEF_LINE_WIDTH_0 );
944cdf0e10cSrcweir     SvxBoxItem aBox( ATTR_BORDER );
945cdf0e10cSrcweir 	aBox.SetLine(&aLine, BOX_LINE_LEFT);
946cdf0e10cSrcweir 	aBox.SetLine(&aLine, BOX_LINE_TOP);
947cdf0e10cSrcweir 	aBox.SetLine(&aLine, BOX_LINE_RIGHT);
948cdf0e10cSrcweir 	aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
949cdf0e10cSrcweir 
950cdf0e10cSrcweir 	Color aWhite(COL_WHITE);
951cdf0e10cSrcweir 	Color aBlue(COL_BLUE);
952cdf0e10cSrcweir     SvxColorItem aWhiteText( aWhite, ATTR_FONT_COLOR );
953cdf0e10cSrcweir     SvxColorItem aBlackText( aBlack, ATTR_FONT_COLOR );
954cdf0e10cSrcweir     SvxBrushItem aBlueBack( aBlue, ATTR_BACKGROUND );
955cdf0e10cSrcweir     SvxBrushItem aWhiteBack( aWhite, ATTR_BACKGROUND );
956cdf0e10cSrcweir     SvxBrushItem aGray70Back( Color(0x4d, 0x4d, 0x4d), ATTR_BACKGROUND );
957cdf0e10cSrcweir     SvxBrushItem aGray20Back( Color(0xcc, 0xcc, 0xcc), ATTR_BACKGROUND );
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<16; i++)
960cdf0e10cSrcweir 	{
961cdf0e10cSrcweir         pData->PutItem( i, aBox );
962cdf0e10cSrcweir         pData->PutItem( i, aFontItem );
963cdf0e10cSrcweir         pData->PutItem( i, aCJKFontItem );
964cdf0e10cSrcweir         pData->PutItem( i, aCTLFontItem );
965cdf0e10cSrcweir         aHeight.SetWhich( ATTR_FONT_HEIGHT );
966cdf0e10cSrcweir         pData->PutItem( i, aHeight );
967cdf0e10cSrcweir         aHeight.SetWhich( ATTR_CJK_FONT_HEIGHT );
968cdf0e10cSrcweir         pData->PutItem( i, aHeight );
969cdf0e10cSrcweir         aHeight.SetWhich( ATTR_CTL_FONT_HEIGHT );
970cdf0e10cSrcweir         pData->PutItem( i, aHeight );
971cdf0e10cSrcweir         if (i<4)                                    // top: white on blue
972cdf0e10cSrcweir 		{
973cdf0e10cSrcweir             pData->PutItem( i, aWhiteText );
974cdf0e10cSrcweir             pData->PutItem( i, aBlueBack );
975cdf0e10cSrcweir 		}
976cdf0e10cSrcweir         else if ( i%4 == 0 )                        // left: white on gray70
977cdf0e10cSrcweir 		{
978cdf0e10cSrcweir             pData->PutItem( i, aWhiteText );
979cdf0e10cSrcweir             pData->PutItem( i, aGray70Back );
980cdf0e10cSrcweir 		}
981cdf0e10cSrcweir         else if ( i%4 == 3 || i >= 12 )             // right and bottom: black on gray20
982cdf0e10cSrcweir 		{
983cdf0e10cSrcweir             pData->PutItem( i, aBlackText );
984cdf0e10cSrcweir             pData->PutItem( i, aGray20Back );
985cdf0e10cSrcweir 		}
986cdf0e10cSrcweir         else                                        // center: black on white
987cdf0e10cSrcweir 		{
988cdf0e10cSrcweir             pData->PutItem( i, aBlackText );
989cdf0e10cSrcweir             pData->PutItem( i, aWhiteBack );
990cdf0e10cSrcweir 		}
991cdf0e10cSrcweir 	}
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 	Insert(pData);
994cdf0e10cSrcweir }
995cdf0e10cSrcweir 
ScAutoFormat(const ScAutoFormat & rAutoFormat)996cdf0e10cSrcweir ScAutoFormat::ScAutoFormat(const ScAutoFormat& rAutoFormat) :
997cdf0e10cSrcweir 	ScSortedCollection (rAutoFormat),
998cdf0e10cSrcweir 	bSaveLater		 (sal_False)
999cdf0e10cSrcweir {}
1000cdf0e10cSrcweir 
~ScAutoFormat()1001cdf0e10cSrcweir ScAutoFormat::~ScAutoFormat()
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir 	//	Bei Aenderungen per StarOne wird nicht sofort gespeichert, sondern zuerst nur
1004cdf0e10cSrcweir 	//	das SaveLater Flag gesetzt. Wenn das Flag noch gesetzt ist, jetzt speichern.
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 	if (bSaveLater)
1007cdf0e10cSrcweir 		Save();
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir 
SetSaveLater(sal_Bool bSet)1010cdf0e10cSrcweir void ScAutoFormat::SetSaveLater( sal_Bool bSet )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir 	bSaveLater = bSet;
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir 
Compare(ScDataObject * pKey1,ScDataObject * pKey2) const1015cdf0e10cSrcweir short ScAutoFormat::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir 	String aStr1;
1018cdf0e10cSrcweir 	String aStr2;
1019cdf0e10cSrcweir 	((ScAutoFormatData*)pKey1)->GetName(aStr1);
1020cdf0e10cSrcweir 	((ScAutoFormatData*)pKey2)->GetName(aStr2);
1021cdf0e10cSrcweir 	String aStrStandard = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
1022cdf0e10cSrcweir     if ( ScGlobal::GetpTransliteration()->isEqual( aStr1, aStrStandard ) )
1023cdf0e10cSrcweir 		return -1;
1024cdf0e10cSrcweir     if ( ScGlobal::GetpTransliteration()->isEqual( aStr2, aStrStandard ) )
1025cdf0e10cSrcweir 		return 1;
1026cdf0e10cSrcweir     return (short) ScGlobal::GetpTransliteration()->compareString( aStr1, aStr2 );
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir 
Load()1029cdf0e10cSrcweir sal_Bool ScAutoFormat::Load()
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir 	INetURLObject aURL;
1034cdf0e10cSrcweir 	SvtPathOptions aPathOpt;
1035cdf0e10cSrcweir 	aURL.SetSmartURL( aPathOpt.GetUserConfigPath() );
1036cdf0e10cSrcweir 	aURL.setFinalSlash();
1037cdf0e10cSrcweir 	aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( sAutoTblFmtName ) ) );
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 	SfxMedium aMedium( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_READ, sal_True );
1040cdf0e10cSrcweir 	SvStream* pStream = aMedium.GetInStream();
1041cdf0e10cSrcweir 	bRet = (pStream && pStream->GetError() == 0);
1042cdf0e10cSrcweir 	if (bRet)
1043cdf0e10cSrcweir 	{
1044cdf0e10cSrcweir 		SvStream& rStream = *pStream;
1045cdf0e10cSrcweir 		// Achtung hier muss ein allgemeiner Header gelesen werden
1046cdf0e10cSrcweir 		sal_uInt16 nVal = 0;
1047cdf0e10cSrcweir 		rStream >> nVal;
1048cdf0e10cSrcweir 		bRet = 0 == rStream.GetError();
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 		ScAfVersions aVersions;
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir 		if (bRet)
1053cdf0e10cSrcweir 		{
1054cdf0e10cSrcweir 			if( nVal == AUTOFORMAT_ID_358 ||
1055cdf0e10cSrcweir 					(AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
1056cdf0e10cSrcweir 			{
1057cdf0e10cSrcweir 				sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_40;
1058cdf0e10cSrcweir 				sal_uInt8 nChrSet, nCnt;
1059cdf0e10cSrcweir 				long nPos = rStream.Tell();
1060cdf0e10cSrcweir 				rStream >> nCnt >> nChrSet;
1061cdf0e10cSrcweir //				if( 4 <= nCnt )
1062cdf0e10cSrcweir //					rStream >> nFileVers;
1063cdf0e10cSrcweir 				if( rStream.Tell() != sal_uLong(nPos + nCnt) )
1064cdf0e10cSrcweir 				{
1065cdf0e10cSrcweir 					DBG_ERRORFILE( "Der Header enthaelt mehr/neuere Daten" );
1066cdf0e10cSrcweir 					rStream.Seek( nPos + nCnt );
1067cdf0e10cSrcweir 				}
1068cdf0e10cSrcweir                 rStream.SetStreamCharSet( GetSOLoadTextEncoding( nChrSet, nFileVers ) );
1069cdf0e10cSrcweir 				rStream.SetVersion( nFileVers );
1070cdf0e10cSrcweir 			}
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 			if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
1073cdf0e10cSrcweir 					(AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
1074cdf0e10cSrcweir 			{
1075cdf0e10cSrcweir 				aVersions.Load( rStream, nVal );		// Item-Versionen
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 				ScAutoFormatData* pData;
1078cdf0e10cSrcweir 				sal_uInt16 nAnz = 0;
1079cdf0e10cSrcweir 				rStream >> nAnz;
1080cdf0e10cSrcweir 				bRet = (rStream.GetError() == 0);
1081cdf0e10cSrcweir 				for (sal_uInt16 i=0; bRet && (i < nAnz); i++)
1082cdf0e10cSrcweir 				{
1083cdf0e10cSrcweir 					pData = new ScAutoFormatData();
1084cdf0e10cSrcweir 					bRet = pData->Load(rStream, aVersions);
1085cdf0e10cSrcweir 					Insert(pData);
1086cdf0e10cSrcweir 				}
1087cdf0e10cSrcweir 			}
1088cdf0e10cSrcweir #ifdef READ_OLDVERS
1089cdf0e10cSrcweir 			else
1090cdf0e10cSrcweir 			{
1091cdf0e10cSrcweir 				if( AUTOFORMAT_OLD_ID_NEW == nVal )
1092cdf0e10cSrcweir 				{
1093cdf0e10cSrcweir 					// alte Version der Versions laden
1094cdf0e10cSrcweir 					rStream >> aVersions.nFontVersion;
1095cdf0e10cSrcweir 					rStream >> aVersions.nFontHeightVersion;
1096cdf0e10cSrcweir 					rStream >> aVersions.nWeightVersion;
1097cdf0e10cSrcweir 					rStream >> aVersions.nPostureVersion;
1098cdf0e10cSrcweir 					rStream >> aVersions.nUnderlineVersion;
1099cdf0e10cSrcweir 					rStream >> aVersions.nCrossedOutVersion;
1100cdf0e10cSrcweir 					rStream >> aVersions.nContourVersion;
1101cdf0e10cSrcweir 					rStream >> aVersions.nShadowedVersion;
1102cdf0e10cSrcweir 					rStream >> aVersions.nColorVersion;
1103cdf0e10cSrcweir 					rStream >> aVersions.nHorJustifyVersion;
1104cdf0e10cSrcweir 					rStream >> aVersions.nVerJustifyVersion;
1105cdf0e10cSrcweir 					rStream >> aVersions.nOrientationVersion;
1106cdf0e10cSrcweir 					rStream >> aVersions.nBoolVersion;
1107cdf0e10cSrcweir 					rStream >> aVersions.nMarginVersion;
1108cdf0e10cSrcweir 					rStream >> aVersions.nBoxVersion;
1109cdf0e10cSrcweir 					rStream >> aVersions.nBrushVersion;
1110cdf0e10cSrcweir 				}
1111cdf0e10cSrcweir 				if( AUTOFORMAT_OLD_ID_OLD == nVal ||
1112cdf0e10cSrcweir 					AUTOFORMAT_OLD_ID_NEW == nVal )
1113cdf0e10cSrcweir 				{
1114cdf0e10cSrcweir 					ScAutoFormatData* pData;
1115cdf0e10cSrcweir 					sal_uInt16 nAnz = 0;
1116cdf0e10cSrcweir 					rStream >> nAnz;
1117cdf0e10cSrcweir 					bRet = 0 == rStream.GetError();
1118cdf0e10cSrcweir 					for( sal_uInt16 i=0; bRet && (i < nAnz); ++i )
1119cdf0e10cSrcweir 					{
1120cdf0e10cSrcweir 						pData = new ScAutoFormatData();
1121cdf0e10cSrcweir 						bRet = pData->LoadOld( rStream, aVersions );
1122cdf0e10cSrcweir 						Insert( pData );
1123cdf0e10cSrcweir 					}
1124cdf0e10cSrcweir 				}
1125cdf0e10cSrcweir 				else
1126cdf0e10cSrcweir 					bRet = sal_False;
1127cdf0e10cSrcweir 			}
1128cdf0e10cSrcweir #endif
1129cdf0e10cSrcweir 		}
1130cdf0e10cSrcweir 	}
1131cdf0e10cSrcweir 	bSaveLater = sal_False;
1132cdf0e10cSrcweir 	return bRet;
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir 
Save()1135cdf0e10cSrcweir sal_Bool ScAutoFormat::Save()
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir 	INetURLObject aURL;
1140cdf0e10cSrcweir 	SvtPathOptions aPathOpt;
1141cdf0e10cSrcweir 	aURL.SetSmartURL( aPathOpt.GetUserConfigPath() );
1142cdf0e10cSrcweir 	aURL.setFinalSlash();
1143cdf0e10cSrcweir 	aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( sAutoTblFmtName ) ) );
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir 	SfxMedium aMedium( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_WRITE, sal_True );
1146cdf0e10cSrcweir 	SvStream* pStream = aMedium.GetOutStream();
1147cdf0e10cSrcweir 	bRet = (pStream && pStream->GetError() == 0);
1148cdf0e10cSrcweir 	if (bRet)
1149cdf0e10cSrcweir 	{
1150cdf0e10cSrcweir 		SvStream& rStream = *pStream;
1151cdf0e10cSrcweir 		rStream.SetVersion( SOFFICE_FILEFORMAT_40 );
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir 		// Achtung hier muss ein allgemeiner Header gespeichert werden
1154cdf0e10cSrcweir 		sal_uInt16 nVal = AUTOFORMAT_ID;
1155cdf0e10cSrcweir 		rStream << nVal
1156cdf0e10cSrcweir 				<< (sal_uInt8)2 		// Anzahl von Zeichen des Headers incl. diesem
1157cdf0e10cSrcweir                 << (sal_uInt8)::GetSOStoreTextEncoding(
1158cdf0e10cSrcweir                     gsl_getSystemTextEncoding(), sal::static_int_cast<sal_uInt16>(rStream.GetVersion()) );
1159cdf0e10cSrcweir //				<< (sal_uInt8)4 		// Anzahl von Zeichen des Headers incl. diesem
1160cdf0e10cSrcweir //				<< (sal_uInt8)::GetStoreCharSet(::GetSystemCharSet())
1161cdf0e10cSrcweir //				<< (UNIT16)SOFFICE_FILEFORMAT_NOW;
1162cdf0e10cSrcweir 		ScAfVersions::Write(rStream);			// Item-Versionen
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 		bRet = (rStream.GetError() == 0);
1165cdf0e10cSrcweir 		//-----------------------------------------------------------
1166cdf0e10cSrcweir 		rStream << (sal_uInt16)(nCount - 1);
1167cdf0e10cSrcweir 		bRet = (rStream.GetError() == 0);
1168cdf0e10cSrcweir 		for (sal_uInt16 i=1; bRet && (i < nCount); i++)
1169cdf0e10cSrcweir 			bRet = ((ScAutoFormatData*)pItems[i])->Save(rStream);
1170cdf0e10cSrcweir 		rStream.Flush();
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir 		aMedium.Commit();
1173cdf0e10cSrcweir 	}
1174cdf0e10cSrcweir 	bSaveLater = sal_False;
1175cdf0e10cSrcweir 	return bRet;
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir 
FindIndexPerName(const String & rName) const1178cdf0e10cSrcweir sal_uInt16 ScAutoFormat::FindIndexPerName( const String& rName ) const
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir 	String				aName;
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir 	for( sal_uInt16 i=0; i<nCount ; i++ )
1183cdf0e10cSrcweir 	{
1184cdf0e10cSrcweir 		ScAutoFormatData* pItem = (ScAutoFormatData*)pItems[i];
1185cdf0e10cSrcweir 		pItem->GetName( aName );
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 		if( aName == rName )
1188cdf0e10cSrcweir 			return i;
1189cdf0e10cSrcweir 	}
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir 	return 0;
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 
1197