diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
commit | 9ae5a91f7955e44d3b24a3f7741f9bca02ac7f24 (patch) | |
tree | 13c111a6380728f470fa177e679b80089a01efc4 /sc/workben |
initial import
Diffstat (limited to 'sc/workben')
-rw-r--r-- | sc/workben/addin.cxx | 627 | ||||
-rw-r--r-- | sc/workben/addin.hxx | 136 | ||||
-rw-r--r-- | sc/workben/makefile.mk | 192 | ||||
-rw-r--r-- | sc/workben/map.idl | 71 | ||||
-rw-r--r-- | sc/workben/result.cxx | 165 | ||||
-rw-r--r-- | sc/workben/result.hxx | 117 | ||||
-rw-r--r-- | sc/workben/test.cxx | 2075 | ||||
-rw-r--r-- | sc/workben/testadd.idl | 101 |
8 files changed, 3484 insertions, 0 deletions
diff --git a/sc/workben/addin.cxx b/sc/workben/addin.cxx new file mode 100644 index 000000000000..f3ecd67ef449 --- /dev/null +++ b/sc/workben/addin.cxx @@ -0,0 +1,627 @@ +/************************************************************************* + * + * $RCSfile: addin.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#include <usr/factoryhlp.hxx> +#include <usr/macros.hxx> +#include <usr/reflserv.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <tools/debug.hxx> +#include <tools/date.hxx> +#include <svtools/itemprop.hxx> +#include <usr/proptypehlp.hxx> +#include <cppuhelper/factory.hxx> +#include <uno/lbnames.h> +#include <osl/diagnose.h> + +#include <com/sun/star/util/date.hpp> + +#include "addin.hxx" +#include "result.hxx" + +using namespace com::sun::star; + +//------------------------------------------------------------------------ + + +//------------------------------------------------------------------------ + +SMART_UNO_IMPLEMENTATION( ScTestAddIn, UsrObject ); + +#define SCADDIN_SERVICE L"com.sun.star.sheet.AddIn" +#define SCTESTADDIN_SERVICE L"stardiv.one.sheet.DemoAddIn" + +//------------------------------------------------------------------------ + +extern "C" { + +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, registry::XRegistryKey * pRegistryKey ) +{ + if (pRegistryKey) + { + try + { + UString aImpl = L"/"; + aImpl += ScTestAddIn::getImplementationName_Static(); + aImpl += L"/UNO/SERVICES"; + + uno::Reference<registry::XRegistryKey> xNewKey( + reinterpret_cast<registry::XRegistryKey*>(pRegistryKey)->createKey(aImpl) ); + + uno::Sequence <rtl::OUString> aSequ = ScTestAddIn::getSupportedServiceNames_Static(); + const rtl::OUString * pArray = aSequ.getConstArray(); + for( INT32 i = 0; i < aSequ.getLength(); i++ ) + xNewKey->createKey( pArray[i] ); + + return sal_True; + } + catch (registry::InvalidRegistryException&) + { + OSL_ENSHURE( sal_False, "### InvalidRegistryException!" ); + } + } + return sal_False; +} + +void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + void* pRet = 0; + + if ( pServiceManager && UString(pImplName) == ScTestAddIn::getImplementationName_Static() ) + { + uno::Reference<lang::XSingleServiceFactory> xFactory( cppu::createOneInstanceFactory( + reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager), + ScTestAddIn::getImplementationName_Static(), + ScTestAddIn_CreateInstance, + ScTestAddIn::getSupportedServiceNames_Static() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} // extern C + +//------------------------------------------------------------------------ + +ScTestAddIn::ScTestAddIn() +{ +} + +ScTestAddIn::~ScTestAddIn() +{ +} + +UString ScTestAddIn::getImplementationName_Static() +{ + return L"stardiv.StarCalc.ScTestAddIn"; +} + +::com::sun::star::uno::Sequence< ::rtl::OUString > ScTestAddIn::getSupportedServiceNames_Static() +{ + uno::Sequence< rtl::OUString > aRet(2); + rtl::OUString* pArray = aRet.getArray(); + pArray[0] = SCADDIN_SERVICE; + pArray[1] = SCTESTADDIN_SERVICE; + return aRet; +} + +uno::Reference<uno::XInterface> ScTestAddIn_CreateInstance( + const uno::Reference<lang::XMultiServiceFactory>& ) +{ + static uno::Reference<uno::XInterface> xInst = (cppu::OWeakObject*)new ScTestAddIn(); + return xInst; +} + + +// XAddIn + +UString ScTestAddIn::getProgrammaticFuntionName(const UString& aDisplayName) + THROWS( (UsrSystemException) ) +{ + //!... + return UString(); +} + +UString ScTestAddIn::getDisplayFunctionName(const UString& aProgrammaticName) + THROWS( (UsrSystemException) ) +{ + // return translated strings + + UString aRet; + if ( aProgrammaticName == L"countParams" ) aRet = L"ParamAnzahl"; + else if ( aProgrammaticName == L"addOne" ) aRet = L"PlusEins"; + else if ( aProgrammaticName == L"repeatStr" ) aRet = L"WiederholeString"; + else if ( aProgrammaticName == L"getDateString" ) aRet = L"Datumsstring"; + else if ( aProgrammaticName == L"getColorValue" ) aRet = L"Farbwert"; + else if ( aProgrammaticName == L"transpose" ) aRet = L"Transponieren"; + else if ( aProgrammaticName == L"transposeInt" ) aRet = L"IntegerTransponieren"; + else if ( aProgrammaticName == L"repeatMultiple" )aRet = L"Mehrfach"; + else if ( aProgrammaticName == L"getStrOrVal" ) aRet = L"StringOderWert"; + else if ( aProgrammaticName == L"callAsync" ) aRet = L"Asynchron"; + return aRet; +} + +UString ScTestAddIn::getFunctionDescription(const UString& aProgrammaticName) + THROWS( (UsrSystemException) ) +{ + // return translated strings + + UString aRet; + if ( aProgrammaticName == L"countParams" ) aRet = L"Gibt die Anzahl der Parameter zurueck."; + else if ( aProgrammaticName == L"addOne" ) aRet = L"Addiert 1 zur uebergebenen Zahl."; + else if ( aProgrammaticName == L"repeatStr" ) aRet = L"Wiederholt eine Zeichenkette."; + else if ( aProgrammaticName == L"getDateString" ) aRet = L"Wandelt ein Datum in eine Zeichenkette."; + else if ( aProgrammaticName == L"getColorValue" ) aRet = L"Gibt den Farbwert eines Zellbereichs zurueck. Bei transparentem Hintergrund wird -1 zurueckgegeben"; + else if ( aProgrammaticName == L"transpose" ) aRet = L"Transponiert eine Matrix."; + else if ( aProgrammaticName == L"transposeInt" ) aRet = L"Transponiert eine Matrix mit Ganzzahlen."; + else if ( aProgrammaticName == L"repeatMultiple" )aRet = L"Wiederholt mehrere Bestandteile."; + else if ( aProgrammaticName == L"getStrOrVal" ) aRet = L"Gibt einen String oder einen Wert zurueck."; + else if ( aProgrammaticName == L"callAsync" ) aRet = L"Test fuer asynchrone Funktion."; + return aRet; +} + +UString ScTestAddIn::getDisplayArgumentName(const UString& aProgrammaticFunctionName, + INT32 nArgument) THROWS( (UsrSystemException) ) +{ + // return translated strings + + UString aRet; + if ( aProgrammaticFunctionName == L"countParams" ) + { + if ( nArgument == 0 ) aRet = L"Parameter"; + } + else if ( aProgrammaticFunctionName == L"addOne" ) + { + if ( nArgument == 0 ) aRet = L"Wert"; + } + else if ( aProgrammaticFunctionName == L"repeatStr" ) + { + if ( nArgument == 0 ) aRet = L"String"; + else if ( nArgument == 1 ) aRet = L"Anzahl"; + } + else if ( aProgrammaticFunctionName == L"getDateString" ) + { + if ( nArgument == 0 ) aRet = L"Dokument"; + else if ( nArgument == 1 ) aRet = L"Wert"; + } + else if ( aProgrammaticFunctionName == L"getColorValue" ) + { + if ( nArgument == 0 ) aRet = L"Bereich"; + } + else if ( aProgrammaticFunctionName == L"transpose" ) + { + if ( nArgument == 0 ) aRet = L"Matrix"; + } + else if ( aProgrammaticFunctionName == L"transposeInt" ) + { + if ( nArgument == 0 ) aRet = L"Matrix"; + } + else if ( aProgrammaticFunctionName == L"repeatMultiple" ) + { + if ( nArgument == 0 ) aRet = L"Anzahl"; + else if ( nArgument == 1 ) aRet = L"Trenner"; + else if ( nArgument == 2 ) aRet = L"Inhalt"; + } + else if ( aProgrammaticFunctionName == L"getStrOrVal" ) + { + if ( nArgument == 0 ) aRet = L"Flag"; + } + else if ( aProgrammaticFunctionName == L"callAsync" ) + { + if ( nArgument == 0 ) aRet = L"Name"; + } + return aRet; +} + +UString ScTestAddIn::getArgumentDescription(const UString& aProgrammaticFunctionName, + INT32 nArgument) THROWS( (UsrSystemException) ) +{ + // return translated strings + + UString aRet; + if ( aProgrammaticFunctionName == L"countParams" ) + { + if ( nArgument == 0 ) aRet = L"Beliebiger Parameter"; + } + else if ( aProgrammaticFunctionName == L"addOne" ) + { + if ( nArgument == 0 ) aRet = L"Der Wert, zu dem 1 addiert wird"; + } + else if ( aProgrammaticFunctionName == L"repeatStr" ) + { + if ( nArgument == 0 ) aRet = L"Der Text, der wiederholt wird"; + else if ( nArgument == 1 ) aRet = L"Die Anzahl der Wiederholungen"; + } + else if ( aProgrammaticFunctionName == L"getDateString" ) + { + if ( nArgument == 0 ) aRet = L"(intern)"; + else if ( nArgument == 1 ) aRet = L"Der Wert, der als Datum formatiert wird"; + } + else if ( aProgrammaticFunctionName == L"getColorValue" ) + { + if ( nArgument == 0 ) aRet = L"Der Bereich, dessen Hintergrundfarbe abgefragt wird"; + } + else if ( aProgrammaticFunctionName == L"transpose" ) + { + if ( nArgument == 0 ) aRet = L"Die Matrix, die transponiert werden soll"; + } + else if ( aProgrammaticFunctionName == L"transposeInt" ) + { + if ( nArgument == 0 ) aRet = L"Die Matrix, die transponiert werden soll"; + } + else if ( aProgrammaticFunctionName == L"repeatMultiple" ) + { + if ( nArgument == 0 ) aRet = L"Anzahl der Wiederholungen"; + else if ( nArgument == 1 ) aRet = L"Text, der zwischen den Inhalten erscheint"; + else if ( nArgument == 2 ) aRet = L"Mehrere Inhalte"; + } + else if ( aProgrammaticFunctionName == L"getStrOrVal" ) + { + if ( nArgument == 0 ) aRet = L"Wenn Flag 0 ist, wird ein Wert zurueckgegeben, sonst ein String."; + } + else if ( aProgrammaticFunctionName == L"callAsync" ) + { + if ( nArgument == 0 ) aRet = L"Ein String"; + } + return aRet; +} + +UString ScTestAddIn::getProgrammaticCategoryName(const UString& aProgrammaticFunctionName) + THROWS( (UsrSystemException) ) +{ + // return non-translated strings + + UString aRet; + if ( aProgrammaticFunctionName == L"countParams" ) aRet = L"Information"; + else if ( aProgrammaticFunctionName == L"addOne" ) aRet = L"Mathematical"; + else if ( aProgrammaticFunctionName == L"repeatStr" ) aRet = L"Text"; + else if ( aProgrammaticFunctionName == L"getDateString" ) aRet = L"Date&Time"; + else if ( aProgrammaticFunctionName == L"getColorValue" ) aRet = L"Spreadsheet"; + else if ( aProgrammaticFunctionName == L"transpose" ) aRet = L"Matrix"; + else if ( aProgrammaticFunctionName == L"transposeInt" ) aRet = L"Matrix"; + else if ( aProgrammaticFunctionName == L"repeatMultiple" )aRet = L"Text"; + else if ( aProgrammaticFunctionName == L"getStrOrVal" ) aRet = L"Add-In"; + else if ( aProgrammaticFunctionName == L"callAsync" ) aRet = L"Realtime"; // new group + return aRet; +} + +UString ScTestAddIn::getDisplayCategoryName(const UString& aProgrammaticFunctionName) + THROWS( (UsrSystemException) ) +{ + // return translated strings + + return L"irgendwas"; // not used for predefined categories +} + +// XLocalizable + +void ScTestAddIn::setLocale(const lang::Locale& eLocale) THROWS( (UsrSystemException) ) +{ + aFuncLoc = eLocale; +// DBG_ERROR( UStringToString(aFuncLoc.Language, CHARSET_SYSTEM) + String("-") + +// UStringToString(aFuncLoc.Country, CHARSET_SYSTEM) ); +} + +::com::sun::star::lang::Locale SAL_CALL ScTestAddIn::getLocale( ) throw(::com::sun::star::uno::RuntimeException) +{ + return aFuncLoc; +} + +// XTestAddIn + +sal_Int32 SAL_CALL ScTestAddIn::countParams( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArgs ) throw(::com::sun::star::uno::RuntimeException) +{ + return aArgs.getLength(); +} + +double SAL_CALL ScTestAddIn::addOne( double fValue ) throw(::com::sun::star::uno::RuntimeException) +{ + return fValue + 1.0; +} + +::rtl::OUString SAL_CALL ScTestAddIn::repeatStr( const ::rtl::OUString& aStr, sal_Int32 nCount ) throw(::com::sun::star::uno::RuntimeException) +{ + String aRet; + String aStrStr = OUStringToString( aStr, CHARSET_SYSTEM ); + for (long i=0; i<nCount; i++) + aRet += aStrStr; + + return StringToOUString( aRet, CHARSET_SYSTEM ); +} + +::rtl::OUString SAL_CALL ScTestAddIn::getDateString( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xCaller, double fValue ) throw(::com::sun::star::uno::RuntimeException) +{ + uno::Any aDateAny = xCaller->getPropertyValue( L"NullDate" ); +//! if ( aDateAny.getReflection()->equals( *Date_getReflection() ) ) + { + util::Date aDate; + aDateAny >>= aDate; + //const Date* pDate = (const Date*)aDateAny.get(); + //if (pDate) + { + //Date aNewDate = *pDate; + Date aNewDate( aDate.Day, aDate.Month, aDate.Year ); + + aNewDate += (long)(fValue+0.5); + + String aRet; + aRet += aNewDate.GetDay(); + aRet += '.'; + aRet += aNewDate.GetMonth(); + aRet += '.'; + aRet += aNewDate.GetYear(); + return StringToOUString( aRet, CHARSET_SYSTEM ); + } + } + + return L"**ERROR**"; +} + +sal_Int32 SAL_CALL ScTestAddIn::getColorValue( const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >& xRange ) throw(::com::sun::star::uno::RuntimeException) +{ + uno::Reference<beans::XPropertySet> xProp( xRange, uno::UNO_QUERY ); + if (xProp.is()) + { + long nRet = -1; + uno::Any aTrans = xProp->getPropertyValue( L"IsCellBackgroundTransparent" ); + BOOL bIsTrans; + aTrans >>= bIsTrans; //! dont use >>= for BOOL + if (!bIsTrans) + { + uno::Any aCol = xProp->getPropertyValue( L"CellBackColor" ); + //nRet = NAMESPACE_USR(OPropertyTypeConversion)::toINT32( aCol ); + aCol >>= nRet; + } + return nRet; + } + return 0; +} + +double lcl_GetDoubleElement( const uno::Sequence< uno::Sequence<double> >& aMatrix, long nCol, long nRow ) +{ + if ( nRow < aMatrix.getLength() ) + { + const uno::Sequence<double>& rRowSeq = aMatrix.getConstArray()[nRow]; + if ( nCol < rRowSeq.getLength() ) + return rRowSeq.getConstArray()[nCol]; + } + return 0.0; // error +} + +INT32 lcl_GetLongElement( const uno::Sequence< uno::Sequence<INT32> >& aMatrix, long nCol, long nRow ) +{ + if ( nRow < aMatrix.getLength() ) + { + const uno::Sequence<INT32>& rRowSeq = aMatrix.getConstArray()[nRow]; + if ( nCol < rRowSeq.getLength() ) + return rRowSeq.getConstArray()[nCol]; + } + return 0.0; // error +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL ScTestAddIn::transpose( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aMatrix ) throw(::com::sun::star::uno::RuntimeException) +{ + long nRowCount = aMatrix.getLength(); + long nColCount = 0; + if ( nRowCount ) + nColCount = aMatrix.getConstArray()[0].getLength(); + + uno::Sequence< uno::Sequence<double> > aRet( nColCount ); + for (long nCol=0; nCol<nColCount; nCol++) + { + uno::Sequence<double> aSubSeq(nRowCount); + for (long nRow=0; nRow<nRowCount; nRow++) + aSubSeq.getArray()[nRow] = lcl_GetDoubleElement( aMatrix, nCol, nRow ); + + aRet.getArray()[nCol] = aSubSeq; + } + + return aRet; +} + +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > > SAL_CALL ScTestAddIn::transposeInt( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > >& aMatrix ) throw(::com::sun::star::uno::RuntimeException) +{ + long nRowCount = aMatrix.getLength(); + long nColCount = 0; + if ( nRowCount ) + nColCount = aMatrix.getConstArray()[0].getLength(); + + uno::Sequence< uno::Sequence<INT32> > aRet( nColCount ); + for (long nCol=0; nCol<nColCount; nCol++) + { + uno::Sequence<INT32> aSubSeq(nRowCount); + for (long nRow=0; nRow<nRowCount; nRow++) + aSubSeq.getArray()[nRow] = lcl_GetLongElement( aMatrix, nCol, nRow ); + + aRet.getArray()[nCol] = aSubSeq; + } + + return aRet; +} + +::rtl::OUString SAL_CALL ScTestAddIn::repeatMultiple( sal_Int32 nCount, const ::com::sun::star::uno::Any& aFirst, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aFollow ) throw(::com::sun::star::uno::RuntimeException) +{ + String aSeparator; + if ( !aFirst.hasValue() ) // not specified + aSeparator = ';'; + else + { + rtl::OUString aUStr; + aFirst >>= aUStr; + aSeparator = OUStringToString( aUStr, CHARSET_SYSTEM ); + } + + String aContent; + long nContCount = aFollow.getLength(); + const uno::Any* pArr = aFollow.getConstArray(); + for (long nPos=0; nPos<nContCount; nPos++) + { + if ( nPos > 0 ) + aContent += ' '; + rtl::OUString aUStr; + pArr[nPos] >>= aUStr; + aContent += OUStringToString( aUStr, CHARSET_SYSTEM ); + } + + String aRet; + + for (long i=0; i<nCount; i++) + { + if (i>0) + aRet += aSeparator; + aRet += aContent; + } + + return StringToOUString(aRet, CHARSET_SYSTEM); +} + +::com::sun::star::uno::Any SAL_CALL ScTestAddIn::getStrOrVal( sal_Int32 nFlag ) throw(::com::sun::star::uno::RuntimeException) +{ + uno::Any aRet; + + //! Test + if ( nFlag == 42 ) + { + uno::Sequence<rtl::OUString> aInner(3); + aInner.getArray()[0] = L"Bla"; + aInner.getArray()[1] = L"Fasel"; + aInner.getArray()[2] = L"Suelz"; + uno::Sequence< uno::Sequence<rtl::OUString> > aOuter( &aInner, 1 ); + + //return uno::Any( &aOuter, Sequence< Sequence<UString> >::getReflection() ); + + aRet <<= aOuter; + return aRet; + } + //! Test + + if ( nFlag ) + aRet <<= UString(L"This is a string."); + else + aRet <<= (INT32)42; + + return aRet; +} + +::com::sun::star::uno::Reference< ::com::sun::star::sheet::XVolatileResult > SAL_CALL ScTestAddIn::callAsync( const ::rtl::OUString& aString ) throw(::com::sun::star::uno::RuntimeException) +{ + String aStr = OUStringToString( aString, CHARSET_SYSTEM ); + char c = (char) aStr; + if ( c >= '0' && c <= '9' ) + { + if (!xNumResult.is()) + xNumResult = new ScAddInResult( "Num" ); + return xNumResult; + } + else + { + if (!xAlphaResult.is()) + xAlphaResult = new ScAddInResult( "Str" ); + return xAlphaResult; + } +} + + +// XServiceName + +::rtl::OUString SAL_CALL ScTestAddIn::getServiceName( ) throw(::com::sun::star::uno::RuntimeException) +{ + return SCTESTADDIN_SERVICE; // name of specific AddIn service +} + +// XServiceInfo + +::rtl::OUString SAL_CALL ScTestAddIn::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getImplementationName_Static(); +} + +sal_Bool SAL_CALL ScTestAddIn::supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException) +{ + return ServiceName == SCADDIN_SERVICE || + ServiceName == SCTESTADDIN_SERVICE; +} + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ScTestAddIn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------ + + + diff --git a/sc/workben/addin.hxx b/sc/workben/addin.hxx new file mode 100644 index 000000000000..281f3c1a2224 --- /dev/null +++ b/sc/workben/addin.hxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * $RCSfile: addin.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef SC_ADDIN_HXX +#define SC_ADDIN_HXX + +#include <com/sun/star/sheet/XAddIn.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <stardiv/starcalc/test/XTestAddIn.hpp> + +#include <cppuhelper/implbase4.hxx> // helper for implementations + + +com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ScTestAddIn_CreateInstance( + const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& ); + + +class ScTestAddIn : public cppu::WeakImplHelper4< + com::sun::star::sheet::XAddIn, + stardiv::starcalc::test::XTestAddIn, + com::sun::star::lang::XServiceName, + com::sun::star::lang::XServiceInfo > +{ +private: + com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xAlphaResult; //! Test + com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xNumResult; //! Test + com::sun::star::lang::Locale aFuncLoc; + +public: + ScTestAddIn(); + virtual ~ScTestAddIn(); + +// SMART_UNO_DECLARATION( ScTestAddIn, UsrObject ); +// friend Reflection * ScTestAddIn_getReflection(); +// virtual BOOL queryInterface( Uik, XInterfaceRef& ); +// virtual XIdlClassRef getIdlClass(void); + + static UString getImplementationName_Static(); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(); + + // XAddIn + virtual ::rtl::OUString SAL_CALL getProgrammaticFuntionName( const ::rtl::OUString& aDisplayName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDisplayFunctionName( const ::rtl::OUString& aProgrammaticName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getFunctionDescription( const ::rtl::OUString& aProgrammaticName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDisplayArgumentName( const ::rtl::OUString& aProgrammaticFunctionName, sal_Int32 nArgument ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getArgumentDescription( const ::rtl::OUString& aProgrammaticFunctionName, sal_Int32 nArgument ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProgrammaticCategoryName( const ::rtl::OUString& aProgrammaticFunctionName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDisplayCategoryName( const ::rtl::OUString& aProgrammaticFunctionName ) throw(::com::sun::star::uno::RuntimeException); + + // XLocalizable + virtual void SAL_CALL setLocale( const ::com::sun::star::lang::Locale& eLocale ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw(::com::sun::star::uno::RuntimeException); + + // XTestAddIn + virtual sal_Int32 SAL_CALL countParams( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArgs ) throw(::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL addOne( double fValue ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL repeatStr( const ::rtl::OUString& aStr, sal_Int32 nCount ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDateString( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xCaller, double fValue ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColorValue( const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >& xRange ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL transpose( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aMatrix ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > > SAL_CALL transposeInt( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_Int32 > >& aMatrix ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XVolatileResult > SAL_CALL callAsync( const ::rtl::OUString& aString ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL repeatMultiple( sal_Int32 nCount, const ::com::sun::star::uno::Any& aFirst, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aFollow ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getStrOrVal( sal_Int32 nFlag ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceName + virtual ::rtl::OUString SAL_CALL getServiceName( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); +}; + + +#endif + diff --git a/sc/workben/makefile.mk b/sc/workben/makefile.mk new file mode 100644 index 000000000000..0845b6e3539a --- /dev/null +++ b/sc/workben/makefile.mk @@ -0,0 +1,192 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:45:16 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=.. + +PRJNAME=workben +TARGET=tst +IDLMAP=map.idl + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +UNOUCRDEP= $(BIN)$/applicat.rdb +UNOUCRRDB= $(BIN)$/applicat.rdb + +UNOTYPES=\ + com.sun.star.util.Date \ + com.sun.star.sheet.XAddIn \ + com.sun.star.sheet.XVolatileResult \ + com.sun.star.lang.XServiceName \ + com.sun.star.lang.XServiceInfo \ + com.sun.star.lang.Locale \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.uno.TypeClass \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.XMultiServiceFactory \ + stardiv.starcalc.test.XTestAddIn + +PACKAGE=stardiv$/starcalc$/test +IDLFILES= testadd.idl + +CXXFILES= \ + addin.cxx \ + result.cxx + +SLOFILES= \ + $(SLO)$/addin.obj \ + $(SLO)$/result.obj + +EXCEPTIONSFILES= \ + $(SLO)$/addin.obj \ + $(SLO)$/result.obj + + +#SRC1FILES= +#SRS1NAME= +#SRSFILES= $(SRS)$/ +#SRC2FILES= +#SRS2NAME= + +#RESLIB1NAME=tst +#RESLIB1SRSFILES=\ +# $(SRS)$/ +# $(SOLARRESDIR)$/ + +SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) +#SHL1LIBS=$(SLB)$/$(TARGET).lib + +SHL1STDLIBS=$(USRLIB) $(SVLIB) $(TOOLSLIB) $(ONELIB) $(SVLLIB) $(TKLIB) $(SALLIB) $(VOSLIB) $(CPPULIB) $(CPPUHELPERLIB) + +SHL1DEPN= $(L)$/itools.lib $(SVLIBDEPEND) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def +SHL1IMPLIB=$(TARGET) +#SHL1RES= $(RES)$/$(TARGET).res +SHL1OBJS= $(SLO)$/addin.obj $(SLO)$/result.obj $(SLO)$/workben$/testadd.obj + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk + +.IF "$(GUI)" == "WNT" + +$(MISC)$/$(SHL1TARGET).def: makefile.mk + @echo ------------------------------ + @echo Making: $@ + @echo LIBRARY $(SHL1TARGET) >$@ + @echo DESCRIPTION 'StarOne Test-DLL' >>$@ + @echo DATA READ WRITE NONSHARED >>$@ + @echo EXPORTS >>$@ + @echo component_getImplementationEnvironment @24 >>$@ + @echo component_writeInfo @25 >>$@ + @echo component_getFactory @26 >>$@ +.ENDIF + +.IF "$(GUI)" == "WIN" + +$(MISC)$/$(SHL1TARGET).def: makefile + @echo ------------------------------ + @echo Making: $@ + @echo LIBRARY $(SHL1TARGET) >$@ + @echo DESCRIPTION 'StarOne Test-DLL' >>$@ + @echo EXETYPE WINDOWS >>$@ + @echo PROTMODE >>$@ + @echo CODE LOADONCALL MOVEABLE DISCARDABLE >>$@ + @echo DATA PRELOAD MOVEABLE SINGLE >>$@ + @echo HEAPSIZE 0 >>$@ + @echo EXPORTS >>$@ + @echo _CreateWindow @2 >>$@ +.ENDIF + +.IF "$(GUI)" == "OS2" + +$(MISC)$/$(SHL1TARGET).def: makefile + @echo ================================================================ + @echo building $@ + @echo ---------------------------------------------------------------- +.IF "$(COM)"!="WTC" + echo LIBRARY INITINSTANCE TERMINSTANCE >$@ + echo DESCRIPTION 'StarOne Test-DLL' >>$@ + echo PROTMODE >>$@ + @echo CODE LOADONCALL >>$@ + @echo DATA PRELOAD MULTIPLE NONSHARED >>$@ + @echo EXPORTS >>$@ +.IF "$(COM)"!="ICC" + @echo _CreateWindow @2 >>$@ +.ELSE + @echo CreateWindow @2 >>$@ +.ENDIF + +.ELSE + @echo option DESCRIPTION 'StarOne Test-DLL' >$@ + @echo name $(BIN)$/$(SHL1TARGET).dll >>$@ + @echo CreateWindow_ @2 >>$@ + @gawk -f s:\util\exp.awk temp.def >>$@ + del temp.def +.ENDIF +.ENDIF diff --git a/sc/workben/map.idl b/sc/workben/map.idl new file mode 100644 index 000000000000..4d597831201d --- /dev/null +++ b/sc/workben/map.idl @@ -0,0 +1,71 @@ +/************************************************************************* + * + * $RCSfile: map.idl,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef SC_WORKBEN_MAP_IDL +#define SC_WORKBEN_MAP_IDL + +#import <com/smartmap.idl> +//#import <vcl/vclmap.idl> + +language cpp +{ +}; + +#endif diff --git a/sc/workben/result.cxx b/sc/workben/result.cxx new file mode 100644 index 000000000000..3e0f13096f0d --- /dev/null +++ b/sc/workben/result.cxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: result.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#include <tools/debug.hxx> +#include <usr/ustring.hxx> + +#include "result.hxx" + +using namespace com::sun::star; + +//------------------------------------------------------------------------ + +SV_IMPL_PTRARR( XResultListenerArr_Impl, XResultListenerPtr ); + +//SMART_UNO_IMPLEMENTATION( ScAddInResult, UsrObject ); + +//------------------------------------------------------------------------ + +ScAddInResult::ScAddInResult(const String& rStr) : + aArg( rStr ), + nTickCount( 0 ) +{ + aTimer.SetTimeout( 1000 ); + aTimer.SetTimeoutHdl( LINK( this, ScAddInResult, TimeoutHdl ) ); + aTimer.Start(); +} + +void ScAddInResult::NewValue() +{ + ++nTickCount; + + uno::Any aAny; + if ( TRUE /* nTickCount % 4 */ ) + { + String aRet = aArg; + aRet += nTickCount; + rtl::OUString aUStr = StringToOUString( aRet, CHARSET_SYSTEM ); + aAny <<= aUStr; + } + // else void + +// sheet::ResultEvent aEvent( (UsrObject*)this, aAny ); + sheet::ResultEvent aEvent( (cppu::OWeakObject*)this, aAny ); + + for ( USHORT n=0; n<aListeners.Count(); n++ ) + (*aListeners[n])->modified( aEvent ); +} + +IMPL_LINK_INLINE_START( ScAddInResult, TimeoutHdl, Timer*, pT ) +{ + NewValue(); + pT->Start(); + return 0; +} +IMPL_LINK_INLINE_END( ScAddInResult, TimeoutHdl, Timer*, pT ) + +ScAddInResult::~ScAddInResult() +{ +} + +// XVolatileResult + +void SAL_CALL ScAddInResult::addResultListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XResultListener >& aListener ) throw(::com::sun::star::uno::RuntimeException) +{ + uno::Reference<sheet::XResultListener> *pObj = new uno::Reference<sheet::XResultListener>( aListener ); + aListeners.Insert( pObj, aListeners.Count() ); + + if ( aListeners.Count() == 1 ) + { + acquire(); // one Ref for all listeners + + NewValue(); //! Test + } +} + +void SAL_CALL ScAddInResult::removeResultListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XResultListener >& aListener ) throw(::com::sun::star::uno::RuntimeException) +{ + acquire(); + + USHORT nCount = aListeners.Count(); + for ( USHORT n=nCount; n--; ) + { + uno::Reference<sheet::XResultListener> *pObj = aListeners[n]; + if ( *pObj == aListener ) + { + aListeners.DeleteAndDestroy( n ); + + if ( aListeners.Count() == 0 ) + { + nTickCount = 0; //! Test + + release(); // release listener Ref + } + + break; + } + } + + release(); +} + +//------------------------------------------------------------------------ + + + diff --git a/sc/workben/result.hxx b/sc/workben/result.hxx new file mode 100644 index 000000000000..6efdbd28179f --- /dev/null +++ b/sc/workben/result.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * $RCSfile: result.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef SC_RESULT_HXX +#define SC_RESULT_HXX + +#ifndef _SVARRAY_HXX +#include <svtools/svarray.hxx> +#endif + +#ifndef _SV_TIMER_HXX +#include <vcl/timer.hxx> +#endif + +#ifndef _STRING_HXX +#include <tools/string.hxx> +#endif + + +#include <com/sun/star/sheet/XVolatileResult.hpp> + +#include <cppuhelper/implbase1.hxx> // helper for implementations + + +//class XResultListenerRef; +typedef ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XResultListener >* XResultListenerPtr; +SV_DECL_PTRARR_DEL( XResultListenerArr_Impl, XResultListenerPtr, 4, 4 ); + + +class ScAddInResult : public cppu::WeakImplHelper1< + com::sun::star::sheet::XVolatileResult> +{ +private: + String aArg; + long nTickCount; + XResultListenerArr_Impl aListeners; + Timer aTimer; + + DECL_LINK( TimeoutHdl, Timer* ); + + void NewValue(); + +public: + ScAddInResult(const String& rStr); + virtual ~ScAddInResult(); + +// SMART_UNO_DECLARATION( ScAddInResult, UsrObject ); + +// virtual BOOL queryInterface( Uik, XInterfaceRef& ); +// virtual XIdlClassRef getIdlClass(void); + + // XVolatileResult + virtual void SAL_CALL addResultListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XResultListener >& aListener ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeResultListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XResultListener >& aListener ) throw(::com::sun::star::uno::RuntimeException); +}; + + +#endif + diff --git a/sc/workben/test.cxx b/sc/workben/test.cxx new file mode 100644 index 000000000000..9ea362fe0507 --- /dev/null +++ b/sc/workben/test.cxx @@ -0,0 +1,2075 @@ +/************************************************************************* + * + * $RCSfile: test.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <tools/debug.hxx> +#include <svtools/libcall.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/window.hxx> +#include <vcl/imagebtn.hxx> +#include <vcl/field.hxx> +#include <vcl/fixed.hxx> +#include <vcl/help.hxx> +#include <usr/conver.hxx> +#include <usr/uno.hxx> +#include <usr/refl.hxx> +#include <stardiv/one/frame/xcollect.hxx> +#include <stardiv/one/text/offfield.hxx> +#include <stardiv/one/offmisc.hxx> +#include <stardiv/one/sheet/offtable.hxx> +#include <stardiv/one/text/offtext.hxx> +#include <stardiv/one/offstyle.hxx> +#include <stardiv/one/offview.hxx> +#include <stardiv/uno/repos/serinfo.hxx> +#include <stardiv/one/sheet/sctypes.hxx> +#include <stardiv/one/sheet/scmodel.hxx> +#include <stardiv/one/sheet/sccells.hxx> +#include <stardiv/one/sheet/sctables.hxx> +#include <stardiv/one/sheet/sctable.hxx> +#include <stardiv/one/sheet/sccell.hxx> +#include <stardiv/one/sheet/scpostit.hxx> +#include <stardiv/one/sheet/scview.hxx> +#include <stardiv/one/sheet/scdata.hxx> +#include <stardiv/one/sheet/scattr.hxx> + +//! das muss als Konstante in irgendeine idl-Datei!!!! +#define TEXTCONTROLCHAR_PARAGRAPH_BREAK 0 + + +class MyFixedText : public FixedText +{ +protected: + void RequestHelp( const HelpEvent& rHEvt ); +public: + MyFixedText(Window* pParent) : FixedText(pParent) {} +}; + +class MyWindow : public Window +{ +private: + NumericField aCountField; + PushButton aCountButton; + MyFixedText aTimeText; + NumericField aColField; + NumericField aRowField; + NumericField aPosField; + NumericField aLenField; + Edit aTextEdit; + PushButton aTextButton; + PushButton aBlaButton; + PushButton aTabButton; + PushButton aViewButton; + +public: + MyWindow( Window *pParent ); + + DECL_LINK(CountHdl, PushButton*); + DECL_LINK(TextHdl, PushButton*); + DECL_LINK(BlaHdl, PushButton*); + DECL_LINK(TabHdl, PushButton*); + DECL_LINK(ViewHdl, PushButton*); +}; + +//----------------------------------------------------------------------- + +class ScTestListener : public XSelectionChangeListener, public UsrObject +{ +private: + FixedText* pFixedText; + +public: + ScTestListener(FixedText* pF); + virtual ~ScTestListener(); + + SMART_UNO_DECLARATION( ScTestListener, UsrObject ); + + virtual XInterface * queryInterface( UsrUik ); + virtual XIdlClassRef getIdlClass(void); + + virtual void disposing(const EventObject& Source); + + // XSelectionChangeListener + virtual void selectionChanged(const EventObject& aEvent); +}; + +//----------------------------------------------------------------------- + +static long nBla = 0; + +static XCellRef xGlobalCell; + +//----------------------------------------------------------------------- + +ScTestListener::ScTestListener(FixedText* pF) : + pFixedText( pF ) +{ +} + +ScTestListener::~ScTestListener() +{ +} + +XInterface* ScTestListener::queryInterface( UsrUik aUIK ) +{ + if ( aUIK == XSelectionChangeListener::getSmartUik() ) + return (XSelectionChangeListener*) this; + + return UsrObject::queryInterface( aUIK ); +} + +XIdlClassRef ScTestListener::getIdlClass(void) +{ + static XIdlClassRef xClass = createStandardClass( L"ScTestListener", + UsrObject::getUsrObjectIdlClass(), + 1, XSelectionChangeListener_getReflection() ); + return xClass; +} + +void ScTestListener::disposing(const EventObject& Source) +{ +} + +// XSelectionChangeListener + +void ScTestListener::selectionChanged(const EventObject& aEvent) +{ + static USHORT nBla = 0; + pFixedText->SetText(++nBla); + + XInterfaceRef xInt = aEvent.Source; + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XCellCollectionRef xCells = (XCellCollection*) + xSelInt->queryInterface(XCellCollection::getSmartUik()); + if (!xCells) return; + + String aStr = OUStringToString( xCells->getAddress(), CHARSET_SYSTEM ); + pFixedText->SetText(aStr); +} + + +//----------------------------------------------------------------------- + +extern "C" Window* __LOADONCALLAPI CreateWindow( Window *pParent, const String& rParam ) +{ + MyWindow *pWin = new MyWindow( pParent ); + return pWin; +} + +void MyFixedText::RequestHelp( const HelpEvent& rHEvt ) +{ + String aTxtStr=GetText(); + Size aTxtSize=GetTextSize(aTxtStr); + Point aShowPoint= OutputToScreenPixel(Point(0,0)); + if ( ( rHEvt.GetMode() & HELPMODE_QUICK ) == HELPMODE_QUICK && + aTxtSize.Width()>GetSizePixel().Width()) + Help::ShowQuickHelp( Rectangle(aShowPoint,aTxtSize), aTxtStr, QUICKHELP_TOP|QUICKHELP_LEFT ); + else + FixedText::RequestHelp( rHEvt ); +} + +MyWindow::MyWindow( Window *pParent ) : + Window( pParent ), + aCountField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), + aCountButton( this ), + aTimeText( this ), + aColField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), + aRowField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), + aPosField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), + aLenField( this, WinBits(WB_SPIN | WB_REPEAT | WB_BORDER) ), + aTextEdit( this, WinBits(WB_BORDER) ), + aTextButton( this ), + aBlaButton( this ), + aTabButton( this ), + aViewButton( this ) +{ + aCountField.SetPosSizePixel( Point(10,10), Size(40,20) ); + aCountField.SetValue(1); + + aCountButton.SetPosSizePixel( Point(10,40), Size(100,30) ); + aCountButton.SetText("hochzaehlen"); + + aTimeText.SetPosSizePixel( Point(10,80), Size(100,20) ); + + aColField.SetPosSizePixel( Point(10,120), Size(40,20) ); + aRowField.SetPosSizePixel( Point(60,120), Size(40,20) ); + aPosField.SetPosSizePixel( Point(10,150), Size(40,20) ); + aLenField.SetPosSizePixel( Point(60,150), Size(40,20) ); + aTextEdit.SetPosSizePixel( Point(10,180), Size(100,20) ); + + aTextButton.SetPosSizePixel( Point(10,210), Size(100,30) ); + aTextButton.SetText("col/row/pos/len"); + + aBlaButton.SetPosSizePixel( Point(10,260), Size(100,30) ); + aBlaButton.SetText("Bla"); + + aTabButton.SetPosSizePixel( Point(10,310), Size(100,30) ); + aTabButton.SetText("Tabellen"); + + aViewButton.SetPosSizePixel( Point(10,360), Size(100,30) ); + aViewButton.SetText("Pfui"); + + aCountButton.SetClickHdl(LINK(this, MyWindow, CountHdl)); + aTextButton.SetClickHdl(LINK(this, MyWindow, TextHdl)); + aBlaButton.SetClickHdl(LINK(this, MyWindow, BlaHdl)); + aTabButton.SetClickHdl(LINK(this, MyWindow, TabHdl)); + aViewButton.SetClickHdl(LINK(this, MyWindow, ViewHdl)); + + aCountField.Show(); + aCountButton.Show(); + aTimeText.Show(); + aColField.Show(); + aRowField.Show(); + aPosField.Show(); + aLenField.Show(); + aTextEdit.Show(); + aTextButton.Show(); + aBlaButton.Show(); + aTabButton.Show(); + aViewButton.Show(); +} + +//----------------------------------------------------------------------- + +XSpreadsheetDocumentRef lcl_GetDocument() +{ + XServiceManagerRef xProv = getGlobalServiceManager(); + DBG_ASSERT( xProv.is(), "Kein ServiceManager!" ); + + XServiceRegistryRef xReg = (XServiceRegistry*)xProv->queryInterface(XServiceRegistry::getSmartUik()); + if ( !xReg ) + return NULL; + + Sequence<Uik> aIfaces( 1 ); + aIfaces.getArray()[0] = XModelCollection::getSmartUik(); + XServiceProviderRef xSSI = xProv->getServiceProvider( L"stardiv.desktop.ModelCollection", + aIfaces, Sequence<Uik>() ); + + XModelCollectionRef aCollRef = (XModelCollection*) + xSSI->newInstance()->queryInterface( XModelCollection::getSmartUik() ); + USHORT nCount = aCollRef->getCount(); + + XSpreadsheetDocumentRef xModel; // Calc-Model + for (USHORT nMod=0; nMod<nCount && !xModel; nMod++) // Calc-Doc suchen + { + XModelRef aRef = aCollRef->getItemByIndex( nMod ); + if ( aRef ) + { + aRef->acquire(); + xModel = (XSpreadsheetDocument*) aRef->queryInterface( XSpreadsheetDocument::getSmartUik() ); + aRef->release(); + } + } + return xModel; +} + +XInterfaceRef lcl_GetView() +{ + XInterfaceRef xView; + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + xView = xDoc->getDDELinks(); //! temporaer zum Testen !!!!!!!!! + + return xView; +} + +//----------------------------------------------------------------------- + +void lcl_OutputNames( const XInterfaceRef& xSource, // XNameAccess + const XSpreadsheetDocumentRef& xDoc, + USHORT nCol, USHORT nRow, USHORT nTab ) +{ + CellAddress aAdr; + aAdr.Sheet = nTab; + aAdr.Column = nCol; + aAdr.Row = nRow; + + XNameAccessRef xNames = (XNameAccess*)xSource->queryInterface(XNameAccess::getSmartUik()); + if (!xNames) return; + Sequence<UString> aSeq = xNames->getElementNames(); + + USHORT nLen = (USHORT)aSeq.getLen(); + + XCellRef xCell = xDoc->getCell(aAdr); + if (!xCell) return; + xCell->setValue( nLen ); + ++aAdr.Row; + + UString* pAry = aSeq.getArray(); + for (USHORT i=0; i<nLen; i++) + { + xCell = xDoc->getCell(aAdr); + if (!xCell) return; + XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); + if (!xText) return; + xText->setText( pAry[i] ); + ++aAdr.Row; + } +} + +//----------------------------------------------------------------------- + +void lcl_SetText( const XTextRef& xText ) +{ + if (!xText.is()) return; + XTextCursorRef xCursor = xText->createTextCursor(); + if (!xCursor.is()) return; + XTextPositionRef xPos = (XTextPosition*)xCursor->queryInterface(XTextPosition::getSmartUik()); + XPropertySetRef xProp = (XPropertySet*)xCursor->queryInterface(XPropertySet::getSmartUik()); + XControlCharacterInsertableRef xControl = (XControlCharacterInsertable*) + xCursor->queryInterface(XControlCharacterInsertable::getSmartUik()); + XParagraphCursorRef xPara = (XParagraphCursor*) + xCursor->queryInterface(XParagraphCursor::getSmartUik()); + + if (!xPos.is() || !xControl.is() || !xPara.is()) return; // PropertySet kann fehlen + + xText->setText(L"bla fasel"); + xCursor->gotoEnd(FALSE); + xControl->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK ); + xPos->collapseToEnd(); + xPos->setText(L"slz"); // zweiter Absatz + + xCursor->gotoStart(FALSE); + xPara->gotoEndOfParagraph(FALSE); + xCursor->goLeft(5, TRUE); // letzte 5 Zeichen im 1. Absatz + if (xProp.is()) + xProp->setPropertyValue(L"Bold", UsrAny((BOOL)TRUE)); +} + +//----------------------------------------------------------------------- + +void lcl_DoCount() +{ + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + { + XActionLockableRef xLock = (XActionLockable*) + xDoc->queryInterface(XActionLockable::getSmartUik()); + XCalculateRef xCalc = (XCalculate*) + xDoc->queryInterface(XCalculate::getSmartUik()); + if (xLock) + xLock->addActionLock(); // nicht zwischendurch painten + if (xCalc) + xCalc->setAutomaticCalculation(FALSE); + + CellAddress aPos; + aPos.Sheet = 0; + + for (USHORT nRow = 0; nRow < 20; nRow++) + { + aPos.Row = nRow; + for (USHORT nCol = 0; nCol < 10; nCol++) + { + aPos.Column = nCol; + XCellRef xCell = xDoc->getCell(aPos); + if ( xCell ) + { + // Wert der Zelle um 1 hochzaehlen + + double fVal = xCell->getValue(); + fVal += 1.0; + xCell->setValue( fVal ); + } + } + } + + if (xCalc) + xCalc->setAutomaticCalculation(TRUE); + if (xLock) + xLock->removeActionLock(); + } +} + + +void lcl_GlobalCell() +{ + if ( xGlobalCell ) + { + String aStr = OUStringToString( xGlobalCell->getFormula(), CHARSET_SYSTEM ); + aStr+='0'; + xGlobalCell->setFormula( StringToOUString( aStr, CHARSET_SYSTEM ) ); + } +} + + +void lcl_Annotations( FixedText& aTimeText ) +{ + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + { + CellAddress aPos; + aPos.Sheet = 0; + aPos.Column = 1; + aPos.Row = 2; + XCellRef xCell = xDoc->getCell(aPos); + if ( xCell ) + { + XSheetAnnotationAnchorRef xAnchor = + (XSheetAnnotationAnchor*)xCell->queryInterface(XSheetAnnotationAnchor::getSmartUik()); + if ( xAnchor ) + { + XSheetAnnotationRef xAnnotation = xAnchor->getAnnotation(); + if ( xAnnotation ) + { + String aBlubb = OUStringToString( xAnnotation->getAuthor(), CHARSET_SYSTEM )+ + String(" - ")+ + OUStringToString( xAnnotation->getDate(), CHARSET_SYSTEM ); + aTimeText.SetText(aBlubb); + + XTextRef xAnnotationText = + (XText*)xAnnotation->queryInterface(XText::getSmartUik()); + if ( xAnnotationText ) + { + XTextCursorRef xCursor = xAnnotationText->createTextCursor(); + if (xCursor) + { + XTextPositionRef xPos = (XTextPosition*) + xCursor->queryInterface(XTextPosition::getSmartUik()); + XControlCharacterInsertableRef xControl = (XControlCharacterInsertable*) + xCursor->queryInterface(XControlCharacterInsertable::getSmartUik()); + + if (xPos && xControl) + { + ULONG nStart = Time::GetSystemTicks(); + + xAnnotationText->setText(L"bla"); + xCursor->gotoEnd(FALSE); + xCursor->goLeft(1,TRUE); + xPos->setText(L"ubb"); + for (USHORT i=0; i<10; i++) + { + xPos->collapseToEnd(); + xControl->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK ); + xPos->collapseToEnd(); + xPos->setText(L"dumdi"); + } + + ULONG nEnd = Time::GetSystemTicks(); + aTimeText.SetText(String(nEnd-nStart)+String(" ms")); + } + } + } + } + } + } + } +} + + +void lcl_Cursor( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + { + XActionLockableRef xLock = (XActionLockable*) + xDoc->queryInterface(XActionLockable::getSmartUik()); + if (xLock) + xLock->addActionLock(); + + CellAddress aPos; + aPos.Sheet = 0; + aPos.Column = 1; + aPos.Row = 2; + XCellRef xCell = xDoc->getCell(aPos); + if ( xCell ) + { + XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); + XCellCollectionRef xColl = (XCellCollection*)xCell->queryInterface(XCellCollection::getSmartUik()); + if ( xText && xColl ) + { + xText->setText(L"bla"); + XLineCursorRef xCursor = xColl->createCursor(); + if ( xCursor ) + { + XCellCursorRef xCC = (XCellCursor*)xCursor->queryInterface(XCellCursor::getSmartUik()); + XCellRangesCursorRef xRC = (XCellRangesCursor*) + xCursor->queryInterface(XCellRangesCursor::getSmartUik()); + + if ( xCC && xRC ) + { + xCursor->goDown( 1, FALSE ); + + xColl = xCC->getRanges(); + if ( xColl ) + { + // XText ist drin, wenn's ne einzelne Zelle ist + xText = (XText*)xColl->queryInterface(XText::getSmartUik()); + if ( xText ) + { + xText->setText(L"fasel"); + } + } + + CellRangeAddress aSecond; + aSecond.Sheet = 0; + aSecond.StartColumn = 3; + aSecond.StartRow = 4; + aSecond.EndColumn = 3; + aSecond.EndRow = 4; + xRC->gotoUnion(aSecond); + + xColl = xCC->getRanges(); + if ( xColl ) + { + XPropertySetRef xProp = (XPropertySet*) + xColl->queryInterface(XPropertySet::getSmartUik()); + if ( xProp ) + { + UsrAny aAny; + + aAny = xProp->getPropertyValue(L"ShadowFormat"); + if ( aAny.getReflection()->getName() == + ShadowFormat_getReflection()->getName() ) + { + //ShadowFormat* pOld = (ShadowFormat*)aAny.get(); + ShadowFormat aNew; + aNew.Location = SHADOWLOCATION_BOTTOMRIGHT; + aNew.ShadowWidth = 100; + aNew.IsTransparent = FALSE; + aNew.Color = 0xff0000L; + aAny.set( &aNew, aAny.getReflection() ); + xProp->setPropertyValue(L"ShadowFormat", aAny); + } + + aAny = xProp->getPropertyValue(L"RotationValue"); + aAny.setINT32(4500); + xProp->setPropertyValue(L"RotationValue", aAny); + + aAny = xProp->getPropertyValue(L"FontHeight"); + aAny.setUINT32(280); + xProp->setPropertyValue(L"FontHeight", aAny); + + aAny = xProp->getPropertyValue(L"TransparentBackground"); + aAny.setBOOL(FALSE); + xProp->setPropertyValue(L"TransparentBackground", aAny); + + aAny = xProp->getPropertyValue(L"BackgroundColor"); + aAny.setUINT32(0xffff00); + xProp->setPropertyValue(L"BackgroundColor", aAny); + + aAny = xProp->getPropertyValue(L"CellProtection"); + if ( aAny.getReflection()->getName() == + CellProtection_getReflection()->getName() ) + { + //CellProtection* pOld = (CellProtection*)aAny.get(); + CellProtection aNew; + aNew.Locked = FALSE; + aNew.FormulaHidden = FALSE; + aNew.Hidden = FALSE; + aNew.PrintHidden = FALSE; + aAny.set( &aNew, aAny.getReflection() ); + xProp->setPropertyValue(L"CellProtection", aAny); + } + } + + // XIndexAccess gibts nur wenn's mehrere sind (??!??!) + XIndexAccessRef xIndex = (XIndexAccess*) + xColl->queryInterface(XIndexAccess::getSmartUik()); + if ( xIndex ) + { + USHORT nCount = (USHORT)xIndex->getCount(); + aTimeText.SetText( String(nCount) ); + } + } + } + } + } + } + + if (xLock) + xLock->removeActionLock(); + } +} + + +void lcl_Cells( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + { + long nCount = 0; + ULONG nStart = Time::GetSystemTicks(); + + XActionLockableRef xLock = (XActionLockable*) + xDoc->queryInterface(XActionLockable::getSmartUik()); +// if (xLock) +// xLock->addActionLock(); + + CellRangeAddress aRngAddr; + aRngAddr.Sheet = 0; + aRngAddr.StartColumn = 0; + aRngAddr.StartRow = 0; + aRngAddr.EndColumn = 9; + aRngAddr.EndRow = 19; + XCellRangeRef xRange = xDoc->getCellRange(aRngAddr); + if (xRange) + { + XCellCollectionRef xColl = (XCellCollection*) + xRange->queryInterface(XCellCollection::getSmartUik()); + if (xColl) + { + XEnumerationAccessRef xEnAcc = xColl->getCells(); + if (xEnAcc) + { + XEnumerationRef xEnum = xEnAcc->getEnumeration(); + if (xEnum) + { + while (xEnum->hasMoreElements()) + { + XInterfaceRef xInt = xEnum->nextElement(); + if (xInt) + { + ++nCount; + } + } + } + } + } + } + + ULONG nEnd = Time::GetSystemTicks(); + aTimeText.SetText(String(nCount)+String(" ")+String(nEnd-nStart)+String(" ms")); + + +// if (xLock) +// xLock->removeActionLock(); + } +} + +void lcl_Sheet( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (!xSheets) return; + XTableSheetRef xSheet = xSheets->getSheetByIndex(0); + if (!xSheet) return; + XNamedRef xNamed = (XNamed*)xSheet->queryInterface(XNamed::getSmartUik()); + if (!xNamed) return; + + String aName = OUStringToString( xNamed->getName(), CHARSET_SYSTEM ); + aName += 'X'; + xNamed->setName(StringToOUString( aName, CHARSET_SYSTEM )); + + XCellRangeRef xRange = (XCellRange*)xSheet->queryInterface(XCellRange::getSmartUik()); + if (!xRange) return; + XCellRef xCell = xRange->getCell(2,1); + if (!xCell) return; + XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); + if (!xText) return; + String aBla = OUStringToString( xText->getText(), CHARSET_SYSTEM ); + aBla += "bla"; + xText->setText(StringToOUString( aBla, CHARSET_SYSTEM )); + + XColumnRowRangeRef xCRR = (XColumnRowRange*)xSheet->queryInterface(XColumnRowRange::getSmartUik()); + if (!xCRR) return; + + XTableColumnsRef xCols = xCRR->getColumns(); + if (!xCols) return; + XPropertySetRef xCol = xCols->getColumnByIndex(2); + if (!xCol) return; + + UINT16 nWidth = TypeConversion::toUINT16(xCol->getPropertyValue(L"Width")); +// UINT16 nNewWidth = nWidth + 100; +// xCol->setPropertyValue(L"Width", UsrAny(nNewWidth)); + + xCol->setPropertyValue(L"OptimalWidth", UsrAny((BOOL)TRUE)); + xCol->setPropertyValue(L"NewPage", UsrAny((BOOL)FALSE)); + + UsrAny aAny = xCol->getPropertyValue(L"ShadowFormat"); + if ( aAny.getReflection()->getName() == + ShadowFormat_getReflection()->getName() ) + { + //ShadowFormat* pOld = (ShadowFormat*)aAny.get(); + ShadowFormat aNew; + aNew.Location = SHADOWLOCATION_BOTTOMRIGHT; + aNew.ShadowWidth = 100; + aNew.IsTransparent = FALSE; + aNew.Color = 0xff0000L; + aAny.set( &aNew, aAny.getReflection() ); + xCol->setPropertyValue(L"ShadowFormat", aAny); + } + + XTableRowsRef xRows = xCRR->getRows(); + if (!xRows) return; + XPropertySetRef xRow = xRows->getRowByIndex(1); + if (!xRow) return; + + xRows->removeRowsByIndex( 2, 1 ); + + UINT16 nHeight = TypeConversion::toUINT16(xRow->getPropertyValue(L"Height")); + BOOL bOptH = TypeConversion::toBOOL(xRow->getPropertyValue(L"OptimalHeight")); + + UINT16 nNewHeight = nHeight + 100; + xRow->setPropertyValue(L"Height", UsrAny(nNewHeight)); + + aTimeText.SetText(String("W:")+String(nWidth)+String(" H:")+String(nHeight)+ + String(" ")+String((USHORT)bOptH)); +} + +void lcl_Names( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XNamedRangesRef xNames = xDoc->getNamedRanges(); + if (!xNames) return; + XNamedRangeRef xName = xNames->getRangeByName(L"bla"); + if (!xName) return; + String aCont = OUStringToString( xName->getContent(), CHARSET_SYSTEM ); + aTimeText.SetText(aCont); + + XCellRangeSourceRef xSource = (XCellRangeSource*) + xName->queryInterface(XCellRangeSource::getSmartUik()); + if (!xSource) return; + XCellRangeRef xRange = xSource->getReferredCells(); + if (!xRange) return; + XPropertySetRef xProp = (XPropertySet*)xRange->queryInterface(XPropertySet::getSmartUik()); + if (!xProp) return; + UsrAny aAny = xProp->getPropertyValue(L"RotationValue"); + aAny.setINT32(3000); + xProp->setPropertyValue(L"RotationValue", aAny); +} + +void lcl_Sheets( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (!xSheets) return; + +#if 0 + xSheets->insertSheet( "hinten", 100 ); + xSheets->insertSheet( "vorne", 0 ); + xSheets->removeSheetByName( "hinten" ); + xSheets->removeSheetByName( "vorne" ); +#endif + + xSheets->moveSheet(0, 1, TRUE); + xSheets->moveSheet(0, 2, FALSE); +} + +void lcl_Goal( FixedText& aTimeText ) +{ + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XGoalSeekRef xGoal = (XGoalSeek*)xDoc->queryInterface(XGoalSeek::getSmartUik()); + if (!xGoal) return; + + double fResult; + CellAddress aFormula; // A1 + aFormula.Sheet = 0; + aFormula.Column = 0; + aFormula.Row = 0; + CellAddress aVar; // A2 + aVar.Sheet = 0; + aVar.Column = 0; + aVar.Row = 1; + BOOL bFound = xGoal->doGoalSeek(fResult, aFormula, aVar, L"42"); + + if (bFound) + { + CellAddress aOut; // A3 + aOut.Sheet = 0; + aOut.Column = 0; + aOut.Row = 2; + + XCellRef xCell = xDoc->getCell(aOut); + if (!xCell) return; + xCell->setValue(fResult); + } +} + +void lcl_TabOp( FixedText& aTimeText ) +{ + // Mehrfachoperation auf Tabelle2 + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + + XCellRangeRef xRange; + XTableOperationRef xGoal; + CellRangeAddress aRangeAddr; + CellRangeAddress aFormulaRange; + CellAddress aColumnCell; + CellAddress aRowCell; + TableOperationMode nMode; + + aRangeAddr.Sheet = 1; // c9:e11 + aRangeAddr.StartColumn = 2; + aRangeAddr.StartRow = 8; + aRangeAddr.EndColumn = 4; + aRangeAddr.EndRow = 10; + aFormulaRange.Sheet = 1; // c6:c7 + aFormulaRange.StartColumn = 2; + aFormulaRange.StartRow = 5; + aFormulaRange.EndColumn = 2; + aFormulaRange.EndRow = 6; + aColumnCell.Sheet = 0; // nicht benutzt + aColumnCell.Column = 0; + aColumnCell.Row = 0; + aRowCell.Sheet = 1; // c5 + aRowCell.Column = 2; + aRowCell.Row = 4; + nMode = TABLEOP_ROW; + + xRange = xDoc->getCellRange(aRangeAddr); + if (!xRange) return; + xGoal = (XTableOperation*)xRange->queryInterface(XTableOperation::getSmartUik()); + if (!xGoal) return; + xGoal->setTableOperation( nMode, aFormulaRange, aColumnCell, aRowCell ); + + aRangeAddr.Sheet = 1; // b19:d21 + aRangeAddr.StartColumn = 1; + aRangeAddr.StartRow = 18; + aRangeAddr.EndColumn = 3; + aRangeAddr.EndRow = 20; + aFormulaRange.Sheet = 1; // c16:d16 + aFormulaRange.StartColumn = 2; + aFormulaRange.StartRow = 15; + aFormulaRange.EndColumn = 3; + aFormulaRange.EndRow = 15; + aColumnCell.Sheet = 1; // b16 + aColumnCell.Column = 1; + aColumnCell.Row = 15; + aRowCell.Sheet = 0; // nicht benutzt + aRowCell.Column = 0; + aRowCell.Row = 0; + nMode = TABLEOP_COLUMN; + + xRange = xDoc->getCellRange(aRangeAddr); + if (!xRange) return; + xGoal = (XTableOperation*)xRange->queryInterface(XTableOperation::getSmartUik()); + if (!xGoal) return; + xGoal->setTableOperation( nMode, aFormulaRange, aColumnCell, aRowCell ); + + aRangeAddr.Sheet = 1; // b29:e32 + aRangeAddr.StartColumn = 1; + aRangeAddr.StartRow = 28; + aRangeAddr.EndColumn = 4; + aRangeAddr.EndRow = 31; + aFormulaRange.Sheet = 1; // c27:c27 + aFormulaRange.StartColumn = 2; + aFormulaRange.StartRow = 26; + aFormulaRange.EndColumn = 2; + aFormulaRange.EndRow = 26; + aColumnCell.Sheet = 1; // c25 + aColumnCell.Column = 2; + aColumnCell.Row = 24; + aRowCell.Sheet = 1; // c26 + aRowCell.Column = 2; + aRowCell.Row = 25; + nMode = TABLEOP_BOTH; + + xRange = xDoc->getCellRange(aRangeAddr); + if (!xRange) return; + xGoal = (XTableOperation*)xRange->queryInterface(XTableOperation::getSmartUik()); + if (!xGoal) return; + xGoal->setTableOperation( nMode, aFormulaRange, aColumnCell, aRowCell ); +} + +void lcl_Fill( FixedText& aTimeText ) +{ + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + + XCellSeriesRef xFill = (XCellSeries*)xSelInt->queryInterface(XCellSeries::getSmartUik()); + if (!xFill) return; + +// xFill->fillAuto( FILL_DIRECTION_TO_BOTTOM, 2 ); + + xFill->fillSeries( FILL_DIRECTION_TO_LEFT, FILL_MODE_GROWTH, FILL_DATE_DAY, + 2.0, 1000.0 ); +} + +void lcl_Audi( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (!xSheets) return; + XTableSheetRef xSheet = xSheets->getSheetByIndex(0); + if (!xSheet) return; + + XSheetAuditingRef xAudi = (XSheetAuditing*)xSheet->queryInterface(XSheetAuditing::getSmartUik()); + if (!xAudi) return; + + CellAddress aPosition; + aPosition.Sheet = 0; + aPosition.Column = 0; + aPosition.Row = 0; + xAudi->showDependents(aPosition); +} + +void lcl_Consoli( FixedText& aTimeText ) +{ + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XConsolidationRef xCons = (XConsolidation*)xDoc->queryInterface(XConsolidation::getSmartUik()); + if (!xCons) return; + XConsolidationDescriptorRef xDesc = xCons->createConsolidationDescriptor(FALSE); + if (!xDesc) return; + xDesc->setFunction(SUMMARY_COUNTNUMS); + xCons->consolidate(xDesc); +} + +void lcl_Sort( FixedText& aTimeText ) +{ + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XSortableRef xSort = (XSortable*)xSelInt->queryInterface(XSortable::getSmartUik()); + if (!xSort) return; + XSortDescriptorRef xDesc = xSort->createSortDescriptor(FALSE); + if (!xDesc) return; + Sequence<SortField> aFields = xDesc->getSortFields(); + if (aFields.getLen()) + { + // 1.Feld umkehren + SortField* pAry = aFields.getArray(); + if (!pAry) return; + pAry[0].Ascending = !pAry[0].Ascending; + } + else // neue Sequence, 1. Spalte aufsteigend + { + aFields = Sequence<SortField>(1); + SortField* pAry = aFields.getArray(); + if (!pAry) return; + pAry[0].Field = 0; + pAry[0].Ascending = TRUE; + pAry[0].Type = SORT_FIELD_AUTOMATIC; + } + xDesc->setSortFields(aFields); + + XTableSortDescriptorRef xTableSort = (XTableSortDescriptor*) + xDesc->queryInterface(XTableSortDescriptor::getSmartUik()); + if (!xTableSort) return; + CellAddress aOutPos; + aOutPos.Sheet = 2; + aOutPos.Column = 0; + aOutPos.Row = 0; + xTableSort->setUseOutputPosition(TRUE); + xTableSort->setOutputPosition(aOutPos); + + XPropertySetRef xPropSet = (XPropertySet*) + xDesc->queryInterface(XPropertySet::getSmartUik()); + if (!xPropSet) return; + xPropSet->setPropertyValue(L"IncludeFormats", UsrAny((BOOL)FALSE)); + + xSort->sort(xDesc); +} + +void lcl_Filter( FixedText& aTimeText ) +{ + aTimeText.SetText("..."); + + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XFilterableRef xFilter = (XFilterable*)xSelInt->queryInterface(XFilterable::getSmartUik()); + if (!xFilter) return; + +#if 0 + XTableFilterDescriptorRef xDesc = xFilter->createFilterDescriptor(FALSE); + if (!xDesc) return; + Sequence<TableFilterField> aFields = xDesc->getFilterFields(); + if (aFields.getLen()) + { + // 1.Feld zwischen 1. und 2. Spalte toggeln + TableFilterField* pAry = aFields.getArray(); + if (!pAry) return; + pAry[0].Field = pAry[0].Field ? 0 : 1; + } + xDesc->setFilterFields(aFields); + xFilter->filter(xDesc); +#endif + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + CellRangeAddress aAddress; + aAddress.Sheet = 3; + aAddress.StartColumn = 0; + aAddress.StartRow = 0; + aAddress.EndColumn = 1; + aAddress.EndRow = 2; + XCellRangeRef xRange = xDoc->getCellRange(aAddress); + if (!xRange) return; + XAdvancedFilterSourceRef xSource = (XAdvancedFilterSource*) + xRange->queryInterface(XAdvancedFilterSource::getSmartUik()); + if (!xSource) return; + + XTableFilterDescriptorRef xDesc = xSource->createAdvancedFilter(xFilter); + if (!xDesc) + { + aTimeText.SetText("kein Filter"); + return; + } + aTimeText.SetText("Filter gefunden"); + xFilter->filter(xDesc); +} + +void lcl_AutoFilter( FixedText& aTimeText ) +{ + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XFilterableRef xFilter = (XFilterable*)xSelInt->queryInterface(XFilterable::getSmartUik()); + if (!xFilter) return; + + BOOL bAuto = xFilter->getAutoFilter(); + xFilter->setAutoFilter(!bAuto); +} + +void lcl_Merge( FixedText& aTimeText ) +{ + static BOOL bMerged = FALSE; + + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XMergeableRef xMerge = (XMergeable*)xSelInt->queryInterface(XMergeable::getSmartUik()); + if (!xMerge) return; + + if (bMerged) + xMerge->unmergeCells(); + else + xMerge->mergeCells(); + bMerged = !bMerged; +} + +void lcl_Outline( FixedText& aTimeText ) +{ + static BOOL bOutline = FALSE; + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (!xSheets) return; + XTableSheetRef xSheet = xSheets->getSheetByIndex(0); + if (!xSheet) return; + XSheetOutlineRef xOut = (XSheetOutline*)xSheet->queryInterface(XSheetOutline::getSmartUik()); + if (!xOut) return; + + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XAddressableCellRangeRef xRange = (XAddressableCellRange*) + xSelInt->queryInterface(XAddressableCellRange::getSmartUik()); + if (!xRange) return; + CellRangeAddress aRange = xRange->getRangeAddress(); + + if (bOutline) + xOut->showDetail( aRange ); + else + xOut->hideDetail( aRange ); + + bOutline = !bOutline; +} + +void lcl_Bla( FixedText& aTimeText ) +{ + aTimeText.SetText("..."); + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XActionLockableRef xLock = (XActionLockable*)xDoc->queryInterface(XActionLockable::getSmartUik()); + if (!xLock) return; + xLock->addActionLock(); + xLock->addActionLock(); + USHORT nCount = xLock->resetActionLocks(); // sollte 2 sein + String aBla = nCount; + xLock->setActionLocks(nCount); + xLock->removeActionLock(); + xLock->removeActionLock(); + + aBla += '/'; aBla += xLock->resetActionLocks(); // sollte 0 sein + + aTimeText.SetText(aBla); +} + +void lcl_CellCursor( FixedText& aTimeText ) +{ + static int nCursorCount = 0; + + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XCellCollectionRef xColl = (XCellCollection*)xSelInt->queryInterface(XCellCollection::getSmartUik()); + if (!xColl) return; + + XLineCursorRef xCursor = xColl->createCursor(); + if (!xCursor) return; + XCellCursorRef xCC = (XCellCursor*)xCursor->queryInterface(XCellCursor::getSmartUik()); + if (!xCC) return; + XCellRangesCursorRef xCRC = (XCellRangesCursor*)xCursor->queryInterface(XCellRangesCursor::getSmartUik()); + if (!xCRC) return; + XCellRangeCursorRef xCR = (XCellRangeCursor*)xCursor->queryInterface(XCellRangeCursor::getSmartUik()); + if (!xCR) return; + XCellContentCursorRef xCCC = (XCellContentCursor*)xCursor->queryInterface(XCellContentCursor::getSmartUik()); + if (!xCCC) return; + XFormulaCursorRef xFC = (XFormulaCursor*)xCursor->queryInterface(XFormulaCursor::getSmartUik()); + if (!xFC) return; + + CellAddress aPos; + aPos.Sheet = 0; // ignored + aPos.Row = 3; + aPos.Column = 2; + + switch (nCursorCount++) + { + case 0: + xFC->gotoDependents(FALSE); + break; + case 1: + xFC->gotoDependents(TRUE); + break; + case 2: + xFC->gotoPrecedents(FALSE); + break; + case 3: + xFC->gotoPrecedents(TRUE); + + nCursorCount = 0; + break; + } + + XCellCollectionRef xNew = xCC->getRanges(); + if (!xNew) return; + xView->select( xNew ); +} + +void lcl_Notes( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (!xSheets) return; + XTableSheetRef xSheet = xSheets->getSheetByIndex(0); + if (!xSheet) return; + + XSheetAnnotationsRef xNotes = xSheet->getAnnotations(); + if (!xNotes) return; + XIndexAccessRef xNIndex = (XIndexAccess*)xNotes->queryInterface(XIndexAccess::getSmartUik()); + if (!xNIndex) return; + + CellAddress aPos; + aPos.Column = 0; + aPos.Row = 0; + aPos.Sheet = 0; + xNotes->addAnnotation( L"neu", aPos ); + + ULONG nCount = xNIndex->getCount(); + for (ULONG i=0; i<nCount; i++) + { + XSheetAnnotationRef xAnn = xNotes->getAnnotationByIndex((UINT16)i); + XTextRef xText = (XText*)xAnn->queryInterface(XText::getSmartUik()); + if (xText) + { + String aStr = OUStringToString( xText->getText(), CHARSET_SYSTEM ); + aStr += "x"; + xText->setText(StringToOUString( aStr, CHARSET_SYSTEM )); + } + } +} + +void lcl_Scenario( FixedText& aTimeText ) +{ + aTimeText.SetText( "..." ); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (!xSheets) return; + XTableSheetRef xSheet = xSheets->getSheetByIndex(0); + if (!xSheet) return; + + XScenariosRef xColl = xSheet->getScenarios(); + if (!xColl) return; + + Sequence<CellRangeAddress> aRanges(2); + CellRangeAddress* pAry = aRanges.getArray(); + if (!pAry) return; + pAry[0].Sheet = 0; + pAry[0].StartColumn = 0; + pAry[0].StartRow = 0; + pAry[0].EndColumn = 1; + pAry[0].EndRow = 1; + pAry[1].Sheet = 0; + pAry[1].StartColumn = 3; + pAry[1].StartRow = 3; + pAry[1].EndColumn = 4; + pAry[1].EndRow = 4; + + xColl->addScenario( aRanges, L"bla", L"bla blubb" ); + + XIndexAccessRef xIndex = (XIndexAccess*)xColl->queryInterface(XIndexAccess::getSmartUik()); + if (!xIndex) return; + ULONG nCount = xIndex->getCount(); + aTimeText.SetText( nCount ); + + XScenarioRef xScen = xColl->getScenarioByIndex(0); + if (!xScen) return; + + aRanges = Sequence<CellRangeAddress>(1); + pAry = aRanges.getArray(); + if (!pAry) return; + pAry[0].Sheet = 0; + pAry[0].StartColumn = 6; + pAry[0].StartRow = 6; + pAry[0].EndColumn = 7; + pAry[0].EndRow = 7; + + xScen->addRanges( aRanges ); + + XTableSheetRef xSh2 = xSheets->getSheetByIndex(1); + if (!xSh2) return; + + xSh2->setVisible( TRUE ); + xSh2->setVisible( FALSE ); +} + +void lcl_Formula( FixedText& aTimeText ) +{ + aTimeText.SetText("..."); + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + CellAddress aPos; + aPos.Sheet = 0; + aPos.Column = 0; + aPos.Row = 0; + XCellRef xCell = xDoc->getCell(aPos); + if (!xCell) return; + +// String aStr = OUStringToString( xCell->getFormula(), CHARSET_SYSTEM ); +// aTimeText.SetText(aStr); + + XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); + if (!xText) return; + String aStr = OUStringToString( xText->getText(), CHARSET_SYSTEM ); + aTimeText.SetText(aStr); +} + +void lcl_DBRange( FixedText& aTimeText ) // 23 +{ + aTimeText.SetText("..."); + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XDatabaseRangesRef xDBs = xDoc->getDatabaseRanges(); + if (!xDBs) return; + + CellRangeAddress aRange; + aRange.Sheet = 0; + aRange.StartColumn = 1; + aRange.StartRow = 1; + aRange.EndColumn = 3; + aRange.EndRow = 10; + + xDBs->addRange( L"blubb", aRange ); + + xDBs->removeRangeByName( L"gaga" ); + + XDatabaseRangeRef xDB = xDBs->getRangeByName( L"blubb" ); + if (!xDB) return; + + String aName = OUStringToString( xDB->getName(), CHARSET_SYSTEM ); + aTimeText.SetText(aName); + + xDB->setName( L"gaga" ); + + CellRangeAddress aDBRange = xDB->getDataArea(); + ++aDBRange.Sheet; + xDB->setDataArea(aDBRange); +} + +void lcl_FillTab( FixedText& aTimeText ) // 24 +{ + aTimeText.SetText("..."); + + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + + XCellRangesRef xRanges = (XCellRanges*)xSelInt->queryInterface(XCellRanges::getSmartUik()); + XIndexAccessRef xIndex = (XIndexAccess*)xSelInt->queryInterface(XIndexAccess::getSmartUik()); + if (!xRanges || !xIndex) return; + + ULONG nCount = xIndex->getCount(); + aTimeText.SetText(nCount); +} + +void lcl_Listener( FixedText& aTimeText ) // 25 +{ + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XStarCalcViewRef xView = (XStarCalcView*)xInt->queryInterface(XStarCalcView::getSmartUik()); + if (!xView) return; + xView->addSelectionChangeListener( new ScTestListener(&aTimeText) ); +} + +void lcl_CellAttrib( FixedText& aTimeText ) // 26 +{ + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return; + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return; + XTextRef xText = (XText*)xSelInt->queryInterface(XText::getSmartUik()); + if (!xText) return; + + XTextCursorRef xCursor = xText->createTextCursor(); + if (!xCursor) return; + + XTextPositionRef xPos = (XTextPosition*)xCursor->queryInterface(XTextPosition::getSmartUik()); + XPropertySetRef xProp = (XPropertySet*)xCursor->queryInterface(XPropertySet::getSmartUik()); + XParagraphCursorRef xPar = (XParagraphCursor*)xCursor->queryInterface(XParagraphCursor::getSmartUik()); + if (!xPos || !xProp || !xPar) return; + + xCursor->gotoStart(FALSE); + xCursor->goRight(1,FALSE); + xCursor->goRight(1,TRUE); + + UsrAny aAny = xProp->getPropertyValue(L"FontHeight"); + UINT32 nOld = aAny.getUINT32(); + aAny.setUINT32(nOld*11/10); + xProp->setPropertyValue(L"FontHeight", aAny); + + xPos->collapseToEnd(); + xCursor->goRight(1,TRUE); + + xProp->setPropertyValue(L"Bold", UsrAny((BOOL)TRUE)); + + xPos->setText(L"x"); + + xPos->collapseToEnd(); + xPar->gotoNextParagraph(FALSE,TRUE); + xProp->setPropertyValue(L"Italic", UsrAny((BOOL)TRUE)); + xProp->setPropertyValue(L"Underlined", UsrAny((BOOL)TRUE)); +} + +void lcl_Styles( FixedText& aTimeText ) // 27 +{ + aTimeText.SetText("..."); + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XStyleFamiliesRef xFamilies = xDoc->getStyleFamilies(); + if (!xFamilies) return; + XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_CELL ); +// XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_PAGE ); + if (!xFamily) return; + long nCount = xFamily->getCount(); + aTimeText.SetText(nCount); + + XStyleRef xStyle = xFamily->getStyleByName(L"rot"); + if (!xStyle) return; +// XPropertySetRef xProp = (XPropertySet*)xStyle->queryInterface(XPropertySet::getSmartUik()); +// if (!xProp) return; + + XStyleRef xNew = xFamily->addStyle( L"gaga", xStyle ); + if (!xNew) return; + XPropertySetRef xProp = (XPropertySet*)xNew->queryInterface(XPropertySet::getSmartUik()); + if (!xProp) return; + + UsrAny aAny; + aAny = xProp->getPropertyValue(L"TransparentBackground"); + aAny.setBOOL(FALSE); + xProp->setPropertyValue(L"TransparentBackground", aAny); + aAny = xProp->getPropertyValue(L"BackgroundColor"); + aAny.setUINT32(0xffff00); + xProp->setPropertyValue(L"BackgroundColor", aAny); + + xFamily->removeStyle( L"rot" ); +} + +void lcl_PageStyle( FixedText& aTimeText ) // 28 +{ + aTimeText.SetText("..."); + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + XStyleFamiliesRef xFamilies = xDoc->getStyleFamilies(); + if (!xFamilies) return; + XStyleFamilyRef xFamily = xFamilies->getStyleFamilyByType( STYLE_FAMILY_PAGE ); + if (!xFamily) return; + XStyleRef xStyle = xFamily->getStyleByName(L"Standard"); + if (!xStyle) return; + XPropertySetRef xProp = (XPropertySet*)xStyle->queryInterface(XPropertySet::getSmartUik()); + if (!xProp) return; + + UsrAny aAny; + aAny = xProp->getPropertyValue(L"RightPageHeaderContent"); + + // geht nicht: +// if ( !XHeaderFooterContent_getReflection()->equals(*aAny.getReflection()) ) +// return; + + XHeaderFooterContentRef* pxContent = (XHeaderFooterContentRef*)aAny.get(); + if (!pxContent || !pxContent->is()) return; + + XTextRef xText = (*pxContent)->getCenterText(); + if (!xText) return; + + String aVal = OUStringToString(xText->getText(), CHARSET_SYSTEM); + aTimeText.SetText(aVal); + +// xText->setText(L"Bla fasel slz"); + lcl_SetText(xText); + + xProp->setPropertyValue(L"RightPageHeaderContent", aAny); +} + +void lcl_AutoForm( FixedText& aTimeText ) // 29 +{ + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return; + +#if 0 + //! Test - AutoFormat muss von der App kommen + XStarCalcViewRef xView = (XStarCalcView*)xInt->queryInterface(XStarCalcView::getSmartUik()); + if (!xView) return; + XTableAutoFormatsRef xFormats = xView->getTableAutoFormats(); + if (!xFormats) return; + //! Test +#endif + XTableAutoFormatsRef xFormats; + + XTableAutoFormatRef xFormat = xFormats->getAutoFormatByName(L"gaga"); + if (!xFormat) return; + XPropertySetRef xProp = (XPropertySet*)xFormat->queryInterface(XPropertySet::getSmartUik()); + if (!xProp) return; + + BOOL bVal = TypeConversion::toBOOL(xProp->getPropertyValue(L"IncludeBackground")); + xProp->setPropertyValue(L"IncludeBackground", UsrAny(BOOL(!bVal))); + + XNamedRef xNamed = (XNamed*)xFormat->queryInterface(XNamed::getSmartUik()); + if (!xNamed) return; + xNamed->setName(L"zzz"); + + xFormats->addAutoFormat(L"gaga"); + XTableAutoFormatRef xNew = xFormats->getAutoFormatByName(L"gaga"); + if (!xNew) return; + + for (USHORT i=0; i<16; i++) + { + XPropertySetRef xNewProp = xNew->getFieldByIndex(i); + if (!xNewProp) return; + + xNewProp->setPropertyValue(L"TransparentBackground", UsrAny(BOOL(FALSE))); + UINT32 nColor = 0x111100 * i; + xNewProp->setPropertyValue(L"BackgroundColor", UsrAny(nColor)); + } +} + +void lcl_Pivot( FixedText& aTimeText ) // 30 +{ + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (!xDoc) return; + + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (!xSheets) return; + XIndexAccessRef xInd = (XIndexAccess*)xSheets->queryInterface(XIndexAccess::getSmartUik()); + if (!xInd) return; + USHORT nCount = (USHORT)xInd->getCount(); + + for (USHORT nTab=0; nTab<nCount; nTab++) + { + XTableSheetRef xSheet = xSheets->getSheetByIndex(nTab); + if (!xSheet) return; + XDataPilotTablesRef xPivots = xSheet->getDataPilotTables(); + if (!xPivots) return; + lcl_OutputNames( xPivots, xDoc, nTab,0,0 ); + XIndexAccessRef xPInd = (XIndexAccess*)xPivots->queryInterface(XIndexAccess::getSmartUik()); + if (!xPInd) return; + USHORT nPCount = (USHORT)xPInd->getCount(); + for (USHORT nP=0; nP<nPCount; nP++) + { + XDataPilotTableRef xTable = xPivots->getTableByIndex(nP); + if (!xTable) return; + +// xTable->refreshTable(); + + XDataPilotDescriptorRef xDesc = (XDataPilotDescriptor*) + xTable->queryInterface(XDataPilotDescriptor::getSmartUik()); + if (!xDesc) return; + CellRangeAddress aSource = xDesc->getSourceRange(); + ++aSource.Sheet; + xDesc->setSourceRange(aSource); + + CellRangeAddress aAddr = xTable->getOutputRange(); + XCellRangeRef xRange = xDoc->getCellRange(aAddr); + if (!xRange) return; + XPropertySetRef xProp = (XPropertySet*)xRange->queryInterface(XPropertySet::getSmartUik()); + if (!xProp) return; + xProp->setPropertyValue(L"TransparentBackground", UsrAny(BOOL(FALSE))); + xProp->setPropertyValue(L"BackgroundColor", UsrAny((UINT32)0x00FF00)); + } + } +} + +IMPL_LINK(MyWindow, CountHdl, PushButton*, EMPTYARG) +{ +#if 0 + + long nCount = aCountField.GetValue(); + if (nCount < 1) + nCount = 1; + + ULONG nStart = Time::GetSystemTicks(); + for (long i=0; i<nCount; i++) + lcl_DoCount(); + ULONG nEnd = Time::GetSystemTicks(); + aTimeText.SetText(String(nCount)+String(" x Count: ")+String(nEnd-nStart)+String(" ms")); + +#else + + long nCount = aCountField.GetValue(); + switch ( nCount ) + { + case 0: + { + ULONG nStart = Time::GetSystemTicks(); + lcl_DoCount(); + ULONG nEnd = Time::GetSystemTicks(); + aTimeText.SetText(String("Count: ")+String(nEnd-nStart)+String(" ms")); + } + break; + case 1: + lcl_GlobalCell(); + break; + case 2: + lcl_Annotations(aTimeText); + break; + case 3: + lcl_Cursor(aTimeText); + break; + case 4: + lcl_Cells(aTimeText); + break; + case 5: + lcl_Sheet(aTimeText); + break; + case 6: + lcl_Names(aTimeText); + break; + case 7: + lcl_Sheets(aTimeText); + break; + case 8: + lcl_Goal(aTimeText); + break; + case 9: + lcl_TabOp(aTimeText); + break; + case 10: + lcl_Fill(aTimeText); + break; + case 11: + lcl_Audi(aTimeText); + break; + case 12: + lcl_Consoli(aTimeText); + break; + case 13: + lcl_Sort(aTimeText); + break; + case 14: + lcl_Filter(aTimeText); + break; + case 15: + lcl_AutoFilter(aTimeText); + break; + case 16: + lcl_Merge(aTimeText); + break; + case 17: + lcl_Outline(aTimeText); + break; + case 18: + lcl_Bla(aTimeText); + break; + case 19: + lcl_CellCursor(aTimeText); + break; + case 20: + lcl_Notes(aTimeText); + break; + case 21: + lcl_Scenario(aTimeText); + break; + case 22: + lcl_Formula(aTimeText); + break; + case 23: + lcl_DBRange(aTimeText); + break; + case 24: + lcl_FillTab(aTimeText); + break; + case 25: + lcl_Listener(aTimeText); + break; + case 26: + lcl_CellAttrib(aTimeText); + break; + case 27: + lcl_Styles(aTimeText); + break; + case 28: + lcl_PageStyle(aTimeText); + break; + case 29: + lcl_AutoForm(aTimeText); + break; + case 30: + lcl_Pivot(aTimeText); + break; + } + +#endif + + return 0; +} + +//----------------------------------------------------------------------- + +IMPL_LINK(MyWindow, TextHdl, PushButton*, EMPTYARG) +{ + USHORT nTab = 0; + USHORT nCol = (USHORT)aColField.GetValue(); + USHORT nRow = (USHORT)aRowField.GetValue(); + USHORT nPos = (USHORT)aPosField.GetValue(); + USHORT nLen = (USHORT)aLenField.GetValue(); + String aStr = aTextEdit.GetText(); + + aTimeText.SetText("..."); + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + { + CellAddress aPos; + aPos.Sheet = nTab; + aPos.Column = nCol; + aPos.Row = nRow; + XCellRef xCell = xDoc->getCell(aPos); + if ( xCell ) + { + XTextRef xCellText = (XText*)xCell->queryInterface(XText::getSmartUik()); + if (xCellText) + { + XTextCursorRef xCursor = xCellText->createTextCursor(); + if (xCursor) + { + XTextPositionRef xPos = (XTextPosition*) + xCursor->queryInterface(XTextPosition::getSmartUik()); + XControlCharacterInsertableRef xControl = (XControlCharacterInsertable*) + xCursor->queryInterface(XControlCharacterInsertable::getSmartUik()); + + if (xPos && xControl) + { + xCursor->gotoStart(FALSE); + xCursor->goRight(11,TRUE); + String aVal = OUStringToString( xPos->getText(), CHARSET_SYSTEM ); + aTimeText.SetText(aVal); + } + } + } + } + } + + return 0; +} + +//----------------------------------------------------------------------- + +IMPL_LINK(MyWindow, BlaHdl, PushButton*, EMPTYARG) +{ + aTimeText.SetText("..."); + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + { + CellAddress aPos; + aPos.Sheet = 0; + aPos.Column = 1; + aPos.Row = 2; + XCellRef xCell = xDoc->getCell(aPos); + if ( xCell ) + { + XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); + XFieldContainerRef xCont = (XFieldContainer*) + xCell->queryInterface(XFieldContainer::getSmartUik()); + + if ( xText && xCont ) + { + XFieldTypesRef xTypes = xCont->getFieldTypes(); + if ( xTypes ) + { + XTextFieldTypeRef xType = xTypes->getFieldType( FIELDTYPE_INTERNET ); + XTextCursorRef xCursor = xText->createTextCursor(); + if ( xCursor && xType ) + { +#if 0 + // Feld einfuegen + XTextPositionRef xPos = (XTextPosition*) + xCursor->queryInterface(XTextPosition::getSmartUik()); + if ( xPos ) + { + xCursor->gotoEnd(FALSE); + XTextFieldRef xField = xTypes->insertTextField( xType, xPos ); + if (xField) + { + // Eigenschaften setzen + XPropertySetRef xProp = (XPropertySet*)xField-> + queryInterface(XPropertySet::getSmartUik()); + if ( xProp ) + { + xProp->setPropertyValue(L"URL", + UsrAny(String("http://www.mopo.de/"))); + xProp->setPropertyValue(L"Representation", + UsrAny(String("ein Hyperlink"))); + } + } + } +#endif + + // letztes Feld loeschen + XIndexAccessRef xIndex = (XIndexAccess*) + xType->queryInterface(XIndexAccess::getSmartUik()); + if (xIndex) + { + String aBla; + ULONG nCount = xIndex->getCount(); + for (ULONG i=0; i<nCount; i++) + { + XInterfaceRef xInt = xIndex->getElementByIndex(i); + if (xInt) + { + XPropertySetRef xProp = (XPropertySet*)xInt-> + queryInterface(XPropertySet::getSmartUik()); + if ( xProp ) + { + if (aBla.Len()) aBla += ','; + aBla += OUStringToString( + TypeConversion::toString( + xProp->getPropertyValue(L"URL") ), + CHARSET_SYSTEM ); + } + if ( i+1 == nCount ) // letztes + { + XTextFieldRef xField = (XTextField*)xInt-> + queryInterface(XTextField::getSmartUik()); + if (xField) + xTypes->removeTextField(xField); + } + } + } + aTimeText.SetText(aBla); + } + } + } + } + } + + xGlobalCell = xCell; + } + return 0; +} + + +//----------------------------------------------------------------------- + +IMPL_LINK(MyWindow, TabHdl, PushButton*, EMPTYARG) +{ + String aResult; + + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + if (xDoc) + { + XSpreadsheetsRef xSheets = xDoc->getSheets(); + if (xSheets) + { + XIndexAccessRef xIndex = (XIndexAccess*)xSheets->queryInterface(XIndexAccess::getSmartUik()); + if (xIndex) + { + USHORT nCount = (USHORT) xIndex->getCount(); + for (USHORT nTab=0; nTab<nCount; nTab++) + { + XInterfaceRef xInt = xIndex->getElementByIndex(nTab); + if (xInt) + { + XNamedRef xNamed = (XNamed*)xInt->queryInterface(XNamed::getSmartUik()); + if (xNamed) + { + if (nTab) + aResult += ","; + aResult += OUStringToString( xNamed->getName(), CHARSET_SYSTEM ); + } + } + } + } + + CellAddress aPos; + aPos.Sheet = 0; + aPos.Column = 0; + aPos.Row = 0; + + XEnumerationAccessRef xEAcc = (XEnumerationAccess*) + xSheets->queryInterface(XEnumerationAccess::getSmartUik()); + if (xEAcc) + { + XEnumerationRef xEnum = xEAcc->getEnumeration(); + if (xEnum) + { + while (xEnum->hasMoreElements()) + { + XInterfaceRef xInt = xEnum->nextElement(); + if (xInt) + { + XNamedRef xNamed = (XNamed*)xInt->queryInterface(XNamed::getSmartUik()); + if (xNamed) + { + UString aName = xNamed->getName(); + XCellRef xCell = xDoc->getCell(aPos); + if ( xCell ) + { + XTextRef xText = (XText*)xCell->queryInterface(XText::getSmartUik()); + xText->setText( aName ); + ++aPos.Row; + } + } + } + } + } + } + } + } + + aTimeText.SetText(aResult); + + return 0; +} + +//----------------------------------------------------------------------- + +void lcl_FillCells(XCellCollectionRef xColl) +{ + XEnumerationAccessRef xEnAcc = xColl->getCells(); + if (!xEnAcc) return; + XEnumerationRef xEnum = xEnAcc->getEnumeration(); + if (!xEnum) return; + while (xEnum->hasMoreElements()) + { + XInterfaceRef xInt = xEnum->nextElement(); + if (xInt) + { + XCellRef xCell = (XCell*)xInt->queryInterface(XCell::getSmartUik()); + if (xCell) + { + xCell->setValue(42.0); + } + } + } +} + +IMPL_LINK(MyWindow, ViewHdl, PushButton*, EMPTYARG) +{ + XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model + XInterfaceRef xInt = lcl_GetView(); + if (!xInt) return 0; + XDocumentViewRef xView = (XDocumentView*)xInt->queryInterface(XDocumentView::getSmartUik()); + if (!xView) return 0; + + XInterfaceRef xSelInt = xView->getSelection(); + if (!xSelInt) return 0; + +#if 0 + XPropertySetRef xProp = (XPropertySet*)xSelInt->queryInterface(XPropertySet::getSmartUik()); + if ( xProp ) + { + UsrAny aAny; + + aAny = xProp->getPropertyValue(L"TransparentBackground"); + aAny.setBOOL(FALSE); + xProp->setPropertyValue(L"TransparentBackground", aAny); + + aAny = xProp->getPropertyValue(L"BackgroundColor"); + aAny.setUINT32(0xffff00); + xProp->setPropertyValue(L"BackgroundColor", aAny); + } + XIndentRef xInd = (XIndent*)xSelInt->queryInterface(XIndent::getSmartUik()); + if ( xInd ) + { + xInd->incrementIndent(); + } +#endif + + XAutoFormattableRef xAuto = (XAutoFormattable*)xSelInt-> + queryInterface(XAutoFormattable::getSmartUik()); + if ( xAuto ) + xAuto->applyAutoFormat( L"gaga" ); + + XFormulaArrayRef xArr = (XFormulaArray*)xSelInt->queryInterface(XFormulaArray::getSmartUik()); + if ( xArr ) + { +// xArr->setFormulaArray( "123" ); + String aFormula = OUStringToString( xArr->getFormulaArray(), CHARSET_SYSTEM ); + aTimeText.SetText(aFormula); + } + else + aTimeText.SetText("..."); + + XTextRef xText = (XText*)xSelInt->queryInterface(XText::getSmartUik()); + if ( xText ) + { + String aStr = OUStringToString( xText->getText(), CHARSET_SYSTEM ); + aStr += 'X'; + xText->setText(StringToOUString(aStr, CHARSET_SYSTEM)); + } + + // Zelle selektieren + +#if 0 + if (xDoc) + { + CellAddress aPos; + aPos.Sheet = 0; + aPos.Column = 1; + aPos.Row = 2; + XCellRef xCell = xDoc->getCell(aPos); + if ( xCell ) + xView->select( xCell ); + } +#endif + + XPrintableRef xPrint = (XPrintable*)xInt->queryInterface(XPrintable::getSmartUik()); + String aName = OUStringToString( xPrint->getPrinterName(), CHARSET_SYSTEM ); +// aTimeText.SetText(aName); + + xPrint->setPrinterName(L"HP5_2"); +// xPrint->setPrinterName(L"blubb"); + +// XPropertySetRef xOptions; +// xPrint->print(xOptions); + +/* XViewPaneRef xPane = (XViewPane*)xInt->queryInterface(XViewPane::getSmartUik()); + if (!xPane) return 0; + xPane->setScrollRow( 2 ); +*/ + + XCellRangeSourceRef xSrc = (XCellRangeSource*) + xInt->queryInterface(XCellRangeSource::getSmartUik()); + if (!xSrc) return 0; + XCellRangeRef xRange = xSrc->getReferredCells(); + if (!xRange) return 0; + XCellCollectionRef xColl = (XCellCollection*) + xRange->queryInterface(XCellCollection::getSmartUik()); + if (!xColl) return 0; + + XActionLockableRef xLock = (XActionLockable*) + xDoc->queryInterface(XActionLockable::getSmartUik()); + if (xLock) + xLock->addActionLock(); // nicht zwischendurch painten + +// lcl_FillCells(xColl); + + if (xLock) + xLock->removeActionLock(); // nicht zwischendurch painten + + XStarCalcViewRef xCalc = (XStarCalcView*)xInt->queryInterface(XStarCalcView::getSmartUik()); + if (!xCalc) return 0; + + return 0; +} + diff --git a/sc/workben/testadd.idl b/sc/workben/testadd.idl new file mode 100644 index 000000000000..d2960529e615 --- /dev/null +++ b/sc/workben/testadd.idl @@ -0,0 +1,101 @@ +/************************************************************************* + * + * $RCSfile: testadd.idl,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:45:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef SC_WORKBEN_TESTADD_IDL +#define SC_WORKBEN_TESTADD_IDL + +#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/beans/XPropertySet.idl> +#include <com/sun/star/table/XCellRange.idl> +#include <com/sun/star/sheet/XVolatileResult.idl> + + +module stardiv +{ +module starcalc +{ +module test +{ + +/** test-interface for an AddIn implementation + */ +[ uik(2DB48150-7FBB-11d3-9F510050-042A51C9), ident("XTestAddIn", 1.0) ] +interface XTestAddIn:com::sun::star::uno::XInterface +{ + long countParams([in]sequence<any> aArgs); + double addOne([in]double fValue); + string repeatStr([in]string aStr, [in]long nCount); + string getDateString([in]com::sun::star::beans::XPropertySet xCaller, [in]double fValue); + long getColorValue([in]com::sun::star::table::XCellRange xRange); + sequence< sequence<double> > transpose([in]sequence< sequence<double> > aMatrix); + sequence< sequence<long> > transposeInt([in]sequence< sequence<long> > aMatrix); + com::sun::star::sheet::XVolatileResult callAsync([in]string aString); + string repeatMultiple([in]long nCount, [in]any aFirst, [in]sequence<any> aFollow); + any getStrOrVal([in]long nFlag); +}; + +}; +}; +}; + + + +#endif + |