This is an automated email from the ASF dual-hosted git repository.

ardovm pushed a commit to branch AOO41X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit e7e4a7599a84142ba8748550cf6a39cbb0dd1e6f
Author: Arrigo Marchiori <[email protected]>
AuthorDate: Mon Jan 27 22:54:29 2025 +0100

    Revert "wiped" nodes and avoid saving history elements
    
    Avoid recording "removed" elements with certain paths, corresponding to
    histories.
    
    The KIND_WIPED nodes were a bad idea as they just created confusion.
    Configuration element must be removed, not replaced.
    
    (cherry picked from commit 13d3b75c6cfbda2f6f8a5dcdb6d9810a02f1492f)
---
 main/configmgr/source/access.cxx       | 24 +--------
 main/configmgr/source/makefile.mk      |  1 -
 main/configmgr/source/node.hxx         | 13 ++---
 main/configmgr/source/wipednode.cxx    | 64 ------------------------
 main/configmgr/source/wipednode.hxx    | 62 -----------------------
 main/configmgr/source/writemodfile.cxx | 89 ++++++++++++++++++----------------
 6 files changed, 51 insertions(+), 202 deletions(-)

diff --git a/main/configmgr/source/access.cxx b/main/configmgr/source/access.cxx
index b06c0d12ae..f7ec65c897 100644
--- a/main/configmgr/source/access.cxx
+++ b/main/configmgr/source/access.cxx
@@ -101,7 +101,6 @@
 #include "propertynode.hxx"
 #include "rootaccess.hxx"
 #include "setnode.hxx"
-#include "wipednode.hxx"
 #include "type.hxx"
 
 namespace configmgr {
@@ -481,7 +480,7 @@ void Access::initBroadcasterAndChanges(
          i != modifications.children.end(); ++i)
     {
         rtl::Reference< ChildAccess > child(getChild(i->first));
-        if (child.is() && (child->getNode()->kind() != Node::KIND_WIPED)) {
+        if (child.is()) {
             switch (child->getNode()->kind()) {
             case Node::KIND_LOCALIZED_PROPERTY:
                 if (!i->second.children.empty()) {
@@ -678,8 +677,6 @@ void Access::initBroadcasterAndChanges(
                         // listeners
                 }
                 break;
-            case Node::KIND_WIPED:
-                break; // Excluded above
             }
         } else {
             switch (getNode()->kind()) {
@@ -1909,29 +1906,12 @@ void Access::removeByName(rtl::OUString const & aName)
                     aName, static_cast< cppu::OWeakObject * >(this));
             }
         }
-        // Elements of file/URL histories must not be marked as
-        // "removed": they must disappear
-        bool mustWipe = false;
-        ::rtl::Reference< Access > parent = getParentAccess();
-        if (parent.is()) {
-            const ::rtl::OUString parentName = parent->getName();
-            mustWipe =
-                ((parentName == ::rtl::OUString::createFromAscii("PickList")) 
||
-                 (parentName == 
::rtl::OUString::createFromAscii("URLHistory"))) &&
-                (getName() == ::rtl::OUString::createFromAscii("ItemList"));
-        }
         Modifications localMods;
         localMods.add(child->getRelativePath());
         // unbind() modifies the parent chain that markChildAsModified() walks,
         // so order is important:
         markChildAsModified(child); //TODO: must not throw
-        if (!mustWipe) {
-            // This will mark the element as "removed"
-            child->unbind();
-        } else {
-            // The element will disappear
-            child->setNode(new WipedNode(child->getNode()->getLayer()));
-        }
+        child->unbind();
         getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
     }
     bc.send();
diff --git a/main/configmgr/source/makefile.mk 
b/main/configmgr/source/makefile.mk
index 7ebadd69e0..ca118eb3e8 100644
--- a/main/configmgr/source/makefile.mk
+++ b/main/configmgr/source/makefile.mk
@@ -57,7 +57,6 @@ SLOFILES = \
     $(SLO)/type.obj \
     $(SLO)/update.obj \
     $(SLO)/valueparser.obj \
-    $(SLO)/wipednode.obj \
     $(SLO)/writemodfile.obj \
     $(SLO)/xcdparser.obj \
     $(SLO)/xcsparser.obj \
diff --git a/main/configmgr/source/node.hxx b/main/configmgr/source/node.hxx
index 5a03d15f78..8f442c5033 100644
--- a/main/configmgr/source/node.hxx
+++ b/main/configmgr/source/node.hxx
@@ -61,24 +61,17 @@ public:
          * Identifies instances of LocalizedValueNode.
          */
         KIND_LOCALIZED_VALUE,
-        /** Group node (&lt;node&gt; element)
+        /** Group member node (&lt;node&gt; element)
          *
          * Identifies instances of GroupNode.
          */
         KIND_GROUP,
-        /** Set node (&lt;node&gt; element)
+        /** Set member node (&lt;node&gt; element)
          *
          * Identifies instances of SetNode.
          */
         KIND_SET,
-        /** Node to be deleted.
-         *
-         * This type of element is not present in the OOR. It is used as a
-         * placeholder for a node that is about to disappear.
-         *
-         * Identifies instances of WipedNode.
-         */
-        KIND_WIPED };
+    };
 
     virtual Kind kind() const = 0;
 
diff --git a/main/configmgr/source/wipednode.cxx 
b/main/configmgr/source/wipednode.cxx
deleted file mode 100644
index 87c992f457..0000000000
--- a/main/configmgr/source/wipednode.cxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-#include "precompiled_configmgr.hxx"
-#include "sal/config.h"
-
-#include "com/sun/star/beans/Optional.hpp"
-#include "com/sun/star/uno/Any.hxx"
-#include "osl/diagnose.h"
-#include "rtl/ref.hxx"
-#include "rtl/ustring.h"
-#include "rtl/ustring.hxx"
-
-#include "components.hxx"
-#include "node.hxx"
-#include "wipednode.hxx"
-
-namespace configmgr {
-
-namespace {
-
-namespace css = com::sun::star;
-
-}
-
-WipedNode::WipedNode(int layer):
-    Node(layer)
-{}
-
-rtl::Reference< Node > WipedNode::clone(bool) const {
-    return new WipedNode(*this);
-}
-
-WipedNode::WipedNode(WipedNode const & other):
-    Node(other)
-{}
-
-WipedNode::~WipedNode() {}
-
-Node::Kind WipedNode::kind() const {
-    return KIND_WIPED;
-}
-
-}
diff --git a/main/configmgr/source/wipednode.hxx 
b/main/configmgr/source/wipednode.hxx
deleted file mode 100644
index 9386aec165..0000000000
--- a/main/configmgr/source/wipednode.hxx
+++ /dev/null
@@ -1,62 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-#ifndef INCLUDED_CONFIGMGR_SOURCE_WIPEDNODE_HXX
-#define INCLUDED_CONFIGMGR_SOURCE_WIPEDNODE_HXX
-
-#include "sal/config.h"
-
-#include "rtl/ref.hxx"
-
-#include "node.hxx"
-
-namespace rtl { class OUString; }
-
-namespace configmgr {
-
-class Components;
-
-/**
- * A configuration element that is going to disappear.
- *
- * These objects are a placeholder for elements that are pending removal
- * and must completely disappear from the configuration registry.
- */
-class WipedNode: public Node {
-public:
-    WipedNode(int layer);
-
-    virtual rtl::Reference< Node > clone(bool keepTemplateName) const;
-
-private:
-    WipedNode(WipedNode const & other);
-
-    virtual ~WipedNode();
-
-    virtual Kind kind() const;
-
-};
-
-}
-
-#endif
diff --git a/main/configmgr/source/writemodfile.cxx 
b/main/configmgr/source/writemodfile.cxx
index 7bd8c64359..b2b4387e49 100644
--- a/main/configmgr/source/writemodfile.cxx
+++ b/main/configmgr/source/writemodfile.cxx
@@ -443,8 +443,6 @@ void writeNode(
         }
         writeData(handle, RTL_CONSTASCII_STRINGPARAM("</node>"));
         break;
-    case Node::KIND_WIPED:
-        break; // Nothing to write
     }
 }
 
@@ -455,55 +453,60 @@ void writeModifications(
     rtl::Reference< Node > const & node,
     Modifications::Node const & modifications)
 {
+    /** Parent paths whose children should disappear */
+    const char *historyPath = "/org.openoffice.Office.Histories/Histories";
+    const char *commonHistoryPath = "/org.openoffice.Office.Common/History";
     // It is never necessary to write oor:finalized or oor:mandatory 
attributes,
     // as they cannot be set via the UNO API.
     if (modifications.children.empty()) {
         OSL_ASSERT(parent.is());
-            // components themselves have no parent but must have children
-        writeData(handle, RTL_CONSTASCII_STRINGPARAM("<item oor:path=\""));
-        writeAttributeValue(handle, parentPathRepresentation);
-        writeData(handle, RTL_CONSTASCII_STRINGPARAM("\">"));
-        if (node.is()) {
-            writeNode(components, handle, parent, nodeName, node);
-        } else {
-            switch (parent->kind()) {
-            case Node::KIND_LOCALIZED_PROPERTY:
-                writeData(handle, RTL_CONSTASCII_STRINGPARAM("<value"));
-                if (nodeName.getLength() != 0) {
+        // components themselves have no parent but must have children
+        if (node.is() ||
+            ((parentPathRepresentation.compareToAscii(historyPath, 
strlen(historyPath)) != 0) &&
+             (parentPathRepresentation.compareToAscii(commonHistoryPath, 
strlen(commonHistoryPath)) != 0))) {
+            writeData(handle, RTL_CONSTASCII_STRINGPARAM("<item oor:path=\""));
+            writeAttributeValue(handle, parentPathRepresentation);
+            writeData(handle, RTL_CONSTASCII_STRINGPARAM("\">"));
+            if (node.is()) {
+                writeNode(components, handle, parent, nodeName, node);
+            } else {
+                switch (parent->kind()) {
+                               case Node::KIND_LOCALIZED_PROPERTY:
+                    writeData(handle, RTL_CONSTASCII_STRINGPARAM("<value"));
+                    if (nodeName.getLength() != 0) {
+                        writeData(
+                            handle, RTL_CONSTASCII_STRINGPARAM(" 
xml:lang=\""));
+                        writeAttributeValue(handle, nodeName);
+                        writeData(handle, RTL_CONSTASCII_STRINGPARAM("\""));
+                    }
                     writeData(
-                        handle, RTL_CONSTASCII_STRINGPARAM(" xml:lang=\""));
+                        handle, RTL_CONSTASCII_STRINGPARAM(" 
oor:op=\"remove\"/>"));
+                    break;
+                case Node::KIND_GROUP:
+                    OSL_ASSERT(
+                               dynamic_cast< GroupNode * 
>(parent.get())->isExtensible());
+                    writeData(
+                        handle, RTL_CONSTASCII_STRINGPARAM("<prop 
oor:name=\""));
                     writeAttributeValue(handle, nodeName);
-                    writeData(handle, RTL_CONSTASCII_STRINGPARAM("\""));
+                    writeData(
+                        handle,
+                        RTL_CONSTASCII_STRINGPARAM("\" oor:op=\"remove\"/>"));
+                    break;
+                case Node::KIND_SET:
+                    writeData(
+                        handle, RTL_CONSTASCII_STRINGPARAM("<node 
oor:name=\""));
+                    writeAttributeValue(handle, nodeName);
+                    writeData(
+                        handle,
+                        RTL_CONSTASCII_STRINGPARAM("\" oor:op=\"remove\"/>"));
+                    break;
+                default:
+                    OSL_ASSERT(false); // this cannot happen
+                    break;
                 }
-                writeData(
-                    handle, RTL_CONSTASCII_STRINGPARAM(" 
oor:op=\"remove\"/>"));
-                break;
-            case Node::KIND_GROUP:
-                OSL_ASSERT(
-                    dynamic_cast< GroupNode * >(parent.get())->isExtensible());
-                writeData(
-                    handle, RTL_CONSTASCII_STRINGPARAM("<prop oor:name=\""));
-                writeAttributeValue(handle, nodeName);
-                writeData(
-                    handle,
-                    RTL_CONSTASCII_STRINGPARAM("\" oor:op=\"remove\"/>"));
-                break;
-            case Node::KIND_SET:
-                writeData(
-                    handle, RTL_CONSTASCII_STRINGPARAM("<node oor:name=\""));
-                writeAttributeValue(handle, nodeName);
-                writeData(
-                    handle,
-                    RTL_CONSTASCII_STRINGPARAM("\" oor:op=\"remove\"/>"));
-                break;
-            case Node::KIND_WIPED:
-                break; // Our parent was wiped, we should not exist
-            default:
-                OSL_ASSERT(false); // this cannot happen
-                break;
             }
-        }
-        writeData(handle, RTL_CONSTASCII_STRINGPARAM("</item>"));
+            writeData(handle, RTL_CONSTASCII_STRINGPARAM("</item>"));
+        } // else: the element disappears
     } else {
         OSL_ASSERT(node.is());
         rtl::OUString pathRep(

Reply via email to