LibreOffice Module comphelper (master) 1
embeddedobjectcontainer.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#ifndef INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
20#define INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
21
22#include <com/sun/star/uno/Reference.h>
23#include <com/sun/star/uno/Sequence.h>
25
26#include <rtl/ustring.hxx>
27#include <memory>
28
29namespace com::sun::star::beans { struct PropertyValue; }
30namespace com::sun::star::embed { class XEmbeddedObject; }
31namespace com::sun::star::embed { class XStorage; }
32namespace com::sun::star::io { class XInputStream; }
34namespace com::sun::star::uno { class XInterface; }
35
36namespace comphelper
37{
38 class EmbeddedObjectContainer;
41 class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IEmbeddedHelper
42 {
43 public:
45 virtual css::uno::Reference < css::embed::XStorage > getStorage() const = 0;
46 virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const = 0;
47 virtual bool isEnableSetModified() const = 0;
48 virtual OUString getDocumentBaseURL() const = 0;
49
50 protected:
52 };
53
54struct EmbedImpl;
56{
57 std::unique_ptr<EmbedImpl> pImpl;
58
59 css::uno::Reference < css::embed::XEmbeddedObject > Get_Impl( const OUString&,
60 const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy,
61 OUString const* pBaseURL);
62
63public:
64 // add an embedded object to the container storage
65 bool StoreEmbeddedObject(
66 const css::uno::Reference<css::embed::XEmbeddedObject>& xObj, OUString& rName, bool bCopy,
67 const OUString& rSrcShellID, const OUString& rDestShellID );
68
69 // add an embedded object that has been imported from the container storage - should only be called by filters!
70 void AddEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, const OUString& );
71
73 EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >& );
74 EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >&,
75 const css::uno::Reference < css::uno::XInterface >& );
77
78 void SwitchPersistence( const css::uno::Reference < css::embed::XStorage >& );
79 bool CommitImageSubStorage();
80 void ReleaseImageSubStorage();
81
82 OUString CreateUniqueObjectName();
83
84 // get a list of object names that have been added so far
85 css::uno::Sequence < OUString > GetObjectNames() const;
86
87 // check for existence of objects at all
88 bool HasEmbeddedObjects() const;
89
90 // check existence of an object - either by identity or by name
91 bool HasEmbeddedObject( const OUString& );
92 bool HasEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
93 bool HasInstantiatedEmbeddedObject( const OUString& );
94
95 // get the object name of an object - this is the persist name if the object has persistence
96 OUString GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
97
98 // retrieve an embedded object by name that either has been added already or is available in the container storage
99 css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr);
100
101 // create an object from a ClassId
102 css::uno::Reference < css::embed::XEmbeddedObject >
103 CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&, OUString&,
104 OUString const* pBaseURL = nullptr );
105
106 css::uno::Reference < css::embed::XEmbeddedObject >
107 CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&,
108 const css::uno::Sequence < css::beans::PropertyValue >&, OUString&,
109 OUString const* pBaseURL = nullptr );
110
111 // insert an embedded object into the container - objects persistent representation will be added to the storage
112 bool InsertEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString& );
113
114 // load an embedded object from a MediaDescriptor and insert it into the container
115 // a new object will be created from the new content and returned
116 css::uno::Reference < css::embed::XEmbeddedObject >
117 InsertEmbeddedObject( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& rName, OUString const* pBaseURL = nullptr);
118
119 // create an embedded link based on a MediaDescriptor and insert it into the container
120 // a new object will be created from the new content and returned
121 css::uno::Reference < css::embed::XEmbeddedObject >
122 InsertEmbeddedLink( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& );
123
124 // create an object from a stream that contains its persistent representation and insert it as usual (usually called from clipboard)
125 // a new object will be created from the new content and returned
126 css::uno::Reference < css::embed::XEmbeddedObject >
127 InsertEmbeddedObject( const css::uno::Reference < css::io::XInputStream >&, OUString& );
128
129 // copy an embedded object into the storage, open the new copy and return it
130 css::uno::Reference <css::embed::XEmbeddedObject> CopyAndGetEmbeddedObject(
131 EmbeddedObjectContainer& rSrc, const css::uno::Reference <css::embed::XEmbeddedObject>& xObj, OUString& rName,
132 const OUString& rSrcShellID, const OUString& rDestShellID );
133
134 // remove an embedded object from the container and from the storage; if object can't be closed
135 // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+
136 void RemoveEmbeddedObject( const OUString& rName, bool bKeepToTempStorage = true);
137 bool RemoveEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, bool bKeepToTempStorage = true);
138
139 // close and remove an embedded object from the container without removing it from the storage
140 void CloseEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& );
141
142 // move an embedded object to another container (keep the persistent name)
143 bool MoveEmbeddedObject( const OUString& rName, EmbeddedObjectContainer& );
144
145 // get the stored graphical representation for the object
146 css::uno::Reference < css::io::XInputStream > GetGraphicStream( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString* pMediaType=nullptr );
147
148 // get the stored graphical representation by the object name
149 css::uno::Reference < css::io::XInputStream > GetGraphicStream( const OUString& aName, OUString* pMediaType=nullptr );
150
151 // add a graphical representation for an object
152 bool InsertGraphicStream( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
153
154 // try to add a graphical representation for an object in optimized way ( might fail )
155 bool InsertGraphicStreamDirectly( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
156
157 // remove a graphical representation for an object
158 void RemoveGraphicStream( const OUString& rObjectName );
159
160 // copy the graphical representation from different container
161 bool TryToCopyGraphReplacement( EmbeddedObjectContainer& rSrc,
162 const OUString& aOrigName,
163 const OUString& aTargetName );
164
165 void CloseEmbeddedObjects();
166 bool StoreChildren(bool _bOasisFormat,bool _bObjectsOnly);
167 bool StoreAsChildren( bool _bOasisFormat
168 ,bool _bCreateEmbedded
169 ,bool _bAutoSaveEvent
170 ,const css::uno::Reference < css::embed::XStorage >& _xStorage);
171
172 static css::uno::Reference< css::io::XInputStream > GetGraphicReplacementStream(
173 sal_Int64 nViewAspect,
174 const css::uno::Reference < css::embed::XEmbeddedObject >&,
175 OUString* pMediaType );
176
183 bool SetPersistentEntries(const css::uno::Reference< css::embed::XStorage >& _xStorage,bool _bClearModifiedFlag = true);
184
185 bool getUserAllowsLinkUpdate() const;
186 void setUserAllowsLinkUpdate(bool bNew);
187};
188
189}
190
191#endif
192
193/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::embed::XEmbeddedObject > InsertEmbeddedObject(const css::uno::Reference< css::io::XInputStream > &, OUString &)
EmbeddedObjectContainer(const css::uno::Reference< css::embed::XStorage > &)
bool HasEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
EmbeddedObjectContainer(const css::uno::Reference< css::embed::XStorage > &, const css::uno::Reference< css::uno::XInterface > &)
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, const css::uno::Sequence< css::beans::PropertyValue > &, OUString &, OUString const *pBaseURL=nullptr)
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
bool RemoveEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, bool bKeepToTempStorage=true)
Helper interface to give access to some common object which replace the SfxObjectShell.
virtual bool isEnableSetModified() const =0
virtual EmbeddedObjectContainer & getEmbeddedObjectContainer() const =0
virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const =0
virtual css::uno::Reference< css::embed::XStorage > getStorage() const =0
virtual OUString getDocumentBaseURL() const =0
#define COMPHELPER_DLLPUBLIC
#define SAL_NO_VTABLE