Kaydet (Commit) 7758d660 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#117245 sw layout: extend TabOverMargin compat mode

This layout compatibility flag is supposed to mimic Word behavior, but
in both cases we failed to lay out the text as Word does.

Change-Id: Ic6fb2eb16ce3670d23aeb9f17bd7043f55164883
Reviewed-on: https://gerrit.libreoffice.org/54087Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 02607734
......@@ -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();
......
......@@ -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();
......
......@@ -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,
......
......@@ -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;
......
......@@ -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() );
......
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