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