diff options
author | Nikhil Walvekar <nikhil.walvekar@synerzip.com> | 2014-02-17 20:46:18 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-03-05 02:48:29 -0600 |
commit | d043c9e3be791993348afaba6effdc3731f7c33d (patch) | |
tree | e8a318ee7f01507efe0479e64bfdaf238da99199 | |
parent | 5490f585f09c0a24b7caab011593ab6bb6e9a318 (diff) |
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>
-rw-r--r-- | sw/qa/extras/inc/swmodeltestbase.hxx | 17 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo73596_AlphaSeparator.docx | bin | 0 -> 16099 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo73596_RunInStyle.docx | bin | 0 -> 15886 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 21 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 13 |
6 files changed, 52 insertions, 1 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 5be397a922d6..cb15d695ac8f 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -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). diff --git a/sw/qa/extras/ooxmlexport/data/fdo73596_AlphaSeparator.docx b/sw/qa/extras/ooxmlexport/data/fdo73596_AlphaSeparator.docx Binary files differnew file mode 100644 index 000000000000..892bc553b3bf --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo73596_AlphaSeparator.docx diff --git a/sw/qa/extras/ooxmlexport/data/fdo73596_RunInStyle.docx b/sw/qa/extras/ooxmlexport/data/fdo73596_RunInStyle.docx Binary files differnew file mode 100644 index 000000000000..8f1863b4670c --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo73596_RunInStyle.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 06b6fa5193e8..f88543882ebf 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -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"); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 5263dcf3a9d1..0109d87b97aa 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -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) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 25daf87712a5..35010980a67a 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -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("\"", ""); |