1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: style.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #ifndef INCLUDED_SVTDLLAPI_H
35 #include "bf_svtools/svtdllapi.h"
39 #include <rsc/rscsfx.hxx>
42 #ifndef _STRING_HXX //autogen
43 #include <tools/string.hxx>
45 #ifndef _LIST_HXX //autogen
46 #include <tools/list.hxx>
48 #ifndef _SFXHINT_HXX //autogen
49 #include <bf_svtools/hint.hxx>
51 #ifndef _SFXLSTNER_HXX //autogen
52 #include <bf_svtools/lstner.hxx>
54 #ifndef _SFXBRDCST_HXX //autogen
55 #include <bf_svtools/brdcst.hxx>
58 #ifndef _SFXPOOLITEM_HXX //autogen
59 #include <bf_svtools/poolitem.hxx>
62 #ifndef _SFX_STYLE_HRC
63 #include <bf_svtools/style.hrc>
74 class SfxStyleSheetBasePool
;
77 /*=========================================================================
79 Jeder, der an Intanzen der Klassen SfxStyleSheetBasePool oder am
80 SfxStyleSheetBase strukturelle �nderungen vornimmt, mu� diese �ber
81 <SfxStyleSheetBasePool::GetBroadcaster()> broadcasten. Daf�r Gibt es die
82 Klasse <SfxStyleSheetHint>, die eine Action-Id und einen Pointer auf einen
83 <SfxStyleSheetBase> erh�lt. Die Actions sind:
85 #define SFX_STYLESHEET_CREATED // neu
86 #define SFX_STYLESHEET_MODIFIED // ver"andert
87 #define SFX_STYLESHEET_CHANGED // ausgetauscht
88 #define SFX_STYLESHEET_ERASED // gel"oscht
90 Es machen bereits die folgenden Methoden von sich aus:
92 SfxStyleSheetHint(SFX_STYLESHEET_MODIFIED) aus:
93 SfxStyleSheetBase::SetName( const String& rName )
94 SfxStyleSheetBase::SetParent( const String& rName )
95 SfxStyleSheetBase::SetFollow( const String& rName )
97 SfxSimpleHint(SFX_HINT_DYING) aus:
98 SfxStyleSheetBasePool::~SfxStyleSheetBasePool()
100 SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *p ) aus:
101 SfxStyleSheetBasePool::Make( const String& rName,
102 SfxStyleFamily eFam, USHORT mask, USHORT nPos)
104 SfxStyleSheetHint( SFX_STYLESHEET_CHANGED, *pNew ) aus:
105 SfxStyleSheetBasePool::Add( SfxStyleSheetBase& rSheet )
107 SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) aus:
108 SfxStyleSheetBasePool::Erase( SfxStyleSheetBase* p )
109 SfxStyleSheetBasePool::Clear()
111 =========================================================================*/
113 #define VIRTUAL510 virtual
115 class SfxStyleSheetBase
117 friend class SfxStyleSheetBasePool
;
120 SfxStyleSheetBasePool
& rPool
; // zugehoeriger Pool
121 SfxStyleFamily nFamily
; // Familie
123 UniString aName
, aParent
, aFollow
;
124 String aHelpFile
; // Name der Hilfedatei
125 SfxItemSet
* pSet
; // ItemSet
126 USHORT nMask
; // Flags
128 ULONG nHelpId
; // Hilfe-ID
130 BOOL bMySet
; // TRUE: Set loeschen im dtor
132 SfxStyleSheetBase( const UniString
&, SfxStyleSheetBasePool
&,
133 SfxStyleFamily eFam
, USHORT mask
);
134 SfxStyleSheetBase( const SfxStyleSheetBase
& );
135 virtual ~SfxStyleSheetBase();
136 virtual void Load( SvStream
&, USHORT
);
137 virtual void Store( SvStream
& );
141 virtual const UniString
& GetName() const;
142 virtual BOOL
SetName( const UniString
& );
143 virtual const UniString
& GetParent() const;
144 virtual BOOL
SetParent( const UniString
& );
145 virtual const UniString
& GetFollow() const;
146 virtual BOOL
SetFollow( const UniString
& );
147 virtual BOOL
HasFollowSupport() const; // Default TRUE
148 virtual BOOL
HasParentSupport() const; // Default TRUE
149 virtual BOOL
HasClearParentSupport() const; // Default FALSE
150 virtual BOOL
IsUsed() const; // Default TRUE
151 // Default aus dem Itemset; entweder dem uebergebenen
152 // oder aus dem per GetItemSet() zurueckgelieferten Set
153 virtual UniString
GetDescription();
154 virtual UniString
GetDescription( SfxMapUnit eMetric
);
156 SfxStyleSheetBasePool
& GetPool() { return rPool
; }
157 SfxStyleFamily
GetFamily() const { return nFamily
; }
158 USHORT
GetMask() const { return nMask
; }
159 void SetMask( USHORT mask
) { nMask
= mask
; }
160 BOOL
IsUserDefined() const
161 { return BOOL( ( nMask
& SFXSTYLEBIT_USERDEF
) != 0 ); }
163 virtual ULONG
GetHelpId( String
& rFile
);
164 virtual void SetHelpId( const String
& r
, ULONG nId
);
166 virtual SfxItemSet
& GetItemSet();
167 virtual USHORT
GetVersion() const;
170 //=========================================================================
172 DECLARE_LIST( SfxStyles
, SfxStyleSheetBase
* )
174 //=========================================================================
176 class SfxStyleSheetIterator
180 Klasse zum Iterieren und Suchen auf einem SfxStyleSheetBasePool.
186 SfxStyleSheetIterator(SfxStyleSheetBasePool
*pBase
,
187 SfxStyleFamily eFam
, USHORT n
=0xFFFF );
188 virtual USHORT
GetSearchMask() const;
189 virtual SfxStyleFamily
GetSearchFamily() const;
190 virtual USHORT
Count();
191 virtual SfxStyleSheetBase
*operator[](USHORT nIdx
);
192 virtual SfxStyleSheetBase
* First();
193 virtual SfxStyleSheetBase
* Next();
194 virtual SfxStyleSheetBase
* Find(const UniString
& rStr
);
195 virtual ~SfxStyleSheetIterator();
199 SfxStyleSheetBasePool
* pBasePool
;
200 SfxStyleFamily nSearchFamily
;
202 BOOL
SearchUsed() const { return bSearchUsed
; }
205 USHORT
GetPos(){return nAktPosition
;}
206 BOOL
IsTrivialSearch();
207 BOOL
DoesStyleMatch(SfxStyleSheetBase
*pStyle
);
210 SfxStyleSheetBase
* pAktStyle
;
214 friend class SfxStyleSheetBasePool
;
217 //=========================================================================
219 class SfxStyleSheetBasePool_Impl
;
221 class SfxStyleSheetBasePool
: public SfxBroadcaster
223 friend class SfxStyleSheetIterator
;
224 friend class SfxStyleSheetBase
;
226 SfxStyleSheetBasePool_Impl
*pImp
;
229 BOOL
Load1_Impl( SvStream
& );
230 SfxStyleSheetIterator
& GetIterator_Impl();
235 SfxStyleFamily nSearchFamily
;
238 SfxStyleSheetBase
& Add( SfxStyleSheetBase
& );
239 void ChangeParent( const UniString
&, const UniString
&, BOOL bVirtual
= TRUE
);
240 virtual SfxStyleSheetBase
* Create( const UniString
&, SfxStyleFamily
, USHORT
);
241 virtual SfxStyleSheetBase
* Create( const SfxStyleSheetBase
& );
244 SfxStyleSheetBasePool( SfxItemPool
& );
245 SfxStyleSheetBasePool( const SfxStyleSheetBasePool
& );
246 ~SfxStyleSheetBasePool();
248 static String
GetStreamName();
250 const String
& GetAppName() const { return aAppName
; }
252 SfxItemPool
& GetPool();
253 const SfxItemPool
& GetPool() const;
255 virtual SfxStyleSheetIterator
* CreateIterator(SfxStyleFamily
, USHORT nMask
);
256 virtual USHORT
Count();
257 virtual SfxStyleSheetBase
* operator[](USHORT nIdx
);
259 virtual SfxStyleSheetBase
& Make(const UniString
&,
261 USHORT nMask
= 0xffff ,
262 USHORT nPos
= 0xffff);
264 VIRTUAL510
void Replace(
265 SfxStyleSheetBase
& rSource
, SfxStyleSheetBase
& rTarget
);
266 virtual SfxStyleSheetBase
* Remove( SfxStyleSheetBase
* );
267 virtual void Insert( SfxStyleSheetBase
* );
269 virtual void Erase( SfxStyleSheetBase
* );
270 virtual void Clear();
272 SfxStyleSheetBasePool
& operator=( const SfxStyleSheetBasePool
& );
273 SfxStyleSheetBasePool
& operator+=( const SfxStyleSheetBasePool
& );
275 SfxStyles
& GetStyles() { return aStyles
; }
276 virtual SfxStyleSheetBase
* First();
277 virtual SfxStyleSheetBase
* Next();
278 virtual SfxStyleSheetBase
* Find( const UniString
&,
279 SfxStyleFamily eFam
, USHORT n
=0xFFFF );
280 virtual BOOL
SetParent(SfxStyleFamily eFam
,
281 const UniString
&rStyle
,
282 const UniString
&rParent
);
284 SfxStyleSheetBase
* Find(const UniString
& rStr
)
285 { return Find(rStr
, nSearchFamily
, nMask
); }
287 void SetSearchMask(SfxStyleFamily eFam
, USHORT n
=0xFFFF );
288 USHORT
GetSearchMask() const;
289 SfxStyleFamily
GetSearchFamily() const { return nSearchFamily
; }
291 BOOL
Load( SvStream
& );
292 BOOL
Store( SvStream
&, BOOL bUsed
= TRUE
);
295 //=========================================================================
297 class SfxStyleSheet
: public SfxStyleSheetBase
,
298 public SfxListener
, public SfxBroadcaster
303 SfxStyleSheet( const UniString
&, SfxStyleSheetBasePool
&, SfxStyleFamily
, USHORT
);
304 SfxStyleSheet( const SfxStyleSheet
& );
306 virtual ~SfxStyleSheet();
308 virtual void SFX_NOTIFY( SfxBroadcaster
& rBC
, const TypeId
& rBCType
,
309 const SfxHint
& rHint
, const TypeId
& rHintType
);
310 virtual BOOL
SetParent( const UniString
& );
313 //=========================================================================
315 class SfxStyleSheetPool
: public SfxStyleSheetBasePool
318 using SfxStyleSheetBasePool::Create
;
319 virtual SfxStyleSheetBase
* Create(const UniString
&, SfxStyleFamily
, USHORT mask
);
320 virtual SfxStyleSheetBase
* Create(const SfxStyleSheet
&);
323 SfxStyleSheetPool( SfxItemPool
& );
325 // virtual BOOL CopyTo(SfxStyleSheetPool &rDest, const String &rSourceName);
328 //=========================================================================
330 #define SFX_STYLESHEET_CREATED 1 // neu
331 #define SFX_STYLESHEET_MODIFIED 2 // ver"andert
332 #define SFX_STYLESHEET_CHANGED 3 // gel"oscht und neu (ausgetauscht)
333 #define SFX_STYLESHEET_ERASED 4 // gel"oscht
334 #define SFX_STYLESHEET_INDESTRUCTION 5 // wird gerade entfernt
336 #define SFX_STYLESHEETPOOL_CHANGES 1 // Aenderungen, die den Zustand
337 // des Pools anedern, aber nicht
338 // ueber die STYLESHEET Hints
339 // verschickt werden sollen.
341 //========================================================================
343 class SfxStyleSheetPoolHint
: public SfxHint
350 SfxStyleSheetPoolHint(USHORT nArgHint
) : nHint(nArgHint
){}
351 USHORT
GetHint() const
355 //=========================================================================
357 class SfxStyleSheetHint
: public SfxHint
359 SfxStyleSheetBase
* pStyleSh
;
365 SfxStyleSheetHint( USHORT
, SfxStyleSheetBase
& );
366 SfxStyleSheetBase
* GetStyleSheet() const
368 USHORT
GetHint() const
372 class SfxStyleSheetHintExtended
: public SfxStyleSheetHint
379 SfxStyleSheetHintExtended(
380 USHORT
, const String
& rOld
,
381 SfxStyleSheetBase
& );
382 const String
& GetOldName() { return aName
; }