[Libreoffice-commits] core.git: sw/qa sw/source
Adam Co
rattles2013 at gmail.com
Fri Aug 30 08:57:20 PDT 2013
sw/qa/extras/ooxmlexport/data/fdo68418.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 18 ++++++++++++++++++
sw/source/filter/ww8/writerwordglue.cxx | 26 +++++++++++++++++++++++++-
sw/source/filter/ww8/writerwordglue.hxx | 16 ++++++++++++++++
4 files changed, 59 insertions(+), 1 deletion(-)
New commits:
commit 196328c91ee889a0a1cbc39ce2549c7405afbef5
Author: Adam Co <rattles2013 at gmail.com>
Date: Tue Aug 20 18:27:41 2013 +0300
fix for IsPlausibleSingleWordSection checking wrong condition
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I503e5944079b6c03413caea27ef940efbd44ced5
Reviewed-on: https://gerrit.libreoffice.org/5548
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/qa/extras/ooxmlexport/data/fdo68418.docx b/sw/qa/extras/ooxmlexport/data/fdo68418.docx
new file mode 100644
index 0000000..10b7c00
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo68418.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0f1e500..b9c5ba7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -113,6 +113,7 @@ public:
void testFdo67737();
void testTransparentShadow();
void testBnc834035();
+ void testFdo68418();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -202,6 +203,7 @@ void Test::run()
{"fdo67737.docx", &Test::testFdo67737},
{"transparent-shadow.docx", &Test::testTransparentShadow},
{"bnc834035.odt", &Test::testBnc834035},
+ {"fdo68418.docx", &Test::testFdo68418},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -1232,6 +1234,22 @@ void Test::testBnc834035()
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:hyperlink", "anchor", "_Toc363553908");
}
+void Test::testFdo68418()
+{
+ // The problem was that in 'MSWordExportBase::SectionProperties' function in 'wrt8sty.cxx'
+ // it checked if it 'IsPlausableSingleWordSection'.
+ // The 'IsPlausableSingleWordSection' compared different aspects of 2 'SwFrmFmt' objects.
+ // One of the checks was 'do both formats have the same distance from the top and bottom ?'
+ // This check is correct if both have headers or both don't have headers.
+ // However - if one has a header, and the other one has an empty header (no header) - it is not correct to compare
+ // between them (same goes for 'footer').
+ uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText");
+ uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText );
+
+ // First page footer is empty, second page footer is 'aaaa'
+ CPPUNIT_ASSERT_EQUAL(OUString("aaaa"), xFooterParagraph->getString()); // I get an error that it expects ''
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 5e3215e..18968d0 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -371,7 +371,7 @@ namespace sw
HdFtDistanceGlue aOne(rTitleFmt.GetAttrSet());
HdFtDistanceGlue aTwo(rFollowFmt.GetAttrSet());
//e.g. #i14509#
- if (!aOne.EqualTopBottom(aTwo))
+ if (!aOne.StrictEqualTopBottom(aTwo))
bPlausableSingleWordSection = false;
}
return bPlausableSingleWordSection;
@@ -424,6 +424,30 @@ namespace sw
return (dyaTop == rOther.dyaTop && dyaBottom == rOther.dyaBottom);
}
+ bool HdFtDistanceGlue::StrictEqualTopBottom(const HdFtDistanceGlue &rOther)
+ const
+ {
+ // Check top only if both object have a header or if
+ // both object don't have a header
+ if ( ( HasHeader() && rOther.HasHeader() ) ||
+ ( !HasHeader() && !rOther.HasHeader() ) )
+ {
+ if (dyaTop != rOther.dyaTop)
+ return false;
+ }
+
+ // Check bottom only if both object have a footer or if
+ // both object don't have a footer
+ if ( ( HasFooter() && rOther.HasFooter() ) ||
+ ( !HasFooter() && !rOther.HasFooter() ) )
+ {
+ if (dyaBottom != rOther.dyaBottom)
+ return false;
+ }
+
+ return true;
+ }
+
ParaStyleMapper::ParaStyleMapper(SwDoc &rDoc)
: mpImpl(new myImplHelpers::StyleMapperImpl<SwTxtFmtColl>(rDoc))
{
diff --git a/sw/source/filter/ww8/writerwordglue.hxx b/sw/source/filter/ww8/writerwordglue.hxx
index 423eddb..263a13e 100644
--- a/sw/source/filter/ww8/writerwordglue.hxx
+++ b/sw/source/filter/ww8/writerwordglue.hxx
@@ -146,6 +146,22 @@ namespace sw
*/
bool EqualTopBottom(const HdFtDistanceGlue &rOther) const;
+ /** Is the top of the page the same in both objects
+ when there are headers\footers present or non-present in both objects
+
+ This test is important, because we would like to ignore cases
+ when there is a header in one object and no header in the second
+ object - because it is wrong to compare between them.
+
+ @param
+ rOther the other HdFtDistanceGlue to compare against
+
+ @return true if the main text areas top and bottom is at the
+ same location, false otherwise (assuming both objects have\don't have
+ a header\footer)
+ */
+ bool StrictEqualTopBottom(const HdFtDistanceGlue &rOther) const;
+
};
}
}
More information about the Libreoffice-commits
mailing list