diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-05-23 23:44:53 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-05-23 23:54:21 -0400 |
commit | dd7605f9908a2c584cf262ad5012577c50f0291c (patch) | |
tree | ac7fbffbed8a4966ab2967027f1403bd6929b5c1 /sc/source/ui/vba/vbawindow.cxx | |
parent | c0c3091c23683cbf68fd40584b07c5432ca5750a (diff) |
Got it to build. Mostly VBA stuff but no idea what kind of shape it is in.
Diffstat (limited to 'sc/source/ui/vba/vbawindow.cxx')
-rw-r--r-- | sc/source/ui/vba/vbawindow.cxx | 211 |
1 files changed, 123 insertions, 88 deletions
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index 761671727e9c..a6d2566c10a9 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -60,11 +60,9 @@ typedef boost::unordered_map< rtl::OUString, SCTAB, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > NameIndexHash; -typedef std::vector < uno::Reference< sheet::XSpreadsheet > > Sheets; +typedef std::vector< uno::Reference< sheet::XSpreadsheet > > Sheets; -typedef ::cppu::WeakImplHelper1< container::XEnumeration - -> Enumeration_BASE; +typedef ::cppu::WeakImplHelper1< container::XEnumeration > Enumeration_BASE; typedef ::cppu::WeakImplHelper3< container::XEnumerationAccess , com::sun::star::container::XIndexAccess @@ -201,13 +199,20 @@ public: }; -ScVbaWindow::ScVbaWindow( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext, xModel ) +ScVbaWindow::ScVbaWindow( + const uno::Reference< XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< frame::XModel >& xModel, + const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) : + WindowImpl_BASE( xParent, xContext, xModel, xController ) { init(); } -ScVbaWindow::ScVbaWindow( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext ) - : WindowImpl_BASE( args, xContext ) +ScVbaWindow::ScVbaWindow( + const uno::Sequence< uno::Any >& args, + const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException) : + WindowImpl_BASE( args, xContext ) { init(); } @@ -219,20 +224,42 @@ ScVbaWindow::init() still zero. The implementation of ActivePane() uses a UNO reference of this (to set this window as parent of the pane obejct). This requires the own refcount to be non-zero, otherwise this instance will be - desctructed immediately! */ + desctructed immediately! Guard the call to ActivePane() in try/catch to + not miss the decrementation of the reference count on exception. */ osl_incrementInterlockedCount( &m_refCount ); - uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - m_xViewPane.set( xController, uno::UNO_QUERY_THROW ); - m_xViewFreezable.set( xController, uno::UNO_QUERY_THROW ); - m_xViewSplitable.set( xController, uno::UNO_QUERY_THROW ); - m_xPane.set( ActivePane(), uno::UNO_QUERY_THROW ); - m_xDevice.set( xController->getFrame()->getComponentWindow(), uno::UNO_QUERY_THROW ); + try + { + m_xPane = ActivePane(); + } + catch( uno::Exception& ) + { + } osl_decrementInterlockedCount( &m_refCount ); } +uno::Reference< beans::XPropertySet > +ScVbaWindow::getControllerProps() throw (uno::RuntimeException) +{ + return uno::Reference< beans::XPropertySet >( getController(), uno::UNO_QUERY_THROW ); +} + +uno::Reference< beans::XPropertySet > +ScVbaWindow::getFrameProps() throw (uno::RuntimeException) +{ + return uno::Reference< beans::XPropertySet >( getController()->getFrame(), uno::UNO_QUERY_THROW ); +} + +uno::Reference< awt::XDevice > +ScVbaWindow::getDevice() throw (uno::RuntimeException) +{ + return uno::Reference< awt::XDevice >( getWindow(), uno::UNO_QUERY_THROW ); +} + void ScVbaWindow::Scroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft, bool bLargeScroll ) throw (uno::RuntimeException) { + if( !m_xPane.is() ) + throw uno::RuntimeException(); if( bLargeScroll ) m_xPane->LargeScroll( Down, Up, ToRight, ToLeft ); else @@ -254,7 +281,7 @@ ScVbaWindow::LargeScroll( const uno::Any& Down, const uno::Any& Up, const uno::A uno::Any SAL_CALL ScVbaWindow::SelectedSheets( const uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< container::XEnumerationAccess > xEnumAccess( new SelectedSheetsEnumAccess( mxContext, m_xModel ) ); + uno::Reference< container::XEnumerationAccess > xEnumAccess( new SelectedSheetsEnumAccess( mxContext, m_xModel ) ); // #FIXME needs a workbook as a parent uno::Reference< excel::XWorksheets > xSheets( new ScVbaWorksheets( uno::Reference< XHelperInterface >(), mxContext, xEnumAccess, m_xModel ) ); if ( aIndex.hasValue() ) @@ -270,17 +297,20 @@ ScVbaWindow::ScrollWorkbookTabs( const uno::Any& /*Sheets*/, const uno::Any& /*P { // #TODO #FIXME need some implementation to scroll through the tabs // but where is this done? -} -uno::Reference< beans::XPropertySet > -getPropsFromModel( const uno::Reference< frame::XModel >& xModel ) -{ - uno::Reference< frame::XController > xController = xModel->getCurrentController(); - if ( !xController.is() ) - throw uno::RuntimeException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM ("No controller for model") ), uno::Reference< uno::XInterface >() ); - return uno::Reference< beans::XPropertySet >( xController->getFrame(), uno::UNO_QUERY ); -} +/* + sal_Int32 nSheets = 0; + sal_Int32 nPosition = 0; + throw uno::RuntimeException( rtl::OUString::createFromAscii("No Implemented" ), uno::Reference< uno::XInterface >() ); + sal_Bool bSheets = ( Sheets >>= nSheets ); + sal_Bool bPosition = ( Position >>= nPosition ); + if ( bSheets || bPosition ) // at least one param specified + if ( bSheets ) + ;// use sheets + else if ( bPosition ) + ; //use position +*/ +} uno::Any SAL_CALL ScVbaWindow::getCaption() throw (uno::RuntimeException) @@ -288,9 +318,8 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException) static rtl::OUString sCrud(RTL_CONSTASCII_USTRINGPARAM(" - OpenOffice.org Calc" ) ); static sal_Int32 nCrudLen = sCrud.getLength(); - uno::Reference< beans::XPropertySet > xProps = getPropsFromModel( m_xModel ); rtl::OUString sTitle; - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SC_UNONAME_TITLE ) ) ) >>= sTitle; + getFrameProps()->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SC_UNONAME_TITLE ) ) ) >>= sTitle; sal_Int32 nCrudIndex = sTitle.indexOf( sCrud ); // adjust title ( by removing crud ) // sCrud string present @@ -326,16 +355,14 @@ ScVbaWindow::getCaption() throw (uno::RuntimeException) void SAL_CALL ScVbaWindow::setCaption( const uno::Any& _caption ) throw (uno::RuntimeException) { - - uno::Reference< beans::XPropertySet > xProps = getPropsFromModel( m_xModel ); - xProps->setPropertyValue( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM ( SC_UNONAME_TITLE ) ) , _caption ); + getFrameProps()->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_TITLE ) ), _caption ); } uno::Any SAL_CALL ScVbaWindow::getScrollRow() throw (uno::RuntimeException) { sal_Int32 nValue = 0; + // !! TODO !! get view shell from controller ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { @@ -349,6 +376,7 @@ ScVbaWindow::getScrollRow() throw (uno::RuntimeException) void SAL_CALL ScVbaWindow::setScrollRow( const uno::Any& _scrollrow ) throw (uno::RuntimeException) { + // !! TODO !! get view shell from controller ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { @@ -364,6 +392,7 @@ uno::Any SAL_CALL ScVbaWindow::getScrollColumn() throw (uno::RuntimeException) { sal_Int32 nValue = 0; + // !! TODO !! get view shell from controller ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { @@ -377,6 +406,7 @@ ScVbaWindow::getScrollColumn() throw (uno::RuntimeException) void SAL_CALL ScVbaWindow::setScrollColumn( const uno::Any& _scrollcolumn ) throw (uno::RuntimeException) { + // !! TODO !! get view shell from controller ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) { @@ -392,6 +422,7 @@ uno::Any SAL_CALL ScVbaWindow::getWindowState() throw (uno::RuntimeException) { sal_Int32 nwindowState = xlNormal; + // !! TODO !! get view shell from controller ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame(); WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow(); @@ -410,6 +441,7 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeE { sal_Int32 nwindowState = xlMaximized; _windowstate >>= nwindowState; + // !! TODO !! get view shell from controller ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame(); WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow(); @@ -444,7 +476,8 @@ ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Reference< excel::XPane > SAL_CALL ScVbaWindow::ActivePane() throw (script::BasicErrorException, uno::RuntimeException) { - return new ScVbaPane( this, mxContext, m_xModel, m_xViewPane ); + uno::Reference< sheet::XViewPane > xViewPane( getController(), uno::UNO_QUERY_THROW ); + return new ScVbaPane( this, mxContext, m_xModel, xViewPane ); } uno::Reference< excel::XRange > SAL_CALL @@ -472,10 +505,9 @@ ScVbaWindow::RangeSelection() throw (script::BasicErrorException, uno::RuntimeEx ::sal_Bool SAL_CALL ScVbaWindow::getDisplayGridlines() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHOWGRID ) ); sal_Bool bGrid = sal_True; - xProps->getPropertyValue( sName ) >>= bGrid; + getControllerProps()->getPropertyValue( sName ) >>= bGrid; return bGrid; } @@ -483,131 +515,125 @@ ScVbaWindow::getDisplayGridlines() throw (uno::RuntimeException) void SAL_CALL ScVbaWindow::setDisplayGridlines( ::sal_Bool _displaygridlines ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHOWGRID ) ); - xProps->setPropertyValue( sName, uno::makeAny( _displaygridlines )); + getControllerProps()->setPropertyValue( sName, uno::makeAny( _displaygridlines )); } ::sal_Bool SAL_CALL ScVbaWindow::getDisplayHeadings() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLROWHDR ) ); sal_Bool bHeading = sal_True; - xProps->getPropertyValue( sName ) >>= bHeading; + getControllerProps()->getPropertyValue( sName ) >>= bHeading; return bHeading; } void SAL_CALL ScVbaWindow::setDisplayHeadings( ::sal_Bool _bDisplayHeadings ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLROWHDR ) ); - xProps->setPropertyValue( sName, uno::makeAny( _bDisplayHeadings )); + getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayHeadings )); } ::sal_Bool SAL_CALL ScVbaWindow::getDisplayHorizontalScrollBar() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_HORSCROLL ) ); sal_Bool bHorizontalScrollBar = sal_True; - xProps->getPropertyValue( sName ) >>= bHorizontalScrollBar; + getControllerProps()->getPropertyValue( sName ) >>= bHorizontalScrollBar; return bHorizontalScrollBar; } void SAL_CALL ScVbaWindow::setDisplayHorizontalScrollBar( ::sal_Bool _bDisplayHorizontalScrollBar ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_HORSCROLL ) ); - xProps->setPropertyValue( sName, uno::makeAny( _bDisplayHorizontalScrollBar )); + getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayHorizontalScrollBar )); } ::sal_Bool SAL_CALL ScVbaWindow::getDisplayOutline() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_OUTLSYMB ) ); sal_Bool bOutline = sal_True; - xProps->getPropertyValue( sName ) >>= bOutline; + getControllerProps()->getPropertyValue( sName ) >>= bOutline; return bOutline; } void SAL_CALL ScVbaWindow::setDisplayOutline( ::sal_Bool _bDisplayOutline ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_OUTLSYMB ) ); - xProps->setPropertyValue( sName, uno::makeAny( _bDisplayOutline )); + getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayOutline )); } ::sal_Bool SAL_CALL ScVbaWindow::getDisplayVerticalScrollBar() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_VERTSCROLL ) ); sal_Bool bVerticalScrollBar = sal_True; - xProps->getPropertyValue( sName ) >>= bVerticalScrollBar; + getControllerProps()->getPropertyValue( sName ) >>= bVerticalScrollBar; return bVerticalScrollBar; } void SAL_CALL ScVbaWindow::setDisplayVerticalScrollBar( ::sal_Bool _bDisplayVerticalScrollBar ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_VERTSCROLL ) ); - xProps->setPropertyValue( sName, uno::makeAny( _bDisplayVerticalScrollBar )); + getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayVerticalScrollBar )); } ::sal_Bool SAL_CALL ScVbaWindow::getDisplayWorkbookTabs() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHEETTABS ) ); sal_Bool bWorkbookTabs = sal_True; - xProps->getPropertyValue( sName ) >>= bWorkbookTabs; + getControllerProps()->getPropertyValue( sName ) >>= bWorkbookTabs; return bWorkbookTabs; } void SAL_CALL ScVbaWindow::setDisplayWorkbookTabs( ::sal_Bool _bDisplayWorkbookTabs ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHEETTABS ) ); - xProps->setPropertyValue( sName, uno::makeAny( _bDisplayWorkbookTabs )); + getControllerProps()->setPropertyValue( sName, uno::makeAny( _bDisplayWorkbookTabs )); } ::sal_Bool SAL_CALL ScVbaWindow::getFreezePanes() throw (uno::RuntimeException) { - return m_xViewFreezable->hasFrozenPanes(); + uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW ); + return xViewFreezable->hasFrozenPanes(); } void SAL_CALL ScVbaWindow::setFreezePanes( ::sal_Bool /*_bFreezePanes*/ ) throw (uno::RuntimeException) { - if( m_xViewSplitable->getIsWindowSplit() ) + uno::Reference< sheet::XViewPane > xViewPane( getController(), uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XViewSplitable > xViewSplitable( xViewPane, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XViewFreezable > xViewFreezable( xViewPane, uno::UNO_QUERY_THROW ); + if( xViewSplitable->getIsWindowSplit() ) { // if there is a split we freeze at the split sal_Int32 nColumn = getSplitColumn(); sal_Int32 nRow = getSplitRow(); - m_xViewFreezable->freezeAtPosition( nColumn, nRow ); + xViewFreezable->freezeAtPosition( nColumn, nRow ); } else { // otherwise we freeze in the center of the visible sheet - table::CellRangeAddress aCellRangeAddress = m_xViewPane->getVisibleRange(); + table::CellRangeAddress aCellRangeAddress = xViewPane->getVisibleRange(); sal_Int32 nColumn = aCellRangeAddress.StartColumn + (( aCellRangeAddress.EndColumn - aCellRangeAddress.StartColumn )/2 ); sal_Int32 nRow = aCellRangeAddress.StartRow + (( aCellRangeAddress.EndRow - aCellRangeAddress.StartRow )/2 ); - m_xViewFreezable->freezeAtPosition( nColumn, nRow ); + xViewFreezable->freezeAtPosition( nColumn, nRow ); } } ::sal_Bool SAL_CALL ScVbaWindow::getSplit() throw (uno::RuntimeException) { - return m_xViewSplitable->getIsWindowSplit(); + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + return xViewSplitable->getIsWindowSplit(); } void SAL_CALL @@ -615,14 +641,16 @@ ScVbaWindow::setSplit( ::sal_Bool _bSplit ) throw (uno::RuntimeException) { if( !_bSplit ) { - m_xViewSplitable->splitAtPosition(0,0); + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + xViewSplitable->splitAtPosition(0,0); } else { + uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW ); uno::Reference< excel::XRange > xRange = ActiveCell(); sal_Int32 nRow = xRange->getRow(); sal_Int32 nColumn = xRange->getColumn(); - m_xViewFreezable->freezeAtPosition( nColumn-1, nRow-1 ); + xViewFreezable->freezeAtPosition( nColumn-1, nRow-1 ); SplitAtDefinedPosition( sal_True ); } } @@ -630,7 +658,8 @@ ScVbaWindow::setSplit( ::sal_Bool _bSplit ) throw (uno::RuntimeException) sal_Int32 SAL_CALL ScVbaWindow::getSplitColumn() throw (uno::RuntimeException) { - return m_xViewSplitable->getSplitColumn(); + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + return xViewSplitable->getSplitColumn(); } void SAL_CALL @@ -638,9 +667,10 @@ ScVbaWindow::setSplitColumn( sal_Int32 _splitcolumn ) throw (uno::RuntimeExcepti { if( getSplitColumn() != _splitcolumn ) { + uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW ); sal_Bool bFrozen = getFreezePanes(); sal_Int32 nRow = getSplitRow(); - m_xViewFreezable->freezeAtPosition( _splitcolumn, nRow ); + xViewFreezable->freezeAtPosition( _splitcolumn, nRow ); SplitAtDefinedPosition( !bFrozen ); } } @@ -648,22 +678,23 @@ ScVbaWindow::setSplitColumn( sal_Int32 _splitcolumn ) throw (uno::RuntimeExcepti double SAL_CALL ScVbaWindow::getSplitHorizontal() throw (uno::RuntimeException) { - double fSplitHorizontal = m_xViewSplitable->getSplitHorizontal(); - double fHoriPoints = PixelsToPoints( m_xDevice, fSplitHorizontal, sal_True ); - return fHoriPoints; + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + return PixelsToPoints( getDevice(), xViewSplitable->getSplitHorizontal(), sal_True ); } void SAL_CALL ScVbaWindow::setSplitHorizontal( double _splithorizontal ) throw (uno::RuntimeException) { - double fHoriPixels = PointsToPixels( m_xDevice, _splithorizontal, sal_True ); - m_xViewSplitable->splitAtPosition( static_cast<sal_Int32>( fHoriPixels ), 0 ); + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + double fHoriPixels = PointsToPixels( getDevice(), _splithorizontal, sal_True ); + xViewSplitable->splitAtPosition( static_cast< sal_Int32 >( fHoriPixels ), 0 ); } sal_Int32 SAL_CALL ScVbaWindow::getSplitRow() throw (uno::RuntimeException) { - sal_Int32 nValue = m_xViewSplitable->getSplitRow(); + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + sal_Int32 nValue = xViewSplitable->getSplitRow(); return nValue ? nValue - 1 : nValue; } @@ -672,9 +703,10 @@ ScVbaWindow::setSplitRow( sal_Int32 _splitrow ) throw (uno::RuntimeException) { if( getSplitRow() != _splitrow ) { + uno::Reference< sheet::XViewFreezable > xViewFreezable( getController(), uno::UNO_QUERY_THROW ); sal_Bool bFrozen = getFreezePanes(); sal_Int32 nColumn = getSplitColumn(); - m_xViewFreezable->freezeAtPosition( nColumn , _splitrow ); + xViewFreezable->freezeAtPosition( nColumn , _splitrow ); SplitAtDefinedPosition( !bFrozen ); } } @@ -682,33 +714,33 @@ ScVbaWindow::setSplitRow( sal_Int32 _splitrow ) throw (uno::RuntimeException) double SAL_CALL ScVbaWindow::getSplitVertical() throw (uno::RuntimeException) { - double fSplitVertical = m_xViewSplitable->getSplitVertical(); - double fVertiPoints = PixelsToPoints( m_xDevice, fSplitVertical, false ); - return fVertiPoints; + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + return PixelsToPoints( getDevice(), xViewSplitable->getSplitVertical(), sal_False ); } void SAL_CALL ScVbaWindow::setSplitVertical(double _splitvertical ) throw (uno::RuntimeException) { - double fVertiPixels = PointsToPixels( m_xDevice, _splitvertical, false ); - m_xViewSplitable->splitAtPosition( 0, static_cast<sal_Int32>( fVertiPixels ) ); + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + double fVertiPixels = PointsToPixels( getDevice(), _splitvertical, sal_False ); + xViewSplitable->splitAtPosition( 0, static_cast<sal_Int32>( fVertiPixels ) ); } void ScVbaWindow::SplitAtDefinedPosition(sal_Bool _bUnFreezePane) { - sal_Int32 nVertSplit = m_xViewSplitable->getSplitVertical(); - sal_Int32 nHoriSplit = m_xViewSplitable->getSplitHorizontal(); + uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XViewFreezable > xViewFreezable( xViewSplitable, uno::UNO_QUERY_THROW ); + sal_Int32 nVertSplit = xViewSplitable->getSplitVertical(); + sal_Int32 nHoriSplit = xViewSplitable->getSplitHorizontal(); if( _bUnFreezePane ) - { - m_xViewFreezable->freezeAtPosition(0,0); - } - m_xViewSplitable->splitAtPosition(nHoriSplit, nVertSplit); + xViewFreezable->freezeAtPosition(0,0); + xViewSplitable->splitAtPosition(nHoriSplit, nVertSplit); } uno::Any SAL_CALL ScVbaWindow::getZoom() throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps = getControllerProps(); rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ZOOMTYPE ) ); sal_Int16 nZoomType = view::DocumentZoomType::PAGE_WIDTH; xProps->getPropertyValue( sName ) >>= nZoomType; @@ -773,6 +805,7 @@ ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException) default: DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); } + // !! TODO !! get view shell from controller ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); if ( pViewShell ) dispatchExecute( pViewShell, nSlot ); @@ -781,7 +814,7 @@ ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException) uno::Reference< excel::XRange > SAL_CALL ScVbaWindow::getVisibleRange() throw (uno::RuntimeException) { - uno::Reference< container::XIndexAccess > xPanesIA( m_xViewPane, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xPanesIA( getController(), uno::UNO_QUERY_THROW ); uno::Reference< sheet::XViewPane > xTopLeftPane( xPanesIA->getByIndex( 0 ), uno::UNO_QUERY_THROW ); uno::Reference< excel::XPane > xPane( new ScVbaPane( this, mxContext, m_xModel, xTopLeftPane ) ); return xPane->getVisibleRange(); @@ -791,7 +824,7 @@ sal_Int32 SAL_CALL ScVbaWindow::PointsToScreenPixelsX(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException) { sal_Int32 nHundredthsofOneMillimeters = Millimeter::getInHundredthsOfOneMillimeter( _points ); - double fConvertFactor = (m_xDevice->getInfo().PixelPerMeterX/100000); + double fConvertFactor = (getDevice()->getInfo().PixelPerMeterX/100000); return static_cast<sal_Int32>(fConvertFactor * nHundredthsofOneMillimeters ); } @@ -799,7 +832,7 @@ sal_Int32 SAL_CALL ScVbaWindow::PointsToScreenPixelsY(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException) { sal_Int32 nHundredthsofOneMillimeters = Millimeter::getInHundredthsOfOneMillimeter( _points ); - double fConvertFactor = (m_xDevice->getInfo().PixelPerMeterY/100000); + double fConvertFactor = (getDevice()->getInfo().PixelPerMeterY/100000); return static_cast<sal_Int32>(fConvertFactor * nHundredthsofOneMillimeters ); } @@ -807,6 +840,7 @@ void SAL_CALL ScVbaWindow::PrintOut( const css::uno::Any& From, const css::uno::Any&To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { // need test, print current active sheet + // !! TODO !! get view shell from controller PrintOutHelper( excel::getBestViewShell( m_xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True ); } @@ -814,6 +848,7 @@ void SAL_CALL ScVbaWindow::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::script::BasicErrorException, css::uno::RuntimeException) { // need test, print preview current active sheet + // !! TODO !! get view shell from controller PrintPreviewHelper( EnableChanges, excel::getBestViewShell( m_xModel ) ); } |