From cefef4b2e59de45d51504a69ae23c803b0dd9590 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 10 Mar 2018 21:10:37 +0900 Subject: xmloff: convert form controls to use Graphic property on import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I98e6a8a6cf114e1b6347b77abc6c3ad30842c3cd Reviewed-on: https://gerrit.libreoffice.org/51042 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- 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 +- 5 files changed, 24 insertions(+), 17 deletions(-) (limited to 'xmloff/source/forms') 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::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::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 #include #include +#include #include #include @@ -275,6 +276,7 @@ namespace xmloff //= OImagePositionImport class OImagePositionImport : public OControlImport { + css::uno::Reference 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

The property needs a special handling because the URL's need to be made relative

*/ - 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" -- cgit