summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2025-01-06 12:07:46 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2025-01-06 15:22:31 +0100
commit08111edaeb425f1b66d0c69c415dbd7d2f44ac8c (patch)
tree497178ea55871fc6e42ca4faf8cc4ca8d2a96f12 /sw
parentca7ee477978c6b818a28fcd601a7033066e23a9f (diff)
crashtesting: assert on reimport of forum-mso-en-2419.docx
after export to docx. Use similar duplicate preventation mechanism as normal bookmarks and annotations use. Change-Id: I31a70f1ee437a5d8cce790c7ec2c7a8d5894d3f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179828 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx12
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx7
2 files changed, 15 insertions, 4 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 0cd8b728bbb3..5fc619f3ecb2 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2336,8 +2336,12 @@ void DocxAttributeOutput::DoWriteBookmarksEnd(std::vector<OUString>& rEnds)
// - "permission-for-user:<permission-id>:<permission-user-name>"
// - "permission-for-group:<permission-id>:<permission-group-name>"
//
-void DocxAttributeOutput::DoWritePermissionTagStart(std::u16string_view permission)
+void DocxAttributeOutput::DoWritePermissionTagStart(const OUString& permission)
{
+ if (m_aOpenedPermissions.find(permission) != m_aOpenedPermissions.end())
+ return;
+ m_aOpenedPermissions.insert(permission);
+
std::u16string_view permissionIdAndName;
sal_Int32 nFSNS;
@@ -2371,8 +2375,11 @@ void DocxAttributeOutput::DoWritePermissionTagStart(std::u16string_view permissi
// - "permission-for-user:<permission-id>:<permission-user-name>"
// - "permission-for-group:<permission-id>:<permission-group-name>"
//
-void DocxAttributeOutput::DoWritePermissionTagEnd(std::u16string_view permission)
+void DocxAttributeOutput::DoWritePermissionTagEnd(const OUString& permission)
{
+ if (m_aOpenedPermissions.find(permission) == m_aOpenedPermissions.end())
+ return;
+
std::u16string_view permissionIdAndName;
auto const ok = o3tl::starts_with(permission, u"permission-for-group:", &permissionIdAndName) ||
@@ -2385,6 +2392,7 @@ void DocxAttributeOutput::DoWritePermissionTagEnd(std::u16string_view permission
m_pSerializer->singleElementNS(XML_w, XML_permEnd,
FSNS(XML_w, XML_id), GetExport().BookmarkToWord(permissionId));
+ m_aOpenedPermissions.erase(permission);
}
/// Write the start permissions
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 385ce344c21d..e19940a673a2 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -783,8 +783,8 @@ private:
void DoWriteBookmarkStartIfExist(sal_Int32 nRunPos);
void DoWriteBookmarkEndIfExist(sal_Int32 nRunPos);
- void DoWritePermissionTagStart(std::u16string_view permission);
- void DoWritePermissionTagEnd(std::u16string_view permission);
+ void DoWritePermissionTagStart(const OUString& permission);
+ void DoWritePermissionTagEnd(const OUString& permission);
void DoWritePermissionsStart();
void DoWritePermissionsEnd();
@@ -927,6 +927,9 @@ private:
/// Name of the last opened annotation mark.
OUString m_sLastOpenedAnnotationMark;
+ /// Set of currently opened permissions
+ std::unordered_set<OUString> m_aOpenedPermissions;
+
/// If there are bookmarks around sequence fields, this map contains the
/// names of these bookmarks for each sequence.
std::map<OUString, std::vector<OUString> > m_aSeqBookmarksNames;