Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / xmleohlp.hxx
blobf5680edb74afadfcb9a9af9046724b54dcc6ea79
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/compbase2.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>
33 // - SvXMLEmbeddedObjectHelper -
36 enum SvXMLEmbeddedObjectHelperMode
38 EMBEDDEDOBJECTHELPER_MODE_READ = 0,
39 EMBEDDEDOBJECTHELPER_MODE_WRITE = 1
43 // - SvXMLEmbeddedObjectHelper -
46 namespace comphelper {
47 class IEmbeddedHelper;
49 class SvGlobalName;
50 struct OUStringLess;
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;
59 private:
61 ::osl::Mutex maMutex;
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
72 // objects
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,
81 bool *pGraphicRepl=0,
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,
89 OUString& rObjName,
90 const SvGlobalName *pClassId,
91 SvStream* pTemp );
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 );
99 protected:
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;
109 public:
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 );
124 void Flush();
126 // XEmbeddedObjectResolver
127 virtual OUString SAL_CALL resolveEmbeddedObjectURL( const OUString& aURL ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 // XNameAccess
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;
134 // XNameAccess
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);
144 #endif
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */