fdo#73596 Added support to import and export \r,\h Index flags.

This supports \r flag run-in type index. If \r is specified then we don't
have to write \e flag (separator char).
\h is Alphabetic separator, where indexes are grouped as per starting
character.

Change-Id: I690b29cef3d24b2a71b01f1deef0e418162d71aa
Reviewed-on: https://gerrit.libreoffice.org/8099
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
Nikhil Walvekar 2014-02-17 20:46:18 +05:30 committed by Miklos Vajna
parent 5490f585f0
commit d043c9e3be
6 changed files with 52 additions and 1 deletions

View File

@ -580,6 +580,23 @@ protected:
nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes));
}
/**
* Assert that rXPath exists, and returns exactly nNumberOfNodes nodes.
* Useful for checking that we do _not_ export some node (nNumberOfNodes == 0).
*/
void assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent)
{
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("XPath '" + rXPath + "' not found").getStr(),
1, xmlXPathNodeSetGetLength(pXmlNodes));
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
CPPUNIT_ASSERT_EQUAL_MESSAGE("XPath contents do not match",rContent,contents);
}
/**
* Assert that rXPath exists, and has exactly nNumberOfChildNodes child nodes.
* Useful for checking that we do have a no child nodes to a specific node (nNumberOfChildNodes == 0).

Binary file not shown.

View File

@ -2348,6 +2348,27 @@ DECLARE_OOXMLEXPORT_TEST(testFdo73541,"fdo73541.docx")
assertXPath(pXmlDoc, "/w:settings/w:mirrorMargins");
}
DECLARE_OOXMLEXPORT_TEST(testfdo73596_RunInStyle,"fdo73596_RunInStyle.docx")
{
// INDEX should be preserved.
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText[1]"," INDEX \\e \"");
}
DECLARE_OOXMLEXPORT_TEST(testfdo73596_AlphaSeparator,"fdo73596_AlphaSeparator.docx")
{
// INDEX flag \h "A" should be preserved.
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText[1]");
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
CPPUNIT_ASSERT(contents.match(" INDEX \\h \"A\" \\e \""));
}
DECLARE_OOXMLEXPORT_TEST(testFDO74106, "FDO74106.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");

View File

@ -2102,7 +2102,9 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect )
if (nsSwTOIOptions::TOI_ALPHA_DELIMITTER & pTOX->GetOptions())
sStr += "\\h \"A\" ";
if (!pTOX->GetTOXForm().IsCommaSeparated())
{
// In case of Run-in style no separators are added.
OUString aFillTxt;
for (sal_uInt8 n = 1; n <= 3; ++n)
{

View File

@ -2944,20 +2944,31 @@ void DomainMapper_Impl::handleIndex
uno::Reference< beans::XPropertySet > xTOC;
m_bStartTOC = true;
m_bStartIndex = true;
OUString sValue;
if (m_xTextFactory.is())
xTOC.set(
m_xTextFactory->createInstance(
sTOCServiceName),
uno::UNO_QUERY_THROW);
if (xTOC.is())
{
xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(OUString()));
if( lcl_FindInCommand( pContext->GetCommand(), 'r', sValue ))
{
xTOC->setPropertyValue("IsCommaSeparated", uno::makeAny(true));
}
if( lcl_FindInCommand( pContext->GetCommand(), 'h', sValue ))
{
xTOC->setPropertyValue("UseAlphabeticalSeparators", uno::makeAny(true));
}
}
pContext->SetTOC( xTOC );
uno::Reference< text::XTextContent > xToInsert( xTOC, uno::UNO_QUERY );
appendTextContent(xToInsert, uno::Sequence< beans::PropertyValue >() );
OUString sValue;
if( lcl_FindInCommand( pContext->GetCommand(), 'c', sValue ))
{
sValue = sValue.replaceAll("\"", "");