[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/qa sw/source

Luke Deller luke at deller.id.au
Wed Jul 9 04:22:04 PDT 2014


 sw/qa/extras/ww8import/data/fdo77844.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx     |   47 +++++++++++++++++++++++++++++++
 sw/source/filter/ww8/ww8par.cxx          |   15 ++++++++-
 3 files changed, 60 insertions(+), 2 deletions(-)

New commits:
commit 025a9cf3a8ceba61d8424d7dcb029ab9607a0d73
Author: Luke Deller <luke at deller.id.au>
Date:   Sun Jul 6 23:19:18 2014 +1000

    fix fdo#77844: header wrongly enabled from .doc
    
    The LO page style needs page headers to be turned on if the
    corresponding .doc file section has a left (=even) page header or a
    first page header.
    
    However this should not be triggered in the case where a first page
    header is present but hidden due to the "different first page" header
    option being disabled. This case is fixed by this commit.
    
    Change-Id: If3de0df45378587fdbdecc6a091d2f4b60940b43
    Reviewed-on: https://gerrit.libreoffice.org/10100
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit f312ef98de57a5926be67421395544bb9d41b809)
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/ww8import/data/fdo77844.doc b/sw/qa/extras/ww8import/data/fdo77844.doc
new file mode 100755
index 0000000..cd7368d
Binary files /dev/null and b/sw/qa/extras/ww8import/data/fdo77844.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 270d665..147fb88 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -415,6 +415,53 @@ DECLARE_WW8IMPORT_TEST(testBnc875715, "bnc875715.doc")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xSections->getByIndex(0), "SectionLeftMargin"));
 }
 
+DECLARE_WW8IMPORT_TEST(testFdo77844, "fdo77844.doc")
+{
+    uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles");
+
+    // get a page cursor
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+        xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> xCursor(
+        xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+
+    // check that the first page has no header
+    xCursor->jumpToFirstPage();
+    OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
+    uno::Reference<style::XStyle> pageStyle(
+        pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
+    bool headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
+    CPPUNIT_ASSERT(!headerIsOn);
+
+    // check that the second page has a header
+    xCursor->jumpToPage(2);
+    pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
+    pageStyle.set(
+        pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
+    headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
+    CPPUNIT_ASSERT(headerIsOn);
+
+    // check that the third page has a header
+    xCursor->jumpToPage(3);
+    pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
+    pageStyle.set(
+        pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
+    headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
+    CPPUNIT_ASSERT(headerIsOn);
+
+    // check that the fourth page has no header
+    // (#if'd out as this is not yet imported correctly)
+#if 0
+    xCursor->jumpToPage(4);
+    pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
+    pageStyle.set(
+        pageStyles->getByName(pageStyleName), uno::UNO_QUERY);
+    headerIsOn = getProperty<bool>(pageStyle, "HeaderIsOn");
+    CPPUNIT_ASSERT(!headerIsOn);
+#endif
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 9224568..11fafbe 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2377,6 +2377,9 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
         long nLen;
         sal_uInt8 nNumber = 5;
 
+        // This loops through the 6 flags WW8_{FOOTER,HEADER}_{ODD,EVEN,FIRST}
+        // corresponding to bit fields in grpfIhdt indicating which
+        // header/footer(s) are present in this section
         for( sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
         {
             if (nI & grpfIhdt)
@@ -2394,6 +2397,12 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
                     = (nI & ( WW8_HEADER_EVEN | WW8_FOOTER_EVEN )) ? true: false;
                 bool bUseFirst
                     = (nI & ( WW8_HEADER_FIRST | WW8_FOOTER_FIRST )) ? true: false;
+
+                // If we are loading a first-page header/footer which is not
+                // actually enabled in this section (it still needs to be
+                // loaded as it may be inherited by a later section)
+                bool bDisabledFirst = bUseFirst && !rSection.HasTitlePage();
+
                 bool bFooter
                     = (nI & ( WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST )) ? true: false;
 
@@ -2408,7 +2417,8 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
                 {
                     bIsFooter = true;
                     //#i17196# Cannot have left without right
-                    if (!pPD->GetMaster().GetFooter().GetFooterFmt())
+                    if (!bDisabledFirst
+                            && !pPD->GetMaster().GetFooter().GetFooterFmt())
                         pPD->GetMaster().SetFmtAttr(SwFmtFooter(true));
                     if (bUseLeft)
                         pPD->GetLeft().SetFmtAttr(SwFmtFooter(true));
@@ -2420,7 +2430,8 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
                 {
                     bIsHeader = true;
                     //#i17196# Cannot have left without right
-                    if (!pPD->GetMaster().GetHeader().GetHeaderFmt())
+                    if (!bDisabledFirst
+                            && !pPD->GetMaster().GetHeader().GetHeaderFmt())
                         pPD->GetMaster().SetFmtAttr(SwFmtHeader(true));
                     if (bUseLeft)
                         pPD->GetLeft().SetFmtAttr(SwFmtHeader(true));


More information about the Libreoffice-commits mailing list