summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAdam Co <rattles2013@gmail.com>2013-08-20 18:27:41 +0300
committerCaolán McNamara <caolanm@redhat.com>2013-08-30 15:56:57 +0000
commit196328c91ee889a0a1cbc39ce2549c7405afbef5 (patch)
tree9b180b9507a583f2dd34fd3ab36f5df43ee6954e /sw
parentd07e7d692ddd2a9ab956a59bcc0f676c7d76bc10 (diff)
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@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo68418.docxbin0 -> 13897 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx18
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx26
-rw-r--r--sw/source/filter/ww8/writerwordglue.hxx16
4 files changed, 59 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo68418.docx b/sw/qa/extras/ooxmlexport/data/fdo68418.docx
new file mode 100644
index 000000000000..10b7c009c2a5
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo68418.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0f1e500e5ca6..b9c5ba77fd77 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 5e3215e7b3c0..18968d060bd6 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 423eddba763d..263a13ebabca 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;
+
};
}
}