1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmleohlp.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <cppuhelper/compbase2.hxx>
35 #include <osl/mutex.hxx>
36 #include <sot/storage.hxx>
38 #include <com/sun/star/container/XNameContainer.hpp>
39 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include <com/sun/star/embed/XEmbeddedObject.hpp>
42 #include "svx/svxdllapi.h"
44 // -----------------------------
45 // - SvXMLEmbeddedObjectHelper -
46 // -----------------------------
48 enum SvXMLEmbeddedObjectHelperMode
50 EMBEDDEDOBJECTHELPER_MODE_READ
= 0,
51 EMBEDDEDOBJECTHELPER_MODE_WRITE
= 1
54 // -----------------------------
55 // - SvXMLEmbeddedObjectHelper -
56 // -----------------------------
58 namespace comphelper
{
59 class IEmbeddedHelper
;
63 class OutputStorageWrapper_Impl
;
65 class SVX_DLLPUBLIC SvXMLEmbeddedObjectHelper
: public ::cppu::WeakComponentImplHelper2
<
66 ::com::sun::star::document::XEmbeddedObjectResolver
,
67 ::com::sun::star::container::XNameAccess
>
69 typedef ::std::map
< ::rtl::OUString
, OutputStorageWrapper_Impl
*,
70 OUStringLess
> SvXMLEmbeddedObjectHelper_Impl
;
75 const ::rtl::OUString maReplacementGraphicsContainerStorageName
;
76 const ::rtl::OUString maReplacementGraphicsContainerStorageName60
;
77 ::rtl::OUString maCurContainerStorageName
;
80 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> mxRootStorage
; // package
81 ::comphelper::IEmbeddedHelper
* mpDocPersist
;
82 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> mxContainerStorage
; // container sub package for
83 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> mxTempStorage
; // package
85 SvXMLEmbeddedObjectHelperMode meCreateMode
;
86 SvXMLEmbeddedObjectHelper_Impl
*mpStreamMap
;
88 SVX_DLLPRIVATE sal_Bool
ImplGetStorageNames(
89 const ::rtl::OUString
& rURLStr
,
90 ::rtl::OUString
& rContainerStorageName
,
91 ::rtl::OUString
& rObjectStorageName
,
92 sal_Bool bInternalToExternal
,
93 sal_Bool
*pGraphicRepl
=0,
94 sal_Bool
*pOasisFormat
=0 ) const;
96 SVX_DLLPRIVATE
com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> ImplGetContainerStorage(
97 const ::rtl::OUString
& rStorageName
);
99 SVX_DLLPRIVATE String
ImplGetUniqueName( ::comphelper::IEmbeddedHelper
*, const sal_Char
* p
) const;
100 SVX_DLLPRIVATE sal_Bool
ImplReadObject(
101 const ::rtl::OUString
& rContainerStorageName
,
102 ::rtl::OUString
& rObjName
,
103 const SvGlobalName
*pClassId
,
106 SVX_DLLPRIVATE ::rtl::OUString
ImplInsertEmbeddedObjectURL(
107 const ::rtl::OUString
& rURLStr
);
109 SVX_DLLPRIVATE ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> ImplGetReplacementImage(
110 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
>& xObj
);
114 SvXMLEmbeddedObjectHelper();
115 ~SvXMLEmbeddedObjectHelper();
116 void Init( const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>&,
117 ::comphelper::IEmbeddedHelper
& rDocPersist
,
118 SvXMLEmbeddedObjectHelperMode eCreateMode
);
120 virtual void SAL_CALL
disposing();
123 SvXMLEmbeddedObjectHelper(
124 ::comphelper::IEmbeddedHelper
& rDocPersist
,
125 SvXMLEmbeddedObjectHelperMode eCreateMode
);
127 static SvXMLEmbeddedObjectHelper
* Create(
128 const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>&,
129 ::comphelper::IEmbeddedHelper
& rDocPersist
,
130 SvXMLEmbeddedObjectHelperMode eCreateMode
,
131 sal_Bool bDirect
= sal_True
);
132 static SvXMLEmbeddedObjectHelper
* Create(
133 ::comphelper::IEmbeddedHelper
& rDocPersist
,
134 SvXMLEmbeddedObjectHelperMode eCreateMode
);
135 static void Destroy( SvXMLEmbeddedObjectHelper
* pSvXMLEmbeddedObjectHelper
);
139 // XEmbeddedObjectResolver
140 virtual ::rtl::OUString SAL_CALL
resolveEmbeddedObjectURL( const ::rtl::OUString
& aURL
) throw(::com::sun::star::uno::RuntimeException
);
143 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
144 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( ) throw (::com::sun::star::uno::RuntimeException
);
145 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
);
148 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw (::com::sun::star::uno::RuntimeException
);
149 virtual sal_Bool SAL_CALL
hasElements( ) throw (::com::sun::star::uno::RuntimeException
);