summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-04-28 09:50:54 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-04-28 13:19:10 +0200
commitb73c6c8e53cf944848cdb3a79371703de99a8710 (patch)
tree1ef6fc49454331df5f9cfe3f3449d1b42f0dc0d9 /sw/source/uibase
parentecd8508eaf8a3eb064b26c5c80cd2930fe6e7555 (diff)
sw bibliography: fix warning when de-selecting a biblio entry field
De-selecting a biblio entry field resulted in this warning: warn:sw.core:3311:3311:sw/source/core/fields/authfld.cxx:104: SwAuthorityFieldType::RemoveField: pEntry is not my field But this was even an assert before commit 64ffabbdb2725e93de997171708bb31c33c93a55 (sw bibliography, refer to a page: make the biblio field clickable, 2021-03-12). It seems the root of the problem was: - SwAuthorityFieldType has a list of SwAuthEntry instances that its SwAuthorityFields may have - when the field is selected, we copy the selection to a clipboard document, using SwFEShell::Copy() - this calls SwAuthorityFieldType::AppendField() to register the SwAuthEntry, but that registers a copy instead - SwAuthorityFieldType::RemoveField() then asserted that the original SwAuthEntry is part of SwAuthorityFieldType's list, but it was not Fix the problem by returning a reference to the copied SwAuthEntry in SwAuthorityFieldType::AppendField(), that fixes the warning and then we can turn this back to an assert, to detect problems where an unregistered SwAuthEntry would be de-registered. In practice this caused a problem in the Insert Bibliography Entry dialog: bibliography source = document content case uses SwAuthorityFieldType::GetAllEntryIdentifiers() to provide a list of sources, and this way sources were not removed from that list when deleting biblio entry fields. Change-Id: Iea4fa44302aaac0daa122bbf227888d1dbb06597 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114765 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/utlui/initui.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index f9567ec4ab45..a690b7cfe9df 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <libxml/xmlwriter.h>
+
#include <unotools/localedatawrapper.hxx>
#include <viewsh.hxx>
#include <initui.hxx>
@@ -286,4 +288,21 @@ OUString const & SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType)
return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)];
}
+void SwAuthorityFieldType::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwAuthorityFieldType"));
+ SwFieldType::dumpAsXml(pWriter);
+
+ (void)xmlTextWriterStartElement(pWriter, BAD_CAST("DataArr"));
+ for (const auto& xAuthEntry : m_DataArr)
+ {
+ (void)xmlTextWriterStartElement(pWriter, BAD_CAST("AuthEntry"));
+ (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", xAuthEntry.get());
+ (void)xmlTextWriterEndElement(pWriter);
+ }
+ (void)xmlTextWriterEndElement(pWriter);
+
+ (void)xmlTextWriterEndElement(pWriter);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */