2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2013-10-23 19:18:27 +02:00
|
|
|
#ifndef INCLUDED_BASIC_SBXCORE_HXX
|
|
|
|
#define INCLUDED_BASIC_SBXCORE_HXX
|
2007-04-11 11:54:30 +00:00
|
|
|
|
|
|
|
#include <tools/rtti.hxx>
|
|
|
|
#include <tools/ref.hxx>
|
|
|
|
|
|
|
|
#include <basic/sbxdef.hxx>
|
2013-11-09 13:29:54 -06:00
|
|
|
#include <basic/basicdllapi.h>
|
2007-04-11 11:54:30 +00:00
|
|
|
|
|
|
|
class SvStream;
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// The following Macro defines four (five) necessary methods within a
|
|
|
|
// SBX object. LoadPrivateData() and StorePrivateData() must be implemented.
|
|
|
|
// They are necessary for loading/storing the data of derived classes.
|
|
|
|
// Load() and Store() must not be overridden.
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// This version of the Macros does not define Load/StorePrivateData()-methods
|
2007-04-11 11:54:30 +00:00
|
|
|
#define SBX_DECL_PERSIST_NODATA( nCre, nSbxId, nVer ) \
|
2014-03-26 16:37:00 +01:00
|
|
|
virtual sal_uInt32 GetCreator() const SAL_OVERRIDE { return nCre; } \
|
|
|
|
virtual sal_uInt16 GetVersion() const SAL_OVERRIDE { return nVer; } \
|
|
|
|
virtual sal_uInt16 GetSbxId() const SAL_OVERRIDE { return nSbxId; }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
|
|
|
class SbxBase;
|
|
|
|
class SbxFactory;
|
|
|
|
class SbxObject;
|
|
|
|
|
2011-07-28 18:17:31 +02:00
|
|
|
class BASIC_DLLPUBLIC SbxBase : virtual public SvRefBase
|
2007-04-11 11:54:30 +00:00
|
|
|
{
|
2014-03-26 11:18:51 +02:00
|
|
|
virtual bool LoadData( SvStream&, sal_uInt16 );
|
|
|
|
virtual bool StoreData( SvStream& ) const;
|
2007-04-11 11:54:30 +00:00
|
|
|
protected:
|
2014-08-21 14:41:58 +02:00
|
|
|
SbxFlagBits nFlags; // Flag-Bits
|
2007-04-11 11:54:30 +00:00
|
|
|
|
|
|
|
SbxBase();
|
|
|
|
SbxBase( const SbxBase& );
|
|
|
|
SbxBase& operator=( const SbxBase& );
|
|
|
|
virtual ~SbxBase();
|
2015-07-24 16:22:29 +02:00
|
|
|
|
|
|
|
virtual bool LoadPrivateData( SvStream&, sal_uInt16 );
|
|
|
|
virtual bool StorePrivateData( SvStream& ) const;
|
|
|
|
virtual sal_uInt32 GetCreator() const { return 0; }
|
|
|
|
virtual sal_uInt16 GetVersion() const { return 0; }
|
|
|
|
virtual sal_uInt16 GetSbxId() const { return 0; }
|
|
|
|
|
2007-04-11 11:54:30 +00:00
|
|
|
public:
|
|
|
|
TYPEINFO();
|
2014-08-21 14:41:58 +02:00
|
|
|
inline void SetFlags( SbxFlagBits n );
|
|
|
|
inline SbxFlagBits GetFlags() const;
|
|
|
|
inline void SetFlag( SbxFlagBits n );
|
|
|
|
inline void ResetFlag( SbxFlagBits n );
|
|
|
|
inline bool IsSet( SbxFlagBits n ) const;
|
|
|
|
inline bool IsReset( SbxFlagBits n ) const;
|
2014-03-26 11:18:51 +02:00
|
|
|
inline bool CanRead() const;
|
|
|
|
inline bool CanWrite() const;
|
|
|
|
inline bool IsModified() const;
|
|
|
|
inline bool IsHidden() const;
|
|
|
|
inline bool IsVisible() const;
|
|
|
|
|
|
|
|
virtual bool IsFixed() const;
|
|
|
|
virtual void SetModified( bool );
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2012-11-03 09:07:25 -05:00
|
|
|
virtual SbxDataType GetType() const;
|
2007-04-11 11:54:30 +00:00
|
|
|
virtual SbxClassType GetClass() const;
|
|
|
|
|
2015-01-21 12:15:26 +02:00
|
|
|
virtual void Clear();
|
2007-04-11 11:54:30 +00:00
|
|
|
|
|
|
|
static SbxBase* Load( SvStream& );
|
2012-11-03 09:07:25 -05:00
|
|
|
static void Skip( SvStream& );
|
2014-03-26 11:18:51 +02:00
|
|
|
bool Store( SvStream& );
|
|
|
|
virtual bool LoadCompleted();
|
2007-04-11 11:54:30 +00:00
|
|
|
|
|
|
|
static SbxError GetError();
|
|
|
|
static void SetError( SbxError );
|
2014-03-26 11:18:51 +02:00
|
|
|
static bool IsError();
|
2007-04-11 11:54:30 +00:00
|
|
|
static void ResetError();
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Set the factory for Load/Store/Create
|
2007-04-11 11:54:30 +00:00
|
|
|
static void AddFactory( SbxFactory* );
|
|
|
|
static void RemoveFactory( SbxFactory* );
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
static SbxBase* Create( sal_uInt16, sal_uInt32=SBXCR_SBX );
|
2013-04-07 12:06:47 +02:00
|
|
|
static SbxObject* CreateObject( const OUString& );
|
2007-04-11 11:54:30 +00:00
|
|
|
};
|
|
|
|
|
2014-04-07 12:31:09 +02:00
|
|
|
typedef tools::SvRef<SbxBase> SbxBaseRef;
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-08-21 14:41:58 +02:00
|
|
|
inline void SbxBase::SetFlags( SbxFlagBits n )
|
2014-03-28 15:15:26 +01:00
|
|
|
{ nFlags = n; }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-08-21 14:41:58 +02:00
|
|
|
inline SbxFlagBits SbxBase::GetFlags() const
|
2014-03-28 15:15:26 +01:00
|
|
|
{ return nFlags; }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-08-21 14:41:58 +02:00
|
|
|
inline void SbxBase::SetFlag( SbxFlagBits n )
|
2014-03-28 15:15:26 +01:00
|
|
|
{ nFlags |= n; }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-08-21 14:41:58 +02:00
|
|
|
inline void SbxBase::ResetFlag( SbxFlagBits n )
|
2014-03-28 15:15:26 +01:00
|
|
|
{ nFlags &= ~n; }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-08-21 14:41:58 +02:00
|
|
|
inline bool SbxBase::IsSet( SbxFlagBits n ) const
|
2015-07-27 11:31:24 +02:00
|
|
|
{ return ( nFlags & n ) != SbxFlagBits::NONE; }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-08-21 14:41:58 +02:00
|
|
|
inline bool SbxBase::IsReset( SbxFlagBits n ) const
|
2015-07-27 11:31:24 +02:00
|
|
|
{ return ( nFlags & n ) == SbxFlagBits::NONE; }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-03-26 11:18:51 +02:00
|
|
|
inline bool SbxBase::CanRead() const
|
2015-07-27 11:31:24 +02:00
|
|
|
{ return IsSet( SbxFlagBits::Read ); }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-03-26 11:18:51 +02:00
|
|
|
inline bool SbxBase::CanWrite() const
|
2015-07-27 11:31:24 +02:00
|
|
|
{ return IsSet( SbxFlagBits::Write ); }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-03-26 11:18:51 +02:00
|
|
|
inline bool SbxBase::IsModified() const
|
2015-07-27 11:31:24 +02:00
|
|
|
{ return IsSet( SbxFlagBits::Modified ); }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-03-26 11:18:51 +02:00
|
|
|
inline bool SbxBase::IsHidden() const
|
2015-07-27 11:31:24 +02:00
|
|
|
{ return IsSet( SbxFlagBits::Hidden ); }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
2014-03-26 11:18:51 +02:00
|
|
|
inline bool SbxBase::IsVisible() const
|
2015-07-27 11:31:24 +02:00
|
|
|
{ return IsReset( SbxFlagBits::Invisible ); }
|
2007-04-11 11:54:30 +00:00
|
|
|
|
|
|
|
#endif
|
2010-10-27 13:11:31 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|