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