cf7255d
From bb21f53e6c9b6b3f4a2d8c5e55ebc3a08caa69ba Mon Sep 17 00:00:00 2001
a97f9d1
From: Miklos Vajna <vmiklos@collabora.co.uk>
a97f9d1
Date: Thu, 18 Sep 2014 15:47:59 +0200
a97f9d1
Subject: [PATCH] DOCX import: fix handling of dropdown SDT around cell
a97f9d1
a97f9d1
There were two problems here:
a97f9d1
a97f9d1
1) The CT_SdtContentCell handlers didn't emit the usual
a97f9d1
NS_ooxml::LN_CT_SdtBlock_sdtContent /
a97f9d1
NS_ooxml::LN_CT_SdtBlock_sdtEndContent tokens, so the dropdown control
a97f9d1
was not created (and then was created with the wrong anchor).
a97f9d1
a97f9d1
2) In case the SDT was around the cell, the newline character was also
a97f9d1
added to the text of the currently selected entry, resulting in an
a97f9d1
invalid argument of SwXText::convertToTable(), so no table was created.
a97f9d1
a97f9d1
(cherry picked from commit 419054c0f19acb323a0e51c7ef49a1a2d9f42ac8)
a97f9d1
a97f9d1
Conflicts:
a97f9d1
	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
a97f9d1
	writerfilter/source/dmapper/DomainMapper.cxx
a97f9d1
	writerfilter/source/ooxml/model.xml
a97f9d1
a97f9d1
Change-Id: I4806626181f40c6d26ff7b25f5dbb863967d8077
a97f9d1
---
cf7255d
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |  9 ---------
a97f9d1
 writerfilter/source/dmapper/DomainMapper.cxx | 14 +++++++++++---
a97f9d1
 writerfilter/source/ooxml/model.xml          |  5 ++++-
cf7255d
 3 files changed, 15 insertions(+), 13 deletions(-)
a97f9d1
cf7255d
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
cf7255d
index a443d58..24459d1 100644
cf7255d
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
cf7255d
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
cf7255d
@@ -3566,15 +3566,6 @@ DECLARE_OOXMLEXPORT_TEST(testfdo79822, "fdo79822.docx")
cf7255d
         return;
cf7255d
 }
cf7255d
 
cf7255d
-DECLARE_OOXMLEXPORT_TEST(testfdo79817,"fdo79817.docx")
cf7255d
-{
cf7255d
-    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
cf7255d
-    if (!pXmlDoc)
cf7255d
-        return;
cf7255d
-    assertXPath ( pXmlDoc, "/w:document/w:body/w:p[3]/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{9222E47B-A68B-4AEB-9855-21C912B9D3D2}");
cf7255d
-    assertXPath ( pXmlDoc, "/w:document/w:body/w:p[3]/w:sdt/w:sdtPr/w:dataBinding", "xpath","/ns0:properties[1]/documentManagement[1]/ns2:Responsible_x0020_Officer_x0020_Title[1]");
cf7255d
-}
cf7255d
-
cf7255d
 DECLARE_OOXMLEXPORT_TEST(testfdo80522,"fdo80522.docx")
cf7255d
 {
cf7255d
    xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
a97f9d1
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
a97f9d1
index 44efb59..baf91d9 100644
a97f9d1
--- a/writerfilter/source/dmapper/DomainMapper.cxx
a97f9d1
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
a97f9d1
@@ -2768,10 +2768,18 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
a97f9d1
     aBuffer.append( (const sal_Unicode *) data_, len);
a97f9d1
     sText = aBuffer.makeStringAndClear();
a97f9d1
 
a97f9d1
+
a97f9d1
+    bool bNewLine = len == 1 && (sText[0] == 0x0d || sText[0] == 0x07);
a97f9d1
     if (!m_pImpl->m_pSdtHelper->getDropDownItems().empty())
a97f9d1
     {
a97f9d1
-        m_pImpl->m_pSdtHelper->getSdtTexts().append(sText);
a97f9d1
-        return;
a97f9d1
+        if (bNewLine)
a97f9d1
+            // Dropdown control has single-line texts, so in case of newline, create the control.
a97f9d1
+            m_pImpl->m_pSdtHelper->createDropDownControl();
a97f9d1
+        else
a97f9d1
+        {
a97f9d1
+            m_pImpl->m_pSdtHelper->getSdtTexts().append(sText);
a97f9d1
+            return;
a97f9d1
+        }
a97f9d1
     }
a97f9d1
     else if (!m_pImpl->m_pSdtHelper->getDateFormat().isEmpty())
a97f9d1
     {
a97f9d1
@@ -2814,7 +2822,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
a97f9d1
     {
a97f9d1
         m_pImpl->getTableManager().utext(data_, len);
a97f9d1
 
a97f9d1
-        if(len == 1 && (sText[0] == 0x0d || sText[0] == 0x07))
a97f9d1
+        if (bNewLine)
a97f9d1
         {
a97f9d1
             if (m_pImpl->m_bIgnoreNextPara)
a97f9d1
             {
a97f9d1
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
a97f9d1
index 69ac296..3f4e71c 100644
a97f9d1
--- a/writerfilter/source/ooxml/model.xml
a97f9d1
+++ b/writerfilter/source/ooxml/model.xml
a97f9d1
@@ -25033,7 +25033,10 @@
a97f9d1
     <resource name="CT_SdtContentRun" resource="Stream" tag="field"/>
a97f9d1
     <resource name="CT_SdtContentBlock" resource="Stream" tag="field"/>
a97f9d1
     <resource name="CT_SdtContentRow" resource="Stream" tag="field"/>
a97f9d1
-    <resource name="CT_SdtContentCell" resource="Stream" tag="field"/>
a97f9d1
+    <resource name="CT_SdtContentCell" resource="Stream" tag="field">
a97f9d1
+      <action name="start" action="startSdt"/>
a97f9d1
+      <action name="end" action="endSdt"/>
a97f9d1
+    </resource>
a97f9d1
     <resource name="CT_SdtBlock" resource="Stream" tag="field">
a97f9d1
       <element name="sdtPr" tokenid="ooxml:CT_SdtBlock_sdtPr"/>
a97f9d1
       <element name="sdtEndPr" tokenid="ooxml:CT_SdtBlock_sdtEndPr"/>
a97f9d1
-- 
a97f9d1
2.1.0
a97f9d1