1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifdef _MSC_VER 25cdf0e10cSrcweir #pragma hdrstop 26cdf0e10cSrcweir #endif 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <usr/factoryhlp.hxx> 29cdf0e10cSrcweir #include <usr/macros.hxx> 30cdf0e10cSrcweir #include <usr/reflserv.hxx> 31cdf0e10cSrcweir #include <vos/mutex.hxx> 32cdf0e10cSrcweir #include <vcl/svapp.hxx> 33cdf0e10cSrcweir #include <tools/debug.hxx> 34cdf0e10cSrcweir #include <tools/date.hxx> 35cdf0e10cSrcweir #include <svl/itemprop.hxx> 36cdf0e10cSrcweir #include <usr/proptypehlp.hxx> 37cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 38cdf0e10cSrcweir #include <uno/lbnames.h> 39cdf0e10cSrcweir #include <osl/diagnose.h> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <com/sun/star/util/date.hpp> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include "addin.hxx" 44cdf0e10cSrcweir #include "result.hxx" 45cdf0e10cSrcweir 46cdf0e10cSrcweir using namespace com::sun::star; 47cdf0e10cSrcweir 48cdf0e10cSrcweir //------------------------------------------------------------------------ 49cdf0e10cSrcweir 50cdf0e10cSrcweir 51cdf0e10cSrcweir //------------------------------------------------------------------------ 52cdf0e10cSrcweir 53cdf0e10cSrcweir SMART_UNO_IMPLEMENTATION( ScTestAddIn, UsrObject ); 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define SCADDIN_SERVICE L"com.sun.star.sheet.AddIn" 56cdf0e10cSrcweir #define SCTESTADDIN_SERVICE L"stardiv.one.sheet.DemoAddIn" 57cdf0e10cSrcweir 58cdf0e10cSrcweir //------------------------------------------------------------------------ 59cdf0e10cSrcweir 60cdf0e10cSrcweir extern "C" { 61cdf0e10cSrcweir 62cdf0e10cSrcweir void SAL_CALL component_getImplementationEnvironment( 63cdf0e10cSrcweir const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir sal_Bool SAL_CALL component_writeInfo( 69cdf0e10cSrcweir void * pServiceManager, registry::XRegistryKey * pRegistryKey ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir if (pRegistryKey) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir try 74cdf0e10cSrcweir { 75cdf0e10cSrcweir UString aImpl = L"/"; 76cdf0e10cSrcweir aImpl += ScTestAddIn::getImplementationName_Static(); 77cdf0e10cSrcweir aImpl += L"/UNO/SERVICES"; 78cdf0e10cSrcweir 79cdf0e10cSrcweir uno::Reference<registry::XRegistryKey> xNewKey( 80cdf0e10cSrcweir reinterpret_cast<registry::XRegistryKey*>(pRegistryKey)->createKey(aImpl) ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir uno::Sequence <rtl::OUString> aSequ = ScTestAddIn::getSupportedServiceNames_Static(); 83cdf0e10cSrcweir const rtl::OUString * pArray = aSequ.getConstArray(); 84cdf0e10cSrcweir for( INT32 i = 0; i < aSequ.getLength(); i++ ) 85cdf0e10cSrcweir xNewKey->createKey( pArray[i] ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir return sal_True; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir catch (registry::InvalidRegistryException&) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir OSL_ENSHURE( sal_False, "### InvalidRegistryException!" ); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir } 94cdf0e10cSrcweir return sal_False; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir void * SAL_CALL component_getFactory( 98cdf0e10cSrcweir const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir void* pRet = 0; 101cdf0e10cSrcweir 102cdf0e10cSrcweir if ( pServiceManager && UString(pImplName) == ScTestAddIn::getImplementationName_Static() ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir uno::Reference<lang::XSingleServiceFactory> xFactory( cppu::createOneInstanceFactory( 105cdf0e10cSrcweir reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager), 106cdf0e10cSrcweir ScTestAddIn::getImplementationName_Static(), 107cdf0e10cSrcweir ScTestAddIn_CreateInstance, 108cdf0e10cSrcweir ScTestAddIn::getSupportedServiceNames_Static() ) ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir if (xFactory.is()) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir xFactory->acquire(); 113cdf0e10cSrcweir pRet = xFactory.get(); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir return pRet; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir } // extern C 121cdf0e10cSrcweir 122cdf0e10cSrcweir //------------------------------------------------------------------------ 123cdf0e10cSrcweir 124cdf0e10cSrcweir ScTestAddIn::ScTestAddIn() 125cdf0e10cSrcweir { 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir ScTestAddIn::~ScTestAddIn() 129cdf0e10cSrcweir { 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir UString ScTestAddIn::getImplementationName_Static() 133cdf0e10cSrcweir { 134cdf0e10cSrcweir return L"stardiv.StarCalc.ScTestAddIn"; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > ScTestAddIn::getSupportedServiceNames_Static() 138cdf0e10cSrcweir { 139cdf0e10cSrcweir uno::Sequence< rtl::OUString > aRet(2); 140cdf0e10cSrcweir rtl::OUString* pArray = aRet.getArray(); 141cdf0e10cSrcweir pArray[0] = SCADDIN_SERVICE; 142cdf0e10cSrcweir pArray[1] = SCTESTADDIN_SERVICE; 143cdf0e10cSrcweir return aRet; 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir uno::Reference<uno::XInterface> ScTestAddIn_CreateInstance( 147cdf0e10cSrcweir const uno::Reference<lang::XMultiServiceFactory>& ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir static uno::Reference<uno::XInterface> xInst = (cppu::OWeakObject*)new ScTestAddIn(); 150cdf0e10cSrcweir return xInst; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir 154cdf0e10cSrcweir // XAddIn 155cdf0e10cSrcweir 156cdf0e10cSrcweir UString ScTestAddIn::getProgrammaticFuntionName(const UString& aDisplayName) 157cdf0e10cSrcweir THROWS( (UsrSystemException) ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir //!... 160cdf0e10cSrcweir return UString(); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir UString ScTestAddIn::getDisplayFunctionName(const UString& aProgrammaticName) 164cdf0e10cSrcweir THROWS( (UsrSystemException) ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir // return translated strings 167cdf0e10cSrcweir 168cdf0e10cSrcweir UString aRet; 169cdf0e10cSrcweir if ( aProgrammaticName == L"countParams" ) aRet = L"ParamAnzahl"; 170cdf0e10cSrcweir else if ( aProgrammaticName == L"addOne" ) aRet = L"PlusEins"; 171cdf0e10cSrcweir else if ( aProgrammaticName == L"repeatStr" ) aRet = L"WiederholeString"; 172cdf0e10cSrcweir else if ( aProgrammaticName == L"getDateString" ) aRet = L"Datumsstring"; 173cdf0e10cSrcweir else if ( aProgrammaticName == L"getColorValue" ) aRet = L"Farbwert"; 174cdf0e10cSrcweir else if ( aProgrammaticName == L"transpose" ) aRet = L"Transponieren"; 175cdf0e10cSrcweir else if ( aProgrammaticName == L"transposeInt" ) aRet = L"IntegerTransponieren"; 176cdf0e10cSrcweir else if ( aProgrammaticName == L"repeatMultiple" )aRet = L"Mehrfach"; 177cdf0e10cSrcweir else if ( aProgrammaticName == L"getStrOrVal" ) aRet = L"StringOderWert"; 178cdf0e10cSrcweir else if ( aProgrammaticName == L"callAsync" ) aRet = L"Asynchron"; 179cdf0e10cSrcweir return aRet; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir UString ScTestAddIn::getFunctionDescription(const UString& aProgrammaticName) 183cdf0e10cSrcweir THROWS( (UsrSystemException) ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir // return translated strings 186cdf0e10cSrcweir 187cdf0e10cSrcweir UString aRet; 188cdf0e10cSrcweir if ( aProgrammaticName == L"countParams" ) aRet = L"Gibt die Anzahl der Parameter zurueck."; 189cdf0e10cSrcweir else if ( aProgrammaticName == L"addOne" ) aRet = L"Addiert 1 zur uebergebenen Zahl."; 190cdf0e10cSrcweir else if ( aProgrammaticName == L"repeatStr" ) aRet = L"Wiederholt eine Zeichenkette."; 191cdf0e10cSrcweir else if ( aProgrammaticName == L"getDateString" ) aRet = L"Wandelt ein Datum in eine Zeichenkette."; 192cdf0e10cSrcweir else if ( aProgrammaticName == L"getColorValue" ) aRet = L"Gibt den Farbwert eines Zellbereichs zurueck. Bei transparentem Hintergrund wird -1 zurueckgegeben"; 193cdf0e10cSrcweir else if ( aProgrammaticName == L"transpose" ) aRet = L"Transponiert eine Matrix."; 194cdf0e10cSrcweir else if ( aProgrammaticName == L"transposeInt" ) aRet = L"Transponiert eine Matrix mit Ganzzahlen."; 195cdf0e10cSrcweir else if ( aProgrammaticName == L"repeatMultiple" )aRet = L"Wiederholt mehrere Bestandteile."; 196cdf0e10cSrcweir else if ( aProgrammaticName == L"getStrOrVal" ) aRet = L"Gibt einen String oder einen Wert zurueck."; 197cdf0e10cSrcweir else if ( aProgrammaticName == L"callAsync" ) aRet = L"Test fuer asynchrone Funktion."; 198cdf0e10cSrcweir return aRet; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir UString ScTestAddIn::getDisplayArgumentName(const UString& aProgrammaticFunctionName, 202cdf0e10cSrcweir INT32 nArgument) THROWS( (UsrSystemException) ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir // return translated strings 205cdf0e10cSrcweir 206cdf0e10cSrcweir UString aRet; 207cdf0e10cSrcweir if ( aProgrammaticFunctionName == L"countParams" ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Parameter"; 210cdf0e10cSrcweir } 211cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"addOne" ) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Wert"; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"repeatStr" ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"String"; 218cdf0e10cSrcweir else if ( nArgument == 1 ) aRet = L"Anzahl"; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getDateString" ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Dokument"; 223cdf0e10cSrcweir else if ( nArgument == 1 ) aRet = L"Wert"; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getColorValue" ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Bereich"; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"transpose" ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Matrix"; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"transposeInt" ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Matrix"; 236cdf0e10cSrcweir } 237cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"repeatMultiple" ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Anzahl"; 240cdf0e10cSrcweir else if ( nArgument == 1 ) aRet = L"Trenner"; 241cdf0e10cSrcweir else if ( nArgument == 2 ) aRet = L"Inhalt"; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getStrOrVal" ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Flag"; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"callAsync" ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Name"; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir return aRet; 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir UString ScTestAddIn::getArgumentDescription(const UString& aProgrammaticFunctionName, 255cdf0e10cSrcweir INT32 nArgument) THROWS( (UsrSystemException) ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir // return translated strings 258cdf0e10cSrcweir 259cdf0e10cSrcweir UString aRet; 260cdf0e10cSrcweir if ( aProgrammaticFunctionName == L"countParams" ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Beliebiger Parameter"; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"addOne" ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Der Wert, zu dem 1 addiert wird"; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"repeatStr" ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Der Text, der wiederholt wird"; 271cdf0e10cSrcweir else if ( nArgument == 1 ) aRet = L"Die Anzahl der Wiederholungen"; 272cdf0e10cSrcweir } 273cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getDateString" ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"(intern)"; 276cdf0e10cSrcweir else if ( nArgument == 1 ) aRet = L"Der Wert, der als Datum formatiert wird"; 277cdf0e10cSrcweir } 278cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getColorValue" ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Der Bereich, dessen Hintergrundfarbe abgefragt wird"; 281cdf0e10cSrcweir } 282cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"transpose" ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Die Matrix, die transponiert werden soll"; 285cdf0e10cSrcweir } 286cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"transposeInt" ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Die Matrix, die transponiert werden soll"; 289cdf0e10cSrcweir } 290cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"repeatMultiple" ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Anzahl der Wiederholungen"; 293cdf0e10cSrcweir else if ( nArgument == 1 ) aRet = L"Text, der zwischen den Inhalten erscheint"; 294cdf0e10cSrcweir else if ( nArgument == 2 ) aRet = L"Mehrere Inhalte"; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getStrOrVal" ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Wenn Flag 0 ist, wird ein Wert zurueckgegeben, sonst ein String."; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"callAsync" ) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir if ( nArgument == 0 ) aRet = L"Ein String"; 303cdf0e10cSrcweir } 304cdf0e10cSrcweir return aRet; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir UString ScTestAddIn::getProgrammaticCategoryName(const UString& aProgrammaticFunctionName) 308cdf0e10cSrcweir THROWS( (UsrSystemException) ) 309cdf0e10cSrcweir { 310cdf0e10cSrcweir // return non-translated strings 311cdf0e10cSrcweir 312cdf0e10cSrcweir UString aRet; 313cdf0e10cSrcweir if ( aProgrammaticFunctionName == L"countParams" ) aRet = L"Information"; 314cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"addOne" ) aRet = L"Mathematical"; 315cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"repeatStr" ) aRet = L"Text"; 316cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getDateString" ) aRet = L"Date&Time"; 317cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getColorValue" ) aRet = L"Spreadsheet"; 318cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"transpose" ) aRet = L"Matrix"; 319cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"transposeInt" ) aRet = L"Matrix"; 320cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"repeatMultiple" )aRet = L"Text"; 321cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"getStrOrVal" ) aRet = L"Add-In"; 322cdf0e10cSrcweir else if ( aProgrammaticFunctionName == L"callAsync" ) aRet = L"Realtime"; // new group 323cdf0e10cSrcweir return aRet; 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir UString ScTestAddIn::getDisplayCategoryName(const UString& aProgrammaticFunctionName) 327cdf0e10cSrcweir THROWS( (UsrSystemException) ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir // return translated strings 330cdf0e10cSrcweir 331cdf0e10cSrcweir return L"irgendwas"; // not used for predefined categories 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir // XLocalizable 335cdf0e10cSrcweir 336cdf0e10cSrcweir void ScTestAddIn::setLocale(const lang::Locale& eLocale) THROWS( (UsrSystemException) ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir aFuncLoc = eLocale; 339cdf0e10cSrcweir // DBG_ERROR( UStringToString(aFuncLoc.Language, CHARSET_SYSTEM) + String("-") + 340cdf0e10cSrcweir // UStringToString(aFuncLoc.Country, CHARSET_SYSTEM) ); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir ::com::sun::star::lang::Locale SAL_CALL ScTestAddIn::getLocale( ) throw(::com::sun::star::uno::RuntimeException) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir return aFuncLoc; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir // XTestAddIn 349cdf0e10cSrcweir 350cdf0e10cSrcweir sal_Int32 SAL_CALL ScTestAddIn::countParams( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArgs ) throw(::com::sun::star::uno::RuntimeException) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir return aArgs.getLength(); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir double SAL_CALL ScTestAddIn::addOne( double fValue ) throw(::com::sun::star::uno::RuntimeException) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir return fValue + 1.0; 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScTestAddIn::repeatStr( const ::rtl::OUString& aStr, sal_Int32 nCount ) throw(::com::sun::star::uno::RuntimeException) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir String aRet; 363cdf0e10cSrcweir String aStrStr = OUStringToString( aStr, CHARSET_SYSTEM ); 364cdf0e10cSrcweir for (long i=0; i<nCount; i++) 365cdf0e10cSrcweir aRet += aStrStr; 366cdf0e10cSrcweir 367cdf0e10cSrcweir return StringToOUString( aRet, CHARSET_SYSTEM ); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir ::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) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir uno::Any aDateAny = xCaller->getPropertyValue( L"NullDate" ); 373cdf0e10cSrcweir //! if ( aDateAny.getReflection()->equals( *Date_getReflection() ) ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir util::Date aDate; 376cdf0e10cSrcweir aDateAny >>= aDate; 377cdf0e10cSrcweir //const Date* pDate = (const Date*)aDateAny.get(); 378cdf0e10cSrcweir //if (pDate) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir //Date aNewDate = *pDate; 381cdf0e10cSrcweir Date aNewDate( aDate.Day, aDate.Month, aDate.Year ); 382cdf0e10cSrcweir 383cdf0e10cSrcweir aNewDate += (long)(fValue+0.5); 384cdf0e10cSrcweir 385cdf0e10cSrcweir String aRet; 386cdf0e10cSrcweir aRet += aNewDate.GetDay(); 387cdf0e10cSrcweir aRet += '.'; 388cdf0e10cSrcweir aRet += aNewDate.GetMonth(); 389cdf0e10cSrcweir aRet += '.'; 390cdf0e10cSrcweir aRet += aNewDate.GetYear(); 391cdf0e10cSrcweir return StringToOUString( aRet, CHARSET_SYSTEM ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir return L"**ERROR**"; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir sal_Int32 SAL_CALL ScTestAddIn::getColorValue( const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >& xRange ) throw(::com::sun::star::uno::RuntimeException) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xProp( xRange, uno::UNO_QUERY ); 401cdf0e10cSrcweir if (xProp.is()) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir long nRet = -1; 404cdf0e10cSrcweir uno::Any aTrans = xProp->getPropertyValue( L"IsCellBackgroundTransparent" ); 405cdf0e10cSrcweir BOOL bIsTrans; 406cdf0e10cSrcweir aTrans >>= bIsTrans; //! dont use >>= for BOOL 407cdf0e10cSrcweir if (!bIsTrans) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir uno::Any aCol = xProp->getPropertyValue( L"CellBackColor" ); 410cdf0e10cSrcweir //nRet = NAMESPACE_USR(OPropertyTypeConversion)::toINT32( aCol ); 411cdf0e10cSrcweir aCol >>= nRet; 412cdf0e10cSrcweir } 413cdf0e10cSrcweir return nRet; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir return 0; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir double lcl_GetDoubleElement( const uno::Sequence< uno::Sequence<double> >& aMatrix, long nCol, long nRow ) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir if ( nRow < aMatrix.getLength() ) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir const uno::Sequence<double>& rRowSeq = aMatrix.getConstArray()[nRow]; 423cdf0e10cSrcweir if ( nCol < rRowSeq.getLength() ) 424cdf0e10cSrcweir return rRowSeq.getConstArray()[nCol]; 425cdf0e10cSrcweir } 426cdf0e10cSrcweir return 0.0; // error 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir INT32 lcl_GetLongElement( const uno::Sequence< uno::Sequence<INT32> >& aMatrix, long nCol, long nRow ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir if ( nRow < aMatrix.getLength() ) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir const uno::Sequence<INT32>& rRowSeq = aMatrix.getConstArray()[nRow]; 434cdf0e10cSrcweir if ( nCol < rRowSeq.getLength() ) 435cdf0e10cSrcweir return rRowSeq.getConstArray()[nCol]; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir return 0.0; // error 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir ::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) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir long nRowCount = aMatrix.getLength(); 443cdf0e10cSrcweir long nColCount = 0; 444cdf0e10cSrcweir if ( nRowCount ) 445cdf0e10cSrcweir nColCount = aMatrix.getConstArray()[0].getLength(); 446cdf0e10cSrcweir 447cdf0e10cSrcweir uno::Sequence< uno::Sequence<double> > aRet( nColCount ); 448cdf0e10cSrcweir for (long nCol=0; nCol<nColCount; nCol++) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir uno::Sequence<double> aSubSeq(nRowCount); 451cdf0e10cSrcweir for (long nRow=0; nRow<nRowCount; nRow++) 452cdf0e10cSrcweir aSubSeq.getArray()[nRow] = lcl_GetDoubleElement( aMatrix, nCol, nRow ); 453cdf0e10cSrcweir 454cdf0e10cSrcweir aRet.getArray()[nCol] = aSubSeq; 455cdf0e10cSrcweir } 456cdf0e10cSrcweir 457cdf0e10cSrcweir return aRet; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir ::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) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir long nRowCount = aMatrix.getLength(); 463cdf0e10cSrcweir long nColCount = 0; 464cdf0e10cSrcweir if ( nRowCount ) 465cdf0e10cSrcweir nColCount = aMatrix.getConstArray()[0].getLength(); 466cdf0e10cSrcweir 467cdf0e10cSrcweir uno::Sequence< uno::Sequence<INT32> > aRet( nColCount ); 468cdf0e10cSrcweir for (long nCol=0; nCol<nColCount; nCol++) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir uno::Sequence<INT32> aSubSeq(nRowCount); 471cdf0e10cSrcweir for (long nRow=0; nRow<nRowCount; nRow++) 472cdf0e10cSrcweir aSubSeq.getArray()[nRow] = lcl_GetLongElement( aMatrix, nCol, nRow ); 473cdf0e10cSrcweir 474cdf0e10cSrcweir aRet.getArray()[nCol] = aSubSeq; 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir return aRet; 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir ::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) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir String aSeparator; 483cdf0e10cSrcweir if ( !aFirst.hasValue() ) // not specified 484cdf0e10cSrcweir aSeparator = ';'; 485cdf0e10cSrcweir else 486cdf0e10cSrcweir { 487cdf0e10cSrcweir rtl::OUString aUStr; 488cdf0e10cSrcweir aFirst >>= aUStr; 489cdf0e10cSrcweir aSeparator = OUStringToString( aUStr, CHARSET_SYSTEM ); 490cdf0e10cSrcweir } 491cdf0e10cSrcweir 492cdf0e10cSrcweir String aContent; 493cdf0e10cSrcweir long nContCount = aFollow.getLength(); 494cdf0e10cSrcweir const uno::Any* pArr = aFollow.getConstArray(); 495cdf0e10cSrcweir for (long nPos=0; nPos<nContCount; nPos++) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir if ( nPos > 0 ) 498cdf0e10cSrcweir aContent += ' '; 499cdf0e10cSrcweir rtl::OUString aUStr; 500cdf0e10cSrcweir pArr[nPos] >>= aUStr; 501cdf0e10cSrcweir aContent += OUStringToString( aUStr, CHARSET_SYSTEM ); 502cdf0e10cSrcweir } 503cdf0e10cSrcweir 504cdf0e10cSrcweir String aRet; 505cdf0e10cSrcweir 506cdf0e10cSrcweir for (long i=0; i<nCount; i++) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir if (i>0) 509cdf0e10cSrcweir aRet += aSeparator; 510cdf0e10cSrcweir aRet += aContent; 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir return StringToOUString(aRet, CHARSET_SYSTEM); 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL ScTestAddIn::getStrOrVal( sal_Int32 nFlag ) throw(::com::sun::star::uno::RuntimeException) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir uno::Any aRet; 519cdf0e10cSrcweir 520cdf0e10cSrcweir //! Test 521cdf0e10cSrcweir if ( nFlag == 42 ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir uno::Sequence<rtl::OUString> aInner(3); 524cdf0e10cSrcweir aInner.getArray()[0] = L"Bla"; 525cdf0e10cSrcweir aInner.getArray()[1] = L"Fasel"; 526cdf0e10cSrcweir aInner.getArray()[2] = L"Suelz"; 527cdf0e10cSrcweir uno::Sequence< uno::Sequence<rtl::OUString> > aOuter( &aInner, 1 ); 528cdf0e10cSrcweir 529cdf0e10cSrcweir //return uno::Any( &aOuter, Sequence< Sequence<UString> >::getReflection() ); 530cdf0e10cSrcweir 531cdf0e10cSrcweir aRet <<= aOuter; 532cdf0e10cSrcweir return aRet; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir //! Test 535cdf0e10cSrcweir 536cdf0e10cSrcweir if ( nFlag ) 537cdf0e10cSrcweir aRet <<= UString(L"This is a string."); 538cdf0e10cSrcweir else 539cdf0e10cSrcweir aRet <<= (INT32)42; 540cdf0e10cSrcweir 541cdf0e10cSrcweir return aRet; 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XVolatileResult > SAL_CALL ScTestAddIn::callAsync( const ::rtl::OUString& aString ) throw(::com::sun::star::uno::RuntimeException) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir String aStr = OUStringToString( aString, CHARSET_SYSTEM ); 547cdf0e10cSrcweir char c = (char) aStr; 548cdf0e10cSrcweir if ( c >= '0' && c <= '9' ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir if (!xNumResult.is()) 551cdf0e10cSrcweir xNumResult = new ScAddInResult( "Num" ); 552cdf0e10cSrcweir return xNumResult; 553cdf0e10cSrcweir } 554cdf0e10cSrcweir else 555cdf0e10cSrcweir { 556cdf0e10cSrcweir if (!xAlphaResult.is()) 557cdf0e10cSrcweir xAlphaResult = new ScAddInResult( "Str" ); 558cdf0e10cSrcweir return xAlphaResult; 559cdf0e10cSrcweir } 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir 563cdf0e10cSrcweir // XServiceName 564cdf0e10cSrcweir 565cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScTestAddIn::getServiceName( ) throw(::com::sun::star::uno::RuntimeException) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir return SCTESTADDIN_SERVICE; // name of specific AddIn service 568cdf0e10cSrcweir } 569cdf0e10cSrcweir 570cdf0e10cSrcweir // XServiceInfo 571cdf0e10cSrcweir 572cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScTestAddIn::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir return getImplementationName_Static(); 575cdf0e10cSrcweir } 576cdf0e10cSrcweir 577cdf0e10cSrcweir sal_Bool SAL_CALL ScTestAddIn::supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir return ServiceName == SCADDIN_SERVICE || 580cdf0e10cSrcweir ServiceName == SCTESTADDIN_SERVICE; 581cdf0e10cSrcweir } 582cdf0e10cSrcweir 583cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ScTestAddIn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) 584cdf0e10cSrcweir { 585cdf0e10cSrcweir return getSupportedServiceNames_Static(); 586cdf0e10cSrcweir } 587cdf0e10cSrcweir 588cdf0e10cSrcweir //------------------------------------------------------------------------ 589cdf0e10cSrcweir 590cdf0e10cSrcweir 591cdf0e10cSrcweir 592