summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2010-09-14 23:23:30 +0200
committerNiklas Nebel <nn@openoffice.org>2010-09-14 23:23:30 +0200
commit7e98422fec2e9132dee0bacba19f323a4b192509 (patch)
treecc311dc7928557d84a239d1c7d436d7fca56bf4b /sc
parentmib19: #163566# compare cursor position in ScDocFunc::NotifyInputHandler (diff)
downloadcore-7e98422fec2e9132dee0bacba19f323a4b192509.tar.gz
core-7e98422fec2e9132dee0bacba19f323a4b192509.zip
mib19: #163566# use common helper method for ScVbaRange::Cells and ScVbaWorksheet::Cells
Diffstat (limited to 'sc')
-rwxr-xr-xsc/source/ui/vba/vbarange.cxx24
-rw-r--r--sc/source/ui/vba/vbarange.hxx6
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx5
3 files changed, 28 insertions, 7 deletions
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index d32ad0a4b41e..95b54cc1f9d2 100755
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -2060,6 +2060,18 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr
return xRange->Cells( nRowIndex, nColumnIndex );
}
+ // Performance: Use a common helper method for ScVbaRange::Cells and ScVbaWorksheet::Cells,
+ // instead of creating a new ScVbaRange object in often-called ScVbaWorksheet::Cells
+ return CellsHelper( mxParent, mxContext, mxRange, nRowIndex, nColumnIndex );
+}
+
+// static
+uno::Reference< excel::XRange >
+ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< css::table::XCellRange >& xRange,
+ const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) throw(uno::RuntimeException)
+{
sal_Int32 nRow = 0, nColumn = 0;
sal_Bool bIsIndex = nRowIndex.hasValue();
@@ -2071,7 +2083,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr
// convertion routine e.g. bSuccess = getValueFromAny( nRow, nRowIndex, getCppuType((sal_Int32*)0) )
if ( nRowIndex.hasValue() && !( nRowIndex >>= nRow ) )
{
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext );
uno::Any aConverted;
try
{
@@ -2082,7 +2094,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr
}
if ( bIsColumnIndex && !( nColumnIndex >>= nColumn ) )
{
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext );
uno::Any aConverted;
try
{
@@ -2092,17 +2104,17 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr
catch( uno::Exception& ) {} // silence any errors
}
- RangeHelper thisRange( mxRange );
+ RangeHelper thisRange( xRange );
table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet();
if( !bIsIndex && !bIsColumnIndex ) // .Cells
// #FIXE needs proper parent ( Worksheet )
- return uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, mxRange ) );
+ return uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xRange ) );
sal_Int32 nIndex = --nRow;
if( bIsIndex && !bIsColumnIndex ) // .Cells(n)
{
- uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, ::uno::UNO_QUERY_THROW);
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(xRange, ::uno::UNO_QUERY_THROW);
sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount();
if ( !nIndex || nIndex < 0 )
@@ -2115,7 +2127,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr
--nColumn;
nRow = nRow + thisRangeAddress.StartRow;
nColumn = nColumn + thisRangeAddress.StartColumn;
- return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) );
+ return new ScVbaRange( xParent, xContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) );
}
void
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index e7488e434f30..a8aada649575 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -149,6 +149,12 @@ public:
const rtl::OUString& sRangeName, ScDocShell* pDocSh,
formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException );
+ static css::uno::Reference< ov::excel::XRange > CellsHelper(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::table::XCellRange >& xRange,
+ const css::uno::Any &nRowIndex, const css::uno::Any &nColumnIndex ) throw(css::uno::RuntimeException);
+
// Attributes
virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue( const css::uno::Any& aValue ) throw ( css::uno::RuntimeException);
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 1f31cb7e19ce..c57048d5b148 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -658,7 +658,10 @@ uno::Reference< excel::XRange >
ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol )
throw (uno::RuntimeException)
{
- return getSheetRange()->Cells( nRow, nCol );
+ // Performance optimization for often-called Cells method:
+ // Use a common helper method instead of creating a new ScVbaRange object
+ uno::Reference< table::XCellRange > xRange( getSheet(), uno::UNO_QUERY_THROW );
+ return ScVbaRange::CellsHelper( mxParent, mxContext, xRange, nRow, nCol );
}
uno::Reference< excel::XRange >