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>
This commit is contained in:
@@ -48,6 +48,7 @@ $(eval $(call gb_Module_add_check_targets,sw,\
|
|||||||
$(eval $(call gb_Module_add_slowcheck_targets,sw,\
|
$(eval $(call gb_Module_add_slowcheck_targets,sw,\
|
||||||
CppunitTest_sw_htmlexport \
|
CppunitTest_sw_htmlexport \
|
||||||
CppunitTest_sw_macros_test \
|
CppunitTest_sw_macros_test \
|
||||||
|
CppunitTest_sw_ooxmlexport \
|
||||||
CppunitTest_sw_ooxmlimport \
|
CppunitTest_sw_ooxmlimport \
|
||||||
CppunitTest_sw_ww8export \
|
CppunitTest_sw_ww8export \
|
||||||
CppunitTest_sw_ww8import \
|
CppunitTest_sw_ww8import \
|
||||||
|
BIN
sw/qa/extras/ooxmlexport/data/fdo64238_a.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/fdo64238_a.docx
Normal file
Binary file not shown.
BIN
sw/qa/extras/ooxmlexport/data/fdo64238_b.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/fdo64238_b.docx
Normal file
Binary file not shown.
@@ -81,6 +81,8 @@ public:
|
|||||||
void testFDO63053();
|
void testFDO63053();
|
||||||
void testWatermark();
|
void testWatermark();
|
||||||
void testFdo43093();
|
void testFdo43093();
|
||||||
|
void testFdo64238_a();
|
||||||
|
void testFdo64238_b();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(Test);
|
CPPUNIT_TEST_SUITE(Test);
|
||||||
#if !defined(MACOSX) && !defined(WNT)
|
#if !defined(MACOSX) && !defined(WNT)
|
||||||
@@ -136,6 +138,8 @@ void Test::run()
|
|||||||
{"fdo63053.docx" , &Test::testFDO63053},
|
{"fdo63053.docx" , &Test::testFDO63053},
|
||||||
{"watermark.docx", &Test::testWatermark},
|
{"watermark.docx", &Test::testWatermark},
|
||||||
{"fdo43093.docx", &Test::testFdo43093},
|
{"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
|
// Don't test the first import of these, for some reason those tests fail
|
||||||
const char* aBlacklist[] = {
|
const char* aBlacklist[] = {
|
||||||
@@ -808,6 +812,46 @@ void Test::testFdo43093()
|
|||||||
CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir);
|
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_TEST_SUITE_REGISTRATION(Test);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -175,6 +175,7 @@ DomainMapper_Impl::DomainMapper_Impl(
|
|||||||
m_bInStyleSheetImport( false ),
|
m_bInStyleSheetImport( false ),
|
||||||
m_bInAnyTableImport( false ),
|
m_bInAnyTableImport( false ),
|
||||||
m_bInHeaderFooterImport( false ),
|
m_bInHeaderFooterImport( false ),
|
||||||
|
m_bDiscardHeaderFooter( false ),
|
||||||
m_bLineNumberingSet( false ),
|
m_bLineNumberingSet( false ),
|
||||||
m_bIsInFootnoteProperties( true ),
|
m_bIsInFootnoteProperties( true ),
|
||||||
m_bIsCustomFtnMark( false ),
|
m_bIsCustomFtnMark( false ),
|
||||||
@@ -1174,10 +1175,15 @@ util::DateTime lcl_DateStringToDateTime( const OUString& rDateTime )
|
|||||||
|
|
||||||
return aDateTime;
|
return aDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapPtr pPropertyMap )
|
void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapPtr pPropertyMap )
|
||||||
{
|
{
|
||||||
|
if (m_bDiscardHeaderFooter)
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_aTextAppendStack.empty())
|
if (m_aTextAppendStack.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( pPropertyMap == m_pTopContext && !deferredCharacterProperties.empty())
|
if( pPropertyMap == m_pTopContext && !deferredCharacterProperties.empty())
|
||||||
processDeferredCharacterProperties();
|
processDeferredCharacterProperties();
|
||||||
uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
|
uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
|
||||||
@@ -1370,24 +1376,31 @@ void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType)
|
|||||||
return;
|
return;
|
||||||
try
|
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;
|
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
|
//switch on header use
|
||||||
// Even if the 'Even' header is blank - the flag should be imported (so it would look in LO like in Word)
|
xPageStyle->setPropertyValue(
|
||||||
if( m_pSettingsTable->GetEvenAndOddHeaders())
|
rPropNameSupplier.GetName(PROP_HEADER_IS_ON),
|
||||||
xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_SHARED), uno::makeAny( false ));
|
uno::makeAny(sal_True) );
|
||||||
|
|
||||||
//set the interface
|
// If the 'Different Even & Odd Pages' flag is turned on - do not ignore it
|
||||||
uno::Reference< text::XText > xHeaderText;
|
// Even if the 'Even' header is blank - the flag should be imported (so it would look in LO like in Word)
|
||||||
xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? PROP_HEADER_TEXT_LEFT : PROP_HEADER_TEXT) ) >>= xHeaderText;
|
if( m_pSettingsTable->GetEvenAndOddHeaders() )
|
||||||
m_aTextAppendStack.push( TextAppendContext(uno::Reference< text::XTextAppend >( xHeaderText, uno::UNO_QUERY_THROW),
|
xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_SHARED), uno::makeAny( false ));
|
||||||
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& )
|
catch( const uno::Exception& )
|
||||||
{
|
{
|
||||||
@@ -1415,23 +1428,31 @@ void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType)
|
|||||||
return;
|
return;
|
||||||
try
|
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;
|
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
|
//switch on footer use
|
||||||
// Even if the 'Even' footer is blank - the flag should be imported (so it would look in LO like in Word)
|
xPageStyle->setPropertyValue(
|
||||||
if( m_pSettingsTable->GetEvenAndOddHeaders())
|
rPropNameSupplier.GetName(PROP_FOOTER_IS_ON),
|
||||||
xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_SHARED), uno::makeAny( false ));
|
uno::makeAny(sal_True) );
|
||||||
//set the interface
|
|
||||||
uno::Reference< text::XText > xFooterText;
|
// If the 'Different Even & Odd Pages' flag is turned on - do not ignore it
|
||||||
xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? PROP_FOOTER_TEXT_LEFT : PROP_FOOTER_TEXT) ) >>= xFooterText;
|
// Even if the 'Even' footer is blank - the flag should be imported (so it would look in LO like in Word)
|
||||||
m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >( xFooterText, uno::UNO_QUERY_THROW ),
|
if( m_pSettingsTable->GetEvenAndOddHeaders() )
|
||||||
m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : m_xBodyText->createTextCursorByRange(xFooterText->getStart())));
|
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& )
|
catch( const uno::Exception& )
|
||||||
{
|
{
|
||||||
@@ -1446,7 +1467,13 @@ void DomainMapper_Impl::PopPageHeaderFooter()
|
|||||||
//this has to be removed
|
//this has to be removed
|
||||||
RemoveLastParagraph( );
|
RemoveLastParagraph( );
|
||||||
if (!m_aTextAppendStack.empty())
|
if (!m_aTextAppendStack.empty())
|
||||||
m_aTextAppendStack.pop();
|
{
|
||||||
|
if (!m_bDiscardHeaderFooter)
|
||||||
|
{
|
||||||
|
m_aTextAppendStack.pop();
|
||||||
|
}
|
||||||
|
m_bDiscardHeaderFooter = false;
|
||||||
|
}
|
||||||
m_bInHeaderFooterImport = false;
|
m_bInHeaderFooterImport = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -344,6 +344,7 @@ private:
|
|||||||
bool m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
|
bool m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
|
||||||
bool m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
|
bool m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
|
||||||
bool m_bInHeaderFooterImport;
|
bool m_bInHeaderFooterImport;
|
||||||
|
bool m_bDiscardHeaderFooter;
|
||||||
|
|
||||||
bool m_bLineNumberingSet;
|
bool m_bLineNumberingSet;
|
||||||
bool m_bIsInFootnoteProperties;
|
bool m_bIsInFootnoteProperties;
|
||||||
|
Reference in New Issue
Block a user