2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-29 14:02:24 +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 .
|
|
|
|
*/
|
2013-10-23 19:17:00 +02:00
|
|
|
#ifndef INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
|
|
|
|
#define INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/uno/Reference.h>
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|
|
|
#include <com/sun/star/embed/XEmbeddedObject.hpp>
|
2008-03-05 17:28:28 +00:00
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
2004-10-04 20:05:39 +00:00
|
|
|
#include <com/sun/star/embed/XStorage.hpp>
|
2008-07-11 06:30:35 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
2004-10-04 20:05:39 +00:00
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2013-11-09 13:59:36 -06:00
|
|
|
#include <comphelper/comphelperdllapi.h>
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
#include <rtl/ustring.hxx>
|
2016-06-01 01:25:41 +02:00
|
|
|
#include <memory>
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
namespace comphelper
|
|
|
|
{
|
2008-03-05 17:28:28 +00:00
|
|
|
class EmbeddedObjectContainer;
|
|
|
|
/** Helper interface to give access to some common object which replace the SfxObjectShell
|
|
|
|
*/
|
SAL_DLLPUBLIC_RTTI for proper RTTI visibility for LLVM
The Itanium C++ ABI mandates that for a unique (complete) C++ type a single
unique symbol for the type's RTTI name is used across a process's dynamic
objects (so type equivalence can be determined via pointer comparison on the
RTTI names).
GCC nowadays deviates from that, using strcmp to determine equivalence, so it is
resilient to RTTI names being bound locally within dynamic objects (which has
performance benefits, but also makes it impossible to have unrelated types that
happen to have the same name "encapsulated" in individual dynamic objects---
whether or not that would violate the ODR would be open to interpretation of how
dynamic objects fit into the C++ Standard).
LLVM sticks to the Itanium ABI, which becomes notable in at least two places:
For one, libc++abi's __dynamic_cast uses strict checking. It still has a
_LIBCXX_DYNAMIC_FALLBACK for now that additionally uses strcmp checking and
syslogs visibility violations. Mac OS X uses libc++abi with
_LIBCXX_DYNAMIC_FALLBACK enabled, and running LO routinely logs dynamic_cast
errors to the Console there.
For another, RTTI-based UBSan checks unconditionally only use strict checking
(cf. isDerivedFromAtOffset in lib/ubsan/ubsan_type_hash.cc). This causes false
positives from Clang -fsanitize=function and -fsanitize=vptr even on Linux not
using libc++abi.
Therefore, introduce SAL_DLLPUBLIC_RTTI to mark types for which RTTI needs to
have default visibility under the Itanium/LLVM semantics. There is
unfortunately no way to mark only the (implicitly generated) RTTI symbols for
default visibility, but at least with the cases where SAL_DLLPUBLIC_RTTI is used
for now that is no real problem---any class type marked SAL_DLLPUBLIC_RTTI only
has inline (covered by -fvisibility-inlines-hidden) or undefined pure virtual
functions. It appears that even the vtables of those classes remain hidden, at
least with Mach-O on Mac OS X. (That also means there is no need for a
SAL_DLLPRIVATE_RTTI marker analoguous to the---also superfluous in retrospect---
CPPU_GCC_DLLPRIVATE one.)
Nevertheless, the number of exported symbols of course increases when
SAL_DLLPUBLIC_RTTI is "active." For a full-blown --enable-dbgutil build on Mac
OS X,
find instdir/LibreOffice.app/Contents -name \*.dylib\* -exec nm -gU {} \; \
wc -l
increased from 125541 to 139239. For Linux, an option might be to "activate"
SAL_DLLPUBLIC_RTTI only for __clang__ plus !ENABLE_RUNTIME_OPTIMIZATIONS.
The set of types marked SAL_DLLPUBLIC_RTTI with this patch (wholesale cppumaker-
generated UNO enum, struct, and interface types; plus some IEmbeddedHelper and
IUndoManager) is chosen so that a full "make check" on Mac OS X no longer
syslogs any dynamic_cast errors to the Console.
Change-Id: I42fa6ec01c2503ec24bcd9c0518abb112afa3235
2015-01-22 09:26:38 +01:00
|
|
|
class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IEmbeddedHelper
|
2008-03-05 17:28:28 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual EmbeddedObjectContainer& getEmbeddedObjectContainer() const = 0;
|
2015-10-19 12:51:29 +02:00
|
|
|
virtual css::uno::Reference < css::embed::XStorage > getStorage() const = 0;
|
|
|
|
virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const = 0;
|
2008-03-05 17:28:28 +00:00
|
|
|
virtual bool isEnableSetModified() const = 0;
|
2015-12-14 13:41:57 +01:00
|
|
|
virtual OUString getDocumentBaseURL() const = 0;
|
2012-03-14 13:27:56 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
~IEmbeddedHelper() {}
|
2008-03-05 17:28:28 +00:00
|
|
|
};
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
struct EmbedImpl;
|
2005-02-16 14:54:42 +00:00
|
|
|
class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer
|
2004-10-04 20:05:39 +00:00
|
|
|
{
|
2016-06-01 01:25:41 +02:00
|
|
|
std::unique_ptr<EmbedImpl> pImpl;
|
2004-10-04 20:05:39 +00:00
|
|
|
|
2015-10-19 12:51:29 +02:00
|
|
|
css::uno::Reference < css::embed::XEmbeddedObject > Get_Impl( const OUString&,
|
2015-12-14 13:41:57 +01:00
|
|
|
const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy,
|
2016-07-25 13:32:04 +02:00
|
|
|
OUString const* pBaseURL);
|
2007-05-22 19:19:00 +00:00
|
|
|
|
2005-03-23 13:27:24 +00:00
|
|
|
public:
|
2004-10-04 20:05:39 +00:00
|
|
|
// add an embedded object to the container storage
|
2014-06-13 11:12:50 -04:00
|
|
|
bool StoreEmbeddedObject(
|
|
|
|
const css::uno::Reference<css::embed::XEmbeddedObject>& xObj, OUString& rName, bool bCopy,
|
|
|
|
const OUString& rSrcShellID, const OUString& rDestShellID );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// add an embedded object that has been imported from the container storage - should only be called by filters!
|
2015-10-19 12:51:29 +02:00
|
|
|
void AddEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, const OUString& );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
EmbeddedObjectContainer();
|
2015-10-19 12:51:29 +02:00
|
|
|
EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >& );
|
|
|
|
EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >&,
|
|
|
|
const css::uno::Reference < css::uno::XInterface >& );
|
2004-10-04 20:05:39 +00:00
|
|
|
~EmbeddedObjectContainer();
|
|
|
|
|
2015-10-19 12:51:29 +02:00
|
|
|
void SwitchPersistence( const css::uno::Reference < css::embed::XStorage >& );
|
|
|
|
bool CommitImageSubStorage();
|
2005-02-02 15:03:10 +00:00
|
|
|
void ReleaseImageSubStorage();
|
2004-10-04 20:05:39 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString CreateUniqueObjectName();
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// get a list of object names that have been added so far
|
2017-10-24 13:02:58 +02:00
|
|
|
css::uno::Sequence < OUString > GetObjectNames() const;
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// check for existence of objects at all
|
2017-10-24 13:02:58 +02:00
|
|
|
bool HasEmbeddedObjects() const;
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// check existence of an object - either by identity or by name
|
2014-02-16 22:51:15 +01:00
|
|
|
bool HasEmbeddedObject( const OUString& );
|
2017-10-24 13:02:58 +02:00
|
|
|
bool HasEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
|
2014-02-16 22:51:15 +01:00
|
|
|
bool HasInstantiatedEmbeddedObject( const OUString& );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// get the object name of an object - this is the persist name if the object has persistence
|
2017-10-24 13:02:58 +02:00
|
|
|
OUString GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// retrieve an embedded object by name that either has been added already or is available in the container storage
|
2015-12-14 13:41:57 +01:00
|
|
|
css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr);
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// create an object from a ClassId
|
2015-10-19 12:51:29 +02:00
|
|
|
css::uno::Reference < css::embed::XEmbeddedObject >
|
2016-01-09 14:45:19 +00:00
|
|
|
CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&, OUString&,
|
|
|
|
OUString const* pBaseURL = nullptr );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
2015-10-19 12:51:29 +02:00
|
|
|
css::uno::Reference < css::embed::XEmbeddedObject >
|
|
|
|
CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&,
|
2016-01-09 14:45:19 +00:00
|
|
|
const css::uno::Sequence < css::beans::PropertyValue >&, OUString&,
|
|
|
|
OUString const* pBaseURL = nullptr );
|
2006-11-01 17:30:36 +00:00
|
|
|
|
2013-02-23 15:06:20 +01:00
|
|
|
// insert an embedded object into the container - objects persistent representation will be added to the storage
|
2015-10-19 12:51:29 +02:00
|
|
|
bool InsertEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString& );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// load an embedded object from a MediaDescriptor and insert it into the container
|
|
|
|
// a new object will be created from the new content and returned
|
2015-10-19 12:51:29 +02:00
|
|
|
css::uno::Reference < css::embed::XEmbeddedObject >
|
2015-12-23 21:22:58 +00:00
|
|
|
InsertEmbeddedObject( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& rName, OUString const* pBaseURL = nullptr);
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// create an embedded link based on a MediaDescriptor and insert it into the container
|
|
|
|
// a new object will be created from the new content and returned
|
2015-10-19 12:51:29 +02:00
|
|
|
css::uno::Reference < css::embed::XEmbeddedObject >
|
|
|
|
InsertEmbeddedLink( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// create an object from a stream that contains its persistent representation and insert it as usual (usually called from clipboard)
|
|
|
|
// a new object will be created from the new content and returned
|
2015-10-19 12:51:29 +02:00
|
|
|
css::uno::Reference < css::embed::XEmbeddedObject >
|
|
|
|
InsertEmbeddedObject( const css::uno::Reference < css::io::XInputStream >&, OUString& );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
2005-07-12 11:27:16 +00:00
|
|
|
// copy an embedded object into the storage, open the new copy and return it
|
2014-06-13 11:12:50 -04:00
|
|
|
css::uno::Reference <css::embed::XEmbeddedObject> CopyAndGetEmbeddedObject(
|
|
|
|
EmbeddedObjectContainer& rSrc, const css::uno::Reference <css::embed::XEmbeddedObject>& xObj, OUString& rName,
|
|
|
|
const OUString& rSrcShellID, const OUString& rDestShellID );
|
2005-07-12 11:27:16 +00:00
|
|
|
|
2004-11-26 15:36:11 +00:00
|
|
|
// remove an embedded object from the container and from the storage; if object can't be closed
|
2012-06-21 14:25:25 +00:00
|
|
|
// #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+
|
2018-01-23 16:45:23 +02:00
|
|
|
void RemoveEmbeddedObject( const OUString& rName, bool bKeepToTempStorage = true);
|
2016-04-04 15:01:55 +02:00
|
|
|
bool RemoveEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, bool bKeepToTempStorage = true);
|
2004-10-04 20:05:39 +00:00
|
|
|
|
2005-10-19 11:47:36 +00:00
|
|
|
// close and remove an embedded object from the container without removing it from the storage
|
2018-01-23 16:45:23 +02:00
|
|
|
void CloseEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& );
|
2005-10-19 11:47:36 +00:00
|
|
|
|
2004-10-04 20:05:39 +00:00
|
|
|
// move an embedded object to another container (keep the persistent name)
|
2014-02-16 22:51:15 +01:00
|
|
|
bool MoveEmbeddedObject( const OUString& rName, EmbeddedObjectContainer& );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
// get the stored graphical representation for the object
|
2015-11-10 10:11:47 +01:00
|
|
|
css::uno::Reference < css::io::XInputStream > GetGraphicStream( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString* pMediaType=nullptr );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
2005-03-23 13:27:24 +00:00
|
|
|
// get the stored graphical representation by the object name
|
2015-11-10 10:11:47 +01:00
|
|
|
css::uno::Reference < css::io::XInputStream > GetGraphicStream( const OUString& aName, OUString* pMediaType=nullptr );
|
2005-03-23 13:27:24 +00:00
|
|
|
|
2004-10-04 20:05:39 +00:00
|
|
|
// add a graphical representation for an object
|
2015-10-19 12:51:29 +02:00
|
|
|
bool InsertGraphicStream( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
|
2004-10-04 20:05:39 +00:00
|
|
|
|
2005-10-19 11:47:36 +00:00
|
|
|
// try to add a graphical representation for an object in optimized way ( might fail )
|
2015-10-19 12:51:29 +02:00
|
|
|
bool InsertGraphicStreamDirectly( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
|
2005-10-19 11:47:36 +00:00
|
|
|
|
2004-10-04 20:05:39 +00:00
|
|
|
// remove a graphical representation for an object
|
2018-01-23 16:45:23 +02:00
|
|
|
void RemoveGraphicStream( const OUString& rObjectName );
|
2004-11-26 15:36:11 +00:00
|
|
|
|
2005-03-23 13:27:24 +00:00
|
|
|
// copy the graphical representation from different container
|
2014-02-16 22:51:15 +01:00
|
|
|
bool TryToCopyGraphReplacement( EmbeddedObjectContainer& rSrc,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& aOrigName,
|
|
|
|
const OUString& aTargetName );
|
2005-03-23 13:27:24 +00:00
|
|
|
|
2015-10-19 12:51:29 +02:00
|
|
|
void CloseEmbeddedObjects();
|
2014-02-16 22:51:15 +01:00
|
|
|
bool StoreChildren(bool _bOasisFormat,bool _bObjectsOnly);
|
|
|
|
bool StoreAsChildren( bool _bOasisFormat
|
|
|
|
,bool _bCreateEmbedded
|
2015-10-19 12:51:29 +02:00
|
|
|
,const css::uno::Reference < css::embed::XStorage >& _xStorage);
|
2008-03-05 17:28:28 +00:00
|
|
|
|
2015-10-19 12:51:29 +02:00
|
|
|
static css::uno::Reference< css::io::XInputStream > GetGraphicReplacementStream(
|
2008-03-05 17:28:28 +00:00
|
|
|
sal_Int64 nViewAspect,
|
2015-10-19 12:51:29 +02:00
|
|
|
const css::uno::Reference < css::embed::XEmbeddedObject >&,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString* pMediaType );
|
2008-03-05 17:28:28 +00:00
|
|
|
|
|
|
|
/** call setPersistentEntry for each embedded object in the container
|
|
|
|
*
|
2015-09-29 17:54:23 +02:00
|
|
|
* \param _xStorage The storage where to store the objects.
|
2013-12-20 11:25:37 +01:00
|
|
|
* \param _bClearModifedFlag If <TRUE/> then the modified flag will be set to <FALSE/> otherwise nothing happen.
|
2010-12-04 13:22:40 +09:00
|
|
|
* \return <FALSE/> if no error occurred, otherwise <TRUE/>.
|
2008-03-05 17:28:28 +00:00
|
|
|
*/
|
2015-10-19 12:51:29 +02:00
|
|
|
bool SetPersistentEntries(const css::uno::Reference< css::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true);
|
2014-08-07 09:59:26 +00:00
|
|
|
|
|
|
|
bool getUserAllowsLinkUpdate() const;
|
|
|
|
void setUserAllowsLinkUpdate(bool bNew);
|
2004-10-04 20:05:39 +00:00
|
|
|
};
|
|
|
|
|
2006-06-19 21:42:55 +00:00
|
|
|
}
|
2004-10-04 20:05:39 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|