xref: /AOO41X/main/sw/source/ui/config/uinums.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <hintids.hxx>
35*cdf0e10cSrcweir #include <svl/urihelper.hxx>
36*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
37*cdf0e10cSrcweir #include <tools/stream.hxx>
38*cdf0e10cSrcweir #ifndef _SFX_INIMGR_HXX
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
41*cdf0e10cSrcweir #include <svl/itemiter.hxx>
42*cdf0e10cSrcweir #include <editeng/brshitem.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <tools/resid.hxx>
46*cdf0e10cSrcweir #include <fmtornt.hxx>
47*cdf0e10cSrcweir #include <swtypes.hxx>		// Leerstring
48*cdf0e10cSrcweir #include <wrtsh.hxx>
49*cdf0e10cSrcweir #include <uinums.hxx>
50*cdf0e10cSrcweir #include <poolfmt.hxx>
51*cdf0e10cSrcweir #include <charfmt.hxx>
52*cdf0e10cSrcweir #include <frmatr.hxx>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include <unomid.h>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir using namespace ::com::sun::star;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #define VERSION_30B		((sal_uInt16)250)
60*cdf0e10cSrcweir #define VERSION_31B		((sal_uInt16)326)
61*cdf0e10cSrcweir #define VERSION_40A		((sal_uInt16)364)
62*cdf0e10cSrcweir #define VERSION_50A     ((sal_uInt16)373)
63*cdf0e10cSrcweir #define VERSION_53A     ((sal_uInt16)596)
64*cdf0e10cSrcweir #define ACT_NUM_VERSION	VERSION_53A
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #define NUMRULE_FILENAME "numrule.cfg"
67*cdf0e10cSrcweir #define CHAPTER_FILENAME "chapter.cfg"
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir /*------------------------------------------------------------------------
70*cdf0e10cSrcweir  Beschreibung:	Ops. zum Laden / Speichern
71*cdf0e10cSrcweir ------------------------------------------------------------------------*/
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir SV_IMPL_PTRARR( _SwNumFmtsAttrs, SfxPoolItem* )
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir // SwNumRulesWithName ----------------------------------------------------
78*cdf0e10cSrcweir // PUBLIC METHODES -------------------------------------------------------
79*cdf0e10cSrcweir /*------------------------------------------------------------------------
80*cdf0e10cSrcweir  Beschreibung:	Speichern einer Regel
81*cdf0e10cSrcweir  Parameter:		rCopy -- die zu speichernde Regel
82*cdf0e10cSrcweir 				nIdx -- Position, an der die Regel zu speichern ist.
83*cdf0e10cSrcweir 						Eine alte Regel an dieser Position wird ueberschrieben.
84*cdf0e10cSrcweir ------------------------------------------------------------------------*/
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir SwBaseNumRules::SwBaseNumRules( const String& rFileName )
87*cdf0e10cSrcweir     :
88*cdf0e10cSrcweir     sFileName( rFileName ),
89*cdf0e10cSrcweir     nVersion(0),
90*cdf0e10cSrcweir 	bModified( sal_False )
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir 	Init();
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir /*-----------------26.06.97 08.30-------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir --------------------------------------------------*/
98*cdf0e10cSrcweir SwBaseNumRules::~SwBaseNumRules()
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir 	if( bModified )
101*cdf0e10cSrcweir 	{
102*cdf0e10cSrcweir 		SvtPathOptions aPathOpt;
103*cdf0e10cSrcweir         String sNm( aPathOpt.GetUserConfigPath() );
104*cdf0e10cSrcweir 		sNm += INET_PATH_TOKEN;
105*cdf0e10cSrcweir 		sNm += sFileName;
106*cdf0e10cSrcweir 		INetURLObject aTempObj(sNm);
107*cdf0e10cSrcweir 		sNm = aTempObj.GetFull();
108*cdf0e10cSrcweir 		SfxMedium aStrm( sNm, STREAM_WRITE | STREAM_TRUNC |
109*cdf0e10cSrcweir 										STREAM_SHARE_DENYALL, sal_True );
110*cdf0e10cSrcweir 		Store( *aStrm.GetOutStream() );
111*cdf0e10cSrcweir 	}
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < nMaxRules; ++i )
114*cdf0e10cSrcweir 		delete pNumRules[i];
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir /*------------------------------------------------------------------------
118*cdf0e10cSrcweir  Beschreibung:
119*cdf0e10cSrcweir ------------------------------------------------------------------------*/
120*cdf0e10cSrcweir void  SwBaseNumRules::Init()
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < nMaxRules; ++i )
123*cdf0e10cSrcweir 		pNumRules[i] = 0;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	String sNm( sFileName );
126*cdf0e10cSrcweir 	SvtPathOptions aOpt;
127*cdf0e10cSrcweir 	if( aOpt.SearchFile( sNm, SvtPathOptions::PATH_USERCONFIG ))
128*cdf0e10cSrcweir 	{
129*cdf0e10cSrcweir 		SfxMedium aStrm( sNm, STREAM_STD_READ, sal_True );
130*cdf0e10cSrcweir 		Load( *aStrm.GetInStream() );
131*cdf0e10cSrcweir 	}
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir /*-----------------26.06.97 08.30-------------------
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir --------------------------------------------------*/
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir void SwBaseNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx)
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir 	ASSERT(nIdx < nMaxRules, Array der NumRules ueberindiziert.);
141*cdf0e10cSrcweir 	if( !pNumRules[nIdx] )
142*cdf0e10cSrcweir 		pNumRules[nIdx] = new SwNumRulesWithName( rCopy );
143*cdf0e10cSrcweir 	else
144*cdf0e10cSrcweir 		*pNumRules[nIdx] = rCopy;
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir // PROTECTED METHODES ----------------------------------------------------
148*cdf0e10cSrcweir /*------------------------------------------------------------------------
149*cdf0e10cSrcweir  Beschreibung:	Speichern
150*cdf0e10cSrcweir ------------------------------------------------------------------------*/
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir sal_Bool /**/ SwBaseNumRules::Store(SvStream &rStream)
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	rStream << ACT_NUM_VERSION;
155*cdf0e10cSrcweir 		// Schreiben, welche Positionen durch eine Regel belegt sind
156*cdf0e10cSrcweir 		// Anschliessend Schreiben der einzelnen Rules
157*cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < nMaxRules; ++i)
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		if(pNumRules[i])
160*cdf0e10cSrcweir 		{
161*cdf0e10cSrcweir 			rStream << (unsigned char) sal_True;
162*cdf0e10cSrcweir 			pNumRules[i]->Store( rStream );
163*cdf0e10cSrcweir 		}
164*cdf0e10cSrcweir 		else
165*cdf0e10cSrcweir 			rStream << (unsigned char) sal_False;
166*cdf0e10cSrcweir 	}
167*cdf0e10cSrcweir 	return sal_True;
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir /*------------------------------------------------------------------------
173*cdf0e10cSrcweir  Beschreibung:	Speichern / Laden
174*cdf0e10cSrcweir ------------------------------------------------------------------------*/
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir int SwBaseNumRules::Load(SvStream &rStream)
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir 	int			rc = 0;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 	rStream >> nVersion;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	// wegen eines kleinen aber schweren Fehlers schreibt die PreFinal die
184*cdf0e10cSrcweir 	// gleiche VERSION_40A wie das SP2 #55402#
185*cdf0e10cSrcweir 	if(VERSION_40A == nVersion)
186*cdf0e10cSrcweir 	{
187*cdf0e10cSrcweir 		DBG_ERROR("Version 364 ist nicht eindeutig #55402#");
188*cdf0e10cSrcweir 	}
189*cdf0e10cSrcweir 	else if( VERSION_30B == nVersion || VERSION_31B == nVersion ||
190*cdf0e10cSrcweir 			 ACT_NUM_VERSION >= nVersion )
191*cdf0e10cSrcweir 	{
192*cdf0e10cSrcweir 		unsigned char bRule = sal_False;
193*cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < nMaxRules; ++i)
194*cdf0e10cSrcweir 		{
195*cdf0e10cSrcweir 			rStream >> bRule;
196*cdf0e10cSrcweir 			if(bRule)
197*cdf0e10cSrcweir 				pNumRules[i] = new SwNumRulesWithName( rStream, nVersion );
198*cdf0e10cSrcweir 		}
199*cdf0e10cSrcweir 	}
200*cdf0e10cSrcweir 	else
201*cdf0e10cSrcweir 	{
202*cdf0e10cSrcweir 		rc = 1;
203*cdf0e10cSrcweir 	}
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 	return rc;
206*cdf0e10cSrcweir }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir /*-----------------26.06.97 08.34-------------------
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir --------------------------------------------------*/
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir /*------------------------------------------------------------------------*/
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir SwChapterNumRules::SwChapterNumRules() :
216*cdf0e10cSrcweir 	SwBaseNumRules(C2S(CHAPTER_FILENAME))
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir /*------------------------------------------------------------------------*/
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir  SwChapterNumRules::~SwChapterNumRules()
223*cdf0e10cSrcweir {
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir /*-----------------26.06.97 08.23-------------------
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir --------------------------------------------------*/
229*cdf0e10cSrcweir void SwChapterNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx)
230*cdf0e10cSrcweir {
231*cdf0e10cSrcweir 	bModified = sal_True;
232*cdf0e10cSrcweir 	SwBaseNumRules::ApplyNumRules(rCopy, nIdx);
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir /*------------------------------------------------------------------------*/
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir SwNumRulesWithName::SwNumRulesWithName( const SwNumRule &rCopy,
238*cdf0e10cSrcweir                                         const String &rName )
239*cdf0e10cSrcweir 	: aName(rName)
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir     for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir 		const SwNumFmt* pFmt = rCopy.GetNumFmt( n );
244*cdf0e10cSrcweir 		if( pFmt )
245*cdf0e10cSrcweir 			aFmts[ n ] = new _SwNumFmtGlobal( *pFmt );
246*cdf0e10cSrcweir 		else
247*cdf0e10cSrcweir 			aFmts[ n ] = 0;
248*cdf0e10cSrcweir 	}
249*cdf0e10cSrcweir }
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir /*------------------------------------------------------------------------
252*cdf0e10cSrcweir  Beschreibung:
253*cdf0e10cSrcweir ------------------------------------------------------------------------*/
254*cdf0e10cSrcweir SwNumRulesWithName::SwNumRulesWithName( const SwNumRulesWithName& rCopy )
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir 	memset( aFmts, 0, sizeof( aFmts ));
257*cdf0e10cSrcweir 	*this = rCopy;
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir /*------------------------------------------------------------------------
262*cdf0e10cSrcweir  Beschreibung:
263*cdf0e10cSrcweir ------------------------------------------------------------------------*/
264*cdf0e10cSrcweir SwNumRulesWithName::~SwNumRulesWithName()
265*cdf0e10cSrcweir {
266*cdf0e10cSrcweir 	for( int n = 0; n < MAXLEVEL; ++n )
267*cdf0e10cSrcweir 		delete aFmts[ n ];
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir /*------------------------------------------------------------------------
271*cdf0e10cSrcweir  Beschreibung:
272*cdf0e10cSrcweir ------------------------------------------------------------------------*/
273*cdf0e10cSrcweir const SwNumRulesWithName& SwNumRulesWithName::operator=(const SwNumRulesWithName &rCopy)
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir 	if( this != &rCopy )
276*cdf0e10cSrcweir 	{
277*cdf0e10cSrcweir 		aName = rCopy.aName;
278*cdf0e10cSrcweir 		for( int n = 0; n < MAXLEVEL; ++n )
279*cdf0e10cSrcweir 		{
280*cdf0e10cSrcweir 			delete aFmts[ n ];
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 			_SwNumFmtGlobal* pFmt = rCopy.aFmts[ n ];
283*cdf0e10cSrcweir 			if( pFmt )
284*cdf0e10cSrcweir 				aFmts[ n ] = new _SwNumFmtGlobal( *pFmt );
285*cdf0e10cSrcweir 			else
286*cdf0e10cSrcweir 				aFmts[ n ] = 0;
287*cdf0e10cSrcweir 		}
288*cdf0e10cSrcweir 	}
289*cdf0e10cSrcweir 	return *this;
290*cdf0e10cSrcweir }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir /*------------------------------------------------------------------------
293*cdf0e10cSrcweir  Beschreibung:
294*cdf0e10cSrcweir ------------------------------------------------------------------------*/
295*cdf0e10cSrcweir SwNumRulesWithName::SwNumRulesWithName( SvStream &rStream, sal_uInt16 nVersion )
296*cdf0e10cSrcweir {
297*cdf0e10cSrcweir 	CharSet eEncoding = gsl_getSystemTextEncoding();
298*cdf0e10cSrcweir 	rStream.ReadByteString(aName, eEncoding);
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 	char c;
301*cdf0e10cSrcweir 	for(sal_uInt16 n = 0; n < MAXLEVEL; ++n )
302*cdf0e10cSrcweir 	{
303*cdf0e10cSrcweir 		if( VERSION_30B == nVersion )
304*cdf0e10cSrcweir 			c = 1;
305*cdf0e10cSrcweir 		// wegen eines kleinen aber schweren Fehlers schreibt die PreFinal die
306*cdf0e10cSrcweir 		// gleiche VERSION_40A wie das SP2 #55402#
307*cdf0e10cSrcweir 		else if(nVersion < VERSION_40A && n > 5)
308*cdf0e10cSrcweir //		else if(nVersion < VERSION_50A && n > 5)
309*cdf0e10cSrcweir 			c = 0;
310*cdf0e10cSrcweir 		else
311*cdf0e10cSrcweir 			rStream >> c;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 		if( c )
314*cdf0e10cSrcweir 			aFmts[ n ] = new _SwNumFmtGlobal( rStream, nVersion );
315*cdf0e10cSrcweir 		else
316*cdf0e10cSrcweir 			aFmts[ n ] = 0;
317*cdf0e10cSrcweir 	}
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir /*------------------------------------------------------------------------
321*cdf0e10cSrcweir  Beschreibung:
322*cdf0e10cSrcweir ------------------------------------------------------------------------*/
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir void SwNumRulesWithName::MakeNumRule( SwWrtShell& rSh, SwNumRule& rChg ) const
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir     // --> OD 2008-02-11 #newlistlevelattrs#
327*cdf0e10cSrcweir     // --> OD 2008-06-06 #i89178#
328*cdf0e10cSrcweir     rChg = SwNumRule( aName, numfunc::GetDefaultPositionAndSpaceMode() );
329*cdf0e10cSrcweir     // <--
330*cdf0e10cSrcweir 	rChg.SetAutoRule( sal_False );
331*cdf0e10cSrcweir 	_SwNumFmtGlobal* pFmt;
332*cdf0e10cSrcweir 	for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
333*cdf0e10cSrcweir 		if( 0 != ( pFmt = aFmts[ n ] ) )
334*cdf0e10cSrcweir 		{
335*cdf0e10cSrcweir 			SwNumFmt aNew;
336*cdf0e10cSrcweir 			pFmt->ChgNumFmt( rSh, aNew );
337*cdf0e10cSrcweir 			rChg.Set( n, aNew );
338*cdf0e10cSrcweir 		}
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir /*------------------------------------------------------------------------
342*cdf0e10cSrcweir  Beschreibung:
343*cdf0e10cSrcweir ------------------------------------------------------------------------*/
344*cdf0e10cSrcweir void SwNumRulesWithName::Store( SvStream &rStream )
345*cdf0e10cSrcweir {
346*cdf0e10cSrcweir 	CharSet eEncoding = gsl_getSystemTextEncoding();
347*cdf0e10cSrcweir 	rStream.WriteByteString(aName, eEncoding);
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 	for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
350*cdf0e10cSrcweir 	{
351*cdf0e10cSrcweir 		_SwNumFmtGlobal* pFmt = aFmts[ n ];
352*cdf0e10cSrcweir 		if( pFmt )
353*cdf0e10cSrcweir 		{
354*cdf0e10cSrcweir 			rStream << (char)1;
355*cdf0e10cSrcweir 			pFmt->Store( rStream );
356*cdf0e10cSrcweir 		}
357*cdf0e10cSrcweir 		else
358*cdf0e10cSrcweir 			rStream << (char)0;
359*cdf0e10cSrcweir 	}
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir /*------------------------------------------------------------------------
362*cdf0e10cSrcweir  Beschreibung:
363*cdf0e10cSrcweir ------------------------------------------------------------------------*/
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( const SwNumFmt& rFmt )
367*cdf0e10cSrcweir 	: aFmt( rFmt ), nCharPoolId( USHRT_MAX )
368*cdf0e10cSrcweir {
369*cdf0e10cSrcweir 	// relative Abstaende ?????
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 	SwCharFmt* pFmt = rFmt.GetCharFmt();
372*cdf0e10cSrcweir 	if( pFmt )
373*cdf0e10cSrcweir 	{
374*cdf0e10cSrcweir 		sCharFmtName = pFmt->GetName();
375*cdf0e10cSrcweir 		nCharPoolId = pFmt->GetPoolFmtId();
376*cdf0e10cSrcweir 		if( pFmt->GetAttrSet().Count() )
377*cdf0e10cSrcweir 		{
378*cdf0e10cSrcweir 			SfxItemIter aIter( pFmt->GetAttrSet() );
379*cdf0e10cSrcweir 			const SfxPoolItem *pCurr = aIter.GetCurItem();
380*cdf0e10cSrcweir 			while( sal_True )
381*cdf0e10cSrcweir 			{
382*cdf0e10cSrcweir 				aItems.Insert( pCurr->Clone(), aItems.Count() );
383*cdf0e10cSrcweir 				if( aIter.IsAtEnd() )
384*cdf0e10cSrcweir 					break;
385*cdf0e10cSrcweir 				pCurr = aIter.NextItem();
386*cdf0e10cSrcweir 			}
387*cdf0e10cSrcweir 		}
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 		aFmt.SetCharFmt( 0 );
390*cdf0e10cSrcweir 	}
391*cdf0e10cSrcweir }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir /*------------------------------------------------------------------------
394*cdf0e10cSrcweir  Beschreibung:
395*cdf0e10cSrcweir ------------------------------------------------------------------------*/
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( const _SwNumFmtGlobal& rFmt )
398*cdf0e10cSrcweir     :
399*cdf0e10cSrcweir     aFmt( rFmt.aFmt ),
400*cdf0e10cSrcweir     sCharFmtName( rFmt.sCharFmtName ),
401*cdf0e10cSrcweir     nCharPoolId( rFmt.nCharPoolId )
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	for( sal_uInt16 n = rFmt.aItems.Count(); n; )
404*cdf0e10cSrcweir 		aItems.Insert( rFmt.aItems[ --n ]->Clone(), aItems.Count() );
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir /*------------------------------------------------------------------------
408*cdf0e10cSrcweir  Beschreibung:
409*cdf0e10cSrcweir ------------------------------------------------------------------------*/
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir SwNumRulesWithName::_SwNumFmtGlobal::_SwNumFmtGlobal( SvStream& rStream,
412*cdf0e10cSrcweir 														sal_uInt16 nVersion )
413*cdf0e10cSrcweir 	: nCharPoolId( USHRT_MAX )
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir 	CharSet eEncoding = gsl_getSystemTextEncoding();
416*cdf0e10cSrcweir 	{
417*cdf0e10cSrcweir 		sal_uInt16 nUS;
418*cdf0e10cSrcweir 		sal_Char cChar;
419*cdf0e10cSrcweir 		short nShort;
420*cdf0e10cSrcweir 		sal_Bool bFlag;
421*cdf0e10cSrcweir 		String sStr;
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 		rStream >> nUS;				aFmt.SetNumberingType((sal_Int16)nUS );
424*cdf0e10cSrcweir 		if( VERSION_53A > nVersion )
425*cdf0e10cSrcweir 		{
426*cdf0e10cSrcweir 			rStream >> cChar;		aFmt.SetBulletChar( cChar );
427*cdf0e10cSrcweir 		}
428*cdf0e10cSrcweir 		else
429*cdf0e10cSrcweir 		{
430*cdf0e10cSrcweir 			rStream >> nUS; 		aFmt.SetBulletChar( nUS );
431*cdf0e10cSrcweir 		}
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 		rStream >> bFlag;			aFmt.SetIncludeUpperLevels( bFlag );
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 		if( VERSION_30B == nVersion )
436*cdf0e10cSrcweir 		{
437*cdf0e10cSrcweir 			long nL;
438*cdf0e10cSrcweir 			rStream >> cChar;		aFmt.SetStart( (sal_uInt16)cChar );
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 			rStream.ReadByteString(sStr, eEncoding);
441*cdf0e10cSrcweir 			aFmt.SetPrefix( sStr );
442*cdf0e10cSrcweir 			rStream.ReadByteString(sStr, eEncoding);
443*cdf0e10cSrcweir 			aFmt.SetSuffix( sStr );
444*cdf0e10cSrcweir 			rStream >> nUS;			aFmt.SetNumAdjust( SvxAdjust( nUS ) );
445*cdf0e10cSrcweir 			rStream >> nL;			aFmt.SetLSpace( lNumIndent );
446*cdf0e10cSrcweir 			rStream >> nL;			aFmt.SetFirstLineOffset( (short)nL );
447*cdf0e10cSrcweir 		}
448*cdf0e10cSrcweir 		else 				// alter StartWert war ein Byte
449*cdf0e10cSrcweir 		{
450*cdf0e10cSrcweir 			rStream >> nUS;			aFmt.SetStart( nUS );
451*cdf0e10cSrcweir 			rStream.ReadByteString(sStr, eEncoding);
452*cdf0e10cSrcweir 			aFmt.SetPrefix( sStr );
453*cdf0e10cSrcweir 			rStream.ReadByteString(sStr, eEncoding);
454*cdf0e10cSrcweir 			aFmt.SetSuffix( sStr );
455*cdf0e10cSrcweir 			rStream >> nUS;			aFmt.SetNumAdjust( SvxAdjust( nUS ) );
456*cdf0e10cSrcweir 			rStream >> nUS;			aFmt.SetAbsLSpace( nUS );
457*cdf0e10cSrcweir 			rStream >> nShort;		aFmt.SetFirstLineOffset( nShort );
458*cdf0e10cSrcweir 			rStream >> nUS;			aFmt.SetCharTextDistance( nUS );
459*cdf0e10cSrcweir 			rStream >> nShort;		aFmt.SetLSpace( nShort );
460*cdf0e10cSrcweir 			rStream >> bFlag;
461*cdf0e10cSrcweir 		}
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 		sal_uInt16	nFamily;
464*cdf0e10cSrcweir 		sal_uInt16  nCharSet;
465*cdf0e10cSrcweir 		short   nWidth;
466*cdf0e10cSrcweir 		short   nHeight;
467*cdf0e10cSrcweir 		sal_uInt16  nPitch;
468*cdf0e10cSrcweir 		String aName;
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 		rStream.ReadByteString(aName, eEncoding);
471*cdf0e10cSrcweir 		rStream >> nFamily >> nCharSet >> nWidth >> nHeight >> nPitch;
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 		if( aName.Len() )
474*cdf0e10cSrcweir 		{
475*cdf0e10cSrcweir 			Font aFont( nFamily, Size( nWidth, nHeight ) );
476*cdf0e10cSrcweir 			aFont.SetName( aName );
477*cdf0e10cSrcweir 			aFont.SetCharSet( (CharSet)nCharSet );
478*cdf0e10cSrcweir 			aFont.SetPitch( (FontPitch)nPitch );
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 			aFmt.SetBulletFont( &aFont );
481*cdf0e10cSrcweir 		}
482*cdf0e10cSrcweir 		else
483*cdf0e10cSrcweir 			nCharSet = RTL_TEXTENCODING_SYMBOL;
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 		if( VERSION_53A > nVersion )
486*cdf0e10cSrcweir 			aFmt.SetBulletChar( ByteString::ConvertToUnicode(
487*cdf0e10cSrcweir                                             sal_Char(aFmt.GetBulletChar()), nCharSet ));
488*cdf0e10cSrcweir 	}
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 	if( VERSION_30B != nVersion )
491*cdf0e10cSrcweir 	{
492*cdf0e10cSrcweir 		sal_uInt16 nItemCount;
493*cdf0e10cSrcweir 		rStream >> nCharPoolId;
494*cdf0e10cSrcweir 		rStream.ReadByteString(sCharFmtName, eEncoding);
495*cdf0e10cSrcweir 		rStream >> nItemCount;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir 		while( nItemCount-- )
498*cdf0e10cSrcweir 		{
499*cdf0e10cSrcweir 			sal_uInt16 nWhich, nVers;
500*cdf0e10cSrcweir 			rStream >> nWhich >> nVers;
501*cdf0e10cSrcweir 			aItems.Insert( GetDfltAttr( nWhich )->Create( rStream, nVers ),
502*cdf0e10cSrcweir 							aItems.Count() );
503*cdf0e10cSrcweir 		}
504*cdf0e10cSrcweir 	}
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 	if( VERSION_40A == nVersion && SVX_NUM_BITMAP == aFmt.GetNumberingType() )
507*cdf0e10cSrcweir 	{
508*cdf0e10cSrcweir 		sal_uInt8 cF;
509*cdf0e10cSrcweir 		Size aSz;
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir 		rStream >> aSz.Width() >> aSz.Height();
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 		rStream >> cF;
514*cdf0e10cSrcweir 		if( cF )
515*cdf0e10cSrcweir 		{
516*cdf0e10cSrcweir 			SvxBrushItem* pBrush = 0;
517*cdf0e10cSrcweir 			SwFmtVertOrient* pVOrient = 0;
518*cdf0e10cSrcweir 			sal_uInt16 nVer;
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir 			if( cF & 1 )
521*cdf0e10cSrcweir 			{
522*cdf0e10cSrcweir 				rStream >> nVer;
523*cdf0e10cSrcweir 				pBrush = (SvxBrushItem*)GetDfltAttr( RES_BACKGROUND )
524*cdf0e10cSrcweir 										->Create( rStream, nVer );
525*cdf0e10cSrcweir 			}
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir 			if( cF & 2 )
528*cdf0e10cSrcweir 			{
529*cdf0e10cSrcweir 				rStream >> nVer;
530*cdf0e10cSrcweir 				pVOrient = (SwFmtVertOrient*)GetDfltAttr( RES_VERT_ORIENT )
531*cdf0e10cSrcweir 										->Create( rStream, nVer );
532*cdf0e10cSrcweir 			}
533*cdf0e10cSrcweir             sal_Int16 eOrient = text::VertOrientation::NONE;
534*cdf0e10cSrcweir 			if(pVOrient)
535*cdf0e10cSrcweir                 eOrient = (sal_Int16)pVOrient->GetVertOrient();
536*cdf0e10cSrcweir 			aFmt.SetGraphicBrush( pBrush, &aSz, pVOrient ? &eOrient : 0 );
537*cdf0e10cSrcweir 		}
538*cdf0e10cSrcweir 	}
539*cdf0e10cSrcweir }
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir /*------------------------------------------------------------------------
543*cdf0e10cSrcweir  Beschreibung:
544*cdf0e10cSrcweir ------------------------------------------------------------------------*/
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir SwNumRulesWithName::_SwNumFmtGlobal::~_SwNumFmtGlobal()
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir }
549*cdf0e10cSrcweir /*------------------------------------------------------------------------
550*cdf0e10cSrcweir  Beschreibung:
551*cdf0e10cSrcweir ------------------------------------------------------------------------*/
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir void SwNumRulesWithName::_SwNumFmtGlobal::Store( SvStream& rStream )
555*cdf0e10cSrcweir {
556*cdf0e10cSrcweir 	CharSet eEncoding = gsl_getSystemTextEncoding();
557*cdf0e10cSrcweir 	{
558*cdf0e10cSrcweir 		String aName;
559*cdf0e10cSrcweir 		sal_uInt16 nFamily = FAMILY_DONTKNOW, nCharSet = 0, nPitch = 0;
560*cdf0e10cSrcweir 		short  nWidth = 0, nHeight = 0;
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir 		const Font* pFnt = aFmt.GetBulletFont();
563*cdf0e10cSrcweir 		if( pFnt )
564*cdf0e10cSrcweir 		{
565*cdf0e10cSrcweir 			aName = pFnt->GetName();
566*cdf0e10cSrcweir 			nFamily = (sal_uInt16)pFnt->GetFamily();
567*cdf0e10cSrcweir 			nCharSet = (sal_uInt16)pFnt->GetCharSet();
568*cdf0e10cSrcweir 			nWidth = (short)pFnt->GetSize().Width();
569*cdf0e10cSrcweir 			nHeight = (short)pFnt->GetSize().Height();
570*cdf0e10cSrcweir 			nPitch = (sal_uInt16)pFnt->GetPitch();
571*cdf0e10cSrcweir 		}
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir 		rStream << sal_uInt16(aFmt.GetNumberingType())
574*cdf0e10cSrcweir 				<< aFmt.GetBulletChar()
575*cdf0e10cSrcweir 				<< (aFmt.GetIncludeUpperLevels() > 0)
576*cdf0e10cSrcweir 				<< aFmt.GetStart();
577*cdf0e10cSrcweir 		rStream.WriteByteString( aFmt.GetPrefix(), eEncoding );
578*cdf0e10cSrcweir 		rStream.WriteByteString( aFmt.GetSuffix(), eEncoding );
579*cdf0e10cSrcweir 		rStream << sal_uInt16( aFmt.GetNumAdjust() )
580*cdf0e10cSrcweir 				<< aFmt.GetAbsLSpace()
581*cdf0e10cSrcweir 				<< aFmt.GetFirstLineOffset()
582*cdf0e10cSrcweir 				<< aFmt.GetCharTextDistance()
583*cdf0e10cSrcweir 				<< aFmt.GetLSpace()
584*cdf0e10cSrcweir 				<< sal_False;//aFmt.IsRelLSpace();
585*cdf0e10cSrcweir 		rStream.WriteByteString( aName, eEncoding );
586*cdf0e10cSrcweir 		rStream << nFamily
587*cdf0e10cSrcweir 				<< nCharSet
588*cdf0e10cSrcweir 				<< nWidth
589*cdf0e10cSrcweir 				<< nHeight
590*cdf0e10cSrcweir 				<< nPitch;
591*cdf0e10cSrcweir 	}
592*cdf0e10cSrcweir 	rStream << nCharPoolId;
593*cdf0e10cSrcweir 	rStream.WriteByteString( sCharFmtName, eEncoding );
594*cdf0e10cSrcweir 	rStream << aItems.Count();
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir 	for( sal_uInt16 n = aItems.Count(); n; )
597*cdf0e10cSrcweir 	{
598*cdf0e10cSrcweir 		SfxPoolItem* pItem = aItems[ --n ];
599*cdf0e10cSrcweir 		sal_uInt16 nIVers = pItem->GetVersion( SOFFICE_FILEFORMAT_50 );
600*cdf0e10cSrcweir 		ASSERT( nIVers != USHRT_MAX,
601*cdf0e10cSrcweir 				"Was'n das: Item-Version USHRT_MAX in der aktuellen Version" );
602*cdf0e10cSrcweir 		rStream << pItem->Which()
603*cdf0e10cSrcweir 				<< nIVers;
604*cdf0e10cSrcweir 		pItem->Store( rStream, nIVers );
605*cdf0e10cSrcweir 	}
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 	// Erweiterungen fuer Version 40A
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir 	if( SVX_NUM_BITMAP == aFmt.GetNumberingType() )
610*cdf0e10cSrcweir 	{
611*cdf0e10cSrcweir 		rStream << (sal_Int32)aFmt.GetGraphicSize().Width()
612*cdf0e10cSrcweir 				<< (sal_Int32)aFmt.GetGraphicSize().Height();
613*cdf0e10cSrcweir 		sal_uInt8 cFlg = ( 0 != aFmt.GetBrush() ? 1 : 0 ) +
614*cdf0e10cSrcweir 					( 0 != aFmt.GetGraphicOrientation() ? 2 : 0 );
615*cdf0e10cSrcweir 		rStream << cFlg;
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir 		if( aFmt.GetBrush() )
618*cdf0e10cSrcweir 		{
619*cdf0e10cSrcweir 			sal_uInt16 nVersion = aFmt.GetBrush()->GetVersion( SOFFICE_FILEFORMAT_50 );
620*cdf0e10cSrcweir 			rStream << nVersion;
621*cdf0e10cSrcweir 			aFmt.GetBrush()->Store( rStream, nVersion );
622*cdf0e10cSrcweir 		}
623*cdf0e10cSrcweir 		if( aFmt.GetGraphicOrientation() )
624*cdf0e10cSrcweir 		{
625*cdf0e10cSrcweir 			sal_uInt16 nVersion = aFmt.GetGraphicOrientation()->GetVersion( SOFFICE_FILEFORMAT_50 );
626*cdf0e10cSrcweir 			rStream << nVersion;
627*cdf0e10cSrcweir 			aFmt.GetGraphicOrientation()->Store( rStream, nVersion );
628*cdf0e10cSrcweir 		}
629*cdf0e10cSrcweir 	}
630*cdf0e10cSrcweir }
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir /*------------------------------------------------------------------------
633*cdf0e10cSrcweir  Beschreibung:
634*cdf0e10cSrcweir ------------------------------------------------------------------------*/
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir void SwNumRulesWithName::_SwNumFmtGlobal::ChgNumFmt( SwWrtShell& rSh,
637*cdf0e10cSrcweir 							SwNumFmt& rNew ) const
638*cdf0e10cSrcweir {
639*cdf0e10cSrcweir 	SwCharFmt* pFmt = 0;
640*cdf0e10cSrcweir 	if( sCharFmtName.Len() )
641*cdf0e10cSrcweir 	{
642*cdf0e10cSrcweir 		// suche erstmal ueber den Namen
643*cdf0e10cSrcweir 		sal_uInt16 nArrLen = rSh.GetCharFmtCount();
644*cdf0e10cSrcweir 		for( sal_uInt16 i = 1; i < nArrLen; ++i )
645*cdf0e10cSrcweir 		{
646*cdf0e10cSrcweir 			pFmt = &rSh.GetCharFmt( i );
647*cdf0e10cSrcweir 			if( COMPARE_EQUAL == pFmt->GetName().CompareTo( sCharFmtName ))
648*cdf0e10cSrcweir 				// ist vorhanden, also belasse die Attribute wie sie sind!
649*cdf0e10cSrcweir 				break;
650*cdf0e10cSrcweir 			pFmt = 0;
651*cdf0e10cSrcweir 		}
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 		if( !pFmt )
654*cdf0e10cSrcweir 		{
655*cdf0e10cSrcweir 			if( IsPoolUserFmt( nCharPoolId ) )
656*cdf0e10cSrcweir 			{
657*cdf0e10cSrcweir 				pFmt = rSh.MakeCharFmt( sCharFmtName );
658*cdf0e10cSrcweir 				pFmt->SetAuto( sal_False );
659*cdf0e10cSrcweir 			}
660*cdf0e10cSrcweir 			else
661*cdf0e10cSrcweir 				pFmt = rSh.GetCharFmtFromPool( nCharPoolId );
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir 			if( !pFmt->GetDepends() )		// Attribute setzen
664*cdf0e10cSrcweir 				for( sal_uInt16 n = aItems.Count(); n; )
665*cdf0e10cSrcweir                     pFmt->SetFmtAttr( *aItems[ --n ] );
666*cdf0e10cSrcweir 		}
667*cdf0e10cSrcweir 	}
668*cdf0e10cSrcweir 	((SwNumFmt&)aFmt).SetCharFmt( pFmt );
669*cdf0e10cSrcweir 	rNew = aFmt;
670*cdf0e10cSrcweir 	if( pFmt )
671*cdf0e10cSrcweir 		((SwNumFmt&)aFmt).SetCharFmt( 0 );
672*cdf0e10cSrcweir }
673*cdf0e10cSrcweir 
674