[Libreoffice-commits] core.git: filter/source include/filter oox/source sw/qa sw/source
Bisal Nayal
bisal.nayal at synerzip.com
Mon Jul 21 08:03:54 PDT 2014
filter/source/msfilter/util.cxx | 12 ++++++++++++
include/filter/msfilter/util.hxx | 8 ++++++++
oox/source/export/vmlexport.cxx | 15 ++-------------
sw/qa/extras/ooxmlexport/data/fdo78663.docx |binary
sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 28 +++++++++++++++++++++++++---
sw/source/filter/ww8/docxsdrexport.cxx | 3 ++-
6 files changed, 49 insertions(+), 17 deletions(-)
New commits:
commit 245df9b4b37e3b1a6863aec5802346999bd71477
Author: Bisal Nayal <bisal.nayal at synerzip.com>
Date: Fri Jul 11 16:27:34 2014 +0530
fdo#78663 : The File gets corrupted when saved in LO
Problem Description:
The docx file contains a word art inside a drawing tool.
After RT, nesting of <txbxContent> tag is happening which
is causing the corruption.
Solution: Created a service in util.cxx for checking
few shapetypes for which textbox with content is not
allowed. This check also helps to find that if we are
already inside a DML then we should purely read VML
Information.An existing UT testWordArtWithinDraingtool
was failing. The UT is related to same issue
(word art inside drawing tool) hence changed it
accordingly. Following is the commit id of the
UT-Change-Id: I00e94712e912ad1977fcb65a945fefb927795d77
Change-Id: I7e456c9f6a69af80da443e29eb02a64ba7d59468
Reviewed-on: https://gerrit.libreoffice.org/10229
Reviewed-by: LuboÅ¡ LuÅák <l.lunak at collabora.com>
Tested-by: LuboÅ¡ LuÅák <l.lunak at collabora.com>
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 5aad6fe..9f3a640 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -1333,6 +1333,18 @@ MSO_SPT GETVMLShapeType(const OString& aType)
return i == pDMLToVMLMap->end() ? mso_sptNil : i->second;
}
+bool HasTextBoxContent(sal_uInt32 nShapeType)
+{
+ switch (nShapeType)
+ {
+ case ESCHER_ShpInst_TextPlainText:
+ case ESCHER_ShpInst_TextSlantUp:
+ case ESCHER_ShpInst_TextDeflateInflateDeflate:
+ return false;
+ default:
+ return true;
+ }
+}
}
}
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index ddf5a12..c1bb36d 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -17,6 +17,7 @@
#include <filter/msfilter/msfilterdllapi.h>
#include <svx/msdffdef.hxx>
#include <com/sun/star/awt/Size.hpp>
+#include <filter/msfilter/escherex.hxx>
namespace msfilter {
namespace util {
@@ -138,6 +139,13 @@ MSFILTER_DLLPUBLIC const char* GetOOXMLPresetGeometry( const char* sShapeType );
/// Similar to EnhancedCustomShapeTypeNames::Get(), but returns an MSO_SPT (binary / VML type).
MSFILTER_DLLPUBLIC MSO_SPT GETVMLShapeType(const OString& aType);
+/**
+ * The following function checks if a MSO shapetype is allowed to have textboxcontent.
+ *
+ * @param nShapeType shape to check
+ */
+MSFILTER_DLLPUBLIC bool HasTextBoxContent(sal_uInt32 nShapeType);
+
}
}
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 039514d..a0a1ac7 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -31,6 +31,7 @@
#include <svx/svdotext.hxx>
#include <vcl/cvtgrf.hxx>
#include <filter/msfilter/msdffimp.hxx>
+#include <filter/msfilter/util.hxx>
#include <filter/msfilter/escherex.hxx>
#include <com/sun/star/drawing/XShape.hpp>
@@ -970,18 +971,6 @@ bool lcl_isTextBox(const SdrObject* pSdrObject)
return false;
}
-bool lcl_hasTextBoxContent(sal_uInt32 nShapeType)
-{
- switch (nShapeType)
- {
- case ESCHER_ShpInst_TextPlainText:
- case ESCHER_ShpInst_TextSlantUp:
- return false;
- default:
- return true;
- }
-}
-
OUString lcl_getAnchorIdFromGrabBag(const SdrObject* pSdrObject)
{
OUString aResult;
@@ -1137,7 +1126,7 @@ sal_Int32 VMLExport::StartShape()
// now check if we have some editeng text (not associated textbox) and we have a text exporter registered
const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, m_pSdrObject);
- if (pTxtObj && m_pTextExport && lcl_hasTextBoxContent(m_nShapeType) && !IsWaterMarkShape(m_pSdrObject->GetName()) && !lcl_isTextBox(m_pSdrObject))
+ if (pTxtObj && m_pTextExport && msfilter::util::HasTextBoxContent(m_nShapeType) && !IsWaterMarkShape(m_pSdrObject->GetName()) && !lcl_isTextBox(m_pSdrObject))
{
const OutlinerParaObject* pParaObj = 0;
bool bOwnParaObj = false;
diff --git a/sw/qa/extras/ooxmlexport/data/fdo78663.docx b/sw/qa/extras/ooxmlexport/data/fdo78663.docx
new file mode 100644
index 0000000..be35b6c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo78663.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 92dc825..20f7fd7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -1595,10 +1595,32 @@ DECLARE_OOXMLEXPORT_TEST(testWordArtWithinDraingtool, "testWordArtWithinDraingto
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
- assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1);
- assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:rect[1]/v:textbox[1]/w:txbxContent[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1);
+ assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent",1);
+ assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:textbox/w:txbxContent/w:p/w:r/w:pict/v:shape",1);
// Make sure that the shape inside a shape is exported as VML-only, no embedded mc:AlternateContent before w:pict.
- assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]/w:p/w:r/w:pict",1);
+ assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/w:pict",1);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testfdo78663, "fdo78663.docx")
+{
+/* * A 2007 word art tool is enclosed in a 2010 drawing toolWithin a file,
+ * Originally the file has the following xml tag hierarchy.
+ *
+ * <p> <r> <ac> <drawing> <txbx> <txbxContent> <pict><shapetype> <shape> ...</shape></shapetype> </pict> </txbxContent></txbx> </drawing> </ac> </r> </p>
+ * After RT :
+ * <p> <r> <ac> <drawing> <txbx> <txbxContent> <pict><shapetype> <shape> <textbox><txbxContent> ... </txbxContent></textbox></shape></shapetype> </pict> </txbxContent></txbx> </drawing> </ac> </r> </p>
+ * MSO doesn't allow nesting of txbxContent tags.
+ * As the text of the wordart tool is written in the tag <v:textpath string="Welcome to... "History is fun and informative"/>
+ * We shouldn't repeat it again in <shapetype><shape> <textbox><txbxContent>
+ * */
+
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/w:pict/v:shape/v:path",1);
+ assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:textbox/w:txbxContent/w:p/w:r/w:pict/v:shape/v:path",1);
+ // Make sure that the shape inside a shape is exported as VML-only, no embedded mc:AlternateContent before w:pict.
+ assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx/w:txbxContent/w:p/w:r/w:pict",1);
}
DECLARE_OOXMLEXPORT_TEST(testFdo78957, "fdo78957.docx")
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index da9dc23..8e137d9 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -852,7 +852,8 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrmFm
MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType(xShape, nMirrorFlags, sShapeType);
// In case we are already inside a DML block, then write the shape only as VML, turn out that's allowed to do.
- if (eShapeType != ESCHER_ShpInst_TextPlainText && m_pImpl->isSupportedDMLShape(xShape) && !bDMLAndVMLDrawingOpen)
+ // A common service created in util to check for VML shapes which are allowed to have textbox in content
+ if ( (msfilter::util::HasTextBoxContent(eShapeType)) && m_pImpl->isSupportedDMLShape(xShape) && !bDMLAndVMLDrawingOpen)
{
m_pImpl->m_pSerializer->startElementNS(XML_mc, XML_AlternateContent, FSEND);
More information about the Libreoffice-commits
mailing list