connectivity/source/drivers/dbase/dindexnode.cxx |    2 
 oox/source/export/shapes.cxx                     |   15 ++---
 sd/qa/unit/export-tests-ooxml4.cxx               |    3 -
 sw/source/core/access/accmap.cxx                 |    2 
 sw/source/core/text/txtfrm.cxx                   |    2 
 sw/source/uibase/utlui/navipi.cxx                |    6 +-
 test/source/bootstrapfixture.cxx                 |   58 ++++++++++++++++++++++-
 7 files changed, 69 insertions(+), 19 deletions(-)

New commits:
commit e2bf07ea2553acf204f94c90bb4f547b15b12861
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Sep 19 12:53:19 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Sep 21 22:33:24 2024 +0200

    cid#1607126 silence Overflowed constant
    
    and
    
    cid#1607075 Overflowed constant
    cid#1606969 Overflowed constant
    cid#1606652 Overflowed constant
    
    Change-Id: I7f7ee294438b73785b4005eb529bda98fdddfc97
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173741
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx 
b/connectivity/source/drivers/dbase/dindexnode.cxx
index 6eb435765fa6..6857679c98f1 100644
--- a/connectivity/source/drivers/dbase/dindexnode.cxx
+++ b/connectivity/source/drivers/dbase/dindexnode.cxx
@@ -168,7 +168,7 @@ bool ONDXPage::Find(const ONDXKey& rKey)
     else if (i == nCount)
     {
         rIndex.m_aCurLeaf = this;
-        rIndex.m_nCurNode = i - 1;
+        rIndex.m_nCurNode = sal_uInt16(i - 1);
         bResult = false;
     }
     else
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index ebcd334825a6..ab44250bca8c 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1282,7 +1282,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection()
                     {
                         SwAccessibleObjShape_Impl  *pShape = pShapes.get();
                         size_t nNumShapes = nShapes;
-                        while( nNumShapes )
+                        while (nNumShapes > 0)
                         {
                             if( pShape < pSelShape && 
(pShape->first==(*aIter).first) )
                             {
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 8ab7ca61d2e5..fbd3a3891fbb 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -933,7 +933,7 @@ void RemoveFootnotesForNode(
     rFootnoteIdxs.SeekEntry( rTextNode, &nPos );
     if (nPos < rFootnoteIdxs.size())
     {
-        while (nPos && rTextNode == (rFootnoteIdxs[ nPos ]->GetTextNode()))
+        while (nPos > 0 && rTextNode == (rFootnoteIdxs[ nPos ]->GetTextNode()))
             --nPos;
         if (nPos || rTextNode != (rFootnoteIdxs[ nPos ]->GetTextNode()))
             ++nPos;
diff --git a/sw/source/uibase/utlui/navipi.cxx 
b/sw/source/uibase/utlui/navipi.cxx
index 4db946c53e5f..b2bd8684a1dd 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -79,8 +79,10 @@ void SwNavigationPI::MoveOutline(SwOutlineNodes::size_type 
nSource, SwOutlineNod
     if (!pView)
         return;
     SwWrtShell &rSh = pView->GetWrtShell();
-    if(nTarget < nSource || nTarget == SwOutlineNodes::npos)
-        nTarget ++;
+    if (nTarget == SwOutlineNodes::npos)
+        nTarget = 0;
+    else if (nTarget < nSource)
+        nTarget++;
     if ( !rSh.IsOutlineMovable( nSource ))
         return;
 
commit 275aebc5085cd4b0fd3d045ef1ec65c99e1d5b56
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Sep 21 18:41:17 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Sep 21 22:33:12 2024 +0200

    tdf#163064: pic element is required here, after all
    
    In commit cf15306ccf49da290b391517e2c5dd22a4f1be45 (ERROR: Invalid
    content was found starting with element 'p:pic'., 2014-12-22), the
    pic element inside the oleObj element was only alloswed for the old
    revision of ECMA-736 export, because that was considered invalid by
    officeotron. However, as of ECMA-376-1:2016,  this element is
    mandatory; CT_OleObject definition in Annex A has:
    
     <xsd:element name="pic" type="CT_Picture" minOccurs="1" maxOccurs="1"/>
    
    and Annex L (Primer) has L.7.2.5 "Embeddings in a PresentationML
    Document" saying:
    
     The oleObj element shall have a pic child element that (optionally)
     contains the image data to be used in place of loading the actual
     object data.
    
    The omission of this in the export is the reason of tdf#163064. So
    here I filter out the error from the validation results, which is
    not ideal (I have no way to know if the found pic is really in the
    oleObj, or somewhere else), but a lesser evil, compared to required
    exclusion of all tests that export OLE objects.
    
    Change-Id: Ia73a49da7347e8ff22c626e211b55ba1e0625070
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173761
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index f614b1e003e7..5726e445a452 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2912,15 +2912,12 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
 
     // pic element
     SdrObject* pSdrOLE2(SdrObject::getSdrObjectFromXShape(xShape));
-    // The spec doesn't allow <p:pic> here, but PowerPoint requires it.
-    bool const bEcma = mpFB->getVersion() == oox::core::ECMA_376_1ST_EDITION;
-    if (bEcma)
-        if (auto pOle2Obj = dynamic_cast<SdrOle2Obj*>(pSdrOLE2))
-        {
-            const Graphic* pGraphic = pOle2Obj->GetGraphic();
-            if (pGraphic)
-                WriteGraphicObjectShapePart( xShape, pGraphic );
-        }
+    if (auto pOle2Obj = dynamic_cast<SdrOle2Obj*>(pSdrOLE2))
+    {
+        const Graphic* pGraphic = pOle2Obj->GetGraphic();
+        if (pGraphic)
+            WriteGraphicObjectShapePart(xShape, pGraphic);
+    }
 
     mpFS->endElementNS( mnXmlNamespace, XML_oleObj );
 
diff --git a/sd/qa/unit/export-tests-ooxml4.cxx 
b/sd/qa/unit/export-tests-ooxml4.cxx
index bac50f28bdc1..150c99fbac54 100644
--- a/sd/qa/unit/export-tests-ooxml4.cxx
+++ b/sd/qa/unit/export-tests-ooxml4.cxx
@@ -734,8 +734,6 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, 
testTdf143222_embeddedWorksheet)
     CPPUNIT_ASSERT_MESSAGE("no graphic", pGraphic != nullptr);
     CPPUNIT_ASSERT_MESSAGE("no graphic", !pGraphic->IsNone());
 
-    // TODO: this currently fails - see tdf#163064
-#if 0
     // Check export of embedded worksheet in slide.
     saveAndReload(u"Impress Office Open XML"_ustr);
 
@@ -746,7 +744,6 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, 
testTdf143222_embeddedWorksheet)
     pGraphic = pOleObj->GetGraphic();
     CPPUNIT_ASSERT_MESSAGE("no graphic after the export", pGraphic != nullptr);
     CPPUNIT_ASSERT_MESSAGE("no graphic after the export", !pGraphic->IsNone());
-#endif
 }
 
 CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTdf143315)
diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx
index 891af3c6f640..4cf04adf3db3 100644
--- a/test/source/bootstrapfixture.cxx
+++ b/test/source/bootstrapfixture.cxx
@@ -138,6 +138,59 @@ OString loadFile(const OUString& rURL)
     return aContent;
 }
 
+constexpr std::u16string_view grand_total = u"Grand total of errors in 
submitted package: ";
+
+OUString filterOut(const OUString& s, std::u16string_view excludedSubstr)
+{
+    OUString result = s;
+    for (;;)
+    {
+        sal_Int32 pos = result.indexOf(excludedSubstr);
+        if (pos < 0)
+            break;
+        sal_Int32 start = result.lastIndexOf('
', pos);
+        if (!result.match("ERROR", start + 1))
+            return s; // unexpected string format
+        sal_Int32 end = result.indexOf('
', pos);
+        result = result.replaceAt(start, end - start, u""_ustr);
+        pos = result.lastIndexOf(grand_total);
+        if (pos < 0)
+            return s; // unexpected string format
+        start = end = pos + grand_total.size();
+        while (end < result.getLength() && rtl::isAsciiDigit(result[end]))
+            ++end;
+        std::u16string_view aNumber = result.subView(start, end - start);
+        sal_Int32 nErrors = o3tl::toInt32(aNumber) - 1;
+        result = result.replaceAt(start, end - start, 
OUString::number(nErrors));
+    }
+    return result;
+}
+
+OUString filterValidationResults(const OUString& s)
+{
+    OUString result = s;
+    // In ECMA-376-1 Second Edition, 2008, there is the following restriction 
for oleObj:
+    //
+    // <xsd:choice minOccurs="1" maxOccurs="1">
+    //  <xsd:element name="embed" type="CT_OleObjectEmbed"/>
+    //  <xsd:element name="link" type="CT_OleObjectLink"/>
+    //  <xsd:element name="pic" type="CT_Picture"/>
+    // </xsd:choice>
+    //
+    // This makes simultaneous use of embed (or link) and pic impossible. This 
was obviously a
+    // mistake; and the following editions of standard fixed it: e.g., in 
ECMA-376-1:2016, that
+    // rule is
+    //
+    // <xsd:choice minOccurs="1" maxOccurs="1">
+    //  <xsd:element name="embed" type="CT_OleObjectEmbed"/>
+    //  <xsd:element name="link" type="CT_OleObjectLink"/>
+    // </xsd:choice>
+    // <xsd:element name="pic" type="CT_Picture" minOccurs="1" maxOccurs="1"/>
+    //
+    // But officeotron only knows the old version...
+    result = filterOut(result, u"Invalid content was found starting with 
element 'p:pic'. No child element is expected at this point.");
+    return result;
+}
 }
 #endif
 
@@ -213,15 +266,16 @@ void test::BootstrapFixture::validate(const OUString& 
rPath, test::ValidationFor
 
     if( eFormat == test::OOXML && !aContentOUString.isEmpty() )
     {
+        aContentOUString = filterValidationResults(aContentOUString);
         // check for validation errors here
-        sal_Int32 nIndex = aContentOUString.lastIndexOf("Grand total of errors 
in submitted package: ");
+        sal_Int32 nIndex = aContentOUString.lastIndexOf(grand_total);
         if(nIndex == -1)
         {
             SAL_WARN("test", "no summary line");
         }
         else
         {
-            sal_Int32 nStartOfNumber = nIndex + std::strlen("Grand total of 
errors in submitted package: ");
+            sal_Int32 nStartOfNumber = nIndex + grand_total.size();
             std::u16string_view aNumber = 
aContentOUString.subView(nStartOfNumber);
             sal_Int32 nErrors = o3tl::toInt32(aNumber);
             OString aMsg = "validation error in OOXML export: Errors: " + 
OString::number(nErrors);

Reply via email to