[Libreoffice-commits] core.git: Branch 'private/lmamane/for-julien2412-master' - 231 commits - accessibility/inc accessibility/source android/Bootstrap basctl/source basegfx/source basic/qa basic/source bin/distro-install-desktop-integration bin/gbuild-to-ide bin/gbuild-to-ideNS bin/generate-bash-completion bin/generate-bash-completion.py bridges/Library_cpp_uno.mk chart2/source codemaker/Module_codemaker.mk compilerplugins/clang configure.ac connectivity/source cui/source cui/uiconfig dbaccess/source desktop/source distro-configs/LibreOfficeFlatpak.conf drawinglayer/source dtrans/source editeng/qa editeng/source embeddedobj/source extensions/Library_abp.mk extensions/Library_dbp.mk extensions/qa extensions/source external/liborcus filter/source forms/source fpicker/source framework/inc framework/source helpcontent2 i18npool/inc i18npool/source include/connectivity include/desktop include/editeng include/i18nlangtag include/o3tl include/osl include/sax include/sfx2 include/svl include/svtools inc lude/svx include/test include/toolkit include/tools include/uno include/unotools include/vbahelper include/vcl include/xmloff io/source libreofficekit/qa lingucomponent/source lotuswordpro/source Makefile.in officecfg/registry onlineupdate/source oovbaapi/ooo oox/Library_oox.mk oox/qa oox/source opencl/source package/source postprocess/packimages qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests registry/test reportdesign/inc reportdesign/source rsc/inc rsc/source salhelper/Module_salhelper.mk sal/osl sal/textenc sax/source scaddins/source sc/CppunitTest_sc_cellobj.mk sc/CppunitTest_sc_ucalc.mk sc/inc sc/Library_sc.mk sc/Module_sc.mk sc/qa scripting/source sc/source sdext/source sd/inc sd/qa sd/source sfx2/qa sfx2/source sfx2/uiconfig shell/source slideshow/source solenv/CompilerTest_compilerplugins_clang.mk solenv/gbuild solenv/gdb sot/source starmath/qa starmath/source stoc/source store/source svgio/source svl/qa svl/source svtools/source svx/qa svx/source sw/inc sw/qa sw/s ource test/Library_subsequenttest.mk test/source testtools/source toolkit/source tools/qa tools/source ucb/source udkapi/com unotools/source unoxml/source uui/source vbahelper/source vcl/inc vcl/opengl vcl/osx vcl/qa vcl/source vcl/unx vcl/workben writerfilter/source xmlhelp/source xmloff/source xmlscript/source xmlsecurity/inc xmlsecurity/qa xmlsecurity/source xmlsecurity/test_docs

Lionel Elie Mamane lionel at mamane.lu
Sun Jul 2 09:56:19 UTC 2017


Rebased ref, commits from common ancestor:
commit d401b4a40d093210d5a3a7f1f3b0379f8cafc173
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Jul 2 11:28:09 2017 +0200

    factorisation du décodage
    
    Change-Id: I0130945b5c616beaa3eaedb34e5ca77b1bd70547

diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 97316e5e2536..fa34331d85f9 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -2026,6 +2026,89 @@ OSQLColumns::Vector::const_iterator find(OSQLColumns::Vector::const_iterator fir
         ++first;
     return first;
 }
+
+namespace dbase
+{
+    bool dbfDecodeCharset(rtl_TextEncoding &_out_encoding, sal_uInt8 nType, sal_uInt8 nCodepage)
+    {
+        switch (nType)
+        {
+        case dBaseIII:
+        case dBaseIV:
+        case dBaseV:
+        case VisualFoxPro:
+        case VisualFoxProAuto:
+        case dBaseFS:
+        case dBaseFSMemo:
+        case dBaseIVMemoSQL:
+        case dBaseIIIMemo:
+        case FoxProMemo:
+        {
+            if (nCodepage != 0x00)
+            {
+                auto eEncoding(RTL_TEXTENCODING_DONTKNOW);
+                switch(nCodepage)
+                {
+                case 0x01: eEncoding = RTL_TEXTENCODING_IBM_437; break;       // DOS USA  code page 437
+                case 0x02: eEncoding = RTL_TEXTENCODING_IBM_850; break;       // DOS Multilingual code page 850
+                case 0x03: eEncoding = RTL_TEXTENCODING_MS_1252; break;       // Windows ANSI code page 1252
+                case 0x04: eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;   // Standard Macintosh
+                case 0x64: eEncoding = RTL_TEXTENCODING_IBM_852; break;       // EE MS-DOS    code page 852
+                case 0x65: eEncoding = RTL_TEXTENCODING_IBM_866; break;       // Russian MS-DOS   code page 866
+                case 0x66: eEncoding = RTL_TEXTENCODING_IBM_865; break;       // Nordic MS-DOS    code page 865
+                case 0x67: eEncoding = RTL_TEXTENCODING_IBM_861; break;       // Icelandic MS-DOS
+                //case 0x68: eEncoding = ; break;     // Kamenicky (Czech) MS-DOS
+                //case 0x69: eEncoding = ; break;     // Mazovia (Polish) MS-DOS
+                case 0x6A: eEncoding = RTL_TEXTENCODING_IBM_737; break;       // Greek MS-DOS (437G)
+                case 0x6B: eEncoding = RTL_TEXTENCODING_IBM_857; break;       // Turkish MS-DOS
+                case 0x6C: eEncoding = RTL_TEXTENCODING_IBM_863; break;       // MS-DOS, Canada
+                case 0x78: eEncoding = RTL_TEXTENCODING_MS_950; break;        // Windows, Traditional Chinese
+                case 0x79: eEncoding = RTL_TEXTENCODING_MS_949; break;        // Windows, Korean (Hangul)
+                case 0x7A: eEncoding = RTL_TEXTENCODING_MS_936; break;        // Windows, Simplified Chinese
+                case 0x7B: eEncoding = RTL_TEXTENCODING_MS_932; break;        // Windows, Japanese (Shift-jis)
+                case 0x7C: eEncoding = RTL_TEXTENCODING_MS_874; break;        // Windows, Thai
+                case 0x7D: eEncoding = RTL_TEXTENCODING_MS_1255; break;       // Windows, Hebrew
+                case 0x7E: eEncoding = RTL_TEXTENCODING_MS_1256; break;       // Windows, Arabic
+                case 0x96: eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break;    // Russian Macintosh
+                case 0x97: eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break;    // Eastern European Macintosh
+                case 0x98: eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break;   // Greek Macintosh
+                case 0xC8: eEncoding = RTL_TEXTENCODING_MS_1250; break;       // Windows EE   code page 1250
+                case 0xC9: eEncoding = RTL_TEXTENCODING_MS_1251; break;       // Russian Windows
+                case 0xCA: eEncoding = RTL_TEXTENCODING_MS_1254; break;       // Turkish Windows
+                case 0xCB: eEncoding = RTL_TEXTENCODING_MS_1253; break;       // Greek Windows
+                case 0xCC: eEncoding = RTL_TEXTENCODING_MS_1257; break;       // Windows, Baltic
+                }
+                if(eEncoding != RTL_TEXTENCODING_DONTKNOW)
+                {
+                    _out_encoding = eEncoding;
+                    return true;
+                }
+            }
+        }
+        }
+        return false;
+    }
+
+    bool dbfReadCharset(rtl_TextEncoding &nCharSet, SvStream* dbf_Stream)
+    {
+        sal_uInt8 nType=0;
+        dbf_Stream->ReadUChar( nType );
+
+        dbf_Stream->Seek(STREAM_SEEK_TO_BEGIN + 29);
+        if (dbf_Stream->IsEof())
+        {
+            return false;
+        }
+        else
+        {
+            sal_uInt8 nEncoding=0;
+            dbf_Stream->ReadUChar( nEncoding );
+            return dbfDecodeCharset(nCharSet, nType, nEncoding);
+        }
+    }
+
+}
+
 } //namespace connectivity
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 51b400300566..3e14a594bbb7 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -249,9 +249,13 @@ void ODbaseTable::readHeader()
             case dBaseIVMemoSQL:
             case dBaseIIIMemo:
             case FoxProMemo:
-                // TODO: check that the code removed here is not needed when opening a DBF file
-                // from something else than Calc. E.g. Base. If it is, then factorise it into
-                // a function accessible from connectivity and from sc
+                m_pFileStream->SetEndian(SvStreamEndian::LITTLE);
+                if( getConnection()->isTextEncodingDefaulted() &&
+                   !dbfDecodeCharset(m_eEncoding, nType, m_aHeader.trailer[17]))
+                {
+                    m_eEncoding = RTL_TEXTENCODING_IBM_850;
+                }
+                break;
             case dBaseIVMemo:
                 m_pFileStream->SetEndian(SvStreamEndian::LITTLE);
                 break;
diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx
index 7f4719bd41c8..4b493ee98267 100644
--- a/include/connectivity/dbtools.hxx
+++ b/include/connectivity/dbtools.hxx
@@ -27,6 +27,7 @@
 #include <unotools/sharedunocomponent.hxx>
 #include <connectivity/dbtoolsdllapi.hxx>
 #include <connectivity/FValue.hxx>
+#include <tools/stream.hxx>
 
 namespace com { namespace sun { namespace star {
 
@@ -786,9 +787,51 @@ namespace dbtools
             OUStringBuffer& _out_rSQLPredicate
         );
 
-
 }   // namespace dbtools
 
+namespace connectivity::dbase
+{
+    enum DBFType  { dBaseIII         = 0x03,
+                    dBaseIV          = 0x04,
+                    dBaseV           = 0x05,
+                    VisualFoxPro     = 0x30,
+                    VisualFoxProAuto = 0x31, // Visual FoxPro with AutoIncrement field
+                    dBaseFS          = 0x43,
+                    dBaseFSMemo      = 0xB3,
+                    dBaseIIIMemo     = 0x83,
+                    dBaseIVMemo      = 0x8B,
+                    dBaseIVMemoSQL   = 0x8E,
+                    FoxProMemo       = 0xF5
+    };
+
+    /** decode a DBase file's codepage byte to a RTL charset
+        @param  _out_nCharset
+            in case of success, the decoded RTL charset is written there.
+            else, this is not written to.
+        @param  nType
+            the file's type byte
+        @param  nCodepage
+            the file's codepage byte
+        @return
+            true if a RTL charset was successfully decoded and written to _out_nCharset
+            false if nothing was written to _out_nCharset
+    */
+    OOO_DLLPUBLIC_DBTOOLS bool dbfDecodeCharset(rtl_TextEncoding &_out_nCharset, sal_uInt8 nType, sal_uInt8 nCodepage);
+
+    /** decode a DBase file's codepage byte to a RTL charset
+        @param  _out_nCharset
+            in case of success, the decoded RTL charset is written there.
+            else, this is not written to.
+        @param  dbf_Stream
+            pointer to a SvStream encapsulating the DBase file.
+            The stream will be rewinded and read from.
+            No guarantee is made on its position afterwards. Caller must reposition it itself.
+        @return
+            true if a RTL charset was successfully decoded and written to _out_nCharset
+            false if nothing was written to _out_nCharset
+    */
+    OOO_DLLPUBLIC_DBTOOLS bool dbfReadCharset(rtl_TextEncoding &nCharSet, SvStream* dbf_Stream);
+} // namespace connectivity::dbase
 
 #endif // INCLUDED_CONNECTIVITY_DBTOOLS_HXX
 
diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk
index d918182a0c4f..d423f6c73a7b 100644
--- a/sc/CppunitTest_sc_ucalc.mk
+++ b/sc/CppunitTest_sc_ucalc.mk
@@ -45,6 +45,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ucalc, \
     comphelper \
     cppu \
     cppuhelper \
+    dbtools \
     drawinglayer \
     editeng \
     for \
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 5b7d2fcf9275..c9f54638e62e 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -58,6 +58,7 @@ $(eval $(call gb_Library_use_libraries,sc,\
     comphelper \
     cppu \
     cppuhelper \
+    dbtools \
     drawinglayer \
     editeng \
     for \
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index de16f6b28f55..b2da4408e874 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -22,6 +22,7 @@
 #include <vcl/msgbox.hxx>
 #include <vcl/svapp.hxx>
 #include <unotools/ucbstreamhelper.hxx>
+#include <connectivity/dbtools.hxx>
 
 #include "editutil.hxx"
 #include "filtuno.hxx"
@@ -44,6 +45,7 @@
 
 using namespace com::sun::star;
 using namespace com::sun::star::uno;
+using namespace connectivity::dbase;
 
 #define SCFILTEROPTIONSOBJ_SERVICE      "com.sun.star.ui.dialogs.FilterOptionsDialog"
 #define SCFILTEROPTIONSOBJ_IMPLNAME     "com.sun.star.comp.Calc.FilterOptionsDialog"
@@ -84,97 +86,34 @@ namespace
 
     charsetSource load_CharSet(rtl_TextEncoding &nCharSet, bool bExport, SvStream* dbf_Stream)
     {
+        if (dbfReadCharset(nCharSet, dbf_Stream))
         {
-            sal_uInt8 nType=0;
-            dbf_Stream->ReadUChar( nType );
-
-            switch (nType)
-            {
-            case dBaseIII:
-            case dBaseIV:
-            case dBaseV:
-            case VisualFoxPro:
-            case VisualFoxProAuto:
-            case dBaseFS:
-            case dBaseFSMemo:
-            case dBaseIVMemoSQL:
-            case dBaseIIIMemo:
-            case FoxProMemo:
-                dbf_Stream->SetEndian(SvStreamEndian::LITTLE);
-
-                dbf_Stream->Seek(STREAM_SEEK_TO_BEGIN + 29);
-                if (! dbf_Stream->IsEof())
-                {
-                    sal_uInt8 nEncoding=0;
-                    dbf_Stream->ReadUChar( nEncoding );
-                    if (nEncoding != 0x00)
-                    {
-                        auto eEncoding(RTL_TEXTENCODING_DONTKNOW);
-                        switch(nEncoding)
-                        {
-                        case 0x01: eEncoding = RTL_TEXTENCODING_IBM_437; break;       // DOS USA  code page 437
-                        case 0x02: eEncoding = RTL_TEXTENCODING_IBM_850; break;       // DOS Multilingual code page 850
-                        case 0x03: eEncoding = RTL_TEXTENCODING_MS_1252; break;       // Windows ANSI code page 1252
-                        case 0x04: eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;   // Standard Macintosh
-                        case 0x64: eEncoding = RTL_TEXTENCODING_IBM_852; break;       // EE MS-DOS    code page 852
-                        case 0x65: eEncoding = RTL_TEXTENCODING_IBM_866; break;       // Russian MS-DOS   code page 866
-                        case 0x66: eEncoding = RTL_TEXTENCODING_IBM_865; break;       // Nordic MS-DOS    code page 865
-                        case 0x67: eEncoding = RTL_TEXTENCODING_IBM_861; break;       // Icelandic MS-DOS
-                        //case 0x68: eEncoding = ; break;     // Kamenicky (Czech) MS-DOS
-                        //case 0x69: eEncoding = ; break;     // Mazovia (Polish) MS-DOS
-                        case 0x6A: eEncoding = RTL_TEXTENCODING_IBM_737; break;       // Greek MS-DOS (437G)
-                        case 0x6B: eEncoding = RTL_TEXTENCODING_IBM_857; break;       // Turkish MS-DOS
-                        case 0x6C: eEncoding = RTL_TEXTENCODING_IBM_863; break;       // MS-DOS, Canada
-                        case 0x78: eEncoding = RTL_TEXTENCODING_MS_950; break;        // Windows, Traditional Chinese
-                        case 0x79: eEncoding = RTL_TEXTENCODING_MS_949; break;        // Windows, Korean (Hangul)
-                        case 0x7A: eEncoding = RTL_TEXTENCODING_MS_936; break;        // Windows, Simplified Chinese
-                        case 0x7B: eEncoding = RTL_TEXTENCODING_MS_932; break;        // Windows, Japanese (Shift-jis)
-                        case 0x7C: eEncoding = RTL_TEXTENCODING_MS_874; break;        // Windows, Thai
-                        case 0x7D: eEncoding = RTL_TEXTENCODING_MS_1255; break;       // Windows, Hebrew
-                        case 0x7E: eEncoding = RTL_TEXTENCODING_MS_1256; break;       // Windows, Arabic
-                        case 0x96: eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break;    // Russian Macintosh
-                        case 0x97: eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break;    // Eastern European Macintosh
-                        case 0x98: eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break;   // Greek Macintosh
-                        case 0xC8: eEncoding = RTL_TEXTENCODING_MS_1250; break;       // Windows EE   code page 1250
-                        case 0xC9: eEncoding = RTL_TEXTENCODING_MS_1251; break;       // Russian Windows
-                        case 0xCA: eEncoding = RTL_TEXTENCODING_MS_1254; break;       // Turkish Windows
-                        case 0xCB: eEncoding = RTL_TEXTENCODING_MS_1253; break;       // Greek Windows
-                        case 0xCC: eEncoding = RTL_TEXTENCODING_MS_1257; break;       // Windows, Baltic
-                        }
-                        if(eEncoding != RTL_TEXTENCODING_DONTKNOW)
-                        {
-                            nCharSet = eEncoding;
-                            return charsetSource::charset_from_file;
-                        }
-                    }
-                }
-            }
+            return charsetSource::charset_from_file;
         }
-        {
-            Sequence<Any> aValues;
-            const Any *pProperties;
-            Sequence<OUString> aNames { DBF_CHAR_SET };
-            ScLinkConfigItem aItem( OUString::createFromAscii(
-                                        bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
 
-            aValues = aItem.GetProperties( aNames );
-            pProperties = aValues.getConstArray();
+        Sequence<Any> aValues;
+        const Any *pProperties;
+        Sequence<OUString> aNames { DBF_CHAR_SET };
+        ScLinkConfigItem aItem( OUString::createFromAscii(
+                                    bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
+
+        aValues = aItem.GetProperties( aNames );
+        pProperties = aValues.getConstArray();
 
-            if( pProperties[0].hasValue() )
+        if( pProperties[0].hasValue() )
+        {
+            sal_Int32 nChar = 0;
+            pProperties[0] >>= nChar;
+            if( nChar >= 0)
             {
-                sal_Int32 nChar = 0;
-                pProperties[0] >>= nChar;
-                if( nChar >= 0)
-                {
-                    nCharSet = (rtl_TextEncoding) nChar;
-                    return charsetSource::charset_from_user_setting;
-                }
+                nCharSet = (rtl_TextEncoding) nChar;
+                return charsetSource::charset_from_user_setting;
             }
-
-            // Default choice
-            nCharSet = RTL_TEXTENCODING_IBM_850;
-            return charsetSource::charset_default;
         }
+
+        // Default choice
+        nCharSet = RTL_TEXTENCODING_IBM_850;
+        return charsetSource::charset_default;
     }
 
     void save_CharSet( rtl_TextEncoding nCharSet, bool bExport )
commit 032872ffc7902e330df2863399c84550dbb31ae6
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 28 03:55:33 2017 +0200

    check for end of file, correct comment
    
    Change-Id: I8262651019364b5a2a927667cfd31555d03e6eab

diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index 45570676c9e2..de16f6b28f55 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -103,9 +103,8 @@ namespace
                 dbf_Stream->SetEndian(SvStreamEndian::LITTLE);
 
                 dbf_Stream->Seek(STREAM_SEEK_TO_BEGIN + 29);
-               // TODO : how to check this?
-               // if (seek_succeeded_ie_not_end_of_file)
-                //{
+                if (! dbf_Stream->IsEof())
+                {
                     sal_uInt8 nEncoding=0;
                     dbf_Stream->ReadUChar( nEncoding );
                     if (nEncoding != 0x00)
@@ -148,9 +147,8 @@ namespace
                             return charsetSource::charset_from_file;
                         }
                     }
-                //}
+                }
             }
-            // dbf_Stream goes out of scope, is automatically closed
         }
         {
             Sequence<Any> aValues;
@@ -360,6 +358,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
                    break;
             }
             bDBEnc = true;
+            // pInStream goes out of scope, the stream is automatically closed
         }
         else if ( aFilterString == ScDocShell::GetDifFilterName() )
         {
commit 9f6358e8f359eb50b45b056573ce315473ab692d
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 28 03:55:00 2017 +0200

    we need gpgme header, too
    
    not only gpgmepp headers
    
    Change-Id: I46723ce751d631e165982c6c7bc2f820f9a5d0a8

diff --git a/configure.ac b/configure.ac
index 36f6ccebf452..0eb7ed7150a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10281,6 +10281,8 @@ if test "$_os" = "Linux"; then
         # checking for it also filters out older, KDE-dependent libgpgmepp versions
         AC_CHECK_LIB(gpgmepp, progress_callback, [ GPGMEPP_LIBS=-lgpgmepp ],
             [AC_MSG_ERROR(gpgmepp not found or not functional)], [])
+        AC_CHECK_HEADER(gpgme.h, [],
+            [AC_MSG_ERROR([gpgme headers not found, install gpgme development package])], [])
     else
         AC_MSG_RESULT([internal])
         BUILD_TYPE="$BUILD_TYPE LIBGPGERROR LIBASSUAN GPGMEPP"
commit 8a146a7e29a17f0ab82fee7e45b32d81f1f92619
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jun 28 03:03:02 2017 +0200

    julien it compiles patch
    
    Change-Id: I89fa48dda0d907fa0bdcc49be373ed1b1cfd8c73

diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index 09a6a78a9867..45570676c9e2 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -68,13 +68,25 @@ namespace
         charset_from_user_setting,
         charset_default
     };
-
-    charsetSource load_CharSet( rtl_TextEncoding &nCharSet, bool bExport, string_or_url fname )
+    // TODO: use DTable.hxx instead
+            enum DBFType  { dBaseIII         = 0x03,
+                            dBaseIV          = 0x04,
+                            dBaseV           = 0x05,
+                            VisualFoxPro     = 0x30,
+                            VisualFoxProAuto = 0x31, // Visual FoxPro with AutoIncrement field
+                            dBaseFS          = 0x43,
+                            dBaseFSMemo      = 0xB3,
+                            dBaseIIIMemo     = 0x83,
+                            dBaseIVMemo      = 0x8B,
+                            dBaseIVMemoSQL   = 0x8E,
+                            FoxProMemo       = 0xF5
+                          };
+
+    charsetSource load_CharSet(rtl_TextEncoding &nCharSet, bool bExport, SvStream* dbf_Stream)
     {
         {
-            lo_stream dbfStream(fname, ...);
             sal_uInt8 nType=0;
-            dbfStream.ReadUChar( nType );
+            dbf_Stream->ReadUChar( nType );
 
             switch (nType)
             {
@@ -88,56 +100,57 @@ namespace
             case dBaseIVMemoSQL:
             case dBaseIIIMemo:
             case FoxProMemo:
-                dbfStream.SetEndian(SvStreamEndian::LITTLE);
+                dbf_Stream->SetEndian(SvStreamEndian::LITTLE);
 
-                dbf_stream.Seek(STREAM_SEEK_TO_BEGIN + 29);
-                if (seek_succeeded_ie_not_end_of_file)
-                {
+                dbf_Stream->Seek(STREAM_SEEK_TO_BEGIN + 29);
+               // TODO : how to check this?
+               // if (seek_succeeded_ie_not_end_of_file)
+                //{
                     sal_uInt8 nEncoding=0;
-                    dbfStream.ReadUChar( nEncoding );
+                    dbf_Stream->ReadUChar( nEncoding );
                     if (nEncoding != 0x00)
                     {
                         auto eEncoding(RTL_TEXTENCODING_DONTKNOW);
-                        switch(m_aHeader.db_frei[17])
+                        switch(nEncoding)
                         {
-                        case 0x01: m_eEncoding = RTL_TEXTENCODING_IBM_437; break;       // DOS USA  code page 437
-                        case 0x02: m_eEncoding = RTL_TEXTENCODING_IBM_850; break;       // DOS Multilingual code page 850
-                        case 0x03: m_eEncoding = RTL_TEXTENCODING_MS_1252; break;       // Windows ANSI code page 1252
-                        case 0x04: m_eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;   // Standard Macintosh
-                        case 0x64: m_eEncoding = RTL_TEXTENCODING_IBM_852; break;       // EE MS-DOS    code page 852
-                        case 0x65: m_eEncoding = RTL_TEXTENCODING_IBM_866; break;       // Russian MS-DOS   code page 866
-                        case 0x66: m_eEncoding = RTL_TEXTENCODING_IBM_865; break;       // Nordic MS-DOS    code page 865
-                        case 0x67: m_eEncoding = RTL_TEXTENCODING_IBM_861; break;       // Icelandic MS-DOS
-                        //case 0x68: m_eEncoding = ; break;     // Kamenicky (Czech) MS-DOS
-                        //case 0x69: m_eEncoding = ; break;     // Mazovia (Polish) MS-DOS
-                        case 0x6A: m_eEncoding = RTL_TEXTENCODING_IBM_737; break;       // Greek MS-DOS (437G)
-                        case 0x6B: m_eEncoding = RTL_TEXTENCODING_IBM_857; break;       // Turkish MS-DOS
-                        case 0x6C: m_eEncoding = RTL_TEXTENCODING_IBM_863; break;       // MS-DOS, Canada
-                        case 0x78: m_eEncoding = RTL_TEXTENCODING_MS_950; break;        // Windows, Traditional Chinese
-                        case 0x79: m_eEncoding = RTL_TEXTENCODING_MS_949; break;        // Windows, Korean (Hangul)
-                        case 0x7A: m_eEncoding = RTL_TEXTENCODING_MS_936; break;        // Windows, Simplified Chinese
-                        case 0x7B: m_eEncoding = RTL_TEXTENCODING_MS_932; break;        // Windows, Japanese (Shift-jis)
-                        case 0x7C: m_eEncoding = RTL_TEXTENCODING_MS_874; break;        // Windows, Thai
-                        case 0x7D: m_eEncoding = RTL_TEXTENCODING_MS_1255; break;       // Windows, Hebrew
-                        case 0x7E: m_eEncoding = RTL_TEXTENCODING_MS_1256; break;       // Windows, Arabic
-                        case 0x96: m_eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break;    // Russian Macintosh
-                        case 0x97: m_eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break;    // Eastern European Macintosh
-                        case 0x98: m_eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break;   // Greek Macintosh
-                        case 0xC8: m_eEncoding = RTL_TEXTENCODING_MS_1250; break;       // Windows EE   code page 1250
-                        case 0xC9: m_eEncoding = RTL_TEXTENCODING_MS_1251; break;       // Russian Windows
-                        case 0xCA: m_eEncoding = RTL_TEXTENCODING_MS_1254; break;       // Turkish Windows
-                        case 0xCB: m_eEncoding = RTL_TEXTENCODING_MS_1253; break;       // Greek Windows
-                        case 0xCC: m_eEncoding = RTL_TEXTENCODING_MS_1257; break;       // Windows, Baltic
+                        case 0x01: eEncoding = RTL_TEXTENCODING_IBM_437; break;       // DOS USA  code page 437
+                        case 0x02: eEncoding = RTL_TEXTENCODING_IBM_850; break;       // DOS Multilingual code page 850
+                        case 0x03: eEncoding = RTL_TEXTENCODING_MS_1252; break;       // Windows ANSI code page 1252
+                        case 0x04: eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;   // Standard Macintosh
+                        case 0x64: eEncoding = RTL_TEXTENCODING_IBM_852; break;       // EE MS-DOS    code page 852
+                        case 0x65: eEncoding = RTL_TEXTENCODING_IBM_866; break;       // Russian MS-DOS   code page 866
+                        case 0x66: eEncoding = RTL_TEXTENCODING_IBM_865; break;       // Nordic MS-DOS    code page 865
+                        case 0x67: eEncoding = RTL_TEXTENCODING_IBM_861; break;       // Icelandic MS-DOS
+                        //case 0x68: eEncoding = ; break;     // Kamenicky (Czech) MS-DOS
+                        //case 0x69: eEncoding = ; break;     // Mazovia (Polish) MS-DOS
+                        case 0x6A: eEncoding = RTL_TEXTENCODING_IBM_737; break;       // Greek MS-DOS (437G)
+                        case 0x6B: eEncoding = RTL_TEXTENCODING_IBM_857; break;       // Turkish MS-DOS
+                        case 0x6C: eEncoding = RTL_TEXTENCODING_IBM_863; break;       // MS-DOS, Canada
+                        case 0x78: eEncoding = RTL_TEXTENCODING_MS_950; break;        // Windows, Traditional Chinese
+                        case 0x79: eEncoding = RTL_TEXTENCODING_MS_949; break;        // Windows, Korean (Hangul)
+                        case 0x7A: eEncoding = RTL_TEXTENCODING_MS_936; break;        // Windows, Simplified Chinese
+                        case 0x7B: eEncoding = RTL_TEXTENCODING_MS_932; break;        // Windows, Japanese (Shift-jis)
+                        case 0x7C: eEncoding = RTL_TEXTENCODING_MS_874; break;        // Windows, Thai
+                        case 0x7D: eEncoding = RTL_TEXTENCODING_MS_1255; break;       // Windows, Hebrew
+                        case 0x7E: eEncoding = RTL_TEXTENCODING_MS_1256; break;       // Windows, Arabic
+                        case 0x96: eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break;    // Russian Macintosh
+                        case 0x97: eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break;    // Eastern European Macintosh
+                        case 0x98: eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break;   // Greek Macintosh
+                        case 0xC8: eEncoding = RTL_TEXTENCODING_MS_1250; break;       // Windows EE   code page 1250
+                        case 0xC9: eEncoding = RTL_TEXTENCODING_MS_1251; break;       // Russian Windows
+                        case 0xCA: eEncoding = RTL_TEXTENCODING_MS_1254; break;       // Turkish Windows
+                        case 0xCB: eEncoding = RTL_TEXTENCODING_MS_1253; break;       // Greek Windows
+                        case 0xCC: eEncoding = RTL_TEXTENCODING_MS_1257; break;       // Windows, Baltic
                         }
                         if(eEncoding != RTL_TEXTENCODING_DONTKNOW)
                         {
                             nCharSet = eEncoding;
-                            return charset_from_file;
+                            return charsetSource::charset_from_file;
                         }
                     }
-                }
+                //}
             }
-            // dbfStream goes out of scope, is automatically closed
+            // dbf_Stream goes out of scope, is automatically closed
         }
         {
             Sequence<Any> aValues;
@@ -156,13 +169,13 @@ namespace
                 if( nChar >= 0)
                 {
                     nCharSet = (rtl_TextEncoding) nChar;
-                    return charset_from_user_setting;
+                    return charsetSource::charset_from_user_setting;
                 }
             }
 
             // Default choice
             nCharSet = RTL_TEXTENCODING_IBM_850;
-            return charset_default;
+            return charsetSource::charset_default;
         }
     }
 
@@ -334,10 +347,17 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
                 //  dBase import
                 aTitle = ScGlobal::GetRscString( STR_IMPORT_DBF );
             }
-            switch(load_CharSet( eEncoding, bExport, aFileName ))
+
+            std::unique_ptr<SvStream> pInStream;
+            if ( xInputStream.is() )
+                pInStream.reset(utl::UcbStreamHelper::CreateStream( xInputStream ));
+            switch(load_CharSet( eEncoding, bExport, pInStream.get()))
             {
-            case charset_from_file:
-                skipDialog = true;
+                case charsetSource::charset_from_file:
+                  skipDialog = true;break;
+                case charsetSource::charset_from_user_setting:
+                case charsetSource::charset_default:
+                   break;
             }
             bDBEnc = true;
         }
commit 12a57a527a9ddcc56a9af79bf063ebde6b0b1d2c
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Jun 25 18:02:01 2017 +0200

    ne plus faire la détection automatioque une 2e fois
    
    et lui faire confiance, i.e. ne plus écraser IBM_850
    TODO: vérifier le cas base, où ce ne serait pas une 2e fois et il faudrait encore la faire
    
    Conflicts:
            connectivity/source/drivers/dbase/DTable.cxx
    
    Change-Id: I401a93dce8ddf100031f1f04872df47ef453eb63

diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 6da1f893e6fc..51b400300566 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -249,52 +249,9 @@ void ODbaseTable::readHeader()
             case dBaseIVMemoSQL:
             case dBaseIIIMemo:
             case FoxProMemo:
-                m_pFileStream->SetEndian(SvStreamEndian::LITTLE);
-                // trailer[17] corresponds to language code, see DBFHeader def in connectivity/source/inc/dbase/DTable.hxx
-                if ( m_aHeader.trailer[17] != 0x00 && getConnection()->isTextEncodingDefaulted() )
-                {
-                    switch(m_aHeader.trailer[17])
-                    {
-                        case 0x01: m_eEncoding = RTL_TEXTENCODING_IBM_437; break;       // DOS USA  code page 437
-                        case 0x02: m_eEncoding = RTL_TEXTENCODING_IBM_850; break;       // DOS Multilingual code page 850
-                        case 0x03: m_eEncoding = RTL_TEXTENCODING_MS_1252; break;       // Windows ANSI code page 1252
-                        case 0x04: m_eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;   // Standard Macintosh
-                        case 0x64: m_eEncoding = RTL_TEXTENCODING_IBM_852; break;       // EE MS-DOS    code page 852
-                        case 0x65: m_eEncoding = RTL_TEXTENCODING_IBM_866; break;       // Russian MS-DOS   code page 866
-                        case 0x66: m_eEncoding = RTL_TEXTENCODING_IBM_865; break;       // Nordic MS-DOS    code page 865
-                        case 0x67: m_eEncoding = RTL_TEXTENCODING_IBM_861; break;       // Icelandic MS-DOS
-                        //case 0x68: m_eEncoding = ; break;     // Kamenicky (Czech) MS-DOS
-                        //case 0x69: m_eEncoding = ; break;     // Mazovia (Polish) MS-DOS
-                        case 0x6A: m_eEncoding = RTL_TEXTENCODING_IBM_737; break;       // Greek MS-DOS (437G)
-                        case 0x6B: m_eEncoding = RTL_TEXTENCODING_IBM_857; break;       // Turkish MS-DOS
-                        case 0x6C: m_eEncoding = RTL_TEXTENCODING_IBM_863; break;       // MS-DOS, Canada
-                        case 0x78: m_eEncoding = RTL_TEXTENCODING_MS_950; break;        // Windows, Traditional Chinese
-                        case 0x79: m_eEncoding = RTL_TEXTENCODING_MS_949; break;        // Windows, Korean (Hangul)
-                        case 0x7A: m_eEncoding = RTL_TEXTENCODING_MS_936; break;        // Windows, Simplified Chinese
-                        case 0x7B: m_eEncoding = RTL_TEXTENCODING_MS_932; break;        // Windows, Japanese (Shift-jis)
-                        case 0x7C: m_eEncoding = RTL_TEXTENCODING_MS_874; break;        // Windows, Thai
-                        case 0x7D: m_eEncoding = RTL_TEXTENCODING_MS_1255; break;       // Windows, Hebrew
-                        case 0x7E: m_eEncoding = RTL_TEXTENCODING_MS_1256; break;       // Windows, Arabic
-                        case 0x96: m_eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break;    // Russian Macintosh
-                        case 0x97: m_eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break;    // Eastern European Macintosh
-                        case 0x98: m_eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break;   // Greek Macintosh
-                        case 0xC8: m_eEncoding = RTL_TEXTENCODING_MS_1250; break;       // Windows EE   code page 1250
-                        case 0xC9: m_eEncoding = RTL_TEXTENCODING_MS_1251; break;       // Russian Windows
-                        case 0xCA: m_eEncoding = RTL_TEXTENCODING_MS_1254; break;       // Turkish Windows
-                        case 0xCB: m_eEncoding = RTL_TEXTENCODING_MS_1253; break;       // Greek Windows
-                        case 0xCC: m_eEncoding = RTL_TEXTENCODING_MS_1257; break;       // Windows, Baltic
-                        default:
-                            // Default Encoding
-                            m_eEncoding = RTL_TEXTENCODING_IBM_850;
-                            break;
-                    }
-                }
-                else
-                {
-                    // Default Encoding
-                    m_eEncoding = RTL_TEXTENCODING_IBM_850;
-                }
-                break;
+                // TODO: check that the code removed here is not needed when opening a DBF file
+                // from something else than Calc. E.g. Base. If it is, then factorise it into
+                // a function accessible from connectivity and from sc
             case dBaseIVMemo:
                 m_pFileStream->SetEndian(SvStreamEndian::LITTLE);
                 break;
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index b21e6426e99b..5a676d24d029 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -301,10 +301,6 @@ ErrCode ScDocShell::DBaseImport( const OUString& rFullFileName, rtl_TextEncoding
 
     ErrCode nErr = ERRCODE_NONE;
 
-    // Try to get the Text Encoding from the driver
-    if( eCharSet == RTL_TEXTENCODING_IBM_850 )
-        eCharSet = RTL_TEXTENCODING_DONTKNOW;
-
     try
     {
         long i;
commit 1ca5ed457e0851e574e6c070577f39de4ecfd425
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Jun 25 17:49:28 2017 +0200

    utiliser la détection automatique
    
    Change-Id: I355396794a883e131698d56046b9226095dd8414

diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index c7b88e5fd345..09a6a78a9867 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -292,6 +292,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
     {
         bool bDBEnc     = false;
         bool bAscii     = false;
+        bool skipDialog = false;
 
         sal_Unicode const cStrDel = '"';
         sal_Unicode cAsciiDel = ';';
@@ -333,7 +334,11 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
                 //  dBase import
                 aTitle = ScGlobal::GetRscString( STR_IMPORT_DBF );
             }
-            load_CharSet( eEncoding, bExport );
+            switch(load_CharSet( eEncoding, bExport, aFileName ))
+            {
+            case charset_from_file:
+                skipDialog = true;
+            }
             bDBEnc = true;
         }
         else if ( aFilterString == ScDocShell::GetDifFilterName() )
@@ -353,21 +358,37 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
         }
 
         ScImportOptions aOptions( cAsciiDel, cStrDel, eEncoding);
-
-        ScopedVclPtr<AbstractScImportOptionsDlg> pDlg(pFact->CreateScImportOptionsDlg(
-                                                                            bAscii, &aOptions, &aTitle, true/*bMultiByte*/, bDBEnc,
-                                                                            !bExport));
-        OSL_ENSURE(pDlg, "Dialog create fail!");
-        if ( pDlg->Execute() == RET_OK )
+        if(skipDialog)
+        {
+            // TODO: check we are not missing some of the stuff that ScImportOptionsDlg::GetImportOptions
+            // (file sc/source/ui/dbgui/scuiimoptdlg.cxx) does
+            // that is, if the dialog sets options that are not selected by the user (!)
+            // then we are missing them here.
+            // Then we may need to rip them out of the dialog.
+            // Or we actually change the dialog to not display if skipDialog==true
+            // in that case, add an argument skipDialog to CreateScImportOptionsDlg
+            nRet = ui::dialogs::ExecutableDialogResults::OK;
+        }
+        else
+        {
+            ScopedVclPtr<AbstractScImportOptionsDlg> pDlg(pFact->CreateScImportOptionsDlg(
+                                                                            bAscii, &aOptions, &aTitle, bMultiByte/*bMultiByte*/,
+                                                                            bDBEnc, !bExport));
+            OSL_ENSURE(pDlg, "Dialog create fail!");
+            if ( pDlg->Execute() == RET_OK )
+            {
+                pDlg->SaveImportOptions();
+                pDlg->GetImportOptions( aOptions );
+                save_CharSet( aOptions.eCharSet, bExport );
+                nRet = ui::dialogs::ExecutableDialogResults::OK;
+            }
+        }
+        if (nRet == ui::dialogs::ExecutableDialogResults::OK)
         {
-            pDlg->SaveImportOptions();
-            pDlg->GetImportOptions( aOptions );
-            save_CharSet( aOptions.eCharSet, bExport );
             if ( bAscii )
                 aFilterOptions = aOptions.BuildString();
             else
                 aFilterOptions = aOptions.aStrFont;
-            nRet = ui::dialogs::ExecutableDialogResults::OK;
         }
     }
 
commit 58ad75baeafd9ca1835a6405dd03c0b65b08871e
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Jun 25 17:21:45 2017 +0200

    détection automatique
    
    Change-Id: Ic6b940b4bd5f3c181b022acffb211b719b99710f

diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index c0cc98782879..c7b88e5fd345 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -59,44 +59,127 @@ SC_SIMPLE_SERVICE_INFO( ScFilterOptionsObj, SCFILTEROPTIONSOBJ_IMPLNAME, SCFILTE
 #define DBF_SEP_PATH_IMPORT         "Office.Calc/Dialogs/DBFImport"
 #define DBF_SEP_PATH_EXPORT         "Office.Calc/Dialogs/DBFExport"
 
-static void load_CharSet( rtl_TextEncoding &nCharSet, bool bExport )
+namespace
 {
-    Sequence<Any> aValues;
-    const Any *pProperties;
-    Sequence<OUString> aNames { DBF_CHAR_SET };
-    ScLinkConfigItem aItem( OUString::createFromAscii(
-                                bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
 
-    aValues = aItem.GetProperties( aNames );
-    pProperties = aValues.getConstArray();
-
-    // Default choice
-    nCharSet = RTL_TEXTENCODING_IBM_850;
+    enum class charsetSource
+    {
+        charset_from_file,
+        charset_from_user_setting,
+        charset_default
+    };
 
-    if( pProperties[0].hasValue() )
+    charsetSource load_CharSet( rtl_TextEncoding &nCharSet, bool bExport, string_or_url fname )
     {
-        sal_Int32 nChar = 0;
-        pProperties[0] >>= nChar;
-        if( nChar >= 0)
         {
-            nCharSet = (rtl_TextEncoding) nChar;
+            lo_stream dbfStream(fname, ...);
+            sal_uInt8 nType=0;
+            dbfStream.ReadUChar( nType );
+
+            switch (nType)
+            {
+            case dBaseIII:
+            case dBaseIV:
+            case dBaseV:
+            case VisualFoxPro:
+            case VisualFoxProAuto:
+            case dBaseFS:
+            case dBaseFSMemo:
+            case dBaseIVMemoSQL:
+            case dBaseIIIMemo:
+            case FoxProMemo:
+                dbfStream.SetEndian(SvStreamEndian::LITTLE);
+
+                dbf_stream.Seek(STREAM_SEEK_TO_BEGIN + 29);
+                if (seek_succeeded_ie_not_end_of_file)
+                {
+                    sal_uInt8 nEncoding=0;
+                    dbfStream.ReadUChar( nEncoding );
+                    if (nEncoding != 0x00)
+                    {
+                        auto eEncoding(RTL_TEXTENCODING_DONTKNOW);
+                        switch(m_aHeader.db_frei[17])
+                        {
+                        case 0x01: m_eEncoding = RTL_TEXTENCODING_IBM_437; break;       // DOS USA  code page 437
+                        case 0x02: m_eEncoding = RTL_TEXTENCODING_IBM_850; break;       // DOS Multilingual code page 850
+                        case 0x03: m_eEncoding = RTL_TEXTENCODING_MS_1252; break;       // Windows ANSI code page 1252
+                        case 0x04: m_eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break;   // Standard Macintosh
+                        case 0x64: m_eEncoding = RTL_TEXTENCODING_IBM_852; break;       // EE MS-DOS    code page 852
+                        case 0x65: m_eEncoding = RTL_TEXTENCODING_IBM_866; break;       // Russian MS-DOS   code page 866
+                        case 0x66: m_eEncoding = RTL_TEXTENCODING_IBM_865; break;       // Nordic MS-DOS    code page 865
+                        case 0x67: m_eEncoding = RTL_TEXTENCODING_IBM_861; break;       // Icelandic MS-DOS
+                        //case 0x68: m_eEncoding = ; break;     // Kamenicky (Czech) MS-DOS
+                        //case 0x69: m_eEncoding = ; break;     // Mazovia (Polish) MS-DOS
+                        case 0x6A: m_eEncoding = RTL_TEXTENCODING_IBM_737; break;       // Greek MS-DOS (437G)
+                        case 0x6B: m_eEncoding = RTL_TEXTENCODING_IBM_857; break;       // Turkish MS-DOS
+                        case 0x6C: m_eEncoding = RTL_TEXTENCODING_IBM_863; break;       // MS-DOS, Canada
+                        case 0x78: m_eEncoding = RTL_TEXTENCODING_MS_950; break;        // Windows, Traditional Chinese
+                        case 0x79: m_eEncoding = RTL_TEXTENCODING_MS_949; break;        // Windows, Korean (Hangul)
+                        case 0x7A: m_eEncoding = RTL_TEXTENCODING_MS_936; break;        // Windows, Simplified Chinese
+                        case 0x7B: m_eEncoding = RTL_TEXTENCODING_MS_932; break;        // Windows, Japanese (Shift-jis)
+                        case 0x7C: m_eEncoding = RTL_TEXTENCODING_MS_874; break;        // Windows, Thai
+                        case 0x7D: m_eEncoding = RTL_TEXTENCODING_MS_1255; break;       // Windows, Hebrew
+                        case 0x7E: m_eEncoding = RTL_TEXTENCODING_MS_1256; break;       // Windows, Arabic
+                        case 0x96: m_eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break;    // Russian Macintosh
+                        case 0x97: m_eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break;    // Eastern European Macintosh
+                        case 0x98: m_eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break;   // Greek Macintosh
+                        case 0xC8: m_eEncoding = RTL_TEXTENCODING_MS_1250; break;       // Windows EE   code page 1250
+                        case 0xC9: m_eEncoding = RTL_TEXTENCODING_MS_1251; break;       // Russian Windows
+                        case 0xCA: m_eEncoding = RTL_TEXTENCODING_MS_1254; break;       // Turkish Windows
+                        case 0xCB: m_eEncoding = RTL_TEXTENCODING_MS_1253; break;       // Greek Windows
+                        case 0xCC: m_eEncoding = RTL_TEXTENCODING_MS_1257; break;       // Windows, Baltic
+                        }
+                        if(eEncoding != RTL_TEXTENCODING_DONTKNOW)
+                        {
+                            nCharSet = eEncoding;
+                            return charset_from_file;
+                        }
+                    }
+                }
+            }
+            // dbfStream goes out of scope, is automatically closed
+        }
+        {
+            Sequence<Any> aValues;
+            const Any *pProperties;
+            Sequence<OUString> aNames { DBF_CHAR_SET };
+            ScLinkConfigItem aItem( OUString::createFromAscii(
+                                        bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
+
+            aValues = aItem.GetProperties( aNames );
+            pProperties = aValues.getConstArray();
+
+            if( pProperties[0].hasValue() )
+            {
+                sal_Int32 nChar = 0;
+                pProperties[0] >>= nChar;
+                if( nChar >= 0)
+                {
+                    nCharSet = (rtl_TextEncoding) nChar;
+                    return charset_from_user_setting;
+                }
+            }
+
+            // Default choice
+            nCharSet = RTL_TEXTENCODING_IBM_850;
+            return charset_default;
         }
     }
-}
 
-static void save_CharSet( rtl_TextEncoding nCharSet, bool bExport )
-{
-    Sequence<Any> aValues;
-    Any *pProperties;
-    Sequence<OUString> aNames { DBF_CHAR_SET };
-    ScLinkConfigItem aItem( OUString::createFromAscii(
-                                bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
+    void save_CharSet( rtl_TextEncoding nCharSet, bool bExport )
+    {
+        Sequence<Any> aValues;
+        Any *pProperties;
+        Sequence<OUString> aNames { DBF_CHAR_SET };
+        ScLinkConfigItem aItem( OUString::createFromAscii(
+                                    bExport?DBF_SEP_PATH_EXPORT:DBF_SEP_PATH_IMPORT ) );
 
-    aValues = aItem.GetProperties( aNames );
-    pProperties = aValues.getArray();
-    pProperties[0] <<= (sal_Int32) nCharSet;
+        aValues = aItem.GetProperties( aNames );
+        pProperties = aValues.getArray();
+        pProperties[0] <<= (sal_Int32) nCharSet;
 
-    aItem.PutProperties(aNames, aValues);
+        aItem.PutProperties(aNames, aValues);
+    }
 }
 
 ScFilterOptionsObj::ScFilterOptionsObj() :
commit c08dd17baf7ea63f10d5311e90c5c6a4c48aac20
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Wed Jun 28 08:09:33 2017 +0000

    tdf#45904 Move Java XCellAddressable test to C++
    
    Change-Id: Ib68c7dd8087f19bd969cf5273c3a6e8664c6bb62
    Reviewed-on: https://gerrit.libreoffice.org/39348
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/include/test/sheet/xcelladdressable.hxx b/include/test/sheet/xcelladdressable.hxx
new file mode 100644
index 000000000000..cf2da7eadc1f
--- /dev/null
+++ b/include/test/sheet/xcelladdressable.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDE_TEST_SHEET_XCELLADDRESSABLE_HXX
+#define INCLUDE_TEST_SHEET_XCELLADDRESSABLE_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <test/testdllapi.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XCellAddressable
+{
+public:
+    virtual uno::Reference< uno::XInterface > init() = 0;
+    virtual ~XCellAddressable(){}
+
+    void testGetCellAddress();
+};
+
+}
+
+#endif // INCLUDE_TEST_SHEET_XCELLADDRESSABLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index da5822fcd1bd..458ebf1b7cf9 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -592,7 +592,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_XAreaLinks \
     qadevOOo/tests/java/ifc/sheet/_XArrayFormulaRange \
     qadevOOo/tests/java/ifc/sheet/_XCalculatable \
-    qadevOOo/tests/java/ifc/sheet/_XCellAddressable \
     qadevOOo/tests/java/ifc/sheet/_XCellFormatRangesSupplier \
     qadevOOo/tests/java/ifc/sheet/_XCellRangeAddressable \
     qadevOOo/tests/java/ifc/sheet/_XCellRangeData \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
index 583f9f622b18..ef1c845ab31b 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
@@ -139,7 +139,6 @@
 "ScCellObj";"com::sun::star::text::XTextRange";"getEnd()"
 "ScCellObj";"com::sun::star::text::XTextRange";"getString()"
 "ScCellObj";"com::sun::star::text::XTextRange";"setString()"
-"ScCellObj";"com::sun::star::sheet::XCellAddressable";"getCellAddress()"
 "ScCellObj";"com::sun::star::sheet::SheetCell";"Position"
 "ScCellObj";"com::sun::star::sheet::SheetCell";"Size"
 "ScCellObj";"com::sun::star::sheet::SheetCell";"FormulaLocal#optional"
diff --git a/sc/CppunitTest_sc_cellobj.mk b/sc/CppunitTest_sc_cellobj.mk
new file mode 100644
index 000000000000..62183c32b4c9
--- /dev/null
+++ b/sc/CppunitTest_sc_cellobj.mk
@@ -0,0 +1,106 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_cellobj))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_cellobj, \
+    sc/qa/extras/sccellobj \
+))
+
+$(eval $(call gb_CppunitTest_use_external,sc_cellobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_cellobj, \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    for \
+    forui \
+    i18nlangtag \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sc \
+    sfx \
+    sot \
+    subsequenttest \
+    svl \
+    svt \
+    svx \
+    svxcore \
+	test \
+    tk \
+    tl \
+    ucbhelper \
+	unotest \
+    utl \
+    vbahelper \
+    vcl \
+    xo \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_cellobj,\
+    -I$(SRCDIR)/sc/source/ui/inc \
+    -I$(SRCDIR)/sc/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_cellobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_cellobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_cellobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_cellobj,\
+    basic/util/sb \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    dbaccess/util/dba \
+    filter/source/config/cache/filterconfig1 \
+    filter/source/storagefilterdetect/storagefd \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    linguistic/source/lng \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    scripting/source/basprov/basprov \
+    scripting/util/scriptframe \
+    sc/util/sc \
+    sc/util/scd \
+    sc/util/scfilt \
+    $(call gb_Helper_optional,SCRIPTING, \
+	    sc/util/vbaobj) \
+    sfx2/util/sfx \
+    sot/util/sot \
+    svl/source/fsstor/fsstorage \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    ucb/source/ucp/tdoc/ucptdoc1 \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+    uui/util/uui \
+    xmloff/util/xo \
+	svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_cellobj))
+
+# vim: set noet sw=4 ts=4:
+
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index d1248eaca7d7..edb72275e6a9 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -121,6 +121,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_check_data_pilot_field \
 	CppunitTest_sc_check_data_pilot_table \
 	CppunitTest_sc_viewpaneobj \
+	CppunitTest_sc_cellobj \
 	CppunitTest_sc_cellcursorobj \
 ))
 
diff --git a/sc/qa/extras/sccellobj.cxx b/sc/qa/extras/sccellobj.cxx
new file mode 100644
index 000000000000..3ee66bb19789
--- /dev/null
+++ b/sc/qa/extras/sccellobj.cxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/calc_unoapi_test.hxx>
+#include <test/sheet/xcelladdressable.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+using namespace css;
+using namespace css::uno;
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 1
+
+class ScCellObj : public CalcUnoApiTest, public apitest::XCellAddressable
+{
+public:
+    ScCellObj();
+
+    virtual uno::Reference< uno::XInterface > init() override;
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScCellObj);
+    // XCellAddressable
+    CPPUNIT_TEST(testGetCellAddress);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+
+    static sal_Int32 nTest;
+    static uno::Reference< lang::XComponent > mxComponent;
+
+};
+
+sal_Int32 ScCellObj::nTest = 0;
+uno::Reference< lang::XComponent > ScCellObj::mxComponent;
+
+ScCellObj::ScCellObj()
+        : CalcUnoApiTest("/sc/qa/extrax/testdocuments")
+{
+}
+
+uno::Reference< uno::XInterface > ScCellObj::init()
+{
+    // create a calc document
+    if (!mxComponent.is())
+        mxComponent = loadFromDesktop("private:factory/scalc");
+
+    uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("no calc document", xSheetDoc.is());
+
+    // get getSheets
+    uno::Reference< sheet::XSpreadsheets > xSheets (xSheetDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Any rSheet = xSheets->getByName("Sheet1");
+    // query for the XCellRange interface
+    uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
+    uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName("A1");
+
+    return xCellRange->getCellByPosition(0, 0);
+}
+
+void ScCellObj::setUp()
+{
+    nTest++;
+    CalcUnoApiTest::setUp();
+}
+
+void ScCellObj::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        closeDocument(mxComponent);
+        mxComponent.clear();
+    }
+
+    CalcUnoApiTest::tearDown();
+}
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScCellObj);
+
+} // end namespace
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index e5ab18b166f2..1f68fd395ba5 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
     test/source/container/xnamed \
     test/source/sheet/cellproperties \
     test/source/sheet/datapilotfield \
+    test/source/sheet/xcelladdressable \
     test/source/sheet/xcellrangedata \
     test/source/sheet/xcellrangereferrer \
     test/source/sheet/xcellrangesquery \
diff --git a/test/source/sheet/xcelladdressable.cxx b/test/source/sheet/xcelladdressable.cxx
new file mode 100644
index 000000000000..0d92b1ae2333
--- /dev/null
+++ b/test/source/sheet/xcelladdressable.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcelladdressable.hxx>
+
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+CPPUNIT_NS_BEGIN
+
+template<> struct assertion_traits<table::CellAddress>
+{
+    static bool equal(const table::CellAddress& x, const table::CellAddress& y)
+    {
+        return x == y;
+    }
+
+    static std::string toString( const table::CellAddress& x )
+    {
+        OStringStream ost;
+        ost << "Sheet: " << x.Sheet << " Column: " << x.Column << " Row: " << x.Row;
+        return ost.str();
+    }
+};
+
+CPPUNIT_NS_END
+
+namespace apitest {
+
+void XCellAddressable::testGetCellAddress()
+{
+    uno::Reference< sheet::XCellAddressable > xCellAddressable(init(), UNO_QUERY_THROW);
+    table::CellAddress xCellAddress = xCellAddressable->getCellAddress();
+    table::CellAddress defaultCellAddress;
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("getCellAddress() didn't returned default cell address",
+                                 defaultCellAddress, xCellAddress);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 01985fd8fccf46749b74ee733391ce8b6ec1f1f8
Author: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Date:   Sat Jul 1 10:22:06 2017 +0200

    xmlsecurity: avoid crash on empty security context
    
    This should prevent 8cf224c2-f9b9-44e1-9cb0-fc452e570886
    
    Change-Id: I1ad4d8437923eb677d574c2c469cc62378c9c7a6
    Reviewed-on: https://gerrit.libreoffice.org/39430
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index cb9d2db4d4e5..828823974182 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -153,6 +153,8 @@ void CertificateChooser::ImplInitialize()
 
     for (auto &secContext : mxSecurityContexts)
     {
+        if (!secContext.is())
+            continue;
         auto secEnvironment = secContext->getSecurityEnvironment();
         if (!secEnvironment.is())
             continue;
commit 7250bc4721b334714bb0fa1345211c83330f94b2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jun 30 23:23:36 2017 +0200

    notify the clipboard terminate listener before any other terminate listener
    
    Otherwise we may have destroyed a service that is needed to generate
    one of the clipboard formats requested by the system clipboard.
    
    Change-Id: Id05de3ac569e3ed38cd97efc4c48326bc6a8db0b
    Reviewed-on: https://gerrit.libreoffice.org/39429
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx
index 2b07a2487d97..a77c816e9d2a 100644
--- a/framework/inc/services/desktop.hxx
+++ b/framework/inc/services/desktop.hxx
@@ -341,6 +341,15 @@ class Desktop : private cppu::BaseMutex,
          */
         void impl_sendCancelTerminationEvent(const TTerminateListenerList& lCalledListener);
 
+        /** calls notifyTermination() on the clipboard listener
+         *
+         * The system clipboard may decide that it wants copies
+         * in several formats of the clipboard content requiring
+         * nearly all the services
+         *
+         */
+        void impl_sendTerminateToClipboard();
+
         /** calls notifyTermination() on every registered termination listener.
          *
          *  Note: Only normal termination listener (registered in list m_aListenerContainer
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 7c3c2e4b80d1..e96224815441 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -324,6 +324,10 @@ sal_Bool SAL_CALL Desktop::terminate()
         aWriteLock.clear();
         /* UNSAFE AREA ------------------------------------------------------------------------------------- */
 
+        // The clipboard listener needs to be the first. It can create copies of the
+        // existing document which needs basically all the available infrastructure.
+        impl_sendTerminateToClipboard();
+
         impl_sendNotifyTerminationEvent();
         {
             SolarMutexGuard aGuard;
@@ -1630,6 +1634,46 @@ void Desktop::impl_sendCancelTerminationEvent(const Desktop::TTerminateListenerL
     }
 }
 
+void Desktop::impl_sendTerminateToClipboard()
+{
+    TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
+
+    ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
+    if ( ! pContainer )
+        return;
+
+    ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
+    while ( aIterator.hasMoreElements() )
+    {
+        try
+        {
+            css::uno::Reference< css::lang::XServiceInfo > xInfo( aIterator.next(), css::uno::UNO_QUERY );
+            if ( !xInfo.is() )
+                continue;
+
+            if ( xInfo->getImplementationName() != "com.sun.star.comp.svt.TransferableHelperTerminateListener" )
+                continue;
+
+            css::uno::Reference< css::frame::XTerminateListener > xListener(xInfo, css::uno::UNO_QUERY);
+            if ( ! xListener.is() )
+                continue;
+
+            css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
+            xListener->notifyTermination( aEvent );
+
+            // don't notify twice
+            aIterator.remove();
+        }
+        catch( const css::uno::Exception& )
+        {
+            // clean up container.
+            // E.g. dead remote listener objects can make trouble otherwise.
+            // Iterator implementation allows removing objects during it's used !
+            aIterator.remove();
+        }
+    }
+}
+
 void Desktop::impl_sendNotifyTerminationEvent()
 {
     TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
diff --git a/include/svtools/transfer.hxx b/include/svtools/transfer.hxx
index bc3c6eceacab..f499a2a1fce4 100644
--- a/include/svtools/transfer.hxx
+++ b/include/svtools/transfer.hxx
@@ -29,6 +29,7 @@
 #include <sot/exchange.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <com/sun/star/datatransfer/XTransferable2.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
@@ -127,7 +128,7 @@ class SVT_DLLPUBLIC TransferableHelper : public cppu::WeakImplHelper< css::datat
 private:
 
     // nested class to implement the XTerminateListener interface
-    class TerminateListener : public cppu::WeakImplHelper< css::frame::XTerminateListener >
+    class TerminateListener : public cppu::WeakImplHelper< css::frame::XTerminateListener, css::lang::XServiceInfo >
     {
     private:
 
@@ -142,6 +143,11 @@ private:
         virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override;
         virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override;
 
+        // XServiceInfo
+        virtual OUString SAL_CALL getImplementationName() override;
+        virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override;
+        virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
     public:
 
                               TerminateListener( TransferableHelper& rDropTargetHelper );
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index 955e9b8d3276..d1913d795e4a 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -253,6 +253,21 @@ void SAL_CALL TransferableHelper::TerminateListener::notifyTermination( const Ev
     mrParent.ImplFlush();
 }
 
+OUString SAL_CALL TransferableHelper::TerminateListener::getImplementationName()
+{
+    return OUString("com.sun.star.comp.svt.TransferableHelperTerminateListener");
+}
+
+sal_Bool SAL_CALL TransferableHelper::TerminateListener::supportsService(const OUString& /*rServiceName*/)
+{
+    return false;
+}
+
+css::uno::Sequence<OUString> TransferableHelper::TerminateListener::getSupportedServiceNames()
+{
+    return css::uno::Sequence<OUString>();
+}
+
 
 Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor )
 {
commit 34c77d4bf3d2924c4ad26728d4c491b393fa0fc8
Author: Henry Castro <hcastro at collabora.com>
Date:   Sat Jul 1 11:31:24 2017 -0400

    sc lok: disable items of the overlay manager
    
    They consume unnecessary CPU idle task in the tiled
    redenring case
    
    Change-Id: I477d17479ee83b31474675ef0d2317163d4fcee7
    Reviewed-on: https://gerrit.libreoffice.org/39437
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index bc79b8c87af4..a7a9e9b72ac7 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5626,6 +5626,8 @@ void ScGridWindow::UpdateCopySourceOverlay()
 
     DeleteCopySourceOverlay();
 
+    if (comphelper::LibreOfficeKit::isActive())
+        return;
     if (!pViewData->ShowPasteSource())
         return;
     rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
@@ -5886,9 +5888,6 @@ void ScGridWindow::UpdateCursorOverlay()
                 xOverlayManager->add(*pOverlay);
                 mpOOCursors.reset(new sdr::overlay::OverlayObjectList);
                 mpOOCursors->append(pOverlay);
-
-                // notify the LibreOfficeKit too
-                updateLibreOfficeKitSelection(pViewData, aPixelRects);
             }
         }
     }
@@ -5924,8 +5923,12 @@ void ScGridWindow::UpdateSelectionOverlay()
     {
         // #i70788# get the OverlayManager safely
         rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
-
-        if (xOverlayManager.is())
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            // notify the LibreOfficeKit too
+            updateLibreOfficeKitSelection(pViewData, aPixelRects);
+        }
+        else if (xOverlayManager.is())
         {
             std::vector< basegfx::B2DRange > aRanges;
             const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
@@ -5962,9 +5965,6 @@ void ScGridWindow::UpdateSelectionOverlay()
             xOverlayManager->add(*pOverlay);
             mpOOSelection.reset(new sdr::overlay::OverlayObjectList);
             mpOOSelection->append(pOverlay);
-
-            // notify the LibreOfficeKit too
-            updateLibreOfficeKitSelection(pViewData, aPixelRects);
         }
     }
     else
@@ -6037,7 +6037,7 @@ void ScGridWindow::UpdateAutoFillOverlay()
         // #i70788# get the OverlayManager safely
         rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
 
-        if (xOverlayManager.is())
+        if (xOverlayManager.is() && !comphelper::LibreOfficeKit::isActive())
         {
             Color aHandleColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
             if (pViewData->GetActivePart() != eWhich)
@@ -6165,7 +6165,7 @@ void ScGridWindow::UpdateDragRectOverlay()
         // #i70788# get the OverlayManager safely
         rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
 
-        if (xOverlayManager.is())
+        if (xOverlayManager.is() && !comphelper::LibreOfficeKit::isActive())
         {
             std::vector< basegfx::B2DRange > aRanges;
             const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
@@ -6213,7 +6213,7 @@ void ScGridWindow::UpdateHeaderOverlay()
         // #i70788# get the OverlayManager safely
         rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
 
-        if (xOverlayManager.is())
+        if (xOverlayManager.is() && !comphelper::LibreOfficeKit::isActive())
         {
             // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor();
             std::vector< basegfx::B2DRange > aRanges;
@@ -6281,7 +6281,7 @@ void ScGridWindow::UpdateShrinkOverlay()
         // #i70788# get the OverlayManager safely
         rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
 
-        if (xOverlayManager.is())
+        if (xOverlayManager.is() && !comphelper::LibreOfficeKit::isActive())
         {
             std::vector< basegfx::B2DRange > aRanges;
             const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
commit 258df6f41d89a606a980942df6337d446634c0a6
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Sat Jul 1 14:48:22 2017 +0200

    tdf#107505: Impress - crash with two people co-editing one slide
    
    In tiledrendering mode cursor inside shapes are not handled very well now.
    Different LO instances manipulates the same cursor instead of having
    one separate cursor for all instances (as in case of simple text editing
    in Writer).
    
    Crashes caused by that one cursor is owned (created and destroyed) by one
    LO instance but used by an other instance in the meantime. We can avoid
    this by not making this cursor available to the other instances. Cursor is
    hidden anyway so don't need to have it set to the corresponding Window.
    
    Change-Id: Id78f79e73eda88f3c2c6aa7f534c32f3f8aba174
    Reviewed-on: https://gerrit.libreoffice.org/39432
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index cb7fa37892f1..04e3b34f8aff 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -908,6 +908,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
                             {
                                 OutlinerView* pOutlView = ImpMakeOutlinerView(static_cast<vcl::Window*>(&rOutDev), nullptr);
                                 pOutlView->HideCursor();
+                                static_cast<vcl::Window*>(&rOutDev)->SetCursor(nullptr);
                                 pTextEditOutliner->InsertView(pOutlView);
                             }
                         }
commit 68c8d7faa219b36d5d17ca84f4f1002ec998b80c
Author: Justin Luth <justin_luth at sil.org>
Date:   Sat Jul 1 09:34:23 2017 -0400

    tdf#108448 ww8export: endnote unit test
    
    Change-Id: I3559e51c7fe9fedf616857b5ae612b4a8f6c67d5
    Reviewed-on: https://gerrit.libreoffice.org/39431
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/qa/extras/ww8export/data/tdf108448_endNote.odt b/sw/qa/extras/ww8export/data/tdf108448_endNote.odt
new file mode 100644
index 000000000000..bc4a751a8978
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf108448_endNote.odt differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index d429d53b0404..70aa498d5fdc 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -15,6 +15,7 @@
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <com/sun/star/text/XFootnote.hpp>
 #include <pagedesc.hxx>
 
 class Test : public SwModelTestBase
@@ -96,6 +97,24 @@ DECLARE_WW8EXPORT_TEST(testBnc863018b, "bnc863018b.doc")
     CPPUNIT_ASSERT_EQUAL( 1, getPages() );
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf108448_endNote, "tdf108448_endNote.odt")
+{
+    uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xEndnotes(xEndnotesSupplier->getEndnotes(), uno::UNO_QUERY);
+    uno::Reference<text::XText> xEndnote;
+    xEndnotes->getByIndex(0) >>= xEndnote;
+
+    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xEndnote->getText(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+    int nRet = 0;
+    while (xParaEnum->hasMoreElements())
+    {
+        xParaEnum->nextElement();
+        nRet++;
+    }
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in Endnote i", 1, nRet );
+}
+
 DECLARE_WW8EXPORT_TEST(testTdf104805, "tdf104805.doc")
 {
     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WW8Num1"), uno::UNO_QUERY);
commit 51f616ddd7a2e3310e1b30dbd73d90e5138980ea
Author: Aron Budea <aron.budea at collabora.com>
Date:   Fri Jun 30 23:57:35 2017 +0200

    tdf#108622: use correct type for last check timestamp during autocorrect
    
    It's only supposed to check the files once every 2-mins, with
    mismatching type that happens each time.
    
    Change-Id: Ie9243cf928d952e28989dd981508de86cb7dbddb
    Reviewed-on: https://gerrit.libreoffice.org/39428
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index b5dd3a1233cd..3c832486a04e 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -1571,7 +1571,7 @@ bool SvxAutoCorrect::CreateLanguageFile( const LanguageTag& rLanguageTag, bool b
 
     tools::Time nMinTime( 0, 2 ), nAktTime( tools::Time::SYSTEM ), nLastCheckTime( tools::Time::EMPTY );
 
-    std::map<LanguageTag, long>::iterator nFndPos = aLastFileTable.find(rLanguageTag);
+    auto nFndPos = aLastFileTable.find(rLanguageTag);
     if(nFndPos != aLastFileTable.end() &&
        (nLastCheckTime.SetTime(nFndPos->second), nLastCheckTime < nAktTime) &&
        nAktTime - nLastCheckTime < nMinTime)
diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx
index 10df11213dd3..1cc14c0214ae 100644
--- a/include/editeng/svxacorr.hxx
+++ b/include/editeng/svxacorr.hxx
@@ -233,7 +233,7 @@ class EDITENG_DLLPUBLIC SvxAutoCorrect
 
     // all languages in a table
     std::map<LanguageTag, std::unique_ptr<SvxAutoCorrectLanguageLists>> m_aLangTable;
-    std::map<LanguageTag, long> aLastFileTable;
+    std::map<LanguageTag, sal_Int64> aLastFileTable;
     std::unique_ptr<CharClass> pCharClass;
 
     bool bRunNext;
commit 8e974d24f3bbc59c66476db1a56e6a2013a528e0
Author: Justin Luth <justin_luth at sil.org>
Date:   Tue Jun 13 13:48:44 2017 +0300

    tdf#108448 ww8export: skip sectionbreak for endnotes
    
    MSWord ignores page-breaks in endnotes, and just adds
    endnotes at the end of the last page.
    LO automatically page-breaks with pageStyle Endnotes. It
    must be built into the code that handles endnotes.
    
    Don't try to export that page-break - it doesn't work anyway.
    
    Change-Id: I2f266b20a6fa97d0522878f71fe0a6822833d89c
    Reviewed-on: https://gerrit.libreoffice.org/38727
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index b1a49391b848..987a060820cc 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -2649,7 +2649,8 @@ void MSWordExportBase::WriteText()
     {
         SwNode& rNd = m_pCurPam->GetNode();
 
-        if ( rNd.IsTextNode() )
+        // no section breaks exported for Endnotes
+        if ( rNd.IsTextNode() && m_nTextTyp != TXT_EDN )
             SectionBreaksAndFrames( *rNd.GetTextNode() );
 
         // output the various types of nodes
commit 4b5f5f868fa6a7c86535d251e77d8a6d956f2fa4
Author: Mohammed Abdul Azeem <azeemmysore at gmail.com>
Date:   Thu Jun 29 23:39:07 2017 +0530

    Moving legacy contexts to FastContexts:
    
    ScXMLTrackedChangesContext
    ScXMLCalculationSettingsContext
    ScXMLContentValidationsContext
    ScXMLLabelRangesContext
    ScXMLNamedExpressionsContext
    ScXMLDatabaseRangesContext
    ScXMLDatabaseRangeContext
    ScXMLDataPilotTablesContext
    ScXMLConsolidationContext
    ScXMLDDELinksContext
    ScXMLDataStreamContext
    
    Change-Id: I702d30e01af5e3707d34303ddebc3d07913d67e3
    Reviewed-on: https://gerrit.libreoffice.org/39397
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
index 452cd3f97836..f39ccebe5eb6 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
@@ -32,10 +32,9 @@ using namespace com::sun::star;
 using namespace xmloff::token;
 
 ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList) :
+    ScXMLImportContext( rImport ),
     fIterationEpsilon(0.001),
     nIterationCount(100),
     nYear2000(1930),
@@ -49,53 +48,45 @@ ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& r
     aNullDate.Day = 30;
     aNullDate.Month = 12;
     aNullDate.Year = 1899;
-    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-    for( sal_Int16 i=0; i < nAttrCount; ++i )
+    if( xAttrList.is() )
     {
-        const OUString& sAttrName(xAttrList->getNameByIndex( i ));
-        OUString aLocalName;
-        sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
-                                            sAttrName, &aLocalName );
-        const OUString& sValue(xAttrList->getValueByIndex( i ));
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
 
-        if (nPrefix == XML_NAMESPACE_TABLE)
+        for( auto &aIter : *pAttribList )
         {
-            if (IsXMLToken(aLocalName, XML_CASE_SENSITIVE))
+            switch( aIter.getToken() )
             {
-                if (IsXMLToken(sValue, XML_FALSE))
+            case XML_ELEMENT( TABLE, XML_CASE_SENSITIVE ):
+                if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     bIgnoreCase = true;
-            }
-            else if (IsXMLToken(aLocalName, XML_PRECISION_AS_SHOWN))
-            {
-                if (IsXMLToken(sValue, XML_TRUE))
+                break;
+            case XML_ELEMENT( TABLE, XML_PRECISION_AS_SHOWN ):
+                if( IsXMLToken( aIter.toCString(), XML_TRUE ) )
                     bCalcAsShown = true;
-            }
-            else if (IsXMLToken(aLocalName, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL))
-            {
-                if (IsXMLToken(sValue, XML_FALSE))
+                break;
+            case XML_ELEMENT( TABLE, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL ):
+                if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     bMatchWholeCell = false;
-            }
-            else if (IsXMLToken(aLocalName, XML_AUTOMATIC_FIND_LABELS))
-            {
-                if (IsXMLToken(sValue, XML_FALSE))
+                break;
+            case XML_ELEMENT( TABLE, XML_AUTOMATIC_FIND_LABELS ):
+                if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     bLookUpLabels = false;
-            }
-            else if (IsXMLToken(aLocalName, XML_NULL_YEAR))
-            {
+                break;
+            case XML_ELEMENT( TABLE, XML_NULL_YEAR ):
                 sal_Int32 nTemp;
-                ::sax::Converter::convertNumber(nTemp, sValue);
+                ::sax::Converter::convertNumber( nTemp, aIter.toString() );
                 nYear2000 = static_cast<sal_uInt16>(nTemp);
-            }
-            else if (IsXMLToken(aLocalName, XML_USE_REGULAR_EXPRESSIONS))
-            {
+                break;
+            case XML_ELEMENT( TABLE, XML_USE_REGULAR_EXPRESSIONS ):
                 // Overwrite only the default (regex true) value, not wildcard.
-                if (eSearchType == utl::SearchParam::SearchType::Regexp && IsXMLToken(sValue, XML_FALSE))
+                if( eSearchType == utl::SearchParam::SearchType::Regexp && IsXMLToken( aIter.toCString(), XML_FALSE ) )
                     eSearchType = utl::SearchParam::SearchType::Normal;
-            }
-            else if (IsXMLToken(aLocalName, XML_USE_WILDCARDS))
-            {
-                if (IsXMLToken(sValue, XML_TRUE))
+                break;
+            case XML_ELEMENT( TABLE, XML_USE_WILDCARDS ):
+                if( IsXMLToken( aIter.toCString(), XML_TRUE ) )
                     eSearchType = utl::SearchParam::SearchType::Wildcard;
+                break;
             }
         }
     }
@@ -125,7 +116,7 @@ SvXMLImportContext *ScXMLCalculationSettingsContext::CreateChildContext( sal_uIn
     return pContext;
 }
 
-void ScXMLCalculationSettingsContext::EndElement()
+void SAL_CALL ScXMLCalculationSettingsContext::endFastElement( sal_Int32 /*nElement*/ )
 {
     if (GetScImport().GetModel().is())
     {
diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx
index 3ad233a39407..fb0cd553a673 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.hxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.hxx
@@ -41,9 +41,8 @@ class ScXMLCalculationSettingsContext : public ScXMLImportContext
     bool bMatchWholeCell;
 
 public:
-    ScXMLCalculationSettingsContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLCalculationSettingsContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLCalculationSettingsContext() override;
 
@@ -55,7 +54,7 @@ public:
     void SetIterationStatus(const bool bValue) { bIsIterationEnabled = bValue; }
     void SetIterationCount(const sal_Int32 nValue) { nIterationCount = nValue; }
     void SetIterationEpsilon(const double fValue) { fIterationEpsilon = fValue; }
-    virtual void EndElement() override;
+    virtual void SAL_CALL endFastElement( sal_Int32 Element ) override;
 };
 
 class ScXMLNullDateContext : public ScXMLImportContext
diff --git a/sc/source/filter/xml/XMLConsolidationContext.cxx b/sc/source/filter/xml/XMLConsolidationContext.cxx
index 217327a4a8cb..8e27b573de7b 100644
--- a/sc/source/filter/xml/XMLConsolidationContext.cxx
+++ b/sc/source/filter/xml/XMLConsolidationContext.cxx
@@ -24,54 +24,50 @@
 #include "XMLConverter.hxx"
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
 
 using namespace ::com::sun::star;
 using namespace xmloff::token;
 
 ScXMLConsolidationContext::ScXMLConsolidationContext(
         ScXMLImport& rImport,
-        sal_uInt16 nPrfx,
-        const OUString& rLName,
-        const uno::Reference< xml::sax::XAttributeList >& xAttrList ) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+        sal_Int32 /*nElement*/,
+        const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) :
+    ScXMLImportContext( rImport ),
     eFunction( SUBTOTAL_FUNC_NONE ),
     bLinkToSource( false ),
     bTargetAddr(false)
 {
     rImport.LockSolarMutex();
-    if( !xAttrList.is() ) return;
-
-    sal_Int16               nAttrCount      = xAttrList->getLength();
-    const SvXMLTokenMap&    rAttrTokenMap   = GetScImport().GetConsolidationAttrTokenMap();
-
-    for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
+    if( xAttrList.is() )
     {
-        const OUString& sAttrName  (xAttrList->getNameByIndex( nIndex ));
-        const OUString& sValue     (xAttrList->getValueByIndex( nIndex ));
-        OUString aLocalName;
-        sal_uInt16 nPrefix      = GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
 
-        switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+        for( auto &aIter : *pAttribList )
         {
-            case XML_TOK_CONSOLIDATION_ATTR_FUNCTION:
-                eFunction = ScXMLConverter::GetSubTotalFuncFromString( sValue );
-            break;
-            case XML_TOK_CONSOLIDATION_ATTR_SOURCE_RANGES:
-                sSourceList = sValue;
-            break;
-            case XML_TOK_CONSOLIDATION_ATTR_TARGET_ADDRESS:
-                {
-                    sal_Int32 nOffset(0);
-                    bTargetAddr = ScRangeStringConverter::GetAddressFromString(
-                        aTargetAddr, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset );
-                }
+            switch( aIter.getToken() )
+            {
+                case XML_ELEMENT( TABLE, XML_FUNCTION ):
+                    eFunction = ScXMLConverter::GetSubTotalFuncFromString( aIter.toString() );
+                break;
+                case XML_ELEMENT( TABLE, XML_SOURCE_CELL_RANGE_ADDRESSES ):
+                    sSourceList = aIter.toString();
+                break;
+                case XML_ELEMENT( TABLE, XML_TARGET_CELL_ADDRESS ):
+                    {
+                        sal_Int32 nOffset(0);
+                        bTargetAddr = ScRangeStringConverter::GetAddressFromString(
+                            aTargetAddr, aIter.toString(), GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset );
+                    }
+                    break;
+                case XML_ELEMENT( TABLE, XML_USE_LABEL ):
+                    sUseLabel = aIter.toString();
                 break;
-            case XML_TOK_CONSOLIDATION_ATTR_USE_LABEL:
-                sUseLabel = sValue;
-            break;
-            case XML_TOK_CONSOLIDATION_ATTR_LINK_TO_SOURCE:
-                bLinkToSource = IsXMLToken(sValue, XML_TRUE);
-            break;
+                case XML_ELEMENT( TABLE, XML_LINK_TO_SOURCE_DATA ):
+                    bLinkToSource = IsXMLToken( aIter.toCString(), XML_TRUE );
+                break;
+            }
         }
     }
 }
@@ -89,7 +85,7 @@ SvXMLImportContext *ScXMLConsolidationContext::CreateChildContext(
     return new SvXMLImportContext( GetImport(), nPrefix, rLName );
 }
 
-void ScXMLConsolidationContext::EndElement()
+void SAL_CALL ScXMLConsolidationContext::endFastElement( sal_Int32 /*nElement*/ )
 {
     if (bTargetAddr)
     {
diff --git a/sc/source/filter/xml/XMLConsolidationContext.hxx b/sc/source/filter/xml/XMLConsolidationContext.hxx
index 499aab1ed55f..3a7ebf272331 100644
--- a/sc/source/filter/xml/XMLConsolidationContext.hxx
+++ b/sc/source/filter/xml/XMLConsolidationContext.hxx
@@ -40,9 +40,8 @@ private:
 public:
                                 ScXMLConsolidationContext(
                                     ScXMLImport& rImport,
-                                    sal_uInt16 nPrfx,
-                                    const OUString& rLName,
-                                    const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList
+                                    sal_Int32 nElement,
+                                    const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList
                                     );
     virtual                     ~ScXMLConsolidationContext() override;
 
@@ -51,7 +50,7 @@ public:
                                     const OUString& rLocalName,
                                     const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList
                                     ) override;
-    virtual void                EndElement() override;
+    virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
 };
 
 #endif
diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx
index 4b0260231ad8..dc179e1c1451 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.cxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.cxx
@@ -32,10 +32,9 @@ using namespace com::sun::star;
 using namespace xmloff::token;
 
 ScXMLDDELinksContext::ScXMLDDELinksContext( ScXMLImport& rImport,
-                                      sal_uInt16 nPrfx,
-                                      const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& /* xAttrList */ ) :
-    ScXMLImportContext( rImport, nPrfx, rLName )
+                                      sal_Int32 /*nElement*/,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& /* xAttrList */ ) :
+    ScXMLImportContext( rImport )
 {
     // here are no attributes
     rImport.LockSolarMutex();
@@ -61,10 +60,6 @@ SvXMLImportContext *ScXMLDDELinksContext::CreateChildContext( sal_uInt16 nPrefix
     return pContext;
 }
 
-void ScXMLDDELinksContext::EndElement()
-{
-}
-
 ScXMLDDELinkContext::ScXMLDDELinkContext( ScXMLImport& rImport,
                                       sal_uInt16 nPrfx,
                                       const OUString& rLName,
diff --git a/sc/source/filter/xml/XMLDDELinksContext.hxx b/sc/source/filter/xml/XMLDDELinksContext.hxx
index 43cfccab9758..79ec32644e7d 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.hxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.hxx
@@ -28,17 +28,14 @@
 class ScXMLDDELinksContext : public ScXMLImportContext
 {
 public:
-    ScXMLDDELinksContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
-                        const OUString& rLName,
-                        const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList);
+    ScXMLDDELinksContext( ScXMLImport& rImport, sal_Int32 nElement,
+                        const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList);
 
     virtual ~ScXMLDDELinksContext() override;
 
     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                      const OUString& rLocalName,
                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-
-    virtual void EndElement() override;
 };
 
 struct ScDDELinkCell
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index e6b3427eb9a0..ab95b71bc461 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -384,33 +384,27 @@ public:
 };
 
 ScXMLTrackedChangesContext::ScXMLTrackedChangesContext( ScXMLImport& rImport,
-                                              sal_uInt16 nPrfx,
-                                                   const OUString& rLName,
-                                              const uno::Reference<xml::sax::XAttributeList>& xAttrList,
+                                              sal_Int32 /*nElement*/,
+                                              const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
                                               ScXMLChangeTrackingImportHelper* pTempChangeTrackingImportHelper ) :
-    ScXMLImportContext( rImport, nPrfx, rLName ),
+    ScXMLImportContext( rImport ),
     pChangeTrackingImportHelper(pTempChangeTrackingImportHelper)
 {
     rImport.LockSolarMutex();
 
-    sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
-    for( sal_Int16 i=0; i < nAttrCount; ++i )
+    if( xAttrList.is() )
     {
-        const OUString& sAttrName(xAttrList->getNameByIndex( i ));
-        OUString aLocalName;
-        sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
-                                            sAttrName, &aLocalName ));
-        const OUString& sValue(xAttrList->getValueByIndex( i ));
-        if (nPrefix == XML_NAMESPACE_TABLE)
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
+
+        auto aIter( pAttribList->find( XML_ELEMENT( TABLE, XML_PROTECTION_KEY ) ) );
+        if( aIter != pAttribList->end() )
         {
-            if (IsXMLToken(aLocalName, XML_PROTECTION_KEY))
+            if( !aIter.isEmpty() )
             {
-                if (!sValue.isEmpty())
-                {
-                    uno::Sequence<sal_Int8> aPass;
-                    ::sax::Converter::decodeBase64(aPass, sValue);
-                    pChangeTrackingImportHelper->SetProtection(aPass);
-                }
+                uno::Sequence<sal_Int8> aPass;
+                ::sax::Converter::decodeBase64( aPass, aIter.toString() );
+                pChangeTrackingImportHelper->SetProtection(aPass);
             }
         }
     }
@@ -457,10 +451,6 @@ SvXMLImportContext *ScXMLTrackedChangesContext::CreateChildContext( sal_uInt16 n
     return pContext;
 }
 
-void ScXMLTrackedChangesContext::EndElement()
-{
-}
-
 ScXMLChangeInfoContext::ScXMLChangeInfoContext(  ScXMLImport& rImport,
                                               sal_uInt16 nPrfx,
                                               const OUString& rLName,
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.hxx b/sc/source/filter/xml/XMLTrackedChangesContext.hxx
index c3313161f007..e059a8682abb 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.hxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.hxx
@@ -34,15 +34,14 @@ class ScXMLTrackedChangesContext : public ScXMLImportContext
     ScXMLChangeTrackingImportHelper*    pChangeTrackingImportHelper;
 
 public:
-    ScXMLTrackedChangesContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
-                                      const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList,
+    ScXMLTrackedChangesContext( ScXMLImport& rImport, sal_Int32 nElement,
+                                      const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList,
                                       ScXMLChangeTrackingImportHelper* pChangeTrackingImportHelper);
     virtual ~ScXMLTrackedChangesContext() override;
 
     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                                     const OUString& rLocalName,
                                                     const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-    virtual void EndElement() override;
 };
 
 #endif
diff --git a/sc/source/filter/xml/datastreamimport.cxx b/sc/source/filter/xml/datastreamimport.cxx
index a764718e0c33..5e19c5215c15 100644
--- a/sc/source/filter/xml/datastreamimport.cxx
+++ b/sc/source/filter/xml/datastreamimport.cxx
@@ -13,6 +13,7 @@
 #include <rangeutl.hxx>
 #include <importfilterdata.hxx>
 #include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlnmspe.hxx>
 #include <xmloff/xmltoken.hxx>
 #include <formula/grammar.hxx>
 
@@ -20,56 +21,51 @@ using namespace com::sun::star;
 using namespace xmloff::token;
 
 ScXMLDataStreamContext::ScXMLDataStreamContext(
-    ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
-    const css::uno::Reference< css::xml::sax::XAttributeList>& xAttrList ) :
-    ScXMLImportContext(rImport, nPrefix, rLocalName),
+    ScXMLImport& rImport, sal_Int32 /*nElement*/,
+    const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList ) :
+    ScXMLImportContext(rImport),
     mbRefreshOnEmpty(false),
     meInsertPos(sc::ImportPostProcessData::DataStream::InsertBottom)
 {
-    if (!xAttrList.is())
-        return;
-
-    const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataStreamAttrTokenMap();
-
-    for (sal_Int32 i = 0; i < xAttrList->getLength(); ++i)
+    if( xAttrList.is() )
     {
-        const OUString& rName = xAttrList->getNameByIndex(i);
-        OUString aLocalName;
-        sal_uInt16 nLocalPrefix =
-            GetScImport().GetNamespaceMap().GetKeyByAttrName(rName, &aLocalName);
+        sax_fastparser::FastAttributeList *pAttribList =
+            static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
 
-        const OUString& rVal = xAttrList->getValueByIndex(i);
-        switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
+        for( auto &aIter : *pAttribList )
         {
-            case XML_TOK_DATA_STREAM_ATTR_URL:
-                maURL = GetScImport().GetAbsoluteReference(rVal);
-            break;
-            case XML_TOK_DATA_STREAM_ATTR_RANGE:
+            switch ( aIter.getToken() )
             {
-                ScDocument* pDoc = GetScImport().GetDocument();
-                sal_Int32 nOffset = 0;
-                if (!ScRangeStringConverter::GetRangeFromString(
-                    maRange, rVal, pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
-                    maRange.SetInvalid();
+                case XML_ELEMENT( XLINK, XML_HREF ):
+                    maURL = GetScImport().GetAbsoluteReference( aIter.toString() );
+                break;
+                case XML_ELEMENT( TABLE, XML_TARGET_RANGE_ADDRESS ):
+                {
+                    ScDocument* pDoc = GetScImport().GetDocument();
+                    sal_Int32 nOffset = 0;
+                    if (!ScRangeStringConverter::GetRangeFromString(
+                        maRange, aIter.toString(), pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
+                        maRange.SetInvalid();
+                }
+                break;
+                case XML_ELEMENT( CALC_EXT, XML_EMPTY_LINE_REFRESH ):
+                    mbRefreshOnEmpty = IsXMLToken( aIter.toCString(), XML_TRUE );
+                break;
+                case XML_ELEMENT( CALC_EXT, XML_INSERTION_POSITION ):
+                    meInsertPos = IsXMLToken( aIter.toCString(), XML_TOP ) ?
+                        sc::ImportPostProcessData::DataStream::InsertTop :
+                        sc::ImportPostProcessData::DataStream::InsertBottom;
+                break;
+                default:

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list