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

2022-06-10 Thread Michael Stahl (via logerrit)
 sw/inc/IDocumentContentOperations.hxx   |   11 +++
 sw/inc/editsh.hxx   |4 -
 sw/qa/extras/uiwriter/uiwriter3.cxx |6 +-
 sw/qa/uitest/writer_tests7/tdf137802.py |2 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   46 
 sw/source/core/docnode/ndsect.cxx   |2 
 sw/source/core/docnode/ndtbl.cxx|2 
 sw/source/core/edit/autofmt.cxx |4 -
 sw/source/core/edit/eddel.cxx   |9 +--
 sw/source/core/edit/edglbldc.cxx|2 
 sw/source/core/edit/editsh.cxx  |4 -
 sw/source/core/frmedt/fecopy.cxx|2 
 sw/source/core/frmedt/fetab.cxx |4 -
 sw/source/core/inc/DocumentContentOperationsManager.hxx |9 +--
 sw/source/core/inc/UndoDelete.hxx   |3 +
 sw/source/core/layout/atrfrm.cxx|2 
 sw/source/core/undo/undel.cxx   |   21 +--
 sw/source/core/undo/unins.cxx   |2 
 sw/source/core/undo/unredln.cxx |4 -
 sw/source/core/undo/untbl.cxx   |   14 ++--
 sw/source/uibase/dochdl/swdtflvr.cxx|2 
 sw/source/uibase/docvw/edtwin.cxx   |2 
 sw/source/uibase/lingu/hhcwrp.cxx   |4 -
 sw/source/uibase/ribbar/inputwin.cxx|4 -
 sw/source/uibase/utlui/content.cxx  |2 
 sw/source/uibase/wrtsh/delete.cxx   |   28 -
 sw/source/uibase/wrtsh/select.cxx   |4 -
 27 files changed, 119 insertions(+), 80 deletions(-)

New commits:
commit 5192cd430e8cab0ed04f8c70c5194397455ac705
Author: Michael Stahl 
AuthorDate: Tue Jun 7 19:01:24 2022 +0200
Commit: Miklos Vajna 
CommitDate: Fri Jun 10 13:07:29 2022 +0200

tdf#133957 sw: don't delete flys on Backspace/Delete keys

Also fixes: tdf#134007 tdf#138835 tdf#139514

When a character is deleted via the keyboard by Backspace or Delete key,
an artificial selection is created in SwWrtShell::DelLeft()/DelRight().

Ideally this should not delete flys that may be anchored to the
paragraphs, but unfortunately this may happen if there are only 2 empty
paragraphs in the section, because then the artificial selection cannot
be distinguished by the SwDoc implementation from a selection from
Ctrl+A (Select All), which *should* delete the flys.

So introduce a new flag that needs to be passed down multiple layers so
that SwUndoDelete can use it to determine if flys should be deleted, and
translating it to a flag that had been introduced to preserve flys in
ReplaceRange() previously.

There are a couple more callers that look like they want to "replace"
some text, so guess a bit at where to set this new flag.

(note: of course fly anchored *as char* must be deleted via keys.)

(regression from commit e75dd1fc992f168f24d66595265a978071cdd277)

Change-Id: Ib4467476b12a12aefbbcb74ab9802f9318cf9aa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135476
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 85376a02348810812d515ee72140dbf56f2b6040)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135517
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/IDocumentContentOperations.hxx 
b/sw/inc/IDocumentContentOperations.hxx
index 8f082a632d73..6faaf62fccf4 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -82,6 +82,16 @@ namespace o3tl
 template<> struct typed_flags : is_typed_flags {};
 }
 
+enum class SwDeleteFlags
+{
+Default = 0,
+ArtificialSelection = (1<<0), ///< keyboard delete, artificial selection, 
avoid deleting flys
+};
+namespace o3tl
+{
+template<> struct typed_flags : 
is_typed_flags {};
+}
+
 /** Text operation/manipulation interface
 */
 class IDocumentContentOperations
@@ -144,6 +154,7 @@ public:
 Needed for hiding of deletion redlines
 */
 virtual bool DeleteAndJoin( SwPaM&,
+SwDeleteFlags flags = SwDeleteFlags::Default,
 const bool bForceJoinNext = false ) = 0;
 
 virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0;
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 72571775af91..e07c287e4a3f 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -150,7 +150,7 @@ class SW_DLLPUBLIC SwEditShell : public SwCursorShell
  that will be used by GetGraphic() and GetGraphicSize(). */
 SAL_DLLPRIVATE SwGrfNode *GetGrfNode_() const ;
 
-SAL_DLLPRIVATE void DeleteSel( SwPaM& rPam, bool* pUndo = nullptr );
+SAL_DLLPRIVATE void DeleteSel(SwPaM& rPam, bool 

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

2022-04-07 Thread Michael Stahl (via logerrit)
 sw/inc/IDocumentMarkAccess.hxx |5 
 sw/qa/core/data/rtf/pass/forcepoint104.rtf |  571 +
 sw/qa/extras/uiwriter/uiwriter.cxx |4 
 sw/source/core/doc/docbm.cxx   |   22 -
 sw/source/core/inc/MarkManager.hxx |2 
 sw/source/core/undo/unbkmk.cxx |2 
 sw/source/core/undo/undobj.cxx |2 
 sw/source/ui/misc/bookmark.cxx |2 
 sw/source/uibase/dochdl/swdtflvr.cxx   |4 
 sw/source/uibase/shells/textsh1.cxx|4 
 sw/source/uibase/utlui/content.cxx |2 
 11 files changed, 599 insertions(+), 21 deletions(-)

New commits:
commit c489920f6f497a5bc4a9932eaa8408209b54294c
Author: Michael Stahl 
AuthorDate: Tue Apr 5 21:09:45 2022 +0200
Commit: Thorsten Behrens 
CommitDate: Fri Apr 8 00:48:48 2022 +0200

forcepoint#104 sw: do not delete fieldmark chars in MoveNodeRange()

The problem is that SwXTextTableCursor::mergeRange() wants to move some
nodes, and the deleteMarks() deletes a fieldmark creating a SaveBookmark
but it contains the positions relative to the CH_TXT_ATR_FIELD* still in
the text, while deleting the fieldmark of course removes these.

The SaveBookmark would need to adjust the indexes and store the
separator position too and the vector would need to be restored in
reverse order.

But every time the SaveBookmarks are created, they are restored as well,
so it looks simpler to just suppress deleting the CH_TXT_ATR_FIELD* in
this case, and inserting them too (latter is already done when copying
text).

Change-Id: I690c6432a38eab6dec10adff74e638f0e52cca55
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132531
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 5d41c2461642364b7159398024acccbee12f6e3e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132589
Reviewed-by: Thorsten Behrens 

diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 1d11734e46e9..d7f3bdd6674b 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -236,9 +236,12 @@ class IDocumentMarkAccess
 
 @param ppMark
 [in] an iterator pointing to the Mark to be deleted.
+@param isMoveNodes
+[in] the mark is deleted only temporarily for a node move, do not
+ remove fieldmark chars.
 */
 virtual std::unique_ptr
-deleteMark(const IDocumentMarkAccess::const_iterator_t& ppMark) =0;
+deleteMark(const IDocumentMarkAccess::const_iterator_t& ppMark, 
bool isMoveNodes) =0;
 
 /** Deletes a mark.
 
diff --git a/sw/qa/core/data/rtf/pass/forcepoint104.rtf 
b/sw/qa/core/data/rtf/pass/forcepoint104.rtf
new file mode 100644
index ..2effec385394
--- /dev/null
+++ b/sw/qa/core/data/rtf/pass/forcepoint104.rtf
@@ -0,0 +1,571 @@
+{\rtf1\ansi\deflang1045\ftnbj\uc1\deff1
+{\fonttbl{\f0 \froman \fcharset238 Times New Roman;}{\f1 \fswiss 
\fcharset23838 Arial;}{\f2 \fnil \fcharset238 Wingdings;}{\f3 \froman 
\fcharset23838 Times New Roman;}{\f4 \fswiss \fcharset238 Arial;}{\f5 \fswiss 
\fcharset238 Times New Roman;}{\f6 \fswiss \fcharset23838 
+Lucida Sans;}{\f7 \froman \fcharset238 Symbol;}{\f8 \fswiss \fcharset238 
Lucida Sans;}{\f9 \froman \fcharset238 Times New Roman;}{\f10 \fnil Courier 
New;}}
+{\colortbl ;\red255\green255\blue255 ;\red0\green0\blue0 
;\red0\green64\blue128 ;\red255\green255\blue128 ;\red0\green0\blue255 
;\red0\green0\blue160 ;\red0\green0\blue0 ;\red0\green0\blue0 
;\red0\green0\blue0 ;\red131\green58\blue20 ;\red164\green79\blue36 
+;\red162\green78\blue34 ;\red255\green255\blue255 ;\red254\green255\blue255 
;\red250\green255\blue255 ;\red251\green255\blue255 ;\red27\green10\blue0 
;\red195\green114\blue46 ;\red252\green255\blue255 ;\red249\green255\blue255 
;\red17\green7\blue0 ;\red218\green211\blue185 
+;\red179\green89\blue0 ;\red170\green83\blue0 ;\red209\green110\blue0 
;\red237\green167\blue86 ;\red242\green153\blue51 ;\red220\green127\blue19 
;\red0\green0\blue9 ;\red0\green0\blue2 ;\red0\green32\blue0 ;}
+{\stylesheet{\fs20\cf0\cb1\ulc0 Normal;}{\cs1\f3\fs20\cf0\cb1\ulc0 Default 
Paragraph Font;}{\s2\f3\fs24\cf0\cb1\ulc2 TOC 
1;}{\s3\f3\fs24\cf0\cb1\ulc2\li180 TOC 2;}{\s4\f3\fs24\cf0\cb1\ulc2\li360 TOC 
3;}{\s5\f3\fs24\cf0\cb1\ulc2\li540 TOC 4;}{\s6\f3\fs24\cf0\cb1\ulc2\li720 
+TOC 5;}{\s7\f3\fs24\cf0\cb1\ulc2\li900 TOC 6;}{\s8\f3\fs24\cf0\cb1\ulc2\li1080 
TOC 7;}{\s9\f3\fs24\cf0\cb1\ulc2\li1260 TOC 
8;}{\s10\f3\fs24\cf0\cb1\ulc2\li1440 TOC 
9;}{\s11\f1\fs32\b\cf3\cb1\ulc0\sb240\sa60 Heading 
1;}{\s12\f1\fs28\b\cf3\cb1\ulc0\sb240\sa60\outlinelevel1 
+Heading 2;}{\s13\f1\fs26\b\cf3\cb1\ulc0\sb240\sa60\outlinelevel2 Heading 
3;}{\s14\f3\fs28\b\cf3\cb1\ulc0\sb240\sa60\outlinalevel3 Heading 
4;}{\s15\f3\fs26\b\i\cf3\cb1\ulc0\sb240\sa60\outlinelevel4 Heading 

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

2022-04-03 Thread Sarper Akdemir (via logerrit)
 sw/inc/unoprnms.hxx  |1 
 sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   17 
++
 sw/source/core/unocore/unoobj.cxx|9 
+
 writerfilter/source/dmapper/DomainMapper.cxx |2 -
 writerfilter/source/dmapper/DomainMapper_Impl.cxx|8 

 6 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 87c1615c1f6525c3f0e0d16dd98269744d21d183
Author: Sarper Akdemir 
AuthorDate: Wed Mar 30 17:02:30 2022 +0300
Commit: Andras Timar 
CommitDate: Sun Apr 3 17:33:46 2022 +0200

tdf#148273 docx import: fix section break format leak to bullets

Fixes RES_PARATR_LIST_AUTOFMT leaking into the next section.

Achieves this by resetting list related attributes on the cursor's
text node in DomainMapper_Impl::RemoveLastParagraph() after the
deletion of the paragraph.

Change-Id: Ib4d09c5f190b8b8fd3bdc119ddd57d91f353de2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132324
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132440
Reviewed-by: Andras Timar 

diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 7ef5d0a58cd7..b9dbdc40e9fa 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -500,6 +500,7 @@
 #define UNO_NAME_SEPARATOR_LINE_IS_ON "SeparatorLineIsOn"
 #define UNO_NAME_IS_SKIP_HIDDEN_TEXT "IsSkipHiddenText"
 #define UNO_NAME_IS_SKIP_PROTECTED_TEXT "IsSkipProtectedText"
+#define UNO_NAME_RESET_PARAGRAPH_LIST_ATTRIBUTES "ResetParagraphListAttributes"
 #define UNO_NAME_DOCUMENT_INDEX_MARKS "DocumentIndexMarks"
 #define UNO_NAME_FOOTNOTE_IS_COLLECT_AT_TEXT_END "FootnoteIsCollectAtTextEnd"
 #define UNO_NAME_FOOTNOTE_IS_RESTART_NUMBERING "FootnoteIsRestartNumbering"
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx
new file mode 100644
index ..1ebb1e8b419c
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index f23721767fc9..370989a9d6b7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -11,6 +11,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -282,6 +283,22 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf147978enhancedPathABVW)
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, 
"tdf148273_sectionBulletFormatLeak.docx")
+{
+// get a paragraph with bullet point after section break
+uno::Reference xParagraph = getParagraph(4);
+uno::Reference xProps(xParagraph, uno::UNO_QUERY);
+
+// Make sure that the bullet has no ListAutoFormat inherited from
+// the empty paragraph before the section break
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 0
+// - Actual  : 1
+// i.e. empty paragraph formats from the first section leaked to the 
bullet's formatting
+uno::Any aValue = xProps->getPropertyValue("ListAutoFormat");
+CPPUNIT_ASSERT_EQUAL(false, aValue.hasValue());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unoobj.cxx 
b/sw/source/core/unocore/unoobj.cxx
index b26acac97282..09136cf44c8c 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -2087,6 +2087,15 @@ SwXTextCursor::setPropertyValue(
 }
 rUnoCursor.SetSkipOverProtectSections(bSet);
 }
+else if (rPropertyName == UNO_NAME_RESET_PARAGRAPH_LIST_ATTRIBUTES)
+{
+SwTextNode* pTextNode= GetPaM()->GetNode().GetTextNode();
+
+if(pTextNode)
+{
+pTextNode->ResetAttr(RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END);
+}
+}
 else
 {
 SwUnoCursorHelper::SetPropertyValue(rUnoCursor,
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index ffa829351baa..691e876d4859 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3768,10 +3768,10 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
 
static_cast(xContext.get())->SetListId(-1);;
 xContext->Erase(PROP_NUMBERING_LEVEL);
 }
-m_pImpl->SetParaSectpr(false);
 finishParagraph(bRemove, bNoNumbering);
 if (bRemove)
 m_pImpl->RemoveLastParagraph();
+m_pImpl->SetParaSectpr(false);
 }
 else
 {
diff --git 

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

2022-03-12 Thread Michael Stahl (via logerrit)
 sw/inc/crsrsh.hxx|   11 +++--
 sw/qa/extras/uiwriter/uiwriter.cxx   |6 ++---
 sw/source/core/crsr/crstrvl.cxx  |   41 +--
 sw/source/uibase/docvw/edtwin.cxx|   17 +++---
 sw/source/uibase/shells/textfld.cxx  |2 -
 sw/source/uibase/uitest/uiobject.cxx |   29 ++--
 6 files changed, 78 insertions(+), 28 deletions(-)

New commits:
commit 26830d91d2f2a2d50f989fa3f36d18d55ea0eafd
Author: Michael Stahl 
AuthorDate: Fri Mar 4 21:53:38 2022 +0100
Commit: Thorsten Behrens 
CommitDate: Sat Mar 12 11:18:16 2022 +0100

sw_redlinehide: more issues with SwEditWin Surrounding functions

.. and SwEditWinUIObject.

These need to work with TextFrameIndex.  Add some functions to
SwCursorShell to make it possible.

Change-Id: I884c4822a0e7ecf254ea09a893762e1e6d539534
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131042
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 112592ac580108998a2cd99ae9bbf376c80c10d8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131109
Reviewed-by: Thorsten Behrens 

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index dc633a7bc9f2..6d843e7e424d 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -26,6 +26,9 @@
 #include 
 #include 
 
+#ifdef SW_DLLIMPLEMENTATION
+#include 
+#endif
 #include "IShellCursorSupplier.hxx"
 #include "swdllapi.h"
 #include "docary.hxx"
@@ -789,8 +792,12 @@ public:
 bool GotoINetAttr( const SwTextINetFormat& rAttr );
 const SwFormatINetFormat* FindINetAttr( std::u16string_view rName ) const;
 
-bool SelectText( const sal_Int32 nStart,
-const sal_Int32 nEnd );
+bool SelectTextModel(sal_Int32 nStart, sal_Int32 nEnd);
+#ifdef SW_DLLIMPLEMENTATION
+bool SelectTextView(TextFrameIndex nStart, TextFrameIndex nEnd);
+// result is only valid while cursor isn't moved!
+TextFrameIndex GetCursorPointAsViewIndex() const;
+#endif
 
 bool CheckTableBoxContent( const SwPosition* pPos = nullptr );
 void SaveTableBoxContent( const SwPosition* pPos = nullptr );
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index bd7a464a23bf..d626d5a9d6ec 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -3703,7 +3703,7 @@ void SwUiWriterTest::testUndoDelAsCharTdf107512()
 CPPUNIT_ASSERT(rIDCO.InsertGraphicObject(*pShell->GetCursor(), grf, 
, ));
 CPPUNIT_ASSERT_EQUAL(size_t(2), pDoc->GetFlyCount(FLYCNTTYPE_GRF));
 SvxCharHiddenItem hidden(true, RES_CHRATR_HIDDEN);
-pShell->SelectText(1, 4);
+pShell->SelectTextModel(1, 4);
 rIDCO.InsertPoolItem(*pShell->GetCursor(), hidden);
 // now we have "\1foo\1" with the "foo" hidden
 
CPPUNIT_ASSERT(pShell->GetCursor()->GetNode().GetTextNode()->GetTextAttrForCharAt(0,
 RES_TXTATR_FLYCNT));
@@ -3717,7 +3717,7 @@ void SwUiWriterTest::testUndoDelAsCharTdf107512()
 query.ClearItem(RES_CHRATR_HIDDEN);
 
 // delete from the start
-pShell->SelectText(0, 4);
+pShell->SelectTextModel(0, 4);
 rIDCO.DeleteAndJoin(*pShell->GetCursor());
 
CPPUNIT_ASSERT(pShell->GetCursor()->GetNode().GetTextNode()->GetTextAttrForCharAt(0,
 RES_TXTATR_FLYCNT));
 CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetFlyCount(FLYCNTTYPE_GRF));
@@ -3760,7 +3760,7 @@ void SwUiWriterTest::testUndoDelAsCharTdf107512()
 query.ClearItem(RES_CHRATR_HIDDEN);
 
 // delete from the end
-pShell->SelectText(1, 5);
+pShell->SelectTextModel(1, 5);
 rIDCO.DeleteAndJoin(*pShell->GetCursor());
 
CPPUNIT_ASSERT(pShell->GetCursor()->GetNode().GetTextNode()->GetTextAttrForCharAt(0,
 RES_TXTATR_FLYCNT));
 CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetFlyCount(FLYCNTTYPE_GRF));
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index da22013cc31f..e7e27c1980a3 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1996,7 +1996,7 @@ bool SwContentAtPos::IsInRTLText()const
 return bRet;
 }
 
-bool SwCursorShell::SelectText( const sal_Int32 nStart,
+bool SwCursorShell::SelectTextModel( const sal_Int32 nStart,
  const sal_Int32 nEnd )
 {
 CurrShell aCurr( this );
@@ -2020,6 +2020,43 @@ bool SwCursorShell::SelectText( const sal_Int32 nStart,
 return bRet;
 }
 
+TextFrameIndex SwCursorShell::GetCursorPointAsViewIndex() const
+{
+SwPosition const*const pPos(GetCursor()->GetPoint());
+SwTextNode const*const pTextNode(pPos->nNode.GetNode().GetTextNode());
+assert(pTextNode);
+SwTextFrame const*const pFrame(static_cast(pTextNode->getLayoutFrame(GetLayout(;
+assert(pFrame);
+return pFrame->MapModelToViewPos(*pPos);
+}
+
+bool SwCursorShell::SelectTextView(TextFrameIndex const nStart,
+ TextFrameIndex const nEnd)
+{
+CurrShell aCurr( this );
+bool 

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

2022-02-16 Thread László Németh (via logerrit)
 sw/inc/doc.hxx  |2 +
 sw/qa/extras/uiwriter/uiwriter3.cxx |   53 
 sw/source/core/docnode/ndtbl1.cxx   |   22 ++
 sw/source/core/frmedt/fetab.cxx |   12 +++-
 4 files changed, 82 insertions(+), 7 deletions(-)

New commits:
commit 6b80222d6bc043eb78a2986e9051cee3e5ee0967
Author: László Németh 
AuthorDate: Mon Feb 14 19:13:37 2022 +0100
Commit: László Németh 
CommitDate: Wed Feb 16 20:35:25 2022 +0100

tdf#146622 sw crash fix: don't delete already deleted rows

Delete tables and rows removed also tables and table rows
with tracked row deletion/insertion. This resulted not only
lost change tracking, but a crashing Undo.

Crash regression from commit 99059a1ececa3621c2fe46fabdd79eed9d626c42
"tdf#143359 sw: track deletion of empty table rows".

Non-tracked deletion of the tracked row changes was a
temporary solution for the missing UI of tracked
row changes, implemented in commit 05366b8e6683363688de8708a3d88cf144c7a2bf
"tdf#60382 sw offapi: add change tracking of table/row deletion".

Note: UI was added in commit f348440e17debacbcba9153e238e010e8c020bdc
"tdf#146120 sw: show tracked table changes with different color",
commit 95c003d75e0f8b255344715a35358072b5eba99d
"tdf#146145 sw: 1-click Accept/Reject of table row changes",
commit 84fbb3398f7486f00e7b7dea415e1ea2510a9535
"tdf#146144 sw: add tooltip to table rows with change tracking",
commit eebe4747d2d13545004937bb0267ccfc8ab9d63f
"tdf#144270 sw: manage tracked table (row) deletion/insertion",
commit f481c2c8e74bded11fac754e493560391229dbcd
"tdf#144057 sw track changes: hide deleted table rows" and
commit 23846867ea32667ccf328c36142394dd6aaee8ba
"tdf#147182 sw: accept/reject all changes of a table selection".

(cherry-picked from commit 95213407dfcbf34056037d60243ff915340d1a2e)

Change-Id: I384b750b0d3626fa8b3f256c7eaf5b93f382e4e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130011
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 831c59d2cc05..f7749190e3ea 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1491,6 +1491,8 @@ public:
 /// rNotTracked = false means that the row was deleted or inserted with 
its tracked cell content
 /// bAll: delete all table rows without selection
 void SetRowNotTracked( const SwCursor& rCursor, const SvxPrintItem 
, bool bAll = false );
+/// don't call SetRowNotTracked() for rows with tracked row change
+static bool HasRowNotTracked( const SwCursor& rCursor );
 void SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet );
 void SetTabLineStyle( const SwCursor& rCursor,
   const Color* pColor, bool bSetLine,
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index cf8c4e07e9b6..d2123c33b20c 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1890,6 +1890,59 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132744)
 CPPUNIT_ASSERT_EQUAL(1, getShapes());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146622)
+{
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-del-add.docx");
+CPPUNIT_ASSERT(pDoc);
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTables->getCount());
+uno::Reference xTableNames = 
xTablesSupplier->getTextTables();
+CPPUNIT_ASSERT(xTableNames->hasByName("Table1"));
+uno::Reference xTable1(xTableNames->getByName("Table1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+
+dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+
+// This was 3 (deleting the already deleted row with change tracking)
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+Scheduler::ProcessEventsToIdle();
+
+dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+dispatchCommand(mxComponent, ".uno:SelectAll", {});
+Scheduler::ProcessEventsToIdle();
+
+dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+// This was 2 (deleting the already deleted table with change tracking)
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTables->getCount());

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

2022-01-31 Thread Andreas Heinisch (via logerrit)
 sw/inc/iodetect.hxx |4 ++
 sw/qa/uitest/data/tdf106899.odt |binary
 sw/qa/uitest/data/tdf106899.sdi |1 
 sw/qa/uitest/writer_tests5/tdf106899.py |   44 
 sw/source/core/edit/edtox.cxx   |6 +++-
 sw/source/filter/basflt/iodetect.cxx|   17 
 6 files changed, 71 insertions(+), 1 deletion(-)

New commits:
commit ddf9b2e23768a33041a3efe20840f1e11abff434
Author: Andreas Heinisch 
AuthorDate: Sun Jan 9 18:44:11 2022 +0100
Commit: Mike Kaganski 
CommitDate: Mon Jan 31 13:51:20 2022 +0100

tdf#106899 - Import concordance file using appropriate charset

At the beginning of the import process for the various index entries,
try to determine the correct character set for the tox concordance file.

Change-Id: I3f48325a80ed08c2c06c295a24b2fc29ce1adf99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128194
Reviewed-by: Mike Kaganski 
Reviewed-by: Andreas Heinisch 
Tested-by: Jenkins
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129206

diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx
index 9069b01ffda0..ce24e0800134 100644
--- a/sw/inc/iodetect.hxx
+++ b/sw/inc/iodetect.hxx
@@ -28,6 +28,8 @@
 #include 
 #include "swdllapi.h"
 
+#define DETECT_ENCODING_BUFFER_SIZE 4096
+
 #define FILTER_RTF  "RTF"   ///< RTF filter
 #define sRtfWH  "WH_RTF"
 #define FILTER_TEXT u"TEXT"  ///< text filter with default codeset
@@ -105,6 +107,8 @@ public:
 static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
 static bool IsValidStgFilter( const css::uno::Reference < 
css::embed::XStorage >& rStg, const SfxFilter& rFilter);
 
+// tdf#106899 - wrapper around IsDetectableText to retrieve the text 
encoding for a given stream
+static rtl_TextEncoding GetTextEncoding(SvStream&);
 static bool IsDetectableText( const char* pBuf, sal_uLong ,
 rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd, bool 
*pBom);
 
diff --git a/sw/qa/uitest/data/tdf106899.odt b/sw/qa/uitest/data/tdf106899.odt
new file mode 100644
index ..3f77c82655f3
Binary files /dev/null and b/sw/qa/uitest/data/tdf106899.odt differ
diff --git a/sw/qa/uitest/data/tdf106899.sdi b/sw/qa/uitest/data/tdf106899.sdi
new file mode 100644
index ..6b110b259661
--- /dev/null
+++ b/sw/qa/uitest/data/tdf106899.sdi
@@ -0,0 +1 @@
+Nguyễn Khánh
\ No newline at end of file
diff --git a/sw/qa/uitest/writer_tests5/tdf106899.py 
b/sw/qa/uitest/writer_tests5/tdf106899.py
new file mode 100644
index ..389552e24a89
--- /dev/null
+++ b/sw/qa/uitest/writer_tests5/tdf106899.py
@@ -0,0 +1,44 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import org.libreoffice.unotest
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_url_for_data_file
+import time
+
+class tdf106899(UITestCase):
+
+def test_tdf106899_alphabetical_index_utf8(self):
+# Copy concordance file containing an utf8 index entry
+org.libreoffice.unotest.makeCopyFromTDOC("tdf106899.sdi")
+with self.ui_test.load_file(get_url_for_data_file("tdf106899.odt")) as 
document:
+xWriterDoc = self.xUITest.getTopFocusWindow()
+
+# Update the alphabetical index and check if it contains the utf8 
index entry
+xDocumentIndexes = document.DocumentIndexes
+self.assertEqual(xDocumentIndexes.getCount(), 1)
+self.assertEqual(xDocumentIndexes.hasByName("Alphabetical 
Index1"), True)
+xDocumentIndex = xDocumentIndexes.getByName("Alphabetical Index1")
+xIndexAnchor = xDocumentIndex.getAnchor()
+self.assertEqual("Nguyễn Khánh" in xIndexAnchor.getString(), False)
+
+# TODO Bug Report - Refresh of the index does only work using 
.uno:UpdateAllIndexes
+# It does not work with xDocumentIndex.refresh() nor with 
xDocumentIndex.update()
+self.xUITest.executeCommand(".uno:UpdateAllIndexes")
+
+# TODO Bug Report - Retrieving the text of the updated index only 
works using the cursor
+# It does not work with xIndexAnchor.getString()
+xCursor = document.getText().createTextCursor()
+xCursor.gotoRange(xDocumentIndex.getAnchor().getEnd(), False)
+xCursor.gotoStartOfParagraph(True)
+
+# Without the fix in place the index does not contain the ut8 
index entry
+self.assertEqual("Nguyễn Khánh" in xCursor.getString(), True)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/edit/edtox.cxx 

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

2022-01-12 Thread László Németh (via logerrit)
 sw/inc/bitmaps.hlst |2 
 sw/qa/uitest/writer_tests/trackedChanges.py |  105 +++
 sw/source/uibase/inc/redlndlg.hxx   |2 
 sw/source/uibase/misc/redlndlg.cxx  |  148 +---
 4 files changed, 242 insertions(+), 15 deletions(-)

New commits:
commit dabf1516e83963b24cf4c54c42b02354053a2199
Author: László Németh 
AuthorDate: Wed Jan 12 10:27:35 2022 +0100
Commit: Xisco Fauli 
CommitDate: Wed Jan 12 19:08:40 2022 +0100

tdf#144270 sw: manage tracked table (row) deletion/insertion

in Manage Changes dialog window, where deleted/inserted
tables and table rows were shown as multiple cell changes,
as a regression. Now a single table deletion/insertion or
deleted/inserted consecutive table rows are shown with a
single tree item in the dialog window instead of showing
multiple cell changes.

Add new Action icons to the tracked table row
insertion/deletion tree items (re-using table row
deletion/insertion icons).

Show cell changes as children of the single parent
item tracked table row change.

Accept/Reject and Accept/Reject All support
1-click acceptance or rejection of table (row) changes,
instead of clicking on all cell changes of a single
table (row) deletion/insertion.

Regression from commit c4cf85766453982f1aa94a7f2cb22af19ed100be
"sw: fix crash due to redlines on tables on ooo121112-2.docx".

(cherry-picked from commit eebe4747d2d13545004937bb0267ccfc8ab9d63f)

Conflicts:
sw/inc/bitmaps.hlst

Change-Id: Id03a8075cc6849b70a8d32e1a955b79e7d3a3246
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128326
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sw/inc/bitmaps.hlst b/sw/inc/bitmaps.hlst
index 2a7495d70896..2e52f1e47352 100644
--- a/sw/inc/bitmaps.hlst
+++ b/sw/inc/bitmaps.hlst
@@ -28,6 +28,8 @@
 #define BMP_REDLINE_FMTCOLLSET  "sw/res/redline_fmtcollset.png"
 #define BMP_REDLINE_MOVED_INSERTION "cmd/sc_paste.png"
 #define BMP_REDLINE_MOVED_DELETION  "cmd/sc_cut.png"
+#define BMP_REDLINE_ROW_INSERTION   "cmd/sc_insertrows.png"
+#define BMP_REDLINE_ROW_DELETION"cmd/sc_deleterows.png"
 
 #define RID_BMP_COLLAPSE"res/sx18002.png"
 #define RID_BMP_EXPAND  "res/sx18003.png"
diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py 
b/sw/qa/uitest/writer_tests/trackedChanges.py
index 698202bf1647..dea49c28673f 100644
--- a/sw/qa/uitest/writer_tests/trackedChanges.py
+++ b/sw/qa/uitest/writer_tests/trackedChanges.py
@@ -214,4 +214,109 @@ class trackedchanges(UITestCase):
 # Check the changes are shown after opening the Manage Tracked 
Changes dialog
 self.assertGreater(document.CurrentController.PageCount, 5)
 
+def test_tdf144270_tracked_table_rows(self):
+with 
self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as 
document:
+xWriterDoc = self.xUITest.getTopFocusWindow()
+xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+tables = document.getTextTables()
+self.assertEqual(3, len(tables))
+
+# Accept
+with 
self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges",
 close_button="close") as xTrackDlg:
+changesList = xTrackDlg.getChild("writerchanges")
+
+# This was 14 (every cell is a different change instead of 
counting rows or tables)
+# Now: 4 changes (2 deleted/inserted rows and 2 
deleted/inserted tables)
+self.assertEqual(4, len(changesList.getChildren()))
+
+# Without the fix in place, it would have crashed here
+for i in (3, 2, 1, 0):
+xAccBtn = xTrackDlg.getChild("accept")
+xAccBtn.executeAction("CLICK", tuple())
+self.assertEqual(i, len(changesList.getChildren()))
+
+tables = document.getTextTables()
+self.assertEqual(2, len(tables))
+
+for i in range(1, 5):
+xUndoBtn = xTrackDlg.getChild("undo")
+xUndoBtn.executeAction("CLICK", tuple())
+self.assertEqual(i, len(changesList.getChildren()))
+
+tables = document.getTextTables()
+self.assertEqual(3, len(tables))
+
+# Accept All
+with 
self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges",
 close_button="close") as xTrackDlg:
+changesList = xTrackDlg.getChild("writerchanges")
+
+# This was 14 (every cell is a different change instead of 
counting rows or tables)
+# Now: 4 changes (2 deleted/inserted rows and 2 
deleted/inserted tables)
+

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

2021-12-22 Thread László Németh (via logerrit)
 sw/inc/swtable.hxx|7 ++
 sw/qa/extras/uiwriter/uiwriter4.cxx   |   62 +-
 sw/source/core/doc/DocumentRedlineManager.cxx |   33 +++--
 sw/source/core/table/swtable.cxx  |   18 +--
 4 files changed, 105 insertions(+), 15 deletions(-)

New commits:
commit 631649f233bda500c627719b9e43df3fe08df7c5
Author: László Németh 
AuthorDate: Tue Dec 21 11:50:19 2021 +0100
Commit: Xisco Fauli 
CommitDate: Wed Dec 22 10:12:16 2021 +0100

tdf#146243 sw: fix Undo of accepting table row insertion

Fix Undo of accepting table row insertion to get back
the "false" value of HasTextChangesOnly property and the
associated light blue table row background.

This fixes also the missing update of the table row
background at accepting the table row insertion.

Follow-up to commit 8c028b7e41e3d350d0e67005b16faf0159cc5c12
"tdf#146244 sw: update HasTextChangesOnly in modified rows".

Change-Id: I8e2436b6b7b67f06037481955ff22cdbc2b22dc0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127228
Tested-by: Jenkins
Reviewed-by: László Németh 
(cherry picked from commit 1edaee2f03bce0efa409c592919458658d0aa751)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127186
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 652b254a8c86..33a85f2c62a6 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -399,12 +399,15 @@ public:
 bool IsEmpty() const;
 
 // Update TextChangesOnly property based on the redlines of the table row.
-// rRedlinePos: search from this redline to speed up SwTable::IsDeleted().
+// rRedlinePos: search from this redline index to speed up 
SwTable::IsDeleted().
+// bUpdateProperty: don't update HasTextChangesOnly property, if 
bUpdateProperty = false.
+// Set rRedlinePos after the last redline index of the table row.
 // Return with the redline, which associated to the row change (latest 
deletion
 // in the case of deleted row, the first insertion in the case of row 
insertion
 // or npos, if TextChangesOnly is true, i.e. the table row is not deleted 
or inserted).
 // Cache also the type of the redline associated to the changed table row.
-SwRedlineTable::size_type UpdateTextChangesOnly(SwRedlineTable::size_type& 
rRedlinePos) const;
+SwRedlineTable::size_type UpdateTextChangesOnly(
+SwRedlineTable::size_type& rRedlinePos, bool bUpdateProperty = true) 
const;
 // is it a tracked deleted row
 bool IsDeleted(SwRedlineTable::size_type& rRedlinePos) const;
 // set/get (if it's possible, cached) redline type
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 015a065f543b..46d06d0985ae 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -200,6 +200,7 @@ public:
 void testTdf104814();
 void testTableRedlineRedoCrash();
 void testTableRemoveHasTextChangesOnly();
+void testTableRemoveHasTextChangesOnly2();
 void testTdf66405();
 void testTdf35021_tabOverMarginDemo();
 void testTdf106701_tabOverMarginAutotab();
@@ -324,6 +325,7 @@ public:
 CPPUNIT_TEST(testTdf104814);
 CPPUNIT_TEST(testTableRedlineRedoCrash);
 CPPUNIT_TEST(testTableRemoveHasTextChangesOnly);
+CPPUNIT_TEST(testTableRemoveHasTextChangesOnly2);
 CPPUNIT_TEST(testTdf66405);
 CPPUNIT_TEST(testTdf35021_tabOverMarginDemo);
 CPPUNIT_TEST(testTdf106701_tabOverMarginAutotab);
@@ -1521,7 +1523,6 @@ void SwUiWriterTest4::testTableRedlineRedoCrash()
 
 void SwUiWriterTest4::testTableRemoveHasTextChangesOnly()
 {
-//createSwDoc(DATA_DIRECTORY, "tdf91292_paraBackground.docx");
 SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-del-add.docx");
 CPPUNIT_ASSERT(pDoc);
 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
@@ -1592,6 +1593,65 @@ void SwUiWriterTest4::testTableRemoveHasTextChangesOnly()
 assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row", 4);
 }
 
+void SwUiWriterTest4::testTableRemoveHasTextChangesOnly2()
+{
+SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-del-add.docx");
+CPPUNIT_ASSERT(pDoc);
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+
+// disable Record Changes
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+CPPUNIT_ASSERT_MESSAGE("redlining should be off",
+   !pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// check redline count
+SwEditShell* const pEditShell(pDoc->GetEditShell());
+CPPUNIT_ASSERT_EQUAL(static_cast(14), 
pEditShell->GetRedlineCount());
+
+// 4 rows in Show Changes mode
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/tab[1]/row", 4);
+
+// Move the cursor to the tracked insertion, after 

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

2021-12-03 Thread Michael Stahl (via logerrit)
 sw/inc/editsh.hxx  |2 
 sw/qa/extras/tiledrendering/tiledrendering.cxx |2 
 sw/qa/extras/uiwriter/uiwriter.cxx |   24 +--
 sw/qa/extras/uiwriter/uiwriter4.cxx|2 
 sw/source/core/edit/edfld.cxx  |6 +-
 sw/source/ui/dbui/dbinsdlg.cxx |4 -
 sw/source/uibase/dochdl/swdtflvr.cxx   |2 
 sw/source/uibase/fldui/fldmgr.cxx  |   53 ++---
 sw/source/uibase/inc/wrtsh.hxx |2 
 sw/source/uibase/wrtsh/wrtsh2.cxx  |8 ++-
 10 files changed, 59 insertions(+), 46 deletions(-)

New commits:
commit f9ea114171cb422dac60100aa4d51502563f37a1
Author: Michael Stahl 
AuthorDate: Wed Dec 1 17:06:08 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Dec 3 16:56:54 2021 +0100

tdf#145062 sw: deal with failing insertion of field in SwWrtShell

Change-Id: Ic0c479e97b7a5f6fcc7f7eb454eb77a5c47de9db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126191
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit e58583e70b3434a158a3902cc7ae81d0b3bdfc49)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126244

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 076cbbf5b3bb..72571775af91 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -395,7 +395,7 @@ public:
 /// Currently there are two variants: signature and classification.
 bool RemoveParagraphMetadataFieldAtCursor();
 
-void Insert2(SwField const &, const bool bForceExpandHints);
+bool InsertField(SwField const &, const bool bForceExpandHints);
 
 void UpdateOneField(SwField &);   ///< One single field.
 
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 46a4eab3ac98..b8f3430e3269 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -2367,7 +2367,7 @@ void SwTiledRenderingTest::testRedlineField()
 
 SwDateTimeField 
aDate(static_cast(pWrtShell->GetFieldType(0, 
SwFieldIds::DateTime)));
 //aDate->SetDateTime(::DateTime(::DateTime::SYSTEM));
-pWrtShell->Insert(aDate);
+pWrtShell->InsertField2(aDate);
 
 // Get the redline just created
 const SwRedlineTable& rTable = 
pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 4325aeb1b1f5..bd7a464a23bf 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1027,7 +1027,7 @@ void SwUiWriterTest::testFdo74981()
 SwDoc* pDoc = createSwDoc();
 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
 SwInputField 
aField(static_cast(pWrtShell->GetFieldType(0, 
SwFieldIds::Input)), "foo", "bar", 0, 0);
-pWrtShell->Insert(aField);
+pWrtShell->InsertField2(aField);
 
 {
 // expect hints
@@ -1058,10 +1058,10 @@ void SwUiWriterTest::testTdf98512()
 SwInputFieldType *const pType(static_cast(
 pWrtShell->GetFieldType(0, SwFieldIds::Input)));
 SwInputField aField1(pType, "foo", "bar", INP_TXT, 0);
-pWrtShell->Insert(aField1);
+pWrtShell->InsertField2(aField1);
 pWrtShell->SttEndDoc(/*bStt=*/true);
 SwInputField aField2(pType, "baz", "quux", INP_TXT, 0);
-pWrtShell->Insert(aField2);
+pWrtShell->InsertField2(aField2);
 pWrtShell->SttEndDoc(/*bStt=*/true);
 pWrtShell->SetMark();
 pWrtShell->SttEndDoc(/*bStt=*/false);
@@ -2694,14 +2694,14 @@ void SwUiWriterTest::testTdf77342()
 pWrtShell->StartOfSection();
 //inserting reference field 1
 SwGetRefField aField1(pRefType, "", "", REF_FOOTNOTE, sal_uInt16(0), 
REF_CONTENT);
-pWrtShell->Insert(aField1);
+pWrtShell->InsertField2(aField1);
 //inserting second footnote
 pWrtShell->InsertFootnote("");
 pWrtShell->StartOfSection();
 pCursor->Move(fnMoveForward);
 //inserting reference field 2
 SwGetRefField aField2(pRefType, "", "", REF_FOOTNOTE, sal_uInt16(1), 
REF_CONTENT);
-pWrtShell->Insert(aField2);
+pWrtShell->InsertField2(aField2);
 //inserting third footnote
 pWrtShell->InsertFootnote("");
 pWrtShell->StartOfSection();
@@ -2709,7 +2709,7 @@ void SwUiWriterTest::testTdf77342()
 pCursor->Move(fnMoveForward);
 //inserting reference field 3
 SwGetRefField aField3(pRefType, "", "", REF_FOOTNOTE, sal_uInt16(2), 
REF_CONTENT);
-pWrtShell->Insert(aField3);
+pWrtShell->InsertField2(aField3);
 //updating the fields
 IDocumentFieldsAccess& rField(pDoc->getIDocumentFieldsAccess());
 rField.UpdateExpFields(nullptr, true);
@@ -2930,38 +2930,38 @@ void SwUiWriterTest::testTdf63553()
 //inserting sequence field 1
 SwSetExpFieldType* pSeqType = 
static_cast(pWrtShell->GetFieldType(SwFieldIds::SetExp, 
"Illustration"));
 SwSetExpField 

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

2021-11-28 Thread Stephan Bergmann (via logerrit)
 dev/null|binary
 sw/inc/textboxhelper.hxx|   74 +--
 sw/inc/unomid.h |4 
 sw/inc/unoprnms.hxx |1 
 sw/qa/uitest/writer_tests4/ComplexGroupShapeTest.py |  124 -
 sw/source/core/doc/DocumentLayoutManager.cxx|   45 -
 sw/source/core/doc/docdraw.cxx  |   55 --
 sw/source/core/doc/docfly.cxx   |   11 
 sw/source/core/doc/textboxhelper.cxx|  492 
 sw/source/core/draw/dcontact.cxx|   11 
 sw/source/core/draw/dview.cxx   |8 
 sw/source/core/frmedt/feshview.cxx  |4 
 sw/source/core/layout/atrfrm.cxx|5 
 sw/source/core/unocore/unodraw.cxx  |   66 --
 sw/source/core/unocore/unomap.cxx   |3 
 sw/source/core/unocore/unomap1.cxx  |1 
 16 files changed, 202 insertions(+), 702 deletions(-)

