1234bd5c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3234bd5c5SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4234bd5c5SAndrew Rist * or more contributor license agreements. See the NOTICE file
5234bd5c5SAndrew Rist * distributed with this work for additional information
6234bd5c5SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7234bd5c5SAndrew Rist * to you under the Apache License, Version 2.0 (the
8234bd5c5SAndrew Rist * "License"); you may not use this file except in compliance
9234bd5c5SAndrew Rist * with the License. You may obtain a copy of the License at
10234bd5c5SAndrew Rist *
11234bd5c5SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12234bd5c5SAndrew Rist *
13234bd5c5SAndrew Rist * Unless required by applicable law or agreed to in writing,
14234bd5c5SAndrew Rist * software distributed under the License is distributed on an
15234bd5c5SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16234bd5c5SAndrew Rist * KIND, either express or implied. See the License for the
17234bd5c5SAndrew Rist * specific language governing permissions and limitations
18234bd5c5SAndrew Rist * under the License.
19234bd5c5SAndrew Rist *
20234bd5c5SAndrew Rist *************************************************************/
21234bd5c5SAndrew Rist
22234bd5c5SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SBXCORE_HXX
25cdf0e10cSrcweir #define _SBXCORE_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/rtti.hxx>
28cdf0e10cSrcweir #include <tools/ref.hxx>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir
31*7fef15a0SDamjan Jovanovic #include "basic/basicdllapi.h"
32cdf0e10cSrcweir #include <basic/sbxdef.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir class SvStream;
35cdf0e10cSrcweir class String;
36cdf0e10cSrcweir class UniString;
37cdf0e10cSrcweir
38cdf0e10cSrcweir // The following Macro defines four (five) necessary methods within a
39cdf0e10cSrcweir // SBX object. LoadPrivateData() and StorePrivateData() must be implemented.
40cdf0e10cSrcweir // They are necessary for loading/storing the data of derived classes.
41cdf0e10cSrcweir // Load() and Store() must not be overridden.
42cdf0e10cSrcweir
43cdf0e10cSrcweir // This version of the Macros does not define Load/StorePrivateData()-methods
44cdf0e10cSrcweir #define SBX_DECL_PERSIST_NODATA( nCre, nSbxId, nVer ) \
45cdf0e10cSrcweir virtual sal_uInt32 GetCreator() const { return nCre; } \
46cdf0e10cSrcweir virtual sal_uInt16 GetVersion() const { return nVer; } \
47cdf0e10cSrcweir virtual sal_uInt16 GetSbxId() const { return nSbxId; }
48cdf0e10cSrcweir
49cdf0e10cSrcweir #define SBX_DECL_PERSIST_NODATA_() \
50cdf0e10cSrcweir virtual sal_uInt32 GetCreator() const; \
51cdf0e10cSrcweir virtual sal_uInt16 GetVersion() const; \
52cdf0e10cSrcweir virtual sal_uInt16 GetSbxId() const;
53cdf0e10cSrcweir
54cdf0e10cSrcweir // This version of the macro defines Load/StorePrivateData()-methods
55cdf0e10cSrcweir #define SBX_DECL_PERSIST( nCre, nSbxId, nVer ) \
56cdf0e10cSrcweir virtual sal_Bool LoadPrivateData( SvStream&, sal_uInt16 ); \
57cdf0e10cSrcweir virtual sal_Bool StorePrivateData( SvStream& ) const; \
58cdf0e10cSrcweir SBX_DECL_PERSIST_NODATA( nCre, nSbxId, nVer )
59cdf0e10cSrcweir
60cdf0e10cSrcweir #define SBX_DECL_PERSIST_() \
61cdf0e10cSrcweir virtual sal_Bool LoadPrivateData( SvStream&, sal_uInt16 ); \
62cdf0e10cSrcweir virtual sal_Bool StorePrivateData( SvStream& ) const; \
63cdf0e10cSrcweir SBX_DECL_PERSIST_NODATA_()
64cdf0e10cSrcweir
65cdf0e10cSrcweir #define SBX_IMPL_PERSIST( C, nCre, nSbxId, nVer ) \
66cdf0e10cSrcweir sal_uInt32 C::GetCreator() const { return nCre; } \
67cdf0e10cSrcweir sal_uInt16 C::GetVersion() const { return nVer; } \
68cdf0e10cSrcweir sal_uInt16 C::GetSbxId() const { return nSbxId; }
69cdf0e10cSrcweir
70cdf0e10cSrcweir class SbxBase;
71cdf0e10cSrcweir class SbxFactory;
72cdf0e10cSrcweir class SbxObject;
73cdf0e10cSrcweir
74*7fef15a0SDamjan Jovanovic DBG_NAMEEX_VISIBILITY(SbxBase, BASIC_DLLPUBLIC)
75cdf0e10cSrcweir
76cdf0e10cSrcweir class SbxBaseImpl;
77cdf0e10cSrcweir
78*7fef15a0SDamjan Jovanovic class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase
79cdf0e10cSrcweir {
80cdf0e10cSrcweir SbxBaseImpl* mpSbxBaseImpl; // Impl data
81cdf0e10cSrcweir
82cdf0e10cSrcweir virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
83cdf0e10cSrcweir virtual sal_Bool StoreData( SvStream& ) const;
84cdf0e10cSrcweir protected:
85cdf0e10cSrcweir sal_uInt16 nFlags; // Flag-Bits
86cdf0e10cSrcweir
87cdf0e10cSrcweir SbxBase();
88cdf0e10cSrcweir SbxBase( const SbxBase& );
89cdf0e10cSrcweir SbxBase& operator=( const SbxBase& );
90cdf0e10cSrcweir virtual ~SbxBase();
91cdf0e10cSrcweir SBX_DECL_PERSIST(0,0,0);
92cdf0e10cSrcweir public:
93cdf0e10cSrcweir TYPEINFO();
94cdf0e10cSrcweir inline void SetFlags( sal_uInt16 n );
95cdf0e10cSrcweir inline sal_uInt16 GetFlags() const;
96cdf0e10cSrcweir inline void SetFlag( sal_uInt16 n );
97cdf0e10cSrcweir inline void ResetFlag( sal_uInt16 n );
98cdf0e10cSrcweir inline sal_Bool IsSet( sal_uInt16 n ) const;
99cdf0e10cSrcweir inline sal_Bool IsReset( sal_uInt16 n ) const;
100cdf0e10cSrcweir inline sal_Bool CanRead() const;
101cdf0e10cSrcweir inline sal_Bool CanWrite() const;
102cdf0e10cSrcweir inline sal_Bool IsModified() const;
103cdf0e10cSrcweir inline sal_Bool IsConst() const;
104cdf0e10cSrcweir inline sal_Bool IsHidden() const;
105cdf0e10cSrcweir inline sal_Bool IsVisible() const;
106cdf0e10cSrcweir
107cdf0e10cSrcweir virtual sal_Bool IsFixed() const;
108cdf0e10cSrcweir virtual void SetModified( sal_Bool );
109cdf0e10cSrcweir
110cdf0e10cSrcweir virtual SbxDataType GetType() const;
111cdf0e10cSrcweir virtual SbxClassType GetClass() const;
112cdf0e10cSrcweir
113cdf0e10cSrcweir virtual void Clear();
114cdf0e10cSrcweir
115cdf0e10cSrcweir static SbxBase* Load( SvStream& );
116cdf0e10cSrcweir static void Skip( SvStream& );
117cdf0e10cSrcweir sal_Bool Store( SvStream& );
118cdf0e10cSrcweir virtual sal_Bool LoadCompleted();
119cdf0e10cSrcweir virtual sal_Bool StoreCompleted();
120cdf0e10cSrcweir
121cdf0e10cSrcweir static SbxError GetError();
122cdf0e10cSrcweir static void SetError( SbxError );
123cdf0e10cSrcweir static sal_Bool IsError();
124cdf0e10cSrcweir static void ResetError();
125cdf0e10cSrcweir
126cdf0e10cSrcweir // Set the factory for Load/Store/Create
127cdf0e10cSrcweir static void AddFactory( SbxFactory* );
128cdf0e10cSrcweir static void RemoveFactory( SbxFactory* );
129cdf0e10cSrcweir
130cdf0e10cSrcweir static SbxBase* Create( sal_uInt16, sal_uInt32=SBXCR_SBX );
131cdf0e10cSrcweir static SbxObject* CreateObject( const String& );
132cdf0e10cSrcweir // Sbx solution as replacement for SfxBroadcaster::Enable()
133cdf0e10cSrcweir static void StaticEnableBroadcasting( sal_Bool bEnable );
134cdf0e10cSrcweir static sal_Bool StaticIsEnabledBroadcasting( void );
135cdf0e10cSrcweir };
136cdf0e10cSrcweir
137cdf0e10cSrcweir #ifndef SBX_BASE_DECL_DEFINED
138cdf0e10cSrcweir #define SBX_BASE_DECL_DEFINED
SV_DECL_REF(SbxBase)139cdf0e10cSrcweir SV_DECL_REF(SbxBase)
140cdf0e10cSrcweir #endif
141cdf0e10cSrcweir
142cdf0e10cSrcweir inline void SbxBase::SetFlags( sal_uInt16 n )
143cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); nFlags = n; }
144cdf0e10cSrcweir
GetFlags() const145cdf0e10cSrcweir inline sal_uInt16 SbxBase::GetFlags() const
146cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return nFlags; }
147cdf0e10cSrcweir
SetFlag(sal_uInt16 n)148cdf0e10cSrcweir inline void SbxBase::SetFlag( sal_uInt16 n )
149cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); nFlags |= n; }
150cdf0e10cSrcweir
ResetFlag(sal_uInt16 n)151cdf0e10cSrcweir inline void SbxBase::ResetFlag( sal_uInt16 n )
152cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); nFlags &= ~n; }
153cdf0e10cSrcweir
IsSet(sal_uInt16 n) const154cdf0e10cSrcweir inline sal_Bool SbxBase::IsSet( sal_uInt16 n ) const
155cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return sal_Bool( ( nFlags & n ) != 0 ); }
156cdf0e10cSrcweir
IsReset(sal_uInt16 n) const157cdf0e10cSrcweir inline sal_Bool SbxBase::IsReset( sal_uInt16 n ) const
158cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return sal_Bool( ( nFlags & n ) == 0 ); }
159cdf0e10cSrcweir
CanRead() const160cdf0e10cSrcweir inline sal_Bool SbxBase::CanRead() const
161cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_READ ); }
162cdf0e10cSrcweir
CanWrite() const163cdf0e10cSrcweir inline sal_Bool SbxBase::CanWrite() const
164cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_WRITE ); }
165cdf0e10cSrcweir
IsModified() const166cdf0e10cSrcweir inline sal_Bool SbxBase::IsModified() const
167cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_MODIFIED ); }
168cdf0e10cSrcweir
IsConst() const169cdf0e10cSrcweir inline sal_Bool SbxBase::IsConst() const
170cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_CONST ); }
171cdf0e10cSrcweir
IsHidden() const172cdf0e10cSrcweir inline sal_Bool SbxBase::IsHidden() const
173cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_HIDDEN ); }
174cdf0e10cSrcweir
IsVisible() const175cdf0e10cSrcweir inline sal_Bool SbxBase::IsVisible() const
176cdf0e10cSrcweir { DBG_CHKTHIS( SbxBase, 0 ); return IsReset( SBX_INVISIBLE ); }
177cdf0e10cSrcweir
178cdf0e10cSrcweir #endif
179