build fix
[LibreOffice.git] / include / basic / sbxcore.hxx
blobafa7e393f56cc1e9b2b44986fbb3900100567b76
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 <basic/basicdllapi.h>
24 #include <basic/sbxdef.hxx>
25 #include <rtl/ustring.hxx>
26 #include <tools/ref.hxx>
28 class SvStream;
30 // The following Macro defines four (five) necessary methods within a
31 // SBX object. LoadPrivateData() and StorePrivateData() must be implemented.
32 // They are necessary for loading/storing the data of derived classes.
33 // Load() and Store() must not be overridden.
35 // This version of the Macros does not define Load/StorePrivateData()-methods
36 #define SBX_DECL_PERSIST_NODATA( nSbxId, nVer ) \
37 virtual sal_uInt16 GetVersion() const override { return nVer; } \
38 virtual sal_uInt16 GetSbxId() const override { return nSbxId; }
40 class SbxFactory;
41 class SbxObject;
43 class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase
45 virtual bool LoadData( SvStream&, sal_uInt16 ) = 0;
46 virtual bool StoreData( SvStream& ) const = 0;
47 protected:
48 SbxFlagBits nFlags; // Flag-Bits
50 SbxBase();
51 SbxBase( const SbxBase& );
52 SbxBase& operator=( const SbxBase& );
53 virtual ~SbxBase() override;
55 virtual sal_uInt16 GetVersion() const = 0;
56 virtual sal_uInt16 GetSbxId() const = 0;
58 public:
59 inline void SetFlags( SbxFlagBits n );
60 inline SbxFlagBits GetFlags() const;
61 inline void SetFlag( SbxFlagBits n );
62 inline void ResetFlag( SbxFlagBits n );
63 inline bool IsSet( SbxFlagBits n ) const;
64 inline bool IsReset( SbxFlagBits n ) const;
65 inline bool CanRead() const;
66 inline bool CanWrite() const;
67 inline bool IsModified() const;
68 inline bool IsHidden() const;
69 inline bool IsVisible() const;
71 virtual bool IsFixed() const;
72 virtual void SetModified( bool );
74 virtual SbxDataType GetType() const;
75 virtual SbxClassType GetClass() const;
77 virtual void Clear() = 0;
79 static SbxBase* Load( SvStream& );
80 bool Store( SvStream& );
81 virtual bool LoadCompleted();
83 static SbxError GetError();
84 static void SetError( SbxError );
85 static bool IsError();
86 static void ResetError();
88 // Set the factory for Load/Store/Create
89 static void AddFactory( SbxFactory* );
90 static void RemoveFactory( SbxFactory* );
92 static SbxBase* Create( sal_uInt16, sal_uInt32 );
93 static SbxObject* CreateObject( const OUString& );
96 typedef tools::SvRef<SbxBase> SbxBaseRef;
98 inline void SbxBase::SetFlags( SbxFlagBits n )
99 { nFlags = n; }
101 inline SbxFlagBits SbxBase::GetFlags() const
102 { return nFlags; }
104 inline void SbxBase::SetFlag( SbxFlagBits n )
105 { nFlags |= n; }
107 inline void SbxBase::ResetFlag( SbxFlagBits n )
108 { nFlags &= ~n; }
110 inline bool SbxBase::IsSet( SbxFlagBits n ) const
111 { return ( nFlags & n ) != SbxFlagBits::NONE; }
113 inline bool SbxBase::IsReset( SbxFlagBits n ) const
114 { return ( nFlags & n ) == SbxFlagBits::NONE; }
116 inline bool SbxBase::CanRead() const
117 { return IsSet( SbxFlagBits::Read ); }
119 inline bool SbxBase::CanWrite() const
120 { return IsSet( SbxFlagBits::Write ); }
122 inline bool SbxBase::IsModified() const
123 { return IsSet( SbxFlagBits::Modified ); }
125 inline bool SbxBase::IsHidden() const
126 { return IsSet( SbxFlagBits::Hidden ); }
128 inline bool SbxBase::IsVisible() const
129 { return IsReset( SbxFlagBits::Invisible ); }
131 #endif
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */