summaryrefslogtreecommitdiff
path: root/configmgr/source
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source')
-rwxr-xr-x[-rw-r--r--]configmgr/source/README0
-rwxr-xr-x[-rw-r--r--]configmgr/source/access.cxx99
-rwxr-xr-x[-rw-r--r--]configmgr/source/access.hxx14
-rwxr-xr-x[-rw-r--r--]configmgr/source/additions.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/broadcaster.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/broadcaster.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/childaccess.cxx15
-rwxr-xr-x[-rw-r--r--]configmgr/source/childaccess.hxx11
-rwxr-xr-x[-rw-r--r--]configmgr/source/components.cxx28
-rwxr-xr-x[-rw-r--r--]configmgr/source/components.hxx7
-rwxr-xr-x[-rw-r--r--]configmgr/source/configmgr.component0
-rwxr-xr-x[-rw-r--r--]configmgr/source/configurationprovider.cxx13
-rwxr-xr-x[-rw-r--r--]configmgr/source/configurationprovider.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/configurationregistry.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/configurationregistry.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/data.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/data.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/defaultprovider.cxx7
-rwxr-xr-x[-rw-r--r--]configmgr/source/defaultprovider.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/groupnode.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/groupnode.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/localizedpropertynode.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/localizedpropertynode.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/localizedvaluenode.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/localizedvaluenode.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/lock.cxx11
-rwxr-xr-x[-rw-r--r--]configmgr/source/lock.hxx7
-rwxr-xr-x[-rw-r--r--]configmgr/source/makefile.mk0
-rwxr-xr-x[-rw-r--r--]configmgr/source/modifications.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/modifications.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/node.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/node.hxx9
-rwxr-xr-x[-rw-r--r--]configmgr/source/nodemap.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/nodemap.hxx5
-rwxr-xr-xconfigmgr/source/pad.cxx94
-rwxr-xr-x[-rw-r--r--]configmgr/source/parsemanager.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/parsemanager.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/parser.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/partial.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/partial.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/path.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/propertynode.cxx11
-rwxr-xr-x[-rw-r--r--]configmgr/source/propertynode.hxx7
-rwxr-xr-x[-rw-r--r--]configmgr/source/rootaccess.cxx29
-rwxr-xr-x[-rw-r--r--]configmgr/source/rootaccess.hxx11
-rwxr-xr-x[-rw-r--r--]configmgr/source/services.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/setnode.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/setnode.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/type.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/type.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/update.cxx14
-rwxr-xr-x[-rw-r--r--]configmgr/source/update.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/valueparser.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/valueparser.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/writemodfile.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/writemodfile.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xcdparser.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xcdparser.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xcsparser.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xcsparser.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xcuparser.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xcuparser.hxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xmldata.cxx3
-rwxr-xr-x[-rw-r--r--]configmgr/source/xmldata.hxx3
-rwxr-xr-xconfigmgr/source/xmlreader.cxx1058
-rwxr-xr-xconfigmgr/source/xmlreader.hxx182
66 files changed, 1655 insertions, 106 deletions
diff --git a/configmgr/source/README b/configmgr/source/README
index f26c68ecf7c0..f26c68ecf7c0 100644..100755
--- a/configmgr/source/README
+++ b/configmgr/source/README
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 2548643c7ce1..ef7ba869cf94 100644..100755
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -165,7 +166,9 @@ void Access::initBroadcaster(
Access::Access(Components & components):
components_(components), disposed_(false)
-{}
+{
+ lock_ = lock();
+}
Access::~Access() {}
@@ -850,7 +853,7 @@ css::uno::Sequence< css::uno::Type > Access::getTypes()
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
comphelper::SequenceAsVector< css::uno::Type > types;
types.push_back(cppu::UnoType< css::uno::XInterface >::get());
@@ -899,7 +902,7 @@ css::uno::Sequence< sal_Int8 > Access::getImplementationId()
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return css::uno::Sequence< sal_Int8 >();
}
@@ -907,7 +910,7 @@ css::uno::Sequence< sal_Int8 > Access::getImplementationId()
rtl::OUString Access::getImplementationName() throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("org.openoffice-configmgr::Access"));
@@ -917,7 +920,7 @@ sal_Bool Access::supportsService(rtl::OUString const & ServiceName)
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames());
for (sal_Int32 i = 0; i < names.getLength(); ++i) {
@@ -932,7 +935,7 @@ css::uno::Sequence< rtl::OUString > Access::getSupportedServiceNames()
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
comphelper::SequenceAsVector< rtl::OUString > services;
services.push_back(
@@ -996,7 +999,7 @@ void Access::dispose() throw (css::uno::RuntimeException) {
OSL_ASSERT(thisIs(IS_ANY));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
if (getParentAccess().is()) {
throw css::uno::RuntimeException(
@@ -1021,7 +1024,7 @@ void Access::addEventListener(
{
OSL_ASSERT(thisIs(IS_ANY));
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
if (!xListener.is()) {
throw css::uno::RuntimeException(
@@ -1044,7 +1047,7 @@ void Access::removeEventListener(
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
DisposeListeners::iterator i(disposeListeners_.find(aListener));
if (i != disposeListeners_.end()) {
@@ -1054,7 +1057,7 @@ void Access::removeEventListener(
css::uno::Type Access::getElementType() throw (css::uno::RuntimeException) {
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
rtl::Reference< Node > p(getNode());
switch (p->kind()) {
@@ -1078,7 +1081,7 @@ css::uno::Type Access::getElementType() throw (css::uno::RuntimeException) {
sal_Bool Access::hasElements() throw (css::uno::RuntimeException) {
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return !getAllChildren().empty(); //TODO: optimize
}
@@ -1089,7 +1092,7 @@ css::uno::Any Access::getByName(rtl::OUString const & aName)
css::lang::WrappedTargetException, css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getChild(aName));
if (!child.is()) {
@@ -1103,7 +1106,7 @@ css::uno::Sequence< rtl::OUString > Access::getElementNames()
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
comphelper::SequenceAsVector< rtl::OUString > names;
@@ -1120,7 +1123,7 @@ sal_Bool Access::hasByName(rtl::OUString const & aName)
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return getChild(aName).is();
}
@@ -1129,7 +1132,7 @@ css::uno::Any Access::getByHierarchicalName(rtl::OUString const & aName)
throw (css::container::NoSuchElementException, css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getSubChild(aName));
if (!child.is()) {
@@ -1143,7 +1146,7 @@ sal_Bool Access::hasByHierarchicalName(rtl::OUString const & aName)
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return getSubChild(aName).is();
}
@@ -1154,7 +1157,7 @@ void Access::addContainerListener(
{
OSL_ASSERT(thisIs(IS_ANY));
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
if (!xListener.is()) {
throw css::uno::RuntimeException(
@@ -1177,7 +1180,7 @@ void Access::removeContainerListener(
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
ContainerListeners::iterator i(containerListeners_.find(xListener));
if (i != containerListeners_.end()) {
@@ -1189,7 +1192,7 @@ rtl::OUString Access::getExactName(rtl::OUString const & aApproximateName)
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return aApproximateName;
}
@@ -1198,7 +1201,7 @@ css::uno::Sequence< css::beans::Property > Access::getProperties()
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
comphelper::SequenceAsVector< css::beans::Property > properties;
for (std::vector< rtl::Reference< ChildAccess > >::iterator i(
@@ -1214,7 +1217,7 @@ css::beans::Property Access::getPropertyByName(rtl::OUString const & aName)
throw (css::beans::UnknownPropertyException, css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
rtl::Reference< ChildAccess > child(getChild(aName));
if (!child.is()) {
throw css::beans::UnknownPropertyException(
@@ -1227,13 +1230,13 @@ sal_Bool Access::hasPropertyByName(rtl::OUString const & Name)
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
return getChild(Name).is();
}
rtl::OUString Access::getHierarchicalName() throw (css::uno::RuntimeException) {
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
// For backwards compatibility, return an absolute path representation where
// available:
@@ -1257,7 +1260,7 @@ rtl::OUString Access::composeHierarchicalName(
css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
if (aRelativeName.getLength() == 0 || aRelativeName[0] == '/') {
throw css::lang::IllegalArgumentException(
@@ -1277,7 +1280,7 @@ rtl::OUString Access::composeHierarchicalName(
rtl::OUString Access::getName() throw (css::uno::RuntimeException) {
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return getNameInternal();
}
@@ -1288,7 +1291,7 @@ void Access::setName(rtl::OUString const & aName)
OSL_ASSERT(thisIs(IS_ANY));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
checkFinalized();
Modifications localMods;
@@ -1352,7 +1355,7 @@ void Access::setName(rtl::OUString const & aName)
css::beans::Property Access::getAsProperty() throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return asProperty();
}
@@ -1374,7 +1377,7 @@ void Access::setPropertyValue(
OSL_ASSERT(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
rtl::OUString(
@@ -1398,7 +1401,7 @@ css::uno::Any Access::getPropertyValue(rtl::OUString const & PropertyName)
css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
rtl::Reference< ChildAccess > child(getChild(PropertyName));
if (!child.is()) {
throw css::beans::UnknownPropertyException(
@@ -1417,7 +1420,7 @@ void Access::addPropertyChangeListener(
{
OSL_ASSERT(thisIs(IS_GROUP));
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (!xListener.is()) {
throw css::uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
@@ -1444,7 +1447,7 @@ void Access::removePropertyChangeListener(
css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkKnownProperty(aPropertyName);
PropertyChangeListeners::iterator i(
propertyChangeListeners_.find(aPropertyName));
@@ -1469,7 +1472,7 @@ void Access::addVetoableChangeListener(
{
OSL_ASSERT(thisIs(IS_GROUP));
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (!aListener.is()) {
throw css::uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
@@ -1497,7 +1500,7 @@ void Access::removeVetoableChangeListener(
css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkKnownProperty(PropertyName);
VetoableChangeListeners::iterator i(
vetoableChangeListeners_.find(PropertyName));
@@ -1522,7 +1525,7 @@ void Access::setPropertyValues(
OSL_ASSERT(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
rtl::OUString(
@@ -1559,7 +1562,7 @@ css::uno::Sequence< css::uno::Any > Access::getPropertyValues(
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
css::uno::Sequence< css::uno::Any > vals(aPropertyNames.getLength());
for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i) {
rtl::Reference< ChildAccess > child(getChild(aPropertyNames[i]));
@@ -1584,7 +1587,7 @@ void Access::addPropertiesChangeListener(
{
OSL_ASSERT(thisIs(IS_GROUP));
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (!xListener.is()) {
throw css::uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
@@ -1607,7 +1610,7 @@ void Access::removePropertiesChangeListener(
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
PropertiesChangeListeners::iterator i(
propertiesChangeListeners_.find(xListener));
if (i != propertiesChangeListeners_.end()) {
@@ -1650,7 +1653,7 @@ void Access::setHierarchicalPropertyValue(
OSL_ASSERT(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
rtl::OUString(
@@ -1682,7 +1685,7 @@ css::uno::Any Access::getHierarchicalPropertyValue(
css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalPropertyName));
if (!child.is()) {
throw css::beans::UnknownPropertyException(
@@ -1702,7 +1705,7 @@ void Access::setHierarchicalPropertyValues(
OSL_ASSERT(thisIs(IS_GROUP));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (!getRootAccess()->isUpdate()) {
throw css::uno::RuntimeException(
rtl::OUString(
@@ -1746,7 +1749,7 @@ css::uno::Sequence< css::uno::Any > Access::getHierarchicalPropertyValues(
css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
css::uno::Sequence< css::uno::Any > vals(
aHierarchicalPropertyNames.getLength());
for (sal_Int32 i = 0; i < aHierarchicalPropertyNames.getLength(); ++i) {
@@ -1770,7 +1773,7 @@ css::beans::Property Access::getPropertyByHierarchicalName(
throw (css::beans::UnknownPropertyException, css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalName));
if (!child.is()) {
throw css::beans::UnknownPropertyException(
@@ -1784,7 +1787,7 @@ sal_Bool Access::hasPropertyByHierarchicalName(
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_GROUP));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
return getSubChild(aHierarchicalName).is();
}
@@ -1798,7 +1801,7 @@ void Access::replaceByName(
OSL_ASSERT(thisIs(IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getChild(aName));
if (!child.is()) {
@@ -1842,7 +1845,7 @@ void Access::insertByName(
OSL_ASSERT(thisIs(IS_EXTENSIBLE|IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
checkFinalized();
if (getChild(aName).is()) {
@@ -1892,7 +1895,7 @@ void Access::removeByName(rtl::OUString const & aName)
OSL_ASSERT(thisIs(IS_EXTENSIBLE|IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
rtl::Reference< ChildAccess > child(getChild(aName));
if (!child.is() || child->isFinalized() ||
@@ -2224,7 +2227,7 @@ rtl::Reference< Access > Access::getNotificationRoot() {
#if OSL_DEBUG_LEVEL > 0
bool Access::thisIs(int what) {
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
rtl::Reference< Node > p(getNode());
Node::Kind k(p->kind());
return k != Node::KIND_PROPERTY && k != Node::KIND_LOCALIZED_VALUE &&
@@ -2241,3 +2244,5 @@ bool Access::thisIs(int what) {
#endif
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/access.hxx b/configmgr/source/access.hxx
index 8c10aa8ccece..bf314f2f6aca 100644..100755
--- a/configmgr/source/access.hxx
+++ b/configmgr/source/access.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -35,6 +36,7 @@
#include <vector>
#include "boost/noncopyable.hpp"
+#include "boost/shared_ptr.hpp"
#include "com/sun/star/beans/PropertyVetoException.hpp"
#include "com/sun/star/beans/UnknownPropertyException.hpp"
#include "com/sun/star/beans/XExactName.hpp"
@@ -128,15 +130,12 @@ public:
bool isValue();
void markChildAsModified(rtl::Reference< ChildAccess > const & child);
-
void releaseChild(rtl::OUString const & name);
virtual Path getAbsolutePath() = 0;
-
virtual Path getRelativePath() = 0;
virtual rtl::OUString getRelativePathRepresentation() = 0;
-
virtual rtl::Reference< Node > getNode() = 0;
virtual bool isFinalized() = 0;
@@ -153,9 +152,7 @@ protected:
virtual ~Access();
virtual rtl::OUString getNameInternal() = 0;
-
virtual rtl::Reference< RootAccess > getRootAccess() = 0;
-
virtual rtl::Reference< Access > getParentAccess() = 0;
virtual void addTypes(std::vector< com::sun::star::uno::Type > * types)
@@ -165,7 +162,6 @@ protected:
std::vector< rtl::OUString > * services) = 0;
virtual void initDisposeBroadcaster(Broadcaster * broadcaster);
-
virtual void clearListeners() throw ();
virtual com::sun::star::uno::Any SAL_CALL queryInterface(
@@ -177,9 +173,7 @@ protected:
void checkLocalizedPropertyAccess();
rtl::Reference< Node > getParentNode();
-
rtl::Reference< ChildAccess > getChild(rtl::OUString const & name);
-
std::vector< rtl::Reference< ChildAccess > > getAllChildren();
void checkValue(
@@ -568,6 +562,8 @@ private:
PropertiesChangeListeners propertiesChangeListeners_;
bool disposed_;
+ boost::shared_ptr<osl::Mutex> lock_;
+
#if OSL_DEBUG_LEVEL > 0
protected:
enum {
@@ -580,3 +576,5 @@ protected:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/additions.hxx b/configmgr/source/additions.hxx
index f34373c7f742..5278dec2995f 100644..100755
--- a/configmgr/source/additions.hxx
+++ b/configmgr/source/additions.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -41,3 +42,5 @@ typedef std::list< Path > Additions;
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/broadcaster.cxx b/configmgr/source/broadcaster.cxx
index ab59d333d6d3..8634dfa08bc3 100644..100755
--- a/configmgr/source/broadcaster.cxx
+++ b/configmgr/source/broadcaster.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -256,3 +257,5 @@ Broadcaster::ChangesNotification::ChangesNotification(
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/broadcaster.hxx b/configmgr/source/broadcaster.hxx
index 95c4b1fac49b..75db85ec015d 100644..100755
--- a/configmgr/source/broadcaster.hxx
+++ b/configmgr/source/broadcaster.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -179,3 +180,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx
index d387f351de30..3d9c40bc072b 100644..100755
--- a/configmgr/source/childaccess.cxx
+++ b/configmgr/source/childaccess.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -94,6 +95,7 @@ ChildAccess::ChildAccess(
Access(components), root_(root), parent_(parent), name_(name), node_(node),
inTransaction_(false)
{
+ lock_ = lock();
OSL_ASSERT(root.is() && parent.is() && node.is());
}
@@ -102,6 +104,7 @@ ChildAccess::ChildAccess(
rtl::Reference< Node > const & node):
Access(components), root_(root), node_(node), inTransaction_(false)
{
+ lock_ = lock();
OSL_ASSERT(root.is() && node.is());
}
@@ -168,7 +171,7 @@ css::uno::Reference< css::uno::XInterface > ChildAccess::getParent()
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return static_cast< cppu::OWeakObject * >(parent_.get());
}
@@ -177,7 +180,7 @@ void ChildAccess::setParent(css::uno::Reference< css::uno::XInterface > const &)
throw (css::lang::NoSupportException, css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
throw css::lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("setParent")),
@@ -189,7 +192,7 @@ sal_Int64 ChildAccess::getSomething(
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
return aIdentifier == getTunnelId()
? reinterpret_cast< sal_Int64 >(this) : 0;
@@ -359,7 +362,7 @@ void ChildAccess::commitChanges(bool valid, Modifications * globalModifications)
}
ChildAccess::~ChildAccess() {
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
if (parent_.is()) {
parent_->releaseChild(name_);
}
@@ -389,7 +392,7 @@ css::uno::Any ChildAccess::queryInterface(css::uno::Type const & aType)
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
css::uno::Any res(Access::queryInterface(aType));
return res.hasValue()
@@ -400,3 +403,5 @@ css::uno::Any ChildAccess::queryInterface(css::uno::Type const & aType)
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/childaccess.hxx b/configmgr/source/childaccess.hxx
index c1cb14896978..77fd5190aae8 100644..100755
--- a/configmgr/source/childaccess.hxx
+++ b/configmgr/source/childaccess.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -39,6 +40,7 @@
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
+#include "boost/shared_ptr.hpp"
#include "rtl/ref.hxx"
#include "sal/types.h"
@@ -75,11 +77,9 @@ public:
rtl::Reference< Node > const & node);
virtual Path getAbsolutePath();
-
virtual Path getRelativePath();
virtual rtl::OUString getRelativePathRepresentation();
-
virtual rtl::Reference< Node > getNode();
virtual bool isFinalized();
@@ -87,11 +87,9 @@ public:
virtual rtl::OUString getNameInternal();
virtual rtl::Reference< RootAccess > getRootAccess();
-
virtual rtl::Reference< Access > getParentAccess();
virtual void SAL_CALL acquire() throw ();
-
virtual void SAL_CALL release() throw ();
virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
@@ -117,9 +115,7 @@ public:
void unbind() throw ();
bool isInTransaction() const { return inTransaction_; }
-
void committed();
-
void setNode(rtl::Reference< Node > const & node);
void setProperty(
@@ -150,8 +146,11 @@ private:
std::auto_ptr< com::sun::star::uno::Any > changedValue_;
bool inTransaction_;
// to determine if a free node can be inserted underneath some root
+ boost::shared_ptr<osl::Mutex> lock_;
};
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index 2d148959edfc..108e08fa7a12 100644..100755
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -182,6 +183,7 @@ private:
rtl::OUString url_;
Data const & data_;
osl::Condition delay_;
+ boost::shared_ptr<osl::Mutex> lock_;
};
Components::WriteThread::WriteThread(
@@ -189,6 +191,7 @@ Components::WriteThread::WriteThread(
rtl::OUString const & url, Data const & data):
reference_(reference), components_(components), url_(url), data_(data)
{
+ lock_ = lock();
OSL_ASSERT(reference != 0);
acquire();
}
@@ -196,7 +199,7 @@ Components::WriteThread::WriteThread(
void Components::WriteThread::run() {
TimeValue t = { 1, 0 }; // 1 sec
delay_.wait(&t); // must not throw; result_error is harmless and ignored
- osl::MutexGuard g(lock); // must not throw
+ osl::MutexGuard g(*lock_); // must not throw
try {
try {
writeModFile(components_, url_, data_);
@@ -219,9 +222,9 @@ Components & Components::getSingleton(
{
OSL_ASSERT(context.is());
if (!singletonCreated) {
- singletonCreated = true;
static Components theSingleton(context);
singleton = &theSingleton;
+ singletonCreated = true;
}
if (singleton == 0) {
throw css::uno::RuntimeException(
@@ -299,7 +302,17 @@ void Components::addModification(Path const & path) {
data_.modifications.add(path);
}
+bool Components::hasModifications() const
+{
+ return data_.modifications.getRoot().children.begin() !=
+ data_.modifications.getRoot().children.end();
+}
+
void Components::writeModifications() {
+
+ if (!hasModifications())
+ return;
+
if (!writeThread_.is()) {
writeThread_ = new WriteThread(
&writeThread_, *this, getModificationFileUrl(), data_);
@@ -310,7 +323,7 @@ void Components::writeModifications() {
void Components::flushModifications() {
rtl::Reference< WriteThread > thread;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
thread = writeThread_;
}
if (thread.is()) {
@@ -501,6 +514,8 @@ Components::Components(
css::uno::Reference< css::uno::XComponentContext > const & context):
context_(context)
{
+ lock_ = lock();
+
OSL_ASSERT(context.is());
RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "begin parsing");
parseXcsXcuLayer(
@@ -576,7 +591,10 @@ Components::Components(
RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "end parsing");
}
-Components::~Components() {}
+Components::~Components()
+{
+ flushModifications();
+}
void Components::parseFileLeniently(
FileParser * parseFile, rtl::OUString const & url, int layer, Data & data,
@@ -861,3 +879,5 @@ void Components::parseModificationLayer() {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx
index 34b693c7e585..9d216e1bb915 100644..100755
--- a/configmgr/source/components.hxx
+++ b/configmgr/source/components.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -34,6 +35,7 @@
#include <set>
#include "boost/noncopyable.hpp"
+#include "boost/shared_ptr.hpp"
#include "com/sun/star/beans/Optional.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "rtl/ref.hxx"
@@ -92,6 +94,8 @@ public:
void writeModifications();
+ bool hasModifications() const;
+
void flushModifications();
// must be called with configmgr::lock unaquired; must be called before
// shutdown if writeModifications has ever been called (probably
@@ -171,8 +175,11 @@ private:
WeakRootSet roots_;
ExternalServices externalServices_;
rtl::Reference< WriteThread > writeThread_;
+ boost::shared_ptr<osl::Mutex> lock_;
};
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/configmgr.component b/configmgr/source/configmgr.component
index 6ed51257005d..6ed51257005d 100644..100755
--- a/configmgr/source/configmgr.component
+++ b/configmgr/source/configmgr.component
diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx
index 999253118f11..6b8d967e92b9 100644..100755
--- a/configmgr/source/configurationprovider.cxx
+++ b/configmgr/source/configurationprovider.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -108,6 +109,7 @@ public:
ServiceBase(*static_cast< osl::Mutex * >(this)), context_(context),
locale_(locale)
{
+ lock_ = lock();
OSL_ASSERT(context.is());
}
@@ -171,6 +173,7 @@ private:
css::uno::Reference< css::uno::XComponentContext > context_;
rtl::OUString locale_;
+ boost::shared_ptr<osl::Mutex> lock_;
};
css::uno::Reference< css::uno::XInterface > Service::createInstance(
@@ -274,7 +277,7 @@ Service::createInstanceWithArguments(
ServiceSpecifier),
static_cast< cppu::OWeakObject * >(this));
}
- osl::MutexGuard guard(lock);
+ osl::MutexGuard guard(*lock_);
Components & components = Components::getSingleton(context_);
rtl::Reference< RootAccess > root(
new RootAccess(components, nodepath, locale, update));
@@ -355,13 +358,13 @@ void Service::removeFlushListener(
void Service::setLocale(css::lang::Locale const & eLocale)
throw (css::uno::RuntimeException)
{
- osl::MutexGuard guard(lock);
+ osl::MutexGuard guard(*lock_);
locale_ = comphelper::Locale(
eLocale.Language, eLocale.Country, eLocale.Variant).toISO();
}
css::lang::Locale Service::getLocale() throw (css::uno::RuntimeException) {
- osl::MutexGuard guard(lock);
+ osl::MutexGuard guard(*lock_);
css::lang::Locale loc;
if (locale_.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("*"))) {
loc.Language = locale_;
@@ -385,7 +388,7 @@ css::lang::Locale Service::getLocale() throw (css::uno::RuntimeException) {
void Service::flushModifications() const {
Components * components;
{
- osl::MutexGuard guard(lock);
+ osl::MutexGuard guard(*lock_);
components = &Components::getSingleton(context_);
}
components->flushModifications();
@@ -543,3 +546,5 @@ createFactory(
}
} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/configurationprovider.hxx b/configmgr/source/configurationprovider.hxx
index 4a8c38383774..a55e99809d79 100644..100755
--- a/configmgr/source/configurationprovider.hxx
+++ b/configmgr/source/configurationprovider.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -65,3 +66,5 @@ SAL_CALL createFactory(
} }
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/configurationregistry.cxx b/configmgr/source/configurationregistry.cxx
index f4810eb34ff8..a46d5ceb2e13 100644..100755
--- a/configmgr/source/configurationregistry.cxx
+++ b/configmgr/source/configurationregistry.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -896,3 +897,5 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
}
} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/configurationregistry.hxx b/configmgr/source/configurationregistry.hxx
index 417c519b97f4..fdba8f51e583 100644..100755
--- a/configmgr/source/configurationregistry.hxx
+++ b/configmgr/source/configurationregistry.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -55,3 +56,5 @@ getSupportedServiceNames();
} }
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx
index 50466ca0532c..989f543b197d 100644..100755
--- a/configmgr/source/data.cxx
+++ b/configmgr/source/data.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -370,3 +371,5 @@ rtl::Reference< Data::ExtensionXcu > Data::removeExtensionXcuAdditions(
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/data.hxx b/configmgr/source/data.hxx
index 8f5f7af0d86e..f60ecfa1e807 100644..100755
--- a/configmgr/source/data.hxx
+++ b/configmgr/source/data.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -104,3 +105,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/defaultprovider.cxx b/configmgr/source/defaultprovider.cxx
index 9079d4736a6c..6e65301e8c82 100644..100755
--- a/configmgr/source/defaultprovider.cxx
+++ b/configmgr/source/defaultprovider.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -46,12 +47,10 @@ namespace {
namespace css = com::sun::star;
-}
-
css::uno::Reference< css::uno::XInterface > create(
css::uno::Reference< css::uno::XComponentContext > const & context)
{
- osl::MutexGuard guard(lock);
+ osl::MutexGuard guard(*lock_);
static css::uno::Reference< css::uno::XInterface > singleton(
configuration_provider::createDefault(context));
return singleton;
@@ -71,3 +70,5 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
}
} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/defaultprovider.hxx b/configmgr/source/defaultprovider.hxx
index f678931d35fe..1dbc44d525e0 100644..100755
--- a/configmgr/source/defaultprovider.hxx
+++ b/configmgr/source/defaultprovider.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -57,3 +58,5 @@ getSupportedServiceNames();
} }
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/groupnode.cxx b/configmgr/source/groupnode.cxx
index 59c0f89df5d1..fa56afa1a29c 100644..100755
--- a/configmgr/source/groupnode.cxx
+++ b/configmgr/source/groupnode.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -88,3 +89,5 @@ void GroupNode::clear() {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/groupnode.hxx b/configmgr/source/groupnode.hxx
index 9d7bbbafa5b3..02f1679998a2 100644..100755
--- a/configmgr/source/groupnode.hxx
+++ b/configmgr/source/groupnode.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -73,3 +74,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/localizedpropertynode.cxx b/configmgr/source/localizedpropertynode.cxx
index 54560d7aded4..c03f552de1d3 100644..100755
--- a/configmgr/source/localizedpropertynode.cxx
+++ b/configmgr/source/localizedpropertynode.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -85,3 +86,5 @@ void LocalizedPropertyNode::clear() {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/localizedpropertynode.hxx b/configmgr/source/localizedpropertynode.hxx
index 4ebcf8e243da..bbe934e36bcd 100644..100755
--- a/configmgr/source/localizedpropertynode.hxx
+++ b/configmgr/source/localizedpropertynode.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -74,3 +75,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/localizedvaluenode.cxx b/configmgr/source/localizedvaluenode.cxx
index c0e3bc333187..ac6346f09227 100644..100755
--- a/configmgr/source/localizedvaluenode.cxx
+++ b/configmgr/source/localizedvaluenode.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -76,3 +77,5 @@ Node::Kind LocalizedValueNode::kind() const {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/localizedvaluenode.hxx b/configmgr/source/localizedvaluenode.hxx
index bfcbdea1de51..23139bec4029 100644..100755
--- a/configmgr/source/localizedvaluenode.hxx
+++ b/configmgr/source/localizedvaluenode.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -64,3 +65,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/lock.cxx b/configmgr/source/lock.cxx
index dc7f26a34e73..3950a2d5e3e0 100644..100755
--- a/configmgr/source/lock.cxx
+++ b/configmgr/source/lock.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -34,6 +35,14 @@
namespace configmgr {
-osl::Mutex lock;
+boost::shared_ptr<osl::Mutex> lock()
+{
+ static boost::shared_ptr<osl::Mutex> theLock;
+ if (!theLock.get())
+ theLock.reset(new osl::Mutex);
+ return theLock;
+}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/lock.hxx b/configmgr/source/lock.hxx
index b541f48fbe77..b37e83a44ee2 100644..100755
--- a/configmgr/source/lock.hxx
+++ b/configmgr/source/lock.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -29,13 +30,15 @@
#define INCLUDED_CONFIGMGR_SOURCE_LOCK_HXX
#include "sal/config.h"
-
#include "osl/mutex.hxx"
+#include "boost/shared_ptr.hpp"
namespace configmgr {
-extern osl::Mutex lock;
+boost::shared_ptr<osl::Mutex> lock();
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/makefile.mk b/configmgr/source/makefile.mk
index 94747d9dd803..94747d9dd803 100644..100755
--- a/configmgr/source/makefile.mk
+++ b/configmgr/source/makefile.mk
diff --git a/configmgr/source/modifications.cxx b/configmgr/source/modifications.cxx
index add18ceaa1ea..e83d4a501af6 100644..100755
--- a/configmgr/source/modifications.cxx
+++ b/configmgr/source/modifications.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -85,3 +86,5 @@ Modifications::Node const & Modifications::getRoot() const {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/modifications.hxx b/configmgr/source/modifications.hxx
index c28b1aadd192..fa4f08a157fd 100644..100755
--- a/configmgr/source/modifications.hxx
+++ b/configmgr/source/modifications.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -65,3 +66,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/node.cxx b/configmgr/source/node.cxx
index 5473b6b1de0c..58d13c4fee55 100644..100755
--- a/configmgr/source/node.cxx
+++ b/configmgr/source/node.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -102,3 +103,5 @@ Node::~Node() {}
void Node::clear() {}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/node.hxx b/configmgr/source/node.hxx
index f79e7ba296fa..932d11cf3744 100644..100755
--- a/configmgr/source/node.hxx
+++ b/configmgr/source/node.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -50,30 +51,24 @@ public:
virtual rtl::Reference< Node > clone(bool keepTemplateName) const = 0;
virtual NodeMap & getMembers();
-
virtual rtl::OUString getTemplateName() const;
virtual void setMandatory(int layer);
-
virtual int getMandatory() const;
void setLayer(int layer);
-
int getLayer() const;
void setFinalized(int layer);
-
int getFinalized() const;
rtl::Reference< Node > getMember(rtl::OUString const & name);
protected:
explicit Node(int layer);
-
Node(const Node & other);
virtual ~Node();
-
virtual void clear();
int layer_;
@@ -83,3 +78,5 @@ protected:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/nodemap.cxx b/configmgr/source/nodemap.cxx
index 8e4d06030bdf..432aa64e7991 100644..100755
--- a/configmgr/source/nodemap.cxx
+++ b/configmgr/source/nodemap.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -48,3 +49,5 @@ void cloneNodeMap(NodeMap const & source, NodeMap * target) {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/nodemap.hxx b/configmgr/source/nodemap.hxx
index 92ea324091cd..5e9e501e9fc7 100644..100755
--- a/configmgr/source/nodemap.hxx
+++ b/configmgr/source/nodemap.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -29,9 +30,7 @@
#define INCLUDED_CONFIGMGR_SOURCE_NODEMAP_HXX
#include "sal/config.h"
-
#include <map>
-
#include "rtl/ref.hxx"
namespace rtl { class OUString; }
@@ -47,3 +46,5 @@ void cloneNodeMap(NodeMap const & source, NodeMap * target);
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/pad.cxx b/configmgr/source/pad.cxx
new file mode 100755
index 000000000000..68a92b5aa741
--- /dev/null
+++ b/configmgr/source/pad.cxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+* 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.
+*
+************************************************************************/
+
+#include "precompiled_configmgr.hxx"
+#include "sal/config.h"
+
+#include "osl/diagnose.h"
+#include "rtl/string.h"
+#include "sal/types.h"
+
+#include "pad.hxx"
+#include "span.hxx"
+
+namespace configmgr {
+
+void Pad::add(char const * begin, sal_Int32 length) {
+ OSL_ASSERT(
+ begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0));
+ if (length != 0) {
+ flushSpan();
+ if (buffer_.getLength() == 0) {
+ span_ = Span(begin, length);
+ } else {
+ buffer_.append(begin, length);
+ }
+ }
+}
+
+void Pad::addEphemeral(char const * begin, sal_Int32 length) {
+ OSL_ASSERT(
+ begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0));
+ if (length != 0) {
+ flushSpan();
+ buffer_.append(begin, length);
+ }
+}
+
+void Pad::clear() {
+ OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0));
+ span_.clear();
+ buffer_.setLength(0);
+}
+
+bool Pad::is() const {
+ OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0));
+ return span_.is() || buffer_.getLength() != 0;
+}
+
+Span Pad::get() const {
+ OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0));
+ if (span_.is()) {
+ return span_;
+ } else if (buffer_.getLength() == 0) {
+ return Span(RTL_CONSTASCII_STRINGPARAM(""));
+ } else {
+ return Span(buffer_.getStr(), buffer_.getLength());
+ }
+}
+
+void Pad::flushSpan() {
+ if (span_.is()) {
+ buffer_.append(span_.begin, span_.length);
+ span_.clear();
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/parsemanager.cxx b/configmgr/source/parsemanager.cxx
index c17eddd2976f..d5a2d2ddd5b0 100644..100755
--- a/configmgr/source/parsemanager.cxx
+++ b/configmgr/source/parsemanager.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -98,3 +99,5 @@ bool ParseManager::parse() {
ParseManager::~ParseManager() {}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/parsemanager.hxx b/configmgr/source/parsemanager.hxx
index 19d16c74621a..a6a238b0a0ec 100644..100755
--- a/configmgr/source/parsemanager.hxx
+++ b/configmgr/source/parsemanager.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -68,3 +69,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/parser.hxx b/configmgr/source/parser.hxx
index f782e0dbc151..a7151b71c616 100644..100755
--- a/configmgr/source/parser.hxx
+++ b/configmgr/source/parser.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -60,3 +61,5 @@ protected:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/partial.cxx b/configmgr/source/partial.cxx
index 4c9189ed05c4..f3f91a4c05a6 100644..100755
--- a/configmgr/source/partial.cxx
+++ b/configmgr/source/partial.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -135,3 +136,5 @@ Partial::Containment Partial::contains(Path const & path) const {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/partial.hxx b/configmgr/source/partial.hxx
index 39931448c66d..135aa5d66355 100644..100755
--- a/configmgr/source/partial.hxx
+++ b/configmgr/source/partial.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -69,3 +70,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/path.hxx b/configmgr/source/path.hxx
index fc70287dfe7b..2de401099d00 100644..100755
--- a/configmgr/source/path.hxx
+++ b/configmgr/source/path.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -41,3 +42,5 @@ typedef std::vector< rtl::OUString > Path;
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/propertynode.cxx b/configmgr/source/propertynode.cxx
index f3e459998e7e..8e2eec660d2b 100644..100755
--- a/configmgr/source/propertynode.cxx
+++ b/configmgr/source/propertynode.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -51,8 +52,8 @@ namespace css = com::sun::star;
PropertyNode::PropertyNode(
int layer, Type staticType, bool nillable, css::uno::Any const & value,
bool extension):
- Node(layer), staticType_(staticType), nillable_(nillable), value_(value),
- extension_(extension)
+ Node(layer), staticType_(staticType), nillable_(nillable),
+ extension_(extension), value_(value)
{}
rtl::Reference< Node > PropertyNode::clone(bool) const {
@@ -97,8 +98,8 @@ bool PropertyNode::isExtension() const {
PropertyNode::PropertyNode(PropertyNode const & other):
Node(other), staticType_(other.staticType_), nillable_(other.nillable_),
- value_(other.value_), externalDescriptor_(other.externalDescriptor_),
- extension_(other.extension_)
+ extension_(other.extension_), externalDescriptor_(other.externalDescriptor_),
+ value_(other.value_)
{}
PropertyNode::~PropertyNode() {}
@@ -108,3 +109,5 @@ Node::Kind PropertyNode::kind() const {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/propertynode.hxx b/configmgr/source/propertynode.hxx
index 506526ffcc1e..6e0edc895f29 100644..100755
--- a/configmgr/source/propertynode.hxx
+++ b/configmgr/source/propertynode.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -73,11 +74,13 @@ private:
// as specified in the component-schema (TYPE_ANY, ...,
// TYPE_HEXBINARY_LIST; not TYPE_ERROR or TYPE_NIL)
bool nillable_;
- com::sun::star::uno::Any value_;
- rtl::OUString externalDescriptor_;
bool extension_;
+ rtl::OUString externalDescriptor_;
+ com::sun::star::uno::Any value_;
};
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx
index f5d0bb137202..ef5982e3a56d 100644..100755
--- a/configmgr/source/rootaccess.cxx
+++ b/configmgr/source/rootaccess.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -77,7 +78,9 @@ RootAccess::RootAccess(
rtl::OUString const & locale, bool update):
Access(components), pathRepresentation_(pathRepresentation),
locale_(locale), update_(update)
-{}
+{
+ lock_ = lock();
+}
Path RootAccess::getAbsolutePath() {
getNode();
@@ -128,7 +131,7 @@ bool RootAccess::isUpdate() const {
}
RootAccess::~RootAccess() {
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
getComponents().removeRootAccess(this);
}
@@ -226,7 +229,7 @@ css::uno::Any RootAccess::queryInterface(css::uno::Type const & aType)
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
css::uno::Any res(Access::queryInterface(aType));
if (res.hasValue()) {
@@ -250,7 +253,7 @@ void RootAccess::addChangesListener(
{
OSL_ASSERT(thisIs(IS_ANY));
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
if (!aListener.is()) {
throw css::uno::RuntimeException(
@@ -273,7 +276,7 @@ void RootAccess::removeChangesListener(
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_ANY));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
ChangesListeners::iterator i(changesListeners_.find(aListener));
if (i != changesListeners_.end()) {
@@ -287,7 +290,7 @@ void RootAccess::commitChanges()
OSL_ASSERT(thisIs(IS_UPDATE));
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
int finalizedLayer;
Modifications globalMods;
@@ -305,7 +308,7 @@ void RootAccess::commitChanges()
sal_Bool RootAccess::hasPendingChanges() throw (css::uno::RuntimeException) {
OSL_ASSERT(thisIs(IS_UPDATE));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
//TODO: Optimize:
std::vector< css::util::ElementChange > changes;
@@ -317,11 +320,21 @@ css::util::ChangesSet RootAccess::getPendingChanges()
throw (css::uno::RuntimeException)
{
OSL_ASSERT(thisIs(IS_UPDATE));
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
checkLocalizedPropertyAccess();
comphelper::SequenceAsVector< css::util::ElementChange > changes;
reportChildChanges(&changes);
return changes.getAsConstList();
}
+rtl::OUString RootAccess::getImplementationName() throw (css::uno::RuntimeException)
+{
+ OSL_ASSERT(thisIs(IS_ANY));
+ osl::MutexGuard g(*lock_);
+ checkLocalizedPropertyAccess();
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "configmgr.RootAccess" ) );
+}
+
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/rootaccess.hxx b/configmgr/source/rootaccess.hxx
index 77d945cdbbed..c1751210c50c 100644..100755
--- a/configmgr/source/rootaccess.hxx
+++ b/configmgr/source/rootaccess.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -38,6 +39,7 @@
#include "com/sun/star/util/ChangesSet.hpp"
#include "com/sun/star/util/XChangesBatch.hpp"
#include "com/sun/star/util/XChangesNotifier.hpp"
+#include "boost/shared_ptr.hpp"
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
@@ -84,6 +86,11 @@ public:
bool isUpdate() const;
+protected:
+
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (com::sun::star::uno::RuntimeException);
+
private:
virtual ~RootAccess();
@@ -150,8 +157,12 @@ private:
rtl::OUString name_;
bool finalized_;
ChangesListeners changesListeners_;
+
+ boost::shared_ptr<osl::Mutex> lock_;
};
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/services.cxx b/configmgr/source/services.cxx
index dd01189be6e2..d274cd8973ca 100644..100755
--- a/configmgr/source/services.cxx
+++ b/configmgr/source/services.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -88,3 +89,5 @@ component_getImplementationEnvironment(
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/setnode.cxx b/configmgr/source/setnode.cxx
index 465345a5f856..52b117bb0154 100644..100755
--- a/configmgr/source/setnode.cxx
+++ b/configmgr/source/setnode.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -127,3 +128,5 @@ void SetNode::clear() {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/setnode.hxx b/configmgr/source/setnode.hxx
index 94ce537adda1..00bcab2a55a1 100644..100755
--- a/configmgr/source/setnode.hxx
+++ b/configmgr/source/setnode.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -82,3 +83,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/type.cxx b/configmgr/source/type.cxx
index e1b8a95859ef..b3bfd72d3e8d 100644..100755
--- a/configmgr/source/type.cxx
+++ b/configmgr/source/type.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -185,3 +186,5 @@ Type getDynamicType(css::uno::Any const & value) {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/type.hxx b/configmgr/source/type.hxx
index 85edc9b5e9cd..91e335de1e44 100644..100755
--- a/configmgr/source/type.hxx
+++ b/configmgr/source/type.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -54,3 +55,5 @@ Type getDynamicType(com::sun::star::uno::Any const & value);
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx
index 258765158aa3..d63ff05841ab 100644..100755
--- a/configmgr/source/update.cxx
+++ b/configmgr/source/update.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -31,6 +32,7 @@
#include <set>
#include "boost/noncopyable.hpp"
+#include "boost/shared_ptr.hpp"
#include "com/sun/star/configuration/XUpdate.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
@@ -75,6 +77,7 @@ public:
context_(context)
{
OSL_ASSERT(context.is());
+ lock_ = lock();
}
private:
@@ -97,6 +100,7 @@ private:
css::uno::Sequence< rtl::OUString > const & excludedPaths)
throw (css::uno::RuntimeException);
+ boost::shared_ptr<osl::Mutex> lock_;
css::uno::Reference< css::uno::XComponentContext > context_;
};
@@ -104,7 +108,7 @@ void Service::insertExtensionXcsFile(
sal_Bool shared, rtl::OUString const & fileUri)
throw (css::uno::RuntimeException)
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
}
@@ -114,7 +118,7 @@ void Service::insertExtensionXcuFile(
{
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
Components & components = Components::getSingleton(context_);
Modifications mods;
components.insertExtensionXcuFile(shared, fileUri, &mods);
@@ -129,7 +133,7 @@ void Service::removeExtensionXcuFile(rtl::OUString const & fileUri)
{
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
Components & components = Components::getSingleton(context_);
Modifications mods;
components.removeExtensionXcuFile(fileUri, &mods);
@@ -147,7 +151,7 @@ void Service::insertModificationXcuFile(
{
Broadcaster bc;
{
- osl::MutexGuard g(lock);
+ osl::MutexGuard g(*lock_);
Components & components = Components::getSingleton(context_);
Modifications mods;
components.insertModificationXcuFile(
@@ -179,3 +183,5 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
}
} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/update.hxx b/configmgr/source/update.hxx
index a60264e67ac3..3e423679d327 100644..100755
--- a/configmgr/source/update.hxx
+++ b/configmgr/source/update.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -57,3 +58,5 @@ getSupportedServiceNames();
} }
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index 0be173f74919..8488531019cb 100644..100755
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -476,3 +477,5 @@ template< typename T > css::uno::Any ValueParser::convertItems() {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/valueparser.hxx b/configmgr/source/valueparser.hxx
index c5e1d0a0a45f..a3ee2310ea35 100644..100755
--- a/configmgr/source/valueparser.hxx
+++ b/configmgr/source/valueparser.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -90,3 +91,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx
index 5616833abf3d..fcb1129bba1e 100644..100755
--- a/configmgr/source/writemodfile.cxx
+++ b/configmgr/source/writemodfile.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -600,3 +601,5 @@ void writeModFile(
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/writemodfile.hxx b/configmgr/source/writemodfile.hxx
index 250edfd095af..0277bacdc477 100644..100755
--- a/configmgr/source/writemodfile.hxx
+++ b/configmgr/source/writemodfile.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -43,3 +44,5 @@ void writeModFile(
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xcdparser.cxx b/configmgr/source/xcdparser.cxx
index a7b66fe60157..7c2e21d6c6bb 100644..100755
--- a/configmgr/source/xcdparser.cxx
+++ b/configmgr/source/xcdparser.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -183,3 +184,5 @@ void XcdParser::characters(xmlreader::Span const & text) {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xcdparser.hxx b/configmgr/source/xcdparser.hxx
index a807e011b244..6e98160dfeff 100644..100755
--- a/configmgr/source/xcdparser.hxx
+++ b/configmgr/source/xcdparser.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -77,3 +78,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx
index 1deb8e9f3029..c558bd9864b7 100644..100755
--- a/configmgr/source/xcsparser.cxx
+++ b/configmgr/source/xcsparser.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -666,3 +667,5 @@ void XcsParser::handleSetItem(xmlreader::XmlReader & reader, SetNode * set) {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xcsparser.hxx b/configmgr/source/xcsparser.hxx
index 1fac315c0783..c259a02eaec8 100644..100755
--- a/configmgr/source/xcsparser.hxx
+++ b/configmgr/source/xcsparser.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -105,3 +106,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx
index dc5d08cb4e08..3a81ea4e3673 100644..100755
--- a/configmgr/source/xcuparser.cxx
+++ b/configmgr/source/xcuparser.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -1134,3 +1135,5 @@ void XcuParser::recordModification(bool addition) {
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xcuparser.hxx b/configmgr/source/xcuparser.hxx
index 6cd600c8aab1..dda51d254f37 100644..100755
--- a/configmgr/source/xcuparser.hxx
+++ b/configmgr/source/xcuparser.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -155,3 +156,5 @@ private:
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xmldata.cxx b/configmgr/source/xmldata.cxx
index 7d3d9ead3d2c..5120506bfbb4 100644..100755
--- a/configmgr/source/xmldata.cxx
+++ b/configmgr/source/xmldata.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -198,3 +199,5 @@ rtl::OUString parseTemplateReference(
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xmldata.hxx b/configmgr/source/xmldata.hxx
index e60e1082cabb..2b35adaae4f9 100644..100755
--- a/configmgr/source/xmldata.hxx
+++ b/configmgr/source/xmldata.hxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -56,3 +57,5 @@ rtl::OUString parseTemplateReference(
}
#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xmlreader.cxx b/configmgr/source/xmlreader.cxx
new file mode 100755
index 000000000000..49963ca3188a
--- /dev/null
+++ b/configmgr/source/xmlreader.cxx
@@ -0,0 +1,1058 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+* 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.
+*
+************************************************************************/
+
+#include "precompiled_configmgr.hxx"
+#include "sal/config.h"
+#include "sal/macros.h"
+
+#include <cstddef>
+
+#include "com/sun/star/container/NoSuchElementException.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "osl/diagnose.h"
+#include "osl/file.h"
+#include "rtl/string.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+#include "pad.hxx"
+#include "span.hxx"
+#include "xmlreader.hxx"
+
+namespace configmgr {
+
+namespace {
+
+namespace css = com::sun::star;
+
+bool isSpace(char c) {
+ switch (c) {
+ case '\x09':
+ case '\x0A':
+ case '\x0D':
+ case ' ':
+ return true;
+ default:
+ return false;
+ }
+}
+
+}
+
+XmlReader::XmlReader(rtl::OUString const & fileUrl)
+ SAL_THROW((
+ css::container::NoSuchElementException, css::uno::RuntimeException)):
+ fileUrl_(fileUrl)
+{
+ switch (osl_openFile(fileUrl_.pData, &fileHandle_, osl_File_OpenFlag_Read))
+ {
+ case osl_File_E_None:
+ break;
+ case osl_File_E_NOENT:
+ throw css::container::NoSuchElementException(
+ fileUrl_, css::uno::Reference< css::uno::XInterface >());
+ default:
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cannot open ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ oslFileError e = osl_getFileSize(fileHandle_, &fileSize_);
+ if (e == osl_File_E_None) {
+ e = osl_mapFile(
+ fileHandle_, &fileAddress_, fileSize_, 0,
+ osl_File_MapFlag_WillNeed);
+ }
+ if (e != osl_File_E_None) {
+ e = osl_closeFile(fileHandle_);
+ if (e != osl_File_E_None) {
+ OSL_TRACE("osl_closeFile failed with %ld", static_cast< long >(e));
+ }
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cannot mmap ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ namespaces_.push_back(
+ NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML));
+ namespaces_.push_back(
+ NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xsi")), NAMESPACE_XSI));
+ // old user layer .xcu files used the xsi namespace prefix without
+ // declaring a corresponding namespace binding, see issue 77174; reading
+ // those files during migration would fail without this hack that can be
+ // removed once migration is no longer relevant (see
+ // Components::parseModificationLayer)
+ pos_ = static_cast< char * >(fileAddress_);
+ end_ = pos_ + fileSize_;
+ state_ = STATE_CONTENT;
+}
+
+XmlReader::~XmlReader() {
+ oslFileError e = osl_unmapFile(fileAddress_, fileSize_);
+ if (e != osl_File_E_None) {
+ OSL_TRACE("osl_unmapFile failed with %ld", static_cast< long >(e));
+ }
+ e = osl_closeFile(fileHandle_);
+ if (e != osl_File_E_None) {
+ OSL_TRACE("osl_closeFile failed with %ld", static_cast< long >(e));
+ }
+}
+
+XmlReader::Result XmlReader::nextItem(
+ Text reportText, Span * data, Namespace * ns)
+{
+ switch (state_) {
+ case STATE_CONTENT:
+ switch (reportText) {
+ case TEXT_NONE:
+ return handleSkippedText(data, ns);
+ case TEXT_RAW:
+ return handleRawText(data);
+ case TEXT_NORMALIZED:
+ return handleNormalizedText(data);
+ }
+ case STATE_START_TAG:
+ return handleStartTag(ns, data);
+ case STATE_END_TAG:
+ return handleEndTag();
+ case STATE_EMPTY_ELEMENT_TAG:
+ handleElementEnd();
+ return RESULT_END;
+ default: // STATE_DONE
+ return RESULT_DONE;
+ }
+}
+
+bool XmlReader::nextAttribute(Namespace * ns, Span * localName) {
+ OSL_ASSERT(ns != 0 && localName != 0);
+ if (firstAttribute_) {
+ currentAttribute_ = attributes_.begin();
+ firstAttribute_ = false;
+ } else {
+ ++currentAttribute_;
+ }
+ if (currentAttribute_ == attributes_.end()) {
+ return false;
+ }
+ if (currentAttribute_->nameColon == 0) {
+ *ns = NAMESPACE_NONE;
+ *localName = Span(
+ currentAttribute_->nameBegin,
+ currentAttribute_->nameEnd - currentAttribute_->nameBegin);
+ } else {
+ *ns = getNamespace(
+ Span(
+ currentAttribute_->nameBegin,
+ currentAttribute_->nameColon - currentAttribute_->nameBegin));
+ *localName = Span(
+ currentAttribute_->nameColon + 1,
+ currentAttribute_->nameEnd - (currentAttribute_->nameColon + 1));
+ }
+ return true;
+}
+
+Span XmlReader::getAttributeValue(bool fullyNormalize) {
+ return handleAttributeValue(
+ currentAttribute_->valueBegin, currentAttribute_->valueEnd,
+ fullyNormalize);
+}
+
+XmlReader::Namespace XmlReader::getNamespace(Span const & prefix) const {
+ for (NamespaceList::const_reverse_iterator i(namespaces_.rbegin());
+ i != namespaces_.rend(); ++i)
+ {
+ if (prefix.equals(i->prefix)) {
+ return i->ns;
+ }
+ }
+ return NAMESPACE_OTHER;
+}
+
+rtl::OUString XmlReader::getUrl() const {
+ return fileUrl_;
+}
+
+void XmlReader::normalizeLineEnds(Span const & text) {
+ char const * p = text.begin;
+ sal_Int32 n = text.length;
+ for (;;) {
+ sal_Int32 i = rtl_str_indexOfChar_WithLength(p, n, '\x0D');
+ if (i < 0) {
+ break;
+ }
+ pad_.add(p, i);
+ p += i + 1;
+ n -= i + 1;
+ if (n == 0 || *p != '\x0A') {
+ pad_.add(RTL_CONSTASCII_STRINGPARAM("\x0A"));
+ }
+ }
+ pad_.add(p, n);
+}
+
+void XmlReader::skipSpace() {
+ while (isSpace(peek())) {
+ ++pos_;
+ }
+}
+
+bool XmlReader::skipComment() {
+ if (rtl_str_shortenedCompare_WithLength(
+ pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("--"),
+ RTL_CONSTASCII_LENGTH("--")) !=
+ 0)
+ {
+ return false;
+ }
+ pos_ += RTL_CONSTASCII_LENGTH("--");
+ sal_Int32 i = rtl_str_indexOfStr_WithLength(
+ pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("--"));
+ if (i < 0) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "premature end (within comment) of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ pos_ += i + RTL_CONSTASCII_LENGTH("--");
+ if (read() != '>') {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "illegal \"--\" within comment in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ return true;
+}
+
+void XmlReader::skipProcessingInstruction() {
+ sal_Int32 i = rtl_str_indexOfStr_WithLength(
+ pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("?>"));
+ if (i < 0) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad '<?' in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ pos_ += i + RTL_CONSTASCII_LENGTH("?>");
+}
+
+void XmlReader::skipDocumentTypeDeclaration() {
+ // Neither is it checked that the doctypedecl is at the correct position in
+ // the document, nor that it is well-formed:
+ for (;;) {
+ char c = read();
+ switch (c) {
+ case '\0': // i.e., EOF
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "premature end (within DTD) of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ case '"':
+ case '\'':
+ {
+ sal_Int32 i = rtl_str_indexOfChar_WithLength(
+ pos_, end_ - pos_, c);
+ if (i < 0) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "premature end (within DTD) of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ pos_ += i + 1;
+ }
+ break;
+ case '>':
+ return;
+ case '[':
+ for (;;) {
+ c = read();
+ switch (c) {
+ case '\0': // i.e., EOF
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "premature end (within DTD) of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ case '"':
+ case '\'':
+ {
+ sal_Int32 i = rtl_str_indexOfChar_WithLength(
+ pos_, end_ - pos_, c);
+ if (i < 0) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "premature end (within DTD) of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ pos_ += i + 1;
+ }
+ break;
+ case '<':
+ switch (read()) {
+ case '\0': // i.e., EOF
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "premature end (within DTD) of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ case '!':
+ skipComment();
+ break;
+ case '?':
+ skipProcessingInstruction();
+ break;
+ default:
+ break;
+ }
+ break;
+ case ']':
+ skipSpace();
+ if (read() != '>') {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "missing \">\" of DTD in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ return;
+ default:
+ break;
+ }
+ }
+ default:
+ break;
+ }
+ }
+}
+
+Span XmlReader::scanCdataSection() {
+ if (rtl_str_shortenedCompare_WithLength(
+ pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("[CDATA["),
+ RTL_CONSTASCII_LENGTH("[CDATA[")) !=
+ 0)
+ {
+ return Span();
+ }
+ pos_ += RTL_CONSTASCII_LENGTH("[CDATA[");
+ char const * begin = pos_;
+ sal_Int32 i = rtl_str_indexOfStr_WithLength(
+ pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("]]>"));
+ if (i < 0) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "premature end (within CDATA section) of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ pos_ += i + RTL_CONSTASCII_LENGTH("]]>");
+ return Span(begin, i);
+}
+
+bool XmlReader::scanName(char const ** nameColon) {
+ OSL_ASSERT(nameColon != 0 && *nameColon == 0);
+ for (char const * begin = pos_;; ++pos_) {
+ switch (peek()) {
+ case '\0': // i.e., EOF
+ case '\x09':
+ case '\x0A':
+ case '\x0D':
+ case ' ':
+ case '/':
+ case '=':
+ case '>':
+ return pos_ != begin;
+ case ':':
+ *nameColon = pos_;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+XmlReader::Namespace XmlReader::scanNamespaceIri(
+ char const * begin, char const * end)
+{
+ OSL_ASSERT(begin != 0 && begin <= end);
+ Span iri(handleAttributeValue(begin, end, false));
+ struct Iri {
+ char const * begin;
+ sal_Int32 length;
+ XmlReader::Namespace ns;
+ };
+ static Iri const iris[] = {
+ { RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry"),
+ XmlReader::NAMESPACE_OOR },
+ { RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema"),
+ XmlReader::NAMESPACE_XS },
+ { RTL_CONSTASCII_STRINGPARAM(
+ "http://www.w3.org/2001/XMLSchema-instance"),
+ XmlReader::NAMESPACE_XSI },
+ { RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/XML/1998/namespace"),
+ XmlReader::NAMESPACE_XML } };
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS( iris ); ++i) {
+ if (rtl_str_compare_WithLength(
+ iri.begin, iri.length, iris[i].begin, iris[i].length) ==
+ 0)
+ {
+ return iris[i].ns;
+ }
+ }
+ return XmlReader::NAMESPACE_OTHER;
+}
+
+char const * XmlReader::handleReference(char const * position, char const * end)
+{
+ OSL_ASSERT(position != 0 && *position == '&' && position < end);
+ ++position;
+ if (*position == '#') {
+ ++position;
+ sal_Int32 val = 0;
+ char const * p;
+ if (*position == 'x') {
+ ++position;
+ p = position;
+ for (;; ++position) {
+ char c = *position;
+ if (c >= '0' && c <= '9') {
+ val = 16 * val + (c - '0');
+ } else if (c >= 'A' && c <= 'F') {
+ val = 16 * val + (c - 'A') + 10;
+ } else if (c >= 'a' && c <= 'f') {
+ val = 16 * val + (c - 'a') + 10;
+ } else {
+ break;
+ }
+ if (val > 0x10FFFF) { // avoid overflow
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "'&#x...' too large in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ }
+ } else {
+ p = position;
+ for (;; ++position) {
+ char c = *position;
+ if (c >= '0' && c <= '9') {
+ val = 10 * val + (c - '0');
+ } else {
+ break;
+ }
+ if (val > 0x10FFFF) { // avoid overflow
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "'&#...' too large in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ }
+ }
+ if (position == p || *position++ != ';') {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("'&#...' missing ';' in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ OSL_ASSERT(val >= 0 && val <= 0x10FFFF);
+ if ((val < 0x20 && val != 0x9 && val != 0xA && val != 0xD) ||
+ (val >= 0xD800 && val <= 0xDFFF) || val == 0xFFFE || val == 0xFFFF)
+ {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "character reference denoting invalid character in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ char buf[4];
+ sal_Int32 len;
+ if (val < 0x80) {
+ buf[0] = static_cast< char >(val);
+ len = 1;
+ } else if (val < 0x800) {
+ buf[0] = static_cast< char >((val >> 6) | 0xC0);
+ buf[1] = static_cast< char >((val & 0x3F) | 0x80);
+ len = 2;
+ } else if (val < 0x10000) {
+ buf[0] = static_cast< char >((val >> 12) | 0xE0);
+ buf[1] = static_cast< char >(((val >> 6) & 0x3F) | 0x80);
+ buf[2] = static_cast< char >((val & 0x3F) | 0x80);
+ len = 3;
+ } else {
+ buf[0] = static_cast< char >((val >> 18) | 0xF0);
+ buf[1] = static_cast< char >(((val >> 12) & 0x3F) | 0x80);
+ buf[2] = static_cast< char >(((val >> 6) & 0x3F) | 0x80);
+ buf[3] = static_cast< char >((val & 0x3F) | 0x80);
+ len = 4;
+ }
+ pad_.addEphemeral(buf, len);
+ return position;
+ } else {
+ struct EntityRef {
+ char const * inBegin;
+ sal_Int32 inLength;
+ char const * outBegin;
+ sal_Int32 outLength;
+ };
+ static EntityRef const refs[] = {
+ { RTL_CONSTASCII_STRINGPARAM("amp;"),
+ RTL_CONSTASCII_STRINGPARAM("&") },
+ { RTL_CONSTASCII_STRINGPARAM("lt;"),
+ RTL_CONSTASCII_STRINGPARAM("<") },
+ { RTL_CONSTASCII_STRINGPARAM("gt;"),
+ RTL_CONSTASCII_STRINGPARAM(">") },
+ { RTL_CONSTASCII_STRINGPARAM("apos;"),
+ RTL_CONSTASCII_STRINGPARAM("'") },
+ { RTL_CONSTASCII_STRINGPARAM("quot;"),
+ RTL_CONSTASCII_STRINGPARAM("\"") } };
+ for (std::size_t i = 0; i < SAL_N_ELEMENTS( refs ); ++i) {
+ if (rtl_str_shortenedCompare_WithLength(
+ position, end - position, refs[i].inBegin, refs[i].inLength,
+ refs[i].inLength) ==
+ 0)
+ {
+ position += refs[i].inLength;
+ pad_.add(refs[i].outBegin, refs[i].outLength);
+ return position;
+ }
+ }
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("unknown entity reference in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+}
+
+Span XmlReader::handleAttributeValue(
+ char const * begin, char const * end, bool fullyNormalize)
+{
+ pad_.clear();
+ if (fullyNormalize) {
+ while (begin != end && isSpace(*begin)) {
+ ++begin;
+ }
+ while (end != begin && isSpace(end[-1])) {
+ --end;
+ }
+ char const * p = begin;
+ enum Space { SPACE_NONE, SPACE_SPAN, SPACE_BREAK };
+ // a single true space character can go into the current span,
+ // everything else breaks the span
+ Space space = SPACE_NONE;
+ while (p != end) {
+ switch (*p) {
+ case '\x09':
+ case '\x0A':
+ case '\x0D':
+ switch (space) {
+ case SPACE_NONE:
+ pad_.add(begin, p - begin);
+ pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
+ space = SPACE_BREAK;
+ break;
+ case SPACE_SPAN:
+ pad_.add(begin, p - begin);
+ space = SPACE_BREAK;
+ break;
+ case SPACE_BREAK:
+ break;
+ }
+ begin = ++p;
+ break;
+ case ' ':
+ switch (space) {
+ case SPACE_NONE:
+ ++p;
+ space = SPACE_SPAN;
+ break;
+ case SPACE_SPAN:
+ pad_.add(begin, p - begin);
+ begin = ++p;
+ space = SPACE_BREAK;
+ break;
+ case SPACE_BREAK:
+ begin = ++p;
+ break;
+ }
+ break;
+ case '&':
+ pad_.add(begin, p - begin);
+ p = handleReference(p, end);
+ begin = p;
+ space = SPACE_NONE;
+ break;
+ default:
+ ++p;
+ space = SPACE_NONE;
+ break;
+ }
+ }
+ pad_.add(begin, p - begin);
+ } else {
+ char const * p = begin;
+ while (p != end) {
+ switch (*p) {
+ case '\x09':
+ case '\x0A':
+ pad_.add(begin, p - begin);
+ begin = ++p;
+ pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
+ break;
+ case '\x0D':
+ pad_.add(begin, p - begin);
+ ++p;
+ if (peek() == '\x0A') {
+ ++p;
+ }
+ begin = p;
+ pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
+ break;
+ case '&':
+ pad_.add(begin, p - begin);
+ p = handleReference(p, end);
+ begin = p;
+ break;
+ default:
+ ++p;
+ break;
+ }
+ }
+ pad_.add(begin, p - begin);
+ }
+ return pad_.get();
+}
+
+XmlReader::Result XmlReader::handleStartTag(Namespace * ns, Span * localName) {
+ OSL_ASSERT(ns != 0 && localName);
+ char const * nameBegin = pos_;
+ char const * nameColon = 0;
+ if (!scanName(&nameColon)) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad tag name in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ char const * nameEnd = pos_;
+ NamespaceList::size_type inheritedNamespaces = namespaces_.size();
+ bool hasDefaultNs = false;
+ Namespace defaultNs = NAMESPACE_NONE;
+ attributes_.clear();
+ for (;;) {
+ char const * p = pos_;
+ skipSpace();
+ if (peek() == '/' || peek() == '>') {
+ break;
+ }
+ if (pos_ == p) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "missing whitespace before attribute in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ char const * attrNameBegin = pos_;
+ char const * attrNameColon = 0;
+ if (!scanName(&attrNameColon)) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("bad attribute name in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ char const * attrNameEnd = pos_;
+ skipSpace();
+ if (read() != '=') {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '=' in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ skipSpace();
+ char del = read();
+ if (del != '\'' && del != '"') {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("bad attribute value in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ char const * valueBegin = pos_;
+ sal_Int32 i = rtl_str_indexOfChar_WithLength(pos_, end_ - pos_, del);
+ if (i < 0) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "unterminated attribute value in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ char const * valueEnd = pos_ + i;
+ pos_ += i + 1;
+ if (attrNameColon == 0 &&
+ Span(attrNameBegin, attrNameEnd - attrNameBegin).equals(
+ RTL_CONSTASCII_STRINGPARAM("xmlns")))
+ {
+ hasDefaultNs = true;
+ defaultNs = scanNamespaceIri(valueBegin, valueEnd);
+ } else if (attrNameColon != 0 &&
+ Span(attrNameBegin, attrNameColon - attrNameBegin).equals(
+ RTL_CONSTASCII_STRINGPARAM("xmlns")))
+ {
+ namespaces_.push_back(
+ NamespaceData(
+ Span(attrNameColon + 1, attrNameEnd - (attrNameColon + 1)),
+ scanNamespaceIri(valueBegin, valueEnd)));
+ } else {
+ attributes_.push_back(
+ AttributeData(
+ attrNameBegin, attrNameEnd, attrNameColon, valueBegin,
+ valueEnd));
+ }
+ }
+ if (!hasDefaultNs && !elements_.empty()) {
+ defaultNs = elements_.top().defaultNamespace;
+ }
+ firstAttribute_ = true;
+ if (peek() == '/') {
+ state_ = STATE_EMPTY_ELEMENT_TAG;
+ ++pos_;
+ } else {
+ state_ = STATE_CONTENT;
+ }
+ if (peek() != '>') {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '>' in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ ++pos_;
+ elements_.push(
+ ElementData(
+ Span(nameBegin, nameEnd - nameBegin), inheritedNamespaces,
+ defaultNs));
+ if (nameColon == 0) {
+ *ns = defaultNs;
+ *localName = Span(nameBegin, nameEnd - nameBegin);
+ } else {
+ *ns = getNamespace(Span(nameBegin, nameColon - nameBegin));
+ *localName = Span(nameColon + 1, nameEnd - (nameColon + 1));
+ }
+ return RESULT_BEGIN;
+}
+
+XmlReader::Result XmlReader::handleEndTag() {
+ if (elements_.empty()) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("spurious end tag in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ char const * nameBegin = pos_;
+ char const * nameColon = 0;
+ if (!scanName(&nameColon) ||
+ !elements_.top().name.equals(nameBegin, pos_ - nameBegin))
+ {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("tag mismatch in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ handleElementEnd();
+ skipSpace();
+ if (peek() != '>') {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '>' in ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ ++pos_;
+ return RESULT_END;
+}
+
+void XmlReader::handleElementEnd() {
+ OSL_ASSERT(!elements_.empty());
+ namespaces_.resize(elements_.top().inheritedNamespaces);
+ elements_.pop();
+ state_ = elements_.empty() ? STATE_DONE : STATE_CONTENT;
+}
+
+XmlReader::Result XmlReader::handleSkippedText(Span * data, Namespace * ns) {
+ for (;;) {
+ sal_Int32 i = rtl_str_indexOfChar_WithLength(pos_, end_ - pos_, '<');
+ if (i < 0) {
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("premature end of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ }
+ pos_ += i + 1;
+ switch (peek()) {
+ case '!':
+ ++pos_;
+ if (!skipComment() && !scanCdataSection().is()) {
+ skipDocumentTypeDeclaration();
+ }
+ break;
+ case '/':
+ ++pos_;
+ return handleEndTag();
+ case '?':
+ ++pos_;
+ skipProcessingInstruction();
+ break;
+ default:
+ return handleStartTag(ns, data);
+ }
+ }
+}
+
+XmlReader::Result XmlReader::handleRawText(Span * text) {
+ pad_.clear();
+ for (char const * begin = pos_;;) {
+ switch (peek()) {
+ case '\0': // i.e., EOF
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("premature end of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ case '\x0D':
+ pad_.add(begin, pos_ - begin);
+ ++pos_;
+ if (peek() != '\x0A') {
+ pad_.add(RTL_CONSTASCII_STRINGPARAM("\x0A"));
+ }
+ begin = pos_;
+ break;
+ case '&':
+ pad_.add(begin, pos_ - begin);
+ pos_ = handleReference(pos_, end_);
+ begin = pos_;
+ break;
+ case '<':
+ pad_.add(begin, pos_ - begin);
+ ++pos_;
+ switch (peek()) {
+ case '!':
+ ++pos_;
+ if (!skipComment()) {
+ Span cdata(scanCdataSection());
+ if (cdata.is()) {
+ normalizeLineEnds(cdata);
+ } else {
+ skipDocumentTypeDeclaration();
+ }
+ }
+ begin = pos_;
+ break;
+ case '/':
+ *text = pad_.get();
+ ++pos_;
+ state_ = STATE_END_TAG;
+ return RESULT_TEXT;
+ case '?':
+ ++pos_;
+ skipProcessingInstruction();
+ begin = pos_;
+ break;
+ default:
+ *text = pad_.get();
+ state_ = STATE_START_TAG;
+ return RESULT_TEXT;
+ }
+ break;
+ default:
+ ++pos_;
+ break;
+ }
+ }
+}
+
+XmlReader::Result XmlReader::handleNormalizedText(Span * text) {
+ pad_.clear();
+ char const * flowBegin = pos_;
+ char const * flowEnd = pos_;
+ enum Space { SPACE_START, SPACE_NONE, SPACE_SPAN, SPACE_BREAK };
+ // a single true space character can go into the current flow,
+ // everything else breaks the flow
+ Space space = SPACE_START;
+ for (;;) {
+ switch (peek()) {
+ case '\0': // i.e., EOF
+ throw css::uno::RuntimeException(
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("premature end of ")) +
+ fileUrl_),
+ css::uno::Reference< css::uno::XInterface >());
+ case '\x09':
+ case '\x0A':
+ case '\x0D':
+ switch (space) {
+ case SPACE_START:
+ case SPACE_BREAK:
+ break;
+ case SPACE_NONE:
+ case SPACE_SPAN:
+ space = SPACE_BREAK;
+ break;
+ }
+ ++pos_;
+ break;
+ case ' ':
+ switch (space) {
+ case SPACE_START:
+ case SPACE_BREAK:
+ break;
+ case SPACE_NONE:
+ space = SPACE_SPAN;
+ break;
+ case SPACE_SPAN:
+ space = SPACE_BREAK;
+ break;
+ }
+ ++pos_;
+ break;
+ case '&':
+ switch (space) {
+ case SPACE_START:
+ break;
+ case SPACE_NONE:
+ case SPACE_SPAN:
+ pad_.add(flowBegin, pos_ - flowBegin);
+ break;
+ case SPACE_BREAK:
+ pad_.add(flowBegin, flowEnd - flowBegin);
+ pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
+ break;
+ }
+ pos_ = handleReference(pos_, end_);
+ flowBegin = pos_;
+ flowEnd = pos_;
+ space = SPACE_NONE;
+ break;
+ case '<':
+ ++pos_;
+ switch (peek()) {
+ case '!':
+ ++pos_;
+ if (skipComment()) {
+ space = SPACE_BREAK;
+ } else {
+ Span cdata(scanCdataSection());
+ if (cdata.is()) {
+ // CDATA is not normalized (similar to character
+ // references; it keeps the code simple), but it might
+ // arguably be better to normalize it:
+ switch (space) {
+ case SPACE_START:
+ break;
+ case SPACE_NONE:
+ case SPACE_SPAN:
+ pad_.add(flowBegin, pos_ - flowBegin);
+ break;
+ case SPACE_BREAK:
+ pad_.add(flowBegin, flowEnd - flowBegin);
+ pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
+ break;
+ }
+ normalizeLineEnds(cdata);
+ flowBegin = pos_;
+ flowEnd = pos_;
+ space = SPACE_NONE;
+ } else {
+ skipDocumentTypeDeclaration();
+ }
+ }
+ break;
+ case '/':
+ ++pos_;
+ pad_.add(flowBegin, flowEnd - flowBegin);
+ *text = pad_.get();
+ state_ = STATE_END_TAG;
+ return RESULT_TEXT;
+ case '?':
+ ++pos_;
+ skipProcessingInstruction();
+ space = SPACE_BREAK;
+ break;
+ default:
+ pad_.add(flowBegin, flowEnd - flowBegin);
+ *text = pad_.get();
+ state_ = STATE_START_TAG;
+ return RESULT_TEXT;
+ }
+ break;
+ default:
+ switch (space) {
+ case SPACE_START:
+ flowBegin = pos_;
+ break;
+ case SPACE_NONE:
+ case SPACE_SPAN:
+ break;
+ case SPACE_BREAK:
+ pad_.add(flowBegin, flowEnd - flowBegin);
+ pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
+ flowBegin = pos_;
+ break;
+ }
+ flowEnd = ++pos_;
+ space = SPACE_NONE;
+ break;
+ }
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configmgr/source/xmlreader.hxx b/configmgr/source/xmlreader.hxx
new file mode 100755
index 000000000000..c5436fea81f7
--- /dev/null
+++ b/configmgr/source/xmlreader.hxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+* 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 INCLUDED_CONFIGMGR_SOURCE_XMLREADER_HXX
+#define INCLUDED_CONFIGMGR_SOURCE_XMLREADER_HXX
+
+#include "sal/config.h"
+
+#include <stack>
+#include <vector>
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/container/NoSuchElementException.hpp"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "osl/file.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+#include "pad.hxx"
+#include "span.hxx"
+
+namespace configmgr {
+
+class XmlReader: private boost::noncopyable {
+public:
+ explicit XmlReader(rtl::OUString const & fileUrl)
+ SAL_THROW((
+ com::sun::star::container::NoSuchElementException,
+ com::sun::star::uno::RuntimeException));
+
+ ~XmlReader();
+
+ enum Namespace {
+ NAMESPACE_NONE, NAMESPACE_XML, NAMESPACE_OOR, NAMESPACE_XS,
+ NAMESPACE_XSI, NAMESPACE_OTHER };
+
+ enum Text { TEXT_NONE, TEXT_RAW, TEXT_NORMALIZED };
+
+ enum Result { RESULT_BEGIN, RESULT_END, RESULT_TEXT, RESULT_DONE };
+
+ // RESULT_BEGIN: data = localName, ns = ns
+ // RESULT_END: data, ns unused
+ // RESULT_TEXT: data = text, ns unused
+ Result nextItem(Text reportText, Span * data, Namespace * ns);
+
+ bool nextAttribute(Namespace * ns, Span * localName);
+
+ // the span returned by getAttributeValue is only valid until the next call
+ // to nextItem or getAttributeValue
+ Span getAttributeValue(bool fullyNormalize);
+
+ Namespace getNamespace(Span const & prefix) const;
+
+ rtl::OUString getUrl() const;
+
+private:
+ inline char read() { return pos_ == end_ ? '\0' : *pos_++; }
+ inline char peek() { return pos_ == end_ ? '\0' : *pos_; }
+
+ void normalizeLineEnds(Span const & text);
+
+ void skipSpace();
+ bool skipComment();
+ void skipProcessingInstruction();
+ void skipDocumentTypeDeclaration();
+
+ Span scanCdataSection();
+
+ bool scanName(char const ** nameColon);
+
+ Namespace scanNamespaceIri(char const * begin, char const * end);
+
+ char const * handleReference(char const * position, char const * end);
+
+ Span handleAttributeValue(
+ char const * begin, char const * end, bool fullyNormalize);
+
+ Result handleStartTag(Namespace * ns, Span * localName);
+ Result handleEndTag();
+
+ void handleElementEnd();
+
+ Result handleSkippedText(Span * data, Namespace * ns);
+ Result handleRawText(Span * text);
+ Result handleNormalizedText(Span * text);
+
+ struct NamespaceData {
+ Span prefix;
+ Namespace ns;
+
+ NamespaceData() {}
+
+ NamespaceData(Span const & thePrefix, Namespace theNs):
+ prefix(thePrefix), ns(theNs) {}
+ };
+
+ typedef std::vector< NamespaceData > NamespaceList;
+
+ struct ElementData {
+ Span name;
+ NamespaceList::size_type inheritedNamespaces;
+ Namespace defaultNamespace;
+
+ ElementData(
+ Span const & theName,
+ NamespaceList::size_type theInheritedNamespaces,
+ Namespace theDefaultNamespace):
+ name(theName), inheritedNamespaces(theInheritedNamespaces),
+ defaultNamespace(theDefaultNamespace)
+ {}
+ };
+
+ typedef std::stack< ElementData > ElementStack;
+
+ struct AttributeData {
+ char const * nameBegin;
+ char const * nameEnd;
+ char const * nameColon;
+ char const * valueBegin;
+ char const * valueEnd;
+
+ AttributeData(
+ char const * theNameBegin, char const * theNameEnd,
+ char const * theNameColon, char const * theValueBegin,
+ char const * theValueEnd):
+ nameBegin(theNameBegin), nameEnd(theNameEnd),
+ nameColon(theNameColon), valueBegin(theValueBegin),
+ valueEnd(theValueEnd)
+ {}
+ };
+
+ typedef std::vector< AttributeData > Attributes;
+
+ enum State {
+ STATE_CONTENT, STATE_START_TAG, STATE_END_TAG, STATE_EMPTY_ELEMENT_TAG,
+ STATE_DONE };
+
+ rtl::OUString fileUrl_;
+ oslFileHandle fileHandle_;
+ sal_uInt64 fileSize_;
+ void * fileAddress_;
+ NamespaceList namespaces_;
+ ElementStack elements_;
+ char const * pos_;
+ char const * end_;
+ State state_;
+ Attributes attributes_;
+ Attributes::iterator currentAttribute_;
+ bool firstAttribute_;
+ Pad pad_;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */