diff options
author | Tsutomu Uchino <hanya@apache.org> | 2015-01-26 09:06:52 +0000 |
---|---|---|
committer | Tsutomu Uchino <hanya@apache.org> | 2015-01-26 09:06:52 +0000 |
commit | 350c4f9a01b88d4fd1006465151348ac5d459f1a (patch) | |
tree | fc5adc9735b9f2adb94d2bd64b29fec17b4d1c23 /xmlscript | |
parent | 1c1efea327d26d61e3feccbd0ee0275707ba997d (diff) |
#i98734# store and load ScaleMode property of image control on dialogs
Suggested by: Frank Schönheit <frank.schoenheit@gmx.de>
Notes
Notes:
merged as: 41146013ad088e6539335454edffc0a394a1d24f
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/dtd/dialog.dtd | 1 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/exp_share.hxx | 2 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/imp_share.hxx | 3 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 2 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_export.cxx | 31 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 3 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_import.cxx | 38 |
7 files changed, 80 insertions, 0 deletions
diff --git a/xmlscript/dtd/dialog.dtd b/xmlscript/dtd/dialog.dtd index 56525f086777..414521e7ea4a 100644 --- a/xmlscript/dtd/dialog.dtd +++ b/xmlscript/dtd/dialog.dtd @@ -247,6 +247,7 @@ <!ATTLIST dlg:img %default-attributes; dlg:src CDATA #IMPLIED dlg:scale-image %boolean; #IMPLIED + dlg:scale-mode (none|isotropic|anisotropic); #IMPLIED dlg:tabstop %boolean; #IMPLIED > diff --git a/xmlscript/source/xmldlg_imexp/exp_share.hxx b/xmlscript/source/xmldlg_imexp/exp_share.hxx index 37ea633aa352..1e2bdaac18b3 100644 --- a/xmlscript/source/xmldlg_imexp/exp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/exp_share.hxx @@ -153,6 +153,8 @@ public: ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); void readSelectionTypeAttr( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); + void readImageScaleModeAttr( + ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName ); // inline void addBoolAttr( ::rtl::OUString const & rAttrName, sal_Bool bValue ) diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx index 1ef84a0c859c..922e4856d29d 100644 --- a/xmlscript/source/xmldlg_imexp/imp_share.hxx +++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx @@ -447,6 +447,9 @@ public: bool importSelectionTypeProperty( ::rtl::OUString const & rPropName, ::rtl::OUString const & rAttrName, 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 ); }; //============================================================================== diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index 46b1b0180f5f..a021e191c142 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -591,6 +591,8 @@ void ElementDescriptor::readImageControlModel( StyleBag * all_styles ) readDefaults(); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleImage") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scale-image") ) ); + readImageScaleModeAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleMode") ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":scale-mode") ) ); readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":src") ) ); readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("Tabstop") ), diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx index 3485138691e3..64ca41a157ec 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/FontWidth.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/PushButtonType.hpp> #include <com/sun/star/awt/VisualEffect.hpp> @@ -968,6 +969,36 @@ void ElementDescriptor::readSelectionTypeAttr( OUString const & rPropName, OUStr } } //__________________________________________________________________________________________________ +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( RTL_CONSTASCII_USTRINGPARAM("none") ) ); + break; + case ::awt::ImageScaleMode::ISOTROPIC: + addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("isotropic") ) ); + break; + case ::awt::ImageScaleMode::ANISOTROPIC: + addAttribute( rAttrName, OUString( RTL_CONSTASCII_USTRINGPARAM("anisotropic") ) ); + break; + default: + OSL_ENSURE( 0, "### illegal image scale mode value."); + break; + } + } + } +} +//__________________________________________________________________________________________________ void ElementDescriptor::readDefaults( bool supportPrintable, bool supportVisible ) { Any a( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index 78bd2ad1c189..011ae7a241ab 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -999,6 +999,9 @@ void ImageControlElement::endElement() ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleImage") ), OUString( RTL_CONSTASCII_USTRINGPARAM("scale-image") ), _xAttributes ); + ctx.importImageScaleModeProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleMode") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("scale-mode") ), + _xAttributes ); ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("ImageURL") ), OUString( RTL_CONSTASCII_USTRINGPARAM("src") ), _xAttributes ); diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx index 0d56d6c7666b..318aa3ec8d47 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx @@ -44,6 +44,7 @@ #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/FontWidth.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/PushButtonType.hpp> #include <com/sun/star/awt/VisualEffect.hpp> @@ -1339,6 +1340,43 @@ bool ImportContext::importSelectionTypeProperty( 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.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("none") )) + { + nImageScaleMode = awt::ImageScaleMode::NONE; + } + else if (aImageScaleMode.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("isotropic") )) + { + nImageScaleMode = awt::ImageScaleMode::ISOTROPIC; + } + else if (aImageScaleMode.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("anisotropic") )) + { + nImageScaleMode = awt::ImageScaleMode::ANISOTROPIC; + } + else + { + throw xml::sax::SAXException( + OUString( RTL_CONSTASCII_USTRINGPARAM("invalid scale image mode value!") ), + Reference< XInterface >(), Any() ); + } + + _xControlModel->setPropertyValue( rPropName, makeAny( nImageScaleMode ) ); + return true; + } + return false; +} + //================================================================================================== struct StringTriple { |