sc/source/ui/drawfunc/chartsh.cxx             |    4 +--
 sc/source/ui/drawfunc/drawsh.cxx              |    2 -
 sc/source/ui/drawfunc/drawsh2.cxx             |   14 ++++++-------
 sc/source/ui/drawfunc/drawsh5.cxx             |   16 +++++++--------
 sc/source/ui/drawfunc/drformsh.cxx            |    4 +--
 sc/source/ui/drawfunc/drtxtob.cxx             |    4 +--
 sc/source/ui/drawfunc/drtxtob1.cxx            |    2 -
 sc/source/ui/drawfunc/fudraw.cxx              |    2 -
 sc/source/ui/drawfunc/fuins1.cxx              |    4 +--
 sc/source/ui/drawfunc/fuins2.cxx              |   16 +++++++--------
 sc/source/ui/drawfunc/fusel.cxx               |    2 -
 sc/source/ui/drawfunc/graphsh.cxx             |    8 +++----
 sc/source/ui/drawfunc/mediash.cxx             |    2 -
 sc/source/ui/drawfunc/oleobjsh.cxx            |    4 +--
 sw/inc/docary.hxx                             |    6 +++--
 sw/source/core/doc/DocumentRedlineManager.cxx |    7 +++++-
 sw/source/core/doc/docredln.cxx               |   27 ++++++++++++++++++++++++++
 17 files changed, 79 insertions(+), 45 deletions(-)

New commits:
commit ec49191e58df2f5cb37e2608f3262e9604385fb0
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri May 31 09:57:45 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Jun 1 10:23:29 2024 +0200

    loplugin:ostr in sc/../drawfunc
    
    Change-Id: I5191883a86a004f2e7c283dc0e0e77de2f7eda04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168281
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sc/source/ui/drawfunc/chartsh.cxx 
b/sc/source/ui/drawfunc/chartsh.cxx
index e6378a5fa9cb..7a0a63b76195 100644
--- a/sc/source/ui/drawfunc/chartsh.cxx
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -61,7 +61,7 @@ void ScChartShell::InitInterface_Impl()
                                             SfxVisibilityFlags::Standard | 
SfxVisibilityFlags::Server,
                                             ToolbarId::Draw_Objectbar);
 
-    GetStaticInterface()->RegisterPopupMenu("oleobject");
+    GetStaticInterface()->RegisterPopupMenu(u"oleobject"_ustr);
 }
 
 void ScChartShell::Activate(bool bMDI)
@@ -97,7 +97,7 @@ void ScChartShell::Deactivate(bool bMDI)
 ScChartShell::ScChartShell(ScViewData& rData) :
     ScDrawShell(rData)
 {
-    SetName( "ChartObject" );
+    SetName( u"ChartObject"_ustr );
     
SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Chart));
 }
 
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index 2e11d3817ee5..53ca99000933 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -92,7 +92,7 @@ void ScDrawShell::InitInterface_Impl()
                                             SfxVisibilityFlags::Standard | 
SfxVisibilityFlags::Server,
                                             ToolbarId::Draw_Objectbar);
 
-    GetStaticInterface()->RegisterPopupMenu("draw");
+    GetStaticInterface()->RegisterPopupMenu(u"draw"_ustr);
 
     
GetStaticInterface()->RegisterChildWindow(SvxFontWorkChildWindow::GetChildWindowId());
 }
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx 
b/sc/source/ui/drawfunc/drawsh2.cxx
index fddc50fe5c13..418d92d00f32 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -72,7 +72,7 @@ ScDrawShell::ScDrawShell( ScViewData& rData ) :
     {
         pMgr->SetMaxUndoActionCount( 0 );
     }
-    SetName("Drawing");
+    SetName(u"Drawing"_ustr);
 
     mpSelectionChangeHandler->Connect();
 }
@@ -341,12 +341,12 @@ static void setupFillColorForChart(const SfxViewShell* 
pShell, SfxItemSet& rSet)
     if (!xInfo.is())
         return;
 
-    if (xInfo->hasPropertyByName("FillColor"))
+    if (xInfo->hasPropertyByName(u"FillColor"_ustr))
     {
         sal_uInt32 nFillColor = 0;
-        xPropSet->getPropertyValue("FillColor") >>= nFillColor;
+        xPropSet->getPropertyValue(u"FillColor"_ustr) >>= nFillColor;
 
-        XFillColorItem aFillColorItem("", Color(ColorTransparency, 
nFillColor));
+        XFillColorItem aFillColorItem(u""_ustr, Color(ColorTransparency, 
nFillColor));
         rSet.Put(aFillColorItem);
 
         if (comphelper::LibreOfficeKit::isActive())
@@ -354,11 +354,11 @@ static void setupFillColorForChart(const SfxViewShell* 
pShell, SfxItemSet& rSet)
                     (".uno:FillColor=" + OString::number(nFillColor)));
     }
 
-    if (!(comphelper::LibreOfficeKit::isActive() && 
xInfo->hasPropertyByName("FillGradientName")))
+    if (!(comphelper::LibreOfficeKit::isActive() && 
xInfo->hasPropertyByName(u"FillGradientName"_ustr)))
         return;
 
     OUString aGradientName;
-    xPropSet->getPropertyValue("FillGradientName") >>= aGradientName;
+    xPropSet->getPropertyValue(u"FillGradientName"_ustr) >>= aGradientName;
 
     ::css::uno::Reference< ::css::frame::XController > xChartController = 
xChart->getCurrentController();
     if( !xChartController.is() )
@@ -370,7 +370,7 @@ static void setupFillColorForChart(const SfxViewShell* 
pShell, SfxItemSet& rSet)
         return;
 
     css::uno::Reference<css::container::XNameAccess> xNameAccess(
-        xFact->createInstance("com.sun.star.drawing.GradientTable"), 
css::uno::UNO_QUERY);
+        xFact->createInstance(u"com.sun.star.drawing.GradientTable"_ustr), 
css::uno::UNO_QUERY);
 
     if (xNameAccess.is() && xNameAccess->hasByName(aGradientName))
     {
diff --git a/sc/source/ui/drawfunc/drawsh5.cxx 
b/sc/source/ui/drawfunc/drawsh5.cxx
index b3f344730aba..58b3f3538da6 100644
--- a/sc/source/ui/drawfunc/drawsh5.cxx
+++ b/sc/source/ui/drawfunc/drawsh5.cxx
@@ -81,7 +81,7 @@ void ScDrawShell::GetHLinkState( SfxItemSet& rSet )           
  //  Hyperlink
             uno::Reference< beans::XPropertySet > xPropSet( xControlModel, 
uno::UNO_QUERY );
             uno::Reference< beans::XPropertySetInfo > xInfo = 
xPropSet->getPropertySetInfo();
 
-            OUString sPropButtonType( "ButtonType" );
+            OUString sPropButtonType( u"ButtonType"_ustr );
 
             if(xInfo->hasPropertyByName( sPropButtonType ))
             {
@@ -91,7 +91,7 @@ void ScDrawShell::GetHLinkState( SfxItemSet& rSet )           
  //  Hyperlink
                 {
                     OUString sTmp;
                     // Label
-                    OUString sPropLabel( "Label" );
+                    OUString sPropLabel( u"Label"_ustr );
                     if(xInfo->hasPropertyByName( sPropLabel ))
                     {
                         aAny = xPropSet->getPropertyValue( sPropLabel );
@@ -101,7 +101,7 @@ void ScDrawShell::GetHLinkState( SfxItemSet& rSet )         
    //  Hyperlink
                         }
                     }
                     // URL
-                    OUString sPropTargetURL( "TargetURL" );
+                    OUString sPropTargetURL( u"TargetURL"_ustr );
                     if(xInfo->hasPropertyByName( sPropTargetURL ))
                     {
                         aAny = xPropSet->getPropertyValue( sPropTargetURL );
@@ -111,7 +111,7 @@ void ScDrawShell::GetHLinkState( SfxItemSet& rSet )         
    //  Hyperlink
                         }
                     }
                     // Target
-                    OUString sPropTargetFrame( "TargetFrame" );
+                    OUString sPropTargetFrame( u"TargetFrame"_ustr );
                     if(xInfo->hasPropertyByName( sPropTargetFrame ))
                     {
                         aAny = xPropSet->getPropertyValue( sPropTargetFrame );
@@ -168,15 +168,15 @@ void ScDrawShell::ExecuteHLink( const SfxRequest& rReq )
                                 uno::Reference< beans::XPropertySet > 
xPropSet( xControlModel, uno::UNO_QUERY );
                                 uno::Reference< beans::XPropertySetInfo > 
xInfo = xPropSet->getPropertySetInfo();
 
-                                OUString sPropTargetURL( "TargetURL" );
+                                OUString sPropTargetURL( u"TargetURL"_ustr );
 
                                 // Is it possible to set a URL in the object?
                                 if (xInfo->hasPropertyByName( sPropTargetURL ))
                                 {
 
-                                    OUString sPropButtonType( "ButtonType");
-                                    OUString sPropTargetFrame( "TargetFrame" );
-                                    OUString sPropLabel( "Label" );
+                                    OUString sPropButtonType( 
u"ButtonType"_ustr);
+                                    OUString sPropTargetFrame( 
u"TargetFrame"_ustr );
+                                    OUString sPropLabel( u"Label"_ustr );
 
                                     if ( xInfo->hasPropertyByName( sPropLabel 
) )
                                     {
diff --git a/sc/source/ui/drawfunc/drformsh.cxx 
b/sc/source/ui/drawfunc/drformsh.cxx
index b91e08646be7..0c804f23f441 100644
--- a/sc/source/ui/drawfunc/drformsh.cxx
+++ b/sc/source/ui/drawfunc/drformsh.cxx
@@ -37,14 +37,14 @@ void ScDrawFormShell::InitInterface_Impl()
                                             SfxVisibilityFlags::Standard | 
SfxVisibilityFlags::Server,
                                             ToolbarId::Objectbar_Format);
 
-    GetStaticInterface()->RegisterPopupMenu("form");
+    GetStaticInterface()->RegisterPopupMenu(u"form"_ustr);
 }
 
 
 ScDrawFormShell::ScDrawFormShell(ScViewData& rData) :
     ScDrawShell(rData)
 {
-    SetName("DrawForm");
+    SetName(u"DrawForm"_ustr);
     
SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Form));
 }
 
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index 914a2e49b0e7..6138b29120e4 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -89,7 +89,7 @@ void ScDrawTextObjectBar::InitInterface_Impl()
                                             SfxVisibilityFlags::Standard | 
SfxVisibilityFlags::Server,
                                             ToolbarId::Text_Toolbox_Sc);
 
-    GetStaticInterface()->RegisterPopupMenu("drawtext");
+    GetStaticInterface()->RegisterPopupMenu(u"drawtext"_ustr);
 
     GetStaticInterface()->RegisterChildWindow(ScGetFontWorkId());
 }
@@ -124,7 +124,7 @@ ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData& rData) 
:
         pMgr->SetMaxUndoActionCount( 0 );
     }
 
-    SetName("DrawText");
+    SetName(u"DrawText"_ustr);
     
SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::DrawText));
 }
 
diff --git a/sc/source/ui/drawfunc/drtxtob1.cxx 
b/sc/source/ui/drawfunc/drtxtob1.cxx
index 4810876a33c4..10974d1e5be2 100644
--- a/sc/source/ui/drawfunc/drtxtob1.cxx
+++ b/sc/source/ui/drawfunc/drtxtob1.cxx
@@ -46,7 +46,7 @@ bool ScDrawTextObjectBar::ExecuteCharDlg( const SfxItemSet& 
rArgs,
         mrViewData.GetSfxDocShell(), true));
     if (nSlot == SID_CHAR_DLG_EFFECT)
     {
-        pDlg->SetCurPageId("fonteffects");
+        pDlg->SetCurPageId(u"fonteffects"_ustr);
     }
     bool bRet = ( pDlg->Execute() == RET_OK );
 
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
index 1e0c0e5f8ad5..f7c92e396474 100644
--- a/sc/source/ui/drawfunc/fudraw.cxx
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -199,7 +199,7 @@ bool FuDraw::KeyInput(const KeyEvent& rKEvt)
         case KEY_ESCAPE:
             if ( rViewShell.IsDrawTextShell() || aSfxRequest.GetSlot() == 
SID_DRAW_NOTEEDIT )
             {
-                collectUIInformation("CLOSE");
+                collectUIInformation(u"CLOSE"_ustr);
                 // if object selected -> normal draw-shell, else turn off 
drawing
                 rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), 
SfxCallMode::SLOT | SfxCallMode::RECORD);
                 bReturn = true;
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index aa51747f864f..886d2b29ecf3 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -256,7 +256,7 @@ static void lcl_InsertMedia( const OUString& rMediaURL, 
bool bApi,
         *rData.GetDocument().GetDrawLayer(),
         tools::Rectangle(aInsertPos, aSize));
 
-    pObj->setURL( realURL, ""/*TODO?*/ );
+    pObj->setURL( realURL, u""_ustr/*TODO?*/ );
     pView->InsertObjectAtView( pObj.get(), *pPV, bApi ? 
SdrInsertFlags::DONTMARK : SdrInsertFlags::NONE );
 }
 #endif
@@ -433,7 +433,7 @@ FuInsertMedia::FuInsertMedia( ScTabViewShell&   rViewSh,
                 avmedia::MediaWindow::dispatchInsertAVMedia(xDispatchProvider, 
aSize, aURL, bLink);
             }));
 
-        const bool bIsMediaURL = ::avmedia::MediaWindow::isMediaURL(aURL, 
""/*TODO?*/, true, xPlayerListener);
+        const bool bIsMediaURL = ::avmedia::MediaWindow::isMediaURL(aURL, 
u""_ustr/*TODO?*/, true, xPlayerListener);
 
         if( pWin )
             pWin->LeaveWait();
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 4d34208b7ec6..cac0c9f3e53a 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -185,16 +185,16 @@ void lcl_ChartInit(const uno::Reference 
<embed::XEmbeddedObject>& xObj, ScViewDa
 
     uno::Sequence< beans::PropertyValue > aArgs{
         beans::PropertyValue(
-            "CellRangeRepresentation", -1,
+            u"CellRangeRepresentation"_ustr, -1,
             uno::Any( aRangeString ), beans::PropertyState_DIRECT_VALUE ),
         beans::PropertyValue(
-            "HasCategories", -1,
+            u"HasCategories"_ustr, -1,
             uno::Any( bHasCategories ), beans::PropertyState_DIRECT_VALUE ),
         beans::PropertyValue(
-            "FirstCellAsLabel", -1,
+            u"FirstCellAsLabel"_ustr, -1,
             uno::Any( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ),
         beans::PropertyValue(
-            "DataRowSource", -1,
+            u"DataRowSource"_ustr, -1,
             uno::Any( eDataRowSource ), beans::PropertyState_DIRECT_VALUE )
     };
 
@@ -638,7 +638,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, 
vcl::Window* pWin, ScDrawV
             {
                 
css::uno::Reference<css::ui::dialogs::XAsynchronousExecutableDialog> xDialog(
                     xMCF->createInstanceWithContext(
-                        "com.sun.star.comp.chart2.WizardDialog"
+                        u"com.sun.star.comp.chart2.WizardDialog"_ustr
                         , xContext), uno::UNO_QUERY);
                 uno::Reference< lang::XInitialization > xInit( xDialog, 
uno::UNO_QUERY );
                 if( xChartModel.is() && xInit.is() )
@@ -660,7 +660,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, 
vcl::Window* pWin, ScDrawV
                         {
                             //get dialog size:
                             awt::Size aDialogAWTSize;
-                            if( xDialogProps->getPropertyValue("Size")
+                            if( xDialogProps->getPropertyValue(u"Size"_ustr)
                                 >>= aDialogAWTSize )
                             {
                                 Size aDialogSize( aDialogAWTSize.Width, 
aDialogAWTSize.Height );
@@ -668,12 +668,12 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, 
vcl::Window* pWin, ScDrawV
                                 {
                                     //calculate and set new position
                                     Point aDialogPos = 
rViewShell.GetChartDialogPos( aDialogSize, aRect );
-                                    xDialogProps->setPropertyValue("Position",
+                                    
xDialogProps->setPropertyValue(u"Position"_ustr,
                                         uno::Any( 
awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) );
                                 }
                             }
                             //tell the dialog to unlock controller
-                            
xDialogProps->setPropertyValue("UnlockControllersOnExecute",
+                            
xDialogProps->setPropertyValue(u"UnlockControllersOnExecute"_ustr,
                                         uno::Any( true ) );
 
                         }
diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx
index a88acf7b3fc0..7d0174380722 100644
--- a/sc/source/ui/drawfunc/fusel.cxx
+++ b/sc/source/ui/drawfunc/fusel.cxx
@@ -191,7 +191,7 @@ bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
                            {
                                try
                                {
-                                   aCaller = xProps->getPropertyValue("Name");
+                                   aCaller = 
xProps->getPropertyValue(u"Name"_ustr);
                                }
                                catch( uno::Exception& ) {}
                            }
diff --git a/sc/source/ui/drawfunc/graphsh.cxx 
b/sc/source/ui/drawfunc/graphsh.cxx
index 05fac4b1a04f..71420be473b7 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -46,14 +46,14 @@ void ScGraphicShell::InitInterface_Impl()
                                             SfxVisibilityFlags::Standard | 
SfxVisibilityFlags::Server,
                                             ToolbarId::Graphic_Objectbar);
 
-    GetStaticInterface()->RegisterPopupMenu("graphic");
+    GetStaticInterface()->RegisterPopupMenu(u"graphic"_ustr);
 }
 
 
 ScGraphicShell::ScGraphicShell(ScViewData& rData) :
     ScDrawShell(rData)
 {
-    SetName("GraphicObject");
+    SetName(u"GraphicObject"_ustr);
     
SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Graphic));
 }
 
@@ -284,12 +284,12 @@ void ScGraphicShell::ExecuteSaveGraphic( 
SAL_UNUSED_PARAMETER SfxRequest& /*rReq
 
             if (nState == RET_YES)
             {
-                GraphicHelper::ExportGraphic(pWinFrame, 
pObj->GetTransformedGraphic(), "");
+                GraphicHelper::ExportGraphic(pWinFrame, 
pObj->GetTransformedGraphic(), u""_ustr);
             }
             else if (nState == RET_NO)
             {
                 const GraphicObject& aGraphicObject(pObj->GetGraphicObject());
-                GraphicHelper::ExportGraphic(pWinFrame, 
aGraphicObject.GetGraphic(), "");
+                GraphicHelper::ExportGraphic(pWinFrame, 
aGraphicObject.GetGraphic(), u""_ustr);
             }
         }
     }
diff --git a/sc/source/ui/drawfunc/mediash.cxx 
b/sc/source/ui/drawfunc/mediash.cxx
index f5b3350ba6a6..438f7a2c9bdb 100644
--- a/sc/source/ui/drawfunc/mediash.cxx
+++ b/sc/source/ui/drawfunc/mediash.cxx
@@ -39,7 +39,7 @@ void ScMediaShell::InitInterface_Impl()
     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, 
SfxVisibilityFlags::Invisible,
                                             ToolbarId::Media_Objectbar);
 
-    GetStaticInterface()->RegisterPopupMenu("media");
+    GetStaticInterface()->RegisterPopupMenu(u"media"_ustr);
 }
 
 ScMediaShell::ScMediaShell(ScViewData& rData)
diff --git a/sc/source/ui/drawfunc/oleobjsh.cxx 
b/sc/source/ui/drawfunc/oleobjsh.cxx
index 0e9f0075d904..afc0a61d655c 100644
--- a/sc/source/ui/drawfunc/oleobjsh.cxx
+++ b/sc/source/ui/drawfunc/oleobjsh.cxx
@@ -33,14 +33,14 @@ void ScOleObjectShell::InitInterface_Impl()
                                             SfxVisibilityFlags::Standard | 
SfxVisibilityFlags::Server,
                                             ToolbarId::Draw_Objectbar);
 
-    GetStaticInterface()->RegisterPopupMenu("oleobject");
+    GetStaticInterface()->RegisterPopupMenu(u"oleobject"_ustr);
 }
 
 
 ScOleObjectShell::ScOleObjectShell(ScViewData& rData) :
     ScDrawShell(rData)
 {
-    SetName("OleObject");
+    SetName(u"OleObject"_ustr);
     
SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::OLE));
 }
 
commit a06946271e7139352501e0840256402ac43f4c65
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri May 31 13:51:07 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Jun 1 10:23:17 2024 +0200

    tdf#144208 speedup doc with lots of redline
    
    This takes my load time from 48s to 6s.
    
    The specific problem site is DocumentRedlineManager::SplitRedline,
    which is hard hit when loading DOCX files.
    Speed it up by caching the redline with the max end pos, which works
    because most of the time we are trying to split around a position
    which is the past of the end of the existing redlines.
    
    Possibly a better solution would be not to call SplitRedline
    at all, but propogating that information around is tricky given
    that we are crossing module boundaries here, calling from xmloff/
    into sw/
    
    Change-Id: Ia8e5703c1cc9e861e27a24c24f207f12e594ff44
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167892
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index abe0adeecf8e..55ae1c7eb478 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -29,6 +29,7 @@
 #include "tox.hxx"
 #include "numrule.hxx"
 #include "fldbas.hxx"
+#include "pam.hxx"
 
 class SwRangeRedline;
 class SwExtraRedline;
@@ -36,7 +37,6 @@ class SwOLENode;
 class SwTable;
 class SwTableLine;
 class SwTableBox;
-struct SwPosition;
 enum class RedlineType : sal_uInt16;
 
 /** provides some methods for generic operations on lists that contain 
SwFormat* subclasses. */
@@ -227,6 +227,7 @@ private:
     /// fast binary search, or if we have to fall back to a linear search
     bool m_bHasOverlappingElements = false;
     mutable sal_uInt32 m_nMaxMovedID = 1;   //every move-redline pair get a 
unique ID, so they can find each other.
+    mutable const SwRangeRedline* mpMaxEndPos = nullptr; // the redline with 
the maximum end pos
 public:
     ~SwRedlineTable();
     bool Contains(const SwRangeRedline* p) const { return maVector.find(p) != 
maVector.end(); }
@@ -236,6 +237,7 @@ public:
     bool Insert(SwRangeRedline*& p, size_type& rInsPos);
     bool InsertWithValidRanges(SwRangeRedline*& p, size_type* pInsPos = 
nullptr);
     bool HasOverlappingElements() const { return m_bHasOverlappingElements; }
+    const SwPosition& GetMaxEndPos() const;
 
     void Remove( size_type nPos );
     void Remove( const SwRangeRedline* p );
@@ -276,7 +278,7 @@ public:
     SwRangeRedline*             operator[]( size_type idx ) const { return 
maVector[idx]; }
     vector_type::const_iterator begin() const { return maVector.begin(); }
     vector_type::const_iterator end() const { return maVector.end(); }
-    void                        Resort() { maVector.Resort(); }
+    void                        Resort() { maVector.Resort(); mpMaxEndPos = 
nullptr; }
 
     // Notifies all LOK clients when redlines are added/modified/removed
     static void                 LOKRedlineNotification(RedlineNotification 
eType, SwRangeRedline* pRedline);
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 710baaf41b94..6e287c6fb91f 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2599,8 +2599,13 @@ void DocumentRedlineManager::CompressRedlines(size_t 
nStartIndex)
 
 bool DocumentRedlineManager::SplitRedline( const SwPaM& rRange )
 {
-    bool bChg = false;
+    if (maRedlineTable.empty())
+        return false;
     auto [pStt, pEnd] = rRange.StartEnd(); // SwPosition*
+    // tdf#144208 this happens a lot during load of some DOCX files.
+    if (*pEnd > maRedlineTable.GetMaxEndPos())
+        return false;
+    bool bChg = false;
     SwRedlineTable::size_type n = 0;
     //FIXME overlapping problem GetRedline( *pStt, &n );
     for ( ; n < maRedlineTable.size(); ++n)
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 9860964a89d6..fe1c917ba9c3 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -443,7 +443,11 @@ bool SwRedlineTable::Insert(SwRangeRedline*& p)
 
         p->CallDisplayFunc(nP);
         if (rv.second)
+        {
             CheckOverlapping(rv.first);
+            if (!mpMaxEndPos || (*(*rv.first)->End()) > *mpMaxEndPos->End())
+                mpMaxEndPos = *rv.first;
+        }
         return rv.second;
     }
     return InsertWithValidRanges( p );
@@ -482,7 +486,11 @@ bool SwRedlineTable::Insert(SwRangeRedline*& p, size_type& 
rP)
         rP = rv.first - begin();
         p->CallDisplayFunc(rP);
         if (rv.second)
+        {
             CheckOverlapping(rv.first);
+            if (!mpMaxEndPos || (*(*rv.first)->End()) > *mpMaxEndPos->End())
+                mpMaxEndPos = *rv.first;
+        }
         return rv.second;
     }
     return InsertWithValidRanges( p, &rP );
@@ -683,6 +691,8 @@ void SwRedlineTable::Remove( size_type nP )
     if( !nP && 1 == size() )
         pDoc = &maVector.front()->GetDoc();
 
+    if (mpMaxEndPos == maVector[nP])
+        mpMaxEndPos = nullptr;
     maVector.erase( maVector.begin() + nP );
 
     if( pDoc && !pDoc->IsInDtor() )
@@ -703,6 +713,7 @@ void SwRedlineTable::DeleteAndDestroyAll()
         delete pRedline;
     }
     m_bHasOverlappingElements = false;
+    mpMaxEndPos = nullptr;
 }
 
 void SwRedlineTable::DeleteAndDestroy(size_type const nP)
@@ -711,6 +722,8 @@ void SwRedlineTable::DeleteAndDestroy(size_type const nP)
     maVector.erase(maVector.begin() + nP);
     LOKRedlineNotification(RedlineNotification::Remove, pRedline);
     delete pRedline;
+    if (pRedline == mpMaxEndPos)
+        mpMaxEndPos = nullptr;
 }
 
 SwRedlineTable::size_type SwRedlineTable::FindNextOfSeqNo( size_type nSttPos ) 
const
@@ -831,6 +844,20 @@ bool lcl_CanCombineWithRange(SwRangeRedline* pOrigin, 
SwRangeRedline* pActual,
 }
 }
 
+const SwPosition& SwRedlineTable::GetMaxEndPos() const
+{
+    assert(!empty() && "cannot call this when the redline table is empty");
+    if (mpMaxEndPos)
+        return *mpMaxEndPos->End();
+    for (const SwRangeRedline* i : maVector)
+    {
+        if (!mpMaxEndPos || *i->End() > *mpMaxEndPos->End())
+            mpMaxEndPos = i;
+    }
+    assert(mpMaxEndPos);
+    return *mpMaxEndPos->End();
+}
+
 void SwRedlineTable::getConnectedArea(size_type nPosOrigin, size_type& 
rPosStart,
                                       size_type& rPosEnd, bool bCheckChilds) 
const
 {

Reply via email to