You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by pf...@apache.org on 2012/08/13 20:05:00 UTC

svn commit: r1372531 - in /incubator/ooo/trunk/main/sc/source/ui/vba: vbawindow.cxx vbawindow.hxx

Author: pfg
Date: Mon Aug 13 18:05:00 2012
New Revision: 1372531

URL: http://svn.apache.org/viewvc?rev=1372531&view=rev
Log:
i106278 - Window.ActiveSheet,Window.FreezePanes,Window.Split, Window.View 
not working correctly.

Patch by:	lihuiibm
Reviewed by:	Chen Peng	

Modified:
    incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.cxx
    incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.hxx

Modified: incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.cxx?rev=1372531&r1=1372530&r2=1372531&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.cxx Mon Aug 13 18:05:00 2012
@@ -602,25 +602,33 @@ ScVbaWindow::getFreezePanes() throw (uno
 }
 
 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);
 	}
 }
 
@@ -645,8 +653,7 @@ ScVbaWindow::setSplit( ::sal_Bool _bSpli
 		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 );
 	}
 }
 
@@ -663,10 +670,8 @@ ScVbaWindow::setSplitColumn( sal_Int32 _
 	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 );
 	}
 }
 
@@ -689,8 +694,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 
@@ -699,10 +703,8 @@ ScVbaWindow::setSplitRow( sal_Int32 _spl
 	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 );
 	}
 }
 
@@ -721,15 +723,30 @@ ScVbaWindow::setSplitVertical(double _sp
 	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 
@@ -778,8 +795,18 @@ ScVbaWindow::ActiveSheet(  ) throw (scri
 uno::Any SAL_CALL
 ScVbaWindow::getView() throw (uno::RuntimeException)
 {
-	// not supported now	
-	sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;	
+	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 );	
 }
 

Modified: incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.hxx?rev=1372531&r1=1372530&r2=1372531&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/vba/vbawindow.hxx Mon Aug 13 18:05:00 2012
@@ -49,7 +49,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);