From 7ba32a63cf6064b5ad6e27c95ea3d9fa01ef19b1 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 10 Mar 2018 22:27:12 +0900 Subject: xmloff: convert replacement image loading to use "Graphic" prop. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this change ResolveGraphicObjectURLFromBase64 and ResolveGraphicObjectURL became unused and are also removed with this commit. Change-Id: I45428a4e47f0e8800f18c1fdba007293dfcb53f4 Reviewed-on: https://gerrit.libreoffice.org/51043 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- xmloff/source/core/xmlimp.cxx | 38 ----------------------- xmloff/source/draw/XMLReplacementImageContext.cxx | 37 ++++++++++++---------- 2 files changed, 21 insertions(+), 54 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index a58f32ba861b..3c1e8bb0c6ea 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1399,33 +1399,6 @@ uno::Reference SvXMLImport::loadGraphicFromBase64(uno::Refere return xGraphic; } -OUString SvXMLImport::ResolveGraphicObjectURL( const OUString& rURL, - bool bLoadOnDemand ) -{ - OUString sRet; - - if( IsPackageURL( rURL ) ) - { - if( !bLoadOnDemand && mxGraphicResolver.is() ) - { - OUString aTmp( msPackageProtocol ); - aTmp += rURL; - sRet = mxGraphicResolver->resolveGraphicObjectURL( aTmp ); - } - - if( sRet.isEmpty() ) - { - sRet = msPackageProtocol; - sRet += rURL; - } - } - - if( sRet.isEmpty() ) - sRet = GetAbsoluteReference( rURL ); - - return sRet; -} - Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64() { Reference< XOutputStream > xOStm; @@ -1437,17 +1410,6 @@ Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64() return xOStm; } -OUString SvXMLImport::ResolveGraphicObjectURLFromBase64( - const Reference < XOutputStream >& rOut ) -{ - OUString sURL; - Reference< document::XBinaryStreamResolver > xStmResolver( mxGraphicResolver, UNO_QUERY ); - if( xStmResolver.is() ) - sURL = xStmResolver->resolveOutputStream( rOut ); - - return sURL; -} - OUString SvXMLImport::ResolveEmbeddedObjectURL( const OUString& rURL, const OUString& rClassId ) diff --git a/xmloff/source/draw/XMLReplacementImageContext.cxx b/xmloff/source/draw/XMLReplacementImageContext.cxx index cbea729a59af..eb5f6ea52c15 100644 --- a/xmloff/source/draw/XMLReplacementImageContext.cxx +++ b/xmloff/source/draw/XMLReplacementImageContext.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::makeAny; using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::beans; - +using namespace css; XMLReplacementImageContext::XMLReplacementImageContext( SvXMLImport& rImport, @@ -75,25 +76,29 @@ void XMLReplacementImageContext::EndElement() "neither URL nor base64 image data given" ); rtl::Reference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport(); - OUString sHRef; - if( !m_sHRef.isEmpty() ) + uno::Reference xGraphic; + + try { - bool bForceLoad = xTxtImport->IsInsertMode() || - xTxtImport->IsBlockMode() || - xTxtImport->IsStylesOnlyMode() || - xTxtImport->IsOrganizerMode(); - sHRef = GetImport().ResolveGraphicObjectURL( m_sHRef, !bForceLoad ); + if( !m_sHRef.isEmpty() ) + { + xGraphic = GetImport().loadGraphicByURL(m_sHRef); + } + else if( m_xBase64Stream.is() ) + { + xGraphic = GetImport().loadGraphicFromBase64(m_xBase64Stream); + m_xBase64Stream = nullptr; + } } - else if( m_xBase64Stream.is() ) + catch (uno::Exception const &) + {} + + Reference < XPropertySetInfo > xPropSetInfo = m_xPropSet->getPropertySetInfo(); + + if (xGraphic.is() && xPropSetInfo->hasPropertyByName("Graphic")) { - sHRef = GetImport().ResolveGraphicObjectURLFromBase64( m_xBase64Stream ); - m_xBase64Stream = nullptr; + m_xPropSet->setPropertyValue("Graphic", uno::makeAny(xGraphic)); } - - Reference < XPropertySetInfo > xPropSetInfo = - m_xPropSet->getPropertySetInfo(); - if( xPropSetInfo->hasPropertyByName("GraphicURL") ) - m_xPropSet->setPropertyValue("GraphicURL", makeAny( sHRef ) ); } SvXMLImportContextRef XMLReplacementImageContext::CreateChildContext( -- cgit tro/escriba/escriba-5.2 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2021-03-23tdf#124176 Use pragma once in s*Vincent LE GARREC
2020-09-17Tokens2RangeStringXML ctor never called with null ScDocument*Caolán McNamara