From 857d34a9091cd6861784aef87db6c4dbc17e9c7e Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Tue, 13 May 2008 13:29:03 +0000 Subject: INTEGRATION: CWS presenterscreen (1.2.4); FILE MERGED 2008/04/30 08:07:07 af 1.2.4.6: #i88853# Extended functionality to allow easier modification of properties. 2008/04/23 11:51:49 af 1.2.4.5: #i18486# Added desctructor. 2008/04/22 08:25:27 af 1.2.4.4: RESYNC: (1.2-1.3); FILE MERGED 2008/04/18 09:02:23 af 1.2.4.3: #i18486# Avoid crash because of missing configuration entries. 2008/04/16 16:59:13 af 1.2.4.2: #i18486# Fixed some Linux build problems. 2008/04/16 15:29:08 af 1.2.4.1: #i18486# Added support for accessing configuration nodes as property sets. --- .../presenter/PresenterConfigurationAccess.cxx | 193 +++++++++++++++++++-- 1 file changed, 175 insertions(+), 18 deletions(-) (limited to 'sdext/source/presenter/PresenterConfigurationAccess.cxx') diff --git a/sdext/source/presenter/PresenterConfigurationAccess.cxx b/sdext/source/presenter/PresenterConfigurationAccess.cxx index 43659b541fbc..7909d39e14e7 100644 --- a/sdext/source/presenter/PresenterConfigurationAccess.cxx +++ b/sdext/source/presenter/PresenterConfigurationAccess.cxx @@ -8,7 +8,7 @@ * * $RCSfile: PresenterConfigurationAccess.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * * This file is part of OpenOffice.org. * @@ -40,13 +40,19 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using ::rtl::OUString; +#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) + namespace sdext { namespace presenter { +const ::rtl::OUString PresenterConfigurationAccess::msPresenterScreenRootName = + A2S("/org.openoffice.Office.extension.PresenterScreen/"); + PresenterConfigurationAccess::PresenterConfigurationAccess ( const Reference& rxContext, const OUString& rsRootName, WriteMode eMode) - : mxRoot() + : mxRoot(), + maNode() { try { @@ -55,37 +61,35 @@ PresenterConfigurationAccess::PresenterConfigurationAccess ( { Sequence aCreationArguments(3); aCreationArguments[0] = makeAny(beans::PropertyValue( - OUString( - RTL_CONSTASCII_USTRINGPARAM("nodepath")), + A2S("nodepath"), 0, makeAny(rsRootName), beans::PropertyState_DIRECT_VALUE)); aCreationArguments[1] = makeAny(beans::PropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), + A2S("depth"), 0, makeAny((sal_Int32)-1), beans::PropertyState_DIRECT_VALUE)); aCreationArguments[2] = makeAny(beans::PropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), + A2S("lazywrite"), 0, makeAny(true), beans::PropertyState_DIRECT_VALUE)); OUString sAccessService; if (eMode == READ_ONLY) - sAccessService = OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationAccess")); + sAccessService = A2S("com.sun.star.configuration.ConfigurationAccess"); else - sAccessService = OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationUpdateAccess")); + sAccessService = A2S("com.sun.star.configuration.ConfigurationUpdateAccess"); Reference xProvider ( xFactory->createInstanceWithContext( - OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider"), + A2S("com.sun.star.configuration.ConfigurationProvider"), rxContext), UNO_QUERY_THROW); mxRoot = xProvider->createInstanceWithArguments( sAccessService, aCreationArguments); + maNode <<= mxRoot; } } catch (Exception& rException) @@ -99,6 +103,21 @@ PresenterConfigurationAccess::PresenterConfigurationAccess ( +PresenterConfigurationAccess::~PresenterConfigurationAccess (void) +{ +} + + + + +bool PresenterConfigurationAccess::IsValid (void) const +{ + return mxRoot.is(); +} + + + + Any PresenterConfigurationAccess::GetConfigurationNode (const OUString& sPathToNode) { return GetConfigurationNode( @@ -109,6 +128,72 @@ Any PresenterConfigurationAccess::GetConfigurationNode (const OUString& sPathToN +Reference PresenterConfigurationAccess::GetNodeProperties ( + const OUString& sPathToNode) +{ + return GetNodeProperties( + Reference(mxRoot, UNO_QUERY), + sPathToNode); +} + + + + +bool PresenterConfigurationAccess::GoToChild (const ::rtl::OUString& rsPathToNode) +{ + if ( ! IsValid()) + return false; + + Reference xNode (maNode, UNO_QUERY); + if (xNode.is()) + { + maNode = GetConfigurationNode( + Reference(maNode, UNO_QUERY), + rsPathToNode); + if (Reference(maNode, UNO_QUERY).is()) + return true; + } + + mxRoot = NULL; + return false; +} + + + + +bool PresenterConfigurationAccess::GoToChild (const Predicate& rPredicate) +{ + if ( ! IsValid()) + return false; + + maNode = Find(Reference(maNode,UNO_QUERY), rPredicate); + if (Reference(maNode, UNO_QUERY).is()) + return true; + + mxRoot = NULL; + return false; +} + + + + +bool PresenterConfigurationAccess::SetProperty ( + const ::rtl::OUString& rsPropertyName, + const Any& rValue) +{ + Reference xProperties (maNode, UNO_QUERY); + if (xProperties.is()) + { + xProperties->setPropertyValue(rsPropertyName, rValue); + return true; + } + else + return false; +} + + + + Any PresenterConfigurationAccess::GetConfigurationNode ( const css::uno::Reference& rxNode, const OUString& sPathToNode) @@ -136,6 +221,16 @@ Any PresenterConfigurationAccess::GetConfigurationNode ( +Reference PresenterConfigurationAccess::GetNodeProperties ( + const css::uno::Reference& rxNode, + const ::rtl::OUString& rsPathToNode) +{ + return Reference(GetConfigurationNode(rxNode, rsPathToNode), UNO_QUERY); +} + + + + void PresenterConfigurationAccess::CommitChanges (void) { Reference xConfiguration (mxRoot, UNO_QUERY); @@ -176,6 +271,8 @@ void PresenterConfigurationAccess::ForAll ( bool bHasAllValues (true); const OUString& rsKey (aKeys[nItemIndex]); Reference xSetItem (rxContainer->getByName(rsKey), UNO_QUERY); + Reference xSet (xSetItem, UNO_QUERY); + OSL_ASSERT(xSet.is()); if (xSetItem.is()) { // Get from the current item of the container the children @@ -199,6 +296,26 @@ void PresenterConfigurationAccess::ForAll ( +void PresenterConfigurationAccess::ForAll ( + const Reference& rxContainer, + const PropertySetProcessor& rProcessor) +{ + if (rxContainer.is()) + { + Sequence aKeys (rxContainer->getElementNames()); + for (sal_Int32 nItemIndex=0; nItemIndex xSet (rxContainer->getByName(rsKey), UNO_QUERY); + if (xSet.is()) + rProcessor(rsKey, xSet); + } + } +} + + + + void PresenterConfigurationAccess::FillList( const Reference& rxContainer, const ::rtl::OUString& rsArgument, @@ -228,7 +345,7 @@ void PresenterConfigurationAccess::FillList( -Reference PresenterConfigurationAccess::Find ( +Any PresenterConfigurationAccess::Find ( const Reference& rxContainer, const Predicate& rPredicate) { @@ -237,14 +354,54 @@ Reference PresenterConfigurationAccess::Find ( Sequence aKeys (rxContainer->getElementNames()); for (sal_Int32 nItemIndex=0; nItemIndex xSetItem ( - rxContainer->getByName(aKeys[nItemIndex]), UNO_QUERY); - if (xSetItem.is()) - if (rPredicate(aKeys[nItemIndex], xSetItem)) - return xSetItem; + Reference xProperties ( + rxContainer->getByName(aKeys[nItemIndex]), + UNO_QUERY); + if (xProperties.is()) + if (rPredicate(aKeys[nItemIndex], xProperties)) + return Any(xProperties); } } - return NULL; + return Any(); +} + + + + +bool PresenterConfigurationAccess::IsStringPropertyEqual ( + const ::rtl::OUString& rsValue, + const ::rtl::OUString& rsPropertyName, + const css::uno::Reference& rxNode) +{ + OUString sValue; + if (GetProperty(rxNode, rsPropertyName) >>= sValue) + return sValue == rsValue; + else + return false; +} + + + + +Any PresenterConfigurationAccess::GetProperty ( + const Reference& rxProperties, + const OUString& rsKey) +{ + OSL_ASSERT(rxProperties.is()); + if ( ! rxProperties.is()) + return Any(); + try + { + Reference xInfo (rxProperties->getPropertySetInfo()); + if (xInfo.is()) + if ( ! xInfo->hasPropertyByName(rsKey)) + return Any(); + return rxProperties->getPropertyValue(rsKey); + } + catch (beans::UnknownPropertyException&) + { + } + return Any(); } -- cgit