diff options
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/dbgui/pvfundlg.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/dbgui/pvlaydlg.cxx | 57 | ||||
-rw-r--r-- | sc/source/ui/inc/pvlaydlg.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/tabvwsh.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/vba/makefile.mk | 92 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaapplication.cxx | 610 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaglobals.cxx | 28 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaglobals.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/vba/vbanames.cxx | 5 | ||||
-rwxr-xr-x | sc/source/ui/vba/vbarange.cxx | 48 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworkbook.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworkbooks.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.cxx | 45 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheets.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin2.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/view/prevwsh.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh4.cxx | 8 |
19 files changed, 478 insertions, 471 deletions
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index 6b04993ba0bc..b5a19ef0ec9b 100644 --- a/sc/source/ui/dbgui/pvfundlg.cxx +++ b/sc/source/ui/dbgui/pvfundlg.cxx @@ -735,8 +735,9 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHOR for (long nDim=0; nDim<nDimCount; nDim++) { BOOL bIsDataLayout; - String aName = rDPObj.GetDimName( nDim, bIsDataLayout ); - if ( !bIsDataLayout && !rDPObj.IsDuplicated( nDim ) ) + sal_Int32 nDimFlags = 0; + String aName = rDPObj.GetDimName( nDim, bIsDataLayout, &nDimFlags ); + if ( !bIsDataLayout && !rDPObj.IsDuplicated( nDim ) && ScDPObject::IsOrientationAllowed( nOrient, nDimFlags ) ) { const ScDPSaveDimension* pDimension = pSaveData ? pSaveData->GetExistingDimensionByName(aName) : 0; if ( !pDimension || (pDimension->GetOrientation() != nOrient) ) diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx index 1eca44a787ed..56d7e3550cda 100644 --- a/sc/source/ui/dbgui/pvlaydlg.cxx +++ b/sc/source/ui/dbgui/pvlaydlg.cxx @@ -567,7 +567,9 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po } } - if ( (toArr->back().get() == NULL) + bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); + if ( bAllowed + && (toArr->back().get() == NULL) && (!Contains( toArr, fData.mnCol, nAt )) ) { // ggF. in anderem Fenster entfernen @@ -714,7 +716,8 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF { ScDPFuncData fData( *((*fromArr)[nFromIndex]) ); - if ( Contains( fromArr, fData.mnCol, nAt ) ) + bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); + if ( bAllowed && Contains( fromArr, fData.mnCol, nAt ) ) { fromWnd->DelField( nAt ); Remove( fromArr, nAt ); @@ -935,21 +938,41 @@ PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt ) if ( bIsDrag ) { Point aPos = ScreenToOutputPixel( rAt ); + ScDPFieldType eCheckTarget = TYPE_SELECT; if ( aRectPage.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_PAGE ); + eCheckTarget = TYPE_PAGE; else if ( aRectCol.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_COL ); + eCheckTarget = TYPE_COL; else if ( aRectRow.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_ROW ); + eCheckTarget = TYPE_ROW; else if ( aRectData.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_DATA ); + eCheckTarget = TYPE_DATA; else if ( eDnDFromType != TYPE_SELECT ) ePtr = POINTER_PIVOT_DELETE; else if ( aRectSelect.IsInside( aPos ) ) ePtr = lclGetPointerForField( TYPE_SELECT ); else ePtr = POINTER_NOTALLOWED; + + if ( eCheckTarget != TYPE_SELECT ) + { + // check if the target orientation is allowed for this field + ScDPFuncDataVec* fromArr = NULL; + switch ( eDnDFromType ) + { + case TYPE_PAGE: fromArr = &aPageArr; break; + case TYPE_COL: fromArr = &aColArr; break; + case TYPE_ROW: fromArr = &aRowArr; break; + case TYPE_DATA: fromArr = &aDataArr; break; + case TYPE_SELECT: fromArr = &aSelectArr; break; + } + ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) ); + if (IsOrientationAllowed( fData.mnCol, eCheckTarget )) + ePtr = lclGetPointerForField( eCheckTarget ); + else + ePtr = POINTER_NOTALLOWED; + } } return ePtr; @@ -1218,6 +1241,28 @@ String ScDPLayoutDlg::GetLabelString( SCsCOL nCol ) return String(); } +//---------------------------------------------------------------------------- + +bool ScDPLayoutDlg::IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType ) +{ + bool bAllowed = true; + ScDPLabelData* pData = GetLabelData( nCol ); + DBG_ASSERT( pData, "LabelData not found" ); + if (pData) + { + sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN; + switch (eType) + { + case TYPE_PAGE: eOrient = sheet::DataPilotFieldOrientation_PAGE; break; + case TYPE_COL: eOrient = sheet::DataPilotFieldOrientation_COLUMN; break; + case TYPE_ROW: eOrient = sheet::DataPilotFieldOrientation_ROW; break; + case TYPE_DATA: eOrient = sheet::DataPilotFieldOrientation_DATA; break; + case TYPE_SELECT: eOrient = sheet::DataPilotFieldOrientation_HIDDEN; break; + } + bAllowed = ScDPObject::IsOrientationAllowed( (USHORT)eOrient, pData->mnFlags ); + } + return bAllowed; +} //---------------------------------------------------------------------------- diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx index c74b9e028d2f..e16c3266510e 100644 --- a/sc/source/ui/inc/pvlaydlg.hxx +++ b/sc/source/ui/inc/pvlaydlg.hxx @@ -198,6 +198,7 @@ private: Point DlgPos2WndPos ( const Point& rPt, Window& rWnd ); ScDPLabelData* GetLabelData ( SCsCOL nCol, size_t* pPos = NULL ); String GetLabelString ( SCsCOL nCol ); + bool IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType ); String GetFuncString ( USHORT& rFuncMask, BOOL bIsValue = TRUE ); BOOL Contains ( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt ); void Remove ( ScDPFuncDataVec* pArr, size_t nAt ); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index b4313c1d7a32..28cc2a823928 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -144,7 +144,6 @@ private: ScNavigatorSettings* pNavSettings; // used in first Activate - ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > aPendingUserData; BOOL bFirstActivate; BOOL bActiveDrawSh; diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index 4cb7e3eb064b..92bb3fd39db0 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -47,63 +47,63 @@ INCPRE=$(INCCOM)$/$(TARGET) # ------------------------------------------------------------------ SLOFILES= \ - $(SLO)$/vbaglobals.obj \ - $(SLO)$/vbaworkbook.obj \ - $(SLO)$/vbaworksheets.obj \ + $(SLO)$/excelvbahelper.obj \ + $(SLO)$/service.obj \ $(SLO)$/vbaapplication.obj \ - $(SLO)$/vbarange.obj \ - $(SLO)$/vbaname.obj \ - $(SLO)$/vbanames.obj \ - $(SLO)$/vbacomment.obj \ - $(SLO)$/vbacomments.obj \ - $(SLO)$/vbaworkbooks.obj \ - $(SLO)$/vbaworksheet.obj \ - $(SLO)$/vbaoutline.obj \ - $(SLO)$/vbafont.obj\ - $(SLO)$/excelvbahelper.obj\ - $(SLO)$/vbainterior.obj\ - $(SLO)$/vbawsfunction.obj\ - $(SLO)$/vbawindow.obj\ - $(SLO)$/vbachart.obj\ - $(SLO)$/vbachartobject.obj\ - $(SLO)$/vbachartobjects.obj\ - $(SLO)$/vbaseriescollection.obj\ - $(SLO)$/vbadialogs.obj \ - $(SLO)$/vbadialog.obj \ - $(SLO)$/vbapivottable.obj \ - $(SLO)$/vbapivotcache.obj \ - $(SLO)$/vbapivottables.obj \ - $(SLO)$/vbawindows.obj \ - $(SLO)$/vbapalette.obj \ + $(SLO)$/vbaassistant.obj \ + $(SLO)$/vbaaxes.obj \ + $(SLO)$/vbaaxis.obj \ + $(SLO)$/vbaaxistitle.obj \ $(SLO)$/vbaborders.obj \ $(SLO)$/vbacharacters.obj \ - $(SLO)$/vbavalidation.obj \ - $(SLO)$/vbasheetobject.obj \ - $(SLO)$/vbasheetobjects.obj \ - $(SLO)$/vbaoleobject.obj \ - $(SLO)$/vbaoleobjects.obj \ - $(SLO)$/vbatextboxshape.obj \ - $(SLO)$/vbapane.obj \ - $(SLO)$/vbatextframe.obj \ - $(SLO)$/vbacharttitle.obj \ + $(SLO)$/vbachart.obj \ + $(SLO)$/vbachartobject.obj \ + $(SLO)$/vbachartobjects.obj \ $(SLO)$/vbacharts.obj \ - $(SLO)$/vbaaxistitle.obj \ - $(SLO)$/vbaaxes.obj \ - $(SLO)$/vbaaxis.obj \ - $(SLO)$/vbaformat.obj \ + $(SLO)$/vbacharttitle.obj \ + $(SLO)$/vbacomment.obj \ + $(SLO)$/vbacomments.obj \ $(SLO)$/vbacondition.obj \ + $(SLO)$/vbadialog.obj \ + $(SLO)$/vbadialogs.obj \ + $(SLO)$/vbaeventshelper.obj \ + $(SLO)$/vbafont.obj \ + $(SLO)$/vbaformat.obj \ $(SLO)$/vbaformatcondition.obj \ $(SLO)$/vbaformatconditions.obj \ - $(SLO)$/vbastyle.obj \ - $(SLO)$/vbastyles.obj \ - $(SLO)$/vbaassistant.obj \ + $(SLO)$/vbaglobals.obj \ $(SLO)$/vbahyperlink.obj \ $(SLO)$/vbahyperlinks.obj \ - $(SLO)$/vbapagesetup.obj \ + $(SLO)$/vbainterior.obj \ + $(SLO)$/vbaname.obj \ + $(SLO)$/vbanames.obj \ + $(SLO)$/vbaoleobject.obj \ + $(SLO)$/vbaoleobjects.obj \ + $(SLO)$/vbaoutline.obj \ $(SLO)$/vbapagebreak.obj \ $(SLO)$/vbapagebreaks.obj \ - $(SLO)$/vbaeventshelper.obj \ - $(SLO)$/service.obj + $(SLO)$/vbapagesetup.obj \ + $(SLO)$/vbapalette.obj \ + $(SLO)$/vbapane.obj \ + $(SLO)$/vbapivotcache.obj \ + $(SLO)$/vbapivottable.obj \ + $(SLO)$/vbapivottables.obj \ + $(SLO)$/vbarange.obj \ + $(SLO)$/vbaseriescollection.obj \ + $(SLO)$/vbasheetobject.obj \ + $(SLO)$/vbasheetobjects.obj \ + $(SLO)$/vbastyle.obj \ + $(SLO)$/vbastyles.obj \ + $(SLO)$/vbatextboxshape.obj \ + $(SLO)$/vbatextframe.obj \ + $(SLO)$/vbavalidation.obj \ + $(SLO)$/vbawindow.obj \ + $(SLO)$/vbawindows.obj \ + $(SLO)$/vbaworkbook.obj \ + $(SLO)$/vbaworkbooks.obj \ + $(SLO)$/vbaworksheet.obj \ + $(SLO)$/vbaworksheets.obj \ + $(SLO)$/vbawsfunction.obj .ENDIF # --- Targets ------------------------------------------------------ diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 8f5aba5c4acb..f3965393e919 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -88,12 +88,6 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; -// Enable our own join detection for Intersection and Union -// should be more efficient than using ScRangeList::Join ( because -// we already are testing the same things ) - -#define OWN_JOIN 1 - // #TODO is this defined somewhere else? #if ( defined UNX ) || ( defined OS2 ) //unix #define FILE_PATH_SEPERATOR "/" @@ -302,7 +296,8 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException ) sal_Int32 nCursorX = pTabView->GetCurX(); sal_Int32 nCursorY = pTabView->GetCurY(); - return new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); + uno::Reference< XHelperInterface > xParent( excel::getUnoSheetModuleObj( xRange ), uno::UNO_QUERY_THROW ); + return new ScVbaRange( xParent, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) ); } uno::Any SAL_CALL @@ -805,412 +800,289 @@ ScVbaApplication::PathSeparator( ) throw (script::BasicErrorException, uno::Run return sPathSep; } -typedef std::list< ScRange > Ranges; -typedef std::list< ScRangeList > RangesList; +// ---------------------------------------------------------------------------- +// Helpers for Intersect and Union + +namespace { + +typedef ::std::list< ScRange > ListOfScRange; -void lcl_addRangesToVec( RangesList& vRanges, const uno::Any& aArg ) throw ( script::BasicErrorException, uno::RuntimeException ) +/** Appends all ranges of a VBA Range object in the passed Any to the list of ranges. */ +void lclAddToListOfScRange( ListOfScRange& rList, const uno::Any& rArg ) + throw (script::BasicErrorException, uno::RuntimeException) { - ScRangeList theRanges; - uno::Reference< excel::XRange > xRange( aArg, uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xCol->getCount(); - for( sal_Int32 i = 1; i <= nCount; ++i ) + if( rArg.hasValue() ) { - uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::makeAny( sal_Int32(i) ), uno::Any() ), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW ); - table::CellRangeAddress addr = xAddressable->getRangeAddress(); - ScRange refRange; - ScUnoConversion::FillScRange( refRange, addr ); - theRanges.Append( refRange ); + uno::Reference< excel::XRange > xRange( rArg, uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW ); + for( sal_Int32 nIdx = 1, nCount = xCol->getCount(); nIdx <= nCount; ++nIdx ) + { + uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::Any( nIdx ), uno::Any() ), uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW ); + ScRange aScRange; + ScUnoConversion::FillScRange( aScRange, xAddressable->getRangeAddress() ); + rList.push_back( aScRange ); + } } - vRanges.push_back( theRanges ); } -void lcl_addRangeToVec( Ranges& vRanges, const uno::Any& aArg ) throw ( script::BasicErrorException, uno::RuntimeException ) +/** Returns true, if the passed ranges can be expressed by a single range. The + new range will be contained in r1 then, the range r2 can be removed. */ +bool lclTryJoin( ScRange& r1, const ScRange& r2 ) { - uno::Reference< excel::XRange > xRange( aArg, uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xCol->getCount(); - for( sal_Int32 i = 1; i <= nCount; ++i ) + // 1) r2 is completely inside r1 + if( r1.In( r2 ) ) + return true; + + // 2) r1 is completely inside r2 + if( r2.In( r1 ) ) { - uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::makeAny( sal_Int32(i) ), uno::Any() ), uno::UNO_QUERY_THROW ); - uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW ); - table::CellRangeAddress addr = xAddressable->getRangeAddress(); - ScRange refRange; - ScUnoConversion::FillScRange( refRange, addr ); - vRanges.push_back( refRange ); + r1 = r2; + return true; } -} -bool lcl_canJoin( ScRange& r1, ScRange& r2 ) -{ - bool bCanJoin = false; - SCCOL startEndColDiff = r2.aStart.Col() - r1.aEnd.Col(); - SCROW startEndRowDiff = r2.aStart.Row() - r1.aEnd.Row(); - SCCOL startColDiff = r2.aStart.Col() - r1.aStart.Col(); - SCCOL endColDiff = r2.aEnd.Col() - r1.aEnd.Col(); - SCROW startRowDiff = r2.aStart.Row() - r1.aStart.Row(); - SCROW endRowDiff = r2.aEnd.Row() - r1.aEnd.Row(); - if ( ( startRowDiff == endRowDiff ) && startRowDiff == 0 && startColDiff >=0 && endColDiff > 0 && ( startEndColDiff <= 1 && startEndColDiff >= -r1.aEnd.Col() ) ) - bCanJoin = true; - else if ( ( startColDiff == endColDiff ) && startColDiff == 0 && startRowDiff >= 0 && endRowDiff > 0 && ( startEndRowDiff <= 1 && startEndRowDiff >= -r1.aEnd.Row() ) ) - bCanJoin = true; -#ifdef DEBUG - String sr1; - String sr2; - r1.Format( sr1, SCA_VALID ) ; - r2.Format( sr2, SCA_VALID ) ; - OSL_TRACE(" canJoin address %s with %s %s ( startRowDiff(%d), endRowDiff(%d), startColDiff(%d) endColDiff(%d) startEndRowDiff(%d), startEndColDiff(%d) ", - rtl::OUStringToOString( sr1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( sr2, RTL_TEXTENCODING_UTF8 ).getStr(), bCanJoin ? "true" : "false", startRowDiff, endRowDiff, startColDiff, endColDiff, startEndRowDiff, startEndColDiff ); -#endif - return bCanJoin; -} -// strips out ranges that contain other ranges, also -// if the borders of the intersecting ranges are alligned -// then the the range is extended to the larger -// e.g. Range("A4:D10"), Range("B4:E10") would be combined -// to Range("A4:E10") -void lcl_strip_containedRanges( Ranges& vRanges ) -{ - // get rid of ranges that are surrounded by other ranges - Ranges::iterator it_outer = vRanges.begin(); - while( it_outer != vRanges.end() ) + SCCOL n1L = r1.aStart.Col(); + SCCOL n1R = r1.aEnd.Col(); + SCROW n1T = r1.aStart.Row(); + SCROW n1B = r1.aEnd.Row(); + SCCOL n2L = r2.aStart.Col(); + SCCOL n2R = r2.aEnd.Col(); + SCROW n2T = r2.aStart.Row(); + SCROW n2B = r2.aEnd.Row(); + + // 3) r1 and r2 have equal upper and lower border + if( (n1T == n2T) && (n1B == n2B) ) { - bool it_outer_erased = false; // true = it_outer erased from vRanges - Ranges::iterator it_inner = vRanges.begin(); - /* Exit the inner loop if outer iterator has been erased in its last - iteration (this means it has been joined to last it_inner, or that - the it_inner contains it completely). The inner loop will restart - with next element of the outer loop, and all elements (from the - beginning of the list) will be checked against that new element. */ - while( !it_outer_erased && (it_inner != vRanges.end()) ) + // check that r1 overlaps or touches r2 + if( ((n1L < n2L) && (n2L - 1 <= n1R)) || ((n2L < n1L) && (n1L - 1 <= n2R)) ) { - bool it_inner_erased = false; // true = it_inner erased from vRanges - if ( it_outer != it_inner ) - { -#ifdef DEBUG - String r1; - String r2; - it_outer->Format( r1, SCA_VALID ) ; - it_inner->Format( r2, SCA_VALID ) ; - OSL_TRACE( "try strip/join address %s with %s ", - rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - if ( it_outer->In( *it_inner ) ) - { - it_inner = vRanges.erase( it_inner ); - it_inner_erased = true; - } - else if ( it_inner->In( *it_outer ) ) - { - it_outer = vRanges.erase( it_outer ); - it_outer_erased = true; - } -#ifndef OWN_JOIN - else if ( (*it_inner).aStart.Row() == (*it_outer).aStart.Row() - && (*it_inner).aEnd.Row() == (*it_outer).aEnd.Row() ) - { - it_outer->ExtendTo( *it_inner ); - it_inner = vRanges.erase( it_inner ); - it_inner_erased = true; - } -#else - else if ( lcl_canJoin( *it_outer, *it_inner ) ) - { - it_outer->ExtendTo( *it_inner ); - it_inner = vRanges.erase( it_inner ); - it_inner_erased = true; - } - else if ( lcl_canJoin( *it_inner, *it_outer) ) - { - it_inner->ExtendTo( *it_outer ); - it_outer = vRanges.erase( it_outer ); - it_outer_erased = true; - } -#endif - } - /* If it_inner has not been erased from vRanges, continue inner - loop with next element. Otherwise, it_inner already points to - the next element (return value of list::erase()). */ - if( !it_inner_erased ) - ++it_inner; + r1.aStart.SetCol( ::std::min( n1L, n2L ) ); + r1.aEnd.SetCol( ::std::max( n1R, n2R ) ); + return true; } - /* If it_outer has not been erased from vRanges, continue outer loop - with next element. Otherwise, it_outer already points to the next - element (return value of list::erase()). */ - if( !it_outer_erased ) - ++it_outer; + return false; } + // 4) r1 and r2 have equal left and right border + if( (n1L == n2L) && (n1R == n2R) ) + { + // check that r1 overlaps or touches r2 + if( ((n1T < n2T) && (n2T + 1 <= n1B)) || ((n2T < n1T) && (n1T + 1 <= n2B)) ) + { + r1.aStart.SetRow( ::std::min( n1T, n2T ) ); + r1.aEnd.SetRow( ::std::max( n1B, n2B ) ); + return true; + } + return false; + } + + // 5) cannot join these ranges + return false; } -Ranges -lcl_intersectionImpl( ScRangeList& rl1, ScRangeList& rl2 ) +/** Strips out ranges that are contained by other ranges, joins ranges that can be joined + together (aligned borders, e.g. A4:D10 and B4:E10 would be combined to A4:E10. */ +void lclJoinRanges( ListOfScRange& rList ) { - Ranges intersections; - for ( USHORT x = 0 ; x < rl1.Count(); ++x ) + ListOfScRange::iterator aOuterIt = rList.begin(); + while( aOuterIt != rList.end() ) { - for ( USHORT y = 0 ; y < rl2.Count(); ++y ) + bool bAnyErased = false; // true = any range erased from rList + ListOfScRange::iterator aInnerIt = rList.begin(); + while( aInnerIt != rList.end() ) { -#ifdef DEBUG - String r1; - String r2; - rl1.GetObject( x )->Format( r1, SCA_VALID ) ; - rl2.GetObject( y )->Format( r2, SCA_VALID ) ; - OSL_TRACE( "comparing address %s with %s ", - rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - if( rl1.GetObject( x )->Intersects( *rl2.GetObject( y ) ) ) + bool bInnerErased = false; // true = aInnerIt erased from rList + // do not compare a range with itself + if( (aOuterIt != aInnerIt) && lclTryJoin( *aOuterIt, *aInnerIt ) ) { - ScRange aIntersection = ScRange( Max( rl1.GetObject( x )->aStart.Col(), rl2.GetObject( y )->aStart.Col() ), - Max( rl1.GetObject( x )->aStart.Row(), rl2.GetObject( y )->aStart.Row() ), - Max( rl1.GetObject( x )->aStart.Tab(), rl2.GetObject( y )->aStart.Tab() ), - Min( rl1.GetObject( x )->aEnd.Col(), rl2.GetObject( y )->aEnd.Col() ), - Min( rl1.GetObject( x )->aEnd.Row(), rl2.GetObject( y )->aEnd.Row() ), - Min( rl1.GetObject( x )->aEnd.Tab(), rl2.GetObject( y )->aEnd.Tab() ) ); - intersections.push_back( aIntersection ); + // aOuterIt points to joined range, aInnerIt will be removed + aInnerIt = rList.erase( aInnerIt ); + bInnerErased = bAnyErased = true; } + /* If aInnerIt has been erased from rList, it already points to + the next element (return value of list::erase()). */ + if( !bInnerErased ) + ++aInnerIt; } + // if any range has been erased, repeat outer loop with the same range + if( !bAnyErased ) + ++aOuterIt; } - lcl_strip_containedRanges( intersections ); - return intersections; } -// Intersection of a set of ranges ( where each range is represented by a ScRangeList e.g. -// any range can be a multi-area range ) -// An intersection is performed between each range in the set of ranges. -// The resulting set of intersections is then processed to strip out any -// intersections that contain other intersections ( and also ranges that directly line up -// are joined ) ( see lcl_strip_containedRanges ) -RangesList lcl_intersections( RangesList& vRanges ) +/** Intersects the passed list with all ranges of a VBA Range object in the passed Any. */ +void lclIntersectRanges( ListOfScRange& rList, const uno::Any& rArg ) + throw (script::BasicErrorException, uno::RuntimeException) { - RangesList intersections; - RangesList::iterator it = vRanges.begin(); - while( it != vRanges.end() ) + // extract the ranges from the passed argument, will throw on invalid data + ListOfScRange aList2; + lclAddToListOfScRange( aList2, rArg ); + // do nothing, if the passed list is already empty + if( !rList.empty() && !aList2.empty() ) { - Ranges intermediateList; - for( RangesList::iterator it_inner = vRanges.begin(); it_inner != vRanges.end(); ++it_inner ) + // save original list in a local + ListOfScRange aList1; + aList1.swap( rList ); + // join ranges from passed argument + lclJoinRanges( aList2 ); + // calculate intersection of the ranges in both lists + for( ListOfScRange::const_iterator aOuterIt = aList1.begin(), aOuterEnd = aList1.end(); aOuterIt != aOuterEnd; ++aOuterIt ) { - if ( it != it_inner ) + for( ListOfScRange::const_iterator aInnerIt = aList2.begin(), aInnerEnd = aList2.end(); aInnerIt != aInnerEnd; ++aInnerIt ) { - Ranges ranges = lcl_intersectionImpl( *it, *it_inner ); - for ( Ranges::iterator range_it = ranges.begin(); range_it != ranges.end(); ++range_it ) - intermediateList.push_back( *range_it ); + if( aOuterIt->Intersects( *aInnerIt ) ) + { + ScRange aIsectRange( + Max( aOuterIt->aStart.Col(), aInnerIt->aStart.Col() ), + Max( aOuterIt->aStart.Row(), aInnerIt->aStart.Row() ), + Max( aOuterIt->aStart.Tab(), aInnerIt->aStart.Tab() ), + Min( aOuterIt->aEnd.Col(), aInnerIt->aEnd.Col() ), + Min( aOuterIt->aEnd.Row(), aInnerIt->aEnd.Row() ), + Min( aOuterIt->aEnd.Tab(), aInnerIt->aEnd.Tab() ) ); + rList.push_back( aIsectRange ); + } } } - it = vRanges.erase( it ); // remove it so we don't include it in the next pass. - // 'it' is removed uncontidionally from vRanges, so the while loop will terminate - - ScRangeList argIntersect; - lcl_strip_containedRanges( intermediateList ); - - for( Ranges::iterator it_inter = intermediateList.begin(); it_inter != intermediateList.end(); ++it_inter ) -#ifndef OWN_JOIN - argIntersect.Join( *it_inter ); -#else - argIntersect.Append( *it_inter ); -#endif - - intersections.push_back( argIntersect ); - } - return intersections; -} - -uno::Reference< excel::XRange > SAL_CALL -ScVbaApplication::Intersect( const uno::Reference< excel::XRange >& Arg1, const uno::Reference< excel::XRange >& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5, const uno::Any& Arg6, const uno::Any& Arg7, const uno::Any& Arg8, const uno::Any& Arg9, const uno::Any& Arg10, const uno::Any& Arg11, const uno::Any& Arg12, const uno::Any& Arg13, const uno::Any& Arg14, const uno::Any& Arg15, const uno::Any& Arg16, const uno::Any& Arg17, const uno::Any& Arg18, const uno::Any& Arg19, const uno::Any& Arg20, const uno::Any& Arg21, const uno::Any& Arg22, const uno::Any& Arg23, const uno::Any& Arg24, const uno::Any& Arg25, const uno::Any& Arg26, const uno::Any& Arg27, const uno::Any& Arg28, const uno::Any& Arg29, const uno::Any& Arg30 ) throw (script::BasicErrorException, uno::RuntimeException) -{ - if ( !Arg1.is() || !Arg2.is() ) - DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); - - RangesList vRanges; - lcl_addRangesToVec( vRanges, uno::makeAny( Arg1 ) ); - lcl_addRangesToVec( vRanges, uno::makeAny( Arg2 ) ); - - if ( Arg3.hasValue() ) - lcl_addRangesToVec( vRanges, Arg3 ); - if ( Arg4.hasValue() ) - lcl_addRangesToVec( vRanges, Arg4 ); - if ( Arg5.hasValue() ) - lcl_addRangesToVec( vRanges, Arg5 ); - if ( Arg6.hasValue() ) - lcl_addRangesToVec( vRanges, Arg6 ); - if ( Arg7.hasValue() ) - lcl_addRangesToVec( vRanges, Arg7 ); - if ( Arg8.hasValue() ) - lcl_addRangesToVec( vRanges, Arg8 ); - if ( Arg9.hasValue() ) - lcl_addRangesToVec( vRanges, Arg9 ); - if ( Arg10.hasValue() ) - lcl_addRangesToVec( vRanges, Arg10 ); - if ( Arg11.hasValue() ) - lcl_addRangesToVec( vRanges, Arg11 ); - if ( Arg12.hasValue() ) - lcl_addRangesToVec( vRanges, Arg12 ); - if ( Arg13.hasValue() ) - lcl_addRangesToVec( vRanges, Arg13 ); - if ( Arg14.hasValue() ) - lcl_addRangesToVec( vRanges, Arg14 ); - if ( Arg15.hasValue() ) - lcl_addRangesToVec( vRanges, Arg15 ); - if ( Arg16.hasValue() ) - lcl_addRangesToVec( vRanges, Arg16 ); - if ( Arg17.hasValue() ) - lcl_addRangesToVec( vRanges, Arg17 ); - if ( Arg18.hasValue() ) - lcl_addRangesToVec( vRanges, Arg18 ); - if ( Arg19.hasValue() ) - lcl_addRangesToVec( vRanges, Arg19 ); - if ( Arg20.hasValue() ) - lcl_addRangesToVec( vRanges, Arg20 ); - if ( Arg21.hasValue() ) - lcl_addRangesToVec( vRanges, Arg21 ); - if ( Arg22.hasValue() ) - lcl_addRangesToVec( vRanges, Arg22 ); - if ( Arg23.hasValue() ) - lcl_addRangesToVec( vRanges, Arg23 ); - if ( Arg24.hasValue() ) - lcl_addRangesToVec( vRanges, Arg24 ); - if ( Arg25.hasValue() ) - lcl_addRangesToVec( vRanges, Arg25 ); - if ( Arg26.hasValue() ) - lcl_addRangesToVec( vRanges, Arg26 ); - if ( Arg27.hasValue() ) - lcl_addRangesToVec( vRanges, Arg27 ); - if ( Arg28.hasValue() ) - lcl_addRangesToVec( vRanges, Arg28 ); - if ( Arg29.hasValue() ) - lcl_addRangesToVec( vRanges, Arg29 ); - if ( Arg30.hasValue() ) - lcl_addRangesToVec( vRanges, Arg30 ); - - uno::Reference< excel::XRange > xRefRange; - - ScRangeList aCellRanges; - // first pass - gets the set of all possible interections of Arg1..ArgN - RangesList intersections = lcl_intersections( vRanges ); - // second pass - gets the intersections of the intersections ( don't ask, but this - // is what seems to happen ) - if ( intersections.size() > 1) - intersections = lcl_intersections( intersections ); - for( RangesList::iterator it = intersections.begin(); it != intersections.end(); ++it ) - { - for ( USHORT x = 0 ; x < it->Count(); ++x ) -#ifndef OWN_JOIN - aCellRanges.Join( *it->GetObject(x) ); -#else - aCellRanges.Append( *it->GetObject(x) ); -#endif + // again, join the result ranges + lclJoinRanges( rList ); } - - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - ScDocShell* pDocShell = excel::getDocShell( xModel ); - if ( aCellRanges.Count() == 1 ) - { - uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() )); - xRefRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange ); - } - else if ( aCellRanges.Count() > 1 ) - { - uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) ); - xRefRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ) , mxContext, xRanges ); - - } - return xRefRange; } -uno::Reference< excel::XRange > SAL_CALL -ScVbaApplication::Union( const uno::Reference< excel::XRange >& Arg1, const uno::Reference< excel::XRange >& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5, const uno::Any& Arg6, const uno::Any& Arg7, const uno::Any& Arg8, const uno::Any& Arg9, const uno::Any& Arg10, const uno::Any& Arg11, const uno::Any& Arg12, const uno::Any& Arg13, const uno::Any& Arg14, const uno::Any& Arg15, const uno::Any& Arg16, const uno::Any& Arg17, const uno::Any& Arg18, const uno::Any& Arg19, const uno::Any& Arg20, const uno::Any& Arg21, const uno::Any& Arg22, const uno::Any& Arg23, const uno::Any& Arg24, const uno::Any& Arg25, const uno::Any& Arg26, const uno::Any& Arg27, const uno::Any& Arg28, const uno::Any& Arg29, const uno::Any& Arg30 ) throw (script::BasicErrorException, uno::RuntimeException) +/** Creates a VBA Range object from the passed list of ranges. */ +uno::Reference< excel::XRange > lclCreateVbaRange( + const uno::Reference< uno::XComponentContext >& rxContext, + const uno::Reference< frame::XModel >& rxModel, + const ListOfScRange& rList ) throw (uno::RuntimeException) { - if ( !Arg1.is() || !Arg2.is() ) - DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); - - uno::Reference< excel::XRange > xRange; - Ranges vRanges; - lcl_addRangeToVec( vRanges, uno::makeAny( Arg1 ) ); - lcl_addRangeToVec( vRanges, uno::makeAny( Arg2 ) ); - - if ( Arg3.hasValue() ) - lcl_addRangeToVec( vRanges, Arg3 ); - if ( Arg4.hasValue() ) - lcl_addRangeToVec( vRanges, Arg4 ); - if ( Arg5.hasValue() ) - lcl_addRangeToVec( vRanges, Arg5 ); - if ( Arg6.hasValue() ) - lcl_addRangeToVec( vRanges, Arg6 ); - if ( Arg7.hasValue() ) - lcl_addRangeToVec( vRanges, Arg7 ); - if ( Arg8.hasValue() ) - lcl_addRangeToVec( vRanges, Arg8 ); - if ( Arg9.hasValue() ) - lcl_addRangeToVec( vRanges, Arg9 ); - if ( Arg10.hasValue() ) - lcl_addRangeToVec( vRanges, Arg10 ); - if ( Arg11.hasValue() ) - lcl_addRangeToVec( vRanges, Arg11 ); - if ( Arg12.hasValue() ) - lcl_addRangeToVec( vRanges, Arg12 ); - if ( Arg13.hasValue() ) - lcl_addRangeToVec( vRanges, Arg13 ); - if ( Arg14.hasValue() ) - lcl_addRangeToVec( vRanges, Arg14 ); - if ( Arg15.hasValue() ) - lcl_addRangeToVec( vRanges, Arg15 ); - if ( Arg16.hasValue() ) - lcl_addRangeToVec( vRanges, Arg16 ); - if ( Arg17.hasValue() ) - lcl_addRangeToVec( vRanges, Arg17 ); - if ( Arg18.hasValue() ) - lcl_addRangeToVec( vRanges, Arg18 ); - if ( Arg19.hasValue() ) - lcl_addRangeToVec( vRanges, Arg19 ); - if ( Arg20.hasValue() ) - lcl_addRangeToVec( vRanges, Arg20 ); - if ( Arg21.hasValue() ) - lcl_addRangeToVec( vRanges, Arg21 ); - if ( Arg22.hasValue() ) - lcl_addRangeToVec( vRanges, Arg22 ); - if ( Arg23.hasValue() ) - lcl_addRangeToVec( vRanges, Arg23 ); - if ( Arg24.hasValue() ) - lcl_addRangeToVec( vRanges, Arg24 ); - if ( Arg25.hasValue() ) - lcl_addRangeToVec( vRanges, Arg25 ); - if ( Arg26.hasValue() ) - lcl_addRangeToVec( vRanges, Arg26 ); - if ( Arg27.hasValue() ) - lcl_addRangeToVec( vRanges, Arg27 ); - if ( Arg28.hasValue() ) - lcl_addRangeToVec( vRanges, Arg28 ); - if ( Arg29.hasValue() ) - lcl_addRangeToVec( vRanges, Arg29 ); - if ( Arg30.hasValue() ) - lcl_addRangeToVec( vRanges, Arg30 ); + ScDocShell* pDocShell = excel::getDocShell( rxModel ); + if( !pDocShell ) throw uno::RuntimeException(); ScRangeList aCellRanges; - lcl_strip_containedRanges( vRanges ); + for( ListOfScRange::const_iterator aIt = rList.begin(), aEnd = rList.end(); aIt != aEnd; ++aIt ) + aCellRanges.Append( *aIt ); - for( Ranges::iterator it = vRanges.begin(); it != vRanges.end(); ++it ) - aCellRanges.Append( *it ); - - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - ScDocShell* pDocShell = excel::getDocShell( xModel ); - if ( aCellRanges.Count() == 1 ) + if( aCellRanges.Count() == 1 ) { - // normal range - uno::Reference< table::XCellRange > xCalcRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); - xRange = new ScVbaRange( excel::getUnoSheetModuleObj( xCalcRange ), mxContext, xCalcRange ); + uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); + return new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), rxContext, xRange ); } - else if ( aCellRanges.Count() > 1 ) // Multi-Area + if( aCellRanges.Count() > 1 ) { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) ); - xRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), mxContext, xRanges ); + return new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), rxContext, xRanges ); } - - // #FIXME need proper (WorkSheet) parent - return xRange; + return 0; +} + +} // namespace + +// ---------------------------------------------------------------------------- + +uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Intersect( + const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2, + const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6, + const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10, + const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14, + const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18, + const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22, + const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26, + const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 ) + throw (script::BasicErrorException, uno::RuntimeException) +{ + if( !rArg1.is() || !rArg2.is() ) + DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); + + // initialize the result list with 1st parameter, join its ranges together + ListOfScRange aList; + lclAddToListOfScRange( aList, uno::Any( rArg1 ) ); + lclJoinRanges( aList ); + + // process all other parameters, this updates the list with intersection + lclIntersectRanges( aList, uno::Any( rArg2 ) ); + lclIntersectRanges( aList, rArg3 ); + lclIntersectRanges( aList, rArg4 ); + lclIntersectRanges( aList, rArg5 ); + lclIntersectRanges( aList, rArg6 ); + lclIntersectRanges( aList, rArg7 ); + lclIntersectRanges( aList, rArg8 ); + lclIntersectRanges( aList, rArg9 ); + lclIntersectRanges( aList, rArg10 ); + lclIntersectRanges( aList, rArg11 ); + lclIntersectRanges( aList, rArg12 ); + lclIntersectRanges( aList, rArg13 ); + lclIntersectRanges( aList, rArg14 ); + lclIntersectRanges( aList, rArg15 ); + lclIntersectRanges( aList, rArg16 ); + lclIntersectRanges( aList, rArg17 ); + lclIntersectRanges( aList, rArg18 ); + lclIntersectRanges( aList, rArg19 ); + lclIntersectRanges( aList, rArg20 ); + lclIntersectRanges( aList, rArg21 ); + lclIntersectRanges( aList, rArg22 ); + lclIntersectRanges( aList, rArg23 ); + lclIntersectRanges( aList, rArg24 ); + lclIntersectRanges( aList, rArg25 ); + lclIntersectRanges( aList, rArg26 ); + lclIntersectRanges( aList, rArg27 ); + lclIntersectRanges( aList, rArg28 ); + lclIntersectRanges( aList, rArg29 ); + lclIntersectRanges( aList, rArg30 ); + + // create the VBA Range object + return lclCreateVbaRange( mxContext, getCurrentDocument(), aList ); +} + +uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Union( + const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2, + const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6, + const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10, + const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14, + const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18, + const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22, + const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26, + const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 ) + throw (script::BasicErrorException, uno::RuntimeException) +{ + if( !rArg1.is() || !rArg2.is() ) + DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); + + ListOfScRange aList; + lclAddToListOfScRange( aList, uno::Any( rArg1 ) ); + lclAddToListOfScRange( aList, uno::Any( rArg2 ) ); + lclAddToListOfScRange( aList, rArg3 ); + lclAddToListOfScRange( aList, rArg4 ); + lclAddToListOfScRange( aList, rArg5 ); + lclAddToListOfScRange( aList, rArg6 ); + lclAddToListOfScRange( aList, rArg7 ); + lclAddToListOfScRange( aList, rArg8 ); + lclAddToListOfScRange( aList, rArg9 ); + lclAddToListOfScRange( aList, rArg10 ); + lclAddToListOfScRange( aList, rArg11 ); + lclAddToListOfScRange( aList, rArg12 ); + lclAddToListOfScRange( aList, rArg13 ); + lclAddToListOfScRange( aList, rArg14 ); + lclAddToListOfScRange( aList, rArg15 ); + lclAddToListOfScRange( aList, rArg16 ); + lclAddToListOfScRange( aList, rArg17 ); + lclAddToListOfScRange( aList, rArg18 ); + lclAddToListOfScRange( aList, rArg19 ); + lclAddToListOfScRange( aList, rArg20 ); + lclAddToListOfScRange( aList, rArg21 ); + lclAddToListOfScRange( aList, rArg22 ); + lclAddToListOfScRange( aList, rArg23 ); + lclAddToListOfScRange( aList, rArg24 ); + lclAddToListOfScRange( aList, rArg25 ); + lclAddToListOfScRange( aList, rArg26 ); + lclAddToListOfScRange( aList, rArg27 ); + lclAddToListOfScRange( aList, rArg28 ); + lclAddToListOfScRange( aList, rArg29 ); + lclAddToListOfScRange( aList, rArg30 ); + + // simply join together all ranges as much as possible, strip out covered ranges etc. + lclJoinRanges( aList ); + + // create the VBA Range object + return lclCreateVbaRange( mxContext, getCurrentDocument(), aList ); } void diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx index 03f3ecd3c50c..c70a7f83726d 100644 --- a/sc/source/ui/vba/vbaglobals.cxx +++ b/sc/source/ui/vba/vbaglobals.cxx @@ -80,6 +80,15 @@ ScVbaGlobals::getApplication() throw (uno::RuntimeException) return mxApplication; } + +uno::Reference<excel::XApplication > SAL_CALL +ScVbaGlobals::getExcel() throw (uno::RuntimeException) +{ + return getApplication(); +} + + + uno::Reference< excel::XWorkbook > SAL_CALL ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException) { @@ -219,6 +228,25 @@ ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException) } + +uno::Any SAL_CALL +ScVbaGlobals::getDebug() throw (uno::RuntimeException) +{ + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.Debug" ) ), aArgs, mxContext ); + return uno::Any( xVBADebug ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); +} + uno::Sequence< ::rtl::OUString > SAL_CALL ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException) { diff --git a/sc/source/ui/vba/vbaglobals.hxx b/sc/source/ui/vba/vbaglobals.hxx index ae34d710240f..f22e5b19faa4 100644 --- a/sc/source/ui/vba/vbaglobals.hxx +++ b/sc/source/ui/vba/vbaglobals.hxx @@ -82,7 +82,8 @@ typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > Sc virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException ); virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - + virtual css::uno::Reference< ov::excel::XApplication > SAL_CALL getExcel() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getDebug() throw (css::uno::RuntimeException); // XMultiServiceFactory diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index 2304874bdb1b..9fd22bf89f7a 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -173,11 +173,6 @@ ScVbaNames::getElementType() throw( css::uno::RuntimeException ) uno::Reference< container::XEnumeration > ScVbaNames::createEnumeration() throw (uno::RuntimeException) { - if ( mxNames.is() ) - { - uno::Reference< container::XEnumerationAccess > xAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xAccess->createEnumeration(); - } uno::Reference< container::XEnumerationAccess > xEnumAccess( mxNames, uno::UNO_QUERY_THROW ); return new NamesEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); } diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index b50199f025d0..455af075306c 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -1206,6 +1206,14 @@ inline table::CellRangeAddress lclGetRangeAddress( const uno::Reference< RangeTy return uno::Reference< sheet::XCellRangeAddressable >( rxCellRange, uno::UNO_QUERY_THROW )->getRangeAddress(); } +void lclClearRange( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException) +{ + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = VALUE | DATETIME | STRING | ANNOTATION | FORMULA | HARDATTR | STYLES | EDITATTR | FORMATTED; + uno::Reference< sheet::XSheetOperation > xSheetOperation( rxCellRange, uno::UNO_QUERY_THROW ); + xSheetOperation->clearContents( nFlags ); +} + uno::Reference< sheet::XSheetCellRange > lclExpandToMerged( const uno::Reference< table::XCellRange >& rxCellRange, bool bRecursive ) throw (uno::RuntimeException) { uno::Reference< sheet::XSheetCellRange > xNewCellRange( rxCellRange, uno::UNO_QUERY_THROW ); @@ -1251,15 +1259,27 @@ void lclExpandAndMerge( const uno::Reference< table::XCellRange >& rxCellRange, // Calc cannot merge over merged ranges, always unmerge first xMerge->merge( sal_False ); if( bMerge ) + { + // clear all contents of the covered cells (not the top-left cell) + table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange ); + sal_Int32 nLastColIdx = aRangeAddr.EndColumn - aRangeAddr.StartColumn; + sal_Int32 nLastRowIdx = aRangeAddr.EndRow - aRangeAddr.StartRow; + // clear cells of top row, right of top-left cell + if( nLastColIdx > 0 ) + lclClearRange( rxCellRange->getCellRangeByPosition( 1, 0, nLastColIdx, 0 ) ); + // clear all rows below top row + if( nLastRowIdx > 0 ) + lclClearRange( rxCellRange->getCellRangeByPosition( 0, 1, nLastColIdx, nLastRowIdx ) ); + // merge the range xMerge->merge( sal_True ); - // FIXME need to check whether all the cell contents are retained or lost by popping up a dialog + } } util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException) { /* 1) Check if range is completely inside one single merged range. To do this, try to extend from top-left cell only (not from entire range). - This will excude cases where this range consists of several merged + This will exclude cases where this range consists of several merged ranges (or parts of them). */ table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange ); uno::Reference< table::XCellRange > xTopLeft( rxCellRange->getCellRangeByPosition( 0, 0, 0, 0 ), uno::UNO_SET_THROW ); @@ -1508,7 +1528,8 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException) void ScVbaRange::Clear() throw (uno::RuntimeException) { - sal_Int32 nFlags = sheet::CellFlags::VALUE | sheet::CellFlags::STRING | sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR | sheet::CellFlags::FORMULA; + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED; ClearContents( nFlags ); } @@ -2294,8 +2315,7 @@ ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException) void ScVbaRange::setMergeCells( const uno::Any& aIsMerged ) throw (script::BasicErrorException, uno::RuntimeException) { - bool bMerge = false; - aIsMerged >>= bMerge; + bool bMerge = extractBoolFromAny( aIsMerged ); if( mxRanges.is() ) { @@ -2496,7 +2516,8 @@ ScVbaRange::setWrapText( const uno::Any& aIsWrapped ) throw (script::BasicErrorE } uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY_THROW ); - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ), aIsWrapped ); + bool bIsWrapped = extractBoolFromAny( aIsWrapped ); + xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ), uno::Any( bIsWrapped ) ); } uno::Any @@ -2875,13 +2896,11 @@ ScVbaRange::setHidden( const uno::Any& _hidden ) throw (uno::RuntimeException) return; } - sal_Bool bHidden = sal_False; - _hidden >>= bHidden; - + bool bHidden = extractBoolFromAny( _hidden ); try { uno::Reference< beans::XPropertySet > xProps = getRowOrColumnProps( mxRange, mbIsRows ); - xProps->setPropertyValue( ISVISIBLE, uno::makeAny( !bHidden ) ); + xProps->setPropertyValue( ISVISIBLE, uno::Any( !bHidden ) ); } catch( uno::Exception& e ) { @@ -2978,7 +2997,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L // return a Range object that represents the first cell where that information is found. rtl::OUString sWhat; sal_Int32 nWhat = 0; - float fWhat = 0.0; + double fWhat = 0.0; // string. if( What >>= sWhat ) @@ -3010,6 +3029,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L { uno::Reference< util::XSearchDescriptor > xDescriptor = xSearch->createSearchDescriptor(); xDescriptor->setSearchString( sSearch ); + xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHREGEXP ) ), uno::Any( true ) ); uno::Reference< excel::XRange > xAfterRange; uno::Reference< table::XCellRange > xStartCell; @@ -3115,8 +3135,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L ScGlobal::SetSearchItem( newOptions ); - uno::Reference< util::XSearchDescriptor > xSearchDescriptor( xDescriptor, uno::UNO_QUERY ); - uno::Reference< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xSearchDescriptor) : xSearch->findFirst( xSearchDescriptor ); + uno::Reference< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xDescriptor) : xSearch->findFirst( xDescriptor ); uno::Reference< table::XCellRange > xCellRange( xInterface, uno::UNO_QUERY ); if ( xCellRange.is() ) { @@ -4910,8 +4929,7 @@ void ScVbaRange::setShowDetail(const uno::Any& aShowDetail) throw ( css::uno::Ru if( m_Areas->getCount() > 1 ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not set Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() ); - sal_Bool bShowDetail = sal_False; - aShowDetail >>= bShowDetail; + bool bShowDetail = extractBoolFromAny( aShowDetail ); RangeHelper helper( mxRange ); uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = helper.getSheetCellCursor(); diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index 365c8b35a00c..28469c4685a2 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -50,6 +50,7 @@ #include "vbanames.hxx" // Amelia Wang #include "nameuno.hxx" #include "docoptio.hxx" +#include "unonames.hxx" // Much of the impl. for the equivalend UNO module is // sc/source/ui/unoobj/docuno.cxx, viewuno.cxx @@ -208,7 +209,6 @@ ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args, uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext ) - { init(); } @@ -216,21 +216,24 @@ ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args, uno::Reference< excel::XWorksheet > ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException) { - uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ) ); - uno::Reference< sheet::XSpreadsheet > xSheet; + uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW ); uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - if ( xView.is() ) - xSheet = xView->getActiveSheet(); - return new ScVbaWorksheet( this, mxContext, xSheet, xModel ); + uno::Reference< beans::XPropertySet > xSheetProps( xView->getActiveSheet(), uno::UNO_QUERY_THROW ); + // #162503# return the original document module wrapper object, instead of a new instance + ::rtl::OUString aCodeName; + xSheetProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= aCodeName; + ScDocShell* pShell = excel::getDocShell( xModel ); + if( !pShell ) + throw uno::RuntimeException(); + return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW ); } + uno::Any SAL_CALL ScVbaWorkbook::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException) { return Worksheets( aIndex ); } - - uno::Any SAL_CALL ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException) { diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 5298f60e0943..7efee1505dcb 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -76,7 +76,7 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer(); uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW ); xVBACompat->setVBACompatibilityMode( sal_True ); - String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "VBAProject" ) ); + String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); pShell->GetBasicManager()->SetName( aPrjName ); if( xLibContainer.is() ) diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 4eab79813474..6ee6fa1f6b19 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XCalculatable.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XCellRangeReferrer.hpp> #include <com/sun/star/sheet/XSheetCellRange.hpp> #include <com/sun/star/sheet/XSheetCellCursor.hpp> #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp> @@ -319,6 +320,40 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx } +uno::Reference< beans::XPropertySet > ScVbaWorksheet::getFirstDBRangeProperties() throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xDBRangesIA( xModelProps->getPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DatabaseRanges" ) ) ), uno::UNO_QUERY_THROW ); + + for( sal_Int32 nIndex = 0, nCount = xDBRangesIA->getCount(); nIndex < nCount; ++nIndex ) + { + uno::Reference< sheet::XCellRangeReferrer > xDBRange( xDBRangesIA->getByIndex( nIndex ), uno::UNO_QUERY_THROW ); + // check if the database area is on this sheet + uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( xDBRange->getReferredCells(), uno::UNO_QUERY_THROW ); + if( getSheetID() == xRangeAddr->getRangeAddress().Sheet ) + return uno::Reference< beans::XPropertySet >( xDBRange, uno::UNO_QUERY_THROW ); + } + return uno::Reference< beans::XPropertySet >(); +} + +sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties(); + sal_Bool bAutoFilterMode = sal_False; + return + xDBRangeProps.is() && + (xDBRangeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ) ) >>= bAutoFilterMode) && + bAutoFilterMode; +} + +void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties(); + if( xDBRangeProps.is() ) + xDBRangeProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ), uno::Any( bAutoFilterMode ) ); +} + uno::Reference< excel::XRange > ScVbaWorksheet::getUsedRange() throw (uno::RuntimeException) { @@ -379,7 +414,7 @@ ScVbaWorksheet::getStandardHeight() throw (uno::RuntimeException) sal_Bool ScVbaWorksheet::getProtectionMode() throw (uno::RuntimeException) { - return false; + return sal_False; } sal_Bool @@ -392,7 +427,13 @@ ScVbaWorksheet::getProtectContents()throw (uno::RuntimeException) sal_Bool ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException) { - return false; + return sal_False; +} + +sal_Bool +ScVbaWorksheet::getProtectScenarios() throw (uno::RuntimeException) +{ + return sal_False; } void diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx index 196a195258d7..78bcc2503a49 100644 --- a/sc/source/ui/vba/vbaworksheet.hxx +++ b/sc/source/ui/vba/vbaworksheet.hxx @@ -68,6 +68,9 @@ class ScVbaWorksheet : public WorksheetImpl_BASE css::uno::Reference< css::container::XNameAccess > getFormControls(); css::uno::Any getControlShape( const rtl::OUString& sName ); + + css::uno::Reference< css::beans::XPropertySet > getFirstDBRangeProperties() throw (css::uno::RuntimeException); + protected: ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ); @@ -95,6 +98,7 @@ public: virtual ::sal_Bool SAL_CALL getProtectionMode() throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getProtectContents() throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getProtectDrawingObjects() throw (css::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getProtectScenarios() throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getUsedRange() throw (css::uno::RuntimeException) ; virtual css::uno::Any SAL_CALL ChartObjects( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XOutline > SAL_CALL Outline( ) throw (css::uno::RuntimeException); @@ -106,6 +110,8 @@ public: virtual sal_Int16 SAL_CALL getIndex() throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getEnableSelection() throw (css::uno::RuntimeException); virtual void SAL_CALL setEnableSelection( sal_Int32 nSelection ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoFilterMode() throw (css::uno::RuntimeException); + virtual void SAL_CALL setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL Activate() throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 5344e6b3a9be..7fa5196a6b04 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -52,7 +52,7 @@ #include "vbaglobals.hxx" #include "vbaworksheet.hxx" #include "vbaworkbook.hxx" -#include <unonames.hxx> +#include "unonames.hxx" using namespace ::ooo::vba; using namespace ::com::sun::star; diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index a64814d952ef..ec584213898c 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -309,10 +309,17 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) aPosRect, nOrient, nDimPos ); UpdateDragRect( bHasRange && bMove, aPosRect ); + BOOL bIsDataLayout; + sal_Int32 nDimFlags = 0; + String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout, &nDimFlags ); + bool bAllowed = !bHasRange || ScDPObject::IsOrientationAllowed( nOrient, nDimFlags ); + if (bMove) // set mouse pointer { PointerStyle ePointer = POINTER_PIVOT_DELETE; - if ( bHasRange ) + if ( !bAllowed ) + ePointer = POINTER_NOTALLOWED; + else if ( bHasRange ) switch (nOrient) { case sheet::DataPilotFieldOrientation_COLUMN: ePointer = POINTER_PIVOT_COL; break; @@ -327,15 +334,13 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) if (!bHasRange) nOrient = sheet::DataPilotFieldOrientation_HIDDEN; - BOOL bIsDataLayout; - String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout ); if ( bIsDataLayout && ( nOrient != sheet::DataPilotFieldOrientation_COLUMN && nOrient != sheet::DataPilotFieldOrientation_ROW ) ) { // removing data layout is not allowed pViewData->GetView()->ErrorMessage(STR_PIVOT_MOVENOTALLOWED); } - else + else if ( bAllowed ) { ScDPSaveData aSaveData( *pDragDPObj->GetSaveData() ); diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 38d5144274c5..48ffd4fd39a4 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -108,7 +108,7 @@ SFX_IMPL_INTERFACE( ScPreviewShell, SfxViewShell, ScResId(SCSTR_PREVIEWSHELL) ) SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_PREVIEW)); } -SFX_IMPL_VIEWFACTORY( ScPreviewShell, ScResId(STR_NONAME) ) +SFX_IMPL_NAMED_VIEWFACTORY( ScPreviewShell, "PrintPreview" ) { SFX_VIEW_REGISTRATION(ScDocShell); } diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx index 1733cf2e19b5..2fc2bba072d9 100644 --- a/sc/source/ui/view/tabvwsh.cxx +++ b/sc/source/ui/view/tabvwsh.cxx @@ -102,7 +102,7 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL)) //-->Added by PengYunQuan for Validity Cell Range Picker } -SFX_IMPL_VIEWFACTORY( ScTabViewShell, ScResId(STR_NONAME) ) +SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" ) { SFX_VIEW_REGISTRATION(ScDocShell); } diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index ed09ec85ee8c..0835d08de9fd 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -173,13 +173,6 @@ void __EXPORT ScTabViewShell::Activate(BOOL bMDI) SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL ) ); bFirstActivate = FALSE; - if ( aPendingUserData.hasElements() ) - { - // #89897# read user data from print preview now, after ctor - DoReadUserDataSequence( aPendingUserData ); - aPendingUserData.realloc( 0 ); - } - // #116278# ReadExtOptions (view settings from Excel import) must also be done // after the ctor, because of the potential calls to Window::Show. // Even after the fix for #104887# (Window::Show no longer notifies the access @@ -1924,7 +1917,6 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, if ( pOldSh && pOldSh->ISA( ScPreviewShell ) ) { ScPreviewShell* pPreviewShell = ((ScPreviewShell*)pOldSh); - aPendingUserData = pPreviewShell->GetSourceData(); // used in Activate nForceDesignMode = pPreviewShell->GetSourceDesignMode(); } |