dev/null                            |binary
 oox/source/core/contexthandler2.cxx |   31 ++++++---------
 sd/qa/unit/data/odp/Math.fodp       |   70 ++++++++++++++++++++++++++++++++++++
 sd/qa/unit/export-tests-ooxml2.cxx  |    6 +--
 sd/qa/unit/export-tests-ooxml4.cxx  |    2 -
 5 files changed, 87 insertions(+), 22 deletions(-)

New commits:
commit e8e7ba59e6f90dbdc9b660d72132293b78bc48a7
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Sep 11 12:57:25 2024 +0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Sep 12 08:46:43 2024 +0200

    Related: tdf#129061 Avoid formula import and use fallback for now
    
    Until we support the correct inline formulas, their import fails badly
    in Impress, because we completely lose them in boxes with other content,
    and even where they are the sole content, they stretch to the size of
    the box incorrectly.
    
    Commit 4038d6c393c3cf6330671124ba69cdba98b24960 (tdf#117658 PPTX import:
    fix duplicated math object handling, 2019-11-13) opted to enable the
    Choice variant from the AlternateContent representing formula boxes.
    This change switches to Fallback graphic, losing the option to edit
    standalone imported formulas, but instead, allowing to see the formulas
    as they were created in PowerPoint.
    
    Unit test in sd/qa/unit/export-tests-ooxml2.cxx, created in commit
    331a0a347e2ed238ff41c8cd7815b946cc95ac0f (starmath: fix OOXML export
    of non-BMP Unicode, 2016-01-21) was changed, because it depended on
    importing the formula from PPTX, which is disabled here. Since it
    was fixing the export part, the FODP source seems to be a reasonable
    replacement.
    
    Change-Id: Ibd0e2bcd68296020c3bc057cb6a563918926cf2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173163
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173212
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/oox/source/core/contexthandler2.cxx 
b/oox/source/core/contexthandler2.cxx
index 93da89b8c043..3229b0bdeeac 100644
--- a/oox/source/core/contexthandler2.cxx
+++ b/oox/source/core/contexthandler2.cxx
@@ -24,6 +24,7 @@
 #include <oox/token/tokens.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <o3tl/safeint.hxx>
+#include <o3tl/string_view.hxx>
 #include <osl/diagnose.h>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -239,30 +240,24 @@ bool ContextHandler2Helper::prepareMceContext( sal_Int32 
nElement, const Attribu
                 // is long gone. For now let's decide depending on a list of 
supported
                 // namespaces like we do in writerfilter
 
-                std::vector<OUString> aSupportedNS =
+                std::u16string_view aSupportedNS[] =
                 {
-                    "a14", // Impress needs this to import math formulas.
-                    "p14",
-                    "p15",
-                    "x12ac",
-                    "v"
+                    // u"a14", // We do not currently support inline formulas 
and other a14 stuff
+                    u"p14",
+                    u"p15",
+                    u"x12ac",
+                    u"v"
                 };
 
-                Reference<XServiceInfo> xModel(getDocFilter().getModel(), 
UNO_QUERY);
-                if (xModel.is() && 
xModel->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+                for (size_t pos = 0; pos != std::u16string_view::npos;)
                 {
-                    // No a14 for Calc documents, it would cause duplicated 
shapes as-is.
-                    auto it = std::find(aSupportedNS.begin(), 
aSupportedNS.end(), "a14");
-                    if (it != aSupportedNS.end())
-                    {
-                        aSupportedNS.erase(it);
-                    }
+                    // 'Requires' is a space-separated list
+                    auto ns = o3tl::getToken(aRequires, u' ', pos);
+                    if (!ns.empty() && std::find(std::begin(aSupportedNS), 
std::end(aSupportedNS), ns) == std::end(aSupportedNS))
+                        return false;
                 }
 
-                if (std::find(aSupportedNS.begin(), aSupportedNS.end(), 
aRequires) != aSupportedNS.end())
-                    setMCEState( MCE_STATE::FoundChoice ) ;
-                else
-                    return false;
+                setMCEState( MCE_STATE::FoundChoice ) ;
             }
             break;
 
diff --git a/sd/qa/unit/data/odp/Math.fodp b/sd/qa/unit/data/odp/Math.fodp
new file mode 100644
index 000000000000..676fc84475a2
--- /dev/null
+++ b/sd/qa/unit/data/odp/Math.fodp
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" 
office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.presentation">
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Sans" 
svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="roman" 
style:font-pitch="variable"/>
+  <style:font-face style:name="Liberation Serif" 
svg:font-family="&apos;Liberation Serif&apos;" 
style:font-family-generic="roman" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:style style:name="Object_20_with_20_no_20_fill_20_and_20_no_20_line" 
style:display-name="Object with no fill and no line" style:family="graphic" 
style:parent-style-name="standard">
+   <style:graphic-properties draw:stroke="none" draw:fill="none"/>
+  </style:style>
+  <style:presentation-page-layout style:name="AL1T0">
+   <presentation:placeholder presentation:object="title" svg:x="2cm" 
svg:y="1.7cm" svg:width="24cm" svg:height="3.5cm"/>
+   <presentation:placeholder presentation:object="subtitle" svg:x="2cm" 
svg:y="5.8cm" svg:width="24cm" svg:height="13cm"/>
+  </style:presentation-page-layout>
+ </office:styles>
+ <office:automatic-styles>
+  <style:page-layout style:name="PM1">
+   <style:page-layout-properties fo:margin-top="0" fo:margin-bottom="0" 
fo:margin-left="0" fo:margin-right="0" fo:page-width="254mm" 
fo:page-height="190.5mm" style:print-orientation="landscape"/>
+  </style:page-layout>
+  <style:style style:name="dp1" style:family="drawing-page">
+   <style:drawing-page-properties presentation:background-visible="true" 
presentation:background-objects-visible="true" 
presentation:display-footer="false" presentation:display-page-number="false" 
presentation:display-date-time="false"/>
+  </style:style>
+  <style:style style:name="gr1" style:family="graphic" 
style:parent-style-name="Object_20_with_20_no_20_fill_20_and_20_no_20_line">
+   <style:graphic-properties draw:stroke="none" svg:stroke-width="0" 
draw:fill="none" draw:textarea-horizontal-align="justify" 
draw:textarea-vertical-align="top" draw:auto-grow-height="true" 
draw:fit-to-size="false" style:shrink-to-fit="false" fo:padding-top="0.125cm" 
fo:padding-bottom="0.125cm" fo:padding-left="0.25cm" fo:padding-right="0.25cm" 
fo:wrap-option="no-wrap" draw:ole-draw-aspect="1" style:protect="size"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:master-styles>
+  <draw:layer-set>
+   <draw:layer draw:name="layout"/>
+   <draw:layer draw:name="background"/>
+   <draw:layer draw:name="backgroundobjects"/>
+   <draw:layer draw:name="controls"/>
+   <draw:layer draw:name="measurelines"/>
+  </draw:layer-set>
+  <style:master-page style:name="Title_20_Slide" style:display-name="Title 
Slide" style:page-layout-name="PM1" draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:presentation>
+   <draw:page draw:name="page1" draw:master-page-name="Title_20_Slide" 
presentation:presentation-page-layout-name="AL1T0">
+    <draw:frame draw:name="Formula" draw:style-name="gr1" draw:layer="layout" 
svg:width="14cm" svg:height="2cm" svg:x="8cm" svg:y="8cm">
+     <draw:object>
+      <math xmlns="http://www.w3.org/1998/Math/MathML"; display="block">
+       <semantics>
+        <mrow>
+         <mrow>
+          <msup>
+           <mi mathvariant="italic">𝑎</mi>
+           <mn>2</mn>
+          </msup>
+          <mo stretchy="false">+</mo>
+          <msup>
+           <mi mathvariant="italic">𝑏</mi>
+           <mn>2</mn>
+          </msup>
+         </mrow>
+         <mo stretchy="false">=</mo>
+         <msup>
+          <mi mathvariant="italic">𝑐</mi>
+          <mn>2</mn>
+         </msup>
+        </mrow>
+       </semantics>
+      </math>
+     </draw:object>
+    </draw:frame>
+   </draw:page>
+  </office:presentation>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sd/qa/unit/data/pptx/Math.pptx b/sd/qa/unit/data/pptx/Math.pptx
deleted file mode 100644
index fef20675b59e..000000000000
Binary files a/sd/qa/unit/data/pptx/Math.pptx and /dev/null differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index de274bacb1c5..43ca89e6b860 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -374,13 +374,13 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testMathObject)
     }
 }
 
-CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testMathObjectPPT2010)
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testMathExportNonBMP)
 {
     // Check import / export of math object
-    createSdImpressDoc("pptx/Math.pptx");
+    createSdImpressDoc("odp/Math.fodp");
     save("Impress Office Open XML");
 
-    // Export an MS specific ole object (imported from a PPTX document)
+    // Export an MS specific ole object
     {
         xmlDocUniquePtr pXmlDocContent = parseExport("ppt/slides/slide1.xml");
         assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice"_ostr,
diff --git a/sd/qa/unit/export-tests-ooxml4.cxx 
b/sd/qa/unit/export-tests-ooxml4.cxx
index 06cc2805d64d..f99a3897b3af 100644
--- a/sd/qa/unit/export-tests-ooxml4.cxx
+++ b/sd/qa/unit/export-tests-ooxml4.cxx
@@ -429,7 +429,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf129372)
 
     const SdrObject* pObj = pPage->GetObj(0);
     CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr);
-    CPPUNIT_ASSERT_EQUAL(SdrObjKind::OLE2, pObj->GetObjIdentifier());
+    CPPUNIT_ASSERT_EQUAL(SdrObjKind::CustomShape, pObj->GetObjIdentifier());
 }
 
 CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testShapeGlowEffect)

Reply via email to