New commits:
commit 2408a1ac6131d137704860f5f8b83bb98d62a4d1
Author: Stephan Bergmann 
AuthorDate: Sun Nov 28 15:14:45 2021 +0100
Commit: Stephan Bergmann 
CommitDate: Sun Nov 28 18:03:04 2021 +0100

Revert "tdf#129183 sw: textboxes in group shapes - part 3"

This reverts commit eabcfb3f18a6944d9ad89cecd3eb3ca7a2259cf3.
Conflicts:
sw/source/core/doc/textboxhelper.cxx

It caused UITest_writer_tests4 to fail in an ASan build with
> ==2987325==ERROR: AddressSanitizer: heap-use-after-free on address 
0x613e5048 at pc 0x7f20cb3112ac bp 0x7f1e62de92d0 sp 0x7f1e62de92c8
> WRITE of size 8 at 0x613e5048 thread T47
>  #0 in SwFrameFormat::SetOtherTextBoxFormat(SwTextBoxNode*) at 
sw/inc/frmfmt.hxx:106:77
>  #1 in SwTextBoxNode::~SwTextBoxNode() at 
sw/source/core/doc/textboxhelper.cxx:1680:30
>  #2 in SwFrameFormat::~SwFrameFormat() at 
sw/source/core/layout/atrfrm.cxx:2564:9
>  #3 in SwDrawFrameFormat::~SwDrawFrameFormat() at 
sw/source/core/layout/atrfrm.cxx:3455:1
>  #4 in SwDrawFrameFormat::~SwDrawFrameFormat() at 
sw/source/core/layout/atrfrm.cxx:3453:1
>  #5 in SwFrameFormats::DeleteAndDestroyAll(bool) at 
sw/source/core/doc/docfmt.cxx:2115:9
>  #6 in SwDoc::~SwDoc() at sw/source/core/doc/docnew.cxx:565:28
>  #7 in SwDoc::release() at sw/source/core/doc/doc.cxx:118:9
>  #8 in rtl::Reference::clear() at include/rtl/ref.hxx:196:19
>  #9 in SwDocShell::RemoveLink() at 
sw/source/uibase/app/docshini.cxx:444:16
>  #10 in SwDocShell::~SwDocShell() at 
sw/source/uibase/app/docshini.cxx:372:5
>  #11 in SwDocShell::~SwDocShell() at 
sw/source/uibase/app/docshini.cxx:362:1
>  #12 in SwDocShell::~SwDocShell() at 
sw/source/uibase/app/docshini.cxx:362:1
>  #13 in SvRefBase::ReleaseRef() at include/tools/ref.hxx:163:29
>  #14 in tools::SvRef::~SvRef() at 
include/tools/ref.hxx:56:36
>  #15 in 
IMPL_SfxBaseModel_DataContainer::~IMPL_SfxBaseModel_DataContainer() at 
sfx2/source/doc/sfxbasemodel.cxx:245:5
>  #16 in void 
std::destroy_at(IMPL_SfxBaseModel_DataContainer*)
 at 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_construct.h:88:15
>  #17 in void 
std::allocator_traits 
>::destroy(std::allocator&,
 IMPL_SfxBaseModel_DataContainer*) at 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/alloc_traits.h:537:4
>  #18 in std::_Sp_counted_ptr_inplace, 
(__gnu_cxx::_Lock_policy)2>::_M_dispose() at 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:528:2
>  #19 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() 
at 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:168:6
>  #20 in 
std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() at 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:705:11
>  #21 in std::__shared_ptr::~__shared_ptr() at 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:1154:31
>  #22 in std::__shared_ptr::reset() at 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:1272:9
>  #23 in SfxBaseModel::dispose() at sfx2/source/doc/sfxbasemodel.cxx:757:13
>  #24 in SwXTextDocument::dispose() at 
sw/source/uibase/uno/unotxdoc.cxx:549:19
>  #25 in SfxBaseModel::close(unsigned char) at 
sfx2/source/doc/sfxbasemodel.cxx:1482:5
>  #26 in SwXTextDocument::close(unsigned char) at 
sw/source/uibase/uno/unotxdoc.cxx:562:19
>  #27 in SfxBaseModel::dispose() at sfx2/source/doc/sfxbasemodel.cxx:718:13
>  #28 in SwXTextDocument::dispose() at 
sw/source/uibase/uno/unotxdoc.cxx:549:19
>  #29 in