Kaydet (Commit) 41146013 authored tarafından Tsutomu Uchino's avatar Tsutomu Uchino Kaydeden (comit) Caolán McNamara

Resolves: #i98734# save/load ScaleMode property of image control on dialogs

Suggested by: Frank Schönheit <frank.schoenheit@gmx.de>
(cherry picked from commit 350c4f9a)

Conflicts:
	xmlscript/source/xmldlg_imexp/exp_share.hxx
	xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
	xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
	xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
	xmlscript/source/xmldlg_imexp/xmldlg_import.cxx

Change-Id: I2a11809112c0b1b53349f5b74dca20897d4a6acd
üst dbf15c90
...@@ -203,7 +203,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) ...@@ -203,7 +203,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount )
DECL_PROP_2 ( "AutoRepeat", AUTO_REPEAT, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "AutoRepeat", AUTO_REPEAT, sal_Bool, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "RepeatDelay", REPEAT_DELAY, sal_Int32, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "RepeatDelay", REPEAT_DELAY, sal_Int32, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "ScaleImage", SCALEIMAGE, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScaleImage", SCALEIMAGE, bool, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "ScaleMode", IMAGE_SCALE_MODE, sal_Int16, BOUND, MAYBEDEFAULT ), DECL_DEP_PROP_2 ( "ScaleMode", IMAGE_SCALE_MODE, sal_Int16, BOUND, MAYBEDEFAULT ),
DECL_DEP_PROP_3 ( "ScrollValue", SCROLLVALUE, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_DEP_PROP_3 ( "ScrollValue", SCROLLVALUE, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
DECL_PROP_2 ( "ScrollValueMax", SCROLLVALUE_MAX, sal_Int32, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScrollValueMax", SCROLLVALUE_MAX, sal_Int32, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "ScrollValueMin", SCROLLVALUE_MIN, sal_Int32, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScrollValueMin", SCROLLVALUE_MIN, sal_Int32, BOUND, MAYBEDEFAULT ),
......
...@@ -242,6 +242,7 @@ ...@@ -242,6 +242,7 @@
<!ATTLIST dlg:img %default-attributes; <!ATTLIST dlg:img %default-attributes;
dlg:src CDATA #IMPLIED dlg:src CDATA #IMPLIED
dlg:scale-image %boolean; #IMPLIED dlg:scale-image %boolean; #IMPLIED
dlg:scale-mode (none|isotropic|anisotropic); #IMPLIED
dlg:tabstop %boolean; #IMPLIED dlg:tabstop %boolean; #IMPLIED
> >
......
...@@ -161,6 +161,8 @@ public: ...@@ -161,6 +161,8 @@ public:
OUString const & rPropName, OUString const & rAttrName ); OUString const & rPropName, OUString const & rAttrName );
void readSelectionTypeAttr( void readSelectionTypeAttr(
OUString const & rPropName, OUString const & rAttrName ); OUString const & rPropName, OUString const & rAttrName );
void readImageScaleModeAttr(
OUString const & rPropName, OUString const & rAttrName );
void readDataAwareAttr( void readDataAwareAttr(
OUString const & rAttrName ); OUString const & rAttrName );
inline void addBoolAttr( inline void addBoolAttr(
......
...@@ -468,6 +468,9 @@ public: ...@@ -468,6 +468,9 @@ public:
bool importDataAwareProperty( bool importDataAwareProperty(
OUString const & rPropName, OUString const & rPropName,
css::uno::Reference<css::xml::input::XAttributes> const & xAttributes ); css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
bool importImageScaleModeProperty(
::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName,
css::uno::Reference<css::xml::input::XAttributes> const & xAttributes );
}; };
class ControlImportContext : public ImportContext class ControlImportContext : public ImportContext
......
...@@ -589,6 +589,7 @@ void ElementDescriptor::readImageControlModel( StyleBag * all_styles ) ...@@ -589,6 +589,7 @@ void ElementDescriptor::readImageControlModel( StyleBag * all_styles )
// collect elements // collect elements
readDefaults(); readDefaults();
readBoolAttr( "ScaleImage", XMLNS_DIALOGS_PREFIX ":scale-image" ); readBoolAttr( "ScaleImage", XMLNS_DIALOGS_PREFIX ":scale-image" );
readImageScaleModeAttr( "ScaleMode", XMLNS_DIALOGS_PREFIX ":scale-mode" );
readBoolAttr( "Tabstop", XMLNS_DIALOGS_PREFIX ":tabstop" ); readBoolAttr( "Tabstop", XMLNS_DIALOGS_PREFIX ":tabstop" );
readImageURLAttr( "ImageURL", XMLNS_DIALOGS_PREFIX ":src" ); readImageURLAttr( "ImageURL", XMLNS_DIALOGS_PREFIX ":src" );
readEvents(); readEvents();
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/awt/FontWidth.hpp> #include <com/sun/star/awt/FontWidth.hpp>
#include <com/sun/star/awt/ImagePosition.hpp> #include <com/sun/star/awt/ImagePosition.hpp>
#include <com/sun/star/awt/ImageScaleMode.hpp>
#include <com/sun/star/awt/LineEndFormat.hpp> #include <com/sun/star/awt/LineEndFormat.hpp>
#include <com/sun/star/awt/PushButtonType.hpp> #include <com/sun/star/awt/PushButtonType.hpp>
#include <com/sun/star/awt/VisualEffect.hpp> #include <com/sun/star/awt/VisualEffect.hpp>
...@@ -1010,6 +1011,36 @@ void ElementDescriptor::readScrollableSettings() ...@@ -1010,6 +1011,36 @@ void ElementDescriptor::readScrollableSettings()
XMLNS_DIALOGS_PREFIX ":vscroll" ); XMLNS_DIALOGS_PREFIX ":vscroll" );
} }
void ElementDescriptor::readImageScaleModeAttr( OUString const & rPropName, OUString const & rAttrName )
{
if (beans::PropertyState_DEFAULT_VALUE != _xPropState->getPropertyState( rPropName ))
{
Any aImageScaleMode( _xProps->getPropertyValue( rPropName ) );
if (aImageScaleMode.getValueTypeClass() == TypeClass_SHORT)
{
sal_Int16 nImageScaleMode;
aImageScaleMode >>= nImageScaleMode;
switch(nImageScaleMode)
{
case ::awt::ImageScaleMode::NONE:
addAttribute( rAttrName, OUString( "none") );
break;
case ::awt::ImageScaleMode::ISOTROPIC:
addAttribute( rAttrName, OUString( "isotropic") );
break;
case ::awt::ImageScaleMode::ANISOTROPIC:
addAttribute( rAttrName, OUString( "anisotropic" ) );
break;
default:
OSL_ENSURE( 0, "### illegal image scale mode value.");
break;
}
}
}
}
void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible ) void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible )
{ {
Any a( _xProps->getPropertyValue( "Name" ) ); Any a( _xProps->getPropertyValue( "Name" ) );
......
...@@ -910,6 +910,7 @@ void ImageControlElement::endElement() ...@@ -910,6 +910,7 @@ void ImageControlElement::endElement()
ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes ); ctx.importDefaults( _nBasePosX, _nBasePosY, _xAttributes );
ctx.importBooleanProperty( "ScaleImage", "scale-image", _xAttributes ); ctx.importBooleanProperty( "ScaleImage", "scale-image", _xAttributes );
ctx.importImageScaleModeProperty( "ScaleMode" , "scale-mode" , _xAttributes );
Reference< document::XStorageBasedDocument > xDocStorage( _pImport->getDocOwner(), UNO_QUERY ); Reference< document::XStorageBasedDocument > xDocStorage( _pImport->getDocOwner(), UNO_QUERY );
ctx.importImageURLProperty( "ImageURL" , "src" , _xAttributes ); ctx.importImageURLProperty( "ImageURL" , "src" , _xAttributes );
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/awt/FontWidth.hpp> #include <com/sun/star/awt/FontWidth.hpp>
#include <com/sun/star/awt/ImagePosition.hpp> #include <com/sun/star/awt/ImagePosition.hpp>
#include <com/sun/star/awt/ImageScaleMode.hpp>
#include <com/sun/star/awt/LineEndFormat.hpp> #include <com/sun/star/awt/LineEndFormat.hpp>
#include <com/sun/star/awt/PushButtonType.hpp> #include <com/sun/star/awt/PushButtonType.hpp>
#include <com/sun/star/awt/VisualEffect.hpp> #include <com/sun/star/awt/VisualEffect.hpp>
...@@ -1363,6 +1364,42 @@ bool ImportContext::importSelectionTypeProperty( ...@@ -1363,6 +1364,42 @@ bool ImportContext::importSelectionTypeProperty(
return false; return false;
} }
bool ImportContext::importImageScaleModeProperty(
OUString const & rPropName, OUString const & rAttrName,
Reference< xml::input::XAttributes > const & xAttributes )
{
OUString aImageScaleMode(
xAttributes->getValueByUidName(
_pImport->XMLNS_DIALOGS_UID, rAttrName ) );
if (!aImageScaleMode.isEmpty())
{
sal_Int16 nImageScaleMode;
if (aImageScaleMode == "none")
{
nImageScaleMode = awt::ImageScaleMode::NONE;
}
else if (aImageScaleMode == "isotropic")
{
nImageScaleMode = awt::ImageScaleMode::ISOTROPIC;
}
else if (aImageScaleMode == "anisotropic")
{
nImageScaleMode = awt::ImageScaleMode::ANISOTROPIC;
}
else
{
throw xml::sax::SAXException(
OUString( "invalid scale image mode value!" ),
Reference< XInterface >(), Any() );
}
_xControlModel->setPropertyValue( rPropName, makeAny( nImageScaleMode ) );
return true;
}
return false;
}
struct StringTriple struct StringTriple
{ {
char const * first; char const * first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment