diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-23 08:15:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-23 14:49:04 +0200 |
commit | d367ee2f8c204f351072c0eb10259fd7aa497770 (patch) | |
tree | 351c016c0d0ef15a739fe8e766d9ae0b0c1edf72 /framework/source/xml | |
parent | bfe225b7003d119ff214cbaa771289de105c48d5 (diff) |
Simplify framework image manager
various bits are no longer used since
commit ca00697e3dae9a03573d11281fc8d9a4ee391d3d
Date: Tue Sep 8 04:57:32 2009 +0000
CWS-TOOLING: integrate CWS oj18
Change-Id: Iea57cee35026fd90f6a9aaf9927a80a646d722bb
Reviewed-on: https://gerrit.libreoffice.org/76147
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework/source/xml')
-rw-r--r-- | framework/source/xml/imagesdocumenthandler.cxx | 344 |
1 files changed, 3 insertions, 341 deletions
diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx index 927e52627e97..7005a07b89ac 100644 --- a/framework/source/xml/imagesdocumenthandler.cxx +++ b/framework/source/xml/imagesdocumenthandler.cxx @@ -43,8 +43,6 @@ using namespace ::com::sun::star::xml::sax; #define ELEMENT_NS_IMAGESCONTAINER "image:imagescontainer" #define ELEMENT_NS_IMAGES "image:images" #define ELEMENT_NS_ENTRY "image:entry" -#define ELEMENT_NS_EXTERNALIMAGES "image:externalimages" -#define ELEMENT_NS_EXTERNALENTRY "image:externalentry" #define ATTRIBUTE_HREF "href" #define ATTRIBUTE_MASKCOLOR "maskcolor" @@ -102,11 +100,9 @@ ImageXMLEntryProperty const ImagesEntries[OReadImagesDocumentHandler::IMG_XML_EN OReadImagesDocumentHandler::OReadImagesDocumentHandler( ImageListsDescriptor& aItems ) : m_aImageList( aItems ), - m_pImages( nullptr ), - m_pExternalImages( nullptr ) + m_pImages( nullptr ) { m_aImageList.pImageList = nullptr; - m_aImageList.pExternalImageList = nullptr; m_nHashMaskModeBitmap = OUString( ATTRIBUTE_MASKMODE_BITMAP ).hashCode(); m_nHashMaskModeColor = OUString( ATTRIBUTE_MASKMODE_COLOR ).hashCode(); @@ -200,86 +196,6 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( m_bImagesStartFound = true; m_pImages = new ImageListItemDescriptor; - - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) - { - pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); - if ( pImageEntry != m_aImageMap.end() ) - { - switch ( pImageEntry->second ) - { - case IMG_ATTRIBUTE_HREF: - { - m_pImages->aURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_MASKCOLOR: - { - OUString aColor = xAttribs->getValueByIndex( n ); - - if ( aColor.startsWith("#") ) - { - // the color value is given as #rrggbb and used the hexadecimal system!! - sal_uInt32 nColor = aColor.copy( 1 ).toUInt32( 16 ); - - m_pImages->aMaskColor = Color( nColor ); - } - } - break; - - case IMG_ATTRIBUTE_MASKURL: - { - m_pImages->aMaskURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_MASKMODE: - { - sal_Int32 nHashCode = xAttribs->getValueByIndex( n ).hashCode(); - if ( nHashCode == m_nHashMaskModeBitmap ) - m_pImages->nMaskMode = ImageMaskMode_Bitmap; - else if ( nHashCode == m_nHashMaskModeColor ) - m_pImages->nMaskMode = ImageMaskMode_Color; - else - { - delete m_pImages; - m_pImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Attribute image:maskmode must be 'maskcolor' or 'maskbitmap'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - } - break; - - case IMG_ATTRIBUTE_HIGHCONTRASTURL: - { - m_pImages->aHighContrastURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_HIGHCONTRASTMASKURL: - { - m_pImages->aHighContrastMaskURL = xAttribs->getValueByIndex( n ); - } - break; - - default: - break; - } - } - } // for - - if ( m_pImages->aURL.isEmpty() ) - { - delete m_pImages; - m_pImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Required attribute xlink:href must have a value!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } } break; @@ -301,7 +217,6 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( // Create new image item descriptor std::unique_ptr<ImageItemDescriptor> pItem(new ImageItemDescriptor); - pItem->nIndex = -1; // Read attributes for this image definition for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) @@ -317,126 +232,8 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( } break; - case IMG_ATTRIBUTE_BITMAPINDEX: - { - pItem->nIndex = xAttribs->getValueByIndex( n ).toInt32(); - } - break; - - default: - break; - } - } - } - - // Check required attribute "bitmap-index" - if ( pItem->nIndex < 0 ) - { - delete m_pImages; - m_pImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Required attribute 'image:bitmap-index' must have a value >= 0!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - // Check required attribute "command" - if ( pItem->aCommandURL.isEmpty() ) - { - delete m_pImages; - m_pImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Required attribute 'image:command' must have a value!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - m_pImages->pImageItemList->push_back( std::move(pItem) ); - } - break; - - case IMG_ELEMENT_EXTERNALIMAGES: - { - // Check that image:externalimages is embedded into image:imagecontainer - if ( !m_bImageContainerStartFound ) - { - delete m_pImages; - m_pImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Element 'image:externalimages' must be embedded into element 'image:imagecontainer'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - // Check that image:externalentry is NOT embedded into image:externalentry - if ( m_bExternalImagesStartFound ) - { - delete m_pImages; - m_pImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Element 'image:externalimages' cannot be embedded into 'image:externalimages'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - // Create unique external image container - m_bExternalImagesStartFound = true; - m_pExternalImages = new ExternalImageItemListDescriptor; - } - break; - - case IMG_ELEMENT_EXTERNALENTRY: - { - if ( !m_bExternalImagesStartFound ) - { - delete m_pImages; - delete m_pExternalImages; - m_pImages = nullptr; - m_pExternalImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Element 'image:externalentry' must be embedded into 'image:externalimages'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( m_bExternalImageStartFound ) - { - delete m_pImages; - delete m_pExternalImages; - m_pImages = nullptr; - m_pExternalImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Element 'image:externalentry' cannot be embedded into 'image:externalentry'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - m_bExternalImageStartFound = true; - - std::unique_ptr<ExternalImageItemDescriptor> pItem(new ExternalImageItemDescriptor); - - // Read attributes for this external image definition - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) - { - pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); - if ( pImageEntry != m_aImageMap.end() ) - { - switch ( pImageEntry->second ) - { - case IMG_ATTRIBUTE_COMMAND: - { - pItem->aCommandURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_HREF: - { - pItem->aURL = xAttribs->getValueByIndex( n ); - } - break; - default: - break; + break; } } } @@ -445,30 +242,14 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( if ( pItem->aCommandURL.isEmpty() ) { delete m_pImages; - delete m_pExternalImages; m_pImages = nullptr; - m_pExternalImages = nullptr; OUString aErrorMessage = getErrorLineString(); aErrorMessage += "Required attribute 'image:command' must have a value!"; throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - // Check required attribute "href" - if ( pItem->aURL.isEmpty() ) - { - delete m_pImages; - delete m_pExternalImages; - m_pImages = nullptr; - m_pExternalImages = nullptr; - - OUString aErrorMessage = getErrorLineString(); - aErrorMessage += "Required attribute 'xlink:href' must have a value!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( m_pExternalImages ) - m_pExternalImages->push_back( std::move(pItem) ); + m_pImages->pImageItemList->push_back( std::move(pItem) ); } break; @@ -505,24 +286,6 @@ void SAL_CALL OReadImagesDocumentHandler::endElement(const OUString& aName) } break; - case IMG_ELEMENT_EXTERNALIMAGES: - { - if ( m_pExternalImages && !m_aImageList.pExternalImageList ) - { - m_aImageList.pExternalImageList.reset( m_pExternalImages ); - } - - m_bExternalImagesStartFound = false; - m_pExternalImages = nullptr; - } - break; - - case IMG_ELEMENT_EXTERNALENTRY: - { - m_bExternalImageStartFound = false; - } - break; - default: break; } } @@ -621,11 +384,6 @@ void OWriteImagesDocumentHandler::WriteImagesDocument() } } - if ( m_aImageListsItems.pExternalImageList ) - { - WriteExternalImageList( m_aImageListsItems.pExternalImageList.get() ); - } - m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_IMAGESCONTAINER ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); @@ -644,51 +402,6 @@ void OWriteImagesDocumentHandler::WriteImageList( const ImageListItemDescriptor* m_aAttributeType, m_aAttributeValueSimple ); - pList->AddAttribute( m_aXMLXlinkNS + ATTRIBUTE_HREF, - m_aAttributeType, - pImageList->aURL ); - - if ( pImageList->nMaskMode == ImageMaskMode_Bitmap ) - { - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_MASKMODE, - m_aAttributeType, - ATTRIBUTE_MASKMODE_BITMAP ); - - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_MASKURL, - m_aAttributeType, - pImageList->aMaskURL ); - - if ( !pImageList->aHighContrastMaskURL.isEmpty() ) - { - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_HIGHCONTRASTMASKURL, - m_aAttributeType, - pImageList->aHighContrastMaskURL ); - } - } - else - { - OUStringBuffer aColorStrBuffer( 8 ); - sal_Int64 nValue = sal_uInt32(pImageList->aMaskColor.GetRGBColor()); - - aColorStrBuffer.append( "#" ); - aColorStrBuffer.append( OUString::number( nValue, 16 )); - - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_MASKCOLOR, - m_aAttributeType, - aColorStrBuffer.makeStringAndClear() ); - - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_MASKMODE, - m_aAttributeType, - ATTRIBUTE_MASKMODE_COLOR ); - } - - if ( !pImageList->aHighContrastURL.isEmpty() ) - { - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_HIGHCONTRASTURL, - m_aAttributeType, - pImageList->aHighContrastURL ); - } - m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGES, xList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); @@ -708,10 +421,6 @@ void OWriteImagesDocumentHandler::WriteImage( const ImageItemDescriptor* pImage ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_BITMAPINDEX, - m_aAttributeType, - OUString::number( pImage->nIndex ) ); - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_COMMAND, m_aAttributeType, pImage->aCommandURL ); @@ -723,53 +432,6 @@ void OWriteImagesDocumentHandler::WriteImage( const ImageItemDescriptor* pImage m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); } -void OWriteImagesDocumentHandler::WriteExternalImageList( const ExternalImageItemListDescriptor* pExternalImageList ) -{ - m_xWriteDocumentHandler->startElement( ELEMENT_NS_EXTERNALIMAGES, m_xEmptyList ); - m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - - for (const auto & i : *pExternalImageList) - { - const ExternalImageItemDescriptor* pItem = i.get(); - WriteExternalImage( pItem ); - } - - m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - m_xWriteDocumentHandler->endElement( ELEMENT_NS_EXTERNALIMAGES ); - m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); -} - -void OWriteImagesDocumentHandler::WriteExternalImage( const ExternalImageItemDescriptor* pExternalImage ) -{ - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); - - // save required attributes - pList->AddAttribute( m_aAttributeXlinkType, - m_aAttributeType, - m_aAttributeValueSimple ); - - if ( !pExternalImage->aURL.isEmpty() ) - { - pList->AddAttribute( m_aXMLXlinkNS + ATTRIBUTE_HREF, - m_aAttributeType, - pExternalImage->aURL ); - } - - if ( !pExternalImage->aCommandURL.isEmpty() ) - { - pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_COMMAND, - m_aAttributeType, - pExternalImage->aCommandURL ); - } - - m_xWriteDocumentHandler->startElement( ELEMENT_NS_EXTERNALENTRY, xList ); - m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - - m_xWriteDocumentHandler->endElement( ELEMENT_NS_EXTERNALENTRY ); - m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); -} - } // namespace framework /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |