Kaydet (Commit) 385852e9 authored tarafından Miklos Vajna's avatar Miklos Vajna

sw::util::IsPlausableSingleWordSection: take care of Boxes if LRSpace differs

The problem was the following: due to borders, the LR space items were
not equal, but we still want to merge the page styles, as they only
differ due to the page border.

Change-Id: I55069368edba27ab9c70421e5e71ca24c73350e9
üst 08416eb7
......@@ -3810,6 +3810,14 @@ DECLARE_OOXMLEXPORT_TEST(testSdtCitationRun, "sdt-citation-run.docx")
}
}
DECLARE_OOXMLEXPORT_TEST(testPlausableBorder, "plausable-border.docx")
{
// sw::util::IsPlausableSingleWordSection() did not merge two page styles due to borders.
if (xmlDocPtr pXmlDoc = parseExport())
// Page break was exported as section break, this was 0
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -334,6 +334,23 @@ namespace myImplHelpers
};
}
/// Count what Word calls left/right margin from a format's LRSpace + Box.
static SvxLRSpaceItem lcl_getWordLRSpace(const SwFrmFmt& rFmt)
{
SvxLRSpaceItem aLR(rFmt.GetLRSpace());
const SvxBoxItem& rBox = rFmt.GetBox();
aLR.SetLeft(aLR.GetLeft() + rBox.GetDistance(BOX_LINE_LEFT));
if (const editeng::SvxBorderLine* pLeft = rBox.GetLeft())
aLR.SetLeft(aLR.GetLeft() + pLeft->GetWidth());
aLR.SetRight(aLR.GetRight() + rBox.GetDistance(BOX_LINE_RIGHT));
if (const editeng::SvxBorderLine* pRight = rBox.GetRight())
aLR.SetRight(aLR.GetRight() + pRight->GetWidth());
return aLR;
}
namespace sw
{
namespace util
......@@ -347,8 +364,8 @@ namespace sw
const SwFmtCol& rFollowCols = rFollowFmt.GetCol();
const SwColumns& rFirstColumns = rFirstCols.GetColumns();
const SwColumns& rFollowColumns = rFollowCols.GetColumns();
const SvxLRSpaceItem &rOneLR = rTitleFmt.GetLRSpace();
const SvxLRSpaceItem &rTwoLR= rFollowFmt.GetLRSpace();
SvxLRSpaceItem aOneLR = lcl_getWordLRSpace(rTitleFmt);
SvxLRSpaceItem aTwoLR = lcl_getWordLRSpace(rFollowFmt);
const SwFmtFrmSize& rFirstFrmSize = rTitleFmt.GetFrmSize();
const SwFmtFrmSize& rFollowFrmSize = rFollowFmt.GetFrmSize();
......@@ -357,7 +374,7 @@ namespace sw
//e.g. #i4320#
bPlausableSingleWordSection = false;
}
else if (rOneLR != rTwoLR)
else if (aOneLR != aTwoLR)
bPlausableSingleWordSection = false;
else if (rFirstFrmSize != rFollowFrmSize)
bPlausableSingleWordSection = false;
......
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