[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - filter/qa filter/source

2022-01-25 Thread Rash419 (via logerrit)
 filter/qa/unit/data/attributeRedefinedTest.odp |binary
 filter/qa/unit/svg.cxx |   42 +
 filter/source/svg/svgwriter.cxx|   14 +++-
 3 files changed, 55 insertions(+), 1 deletion(-)

New commits:
commit e3a0ef15eb7abccff6b55940dbd9b3278004388a
Author: Rash419 
AuthorDate: Mon Jan 24 15:56:15 2022 +0530
Commit: Andras Timar 
CommitDate: Tue Jan 25 09:24:33 2022 +0100

svgexport: fix: attribute id redefined

If there is a id for empty paragraph exist we need to create a empty
text paragraph to accomodate the id if we don't do that then we
get multiple id attribute on same element for example:


Change-Id: I41c21dc94deef93e423aaff2248f6931fa6ca8de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128884
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/filter/qa/unit/data/attributeRedefinedTest.odp 
b/filter/qa/unit/data/attributeRedefinedTest.odp
new file mode 100644
index ..dfb814bfb9ec
Binary files /dev/null and b/filter/qa/unit/data/attributeRedefinedTest.odp 
differ
diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx
index c59d3cf63dca..95f894ed42cd 100644
--- a/filter/qa/unit/svg.cxx
+++ b/filter/qa/unit/svg.cxx
@@ -138,6 +138,48 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testShapeNographic)
 xStorable->storeToURL("private:stream", 
aMediaDescriptor.getAsConstPropertyValueList());
 }
 
+CPPUNIT_TEST_FIXTURE(SvgFilterTest, attributeRedefinedTest)
+{
+// Load document containing empty paragraphs with ids.
+load("attributeRedefinedTest.odp");
+
+// Export to SVG.
+uno::Reference xStorable(getComponent(), 
uno::UNO_QUERY_THROW);
+SvMemoryStream aStream;
+uno::Reference xOut = new 
utl::OOutputStreamWrapper(aStream);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
+aMediaDescriptor["OutputStream"] <<= xOut;
+xStorable->storeToURL("private:stream", 
aMediaDescriptor.getAsConstPropertyValueList());
+aStream.Seek(STREAM_SEEK_TO_BEGIN);
+
+xmlDocPtr pXmlDoc = parseXmlStream();
+
+// We expect four paragraph
+// 2 empty paragraphs with ids
+// 2 paragraphs with text
+// Without the accompanying fix the test would have failed with
+// Expected : 4
+// Actual : 2
+// i.e. 2 of the empty paragraph do not get generated even if there
+// is id imported for the paragraphs
+// If we don't create the empty paragraphs the id attribute attribute gets 
redefined like this:
+// 
+
+OString xPath = 
"//svg:g[@class='TextShape']//svg:text[@class='SVGTextShape']//"
+"svg:tspan[@class='TextParagraph']";
+assertXPath(pXmlDoc, xPath, 4);
+
+//assert that each tspan element with TextParagraph class has id and the 
tspan element of
+//each empty paragraph doesnot contain tspan element with class 
TextPosition
+assertXPath(pXmlDoc, xPath + "[1]", "id", "id4");
+assertXPath(pXmlDoc, xPath + "[2]", "id", "id5");
+assertXPath(pXmlDoc, xPath + "[2]//svg:tspan[@class='TextPosition']", 0);
+assertXPath(pXmlDoc, xPath + "[3]", "id", "id6");
+assertXPath(pXmlDoc, xPath + "[3]//svg:tspan[@class='TextPosition']", 0);
+assertXPath(pXmlDoc, xPath + "[4]", "id", "id7");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 95980ce9b932..694cc073a81c 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -1077,7 +1077,19 @@ bool SVGTextWriter::nextParagraph()
 const OUString& rParagraphId = implGetValidIDFromInterface( 
Reference(xTextContent, UNO_QUERY) );
 if( !rParagraphId.isEmpty() )
 {
-mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId );
+// if there is id for empty paragraph we need to create a empty 
text paragraph
+Reference < XTextRange > xRange( xTextContent, UNO_QUERY_THROW );
+if ( xRange.is() && xRange->getString().isEmpty() )
+{
+endTextParagraph();
+mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", 
"TextParagraph" );
+mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId 
);
+mpTextParagraphElem.reset(new SvXMLElementExport( mrExport, 
XML_NAMESPACE_NONE, aXMLElemTspan, mbIWS, mbIWS ));
+}
+else
+{
+mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId 
);
+}
 }
 return true;
 }


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - filter/qa filter/source sfx2/source

2021-12-24 Thread Miklos Vajna (via logerrit)
 filter/qa/unit/textfilterdetect.cxx |   20 
 filter/source/textfilterdetect/filterdetect.cxx |6 +-
 sfx2/source/doc/objstor.cxx |   10 +-
 3 files changed, 34 insertions(+), 2 deletions(-)

New commits:
commit da88d0e570493cc6b0f56744bfbc00d829b26ee7
Author: Miklos Vajna 
AuthorDate: Tue Dec 21 14:31:34 2021 +0100
Commit: Mike Kaganski 
CommitDate: Sat Dec 25 06:48:11 2021 +0100

filter: try to detect 0-byte DOC files based on extension

Commit ae1f51b4888a3aa14837ac6e4083f33b2176ca45 (tdf#123476 filter: try
to detect 0-byte files based on extension, 2020-10-28), already
implemented this UNO-based import filters, do the same for built-in
filters as well.

Another problem in filter/ was to pick the WW6 filter for .doc --
require export+preferred support in the filter to get WW8 instead.

An additional filter that may kick in is MS Word 2003 XML: this is
avoided by requiring "preferred".

(cherry picked from commit e519d7465f38367205b37bc80f0244029e352306)

Conflicts:
filter/qa/unit/textfilterdetect.cxx

Change-Id: I46e280beb5341213b0fe7a09a549b52c0c1ea3f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127296
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127432

diff --git a/filter/qa/unit/data/empty.doc b/filter/qa/unit/data/empty.doc
new file mode 100644
index ..e69de29bb2d1
diff --git a/filter/qa/unit/textfilterdetect.cxx 
b/filter/qa/unit/textfilterdetect.cxx
index 74d967490ffe..4083610b0736 100644
--- a/filter/qa/unit/textfilterdetect.cxx
+++ b/filter/qa/unit/textfilterdetect.cxx
@@ -116,6 +116,26 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testEmptyFile)
 // Without the accompanying fix in place, this test would have failed, as 
it was opened in
 // Writer instead.
 
CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument"));
+getComponent()->dispose();
+
+// ... and DOC
+aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "empty.doc";
+// Without the accompanying fix in place, this test would have failed, the 
import filter aborted
+// loading.
+getComponent() = loadFromDesktop(aURL);
+xServiceInfo.set(getComponent(), uno::UNO_QUERY);
+CPPUNIT_ASSERT(xServiceInfo.is());
+
CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextDocument"));
+uno::Reference xModel(getComponent(), uno::UNO_QUERY);
+uno::Sequence aArgs = xModel->getArgs();
+comphelper::SequenceAsHashMap aMap(aArgs);
+OUString aFilterName;
+aMap["FilterName"] >>= aFilterName;
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: MS Word 97
+// - Actual  : MS WinWord 6.0
+// i.e. opening worked, but saving back failed instead of producing a WW8 
binary file.
+CPPUNIT_ASSERT_EQUAL(OUString("MS Word 97"), aFilterName);
 }
 }
 
diff --git a/filter/source/textfilterdetect/filterdetect.cxx 
b/filter/source/textfilterdetect/filterdetect.cxx
index 1f5080ad0951..4a6314c9224a 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -149,7 +149,11 @@ bool HandleEmptyFileUrlByExtension(MediaDescriptor& 
rMediaDesc, const OUString&
 return false;
 }
 
-std::shared_ptr 
pFilter(SfxFilterMatcher().GetFilter4Extension(rExt));
+// Requiring the export+preferred flags helps to find the relevant filter, 
e.g. .doc -> WW8 (and
+// not WW6 or Mac_Word).
+SfxFilterFlags nMust
+= SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | 
SfxFilterFlags::PREFERED;
+std::shared_ptr 
pFilter(SfxFilterMatcher().GetFilter4Extension(rExt, nMust));
 if (!pFilter)
 {
 return false;
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 49d90e54c599..abdb402e507e 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -774,7 +774,15 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed )
 }
 else
 {
-bOk = ConvertFrom(*pMedium);
+if (tools::isEmptyFileUrl(pMedium->GetName()))
+{
+// The import filter would fail with empty input.
+bOk = true;
+}
+else
+{
+bOk = ConvertFrom(*pMedium);
+}
 InitOwnModel_Impl();
 }
 }


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - filter/qa filter/source

2020-09-08 Thread Miklos Vajna (via logerrit)
 filter/qa/unit/data/shape-nographic.odp |binary
 filter/qa/unit/svg.cxx  |   19 +++
 filter/source/svg/svgexport.cxx |3 ++-
 filter/source/svg/svgwriter.cxx |5 -
 4 files changed, 25 insertions(+), 2 deletions(-)

New commits:
commit ac4030a0ca1aecd15d068b67780b81671c5a9aca
Author: Miklos Vajna 
AuthorDate: Mon Sep 7 17:00:44 2020 +0200
Commit: Miklos Vajna 
CommitDate: Tue Sep 8 10:18:39 2020 +0200

SVG export: fix failure on trying to read graphic of a 3D shape

Regression from commit 8fc1b60f62c213a0476f3acc9f89cd5eccbf335d (sw SVG
export: try to reuse original bitmap data for JPG and PNG bitmaps,
2020-02-27), which generalized the code that tries to get the original
bitmap of shapes for performance reasons. Originally this worked with
SdrGrafObj, but now we try every XShape which has a Graphic property.

Add the missing check, so shapes without a graphic property just miss
the fast path, but doesn't fail the entire SVG export.

(cherry picked from commit fbcdbfef8664430e15b9429187b58dede992accf)

Conflicts:
filter/qa/unit/svg.cxx
filter/source/svg/svgexport.cxx

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

diff --git a/filter/qa/unit/data/shape-nographic.odp 
b/filter/qa/unit/data/shape-nographic.odp
new file mode 100644
index ..43186d614986
Binary files /dev/null and b/filter/qa/unit/data/shape-nographic.odp differ
diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx
index a8b177ed11bf..c59d3cf63dca 100644
--- a/filter/qa/unit/svg.cxx
+++ b/filter/qa/unit/svg.cxx
@@ -119,6 +119,25 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(SvgFilterTest, testShapeNographic)
+{
+// Load a document containing a 3D shape.
+load("shape-nographic.odp");
+
+// Export to SVG.
+uno::Reference xStorable(getComponent(), 
uno::UNO_QUERY_THROW);
+SvMemoryStream aStream;
+uno::Reference xOut = new 
utl::OOutputStreamWrapper(aStream);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
+aMediaDescriptor["OutputStream"] <<= xOut;
+
+// Without the accompanying fix in place, this test would have failed with:
+// An uncaught exception of type com.sun.star.io.IOException
+// - SfxBaseModel::impl_store  failed: 0xc10(Error Area:Io 
Class:Write Code:16)
+xStorable->storeToURL("private:stream", 
aMediaDescriptor.getAsConstPropertyValueList());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index ab1ee9ce647b..50083f7b1f8d 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -58,6 +58,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -604,7 +605,7 @@ bool SVGFilter::implExportImpressOrDraw( const Reference< 
XOutputStream >& rxOSt
 {
 delete mpSVGDoc;
 mpSVGDoc = nullptr;
-OSL_FAIL( "Exception caught" );
+SAL_WARN("filter.svg", "Exception caught");
 }
 
 if( nullptr != pSdrModel )
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 6f4c25c6f0f0..7bc652e58a42 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2691,7 +2691,10 @@ void GetGraphicFromXShape(const 
css::uno::Reference* pShap
 }
 
 uno::Reference xGraphic;
-xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
+if (xPropertySet->getPropertySetInfo()->hasPropertyByName("Graphic"))
+{
+xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
+}
 rGraphic= Graphic(xGraphic);
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits