LibreOffice Module basic (master) 1
sbxcore.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_BASIC_SBXCORE_HXX
21#define INCLUDED_BASIC_SBXCORE_HXX
22
23#include <basic/basicdllapi.h>
24#include <basic/sbxdef.hxx>
25#include <rtl/ustring.hxx>
26#include <tools/ref.hxx>
27
28class SvStream;
29class ErrCode;
30
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.
35
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; }
40
41class SbxFactory;
42class SbxObject;
43class SbxBase;
44
47
48class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase
49{
50 virtual bool LoadData( SvStream&, sal_uInt16 ) = 0;
51 virtual std::pair<bool, sal_uInt32> StoreData( SvStream& ) const = 0;
52protected:
53 SbxFlagBits nFlags; // Flag-Bits
54
55 SbxBase();
56 SbxBase( const SbxBase& );
57 SbxBase& operator=( const SbxBase& );
58 virtual ~SbxBase() override;
59
60 virtual sal_uInt16 GetVersion() const = 0;
61 virtual sal_uInt16 GetSbxId() const = 0;
62
63public:
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;
75
76 virtual bool IsFixed() const;
77 virtual void SetModified( bool );
78
79 virtual SbxDataType GetType() const;
80
81 virtual void Clear() = 0;
82
83 static SbxBaseRef Load( SvStream& );
84 std::pair<bool, sal_uInt32> Store( SvStream& );
85 virtual bool LoadCompleted();
86
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();
93
94 // Set the factory for Load/Store/Create
95 static void AddFactory( SbxFactory* );
96 static void RemoveFactory( SbxFactory const * );
97
98 static SbxBaseRef Create( sal_uInt16, sal_uInt32 );
99 static SbxObjectRef CreateObject( const OUString& );
100};
101
103{ nFlags = n; }
104
106{ return nFlags; }
107
109{ nFlags |= n; }
110
112{ nFlags &= ~n; }
113
114inline bool SbxBase::IsSet( SbxFlagBits n ) const
115{ return ( nFlags & n ) != SbxFlagBits::NONE; }
116
117inline bool SbxBase::IsReset( SbxFlagBits n ) const
118{ return ( nFlags & n ) == SbxFlagBits::NONE; }
119
120inline bool SbxBase::CanRead() const
121{ return IsSet( SbxFlagBits::Read ); }
122
123inline bool SbxBase::CanWrite() const
124{ return IsSet( SbxFlagBits::Write ); }
125
126inline bool SbxBase::IsModified() const
127{ return IsSet( SbxFlagBits::Modified ); }
128
129inline bool SbxBase::IsHidden() const
130{ return IsSet( SbxFlagBits::Hidden ); }
131
132inline bool SbxBase::IsVisible() const
133{ return IsReset( SbxFlagBits::Invisible ); }
134
135#endif
136
137/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BASIC_DLLPUBLIC
Definition: basicdllapi.h:17
bool IsVisible() const
Definition: sbxcore.hxx:132
bool CanWrite() const
Definition: sbxcore.hxx:123
bool CanRead() const
Definition: sbxcore.hxx:120
SbxFlagBits nFlags
Definition: sbxcore.hxx:53
bool IsHidden() const
Definition: sbxcore.hxx:129
void SetFlags(SbxFlagBits n)
Definition: sbxcore.hxx:102
virtual void Clear()=0
bool IsSet(SbxFlagBits n) const
Definition: sbxcore.hxx:114
bool IsModified() const
Definition: sbxcore.hxx:126
void SetFlag(SbxFlagBits n)
Definition: sbxcore.hxx:108
virtual sal_uInt16 GetSbxId() const =0
SbxFlagBits GetFlags() const
Definition: sbxcore.hxx:105
virtual bool LoadData(SvStream &, sal_uInt16)=0
virtual sal_uInt16 GetVersion() const =0
virtual std::pair< bool, sal_uInt32 > StoreData(SvStream &) const =0
bool IsReset(SbxFlagBits n) const
Definition: sbxcore.hxx:117
void ResetFlag(SbxFlagBits n)
Definition: sbxcore.hxx:111
SvRefBase & operator=(const SvRefBase &)
void SetFlags(EVControlBits &rBits, EVControlBits nMask, bool bOn)
constexpr OUStringLiteral IsHidden(u"IsHidden")
sal_Int64 n
SvStream & Store(const SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16)
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
tools::SvRef< SbxBase > SbxBaseRef
Definition: sbxcore.hxx:43
tools::SvRef< SbxObject > SbxObjectRef
Definition: sbxcore.hxx:46
SbxDataType
Definition: sbxdef.hxx:37
SbxFlagBits
Definition: sbxdef.hxx:131
int SetError()
int GetError()