download.lst                                        |    8 
 external/pdfium/Library_pdfium.mk                   |    1 
 external/pdfium/UnpackedTarball_pdfium.mk           |    8 
 external/pdfium/abseil-trivial.patch                |   31 ---
 external/pdfium/build.patch.1                       |  170 ++++++++++----------
 external/pdfium/inc/pch/precompiled_pdfium.hxx      |    2 
 external/pdfium/include.patch                       |   11 -
 include/xmloff/xmlimp.hxx                           |    1 
 sc/inc/column.hxx                                   |    6 
 sc/qa/unit/ucalc_copypaste.cxx                      |   45 +++++
 sc/source/core/data/table1.cxx                      |    5 
 sc/source/core/data/table2.cxx                      |    3 
 sc/source/ui/view/output2.cxx                       |    5 
 sd/qa/uitest/data/tdf155863.odp                     |binary
 sd/qa/uitest/impress_tests/tdf155863.py             |   34 ++++
 sd/source/filter/xml/sdxmlwrp.cxx                   |    2 
 svx/source/svdraw/svdograf.cxx                      |   24 +-
 sw/qa/extras/layout/data/tox-update-wrong-pages.odt |binary
 sw/qa/extras/layout/layout.cxx                      |   34 ++++
 sw/source/core/inc/frmtool.hxx                      |    1 
 sw/source/core/layout/flowfrm.cxx                   |   20 ++
 sw/source/core/layout/sectfrm.cxx                   |    3 
 xmloff/qa/unit/uxmloff.cxx                          |   65 ++++---
 xmloff/source/core/xmlimp.cxx                       |   80 ++++++---
 xmloff/source/meta/xmlmetai.cxx                     |    4 
 25 files changed, 347 insertions(+), 216 deletions(-)

New commits:
commit 07f3199b06ef767c1d1378a6e4f270ef0f05f479
Author:     Czeber László Ádám <[email protected]>
AuthorDate: Mon Jun 12 16:12:05 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:49 2023 +0200

    tdf#122676 sc: fix format with * (filling) and NBSP thousand separator
    
    Numbers containing no-break space (NBSP) thousand separator enabled
    the EditEngine layout, losing filling e.g. for stretching spaces.
    Enable EditEngine for NBSP characters only if there is no filling
    in the number format code, fixing MSO interoperability, too.
    
    In number format codes, asterisk (*) followed by a character is used
    to fill the available space in the column with that character, e.g.
    format code
    
    [>0]" "* # ##0" € ";[<0]-* # ##0" € ";" "* -#" € ";" "@" "
    
    put the minus sign at the left side of the column, while
    the number at the right side of the column. Because of the NBSP
    thousand separator, bigger numbers got different layout previously,
    i.e. minus signs right next to the numbers.
    
    Note: there is a better solution for the layout problem: using narrow
    no-break space (U-202F), which is the proposed thousand separator in
    typography, and it's back-compatible, because it doesn't enable the 
different layout.
    
    Change-Id: Ia35f01733687ee6005f06ff3ab999b7a4b712ad4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152901
    Reviewed-by: László Németh <[email protected]>
    Tested-by: László Németh <[email protected]>
    (cherry picked from commit 72e70088dc45fbe15f809abf5263247b13d937ac)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153337
    Tested-by: Jenkins

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 649ccdd7349e..fe8d06684517 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -815,6 +815,11 @@ bool ScDrawStringsVars::HasEditCharacters() const
         switch(aString[nIdx])
         {
             case CHAR_NBSP:
+                // tdf#122676: Ignore CHAR_NBSP (this is thousand separator in 
any number)
+                // if repeat character is set
+                if (nRepeatPos < 0)
+                    return true;
+                break;
             case CHAR_SHY:
             case CHAR_ZWSP:
             case CHAR_LRM:
commit 738d7c7198a7697c9311343ebd10c7e56ac9f5d5
Author:     Michael Stahl <[email protected]>
AuthorDate: Tue Jun 27 14:50:02 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:48 2023 +0200

    xmloff: ODF import: adapt generator parsing to 2-digit major versions
    
    DocumentInfo currently assumes that a LO version encoded in "BuildId"
    property has only 1 digit major version, which is now wrong and would
    start to give incorrect results when major version "30" will be detected
    as LO_3x.
    
    Add the dots as separators into the BuildId because it's not going to
    work without.
    
    Change-Id: I8918afe3642cbefa8488c57658f1505c9a20eddd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153649
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit b1ce8bb078904db1df542f7a1c2ed527dde1a2d3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153689
    Reviewed-by: Christian Lohmaier <[email protected]>

diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 26873175268d..3684a7e087b5 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -560,6 +560,7 @@ public:
     static const sal_uInt16 LO_6x = 60 | LO_flag;
     static const sal_uInt16 LO_63x = 63 | LO_flag;
     static const sal_uInt16 LO_7x = 70 | LO_flag;
+    static const sal_uInt16 LO_New = 100 | LO_flag;
     static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
 
     /** depending on whether the generator version indicates LO, compare
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx 
b/sd/source/filter/xml/sdxmlwrp.cxx
index 43c3d0d7766d..91b02e67e525 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -693,7 +693,7 @@ bool SdXMLFilter::Import( ErrCode& nError )
                 if( !sBuildId.isEmpty() )
                 {
                     sal_Int32 nIndex = sBuildId.indexOf('$');
-                    if( nIndex != -1 )
+                    if (sBuildId.indexOf(';') == -1 && nIndex != -1)
                     {
                         sal_Int32 nUPD = o3tl::toInt32(sBuildId.subView( 0, 
nIndex ));
 
diff --git a/xmloff/qa/unit/uxmloff.cxx b/xmloff/qa/unit/uxmloff.cxx
index 9cad246f976e..2155532e27b1 100644
--- a/xmloff/qa/unit/uxmloff.cxx
+++ b/xmloff/qa/unit/uxmloff.cxx
@@ -171,33 +171,35 @@ void Test::testMetaGenerator()
         { "OpenOffice/4.1.4$Unix OpenOffice.org_project/414m2$Build-9785", 
"414$9785", SvXMLImport::AOO_4x },
 
         // LO versions
-        { "LibreOffice/3.3$Linux LibreOffice_project/330m17$Build-3", 
"330$3;33", SvXMLImport::LO_3x },
-        { "BrOffice/3.3$Win32 LibreOffice_project/330m19$Build-8", "330$8;33", 
SvXMLImport::LO_3x },
-        { "LibreOffice/3.4$Linux LibreOffice_project/340m1$Build-1206", 
"340$1206;34", SvXMLImport::LO_3x },
-        { "LibreOffice/3.5$Linux_X86_64 
LibreOffice_project/3fa2330-e49ffd2-90d118b-705e248-051e21c", ";35", 
SvXMLImport::LO_3x },
-        { "LibreOffice/3.6$Windows_x86 
LibreOffice_project/a9a0717-273e462-768e6e3-978247f-65e65f", ";36", 
SvXMLImport::LO_3x },
-        { "LibreOffice/4.0.2.2$Windows_x86 
LibreOffice_project/4c82dcdd6efcd48b1d8bba66bfe1989deee49c3", ";4022", 
SvXMLImport::LO_41x },
-        { "LibreOffice/4.1.2.3$MacOSX_x86 
LibreOffice_project/40b2d7fde7e8d2d7bc5a449dc65df4d08a7dd38", ";4123", 
SvXMLImport::LO_41x },
-        { "LibreOffice/4.2.8.2$Windows_x86 
LibreOffice_project/48d50dbfc06349262c9d50868e5c1f630a573ebd", ";4282", 
SvXMLImport::LO_42x },
-        { "LibreOffice_from_Collabora_4.2-8/4.2.10.8$Linux_x86 
LibreOffice_project/84584cc237b2eb93f7684d8fcd063bb37e87b5fb", ";42108", 
SvXMLImport::LO_42x },
-        { "LibreOffice/4.3.3.2$Linux_x86 
LibreOffice_project/9bb7eadab57b6755b1265afa86e04bf45fbfc644", ";4332", 
SvXMLImport::LO_43x },
-        { "LibreOffice_from_Collabora_4.4-10/4.4.10.9$Linux_x86 
LibreOffice_project/5600b19b88a01bbb669b0900100760758dff8c26", ";44109", 
SvXMLImport::LO_44x },
-        { "LibreOffice/4.3.3.2$Linux_X86_64 
LibreOffice_project/430m0$Build-2", "430$2;4332", SvXMLImport::LO_43x },
-        { "LibreOffice/4.4.3.2$Linux_x86 
LibreOffice_project/88805f81e9fe61362df02b9941de8e38a9b5fd16", ";4432", 
SvXMLImport::LO_44x },
-        { "LibreOffice/5.0.1.1$Linux_x86 LibreOffice_project/00m0$Build-1", 
"00$1;5011", SvXMLImport::LO_5x },
-        { "LibreOffice/5.0.3.2$Windows_X86_64 
LibreOffice_project/e5f16313668ac592c1bfb310f4390624e3dbfb75", ";5032", 
SvXMLImport::LO_5x },
-        { "Collabora_Office/5.0.10.19$Linux_X86_64 
LibreOffice_project/95060d44300d8866fa81c16fc8fe2afe22d63777", ";501019", 
SvXMLImport::LO_5x },
-        { "LibreOffice/5.1.6.2.0$Linux_X86_64 LibreOffice_project/10$Build-2", 
";51620", SvXMLImport::LO_5x },
-        { "Collabora_Office/5.1.10.17$Linux_X86_64 
LibreOffice_project/a104cbe76eefca3cf23973da68893d2225fd718b", ";511017", 
SvXMLImport::LO_5x },
-        { "LibreOffice/5.2.1.2$Windows_X86_64 
LibreOffice_project/31dd62db80d4e60af04904455ec9c9219178d620", ";5212", 
SvXMLImport::LO_5x },
-        { "LibreOffice_Vanilla/5.2.3.5$MacOSX_X86_64 
LibreOffice_project/83adc9c35c74e0badc710d981405858b1179a327", ";5235", 
SvXMLImport::LO_5x },
-        { "LibreOffice/5.3.4.2$Windows_X86_64 
LibreOffice_project/f82d347ccc0be322489bf7da61d7e4ad13fe2ff3", ";5342", 
SvXMLImport::LO_5x },
-        { "Collabora_Office/5.3.10.27$Linux_X86_64 
LibreOffice_project/7a5a5378661e338a44666c08773cc796b8d1c84a", ";531027", 
SvXMLImport::LO_5x },
-        { "LibreOfficeDev/5.4.7.0.0$Linux_X86_64 
LibreOffice_project/ba7461fc88c08e75e315f786020a2946e56166c9", ";54700", 
SvXMLImport::LO_5x },
-        { "LibreOfficeDev/6.0.3.0.0$Linux_X86_64 
LibreOffice_project/34442b85bfb0c451738b4db023345a7484463321", ";60300", 
SvXMLImport::LO_6x },
-        { "LibreOffice_powered_by_CIBDev/6.3.9.0.0$Linux_X86_64 
LibreOffice_project/c87f331d2900eab70ac3021cbe530926efa6499f", ";63900", 
SvXMLImport::LO_63x },
-        { "LibreOffice_powered_by_CIBDev/6.4.0.0.0$Linux_X86_64 
LibreOffice_project/e29e100174c133d27e953934311d68602c4515b7", ";64000", 
SvXMLImport::LO_63x },
-        { "LibreOfficeDev/7.0.6.0.0$Linux_X86_64 
LibreOffice_project/dfc40e2292c6e19e285c10ed8c8044d9454107d0", ";70600", 
SvXMLImport::LO_7x },
+        { "LibreOffice/3.3$Linux LibreOffice_project/330m17$Build-3", 
"330$3;3.3", SvXMLImport::LO_3x },
+        { "BrOffice/3.3$Win32 LibreOffice_project/330m19$Build-8", 
"330$8;3.3", SvXMLImport::LO_3x },
+        { "LibreOffice/3.4$Linux LibreOffice_project/340m1$Build-1206", 
"340$1206;3.4", SvXMLImport::LO_3x },
+        { "LibreOffice/3.5$Linux_X86_64 
LibreOffice_project/3fa2330-e49ffd2-90d118b-705e248-051e21c", ";3.5", 
SvXMLImport::LO_3x },
+        { "LibreOffice/3.6$Windows_x86 
LibreOffice_project/a9a0717-273e462-768e6e3-978247f-65e65f", ";3.6", 
SvXMLImport::LO_3x },
+        { "LibreOffice/4.0.2.2$Windows_x86 
LibreOffice_project/4c82dcdd6efcd48b1d8bba66bfe1989deee49c3", ";4.0.2.2", 
SvXMLImport::LO_41x },
+        { "LibreOffice/4.1.2.3$MacOSX_x86 
LibreOffice_project/40b2d7fde7e8d2d7bc5a449dc65df4d08a7dd38", ";4.1.2.3", 
SvXMLImport::LO_41x },
+        { "LibreOffice/4.2.8.2$Windows_x86 
LibreOffice_project/48d50dbfc06349262c9d50868e5c1f630a573ebd", ";4.2.8.2", 
SvXMLImport::LO_42x },
+        { "LibreOffice_from_Collabora_4.2-8/4.2.10.8$Linux_x86 
LibreOffice_project/84584cc237b2eb93f7684d8fcd063bb37e87b5fb", ";4.2.10.8", 
SvXMLImport::LO_42x },
+        { "LibreOffice/4.3.3.2$Linux_x86 
LibreOffice_project/9bb7eadab57b6755b1265afa86e04bf45fbfc644", ";4.3.3.2", 
SvXMLImport::LO_43x },
+        { "LibreOffice_from_Collabora_4.4-10/4.4.10.9$Linux_x86 
LibreOffice_project/5600b19b88a01bbb669b0900100760758dff8c26", ";4.4.10.9", 
SvXMLImport::LO_44x },
+        { "LibreOffice/4.3.3.2$Linux_X86_64 
LibreOffice_project/430m0$Build-2", "430$2;4.3.3.2", SvXMLImport::LO_43x },
+        { "LibreOffice/4.4.3.2$Linux_x86 
LibreOffice_project/88805f81e9fe61362df02b9941de8e38a9b5fd16", ";4.4.3.2", 
SvXMLImport::LO_44x },
+        { "LibreOffice/5.0.1.1$Linux_x86 LibreOffice_project/00m0$Build-1", 
"00$1;5.0.1.1", SvXMLImport::LO_5x },
+        { "LibreOffice/5.0.3.2$Windows_X86_64 
LibreOffice_project/e5f16313668ac592c1bfb310f4390624e3dbfb75", ";5.0.3.2", 
SvXMLImport::LO_5x },
+        { "Collabora_Office/5.0.10.19$Linux_X86_64 
LibreOffice_project/95060d44300d8866fa81c16fc8fe2afe22d63777", ";5.0.10.19", 
SvXMLImport::LO_5x },
+        { "LibreOffice/5.1.6.2.0$Linux_X86_64 LibreOffice_project/10$Build-2", 
";5.1.6.2.0", SvXMLImport::LO_5x },
+        { "Collabora_Office/5.1.10.17$Linux_X86_64 
LibreOffice_project/a104cbe76eefca3cf23973da68893d2225fd718b", ";5.1.10.17", 
SvXMLImport::LO_5x },
+        { "LibreOffice/5.2.1.2$Windows_X86_64 
LibreOffice_project/31dd62db80d4e60af04904455ec9c9219178d620", ";5.2.1.2", 
SvXMLImport::LO_5x },
+        { "LibreOffice_Vanilla/5.2.3.5$MacOSX_X86_64 
LibreOffice_project/83adc9c35c74e0badc710d981405858b1179a327", ";5.2.3.5", 
SvXMLImport::LO_5x },
+        { "LibreOffice/5.3.4.2$Windows_X86_64 
LibreOffice_project/f82d347ccc0be322489bf7da61d7e4ad13fe2ff3", ";5.3.4.2", 
SvXMLImport::LO_5x },
+        { "Collabora_Office/5.3.10.27$Linux_X86_64 
LibreOffice_project/7a5a5378661e338a44666c08773cc796b8d1c84a", ";5.3.10.27", 
SvXMLImport::LO_5x },
+        { "LibreOfficeDev/5.4.7.0.0$Linux_X86_64 
LibreOffice_project/ba7461fc88c08e75e315f786020a2946e56166c9", ";5.4.7.0.0", 
SvXMLImport::LO_5x },
+        { "LibreOfficeDev/6.0.3.0.0$Linux_X86_64 
LibreOffice_project/34442b85bfb0c451738b4db023345a7484463321", ";6.0.3.0.0", 
SvXMLImport::LO_6x },
+        { "LibreOffice_powered_by_CIBDev/6.3.9.0.0$Linux_X86_64 
LibreOffice_project/c87f331d2900eab70ac3021cbe530926efa6499f", ";6.3.9.0.0", 
SvXMLImport::LO_63x },
+        { "LibreOffice_powered_by_CIBDev/6.4.0.0.0$Linux_X86_64 
LibreOffice_project/e29e100174c133d27e953934311d68602c4515b7", ";6.4.0.0.0", 
SvXMLImport::LO_63x },
+        { "LibreOfficeDev/7.0.6.0.0$Linux_X86_64 
LibreOffice_project/dfc40e2292c6e19e285c10ed8c8044d9454107d0", ";7.0.6.0.0", 
SvXMLImport::LO_7x },
+        { "CIB_OfficeDev/6.4.0.19$Linux_X86_64 
LibreOffice_project/2e04f804b5f82770435f250873f07b3384d95504", ";6.4.0.19", 
SvXMLImport::LO_63x },
+        { "LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64 
LibreOffice_project/b81e7b6f3c71fb3ade1cb665444ac730dac0a9a9", ";24.2.0.0.", 
SvXMLImport::LO_New },
     };
 
     for (size_t i = 0; i < SAL_N_ELEMENTS(tests); ++i)
@@ -213,14 +215,15 @@ void Test::testMetaGenerator()
                 OUString::createFromAscii(tests[i].generator), xInfoSet);
         if (tests[i].buildId[0] != '\0')
         {
-            CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(tests[i].buildId),
-                    xInfoSet->getPropertyValue("BuildId").get<OUString>());
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(tests[i].generator,
+                                 OUString::createFromAscii(tests[i].buildId),
+                                 
xInfoSet->getPropertyValue("BuildId").get<OUString>());
         }
         else
         {
-            CPPUNIT_ASSERT(!xInfoSet->getPropertyValue("BuildId").hasValue());
+            CPPUNIT_ASSERT_MESSAGE(tests[i].generator, 
!xInfoSet->getPropertyValue("BuildId").hasValue());
         }
-        CPPUNIT_ASSERT_EQUAL(tests[i].result, pImport->getGeneratorVersion());
+        CPPUNIT_ASSERT_EQUAL_MESSAGE(tests[i].generator, tests[i].result, 
pImport->getGeneratorVersion());
     }
 }
 
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index e8b4ae2e0f97..d5228ae115f4 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -172,50 +172,72 @@ public:
                 OUString const loVersion(buildIds.copy(ix + 1));
                 if (!loVersion.isEmpty())
                 {
-                    if ('3' == loVersion[0])
-                    {
-                        mnGeneratorVersion = SvXMLImport::LO_3x;
-                    }
-                    else if ('4' == loVersion[0])
-                    {
-                        if (loVersion.getLength() > 1
-                            && (loVersion[1] == '0' || loVersion[1] == '1'))
+                    auto const firstDot(loVersion.indexOf('.'));
+                    if (firstDot == 1)
+                    {   // old version scheme 3.3 ... 7.6
+                        if ('3' == loVersion[0])
                         {
-                            mnGeneratorVersion = SvXMLImport::LO_41x; // 
4.0/4.1
+                            mnGeneratorVersion = SvXMLImport::LO_3x;
                         }
-                        else if (loVersion.getLength() > 1 && '2' == 
loVersion[1])
+                        else if ('4' == loVersion[0])
                         {
-                            mnGeneratorVersion = SvXMLImport::LO_42x; // 4.2
+                            if (loVersion.getLength() > 2
+                                && (loVersion[2] == '0' || loVersion[2] == 
'1'))
+                            {
+                                mnGeneratorVersion = SvXMLImport::LO_41x; // 
4.0/4.1
+                            }
+                            else if (loVersion.getLength() > 2 && '2' == 
loVersion[2])
+                            {
+                                mnGeneratorVersion = SvXMLImport::LO_42x; // 
4.2
+                            }
+                            else if (loVersion.getLength() > 2 && '3' == 
loVersion[2])
+                            {
+                                mnGeneratorVersion = SvXMLImport::LO_43x; // 
4.3
+                            }
+                            else if (loVersion.getLength() > 2 && '4' == 
loVersion[2])
+                            {
+                                mnGeneratorVersion = SvXMLImport::LO_44x; // 
4.4
+                            }
                         }
-                        else if (loVersion.getLength() > 1 && '3' == 
loVersion[1])
+                        else if ('5' == loVersion[0])
                         {
-                            mnGeneratorVersion = SvXMLImport::LO_43x; // 4.3
+                            mnGeneratorVersion = SvXMLImport::LO_5x;
                         }
-                        else if (loVersion.getLength() > 1 && '4' == 
loVersion[1])
+                        else if ('6' == loVersion[0])
                         {
-                            mnGeneratorVersion = SvXMLImport::LO_44x; // 4.4
+                            if (loVersion.getLength() > 2
+                                && (loVersion[2] == '0' || loVersion[2] == '1'
+                                    || loVersion[2] == '2'))
+                            {
+                                mnGeneratorVersion = SvXMLImport::LO_6x; // 
6.0/6.1/6.2
+                            }
+                            else
+                            {
+                                mnGeneratorVersion = SvXMLImport::LO_63x; // 
6.3/6.4
+                            }
                         }
-                    }
-                    else if ('5' == loVersion[0])
-                    {
-                        mnGeneratorVersion = SvXMLImport::LO_5x;
-                    }
-                    else if ('6' == loVersion[0])
-                    {
-                        if (loVersion.getLength() > 1
-                            && (loVersion[1] == '0' || loVersion[1] == '1'
-                                || loVersion[1] == '2'))
+                        else if ('7' == loVersion[0])
                         {
-                            mnGeneratorVersion = SvXMLImport::LO_6x; // 
6.0/6.1/6.2
+                            mnGeneratorVersion = SvXMLImport::LO_7x;
                         }
                         else
                         {
-                            mnGeneratorVersion = SvXMLImport::LO_63x; // 
6.3/6.4
+                            SAL_INFO("xmloff.core", "unknown LO version: " << 
loVersion);
                         }
                     }
-                    else if ('7' == loVersion[0])
+                    else if (1 < firstDot) // new version scheme 24.2 ...
                     {
-                        mnGeneratorVersion = SvXMLImport::LO_7x;
+                        OUString const nMajor(loVersion.subView(0, firstDot));
+                        auto const year(nMajor.toInt32());
+                        //auto const 
month(loVersion.copy(firstDot+1).toInt32());
+                        if (0 < year)
+                        {
+                            mnGeneratorVersion = SvXMLImport::LO_New;
+                        }
+                        else
+                        {
+                            SAL_INFO("xmloff.core", "unknown LO version: " << 
loVersion);
+                        }
                     }
                     else
                     {
diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx
index 6f75963056b2..a6d2b894a70b 100644
--- a/xmloff/source/meta/xmlmetai.cxx
+++ b/xmloff/source/meta/xmlmetai.cxx
@@ -283,11 +283,11 @@ void 
SvXMLMetaDocumentContext::setBuildId(std::u16string_view i_rBuildId, const
         assert(firstSlash != std::u16string_view::npos);
         for (size_t i = firstSlash + 1; i < i_rBuildId.size(); ++i)
         {
-            if (rtl::isAsciiDigit(i_rBuildId[i]))
+            if (rtl::isAsciiDigit(i_rBuildId[i]) || '.' == i_rBuildId[i])
             {
                 sNumber.append(i_rBuildId[i]);
             }
-            else if ('.' != i_rBuildId[i])
+            else
             {
                 break;
             }
commit 285da02c047f58b2d9ae8aba5d450f75e006e9fb
Author:     Tibor Nagy <[email protected]>
AuthorDate: Fri Jun 16 09:34:29 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:48 2023 +0200

    tdf#155863 sd: fix resizing of cropped images to original size
    
    Resizing with the function "Original Size" (e.g. in the context menu) 
resulted distortion in case of cropped images, if the original image
    and its cropping have different aspect ratios. Now zoom the cropped
    image to the original resolution instead of stretching it to the
    same size.
    
    Change-Id: I5e59f8b48dc03844a739c3eb803e3195a12d9c6d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153170
    Tested-by: László Németh <[email protected]>
    Reviewed-by: László Németh <[email protected]>
    (cherry picked from commit a4e12cbfc69cfe668fa30756a3c5843e911e22b1)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153342
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sd/qa/uitest/data/tdf155863.odp b/sd/qa/uitest/data/tdf155863.odp
new file mode 100644
index 000000000000..2ae286c05d31
Binary files /dev/null and b/sd/qa/uitest/data/tdf155863.odp differ
diff --git a/sd/qa/uitest/impress_tests/tdf155863.py 
b/sd/qa/uitest/impress_tests/tdf155863.py
new file mode 100644
index 000000000000..bce8936a3d40
--- /dev/null
+++ b/sd/qa/uitest/impress_tests/tdf155863.py
@@ -0,0 +1,34 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-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/.
+#
+
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
+
+class tdf155863(UITestCase):
+    def test_tdf155863(self):
+        # This document contains an image with an original size of 7.99cm x 
5.74cm.
+        # The image has been cropped 0.8cm on the left, 3.59cm on the right, 
0.99cm at the top,
+        # and 0.75cm at the bottom.
+        # Also, it has been resized to a width of 2.1cm and a height of 2.33cm.
+        with self.ui_test.load_file(get_url_for_data_file("tdf155863.odp")) as 
document:
+            xImpressDoc = self.xUITest.getTopFocusWindow()
+            xEditWin = xImpressDoc.getChild("impress_win")
+
+            # select the image on the first slide
+            xEditWin.executeAction("SELECT", 
mkPropertyValues({"OBJECT":"Image"}))
+
+            # click "Original Size"
+            self.xUITest.executeCommand(".uno:OriginalSize")
+
+            # tdf#155863: Without the fix in place, the image will be 
distorted due to the wrong size.
+            self.assertEqual(3597, 
document.DrawPages[0].getByIndex(0).Size.Width)
+            self.assertEqual(3998, 
document.DrawPages[0].getByIndex(0).Size.Height)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 1c1be8a7a69a..946cbee0ba0d 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -480,23 +480,21 @@ Size SdrGrafObj::getOriginalSize() const
 {
     Size aSize = GetGrafPrefSize();
 
-    if (aGrafInfo.IsCropped())
-    {
-        const tools::Long 
aCroppedTop(OutputDevice::LogicToLogic(aGrafInfo.GetTopCrop(), 
getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
-        const tools::Long 
aCroppedBottom(OutputDevice::LogicToLogic(aGrafInfo.GetBottomCrop(), 
getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
-        const tools::Long 
aCroppedLeft(OutputDevice::LogicToLogic(aGrafInfo.GetLeftCrop(), 
getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
-        const tools::Long 
aCroppedRight(OutputDevice::LogicToLogic(aGrafInfo.GetRightCrop(), 
getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
-        const tools::Long aCroppedWidth(aSize.getWidth() - aCroppedLeft + 
aCroppedRight);
-        const tools::Long aCroppedHeight(aSize.getHeight() - aCroppedTop + 
aCroppedBottom);
-
-        aSize = Size ( aCroppedWidth, aCroppedHeight);
-    }
-
-    if ( GetGrafPrefMapMode().GetMapUnit() == MapUnit::MapPixel )
+    if (GetGrafPrefMapMode().GetMapUnit() == MapUnit::MapPixel)
         aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, 
MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
     else
         aSize = OutputDevice::LogicToLogic(aSize, GetGrafPrefMapMode(), 
MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
 
+    if (aGrafInfo.IsCropped())
+    {
+        const tools::Long aCroppedWidth(aSize.getWidth() - 
aGrafInfo.GetLeftCrop()
+                                        - aGrafInfo.GetRightCrop());
+        const tools::Long aCroppedHeight(aSize.getHeight() - 
aGrafInfo.GetTopCrop()
+                                         - aGrafInfo.GetBottomCrop());
+
+        aSize = Size(aCroppedWidth, aCroppedHeight);
+    }
+
     return aSize;
 }
 
commit 8b9913cab48bc33bdf76ae7f617cd9932a49c5bf
Author:     Eike Rathke <[email protected]>
AuthorDate: Tue Jun 27 13:39:13 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:48 2023 +0200

    Update language-subtag-registry to 2023-05-11
    
    Change-Id: Ieb1c3eab66c06c8e7b3d9751d9e4548dbd7efc04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153643
    Reviewed-by: Eike Rathke <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit bc82afbfd320ecf5e7ed5dc87d1606b97dd10821)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153665
    Reviewed-by: Xisco Fauli <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/download.lst b/download.lst
index 6fa86f726923..884a156b332e 100644
--- a/download.lst
+++ b/download.lst
@@ -338,8 +338,8 @@ LIBJPEG_TURBO_TARBALL := libjpeg-turbo-2.1.5.1.tar.gz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-LANGTAGREG_SHA256SUM := 
e2d9224e0e50fc8ad12a3cf47396bbcadf45b2515839d4770432653a88972c00
-LANGTAGREG_TARBALL := language-subtag-registry-2022-08-08.tar.bz2
+LANGTAGREG_SHA256SUM := 
9042b64cd473bf36073513b474046f13778107b57c2ac47fb2633104120d69da
+LANGTAGREG_TARBALL := language-subtag-registry-2023-05-11.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
commit 49076ef470fd7ef004498ecb2d096c03f95cc39b
Author:     Czeber László Ádám <[email protected]>
AuthorDate: Thu Jun 8 14:55:34 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:48 2023 +0200

    tdf#153437 sc: fix broken formatting without performance regression
    
    Follow-up to commit 7be7e1ff95af485a9cb00748800d3d084f96387c
    "tdf#153437 sc: fix broken formatting at Undo of row/column insertion"
    by replacing that with a better version without performance
    regression. This keeps the original performance fix of
    commit 2e86718626a07e1656661df3ad69a64848bf4614
    "don't allocate unnecessary columns when inserting a row"
    related to the support of 16k columns.
    
    The previous fix used extra memory to fix the broken formatting
    of the cells. I have now solved the error in tdf#153437 without
    taking extra memory. It doesn't change the reserved cells, it just
    deletes a row from the default attribute of the cells when deleting
    rows, so they don't slip. When deleting a column, the last column
    in the still reserved area loses its formatting. I copied the default value 
back here, as the other columns have this value.
    
    Change-Id: I35da1cb79ff4e3493e91d29766cc2b81412080eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152742
    Tested-by: László Németh <[email protected]>
    Reviewed-by: László Németh <[email protected]>
    (cherry picked from commit c61f5a5d55c07721f044befc1f6efa0231cd92f6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152814
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153494
    Tested-by: Jenkins

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 949ca30dd137..87d3dc730a9f 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -171,6 +171,7 @@ public:
 
     bool        TestInsertRow( SCSIZE nSize ) const;
     void        InsertRow( SCROW nStartRow, SCSIZE nSize );
+    void        DeleteRow( SCROW nStartRow, SCSIZE nSize );
 };
 
 // Use protected inheritance to prevent publishing some internal ScColumnData
@@ -1054,4 +1055,9 @@ inline void ScColumnData::InsertRow( SCROW nStartRow, 
SCSIZE nSize )
     pAttrArray->InsertRow( nStartRow, nSize );
 }
 
+inline void ScColumnData::DeleteRow(SCROW nStartRow, SCSIZE nSize)
+{
+    pAttrArray->DeleteRow( nStartRow, nSize );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 6cb5384c05f9..308025656319 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1851,13 +1851,11 @@ void ScTable::UpdateReference(
     }
     else
     {
-        // When deleting row(s) or column(s), allocate the last column
-        // before updating the references
-        if (nDx < 0 || nDy < 0)
-            CreateColumnIfNotExists(rDocument.MaxCol());
-
-        for (SCCOL col : GetColumnsRange(0, rDocument.MaxCol()))
-            bUpdated |= CreateColumnIfNotExists(col).UpdateReference(rCxt, 
pUndoDoc);
+        for (SCCOL col : GetAllocatedColumnsRange(0, rDocument.MaxCol()))
+            bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc);
+        // When deleting row(s), delete same row from the default attribute
+        if (nDy < 0)
+            aDefaultColData.DeleteRow(nRow1+nDy, -nDy);
     }
 
     if ( bIncludeDraw )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9a163e25b74e..a4758d088ac0 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -400,6 +400,9 @@ void ScTable::DeleteCol(
     {
         for (SCCOL nCol = nStartCol + nSize; nCol < aCol.size(); ++nCol)
             aCol[nCol].SwapCol(aCol[nCol - nSize]);
+        // When delete column(s), inicialize the last columns from the default 
attributes
+        for (SCCOL nCol = aCol.size() - nSize; nCol < aCol.size(); ++nCol)
+            aCol[nCol].Init(nCol, aCol[nCol].GetTab(), rDocument, false);
     }
     else
     {
commit f5f41aee008d8eac61d795ee71b2ac76038d5802
Author:     Miklos Vajna <[email protected]>
AuthorDate: Wed May 24 20:13:48 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:47 2023 +0200

    Update pdfium to 5778
    
    - external/pdfium/abseil-trivial.patch is no longer needed, upstream
      does what we did previously
    
    - external/pdfium/build.patch.1: re-generate with 'patch -p1' + 'git
      diff'
    
    - external/pdfium/include.patch is no longer needed, upstream does what
      we did previously
    
    Change-Id: I39a6f721e436aa53914bbf43b78ac7d86e5eac59
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152244
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit dc69e7c52f12f57197f26b56c968139186d4ed5b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153653
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/download.lst b/download.lst
index 5824823736db..6fa86f726923 100644
--- a/download.lst
+++ b/download.lst
@@ -497,8 +497,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
1a625b25562fb4c25c8bf4660c704111cdd306b8934b94dcd9b89329909ede55
-PDFIUM_TARBALL := pdfium-5636.tar.bz2
+PDFIUM_SHA256SUM := 
b1052ff24e9ffb11af017c444bb0f6ad508d64c9a0fb88cacb0e8210245dde06
+PDFIUM_TARBALL := pdfium-5778.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/Library_pdfium.mk 
b/external/pdfium/Library_pdfium.mk
index a9eef6762436..a5c659ea80ea 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -293,6 +293,7 @@ $(eval $(call 
gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_transferfunc \
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_basedcs \
     UnpackedTarball/pdfium/core/fpdfapi/page/cpdf_indexedcs \
+    UnpackedTarball/pdfium/core/fpdfapi/parser/object_tree_traversal_util \
 ))
 
 # fpdfdoc
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index 46c7a45ee798..79e93d24d439 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -14,14 +14,6 @@ pdfium_patches += build.patch.1
 # Avoids Windows 8 build dependency.
 pdfium_patches += windows7.patch.1
 pdfium_patches += c++20-comparison.patch
-# Use CoreGraphics.h instead of Carbon.h -- 
https://pdfium-review.googlesource.com/c/pdfium/+/99753
-# pdfium_patches += cg-instead-of-carbon.patch.1
-# Android NDK 19 - that is known to work well - does not have 2 defines -- 
https://pdfium-review.googlesource.com/c/pdfium/+/96530
-# pdfium_patches += AndroidNDK19.patch.1
-
-pdfium_patches += include.patch
-
-pdfium_patches += abseil-trivial.patch
 
 pdfium_patches += constexpr-template.patch
 
diff --git a/external/pdfium/abseil-trivial.patch 
b/external/pdfium/abseil-trivial.patch
deleted file mode 100644
index fa91fa6bbba9..000000000000
--- a/external/pdfium/abseil-trivial.patch
+++ /dev/null
@@ -1,31 +0,0 @@
---- third_party/abseil-cpp/absl/meta/type_traits.h
-+++ third_party/abseil-cpp/absl/meta/type_traits.h
-@@ -501,27 +501,7 @@ struct is_trivially_move_assignable
- // operation that is not trivial. `is_trivially_copy_assignable<T>` is simply
- // `is_trivially_assignable<T&, const T&>`.
- template <typename T>
--struct is_trivially_copy_assignable
--#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
--    : std::is_trivially_copy_assignable<T> {
--#else
--    : std::integral_constant<
--          bool, __has_trivial_assign(typename std::remove_reference<T>::type) 
&&
--                    absl::is_copy_assignable<T>::value> {
--#endif
--#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
-- private:
--  static constexpr bool compliant =
--      std::is_trivially_copy_assignable<T>::value ==
--      is_trivially_copy_assignable::value;
--  static_assert(compliant || std::is_trivially_copy_assignable<T>::value,
--                "Not compliant with std::is_trivially_copy_assignable; "
--                "Standard: false, Implementation: true");
--  static_assert(compliant || !std::is_trivially_copy_assignable<T>::value,
--                "Not compliant with std::is_trivially_copy_assignable; "
--                "Standard: true, Implementation: false");
--#endif  // ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
--};
-+using is_trivially_copy_assignable = std::is_trivially_copy_assignable<T>;
- 
- #if defined(__cpp_lib_remove_cvref) && __cpp_lib_remove_cvref >= 201711L
- template <typename T>
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index 6f6a53a44ef3..2c177b3b61a4 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -1,9 +1,66 @@
 -*- Mode: diff -*-
+diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp 
b/core/fpdfapi/font/cpdf_cidfont.cpp
+index f5a51b24e..8b308d0a6 100644
+--- a/core/fpdfapi/font/cpdf_cidfont.cpp
++++ b/core/fpdfapi/font/cpdf_cidfont.cpp
+@@ -755,7 +755,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, 
bool* pVertGlyph) {
+         uint32_t maccode = CharCodeFromUnicodeForFreetypeEncoding(
+             FT_ENCODING_APPLE_ROMAN, name_unicode);
+         index = maccode ? FT_Get_Char_Index(face, maccode)
+-                        : FT_Get_Name_Index(face, name);
++                        : FT_Get_Name_Index(face, const_cast<char*>(name));
+       }
+       if (index == 0 || index == 0xffff)
+         return charcode ? static_cast<int>(charcode) : -1;
+diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp 
b/core/fpdfapi/font/cpdf_truetypefont.cpp
+index 0a59b54eb..a96e11759 100644
+--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
++++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
+@@ -91,7 +91,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
+               FT_ENCODING_APPLE_ROMAN,
+               m_Encoding.UnicodeFromCharCode(charcode));
+           if (!maccode) {
+-            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
++            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
+           } else {
+             m_GlyphIndex[charcode] = FT_Get_Char_Index(face, maccode);
+           }
+@@ -105,7 +105,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
+         m_GlyphIndex[charcode] = FT_Get_Char_Index(face, 32);
+         continue;
+       }
+-      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
++      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
+       if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
+         continue;
+ 
+diff --git a/core/fpdfapi/font/cpdf_type1font.cpp 
b/core/fpdfapi/font/cpdf_type1font.cpp
+index 55510e7d7..2f13f00b8 100644
+--- a/core/fpdfapi/font/cpdf_type1font.cpp
++++ b/core/fpdfapi/font/cpdf_type1font.cpp
+@@ -263,7 +263,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
+                                           static_cast<uint32_t>(charcode));
+       if (name) {
+         m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+-        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
++        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
+       } else {
+         m_GlyphIndex[charcode] = FT_Get_Char_Index(
+             m_Font.GetFaceRec(), static_cast<uint32_t>(charcode));
+@@ -294,7 +294,7 @@ void CPDF_Type1Font::LoadGlyphMap() {
+       continue;
+ 
+     m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
+-    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
++    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
+     if (m_GlyphIndex[charcode] != 0)
+       continue;
+ 
 diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
-index 323de4ffc..f11a0b0ad 100644
+index 228a0c137..bf512beb3 100644
 --- a/core/fpdfdoc/cpdf_metadata.cpp
 +++ b/core/fpdfdoc/cpdf_metadata.cpp
-@@ -74,7 +74,7 @@ std::vector<UnsupportedFeature> 
CPDF_Metadata::CheckForSharedForm() const {
+@@ -77,7 +77,7 @@ std::vector<UnsupportedFeature> 
CPDF_Metadata::CheckForSharedForm() const {
    CFX_XMLParser parser(stream);
    std::unique_ptr<CFX_XMLDocument> doc = parser.Parse();
    if (!doc)
@@ -12,37 +69,11 @@ index 323de4ffc..f11a0b0ad 100644
  
    std::vector<UnsupportedFeature> unsupported;
    CheckForSharedFormInternal(doc->GetRoot(), &unsupported);
-diff --git a/third_party/base/span.h b/third_party/base/span.h
-index ec9f9903f..1c17ad091 100644
---- a/third_party/base/span.h
-+++ b/third_party/base/span.h
-@@ -208,7 +208,7 @@ class span {
-   // Conversions from spans of compatible types: this allows a span<T> to be
-   // seamlessly used as a span<const T>, but not the other way around.
-   template <typename U, typename = internal::EnableIfLegalSpanConversion<U, 
T>>
--  constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
-+  span(const span<U>& other) : span(other.data(), other.size()) {}
-   span& operator=(const span& other) noexcept {
-     if (this != &other) {
-       ReleaseEmptySpan();
-diff --git a/third_party/base/span.h b/third_party/base/span.h
-index 0fb627ba8..dda1fc8bc 100644
---- a/third_party/base/span.h
-+++ b/third_party/base/span.h
-@@ -204,7 +204,7 @@ class span {
-   // size()|.
-   template <typename Container,
-             typename = internal::EnableIfSpanCompatibleContainer<Container, 
T>>
--  constexpr span(Container& container)
-+  span(Container& container)
-       : span(container.data(), container.size()) {}
-   template <
-       typename Container,
 diff --git a/core/fxcodec/jpx/cjpx_decoder.cpp 
b/core/fxcodec/jpx/cjpx_decoder.cpp
-index d8875786c..bc019ebe1 100644
+index 9391d61ab..490ce2230 100644
 --- a/core/fxcodec/jpx/cjpx_decoder.cpp
 +++ b/core/fxcodec/jpx/cjpx_decoder.cpp
-@@ -73,7 +73,7 @@ absl::optional<OpjImageRgbData> alloc_rgb(size_t size) {
+@@ -75,7 +75,7 @@ absl::optional<OpjImageRgbData> alloc_rgb(size_t size) {
    if (!data.b)
      return absl::nullopt;
  
@@ -52,10 +83,10 @@ index d8875786c..bc019ebe1 100644
  
  void sycc_to_rgb(int offset,
 diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
-index 8b3a72700..ea1db23f4 100644
+index a2a44df39..d6cedee46 100644
 --- a/core/fxge/cfx_font.cpp
 +++ b/core/fxge/cfx_font.cpp
-@@ -47,25 +47,9 @@ struct OUTLINE_PARAMS {
+@@ -48,25 +48,9 @@ struct OUTLINE_PARAMS {
  // TODO(crbug.com/pdfium/1400): When FT_Done_MM_Var() is more likely to be
  // available to all users in the future, remove FreeMMVar() and use
  // FT_Done_MM_Var() directly.
@@ -82,10 +113,10 @@ index 8b3a72700..ea1db23f4 100644
  
  FX_RECT FXRectFromFTPos(FT_Pos left, FT_Pos top, FT_Pos right, FT_Pos bottom) 
{
 diff --git a/third_party/base/numerics/safe_conversions_impl.h 
b/third_party/base/numerics/safe_conversions_impl.h
-index 4d8a7b7d9..d14c6dc06 100644
+index 44c921a14..0152a89b7 100644
 --- a/third_party/base/numerics/safe_conversions_impl.h
 +++ b/third_party/base/numerics/safe_conversions_impl.h
-@@ -88,7 +88,7 @@ constexpr typename std::make_unsigned<T>::type 
SafeUnsignedAbs(T value) {
+@@ -89,7 +89,7 @@ constexpr typename std::make_unsigned<T>::type 
SafeUnsignedAbs(T value) {
  
  // TODO(jschuh): Switch to std::is_constant_evaluated() once C++20 is 
supported.
  // Alternately, the usage could be restructured for "consteval if" in C++23.
@@ -94,57 +125,28 @@ index 4d8a7b7d9..d14c6dc06 100644
  
  // TODO(jschuh): Debug builds don't reliably propagate constants, so we 
restrict
  // some accelerated runtime paths to release builds until this can be forced
---- pdfium/core/fpdfapi/font/cpdf_cidfont.cpp.orig     2022-05-20 
09:25:52.066728467 +0000
-+++ pdfium/core/fpdfapi/font/cpdf_cidfont.cpp  2022-05-20 09:25:56.146736531 
+0000
-@@ -738,7 +738,7 @@
-         uint32_t maccode = CharCodeFromUnicodeForFreetypeEncoding(
-             FT_ENCODING_APPLE_ROMAN, name_unicode);
-         index = maccode ? FT_Get_Char_Index(face, maccode)
--                        : FT_Get_Name_Index(face, name);
-+                        : FT_Get_Name_Index(face, const_cast<char*>(name));
-       }
-       if (index == 0 || index == 0xffff)
-         return charcode ? static_cast<int>(charcode) : -1;
---- pdfium/core/fpdfapi/font/cpdf_type1font.cpp.orig   2022-05-20 
09:26:59.090862058 +0000
-+++ pdfium/core/fpdfapi/font/cpdf_type1font.cpp        2022-05-20 
09:27:33.810932435 +0000
-@@ -260,7 +260,7 @@
-                                           static_cast<uint32_t>(charcode));
-       if (name) {
-         m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
--        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
-+        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
-       } else {
-         m_GlyphIndex[charcode] = FT_Get_Char_Index(
-             m_Font.GetFaceRec(), static_cast<uint32_t>(charcode));
-@@ -291,7 +291,7 @@
-       continue;
- 
-     m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
--    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
-+    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), 
const_cast<char*>(name));
-     if (m_GlyphIndex[charcode] != 0)
-       continue;
- 
---- pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp.orig        2022-05-20 
09:26:12.066767996 +0000
-+++ pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp     2022-05-20 
09:26:46.690836923 +0000
-@@ -90,7 +90,7 @@
-               FT_ENCODING_APPLE_ROMAN,
-               m_Encoding.UnicodeFromCharCode(charcode));
-           if (!maccode) {
--            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
-+            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
-           } else {
-             m_GlyphIndex[charcode] = FT_Get_Char_Index(face, maccode);
-           }
-@@ -104,7 +104,7 @@
-         m_GlyphIndex[charcode] = FT_Get_Char_Index(face, 32);
-         continue;
-       }
--      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
-+      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, 
const_cast<char*>(name));
-       if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
-         continue;
+diff --git a/third_party/base/span.h b/third_party/base/span.h
+index ed2a3c8de..87493861c 100644
+--- a/third_party/base/span.h
++++ b/third_party/base/span.h
+@@ -211,7 +211,7 @@ class TRIVIAL_ABI GSL_POINTER span {
+ #else
+   template <typename Container,
+             typename = internal::EnableIfSpanCompatibleContainer<Container, 
T>>
+-  constexpr span(Container& container)
++  span(Container& container)
+       : span(container.data(), container.size()) {}
+ #endif
  
+@@ -225,7 +225,7 @@ class TRIVIAL_ABI GSL_POINTER span {
+   // Conversions from spans of compatible types: this allows a span<T> to be
+   // seamlessly used as a span<const T>, but not the other way around.
+   template <typename U, typename = internal::EnableIfLegalSpanConversion<U, 
T>>
+-  constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
++  span(const span<U>& other) : span(other.data(), other.size()) {}
+   span& operator=(const span& other) noexcept {
+     if (this != &other) {
+       ReleaseEmptySpan();
 diff --git a/third_party/libopenjpeg/openjpeg.c 
b/third_party/libopenjpeg/openjpeg.c
 index 29d3ee528..d5c7a1bc9 100644
 --- a/third_party/libopenjpeg/openjpeg.c
diff --git a/external/pdfium/include.patch b/external/pdfium/include.patch
deleted file mode 100644
index 75c0e3b9272a..000000000000
--- a/external/pdfium/include.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- constants/annotation_flags.h
-+++ constants/annotation_flags.h
-@@ -5,6 +5,8 @@
- #ifndef CONSTANTS_ANNOTATION_FLAGS_H_
- #define CONSTANTS_ANNOTATION_FLAGS_H_
- 
-+#include <stdint.h>
-+
- namespace pdfium {
- namespace annotation_flags {
- 
commit 85210161a54ecc14ab593d8964c08b6589742385
Author:     Miklos Vajna <[email protected]>
AuthorDate: Fri Mar 10 17:21:42 2023 +0100
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:47 2023 +0200

    Update pdfium to 5636
    
    Some changes in the bundled libtiff, but it seems that would be for XFA
    which we disable, so it doesn't affect us.
    
    Change-Id: Ibadeecf20daec342fbfef6d1e89bd17f5f0095e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148652
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 47afcad0d599009c38b4597c27558ec2af58b7f8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153651
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/download.lst b/download.lst
index 641074895832..5824823736db 100644
--- a/download.lst
+++ b/download.lst
@@ -497,8 +497,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
9fae5f8b3b90a4f7ca663f741e232e1e4c3f098fb7a18b0ad52e74ae172cf16c
-PDFIUM_TARBALL := pdfium-5522.tar.bz2
+PDFIUM_SHA256SUM := 
1a625b25562fb4c25c8bf4660c704111cdd306b8934b94dcd9b89329909ede55
+PDFIUM_TARBALL := pdfium-5636.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx 
b/external/pdfium/inc/pch/precompiled_pdfium.hxx
index 315b5d81ec12..6258e8036360 100644
--- a/external/pdfium/inc/pch/precompiled_pdfium.hxx
+++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx
@@ -310,6 +310,8 @@
 #include <core/fxcrt/fileaccess_iface.h>
 #include <core/fxcrt/fixed_try_alloc_zeroed_data_vector.h>
 #include <core/fxcrt/fixed_uninit_data_vector.h>
+#include <core/fxcrt/fixed_zeroed_data_vector.h>
+#include <core/fxcrt/fx_2d_size.h>
 #include <core/fxcrt/fx_bidi.h>
 #include <core/fxcrt/fx_codepage.h>
 #include <core/fxcrt/fx_coordinates.h>
commit 082cb0dcf42749832e2737db415dc015b117ce78
Author:     Miklos Vajna <[email protected]>
AuthorDate: Thu Jan 12 20:12:37 2023 +0100
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:47 2023 +0200

    Update pdfium to 5522
    
    The internal libpng 1.6 is now dropped, but that doesn't really affect
    us.
    
    Change-Id: I777c024c76c17689c20bbe6453467ba5fb22baba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145417
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 04fd7d0f53faa08c608034707ca4a459a162712d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153650
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/download.lst b/download.lst
index 2c088d10cf1d..641074895832 100644
--- a/download.lst
+++ b/download.lst
@@ -497,8 +497,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
-PDFIUM_SHA256SUM := 
7db59b1e91f2bc0ab4c5e19d1a4f881e6a47dbb0d3b7e980a7358225b12a0f35
-PDFIUM_TARBALL := pdfium-5408.tar.bz2
+PDFIUM_SHA256SUM := 
9fae5f8b3b90a4f7ca663f741e232e1e4c3f098fb7a18b0ad52e74ae172cf16c
+PDFIUM_TARBALL := pdfium-5522.tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
commit 992c52bf049ca60d4b3c34e4d9a44052a816646f
Author:     Czeber László Ádám <[email protected]>
AuthorDate: Wed May 24 09:05:16 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:47 2023 +0200

    tdf#153437 sc: fix broken formatting at Undo of row/column insertion
    
    Performance fix for the 16k rows resulted broken
    formatting during Undo of row insertion, e.g. rows
    with background color fell apart, highlighting partially
    also the row under the deleted row removed by Undo, or
    Undo of inserted/copied columns removed the background
    coloring at the place of the removed columns.
    
    Formatting was always deleted after the last column
    containing data, because the row was only allocated until
    then. When deleting row(s) or column(s), allocate the last
    column before updating the references.
    
    Regression from commit 2e86718626a07e1656661df3ad69a64848bf4614
    "don't allocate unnecessary columns when inserting a row".
    
    Change-Id: I8d74d59ff0051fdfe183e14a16d987edc71d55e6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152185
    Tested-by: László Németh <[email protected]>
    Reviewed-by: László Németh <[email protected]>
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153493
    Reviewed-by: Stéphane Guillou <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx
index b6062cb04c72..e63353c860ec 100644
--- a/sc/qa/unit/ucalc_copypaste.cxx
+++ b/sc/qa/unit/ucalc_copypaste.cxx
@@ -27,6 +27,7 @@
 #include <refundo.hxx>
 #include <scitems.hxx>
 #include <scopetools.hxx>
+#include <undomanager.hxx>
 
 #include <sfx2/docfile.hxx>
 
@@ -135,6 +136,7 @@ public:
 
     // tdf#80137
     void testCopyPasteMatrixFormula();
+    void testUndoBackgroundColor();
 
     CPPUNIT_TEST_SUITE(TestCopyPaste);
 
@@ -239,6 +241,7 @@ public:
     CPPUNIT_TEST(testMixDataWithFormulaTdf116413);
 
     CPPUNIT_TEST(testCopyPasteMatrixFormula);
+    CPPUNIT_TEST(testUndoBackgroundColor);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -10905,6 +10908,48 @@ void TestCopyPaste::testCopyPasteMatrixFormula()
     m_pDoc->DeleteTab(0);
 }
 
+void TestCopyPaste::testUndoBackgroundColor()
+{
+    m_pDoc->InsertTab(0, "Table1");
+
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    ScMarkData aMark(m_pDoc->GetSheetLimits());
+
+    // Set Values to B1, C2, D5
+    m_pDoc->SetValue(ScAddress(1, 0, 0), 1.0); // B1
+    m_pDoc->SetValue(ScAddress(2, 1, 0), 2.0); // C2
+    m_pDoc->SetValue(ScAddress(3, 4, 0), 3.0); // D5
+
+    // Add patterns
+    ScPatternAttr aCellBlueColor(m_pDoc->GetPool());
+    aCellBlueColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
+    m_pDoc->ApplyPatternAreaTab(0, 3, m_pDoc->MaxCol(), 3, 0, aCellBlueColor);
+
+    // Insert a new row at row 3
+    ScRange aRowOne(0, 2, 0, m_pDoc->MaxCol(), 2, 0);
+    aMark.SetMarkArea(aRowOne);
+    ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
+    rFunc.InsertCells(aRowOne, &aMark, INS_INSROWS_BEFORE, true, true);
+
+    // Check patterns
+    const SfxPoolItem* pItem = nullptr;
+    m_pDoc->GetPattern(ScAddress(1000, 4, 
0))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
+    CPPUNIT_ASSERT(pItem);
+    CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const 
SvxBrushItem*>(pItem)->GetColor());
+
+    // Undo the new row
+    m_pDoc->GetUndoManager()->Undo();
+
+    // Check patterns
+    // Failed if row 3 is not blue all the way through
+    pItem = nullptr;
+    m_pDoc->GetPattern(ScAddress(1000, 3, 
0))->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
+    CPPUNIT_ASSERT(pItem);
+    CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast<const 
SvxBrushItem*>(pItem)->GetColor());
+
+    m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(TestCopyPaste);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 78c49912bcc9..6cb5384c05f9 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1851,8 +1851,13 @@ void ScTable::UpdateReference(
     }
     else
     {
-        for( SCCOL col : GetAllocatedColumnsRange( 0, rDocument.MaxCol()))
-            bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc);
+        // When deleting row(s) or column(s), allocate the last column
+        // before updating the references
+        if (nDx < 0 || nDy < 0)
+            CreateColumnIfNotExists(rDocument.MaxCol());
+
+        for (SCCOL col : GetColumnsRange(0, rDocument.MaxCol()))
+            bUpdated |= CreateColumnIfNotExists(col).UpdateReference(rCxt, 
pUndoDoc);
     }
 
     if ( bIncludeDraw )
commit 298d635abf103bfbfb1d3374b49799b775449b0e
Author:     Michael Stahl <[email protected]>
AuthorDate: Fri May 12 17:45:45 2023 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Fri Jun 30 00:52:47 2023 +0200

    tdf#155324 sw: layout: try not to MoveFwd onto a page created by page break
    
    There is a ToX that is updated; it has about 4 pages worth of entries.
    
    When the old entries are deleted, 2 of the pages become empty, and since
    commit b9ef71476fd70bc13f50ebe80390e0730d1b7afb these pages are deleted.
    
    While layouting the new entries, these are moved onto the page following
    the ToX, which starts with a page break and contains lots of footnotes.
    
    Now the footnotes reduce the space on the page available for the ToX
    entries, and thus after CalcLayout() there are 5 ToX pages instead of 4.
    
    Then the page numbers are inserted into the entries, and another layout
    action deletes one of the ToX pages; now all the page numbers are too
    large by 1.
    
    Some ideas to fix this:
    1) ignore a footnote when formatting a frame that is before the
       footnote anchor frame; similar to commit
       c79bf7865bff4e88cc201357370d8faeef8e6ad9
    2) invalidate the last content on the page when moving forward the
       footnote container, similar to commit
       eb85de8e6b61fb3fcb6c03ae0145f7fe5478bccf; this doesn't look easy to
       do because as it turns out the footnote container is moved in
       SwLayoutFrame::Cut() 5 function calls inside MoveFwd() while the frame
       on which MoveFwd() is called is still on the page, so would probably
       somehow need to be detected in MoveFwd() itself?
    3) don't move frames forward onto a page that was created by a page
       break - instead create a new frame.
    
    Let's try 3) for now, only in SwFrame::GetNextSctLeaf().
    
    (regression from commit b9ef71476fd70bc13f50ebe80390e0730d1b7afb)
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151711
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit 325fe7ab507fd8f2ca17a3db32181edf30169525)
    
    tdf#155324 sw: add unit test
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151876
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit 247738a9afeeb2f0644fa0307b7023fe115fae83)
    
    Change-Id: I641f586799a5ddb4e2a6ff8e9de784e422ecc214
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151889
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <[email protected]>

diff --git a/sw/qa/extras/layout/data/tox-update-wrong-pages.odt 
b/sw/qa/extras/layout/data/tox-update-wrong-pages.odt
new file mode 100644
index 000000000000..40ceb7ac4bd2
Binary files /dev/null and 
b/sw/qa/extras/layout/data/tox-update-wrong-pages.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index c88d698ebc95..021114bd070e 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -5117,6 +5117,40 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testTdf54465_ColumnsWithFootnoteDoNotOccupy
     assertXPath(pXmlDoc, "/root/page", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155324)
+{
+    createSwDoc("tox-update-wrong-pages.odt");
+
+    dispatchCommand(mxComponent, ".uno:UpdateAllIndexes", {});
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+    // the problem was that the first entry was on page 7, 2nd on page 9 etc.
+    assertXPath(pXmlDoc,
+                
"/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
+                "portion", "Foo");
+    assertXPath(pXmlDoc,
+                
"/root/page[1]/body/section[2]/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
+                "portion", "5");
+    assertXPath(pXmlDoc,
+                
"/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
+                "portion", "bar");
+    assertXPath(pXmlDoc,
+                
"/root/page[1]/body/section[2]/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
+                "portion", "7");
+    assertXPath(pXmlDoc,
+                
"/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[1]",
+                "portion", "Three");
+    assertXPath(pXmlDoc,
+                
"/root/page[1]/body/section[2]/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion[2]",
+                "portion", "7");
+
+    // check first content page has the footnotes
+    assertXPath(pXmlDoc, 
"/root/page[5]/body/txt[1]/SwParaPortion/SwLineLayout", "portion", "Foo");
+    assertXPath(pXmlDoc, "/root/page[4]/ftncont", 0);
+    assertXPath(pXmlDoc, "/root/page[5]/ftncont/ftn", 5);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index 0aaa4d2c05c3..5cabab690b61 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -158,6 +158,7 @@ SwTwips CalcRowRstHeight( SwLayoutFrame *pRow );
 tools::Long CalcHeightWithFlys( const SwFrame *pFrame );
 
 namespace sw {
+    bool HasPageBreakBefore(SwPageFrame const& rPage);
     bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 nPageNum);
     class FlyCreationSuppressor
     {
diff --git a/sw/source/core/layout/flowfrm.cxx 
b/sw/source/core/layout/flowfrm.cxx
index 68bde26d59b7..41b6b8fff953 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -904,6 +904,26 @@ SwLayoutFrame *SwFrame::GetLeaf( MakePageType eMakePage, 
bool bFwd )
     return bFwd ? GetNextLeaf( eMakePage ) : GetPrevLeaf();
 }
 
+namespace sw {
+
+bool HasPageBreakBefore(SwPageFrame const& rPage)
+{
+    SwFrame const* pFlow(rPage.FindFirstBodyContent());
+    if (!pFlow)
+    {
+        return false;
+    }
+    while (pFlow->GetUpper()->IsInTab())
+    {
+        pFlow = pFlow->GetUpper()->FindTabFrame();
+    }
+    return pFlow->GetPageDescItem().GetPageDesc()
+        || pFlow->GetBreakItem().GetBreak() == SvxBreak::PageBefore
+        || pFlow->GetBreakItem().GetBreak() == SvxBreak::PageBoth;
+};
+
+} // namespace sw
+
 bool SwFrame::WrongPageDesc( SwPageFrame* pNew )
 {
     // Now it's getting a bit complicated:
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index b9249de5c340..b6890aec917b 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -1756,7 +1756,8 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType 
eMakePage )
             // case pLayLeaf points to our section's cell's follow, which is
             // fine to be on the same page. New page creation is handled when
             // creating / moving the cell frame.
-            if( WrongPageDesc( pNxtPg ) && !bLayLeafTableAllowed )
+            // It doesn't make sense to move to a page that starts with break?
+            if ((WrongPageDesc(pNxtPg) || HasPageBreakBefore(*pNxtPg)) && 
!bLayLeafTableAllowed)
             {
                 if( bWrongPage )
                     break; // there's a column between me and my right page

Reply via email to