summaryrefslogtreecommitdiff
path: root/sc/workben
diff options
context:
space:
mode:
Diffstat (limited to 'sc/workben')
-rw-r--r--sc/workben/addin.cxx588
-rw-r--r--sc/workben/addin.hxx104
-rw-r--r--sc/workben/celltrans/keywords_utf16.txtbin0 -> 1830 bytes
-rwxr-xr-xsc/workben/celltrans/parse.py209
-rw-r--r--sc/workben/makefile.mk96
-rw-r--r--sc/workben/map.idl37
-rw-r--r--sc/workben/result.cxx135
-rw-r--r--sc/workben/result.hxx77
-rw-r--r--sc/workben/test.cxx1939
-rw-r--r--sc/workben/testadd.idl67
10 files changed, 3252 insertions, 0 deletions
diff --git a/sc/workben/addin.cxx b/sc/workben/addin.cxx
new file mode 100644
index 000000000000..d3c64e2dd5c6
--- /dev/null
+++ b/sc/workben/addin.cxx
@@ -0,0 +1,588 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+#pragma hdrstop
+#endif
+
+#include <usr/factoryhlp.hxx>
+#include <usr/macros.hxx>
+#include <usr/reflserv.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/debug.hxx>
+#include <tools/date.hxx>
+#include <svl/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( false, "### InvalidRegistryException!" );
+ }
+ }
+ return 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;
+}
+
+::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" );
+ {
+ util::Date aDate;
+ aDateAny >>= aDate;
+ {
+ 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" );
+ sal_Bool bIsTrans;
+ aTrans >>= bIsTrans; //! dont use >>= for BOOL
+ if (!bIsTrans)
+ {
+ uno::Any aCol = xProp->getPropertyValue( L"CellBackColor" );
+ 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 );
+
+ 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();
+}
+
+//------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/workben/addin.hxx b/sc/workben/addin.hxx
new file mode 100644
index 000000000000..ce87f29726c6
--- /dev/null
+++ b/sc/workben/addin.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/workben/celltrans/keywords_utf16.txt b/sc/workben/celltrans/keywords_utf16.txt
new file mode 100644
index 000000000000..5b00a5ffb7d2
--- /dev/null
+++ b/sc/workben/celltrans/keywords_utf16.txt
Binary files differ
diff --git a/sc/workben/celltrans/parse.py b/sc/workben/celltrans/parse.py
new file mode 100755
index 000000000000..ea1bf3ab6828
--- /dev/null
+++ b/sc/workben/celltrans/parse.py
@@ -0,0 +1,209 @@
+#!/usr/bin/env python
+#***********************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#***********************************************************************
+
+import sys
+
+localeNames = {'fr': 'French', 'hu': 'Hungarian', 'de': 'German'}
+def getLocaleName (code):
+ global localeNames
+ if localeNames.has_key(code):
+ return localeNames[code]
+ else:
+ return "(unknown locale)"
+
+def getAscii (ords):
+ ascii = ''
+ for c in ords:
+ ascii += chr(c)
+ return ascii
+
+class LocaleData(object):
+ def __init__ (self, locale):
+ self.locale = locale
+ self.funcList = {}
+
+ def addKeywordMap (self, funcName, localeName, engName):
+ if not self.funcList.has_key(funcName):
+ self.funcList[funcName] = []
+
+ self.funcList[funcName].append([localeName, engName])
+
+ def getLocaleFuncVarName (self, func, pair):
+ return func.lower() + "_" + getAscii(pair[1]).lower() + "_" + self.locale
+
+ def dumpCode (self):
+ chars = ""
+
+ # locale output
+ chars += "// " + "-"*75 + "\n"
+ chars += "// %s language locale (automatically generated)\n"%getLocaleName(self.locale)
+ chars += "// " + "-"*75 + "\n"
+ chars += "static const Locale a" + self.locale.capitalize() + "(OUString::createFromAscii(\""
+ chars += self.locale
+ chars += "\"), OUString(), OUString());\n\n"
+
+ # pre instantiations of localized function names.
+ funcs = self.funcList.keys()
+ funcs.sort()
+ chars += "// pre instantiations of localized function names\n"
+ for func in funcs:
+ for item in self.funcList[func]:
+ chars += "static const sal_Unicode " + self.getLocaleFuncVarName(func, item) + "[] = {\n"
+ chars += " "
+ isFirst = True
+ # Dump the UTF-16 bytes.
+ for uval in item[0]:
+ if isFirst:
+ isFirst = False
+ else:
+ chars += ", "
+ chars += "0x%.4X"%uval
+
+ # Don't forget to null-terminate the string.
+ if not isFirst:
+ chars += ", "
+ chars += "0x0000"
+
+ chars += "};\n"
+
+ # map item instantiations
+ chars += "\n"
+ chars += "static const TransItem p" + self.locale.capitalize() + "[] = {\n"
+ for func in funcs:
+ for item in self.funcList[func]:
+ chars += " "
+ chars += "{%s, \"%s\", %s},\n"%(self.getLocaleFuncVarName(func, item),
+ getAscii(item[1]),
+ "oc"+func.capitalize())
+
+ chars += " {NULL, NULL, ocNone}\n"
+ chars += "};\n\n"
+
+ # addToMap call
+ chars += "addToMap(%s, %s);\n"%(
+ "p"+self.locale.capitalize(), "a"+self.locale.capitalize())
+
+ return chars
+
+class Parser(object):
+
+ def __init__ (self, args):
+ # default input & output files.
+ self.infile = "./keywords_utf16.txt"
+ self.outfile = "../../source/core/tool/cellkeywords.inl"
+
+ if len(args) >= 2:
+ self.infile = args[1]
+ if len(args) >= 3:
+ self.outfile = args[2]
+
+ def getDByte (self):
+ # Assume little endian.
+ bh = ord(self.bytes[self.i])
+ bl = ord(self.bytes[self.i+1])
+ dbyte = bl*256 + bh
+ self.i += 2
+ return dbyte
+
+ def parseLine (self):
+ buf = []
+ while self.i < self.size:
+ dbyte = self.getDByte()
+ if dbyte == 0x000A:
+ break
+ buf.append(dbyte)
+ return buf
+
+ def dumpBuf (self, buf, linefeed=True):
+ for item in buf:
+ sys.stdout.write(chr(item))
+ if linefeed:
+ print ''
+
+ def parse (self):
+
+ file = open(self.infile, 'r')
+ self.bytes = file.read()
+ file.close()
+
+ self.size = len(self.bytes)
+ self.i = 0
+
+ localeList = [] # stores an array of locale data objects.
+ funcName = None
+ word = []
+ wordPair = []
+
+ while self.i < self.size:
+ dbyte = self.getDByte()
+ if dbyte == 0xFEFF and self.i == 2:
+ # unicode signature - ignore it.
+ pass
+ elif dbyte == 0x0024:
+ # $ - locale name
+ buf = self.parseLine()
+ locale = getAscii(buf)
+ localeList.append(LocaleData(locale))
+
+ elif dbyte == 0x0040:
+ # @ - function name
+ buf = self.parseLine()
+ funcName = getAscii(buf)
+
+ elif dbyte == 0x002C:
+ # , - comma separator
+ if len(word) > 0:
+ wordPair.append(word)
+ word = []
+ elif dbyte == 0x000A:
+ # linefeed
+ if len(word) > 0:
+ wordPair.append(word)
+ word = []
+ if len(wordPair) >= 2:
+ localeList[-1].addKeywordMap(funcName, wordPair[0], wordPair[1])
+ wordPair = []
+ elif dbyte in [0x0009, 0x0020]:
+ # whitespace - ignore it.
+ pass
+ else:
+ word.append(dbyte)
+
+ chars = "// This file has been automatically generated. Do not hand-edit this!\n"
+ for obj in localeList:
+ chars += "\n" + obj.dumpCode()
+
+ # Write to output file.
+ file = open(self.outfile, 'w')
+ file.write(chars)
+ file.close()
+
+if __name__=='__main__':
+ parser = Parser(sys.argv)
+ parser.parse()
+
diff --git a/sc/workben/makefile.mk b/sc/workben/makefile.mk
new file mode 100644
index 000000000000..ba5ebbbba15e
--- /dev/null
+++ b/sc/workben/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=sc
+TARGET=tst
+IDLMAP=map.idl
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.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
+
+SLOFILES= \
+ $(SLO)$/addin.obj \
+ $(SLO)$/result.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/addin.obj \
+ $(SLO)$/result.obj
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS=$(VCLLIB) $(TOOLSLIB) $(SVLLIB) $(TKLIB) $(SALLIB) $(CPPULIB) $(CPPUHELPERLIB)
+
+SHL1DEPN= $(L)$/itools.lib $(SVLIBDEPEND)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1IMPLIB=$(TARGET)
+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) >$@
+.IF "$(COM)"!="GCC"
+ @echo DESCRIPTION 'StarOne Test-DLL' >>$@
+ @echo DATA READ WRITE NONSHARED >>$@
+.ENDIF
+ @echo EXPORTS >>$@
+ @echo component_getImplementationEnvironment @24 >>$@
+ @echo component_writeInfo @25 >>$@
+ @echo component_getFactory @26 >>$@
+.ENDIF
+
diff --git a/sc/workben/map.idl b/sc/workben/map.idl
new file mode 100644
index 000000000000..8c198970dd2c
--- /dev/null
+++ b/sc/workben/map.idl
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#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..c74118ac4882
--- /dev/null
+++ b/sc/workben/result.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+#pragma hdrstop
+#endif
+
+#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 ( sal_uInt16 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();
+
+ sal_uInt16 nCount = aListeners.Count();
+ for ( sal_uInt16 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();
+}
+
+//------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/workben/result.hxx b/sc/workben/result.hxx
new file mode 100644
index 000000000000..b0c31da16e9d
--- /dev/null
+++ b/sc/workben/result.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_RESULT_HXX
+#define SC_RESULT_HXX
+
+#include <svl/svarray.hxx>
+#include <vcl/timer.hxx>
+#include <tools/string.hxx>
+
+
+#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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/workben/test.cxx b/sc/workben/test.cxx
new file mode 100644
index 000000000000..a289fff1b9be
--- /dev/null
+++ b/sc/workben/test.cxx
@@ -0,0 +1,1939 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <tools/debug.hxx>
+#include <svtools/libcall.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/window.hxx>
+#include <vcl/button.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 sal_uInt16 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() );
+ sal_uInt16 nCount = aCollRef->getCount();
+
+ XSpreadsheetDocumentRef xModel; // Calc-Model
+ for (sal_uInt16 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,
+ sal_uInt16 nCol, sal_uInt16 nRow, sal_uInt16 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();
+
+ sal_uInt16 nLen = (sal_uInt16)aSeq.getLen();
+
+ XCellRef xCell = xDoc->getCell(aAdr);
+ if (!xCell) return;
+ xCell->setValue( nLen );
+ ++aAdr.Row;
+
+ UString* pAry = aSeq.getArray();
+ for (sal_uInt16 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"s\xFClz"); // 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((sal_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 (sal_uInt16 nRow = 0; nRow < 20; nRow++)
+ {
+ aPos.Row = nRow;
+ for (sal_uInt16 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)
+ {
+ sal_uLong nStart = Time::GetSystemTicks();
+
+ xAnnotationText->setText(L"bla");
+ xCursor->gotoEnd(false);
+ xCursor->goLeft(1,true);
+ xPos->setText(L"ubb");
+ for (sal_uInt16 i=0; i<10; i++)
+ {
+ xPos->collapseToEnd();
+ xControl->insertControlCharacter( TEXTCONTROLCHAR_PARAGRAPH_BREAK );
+ xPos->collapseToEnd();
+ xPos->setText(L"dumdi");
+ }
+
+ sal_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 )
+ {
+ sal_uInt16 nCount = (sal_uInt16)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;
+ sal_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;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ sal_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((sal_Bool)true));
+ xCol->setPropertyValue(L"NewPage", UsrAny((sal_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"));
+ sal_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((sal_uInt16)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;
+
+ 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;
+ sal_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((sal_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;
+
+ 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;
+
+ sal_Bool bAuto = xFilter->getAutoFilter();
+ xFilter->setAutoFilter(!bAuto);
+}
+
+void lcl_Merge( FixedText& aTimeText )
+{
+ static sal_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 sal_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();
+ sal_uInt16 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 );
+
+ sal_uLong nCount = xNIndex->getCount();
+ for (sal_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;
+ sal_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;
+
+ sal_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");
+ sal_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((sal_Bool)true));
+
+ xPos->setText(L"x");
+
+ xPos->collapseToEnd();
+ xPar->gotoNextParagraph(false,true);
+ xProp->setPropertyValue(L"Italic", UsrAny((sal_Bool)true));
+ xProp->setPropertyValue(L"Underlined", UsrAny((sal_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 s\xFClz");
+ lcl_SetText(xText);
+
+ xProp->setPropertyValue(L"RightPageHeaderContent", aAny);
+}
+
+void lcl_AutoForm( FixedText& aTimeText ) // 29
+{
+ XInterfaceRef xInt = lcl_GetView();
+ if (!xInt) return;
+
+ XTableAutoFormatsRef xFormats;
+
+ XTableAutoFormatRef xFormat = xFormats->getAutoFormatByName(L"gaga");
+ if (!xFormat) return;
+ XPropertySetRef xProp = (XPropertySet*)xFormat->queryInterface(XPropertySet::getSmartUik());
+ if (!xProp) return;
+
+ sal_Bool bVal = TypeConversion::toBOOL(xProp->getPropertyValue(L"IncludeBackground"));
+ xProp->setPropertyValue(L"IncludeBackground", UsrAny(sal_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 (sal_uInt16 i=0; i<16; i++)
+ {
+ XPropertySetRef xNewProp = xNew->getFieldByIndex(i);
+ if (!xNewProp) return;
+
+ xNewProp->setPropertyValue(L"TransparentBackground", UsrAny(sal_Bool(false)));
+ sal_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;
+ sal_uInt16 nCount = (sal_uInt16)xInd->getCount();
+
+ for (sal_uInt16 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;
+ sal_uInt16 nPCount = (sal_uInt16)xPInd->getCount();
+ for (sal_uInt16 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(sal_Bool(false)));
+ xProp->setPropertyValue(L"BackgroundColor", UsrAny((sal_uInt32)0x00FF00));
+ }
+ }
+}
+
+IMPL_LINK(MyWindow, CountHdl, PushButton*, EMPTYARG)
+{
+
+ long nCount = aCountField.GetValue();
+ switch ( nCount )
+ {
+ case 0:
+ {
+ sal_uLong nStart = Time::GetSystemTicks();
+ lcl_DoCount();
+ sal_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;
+ }
+
+ return 0;
+}
+
+//-----------------------------------------------------------------------
+
+IMPL_LINK(MyWindow, TextHdl, PushButton*, EMPTYARG)
+{
+ sal_uInt16 nCol = (sal_uInt16)aColField.GetValue();
+ sal_uInt16 nRow = (sal_uInt16)aRowField.GetValue();
+ sal_uInt16 nPos = (sal_uInt16)aPosField.GetValue();
+ sal_uInt16 nLen = (sal_uInt16)aLenField.GetValue();
+ String aStr = aTextEdit.GetText();
+
+ aTimeText.SetText("...");
+
+ XSpreadsheetDocumentRef xDoc = lcl_GetDocument(); // Calc-Model
+ if (xDoc)
+ {
+ sal_uInt16 nTab = 0;
+ CellAddress aPos;
+ aPos.Sheet = 0;
+ 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 )
+ {
+
+ // letztes Feld loeschen
+ XIndexAccessRef xIndex = (XIndexAccess*)
+ xType->queryInterface(XIndexAccess::getSmartUik());
+ if (xIndex)
+ {
+ String aBla;
+ sal_uLong nCount = xIndex->getCount();
+ for (sal_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)
+ {
+ sal_uInt16 nCount = (sal_uInt16) xIndex->getCount();
+ for (sal_uInt16 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;
+
+ 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));
+ }
+
+ 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;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/workben/testadd.idl b/sc/workben/testadd.idl
new file mode 100644
index 000000000000..c5684820e66a
--- /dev/null
+++ b/sc/workben/testadd.idl
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#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
+