Kaydet (Commit) c605c8d0 authored tarafından Noel Grandin's avatar Noel Grandin

SvPersistStream dead

since commit 1e4b1e4a
"Removing unused SfxItemPool serialisation from editeng"

Change-Id: I8a3cd36a13b7d2322047c2035e0f23c70ca9cdf0
Reviewed-on: https://gerrit.libreoffice.org/40880Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 61d49afa
......@@ -20,7 +20,7 @@
#include <editeng/measfld.hxx>
SV_IMPL_PERSIST1(SdrMeasureField,SvxFieldData);
SV_IMPL_PERSIST1(SdrMeasureField);
SdrMeasureField::~SdrMeasureField()
{
......@@ -36,16 +36,4 @@ bool SdrMeasureField::operator==(const SvxFieldData& rSrc) const
return eMeasureFieldKind == static_cast<const SdrMeasureField&>(rSrc).GetMeasureFieldKind();
}
void SdrMeasureField::Load(SvPersistStream& rIn)
{
sal_uInt16 nFieldKind;
rIn.ReadUInt16( nFieldKind );
eMeasureFieldKind=(SdrMeasureFieldKind)nFieldKind;
}
void SdrMeasureField::Save(SvPersistStream& rOut)
{
rOut.WriteUInt16( eMeasureFieldKind );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -82,7 +82,7 @@ public:
}
};
class SvMetaObject : public SvRttiBase
class SvMetaObject : public SvRefBase
{
protected:
OString aName;
......
......@@ -76,7 +76,6 @@ public:
virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
const SvxFieldData* GetField() const { return mxField.get(); }
static SvClassManager& GetClassManager();
};
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#ifndef INCLUDED_SVX_SVDFIELD_HXX
#define INCLUDED_SVX_SVDFIELD_HXX
#include <svx/svxdllapi.h>
void SVX_DLLPUBLIC SdrRegisterFieldClasses();
#endif // INCLUDED_SVX_SVDFIELD_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -26,147 +26,18 @@
#include <map>
#include <unordered_map>
#define ERRCODE_IO_NOFACTORY ERRCODE_IO_WRONGFORMAT
class SvPersistBase;
typedef void * (*SvCreateInstancePersist)( SvPersistBase ** );
#define SV_CLASS_REGISTER( Class ) \
Register( Class::StaticClassId(), Class::CreateInstance )
class TOOLS_DLLPUBLIC SvClassManager
{
typedef std::unordered_map<sal_Int32, SvCreateInstancePersist> Map;
Map aAssocTable;
public:
void Register( sal_Int32 nClassId, SvCreateInstancePersist pFunc );
SvCreateInstancePersist Get( sal_Int32 nClassId );
};
class TOOLS_DLLPUBLIC SvRttiBase : public SvRefBase
{
public:
};
#define SV_DECL_PERSIST1( Class, CLASS_ID ) \
static sal_Int32 StaticClassId() { return CLASS_ID; } \
static void * CreateInstance( SvPersistBase ** ppBase ); \
friend SvPersistStream& operator >> ( SvPersistStream & rStm, \
Class *& rpObj); \
virtual sal_Int32 GetClassId() const override; \
virtual void Load( SvPersistStream & ) override; \
virtual void Save( SvPersistStream & ) override;
#define SV_IMPL_PERSIST1( Class, Super1 ) \
void * Class::CreateInstance( SvPersistBase ** ppBase )\
{ \
Class * p = new Class(); \
*ppBase = p; \
return p; \
} \
sal_Int32 Class::GetClassId() const \
#define SV_IMPL_PERSIST1( Class ) \
sal_Int32 Class::GetClassId() const \
{ return StaticClassId(); } \
SvPersistStream& operator >> (SvPersistStream & rStm, Class *& rpObj)\
{ \
SvPersistBase * pObj; \
rStm >> pObj; \
rpObj = dynamic_cast< Class*>( pObj ); \
return rStm; \
}
class SvPersistStream;
class SvPersistBase : public SvRttiBase
class SvPersistBase : public SvRefBase
{
public:
virtual sal_Int32 GetClassId() const = 0;
virtual void Load( SvPersistStream & ) = 0;
virtual void Save( SvPersistStream & ) = 0;
TOOLS_DLLPUBLIC friend SvPersistStream& operator >> ( SvPersistStream & rStm,
SvPersistBase *& rpObj );
};
class SvStream;
/** Persistent Stream
This class provides accessor to storing and loading runtime objects.
All dependent objects have to be stored as well.
In order to load objects automatically, every object class must
provide a Factory method to read an object from stream.
The list of all classes is stored in a <SvClassManager> object
and is sent to SvPersistStream upon initialization.
By using the Method SvPersistStream::WriteCompressed and
SvPersistStream::ReadCompressed, compressed sal_uInt32 values may be
written to / read from the Stream.
Several helper methods exists for writing and reading
object lengths to the stream: SvPersistStream::WriteDummyLen,
SvPersistStream::WriteLen and SvPersistStream::ReadLen.
[Example]
One example is described in the constructor.
Assume a ring-like dependency, where A references B,
B itself references C, and C references to both D and A.
The order of the objects upon saving and loading does not matter,
as long objects are loaded in the same order they were stored.
Saving: Loading:
A,B,C,D A,B,C,D correct
B,A,C,D B,A,C,D correct
C,A,B,D A,B,C,D wrong
A,B,C,D A,B,C wrong
@note The file formats DBG_UTIL and !DBG_UTIL differ, but we can read from
both versions.
*/
class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
{
public:
typedef UniqueIndex<SvPersistBase>::Index Index;
private:
typedef std::map<SvPersistBase*, Index> PersistBaseMap;
SvClassManager & rClassMgr;
SvStream * pStm;
PersistBaseMap aPTable; // reversed pointer and key
UniqueIndex<SvPersistBase>
aPUIdx;
Index nStartIdx;
virtual std::size_t GetData(void* pData, std::size_t nSize) override;
virtual std::size_t PutData(const void* pData, std::size_t nSize) override;
virtual sal_uInt64 SeekPos(sal_uInt64 nPos) override;
virtual void FlushData() override;
protected:
void WriteObj( sal_uInt8 nHdr, SvPersistBase * pObj );
void ReadObj( SvPersistBase * & rpObj );
public:
virtual void ResetError() override;
SvPersistStream( SvClassManager &, SvStream * pStream );
virtual ~SvPersistStream() override;
SvPersistBase * GetObject( Index nIdx ) const;
Index GetIndex( SvPersistBase * ) const;
static void WriteCompressed( SvStream & rStm, sal_uInt32 nVal );
static sal_uInt32 ReadCompressed( SvStream & rStm );
sal_uInt32 WriteDummyLen();
void WriteLen( sal_uInt32 nLenPos );
sal_uInt32 ReadLen( sal_uInt32 * pTestPos );
SvPersistStream& WritePointer( SvPersistBase * pObj );
SvPersistStream& ReadPointer( SvPersistBase * & rpObj );
TOOLS_DLLPUBLIC friend SvPersistStream& WriteSvPersistBase(SvPersistStream &, SvPersistBase *);
TOOLS_DLLPUBLIC friend SvPersistStream& operator >> (SvPersistStream &, SvPersistBase * &);
};
#endif
......
......@@ -100,7 +100,6 @@
#include <svx/imapdlg.hxx>
#include "editutil.hxx"
#include <svx/svdfield.hxx>
#include "dwfunctr.hxx"
#include "acredlin.hxx"
......@@ -262,14 +261,6 @@ void ScDLL::Init()
sc::SearchResultsDlgWrapper::RegisterChildWindow(false, pMod);
ScCondFormatDlgWrapper::RegisterChildWindow(false, pMod);
// EditEngine Field; insofar not already defined in OfficeApplication::Init
SvClassManager& rClassManager = SvxFieldItem::GetClassManager();
rClassManager.Register(SvxPagesField::StaticClassId(), SvxPagesField::CreateInstance);
rClassManager.Register(SvxFileField::StaticClassId(), SvxFileField::CreateInstance);
rClassManager.Register(SvxTableField::StaticClassId(), SvxTableField::CreateInstance);
SdrRegisterFieldClasses(); // Register SvDraw fields
// Add 3DObject Factory
E3dObjFactory();
......
......@@ -25,7 +25,6 @@
#include <unotools/configmgr.hxx>
#include <unotools/moduleoptions.hxx>
#include <svx/fmobjfac.hxx>
#include <svx/svdfield.hxx>
#include <svx/objfac3d.hxx>
#include <vcl/svapp.hxx>
......@@ -277,9 +276,6 @@ void SdDLL::Init()
// register your controllers here
RegisterControllers(pModule);
// register SvDraw-Fields
SdrRegisterFieldClasses();
// register 3D-object-factory
E3dObjFactory();
......
......@@ -18,27 +18,8 @@
*/
#include <editeng/eeitem.hxx>
#include <editeng/measfld.hxx>
#include <svx/svdotext.hxx>
#include <svx/svdfield.hxx>
static bool bInit = false;
// Do not remove this, it is still used in src536a!
void SdrRegisterFieldClasses()
{
if ( !bInit )
{
SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SdrMeasureField);
SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SvxHeaderField);
SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SvxFooterField);
SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SvxDateTimeField);
bInit = true;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////// */
bool SdrTextObj::CalcFieldValue(const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_uInt16 /*nPos*/,
bool /*bEdit*/, Color*& /*rpTxtColor*/, Color*& /*rpFldColor*/, OUString& /*rRet*/) const
......
......@@ -40,7 +40,6 @@
#include <comphelper/processfactory.hxx>
#include <svx/fmobjfac.hxx>
#include <svx/svdfield.hxx>
#include <svx/objfac3d.hxx>
#include <editeng/acorrcfg.hxx>
......@@ -110,9 +109,6 @@ SwDLL::SwDLL()
pDocFact->SetDocumentServiceName("com.sun.star.text.TextDocument");
}
// register SvDraw-Fields
SdrRegisterFieldClasses();
// register 3D-object-Factory
E3dObjFactory();
......
......@@ -70,7 +70,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/misc/cpuid \
tools/source/misc/extendapplicationenvironment \
tools/source/ref/globname \
tools/source/ref/pstm \
tools/source/ref/ref \
tools/source/stream/stream \
tools/source/stream/vcompat \
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment