diff -u -r ./old/sc/source/ui/vba/vbawindow.cxx ./new/sc/source/ui/vba/vbawindow.cxx --- ./old/sc/source/ui/vba/vbawindow.cxx 2009-10-15 22:39:54.000000000 +0800 +++ ./new/sc/source/ui/vba/vbawindow.cxx 2009-10-21 16:42:52.000000000 +0800 @@ -2,7 +2,7 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2009 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * @@ -594,22 +594,30 @@ } void SAL_CALL -ScVbaWindow::setFreezePanes( ::sal_Bool /*_bFreezePanes*/ ) throw (uno::RuntimeException) +ScVbaWindow::setFreezePanes( ::sal_Bool _bFreezePanes ) throw (uno::RuntimeException) { - if( m_xViewSplitable->getIsWindowSplit() ) + if( _bFreezePanes ) { - // if there is a split we freeze at the split - sal_Int32 nColumn = getSplitColumn(); - sal_Int32 nRow = getSplitRow(); - m_xViewFreezable->freezeAtPosition( nColumn, nRow ); + if( m_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 ); + } + else + { + // otherwise we freeze in the center of the visible sheet + table::CellRangeAddress aCellRangeAddress = m_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 ); + } } - else + else //VBA, minz@cn.ibm.com. { - // otherwise we freeze in the center of the visible sheet - table::CellRangeAddress aCellRangeAddress = m_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 ); + //remove the freeze panes + m_xViewSplitable->splitAtPosition(0,0); } } @@ -631,8 +639,9 @@ uno::Reference< excel::XRange > xRange = ActiveCell(); sal_Int32 nRow = xRange->getRow(); sal_Int32 nColumn = xRange->getColumn(); - m_xViewFreezable->freezeAtPosition( nColumn-1, nRow-1 ); - SplitAtDefinedPosition( sal_True ); + //m_xViewFreezable->freezeAtPosition( nColumn-1, nRow-1 ); + //SplitAtDefinedPosition( sal_True ); + SplitAtDefinedPosition( nColumn-1, nRow-1 ); } } @@ -647,10 +656,11 @@ { if( getSplitColumn() != _splitcolumn ) { - sal_Bool bFrozen = getFreezePanes(); + //sal_Bool bFrozen = getFreezePanes(); sal_Int32 nRow = getSplitRow(); - m_xViewFreezable->freezeAtPosition( _splitcolumn, nRow ); - SplitAtDefinedPosition( !bFrozen ); + //m_xViewFreezable->freezeAtPosition( _splitcolumn, nRow ); + //SplitAtDefinedPosition( !bFrozen ); + SplitAtDefinedPosition( _splitcolumn, nRow ); } } @@ -672,8 +682,9 @@ sal_Int32 SAL_CALL ScVbaWindow::getSplitRow() throw (uno::RuntimeException) { - sal_Int32 nValue = m_xViewSplitable->getSplitRow(); - return nValue ? nValue - 1 : nValue; + //VBA, minz@cn.ibm.com. + return m_xViewSplitable->getSplitRow(); + //return nValue ? nValue - 1 : nValue; } void SAL_CALL @@ -681,10 +692,11 @@ { if( getSplitRow() != _splitrow ) { - sal_Bool bFrozen = getFreezePanes(); + //sal_Bool bFrozen = getFreezePanes(); sal_Int32 nColumn = getSplitColumn(); - m_xViewFreezable->freezeAtPosition( nColumn , _splitrow ); - SplitAtDefinedPosition( !bFrozen ); + //m_xViewFreezable->freezeAtPosition( nColumn , _splitrow ); + //SplitAtDefinedPosition( !bFrozen ); + SplitAtDefinedPosition( nColumn, _splitrow ); } } @@ -703,8 +715,11 @@ m_xViewSplitable->splitAtPosition( 0, static_cast( fVertiPixels ) ); } -void ScVbaWindow::SplitAtDefinedPosition(sal_Bool _bUnFreezePane) +//VBA, minz@cn.ibm.com. Refactory this function. +//void ScVbaWindow::SplitAtDefinedPosition(sal_Bool _bUnFreezePane) +void ScVbaWindow::SplitAtDefinedPosition( sal_Int32 nColumns, sal_Int32 nRows ) { + /* sal_Int32 nVertSplit = m_xViewSplitable->getSplitVertical(); sal_Int32 nHoriSplit = m_xViewSplitable->getSplitHorizontal(); if( _bUnFreezePane ) @@ -712,6 +727,28 @@ m_xViewFreezable->freezeAtPosition(0,0); } m_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 + m_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 @@ -762,8 +799,19 @@ uno::Any SAL_CALL ScVbaWindow::getView() throw (uno::RuntimeException) { - // not supported now + // VBA, minz@cn.ibm.com. Add the implementation. + BOOL bPageBreak = 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 -u -r ./old/sc/source/ui/vba/vbawindow.hxx ./new/sc/source/ui/vba/vbawindow.hxx --- ./old/sc/source/ui/vba/vbawindow.hxx 2009-10-15 22:39:54.000000000 +0800 +++ ./new/sc/source/ui/vba/vbawindow.hxx 2009-10-21 16:42:56.000000000 +0800 @@ -2,7 +2,7 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2009 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * @@ -56,7 +56,7 @@ css::uno::Reference< css::awt::XDevice > m_xDevice; void init(); protected: - void SplitAtDefinedPosition(sal_Bool _bUnFreezePane); + void SplitAtDefinedPosition( sal_Int32 nColumns, sal_Int32 nRows /*sal_Bool _bUnFreezePane*/ );//VBA, minz@cn.ibm.com. 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); public: