Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svtools / style.hxx
bloba55ea95ae9f027abb58dc2c6b0341385b35296b4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: style.hxx,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 #ifndef _SFXSTYLE_HXX
32 #define _SFXSTYLE_HXX
34 #ifndef INCLUDED_SVTDLLAPI_H
35 #include "bf_svtools/svtdllapi.h"
36 #endif
38 #ifndef _RSCSFX_HXX
39 #include <rsc/rscsfx.hxx>
40 #endif
42 #ifndef _STRING_HXX //autogen
43 #include <tools/string.hxx>
44 #endif
45 #ifndef _LIST_HXX //autogen
46 #include <tools/list.hxx>
47 #endif
48 #ifndef _SFXHINT_HXX //autogen
49 #include <bf_svtools/hint.hxx>
50 #endif
51 #ifndef _SFXLSTNER_HXX //autogen
52 #include <bf_svtools/lstner.hxx>
53 #endif
54 #ifndef _SFXBRDCST_HXX //autogen
55 #include <bf_svtools/brdcst.hxx>
56 #endif
58 #ifndef _SFXPOOLITEM_HXX //autogen
59 #include <bf_svtools/poolitem.hxx>
60 #endif
62 #ifndef _SFX_STYLE_HRC
63 #include <bf_svtools/style.hrc>
64 #endif
66 class SvStream;
68 namespace binfilter
71 class SfxItemSet;
72 class SfxItemPool;
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;
119 protected:
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& );
139 public:
140 TYPEINFO();
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
178 /* [Beschreibung]
180 Klasse zum Iterieren und Suchen auf einem SfxStyleSheetBasePool.
185 public:
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();
197 protected:
199 SfxStyleSheetBasePool* pBasePool;
200 SfxStyleFamily nSearchFamily;
201 USHORT nMask;
202 BOOL SearchUsed() const { return bSearchUsed; }
204 private:
205 USHORT GetPos(){return nAktPosition;}
206 BOOL IsTrivialSearch();
207 BOOL DoesStyleMatch(SfxStyleSheetBase *pStyle);
209 void* pImp;
210 SfxStyleSheetBase* pAktStyle;
211 USHORT nAktPosition;
212 BOOL bSearchUsed;
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;
228 private:
229 BOOL Load1_Impl( SvStream& );
230 SfxStyleSheetIterator& GetIterator_Impl();
231 protected:
232 String aAppName;
233 SfxItemPool& rPool;
234 SfxStyles aStyles;
235 SfxStyleFamily nSearchFamily;
236 USHORT nMask;
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& );
243 public:
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&,
260 SfxStyleFamily eFam,
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
300 public:
301 TYPEINFO();
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
317 protected:
318 using SfxStyleSheetBasePool::Create;
319 virtual SfxStyleSheetBase* Create(const UniString&, SfxStyleFamily, USHORT mask);
320 virtual SfxStyleSheetBase* Create(const SfxStyleSheet &);
322 public:
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
345 USHORT nHint;
347 public:
348 TYPEINFO();
350 SfxStyleSheetPoolHint(USHORT nArgHint) : nHint(nArgHint){}
351 USHORT GetHint() const
352 { return nHint; }
355 //=========================================================================
357 class SfxStyleSheetHint: public SfxHint
359 SfxStyleSheetBase* pStyleSh;
360 USHORT nHint;
362 public:
363 TYPEINFO();
365 SfxStyleSheetHint( USHORT, SfxStyleSheetBase& );
366 SfxStyleSheetBase* GetStyleSheet() const
367 { return pStyleSh; }
368 USHORT GetHint() const
369 { return nHint; }
372 class SfxStyleSheetHintExtended: public SfxStyleSheetHint
374 String aName;
376 public:
377 TYPEINFO();
379 SfxStyleSheetHintExtended(
380 USHORT, const String& rOld,
381 SfxStyleSheetBase& );
382 const String& GetOldName() { return aName; }
387 #endif