fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / inc / xml / imagesdocumenthandler.hxx
blobfcdaa6a1874b9d38f48a57164f9cd4cffc28bb69
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_FRAMEWORK_INC_XML_IMAGESDOCUMENTHANDLER_HXX
21 #define INCLUDED_FRAMEWORK_INC_XML_IMAGESDOCUMENTHANDLER_HXX
23 #include <framework/fwedllapi.h>
25 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
27 #include <xml/imagesconfiguration.hxx>
28 #include <rtl/ustring.hxx>
29 #include <cppuhelper/implbase1.hxx>
31 #include <unordered_map>
32 #include <stdtypes.h>
34 namespace framework{
36 // Hash code function for using in all hash maps of follow implementation.
38 class OReadImagesDocumentHandler : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
40 public:
41 enum Image_XML_Entry
43 IMG_ELEMENT_IMAGECONTAINER,
44 IMG_ELEMENT_IMAGES,
45 IMG_ELEMENT_ENTRY,
46 IMG_ELEMENT_EXTERNALIMAGES,
47 IMG_ELEMENT_EXTERNALENTRY,
48 IMG_ATTRIBUTE_HREF,
49 IMG_ATTRIBUTE_MASKCOLOR,
50 IMG_ATTRIBUTE_COMMAND,
51 IMG_ATTRIBUTE_BITMAPINDEX,
52 IMG_ATTRIBUTE_MASKURL,
53 IMG_ATTRIBUTE_MASKMODE,
54 IMG_ATTRIBUTE_HIGHCONTRASTURL,
55 IMG_ATTRIBUTE_HIGHCONTRASTMASKURL,
56 IMG_XML_ENTRY_COUNT
59 enum Image_XML_Namespace
61 IMG_NS_IMAGE,
62 IMG_NS_XLINK,
63 TBL_XML_NAMESPACES_COUNT
66 OReadImagesDocumentHandler( ImageListsDescriptor& aItems );
67 virtual ~OReadImagesDocumentHandler();
69 // XDocumentHandler
70 virtual void SAL_CALL startDocument()
71 throw ( ::com::sun::star::xml::sax::SAXException,
72 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
74 virtual void SAL_CALL endDocument()
75 throw( ::com::sun::star::xml::sax::SAXException,
76 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
78 virtual void SAL_CALL startElement(
79 const OUString& aName,
80 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
81 throw (::com::sun::star::xml::sax::SAXException,
82 ::com::sun::star::uno::RuntimeException,
83 std::exception) SAL_OVERRIDE;
85 virtual void SAL_CALL endElement(const OUString& aName)
86 throw (::com::sun::star::xml::sax::SAXException,
87 ::com::sun::star::uno::RuntimeException,
88 std::exception) SAL_OVERRIDE;
90 virtual void SAL_CALL characters(const OUString& aChars)
91 throw( ::com::sun::star::xml::sax::SAXException,
92 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
94 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces)
95 throw( ::com::sun::star::xml::sax::SAXException,
96 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
98 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
99 const OUString& aData)
100 throw( ::com::sun::star::xml::sax::SAXException,
101 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
103 virtual void SAL_CALL setDocumentLocator(
104 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
105 throw( ::com::sun::star::xml::sax::SAXException,
106 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
108 private:
109 OUString getErrorLineString();
111 class ImageHashMap : public std::unordered_map< OUString ,
112 Image_XML_Entry ,
113 OUStringHash,
114 std::equal_to< OUString > >
116 public:
117 inline void free()
119 ImageHashMap().swap( *this );// get rid of reserved capacity
123 bool m_bImageContainerStartFound;
124 bool m_bImageContainerEndFound;
125 bool m_bImagesStartFound;
126 bool m_bImagesEndFound;
127 bool m_bImageStartFound;
128 bool m_bExternalImagesStartFound;
129 bool m_bExternalImagesEndFound;
130 bool m_bExternalImageStartFound;
131 sal_Int32 m_nHashMaskModeBitmap;
132 sal_Int32 m_nHashMaskModeColor;
133 ImageHashMap m_aImageMap;
134 ImageListsDescriptor& m_aImageList;
135 ImageListItemDescriptor* m_pImages;
136 ExternalImageItemListDescriptor* m_pExternalImages;
137 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
140 class OWriteImagesDocumentHandler
142 public:
143 OWriteImagesDocumentHandler(
144 const ImageListsDescriptor& aItems,
145 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
146 virtual ~OWriteImagesDocumentHandler();
148 void WriteImagesDocument() throw
149 ( ::com::sun::star::xml::sax::SAXException,
150 ::com::sun::star::uno::RuntimeException );
152 protected:
153 void WriteImageList( const ImageListItemDescriptor* ) throw
154 ( ::com::sun::star::xml::sax::SAXException,
155 ::com::sun::star::uno::RuntimeException );
157 void WriteExternalImageList( const ExternalImageItemListDescriptor* ) throw
158 ( ::com::sun::star::xml::sax::SAXException,
159 ::com::sun::star::uno::RuntimeException );
161 void WriteImage( const ImageItemDescriptor* ) throw
162 ( ::com::sun::star::xml::sax::SAXException,
163 ::com::sun::star::uno::RuntimeException );
165 void WriteExternalImage( const ExternalImageItemDescriptor* ) throw
166 ( ::com::sun::star::xml::sax::SAXException,
167 ::com::sun::star::uno::RuntimeException );
169 const ImageListsDescriptor& m_aImageListsItems;
170 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
171 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
172 OUString m_aXMLXlinkNS;
173 OUString m_aXMLImageNS;
174 OUString m_aAttributeType;
175 OUString m_aAttributeXlinkType;
176 OUString m_aAttributeValueSimple;
179 } // namespace framework
181 #endif
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */