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>
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index 8251602..15662c3 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 c2cfc36..a1429ca 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 9f173b5..c4b5ece 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 e01b6c7..2d940bf 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 cb1b756..695ffa7 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"