diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-12-13 12:37:00 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-12-13 12:50:34 +0100 |
commit | bcdea3b379637a98e5bbc304078149ca6c2b6e03 (patch) | |
tree | a3803df980a54ab1a03c740c3114a54ca7d12f27 /configmgr/source/rootaccess.cxx | |
parent | Improve quoting when calling submake for custom targets. (diff) | |
download | core-bcdea3b379637a98e5bbc304078149ca6c2b6e03.tar.gz core-bcdea3b379637a98e5bbc304078149ca6c2b6e03.zip |
Simplified, type-safe C++ configuration access.
* New offapi com.sun.star.configuration entities to access the complete
configuration read-only or read/write...
* ...configmgr adapted to support those new services/singletons...
* ...new unotools/configuration.hxx is the type-safe C++ plumbing on top of
that...
* ...officecfg now generates C++ headers to access all the properties and sets
given in the .xcs files...
* ...and svl's asiancfg.cxx exemplarily makes use of the new
officecfg/Office/Common.hxx to access the configuration.
* There is still TODOs: For one, see those listed in
officecfg/registry/cppheader.xsl. For another, at least a notification
mechanism for the new read-only configuration access and the C++ wrapper is
missing.
Diffstat (limited to 'configmgr/source/rootaccess.cxx')
-rw-r--r-- | configmgr/source/rootaccess.cxx | 179 |
1 files changed, 91 insertions, 88 deletions
diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx index fc1fe39e8073..03ee3b88e29a 100644 --- a/configmgr/source/rootaccess.cxx +++ b/configmgr/source/rootaccess.cxx @@ -133,6 +133,91 @@ void RootAccess::setAlive(bool b) { alive_ = b; } +void RootAccess::addChangesListener( + css::uno::Reference< css::util::XChangesListener > const & aListener) + throw (css::uno::RuntimeException) +{ + assert(thisIs(IS_ANY)); + { + osl::MutexGuard g(*lock_); + checkLocalizedPropertyAccess(); + if (!aListener.is()) { + throw css::uno::RuntimeException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")), + static_cast< cppu::OWeakObject * >(this)); + } + if (!isDisposed()) { + changesListeners_.insert(aListener); + return; + } + } + try { + aListener->disposing( + css::lang::EventObject(static_cast< cppu::OWeakObject * >(this))); + } catch (css::lang::DisposedException &) {} +} + +void RootAccess::removeChangesListener( + css::uno::Reference< css::util::XChangesListener > const & aListener) + throw (css::uno::RuntimeException) +{ + assert(thisIs(IS_ANY)); + osl::MutexGuard g(*lock_); + checkLocalizedPropertyAccess(); + ChangesListeners::iterator i(changesListeners_.find(aListener)); + if (i != changesListeners_.end()) { + changesListeners_.erase(i); + } +} + +void RootAccess::commitChanges() + throw (css::lang::WrappedTargetException, css::uno::RuntimeException) +{ + assert(thisIs(IS_UPDATE)); + if (!alive_) + { + return; + } + Broadcaster bc; + { + osl::MutexGuard g(*lock_); + + checkLocalizedPropertyAccess(); + int finalizedLayer; + Modifications globalMods; + commitChildChanges( + ((getComponents().resolvePathRepresentation( + pathRepresentation_, 0, 0, &finalizedLayer) + == node_) && + finalizedLayer == Data::NO_LAYER), + &globalMods); + getComponents().writeModifications(); + getComponents().initGlobalBroadcaster(globalMods, this, &bc); + } + bc.send(); +} + +sal_Bool RootAccess::hasPendingChanges() throw (css::uno::RuntimeException) { + assert(thisIs(IS_UPDATE)); + osl::MutexGuard g(*lock_); + checkLocalizedPropertyAccess(); + //TODO: Optimize: + std::vector< css::util::ElementChange > changes; + reportChildChanges(&changes); + return !changes.empty(); +} + +css::util::ChangesSet RootAccess::getPendingChanges() + throw (css::uno::RuntimeException) +{ + assert(thisIs(IS_UPDATE)); + osl::MutexGuard g(*lock_); + checkLocalizedPropertyAccess(); + comphelper::SequenceAsVector< css::util::ElementChange > changes; + reportChildChanges(&changes); + return changes.getAsConstList(); +} + RootAccess::~RootAccess() { osl::MutexGuard g(*lock_); @@ -166,8 +251,10 @@ rtl::Reference< Node > RootAccess::getNode() { // RuntimeException.Context is left null here } pathRepresentation_ = canonic; - assert(!path_.empty()); - name_ = path_.back(); + assert(!path_.empty() || node_->kind() == Node::KIND_ROOT); + if (!path_.empty()) { + name_ = path_.back(); + } finalized_ = finalizedLayer != Data::NO_LAYER; } return node_; @@ -252,97 +339,13 @@ css::uno::Any RootAccess::queryInterface(css::uno::Type const & aType) return res; } -void RootAccess::addChangesListener( - css::uno::Reference< css::util::XChangesListener > const & aListener) +rtl::OUString RootAccess::getImplementationName() throw (css::uno::RuntimeException) { assert(thisIs(IS_ANY)); - { - osl::MutexGuard g(*lock_); - checkLocalizedPropertyAccess(); - if (!aListener.is()) { - throw css::uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")), - static_cast< cppu::OWeakObject * >(this)); - } - if (!isDisposed()) { - changesListeners_.insert(aListener); - return; - } - } - try { - aListener->disposing( - css::lang::EventObject(static_cast< cppu::OWeakObject * >(this))); - } catch (css::lang::DisposedException &) {} -} - -void RootAccess::removeChangesListener( - css::uno::Reference< css::util::XChangesListener > const & aListener) - throw (css::uno::RuntimeException) -{ - assert(thisIs(IS_ANY)); - osl::MutexGuard g(*lock_); - checkLocalizedPropertyAccess(); - ChangesListeners::iterator i(changesListeners_.find(aListener)); - if (i != changesListeners_.end()) { - changesListeners_.erase(i); - } -} - -void RootAccess::commitChanges() - throw (css::lang::WrappedTargetException, css::uno::RuntimeException) -{ - assert(thisIs(IS_UPDATE)); - if (!alive_) - { - return; - } - Broadcaster bc; - { - osl::MutexGuard g(*lock_); - - checkLocalizedPropertyAccess(); - int finalizedLayer; - Modifications globalMods; - commitChildChanges( - ((getComponents().resolvePathRepresentation( - pathRepresentation_, 0, 0, &finalizedLayer) - == node_) && - finalizedLayer == Data::NO_LAYER), - &globalMods); - getComponents().writeModifications(); - getComponents().initGlobalBroadcaster(globalMods, this, &bc); - } - bc.send(); -} - -sal_Bool RootAccess::hasPendingChanges() throw (css::uno::RuntimeException) { - assert(thisIs(IS_UPDATE)); - osl::MutexGuard g(*lock_); - checkLocalizedPropertyAccess(); - //TODO: Optimize: - std::vector< css::util::ElementChange > changes; - reportChildChanges(&changes); - return !changes.empty(); -} - -css::util::ChangesSet RootAccess::getPendingChanges() - throw (css::uno::RuntimeException) -{ - assert(thisIs(IS_UPDATE)); - osl::MutexGuard g(*lock_); - checkLocalizedPropertyAccess(); - comphelper::SequenceAsVector< css::util::ElementChange > changes; - reportChildChanges(&changes); - return changes.getAsConstList(); -} - -rtl::OUString RootAccess::getImplementationName() throw (css::uno::RuntimeException) -{ - assert(thisIs(IS_ANY)); osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); - return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "configmgr.RootAccess" ) ); + return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("configmgr.RootAccess")); } } |