[Libreoffice-commits] core.git: 2 commits - sw/CppunitTest_sw_uiwriter.mk sw/qa sw/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Mon Oct 12 14:43:21 PDT 2015
sw/CppunitTest_sw_uiwriter.mk | 6 +--
sw/qa/extras/uiwriter/data/tdf77014.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 50 ++++++++++++++++++++++++++++++
sw/source/core/text/portxt.cxx | 53 +-------------------------------
4 files changed, 55 insertions(+), 54 deletions(-)
New commits:
commit 5e1714fd7fcb45fa5f1220d892dba597da40b500
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Oct 12 23:28:53 2015 +0200
tdf#77014 fix input field breaking of words at new line
SwTextInputFieldPortion::Format has previously tried to erase the
input field special chars, which caused the words not breaking as
expected or in the same way as normal text. It appears that it is
actually not necessary to do this at all so just calling the super
class method SwTextPortion::Format does the job and fixes the
problem. After testing I could not find anything that is obviously
wrong.
Change-Id: Ie763f55ad55863dd224425dc481b7100deb639fa
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index d5cca56..e3a6388 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -655,58 +655,9 @@ SwTextInputFieldPortion::SwTextInputFieldPortion()
SetWhichPor( POR_INPUTFLD );
}
-bool SwTextInputFieldPortion::Format( SwTextFormatInfo &rInf )
+bool SwTextInputFieldPortion::Format(SwTextFormatInfo &rTextFormatInfo)
{
- mbContainsInputFieldStart =
- rInf.GetChar( rInf.GetIdx() ) == CH_TXT_ATR_INPUTFIELDSTART;
- mbContainsInputFieldEnd =
- rInf.GetChar( rInf.GetIdx() + rInf.GetLen() - 1 ) == CH_TXT_ATR_INPUTFIELDEND;
-
- bool bRet = false;
- if ( rInf.GetLen() == 1
- && ( mbContainsInputFieldStart || mbContainsInputFieldEnd ) )
- {
- Width( 0 );
- }
- else
- {
- SwTextSlot aFormatText( &rInf, this, true, true );
- if ( rInf.GetLen() == 0 )
- {
- Width( 0 );
- }
- else
- {
- const sal_Int32 nFormerLineStart = rInf.GetLineStart();
- if ( !mbContainsInputFieldStart )
- {
- rInf.SetLineStart( 0 );
- }
-
- bRet = SwTextPortion::Format( rInf );
-
- if ( mbContainsInputFieldEnd )
- {
- // adjust portion length accordingly, if complete text fits into the portion
- if ( GetLen() == rInf.GetLen() )
- {
- SetLen( GetLen() + 1 );
- }
- }
-
- if ( mbContainsInputFieldStart )
- {
- // adjust portion length accordingly
- SetLen( GetLen() + 1 );
- }
- else
- {
- rInf.SetLineStart( nFormerLineStart );
- }
- }
- }
-
- return bRet;
+ return SwTextPortion::Format(rTextFormatInfo);
}
void SwTextInputFieldPortion::Paint( const SwTextPaintInfo &rInf ) const
commit 1db251e1a191844eb99462a67e9acf4f4b67233f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Oct 12 23:25:45 2015 +0200
tdf#77014 create a test for this bug
Change-Id: Iebe72287f62da7382f12e7645b48fa666610a8c5
diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk
index efe9174..e30197e 100644
--- a/sw/CppunitTest_sw_uiwriter.mk
+++ b/sw/CppunitTest_sw_uiwriter.mk
@@ -22,18 +22,18 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \
cppu \
cppuhelper \
editeng \
- msword \
+ msword \
sal \
sfx \
svl \
svt \
- svxcore \
+ svxcore \
sw \
test \
unotest \
vcl \
tl \
- utl \
+ utl \
$(gb_UWINAPI) \
))
diff --git a/sw/qa/extras/uiwriter/data/tdf77014.odt b/sw/qa/extras/uiwriter/data/tdf77014.odt
new file mode 100644
index 0000000..66d6835
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf77014.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index f77cb9b..988ebf8 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -166,6 +166,7 @@ public:
void testTdf89720();
void testTdf88986();
void testTdf87922();
+ void testTdf77014();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -241,6 +242,7 @@ public:
CPPUNIT_TEST(testTdf89720);
CPPUNIT_TEST(testTdf88986);
CPPUNIT_TEST(testTdf87922);
+ CPPUNIT_TEST(testTdf77014);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2696,6 +2698,54 @@ void SwUiWriterTest::testTdf87922()
CPPUNIT_ASSERT_EQUAL(COL_WHITE, aFont.GetColor().GetColor());
}
+void SwUiWriterTest::testTdf77014()
+{
+ // The problem described in the bug tdf#77014 is that the input
+ // field text ("ThisIsAllOneWord") is broken up on linebreak, but
+ // it should be in one piece (like normal text).
+
+ // This test checks that the input field is in one piece.
+
+ load(DATA_DIRECTORY, "tdf77014.odt");
+
+ // First paragraph
+ CPPUNIT_ASSERT_EQUAL(OUString("POR_TXT"), parseDump("/root/page/body/txt[4]/Text[1]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("91"), parseDump("/root/page/body/txt[4]/Text[1]", "nLength"));
+
+ // The "Unknown" is the input field:
+ // which is 16 chars + 2 hidden chars (start & end input field) = 18 chars
+ // If this is correct then the input field is in one piece
+ CPPUNIT_ASSERT_EQUAL(OUString("Unknown"), parseDump("/root/page/body/txt[4]/Text[2]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("18"), parseDump("/root/page/body/txt[4]/Text[2]", "nLength"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("POR_TXT"), parseDump("/root/page/body/txt[4]/Text[3]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), parseDump("/root/page/body/txt[4]/Text[3]", "nLength"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("POR_TXT"), parseDump("/root/page/body/txt[4]/Text[1]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("91"), parseDump("/root/page/body/txt[4]/Text[1]", "nLength"));
+
+ // Second paragraph
+ CPPUNIT_ASSERT_EQUAL(OUString("POR_TXT"), parseDump("/root/page/body/txt[5]/Text[1]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("91"), parseDump("/root/page/body/txt[5]/Text[1]", "nLength"));
+
+ // The input field here has more words ("One Two Three Four Five")
+ // and it should break after "Two".
+ // "One Two" = 7 chars + 1 start input field hidden character = 8 chars
+ CPPUNIT_ASSERT_EQUAL(OUString("Unknown"), parseDump("/root/page/body/txt[5]/Text[2]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("8"), parseDump("/root/page/body/txt[5]/Text[2]", "nLength"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("POR_HOLE"), parseDump("/root/page/body/txt[5]/Text[3]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), parseDump("/root/page/body/txt[5]/Text[3]", "nLength"));
+
+ // In new line..
+ // "Three Four Five" = 16 chars + 1 end input field hidden character = 16 chars
+ CPPUNIT_ASSERT_EQUAL(OUString("Unknown"), parseDump("/root/page/body/txt[5]/Text[4]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("16"), parseDump("/root/page/body/txt[5]/Text[4]", "nLength"));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("POR_TXT"), parseDump("/root/page/body/txt[5]/Text[5]", "nType"));
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), parseDump("/root/page/body/txt[5]/Text[5]", "nLength"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list