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/compbase.hxx>
24 #include <osl/mutex.hxx>
25 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
26 #include <com/sun/star/container/XNameAccess.hpp>
27 #include <com/sun/star/embed/XEmbeddedObject.hpp>
28 #include <com/sun/star/embed/XStorage.hpp>
29 #include <svx/svxdllapi.h>
30 #include <rtl/ref.hxx>
31 #include <tools/stream.hxx>
35 enum class SvXMLEmbeddedObjectHelperMode
40 namespace comphelper
{ class IEmbeddedHelper
; }
43 class OutputStorageWrapper_Impl
;
46 class SVX_DLLPUBLIC SvXMLEmbeddedObjectHelper final
:
47 public cppu::WeakComponentImplHelper
< css::document::XEmbeddedObjectResolver
, css::container::XNameAccess
>
51 OUString maCurContainerStorageName
;
54 css::uno::Reference
< css::embed::XStorage
> mxRootStorage
; // package
55 ::comphelper::IEmbeddedHelper
* mpDocPersist
;
56 css::uno::Reference
< css::embed::XStorage
> mxContainerStorage
; // container sub package for
57 css::uno::Reference
< css::embed::XStorage
> mxTempStorage
; // package
59 SvXMLEmbeddedObjectHelperMode meCreateMode
;
60 std::unique_ptr
<std::map
< OUString
, rtl::Reference
<OutputStorageWrapper_Impl
> >>
63 SVX_DLLPRIVATE
bool ImplGetStorageNames(
64 const OUString
& rURLStr
,
65 OUString
& rContainerStorageName
,
66 OUString
& rObjectStorageName
,
67 bool bInternalToExternal
,
68 bool *pGraphicRepl
=nullptr,
69 bool *pOasisFormat
=nullptr ) const;
71 SVX_DLLPRIVATE
css::uno::Reference
< css::embed::XStorage
> const & ImplGetContainerStorage(
72 const OUString
& rStorageName
);
74 SVX_DLLPRIVATE
void ImplReadObject(
75 const OUString
& rContainerStorageName
,
77 const SvGlobalName
*pClassId
,
80 SVX_DLLPRIVATE OUString
ImplInsertEmbeddedObjectURL(
81 const OUString
& rURLStr
);
83 SVX_DLLPRIVATE
css::uno::Reference
< css::io::XInputStream
> ImplGetReplacementImage(
84 const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
);
86 SvXMLEmbeddedObjectHelper();
87 virtual ~SvXMLEmbeddedObjectHelper() override
;
88 void Init( const css::uno::Reference
< css::embed::XStorage
>&,
89 ::comphelper::IEmbeddedHelper
& rDocPersist
,
90 SvXMLEmbeddedObjectHelperMode eCreateMode
);
92 virtual void SAL_CALL
disposing() override
;
95 SvXMLEmbeddedObjectHelper(
96 ::comphelper::IEmbeddedHelper
& rDocPersist
,
97 SvXMLEmbeddedObjectHelperMode eCreateMode
);
99 static rtl::Reference
<SvXMLEmbeddedObjectHelper
> Create(
100 const css::uno::Reference
< css::embed::XStorage
>&,
101 ::comphelper::IEmbeddedHelper
& rDocPersist
,
102 SvXMLEmbeddedObjectHelperMode eCreateMode
);
103 static rtl::Reference
<SvXMLEmbeddedObjectHelper
> Create(
104 ::comphelper::IEmbeddedHelper
& rDocPersist
,
105 SvXMLEmbeddedObjectHelperMode eCreateMode
);
107 // XEmbeddedObjectResolver
108 virtual OUString SAL_CALL
resolveEmbeddedObjectURL( const OUString
& aURL
) override
;
111 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
112 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
113 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
116 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
117 virtual sal_Bool SAL_CALL
hasElements( ) override
;
120 static void splitObjectURL(const OUString
& aURLNoPar
,
121 OUString
& rContainerStorageName
,
122 OUString
& rObjectStorageName
);
125 #endif // INCLUDED_SVX_XMLEOHLP_HXX
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */