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

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 15 11:16:41 UTC 2021


 sot/source/base/exchange.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 34d8cdfe7f80ed343cfb1f6f55cd10d5a9a38535
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Jan 14 02:57:35 2021 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Jan 15 12:16:06 2021 +0100

    Make SotExchange::GetFormat() accept a MIME type with additional parameters
    
    For instance, if SotExchange::GetFormat() is passed a flavor with MIME
    type
    "application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star
    Object Descriptor (XML)\";typename=\"LibreOffice 7.2 Spreadsheet\"" we
    do want to recognize it as SotClipboardFormatId::OBJECTDESCRIPTOR,
    even if the MIME type in the entry for it in the array in
    ImplFormatArray_Impl only has the windows_formatname parameter.
    
    This is part of fixing
    https://github.com/CollaboraOnline/online/issues/849, but it will help
    for corresponding problems with LibreOffice on macOS, too.
    
    Note that on Linux, SotExchange::GetFormat() gets called with a flavor
    with a MIME type that does *not* have all the extra parameters
    (classname, typename, displayname, viewaspect, width, height, posx,
    posy) (See the GitHub issue mentioned above.) This change does not
    remove any checks for classname, typename, etc. There are/were no such
    checks in SotExchange::GetFormat().
    
    But, in the (much different) code path for macOS (and iOS), with my
    work in process in vcl, SotExchange::GetFormat() gets called with a
    flavor with a MIME type that *does* contain those extra parameters. I
    don't see the point in introducing checks of the "sanity" of those
    into SotExchange::GetFormat().
    
    (In this branch, already contains the add-on fix to use the existing
    OUString::matchAsciiL() instead of requiring a new
    OUString::startsWithAsciiL().)
    
    Change-Id: Ie65ed1ab922cdaa6557eb65d980b9e886d3c6971
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109254
    Tested-by: Jenkins
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109352
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx
index da90eef263d7..eb6dc9f2c4a8 100644
--- a/sot/source/base/exchange.cxx
+++ b/sot/source/base/exchange.cxx
@@ -447,10 +447,16 @@ SotClipboardFormatId SotExchange::GetFormat( const DataFlavor& rFlavor )
     // only into 5.1 chart documents - in 5.0 and 5.2 it was 42 ("StarChart 5.0")
     // The registry only contains the entry for the 42 format id.
     for( SotClipboardFormatId i = SotClipboardFormatId::RTF; i <= SotClipboardFormatId::USER_END;  ++i )
-        if( rMimeType.equalsAscii( pFormatArray_Impl[ static_cast<int>(i) ].pMimeType ) )
+    {
+        const char* const pFormatMimeType = pFormatArray_Impl[ static_cast<int>(i) ].pMimeType;
+        const sal_Int32 nFormatMimeTypeLen = rtl_str_getLength( pFormatMimeType );
+        if( rMimeType.matchAsciiL( pFormatMimeType, nFormatMimeTypeLen ) &&
+            ( rMimeType.getLength() == nFormatMimeTypeLen ||
+              rMimeType[ nFormatMimeTypeLen ] == ';' ) )
             return ( (i == SotClipboardFormatId::STARCHARTDOCUMENT_50)
                      ? SotClipboardFormatId::STARCHART_50
                      : i );
+    }
 
     // then in the dynamic list
     tDataFlavorList& rL = InitFormats_Impl();


More information about the Libreoffice-commits mailing list