1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: imagesdocumenthandler.hxx,v $
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 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
39 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
42 //_________________________________________________________________________________________________________________
44 //_________________________________________________________________________________________________________________
45 #include <xml/imagesconfiguration.hxx>
46 #include <threadhelp/threadhelpbase.hxx>
47 #include <rtl/ustring.hxx>
48 #include <cppuhelper/implbase1.hxx>
53 //_________________________________________________________________________________________________________________
55 //_________________________________________________________________________________________________________________
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
>
68 IMG_ELEMENT_IMAGECONTAINER
,
71 IMG_ELEMENT_EXTERNALIMAGES
,
72 IMG_ELEMENT_EXTERNALENTRY
,
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
,
84 enum Image_XML_Namespace
88 TBL_XML_NAMESPACES_COUNT
91 OReadImagesDocumentHandler( ImageListsDescriptor
& aItems
);
92 virtual ~OReadImagesDocumentHandler();
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
);
132 ::rtl::OUString
getErrorLineString();
134 class ImageHashMap
: public ::std::hash_map
< ::rtl::OUString
,
137 ::std::equal_to
< ::rtl::OUString
> >
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.
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
);
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