[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2023-08-10 Thread Michael Stahl (via logerrit)
 sw/source/core/inc/tabfrm.hxx|1 +
 sw/source/core/layout/fly.cxx|7 ++-
 sw/source/core/layout/tabfrm.cxx |   24 ++--
 3 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit f7062f0568a60898b3ccea25caab73807f528d6c
Author: Michael Stahl 
AuthorDate: Tue Aug 8 12:21:20 2023 +0200
Commit: Michael Stahl 
CommitDate: Thu Aug 10 12:52:28 2023 +0200

tdf#156551 tdf#150606 sw: layout: only invalidate SwTabFrame if it...

... wants to move back.

In this document, the table 1709 splits across 3 columns of the section
1702 with 1 row each, and when its follows are invalidated in
CalcContent(), the later SwTabFrame::MakeAll() of the 1st follow joins
the 2nd follow and invalidates the size of the section frame, causing a
loop.

So only invalidate if that actually looks necessary.

(regression from commit 59987d3c77ec7dbf59fbea9f47cc226f4e8903f9)

Change-Id: I360c8f697a7666a19a08d8ebcabbcfa3a7cdf844
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155452
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit a9b19f78f3cdcbf5c949a85b45877e903114cc54)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155456
Tested-by: Michael Stahl 

diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx
index 95da935cd079..6dfa6c743a13 100644
--- a/sw/source/core/inc/tabfrm.hxx
+++ b/sw/source/core/inc/tabfrm.hxx
@@ -43,6 +43,7 @@ class SwTabFrame: public SwLayoutFrame, public SwFlowFrame
 bool m_bCalcLowers  :1; /// For stability of the content in MakeAll
 bool m_bLowersFormatted :1; /// Communication between MakeAll and Layact
 bool m_bLockBackMove:1; /// The Master took care of the BackMove test
+bool m_bWantBackMove:1; /// Table wants to move back but was locked
 bool m_bResizeHTMLTable :1; /// Call the Resize of the HTMLTableLayout in 
the MakeAll
 /// This is an optimization, so that we don't 
have to call
 /// it in ContentFrame::Grow; there it might 
be called for
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 6cdec269c2d9..2b6973d14e97 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1663,7 +1663,12 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
 {
 assert(static_cast(pFrame)->IsFollow());
 static_cast(pFrame)->m_bLockBackMove = false;
-pFrame->InvalidatePos();
+// tdf#150606 encourage it to move back in FormatLayout()
+if (static_cast(pFrame)->m_bWantBackMove)
+{
+static_cast(pFrame)->m_bWantBackMove = 
false;
+pFrame->InvalidatePos();
+}
 }
 }
 
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 4489142e8e56..f39250dcc67b 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -74,6 +74,7 @@ SwTabFrame::SwTabFrame( SwTable , SwFrame* pSib )
 , m_bCalcLowers(false)
 , m_bLowersFormatted(false)
 , m_bLockBackMove(false)
+, m_bWantBackMove(false)
 , m_bResizeHTMLTable(false)
 , m_bONECalcLowers(false)
 , m_bHasFollowFlowLine(false)
@@ -113,6 +114,7 @@ SwTabFrame::SwTabFrame( SwTabFrame  )
 , m_bCalcLowers(false)
 , m_bLowersFormatted(false)
 , m_bLockBackMove(false)
+, m_bWantBackMove(false)
 , m_bResizeHTMLTable(false)
 , m_bONECalcLowers(false)
 , m_bHasFollowFlowLine(false)
@@ -3549,9 +3551,17 @@ bool SwTabFrame::ShouldBwdMoved( SwLayoutFrame 
*pNewUpper, bool  )
 }
 else if (!m_bLockBackMove)
 bMoveAnyway = true;
+else
+{
+m_bWantBackMove = true;
+}
 }
 else if (!m_bLockBackMove)
 bMoveAnyway = true;
+else
+{
+m_bWantBackMove = true;
+}
 
 if ( bMoveAnyway )
 {
@@ -3563,7 +3573,7 @@ bool SwTabFrame::ShouldBwdMoved( SwLayoutFrame 
*pNewUpper, bool  )
 // This frame fits into pNewUpper in case it has no space, but this
 // frame is empty.
 bFits = nSpace >= 0;
-if (!m_bLockBackMove && bFits)
+if (bFits)
 {
 // #i26945# - check, if follow flow line
 // contains frame, which are moved forward due to its object
@@ -3582,7 +3592,17 @@ bool SwTabFrame::ShouldBwdMoved( SwLayoutFrame 
*pNewUpper, bool  )
 // 'return nHeight <= nSpace' to 'return nTmpHeight < nSpace'.
 // This obviously results in problems with table frames in
 // sections. Remember: Every twip is sacred.
-return nTmpHeight <= nSpace;
+if 

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-12-29 Thread Michael Stahl (via logerrit)
 sw/source/core/inc/flyfrms.hxx   |1 +
 sw/source/core/layout/flylay.cxx |   13 +
 2 files changed, 14 insertions(+)

New commits:
commit 148c938020f5467b78da37a5045672635e2e3afa
Author: Michael Stahl 
AuthorDate: Tue Dec 20 21:04:05 2022 +0100
Commit: Thorsten Behrens 
CommitDate: Fri Dec 30 00:33:01 2022 +

tdf#146875 sw: move also at-frame flys off SwPageFrame

The bugdoc contains an at-frame anchored fly on page 77, which is
anchored to an at-page anchored fly.

While layouting page 74, the fly is moved to page 77, and the content on
page 74 invalidated.

Unexpectedly, calling RegisterAtPage on a SwFlyLayFrame does absolutely
nothing, as it calls the base class SwFlyFrame, so the fly stays on page
74.

Thus, page 74 never actually becomes valid, and later pages are never
layouted.

(regression from commit eb85de8e6b61fb3fcb6c03ae0145f7fe5478bccf)

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

Change-Id: I4fcbed4daf83f9e554de5a877a40b2c2419c0f2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144759
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx
index 04b505ddd548..cb94b7cbd259 100644
--- a/sw/source/core/inc/flyfrms.hxx
+++ b/sw/source/core/inc/flyfrms.hxx
@@ -151,6 +151,7 @@ public:
 
 SwFlyLayFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor );
 
+virtual void RegisterAtPage(SwPageFrame &) override;
 protected:
 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
 };
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 4a7030ea241e..c915ee82d95a 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -723,6 +723,19 @@ SwFlyLayFrame::SwFlyLayFrame( SwFlyFrameFormat *pFormat, 
SwFrame* pSib, SwFrame
 m_bLayout = true;
 }
 
+void SwFlyLayFrame::RegisterAtPage(SwPageFrame & rPageFrame)
+{
+assert(GetPageFrame() != );
+if (GetPageFrame())
+{
+GetPageFrame()->MoveFly( this,  );
+}
+else
+{
+rPageFrame.AppendFlyToPage( this );
+}
+}
+
 // #i28701#
 
 void SwFlyLayFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-12-16 Thread Michael Stahl (via logerrit)
 sw/source/core/txtnode/ndtxt.cxx |   20 
 1 file changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 5dbf1cbc9bfc0e930edc470e93bf27148635dd5f
Author: Michael Stahl 
AuthorDate: Tue Dec 13 20:35:07 2022 +0100
Commit: Michael Stahl 
CommitDate: Fri Dec 16 13:31:13 2022 +

(related: tdf#149595) sw: also re-sort SwSortedObjs on SwPageFrame

... if SwTextNode content changes; for the unit test here we get:

  Error: elements in iterator range [first, last) are not partitioned by
  the predicate __comp and value __val.

Also, the SwTextNode may have multiple text frames on multiple pages.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144108
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit c684301352bcca709bc8d1c99e0f08e7096e9716)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144131
Reviewed-by: Christian Lohmaier 
(cherry picked from commit 2033a23379c0eb9d6de41c7b1473769fda2cc632)

Change-Id: I05d4276e4b4b94fe3cd2cdfda3418ad51fa08f5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144288
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index ed1e19bd5ce7..ce533a220bd9 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1533,10 +1534,21 @@ void SwTextNode::Update(
 
 //Any drawing objects anchored into this text node may be sorted by their
 //anchor position which may have changed here, so resort them
-SwContentFrame* pContentFrame = 
getLayoutFrame(GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout());
-SwSortedObjs* pSortedObjs = pContentFrame ? pContentFrame->GetDrawObjs() : 
nullptr;
-if (pSortedObjs)
-pSortedObjs->UpdateAll();
+SwIterator 
iter(*this);
+for (SwTextFrame* pFrame = iter.First(); pFrame; pFrame = iter.Next())
+{
+SwSortedObjs * pSortedObjs(pFrame->GetDrawObjs());
+if (pSortedObjs)
+{
+pSortedObjs->UpdateAll();
+}
+// also sort the objs on the page frame
+pSortedObjs = pFrame->FindPageFrame()->GetSortedObjs();
+if (pSortedObjs) // doesn't exist yet if called for inserting as-char 
fly
+{
+pSortedObjs->UpdateAll();
+}
+}
 
 // Update the paragraph signatures.
 if (SwEditShell* pEditShell = GetDoc()->GetEditShell())


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-12-16 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/DocumentRedlineManager.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 13ca7ea1e8142e02f3518de5d0a1999701c925c9
Author: Michael Stahl 
AuthorDate: Fri Jul 15 20:55:35 2022 +0200
Commit: Michael Stahl 
CommitDate: Fri Dec 16 13:27:08 2022 +

tdf#149548 sw: don't rely on binary search in SplitRedline()

The problem is that for this bugdoc overlapping redlines are created by
writerfilter, and so this one survives the split in SwDoc::TextToTable()
when creating a cell on node 146 to 149:

$125 = (SwRangeRedline) {
   = SwPaM = {
point = SwPosition (node 155, offset 156),
mark = SwPosition (node 146, offset 0)
  },

It's not found in GetRedline(), as that relies on the redlines never
overlapping, so isn't split at end of 149.

Then when copying to the clipboard, all redlines are deleted and this
deletes cell start and end nodes, while the cell's SwTableBox is still
referenced elsewhere.

(reportedly somehow a regression from
commit c4cf85766453982f1aa94a7f2cb22af19ed100be)

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137110
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit de49e1c55dc10ce1b59345af5cc49fde3adf65b7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138286
Reviewed-by: Xisco Fauli 
(cherry picked from commit fa5838b018a5f1e5b1616bbacbb242eb4fac998a)

Change-Id: I6466e6777cd83c7625381f7049f30c8a2f487af1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144220
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index e11c1c6f2c4b..718492ab3f79 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2325,7 +2325,7 @@ bool DocumentRedlineManager::SplitRedline( const SwPaM& 
rRange )
 SwRedlineTable::size_type n = 0;
 const SwPosition* pStt = rRange.Start();
 const SwPosition* pEnd = rRange.End();
-GetRedline( *pStt,  );
+//FIXME overlapping problem GetRedline( *pStt,  );
 for ( ; n < mpRedlineTable->size(); ++n)
 {
 SwRangeRedline * pRedline = (*mpRedlineTable)[ n ];


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-08-03 Thread Michael Stahl (via logerrit)
 sw/source/filter/xml/xmlexp.hxx   |5 +
 sw/source/filter/xml/xmlfmte.cxx  |   12 ++-
 sw/source/filter/xml/xmliteme.cxx |2 
 sw/source/filter/xml/xmltble.cxx  |  149 +++---
 sw/source/filter/xml/xmltexte.hxx |   12 +++
 5 files changed, 103 insertions(+), 77 deletions(-)

New commits:
commit 8fcc188bc37dff0040dfca55f63a7836ef3ae686
Author: Michael Stahl 
AuthorDate: Fri Jul 29 17:00:14 2022 +0200
Commit: Thorsten Behrens 
CommitDate: Wed Aug 3 21:55:04 2022 +0200

tdf#145226 sw: ODF export: fix table-row/table-cell styles

The SwFrameFormat for table lines and table boxes gets an auto-generated
name in SwDoc::MakeTableBoxFormat()/MakeTableLineFormat().

The problem is that xmltble.cxx assumes that these SwFrameFormats never
have a name, and sets names on them temporarily during
exportTextAutoStyles(), then later reads them when exporting the
table-rows and table-cells, then eventually resets them all to an empty
name.

One issue is that it assumes that a non-empty SwFrameFormat name
indicates a style has been exported, but that isn't always the case, and
the name may still be an auto-generated one.

Another issue is that overwriting the names interferes with the use of
the names in Undo operations.

So store the name for the ODF styles in members of the filter classes
instead of the core model.

(regression from commit 083fe09958658de8c3da87a28e0f8ff7b3b8a5e9)

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

tdf#145226 sw: ODF export: fix table-row/table-cell style display-name
Missed this attribute in commit 5a9fe1d80ea977c439dd10ee2056abe6b0cb4d07

Change-Id: I9b17962decbf9f8ecd2a91551230cf0f012e7a9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137765
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
index 22e6a42368a7..a5abc5baf15f 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -23,6 +23,8 @@
 #include 
 #include "xmlitmap.hxx"
 #include 
+
+#include 
 #include 
 
 class SwDoc;
@@ -73,7 +75,8 @@ class SwXMLExport : public SvXMLExport
  SwXMLTableInfo_Impl& rTableInfo,
  bool bTop=false );
 
-void ExportFormat( const SwFormat& rFormat,  enum 
::xmloff::token::XMLTokenEnum eClass );
+void ExportFormat(const SwFormat& rFormat, enum 
::xmloff::token::XMLTokenEnum eClass,
+::std::optional const oStyleName);
 void ExportTableFormat( const SwFrameFormat& rFormat, sal_uInt32 nAbsWidth 
);
 
 void ExportTableColumnStyle( const SwXMLTableColumn_Impl& rCol );
diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx
index 209cdd5a3904..b7aa337eede3 100644
--- a/sw/source/filter/xml/xmlfmte.cxx
+++ b/sw/source/filter/xml/xmlfmte.cxx
@@ -46,7 +46,8 @@ using namespace ::com::sun::star::drawing;
 using namespace ::com::sun::star::lang;
 using namespace ::xmloff::token;
 
-void SwXMLExport::ExportFormat( const SwFormat& rFormat, enum XMLTokenEnum 
eFamily )
+void SwXMLExport::ExportFormat(const SwFormat& rFormat, enum XMLTokenEnum 
eFamily,
+::std::optional const oStyleName)
 {
 // 
 CheckAttrList();
@@ -57,11 +58,14 @@ void SwXMLExport::ExportFormat( const SwFormat& rFormat, 
enum XMLTokenEnum eFami
 return;
 OSL_ENSURE( eFamily != XML_TOKEN_INVALID, "family must be specified" );
 // style:name="..."
+assert(oStyleName || (eFamily != XML_TABLE_ROW && eFamily != 
XML_TABLE_CELL));
 bool bEncoded = false;
-AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, EncodeStyleName(
-rFormat.GetName(),  ) );
+OUString const name(oStyleName ? *oStyleName : rFormat.GetName());
+AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, EncodeStyleName(name, 
));
 if( bEncoded )
-AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rFormat.GetName() 
);
+{
+AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, name);
+}
 
 if( eFamily != XML_TOKEN_INVALID )
 AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, eFamily );
diff --git a/sw/source/filter/xml/xmliteme.cxx 
b/sw/source/filter/xml/xmliteme.cxx
index b307a5c10872..8972bd14a51e 100644
--- a/sw/source/filter/xml/xmliteme.cxx
+++ b/sw/source/filter/xml/xmliteme.cxx
@@ -219,7 +219,7 @@ void SwXMLExport::ExportTableFormat( const SwFrameFormat& 
rFormat, sal_uInt32 nA
 {
 static_cast(m_pTableItemMapper.get())
 ->SetAbsWidth( nAbsWidth );
-ExportFormat( rFormat, XML_TABLE );
+ExportFormat(rFormat, XML_TABLE, {});
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmltble.cxx 

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-07-28 Thread Michael Stahl (via logerrit)
 sw/source/core/unocore/unobkm.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 7cb316137751e471a835cb1c506fb89b29f4d65b
Author: Michael Stahl 
AuthorDate: Wed Jul 27 16:06:05 2022 +0200
Commit: Michael Stahl 
CommitDate: Thu Jul 28 11:28:25 2022 +0200

sw: SolarMutexGuard missing in SwXBookmark::setPropertyValue()

Change-Id: I41187b02e6b0545529e2a2c5b07da671eae89079
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137506
Reviewed-by: Michael Stahl 
Tested-by: Jenkins
(cherry picked from commit c7a76952b6fa0e6688028047726ac794fdd5cca3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137519
Tested-by: Michael Stahl 

diff --git a/sw/source/core/unocore/unobkm.cxx 
b/sw/source/core/unocore/unobkm.cxx
index ddeaccf1966b..a4d719016f68 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -410,6 +410,8 @@ void SAL_CALL
 SwXBookmark::setPropertyValue(const OUString& PropertyName,
 const uno::Any& rValue)
 {
+SolarMutexGuard g;
+
 if (PropertyName == UNO_NAME_BOOKMARK_HIDDEN)
 {
 bool bNewValue = false;


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-21 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/DocumentRedlineManager.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 358197bcbbb2a24e2a4378786b494cf2ce360d15
Author: Michael Stahl 
AuthorDate: Tue Jun 14 17:19:23 2022 +0200
Commit: Thorsten Behrens 
CommitDate: Tue Jun 21 23:42:24 2022 +0200

sw_redlinehide: skip unnecessary updates when undoing redlined delete

When reproducing tdf#135976 and then Undo, an UAF crash happens here:

  assert(!pFrame->GetDrawObjs() || !pObjs->Contains(*pObj));

The pObjs was actually deleted and then re-created, because the pObj was
removed from the frame and added again to the same frame.

This is a bit unexpected, so prevent it by taking a shortcut in the
caller UpdateFramesForRemoveDeleteRedline() to insert a check that had
been removed in commit 14e87a4b15d31a34e6053f6194688f3aa23af991.

If the rPam is inside a single node, the sw::RedlineUnDelText hint that
was sent to the SwTextFrame should be sufficient to update it and the
rest of the code in the loop that deals with newly split paragraph can
be skipped.

Change-Id: I5f36eb91bc20003887ee0bad03ea4a6e67135de9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135907
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit cf9a16caf5012d65b2a45a5525e36e40585dd35c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135892
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 918f435d48de3f29814f187c8621c1a564c5b835)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136222
Tested-by: Thorsten Behrens 

diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 8ae32f266bdb..e11c1c6f2c4b 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -283,6 +283,12 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, 
SwPaM const& rPam)
 break;
 }
 
+// no nodes can be unmerged by this - skip MakeFrames() etc.
+if (rPam.GetPoint()->nNode == rPam.GetMark()->nNode)
+{
+break; // continue with AppendAllObjs()
+}
+
 // first, call CheckParaRedlineMerge on the first paragraph,
 // to init flag on new merge range (if any) + 1st node post the 
merge
 auto eMode(sw::FrameMode::Existing);


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-21 Thread Michael Stahl (via logerrit)
 sw/source/core/undo/undobj.cxx |   12 
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit c6a2033221c86166a2226023f34314eb59380fa2
Author: Michael Stahl 
AuthorDate: Wed Jun 8 17:34:32 2022 +0200
Commit: Thorsten Behrens 
CommitDate: Tue Jun 21 23:40:25 2022 +0200

(related: tdf#139514) sw: fix Undo of delete with at-para fly

Nonobviously, there are situations where the anchor node must be
preserved and restored when it's not on the node that is being deleted.

(probably regression from commit 91b2325808a75174f284c48c8b8afc118fad74e4)

Change-Id: I39f09ddb631204c8ad522f9ec7068d235ca94ad2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135509
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 12acdce71dd6b6af2c52ba8fa3248d3166418543)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135518
Reviewed-by: Miklos Vajna 
(cherry picked from commit 054c248127c78521b4a4e7aacd8936bd54259996)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136218
Tested-by: Michael Stahl 

diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 3fe7f107f052..d611cb4a496b 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -981,10 +981,14 @@ void SwUndoSaveContent::DelContentIndex( const 
SwPosition& rMark,
 // Moving the anchor?
 else if 
(!((DelContentType::CheckNoCntnt|DelContentType::ExcludeFlyAtStartEnd)
 & nDelContentType) &&
-// at least for calls from SwUndoDelete,
-// this should work - other Undos don't
-// remember the order of the cursor
-(rPoint.nNode.GetIndex() == 
pAPos->nNode.GetIndex())
+// for SwUndoDelete: rPoint is the node that
+// will be Joined - so anchor should be moved
+// off it - but UndoImpl() split will insert
+// new node *before* existing one so a no-op
+// may need to be done here to add it to
+// history for Undo.
+(rPoint.nNode.GetIndex() == 
pAPos->nNode.GetIndex()
+ || pStt->nNode.GetIndex() == 
pAPos->nNode.GetIndex())
 // Do not try to move the anchor to a table!
 && rMark.nNode.GetNode().IsTextNode())
 {


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-21 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/docnew.cxx |   27 ++-
 1 file changed, 14 insertions(+), 13 deletions(-)

New commits:
commit 97a8db45e6ad8fb397edf5e239384637353f0b2f
Author: Michael Stahl 
AuthorDate: Wed Jun 1 20:30:50 2022 +0200
Commit: Thorsten Behrens 
CommitDate: Tue Jun 21 23:39:46 2022 +0200

tdf#148309 sw_redlinehide: fix mail merge performance regression

The problem is that in the call to pTargetShell->EndAllAction(), the
cursor is on the node before the newly appended one that has the page
break, and only this node is formatted (via GetFormatted()), so no new
page frames are inserted in the layout, which then creates massive
performance problems later, particularly since the bugdoc contains
multiple at-page anchored flys.

(regression from commit 42448f48bb48a13d6618a181b12840db6d85c574)

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135356
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 
(cherry picked from commit ff525d0d70ea9d189a430bde944b56d048b03e55)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135273
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 57cd4735a7312174e63d2a1a3dd3831443169530)

Revert "trac#34262 Revert "tdf#144565 sw_redlinehide: fix mailmerge when 
flys anchored at last node""

This reverts commit 228537cebb6ffa75e7e2270fb7bfd6e91fa6ba2c.
The performance regression should be fixed with above commit.

Change-Id: I05cd2a515a7f67132ab1c8c6fa0d675252ea3a15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136181
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 984f2335bc45..6b041fa96c51 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1054,19 +1054,19 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, 
sal_uInt16 const nStartPageNu
 {
 SwNodeIndex aBreakIdx( GetNodes().GetEndOfContent(), -1 );
 SwPosition aBreakPos( aBreakIdx );
-// InsertPageBreak just works on SwTextNode nodes, so make
-// sure the last node is one!
-bool bIsTextNode = aBreakIdx.GetNode().IsTextNode();
-if ( !bIsTextNode )
-getIDocumentContentOperations().AppendTextNode( aBreakPos );
-const OUString name = pTargetPageDesc->GetName();
-pTargetShell->InsertPageBreak( , nStartPageNumber );
-if ( !bIsTextNode )
-{
-pTargetShell->SttEndDoc( false );
---aBreakIdx;
-GetNodes().Delete( aBreakIdx );
-}
+// insert new node - will be removed at the end...
+// (don't SplitNode() as it may move flys to the wrong node)
+getIDocumentContentOperations().AppendTextNode(aBreakPos);
+SwFormatPageDesc pageDesc(pTargetPageDesc);
+pageDesc.SetNumOffset(nStartPageNumber);
+// set break on the last paragraph
+getIDocumentContentOperations().InsertPoolItem(SwPaM(aBreakPos),
+pageDesc, SetAttrMode::DEFAULT, pTargetShell->GetLayout());
+// tdf#148309 move to the last node - so that the "flush page 
break"
+// code below will format the frame of the node with the page 
break,
+// which is required for new page frames to be created!  Else 
layout
+// performance will be terrible.
+pTargetShell->SttEndDoc(false);
 
 // There is now a new empty text node on the new page. If it has
 // any marks, those are from the previous page: move them back
@@ -1097,6 +1097,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, 
sal_uInt16 const nStartPageNu
 if ( !bDeletePrevious )
 {
 SAL_INFO( "sw.pageframe", "(Flush pagebreak AKA EndAllAction" 
);
+
assert(pTargetShell->GetCursor()->GetPoint()->nNode.GetNode().GetTextNode()->GetSwAttrSet().HasItem(RES_PAGEDESC));
 pTargetShell->EndAllAction();
 SAL_INFO( "sw.pageframe",  "Flush changes AKA EndAllAction)" );
 pTargetShell->StartAllAction();


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-21 Thread Michael Stahl (via logerrit)
 sw/source/core/crsr/crbm.cxx |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 5fec7a762b2e8d9eb3612737832478a4eb41d5af
Author: Michael Stahl 
AuthorDate: Fri May 20 15:46:20 2022 +0200
Commit: Michael Stahl 
CommitDate: Tue Jun 21 12:47:10 2022 +0200

sw_redlinehide: fix crash in IsMarkHidden() if pointing to table node

This is called during mail merge from documentStartPageNumber()
and if the document starts with a table, the passed UNO mark will point
to SwTableNode.

(regression from commit 943d9be770e550d20ca72274fa5e914d1f61e605)

Change-Id: Ic69c12ba0d819eda85de5dde95e35a8071466c2e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134692
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 4d3b750d08d05c475fb38f8b3961696d9cc9882f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134776
Reviewed-by: Caolán McNamara 
(cherry picked from commit 9b767013115b967bb2a9215a4ee49f7b0ef2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136180
Tested-by: Michael Stahl 

diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx
index a9175808de85..b35b1329cbca 100644
--- a/sw/source/core/crsr/crbm.cxx
+++ b/sw/source/core/crsr/crbm.cxx
@@ -130,9 +130,14 @@ bool IsMarkHidden(SwRootFrame const& rLayout, 
::sw::mark::IMark const& rMark)
 {
 return false;
 }
-SwTextNode const& rNode(*rMark.GetMarkPos().nNode.GetNode().GetTextNode());
+SwNode const& rNode(rMark.GetMarkPos().nNode.GetNode());
+SwTextNode const*const pTextNode(rNode.GetTextNode());
+if (pTextNode == nullptr)
+{   // UNO_BOOKMARK may point to table node
+return rNode.GetRedlineMergeFlag() == SwNode::Merge::Hidden;
+}
 SwTextFrame const*const pFrame(static_cast(
-rNode.getLayoutFrame()));
+pTextNode->getLayoutFrame()));
 if (!pFrame)
 {
 return true;
@@ -147,14 +152,14 @@ bool IsMarkHidden(SwRootFrame const& rLayout, 
::sw::mark::IMark const& rMark)
 }
 else
 {
-if (rMark.GetMarkPos().nContent.GetIndex() == rNode.Len())
+if (rMark.GetMarkPos().nContent.GetIndex() == pTextNode->Len())
 {   // at end of node: never deleted (except if node deleted)
-return rNode.GetRedlineMergeFlag() == SwNode::Merge::Hidden;
+return pTextNode->GetRedlineMergeFlag() == SwNode::Merge::Hidden;
 }
 else
 {   // check character following mark pos
 return pFrame->MapModelToViewPos(rMark.GetMarkPos())
-== pFrame->MapModelToView(, 
rMark.GetMarkPos().nContent.GetIndex() + 1);
+== pFrame->MapModelToView(pTextNode, 
rMark.GetMarkPos().nContent.GetIndex() + 1);
 }
 }
 }


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-21 Thread Michael Stahl (via logerrit)
 sw/source/core/text/xmldump.cxx |   24 
 1 file changed, 24 insertions(+)

New commits:
commit 20caf52668931a49e5a93267c7760d133298fb70
Author: Michael Stahl 
AuthorDate: Tue Apr 13 20:04:27 2021 +0200
Commit: Michael Stahl 
CommitDate: Tue Jun 21 11:55:46 2022 +0200

sw: layout dump: sorted_objs of SwPageFrame

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

Change-Id: I2bf8493744d054c513ab9b65136b6e29e9aa07f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136179
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index b93577838258..147ed5a97eb7 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -350,6 +351,29 @@ void SwFrame::dumpAsXml( xmlTextWriterPtr writer ) const
 OUString aFormatName = pPageFrame->GetPageDesc()->GetName();
 xmlTextWriterWriteFormatAttribute( writer, BAD_CAST("pageDesc"), 
"%s", BAD_CAST(OUStringToOString(aFormatName, RTL_TEXTENCODING_UTF8).getStr()));
 xmlTextWriterEndElement(writer);
+#ifdef UNX
+// disable for tests to avoid resolving loads of merge conflicts 
(var is only set on UNX in this branch)
+if (!getenv("LO_TESTNAME")) if (auto const* pObjs = 
pPageFrame->GetSortedObjs())
+{
+(void)xmlTextWriterStartElement(writer, 
BAD_CAST("sorted_objs"));
+for (SwAnchoredObject const*const pObj : *pObjs)
+{   // just print pointer, full details will be printed on its 
anchor frame
+// this nonsense is needed because of multiple inheritance
+if (SwFlyFrame const*const pFly = dynamic_cast(pObj))
+{
+(void)xmlTextWriterStartElement(writer, 
BAD_CAST("fly"));
+(void)xmlTextWriterWriteFormatAttribute(writer, 
BAD_CAST("ptr"), "%p", pFly);
+}
+else
+{
+(void)xmlTextWriterStartElement(writer, 
BAD_CAST(pObj->getElementName()));
+(void)xmlTextWriterWriteFormatAttribute(writer, 
BAD_CAST("ptr"), "%p", pObj);
+}
+(void)xmlTextWriterEndElement(writer);
+}
+(void)xmlTextWriterEndElement(writer);
+}
+#endif
 }
 
 if (IsTextFrame())


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-21 Thread Michael Stahl (via logerrit)
 sw/source/core/docnode/node.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit acad0f0c53b788f40b2e8344a1c0fe6e862e
Author: Michael Stahl 
AuthorDate: Tue May 17 14:09:08 2022 +0200
Commit: Michael Stahl 
CommitDate: Tue Jun 21 11:34:25 2022 +0200

tdf#148461 sw_redlinehide: fix assert in SwContentNode::DelFrames()

The assert(pMerged->pFirstNode->GetIndex() <= i) is intended for when
frames are really deleted, but CheckParaRedlineMerge() calls it while
the now-outdated MergedPara is still on the frame, but the nodes already
have new flags; assign a dummy node in this situation.

Change-Id: I23fbfdb6901e6e15abf92913aa252e59877bc280
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134475
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 6ee57b39ba912f0902714d8c4d1a267511a3c6ca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134446
Reviewed-by: Caolán McNamara 
(cherry picked from commit 6767a309b7c3ddd283a83bcf7dc36fecaf9cc6b9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136176
Tested-by: Michael Stahl 

diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 955e113f2768..0bf2729cd02c 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1384,6 +1384,12 @@ void SwContentNode::DelFrames(SwRootFrame const*const 
pLayout)
 pMerged->pParaPropsNode = pNode->GetTextNode();
 break;
 }
+else if (pMerged->pFirstNode->GetIndex() == i)
+{   // this can only happen when called from 
CheckParaRedlineMerge()
+// and the pMerged will be deleted anyway
+pMerged->pParaPropsNode = pMerged->pFirstNode;
+break;
+}
 }
 
assert(pMerged->listener.IsListeningTo(pMerged->pParaPropsNode));
 }


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-20 Thread Caolán McNamara (via logerrit)
 sw/source/core/text/porfld.cxx |   14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 5ea863f55c0a6221c487e5352a7101d3c8564e5f
Author: Caolán McNamara 
AuthorDate: Fri Mar 11 21:47:43 2022 +
Commit: Michael Stahl 
CommitDate: Mon Jun 20 11:23:32 2022 +0200

an inconsistent SwTextFormatInfo index, len, text length case

seen on loading sw/qa/python/testdocuments/TESTMETA.odt

maybe since:

commit 2f3684b2289a8c46dc6144064a452cc529400f28
Date:   Tue Jul 31 16:00:02 2018 +0200

[API CHANGE] add some more asserts to the string functions

but probably an underlying issue since conversion from UniString
to OUString

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131407
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit eb7fbe1f3a37d89b97bd8976bdc006099578c204)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132860
Reviewed-by: Michael Stahl 
(cherry picked from commit 177589cb4f8ef20ff84dbfc141b145b28e57be83)

Change-Id: If731163fbc5e05b813ccd21df65164fe476cba9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133902
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index a5eb9b99ce9b..776770915e2e 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -175,10 +175,18 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, 
const SwFieldPortion *pP
 pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() );
 pInf->SetIdx(TextFrameIndex(0));
 }
-else if (nIdx < TextFrameIndex(pOldText->getLength()))
+else
 {
-sal_Int32 const nFieldLen(pPor->GetFieldLen());
-aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText);
+TextFrameIndex nEnd(pOldText->getLength());
+if (nIdx < nEnd)
+{
+sal_Int32 const nFieldLen(pPor->GetFieldLen());
+aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, 
aText);
+}
+else if (nIdx == nEnd)
+aText = *pOldText + aText;
+else
+SAL_WARN("sw.core", "SwFieldSlot bad SwFieldPortion index.");
 }
 pInf->SetText( aText );
 }


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-20 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/flycnt.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 97f81c178bb625b4e647e690b94b1056e6174f6e
Author: Michael Stahl 
AuthorDate: Mon Mar 14 19:11:21 2022 +0100
Commit: Michael Stahl 
CommitDate: Mon Jun 20 11:21:58 2022 +0200

tdf#135220 sw: fix layout after SwUndoDelete

The bugdoc is 398 pages after initial load and 397 pages after Undo.

There is really only one problem, on page 6 the fly frame 7370 "Figure
3: Hay Rake in Weeds" anchored on SwTextFrame 5896 should be on page 7
and aligned to the top of its paragraph.

First, 5986 moves forward from page 6 to 7, hitting the condition added
in commit c799de145f7e289f31e3669646e5bd12814e6c5e
debug:1170918:1170918: 
SwObjectFormatterTextFrame::CheckMovedFwdCondition(): 
o_rbPageHasFlysAnchoredBelowThis because next chain on same page

Then 5986 moves back to page 6.  When it is formatted there, the
ConsiderObjWrapInfluenceOnObjPos() is true, preventing a formatting of
the anchor frame - so it does not move forward.

The flag SetTmpConsiderWrapInfluence(true) was set the first time (when
it moved forward).

Setting this flag for any anchor frame that moves forward was added in
2005 in commit 46297c0923c50a12510c7b15b725c8d2fd80f9c0 and apparently
the only way the flag is cleared is when SwDoc's SetModified() is
called (or the frame is in a table or column).

So it is similar to the InsertMovedFwdFrame() case that was addressed by
commit c799de145f7e289f31e3669646e5bd12814e6c5e in that the flag should
not be set if bPageHasFlysAnchoredBelowThis is true.

(reportedly regression from sw_redlinehide
 commit 6c7245e789f973cf6dad03f7008ab3f9d12d350c)

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131560
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit d9e38d5830ac278d7180b96fb6cefe3ee8ef6d76)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131591
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 24a8c6d10bfe377631d980806a511e1aa00a2e16)

Change-Id: I27b2a1becf5f7a760e74e801e23472116d0a5ced
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133890
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 6760eec25b8c..a197974d74f2 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -428,7 +428,10 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 bAnchoredAtMaster, nToPageNum, bDummy,
 bPageHasFlysAnchoredBelowThis) )
 {
-bConsiderWrapInfluenceDueToMovedFwdAnchor = true;
+if (!bPageHasFlysAnchoredBelowThis)
+{
+bConsiderWrapInfluenceDueToMovedFwdAnchor = true;
+}
 // mark anchor text frame
 // directly, that it is moved forward by object 
positioning.
 SwTextFrame* pAnchorTextFrame( 
static_cast(AnchorFrame()) );


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-06-20 Thread Michael Stahl (via logerrit)
 sw/source/core/inc/layfrm.hxx |1 +
 sw/source/core/layout/findfrm.cxx |   21 +
 sw/source/core/layout/pagechg.cxx |2 ++
 3 files changed, 24 insertions(+)

New commits:
commit 6a8fa0aa5966a8f7043307289f03aefdbaf6c585
Author: Michael Stahl 
AuthorDate: Wed Apr 20 18:48:30 2022 +0200
Commit: Michael Stahl 
CommitDate: Mon Jun 20 11:17:54 2022 +0200

sw: layout: fix crash when deleting page with section being formatted

This crashes only when calling storeToURL() with writer_pdf_Export?

There is a text frame 112, followed by section frame 126, which contains
table frame 127.

The section frame 126 is being formatted, which in
SwFrame::PrepareMake() formats its prev, text frame 112.

This does MoveBwd() and in SwContentFrame::MakeAll() formats its next,
tab frame 127.

This also does MoveBwd() and then there is this really odd condition in
SwTabFrame::Paste() where it calls SwFrame::CheckPageDescs() if it
*doesn't* have a RES_PAGEDESC item and the page has a non-default page
style - this condition remains inexplicable since initial CVS import.

Then CheckPageDesc() sees the (next) page is empty and deletes it.

So check in sw::IsPageFrameEmpty() that there aren't any sections with
IsDeleteForbidden() set.

(regression from commit b9ef71476fd70bc13f50ebe80390e0730d1b7afb)

Change-Id: I3c64fe40fabffc255c4146a35c678ce6a1cc09c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133222
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 85aa57359befd7a21b3fdf36f2b362f50495f77c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133151
Reviewed-by: Xisco Fauli 
(cherry picked from commit 116b246e42a1c807e4e693bd020231a22f05abcd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133885
Tested-by: Michael Stahl 

diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index f7d90f00d8f6..835b20c0cfd6 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -100,6 +100,7 @@ public:
 SwPrintData const*const pPrintData = nullptr ) const 
override;
 const SwFrame *Lower() const { return m_pLower; }
   SwFrame *Lower()   { return m_pLower; }
+bool ContainsDeleteForbiddenLayFrame() const;
 const SwContentFrame *ContainsContent() const;
 inline SwContentFrame *ContainsContent();
 const SwCellFrame *FirstCell() const;
diff --git a/sw/source/core/layout/findfrm.cxx 
b/sw/source/core/layout/findfrm.cxx
index a35af84d54a1..632e136fdd10 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -161,6 +161,27 @@ const SwFrame *SwLayoutFrame::ContainsAny( const bool 
_bInvestigateFootnoteForSe
 return nullptr;
 }
 
+bool SwLayoutFrame::ContainsDeleteForbiddenLayFrame() const
+{
+if (IsDeleteForbidden())
+{
+return true;
+}
+for (SwFrame const* pFrame = Lower(); pFrame; pFrame = pFrame->GetNext())
+{
+if (!pFrame->IsLayoutFrame())
+{
+continue;
+}
+SwLayoutFrame const*const pLay(static_cast(pFrame));
+if (pLay->ContainsDeleteForbiddenLayFrame())
+{
+return true;
+}
+}
+return false;
+}
+
 const SwFrame* SwFrame::GetLower() const
 {
 return IsLayoutFrame() ? static_cast(this)->Lower() 
: nullptr;
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 75eacea7c95a..b1a04f0890c6 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1025,6 +1025,8 @@ bool IsPageFrameEmpty(SwPageFrame const& rPage)
  rPage.FindFootnoteCont() ||
  (nullptr != (pBody = rPage.FindBodyCont()) &&
 ( pBody->ContainsContent() ||
+  // check for section frames that are being formatted on the stack
+  rPage.ContainsDeleteForbiddenLayFrame() ||
 // #i47580#
 // Do not delete page if there's an empty tabframe
 // left. I think it might be correct to use ContainsAny()


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-05-16 Thread Caolán McNamara (via logerrit)
 sw/source/core/layout/layact.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 86ca21d394e44a91a9cf027939403bd1a20ada64
Author: Caolán McNamara 
AuthorDate: Fri Mar 25 12:10:32 2022 +
Commit: Michael Stahl 
CommitDate: Mon May 16 12:38:26 2022 +0200

forcepoint#89 don't remove page with footnote continuation frame

in browse/html/web mode

Change-Id: Ic821dd7f2cc1f47305b5fe2ced16d5168aedc0b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132045
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit e672a8351df5e9fcbdafa34857a16f2bd547ebd6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133938
Tested-by: Michael Stahl 

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index abd255b69662..62d78d4c38e6 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -306,7 +306,8 @@ bool SwLayAction::RemoveEmptyBrowserPages()
 do
 {
 if ( (pPage->GetSortedObjs() && pPage->GetSortedObjs()->size()) ||
- pPage->ContainsContent() )
+ pPage->ContainsContent() ||
+ pPage->FindFootnoteCont() )
 pPage = static_cast(pPage->GetNext());
 else
 {


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-05-16 Thread Caolán McNamara (via logerrit)
 sw/source/core/layout/tabfrm.cxx |   42 ---
 1 file changed, 26 insertions(+), 16 deletions(-)

New commits:
commit 7c843c2b2099ec325dd95413892a2c72bb98dd8e
Author: Caolán McNamara 
AuthorDate: Sat Apr 2 20:20:10 2022 +0100
Commit: Michael Stahl 
CommitDate: Mon May 16 12:32:16 2022 +0200

forcepoint#100 drop SwBorderAttrAccess to allow cache entry to be removed

for SwBorderAttr which gets deleted during this call

also includes...

Related: forcepoint#100 we don't need pAttrs for the duration of the full 
scope

similar to the case of

commit 6b1eae0334ba8bad7656a859695551ce51b62f95
Date:   Fri May 18 08:26:14 2001 +

Fix #87058#: Locked boraderattribut

the SwCache object cannot be deleted if its locked, leading to a leak,
we don't need pAttrs for the entire scope here so we can defer to the
end of the scope the reacquire the lock to set pAttrs

and also includes...

Related: forcepoint#100 don't reacquire after every release

instead release when we have to, and only reacquire if necessary
before use of pAttrs

Change-Id: Ie52aab7e5933d76b0c055389798104e4d93f39e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132462
Reviewed-by: Michael Stahl 
Tested-by: Jenkins
(cherry picked from commit 37f39a4156069ba5f099045ce93370507d9ba215)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133901
Tested-by: Michael Stahl 

diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 350083909511..7e48a88f465c 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1990,8 +1990,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 pAccess.reset();
 m_bCalcLowers |= pLayout->Resize(
 pLayout->GetBrowseWidthByTabFrame( *this ) );
-pAccess = 
std::make_unique(SwFrame::GetCache(), this);
-pAttrs = pAccess->Get();
 }
 
 setFramePrintAreaValid(false);
@@ -2020,6 +2018,12 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 const long nOldPrtWidth = aRectFnSet.GetWidth(getFramePrintArea());
 const long nOldFrameWidth = aRectFnSet.GetWidth(getFrameArea());
 const Point aOldPrtPos  = aRectFnSet.GetPos(getFramePrintArea());
+
+if (!pAccess)
+{
+pAccess = 
std::make_unique(SwFrame::GetCache(), this);
+pAttrs = pAccess->Get();
+}
 Format( getRootFrame()->GetCurrShell()->GetOut(), pAttrs );
 
 SwHTMLTableLayout *pLayout = GetTable()->GetHTMLTableLayout();
@@ -2030,8 +2034,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 pAccess.reset();
 m_bCalcLowers |= pLayout->Resize(
 pLayout->GetBrowseWidthByTabFrame( *this ) );
-pAccess = 
std::make_unique(SwFrame::GetCache(), this);
-pAttrs = pAccess->Get();
 }
 if ( aOldPrtPos != aRectFnSet.GetPos(getFramePrintArea()) )
 aNotify.SetLowersComplete( false );
@@ -2080,15 +2082,22 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 pAccess.reset();
 m_bCalcLowers |= pHTMLLayout->Resize(
 pHTMLLayout->GetBrowseWidthByTabFrame( *this ) 
);
+}
+
+setFramePrintAreaValid(false);
 
+if (!pAccess)
+{
 pAccess = 
std::make_unique(SwFrame::GetCache(), this);
 pAttrs = pAccess->Get();
 }
-
-setFramePrintAreaValid(false);
 Format( getRootFrame()->GetCurrShell()->GetOut(), 
pAttrs );
 }
+
+pAccess.reset();
+
 lcl_RecalcTable( *this, nullptr, aNotify );
+
 m_bLowersFormatted = true;
 if ( bKeep && KEEPTAB )
 {
@@ -2252,11 +2261,18 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 // 6. There is no section change behind the table (see 
IsKeep)
 // 7. The last table row wants to keep with its next.
 const SwRowFrame* pLastRow = static_cast(GetLastLower());
-if (pLastRow
-&& IsKeep(pAttrs->GetAttrSet().GetKeep(), 
GetBreakItem(), true)
-&& pLastRow->ShouldRowKeepWithNext())
+if (pLastRow)
 {
-bFormat = true;
+if (!pAccess)
+{
+

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-05-16 Thread Caolán McNamara (via logerrit)
 sw/source/core/text/itratr.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit cd82dc383e4e1aaceda1831ca6b28f829945ce82
Author: Caolán McNamara 
AuthorDate: Thu Mar 24 14:32:22 2022 +
Commit: Michael Stahl 
CommitDate: Mon May 16 12:26:55 2022 +0200

forcepoint#86 RES_TXTATR_UNKNOWN_CONTAINER item put at invalid index

RES_CHRATR_BEGIN is 1, presumably RES_TXTATR_UNKNOWN_CONTAINER should
be stored in the last index

Change-Id: Id37fff41cbbccbc26fe5ccce6027014af7362729
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132040
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit f5ff8e0feb218a001e2ce5ced9ec4e13f2bff73d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133898
Tested-by: Michael Stahl 

diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 4933bce92c9f..1a60ff2b42d6 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -447,7 +447,7 @@ static void InsertCharAttrs(SfxPoolItem const** pAttrs, 
SfxItemSet const& rItems
 }
 else if (nWhich == RES_TXTATR_UNKNOWN_CONTAINER)
 {
-pAttrs[RES_CHRATR_END] = pItem;
+pAttrs[RES_CHRATR_END - RES_CHRATR_BEGIN] = pItem;
 }
 }
 }


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-04-01 Thread Michael Weghorn (via logerrit)
 sw/source/core/doc/docnew.cxx |   21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

New commits:
commit 228537cebb6ffa75e7e2270fb7bfd6e91fa6ba2c
Author: Michael Weghorn 
AuthorDate: Fri Apr 1 08:14:30 2022 +0200
Commit: Michael Weghorn 
CommitDate: Fri Apr 1 10:00:44 2022 +0200

trac#34262 Revert "tdf#144565 sw_redlinehide: fix mailmerge when flys 
anchored at last node"

Causes significant performance regressions
with WollMux mail merge, so revert for now.

Mail merge with the test doc from tdf#144565 at
least already fails with LO 6.1 (Build-ID 2103)
on moviA as well, so for now, better live with an existing
bug than introducing a new one in our LO 6.4 based
releases.

This reverts commit beae7a08c30f2f368708dbc7a9988ecfad08af60.

Change-Id: I6271ffe3f3036df6e16d93389ad21419b541e03e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132394
Tested-by: Michael Weghorn 
Reviewed-by: Michael Weghorn 

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index e125e44420b7..984f2335bc45 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1054,14 +1054,19 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, 
sal_uInt16 const nStartPageNu
 {
 SwNodeIndex aBreakIdx( GetNodes().GetEndOfContent(), -1 );
 SwPosition aBreakPos( aBreakIdx );
-// insert new node - will be removed at the end...
-// (don't SplitNode() as it may move flys to the wrong node)
-getIDocumentContentOperations().AppendTextNode(aBreakPos);
-SwFormatPageDesc pageDesc(pTargetPageDesc);
-pageDesc.SetNumOffset(nStartPageNumber);
-// set break on the last paragraph
-getIDocumentContentOperations().InsertPoolItem(SwPaM(aBreakPos),
-pageDesc, SetAttrMode::DEFAULT, pTargetShell->GetLayout());
+// InsertPageBreak just works on SwTextNode nodes, so make
+// sure the last node is one!
+bool bIsTextNode = aBreakIdx.GetNode().IsTextNode();
+if ( !bIsTextNode )
+getIDocumentContentOperations().AppendTextNode( aBreakPos );
+const OUString name = pTargetPageDesc->GetName();
+pTargetShell->InsertPageBreak( , nStartPageNumber );
+if ( !bIsTextNode )
+{
+pTargetShell->SttEndDoc( false );
+--aBreakIdx;
+GetNodes().Delete( aBreakIdx );
+}
 
 // There is now a new empty text node on the new page. If it has
 // any marks, those are from the previous page: move them back


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-03-18 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/ftnfrm.cxx |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit cb58014691eaa278e4bd19dd0ab65524846c8adc
Author: Michael Stahl 
AuthorDate: Tue Mar 8 17:36:41 2022 +0100
Commit: Thorsten Behrens 
CommitDate: Sat Mar 19 00:26:03 2022 +0100

tdf#139687 sw: invalidate text frame in footnote when moving it

The problem (which only reproduces here on copy/paste with
SAL_USE_VCLPLUGIN=kf5, not with gtk3) is that on SwTextFrame 2638 in a
footnote on page 19 containing "Saeed, 100–101." there should be a top
margin of 0 but it's actually 144.

The footnote was initially created on a previous page with another
footnote with SwTextFrame 2635 before it, that's how it got this top
margin.

Invalidate the print area in SwFootnoteFrame::Paste(), which is called
when the footnote is moved to a different container.

(somehow regression from commit 723728cd358693b8f4bc9d913541aa4479f2bd48)

Change-Id: I7346fd03fccad3eddccbbcd56c4b50127a337b24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131217
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 86081afc3021fa0ae6c2b32d11b4b20cc8a190a3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131201
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 3d8533cb894614394f1ecf05b3d6dc60f3bf6dd6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131629
Tested-by: Thorsten Behrens 

diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 9573944b71d1..425aa5fd0a9e 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -572,10 +572,20 @@ void SwFootnoteFrame::Paste(  SwFrame* pParent, SwFrame* 
pSibling )
 if( 
aRectFnSet.GetWidth(getFrameArea())!=aRectFnSet.GetWidth(pParent->getFramePrintArea())
 )
 InvalidateSize_();
 InvalidatePos_();
+if (SwFrame *const pContent = ContainsContent())
+{   // tdf#139687 invalidate possibly stale top margin (computed from 
previous frame)
+pContent->InvalidatePrt_();
+}
 SwPageFrame *pPage = FindPageFrame();
 InvalidatePage( pPage );
-if ( GetNext() )
-GetNext()->InvalidatePos_();
+if (SwFootnoteFrame *const pNext = static_cast(GetNext()))
+{
+pNext->InvalidatePos_();
+if (SwFrame *const pContent = pNext->ContainsContent())
+{   // tdf#139687 invalidate possibly stale top margin (computed from 
previous frame)
+pContent->InvalidatePrt_();
+}
+}
 if( aRectFnSet.GetHeight(getFrameArea()) )
 pParent->Grow( aRectFnSet.GetHeight(getFrameArea()) );
 


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-03-18 Thread Michael Stahl (via logerrit)
 sw/source/core/edit/edlingu.cxx |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

New commits:
commit 383ee369e3e69ac356b2e3a800274241949e791b
Author: Michael Stahl 
AuthorDate: Tue Mar 8 13:58:28 2022 +0100
Commit: Michael Stahl 
CommitDate: Fri Mar 18 19:38:20 2022 +0100

tdf#147416 sw_redlinehide: fix spell checking popup

The problem is that SwEditShell::GetCorrection() uses the SwTextNode
text without filtering redlines.

Using ExpandMode::ReplaceMode should work as it will replace
CH_TXTATR_INWORD with nothing and CH_TXTATR_BREAKWORD with ZWSP.

Unfortunately there isn't yet a mode that can handle fieldmarks as they
are displayed in the layout.

Change-Id: Ia243d90309fdd7b6ca159c5df2f4d98725400c5c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131210
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit e07b9c5142af838648a4d03a0bdce76612cf7535)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131198
Reviewed-by: Thorsten Behrens 
(cherry picked from commit c29caa41f826e0f3f7850d6276407a937c512957)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131626
Tested-by: Michael Stahl 

diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 69446dd9b060..8c50eadd8740 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -823,11 +823,16 @@ void SwEditShell::HandleCorrectionError(const OUString& 
aText, SwPosition aPos,
 SwRect& rSelectRect)
 {
 // save the start and end positions of the line and the starting point
+SwNode const& rNode(GetCursor()->GetPoint()->nNode.GetNode());
 Push();
 LeftMargin();
-const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex();
+const sal_Int32 nLineStart =  == 
()->GetPoint()->nNode.GetNode()
+? GetCursor()->GetPoint()->nContent.GetIndex()
+: 0;
 RightMargin();
-const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex();
+const sal_Int32 nLineEnd =  == 
()->GetPoint()->nNode.GetNode()
+? GetCursor()->GetPoint()->nContent.GetIndex()
+: rNode.GetTextNode()->Len();
 Pop(PopMode::DeleteCurrent);
 
 // make sure the selection build later from the data below does
@@ -909,8 +914,14 @@ uno::Reference< XSpellAlternatives >
 if (pWrong->InWrongWord(nBegin, nLen) && !pNode->IsSymbolAt(nBegin))
 {
 const OUString aText(pNode->GetText().copy(nBegin, nLen));
-OUString aWord = 
aText.replaceAll(OUStringChar(CH_TXTATR_BREAKWORD), "")
-  .replaceAll(OUStringChar(CH_TXTATR_INWORD), 
"");
+// TODO: this doesn't handle fieldmarks properly
+ModelToViewHelper const aConversionMap(*pNode, GetLayout(),
+ExpandMode::ExpandFields | ExpandMode::ExpandFootnote | 
ExpandMode::ReplaceMode
+| (GetLayout()->IsHideRedlines() ? ExpandMode::HideDeletions : 
ExpandMode(0))
+| (GetViewOptions()->IsShowHiddenChar() ? ExpandMode(0) : 
ExpandMode::HideInvisible));
+auto const 
nBeginView(aConversionMap.ConvertToViewPosition(nBegin));
+OUString const aWord(aConversionMap.getViewText().copy(nBeginView,
+aConversionMap.ConvertToViewPosition(nBegin+nLen) - 
nBeginView));
 
 uno::Reference< XSpellChecker1 >  xSpell( ::GetSpellChecker() );
 if( xSpell.is() )


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-03-15 Thread Michael Stahl (via logerrit)
 sw/source/uibase/docvw/edtwin.cxx |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 846ff2d3723c120ad8972b6757a180e8cd627007
Author: Michael Stahl 
AuthorDate: Fri Mar 4 20:05:03 2022 +0100
Commit: Thorsten Behrens 
CommitDate: Wed Mar 16 02:08:07 2022 +0100

sw_redlinehide: fix crashes in SwEditWin Surrounding functions

These foolish functions write into the shell cursor!

But the shell cursor's node isn't necessarily the same as before with
merged paragraphs, so could crash with out of bounds indexes.

Better use Push()/Pop().

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131041
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit aac9bd235e65b27faf63e64bba3ecd94837381d6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131127
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 08690fe5c4e5028ccaebc80145be650caf62ea76)

Change-Id: I4fd0e2aa915b6c5448772a2c766848607bbf5aaa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131624
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 80c00954fa0e..0887baca08ed 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6285,8 +6285,7 @@ OUString SwEditWin::GetSurroundingText() const
 rSh.GetSelectedText( sReturn, ParaBreakType::ToOnlyCR  );
 else if( !rSh.HasSelection() )
 {
-SwPosition *pPos = rSh.GetCursor()->GetPoint();
-const sal_Int32 nPos = pPos->nContent.GetIndex();
+rSh.Push();
 
 // get the sentence around the cursor
 rSh.HideCursor();
@@ -6295,8 +6294,7 @@ OUString SwEditWin::GetSurroundingText() const
 rSh.GoEndSentence();
 rSh.GetSelectedText( sReturn, ParaBreakType::ToOnlyCR  );
 
-pPos->nContent = nPos;
-rSh.ClearMark();
+rSh.Pop(SwCursorShell::PopMode::DeleteCurrent);
 rSh.HideCursor();
 }
 
@@ -6318,13 +6316,13 @@ Selection SwEditWin::GetSurroundingTextSelection() const
 // around the visible cursor.
 SwPosition *pPos = rSh.GetCursor()->GetPoint();
 const sal_Int32 nPos = pPos->nContent.GetIndex();
+rSh.Push();
 
 rSh.HideCursor();
 rSh.GoStartSentence();
 const sal_Int32 nStartPos = 
rSh.GetCursor()->GetPoint()->nContent.GetIndex();
 
-pPos->nContent = nPos;
-rSh.ClearMark();
+rSh.Pop(SwCursorShell::PopMode::DeleteCurrent);
 rSh.ShowCursor();
 
 return Selection( nPos - nStartPos, nPos - nStartPos );


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-02-17 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/tabfrm.cxx |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit cf22078252d7163989d1e298fbbd61bd7c3621bf
Author: Michael Stahl 
AuthorDate: Thu Feb 10 19:43:08 2022 +0100
Commit: Thorsten Behrens 
CommitDate: Thu Feb 17 13:16:06 2022 +0100

sw: fix layout loop on soffice --convert-to pdf ooo95698-1.odt

For unknown reasons, this loops since commit
32902f66e7749b2d06d13f50416be5323a0c0ea9a
"sw_redlinehide: make layout based Show/Hide mode the default"

The problem is that when page 1 is layouted for the first time, it
splits into 6 pages, and then the SwTabFrame 47 decides that it wants
to move its follow flow line because it fits onto page 1.

Then splitting the SwTabFrame again fails, but for this
RemoveFollowFlowLine() was called a 2nd time and removed the one on
page 3.

The result is a layout with content on page 1, nothing on page 2, 3
and again content on page 4.  This seems to reoccur every time page 1
is formatted.

But the first RemoveFollowFlowLine() was wrong because
CalcHeightOfFirstContentLine() returns 0 because
lcl_CalcHeightOfFirstContentLine() didn't handle the case of
SwSectionFrame containing SwTabFrame.

This is similar to commit e024cad7c1365da6a198656c3ca0c32b28938e87
doing the same thing for text frames in section.

Change-Id: I23fb4d1d56622039f461bb2d357a9c88db140605
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129800
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit b4271e028686d729189afc5e42a9c310f81144f3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129828
Reviewed-by: Xisco Fauli 
(cherry picked from commit 60811f97c753360393f52aa747837db15a722162)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130047
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 719f08e5a363..2eb527e229ac 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -5506,9 +5506,12 @@ static SwTwips lcl_CalcHeightOfFirstContentLine( const 
SwRowFrame& rSourceLine )
 const SwRowFrame* pTmpSourceRow = static_cast(pCurrSourceCell->Lower());
 nTmpHeight = lcl_CalcHeightOfFirstContentLine( *pTmpSourceRow 
);
 }
