summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2018-12-06 19:11:58 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-01-09 22:30:08 +0100
commitff4f2ba3242d303f7f238a7a142440f1f4b1f288 (patch)
treee26084095041d94378b9189ea026da22b8e456b6 /sw
parentf22f28e722a8a2efdc42bddba80a3a43025a61fd (diff)
sw: DOCX: recognize TOC title during import
Change-Id: Ifa4fb59858d61580f76e3d104aa4caa6b5902d1b Reviewed-on: https://gerrit.libreoffice.org/64735 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/doc.hxx5
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx14
-rw-r--r--sw/source/core/doc/doctxm.cxx17
-rw-r--r--sw/source/core/unocore/unoidx.cxx6
-rw-r--r--sw/source/filter/ww8/docxexport.cxx5
5 files changed, 38 insertions, 9 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 3878c4299b89..4d1cf10c9010 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -917,6 +917,11 @@ public:
const SfxItemSet* pSet = nullptr,
bool bExpand = false,
SwRootFrame const* pLayout = nullptr);
+ SwTOXBaseSection* InsertTableOf( const SwPaM& aPam,
+ const SwTOXBase& rTOX,
+ const SfxItemSet* pSet = nullptr,
+ bool bExpand = false,
+ SwRootFrame const* pLayout = nullptr );
void InsertTableOf( sal_uLong nSttNd, sal_uLong nEndNd,
const SwTOXBase& rTOX,
const SfxItemSet* pSet );
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index b36fe833dcc3..90c7566e30d3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/text/RubyAdjust.hpp>
#include <com/sun/star/text/RubyPosition.hpp>
+#include <com/sun/star/text/XDocumentIndex.hpp>
#include <sfx2/docfile.hxx>
@@ -144,6 +145,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf121561_tocTitle, "tdf121456_tabsOffset.odt")
assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:docPartObj/w:docPartUnique", 1);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf121561_tocTitleDocx, "tdf121456_tabsOffset.odt")
+{
+ xmlDocPtr pXmlDoc = parseExport();
+ if (!pXmlDoc)
+ return;
+
+ uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexes(xIndexSupplier->getDocumentIndexes( ), uno::UNO_QUERY);
+ uno::Reference<text::XDocumentIndex> xTOCIndex(xIndexes->getByIndex(0), uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Inhaltsverzeichnis"), getProperty<OUString>(xTOCIndex, "Title"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf106174_rtlParaAlign, "tdf106174_rtlParaAlign.docx")
{
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getParagraph(1), "ParaAdjust"));
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 4e7ab4507e06..923cd9b1084f 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -347,15 +347,24 @@ const SwTOXMark& SwDoc::GotoTOXMark( const SwTOXMark& rCurTOXMark,
}
SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos,
- const SwTOXBase& rTOX,
- const SfxItemSet* pSet,
- bool bExpand,
+ const SwTOXBase& rTOX,
+ const SfxItemSet* pSet,
+ bool bExpand,
SwRootFrame const*const pLayout)
{
+ SwPaM aPam( rPos );
+ return InsertTableOf( aPam, rTOX, pSet, bExpand, pLayout );
+}
+
+SwTOXBaseSection* SwDoc::InsertTableOf( const SwPaM& aPam,
+ const SwTOXBase& rTOX,
+ const SfxItemSet* pSet,
+ bool bExpand,
+ SwRootFrame const*const pLayout )
+{
GetIDocumentUndoRedo().StartUndo( SwUndoId::INSTOX, nullptr );
OUString sSectNm = GetUniqueTOXBaseName( *rTOX.GetTOXType(), rTOX.GetTOXName() );
- SwPaM aPam( rPos );
SwSectionData aSectionData( TOX_CONTENT_SECTION, sSectNm );
SwTOXBaseSection *const pNewSection = dynamic_cast<SwTOXBaseSection *>(
InsertSwSection( aPam, aSectionData, & rTOX, pSet, false ));
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 7e40304a6f2a..c7f3397b62b0 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -1340,10 +1340,6 @@ SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange)
}
UnoActionContext aAction(pDoc);
- if (aPam.HasMark())
- {
- pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
- }
SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase();
SwTOXType const*const pTOXType = rTOXBase.GetTOXType();
@@ -1354,7 +1350,7 @@ SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange)
}
//TODO: apply Section attributes (columns and background)
SwTOXBaseSection *const pTOX =
- pDoc->InsertTableOf( *aPam.GetPoint(), rTOXBase, nullptr, false,
+ pDoc->InsertTableOf( aPam, rTOXBase, nullptr, false,
m_pImpl->m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout());
pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName());
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 097195c9cc20..79717e24761c 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1442,6 +1442,11 @@ void DocxExport::WriteMainText()
// setup the namespaces
m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces());
+ if ( getenv("SW_DEBUG_DOM") )
+ {
+ m_pDoc->dumpAsXml();
+ }
+
// reset the incrementing linked-textboxes chain ID before re-saving.
m_nLinkedTextboxesChainId=0;
m_aLinkedTextboxesHelper.clear();