update credits
[LibreOffice.git] / framework / inc / xml / imagesdocumenthandler.hxx
blobfdc9f4cca025d932c947aabfd484de53b248d69b
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 FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_
21 #define FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_
23 #include <framework/fwedllapi.h>
25 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
27 #include <xml/imagesconfiguration.hxx>
28 #include <threadhelp/threadhelpbase.hxx>
29 #include <rtl/ustring.hxx>
30 #include <cppuhelper/implbase1.hxx>
32 #include <boost/unordered_map.hpp>
33 #include <stdtypes.h>
35 namespace framework{
37 //*****************************************************************************************************************
38 // Hash code function for using in all hash maps of follow implementation.
40 class OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
41 public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
43 public:
44 enum Image_XML_Entry
46 IMG_ELEMENT_IMAGECONTAINER,
47 IMG_ELEMENT_IMAGES,
48 IMG_ELEMENT_ENTRY,
49 IMG_ELEMENT_EXTERNALIMAGES,
50 IMG_ELEMENT_EXTERNALENTRY,
51 IMG_ATTRIBUTE_HREF,
52 IMG_ATTRIBUTE_MASKCOLOR,
53 IMG_ATTRIBUTE_COMMAND,
54 IMG_ATTRIBUTE_BITMAPINDEX,
55 IMG_ATTRIBUTE_MASKURL,
56 IMG_ATTRIBUTE_MASKMODE,
57 IMG_ATTRIBUTE_HIGHCONTRASTURL,
58 IMG_ATTRIBUTE_HIGHCONTRASTMASKURL,
59 IMG_XML_ENTRY_COUNT
62 enum Image_XML_Namespace
64 IMG_NS_IMAGE,
65 IMG_NS_XLINK,
66 TBL_XML_NAMESPACES_COUNT
69 OReadImagesDocumentHandler( ImageListsDescriptor& aItems );
70 virtual ~OReadImagesDocumentHandler();
72 // XDocumentHandler
73 virtual void SAL_CALL startDocument(void)
74 throw ( ::com::sun::star::xml::sax::SAXException,
75 ::com::sun::star::uno::RuntimeException );
77 virtual void SAL_CALL endDocument(void)
78 throw( ::com::sun::star::xml::sax::SAXException,
79 ::com::sun::star::uno::RuntimeException );
81 virtual void SAL_CALL startElement(
82 const OUString& aName,
83 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
84 throw( ::com::sun::star::xml::sax::SAXException,
85 ::com::sun::star::uno::RuntimeException );
87 virtual void SAL_CALL endElement(const OUString& aName)
88 throw( ::com::sun::star::xml::sax::SAXException,
89 ::com::sun::star::uno::RuntimeException );
91 virtual void SAL_CALL characters(const OUString& aChars)
92 throw( ::com::sun::star::xml::sax::SAXException,
93 ::com::sun::star::uno::RuntimeException );
95 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces)
96 throw( ::com::sun::star::xml::sax::SAXException,
97 ::com::sun::star::uno::RuntimeException );
99 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
100 const OUString& aData)
101 throw( ::com::sun::star::xml::sax::SAXException,
102 ::com::sun::star::uno::RuntimeException );
104 virtual void SAL_CALL setDocumentLocator(
105 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
106 throw( ::com::sun::star::xml::sax::SAXException,
107 ::com::sun::star::uno::RuntimeException );
109 private:
110 OUString getErrorLineString();
112 class ImageHashMap : public ::boost::unordered_map< OUString ,
113 Image_XML_Entry ,
114 OUStringHash,
115 ::std::equal_to< OUString > >
117 public:
118 inline void free()
120 ImageHashMap().swap( *this );
124 sal_Bool m_bImageContainerStartFound;
125 sal_Bool m_bImageContainerEndFound;
126 sal_Bool m_bImagesStartFound;
127 sal_Bool m_bImagesEndFound;
128 sal_Bool m_bImageStartFound;
129 sal_Bool m_bExternalImagesStartFound;
130 sal_Bool m_bExternalImagesEndFound;
131 sal_Bool m_bExternalImageStartFound;
132 sal_Int32 m_nHashMaskModeBitmap;
133 sal_Int32 m_nHashMaskModeColor;
134 ImageHashMap m_aImageMap;
135 ImageListsDescriptor& m_aImageList;
136 ImageListItemDescriptor* m_pImages;
137 ExternalImageItemListDescriptor* m_pExternalImages;
138 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
141 class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
143 public:
144 OWriteImagesDocumentHandler(
145 const ImageListsDescriptor& aItems,
146 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
147 virtual ~OWriteImagesDocumentHandler();
149 void WriteImagesDocument() throw
150 ( ::com::sun::star::xml::sax::SAXException,
151 ::com::sun::star::uno::RuntimeException );
153 protected:
154 virtual void WriteImageList( const ImageListItemDescriptor* ) throw
155 ( ::com::sun::star::xml::sax::SAXException,
156 ::com::sun::star::uno::RuntimeException );
158 virtual void WriteExternalImageList( const ExternalImageItemListDescriptor* ) throw
159 ( ::com::sun::star::xml::sax::SAXException,
160 ::com::sun::star::uno::RuntimeException );
162 virtual void WriteImage( const ImageItemDescriptor* ) throw
163 ( ::com::sun::star::xml::sax::SAXException,
164 ::com::sun::star::uno::RuntimeException );
166 virtual void WriteExternalImage( const ExternalImageItemDescriptor* ) throw
167 ( ::com::sun::star::xml::sax::SAXException,
168 ::com::sun::star::uno::RuntimeException );
170 const ImageListsDescriptor& m_aImageListsItems;
171 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
172 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
173 OUString m_aXMLXlinkNS;
174 OUString m_aXMLImageNS;
175 OUString m_aAttributeType;
176 OUString m_aAttributeXlinkType;
177 OUString m_aAttributeValueSimple;
180 } // namespace framework
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */