sw/qa/uibase/wrtsh/wrtsh.cxx                  |    7 +++++++
 sw/source/core/txtnode/attrcontentcontrol.cxx |    1 -
 sw/source/uibase/wrtsh/wrtsh1.cxx             |   14 ++++++++++++++
 sw/source/uibase/wrtsh/wrtsh3.cxx             |    4 ----
 4 files changed, 21 insertions(+), 5 deletions(-)

New commits:
commit 618cef756b87f9816d0dcbe04af163ccd06a986e
Author:     offtkp <parisop...@gmail.com>
AuthorDate: Mon Dec 12 13:03:43 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Dec 13 06:44:03 2022 +0000

    docx: Do not remove showingPlcHdr until edit
    
    When a placeholder has the showingPlcHdr attribute, the entire text is
    selected upon click. This is no longer removed by selecting it once but
    once the text has been edited.
    
    Change-Id: I9a4d68289c8b95ab0098e55a5fa6edb1606c7df2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143985
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx
index d2adde32a179..a2d9fdc37514 100644
--- a/sw/qa/uibase/wrtsh/wrtsh.cxx
+++ b/sw/qa/uibase/wrtsh/wrtsh.cxx
@@ -399,6 +399,13 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInsertPlainTextContentControl)
     // Without the accompanying fix in place, this test would have failed, 
there was no special
     // handling for plain text content controls.
     CPPUNIT_ASSERT(pContentControl->GetPlainText());
+
+    CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder());
+    pWrtShell->GotoContentControl(rFormatContentControl);
+    CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder());
+    pWrtShell->Insert("Foo");
+    // No longer showing placeholder text, as it has been changed
+    CPPUNIT_ASSERT(!pContentControl->GetShowingPlaceHolder());
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testInsertComboBoxContentControl)
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx 
b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 890bf20c1376..1db39849fbe6 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -720,7 +720,6 @@ void SwTextContentControl::Invalidate()
     pDocShell->GetWrtShell()->Push();
 
     // visit the control in the text (which makes any necessary visual changes)
-    // NOTE: simply going to a control indicates cancelling 
ShowingPlaceHolder, unless bOnlyRefresh
     // NOTE: simply going to a checkbox causes a toggle, unless bOnlyRefresh
     auto& rFormatContentControl = 
static_cast<SwFormatContentControl&>(GetAttr());
     pDocShell->GetWrtShell()->GotoContentControl(rFormatContentControl, 
/*bOnlyRefresh=*/true);
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index adf96052e8fa..b989343266cb 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -117,6 +117,7 @@
 #include <UndoCore.hxx>
 #include <formatlinebreak.hxx>
 #include <formatcontentcontrol.hxx>
+#include <textcontentcontrol.hxx>
 
 using namespace sw::mark;
 using namespace com::sun::star;
@@ -262,6 +263,19 @@ void SwWrtShell::Insert( const OUString &rStr )
     bCallIns ?
         SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr 
);
 
+    // Check whether node is content control
+    SwTextContentControl* pTextContentControl = CursorInsideContentControl();
+    if (pTextContentControl)
+    {
+        std::shared_ptr<SwContentControl> pContentControl =
+            pTextContentControl->GetContentControl().GetContentControl();
+        if (pContentControl)
+        {
+            // Set showingPlcHdr to false as node has been edited
+            pContentControl->SetShowingPlaceHolder(false);
+        }
+    }
+
     if( bStarted )
     {
         EndUndo();
diff --git a/sw/source/uibase/wrtsh/wrtsh3.cxx 
b/sw/source/uibase/wrtsh/wrtsh3.cxx
index aa170d1374a4..4e80bfc1e3d1 100644
--- a/sw/source/uibase/wrtsh/wrtsh3.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh3.cxx
@@ -125,10 +125,6 @@ bool SwWrtShell::GotoContentControl(const 
SwFormatContentControl& rContentContro
     (this->*m_fnKillSel)(nullptr, false);
 
     bool bRet = SwCursorShell::GotoFormatContentControl(rContentControl);
-    // Assume that once the placeholder is selected, the content is no longer 
the placeholder.
-    if (!bOnlyRefresh && pContentControl)
-        pContentControl->SetShowingPlaceHolder(false);
-
 
     if (bRet && pContentControl && pContentControl->GetCheckbox())
     {

Reply via email to