Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/4233

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/33/4233/1

fdo#64238: fix for missing footer bug

Change-Id: I328547c41bfc1a23f7e6233db57fbfa415e22cb3
---
A sw/qa/extras/ooxmlexport/data/fdo64238_a.docx
A sw/qa/extras/ooxmlexport/data/fdo64238_b.docx
M sw/qa/extras/ooxmlexport/ooxmlexport.cxx
M writerfilter/source/dmapper/DomainMapper_Impl.cxx
M writerfilter/source/dmapper/DomainMapper_Impl.hxx
5 files changed, 99 insertions(+), 27 deletions(-)



diff --git a/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx 
b/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx
new file mode 100644
index 0000000..7c43fea
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx 
b/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx
new file mode 100644
index 0000000..bfaf92c
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ca6fad6..1295e28 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -72,6 +72,8 @@
     void testI120928();
     void testFdo64826();
     void testPageBackground();
+    void testFdo64238_a();
+    void testFdo64238_b();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -121,6 +123,8 @@
         {"i120928.docx", &Test::testI120928},
         {"fdo64826.docx", &Test::testFdo64826},
         {"page-background.docx", &Test::testPageBackground},
+        {"fdo64238_a.docx", &Test::testFdo64238_a},
+        {"fdo64238_b.docx", &Test::testFdo64238_b},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -688,6 +692,46 @@
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
 }
 
+void Test::testFdo64238_a()
+{
+    // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer 
*was filled*
+    // then LO would still import the Even footer and concatenate it to to the odd footer.
+    // This case specifically is for :
+    // 'Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in 
Word
+    // In this case the imported footer in LO was supposed to be blank, but instead was the 'even' 
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 );
+    uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+    int numOfRuns = 0;
+    while (xRunEnum->hasMoreElements())
+    {
+        uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+        numOfRuns++;
+    }
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), numOfRuns);
+}
+
+void Test::testFdo64238_b()
+{
+    // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer 
*was filled*
+    // then LO would still import the Even footer and concatenate it to to the odd footer.
+    // This case specifically is for :
+    // 'Non-Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked 
in Word
+    // In this case the imported footer in LO was supposed to be just the odd footer, but instead 
was the 'odd' and 'even' footers concatenated
+    uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> 
(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText");
+    uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText );
+    uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+    int numOfRuns = 0;
+    while (xRunEnum->hasMoreElements())
+    {
+        uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+        numOfRuns++;
+    }
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index fbc633d..6734e75 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -175,6 +175,7 @@
         m_bInStyleSheetImport( false ),
         m_bInAnyTableImport( false ),
         m_bInHeaderFooterImport( false ),
+        m_bDiscardHeaderFooter( false ),
         m_bLineNumberingSet( false ),
         m_bIsInFootnoteProperties( true ),
         m_bIsCustomFtnMark( false ),
@@ -1174,10 +1175,15 @@
 
     return aDateTime;
 }
+
 void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapPtr pPropertyMap )
 {
+    if (m_bDiscardHeaderFooter)
+        return;
+
     if (m_aTextAppendStack.empty())
         return;
+
     if( pPropertyMap == m_pTopContext && !deferredCharacterProperties.empty())
         processDeferredCharacterProperties();
     uno::Reference< text::XTextAppend >  xTextAppend = m_aTextAppendStack.top().xTextAppend;
@@ -1370,21 +1376,28 @@
             return;
         try
         {
-            PropertyNameSupplier& rPropNameSupplier = 
PropertyNameSupplier::GetPropertyNameSupplier();
-            //switch on header use
-            xPageStyle->setPropertyValue(
-                    rPropNameSupplier.GetName(PROP_HEADER_IS_ON),
-                    uno::makeAny(sal_True) );
-            // if a left header is available then header are not shared
             bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
-            if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
-                xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_SHARED), 
uno::makeAny( false ));
+            if ((!bLeft && !m_pSettingsTable->GetEvenAndOddHeaders()) || 
(m_pSettingsTable->GetEvenAndOddHeaders()))
+            {
+                PropertyNameSupplier& rPropNameSupplier = 
PropertyNameSupplier::GetPropertyNameSupplier();
+                //switch on header use
+                xPageStyle->setPropertyValue(
+                        rPropNameSupplier.GetName(PROP_HEADER_IS_ON),
+                        uno::makeAny(sal_True) );
+                // if a left header is available then header are not shared
+                if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
+                    xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_SHARED), 
uno::makeAny( false ));
 
-            //set the interface
-            uno::Reference< text::XText > xHeaderText;
-            xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? PROP_HEADER_TEXT_LEFT 
: PROP_HEADER_TEXT) ) >>= xHeaderText;
-            m_aTextAppendStack.push( TextAppendContext(uno::Reference< text::XTextAppend >( 
xHeaderText, uno::UNO_QUERY_THROW),
-                        m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : 
m_xBodyText->createTextCursorByRange(xHeaderText->getStart())));
+                //set the interface
+                uno::Reference< text::XText > xHeaderText;
+                xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? 
PROP_HEADER_TEXT_LEFT : PROP_HEADER_TEXT) ) >>= xHeaderText;
+                m_aTextAppendStack.push( TextAppendContext(uno::Reference< text::XTextAppend >( 
xHeaderText, uno::UNO_QUERY_THROW),
+                            m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : 
m_xBodyText->createTextCursorByRange(xHeaderText->getStart())));
+            }
+            else
+            {
+                m_bDiscardHeaderFooter = true;
+            }
         }
         catch( const uno::Exception& )
         {
@@ -1412,20 +1425,28 @@
             return;
         try
         {
-            PropertyNameSupplier& rPropNameSupplier = 
PropertyNameSupplier::GetPropertyNameSupplier();
-            //switch on footer use
-            xPageStyle->setPropertyValue(
-                    rPropNameSupplier.GetName(PROP_FOOTER_IS_ON),
-                    uno::makeAny(sal_True) );
-            // if a left header is available then footer is not shared
             bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
-            if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
-                xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_SHARED), 
uno::makeAny( false ));
-            //set the interface
-            uno::Reference< text::XText > xFooterText;
-            xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? PROP_FOOTER_TEXT_LEFT 
: PROP_FOOTER_TEXT) ) >>= xFooterText;
-            m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >( 
xFooterText, uno::UNO_QUERY_THROW ),
-                        m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : 
m_xBodyText->createTextCursorByRange(xFooterText->getStart())));
+            if ((!bLeft && !m_pSettingsTable->GetEvenAndOddHeaders()) || 
(m_pSettingsTable->GetEvenAndOddHeaders()))
+            {
+                PropertyNameSupplier& rPropNameSupplier = 
PropertyNameSupplier::GetPropertyNameSupplier();
+                //switch on footer use
+                xPageStyle->setPropertyValue(
+                        rPropNameSupplier.GetName(PROP_FOOTER_IS_ON),
+                        uno::makeAny(sal_True) );
+                // if a left header is available then footer is not shared
+                bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
+                if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
+                    xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_SHARED), 
uno::makeAny( false ));
+                //set the interface
+                uno::Reference< text::XText > xFooterText;
+                xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? 
PROP_FOOTER_TEXT_LEFT : PROP_FOOTER_TEXT) ) >>= xFooterText;
+                m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >( 
xFooterText, uno::UNO_QUERY_THROW ),
+                            m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : 
m_xBodyText->createTextCursorByRange(xFooterText->getStart())));
+            }
+            else
+            {
+                m_bDiscardHeaderFooter = true;
+            }
         }
         catch( const uno::Exception& )
         {
@@ -1440,7 +1461,13 @@
     //this has to be removed
     RemoveLastParagraph( );
     if (!m_aTextAppendStack.empty())
-        m_aTextAppendStack.pop();
+    {
+        if (!m_bDiscardHeaderFooter)
+        {
+            m_aTextAppendStack.pop();
+        }
+        m_bDiscardHeaderFooter = false;
+    }
     m_bInHeaderFooterImport = false;
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index dc7f2dd..e44316d 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -344,6 +344,7 @@
     bool                            m_bInStyleSheetImport; //in import of fonts, styles, lists or 
lfos
     bool                            m_bInAnyTableImport; //in import of fonts, styles, lists or 
lfos
     bool                            m_bInHeaderFooterImport;
+    bool                            m_bDiscardHeaderFooter;
 
     bool                            m_bLineNumberingSet;
     bool                            m_bIsInFootnoteProperties;

-- 
To view, visit https://gerrit.libreoffice.org/4233
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I328547c41bfc1a23f7e6233db57fbfa415e22cb3
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Adam CloudOn <rattles2013@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.