/src/libreoffice/include/comphelper/embeddedobjectcontainer.hxx
Line | Count | Source |
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> |
24 | | #include <comphelper/comphelperdllapi.h> |
25 | | |
26 | | #include <rtl/ustring.hxx> |
27 | | #include <memory> |
28 | | |
29 | | namespace com::sun::star::beans { struct PropertyValue; } |
30 | | namespace com::sun::star::embed { class XEmbeddedObject; } |
31 | | namespace com::sun::star::embed { class XStorage; } |
32 | | namespace com::sun::star::io { class XInputStream; } |
33 | | namespace com::sun::star::task { class XInteractionHandler; } |
34 | | namespace com::sun::star::uno { class XInterface; } |
35 | | |
36 | | namespace comphelper |
37 | | { |
38 | | class EmbeddedObjectContainer; |
39 | | /** Helper interface to give access to some common object which replace the SfxObjectShell |
40 | | */ |
41 | | class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IEmbeddedHelper |
42 | | { |
43 | | public: |
44 | | virtual EmbeddedObjectContainer& getEmbeddedObjectContainer() const = 0; |
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: |
51 | 245k | ~IEmbeddedHelper() {} |
52 | | }; |
53 | | |
54 | | struct EmbedImpl; |
55 | | class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer |
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 | | |
63 | | public: |
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 | | |
72 | | EmbeddedObjectContainer(); |
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 >& ); |
76 | | ~EmbeddedObjectContainer(); |
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 | | OUString const* pTargetShellID = nullptr); |
114 | | |
115 | | // load an embedded object from a MediaDescriptor and insert it into the container |
116 | | // a new object will be created from the new content and returned |
117 | | css::uno::Reference < css::embed::XEmbeddedObject > |
118 | | InsertEmbeddedObject( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& rName, OUString const* pBaseURL = nullptr); |
119 | | |
120 | | // create an embedded link based on a MediaDescriptor and insert it into the container |
121 | | // a new object will be created from the new content and returned |
122 | | css::uno::Reference < css::embed::XEmbeddedObject > |
123 | | InsertEmbeddedLink( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& ); |
124 | | |
125 | | // create an object from a stream that contains its persistent representation and insert it as usual (usually called from clipboard) |
126 | | // a new object will be created from the new content and returned |
127 | | css::uno::Reference < css::embed::XEmbeddedObject > |
128 | | InsertEmbeddedObject( const css::uno::Reference < css::io::XInputStream >&, OUString& ); |
129 | | |
130 | | // copy an embedded object into the storage, open the new copy and return it |
131 | | css::uno::Reference <css::embed::XEmbeddedObject> CopyAndGetEmbeddedObject( |
132 | | EmbeddedObjectContainer& rSrc, const css::uno::Reference <css::embed::XEmbeddedObject>& xObj, OUString& rName, |
133 | | const OUString& rSrcShellID, const OUString& rDestShellID ); |
134 | | |
135 | | // remove an embedded object from the container and from the storage; if object can't be closed |
136 | | // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+ |
137 | | void RemoveEmbeddedObject( const OUString& rName, bool bKeepToTempStorage = true); |
138 | | bool RemoveEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, bool bKeepToTempStorage = true); |
139 | | |
140 | | // close and remove an embedded object from the container without removing it from the storage |
141 | | void CloseEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& ); |
142 | | |
143 | | // move an embedded object to another container (keep the persistent name) |
144 | | bool MoveEmbeddedObject( const OUString& rName, EmbeddedObjectContainer& ); |
145 | | |
146 | | // get the stored graphical representation for the object |
147 | | css::uno::Reference < css::io::XInputStream > GetGraphicStream( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString* pMediaType=nullptr ); |
148 | | |
149 | | // get the stored graphical representation by the object name |
150 | | css::uno::Reference < css::io::XInputStream > GetGraphicStream( const OUString& aName, OUString* pMediaType=nullptr ); |
151 | | |
152 | | // add a graphical representation for an object |
153 | | bool InsertGraphicStream( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType ); |
154 | | |
155 | | // try to add a graphical representation for an object in optimized way ( might fail ) |
156 | | bool InsertGraphicStreamDirectly( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType ); |
157 | | |
158 | | // remove a graphical representation for an object |
159 | | void RemoveGraphicStream( const OUString& rObjectName ); |
160 | | |
161 | | // copy the graphical representation from different container |
162 | | bool TryToCopyGraphReplacement( EmbeddedObjectContainer& rSrc, |
163 | | const OUString& aOrigName, |
164 | | const OUString& aTargetName ); |
165 | | |
166 | | void CloseEmbeddedObjects(); |
167 | | bool StoreChildren(bool _bOasisFormat,bool _bObjectsOnly); |
168 | | bool StoreAsChildren( bool _bOasisFormat |
169 | | ,bool _bCreateEmbedded |
170 | | ,bool _bAutoSaveEvent |
171 | | ,const css::uno::Reference < css::embed::XStorage >& _xStorage); |
172 | | |
173 | | static css::uno::Reference< css::io::XInputStream > GetGraphicReplacementStream( |
174 | | sal_Int64 nViewAspect, |
175 | | const css::uno::Reference < css::embed::XEmbeddedObject >&, |
176 | | OUString* pMediaType ); |
177 | | |
178 | | /** call setPersistentEntry for each embedded object in the container |
179 | | * |
180 | | * \param _xStorage The storage where to store the objects. |
181 | | * \param _bClearModifiedFlag If <TRUE/> then the modified flag will be set to <FALSE/> otherwise nothing happen. |
182 | | * \return <FALSE/> if no error occurred, otherwise <TRUE/>. |
183 | | */ |
184 | | bool SetPersistentEntries(const css::uno::Reference< css::embed::XStorage >& _xStorage,bool _bClearModifiedFlag = true); |
185 | | |
186 | | // if DisableActiveContent configuration option is set, this always returns false |
187 | | bool getUserAllowsLinkUpdate() const; |
188 | | |
189 | | // if DisableActiveContent configuration option is set, this has no effect |
190 | | void setUserAllowsLinkUpdate(bool bNew); |
191 | | }; |
192 | | |
193 | | } |
194 | | |
195 | | #endif |
196 | | |
197 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |