summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2018-09-13 15:38:07 +0100
committerMichael Meeks <michael.meeks@collabora.com>2018-09-17 10:49:38 +0200
commitbe9b83445ec19346a4d5c830c955ed573469591a (patch)
tree089da6003d1e862f745942cfaea996068c265f77
parent694a433d5fbc9ab77dd37e7be9e79f3d3776eb24 (diff)
oovbaapi: hack Excel / OptionButton compatibility into Button for now.
Change-Id: I22d2d545a6201cbb89d430c65f66e0fea8794d83 Reviewed-on: https://gerrit.libreoffice.org/60541 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--oovbaapi/ooo/vba/excel/XButton.idl10
-rw-r--r--sc/source/ui/vba/vbasheetobject.cxx20
-rw-r--r--sc/source/ui/vba/vbasheetobject.hxx4
-rw-r--r--sc/source/ui/vba/vbasheetobjects.cxx35
-rw-r--r--sc/source/ui/vba/vbasheetobjects.hxx3
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx26
-rw-r--r--sc/source/ui/vba/vbaworksheet.hxx4
7 files changed, 78 insertions, 24 deletions
diff --git a/oovbaapi/ooo/vba/excel/XButton.idl b/oovbaapi/ooo/vba/excel/XButton.idl
index 4a7f803ffc85..03ca15b0072f 100644
--- a/oovbaapi/ooo/vba/excel/XButton.idl
+++ b/oovbaapi/ooo/vba/excel/XButton.idl
@@ -29,8 +29,6 @@
module ooo { module vba { module excel {
-
-
/** Additional attributes for a push button drawing control (this interface
does not belong to ActiveX form controls).
*/
@@ -52,12 +50,16 @@ interface XButton : com::sun::star::uno::XInterface
ooo::vba::excel::XlOrientation. */
[attribute] long Orientation;
+ /** OptionButton only hack - are we checked */
+ [attribute] any Value;
+
+ /** OptionButton only hack - another way to get the text */
+ [attribute] string Text;
+
/** Access to text and text formatting of the button caption. */
XCharacters Characters( [in] any Start, [in] any Length );
};
-
-
}; }; };
#endif
diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx
index ac58ce940325..9e5b7856d6c4 100644
--- a/sc/source/ui/vba/vbasheetobject.cxx
+++ b/sc/source/ui/vba/vbasheetobject.cxx
@@ -504,6 +504,26 @@ void SAL_CALL ScVbaButton::setOrientation( sal_Int32 /*nOrientation*/ )
// not supported
}
+uno::Any SAL_CALL ScVbaButton::getValue()
+{
+ return mxControlProps->getPropertyValue( "State" );
+}
+
+void SAL_CALL ScVbaButton::setValue( const uno::Any &nValue )
+{
+ return mxControlProps->setPropertyValue( "State", nValue );
+}
+
+OUString SAL_CALL ScVbaButton::getText()
+{
+ return mxControlProps->getPropertyValue( "Label" ).get< OUString >();
+}
+
+void SAL_CALL ScVbaButton::setText( const OUString &aText )
+{
+ return mxControlProps->setPropertyValue( "Label", uno::Any( aText ) );
+}
+
// XButton methods
uno::Reference< excel::XCharacters > SAL_CALL ScVbaButton::Characters( const uno::Any& rStart, const uno::Any& rLength )
diff --git a/sc/source/ui/vba/vbasheetobject.hxx b/sc/source/ui/vba/vbasheetobject.hxx
index 721bcf99a243..481490f97ae8 100644
--- a/sc/source/ui/vba/vbasheetobject.hxx
+++ b/sc/source/ui/vba/vbasheetobject.hxx
@@ -199,6 +199,10 @@ public:
virtual void SAL_CALL setVerticalAlignment( sal_Int32 nAlign ) override;
virtual sal_Int32 SAL_CALL getOrientation() override;
virtual void SAL_CALL setOrientation( sal_Int32 nOrientation ) override;
+ virtual css::uno::Any SAL_CALL getValue() override;
+ virtual void SAL_CALL setValue( const css::uno::Any &nValue ) override;
+ virtual OUString SAL_CALL getText() override;
+ virtual void SAL_CALL setText( const OUString &aText ) override;
// XButton methods
css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters(
diff --git a/sc/source/ui/vba/vbasheetobjects.cxx b/sc/source/ui/vba/vbasheetobjects.cxx
index 86343729b4a8..1876b30e9127 100644
--- a/sc/source/ui/vba/vbasheetobjects.cxx
+++ b/sc/source/ui/vba/vbasheetobjects.cxx
@@ -371,7 +371,8 @@ public:
const uno::Reference< frame::XModel >& rxModel,
const uno::Reference< sheet::XSpreadsheet >& rxSheet,
const uno::Type& rVbaType,
- const OUString& rModelServiceName );
+ const OUString& rModelServiceName,
+ sal_Int16 /* css::form::FormComponentType */ eType );
protected:
/// @throws uno::RuntimeException
@@ -386,6 +387,7 @@ protected:
protected:
uno::Reference< container::XIndexContainer > mxFormIC;
OUString maModelServiceName;
+ sal_Int16 /* css::form::FormComponentType */ meType;
};
ScVbaControlContainer::ScVbaControlContainer(
@@ -394,9 +396,11 @@ ScVbaControlContainer::ScVbaControlContainer(
const uno::Reference< frame::XModel >& rxModel,
const uno::Reference< sheet::XSpreadsheet >& rxSheet,
const uno::Type& rVbaType,
- const OUString& rModelServiceName ) :
+ const OUString& rModelServiceName,
+ sal_Int16 /* css::form::FormComponentType */ eType ) :
ScVbaObjectContainer( rxParent, rxContext, rxModel, rxSheet, rVbaType ),
- maModelServiceName( rModelServiceName )
+ maModelServiceName( rModelServiceName ),
+ meType( eType )
{
}
@@ -429,7 +433,7 @@ bool ScVbaControlContainer::implPickShape( const uno::Reference< drawing::XShape
uno::Reference< beans::XPropertySet > xModelProps( xControlShape->getControl(), uno::UNO_QUERY_THROW );
sal_Int16 nClassId = -1;
return lclGetProperty( nClassId, xModelProps, "ClassId" ) &&
- (nClassId == form::FormComponentType::COMMANDBUTTON) && implCheckProperties( xModelProps );
+ (nClassId == meType) && implCheckProperties( xModelProps );
}
catch( uno::Exception& )
{
@@ -472,13 +476,15 @@ void ScVbaControlContainer::implOnShapeCreated( const uno::Reference< drawing::X
class ScVbaButtonContainer : public ScVbaControlContainer
{
+ bool mbOptionButtons;
public:
/// @throws uno::RuntimeException
explicit ScVbaButtonContainer(
const uno::Reference< XHelperInterface >& rxParent,
const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference< frame::XModel >& rxModel,
- const uno::Reference< sheet::XSpreadsheet >& rxSheet );
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet,
+ bool bOptionButtons);
protected:
virtual ScVbaSheetObjectBase* implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) override;
@@ -489,11 +495,18 @@ ScVbaButtonContainer::ScVbaButtonContainer(
const uno::Reference< XHelperInterface >& rxParent,
const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference< frame::XModel >& rxModel,
- const uno::Reference< sheet::XSpreadsheet >& rxSheet ) :
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet,
+ bool bOptionButtons ) :
ScVbaControlContainer(
rxParent, rxContext, rxModel, rxSheet,
cppu::UnoType<excel::XButton>::get(),
- "com.sun.star.form.component.CommandButton" )
+ ( bOptionButtons ?
+ OUString( "com.sun.star.form.component.RadioButton" ) :
+ OUString( "com.sun.star.form.component.CommandButton" ) ),
+ ( bOptionButtons ?
+ form::FormComponentType::RADIOBUTTON :
+ form::FormComponentType::COMMANDBUTTON) ),
+ mbOptionButtons(bOptionButtons)
{
}
@@ -505,6 +518,9 @@ ScVbaSheetObjectBase* ScVbaButtonContainer::implCreateVbaObject( const uno::Refe
bool ScVbaButtonContainer::implCheckProperties( const uno::Reference< beans::XPropertySet >& rxModelProps ) const
{
+ if (mbOptionButtons)
+ return true;
+
// do not insert toggle buttons into the 'Buttons' collection
bool bToggle = false;
return lclGetProperty( bToggle, rxModelProps, "Toggle" ) && !bToggle;
@@ -514,8 +530,9 @@ ScVbaButtons::ScVbaButtons(
const uno::Reference< XHelperInterface >& rxParent,
const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference< frame::XModel >& rxModel,
- const uno::Reference< sheet::XSpreadsheet >& rxSheet ) :
- ScVbaGraphicObjectsBase( new ScVbaButtonContainer( rxParent, rxContext, rxModel, rxSheet ) )
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet,
+ bool bOptionButtons) :
+ ScVbaGraphicObjectsBase( new ScVbaButtonContainer( rxParent, rxContext, rxModel, rxSheet, bOptionButtons ) )
{
}
diff --git a/sc/source/ui/vba/vbasheetobjects.hxx b/sc/source/ui/vba/vbasheetobjects.hxx
index ca9872e4f9f4..7fd36bf4cb28 100644
--- a/sc/source/ui/vba/vbasheetobjects.hxx
+++ b/sc/source/ui/vba/vbasheetobjects.hxx
@@ -94,7 +94,8 @@ public:
const css::uno::Reference< ov::XHelperInterface >& rxParent,
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
const css::uno::Reference< css::frame::XModel >& rxModel,
- const css::uno::Reference< css::sheet::XSpreadsheet >& rxSheet );
+ const css::uno::Reference< css::sheet::XSpreadsheet >& rxSheet,
+ bool bOptionButtons);
VBAHELPER_DECL_XHELPERINTERFACE
};
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 87052e0155ad..6a902d7efa83 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -809,16 +809,24 @@ ScVbaWorksheet::Shapes( const uno::Any& aIndex )
return uno::makeAny( xVbaShapes );
}
-uno::Any SAL_CALL
-ScVbaWorksheet::Buttons( const uno::Any& rIndex )
+uno::Any
+ScVbaWorksheet::getButtons( const uno::Any &rIndex, bool bOptionButtons )
{
- if( !mxButtons.is() )
- mxButtons.set( new ScVbaButtons( this, mxContext, mxModel, mxSheet ) );
+ ::rtl::Reference< ScVbaSheetObjectsBase > &rxButtons = bOptionButtons ? mxButtons[0] : mxButtons[1];
+
+ if( !rxButtons.is() )
+ rxButtons.set( new ScVbaButtons( this, mxContext, mxModel, mxSheet, bOptionButtons ) );
else
- mxButtons->collectShapes();
+ rxButtons->collectShapes();
if( rIndex.hasValue() )
- return mxButtons->Item( rIndex, uno::Any() );
- return uno::Any( uno::Reference< XCollection >( mxButtons.get() ) );
+ return rxButtons->Item( rIndex, uno::Any() );
+ return uno::Any( uno::Reference< XCollection >( rxButtons.get() ) );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Buttons( const uno::Any& rIndex )
+{
+ return getButtons( rIndex, false );
}
uno::Any SAL_CALL
@@ -852,9 +860,9 @@ ScVbaWorksheet::ListBoxes( const uno::Any& /*rIndex*/ )
}
uno::Any SAL_CALL
-ScVbaWorksheet::OptionButtons( const uno::Any& /*rIndex*/ )
+ScVbaWorksheet::OptionButtons( const uno::Any& rIndex )
{
- throw uno::RuntimeException();
+ return getButtons( rIndex, true );
}
uno::Any SAL_CALL
diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx
index b706848bea0e..af93e41d350e 100644
--- a/sc/source/ui/vba/vbaworksheet.hxx
+++ b/sc/source/ui/vba/vbaworksheet.hxx
@@ -51,7 +51,7 @@ class ScVbaWorksheet : public WorksheetImpl_BASE
css::uno::Reference< css::frame::XModel > mxModel;
css::uno::Reference< ov::excel::XChartObjects > mxCharts;
css::uno::Reference< ov::excel::XHyperlinks > mxHlinks;
- ::rtl::Reference< ScVbaSheetObjectsBase > mxButtons;
+ ::rtl::Reference< ScVbaSheetObjectsBase > mxButtons[2];
bool mbVeryHidden;
/// @throws css::uno::RuntimeException
@@ -62,6 +62,8 @@ class ScVbaWorksheet : public WorksheetImpl_BASE
css::uno::Reference< css::container::XNameAccess > getFormControls();
css::uno::Any getControlShape( const OUString& sName );
+ css::uno::Any getButtons( const css::uno::Any &rIndex, bool bOptionButtons );
+
public:
/// @throws css::uno::RuntimeException
ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent,