summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2010-08-05 15:43:06 +0200
committerDaniel Rentz <dr@openoffice.org>2010-08-05 15:43:06 +0200
commit2f19a7db1f8b7a03b52b1e18c31b3ac9b62a7de9 (patch)
tree83b1d2d19a06b642dbb2e0603a36865c796aed4e /sc
parent8eab4b9f3c47d857bc7ffb7080ba02e7f46fdb78 (diff)
mib18: #162503# do not create a new Worksheet object in Workbook.ActiveSheet but return existing object supporting VBA module access
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx19
-rw-r--r--sc/source/ui/vba/vbaworksheets.cxx2
2 files changed, 12 insertions, 9 deletions
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 365c8b35a00c..28469c4685a2 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -50,6 +50,7 @@
#include "vbanames.hxx" // Amelia Wang
#include "nameuno.hxx"
#include "docoptio.hxx"
+#include "unonames.hxx"
// Much of the impl. for the equivalend UNO module is
// sc/source/ui/unoobj/docuno.cxx, viewuno.cxx
@@ -208,7 +209,6 @@ ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface
ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext )
-
{
init();
}
@@ -216,21 +216,24 @@ ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
uno::Reference< excel::XWorksheet >
ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException)
{
- uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ) );
- uno::Reference< sheet::XSpreadsheet > xSheet;
+ uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );
uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- if ( xView.is() )
- xSheet = xView->getActiveSheet();
- return new ScVbaWorksheet( this, mxContext, xSheet, xModel );
+ uno::Reference< beans::XPropertySet > xSheetProps( xView->getActiveSheet(), uno::UNO_QUERY_THROW );
+ // #162503# return the original document module wrapper object, instead of a new instance
+ ::rtl::OUString aCodeName;
+ xSheetProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= aCodeName;
+ ScDocShell* pShell = excel::getDocShell( xModel );
+ if( !pShell )
+ throw uno::RuntimeException();
+ return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW );
}
+
uno::Any SAL_CALL
ScVbaWorkbook::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
{
return Worksheets( aIndex );
}
-
-
uno::Any SAL_CALL
ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
{
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
index 5344e6b3a9be..7fa5196a6b04 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -52,7 +52,7 @@
#include "vbaglobals.hxx"
#include "vbaworksheet.hxx"
#include "vbaworkbook.hxx"
-#include <unonames.hxx>
+#include "unonames.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;