merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / xml / imagesdocumenthandler.hxx
blob52aa6d8e33ea5036ec8883f97ab2d53097a5622b
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.6 $
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_XML_IMAGEDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_XML_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 <xml/imagesconfiguration.hxx>
46 #include <threadhelp/threadhelpbase.hxx>
47 #include <rtl/ustring.hxx>
48 #include <cppuhelper/implbase1.hxx>
50 #include <hash_map>
51 #include <stdtypes.h>
53 //_________________________________________________________________________________________________________________
54 // namespace
55 //_________________________________________________________________________________________________________________
57 namespace framework{
59 //*****************************************************************************************************************
60 // Hash code function for using in all hash maps of follow implementation.
62 class OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
63 public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
65 public:
66 enum Image_XML_Entry
68 IMG_ELEMENT_IMAGECONTAINER,
69 IMG_ELEMENT_IMAGES,
70 IMG_ELEMENT_ENTRY,
71 IMG_ELEMENT_EXTERNALIMAGES,
72 IMG_ELEMENT_EXTERNALENTRY,
73 IMG_ATTRIBUTE_HREF,
74 IMG_ATTRIBUTE_MASKCOLOR,
75 IMG_ATTRIBUTE_COMMAND,
76 IMG_ATTRIBUTE_BITMAPINDEX,
77 IMG_ATTRIBUTE_MASKURL,
78 IMG_ATTRIBUTE_MASKMODE,
79 IMG_ATTRIBUTE_HIGHCONTRASTURL,
80 IMG_ATTRIBUTE_HIGHCONTRASTMASKURL,
81 IMG_XML_ENTRY_COUNT
84 enum Image_XML_Namespace
86 IMG_NS_IMAGE,
87 IMG_NS_XLINK,
88 TBL_XML_NAMESPACES_COUNT
91 OReadImagesDocumentHandler( ImageListsDescriptor& aItems );
92 virtual ~OReadImagesDocumentHandler();
94 // XDocumentHandler
95 virtual void SAL_CALL startDocument(void)
96 throw ( ::com::sun::star::xml::sax::SAXException,
97 ::com::sun::star::uno::RuntimeException );
99 virtual void SAL_CALL endDocument(void)
100 throw( ::com::sun::star::xml::sax::SAXException,
101 ::com::sun::star::uno::RuntimeException );
103 virtual void SAL_CALL startElement(
104 const rtl::OUString& aName,
105 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
106 throw( ::com::sun::star::xml::sax::SAXException,
107 ::com::sun::star::uno::RuntimeException );
109 virtual void SAL_CALL endElement(const rtl::OUString& aName)
110 throw( ::com::sun::star::xml::sax::SAXException,
111 ::com::sun::star::uno::RuntimeException );
113 virtual void SAL_CALL characters(const rtl::OUString& aChars)
114 throw( ::com::sun::star::xml::sax::SAXException,
115 ::com::sun::star::uno::RuntimeException );
117 virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
118 throw( ::com::sun::star::xml::sax::SAXException,
119 ::com::sun::star::uno::RuntimeException );
121 virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
122 const rtl::OUString& aData)
123 throw( ::com::sun::star::xml::sax::SAXException,
124 ::com::sun::star::uno::RuntimeException );
126 virtual void SAL_CALL setDocumentLocator(
127 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
128 throw( ::com::sun::star::xml::sax::SAXException,
129 ::com::sun::star::uno::RuntimeException );
131 private:
132 ::rtl::OUString getErrorLineString();
134 class ImageHashMap : public ::std::hash_map< ::rtl::OUString ,
135 Image_XML_Entry ,
136 OUStringHashCode ,
137 ::std::equal_to< ::rtl::OUString > >
139 public:
140 inline void free()
142 ImageHashMap().swap( *this );
146 sal_Bool m_bImageContainerStartFound;
147 sal_Bool m_bImageContainerEndFound;
148 sal_Bool m_bImagesStartFound;
149 sal_Bool m_bImagesEndFound;
150 sal_Bool m_bImageStartFound;
151 sal_Bool m_bExternalImagesStartFound;
152 sal_Bool m_bExternalImagesEndFound;
153 sal_Bool m_bExternalImageStartFound;
154 sal_Int32 m_nHashMaskModeBitmap;
155 sal_Int32 m_nHashMaskModeColor;
156 ImageHashMap m_aImageMap;
157 ImageListsDescriptor& m_aImageList;
158 ImageListItemDescriptor* m_pImages;
159 ExternalImageItemListDescriptor* m_pExternalImages;
160 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
163 class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
165 public:
166 OWriteImagesDocumentHandler(
167 const ImageListsDescriptor& aItems,
168 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
169 virtual ~OWriteImagesDocumentHandler();
171 void WriteImagesDocument() throw
172 ( ::com::sun::star::xml::sax::SAXException,
173 ::com::sun::star::uno::RuntimeException );
175 protected:
176 virtual void WriteImageList( const ImageListItemDescriptor* ) throw
177 ( ::com::sun::star::xml::sax::SAXException,
178 ::com::sun::star::uno::RuntimeException );
180 virtual void WriteExternalImageList( const ExternalImageItemListDescriptor* ) throw
181 ( ::com::sun::star::xml::sax::SAXException,
182 ::com::sun::star::uno::RuntimeException );
184 virtual void WriteImage( const ImageItemDescriptor* ) throw
185 ( ::com::sun::star::xml::sax::SAXException,
186 ::com::sun::star::uno::RuntimeException );
188 virtual void WriteExternalImage( const ExternalImageItemDescriptor* ) throw
189 ( ::com::sun::star::xml::sax::SAXException,
190 ::com::sun::star::uno::RuntimeException );
192 const ImageListsDescriptor& m_aImageListsItems;
193 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
194 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
195 ::rtl::OUString m_aXMLXlinkNS;
196 ::rtl::OUString m_aXMLImageNS;
197 ::rtl::OUString m_aAttributeType;
198 ::rtl::OUString m_aAttributeXlinkType;
199 ::rtl::OUString m_aAttributeValueSimple;
202 } // namespace framework
204 #endif