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