-else if ( pTmp->IsTabFrame() )
+else if (pTmp->IsTabFrame() || (pTmp->IsSctFrame() && 
pTmp->GetLower() && pTmp->GetLower()->IsTabFrame()))
 {
-nTmpHeight = static_cast(pTmp)->CalcHeightOfFirstContentLine();
+SwTabFrame const*const pTabFrame(pTmp->IsTabFrame()
+? static_cast(pTmp)
+: static_cast(pTmp->GetLower()));
+nTmpHeight = pTabFrame->CalcHeightOfFirstContentLine();
 }
 else if (pTmp->IsTextFrame() || (pTmp->IsSctFrame() && 
pTmp->GetLower() && pTmp->GetLower()->IsTextFrame()))
 {


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-02-16 Thread Michael Stahl (via logerrit)
 sw/source/ui/fldui/fldref.cxx |   47 --
 1 file changed, 19 insertions(+), 28 deletions(-)

New commits:
commit bcd760e72c2b75cedf4adf5f5a949a57a8a3f1be
Author: Michael Stahl 
AuthorDate: Fri Feb 4 18:28:00 2022 +0100
Commit: Thorsten Behrens 
CommitDate: Thu Feb 17 01:27:06 2022 +0100

tdf#146462 sw: fix broken CrossReference field tab page

(regression from 40487d9c81c69c4e5ee1621e53c8162ae33c80b2)

Change-Id: Ifb4117a8fa5c393483209b2768f0b6ea4eea2d5e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129502
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 
(cherry picked from commit 6d5f22585003e1b0091eefad9d6a2446a1b510d1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130045
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 2b29583e7c8a..d13ed61cd550 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -477,11 +477,6 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 SwGetRefField const*const 
pRefField(dynamic_cast(GetCurField()));
 const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
 
-if (!pRefField)
-{
-return;
-}
-
 OUString sOldSel;
 // #i83479#
 if ( m_xSelectionLB->get_visible() )
@@ -490,7 +485,7 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 if (nSelectionSel != -1)
 sOldSel = m_xSelectionLB->get_text(nSelectionSel);
 }
-if (IsFieldEdit() && sOldSel.isEmpty())
+if (IsFieldEdit() && pRefField && sOldSel.isEmpty())
 sOldSel = OUString::number( pRefField->GetSeqNo() + 1 );
 
 m_xSelectionLB->freeze();
@@ -539,7 +534,7 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 }
 }
 }
-if (IsFieldEdit())
+if (IsFieldEdit() && pRefField)
 sOldSel = pRefField->GetSetRefName();
 }
 else if (nTypeId == REFFLDFLAG_FOOTNOTE)
@@ -554,7 +549,7 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 {
 m_xSelectionLB->append_text( aArr[ n ].sDlgEntry );
 }
-if (IsFieldEdit() && pRefField->GetSeqNo() == aArr[ n ].nSeqNo)
+if (IsFieldEdit() && pRefField && pRefField->GetSeqNo() == 
aArr[ n ].nSeqNo)
 sOldSel = aArr[n].sDlgEntry;
 }
 }
@@ -570,7 +565,7 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 {
 m_xSelectionLB->append_text( aArr[ n ].sDlgEntry );
 }
-if (IsFieldEdit() && pRefField->GetSeqNo() == aArr[ n ].nSeqNo)
+if (IsFieldEdit() && pRefField && pRefField->GetSeqNo() == 
aArr[ n ].nSeqNo)
 sOldSel = aArr[n].sDlgEntry;
 }
 }
