1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <rtl/ref.hxx>
24 #include <svl/style.hxx>
25 #include <svl/itemset.hxx>
27 #include <boost/ptr_container/ptr_vector.hpp>
30 class SwDocStyleSheetPool
;
37 /*--------------------------------------------------------------------
39 --------------------------------------------------------------------*/
40 class SwPoolFmtList
: public std::vector
<String
>
44 void Append( char cChar
, const String
& rStr
);
48 /*--------------------------------------------------------------------
50 --------------------------------------------------------------------*/
51 class SW_DLLPUBLIC SwDocStyleSheet
: public SfxStyleSheetBase
53 friend class SwDocStyleSheetPool
;
54 friend class SwStyleSheetIterator
;
59 const SwPageDesc
* pDesc
;
60 const SwNumRule
* pNumRule
;
68 /// Make empty shell a real StyleSheet (Core).
69 SW_DLLPRIVATE
void Create();
71 /// Fill StyleSheet with data.
78 SW_DLLPRIVATE sal_Bool
FillStyleSheet( FillStyleType eFType
);
81 virtual ~SwDocStyleSheet();
84 SwDocStyleSheet( SwDoc
& rDoc
,
86 SwDocStyleSheetPool
* pPool
,
90 SwDocStyleSheet( const SwDocStyleSheet
& );
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 /*--------------------------------------------------------------------
149 --------------------------------------------------------------------*/
151 class SwStyleSheetIterator
: public SfxStyleSheetIterator
, public SfxListener
153 rtl::Reference
< SwDocStyleSheet
> mxIterSheet
;
154 rtl::Reference
< SwDocStyleSheet
> mxStyleSheet
;
157 sal_Bool bFirstCalled
;
159 void AppendStyleList(const boost::ptr_vector
<String
>& rLst
,
161 sal_Bool bTestHidden
,
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
;
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
;
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
; }
219 virtual void SAL_CALL
acquire( ) throw ();
220 virtual void SAL_CALL
release( ) throw ();
222 void InvalidateIterator();
225 virtual ~SwDocStyleSheetPool();
227 /// For not-so-clever compilers.
229 SwDocStyleSheetPool( const SwDocStyleSheetPool
& );
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */