bump product version to 4.2.0.1
[LibreOffice.git] / include / comphelper / embeddedobjectcontainer.hxx
blob7ce0566c926c2b55b1204037516b8b4fbc9183d9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
20 #define INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
22 #include <com/sun/star/uno/Reference.h>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/embed/XEmbeddedObject.hpp>
25 #include <com/sun/star/task/XInteractionHandler.hpp>
26 #include <com/sun/star/embed/XStorage.hpp>
27 #include <com/sun/star/io/XInputStream.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <com/sun/star/frame/XModel.hpp>
30 #include <comphelper/comphelperdllapi.h>
32 #include <rtl/ustring.hxx>
34 namespace comphelper
36 class EmbeddedObjectContainer;
37 /** Helper interface to give access to some common object which replace the SfxObjectShell
39 class SAL_NO_VTABLE IEmbeddedHelper
41 public:
42 virtual EmbeddedObjectContainer& getEmbeddedObjectContainer() const = 0;
43 virtual com::sun::star::uno::Reference < com::sun::star::embed::XStorage > getStorage() const = 0;
44 virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler() const = 0;
45 virtual bool isEnableSetModified() const = 0;
47 protected:
48 ~IEmbeddedHelper() {}
51 struct EmbedImpl;
52 class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer
54 EmbedImpl* pImpl;
56 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > Get_Impl( const OUString&,
57 const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xCopy);
59 public:
60 // add an embedded object to the container storage
61 sal_Bool StoreEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, OUString&, sal_Bool );
63 // add an embedded object that has been imported from the container storage - should only be called by filters!
64 void AddEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, const OUString& );
66 EmbeddedObjectContainer();
67 EmbeddedObjectContainer( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& );
68 EmbeddedObjectContainer( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&,
69 const com::sun::star::uno::Reference < com::sun::star::uno::XInterface >& );
70 ~EmbeddedObjectContainer();
72 void SwitchPersistence( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& );
73 sal_Bool CommitImageSubStorage();
74 void ReleaseImageSubStorage();
76 OUString CreateUniqueObjectName();
78 // get a list of object names that have been added so far
79 com::sun::star::uno::Sequence < OUString > GetObjectNames();
81 // check for existence of objects at all
82 sal_Bool HasEmbeddedObjects();
84 // check existence of an object - either by identity or by name
85 sal_Bool HasEmbeddedObject( const OUString& );
86 sal_Bool HasEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& );
87 sal_Bool HasInstantiatedEmbeddedObject( const OUString& );
89 // get the object name of an object - this is the persist name if the object has persistence
90 OUString GetEmbeddedObjectName( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& );
92 // retrieve an embedded object by name that either has been added already or is available in the container storage
93 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > GetEmbeddedObject( const OUString& );
95 // create an object from a ClassId
96 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >
97 CreateEmbeddedObject( const com::sun::star::uno::Sequence < sal_Int8 >&, OUString& );
99 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >
100 CreateEmbeddedObject( const com::sun::star::uno::Sequence < sal_Int8 >&,
101 const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, OUString& );
103 // insert an embedded object into the container - objects persistent representation will be added to the storage
104 sal_Bool InsertEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, OUString& );
106 // load an embedded object from a MediaDescriptor and insert it into the container
107 // a new object will be created from the new content and returned
108 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >
109 InsertEmbeddedObject( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, OUString& );
111 // create an embedded link based on a MediaDescriptor and insert it into the container
112 // a new object will be created from the new content and returned
113 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >
114 InsertEmbeddedLink( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, OUString& );
116 // create an object from a stream that contains its persistent representation and insert it as usual (usually called from clipboard)
117 // a new object will be created from the new content and returned
118 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >
119 InsertEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >&, OUString& );
121 // copy an embedded object into the storage, open the new copy and return it
122 ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject > CopyAndGetEmbeddedObject( EmbeddedObjectContainer& rSrc, const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& xObj, /* TODO const OUString& aOrigName,*/ OUString& rName );
124 // move an embedded object from one container to another one
125 sal_Bool MoveEmbeddedObject( EmbeddedObjectContainer& rSrc, const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, OUString& );
127 // remove an embedded object from the container and from the storage; if object can't be closed
128 // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+
129 sal_Bool RemoveEmbeddedObject( const OUString& rName, sal_Bool bClose = sal_True, sal_Bool bKeepToTempStorage = sal_True );
130 sal_Bool RemoveEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, sal_Bool bClose = sal_True, sal_Bool bKeepToTempStorage = sal_True );
132 // close and remove an embedded object from the container without removing it from the storage
133 sal_Bool CloseEmbeddedObject( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >& );
135 // move an embedded object to another container (keep the persistent name)
136 sal_Bool MoveEmbeddedObject( const OUString& rName, EmbeddedObjectContainer& );
138 // get the stored graphical representation for the object
139 com::sun::star::uno::Reference < com::sun::star::io::XInputStream > GetGraphicStream( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XEmbeddedObject >&, OUString* pMediaType=0 );
141 // get the stored graphical representation by the object name
142 com::sun::star::uno::Reference < com::sun::star::io::XInputStream > GetGraphicStream( const OUString& aName, OUString* pMediaType=0 );
144 // add a graphical representation for an object
145 sal_Bool InsertGraphicStream( const com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
147 // try to add a graphical representation for an object in optimized way ( might fail )
148 sal_Bool InsertGraphicStreamDirectly( const com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
150 // remove a graphical representation for an object
151 sal_Bool RemoveGraphicStream( const OUString& rObjectName );
153 // copy the graphical representation from different container
154 sal_Bool TryToCopyGraphReplacement( EmbeddedObjectContainer& rSrc,
155 const OUString& aOrigName,
156 const OUString& aTargetName );
158 void CloseEmbeddedObjects();
159 sal_Bool StoreChildren(sal_Bool _bOasisFormat,sal_Bool _bObjectsOnly);
160 sal_Bool StoreAsChildren( sal_Bool _bOasisFormat
161 ,sal_Bool _bCreateEmbedded
162 ,const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& _xStorage);
164 static com::sun::star::uno::Reference< com::sun::star::io::XInputStream > GetGraphicReplacementStream(
165 sal_Int64 nViewAspect,
166 const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >&,
167 OUString* pMediaType );
169 /** call setPersistentEntry for each embedded object in the container
171 * \param _xStorage The storeage where to store the objects.
172 * \param _bClearModifedFlag If <TRUE/> then the modifed flag will be set to <FALSE/> otherwise nothing happen.
173 * \return <FALSE/> if no error occurred, otherwise <TRUE/>.
175 sal_Bool SetPersistentEntries(const com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true);
180 #endif
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */