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>
2007-05-22 19:19:00 +00:00
# include <com/sun/star/frame/XModel.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>
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
*/
class SAL_NO_VTABLE IEmbeddedHelper
{
public :
virtual EmbeddedObjectContainer & getEmbeddedObjectContainer ( ) const = 0 ;
virtual com : : sun : : star : : uno : : Reference < com : : sun : : star : : embed : : XStorage > getStorage ( ) const = 0 ;
virtual : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : task : : XInteractionHandler > getInteractionHandler ( ) const = 0 ;
virtual bool isEnableSetModified ( ) 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
{
EmbedImpl * pImpl ;
2013-04-07 12:06:47 +02:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > Get_Impl ( const OUString & ,
2007-05-22 19:19:00 +00:00
const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & xCopy ) ;
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
2013-04-07 12:06:47 +02:00
sal_Bool StoreEmbeddedObject ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & , OUString & , sal_Bool ) ;
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!
2013-04-07 12:06:47 +02:00
void AddEmbeddedObject ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & , const OUString & ) ;
2004-10-04 20:05:39 +00:00
EmbeddedObjectContainer ( ) ;
EmbeddedObjectContainer ( const com : : sun : : star : : uno : : Reference < com : : sun : : star : : embed : : XStorage > & ) ;
2007-05-22 19:19:00 +00:00
EmbeddedObjectContainer ( const com : : sun : : star : : uno : : Reference < com : : sun : : star : : embed : : XStorage > & ,
const com : : sun : : star : : uno : : Reference < com : : sun : : star : : uno : : XInterface > & ) ;
2004-10-04 20:05:39 +00:00
~ EmbeddedObjectContainer ( ) ;
void SwitchPersistence ( const com : : sun : : star : : uno : : Reference < com : : sun : : star : : embed : : XStorage > & ) ;
2005-07-12 11:27:16 +00:00
sal_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
2013-04-07 12:06:47 +02:00
com : : sun : : star : : uno : : Sequence < OUString > GetObjectNames ( ) ;
2004-10-04 20:05:39 +00:00
// check for existence of objects at all
sal_Bool HasEmbeddedObjects ( ) ;
// check existence of an object - either by identity or by name
2013-04-07 12:06:47 +02:00
sal_Bool HasEmbeddedObject ( const OUString & ) ;
2004-10-04 20:05:39 +00:00
sal_Bool HasEmbeddedObject ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & ) ;
2013-04-07 12:06:47 +02:00
sal_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
2013-04-07 12:06:47 +02:00
OUString GetEmbeddedObjectName ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & ) ;
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
2013-04-07 12:06:47 +02:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > GetEmbeddedObject ( const OUString & ) ;
2004-10-04 20:05:39 +00:00
// create an object from a ClassId
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject >
2013-04-07 12:06:47 +02:00
CreateEmbeddedObject ( const com : : sun : : star : : uno : : Sequence < sal_Int8 > & , OUString & ) ;
2004-10-04 20:05:39 +00:00
2006-11-01 17:30:36 +00:00
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject >
CreateEmbeddedObject ( const com : : sun : : star : : uno : : Sequence < sal_Int8 > & ,
2013-04-07 12:06:47 +02:00
const com : : sun : : star : : uno : : Sequence < com : : sun : : star : : beans : : PropertyValue > & , OUString & ) ;
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
2013-04-07 12:06:47 +02:00
sal_Bool InsertEmbeddedObject ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : 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
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject >
2013-04-07 12:06:47 +02:00
InsertEmbeddedObject ( const : : com : : sun : : star : : uno : : Sequence < : : com : : sun : : star : : beans : : PropertyValue > & , OUString & ) ;
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
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject >
2013-04-07 12:06:47 +02:00
InsertEmbeddedLink ( const : : com : : sun : : star : : uno : : Sequence < : : com : : sun : : star : : 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
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject >
2013-04-07 12:06:47 +02:00
InsertEmbeddedObject ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : 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
2013-04-07 12:06:47 +02:00
: : 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 ) ;
2005-07-12 11:27:16 +00:00
2004-11-26 15:36:11 +00:00
// move an embedded object from one container to another one
2013-04-07 12:06:47 +02:00
sal_Bool MoveEmbeddedObject ( EmbeddedObjectContainer & rSrc , const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & , OUString & ) ;
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+
sal_Bool RemoveEmbeddedObject ( const OUString & rName , sal_Bool bClose = sal_True , sal_Bool bKeepToTempStorage = sal_True ) ;
sal_Bool RemoveEmbeddedObject ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & , sal_Bool bClose = sal_True , sal_Bool bKeepToTempStorage = sal_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
sal_Bool CloseEmbeddedObject ( const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : embed : : XEmbeddedObject > & ) ;
2004-10-04 20:05:39 +00:00
// move an embedded object to another container (keep the persistent name)
2013-04-07 12:06:47 +02:00
sal_Bool MoveEmbeddedObject ( const OUString & rName , EmbeddedObjectContainer & ) ;
2004-10-04 20:05:39 +00:00
// get the stored graphical representation for the object
2013-04-07 12:06:47 +02:00
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 ) ;
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
2013-04-07 12:06:47 +02:00
com : : sun : : star : : uno : : Reference < com : : sun : : star : : io : : XInputStream > GetGraphicStream ( const OUString & aName , OUString * pMediaType = 0 ) ;
2005-03-23 13:27:24 +00:00
2004-10-04 20:05:39 +00:00
// add a graphical representation for an object
2013-04-07 12:06:47 +02:00
sal_Bool InsertGraphicStream ( const com : : sun : : star : : uno : : Reference < com : : sun : : star : : 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 )
2013-04-07 12:06:47 +02:00
sal_Bool InsertGraphicStreamDirectly ( const com : : sun : : star : : uno : : Reference < com : : sun : : star : : 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
2013-04-07 12:06:47 +02:00
sal_Bool 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
sal_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
2004-11-26 15:36:11 +00:00
void CloseEmbeddedObjects ( ) ;
2008-03-05 17:28:28 +00:00
sal_Bool StoreChildren ( sal_Bool _bOasisFormat , sal_Bool _bObjectsOnly ) ;
sal_Bool StoreAsChildren ( sal_Bool _bOasisFormat
, sal_Bool _bCreateEmbedded
, const com : : sun : : star : : uno : : Reference < com : : sun : : star : : embed : : XStorage > & _xStorage ) ;
static com : : sun : : star : : uno : : Reference < com : : sun : : star : : io : : XInputStream > GetGraphicReplacementStream (
sal_Int64 nViewAspect ,
const com : : sun : : star : : uno : : Reference < com : : sun : : star : : 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
*
* \ param _xStorage The storeage 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
*/
sal_Bool SetPersistentEntries ( const com : : sun : : star : : uno : : Reference < com : : sun : : star : : embed : : XStorage > & _xStorage , bool _bClearModifedFlag = true ) ;
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: */