summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-10-14 16:31:13 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-10-14 16:54:39 +0200
commit05e9de8d69dd9a2194f6f561fa77c0c61534e9a8 (patch)
treea0159d85f8ee622883a6c9e80aba05a25967d7a7
parentc9a3695857f3c616dcfe3503616be961ed4c8987 (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/CppunitTest_sw_odfimport.mk sw/qa/extras/odfimport/odfimport.cxx Change-Id: I64e969ef5e8f519314f5613f8e6fae626ae085ce
-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 a37b4380fa25..41357beec095 100644
--- a/sw/CppunitTest_sw_odfimport.mk
+++ b/sw/CppunitTest_sw_odfimport.mk
@@ -56,6 +56,9 @@ $(eval $(call gb_CppunitTest_use_components,sw_odfimport,\
configmgr/source/configmgr \
embeddedobj/util/embobj \
filter/source/config/cache/filterconfig1 \
+ 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 e7fa8fbe4743..f1651bdcb6e7 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -13,6 +13,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>
@@ -462,6 +463,16 @@ DECLARE_ODFIMPORT_TEST(testSpellmenuRedline, "spellmenu-redline.odt")
CPPUNIT_ASSERT_EQUAL(sal_uInt16(FN_REDLINE_PREV_CHANGE), aPopup.GetItemId(aPopup.GetItemCount() - 1));
}
+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 6b0eed62c6c6..c4a9033b6e79 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -999,10 +999,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;