summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorCyrille Moureaux <cyrillem@openoffice.org>2002-07-19 17:21:07 +0000
committerCyrille Moureaux <cyrillem@openoffice.org>2002-07-19 17:21:07 +0000
commit2eea65657def305f86ecaf8a8a64880f777c7869 (patch)
treea511117ec5b13ad100455cf652210d537c2f5e26 /configmgr
parent5add1dca0e5db2edf12e97569d6a2c372994fff1 (diff)
#98489# Handling of replaced properties, empty strings in void string properties
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/xml/layerparser.cxx60
-rw-r--r--configmgr/source/xml/layerparser.hxx15
2 files changed, 57 insertions, 18 deletions
diff --git a/configmgr/source/xml/layerparser.cxx b/configmgr/source/xml/layerparser.cxx
index 8036da43801b..6b2ed602c16e 100644
--- a/configmgr/source/xml/layerparser.cxx
+++ b/configmgr/source/xml/layerparser.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: layerparser.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2002-07-14 16:49:50 $
+ * last change: $Author: cyrillem $ $Date: 2002-07-19 18:21:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -123,7 +123,6 @@ void SAL_CALL LayerParser::startElement( const OUString& aName, const uno::Refer
this->startSkipping( aName, xAttribs );
return;
}
-
ElementInfo aInfo = getDataParser().parseElementInfo(aName,xAttribs);
switch (aInfo.type)
@@ -171,9 +170,9 @@ void SAL_CALL LayerParser::endElement( const OUString& aName )
else if (this->isInNode())
this->endNode();
- else
+ else {
this->raiseParseException("Layer parser: Invalid XML: endElement without matching startElement");
-
+ }
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
@@ -254,6 +253,35 @@ void LayerParser::startProperty( ElementInfo const & aInfo, const uno::Reference
}
// -----------------------------------------------------------------------------
+void LayerParser::addOrReplaceCurrentProperty(const uno::Any& aValue) {
+ const ElementInfo& currentInfo = getActiveNodeInfo() ;
+
+ OSL_ASSERT(currentInfo.op == Operation::replace) ;
+ try {
+ if (aValue.hasValue()) {
+ m_xHandler->addPropertyWithValue(currentInfo.name,
+ currentInfo.flags, aValue) ;
+ }
+ else {
+ m_xHandler->addProperty(currentInfo.name, currentInfo.flags,
+ getActivePropertyType()) ;
+ }
+ }
+ catch (com::sun::star::beans::PropertyExistException& exception) {
+ // If we're here, someone is trying to do a replace
+ // on an existing property. Now that doesn't make
+ // a lot of sense to be honest, but since that amounts
+ // to a modify anyway, let's humor that someone.
+ // Print a warning anyway.
+ OSL_ENSURE(false, "Found a replace operation on an existing property, use modify instead") ;
+ m_xHandler->overrideProperty(currentInfo.name, currentInfo.flags,
+ getActivePropertyType()) ;
+ // The value cannot be localised, this would have been trapped earlier
+ m_xHandler->setPropertyValue(aValue) ;
+ }
+}
+// -----------------------------------------------------------------------------
+
void LayerParser::endProperty()
{
OSL_ASSERT(!this->isInRemoved());
@@ -262,10 +290,13 @@ void LayerParser::endProperty()
{
if (this->isInUnhandledProperty())
{
- ElementInfo const & aInfo = getActiveNodeInfo();
- OSL_ASSERT(aInfo.op == Operation::replace);
+ uno::Any value ;
- m_xHandler->addProperty(aInfo.name,aInfo.flags,getActivePropertyType());
+ if (getActivePropertyType() == getCppuType(
+ static_cast<rtl::OUString *>(NULL))){
+ value <<= rtl::OUString() ;
+ }
+ addOrReplaceCurrentProperty(value) ;
}
m_bNewProp = false;
}
@@ -291,18 +322,15 @@ void LayerParser::endValueData()
{
uno::Any aValue = this->getCurrentValue();
+ if (!aValue.hasValue() && getActivePropertyType() == getCppuType(
+ static_cast<rtl::OUString *>(NULL))) {
+ aValue <<= rtl::OUString() ;
+ }
if (m_bNewProp)
{
OSL_ENSURE(!isValueDataLocalized(),"Layer parser: Invalid Data: 'lang' ignored for newly added property.");
- ElementInfo const & aInfo = this->getActiveNodeInfo();
-
- OSL_ASSERT( aInfo.op == Operation::replace );
-
- if (aValue.hasValue())
- m_xHandler->addPropertyWithValue(aInfo.name,aInfo.flags,aValue);
- else
- m_xHandler->addProperty(aInfo.name,aInfo.flags,getActivePropertyType());
+ addOrReplaceCurrentProperty(aValue) ;
}
else if (this->isValueDataLocalized())
{
diff --git a/configmgr/source/xml/layerparser.hxx b/configmgr/source/xml/layerparser.hxx
index 4d435ce99378..4c4ef50148c3 100644
--- a/configmgr/source/xml/layerparser.hxx
+++ b/configmgr/source/xml/layerparser.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: layerparser.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2002-05-16 11:00:29 $
+ * last change: $Author: cyrillem $ $Date: 2002-07-19 18:21:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -125,6 +125,17 @@ namespace configmgr
/// end collecting data for a value - returns the collected value
void endValueData();
+ /**
+ Forces the addition or replacement of a property.
+ As it is possible to "replace" an existing property,
+ even though this amounts to a modify, this method
+ first tries to add a new property and failing that,
+ to replace the value of an existing one.
+
+ @param aValue value to be set for the property
+ */
+ void addOrReplaceCurrentProperty(const uno::Any& aValue) ;
+
bool isInRemoved() const { return m_bRemoved; }
void checkNotRemoved();
private: