diff options
-rw-r--r-- | framework/inc/xml/imagesconfiguration.hxx | 19 | ||||
-rw-r--r-- | framework/inc/xml/imagesdocumenthandler.hxx | 11 | ||||
-rw-r--r-- | framework/source/uiconfiguration/imagemanagerimpl.cxx | 25 | ||||
-rw-r--r-- | framework/source/xml/imagesconfiguration.cxx | 4 | ||||
-rw-r--r-- | framework/source/xml/imagesdocumenthandler.cxx | 59 |
5 files changed, 31 insertions, 87 deletions
diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx index 983a16d66c9b..1e3ec096e7f7 100644 --- a/framework/inc/xml/imagesconfiguration.hxx +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -39,20 +39,7 @@ struct ImageItemDescriptor OUString aCommandURL; // URL command to dispatch }; -typedef std::vector<std::unique_ptr<ImageItemDescriptor> > ImageItemListDescriptor; - -struct ImageListItemDescriptor -{ - std::unique_ptr<ImageItemListDescriptor> - pImageItemList; // an array of ImageItemDescriptors that describes every image -}; - -typedef std::vector<std::unique_ptr<ImageListItemDescriptor> > ImageListDescriptor; - -struct ImageListsDescriptor -{ - std::unique_ptr<ImageListDescriptor> pImageList; -}; +typedef std::vector<ImageItemDescriptor> ImageItemDescriptorList; class ImagesConfiguration { @@ -60,12 +47,12 @@ class ImagesConfiguration static bool LoadImages( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::io::XInputStream >& rInputStream, - ImageListsDescriptor& rItems ); + ImageItemDescriptorList& rItems ); static bool StoreImages( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::io::XOutputStream >& rOutputStream, - const ImageListsDescriptor& rItems ); + const ImageItemDescriptorList& rItems ); }; } // namespace framework diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx index 720071d0632e..2df23a205cd3 100644 --- a/framework/inc/xml/imagesdocumenthandler.hxx +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -62,7 +62,7 @@ class OReadImagesDocumentHandler : public ::cppu::WeakImplHelper< css::xml::sax: IMG_NS_XLINK }; - OReadImagesDocumentHandler( ImageListsDescriptor& aItems ); + OReadImagesDocumentHandler( ImageItemDescriptorList& aItems ); virtual ~OReadImagesDocumentHandler() override; // XDocumentHandler @@ -101,8 +101,7 @@ class OReadImagesDocumentHandler : public ::cppu::WeakImplHelper< css::xml::sax: sal_Int32 m_nHashMaskModeBitmap; sal_Int32 m_nHashMaskModeColor; ImageHashMap m_aImageMap; - ImageListsDescriptor& m_aImageList; - ImageListItemDescriptor* m_pImages; + ImageItemDescriptorList& m_rImageList; css::uno::Reference< css::xml::sax::XLocator > m_xLocator; }; @@ -110,7 +109,7 @@ class OWriteImagesDocumentHandler final { public: OWriteImagesDocumentHandler( - const ImageListsDescriptor& aItems, + const ImageItemDescriptorList& aItems, css::uno::Reference< css::xml::sax::XDocumentHandler > const & rWriteDocumentHandler); ~OWriteImagesDocumentHandler(); @@ -122,13 +121,13 @@ class OWriteImagesDocumentHandler final private: /// @throws css::xml::sax::SAXException /// @throws css::uno::RuntimeException - void WriteImageList( const ImageListItemDescriptor* ); + void WriteImageList( const ImageItemDescriptorList* ); /// @throws css::xml::sax::SAXException /// @throws css::uno::RuntimeException void WriteImage( const ImageItemDescriptor* ); - const ImageListsDescriptor& m_aImageListsItems; + const ImageItemDescriptorList& m_rImageItemList; css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList; OUString m_aXMLXlinkNS; diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index fc6a54d3d2c2..a962588441c4 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -322,21 +322,19 @@ void ImageManagerImpl::implts_loadUserImages( ElementModes::READ ); uno::Reference< XInputStream > xInputStream = xStream->getInputStream(); - ImageListsDescriptor aUserImageListInfo; + ImageItemDescriptorList aUserImageListInfo; ImagesConfiguration::LoadImages( m_xContext, xInputStream, aUserImageListInfo ); - if (( aUserImageListInfo.pImageList != nullptr ) && - ( !aUserImageListInfo.pImageList->empty() )) + if ( !aUserImageListInfo.empty() ) { - ImageListItemDescriptor* pList = aUserImageListInfo.pImageList->front().get(); - sal_Int32 nCount = pList->pImageItemList->size(); + sal_Int32 nCount = aUserImageListInfo.size(); std::vector< OUString > aUserImagesVector; aUserImagesVector.reserve(nCount); for ( sal_Int32 i=0; i < nCount; i++ ) { - const ImageItemDescriptor* pItem = (*pList->pImageItemList)[i].get(); - aUserImagesVector.push_back( pItem->aCommandURL ); + const ImageItemDescriptor& rItem = aUserImageListInfo[i]; + aUserImagesVector.push_back( rItem.aCommandURL ); } uno::Reference< XStream > xBitmapStream = xUserBitmapsStorage->openStreamElement( @@ -393,18 +391,13 @@ bool ImageManagerImpl::implts_storeUserImages( ImageList* pImageList = implts_getUserImageList( nImageType ); if ( pImageList->GetImageCount() > 0 ) { - ImageListsDescriptor aUserImageListInfo; - aUserImageListInfo.pImageList.reset( new ImageListDescriptor ); + ImageItemDescriptorList aUserImageListInfo; - ImageListItemDescriptor* pList = new ImageListItemDescriptor; - aUserImageListInfo.pImageList->push_back( std::unique_ptr<ImageListItemDescriptor>(pList) ); - - pList->pImageItemList.reset( new ImageItemListDescriptor ); for ( sal_uInt16 i=0; i < pImageList->GetImageCount(); i++ ) { - ImageItemDescriptor* pItem = new ImageItemDescriptor; - pItem->aCommandURL = pImageList->GetImageName( i ); - pList->pImageItemList->push_back( std::unique_ptr<ImageItemDescriptor>(pItem) ); + ImageItemDescriptor aItem; + aItem.aCommandURL = pImageList->GetImageName( i ); + aUserImageListInfo.push_back( aItem ); } uno::Reference< XTransactedObject > xTransaction; diff --git a/framework/source/xml/imagesconfiguration.cxx b/framework/source/xml/imagesconfiguration.cxx index 444cef4252cc..12fa4bd84aa8 100644 --- a/framework/source/xml/imagesconfiguration.cxx +++ b/framework/source/xml/imagesconfiguration.cxx @@ -43,7 +43,7 @@ namespace framework bool ImagesConfiguration::LoadImages( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::io::XInputStream >& rInputStream, - ImageListsDescriptor& rItems ) + ImageItemDescriptorList& rItems ) { Reference< XParser > xParser = Parser::create( rxContext ); @@ -81,7 +81,7 @@ bool ImagesConfiguration::LoadImages( bool ImagesConfiguration::StoreImages( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::io::XOutputStream >& rOutputStream, - const ImageListsDescriptor& rItems ) + const ImageItemDescriptorList& rItems ) { Reference< XWriter > xWriter = Writer::create(rxContext); xWriter->setOutputStream( rOutputStream ); diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx index 7005a07b89ac..dd95ddbf22e7 100644 --- a/framework/source/xml/imagesdocumenthandler.cxx +++ b/framework/source/xml/imagesdocumenthandler.cxx @@ -98,12 +98,9 @@ ImageXMLEntryProperty const ImagesEntries[OReadImagesDocumentHandler::IMG_XML_EN { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_HIGHCONTRASTMASKURL } }; -OReadImagesDocumentHandler::OReadImagesDocumentHandler( ImageListsDescriptor& aItems ) : - m_aImageList( aItems ), - m_pImages( nullptr ) +OReadImagesDocumentHandler::OReadImagesDocumentHandler( ImageItemDescriptorList& rItems ) : + m_rImageList( rItems ) { - m_aImageList.pImageList = nullptr; - m_nHashMaskModeBitmap = OUString( ATTRIBUTE_MASKMODE_BITMAP ).hashCode(); m_nHashMaskModeColor = OUString( ATTRIBUTE_MASKMODE_COLOR ).hashCode(); @@ -191,11 +188,7 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - if ( !m_aImageList.pImageList ) - m_aImageList.pImageList.reset( new ImageListDescriptor ); - m_bImagesStartFound = true; - m_pImages = new ImageListItemDescriptor; } break; @@ -204,19 +197,13 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( // Check that image:entry is embedded into image:images! if ( !m_bImagesStartFound ) { - delete m_pImages; - m_pImages = nullptr; - OUString aErrorMessage = getErrorLineString(); aErrorMessage += "Element 'image:entry' must be embedded into element 'image:images'!"; throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - if ( !m_pImages->pImageItemList ) - m_pImages->pImageItemList.reset( new ImageItemListDescriptor ); - // Create new image item descriptor - std::unique_ptr<ImageItemDescriptor> pItem(new ImageItemDescriptor); + ImageItemDescriptor aItem; // Read attributes for this image definition for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) @@ -228,7 +215,7 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( { case IMG_ATTRIBUTE_COMMAND: { - pItem->aCommandURL = xAttribs->getValueByIndex( n ); + aItem.aCommandURL = xAttribs->getValueByIndex( n ); } break; @@ -239,17 +226,14 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( } // Check required attribute "command" - if ( pItem->aCommandURL.isEmpty() ) + if ( aItem.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) ); + m_rImageList.push_back( aItem ); } break; @@ -276,12 +260,6 @@ void SAL_CALL OReadImagesDocumentHandler::endElement(const OUString& aName) case IMG_ELEMENT_IMAGES: { - if ( m_pImages ) - { - if ( m_aImageList.pImageList ) - m_aImageList.pImageList->push_back( std::unique_ptr<ImageListItemDescriptor>(m_pImages) ); - m_pImages = nullptr; - } m_bImagesStartFound = false; } break; @@ -328,9 +306,9 @@ OUString OReadImagesDocumentHandler::getErrorLineString() // OWriteImagesDocumentHandler OWriteImagesDocumentHandler::OWriteImagesDocumentHandler( - const ImageListsDescriptor& aItems, + const ImageItemDescriptorList& rItems, Reference< XDocumentHandler > const & rWriteDocumentHandler ) : - m_aImageListsItems( aItems ), + m_rImageItemList( rItems ), m_xWriteDocumentHandler( rWriteDocumentHandler ) { ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; @@ -373,16 +351,7 @@ void OWriteImagesDocumentHandler::WriteImagesDocument() m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGESCONTAINER, pList.get() ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - if ( m_aImageListsItems.pImageList ) - { - ImageListDescriptor* pImageList = m_aImageListsItems.pImageList.get(); - - for ( size_t i = 0; i < m_aImageListsItems.pImageList->size(); i++ ) - { - const ImageListItemDescriptor* pImageItems = (*pImageList)[i].get(); - WriteImageList( pImageItems ); - } - } + WriteImageList( &m_rImageItemList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_IMAGESCONTAINER ); @@ -392,7 +361,7 @@ void OWriteImagesDocumentHandler::WriteImagesDocument() // protected member functions -void OWriteImagesDocumentHandler::WriteImageList( const ImageListItemDescriptor* pImageList ) +void OWriteImagesDocumentHandler::WriteImageList( const ImageItemDescriptorList* pImageList ) { ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; Reference< XAttributeList > xList( static_cast<XAttributeList *>(pList) , UNO_QUERY ); @@ -405,12 +374,8 @@ void OWriteImagesDocumentHandler::WriteImageList( const ImageListItemDescriptor* m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGES, xList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - ImageItemListDescriptor* pImageItemList = pImageList->pImageItemList.get(); - if ( pImageItemList ) - { - for (std::unique_ptr<ImageItemDescriptor> & i : *pImageItemList) - WriteImage( i.get() ); - } + for (const ImageItemDescriptor & i : *pImageList) + WriteImage( &i ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_IMAGES ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); |