xref: /AOO41X/main/sw/inc/docstyle.hxx (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 #ifndef _DOCSTYLE_HXX
28*cdf0e10cSrcweir #define _DOCSTYLE_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <rtl/ref.hxx>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifndef _SVSTDARR_HXX
33*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
34*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #include <svl/style.hxx>
37*cdf0e10cSrcweir #include <svl/itemset.hxx>
38*cdf0e10cSrcweir #include "swdllapi.h"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir class SwDoc;
41*cdf0e10cSrcweir class SwDocStyleSheetPool;
42*cdf0e10cSrcweir class SwPageDesc;
43*cdf0e10cSrcweir class SwCharFmt;
44*cdf0e10cSrcweir class SwTxtFmtColl;
45*cdf0e10cSrcweir class SwFrmFmt;
46*cdf0e10cSrcweir class SwNumRule;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir /*--------------------------------------------------------------------
49*cdf0e10cSrcweir 	Beschreibung:	Lokale Hilfsklasse
50*cdf0e10cSrcweir  --------------------------------------------------------------------*/
51*cdf0e10cSrcweir class SwPoolFmtList : public SvStringsDtor
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir public:
54*cdf0e10cSrcweir 	SwPoolFmtList() {}
55*cdf0e10cSrcweir 	void Append( char cChar, const String& rStr );
56*cdf0e10cSrcweir 	void Erase();
57*cdf0e10cSrcweir };
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir /*--------------------------------------------------------------------
61*cdf0e10cSrcweir 	Beschreibung:	temp. StyleSheet
62*cdf0e10cSrcweir  --------------------------------------------------------------------*/
63*cdf0e10cSrcweir class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir 	friend class SwDocStyleSheetPool;
66*cdf0e10cSrcweir 	friend class SwStyleSheetIterator;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 	SwCharFmt*			pCharFmt;
69*cdf0e10cSrcweir 	SwTxtFmtColl* 		pColl;
70*cdf0e10cSrcweir 	SwFrmFmt* 			pFrmFmt;
71*cdf0e10cSrcweir 	const SwPageDesc* 	pDesc;
72*cdf0e10cSrcweir 	const SwNumRule*	pNumRule;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 	SwDoc&				rDoc;
75*cdf0e10cSrcweir 	SfxItemSet			aCoreSet;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	sal_Bool 				bPhysical;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	// leere Huelse zum richtigen StyleSheet (Core) machen
81*cdf0e10cSrcweir 	SW_DLLPRIVATE void				Create();
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	// den StyleSheet mit Daten fuellen
84*cdf0e10cSrcweir 	enum FillStyleType {
85*cdf0e10cSrcweir 		FillOnlyName,
86*cdf0e10cSrcweir 		FillAllInfo,
87*cdf0e10cSrcweir 		FillPhysical
88*cdf0e10cSrcweir 	};
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	SW_DLLPRIVATE sal_Bool FillStyleSheet( FillStyleType eFType );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir protected:
93*cdf0e10cSrcweir 	virtual ~SwDocStyleSheet();
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir public:
96*cdf0e10cSrcweir 	SwDocStyleSheet( SwDoc& 				rDoc,
97*cdf0e10cSrcweir 					 const String& 			rName,
98*cdf0e10cSrcweir 					 SwDocStyleSheetPool& 	rPool,
99*cdf0e10cSrcweir 					 SfxStyleFamily 		eFam,
100*cdf0e10cSrcweir 					 sal_uInt16 				nMask);
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	SwDocStyleSheet( const SwDocStyleSheet& );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	void					Reset();
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	void 					SetMask(sal_uInt16 nMsk)			{ nMask = nMsk;   	}
107*cdf0e10cSrcweir 	void 					SetFamily(SfxStyleFamily eFam)	{ nFamily = eFam;	}
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	sal_Bool		   			IsPhysical() const				{ return bPhysical; }
110*cdf0e10cSrcweir 	void					SetPhysical(sal_Bool bPhys);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     // --> OD 2008-02-11 #newlistlevelattrs#
113*cdf0e10cSrcweir     // add optional parameter <bResetIndentAttrsAtParagraphStyle>, default value sal_False,
114*cdf0e10cSrcweir     // which indicates that the indent attributes at a paragraph style should
115*cdf0e10cSrcweir     // be reset in case that a list style is applied to the paragraph style and
116*cdf0e10cSrcweir     // no indent attributes are applied.
117*cdf0e10cSrcweir     void                    SetItemSet( const SfxItemSet& rSet,
118*cdf0e10cSrcweir                                         const bool bResetIndentAttrsAtParagraphStyle = false );
119*cdf0e10cSrcweir     // <--
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	virtual SfxItemSet& 	GetItemSet();
122*cdf0e10cSrcweir     // --> OD 2008-02-12 #newlistlevelattrs#
123*cdf0e10cSrcweir     // new method for paragraph styles to merge indent attributes of applied list
124*cdf0e10cSrcweir     // style into the given item set, if the list style indent attributes are applicable.
125*cdf0e10cSrcweir     void MergeIndentAttrsOfListStyle( SfxItemSet& rSet );
126*cdf0e10cSrcweir     // <--
127*cdf0e10cSrcweir 	virtual const String& 	GetParent() const;
128*cdf0e10cSrcweir 	virtual const String& 	GetFollow() const;
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	virtual sal_uLong GetHelpId( String& rFile );
131*cdf0e10cSrcweir 	virtual void SetHelpId( const String& r, sal_uLong nId );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	// Vorbelegen der member ohne physikalischen Zugriff
134*cdf0e10cSrcweir 	// wird vom StyleSheetPool benutzt
135*cdf0e10cSrcweir 	//
136*cdf0e10cSrcweir 	void			  		PresetName(const String& rName)  { aName   = rName; }
137*cdf0e10cSrcweir 	void			  		PresetNameAndFamily(const String& rName);
138*cdf0e10cSrcweir 	void					PresetParent(const String& rName){ aParent = rName; }
139*cdf0e10cSrcweir 	void					PresetFollow(const String& rName){ aFollow = rName; }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	virtual sal_Bool 			SetName( const String& rStr);
142*cdf0e10cSrcweir 	virtual sal_Bool 			SetParent( const String& rStr);
143*cdf0e10cSrcweir 	virtual sal_Bool 			SetFollow( const String& rStr);
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 	virtual sal_Bool 			HasFollowSupport() const;
146*cdf0e10cSrcweir 	virtual sal_Bool 			HasParentSupport() const;
147*cdf0e10cSrcweir 	virtual sal_Bool 			HasClearParentSupport() const;
148*cdf0e10cSrcweir 	virtual String 			GetDescription();
149*cdf0e10cSrcweir 	virtual String 			GetDescription(SfxMapUnit eUnit);
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	SwCharFmt*		   		GetCharFmt();
152*cdf0e10cSrcweir 	SwTxtFmtColl* 			GetCollection();
153*cdf0e10cSrcweir 	SwFrmFmt* 				GetFrmFmt();
154*cdf0e10cSrcweir 	const SwPageDesc* 		GetPageDesc();
155*cdf0e10cSrcweir 	const SwNumRule*		GetNumRule();
156*cdf0e10cSrcweir 	void					SetNumRule(const SwNumRule& rRule);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	virtual sal_Bool 			IsUsed() const;
159*cdf0e10cSrcweir };
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir /*--------------------------------------------------------------------
162*cdf0e10cSrcweir 	Beschreibung:	Iterator fuer den Pool
163*cdf0e10cSrcweir  --------------------------------------------------------------------*/
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir class SwStyleSheetIterator : public SfxStyleSheetIterator, public SfxListener
166*cdf0e10cSrcweir {
167*cdf0e10cSrcweir 	rtl::Reference< SwDocStyleSheet > mxIterSheet;
168*cdf0e10cSrcweir 	rtl::Reference< SwDocStyleSheet > mxStyleSheet;
169*cdf0e10cSrcweir 	SwPoolFmtList 		aLst;
170*cdf0e10cSrcweir 	sal_uInt16 				nLastPos;
171*cdf0e10cSrcweir 	sal_Bool 				bFirstCalled;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	void				AppendStyleList(const SvStringsDtor& rLst,
174*cdf0e10cSrcweir 										sal_Bool 	bUsed,
175*cdf0e10cSrcweir 										sal_uInt16 	nSection,
176*cdf0e10cSrcweir 										char	cType);
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir public:
179*cdf0e10cSrcweir 	SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
180*cdf0e10cSrcweir 						  SfxStyleFamily eFam, sal_uInt16 n=0xFFFF );
181*cdf0e10cSrcweir 	virtual ~SwStyleSheetIterator();
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	virtual sal_uInt16 Count();
184*cdf0e10cSrcweir 	virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx);
185*cdf0e10cSrcweir 	virtual SfxStyleSheetBase* First();
186*cdf0e10cSrcweir 	virtual SfxStyleSheetBase* Next();
187*cdf0e10cSrcweir 	virtual SfxStyleSheetBase* Find(const UniString& rStr);
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	virtual void Notify( SfxBroadcaster&, const SfxHint& );
190*cdf0e10cSrcweir };
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir /*--------------------------------------------------------------------
193*cdf0e10cSrcweir 	Beschreibung:	Pool fuer
194*cdf0e10cSrcweir  --------------------------------------------------------------------*/
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir class SwDocStyleSheetPool : public SfxStyleSheetBasePool
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir 	rtl::Reference< SwDocStyleSheet > mxStyleSheet;
199*cdf0e10cSrcweir 	SwDoc&				rDoc;
200*cdf0e10cSrcweir 	sal_Bool				bOrganizer : 1;		// sal_True: fuer den Organizer
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	virtual SfxStyleSheetBase* Create( const String&, SfxStyleFamily, sal_uInt16 nMask);
204*cdf0e10cSrcweir 	virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& );
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     using SfxStyleSheetBasePool::Find;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir public:
209*cdf0e10cSrcweir 	SwDocStyleSheetPool( SwDoc&, sal_Bool bOrganizer = sal_False );
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 	virtual void Replace( SfxStyleSheetBase& rSource,
212*cdf0e10cSrcweir 						  SfxStyleSheetBase& rTarget );
213*cdf0e10cSrcweir 	virtual SfxStyleSheetBase& Make(const String&, SfxStyleFamily, sal_uInt16 nMask, sal_uInt16 nPos = 0xffff);
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 	virtual SfxStyleSheetBase* Find( const String&, SfxStyleFamily eFam,
216*cdf0e10cSrcweir 									sal_uInt16 n=0xFFFF );
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	virtual sal_Bool SetParent( SfxStyleFamily eFam, const String &rStyle,
219*cdf0e10cSrcweir 							const String &rParent );
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	virtual void Remove( SfxStyleSheetBase* pStyle);
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	void	SetOrganizerMode( sal_Bool bMode )	{ bOrganizer = bMode; }
224*cdf0e10cSrcweir 	sal_Bool 	IsOrganizerMode() const 		{ return bOrganizer; }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 	virtual SfxStyleSheetIterator* CreateIterator( SfxStyleFamily,
227*cdf0e10cSrcweir 													sal_uInt16 nMask );
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 	SwDoc& GetDoc() const { return rDoc; }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	void dispose();
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     virtual void SAL_CALL acquire(  ) throw ();
234*cdf0e10cSrcweir     virtual void SAL_CALL release(  ) throw ();
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir protected:
237*cdf0e10cSrcweir 	virtual ~SwDocStyleSheetPool();
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 	//Fuer die daemlicheren Compiler
240*cdf0e10cSrcweir private:
241*cdf0e10cSrcweir 	SwDocStyleSheetPool( const SwDocStyleSheetPool& );
242*cdf0e10cSrcweir };
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir #endif
246