summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-03-10 22:27:12 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-03-11 01:51:12 +0100
commit7ba32a63cf6064b5ad6e27c95ea3d9fa01ef19b1 (patch)
tree0b9f8cf59713b7c02ea39ae836b642b38c0635dd /xmloff
parentcefef4b2e59de45d51504a69ae23c803b0dd9590 (diff)
xmloff: convert replacement image loading to use "Graphic" prop.
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 <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlimp.cxx38
-rw-r--r--xmloff/source/draw/XMLReplacementImageContext.cxx37
2 files changed, 21 insertions, 54 deletions
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<graphic::XGraphic> 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 <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
#include <osl/diagnose.h>
#include <xmloff/xmlimp.hxx>
#include <xmloff/xmltoken.hxx>
@@ -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<graphic::XGraphic> 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(