diff options
Diffstat (limited to 'include/sot')
-rw-r--r-- | include/sot/exchange.hxx | 152 | ||||
-rw-r--r-- | include/sot/filelist.hxx | 49 | ||||
-rw-r--r-- | include/sot/formats.hxx | 193 | ||||
-rw-r--r-- | include/sot/object.hxx | 53 | ||||
-rw-r--r-- | include/sot/sotdllapi.h | 34 | ||||
-rw-r--r-- | include/sot/stg.hxx | 317 | ||||
-rw-r--r-- | include/sot/storage.hxx | 172 | ||||
-rw-r--r-- | include/sot/storinfo.hxx | 63 |
8 files changed, 1033 insertions, 0 deletions
diff --git a/include/sot/exchange.hxx b/include/sot/exchange.hxx new file mode 100644 index 0000000000..f778d86a97 --- /dev/null +++ b/include/sot/exchange.hxx @@ -0,0 +1,152 @@ +/* -*- 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_SOT_EXCHANGE_HXX +#define INCLUDED_SOT_EXCHANGE_HXX + +#include <vector> +#include <com/sun/star/datatransfer/DataFlavor.hpp> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> +#include <sot/sotdllapi.h> +#include <sot/formats.hxx> +#include <o3tl/typed_flags_set.hxx> + +namespace com::sun::star::datatransfer { + class XTransferable; +} + +namespace com::sun::star::uno { template <typename > class Reference; } + +struct DataFlavorEx : public css::datatransfer::DataFlavor +{ + SotClipboardFormatId mnSotId; +}; + +typedef ::std::vector<DataFlavorEx> DataFlavorExVector; + + +SOT_DLLPUBLIC bool IsFormatSupported( const DataFlavorExVector& rDataFlavorExVector, + SotClipboardFormatId nId ); + +// actions +#define EXCHG_INOUT_ACTION_NONE (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_NONE)) +#define EXCHG_IN_ACTION_DEFAULT EXCHG_INOUT_ACTION_NONE +#define EXCHG_IN_ACTION_MOVE (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_MOVE)) +#define EXCHG_IN_ACTION_COPY (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_COPY)) +#define EXCHG_IN_ACTION_LINK (sal_uInt8(css::datatransfer::dnd::DNDConstants::ACTION_LINK)) +#define EXCHG_OUT_ACTION_INSERT_FILE (sal_uInt8(20)) +#define EXCHG_OUT_ACTION_INSERT_IMAGEMAP (sal_uInt8(22)) +#define EXCHG_OUT_ACTION_INSERT_OLE (sal_uInt8(23)) +#define EXCHG_OUT_ACTION_INSERT_INTERACTIVE (sal_uInt8(24)) +#define EXCHG_OUT_ACTION_REPLACE_IMAGEMAP (sal_uInt8(29)) +#define EXCHG_OUT_ACTION_GET_ATTRIBUTES (sal_uInt8(30)) +#define EXCHG_OUT_ACTION_INSERT_PRIVATE (sal_uInt8(35)) +#define EXCHG_OUT_ACTION_INSERT_HTML (sal_uInt8(36)) +#define EXCHG_OUT_ACTION_MOVE_PRIVATE (sal_uInt8(37)) +#define EXCHG_OUT_ACTION_INSERT_STRING (sal_uInt8(38)) +#define EXCHG_OUT_ACTION_INSERT_DRAWOBJ (sal_uInt8(39)) +#define EXCHG_OUT_ACTION_INSERT_SVXB (sal_uInt8(40)) +#define EXCHG_OUT_ACTION_INSERT_GDIMETAFILE (sal_uInt8(41)) +#define EXCHG_OUT_ACTION_INSERT_BITMAP (sal_uInt8(42)) +#define EXCHG_OUT_ACTION_INSERT_DDE (sal_uInt8(43)) +#define EXCHG_OUT_ACTION_INSERT_HYPERLINK (sal_uInt8(44)) +#define EXCHG_OUT_ACTION_REPLACE_DRAWOBJ (sal_uInt8(45)) +#define EXCHG_OUT_ACTION_REPLACE_SVXB (sal_uInt8(46)) +#define EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE (sal_uInt8(47)) +#define EXCHG_OUT_ACTION_REPLACE_BITMAP (sal_uInt8(48)) +#define EXCHG_OUT_ACTION_REPLACE_GRAPH (sal_uInt8(49)) +#define EXCHG_OUT_ACTION_INSERT_GRAPH (sal_uInt8(50)) + +enum class SotExchangeActionFlags { + NONE = 0x0000, + InsertImageMap = 0x0400, + ReplaceImageMap = 0x0800, + InsertTargetUrl = 0x2000, +}; +namespace o3tl { + template<> struct typed_flags<SotExchangeActionFlags> : is_typed_flags<SotExchangeActionFlags, 0x2c00> {}; +} + +// destinations +enum class SotExchangeDest +{ + NONE = 0, + DOC_OLEOBJ = 1, + CHARTDOC_OLEOBJ = 2, + DOC_TEXTFRAME = 3, + DOC_GRAPHOBJ = 4, + DOC_LNKD_GRAPHOBJ = 5, + DOC_GRAPH_W_IMAP = 6, + DOC_LNKD_GRAPH_W_IMAP = 7, + DOC_IMAPREGION = 8, + DOC_DRAWOBJ = 9, + DOC_URLBUTTON = 10, + DOC_URLFIELD = 11, + DOC_GROUPOBJ = 12, + SWDOC_FREE_AREA = 13, + SCDOC_FREE_AREA = 14, + SDDOC_FREE_AREA = 15, + DOC_TEXTFRAME_WEB = 16, + SWDOC_FREE_AREA_WEB = 17, +}; + +class SvGlobalName; + +class SOT_DLLPUBLIC SotExchange +{ +public: + static SotClipboardFormatId RegisterFormat( const css::datatransfer::DataFlavor& rFlavor ); + static SotClipboardFormatId RegisterFormatName( const OUString& rName ); + static SotClipboardFormatId RegisterFormatMimeType( const OUString& rMimeType ); + + static SotClipboardFormatId GetFormat( const css::datatransfer::DataFlavor& rFlavor ); + static OUString GetFormatName( SotClipboardFormatId nFormat ); + static bool GetFormatDataFlavor( SotClipboardFormatId nFormat, css::datatransfer::DataFlavor& rFlavor ); + static OUString GetFormatMimeType( SotClipboardFormatId nFormat ); + static bool IsInternal( const SvGlobalName& ); + static SotClipboardFormatId GetFormatIdFromMimeType( std::u16string_view rMimeType ); + + // same for XTransferable interface + static sal_uInt8 GetExchangeAction( + // XTransferable + const DataFlavorExVector& rDataFlavorExVector, + // destination of an action + SotExchangeDest nDestination, + // action for a source + sal_uInt16 nSourceOptions, + // user action (EXCHG_IN_*, EXCHG_INOUT_*) + sal_uInt8 nUserAction, + // In:- Out: format to use + SotClipboardFormatId& rFormat, + // In:- Out: default action (EXCHG_IN_*, EXCHG_INOUT_*) + sal_uInt8& rDefaultAction, + // In:- optional - check only for this specific format + SotClipboardFormatId nOnlyTestFormat = SotClipboardFormatId::NONE, + // In:- optional - check the contents of Xtransferable + const css::uno::Reference< css::datatransfer::XTransferable >* pxTransferable = nullptr, + // Out: optional: - default action flags + SotExchangeActionFlags* pActionFlags = nullptr); + + static sal_uInt16 IsChart( const SvGlobalName& rName ); + static sal_uInt16 IsMath( const SvGlobalName& rName ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sot/filelist.hxx b/include/sot/filelist.hxx new file mode 100644 index 0000000000..e95ea38cce --- /dev/null +++ b/include/sot/filelist.hxx @@ -0,0 +1,49 @@ +/* -*- 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_SOT_FILELIST_HXX +#define INCLUDED_SOT_FILELIST_HXX + +#include <sot/sotdllapi.h> +#include <rtl/ustring.hxx> + +#include <vector> + +class SvStream; + +class SOT_DLLPUBLIC FileList +{ + std::vector<OUString> aStrList; + +private: + void clear() { aStrList.clear(); } + +public: + // import / export + SOT_DLLPUBLIC friend SvStream& ReadFileList(SvStream& rIStm, FileList& rFileList); + + // fill in / interrogate list + void AppendFile(const OUString& rStr); + OUString GetFile(size_t nIndex) const; + size_t Count() const; +}; + +#endif // INCLUDED_SOT_FILELIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sot/formats.hxx b/include/sot/formats.hxx new file mode 100644 index 0000000000..12727ffb34 --- /dev/null +++ b/include/sot/formats.hxx @@ -0,0 +1,193 @@ +/* -*- 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_SOT_FORMATS_HXX +#define INCLUDED_SOT_FORMATS_HXX + +#include <sal/types.h> + +// - predefined formats - +// Do NOT change the order of these values as the implementation depends on them! +enum class SotClipboardFormatId : sal_uInt32 +{ +// standard formats for that Copy/Paste methods exist + STRING = 1, + BITMAP = 2, + GDIMETAFILE = 3, + PRIVATE = 4, + SIMPLE_FILE = 5, + FILE_LIST = 6, +// further formats (only via CopyData/PasteData) + RTF = 10, + + NONE = 0, + ONLY_USED_IN_SW = 8, // the SW module essentially creates its own ID's and this is one of them + DRAWING = 11, + SVXB = 12, + SVIM = 13, + XFA = 14, + EDITENGINE_ODF_TEXT_FLAT = 15, + INTERNALLINK_STATE = 16, + SOLK = 17, + NETSCAPE_BOOKMARK = 18, + TREELISTBOX = 19, + NATIVE = 20, + OWNERLINK = 21, + STARSERVER = 22, + STAROBJECT = 23, + APPLETOBJECT = 24, + PLUGIN_OBJECT = 25, + STARWRITER_30 = 26, + STARWRITER_40 = 27, + STARWRITER_50 = 28, + STARWRITERWEB_40 = 29, + STARWRITERWEB_50 = 30, + STARWRITERGLOB_40 = 31, + STARWRITERGLOB_50 = 32, + STARDRAW = 33, + STARDRAW_40 = 34, + STARIMPRESS_50 = 35, + STARDRAW_50 = 36, + STARCALC = 37, + STARCALC_40 = 38, + STARCALC_50 = 39, + STARCHART = 40, + STARCHART_40 = 41, + STARCHART_50 = 42, + STARIMAGE = 43, + STARIMAGE_40 = 44, + STARIMAGE_50 = 45, + STARMATH = 46, + STARMATH_40 = 47, + STARMATH_50 = 48, + STAROBJECT_PAINTDOC = 49, + FILLED_AREA = 50, + HTML = 51, + HTML_SIMPLE = 52, + CHAOS = 53, + CNT_MSGATTACHFILE = 54, + BIFF_5 = 55, + BIFF__5 = 56, + SYLK = 57, + SYLK_BIGCAPS = 58, + LINK = 59, + DIF = 60, + STARDRAW_TABBAR = 61, + SONLK = 62, + MSWORD_DOC = 63, + STAR_FRAMESET_DOC = 64, + OFFICE_DOC = 65, + NOTES_DOCINFO = 66, + NOTES_HNOTE = 67, + NOTES_NATIVE = 68, + SFX_DOC = 69, + EVDF = 70, + ESDF = 71, + IDF = 72, + EFTP = 73, + EFD = 74, + SVX_FORMFIELDEXCH = 75, + EXTENDED_TABBAR = 76, + SBA_DATAEXCHANGE = 77, + SBA_FIELDDATAEXCHANGE = 78, + SBA_PRIVATE_URL = 79, + SBA_TABED = 80, + SBA_TABID = 81, + SBA_JOIN = 82, + OBJECTDESCRIPTOR = 83, + LINKSRCDESCRIPTOR = 84, + EMBED_SOURCE = 85, + LINK_SOURCE = 86, + EMBEDDED_OBJ = 87, + FILECONTENT = 88, + FILEGRPDESCRIPTOR = 89, + FILENAME = 90, + SD_OLE = 91, + EMBEDDED_OBJ_OLE = 92, + EMBED_SOURCE_OLE = 93, + OBJECTDESCRIPTOR_OLE = 94, + LINKSRCDESCRIPTOR_OLE = 95, + LINK_SOURCE_OLE = 96, + SBA_CTRLDATAEXCHANGE = 97, + OUTPLACE_OBJ = 98, + CNT_OWN_CLIP = 99, + INET_IMAGE = 100, + NETSCAPE_IMAGE = 101, + SBA_FORMEXCHANGE = 102, + SBA_REPORTEXCHANGE = 103, + UNIFORMRESOURCELOCATOR = 104, + STARCHARTDOCUMENT_50 = 105, + GRAPHOBJ = 106, + STARWRITER_60 = 107, + STARWRITERWEB_60 = 108, + STARWRITERGLOB_60 = 109, + STARDRAW_60 = 110, + STARIMPRESS_60 = 111, + STARCALC_60 = 112, + STARCHART_60 = 113, + STARMATH_60 = 114, + WMF = 115, + DBACCESS_QUERY = 116, + DBACCESS_TABLE = 117, + DBACCESS_COMMAND = 118, + DIALOG_60 = 119, + EMF = 120, + BIFF_8 = 121, + BMP = 122, + HTML_NO_COMMENT = 123, + STARWRITER_8 = 124, + STARWRITERWEB_8 = 125, + STARWRITERGLOB_8 = 126, + STARDRAW_8 = 127, + STARIMPRESS_8 = 128, + STARCALC_8 = 129, + STARCHART_8 = 130, + STARMATH_8 = 131, + XFORMS = 132, + STARWRITER_8_TEMPLATE = 133, + STARDRAW_8_TEMPLATE = 134, + STARIMPRESS_8_TEMPLATE = 135, + STARCALC_8_TEMPLATE = 136, + STARCHART_8_TEMPLATE = 137, + STARMATH_8_TEMPLATE = 138, + STARBASE_8 = 139, + HC_GDIMETAFILE = 140, + PNG = 141, + STARWRITERGLOB_8_TEMPLATE = 142, + MATHML = 143, + JPEG = 144, + RICHTEXT = 145, + STRING_TSVC = 146, + PDF = 147, + // the point at which we start allocating "runtime" format IDs + USER_END = PDF +}; + +/** Make it easier to iterate over format IDs */ +inline SotClipboardFormatId& operator++(SotClipboardFormatId& eFormat) +{ + eFormat = static_cast<SotClipboardFormatId>(static_cast<sal_uInt32>(eFormat) + 1); + return eFormat; +} + +#define SOT_FORMAT_SYSTEM_START SotClipboardFormatId::NONE + +#endif // INCLUDED_SOT_FORMATS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sot/object.hxx b/include/sot/object.hxx new file mode 100644 index 0000000000..1657986c84 --- /dev/null +++ b/include/sot/object.hxx @@ -0,0 +1,53 @@ +/* -*- 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_SOT_OBJECT_HXX +#define INCLUDED_SOT_OBJECT_HXX + +#include <sal/config.h> + +#include <tools/ref.hxx> +#include <sot/sotdllapi.h> + +class SOT_DLLPUBLIC SotObject : virtual public SvRefBase +{ + sal_uInt16 nOwnerLockCount; + bool bInClose; // TRUE, in DoClose + +protected: + virtual ~SotObject() override; + virtual bool Close(); + +public: + SotObject(); + + sal_uInt16 GetOwnerLockCount() const { return nOwnerLockCount; } + + void OwnerLock(bool bLock); + bool DoClose(); + bool IsInClose() const { return bInClose; } + +private: + SotObject& operator=(const SotObject&) = delete; + SotObject(const SotObject&) = delete; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sot/sotdllapi.h b/include/sot/sotdllapi.h new file mode 100644 index 0000000000..c01d6ed3a1 --- /dev/null +++ b/include/sot/sotdllapi.h @@ -0,0 +1,34 @@ +/* -*- 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_SOT_SOTDLLAPI_H +#define INCLUDED_SOT_SOTDLLAPI_H + +#include <sal/types.h> + +#if defined(SOT_DLLIMPLEMENTATION) +#define SOT_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SOT_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define SOT_DLLPRIVATE SAL_DLLPRIVATE + +#endif // INCLUDED_SOT_SOTDLLAPI_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sot/stg.hxx b/include/sot/stg.hxx new file mode 100644 index 0000000000..72003f08fd --- /dev/null +++ b/include/sot/stg.hxx @@ -0,0 +1,317 @@ +/* -*- 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_SOT_STG_HXX +#define INCLUDED_SOT_STG_HXX + +#include <tools/stream.hxx> +#include <tools/globname.hxx> +#include <sot/storinfo.hxx> +#include <sot/sotdllapi.h> +#include <config_options.h> + +namespace com::sun::star::ucb { class XProgressHandler; } +namespace com::sun::star::uno { class Any; } +namespace com::sun::star::uno { template <typename > class Reference; } + +class StgIo; +class StgDirEntry; +typedef struct SvGUID ClsId; + +class StorageBase : public SvRefBase +{ +protected: + mutable ErrCode m_nError; // error code + StreamMode m_nMode; // open mode + bool m_bAutoCommit; + StorageBase(); + virtual ~StorageBase() override; +public: + virtual bool Validate( bool=false ) const = 0; + virtual bool ValidateMode( StreamMode ) const = 0; + void ResetError() const; + void SetError( ErrCode ) const; + ErrCode GetError() const; + bool Good() const { return m_nError == ERRCODE_NONE; } + StreamMode GetMode() const { return m_nMode; } + void SetAutoCommit( bool bSet ) + { m_bAutoCommit = bSet; } +}; + +class BaseStorageStream : public StorageBase +{ +public: + virtual sal_Int32 Read( void * pData, sal_Int32 nSize ) = 0; + virtual sal_Int32 Write( const void* pData, sal_Int32 nSize ) = 0; + virtual sal_uInt64 Seek( sal_uInt64 nPos ) = 0; + virtual sal_uInt64 Tell() = 0; + virtual void Flush() = 0; + virtual bool SetSize( sal_uInt64 nNewSize ) = 0; + virtual sal_uInt64 GetSize() const = 0; + virtual void CopyTo( BaseStorageStream * pDestStm ) = 0; + virtual bool Commit() = 0; + virtual bool Equals( const BaseStorageStream& rStream ) const = 0; +}; + +enum class SotClipboardFormatId : sal_uInt32; + +class SAL_DLLPUBLIC_RTTI BaseStorage : public StorageBase +{ +public: + virtual const OUString& GetName() const = 0; + virtual bool IsRoot() const = 0; + virtual void SetClassId( const ClsId& ) = 0; + virtual const ClsId& GetClassId() const = 0; + virtual void SetDirty() = 0; + virtual void SetClass( const SvGlobalName & rClass, + SotClipboardFormatId nOriginalClipFormat, + const OUString & rUserTypeName ) = 0; + virtual SvGlobalName GetClassName() = 0; + virtual SotClipboardFormatId GetFormat() = 0; + virtual OUString GetUserName() = 0; + virtual void FillInfoList( SvStorageInfoList* ) const = 0; + virtual bool CopyTo( BaseStorage* pDestStg ) const = 0; + virtual bool Commit() = 0; + virtual bool Revert() = 0; + virtual BaseStorageStream* OpenStream( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = true ) = 0; + virtual BaseStorage* OpenStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) = 0; + virtual BaseStorage* OpenUCBStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) = 0; + virtual BaseStorage* OpenOLEStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) = 0; + virtual bool IsStream( const OUString& rEleName ) const = 0; + virtual bool IsStorage( const OUString& rEleName ) const = 0; + virtual bool IsContained( const OUString& rEleName ) const = 0; + virtual void Remove( const OUString & rEleName ) = 0; + virtual bool CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) = 0; + virtual bool ValidateFAT() = 0; + virtual bool Equals( const BaseStorage& rStream ) const = 0; +}; + +class OLEStorageBase +{ +protected: + StreamMode& nStreamMode; // open mode + StgIo* pIo; // I/O subsystem + StgDirEntry* pEntry; // the dir entry + OLEStorageBase( StgIo*, StgDirEntry*, StreamMode& ); + ~OLEStorageBase(); + bool Validate_Impl( bool ) const; + static bool ValidateMode_Impl( StreamMode, StgDirEntry const * p = nullptr ); +}; + +class StorageStream final : public BaseStorageStream, public OLEStorageBase +{ +//friend class Storage; + sal_uInt64 nPos; // current position + + virtual ~StorageStream() override; +public: + StorageStream( StgIo*, StgDirEntry*, StreamMode ); + virtual sal_Int32 Read( void * pData, sal_Int32 nSize ) override; + virtual sal_Int32 Write( const void* pData, sal_Int32 nSize ) override; + virtual sal_uInt64 Seek( sal_uInt64 nPos ) override; + virtual sal_uInt64 Tell() override { return nPos; } + virtual void Flush() override; + virtual bool SetSize( sal_uInt64 nNewSize ) override; + virtual sal_uInt64 GetSize() const override; + virtual void CopyTo( BaseStorageStream * pDestStm ) override; + virtual bool Commit() final override; + virtual bool Validate( bool=false ) const override; + virtual bool ValidateMode( StreamMode ) const override; + virtual bool Equals( const BaseStorageStream& rStream ) const override; +}; + +class UCBStorageStream; + +class UNLESS_MERGELIBS(SOT_DLLPUBLIC) Storage final : public BaseStorage, public OLEStorageBase +{ + OUString aName; + bool bIsRoot; + void Init( bool bCreate ); + Storage( StgIo*, StgDirEntry*, StreamMode ); + virtual ~Storage() override; +public: + Storage( OUString, StreamMode, bool bDirect ); + Storage( SvStream& rStrm, bool bDirect ); + Storage( UCBStorageStream& rStrm, bool bDirect ); + + static bool IsStorageFile( const OUString & rFileName ); + static bool IsStorageFile( SvStream* ); + + virtual const OUString& GetName() const final override; + virtual bool IsRoot() const override { return bIsRoot; } + virtual void SetClassId( const ClsId& ) override; + virtual const ClsId& GetClassId() const override; + virtual void SetDirty() override; + virtual void SetClass( const SvGlobalName & rClass, + SotClipboardFormatId nOriginalClipFormat, + const OUString & rUserTypeName ) override; + virtual SvGlobalName GetClassName() override; + virtual SotClipboardFormatId GetFormat() override; + virtual OUString GetUserName() override; + virtual void FillInfoList( SvStorageInfoList* ) const override; + virtual bool CopyTo( BaseStorage* pDestStg ) const override; + virtual bool Commit() final override; + virtual bool Revert() override; + virtual BaseStorageStream* OpenStream( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = true ) override; + virtual BaseStorage* OpenStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) override; + virtual BaseStorage* OpenUCBStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) override; + virtual BaseStorage* OpenOLEStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) override; + virtual bool IsStream( const OUString& rEleName ) const override; + virtual bool IsStorage( const OUString& rEleName ) const override; + virtual bool IsContained( const OUString& rEleName ) const override; + virtual void Remove( const OUString & rEleName ) override; + virtual bool CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) override; + virtual bool ValidateFAT() override; + virtual bool Validate( bool=false ) const override; + virtual bool ValidateMode( StreamMode ) const override; + bool ValidateMode( StreamMode, StgDirEntry const * p ) const; + virtual bool Equals( const BaseStorage& rStream ) const override; +}; + +class UCBStorageStream_Impl; +class UCBStorageStream final : public BaseStorageStream +{ +friend class UCBStorage; + + UCBStorageStream_Impl* + pImp; + virtual ~UCBStorageStream() override; +public: + UCBStorageStream( const OUString& rName, StreamMode nMode, bool bDirect, bool bRepair, css::uno::Reference< css::ucb::XProgressHandler > const & xProgress ); + UCBStorageStream( UCBStorageStream_Impl* ); + + virtual sal_Int32 Read( void * pData, sal_Int32 nSize ) override; + virtual sal_Int32 Write( const void* pData, sal_Int32 nSize ) override; + virtual sal_uInt64 Seek( sal_uInt64 nPos ) override; + virtual sal_uInt64 Tell() override; + virtual void Flush() override; + virtual bool SetSize( sal_uInt64 nNewSize ) override; + virtual sal_uInt64 GetSize() const override; + virtual void CopyTo( BaseStorageStream * pDestStm ) override; + virtual bool Commit() override; + virtual bool Validate( bool=false ) const override; + virtual bool ValidateMode( StreamMode ) const override; + virtual bool Equals( const BaseStorageStream& rStream ) const override; + bool SetProperty( const OUString& rName, const css::uno::Any& rValue ); + + SvStream* GetModifySvStream(); +}; + +namespace ucbhelper +{ + class Content; +} + +class UCBStorage_Impl; +struct UCBStorageElement_Impl; +class SOT_DLLPUBLIC UCBStorage final : public BaseStorage +{ + UCBStorage_Impl* pImp; + + virtual ~UCBStorage() override; +public: + static bool IsStorageFile( SvStream* ); + + UCBStorage( const ::ucbhelper::Content& rContent, + const OUString& rName, + StreamMode nMode, + bool bDirect, + bool bIsRoot ); + + UCBStorage( const OUString& rName, + StreamMode nMode, + bool bDirect, + bool bIsRoot ); + + UCBStorage( const OUString& rName, + StreamMode nMode, + bool bDirect, + bool bIsRoot, + bool bIsRepair, + css::uno::Reference< css::ucb::XProgressHandler > const & + xProgressHandler ); + + UCBStorage( UCBStorage_Impl* ); + + UCBStorage( SvStream& rStrm, bool bDirect ); + + virtual const OUString& GetName() const override; + virtual bool IsRoot() const override; + virtual void SetClassId( const ClsId& ) override; + virtual const ClsId& GetClassId() const override; + virtual void SetDirty() override; + virtual void SetClass( const SvGlobalName & rClass, + SotClipboardFormatId nOriginalClipFormat, + const OUString & rUserTypeName ) override; + virtual SvGlobalName GetClassName() override; + virtual SotClipboardFormatId GetFormat() override; + virtual OUString GetUserName() override; + virtual void FillInfoList( SvStorageInfoList* ) const override; + virtual bool CopyTo( BaseStorage* pDestStg ) const override; + virtual bool Commit() final override; + virtual bool Revert() override; + virtual BaseStorageStream* OpenStream( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = true ) override; + virtual BaseStorage* OpenStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) override; + virtual BaseStorage* OpenUCBStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) override; + virtual BaseStorage* OpenOLEStorage( const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool bDirect = false ) override; + virtual bool IsStream( const OUString& rEleName ) const override; + virtual bool IsStorage( const OUString& rEleName ) const override; + virtual bool IsContained( const OUString& rEleName ) const override; + virtual void Remove( const OUString & rEleName ) override; + virtual bool CopyTo( const OUString & rEleName, BaseStorage * pDest, const OUString & rNewName ) override; + virtual bool ValidateFAT() override; + virtual bool Validate( bool=false ) const override; + virtual bool ValidateMode( StreamMode ) const override; + virtual bool Equals( const BaseStorage& rStream ) const override; + + UCBStorageElement_Impl* FindElement_Impl( std::u16string_view rName ) const; + bool CopyStorageElement_Impl( UCBStorageElement_Impl const & rElement, + BaseStorage* pDest, const OUString& rNew ) const; + BaseStorage* OpenStorage_Impl( const OUString & rEleName, + StreamMode, bool bDirect, bool bForceUCBStorage ); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sot/storage.hxx b/include/sot/storage.hxx new file mode 100644 index 0000000000..ac11340ac2 --- /dev/null +++ b/include/sot/storage.hxx @@ -0,0 +1,172 @@ +/* -*- 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_SOT_STORAGE_HXX +#define INCLUDED_SOT_STORAGE_HXX + +#include <sot/object.hxx> +#include <tools/stream.hxx> +#include <tools/globname.hxx> +#include <comphelper/errcode.hxx> +#include <sot/storinfo.hxx> +#include <sot/sotdllapi.h> + +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::uno { class Any; } +namespace com::sun::star::uno { template <typename > class Reference; } + +enum class SotClipboardFormatId : sal_uInt32; + +class BaseStorageStream; + +class SOT_DLLPUBLIC SotTempStream final : virtual public SvRefBase, public SvStream +{ +friend class SotStorage; + + virtual ~SotTempStream() override; +public: + SotTempStream(OUString const & rString, StreamMode = StreamMode::STD_READWRITE); + + void CopyTo(SotTempStream * pDestStm); +}; + +class SOT_DLLPUBLIC SotStorageStream final : virtual public SotObject, public SvStream +{ +friend class SotStorage; + BaseStorageStream * pOwnStm; // pointer to the own stream + + 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; + + virtual ~SotStorageStream() override; +public: + SotStorageStream(BaseStorageStream *pBaseStream); + + virtual void ResetError() override; + + virtual void SetSize(sal_uInt64 nNewSize) override; + sal_uInt32 GetSize() const; + void Commit(); + bool SetProperty(OUString const & rName, css::uno::Any const & rValue); + virtual sal_uInt64 TellEnd() override; +}; + +class BaseStorage; +class SOT_DLLPUBLIC SotStorage final : virtual public SotObject +{ +friend class SotStorageStream; + + BaseStorage* m_pOwnStg; // target storage + SvStream* m_pStorStm; // only for SDSTORAGES + ErrCode m_nError; + OUString m_aName;// name of the storage + bool m_bIsRoot; // e.g.: File Storage + bool m_bDelStm; + OString m_aKey; // aKey.Len != 0 -> encryption + sal_Int32 m_nVersion; + + virtual ~SotStorage() override; + void CreateStorage(bool bUCBStorage, StreamMode); +public: + SotStorage(OUString const & rString, StreamMode eMode = StreamMode::STD_READWRITE); + SotStorage(bool bUCBStorage, const OUString & rString, + StreamMode = StreamMode::STD_READWRITE); + SotStorage(BaseStorage * pStorage); + SotStorage(SvStream & rStream); + SotStorage(bool bUCBStorage, SvStream & rStream); + SotStorage(SvStream * rStream, bool bDelete); + + std::unique_ptr<SvMemoryStream> CreateMemoryStream(); + + static bool IsStorageFile(OUString const & rFileName); + static bool IsStorageFile(SvStream* pStream); + + const OUString& GetName() const; + + bool Validate(); + + const OString& GetKey() const { return m_aKey;} + + void SetVersion(sal_Int32 nVersion) + { + m_nVersion = nVersion; + } + sal_Int32 GetVersion() const + { + return m_nVersion; + } + + ErrCode GetError() const + { + return m_nError.IgnoreWarning(); + } + void SetError(ErrCode nErrorCode) + { + if (m_nError == ERRCODE_NONE) + m_nError = nErrorCode; + } + + void SignAsRoot(bool bRoot) { m_bIsRoot = bRoot; } + + // own data sector + void SetClass(const SvGlobalName & rClass, + SotClipboardFormatId bOriginalClipFormat, + const OUString & rUserTypeName); + + SvGlobalName GetClassName(); // type of data in the storage + SotClipboardFormatId GetFormat(); + OUString GetUserName(); + + // list of all elements + void FillInfoList(SvStorageInfoList *) const; + bool CopyTo(SotStorage * pDestStg); + bool Commit(); + + // create stream with connection to Storage, + // more or less a Parent-Child relationship + tools::SvRef<SotStorageStream> OpenSotStream(const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE); + SotStorage* OpenSotStorage(const OUString & rEleName, + StreamMode = StreamMode::STD_READWRITE, + bool transacted = true); + + // query whether Storage or Stream + bool IsStream( const OUString & rEleName ) const; + bool IsStorage( const OUString & rEleName ) const; + bool IsContained( const OUString & rEleName ) const; + // remove element + bool Remove(const OUString & rEleName); + bool CopyTo(const OUString & rEleName, SotStorage* pDest, + const OUString & rNewName); + + bool IsOLEStorage() const; + static bool IsOLEStorage(const OUString & rFileName); + static bool IsOLEStorage(SvStream* pStream); + + static SotStorage* OpenOLEStorage(css::uno::Reference<css::embed::XStorage> const & xStorage, + OUString const & rEleName, StreamMode = StreamMode::STD_READWRITE); + static SotClipboardFormatId GetFormatID(css::uno::Reference<css::embed::XStorage> const & xStorage); + static sal_Int32 GetVersion(css::uno::Reference<css::embed::XStorage> const & xStorage); +}; + +#endif // INCLUDED_SOT_STORAGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sot/storinfo.hxx b/include/sot/storinfo.hxx new file mode 100644 index 0000000000..c1283cffe1 --- /dev/null +++ b/include/sot/storinfo.hxx @@ -0,0 +1,63 @@ +/* -*- 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_SOT_STORINFO_HXX +#define INCLUDED_SOT_STORINFO_HXX + +#include <rtl/ustring.hxx> +#include <utility> +#include <vector> +#include <sot/sotdllapi.h> +#include <sot/formats.hxx> + +class StgDirEntry; +class SvStream; + +class SvStorageInfo +{ + friend class SotStorage; + OUString aName; + sal_uInt64 nSize; + bool bStream; + bool bStorage; + +public: + SvStorageInfo(const StgDirEntry&); + SvStorageInfo(OUString _aName, sal_uInt64 nSz, bool bIsStorage) + : aName(std::move(_aName)) + , nSize(nSz) + , bStream(!bIsStorage) + , bStorage(bIsStorage) + { + } + + const OUString& GetName() const { return aName; } + bool IsStream() const { return bStream; } + bool IsStorage() const { return bStorage; } + sal_uInt64 GetSize() const { return nSize; } +}; + +typedef std::vector<SvStorageInfo> SvStorageInfoList; + +SotClipboardFormatId ReadClipboardFormat(SvStream& rStm); +SOT_DLLPUBLIC void WriteClipboardFormat(SvStream& rStm, SotClipboardFormatId nFormat); + +#endif // _STORINFO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |