[Libreoffice-commits] core.git: sw/source writerfilter/source
Szymon Kłos
szymon.klos at collabora.com
Tue May 2 07:34:08 UTC 2017
sw/source/filter/docx/swdocxreader.cxx | 18 ++++++++++++++----
writerfilter/source/dmapper/DomainMapper.cxx | 14 ++++++++++++++
writerfilter/source/ooxml/model.xml | 7 +++++++
3 files changed, 35 insertions(+), 4 deletions(-)
New commits:
commit fb3989b6f70b48f4da8ca87e791f6922da56279e
Author: Szymon Kłos <szymon.klos at collabora.com>
Date: Mon May 1 19:05:48 2017 +0200
AutoText: read names of entries
+ extended model to parse <docPartPr> and <name> marks
+ names are inserted to the document before content
of each entry
+ SwDOCXReader interprets first paragraph of each section
as a name
Change-Id: Ib7de152ba1c6bea4f4665f98d321019c3f68863e
Reviewed-on: https://gerrit.libreoffice.org/37124
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/source/filter/docx/swdocxreader.cxx b/sw/source/filter/docx/swdocxreader.cxx
index 7a3cc9425bd5..8a20cf0d2a8a 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -111,6 +111,19 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
sal_uInt16 nGlosEntry = 0;
SwContentNode* pCNd = nullptr;
do {
+ // Get name - first paragraph
+ OUString aLNm;
+ {
+ SwPaM aPam( aStart );
+ SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
+ ++rIdx;
+ aLNm = aPam.GetNode().GetTextNode()->GetText();
+ }
+
+ // Do not copy name
+ aStart++;
+
+ // Get content
SwPaM aPam( aStart );
{
SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
@@ -139,10 +152,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
// Now we have the right selection for one entry
rBlocks.ClearDoc();
- // TODO: correct entry name
- const OUString rLNm = "ImportedAutoText";
-
- OUString sShortcut = rLNm;
+ OUString sShortcut = aLNm;
// Need to check make sure the shortcut is not already being used
sal_Int32 nStart = 0;
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 1784c612c0bd..62544ca858f1 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1080,6 +1080,13 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_Cnf_val:
m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "val", sStringValue);
break;
+ case NS_ooxml::LN_CT_DocPartName_val:
+ {
+ // Add glossary entry name as a first paragraph in section
+ PropertyMapPtr pContext = m_pImpl->GetTopContext();
+ m_pImpl->appendTextPortion(sStringValue, pContext);
+ break;
+ }
default:
SAL_WARN("writerfilter", "DomainMapper::lcl_attribute: unhandled token: " << nName);
}
@@ -2753,6 +2760,13 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
pProperties->resolve(m_pImpl->getSmartTagHandler());
}
break;
+ case NS_ooxml::LN_CT_DocPartPr_name:
+ {
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+ if (pProperties.get() != nullptr)
+ pProperties->resolve(*this);
+ }
+ break;
default:
{
#ifdef DEBUG_WRITERFILTER
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index f943618a35bd..a39f0537fa76 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -19062,6 +19062,13 @@
<action name="start" action="startGlossaryEntry"/>
<action name="end" action="endGlossaryEntry"/>
</resource>
+ <resource name="CT_DocPartPr" resource="Properties">
+ <action name="start" action="startSectionGroup"/>
+ <element name="name" tokenid="ooxml:CT_DocPartPr_name"/>
+ </resource>
+ <resource name="CT_DocPartName" resource="Properties">
+ <attribute name="val" tokenid="ooxml:CT_DocPartName_val"/>
+ </resource>
<resource name="document" resource="Stream"/>
<resource name="glossaryDocument" resource="Stream"/>
<resource name="CT_TxbxContent" resource="Stream">
More information about the Libreoffice-commits
mailing list