@@ -594,9 +589,9 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 OUString sId(OUString::number(nOutlIdx));
 m_xSelectionToolTipLB->append(sId,
 pIDoc->getOutlineText(nOutlIdx, pSh->GetLayout(), 
true, true, false));
-if ( ( IsFieldEdit() &&
-   pRefField->GetReferencedTextNode() == 
maOutlineNodes[nOutlIdx] ) ||
-mpSavedSelectedTextNode == maOutlineNodes[nOutlIdx] )
+if ((IsFieldEdit() && pRefField
+&& pRefField->GetReferencedTextNode() == 
maOutlineNodes[nOutlIdx])
+|| mpSavedSelectedTextNode == maOutlineNodes[nOutlIdx])
 {
 m_sSelectionToolTipLBId = sId;
 sOldSel.clear();
@@ -629,9 +624,9 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 OUString sId(OUString::number(nNumItemIdx));
 m_xSelectionToolTipLB->append(sId,
 pIDoc->getListItemText(*maNumItems[nNumItemIdx], 
*pSh->GetLayout()));
-if ( ( IsFieldEdit() &&
-   pRefField->GetReferencedTextNode() == 
maNumItems[nNumItemIdx]->GetTextNode() ) ||
-mpSavedSelectedTextNode == 
maNumItems[nNumItemIdx]->GetTextNode() )
+if ((IsFieldEdit() && pRefField
+&& pRefField->GetReferencedTextNode() == 
maNumItems[nNumItemIdx]->GetTextNode())
+|| mpSavedSelectedTextNode == 
maNumItems[nNumItemIdx]->GetTextNode())
 {
 m_sSelectionToolTipLBId = sId;
 sOldSel.clear();
@@ -666,12 +661,12 @@ void SwFieldRefPage::UpdateSubType(const OUString& 
filterString)
 {
 

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-02-16 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/frmtool.cxx |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 41dcf7e756ef14e624733adbe77d85efe1f506b7
Author: Michael Stahl 
AuthorDate: Thu Dec 23 19:17:24 2021 +0100
Commit: Thorsten Behrens 
CommitDate: Wed Feb 16 22:58:32 2022 +0100

tdf#138743 sw_redlinehide: delete FlyFrames when hiding tracked changes

Cannot remember why but when RemoveHiddenObjsOfNode() was added in
commit 464ef392f901c6e2ad3d32df8b039f2226073cf4 only as-char draw shapes
were removed from the draw page, but as-char fly frames remained.

For these only a barely visible border is painted sometimes, but the
problem is they remain as a mouse click target, not sure how i didn't
notice this earlier.

Somehow image painting is wonky on current master, works fine on 7.1.

Change-Id: Ie4e20f6a399daadda1badf155ba510445394f5e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127366
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 2954039767e1adab7a65838b61a449b701f244a4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127373
Reviewed-by: Thorsten Behrens 
(cherry picked from commit cc33e4d46cb43ba9285ea3deaacbd4ee6374dd0f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130048
Tested-by: Thorsten Behrens 

diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index 2a604cf8a15c..9b3386a9b4df 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1162,8 +1162,7 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode,
 {
 SwFormatAnchor const& rAnchor = pFrameFormat->GetAnchor();
 if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR
-|| (rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR
-&& RES_DRAWFRMFMT == pFrameFormat->Which()))
+|| rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR)
 {
 assert(rAnchor.GetContentAnchor()->nNode.GetIndex() == 
rNode.GetIndex());
 if (!IsShown(rNode.GetIndex(), rAnchor, pIter, pEnd, pFirstNode, 
pLastNode))


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2022-02-11 Thread Caolán McNamara (via logerrit)
 sw/source/filter/ww8/wrtw8sty.cxx |   28 ++--
 sw/source/filter/ww8/wrtww8.hxx   |4 ++--
 2 files changed, 16 insertions(+), 16 deletions(-)

New commits:
commit 5ce7ff04b3c0352ad7573367e464dd8156e714da
Author: Caolán McNamara 
AuthorDate: Thu Feb 10 10:53:27 2022 +
Commit: Thorsten Behrens 
CommitDate: Fri Feb 11 16:22:05 2022 +0100

limit style export to words max style count

and

use std::vector

LIBREOFFICE-U78X8I5G

Change-Id: I436b4c13a4ce07f5e9e5d374163bc4de55cd2cde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129766
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 8e94ec9d93fe3e1057fb1aaa2f0419114c4ea11c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129817
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/filter/ww8/wrtw8sty.cxx 
b/sw/source/filter/ww8/wrtw8sty.cxx
index 8a315444a133..6228526a88ba 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -151,13 +151,13 @@ MSWordStyles::MSWordStyles( MSWordExportBase& rExport, 
bool bListStyles )
 m_rExport.m_pDoc->GetFootnoteInfo().GetAnchorCharFormat( 
*m_rExport.m_pDoc );
 m_rExport.m_pDoc->GetFootnoteInfo().GetCharFormat( *m_rExport.m_pDoc );
 }
-sal_uInt16 nAlloc = WW8_RESERVED_SLOTS + 
m_rExport.m_pDoc->GetCharFormats()->size() - 1 +
+sal_uInt32 nAlloc = WW8_RESERVED_SLOTS + 
m_rExport.m_pDoc->GetCharFormats()->size() - 1 +
  
m_rExport.m_pDoc->GetTextFormatColls()->size() - 1 +
  (bListStyles ? 
m_rExport.m_pDoc->GetNumRuleTable().size() - 1 : 0);
+nAlloc = std::min(nAlloc, MSWORD_MAX_STYLES_LIMIT);
 
 // somewhat generous ( free for up to 15 )
-m_pFormatA.reset( new SwFormat*[ nAlloc ] );
-memset( m_pFormatA.get(), 0, nAlloc * sizeof( SwFormat* ) );
+m_aFormatA.resize(nAlloc, nullptr);
 memset( m_aHeadingParagraphStyles, -1 , MAXLEVEL * sizeof( sal_uInt16));
 
 BuildStylesTable();
@@ -173,7 +173,7 @@ sal_uInt16 MSWordStyles::GetSlot( const SwFormat* pFormat ) 
const
 {
 sal_uInt16 n;
 for ( n = 0; n < m_nUsedSlots; n++ )
-if ( m_pFormatA[n] == pFormat )
+if ( m_aFormatA[n] == pFormat )
 return n;
 return 0xfff;   // 0xfff: WW: zero
 }
@@ -282,19 +282,19 @@ void MSWordStyles::BuildStylesTable()
 
 const SwCharFormats& rArr = *m_rExport.m_pDoc->GetCharFormats();   // 
first CharFormat
 // the default character style ( 0 ) will not be outputted !
-for( size_t n = 1; n < rArr.size(); n++ )
+for( size_t n = 1; n < rArr.size() && m_nUsedSlots < 
MSWORD_MAX_STYLES_LIMIT; n++ )
 {
 SwCharFormat* pFormat = rArr[n];
-m_pFormatA[ BuildGetSlot( *pFormat ) ] = pFormat;
+m_aFormatA[ BuildGetSlot( *pFormat ) ] = pFormat;
 }
 
 const SwTextFormatColls& rArr2 = *m_rExport.m_pDoc->GetTextFormatColls();  
 // then TextFormatColls
 // the default character style ( 0 ) will not be outputted !
-for( size_t n = 1; n < rArr2.size(); n++ )
+for( size_t n = 1; n < rArr2.size() && m_nUsedSlots < 
MSWORD_MAX_STYLES_LIMIT; n++ )
 {
 SwTextFormatColl* pFormat = rArr2[n];
 sal_uInt16 nId = BuildGetSlot( *pFormat ) ;
-m_pFormatA[ nId ] = pFormat;
+m_aFormatA[ nId ] = pFormat;
 if ( pFormat->IsAssignedToListLevelOfOutlineStyle() )
 {
 int nLvl = pFormat->GetAssignedOutlineStyleLevel() ;
@@ -307,7 +307,7 @@ void MSWordStyles::BuildStylesTable()
 return;
 
 const SwNumRuleTable& rNumRuleTable = m_rExport.m_pDoc->GetNumRuleTable();
-for (size_t i = 0; i < rNumRuleTable.size(); ++i)
+for (size_t i = 0; i < rNumRuleTable.size() && m_nUsedSlots < 
MSWORD_MAX_STYLES_LIMIT; ++i)
 {
 const SwNumRule* pNumRule = rNumRuleTable[i];
 if (pNumRule->IsAutoRule() || pNumRule->GetName().startsWith("WWNum"))
@@ -347,8 +347,8 @@ void MSWordStyles::BuildStyleIds()
 for (sal_uInt16 n = 1; n < m_nUsedSlots; ++n)
 {
 OUString aName;
-if(m_pFormatA[n])
-aName = m_pFormatA[n]->GetName();
+if (m_aFormatA[n])
+aName = m_aFormatA[n]->GetName();
 else if (m_aNumRules.find(n) != m_aNumRules.end())
 aName = m_aNumRules[n]->GetName();
 
@@ -612,8 +612,8 @@ void MSWordStyles::OutputStyle( SwFormat* pFormat, 
sal_uInt16 nPos )
 for ( int nSuffix = 0; ; ++nSuffix ) {
 bool clash=false;
 for ( sal_uInt16 n = 1; n < m_nUsedSlots; ++n )
-if ( m_pFormatA[n] &&
- m_pFormatA[n]->GetName().equalsIgnoreAsciiCase(aName) 
)
+if ( m_aFormatA[n] &&
+ m_aFormatA[n]->GetName().equalsIgnoreAsciiCase(aName) 
)
 {

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-12-22 Thread Michael Stahl (via logerrit)
 sw/source/ui/fldui/flddb.cxx   |   12 +---
 sw/source/ui/fldui/flddinf.cxx |   22 +-
 sw/source/ui/fldui/fldref.cxx  |   21 ++---
 3 files changed, 44 insertions(+), 11 deletions(-)

New commits:
commit 5b450e20af175e76e858d205e49b1c1e93644359
Author: Michael Stahl 
AuthorDate: Fri Dec 17 18:46:29 2021 +0100
Commit: Michael Stahl 
CommitDate: Wed Dec 22 13:57:06 2021 +0100

tdf#145062 sw: try to fix UBSan crash in UITest

  /sw/source/ui/fldui/fldref.cxx:470:32: runtime error: downcast of address 
0x60700065f330 which does not point to an object of type 'SwGetRefField'
  0x60700065f330: note: object is of type 'SwInputField'
   a8 04 00 78  30 d8 f7 f1 8c 2b 00 00  60 9a d4 4c 8c 2b 00 00  00 b6 57 
00 10 61 00 00  00 00 00 00
^~~
vptr for 'SwInputField'
  #0 0x2b917d44b1fc in SwFieldRefPage::UpdateSubType(rtl::OUString 
const&) /sw/source/ui/fldui/fldref.cxx:470:32
  #1 0x2b917d463aa9 in SwFieldRefPage::TypeHdl(weld::TreeView&) 
/sw/source/ui/fldui/fldref.cxx:358:5
  #2 0x2b917d45f9e4 in SwFieldRefPage::Reset(SfxItemSet const*) 
/sw/source/ui/fldui/fldref.cxx:258:5
  #3 0x2b917d436efd in SwFieldPage::EditNewField(bool) 
/sw/source/ui/fldui/fldpage.cxx:110:5
  #4 0x2b917d48e725 in 
SwFieldDlg::ReInitTabPage(std::basic_string_view 
>, bool) /sw/source/ui/fldui/fldtdlg.cxx:214:16
  #5 0x2b917d48f411 in SwFieldDlg::Activate() 
/sw/source/ui/fldui/fldtdlg.cxx:233:9
  #9 0x2b8c8ac6f2b8 in Timer::Invoke() /vcl/source/app/timer.cxx:75:21
  #16 0x2b8c8abaec67 in Application::Yield() 
/vcl/source/app/svapp.cxx:532:5
  #17 0x2b8c87842191 in Dialog::Execute() 
/vcl/source/window/dialog.cxx:1056:9
  #18 0x2b8c8a7bfabd in SalInstanceDialog::run() 
/vcl/source/app/salvtables.cxx:1685:23
  #19 0x2b917cc6879c in weld::DialogController::run() 
/include/vcl/weld.hxx:2516:47
  #20 0x2b917cf6e99c in SwFieldInputDlg::run() 
/sw/source/uibase/inc/inpdlg.hxx:56:47

Apparently SwFieldPage::Init() is called from SwFieldRefPage::Reset()
and replaces m_pCurField with whatever is at the cursor position now.

This should avoid crashes but it's kind of ugly. Should the dialog
perhaps switch to a different tab page?

Change-Id: I9c46665680090a5f164fd5d594fd3e7b1ab31f48
(cherry picked from commit d73f2e3132786a20794e3ac66f9b487fc737d514)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127307
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index 01b9065cd36e..937c2b265c71 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -299,12 +299,18 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox)
 OUString sColumnName;
 if (nTypeId == SwFieldTypesEnum::Database)
 {
-aData = static_cast(GetCurField())->GetDBData();
-sColumnName = 
static_cast(GetCurField()->GetTyp())->GetColumnName();
+if (auto const*const pField = 
dynamic_cast(GetCurField()))
+{
+aData = pField->GetDBData();
+sColumnName = 
static_cast(GetCurField()->GetTyp())->GetColumnName();
+}
 }
 else
 {
-aData = 
static_cast(GetCurField())->GetDBData(pSh->GetDoc());
+if (auto *const pField = 
dynamic_cast(GetCurField()))
+{
+aData = pField->GetDBData(pSh->GetDoc());
+}
 }
 m_xDatabaseTLB->Select(aData.sDataSource, aData.sCommand, sColumnName);
 }
diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index 92d263a6efd1..4fe4d8b41aaa 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -99,10 +99,13 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* )
 if (IsFieldEdit())
 {
 const SwField* pCurField = GetCurField();
-nSubType = static_cast(pCurField)->GetSubType() 
& 0xff;
+nSubType = pCurField->GetSubType() & 0xff;
 if( nSubType == DI_CUSTOM )
 {
-m_sOldCustomFieldName = static_cast(pCurField)->GetName();
+if (auto const pField = dynamic_cast(pCurField))
+{
+m_sOldCustomFieldName = pField->GetName();
+}
 }
 m_xFormatLB->SetAutomaticLanguage(pCurField->IsAutomaticLanguage());
 SwWrtShell *pSh = GetWrtShell();
@@ -311,12 +314,17 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, 
weld::TreeView&, void)
 bEnable = true;
 }
 
-sal_uInt32 nFormat = IsFieldEdit() ? 
static_cast(GetCurField())->GetFormat() : 0;
+sal_uInt32 nFormat = 0;
 
-sal_uInt16 nOldSubType = IsFieldEdit() ? 
(static_cast(GetCurField())->GetSubType() & 0xff00) : 0;
+sal_uInt16 nOldSubType = 0;
 
 if 

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-12-22 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/docnew.cxx |   21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

New commits:
commit beae7a08c30f2f368708dbc7a9988ecfad08af60
Author: Michael Stahl 
AuthorDate: Thu Dec 16 13:36:46 2021 +0100
Commit: Michael Stahl 
CommitDate: Wed Dec 22 13:09:03 2021 +0100

tdf#144565 sw_redlinehide: fix mailmerge when flys anchored at last node

The InsertPageBreak() calls SplitNode() which is not ideal as the flys
anchored at the last node of the document may end up anchored to the
newly inserted node and this one will be removed again a bit further on:
  GetNodes().Delete( aDelIdx, iDelNodes );

... which is what crashes, when the SwNodeIndex of the anchor is moved
hard to a different node, which causes inconsistencies such as:

sw/source/core/text/txtfrm.cxx:1263: TextFrameIndex 
SwTextFrame::MapModelToView(const SwTextNode*, sal_Int32) const: Assertion 
`static_cast(const_cast(SwFrame::GetDep()))
 == pNode' failed.

Instead, always use AppendTextNode() and then set the break item
directly, which even simplifies the code.

(reportedly a regression from 166b5010b402a41b192b1659093a25acf9065fd9
 although i wasn't able to find an earlier version that didn't crash
 in some way)

Change-Id: I4cac74fc86fc505f62b14cf0d7a7f9689c7402ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126921
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 42448f48bb48a13d6618a181b12840db6d85c574)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126945
Reviewed-by: Caolán McNamara 
(cherry picked from commit eb4ab0c70c549cabf5625a824eee950f82fbf622)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127305
Tested-by: Michael Stahl 

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 984f2335bc45..e125e44420b7 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1054,19 +1054,14 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, 
sal_uInt16 const nStartPageNu
 {
 SwNodeIndex aBreakIdx( GetNodes().GetEndOfContent(), -1 );
 SwPosition aBreakPos( aBreakIdx );
-// InsertPageBreak just works on SwTextNode nodes, so make
-// sure the last node is one!
-bool bIsTextNode = aBreakIdx.GetNode().IsTextNode();
-if ( !bIsTextNode )
-getIDocumentContentOperations().AppendTextNode( aBreakPos );
-const OUString name = pTargetPageDesc->GetName();
-pTargetShell->InsertPageBreak( , nStartPageNumber );
-if ( !bIsTextNode )
-{
-pTargetShell->SttEndDoc( false );
---aBreakIdx;
-GetNodes().Delete( aBreakIdx );
-}
+// insert new node - will be removed at the end...
+// (don't SplitNode() as it may move flys to the wrong node)
+getIDocumentContentOperations().AppendTextNode(aBreakPos);
+SwFormatPageDesc pageDesc(pTargetPageDesc);
+pageDesc.SetNumOffset(nStartPageNumber);
+// set break on the last paragraph
+getIDocumentContentOperations().InsertPoolItem(SwPaM(aBreakPos),
+pageDesc, SetAttrMode::DEFAULT, pTargetShell->GetLayout());
 
 // There is now a new empty text node on the new page. If it has
 // any marks, those are from the previous page: move them back


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-12-21 Thread Justin Luth (via logerrit)
 sw/source/core/edit/acorrect.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 55a7fde6bbe62eb9be2f48f1e97ac86192d932c8
Author: Justin Luth 
AuthorDate: Thu Nov 11 12:28:21 2021 +0200
Commit: Thorsten Behrens 
CommitDate: Tue Dec 21 23:51:46 2021 +0100

tdf#139922 sw autocorr: don't return GetPrevPara if isEmpty

This fixes a LO 6.2 regression caused by
commit 4cf5a46f16dec8ce16c6662ce5c17903e28b8fa3.

Change-Id: I4aee8f4e79a40a8b8f82faa3e62dead80a952510
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125037
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Michael Stahl 
(cherry picked from commit 59dc5d00b04927d07df2dcc3c17acfdc760d8765)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125144
(cherry picked from commit 133fe29d06445daadc556cff013d5194a883ea9b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127156
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 7304e6e7b702..286d4d078de5 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -346,8 +346,11 @@ OUString const* SwAutoCorrDoc::GetPrevPara(bool const 
bAtNormalPos)
 }
 sw::GotoPrevLayoutTextFrame(*pIdx, rEditSh.GetLayout());
 }
-if (pFrame && 0 == 
pFrame->GetTextNodeForParaProps()->GetAttrOutlineLevel())
+if (pFrame && !pFrame->GetText().isEmpty() &&
+0 == pFrame->GetTextNodeForParaProps()->GetAttrOutlineLevel())
+{
 pStr = & pFrame->GetText();
+}
 
 if( bUndoIdInitialized )
 bUndoIdInitialized = true;


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-12-21 Thread Vasily Melenchuk (via logerrit)
 sw/source/filter/ww8/docxattributeoutput.cxx |  765 +++
 sw/source/filter/ww8/docxattributeoutput.hxx |   73 +-
 2 files changed, 356 insertions(+), 482 deletions(-)

New commits:
commit c635dcd89a62a015daddd2976eaef1db771a0ab8
Author: Vasily Melenchuk 
AuthorDate: Tue Nov 16 18:12:39 2021 +0300
Commit: Thorsten Behrens 
CommitDate: Tue Dec 21 12:48:14 2021 +0100

sw: refactoring for docx sdt blocks output

Previous approach with almost duplicate storage and processing
for paragraph-level and run-level sdt blocks was very bulky.
Especially this became visible once supported std elements list
start to grow.

Paragraph-level sdt block and run-level sdt block data are almost
identical, so they can be kept in one standard class
(SdtBlockHelper) and use the same methods for collecting data
from grabbags and writing to output without passing huge amount
of parameters.

Change-Id: I4e1183eddf20317e954cb8aca72e97a4fc45ac68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125372
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
Reviewed-by: Vasily Melenchuk 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127158
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 78673d876df9..31c05f3a7efb 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -301,6 +301,28 @@ static bool lcl_isOnelinerSdt(const OUString& rName)
 return rName == "Title" || rName == "Subtitle" || rName == "Company";
 }
 
+static void AddToAttrList(rtl::Reference& 
pAttrList, sal_Int32 nAttrs, ...)
+{
+if (!pAttrList.is())
+pAttrList = FastSerializerHelper::createAttrList();
+
+va_list args;
+va_start(args, nAttrs);
+for (sal_Int32 i = 0; i < nAttrs; i++)
+{
+sal_Int32 nName = va_arg(args, sal_Int32);
+const char* pValue = va_arg(args, const char*);
+if (pValue)
+pAttrList->add(nName, pValue);
+}
+va_end(args);
+}
+
+static void AddToAttrList(rtl::Reference& 
pAttrList, sal_Int32 nAttrName, const char* sAttrValue)
+{
+AddToAttrList(pAttrList, 1, nAttrName, sAttrValue);
+}
+
 // write a floating table directly to docx without the surrounding frame
 void DocxAttributeOutput::WriteFloatingTable(ww8::Frame const* pParentFrame)
 {
@@ -438,7 +460,7 @@ void DocxAttributeOutput::StartParagraph( 
ww8::WW8TableNodeInfo::Pointer_t pText
 // would normally arrive, it would be too late (would be after the
 // paragraph start has been written).
 bool bEndParaSdt = false;
-if (m_bStartedParaSdt)
+if (m_aParagraphSdt.m_bStartedSdt)
 {
 SwTextNode* pTextNode = m_rExport.m_pCurPam->GetNode().GetTextNode();
 if (pTextNode && pTextNode->GetpSwAttrSet())
@@ -448,17 +470,16 @@ void DocxAttributeOutput::StartParagraph( 
ww8::WW8TableNodeInfo::Pointer_t pText
 {
 const SfxGrabBagItem& rParaGrabBag = static_cast(*pItem);
 const std::map& rMap = 
rParaGrabBag.GetGrabBag();
-bEndParaSdt = m_bStartedParaSdt && 
rMap.find("ParaSdtEndBefore") != rMap.end();
+bEndParaSdt = m_aParagraphSdt.m_bStartedSdt && 
rMap.find("ParaSdtEndBefore") != rMap.end();
 }
 }
 }
 // TODO also avoid multiline paragraphs in those SDT types for shape text
-bool bOneliner = m_bStartedParaSdt && 
!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen() && 
lcl_isOnelinerSdt(m_aStartedParagraphSdtPrAlias);
-if (bEndParaSdt || (m_bStartedParaSdt && m_bHadSectPr) || bOneliner)
+bool bOneliner = m_aParagraphSdt.m_bStartedSdt && 
!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen() && 
lcl_isOnelinerSdt(m_aStartedParagraphSdtPrAlias);
+if (bEndParaSdt || (m_aParagraphSdt.m_bStartedSdt && m_bHadSectPr) || 
bOneliner)
 {
 // This is the common case: "close sdt before the current paragraph" 
was requested by the next paragraph.
-EndSdtBlock();
-m_bStartedParaSdt = false;
+m_aParagraphSdt.EndSdtBlock(m_pSerializer);
 m_aStartedParagraphSdtPrAlias.clear();
 }
 m_bHadSectPr = false;
@@ -551,24 +572,265 @@ static OString convertToOOXMLHoriOrientRel(sal_Int16 
nOrientRel)
 }
 }
 
-static void lcl_deleteAndResetTheLists(
-rtl::Reference& pSdtPrTokenChildren,
-rtl::Reference& pSdtPrDataBindingAttrs,
-rtl::Reference& pSdtPrTextAttrs,
-OUString& rSdtPrAlias, OUString& rSdtPrPlaceholderDocPart, OUString& 
rColor)
+void SdtBlockHelper::DeleteAndResetTheLists()
 {
-if( pSdtPrTokenChildren.is() )
-pSdtPrTokenChildren.clear();
-if( pSdtPrDataBindingAttrs.is() )
-pSdtPrDataBindingAttrs.clear();
-if (pSdtPrTextAttrs.is())
-pSdtPrTextAttrs.clear();
-if (!rSdtPrAlias.isEmpty())
-

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-12-17 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/DocumentContentOperationsManager.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit dc3a473ef127bf804ffe23e5db869db6d61bd7a9
Author: Michael Stahl 
AuthorDate: Tue Dec 14 19:34:36 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Dec 17 11:24:55 2021 +0100

tdf#141175 sw_redlinehide: fix crash in lcl_DeleteRedlines()

The GetNext() returns itself if it's alone in the Ring.

(regression from 27aa4b16bf704d0246595750daf57b57ff2577b3)

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126844
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 19f2054c6063177d08c818c5b7eeba7ab9178249)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126824
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 7b672a6d89581885c305068a714a72b5352de12f)

Change-Id: Idf92ce5362c4a4acf1582f463fe7bafc8553b400
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126954
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index c3e5298c81da..758c990e927e 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -387,7 +387,8 @@ namespace
 *pDelPam->GetPoint(), 
nDelCount );
 }
 
-if (pDelPam->GetNext() && 
*pDelPam->GetNext()->End() == *pDelPam->Start())
+if (pDelPam->GetNext() != pDelPam.get()
+&& *pDelPam->GetNext()->End() == 
*pDelPam->Start())
 {
 *pDelPam->GetNext()->End() = *pDelPam->End();
 pDelPam.reset(pDelPam->GetNext());


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-12-17 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/DocumentContentOperationsManager.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 9d66c93dba0e91e8023d549d9eb5521d7829cb3f
Author: Michael Stahl 
AuthorDate: Tue Dec 14 17:32:28 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Dec 17 11:24:39 2021 +0100

tdf#136855 sw: fix ReplaceRangeImpl() restoring of rPam

This broke in CWS swrefactormarks2 (commit
df6d312ca537402463e4eb0530f22b956600fc02) but for spell-checking the
ReplaceRange() wasn't used until commit
e1629c210ad78310e3d48c0756723134a27b89df.

Change-Id: I4a6256b65b89e21e9e87ff45d0c5e6c4577a5846
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126842
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit d16c5f47600d236e911ae50d0e58a3f2256f5a61)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126822
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 6af4500fffe0d0db03b4d4a7e77cf627124aefc1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126953
Tested-by: Michael Stahl 

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 5afadfff3de8..c3e5298c81da 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4406,8 +4406,8 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( 
SwPaM& rPam, const OUSt
 m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( eOld );
 
 *rPam.GetPoint() = pBkmk->GetMarkPos();
-if(pBkmk->IsExpanded())
-*rPam.GetMark() = pBkmk->GetOtherMarkPos();
+*rPam.GetMark() = pBkmk->IsExpanded() ? 
pBkmk->GetOtherMarkPos() : pBkmk->GetMarkPos();
+
 m_rDoc.getIDocumentMarkAccess()->deleteMark(pBkmk);
 }
 bJoinText = false;


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-11-17 Thread Michael Stahl (via logerrit)
 sw/source/filter/html/htmltab.cxx |   10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

New commits:
commit f53189e02c6017f2ba6d7d83ead69f763d3b29aa
Author: Michael Stahl 
AuthorDate: Wed Nov 17 11:04:19 2021 +0100
Commit: Michael Stahl 
CommitDate: Wed Nov 17 12:21:26 2021 +0100

oops, fix merge error in commit 08abcae56b13b11d699a30553f7edfc54225d687

"ofz#40593 remove Objects from m_xResizeDrawObjects if deleted during parse"

Change-Id: I715530cc19b670eef109e59148db2aac05bd33be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125376
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/filter/html/htmltab.cxx 
b/sw/source/filter/html/htmltab.cxx
index f90b77522319..670ed3ae7aeb 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -1069,19 +1069,15 @@ bool SwHTMLParser::IsReqIF() const
 }
 
 // if any m_pResizeDrawObjects members are deleted during parse, remove them
-// from m_pResizeDrawObjects and m_xDrawObjectPercentWidths
+// from m_pResizeDrawObjects and m_pDrawObjectPrcWidths
 void HTMLTable::ObjectInDestruction(const SdrObject& rObject)
 {
 auto it = std::find(m_pResizeDrawObjects->begin(), 
m_pResizeDrawObjects->end(), );
 assert(it != m_pResizeDrawObjects->end());
-#if 0
 auto nIndex = std::distance(m_pResizeDrawObjects->begin(), it);
-#endif
 m_pResizeDrawObjects->erase(it);
-#if 0
-auto otherit = m_xDrawObjectPercentWidths->begin() + nIndex * 3;
-m_xDrawObjectPercentWidths->erase(otherit, otherit + 3);
-#endif
+auto otherit = m_pDrawObjectPrcWidths->begin() + nIndex * 3;
+m_pDrawObjectPrcWidths->erase(otherit, otherit + 3);
 }
 
 HTMLTable::~HTMLTable()


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-11-17 Thread Caolán McNamara (via logerrit)
 sw/source/filter/ww8/ww8par.cxx |4 ++--
 sw/source/filter/ww8/ww8par.hxx |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 581bb5fedca6644ceac22d4947833dff5396265e
Author: Caolán McNamara 
AuthorDate: Sat Sep 25 19:57:36 2021 +0100
Commit: Michael Stahl 
CommitDate: Wed Nov 17 10:29:21 2021 +0100

ofz#39252 use safer SwUnoCursor for the pos to move back to

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122611
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit ca844cbdc3e933e3082e9cde0632445916de819e)

Change-Id: Iba6f200cea92196986bd30564cf56ab5d8b954b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125329
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 1a99e0805e98..41beb52670ff 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1992,7 +1992,7 @@ void SwWW8ImplReader::ImportDopTypography(const 
WW8DopTypography )
  * Footnotes and Endnotes
  */
 WW8ReaderSave::WW8ReaderSave(SwWW8ImplReader* pRdr ,WW8_CP nStartCp) :
-maTmpPos(*pRdr->m_pPaM->GetPoint()),
+mxTmpPos(pRdr->m_rDoc.CreateUnoCursor(*pRdr->m_pPaM->GetPoint())),
 mxOldStck(std::move(pRdr->m_xCtrlStck)),
 mxOldAnchorStck(std::move(pRdr->m_xAnchorStck)),
 mxOldRedlines(std::move(pRdr->m_xRedlineStack)),
@@ -2090,7 +2090,7 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
 pRdr->DeleteAnchorStack();
 pRdr->m_xAnchorStck = std::move(mxOldAnchorStck);
 
-*pRdr->m_pPaM->GetPoint() = maTmpPos;
+*pRdr->m_pPaM->GetPoint() = GetStartPos();
 
 if (mxOldPlcxMan != pRdr->m_xPlcxMan)
 pRdr->m_xPlcxMan = mxOldPlcxMan;
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 9f19f48d463b..f98853d82295 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -589,7 +589,7 @@ class WW8ReaderSave
 {
 private:
 WW8PLCFxSaveAll maPLCFxSave;
-SwPosition const maTmpPos;
+std::shared_ptr mxTmpPos;
 std::deque maOldApos;
 std::deque maOldFieldStack;
 std::unique_ptr mxOldStck;
@@ -617,7 +617,7 @@ private:
 public:
 WW8ReaderSave(SwWW8ImplReader* pRdr, WW8_CP nStart=-1);
 void Restore(SwWW8ImplReader* pRdr);
-const SwPosition () const { return maTmpPos; }
+const SwPosition () const { return *mxTmpPos->GetPoint(); }
 };
 
 enum class eF_ResT { OK, TEXT, TAGIGN, READ_FSPA };


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-11-16 Thread Caolán McNamara (via logerrit)
 sw/source/core/inc/layact.hxx|8 +-
 sw/source/core/layout/layact.cxx |   51 +++
 2 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit 55f07410ed109acd01b29fdc72dbeb95c661ed50
Author: Caolán McNamara 
AuthorDate: Fri Jul 16 12:45:21 2021 +0100
Commit: Michael Stahl 
CommitDate: Tue Nov 16 10:44:57 2021 +0100

crashtesting: UaF on layout of fdo53985-1.docx

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119060
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit ceb32f59d96a17c3007ed883fb44bc880673c8e0)

Change-Id: Id8ca0d277f485347e21bd8d6d68de2a7de13de48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125241
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx
index 37fc4a9aae9e..75a0523fda7f 100644
--- a/sw/source/core/inc/layact.hxx
+++ b/sw/source/core/inc/layact.hxx
@@ -68,6 +68,9 @@ class SwLayAction
 
 std::unique_ptr m_pWait;
 
+std::vector m_aFrameStack;
+std::vector> m_aFrameDeleteGuards;
+
 // If a paragraph (or anything else) moved more than one page when
 // formatting, it adds its new page number here.
 // The InternalAction can then take the appropriate steps.
@@ -124,6 +127,9 @@ class SwLayAction
 
 bool RemoveEmptyBrowserPages();
 
+void PushFormatLayout(SwFrame* pLow);
+void PopFormatLayout();
+
 public:
 SwLayAction(SwRootFrame *pRt, SwViewShellImp *pImp, TaskStopwatch* pWatch 
= nullptr);
 ~SwLayAction();
@@ -148,7 +154,7 @@ public:
 void SetReschedule  ( bool bNew )   { m_bReschedule = bNew; }
 void SetWaitAllowed ( bool bNew )   { m_bWaitAllowed = bNew; }
 
-void SetAgain(bool bAgain) { m_bAgain = bAgain; }
+void SetAgain(bool bAgain);
 void SetUpdateExpFields() {m_bUpdateExpFields = true; }
 
 inline void SetCheckPageNum( sal_uInt16 nNew );
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index d677bccbdb22..1600f556e32a 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -321,6 +321,53 @@ bool SwLayAction::RemoveEmptyBrowserPages()
 return bRet;
 }
 
+void SwLayAction::SetAgain(bool bAgain)
+{
+if (bAgain == m_bAgain)
+return;
+
+m_bAgain = bAgain;
+
+assert(m_aFrameStack.size() == m_aFrameDeleteGuards.size());
+size_t nCount = m_aFrameStack.size();
+if (m_bAgain)
+{
+// LayAction::FormatLayout is now flagged to exit early and will avoid
+// dereferencing any SwFrames in the stack of FormatLayouts so allow
+// their deletion
+for (size_t i = 0; i < nCount; ++i)
+m_aFrameDeleteGuards[i].reset();
+}
+else
+{
+// LayAction::FormatLayout is now continue normally and will
+// dereference the top SwFrame in the stack of m_aFrameStack as each
+// FormatLevel returns so disallow their deletion
+for (size_t i = 0; i < nCount; ++i)
+m_aFrameDeleteGuards[i] = 
std::make_unique(m_aFrameStack[i]);
+}
+}
+
+void SwLayAction::PushFormatLayout(SwFrame* pLow)
+{
+/* Workaround crash seen in crashtesting with fdo53985-1.docx
+
+   Lock pLow against getting deleted when it will be dereferenced
+   after FormatLayout
+
+   If SetAgain is called to make SwLayAction exit early to avoid that
+   dereference, then it clears these guards
+*/
+m_aFrameStack.push_back(pLow);
+m_aFrameDeleteGuards.push_back(std::make_unique(pLow));
+}
+
+void SwLayAction::PopFormatLayout()
+{
+m_aFrameDeleteGuards.pop_back();
+m_aFrameStack.pop_back();
+}
+
 void SwLayAction::Action(OutputDevice* pRenderContext)
 {
 m_bActionInProgress = true;
@@ -1380,7 +1427,11 @@ bool SwLayAction::FormatLayout( OutputDevice 
*pRenderContext, SwLayoutFrame *pLa
 }
 // Skip the ones already registered for deletion
 else if( !pLow->IsSctFrame() || 
static_cast(pLow)->GetSection() )
+{
+PushFormatLayout(pLow);
 bChanged |= FormatLayout( pRenderContext, 
static_cast(pLow), bAddRect );
+PopFormatLayout();
+}
 }
 else if ( m_pImp->GetShell()->IsPaintLocked() )
 // Shortcut to minimize the cycles. With Lock, the


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-11-16 Thread Caolán McNamara (via logerrit)
 sw/source/core/inc/layact.hxx   |2 +-
 sw/source/core/layout/layact.cxx|   14 +-
 sw/source/core/layout/objectformattertxtfrm.cxx |2 +-
 sw/source/core/layout/pagechg.cxx   |2 +-
 4 files changed, 12 insertions(+), 8 deletions(-)

New commits:
commit a485769c98a92dfa1da1be60d2f85a2343b1ca42
Author: Caolán McNamara 
AuthorDate: Thu Jul 15 14:13:35 2021 +0100
Commit: Michael Stahl 
CommitDate: Tue Nov 16 10:44:31 2021 +0100

Only change SwLayAction::m_bAgain via SetAgain

no logic change intended

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118983
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 3a5383892e1f0e22558cd56cb77d56a09c515b7a)

Change-Id: Ib0174f8040faa3efde7b9c5ba9b062bac5a35da3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125240
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/inc/layact.hxx b/sw/source/core/inc/layact.hxx
index c212b40f1516..37fc4a9aae9e 100644
--- a/sw/source/core/inc/layact.hxx
+++ b/sw/source/core/inc/layact.hxx
@@ -148,7 +148,7 @@ public:
 void SetReschedule  ( bool bNew )   { m_bReschedule = bNew; }
 void SetWaitAllowed ( bool bNew )   { m_bWaitAllowed = bNew; }
 
-void SetAgain() { m_bAgain = true; }
+void SetAgain(bool bAgain) { m_bAgain = bAgain; }
 void SetUpdateExpFields() {m_bUpdateExpFields = true; }
 
 inline void SetCheckPageNum( sal_uInt16 nNew );
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index e5267fff5fb7..d677bccbdb22 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -284,11 +284,12 @@ bool SwLayAction::IsInterrupt()
 
 void SwLayAction::Reset()
 {
+SetAgain(false);
 m_pOptTab = nullptr;
 m_nStartTicks = std::clock();
 m_nEndPage = m_nPreInvaPage = m_nCheckPageNum = USHRT_MAX;
 m_bPaint = m_bComplete = m_bWaitAllowed = m_bCheckPages = true;
-m_bInterrupt = m_bAgain = m_bNextCycle = m_bCalcLayout = m_bReschedule =
+m_bInterrupt = m_bNextCycle = m_bCalcLayout = m_bReschedule =
 m_bUpdateExpFields = m_bBrowseActionStop = false;
 m_pCurPage = nullptr;
 }
@@ -346,12 +347,15 @@ void SwLayAction::Action(OutputDevice* pRenderContext)
 SetCheckPages( false );
 
 InternalAction(pRenderContext);
-m_bAgain |= RemoveEmptyBrowserPages();
+if (RemoveEmptyBrowserPages())
+SetAgain(true);
 while ( IsAgain() )
 {
-m_bAgain = m_bNextCycle = false;
+SetAgain(false);
+m_bNextCycle = false;
 InternalAction(pRenderContext);
-m_bAgain |= RemoveEmptyBrowserPages();
+if (RemoveEmptyBrowserPages())
+SetAgain(true);
 }
 m_pRoot->DeleteEmptySct();
 
@@ -643,7 +647,7 @@ void SwLayAction::InternalAction(OutputDevice* 
pRenderContext)
 {
 bool bOld = IsAgain();
 m_pRoot->RemoveSuperfluous();
-m_bAgain = bOld;
+SetAgain(bOld);
 }
 if ( IsAgain() )
 {
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx 
b/sw/source/core/layout/objectformattertxtfrm.cxx
index 2a072d5f97a5..45608c13c651 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -307,7 +307,7 @@ bool SwObjectFormatterTextFrame::DoFormatObjs()
 {
 // notify layout action, thus is can restart the layout process on
 // a previous page.
-GetLayAction()->SetAgain();
+GetLayAction()->SetAgain(true);
 }
 else
 {
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 02d8ec499e3f..75eacea7c95a 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -284,7 +284,7 @@ void SwPageFrame::DestroyImpl()
 SwViewShellImp *pImp = pSh->Imp();
 pImp->SetFirstVisPageInvalid();
 if ( pImp->IsAction() )
-pImp->GetLayAction().SetAgain();
+pImp->GetLayAction().SetAgain(true);
 // #i9719# - retouche area of page
 // including border and shadow area.
 const bool bRightSidebar = (SidebarPosition() == 
sw::sidebarwindows::SidebarPosition::RIGHT);


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-11-16 Thread Caolán McNamara (via logerrit)
 sw/source/core/text/itrform2.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit a69808752ba49a861c135ba4e6bf3b1a7d021d72
Author: Caolán McNamara 
AuthorDate: Mon Jul 12 16:21:04 2021 +0100
Commit: Michael Stahl 
CommitDate: Tue Nov 16 10:36:15 2021 +0100

crashtesting: UaF on layout of ooo98566-1.odt

in:
sw/source/core/text/itrform2.cxx:2643 SwTextFormatter::NewFlyCntPortion
at: pFly = static_cast(pHint)->GetFlyFrame(pFrame)

(gdb) print m_pCurr
$2 = (SwLineLayout *) 0x55ea220a0020

after calling GetFlyFrame m_pCurr is unchanged and we will call
m_pCurr->MaxAscentDescent
on it.

But m_pCurr is deleted during GetFlyFrame by...

 #18 0x7f98c5cd337f in SwLineLayout::~SwLineLayout() 
(this=this@entry=0x55ea220a0020, __in_chrg=)
 at source/libo-core/sw/source/core/text/portxt.hxx:26
 #19 0x7f98c5cd347a in SwParaPortion::~SwParaPortion() 
(this=0x55ea220a0020, __in_chrg=)
 at source/libo-core/sw/source/core/text/porlay.cxx:2491
 #20 0x7f98c5cd3485 in SwParaPortion::~SwParaPortion() 
(this=0x55ea220a0020, __in_chrg=)
 at source/libo-core/sw/source/core/text/porlay.cxx:2491
 #21 0x7f98c5d05e70 in 
std::default_delete::operator()(SwParaPortion*) const 
(__ptr=, this=)
 at /usr/include/c++/8/bits/unique_ptr.h:75
 #22 0x7f98c5d05e70 in std::unique_ptr >::reset(SwParaPortion*)
 (__p=, this=) at 
/usr/include/c++/8/bits/unique_ptr.h:382
 #23 0x7f98c5d05e70 in SwTextLine::SetPara(SwParaPortion*, bool) 
(bDelete=true, pNew=0x0, this=)
 at source/libo-core/sw/source/core/text/txtcache.hxx:45
 #24 0x7f98c5d05e70 in SwTextFrame::ClearPara() 
(this=this@entry=0x55ea21302b60) at 
source/libo-core/sw/source/core/text/txtcache.cxx:113
 #25 0x7f98c5d1be89 in SwTextFrame::Init() 
(this=this@entry=0x55ea21302b60) at 
source/libo-core/sw/source/core/text/txtfrm.cxx:757
 #26 0x7f98c5d2630c in SwTextFrame::Prepare(PrepareHint, void const*, 
bool)
 (this=0x55ea21302b60, ePrep=PrepareHint::FlyFrameArrive, 
pVoid=, bNotify=)
 at source/libo-core/sw/source/core/text/txtfrm.cxx:3086
 #27 0x7f98c5b1edb8 in 
SwFlyInContentFrame::NotifyBackground(SwPageFrame*, SwRect const&, PrepareHint)
 (this=, rRect=..., eHint=) at 
source/libo-core/sw/inc/anchoredobject.hxx:205
 #28 0x7f98c5b261a6 in Notify(SwFlyFrame*, SwPageFrame*, SwRect const&, 
SwRect const*)
 (pFly=pFly@entry=0x55ea21a18d60, pOld=0x0, rOld=SwRect = {...}, 
pOldPrt=pOldPrt@entry=0x7ffeb50390f8)
 at source/libo-core/sw/source/core/inc/frame.hxx:1177
 #29 0x7f98c5b2ceca in SwFlyNotify::~SwFlyNotify() 
(this=0x7ffeb50390d0, __in_chrg=)
 at source/libo-core/sw/source/core/layout/frmtool.cxx:648
 #30 0x7f98c5b1fa25 in SwFlyInContentFrame::MakeAll(OutputDevice*) 
(this=0x55ea21a18d60)
 at source/libo-core/sw/source/core/inc/frmtool.hxx:419
 #31 0x7f98c5aec3a9 in SwFrame::PrepareMake(OutputDevice*) 
(this=0x55ea21a18d60, pRenderContext=0x55ea212bc4c0)
 at source/libo-core/sw/source/core/layout/calcmove.cxx:375
 #32 0x7f98c5b17ad2 in SwFlyFrame::Calc(OutputDevice*) const 
(this=, pRenderContext=)
 at source/libo-core/sw/source/core/layout/fly.cxx:2890
 #33 0x7f98c5b636c5 in SwObjectFormatter::FormatLayout_(SwLayoutFrame&) 
(this=this@entry=0x55ea2244d150, _rLayoutFrame=...)
 at source/libo-core/include/rtl/ref.hxx:206
 #34 0x7f98c5b6413e in SwObjectFormatter::FormatObj_(SwAnchoredObject&) 
(this=this@entry=0x55ea2244d150, _rAnchoredObj=...)
 at source/libo-core/sw/source/core/layout/objectformatter.cxx:296
 #35 0x7f98c5b6705b in 
SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject&, bool)
 (this=0x55ea2244d150, _rAnchoredObj=..., _bCheckForMovedFwd=)
 at source/libo-core/sw/source/core/layout/objectformattertxtfrm.cxx:136
 #36 0x7f98c5b6359f in SwObjectFormatter::FormatObj(SwAnchoredObject&, 
SwFrame*, SwPageFrame const*)
 (_rAnchoredObj=..., _pAnchorFrame=, 
_pPageFrame=)
 at source/libo-core/sw/source/core/layout/objectformatter.cxx:190
 #37 0x7f98c5d717aa in SwTextFlyCnt::GetFlyFrame_(SwFrame const*) 
(this=this@entry=0x55ea214d8810, pCurrFrame=pCurrFrame@entry=0x55ea21302b60)
 at source/libo-core/sw/source/core/inc/frame.hxx:1177
 #38 0x7f98c5cb511b in SwTextFlyCnt::GetFlyFrame(SwFrame const*) 
(pCurrFrame=0x55ea21302b60, this=0x55ea214d8810)
 at source/libo-core/sw/inc/txtflcnt.hxx:48
 #39 0x7f98c5cb511b in 
SwTextFormatter::NewFlyCntPortion(SwTextFormatInfo&, SwTextAttr*) const
 (this=this@entry=0x7ffeb503a6b0, rInf=..., pHint=0x55ea214d8810) at 
source/libo-core/sw/source/core/text/itrform2.cxx:2643

(gdb) print this
(SwLinePortion * const) 0x55ea220a0020

The SwTextFrame of SwTextFrame::ClearPara is the same 

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-11-16 Thread Caolán McNamara (via logerrit)
 sw/source/core/undo/undobj.cxx |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 0fec76e0301c839f7fe3a5ba3052038d2ca611c7
Author: Caolán McNamara 
AuthorDate: Sun Feb 28 18:53:55 2021 +
Commit: Michael Stahl 
CommitDate: Tue Nov 16 10:27:11 2021 +0100

ofz#31538 null-deref

Change-Id: I3264c0fd509e16cf4727847199f0be316d03d0e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111713
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 58f5c3b07701a14a61dc6b11f959faaf8aa98b9b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125232
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index fa86072a3008..3b1860ecc7c1 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -1558,9 +1558,14 @@ static bool IsNotBackspaceHeuristic(
 SwPosition const& rStart, SwPosition const& rEnd)
 {
 // check if the selection is backspace/delete created by DelLeft/DelRight
-return rStart.nNode.GetIndex() + 1 != rEnd.nNode.GetIndex()
-|| rEnd.nContent != 0
-|| rStart.nContent != rStart.nNode.GetNode().GetTextNode()->Len();
+if (rStart.nNode.GetIndex() + 1 != rEnd.nNode.GetIndex())
+return true;
+if (rEnd.nContent != 0)
+return true;
+const SwTextNode* pTextNode = rStart.nNode.GetNode().GetTextNode();
+if (!pTextNode || rStart.nContent != pTextNode->Len())
+return true;
+return false;
 }
 
 bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-10-06 Thread Vasily Melenchuk (via logerrit)
 sw/source/ui/fldui/fldtdlg.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 53e5bba49f46c6027b104b34c7c807445ee807ff
Author: Vasily Melenchuk 
AuthorDate: Mon Oct 4 17:40:31 2021 +0200
Commit: Thorsten Behrens 
CommitDate: Wed Oct 6 13:49:10 2021 +0200

tdf#144907: sw ui: allow closing of "Fields" dialog

In some cases (described in task) dialog is not closed.
This is happens due to not delivered request to
SwTextShell::ExecField(). So we could just close dialog
explicitly, if Execute() action did fail.

Change-Id: I1c712295a21037bc8bb28e2a97e750299b41250c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123059
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit da5580369bfd15857fb21a1f610e393d07abb805)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123152
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx
index 8c1bb998fb85..454e844b0278 100644
--- a/sw/source/ui/fldui/fldtdlg.cxx
+++ b/sw/source/ui/fldui/fldtdlg.cxx
@@ -110,9 +110,16 @@ void SwFieldDlg::Close()
 {
 if (m_bClosing)
 return;
-m_pBindings->GetDispatcher()->
+const SfxPoolItem* pResult = m_pBindings->GetDispatcher()->
 Execute(m_bDataBaseMode ? FN_INSERT_FIELD_DATA_ONLY : FN_INSERT_FIELD,
 SfxCallMode::SYNCHRON|SfxCallMode::RECORD);
+if (!pResult)
+{
+// If Execute action did fail for whatever reason, this means that 
request
+// to close did fail or wasn't delivered to SwTextShell::ExecField().
+// Just explicitly close dialog in this case.
+SfxTabDialogController::EndDialog();
+}
 }
 
 void SwFieldDlg::Initialize(SfxChildWinInfo const *pInfo)


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-09-10 Thread Samuel Mehrbrodt (via logerrit)
 sw/source/uibase/shells/drwbassh.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit c7df28f23d7a6717b525dd2fdd87e3381107e2f1
Author: Samuel Mehrbrodt 
AuthorDate: Wed Aug 25 14:14:51 2021 +0200
Commit: Thorsten Behrens 
CommitDate: Fri Sep 10 10:33:23 2021 +0200

Fix crash when drawing shape

Fallout from 75cd2b0fa71c73ae815b80d8e42328024ea63555

Change-Id: I455519126d11bee1b809f9fd9476b2fdd0f1a524
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121034
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit 2694a666b62701a8c0e546151c41f9c30aba00da)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121053
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/source/uibase/shells/drwbassh.cxx 
b/sw/source/uibase/shells/drwbassh.cxx
index 924877a876a5..6f73e76ec91c 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -798,7 +798,10 @@ void SwDrawBaseShell::GetState(SfxItemSet& rSet)
 case SID_COPY_HYPERLINK_LOCATION:
 {
 if (pSdrView->GetMarkedObjectCount() != 1)
+{
 rSet.DisableItem(nWhich);
+break;
+}
 
 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source xmloff/source

2021-08-24 Thread Samuel Mehrbrodt (via logerrit)
 sw/source/uibase/shells/drwbassh.cxx|   31 +---
 xmloff/source/text/XMLTextFrameHyperlinkContext.cxx |   17 --
 2 files changed, 40 insertions(+), 8 deletions(-)

New commits:
commit 96e106495a45fbb3d70e1266a95f5e31703abb83
Author: Samuel Mehrbrodt 
AuthorDate: Mon Aug 23 10:17:56 2021 +0200
Commit: Thorsten Behrens 
CommitDate: Tue Aug 24 11:28:37 2021 +0200

tdf#143736 Load hyperlink from more shapes

And limit the shape types which can have a hyperlink to those known to work.

Change-Id: I3d3522bea1e756dad8ddc2041e6588a367f42a7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120861
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit 75cd2b0fa71c73ae815b80d8e42328024ea63555)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120935
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/uibase/shells/drwbassh.cxx 
b/sw/source/uibase/shells/drwbassh.cxx
index e5b4bb177ae0..924877a876a5 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -799,11 +799,34 @@ void SwDrawBaseShell::GetState(SfxItemSet& rSet)
 {
 if (pSdrView->GetMarkedObjectCount() != 1)
 rSet.DisableItem(nWhich);
-else if (nWhich == SID_OPEN_HYPERLINK || nWhich == 
SID_REMOVE_HYPERLINK
- || nWhich == SID_EDIT_HYPERLINK || nWhich == 
SID_COPY_HYPERLINK_LOCATION)
+
+const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+sal_uInt16 nObjType = pObj->GetObjIdentifier();
+
+// Only enable hyperlink for the following types
+switch (nObjType)
+{
+case OBJ_PATHFILL:
+case OBJ_SECT:
+case OBJ_LINE:
+case OBJ_CUSTOMSHAPE:
+case OBJ_TEXT:
+case OBJ_RECT:
+case OBJ_CAPTION:
+case OBJ_POLY:
+case OBJ_PLIN:
+case OBJ_MEASURE:
+case OBJ_EDGE:
+break;
+default:
+rSet.DisableItem(nWhich);
+break;
+}
+
+if (nWhich == SID_OPEN_HYPERLINK || nWhich == 
SID_REMOVE_HYPERLINK
+|| nWhich == SID_EDIT_HYPERLINK || nWhich == 
SID_COPY_HYPERLINK_LOCATION)
 {
-const SdrMarkList& rMarkList = 
pSdrView->GetMarkedObjectList();
-SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
 if (pObj->getHyperlink().isEmpty())
 rSet.DisableItem(nWhich);
 }
diff --git a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx 
b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
index 278d6d953205..3901a010fbd9 100644
--- a/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
+++ b/xmloff/source/text/XMLTextFrameHyperlinkContext.cxx
@@ -113,14 +113,23 @@ SvXMLImportContextRef 
XMLTextFrameHyperlinkContext::CreateChildContext(
 SvXMLImportContext *pContext = nullptr;
 XMLTextFrameContext *pTextFrameContext = nullptr;
 
-if( XML_NAMESPACE_DRAW == nPrefix )
+if( XML_NAMESPACE_DRAW == nPrefix || XML_NAMESPACE_DR3D == nPrefix)
 {
-if( IsXMLToken( rLocalName, XML_FRAME ) )
+if( XML_NAMESPACE_DRAW == nPrefix && IsXMLToken( rLocalName, XML_FRAME 
) )
 pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
 rLocalName, xAttrList,
 eDefaultAnchorType );
-else if (IsXMLToken(rLocalName, XML_CUSTOM_SHAPE) || 
IsXMLToken(rLocalName, XML_PATH)
- || IsXMLToken(rLocalName, XML_ELLIPSE) || 
IsXMLToken(rLocalName, XML_LINE))
+else if ((XML_NAMESPACE_DRAW == nPrefix && (
+ IsXMLToken(rLocalName, XML_CUSTOM_SHAPE) || 
IsXMLToken(rLocalName, XML_PATH)
+ || IsXMLToken(rLocalName, XML_ELLIPSE) || 
IsXMLToken(rLocalName, XML_LINE)
+ || IsXMLToken(rLocalName, XML_RECT) || 
IsXMLToken(rLocalName, XML_CAPTION)
+ || IsXMLToken(rLocalName, XML_POLYGON) || 
IsXMLToken(rLocalName, XML_POLYLINE)
+ || IsXMLToken(rLocalName, XML_MEASURE) || 
IsXMLToken(rLocalName, XML_CIRCLE)
+ || IsXMLToken(rLocalName, XML_CONNECTOR) || 
IsXMLToken(rLocalName, XML_CONTROL)
+ || IsXMLToken(rLocalName, XML_PAGE_THUMBNAIL) || 
IsXMLToken(rLocalName, XML_G)
+ ))
+ || (XML_NAMESPACE_DR3D == nPrefix && IsXMLToken(rLocalName, 
XML_SCENE))
+ )
 {
  

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-08-24 Thread Michael Stahl (via logerrit)
 sw/source/core/crsr/bookmrk.cxx |   45 
 sw/source/core/doc/docbm.cxx|   16 ++
 sw/source/core/inc/bookmrk.hxx  |   10 +---
 3 files changed, 67 insertions(+), 4 deletions(-)

New commits:
commit e210e9b67cd46de98ee94dfdc54952c99f58be17
Author: Michael Stahl 
AuthorDate: Tue Jan 21 13:15:50 2020 +0100
Commit: Michael Stahl 
CommitDate: Tue Aug 24 11:02:19 2021 +0200

tdf#45589 sw: invalidate on bookmark insertion/deletion

Invalidate the text frames when a bookmark is inserted or deleted; also
when MarkManager::repositionMark() changes the positions.

The other calls of SetMarkPos()/SetOtherMarkPos() look like they're all
from code that corrects positions after text insertions or deletions so
no additional invalidate should be necessary there.

It turns out that one WW8 document in sw_filters_test wants to insert
a bookmark on a SwGrfNode; check for that in makeMark().

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

crashtesting: null dereference of reexporting abi12570.odt to odt

FLY_AT_FLY shape is anchored on SwStartNode of fly section.

(regression from ef8427d12a63127a2eb867637699343d630545dd)

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91336
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 71ed878556422068041025668876fb3300c128df)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96318
Tested-by: Thorsten Behrens 
(cherry picked from commit 79bc162d86c62506614a19bf7c92c72237804f5e)

Change-Id: I293e6da9042bea5992cb27091b9cff77e5c7961d
4fe70237c060cc810af82657bc5791e7024db8f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120869
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index a16713dc295d..fad65a238147 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -238,6 +239,12 @@ namespace
 
 io_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::UI_REPLACE, nullptr);
 };
+
+auto InvalidatePosition(SwPosition const& rPos) -> void
+{
+SwUpdateAttr const hint(rPos.nContent.GetIndex(), 
rPos.nContent.GetIndex(), 0);
+rPos.nNode.GetNode().GetTextNode()->NotifyClients(nullptr, );
+}
 }
 
 namespace sw { namespace mark
@@ -337,6 +344,11 @@ namespace sw { namespace mark
 }
 
 // TODO: everything else uses MarkBase::GenerateNewName ?
+
+auto MarkBase::InvalidateFrames() -> void
+{
+}
+
 NavigatorReminder::NavigatorReminder(const SwPaM& rPaM)
 : MarkBase(rPaM, "__NavigatorReminder__")
 { }
@@ -393,6 +405,7 @@ namespace sw { namespace mark
 std::make_unique(*this));
 }
 io_pDoc->getIDocumentState().SetModified();
+InvalidateFrames();
 }
 
 void Bookmark::DeregisterFromDoc(SwDoc* const io_pDoc)
@@ -405,6 +418,36 @@ namespace sw { namespace mark
 std::make_unique(*this));
 }
 io_pDoc->getIDocumentState().SetModified();
+InvalidateFrames();
+}
+
+// invalidate text frames in case it's hidden or Formatting Marks enabled
+auto Bookmark::InvalidateFrames() -> void
+{
+InvalidatePosition(GetMarkPos());
+if (IsExpanded())
+{
+InvalidatePosition(GetOtherMarkPos());
+}
+}
+
+void Bookmark::Hide(bool const isHide)
+{
+if (isHide != m_bHidden)
+{
+m_bHidden = isHide;
+InvalidateFrames();
+}
+}
+
+void Bookmark::SetHideCondition(OUString const& rHideCondition)
+{
+if (m_sHideCondition != rHideCondition)
+{
+m_sHideCondition = rHideCondition;
+// don't eval condition here yet - probably only needed for
+// UI editing condition and that doesn't exist yet
+}
 }
 
 ::sfx2::IXmlIdRegistry& Bookmark::GetRegistry()
@@ -513,6 +556,8 @@ namespace sw { namespace mark
 if (eMode == sw::mark::InsertMode::New)
 {
 lcl_SetFieldMarks(this, io_pDoc, CH_TXT_ATR_FIELDSTART, 
CH_TXT_ATR_FIELDEND, pSepPos);
+// no need to invalidate text frames here, the insertion of the
+// CH_TXT_ATR already invalidates
 }
 else
 {
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index a9eed445a21c..e061dbf0a310 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -561,6 +561,18 @@ namespace sw { namespace mark
 pPos2->nContent.GetIndex());
 }
 #endif
+

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-08-05 Thread Vasily Melenchuk (via logerrit)
 sw/source/core/draw/dview.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit fd7ac9010aabc89286e6e7d7ee5b565c8c5b22cb
Author: Vasily Melenchuk 
AuthorDate: Thu Aug 5 11:16:58 2021 +0300
Commit: Thorsten Behrens 
CommitDate: Thu Aug 5 21:48:01 2021 +0200

tdf#99932: sw: fix for invalid anchor location for FLY_AT_CHAR mode

In such case anchor position depends on LastCharRect which can be
invalid because of happened frame movement, resize, etc.

Change-Id: I3d3c6318ee1ce5f4043e21ab091417d283c4260c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120059
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 6e879d5f142766c941d1c3bafd17f67b78c1c9f4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119989
Tested-by: Thorsten Behrens 

diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index c1a7b6a8cbbc..b20ae1031382 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -231,6 +231,11 @@ void SwDrawView::AddCustomHdl()
 // #i28701# - use last character rectangle saved at object
 // in order to avoid a format of the anchor frame
 SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj 
)->GetAnchoredObj( pObj );
+
+// Invalidate/recalc LastCharRect which can contain invalid frame 
offset because
+// of later frame changes
+pAnchoredObj->CheckCharRectAndTopOfLine(false);
+
 SwRect aAutoPos = pAnchoredObj->GetLastCharRect();
 if ( aAutoPos.Height() )
 {


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-05-21 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/DocumentRedlineManager.cxx |2 ++
 sw/source/core/text/txtfrm.cxx|2 ++
 2 files changed, 4 insertions(+)

New commits:
commit ffd69465a547cd5acad92aad13142edbac1e0882
Author: Michael Stahl 
AuthorDate: Thu Jan 14 20:10:24 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri May 21 22:17:29 2021 +0200

tdf#135014 sw_redlinehide: fix missing frames when removing fieldmark

A fieldmark was deleted. UpdateFramesForRemoveDeleteRedline() deleted
the MergedPara but its start node was before the start node of the
fieldmark, and then MakeFrames() didn't find a frame on the preceding
node and did nothing.

Similar problem likely possible with redline.

Change-Id: I532f9a67c0268f3287736a61da4cc9fefec7b8e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109307
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 32e104c1d6be0ffe6ed6c4e08af868c87b3c258c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109347
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115929
Tested-by: Michael Stahl 

diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index ff9b05743d10..8ae32f266bdb 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -301,6 +301,8 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM 
const& rPam)
 pFrame->SetMergedPara(sw::CheckParaRedlineMerge(
 *pFrame, rFirstNode, eMode));
 eMode = sw::FrameMode::New; // Existing is not idempotent!
+// update pNode so MakeFrames starts on 2nd node
+pNode = 
 }
 }
 if (pLast != pNode)
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 17636cda44e3..23cb91a458c8 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1292,6 +1292,8 @@ void 
SwTextFrame::SetMergedPara(std::unique_ptr p)
 pFirst->Add(this); // must register at node again
 }
 }
+// postcondition: frame must be listening somewhere
+assert(m_pMergedPara || GetDep());
 }
 
 const OUString& SwTextFrame::GetText() const
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-05-21 Thread Justin Luth (via logerrit)
 sw/source/core/edit/autofmt.cxx |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 6c8ac0584c7947cb180b9730669aa01b04bcc8e4
Author: Justin Luth 
AuthorDate: Fri Jan 15 20:32:43 2021 +0300
Commit: Michael Stahl 
CommitDate: Fri May 21 22:17:08 2021 +0200

tdf#136704 sw autofmt: prevent crash if no nextNode

The second GetNextNode() was a nullptr
that was being dereferenced.

Now, when enter is pressed after some text followed by a colon,
that line is made into a heading3, and the new blank line is
properly using the text body paragraph style.

Change-Id: If10dc85e490ac57fc150b3d541f5033dfd5293bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109413
Tested-by: Jenkins
Reviewed-by: Justin Luth 
Reviewed-by: Michael Stahl 
(cherry picked from commit fea7b531a4c9e8326a64426325b16585675a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109520
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115928
Tested-by: Michael Stahl 

diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index a3687b5e308c..cb905187faed 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1904,11 +1904,14 @@ void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
 JoinPrevPara();
 
 DeleteLeadingTrailingBlanks( true, false );
-const SwTextFrame *const pNextFrame = GetNextNode(false);
-(void)DeleteJoinCurNextPara(pNextFrame, true);
-
+const SwTextFrame* pNextFrame = GetNextNode(false);
+if (pNextFrame->GetNext())
+{
+(void)DeleteJoinCurNextPara(pNextFrame, true);
+pNextFrame = GetNextNode(false);
+}
 m_aDelPam.DeleteMark();
-m_aDelPam.GetPoint()->nNode = 
*GetNextNode(false)->GetTextNodeForParaProps();
+m_aDelPam.GetPoint()->nNode = *pNextFrame->GetTextNodeForParaProps();
 m_aDelPam.GetPoint()->nContent.Assign( m_aDelPam.GetContentNode(), 0 );
 m_pDoc->SetTextFormatColl( m_aDelPam,  );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-05-19 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/flycnt.cxx|3 +-
 sw/source/core/layout/objectformattertxtfrm.cxx |   27 ++--
 sw/source/core/layout/objectformattertxtfrm.hxx |2 -
 3 files changed, 19 insertions(+), 13 deletions(-)

New commits:
commit 97118a47de5e7e92aa189c2923b83b55c7db732b
Author: Michael Stahl 
AuthorDate: Thu May 6 18:20:14 2021 +0200
Commit: Michael Stahl 
CommitDate: Wed May 19 10:52:18 2021 +0200

tdf#138518 sw: layout: fix assert on ooo43913-1.doc

Assertion `rAnchoredObjPage.GetPhyPageNum() == _nFromPageNum' failed.

Because not only the fly's anchor frame moves forward in
FormatAnchorFrameForCheckMoveFwd(), but also the fly itself,
apparently because it's in a table:

0  SwAnchoredObject::SetPageFrame(SwPageFrame*) (this=0x5a1d3d8, 
_pNewPageFrame=0x8cfbeb0) at sw/source/core/layout/anchoredobject.cxx:162
1  SwPageFrame::MoveFly(SwFlyFrame*, SwPageFrame*) (this=0x8cbd8c0, 
pToMove=0x5a1d280, pDest=0x8cfbeb0) at sw/source/core/layout/flylay.cxx:985
2  lcl_ArrangeLowers(SwLayoutFrame*, tools::Long, bool) (pLay=0x8cf80c0, 
lYStart=179488, bInva=false) at sw/source/core/layout/tabfrm.cxx:5000
3  SwCellFrame::Format(OutputDevice*, SwBorderAttrs const*) 
(this=0x8cf80c0, pAttrs=0x8ce78c0) at sw/source/core/layout/tabfrm.cxx:5359
4  SwLayoutFrame::MakeAll(OutputDevice*) (this=0x8cf80c0) at 
sw/source/core/layout/calcmove.cxx:1036
5  SwFrame::PrepareMake(OutputDevice*) (this=0x8cf80c0, 
pRenderContext=0x5b7fcf0) at sw/source/core/layout/calcmove.cxx:375
6  SwFrame::Calc(OutputDevice*) const (this=0x8cf80c0, 
pRenderContext=0x5b7fcf0) at sw/source/core/layout/trvlfrm.cxx:1792
7  SwFrame::MakePos() (this=0x8cebdb0) at 
sw/source/core/layout/calcmove.cxx:627
8  SwTextFrame::MakePos() (this=0x8cebdb0) at 
sw/source/core/text/frmform.cxx:340
9  SwContentFrame::MakeAll(OutputDevice*) (this=0x8cebdb0) at 
sw/source/core/layout/calcmove.cxx:1412
10 SwFrame::PrepareMake(OutputDevice*) (this=0x8cebdb0, 
pRenderContext=0x5b7fcf0) at sw/source/core/layout/calcmove.cxx:286
11 SwFrame::Calc(OutputDevice*) const (this=0x8cebdb0, 
pRenderContext=0x5b7fcf0) at sw/source/core/layout/trvlfrm.cxx:1792
12 SwTextFrame::CalcFollow(o3tl::strong_int) 
(this=0x5ae2c60, nTextOfst=...) at sw/source/core/text/frmform.cxx:279
13 SwTextFrame::AdjustFollow_(SwTextFormatter&, o3tl::strong_int, o3tl::strong_int, unsigned char) 
(this=0x5ae2c60, rLine=..., nOffset=..., nEnd=..., nMode=1 '\001') at 
sw/source/core/text/frmform.cxx:611
14 SwTextFrame::FormatAdjust(SwTextFormatter&, WidowsAndOrphans&, 
o3tl::strong_int, bool) (this=0x5ae2c60, rLine=..., 
rFrameBreak=..., nStrLen=..., bDummy=false) at 
sw/source/core/text/frmform.cxx:1166
15 SwTextFrame::Format_(SwTextFormatter&, SwTextFormatInfo&, bool) 
(this=0x5ae2c60, rLine=..., rInf=..., bAdjust=false) at 
sw/source/core/text/frmform.cxx:1613
16 SwTextFrame::Format_(OutputDevice*, SwParaPortion*) (this=0x5ae2c60, 
pRenderContext=0x5b7fcf0, pPara=0x8d07490) at 
sw/source/core/text/frmform.cxx:1720
17 SwTextFrame::Format(OutputDevice*, SwBorderAttrs const*) 
(this=0x5ae2c60, pRenderContext=0x5b7fcf0) at 
sw/source/core/text/frmform.cxx:1910
18 SwContentFrame::MakeAll(OutputDevice*) (this=0x5ae2c60) at 
sw/source/core/layout/calcmove.cxx:1525
19 SwFrame::PrepareMake(OutputDevice*) (this=0x5ae2f80, 
pRenderContext=0x5b7fcf0) at sw/source/core/layout/calcmove.cxx:321
20 SwFrame::Calc(OutputDevice*) const (this=0x5ae2f80, 
pRenderContext=0x5b7fcf0) at sw/source/core/layout/trvlfrm.cxx:1792
21 SwObjectFormatterTextFrame::FormatAnchorFrameAndItsPrevs(SwTextFrame&) 
(_rAnchorTextFrame=...) at sw/source/core/layout/objectformattertxtfrm.cxx:905
22 SwObjectFormatterTextFrame::FormatAnchorFrameForCheckMoveFwd() 
(this=0x8ce5720) at sw/source/core/layout/objectformattertxtfrm.cxx:919
23 SwObjectFormatterTextFrame::DoFormatObjs() (this=0x8ce5720) at 
sw/source/core/layout/objectformattertxtfrm.cxx:368
24 SwObjectFormatter::FormatObjsAtFrame(SwFrame&, SwPageFrame const&, 
SwLayAction*) (_rAnchorFrame=..., _rPageFrame=..., _pLayAction=0x0) at 
sw/source/core/layout/objectformatter.cxx:160
25 SwContentFrame::CalcLowers(SwLayoutFrame&, SwLayoutFrame const&, long, 
bool) (rLay=..., rDontLeave=..., nBottom=192048, bSkipRowSpanCells=true) at 
sw/source/core/layout/tabfrm.cxx:1534
26 lcl_RecalcRow(SwRowFrame&, tools::Long) (rRow=..., nBottom=192048) at 
sw/source/core/layout/tabfrm.cxx:1653
27 SwTabFrame::MakeAll(OutputDevice*) (this=0x8cf5f80, 
pRenderContext=0x5b7fcf0) at sw/source/core/layout/tabfrm.cxx:2425

It looks like the _nFromPageNum is always from the
SwObjectFormatter::mrPageFrame anyway because that's a precondition of
the mpPgNumAndTypeOfAnchors->Collect() being called, so just rely on
that to get the correct page.

(regression from c799de145f7e289f31e3669646e5bd12814e6c5e)


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-05-19 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/flycnt.cxx|   18 ++-
 sw/source/core/layout/objectformattertxtfrm.cxx |  142 ++--
 sw/source/core/layout/objectformattertxtfrm.hxx |9 +
 3 files changed, 152 insertions(+), 17 deletions(-)

New commits:
commit 7c6d7876d08e084b98873c724c1af9337c847281
Author: Michael Stahl 
AuthorDate: Thu Apr 22 13:43:07 2021 +0200
Commit: Michael Stahl 
CommitDate: Wed May 19 10:50:25 2021 +0200

tdf#138518 sw: layout: avoid moving flys forward prematurely

(regression from b9ef71476fd70bc13f50ebe80390e0730d1b7afb
"tdf#134298 sw: layout: remove left-over page frame without content")

When updating the 3rd ToX, the change to remove empty page frames
causes one page frame to be deleted.

On the subsequent layout, things generally move backward, but there are
some fly-related hiccups; the first problem is visible on page 7.

Commit eb85de8e6b61fb3fcb6c03ae0145f7fe5478bccf
"sw: layout: if fly's anchor moves forward, move fly off SwPageFrame"
helps quite a bit, but not completely; now the first problem happens on
page 54, when SwTextFrame 1261 and its fly 3132 are formatted.

Frame 1261 moves forward to page 55, and then
SwObjectFormatterTextFrame::CheckMovedFwdCondition() returns true and so
SwMovedFwdFramesByObjPos::Insert() is called to prevent frame 1261 from
moving back to page 54.

But the reason why it moved forward is that there are 3 flys on page 54
that are anchored on frames in the next-chain of 1261, namely 1275,
1283 and 1284; if these flys weren't on the page then 1261 would fit.

While the move forward cannot be easily prevented in the situation, it's
possible to avoid the entry into the SwMovedFwdFramesByObjPos map,
by detecting that there are flys on the page that would should forward
*before* the current one does.

With this fix and the above mentioned commit to get the flys off the
page, frame 1261 will eventually move back to page 54 again.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114478
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit c799de145f7e289f31e3669646e5bd12814e6c5e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114521
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 8feac9601cfe35ee0966776bab15d122206f154e)

tdf#138518 sw: layout: unbreak fdo80206-1.doc

The 7 flys on the para on page 3 create ~15 extra pages with one
paragraph each.

Argh! One of the bPageHasFlysAnchoredBelowThis checks was inverted.
How dumb of me.

(regression from c799de145f7e289f31e3669646e5bd12814e6c5e)

Still doesn't look good but now it looks same as in 7.0.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115242
Reviewed-by: Michael Stahl 
Tested-by: Jenkins
(cherry picked from commit 59d96acec8c4d9e472daa3e2c287b3a754e01817)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115206
Reviewed-by: Caolán McNamara 
(cherry picked from commit dcea18e66e61c6f411b9bf6498a0ffc374161484)

Change-Id: I83e44d65a0b889a49a313b0cd8b08efce4c3afa7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115765
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 7ac4cf41740a..e394ff411971 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -421,9 +421,11 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 // 
 sal_uInt32 nToPageNum( 0 );
 bool bDummy( false );
+bool bPageHasFlysAnchoredBelowThis(false);
 if ( SwObjectFormatterTextFrame::CheckMovedFwdCondition(
 *this, GetPageFrame()->GetPhyPageNum(),
-bAnchoredAtMaster, nToPageNum, bDummy 
) )
+bAnchoredAtMaster, nToPageNum, bDummy,
+bPageHasFlysAnchoredBelowThis) )
 {
 bConsiderWrapInfluenceDueToMovedFwdAnchor = true;
 // mark anchor text frame
@@ -436,14 +438,22 @@ void SwFlyAtContentFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 rDoc, *pAnchorTextFrame, 
nAnchorFrameToPageNum ) )
 {
 if ( nAnchorFrameToPageNum < nToPageNum )
-SwLayouter::RemoveMovedFwdFrame( rDoc, 
*pAnchorTextFrame );
+{
+if (!bPageHasFlysAnchoredBelowThis)
+{
+SwLayouter::RemoveMovedFwdFrame(rDoc, 
*pAnchorTextFrame);
+  

[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-05-19 Thread Michael Stahl (via logerrit)
 sw/source/core/inc/flyfrms.hxx|1 +
 sw/source/core/layout/pagechg.cxx |5 +
 2 files changed, 6 insertions(+)

New commits:
commit cb288cdceb053d3d7aee52464fff8b34651eec51
Author: Michael Stahl 
AuthorDate: Tue Apr 20 12:45:36 2021 +0200
Commit: Michael Stahl 
CommitDate: Wed May 19 10:49:19 2021 +0200

tdf#138785 sw: fix mis-positioned as-char flys when deleting empty page

When SwFrame::CheckPageDescs() deletes an empty page in the middle of
the document, which happens during SetRedlineFlags() here, the
SwFlyInContentFrame::maFrameArea is moved in lcl_MoveAllLowers(), but
the SwFlyInContentFrame::m_aRefPoint stays unchanged.

Because the formatting occurs only after the redline mode is reset, the
position of the SwFlyInContentFrame when it is formatted is exactly the
same as its (stale) m_aRefPoint, so the setting of (updated) maFrameArea
is skipped in SwAsCharAnchoredObjectPosition::CalcPosition(), so the
fly ends up a page above where it should be.

So keep m_aRefPoint consistent with maFrameArea in lcl_MoveAllLowers().

(regression from b9ef71476fd70bc13f50ebe80390e0730d1b7afb)

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114332
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit e656cf2a71e738c282abcd0d610e724b955f274a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114520
Reviewed-by: Thorsten Behrens 
(cherry picked from commit c79b92edfb5e650fff76688998cf4f0bbd08d2a4)

Change-Id: If1b421daa0d71718d89d9772f5c0d9e367e76845
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115764
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx
index b67d2934315f..04b505ddd548 100644
--- a/sw/source/core/inc/flyfrms.hxx
+++ b/sw/source/core/inc/flyfrms.hxx
@@ -228,6 +228,7 @@ public:
 
 //see layact.cxx
 void AddRefOfst( long nOfst ) { aRef.AdjustY( nOfst ); }
+void AddRefOfst(Point const& rOfst) { aRef += rOfst; }
 
 // #i26791#
 virtual void MakeObjPos() override;
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 0f97c40a9da0..02d8ec499e3f 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -2003,6 +2003,11 @@ static void lcl_MoveAllLowerObjs( SwFrame* pFrame, const 
Point& rOffset )
 {
 SwFlyFrame* pFlyFrame( static_cast(pAnchoredObj) );
 lcl_MoveAllLowers( pFlyFrame, rOffset );
+// tdf#138785 update position specific to as-char flys
+if (pFlyFrame->IsFlyInContentFrame())
+{
+
static_cast(pFlyFrame)->AddRefOfst(rOffset);
+}
 pFlyFrame->NotifyDrawObj();
 // --> let the active embedded object be moved
 SwFrame* pLower = pFlyFrame->Lower();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2021-05-19 Thread Michael Stahl (via logerrit)
 sw/source/core/layout/layact.cxx |   20 
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 9845172aff75d6a53a4c7cb212dfeeb37b7eb625
Author: Michael Stahl 
AuthorDate: Mon Nov 16 13:08:48 2020 +0100
Commit: Michael Stahl 
CommitDate: Wed May 19 10:43:14 2021 +0200

(related tdf#134298) sw: layout: avoid infinite loop in InternalAction()

The condition IsInterrupt() && pPage && (m_nCheckPageNum != USHRT_MAX)
isn't handled properly and the while loop will never terminate with
the fix for tdf#134298 in several UITest_writer_tests*.

If m_nCheckPageNum is set, then it must result in a call to
CheckPageDescs() here; it's a member of SwLayAction so won't survive
until the next idle layout invocation.

There is a funny history of these loop conditions with
commit 9eff9e699e17cc5a8a25895bd28dc8e4ceb8071e
and cee296066ab780217395201ab84c2150c8840d25 so we can only hope
this time we got it right...

Change-Id: I91b63540bf4280296d747cb8e841594f8dd3b140
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105927
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 094ee3955ee81e1bc631d50cc216cbb17a777839)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114096
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 04201e1c6f5e..90d2eed2b1ff 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -448,15 +448,19 @@ void SwLayAction::InternalAction(OutputDevice* 
pRenderContext)
 sal_uInt16 nPercentPageNum = 0;
 while ((!IsInterrupt() && pPage) || (m_nCheckPageNum != USHRT_MAX))
 {
-if (!pPage && m_nCheckPageNum != USHRT_MAX)
+// note: this is the only place that consumes and resets 
m_nCheckPageNum
+if ((IsInterrupt() || !pPage) && m_nCheckPageNum != USHRT_MAX)
 {
-SwPageFrame *pPg = static_cast(m_pRoot->Lower());
-while (pPg && pPg->GetPhyPageNum() < m_nCheckPageNum)
-pPg = static_cast(pPg->GetNext());
-if (pPg)
-pPage = pPg;
-if (!pPage)
-break;
+if (!pPage || m_nCheckPageNum < pPage->GetPhyPageNum())
+{
+SwPageFrame *pPg = static_cast(m_pRoot->Lower());
+while (pPg && pPg->GetPhyPageNum() < m_nCheckPageNum)
+pPg = static_cast(pPg->GetNext());
+if (pPg)
+pPage = pPg;
+if (!pPage)
+break;
+}
 
 SwPageFrame *pTmp = pPage->GetPrev() ?
 
static_cast(pPage->GetPrev()) : pPage;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2020-11-05 Thread Caolán McNamara (via logerrit)
 sw/source/ui/dbui/dbtablepreviewdialog.cxx |   53 +++--
 sw/source/ui/dbui/dbtablepreviewdialog.hxx |4 +-
 2 files changed, 46 insertions(+), 11 deletions(-)

New commits:
commit be48c5b2719b66a35a8920550ebee6e45f266cc6
Author: Caolán McNamara 
AuthorDate: Wed Nov 4 13:01:53 2020 +
Commit: Michael Weghorn 
CommitDate: Thu Nov 5 12:48:06 2020 +0100

tdf#137982 m_xFrame is already disposed

move the frame cleanup into a helper that listens to see if it got
disposed by the preview itself

Change-Id: I523285268118300f18b0f0f0a10fab7a9cced9c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105221
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit a986db4b2d24669e502e447036851e118cc23036)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105349
Tested-by: Michael Weghorn 
Reviewed-by: Michael Weghorn 

diff --git a/sw/source/ui/dbui/dbtablepreviewdialog.cxx 
b/sw/source/ui/dbui/dbtablepreviewdialog.cxx
index 23e7984623d8..8f2d92b1c7d5 100644
--- a/sw/source/ui/dbui/dbtablepreviewdialog.cxx
+++ b/sw/source/ui/dbui/dbtablepreviewdialog.cxx
@@ -20,6 +20,8 @@
 #include 
 #include "dbtablepreviewdialog.hxx"
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -32,6 +34,34 @@ using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::util;
 
+class DBTablePreviewFrame
+: public cppu::WeakImplHelper
+{
+private:
+css::uno::Reference m_xFrame;
+
+virtual void SAL_CALL disposing(const lang::EventObject& /*Source*/) 
override
+{
+m_xFrame.clear();
+}
+
+public:
+DBTablePreviewFrame(css::uno::Reference& rFrame)
+: m_xFrame(rFrame)
+{
+}
+
+void cleanup()
+{
+if (m_xFrame.is())
+{
+m_xFrame->setComponent(nullptr, nullptr);
+m_xFrame->dispose();
+m_xFrame.clear();
+}
+}
+};
+
 SwDBTablePreviewDialog::SwDBTablePreviewDialog(weld::Window* pParent, 
uno::Sequence< beans::PropertyValue> const & rValues)
 : SfxDialogController(pParent, "modules/swriter/ui/tablepreviewdialog.ui", 
"TablePreviewDialog")
 , m_xDescriptionFI(m_xBuilder->weld_label("description"))
@@ -51,22 +81,26 @@ 
SwDBTablePreviewDialog::SwDBTablePreviewDialog(weld::Window* pParent, uno::Seque
 m_xDescriptionFI->set_label(sDescription.replaceFirst("%1", sTemp));
 }
 
+css::uno::Reference xFrame;
 try
 {
 // create a frame wrapper for myself
-m_xFrame = frame::Frame::create( 
comphelper::getProcessComponentContext() );
-m_xFrame->initialize(m_xBeamerWIN->CreateChildFrame());
+xFrame = frame::Frame::create( 
comphelper::getProcessComponentContext() );
+xFrame->initialize(m_xBeamerWIN->CreateChildFrame());
 }
 catch (uno::Exception const &)
 {
-m_xFrame.clear();
+xFrame.clear();
 }
-if (m_xFrame.is())
+if (xFrame.is())
 {
+m_xFrameListener.set(new DBTablePreviewFrame(xFrame));
+xFrame->addEventListener(m_xFrameListener.get());
+
 util::URL aURL;
 aURL.Complete = ".component:DB/DataSourceBrowser";
-uno::Reference xD = m_xFrame->queryDispatch(aURL, 
"", 0x0C);
-if(xD.is())
+uno::Reference xD = xFrame->queryDispatch(aURL, "", 
0x0C);
+if (xD.is())
 {
 xD->dispatch(aURL, rValues);
 m_xBeamerWIN->show();
@@ -76,11 +110,10 @@ 
SwDBTablePreviewDialog::SwDBTablePreviewDialog(weld::Window* pParent, uno::Seque
 
 SwDBTablePreviewDialog::~SwDBTablePreviewDialog()
 {
-if(m_xFrame.is())
+if (m_xFrameListener)
 {
-m_xFrame->setComponent(nullptr, nullptr);
-m_xFrame->dispose();
-m_xFrame.clear();
+m_xFrameListener->cleanup();
+m_xFrameListener.clear();
 }
 }
 
diff --git a/sw/source/ui/dbui/dbtablepreviewdialog.hxx 
b/sw/source/ui/dbui/dbtablepreviewdialog.hxx
index ec2c58d92bf3..27e6e83d39ca 100644
--- a/sw/source/ui/dbui/dbtablepreviewdialog.hxx
+++ b/sw/source/ui/dbui/dbtablepreviewdialog.hxx
@@ -27,12 +27,14 @@ namespace com{ namespace sun{ namespace star{
 namespace frame{ class XFrame2; }
 }}}
 
+class DBTablePreviewFrame;
+
 class SwDBTablePreviewDialog : public SfxDialogController
 {
 std::unique_ptr m_xDescriptionFI;
 std::unique_ptr m_xBeamerWIN;
 
-css::uno::Reference< css::frame::XFrame2 > m_xFrame;
+rtl::Reference m_xFrameListener;
 public:
 SwDBTablePreviewDialog(weld::Window* pParent,
 css::uno::Sequence< css::beans::PropertyValue> const & rValues  );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2020-10-17 Thread Michael Stahl (via logerrit)
 sw/source/core/undo/untblk.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 34ba6f515a1d96bdbf5d01b3e37828e47f6b018b
Author: Michael Stahl 
AuthorDate: Fri Oct 16 14:27:04 2020 +0200
Commit: Michael Stahl 
CommitDate: Sat Oct 17 09:15:25 2020 +0200

tdf#135733 sw: fix mistake in SwUndoInserts::SetInsertRange()

First init m_nDeleteTextNodes, then check it; it is inited to 1 in the
ctor so the ++m_nSttNode was skipped.

This then caused bJoinNext to be true in UndoImpl() when it should
be false.

(regression from dc7e7b94a7211c576454267c09eb108e761e4487)

Change-Id: I74038ef7f8036581dd77341dc8372e87139bdb6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104433
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 7221b7638c74b13e229f7ff50349a253ebb74cfc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104344
Tested-by: Michael Stahl 

diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 28f41f817061..449f41795697 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -125,11 +125,11 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, 
bool bScanFlys,
 m_nSttNode = pTmpPos->nNode.GetIndex();
 m_nSttContent = pTmpPos->nContent.GetIndex();
 
+m_nDeleteTextNodes = nDeleteTextNodes;
 if (m_nDeleteTextNodes == 0) // if a table selection is added...
 {
 ++m_nSttNode; // ... then the CopyPam is not fully correct
 }
-m_nDeleteTextNodes = nDeleteTextNodes;
 }
 
 // Fill m_FlyUndos with flys anchored to first and last paragraphs
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2020-10-15 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/DocumentContentOperationsManager.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 25f4c91e1a501c20c84ac0d54bea295596bf120d
Author: Michael Stahl 
AuthorDate: Wed Oct 14 16:10:29 2020 +0200
Commit: Michael Stahl 
CommitDate: Thu Oct 15 15:29:56 2020 +0200

tdf#136577 sw: fix Undo of Replace with nothing

The UI doesn't allow to replace an empty selection anyway, but it now
happens on Undo.

(regression from e1629c210ad78310e3d48c0756723134a27b89df)

Change-Id: I468f28335beaeb8c42df8ed4cfc90f2c03129239
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104308
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit d3eca4177a78c3db17b4699ea6e071e52488c46f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104305
Reviewed-by: Caolán McNamara 
(cherry picked from commit ba5584a3ce86c2db52e2e4a4b91254741b2616ec)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104333
Tested-by: Michael Stahl 

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 909c88632f5e..0199260aa6cf 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4261,7 +4261,7 @@ bool 
DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam)
 bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const 
OUString& rStr,
 const bool bRegExReplace )
 {
-if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() )
+if (!rPam.HasMark())
 return false;
 
 bool bJoinText, bJoinPrev;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2020-10-15 Thread Michael Stahl (via logerrit)
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   10 --
 sw/source/uibase/wrtsh/wrtsh1.cxx   |4 
 2 files changed, 4 insertions(+), 10 deletions(-)

New commits:
commit bc6e4fc8caf95b3b4a6cbfcfe906bd3084afdf30
Author: Michael Stahl 
AuthorDate: Wed Oct 14 12:42:54 2020 +0200
Commit: Michael Stahl 
CommitDate: Thu Oct 15 13:41:20 2020 +0200

tdf#135260 sw_redlinehide: fix insert-with-delete differently

The problem with the fix for tdf#127635 is that now the cursor doesn't
move left on backspace if change tracking is on.

(regression from 398ba26077f9029bdf6f7378bfc9ce8376b6f02d)

Revert that and fix the autocorrect position in SwWrtShell::Insert()
instead.

Change-Id: I5989a589b654fc6e5ba3dd66922af15eff758ecc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104280
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit be4616d6b49b8c9cf1a90b212b24ead3dabcab6c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104299
Reviewed-by: Caolán McNamara 
(cherry picked from commit 10c638e520096a0cc282d91ac2a447509f674a6f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104332
Tested-by: Michael Stahl 

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index ecebb3d000b6..909c88632f5e 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2007,11 +2007,6 @@ void DocumentContentOperationsManager::DeleteRange( 
SwPaM & rPam )
 {
 lcl_DoWithBreaks( *this, rPam, 
::DeleteRangeImpl );
 
-if (m_rDoc.getIDocumentRedlineAccess().IsRedlineOn())
-{
-rPam.Normalize(false); // tdf#127635 put point at the end of deletion
-}
-
 if (!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline()
 && !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty())
 {
@@ -2188,11 +2183,6 @@ bool DocumentContentOperationsManager::DeleteAndJoin( 
SwPaM & rPam,
 : ::DeleteAndJoinImpl,
 bForceJoinNext );
 
-if (m_rDoc.getIDocumentRedlineAccess().IsRedlineOn())
-{
-rPam.Normalize(false); // tdf#127635 put point at the end of deletion
-}
-
 return ret;
 }
 
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 9eb00d361b9a..0840ed3cd407 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -243,7 +243,11 @@ void SwWrtShell::Insert( const OUString  )
 
 StartUndo(SwUndoId::REPLACE, );
 bStarted = true;
+Push();
 bDeleted = DelRight();
+Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore selection (if 
tracking changes)
+NormalizePam(false); // tdf#127635 put point at the end of deletion
+ClearMark();
 }
 
 bCallIns ?
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2020-09-21 Thread Samuel Mehrbrodt (via logerrit)
 sw/source/core/crsr/crstrvl.cxx  |2 +-
 sw/source/core/txtnode/ndtxt.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 1d51724adc5719e440ca0b457c80c161d8ca04c8
Author: Samuel Mehrbrodt 
AuthorDate: Thu Aug 20 15:33:49 2020 +0200
Commit: Thorsten Behrens 
CommitDate: Mon Sep 21 20:53:14 2020 +0200

Related tdf#100492 Detect click into empty field

Change-Id: Ic2937d619a8361b9d17b7dfa16698a5005f34ec6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101076
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit 2c7bf3543ab798d1c117d9f3258467e4aef9a8db)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103108
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 

diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 9153b8b34e85..7df0ce6ff323 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -949,7 +949,7 @@ bool SwCursorShell::CursorInsideInputField() const
 {
 for(SwPaM& rCursor : GetCursor()->GetRingContainer())
 {
-if (dynamic_cast(GetTextFieldAtCursor(, false)))
+if (dynamic_cast(GetTextFieldAtCursor(, true)))
 return true;
 }
 return false;
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 3d721ebee00b..28cb96d2c71b 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1788,7 +1788,7 @@ SwTextField* SwTextNode::GetFieldTextAttrAt(
 dynamic_cast( GetTextAttrAt(
 nIndex,
 RES_TXTATR_INPUTFIELD,
-bIncludeInputFieldAtStart ? DEFAULT : PARENT ));
+bIncludeInputFieldAtStart ? DEFAULT : EXPAND ));
 }
 
 return pTextField;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2020-01-29 Thread Serge Krot (via logerrit)
 sw/source/filter/ww8/ww8atr.cxx |   16 
 1 file changed, 16 insertions(+)

New commits:
commit 98967613b4ca12f6be4d3a75be65caa3b45621e3
Author: Serge Krot 
AuthorDate: Fri Jan 10 14:44:25 2020 +0100
Commit: Thorsten Behrens 
CommitDate: Wed Jan 29 12:46:38 2020 +0100

tdf#129924 docx import: set background color

Change-Id: If586a7a11e375c1592253630af87772bca40b52e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86542
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 

tdf#129924 critical fix: use SvxColorItem instead of SvxBrushItem

Change-Id: I09b1e9fe53315974864c8d6947c7cb861f069a68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86953
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87537
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index dd9bcf6d02ef..892750d8240f 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -261,6 +261,22 @@ void MSWordExportBase::ExportPoolItemsToCHP( 
ww8::PoolItems , sal_uInt16
 
 AttrOutput().OutputItem( fontHeight );
  }
+ else if (nWhich == RES_CHRATR_COLOR)
+ {
+const SvxColorItem& rColor = static_cast(*pItem);
+const SfxPoolItem* pBackgroundItem = SearchPoolItems(rItems, 
RES_CHRATR_BACKGROUND);
+if (rColor.GetValue() == COL_AUTO && pBackgroundItem)
+{
+const SvxBrushItem& rBrushBackground = static_cast(*pBackgroundItem);
+SvxColorItem 
aForeground(rBrushBackground.GetColor().IsDark() ? COL_WHITE : COL_BLACK, 
RES_CHRATR_COLOR);
+AttrOutput().OutputItem(aForeground);
+}
+else
+{
+// default
+AttrOutput().OutputItem( *pItem );
+}
+ }
  else
  {
 AttrOutput().OutputItem( *pItem );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

2020-01-29 Thread Serge Krot (via logerrit)
 sw/source/filter/ww8/docxattributeoutput.cxx |7 +++
 1 file changed, 7 insertions(+)

New commits:
commit 0d2d1643e127696dbee30ab57fa56508c0c4d04b
Author: Serge Krot 
AuthorDate: Tue Jan 14 16:03:08 2020 +0100
Commit: Thorsten Behrens 
CommitDate: Wed Jan 29 12:46:03 2020 +0100

tdf#126795 docx export: do not output tab stops twice

Change-Id: I70235df7fb73133f413863ee5eb7c76905a60248
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86767
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 264d27c94d7286a407b05a32f4097ac9d543e1a3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87525
Tested-by: Thorsten Behrens 

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7a01c9ff1533..cf0195c2c7ec 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7869,6 +7869,13 @@ void DocxAttributeOutput::ParaTabStop( const 
SvxTabStopItem& rTabStop )
 return;
 }
 
+// do not output inherited tabs twice (inside styles and inside inline 
properties)
+if ( nCount == nInheritedTabCount && nCount > 0 )
+{
+if ( *pInheritedTabs == rTabStop )
+return;
+}
+
 m_pSerializer->startElementNS(XML_w, XML_tabs);
 
 // Get offset for tabs
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits