summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorPedro Giffuni <pfg@apache.org>2012-08-13 17:05:00 +0000
committerNoel Power <noel.power@suse.com>2013-05-29 11:34:17 +0100
commitb1edc65b2ad18720fefb5ba769f2c6f8c46623d6 (patch)
treec9b6f00f0c897fdef36527c05c7300c7f9afec1f /sc
parent4908bc611113f4c125eff52e2b66d029ffaf31d3 (diff)
i106278 - Window.ActiveSheet,Window.FreezePanes,Window.Split, Window.View
not working correctly. Patch by: lihuiibm Reviewed by: Chen Peng
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/vba/vbawindow.cxx83
-rw-r--r--sc/source/ui/vba/vbawindow.hxx2
2 files changed, 56 insertions, 29 deletions
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index caf68a06c856..99ec6ebe5704 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -597,25 +597,33 @@ ScVbaWindow::getFreezePanes() throw (uno::RuntimeException)
}
void SAL_CALL
-ScVbaWindow::setFreezePanes( ::sal_Bool /*_bFreezePanes*/ ) throw (uno::RuntimeException)
+ScVbaWindow::setFreezePanes( ::sal_Bool _bFreezePanes ) throw (uno::RuntimeException)
{
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( _bFreezePanes )
{
- // if there is a split we freeze at the split
- sal_Int32 nColumn = getSplitColumn();
- sal_Int32 nRow = getSplitRow();
- xViewFreezable->freezeAtPosition( nColumn, nRow );
+ if( xViewSplitable->getIsWindowSplit() )
+ {
+ // if there is a split we freeze at the split
+ sal_Int32 nColumn = getSplitColumn();
+ sal_Int32 nRow = getSplitRow();
+ xViewFreezable->freezeAtPosition( nColumn, nRow );
+ }
+ else
+ {
+ // otherwise we freeze in the center of the visible sheet
+ 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 );
+ xViewFreezable->freezeAtPosition( nColumn, nRow );
+ }
}
else
{
- // otherwise we freeze in the center of the visible sheet
- 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 );
- xViewFreezable->freezeAtPosition( nColumn, nRow );
+ //remove the freeze panes
+ xViewSplitable->splitAtPosition(0,0);
}
}
@@ -640,8 +648,7 @@ ScVbaWindow::setSplit( ::sal_Bool _bSplit ) throw (uno::RuntimeException)
uno::Reference< excel::XRange > xRange = ActiveCell();
sal_Int32 nRow = xRange->getRow();
sal_Int32 nColumn = xRange->getColumn();
- xViewFreezable->freezeAtPosition( nColumn-1, nRow-1 );
- SplitAtDefinedPosition( sal_True );
+ SplitAtDefinedPosition( nColumn-1, nRow-1 );
}
}
@@ -658,10 +665,8 @@ 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();
- xViewFreezable->freezeAtPosition( _splitcolumn, nRow );
- SplitAtDefinedPosition( !bFrozen );
+ SplitAtDefinedPosition( _splitcolumn, nRow );
}
}
@@ -684,8 +689,7 @@ sal_Int32 SAL_CALL
ScVbaWindow::getSplitRow() throw (uno::RuntimeException)
{
uno::Reference< sheet::XViewSplitable > xViewSplitable( getController(), uno::UNO_QUERY_THROW );
- sal_Int32 nValue = xViewSplitable->getSplitRow();
- return nValue ? nValue - 1 : nValue;
+ return xViewSplitable->getSplitRow();
}
void SAL_CALL
@@ -694,10 +698,8 @@ 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();
- xViewFreezable->freezeAtPosition( nColumn , _splitrow );
- SplitAtDefinedPosition( !bFrozen );
+ SplitAtDefinedPosition( nColumn, _splitrow );
}
}
@@ -716,15 +718,30 @@ ScVbaWindow::setSplitVertical(double _splitvertical ) throw (uno::RuntimeExcepti
xViewSplitable->splitAtPosition( 0, static_cast<sal_Int32>( fVertiPixels ) );
}
-void ScVbaWindow::SplitAtDefinedPosition(sal_Bool _bUnFreezePane)
+void ScVbaWindow::SplitAtDefinedPosition( sal_Int32 nColumns, sal_Int32 nRows )
{
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 )
- xViewFreezable->freezeAtPosition(0,0);
- xViewSplitable->splitAtPosition(nHoriSplit, nVertSplit);
+ // nColumns and nRows means split columns/rows
+ if( nColumns == 0 && nRows == 0 )
+ return;
+
+ sal_Int32 cellColumn = nColumns + 1;
+ sal_Int32 cellRow = nRows + 1;
+
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if ( pViewShell )
+ {
+ //firstly remove the old splitter
+ xViewSplitable->splitAtPosition(0,0);
+
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XWorksheet > xSheet( xApplication->getActiveSheet(), uno::UNO_QUERY_THROW );
+ xSheet->Cells(uno::makeAny(cellRow), uno::makeAny(cellColumn))->Select();
+
+ //pViewShell->FreezeSplitters( FALSE );
+ dispatchExecute( pViewShell, SID_WINDOW_SPLIT );
+ }
}
uno::Any SAL_CALL
@@ -773,8 +790,18 @@ ScVbaWindow::ActiveSheet( ) throw (script::BasicErrorException, uno::RuntimeExc
uno::Any SAL_CALL
ScVbaWindow::getView() throw (uno::RuntimeException)
{
- // not supported now
+ sal_Bool bPageBreak = sal_False;
sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;
+
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if (pViewShell)
+ bPageBreak = pViewShell->GetViewData()->IsPagebreakMode();
+
+ if( bPageBreak )
+ nWindowView = excel::XlWindowView::xlPageBreakPreview;
+ else
+ nWindowView = excel::XlWindowView::xlNormalView;
+
return uno::makeAny( nWindowView );
}
diff --git a/sc/source/ui/vba/vbawindow.hxx b/sc/source/ui/vba/vbawindow.hxx
index c637fdf736a9..a80879144860 100644
--- a/sc/source/ui/vba/vbawindow.hxx
+++ b/sc/source/ui/vba/vbawindow.hxx
@@ -45,7 +45,7 @@ private:
css::uno::Reference< css::awt::XDevice > getDevice() throw (css::uno::RuntimeException);
protected:
- void SplitAtDefinedPosition(sal_Bool _bUnFreezePane);
+ void SplitAtDefinedPosition( sal_Int32 nColumns, sal_Int32 nRows );
public:
void Scroll( const css::uno::Any& Down, const css::uno::Any& Up, const css::uno::Any& ToRight, const css::uno::Any& ToLeft, bool bLargeScroll = false ) throw (css::uno::RuntimeException);