sync master with lastest vba changes
[ooovba.git] / framework / inc / classes / imagesdocumenthandler.hxx
blob4d9a91e8811f0f6c6dfb358f3705f18abb7733bb
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: imagesdocumenthandler.hxx,v $
10 * $Revision: 1.5 $
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 __FRAMEWORK_CLASSES_IMAGEDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_CLASSES_IMAGEDOCUMENTHANDLER_HXX_
34 //_________________________________________________________________________________________________________________
35 // interface includes
36 //_________________________________________________________________________________________________________________
38 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
39 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
40 #endif
42 //_________________________________________________________________________________________________________________
43 // other includes
44 //_________________________________________________________________________________________________________________
45 #include <classes/imagesconfiguration.hxx>
46 #include <threadhelp/threadhelpbase.hxx>
47 #include <rtl/ustring.hxx>
48 #include <cppuhelper/weak.hxx>
50 #ifndef __SGI_STL_HASH_MAP
51 #include <hash_map>
52 #endif
53 #include <stdtypes.h>
55 //_________________________________________________________________________________________________________________
56 // namespace
57 //_________________________________________________________________________________________________________________
59 namespace framework{
61 //*****************************************************************************************************************
62 // Hash code function for using in all hash maps of follow implementation.
64 class OReadImagesDocumentHandler : public ::com::sun::star::xml::sax::XDocumentHandler,
65 private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
66 public ::cppu::OWeakObject
68 public:
69 enum Image_XML_Entry
71 IMG_ELEMENT_IMAGECONTAINER,
72 IMG_ELEMENT_IMAGES,
73 IMG_ELEMENT_ENTRY,
74 IMG_ELEMENT_EXTERNALIMAGES,
75 IMG_ELEMENT_EXTERNALENTRY,
76 IMG_ATTRIBUTE_HREF,
77 IMG_ATTRIBUTE_MASKCOLOR,
78 IMG_ATTRIBUTE_COMMAND,
79 IMG_ATTRIBUTE_BITMAPINDEX,
80 IMG_ATTRIBUTE_MASKURL,
81 IMG_ATTRIBUTE_MASKMODE,
82 IMG_ATTRIBUTE_HIGHCONTRASTURL,
83 IMG_ATTRIBUTE_HIGHCONTRASTMASKURL,
84 IMG_XML_ENTRY_COUNT
87 enum Image_XML_Namespace
89 IMG_NS_IMAGE,
90 IMG_NS_XLINK,
91 TBL_XML_NAMESPACES_COUNT
94 OReadImagesDocumentHandler( ImageListsDescriptor& aItems );
95 virtual ~OReadImagesDocumentHandler();
97 // XInterface
98 virtual void SAL_CALL acquire() throw()
99 { OWeakObject::acquire(); }
100 virtual void SAL_CALL release() throw()
101 { OWeakObject::release(); }
102 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
103 const ::com::sun::star::uno::Type & rType ) throw( ::com::sun::star::uno::RuntimeException );
105 // XDocumentHandler
106 virtual void SAL_CALL startDocument(void)
107 throw ( ::com::sun::star::xml::sax::SAXException,
108 ::com::sun::star::uno::RuntimeException );
110 virtual void SAL_CALL endDocument(void)
111 throw( ::com::sun::star::xml::sax::SAXException,
112 ::com::sun::star::uno::RuntimeException );
114 virtual void SAL_CALL startElement(
115 const rtl::OUString& aName,
116 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
117 throw( ::com::sun::star::xml::sax::SAXException,
118 ::com::sun::star::uno::RuntimeException );
120 virtual void SAL_CALL endElement(const rtl::OUString& aName)
121 throw( ::com::sun::star::xml::sax::SAXException,
122 ::com::sun::star::uno::RuntimeException );
124 virtual void SAL_CALL characters(const rtl::OUString& aChars)
125 throw( ::com::sun::star::xml::sax::SAXException,
126 ::com::sun::star::uno::RuntimeException );
128 virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
129 throw( ::com::sun::star::xml::sax::SAXException,
130 ::com::sun::star::uno::RuntimeException );
132 virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
133 const rtl::OUString& aData)
134 throw( ::com::sun::star::xml::sax::SAXException,
135 ::com::sun::star::uno::RuntimeException );
137 virtual void SAL_CALL setDocumentLocator(
138 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
139 throw( ::com::sun::star::xml::sax::SAXException,
140 ::com::sun::star::uno::RuntimeException );
142 private:
143 ::rtl::OUString getErrorLineString();
145 class ImageHashMap : public ::std::hash_map< ::rtl::OUString ,
146 Image_XML_Entry ,
147 OUStringHashCode ,
148 ::std::equal_to< ::rtl::OUString > >
150 public:
151 inline void free()
153 ImageHashMap().swap( *this );
157 sal_Bool m_bImageContainerStartFound;
158 sal_Bool m_bImageContainerEndFound;
159 sal_Bool m_bImagesStartFound;
160 sal_Bool m_bImagesEndFound;
161 sal_Bool m_bImageStartFound;
162 sal_Bool m_bExternalImagesStartFound;
163 sal_Bool m_bExternalImagesEndFound;
164 sal_Bool m_bExternalImageStartFound;
165 sal_Int32 m_nHashMaskModeBitmap;
166 sal_Int32 m_nHashMaskModeColor;
167 ImageHashMap m_aImageMap;
168 ImageListsDescriptor& m_aImageList;
169 ImageListItemDescriptor* m_pImages;
170 ExternalImageItemListDescriptor* m_pExternalImages;
171 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
174 class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
176 public:
177 OWriteImagesDocumentHandler(
178 const ImageListsDescriptor& aItems,
179 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
180 virtual ~OWriteImagesDocumentHandler();
182 void WriteImagesDocument() throw
183 ( ::com::sun::star::xml::sax::SAXException,
184 ::com::sun::star::uno::RuntimeException );
186 protected:
187 virtual void WriteImageList( const ImageListItemDescriptor* ) throw
188 ( ::com::sun::star::xml::sax::SAXException,
189 ::com::sun::star::uno::RuntimeException );
191 virtual void WriteExternalImageList( const ExternalImageItemListDescriptor* ) throw
192 ( ::com::sun::star::xml::sax::SAXException,
193 ::com::sun::star::uno::RuntimeException );
195 virtual void WriteImage( const ImageItemDescriptor* ) throw
196 ( ::com::sun::star::xml::sax::SAXException,
197 ::com::sun::star::uno::RuntimeException );
199 virtual void WriteExternalImage( const ExternalImageItemDescriptor* ) throw
200 ( ::com::sun::star::xml::sax::SAXException,
201 ::com::sun::star::uno::RuntimeException );
203 const ImageListsDescriptor& m_aImageListsItems;
204 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
205 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
206 ::rtl::OUString m_aXMLXlinkNS;
207 ::rtl::OUString m_aXMLImageNS;
208 ::rtl::OUString m_aAttributeType;
209 ::rtl::OUString m_aAttributeXlinkType;
210 ::rtl::OUString m_aAttributeValueSimple;
213 } // namespace framework
215 #endif