[Libreoffice-commits] core.git: include/oox oox/source sc/source sd/qa

2021-07-08 Thread Gülşah Köse (via logerrit)
 include/oox/core/contexthandler2.hxx  |   19 +
 include/oox/core/fragmenthandler2.hxx |   11 ---
 include/oox/drawingml/graphicshapecontext.hxx |1 
 include/oox/ole/oleobjecthelper.hxx   |1 
 oox/source/core/contexthandler2.cxx   |   85 +-
 oox/source/core/fragmenthandler2.cxx  |   70 -
 oox/source/drawingml/graphicshapecontext.cxx  |   11 +++
 sc/source/filter/oox/worksheetfragment.cxx|6 -
 sd/qa/unit/data/pptx/tdf143222.pptx   |binary
 sd/qa/unit/export-tests-ooxml3.cxx|   30 +
 10 files changed, 148 insertions(+), 86 deletions(-)

New commits:
commit 92a407b7f90a98704a238c5ffa3a3491eaf3263a
Author: Gülşah Köse 
AuthorDate: Wed Jul 7 00:27:58 2021 +0300
Commit: Gülşah Köse 
CommitDate: Thu Jul 8 23:12:07 2021 +0200

tdf143222 Handle alternate content of graphicData element.

Handle alternate content and make true choice.

According to ooxml spec ole object requires exactly one pic
element. (ECMA-376 Part 1, Annex A, CT_OleObject). In the
current case first choice has not pic element and we should
allow fallback processing.

Change-Id: I30b7de703b8c2f00d6bf286e05eea505ac3627f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118539
Tested-by: Jenkins
Reviewed-by: Gülşah Köse 

diff --git a/include/oox/core/contexthandler2.hxx 
b/include/oox/core/contexthandler2.hxx
index 4e256089ac8e..3a75aff5706a 100644
--- a/include/oox/core/contexthandler2.hxx
+++ b/include/oox/core/contexthandler2.hxx
@@ -72,7 +72,7 @@ struct ElementInfo;
 class OOX_DLLPUBLIC ContextHandler2Helper
 {
 public:
-explicitContextHandler2Helper( bool bEnableTrimSpace );
+explicitContextHandler2Helper( bool bEnableTrimSpace, 
XmlFilterBase& rFilter );
 explicitContextHandler2Helper( const ContextHandler2Helper& 
rParent );
 virtual ~ContextHandler2Helper();
 
@@ -201,6 +201,21 @@ protected:
 /** Must be called from endRecord() in derived classes. */
 voidimplEndRecord( sal_Int32 nRecId );
 
+boolprepareMceContext( sal_Int32 nElement, const 
AttributeList& rAttribs );
+XmlFilterBase&  getDocFilter() const { return mrFilter; }
+
+enum class MCE_STATE
+{
+Started,
+FoundChoice
+};
+
+MCE_STATE   getMCEState() const { return aMceState.back(); }
+voidsetMCEState( MCE_STATE aState ) { aMceState.back() = 
aState; }
+voidaddMCEState( MCE_STATE aState ) { aMceState.push_back( 
aState ); }
+voidremoveMCEState() { aMceState.pop_back(); }
+boolisMCEStateEmpty() { return aMceState.empty(); }
+
 private:
 ContextHandler2Helper& operator=( const ContextHandler2Helper& ) = delete;
 
@@ -214,9 +229,11 @@ private:
 
 ContextStackRef mxContextStack; ///< Stack of all processed 
elements.
 size_t  mnRootStackSize;///< Stack size on construction 
time.
+std::vector aMceState;
 
 protected:
 boolmbEnableTrimSpace;  ///< True = trim whitespace in 
characters().
+XmlFilterBase&  mrFilter;
 };
 
 class OOX_DLLPUBLIC ContextHandler2 : public ContextHandler, public 
ContextHandler2Helper
diff --git a/include/oox/core/fragmenthandler2.hxx 
b/include/oox/core/fragmenthandler2.hxx
index 86d1453f13a1..598426ee681e 100644
--- a/include/oox/core/fragmenthandler2.hxx
+++ b/include/oox/core/fragmenthandler2.hxx
@@ -47,17 +47,6 @@ class XmlFilterBase;
 
 class OOX_DLLPUBLIC FragmentHandler2 : public FragmentHandler, public 
ContextHandler2Helper
 {
-protected:
-enum class MCE_STATE
-{
-Started,
-FoundChoice
-};
-::std::vector   aMceState;
-
-boolprepareMceContext( sal_Int32 nElement, const 
AttributeList& rAttribs );
-
-
 public:
 explicitFragmentHandler2(
 XmlFilterBase& rFilter,
diff --git a/include/oox/drawingml/graphicshapecontext.hxx 
b/include/oox/drawingml/graphicshapecontext.hxx
index 4813d5fc9aed..ffd579f00bb1 100644
--- a/include/oox/drawingml/graphicshapecontext.hxx
+++ b/include/oox/drawingml/graphicshapecontext.hxx
@@ -62,6 +62,7 @@ public:
 OleObjectGraphicDataContext( ::oox::core::ContextHandler2Helper const & 
rParent, const ShapePtr& pShapePtr );
 virtual ~OleObjectGraphicDataContext() override;
 virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 
Element, const ::oox::AttributeList& rAttribs ) override;
+virtual void onEndElement() override;
 
 private:
 ::oox::vml::OleObjectInfo& mrOleObjectInfo;
diff --git a/include/oox/ole/oleobjecthelper.hxx 
b/include/oox/ole/oleobjecthelper.hxx
index d2506f3d4949..5b792f2048b1 100644
--- a/include/oox/ole/oleobjecthelper.hxx
+++ b/include/oox/ole/oleobjecthelper.hxx
@@ -47,6 +47,7 @@ 

[Libreoffice-commits] core.git: include/oox oox/source sc/source sd/qa

2017-09-23 Thread Szymon Kłos
 include/oox/export/chartexport.hxx  |3 +--
 oox/source/export/chartexport.cxx   |   10 +-
 oox/source/export/shapes.cxx|2 +-
 sc/source/filter/excel/xeescher.cxx |3 ++-
 sd/qa/unit/data/pptx/tdf112089.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   16 
 6 files changed, 21 insertions(+), 13 deletions(-)

New commits:
commit c0a61832965aff202d72a2bf51556c5c6b6d594b
Author: Szymon Kłos 
Date:   Wed Sep 20 16:29:54 2017 +0200

tdf#112089 add charts to the ShapeMap

Charts weren't added to the collection what resulted
in missing ids during export (target field).

Change-Id: Ie96a4e33a52c5448342a3c3dcec0d8e8b244e270
Reviewed-on: https://gerrit.libreoffice.org/42552
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 

diff --git a/include/oox/export/chartexport.hxx 
b/include/oox/export/chartexport.hxx
index dadad8d6ca34..cebc4f41ca4d 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -211,10 +211,9 @@ public:
  ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType );
 virtual ~ChartExport() {}
 
-sal_Int32   GetChartID( );
 const css::uno::Reference< css::frame::XModel >& getModel(){ return 
mxChartModel; }
 
-void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& 
xShape, sal_Int32 nChartCount );
+void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& 
xShape, sal_Int32 nID, sal_Int32 nChartCount );
 
 void ExportContent();
 void InitRangeSegmentationProperties(
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 60bdc4d8c6c7..bbf0cf113f14 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -377,12 +377,6 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, 
FSHelperPtr pFS, Reference< f
 {
 }
 
-sal_Int32 ChartExport::GetChartID( )
-{
-sal_Int32 nID = GetFB()->GetUniqueId();
-return nID;
-}
-
 sal_Int32 ChartExport::getChartType( )
 {
 OUString sChartType = mxDiagram->getDiagramType();
@@ -434,7 +428,7 @@ OUString ChartExport::parseFormula( const OUString& rRange )
 return aResult;
 }
 
-void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 
nChartCount )
+void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 
nID, sal_Int32 nChartCount )
 {
 FSHelperPtr pFS = GetFS();
 
@@ -448,8 +442,6 @@ void ChartExport::WriteChartObj( const Reference< XShape >& 
xShape, sal_Int32 nC
 if (xNamed.is())
 sName = xNamed->getName();
 
-sal_Int32 nID = GetChartID();
-
 pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
   XML_id, I32S( nID ),
   XML_name,   USS( sName ),
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index b3d42048ec6d..05ea273d2612 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1935,7 +1935,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 Reference< XModel > xModel( xChartDoc, UNO_QUERY );
 ChartExport aChartExport( mnXmlNamespace, GetFS(), xModel, GetFB(), 
GetDocumentType() );
 static sal_Int32 nChartCount = 0;
-aChartExport.WriteChartObj( xShape, ++nChartCount );
+aChartExport.WriteChartObj( xShape, GetNewShapeID( xShape ), 
++nChartCount );
 return *this;
 }
 
diff --git a/sc/source/filter/excel/xeescher.cxx 
b/sc/source/filter/excel/xeescher.cxx
index 13a58328fce4..f3da7609ae02 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -1140,7 +1140,8 @@ void XclExpChartObj::SaveXml( XclExpXmlStream& rStrm )
 ChartExport aChartExport(XML_xdr, pDrawing, xModel, , 
drawingml::DOCUMENT_XLSX);
 static sal_Int32 nChartCount = 0;
 nChartCount++;
-aChartExport.WriteChartObj( mxShape, nChartCount );
+sal_Int32 nID = rStrm.GetUniqueId();
+aChartExport.WriteChartObj( mxShape, nID, nChartCount );
 // TODO: get the correcto chart number
 }
 
diff --git a/sd/qa/unit/data/pptx/tdf112089.pptx 
b/sd/qa/unit/data/pptx/tdf112089.pptx
new file mode 100755
index ..d0cafcd91c72
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf112089.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 9861726386e0..cd60f8dc95c2 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -112,6 +112,7 @@ public:
 void testTdf112552();
 void testTdf112557();
 void testTdf112334();
+void testTdf112089();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -151,6 +152,7 @@ public:
 CPPUNIT_TEST(testTdf112552);
 CPPUNIT_TEST(testTdf112557);
 CPPUNIT_TEST(testTdf112334);
+