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 <basic/basicdllapi.h>
24 #include <basic/sbxdef.hxx>
25 #include <rtl/ustring.hxx>
26 #include <tools/ref.hxx>
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( nSbxId, nVer ) \
38 virtual sal_uInt16 GetVersion() const override { return nVer; } \
39 virtual sal_uInt16 GetSbxId() const override { return nSbxId; }
45 typedef tools::SvRef
<SbxBase
> SbxBaseRef
;
46 typedef tools::SvRef
<SbxObject
> SbxObjectRef
;
48 class BASIC_DLLPUBLIC SbxBase
: virtual public SvRefBase
50 virtual bool LoadData( SvStream
&, sal_uInt16
) = 0;
51 virtual std::pair
<bool, sal_uInt32
> StoreData( SvStream
& ) const = 0;
53 SbxFlagBits nFlags
; // Flag-Bits
56 SbxBase( const SbxBase
& );
57 SbxBase
& operator=( const SbxBase
& );
58 virtual ~SbxBase() override
;
60 virtual sal_uInt16
GetVersion() const = 0;
61 virtual sal_uInt16
GetSbxId() const = 0;
64 inline void SetFlags( SbxFlagBits n
);
65 inline SbxFlagBits
GetFlags() const;
66 inline void SetFlag( SbxFlagBits n
);
67 inline void ResetFlag( SbxFlagBits n
);
68 inline bool IsSet( SbxFlagBits n
) const;
69 inline bool IsReset( SbxFlagBits n
) const;
70 inline bool CanRead() const;
71 inline bool CanWrite() const;
72 inline bool IsModified() const;
73 inline bool IsHidden() const;
74 inline bool IsVisible() const;
76 virtual bool IsFixed() const;
77 virtual void SetModified( bool );
79 virtual SbxDataType
GetType() const;
81 virtual void Clear() = 0;
83 static SbxBaseRef
Load( SvStream
& );
84 std::pair
<bool, sal_uInt32
> Store( SvStream
& );
85 virtual bool LoadCompleted();
87 static ErrCode
const & GetError();
88 static OUString
const& GetErrorMsg();
89 static void SetError( ErrCode
);
90 static void SetError(ErrCode
, const OUString
&);
91 static bool IsError();
92 static void ResetError();
94 // Set the factory for Load/Store/Create
95 static void AddFactory( SbxFactory
* );
96 static void RemoveFactory( SbxFactory
const * );
98 static SbxBaseRef
Create( sal_uInt16
, sal_uInt32
);
99 static SbxObjectRef
CreateObject( const OUString
& );
102 inline void SbxBase::SetFlags( SbxFlagBits n
)
105 inline SbxFlagBits
SbxBase::GetFlags() const
108 inline void SbxBase::SetFlag( SbxFlagBits n
)
111 inline void SbxBase::ResetFlag( SbxFlagBits n
)
114 inline bool SbxBase::IsSet( SbxFlagBits n
) const
115 { return ( nFlags
& n
) != SbxFlagBits::NONE
; }
117 inline bool SbxBase::IsReset( SbxFlagBits n
) const
118 { return ( nFlags
& n
) == SbxFlagBits::NONE
; }
120 inline bool SbxBase::CanRead() const
121 { return IsSet( SbxFlagBits::Read
); }
123 inline bool SbxBase::CanWrite() const
124 { return IsSet( SbxFlagBits::Write
); }
126 inline bool SbxBase::IsModified() const
127 { return IsSet( SbxFlagBits::Modified
); }
129 inline bool SbxBase::IsHidden() const
130 { return IsSet( SbxFlagBits::Hidden
); }
132 inline bool SbxBase::IsVisible() const
133 { return IsReset( SbxFlagBits::Invisible
); }
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */