Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svx / xmlgrhlp.hxx
blobb1a5021c62373114d02970a23a097cd72b2ca6ca
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlgrhlp.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLGRHLP_HXX
32 #define _XMLGRHLP_HXX
34 #ifndef _CPPUHELPER_COMPBASE2_HXX_
35 #include <cppuhelper/compbase2.hxx>
36 #endif
38 #include <bf_so3/svstor.hxx>
40 #ifndef _BF_GOODIES_GRAPHICOBJECT_HXX
41 #include <bf_goodies/graphicobject.hxx>
42 #endif
43 #include <vector>
44 #include <set>
45 #include <utility>
47 #ifndef _COM_SUN_STAR_DOCUMENT_XGRAPHICOBJECTRESOLVER_HPP_
48 #include <com/sun/star/document/XGraphicObjectResolver.hpp>
49 #endif
50 #ifndef _COM_SUN_STAR_DOCUMENT_XBINARYSTREAMRESOLVER_HPP_
51 #include <com/sun/star/document/XBinaryStreamResolver.hpp>
52 #endif
53 class SotStorage;
54 namespace binfilter {
56 // ----------------------
57 // - SvXMLGraphicHelper -
58 // ----------------------
60 enum SvXMLGraphicHelperMode
62 GRAPHICHELPER_MODE_READ = 0,
63 GRAPHICHELPER_MODE_WRITE = 1
66 // ----------------------
67 // - SvXMLGraphicHelper -
68 // ----------------------
71 class SvXMLGraphicHelper : public ::cppu::WeakComponentImplHelper2< ::com::sun::star::document::XGraphicObjectResolver,
72 ::com::sun::star::document::XBinaryStreamResolver >
74 private:
76 typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > URLPair;
77 typedef ::std::vector< URLPair > URLPairVector;
78 typedef ::std::vector< BfGraphicObject > GraphicObjectVector;
79 typedef ::std::set< ::rtl::OUString > URLSet;
80 typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > > GraphicOutputStreamVector;
82 ::osl::Mutex maMutex;
83 SotStorage* mpRootStorage;
84 SotStorageRef mxGraphicStorage;
85 ::rtl::OUString maCurStorageName;
86 URLPairVector maGrfURLs;
87 GraphicObjectVector maGrfObjs;
88 GraphicOutputStreamVector maGrfStms;
89 URLSet maURLSet;
90 SvXMLGraphicHelperMode meCreateMode;
91 sal_Bool mbDirect;
93 sal_Bool ImplGetStreamNames( const ::rtl::OUString& rURLStr,
94 ::rtl::OUString& rPictureStorageName,
95 ::rtl::OUString& rPictureStreamName );
96 SotStorageRef ImplGetGraphicStorage( const ::rtl::OUString& rPictureStorageName );
97 SotStorageStreamRef ImplGetGraphicStream( const ::rtl::OUString& rPictureStorageName,
98 const ::rtl::OUString& rPictureStreamName,
99 BOOL bTruncate );
100 String ImplGetGraphicMimeType( const String& rFileName ) const;
101 Graphic ImplReadGraphic( const ::rtl::OUString& rPictureStorageName,
102 const ::rtl::OUString& rPictureStreamName );
103 sal_Bool ImplWriteGraphic( const ::rtl::OUString& rPictureStorageName,
104 const ::rtl::OUString& rPictureStreamName,
105 const ::rtl::OUString& rGraphicId );
106 void ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, sal_uInt32 nInsertPos );
108 protected:
109 SvXMLGraphicHelper();
110 ~SvXMLGraphicHelper();
111 void Init( SotStorage* pXMLStorage,
112 SvXMLGraphicHelperMode eCreateMode,
113 BOOL bDirect );
115 virtual void SAL_CALL disposing();
117 public:
118 SvXMLGraphicHelper( SvXMLGraphicHelperMode eCreateMode );
120 static SvXMLGraphicHelper* Create( SotStorage& rXMLStorage,
121 SvXMLGraphicHelperMode eCreateMode,
122 BOOL bDirect = TRUE );
123 static SvXMLGraphicHelper* Create( SvXMLGraphicHelperMode eCreateMode );
125 static void Destroy( SvXMLGraphicHelper* pSvXMLGraphicHelper );
127 void Flush();
129 public:
131 // XGraphicObjectResolver
132 virtual ::rtl::OUString SAL_CALL resolveGraphicObjectURL( const ::rtl::OUString& aURL ) throw(::com::sun::star::uno::RuntimeException);
134 // XBinaryStreamResolver
135 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( const ::rtl::OUString& rURL ) throw (::com::sun::star::uno::RuntimeException);
136 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL createOutputStream( ) throw (::com::sun::star::uno::RuntimeException);
137 virtual ::rtl::OUString SAL_CALL resolveOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rxBinaryStream ) throw (::com::sun::star::uno::RuntimeException);
140 }//end of namespace binfilter
141 #endif