framework/inc/xml/imagesconfiguration.hxx | 11 ++++++++++- framework/source/uiconfiguration/imagemanagerimpl.cxx | 12 +++++++----- framework/source/xml/imagesdocumenthandler.cxx | 9 +++++++-- 3 files changed, 24 insertions(+), 8 deletions(-)
New commits: commit 85d1e6662b09be414565c6aa512abf5bc9b83f3d Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Oct 9 17:16:09 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Oct 9 15:40:49 2024 +0200 tdf#163362: write xlink:href in image:images, image:bitmap-index in image:entry Those were mandatory prior to commit d367ee2f8c204f351072c0eb10259fd7aa497770, and still mandatory e.g. in AOO. Restore writing those, for interoperability and backward compatibility. Change-Id: I84f33e13e6bade8b2f2dd0cc5e2e0f4a96d50e84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174721 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx index 4b17b7c98d84..b50a1dd56d56 100644 --- a/framework/inc/xml/imagesconfiguration.hxx +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -30,10 +30,19 @@ namespace framework struct ImageItemDescriptor { + // index of the bitmap inside the bitmaplist; not required currently, but was mandatory + // previously, so needs to be written for backward compatibility + long nIndex = -1; OUString aCommandURL; // URL command to dispatch }; -typedef std::vector<ImageItemDescriptor> ImageItemDescriptorList; +struct ImageItemDescriptorList +{ + // a URL to a bitmap with several images inside; not required currently, but was mandatory + // previously, so needs to be written for backward compatibility + OUString aURL; + std::vector<ImageItemDescriptor> aImageItemDescriptors; +}; class ImagesConfiguration { diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 31deab1fc15c..25cd0841efe9 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -308,14 +308,14 @@ void ImageManagerImpl::implts_loadUserImages( ImagesConfiguration::LoadImages( m_xContext, xInputStream, aUserImageListInfo ); - if ( !aUserImageListInfo.empty() ) + if (!aUserImageListInfo.aImageItemDescriptors.empty()) { - sal_Int32 nCount = aUserImageListInfo.size(); + sal_Int32 nCount = aUserImageListInfo.aImageItemDescriptors.size(); std::vector< OUString > aUserImagesVector; aUserImagesVector.reserve(nCount); for ( sal_Int32 i=0; i < nCount; i++ ) { - const ImageItemDescriptor& rItem = aUserImageListInfo[i]; + const ImageItemDescriptor& rItem = aUserImageListInfo.aImageItemDescriptors[i]; aUserImagesVector.push_back( rItem.aCommandURL ); } @@ -379,9 +379,11 @@ bool ImageManagerImpl::implts_storeUserImages( for ( sal_uInt16 i=0; i < pImageList->GetImageCount(); i++ ) { ImageItemDescriptor aItem; - aItem.aCommandURL = pImageList->GetImageName( i ); - aUserImageListInfo.push_back( aItem ); + aItem.nIndex = i; + aItem.aCommandURL = pImageList->GetImageName(i); + aUserImageListInfo.aImageItemDescriptors.push_back( aItem ); } + aUserImageListInfo.aURL = "Bitmaps/" + BITMAP_FILE_NAMES[nImageType]; uno::Reference< XTransactedObject > xTransaction; uno::Reference< XOutputStream > xOutputStream; diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx index 6f0d41ce3e7c..fe20553ee878 100644 --- a/framework/source/xml/imagesdocumenthandler.cxx +++ b/framework/source/xml/imagesdocumenthandler.cxx @@ -50,6 +50,7 @@ constexpr OUString ELEMENT_NS_ENTRY = u"image:entry"_ustr; constexpr OUStringLiteral ATTRIBUTE_XMLNS_IMAGE = u"xmlns:image"; constexpr OUStringLiteral ATTRIBUTE_XMLNS_XLINK = u"xmlns:xlink"; +constexpr OUString ATTRIBUTE_XLINK_HREF = u"xlink:href"_ustr; constexpr OUStringLiteral ATTRIBUTE_XLINK_TYPE = u"xlink:type"; constexpr OUStringLiteral ATTRIBUTE_XLINK_TYPE_VALUE = u"simple"; @@ -212,7 +213,7 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - m_rImageList.push_back( aItem ); + m_rImageList.aImageItemDescriptors.push_back(aItem); } break; @@ -335,10 +336,12 @@ void OWriteImagesDocumentHandler::WriteImageList( const ImageItemDescriptorList* pList->AddAttribute( m_aAttributeXlinkType, m_aAttributeValueSimple ); + pList->AddAttribute(ATTRIBUTE_XLINK_HREF, pImageList->aURL); + m_xWriteDocumentHandler->startElement( ELEMENT_NS_IMAGES, pList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); - for (const ImageItemDescriptor & i : *pImageList) + for (const ImageItemDescriptor & i : pImageList->aImageItemDescriptors) WriteImage( &i ); m_xWriteDocumentHandler->endElement( ELEMENT_NS_IMAGES ); @@ -349,6 +352,8 @@ void OWriteImagesDocumentHandler::WriteImage( const ImageItemDescriptor* pImage { rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList; + pList->AddAttribute(m_aXMLImageNS + ATTRIBUTE_BITMAPINDEX, OUString::number(pImage->nIndex)); + pList->AddAttribute( m_aXMLImageNS + ATTRIBUTE_COMMAND, pImage->aCommandURL );