[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/inc sw/qa sw/source xmloff/qa

2023-04-12 Thread Justin Luth (via logerrit)
 dev/null  |binary
 sw/inc/frmfmt.hxx |6 
 sw/inc/textboxhelper.hxx  |   26 +
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|6 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   18 -
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |4 
 sw/qa/extras/uiwriter/uiwriter3.cxx   |  132 -
 sw/source/core/doc/DocumentLayoutManager.cxx  |8 
 sw/source/core/doc/docdraw.cxx|   29 --
 sw/source/core/doc/textboxhelper.cxx  |  373 +-
 sw/source/core/draw/dcontact.cxx  |2 
 sw/source/core/frmedt/feshview.cxx|8 
 sw/source/core/layout/atrfrm.cxx  |   31 +-
 sw/source/core/text/porfly.cxx|   56 +++
 sw/source/core/undo/undobj1.cxx   |   22 -
 sw/source/core/undo/undraw.cxx|   32 +-
 xmloff/qa/unit/draw.cxx   |2 
 17 files changed, 338 insertions(+), 417 deletions(-)

New commits:
commit 1f53c056c4bdd403a709f72263168137d7bdb1c0
Author: Justin Luth 
AuthorDate: Wed Apr 12 08:57:36 2023 -0400
Commit: Andras Timar 
CommitDate: Wed Apr 12 21:33:00 2023 +0200

Revert "tdf#147126 sw: fix missing as_char anchoring of group textboxes"

This reverts commit 341e397d970d10281fbc9691874b4441a841837d.

It was added for T38690 and removed for T41585

Change-Id: I39cd0711047a131a3d60106b8682097411318781
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150293
Reviewed-by: Justin Luth 
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index fd194a639bcc..1a0cadabc0e9 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -92,6 +92,10 @@ public:
 /// Copy shape attributes to the text frame
 static void updateTextBoxMargin(SdrObject* pObj);
 
+/// Sets the surround to through for the textframe of the given shape,
+/// not to interfere with the layout. Returns true on success.
+static bool setWrapThrough(SwFrameFormat* pShape);
+
 /// Sets the anchor of the associated textframe of the given shape, and
 /// returns true on success.
 static bool changeAnchor(SwFrameFormat* pShape, SdrObject* pObj);
@@ -100,9 +104,19 @@ public:
 /// returns true on success.
 static bool doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pObj);
 
+/// Returns true if the anchor different for the  given shape, and the
+/// associated textframe of the given shape.
+/// Note: In case of AS_CHAR anchor the anchor type must be different,
+/// because if not, layout breaks, but this situation also handled by
+/// this function, and returns true in that case too.
+static std::optional isAnchorTypeDifferent(const SwFrameFormat* 
pShape);
+
 /// Sets the correct size of textframe depending on the given SdrObject.
 static bool syncTextBoxSize(SwFrameFormat* pShape, SdrObject* pObj);
 
+/// Returns true if the given shape has a valid textframe.
+static bool isTextBoxShapeHasValidTextFrame(const SwFrameFormat* pShape);
+
 // Returns true on success. Synchronize z-order of the text frame of the 
given textbox
 // by setting it one level higher than the z-order of the shape of the 
textbox.
 static bool DoTextBoxZOrderCorrection(SwFrameFormat* pShape, const 
SdrObject* pObj);
@@ -174,8 +188,7 @@ public:
 /// Calls the method given by pFunc with every textboxes of the group 
given by pFormat.
 static void synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat*, 
SdrObject*),
 SwFrameFormat* pFormat, 
SdrObject* pObj);
-
-/// Collect all textboxes of the group given by the pGroupObj Parameter. 
Returns with a
+/// Collect all textboxes of the group given by the pGoupObj Parameter. 
Returns with a
 /// vector filled with the textboxes.
 static std::vector CollectTextBoxes(SdrObject* 
pGroupObject,
 SwFrameFormat* 
pFormat);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index b84b9ef1f9d6..3747aa399a27 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -400,16 +400,14 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFdo78910, 
"fdo78910.docx")
 assertXPath ( pXmlDoc, "//w:hyperlink[2]/w:r[5]/w:fldChar", "fldCharType", 
"end" );
 }
 
-// FIXME: During this test a pure VML shape get converted to DML and crash at 
verifying.
-// CPPUNIT_TEST_FIXTURE(Test, testFDO78590)
-// DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFDO78590, "FDO78590.docx")
-// {
-// xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
-//
-// // This is to ensure that the fld starts and ends inside a hyperlink...
-// assertXPath ( pXmlDoc, 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 2 commits - sw/inc sw/qa sw/source xmloff/qa

2023-01-17 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/frmfmt.hxx |6 
 sw/inc/textboxhelper.hxx  |   26 -
 sw/qa/extras/ooxmlexport/data/Tdf147485.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|6 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   18 -
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx |4 
 sw/qa/extras/uiwriter/data/tdf147126.docx |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx   |  132 +
 sw/source/core/doc/DocumentLayoutManager.cxx  |8 
 sw/source/core/doc/docdraw.cxx|   29 +-
 sw/source/core/doc/textboxhelper.cxx  |  373 --
 sw/source/core/draw/dcontact.cxx  |2 
 sw/source/core/frmedt/feshview.cxx|8 
 sw/source/core/layout/atrfrm.cxx  |   31 --
 sw/source/core/text/porfly.cxx|   56 ---
 sw/source/core/undo/undobj1.cxx   |   22 -
 sw/source/core/undo/undraw.cxx|   32 +-
 xmloff/qa/unit/draw.cxx   |2 
 18 files changed, 417 insertions(+), 338 deletions(-)

New commits:
commit 044c63c631f0af832aa8452bc4a8b0b38dc91c23
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Mar 30 13:05:37 2022 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jan 17 09:24:56 2023 +

tdf#147485 sw: fix group shape crash using std::shared_ptr

for SwFrameFormat::m_pOtherTextBoxeFormats.
Before there was broken manual handling of this
member, resulting random crashes.

Details: Writer textboxes are textframe + shape
pairs. Accordingly the shape has a draw format,
the frame has a fly format. In case of group
shapes the paired structure doesn't work, because
there is one shape format and many fly formats.
To handle this there is a class (SwTextBoxNode)
which has a small frame format table inside.
This cache gives the possibility to handle
each frame shape pairs inside the group depending
on what SdrObject owns that textbox.

However there is another place where these formats
stored, namely the SpzFrameFormatTable in SwDoc.
The only problem is that, when a flyframe removed,
it has to be deleted from both tables, but if the
DelLayoutFormat() is called, that will call the
~FrameFormat(), and if the format already deleted
from the SwTextBoxNode, there will be double deleting
for the same address, which caused the crash.

To avoid this the following is present:

When fly deletion occurs, first the format is
deleted from the doc, then via the ~SwFrameFomat()
will be deleted from the TextBoxNode. If the deleted
format is a drawing, the whole node will be destructed
via the shared_ptr. Hopefully that will be fine,
without any leak.

Change-Id: I007724695bc035998cb35efeefecd308aae36e85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132308
Reviewed-by: László Németh 
Tested-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143369
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 59aee54a2f4a..808bbb482e5d 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -74,7 +74,7 @@ class SW_DLLPUBLIC SwFrameFormat
 // The assigned SwFrmFmt list.
 SwFrameFormats *m_ffList;
 
-SwTextBoxNode* m_pOtherTextBoxFormat;
+std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats;
 
 struct change_name
 {
@@ -102,8 +102,8 @@ protected:
 
 public:
 
-SwTextBoxNode* GetOtherTextBoxFormat() const { return 
m_pOtherTextBoxFormat; };
-void SetOtherTextBoxFormat(SwTextBoxNode* pNew) { m_pOtherTextBoxFormat = 
pNew; };
+const std::shared_ptr< SwTextBoxNode >& GetOtherTextBoxFormats() const { 
return m_pOtherTextBoxFormats; };
+void SetOtherTextBoxFormats(const std::shared_ptr& rNew) { 
m_pOtherTextBoxFormats = rNew; };
 
 virtual ~SwFrameFormat() override;
 
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index fd194a639bcc..a389634c60eb 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -214,7 +214,7 @@ public:
 ~SwTextBoxNode();
 
 // default copy ctor is enough
-SwTextBoxNode(SwTextBoxNode&) = default;
+SwTextBoxNode(const SwTextBoxNode&) = default;
 
 // This method adds a textbox entry to the shape
 // Parameters:
@@ -225,7 +225,12 @@ public:
 // This will remove the textbox entry.
 // Parameters:
 // pDrawObject: The shape which have the textbox to be deleted.
-void DelTextBox(const SdrObject* pDrawObject);
+void DelTextBox(const SdrObject* pDrawObject, bool bDelFromDoc = false);
+
+// This will remove the textbox entry.
+// Parameters:
+// pTextBox: The textbox what have to be deleted.
+void DelTextBox(const SwFrameFormat* pTextBox, bool bDelFromDoc = false);
 
 // This will return with the frame format of the textbox what