core.git: Branch 'libreoffice-24-2-0' - sw/source

2024-01-26 Thread Michael Stahl (via logerrit)
 sw/source/core/text/itrcrsr.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 117fa5a2199a06e11eddf8d007704bdae68ea02d
Author: Michael Stahl 
AuthorDate: Tue Jan 23 18:23:12 2024 +0100
Commit: Miklos Vajna 
CommitDate: Fri Jan 26 09:49:11 2024 +0100

sw: fix crash in SwTextCursor::GetModelPositionForViewPoint()

With a field that spans 3 SwTextFrames, it happens that
rText[sal_Int32(nCurrStart + nLength) - 1]
results in rText[-1]; it looks like both nCurrStart and nLength are
correct (nCurrStart was decremented in line 1531 after "if (bFieldInfo)")
so there is a missing check here.

Change-Id: I0d5be617e8e54c20dc8633efd3a7d82510f4acd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162522
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 42a315b4a777dc371297752b6233e437d36c456b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162546
Reviewed-by: Xisco Fauli 
Reviewed-by: Christian Lohmaier 
Reviewed-by: Ilmari Lauhakangas 
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 30b605cac011..a39eb77301ba 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1621,8 +1621,11 @@ TextFrameIndex 
SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
 
 // Skip space at the end of the line
 if( bLastPortion && (m_pCurr->GetNext() || m_pFrame->GetFollow() )
-&& rText[sal_Int32(nCurrStart + nLength) - 1] == ' ' )
+&& sal_Int32(nLength) != 0
+&& rText[sal_Int32(nCurrStart + nLength) - 1] == ' ')
+{
 --nLength;
+}
 
 if( nWidth > nX ||
   ( nWidth == nX && pPor->IsMultiPortion() && 
static_cast(pPor)->IsDouble() ) )


core.git: Branch 'libreoffice-24-2-0' - sw/source

2024-01-24 Thread Jim Raykowski (via logerrit)
 sw/source/uibase/utlui/content.cxx |   20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 553b91ef4204d0d6473f45ceadb76d6e24a08879
Author: Jim Raykowski 
AuthorDate: Fri Jan 12 23:56:43 2024 -0900
Commit: Michael Weghorn 
CommitDate: Wed Jan 24 09:27:42 2024 +0100

tdf#159147 Fix crash when editing hyperlink while navigator is open

by assuring the SwURLFieldContent::SwTextINetFormat pointer is still
valid before trying to bring the hyperlink content to attention

Change-Id: I7f672576ab2869c5483284b543e99e46a558acc9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162013
Tested-by: Jenkins
Tested-by: Xisco Fauli 
Reviewed-by: Jim Raykowski 
(cherry picked from commit b2500f0e32b33eec2740dc370238f66fb8b50ffb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162212
Reviewed-by: Xisco Fauli 
(cherry picked from commit a6ce9960c37928cb8a27383dc8e10125011131c9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162216
Reviewed-by: Hossein 
Reviewed-by: Michael Stahl 
Reviewed-by: Ilmari Lauhakangas 
Tested-by: Michael Weghorn 
Reviewed-by: Michael Weghorn 

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 72fd76cbe1ce..3bf29979ddf3 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -6077,8 +6077,24 @@ void SwContentTree::BringEntryToAttention(const 
weld::TreeIter& rEntry)
 }
 else if (nType == ContentTypeId::URLFIELD)
 {
-BringURLFieldsToAttention(SwGetINetAttrs 
{SwGetINetAttr(pCnt->GetName(),
-
*static_cast(pCnt)->GetINetAttr())});
+// tdf#159147 - Assure the SwURLFieldContent::SwTextINetFormat 
pointer is valid
+// before bringing to attention.
+const SwTextINetFormat* pTextINetFormat
+= static_cast(pCnt)->GetINetAttr();
+const SwCharFormats* pFormats = 
m_pActiveShell->GetDoc()->GetCharFormats();
+for (auto n = pFormats->size(); 1 < n;)
+{
+SwIterator 
aIter(*(*pFormats)[--n]);
+for (SwTextINetFormat* pFnd = aIter.First(); pFnd; pFnd = 
aIter.Next() )
+{
+if (pTextINetFormat == pFnd)
+{
+BringURLFieldsToAttention(SwGetINetAttrs 
{SwGetINetAttr(pCnt->GetName(),
+  
*pTextINetFormat)});
+break;
+}
+}
+}
 }
 else if (nType == ContentTypeId::REFERENCE)
 {


core.git: Branch 'libreoffice-24-2-0' - sw/source

2024-01-23 Thread Patrick Luby (via logerrit)
 sw/source/core/undo/untbl.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 0989275534bda8cd559e80b8579bba7271344e7d
Author: Patrick Luby 
AuthorDate: Sat Jan 13 17:57:56 2024 -0500
Commit: Patrick Luby 
CommitDate: Tue Jan 23 19:39:43 2024 +0100

tdf#159025 skip undo if SwTableNode is a nullptr

I don't know what causes the SwTableNode to be a nullptr in the
case of tdf#159025, but at least stop the crashing by skipping
this undo request.

Change-Id: Idad1ed290af215e591018ea58732b77ca504ba01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162031
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
Reviewed-by: Patrick Luby 
(cherry picked from commit f414c61f8dd2617baa0851525b8a7a630c5e34da)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162227
Reviewed-by: Michael Weghorn 
Reviewed-by: Ilmari Lauhakangas 
Tested-by: Patrick Luby 

diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 6f122e73b6da..72f1c809e227 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -272,7 +272,14 @@ void SwUndoInsTable::UndoImpl(::sw::UndoRedoContext & 
rContext)
 SwNodeIndex aIdx( rDoc.GetNodes(), m_nStartNode );
 
 SwTableNode* pTableNd = aIdx.GetNode().GetTableNode();
-OSL_ENSURE( pTableNd, "no TableNode" );
+// tdf#159025 skip undo if SwTableNode is a nullptr
+// I don't know what causes the SwTableNode to be a nullptr in the
+// case of tdf#159025, but at least stop the crashing by skipping
+// this undo request.
+SAL_WARN_IF( !pTableNd, "sw.core", "no TableNode" );
+if( !pTableNd )
+return;
+
 pTableNd->DelFrames();
 
 if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() ))