diff options
author | Adam Co <rattles2013@gmail.com> | 2013-06-12 15:06:42 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-06-19 14:31:38 +0200 |
commit | 782adba4d436c65cdf85d48f28486321873b15ed (patch) | |
tree | d290af4203b229a4e8fb6db83e1a0a46b96d9cf7 | |
parent | 8c1d1b66904cdd95e8eec746a81cf1c57ad0e85a (diff) |
fdo#64238: fix for missing footer bug
Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I328547c41bfc1a23f7e6233db57fbfa415e22cb3
Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo64238_a.docx | bin | 0 -> 16401 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo64238_b.docx | bin | 0 -> 14359 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 44 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 91 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 1 |
6 files changed, 105 insertions, 32 deletions
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index d8ca65ecc151..202c67c4fc35 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -48,6 +48,7 @@ $(eval $(call gb_Module_add_check_targets,sw,\ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_htmlexport \ CppunitTest_sw_macros_test \ + CppunitTest_sw_ooxmlexport \ CppunitTest_sw_ooxmlimport \ CppunitTest_sw_ww8export \ CppunitTest_sw_ww8import \ diff --git a/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx b/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx Binary files differnew file mode 100644 index 000000000000..7c43feaf75a7 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo64238_a.docx diff --git a/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx b/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx Binary files differnew file mode 100644 index 000000000000..bfaf92cca2fc --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo64238_b.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 1cfc0aec25f9..3dbb0a45febf 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -81,6 +81,8 @@ public: void testFDO63053(); void testWatermark(); void testFdo43093(); + void testFdo64238_a(); + void testFdo64238_b(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -136,6 +138,8 @@ void Test::run() {"fdo63053.docx" , &Test::testFDO63053}, {"watermark.docx", &Test::testWatermark}, {"fdo43093.docx", &Test::testFdo43093}, + {"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[] = { @@ -808,6 +812,46 @@ void Test::testFdo43093() CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); } +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 c822739168d7..0ffbc9307ef3 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -175,6 +175,7 @@ DomainMapper_Impl::DomainMapper_Impl( 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 @@ util::DateTime lcl_DateStringToDateTime( const OUString& rDateTime ) 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,24 +1376,31 @@ void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType) 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()) || (m_pSettingsTable->GetEvenAndOddHeaders())) + { + PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); - // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it - // Even if the 'Even' header is blank - the flag should be imported (so it would look in LO like in Word) - if( 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()))); + //switch on header use + xPageStyle->setPropertyValue( + rPropNameSupplier.GetName(PROP_HEADER_IS_ON), + uno::makeAny(sal_True) ); + + // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it + // Even if the 'Even' header is blank - the flag should be imported (so it would look in LO like in Word) + if( 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()))); + } + else + { + m_bDiscardHeaderFooter = true; + } } catch( const uno::Exception& ) { @@ -1415,23 +1428,31 @@ void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType) 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()) || (m_pSettingsTable->GetEvenAndOddHeaders())) + { + PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); - // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it - // Even if the 'Even' footer is blank - the flag should be imported (so it would look in LO like in Word) - if( 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()))); + //switch on footer use + xPageStyle->setPropertyValue( + rPropNameSupplier.GetName(PROP_FOOTER_IS_ON), + uno::makeAny(sal_True) ); + + // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it + // Even if the 'Even' footer is blank - the flag should be imported (so it would look in LO like in Word) + if( 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& ) { @@ -1446,7 +1467,13 @@ void DomainMapper_Impl::PopPageHeaderFooter() //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 f88f49441f01..374cdf5cb0c6 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -344,6 +344,7 @@ private: 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; |