[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 5 commits - android/source sal/osl sc/inc sc/source svx/source

Mert Tumer (via logerrit) logerrit at kemper.freedesktop.org
Wed May 13 19:44:11 UTC 2020


 android/source/build.gradle      |    7 +++++++
 sal/osl/unx/file.cxx             |   24 +++++++++++++++++-------
 sc/inc/document.hxx              |    2 +-
 sc/inc/table.hxx                 |    2 +-
 sc/source/core/data/document.cxx |    4 ++--
 sc/source/core/data/table2.cxx   |   31 +++++++++++++++++++++++++++----
 sc/source/ui/view/viewdata.cxx   |   29 +++++++++++------------------
 sc/source/ui/view/viewfun5.cxx   |    3 ++-
 svx/source/unodraw/unoprov.cxx   |   22 +++++++++++++++++-----
 9 files changed, 85 insertions(+), 39 deletions(-)

New commits:
commit e2bdf124eca37cdcac62224269cdc6792126638c
Author:     Mert Tumer <mert.tumer at collabora.com>
AuthorDate: Mon Jan 20 22:08:40 2020 +0300
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed May 13 20:12:30 2020 +0100

    Fix csv dialog pops up on mobile when copy/paste
    
    Change-Id: I9e4b154090ad9da0d10a368656f6f63fe335cecf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87132
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    (cherry picked from commit f99605b6df506d51411d22d377eafd722685edbd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88397
    Tested-by: Jenkins
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 0e61a2a8a072..c80d6b059735 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -33,6 +33,7 @@
 #include <svx/svdpage.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/docfile.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <comphelper/classids.hxx>
 #include <sot/formats.hxx>
 #include <sot/filelist.hxx>
@@ -336,7 +337,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
             {
                 // Do CSV dialog if more than one line. But not if invoked from Automation.
                 sal_Int32 nDelim = pStrBuffer->indexOf('\n');
-                if (!comphelper::Automation::AutomationInvokedZone::isActive()
+                if (!comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()) && !comphelper::Automation::AutomationInvokedZone::isActive()
                     && nDelim >= 0 && nDelim != pStrBuffer->getLength () - 1)
                 {
                     vcl::Window* pParent = GetActiveWin();
commit 935c46c4e65b30486daac27c5bfd4c0532c8fcb8
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Nov 18 15:35:18 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed May 13 20:07:04 2020 +0100

    crashtesting fdo78617-2.ods
    
    as a consequence of
            commit feec8e3c34e08b621098a17f1011dccd0b4f7f4c
            Date:   Tue Nov 12 16:00:55 2019 +0200
        reduce iteration in ScViewData::GetScrPos
    
    Change-Id: Iec539c33bd80b9ad2d2a3698d443c5cec81f8f85
    Reviewed-on: https://gerrit.libreoffice.org/83093
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index e4ca4479bd3b..b5939dbbc83e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3282,17 +3282,20 @@ sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fS
 
                     // round-down a single height value, multiply resulting (pixel) values
                     const sal_uLong nOneHeight = static_cast<sal_uLong>( aData.mnValue * fScale );
-                    SCROW nRowsInSegment = nSegmentEnd + 1 - nRow;
-                    if (pnMaxHeight)
+                    // sometimes scaling results in zero height
+                    if (nOneHeight)
                     {
-                        nRowsInSegment = std::min(nRowsInSegment, static_cast<SCROW>(*pnMaxHeight / nOneHeight + 1));
-                        nHeight += nOneHeight * nRowsInSegment;
-                        if (nHeight > *pnMaxHeight)
-                            return nHeight;
+                        SCROW nRowsInSegment = nSegmentEnd + 1 - nRow;
+                        if (pnMaxHeight)
+                        {
+                            nRowsInSegment = std::min(nRowsInSegment, static_cast<SCROW>(*pnMaxHeight / nOneHeight + 1));
+                            nHeight += nOneHeight * nRowsInSegment;
+                            if (nHeight > *pnMaxHeight)
+                                return nHeight;
+                        }
+                        else
+                            nHeight += nOneHeight * nRowsInSegment;
                     }
-                    else
-                        nHeight += nOneHeight * nRowsInSegment;
-
 
                     nRow = nSegmentEnd + 1;
                 }
commit 50cf5641eda91337015ae0ec34fd24ce22e9583b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Nov 12 16:00:55 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed May 13 20:06:32 2020 +0100

    reduce iteration in ScViewData::GetScrPos
    
    we already have a ScTable::GetRowHeightScaled method that uses spans, so use
    that.
    
    Change-Id: I126292b4a8b37ebf2d4f737dcbfdadc31226531e
    Reviewed-on: https://gerrit.libreoffice.org/82520
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 15fdc5074357..a23e14296efe 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1860,7 +1860,7 @@ public:
      * specified height.
      */
     SCROW                       GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const;
-    sal_uLong                   GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
+    sal_uLong                   GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale, const sal_uLong* pnMaxHeight = nullptr ) const;
     SC_DLLPUBLIC sal_uLong      GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
     SC_DLLPUBLIC sal_uLong      GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index b2fca017608f..a7d051663e2a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -808,7 +808,7 @@ public:
     sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
     sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
     sal_uLong       GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
-    sal_uLong       GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
+    sal_uLong       GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale, const sal_uLong* pnMaxHeight = nullptr ) const;
     sal_uLong       GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const;
     sal_uLong       GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const;
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 106360e2a14d..bbdeaeb32d3d 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4183,7 +4183,7 @@ SCROW ScDocument::GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const
 }
 
 sal_uLong ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow,
-        SCTAB nTab, double fScale ) const
+        SCTAB nTab, double fScale, const sal_uLong* pnMaxHeight ) const
 {
     // faster for a single row
     if (nStartRow == nEndRow)
@@ -4194,7 +4194,7 @@ sal_uLong ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow,
         return 0;
 
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
-        return maTabs[nTab]->GetScaledRowHeight( nStartRow, nEndRow, fScale);
+        return maTabs[nTab]->GetScaledRowHeight( nStartRow, nEndRow, fScale, pnMaxHeight );
 
     OSL_FAIL("wrong sheet number");
     return 0;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 1eb549b29ade..e4ca4479bd3b 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3255,7 +3255,7 @@ sal_uLong ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZ
         return (nEndRow - nStartRow + 1) * static_cast<sal_uLong>(ScGlobal::nStdRowHeight);
 }
 
-sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const
+sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale, const sal_uLong* pnMaxHeight ) const
 {
     OSL_ENSURE(ValidRow(nStartRow) && ValidRow(nEndRow),"wrong row number");
 
@@ -3281,8 +3281,18 @@ sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fS
                     SCROW nSegmentEnd = std::min( nLastRow, aData.mnRow2 );
 
                     // round-down a single height value, multiply resulting (pixel) values
-                    sal_uLong nOneHeight = static_cast<sal_uLong>( aData.mnValue * fScale );
-                    nHeight += nOneHeight * ( nSegmentEnd + 1 - nRow );
+                    const sal_uLong nOneHeight = static_cast<sal_uLong>( aData.mnValue * fScale );
+                    SCROW nRowsInSegment = nSegmentEnd + 1 - nRow;
+                    if (pnMaxHeight)
+                    {
+                        nRowsInSegment = std::min(nRowsInSegment, static_cast<SCROW>(*pnMaxHeight / nOneHeight + 1));
+                        nHeight += nOneHeight * nRowsInSegment;
+                        if (nHeight > *pnMaxHeight)
+                            return nHeight;
+                    }
+                    else
+                        nHeight += nOneHeight * nRowsInSegment;
+
 
                     nRow = nSegmentEnd + 1;
                 }
@@ -3292,7 +3302,17 @@ sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fS
         return nHeight;
     }
     else
-        return static_cast<sal_uLong>((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight * fScale);
+    {
+        const sal_uLong nOneHeight = static_cast<sal_uLong>(ScGlobal::nStdRowHeight * fScale);
+        SCROW nRowsInSegment = nEndRow - nStartRow + 1;
+        if (pnMaxHeight)
+        {
+            nRowsInSegment = std::min(nRowsInSegment, static_cast<SCROW>(*pnMaxHeight / nOneHeight + 1));
+            return nOneHeight * nRowsInSegment;
+        }
+        else
+            return static_cast<sal_uLong>(nRowsInSegment * nOneHeight);
+    }
 }
 
 sal_uInt16 ScTable::GetOriginalHeight( SCROW nRow ) const       // non-0 even if hidden
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 0ea25ebce6de..7c4b719f2e33 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2100,7 +2100,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
         const_cast<ScViewData*>(this)->aScrSize.setHeight( pView->GetGridHeight(eWhichY) );
     }
 
-    sal_uInt16 nTSize;
+    sal_uLong nTSize;
     bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
 
 
@@ -2168,27 +2168,20 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
 
         if (nWhereY >= nStartPosY)
         {
-            for (SCROW nY = nStartPosY; nY < nWhereY && (bAllowNeg || bIsTiledRendering || nScrPosY <= aScrSize.Height()); nY++)
+            if (bAllowNeg || bIsTiledRendering || nScrPosY <= aScrSize.Height())
             {
-                if ( nY > pDoc->MaxRow() )
+                if ( nWhereY-1 > pDoc->MaxRow() )
                     nScrPosY = 0x7FFFFFFF;
+                else if (bAllowNeg || bIsTiledRendering)
+                {
+                    sal_uLong nSizeYPix = pDoc->GetScaledRowHeight( nStartPosY, nWhereY-1, nTabNo, nPPTY );
+                    nScrPosY += nSizeYPix;
+                }
                 else
                 {
-                    nTSize = pDoc->GetRowHeight( nY, nTabNo );
-                    if (nTSize)
-                    {
-                        long nSizeYPix = ToPixel( nTSize, nPPTY );
-                        nScrPosY += nSizeYPix;
-                    }
-                    else if ( nY < pDoc->MaxRow() )
-                    {
-                        // skip multiple hidden rows (forward only for now)
-                        SCROW nNext = pDoc->FirstVisibleRow(nY + 1, pDoc->MaxRow(), nTabNo);
-                        if ( nNext > pDoc->MaxRow() )
-                            nY = pDoc->MaxRow();
-                        else
-                            nY = nNext - 1;     // +=nDir advances to next visible row
-                    }
+                    sal_uLong nMaxHeight = aScrSize.getHeight() - nScrPosY;
+                    sal_uLong nSizeYPix = pDoc->GetScaledRowHeight( nStartPosY, nWhereY-1, nTabNo, nPPTY, &nMaxHeight );
+                    nScrPosY += nSizeYPix;
                 }
             }
         }
commit 63bb08384de63b81374223f7b49def160de69cfd
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Dec 18 15:35:53 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed May 13 20:06:02 2020 +0100

    reduce temporary OUString creation
    
    speeds up dialog load time a little (5%)
    
    Change-Id: Ia4e5f1973bb6f06b2b5ec6a251e4ad07fc3636d2
    Reviewed-on: https://gerrit.libreoffice.org/85389
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 06bd11bda42e..02c39a1b9362 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -1834,12 +1834,24 @@ static bool SvxUnoConvertResourceStringBuiltIn(const char** pSourceResIds, const
 
     for(int i = 0; i < nCount; ++i )
     {
-        OUString aStrDefName = bToApi ? SvxResId(pSourceResIds[i]) : OUString::createFromAscii(pSourceResIds[i]);
-        if( sStr == aStrDefName )
+        if (bToApi)
+        {
+            OUString aStrDefName = SvxResId(pSourceResIds[i]);
+            if( sStr == aStrDefName )
+            {
+                OUString aReplace = OUString::createFromAscii(pDestResIds[i]);
+                rString = rString.replaceAt( 0, aStrDefName.getLength(), aReplace );
+                return true;
+            }
+        }
+        else
         {
-            OUString aReplace = bToApi ? OUString::createFromAscii(pDestResIds[i]) : SvxResId(pDestResIds[i]);
-            rString = rString.replaceAt( 0, aStrDefName.getLength(), aReplace );
-            return true;
+            if( sStr.equalsAscii(pSourceResIds[i]) )
+            {
+                OUString aReplace = SvxResId(pDestResIds[i]);
+                rString = rString.replaceAt( 0, strlen(pSourceResIds[i]), aReplace );
+                return true;
+            }
         }
     }
 
commit d28d47b1bf02c8385c988388ee01726f61d17693
Author:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
AuthorDate: Mon Nov 18 17:08:00 2019 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed May 13 20:04:03 2020 +0100

    tdf#128101 android: fix documents with manual page break
    
    code reads a .ui file to show a menu to edit/delete that pagebreak. That
    file was not packaged in the Android viewer and causes an exception that
    is not handled and ultimately results in a crash.
    
    Change-Id: Ie73d886daf9202ba12e1b5a241bc7b6d184ae770
    Reviewed-on: https://gerrit.libreoffice.org/83104
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86165
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/android/source/build.gradle b/android/source/build.gradle
index fe7ac2d30afe..428b709f4da5 100644
--- a/android/source/build.gradle
+++ b/android/source/build.gradle
@@ -149,6 +149,13 @@ task copyUnpackAssets(type: Copy) {
                 )
         }
     }
+    // documents with manual page break trigger attempt to read the ui file
+    // would trigger a css::container::NoSuchElementException with osl_File_E_NOENT
+    // if not present and since it is not caught would crash the app...
+    into('config') {
+        from "${liboInstdir}/share/config"
+        include '**/pagebreakmenu.ui'
+    }
 }
 
 task copyAssets(type: Copy) {
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 2ca6b8c06ff3..10dcf74a0ab3 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -890,13 +890,23 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
     {
         OString aData;
         bool bCache = true;
-        AndroidFileCache::Entry *pHit = AndroidFileCache::getHitCache().find(cpFilePath);
+
+        const char *cpAssetsPath = cpFilePath + sizeof("/assets/") - 1;
+        // some requests are /assets//foo...
+        if (cpAssetsPath[0] == '/')
+        {
+            __android_log_print(ANDROID_LOG_DEBUG,"libo:sal/osl/unx/file", "double-slash in path: %s", cpFilePath);
+            cpAssetsPath++;
+        }
+
+        AndroidFileCache::Entry *pHit = AndroidFileCache::getHitCache().find(cpAssetsPath);
         if (pHit)
             aData = pHit->maData;
+
         else
         {
             bCache = false;
-            AndroidFileCache::Entry *pMiss = AndroidFileCache::getMissCache().find(cpFilePath);
+            AndroidFileCache::Entry *pMiss = AndroidFileCache::getMissCache().find(cpAssetsPath);
             if (pMiss)
             {
                 errno = ENOENT;
@@ -904,10 +914,10 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
                 return osl_File_E_NOENT;
             }
             AAssetManager* mgr = lo_get_native_assetmgr();
-            AAsset* asset = AAssetManager_open(mgr, cpFilePath + sizeof("/assets/")-1, AASSET_MODE_BUFFER);
+            AAsset* asset = AAssetManager_open(mgr, cpAssetsPath, AASSET_MODE_BUFFER);
             if (!asset)
             {
-                AndroidFileCache::getMissCache().insert(cpFilePath, aData);
+                AndroidFileCache::getMissCache().insert(cpAssetsPath, aData);
                 errno = ENOENT;
                 __android_log_print(ANDROID_LOG_ERROR,"libo:sal/osl/unx/file", "failed to open %s", cpFilePath);
                 return osl_File_E_NOENT;
@@ -924,7 +934,7 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
                 aData = OString(pData, SAL_NO_ACQUIRE);
 
                 if (pData->length < 50 * 1024)
-                    AndroidFileCache::getHitCache().insert(cpFilePath, aData);
+                    AndroidFileCache::getHitCache().insert(cpAssetsPath, aData);
             }
         }
 
@@ -935,8 +945,8 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle,
             // loading a document from /assets fails with that idiotic
             // "General Error" dialog...
         }
-        SAL_WARN("sal.file", "osl_openFile(" << cpFilePath << ") => " << aData.getLength() <<
-                 " bytes from file " << (bCache ? "cache" : "system"));
+        SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ") => '" << cpAssetsPath << "'"
+                 << aData.getLength() << " bytes from file " << (bCache ? "cache" : "system"));
         return openMemoryAsFile(aData, pHandle, cpFilePath);
     }
 #endif


More information about the Libreoffice-commits mailing list