1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cfgapi_timetest.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_configmgr.hxx"
33 #define _PRIVATE_TEST_
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/uno/Type.hxx>
42 #include <com/sun/star/uno/TypeClass.hpp>
44 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
45 #include <com/sun/star/container/XNameAccess.hpp>
46 #include <com/sun/star/container/XHierarchicalName.hpp>
47 #include <com/sun/star/container/XNamed.hpp>
48 #include <com/sun/star/container/XNameReplace.hpp>
49 #include <com/sun/star/container/XChild.hpp>
50 #include <com/sun/star/beans/XExactName.hpp>
51 #include <com/sun/star/util/XChangesBatch.hpp>
54 #include <rtl/ustring.hxx>
55 #include <rtl/string.hxx>
56 #include <cppuhelper/servicefactory.hxx>
57 #include <com/sun/star/uno/Sequence.h>
58 #include <com/sun/star/uno/Any.h>
59 #include <osl/profile.hxx>
60 #include <osl/process.h>
63 #include "createpropertyvalue.hxx"
65 #include "typeconverter.hxx"
67 // #include <com/sun/star/configuration/XConfigurationSync.hpp>
69 using namespace ::com::sun::star::uno
;
70 using namespace ::com::sun::star::lang
;
71 using namespace ::com::sun::star::container
;
72 using namespace ::com::sun::star::beans
;
73 //using namespace ::com::sun::star::util;
74 using namespace ::com::sun::star::util
;
76 using ::rtl::OUString
;
78 //using namespace ::configmgr;
80 using namespace ::cppu
;
82 #define ASCII(x) ::rtl::OUString::createFromAscii(x)
84 bool m_bInteractive
= false;
86 #define COUT if(m_bInteractive) cout
88 ostream
& operator << (ostream
& out
, rtl::OUString
const& aStr
)
90 sal_Unicode
const* const pStr
= aStr
.getStr();
91 sal_Unicode
const* const pEnd
= pStr
+ aStr
.getLength();
92 for (sal_Unicode
const* p
= pStr
; p
< pEnd
; ++p
)
93 if (0 < *p
&& *p
< 127) // ASCII
96 out
<< "[\\u" << hex
<< *p
<< "]";
100 void showSequence(const Sequence
<OUString
> &aSeq
)
103 const OUString
*pStr
= aSeq
.getConstArray();
104 for (int i
=0;i
<aSeq
.getLength();i
++)
106 OUString aStr
= pStr
[i
];
107 // aArray += aStr + ASCII(", ");
108 COUT
<< aStr
<< endl
;
110 volatile int dummy
= 0;
113 //=============================================================================
115 inline void operator <<= (::rtl::OUString
& _rUnicodeString
, const sal_Char
* _pAsciiString
)
117 _rUnicodeString
= ::rtl::OUString::createFromAscii(_pAsciiString
);
120 inline void operator <<= (::rtl::OUString
& _rUnicodeString
, const ::rtl::OString
& _rAsciiString
)
122 _rUnicodeString
<<= _rAsciiString
.getStr();
125 inline void operator <<= (Any
& _rUnoValue
, const sal_Char
* _pAsciiString
)
127 _rUnoValue
<<= ::rtl::OUString::createFromAscii(_pAsciiString
);
130 inline void operator <<= (Any
& _rUnoValue
, const ::rtl::OString
& _rAsciiString
)
132 _rUnoValue
<<= _rAsciiString
.getStr();
135 //=============================================================================
136 void test_read_access(Reference
< XInterface
>& xIface
, const Reference
< XMultiServiceFactory
> &xMSF
);
137 //=============================================================================
139 // -----------------------------------------------------------------------------
140 struct prompt_and_wait
143 prompt_and_wait(char const* text
= "") : myText(text
) {}
148 COUT
<< myText
<< ">" << endl
;
149 int const mx
= int( (+0u - +1u) >> 1);
152 if (cin
.get(c
) && c
!= '\n')
157 static prompt_and_wait
exit_prompt("Quitting\nQ");
160 Reference
< XChangesBatch
> xChangesBatch
= NULL
;
163 if (xChangesBatch
.is())
165 xChangesBatch
->commitChanges();
169 // -----------------------------------------------------------------------------
170 static sal_Bool s_bInitialized
= sal_False
;
171 static const sal_Char
* s_pSourcePath
= "f:/office60_623/share/config/registry";
172 static const sal_Char
* s_pUpdatePath
= "f:/office60_623/user/config/registry";
173 static const sal_Char
* s_pRootNode
= "org.openoffice.Office.Common";
174 static const sal_Char
* s_pServerType
= "local";
175 static const sal_Char
* s_pLocale
= "de-DE";
176 static const sal_Char
* s_pServer
= "lautrec-3108:19205";
177 static const sal_Char
* s_pUser
= "lars";
178 static const sal_Char
* s_pPassword
= "";
180 std::vector
<rtl::OString
> m_sNodes
;
182 // -----------------------------------------------------------------------------
183 static void loadDefaults()
188 s_bInitialized
= sal_True
;
192 // the executable file name
193 ::rtl::OUString sExecutable
;
194 osl_getExecutableFile(&sExecutable
.pData
);
195 // cut the name, add a cfgapi.ini to the path
196 sal_Int32 nLastSep
= sExecutable
.lastIndexOf('/');
198 sExecutable
= sExecutable
.copy(0, nLastSep
+ 1);
200 sExecutable
+= ::rtl::OUString::createFromAscii("cfgapirc");
202 sExecutable
+= ::rtl::OUString::createFromAscii("cfgapi.ini");
204 ::rtl::OUString sSystem
;
205 if (osl_File_E_None
== osl_getSystemPathFromFileURL(sExecutable
.pData
, &sSystem
.pData
))
207 ::osl::Profile
aProfile(sExecutable
);
209 static ::rtl::OString
sSection("defaults");
210 static ::rtl::OString
sSourcePath("sourcepath");
211 static ::rtl::OString
sUpdatePath("updatepath");
212 static ::rtl::OString
sRootNode("rootnode");
213 static ::rtl::OString
sServerType("servertype");
214 static ::rtl::OString
sLocale("Locale");
215 static ::rtl::OString
sServer("Server");
216 static ::rtl::OString
sUser("User");
217 static ::rtl::OString
sPassword("Password");
219 // read some strings.
220 // Do this static because we want to redirect the global static character pointers to the buffers.
221 static ::rtl::OString s_sSourcePath
= aProfile
.readString(sSection
, sSourcePath
, s_pSourcePath
);
222 static ::rtl::OString s_sUpdatePath
= aProfile
.readString(sSection
, sUpdatePath
, s_pUpdatePath
);
223 static ::rtl::OString s_sRootNode
= aProfile
.readString(sSection
, sRootNode
, s_pRootNode
);
224 static ::rtl::OString s_sServerType
= aProfile
.readString(sSection
, sServerType
, s_pServerType
);
225 static ::rtl::OString s_sLocale
= aProfile
.readString(sSection
, sLocale
, s_pLocale
);
226 static ::rtl::OString s_sServer
= aProfile
.readString(sSection
, sServer
, s_pServer
);
227 static ::rtl::OString s_sUser
= aProfile
.readString(sSection
, sUser
, s_pUser
);
228 static ::rtl::OString s_sPassword
= aProfile
.readString(sSection
, sPassword
, s_pPassword
);
230 // do this redirection
231 s_pSourcePath
= s_sSourcePath
.getStr();
232 s_pUpdatePath
= s_sUpdatePath
.getStr();
233 s_pRootNode
= s_sRootNode
.getStr();
234 s_pServerType
= s_sServerType
.getStr();
235 s_pLocale
= s_sLocale
.getStr();
236 s_pServer
= s_sServer
.getStr();
237 s_pUser
= s_sUser
.getStr();
238 s_pPassword
= s_sPassword
.getStr();
240 static ::rtl::OString
sNodeSection("nodes");
241 static ::rtl::OString
sCount("count");
242 rtl::OUString sCountValue
;
243 sCountValue
<<= aProfile
.readString(sNodeSection
, sCount
, "0");
244 sal_Int32 nCount
= sCountValue
.toInt32();
245 for (sal_Int32 i
=0;i
<nCount
;i
++)
247 ::rtl::OString
sNodeName("node");
248 sNodeName
+= OString::valueOf(i
);
249 ::rtl::OString sNode
= aProfile
.readString(sNodeSection
, sNodeName
, "");
250 m_sNodes
.push_back(sNode
);
254 catch(std::exception
& e
)
256 e
.what(); // silence warnings
260 // -----------------------------------------------------------------------------
261 Sequence
<Any
> createSequence(const OUString
&sUser
, const OUString
&sPasswd
)
263 Sequence
< Any
> aCPArgs
;
265 if (sUser
.getLength() > 0)
268 aCPArgs
[0] <<= configmgr::createPropertyValue(ASCII("user"), sUser
);
270 if (sPasswd
.getLength() > 0)
273 aCPArgs
[1] <<= configmgr::createPropertyValue(ASCII("password"), sPasswd
);
278 //=============================================================================
280 #if (defined UNX) || (defined OS2)
285 OString
input(const char* pDefaultText
, char cEcho
)
287 // PRE: a Default Text would be shown, cEcho is a Value which will show if a key is pressed.
288 const int MAX_INPUT_LEN
= 500;
289 char aBuffer
[MAX_INPUT_LEN
];
291 strcpy(aBuffer
, pDefaultText
);
292 int nLen
= strlen(aBuffer
);
310 aBuffer
[nLen
] = '\0';
320 if (nLen
< MAX_INPUT_LEN
)
331 aBuffer
[nLen
++] = ch
;
332 aBuffer
[nLen
] = '\0';
342 if (!cin
.getline(aBuffer
,sizeof aBuffer
))
345 return OString(aBuffer
);
349 // -----------------------------------------------------------------------------
350 rtl::OUString
enterValue(const char* _aStr
, const char* _aDefault
, bool _bIsAPassword
)
358 sValue
<<= input(_aDefault
, _bIsAPassword
? '*' : 0);
362 sValue
<<= _aDefault
;
369 void ask_for_a_node_and_test_it(const Reference
< XMultiServiceFactory
> &xCfgProvider
,
370 const OUString
& sUser
, const OUString
&sPasswd
,
371 const OUString
& sPath
, bool bLocal
, const OUString
&sLocale
);
373 // -----------------------------------------------------------------------------
374 // ---------------------------------- M A I N ----------------------------------
375 // -----------------------------------------------------------------------------
377 #if (defined UNX) || (defined OS2)
378 int main( int argc
, char * argv
[] )
380 int _cdecl
main( int argc
, char * argv
[] )
384 aTimeout
.Seconds
= 5;
385 aTimeout
.Nanosec
= 0;
387 // COUT << " Please insert Text: ";
389 // OString aTxt = input("Der Text", 0);
390 // COUT << endl << "You inserted: " << aTxt.getStr() << endl;
392 // COUT << "Please insert Password: ";
394 // OString aPasswd = input("", '*');
395 // COUT << endl << "You inserted: " << aPasswd.getStr() << endl;
399 m_bInteractive
= false;
402 // OString aParam(argv[1]);
403 // if (aParam.equals("ask"))
405 // m_bInteractive = true;
411 OUString
const sServiceRegistry
= OUString::createFromAscii( argc
> 1 ? argv
[1] : "applicat.rdb" );
412 Reference
< XMultiServiceFactory
> xORB
= createRegistryServiceFactory(
419 cerr
<< "Could not create the service factory !\n\n";
422 COUT
<< "Service factory created !\n---------------------------------------------------------------" << endl
;
424 Sequence
< Any
> aCPArgs
;
426 OUString sServerType
= enterValue("servertype: ", s_pServerType
, false);
430 rtl::OUString sUser
, sPasswd
;
432 bool bLocal
= sServerType
.equalsIgnoreAsciiCase(ASCII("local")) || sServerType
.equalsIgnoreAsciiCase(ASCII("setup"));
435 rtl::OUString sServer
;
436 sServer
= enterValue("server : ", s_pServer
,false);
439 sUser
= enterValue("user : ", s_pUser
, false);
442 sPasswd
= enterValue("password: ", s_pPassword
, true);
445 aCPArgs
= createSequence(sUser
, sPasswd
);
447 aCPArgs
.realloc(aCPArgs
.getLength() + 1);
448 aCPArgs
[aCPArgs
.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("server"), sServer
);
450 long nTimeout
= 10000;
451 aCPArgs
.realloc(aCPArgs
.getLength() + 1);
452 aCPArgs
[aCPArgs
.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("timeout"), nTimeout
);
455 aCPArgs
.realloc(aCPArgs
.getLength() + 1);
456 aCPArgs
[aCPArgs
.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("port"), nPort
);
460 rtl::OUString sSharePath
, sUserPath
;
461 sSharePath
= enterValue("share path: ", s_pSourcePath
, false);
463 sUserPath
= enterValue("user path : ", s_pUpdatePath
, false);
466 aCPArgs
.realloc(aCPArgs
.getLength() + 1);
468 pAny
= &aCPArgs
[aCPArgs
.getLength() - 1];
469 *pAny
<<= configmgr::createPropertyValue(ASCII("sourcepath"), sSharePath
);
470 aCPArgs
.realloc(aCPArgs
.getLength() + 1);
471 aCPArgs
[aCPArgs
.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("updatepath"), sUserPath
);
474 aCPArgs
.realloc(aCPArgs
.getLength() + 1);
475 aCPArgs
[aCPArgs
.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("servertype"), sServerType
);
477 Reference
< XMultiServiceFactory
> xCfgProvider(
478 xORB
->createInstanceWithArguments(
479 ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"),
482 if (!xCfgProvider
.is())
485 cerr
<< "Could not create the configuration provider !\n\n";
489 cout
<< "---------------------------------------------------------------\n Configuration Provider created !\n---------------------------------------------------------------" << endl
;
492 sPath
<<= s_pRootNode
;
494 sLocale
<<= s_pLocale
;
498 sPath
= enterValue("nodepath: ", s_pRootNode
, false);
502 sLocale
= enterValue("locale : ", s_pLocale
, false);
505 ask_for_a_node_and_test_it(xCfgProvider
, sUser
, sPasswd
, sPath
, bLocal
, sLocale
);
510 for(std::vector
<OString
>::const_iterator it
= m_sNodes
.begin();
511 it
!= m_sNodes
.end();
516 if (sPath
.getLength() > 0)
517 ask_for_a_node_and_test_it(xCfgProvider
, sUser
, sPasswd
, sPath
, bLocal
, sLocale
);
524 cerr
<< "Caught exception: " << e
.Message
<< endl
;
530 // -----------------------------------------------------------------------------
531 void ask_for_a_node_and_test_it(const Reference
< XMultiServiceFactory
> &xCfgProvider
,
532 const OUString
& sUser
, const OUString
&sPasswd
,
533 const OUString
& sPath
, bool bLocal
, const OUString
&sLocale
)
537 Sequence
< Any
> aArgs
;
538 aArgs
= createSequence(sUser
, sPasswd
);
540 aArgs
.realloc(aArgs
.getLength() + 1);
541 aArgs
[aArgs
.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("nodepath"), sPath
);
545 aArgs
.realloc(aArgs
.getLength() + 1);
546 aArgs
[aArgs
.getLength() - 1] <<= configmgr::createPropertyValue(ASCII("locale"), sLocale
);
549 Reference
< XInterface
> xIFace
= xCfgProvider
->createInstanceWithArguments(
550 OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
552 cout
<< "Configuration Read/Write Access created for :" << sPath
<< endl
;
554 xChangesBatch
= Reference
< XChangesBatch
>(xIFace
, UNO_QUERY
);
556 Sequence
<OUString
> aSeq
= xCfgProvider
->getAvailableServiceNames();
559 test_read_access(xIFace
, xCfgProvider
);
564 cerr
<< "Caught exception: " << e
.Message
<< endl
;
568 ///////////////////////////////////////////////////////////////////////////////////////////
569 void test(Reference
< XHierarchicalName
>& xAccessName
)
571 if (xAccessName
.is())
573 COUT
<< "Accessing Node: " << xAccessName
->getHierarchicalName() << endl
;
577 cerr
<< "BUG: XHierarchicalName not available" << endl
;
580 // -----------------------------------------------------------------------------
581 void test(Reference
< XNamed
>& xAccess
)
585 COUT
<< "Node is named: " << xAccess
->getName() << endl
;
588 cerr
<< "BUG: XNamed not available" << endl
;
591 ///////////////////////////////////////////////////////////////////////////////////////////
592 void write(Reference
<XNameAccess
>& xAccess
)
596 Sequence
<OUString
> aNames( xAccess
->getElementNames() );
598 COUT
<< "Element Names: (" << aNames
.getLength() << ")";
599 for (int i
= 0; i
< aNames
.getLength(); ++i
)
601 COUT
<< "\n[" << i
<< "] -\t" << aNames
[i
];
606 cerr
<< "BUG: XNameAccess not available" << endl
;
608 // -----------------------------------------------------------------------------
609 void write(Reference
< XChild
>& xChild
)
613 COUT
<< "\n[ P ] -\tParent" << endl
;
616 cerr
<< "BUG: Parent not available (no XChild)" << endl
;
618 ///////////////////////////////////////////////////////////////////////////////////////////
620 bool ask(Reference
< XInterface
>& xIface
, const Reference
<XMultiServiceFactory
> &);
622 void test_read_access(Reference
< XInterface
>& xIface
, const Reference
< XMultiServiceFactory
> &xMSF
)
624 using com::sun::star::uno::UNO_QUERY
;
627 COUT
<< "\n\n---------------------------------------------------------------" << endl
;
628 Reference
< XNameAccess
> xAccess(xIface
, UNO_QUERY
);
629 Reference
< XChild
> xChild(xIface
, UNO_QUERY
);
630 Reference
< XHierarchicalName
> xAccessPath(xIface
,UNO_QUERY
);
631 Reference
< XNamed
> xAccessName(xIface
,UNO_QUERY
);
632 // Reference< XHierarchicalNameAccess >& xAccess(xIface, UNO_QUERY);
639 if (!m_bInteractive
) break;
641 while (ask(xIface
, xMSF
));
644 bool ask(Reference
< XInterface
>& xIface
, const Reference
< XMultiServiceFactory
> &xMSF
)
646 COUT
<< "\n[ Q ] -> <Quit>";
647 COUT
<< "\n[ S ] -> <SetValue> ";
650 COUT
<< "\n:> " << flush
;
654 bool bHandled
= false;
655 bool bInserted
= false;
657 if (cin
.getline(buf
,sizeof buf
))
659 Reference
< XInterface
> xNext
;
660 if ((buf
[0] == 'q' || buf
[0] == 'Q') && (0 == buf
[1]))
664 else if (buf
[0] == 0)
668 else if((buf
[0] == 0 || buf
[0] == 'o' || buf
[0] == 'O') && (0 == buf
[1]))
671 COUT << "work Offline" << endl;
672 Reference<com::sun::star::configuration::XConfigurationSync> xSync(xMSF, UNO_QUERY);
674 Sequence< Any > aArgs2(5);
676 aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Setup"));
677 // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Common"));
678 // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Java"));
679 // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.Writer"));
680 // aArgs2[n++] <<= configmgr::createPropertyValue(ASCII("path"), ASCII("org.openoffice.Office.ucb.Hierarchy"));
681 xSync->offline(aArgs2);
685 else if((buf
[0] == 0 || buf
[0] == 's' || buf
[0] == 'S') && (0 == buf
[1]))
688 Reference
< XNameAccess
> xAccess(xIface
, UNO_QUERY
);
690 COUT
<< "SetMode, insert a Number" << endl
;
691 cin
.getline(buf
,sizeof buf
);
695 else if ((buf
[0] == 'p' || buf
[0] == 'P') && (0 == buf
[1]))
697 Reference
< XChild
> xChild(xIface
, UNO_QUERY
);
699 xNext
= xChild
->getParent();
703 if (bHandled
== false)
705 Reference
< XNameAccess
> xAccess(xIface
, UNO_QUERY
);
706 Reference
< XHierarchicalNameAccess
> xDeepAccess(xIface
, UNO_QUERY
);
707 Reference
< XExactName
> xExactName(xIface
, UNO_QUERY
);
709 if (xAccess
.is() || xDeepAccess
.is())
712 OUString aInput
= OUString::createFromAscii(buf
);
716 ::rtl::OUString sTemp
= xExactName
->getExactName(aInput
);
717 if (sTemp
.getLength())
721 if (xAccess
.is() && xAccess
->hasByName(aInput
))
725 else if (xDeepAccess
.is() && xDeepAccess
->hasByHierarchicalName(aInput
))
729 else if ('0' <= buf
[0] && buf
[0] <= '9' && xAccess
.is())
731 unsigned int n
= unsigned(atoi(buf
));
732 Sequence
<OUString
> aNames
= xAccess
->getElementNames();
733 if (n
< aNames
.getLength())
737 if (aName
.getLength())
739 bool bNest
= aInput
.indexOf(sal_Unicode('/')) >= 0;
741 Any aElement
= bNest
? ( xDeepAccess
.is() ? xDeepAccess
->getByHierarchicalName(aName
) : Any())
742 : ( xAccess
. is() ? xAccess
-> getByName(aName
) : Any() );
744 while (aElement
.getValueTypeClass() == TypeClass_ANY
)
749 sal_Bool bValue
= true;
750 sal_Bool bValueOk
= false;
752 switch (aElement
.getValueTypeClass() )
754 case TypeClass_INTERFACE
: bValue
= false; break;
755 case TypeClass_BOOLEAN
:
757 sal_Bool
* pVal
= (sal_Bool
*)aElement
.getValue();
758 bValueOk
= (pVal
!= 0);
760 COUT
<< "VALUE '" << aName
<< "' is a BOOLEAN = ";
763 COUT
<< "NULL (error!!)";
776 case TypeClass_SHORT
:
779 COUT
<< "VALUE '" << aName
<< "' is a SHORT (16 bit) = ";
780 if (bValueOk
= (aElement
>>= aValue
))
785 cerr
<< "ERROR RETRIEVING VALUE";
793 COUT
<< "VALUE '" << aName
<< "' is a INT (32 bit) = ";
794 if (bValueOk
= (aElement
>>= aValue
))
799 cerr
<< "ERROR RETRIEVING VALUE";
803 case TypeClass_HYPER
:
806 COUT
<< "VALUE '" << aName
<< "' is a LONG (64 bit) = ";
807 if (bValueOk
= (aElement
>>= aValue
))
809 COUT
<< double(aValue
);
812 cerr
<< "ERROR RETRIEVING VALUE";
816 case TypeClass_DOUBLE
:
819 COUT
<< "VALUE '" << aName
<< "' is a DOUBLE = ";
820 if (bValueOk
= (aElement
>>= aValue
))
825 cerr
<< "ERROR RETRIEVING VALUE";
829 case TypeClass_STRING
:
832 COUT
<< "VALUE '" << aName
<< "' is a STRING = ";
833 if (bValueOk
= (aElement
>>= aValue
))
835 COUT
<< "\"" << aValue
<< "\"";
838 cerr
<< "ERROR RETRIEVING VALUE";
842 case TypeClass_SEQUENCE
:
844 COUT
<< "VALUE '" << aName
<< "' is a SEQUENCE or BINARY" << endl
;
846 Type aTypeS
= configmgr::getSequenceElementType(aElement
.getValueType());
847 OUString sType
= configmgr::toTypeName(aTypeS
.getTypeClass());
848 COUT
<< "Real type is Sequence<" << sType
<< ">" << endl
;
853 COUT
<< "ELEMENT '" << aName
<< "' is NULL and VOID " << endl
;
857 cerr
<< "Error: ELEMENT '" << aName
<< "' is of unknown or unrecognized type" << endl
;
864 if (aElement
.getValueTypeClass() == TypeClass_BOOLEAN
||
865 aElement
.getValueTypeClass() == TypeClass_VOID
)
867 COUT
<< "Set Value (Type=BOOL) to :";
869 cin
.getline(buf
,sizeof buf
);
870 OUString aInput
= OUString::createFromAscii(buf
);
871 sal_Bool bValue
= false;
874 if (aInput
.equalsIgnoreAsciiCase(ASCII("true")))
877 aValueAny
<<= bValue
;
879 else if (aInput
.equalsIgnoreAsciiCase(ASCII("false")))
882 aValueAny
<<= bValue
;
884 else if (aInput
.equalsIgnoreAsciiCase(ASCII("null")))
888 Reference
< XNameReplace
> xNameReplace(xAccess
, UNO_QUERY
);
889 if (xNameReplace
.is())
891 xNameReplace
->replaceByName(aName
, aValueAny
);
896 else if (aElement
.getValueTypeClass() == TypeClass_STRING
)
898 COUT
<< "set value (type = string) to : ";
900 cin
.getline(buf
,sizeof buf
);
904 Reference
< XNameReplace
> xNameReplace(xAccess
, UNO_QUERY
);
905 if (xNameReplace
.is())
907 xNameReplace
->replaceByName(aName
, aValue
);
914 cerr
<< "Sorry, only BOOLEAN Values can changed today." << endl
;
918 return bValueOk
? true : false;
921 if (aElement
>>= xNext
)
923 COUT
<< "Got an Interface for '" << aName
<< "'" << endl
;
926 cerr
<< "Error: Cannot get an Interface for '" << aName
<< "'" << endl
;
930 cerr
<< "Error: No element \"" << aInput
<< "\" found." <<endl
;
940 cerr
<< "Error: could not obtain the requested Object " << endl
;
944 COUT
<< "Input Error " << endl
;
950 cerr
<< "An Exception occurred: " << e
.Message
<< endl
;
955 cerr
<< "An UNKNOWN Exception occurred !" << endl
;