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