diff options
author | Noel Grandin <noel@peralex.com> | 2014-06-18 12:14:29 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-06-24 11:34:21 +0200 |
commit | e2080e70fe8b085f18e868e46340454720fa94ca (patch) | |
tree | 4038d1d57b41b68a47d5ebbbe6ad390648ec6303 /sc/source/ui/vba | |
parent | f910280b8704ed9c289150a4ca3c8d60e15d0d97 (diff) |
new compilerplugin returnbyref
Find places where we are returning a pointer to something, where we can
be returning a reference.
e.g.
class A {
struct X x;
public X* getX() { return &x; }
}
which can be:
public X& getX() { return x; }
Change-Id: I796fd23fd36a18aedf6e36bc28f8fab4f518c6c7
Diffstat (limited to 'sc/source/ui/vba')
-rw-r--r-- | sc/source/ui/vba/excelvbahelper.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaapplication.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/vba/vbachart.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaeventshelper.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaname.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/vba/vbanames.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/vba/vbapagesetup.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/vba/vbarange.cxx | 157 | ||||
-rw-r--r-- | sc/source/ui/vba/vbarange.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/vba/vbatextboxshape.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/vba/vbawindow.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworkbook.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheets.cxx | 4 |
14 files changed, 140 insertions, 165 deletions
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index ef7ebc1ad8d8..96c76a725612 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -98,7 +98,7 @@ void implSetZoom( const uno::Reference< frame::XModel >& xModel, sal_Int16 nZoom { ScTabViewShell* pViewSh = excel::getBestViewShell( xModel ); Fraction aFract( nZoom, 100 ); - pViewSh->GetViewData()->SetZoom( aFract, aFract, nTabs ); + pViewSh->GetViewData().SetZoom( aFract, aFract, nTabs ); pViewSh->RefreshZoom(); } @@ -195,8 +195,8 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, sal_uInt16 ScTabViewShell* pTabViewShell = getBestViewShell( xModel ); if ( pTabViewShell ) { - ScViewData* pView = pTabViewShell->GetViewData(); - Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL; + ScViewData& rView = pTabViewShell->GetViewData(); + Window* pWin = rView.GetActiveWin(); if (pWin) { ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); @@ -319,21 +319,21 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance("ooo.vba.VBAObjectModuleObjectProvider"), uno::UNO_QUERY_THROW ); // set up the module info for the workbook and sheets in the nealy created // spreadsheet - ScDocument* pDoc = pShell->GetDocument(); - OUString sCodeName = pDoc->GetCodeName(); + ScDocument& rDoc = pShell->GetDocument(); + OUString sCodeName = rDoc.GetCodeName(); if ( sCodeName.isEmpty() ) { sCodeName = "ThisWorkbook"; - pDoc->SetCodeName( sCodeName ); + rDoc.SetCodeName( sCodeName ); } std::vector< OUString > sDocModuleNames; sDocModuleNames.push_back( sCodeName ); - for ( SCTAB index = 0; index < pDoc->GetTableCount(); index++) + for ( SCTAB index = 0; index < rDoc.GetTableCount(); index++) { OUString aName; - pDoc->GetCodeName( index, aName ); + rDoc.GetCodeName( index, aName ); sDocModuleNames.push_back( aName ); } @@ -359,7 +359,7 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& itself as listener for specific events. */ try { - uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument()->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument().GetVbaEventProcessor(), uno::UNO_SET_THROW ); uno::Sequence< uno::Any > aArgs; xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs ); } diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 95de99017ab2..c050f1153c53 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -302,12 +302,10 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException, std::exception ) ScTabViewShell* pViewShell = excel::getCurrentBestViewShell(mxContext); if ( !pViewShell ) throw uno::RuntimeException("No ViewShell available" ); - ScViewData* pTabView = pViewShell->GetViewData(); - if ( !pTabView ) - throw uno::RuntimeException("No ViewData available" ); + ScViewData& rTabView = pViewShell->GetViewData(); - sal_Int32 nCursorX = pTabView->GetCurX(); - sal_Int32 nCursorY = pTabView->GetCurY(); + sal_Int32 nCursorX = rTabView.GetCurX(); + sal_Int32 nCursorY = rTabView.GetCurY(); // #i117392# excel::getUnoSheetModuleObj() may return null in documents without global VBA mode enabled return new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); @@ -576,9 +574,9 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro { xVbaSheetRange->Select(); uno::Reference< excel::XWindow > xWindow = getActiveWindow(); - ScSplitPos eWhich = pShell->GetViewData()->GetActivePart(); - sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich)); - sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich)); + ScSplitPos eWhich = pShell->GetViewData().GetActivePart(); + sal_Int32 nValueX = pShell->GetViewData().GetPosX(WhichH(eWhich)); + sal_Int32 nValueY = pShell->GetViewData().GetPosY(WhichV(eWhich)); xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaSheetRange->getRow() - 1) ), uno::makeAny( (sal_Int16)nValueY ), uno::makeAny( (sal_Int16)(xVbaSheetRange->getColumn() - 1) ), @@ -616,9 +614,9 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro { xVbaRange->Select(); uno::Reference< excel::XWindow > xWindow = getActiveWindow(); - ScSplitPos eWhich = pShell->GetViewData()->GetActivePart(); - sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich)); - sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich)); + ScSplitPos eWhich = pShell->GetViewData().GetActivePart(); + sal_Int32 nValueX = pShell->GetViewData().GetPosX(WhichH(eWhich)); + sal_Int32 nValueY = pShell->GetViewData().GetPosY(WhichV(eWhich)); xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaRange->getRow() - 1) ), uno::makeAny( (sal_Int16)nValueY ), uno::makeAny( (sal_Int16)(xVbaRange->getColumn() - 1) ), @@ -772,7 +770,7 @@ ScVbaApplication::getDisplayScrollBars() throw (uno::RuntimeException, std::exc ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext ); if ( pShell ) { - return ( pShell->GetViewData()->IsHScrollMode() && pShell->GetViewData()->IsVScrollMode() ); + return ( pShell->GetViewData().IsHScrollMode() && pShell->GetViewData().IsVScrollMode() ); } return true; } @@ -1225,8 +1223,8 @@ ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeExc { OSL_TRACE("ScVbaApplication::Volatile() In method ->%s<-", OUStringToOString( pMeth->GetName(), RTL_TEXTENCODING_UTF8 ).getStr() ); uno::Reference< frame::XModel > xModel( getCurrentDocument() ); - ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); - pDoc->GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), bVolatile); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + rDoc.GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), bVolatile); } // this is bound to break when loading the document diff --git a/sc/source/ui/vba/vbachart.cxx b/sc/source/ui/vba/vbachart.cxx index 811768a374fd..18214850e401 100644 --- a/sc/source/ui/vba/vbachart.cxx +++ b/sc/source/ui/vba/vbachart.cxx @@ -579,13 +579,9 @@ ScVbaChart::setSourceData( const css::uno::Reference< ::ooo::vba::excel::XRange ScVbaRange* pRange = static_cast< ScVbaRange* >( _xCalcRange.get() ); if ( pRange ) { - ScDocument* pDoc = pRange->getScDocument(); - if ( pDoc ) - { - bsetRowHeaders = pDoc->HasRowHeader( static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ) ); - bsetColumnHeaders = pDoc->HasColHeader( static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet )); -; - } + ScDocument& rDoc = pRange->getScDocument(); + bsetRowHeaders = rDoc.HasRowHeader( static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ) ); + bsetColumnHeaders = rDoc.HasColHeader( static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet )); } mxTableChart->setHasRowHeaders(bsetRowHeaders); mxTableChart->setHasColumnHeaders(bsetColumnHeaders); diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index c506dded4893..c4c42a1c30f8 100644 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -510,7 +510,7 @@ ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, co mbOpened( false ) { mpDocShell = dynamic_cast< ScDocShell* >( mpShell ); // mpShell from base class - mpDoc = mpDocShell ? mpDocShell->GetDocument() : 0; + mpDoc = mpDocShell ? &mpDocShell->GetDocument() : 0; if( !mxModel.is() || !mpDocShell || !mpDoc ) return; diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx index f80eaf534519..4949384b17fc 100644 --- a/sc/source/ui/vba/vbaname.cxx +++ b/sc/source/ui/vba/vbaname.cxx @@ -130,12 +130,12 @@ void ScVbaName::setContent( const OUString& rContent, const formula::FormulaGra if ( pNamedRange && pNamedRange->pDocShell ) { - ScDocument* pDoc = pNamedRange->pDocShell->GetDocument(); + ScDocument& rDoc = pNamedRange->pDocShell->GetDocument(); ScRangeData* pOldData = pNamedRange->GetRangeData_Impl(); if (pOldData) { // Shorter way of doing this ? - ScCompiler aComp( pDoc, pOldData->GetPos() ); + ScCompiler aComp( &rDoc, pOldData->GetPos() ); aComp.SetGrammar( eGrammar ); boost::scoped_ptr<ScTokenArray> pArray(aComp.CompileString(sContent)); pOldData->SetCode(*pArray); diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index c93fdbac564b..8cf18ec2183e 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -78,10 +78,8 @@ ScVbaNames::getScDocument() ScTabViewShell * pTabViewShell = excel::getBestViewShell( xModel ); if ( !pTabViewShell ) throw uno::RuntimeException( "No ViewShell available" ); - ScViewData* pViewData = pTabViewShell->GetViewData(); - if ( !pViewData ) - throw uno::RuntimeException( "No ViewData available" ); - return pViewData->GetDocument(); + ScViewData& rViewData = pTabViewShell->GetViewData(); + return rViewData.GetDocument(); } diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx index f422778ccb0b..7f91a80da576 100644 --- a/sc/source/ui/vba/vbapagesetup.cxx +++ b/sc/source/ui/vba/vbapagesetup.cxx @@ -82,8 +82,8 @@ OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeExcepti ScUnoConversion::FillScRange( aRange, aSeq[i] ); aRangeList.Append( aRange ); } - ScDocument* pDoc = excel::getDocShell( mxModel )->GetDocument(); - aRangeList.Format( aPrintArea, nFlags, pDoc, formula::FormulaGrammar::CONV_XL_A1, ',' ); + ScDocument& rDoc = excel::getDocShell( mxModel )->GetDocument(); + aRangeList.Format( aPrintArea, nFlags, &rDoc, formula::FormulaGrammar::CONV_XL_A1, ',' ); } return aPrintArea; diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 75d34169cf2c..57d3ec747257 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -274,18 +274,16 @@ void ScVbaRange::fireChangeEvent() { if( ScVbaApplication::getDocumentEventsEnabled() ) { - if( ScDocument* pDoc = getScDocument() ) + ScDocument& rDoc = getScDocument(); + uno::Reference< script::vba::XVBAEventProcessor > xVBAEvents = rDoc.GetVbaEventProcessor(); + if( xVBAEvents.is() ) try + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= uno::Reference< excel::XRange >( this ); + xVBAEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_CHANGE, aArgs ); + } + catch( uno::Exception& ) { - uno::Reference< script::vba::XVBAEventProcessor > xVBAEvents = pDoc->GetVbaEventProcessor(); - if( xVBAEvents.is() ) try - { - uno::Sequence< uno::Any > aArgs( 1 ); - aArgs[ 0 ] <<= uno::Reference< excel::XRange >( this ); - xVBAEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_CHANGE, aArgs ); - } - catch( uno::Exception& ) - { - } } } } @@ -426,17 +424,17 @@ uno::Reference< frame::XModel > getModelFromRange( const uno::Reference< table:: return getModelFromXIf( xIf ); } -ScDocument* +ScDocument& getDocumentFromRange( const uno::Reference< table::XCellRange >& xRange ) { ScDocShell* pDocShell = getDocShellFromRange( xRange ); if ( !pDocShell ) throw uno::RuntimeException("Failed to access underlying docshell from uno range object" ); - ScDocument* pDoc = pDocShell->GetDocument(); - return pDoc; + ScDocument& rDoc = pDocShell->GetDocument(); + return rDoc; } -ScDocument* +ScDocument& ScVbaRange::getScDocument() throw (uno::RuntimeException) { if ( mxRanges.is() ) @@ -1157,12 +1155,11 @@ bool ScVbaRange::getCellRangesForAddress( sal_uInt16& rResFlags, const OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter ) { - ScDocument* pDoc = NULL; if ( pDocSh ) { - pDoc = pDocSh->GetDocument(); + ScDocument& rDoc = pDocSh->GetDocument(); sal_uInt16 nMask = SCA_VALID; - rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, 0, cDelimiter ); + rResFlags = rCellRanges.Parse( sAddress, &rDoc, nMask, eConv, 0, cDelimiter ); if ( rResFlags & SCA_VALID ) { return true; @@ -1203,17 +1200,14 @@ bool getScRangeListForAddress( const OUString& sName, ScDocShell* pDocSh, ScRang if ( !xNameAccess->hasByName( sAddress ) ) { // try a local name - ScDocument* pDoc = pDocSh->GetDocument(); - if ( pDoc ) + ScDocument& rDoc = pDocSh->GetDocument(); + SCTAB nCurTab = ScDocShell::GetCurTab(); + ScRangeName* pRangeName = rDoc.GetRangeName(nCurTab); + if (pRangeName) { - SCTAB nCurTab = ScDocShell::GetCurTab(); - ScRangeName* pRangeName = pDoc->GetRangeName(nCurTab); - if (pRangeName) - { - bLocalName = pRangeName->findByUpperName(ScGlobal::pCharClass->uppercase(sAddress)) != NULL; - // TODO: Handle local names correctly. - (void)bLocalName; - } + bLocalName = pRangeName->findByUpperName(ScGlobal::pCharClass->uppercase(sAddress)) != NULL; + // TODO: Handle local names correctly. + (void)bLocalName; } } char aChar = 0; @@ -1223,7 +1217,7 @@ bool getScRangeListForAddress( const OUString& sName, ScDocShell* pDocSh, ScRang sAddress = xNamed->getContent(); // As the address comes from OOO, the addressing // style is may not be XL_A1 - eConv = pDocSh->GetDocument()->GetAddressConvention(); + eConv = pDocSh->GetDocument().GetAddressConvention(); aChar = ';'; } @@ -1367,7 +1361,7 @@ util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxC of a merged range is part of this range are not covered. */ ScRange aScRange; ScUnoConversion::FillScRange( aScRange, aRangeAddr ); - bool bHasMerged = getDocumentFromRange( rxCellRange )->HasAttrib( aScRange, HASATTR_MERGED | HASATTR_OVERLAPPED ); + bool bHasMerged = getDocumentFromRange( rxCellRange ).HasAttrib( aScRange, HASATTR_MERGED | HASATTR_OVERLAPPED ); return bHasMerged ? util::TriState_INDETERMINATE : util::TriState_NO; } @@ -1424,10 +1418,8 @@ static uno::Reference< XCollection > lcl_setupBorders( const uno::Reference< excel::XRange >& xParentRange, const uno::Reference<uno::XComponentContext>& xContext, const uno::Reference< table::XCellRange >& xRange ) throw( uno::RuntimeException ) { uno::Reference< XHelperInterface > xParent( xParentRange, uno::UNO_QUERY_THROW ); - ScDocument* pDoc = getDocumentFromRange(xRange); - if ( !pDoc ) - throw uno::RuntimeException("Failed to access document from shell" ); - ScVbaPalette aPalette( pDoc->GetDocumentShell() ); + ScDocument& rDoc = getDocumentFromRange(xRange); + ScVbaPalette aPalette( rDoc.GetDocumentShell() ); uno::Reference< XCollection > borders( new ScVbaBorders( xParent, xContext, xRange, aPalette ) ); return borders; } @@ -1667,7 +1659,7 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar:: aVisitor.visit( valueProcessor ); return; } - CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram ); + CellFormulaValueSetter formulaValueSetter( rFormula, &getScDocument(), eGram ); setValue( rFormula, formulaValueSetter, bFireEvent ); } @@ -1683,7 +1675,7 @@ ScVbaRange::getFormulaValue( formula::FormulaGrammar::Grammar eGram ) throw (uno uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW ); return xRange->getFormula(); } - CellFormulaValueGetter valueGetter( getScDocument(), eGram ); + CellFormulaValueGetter valueGetter( &getScDocument(), eGram ); return getValue( valueGetter ); } @@ -2023,7 +2015,7 @@ ScVbaRange::setFormulaArray(const uno::Any& rFormula) throw (uno::RuntimeExcepti rFormula >>= sFormula; uno::Sequence<sheet::FormulaToken> aTokens = xParser->parseFormula( sFormula, aAddress ); ScTokenArray aTokenArray; - (void)ScTokenConversion::ConvertToTokenArray( *getScDocument(), aTokenArray, aTokens ); + (void)ScTokenConversion::ConvertToTokenArray( getScDocument(), aTokenArray, aTokens ); getScDocShell()->GetDocFunc().EnterMatrix( *getScRangeList()[0], NULL, &aTokenArray, OUString(), true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 ); } @@ -2089,7 +2081,7 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut } sal_uInt16 nFlags = SCA_VALID; ScDocShell* pDocShell = getScDocShell(); - ScDocument* pDoc = pDocShell->GetDocument(); + ScDocument& rDoc = pDocShell->GetDocument(); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); @@ -2126,22 +2118,20 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut table::CellRangeAddress refAddress = getCellRangeAddressForVBARange( RelativeTo, pDocShell ); dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, static_cast< SCROW >( refAddress.StartRow ), static_cast< SCCOL >( refAddress.StartColumn ) ); } - return aRange.Format(nFlags, pDoc, dDetails); + return aRange.Format(nFlags, &rDoc, dDetails); } uno::Reference < excel::XFont > ScVbaRange::Font() throw ( script::BasicErrorException, uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY ); - ScDocument* pDoc = getScDocument(); + ScDocument& rDoc = getScDocument(); if ( mxRange.is() ) xProps.set(mxRange, ::uno::UNO_QUERY ); else if ( mxRanges.is() ) xProps.set(mxRanges, ::uno::UNO_QUERY ); - if ( !pDoc ) - throw uno::RuntimeException("Failed to access document from shell" ); - ScVbaPalette aPalette( pDoc->GetDocumentShell() ); + ScVbaPalette aPalette( rDoc.GetDocumentShell() ); ScCellRangeObj* pRangeObj = NULL; try { @@ -2210,7 +2200,7 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - sal_uInt16 flags = tmpRange.ParseCols( sCol, getDocumentFromRange( xRange ), dDetails ); + sal_uInt16 flags = tmpRange.ParseCols( sCol, &getDocumentFromRange( xRange ), dDetails ); if ( ( flags & 0x200 ) != 0x200 ) throw uno::RuntimeException(); nColumn = tmpRange.aStart.Col() + 1; @@ -2387,7 +2377,7 @@ ScVbaRange::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException, std::exc { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - tmpRange.ParseRows( sAddress, getDocumentFromRange( mxRange ), dDetails ); + tmpRange.ParseRows( sAddress, &getDocumentFromRange( mxRange ), dDetails ); SCROW nStartRow = tmpRange.aStart.Row(); SCROW nEndRow = tmpRange.aEnd.Row(); @@ -2431,7 +2421,7 @@ ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException, std:: { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - tmpRange.ParseCols( sAddress, getDocumentFromRange( mxRange ), dDetails ); + tmpRange.ParseCols( sAddress, &getDocumentFromRange( mxRange ), dDetails ); SCCOL nStartCol = tmpRange.aStart.Col(); SCCOL nEndCol = tmpRange.aEnd.Col(); @@ -2691,7 +2681,7 @@ ScVbaRange::getWrapText() throw (script::BasicErrorException, uno::RuntimeExcept uno::Reference< excel::XInterior > ScVbaRange::Interior( ) throw ( script::BasicErrorException, uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( mxRange, uno::UNO_QUERY_THROW ); - return new ScVbaInterior ( this, mxContext, xProps, getScDocument() ); + return new ScVbaInterior ( this, mxContext, xProps, &getScDocument() ); } uno::Reference< excel::XRange > ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2 ) throw (uno::RuntimeException, std::exception) @@ -3400,15 +3390,13 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal; sal_Int16 nDataOption3 = excel::XlSortDataOption::xlSortNormal; - ScDocument* pDoc = getScDocument(); - if ( !pDoc ) - throw uno::RuntimeException("Failed to access document from shell" ); + ScDocument& rDoc = getScDocument(); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); ScSortParam aSortParam; SCTAB nTab = thisRangeAddress.Sheet; - pDoc->GetSortParam( aSortParam, nTab ); + rDoc.GetSortParam( aSortParam, nTab ); if ( DataOption1.hasValue() ) DataOption1 >>= nDataOption1; @@ -3464,8 +3452,8 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& if ( nHeader == excel::XlYesNoGuess::xlGuess ) { - bool bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), static_cast< SCCOL >( thisRangeAddress.EndColumn ), static_cast< SCROW >( thisRangeAddress.EndRow ), static_cast< SCTAB >( thisRangeAddress.Sheet )); - bool bHasRowHeader = pDoc->HasRowHeader( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), static_cast< SCCOL >( thisRangeAddress.EndColumn ), static_cast< SCROW >( thisRangeAddress.EndRow ), static_cast< SCTAB >( thisRangeAddress.Sheet ) ); + bool bHasColHeader = rDoc.HasColHeader( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), static_cast< SCCOL >( thisRangeAddress.EndColumn ), static_cast< SCROW >( thisRangeAddress.EndRow ), static_cast< SCTAB >( thisRangeAddress.Sheet )); + bool bHasRowHeader = rDoc.HasRowHeader( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), static_cast< SCCOL >( thisRangeAddress.EndColumn ), static_cast< SCROW >( thisRangeAddress.EndRow ), static_cast< SCTAB >( thisRangeAddress.Sheet ) ); if ( bHasColHeader || bHasRowHeader ) nHeader = excel::XlYesNoGuess::xlYes; else @@ -3559,7 +3547,7 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& nIndex = findSortPropertyIndex( sortDescriptor, CONTS_HEADER ); sortDescriptor[ nIndex ].Value <<= bContainsHeader; - pDoc->SetSortParam( aSortParam, nTab ); + rDoc.SetSortParam( aSortParam, nTab ); xSort->sort( sortDescriptor ); // #FIXME #TODO @@ -3663,12 +3651,10 @@ ScVbaRange::characters( const uno::Any& Start, const uno::Any& Length ) throw (u if ( !isSingleCellRange() ) throw uno::RuntimeException("Can't create Characters property for multicell range " ); uno::Reference< text::XSimpleText > xSimple(mxRange->getCellByPosition(0,0) , uno::UNO_QUERY_THROW ); - ScDocument* pDoc = getDocumentFromRange(mxRange); - if ( !pDoc ) - throw uno::RuntimeException("Failed to access document from shell" ); + ScDocument& rDoc = getDocumentFromRange(mxRange); - ScVbaPalette aPalette( pDoc->GetDocumentShell() ); - return new ScVbaCharacters( this, mxContext, aPalette, xSimple, Start, Length ); + ScVbaPalette aPalette( rDoc.GetDocumentShell() ); + return new ScVbaCharacters( this, mxContext, aPalette, xSimple, Start, Length ); } void SAL_CALL @@ -3761,8 +3747,8 @@ double ScVbaRange::getCalcColWidth(const table::CellRangeAddress& rAddress) throw (uno::RuntimeException, std::exception) { - ScDocument* pDoc = getScDocument(); - sal_uInt16 nWidth = pDoc->GetOriginalWidth( static_cast< SCCOL >( rAddress.StartColumn ), static_cast< SCTAB >( rAddress.Sheet ) ); + ScDocument& rDoc = getScDocument(); + sal_uInt16 nWidth = rDoc.GetOriginalWidth( static_cast< SCCOL >( rAddress.StartColumn ), static_cast< SCTAB >( rAddress.Sheet ) ); double nPoints = lcl_TwipsToPoints( nWidth ); nPoints = lcl_Round2DecPlaces( nPoints ); return nPoints; @@ -3772,8 +3758,8 @@ double ScVbaRange::getCalcRowHeight(const table::CellRangeAddress& rAddress) throw (uno::RuntimeException, std::exception) { - ScDocument* pDoc = getDocumentFromRange( mxRange ); - sal_uInt16 nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet ); + ScDocument& rDoc = getDocumentFromRange( mxRange ); + sal_uInt16 nWidth = rDoc.GetOriginalHeight( rAddress.StartRow, rAddress.Sheet ); double nPoints = lcl_TwipsToPoints( nWidth ); nPoints = lcl_Round2DecPlaces( nPoints ); return nPoints; @@ -3782,9 +3768,9 @@ ScVbaRange::getCalcRowHeight(const table::CellRangeAddress& rAddress) // return Char Width in points double getDefaultCharWidth( ScDocShell* pDocShell ) { - ScDocument* pDoc = pDocShell->GetDocument(); - OutputDevice* pRefDevice = pDoc->GetRefDevice(); - ScPatternAttr* pAttr = pDoc->GetDefPattern(); + ScDocument& rDoc = pDocShell->GetDocument(); + OutputDevice* pRefDevice = rDoc.GetRefDevice(); + ScPatternAttr* pAttr = rDoc.GetDefPattern(); ::Font aDefFont; pAttr->GetFont( aDefFont, SC_AUTOCOL_BLACK, pRefDevice ); pRefDevice->SetFont( aDefFont ); @@ -3815,7 +3801,7 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException, std::exception) for( sal_Int32 nCol = nStartCol ; nCol <= nEndCol; ++nCol ) { thisAddress.StartColumn = nCol; - sal_uInt16 nCurTwips = pShell->GetDocument()->GetOriginalWidth( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCTAB >( thisAddress.Sheet ) ); + sal_uInt16 nCurTwips = pShell->GetDocument().GetOriginalWidth( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCTAB >( thisAddress.Sheet ) ); if ( nCol == nStartCol ) nColTwips = nCurTwips; if ( nColTwips != nCurTwips ) @@ -3983,7 +3969,7 @@ ScVbaRange::getRowHeight() for ( sal_Int32 nRow = nStartRow ; nRow <= nEndRow; ++nRow ) { thisAddress.StartRow = nRow; - sal_uInt16 nCurTwips = pShell->GetDocument()->GetOriginalHeight( thisAddress.StartRow, thisAddress.Sheet ); + sal_uInt16 nCurTwips = pShell->GetDocument().GetOriginalHeight( thisAddress.StartRow, thisAddress.Sheet ); if ( nRow == nStartRow ) nRowTwips = nCurTwips; if ( nRowTwips != nCurTwips ) @@ -4037,13 +4023,13 @@ ScVbaRange::getPageBreak() throw (uno::RuntimeException, std::exception) uno::Reference< frame::XModel > xModel = pShell->GetModel(); if ( xModel.is() ) { - ScDocument* pDoc = getDocumentFromRange( mxRange ); + ScDocument& rDoc = getDocumentFromRange( mxRange ); ScBreakType nBreak = BREAK_NONE; if ( !bColumn ) - nBreak = pDoc->HasRowBreak(thisAddress.StartRow, thisAddress.Sheet); + nBreak = rDoc.HasRowBreak(thisAddress.StartRow, thisAddress.Sheet); else - nBreak = pDoc->HasColBreak(thisAddress.StartColumn, thisAddress.Sheet); + nBreak = rDoc.HasColBreak(thisAddress.StartColumn, thisAddress.Sheet); if (nBreak & BREAK_PAGE) nPageBreak = excel::XlPageBreak::xlPageBreakAutomatic; @@ -4276,7 +4262,7 @@ static ScDBData* lcl_GetDBData_Impl( ScDocShell* pDocShell, sal_Int16 nSheet ) ScDBData* pRet = NULL; if (pDocShell) { - pRet = pDocShell->GetDocument()->GetAnonymousDBData(nSheet); + pRet = pDocShell->GetDocument().GetAnonymousDBData(nSheet); } return pRet; } @@ -4441,7 +4427,7 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const RangeHelper multiCellRange( mxRange ); autoFiltAddress = multiCellRange.getCellRangeAddressable()->getRangeAddress(); // #163530# Filter box shows only entry of first row - ScDocument* pDocument = ( pShell ? pShell->GetDocument() : NULL ); + ScDocument* pDocument = ( pShell ? &pShell->GetDocument() : NULL ); if ( pDocument ) { SCCOL nStartCol = autoFiltAddress.StartColumn; @@ -4473,7 +4459,7 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const // set header (autofilter always need column headers) uno::Reference< beans::XPropertySet > xFiltProps( xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY_THROW ); bool bHasColHeader = false; - ScDocument* pDoc = pShell ? pShell->GetDocument() : NULL; + ScDocument* pDoc = pShell ? &pShell->GetDocument() : NULL; if (pDoc) { bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( autoFiltAddress.StartColumn ), static_cast< SCROW >( autoFiltAddress.StartRow ), static_cast< SCCOL >( autoFiltAddress.EndColumn ), static_cast< SCROW >( autoFiltAddress.EndRow ), static_cast< SCTAB >( autoFiltAddress.Sheet ) ); @@ -4881,18 +4867,15 @@ uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException, std::ex (thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn )) { bool bColumn =thisAddress.StartRow == thisAddress.EndRow ? false:sal_True; - ScDocument* pDoc = getDocumentFromRange( mxRange ); - ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), true); - const ScOutlineArray* pOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray(); - if( pOutlineArray ) + ScDocument& rDoc = getDocumentFromRange( mxRange ); + ScOutlineTable* pOutlineTable = rDoc.GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), true); + const ScOutlineArray& rOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray(); + SCCOLROW nPos = bColumn ? (SCCOLROW)(thisAddress.EndColumn-1):(SCCOLROW)(thisAddress.EndRow-1); + const ScOutlineEntry* pEntry = rOutlineArray.GetEntryByPos( 0, nPos ); + if( pEntry ) { - SCCOLROW nPos = bColumn ? (SCCOLROW)(thisAddress.EndColumn-1):(SCCOLROW)(thisAddress.EndRow-1); - const ScOutlineEntry* pEntry = pOutlineArray->GetEntryByPos( 0, nPos ); - if( pEntry ) - { - bShowDetail = !pEntry->IsHidden(); - return uno::makeAny( bShowDetail ); - } + bShowDetail = !pEntry->IsHidden(); + return uno::makeAny( bShowDetail ); } } else @@ -5334,8 +5317,8 @@ ScVbaRange::PreviousNext( bool bIsPrevious ) SCROW nNewY = refRange.aStart.Row(); SCTAB nTab = refRange.aStart.Tab(); - ScDocument* pDoc = getScDocument(); - pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, true,true, markedRange ); + ScDocument& rDoc = getScDocument(); + rDoc.GetNextPos( nNewX,nNewY, nTab, nMove,0, true,true, markedRange ); refRange.aStart.SetCol( nNewX ); refRange.aStart.SetRow( nNewY ); refRange.aStart.SetTab( nTab ); diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index 985823553d83..5fe1c664b412 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -122,7 +122,7 @@ public: ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges, bool bIsRows = false, bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException, css::uno::RuntimeException ); ScVbaRange( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException, css::uno::RuntimeException ); - ScDocument* getScDocument() throw (css::uno::RuntimeException); + ScDocument& getScDocument() throw (css::uno::RuntimeException); ScDocShell* getScDocShell() throw (css::uno::RuntimeException); /** Returns the ScVbaRange implementation object for the passed VBA Range object. */ diff --git a/sc/source/ui/vba/vbatextboxshape.cxx b/sc/source/ui/vba/vbatextboxshape.cxx index 3cbb47743ea1..747aad67543d 100644 --- a/sc/source/ui/vba/vbatextboxshape.cxx +++ b/sc/source/ui/vba/vbatextboxshape.cxx @@ -47,7 +47,7 @@ uno::Reference< excel::XCharacters > SAL_CALL ScVbaTextBoxShape::characters( const uno::Any& Start, const uno::Any& Length ) throw (uno::RuntimeException, std::exception) { ScDocShell* pDocShell = excel::getDocShell( m_xModel ); - ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL; + ScDocument* pDoc = pDocShell ? &pDocShell->GetDocument() : NULL; if ( !pDoc ) throw uno::RuntimeException("Failed to access document from shell" ); diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index ac89af3c0ab4..3f383c6da532 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -111,9 +111,9 @@ public: if ( !pViewShell ) throw uno::RuntimeException("Cannot obtain view shell" ); - SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); + SCTAB nTabCount = pDocShell->GetDocument().GetTableCount(); SCTAB nIndex = 0; - const ScMarkData& rMarkData = pViewShell->GetViewData()->GetMarkData(); + const ScMarkData& rMarkData = pViewShell->GetViewData().GetMarkData(); sheets.reserve( nTabCount ); uno::Reference <sheet::XSpreadsheetDocument> xSpreadSheet( m_xModel, uno::UNO_QUERY_THROW ); uno::Reference <container::XIndexAccess> xIndex( xSpreadSheet->getSheets(), uno::UNO_QUERY_THROW ); @@ -355,8 +355,8 @@ ScVbaWindow::getScrollRow() throw (uno::RuntimeException, std::exception) ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { - ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart(); - nValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich)); + ScSplitPos eWhich = pViewShell->GetViewData().GetActivePart(); + nValue = pViewShell->GetViewData().GetPosY(WhichV(eWhich)); } return uno::makeAny( nValue + 1); @@ -371,8 +371,8 @@ ScVbaWindow::setScrollRow( const uno::Any& _scrollrow ) throw (uno::RuntimeExcep { sal_Int32 scrollRow = 0; _scrollrow >>= scrollRow; - ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart(); - sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich)) + 1; + ScSplitPos eWhich = pViewShell->GetViewData().GetActivePart(); + sal_Int32 nOldValue = pViewShell->GetViewData().GetPosY(WhichV(eWhich)) + 1; pViewShell->ScrollLines(0, scrollRow - nOldValue); } } @@ -385,8 +385,8 @@ ScVbaWindow::getScrollColumn() throw (uno::RuntimeException, std::exception) ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { - ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart(); - nValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich)); + ScSplitPos eWhich = pViewShell->GetViewData().GetActivePart(); + nValue = pViewShell->GetViewData().GetPosX(WhichH(eWhich)); } return uno::makeAny( nValue + 1); @@ -401,8 +401,8 @@ ScVbaWindow::setScrollColumn( const uno::Any& _scrollcolumn ) throw (uno::Runtim { sal_Int32 scrollColumn = 0; _scrollcolumn >>= scrollColumn; - ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart(); - sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich)) + 1; + ScSplitPos eWhich = pViewShell->GetViewData().GetActivePart(); + sal_Int32 nOldValue = pViewShell->GetViewData().GetPosX(WhichH(eWhich)) + 1; pViewShell->ScrollLines(scrollColumn - nOldValue, 0); } } @@ -794,7 +794,7 @@ ScVbaWindow::getView() throw (uno::RuntimeException, std::exception) ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if (pViewShell) - bPageBreak = pViewShell->GetViewData()->IsPagebreakMode(); + bPageBreak = pViewShell->GetViewData().IsPagebreakMode(); if( bPageBreak ) nWindowView = excel::XlWindowView::xlPageBreakPreview; @@ -871,9 +871,9 @@ ScVbaWindow::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::scri double SAL_CALL ScVbaWindow::getTabRatio() throw (css::uno::RuntimeException, std::exception) { ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); - if ( pViewShell && pViewShell->GetViewData() && pViewShell->GetViewData()->GetView() ) + if ( pViewShell && pViewShell->GetViewData().GetView() ) { - double fRatio = pViewShell->GetViewData()->GetView()->GetRelTabBarWidth(); + double fRatio = pViewShell->GetViewData().GetView()->GetRelTabBarWidth(); if ( fRatio >= 0.0 && fRatio <= 1.0 ) return fRatio; } @@ -883,10 +883,10 @@ double SAL_CALL ScVbaWindow::getTabRatio() throw (css::uno::RuntimeException, st void SAL_CALL ScVbaWindow::setTabRatio( double fRatio ) throw (css::uno::RuntimeException, std::exception) { ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); - if ( pViewShell && pViewShell->GetViewData() && pViewShell->GetViewData()->GetView() ) + if ( pViewShell && pViewShell->GetViewData().GetView() ) { if ( fRatio >= 0.0 && fRatio <= 1.0 ) - pViewShell->GetViewData()->GetView()->SetRelTabBarWidth( fRatio ); + pViewShell->GetViewData().GetView()->SetRelTabBarWidth( fRatio ); } } diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index 7599126b685c..d78bdde29f80 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -280,17 +280,17 @@ ScVbaWorkbook::getProtectStructure() throw (uno::RuntimeException, std::exceptio sal_Bool SAL_CALL ScVbaWorkbook::getPrecisionAsDisplayed() throw (uno::RuntimeException, std::exception) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); - return pDoc->GetDocOptions().IsCalcAsShown(); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + return rDoc.GetDocOptions().IsCalcAsShown(); } void SAL_CALL ScVbaWorkbook::setPrecisionAsDisplayed( sal_Bool _precisionAsDisplayed ) throw (uno::RuntimeException, std::exception) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); - ScDocOptions aOpt = pDoc->GetDocOptions(); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + ScDocOptions aOpt = rDoc.GetDocOptions(); aOpt.SetCalcAsShown( _precisionAsDisplayed ); - pDoc->SetDocOptions( aOpt ); + rDoc.SetDocOptions( aOpt ); } void diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index b367e3611c9a..4b5d2d4a62a1 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -234,7 +234,7 @@ ScVbaWorksheet::createSheetCopyInNewDoc(const OUString& aCurrSheetName) ScDocShell* pShell = excel::getDocShell( xModel ); OUString aCodeName; - pShell->GetDocument()->GetCodeName( 0, aCodeName ); + pShell->GetDocument().GetCodeName( 0, aCodeName ); return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW ); } @@ -344,8 +344,8 @@ ScVbaWorksheet::getEnableSelection() throw (uno::RuntimeException, std::exceptio if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) ) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); - ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); bool bLockedCells = false; bool bUnlockedCells = false; if( pProtect ) @@ -379,8 +379,8 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) ) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); - ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); // default is xlNoSelection bool bLockedCells = false; bool bUnlockedCells = false; @@ -407,8 +407,8 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException, std::exception) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); - ScDBData* pDBData = pDoc->GetAnonymousDBData(getSheetID()); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + ScDBData* pDBData = rDoc.GetAnonymousDBData(getSheetID()); if (pDBData) return pDBData->HasAutoFilter(); return false; @@ -418,19 +418,19 @@ void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) thro { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); ScDocShell* pDocShell = excel::getDocShell( xModel ); - ScDocument* pDoc = pDocShell->GetDocument(); - ScDBData* pDBData = pDoc->GetAnonymousDBData(getSheetID()); + ScDocument& rDoc = pDocShell->GetDocument(); + ScDBData* pDBData = rDoc.GetAnonymousDBData(getSheetID()); if (pDBData) { pDBData->SetAutoFilter(bAutoFilterMode); ScRange aRange; pDBData->GetArea(aRange); - if (bAutoFilterMode && pDoc) - pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(), + if (bAutoFilterMode) + rDoc.ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(), aRange.aStart.Tab(), SC_MF_AUTO ); - else if (!bAutoFilterMode && pDoc) - pDoc->RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), + else if (!bAutoFilterMode) + rDoc.RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(), aRange.aStart.Tab(), SC_MF_AUTO ); ScRange aPaintRange(aRange.aStart, aRange.aEnd); @@ -519,8 +519,8 @@ ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException, std::ex if ( bSheetExists ) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); - ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); if ( pProtect ) return pProtect->isOptionEnabled( ScTableProtection::OBJECTS ); } diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 7a88275337cb..038b3f052bd4 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -370,7 +370,7 @@ ScVbaWorksheets::Select( const uno::Any& Replace ) throw (uno::RuntimeException, if ( !pViewShell ) throw uno::RuntimeException("Cannot obtain view shell" ); - ScMarkData& rMarkData = pViewShell->GetViewData()->GetMarkData(); + ScMarkData& rMarkData = pViewShell->GetViewData().GetMarkData(); bool bReplace = true; Replace >>= bReplace; // Replace is defaulted to True, meanining this current collection @@ -549,7 +549,7 @@ void ScVbaWorksheets::PrintPreview( const css::uno::Any& /*EnableChanges*/ ) thr WaitUntilPreviewIsClosed( pViewFrame ); // restore old tab selection pViewShell = excel::getBestViewShell( mxModel ); - pViewShell->GetViewData()->GetMarkData().SetSelectedTabs(aOldTabs); + pViewShell->GetViewData().GetMarkData().SetSelectedTabs(aOldTabs); } } } |