sw/qa/extras/uiwriter/uiwriter.cxx | 40 +++++++++++++++++++++++++++++++++++++ sw/source/core/txtnode/ndtxt.cxx | 3 +- sw/source/uibase/fldui/fldmgr.cxx | 11 +++++++--- 3 files changed, 50 insertions(+), 4 deletions(-)
New commits: commit 39d719a80d8c87856c84e3ecd569d45fa6f8a30e Author: Michael Stahl <mst...@redhat.com> Date: Tue May 3 11:39:37 2016 +0200 tdf#99529 sw: don't pop up input field dialog before inserting field The dialog calls SwEditShell::UpdateFields(), so if there is already a existing field at the current cursor position it will be "updated" before the new field is inserted. Change-Id: I8ddbbe00534950759781a1ce8d0dca0376663462 diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index e9e586c..0b5ef6d 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1185,9 +1185,6 @@ bool SwFieldMgr::InsertField( new SwInputField( pTyp, rData.m_sPar1, rData.m_sPar2, nSubType|nsSwExtendedSubType::SUB_INVISIBLE, nFormatId); pField = pInpField; } - - // start dialog - pCurShell->StartInputFieldDlg(pField, false, rData.m_pParent); break; } @@ -1329,6 +1326,14 @@ bool SwFieldMgr::InsertField( pCurShell->Insert( *pField ); + if (TYP_INPUTFLD == rData.m_nTypeId) + { + // start dialog, not before the field is inserted tdf#99529 + pCurShell->Left(CRSR_SKIP_CHARS, + false, (INP_VAR == (nSubType & 0xff)) ? 1 : 2, false ); + pCurShell->StartInputFieldDlg(pField, false, rData.m_pParent); + } + if(bExp && bEvalExp) pCurShell->UpdateExpFields(true); commit 20ae3d14187dacce2c2a1d2eab389e6110fe8442 Author: Michael Stahl <mst...@redhat.com> Date: Tue May 3 10:53:59 2016 +0200 tdf#98512 sw: add unit test ... and fix the SAL_WARN not to warn spuriously. Change-Id: Ic951fc0d811e5cab39989285d34bdd2fff8f95fd diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 11a0824..fca4a79 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -112,6 +112,7 @@ public: void testFdo75110(); void testFdo75898(); void testFdo74981(); + void testTdf98512(); void testShapeTextboxSelect(); void testShapeTextboxDelete(); void testCp1000071(); @@ -211,6 +212,7 @@ public: CPPUNIT_TEST(testFdo75110); CPPUNIT_TEST(testFdo75898); CPPUNIT_TEST(testFdo74981); + CPPUNIT_TEST(testTdf98512); CPPUNIT_TEST(testShapeTextboxSelect); CPPUNIT_TEST(testShapeTextboxDelete); CPPUNIT_TEST(testCp1000071); @@ -701,6 +703,44 @@ void SwUiWriterTest::testFdo74981() CPPUNIT_ASSERT(!pTextNode->HasHints()); } +void SwUiWriterTest::testTdf98512() +{ + SwDoc* pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwInputFieldType *const pType(static_cast<SwInputFieldType*>( + pWrtShell->GetFieldType(0, RES_INPUTFLD))); + SwInputField aField1(pType, OUString("foo"), OUString("bar"), INP_TXT, 0); + pWrtShell->Insert(aField1); + pWrtShell->SttEndDoc(/*bStt=*/true); + SwInputField aField2(pType, OUString("baz"), OUString("quux"), INP_TXT, 0); + pWrtShell->Insert(aField2); + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->SetMark(); + pWrtShell->SttEndDoc(/*bStt=*/false); + OUString const expected1( + OUStringLiteral1<CH_TXT_ATR_INPUTFIELDSTART>() + "foo" + OUStringLiteral1<CH_TXT_ATR_INPUTFIELDEND>()); + OUString const expected2( + OUStringLiteral1<CH_TXT_ATR_INPUTFIELDSTART>() + "baz" + OUStringLiteral1<CH_TXT_ATR_INPUTFIELDEND>() + + expected1); + CPPUNIT_ASSERT_EQUAL(expected2, pWrtShell->getShellCursor(false)->GetText()); + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + rUndoManager.Undo(); + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->SetMark(); + pWrtShell->SttEndDoc(/*bStt=*/false); + CPPUNIT_ASSERT_EQUAL(expected1, pWrtShell->getShellCursor(false)->GetText()); + rUndoManager.Redo(); + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->SetMark(); + pWrtShell->SttEndDoc(/*bStt=*/false); + CPPUNIT_ASSERT_EQUAL(expected2, pWrtShell->getShellCursor(false)->GetText()); + rUndoManager.Undo(); + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->SetMark(); + pWrtShell->SttEndDoc(/*bStt=*/false); + CPPUNIT_ASSERT_EQUAL(expected1, pWrtShell->getShellCursor(false)->GetText()); +} + void SwUiWriterTest::testShapeTextboxSelect() { SwDoc* pDoc = createDoc("shape-textbox.odt"); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index ecc1d37..62b8024 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1940,6 +1940,7 @@ OUString SwTextNode::InsertText( const OUString & rStr, const SwIndex & rIdx, if ( HasHints() ) { + bool const bHadHints(!m_pSwpHints->CanBeDeleted()); bool bMergePortionsNeeded(false); for ( size_t i = 0; i < m_pSwpHints->Count() && rIdx >= m_pSwpHints->Get(i)->GetStart(); ++i ) @@ -2004,7 +2005,7 @@ OUString SwTextNode::InsertText( const OUString & rStr, const SwIndex & rIdx, { m_pSwpHints->MergePortions(*this); } - SAL_WARN_IF(m_pSwpHints->CanBeDeleted(), "sw.core", + SAL_WARN_IF(bHadHints && m_pSwpHints->CanBeDeleted(), "sw.core", "SwTextNode::InsertText: unexpected loss of hints"); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits