1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_SVX_XMLEOHLP_HXX
21 #define INCLUDED_SVX_XMLEOHLP_HXX
23 #include <cppuhelper/compbase2.hxx>
24 #include <osl/mutex.hxx>
26 #include <com/sun/star/container/XNameContainer.hpp>
27 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
28 #include <com/sun/star/container/XNameAccess.hpp>
29 #include <com/sun/star/embed/XEmbeddedObject.hpp>
30 #include <svx/svxdllapi.h>
33 // - SvXMLEmbeddedObjectHelper -
36 enum SvXMLEmbeddedObjectHelperMode
38 EMBEDDEDOBJECTHELPER_MODE_READ
= 0,
39 EMBEDDEDOBJECTHELPER_MODE_WRITE
= 1
43 // - SvXMLEmbeddedObjectHelper -
46 namespace comphelper
{
47 class IEmbeddedHelper
;
51 class OutputStorageWrapper_Impl
;
53 class SVX_DLLPUBLIC SvXMLEmbeddedObjectHelper
: public ::cppu::WeakComponentImplHelper2
<
54 ::com::sun::star::document::XEmbeddedObjectResolver
,
55 ::com::sun::star::container::XNameAccess
>
57 typedef ::std::map
< OUString
, OutputStorageWrapper_Impl
*,
58 OUStringLess
> SvXMLEmbeddedObjectHelper_Impl
;
63 const OUString maReplacementGraphicsContainerStorageName
;
64 const OUString maReplacementGraphicsContainerStorageName60
;
65 OUString maCurContainerStorageName
;
68 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> mxRootStorage
; // package
69 ::comphelper::IEmbeddedHelper
* mpDocPersist
;
70 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> mxContainerStorage
; // container sub package for
71 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> mxTempStorage
; // package
73 SvXMLEmbeddedObjectHelperMode meCreateMode
;
74 SvXMLEmbeddedObjectHelper_Impl
*mpStreamMap
;
76 SVX_DLLPRIVATE
bool ImplGetStorageNames(
77 const OUString
& rURLStr
,
78 OUString
& rContainerStorageName
,
79 OUString
& rObjectStorageName
,
80 bool bInternalToExternal
,
82 bool *pOasisFormat
=0 ) const;
84 SVX_DLLPRIVATE
com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
> ImplGetContainerStorage(
85 const OUString
& rStorageName
);
87 SVX_DLLPRIVATE
bool ImplReadObject(
88 const OUString
& rContainerStorageName
,
90 const SvGlobalName
*pClassId
,
93 SVX_DLLPRIVATE OUString
ImplInsertEmbeddedObjectURL(
94 const OUString
& rURLStr
);
96 SVX_DLLPRIVATE ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> ImplGetReplacementImage(
97 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
>& xObj
);
101 SvXMLEmbeddedObjectHelper();
102 virtual ~SvXMLEmbeddedObjectHelper();
103 void Init( const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>&,
104 ::comphelper::IEmbeddedHelper
& rDocPersist
,
105 SvXMLEmbeddedObjectHelperMode eCreateMode
);
107 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
110 SvXMLEmbeddedObjectHelper(
111 ::comphelper::IEmbeddedHelper
& rDocPersist
,
112 SvXMLEmbeddedObjectHelperMode eCreateMode
);
114 static SvXMLEmbeddedObjectHelper
* Create(
115 const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>&,
116 ::comphelper::IEmbeddedHelper
& rDocPersist
,
117 SvXMLEmbeddedObjectHelperMode eCreateMode
,
118 bool bDirect
= true );
119 static SvXMLEmbeddedObjectHelper
* Create(
120 ::comphelper::IEmbeddedHelper
& rDocPersist
,
121 SvXMLEmbeddedObjectHelperMode eCreateMode
);
122 static void Destroy( SvXMLEmbeddedObjectHelper
* pSvXMLEmbeddedObjectHelper
);
126 // XEmbeddedObjectResolver
127 virtual OUString SAL_CALL
resolveEmbeddedObjectURL( const OUString
& aURL
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
130 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
) throw (::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
131 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
132 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
135 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
136 virtual sal_Bool SAL_CALL
hasElements( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 static void splitObjectURL(const OUString
& aURLNoPar
,
140 OUString
& rContainerStorageName
,
141 OUString
& rObjectStorageName
);
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */