summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2022-11-23 18:12:20 -0500
committerJustin Luth <jluth@mail.com>2022-12-01 21:32:05 +0100
commit982f9ec1e07364e317fbcd25f1ef06f984cc0ce8 (patch)
tree5391f502f0288a786d935863964e772a8f81c990 /sw
parent224fc966096e9fc52d8e41fbae211e3999edd945 (diff)
tdf#151548 ContentControls: Add Delete()
Needed a function to delete a control, so it seemed to make sense to include it here. [I saw a nice bExact flag, but it doesn't work because RES_TXTATTR_CONTENTCONTROLS is outside of a certain range. Oh well.] make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME=testVba Change-Id: If7da3d4d614d9dfd20f539f651477cbd18d25e20 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143195 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/textcontentcontrol.hxx2
-rw-r--r--sw/qa/core/data/docm/testModernVBA.docmbin31991 -> 31807 bytes
-rw-r--r--sw/source/core/txtnode/attrcontentcontrol.cxx14
-rw-r--r--sw/source/ui/vba/vbacontentcontrol.cxx5
4 files changed, 18 insertions, 3 deletions
diff --git a/sw/inc/textcontentcontrol.hxx b/sw/inc/textcontentcontrol.hxx
index a9bc4e4a1054..3fb7ea124b99 100644
--- a/sw/inc/textcontentcontrol.hxx
+++ b/sw/inc/textcontentcontrol.hxx
@@ -41,6 +41,8 @@ public:
void ChgTextNode(SwTextNode* pNode);
+ void Delete(bool bSaveContents);
+
SwTextNode* GetTextNode() const;
/// Get the current (potentially invalid) string from the doc
OUString ToString() const;
diff --git a/sw/qa/core/data/docm/testModernVBA.docm b/sw/qa/core/data/docm/testModernVBA.docm
index dd96686659ca..be7d99a24b84 100644
--- a/sw/qa/core/data/docm/testModernVBA.docm
+++ b/sw/qa/core/data/docm/testModernVBA.docm
Binary files differ
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx
index e3d0c2237b3b..890bf20c1376 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -675,6 +675,20 @@ void SwTextContentControl::ChgTextNode(SwTextNode* pNode)
}
}
+void SwTextContentControl::Delete(bool bSaveContents)
+{
+ if (!GetTextNode())
+ return;
+
+ if (bSaveContents)
+ GetTextNode()->RstTextAttr(GetStart(), *End() - GetStart(), RES_TXTATR_CONTENTCONTROL);
+ else
+ {
+ SwPaM aPaM(*GetTextNode(), GetStart(), *GetTextNode(), *End());
+ GetTextNode()->GetDoc().getIDocumentContentOperations().DeleteAndJoin(aPaM);
+ }
+}
+
SwTextNode* SwTextContentControl::GetTextNode() const
{
auto& rFormatContentControl = static_cast<const SwFormatContentControl&>(GetAttr());
diff --git a/sw/source/ui/vba/vbacontentcontrol.cxx b/sw/source/ui/vba/vbacontentcontrol.cxx
index d75ce84d7f4a..da3f3ec6f4ee 100644
--- a/sw/source/ui/vba/vbacontentcontrol.cxx
+++ b/sw/source/ui/vba/vbacontentcontrol.cxx
@@ -676,15 +676,14 @@ void SwVbaContentControl::Cut()
SAL_INFO("sw.vba",
"SwVbaContentControl::Cut[" << getID() << "], but missing sending to clipboard");
- Delete(uno::Any(false));
+ m_rCC.Delete(/*bSaveContents=*/false);
}
void SwVbaContentControl::Delete(const uno::Any& DeleteContents)
{
bool bDeleteContents = false;
DeleteContents >>= bDeleteContents;
- SAL_INFO("sw.vba", "SwVbaContentControl::Delete[" << DeleteContents << "] stub");
- //m_rCC.ChgTextNode(nullptr); // works, but crashes on UI touch - probably requires invalidation
+ m_rCC.Delete(!bDeleteContents);
}
void SwVbaContentControl::SetCheckedSymbol(sal_Int32 Character, const uno::Any& Font)