summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-05-01 19:05:48 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-05-02 09:33:35 +0200
commitfb3989b6f70b48f4da8ca87e791f6922da56279e (patch)
treefe4cb5b2698c21ed6661ab411d566d58a4992d3f
parent1b9d9a8bb640b7883c143cb39e3024be86528977 (diff)
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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/source/filter/docx/swdocxreader.cxx18
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx14
-rw-r--r--writerfilter/source/ooxml/model.xml7
3 files changed, 35 insertions, 4 deletions
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">