Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_
30 : : #define FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_
31 : :
32 : : #include <framework/fwedllapi.h>
33 : :
34 : : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
35 : :
36 : : #include <xml/imagesconfiguration.hxx>
37 : : #include <threadhelp/threadhelpbase.hxx>
38 : : #include <rtl/ustring.hxx>
39 : : #include <cppuhelper/implbase1.hxx>
40 : :
41 : : #include <boost/unordered_map.hpp>
42 : : #include <stdtypes.h>
43 : :
44 : : namespace framework{
45 : :
46 : : //*****************************************************************************************************************
47 : : // Hash code function for using in all hash maps of follow implementation.
48 : :
49 : : class OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
50 : : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
51 : : {
52 : : public:
53 : : enum Image_XML_Entry
54 : : {
55 : : IMG_ELEMENT_IMAGECONTAINER,
56 : : IMG_ELEMENT_IMAGES,
57 : : IMG_ELEMENT_ENTRY,
58 : : IMG_ELEMENT_EXTERNALIMAGES,
59 : : IMG_ELEMENT_EXTERNALENTRY,
60 : : IMG_ATTRIBUTE_HREF,
61 : : IMG_ATTRIBUTE_MASKCOLOR,
62 : : IMG_ATTRIBUTE_COMMAND,
63 : : IMG_ATTRIBUTE_BITMAPINDEX,
64 : : IMG_ATTRIBUTE_MASKURL,
65 : : IMG_ATTRIBUTE_MASKMODE,
66 : : IMG_ATTRIBUTE_HIGHCONTRASTURL,
67 : : IMG_ATTRIBUTE_HIGHCONTRASTMASKURL,
68 : : IMG_XML_ENTRY_COUNT
69 : : };
70 : :
71 : : enum Image_XML_Namespace
72 : : {
73 : : IMG_NS_IMAGE,
74 : : IMG_NS_XLINK,
75 : : TBL_XML_NAMESPACES_COUNT
76 : : };
77 : :
78 : : OReadImagesDocumentHandler( ImageListsDescriptor& aItems );
79 : : virtual ~OReadImagesDocumentHandler();
80 : :
81 : : // XDocumentHandler
82 : : virtual void SAL_CALL startDocument(void)
83 : : throw ( ::com::sun::star::xml::sax::SAXException,
84 : : ::com::sun::star::uno::RuntimeException );
85 : :
86 : : virtual void SAL_CALL endDocument(void)
87 : : throw( ::com::sun::star::xml::sax::SAXException,
88 : : ::com::sun::star::uno::RuntimeException );
89 : :
90 : : virtual void SAL_CALL startElement(
91 : : const rtl::OUString& aName,
92 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
93 : : throw( ::com::sun::star::xml::sax::SAXException,
94 : : ::com::sun::star::uno::RuntimeException );
95 : :
96 : : virtual void SAL_CALL endElement(const rtl::OUString& aName)
97 : : throw( ::com::sun::star::xml::sax::SAXException,
98 : : ::com::sun::star::uno::RuntimeException );
99 : :
100 : : virtual void SAL_CALL characters(const rtl::OUString& aChars)
101 : : throw( ::com::sun::star::xml::sax::SAXException,
102 : : ::com::sun::star::uno::RuntimeException );
103 : :
104 : : virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
105 : : throw( ::com::sun::star::xml::sax::SAXException,
106 : : ::com::sun::star::uno::RuntimeException );
107 : :
108 : : virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
109 : : const rtl::OUString& aData)
110 : : throw( ::com::sun::star::xml::sax::SAXException,
111 : : ::com::sun::star::uno::RuntimeException );
112 : :
113 : : virtual void SAL_CALL setDocumentLocator(
114 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
115 : : throw( ::com::sun::star::xml::sax::SAXException,
116 : : ::com::sun::star::uno::RuntimeException );
117 : :
118 : : private:
119 : : ::rtl::OUString getErrorLineString();
120 : :
121 [ # # ]: 0 : class ImageHashMap : public ::boost::unordered_map< ::rtl::OUString ,
122 : : Image_XML_Entry ,
123 : : OUStringHashCode ,
124 : : ::std::equal_to< ::rtl::OUString > >
125 : : {
126 : : public:
127 : : inline void free()
128 : : {
129 : : ImageHashMap().swap( *this );
130 : : }
131 : : };
132 : :
133 : : sal_Bool m_bImageContainerStartFound;
134 : : sal_Bool m_bImageContainerEndFound;
135 : : sal_Bool m_bImagesStartFound;
136 : : sal_Bool m_bImagesEndFound;
137 : : sal_Bool m_bImageStartFound;
138 : : sal_Bool m_bExternalImagesStartFound;
139 : : sal_Bool m_bExternalImagesEndFound;
140 : : sal_Bool m_bExternalImageStartFound;
141 : : sal_Int32 m_nHashMaskModeBitmap;
142 : : sal_Int32 m_nHashMaskModeColor;
143 : : ImageHashMap m_aImageMap;
144 : : ImageListsDescriptor& m_aImageList;
145 : : ImageListItemDescriptor* m_pImages;
146 : : ExternalImageItemListDescriptor* m_pExternalImages;
147 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
148 : : };
149 : :
150 : : class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
151 : : {
152 : : public:
153 : : OWriteImagesDocumentHandler(
154 : : const ImageListsDescriptor& aItems,
155 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
156 : : virtual ~OWriteImagesDocumentHandler();
157 : :
158 : : void WriteImagesDocument() throw
159 : : ( ::com::sun::star::xml::sax::SAXException,
160 : : ::com::sun::star::uno::RuntimeException );
161 : :
162 : : protected:
163 : : virtual void WriteImageList( const ImageListItemDescriptor* ) throw
164 : : ( ::com::sun::star::xml::sax::SAXException,
165 : : ::com::sun::star::uno::RuntimeException );
166 : :
167 : : virtual void WriteExternalImageList( const ExternalImageItemListDescriptor* ) throw
168 : : ( ::com::sun::star::xml::sax::SAXException,
169 : : ::com::sun::star::uno::RuntimeException );
170 : :
171 : : virtual void WriteImage( const ImageItemDescriptor* ) throw
172 : : ( ::com::sun::star::xml::sax::SAXException,
173 : : ::com::sun::star::uno::RuntimeException );
174 : :
175 : : virtual void WriteExternalImage( const ExternalImageItemDescriptor* ) throw
176 : : ( ::com::sun::star::xml::sax::SAXException,
177 : : ::com::sun::star::uno::RuntimeException );
178 : :
179 : : const ImageListsDescriptor& m_aImageListsItems;
180 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
181 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
182 : : ::rtl::OUString m_aXMLXlinkNS;
183 : : ::rtl::OUString m_aXMLImageNS;
184 : : ::rtl::OUString m_aAttributeType;
185 : : ::rtl::OUString m_aAttributeXlinkType;
186 : : ::rtl::OUString m_aAttributeValueSimple;
187 : : };
188 : :
189 : : } // namespace framework
190 : :
191 : : #endif
192 : :
193 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|