Fix outline numbering for ooxml import filter.

Conflicts:
	sw/qa/extras/ooxmlimport/ooxmlimport.cxx
Reviewed on:
	https://gerrit.libreoffice.org/12519

Change-Id: Ifd8a562bcee4f57cc99ed3215e6d8d6dd95216b0
This commit is contained in:
Mark Hung
2014-11-17 13:13:10 -08:00
committed by Miklos Vajna
parent 24714f5eaa
commit 29a91e4739
3 changed files with 29 additions and 5 deletions

Binary file not shown.

View File

@@ -2532,6 +2532,30 @@ DECLARE_OOXMLIMPORT_TEST(testFdo85542, "fdo85542.docx")
uno::Reference<text::XTextRange> xTextNeighborhood(xNeighborhoodCursor, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(xTextNeighborhood->getString(), OUString("AB"));
}
DECLARE_OOXMLIMPORT_TEST(testChtOutlineNumberingOoxml, "chtoutline.docx")
{
const sal_Unicode aExpectedPrefix[2] = { 0x7b2c, 0x0020 };
const sal_Unicode aExpectedSuffix[2] = { 0x0020, 0x7ae0 };
uno::Reference< text::XChapterNumberingSupplier > xChapterNumberingSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference< container::XIndexAccess> xLevels(xChapterNumberingSupplier->getChapterNumberingRules());
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex(0) >>= aProps; // 1st level
OUString aSuffix,aPrefix;
for (int i = 0; i < aProps.getLength(); ++i)
{
const beans::PropertyValue& rProp = aProps[i];
if (rProp.Name == "Suffix")
aSuffix = rProp.Value.get<OUString>();
if (rProp.Name == "Prefix")
aPrefix = rProp.Value.get<OUString>();
}
CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix,SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();

View File

@@ -147,11 +147,11 @@ void ListLevel::SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle )
// AFAICT .docx spec does not identify which numberings or paragraph
// styles are actually the ones to be used for outlines (chapter numbering),
// it only kind of says somewhere that they should be named Heading1 to Heading9.
const OUString styleId = pStyle->sStyleIdentifierD;
m_outline = ( styleId.getLength() == RTL_CONSTASCII_LENGTH( "Heading1" )
&& styleId.match( "Heading", 0 )
&& styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] >= '1'
&& styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] <= '9' );
const OUString styleId= pStyle->sConvertedStyleName;
m_outline = ( styleId.getLength() == RTL_CONSTASCII_LENGTH( "Heading 1" )
&& styleId.match( "Heading ", 0 )
&& styleId[ RTL_CONSTASCII_LENGTH( "Heading " ) ] >= '1'
&& styleId[ RTL_CONSTASCII_LENGTH( "Heading " ) ] <= '9' );
}
sal_Int16 ListLevel::GetParentNumbering( const OUString& sText, sal_Int16 nLevel,