Author: hanya
Date: Mon Jan 26 09:06:52 2015
New Revision: 1654744

URL: http://svn.apache.org/r1654744
Log:
#i98734# store and load ScaleMode property of image control on dialogs

Suggested by: Frank Schönheit <[email protected]>

Modified:
    openoffice/trunk/main/toolkit/source/helper/property.cxx
    openoffice/trunk/main/xmlscript/dtd/dialog.dtd
    openoffice/trunk/main/xmlscript/source/xmldlg_imexp/exp_share.hxx
    openoffice/trunk/main/xmlscript/source/xmldlg_imexp/imp_share.hxx
    openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
    openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
    openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
    openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx

Modified: openoffice/trunk/main/toolkit/source/helper/property.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/toolkit/source/helper/property.cxx?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/toolkit/source/helper/property.cxx (original)
+++ openoffice/trunk/main/toolkit/source/helper/property.cxx Mon Jan 26 
09:06:52 2015
@@ -217,7 +217,7 @@ ImplPropertyInfo* ImplGetPropertyInfos(
             DECL_PROP_2     ( "AutoRepeat",             AUTO_REPEAT,        
sal_Bool,           BOUND, MAYBEDEFAULT ),
             DECL_PROP_2     ( "RepeatDelay",            REPEAT_DELAY,       
sal_Int32,          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_PROP_2     ( "ScrollValueMax",         SCROLLVALUE_MAX,    
sal_Int32,          BOUND, MAYBEDEFAULT ),
             DECL_PROP_2     ( "ScrollValueMin",         SCROLLVALUE_MIN,    
sal_Int32,          BOUND, MAYBEDEFAULT ),

Modified: openoffice/trunk/main/xmlscript/dtd/dialog.dtd
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmlscript/dtd/dialog.dtd?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/xmlscript/dtd/dialog.dtd (original)
+++ openoffice/trunk/main/xmlscript/dtd/dialog.dtd Mon Jan 26 09:06:52 2015
@@ -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
                   >
 

Modified: openoffice/trunk/main/xmlscript/source/xmldlg_imexp/exp_share.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmlscript/source/xmldlg_imexp/exp_share.hxx?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/xmlscript/source/xmldlg_imexp/exp_share.hxx (original)
+++ openoffice/trunk/main/xmlscript/source/xmldlg_imexp/exp_share.hxx Mon Jan 
26 09:06:52 2015
@@ -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 )

Modified: openoffice/trunk/main/xmlscript/source/xmldlg_imexp/imp_share.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmlscript/source/xmldlg_imexp/imp_share.hxx?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/xmlscript/source/xmldlg_imexp/imp_share.hxx (original)
+++ openoffice/trunk/main/xmlscript/source/xmldlg_imexp/imp_share.hxx Mon Jan 
26 09:06:52 2015
@@ -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 
);
 };
 
 
//==============================================================================

Modified: 
openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx 
(original)
+++ openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx 
Mon Jan 26 09:06:52 2015
@@ -591,6 +591,8 @@ void ElementDescriptor::readImageControl
     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") ),

Modified: openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx 
(original)
+++ openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx Mon 
Jan 26 09:06:52 2015
@@ -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::readSelectionTyp
     }
 }
 
//__________________________________________________________________________________________________
+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") ) ) );

Modified: 
openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx 
(original)
+++ openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx 
Mon Jan 26 09:06:52 2015
@@ -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 );

Modified: openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx?rev=1654744&r1=1654743&r2=1654744&view=diff
==============================================================================
--- openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx 
(original)
+++ openoffice/trunk/main/xmlscript/source/xmldlg_imexp/xmldlg_import.cxx Mon 
Jan 26 09:06:52 2015
@@ -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>
@@ -1337,6 +1338,43 @@ bool ImportContext::importSelectionTypeP
         return true;
     }
     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;
 }
 
 
//==================================================================================================


Reply via email to