update credits
[LibreOffice.git] / include / basic / sbxcore.hxx
blob98f984196dd6450e079c778dde736738eed9a376
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 .
20 #ifndef INCLUDED_BASIC_SBXCORE_HXX
21 #define INCLUDED_BASIC_SBXCORE_HXX
23 #include <tools/rtti.hxx>
24 #include <tools/ref.hxx>
26 #include <basic/sbxdef.hxx>
27 #include <basic/basicdllapi.h>
29 class SvStream;
31 // The following Macro defines four (five) necessary methods within a
32 // SBX object. LoadPrivateData() and StorePrivateData() must be implemented.
33 // They are necessary for loading/storing the data of derived classes.
34 // Load() and Store() must not be overridden.
36 // This version of the Macros does not define Load/StorePrivateData()-methods
37 #define SBX_DECL_PERSIST_NODATA( nCre, nSbxId, nVer ) \
38 virtual sal_uInt32 GetCreator() const SAL_OVERRIDE { return nCre; } \
39 virtual sal_uInt16 GetVersion() const SAL_OVERRIDE { return nVer; } \
40 virtual sal_uInt16 GetSbxId() const SAL_OVERRIDE { return nSbxId; }
42 // This version of the macro defines Load/StorePrivateData()-methods
43 #define SBX_DECL_PERSIST( nCre, nSbxId, nVer ) \
44 virtual bool LoadPrivateData( SvStream&, sal_uInt16 ); \
45 virtual bool StorePrivateData( SvStream& ) const; \
46 virtual sal_uInt32 GetCreator() const { return nCre; } \
47 virtual sal_uInt16 GetVersion() const { return nVer; } \
48 virtual sal_uInt16 GetSbxId() const { return nSbxId; }
50 class SbxBase;
51 class SbxFactory;
52 class SbxObject;
54 class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase
56 virtual bool LoadData( SvStream&, sal_uInt16 );
57 virtual bool StoreData( SvStream& ) const;
58 protected:
59 SbxFlagBits nFlags; // Flag-Bits
61 SbxBase();
62 SbxBase( const SbxBase& );
63 SbxBase& operator=( const SbxBase& );
64 virtual ~SbxBase();
65 SBX_DECL_PERSIST(0,0,0);
66 public:
67 TYPEINFO();
68 inline void SetFlags( SbxFlagBits n );
69 inline SbxFlagBits GetFlags() const;
70 inline void SetFlag( SbxFlagBits n );
71 inline void ResetFlag( SbxFlagBits n );
72 inline bool IsSet( SbxFlagBits n ) const;
73 inline bool IsReset( SbxFlagBits n ) const;
74 inline bool CanRead() const;
75 inline bool CanWrite() const;
76 inline bool IsModified() const;
77 inline bool IsConst() const;
78 inline bool IsHidden() const;
79 inline bool IsVisible() const;
81 virtual bool IsFixed() const;
82 virtual void SetModified( bool );
84 virtual SbxDataType GetType() const;
85 virtual SbxClassType GetClass() const;
87 virtual void Clear();
89 static SbxBase* Load( SvStream& );
90 static void Skip( SvStream& );
91 bool Store( SvStream& );
92 virtual bool LoadCompleted();
93 bool StoreCompleted();
95 static SbxError GetError();
96 static void SetError( SbxError );
97 static bool IsError();
98 static void ResetError();
100 // Set the factory for Load/Store/Create
101 static void AddFactory( SbxFactory* );
102 static void RemoveFactory( SbxFactory* );
104 static SbxBase* Create( sal_uInt16, sal_uInt32=SBXCR_SBX );
105 static SbxObject* CreateObject( const OUString& );
108 typedef tools::SvRef<SbxBase> SbxBaseRef;
110 inline void SbxBase::SetFlags( SbxFlagBits n )
111 { nFlags = n; }
113 inline SbxFlagBits SbxBase::GetFlags() const
114 { return nFlags; }
116 inline void SbxBase::SetFlag( SbxFlagBits n )
117 { nFlags |= n; }
119 inline void SbxBase::ResetFlag( SbxFlagBits n )
120 { nFlags &= ~n; }
122 inline bool SbxBase::IsSet( SbxFlagBits n ) const
123 { return ( nFlags & n ) != SBX_NONE; }
125 inline bool SbxBase::IsReset( SbxFlagBits n ) const
126 { return ( nFlags & n ) == SBX_NONE; }
128 inline bool SbxBase::CanRead() const
129 { return IsSet( SBX_READ ); }
131 inline bool SbxBase::CanWrite() const
132 { return IsSet( SBX_WRITE ); }
134 inline bool SbxBase::IsModified() const
135 { return IsSet( SBX_MODIFIED ); }
137 inline bool SbxBase::IsConst() const
138 { return IsSet( SBX_CONST ); }
140 inline bool SbxBase::IsHidden() const
141 { return IsSet( SBX_HIDDEN ); }
143 inline bool SbxBase::IsVisible() const
144 { return IsReset( SBX_INVISIBLE ); }
146 #endif
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */