summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-14 16:31:13 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-10-14 16:30:05 +0000
commitbea74d73f4782b17f5286327f15db60ab3ae85de (patch)
treee227a6d0f402e20b9b2879b9d1a5441f40bdb119
parentffa12f6502af07c257aabd5198854b3b7c03d0da (diff)
bnc#800714 SwTxtFrm::FormatAdjust: still call SplitFrm if we have columns
Regression from c5a8a2c3cbcee0175127a0662e3d820ea4deea22 (sw34bf05: i#84870 - method <SwTxtFrm::FormatAdjust(..)> - do not split text frame which only contains on as-character anchored object, 2011-03-11), the i#84870 fix was for a document which didn't have columns, and didn't consider that this causes a layout loop in case: 1) There are two paragraphs in a section, having multiple columns. 2) The second paragraph has fo:keep-together="always". In this case originally we tried to call SplitFrm(), realized that it didn't help, and then gave up. But after the change, we kept trying to satisfy the two conflicting requirements (balance content in the 3 columns vs keep the second paragraph with the first one). Fix the problem by not calling SplitFrm() only in case we're not inside columns. (cherry picked from commit 2d35baed5e87ffe7ca371986391cdb3983cdd2b1) Conflicts: sw/qa/extras/odfimport/odfimport.cxx Change-Id: I64e969ef5e8f519314f5613f8e6fae626ae085ce Reviewed-on: https://gerrit.libreoffice.org/11973 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/CppunitTest_sw_odfimport.mk3
-rw-r--r--sw/qa/extras/odfimport/data/bnc800714.fodt35
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx11
-rw-r--r--sw/source/core/text/frmform.cxx7
4 files changed, 55 insertions, 1 deletions
diff --git a/sw/CppunitTest_sw_odfimport.mk b/sw/CppunitTest_sw_odfimport.mk
index 60424f696972..e57d308f1c58 100644
--- a/sw/CppunitTest_sw_odfimport.mk
+++ b/sw/CppunitTest_sw_odfimport.mk
@@ -57,6 +57,9 @@ $(eval $(call gb_CppunitTest_use_components,sw_odfimport,\
embeddedobj/util/embobj \
filter/source/config/cache/filterconfig1 \
filter/source/storagefilterdetect/storagefd \
+ filter/source/odfflatxml/odfflatxml \
+ filter/source/xmlfilterdetect/xmlfd \
+ filter/source/xmlfilteradaptor/xmlfa \
framework/util/fwk \
i18npool/util/i18npool \
lingucomponent/source/languageguessing/guesslang \
diff --git a/sw/qa/extras/odfimport/data/bnc800714.fodt b/sw/qa/extras/odfimport/data/bnc800714.fodt
new file mode 100644
index 000000000000..a759b7c843a1
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/bnc800714.fodt
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:automatic-styles>
+ <style:style style:name="P1" style:family="paragraph"/>
+ <style:style style:name="P2" style:family="paragraph">
+ <style:paragraph-properties fo:keep-with-next="always"/>
+ </style:style>
+ <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame">
+ <style:graphic-properties style:vertical-pos="top" style:vertical-rel="baseline"/>
+ </style:style>
+ <style:style style:name="Sect1" style:family="section">
+ <style:section-properties text:dont-balance-text-columns="false" style:editable="false">
+ <style:columns fo:column-count="3" fo:column-gap="0cm">
+ <style:column style:rel-width="21845*" fo:start-indent="0cm" fo:end-indent="0cm"/>
+ <style:column style:rel-width="21845*" fo:start-indent="0cm" fo:end-indent="0cm"/>
+ <style:column style:rel-width="21845*" fo:start-indent="0cm" fo:end-indent="0cm"/>
+ </style:columns>
+ </style:section-properties>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:p text:style-name="P1">Before.</text:p>
+ <text:section text:style-name="Sect1" text:name="Section1">
+ <text:p text:style-name="P2"><draw:frame draw:style-name="fr1" draw:name="Frame1" text:anchor-type="as-char" svg:width="2cm" draw:z-index="0">
+ <draw:text-box fo:min-height="0.439cm">
+ <text:p/>
+ </draw:text-box>
+ </draw:frame></text:p>
+ <text:p text:style-name="P1">Frame.</text:p>
+ </text:section>
+ <text:p text:style-name="P1">After.</text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 36aa4374639e..8ca92c01ee92 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -14,6 +14,7 @@
#include <com/sun/star/style/PageStyleLayout.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/text/XTextSection.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <wrtsh.hxx>
@@ -513,6 +514,16 @@ DECLARE_ODFIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.odt")
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xParagraph, 2), "CharWeight"));
}
+DECLARE_ODFIMPORT_TEST(testBnc800714, "bnc800714.fodt")
+{
+ // Document's second paragraph wants to be together with the third one, but:
+ // - it's in a section with multiple columns
+ // - contains a single as-char anchored frame
+ // This was a layout loop.
+ CPPUNIT_ASSERT(getProperty< uno::Reference<text::XTextSection> >(getParagraph(2), "TextSection").is());
+ CPPUNIT_ASSERT(getProperty<bool>(getParagraph(2), "ParaKeepTogether"));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 1d688d88718b..3699c3907f43 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -978,10 +978,15 @@ void SwTxtFrm::FormatAdjust( SwTxtFormatter &rLine,
? 1 : 0;
// --> OD #i84870#
// no split of text frame, which only contains a as-character anchored object
- const bool bOnlyContainsAsCharAnchoredObj =
+ bool bOnlyContainsAsCharAnchoredObj =
!IsFollow() && nStrLen == 1 &&
GetDrawObjs() && GetDrawObjs()->Count() == 1 &&
(*GetDrawObjs())[0]->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR;
+
+ // Still try split text frame if we have columns.
+ if (FindColFrm())
+ bOnlyContainsAsCharAnchoredObj = false;
+
if ( nNew && bOnlyContainsAsCharAnchoredObj )
{
nNew = 0;