[Libreoffice-commits] core.git: include/oox oox/source sc/qa sc/source solenv/clang-format

2022-10-24 Thread Regina Henschel (via logerrit)
 include/oox/shape/ShapeDrawingFragmentHandler.hxx  |2 
 oox/source/shape/ShapeContextHandler.cxx   |2 
 oox/source/shape/ShapeDrawingFragmentHandler.cxx   |2 
 sc/qa/unit/data/xlsx/tdf83671_SmartArt_import.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx|   47 +
 sc/source/filter/oox/drawingfragment.cxx   |   22 +
 solenv/clang-format/excludelist|2 
 7 files changed, 73 insertions(+), 4 deletions(-)

New commits:
commit 9ad7df41572d67687221cb43d53cde27a45fff0f
Author: Regina Henschel 
AuthorDate: Thu Oct 20 14:28:07 2022 +0200
Commit: Miklos Vajna 
CommitDate: Mon Oct 24 15:09:37 2022 +0200

tdf#83671 make SmartArt visible in import of xlsx

Problem is, that Excel writes a zero size in xdr:xfrm for the SmartArt.
With that the import generates a background size with zero width and
height and no shapes at all in the SmartArt group. The diagram DOM is
imported correctly. The actual size is not known until the row and column
values of the anchor are evaluated.
The idea of this patch is to correct the background size directly and to
repeat the import of drawing.xml when the actual size is known.

I noticed that in import of SmartArt in docx there is a similar problem
that the SmartArt shapes are missing at some point, as can be seen in
ShapeContextHandler::getShape(), about line 428. It uses
ShapeDrawingFragmentHandler to import the shapes. To be able to use that
handler too, I have moved its header file to include.
The solution for docx uses a loop over the vector getExtDrawings(). But I
have not seen a SmartArt case, where more then one element exists in it.

Whether the shape is a diagram, is indirectly tested currently. The
shape has yet no direct method for it.

Change-Id: I9d705ed5bfb2894e9ce740ebf8589e06b4870bed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141571
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/shape/ShapeDrawingFragmentHandler.hxx 
b/include/oox/shape/ShapeDrawingFragmentHandler.hxx
similarity index 93%
rename from oox/source/shape/ShapeDrawingFragmentHandler.hxx
rename to include/oox/shape/ShapeDrawingFragmentHandler.hxx
index 15b424b6fd8f..340edca5e1d1 100644
--- a/oox/source/shape/ShapeDrawingFragmentHandler.hxx
+++ b/include/oox/shape/ShapeDrawingFragmentHandler.hxx
@@ -16,7 +16,7 @@
 namespace oox::shape {
 
 /// Generic (i.e. not specific to PPTX) handler for the prerendered diagram 
parsing.
-class ShapeDrawingFragmentHandler : public oox::core::FragmentHandler2
+class OOX_DLLPUBLIC ShapeDrawingFragmentHandler : public 
oox::core::FragmentHandler2
 {
 public:
 ShapeDrawingFragmentHandler(oox::core::XmlFilterBase& rFilter, const 
OUString& rFragmentPath, oox::drawingml::ShapePtr pGroupShapePtr);
diff --git a/oox/source/shape/ShapeContextHandler.cxx 
b/oox/source/shape/ShapeContextHandler.cxx
index 54a455452365..4e8329c1417d 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -22,7 +22,7 @@
 #include 
 
 #include 
-#include "ShapeDrawingFragmentHandler.hxx"
+#include 
 #include "LockedCanvasContext.hxx"
 #include "WpsContext.hxx"
 #include "WpgContext.hxx"
diff --git a/oox/source/shape/ShapeDrawingFragmentHandler.cxx 
b/oox/source/shape/ShapeDrawingFragmentHandler.cxx
index 0e915058fcb4..456f7df6c80d 100644
--- a/oox/source/shape/ShapeDrawingFragmentHandler.cxx
+++ b/oox/source/shape/ShapeDrawingFragmentHandler.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "ShapeDrawingFragmentHandler.hxx"
+#include 
 
 #include 
 #include 
diff --git a/sc/qa/unit/data/xlsx/tdf83671_SmartArt_import.xlsx 
b/sc/qa/unit/data/xlsx/tdf83671_SmartArt_import.xlsx
new file mode 100644
index ..9ec0a0e7906c
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf83671_SmartArt_import.xlsx 
differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index e4bf84b2fade..1ce547a23373 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include "helper/qahelper.hxx"
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -185,6 +186,7 @@ public:
 void testAutofilterNamedRangesXLSX();
 void testInvalidBareBiff5();
 void testTooManyColsRows();
+void testTdf83671_SmartArt_import();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest2);
 
@@ -301,6 +303,7 @@ public:
 CPPUNIT_TEST(testAutofilterNamedRangesXLSX);
 CPPUNIT_TEST(testInvalidBareBiff5);
 CPPUNIT_TEST(testTooManyColsRows);
+CPPUNIT_TEST(testTdf83671_SmartArt_import);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -3042,6 +3045,50 @@ void ScFiltersTest2::testTooManyColsRows()
 xDocSh->DoClose();
 }
 
+void 

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

2022-03-30 Thread Tünde Tóth (via logerrit)
 include/oox/export/drawingml.hxx |8 +
 oox/source/export/drawingml.cxx  |  207 +--
 sc/qa/unit/data/ods/tdf91286.ods |binary
 sc/qa/unit/subsequent_export_test2.cxx   |   26 +++
 sc/source/filter/excel/xestream.cxx  |4 
 sd/qa/unit/data/odp/tdf74670.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx   |   26 +++
 sd/source/filter/eppt/pptx-epptooxml.cxx |2 
 8 files changed, 182 insertions(+), 91 deletions(-)

New commits:
commit aea8043bc5f5187498fa450505d6de9d6986e2a6
Author: Tünde Tóth 
AuthorDate: Tue Mar 22 09:47:57 2022 +0100
Commit: László Németh 
CommitDate: Wed Mar 30 18:24:45 2022 +0200

tdf#74670 tdf#91286 PPTX XLSX export: save image once

Impress and Calc used to dump the same image file
as many times as it was featured in the document,
resulting redundant, sometimes huge documents.

Note: using only checksum to recognize image duplication
is a regression, because checksum collision results
image loss. This is a very unlikely event, and
the following commits have got the same problem.
The solution is comparing the images with the same
checksum byte for byte.

See also commit b484e9814c66d8d51cea974390963a6944bc9d73
"tdf#83227 oox: reuse RelId in DML/VML export for the same graphic"
and commit 797fef38612fb2fd62d1f6591619b9361e526bca
"tdf#118535 DOCX export: save header image once".

Change-Id: I9f233d521941381746634cf4f9b5991da0dadda9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131928
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index fb125dd647ad..9a7f744520c8 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -21,7 +21,9 @@
 #define INCLUDED_OOX_EXPORT_DRAWINGML_HXX
 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
@@ -41,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -150,6 +153,7 @@ private:
 static std::map maWdpCache;
 static sal_Int32 mnDrawingMLCount;
 static sal_Int32 mnVmlCount;
+static std::stack> 
maExportGraphics;
 
 /// To specify where write eg. the images to (like 'ppt', or 'word' - 
according to the OPC).
 DocumentType meDocumentType;
@@ -342,9 +346,11 @@ public:
 sal_Int32 getBulletMarginIndentation (const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, std::u16string_view 
propName);
 
 static void ResetCounters();
-
 static void ResetMlCounters();
 
+static void PushExportGraphics();
+static void PopExportGraphics();
+
 static sal_Int32 getNewDrawingUniqueId() { return ++mnDrawingMLCount; }
 static sal_Int32 getNewVMLUniqueId() { return ++mnVmlCount; }
 
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a790a643abc0..a99a0474a458 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -111,7 +111,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -237,6 +236,7 @@ int DrawingML::mnWdpImageCounter = 1;
 std::map DrawingML::maWdpCache;
 sal_Int32 DrawingML::mnDrawingMLCount = 0;
 sal_Int32 DrawingML::mnVmlCount = 0;
+std::stack> 
DrawingML::maExportGraphics;
 
 sal_Int16 DrawingML::GetScriptType(const OUString& rStr)
 {
@@ -275,6 +275,16 @@ void DrawingML::ResetMlCounters()
 mnVmlCount = 0;
 }
 
+void DrawingML::PushExportGraphics()
+{
+maExportGraphics.emplace();
+}
+
+void DrawingML::PopExportGraphics()
+{
+maExportGraphics.pop();
+}
+
 bool DrawingML::GetProperty( const Reference< XPropertySet >& rXPropertySet, 
const OUString& aName )
 {
 try
@@ -1264,113 +1274,130 @@ const char* DrawingML::GetRelationCompPrefix() const
 OUString DrawingML::WriteImage( const Graphic& rGraphic , bool 
bRelPathToMedia, OUString* pFileName )
 {
 GfxLink aLink = rGraphic.GetGfxLink ();
+BitmapChecksum aChecksum = rGraphic.GetChecksum();
 OUString sMediaType;
 const char* pExtension = "";
 OUString sRelId;
+OUString sPath;
 
-SvMemoryStream aStream;
-const void* aData = aLink.GetData();
-std::size_t nDataSize = aLink.GetDataSize();
-
-switch ( aLink.GetType() )
+// tdf#74670 tdf#91286 Save image only once (this is no problem for DOCX)
+if (GetDocumentType() != DOCUMENT_DOCX && !maExportGraphics.empty())
 {
-case GfxLinkType::NativeGif:
-sMediaType = "image/gif";
-pExtension = ".gif";
-break;
+auto aIterator = maExportGraphics.top().find(aChecksum);
+if (aIterator != maExportGraphics.top().end())
+sPath = aIterator->second;
+}
 
-// #i15508# added BMP type for better exports
-// export not yet active, so adding for reference (not checked)
-case GfxLinkType::NativeBmp:
-

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

2021-10-13 Thread Attila Szűcs (via logerrit)
 include/oox/core/xmlfilterbase.hxx |2 
 oox/source/core/xmlfilterbase.cxx  |9 +++
 sc/qa/unit/data/xlsx/tdf144642_RowHeight_10mm_SavedByCalc.xlsx |binary
 sc/qa/unit/data/xlsx/tdf144642_RowHeight_28.35pt_SavedByExcel.xlsx |binary
 sc/qa/unit/subsequent_export_test.cxx  |2 
 sc/qa/unit/subsequent_export_test2.cxx |   25 
++
 sc/source/filter/oox/sheetdatacontext.cxx  |6 ++
 7 files changed, 42 insertions(+), 2 deletions(-)

New commits:
commit 537cb82be8fa021fd9382cca874645c75daaef20
Author: Attila Szűcs 
AuthorDate: Wed Sep 22 13:19:23 2021 +0200
Commit: László Németh 
CommitDate: Wed Oct 13 16:57:35 2021 +0200

tdf#144642 XLSX import: round down row height to 0.75 pt

like table layout of MSO does, e.g. 20 pt to 19.5 pt.

Changing table row height is only for interoperability.
To avoid of regressions, apply this workaround only for
documents created in MSO.

Note: likely this is an old adjustment for low-resolution
monitors, where 0.75 is the factor between 96 ppi of Windows
resolution and (originally) 72 ppi of monitor resolutions.

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: Ie1e2c781d21174a877b18cd3250eb445222bd1c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122428
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/include/oox/core/xmlfilterbase.hxx 
b/include/oox/core/xmlfilterbase.hxx
index 7c1cada284d2..15de6ce680c9 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -246,6 +246,7 @@ public:
 static FastParser* createParser();
 
 bool isMSO2007Document() const;
+bool isMSODocument() const;
 
 /// Signal that an MSO 2007-created SmartArt was found, need to warn the
 /// user about it.
@@ -281,6 +282,7 @@ private:
 sal_Int32 mnRelId;
 sal_Int32 mnMaxDocId;
 bool mbMSO2007;
+bool mbMSO;
 protected:
 bool mbMissingExtDrawing;
 };
diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index 371439b022a2..7f4ff6bd0f0c 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -200,6 +200,7 @@ XmlFilterBase::XmlFilterBase( const Reference< 
XComponentContext >& rxContext )
 mnRelId( 1 ),
 mnMaxDocId( 0 ),
 mbMSO2007(false),
+mbMSO(false),
 mbMissingExtDrawing(false)
 {
 }
@@ -218,9 +219,10 @@ XmlFilterBase::~XmlFilterBase()
 
 void XmlFilterBase::checkDocumentProperties(const 
Reference& xDocProps)
 {
-mbMSO2007 = false;
+mbMSO2007 = mbMSO = false;
 if (!xDocProps->getGenerator().startsWithIgnoreAsciiCase("Microsoft"))
 return;
+mbMSO = true;
 
 uno::Reference 
xUserDefProps(xDocProps->getUserDefinedProperties(), uno::UNO_QUERY);
 if (!xUserDefProps.is())
@@ -1020,6 +1022,11 @@ bool XmlFilterBase::isMSO2007Document() const
 return mbMSO2007;
 }
 
+bool XmlFilterBase::isMSODocument() const
+{
+return mbMSO;
+}
+
 void XmlFilterBase::setMissingExtDrawing()
 {
 mbMissingExtDrawing = true;
diff --git a/sc/qa/unit/data/xlsx/tdf144642_RowHeight_10mm_SavedByCalc.xlsx 
b/sc/qa/unit/data/xlsx/tdf144642_RowHeight_10mm_SavedByCalc.xlsx
new file mode 100644
index ..d85d94c107fc
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/tdf144642_RowHeight_10mm_SavedByCalc.xlsx differ
diff --git a/sc/qa/unit/data/xlsx/tdf144642_RowHeight_28.35pt_SavedByExcel.xlsx 
b/sc/qa/unit/data/xlsx/tdf144642_RowHeight_28.35pt_SavedByExcel.xlsx
new file mode 100644
index ..367922d6581f
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/tdf144642_RowHeight_28.35pt_SavedByExcel.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test.cxx 
b/sc/qa/unit/subsequent_export_test.cxx
index aa2a12f69d33..ad27741d4ad8 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -1564,7 +1564,7 @@ void ScExportTest::testMiscRowHeightExport()
 static const TestParam::RowData DfltRowData[] = {
 { 0, 4, 0, 529, 0, false },
 { 5, 10, 0, 1058, 0, false },
-{ 17, 20, 0, 1767, 0, false },
+{ 17, 20, 0, 1746, 0, false },
 // check last couple of row in document to ensure
 // they are 5.29mm ( effective default row xlsx height )
 { 1048573, 1048575, 0, 529, 0, false },
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index cea7c5e00628..2be6a07c4af8 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -199,6 +199,7 @@ public:
 void testTdf136721_paper_size();
 void testTdf139258_rotated_image();
 void testTdf142854_GridVisibilityImportXlsxInHeadlessMode();
+void testTdf144642_RowHeightRounding();
 void testTdf140431();
 void 

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

2019-04-17 Thread tundet (via logerrit)
 include/oox/export/chartexport.hxx|3 ++
 include/oox/export/drawingml.hxx  |   10 
 include/oox/export/shapes.hxx |   10 
 oox/source/export/chartexport.cxx |   26 +-
 oox/source/export/drawingml.cxx   |   14 
 oox/source/export/shapes.cxx  |   24 
 sc/qa/unit/data/xlsx/chart_hyperlink.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx |   24 
 sc/source/filter/excel/xeescher.cxx   |7 --
 sc/source/filter/inc/xcl97rec.hxx |   14 
 sc/source/filter/inc/xeescher.hxx |4 ++-
 sc/source/filter/xcl97/xcl97esc.cxx   |2 -
 sc/source/filter/xcl97/xcl97rec.cxx   |   35 --
 13 files changed, 118 insertions(+), 55 deletions(-)

New commits:
commit dc091e7fd952b0530db8583247c2f910d627700a
Author: tundet 
AuthorDate: Fri Apr 12 10:21:42 2019 +0200
Commit: László Németh 
CommitDate: Wed Apr 17 10:17:47 2019 +0200

tdf#123645 XLSX export: fix hyperlink inserted to chart

Hyperlink inserted to chart lost after export.

chart_hyperlink.xlsx: Test file from Excel 2016.

Change-Id: Ideca10e544193ba43d7c2ef6e9dd8e393383edc1
Reviewed-on: https://gerrit.libreoffice.org/70648
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/include/oox/export/chartexport.hxx 
b/include/oox/export/chartexport.hxx
index c5f9e6ebd188..b39b3f52b455 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -101,6 +101,7 @@ private:
 css::uno::Reference< css::frame::XModel > mxChartModel;
 css::uno::Reference< css::chart::XDiagram > mxDiagram;
 css::uno::Reference< css::chart2::XDiagram > mxNewDiagram;
+std::shared_ptr mpURLTransformer;
 
 // members filled by InitRangeSegmentationProperties (retrieved from 
DataProvider)
 bool mbHasCategoryLabels; //if the categories are only automatically 
generated this will be false
@@ -214,6 +215,8 @@ public:
  ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType );
 virtual ~ChartExport() {}
 
+void SetURLTranslator(const std::shared_ptr& pTransformer);
+
 const css::uno::Reference< css::frame::XModel >& getModel(){ return 
mxChartModel; }
 
 void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& 
xShape, sal_Int32 nID, sal_Int32 nChartCount );
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index b3cdbb3600ba..8ed1aaf0d702 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -96,6 +96,16 @@ namespace core {
 
 namespace drawingml {
 
+class OOX_DLLPUBLIC URLTransformer
+{
+public:
+virtual ~URLTransformer();
+
+virtual OUString getTransformedString(const OUString& rURL) const;
+
+virtual bool isExternalURL(const OUString& rURL) const;
+};
+
 // Our rotation is counter-clockwise and is in 100ths of a degree.
 // drawingML rotation is clockwise and is in 6ths of a degree.
 template  T ExportRotateClockwisify(T input)
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
index aa0ca2cd1a62..b7755ccee9d2 100644
--- a/include/oox/export/shapes.hxx
+++ b/include/oox/export/shapes.hxx
@@ -78,16 +78,6 @@ OOX_DLLPUBLIC css::uno::Reference 
GetOLEObjectStream(
 
 namespace oox { namespace drawingml {
 
-class OOX_DLLPUBLIC URLTransformer
-{
-public:
-virtual ~URLTransformer();
-
-virtual OUString getTransformedString(const OUString& rURL) const;
-
-virtual bool isExternalURL(const OUString& rURL) const;
-};
-
 class OOX_DLLPUBLIC ShapeExport : public DrawingML {
 
 private:
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 15e9bca1c1c9..672ae2579d99 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -376,6 +376,7 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, 
FSHelperPtr pFS, Reference< f
 , mnXmlNamespace( nXmlNamespace )
 , mnSeriesCount(0)
 , mxChartModel( xModel )
+, mpURLTransformer(new URLTransformer)
 , mbHasCategoryLabels( false )
 , mbHasZAxis( false )
 , mbIs3DChart( false )
@@ -384,6 +385,11 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, 
FSHelperPtr pFS, Reference< f
 {
 }
 
+void ChartExport::SetURLTranslator(const std::shared_ptr& 
pTransformer)
+{
+mpURLTransformer = pTransformer;
+}
+
 sal_Int32 ChartExport::getChartType( )
 {
 OUString sChartType = mxDiagram->getDiagramType();
@@ -445,6 +451,8 @@ void ChartExport::WriteChartObj( const Reference< XShape >& 
xShape, sal_Int32 nI
 {
 FSHelperPtr pFS = GetFS();
 
+Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
+
 pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
 
 pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
@@ -455,11 +463,27 @@ void 

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

2018-03-08 Thread Jan Holesovsky
 include/oox/core/xmlfilterbase.hxx|6 +-
 oox/source/core/xmlfilterbase.cxx |2 --
 sc/qa/unit/subsequent_export-test.cxx |4 
 sc/source/filter/excel/excdoc.cxx |3 ++-
 sd/qa/unit/export-tests-ooxml1.cxx|4 ++--
 sd/source/filter/eppt/pptx-epptooxml.cxx  |4 ++--
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx |   11 +++
 7 files changed, 26 insertions(+), 8 deletions(-)

New commits:
commit bf5c486946f2b0a708a251c8ff614293ae37c6ba
Author: Jan Holesovsky 
Date:   Thu Mar 8 12:24:48 2018 +0100

tdf#116283 oox customXml: Don't write the Relationship to DOCX files twice.

Change-Id: Id3da40138e86c142707e377aa897df372aacb704
Reviewed-on: https://gerrit.libreoffice.org/50947
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/include/oox/core/xmlfilterbase.hxx 
b/include/oox/core/xmlfilterbase.hxx
index 75fc03920b79..69586fe020bb 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -226,7 +226,12 @@ public:
  */
 void exportDocumentProperties( const css::uno::Reference< 
css::document::XDocumentProperties >& xProperties );
 
+/** Write the customXml entries we are preserving (xlsx and pptx only). */
+void exportCustomFragments();
+
+/** Read the document properties and also the customXml entries (xlsx and 
pptx only). */
 void importDocumentProperties();
+
 static void putPropertiesToDocumentGrabBag(const 
css::uno::Reference& xDstDoc,
const 
comphelper::SequenceAsHashMap& rProperties);
 
@@ -259,7 +264,6 @@ private:
 const css::uno::Reference< css::io::XStream >& 
rxOutStream ) const override;
 
 void importCustomFragments(css::uno::Reference& 
xDocumentStorage);
-void exportCustomFragments();
 
 private:
 ::std::unique_ptr< XmlFilterBaseImpl > mxImpl;
diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index 0388fae5f473..00d202b315da 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -841,8 +841,6 @@ void XmlFilterBase::exportDocumentProperties( const 
Reference< XDocumentProperti
 writeAppProperties( *this, xProperties );
 writeCustomProperties( *this, xProperties );
 }
-
-exportCustomFragments();
 }
 
 // protected --
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 595e563dc301..ff4063f8ed84 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -3055,6 +3055,10 @@ void ScExportTest::testCustomXml()
 xmlDocPtr pRelsDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"customXml/_rels/item1.xml.rels");
 CPPUNIT_ASSERT(pRelsDoc);
 
+// Check there is a relation to itemProps1.xml.
+assertXPath(pRelsDoc, "/r:Relationships/r:Relationship", 1);
+assertXPath(pRelsDoc, "/r:Relationships/r:Relationship[@Id='rId1']", 
"Target", "itemProps1.xml");
+
 std::shared_ptr pStream = 
XPathHelper::parseExportStream(pXPathFile, m_xSFactory, "ddp/ddpfile.xen");
 CPPUNIT_ASSERT(pStream);
 }
diff --git a/sc/source/filter/excel/excdoc.cxx 
b/sc/source/filter/excel/excdoc.cxx
index d2dd5d147b0e..bc0d4e3de177 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -830,7 +830,8 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm )
 uno::Reference xDPS( 
pDocShell->GetModel(), uno::UNO_QUERY_THROW );
 uno::Reference xDocProps = 
xDPS->getDocumentProperties();
 
-rStrm.exportDocumentProperties( xDocProps );
+rStrm.exportDocumentProperties(xDocProps);
+rStrm.exportCustomFragments();
 
 sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream();
 rWorkbook->startElement( XML_workbook,
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 2ccc48982727..54e411a482f7 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -847,8 +847,8 @@ void SdOOXMLExportTest1::testCustomXml()
 CPPUNIT_ASSERT(pRelsDoc);
 
 // Check there is a relation to itemProps1.xml.
-const OUString sXmlPath = 
"/rels:Relationships/rels:Relationship[@Id='rId1']";
-assertXPath(pRelsDoc, OUStringToOString(sXmlPath, RTL_TEXTENCODING_UTF8), 
"Target", "itemProps1.xml");
+assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship", 1);
+assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", 
"Target", "itemProps1.xml");
 
 std::shared_ptr pStream = parseExportStream(tempFile, 
"ddp/ddpfile.xen");
 CPPUNIT_ASSERT(pStream);
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index ca5f9ef56c67..2672f17c185f 100644
---