include/xmloff/xmlimp.hxx | 5 -- xmloff/source/core/xmlimp.cxx | 38 ---------------------- xmloff/source/draw/XMLReplacementImageContext.cxx | 37 ++++++++++++--------- xmloff/source/forms/elementimport.cxx | 31 +++++++++++------ xmloff/source/forms/elementimport.hxx | 2 + xmloff/source/forms/layerimport.cxx | 4 -- xmloff/source/forms/propertyexport.hxx | 2 - xmloff/source/forms/strings.hxx | 2 - 8 files changed, 46 insertions(+), 75 deletions(-)
New commits: commit 7ba32a63cf6064b5ad6e27c95ea3d9fa01ef19b1 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Sat Mar 10 22:27:12 2018 +0900 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 <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 3249b6797ae7..926a44d08f59 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -406,10 +406,7 @@ public: // internal package URL. The later one happens only if bLoadURL is true OUString ResolveGraphicObjectURL( const OUString& rURL, bool bLoadOnDemand ); - css::uno::Reference< css::io::XOutputStream > - GetStreamForGraphicObjectURLFromBase64(); - OUString ResolveGraphicObjectURLFromBase64( - const css::uno::Reference< css::io::XOutputStream >& rOut ); + css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64(); bool IsPackageURL( const OUString& rURL ) const; OUString ResolveEmbeddedObjectURL( const OUString& rURL, 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( commit cefef4b2e59de45d51504a69ae23c803b0dd9590 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Sat Mar 10 21:10:37 2018 +0900 xmloff: convert form controls to use Graphic property on import Change-Id: I98e6a8a6cf114e1b6347b77abc6c3ad30842c3cd Reviewed-on: https://gerrit.libreoffice.org/51042 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 82516023b67f..15662c336f27 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -1118,7 +1118,14 @@ namespace xmloff bool OImagePositionImport::handleAttribute( sal_uInt16 _nNamespaceKey, const OUString& _rLocalName, const OUString& _rValue ) { - if ( _rLocalName == GetXMLToken( XML_IMAGE_POSITION ) ) + static const sal_Char* s_pImageDataAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCAFlags::ImageData); + + if (_rLocalName.equalsAscii(s_pImageDataAttributeName)) + { + m_xGraphic = m_rContext.getGlobalContext().loadGraphicByURL(_rValue); + return true; + } + else if ( _rLocalName == GetXMLToken( XML_IMAGE_POSITION ) ) { OSL_VERIFY( PropertyConversion::convertString( cppu::UnoType<decltype(m_nImagePosition)>::get(), @@ -1127,8 +1134,7 @@ namespace xmloff m_bHaveImagePosition = true; return true; } - - if ( _rLocalName == GetXMLToken( XML_IMAGE_ALIGN ) ) + else if ( _rLocalName == GetXMLToken( XML_IMAGE_ALIGN ) ) { OSL_VERIFY( PropertyConversion::convertString( cppu::UnoType<decltype(m_nImageAlign)>::get(), @@ -1144,6 +1150,13 @@ namespace xmloff { OControlImport::StartElement( _rxAttrList ); + if (m_xGraphic.is()) + { + PropertyValue aGraphicProperty; + aGraphicProperty.Name = PROPERTY_GRAPHIC; + aGraphicProperty.Value <<= m_xGraphic; + implPushBackPropertyValue(aGraphicProperty); + } if ( m_bHaveImagePosition ) { sal_Int16 nUnoImagePosition = ImagePosition::Centered; @@ -1276,16 +1289,10 @@ namespace xmloff ) ); - if ( bMakeAbsolute && !_rValue.isEmpty() ) + if (bMakeAbsolute && !_rValue.isEmpty()) { - // make a global URL out of the local one - OUString sAdjustedValue; - // only resolve image related url - // we don't want say form url targets to be resolved - // using ResolveGraphicObjectURL - if ( _rLocalName.equalsAscii( s_pImageDataAttributeName ) ) - sAdjustedValue = m_rContext.getGlobalContext().ResolveGraphicObjectURL( _rValue, false ); - else + OUString sAdjustedValue = _rValue; + if (!_rLocalName.equalsAscii(s_pImageDataAttributeName)) sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue ); return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, sAdjustedValue ); } diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx index c2cfc36f5b03..a1429caa6e55 100644 --- a/xmloff/source/forms/elementimport.hxx +++ b/xmloff/source/forms/elementimport.hxx @@ -33,6 +33,7 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/form/XGridColumnFactory.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <osl/diagnose.h> #include <map> @@ -275,6 +276,7 @@ namespace xmloff //= OImagePositionImport class OImagePositionImport : public OControlImport { + css::uno::Reference<css::graphic::XGraphic> m_xGraphic; sal_Int16 m_nImagePosition; sal_Int16 m_nImageAlign; bool m_bHaveImagePosition; diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx index 9f173b527271..c4b5ecec73aa 100644 --- a/xmloff/source/forms/layerimport.cxx +++ b/xmloff/source/forms/layerimport.cxx @@ -77,9 +77,7 @@ OFormLayerXMLImport_Impl::OFormLayerXMLImport_Impl(SvXMLImport& _rImporter) m_aAttributeMetaData.addStringProperty( OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Name), PROPERTY_NAME); m_aAttributeMetaData.addStringProperty( - OAttributeMetaData::getSpecialAttributeName(SCAFlags::GroupName), PROPERTY_GROUP_NAME); - m_aAttributeMetaData.addStringProperty( - OAttributeMetaData::getCommonControlAttributeName(CCAFlags::ImageData), PROPERTY_IMAGEURL); + OAttributeMetaData::getSpecialAttributeName(SCAFlags::GroupName), PROPERTY_GROUP_NAME); m_aAttributeMetaData.addStringProperty( OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Label), PROPERTY_LABEL); m_aAttributeMetaData.addStringProperty( diff --git a/xmloff/source/forms/propertyexport.hxx b/xmloff/source/forms/propertyexport.hxx index e01b6c71ad31..2d940bf392df 100644 --- a/xmloff/source/forms/propertyexport.hxx +++ b/xmloff/source/forms/propertyexport.hxx @@ -259,7 +259,7 @@ namespace xmloff <p>The property needs a special handling because the URL's need to be made relative</p> */ - void exportImageDataAttribute() { exportRelativeTargetLocation(PROPERTY_IMAGEURL,CCAFlags::ImageData,false); } + void exportImageDataAttribute() { exportRelativeTargetLocation(PROPERTY_GRAPHIC, CCAFlags::ImageData, false); } /** flag the style properties as 'already exported' diff --git a/xmloff/source/forms/strings.hxx b/xmloff/source/forms/strings.hxx index cb1b7564c299..695ffa777ccf 100644 --- a/xmloff/source/forms/strings.hxx +++ b/xmloff/source/forms/strings.hxx @@ -28,7 +28,7 @@ namespace xmloff #define PROPERTY_ECHOCHAR "EchoChar" #define PROPERTY_MULTILINE "MultiLine" #define PROPERTY_NAME "Name" - #define PROPERTY_IMAGEURL "ImageURL" + #define PROPERTY_GRAPHIC "Graphic" #define PROPERTY_LABEL "Label" #define PROPERTY_TARGETFRAME "TargetFrame" #define PROPERTY_TARGETURL "TargetURL" _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits