Kaydet (Commit) 20ae3d14 authored tarafından Michael Stahl's avatar Michael Stahl

tdf#98512 sw: add unit test

... and fix the SAL_WARN not to warn spuriously.

Change-Id: Ic951fc0d811e5cab39989285d34bdd2fff8f95fd
üst 9a2fccbc
......@@ -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");
......
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment