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 .
20 #ifndef INCLUDED_BASIC_SBXCORE_HXX
21 #define INCLUDED_BASIC_SBXCORE_HXX
23 #include <tools/rtti.hxx>
24 #include <tools/ref.hxx>
25 #include <tools/debug.hxx>
27 #include <basic/sbxdef.hxx>
28 #include <basic/basicdllapi.h>
32 // The following Macro defines four (five) necessary methods within a
33 // SBX object. LoadPrivateData() and StorePrivateData() must be implemented.
34 // They are necessary for loading/storing the data of derived classes.
35 // Load() and Store() must not be overridden.
37 // This version of the Macros does not define Load/StorePrivateData()-methods
38 #define SBX_DECL_PERSIST_NODATA( nCre, nSbxId, nVer ) \
39 virtual sal_uInt32 GetCreator() const SAL_OVERRIDE { return nCre; } \
40 virtual sal_uInt16 GetVersion() const SAL_OVERRIDE { return nVer; } \
41 virtual sal_uInt16 GetSbxId() const SAL_OVERRIDE { return nSbxId; }
43 // This version of the macro defines Load/StorePrivateData()-methods
44 #define SBX_DECL_PERSIST( nCre, nSbxId, nVer ) \
45 virtual bool LoadPrivateData( SvStream&, sal_uInt16 ); \
46 virtual bool StorePrivateData( SvStream& ) const; \
47 virtual sal_uInt32 GetCreator() const { return nCre; } \
48 virtual sal_uInt16 GetVersion() const { return nVer; } \
49 virtual sal_uInt16 GetSbxId() const { return nSbxId; }
55 class BASIC_DLLPUBLIC SbxBase
: virtual public SvRefBase
57 virtual bool LoadData( SvStream
&, sal_uInt16
);
58 virtual bool StoreData( SvStream
& ) const;
60 sal_uInt16 nFlags
; // Flag-Bits
63 SbxBase( const SbxBase
& );
64 SbxBase
& operator=( const SbxBase
& );
66 SBX_DECL_PERSIST(0,0,0);
69 inline void SetFlags( sal_uInt16 n
);
70 inline sal_uInt16
GetFlags() const;
71 inline void SetFlag( sal_uInt16 n
);
72 inline void ResetFlag( sal_uInt16 n
);
73 inline bool IsSet( sal_uInt16 n
) const;
74 inline bool IsReset( sal_uInt16 n
) const;
75 inline bool CanRead() const;
76 inline bool CanWrite() const;
77 inline bool IsModified() const;
78 inline bool IsConst() const;
79 inline bool IsHidden() const;
80 inline bool IsVisible() const;
82 virtual bool IsFixed() const;
83 virtual void SetModified( bool );
85 virtual SbxDataType
GetType() const;
86 virtual SbxClassType
GetClass() const;
90 static SbxBase
* Load( SvStream
& );
91 static void Skip( SvStream
& );
92 bool Store( SvStream
& );
93 virtual bool LoadCompleted();
94 virtual bool StoreCompleted();
96 static SbxError
GetError();
97 static void SetError( SbxError
);
98 static bool IsError();
99 static void ResetError();
101 // Set the factory for Load/Store/Create
102 static void AddFactory( SbxFactory
* );
103 static void RemoveFactory( SbxFactory
* );
105 static SbxBase
* Create( sal_uInt16
, sal_uInt32
=SBXCR_SBX
);
106 static SbxObject
* CreateObject( const OUString
& );
109 typedef tools::SvRef
<SbxBase
> SbxBaseRef
;
111 inline void SbxBase::SetFlags( sal_uInt16 n
)
114 inline sal_uInt16
SbxBase::GetFlags() const
117 inline void SbxBase::SetFlag( sal_uInt16 n
)
120 inline void SbxBase::ResetFlag( sal_uInt16 n
)
123 inline bool SbxBase::IsSet( sal_uInt16 n
) const
124 { return ( nFlags
& n
) != 0; }
126 inline bool SbxBase::IsReset( sal_uInt16 n
) const
127 { return ( nFlags
& n
) == 0; }
129 inline bool SbxBase::CanRead() const
130 { return IsSet( SBX_READ
); }
132 inline bool SbxBase::CanWrite() const
133 { return IsSet( SBX_WRITE
); }
135 inline bool SbxBase::IsModified() const
136 { return IsSet( SBX_MODIFIED
); }
138 inline bool SbxBase::IsConst() const
139 { return IsSet( SBX_CONST
); }
141 inline bool SbxBase::IsHidden() const
142 { return IsSet( SBX_HIDDEN
); }
144 inline bool SbxBase::IsVisible() const
145 { return IsReset( SBX_INVISIBLE
); }
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */