diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-03-10 21:10:37 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-03-11 01:51:00 +0100 |
commit | cefef4b2e59de45d51504a69ae23c803b0dd9590 (patch) | |
tree | 793c759ff144c57d7fdf4c7279200592b13a17f9 /xmloff | |
parent | c21f156e8e5abce387316b3482aacd8f8f309231 (diff) |
xmloff: convert form controls to use Graphic property on import
Change-Id: I98e6a8a6cf114e1b6347b77abc6c3ad30842c3cd
Reviewed-on: https://gerrit.libreoffice.org/51042
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/forms/elementimport.cxx | 31 | ||||
-rw-r--r-- | xmloff/source/forms/elementimport.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/forms/layerimport.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/forms/propertyexport.hxx | 2 | ||||
-rw-r--r-- | xmloff/source/forms/strings.hxx | 2 |
5 files changed, 24 insertions, 17 deletions
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" |