summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/core/txtnode/data/plain-content-control-copy.docxbin0 -> 12178 bytes
-rw-r--r--sw/qa/core/txtnode/txtnode.cxx23
-rw-r--r--sw/source/core/txtnode/thints.cxx4
3 files changed, 26 insertions, 1 deletions
diff --git a/sw/qa/core/txtnode/data/plain-content-control-copy.docx b/sw/qa/core/txtnode/data/plain-content-control-copy.docx
new file mode 100644
index 000000000000..80fecae26d5b
--- /dev/null
+++ b/sw/qa/core/txtnode/data/plain-content-control-copy.docx
Binary files differ
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index dec97c2ab910..b2bc0cec8b22 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -539,6 +539,29 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testSplitFlyAnchorSplit)
CPPUNIT_ASSERT_EQUAL(OUString("PortionType::Fly"), aPortionType);
}
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testPlainContentControlCopy)
+{
+ // Given a document with a plain text content control, all text selected and copied to the
+ // clipboard:
+ createSwDoc("plain-content-control-copy.docx");
+ SwDocShell* pDocShell = getSwDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->SelAll();
+ {
+ rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell);
+ xTransfer->Copy();
+ }
+
+ // When closing that document, then make sure we don't crash on shutdown:
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<util::XCloseable> xFrame(xModel->getCurrentController()->getFrame(),
+ uno::UNO_QUERY);
+ // Without the accompanying fix in place, this resulted in an assertion failure, a char style
+ // still had clients by the time it was deleted.
+ xFrame->close(false);
+ mxComponent.clear();
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 60161c3b8f89..c684b005504f 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1698,7 +1698,9 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode )
// for all of its content.
auto* pTextContentControl = static_txtattr_cast<SwTextContentControl*>(
GetTextAttrAt(pAttr->GetStart(), RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent));
- if (pTextContentControl)
+ // If the caller is SwTextNode::CopyText, we just copy an existing attribute, no need to
+ // correct it.
+ if (pTextContentControl && !(nMode & SetAttrMode::NOTXTATRCHR))
{
auto& rFormatContentControl
= static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());