diff options
Diffstat (limited to 'configmgr/workben')
31 files changed, 0 insertions, 8530 deletions
diff --git a/configmgr/workben/apitest/cfgadduser.cxx b/configmgr/workben/apitest/cfgadduser.cxx deleted file mode 100644 index f75172479efb..000000000000 --- a/configmgr/workben/apitest/cfgadduser.cxx +++ /dev/null @@ -1,355 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include <stdio.h> -#include <string.h> -#include <comphelper/stl_types.hxx> -#include <cppuhelper/extract.hxx> -#include <com/sun/star/uno/Type.hxx> -#include <com/sun/star/uno/TypeClass.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <cppuhelper/servicefactory.hxx> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::container; - -#define ASCII_STRING(rtlOUString) ::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), RTL_TEXTENCODING_ASCII_US).getStr() - -//============================================================================= -void explain(sal_Bool _bVerbose) -{ - cout << "cfgadduser - adding users to a registry server\n"; - cout << "\nusage :\n"; - cout << "cfgadduser [-s <server> -p <port>] [-portal] [-r <registry>] [-a <sysaccount>]"; - cout << " [-h <homedirbase>] [-pwd] <user> [<user>]*\n"; - cout << "\nparameters\n"; - cout << " <server> - machine where the registry server is running\n"; - cout << " <port> - port the registry server is listening at\n"; - cout << " <registry> - registry file to use to instantiate services. Defaulted to\n"; - cout << " applicat.rdb\n"; - cout << " <sysaccount> - system account to use for the newly created user(s)\n"; - cout << " <homedirbase> - home directory base. The concret home dir of a user will\n"; - cout << " be built by appending the the user name to the base dir.\n"; - cout << " <user> - user name to add\n"; - cout << " -portal - specify that the program should connect to a running portal,\n"; - cout << " not directly to the registry server (you need a "; -#ifdef WIN32 - cout << "portal.dll\n"; -#else - cout << "libportal.so\n"; -#endif - cout << " for this)\n"; - cout << " In this case, <server> and <port> specify the location where\n"; - cout << " StarPortal is running\n"; - cout << "\n"; - cout << "If no server is specified, the configuration proxy will try to bootstrap from\n"; - cout << "the initialization file ("; -#ifdef WIN32 - cout << "sregistry.ini"; -#else - cout << "sregistryrc"; -#endif - cout << ")\n\n"; - cout.flush(); -} - -//============================================================================= -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - sal_Char* pPort = NULL; - sal_Char* pServer = NULL; - sal_Char* pRegistry = NULL; - sal_Char* pSysAccount = NULL; - sal_Char* pHomeDirBase = NULL; - sal_Bool bPortal = sal_False; - - ::std::vector< sal_Char* > aUsers; - - // collect some parameters - sal_Char** pArgs = argv + 1; - for (sal_Int32 i=1; i<argc; ++i, ++pArgs) - { - sal_Char* pCurArg = *pArgs; - sal_Int32 nLen = strlen(pCurArg); - sal_Bool bInvalidArg = sal_True; - if (nLen && ('-' == *pCurArg)) - { // it's a switch - sal_Char* pSwitch = pCurArg + 1; - switch (nLen) - { - case 2: - switch (*pSwitch) - { - case '?': - explain(sal_True); - return 1; - case 'h': - pHomeDirBase = *++pArgs; - ++i; - bInvalidArg = sal_False; - break; - case 'a': - pSysAccount = *++pArgs; - ++i; - bInvalidArg = sal_False; - break; - case 'p': - pPort = *++pArgs; - ++i; - bInvalidArg = sal_False; - break; - case 's': - pServer = *++pArgs; - ++i; - bInvalidArg = sal_False; - break; - case 'r': - pRegistry = *++pArgs; - ++i; - bInvalidArg = sal_False; - break; - } - break; - case 7: - if (0 == strncmp(pSwitch, "portal", 6)) - { - bInvalidArg = sal_False; - bPortal = sal_True; - } - break; - } - } - else - { - if ((1 == nLen) && ('?' == *pCurArg)) - { - explain(sal_True); - return 1; - } - else - { - bInvalidArg = sal_False; - aUsers.push_back(pCurArg); - } - } - if (bInvalidArg) - { - explain(sal_False); - return 1; - } - } - - if ((!pServer && pPort) || (!pPort && pServer)) - { - explain(sal_False); - return 1; - } - - if (0 == aUsers.size()) - { - explain(sal_False); - return 1; - } - - // refine some params - ::rtl::OUString sHomeDirBase, sSystemAccountName; - if (pHomeDirBase) - { - sHomeDirBase = ::rtl::OUString::createFromAscii(pHomeDirBase); - if (!sHomeDirBase.getLength() || ('/' != sHomeDirBase.getStr()[sHomeDirBase.getLength() - 1])) - sHomeDirBase += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - } - if (pSysAccount) - sSystemAccountName = ::rtl::OUString::createFromAscii(pSysAccount); - - try - { - ::rtl::OUString const sServiceRegistry = ::rtl::OUString::createFromAscii( pRegistry ? pRegistry : "applicat.rdb" ); - Reference< XMultiServiceFactory > xORB = ::cppu::createRegistryServiceFactory( - sServiceRegistry, - ::rtl::OUString() - ); - if (!xORB.is()) - { - cerr << "Could not create the service factory !\n\n"; - return 1; - } - - // collect the params for the config provider - Sequence< Any > aProviderArgs(3 + (pServer ? 2 : 0)); - aProviderArgs[0] = makeAny(PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("servertype")), - 0, - makeAny(::rtl::OUString::createFromAscii(bPortal ? "portal" : "remote")), - PropertyState_DIRECT_VALUE - )); - aProviderArgs[1] = makeAny(PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), - 0, - makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Administrator"))), - PropertyState_DIRECT_VALUE - )); - aProviderArgs[2] = makeAny(PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password")), - 0, - makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unused"))), - PropertyState_DIRECT_VALUE - )); - if (pServer) - { - aProviderArgs[3] = makeAny(PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("server")), - 0, - makeAny(::rtl::OUString::createFromAscii(pServer)), - PropertyState_DIRECT_VALUE - )); - - sal_Int32 nPort = ::rtl::OUString::createFromAscii(pPort).toInt32(); - aProviderArgs[4] = makeAny(PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("port")), - 0, - makeAny(nPort), - PropertyState_DIRECT_VALUE - )); - } - - Reference< XMultiServiceFactory > xCfgProvider( - xORB->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"), - aProviderArgs), - UNO_QUERY); - if (!xCfgProvider.is()) - { - cerr << "Could not create the configuration provider !\n\n"; - return 3; - } - - Reference< XInterface > xIFace = xCfgProvider->createInstance( - ::rtl::OUString::createFromAscii("com.sun.star.configuration.UserAdministration")); - if (!xIFace.is()) - { - cerr << "Could not create the configuration provider !\n\n"; - return 4; - } - - Reference< XChangesBatch > xUserChanges(xIFace, UNO_QUERY); - Reference< XNameContainer > xUserContainer(xIFace, UNO_QUERY); - Reference< XSingleServiceFactory> xUserFactory(xIFace, UNO_QUERY); - if (!xUserChanges.is() || !xUserContainer.is() || !xUserFactory.is()) - { - cerr << "the user admin access does not provide the necessary interfaces !\n\n"; - return 5; - } - - cout << "going to add the users ..." << endl << endl; - for ( ::std::vector< sal_Char* >::const_iterator aUserLoop = aUsers.begin(); - aUserLoop != aUsers.end(); - ++aUserLoop - ) - { - cout << *aUserLoop << " ... "; - sal_Bool bHadLinebreak = sal_False; - try - { - Reference< XInterface > xNewUser = xUserFactory->createInstance(); - - // the user name as unicode string use more than once) - ::rtl::OUString sUserName = ::rtl::OUString::createFromAscii(*aUserLoop); - - // the XNameContainer access to the Security node in the user profile data - Reference< XNameReplace > xSecurityDataAccess; - Reference< XNameAccess > xUserDataAccess(xNewUser, UNO_QUERY); - if (xUserDataAccess.is()) - { - Any aSecurity = xUserDataAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Security"))); - ::cppu::extractInterface(xSecurityDataAccess, aSecurity); - } - - if (!xSecurityDataAccess.is()) - throw Exception(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The user administration service did not provide a valid user template.")), NULL); - - // set the home directory - if (sHomeDirBase.getLength()) - { - ::rtl::OUString sHomeDir(sHomeDirBase); - sHomeDir += sUserName; - xSecurityDataAccess->replaceByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HomeDirectory")), makeAny(sHomeDir)); - cout << "\n\thome dir : " << ASCII_STRING(sHomeDir) << " ... "; - cout.flush(); - bHadLinebreak = sal_True; - } - - if (sSystemAccountName.getLength()) - { - xSecurityDataAccess->replaceByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemAccount")), makeAny(sSystemAccountName)); - cout << "\n\tsystem account: " << ASCII_STRING(sSystemAccountName) << " ... "; - cout.flush(); - bHadLinebreak = sal_True; - } - - xUserContainer->insertByName(sUserName, makeAny(xNewUser)); - xUserChanges->commitChanges(); - if (bHadLinebreak) - cout << "\n"; - cout << "done.\n"; - cout.flush(); - } - catch(Exception& e) - { - cout << "\n"; - if (!bHadLinebreak) - cout << "\t"; - cerr << "unable to add the user named " << *aUserLoop << endl; - if (!bHadLinebreak) - cout << "\t"; - cerr << "(exception message: " << ::rtl::OString(e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US).getStr() << ")" << endl; - } - cout << "\n"; - } - } - catch(Exception& e) - { - cerr << "Caught exception: " << ASCII_STRING(e.Message) << endl; - return 2; - } - - return 0; -} diff --git a/configmgr/workben/apitest/cfgadmin.cxx b/configmgr/workben/apitest/cfgadmin.cxx deleted file mode 100644 index f9caf7bf4289..000000000000 --- a/configmgr/workben/apitest/cfgadmin.cxx +++ /dev/null @@ -1,517 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#define _PRIVATE_TEST_ - -#include <iostream> -using namespace std; - -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/Type.hxx> -#include <com/sun/star/uno/TypeClass.hpp> -#include <com/sun/star/beans/XHierarchicalPropertySet.hpp> - -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> - - -#include <rtl/ustring.hxx> -#include <rtl/string.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <com/sun/star/uno/Sequence.h> -#include <com/sun/star/uno/Any.h> - -#include "createpropertyvalue.hxx" - -#include "typeconverter.hxx" -#include <osl/time.h> - -// #include <com/sun/star/configuration/XConfigurationSync.hpp> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -//using namespace ::com::sun::star::util; -using namespace ::com::sun::star::util; - -using ::rtl::OUString; -using ::rtl::OString; -//using namespace ::configmgr; - -using namespace ::cppu; - -#define ASCII(x) ::rtl::OUString::createFromAscii(x) - -ostream& operator << (ostream& out, rtl::OUString const& aStr) -{ - sal_Unicode const* const pStr = aStr.getStr(); - sal_Unicode const* const pEnd = pStr + aStr.getLength(); - for (sal_Unicode const* p = pStr; p < pEnd; ++p) - if (0 < *p && *p < 127) // ASCII - out << char(*p); - else - out << "[\\u" << hex << *p << "]"; - return out; -} - -void showSequence(const Sequence<OUString> &aSeq) -{ - OUString aArray; - const OUString *pStr = aSeq.getConstArray(); - for (int i=0;i<aSeq.getLength();i++) - { - OUString aStr = pStr[i]; - // aArray += aStr + ASCII(", "); - cout << aStr << endl; - } - volatile int dummy = 0; -} - -//============================================================================= -//============================================================================= -void test_read_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF); -//============================================================================= -struct prompt_and_wait -{ - char const* myText; - prompt_and_wait(char const* text = "") : myText(text) {} - ~prompt_and_wait() - { - cout << myText << ">" << endl; - int const mx = int( (+0u - +1u) >> 1); - - char c=0; - if (cin.get(c) && c != '\n') - cin.ignore(mx,'\n'); - } -}; -static prompt_and_wait exit_prompt("Quitting\nQ"); - - -// ----------------------------------------------------------------------------- -Sequence<Any> createSequence(const OUString &sUser, const OUString &sPasswd) -{ - Sequence< Any > aCPArgs; - - if (sUser.getLength() > 0) - { - aCPArgs.realloc(1); - aCPArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser); - } - if (sPasswd.getLength() > 0) - { - aCPArgs.realloc(2); - aCPArgs[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd); - } - return aCPArgs; -} - -//============================================================================= -#include <string.h> -#if (defined UNX) || (defined OS2) -#else -#include <conio.h> -#endif - -OString input(const char* pDefaultText, char cEcho) -{ - // PRE: a Default Text would be shown, cEcho is a Value which will show if a key is pressed. - const int MAX_INPUT_LEN = 500; - char aBuffer[MAX_INPUT_LEN]; - - strcpy(aBuffer, pDefaultText); - int nLen = strlen(aBuffer); - -#ifdef WNT - char ch = '\0'; - - cout << aBuffer; - cout.flush(); - - while(ch != 13) - { - ch = getch(); - if (ch == 8) - { - if (nLen > 0) - { - cout << "\b \b"; - cout.flush(); - --nLen; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - else if (ch != 13) - { - if (nLen < MAX_INPUT_LEN) - { - if (cEcho == 0) - { - cout << ch; - } - else - { - cout << cEcho; - } - cout.flush(); - aBuffer[nLen++] = ch; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - } -#else - if (!cin.getline(aBuffer,sizeof aBuffer)) - return OString(); -#endif - return OString(aBuffer); -} - -// ----------------------------------------------------------------------------- -rtl::OUString enterValue(const char* _aStr, const char* _aDefault, bool _bIsAPassword) -{ - cout << _aStr; - cout.flush(); - OString aTxt = input(_aDefault, _bIsAPassword ? '*' : 0); - - OUString sValue = OUString::createFromAscii(aTxt); - return sValue; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -void write(Reference<XNameAccess >& xAccess) -{ - if (xAccess.is()) - { - Sequence<OUString> aNames( xAccess->getElementNames() ); - - cout << "Element Names: (" << aNames.getLength() << ")"; - for (int i = 0; i < aNames.getLength(); ++i) - cout << "\n[" << i << "] -\t" << aNames[i]; - cout << endl; - } - else - cout << "BUG: XNameAccess not available"; - cout << endl; -} -// ----------------------------------------------------------------------------- -void write(Reference< XChild >& xChild) -{ - if (xChild.is()) - cout << "\n[ P ] -\tParent"; - else - cout << "BUG: Parent not available (no XChild)"; - cout << endl; -} - -// ----------------------------------------------------------------------------- -void displayTree(Reference< XNameAccess > xIFace){ - - write(Reference< XNameAccess >(xIFace)); -} - - -// ----------------------------------------------------------------------------- -void displayGroups(Reference< XNameAccess > xGroupAccess) -{ - - cout << "Currently available groups !\n---------------------------------------------------------------" << endl; - write(xGroupAccess); -} - -// ----------------------------------------------------------------------------- -OUString insertGroup(Reference< XNameAccess > xGroupAccess) -{ - OUString sGroup = enterValue(" Enter a new group to create: ", "", true); - - Reference< XSingleServiceFactory > xFactory(xGroupAccess, UNO_QUERY); - Reference< XNameAccess > xNewGroup(xFactory->createInstance(), UNO_QUERY); - - cout << "Group data: !\n---------------------------------------------------------------" << endl; - write(xNewGroup); - Any aGroup; - aGroup <<= xNewGroup; - Reference< XNameContainer >(xGroupAccess, UNO_QUERY)->insertByName(sGroup, aGroup); - return sGroup; -} - -// ----------------------------------------------------------------------------- -void deleteGroup(Reference< XNameAccess > xGroupAccess, OUString sGroup) -{ - if (!sGroup.getLength()) - sGroup = enterValue(" Enter a group to delete: ", "", true); - cout << "deleting group !\n---------------------------------------------------------------" << endl; - Reference< XNameContainer >(xGroupAccess, UNO_QUERY)->removeByName(sGroup); -} - -// ----------------------------------------------------------------------------- -void displayUsers(Reference< XNameAccess > xUserAccess) -{ - cout << "Currently available users !\n---------------------------------------------------------------" << endl; - write(xUserAccess); -} - -// ----------------------------------------------------------------------------- -OUString insertUser(Reference< XNameAccess > xUserAccess, OUString aGroup) -{ - OUString sUser = enterValue(" Enter a new User to create: ", "", true); - Reference< XSingleServiceFactory > xFactory(xUserAccess, UNO_QUERY); - - Sequence< Any > aArgs(1); - aArgs[0] <<= configmgr::createPropertyValue(ASCII("group"), aGroup); - Reference< XNameAccess > xNewUser(xFactory->createInstanceWithArguments(aArgs), UNO_QUERY); - - cout << "User data: !\n---------------------------------------------------------------" << endl; - write(xNewUser); - - Any aValue; - aValue <<= ASCII("MyCompany"); - - // now do some updates for the user - Reference< XHierarchicalPropertySet > xUpdate(xNewUser, UNO_QUERY); - xUpdate->setHierarchicalPropertyValue(ASCII("Data/Company"),aValue); - - Any aUser; - aUser <<= xNewUser; - Reference< XNameContainer >(xUserAccess, UNO_QUERY)->insertByName(sUser, aUser); - - return sUser; -} - -// ----------------------------------------------------------------------------- -void deleteUser(Reference< XNameAccess > xUserAccess, OUString sUser) -{ - if (!sUser.getLength()) - sUser = enterValue(" Enter a User to delete: ", "", true); - cout << "deleting User !\n---------------------------------------------------------------" << endl; - Reference< XNameContainer >(xUserAccess, UNO_QUERY)->removeByName(sUser); -} - -// ----------------------------------------------------------------------------- -Reference< XNameAccess > beginChanges(Reference< XMultiServiceFactory > xFactory, OUString sPath, OUString& sUser) -{ - if (!sUser.getLength()) - sUser = enterValue(" Enter a User: ", "", true); - - Sequence< Any > aArgs(2); - aArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser); - aArgs[1] <<= configmgr::createPropertyValue(ASCII("nodepath"),sPath); - - cout << "starting update for node:" << sPath << endl; - - Reference< XNameAccess > xTree(xFactory->createInstanceWithArguments(OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), - aArgs), UNO_QUERY); - - return xTree; -} - -template <class Type> -// ----------------------------------------------------------------------------- -void update(Reference< XInterface > xIFace, OUString sRelPath, Type sValue) -{ - Reference< XHierarchicalPropertySet > xTree(xIFace, UNO_QUERY); - Any aValue; - aValue <<= sValue; - - cout << "updating node:" << sRelPath << endl; - xTree->setHierarchicalPropertyValue(sRelPath, aValue); -} - -// ----------------------------------------------------------------------------- -Reference< XHierarchicalPropertySet > insertTree(Reference< XInterface > xIFace, OUString aName) -{ - if (!aName.getLength()) - aName = enterValue("/nEnter a Tree to insert: ", "", false); - - Reference< XSingleServiceFactory > xFactory(xIFace, UNO_QUERY); - Reference< XHierarchicalPropertySet > xNewElement(xFactory->createInstance(), UNO_QUERY); - - cout << "inserting new tree element:" << aName << endl; - - Any aTree; - aTree <<= xNewElement; - Reference< XNameContainer >(xFactory, UNO_QUERY)->insertByName(aName, aTree); - - return xNewElement; -} - -// ----------------------------------------------------------------------------- -void removeTree(Reference< XInterface > xIFace, OUString aName) -{ - if (!aName.getLength()) - aName = enterValue("/nEnter a Tree to remove: ", "", false); - - cout << "removing new tree element:" << aName << endl; - - Reference< XNameContainer >(xIFace, UNO_QUERY)->removeByName(aName); -} - -// ----------------------------------------------------------------------------- -void commitChanges(Reference< XInterface > xIFace) -{ - cout << "committing changes:" << endl; - - Reference< XChangesBatch > xChangesBatch(xIFace, UNO_QUERY); - xChangesBatch->commitChanges(); -} - -// ----------------------------------------------------------------------------- -// ---------------------------------- M A I N ---------------------------------- -// ----------------------------------------------------------------------------- - -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - // cout << " Please insert Text: "; - // cout.flush(); - // OString aTxt = input("Der Text", 0); - // cout << endl << "You inserted: " << aTxt.getStr() << endl; - // - // cout << "Please insert Password: "; - // cout.flush(); - // OString aPasswd = input("", '*'); - // cout << endl << "You inserted: " << aPasswd.getStr() << endl; - - try - { - OUString const sServiceRegistry = OUString::createFromAscii( argc > 1 ? argv[1] : "applicat.rdb" ); - Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory( - sServiceRegistry, - ::rtl::OUString() - ); - if (!xORB.is()) - { - ::flush(cout); - cerr << "Could not create the service factory !\n\n"; - return 1; - } - cout << "Service factory created !\n---------------------------------------------------------------" << endl; - - Sequence< Any > aCPArgs = createSequence(OUString::createFromAscii("Administrator"), OUString()); - - Reference< XMultiServiceFactory > xCfgProvider( - xORB->createInstanceWithArguments( - ::rtl::OUString::createFromAscii("com.sun.star.configuration.AdministrationProvider"), - aCPArgs), - UNO_QUERY); - - if (!xCfgProvider.is()) - { - ::flush(cout); - cerr << "Could not create the configuration provider !\n\n"; - return 3; - } - - cout << "Configuration Provider created !\n---------------------------------------------------------------" << endl; - - Reference< XNameAccess > xUpdateAccess; - Reference< XNameAccess > xGroupAccess(xCfgProvider->createInstance(OUString::createFromAscii("com.sun.star.configuration.GroupAccess")),UNO_QUERY); - Reference< XNameAccess > xUserAccess(xCfgProvider->createInstance(OUString::createFromAscii("com.sun.star.configuration.UserAccess")),UNO_QUERY); - - displayGroups(xGroupAccess); - displayUsers(xUserAccess); - -// create a group - OUString sGroupName = insertGroup(xGroupAccess); -// create a user - OUString sUserName; - sUserName = insertUser(xUserAccess, sGroupName); - -// now do updates for the user - xUpdateAccess = beginChanges(xCfgProvider, OUString::createFromAscii("org.openoffice.Inet"), sUserName); - - update(xUpdateAccess, OUString::createFromAscii("Proxy/FTP/Port"), sal_Int32(12)); - update(xUpdateAccess, OUString::createFromAscii("Proxy/FTP/Name"), OUString::createFromAscii("demo")); - update(xUpdateAccess, OUString::createFromAscii("DNS/IP_Address"), OUString::createFromAscii("demo1")); - - xUpdateAccess = beginChanges(xCfgProvider, OUString::createFromAscii("org.openoffice.Office.Common"), sUserName); - update(xUpdateAccess, OUString::createFromAscii("_3D_Engine/Dithering"), sal_Bool(sal_False)); - commitChanges(xUpdateAccess); - -// now do updates with inserting and removing of nodes - - xUpdateAccess = beginChanges(xCfgProvider, OUString::createFromAscii("org.openoffice.Security/MountPoints"), sUserName); - displayTree(xUpdateAccess); - - Reference< XHierarchicalPropertySet > xTree = insertTree(xUpdateAccess, OUString()); - update(xUpdateAccess, OUString::createFromAscii("InstallationDirectory/Directory"), OUString::createFromAscii("Test1")); - removeTree(xUpdateAccess, OUString()); - commitChanges(xUpdateAccess); - - -/* deleteUser(xUserAccess, sUserName); - deleteGroup(xGroupAccess, sGroupName); */ - - displayGroups(xGroupAccess); - displayUsers(xUserAccess); - } - catch (Exception& e) - { - ::flush(cout); - cerr << "Caught exception: " << e.Message << endl; - return 1; - } -/* - catch (...) - { - flush(cout); - cerr << "BUG: Caught UNKNOWN exception (?) " << endl; - } -*/ - return 0; -} - - - - diff --git a/configmgr/workben/apitest/cfgapi.cxx b/configmgr/workben/apitest/cfgapi.cxx deleted file mode 100644 index 29399896e978..000000000000 --- a/configmgr/workben/apitest/cfgapi.cxx +++ /dev/null @@ -1,865 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#define _PRIVATE_TEST_ - -#include <iostream> -using namespace std; - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/Type.hxx> -#include <com/sun/star/uno/TypeClass.hpp> - -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> - - -#include <rtl/ustring.hxx> -#include <rtl/string.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <com/sun/star/uno/Sequence.h> -#include <com/sun/star/uno/Any.h> -#include <osl/profile.hxx> -#include <osl/process.h> -#include <osl/file.h> - -#include "createpropertyvalue.hxx" - -#include "typeconverter.hxx" - -// #include <com/sun/star/configuration/XConfigurationSync.hpp> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -//using namespace ::com::sun::star::util; -using namespace ::com::sun::star::util; - -using ::rtl::OUString; -using ::rtl::OString; -//using namespace ::configmgr; - -using namespace ::cppu; - -#define ASCII(x) ::rtl::OUString::createFromAscii(x) - -ostream& operator << (ostream& out, rtl::OUString const& aStr) -{ - sal_Unicode const* const pStr = aStr.getStr(); - sal_Unicode const* const pEnd = pStr + aStr.getLength(); - for (sal_Unicode const* p = pStr; p < pEnd; ++p) - if (0 < *p && *p < 127) // ASCII - out << char(*p); - else - out << "[\\u" << hex << *p << "]"; - return out; -} - -void showSequence(const Sequence<OUString> &aSeq) -{ - OUString aArray; - const OUString *pStr = aSeq.getConstArray(); - for (int i=0;i<aSeq.getLength();i++) - { - OUString aStr = pStr[i]; - // aArray += aStr + ASCII(", "); - cout << aStr << endl; - } - volatile int dummy = 0; -} - -//============================================================================= - -inline void operator <<= (::rtl::OUString& _rUnicodeString, const sal_Char* _pAsciiString) -{ - _rUnicodeString = ::rtl::OUString::createFromAscii(_pAsciiString); -} - -inline void operator <<= (::rtl::OUString& _rUnicodeString, const ::rtl::OString& _rAsciiString) -{ - _rUnicodeString <<= _rAsciiString.getStr(); -} - -inline void operator <<= (Any& _rUnoValue, const sal_Char* _pAsciiString) -{ - _rUnoValue <<= ::rtl::OUString::createFromAscii(_pAsciiString); -} - -inline void operator <<= (Any& _rUnoValue, const ::rtl::OString& _rAsciiString) -{ - _rUnoValue <<= _rAsciiString.getStr(); -} - -//============================================================================= -void test_read_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF); -//============================================================================= -struct prompt_and_wait -{ - char const* myText; - prompt_and_wait(char const* text = "") : myText(text) {} - ~prompt_and_wait() - { - cout << myText << ">" << endl; - int const mx = int( (+0u - +1u) >> 1); - - char c=0; - if (cin.get(c) && c != '\n') - cin.ignore(mx,'\n'); - } -}; -static prompt_and_wait exit_prompt("Quitting\nQ"); - - -Reference< XChangesBatch > xChangesBatch = NULL; -void commit() -{ - if (xChangesBatch.is()) - { - xChangesBatch->commitChanges(); - } -} - -// ----------------------------------------------------------------------------- -static sal_Bool s_bInitialized = sal_False; -#ifdef LLA_PRIVAT_DEBUG -static const sal_Char* s_pSourcePath = "l:/src625/configmgr/workben/local_io/share"; -static const sal_Char* s_pUpdatePath = "l:/src625/configmgr/workben/local_io/user"; -static const sal_Char* s_pRootNode = "org.openoffice.ucb.Hierarchy"; // "org.openoffice.test"; -static const sal_Char* s_pServerType = "local"; -static const sal_Char* s_pLocale = "de-DE"; -static const sal_Char* s_pServer = ""; -static const sal_Char* s_pUser = ""; -static const sal_Char* s_pPassword = ""; -#else -static const sal_Char* s_pSourcePath = "g:/src/configmgr/workben/local_io/share"; -static const sal_Char* s_pUpdatePath = "g:/src/configmgr/workben/local_io/user"; -static const sal_Char* s_pRootNode = "org.openoffice.Office.TypeDetection"; -static const sal_Char* s_pServerType = "setup"; -static const sal_Char* s_pLocale = "de-DE"; -static const sal_Char* s_pServer = "lautrec-3108:19205"; -static const sal_Char* s_pUser = "lars"; -static const sal_Char* s_pPassword = ""; -#endif - - -// ----------------------------------------------------------------------------- -static void loadDefaults() -{ - if (s_bInitialized) - return; - - s_bInitialized = sal_True; - - try - { - // the executable file name - ::rtl::OUString sExecutable; - osl_getExecutableFile(&sExecutable.pData); - // cut the name, add a cfgapi.ini to the path - sal_Int32 nLastSep = sExecutable.lastIndexOf('/'); - if (-1 != nLastSep) - sExecutable = sExecutable.copy(0, nLastSep + 1); -#ifdef UNX - sExecutable += ::rtl::OUString::createFromAscii("cfgapirc"); -#else - sExecutable += ::rtl::OUString::createFromAscii("cfgapi.ini"); -#endif - ::rtl::OUString sNormalized; - sNormalized = sExecutable; - if (1) - { - ::osl::Profile aProfile(sNormalized); - - static ::rtl::OString sSection("defaults"); - static ::rtl::OString sSourcePath("sourcepath"); - static ::rtl::OString sUpdatePath("updatepath"); - static ::rtl::OString sRootNode("rootnode"); - static ::rtl::OString sServerType("servertype"); - static ::rtl::OString sLocale("Locale"); - static ::rtl::OString sServer("Server"); - static ::rtl::OString sUser("User"); - static ::rtl::OString sPassword("Password"); - - // read some strings. - // Do this static because we want to redirect the global static character pointers to the buffers. - static ::rtl::OString s_sSourcePath = aProfile.readString(sSection, sSourcePath, s_pSourcePath); - static ::rtl::OString s_sUpdatePath = aProfile.readString(sSection, sUpdatePath, s_pUpdatePath); - static ::rtl::OString s_sRootNode = aProfile.readString(sSection, sRootNode, s_pRootNode); - static ::rtl::OString s_sServerType = aProfile.readString(sSection, sServerType, s_pServerType); - static ::rtl::OString s_sLocale = aProfile.readString(sSection, sLocale, s_pLocale); - static ::rtl::OString s_sServer = aProfile.readString(sSection, sServer, s_pServer); - static ::rtl::OString s_sUser = aProfile.readString(sSection, sUser, s_pUser); - static ::rtl::OString s_sPassword = aProfile.readString(sSection, sPassword, s_pPassword); - - // do this redirection - s_pSourcePath = s_sSourcePath.getStr(); - s_pUpdatePath = s_sUpdatePath.getStr(); - s_pRootNode = s_sRootNode.getStr(); - s_pServerType = s_sServerType.getStr(); - s_pLocale = s_sLocale.getStr(); - s_pServer = s_sServer.getStr(); - s_pUser = s_sUser.getStr(); - s_pPassword = s_sPassword.getStr(); - } - } - catch(std::exception& e) - { - e.what(); // silence warnings - } -} - -// ----------------------------------------------------------------------------- -Sequence<Any> createSequence(const OUString &sUser, const OUString &sPasswd) -{ - Sequence< Any > aCPArgs; - - if (sUser.getLength() > 0) - { - aCPArgs.realloc(1); - aCPArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser); - } - if (sPasswd.getLength() > 0) - { - aCPArgs.realloc(2); - aCPArgs[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd); - } - return aCPArgs; -} - -//============================================================================= -#include <string.h> -#if (defined UNX) || (defined OS2) -#else -#include <conio.h> -#endif - -OString input(const char* pDefaultText, char cEcho) -{ - // PRE: a Default Text would be shown, cEcho is a Value which will show if a key is pressed. - const int MAX_INPUT_LEN = 500; - char aBuffer[MAX_INPUT_LEN]; - - strcpy(aBuffer, pDefaultText); - int nLen = strlen(aBuffer); - -#ifdef WNT - char ch = '\0'; - - cout << aBuffer; - cout.flush(); - - while(ch != 13) - { - ch = getch(); - if (ch == 8) - { - if (nLen > 0) - { - cout << "\b \b"; - cout.flush(); - --nLen; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - else if (ch != 13) - { - if (nLen < MAX_INPUT_LEN) - { - if (cEcho == 0) - { - cout << ch; - } - else - { - cout << cEcho; - } - cout.flush(); - aBuffer[nLen++] = ch; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - } -#else - if (!cin.getline(aBuffer,sizeof aBuffer)) - return OString(); -#endif - return OString(aBuffer); -} - -// ----------------------------------------------------------------------------- -rtl::OUString enterValue(const char* _aStr, const char* _aDefault, bool _bIsAPassword) -{ - cout << _aStr; - cout.flush(); - - OUString sValue; - sValue <<= input(_aDefault, _bIsAPassword ? '*' : 0); - return sValue; -} - - - -// ----------------------------------------------------------------------------- -// ---------------------------------- M A I N ---------------------------------- -// ----------------------------------------------------------------------------- - -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - // cout << " Please insert Text: "; - // cout.flush(); - // OString aTxt = input("Der Text", 0); - // cout << endl << "You inserted: " << aTxt.getStr() << endl; - // - // cout << "Please insert Password: "; - // cout.flush(); - // OString aPasswd = input("", '*'); - // cout << endl << "You inserted: " << aPasswd.getStr() << endl; - - loadDefaults(); - - try - { - OUString const sServiceRegistry = OUString::createFromAscii( argc > 1 ? argv[1] : "applicat.rdb" ); - Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory( - sServiceRegistry, - ::rtl::OUString() - ); - if (!xORB.is()) - { - ::flush(cout); - cerr << "Could not create the service factory !\n\n"; - return 1; - } - cout << "Service factory created !\n---------------------------------------------------------------" << endl; - - Sequence< Any > aCPArgs; - - OUString sServerType = enterValue("servertype: ", s_pServerType, false); - cout << endl; - - - rtl::OUString sUser; - - bool bLocal = sServerType.equalsIgnoreAsciiCase(ASCII("local")) || sServerType.equalsIgnoreAsciiCase(ASCII("setup")); - if (!bLocal) - { - rtl::OUString sServer; - sServer = enterValue("server : ", s_pServer,false); - cout << endl; - - sUser = enterValue("user : ", s_pUser, false); - cout << endl; - - OUString sPasswd = enterValue("password: ", s_pPassword, true); - cout << endl; - - aCPArgs = createSequence(sUser, sPasswd); - - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("server"), sServer); - - OUString sTimeout = ASCII("10000"); - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("timeout"), sTimeout); - - } - else - { - rtl::OUString sSharePath, sUserPath; - sSharePath = enterValue("share path: ", s_pSourcePath, false); - cout << endl; - sUserPath = enterValue("user path : ", s_pUpdatePath, false); - cout << endl; - - aCPArgs.realloc(aCPArgs.getLength() + 1); - sal_Int32 nCount = aCPArgs.getLength() - 1; - Any *pAny = &aCPArgs[nCount]; - *pAny <<= configmgr::createPropertyValue(ASCII("sourcepath"), sSharePath); - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("updatepath"), sUserPath); - } - - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("servertype"), sServerType); - - Reference< XMultiServiceFactory > xCfgProvider( - xORB->createInstanceWithArguments( - ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"), - aCPArgs), - UNO_QUERY); - if (!xCfgProvider.is()) - { - ::flush(cout); - cerr << "Could not create the configuration provider !\n\n"; - return 3; - } - - - - - char aPath[300] = "/"; - int nStart = sizeof( "/" ) - 1; - - cout << "---------------------------------------------------------------\n Configuration Provider created !\n---------------------------------------------------------------" << endl; - - Sequence< Any > aArgs; - aArgs = createSequence(sUser, ASCII("")); - - OUString sPath = enterValue("nodepath: ", s_pRootNode, false); - cout << endl; - - aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("nodepath"), sPath); - - if (!bLocal) - { - OUString sLocale = enterValue("locale : ", s_pLocale, false); - cout << endl; - aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("locale"), sLocale); - } -/* -#else - OUString aStr = ASCII("String"); - sal_Int32 nDepth = 10; - Sequence< Any > aArgs(2); - - aArgs[0] <<= aStr; - aArgs[1] <<= nDepth; -#endif -*/ - Reference< XInterface > xIFace = xCfgProvider->createInstanceWithArguments( - OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), - aArgs); - cout << "---------------------------------------------------------------\n Configuration Read/Write Access created !\n---------------------------------------------------------------" << endl; - - xChangesBatch = Reference< XChangesBatch >(xIFace, UNO_QUERY); - - Sequence<OUString> aSeq = xCfgProvider->getAvailableServiceNames(); - showSequence(aSeq); - - test_read_access(xIFace, xCfgProvider); - } - catch (Exception& e) - { - ::flush(cout); - cerr << "Caught exception: " << e.Message << endl; - } -/* - catch (...) - { - flush(cout); - cerr << "BUG: Caught UNKNOWN exception (?) " << endl; - } -*/ - return 0; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -void test(Reference< XHierarchicalName >& xAccessName) -{ - if (xAccessName.is()) - cout << "Accessing Node: " << xAccessName->getHierarchicalName(); - else - cout << "BUG: XHierarchicalName not available"; - cout << endl; -} -void test(Reference< XNamed >& xAccess) -{ - if (xAccess.is()) - cout << "Node is named: " << xAccess->getName(); - else - cout << "BUG: XNamed not available"; - cout << endl; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -void write(Reference<XNameAccess >& xAccess) -{ - if (xAccess.is()) - { - Sequence<OUString> aNames( xAccess->getElementNames() ); - - cout << "Element Names: (" << aNames.getLength() << ")"; - for (int i = 0; i < aNames.getLength(); ++i) - cout << "\n[" << i << "] -\t" << aNames[i]; - cout << endl; - } - else - cout << "BUG: XNameAccess not available"; - cout << endl; -} -void write(Reference< XChild >& xChild) -{ - if (xChild.is()) - cout << "\n[ P ] -\tParent"; - else - cout << "BUG: Parent not available (no XChild)"; - cout << endl; -} -/////////////////////////////////////////////////////////////////////////////////////////// - -bool ask(Reference< XInterface >& xIface, Reference<XMultiServiceFactory> &); - -void test_read_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF) -{ - using com::sun::star::uno::UNO_QUERY; - do - { - cout << "\n\n---------------------------------------------------------------" << endl; - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - Reference< XChild > xChild(xIface, UNO_QUERY); - Reference< XHierarchicalName > xAccessPath(xIface,UNO_QUERY); - Reference< XNamed > xAccessName(xIface,UNO_QUERY); -// Reference< XHierarchicalNameAccess >& xAccess(xIface, UNO_QUERY); - - test(xAccessPath); - test(xAccessName); - write(xAccess); - write(xChild); - } - while (ask(xIface, xMSF)); -} - -bool ask(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF) -{ - cout << "\n[ Q ] -> <Quit>"; - cout << "\n[ S ] -> <SetValue> "; - cout << endl; - - cout << "\n:> " << flush; - char buf[200] = {0}; - try - { - bool bHandled = false; - bool bInserted = false; - - if (cin.getline(buf,sizeof buf)) - { - Reference< XInterface > xNext; - if ((buf[0] == 'q' || buf[0] == 'Q') && (0 == buf[1])) - { - return false; - } - else if (buf[0] == 0) - { - return true; - } - else if((buf[0] == 0 || buf[0] == 'o' || buf[0] == 'O') && (0 == buf[1])) - { -/* - cout << "work Offline" << endl; - Reference<com::sun::star::configuration::XConfigurationSync> xSync(xMSF, UNO_QUERY); - - Sequence< Any > aArgs2(5); - sal_Int32 n=0; - aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Setup")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Common")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Java")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Writer")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.ucb.Hierarchy")); - xSync->offline(aArgs2); - bHandled = true; -*/ - } - else if((buf[0] == 0 || buf[0] == 's' || buf[0] == 'S') && (0 == buf[1])) - { - // Replace a Value - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - - cout << "SetMode, insert a Number" << endl; - cin.getline(buf,sizeof buf); - bInserted = true; - } - - else if ((buf[0] == 'p' || buf[0] == 'P') && (0 == buf[1])) - { - Reference< XChild > xChild(xIface, UNO_QUERY); - if (xChild.is()) - xNext = xChild->getParent(); - bHandled = true; - } - - if (bHandled == false) - { - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - Reference< XHierarchicalNameAccess > xDeepAccess(xIface, UNO_QUERY); - Reference< XExactName > xExactName(xIface, UNO_QUERY); - - if (xAccess.is() || xDeepAccess.is()) - { - OUString aName; - OUString aInput = OUString::createFromAscii(buf); - - if (xExactName.is()) - { - ::rtl::OUString sTemp = xExactName->getExactName(aInput); - if (sTemp.getLength()) - aInput = sTemp; - } - - if (xAccess.is() && xAccess->hasByName(aInput)) - { - aName = aInput; - } - else if (xDeepAccess.is() && xDeepAccess->hasByHierarchicalName(aInput)) - { - aName = aInput; - } - else if ('0' <= buf[0] && buf[0] <= '9' && xAccess.is()) - { - unsigned int n = unsigned(atoi(buf)); - Sequence<OUString> aNames = xAccess->getElementNames(); - if (n < aNames.getLength()) - aName = aNames[n]; - } - - if (aName.getLength()) - { - bool bNest = aInput.indexOf(sal_Unicode('/')) >= 0; - - Any aElement = bNest ? ( xDeepAccess.is() ? xDeepAccess->getByHierarchicalName(aName) : Any()) - : ( xAccess. is() ? xAccess-> getByName(aName) : Any() ); - - while (aElement.getValueTypeClass() == TypeClass_ANY) - { - Any aWrap(aElement); - aWrap >>= aElement; - } - sal_Bool bValue = true; - sal_Bool bValueOk = false; - - switch (aElement.getValueTypeClass() ) - { - case TypeClass_INTERFACE: bValue = false; break; - case TypeClass_BOOLEAN: - { - sal_Bool* pVal = (sal_Bool*)aElement.getValue(); - bValueOk = (pVal != 0); - - cout << "VALUE '" << aName << "' is a BOOLEAN = "; - if (!bValueOk) - cout << "NULL (error!!)"; - else if (*pVal) - cout << "'TRUE'"; - else - cout << "'FALSE'"; - - cout << endl; - } - break; - case TypeClass_SHORT: - { - sal_Int16 aValue; - cout << "VALUE '" << aName << "' is a SHORT (16 bit) = "; - if (bValueOk = (aElement >>= aValue)) - cout << aValue; - else - cout << "ERROR RETRIEVING VALUE"; - cout << endl; - } - break; - case TypeClass_LONG: - { - - sal_Int32 aValue; - cout << "VALUE '" << aName << "' is a INT (32 bit) = "; - if (bValueOk = (aElement >>= aValue)) - cout << aValue; - else - cout << "ERROR RETRIEVING VALUE"; - cout << endl; - } - break; - case TypeClass_HYPER: - { - sal_Int64 aValue; - cout << "VALUE '" << aName << "' is a LONG (64 bit) = "; - if (bValueOk = (aElement >>= aValue)) - cout << double(aValue); - else - cout << "ERROR RETRIEVING VALUE"; - cout << endl; - } - break; - case TypeClass_DOUBLE: - { - double aValue; - cout << "VALUE '" << aName << "' is a DOUBLE = "; - if (bValueOk = (aElement >>= aValue)) - cout << aValue; - else - cout << "ERROR RETRIEVING VALUE"; - cout << endl; - } - break; - case TypeClass_STRING: - { - OUString aValue; - cout << "VALUE '" << aName << "' is a STRING = "; - if (bValueOk = (aElement >>= aValue)) - cout << "\"" << aValue << "\""; - else - cout << "ERROR RETRIEVING VALUE"; - cout << endl; - } - break; - case TypeClass_SEQUENCE: - { - cout << "VALUE '" << aName << "' is a SEQUENCE or BINARY" << endl; - - Type aTypeS = configmgr::getSequenceElementType(aElement.getValueType()); - OUString sType = configmgr::toTypeName(aTypeS.getTypeClass()); - cout << "Real type is Sequence<" << sType << ">" << endl; - bValueOk = true; - } - break; - case TypeClass_VOID: - cout << "ELEMENT '" << aName << "' is NULL and VOID " << endl; - bValueOk = true; - break; - default: - cout << "Error: ELEMENT '" << aName << "' is of unknown or unrecognized type" << endl; - break; - } - if (bValue) - { - if (bInserted) - { - if (aElement.getValueTypeClass() == TypeClass_BOOLEAN || - aElement.getValueTypeClass() == TypeClass_VOID) - { - cout << "Set Value (Type=BOOL) to :"; - cout.flush(); - cin.getline(buf,sizeof buf); - OUString aInput = OUString::createFromAscii(buf); - sal_Bool bValue = false; - if (aInput.equalsIgnoreAsciiCase(ASCII("true"))) - bValue = true; - - OUString aStr = ASCII("false"); - Any aValueAny; - aValueAny <<= bValue; - - Reference< XNameReplace > xNameReplace(xAccess, UNO_QUERY); - if (xNameReplace.is()) - { - xNameReplace->replaceByName(aName, aValueAny); - commit(); - } - bInserted = false; - } - else if (aElement.getValueTypeClass() == TypeClass_STRING) - { - cout << "set value (type = string) to : "; - cout.flush(); - cin.getline(buf,sizeof buf); - Any aValue; - aValue <<= buf; - - Reference< XNameReplace > xNameReplace(xAccess, UNO_QUERY); - if (xNameReplace.is()) - { - xNameReplace->replaceByName(aName, aValue); - commit(); - } - bInserted = false; - } - else - { - cout << "Sorry, only BOOLEAN Values can changed today." << endl; - } - } - prompt_and_wait(); - return bValueOk ? true : false; - } - - if (aElement >>= xNext) - cout << "Got an Interface for '" << aName << "'" << endl; - else - cout << "Error: Cannot get an Interface for '" << aName << "'" << endl; - } - else - { - cout << "Error: No element \"" << aInput << "\" found." <<endl; - } - } - - } - if (xNext.is()) - { - xIface = xNext; - return true; - } - cout << "Error: could not obtain the requested Object " << endl; - } - else - { - cout << "Input Error " << endl; - return true; - } - } - catch (Exception& e) - { - cout << "An Exception occurred: " << e.Message << endl; - - } - catch (...) - { - cout << "An UNKNOWN Exception occurred !" << endl; - } - - prompt_and_wait(); - return true; -} diff --git a/configmgr/workben/apitest/cfgapi_timetest.cxx b/configmgr/workben/apitest/cfgapi_timetest.cxx deleted file mode 100644 index 2d295991a754..000000000000 --- a/configmgr/workben/apitest/cfgapi_timetest.cxx +++ /dev/null @@ -1,957 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#define _PRIVATE_TEST_ - -#include <iostream> -using namespace std; - -#include <vector> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/Type.hxx> -#include <com/sun/star/uno/TypeClass.hpp> - -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> - - -#include <rtl/ustring.hxx> -#include <rtl/string.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <com/sun/star/uno/Sequence.h> -#include <com/sun/star/uno/Any.h> -#include <osl/profile.hxx> -#include <osl/process.h> -#include <osl/file.h> - -#include "createpropertyvalue.hxx" - -#include "typeconverter.hxx" - -// #include <com/sun/star/configuration/XConfigurationSync.hpp> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -//using namespace ::com::sun::star::util; -using namespace ::com::sun::star::util; - -using ::rtl::OUString; -using ::rtl::OString; -//using namespace ::configmgr; - -using namespace ::cppu; - -#define ASCII(x) ::rtl::OUString::createFromAscii(x) - -bool m_bInteractive = false; - -#define COUT if(m_bInteractive) cout - -ostream& operator << (ostream& out, rtl::OUString const& aStr) -{ - sal_Unicode const* const pStr = aStr.getStr(); - sal_Unicode const* const pEnd = pStr + aStr.getLength(); - for (sal_Unicode const* p = pStr; p < pEnd; ++p) - if (0 < *p && *p < 127) // ASCII - out << char(*p); - else - out << "[\\u" << hex << *p << "]"; - return out; -} - -void showSequence(const Sequence<OUString> &aSeq) -{ - OUString aArray; - const OUString *pStr = aSeq.getConstArray(); - for (int i=0;i<aSeq.getLength();i++) - { - OUString aStr = pStr[i]; - // aArray += aStr + ASCII(", "); - COUT << aStr << endl; - } - volatile int dummy = 0; -} - -//============================================================================= - -inline void operator <<= (::rtl::OUString& _rUnicodeString, const sal_Char* _pAsciiString) -{ - _rUnicodeString = ::rtl::OUString::createFromAscii(_pAsciiString); -} - -inline void operator <<= (::rtl::OUString& _rUnicodeString, const ::rtl::OString& _rAsciiString) -{ - _rUnicodeString <<= _rAsciiString.getStr(); -} - -inline void operator <<= (Any& _rUnoValue, const sal_Char* _pAsciiString) -{ - _rUnoValue <<= ::rtl::OUString::createFromAscii(_pAsciiString); -} - -inline void operator <<= (Any& _rUnoValue, const ::rtl::OString& _rAsciiString) -{ - _rUnoValue <<= _rAsciiString.getStr(); -} - -//============================================================================= -void test_read_access(Reference< XInterface >& xIface, const Reference< XMultiServiceFactory > &xMSF); -//============================================================================= - -// ----------------------------------------------------------------------------- -struct prompt_and_wait -{ - char const* myText; - prompt_and_wait(char const* text = "") : myText(text) {} - ~prompt_and_wait() - { - if (m_bInteractive) - { - COUT << myText << ">" << endl; - int const mx = int( (+0u - +1u) >> 1); - - char c=0; - if (cin.get(c) && c != '\n') - cin.ignore(mx,'\n'); - } - } -}; -static prompt_and_wait exit_prompt("Quitting\nQ"); - - -Reference< XChangesBatch > xChangesBatch = NULL; -void commit() -{ - if (xChangesBatch.is()) - { - xChangesBatch->commitChanges(); - } -} - -// ----------------------------------------------------------------------------- -static sal_Bool s_bInitialized = sal_False; -static const sal_Char* s_pSourcePath = "f:/office60_623/share/config/registry"; -static const sal_Char* s_pUpdatePath = "f:/office60_623/user/config/registry"; -static const sal_Char* s_pRootNode = "org.openoffice.Office.Common"; -static const sal_Char* s_pServerType = "local"; -static const sal_Char* s_pLocale = "de-DE"; -static const sal_Char* s_pServer = "lautrec-3108:19205"; -static const sal_Char* s_pUser = "lars"; -static const sal_Char* s_pPassword = ""; - -std::vector<rtl::OString> m_sNodes; - -// ----------------------------------------------------------------------------- -static void loadDefaults() -{ - if (s_bInitialized) - return; - - s_bInitialized = sal_True; - - try - { - // the executable file name - ::rtl::OUString sExecutable; - osl_getExecutableFile(&sExecutable.pData); - // cut the name, add a cfgapi.ini to the path - sal_Int32 nLastSep = sExecutable.lastIndexOf('/'); - if (-1 != nLastSep) - sExecutable = sExecutable.copy(0, nLastSep + 1); -#ifdef UNX - sExecutable += ::rtl::OUString::createFromAscii("cfgapirc"); -#else - sExecutable += ::rtl::OUString::createFromAscii("cfgapi.ini"); -#endif - ::rtl::OUString sSystem; - if (osl_File_E_None == osl_getSystemPathFromFileURL(sExecutable.pData, &sSystem.pData)) - { - ::osl::Profile aProfile(sExecutable); - - static ::rtl::OString sSection("defaults"); - static ::rtl::OString sSourcePath("sourcepath"); - static ::rtl::OString sUpdatePath("updatepath"); - static ::rtl::OString sRootNode("rootnode"); - static ::rtl::OString sServerType("servertype"); - static ::rtl::OString sLocale("Locale"); - static ::rtl::OString sServer("Server"); - static ::rtl::OString sUser("User"); - static ::rtl::OString sPassword("Password"); - - // read some strings. - // Do this static because we want to redirect the global static character pointers to the buffers. - static ::rtl::OString s_sSourcePath = aProfile.readString(sSection, sSourcePath, s_pSourcePath); - static ::rtl::OString s_sUpdatePath = aProfile.readString(sSection, sUpdatePath, s_pUpdatePath); - static ::rtl::OString s_sRootNode = aProfile.readString(sSection, sRootNode, s_pRootNode); - static ::rtl::OString s_sServerType = aProfile.readString(sSection, sServerType, s_pServerType); - static ::rtl::OString s_sLocale = aProfile.readString(sSection, sLocale, s_pLocale); - static ::rtl::OString s_sServer = aProfile.readString(sSection, sServer, s_pServer); - static ::rtl::OString s_sUser = aProfile.readString(sSection, sUser, s_pUser); - static ::rtl::OString s_sPassword = aProfile.readString(sSection, sPassword, s_pPassword); - - // do this redirection - s_pSourcePath = s_sSourcePath.getStr(); - s_pUpdatePath = s_sUpdatePath.getStr(); - s_pRootNode = s_sRootNode.getStr(); - s_pServerType = s_sServerType.getStr(); - s_pLocale = s_sLocale.getStr(); - s_pServer = s_sServer.getStr(); - s_pUser = s_sUser.getStr(); - s_pPassword = s_sPassword.getStr(); - - static ::rtl::OString sNodeSection("nodes"); - static ::rtl::OString sCount("count"); - rtl::OUString sCountValue; - sCountValue <<= aProfile.readString(sNodeSection, sCount, "0"); - sal_Int32 nCount = sCountValue.toInt32(); - for (sal_Int32 i=0;i<nCount;i++) - { - ::rtl::OString sNodeName("node"); - sNodeName += OString::valueOf(i); - ::rtl::OString sNode = aProfile.readString(sNodeSection, sNodeName, ""); - m_sNodes.push_back(sNode); - } - } - } - catch(std::exception& e) - { - e.what(); // silence warnings - } -} - -// ----------------------------------------------------------------------------- -Sequence<Any> createSequence(const OUString &sUser, const OUString &sPasswd) -{ - Sequence< Any > aCPArgs; - - if (sUser.getLength() > 0) - { - aCPArgs.realloc(1); - aCPArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser); - } - if (sPasswd.getLength() > 0) - { - aCPArgs.realloc(2); - aCPArgs[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd); - } - return aCPArgs; -} - -//============================================================================= -#include <string.h> -#if (defined UNX) || (defined OS2) -#else -#include <conio.h> -#endif - -OString input(const char* pDefaultText, char cEcho) -{ - // PRE: a Default Text would be shown, cEcho is a Value which will show if a key is pressed. - const int MAX_INPUT_LEN = 500; - char aBuffer[MAX_INPUT_LEN]; - - strcpy(aBuffer, pDefaultText); - int nLen = strlen(aBuffer); - -#ifdef WNT - char ch = '\0'; - - COUT << aBuffer; - cout.flush(); - - while(ch != 13) - { - ch = getch(); - if (ch == 8) - { - if (nLen > 0) - { - COUT << "\b \b"; - cout.flush(); - --nLen; - aBuffer[nLen] = '\0'; - } - else - { - COUT << "\a"; - cout.flush(); - } - } - else if (ch != 13) - { - if (nLen < MAX_INPUT_LEN) - { - if (cEcho == 0) - { - COUT << ch; - } - else - { - COUT << cEcho; - } - cout.flush(); - aBuffer[nLen++] = ch; - aBuffer[nLen] = '\0'; - } - else - { - COUT << "\a"; - cout.flush(); - } - } - } -#else - if (!cin.getline(aBuffer,sizeof aBuffer)) - return OString(); -#endif - return OString(aBuffer); -} - - -// ----------------------------------------------------------------------------- -rtl::OUString enterValue(const char* _aStr, const char* _aDefault, bool _bIsAPassword) -{ - COUT << _aStr; - cout.flush(); - - OUString sValue; - if (m_bInteractive) - { - sValue <<= input(_aDefault, _bIsAPassword ? '*' : 0); - } - else - { - sValue <<= _aDefault; - } - return sValue; -} - - - -void ask_for_a_node_and_test_it(const Reference< XMultiServiceFactory > &xCfgProvider, - const OUString& sUser, const OUString &sPasswd, - const OUString& sPath, bool bLocal, const OUString &sLocale); - -// ----------------------------------------------------------------------------- -// ---------------------------------- M A I N ---------------------------------- -// ----------------------------------------------------------------------------- - -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - // COUT << " Please insert Text: "; - // cout.flush(); - // OString aTxt = input("Der Text", 0); - // COUT << endl << "You inserted: " << aTxt.getStr() << endl; - // - // COUT << "Please insert Password: "; - // cout.flush(); - // OString aPasswd = input("", '*'); - // COUT << endl << "You inserted: " << aPasswd.getStr() << endl; - - loadDefaults(); - - m_bInteractive = false; - //if (argc > 1) - //{ - // OString aParam(argv[1]); - // if (aParam.equals("ask")) - // { - // m_bInteractive = true; - // } - //} - - try - { - OUString const sServiceRegistry = OUString::createFromAscii( argc > 1 ? argv[1] : "applicat.rdb" ); - Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory( - sServiceRegistry, - ::rtl::OUString() - ); - if (!xORB.is()) - { - ::flush(cout); - cerr << "Could not create the service factory !\n\n"; - return 1; - } - COUT << "Service factory created !\n---------------------------------------------------------------" << endl; - - Sequence< Any > aCPArgs; - - OUString sServerType = enterValue("servertype: ", s_pServerType, false); - COUT << endl; - - - rtl::OUString sUser, sPasswd; - - bool bLocal = sServerType.equalsIgnoreAsciiCase(ASCII("local")) || sServerType.equalsIgnoreAsciiCase(ASCII("setup")); - if (!bLocal) - { - rtl::OUString sServer; - sServer = enterValue("server : ", s_pServer,false); - COUT << endl; - - sUser = enterValue("user : ", s_pUser, false); - COUT << endl; - - sPasswd = enterValue("password: ", s_pPassword, true); - COUT << endl; - - aCPArgs = createSequence(sUser, sPasswd); - - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("server"), sServer); - - long nTimeout = 10000; - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("timeout"), nTimeout); - - long nPort = 9205; - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("port"), nPort); - } - else - { - rtl::OUString sSharePath, sUserPath; - sSharePath = enterValue("share path: ", s_pSourcePath, false); - COUT << endl; - sUserPath = enterValue("user path : ", s_pUpdatePath, false); - COUT << endl; - - aCPArgs.realloc(aCPArgs.getLength() + 1); - Any* pAny; - pAny = &aCPArgs[aCPArgs.getLength() - 1]; - *pAny <<= configmgr::createPropertyValue(ASCII("sourcepath"), sSharePath); - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("updatepath"), sUserPath); - } - - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("servertype"), sServerType); - - Reference< XMultiServiceFactory > xCfgProvider( - xORB->createInstanceWithArguments( - ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"), - aCPArgs), - UNO_QUERY); - if (!xCfgProvider.is()) - { - ::flush(cout); - cerr << "Could not create the configuration provider !\n\n"; - return 3; - } - - cout << "---------------------------------------------------------------\n Configuration Provider created !\n---------------------------------------------------------------" << endl; - - OUString sPath; - sPath <<= s_pRootNode; - OUString sLocale; - sLocale <<= s_pLocale; - - if (m_bInteractive) - { - sPath = enterValue("nodepath: ", s_pRootNode, false); - COUT << endl; - if (bLocal) - { - sLocale = enterValue("locale : ", s_pLocale, false); - COUT << endl; - } - ask_for_a_node_and_test_it(xCfgProvider, sUser, sPasswd, sPath, bLocal, sLocale); - } - else - { - sUser <<= ""; - for(std::vector<OString>::const_iterator it = m_sNodes.begin(); - it != m_sNodes.end(); - ++it) - { - OUString sPath; - sPath <<= *it; - if (sPath.getLength() > 0) - ask_for_a_node_and_test_it(xCfgProvider, sUser, sPasswd, sPath, bLocal, sLocale); - } - } - } - catch (Exception& e) - { - ::flush(cout); - cerr << "Caught exception: " << e.Message << endl; - return 1; - } - return 0; -} - -// ----------------------------------------------------------------------------- -void ask_for_a_node_and_test_it(const Reference< XMultiServiceFactory > &xCfgProvider, - const OUString& sUser, const OUString &sPasswd, - const OUString& sPath, bool bLocal, const OUString &sLocale) -{ - try - { - Sequence< Any > aArgs; - aArgs = createSequence(sUser, sPasswd); - - aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("nodepath"), sPath); - - if (!bLocal) - { - aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("locale"), sLocale); - } - - Reference< XInterface > xIFace = xCfgProvider->createInstanceWithArguments( - OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), - aArgs); - cout << "Configuration Read/Write Access created for :" << sPath << endl; - - xChangesBatch = Reference< XChangesBatch >(xIFace, UNO_QUERY); - - Sequence<OUString> aSeq = xCfgProvider->getAvailableServiceNames(); - showSequence(aSeq); - - test_read_access(xIFace, xCfgProvider); - } - catch (Exception& e) - { - ::flush(cout); - cerr << "Caught exception: " << e.Message << endl; - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -void test(Reference< XHierarchicalName >& xAccessName) -{ - if (xAccessName.is()) - { - COUT << "Accessing Node: " << xAccessName->getHierarchicalName() << endl; - } - else - { - cerr << "BUG: XHierarchicalName not available" << endl; - } -} -// ----------------------------------------------------------------------------- -void test(Reference< XNamed >& xAccess) -{ - if (xAccess.is()) - { - COUT << "Node is named: " << xAccess->getName() << endl; - } - else - cerr << "BUG: XNamed not available" << endl; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -void write(Reference<XNameAccess >& xAccess) -{ - if (xAccess.is()) - { - Sequence<OUString> aNames( xAccess->getElementNames() ); - - COUT << "Element Names: (" << aNames.getLength() << ")"; - for (int i = 0; i < aNames.getLength(); ++i) - { - COUT << "\n[" << i << "] -\t" << aNames[i]; - } - COUT << endl; - } - else - cerr << "BUG: XNameAccess not available" << endl; -} -// ----------------------------------------------------------------------------- -void write(Reference< XChild >& xChild) -{ - if (xChild.is()) - { - COUT << "\n[ P ] -\tParent" << endl; - } - else - cerr << "BUG: Parent not available (no XChild)" << endl; -} -/////////////////////////////////////////////////////////////////////////////////////////// - -bool ask(Reference< XInterface >& xIface, const Reference<XMultiServiceFactory> &); - -void test_read_access(Reference< XInterface >& xIface, const Reference< XMultiServiceFactory > &xMSF) -{ - using com::sun::star::uno::UNO_QUERY; - do - { - COUT << "\n\n---------------------------------------------------------------" << endl; - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - Reference< XChild > xChild(xIface, UNO_QUERY); - Reference< XHierarchicalName > xAccessPath(xIface,UNO_QUERY); - Reference< XNamed > xAccessName(xIface,UNO_QUERY); -// Reference< XHierarchicalNameAccess >& xAccess(xIface, UNO_QUERY); - - test(xAccessPath); - test(xAccessName); - write(xAccess); - write(xChild); - - if (!m_bInteractive) break; - } - while (ask(xIface, xMSF)); -} - -bool ask(Reference< XInterface >& xIface, const Reference< XMultiServiceFactory > &xMSF) -{ - COUT << "\n[ Q ] -> <Quit>"; - COUT << "\n[ S ] -> <SetValue> "; - COUT << endl; - - COUT << "\n:> " << flush; - char buf[200] = {0}; - try - { - bool bHandled = false; - bool bInserted = false; - - if (cin.getline(buf,sizeof buf)) - { - Reference< XInterface > xNext; - if ((buf[0] == 'q' || buf[0] == 'Q') && (0 == buf[1])) - { - return false; - } - else if (buf[0] == 0) - { - return true; - } - else if((buf[0] == 0 || buf[0] == 'o' || buf[0] == 'O') && (0 == buf[1])) - { -/* - COUT << "work Offline" << endl; - Reference<com::sun::star::configuration::XConfigurationSync> xSync(xMSF, UNO_QUERY); - - Sequence< Any > aArgs2(5); - sal_Int32 n=0; - aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Setup")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Common")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Java")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Writer")); - // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.ucb.Hierarchy")); - xSync->offline(aArgs2); - bHandled = true; -*/ - } - else if((buf[0] == 0 || buf[0] == 's' || buf[0] == 'S') && (0 == buf[1])) - { - // Replace a Value - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - - COUT << "SetMode, insert a Number" << endl; - cin.getline(buf,sizeof buf); - bInserted = true; - } - - else if ((buf[0] == 'p' || buf[0] == 'P') && (0 == buf[1])) - { - Reference< XChild > xChild(xIface, UNO_QUERY); - if (xChild.is()) - xNext = xChild->getParent(); - bHandled = true; - } - - if (bHandled == false) - { - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - Reference< XHierarchicalNameAccess > xDeepAccess(xIface, UNO_QUERY); - Reference< XExactName > xExactName(xIface, UNO_QUERY); - - if (xAccess.is() || xDeepAccess.is()) - { - OUString aName; - OUString aInput = OUString::createFromAscii(buf); - - if (xExactName.is()) - { - ::rtl::OUString sTemp = xExactName->getExactName(aInput); - if (sTemp.getLength()) - aInput = sTemp; - } - - if (xAccess.is() && xAccess->hasByName(aInput)) - { - aName = aInput; - } - else if (xDeepAccess.is() && xDeepAccess->hasByHierarchicalName(aInput)) - { - aName = aInput; - } - else if ('0' <= buf[0] && buf[0] <= '9' && xAccess.is()) - { - unsigned int n = unsigned(atoi(buf)); - Sequence<OUString> aNames = xAccess->getElementNames(); - if (n < aNames.getLength()) - aName = aNames[n]; - } - - if (aName.getLength()) - { - bool bNest = aInput.indexOf(sal_Unicode('/')) >= 0; - - Any aElement = bNest ? ( xDeepAccess.is() ? xDeepAccess->getByHierarchicalName(aName) : Any()) - : ( xAccess. is() ? xAccess-> getByName(aName) : Any() ); - - while (aElement.getValueTypeClass() == TypeClass_ANY) - { - Any aWrap(aElement); - aWrap >>= aElement; - } - sal_Bool bValue = true; - sal_Bool bValueOk = false; - - switch (aElement.getValueTypeClass() ) - { - case TypeClass_INTERFACE: bValue = false; break; - case TypeClass_BOOLEAN: - { - sal_Bool* pVal = (sal_Bool*)aElement.getValue(); - bValueOk = (pVal != 0); - - COUT << "VALUE '" << aName << "' is a BOOLEAN = "; - if (!bValueOk) - { - COUT << "NULL (error!!)"; - } - else if (*pVal) - { - COUT << "'TRUE'"; - } - else - { - COUT << "'FALSE'"; - } - COUT << endl; - } - break; - case TypeClass_SHORT: - { - sal_Int16 aValue; - COUT << "VALUE '" << aName << "' is a SHORT (16 bit) = "; - if (bValueOk = (aElement >>= aValue)) - { - COUT << aValue; - } - else - cerr << "ERROR RETRIEVING VALUE"; - COUT << endl; - } - break; - case TypeClass_LONG: - { - - sal_Int32 aValue; - COUT << "VALUE '" << aName << "' is a INT (32 bit) = "; - if (bValueOk = (aElement >>= aValue)) - { - COUT << aValue; - } - else - cerr << "ERROR RETRIEVING VALUE"; - COUT << endl; - } - break; - case TypeClass_HYPER: - { - sal_Int64 aValue; - COUT << "VALUE '" << aName << "' is a LONG (64 bit) = "; - if (bValueOk = (aElement >>= aValue)) - { - COUT << double(aValue); - } - else - cerr << "ERROR RETRIEVING VALUE"; - COUT << endl; - } - break; - case TypeClass_DOUBLE: - { - double aValue; - COUT << "VALUE '" << aName << "' is a DOUBLE = "; - if (bValueOk = (aElement >>= aValue)) - { - COUT << aValue; - } - else - cerr << "ERROR RETRIEVING VALUE"; - COUT << endl; - } - break; - case TypeClass_STRING: - { - OUString aValue; - COUT << "VALUE '" << aName << "' is a STRING = "; - if (bValueOk = (aElement >>= aValue)) - { - COUT << "\"" << aValue << "\""; - } - else - cerr << "ERROR RETRIEVING VALUE"; - COUT << endl; - } - break; - case TypeClass_SEQUENCE: - { - COUT << "VALUE '" << aName << "' is a SEQUENCE or BINARY" << endl; - - Type aTypeS = configmgr::getSequenceElementType(aElement.getValueType()); - OUString sType = configmgr::toTypeName(aTypeS.getTypeClass()); - COUT << "Real type is Sequence<" << sType << ">" << endl; - bValueOk = true; - } - break; - case TypeClass_VOID: - COUT << "ELEMENT '" << aName << "' is NULL and VOID " << endl; - bValueOk = true; - break; - default: - cerr << "Error: ELEMENT '" << aName << "' is of unknown or unrecognized type" << endl; - break; - } - if (bValue) - { - if (bInserted) - { - if (aElement.getValueTypeClass() == TypeClass_BOOLEAN || - aElement.getValueTypeClass() == TypeClass_VOID) - { - COUT << "Set Value (Type=BOOL) to :"; - cout.flush(); - cin.getline(buf,sizeof buf); - OUString aInput = OUString::createFromAscii(buf); - sal_Bool bValue = false; - - Any aValueAny; - if (aInput.equalsIgnoreAsciiCase(ASCII("true"))) - { - bValue = true; - aValueAny <<= bValue; - } - else if (aInput.equalsIgnoreAsciiCase(ASCII("false"))) - { - bValue = false; - aValueAny <<= bValue; - } - else if (aInput.equalsIgnoreAsciiCase(ASCII("null"))) - { - } - - Reference< XNameReplace > xNameReplace(xAccess, UNO_QUERY); - if (xNameReplace.is()) - { - xNameReplace->replaceByName(aName, aValueAny); - commit(); - } - bInserted = false; - } - else if (aElement.getValueTypeClass() == TypeClass_STRING) - { - COUT << "set value (type = string) to : "; - cout.flush(); - cin.getline(buf,sizeof buf); - Any aValue; - aValue <<= buf; - - Reference< XNameReplace > xNameReplace(xAccess, UNO_QUERY); - if (xNameReplace.is()) - { - xNameReplace->replaceByName(aName, aValue); - commit(); - } - bInserted = false; - } - else - { - cerr << "Sorry, only BOOLEAN Values can changed today." << endl; - } - } - prompt_and_wait(); - return bValueOk ? true : false; - } - - if (aElement >>= xNext) - { - COUT << "Got an Interface for '" << aName << "'" << endl; - } - else - cerr << "Error: Cannot get an Interface for '" << aName << "'" << endl; - } - else - { - cerr << "Error: No element \"" << aInput << "\" found." <<endl; - } - } - - } - if (xNext.is()) - { - xIface = xNext; - return true; - } - cerr << "Error: could not obtain the requested Object " << endl; - } - else - { - COUT << "Input Error " << endl; - return true; - } - } - catch (Exception& e) - { - cerr << "An Exception occurred: " << e.Message << endl; - - } - catch (...) - { - cerr << "An UNKNOWN Exception occurred !" << endl; - } - - prompt_and_wait(); - return true; -} diff --git a/configmgr/workben/apitest/cfgregistry.cxx b/configmgr/workben/apitest/cfgregistry.cxx deleted file mode 100644 index e2a81bbfb9f2..000000000000 --- a/configmgr/workben/apitest/cfgregistry.cxx +++ /dev/null @@ -1,169 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#include <memory.h> -#include <stdio.h> -#include <com/sun/star/xml/sax/XDocumentHandler.hpp> -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/registry/XSimpleRegistry.hpp> -#include <com/sun/star/util/XFlushable.hpp> -#include <cppuhelper/servicefactory.hxx> -#include <cppuhelper/implbase1.hxx> -#ifndef _CPPUHELPER_EXTRACT_HXX_ -#include <cppuhelper/extract.hxx> -#endif -#include <vos/conditn.hxx> -#include <osl/diagnose.h> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::xml; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::registry; -using namespace ::vos; -using namespace ::cppu; -//using namespace ::configmgr; - -//============================================================================= -//= a dirty littly class for printing ascii characters -//============================================================================= -class OAsciiOutput -{ -protected: - sal_Char* m_pCharacters; - -public: - OAsciiOutput(const ::rtl::OUString& _rUnicodeChars); - ~OAsciiOutput() { delete m_pCharacters; } - - const sal_Char* getCharacters() const { return m_pCharacters; } -}; - -//----------------------------------------------------------------------------- -OAsciiOutput::OAsciiOutput(const ::rtl::OUString& _rUnicodeChars) -{ - sal_Int32 nLen = _rUnicodeChars.getLength(); - m_pCharacters = new sal_Char[nLen + 1]; - sal_Char* pFillPtr = m_pCharacters; - const sal_Unicode* pSourcePtr = _rUnicodeChars.getStr(); -#if OSL_DEBUG_LEVEL > 1 - sal_Bool bAsserted = sal_False; -#endif - for (sal_Int32 i=0; i<nLen; ++i, ++pFillPtr, ++pSourcePtr) - { - OSL_ENSURE(bAsserted || !(bAsserted = (*pSourcePtr >= 0x80)), - "OAsciiOutput::OAsciiOutput : non-ascii character found !"); - *pFillPtr = *reinterpret_cast<const sal_Char*>(pSourcePtr); - } - *pFillPtr = 0; -} - -#define ASCII_STRING(rtlOUString) OAsciiOutput(rtlOUString).getCharacters() -#define UNI_STRING(asciiString) ::rtl::OUString::createFromAscii(asciiString) - -//============================================================================= -//============================================================================= - -#if (defined UNX) || (defined OS2) -void main( int argc, char * argv[] ) -#else -void _cdecl main( int argc, char * argv[] ) -#endif -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory( - ::rtl::OUString::createFromAscii("l:\\bin.a\\applicat.rdb"), - ::rtl::OUString() - ); - if (!xORB.is()) - { - fprintf(stdout, "could not create the service factory !\n\n"); - return; - } - - try - { - Reference< XSimpleRegistry > xConfigurationRegistry; - printf("instantiating the configuration registry access\n\r"); - xConfigurationRegistry = xConfigurationRegistry.query( - xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationRegistry")) - ); - - const sal_Char* pLayoutNode = "com.sun.star.Inet"; - printf("opening the registry access to %s\n\r", pLayoutNode); - xConfigurationRegistry->open(UNI_STRING(pLayoutNode), sal_False, sal_False); - - printf("retrieving the root key, enumerating elements\n\r"); - Reference< XRegistryKey > xRoot = xConfigurationRegistry->getRootKey(); - Sequence< ::rtl::OUString > aKeyNames = xRoot->getKeyNames(); - const ::rtl::OUString* pKeyNames = aKeyNames.getConstArray(); - for (sal_Int32 i=0; i<aKeyNames.getLength(); ++i, ++pKeyNames) - printf("\t%i\t%s\n\r", i, ASCII_STRING(*pKeyNames)); - - const sal_Char* pUpdateKey = "Proxy/NoProxy"; - printf("retrieving the key for %s\n\r", pUpdateKey); - Reference< XRegistryKey > xTabStopsKey = xRoot->openKey(UNI_STRING(pUpdateKey)); - -/* xTabStopsKey->createKey(UNI_STRING("blupp")); - - Sequence< ::rtl::OUString > sLanguages = xTabStopsKey->getStringListValue(); - sLanguages.realloc(sLanguages.getLength() + 1); - sLanguages[sLanguages.getLength() - 1] = UNI_STRING("ru"); - xTabStopsKey->setStringListValue(sLanguages); -*/ - - ::rtl::OUString sTest = xTabStopsKey->getStringValue(); - xTabStopsKey->setStringValue(UNI_STRING("blimp")); - - printf("flushing the changes\n\r"); - Reference< XFlushable > xCommit(xConfigurationRegistry, UNO_QUERY); - xCommit->flush(); - } - catch(RuntimeException& e) - { - printf("\n\r\n\rcaught an RuntimeException :\n\r"); - printf(" exception message : %s\n\r", ASCII_STRING(e.Message)); - return; - } - catch(Exception& e) - { - printf("\n\r\n\rcaught an Exception :\n\r"); - printf(" exception message : %s\n\r", ASCII_STRING(e.Message)); - return; - } -} diff --git a/configmgr/workben/apitest/cfgupdate.cxx b/configmgr/workben/apitest/cfgupdate.cxx deleted file mode 100644 index e76789ca10a7..000000000000 --- a/configmgr/workben/apitest/cfgupdate.cxx +++ /dev/null @@ -1,432 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#define _PRIVATE_TEST_ - -#include <iostream> -using namespace std; - -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/Type.hxx> -#include <com/sun/star/uno/TypeClass.hpp> - -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/beans/XHierarchicalPropertySet.hpp> - - -#include <rtl/ustring.hxx> -#include <rtl/string.hxx> -#include <osl/time.h> -#include <cppuhelper/servicefactory.hxx> -#include <com/sun/star/uno/Sequence.h> -#include <com/sun/star/uno/Any.h> - -#include "createpropertyvalue.hxx" - -#include "typeconverter.hxx" - -// #include <com/sun/star/configuration/XConfigurationSync.hpp> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -//using namespace ::com::sun::star::util; -using namespace ::com::sun::star::util; - -using ::rtl::OUString; -using ::rtl::OString; -//using namespace ::configmgr; - -using namespace ::cppu; - -#define ASCII(x) ::rtl::OUString::createFromAscii(x) - -ostream& operator << (ostream& out, rtl::OUString const& aStr) -{ - sal_Unicode const* const pStr = aStr.getStr(); - sal_Unicode const* const pEnd = pStr + aStr.getLength(); - for (sal_Unicode const* p = pStr; p < pEnd; ++p) - if (0 < *p && *p < 127) // ASCII - out << char(*p); - else - out << "[\\u" << hex << *p << "]"; - return out; -} - -void showSequence(const Sequence<OUString> &aSeq) -{ - OUString aArray; - const OUString *pStr = aSeq.getConstArray(); - for (int i=0;i<aSeq.getLength();i++) - { - OUString aStr = pStr[i]; - // aArray += aStr + ASCII(", "); - cout << aStr << endl; - } - volatile int dummy = 0; -} - -//============================================================================= -//============================================================================= -void test_read_access(Reference< XInterface >& xIface, Reference< XMultiServiceFactory > &xMSF); -//============================================================================= -struct prompt_and_wait -{ - char const* myText; - prompt_and_wait(char const* text = "") : myText(text) {} - ~prompt_and_wait() - { - cout << myText << ">" << endl; - int const mx = int( (+0u - +1u) >> 1); - - char c=0; - if (cin.get(c) && c != '\n') - cin.ignore(mx,'\n'); - } -}; -static prompt_and_wait exit_prompt("Quitting\nQ"); - - -// ----------------------------------------------------------------------------- -Sequence<Any> createSequence(const OUString &sUser, const OUString &sPasswd) -{ - Sequence< Any > aCPArgs; - - if (sUser.getLength() > 0) - { - aCPArgs.realloc(1); - aCPArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser); - } - if (sPasswd.getLength() > 0) - { - aCPArgs.realloc(2); - aCPArgs[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd); - } - return aCPArgs; -} - -//============================================================================= -#include <string.h> -#if (defined UNX) || (defined OS2) -#else -#include <conio.h> -#endif - -OString input(const char* pDefaultText, char cEcho) -{ - // PRE: a Default Text would be shown, cEcho is a Value which will show if a key is pressed. - const int MAX_INPUT_LEN = 500; - char aBuffer[MAX_INPUT_LEN]; - - strcpy(aBuffer, pDefaultText); - int nLen = strlen(aBuffer); - -#ifdef WNT - char ch = '\0'; - - cout << aBuffer; - cout.flush(); - - while(ch != 13) - { - ch = getch(); - if (ch == 8) - { - if (nLen > 0) - { - cout << "\b \b"; - cout.flush(); - --nLen; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - else if (ch != 13) - { - if (nLen < MAX_INPUT_LEN) - { - if (cEcho == 0) - { - cout << ch; - } - else - { - cout << cEcho; - } - cout.flush(); - aBuffer[nLen++] = ch; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - } -#else - if (!cin.getline(aBuffer,sizeof aBuffer)) - return OString(); -#endif - return OString(aBuffer); -} - -// ----------------------------------------------------------------------------- -rtl::OUString enterValue(const char* _aStr, const char* _aDefault, bool _bIsAPassword) -{ - cout << _aStr; - cout.flush(); - OString aTxt = input(_aDefault, _bIsAPassword ? '*' : 0); - - OUString sValue = OUString::createFromAscii(aTxt); - return sValue; -} - -// ----------------------------------------------------------------------------- -Reference< XNameAccess > beginChanges(Reference< XMultiServiceFactory > xFactory, OUString sPath) -{ - Sequence< Any > aArgs(1); - aArgs[0] <<= configmgr::createPropertyValue(ASCII("nodepath"),sPath); - - cout << "starting update for node:" << sPath << endl; - - Reference< XNameAccess > xTree(xFactory->createInstanceWithArguments(OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), - aArgs), UNO_QUERY); - - return xTree; -} - -template <class Type> -// ----------------------------------------------------------------------------- -void update(Reference< XInterface > xIFace, OUString sRelPath, Type sValue) -{ - Reference< XHierarchicalPropertySet > xTree(xIFace, UNO_QUERY); - Any aValue; - aValue <<= sValue; - - cout << "updating node:" << sRelPath << endl; - xTree->setHierarchicalPropertyValue(sRelPath, aValue); -} - -// ----------------------------------------------------------------------------- -Reference< XHierarchicalPropertySet > insertTree(Reference< XInterface > xIFace, OUString aName) -{ - if (!aName.getLength()) - aName = enterValue("/nEnter a Tree to insert: ", "", false); - - Reference< XSingleServiceFactory > xFactory(xIFace, UNO_QUERY); - Reference< XHierarchicalPropertySet > xNewElement(xFactory->createInstance(), UNO_QUERY); - - cout << "inserting new tree element:" << aName << endl; - - Any aTree; - aTree <<= xNewElement; - Reference< XNameContainer >(xFactory, UNO_QUERY)->insertByName(aName, aTree); - - return xNewElement; -} - -// ----------------------------------------------------------------------------- -void removeTree(Reference< XInterface > xIFace, OUString aName) -{ - if (!aName.getLength()) - aName = enterValue("/nEnter a Tree to remove: ", "", false); - - cout << "removing new tree element:" << aName << endl; - - Reference< XNameContainer >(xIFace, UNO_QUERY)->removeByName(aName); -} - -// ----------------------------------------------------------------------------- -void commitChanges(Reference< XInterface > xIFace) -{ - cout << "committing changes:" << endl; - - Reference< XChangesBatch > xChangesBatch(xIFace, UNO_QUERY); - xChangesBatch->commitChanges(); -} - -// ----------------------------------------------------------------------------- -void displayTree(Reference< XNameAccess > xIFace, sal_Int32 nLevel) -{ - const char* pTab = " "; - Sequence<OUString> aNames( xIFace->getElementNames() ); - for (int i = 0; i < aNames.getLength(); ++i) - { - Any aElement = xIFace->getByName(aNames[i]); - Reference< XNameAccess > xAccess; - Reference< XSingleServiceFactory > xFactory; - aElement >>= xFactory; - aElement >>= xAccess; - - cout << endl; - for (int j = 0; j < nLevel; j++) - cout << " "; - - if (xAccess.is()) - { - OUString sType; - if (xFactory.is()) - sType = OUString::createFromAscii(" type = 'set' " ); - - cout << "<" << aNames[i] << sType << ">"; - displayTree(xAccess, nLevel + 1); - cout << endl << "</" << aNames[i] << ">"; - } - else - cout << "<" << aNames[i] << "/>"; - - } - ::flush(cout); -} - -// ----------------------------------------------------------------------------- -// ---------------------------------- M A I N ---------------------------------- -// ----------------------------------------------------------------------------- - -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - // cout << " Please insert Text: "; - // cout.flush(); - // OString aTxt = input("Der Text", 0); - // cout << endl << "You inserted: " << aTxt.getStr() << endl; - // - // cout << "Please insert Password: "; - // cout.flush(); - // OString aPasswd = input("", '*'); - // cout << endl << "You inserted: " << aPasswd.getStr() << endl; - - try - { - OUString const sServiceRegistry = OUString::createFromAscii( argc > 1 ? argv[1] : "applicat.rdb" ); - Reference< XMultiServiceFactory > xORB = createRegistryServiceFactory( - sServiceRegistry, - ::rtl::OUString() - ); - if (!xORB.is()) - { - ::flush(cout); - cerr << "Could not create the service factory !\n\n"; - return 1; - } - cout << "Service factory created !\n---------------------------------------------------------------" << endl; - - Sequence< Any > aCPArgs; - - /*OUString sServerType = enterValue("Enter Servertype: ", "remote", false); - cout << endl;*/ - - - rtl::OUString sFilePath; - rtl::OUString sPort; - rtl::OUString sUser; - - sUser = enterValue("Enter User: ", "user1", false); - cout << endl; - - OUString sPasswd;// = enterValue("Enter Password: ", "", true); - cout << endl; - - aCPArgs = createSequence(sUser, sPasswd); - - Reference< XMultiServiceFactory > xCfgProvider( - xORB->createInstanceWithArguments( - ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"), - aCPArgs), - UNO_QUERY); - if (!xCfgProvider.is()) - { - ::flush(cout); - cerr << "Could not create the configuration provider !\n\n"; - return 3; - } - - Reference< XNameAccess > xUpdateAccess; - -// now do updates for the user - xUpdateAccess = beginChanges(xCfgProvider, OUString::createFromAscii("org.openoffice.Security")); - displayTree(xUpdateAccess, 0); - - update(xUpdateAccess, OUString::createFromAscii("_3D_Engine/Dithering"), sal_Bool(sal_False)); - -/* xUpdateAccess = beginChanges(xCfgProvider, OUString::createFromAscii("org.openoffice.Inet")); - - update(xUpdateAccess, OUString::createFromAscii("Proxy/FTP/Port"), sal_Int32(11)); - update(xUpdateAccess, OUString::createFromAscii("Proxy/FTP/Name"), OUString::createFromAscii("Test3")); - update(xUpdateAccess, OUString::createFromAscii("DNS/IP_Address"), OUString::createFromAscii("Test4")); -*/ - commitChanges(xUpdateAccess); - -// now do updates with inserting and removing of nodes - - xUpdateAccess = beginChanges(xCfgProvider, OUString::createFromAscii("org.openoffice.Security/MountPoints")); - displayTree(xUpdateAccess, 0); - - Reference< XHierarchicalPropertySet > xTree = insertTree(xUpdateAccess, OUString()); - update(xUpdateAccess, OUString::createFromAscii("InstallationDirectory/Directory"), OUString::createFromAscii("Test1")); - removeTree(xUpdateAccess, OUString()); - commitChanges(xUpdateAccess); - } - catch (Exception& e) - { - ::flush(cout); - cerr << "Caught exception: " << e.Message << endl; - } -/* - catch (...) - { - ::flush(cout); - cerr << "BUG: Caught UNKNOWN exception (?) " << endl; - } -*/ - return 0; -} - diff --git a/configmgr/workben/apitest/makefile.mk b/configmgr/workben/apitest/makefile.mk deleted file mode 100644 index fb14df415c23..000000000000 --- a/configmgr/workben/apitest/makefile.mk +++ /dev/null @@ -1,124 +0,0 @@ -#************************************************************************* -# -# 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=..$/.. -PRJINC=$(PRJ)$/source - -PRJNAME=configmgr - -TARGET=cfgapi -TARGET2=cfgreg -TARGET3=cfgadduser -TARGET4=cfgadmin -TARGET5=cfgupdate -TARGET6=cfgapi_timetest -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -# ... common for all test executables .............................. -APPSTDLIBS=\ - $(SALLIB) \ - $(VOSLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) - -# ... cfgapi .............................. -APP1STDLIBS = $(APPSTDLIBS) - -APP1STDLIBS+=$(STDLIBCPP) - -APP1TARGET= $(TARGET) -APP1OBJS= \ - $(SLO)$/cfgapi.obj \ - $(SLO)$/strimpl.obj \ - $(SLO)$/typeconverter.obj \ - $(SLO)$/simpletypehelper.obj \ - -# ... cfgapi_timetest .............................. -APP6STDLIBS = $(APPSTDLIBS) - -APP6STDLIBS+=$(STDLIBCPP) - -APP6TARGET= $(TARGET6) -APP6OBJS= \ - $(SLO)$/cfgapi_timetest.obj \ - $(SLO)$/strimpl.obj \ - $(SLO)$/typeconverter.obj \ - $(SLO)$/simpletypehelper.obj \ - -# ... cfgreg .............................. -APP2STDLIBS = $(APPSTDLIBS) - -APP2STDLIBS+=$(STDLIBCPP) - -APP2TARGET= $(TARGET2) -APP2OBJS= \ - $(SLO)$/cfgregistry.obj \ - -# ... cfgadduser .............................. -APP3STDLIBS = $(APPSTDLIBS) - -APP3STDLIBS+=$(STDLIBCPP) - -APP3TARGET= $(TARGET3) -APP3OBJS= \ - $(SLO)$/cfgadduser.obj \ - -# ... cfgadmin .............................. -APP4STDLIBS = $(APPSTDLIBS) - -APP4STDLIBS+=$(STDLIBCPP) - -APP4TARGET= $(TARGET4) -APP4OBJS= \ - $(SLO)$/cfgadmin.obj \ - $(SLO)$/strimpl.obj \ - $(SLO)$/typeconverter.obj \ - $(SLO)$/simpletypehelper.obj \ - -# ... cfgupdate .............................. -APP5STDLIBS = $(APPSTDLIBS) - -APP5STDLIBS+=$(STDLIBCPP) - -APP5TARGET= $(TARGET5) -APP5OBJS= \ - $(SLO)$/cfgupdate.obj \ - $(SLO)$/strimpl.obj \ - $(SLO)$/typeconverter.obj \ - $(SLO)$/simpletypehelper.obj \ - -.INCLUDE : target.mk - - diff --git a/configmgr/workben/apitest/sregistry b/configmgr/workben/apitest/sregistry deleted file mode 100644 index f4f353181f25..000000000000 --- a/configmgr/workben/apitest/sregistry +++ /dev/null @@ -1,8 +0,0 @@ -[configuration] -servertype=remote -[RemoteRegistry] -Server=munch-11072:100 -Timeout=2500 -[LocalRegistry] -rootpath="G:\Configuration" - diff --git a/configmgr/workben/local_io/cfgfile.cxx b/configmgr/workben/local_io/cfgfile.cxx deleted file mode 100644 index a91cc512aa62..000000000000 --- a/configmgr/workben/local_io/cfgfile.cxx +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - - -// ----------------------------------------------------------------------------- -// ------------------------------------ main ------------------------------------ -// ----------------------------------------------------------------------------- - -/* - OUString operator+(const OUString &a, const OUString &b) - { - OUString c = a; - c += b; - return c; - } -*/ - -namespace configmgr -{ - void simpleMappingTest(); - - void importTest(); - void exportTest(); - - void hierarchyTest(); - //void simpleTest(); - void speedTest(); - void stringTest(); - void classTest(); - void hash_test(); - void testRefs(); - void ConfigName(); - - void oslTest(); -} - - - -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else - int _cdecl main( int argc, char * argv[] ) -#endif -{ - -// configmgr::hierarchyTest(); - - -// configmgr::importTest(); -// configmgr::exportTest(); -// configmgr::speedTest(); -// configmgr::simpleTest(); - -// configmgr::simpleMappingTest(); -// configmgr::stringTest(); -// configmgr::classTest(); - -// configmgr::hash_test(); - - // configmgr::testRefs(); - // configmgr::ConfigName(); - - configmgr::oslTest(); - return 0; -} - - diff --git a/configmgr/workben/local_io/cfglocal.cxx b/configmgr/workben/local_io/cfglocal.cxx deleted file mode 100644 index 10530b0ba48d..000000000000 --- a/configmgr/workben/local_io/cfglocal.cxx +++ /dev/null @@ -1,620 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#define _PRIVATE_TEST_ - -#include <memory.h> -#include <string.h> -#include <stdio.h> -#include <vos/socket.hxx> -#include "attributes.hxx" - -#ifndef _CONFIGMGR_SESSION_REMOTESESSION_HXX_ -#include "remotesession.hxx" -#endif -#include <com/sun/star/xml/sax/XDocumentHandler.hpp> -#include <cppuhelper/servicefactory.hxx> -#include <cppuhelper/implbase1.hxx> -#include <vos/conditn.hxx> - -#include <osl/time.h> - -#include "localsession.hxx" -#include "confname.hxx" - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::xml; -using namespace ::vos; -using namespace ::cppu; -using namespace ::configmgr; -using namespace rtl; - -// #define USE_LAYOUT_NODE - -//============================================================================= -//= a dirty littly class for printing ascii characters -//============================================================================= -class OAsciiOutput -{ -protected: - sal_Char* m_pCharacters; - -public: - OAsciiOutput(const ::rtl::OUString& _rUnicodeChars); - ~OAsciiOutput() { delete m_pCharacters; } - - const sal_Char* getCharacters() const { return m_pCharacters; } -}; - -//----------------------------------------------------------------------------- -OAsciiOutput::OAsciiOutput(const ::rtl::OUString& _rUnicodeChars) -{ - sal_Int32 nLen = _rUnicodeChars.getLength(); - m_pCharacters = new sal_Char[nLen + 1]; - sal_Char* pFillPtr = m_pCharacters; - const sal_Unicode* pSourcePtr = _rUnicodeChars.getStr(); -#ifdef DBG_UTIL - sal_Bool bAsserted = sal_False; -#endif - for (sal_Int32 i=0; i<nLen; ++i, ++pFillPtr, ++pSourcePtr) - { - OSL_ENSURE(bAsserted || !(bAsserted = (*pSourcePtr >= 0x80)), - "OAsciiOutput::OAsciiOutput : non-ascii character found !"); - *pFillPtr = *reinterpret_cast<const sal_Char*>(pSourcePtr); - } - *pFillPtr = 0; -} - -#define ASCII_STRING(rtlOUString) OAsciiOutput(rtlOUString).getCharacters() -#define UNI_STRING(salCharPtr) ::rtl::OUString::createFromAscii(salCharPtr) - -//============================================================================= -//= OOpenNodeCallback -//============================================================================= -typedef ::cppu::WeakImplHelper1< sax::XDocumentHandler > OOpenNodeCallback_Base; -class OOpenNodeCallback : public IOpenObjectCallback, public OOpenNodeCallback_Base -{ -protected: - OUString m_sNodeId; - ::vos::OCondition& m_rFinishCondition; - - enum ACTION { STARTELEMENT, CHARACTERS, ENDELEMENT }; - ACTION m_eLastAction; - sal_Int32 m_nLevel; - sal_Bool m_bCloseStartTag; - -protected: - ~OOpenNodeCallback() - { - } - -public: - OOpenNodeCallback(::vos::OCondition& _rFinishCond) : m_rFinishCondition(_rFinishCond), m_nLevel(0), m_eLastAction(ENDELEMENT), m_bCloseStartTag(sal_False) { } - - OUString getNodeId() const { return m_sNodeId; } - - // IOpenObjectCallback - virtual void gotObjectId(const OUString &aName); - - // IDataRequestCallback - virtual Reference< sax::XDocumentHandler > getDataReader() { return static_cast< sax::XDocumentHandler* >(this); } - - // IRequestCallback - virtual void acknowledged(sal_Int32 _nTransId); - virtual void failed(sal_Int32 _nErrorCode); - virtual void done(const StatusInfo& _rStatus); - - // IInterface - virtual void SAL_CALL acquire( ) throw (::com::sun::star::uno::RuntimeException) { OOpenNodeCallback_Base::acquire(); } - virtual void SAL_CALL release( ) throw (::com::sun::star::uno::RuntimeException) { OOpenNodeCallback_Base::release(); } - - // XDocumentHandler - virtual void SAL_CALL startDocument( ) throw(sax::SAXException, RuntimeException) { } - virtual void SAL_CALL endDocument( ) throw(sax::SAXException, RuntimeException) { } - virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const Reference< sax::XAttributeList >& xAttribs ) throw(sax::SAXException, RuntimeException); - virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw(sax::SAXException, RuntimeException); - virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw(sax::SAXException, RuntimeException); - virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw(sax::SAXException, RuntimeException) { } - virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw(sax::SAXException, RuntimeException) { } - virtual void SAL_CALL setDocumentLocator( const Reference< sax::XLocator >& xLocator ) throw(sax::SAXException, RuntimeException) { } -}; - -//............................................................................. -inline void linefeed() -{ - // printf("\n"); -} - -//............................................................................. -void printTabs(sal_Int32 _nCount) -{ - sal_Char* pBuffer = new sal_Char[2 * _nCount + 1]; - memset(pBuffer, ' ', 2 * _nCount); - pBuffer[2 * _nCount] = 0; - // printf(pBuffer); -} - -//----------------------------------------------------------------------------- -void SAL_CALL OOpenNodeCallback::startElement( const ::rtl::OUString& _rName, const Reference< sax::XAttributeList >& xAttribs ) throw(sax::SAXException, RuntimeException) -{ - switch (m_eLastAction) - { - case STARTELEMENT: - if (m_bCloseStartTag) - { - // printf(">"); - } - - m_bCloseStartTag = sal_False; - // no break - case CHARACTERS: - case ENDELEMENT: - linefeed(); - printTabs(m_nLevel); - break; - } - m_eLastAction = STARTELEMENT; - ++m_nLevel; - // printf("<%s", ASCII_STRING(_rName)); - m_bCloseStartTag = sal_True; -} - -//----------------------------------------------------------------------------- -void SAL_CALL OOpenNodeCallback::endElement( const ::rtl::OUString& _rName ) throw(sax::SAXException, RuntimeException) -{ - --m_nLevel; - switch (m_eLastAction) - { - case STARTELEMENT: - if (m_bCloseStartTag) - { - // printf("/>"); - } - - m_bCloseStartTag = sal_False; - break; - case ENDELEMENT: - linefeed(); - printTabs(m_nLevel); - // dont break - case CHARACTERS: - // printf("</%s>", ASCII_STRING(_rName)); - break; - } - m_eLastAction = ENDELEMENT; -} - -//----------------------------------------------------------------------------- -void SAL_CALL OOpenNodeCallback::characters( const ::rtl::OUString& _rChars ) throw(sax::SAXException, RuntimeException) -{ - if (STARTELEMENT == m_eLastAction) - { - if (m_bCloseStartTag && _rChars.trim().getLength()) - { - // printf(">"); - m_bCloseStartTag = sal_False; - } - } - if (_rChars.trim().getLength() != 0) - { - // printf("%s", ASCII_STRING(_rChars)); - m_eLastAction = CHARACTERS; - } -} - -//----------------------------------------------------------------------------- -void OOpenNodeCallback::gotObjectId(const OUString &_nId) -{ - m_sNodeId = _nId; - // printf("object id %i\n", m_nNodeId); -} - -//----------------------------------------------------------------------------- -void OOpenNodeCallback::acknowledged(sal_Int32 _nTransId) -{ - // printf("acknowledged, transaction id : %i\n", _nTransId); -} - -//----------------------------------------------------------------------------- -void OOpenNodeCallback::failed(sal_Int32 _nErrorCode) -{ - // printf("failed because of a connection error (%i)\n", _nErrorCode); - m_rFinishCondition.set(); -} - -//----------------------------------------------------------------------------- -void OOpenNodeCallback::done(const StatusInfo& _rStatus) -{ - if (_rStatus.nCode) - { - printf("\n\ndone, but had an error : %s\n", ASCII_STRING(_rStatus.sMessage)); - } - else - { - // printf("\n\nsuccessfully done\n", ASCII_STRING(_rStatus.sMessage)); - } - - m_rFinishCondition.set(); -} - -//============================================================================= -//= ONodeUpdater -//============================================================================= -class ONodeUpdater : public IDOMNodeDataProvider -{ - sal_Bool m_bWriterLevel; - sal_Bool m_bAdd; -public: - ONodeUpdater(sal_Bool _bStartAtWriterLevel, sal_Bool bAdd) : m_bWriterLevel(_bStartAtWriterLevel), m_bAdd(bAdd) { } - - virtual void writeNodeData(const Reference< sax::XDocumentHandler >& _rHandler); -}; - -//----------------------------------------------------------------------------- -void ONodeUpdater::writeNodeData(const Reference< sax::XDocumentHandler >& _rHandler) -{ - AttributeListImpl *pAttr = new AttributeListImpl; - Reference< sax::XAttributeList > xEmptyAttrList = pAttr; - - pAttr = new AttributeListImpl; - pAttr->addAttribute(UNI_STRING("type"),UNI_STRING("CDATA"),UNI_STRING("string")); - Reference< sax::XAttributeList > xStringAttrList = pAttr; - - if (m_bWriterLevel) - _rHandler->startElement(UNI_STRING("Writer"), xEmptyAttrList); -#ifdef USE_LAYOUT_NODE - _rHandler->startElement(UNI_STRING("Layout"), xEmptyAttrList); - _rHandler->startElement(UNI_STRING("TabStops"), xEmptyAttrList); - if (m_bAdd) - _rHandler->characters(UNI_STRING("0.90")); - else - _rHandler->characters(UNI_STRING("99.99")); - - _rHandler->endElement(UNI_STRING("TabStops")); - _rHandler->endElement(UNI_STRING("Layout")); -#else - // _rHandler->startElement(UNI_STRING("com.sun.star.office.Setup"), xEmptyAttrList); - _rHandler->startElement(UNI_STRING("Modules"), xEmptyAttrList); - _rHandler->startElement(UNI_STRING("StandFonts"), xEmptyAttrList); - _rHandler->startElement(UNI_STRING("Standard"), xStringAttrList); - _rHandler->startElement(UNI_STRING("value"), xEmptyAttrList); - if (m_bAdd) - _rHandler->characters(UNI_STRING("Arial")); - else - _rHandler->characters(UNI_STRING("Courier")); - - _rHandler->endElement(UNI_STRING("value")); - _rHandler->endElement(UNI_STRING("Standard")); - _rHandler->endElement(UNI_STRING("StandFonts")); - _rHandler->endElement(UNI_STRING("Modules")); - // _rHandler->endElement(UNI_STRING("com.sun.star.office.Setup")); - - _rHandler->ignorableWhitespace(OUString()); -#endif - if (m_bWriterLevel) - _rHandler->endElement(UNI_STRING("Writer")); -} - -//============================================================================= -//= OSessionListener -//============================================================================= -class OSessionListener : public ISessionListener -{ -protected: - oslInterlockedCount m_refCount; - -public: - // ISessionListener - virtual void nodeUpdated(const ::rtl::OUString& _rNodePath); - virtual void nodeDeleted(const ::rtl::OUString& _rNodePath); - virtual void nodeAdded(const ::rtl::OUString& _rNodePath); - - // IInterface - virtual void SAL_CALL acquire( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL release( ) throw (::com::sun::star::uno::RuntimeException); -}; - -//----------------------------------------------------------------------------- -void OSessionListener::nodeUpdated(const ::rtl::OUString& _rNodePath) -{ - // printf("[listener] : a node was updated, node path : %s\n", ASCII_STRING(_rNodePath)); -} - -//----------------------------------------------------------------------------- -void OSessionListener::nodeDeleted(const ::rtl::OUString& _rNodePath) -{ - // printf("[listener] : a node was deleted, node path : %s\n", ASCII_STRING(_rNodePath)); -} - -//----------------------------------------------------------------------------- -void OSessionListener::nodeAdded(const ::rtl::OUString& _rNodePath) -{ - // printf("\n[listener] : a node was added, node path : %s", ASCII_STRING(_rNodePath)); -} - -//----------------------------------------------------------------------------- -void SAL_CALL OSessionListener::acquire( ) throw (::com::sun::star::uno::RuntimeException) -{ - osl_incrementInterlockedCount(&m_refCount); -} - -//----------------------------------------------------------------------------- -void SAL_CALL OSessionListener::release( ) throw (::com::sun::star::uno::RuntimeException) -{ - if (!osl_decrementInterlockedCount(&m_refCount)) - delete this; -} - -//============================================================================= -//============================================================================= - -//============================================================================= -static ::rtl::OUString sHost; -static sal_Int32 nPort; -static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb"); - -//============================================================================= -sal_Bool collectArgs(int argc, char * argv[]) -{ - if (argc > 1) - { - sal_Char* pConnectTo = argv[1]; - sal_Char* pSeparator = strchr(pConnectTo, ':'); - if (pSeparator && (0 != *(pSeparator + 1))) - { - sHost = ::rtl::OUString(pConnectTo, pSeparator - pConnectTo, RTL_TEXTENCODING_ASCII_US); - nPort = ::rtl::OUString::createFromAscii(pSeparator + 1).toInt32(); - - if (argc > 2) - sRegistry = ::rtl::OUString::createFromAscii(argv[2]); - return sal_True; - } - } - - printf("cfgclient - registry server client test ...\n\r\n\r"); - printf("usage :\n\r"); - printf(" cfgclient <server>:<port> [<registry file>]\n\r\n\r"); - printf(" <server> : machine to connect to\n\r"); - printf(" <port> : port to connect to\n\r"); - printf(" <registry file> : (optional) registry to bootstrap from. defaulted to \"applicat.rdb\"\n\r\n\r"); - return sal_False; -} - -//============================================================================= - -#if (defined UNX) || (defined OS2) -void main( int argc, char * argv[] ) -#else -void _cdecl main( int argc, char * argv[] ) -#endif -{ - Reference< XMultiServiceFactory > xORB; - try - { - xORB = createRegistryServiceFactory(sRegistry, ::rtl::OUString()); - } - catch (Exception& e) - { - printf("could not bootstrap the services from %s\n\r", ASCII_STRING(sRegistry)); - printf(" (error message : %s)", ASCII_STRING(e.Message)); - } - - if (!xORB.is()) - { - fprintf(stdout, "could not create the service factory !"); - return; - } - - ORef< OSessionListener > xListener = new OSessionListener; - { -/* - ORemoteSession aSession(xORB); - // --------- connect ---------- - sal_Bool bSuccess = aSession.connect(sHost, nPort, &aTimeout); - if (!bSuccess) - { - printf("could not connect to the server (error : %i) ...", aSession.getConnectionError()); - return; - } -*/ - - void testSession(const Reference< XMultiServiceFactory > &xORB, bool bPrint); - - for (int i=0;i<100;i++) - { - TimeValue aStartTime, aEndTime; - osl_getSystemTime(&aStartTime); - testSession(xORB, false); - osl_getSystemTime(&aEndTime); - - sal_Int32 nSeconds = aEndTime.Seconds - aStartTime.Seconds; - sal_Int32 nNanoSec = aEndTime.Nanosec - aStartTime.Nanosec; - if (nNanoSec < 0) - { - nNanoSec = 1000000000 - nNanoSec; - nSeconds++; - } - - cout << "Time: " << nSeconds << ". " << nNanoSec << endl; - } - } -} - -void testSession(const Reference< XMultiServiceFactory > &xORB, bool bPrint) -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - - // create it .. and connect - LocalSession aSession(xORB); - - // --------- openSession ---------- - - OUString aRootPath = OUString::createFromAscii("f:/local/SRC598/configmgr/workben/local_io"); - // f:/local/SRC595/configmgr/workben/local_io); - aSession.open(aRootPath); - - if (aSession.isOpen()) - { - if (bPrint) printf("\nopened the session ..."); - } - else - { - printf("\ncould not open the session ... exiting\n\n"); - return; - } - - // aSession.setListener(xListener.getBodyPtr()); - - OCondition aWaitForSomething; - aWaitForSomething.reset(); - - // --------- openNode ---------- - char* pWriterNode = "com.sun.star.Setup/Modules"; - if (bPrint) printf("\nsending an openNode request for %s ...\n", pWriterNode); - ORef< OOpenNodeCallback > xOpenCallback = new OOpenNodeCallback(aWaitForSomething); - aSession.openNode(UNI_STRING(pWriterNode), 2, xOpenCallback.getBodyPtr()); - - aTimeout.Seconds = 30; - switch (aWaitForSomething.wait(&aTimeout)) - { - case ICondition::result_error: - printf("error while waiting for the callback ... exiting\n\n"); - return; - case ICondition::result_timeout: - if (bPrint) printf("timed out ... exiting\n\n"); - return; - } - - OUString sOpenedNode = xOpenCallback->getNodeId(); - -// aSession.getNode(UNI_STRING("com.sun.star.Spreadsheet"), NULL); -// -// // --------- getNode (1) ---------- -//#ifdef USE_LAYOUT_NODE -// char* pLayoutNode = "com.sun.star.office.Setup/Modules"; -//#else - char* pLayoutNode = "com.sun.star.Setup/Modules"; -//#endif -// printf("\nsending an getNode request for %s ...\n", pLayoutNode); -// aWaitForSomething.reset(); -// aSession.getNode(UNI_STRING(pLayoutNode), new OOpenNodeCallback(aWaitForSomething)); -// -// switch (aWaitForSomething.wait(&aTimeout)) -// { -// case ICondition::result_error: -// printf("error while waiting for the callback ... exiting\n\n"); -// return; -// case ICondition::result_timeout: -// printf("timed out ... exiting\n\n"); -// return; -// } - - // --------- addNode ---------- - if (bPrint) printf("\n\naddNode ...."); - ONodeUpdater aAddTabstops(sal_False, true); // true = WRITER LEVEL - aWaitForSomething.reset(); - aSession.addNode(sOpenedNode, UNI_STRING(pLayoutNode), &aAddTabstops, new OOpenNodeCallback(aWaitForSomething)); - switch (aWaitForSomething.wait(&aTimeout)) - { - case ICondition::result_error: - printf("error while waiting for the callback ... exiting\n\n"); - return; - case ICondition::result_timeout: - if (bPrint) printf("timed out ... exiting\n\n"); - return; - } - - // --------- updateNode ---------- - if (bPrint) printf("\n\nokay, let's try an update ....\n"); - - ONodeUpdater aUpdateWriter(sal_False, false); - aWaitForSomething.reset(); - aSession.updateNode(sOpenedNode, UNI_STRING(pLayoutNode), &aUpdateWriter, new OOpenNodeCallback(aWaitForSomething)); - - switch (aWaitForSomething.wait(&aTimeout)) - { - case ICondition::result_error: - printf("error while waiting for the callback ... exiting\n\n"); - return; - case ICondition::result_timeout: - if (bPrint) printf("timed out ... exiting\n\n"); - return; - } - - // --------- deleteNode ---------- - char* pLayoutNode2 = "com.sun.star.Setup/Modules/StandFonts"; - - if (bPrint) printf("\n\ndeleteNode ...."); - aWaitForSomething.reset(); - aSession.deleteNode(sOpenedNode, UNI_STRING(pLayoutNode2), new OOpenNodeCallback(aWaitForSomething)); - switch (aWaitForSomething.wait(&aTimeout)) - { - case ICondition::result_error: - printf("error while waiting for the callback ... exiting\n\n"); - return; - case ICondition::result_timeout: - if (bPrint) printf("timed out ... exiting\n\n"); - return; - } - -/* - // --------- startListening ---------- - printf("\n\nadding a listener for the Layout node\n"); - Sequence< ::rtl::OUString > aNodesToListen(1); - aNodesToListen[0] = UNI_STRING(pLayoutNode); - aSession.startListening(aNodesToListen, NULL); - - printf("waiting 10 seconds ....\n\n"); - aWaitForSomething.reset(); - aTimeout.Seconds = 10; - aWaitForSomething.wait(&aTimeout); -*/ - // --------- getNode (2) ---------- -// printf("\ndoing a new getNode for the Layout node ...\n"); -// aWaitForSomething.reset(); -// aSession.getNode(UNI_STRING(pLayoutNode), new OOpenNodeCallback(aWaitForSomething)); -// switch (aWaitForSomething.wait(&aTimeout)) -// { -// case ICondition::result_error: -// printf("error while waiting for the callback ... exiting\n\n"); -// return; -// case ICondition::result_timeout: -// printf("timed out ... exiting\n\n"); -// return; -// } - - aSession.closeNode(sOpenedNode, NULL); - aSession.close(NULL); - -} - diff --git a/configmgr/workben/local_io/com.sun.star.office.Setup.xml b/configmgr/workben/local_io/com.sun.star.office.Setup.xml deleted file mode 100644 index 4018ab3b8d5d..000000000000 --- a/configmgr/workben/local_io/com.sun.star.office.Setup.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<com.sun.star.office.Setup> - <Language> - <Language_ID Type="string"><value>1033</value></Language_ID> - </Language> - <Modules> - <SCalc Type="boolean"> - <value>true</value> - </SCalc> - <SChart Type="boolean"> - <value>true</value> - </SChart> - <SDraw Type="boolean"> - <value>true</value> - </SDraw> - <SImage Type="boolean"> - <value>true</value> - </SImage> - <SImpress Type="boolean"> - <value>true</value> - </SImpress> - <SMath Type="boolean"> - <value>true</value> - </SMath> - <SWriter Type="boolean"> - <value>true</value> - </SWriter> - </Modules> -</com.sun.star.office.Setup>
\ No newline at end of file diff --git a/configmgr/workben/local_io/filetest.cxx b/configmgr/workben/local_io/filetest.cxx deleted file mode 100644 index 0a8038e3ae29..000000000000 --- a/configmgr/workben/local_io/filetest.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#include <iostream> -#include<osl/file.hxx> - -#include <rtl/ustring.hxx> -#include <com/sun/star/uno/Sequence.hxx> - -// ----------------------------------------------------------------------------- -// --------------------------------- namespaces --------------------------------- -// ----------------------------------------------------------------------------- -using namespace com::sun::star::uno; - -using ::rtl::OUString; -using ::osl::File; -// ----------------------------------------------------------------------------- -// ---------------------------------- defines ---------------------------------- -// ----------------------------------------------------------------------------- -#define ASCII(x) OUString::createFromAscii(x) - - -// ----------------------------------------------------------------------------- -// ------------------------------------ main ------------------------------------ -// ----------------------------------------------------------------------------- - -/* -OUString operator+(const OUString &a, const OUString &b) -{ - OUString c = a; - c += b; - return c; -} -*/ - -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - OUString aPath = ASCII("f:/local/SRC598/configmgr/workben/local_io"); - OUString aFilename = ASCII("com.sun.star.office.Setup"); - OUString aExtension = ASCII("xml"); - - OUString aFullname = aPath + ASCII("/") + aFilename + ASCII(".") + aExtension; - - // Filename convertieren - OUString aURL; - File aConvert(ASCII("")); - aConvert.normalizePath(aFullname, aURL); - - // File oeffnen - File aFile(aURL); - aFile.open(osl_File_OpenFlag_Read); - - sal_uInt64 nBytesRead; - Sequence< sal_Int8 > aBufferSeq(2000); - sal_Int8 *pBuff = aBufferSeq.getArray(); - aFile.read(pBuff, 2000, nBytesRead); - - aFile.close(); - return 0; -} diff --git a/configmgr/workben/local_io/makefile.mk b/configmgr/workben/local_io/makefile.mk deleted file mode 100644 index 4e3e2f7d2f40..000000000000 --- a/configmgr/workben/local_io/makefile.mk +++ /dev/null @@ -1,110 +0,0 @@ -#************************************************************************* -# -# 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=..$/.. -PRJINC=$(PRJ)$/source - -PRJNAME=configmgr - -TARGET=cfgfile -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -# ... common for all test executables .............................. -APPSTDLIBS=\ - $(SALLIB) \ - $(VOSLIB) \ - $(CPPULIB) \ - $(UNOTOOLSLIB) \ - $(CPPUHELPERLIB) \ - - -# ... FileTests ..................................................... -APP1STDLIBS = $(APPSTDLIBS) \ - $(STDLIBCPP) \ - -APP1STDLIBS+=$(STDLIBCPP) - -APP1TARGET= $(TARGET) - -APP1OBJS= \ - $(SLO)$/cfgfile.obj \ - $(SLO)$/oslstream.obj \ - $(SLO)$/filehelper.obj \ - $(SLO)$/simpletest.obj \ - $(SLO)$/strimpl.obj \ - $(SLO)$/confname.obj \ - -# $(SLO)$/xmlexport.obj \ -# $(SLO)$/xmlimport.obj \ - -# $(SLO)$/xmltreebuilder.obj \ -# $(SLO)$/cmtree.obj \ -# $(SLO)$/cmtreemodel.obj \ -# $(SLO)$/typeconverter.obj \ -# $(SLO)$/changes.obj \ -# $(SLO)$/xmlformater.obj \ -# $(SLO)$/attributes.obj \ -# $(SLO)$/tracer.obj \ - - -# ... common for all test executables .............................. -# APP2STDLIBS = $(APPSTDLIBS) -# -# APP2STDLIBS+=$(STDLIBCPP) -# -# APP2TARGET= cfglocal -# APP2OBJS= \ -# $(SLO)$/cfglocal.obj \ -# $(SLO)$/receivethread.obj \ -# $(SLO)$/redirector.obj \ -# $(SLO)$/socketstream.obj \ -# $(SLO)$/attributes.obj \ -# $(SLO)$/localsession.obj \ -# $(SLO)$/saxtools.obj \ -# $(SLO)$/mergeupdates.obj \ -# $(SLO)$/oslstream.obj \ -# $(SLO)$/configsession.obj \ -# $(SLO)$/confname.obj \ -# $(SLO)$/sessionstream.obj \ -# $(SLO)$/filehelper.obj \ -# $(SLO)$/tracer.obj \ -# $(SLO)$/updatedom.obj \ -# $(SLO)$/strconverter.obj \ -# $(SLO)$/strimpl.obj \ -# - -.INCLUDE : target.mk - - diff --git a/configmgr/workben/local_io/org.openoffice.test.xml b/configmgr/workben/local_io/org.openoffice.test.xml deleted file mode 100644 index ff8e37be411c..000000000000 --- a/configmgr/workben/local_io/org.openoffice.test.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> - -<org.openoffice.test -xmlns="http://openoffice.org/2000/registry/components/org.openoffice.Inet" -xmlns:cfg="http://openoffice.org/2000/registry/instance" -xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xml:lang="en-US"> - -<!-- long --> - <Long cfg:type="long">100000000000000</Long> - <LongList cfg:type="long" cfg:derivedBy="list">1 2 3 - - 4 5 - - - - - 6 7 8 9</LongList> - <LongList2 cfg:type="long" cfg:derivedBy="list" cfg:separator=".">1.2.3.4.5.6.7.8.9</LongList2> - -<!-- double --> - <DoubleWithDot cfg:type="double">.787564</DoubleWithDot> - <EuroDM cfg:type="double">1.95583</EuroDM> - <ZeroDotZeroZeroOne cfg:type="double">0.001</ZeroDotZeroZeroOne> - <ZeroDotOne cfg:type="double">0.1</ZeroDotOne> - <NZeroDotOne cfg:type="double">-0.1</NZeroDotOne> - -<!-- binary --> - <Binary cfg:type="binary" cfg:nullable="true" xsi:null="true"/> - <Binary2 cfg:type="binary" xsi:null="true"/> - <Binary3 cfg:type="binary" >010203040506070809</Binary3> - <Binary4 cfg:type="binary" cfg:nullable="true">000102030405060708090a</Binary4> - -<!-- Strings --> - <NullString cfg:type="string" xsi:null="true"/> - <String cfg:type="string">Identifier</String> - <StringList cfg:type="string" cfg:derivedBy="list">file:/ private:explorer private:help private:newmenu private:schedule private:searchfolder private:user</StringList> - <List cfg:type="string" cfg:derivedBy="list">NULL</List> - <PathAutoCorrect cfg:type="string" cfg:separator=":" cfg:derivedBy="list">$(inst)/share/autocorr:$(user)/autocorr</PathAutoCorrect> - <List2 cfg:type="string" cfg:derivedBy="list" cfg:separator="stupid" >NULLstupidFIRSTstupidSECONDstupid</List2> - <SeparatorKiller cfg:type="string" cfg:derivedBy="list" cfg:separator="." > .,.;.:.#.|.a._.!.$.%./.(.)=.?.+.*.#.~.'.\.{.}._</SeparatorKiller> - -<!-- localized --> - <LocaleString cfg:type="string" cfg:localized="true"> - <cfg:value xml:lang="en-US">This is a string</cfg:value> - <cfg:value xml:lang="de-DE">Dies ist ein String</cfg:value> - </LocaleString> - -<!-- boolean --> - <BoolFalse cfg:type="boolean">false</BoolFalse> - <BoolTrue cfg:type="boolean">true</BoolTrue> - <BoolList cfg:type="boolean" cfg:derivedBy="list">true true false</BoolList> - <BoolNULL cfg:type="boolean" xsi:null="true"/> - -<!-- int --> - <Integer cfg:type="int">3</Integer> - <IntegerNullWithXsi cfg:type="int" xsi:null="true">10</IntegerNullWithXsi> - <IntegerNull cfg:type="int"/> - - <IntList cfg:type="int" cfg:derivedBy="list">1 2 3 4 5 6 7 8 224 226 222 223 5</IntList> - -<!-- short --> - <Short cfg:type="short">100</Short> - - <Inner> - <Inner2> - <IntList cfg:type="int" cfg:derivedBy="list">224 226 222 223 5</IntList> - </Inner2> - </Inner> - -</org.openoffice.test> diff --git a/configmgr/workben/local_io/simpletest.cxx b/configmgr/workben/local_io/simpletest.cxx deleted file mode 100644 index ffe4741d7d2c..000000000000 --- a/configmgr/workben/local_io/simpletest.cxx +++ /dev/null @@ -1,758 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include <memory> -#include <vector> -#include <stack> -#include<osl/file.hxx> - -#include <rtl/ustring.hxx> -#include <rtl/string.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/servicefactory.hxx> - -#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_ -#include <com/sun/star/lang/XComponent.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HDL_ -#include <com/sun/star/io/XActiveDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HDL_ -#include <com/sun/star/io/XActiveDataSink.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATACONTROL_HDL_ -#include <com/sun/star/io/XActiveDataControl.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XDATATRANSFEREVENTLISTENER_HDL_ -#include <com/sun/star/io/XDataTransferEventListener.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XDATAIMPORTER_HDL_ -#include <com/sun/star/io/XDataImporter.hpp> -#endif - -#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HDL_ -#include <com/sun/star/io/XInputStream.hpp> -#endif -#include <com/sun/star/xml/sax/XParser.hpp> -#include <com/sun/star/xml/sax/SAXParseException.hpp> -#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> - -#include <com/sun/star/xml/sax/InputSource.hpp> -#include <vos/thread.hxx> - -#include <vos/pipe.hxx> -#include <osl/diagnose.h> -#include "oslstream.hxx" -#include <com/sun/star/xml/sax/XAttributeList.hpp> - -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> - -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/script/XTypeConverter.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <osl/conditn.hxx> - -#include "xmltreebuilder.hxx" - -#include "dataimport.hxx" - -#include "createpropertyvalue.hxx" -#include "strdecl.hxx" - -#include "confname.hxx" - -#include "FileHelper.hxx" - -// ----------------------------------------------------------------------------- -// --------------------------------- namespaces --------------------------------- -// ----------------------------------------------------------------------------- -namespace uno = com::sun::star::uno; -namespace lang = com::sun::star::lang; -namespace io = com::sun::star::io; -namespace sax = com::sun::star::xml::sax; -namespace script = com::sun::star::script; - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::xml::sax; -using namespace ::com::sun::star::io; -using namespace rtl; -using namespace osl; - -// ----------------------------------------------------------------------------- -// ---------------------------------- defines ---------------------------------- -// ----------------------------------------------------------------------------- -#ifndef ASCII -#define ASCII(x) OUString::createFromAscii(x) -#endif - -ostream& operator << (ostream& out, rtl::OUString const& aStr) -{ - sal_Unicode const* const pStr = aStr.getStr(); - sal_Unicode const* const pEnd = pStr + aStr.getLength(); - for (sal_Unicode const* p = pStr; p < pEnd; ++p) - if (0 < *p && *p < 127) // ASCII - out << char(*p); - else - out << "[\\u" << hex << *p << "]"; - return out; -} - - -// ----------------------------------------------------------------------------- -// ---------------------------------- a Class ---------------------------------- -// ----------------------------------------------------------------------------- -// <Name a="xyz" b="bar"> - -//========================================================================== -//= Visitors -//========================================================================== - - -namespace configmgr -{ - - class XMLSimpleDocHandler : public ::cppu::WeakImplHelper1<sax::XDocumentHandler> - { - // uno::Reference< sax::XDocumentHandler > m_xWriter; // the service object for writing XML code - - sal_Int32 m_nElementDepth; - sal_Int32 m_nIgnoreLevel; - public: - XMLSimpleDocHandler::XMLSimpleDocHandler() - {} - - - // DECLARE_UNO3_DEFAULTS(XMLReadFilter, CmDocumentHandler_BASE); - - // XDocumentHandler - virtual void SAL_CALL startDocument(void) - throw (sax::SAXException, uno::RuntimeException) - { - } - - virtual void SAL_CALL endDocument(void) - throw(sax::SAXException, uno::RuntimeException) - { - } - - virtual void SAL_CALL startElement(const rtl::OUString& aName, - const uno::Reference< sax::XAttributeList > &_xAttrList) - throw(sax::SAXException, uno::RuntimeException) - { - sal_Int16 nAttrCount = _xAttrList.is() ? _xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - OUString aParamName( _xAttrList->getNameByIndex( i ) ); - OUString aParamValue( _xAttrList->getValueByIndex( i ) ); - volatile int dummy = 0; - } - } - - virtual void SAL_CALL endElement(const rtl::OUString& aName) - throw(sax::SAXException, uno::RuntimeException) - { - } - - virtual void SAL_CALL characters(const rtl::OUString& aChars) - throw(sax::SAXException, uno::RuntimeException) - {} - - - virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces) - throw(sax::SAXException, uno::RuntimeException) - {} - - - virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget, - const rtl::OUString& aData) - throw(sax::SAXException, uno::RuntimeException) - {} - - virtual void SAL_CALL setDocumentLocator(const uno::Reference< sax::XLocator > &xLocator) - throw(sax::SAXException, uno::RuntimeException) - {} - }; - -// ----------------------------------------------------------------------------- -// ------------------------------------ Test ------------------------------------ -// ----------------------------------------------------------------------------- -#define ASCII_STRING(rtlOUString) rtl::OUStringToOString(rtlOUString, RTL_TEXTENCODING_ASCII_US).getStr() - static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb"); - - void simpleTest() - { - uno::Reference< lang::XMultiServiceFactory > xMSF; - try - { - xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString()); - } - catch (uno::Exception& e) - { - cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ; - cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl; - } - - if (!xMSF.is()) - { - cerr << "could not create the service factory !" << endl; - return; - } - - OUString aPath = ASCII("e:/temp/Test"); - OUString aFilename = ASCII("calc"); - OUString aExtension = ASCII("xml"); - - OUString aFullname = aPath + ASCII("/") + aFilename + ASCII(".") + aExtension; - - // Filename convertieren - OUString aURL; - File aConvert(ASCII("")); - aConvert.normalizePath(aFullname, aURL); - - // File oeffnen - File aFile(aURL); - aFile.open(osl_File_OpenFlag_Read); - - uno::Reference<io::XInputStream> xInputStream = - new configmgr::OSLInputStreamWrapper(aFile); - - // connect stream to input stream to the parser - InputSource aInputSource; - Reference<XInputStream> xPipeInput( xInputStream, UNO_QUERY ); - aInputSource.aInputStream = xPipeInput; - - Reference< sax::XParser > xParser; - xParser = Reference< sax::XParser > ( - xMSF->createInstance( - ::rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser")), UNO_QUERY); - - XMLSimpleDocHandler *pTest = new XMLSimpleDocHandler(); - - // get filter - Reference<XDocumentHandler> xFilter = pTest; - - // connect parser and filter - xParser->setDocumentHandler( xFilter ); - - // parse - sal_Int16 nRet = 0; - OUString sError; - try - { - xParser->parseStream( aInputSource ); - } - catch( SAXParseException &e ) - { - OUString sLine = OUString::valueOf(e.LineNumber); - OUString aStr = ASCII("SAXParseException occured in "); - sError = aStr + ASCII(" Line: (") + sLine + ASCII(")"); - - OSL_ENSURE(0, rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US).getStr()); - nRet = 3; - } - catch( SAXException &e ) - { - sError = e.Message; - OSL_ENSURE(0, rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US).getStr()); - nRet = 4; - } - catch( IOException &e ) - { - sError = e.Message; - OSL_ENSURE(0, rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US).getStr()); - nRet = 5; - } - } - - -#include <osl/time.h> -#include <rtl/string.hxx> - -class TimeTest -{ - TimeValue m_aStartTime, m_aEndTime; - bool m_bStarted; -public: - TimeTest() - :m_bStarted(false) - { - } - - void start() - { - m_bStarted = true; - osl_getSystemTime(&m_aStartTime); - } - void stop() - { - osl_getSystemTime(&m_aEndTime); - OSL_ENSURE(m_bStarted, "Not Started."); - m_bStarted = false; - } - void showTime(const rtl::OString & aWhatStr) - { - OSL_ENSURE(!m_bStarted, "Not Stopped."); - - sal_Int32 nSeconds = m_aEndTime.Seconds - m_aStartTime.Seconds; - sal_Int32 nNanoSec = m_aEndTime.Nanosec - m_aStartTime.Nanosec; - if (nNanoSec < 0) - { - nNanoSec = 1000000000 - nNanoSec; - nSeconds++; - } - rtl::OString aStr = "Time for "; - aStr += aWhatStr; - aStr += " : "; - aStr += rtl::OString::valueOf(nSeconds); - aStr += "."; - aStr += rtl::OString::valueOf(nNanoSec); - - cout << aStr.getStr() << endl; - } - -}; - -// ----------------------------------------------------------------------------- -// -------------------------------- Mapping Test -------------------------------- -// ----------------------------------------------------------------------------- -// Simple Map created with a stl::vector - -typedef ::std::pair< rtl::OUString, rtl::OUString > Assoc; -// typedef ::std::set<Assoc, ltNode> MappingTable; -typedef std::vector<Assoc> MappingTable; - -rtl::OUString mapTo(const rtl::OUString& aFrom, bool bToNew) -{ - static MappingTable aMap; - if (aMap.empty()) - { - // Fill Map old, new - - aMap.push_back(Assoc(ASCII("value"), TAG_VALUE)); - aMap.push_back(Assoc(ASCII("type"), ATTR_TYPE)); - aMap.push_back(Assoc(ASCII("instance"), ATTR_INSTANCE)); - } - if (bToNew) - { - // check, if we should convert first to second - for (std::vector<Assoc>::const_iterator it = aMap.begin();it != aMap.end();++it) - { - if ((*it).first.equals(aFrom)) - return (*it).second; - } - } - else - { - // check if we should convert second to first - for (std::vector<Assoc>::const_iterator it = aMap.begin();it != aMap.end();++it) - { - if ((*it).second.equals(aFrom)) - return (*it).first; - } - } - - // do nothing! - return aFrom; -} -// ----------------------------------------------------------------------------- -void simpleMappingTest() -{ - OUString aValue = ASCII("value"); - OUString aNew; - - aNew = mapTo(aValue, true); // true for ToNew - aNew = mapTo(aNew, false); - aNew = mapTo(aNew, false); - - volatile int dummy = 0; -} - -// ----------------------------------------------------------------------------- - void speedTest() - { - // check speed of: - // ASCII("value") - // TAG_VALUE - // ... - - sal_Int32 nCount = 1000 * 1000 * 100; - sal_Int32 n; - - cout << "Starting Timetest" << endl; - TimeTest tt; - tt.start(); - for(n=0;n<nCount;n++) - { - } - tt.stop(); - tt.showTime("Leere Schleife: "); - - - nCount = 1000 * 1000 * 5; - rtl::OUString aStr; - - tt.start(); - for(n=0;n<nCount;n++) - { - aStr = ASCII("value"); - } - tt.stop(); - tt.showTime("ASCII() "); - - - OUString aValue = ASCII("value"); - tt.start(); - for(n=0;n<nCount;n++) - { - aStr = TAG_VALUE; - } - tt.stop(); - tt.showTime("TAG_VALUE: "); - - } - -OUString changeToComSunStarPath(const OUString &aPath) -{ - static OUString aOO = ASCII("org.OpenOffice"); - static OUString aCSS = ASCII("com.sun.star"); - OUString aNewPath; - - // compare - if (aPath.compareTo( aOO, aOO.getLength() ) == 0) - { - aNewPath = aCSS; - aNewPath += aPath.copy(aOO.getLength()); - return aNewPath; - } - return aPath; -} - -void stringTest2() -{ - OUString aPath = ASCII("org.OpenOffice.Setup/blah/blub"); - - OUString aNewPath = changeToComSunStarPath(aPath); - volatile int dummy = 0; -} - -/* - -class A -{ -public: - static void run() { - cout << "This is A::run();" << endl; - } - -}; - -class B : public A -{ -public: - - static void run() { - cout << "This is B::run();" << endl; - } -}; - -void classTest() -{ - A a; - B b; - B::run(); -} -*/ - -// ----------------------------------------------------------------------------- -// ------------------------------------ Map ------------------------------------ -// ----------------------------------------------------------------------------- -struct ltstr -{ - bool operator()(const rtl::OUString &s1, const rtl::OUString &s2) const - { - return s1.compareTo(s2) < 0 ? true : false; - } -}; - -void stringTest() -{ - map<const OUString, int, ltstr> months; - - months[ASCII("january")] = 31; - months[ASCII("february")] = 28; - months[ASCII("march")] = 31; - months[ASCII("april")] = 30; - months[ASCII("may")] = 31; - months[ASCII("june")] = 30; - months[ASCII("july")] = 31; - months[ASCII("august")] = 31; - months[ASCII("september")] = 30; - months[ASCII("october")] = 31; - months[ASCII("november")] = 30; - months[ASCII("december")] = 31; - - cout << "june -> " << months[ASCII("june")] << endl; - map<const OUString, int, ltstr>::iterator cur = months.find(ASCII("april")); - // map<const OUString, int, ltstr>::iterator prev = cur; - map<const OUString, int, ltstr>::iterator next = cur; - // ++next; - // --prev; - // cout << "Previous (in alphabetical order) is " << (*prev).first << endl; - for(int i=0;i<12;i++) - { - cout << "Next (in alphabetical order) is " << (*next).first << " days " << (*next).second << endl; - ++next; - } -} - -// ----------------------------------------------------------------------------- -// ---------------------------------- HashMap ---------------------------------- -// ----------------------------------------------------------------------------- -#include <hash_map> - - -namespace test { - -struct eqstr -{ - bool operator()(const rtl::OUString &s1, const rtl::OUString &s2) const - { - return s1.equals(s2) == sal_True ? true : false; - } -}; - -struct hash_oustring -{ - // This hash funktion is a copy of hash<char*> from SGI-STL - size_t operator()(const rtl::OUString &_s) const - { - sal_Int64 nStrLen = _s.getLength(); - const sal_Unicode *pStr = _s.getStr(); - unsigned long h = 0; - for (sal_Int64 i=0;i<nStrLen; ++i) - h = 5*h + *pStr++; - - return size_t(h); - } -}; - -void hash_test() -{ - hash_map<const rtl::OUString, rtl::OUString, hash_oustring, eqstr> months; - - rtl::OUString sJanuary = ASCII("january"); - months[sJanuary] = ASCII("31"); - months[ASCII("february")] = ASCII("28"); - months[ASCII("march")] = ASCII("31"); - months[ASCII("april")] = ASCII("30"); - months[ASCII("may")] = ASCII("31"); - months[ASCII("june")] = ASCII("30"); - months[ASCII("july")] = ASCII("31"); - months[ASCII("august")] = ASCII("31"); - months[ASCII("september")] = ASCII("30"); - months[ASCII("october")] = ASCII("31"); - months[ASCII("november")] = ASCII("30"); - months[ASCII("december")] = ASCII("31"); - - cout << "september -> " << months[ASCII("september")] << endl; - cout << "april -> " << months[ASCII("april")] << endl; - cout << "june -> " << months[ASCII("june")] << endl; - cout << "november -> " << months[ASCII("november")] << endl; -} -} - - -// ----------------------------------------------------------------------------- -// Fri Nov 10 15:10:45 2000 -// ----------------------------------------------------------------------------- - -#include <vos/ref.hxx> - -class Options : public vos::OReference -{ - int m_aValue; -public: - int getValue() {return m_aValue;} - void setValue(int _aValue) {m_aValue = _aValue;} - - -}; - -class A -{ - vos::ORef<Options> m_aOptions; -public: - - vos::ORef<Options> getOptions() {return m_aOptions;} - void setOptions(vos::ORef<Options>& _aOptions) { - m_aOptions = _aOptions; - } -}; - -void testRefs() -{ - vos::ORef<Options> aO = new Options; - aO->setValue(10); - - A a,b; - a.setOptions(aO); - b.setOptions(aO); - cout << "Options from a : " << a.getOptions()->getValue() << endl; - cout << "Options from b : " << b.getOptions()->getValue() << endl; - - aO->setValue(20); - cout << "Options from a : " << a.getOptions()->getValue() << endl; - cout << "Options from b : " << b.getOptions()->getValue() << endl; -} - - - -void ConfigName() -{ - // OUString aSubtreePath = ASCII("/org.openoffice.office.common/path/blah/blub"); - OUString aSubtreePath = ASCII("/org.openoffice.office.common"); - ConfigurationName aName(aSubtreePath); - OUString a = aName.localName(); - OUString b = aName.fullName(); - OUString c = aName.moduleName(); - ConfigurationName aParentName(aName.getParentName()); - OUString d = aParentName.fullName(); - - - { - ConfigurationName aName( ASCII("/" )); - - std::stack< rtl::OUString, std::vector<rtl::OUString> > m_aStringStack; - - if (aName.localName().getLength() != 0) - { - for (ConfigurationName::Iterator it = aName.begin(); - it != aName.end(); - ++it) - { - rtl::OUString aName = *it; - m_aStringStack.push(aName); - // m_xHandler->startElement(*it, rList); - volatile int dummy = 0; - } - } - - // bBack = writeChanges(); - - while(!m_aStringStack.empty()) - { - OUString aName = m_aStringStack.top(); - m_aStringStack.pop(); - } - } -} - -void ConfigName2() -{ - OUString aSubtreePath = ASCII("/org.openoffice.office.common/path/blah/blub"); - ConfigurationName aName(aSubtreePath); - ConfigurationName aParent = aName.getParentName(); - - for (ConfigurationName::Iterator it = aName.begin(); - it != aName.end(); - ++it) - { - rtl::OUString aName = *it; - volatile int dummy = 0; - } -} - -// ----------------------------------------------------------------------------- -inline void operator <<= (rtl::OUString& _rUnicodeString, const sal_Char* _pAsciiString) -{ - _rUnicodeString = ::rtl::OUString::createFromAscii(_pAsciiString); -} - -inline void operator <<= (rtl::OUString& _rUnicodeString, const rtl::OString& _rAsciiString) -{ - _rUnicodeString <<= _rAsciiString.getStr(); -} - -inline void operator <<= (rtl::OString& _rAsciiString, const rtl::OUString& _rUnicodeString) -{ - _rAsciiString = rtl::OUStringToOString(_rUnicodeString,RTL_TEXTENCODING_ASCII_US); -} - -// ----------------------------------------------------------------------------- -bool isBTimeGreaterATime(TimeValue const& A, TimeValue const& B) -{ - if (B.Seconds > A.Seconds) return true; - if (B.Nanosec > A.Nanosec) return true; - - // lower or equal - return false; -} - -// ----------------------------------------------------------------------------- - -void oslTest() -{ - - OUString aDirectory(FileHelper::convertFilenameToFileURL(ASCII("c:/temp/file.out.1"))); - TimeValue a = FileHelper::getFileModificationStamp(aDirectory); - - OUString aDirectory2(FileHelper::convertFilenameToFileURL(ASCII("c:/temp/file.out.2"))); - TimeValue b = FileHelper::getFileModificationStamp(aDirectory2); - - if (isBTimeGreaterATime(a,b)) - { - OSL_ENSURE(false, "FileB ist neuer als FileA"); - } - - -/* - OUString aDirectory(FileHelper::convertFilenameToFileURL(ASCII("c:/temp/dies"))); - osl::FileBase::RC eError = osl::Directory::create(aDirectory); - if (eError != osl::FileBase::E_None) - { - OUString aUStr = FileHelper::createOSLErrorString(eError); - OString aStr; - aStr <<= aUStr; - OSL_ENSURE(false, aStr.getStr()); - } -*/ -} - -} // namespace configmgr diff --git a/configmgr/workben/local_io/xmlexport.cxx b/configmgr/workben/local_io/xmlexport.cxx deleted file mode 100644 index 3312f6ffb1ff..000000000000 --- a/configmgr/workben/local_io/xmlexport.cxx +++ /dev/null @@ -1,236 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include<iostream> -#include<osl/file.hxx> - -#include <rtl/ustring.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/servicefactory.hxx> -/* -#include <cppuhelper/implbase1.hxx> -*/ -#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_ -#include <com/sun/star/lang/XComponent.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XDATATRANSFEREVENTLISTENER_HDL_ -#include <com/sun/star/io/XDataTransferEventListener.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XDATAIMPORTER_HDL_ -#include <com/sun/star/io/XDataExporter.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HDL_ -#include <com/sun/star/io/XOutputStream.hpp> -#endif -#include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/xml/sax/SAXParseException.hpp> -#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> -#include <osl/diagnose.h> -#include <com/sun/star/xml/sax/XAttributeList.hpp> - -#include "oslstream.hxx" -#include "attributes.hxx" -#include "typeconverter.hxx" -#include "xmlformater.hxx" -#include "filehelper.hxx" - - -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/lang/IllegalArgumentException.hpp> - -#include "createpropertyvalue.hxx" -// ----------------------------------------------------------------------------- -// --------------------------------- namespaces --------------------------------- -// ----------------------------------------------------------------------------- -namespace configmgr -{ - - namespace uno = com::sun::star::uno; - namespace lang = com::sun::star::lang; - namespace io = com::sun::star::io; - namespace sax = com::sun::star::xml::sax; - namespace beans = com::sun::star::beans; - - using ::rtl::OUString; - using ::osl::File; - - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::container; - -// ----------------------------------------------------------------------------- -// ---------------------------------- defines ---------------------------------- -// ----------------------------------------------------------------------------- -#define ASCII(x) OUString::createFromAscii(x) - -// ----------------------------------------------------------------------------- - class Listener : public ::cppu::WeakImplHelper1<io::XDataTransferEventListener> - { - virtual void SAL_CALL disposing( const lang::EventObject& Source ) - throw(::com::sun::star::uno::RuntimeException) - { - OSL_ENSURE(0, "disposing"); - } - - - virtual void SAL_CALL finished( const io::DataTransferEvent& aEvent ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "finished"); - } - - virtual void SAL_CALL cancelled( const io::DataTransferEvent& aEvent ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "cancelled"); - } - }; - - class Component: public ::cppu::WeakImplHelper1<lang::XComponent> - { - virtual void SAL_CALL dispose( ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "dispose"); - - } - virtual void SAL_CALL addEventListener( const uno::Reference< lang::XEventListener >& xListener ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "addEventListener"); - } - virtual void SAL_CALL removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "removeEventListener"); - } - }; - - - - - -#define ASCII_STRING(rtlOUString) rtl::OUStringToOString(rtlOUString, RTL_TEXTENCODING_ASCII_US).getStr() - static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb"); - - - - - - - - -// ----------------------------------------------------------------------------- - -// ----------------------------------------------------------------------------- - void exportTest() - { - uno::Reference< lang::XMultiServiceFactory > xMSF; - try - { - xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString()); - } - catch (uno::Exception& e) - { - cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ; - cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl; - } - - if (!xMSF.is()) - { - cerr << "could not create the service factory !" << endl; - return; - } - - OUString aPath = ASCII("l:/SRC601/configmgr/workben/local_io"); - OUString sFilename = ASCII("exported_config"); - OUString aExtension = ASCII("xml"); - - OUString aFullname = aPath + ASCII("/") + sFilename + ASCII(".") + aExtension; - - // Filename convertieren - OUString aURL; - File aConvert(ASCII("")); - aConvert.normalizePath(aFullname, aURL); - - FileHelper::tryToRemoveFile(aURL); - - rtl::OUString sError; - - // File oeffnen - File aFile(aURL); - osl::FileBase::RC eError = aFile.open(OpenFlag_Write | OpenFlag_Create); - - if (eError != osl_File_E_None) - { - sError = ASCII("XMLExportTest:"); - rtl::OString aStr = rtl::OUStringToOString(sError,RTL_TEXTENCODING_ASCII_US); - OSL_ENSURE(0, aStr.getStr()); - return; - } - - // create an outputstream - uno::Reference<io::XOutputStream> xOutputStream = new configmgr::OSLOutputStreamWrapper(aFile); - - // Listener & Component - uno::Reference<io::XDataTransferEventListener> rListener = new Listener(); - uno::Reference<lang::XComponent> rComponent = new Component(); - - - OUString sPath = ASCII("com.sun.star.ucb.Hierarchy"); - - // Create a TypeConverter - uno::Reference<script::XTypeConverter> aConverter; - aConverter = aConverter.query(xMSF->createInstance(ASCII( "com.sun.star.script.Converter" )) ); - - // prepare parameters for DataExport - Sequence< uno::Any > aArgs(4); - aArgs[0] <<= createPropertyValue(ASCII("PackageName"), sFilename); - aArgs[1] <<= createPropertyValue(ASCII("Path"), sPath); // multiple occur possible - aArgs[2] <<= createPropertyValue(ASCII("TypeConverter"), aConverter); // optional - aArgs[3] <<= createPropertyValue(ASCII("Path"), ASCII("com.sun.star.office.Setup")); // multiple occur possible - - // important: createInstanceWithArguments will throw an IllegalArgumentException() if - // parameters are wrong... - Reference< XInterface > xDataExport = xMSF->createInstanceWithArguments( - OUString::createFromAscii("com.sun.star.configuration.DataExport"), - aArgs); - - uno::Reference<io::XDataExporter> rExporter(xDataExport, UNO_QUERY); - - // Export Data - rExporter->exportData(xOutputStream, rComponent, rListener); - } - -} // namespace configmgr diff --git a/configmgr/workben/local_io/xmlimport.cxx b/configmgr/workben/local_io/xmlimport.cxx deleted file mode 100644 index e1d2a6ebb823..000000000000 --- a/configmgr/workben/local_io/xmlimport.cxx +++ /dev/null @@ -1,469 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include <memory> -#include <vector> -#include <stack> -#include<osl/file.hxx> - -#include <rtl/ustring.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/servicefactory.hxx> - -#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_ -#include <com/sun/star/lang/XComponent.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HDL_ -#include <com/sun/star/io/XActiveDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HDL_ -#include <com/sun/star/io/XActiveDataSink.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATACONTROL_HDL_ -#include <com/sun/star/io/XActiveDataControl.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XDATATRANSFEREVENTLISTENER_HDL_ -#include <com/sun/star/io/XDataTransferEventListener.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XDATAIMPORTER_HDL_ -#include <com/sun/star/io/XDataImporter.hpp> -#endif - -#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HDL_ -#include <com/sun/star/io/XInputStream.hpp> -#endif -#include <com/sun/star/xml/sax/XParser.hpp> -#include <com/sun/star/xml/sax/SAXParseException.hpp> -#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> - -#include <com/sun/star/xml/sax/InputSource.hpp> -#include <vos/thread.hxx> - -#include <vos/pipe.hxx> -#include <osl/diagnose.h> -#include "oslstream.hxx" -#include <com/sun/star/xml/sax/XAttributeList.hpp> - -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> - -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/script/XTypeConverter.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <osl/conditn.hxx> - -#include "xmltreebuilder.hxx" - -#include "dataimport.hxx" - -#include "createpropertyvalue.hxx" -// ----------------------------------------------------------------------------- -// --------------------------------- namespaces --------------------------------- -// ----------------------------------------------------------------------------- -namespace uno = com::sun::star::uno; -namespace lang = com::sun::star::lang; -namespace io = com::sun::star::io; -namespace sax = com::sun::star::xml::sax; -namespace script = com::sun::star::script; - -using ::rtl::OUString; -using ::osl::File; - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; - -// ----------------------------------------------------------------------------- -// ---------------------------------- defines ---------------------------------- -// ----------------------------------------------------------------------------- -#ifndef ASCII -#define ASCII(x) OUString::createFromAscii(x) -#endif - - -// ----------------------------------------------------------------------------- -// ---------------------------------- a Class ---------------------------------- -// ----------------------------------------------------------------------------- -// <Name a="xyz" b="bar"> - -//========================================================================== -//= Visitors -//========================================================================== - - -// ----------------------------------------------------------------------------- -class Listener : public ::cppu::WeakImplHelper1<io::XDataTransferEventListener> -{ - osl::Condition m_aCondition; -public: - Listener() - { - m_aCondition.reset(); // will block - } - - virtual void SAL_CALL disposing( const lang::EventObject& Source ) - throw(::com::sun::star::uno::RuntimeException) - { - OSL_ENSURE(0, "disposing"); - m_aCondition.set(); // will not block - } - - virtual void SAL_CALL finished( const io::DataTransferEvent& aEvent ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "finished"); - m_aCondition.set(); // will not block - } - - virtual void SAL_CALL cancelled( const io::DataTransferEvent& aEvent ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "cancelled"); - m_aCondition.set(); // will not block - } -public: - void wait() - { - m_aCondition.wait(); - } -}; - -class Component: public ::cppu::WeakImplHelper1<lang::XComponent> -{ - virtual void SAL_CALL dispose( ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "dispose"); - - } - virtual void SAL_CALL addEventListener( const uno::Reference< lang::XEventListener >& xListener ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "addEventListener"); - } - virtual void SAL_CALL removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) - throw(uno::RuntimeException) - { - OSL_ENSURE(0, "removeEventListener"); - } -}; - - - -namespace configmgr -{ - -// ----------------------------------------------------------------------------- -// ------------------------------------ Test ------------------------------------ -// ----------------------------------------------------------------------------- -#define ASCII_STRING(rtlOUString) rtl::OUStringToOString(rtlOUString, RTL_TEXTENCODING_ASCII_US).getStr() - static ::rtl::OUString sRegistry = ::rtl::OUString::createFromAscii("applicat.rdb"); - - void importTest() - { - uno::Reference< lang::XMultiServiceFactory > xMSF; - try - { - xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString()); - } - catch (uno::Exception& e) - { - cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ; - cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl; - } - - if (!xMSF.is()) - { - cerr << "could not create the service factory !" << endl; - return; - } - - OUString aPath = ASCII("l:/SRC601/configmgr/workben/local_io"); - OUString aFilename = ASCII("hierarchy"); - OUString aExtension = ASCII("xml"); - - OUString aFullname = aPath + ASCII("/") + aFilename + ASCII(".") + aExtension; - - // Filename convertieren - OUString aURL; - File aConvert(ASCII("")); - aConvert.normalizePath(aFullname, aURL); - - // File oeffnen - File aFile(aURL); - aFile.open(osl_File_OpenFlag_Read); - - // sal_uInt64 nBytesRead; - // uno::Sequence< sal_Int8 > aBufferSeq(2000); - // sal_Int8 *pBuff = aBufferSeq.getArray(); - // aFile.read(pBuff, 2000, nBytesRead); - // - // aFile.close(); - - uno::Reference<io::XInputStream> xInputStream = new configmgr::OSLInputStreamWrapper(aFile); - - uno::Reference <uno::XInterface> xPump = xMSF->createInstance( L"com.sun.star.io.Pump" ); - OSL_ENSURE(xPump.is(), "there is no pump"); - - uno::Reference<io::XActiveDataSink> xPumpSink(xPump, uno::UNO_QUERY); - xPumpSink->setInputStream(xInputStream); - - uno::Reference<io::XActiveDataSource> xPumpSource(xPump, uno::UNO_QUERY); - - Listener *pListener = new Listener(); - uno::Reference<io::XDataTransferEventListener> rListener = pListener; - uno::Reference<lang::XComponent> rComponent = new Component(); - - // Create a TypeConverter - uno::Reference<script::XTypeConverter> aConverter; - aConverter = aConverter.query(xMSF->createInstance(ASCII( "com.sun.star.script.Converter" )) ); - - Sequence< uno::Any > aArgs(1); // optional arg. - aArgs[0] <<= configmgr::createPropertyValue(ASCII("TypeConverter"), aConverter); - - Reference< XInterface > xDataImport = xMSF->createInstanceWithArguments( - OUString::createFromAscii("com.sun.star.configuration.DataImport"), - aArgs); - - if (xDataImport.is()) - { - uno::Reference<io::XDataImporter> rImporter(xDataImport, UNO_QUERY); - - // Import Data - rImporter->importData(xPumpSource, rComponent, rListener); - - // lets pump - uno::Reference<io::XActiveDataControl> xControl(xPump, uno::UNO_QUERY); - xControl->start(); - - // TEST: - // rImporter->cancel(); - - // pImporter->wait(); - // Wait until the listener send ready - pListener->wait(); - } - return; - } - -// ----------------------------------------------------------------------------- -// -------------------------------- Import Test -------------------------------- -// ----------------------------------------------------------------------------- - - // ----------- TEST ReadAccess ----------- - void showSequence(const Sequence<OUString> &aSeq); - -void hierarchyTest() -{ - - uno::Reference< lang::XMultiServiceFactory > xMSF; - try - { - xMSF = cppu::createRegistryServiceFactory(sRegistry, ::rtl::OUString()); - } - catch (uno::Exception& e) - { - cout << "could not bootstrap the services from " << ASCII_STRING(sRegistry) << endl ; - cout << " (error message : " << ASCII_STRING(e.Message) << ")" << endl; - } - - if (!xMSF.is()) - { - cerr << "could not create the service factory !" << endl; - return; - } - - - Reference< XMultiServiceFactory > xCfgProvider( xMSF->createInstance( - ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), - UNO_QUERY); - - if (!xCfgProvider.is()) - { - OSL_ENSURE(0, "No Configuration Provider"); - } - - OUString sPath = ASCII("com.sun.star.ucb.Hierarchy"); - - Sequence< Any > aArgs(1); - aArgs[0] <<= sPath; - - Reference< XInterface > xCfgUpdt = xCfgProvider->createInstanceWithArguments( - OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), - aArgs); - - Reference< XNameAccess > xNameAccess(xCfgUpdt, UNO_QUERY); - - // which Names are exist? - showSequence(xNameAccess->getElementNames()); - - OUString aNamePath = ASCII("Root"); - if (xNameAccess->hasByName(aNamePath)) - { - Any aAny; - aAny = xNameAccess->getByName(aNamePath); - TypeClass aTypeClass = aAny.getValueTypeClass(); - if (aAny.getValueTypeClass() == TypeClass_INTERFACE) - { - Reference< XInterface > xInterface; - aAny >>= xInterface; - Reference< XNameAccess > xNameAccess2(xInterface, UNO_QUERY); - if (xNameAccess.is()) - { - Sequence<OUString> aSeq = xNameAccess2->getElementNames(); - showSequence(aSeq); - - // insert a new set -/* - Reference<XHierarchicalName> xHierarchical(xNameAccess, UNO_QUERY); - OUString aHierachicalName = xHierarchical->getHierarchicalName(); - - Sequence< Any > aArgs(2); - aArgs[0] <<= aHierachicalName; - sal_Int32 nLevels=1; - aArgs[1] <<= nLevels; - - Reference< XInterface > xCfgNewUpdt = xCfgProvider->createInstanceWithArguments( - OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), - aArgs); -*/ - Reference< lang::XSingleServiceFactory > xChildFactory(xNameAccess2, UNO_QUERY); - if (xChildFactory.is()) - { - Reference< XInterface > xChild = xChildFactory->createInstance(); - if (xChild.is()) - { - Reference<XNameAccess> xObjectOnTheMedow(xChild, UNO_QUERY); - - - - - // which Names are exist? - showSequence(xObjectOnTheMedow->getElementNames()); - - OUString aChildren = ASCII("Children"); - if (xObjectOnTheMedow->hasByName(aChildren)) - { - Any aAny; - aAny = xObjectOnTheMedow->getByName(aChildren); - TypeClass aTypeClass = aAny.getValueTypeClass(); - if (aAny.getValueTypeClass() == TypeClass_INTERFACE) - { - Reference< XInterface > xInterface; - aAny >>= xInterface; - Reference< XNameAccess > xChildFromOOM(xInterface, UNO_QUERY); - - if (xChildFromOOM.is()) - { - // insert a new Object in the new Object - - Reference< lang::XSingleServiceFactory > xChildFactory(xChildFromOOM, UNO_QUERY); - if (xChildFactory.is()) - { - Reference< XInterface > xChild = xChildFactory->createInstance(); - if (xChild.is()) - { - Reference<XNameContainer> xNameContainer(xChildFromOOM, UNO_QUERY); - if (xNameContainer.is()) - { - xNameContainer->insertByName(ASCII("Test2"), makeAny(xChild)); - } - } - } - } - } - } - - - Reference<XNameContainer> xNameContainer(xNameAccess2, UNO_QUERY); - if (xNameContainer.is()) - { - xNameContainer->insertByName(ASCII("Test"), makeAny(xObjectOnTheMedow)); - } - } - - // commit changes - Reference< XChangesBatch > xChangesBatch(xCfgUpdt, UNO_QUERY); - if (xChangesBatch.is()) - { - xChangesBatch->commitChanges(); - } - } - - Sequence<OUString> aSeq2 = xNameAccess2->getElementNames(); - showSequence(aSeq2); - -/* - OUString *pStr = aSeq.getArray(); - for (int i=0;i<aSeq.getLength();i++) - { - OUString aStr = pStr[i]; - Any aAny; - aAny = xNameAccess->getByName(aStr); - TypeClass aTypeClass = aAny.getValueTypeClass(); - - Reference< XNameReplace > xNameReplace(xNameAccess, UNO_QUERY); - - Any aNewAny; - sal_Bool bValue = false; - aNewAny <<= bValue; - xNameReplace->replaceByName(aStr, aNewAny); - - volatile int dummy = 0; - } -*/ - } - } - volatile int dummy = 0; - } -} - -// ------------------------------ Helperfunctions ------------------------------ - - void showSequence(const Sequence<OUString> &aSeq) - { - OUString aArray; - const OUString *pStr = aSeq.getConstArray(); - for (int i=0;i<aSeq.getLength();i++) - { - OUString aStr = pStr[i]; - aArray += aStr + ASCII(", "); - } - volatile int dummy = 0; - } - -} // namespace configmgr diff --git a/configmgr/workben/logger/exports.dxp b/configmgr/workben/logger/exports.dxp deleted file mode 100644 index 9630d7e06768..000000000000 --- a/configmgr/workben/logger/exports.dxp +++ /dev/null @@ -1,3 +0,0 @@ -component_getImplementationEnvironment -component_writeInfo -component_getFactory diff --git a/configmgr/workben/logger/loggerdfn.cxx b/configmgr/workben/logger/loggerdfn.cxx deleted file mode 100644 index 32f2d53e4a8a..000000000000 --- a/configmgr/workben/logger/loggerdfn.cxx +++ /dev/null @@ -1,151 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include "simplelogger.hxx" -#include <com/sun/star/registry/XRegistryKey.hpp> -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include <cppuhelper/implementationentry.hxx> -#endif -#include <rtl/ustrbuf.hxx> - -namespace cssuno = com::sun::star::uno; -using rtl::OUString; -using rtl::OUStringBuffer; - -//============================================================================== - -static cssuno::Reference<cssuno::XInterface> SAL_CALL - createSimpleLogger( const cssuno::Reference<cssuno::XComponentContext>& aContext) -{ - return * new logger::SimpleLogger(aContext,"configuration.log") ; -} -//============================================================================== - -// adapted from the corresponding cppuhelper function -static sal_Bool component_writeInfoHelper_withSingleton( - void *pServiceManager, void *pRegistryKey , - const cppu::ImplementationEntry entries[], - char const * const singletons[]) -{ - using namespace com::sun::star::registry; - using rtl::OUString; - - sal_Bool bRet = sal_False; - try - { - if( pRegistryKey ) - { - for( sal_Int32 i = 0; entries[i].create ; i ++ ) - { - rtl::OUStringBuffer buf( 124 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/") ); - buf.append( entries[i].getImplementationName() ); - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM( "/UNO/SERVICES" ) ); - cssuno::Reference< XRegistryKey > xNewKey( - static_cast< XRegistryKey * >( pRegistryKey )->createKey( buf.makeStringAndClear() ) ); - - cssuno::Sequence< OUString > const seq = entries[i].getSupportedServiceNames(); - for ( sal_Int32 nPos = 0 ; nPos < seq.getLength(); nPos ++ ) - xNewKey->createKey( seq[nPos] ); - - if (singletons[i]) - { - rtl::OUStringBuffer buf( 124 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/") ); - buf.append( entries[i].getImplementationName() ); - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM( "/UNO/SINGLETONS/" ) ); - buf.appendAscii(singletons[i]); - cssuno::Reference< XRegistryKey > xNewKey( - static_cast< XRegistryKey * >( pRegistryKey )->createKey( buf.makeStringAndClear() ) ); - - xNewKey->setStringValue(entries[i].getImplementationName()); - } - } - bRet = sal_True; - } - } - catch ( InvalidRegistryException & ) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - catch ( cssuno::Exception & ) - { - OSL_ENSURE( sal_False, "### Unexpected UNO Exception!" ); - } - return bRet; -} - -//------------------------------------------------------------------------------ - -static const cppu::ImplementationEntry kImplementations_entries[] = -{ - { - createSimpleLogger, - logger::SimpleLogger::getImplementationName_static, - logger::SimpleLogger::getSupportedServiceNames_static, - cppu::createSingleComponentFactory, - NULL, - 0 - }, - { NULL } -} ; -static const char * const kSingleton_names[] = -{ - "com.sun.star.configuration.theLogger", - NULL -}; - -//------------------------------------------------------------------------------ - -extern "C" void SAL_CALL component_getImplementationEnvironment( - const sal_Char **aEnvTypeName, - uno_Environment **aEnvironment) { - *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ; -} -//------------------------------------------------------------------------------ - -extern "C" sal_Bool SAL_CALL component_writeInfo(void *aServiceManager, - void *aRegistryKey) { - return component_writeInfoHelper_withSingleton( aServiceManager, - aRegistryKey, - kImplementations_entries, - kSingleton_names) ; -} -//------------------------------------------------------------------------------ - -extern "C" void *component_getFactory(const sal_Char *aImplementationName, - void *aServiceManager, - void *aRegistryKey) { - return cppu::component_getFactoryHelper(aImplementationName, - aServiceManager, - aRegistryKey, - kImplementations_entries) ; -} -//------------------------------------------------------------------------------ diff --git a/configmgr/workben/logger/makefile.mk b/configmgr/workben/logger/makefile.mk deleted file mode 100644 index 569326914ba2..000000000000 --- a/configmgr/workben/logger/makefile.mk +++ /dev/null @@ -1,69 +0,0 @@ -#************************************************************************* -# -# 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=..$/.. - -PRJINC=$(PRJ)$/source -PRJNAME=configmgr -TARGET=simplelogger -ENABLE_EXCEPTIONS=TRUE - -# Version -SYSMGR_MAJOR=1 - -# --- Settings --- - -.INCLUDE : settings.mk -DLLPRE = - -# --- Files --- - - -SLOFILES=\ - $(SLO)$/simplelogger.obj \ - $(SLO)$/loggerdfn.obj - -LIB1TARGET=$(SLB)$/_$(TARGET).lib -LIB1OBJFILES=$(SLOFILES) - -SHL1TARGET=$(TARGET)$(SYSMGR_MAJOR).uno -SHL1DEF=$(MISC)$/$(SHL1TARGET).def -SHL1LIBS=$(LIB1TARGET) -SHL1IMPLIB=i$(SHL1TARGET) -SHL1STDLIBS= \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(SALLIB) - -DEF1NAME=$(SHL1TARGET) -DEF1EXPORTFILE=exports.dxp -DEF1DES=Configuration: Simple Logger - -# --- Targets --- - -.INCLUDE : target.mk - diff --git a/configmgr/workben/logger/simplelogger.cxx b/configmgr/workben/logger/simplelogger.cxx deleted file mode 100644 index a6064f813e34..000000000000 --- a/configmgr/workben/logger/simplelogger.cxx +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include "simplelogger.hxx" -#include <com/sun/star/util/logging/LogLevel.hpp> - -#include <osl/thread.h> -#include <stdlib.h> // for getenv - -namespace logger -{ - - namespace LogLevel = com::sun::star::util::logging::LogLevel; - -//============================================================================== -static rtl::OString level2str(sal_Int32 nLevel) -{ - return rtl::OString::valueOf(nLevel); -} - -sal_Int32 str2level(rtl::OString const & str) -{ - return str.toInt32(); -} - -//------------------------------------------------------------------------------ -SimpleLogger::SimpleLogger( const uno::Reference<uno::XComponentContext>& xContext, char const * name) -: mContext(xContext) -, mName( OUString::createFromAscii(name) ) -, mOutput(stderr) -, mLevel(LogLevel::INFO) -{ - if (char const * fname = getenv("CFG_LOGFILE")) - { - mOutput = fopen(fname,"a+"); - OSL_ENSURE(mOutput,"ERROR: could not open logfile\n"); - } - - if (char const * level = getenv("CFG_LOGLEVEL")) - { - mLevel = str2level(level); - } -} -//------------------------------------------------------------------------------ -SimpleLogger::~SimpleLogger() -{ -} -//------------------------------------------------------------------------------ -uno::Reference< logging::XLogger > SAL_CALL - SimpleLogger::getLogger( const OUString& name ) - throw (uno::RuntimeException) -{ - if (name == mName) return this; - - // try whatever - uno::Reference< logging::XLogger > xNamedLogger; - if (mContext.is()) - { - OUString const singleton(RTL_CONSTASCII_USTRINGPARAM("/singletons/")); - mContext->getValueByName(singleton.concat(name)) >>= xNamedLogger; - } - return xNamedLogger; -} - -//------------------------------------------------------------------------------ -sal_Int32 SAL_CALL SimpleLogger::getLevel( ) throw (uno::RuntimeException) -{ - return mLevel; -} - -//------------------------------------------------------------------------------ -OUString SAL_CALL SimpleLogger::getName( ) throw (uno::RuntimeException) -{ - return mName; -} - -//------------------------------------------------------------------------------ -sal_Bool SAL_CALL SimpleLogger::isLoggable( sal_Int32 level ) throw (uno::RuntimeException) -{ - return mOutput && level >= mLevel; -} - -//------------------------------------------------------------------------------ -#define OU2OUT( ustr ) ( rtl::OUStringToOString( ustr, enc ).getStr() ) - -void SAL_CALL SimpleLogger::logp( sal_Int32 level, const OUString& sourceClass, const OUString& sourceMethod, const OUString& msg ) - throw (uno::RuntimeException) -{ - rtl_TextEncoding enc = osl_getThreadTextEncoding(); - if (mOutput && level > mLevel) - { - fprintf( mOutput, "%s {%s.%s}: [%s] %s\n", OU2OUT(mName), - OU2OUT(sourceClass) , OU2OUT(sourceMethod), - level2str(level).getStr(), OU2OUT(msg) ); - } -} - -//------------------------------------------------------------------------------ - -OUString SAL_CALL SimpleLogger::getImplementationName_static() -{ - static const char kImplementationName[] = "com.sun.star.comp.configmgr.logging.SimpleLogger"; - - return OUString(RTL_CONSTASCII_USTRINGPARAM(kImplementationName)) ; -} -//------------------------------------------------------------------------------ - -rtl::OUString SAL_CALL SimpleLogger::getImplementationName() - throw (uno::RuntimeException) -{ - return getImplementationName_static() ; -} -//------------------------------------------------------------------------------ - -uno::Sequence<rtl::OUString> SAL_CALL SimpleLogger::getSupportedServiceNames_static() -{ - uno::Sequence<rtl::OUString> aServices(2) ; - aServices[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.logging.SimpleLogger")) ; - aServices[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.logging.Logger")) ; - - return aServices ; -} -//------------------------------------------------------------------------------ - -sal_Bool SAL_CALL SimpleLogger::supportsService( - const rtl::OUString& aServiceName) - throw (uno::RuntimeException) -{ - uno::Sequence< rtl::OUString > const svc = getSupportedServiceNames_static(); - - for(sal_Int32 i = 0; i < svc.getLength(); ++i ) - if(svc[i] == aServiceName) - return true; - return false; -} -//------------------------------------------------------------------------------ - -uno::Sequence<rtl::OUString> -SAL_CALL SimpleLogger::getSupportedServiceNames() - throw (uno::RuntimeException) -{ - return getSupportedServiceNames_static() ; -} -//------------------------------------------------------------------------------ - - -} // namespace logger diff --git a/configmgr/workben/logger/simplelogger.hxx b/configmgr/workben/logger/simplelogger.hxx deleted file mode 100644 index 81cfeb70a1ef..000000000000 --- a/configmgr/workben/logger/simplelogger.hxx +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef CONFIGMGR_SIMPLELOGGER_HXX_ -#define CONFIGMGR_SIMPLELOGGER_HXX_ - -#include "simplelogger.hxx" -#include <com/sun/star/util/logging/XLogger.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <cppuhelper/implbase2.hxx> - -#include <stdio.h> - -namespace logger { - -namespace uno = com::sun::star::uno ; -namespace lang = com::sun::star::lang ; -namespace logging = com::sun::star::util::logging ; -using rtl::OUString; - -typedef cppu::WeakImplHelper2< logging::XLogger, - lang::XServiceInfo> LoggerBase ; - - -/** - Class implementing the Logger service - */ -class SimpleLogger : public LoggerBase -{ -public : - /** - Service constructor from a service factory. - - @param xContext component context - */ - explicit - SimpleLogger( const uno::Reference<uno::XComponentContext>& xContext, char const * name) ; - - /** Destructor */ - ~SimpleLogger() ; - - // XLogger - virtual uno::Reference< logging::XLogger > SAL_CALL - getLogger( const OUString& name ) - throw (uno::RuntimeException); - - virtual sal_Int32 SAL_CALL getLevel( ) throw (uno::RuntimeException); - virtual OUString SAL_CALL getName( ) throw (uno::RuntimeException); - virtual sal_Bool SAL_CALL isLoggable( sal_Int32 level ) throw (uno::RuntimeException); - - virtual void SAL_CALL - logp( sal_Int32 level, const OUString& sourceClass, const OUString& sourceMethod, const OUString& msg ) - throw (uno::RuntimeException); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() - throw (uno::RuntimeException) ; - - virtual sal_Bool SAL_CALL supportsService( const OUString& aServiceName) - throw (uno::RuntimeException) ; - - virtual uno::Sequence<OUString> SAL_CALL - getSupportedServiceNames(void) throw (uno::RuntimeException) ; - - /** - Provides the implementation name. - - @return implementation name - */ - static OUString SAL_CALL getImplementationName_static() ; - /** - Provides the list of supported services. - - @return list of service names - */ - static uno::Sequence<OUString> SAL_CALL getSupportedServiceNames_static() ; - -private: - /** Component Context */ - uno::Reference<uno::XComponentContext> mContext ; - OUString mName; - FILE * mOutput; - sal_Int32 mLevel; -} ; - -} // namespace logger - -#endif diff --git a/configmgr/workben/memory/logmechanism.hxx b/configmgr/workben/memory/logmechanism.hxx deleted file mode 100644 index a2f6e4ec6f48..000000000000 --- a/configmgr/workben/memory/logmechanism.hxx +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************************************* - * - * 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 __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ -#define __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ - -//***************************************************************************************************************** -// generic macros for logging -//***************************************************************************************************************** - -#ifdef ENABLE_LOGMECHANISM - - //_____________________________________________________________________________________________________________ - // includes - //_____________________________________________________________________________________________________________ - - #ifndef _RTL_STRING_HXX_ - #include <rtl/string.hxx> - #endif - - #include <stdio.h> - - /*_____________________________________________________________________________________________________________ - WRITE_LOGFILE( SFILENAME, STEXT ) - - Log any information in file. We append any information at file and don't clear it anymore. - ( Use new scope in macro to declare pFile more then on time in same "parentscope"! - Don't control pFile before access! What will you doing if its not valid? Log an error ... - An error and an error is an error ... ) - - Attention: You must use "%s" and STEXT as parameter ... because otherwise encoded strings (they include e.g. %...) - are handled wrong. - _____________________________________________________________________________________________________________*/ - - #define WRITE_LOGFILE( SFILENAME, STEXT ) \ - { \ - ::rtl::OString _swriteLogfileFileName ( SFILENAME ); \ - ::rtl::OString _swriteLogfileText ( STEXT ); \ - FILE* pFile = fopen( _swriteLogfileFileName.getStr(), "a" ); \ - fprintf( pFile, "%s", _swriteLogfileText.getStr() ); \ - fclose ( pFile ); \ - } - - /*_____________________________________________________________________________________________________________ - LOGTYPE - - For other debug macros we need information about the output mode. If user forget to set this information we - do it for him. Valid values are: LOGTYPE_FILECONTINUE - LOGTYPE_FILEEXIT - LOGTYPE_MESSAGEBOX - The normal case is LOGTYPE_MESSAGEBOX to show assertions in normal manner! - _____________________________________________________________________________________________________________*/ - - #define LOGTYPE_MESSAGEBOX 1 - #define LOGTYPE_FILECONTINUE 2 - #define LOGTYPE_FILEEXIT 3 - - #ifndef LOGTYPE - #define LOGTYPE \ - LOGTYPE_MESSAGEBOX - #endif - -#else // #ifdef ENABLE_LOGMECHANISM - - /*_____________________________________________________________________________________________________________ - If right testmode is'nt set - implements these macro empty! - _____________________________________________________________________________________________________________*/ - - #define WRITE_LOGFILE( SFILENAME, STEXT ) - #undef LOGTYPE - -#endif // #ifdef ENABLE_LOGMECHANISM - -//***************************************************************************************************************** -// end of file -//***************************************************************************************************************** - -#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ diff --git a/configmgr/workben/memory/main.cxx b/configmgr/workben/memory/main.cxx deleted file mode 100644 index 4ec86cca7d4a..000000000000 --- a/configmgr/workben/memory/main.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#include <iostream> -using namespace std; - -#define ENABLE_MEMORYMEASURE -#define ENABLE_LOGMECHANISM - -// If you wish to enable this memory measure macros ... you need "windows.h" -// But it's not agood idea to include it in your header!!! Because it's not compatible to VCL header .-( -// So you must include it here ... in cxx, where you whish to use it. -#ifdef ENABLE_MEMORYMEASURE - #define VCL_NEED_BASETSD - #include <tools/presys.h> - #include <windows.h> - #include <tools/postsys.h> - #undef VCL_NEED_BASETSD -#endif -#include "memorymeasure.hxx" - -#include "logmechanism.hxx" -// ----------------------------------------------------------------------------- -// ---------------------------------- M A I N ---------------------------------- -// ----------------------------------------------------------------------------- - -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - - START_MEMORYMEASURE( aMemoryInfo ); - - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "first start" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "1" ); - - sal_Char* pTest = new sal_Char[1000 * 1000 * 50]; - sal_Char* pTest1 = new sal_Char[1000 * 1000 * 50]; - sal_Char* pTest2 = new sal_Char[1000 * 1000 * 50]; - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "2" ); - - LOG_MEMORYMEASURE( "FirstTest_of_memusage", "Values of memory access for standard filters.", aMemoryInfo ); - - return 0; -} - diff --git a/configmgr/workben/memory/makefile.mk b/configmgr/workben/memory/makefile.mk deleted file mode 100644 index c93193121de7..000000000000 --- a/configmgr/workben/memory/makefile.mk +++ /dev/null @@ -1,255 +0,0 @@ -#************************************************************************* -# -# 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=..$/.. -PRJINC=$(PRJ)$/source - -PRJNAME=configmgr - -TARGET=memorytest -TARGET2=memorytesthack -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -# ... common for all test executables .............................. -APPSTDLIBS=\ - $(SALLIB) \ - $(VOSLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(COMPHELPERLIB) \ - -# ... cfgapi .............................. -# APP1STDLIBS = $(APPSTDLIBS) -# -# APP1STDLIBS+=$(STDLIBCPP) -# -# APP1TARGET= $(TARGET) -# APP1OBJS= \ -# $(SLO)$/cfgapi2.obj \ -# $(SLO)$/strimpl.obj \ -# $(SLO)$/typeconverter.obj \ -# $(SLO)$/simpletypehelper.obj \ -# $(SLO)$/memory.obj \ - -# ... cfgapi .............................. -APP2STDLIBS = $(APPSTDLIBS) - -APP2STDLIBS+= $(STDLIBCPP) - -# CFLAGS+=-DWITHOUTAPI - -APP2TARGET= $(TARGET2) -APP2OBJS= \ - $(SLO)$/memorytests.obj \ - $(SLO)$/testmodules.obj \ - $(SLO)$/treeload.obj \ - $(SLO)$/accessimpl.obj \ - $(SLO)$/adminproviderimpl.obj \ - $(SLO)$/apiaccessobj.obj \ - $(SLO)$/apifactory.obj \ - $(SLO)$/apifactoryimpl.obj \ - $(SLO)$/apinodeaccess.obj \ - $(SLO)$/apinodeupdate.obj \ - $(SLO)$/apinotifierimpl.obj \ - $(SLO)$/apiserviceinfo.obj \ - $(SLO)$/apitreeaccess.obj \ - $(SLO)$/apitreeimplobj.obj \ - $(SLO)$/attributelist.obj \ - $(SLO)$/attributeparser.obj \ - $(SLO)$/binarybasereader.obj \ - $(SLO)$/binarydecide.obj \ - $(SLO)$/binaryreader.obj \ - $(SLO)$/binarywritehandler.obj \ - $(SLO)$/binarywriter.obj \ - $(SLO)$/bootstrap.obj \ - $(SLO)$/broadcaster.obj \ - $(SLO)$/cachewritescheduler.obj \ - $(SLO)$/changes.obj \ - $(SLO)$/cmtree.obj \ - $(SLO)$/cmtreemodel.obj \ - $(SLO)$/collectchanges.obj \ - $(SLO)$/committer.obj \ - $(SLO)$/confeventhelpers.obj \ - $(SLO)$/confevents.obj \ - $(SLO)$/configexcept.obj \ - $(SLO)$/configgroup.obj \ - $(SLO)$/confignotifier.obj \ - $(SLO)$/configpath.obj \ - $(SLO)$/configsession.obj \ - $(SLO)$/configset.obj \ - $(SLO)$/confname.obj \ - $(SLO)$/confprovider2.obj \ - $(SLO)$/confproviderimpl2.obj \ - $(SLO)$/confsvccomponent.obj \ - $(SLO)$/disposetimer.obj \ - $(SLO)$/elementaccess.obj \ - $(SLO)$/elementimpl.obj \ - $(SLO)$/encodename.obj \ - $(SLO)$/filehelper.obj \ - $(SLO)$/generatecache.obj \ - $(SLO)$/groupaccess.obj \ - $(SLO)$/groupimpl.obj \ - $(SLO)$/groupobjects.obj \ - $(SLO)$/groupupdate.obj \ - $(SLO)$/invalidatetree.obj \ - $(SLO)$/listenercontainer.obj \ - $(SLO)$/loader.obj \ - $(SLO)$/localizednodebuilder.obj \ - $(SLO)$/localizedtreeactions.obj \ - $(SLO)$/localsession.obj \ - $(SLO)$/matchlocale.obj \ - $(SLO)$/mergechange.obj \ - $(SLO)$/namehelper.obj \ - $(SLO)$/nodechange.obj \ - $(SLO)$/nodechangeimpl.obj \ - $(SLO)$/nodechangeinfo.obj \ - $(SLO)$/nodefactory.obj \ - $(SLO)$/nodeimpl.obj \ - $(SLO)$/nodeimplobj.obj \ - $(SLO)$/noderef.obj \ - $(SLO)$/notifycallback.obj \ - $(SLO)$/oslstream.obj \ - $(SLO)$/pathhelper.obj \ - $(SLO)$/portalstream.obj \ - $(SLO)$/propertiesfilterednotifier.obj \ - $(SLO)$/propertyinfohelper.obj \ - $(SLO)$/propertysetaccess.obj \ - $(SLO)$/propsetaccessimpl.obj \ - $(SLO)$/provider.obj \ - $(SLO)$/providerfactory.obj \ - $(SLO)$/providerimpl.obj \ - $(SLO)$/receivethread.obj \ - $(SLO)$/redirector.obj \ - $(SLO)$/remotesession.obj \ - $(SLO)$/roottree.obj \ - $(SLO)$/saxadapter.obj \ - $(SLO)$/saxtools.obj \ - $(SLO)$/sessionfactory.obj \ - $(SLO)$/sessionstream.obj \ - $(SLO)$/setaccess.obj \ - $(SLO)$/setnodeimpl.obj \ - $(SLO)$/setobjects.obj \ - $(SLO)$/setupdate.obj \ - $(SLO)$/simpletypehelper.obj \ - $(SLO)$/socketstream.obj \ - $(SLO)$/strimpl.obj \ - $(SLO)$/synchronize.obj \ - $(SLO)$/template.obj \ - $(SLO)$/templateimpl.obj \ - $(SLO)$/timestamp.obj \ - $(SLO)$/tracer.obj \ - $(SLO)$/translatechanges.obj \ - $(SLO)$/treeactions.obj \ - $(SLO)$/treebuildercallback.obj \ - $(SLO)$/treecache.obj \ - $(SLO)$/treedata.obj \ - $(SLO)$/treeimpl.obj \ - $(SLO)$/treeiterators.obj \ - $(SLO)$/treenodefactory.obj \ - $(SLO)$/trivialbufferedfile.obj \ - $(SLO)$/typeconverter.obj \ - $(SLO)$/updatehandler.obj \ - $(SLO)$/updateimpl.obj \ - $(SLO)$/updatetree.obj \ - $(SLO)$/userimpl.obj \ - $(SLO)$/valueconverter.obj \ - $(SLO)$/valuehandler.obj \ - $(SLO)$/valuenodebuilder.obj \ - $(SLO)$/writesubtreeasbinaryhandler.obj \ - $(SLO)$/xmlformater.obj \ - $(SLO)$/xmltreebuilder.obj \ - $(SLO)$/valuemembernode.obj \ - $(SLO)$/anypair.obj \ - -# $(SLO)$/memory.obj \ - - -# $(SLO)$/strimpl.obj \ -# $(SLO)$/typeconverter.obj \ -# $(SLO)$/simpletypehelper.obj \ -# $(SLO)$/memory.obj \ -# $(SLO)$/loadwithtreemanager.obj \ -# $(SLO)$/localsession.obj \ -# $(SLO)$/configsession.obj \ -# $(SLO)$/confname.obj \ -# $(SLO)$/tracer.obj \ -# $(SLO)$/generatecache.obj \ -# $(SLO)$/treeactions.obj \ -# $(SLO)$/cmtreemodel.obj \ -# $(SLO)$/cmtree.obj \ -# $(SLO)$/xmltreebuilder.obj \ -# $(SLO)$/xmlformater.obj \ -# $(SLO)$/binaryreader.obj \ -# $(SLO)$/binarybasereader.obj \ -# $(SLO)$/binarywriter.obj \ -# $(SLO)$/binarywritehandler.obj \ -# $(SLO)$/binarydecide.obj \ -# $(SLO)$/writesubtreeasbinaryhandler.obj \ -# $(SLO)$/oslstream.obj \ -# $(SLO)$/pathhelper.obj \ -# $(SLO)$/treecache.obj \ -# $(SLO)$/updatetree.obj \ -# $(SLO)$/attributeparser.obj \ -# $(SLO)$/updatehandler.obj \ -# $(SLO)$/synchronize.obj \ -# $(SLO)$/filehelper.obj \ -# $(SLO)$/mergechange.obj \ -# $(SLO)$/providerimpl.obj \ -# $(SLO)$/bootstrap.obj \ -# $(SLO)$/matchlocale.obj \ -# $(SLO)$/changes.obj \ -# $(SLO)$/configexcept.obj \ -# $(SLO)$/valuehandler.obj \ -# $(SLO)$/treenodefactory.obj \ -# $(SLO)$/attributelist.obj \ -# $(SLO)$/namehelper.obj \ -# $(SLO)$/localizedtreeactions.obj \ -# $(SLO)$/trivialbufferedfile.obj \ -# $(SLO)$/cachewritescheduler.obj \ -# $(SLO)$/disposetimer.obj \ -# $(SLO)$/noderef.obj \ -# $(SLO)$/treedata.obj \ -# $(SLO)$/confevents.obj \ -# $(SLO)$/treebuildercallback.obj \ -# $(SLO)$/loader.obj \ -# $(SLO)$/apifactoryimpl.obj \ -# $(SLO)$/apitreeimplobj.obj \ - -# $(SLO)$/.obj \ - - -.INCLUDE : target.mk - - diff --git a/configmgr/workben/memory/memorymeasure.hxx b/configmgr/workben/memory/memorymeasure.hxx deleted file mode 100644 index 90bb777e27d8..000000000000 --- a/configmgr/workben/memory/memorymeasure.hxx +++ /dev/null @@ -1,225 +0,0 @@ -/************************************************************************* - * - * 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 __FRAMEWORK_MACROS_DEBUG_MEMORYMEASURE_HXX_ -#define __FRAMEWORK_MACROS_DEBUG_MEMORYMEASURE_HXX_ - -// ************************************************************************************************************* -// special macros for time measures -// 1) LOGFILE_MEMORYMEASURE used it to define log file for this operations (default will be set automaticly) -// 2) MAKE_MEMORY_SNAPSHOT make snapshot of currently set memory informations of OS -// 3) LOG_MEMORYMEASURE write measured time to logfile -// ************************************************************************************************************* - -#ifdef ENABLE_MEMORYMEASURE - -#if !defined( WIN ) && !defined( WNT ) -#error "Macros to measure memory access not available under platforms different from windows!" -#endif - -//_________________________________________________________________________________________________________________ -// includes -//_________________________________________________________________________________________________________________ - -#include <rtl/strbuf.hxx> - -#ifndef __SGI_STL_VECTOR -#include <vector> -#endif - -/*_____________________________________________________________________________________________________________ - LOGFILE_MEMORYMEASURE - - For follow macros we need a special log file. If user forget to specify anyone, we must do it for him! - _____________________________________________________________________________________________________________*/ - -#ifndef LOGFILE_MEMORYMEASURE -#define LOGFILE_MEMORYMEASURE "memorymeasure.log" -#endif - -/*_____________________________________________________________________________________________________________ - class MemoryMeasure - - We use this baseclass to collect all snapshots in one object and analyze this information at one point. - Macros of this file are used to enable using of this class by special compile-parameter only! - _____________________________________________________________________________________________________________*/ - -class _DBGMemoryMeasure -{ - //--------------------------------------------------------------------------------------------------------- -private: - struct _MemoryInfo - { - MEMORYSTATUS aStatus ; - ::rtl::OString sComment ; - }; - - //--------------------------------------------------------------------------------------------------------- -public: - //_____________________________________________________________________________________________________ - inline _DBGMemoryMeasure() - { - makeSnapshot("Initializing Data"); - } - //_____________________________________________________________________________________________________ - inline _DBGMemoryMeasure(const ::rtl::OString& sComment) - { - makeSnapshot(sComment); - } - - //_____________________________________________________________________________________________________ - // clear used container! - inline ~_DBGMemoryMeasure() - { - ::std::vector< _MemoryInfo >().swap( m_lSnapshots ); - } - - //_____________________________________________________________________________________________________ - inline void makeSnapshot( const ::rtl::OString& sComment ) - { - _MemoryInfo aInfo; - aInfo.sComment = sComment; - GlobalMemoryStatus ( &(aInfo.aStatus) ); - m_lSnapshots.push_back( aInfo ); - } - - //_____________________________________________________________________________________________________ - inline ::rtl::OString getLog() - { - ::rtl::OStringBuffer sBuffer( 10000 ); - - if( m_lSnapshots.size() > 0 ) - { - // Write informations to return buffer - ::std::vector< _MemoryInfo >::const_iterator pItem1; - ::std::vector< _MemoryInfo >::const_iterator pItem2; - - pItem1 = m_lSnapshots.begin(); - pItem2 = pItem1; - ++pItem2; - - while( pItem1!=m_lSnapshots.end() ) - { - sBuffer.append( "snap [ " ); - sBuffer.append( pItem1->sComment ); - sBuffer.append( " ]\n\tavail phys\t=\t" ); - sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailPhys ); - sBuffer.append( "\n\tavail page\t=\t" ); - sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailPageFile ); - sBuffer.append( "\n\tavail virt\t=\t" ); - sBuffer.append( (sal_Int32)pItem1->aStatus.dwAvailVirtual ); - - if( pItem1 == m_lSnapshots.begin() ) - { - sBuffer.append( "\n\t[initial values]\n\n" ); - } - else if( pItem2 != m_lSnapshots.end() ) - { - sBuffer.append( "\n\tdifference\t=\t[ " ); - sBuffer.append( (sal_Int32)(pItem2->aStatus.dwAvailPhys - pItem1->aStatus.dwAvailPhys ) ); - sBuffer.append( ", " ); - sBuffer.append( (sal_Int32)(pItem2->aStatus.dwAvailPageFile - pItem1->aStatus.dwAvailPageFile ) ); - sBuffer.append( ", " ); - sBuffer.append( (sal_Int32)(pItem2->aStatus.dwAvailVirtual - pItem1->aStatus.dwAvailVirtual ) ); - sBuffer.append( " ]\n\n" ); - } - else - { - sBuffer.append( "\n\t[final values]\n\n" ); - } - if( pItem1!=m_lSnapshots.end() ) ++pItem1; - if( pItem2!=m_lSnapshots.end() ) ++pItem2; - } - // clear current list ... make it empty for further snapshots! - ::std::vector< _MemoryInfo >().swap( m_lSnapshots ); - } - - return sBuffer.makeStringAndClear(); - } - - //--------------------------------------------------------------------------------------------------------- -private: - ::std::vector< _MemoryInfo > m_lSnapshots; -}; - -/*_____________________________________________________________________________________________________________ - START_MEMORY_MEASURE - - Create new object to measure memory access. - _____________________________________________________________________________________________________________*/ - -#define START_MEMORYMEASURE( AOBJECT ) \ - _DBGMemoryMeasure AOBJECT; - -#define START_MEMORYMEASURE_FOR( AOBJECT, SCOMMENT ) \ - _DBGMemoryMeasure AOBJECT( SCOMMENT ); - - /*_____________________________________________________________________________________________________________ - MAKE_MEMORY_SNAPSHOT - - Make snapshot of currently set memory informations of OS. - see _DBGMemoryMeasure for further informations - _____________________________________________________________________________________________________________*/ - -#define MAKE_MEMORY_SNAPSHOT( AOBJECT, SCOMMENT ) \ - AOBJECT.makeSnapshot( SCOMMENT ); - - /*_____________________________________________________________________________________________________________ - LOG_MEMORYMEASURE( SOPERATION, SCOMMENT, AOBJECT ) - - Write measured values to logfile. - _____________________________________________________________________________________________________________*/ - -#define LOG_MEMORYMEASURE( SOPERATION, SCOMMENT, AOBJECT ) \ - { \ - ::rtl::OStringBuffer _sBuffer( 256 ); \ - _sBuffer.append( SOPERATION ); \ - _sBuffer.append( "\n" ); \ - _sBuffer.append( SCOMMENT ); \ - _sBuffer.append( "\n\n" ); \ - _sBuffer.append( AOBJECT.getLog() ); \ - WRITE_LOGFILE( LOGFILE_MEMORYMEASURE, _sBuffer.makeStringAndClear() ) \ - } - -#else // #ifdef ENABLE_MEMORYMEASURE - -/*_____________________________________________________________________________________________________________ - If right testmode is'nt set - implements these macros empty! - _____________________________________________________________________________________________________________*/ - -#undef LOGFILE_MEMORYMEASURE -#define START_MEMORYMEASURE( AOBJECT ) -#define MAKE_MEMORY_SNAPSHOT( AOBJECT, SCOMMENT ) -#define LOG_MEMORYMEASURE( SOPERATION, SCOMMENT, AOBJECT ) - -#endif // #ifdef ENABLE_MEMORYMEASURE - -//***************************************************************************************************************** -// end of file -//***************************************************************************************************************** - -#endif // #ifndef __FRAMEWORK_MACROS_DEBUG_MEMORYMEASURE_HXX_ diff --git a/configmgr/workben/memory/memorytests.cxx b/configmgr/workben/memory/memorytests.cxx deleted file mode 100644 index 70a712a584f9..000000000000 --- a/configmgr/workben/memory/memorytests.cxx +++ /dev/null @@ -1,1241 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#define _PRIVATE_TEST_ - -#include <iostream> -#include <vector> -#include "treeload.hxx" - -#include <fstream> - -#define ENABLE_MEMORYMEASURE -#define ENABLE_LOGMECHANISM - -// If you wish to enable this memory measure macros ... you need "windows.h" -// But it's not agood idea to include it in your header!!! Because it's not compatible to VCL header .-( -// So you must include it here ... in cxx, where you whish to use it. -#ifdef ENABLE_MEMORYMEASURE - #define VCL_NEED_BASETSD - #include <tools/presys.h> - #include <windows.h> - #include <tools/postsys.h> - #undef VCL_NEED_BASETSD -#endif -#include "memorymeasure.hxx" - -#include "logmechanism.hxx" - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/Type.hxx> -#include <com/sun/star/uno/TypeClass.hpp> - -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/beans/XExactName.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/lang/XComponent.hpp> - -#include <rtl/ustring.hxx> -#include <rtl/string.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <com/sun/star/uno/Sequence.h> -#include <com/sun/star/uno/Any.h> -#include <osl/profile.hxx> -#include <osl/process.h> -#include <osl/file.h> - -#include <conio.h> - -#include "createpropertyvalue.hxx" - -#include "typeconverter.hxx" - -#include "testmodules.hxx" - -#include "valuenode.hxx" - -namespace configmgr -{ - -using namespace std; - -namespace css = com::sun::star; -namespace uno = css::uno; -namespace lang = css::lang; - -using namespace uno; -using namespace lang; - -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::util; - -using ::rtl::OUString; -using ::rtl::OString; - -using namespace ::cppu; - -#define ASCII(x) ::rtl::OUString::createFromAscii(x) - -ostream& operator << (ostream& out, rtl::OUString const& aStr) -{ - sal_Unicode const* const pStr = aStr.getStr(); - sal_Unicode const* const pEnd = pStr + aStr.getLength(); - for (sal_Unicode const* p = pStr; p < pEnd; ++p) - if (0 < *p && *p < 127) // ASCII - out << char(*p); - else - out << "[\\u" << hex << *p << "]"; - return out; -} - -void showSequence(const Sequence<OUString> &aSeq) -{ - OUString aArray; - const OUString *pStr = aSeq.getConstArray(); - for (int i=0;i<aSeq.getLength();i++) - { - OUString aStr = pStr[i]; - // aArray += aStr + ASCII(", "); - cout << aStr << endl; - } - volatile int dummy = 0; -} - -//============================================================================= - -inline void operator <<= (::rtl::OUString& _rUnicodeString, const sal_Char* _pAsciiString) -{ - _rUnicodeString = ::rtl::OUString::createFromAscii(_pAsciiString); -} - -inline void operator <<= (::rtl::OUString& _rUnicodeString, const ::rtl::OString& _rAsciiString) -{ - _rUnicodeString <<= _rAsciiString.getStr(); -} - -inline void operator <<= (Any& _rUnoValue, const sal_Char* _pAsciiString) -{ - _rUnoValue <<= ::rtl::OUString::createFromAscii(_pAsciiString); -} - -inline void operator <<= (Any& _rUnoValue, const ::rtl::OString& _rAsciiString) -{ - _rUnoValue <<= _rAsciiString.getStr(); -} - -inline void operator <<= (::rtl::OString& _rAsciiString, ::rtl::OUString const& _rUnicodeString ) -{ - _rAsciiString = rtl::OUStringToOString(_rUnicodeString, RTL_TEXTENCODING_ASCII_US).getStr(); -} - -// ----------------------------------------------------------------------------- - -rtl::OString input(const char* pDefaultText, char cEcho) -{ - // PRE: a Default Text would be shown, cEcho is a Value which will show if a key is pressed. - const int MAX_INPUT_LEN = 500; - char aBuffer[MAX_INPUT_LEN]; - - strcpy(aBuffer, pDefaultText); - int nLen = strlen(aBuffer); - -#ifdef WNT - char ch = '\0'; - - cout << aBuffer; - cout.flush(); - - while(ch != 13) - { - ch = getch(); - if (ch == 8) - { - if (nLen > 0) - { - cout << "\b \b"; - cout.flush(); - --nLen; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - else if (ch != 13) - { - if (nLen < MAX_INPUT_LEN) - { - if (cEcho == 0) - { - cout << ch; - } - else - { - cout << cEcho; - } - cout.flush(); - aBuffer[nLen++] = ch; - aBuffer[nLen] = '\0'; - } - else - { - cout << "\a"; - cout.flush(); - } - } - } -#else - if (!cin.getline(aBuffer,sizeof aBuffer)) - return OString(); -#endif - return rtl::OString(aBuffer); -} - -// ----------------------------------------------------------------------------- -rtl::OUString enterValue(const char* _aStr, const char* _aDefault, bool _bIsAPassword) -{ - cout << _aStr; - cout.flush(); - - rtl::OUString sValue; - sValue <<= input(_aDefault, _bIsAPassword ? '*' : 0); - return sValue; -} -//============================================================================= - -uno::Reference< lang::XMultiServiceFactory > getORB(); -// ----------------------------------------------------------------------------- - - -Reference< XChangesBatch > xChangesBatch = NULL; -void commit() -{ - if (xChangesBatch.is()) - { - xChangesBatch->commitChanges(); - } -} - -// ----------------------------------------------------------------------------- -static sal_Bool s_bInitialized = sal_False; -#ifdef LLA_PRIVAT_DEBUG -// static const sal_Char* s_pSourcePath = "//./l|/src632/configmgr/workben/local_io/share"; -// static const sal_Char* s_pUpdatePath = "//./l|/src632/configmgr/workben/local_io/user"; -static const sal_Char* s_pSourcePath = "file:///f:/office60_633/share/config/registry"; -static const sal_Char* s_pUpdatePath = "file:///f:/office60_633/user/config/registry"; -static const sal_Char* s_pRootNode = "org.openoffice.test"; -static const sal_Char* s_pServerType = "local"; -static const sal_Char* s_pLocale = "de-DE"; -static const sal_Char* s_pServer = ""; -static const sal_Char* s_pUser = ""; -static const sal_Char* s_pPassword = ""; -#else -static const sal_Char* s_pSourcePath = "file:///g:/src/configmgr/workben/local_io/share"; -static const sal_Char* s_pUpdatePath = "file:///g:/src/configmgr/workben/local_io/user"; -static const sal_Char* s_pRootNode = "org.openoffice.test"; -static const sal_Char* s_pServerType = "local"; -static const sal_Char* s_pLocale = "de-DE"; -static const sal_Char* s_pServer = "lautrec-3108:19205"; -static const sal_Char* s_pUser = "lars"; -static const sal_Char* s_pPassword = ""; -#endif - -static bool m_bChange = false; -// ----------------------------------------------------------------------------- -static void loadDefaults() -{ - if (s_bInitialized) - return; - - s_bInitialized = sal_True; - - try - { - // the executable file name - ::rtl::OUString sExecutable; - osl_getExecutableFile(&sExecutable.pData); - // cut the name, add a cfgapi.ini to the path - sal_Int32 nLastSep = sExecutable.lastIndexOf('/'); - if (-1 != nLastSep) - sExecutable = sExecutable.copy(0, nLastSep + 1); -#ifdef UNX - sExecutable += ::rtl::OUString::createFromAscii("cfgapirc"); -#else - sExecutable += ::rtl::OUString::createFromAscii("cfgapi.ini"); -#endif - ::rtl::OUString sNormalized; - sNormalized = sExecutable; - if (1) // osl_File_E_None == osl_normalizePath(sExecutable.pData, &sNormalized.pData)) - { - ::osl::Profile aProfile(sNormalized); - - static ::rtl::OString sSection("defaults"); - static ::rtl::OString sSourcePath("sourcepath"); - static ::rtl::OString sUpdatePath("updatepath"); - static ::rtl::OString sRootNode("rootnode"); - static ::rtl::OString sServerType("servertype"); - static ::rtl::OString sLocale("Locale"); - static ::rtl::OString sServer("Server"); - static ::rtl::OString sUser("User"); - static ::rtl::OString sPassword("Password"); - - // read some strings. - // Do this static because we want to redirect the global static character pointers to the buffers. - static ::rtl::OString s_sSourcePath = aProfile.readString(sSection, sSourcePath, s_pSourcePath); - static ::rtl::OString s_sUpdatePath = aProfile.readString(sSection, sUpdatePath, s_pUpdatePath); - static ::rtl::OString s_sRootNode = aProfile.readString(sSection, sRootNode, s_pRootNode); - static ::rtl::OString s_sServerType = aProfile.readString(sSection, sServerType, s_pServerType); - static ::rtl::OString s_sLocale = aProfile.readString(sSection, sLocale, s_pLocale); - static ::rtl::OString s_sServer = aProfile.readString(sSection, sServer, s_pServer); - static ::rtl::OString s_sUser = aProfile.readString(sSection, sUser, s_pUser); - static ::rtl::OString s_sPassword = aProfile.readString(sSection, sPassword, s_pPassword); - - // do this redirection - s_pSourcePath = s_sSourcePath.getStr(); - s_pUpdatePath = s_sUpdatePath.getStr(); - s_pRootNode = s_sRootNode.getStr(); - s_pServerType = s_sServerType.getStr(); - s_pLocale = s_sLocale.getStr(); - s_pServer = s_sServer.getStr(); - s_pUser = s_sUser.getStr(); - s_pPassword = s_sPassword.getStr(); - } - } - catch(std::exception& e) - { - e.what(); // silence warnings - } -} - -// ----------------------------------------------------------------------------- -Sequence<Any> createSequence(const OUString &sUser, const OUString &sPasswd) -{ - Sequence< Any > aCPArgs; - - if (sUser.getLength() > 0) - { - aCPArgs.realloc(1); - aCPArgs[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser); - } - if (sPasswd.getLength() > 0) - { - aCPArgs.realloc(2); - aCPArgs[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd); - } - return aCPArgs; -} - -//============================================================================= -#include <string.h> -#if (defined UNX) || (defined OS2) -#else -#include <conio.h> -#endif - -// ----------------------------------------------------------------------------- - -void test_configuration_provider(uno::Reference<lang::XMultiServiceFactory> _xCfgProvider, - rtl::OUString const& _sUser, bool _bLocal, sal_Int32 _nCount); - - -// ----------------------------------------------------------------------------- - -uno::Reference<lang::XMultiServiceFactory> -getProvider( - uno::Reference< lang::XMultiServiceFactory > _xServiceRegistry, - rtl::OUString const& _sServerType, - rtl::OUString const& _sSharePath, rtl::OUString const& _sUserPath, - bool &_bLocal) -{ - try - { - Sequence< Any > aCPArgs; - - OUString sServerType = _sServerType; // enterValue("servertype: ", s_pServerType, false); - - rtl::OUString sUser; - - _bLocal = sServerType.equalsIgnoreAsciiCase(ASCII("local")) || sServerType.equalsIgnoreAsciiCase(ASCII("setup")); - if (!_bLocal) - { - rtl::OUString sServer; - sServer = enterValue("server : ", s_pServer,false); - cout << endl; - - sUser = enterValue("user : ", s_pUser, false); - cout << endl; - - OUString sPasswd = enterValue("password: ", s_pPassword, true); - cout << endl; - - aCPArgs = createSequence(sUser, sPasswd); - - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("server"), sServer); - - OUString sTimeout = ASCII("10000"); - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("timeout"), sTimeout); - - } - else - { - rtl::OUString sSharePath, sUserPath; - sSharePath = _sSharePath;// enterValue("share path: ", s_pSourcePath, false); - // cout << endl; - sUserPath = _sUserPath; // enterValue("user path : ", s_pUpdatePath, false); - // cout << endl; - - aCPArgs.realloc(aCPArgs.getLength() + 1); - sal_Int32 nCount = aCPArgs.getLength() - 1; - Any *pAny = &aCPArgs[nCount]; - *pAny <<= configmgr::createPropertyValue(ASCII("sourcepath"), sSharePath); - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("updatepath"), sUserPath); - } - - aCPArgs.realloc(aCPArgs.getLength() + 1); - aCPArgs[aCPArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("servertype"), sServerType); - - Reference< XMultiServiceFactory > xCfgProvider( - _xServiceRegistry->createInstanceWithArguments( - ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"), - aCPArgs), - UNO_QUERY); - if (!xCfgProvider.is()) - { - ::flush(cout); - cerr << "Could not create the configuration provider !\n\n"; - return 0; - } -// ----------------------------------------------------------------------------- - return xCfgProvider; - } - catch (Exception& e) - { - ::flush(cout); - cerr << "Caught exception: " << e.Message << endl; - } - return 0; -} - -// ----------------------------------------------------------------------------- -sal_Int32 m_nCount = 0; - -void test(uno::Reference<lang::XMultiServiceFactory> _xORB, rtl::OUString const& _sSharePath, - rtl::OUString const& _sUserPath) -{ - - rtl::OUString sUser; - bool bLocal; - cout << ++m_nCount << ". start test with new provider\n"; - { - START_MEMORYMEASURE_FOR( aMemoryInfo, "*** API Test Execution ***" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "initialisierungs-check" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- Erzeuge Provider" ); - - uno::Reference<lang::XMultiServiceFactory>xCfgProvider = - getProvider(_xORB, ASCII("local"), _sSharePath, _sUserPath, - bLocal); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- Habe Provider, starte Test" ); - - test_configuration_provider(xCfgProvider, sUser, bLocal, 0); // xml - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- Test gelaufen, starte erneut" ); - - test_configuration_provider(xCfgProvider, sUser, bLocal, 0); // xml - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- Test gelaufen, entsorge Provider" ); - - uno::Reference<lang::XComponent>xComponent(xCfgProvider,UNO_QUERY); - xComponent->dispose(); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- Provider disposed" ); - - LOG_MEMORYMEASURE( "---------------- API Memory Test 2-----------------------------", "- Test memory traces.", aMemoryInfo ); - } - - cout << "finish provider test\n"; - - // Test Version 1 and 3, it MUST be equal -} - -// ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- -static rtl::OUString makeFileURL(OUString const& sMaybeURL) -{ - rtl::OUString const fileURLStart(RTL_CONSTASCII_USTRINGPARAM("file:/")); - - if ( 0 != fileURLStart.compareTo(sMaybeURL, fileURLStart.getLength()) ) - { - OUString sURL; - if (!osl_getFileURLFromSystemPath(sMaybeURL.pData, &sURL.pData)) - return sURL; - } - - return sMaybeURL; -} -// ----------------------------------------------------------------------------- -static rtl::OUString makeSystemPath(OUString const& sMaybeURL) -{ - rtl::OUString const fileURLStart(RTL_CONSTASCII_USTRINGPARAM("file:/")); - - if ( 0 == fileURLStart.compareTo(sMaybeURL, fileURLStart.getLength()) ) - { - OUString sSysPath; - if (!osl_getSystemPathFromFileURL(sMaybeURL.pData, &sSysPath.pData)) - return sSysPath; - } - - return sMaybeURL; -} -// ----------------------------------------------------------------------------- -// ---------------------------------- M A I N ---------------------------------- -// ----------------------------------------------------------------------------- - -int main( int argc, char * argv[] ) -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - sal_Int32 nSizeISubtree = sizeof(ISubtree); - sal_Int32 nSizeINode = sizeof(INode); - sal_Int32 nSizeIValueNode = sizeof(ValueNode); - { - loadDefaults(); - - Reference< XMultiServiceFactory > xORB = getORB(); - - rtl::OUString sSharePath = makeSystemPath(enterValue("share path: ", s_pSourcePath, false)); - cout << endl; - rtl::OUString sUserPath = makeSystemPath(enterValue("user path : ", s_pUpdatePath, false)); - cout << endl; - - // test(xORB, sSharePath, sUserPath, ASCII("org.openoffice.test")); - - // char* pMem = new char[1000 * 1000 * 10]; - // showMemoryStatistic(); - -// test(xORB, sSharePath, sUserPath, ASCII("org.openoffice.Office.Views")); - - START_MEMORYMEASURE_FOR( aMemoryInfo, "*** API Test Main ***" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "initialisierungs-check" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "starte test !" ); - - test(xORB, sSharePath, sUserPath); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "tests beendet !" ); - - // stop the programm clear. - Reference< XComponent > xComponent(xORB, UNO_QUERY); - xComponent->dispose(); - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "ORB disposed." ); - - LOG_MEMORYMEASURE( "---------------- API Memory Test-------------------------------", "Outer memory traces.", aMemoryInfo ); - } - return 0; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -void test(Reference< XHierarchicalName >& xAccessName) -{ - if (xAccessName.is()) - { - // cout << "Accessing Node: " << xAccessName->getHierarchicalName(); - } - else - { - // cout << "BUG: XHierarchicalName not available"; - } - // cout << endl; -} -void test(Reference< XNamed >& xAccess) -{ - if (xAccess.is()) - { - // cout << "Node is named: " << xAccess->getName(); - } - else - { - // cout << "BUG: XNamed not available"; - } - // cout << endl; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -void fillAllNames(Reference<XNameAccess >& xAccess, Sequence<OUString>& _aSeq) -{ - if (xAccess.is()) - { - _aSeq = Sequence <OUString>(xAccess->getElementNames()); - - // cout << "Element Names: (" << _aSeq.getLength() << ")"; - // for (int i = 0; i < _aSeq.getLength(); ++i) - // cout << "\n[" << i << "] -\t" << _aSeq[i]; - //cout << endl; - } - else - { - // cout << "BUG: XNameAccess not available"; - } - // cout << endl; -} -void write(Reference< XChild >& xChild) -{ - if (xChild.is()) - { - // cout << "\n[ P ] -\tParent"; - } - else - { - // cout << "BUG: Parent not available (no XChild)"; - } - // cout << endl; -} -/////////////////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -Reference< XInterface > readaccess(uno::Reference< lang::XMultiServiceFactory > &xMSF, - uno::Reference< uno::XInterface > const& xIface, - rtl::OString const& buf, - ostream& outStream) -{ - Reference< XInterface > xNext; - try - { - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - Reference< XHierarchicalNameAccess > xDeepAccess(xIface, UNO_QUERY); - Reference< XExactName > xExactName(xIface, UNO_QUERY); - - if (xAccess.is() || xDeepAccess.is()) - { - OUString aName; - OUString aInput = OUString::createFromAscii(buf); - - if (xExactName.is()) - { - ::rtl::OUString sTemp = xExactName->getExactName(aInput); - if (sTemp.getLength()) - aInput = sTemp; - } - - if (xAccess.is() && xAccess->hasByName(aInput)) - { - aName = aInput; - } - else if (xDeepAccess.is() && xDeepAccess->hasByHierarchicalName(aInput)) - { - aName = aInput; - } - else if ('0' <= buf[0] && buf[0] <= '9' && xAccess.is()) - { - int n = atoi(buf); - Sequence<OUString> aNames = xAccess->getElementNames(); - if (0 <= n && n < aNames.getLength()) - aName = aNames[n]; - } - - if (aName.getLength()) - { - bool bNest = aInput.indexOf(sal_Unicode('/')) >= 0; - - Any aElement = bNest ? - ( xDeepAccess.is() ? - xDeepAccess->getByHierarchicalName(aName) : Any() - ) : - ( xAccess.is() ? - xAccess->getByName(aName) : Any() - ); - - while (aElement.getValueTypeClass() == TypeClass_ANY) - { - Any aWrap(aElement); - aWrap >>= aElement; - } - sal_Bool bValue = true; - sal_Bool bValueOk = false; - - switch (aElement.getValueTypeClass() ) - { - case TypeClass_INTERFACE: - bValue = false; - if (aElement >>= xNext) - { - outStream << "Group: " << aName << endl; - } - else - { - outStream << "ERROR: can't get the interface" << endl; - } - break; - case TypeClass_BOOLEAN: - { - sal_Bool* pVal = (sal_Bool*)aElement.getValue(); - bValueOk = (pVal != 0); - - outStream << "VALUE '" << aName << "' is a BOOLEAN = "; - if (!bValueOk) - outStream << "NULL (error!!)"; - else if (*pVal) - outStream << "'TRUE'"; - else - outStream << "'FALSE'"; - - outStream << endl; - - // tryToChange(xAccess, aName, pVal); - break; - } - case TypeClass_SHORT: - { - sal_Int16 aValue; - outStream << "VALUE '" << aName << "' is a SHORT (16 bit) = "; - if (bValueOk = (aElement >>= aValue)) - { - outStream << aValue; - // tryToChange(xAccess, aName, aValue); - } - else - { - outStream << "ERROR RETRIEVING VALUE"; - } - outStream << endl; - - break; - } - case TypeClass_LONG: - { - - sal_Int32 aValue; - outStream << "VALUE '" << aName << "' is a INT (32 bit) = "; - if (bValueOk = (aElement >>= aValue)) - { - outStream << aValue; - // tryToChange(xAccess, aName, aValue); - } - else - { - outStream << "ERROR RETRIEVING VALUE"; - } - outStream << endl; - break; - } - case TypeClass_HYPER: - { - sal_Int64 aValue; - outStream << "VALUE '" << aName << "' is a LONG (64 bit) = "; - if (bValueOk = (aElement >>= aValue)) - { - outStream << double(aValue); - // tryToChange(xAccess, aName, aValue); - } - else - { - outStream << "ERROR RETRIEVING VALUE"; - } - outStream << endl; - break; - } - case TypeClass_DOUBLE: - { - double aValue; - outStream << "VALUE '" << aName << "' is a DOUBLE = "; - if (bValueOk = (aElement >>= aValue)) - { - outStream << aValue; - } - else - { - outStream << "ERROR RETRIEVING VALUE"; - } - outStream << endl; - break; - } - case TypeClass_STRING: - { - OUString aValue; - outStream << "VALUE '" << aName << "' is a STRING = "; - if (bValueOk = (aElement >>= aValue)) - { - outStream << "\"" << aValue << "\""; - // tryToChange(xAccess, aName, aValue); - } - else - { - outStream << "ERROR RETRIEVING VALUE"; - } - outStream << endl; - break; - } - case TypeClass_SEQUENCE: - { - outStream << "VALUE '" << aName << "' is a SEQUENCE or BINARY" << endl; - - Type aTypeS = configmgr::getSequenceElementType(aElement.getValueType()); - OUString sType = configmgr::toTypeName(aTypeS.getTypeClass()); - outStream << "UNO type is " << aElement.getValueType().getTypeName() << endl; - outStream << "Real type is Sequence<" << sType << ">" << endl; - // outSequence(aElement, aTypeS, outStream); - bValueOk = true; - break; - } - case TypeClass_VOID: - outStream << "ELEMENT '" << aName << "' is NULL and VOID " << endl; - bValueOk = true; - break; - default: - outStream << "Error: ELEMENT '" << aName << "' is of unknown or unrecognized type" << endl; - break; - } - - } - else - { - outStream << "Error: No element \"" << aInput << "\" found." <<endl; - } - } - } - catch (Exception& e) - { - outStream << "An Exception occurred: " << e.Message << endl; - } - catch (...) - { - outStream << "An UNKNOWN Exception occurred !" << endl; - } - - return xNext; -} - - - - -// ----------------------------------------------------------------------------- -void test_read_access( uno::Reference< lang::XMultiServiceFactory > &xMSF, - uno::Reference< uno::XInterface >& xIface, - ofstream & out) -{ - Sequence<OUString> aAllNames; - - using com::sun::star::uno::UNO_QUERY; - - // cout << "\n\n---------------------------------------------------------------" << endl; - Reference< XNameAccess > xAccess(xIface, UNO_QUERY); - Reference< XChild > xChild(xIface, UNO_QUERY); - Reference< XHierarchicalName > xAccessPath(xIface,UNO_QUERY); - Reference< XNamed > xAccessName(xIface,UNO_QUERY); -// Reference< XHierarchicalNameAccess >& xAccess(xIface, UNO_QUERY); - - test(xAccessPath); - test(xAccessName); - fillAllNames(xAccess, aAllNames); - write(xChild); - - for (sal_Int32 i=0;i<aAllNames.getLength();i++) - { - OString aValue; - aValue <<= aAllNames[i]; - uno::Reference<uno::XInterface> xFace = readaccess(xMSF, xIface, aValue, out); - if (xFace.is()) - { - test_read_access(xMSF, xFace, out); - } - } -} - -// ----------------------------------------------------------------------------- -void test_read_access( uno::Reference< lang::XMultiServiceFactory > &xMSF, - uno::Reference< uno::XInterface >& xIface, - rtl::OString aFilename) -{ - ofstream out(aFilename.getStr()); - test_read_access(xMSF, xIface, out); -} - -// ----------------------------------------------------------------------------- -void test_configuration_provider(uno::Reference<lang::XMultiServiceFactory> _xCfgProvider, - rtl::OUString const& _sUser, bool _bLocal, - sal_Int32 _nCount) -{ - START_MEMORYMEASURE_FOR( aMemoryInfo, "*** Configuration Provider Loop Test ***" ); - START_MEMORYMEASURE_FOR( aInnerMemoryInfo, "*** Configuration Provider Module Details ***" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "initialisierungs-check" ); - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "initialisierungs-check" ); - - std::vector< Reference< XInterface > > aLoadedModules; - aLoadedModules.reserve(configtest::s_nTestModules); - - Sequence< Any > aArgs; - aArgs = createSequence(_sUser, ASCII("")); - - if (!_bLocal) - { - OUString sLocale = enterValue("locale : ", s_pLocale, false); - cout << endl; - aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("locale"), sLocale); - } - -#if 0 - sal_Bool bLazyWrite = true; - aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("lazywrite"), bLazyWrite); -#else - sal_Bool bNoCache = true; - aArgs.realloc(aArgs.getLength() + 1); - aArgs[aArgs.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("nocache"), bNoCache); -#endif - - sal_Int32 nPathIdx = aArgs.getLength(); - aArgs.realloc(nPathIdx + 1); - - const OString sInnerInfoText("- - - Loading module: "); - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "- - - Before Loading Modules" ); - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- - Prepared Arguments - Lade Module" ); - - for (char const * const * ppTestModule = configtest::s_aTestModules; *ppTestModule; ++ppTestModule) - { - OUString sPath = OUString::createFromAscii(*ppTestModule); - cout << "\t" << ++_nCount << ". test with node: " << sPath << endl; - - aArgs[nPathIdx] <<= configmgr::createPropertyValue(ASCII("nodepath"), sPath); - - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, sInnerInfoText.concat(*ppTestModule) ); - Reference< XInterface > xIFace = _xCfgProvider->createInstanceWithArguments( - /* OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"), */ - OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), - aArgs); - // cout << "---------------------------------------------------------------\n Configuration Read/Write Access created !\n---------------------------------------------------------------" << endl; - - aLoadedModules.push_back(xIFace); - /* - xChangesBatch = Reference< XChangesBatch >(xIFace, UNO_QUERY); - - Sequence<OUString> aSeq = _xCfgProvider->getAvailableServiceNames(); - - OString sPath; - sPath <<= _sPath; - - OString aFilename = "c:\\temp\\fileout_"; - aFilename += sPath; - aFilename += OString::valueOf(_nCount); - aFilename += ".txt"; - test_read_access(_xCfgProvider, xIFace, aFilename); - */ - } - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "- - - Done Loading modules" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- - Alle Module geladen" ); - - aLoadedModules.clear(); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "- - Module released" ); - - LOG_MEMORYMEASURE( "---------------- API Memory Test 3 -----------------------------", "- - Provider memory traces.", aMemoryInfo ); - LOG_MEMORYMEASURE( "---------------- API Memory Test 4 -----------------------------", "- - - Module memory traces.", aInnerMemoryInfo ); - -} - - -// ----------------------------------------------------------------------------- -// ----------------------------------- Main 2 ----------------------------------- -// ----------------------------------------------------------------------------- - -int requestTest( int argc, char * argv[] ) -{ - TimeValue aTimeout; - aTimeout.Seconds = 5; - aTimeout.Nanosec = 0; - - sal_Int32 nSizeISubtree = sizeof(ISubtree); - sal_Int32 nSizeINode = sizeof(INode); - sal_Int32 nSizeIValueNode = sizeof(ValueNode); - { - loadDefaults(); - - Reference< XMultiServiceFactory > xORB = getORB(); - - rtl::OUString sSharePath = makeFileURL(enterValue("share path: ", s_pSourcePath, false)); - cout << endl; - rtl::OUString sUserPath = makeFileURL(enterValue("user path : ", s_pUpdatePath, false)); - cout << endl; - - START_MEMORYMEASURE_FOR( aMemoryInfo, "*** Request Tree Test ***" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "initialisierungs-check" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "create tree manager" ); - - OTreeLoad aTreeLoad(xORB, sSharePath, sUserPath); - sal_Int32 nIdx = 0; - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "created tree manager" ); - - OString const sInnerInfoText("- Loading module: "); - - START_MEMORYMEASURE_FOR( aInnerMemoryInfo, "*** Request Tree Test Details ***" ); - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "initialisierungs-check" ); - - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "- before loading modules" ); - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "request subtrees" ); - - for (char const * const * ppRequestModule = configtest::s_aTestModules; *ppRequestModule; ++ppRequestModule) - { - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, sInnerInfoText.concat(*ppRequestModule) ); - aTreeLoad.requestSubtree( OUString::createFromAscii(*ppRequestModule)); - } - - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "- loaded all modules" ); - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "release subtrees" ); - - for (char const * const * ppReleaseModule = configtest::s_aTestModules; *ppReleaseModule; ++ppReleaseModule) - aTreeLoad.releaseSubtree( OUString::createFromAscii(*ppReleaseModule)); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "ich habe fertig." ); - LOG_MEMORYMEASURE( "---------------- Request Memory Test ---------------------------", "Direct Cache Access memory traces.", aMemoryInfo ); - LOG_MEMORYMEASURE( "---------------- Request Memory Detail -------------------------", "Module request memory traces.", aInnerMemoryInfo ); - } - return 0; -} - -// ----------------------------------------------------------------------------- -// --------------------------------- Trust Test --------------------------------- -// ----------------------------------------------------------------------------- - -int trust( int argc, char * argv[] ) -{ - Reference< XMultiServiceFactory > xORB = getORB(); - - std::vector<char*> aMemHolder; - aMemHolder.reserve(1024); - - START_MEMORYMEASURE_FOR( aMemoryInfo, "Allocator check" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "initialisierungs-check" ); - - sal_Int32 const total_alloc = 8 * 1024 * 1024; - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "get 8 MB" ); - - char* pChar = new char[total_alloc]; - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "free 8 MB" ); - - delete [] pChar; - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "deleted 8 MB" ); - - sal_Int32 const chunk = 8 * 1024; - sal_Int32 const alloc_count = total_alloc/chunk; - - sal_Int32 const msg_count = 16; - sal_Int32 const loop_count = alloc_count/msg_count; - sal_Int32 const loop_allocation = loop_count * chunk; - - OString const sPieces = OString::valueOf(alloc_count).concat(" pieces"); - OString const sInnerMessage = OString("Allocating ").concat(OString::valueOf(loop_count)) - .concat(" chunks [").concat(OString::valueOf(loop_allocation)).concat(" Bytes]."); - - START_MEMORYMEASURE( aInnerMemoryInfo ); - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "initialisierungs-check" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, OString("get 8 MB as ").concat(sPieces) ); - - for (sal_Int32 i=0;i<alloc_count/loop_count;i++) - { - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, sInnerMessage ); - for (sal_Int32 j=0;j<loop_count;j++) - { - - pChar = new char[8 * 1024]; - aMemHolder.push_back(pChar); - } - } - MAKE_MEMORY_SNAPSHOT( aInnerMemoryInfo, "last allocation done" ); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "free pieces" ); - - pChar = NULL; - for (std::vector<char*>::iterator it = aMemHolder.begin(); - it != aMemHolder.end(); - it++) - { - pChar = *it; - delete []pChar; - } - aMemHolder.clear(); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, OString("get another 8 MB as ").concat(sPieces) ); - - - for (sal_Int32 j=0;j<alloc_count;j++) - { - pChar = new char[8 * 1024]; - aMemHolder.push_back(pChar); - } - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "free second set of pieces" ); - - pChar = NULL; - for (std::vector<char*>::iterator jt = aMemHolder.begin(); - jt != aMemHolder.end(); - jt++) - { - pChar = *jt; - delete []pChar; - } - aMemHolder.clear(); - - MAKE_MEMORY_SNAPSHOT( aMemoryInfo, "ich habe fertig." ); - LOG_MEMORYMEASURE( "---------------- Trust Memory Test ----------------------------", "Cross-checked memory traces.", aMemoryInfo ); - LOG_MEMORYMEASURE( "---------------- Small Allocation Loop ------------------------", "Allocation Loop Detail memory traces.", aInnerMemoryInfo ); - - return 0; -} - -// ----------------------------------------------------------------------------- -static uno::Reference< lang::XMultiServiceFactory > g_xORB; -static void createORB(char const* pRegistry) -{ - if (!g_xORB.is()) - try - { - rtl::OUString const sServiceRegistry = OUString::createFromAscii(pRegistry); - - g_xORB = createRegistryServiceFactory( sServiceRegistry, ::rtl::OUString() ); - - } - catch (uno::Exception &e) - { - cerr << "Exception creating the service factory: " << e.Message << "\n"; - } - else - cerr << "Trying to recreate the service factory\n"; - - if (!g_xORB.is()) - { - ::flush(cout); - cerr << "Could not create the service factory '" << pRegistry << "' !\n"; - exit(-2); - } -} -uno::Reference< lang::XMultiServiceFactory > getORB() -{ - if (!g_xORB.is()) - { - createORB( "applicat.rdb" ); - } - return g_xORB; -} -// ----------------------------------------------------------------------------- - - -} // namespace configmgr -// ----------------------------------------------------------------------------- -void usage() -{ - cerr << "Wrong or missing parameters.\nUsage:\n" - "\tmemorytest [-r <registry.rdb>] (all | trust | request | api)+ [clear] [(+<module>|-<module>)+]\n"; - - exit(-1); -} - -// ----------------------------------------------------------------------------- -// ------------------------------------ Main ------------------------------------ -// ----------------------------------------------------------------------------- -#if (defined UNX) || (defined OS2) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - if (argc > 1 && !::rtl_str_compare(argv[1], "-r" ) ) - { - if (!argv[2]) usage(); - - configmgr::createORB(argv[2]); - - argv += 2; - argc -= 2; - } - configmgr::getORB(); // ensures there is one - - enum TestSelect { TEST_TRUST = 01, TEST_REQUEST = 02, TEST_API = 04, TEST_ALL = 07 }; - - unsigned nSelect = 0; - while (argc >= 1 && argv[1] != NULL) - { - if ( !::rtl_str_compareIgnoreAsciiCase(argv[1], "trust" ) ) nSelect |= TEST_TRUST; - else if ( !::rtl_str_compareIgnoreAsciiCase(argv[1], "request") ) nSelect |= TEST_REQUEST; - else if ( !::rtl_str_compareIgnoreAsciiCase(argv[1], "api" ) ) nSelect |= TEST_API; - else if ( !::rtl_str_compareIgnoreAsciiCase(argv[1], "all" ) ) nSelect |= TEST_ALL; - else break; - - // here we found a known selector, so look on - ++argv; - --argc; - } - - if (nSelect == 0) usage(); - -//-------------------- -#define DO_TEST( test, func ) \ - if (nSelect & TEST_##test) \ - { \ - char const * const test_name = #test; \ - if (int nRet = func(argc, argv)) \ - cerr << "Test: " << test_name << " returned with error code " << nRet << endl; \ - else \ - cerr << "Test: " << test_name << " finished without error !\n" ; \ - } else // to allow a semicolon -//-------------------- - - DO_TEST( TRUST , configmgr::trust ); - DO_TEST( REQUEST , configmgr::requestTest ); - DO_TEST( API , configmgr::main ); - - return 0; -} - diff --git a/configmgr/workben/memory/testmodules.cxx b/configmgr/workben/memory/testmodules.cxx deleted file mode 100644 index 2967a962c56a..000000000000 --- a/configmgr/workben/memory/testmodules.cxx +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include "testmodules.hxx" - - -namespace configtest -{ - #if 0 // more modules - +"org.openoffice.Office.Common", - +"org.openoffice.Office.Linguistic", - x"org.openoffice.Office.TypeDetection", - x"org.openoffice.Setup", - -"org.openoffice.UserProfile", - +"org.openoffice.Inet", - -"org.openoffice.Office.Calc", - -"org.openoffice.Office.Chart", - -"org.openoffice.Office.DataAccess", - -"org.openoffice.Office.Draw", - -"org.openoffice.Office.Impress", - -"org.openoffice.Office.Java", - -"org.openoffice.Office.Labels", - -"org.openoffice.Office.Math", - +"org.openoffice.Office.Views", - +"org.openoffice.Office.Writer", - +"org.openoffice.Office.WriterWeb", - +"org.openoffice.ucb.Configuration", - -"org.openoffice.ucb.Hierarchy", - x"org.openoffice.ucb.Store", - #endif - - char const * const s_aTestModules[] = - { - "org.openoffice.Office.Common", - "org.openoffice.Setup/CJK/Enable", - "org.openoffice.Setup/Office/Modules", - "org.openoffice.Inet", - "org.openoffice.Office.Views", - "org.openoffice.Setup/Product", - "org.openoffice.ucb.Configuration", - "org.openoffice.ucb.Store/ContentProperties", - "org.openoffice.Office.TypeDetection", - "org.openoffice.Office.Writer", - "org.openoffice.Office.WriterWeb", - "org.openoffice.Office.Linguistic", - NULL // end marker - }; - unsigned int const s_nTestModules = sizeof s_aTestModules/sizeof 0[s_aTestModules]; - - std::vector<char const *> listTestModules(int argc, char* argv[]) - { - std::vector<char const *> aModuleList( s_aTestModules, s_aTestModules + s_nTestModules); - return aModuleList; - } -} - - diff --git a/configmgr/workben/memory/testmodules.hxx b/configmgr/workben/memory/testmodules.hxx deleted file mode 100644 index 96d6becf775d..000000000000 --- a/configmgr/workben/memory/testmodules.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************* - * - * 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 CONFIGMGR_WORKBEN_TESTMODULES_ -#include <vector> - -namespace configtest -{ - extern char const * const s_aTestModules[]; - extern unsigned int const s_nTestModules; - extern std::vector<char const *> listTestModules(int argc, char* argv[]); -} -#endif // CONFIGMGR_WORKBEN_TESTMODULES_ - diff --git a/configmgr/workben/memory/treeload.cxx b/configmgr/workben/memory/treeload.cxx deleted file mode 100644 index 11ce7c40a6b9..000000000000 --- a/configmgr/workben/memory/treeload.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <localsession.hxx> -#include <treecache.hxx> -#include <options.hxx> -#include <rtl/ustring.hxx> -#include "treeload.hxx" - -// ----------------------------------------------------------------------------- -namespace configmgr -{ - namespace uno = ::com::sun::star::uno; - namespace lang = ::com::sun::star::lang; - -#define ASCII(x) ::rtl::OUString::createFromAscii(x) - -// ----------------------------------------------------------------------------- -// ------------------------- requestSubtree without API ------------------------- -// ----------------------------------------------------------------------------- - - OTreeLoad::OTreeLoad(uno::Reference<lang::XMultiServiceFactory> const& _xServiceProvider, - rtl::OUString const& _sSourceDirectory, rtl::OUString const& _sUpdateDirectory) throw (uno::Exception) - :m_xServiceProvider(_xServiceProvider) -{ - // Create a TypeConverter - uno::Reference<script::XTypeConverter> xConverter; - xConverter = xConverter.query(m_xServiceProvider->createInstance(ASCII( "com.sun.star.script.Converter" )) ); - - m_xDefaultOptions = new OOptions(xConverter); - m_xDefaultOptions->setNoCache(true); - - // create it .. and connect - std::auto_ptr<LocalSession> pLocal( new LocalSession(m_xServiceProvider) ); - sal_Bool bOpen = pLocal->open(_sSourceDirectory, _sUpdateDirectory); - - IConfigSession* pConfigSession = pLocal.release(); - - m_pTreeMgr = new TreeManager(pConfigSession, m_xDefaultOptions); -} -// ----------------------------------------------------------------------------- -ISubtree* OTreeLoad::requestSubtree( OUString const& aSubtreePath) throw (uno::Exception) -{ - return m_pTreeMgr->requestSubtree(aSubtreePath, m_xDefaultOptions, /* MinLevel */ -1); -} -// ----------------------------------------------------------------------------- -void OTreeLoad::releaseSubtree( OUString const& aSubtreePath) throw (uno::Exception) -{ - m_pTreeMgr->releaseSubtree(aSubtreePath, m_xDefaultOptions); -} - -// ----------------------------------------------------------------------------- -} // namespace diff --git a/configmgr/workben/memory/treeload.hxx b/configmgr/workben/memory/treeload.hxx deleted file mode 100644 index 088c5d24d4cc..000000000000 --- a/configmgr/workben/memory/treeload.hxx +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CONFIGMGR_TREELOAD_HXX -#define CONFIGMGR_TREELOAD_HXX - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -#ifndef _CONFIGMGR_LOCAL_LOCAL_HXX_ -#include <localsession.hxx> -#endif - -#ifndef _CONFIGMGR_TREECACHE_HXX_ -#include <treecache.hxx> -#endif -#include <options.hxx> -#include <rtl/ustring.hxx> - -// ----------------------------------------------------------------------------- -namespace configmgr -{ - namespace uno = ::com::sun::star::uno; - namespace lang = ::com::sun::star::lang; - -// ----------------------------------------------------------------------------- -class OTreeLoad -{ - // LocalSession* m_pLocalSession; // in TreeMgr - TreeManager* m_pTreeMgr; - ::vos::ORef<OOptions> m_xDefaultOptions; - uno::Reference<lang::XMultiServiceFactory> m_xServiceProvider; - -public: - - OTreeLoad(uno::Reference<lang::XMultiServiceFactory> const& _xServiceProvider, - rtl::OUString const& _sSourceDirectory, rtl::OUString const& _sUpdateDirectory); - - ISubtree* requestSubtree(rtl::OUString const& aSubtreePath); - void releaseSubtree(rtl::OUString const& aSubtreePath); -}; - -} // namespace - -#endif |