1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sdext.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir using namespace ::com::sun::star;
39*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
40*cdf0e10cSrcweir using ::rtl::OUString;
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir namespace sdext { namespace presenter {
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir const ::rtl::OUString PresenterConfigurationAccess::msPresenterScreenRootName =
47*cdf0e10cSrcweir     A2S("/org.openoffice.Office.extension.PresenterScreen/");
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir PresenterConfigurationAccess::PresenterConfigurationAccess (
50*cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
51*cdf0e10cSrcweir     const OUString& rsRootName,
52*cdf0e10cSrcweir     WriteMode eMode)
53*cdf0e10cSrcweir     : mxRoot(),
54*cdf0e10cSrcweir       maNode()
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir     try
57*cdf0e10cSrcweir     {
58*cdf0e10cSrcweir         Reference<lang::XMultiComponentFactory> xFactory (rxContext->getServiceManager());
59*cdf0e10cSrcweir         if (xFactory.is())
60*cdf0e10cSrcweir         {
61*cdf0e10cSrcweir             Sequence<Any> aCreationArguments(3);
62*cdf0e10cSrcweir             aCreationArguments[0] = makeAny(beans::PropertyValue(
63*cdf0e10cSrcweir                 A2S("nodepath"),
64*cdf0e10cSrcweir                 0,
65*cdf0e10cSrcweir                 makeAny(rsRootName),
66*cdf0e10cSrcweir                 beans::PropertyState_DIRECT_VALUE));
67*cdf0e10cSrcweir             aCreationArguments[1] = makeAny(beans::PropertyValue(
68*cdf0e10cSrcweir                 A2S("depth"),
69*cdf0e10cSrcweir                 0,
70*cdf0e10cSrcweir                 makeAny((sal_Int32)-1),
71*cdf0e10cSrcweir                 beans::PropertyState_DIRECT_VALUE));
72*cdf0e10cSrcweir             aCreationArguments[2] = makeAny(beans::PropertyValue(
73*cdf0e10cSrcweir                 A2S("lazywrite"),
74*cdf0e10cSrcweir                 0,
75*cdf0e10cSrcweir                 makeAny(true),
76*cdf0e10cSrcweir                 beans::PropertyState_DIRECT_VALUE));
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir             OUString sAccessService;
79*cdf0e10cSrcweir             if (eMode == READ_ONLY)
80*cdf0e10cSrcweir                 sAccessService = A2S("com.sun.star.configuration.ConfigurationAccess");
81*cdf0e10cSrcweir             else
82*cdf0e10cSrcweir                 sAccessService = A2S("com.sun.star.configuration.ConfigurationUpdateAccess");
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir             Reference<lang::XMultiServiceFactory> xProvider (
85*cdf0e10cSrcweir                 xFactory->createInstanceWithContext(
86*cdf0e10cSrcweir                     A2S("com.sun.star.configuration.ConfigurationProvider"),
87*cdf0e10cSrcweir                     rxContext),
88*cdf0e10cSrcweir                 UNO_QUERY_THROW);
89*cdf0e10cSrcweir             mxRoot = xProvider->createInstanceWithArguments(
90*cdf0e10cSrcweir                 sAccessService, aCreationArguments);
91*cdf0e10cSrcweir             maNode <<= mxRoot;
92*cdf0e10cSrcweir         }
93*cdf0e10cSrcweir     }
94*cdf0e10cSrcweir     catch (Exception& rException)
95*cdf0e10cSrcweir     {
96*cdf0e10cSrcweir         OSL_TRACE ("caught exception while opening configuration: %s",
97*cdf0e10cSrcweir             ::rtl::OUStringToOString(rException.Message,
98*cdf0e10cSrcweir                 RTL_TEXTENCODING_UTF8).getStr());
99*cdf0e10cSrcweir     }
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir PresenterConfigurationAccess::~PresenterConfigurationAccess (void)
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir bool PresenterConfigurationAccess::IsValid (void) const
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     return mxRoot.is();
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir Any PresenterConfigurationAccess::GetConfigurationNode (const OUString& sPathToNode)
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir     return GetConfigurationNode(
123*cdf0e10cSrcweir         Reference<container::XHierarchicalNameAccess>(mxRoot, UNO_QUERY),
124*cdf0e10cSrcweir         sPathToNode);
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir Reference<beans::XPropertySet> PresenterConfigurationAccess::GetNodeProperties (
131*cdf0e10cSrcweir     const OUString& sPathToNode)
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir     return GetNodeProperties(
134*cdf0e10cSrcweir         Reference<container::XHierarchicalNameAccess>(mxRoot, UNO_QUERY),
135*cdf0e10cSrcweir         sPathToNode);
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir bool PresenterConfigurationAccess::GoToChild (const ::rtl::OUString& rsPathToNode)
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir     if ( ! IsValid())
144*cdf0e10cSrcweir         return false;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     Reference<container::XHierarchicalNameAccess> xNode (maNode, UNO_QUERY);
147*cdf0e10cSrcweir     if (xNode.is())
148*cdf0e10cSrcweir     {
149*cdf0e10cSrcweir         maNode = GetConfigurationNode(
150*cdf0e10cSrcweir             Reference<container::XHierarchicalNameAccess>(maNode, UNO_QUERY),
151*cdf0e10cSrcweir             rsPathToNode);
152*cdf0e10cSrcweir         if (Reference<XInterface>(maNode, UNO_QUERY).is())
153*cdf0e10cSrcweir             return true;
154*cdf0e10cSrcweir     }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     mxRoot = NULL;
157*cdf0e10cSrcweir     return false;
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir bool PresenterConfigurationAccess::GoToChild (const Predicate& rPredicate)
164*cdf0e10cSrcweir {
165*cdf0e10cSrcweir     if ( ! IsValid())
166*cdf0e10cSrcweir         return false;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     maNode = Find(Reference<container::XNameAccess>(maNode,UNO_QUERY), rPredicate);
169*cdf0e10cSrcweir     if (Reference<XInterface>(maNode, UNO_QUERY).is())
170*cdf0e10cSrcweir         return true;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     mxRoot = NULL;
173*cdf0e10cSrcweir     return false;
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir bool PresenterConfigurationAccess::SetProperty (
180*cdf0e10cSrcweir     const ::rtl::OUString& rsPropertyName,
181*cdf0e10cSrcweir     const Any& rValue)
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     Reference<beans::XPropertySet> xProperties (maNode, UNO_QUERY);
184*cdf0e10cSrcweir     if (xProperties.is())
185*cdf0e10cSrcweir     {
186*cdf0e10cSrcweir         xProperties->setPropertyValue(rsPropertyName, rValue);
187*cdf0e10cSrcweir         return true;
188*cdf0e10cSrcweir     }
189*cdf0e10cSrcweir     else
190*cdf0e10cSrcweir         return false;
191*cdf0e10cSrcweir }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir Any PresenterConfigurationAccess::GetConfigurationNode (
197*cdf0e10cSrcweir     const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
198*cdf0e10cSrcweir     const OUString& sPathToNode)
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir     if (sPathToNode.getLength() == 0)
201*cdf0e10cSrcweir         return Any(rxNode);
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     try
204*cdf0e10cSrcweir     {
205*cdf0e10cSrcweir         if (rxNode.is())
206*cdf0e10cSrcweir         {
207*cdf0e10cSrcweir             return rxNode->getByHierarchicalName(sPathToNode);
208*cdf0e10cSrcweir         }
209*cdf0e10cSrcweir     }
210*cdf0e10cSrcweir     catch (Exception& rException)
211*cdf0e10cSrcweir     {
212*cdf0e10cSrcweir         OSL_TRACE ("caught exception while getting configuration node %s: %s",
213*cdf0e10cSrcweir             ::rtl::OUStringToOString(sPathToNode, RTL_TEXTENCODING_UTF8).getStr(),
214*cdf0e10cSrcweir             ::rtl::OUStringToOString(rException.Message, RTL_TEXTENCODING_UTF8).getStr());
215*cdf0e10cSrcweir     }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     return Any();
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir Reference<beans::XPropertySet> PresenterConfigurationAccess::GetNodeProperties (
224*cdf0e10cSrcweir     const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
225*cdf0e10cSrcweir     const ::rtl::OUString& rsPathToNode)
226*cdf0e10cSrcweir {
227*cdf0e10cSrcweir     return Reference<beans::XPropertySet>(GetConfigurationNode(rxNode, rsPathToNode), UNO_QUERY);
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir void PresenterConfigurationAccess::CommitChanges (void)
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir     Reference<util::XChangesBatch> xConfiguration (mxRoot, UNO_QUERY);
236*cdf0e10cSrcweir     if (xConfiguration.is())
237*cdf0e10cSrcweir         xConfiguration->commitChanges();
238*cdf0e10cSrcweir }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir Any PresenterConfigurationAccess::GetValue (const rtl::OUString& sKey)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir     Reference<container::XNameAccess> xAccess (GetConfigurationNode(sKey), UNO_QUERY);
246*cdf0e10cSrcweir     if (xAccess.is())
247*cdf0e10cSrcweir     {
248*cdf0e10cSrcweir         return xAccess->getByName(sKey);
249*cdf0e10cSrcweir     }
250*cdf0e10cSrcweir     else
251*cdf0e10cSrcweir     {
252*cdf0e10cSrcweir         return Any();
253*cdf0e10cSrcweir     }
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir void PresenterConfigurationAccess::ForAll (
260*cdf0e10cSrcweir     const Reference<container::XNameAccess>& rxContainer,
261*cdf0e10cSrcweir     const ::std::vector<OUString>& rArguments,
262*cdf0e10cSrcweir     const ItemProcessor& rProcessor)
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir     if (rxContainer.is())
265*cdf0e10cSrcweir     {
266*cdf0e10cSrcweir         ::std::vector<Any> aValues(rArguments.size());
267*cdf0e10cSrcweir         Sequence<OUString> aKeys (rxContainer->getElementNames());
268*cdf0e10cSrcweir         for (sal_Int32 nItemIndex=0; nItemIndex<aKeys.getLength(); ++nItemIndex)
269*cdf0e10cSrcweir         {
270*cdf0e10cSrcweir             bool bHasAllValues (true);
271*cdf0e10cSrcweir             const OUString& rsKey (aKeys[nItemIndex]);
272*cdf0e10cSrcweir             Reference<container::XNameAccess> xSetItem (rxContainer->getByName(rsKey), UNO_QUERY);
273*cdf0e10cSrcweir             Reference<beans::XPropertySet> xSet (xSetItem, UNO_QUERY);
274*cdf0e10cSrcweir             OSL_ASSERT(xSet.is());
275*cdf0e10cSrcweir             if (xSetItem.is())
276*cdf0e10cSrcweir             {
277*cdf0e10cSrcweir                 // Get from the current item of the container the children
278*cdf0e10cSrcweir                 // that match the names in the rArguments list.
279*cdf0e10cSrcweir                 for (sal_uInt32 nValueIndex=0; nValueIndex<aValues.size(); ++nValueIndex)
280*cdf0e10cSrcweir                 {
281*cdf0e10cSrcweir                     if ( ! xSetItem->hasByName(rArguments[nValueIndex]))
282*cdf0e10cSrcweir                         bHasAllValues = false;
283*cdf0e10cSrcweir                     else
284*cdf0e10cSrcweir                         aValues[nValueIndex] = xSetItem->getByName(rArguments[nValueIndex]);
285*cdf0e10cSrcweir                 }
286*cdf0e10cSrcweir             }
287*cdf0e10cSrcweir             else
288*cdf0e10cSrcweir                 bHasAllValues = false;
289*cdf0e10cSrcweir             if (bHasAllValues)
290*cdf0e10cSrcweir                 rProcessor(rsKey,aValues);
291*cdf0e10cSrcweir         }
292*cdf0e10cSrcweir     }
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir void PresenterConfigurationAccess::ForAll (
299*cdf0e10cSrcweir     const Reference<container::XNameAccess>& rxContainer,
300*cdf0e10cSrcweir     const PropertySetProcessor& rProcessor)
301*cdf0e10cSrcweir {
302*cdf0e10cSrcweir     if (rxContainer.is())
303*cdf0e10cSrcweir     {
304*cdf0e10cSrcweir         Sequence<OUString> aKeys (rxContainer->getElementNames());
305*cdf0e10cSrcweir         for (sal_Int32 nItemIndex=0; nItemIndex<aKeys.getLength(); ++nItemIndex)
306*cdf0e10cSrcweir         {
307*cdf0e10cSrcweir             const OUString& rsKey (aKeys[nItemIndex]);
308*cdf0e10cSrcweir             Reference<beans::XPropertySet> xSet (rxContainer->getByName(rsKey), UNO_QUERY);
309*cdf0e10cSrcweir             if (xSet.is())
310*cdf0e10cSrcweir                 rProcessor(rsKey, xSet);
311*cdf0e10cSrcweir         }
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir void PresenterConfigurationAccess::FillList(
319*cdf0e10cSrcweir     const Reference<container::XNameAccess>& rxContainer,
320*cdf0e10cSrcweir     const ::rtl::OUString& rsArgument,
321*cdf0e10cSrcweir     ::std::vector<OUString>& rList)
322*cdf0e10cSrcweir {
323*cdf0e10cSrcweir     try
324*cdf0e10cSrcweir     {
325*cdf0e10cSrcweir         if (rxContainer.is())
326*cdf0e10cSrcweir         {
327*cdf0e10cSrcweir             Sequence<OUString> aKeys (rxContainer->getElementNames());
328*cdf0e10cSrcweir             rList.resize(aKeys.getLength());
329*cdf0e10cSrcweir             for (sal_Int32 nItemIndex=0; nItemIndex<aKeys.getLength(); ++nItemIndex)
330*cdf0e10cSrcweir             {
331*cdf0e10cSrcweir                 Reference<container::XNameAccess> xSetItem (
332*cdf0e10cSrcweir                     rxContainer->getByName(aKeys[nItemIndex]), UNO_QUERY);
333*cdf0e10cSrcweir                 if (xSetItem.is())
334*cdf0e10cSrcweir                 {
335*cdf0e10cSrcweir                     xSetItem->getByName(rsArgument) >>= rList[nItemIndex];
336*cdf0e10cSrcweir                 }
337*cdf0e10cSrcweir             }
338*cdf0e10cSrcweir         }
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir     catch (RuntimeException&)
341*cdf0e10cSrcweir     {}
342*cdf0e10cSrcweir }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir Any PresenterConfigurationAccess::Find (
348*cdf0e10cSrcweir     const Reference<container::XNameAccess>& rxContainer,
349*cdf0e10cSrcweir     const Predicate& rPredicate)
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir     if (rxContainer.is())
352*cdf0e10cSrcweir     {
353*cdf0e10cSrcweir         Sequence<OUString> aKeys (rxContainer->getElementNames());
354*cdf0e10cSrcweir         for (sal_Int32 nItemIndex=0; nItemIndex<aKeys.getLength(); ++nItemIndex)
355*cdf0e10cSrcweir         {
356*cdf0e10cSrcweir             Reference<beans::XPropertySet> xProperties (
357*cdf0e10cSrcweir                 rxContainer->getByName(aKeys[nItemIndex]),
358*cdf0e10cSrcweir                 UNO_QUERY);
359*cdf0e10cSrcweir             if (xProperties.is())
360*cdf0e10cSrcweir                 if (rPredicate(aKeys[nItemIndex], xProperties))
361*cdf0e10cSrcweir                     return Any(xProperties);
362*cdf0e10cSrcweir         }
363*cdf0e10cSrcweir     }
364*cdf0e10cSrcweir     return Any();
365*cdf0e10cSrcweir }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir bool PresenterConfigurationAccess::IsStringPropertyEqual (
371*cdf0e10cSrcweir     const ::rtl::OUString& rsValue,
372*cdf0e10cSrcweir     const ::rtl::OUString& rsPropertyName,
373*cdf0e10cSrcweir     const css::uno::Reference<css::beans::XPropertySet>& rxNode)
374*cdf0e10cSrcweir {
375*cdf0e10cSrcweir     OUString sValue;
376*cdf0e10cSrcweir     if (GetProperty(rxNode, rsPropertyName) >>= sValue)
377*cdf0e10cSrcweir         return sValue == rsValue;
378*cdf0e10cSrcweir     else
379*cdf0e10cSrcweir         return false;
380*cdf0e10cSrcweir }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir Any PresenterConfigurationAccess::GetProperty (
386*cdf0e10cSrcweir     const Reference<beans::XPropertySet>& rxProperties,
387*cdf0e10cSrcweir     const OUString& rsKey)
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir     OSL_ASSERT(rxProperties.is());
390*cdf0e10cSrcweir     if ( ! rxProperties.is())
391*cdf0e10cSrcweir         return Any();
392*cdf0e10cSrcweir     try
393*cdf0e10cSrcweir     {
394*cdf0e10cSrcweir         Reference<beans::XPropertySetInfo> xInfo (rxProperties->getPropertySetInfo());
395*cdf0e10cSrcweir         if (xInfo.is())
396*cdf0e10cSrcweir             if ( ! xInfo->hasPropertyByName(rsKey))
397*cdf0e10cSrcweir                 return Any();
398*cdf0e10cSrcweir         return rxProperties->getPropertyValue(rsKey);
399*cdf0e10cSrcweir     }
400*cdf0e10cSrcweir     catch (beans::UnknownPropertyException&)
401*cdf0e10cSrcweir     {
402*cdf0e10cSrcweir     }
403*cdf0e10cSrcweir     return Any();
404*cdf0e10cSrcweir }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir } } // end of namespace sdext::tools
410*cdf0e10cSrcweir 
411