1*f8e07b45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f8e07b45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f8e07b45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f8e07b45SAndrew Rist * distributed with this work for additional information 6*f8e07b45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f8e07b45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f8e07b45SAndrew Rist * "License"); you may not use this file except in compliance 9*f8e07b45SAndrew Rist * with the License. You may obtain a copy of the License at 10*f8e07b45SAndrew Rist * 11*f8e07b45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f8e07b45SAndrew Rist * 13*f8e07b45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f8e07b45SAndrew Rist * software distributed under the License is distributed on an 15*f8e07b45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f8e07b45SAndrew Rist * KIND, either express or implied. See the License for the 17*f8e07b45SAndrew Rist * specific language governing permissions and limitations 18*f8e07b45SAndrew Rist * under the License. 19*f8e07b45SAndrew Rist * 20*f8e07b45SAndrew Rist *************************************************************/ 21*f8e07b45SAndrew Rist 22*f8e07b45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ 25cdf0e10cSrcweir #define FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <framework/fwedllapi.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir // interface includes 31cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 34cdf0e10cSrcweir 35cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 36cdf0e10cSrcweir // other includes 37cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 38cdf0e10cSrcweir #include <xml/imagesconfiguration.hxx> 39cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 40cdf0e10cSrcweir #include <rtl/ustring.hxx> 41cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <hash_map> 44cdf0e10cSrcweir #include <stdtypes.h> 45cdf0e10cSrcweir 46cdf0e10cSrcweir 47cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 48cdf0e10cSrcweir // namespace 49cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace framework{ 52cdf0e10cSrcweir 53cdf0e10cSrcweir //***************************************************************************************************************** 54cdf0e10cSrcweir // Hash code function for using in all hash maps of follow implementation. 55cdf0e10cSrcweir 56cdf0e10cSrcweir class OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. 57cdf0e10cSrcweir public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler > 58cdf0e10cSrcweir { 59cdf0e10cSrcweir public: 60cdf0e10cSrcweir enum Image_XML_Entry 61cdf0e10cSrcweir { 62cdf0e10cSrcweir IMG_ELEMENT_IMAGECONTAINER, 63cdf0e10cSrcweir IMG_ELEMENT_IMAGES, 64cdf0e10cSrcweir IMG_ELEMENT_ENTRY, 65cdf0e10cSrcweir IMG_ELEMENT_EXTERNALIMAGES, 66cdf0e10cSrcweir IMG_ELEMENT_EXTERNALENTRY, 67cdf0e10cSrcweir IMG_ATTRIBUTE_HREF, 68cdf0e10cSrcweir IMG_ATTRIBUTE_MASKCOLOR, 69cdf0e10cSrcweir IMG_ATTRIBUTE_COMMAND, 70cdf0e10cSrcweir IMG_ATTRIBUTE_BITMAPINDEX, 71cdf0e10cSrcweir IMG_ATTRIBUTE_MASKURL, 72cdf0e10cSrcweir IMG_ATTRIBUTE_MASKMODE, 73cdf0e10cSrcweir IMG_ATTRIBUTE_HIGHCONTRASTURL, 74cdf0e10cSrcweir IMG_ATTRIBUTE_HIGHCONTRASTMASKURL, 75cdf0e10cSrcweir IMG_XML_ENTRY_COUNT 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir 78cdf0e10cSrcweir enum Image_XML_Namespace 79cdf0e10cSrcweir { 80cdf0e10cSrcweir IMG_NS_IMAGE, 81cdf0e10cSrcweir IMG_NS_XLINK, 82cdf0e10cSrcweir TBL_XML_NAMESPACES_COUNT 83cdf0e10cSrcweir }; 84cdf0e10cSrcweir 85cdf0e10cSrcweir OReadImagesDocumentHandler( ImageListsDescriptor& aItems ); 86cdf0e10cSrcweir virtual ~OReadImagesDocumentHandler(); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // XDocumentHandler 89cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) 90cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 91cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 92cdf0e10cSrcweir 93cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) 94cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 95cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir virtual void SAL_CALL startElement( 98cdf0e10cSrcweir const rtl::OUString& aName, 99cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs) 100cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 101cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir virtual void SAL_CALL endElement(const rtl::OUString& aName) 104cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 105cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir virtual void SAL_CALL characters(const rtl::OUString& aChars) 108cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 109cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces) 112cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 113cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget, 116cdf0e10cSrcweir const rtl::OUString& aData) 117cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 118cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual void SAL_CALL setDocumentLocator( 121cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator) 122cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 123cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir private: 126cdf0e10cSrcweir ::rtl::OUString getErrorLineString(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir class ImageHashMap : public ::std::hash_map< ::rtl::OUString , 129cdf0e10cSrcweir Image_XML_Entry , 130cdf0e10cSrcweir OUStringHashCode , 131cdf0e10cSrcweir ::std::equal_to< ::rtl::OUString > > 132cdf0e10cSrcweir { 133cdf0e10cSrcweir public: 134cdf0e10cSrcweir inline void free() 135cdf0e10cSrcweir { 136cdf0e10cSrcweir ImageHashMap().swap( *this ); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir }; 139cdf0e10cSrcweir 140cdf0e10cSrcweir sal_Bool m_bImageContainerStartFound; 141cdf0e10cSrcweir sal_Bool m_bImageContainerEndFound; 142cdf0e10cSrcweir sal_Bool m_bImagesStartFound; 143cdf0e10cSrcweir sal_Bool m_bImagesEndFound; 144cdf0e10cSrcweir sal_Bool m_bImageStartFound; 145cdf0e10cSrcweir sal_Bool m_bExternalImagesStartFound; 146cdf0e10cSrcweir sal_Bool m_bExternalImagesEndFound; 147cdf0e10cSrcweir sal_Bool m_bExternalImageStartFound; 148cdf0e10cSrcweir sal_Int32 m_nHashMaskModeBitmap; 149cdf0e10cSrcweir sal_Int32 m_nHashMaskModeColor; 150cdf0e10cSrcweir ImageHashMap m_aImageMap; 151cdf0e10cSrcweir ImageListsDescriptor& m_aImageList; 152cdf0e10cSrcweir ImageListItemDescriptor* m_pImages; 153cdf0e10cSrcweir ExternalImageItemListDescriptor* m_pExternalImages; 154cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; 155cdf0e10cSrcweir }; 156cdf0e10cSrcweir 157cdf0e10cSrcweir class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. 158cdf0e10cSrcweir { 159cdf0e10cSrcweir public: 160cdf0e10cSrcweir OWriteImagesDocumentHandler( 161cdf0e10cSrcweir const ImageListsDescriptor& aItems, 162cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > ); 163cdf0e10cSrcweir virtual ~OWriteImagesDocumentHandler(); 164cdf0e10cSrcweir 165cdf0e10cSrcweir void WriteImagesDocument() throw 166cdf0e10cSrcweir ( ::com::sun::star::xml::sax::SAXException, 167cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir protected: 170cdf0e10cSrcweir virtual void WriteImageList( const ImageListItemDescriptor* ) throw 171cdf0e10cSrcweir ( ::com::sun::star::xml::sax::SAXException, 172cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir virtual void WriteExternalImageList( const ExternalImageItemListDescriptor* ) throw 175cdf0e10cSrcweir ( ::com::sun::star::xml::sax::SAXException, 176cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 177cdf0e10cSrcweir 178cdf0e10cSrcweir virtual void WriteImage( const ImageItemDescriptor* ) throw 179cdf0e10cSrcweir ( ::com::sun::star::xml::sax::SAXException, 180cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir virtual void WriteExternalImage( const ExternalImageItemDescriptor* ) throw 183cdf0e10cSrcweir ( ::com::sun::star::xml::sax::SAXException, 184cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 185cdf0e10cSrcweir 186cdf0e10cSrcweir const ImageListsDescriptor& m_aImageListsItems; 187cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; 188cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList; 189cdf0e10cSrcweir ::rtl::OUString m_aXMLXlinkNS; 190cdf0e10cSrcweir ::rtl::OUString m_aXMLImageNS; 191cdf0e10cSrcweir ::rtl::OUString m_aAttributeType; 192cdf0e10cSrcweir ::rtl::OUString m_aAttributeXlinkType; 193cdf0e10cSrcweir ::rtl::OUString m_aAttributeValueSimple; 194cdf0e10cSrcweir }; 195cdf0e10cSrcweir 196cdf0e10cSrcweir } // namespace framework 197cdf0e10cSrcweir 198cdf0e10cSrcweir #endif 199