bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / docstyle.hxx
blob6057a10fe06cc6ca2f92e3dcd0aae22805a144a9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _DOCSTYLE_HXX
20 #define _DOCSTYLE_HXX
22 #include <rtl/ref.hxx>
24 #include <svl/style.hxx>
25 #include <svl/itemset.hxx>
26 #include "swdllapi.h"
27 #include <boost/ptr_container/ptr_vector.hpp>
29 class SwDoc;
30 class SwDocStyleSheetPool;
31 class SwPageDesc;
32 class SwCharFmt;
33 class SwTxtFmtColl;
34 class SwFrmFmt;
35 class SwNumRule;
37 /*--------------------------------------------------------------------
38 Local helper class.
39 --------------------------------------------------------------------*/
40 class SwPoolFmtList : public std::vector<String>
42 public:
43 SwPoolFmtList() {}
44 void Append( char cChar, const String& rStr );
45 void Erase();
48 /*--------------------------------------------------------------------
49 Temporary StyleSheet.
50 --------------------------------------------------------------------*/
51 class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase
53 friend class SwDocStyleSheetPool;
54 friend class SwStyleSheetIterator;
56 SwCharFmt* pCharFmt;
57 SwTxtFmtColl* pColl;
58 SwFrmFmt* pFrmFmt;
59 const SwPageDesc* pDesc;
60 const SwNumRule* pNumRule;
62 SwDoc& rDoc;
63 SfxItemSet aCoreSet;
65 sal_Bool bPhysical;
68 /// Make empty shell a real StyleSheet (Core).
69 SW_DLLPRIVATE void Create();
71 /// Fill StyleSheet with data.
72 enum FillStyleType {
73 FillOnlyName,
74 FillAllInfo,
75 FillPhysical
78 SW_DLLPRIVATE sal_Bool FillStyleSheet( FillStyleType eFType );
80 protected:
81 virtual ~SwDocStyleSheet();
83 public:
84 SwDocStyleSheet( SwDoc& rDoc,
85 const String& rName,
86 SwDocStyleSheetPool* pPool,
87 SfxStyleFamily eFam,
88 sal_uInt16 nMask);
90 SwDocStyleSheet( const SwDocStyleSheet& );
92 void Reset();
94 void SetMask(sal_uInt16 nMsk) { nMask = nMsk; }
95 void SetFamily(SfxStyleFamily eFam) { nFamily = eFam; }
97 sal_Bool IsPhysical() const { return bPhysical; }
98 void SetPhysical(sal_Bool bPhys);
100 virtual void SetHidden( sal_Bool bHidden );
101 virtual sal_Bool IsHidden( ) const;
103 /** add optional parameter <bResetIndentAttrsAtParagraphStyle>, default value sal_False,
104 which indicates that the indent attributes at a paragraph style should
105 be reset in case that a list style is applied to the paragraph style and
106 no indent attributes are applied. */
107 void SetItemSet( const SfxItemSet& rSet,
108 const bool bResetIndentAttrsAtParagraphStyle = false );
110 virtual SfxItemSet& GetItemSet();
111 /** new method for paragraph styles to merge indent attributes of applied list
112 style into the given item set, if the list style indent attributes are applicable. */
113 void MergeIndentAttrsOfListStyle( SfxItemSet& rSet );
114 virtual const String& GetParent() const;
115 virtual const String& GetFollow() const;
117 virtual sal_uLong GetHelpId( OUString& rFile );
118 virtual void SetHelpId( const OUString& r, sal_uLong nId );
120 /** Preset the members without physical access.
121 Used by StyleSheetPool. */
122 void PresetName(const String& rName) { aName = rName; }
123 void PresetNameAndFamily(const String& rName);
124 void PresetParent(const String& rName){ aParent = rName; }
125 void PresetFollow(const String& rName){ aFollow = rName; }
127 virtual bool SetName( const String& rStr);
128 virtual bool SetParent( const String& rStr);
129 virtual bool SetFollow( const String& rStr);
131 virtual bool HasFollowSupport() const;
132 virtual bool HasParentSupport() const;
133 virtual bool HasClearParentSupport() const;
134 virtual String GetDescription();
135 virtual String GetDescription(SfxMapUnit eUnit);
137 SwCharFmt* GetCharFmt();
138 SwTxtFmtColl* GetCollection();
139 SwFrmFmt* GetFrmFmt();
140 const SwPageDesc* GetPageDesc();
141 const SwNumRule* GetNumRule();
142 void SetNumRule(const SwNumRule& rRule);
144 virtual bool IsUsed() const;
147 /*--------------------------------------------------------------------
148 Iterator for Pool.
149 --------------------------------------------------------------------*/
151 class SwStyleSheetIterator : public SfxStyleSheetIterator, public SfxListener
153 rtl::Reference< SwDocStyleSheet > mxIterSheet;
154 rtl::Reference< SwDocStyleSheet > mxStyleSheet;
155 SwPoolFmtList aLst;
156 sal_uInt16 nLastPos;
157 sal_Bool bFirstCalled;
159 void AppendStyleList(const boost::ptr_vector<String>& rLst,
160 sal_Bool bUsed,
161 sal_Bool bTestHidden,
162 bool bOnlyHidden,
163 sal_uInt16 nSection,
164 char cType);
166 public:
167 SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
168 SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL );
169 virtual ~SwStyleSheetIterator();
171 virtual sal_uInt16 Count();
172 virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx);
173 virtual SfxStyleSheetBase* First();
174 virtual SfxStyleSheetBase* Next();
175 virtual SfxStyleSheetBase* Find(const OUString& rStr);
177 virtual void Notify( SfxBroadcaster&, const SfxHint& );
179 void InvalidateIterator();
183 class SwDocStyleSheetPool : public SfxStyleSheetBasePool
185 rtl::Reference< SwDocStyleSheet > mxStyleSheet;
186 SwDoc& rDoc;
187 sal_Bool bOrganizer : 1; ///< Organizer
190 virtual SfxStyleSheetBase* Create( const String&, SfxStyleFamily, sal_uInt16 nMask);
191 virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& );
193 using SfxStyleSheetBasePool::Find;
195 public:
196 SwDocStyleSheetPool( SwDoc&, sal_Bool bOrganizer = sal_False );
198 virtual void Replace( SfxStyleSheetBase& rSource,
199 SfxStyleSheetBase& rTarget );
200 virtual SfxStyleSheetBase& Make(const String&, SfxStyleFamily, sal_uInt16 nMask, sal_uInt16 nPos = 0xffff);
202 virtual SfxStyleSheetBase* Find( const String&, SfxStyleFamily eFam,
203 sal_uInt16 n=SFXSTYLEBIT_ALL );
205 virtual bool SetParent( SfxStyleFamily eFam, const String &rStyle,
206 const String &rParent );
208 virtual void Remove( SfxStyleSheetBase* pStyle);
210 void SetOrganizerMode( sal_Bool bMode ) { bOrganizer = bMode; }
211 sal_Bool IsOrganizerMode() const { return bOrganizer; }
213 virtual SfxStyleSheetIteratorPtr CreateIterator( SfxStyleFamily, sal_uInt16 nMask );
215 SwDoc& GetDoc() const { return rDoc; }
217 void dispose();
219 virtual void SAL_CALL acquire( ) throw ();
220 virtual void SAL_CALL release( ) throw ();
222 void InvalidateIterator();
224 protected:
225 virtual ~SwDocStyleSheetPool();
227 /// For not-so-clever compilers.
228 private:
229 SwDocStyleSheetPool( const SwDocStyleSheetPool& );
233 #endif
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */