[Libreoffice-commits] core.git: 6 commits - oovbaapi/ooo sc/inc sc/source svtools/inc svtools/source vbahelper/Library_msforms.mk vbahelper/source

Noel Power noel.power at suse.com
Fri Apr 5 09:15:23 PDT 2013


 oovbaapi/ooo/vba/excel/XOLEObject.idl         |    1 
 oovbaapi/ooo/vba/excel/XValidation.idl        |    1 
 oovbaapi/ooo/vba/msforms/XComboBox.idl        |    1 
 sc/inc/cellsuno.hxx                           |    2 
 sc/inc/viewuno.hxx                            |    3 -
 sc/source/ui/unoobj/cellsuno.cxx              |   11 +++
 sc/source/ui/unoobj/viewuno.cxx               |   49 ++++++++++++++++-
 sc/source/ui/vba/vbaapplication.cxx           |   15 +++++
 sc/source/ui/vba/vbaapplication.hxx           |    2 
 sc/source/ui/vba/vbaoleobject.cxx             |   17 +++++
 sc/source/ui/vba/vbaoleobject.hxx             |    4 +
 sc/source/ui/vba/vbarange.cxx                 |    4 -
 sc/source/ui/vba/vbarange.hxx                 |    1 
 sc/source/ui/vba/vbavalidation.cxx            |   59 ++++++++++++++++++++
 sc/source/ui/vba/vbavalidation.hxx            |    1 
 svtools/inc/svtools/bindablecontrolhelper.hxx |    2 
 svtools/source/misc/bindablecontrolhelper.cxx |    8 +-
 vbahelper/Library_msforms.mk                  |    1 
 vbahelper/source/msforms/vbacombobox.cxx      |   10 +++
 vbahelper/source/msforms/vbacombobox.hxx      |    2 
 vbahelper/source/msforms/vbacontrol.cxx       |   74 +++++++++++++++++++++++---
 vbahelper/source/vbahelper/vbacommandbars.cxx |    4 +
 22 files changed, 250 insertions(+), 22 deletions(-)

New commits:
commit 1d633d54bde1c1ae74ae51fcf02d3eced160c1e3
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 5 16:53:23 2013 +0100

    fix Worksheet.Cells by not allowing TableSheet range to change from updates
    
    ScTableSheetObj's own range gets updated via ScCellRangesObj::RefChanged,
    this must be wrong 'cause the range of a sheet is fixed right ?
    
    Change-Id: I19cd39ec58b778f4634258352676da7e04822b65

diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx
index 687105c..6aa36e2 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -1025,7 +1025,7 @@ protected:
 public:
                             ScTableSheetObj(ScDocShell* pDocSh, SCTAB nTab);
     virtual                 ~ScTableSheetObj();
-
+    virtual void            RefChanged();
     void                    InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab);
 
     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 2c0c2b7..1cb7552 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6959,6 +6959,17 @@ ScTableSheetObj::~ScTableSheetObj()
 {
 }
 
+void ScTableSheetObj::RefChanged()
+{
+    // skip calling immediate base
+    // class ScCellRangeObj::RefChanged as
+    // it changes the Sheets range ( which shouldn't
+    // happen ) - hmm maybe we don't even need to
+    // call ScCellRangesBase::RefChanged() :/
+
+    ScCellRangesBase::RefChanged();
+}
+
 void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
 {
     InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
commit 5b8377f80c7618a770900848e205a487d846c66e
Author: Noel Power <noel.power at suse.com>
Date:   Thu Apr 4 17:07:52 2013 +0100

    fix selection change event firing
    
    Change-Id: I64e8b684dd5462e1a742ba47b5480951b4e3a4c4

diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx
index da2f96c..6411979 100644
--- a/sc/inc/viewuno.hxx
+++ b/sc/inc/viewuno.hxx
@@ -205,7 +205,8 @@ private:
     void                    EndMouseListening();
     void                    StartActivationListening();
     void                    EndActivationListening();
-
+    bool                    mbLeftMousePressed;
+    bool                    mbPendingSelectionChanged;
     ScTabViewObj(); // disabled
 public:
                             ScTabViewObj(ScTabViewShell* pViewSh);
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 22c0d9d..7e9e1be 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -463,7 +463,9 @@ ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
     aMouseClickHandlers( 0 ),
     aActivationListeners( 0 ),
     nPreviousTab( 0 ),
-    bDrawSelModeSet(false)
+    bDrawSelModeSet(false),
+    mbLeftMousePressed(false    ),
+    mbPendingSelectionChanged(false)
 {
     if (pViewSh)
         nPreviousTab = pViewSh->GetViewData()->GetTabNo();
@@ -1184,13 +1186,17 @@ bool ScTabViewObj::IsMouseListening() const
     SCTAB nTab = pViewData->GetTabNo();
     return
         pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) ||
-        pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true );
+        pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true ) ||
+        pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_SELECT, true );
+
 }
 
 sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
                                     throw (::uno::RuntimeException)
 {
     sal_Bool bReturn(false);
+    if ( e.Buttons == ::com::sun::star::awt::MouseButton::LEFT )
+        mbLeftMousePressed = true;
 
     uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
     if (!aMouseClickHandlers.empty() && xTarget.is())
@@ -1281,6 +1287,26 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
 sal_Bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
                                     throw (uno::RuntimeException)
 {
+    if ( e.Buttons == ::com::sun::star::awt::MouseButton::LEFT )
+    {
+        try
+        {
+            mbPendingSelectionChanged = false;
+            ScTabViewShell* pViewSh = GetViewShell();
+            ScViewData* pViewData = pViewSh->GetViewData();
+            ScDocShell* pDocSh = pViewData->GetDocShell();
+            ScDocument* pDoc = pDocSh->GetDocument();
+            uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
+            uno::Sequence< uno::Any > aArgs( 1 );
+            aArgs[ 0 ] <<= getSelection();
+            xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs );
+        }
+        catch( uno::Exception& )
+        {
+        }
+        mbLeftMousePressed = false;
+    }
+
     sal_Bool bReturn(false);
 
     if (!aMouseClickHandlers.empty())
@@ -1746,7 +1772,24 @@ void ScTabViewObj::SelectionChanged()
             /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
         }
     }
-    // Removed Sun/Oracle code intentionally, it doesn't work properly ( selection should be fired after mouse release )
+    if ( !mbLeftMousePressed ) // selection still in progress
+    {
+        mbPendingSelectionChanged = false;
+        try
+        {
+            uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
+            uno::Sequence< uno::Any > aArgs( 1 );
+            aArgs[ 0 ] <<= getSelection();
+            xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs );
+        }
+        catch( uno::Exception& )
+        {
+        }
+    }
+    else
+    {
+        mbPendingSelectionChanged = true;
+    }
 }
 
 
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index e9be040..b788368 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -192,11 +192,14 @@ void SAL_CALL ScVbaControl::setEnabled( sal_Bool bVisible ) throw (uno::RuntimeE
 sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException)
 {
     sal_Bool bVisible( sal_True );
+    m_xProps->getPropertyValue ( "EnableVisible" ) >>= bVisible;
     uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
     if ( xControlShape.is() )
     {
+        bool bEnableVisible = bVisible;
         uno::Reference< beans::XPropertySet > xProps( m_xControl, uno::UNO_QUERY_THROW );
         xProps->getPropertyValue ( "Visible" ) >>= bVisible;
+        bVisible = bVisible && bEnableVisible;
     }
     else
         m_xProps->getPropertyValue ( "EnableVisible" ) >>= bVisible;
commit 959d1dc0f3bbf0269d5c7be9a91bba9999d6f821
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 29 17:04:52 2013 +0000

    fix 'Visible' property for XControlShape(s) Foreach support for CommandBars
    
    Seems now we need to additionally set 'Visible' property for XControlShapes
    to ensure correct visibility
    Also we need allow 'For Each' syntax to with with CommandBar collection.
    Note: the implementation of the CommandBar enumeration seems wrong, I
    would have thought that it should match ( and share ) implementation
    details with normal index access ( it doesn't )
    
    Change-Id: Ia5306b4c976f6dc9a5f82e245ca5440f204f5bab

diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 288cefa..e9be040 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -192,7 +192,14 @@ void SAL_CALL ScVbaControl::setEnabled( sal_Bool bVisible ) throw (uno::RuntimeE
 sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException)
 {
     sal_Bool bVisible( sal_True );
-    m_xProps->getPropertyValue( "EnableVisible" ) >>= bVisible;
+    uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
+    if ( xControlShape.is() )
+    {
+        uno::Reference< beans::XPropertySet > xProps( m_xControl, uno::UNO_QUERY_THROW );
+        xProps->getPropertyValue ( "Visible" ) >>= bVisible;
+    }
+    else
+        m_xProps->getPropertyValue ( "EnableVisible" ) >>= bVisible;
     return bVisible;
 }
 
@@ -200,6 +207,12 @@ void SAL_CALL ScVbaControl::setVisible( sal_Bool bVisible ) throw (uno::RuntimeE
 {
     uno::Any aValue( bVisible );
     m_xProps->setPropertyValue( "EnableVisible" , aValue);
+    uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
+    if ( xControlShape.is() )
+    {
+        uno::Reference< beans::XPropertySet > xProps( m_xControl, uno::UNO_QUERY_THROW );
+        xProps->setPropertyValue ( "Visible", aValue );
+    }
 }
 double SAL_CALL ScVbaControl::getHeight() throw (uno::RuntimeException)
 {
diff --git a/vbahelper/source/vbahelper/vbacommandbars.cxx b/vbahelper/source/vbahelper/vbacommandbars.cxx
index 62b5f91..0ca27c2 100644
--- a/vbahelper/source/vbahelper/vbacommandbars.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbars.cxx
@@ -63,6 +63,10 @@ public:
             {
                 uno::Reference< container::XIndexAccess > xCBarSetting = m_pCBarHelper->getSettings( sResourceUrl );
                 uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, m_pCBarHelper, xCBarSetting, sResourceUrl, sal_False ) );
+                // Strange, shouldn't the Enumeration support match/share the
+                // iteration code? ( e.g. ScVbaCommandBars::Item(...) )
+                // and we at least should return here ( something ) it seems
+                return uno::makeAny( xCommandBar );
              }
              else
                 return nextElement();
commit e14a251c2d4478fe8cf085df792aa2181d15b4cf
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 29 16:53:24 2013 +0000

    squash NoSuchElementExceptions when modifying keybindings
    
    Change-Id: I37882845660929e0001a834b6685a4087dfb465f

diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 0d39fa3..07e53cb 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -1295,6 +1295,21 @@ ScVbaApplication::MenuBars( const uno::Any& aIndex ) throw (uno::RuntimeExceptio
     return uno::Any( xMenuBars );
 }
 
+void SAL_CALL ScVbaApplication::OnKey( const ::rtl::OUString& Key, const uno::Any& Procedure ) throw (uno::RuntimeException)
+{
+    try
+    {
+        // Perhaps we can catch some excel specific
+        // related behaviour here
+        VbaApplicationBase::OnKey( Key, Procedure );
+    }
+    catch( container::NoSuchElementException& )
+    {
+        // #TODO special handling for unhandled
+        // bindings
+    }
+}
+
 rtl::OUString
 ScVbaApplication::getServiceImplName()
 {
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 072bd0c..7541178 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -96,7 +96,7 @@ public:
     virtual void SAL_CALL setStatusBar( const css::uno::Any& _statusbar ) throw (css::uno::RuntimeException);
     virtual ::sal_Int32 SAL_CALL getCursor() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setCursor( ::sal_Int32 _cursor ) throw (css::uno::RuntimeException);
-
+    virtual void SAL_CALL OnKey( const ::rtl::OUString& Key, const css::uno::Any& Procedure ) throw (css::uno::RuntimeException);
     virtual sal_Bool SAL_CALL getEnableEvents() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) throw (css::uno::RuntimeException);
 
commit 3ffd86188b470fa7ebd9e6d10678279a1f63a81c
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 5 09:45:38 2013 +0100

    Added and fixed various vba API
    
    Added OLEObject.LinkedCell
    Added ComboBox.LinkedCell
    Added Validation.Type
    
    Change-Id: I5ffc2212e689870d58ca99d1fbdfd7d101f8b50f

diff --git a/oovbaapi/ooo/vba/excel/XOLEObject.idl b/oovbaapi/ooo/vba/excel/XOLEObject.idl
index 9eb3bc2..af1a8d1 100644
--- a/oovbaapi/ooo/vba/excel/XOLEObject.idl
+++ b/oovbaapi/ooo/vba/excel/XOLEObject.idl
@@ -38,6 +38,7 @@ interface XOLEObject
     [attribute] double  Top;
     [attribute] double  Height;
     [attribute] double  Width;
+    [attribute] string  LinkedCell;
 };
 
 //=============================================================================
diff --git a/oovbaapi/ooo/vba/excel/XValidation.idl b/oovbaapi/ooo/vba/excel/XValidation.idl
index 873ca6d..a6549a9 100644
--- a/oovbaapi/ooo/vba/excel/XValidation.idl
+++ b/oovbaapi/ooo/vba/excel/XValidation.idl
@@ -41,6 +41,7 @@ interface XValidation
     [attribute] string ErrorMessage;
     [attribute, readonly] string Formula1;
     [attribute, readonly] string Formula2;
+    [attribute, readonly] long Type;
     void Delete();
     void Add( [in] any Type, [in] any AlertStyle, [in] any Operator, [in] any Formula1, [in] any Formula2);
 };
diff --git a/oovbaapi/ooo/vba/msforms/XComboBox.idl b/oovbaapi/ooo/vba/msforms/XComboBox.idl
index 02ee498..ac1b570 100644
--- a/oovbaapi/ooo/vba/msforms/XComboBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XComboBox.idl
@@ -44,6 +44,7 @@ interface XComboBox
     [attribute] boolean Locked;
     [attribute, readonly] long TextLength;
     [attribute, readonly] XNewFont Font;
+    [attribute] string  LinkedCell;
 
     void AddItem( [in] any pvargItem, [in] any pvargIndex );
     void removeItem( [in] any index );
diff --git a/sc/source/ui/vba/vbaoleobject.cxx b/sc/source/ui/vba/vbaoleobject.cxx
index 6bd3cb5..456629f 100644
--- a/sc/source/ui/vba/vbaoleobject.cxx
+++ b/sc/source/ui/vba/vbaoleobject.cxx
@@ -25,7 +25,10 @@
 #include <ooo/vba/XControlProvider.hpp>
 
 #include "vbaoleobject.hxx"
-
+#include <svx/svdobj.hxx>
+#include "drwlayer.hxx"
+#include "excelvbahelper.hxx"
+#include <svtools/bindablecontrolhelper.hxx>
 using namespace com::sun::star;
 using namespace ooo::vba;
 
@@ -38,7 +41,7 @@ ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParen
     uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW );
     xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
     xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
-    css::uno::Reference< css::frame::XModel > xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
+    uno::Reference<frame::XModel> xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
     uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
     uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( "ooo.vba.ControlProvider" ), mxContext ), uno::UNO_QUERY_THROW );
     m_xControl.set( xControlProvider->createControl(  xControlShape, xModel ) );
@@ -125,6 +128,16 @@ ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException)
     m_xControl->setWidth( _width );
 }
 
+rtl::OUString SAL_CALL ScVbaOLEObject::getLinkedCell() throw (uno::RuntimeException)
+{
+    return m_xControl->getControlSource();
+}
+
+void SAL_CALL ScVbaOLEObject::setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (uno::RuntimeException)
+{
+    m_xControl->setControlSource( _linkedcell );
+}
+
 rtl::OUString
 ScVbaOLEObject::getServiceImplName()
 {
diff --git a/sc/source/ui/vba/vbaoleobject.hxx b/sc/source/ui/vba/vbaoleobject.hxx
index 48bcaf3..4059638 100644
--- a/sc/source/ui/vba/vbaoleobject.hxx
+++ b/sc/source/ui/vba/vbaoleobject.hxx
@@ -45,6 +45,7 @@ public:
     virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (css::uno::RuntimeException);
     virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
+
     virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException);
     virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
@@ -53,7 +54,8 @@ public:
     virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException);
     virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException);
-
+    virtual ::rtl::OUString SAL_CALL getLinkedCell() throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (::com::sun::star::uno::RuntimeException);
 };
 #endif //SC_VBA_OLEOBJECT_HXX
 
diff --git a/sc/source/ui/vba/vbavalidation.cxx b/sc/source/ui/vba/vbavalidation.cxx
index 41189f8..0a9e308 100644
--- a/sc/source/ui/vba/vbavalidation.cxx
+++ b/sc/source/ui/vba/vbavalidation.cxx
@@ -334,6 +334,46 @@ ScVbaValidation::getFormula2() throw (uno::RuntimeException)
     return xCond->getFormula2();
 }
 
+sal_Int32 SAL_CALL
+ScVbaValidation::getType() throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+    sheet::ValidationType nValType = sheet::ValidationType_ANY;
+    xProps->getPropertyValue( STYPE )  >>= nValType;
+    sal_Int32 nExcelType = excel::XlDVType::xlValidateList; // pick a default
+    if ( xProps.is() )
+    {
+        switch ( nValType )
+        {
+            case sheet::ValidationType_LIST:
+                nExcelType = excel::XlDVType::xlValidateList;
+                break;
+            case sheet::ValidationType_ANY: // not ANY not really a great match for anything I fear:-(
+                nExcelType = excel::XlDVType::xlValidateInputOnly;
+                break;
+            case sheet::ValidationType_CUSTOM:
+                nExcelType = excel::XlDVType::xlValidateCustom;
+                break;
+            case sheet::ValidationType_WHOLE:
+                nExcelType = excel::XlDVType::xlValidateWholeNumber;
+                break;
+            case sheet::ValidationType_DECIMAL:
+                nExcelType = excel::XlDVType::xlValidateDecimal;
+                break;
+            case sheet::ValidationType_DATE:
+                nExcelType = excel::XlDVType::xlValidateDate;
+                break;
+            case sheet::ValidationType_TIME:
+                nExcelType = excel::XlDVType::xlValidateTime;
+                break;
+            case sheet::ValidationType_TEXT_LEN:
+                nExcelType = excel::XlDVType::xlValidateTextLength;
+                break;
+        };
+    }
+    return nExcelType;
+}
+
 rtl::OUString
 ScVbaValidation::getServiceImplName()
 {
diff --git a/sc/source/ui/vba/vbavalidation.hxx b/sc/source/ui/vba/vbavalidation.hxx
index 0acd975..ea236a3 100644
--- a/sc/source/ui/vba/vbavalidation.hxx
+++ b/sc/source/ui/vba/vbavalidation.hxx
@@ -51,6 +51,7 @@ public:
     virtual void SAL_CALL setErrorMessage( const ::rtl::OUString& _errormessage ) throw (css::uno::RuntimeException);
     virtual ::rtl::OUString SAL_CALL getFormula1() throw (css::uno::RuntimeException) ;
     virtual ::rtl::OUString SAL_CALL getFormula2() throw (css::uno::RuntimeException);
+    virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException);
     // Methods
     virtual void SAL_CALL Delete(  ) throw (css::uno::RuntimeException);
     virtual void SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& AlertStyle, const css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& Formula2 ) throw (css::uno::RuntimeException);
diff --git a/svtools/inc/svtools/bindablecontrolhelper.hxx b/svtools/inc/svtools/bindablecontrolhelper.hxx
index 15d0d0d..d9e4e7d 100644
--- a/svtools/inc/svtools/bindablecontrolhelper.hxx
+++ b/svtools/inc/svtools/bindablecontrolhelper.hxx
@@ -40,7 +40,7 @@ namespace svt
         BindableControlHelper();    // never implemented
 
     public:
-        SVT_DLLPUBLIC static  void ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource );
+        SVT_DLLPUBLIC static  void ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource, sal_uInt16 nRefTab = 0 );
     };
 
 //........................................................................
diff --git a/svtools/source/misc/bindablecontrolhelper.cxx b/svtools/source/misc/bindablecontrolhelper.cxx
index bdba8a9..904d2b5 100644
--- a/svtools/source/misc/bindablecontrolhelper.cxx
+++ b/svtools/source/misc/bindablecontrolhelper.cxx
@@ -67,7 +67,7 @@ bool lcl_isNamedRange( const rtl::OUString& sAddress, const uno::Reference< fram
 
 
 void
-BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource )
+BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rObj, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource, sal_uInt16 nRefTab )
 {
 // XBindable etc.
     uno::Reference< lang::XMultiServiceFactory > xFac;
@@ -87,7 +87,8 @@ BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno
          {
              // we need this service to properly convert XL notation also
              // Should be easy to extend
-             xConvertor->setPropertyValue( "XL_A1_Representation", uno::makeAny( rsCtrlSource ) );
+             xConvertor->setPropertyValue( "ReferenceSheet", uno::makeAny( nRefTab ) );
+             xConvertor->setPropertyValue( "XLA1Representation", uno::makeAny( rsCtrlSource ) );
              xConvertor->getPropertyValue( "Address" ) >>= aAddress;
          }
 
@@ -119,7 +120,8 @@ BindableControlHelper::ApplyListSourceAndBindableData( const com::sun::star::uno
              {
                  // we need this service to properly convert XL notation also
                  // Should be easy to extend
-                 xConvertor->setPropertyValue( "XL_A1_Representation", uno::makeAny( rsRowSource ) );
+                 xConvertor->setPropertyValue( "ReferenceSheet", uno::makeAny( nRefTab ) );
+                 xConvertor->setPropertyValue( "XLA1Representation", uno::makeAny( rsRowSource ) );
                  xConvertor->getPropertyValue( "Address" ) >>= aAddress;
              }
          }
diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk
index d4bbc08..5b1a34b 100644
--- a/vbahelper/Library_msforms.mk
+++ b/vbahelper/Library_msforms.mk
@@ -55,6 +55,7 @@ $(eval $(call gb_Library_use_libraries,msforms,\
     svl \
     svt \
     svx \
+    svxcore \
     tk \
     tl \
     vbahelper \
diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index 63856e5..de7aa1a 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -277,6 +277,16 @@ void SAL_CALL ScVbaComboBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeEx
     ScVbaControl::setLocked( bLocked );
 }
 
+rtl::OUString SAL_CALL ScVbaComboBox::getLinkedCell() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getControlSource();
+}
+
+void SAL_CALL ScVbaComboBox::setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setControlSource( _linkedcell );
+}
+
 uno::Sequence< OUString >
 ScVbaComboBox::getServiceNames()
 {
diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx
index f71f9c1..06adc9d 100644
--- a/vbahelper/source/msforms/vbacombobox.hxx
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -69,6 +69,8 @@ public:
     virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
     virtual sal_Bool SAL_CALL getLocked() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+    virtual ::rtl::OUString SAL_CALL getLinkedCell() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setLinkedCell( const ::rtl::OUString& _linkedcell ) throw (css::uno::RuntimeException);
 
     // Methods
     virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex ) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index f97ee77..288cefa 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -56,6 +56,10 @@
 #include <vbahelper/helperdecl.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vcl/window.hxx>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <svx/svdobj.hxx>
+
 using namespace com::sun::star;
 using namespace ooo::vba;
 
@@ -286,7 +290,7 @@ ScVbaControl::getControlSource() throw (uno::RuntimeException)
             table::CellAddress aAddress;
             xProps->getPropertyValue( "BoundCell" ) >>= aAddress;
             xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) );
-                    xConvertor->getPropertyValue( "XL_A1_Representation" ) >>= sControlSource;
+                    xConvertor->getPropertyValue( "XLA1Representation" ) >>= sControlSource;
         }
         catch(const uno::Exception&)
         {
@@ -299,7 +303,40 @@ void SAL_CALL
 ScVbaControl::setControlSource( const OUString& _controlsource ) throw (uno::RuntimeException)
 {
     OUString sEmpty;
-    svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, sEmpty );
+    // afaik this is only relevant for Excel documents ( and we need to set up a
+    // reference tab in case no Sheet is specified in "_controlsource"
+    // Can't use the active sheet either, code may of course access
+    uno::Reference< drawing::XDrawPagesSupplier > xSupplier( m_xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
+    sal_Int32 nLen = xIndex->getCount();
+    bool bMatched = false;
+    sal_Int16 nRefTab = 0;
+    for ( sal_Int32 index = 0; index < nLen; ++index )
+    {
+        try
+        {
+            uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
+            uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+            // get the www-standard container
+            uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
+            sal_Int32 nCntrls = xFormControls->getCount();
+            for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
+            {
+                uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
+                bMatched = ( m_xProps == xControl );
+                if ( bMatched )
+                {
+                    nRefTab = index;
+                    break;
+                }
+            }
+        }
+        catch( uno::Exception& ) {}
+        if ( bMatched )
+            break;
+    }
+
+    svt::BindableControlHelper::ApplyListSourceAndBindableData( m_xModel, m_xProps, _controlsource, sEmpty, sal_uInt16( nRefTab ) );
 }
 
 OUString SAL_CALL
@@ -318,7 +355,7 @@ ScVbaControl::getRowSource() throw (uno::RuntimeException)
             table::CellRangeAddress aAddress;
             xProps->getPropertyValue( "CellRange" ) >>= aAddress;
             xConvertor->setPropertyValue( "Address" , uno::makeAny( aAddress ) );
-            xConvertor->getPropertyValue( "XL_A1_Representation" ) >>= sRowSource;
+            xConvertor->getPropertyValue( "XLA1Representation" ) >>= sRowSource;
         }
         catch(const uno::Exception&)
         {
@@ -683,12 +720,21 @@ void ScVbaControl::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeExcep
 
 sal_Bool ScVbaControl::getAutoSize() throw (uno::RuntimeException)
 {
-    return sal_False;
+    bool bIsResizeEnabled = false;
+    uno::Reference< uno::XInterface > xIf( m_xControl, uno::UNO_QUERY_THROW );
+    SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xIf );
+    if ( pObj )
+        bIsResizeEnabled = !pObj->IsResizeProtect();
+    return bIsResizeEnabled;
 }
 
 // currently no implementation for this
-void ScVbaControl::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+void ScVbaControl::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
 {
+    uno::Reference< uno::XInterface > xIf( m_xControl, uno::UNO_QUERY_THROW );
+    SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xIf );
+    if ( pObj )
+        pObj->SetResizeProtect( !bAutoSize );
 }
 
 sal_Bool ScVbaControl::getLocked() throw (uno::RuntimeException)
commit 6f814b5f4ceca2f50edffd8b9023c613fffb9cdf
Author: Noel Power <noel.power at suse.com>
Date:   Fri Mar 29 15:54:08 2013 +0000

    prepend Validation.Formula1 results with '=' for anything not a address
    
    Change-Id: I6061378788b7299f8a8431d1e8d00a4e6ea3e8fb

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 836f2aa..f338332 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1146,7 +1146,7 @@ public:
 };
 
 bool
-getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 )
+ScVbaRange::getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter )
 {
 
     ScDocument* pDoc = NULL;
@@ -1220,7 +1220,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S
         }
 
         sal_uInt16 nFlags = 0;
-        if ( !getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv, aChar ) )
+        if ( !ScVbaRange::getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv, aChar ) )
             return false;
 
         bool bTabFromReferrer = !( nFlags & SCA_TAB_3D );
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index e8cd9a5..26c583e 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -285,6 +285,7 @@ public:
 //     * object should be a lightweight as possible
 //     * we shouldn't need hacks like this below
     static css::uno::Reference< ov::excel::XRange > ApplicationRange( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException);
+    static bool getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 );
     virtual sal_Bool SAL_CALL GoalSeek( const css::uno::Any& Goal, const css::uno::Reference< ov::excel::XRange >& ChangingCell ) throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL SpecialCells( const css::uno::Any& _oType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException );
     // XErrorQuery
diff --git a/sc/source/ui/vba/vbavalidation.cxx b/sc/source/ui/vba/vbavalidation.cxx
index 6fe1ffc..41189f8 100644
--- a/sc/source/ui/vba/vbavalidation.cxx
+++ b/sc/source/ui/vba/vbavalidation.cxx
@@ -28,6 +28,9 @@
 #include <ooo/vba/excel/XlDVAlertStyle.hpp>
 
 #include "unonames.hxx"
+#include "rangelst.hxx"
+#include "excelvbahelper.hxx"
+#include "vbarange.hxx"
 
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
@@ -307,7 +310,21 @@ ScVbaValidation::Add( const uno::Any& Type, const uno::Any& AlertStyle, const un
 ScVbaValidation::getFormula1() throw (uno::RuntimeException)
 {
     uno::Reference< sheet::XSheetCondition > xCond( lcl_getValidationProps( m_xRange ), uno::UNO_QUERY_THROW );
-    return xCond->getFormula1();
+    rtl::OUString sString = xCond->getFormula1();
+
+    sal_uInt16 nFlags = 0;
+    ScRangeList aCellRanges;
+    formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1;
+
+    ScDocShell* pDocSh = excel::GetDocShellFromRange( m_xRange );
+    // in calc validation formula is either a range or formula
+    // that results in range.
+    // In VBA both formula and address can have a leading '='
+    // in result of getFormula1, however it *seems* that a named range or
+    // real formula has to (or is expected to) have the '='
+    if ( pDocSh && !ScVbaRange::getCellRangesForAddress(  nFlags, sString, pDocSh, aCellRanges, eConv ) )
+        sString = "=" + sString;
+    return sString;
 }
 
 ::rtl::OUString SAL_CALL


More information about the Libreoffice-commits mailing list