diff options
author | Vort <vvort@yandex.ru> | 2014-03-31 07:59:07 +0300 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-03-31 15:19:06 +0000 |
commit | 2498e4725e4a8c3a8193e61618d314837d8db180 (patch) | |
tree | 1a570595ebdb490373ab21bef63cb8d69c0a9fcd /sdext | |
parent | 84c40768f8acb0342dcfa223133497f57620fc14 (diff) |
fdo#49431 PDF Import: Improve line and space detection algorithm
Change-Id: Ia0d53e90f49fa020e0738e295a4584254e2b474e
Reviewed-on: https://gerrit.libreoffice.org/8800
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/pdfimport/tree/pdfiprocessor.cxx | 35 | ||||
-rw-r--r-- | sdext/source/pdfimport/tree/pdfiprocessor.hxx | 1 |
2 files changed, 19 insertions, 17 deletions
diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index d5faf25e3b5d..581f0527a6d5 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -57,7 +57,6 @@ namespace pdfi m_xContext(xContext), fYPrevTextPosition(-10000.0), - fPrevTextHeight(0.0), fXPrevTextPosition(0.0), fPrevTextWidth(0.0), m_pElFactory( new ElementFactory() ), @@ -254,10 +253,14 @@ void PDFIProcessor::processGlyphLine() for (size_t i = 0; i < m_GlyphsList.size(); i++) { - double spaceSize = 0.0; + bool prependSpace = false; if (i != 0) - spaceSize = m_GlyphsList[i].getRect().X1 - m_GlyphsList[i - 1].getRect().X2; - bool prependSpace = spaceSize > spaceDetectBoundary; + { + double spaceSize = + m_GlyphsList[i].getRect().X1 - + m_GlyphsList[i - 1].getRect().X2; + prependSpace = spaceSize > spaceDetectBoundary; + } drawCharGlyphs(m_GlyphsList[i].getGlyph(), m_GlyphsList[i].getRect(), m_GlyphsList[i].getGC(), @@ -273,13 +276,14 @@ void PDFIProcessor::drawGlyphLine( const OUString& rGlyphs, const geometry::RealRectangle2D& rRect, const geometry::Matrix2D& rFontMatrix ) { - double isFirstLine= fYPrevTextPosition+ fXPrevTextPosition+ fPrevTextHeight+ fPrevTextWidth ; - if( - ( ( ( fYPrevTextPosition!= rRect.Y1 ) ) || - ( ( fXPrevTextPosition > rRect.X2 ) ) || - ( ( fXPrevTextPosition+fPrevTextWidth*1.3)<rRect.X1 ) - ) && ( isFirstLine> 0.0 ) - ) + ::basegfx::B2DPoint point1(rRect.X1, rRect.Y1); + ::basegfx::B2DPoint point2(rRect.X2, rRect.Y2); + point1 *= getCurrentContext().Transformation; + point2 *= getCurrentContext().Transformation; + + if ((fYPrevTextPosition != point1.getY()) || + (fXPrevTextPosition > point2.getX()) || + ((fXPrevTextPosition + fPrevTextWidth * 1.3) < point1.getX())) { processGlyphLine(); } @@ -288,12 +292,11 @@ void PDFIProcessor::drawGlyphLine( const OUString& rGlyphs, getGCId(getCurrentContext()); - m_GlyphsList.push_back( aGlyph ); + m_GlyphsList.push_back(aGlyph); - fYPrevTextPosition = rRect.Y1; - fXPrevTextPosition = rRect.X2; - fPrevTextHeight = rRect.Y2-rRect.Y1; - fPrevTextWidth = rRect.X2-rRect.X1; + fYPrevTextPosition = point1.getY(); + fXPrevTextPosition = point2.getX(); + fPrevTextWidth = point2.getX() - point1.getX(); } GraphicsContext& PDFIProcessor::getTransformGlyphContext( CharGlyph& rGlyph ) diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.hxx b/sdext/source/pdfimport/tree/pdfiprocessor.hxx index 979e17015c2b..f2b02bdc1b42 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.hxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.hxx @@ -67,7 +67,6 @@ namespace pdfi com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; double fYPrevTextPosition; - double fPrevTextHeight; double fXPrevTextPosition; double fPrevTextWidth; enum DocumentTextDirecion { LrTb, RlTb, TbLr }; |