diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-16 16:48:35 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-07-16 18:16:05 +0200 |
commit | 385852e9add39081f8e915bd88ad8560630762a2 (patch) | |
tree | f96019e9db305f66d857962e0b50689532b6cd57 /sw | |
parent | 08416eb7aa4b07254f92113c519568e8596a91a2 (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/plausable-border.docx | bin | 0 -> 15737 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerwordglue.cxx | 23 |
3 files changed, 28 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/plausable-border.docx b/sw/qa/extras/ooxmlexport/data/plausable-border.docx Binary files differnew file mode 100644 index 000000000000..a1a95470a057 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/plausable-border.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 0e69a541540c..a5aa50d31908 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -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: */ diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index ddc83138ed0e..f6b1f0db0b25 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -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; |