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 <comphelper/compbase.hxx>
24 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
25 #include <com/sun/star/container/XNameAccess.hpp>
26 #include <com/sun/star/embed/XEmbeddedObject.hpp>
27 #include <com/sun/star/embed/XStorage.hpp>
28 #include <svx/svxdllapi.h>
29 #include <rtl/ref.hxx>
30 #include <tools/stream.hxx>
34 enum class SvXMLEmbeddedObjectHelperMode
39 namespace comphelper
{ class IEmbeddedHelper
; }
42 class OutputStorageWrapper_Impl
;
45 class SVXCORE_DLLPUBLIC SvXMLEmbeddedObjectHelper final
:
46 public comphelper::WeakComponentImplHelper
< css::document::XEmbeddedObjectResolver
, css::container::XNameAccess
>
48 OUString maCurContainerStorageName
;
51 css::uno::Reference
< css::embed::XStorage
> mxRootStorage
; // package
52 ::comphelper::IEmbeddedHelper
* mpDocPersist
;
53 css::uno::Reference
< css::embed::XStorage
> mxContainerStorage
; // container sub package for
54 css::uno::Reference
< css::embed::XStorage
> mxTempStorage
; // package
56 SvXMLEmbeddedObjectHelperMode meCreateMode
;
57 std::optional
<std::map
< OUString
, rtl::Reference
<OutputStorageWrapper_Impl
> >>
60 SVX_DLLPRIVATE
bool ImplGetStorageNames(
61 const OUString
& rURLStr
,
62 OUString
& rContainerStorageName
,
63 OUString
& rObjectStorageName
,
64 bool bInternalToExternal
,
65 bool *pGraphicRepl
=nullptr,
66 bool *pOasisFormat
=nullptr ) const;
68 SVX_DLLPRIVATE
css::uno::Reference
< css::embed::XStorage
> const & ImplGetContainerStorage(
69 const OUString
& rStorageName
);
71 SVX_DLLPRIVATE
void ImplReadObject(
72 const OUString
& rContainerStorageName
,
74 const SvGlobalName
*pClassId
,
77 SVX_DLLPRIVATE OUString
ImplInsertEmbeddedObjectURL(
78 const OUString
& rURLStr
);
80 SVX_DLLPRIVATE
css::uno::Reference
< css::io::XInputStream
> ImplGetReplacementImage(
81 const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
);
83 SvXMLEmbeddedObjectHelper();
84 virtual ~SvXMLEmbeddedObjectHelper() override
;
85 void Init( const css::uno::Reference
< css::embed::XStorage
>&,
86 ::comphelper::IEmbeddedHelper
& rDocPersist
,
87 SvXMLEmbeddedObjectHelperMode eCreateMode
);
89 virtual void disposing(std::unique_lock
<std::mutex
>&) override
;
92 SvXMLEmbeddedObjectHelper(
93 ::comphelper::IEmbeddedHelper
& rDocPersist
,
94 SvXMLEmbeddedObjectHelperMode eCreateMode
);
96 static rtl::Reference
<SvXMLEmbeddedObjectHelper
> Create(
97 const css::uno::Reference
< css::embed::XStorage
>&,
98 ::comphelper::IEmbeddedHelper
& rDocPersist
,
99 SvXMLEmbeddedObjectHelperMode eCreateMode
);
100 static rtl::Reference
<SvXMLEmbeddedObjectHelper
> Create(
101 ::comphelper::IEmbeddedHelper
& rDocPersist
,
102 SvXMLEmbeddedObjectHelperMode eCreateMode
);
104 // XEmbeddedObjectResolver
105 virtual OUString SAL_CALL
resolveEmbeddedObjectURL( const OUString
& aURL
) override
;
108 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
109 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
110 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
113 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
114 virtual sal_Bool SAL_CALL
hasElements( ) override
;
117 static void splitObjectURL(const OUString
& aURLNoPar
,
118 OUString
& rContainerStorageName
,
119 OUString
& rObjectStorageName
);
122 #endif // INCLUDED_SVX_XMLEOHLP_HXX
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */