Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / xmleohlp.hxx
blobcb8183fb20a6c022424c9f5f15b994f7d9cde61e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <map>
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>
32 enum class SvXMLEmbeddedObjectHelperMode
34 Read, Write
37 namespace comphelper { class IEmbeddedHelper; }
39 class SvGlobalName;
40 class OutputStorageWrapper_Impl;
43 class SVX_DLLPUBLIC SvXMLEmbeddedObjectHelper :
44 public cppu::WeakComponentImplHelper< css::document::XEmbeddedObjectResolver, css::container::XNameAccess >
46 typedef ::std::map< OUString, OutputStorageWrapper_Impl* > SvXMLEmbeddedObjectHelper_Impl;
47 private:
49 ::osl::Mutex maMutex;
51 const OUString maReplacementGraphicsContainerStorageName;
52 const OUString maReplacementGraphicsContainerStorageName60;
53 OUString maCurContainerStorageName;
56 css::uno::Reference < css::embed::XStorage > mxRootStorage; // package
57 ::comphelper::IEmbeddedHelper* mpDocPersist;
58 css::uno::Reference < css::embed::XStorage > mxContainerStorage; // container sub package for
59 css::uno::Reference < css::embed::XStorage > mxTempStorage; // package
60 // objects
61 SvXMLEmbeddedObjectHelperMode meCreateMode;
62 SvXMLEmbeddedObjectHelper_Impl *mpStreamMap;
64 SVX_DLLPRIVATE bool ImplGetStorageNames(
65 const OUString& rURLStr,
66 OUString& rContainerStorageName,
67 OUString& rObjectStorageName,
68 bool bInternalToExternal,
69 bool *pGraphicRepl=nullptr,
70 bool *pOasisFormat=nullptr ) const;
72 SVX_DLLPRIVATE css::uno::Reference < css::embed::XStorage > const & ImplGetContainerStorage(
73 const OUString& rStorageName );
75 SVX_DLLPRIVATE void ImplReadObject(
76 const OUString& rContainerStorageName,
77 OUString& rObjName,
78 const SvGlobalName *pClassId,
79 SvStream* pTemp );
81 SVX_DLLPRIVATE OUString ImplInsertEmbeddedObjectURL(
82 const OUString& rURLStr );
84 SVX_DLLPRIVATE css::uno::Reference< css::io::XInputStream > ImplGetReplacementImage(
85 const css::uno::Reference< css::embed::XEmbeddedObject >& xObj );
87 protected:
89 SvXMLEmbeddedObjectHelper();
90 virtual ~SvXMLEmbeddedObjectHelper() override;
91 void Init( const css::uno::Reference < css::embed::XStorage >&,
92 ::comphelper::IEmbeddedHelper& rDocPersist,
93 SvXMLEmbeddedObjectHelperMode eCreateMode );
95 virtual void SAL_CALL disposing() override;
97 public:
98 SvXMLEmbeddedObjectHelper(
99 ::comphelper::IEmbeddedHelper& rDocPersist,
100 SvXMLEmbeddedObjectHelperMode eCreateMode );
102 static SvXMLEmbeddedObjectHelper* Create(
103 const css::uno::Reference < css::embed::XStorage >&,
104 ::comphelper::IEmbeddedHelper& rDocPersist,
105 SvXMLEmbeddedObjectHelperMode eCreateMode,
106 bool bDirect = true );
107 static SvXMLEmbeddedObjectHelper* Create(
108 ::comphelper::IEmbeddedHelper& rDocPersist,
109 SvXMLEmbeddedObjectHelperMode eCreateMode );
110 static void Destroy( SvXMLEmbeddedObjectHelper* pSvXMLEmbeddedObjectHelper );
112 // XEmbeddedObjectResolver
113 virtual OUString SAL_CALL resolveEmbeddedObjectURL( const OUString& aURL ) override;
115 // XNameAccess
116 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
117 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
118 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
120 // XNameAccess
121 virtual css::uno::Type SAL_CALL getElementType( ) override;
122 virtual sal_Bool SAL_CALL hasElements( ) override;
125 static void splitObjectURL(const OUString& aURLNoPar,
126 OUString& rContainerStorageName,
127 OUString& rObjectStorageName);
130 #endif // INCLUDED_SVX_XMLEOHLP_HXX
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */