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/container/XNameContainer.hpp>
26 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <com/sun/star/embed/XEmbeddedObject.hpp>
29 #include <svx/svxdllapi.h>
30 #include <rtl/ref.hxx>
34 enum class SvXMLEmbeddedObjectHelperMode
39 namespace comphelper
{ class IEmbeddedHelper
; }
42 class OutputStorageWrapper_Impl
;
45 class SVX_DLLPUBLIC SvXMLEmbeddedObjectHelper final
:
46 public cppu::WeakComponentImplHelper
< css::document::XEmbeddedObjectResolver
, css::container::XNameAccess
>
50 OUString maCurContainerStorageName
;
53 css::uno::Reference
< css::embed::XStorage
> mxRootStorage
; // package
54 ::comphelper::IEmbeddedHelper
* mpDocPersist
;
55 css::uno::Reference
< css::embed::XStorage
> mxContainerStorage
; // container sub package for
56 css::uno::Reference
< css::embed::XStorage
> mxTempStorage
; // package
58 SvXMLEmbeddedObjectHelperMode meCreateMode
;
59 std::unique_ptr
<std::map
< OUString
, rtl::Reference
<OutputStorageWrapper_Impl
> >>
62 SVX_DLLPRIVATE
bool ImplGetStorageNames(
63 const OUString
& rURLStr
,
64 OUString
& rContainerStorageName
,
65 OUString
& rObjectStorageName
,
66 bool bInternalToExternal
,
67 bool *pGraphicRepl
=nullptr,
68 bool *pOasisFormat
=nullptr ) const;
70 SVX_DLLPRIVATE
css::uno::Reference
< css::embed::XStorage
> const & ImplGetContainerStorage(
71 const OUString
& rStorageName
);
73 SVX_DLLPRIVATE
void ImplReadObject(
74 const OUString
& rContainerStorageName
,
76 const SvGlobalName
*pClassId
,
79 SVX_DLLPRIVATE OUString
ImplInsertEmbeddedObjectURL(
80 const OUString
& rURLStr
);
82 SVX_DLLPRIVATE
css::uno::Reference
< css::io::XInputStream
> ImplGetReplacementImage(
83 const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
);
85 SvXMLEmbeddedObjectHelper();
86 virtual ~SvXMLEmbeddedObjectHelper() override
;
87 void Init( const css::uno::Reference
< css::embed::XStorage
>&,
88 ::comphelper::IEmbeddedHelper
& rDocPersist
,
89 SvXMLEmbeddedObjectHelperMode eCreateMode
);
91 virtual void SAL_CALL
disposing() override
;
94 SvXMLEmbeddedObjectHelper(
95 ::comphelper::IEmbeddedHelper
& rDocPersist
,
96 SvXMLEmbeddedObjectHelperMode eCreateMode
);
98 static rtl::Reference
<SvXMLEmbeddedObjectHelper
> Create(
99 const css::uno::Reference
< css::embed::XStorage
>&,
100 ::comphelper::IEmbeddedHelper
& rDocPersist
,
101 SvXMLEmbeddedObjectHelperMode eCreateMode
);
102 static rtl::Reference
<SvXMLEmbeddedObjectHelper
> Create(
103 ::comphelper::IEmbeddedHelper
& rDocPersist
,
104 SvXMLEmbeddedObjectHelperMode eCreateMode
);
106 // XEmbeddedObjectResolver
107 virtual OUString SAL_CALL
resolveEmbeddedObjectURL( const OUString
& aURL
) override
;
110 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
111 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
112 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
115 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
116 virtual sal_Bool SAL_CALL
hasElements( ) override
;
119 static void splitObjectURL(const OUString
& aURLNoPar
,
120 OUString
& rContainerStorageName
,
121 OUString
& rObjectStorageName
);
124 #endif // INCLUDED_SVX_XMLEOHLP_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */