xmlscript: change import/export to not use GraphicObject URL
Change-Id: Ic81bf1a5ce45394e098366d0f4af53845ba0da87 Reviewed-on: https://gerrit.libreoffice.org/51307 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
parent
90cb743a69
commit
043273e721
@ -40,7 +40,6 @@ extern StringTriple const * const g_pEventTranslations;
|
||||
|
||||
}
|
||||
|
||||
#define XMLSCRIPT_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@ -140,8 +140,6 @@ public:
|
||||
OUString const & rPropName, OUString const & rAttrName );
|
||||
void readVerticalAlignAttr(
|
||||
OUString const & rPropName, OUString const & rAttrName );
|
||||
void readImageURLAttr(
|
||||
OUString const & rPropName, OUString const & rAttrName );
|
||||
void readImageAlignAttr(
|
||||
OUString const & rPropName, OUString const & rAttrName );
|
||||
void readImagePositionAttr(
|
||||
@ -164,8 +162,10 @@ public:
|
||||
OUString const & rPropName, OUString const & rAttrName );
|
||||
void readImageScaleModeAttr(
|
||||
OUString const & rPropName, OUString const & rAttrName );
|
||||
void readDataAwareAttr(
|
||||
OUString const & rAttrName );
|
||||
|
||||
void readDataAwareAttr(OUString const & rAttrName );
|
||||
void readImageOrGraphicAttr(OUString const & rAttrName );
|
||||
|
||||
void addBoolAttr(
|
||||
OUString const & rAttrName, bool bValue )
|
||||
{ addAttribute( rAttrName, OUString::boolean(bValue) ); }
|
||||
|
@ -421,7 +421,7 @@ public:
|
||||
bool importVerticalAlignProperty(
|
||||
OUString const & rPropName, OUString const & rAttrName,
|
||||
css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
|
||||
bool importImageURLProperty( OUString const & rPropName, OUString const & rAttrName,
|
||||
bool importGraphicOrImageProperty(OUString const & rAttrName,
|
||||
css::uno::Reference< css::xml::input::XAttributes > const & xAttributes );
|
||||
bool importImageAlignProperty(
|
||||
OUString const & rPropName, OUString const & rAttrName,
|
||||
|
@ -187,8 +187,7 @@ void ElementDescriptor::readButtonModel( StyleBag * all_styles )
|
||||
readAlignAttr( "Align", XMLNS_DIALOGS_PREFIX ":align" );
|
||||
readVerticalAlignAttr( "VerticalAlign", XMLNS_DIALOGS_PREFIX ":valign" );
|
||||
readButtonTypeAttr( "PushButtonType", XMLNS_DIALOGS_PREFIX ":button-type" );
|
||||
readImageURLAttr( "ImageURL", XMLNS_DIALOGS_PREFIX ":image-src" );
|
||||
|
||||
readImageOrGraphicAttr(XMLNS_DIALOGS_PREFIX ":image-src");
|
||||
readImagePositionAttr( "ImagePosition", XMLNS_DIALOGS_PREFIX ":image-position" );
|
||||
readImageAlignAttr( "ImageAlign", XMLNS_DIALOGS_PREFIX ":image-align" );
|
||||
|
||||
@ -247,7 +246,7 @@ void ElementDescriptor::readCheckBoxModel( StyleBag * all_styles )
|
||||
readStringAttr( "Label", XMLNS_DIALOGS_PREFIX ":value" );
|
||||
readAlignAttr( "Align", XMLNS_DIALOGS_PREFIX ":align" );
|
||||
readVerticalAlignAttr( "VerticalAlign", XMLNS_DIALOGS_PREFIX ":valign" );
|
||||
readImageURLAttr( "ImageURL", XMLNS_DIALOGS_PREFIX ":image-src" );
|
||||
readImageOrGraphicAttr(XMLNS_DIALOGS_PREFIX ":image-src");
|
||||
readImagePositionAttr( "ImagePosition", XMLNS_DIALOGS_PREFIX ":image-position" );
|
||||
readBoolAttr( "MultiLine", XMLNS_DIALOGS_PREFIX ":multiline" );
|
||||
|
||||
@ -417,7 +416,7 @@ void ElementDescriptor::readRadioButtonModel( StyleBag * all_styles )
|
||||
readStringAttr( "Label", XMLNS_DIALOGS_PREFIX ":value" );
|
||||
readAlignAttr( "Align", XMLNS_DIALOGS_PREFIX ":align" );
|
||||
readVerticalAlignAttr( "VerticalAlign", XMLNS_DIALOGS_PREFIX ":valign" );
|
||||
readImageURLAttr( "ImageURL", XMLNS_DIALOGS_PREFIX ":image-src" );
|
||||
readImageOrGraphicAttr(XMLNS_DIALOGS_PREFIX ":image-src");
|
||||
readImagePositionAttr( "ImagePosition", XMLNS_DIALOGS_PREFIX ":image-position" );
|
||||
readBoolAttr( "MultiLine", XMLNS_DIALOGS_PREFIX ":multiline" );
|
||||
readStringAttr( "GroupName", XMLNS_DIALOGS_PREFIX ":group-name" );
|
||||
@ -594,7 +593,7 @@ void ElementDescriptor::readImageControlModel( StyleBag * all_styles )
|
||||
readBoolAttr( "ScaleImage", XMLNS_DIALOGS_PREFIX ":scale-image" );
|
||||
readImageScaleModeAttr( "ScaleMode", XMLNS_DIALOGS_PREFIX ":scale-mode" );
|
||||
readBoolAttr( "Tabstop", XMLNS_DIALOGS_PREFIX ":tabstop" );
|
||||
readImageURLAttr( "ImageURL", XMLNS_DIALOGS_PREFIX ":src" );
|
||||
readImageOrGraphicAttr(XMLNS_DIALOGS_PREFIX ":src");
|
||||
readEvents();
|
||||
}
|
||||
|
||||
@ -1042,7 +1041,7 @@ void ElementDescriptor::readDialogModel( StyleBag * all_styles )
|
||||
bool bDecoration = false;
|
||||
if ( (aDecorationAny >>= bDecoration) && !bDecoration )
|
||||
addAttribute( XMLNS_DIALOGS_PREFIX ":withtitlebar", "false" );
|
||||
readImageURLAttr( "ImageURL", XMLNS_DIALOGS_PREFIX ":image-src" );
|
||||
readImageOrGraphicAttr(XMLNS_DIALOGS_PREFIX ":image-src");
|
||||
readEvents();
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,8 @@
|
||||
#include <com/sun/star/table/CellRangeAddress.hpp>
|
||||
#include <com/sun/star/document/XStorageBasedDocument.hpp>
|
||||
#include <com/sun/star/document/GraphicObjectResolver.hpp>
|
||||
#include <com/sun/star/document/XGraphicStorageHandler.hpp>
|
||||
#include <com/sun/star/graphic/XGraphic.hpp>
|
||||
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <i18nlangtag/languagetag.hxx>
|
||||
@ -716,27 +718,36 @@ void ElementDescriptor::readVerticalAlignAttr( OUString const & rPropName, OUStr
|
||||
}
|
||||
}
|
||||
|
||||
void ElementDescriptor::readImageURLAttr( OUString const & rPropName, OUString const & rAttrName )
|
||||
void ElementDescriptor::readImageOrGraphicAttr(OUString const & rAttrName)
|
||||
{
|
||||
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
|
||||
OUString sURL;
|
||||
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState("Graphic"))
|
||||
{
|
||||
OUString sURL;
|
||||
_xProps->getPropertyValue( rPropName ) >>= sURL;
|
||||
|
||||
if ( sURL.startsWith( XMLSCRIPT_GRAPHOBJ_URLPREFIX ) )
|
||||
uno::Reference<graphic::XGraphic> xGraphic;
|
||||
_xProps->getPropertyValue("Graphic") >>= xGraphic;
|
||||
if (xGraphic.is())
|
||||
{
|
||||
Reference< document::XStorageBasedDocument > xDocStorage( _xDocument, UNO_QUERY );
|
||||
if ( xDocStorage.is() )
|
||||
{
|
||||
Reference<XComponentContext> xContext = ::comphelper::getProcessComponentContext();
|
||||
uno::Reference< document::XGraphicObjectResolver > xGraphicResolver =
|
||||
document::GraphicObjectResolver::createWithStorage( xContext, xDocStorage->getDocumentStorage() );
|
||||
sURL = xGraphicResolver->resolveGraphicObjectURL( sURL );
|
||||
uno::Reference<document::XGraphicObjectResolver> xGraphicResolver;
|
||||
xGraphicResolver.set(document::GraphicObjectResolver::createWithStorage(xContext, xDocStorage->getDocumentStorage()));
|
||||
uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
|
||||
xGraphicStorageHandler.set(xGraphicResolver, uno::UNO_QUERY);
|
||||
if (xGraphicStorageHandler.is())
|
||||
{
|
||||
sURL = xGraphicStorageHandler->saveGraphic(xGraphic);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !sURL.isEmpty() )
|
||||
addAttribute( rAttrName, sURL );
|
||||
}
|
||||
else if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState("ImageURL"))
|
||||
{
|
||||
_xProps->getPropertyValue("ImageURL") >>= sURL;
|
||||
}
|
||||
if (!sURL.isEmpty())
|
||||
addAttribute(rAttrName, sURL);
|
||||
}
|
||||
|
||||
void ElementDescriptor::readImageAlignAttr( OUString const & rPropName, OUString const & rAttrName )
|
||||
|
@ -893,7 +893,7 @@ void ImageControlElement::endElement()
|
||||
ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
|
||||
ctx.importBooleanProperty( "ScaleImage", "scale-image", _xAttributes );
|
||||
ctx.importImageScaleModeProperty( "ScaleMode" , "scale-mode" , _xAttributes );
|
||||
ctx.importImageURLProperty( "ImageURL" , "src" , _xAttributes );
|
||||
ctx.importGraphicOrImageProperty("src" , _xAttributes);
|
||||
ctx.importBooleanProperty( "Tabstop", "tabstop", _xAttributes );
|
||||
ctx.importEvents( _events );
|
||||
// avoid ring-reference:
|
||||
@ -1150,7 +1150,7 @@ void TitledBoxElement::endElement()
|
||||
ctx.importStringProperty( "Label", "value", xAttributes );
|
||||
ctx.importAlignProperty( "Align", "align", xAttributes );
|
||||
ctx.importVerticalAlignProperty( "VerticalAlign", "valign", xAttributes );
|
||||
ctx.importImageURLProperty( "ImageURL" , "image-src" , _xAttributes );
|
||||
ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
|
||||
ctx.importImagePositionProperty( "ImagePosition", "image-position", xAttributes );
|
||||
ctx.importBooleanProperty( "MultiLine", "multiline", xAttributes );
|
||||
ctx.importStringProperty( "GroupName", "group-name", xAttributes );
|
||||
@ -1241,7 +1241,7 @@ void RadioGroupElement::endElement()
|
||||
ctx.importStringProperty( "Label", "value", xAttributes );
|
||||
ctx.importAlignProperty( "Align", "align", xAttributes );
|
||||
ctx.importVerticalAlignProperty( "VerticalAlign", "valign", xAttributes );
|
||||
ctx.importImageURLProperty( "ImageURL" , "image-src" , xAttributes );
|
||||
ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
|
||||
ctx.importImagePositionProperty( "ImagePosition", "image-position", xAttributes );
|
||||
ctx.importBooleanProperty( "MultiLine", "multiline", xAttributes );
|
||||
ctx.importStringProperty( "GroupName", "group-name", xAttributes );
|
||||
@ -1491,7 +1491,7 @@ void CheckBoxElement::endElement()
|
||||
ctx.importStringProperty( "Label", "value", _xAttributes );
|
||||
ctx.importAlignProperty( "Align", "align", _xAttributes );
|
||||
ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
|
||||
ctx.importImageURLProperty( "ImageURL" , "image-src" , _xAttributes );
|
||||
ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
|
||||
ctx.importImagePositionProperty( "ImagePosition", "image-position", _xAttributes );
|
||||
ctx.importBooleanProperty( "MultiLine", "multiline", _xAttributes );
|
||||
|
||||
@ -1557,7 +1557,7 @@ void ButtonElement::endElement()
|
||||
ctx.importVerticalAlignProperty( "VerticalAlign", "valign", _xAttributes );
|
||||
ctx.importBooleanProperty( "DefaultButton", "default", _xAttributes );
|
||||
ctx.importButtonTypeProperty( "PushButtonType", "button-type", _xAttributes );
|
||||
ctx.importImageURLProperty( "ImageURL" , "image-src" , _xAttributes );
|
||||
ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
|
||||
ctx.importImagePositionProperty( "ImagePosition", "image-position", _xAttributes );
|
||||
ctx.importImageAlignProperty( "ImageAlign", "image-align", _xAttributes );
|
||||
if (ctx.importLongProperty( "RepeatDelay", "repeat", _xAttributes ))
|
||||
@ -1832,7 +1832,7 @@ void WindowElement::endElement()
|
||||
ctx.importBooleanProperty("Sizeable", "resizeable", _xAttributes );
|
||||
ctx.importStringProperty("Title", "title", _xAttributes );
|
||||
ctx.importBooleanProperty("Decoration", "withtitlebar", _xAttributes );
|
||||
ctx.importImageURLProperty( "ImageURL" , "image-src" , _xAttributes );
|
||||
ctx.importGraphicOrImageProperty("image-src" , _xAttributes);
|
||||
ctx.importScollableSettings( _xAttributes );
|
||||
ctx.importEvents( _events );
|
||||
// avoid ring-reference:
|
||||
|
@ -54,7 +54,9 @@
|
||||
#include <com/sun/star/table/CellAddress.hpp>
|
||||
#include <com/sun/star/table/CellRangeAddress.hpp>
|
||||
#include <com/sun/star/document/XGraphicObjectResolver.hpp>
|
||||
#include <com/sun/star/document/XGraphicStorageHandler.hpp>
|
||||
#include <com/sun/star/document/XStorageBasedDocument.hpp>
|
||||
#include <com/sun/star/graphic/XGraphic.hpp>
|
||||
#include <com/sun/star/util/NumberFormatsSupplier.hpp>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
@ -840,8 +842,8 @@ bool ImportContext::importVerticalAlignProperty(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImportContext::importImageURLProperty(
|
||||
OUString const & rPropName, OUString const & rAttrName,
|
||||
bool ImportContext::importGraphicOrImageProperty(
|
||||
OUString const & rAttrName,
|
||||
Reference< xml::input::XAttributes > const & xAttributes )
|
||||
{
|
||||
OUString sURL = xAttributes->getValueByUidName( _pImport->XMLNS_DIALOGS_UID, rAttrName );
|
||||
@ -849,6 +851,8 @@ bool ImportContext::importImageURLProperty(
|
||||
{
|
||||
Reference< document::XStorageBasedDocument > xDocStorage( _pImport->getDocOwner(), UNO_QUERY );
|
||||
|
||||
uno::Reference<graphic::XGraphic> xGraphic;
|
||||
|
||||
uno::Reference< document::XGraphicObjectResolver > xGraphicResolver;
|
||||
if ( xDocStorage.is() )
|
||||
{
|
||||
@ -857,29 +861,28 @@ bool ImportContext::importImageURLProperty(
|
||||
xGraphicResolver.set(
|
||||
_pImport->getComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext( "com.sun.star.comp.Svx.GraphicImportHelper" , aArgs, _pImport->getComponentContext() ),
|
||||
UNO_QUERY );
|
||||
if ( xGraphicResolver.is() )
|
||||
uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
|
||||
xGraphicStorageHandler.set(xGraphicResolver, uno::UNO_QUERY);
|
||||
if (xGraphicStorageHandler.is())
|
||||
{
|
||||
OUString aTmp("vnd.sun.star.Package:");
|
||||
aTmp += sURL;
|
||||
try
|
||||
{
|
||||
aTmp = xGraphicResolver->resolveGraphicObjectURL( aTmp );
|
||||
if ( !aTmp.isEmpty() )
|
||||
sURL = aTmp;
|
||||
xGraphic = xGraphicStorageHandler->loadGraphic(sURL);
|
||||
}
|
||||
catch( const uno::Exception& )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ( !sURL.isEmpty() )
|
||||
if (xGraphic.is())
|
||||
{
|
||||
Reference< beans::XPropertySet > xProps( getControlModel(), UNO_QUERY );
|
||||
if ( xProps.is() )
|
||||
Reference<beans::XPropertySet> xProps( getControlModel(), UNO_QUERY );
|
||||
if (xProps.is())
|
||||
{
|
||||
xProps->setPropertyValue( rPropName, makeAny( sURL ) );
|
||||
xProps->setPropertyValue("Graphic", makeAny(xGraphic));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user