ooo-build r13034 - in trunk: . patches/dev300 patches/vba



Author: jiaojh
Date: Thu Jul  3 03:30:53 2008
New Revision: 13034
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13034&view=rev

Log:
    * patches/vba/vba-range-find.diff:
    * patches/dev300/apply:
      support range.find.


Added:
   trunk/patches/vba/vba-range-find.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Thu Jul  3 03:30:53 2008
@@ -1509,6 +1509,8 @@
 vba-range-missing-api.diff, Fong
 # ListBox.removeItem
 vba-listbox-removeitem.diff, n#405306, Jianhua
+# Range.Find
+vba-range-find.diff, n#405304, Jianhua
 [ VBAUntested ]
 SectionOwner => noelpwer
 vba-basic-null.diff i#85349, jjiao

Added: trunk/patches/vba/vba-range-find.diff
==============================================================================
--- (empty file)
+++ trunk/patches/vba/vba-range-find.diff	Thu Jul  3 03:30:53 2008
@@ -0,0 +1,197 @@
+--- oovbaapi/org/openoffice/excel/XRange.idl.bak	2008-07-03 07:01:39.000000000 +0800
++++ oovbaapi/org/openoffice/excel/XRange.idl	2008-07-03 07:06:28.000000000 +0800
+@@ -135,6 +135,7 @@ interface XRange
+ 	any getCellRange();
+ 	void PasteSpecial([in] any Paste, [in] any Operation,[in] any SkipBlanks, [in] any Transpose);
+ 	boolean  Replace( [in] string What, [in] string Replacement, [in] any LookAt, [in] any SearchOrder, [in] any MatchCase, [in] any MatchByte, [in] any SearchFormat, [in] any ReplaceFormat );
++    XRange Find( [in] any What, [in] any After, [in] any LookIn, [in] any LookAt, [in] any SearchOrder, [in] any SearchDirection, [in] any MatchCase, [in] any MatchByte, [in] any SearchFormat );
+ 	
+ 	void Sort( [in] any Key1, [in] any Order1, [in] any Key2, [in] any Type,
+ 		[in] any Order2, [in] any Key3, [in] any Order3,
+--- sc/source/ui/vba/vbarange.hxx.bak	2008-07-03 07:07:14.000000000 +0800
++++ sc/source/ui/vba/vbarange.hxx	2008-07-03 07:10:25.000000000 +0800
+@@ -214,6 +214,7 @@ public:
+ 	virtual css::uno::Any SAL_CALL getCellRange(  ) throw (css::uno::RuntimeException);
+ 	virtual void SAL_CALL PasteSpecial( const css::uno::Any& Paste, const css::uno::Any& Operation, const css::uno::Any& SkipBlanks, const css::uno::Any& Transpose ) throw (css::uno::RuntimeException);
+ 	virtual ::sal_Bool SAL_CALL Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replacement, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat, const css::uno::Any& ReplaceFormat ) throw (css::uno::RuntimeException);
++    virtual css::uno::Reference< oo::excel::XRange > SAL_CALL Find( const css::uno::Any& What, const css::uno::Any& After, const css::uno::Any& LookIn, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& SearchDirection, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat ) throw (css::uno::RuntimeException);
+ 	virtual void SAL_CALL Sort( const css::uno::Any& Key1, const css::uno::Any& Order1, const css::uno::Any& Key2, const css::uno::Any& Type, const css::uno::Any& Order2, const css::uno::Any& Key3, const css::uno::Any& Order3, const css::uno::Any& Header, const css::uno::Any& OrderCustom, const css::uno::Any& MatchCase, const css::uno::Any& Orientation, const css::uno::Any& SortMethod,  const css::uno::Any& DataOption1, const css::uno::Any& DataOption2, const css::uno::Any& DataOption3 ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Reference< oo::excel::XRange > SAL_CALL End( ::sal_Int32 Direction )  throw (css::uno::RuntimeException);
+ 	virtual css::uno::Reference< oo::excel::XCharacters > SAL_CALL characters( const css::uno::Any& Start, const css::uno::Any& Length ) throw (css::uno::RuntimeException);
+--- sc/source/ui/vba/vbarange.cxx.bak	2008-07-03 07:07:21.000000000 +0800
++++ sc/source/ui/vba/vbarange.cxx	2008-07-03 10:44:55.000000000 +0800
+@@ -115,6 +115,7 @@
+ #include <org/openoffice/excel/XlCellType.hpp>
+ #include <org/openoffice/excel/XlSpecialCellsValue.hpp>
+ #include <org/openoffice/excel/XlConsolidationFunction.hpp>
++#include <org/openoffice/excel/XlSearchDirection.hpp>
+ 
+ #include <scitems.hxx>
+ #include <svx/srchitem.hxx>
+@@ -2772,6 +2773,166 @@ ScVbaRange::Replace( const ::rtl::OUStri
+ 	return sal_True; // always
+ }
+ 
++uno::Reference< excel::XRange > SAL_CALL 
++ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& LookIn, const uno::Any& LookAt, const uno::Any& SearchOrder, const uno::Any& SearchDirection, const uno::Any& MatchCase, const uno::Any& MatchByte, const uno::Any& SearchFormat ) throw (uno::RuntimeException)
++{
++    // return a Range object that represents the first cell where that information is found.
++    rtl::OUString sWhat;
++    sal_Int32 nWhat;
++    float fWhat;
++    
++    // string.
++    if( What >>= sWhat )
++    {
++        if( !sWhat.getLength() )
++		    throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Find, missing params" )) , uno::Reference< uno::XInterface >() );
++    }
++    else if( What >>= nWhat )
++    {
++        sWhat = rtl::OUString::valueOf( nWhat );
++    }
++    else if( What >>= fWhat )
++    {
++        sWhat = rtl::OUString::valueOf( fWhat );
++    }
++    else
++	    throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Find, missing params" )) , uno::Reference< uno::XInterface >() );
++
++    rtl::OUString sSearch = VBAToRegexp( sWhat );
++
++	const SvxSearchItem& globalSearchOptions = ScGlobal::GetSearchItem();
++	SvxSearchItem newOptions( globalSearchOptions );
++
++	sal_Int16 nLookAt =  globalSearchOptions.GetWordOnly() ?  excel::XlLookAt::xlPart : excel::XlLookAt::xlWhole; 
++	sal_Int16 nSearchOrder = globalSearchOptions.GetRowDirection() ? excel::XlSearchOrder::xlByRows : excel::XlSearchOrder::xlByColumns;
++
++	uno::Reference< util::XSearchable > xSearch( mxRange, uno::UNO_QUERY );
++    if( xSearch.is() )
++    {
++        uno::Reference< util::XSearchDescriptor > xDescriptor = xSearch->createSearchDescriptor();
++        xDescriptor->setSearchString( sSearch );
++
++        uno::Reference< excel::XRange > xAfterRange;
++        uno::Reference< table::XCellRange > xStartCell;
++        if( After >>= xAfterRange )
++        {
++            // After must be a single cell in the range
++            if( xAfterRange->getCount() > 1 )
++		        throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("After must be a single cell." )) , uno::Reference< uno::XInterface >() );
++            uno::Reference< excel::XRange > xCell( Cells( uno::makeAny( xAfterRange->getRow() ), uno::makeAny( xAfterRange->getColumn() ) ), uno::UNO_QUERY );
++            if( !xCell.is() )
++		        throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("After must be in range." )) , uno::Reference< uno::XInterface >() );
++            xStartCell.set( xAfterRange->getCellRange(), uno::UNO_QUERY_THROW );
++        }
++
++        // LookIn
++        if( LookIn.hasValue() )
++        {
++            sal_Int32 nLookIn;
++            if( LookIn >>= nLookIn )
++            {
++                sal_Int16 nSearchType; 
++                switch( nLookIn )
++                {
++                    case excel::XlFindLookIn::xlComments :
++                        nSearchType = SVX_SEARCHIN_NOTE; // Notes
++                    break;
++                    case excel::XlFindLookIn::xlFormulas :
++                        nSearchType = SVX_SEARCHIN_FORMULA;
++                    break;
++                    case excel::XlFindLookIn::xlValues :
++                        nSearchType = SVX_SEARCHIN_VALUE;
++                    break;
++                    default:
++		                throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for LookIn." )) , uno::Reference< uno::XInterface >() );
++                }
++                newOptions.SetCellType( nSearchType );
++                xDescriptor->setPropertyValue( rtl::OUString::createFromAscii( "SearchType" ), uno::makeAny( nSearchType ) );
++            }
++        }
++
++        // LookAt
++		if ( LookAt.hasValue() )
++		{
++			nLookAt =  ::comphelper::getINT16( LookAt );
++			sal_Bool bSearchWords = sal_False;
++			if ( nLookAt == excel::XlLookAt::xlPart )
++				bSearchWords = sal_False;
++			else if ( nLookAt == excel::XlLookAt::xlWhole )
++				bSearchWords = sal_True;
++			else
++				throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for LookAt" )) , uno::Reference< uno::XInterface >() );
++			newOptions.SetWordOnly( bSearchWords );
++			xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHWORDS ) ), uno::makeAny( bSearchWords ) ); 	
++        }
++
++        // SearchOrder
++		if ( SearchOrder.hasValue() )
++		{
++			nSearchOrder =  ::comphelper::getINT16( SearchOrder );
++			sal_Bool bSearchByRow = sal_False;
++			if ( nSearchOrder == excel::XlSearchOrder::xlByColumns )
++				bSearchByRow = sal_False;
++			else if ( nSearchOrder == excel::XlSearchOrder::xlByRows )
++				bSearchByRow = sal_True;
++			else
++				throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for SearchOrder" )) , uno::Reference< uno::XInterface >() );
++			
++			newOptions.SetRowDirection( bSearchByRow ); 
++			xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHBYROW ) ), uno::makeAny( bSearchByRow ) ); 	
++		}			
++
++        // SearchDirection
++        if ( SearchDirection.hasValue() )
++        {
++            sal_Int32 nSearchDirection;
++            if( SearchDirection >>= nSearchDirection )
++            {
++                sal_Bool bSearchBackwards = sal_False;
++                if ( nSearchDirection == excel::XlSearchDirection::xlNext )
++                    bSearchBackwards = sal_False; 
++                else if( nSearchDirection == excel::XlSearchDirection::xlPrevious )
++                    bSearchBackwards = sal_True;
++                else
++				    throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for SearchDirection" )) , uno::Reference< uno::XInterface >() );
++                newOptions.SetBackward( bSearchBackwards );
++                xDescriptor->setPropertyValue( rtl::OUString::createFromAscii( "SearchBackwards" ), uno::makeAny( bSearchBackwards ) );
++            }
++        }
++
++        // MatchCase
++        sal_Bool bMatchCase = sal_False;
++		if ( MatchCase.hasValue() )
++		{
++			// SearchCaseSensitive
++			if( !( MatchCase >>= bMatchCase ) )
++			    throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for MatchCase" )) , uno::Reference< uno::XInterface >() );
++		}			
++        xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHCASE ) ), uno::makeAny( bMatchCase ) ); 	
++
++        // MatchByte
++        // SearchFormat
++        // ignore
++
++		ScGlobal::SetSearchItem( newOptions );	
++
++		uno::Reference< util::XSearchDescriptor > xSearchDescriptor( xDescriptor, uno::UNO_QUERY );
++		uno::Reference< table::XCellRange > xCellRange( xSearch->findNext( xStartCell, xSearchDescriptor ), uno::UNO_QUERY );
++        if ( xCellRange.is() )
++        {
++            uno::Reference< excel::XRange > xResultRange = new ScVbaRange( this, mxContext, xCellRange );
++            if( xResultRange.is() )
++            {
++                xResultRange->Select();
++                return xResultRange;
++            }
++        }
++
++    }
++
++    return uno::Reference< excel::XRange >();
++}
++
+ uno::Reference< table::XCellRange > processKey( const uno::Any& Key, uno::Reference<  uno::XComponentContext >& xContext, ScDocShell* pDocSh )
+ {
+ 	uno::Reference< excel::XRange > xKeyRange;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]