[Libreoffice-commits] core.git: Branch 'feature/cib_contract3753' - 2 commits - include/sal xmloff/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 23 10:32:04 UTC 2021


 include/sal/log.hxx                             |    5 ++++-
 xmloff/source/text/XMLTextMarkImportContext.cxx |    9 +++++++++
 xmloff/source/text/txtimp.cxx                   |    1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 8417f6b94e55b35179ce636627dfb7f0b2474a6f
Author:     Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Mon Feb 22 16:10:47 2021 +0100
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Mon Aug 23 12:21:05 2021 +0200

    tdf#140437 ODF import: fix for broken documents with field code as type
    
    Not sure how old the bug that caused this and which filter it was
    originally but currently the Word import filters don't do that any more.
    
    This causes an exception since commit
    dd24e21bb4f183048a738314934fc3f02ec093f1 so try to fix it up.
    
    Change-Id: I087586054ebd5698ed8e8a4054869df202226e92
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111345
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
    (cherry picked from commit d62c93a831080ef332e416dc78f5600c2c5b9850)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111318
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit 3a1c4dc5887eee7313fe3f6cb20202df89ac5457)

diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx
index 7a919eb99385..8a2e09515d9d 100644
--- a/xmloff/source/text/XMLTextMarkImportContext.cxx
+++ b/xmloff/source/text/XMLTextMarkImportContext.cxx
@@ -200,7 +200,16 @@ static auto InsertFieldmark(SvXMLImport & rImport,
         // setup fieldmark...
         Reference<text::XFormField> const xFormField(xContent, UNO_QUERY);
         assert(xFormField.is());
+    try {
         xFormField->setFieldType(fieldmarkTypeName);
+    } catch (uno::RuntimeException const&) {
+        // tdf#140437 somehow old documents had the field code in the type
+        // attribute instead of field:param
+        SAL_INFO("xmloff.text", "invalid fieldmark type, converting to param");
+        // add without checking: FieldParamImporter::Import() catches ElementExistException
+        rHelper.addFieldParam(ODF_CODE_PARAM, fieldmarkTypeName);
+        xFormField->setFieldType(ODF_UNHANDLED);
+    }
         rHelper.setCurrentFieldParamsTo(xFormField);
         // move cursor after setFieldType as that may delete/re-insert
         rHelper.GetCursor()->gotoRange(xContent->getAnchor()->getEnd(), false);
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index ef739d273c6d..e704eb509266 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -894,6 +894,7 @@ namespace
             }
             catch(const ElementExistException&)
             {
+                SAL_INFO("xmloff.text", "duplicate fieldmark param");
             }
         }
     }
commit bf507f1e0928819e21111165103078b52292c369
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed May 5 08:20:18 2021 +0200
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Mon Aug 23 10:49:49 2021 +0200

    Adapt to "libstdc++: Implement LWG 1203 for rvalue iostreams"
    
    <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=aa475c4ac80733f85ba47b109fc1900f05e810e2>
    towards GCC 12, so that now "the return type is the original rvalue stream type
    not its base class."  (And which would thus have caused issues like
    
    > sfx2/source/control/bindings.cxx:1323:19: error: dynamic_cast from rvalue to reference type '::std::ostringstream &' (aka 'basic_ostringstream<char> &')
    >                 ? SAL_STREAM("File: " << pFile << " Line: " << nLine) : ""));
    >                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > include/sal/log.hxx:198:6: note: expanded from macro 'SAL_STREAM'
    >     (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream).str())
    >      ^
    > include/sal/log.hxx:341:20: note: expanded from macro 'SAL_INFO'
    >         SAL_WHERE, stream)
    >         ~~~~~~~~~~~^~~~~~~
    > include/sal/log.hxx:155:68: note: expanded from macro 'SAL_DETAIL_LOG_STREAM'
    >                 SAL_DETAIL_LOG_STREAM_PRIVATE_(level, area, where, stream); \
    >                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    > include/sal/log.hxx:133:45: note: expanded from macro 'SAL_DETAIL_LOG_STREAM_PRIVATE_'
    >             ::sal::detail::StreamStart() << stream) == 1) \
    >                                             ^~~~~~
    
    now.  While the issue with old libstdc++ that originally prompted the
    dynamic_cast was
    
    > sfx2/source/control/bindings.cxx:1323:19: error: no member named 'str' in 'std::basic_ostream<char>'
    >                 ? SAL_STREAM("File: " << pFile << " Line: " << nLine) : ""));
    >                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > include/sal/log.hxx:194:40: note: expanded from macro 'SAL_STREAM'
    >     (::std::ostringstream() << stream).str()
    >                                        ^
    > include/sal/log.hxx:336:20: note: expanded from macro 'SAL_INFO'
    >         SAL_WHERE, stream)
    >         ~~~~~~~~~~~^~~~~~~
    > include/sal/log.hxx:155:68: note: expanded from macro 'SAL_DETAIL_LOG_STREAM'
    >                 SAL_DETAIL_LOG_STREAM_PRIVATE_(level, area, where, stream); \
    >                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    > include/sal/log.hxx:133:45: note: expanded from macro 'SAL_DETAIL_LOG_STREAM_PRIVATE_'
    >             ::sal::detail::StreamStart() << stream) == 1) \
    >                                             ^~~~~~
    
    .)
    
    The libstdc++ macro _GLIBCXX_RELEASE is reportedly available since GCC 7.1.
    
    Change-Id: I1ee6eabb66355c1f28b9d305cbd85bac50d6b0e1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115121
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    
    (cherry picked from commit 1f3dddd6f21d91c429190ae314dadeec409f35f4, plus
    follow-up 95e26d3dce4f5a3b2d010d5ca47b4e450905a100 "tdf#142326: Adapt to
    'libstdc++: Implement LWG 1203 for rvalue iostreams'")
    Change-Id: I7c8fef25e15fcfa9b83924467dc86dc2957fbd7d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116447
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 428206c3c1c54d01435cf4e4a07174cfbd567335)

diff --git a/include/sal/log.hxx b/include/sal/log.hxx
index 00d533ab5495..f85c7d882134 100644
--- a/include/sal/log.hxx
+++ b/include/sal/log.hxx
@@ -161,7 +161,10 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) {
 
     @since LibreOffice 3.5
 */
-#if defined _LIBCPP_VERSION || (defined _MSC_VER && _MSC_VER >= 1915)
+#if defined _LIBCPP_VERSION \
+    || (defined _GLIBCXX_RELEASE \
+        && (_GLIBCXX_RELEASE >= 12 || (_GLIBCXX_RELEASE == 11 && __GLIBCXX__ > 20210428))) \
+    || (defined _MSC_VER && _MSC_VER >= 1915)
 #define SAL_STREAM(stream) \
     (::std::ostringstream() << stream).str()
 #else


More information about the Libreoffice-commits mailing list