avmedia/source/viewer/mediawindow.cxx            |    8 +
 include/avmedia/mediawindow.hxx                  |    2 
 jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx |    8 -
 sc/source/ui/app/inputwin.cxx                    |    3 
 starmath/source/mathml/iterator.cxx              |    6 -
 svl/source/misc/sharedstringpool.cxx             |    2 
 svx/source/svdraw/svdomedia.cxx                  |    4 
 svx/source/unodraw/unoshape.cxx                  |    9 -
 sw/inc/hints.hxx                                 |    4 
 sw/qa/extras/mailmerge/data/grabbagtest.docx     |binary
 sw/qa/extras/mailmerge/data/onecell.xlsx         |binary
 sw/qa/extras/mailmerge/mailmerge.cxx             |   92 +++++++++++++++---
 sw/qa/extras/uiwriter/data/simplefooter.docx     |binary
 sw/qa/extras/uiwriter/uiwriter.cxx               |   22 ++++
 sw/source/core/attr/hints.cxx                    |    7 -
 sw/source/core/crsr/crbm.cxx                     |   15 +-
 sw/source/core/doc/docbm.cxx                     |   28 +++++
 sw/source/core/doc/docnew.cxx                    |    9 +
 sw/source/core/frmedt/fecopy.cxx                 |   13 +-
 sw/source/core/inc/txtfrm.hxx                    |    3 
 sw/source/core/text/txtfrm.cxx                   |   44 +++++---
 sw/source/core/txtnode/ndtxt.cxx                 |    7 -
 sw/source/core/txtnode/txtedt.cxx                |    2 
 sw/source/filter/ww8/docxattributeoutput.cxx     |    2 
 sw/source/filter/ww8/wrtw8sty.cxx                |    8 +
 sw/source/ui/dbui/mmresultdialogs.cxx            |    8 +
 sw/source/uibase/utlui/glbltree.cxx              |   10 -
 vcl/inc/IconThemeSelector.hxx                    |    3 
 vcl/inc/unx/gtk/gtkframe.hxx                     |    6 +
 vcl/source/app/IconThemeSelector.cxx             |   13 +-
 vcl/source/app/settings.cxx                      |    9 +
 vcl/source/control/fmtfield.cxx                  |    4 
 vcl/unx/generic/printer/cpdmgr.cxx               |    2 
 vcl/unx/generic/printer/cupsmgr.cxx              |    2 
 vcl/unx/gtk3/gtkframe.cxx                        |  117 +++++++++++++++++++++--
 vcl/unx/gtk3/gtkinst.cxx                         |   45 ++++++++
 writerfilter/source/dmapper/DomainMapper.cxx     |    2 
 37 files changed, 432 insertions(+), 87 deletions(-)

New commits:
commit 3796bcf5f22751fdd3d5a1c89aa92795694ccec4
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue May 24 16:30:00 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:03 2022 +0200

    tdf#145248 don't start a drag if actively selecting
    
    Change-Id: I00565adbb32a6d9109a75548a544e79ba1951650
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134896
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 2874ec280f84..07344e1c0a19 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1740,7 +1740,8 @@ bool ScTextWnd::Command( const CommandEvent& rCEvt )
 
 bool ScTextWnd::StartDrag()
 {
-    if (m_xEditView)
+    // tdf#145248 don't start a drag if actively selecting
+    if (m_xEditView && !m_xEditEngine->IsInSelectionMode())
     {
         OUString sSelection = m_xEditView->GetSelected();
         m_xHelper->SetData(sSelection);
commit 6e5c473b0ab658cb93de819ec791db88bb1b9b11
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Sun May 22 12:55:36 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:03 2022 +0200

    vcl: GCC12 says fclose() causes -Werror=use-after-free on any use of FILE*
    
    In file included from vcl/inc/unx/cpdmgr.hxx:34,
                     from vcl/unx/generic/printer/cpdmgr.cxx:25:
    In member function ‘size_t psp::FPtrHash::operator()(const FILE*) const’,
        inlined from ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, 
_Hash, _RangeHash, _Unused, __cache_hash_code>::__hash_code 
std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, 
_Unused, __cache_hash_code>::_M_hash_code(const _Key&) const [with _Key = 
_IO_FILE*; _Value = std::pair<_IO_FILE* const, rtl::OString>; _ExtractKey = 
std::__detail::_Select1st; _Hash = psp::FPtrHash; _RangeHash = 
std::__detail::_Mod_range_hashing; _Unused = 
std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]’ at 
/usr/include/c++/12/bits/hashtable_policy.h:1268:18,
        inlined from ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, 
_Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::size_type 
std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, 
_Unused, _RehashPolicy, _Traits>::_M_erase(std::true_type, const key_type&) 
[with _Key = _IO_FILE*; _Value = std::pair<_IO_FILE* const, rtl::OString>; 
_Alloc = std::allocator<std::pair<_IO_FILE* const, rtl::OString> >; _ExtractKey 
= std::__detail::_Select1st; _Equal = std::equal_to<_IO_FILE*>; _Hash = 
psp::FPtrHash; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = 
std::__detail::_Default_ranged_hash; _RehashPolicy = 
std::__detail::_Prime_rehash_policy; _Traits = 
std::__detail::_Hashtable_traits<true, false, true>]’ at 
/usr/include/c++/12/bits/hashtable.h:2358:43,
        inlined from ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, 
_Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::size_type 
std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, 
_Unused, _RehashPolicy, _Traits>::erase(const key_type&) [with _Key = 
_IO_FILE*; _Value = std::pair<_IO_FILE* const, rtl::OString>; _Alloc = 
std::allocator<std::pair<_IO_FILE* const, rtl::OString> >; _ExtractKey = 
std::__detail::_Select1st; _Equal = std::equal_to<_IO_FILE*>; _Hash = 
psp::FPtrHash; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = 
std::__detail::_Default_ranged_hash; _RehashPolicy = 
std::__detail::_Prime_rehash_policy; _Traits = 
std::__detail::_Hashtable_traits<true, false, true>]’ at 
/usr/include/c++/12/bits/hashtable.h:971:24,
        inlined from ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, 
_Alloc>::size_type std::unordered_map<_Key, _Tp, _Hash, _Pred, 
_Alloc>::erase(const key_type&) [with _Key = _IO_FILE*; _Tp = rtl::OString; 
_Hash = psp::FPtrHash; _Pred = std::equal_to<_IO_FILE*>; _Alloc = 
std::allocator<std::pair<_IO_FILE* const, rtl::OString> >]’ at 
/usr/include/c++/12/bits/unordered_map.h:763:26,
        inlined from ‘virtual bool psp::CPDManager::endSpool(const 
rtl::OUString&, const rtl::OUString&, FILE*, const psp::JobData&, bool, const 
rtl::OUString&)’ at vcl/unx/generic/printer/cpdmgr.cxx:725:28:
    vcl/inc/unx/cupsmgr.hxx:35:43: error: pointer may be used after ‘int 
fclose(FILE*)’ [-Werror=use-after-free]
       35 |     { return reinterpret_cast<size_t>(pPtr); }
          |                                           ^
    vcl/unx/generic/printer/cpdmgr.cxx: In member function ‘virtual bool 
psp::CPDManager::endSpool(const rtl::OUString&, const rtl::OUString&, FILE*, 
const psp::JobData&, bool, const rtl::OUString&)’:
    vcl/unx/generic/printer/cpdmgr.cxx:695:15: note: call to ‘int 
fclose(FILE*)’ here
      695 |         fclose( pFile );
          |         ~~~~~~^~~~~~~~~
    
    Change-Id: Ib035f2287649dcf9a2d37bda85ebcf52c6c51aaa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134739
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 02ebfb8ed6175934a1985786e6816ecef1bd59f8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134632
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/unx/generic/printer/cpdmgr.cxx 
b/vcl/unx/generic/printer/cpdmgr.cxx
index 0a830a7e13c0..fdee9d5b70d6 100644
--- a/vcl/unx/generic/printer/cpdmgr.cxx
+++ b/vcl/unx/generic/printer/cpdmgr.cxx
@@ -722,7 +722,7 @@ bool CPDManager::endSpool( const OUString& rPrintername, 
const OUString& rJobTit
         }
         g_variant_unref(ret);
         unlink( it->second.getStr() );
-        m_aSpoolFiles.erase( pFile );
+        m_aSpoolFiles.erase(it);
     }
 #else
     (void)rPrintername;
diff --git a/vcl/unx/generic/printer/cupsmgr.cxx 
b/vcl/unx/generic/printer/cupsmgr.cxx
index 5c7fb3013e73..4afb2d87617e 100644
--- a/vcl/unx/generic/printer/cupsmgr.cxx
+++ b/vcl/unx/generic/printer/cupsmgr.cxx
@@ -882,7 +882,7 @@ bool CUPSManager::endSpool( const OUString& rPrintername, 
const OUString& rJobTi
 #endif
 
         unlink( it->second.getStr() );
-        m_aSpoolFiles.erase( pFile );
+        m_aSpoolFiles.erase(it);
         if( pOptions )
             cupsFreeOptions( nNumOptions, pOptions );
     }
commit aedb46961795bebf90aaecfbcc08650878f65569
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri May 20 16:01:57 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:02 2022 +0200

    sw: avoid ~SwIndexReg() assert in SwFEShell::PastePages()
    
    Change-Id: I5337dc8568255a778d29b676a39c99f72c42486b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134693
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 1b8c42f8b007d690a85676f260b28b44639fc79a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134777
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index b7a12a828b90..a907e0e838a0 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1133,7 +1133,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, 
sal_uInt16 nStartPage, sal_uInt1
         return;
     }
     MovePage( GetThisFrame, GetFirstSub );
-    SwPaM aCpyPam( *GetCursor()->GetPoint() );
+    ::std::optional<SwPaM> oSourcePam( *GetCursor()->GetPoint() );
     OUString sStartingPageDesc = GetPageDesc( GetCurPageDesc()).GetName();
     SwPageDesc* pDesc = rToFill.FindPageDescByName( sStartingPageDesc, true );
     if( pDesc )
@@ -1145,7 +1145,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, 
sal_uInt16 nStartPage, sal_uInt1
         return;
     }
     //if the page starts with a table a paragraph has to be inserted before
-    SwNode* pTableNode = aCpyPam.GetNode().FindTableNode();
+    SwNode *const pTableNode = oSourcePam->GetNode().FindTableNode();
     if(pTableNode)
     {
         //insert a paragraph
@@ -1155,22 +1155,23 @@ void SwFEShell::PastePages( SwFEShell& rToFill, 
sal_uInt16 nStartPage, sal_uInt1
         if(GetDoc()->getIDocumentContentOperations().AppendTextNode( aBefore ))
         {
             SwPaM aTmp(aBefore);
-            aCpyPam = aTmp;
+            *oSourcePam = aTmp;
         }
         EndUndo(SwUndoId::INSERT);
     }
 
     MovePage( GetThisFrame, GetLastSub );
-    aCpyPam.SetMark();
-    *aCpyPam.GetMark() = *GetCursor()->GetPoint();
+    oSourcePam->SetMark();
+    *oSourcePam->GetMark() = *GetCursor()->GetPoint();
 
     CurrShell aCurr( this );
 
     StartAllAction();
     GetDoc()->getIDocumentFieldsAccess().LockExpFields();
-    SetSelection(aCpyPam);
+    SetSelection(*oSourcePam);
     // copy the text of the selection
     SwEditShell::Copy(rToFill);
+    oSourcePam.reset(); // delete it because Undo will remove its node!
 
     if(pTableNode)
     {
commit e16c8134c119f899150bf8286d25df89be0b8621
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri May 20 20:56:56 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:02 2022 +0200

    sw: copy grab bags in mail merge
    
    Otherwise formatting may get lost when the result is stored as DOCX.
    
    Change-Id: I62cbeb1fc9f120dd9c424daf5dc0471686715537
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134694
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 123d3a9301c90925c23cfb4806d7b0be01b975d6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134762
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/qa/extras/mailmerge/data/grabbagtest.docx 
b/sw/qa/extras/mailmerge/data/grabbagtest.docx
new file mode 100644
index 000000000000..4b40f1fb4e94
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/grabbagtest.docx differ
diff --git a/sw/qa/extras/mailmerge/data/onecell.xlsx 
b/sw/qa/extras/mailmerge/data/onecell.xlsx
new file mode 100644
index 000000000000..972f6b3c5fc5
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/onecell.xlsx differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx 
b/sw/qa/extras/mailmerge/mailmerge.cxx
index e1fee48d74da..663d04f0afbe 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -16,7 +16,9 @@
 
 #include <com/sun/star/text/MailMergeType.hpp>
 #include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/sdbc/XRowSet.hpp>
 #include <com/sun/star/sdbcx/XRowLocate.hpp>
 #include <com/sun/star/task/XJob.hpp>
@@ -77,7 +79,7 @@ public:
      * calling executeMailMerge() after modifying the job arguments.
      */
     void executeMailMergeTest( const char* filename, const char* datasource, 
const char* tablename,
-                               bool file, int selection, const char* column )
+                               char const*const filter, int selection, const 
char* column )
     {
         maMMtestFilename = filename;
         header();
@@ -89,7 +91,7 @@ public:
         const OUString aURI( m_directories.getURLFromSrc(mpTestDocumentPath) + 
OUString::createFromAscii(datasource) );
         const OUString aPrefix = column ? OUString::createFromAscii( column ) 
: "LOMM_";
         const OUString aDBName = registerDBsource( aURI, aWorkDir );
-        initMailMergeJobAndArgs( filename, tablename, aDBName, aPrefix, 
aWorkDir, file, selection, column != nullptr );
+        initMailMergeJobAndArgs( filename, tablename, aDBName, aPrefix, 
aWorkDir, filter, selection, column != nullptr );
 
         verify();
         finish();
@@ -138,7 +140,8 @@ public:
     }
 
     void initMailMergeJobAndArgs( const char* filename, const char* tablename, 
const OUString &aDBName,
-                                  const OUString &aPrefix, const OUString 
&aWorkDir, bool file, int nDataSets,
+                                  const OUString &aPrefix, const OUString 
&aWorkDir,
+                                  char const*const filter, int nDataSets,
                                   const bool bPrefixIsColumn )
     {
         uno::Reference< task::XJob > xJob( 
getMultiServiceFactory()->createInstance( "com.sun.star.text.MailMerge" ), 
uno::UNO_QUERY_THROW );
@@ -146,13 +149,16 @@ public:
 
         mMMargs.reserve( 15 );
 
-        mMMargs.emplace_back( UNO_NAME_OUTPUT_TYPE, uno::Any( file ? 
text::MailMergeType::FILE : text::MailMergeType::SHELL ) );
+        mMMargs.emplace_back( UNO_NAME_OUTPUT_TYPE, uno::Any( filter ? 
text::MailMergeType::FILE : text::MailMergeType::SHELL ) );
         mMMargs.emplace_back( UNO_NAME_DOCUMENT_URL, uno::Any(
                                          ( OUString( 
m_directories.getURLFromSrc(mpTestDocumentPath) + 
OUString::createFromAscii(filename)) ) ) );
         mMMargs.emplace_back( UNO_NAME_DATA_SOURCE_NAME, uno::Any( aDBName ) );
         mMMargs.emplace_back( UNO_NAME_OUTPUT_URL, uno::Any( aWorkDir ) );
-        if (file)
+        if (filter)
+        {
             mMMargs.emplace_back( UNO_NAME_FILE_NAME_PREFIX, uno::Any( aPrefix 
) );
+            mMMargs.emplace_back(UNO_NAME_SAVE_FILTER, 
uno::Any(OUString::createFromAscii(filter)));
+        }
 
         if (bPrefixIsColumn)
             mMMargs.emplace_back( UNO_NAME_FILE_NAME_FROM_COLUMN, uno::Any( 
true ) );
@@ -256,7 +262,7 @@ public:
     /**
      Loads number-th document from mail merge. Requires file output from mail 
merge.
     */
-    void loadMailMergeDocument( int number )
+    void loadMailMergeDocument(int number, char const*const ext = ".odt")
     {
         OUString name;
         if (!msMailMergeOutputPrefix.isEmpty())
@@ -268,7 +274,7 @@ public:
             aURLObj.SetSmartURL( msMailMergeDocumentURL );
             name = aURLObj.GetBase();
         }
-        name += OUString::number( number ) + ".odt";
+        name += OUString::number(number) + 
OStringToOUString(std::string_view(ext, strlen(ext)), 
RTL_TEXTENCODING_ASCII_US);
         loadMailMergeDocument( name );
     }
 
@@ -298,7 +304,7 @@ protected:
     const char* maMMtestFilename;
 };
 
-#define DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, 
file, BaseClass, selection, column) \
+#define DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, 
filter, BaseClass, selection, column) \
     class TestName : public BaseClass { \
     protected: \
         virtual OUString getTestName() override { return #TestName; } \
@@ -308,7 +314,7 @@ protected:
         CPPUNIT_TEST_SUITE_END(); \
     \
         void MailMerge() { \
-            executeMailMergeTest(filename, datasource, tablename, file, 
selection, column); \
+            executeMailMergeTest(filename, datasource, tablename, filter, 
selection, column); \
         } \
         void verify() override; \
     }; \
@@ -317,17 +323,17 @@ protected:
 
 // Will generate the resulting document in mxMMDocument.
 #define DECLARE_SHELL_MAILMERGE_TEST(TestName, filename, datasource, 
tablename) \
-    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, false, 
MMTest, 0, nullptr)
+    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, nullptr, 
MMTest, 0, nullptr)
 
 // Will generate documents as files, use loadMailMergeDocument().
 #define DECLARE_FILE_MAILMERGE_TEST(TestName, filename, datasource, tablename) 
\
-    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, true, 
MMTest, 0, nullptr)
+    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, 
"writer8", MMTest, 0, nullptr)
 
 #define DECLARE_SHELL_MAILMERGE_TEST_SELECTION(TestName, filename, datasource, 
tablename, selection) \
-    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, false, 
MMTest, selection, nullptr)
+    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, nullptr, 
MMTest, selection, nullptr)
 
 #define DECLARE_FILE_MAILMERGE_TEST_COLUMN(TestName, filename, datasource, 
tablename, column) \
-    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, true, 
MMTest, 0, column)
+    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, 
"writer8", MMTest, 0, column)
 
 int MMTest::documentStartPageNumber( int document ) const
 {   // See documentStartPageNumber() .
@@ -1292,5 +1298,65 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf128148, 
"tdf128148.odt", "4_v01.ods", "Tabel
     }
 }
 
+namespace com::sun::star::table {
+
+static std::ostream& operator<<(std::ostream& rStream, table::BorderLine 
const& rLine)
+{
+    rStream << "BorderLine(" << rLine.Color << "," << rLine.InnerLineWidth << 
"," << rLine.OuterLineWidth << "," << rLine.LineDistance << ")";
+    return rStream;
+}
+
+static std::ostream& operator<<(std::ostream& rStream, table::TableBorder 
const& rBorder)
+{
+    rStream << "TableBorder(\n  "
+        << rBorder.TopLine << "," << static_cast<bool>(rBorder.IsTopLineValid) 
<< ",\n  "
+        << rBorder.BottomLine << "," << 
static_cast<bool>(rBorder.IsBottomLineValid) << ",\n  "
+        << rBorder.LeftLine << "," << 
static_cast<bool>(rBorder.IsLeftLineValid) << ",\n  "
+        << rBorder.RightLine << "," << 
static_cast<bool>(rBorder.IsRightLineValid) << ",\n  "
+        << rBorder.HorizontalLine << "," << 
static_cast<bool>(rBorder.IsHorizontalLineValid) << ",\n  "
+        << rBorder.VerticalLine << "," << 
static_cast<bool>(rBorder.IsVerticalLineValid) << ",\n  "
+        << rBorder.Distance << "," << 
static_cast<bool>(rBorder.IsDistanceValid) << ")";
+    return rStream;
+}
+
+}
+
+DECLARE_MAILMERGE_TEST(testGrabBag, "grabbagtest.docx", "onecell.xlsx", 
"Sheet1", "MS Word 2007 XML", MMTest, 0, nullptr)
+{
+    executeMailMerge(true);
+
+    loadMailMergeDocument(0, ".docx");
+
+    SwXTextDocument *const pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), 
pTextDoc->GetDocShell()->GetWrtShell()->GetPhyPageNum());
+
+    // check grabbag
+    uno::Reference<beans::XPropertySet> const xModel(
+        mxComponent, uno::UNO_QUERY_THROW);
+    uno::Sequence<beans::PropertyValue> aInteropGrabBag;
+    pTextDoc->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(13), aInteropGrabBag.getLength());
+
+    // check table border - comes from table style "Tabellenraster"
+    uno::Reference<text::XTextTable> const xTable(getParagraphOrTable(1, 
pTextDoc->getText()), uno::UNO_QUERY_THROW);
+    uno::Reference<beans::XPropertySet> const xTableProps(xTable, 
uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_EQUAL(table::TableBorder(
+                table::BorderLine(util::Color(0), 0, 18, 0), true,
+                table::BorderLine(util::Color(0), 0, 18, 0), true,
+                table::BorderLine(util::Color(0), 0, 18, 0), true,
+                table::BorderLine(util::Color(0), 0, 18, 0), true,
+                table::BorderLine(util::Color(0), 0, 18, 0), true,
+                table::BorderLine(util::Color(0), 0, 0, 0), true,
+                sal_Int16(191), true),
+            getProperty<table::TableBorder>(xTableProps, "TableBorder"));
+
+    // check font is Arial - comes from theme (wrong result was "" - nothing)
+    uno::Reference<text::XText> const xCell(xTable->getCellByName("A1"), 
uno::UNO_QUERY_THROW);
+    uno::Reference<beans::XPropertySet> const xParaA1(getParagraphOrTable(1, 
xCell->getText()), uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xParaA1, 
"CharFontName"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 667cb4283207..7aa134edf841 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -29,6 +29,7 @@
 
 #include <doc.hxx>
 #include <proofreadingiterator.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
 #include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
 #include <com/sun/star/frame/XModel.hpp>
@@ -909,6 +910,14 @@ SfxObjectShell* SwDoc::CreateCopy( bool bCallInitNew, bool 
bEmpty ) const
 
     xRet->ReplaceStyles(*this);
 
+    uno::Reference<beans::XPropertySet> const xThisSet(
+        GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW);
+    uno::Reference<beans::XPropertySet> const xRetSet(
+        pRetShell->GetBaseModel(), uno::UNO_QUERY_THROW);
+    uno::Sequence<beans::PropertyValue> aInteropGrabBag;
+    xThisSet->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag;
+    xRetSet->setPropertyValue("InteropGrabBag", uno::Any(aInteropGrabBag));
+
     if( !bEmpty )
     {
 #ifdef DBG_UTIL
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx 
b/sw/source/ui/dbui/mmresultdialogs.cxx
index e801329df5a6..0699b93e3638 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -685,6 +685,14 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, 
weld::Button&, void)
             pTempView->GetDocShell()->GetDoc()->ReplaceDefaults( 
*pTargetView->GetDocShell()->GetDoc());
             pTempView->GetDocShell()->GetDoc()->ReplaceDocumentProperties( 
*pTargetView->GetDocShell()->GetDoc(), true );
 
+            uno::Reference<beans::XPropertySet> const xThisSet(
+                pTargetView->GetDocShell()->GetBaseModel(), 
uno::UNO_QUERY_THROW);
+            uno::Reference<beans::XPropertySet> const xRetSet(
+                pTempView->GetDocShell()->GetBaseModel(), 
uno::UNO_QUERY_THROW);
+            uno::Sequence<beans::PropertyValue> aInteropGrabBag;
+            xThisSet->getPropertyValue("InteropGrabBag") >>= aInteropGrabBag;
+            xRetSet->setPropertyValue("InteropGrabBag", 
uno::Any(aInteropGrabBag));
+
             pTargetView->GetWrtShell().PastePages(
                 pTempView->GetWrtShell(), 
documentStartPageNumber(xConfigItem.get(), nDoc, false),
                 documentEndPageNumber(xConfigItem.get(), nDoc, false));
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 9232d4938e95..cedf32e752a6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -378,6 +378,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, 
"asciiTheme", ThemeTable::getStringForTheme(nIntValue));
             if (m_pImpl->GetTopContext())
             {
+                // note: overwrite Fonts_ascii with Fonts_asciiTheme *even if*
+                // theme font is empty - this is apparently what Word 2013 does
                 uno::Any aPropValue = uno::makeAny( 
m_pImpl->GetThemeTable()->getFontNameForTheme( nIntValue ) );
                 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, 
aPropValue );
                 
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_FONT_NAME_ASCII, aPropValue, 
true, CHAR_GRAB_BAG );
commit f55db56fcd1453fbdda4c0781c11c16fb1fb12c9
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Mon May 23 15:35:57 2022 -0800
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:02 2022 +0200

    tdf#149231 Fix crash on print preview of master
    
    caused by commit 1f9a792a391f0811bbb5f570ad5c84d13312c539.
    
    Change-Id: Iecfa019b04b84bb70b5e04af51f9f786d7cd9fdf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134846
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>
    (cherry picked from commit f817b3de1aa827d93e2a622735c4d570514f4849)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134788
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/uibase/utlui/glbltree.cxx 
b/sw/source/uibase/utlui/glbltree.cxx
index d658a6db7271..45a03e537216 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -773,7 +773,8 @@ void 
SwGlobalTree::ExecuteContextMenuAction(std::string_view rSelectedPopupEntry
 
 IMPL_LINK_NOARG(SwGlobalTree, Timeout, Timer *, void)
 {
-    if (m_pActiveShell && m_pActiveShell->GetView().GetEditWin().HasFocus())
+    SwView* pView = GetParentWindow()->GetCreateView();
+    if (pView && pView->GetEditWin().HasFocus())
     {
         if (Update(false))
             Display();
@@ -877,14 +878,13 @@ bool SwGlobalTree::Update(bool bHard)
     bool bRet = false;
     if (pActView && pActView->GetWrtShellPtr())
     {
-        SwWrtShell* pOldShell = m_pActiveShell;
+        const SwWrtShell* pOldShell = m_pActiveShell;
         m_pActiveShell = pActView->GetWrtShellPtr();
         if(m_pActiveShell != pOldShell)
         {
-            if (pOldShell)
-                EndListening(*pOldShell->GetView().GetDocShell());
-            StartListening(*m_pActiveShell->GetView().GetDocShell());
             m_pSwGlblDocContents.reset();
+            if (!IsListening(*m_pActiveShell->GetView().GetDocShell()))
+                StartListening(*m_pActiveShell->GetView().GetDocShell());
         }
         if(!m_pSwGlblDocContents)
         {
commit 18fee6b77d7fc3f90f399013c04972642bce0a46
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri May 20 15:46:20 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:02 2022 +0200

    sw_redlinehide: fix crash in IsMarkHidden() if pointing to table node
    
    This is called during mail merge from documentStartPageNumber()
    and if the document starts with a table, the passed UNO mark will point
    to SwTableNode.
    
    (regression from commit 943d9be770e550d20ca72274fa5e914d1f61e605)
    
    Change-Id: Ic69c12ba0d819eda85de5dde95e35a8071466c2e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134692
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 4d3b750d08d05c475fb38f8b3961696d9cc9882f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134776
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index 9e2027a2ceba..02f554014568 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -128,9 +128,14 @@ bool IsMarkHidden(SwRootFrame const& rLayout, 
::sw::mark::IMark const& rMark)
     {
         return false;
     }
-    SwTextNode const& rNode(*rMark.GetMarkPos().nNode.GetNode().GetTextNode());
+    SwNode const& rNode(rMark.GetMarkPos().nNode.GetNode());
+    SwTextNode const*const pTextNode(rNode.GetTextNode());
+    if (pTextNode == nullptr)
+    {   // UNO_BOOKMARK may point to table node
+        return rNode.GetRedlineMergeFlag() == SwNode::Merge::Hidden;
+    }
     SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
-        rNode.getLayoutFrame(&rLayout)));
+        pTextNode->getLayoutFrame(&rLayout)));
     if (!pFrame)
     {
         return true;
@@ -145,14 +150,14 @@ bool IsMarkHidden(SwRootFrame const& rLayout, 
::sw::mark::IMark const& rMark)
     }
     else
     {
-        if (rMark.GetMarkPos().nContent.GetIndex() == rNode.Len())
+        if (rMark.GetMarkPos().nContent.GetIndex() == pTextNode->Len())
         {   // at end of node: never deleted (except if node deleted)
-            return rNode.GetRedlineMergeFlag() == SwNode::Merge::Hidden;
+            return pTextNode->GetRedlineMergeFlag() == SwNode::Merge::Hidden;
         }
         else
         {   // check character following mark pos
             return pFrame->MapModelToViewPos(rMark.GetMarkPos())
-                == pFrame->MapModelToView(&rNode, 
rMark.GetMarkPos().nContent.GetIndex() + 1);
+                == pFrame->MapModelToView(pTextNode, 
rMark.GetMarkPos().nContent.GetIndex() + 1);
         }
     }
 }
commit bc076c09f3693ee3790f294bf9be4827d6f9c4a6
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Sun May 22 14:50:55 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:02 2022 +0200

    starmath: fix real use-after-free detected by GCC 12
    
    In file included from starmath/inc/mathml/iterator.hxx:12,
                     from starmath/source/mathml/iterator.cxx:10:
    In member function ‘SmMlElement* SmMlElement::getParentElement()’,
        inlined from ‘void mathml::SmMlIteratorBottomToTop(SmMlElement*, 
runType, void*) [with runType = void (*)(SmMlElement*, void*)]’ at 
starmath/inc/mathml/iterator.hxx:43:39,
        inlined from ‘void mathml::SmMlIteratorFree(SmMlElement*)’ at 
starmath/source/mathml/iterator.cxx:57:28:
    starmath/inc/mathml/element.hxx:263:46: error: pointer ‘pCurrent’ used 
after ‘void operator delete(void*, std::size_t)’ [-Werror=use-after-free]
      263 |     SmMlElement* getParentElement() { return m_aParentElement; };
          |                                              ^~~~~~~~~~~~~~~~
    In function ‘void mathml::deleteElement(SmMlElement*, void*)’,
        inlined from ‘void mathml::deleteElement(SmMlElement*, void*)’ at 
starmath/source/mathml/iterator.cxx:19:20,
        inlined from ‘void mathml::SmMlIteratorBottomToTop(SmMlElement*, 
runType, void*) [with runType = void (*)(SmMlElement*, void*)]’ at 
starmath/inc/mathml/iterator.hxx:65:21,
        inlined from ‘void mathml::SmMlIteratorFree(SmMlElement*)’ at 
starmath/source/mathml/iterator.cxx:57:28:
    starmath/source/mathml/iterator.cxx:19:77: note: call to ‘void operator 
delete(void*, std::size_t)’ here
       19 | static inline void deleteElement(SmMlElement* aSmMlElement, void*) 
{ delete aSmMlElement; }
          |                                                                     
        ^~~~~~~~~~~~
    
    Change-Id: I09acfe3f7e90bd7f919cfba161f72bdd7a8da70a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134742
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 32c43ee75c094ffe3c34f7a713aa252479515ad0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134775
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/starmath/source/mathml/iterator.cxx 
b/starmath/source/mathml/iterator.cxx
index 481ff799689c..489cbe8ebc05 100644
--- a/starmath/source/mathml/iterator.cxx
+++ b/starmath/source/mathml/iterator.cxx
@@ -56,7 +56,11 @@ void SmMlIteratorFree(SmMlElement* pMlElementTree)
 {
     if (pMlElementTree == nullptr)
         return;
-    SmMlIteratorBottomToTop(pMlElementTree, deleteElement, nullptr);
+    for (size_t i = 0; i < pMlElementTree->getSubElementsCount(); ++i)
+    {
+        SmMlIteratorFree(pMlElementTree->getSubElement(i));
+    }
+    deleteElement(pMlElementTree, nullptr);
 }
 
 SmMlElement* SmMlIteratorCopy(SmMlElement* pMlElementTree)
commit e2f3bc3a98cd65183b5d0580c0fb742240fc376a
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Sun May 22 12:26:48 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:02 2022 +0200

    svl: spurious GCC12 -Werror=maybe-uninitialized
    
    In file included from svl/source/misc/sharedstringpool.cxx:11:
    In constructor ‘svl::SharedString::SharedString(rtl_uString*, 
rtl_uString*)’,
        inlined from ‘svl::SharedString svl::SharedStringPool::intern(const 
rtl::OUString&)’ at svl/source/misc/sharedstringpool.cxx:129:51:
    include/svl/sharedstring.hxx:56:20: error: ‘pResultUpper’ may be used 
uninitialized [-Werror=maybe-uninitialized]
       56 |     mpData(pData), mpDataIgnoreCase(pDataIgnoreCase)
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    svl/source/misc/sharedstringpool.cxx: In member function ‘svl::SharedString 
svl::SharedStringPool::intern(const rtl::OUString&)’:
    svl/source/misc/sharedstringpool.cxx:93:33: note: ‘pResultUpper’ was 
declared here
       93 |     rtl_uString *pResultLower, *pResultUpper;
          |                                 ^~~~~~~~~~~~
    
    Change-Id: I2171855844c76ad3b2a72c1eca737691ca96fc46
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134736
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 694db7d3e7be0caf81dd52dba1a865db206ac145)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134629
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/svl/source/misc/sharedstringpool.cxx 
b/svl/source/misc/sharedstringpool.cxx
index 7abe3ea77507..d88b0a2c22ef 100644
--- a/svl/source/misc/sharedstringpool.cxx
+++ b/svl/source/misc/sharedstringpool.cxx
@@ -92,7 +92,7 @@ SharedString SharedStringPool::intern(const OUString& rStr)
 {
     auto& rMap = mpImpl->maStrMap;
 
-    rtl_uString *pResultLower, *pResultUpper;
+    rtl_uString *pResultLower = {}, *pResultUpper = {}; // bogus GCC 12 
-Werror=maybe-uninitialized
     if (rMap.find_fn(rStr.pData, [&](const Mapped& rMapped) {
             pResultLower = rMapped.first.pData;
             pResultUpper = rMapped.second.pData;
commit f7aa9bc789ccaf6223e20a6fecd81ecd43b6740d
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Tue Mar 15 12:17:30 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:01 2022 +0200

    tdf#149202 Allow for java.version consisting of four dotted segments
    
    ...like "11.0.14.1" reported now by
    java-11-openjdk-headless-11.0.14.1.1-5.fc35.x86_64, and which caused
    
    > warn:jfw:274674:274674:jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx:100: 
[Java framework] sunjavaplugin.so does not know the version: 11.0.14.1 as valid 
for a SUN/Oracle JRE.
    
    (For simplicity, cover it with the same code block that already covers a
    potential "_01" etc. part following the official(?) three dotted segments.)
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131586
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>
    (cherry picked from commit 8e6462571bb4cb872f607b4ac9dfde7f43b79ac3)
    
    Change-Id: Id98235d3be59653ab412f9b6c1ffbf3b0470bd6f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134820
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx 
b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
index 49157f033616..45ce0e1b8272 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
@@ -71,8 +71,8 @@ bool SunVersion::init(const char *szVersion)
                 //separators after maintenance (1.4.1_01, 1.4.1-beta, or 1.4.1)
                 (pCur == pEnd || *pCur == '_' || *pCur == '-')
                 ||
-                //separators between major-minor and minor-maintenance
-                (nPart < 2 && *pCur == '.') )
+                //separators between major-minor and minor-maintenance (or 
fourth segment)
+                (nPart < 3 && *pCur == '.') )
             && (
                 //prevent 1.4.0. 1.4.0-
                 pCur + 1 != pEnd
@@ -112,10 +112,10 @@ bool SunVersion::init(const char *szVersion)
     }
     if (pCur >= pEnd)
         return true;
-    //We have now 1.4.1. This can be followed by _01, -beta, etc.
+    //We have now 1.4.1. This can be followed by _01 (or a fourth segment .1), 
-beta, etc.
     // _01 (update) According to docu must not be followed by any other
     //characters, but on Solaris 9 we have a 1.4.1_01a!!
-    if (* (pCur - 1) == '_')
+    if (* (pCur - 1) == '_' || *(pCur - 1) == '.')
     {// _01, _02
         // update is the last part _01, _01a, part 0 is the digits parts and 1 
the trailing alpha
         while (true)
commit 3907f5392dbf04b219639bff624f8386cb13d2cb
Author:     Hossein <hoss...@libreoffice.org>
AuthorDate: Fri May 20 15:20:40 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:01 2022 +0200

    tdf#149184 DOCX: fix crash removing footer, then saving to doc
    
    When openeing the simplefooter.docx, after removing the footer and
    exporting to .doc, LibreOffice crashes. This regression was
    introduced with 88e6a1bfeac86e0c89d2ff08c908c2b5ae061177 which is
    titled: "DOCX: export hidden (shared) headers/footers".
    
    The current patch fixes this problem by checking to see if the header
    or footer text is there or not.
    
    A unit test is added to avoid this problem in the future. One can run
    the test with:
    
        make CPPUNIT_TEST_NAME="testTdf149184" -sr CppunitTest_sw_uiwriter7
    
    Change-Id: I5586561677b3c490e49b4b10bd987aecdf3fc134
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134684
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134829

diff --git a/sw/qa/extras/uiwriter/data/simplefooter.docx 
b/sw/qa/extras/uiwriter/data/simplefooter.docx
new file mode 100644
index 000000000000..006c85ab7cc8
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/simplefooter.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index b7593759971b..0aea38d4bbe7 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -50,6 +50,7 @@
 #include <com/sun/star/awt/FontUnderline.hpp>
 #include <vcl/TypeSerializer.hxx>
 
+#include <svx/hdft.hxx>
 #include <svx/svdpage.hxx>
 #include <svx/svdview.hxx>
 #include <svl/itemiter.hxx>
@@ -290,6 +291,7 @@ public:
     void testTdf92648();
     void testTdf103978_backgroundTextShape();
     void testTdf117225();
+    void testTdf149184();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -411,6 +413,7 @@ public:
     CPPUNIT_TEST(testTdf92648);
     CPPUNIT_TEST(testTdf103978_backgroundTextShape);
     CPPUNIT_TEST(testTdf117225);
+    CPPUNIT_TEST(testTdf149184);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4691,6 +4694,25 @@ void SwUiWriterTest::testTdf117225()
     CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
 }
 
+void SwUiWriterTest::testTdf149184()
+{
+    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "simplefooter.docx");
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    // Removing the footer for all styles
+    pWrtShell->ChangeHeaderOrFooter(u"", false, false, false);
+    // export to simplefooter.doc
+    uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aStoreProps = 
comphelper::InitPropertySequence({
+        { "FilterName", uno::Any(OUString("MS Word 97")) },
+    });
+    utl::TempFile aTempFile;
+    aTempFile.EnableKillingFile();
+    // Without the fix in place, the test fails with:
+    // [CUT] sw_uiwriter7
+    // Segmentation fault (core dumped)
+    // [_RUN_____] testTdf149184::TestBody
+    xStorable->storeToURL(aTempFile.GetURL(), aStoreProps);
+}
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx 
b/sw/source/filter/ww8/wrtw8sty.cxx
index 9f103627d576..4126b9f88a50 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -2087,6 +2087,10 @@ void MSWordExportBase::WriteHeaderFooterText( const 
SwFormat& rFormat, bool bHea
         m_bHasHdr = true;
         const SwFormatHeader& rHd = rFormat.GetHeader();
         OSL_ENSURE( rHd.GetHeaderFormat(), "Header text is not here" );
+
+        if ( !rHd.GetHeaderFormat() )
+            return;
+
         pContent = &rHd.GetHeaderFormat()->GetContent();
     }
     else
@@ -2094,6 +2098,10 @@ void MSWordExportBase::WriteHeaderFooterText( const 
SwFormat& rFormat, bool bHea
         m_bHasFtr = true;
         const SwFormatFooter& rFt = rFormat.GetFooter();
         OSL_ENSURE( rFt.GetFooterFormat(), "Footer text is not here" );
+
+        if ( !rFt.GetFooterFormat() )
+            return;
+
         pContent = &rFt.GetFooterFormat()->GetContent();
     }
 
commit e4032e96e14b96f267238314b2e66196c315085b
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Mon May 23 10:08:08 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:01 2022 +0200

    tdf#149198 Fix use of nullptr
    
    ...which would have caused std::abort for non-production debug builds since
    4f0c70fb5554325e0cc2129741175bf07de22029 "Avoid calling OString ctor with 
null
    pointer", and started to erroneously pass a nullptr argument into a
    std::string_view for all kinds of builds with
    af16aa625682b649e8843237652b9246d519cbae "Improve loplugin:stringview"
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134758
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>
    (cherry picked from commit c8d4ae2ad0cfdac770d897e7aca72fbb4a87765f, plus
    follow-up f546767b4e9bf3de288ea50336cf1e15f1ee7435 "tdf#149198 Fix previous
    fix")
    
    Change-Id: Iad4d1576ed651a74c0f8b2e8dee3c59f5214accd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134780
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index ea8ca12f3dc2..7e30ec38e1ac 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3144,7 +3144,7 @@ void DocxAttributeOutput::WriteCollectedRunProperties()
     {
         const char* pVal = nullptr;
         m_pColorAttrList->getAsChar(FSNS(XML_w, XML_val), pVal);
-        if (std::string_view("auto") != pVal)
+        if (pVal == nullptr || std::string_view("auto") != pVal)
         {
             m_pSerializer->startElementNS(XML_w14, XML_textFill);
             m_pSerializer->startElementNS(XML_w14, XML_solidFill);
commit 08a142ae6b010fd2f71a36015446abd3af37301a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun May 15 16:07:57 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:01 2022 +0200

    tdf#149068 reject OpenGL versions that don't support glGenVertexArrays
    
    use a throwaway toplevel to figure that out, because if the current
    window is used then gtk will always call glGenVertexArrays on it due
    to the creation of a GLContext which is the problem we want to avoid.
    
    Change-Id: I40ccc48b5ed2d9fd99d3c242244847c8448c3803
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134350
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit da50382b366d6f3de778d8a52136cd812ef5b751)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134628
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index e29a1bfb77f3..4008e98baf0a 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -1960,8 +1960,53 @@ private:
         glViewport(0, 0, width, height);
     }
 
+    // Use a throw away toplevel to determine the OpenGL version because once
+    // an GdkGLContext is created for a window then it seems that
+    // glGenVertexArrays will always be called when the window gets rendered.
+    static int GetOpenGLVersion()
+    {
+        int nMajorGLVersion(0);
+
+        GtkWidget* pWindow;
+#if !GTK_CHECK_VERSION(4,0,0)
+        pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#else
+        pWindow = gtk_window_new();
+#endif
+
+        gtk_widget_realize(pWindow);
+
+        if (GdkSurface* pSurface = widget_get_surface(pWindow))
+        {
+            if (GdkGLContext* pContext = surface_create_gl_context(pSurface))
+            {
+                if (gdk_gl_context_realize(pContext, nullptr))
+                {
+                    gdk_gl_context_make_current(pContext);
+                    gdk_gl_context_get_version(pContext, &nMajorGLVersion, 
nullptr);
+                    gdk_gl_context_clear_current();
+                }
+                g_object_unref(pContext);
+            }
+        }
+
+#if !GTK_CHECK_VERSION(4,0,0)
+        gtk_widget_destroy(pWindow);
+#else
+        gtk_window_destroy(GTK_WINDOW(pWindow));
+#endif
+        return nMajorGLVersion;
+    }
+
     virtual bool ImplInit() override
     {
+        static int nOpenGLVersion = GetOpenGLVersion();
+        if (nOpenGLVersion < 3)
+        {
+            SAL_WARN("vcl.gtk", "gtk GL requires glGenVertexArrays which is 
OpenGL 3, while system provides: " << nOpenGLVersion);
+            return false;
+        }
+
         const SystemEnvData* pEnvData = m_pChildWindow->GetSystemData();
         GtkWidget *pParent = static_cast<GtkWidget*>(pEnvData->pWidget);
         m_pGLArea = gtk_gl_area_new();
commit cc44715a1e7501f6d57a89937f6880dbb467c21e
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri May 20 11:49:44 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:01 2022 +0200

    vcl: avoid EXCEPTION_INT_DIVIDE_BY_ZERO
    
    See 
https://crashreport.libreoffice.org/stats/signature/FormattedField::Down()
    or https://crashreport.libreoffice.org/stats/signature/FormattedField::Up()
    
    Change-Id: I30dfb06a1261a48a75b9d9c2380ed78121758ec2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134674
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit ce39195e533336ce1482e2be6b1bec2b7f992125)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134627

diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index 326ba7f7ef3e..a0d96dd9caae 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -1183,7 +1183,7 @@ void FormattedField::Up()
 
     sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
     sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
-    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() ? 0 : nValue 
% nSpinSize;
+    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() || nSpinSize 
== 0 ? 0 : nValue % nSpinSize;
     if (nValue >= 0)
         nValue = (nRemainder == 0) ? nValue + nSpinSize : nValue + nSpinSize - 
nRemainder;
     else
@@ -1204,7 +1204,7 @@ void FormattedField::Down()
 
     sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
     sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
-    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() ? 0 : nValue 
% nSpinSize;
+    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() || nSpinSize 
== 0 ? 0 : nValue % nSpinSize;
     if (nValue >= 0)
         nValue = (nRemainder == 0) ? nValue - nSpinSize : nValue - nRemainder;
     else
commit 6eee9a22d1b6512242aacf675e141d33e2bc9670
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu May 19 09:34:16 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:00 2022 +0200

    follow org.freedesktop.appearance.color-scheme setting
    
    Change-Id: Id26d01fd19cc3ee12c0e14b785b3a5149d22baf5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134634
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index ced3613ad0ca..c90afbdee899 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -185,6 +185,8 @@ class GtkSalFrame final : public SalFrame
     GtkEventControllerKey*          m_pKeyController;
     gulong                          m_nSettingChangedSignalId;
 #endif
+    gulong                          m_nPortalSettingChangedSignalId;
+    GDBusProxy*                     m_pSettingsPortal;
 #if !GTK_CHECK_VERSION(4, 0, 0)
     GdkWindow*                      m_pForeignParent;
     GdkNativeWindow                 m_aForeignParentWindow;
@@ -412,6 +414,8 @@ class GtkSalFrame final : public SalFrame
 
     bool HandleMenubarMnemonic(guint eState, guint nKeyval);
 
+    void ListenPortalSettings();
+
 public:
     cairo_surface_t*                m_pSurface;
     basegfx::B2IVector              m_aFrameSize;
@@ -633,6 +637,8 @@ public:
 
     const cairo_font_options_t* get_font_options();
 
+    void SetColorScheme(GVariant* variant);
+
     void DisallowCycleFocusOut();
     bool IsCycleFocusOutDisallowed() const;
     void AllowCycleFocusOut();
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index c6fb8ac14ac1..7108f9206380 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -76,6 +76,12 @@ int GtkSalFrame::m_nFloats = 0;
 
 static GDBusConnection* pSessionBus = nullptr;
 
+static void EnsureSessionBus()
+{
+    if (!pSessionBus)
+        pSessionBus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
+}
+
 sal_uInt16 GtkSalFrame::GetKeyModCode( guint state )
 {
     sal_uInt16 nCode = 0;
@@ -541,8 +547,7 @@ static void attach_menu_model(GtkSalFrame* pSalFrame)
 
 #if !GTK_CHECK_VERSION(4,0,0)
     // Get a DBus session connection.
-    if (!pSessionBus)
-        pSessionBus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr);
+    EnsureSessionBus();
     if (!pSessionBus)
         return;
 
@@ -629,13 +634,9 @@ void GtkSalFrame::EnsureAppMenuWatch()
         return;
 
     // Get a DBus session connection.
-    if ( pSessionBus == nullptr )
-    {
-        pSessionBus = g_bus_get_sync( G_BUS_TYPE_SESSION, nullptr, nullptr );
-
-        if ( pSessionBus == nullptr )
-            return;
-    }
+    EnsureSessionBus();
+    if (!pSessionBus)
+        return;
 
     // Publish the menu only if AppMenu registrar is available.
     m_nWatcherId = g_bus_watch_name_on_connection( pSessionBus,
@@ -698,8 +699,14 @@ GtkSalFrame::~GtkSalFrame()
     {
         SolarMutexGuard aGuard;
 
-        if(m_nWatcherId)
+        if (m_nWatcherId)
             g_bus_unwatch_name(m_nWatcherId);
+
+        if (m_nPortalSettingChangedSignalId)
+            g_signal_handler_disconnect(m_pSettingsPortal, 
m_nPortalSettingChangedSignalId);
+
+        if (m_pSettingsPortal)
+            g_object_unref(m_pSettingsPortal);
     }
 
     GtkWidget *pEventWidget = getMouseEventWidget();
@@ -900,6 +907,8 @@ void GtkSalFrame::InitCommon()
     m_pSurface = nullptr;
     m_nGrabLevel = 0;
     m_bSalObjectSetPosSize = false;
+    m_nPortalSettingChangedSignalId = 0;
+    m_pSettingsPortal = nullptr;
 
     m_aDamageHandler.handle = this;
     m_aDamageHandler.damaged = ::damaged;
@@ -1243,6 +1252,91 @@ void GtkSalFrame::AllowCycleFocusOut()
 #endif
 }
 
+namespace
+{
+    enum ColorScheme
+    {
+        DEFAULT,
+        PREFER_DARK,
+        PREFER_LIGHT
+    };
+
+    bool ReadColorScheme(GDBusProxy* proxy, GVariant** out)
+    {
+        g_autoptr (GVariant) ret =
+            g_dbus_proxy_call_sync(proxy, "Read",
+                                   g_variant_new ("(ss)", 
"org.freedesktop.appearance", "color-scheme"),
+                                   G_DBUS_CALL_FLAGS_NONE, G_MAXINT, nullptr, 
nullptr);
+        if (!ret)
+            return false;
+
+        g_autoptr (GVariant) child = nullptr;
+        g_variant_get(ret, "(v)", &child);
+        g_variant_get(child, "v", out);
+
+        return true;
+    }
+}
+
+void GtkSalFrame::SetColorScheme(GVariant* variant)
+{
+    if (!m_pWindow)
+        return;
+
+    guint32 color_scheme = g_variant_get_uint32(variant);
+    if (color_scheme > PREFER_LIGHT)
+        color_scheme = DEFAULT;
+
+    bool bDarkIconTheme(color_scheme == PREFER_DARK);
+    GtkSettings* pSettings = gtk_widget_get_settings(m_pWindow);
+    g_object_set(pSettings, "gtk-application-prefer-dark-theme", 
bDarkIconTheme, nullptr);
+}
+
+static void settings_portal_changed_cb(GDBusProxy*, const char*, const char* 
signal_name,
+                                       GVariant* parameters, gpointer frame)
+{
+    if (g_strcmp0(signal_name, "SettingChanged"))
+        return;
+
+    g_autoptr (GVariant) value = nullptr;
+    const char *name_space;
+    const char *name;
+    g_variant_get(parameters, "(&s&sv)", &name_space, &name, &value);
+
+    if (g_strcmp0(name_space, "org.freedesktop.appearance") ||
+        g_strcmp0(name, "color-scheme"))
+      return;
+
+    GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+    pThis->SetColorScheme(value);
+}
+
+void GtkSalFrame::ListenPortalSettings()
+{
+    EnsureSessionBus();
+
+    if (!pSessionBus)
+        return;
+
+    m_pSettingsPortal = g_dbus_proxy_new_sync(pSessionBus,
+                                              G_DBUS_PROXY_FLAGS_NONE,
+                                              nullptr,
+                                              "org.freedesktop.portal.Desktop",
+                                              
"/org/freedesktop/portal/desktop",
+                                              
"org.freedesktop.portal.Settings",
+                                              nullptr,
+                                              nullptr);
+    if (!m_pSettingsPortal)
+        return;
+
+    g_autoptr (GVariant) value = nullptr;
+
+    if (!ReadColorScheme(m_pSettingsPortal, &value))
+        return;
+
+    SetColorScheme(value);
+    m_nPortalSettingChangedSignalId = g_signal_connect(m_pSettingsPortal, 
"g-signal", G_CALLBACK(settings_portal_changed_cb), this);
+}
 
 void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle )
 {
@@ -1403,6 +1497,9 @@ void GtkSalFrame::Init( SalFrame* pParent, 
SalFrameStyleFlags nStyle )
     {
         // Enable GMenuModel native menu
         attach_menu_model(this);
+
+        // Listen to portal settings for e.g. prefer dark theme
+        ListenPortalSettings();
     }
 }
 
commit bf9856c9d0fe4feba9df30a878e95d1e7fe494f1
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed May 18 18:25:07 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:00 2022 +0200

    svx: fix double-free if SvxShape of SwDrawVirtObj is disposed
    
    First SvxShape::dispose() deletes it, then ~SwDrawFrameFormat() via
    ~SwDrawContact() calls SwDrawContact::RemoveAllVirtObjs() and deletes it
    again.
    
    Back in 2009, CWS dba32 (60698c8a619f219129dbeac7da1f962f3fa63f6a)
    added this OSL_ENSURE, let's actually try to fix this now.
    
    Change-Id: I5c391aa425aa75fb87cecccbf9e41c9f90196f9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134609
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit 5eb25f6a7ecb215f7bc81116cd930c1dec645e8d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134621
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 98a104c49fc8..ee3e58dd0190 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -1286,10 +1286,6 @@ void SAL_CALL SvxShape::dispose()
 
     if ( pObject->IsInserted() && pObject->getSdrPageFromSdrObject() )
     {
-        OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below 
code correct?" );
-            // normally, we are allowed to free the SdrObject only if we have 
its ownership.
-            // Why isn't this checked here?
-
         SdrPage* pPage = pObject->getSdrPageFromSdrObject();
         // delete the SdrObject from the page
         const size_t nCount = pPage->GetObjCount();
@@ -1298,7 +1294,10 @@ void SAL_CALL SvxShape::dispose()
             if ( pPage->GetObj( nNum ) == pObject )
             {
                 OSL_VERIFY( pPage->RemoveObject( nNum ) == pObject );
-                bFreeSdrObject = true;
+                if (HasSdrObjectOwnership())
+                {
+                    bFreeSdrObject = true;
+                }
                 break;
             }
         }
commit e1ef17ca764d049917b32fbc3cd3bb7aa666ea93
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed May 18 18:31:14 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:00 2022 +0200

    sw_fieldmarkhide: fix wrong handling of SwInsText for fieldmarks
    
    For redlines, typically DocumentContentOperationsManager::InsertString()
    will insert text, and it explicitly removes any redlines on the text
    that has been inserted, hence it is always visible - so effectively the
    sw::MergedPara is updated correctly.
    
    However for fieldmarks the situation is different, if the insertion
    happens inside of the part that is hidden in the layout, then it must
    not be inserted into the sw::MergedPara.
    
    Try to figure out which part(s) of a fieldmark the insertion position is
    in and ignore the inserted text as appropriate in
    SwTextFrame::SwClientNotify().
    
    Change-Id: Ic5066b20e9609f50438ca64ac7d2cbd09baeef23
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134611
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 288ad999090d3f88d87f52ff9b292f473f869601)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134616
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index afaf1d9022d9..9c37399f68f6 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -80,8 +80,10 @@ class SwInsText final : public SwMsgPoolItem
 public:
     sal_Int32 nPos;
     sal_Int32 nLen;
+    bool isInsideFieldmarkCommand;
+    bool isInsideFieldmarkResult;
 
-    SwInsText( sal_Int32 nP, sal_Int32 nL );
+    SwInsText(sal_Int32 nP, sal_Int32 nL, bool isInFMCommand, bool 
isInFMResult);
 };
 
 class SwDelChr final : public SwMsgPoolItem
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx
index 81685b777033..8016037bfdb8 100644
--- a/sw/source/core/attr/hints.cxx
+++ b/sw/source/core/attr/hints.cxx
@@ -31,8 +31,11 @@ SwFormatChg::SwFormatChg( SwFormat* pFormat )
 {
 }
 
-SwInsText::SwInsText( sal_Int32 nP, sal_Int32 nL )
-    : SwMsgPoolItem( RES_INS_TXT ), nPos( nP ), nLen( nL )
+SwInsText::SwInsText(sal_Int32 const nP, sal_Int32 const nL, bool const 
isInFMCommand, bool const isInFMResult)
+    : SwMsgPoolItem( RES_INS_TXT )
+    , nPos( nP ), nLen( nL )
+    , isInsideFieldmarkCommand(isInFMCommand)
+    , isInsideFieldmarkResult(isInFMResult)
 {
 }
 
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index e3c87f5ea065..0b8f5a39d158 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1979,4 +1979,32 @@ void DelBookmarks(
     }
 }
 
+namespace sw {
+
+SwInsText MakeSwInsText(SwTextNode & rNode, sal_Int32 const nPos, sal_Int32 
const nLen)
+{
+    SwCursor cursor(SwPosition(rNode, nPos), nullptr);
+    bool isInsideFieldmarkCommand(false);
+    bool isInsideFieldmarkResult(false);
+    while (auto const*const pMark = 
rNode.GetDoc().getIDocumentMarkAccess()->getFieldmarkFor(*cursor.GetPoint()))
+    {
+        if (sw::mark::FindFieldSep(*pMark) < *cursor.GetPoint())
+        {
+            isInsideFieldmarkResult = true;
+        }
+        else
+        {
+            isInsideFieldmarkCommand = true;
+        }
+        *cursor.GetPoint() = pMark->GetMarkStart();
+        if (!cursor.Left(1))
+        {
+            break;
+        }
+    }
+    return SwInsText(nPos, nLen, isInsideFieldmarkCommand, 
isInsideFieldmarkResult);
+}
+
+} // namespace sw
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index f1016eb9a1e0..9550a0e31ab9 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -30,6 +30,7 @@ namespace com::sun::star::linguistic2 { class 
XHyphenatedWord; }
 
 namespace sw::mark { class IMark; }
 class SwCharRange;
+class SwInsText;
 class SwTextNode;
 class SwTextAttrEnd;
 class SwTextFormatter;
@@ -146,6 +147,8 @@ bool IsMarkHintHidden(SwRootFrame const& rLayout,
 
 void RecreateStartTextFrames(SwTextNode & rNode);
 
+auto MakeSwInsText(SwTextNode & rNode, sal_Int32 nPos, sal_Int32 nLen) -> 
SwInsText;
+
 /**
  * Decides if rTextNode has a numbering which has layout-level values (e.g. 
Arabic, but not
  * none or bullets).
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 3c3c82b4e1ac..fb177841728d 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2144,28 +2144,44 @@ void SwTextFrame::SwClientNotify(SwModify const& 
rModify, SfxHint const& rHint)
             sal_Int32 const nNPos = static_cast<const SwInsText*>(pNew)->nPos;
             sal_Int32 const nNLen = static_cast<const SwInsText*>(pNew)->nLen;
             nPos = MapModelToView(&rNode, nNPos);
-            nLen = TextFrameIndex(nNLen);
-            if (m_pMergedPara)
+            // unlike redlines, inserting into fieldmark must be explicitly 
handled
+            bool isHidden(false);
+            switch (getRootFrame()->GetFieldmarkMode())
             {
-                UpdateMergedParaForInsert(*m_pMergedPara, true, rNode, nNPos, 
nNLen);
+                case sw::FieldmarkMode::ShowCommand:
+                    isHidden = static_cast<const 
SwInsText*>(pNew)->isInsideFieldmarkResult;
+                break;
+                case sw::FieldmarkMode::ShowResult:
+                    isHidden = static_cast<const 
SwInsText*>(pNew)->isInsideFieldmarkCommand;
+                break;
+                case sw::FieldmarkMode::ShowBoth: // just to avoid the warning
+                break;
             }
-            if( IsIdxInside( nPos, nLen ) )
+            if (!isHidden)
             {
-                if( !nLen )
+                nLen = TextFrameIndex(nNLen);
+                if (m_pMergedPara)
                 {
-                    // Refresh NumPortions even when line is empty!
-                    if( nPos )
-                        InvalidateSize();
+                    UpdateMergedParaForInsert(*m_pMergedPara, true, rNode, 
nNPos, nNLen);
+                }
+                if( IsIdxInside( nPos, nLen ) )
+                {
+                    if( !nLen )
+                    {
+                        // Refresh NumPortions even when line is empty!
+                        if( nPos )
+                            InvalidateSize();
+                        else
+                            Prepare();
+                    }
                     else
-                        Prepare();
+                        InvalidateRange_( SwCharRange( nPos, nLen ), nNLen );
                 }
-                else
-                    InvalidateRange_( SwCharRange( nPos, nLen ), nNLen );
+                lcl_SetScriptInval( *this, nPos );
+                bSetFieldsDirty = true;
+                lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, 
Tag_TextFrameIndex>);
             }
             lcl_SetWrong( *this, rNode, nNPos, nNLen, true );
-            lcl_SetScriptInval( *this, nPos );
-            bSetFieldsDirty = true;
-            lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, 
Tag_TextFrameIndex>);
         }
         break;
         case RES_DEL_CHR:
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 45b51cfdd744..74ae4c2cb0c3 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2329,7 +2329,7 @@ OUString SwTextNode::InsertText( const OUString & rStr, 
const SwIndex & rIdx,
 
     if ( HasWriterListeners() )
     {   // send this before messing with hints, which will send RES_UPDATE_ATTR
-        SwInsText aHint( aPos, nLen );
+        SwInsText const aHint(sw::MakeSwInsText(*this, aPos, nLen));
         CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint));
     }
 
@@ -2537,7 +2537,8 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const 
SwIndex & rDestStart,
 
     // notify frames - before moving hints, because footnotes
     // want to find their anchor text frame in the follow chain
-    SwInsText aInsHint(nDestStart, nLen);
+    // (also ignore fieldmarks, the caller will recreate frames)
+    SwInsText const aInsHint(nDestStart, nLen, false, false);
     pDest->TriggerNodeUpdate(sw::LegacyModifyHint(nullptr, &aInsHint));
     const sw::MoveText aMoveHint(pDest, nDestStart, nTextStartIdx, nLen);
     CallSwClientNotify(aMoveHint);
@@ -3781,7 +3782,7 @@ void SwTextNode::ReplaceText( const SwIndex& rStart, 
const sal_Int32 nDelLen,
 
     if (sInserted.getLength())
     {
-        SwInsText aHint( nStartPos, sInserted.getLength() );
+        SwInsText const aHint(sw::MakeSwInsText(*this, nStartPos, 
sInserted.getLength()));
         CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint));
     }
 }
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index 9fabb33aa6e1..74ae7cf1d3c2 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1995,7 +1995,7 @@ void SwTextNode::ReplaceTextOnly( sal_Int32 nPos, 
sal_Int32 nLen,
     SwDelText aDelHint( nPos, nTLen );
     CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aDelHint));
 
-    SwInsText aHint( nPos, nTLen );
+    SwInsText const aHint(sw::MakeSwInsText(*this, nPos, nTLen));
     CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint));
 }
 
commit 52533c194fa4153dfe71027b2689390edb1e7cce
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Mon May 16 11:37:57 2022 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:00 2022 +0200

    tdf#148923 PPTX import: fix incorrect image in media file
    
    Linked media file was imported with incorrect image,
    if the Impress couldn't play the media file.
    
    Regression from commit 9564747d2fd5d2c859a359dd7fa6242c6859c0d7
    (tdf#53970 PPTX: fix import of linked media files).
    
    Change-Id: Ib277a61e83c3794376d2c090b7f742707e779832
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134394
    Tested-by: Jenkins
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134635

diff --git a/avmedia/source/viewer/mediawindow.cxx 
b/avmedia/source/viewer/mediawindow.cxx
index 4ff32f636eb6..0b1ca1b9c11a 100644
--- a/avmedia/source/viewer/mediawindow.cxx
+++ b/avmedia/source/viewer/mediawindow.cxx
@@ -352,10 +352,10 @@ uno::Reference< media::XPlayer > 
MediaWindow::createPlayer( const OUString& rURL
     return priv::MediaWindowImpl::createPlayer( rURL, rReferer, pMimeType );
 }
 
-
 uno::Reference< graphic::XGraphic > MediaWindow::grabFrame( const OUString& 
rURL,
                                                             const OUString& 
rReferer,
-                                                            const OUString& 
sMimeType )
+                                                            const OUString& 
sMimeType,
+                                                            const 
uno::Reference<graphic::XGraphic>& rGraphic)
 {
     uno::Reference< media::XPlayer >    xPlayer( createPlayer( rURL, rReferer, 
&sMimeType ) );
     uno::Reference< graphic::XGraphic > xRet;
@@ -394,7 +394,11 @@ uno::Reference< graphic::XGraphic > 
MediaWindow::grabFrame( const OUString& rURL
     }
 
     if (xGraphic)
+    {
+        if (rGraphic)
+            xGraphic.reset(new Graphic(rGraphic));
         xRet = xGraphic->GetXGraphic();
+    }
 
     return xRet;
 }
diff --git a/include/avmedia/mediawindow.hxx b/include/avmedia/mediawindow.hxx
index 78e0b1a299a3..328cad72aad8 100644
--- a/include/avmedia/mediawindow.hxx
+++ b/include/avmedia/mediawindow.hxx
@@ -103,7 +103,7 @@ namespace avmedia
         static css::uno::Reference< css::media::XPlayer > createPlayer( const 
OUString& rURL, const OUString& rReferer, const OUString* pMimeType = nullptr );
 
         static css::uno::Reference< css::graphic::XGraphic > grabFrame( const 
OUString& rURL, const OUString& rReferer,
-            const OUString& sMimeType );
+            const OUString& sMimeType, const 
css::uno::Reference<css::graphic::XGraphic>& rGraphic = nullptr);
 
     private:
         MediaWindow(const MediaWindow&) = delete;
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 515bdff11b42..bc030c7d6d3f 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -146,7 +146,9 @@ uno::Reference< graphic::XGraphic > const & 
SdrMediaObj::getSnapshot() const
         OUString aRealURL = m_xImpl->m_MediaProperties.getTempURL();
         if( aRealURL.isEmpty() )
             aRealURL = m_xImpl->m_MediaProperties.getURL();
-        m_xImpl->m_xCachedSnapshot = avmedia::MediaWindow::grabFrame( 
aRealURL, m_xImpl->m_MediaProperties.getReferer(), 
m_xImpl->m_MediaProperties.getMimeType());
+        uno::Reference<graphic::XGraphic> xGraphic
+            = m_xImpl->m_MediaProperties.getGraphic().GetXGraphic();
+        m_xImpl->m_xCachedSnapshot = avmedia::MediaWindow::grabFrame( 
aRealURL, m_xImpl->m_MediaProperties.getReferer(), 
m_xImpl->m_MediaProperties.getMimeType(), xGraphic);
     }
 #endif
     return m_xImpl->m_xCachedSnapshot;
commit 51fc4559dc193e04ef197ccb009582023190ccf0
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu May 19 11:08:50 2022 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed May 25 11:47:00 2022 +0200

    icon-theme not dynamically changing to match desktop if set to 'auto'
    
    Change-Id: Id5700cff1000fe4b6df6e73c1ce9ff4f206e0a96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134613
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/inc/IconThemeSelector.hxx b/vcl/inc/IconThemeSelector.hxx
index 7e2dfc0da1dd..8dab03d3a8d2 100644
--- a/vcl/inc/IconThemeSelector.hxx
+++ b/vcl/inc/IconThemeSelector.hxx
@@ -62,7 +62,8 @@ public:
     void
     SetUseHighContrastTheme(bool);
 
-    void
+    /** Returns true if the PreferredIconTheme was changed */
+    bool
     SetPreferredIconTheme(const OUString&, bool bDarkIconTheme);
 
     bool
diff --git a/vcl/source/app/IconThemeSelector.cxx 
b/vcl/source/app/IconThemeSelector.cxx
index 253242bcd5ad..5abb7b29d5df 100644
--- a/vcl/source/app/IconThemeSelector.cxx
+++ b/vcl/source/app/IconThemeSelector.cxx
@@ -124,13 +124,20 @@ IconThemeSelector::SetUseHighContrastTheme(bool v)
     mUseHighContrastTheme = v;
 }
 
-void
+bool
 IconThemeSelector::SetPreferredIconTheme(const OUString& theme, bool 
bDarkIconTheme)
 {
     // lower case theme name, and (tdf#120175) replace - with _
     // see icon-themes/README
-    mPreferredIconTheme = theme.toAsciiLowerCase().replace('-','_');
-    mPreferDarkIconTheme = bDarkIconTheme;
+    OUString sIconTheme = theme.toAsciiLowerCase().replace('-','_');
+
+    const bool bChanged = mPreferredIconTheme != sIconTheme || 
mPreferDarkIconTheme != bDarkIconTheme;
+    if (bChanged)
+    {
+        mPreferredIconTheme = sIconTheme;
+        mPreferDarkIconTheme = bDarkIconTheme;
+    }
+    return bChanged;
 }
 
 bool
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 0e64a4269e35..186013ebc999 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -184,7 +184,7 @@ struct ImplStyleData
     std::shared_ptr<vcl::IconThemeSelector>
                                     mIconThemeSelector;
 
-    OUString                   mIconTheme;
+    OUString                        mIconTheme;
     bool                            mbSkipDisabledInMenus;
     bool                            mbHideDisabledMenuItems;
     bool                            mbPreferredContextMenuShortcuts;
@@ -3139,7 +3139,12 @@ StyleSettings::GetHighContrastMode() const
 void
 StyleSettings::SetPreferredIconTheme(const OUString& theme, bool 
bDarkIconTheme)
 {
-    mxData->mIconThemeSelector->SetPreferredIconTheme(theme, bDarkIconTheme);
+    const bool bChanged = 
mxData->mIconThemeSelector->SetPreferredIconTheme(theme, bDarkIconTheme);
+    if (bChanged)
+    {
+        // clear this so it is recalculated if it was selected as the 
automatic theme
+        mxData->mIconTheme.clear();
+    }
 }
 
 void

Reply via email to