sw/qa/extras/uiwriter/data/tdf107362.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 19 +++++++++++++++++++ sw/source/core/text/itrform2.cxx | 5 +++-- sw/source/core/txtnode/fntcache.cxx | 12 ++++-------- 4 files changed, 26 insertions(+), 10 deletions(-)
New commits: commit b647f9f4bcb24ed9b71c77038da6b754b8d42eb7 Author: Mark Hung <mark...@gmail.com> Date: Thu Apr 27 20:41:06 2017 +0800 tdf#107362 don't insert kern if snap to char is not checked. SwKernPortion is inserted between different scripts to snap the later text portion to the charcter grid if type of text grid is lines and chars, even if snap-to-char isn't checked, and create unexpected space there. It is not necessary because when snap-to-char is not checked, there would be pitch between characters. Format all three scripts in the same way and do not insert kern portion anymore if snap-to-char isn't checked. Change-Id: I6078b425aa735beb50cc6a6b4eafbba9f91f7132 Reviewed-on: https://gerrit.libreoffice.org/37037 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Mark Hung <mark...@gmail.com> diff --git a/sw/qa/extras/uiwriter/data/tdf107362.odt b/sw/qa/extras/uiwriter/data/tdf107362.odt new file mode 100755 index 000000000000..9f7e5cbfb7ab Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf107362.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 9cf0fad97ff3..2b4764b7b998 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -232,6 +232,7 @@ public: void testTdf106701_tabOverMarginAutotab(); void testTdf104492(); void testTdf107025(); + void testTdf107362(); void testTdf105417(); void testTdf105625(); void testTdf106736(); @@ -359,6 +360,7 @@ public: CPPUNIT_TEST(testTdf106701_tabOverMarginAutotab); CPPUNIT_TEST(testTdf104492); CPPUNIT_TEST(testTdf107025); + CPPUNIT_TEST(testTdf107362); CPPUNIT_TEST(testTdf105417); CPPUNIT_TEST(testTdf105625); CPPUNIT_TEST(testTdf106736); @@ -4486,6 +4488,23 @@ void SwUiWriterTest::testTdf107025() CPPUNIT_ASSERT_EQUAL( sal_Int32(9), nWidth2 / nWidth1 ); } +void SwUiWriterTest::testTdf107362() +{ + createDoc("tdf107362.odt"); + xmlDocPtr pXmlDoc = parseLayoutDump(); + sal_Int32 nHeight = getXPath(pXmlDoc, "(//Text[@nType='POR_TXT'])[1]" , "nHeight").toInt32(); + sal_Int32 nWidth1 = getXPath(pXmlDoc, "(//Text[@nType='POR_TXT'])[1]" , "nWidth").toInt32(); + sal_Int32 nWidth2 = getXPath(pXmlDoc, "(//Text[@nType='POR_TXT'])[2]" , "nWidth").toInt32(); + sal_Int32 nLineWidth = getXPath(pXmlDoc, "//LineBreak" , "nWidth").toInt32(); + sal_Int32 nKernWidth = nLineWidth - nWidth1 - nWidth2; + // Test only if fonts are available + if ( nWidth1 > 500 && nWidth2 > 200 ) + { + // Kern width should be smaller than 1/3 of the CJK font height. + CPPUNIT_ASSERT( nKernWidth * 3 < nHeight ); + } +} + void SwUiWriterTest::testTdf105417() { SwDoc* pDoc = createDoc("tdf105417.odt"); diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 0823187a85b1..d5a29b0779f1 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -371,6 +371,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) const bool bHasGrid = pGrid && rInf.SnapToGrid() && GRID_LINES_CHARS == pGrid->GetGridType(); + const SwDoc *pDoc = rInf.GetTextFrame()->GetNode()->GetDoc(); const sal_uInt16 nGridWidth = (bHasGrid) ? GetGridWidth(*pGrid, *pDoc) : 0; @@ -472,7 +473,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) } } } - else if ( bHasGrid && ! pGridKernPortion && ! pMulti && ! pPor->InTabGrp() ) + else if ( bHasGrid && pGrid->IsSnapToChars() && ! pGridKernPortion && ! pMulti && ! pPor->InTabGrp() ) { // insert a grid kerning portion if ( ! pGridKernPortion ) @@ -618,7 +619,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf ) } } - if ( bHasGrid && pPor != pGridKernPortion && ! pMulti && ! pPor->InTabGrp() ) + if ( bHasGrid && pGrid->IsSnapToChars() && pPor != pGridKernPortion && ! pMulti && ! pPor->InTabGrp() ) { sal_Int32 nTmp = rInf.GetIdx() + pPor->GetLen(); const SwTwips nRestWidth = rInf.Width() - rInf.X() - pPor->Width(); diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 6439ba66b2d2..8b0b6c960c75 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1029,8 +1029,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) // For text grid refactor // ASIAN LINE AND CHARACTER GRID MODE START: not snap to characters - if ( rInf.GetFrame() && rInf.SnapToGrid() && rInf.GetFont() && - SwFontScript::CJK == rInf.GetFont()->GetActual() ) + if ( rInf.GetFrame() && rInf.SnapToGrid() ) { SwTextGridItem const*const pGrid(GetGridItem(rInf.GetFrame()->FindPageFrame())); @@ -1853,8 +1852,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf ) } //for textgrid refactor - if ( rInf.GetFrame() && nLn && rInf.SnapToGrid() && rInf.GetFont() && - SwFontScript::CJK == rInf.GetFont()->GetActual() ) + if ( rInf.GetFrame() && nLn && rInf.SnapToGrid() && rInf.GetFont() ) { SwTextGridItem const*const pGrid(GetGridItem(rInf.GetFrame()->FindPageFrame())); if ( pGrid && GRID_LINES_CHARS == pGrid->GetGridType() && !pGrid->IsSnapToChars() ) @@ -2112,8 +2110,7 @@ sal_Int32 SwFntObj::GetCursorOfst( SwDrawTextInfo &rInf ) } //for textgrid refactor - if ( rInf.GetFrame() && rInf.GetLen() && rInf.SnapToGrid() && - rInf.GetFont() && SwFontScript::CJK == rInf.GetFont()->GetActual() ) + if ( rInf.GetFrame() && rInf.GetLen() && rInf.SnapToGrid() ) { SwTextGridItem const*const pGrid(GetGridItem(rInf.GetFrame()->FindPageFrame())); if ( pGrid && GRID_LINES_CHARS == pGrid->GetGridType() && !pGrid->IsSnapToChars() ) @@ -2341,8 +2338,7 @@ sal_Int32 SwFont::GetTextBreak( SwDrawTextInfo& rInf, long nTextWidth ) } //for text grid enhancement - if ( rInf.GetFrame() && nLn && rInf.SnapToGrid() && rInf.GetFont() && - SwFontScript::CJK == rInf.GetFont()->GetActual() ) + if ( rInf.GetFrame() && nLn && rInf.SnapToGrid() ) { SwTextGridItem const*const pGrid(GetGridItem(rInf.GetFrame()->FindPageFrame())); if ( pGrid && GRID_LINES_CHARS == pGrid->GetGridType() && !pGrid->IsSnapToChars() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits