[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2022-03-14 Thread Noel Grandin (via logerrit)
 sw/inc/crstate.hxx|4 ++--
 sw/source/core/layout/trvlfrm.cxx |6 +++---
 sw/source/core/text/frmcrsr.cxx   |   12 ++--
 sw/source/core/text/itrcrsr.cxx   |   30 +++---
 4 files changed, 26 insertions(+), 26 deletions(-)

New commits:
commit e8f62db1c0ac5f9fa2510d4c0c8d2111bbeb6427
Author: Noel Grandin 
AuthorDate: Mon Mar 14 14:03:56 2022 +0200
Commit: Xisco Fauli 
CommitDate: Mon Mar 14 17:28:28 2022 +0100

tdf#147143 Word selection error in Arabic text

this reverts
commit 563af8fd15aa37e75af8882cccbdf8914ebe8e61
Author: Noel Grandin 
Date:   Fri Jan 7 22:50:29 2022 +0200
tdf#144890 Invalid selection area when text in LTR run
and
commit ec50b9e5eaec7c94df35617676077ef0d65cecc7
Author: Noel Grandin 
Date:   Thu May 27 11:16:11 2021 +0200
no need to allocate Sw2LinesPos separately on heap

No idea why the commits caused trouble, clearing there is some
"interesting" interaction going on.

Change-Id: I606768403db777b61554f378d3f69f9b4d33d493
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131533
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 22be1665dc6eb28ea1d52c7c5e4347628fc5a76b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131478
Reviewed-by: Xisco Fauli 

diff --git a/sw/inc/crstate.hxx b/sw/inc/crstate.hxx
index f3430c714787..9b223319fd93 100644
--- a/sw/inc/crstate.hxx
+++ b/sw/inc/crstate.hxx
@@ -23,7 +23,7 @@
 #include 
 #include "swrect.hxx"
 
-#include 
+#include 
 
 enum class SwFillMode
 {
@@ -132,7 +132,7 @@ enum class CursorMoveState
 struct SwCursorMoveState
 {
 SwFillCursorPos   *m_pFill; ///< for automatic filling with tabs etc
-std::optional m_x2Lines;   ///< for selections inside/around 
2line portions
+std::unique_ptr m_p2Lines;   ///< for selections 
inside/around 2line portions
 SwSpecialPos*   m_pSpecialPos; ///< for positions inside fields
 Point m_aRealHeight;  ///< contains then the position/height of 
the cursor
 CursorMoveState m_eState;
diff --git a/sw/source/core/layout/trvlfrm.cxx 
b/sw/source/core/layout/trvlfrm.cxx
index 1ad00bdc05ca..a7506ca9a13a 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -2124,11 +2124,11 @@ void SwRootFrame::CalcFrameRects(SwShellCursor )
 //ContentRects to Start- and EndFrames.
 SwRect aStRect, aEndRect;
 pStartFrame->GetCharRect( aStRect, *pStartPos,  );
-std::optional pSt2Pos = std::move(aTmpState.m_x2Lines);
+std::unique_ptr pSt2Pos = std::move(aTmpState.m_p2Lines);
 aTmpState.m_nCursorBidiLevel = pEndFrame->IsRightToLeft() ? 1 : 0;
 
 pEndFrame->GetCharRect( aEndRect, *pEndPos,  );
-std::optional pEnd2Pos = std::move(aTmpState.m_x2Lines);
+std::unique_ptr pEnd2Pos = std::move(aTmpState.m_p2Lines);
 
 SwRect aStFrame ( pStartFrame->UnionFrame( true ) );
 aStFrame.Intersection( pStartFrame->GetPaintArea() );
@@ -2145,7 +2145,7 @@ void SwRootFrame::CalcFrameRects(SwShellCursor )
 // If there's no doubleline portion involved or start and end are both
 // in the same doubleline portion, all works fine, but otherwise
 // we need the following...
-if( (!pSt2Pos && !pEnd2Pos) && ( !pSt2Pos || !pEnd2Pos ||
+if( pSt2Pos != pEnd2Pos && ( !pSt2Pos || !pEnd2Pos ||
 pSt2Pos->aPortion != pEnd2Pos->aPortion ) )
 {
 // If we have a start(end) position inside a doubleline portion
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index b120d17399a7..a4cab82d92b1 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -307,10 +307,10 @@ bool SwTextFrame::GetCharRect( SwRect& rOrig, const 
SwPosition ,
 {
 if ( pFrame->IsRightToLeft() )
 {
-if( pCMS->m_b2Lines && pCMS->m_x2Lines)
+if( pCMS->m_b2Lines && pCMS->m_p2Lines)
 {
-pFrame->SwitchLTRtoRTL( pCMS->m_x2Lines->aLine );
-pFrame->SwitchLTRtoRTL( pCMS->m_x2Lines->aPortion );
+pFrame->SwitchLTRtoRTL( pCMS->m_p2Lines->aLine );
+pFrame->SwitchLTRtoRTL( pCMS->m_p2Lines->aPortion );
 }
 }
 
@@ -327,10 +327,10 @@ bool SwTextFrame::GetCharRect( SwRect& rOrig, const 
SwPosition ,
pCMS->m_aRealHeight.Y() );
 }
 }
-if( pCMS->m_b2Lines && pCMS->m_x2Lines)
+if( pCMS->m_b2Lines && pCMS->m_p2Lines)
 {
-pFrame->SwitchHorizontalToVertical( pCMS->m_x2Lines->aLine 
);
-pFrame->SwitchHorizontalToVertical( 
pCMS->m_x2Lines->aPortion );
+pFrame->SwitchHorizontalToVertical( pCMS->m_p2Lines->aLine 
);
+   

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2022-01-24 Thread Armin Le Grand (Allotropia) (via logerrit)
 sw/inc/unochart.hxx |3 ++-
 sw/source/core/doc/docchart.cxx |   23 ++-
 sw/source/core/unocore/unochart.cxx |6 +-
 3 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit eea37aa26932d06ed8e93d001862bf45175c4446
Author: Armin Le Grand (Allotropia) 
AuthorDate: Tue Jan 18 17:43:16 2022 +0100
Commit: Armin Le Grand 
CommitDate: Mon Jan 24 14:55:05 2022 +0100

tdf#122995 Trigger Chart refresh directly in UpdateCharts for SW

For OLE/Charts in SW we do not (yet) have a refresh
mechanism or embedding of the primitive represetation, so this
needs to be done locally here (simple solution).
To have the Chart already invalidated at the next repaint,
I needed to add a 'immediate' mode to InvalidateTable.

Note: The text there claiming that the framework should do this
is correct, but as long as the mechanism is incomplete (VC/VOC/OC
in SW) direct refresh is needed.

Change-Id: I3c845b3ec46fbb494e7bce163cfe105145421450
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128572
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 
(cherry picked from commit d769e75de28a1afbb1df31b48840626cb35ed7ba)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128809
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx
index 7147f8a036eb..aee03ba4f8bc 100644
--- a/sw/inc/unochart.hxx
+++ b/sw/inc/unochart.hxx
@@ -175,7 +175,8 @@ public:
 voidRemoveDataSequence( const SwTable , 
css::uno::Reference< css::chart2::data::XDataSequence > const  );
 
 // will send modified events for all data-sequences of the table
-voidInvalidateTable( const SwTable *pTable );
+// tdf#122995 added Immediate-Mode to allow non-timer-delayed Chart 
invalidation
+voidInvalidateTable( const SwTable *pTable, bool bImmediate = 
false );
 voidDeleteBox( const SwTable *pTable, const SwTableBox  );
 voidDisposeAllDataSequences( const SwTable *pTable );
 
diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx
index cfa3f153074b..af4a3a30b48c 100644
--- a/sw/source/core/doc/docchart.cxx
+++ b/sw/source/core/doc/docchart.cxx
@@ -107,9 +107,30 @@ void SwDoc::UpdateCharts_( const SwTable& rTable, 
SwViewShell const & rVSh ) con
 aName == pONd->GetChartTableName() &&
 pONd->getLayoutFrame( rVSh.GetLayout() ) )
 {
+// tdf#122995 for OLE/Charts in SW we do not (yet) have a refresh
+// mechanism or embedding of the primitive representation, so this
+// needs to be done locally here (simplest solution).
+bool bImmediateMode(false);
+
+if(pONd->IsChart())
+{
+// refresh to trigger repaint
+const SwRect aChartRect(pONd->FindLayoutRect());
+if(!aChartRect.IsEmpty())
+const_cast(rVSh).InvalidateWindows(aChartRect);
+
+// forced refresh of the chart's primitive representation
+pONd->GetOLEObj().resetBufferedData();
+
+// InvalidateTable using the Immediate-Mode, else the chart 
will
+// not yet know that it is invalidated at the next repaint and 
create
+// the same graphical representation again
+bImmediateMode = true;
+}
+
 SwChartDataProvider *pPCD = 
getIDocumentChartDataProviderAccess().GetChartDataProvider();
 if (pPCD)
-pPCD->InvalidateTable(  );
+pPCD->InvalidateTable( , bImmediateMode );
 // following this the framework will now take care of repainting
 // the chart or it's replacement image...
 }
diff --git a/sw/source/core/unocore/unochart.cxx 
b/sw/source/core/unocore/unochart.cxx
index fc7b5414dc20..b06a8396b8cd 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1422,7 +1422,7 @@ void SwChartDataProvider::RemoveDataSequence( const 
SwTable , uno::Refere
 m_aDataSequences[  ].erase( rxDataSequence );
 }
 
-void SwChartDataProvider::InvalidateTable( const SwTable *pTable )
+void SwChartDataProvider::InvalidateTable( const SwTable *pTable, bool 
bImmediate )
 {
 OSL_ENSURE( pTable, "table pointer is NULL" );
 if (!pTable)
@@ -1442,6 +1442,10 @@ void SwChartDataProvider::InvalidateTable( const SwTable 
*pTable )
 xRef->setModified( true );
 }
 }
+
+// tdf#122995 added Immediate-mode to allow non-timer-delayed Chart 
invalidation
+if (bImmediate && !m_bDisposed)
+   
pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().Disconnect();
 }
 
 void SwChartDataProvider::DeleteBox( const SwTable *pTable, const SwTableBox 
 )


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2022-01-14 Thread Michael Stahl (via logerrit)
 sw/inc/section.hxx |3 +++
 sw/source/core/docnode/section.cxx |8 
 sw/source/core/inc/sectfrm.hxx |4 
 sw/source/core/layout/sectfrm.cxx  |   11 +++
 4 files changed, 26 insertions(+)

New commits:
commit 58d4b1aae1a599322b27ec388b62d8a6ed158ef9
Author: Michael Stahl 
AuthorDate: Mon Jan 10 16:45:33 2022 +0100
Commit: Xisco Fauli 
CommitDate: Fri Jan 14 10:47:51 2022 +0100

tdf#146605 sw: try to fix SwSectionFormat notifications

SwSectionFormat no longer notifies via its SwModify to SwClient
listeners, but only via SvtBroadcaster, so SwSection and SwSectionFrame
need to be SvtListeners.

This can be seen when changing the footnote-at-end setting in the
section dialog, if the SwSection doesn't get the event the footnote
numbers aren't adapted to a new restart value, if the SwSectionFrame
doesn't get the event the footnote container isn't moved.

This is of course not pretty but hopefully it will be refactored further
in the future.

(regression from commit 2e32f4ed5af16a68c97a50806a42ffa2d10f1d7a)

Change-Id: I93c616e209a01fc5d4c8eba701a6ddce5d5b432e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128257
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit cb188ce336e434c2b7002b3d8a41a681e73ae51a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128243
Reviewed-by: Thorsten Behrens 
(cherry picked from commit b14f5424dde966fa3764a7e5c813dc727390354c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128330
Reviewed-by: Xisco Fauli 

diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index ed777e9e68e2..14f9429d572c 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -24,6 +24,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -137,6 +138,7 @@ public:
 
 class SW_DLLPUBLIC SwSection
 : public SwClient
+, public SvtListener // needed for SwClientNotify to be called from 
SwSectionFormat
 {
 // In order to correctly maintain the flag when creating/deleting frames.
 friend class SwSectionNode;
@@ -153,6 +155,7 @@ private:
 bool const bHidden, bool const bCondition);
 
 protected:
+virtual void Notify(SfxHint const& rHint) override;
 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
 
 public:
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index 5fa56e2eb00f..c4d498f05495 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -198,6 +198,8 @@ SwSection::SwSection(
 : SwClient(& rFormat)
 , m_Data(eType, rName)
 {
+StartListening(rFormat.GetNotifier());
+
 SwSection *const pParentSect = GetParent();
 if( pParentSect )
 {
@@ -230,6 +232,7 @@ SwSection::~SwSection()
 else
 {
 pFormat->Remove( this ); // remove
+SvtListener::EndListeningAll();
 
 if (SectionType::Content != m_Data.GetType())
 {
@@ -400,6 +403,11 @@ void SwSection::SetEditInReadonly(bool const bFlag)
 }
 
 void SwSection::SwClientNotify(const SwModify&, const SfxHint& rHint)
+{
+Notify(rHint);
+}
+
+void SwSection::Notify(SfxHint const& rHint)
 {
 if (rHint.GetId() != SfxHintId::SwLegacyModify)
 return;
diff --git a/sw/source/core/inc/sectfrm.hxx b/sw/source/core/inc/sectfrm.hxx
index 276819dff7bf..09c742f8da79 100644
--- a/sw/source/core/inc/sectfrm.hxx
+++ b/sw/source/core/inc/sectfrm.hxx
@@ -22,6 +22,8 @@
 #include "layfrm.hxx"
 #include "flowfrm.hxx"
 
+#include 
+
 class SwSection;
 class SwSectionFormat;
 class SwAttrSetChg;
@@ -45,6 +47,7 @@ namespace o3tl {
 }
 
 class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame
+, public SvtListener // TODO?
 {
 SwSection* m_pSection;
 bool m_bFootnoteAtEnd; // footnotes at the end of section
@@ -70,6 +73,7 @@ class SwSectionFrame final: public SwLayoutFrame, public 
SwFlowFrame
 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
 virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool  ) 
override;
 virtual void Format( vcl::RenderContext* pRenderContext, const 
SwBorderAttrs *pAttrs = nullptr ) override;
+virtual void Notify(SfxHint const& rHint) override;
 virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
 
 public:
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index bc529bd28708..e5ba5d242667 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -74,6 +74,8 @@ SwSectionFrame::SwSectionFrame( SwSection , SwFrame* 
pSib )
 , m_bOwnFootnoteNum(false)
 , m_bFootnoteLock(false)
 {
+StartListening(rSect.GetFormat()->GetNotifier());
+
 mnFrameType = SwFrameType::Section;
 
 CalcFootnoteAtEndFlag();
@@ -90,6 +92,8 @@ SwSectionFrame::SwSectionFrame( SwSectionFrame , bool 
bMaster ) :
 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2022-01-12 Thread Michael Stahl (via logerrit)
 sw/inc/section.hxx |2 +-
 sw/source/core/docnode/section.cxx |   23 +++
 2 files changed, 4 insertions(+), 21 deletions(-)

New commits:
commit 3ce308300b276f62f11e0ed05dea2e5f9340
Author: Michael Stahl 
AuthorDate: Mon Jan 10 12:12:52 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Jan 12 15:12:30 2022 +0100

sw: stop inheriting SwSectionData::m_bProtectFlag from parent section

This is actually no longer inherited by accident since commit
2e32f4ed5af16a68c97a50806a42ffa2d10f1d7a because it replaced the

SwSectionFormat::Modify()->ModifyBroadcast()->CallSwClientNotify()->CallSwClientNotify()
with a call to GetNotifier()->Broadcast(), and apparently SwSection
is a SwClient of SwSectionFormat but not a SvtListener.

But some consider the new behaviour useful, as previously there was no
way to un-protect a section inside an outer protected section at all,
while in this way every section can have its own independent protection
flag. (The m_bEditInReadonlyFlag is not used for this purpose, as it is
only for the case when the document was loaded ReadOnly.)

So make it more explicit by removing the SwSection inheritance code.

A similar change was made for hidden flag in commit
91b0024965908c692bea40f47c58ea9d1bf8a596

Change-Id: I29d3c84309a84267573950775f2a1c6353623724
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128221
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 840cc7883849a10eea11a02a743848238723a3de)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128232
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 20c819bf3bfd9d203f860f1fd078903d0b3945a7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128329
Reviewed-by: Caolán McNamara 

diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index 0647e0273334..ed777e9e68e2 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -73,7 +73,7 @@ private:
 /// may have different value than format attribute:
 /// format attr has value for this section, while flag is
 /// effectively ORed with parent sections!
-bool m_bProtectFlag : 1;
+bool m_bProtectFlag : 1; ///< protect flag is no longer inherited
 // Edit in readonly sections.
 bool m_bEditInReadonlyFlag  : 1;
 
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index afa8b905e99e..5fa56e2eb00f 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -201,15 +201,11 @@ SwSection::SwSection(
 SwSection *const pParentSect = GetParent();
 if( pParentSect )
 {
-m_Data.SetProtectFlag( pParentSect->IsProtectFlag() );
 // edit in readonly sections
 m_Data.SetEditInReadonlyFlag( pParentSect->IsEditInReadonlyFlag() );
 }
 
-if (!m_Data.IsProtectFlag())
-{
-m_Data.SetProtectFlag( rFormat.GetProtect().IsContentProtected() );
-}
+m_Data.SetProtectFlag( rFormat.GetProtect().IsContentProtected() );
 
 if (!m_Data.IsEditInReadonlyFlag()) // edit in readonly sections
 {
@@ -457,21 +453,8 @@ void SwSection::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
 {
 bool bNewFlag =
 static_cast(pNew)->IsContentProtected();
-if( !bNewFlag )
-{
-// Switching off: See if there is protection transferred
-// by the Parents
-const SwSection* pSect = this;
-do {
-if( pSect->IsProtect() )
-{
-bNewFlag = true;
-break;
-}
-pSect = pSect->GetParent();
-} while (pSect);
-}
-
+// this used to inherit the flag from the parent, but then there is
+// no way to turn it off in an inner section
 m_Data.SetProtectFlag( bNewFlag );
 }
 return;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-12-23 Thread Michael Stahl (via logerrit)
 sw/inc/ndarr.hxx  |4 -
 sw/source/core/docnode/nodes.cxx  |  145 --
 sw/source/core/layout/frmtool.cxx |5 +
 3 files changed, 102 insertions(+), 52 deletions(-)

New commits:
commit 1ca3c0d70b31ed173a896bcb37cc731b5324a573
Author: Michael Stahl 
AuthorDate: Tue Dec 21 15:19:33 2021 +0100
Commit: Xisco Fauli 
CommitDate: Thu Dec 23 11:14:27 2021 +0100

tdf#135061 sw_redlinehide: create frames following hidden table

When pasting, the entire document body is covered by a delete redline.

The insert position is in the last node, following a table; table nodes
do hot have any connection to frames if they are hidden by redlines,
so MakeFrames() won't create frames for the inserted nodes.

Refactor SwNodes::FindPrvNxtFrameNode() so that it can detect that table
nodes are hidden in the current layout and continue to search in this
case.

For multiple layouts, MakeFrames() may need to use different nodes per
layout, as the "nearest" one in one layout may be hidden in another.

Change-Id: I3bb2c861c861438ac2695ab49dd91dc2bde87db4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127272
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit af4e20426ad24c6f2c0164b37472f2b7b54ecd30)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127316
Reviewed-by: Xisco Fauli 

diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx
index 6167708d0eb6..18ca83066f82 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -44,6 +44,7 @@ class SwNodeIndex;
 class SwNodeRange;
 class SwOLENode;
 class SwPaM;
+class SwRootFrame;
 class SwSectionData;
 class SwSectionFormat;
 class SwTOXBase;
@@ -307,7 +308,8 @@ public:
  forward after pEnd.
  If no valid node is found, return 0. rFrameIdx points to the node with 
frames. **/
 SwNode* FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
-const SwNode* pEnd ) const;
+const SwNode* pEnd,
+SwRootFrame const* pLayout = nullptr) const;
 
 SwNode * DocumentSectionStartNode(SwNode * pNode) const;
 SwNode * DocumentSectionEndNode(SwNode * pNode) const;
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 6be389697304..708bdb71f27d 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -43,6 +43,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 typedef std::vector SwStartNodePointers;
@@ -2039,7 +2040,8 @@ SwContentNode* SwNodes::GoPrevSection( SwNodeIndex * pIdx,
  * @return result node; 0 if not found
  */
 SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
-const SwNode* pEnd ) const
+SwNode const*const pEnd,
+SwRootFrame const*const pLayout) const
 {
 assert(pEnd != nullptr); // every caller currently
 
@@ -2062,53 +2064,65 @@ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& 
rFrameIdx,
 ? pSttNd->StartOfSectionNode()->FindTableNode()
 : pSttNd->FindTableNode();
 SwNodeIndex aIdx( rFrameIdx );
+
+// search backward for a content or table node
+
 --aIdx;
-SwNode *const pNd = ();
+pFrameNd = ();
 
-pFrameNd = pNd;
-if (pFrameNd->IsContentNode())
+do
 {
-rFrameIdx = aIdx;
-return pFrameNd;
-}
-// search forward or backward for a content node
-pFrameNd = GoPrevSection( , true, false );
-if ( nullptr != pFrameNd &&
-::CheckNodesRange( aIdx, rFrameIdx, true ) &&
-// Never out of the table at the start
-pFrameNd->FindTableNode() == pTableNd &&
-// Bug 37652: Never out of the table at the end
-(!pFrameNd->FindTableNode() || 
pFrameNd->FindTableBoxStartNode()
-== pSttNd->FindTableBoxStartNode() ) &&
- (!pSectNd || pSttNd->IsSectionNode() ||
-  pSectNd->GetIndex() < pFrameNd->GetIndex())
-)
-{
-rFrameIdx = aIdx;
-}
-else
-{
-aIdx = pEnd->GetIndex() + 1;
-
-pFrameNd = ();
-if (!pFrameNd->IsContentNode())
+if (pFrameNd->IsContentNode())
 {
-pFrameNd = GoNextSection( , true, false );
-// NEVER leave the section when doing this!
-if (pFrameNd
-&& !(::CheckNodesRange(aIdx, rFrameIdx, true)
- && (pFrameNd->FindTableNode() == pTableNd &&
-// NEVER go out of the table cell at the end
-  

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-12-23 Thread Michael Stahl (via logerrit)
 sw/inc/ndarr.hxx |4 -
 sw/source/core/docnode/nodes.cxx |   93 ---
 2 files changed, 51 insertions(+), 46 deletions(-)

New commits:
commit 04313336e665c10bbb2d1a47e41e7b38e5c3c2cb
Author: Michael Stahl 
AuthorDate: Tue Dec 21 13:47:32 2021 +0100
Commit: Xisco Fauli 
CommitDate: Thu Dec 23 11:12:39 2021 +0100

sw: simplify SwNodes::FindPrvNxtFrameNode(), improve comments

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127269
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 25aa814aa466cb0a59e34dfef33c50065c445f60)

sw: simplify SwNodes::FindPrvNxtFrameNode(), pEnd is always passed

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127270
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit e0f13ce0f9e2dac836c42141bb848d2bf4fbda75)

sw: simplify SwNodes::FindPrvNxtFrameNode(), de-golf conditionals

Change-Id: Ie5b35793ce38e6338e34d47725e649a56078d603
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127271
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit b922988e2cd57c9397b9e512a7616a10612b2b8f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127315
Reviewed-by: Xisco Fauli 

diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx
index 7e095c8fb0a6..6167708d0eb6 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -303,8 +303,8 @@ public:
 const   SwDoc& GetDoc() const   { return m_rMyDoc; }
 
 /** Search previous / next content node or table node with frames.
- If no end is given begin with the FrameIndex, else start search
- with that before rFrameIdx and pEnd at the back.
+ Search is started backward with the one before rFrameIdx and
+ forward after pEnd.
  If no valid node is found, return 0. rFrameIdx points to the node with 
frames. **/
 SwNode* FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
 const SwNode* pEnd ) const;
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index e7af18a1c16a..6be389697304 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -2027,53 +2027,53 @@ SwContentNode* SwNodes::GoPrevSection( SwNodeIndex * 
pIdx,
 return nullptr;
 }
 
-//TODO: improve documentation
 //TODO: The inventor of the "single responsibility principle" will be crying 
if you ever show this code to him!
-/** find the next/previous ContentNode or a table node with frames
+/** find the next/previous ContentNode or table node that should have layout
+ * frames that are siblings to the ones of the node at rFrameIdx.
  *
- * If no pEnd is given, search is started with FrameIndex; otherwise
- * search is started with the one before rFrameIdx and after pEnd.
+ * Search is started backward with the one before rFrameIdx and
+ * forward after pEnd.
  *
- * @param rFrameIdx node with frames to search in
- * @param pEnd ???
- * @return result node; 0 (!!!) if not found
+ * @param rFrameIdx in: node with frames to search in; out: found node
+ * @param pEnd last node after rFrameIdx that should be excluded from search
+ * @return result node; 0 if not found
  */
 SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
 const SwNode* pEnd ) const
 {
+assert(pEnd != nullptr); // every caller currently
+
 SwNode* pFrameNd = nullptr;
 
 // no layout -> skip
 if( GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell() )
 {
-SwNode* pSttNd = ();
+SwNode *const pSttNd = ();
 
-// move of a hidden section?
-SwSectionNode* pSectNd = pSttNd->IsSectionNode()
+// inside a hidden section?
+SwSectionNode *const pSectNd = pSttNd->IsSectionNode()
 ? pSttNd->StartOfSectionNode()->FindSectionNode()
 : pSttNd->FindSectionNode();
 if( !( pSectNd && pSectNd->GetSection().CalcHiddenFlag() ) )
 {
 // in a table in table situation we have to assure that we don't 
leave the
 // outer table cell when the inner table is looking for a PrvNxt...
-SwTableNode* pTableNd = pSttNd->IsTableNode()
+SwTableNode *const pTableNd = pSttNd->IsTableNode()
 ? pSttNd->StartOfSectionNode()->FindTableNode()
 : pSttNd->FindTableNode();
 SwNodeIndex aIdx( rFrameIdx );
-SwNode* pNd;
-if( pEnd )
-{
---aIdx;
-pNd = ();
-}
-else
-pNd = pSttNd;
+--aIdx;
+SwNode *const pNd = ();
 
-if( ( pFrameNd = pNd )->IsContentNode() )
+pFrameNd = pNd;
+if (pFrameNd->IsContentNode())
+{
 rFrameIdx = aIdx;
-
+return pFrameNd;
+}
 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-12-16 Thread Michael Stahl (via logerrit)
 sw/inc/ndtxt.hxx |2 +-
 sw/source/core/fields/reffld.cxx |4 ++--
 sw/source/core/txtnode/ndtxt.cxx |4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 0d05c7a566f0fd9660c48b3efb74d3c3d969226d
Author: Michael Stahl 
AuthorDate: Wed Dec 15 12:16:35 2021 +0100
Commit: Thorsten Behrens 
CommitDate: Thu Dec 16 09:21:45 2021 +0100

tdf#139843 sw_redlinehide: fix crash while updating reference fields

Use layout in MakeRefNumStr() when checking if node is numbered,
because a hidden node has a null SwNodeNum.

(regression from ae246b44da1708417aaaefe4f9186cfbbb9a9137)

Change-Id: Iea797c03018929601ea797f00e3cf2d7749e55ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126857
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit cc02c0e32fda654cb4bcb93f87ceb48b356e1d84)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126876
Reviewed-by: Thorsten Behrens 

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 9b7de4e89cb7..54db3b1523cb 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -510,7 +510,7 @@ public:
 @retval trueThis text node has a number.
 @retval false   else
  */
-bool HasNumber() const;
+bool HasNumber(SwRootFrame const* pLayout = nullptr) const;
 
 /** Returns if this text node has a bullet.
 
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 2340c1313d0f..20ab617a8fd1 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -768,7 +768,7 @@ static std::pair MakeRefNumStr(
 SwTextNode const& rTextNodeOfReferencedItem(pLayout
 ?   *sw::GetParaPropsNode(*pLayout, i_rTextNodeOfReferencedItem)
 :   i_rTextNodeOfReferencedItem);
-if ( rTextNodeOfReferencedItem.HasNumber() &&
+if ( rTextNodeOfReferencedItem.HasNumber(pLayout) &&
  rTextNodeOfReferencedItem.IsCountedInList() )
 {
 OSL_ENSURE( rTextNodeOfReferencedItem.GetNum(pLayout),
@@ -792,7 +792,7 @@ static std::pair MakeRefNumStr(
 == rTextNodeOfReferencedItem.FindFooterStartNode() 
)
 {
 const SwNodeNum* pNodeNumForTextNodeOfField( nullptr );
-if ( rTextNodeOfField.HasNumber() &&
+if ( rTextNodeOfField.HasNumber(pLayout) &&
  rTextNodeOfField.GetNumRule() == 
rTextNodeOfReferencedItem.GetNumRule() )
 {
 pNodeNumForTextNodeOfField = rTextNodeOfField.GetNum(pLayout);
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index a0cc7337baa1..09c897478f50 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3076,11 +3076,11 @@ sal_uInt16 lcl_BoundListLevel(const int nActualLevel)
 }
 
 // -> #i29560#
-bool SwTextNode::HasNumber() const
+bool SwTextNode::HasNumber(SwRootFrame const*const pLayout) const
 {
 bool bResult = false;
 
-const SwNumRule* pRule = GetNum() ? GetNum()->GetNumRule() : nullptr;
+const SwNumRule *const pRule = GetNum(pLayout) ? 
GetNum(pLayout)->GetNumRule() : nullptr;
 if ( pRule )
 {
 const SwNumFormat& 
aFormat(pRule->Get(lcl_BoundListLevel(GetActualListLevel(;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-11-05 Thread Caolán McNamara (via logerrit)
 sw/inc/PostItMgr.hxx |3 ++-
 sw/source/uibase/docvw/PostItMgr.cxx |   15 +++
 2 files changed, 13 insertions(+), 5 deletions(-)

New commits:
commit 0e83cdaf8a96fa06b95219e581fc2eed7df39c26
Author: Caolán McNamara 
AuthorDate: Thu Nov 4 12:06:58 2021 +
Commit: Michael Stahl 
CommitDate: Fri Nov 5 10:30:49 2021 +0100

Resolves: tdf#143643 ensure relayout on undo of insert comment

Change-Id: I732e23b8ff7c17abf4b5b9b7c7964fca6069543c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124707
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index 760fc7f8abe7..5b12063d2eef 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -153,7 +153,8 @@ class SAL_DLLPUBLIC_RTTI SwPostItMgr final : public 
SfxListener
 boolLayoutByPage( 
std::vector ,
   const tools::Rectangle& rBorder,
   tools::Long lNeededHeight);
-voidCheckForRemovedPostIts();
+// return true if a postit was found to have been removed
+boolCheckForRemovedPostIts();
 boolArrowEnabled(sal_uInt16 aDirection,tools::ULong aPage) 
const;
 boolBorderOverPageBorder(tools::ULong aPage) const;
 boolHasScrollbars() const;
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index d8b79c6e9d7e..f1b3a329f937 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -238,7 +238,7 @@ SwPostItMgr::~SwPostItMgr()
 mPages.clear();
 }
 
-void SwPostItMgr::CheckForRemovedPostIts()
+bool SwPostItMgr::CheckForRemovedPostIts()
 {
 IDocumentRedlineAccess const& 
rIDRA(mpWrtShell->getIDocumentRedlineAccess());
 bool bRemoved = false;
@@ -260,7 +260,7 @@ void SwPostItMgr::CheckForRemovedPostIts()
 }
 
 if ( !bRemoved )
-return;
+return false;
 
 // make sure that no deleted items remain in page lists
 // todo: only remove deleted ones?!
@@ -270,9 +270,13 @@ void SwPostItMgr::CheckForRemovedPostIts()
 PrepareView();
 }
 else
-// if postits are their make sure that page lists are not empty
+{
+// if postits are there make sure that page lists are not empty
 // otherwise sudden paints can cause pain (in BorderOverPageBorder)
 CalcRects();
+}
+
+return true;
 }
 
 SwSidebarItem* SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool 
bCheckExistence, bool bFocus)
@@ -370,7 +374,10 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const 
SfxHint& rHint )
 {
 if (!pField)
 {
-CheckForRemovedPostIts();
+const bool bWasRemoved = CheckForRemovedPostIts();
+// tdf#143643 ensure relayout on undo of insert comment
+if (bWasRemoved)
+mbLayout = true;
 break;
 }
 RemoveItem(pField);


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-10-25 Thread Bjoern Michaelsen (via logerrit)
 sw/inc/fldbas.hxx|2 ++
 sw/inc/fmtfld.hxx|5 +
 sw/source/core/fields/ddefld.cxx |   15 +++
 sw/source/core/fields/ddetbl.cxx |4 
 sw/source/core/fields/fldbas.cxx |5 +
 5 files changed, 27 insertions(+), 4 deletions(-)

New commits:
commit 5380e47db7ad968c442026f7d2e8ede79bc55564
Author: Bjoern Michaelsen 
AuthorDate: Sun Oct 24 23:17:24 2021 +0200
Commit: Michael Stahl 
CommitDate: Mon Oct 25 15:07:44 2021 +0200

tdf#138531: Also update DDE tables, not only fields

Change-Id: I0cbf8ce355b460b2f7ea73c8fae653641c980979
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124129
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 98247b039baea4697e6c387025afcf6a2963c043)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124019

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index e38122ec390d..b25908f35d2a 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -32,6 +32,7 @@
 class SwDoc;
 class SwField;
 class SwFormatField;
+class SwDDETable;
 class SwRootFrame;
 class SvNumberFormatter;
 class IDocumentRedlineAccess;
@@ -281,6 +282,7 @@ public:
 void GatherNodeIndex(std::vector& rvNodeIndex);
 void GatherRefFields(std::vector& rvRFields, const 
sal_uInt16 nTyp);
 void GatherFields(std::vector& rvFormatFields, bool 
bCollectOnlyInDocNodes=true) const;
+void GatherDdeTables(std::vector& rvTables) const;
 };
 
 /** Base class of all fields.
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 706026120aaa..04284a30ad87 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -32,6 +32,7 @@ class SwField;
 class SwTextField;
 class SwView;
 class SwFieldType;
+class SwDDETable;
 class SwFormatField;
 class IDocumentRedlineAccess;
 namespace com::sun::star::text { class XTextField; }
@@ -71,6 +72,10 @@ namespace sw {
 std::vector& m_rvFields;
 GatherFieldsHint(std::vector& rvFields, bool 
bCollectOnlyInDocNodes = true) : 
m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes), m_rvFields(rvFields) {};
 };
+struct GatherDdeTablesHint final : SfxHint {
+std::vector& m_rvTables;
+GatherDdeTablesHint(std::vector& rvTables) : 
m_rvTables(rvTables) {};
+};
 }
 
 
diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx
index 9e07a8afa9bf..ec5eddcffac3 100644
--- a/sw/source/core/fields/ddefld.cxx
+++ b/sw/source/core/fields/ddefld.cxx
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -99,7 +100,7 @@ public:
 OSL_ENSURE(m_rFieldType.GetDoc(), "no pDoc");
 
 // no dependencies left?
-if (m_rFieldType.HasWriterListeners() && !m_rFieldType.IsModifyLocked() && 
!ChkNoDataFlag())
+if (!m_rFieldType.IsModifyLocked() && !ChkNoDataFlag())
 {
 SwViewShell* pSh = 
m_rFieldType.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
 SwEditShell* pESh = m_rFieldType.GetDoc()->GetEditShell();
@@ -109,8 +110,11 @@ public:
 m_rFieldType.LockModify();
 
 std::vector vFields;
+std::vector vTables;
 m_rFieldType.GatherFields(vFields, false);
-if(vFields.size())
+m_rFieldType.GatherDdeTables(vTables);
+const bool bDoAction = vFields.size() || vTables.size();
+if(bDoAction)
 {
 if(pESh)
 pESh->StartAllAction();
@@ -118,16 +122,19 @@ public:
 pSh->StartAction();
 }
 
+// DDE fields attribute in the text
 for(auto pFormatField: vFields)
 {
-// a DDE table or a DDE field attribute in the text
 if(pFormatField->GetTextField())
 pFormatField->UpdateTextNode( nullptr,  );
 }
+// a DDE tables in the text
+for(auto pTable: vTables)
+pTable->ChangeContent();
 
 m_rFieldType.UnlockModify();
 
-if(vFields.size())
+if(bDoAction)
 {
 if(pESh)
 pESh->EndAllAction();
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index f4b959014575..a131515eaa0e 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -118,6 +119,9 @@ void SwDDETable::SwClientNotify(const SwModify& rModify, 
const SfxHint& rHint)
 pInRangeHint->m_nSttNd < pTableNd->EndOfSectionIndex() &&
 pInRangeHint->m_nEndNd > pTableNd->GetIndex() )
 pInRangeHint->m_rIsInRange = true;
+} else if (const auto pGatherDdeTablesHint = dynamic_cast())
+{
+pGatherDdeTablesHint->m_rvTables.push_back(this);
 }
 else if (auto pModifyChangedHint = dynamic_cast())
 {
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index cf3a41460ba3..ad2914c390c1 100644
--- 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-08-12 Thread Balazs Santha (via logerrit)
 sw/inc/doc.hxx|2 +-
 sw/inc/swtable.hxx|2 +-
 sw/source/core/doc/tblrwcl.cxx|3 ++-
 sw/source/core/docnode/ndcopy.cxx |1 +
 sw/source/core/docnode/ndtbl.cxx  |4 ++--
 sw/source/core/edit/edglss.cxx|2 +-
 6 files changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 15fbc6f2dbf114247a89cd3d4d3360c9c00a4390
Author: Balazs Santha 
AuthorDate: Fri Jul 2 19:21:47 2021 +0200
Commit: Michael Stahl 
CommitDate: Thu Aug 12 13:46:56 2021 +0200

tdf#131771 sw: fix missing table style after copying and pasting the table

This fixes the loss of table style setting when copying and then pasting a 
table.
Change-Id: Ie678a269b4cdcddfd73a5d6a27ef9fcb55dcaa46

Change-Id: I48208337ee14fde30417fa3999f56999cc5eda19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118336
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120373
Reviewed-by: Michael Stahl 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index c94e5f04c5f3..6ff73c35cb8c 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1269,7 +1269,7 @@ public:
 
 bool InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
 const SwTable* pCpyTable, bool bCpyName = false,
-bool bCorrPos = false );
+bool bCorrPos = false, const OUString& rStyleName = "" 
);
 
 void UnProtectCells( std::u16string_view rTableName );
 bool UnProtectCells( const SwSelBoxes& rBoxes );
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index fd3cb0367a67..23930d19b7f3 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -278,7 +278,7 @@ public:
  const bool bPerformValidCheck = false ) const;
 // Copy selected boxes to another document.
 bool MakeCopy( SwDoc&, const SwPosition&, const SwSelBoxes&,
-bool bCpyName = false ) const;
+bool bCpyName = false, const OUString& rStyleName = "" ) 
const;
 // Copy table in this
 bool InsTable( const SwTable& rCpyTable, const SwNodeIndex&,
 SwUndoTableCpyTable* pUndo );
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 18eab679a289..7b5367255fda 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -2045,7 +2045,7 @@ void SwTable::CopyHeadlineIntoTable( SwTableNode& 
rTableNd )
 
 bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& rPos,
 const SwSelBoxes& rSelBoxes,
-bool bCpyName ) const
+bool bCpyName, const OUString& rStyleName ) const
 {
 // Find all Boxes/Lines
 FndBox_ aFndBox( nullptr, nullptr );
@@ -2081,6 +2081,7 @@ bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& 
rPos,
 
 pNewTable->SetTableStyleName(pTableNd->GetTable().GetTableStyleName());
 
+pTableNd->GetTable().SetTableStyleName(rStyleName);
 if( auto pSwDDETable = dynamic_cast(this) )
 {
 // A DDE-Table is being copied
diff --git a/sw/source/core/docnode/ndcopy.cxx 
b/sw/source/core/docnode/ndcopy.cxx
index 5b3c9edbd9db..91bb99d696b6 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -271,6 +271,7 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc& rDoc, const 
SwNodeIndex& rIdx ) const
 SwNodeIndex aInsPos( *pEndNd );
 
 SwTable& rTable = pTableNd->GetTable();
+rTable.SetTableStyleName(GetTable().GetTableStyleName());
 rTable.RegisterToFormat( *pTableFormat );
 
 rTable.SetRowsToRepeat( GetTable().GetRowsToRepeat() );
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 3ddfd2019d17..d6005e273192 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4283,7 +4283,7 @@ void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode )
  * This method is called by edglss.cxx/fecopy.cxx
  */
 bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
-const SwTable* pCpyTable, bool bCpyName, bool bCorrPos 
)
+const SwTable* pCpyTable, bool bCpyName, bool 
bCorrPos, const OUString& rStyleName )
 {
 bool bRet;
 
@@ -4306,7 +4306,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const 
SwSelBoxes& rBoxes,
 {
 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
 bRet = pSrcTableNd->GetTable().MakeCopy( *this, rInsPos, rBoxes,
-bCpyName );
+bCpyName, rStyleName );
 }
 
 if( pUndo && bRet )
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 536a0c1643ff..47791dc69a49 100644
--- a/sw/source/core/edit/edglss.cxx
+++ 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-06-21 Thread Noel Grandin (via logerrit)
 sw/inc/list.hxx |   40 ++--
 sw/source/core/doc/list.cxx |  140 +++-
 2 files changed, 45 insertions(+), 135 deletions(-)

New commits:
commit ce85841d7d7592188c1ad3e467e29f436bc05ba2
Author: Noel Grandin 
AuthorDate: Mon Jun 21 09:12:34 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Jun 21 12:07:17 2021 +0200

merge SwList and SwListImpl (tdf#135316 related)

to reduce allocations when loading large documents

Change-Id: I734aec4b22844e999d19f649e8e9cd5949a7cbfb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117543
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit b30e329bfac7279d888908273baec8c7d8dd32ee)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117560

diff --git a/sw/inc/list.hxx b/sw/inc/list.hxx
index 64d62faa9c93..203fda7a266d 100644
--- a/sw/inc/list.hxx
+++ b/sw/inc/list.hxx
@@ -22,15 +22,14 @@
 
 #include 
 #include 
+#include "SwNodeNum.hxx"
+#include "pam.hxx"
 #include 
 
 #include "swdllapi.h"
 
 class SwNumRule;
 class SwNodes;
-class SwNodeNum;
-
-class SwListImpl;
 
 class SwList
 {
@@ -40,9 +39,10 @@ class SwList
 const SwNodes& rNodes );
 ~SwList();
 
-const OUString & GetListId() const;
+const OUString & GetListId() const { return msListId; }
+
+const OUString & GetDefaultListStyleName() const { return 
msDefaultListStyleName; }
 
-SW_DLLPUBLIC const OUString & GetDefaultListStyleName() const;
 void SetDefaultListStyleName(OUString const&);
 
 void InsertListItem( SwNodeNum& rNodeNum,
@@ -64,7 +64,35 @@ class SwList
 SwList( const SwList& ) = delete;
 SwList& operator=( const SwList& ) = delete;
 
-std::unique_ptr> 
mpListImpl;
+void NotifyItemsOnListLevel( const int nLevel );
+
+// unique identifier of the list
+const OUString msListId;
+// default list style for the list items, identified by the list style 
name
+OUString msDefaultListStyleName;
+
+// list trees for certain document ranges
+struct tListTreeForRange
+{
+/// tree always corresponds to document model
+std::unique_ptr pRoot;
+/// Tree that is missing those nodes that are merged or hidden
+/// by delete redlines; this is only used if there is a layout
+/// that has IsHideRedlines() enabled.
+/// A second tree is needed because not only are the numbers in
+/// the nodes different, the structure of the tree may be different
+/// as well, if a high-level node is hidden its children go under
+/// the previous node on the same level.
+/// The nodes of pRootRLHidden are a subset of the nodes of pRoot.
+std::unique_ptr pRootRLHidden;
+/// top-level SwNodes section
+std::unique_ptr pSection;
+tListTreeForRange(std::unique_ptr p1, 
std::unique_ptr p2, std::unique_ptr p3)
+: pRoot(std::move(p1)), pRootRLHidden(std::move(p2)), 
pSection(std::move(p3)) {}
+};
+std::vector maListTrees;
+
+int mnMarkedListLevel;
 };
 #endif // INCLUDED_SW_INC_LIST_HXX
 
diff --git a/sw/source/core/doc/list.cxx b/sw/source/core/doc/list.cxx
index 7cfd1f10305f..4192cab749ad 100644
--- a/sw/source/core/doc/list.cxx
+++ b/sw/source/core/doc/list.cxx
@@ -23,68 +23,8 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 
-// implementation class for SwList
-class SwListImpl
-{
-public:
-SwListImpl( const OUString& sListId,
-SwNumRule& rDefaultListStyle,
-const SwNodes& rNodes );
-~SwListImpl() COVERITY_NOEXCEPT_FALSE;
-
-const OUString& GetListId() const { return msListId;}
-
-const OUString& GetDefaultListStyleName() const { return 
msDefaultListStyleName;}
-
-bool HasNodes() const;
-
-void InsertListItem( SwNodeNum& rNodeNum, bool isHiddenRedlines,
- const int nLevel );
-static void RemoveListItem( SwNodeNum& rNodeNum );
-
-void InvalidateListTree();
-void ValidateListTree();
-
-void MarkListLevel( const int nListLevel,
-const bool bValue );
-
-bool IsListLevelMarked( const int nListLevel ) const;
-
-// unique identifier of the list
-const OUString msListId;
-// default list style for the list items, identified by the list style 
name
-OUString msDefaultListStyleName;
-
-// list trees for certain document ranges
-struct tListTreeForRange
-{
-/// tree always corresponds to document model
-std::unique_ptr pRoot;
-/// Tree that is missing those nodes that are merged or hidden
-/// by delete redlines; this is only used if there is a layout
-/// 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source

2021-06-15 Thread Noel Grandin (via logerrit)
 sw/inc/docstyle.hxx   |   24 +---
 sw/source/uibase/app/docstyle.cxx |   33 -
 2 files changed, 33 insertions(+), 24 deletions(-)

New commits:
commit e3611f81ee35998e3b8382d3c0fab6d4993e4626
Author: Noel Grandin 
AuthorDate: Tue Jun 15 11:44:12 2021 +0200
Commit: Noel Grandin 
CommitDate: Tue Jun 15 15:39:09 2021 +0200

tdf#135316 docx open performance

don't translate back and forth between two representations in
SwPoolFormatList
Shaves 2% off load time.wq

Change-Id: I098c15b92d5bc89fe1631edaed6827931cde5895
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117235
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 9966345f4faebb447d353ce68cee5765863273a2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117219

diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index 520404389fe9..77925dd5f670 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -115,7 +115,7 @@ public:
 /** Preset the members without physical access.
  Used by StyleSheetPool. */
 voidPresetName(const OUString& rName)  { aName   = 
rName; }
-voidPresetNameAndFamily(const OUString& rName);
+voidPresetNameAndFamily(char cFamily, const OUString& 
rName);
 voidPresetParent(const OUString& rName){ aParent = 
rName; }
 voidPresetFollow(const OUString& rName){ aFollow = 
rName; }
 
@@ -141,25 +141,35 @@ public:
 virtual boolIsUsed() const override;
 };
 
+namespace std {
+template<>
+struct hash>
+{
+std::size_t operator()(std::pair const & pair) const
+{ return static_cast(pair.first) ^ 
std::size_t(pair.second.hashCode()); }
+};
+}
+
+
 // Iterator for Pool.
 class SwStyleSheetIterator : public SfxStyleSheetIterator, public SfxListener
 {
 // Local helper class.
 class SwPoolFormatList
 {
-std::vector maImpl;
-typedef std::unordered_map UniqueHash;
+std::vector> maImpl;
+typedef std::unordered_map, sal_uInt32> 
UniqueHash;
 UniqueHash maUnique;
 void rehash();
 public:
 SwPoolFormatList() {}
-void Append( char cChar, std::u16string_view rStr );
+void Append( char cChar, const OUString& rStr );
 void clear() { maImpl.clear(); maUnique.clear(); }
 size_t size() { return maImpl.size(); }
 bool empty() { return maImpl.empty(); }
-sal_uInt32 FindName(SfxStyleFamily eFam, std::u16string_view rName);
-void RemoveName(SfxStyleFamily eFam, std::u16string_view rName);
-const OUString [](sal_uInt32 nIdx) { return maImpl[ nIdx ]; }
+sal_uInt32 FindName(SfxStyleFamily eFam, const OUString& rName);
+void RemoveName(SfxStyleFamily eFam, const OUString& rName);
+const std::pair [](sal_uInt32 nIdx) { return 
maImpl[ nIdx ]; }
 };
 
 rtl::Reference< SwDocStyleSheet > mxIterSheet;
diff --git a/sw/source/uibase/app/docstyle.cxx 
b/sw/source/uibase/app/docstyle.cxx
index 99b44f47ae86..9b3f98e16a1f 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -370,7 +370,7 @@ static const SwBoxAutoFormat* lcl_FindCellStyle(SwDoc& 
rDoc, std::u16string_view
 }
 
 sal_uInt32 SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily 
eFam,
- std::u16string_view 
rName)
+ const OUString& rName)
 {
 if(!maImpl.empty())
 {
@@ -402,9 +402,7 @@ sal_uInt32 
SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily eFam,
 cStyle = ' ';
 break;
 }
-const OUString sSrch = OUStringChar(cStyle) + rName;
-
-UniqueHash::const_iterator it = maUnique.find(sSrch);
+UniqueHash::const_iterator it = 
maUnique.find(std::pair{cStyle, rName});
 if (it != maUnique.end())
 {
 sal_uInt32 nIdx = it->second;
@@ -425,7 +423,7 @@ void SwStyleSheetIterator::SwPoolFormatList::rehash()
 }
 
 void SwStyleSheetIterator::SwPoolFormatList::RemoveName(SfxStyleFamily eFam,
- std::u16string_view rName)
+ const OUString& rName)
 {
 sal_uInt32 nTmpPos = FindName( eFam, rName );
 if( nTmpPos < maImpl.size() )
@@ -437,16 +435,14 @@ void 
SwStyleSheetIterator::SwPoolFormatList::RemoveName(SfxStyleFamily eFam,
 }
 
 // Add Strings to the list of templates
-void SwStyleSheetIterator::SwPoolFormatList::Append( char cChar, 
std::u16string_view rStr )
+void SwStyleSheetIterator::SwPoolFormatList::Append( char cChar, const 
OUString& rStr )
 {
-const OUString aStr = OUStringChar(cChar) + rStr;
-
-UniqueHash::const_iterator it = maUnique.find(aStr);
+UniqueHash::const_iterator it