summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/layout/data/tdf117245.odtbin0 -> 10142 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx14
-rw-r--r--sw/source/core/text/guess.cxx2
-rw-r--r--sw/source/core/text/inftxt.cxx23
-rw-r--r--sw/source/core/text/inftxt.hxx6
-rwxr-xr-xsw/source/core/text/itrform2.cxx2
6 files changed, 45 insertions, 2 deletions
diff --git a/sw/qa/extras/layout/data/tdf117245.odt b/sw/qa/extras/layout/data/tdf117245.odt
new file mode 100644
index 000000000000..7008c325bace
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf117245.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index aa2146354fc0..4d05162a7d74 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -20,12 +20,14 @@ public:
void testTdf116925();
void testTdf117028();
void testTdf116848();
+ void testTdf117245();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testTdf116830);
CPPUNIT_TEST(testTdf116925);
CPPUNIT_TEST(testTdf117028);
CPPUNIT_TEST(testTdf116848);
+ CPPUNIT_TEST(testTdf117245);
CPPUNIT_TEST_SUITE_END();
private:
@@ -117,6 +119,18 @@ void SwLayoutWriter::testTdf116848()
pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout();
}
+void SwLayoutWriter::testTdf117245()
+{
+ createDoc("tdf117245.odt");
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+ // This was 2, TabOverMargin did not use a single line when there was
+ // enough space for the text.
+ assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1);
+
+ // This was 2, same problem elsewhere due to code duplication.
+ assertXPath(pXmlDoc, "/root/page/body/txt[2]/LineBreak", 1);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 5ddf80485522..b3cb3b02d472 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -70,7 +70,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
10000 :
0 ;
- SwTwips nLineWidth = rInf.Width() - rInf.X();
+ SwTwips nLineWidth = rInf.GetLineWidth();
sal_Int32 nMaxLen = rInf.GetText().getLength() - rInf.GetIdx();
const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNode()->GetSwAttrSet().GetAdjust().GetAdjust();
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 65e25af2ee58..d66f946a04ed 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -57,6 +57,7 @@
#include "porftn.hxx"
#include "porrst.hxx"
#include "itratr.hxx"
+#include "portab.hxx"
#include <accessibilityoptions.hxx>
#include <wrong.hxx>
#include <doc.hxx>
@@ -1688,6 +1689,28 @@ bool SwTextFormatInfo::LastKernPortion()
return false;
}
+SwTwips SwTextFormatInfo::GetLineWidth()
+{
+ SwTwips nLineWidth = Width() - X();
+
+ const bool bTabOverMargin = GetTextFrame()->GetTextNode()->getIDocumentSettingAccess()->get(
+ DocumentSettingId::TAB_OVER_MARGIN);
+ if (!bTabOverMargin)
+ return nLineWidth;
+
+ SwTabPortion* pLastTab = GetLastTab();
+ if (!pLastTab)
+ return nLineWidth;
+
+ if (pLastTab->GetTabPos() <= Width())
+ return nLineWidth;
+
+ // Consider tab portions over the printing bounds of the text frame.
+ nLineWidth = pLastTab->GetTabPos() - X();
+
+ return nLineWidth;
+}
+
SwTextSlot::SwTextSlot(
const SwTextSizeInfo *pNew,
const SwLinePortion *pPor,
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index 91f7ef655fb0..ac85d3da4281 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -540,6 +540,12 @@ public:
void Width( const sal_uInt16 nNew ) { m_nWidth = nNew; }
void Init();
+ /**
+ * Returns the distance between the current horizontal position and the end
+ * of the line.
+ */
+ SwTwips GetLineWidth();
+
// Returns the first changed position of the paragraph
inline sal_Int32 GetReformatStart() const;
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 39f68943cb91..f8b8b16c679b 100755
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -979,7 +979,7 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
sal_Int32( pPor->GetAscent() ) ) / 8;
if ( !nExpect )
nExpect = 1;
- nExpect = rInf.GetIdx() + ((rInf.Width() - rInf.X()) / nExpect);
+ nExpect = rInf.GetIdx() + (rInf.GetLineWidth() / nExpect);
if( nExpect > rInf.GetIdx() && nNextChg > nExpect )
nNextChg = std::min( nExpect, rInf.GetText().getLength() );