/src/libreoffice/include/basic/sbxcore.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <basic/basicdllapi.h> |
23 | | #include <basic/sbxdef.hxx> |
24 | | #include <rtl/ustring.hxx> |
25 | | #include <tools/ref.hxx> |
26 | | |
27 | | class SvStream; |
28 | | class ErrCode; |
29 | | |
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. |
34 | | |
35 | | // This version of the Macros does not define Load/StorePrivateData()-methods |
36 | | #define SBX_DECL_PERSIST_NODATA( nSbxId, nVer ) \ |
37 | 0 | virtual sal_uInt16 GetVersion() const override { return nVer; } \Unexecuted instantiation: SbxValue::GetVersion() const Unexecuted instantiation: SbxVariable::GetVersion() const Unexecuted instantiation: SbxObject::GetVersion() const Unexecuted instantiation: SbxArray::GetVersion() const Unexecuted instantiation: SbxDimArray::GetVersion() const Unexecuted instantiation: SbxCollection::GetVersion() const Unexecuted instantiation: SbxStdCollection::GetVersion() const Unexecuted instantiation: SbModule::GetVersion() const Unexecuted instantiation: StarBASIC::GetVersion() const Unexecuted instantiation: SbxMethod::GetVersion() const Unexecuted instantiation: SbMethod::GetVersion() const Unexecuted instantiation: SbxProperty::GetVersion() const Unexecuted instantiation: SbProperty::GetVersion() const |
38 | 0 | virtual sal_uInt16 GetSbxId() const override { return nSbxId; }Unexecuted instantiation: SbxValue::GetSbxId() const Unexecuted instantiation: SbxVariable::GetSbxId() const Unexecuted instantiation: SbxObject::GetSbxId() const Unexecuted instantiation: SbxArray::GetSbxId() const Unexecuted instantiation: SbxDimArray::GetSbxId() const Unexecuted instantiation: SbxCollection::GetSbxId() const Unexecuted instantiation: SbxStdCollection::GetSbxId() const Unexecuted instantiation: SbModule::GetSbxId() const Unexecuted instantiation: StarBASIC::GetSbxId() const Unexecuted instantiation: SbxMethod::GetSbxId() const Unexecuted instantiation: SbMethod::GetSbxId() const Unexecuted instantiation: SbxProperty::GetSbxId() const Unexecuted instantiation: SbProperty::GetSbxId() const |
39 | | |
40 | | class SbxFactory; |
41 | | class SbxObject; |
42 | | class SbxBase; |
43 | | |
44 | | typedef tools::SvRef<SbxBase> SbxBaseRef; |
45 | | typedef tools::SvRef<SbxObject> SbxObjectRef; |
46 | | |
47 | | class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase |
48 | | { |
49 | | virtual bool LoadData( SvStream&, sal_uInt16 ) = 0; |
50 | | virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const = 0; |
51 | | protected: |
52 | | SbxFlagBits nFlags; // Flag-Bits |
53 | | |
54 | | SbxBase(); |
55 | | SbxBase( const SbxBase& ); |
56 | | SbxBase& operator=( const SbxBase& ); |
57 | | virtual ~SbxBase() override; |
58 | | |
59 | | virtual sal_uInt16 GetVersion() const = 0; |
60 | | virtual sal_uInt16 GetSbxId() const = 0; |
61 | | |
62 | | public: |
63 | | inline void SetFlags( SbxFlagBits n ); |
64 | | inline SbxFlagBits GetFlags() const; |
65 | | inline void SetFlag( SbxFlagBits n ); |
66 | | inline void ResetFlag( SbxFlagBits n ); |
67 | | inline bool IsSet( SbxFlagBits n ) const; |
68 | | inline bool IsReset( SbxFlagBits n ) const; |
69 | | inline bool CanRead() const; |
70 | | inline bool CanWrite() const; |
71 | | inline bool IsModified() const; |
72 | | inline bool IsHidden() const; |
73 | | inline bool IsVisible() const; |
74 | | |
75 | | virtual bool IsFixed() const; |
76 | | virtual void SetModified( bool ); |
77 | | |
78 | | virtual SbxDataType GetType() const; |
79 | | |
80 | | virtual void Clear() = 0; |
81 | | |
82 | | static SbxBaseRef Load( SvStream& ); |
83 | | std::pair<bool, sal_uInt32> Store( SvStream& ); |
84 | | virtual bool LoadCompleted(); |
85 | | |
86 | | static ErrCode const & GetError(); |
87 | | static OUString const& GetErrorMsg(); |
88 | | static void SetError( ErrCode ); |
89 | | static void SetError(ErrCode, const OUString&); |
90 | | static bool IsError(); |
91 | | static void ResetError(); |
92 | | |
93 | | // Set the factory for Load/Store/Create |
94 | | static void AddFactory( SbxFactory* ); |
95 | | static void RemoveFactory( SbxFactory const * ); |
96 | | |
97 | | static SbxBaseRef Create( sal_uInt16, sal_uInt32 ); |
98 | | static SbxObjectRef CreateObject( const OUString& ); |
99 | | }; |
100 | | |
101 | | inline void SbxBase::SetFlags( SbxFlagBits n ) |
102 | 0 | { nFlags = n; } |
103 | | |
104 | | inline SbxFlagBits SbxBase::GetFlags() const |
105 | 118k | { return nFlags; } |
106 | | |
107 | | inline void SbxBase::SetFlag( SbxFlagBits n ) |
108 | 127k | { nFlags |= n; } |
109 | | |
110 | | inline void SbxBase::ResetFlag( SbxFlagBits n ) |
111 | 0 | { nFlags &= ~n; } |
112 | | |
113 | | inline bool SbxBase::IsSet( SbxFlagBits n ) const |
114 | 299k | { return ( nFlags & n ) != SbxFlagBits::NONE; } |
115 | | |
116 | | inline bool SbxBase::IsReset( SbxFlagBits n ) const |
117 | 0 | { return ( nFlags & n ) == SbxFlagBits::NONE; } |
118 | | |
119 | | inline bool SbxBase::CanRead() const |
120 | 59.7k | { return IsSet( SbxFlagBits::Read ); } |
121 | | |
122 | | inline bool SbxBase::CanWrite() const |
123 | 168k | { return IsSet( SbxFlagBits::Write ); } |
124 | | |
125 | | inline bool SbxBase::IsModified() const |
126 | 0 | { return IsSet( SbxFlagBits::Modified ); } |
127 | | |
128 | | inline bool SbxBase::IsHidden() const |
129 | 0 | { return IsSet( SbxFlagBits::Hidden ); } |
130 | | |
131 | | inline bool SbxBase::IsVisible() const |
132 | 0 | { return IsReset( SbxFlagBits::Invisible ); } |
133 | | |
134 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |