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

2021-04-23 Thread László Németh (via logerrit)
 sw/inc/IDocumentRedlineAccess.hxx |5 +++
 sw/qa/extras/uiwriter/uiwriter.cxx|   13 +---
 sw/source/core/doc/DocumentRedlineManager.cxx |   29 ++
 sw/source/core/edit/acorrect.cxx  |   41 +-
 sw/source/core/inc/DocumentRedlineManager.hxx |5 +++
 5 files changed, 63 insertions(+), 30 deletions(-)

New commits:
commit a2f9c539accc17cb980c35f810fa24f200c8bf1a
Author: László Németh 
AuthorDate: Mon Nov 9 11:36:57 2020 +0100
Commit: Gabor Kelemen 
CommitDate: Fri Apr 23 15:50:44 2021 +0200

tdf#83419 sw change tracking: clean-up autocorrect

fix of commit ac84cf7dda4a5150ff23e112ee16f00b8de8ec7c
(tdf#83419 sw change tracking: fix bad autocorrect).

Now automatic sentence capitalization and
correction of two initial capitals are allowed
again, if there is a tracked deletion in the same
paragraph before the modified word.

Change-Id: I8c583df2f14468b47079019009e7937f559b652b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105477
Tested-by: László Németh 
Reviewed-by: László Németh 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114548
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/IDocumentRedlineAccess.hxx 
b/sw/inc/IDocumentRedlineAccess.hxx
index 395fae8d47e2..0e4c9e33fb52 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -170,6 +170,11 @@ public:
 /*[in]*/const SwNode& rNode,
 /*[in]*/RedlineType nType) const = 0;
 
+virtual bool HasRedline(
+/*[in]*/const SwPaM& rPam,
+/*[in]*/RedlineType nType,
+/*[in]*/bool bStartOrEndInRange) const = 0;
+
 virtual void CompressRedlines() = 0;
 
 virtual const SwRangeRedline* GetRedline(
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 8d2cd669630d..7b29b6026231 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -7538,8 +7538,14 @@ void SwUiWriterTest::testRedlineAutoCorrect()
 pWrtShell->Insert("et");
 pWrtShell->AutoCorrect(corr, ' ');
 // This was "Ttest" removing the tracked deletion silently.
-// FIXME The second patch from bug #83419 is missing from backport
-sReplaced = "tstest ";
+sReplaced = "tset ";
+nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast(pDoc->GetNodes()[nIndex])->GetText());
+
+// Including capitalization
+pWrtShell->Insert("end. word");
+pWrtShell->AutoCorrect(corr, ' ');
+sReplaced = "tset end. Word ";
 nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
 CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast(pDoc->GetNodes()[nIndex])->GetText());
 
@@ -7547,8 +7553,7 @@ void SwUiWriterTest::testRedlineAutoCorrect()
 dispatchCommand(mxComponent, ".uno:GoToStartOfDoc", {});
 pWrtShell->Insert("a");
 pWrtShell->AutoCorrect(corr, ' ');
-// FIXME The second patch from bug #83419 is missing from backport
-sReplaced = "A tstest ";
+sReplaced = "A tset end. Word ";
 nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
 CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast(pDoc->GetNodes()[nIndex])->GetText());
 }
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index f3aaa13a60d1..010a756af3e4 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2523,6 +2523,35 @@ SwRedlineTable::size_type 
DocumentRedlineManager::GetRedlinePos( const SwNode& r
 // #TODO - add 'SwExtraRedlineTable' also ?
 }
 
+bool DocumentRedlineManager::HasRedline( const SwPaM& rPam, RedlineType nType, 
bool bStartOrEndInRange ) const // xxx
+{
+SwPosition currentStart(*rPam.Start());
+SwPosition currentEnd(*rPam.End());
+SwNodeIndex pEndNodeIndex(currentEnd.nNode.GetNode());
+
+for( SwRedlineTable::size_type n = GetRedlinePos( 
rPam.Start()->nNode.GetNode(), nType );
+n < mpRedlineTable->size(); ++n )
+{
+const SwRangeRedline* pTmp = (*mpRedlineTable)[ n ];
+
+if ( pTmp->Start()->nNode > pEndNodeIndex )
+break;
+
+if( RedlineType::Any != nType && nType != pTmp->GetType() )
+continue;
+
+// redline over the range
+if ( currentStart < *pTmp->End() && *pTmp->Start() <= currentEnd &&
+ // starting or ending within the range
+ ( !bStartOrEndInRange ||
+ ( currentStart <= *pTmp->Start() || *pTmp->End() <= 
currentEnd ) ) )
+{
+return true;
+}
+}
+return false;
+}
+
 const SwRangeRedline* DocumentRedlineManager::GetRedline( const SwPosition& 
rPos,
 SwRedlineTable::size_type* pFndPos ) const
 {
diff --git a/sw/source/core/edit/acorrect.cxx 

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

2021-04-20 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx|6 ++
 sw/qa/extras/layout/data/tdf137025.docx |binary
 sw/qa/extras/layout/layout.cxx  |   69 
 sw/source/core/doc/textboxhelper.cxx|   34 +++
 sw/source/uibase/shells/drawdlg.cxx |8 +++
 5 files changed, 117 insertions(+)

New commits:
commit f97331f691588aa42c004fe19d7874092ab45e4f
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Sep 30 11:24:14 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Tue Apr 20 17:17:22 2021 +0200

tdf#137025 sw: apply textbox padding set in Text

dialog window using Spacing to Borders in
Format->Text Box and Shape->Text attributes...
on the selected text box.

There are two types of text boxes in sw, the
older editeng one, what worked fine, and
the newer one, the shape + text frame one,
where modifying Spacing to Borders had no
effect. This has been fixed by copying the
modified shape attributes to the associated
text frame.

Change-Id: I8da0b414fd4771fa86851d9a6affbd9502894ebf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103674
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit 726c911b90b9a3170fa6b3a34bb952a8d2dbe148)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114352
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index e6c991d8acfa..58f5deba8485 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -79,6 +79,9 @@ public:
 /// Similar to syncProperty(), but used by the internal API (e.g. for UI 
purposes).
 static void syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
rSet);
 
+/// Copy shape attributes to the text frame
+static void updateTextBoxMargin(SdrObject* pObj);
+
 /**
  * If we have an associated TextFrame, then return that.
  *
@@ -105,6 +108,9 @@ public:
  */
 static bool isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType);
 
+/// Returns true if the SdrObject has a SwTextFrame otherwise false
+static bool hasTextFrame(const SdrObject* pObj);
+
 /// Count number of shapes in the document, excluding TextBoxes.
 static sal_Int32 getCount(const SwDoc* pDoc);
 /// Count number of shapes on the page, excluding TextBoxes.
diff --git a/sw/qa/extras/layout/data/tdf137025.docx 
b/sw/qa/extras/layout/data/tdf137025.docx
new file mode 100755
index ..89f33a911ebe
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf137025.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 02c754b8404c..b45474ac4245 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -44,6 +44,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -796,6 +800,71 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testRedlineFlysInHeader)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025)
+{
+// Check the padding of the textbox
+SwDoc* pDoc = createDoc("tdf137025.docx");
+CPPUNIT_ASSERT(pDoc);
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+CPPUNIT_ASSERT(pXmlDoc);
+
+// Check the layout xml
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[3]",
+"value", "567");
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[4]",
+"value", "1134");
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[5]",
+"value", "1701");
+assertXPath(pXmlDoc,
+"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
+"/DefaultProperties/SfxItemSet/SfxInt32Item[6]",
+"value", "2268");
+
+// Check the textbox-shape import too
+auto xShp = getShape(1);
+CPPUNIT_ASSERT(xShp);
+
+uno::Reference xShapeProps(xShp, uno::UNO_QUERY);
+
+SwFrameFormat* pFrameFormat = SwTextBoxHelper::getOtherTextBoxFormat(xShp);
+CPPUNIT_ASSERT(pFrameFormat);
+
+// The shape has these values to copy to the associated text frame after 
modification::
+const long nLPaddng = 
xShapeProps->getPropertyValue("TextLeftDistance").get();
+const long nRPaddng = 
xShapeProps->getPropertyValue("TextRightDistance").get();
+const long nTPaddng = 
xShapeProps->getPropertyValue("TextUpperDistance").get();
+const long nBPaddng = 
xShapeProps->getPropertyValue("TextLowerDistance").get();
+
+CPPUNIT_ASSERT_EQUAL(long(1000), nLPaddng);
+CPPUNIT_ASSERT_EQUAL(long(2000), nRPaddng);
+CPPUNIT_ASSERT_EQUAL(long(3000), nTPaddng);
+ 

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

2021-03-01 Thread Attila Bakos (NISZ) (via logerrit)
 sw/inc/textboxhelper.hxx   |5 ++-
 sw/qa/extras/layout/data/tdf137185.odt |binary
 sw/qa/extras/layout/layout.cxx |   43 +
 sw/source/core/doc/textboxhelper.cxx   |   36 ++-
 sw/source/uibase/shells/drawsh.cxx |2 -
 5 files changed, 82 insertions(+), 4 deletions(-)

New commits:
commit 07b856e94b6e6af25394f2b18adf7ad33ebc7256
Author: Attila Bakos (NISZ) 
AuthorDate: Wed Oct 28 15:11:08 2020 +0100
Commit: Gabor Kelemen 
CommitDate: Mon Mar 1 12:36:21 2021 +0100

tdf#137185 sw: move shape text on adding textbox

The original text of the shape is moved to the new
(text frame of the) text box instead of overlapping
the text content added later.

Change-Id: I2ad8865cdbe3c424c70985737ecda3ac9315cabc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104942
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit ae8bc80952fafc791ce8bbddd99c99626a93989c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111700
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 746a5e90b356..e6c991d8acfa 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -58,8 +58,9 @@ public:
 using SavedLink = std::map;
 /// Maps a draw format to content.
 using SavedContent = std::map;
-/// Create a TextBox for a shape.
-static void create(SwFrameFormat* pShape);
+/// Create a TextBox for a shape. If the second parameter is true,
+/// the original text in the shape will be copied to the frame
+static void create(SwFrameFormat* pShape, bool bCopyText = false);
 /// Destroy a TextBox for a shape.
 static void destroy(SwFrameFormat* pShape);
 /// Get interface of a shape's TextBox, if there is any.
diff --git a/sw/qa/extras/layout/data/tdf137185.odt 
b/sw/qa/extras/layout/data/tdf137185.odt
new file mode 100755
index ..65d1f5de672d
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf137185.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 11bdd07c9771..c41681b93f36 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -35,6 +35,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 
@@ -4464,6 +4470,43 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf135035)
 CPPUNIT_ASSERT_GREATER(nParentWidth, nFly3Width);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf137185)
+{
+// First load the sample bugdoc
+load(DATA_DIRECTORY, "tdf137185.odt");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+// Get the doc shell
+SwDoc* pDoc(pTextDoc->GetDocShell()->GetDoc());
+
+// Get the DrawObject from page
+auto pModel = pDoc->getIDocumentDrawModelAccess().GetDrawModel();
+CPPUNIT_ASSERT(pModel);
+auto pPage = pModel->GetPage(0);
+CPPUNIT_ASSERT(pModel);
+auto pObj = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObj);
+
+// Get the format of the draw object
+auto pShape = FindFrameFormat(pObj);
+CPPUNIT_ASSERT(pShape);
+
+// Check the text of the shape
+uno::Reference xTxt(getShape(1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), xTxt->getText()->getString());
+
+// Add a textbox to the shape
+SwTextBoxHelper::create(pShape, true);
+
+// Check if the text moved from the shape to the frame
+auto pFormat = SwTextBoxHelper::getOtherTextBoxFormat(getShape(1));
+auto xTextFrame = SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), 
pFormat);
+
+CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), 
xTextFrame->getText()->getString());
+CPPUNIT_ASSERT_EQUAL(OUString(), xTxt->getText()->getString());
+// Before the patch it failled, because the text appeared 2 times on each 
other.
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 69b369e2525c..c900255a1a7e 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -49,12 +50,27 @@
 
 using namespace com::sun::star;
 
-void SwTextBoxHelper::create(SwFrameFormat* pShape)
+void SwTextBoxHelper::create(SwFrameFormat* pShape, bool bCopyText)
 {
 // If TextBox wasn't enabled previously
 if (pShape->GetAttrSet().HasItem(RES_CNTNT) && 
pShape->GetOtherTextBoxFormat())
 return;
 
+// Store the current text conent of the shape
+OUString sCopyableText;
+
+if (bCopyText)
+{
+if (auto pSdrShape = pShape->FindRealSdrObject())
+{
+uno::Reference xSrcCnt(pSdrShape->getWeakUnoShape(), 
uno::UNO_QUERY);

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

2021-01-06 Thread Attila Bakos (via logerrit)
 sw/inc/anchoredobject.hxx   |6 ++
 sw/qa/extras/layout/data/tdf106153.docx |binary
 sw/qa/extras/layout/layout.cxx  |   29 +
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx   |   11 ---
 sw/source/core/draw/dflyobj.cxx |2 
 sw/source/core/layout/anchoredobject.cxx|9 +++
 sw/source/core/layout/flylay.cxx|2 
 sw/source/core/objectpositioning/anchoredobjectposition.cxx |   36 ++--
 8 files changed, 54 insertions(+), 41 deletions(-)

New commits:
commit ed4d49b3fb5197f990c3ea38d0c60e15bdae730a
Author: Attila Bakos 
AuthorDate: Thu Aug 6 13:49:43 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Wed Jan 6 14:10:49 2021 +0100

tdf#106153 sw compatibility: fix textboxes exceeding the page

In compatibility mode DISABLE_OFF_PAGE_POSITIONING, textboxes
fell apart by exceeding the page. Now text content stay inside
the textboxes instead of the page area.

Main Developer: Dániel Arató (NISZ).

Commit a4dee94afed9ade6ac50237c8d99a6e49d3bebc1 (tdf#91260: allow
textboxes extending beyond the page bottom) is reverted partially,
according to this and the following commits:

Commit 8d62b79f168180c6992eb483ec864d473050635f
(tdf#112443 disable off-page content positioning) and
commit ee6cd34eb3a2bd1f1340063ee4b90a72ff0c9532
(tdf#123621 sw: fix textbox position according to DOCX).

Change-Id: Icb8fba161f7e8830cdb6bf6e299cccde09e7e008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100239
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit b6850bbe95418ecfde404be1696548f18d200c9b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108863
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx
index 0c5c2495092a..bb65029c97f2 100644
--- a/sw/inc/anchoredobject.hxx
+++ b/sw/inc/anchoredobject.hxx
@@ -408,6 +408,12 @@ class SW_DLLPUBLIC SwAnchoredObject
 */
 virtual bool IsFormatPossible() const;
 
+/** method to determine if dragging objects off page is allowed
+
+Returns true if editor objects can be dragged off page, false 
otherwise
+*/
+static bool IsDraggingOffPageAllowed(const SwFrameFormat*);
+
 // accessors to member 
 void SetTmpConsiderWrapInfluence( const bool 
_bTmpConsiderWrapInfluence );
 bool IsTmpConsiderWrapInfluence() const { return 
mbTmpConsiderWrapInfluence;}
diff --git a/sw/qa/extras/layout/data/tdf106153.docx 
b/sw/qa/extras/layout/data/tdf106153.docx
new file mode 100644
index ..cba072360d4c
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf106153.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 31655426c98e..52b85318e9de 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -1248,6 +1248,35 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testNoLineBreakAtSlash)
 assertXPath(pLayout, "/root/page[1]/body/txt[1]/Text[3]", "Portion", 
"13/c/2, etc.");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106153)
+{
+load(DATA_DIRECTORY, "tdf106153.docx");
+xmlDocUniquePtr pDump = parseLayoutDump();
+
+const sal_Int64 nPageValLeft = getXPath(pDump, "/root/page/infos/bounds", 
"left").toInt64();
+const sal_Int64 nPageValTop = getXPath(pDump, "/root/page/infos/bounds", 
"top").toInt64();
+const sal_Int64 nPageValRight = getXPath(pDump, "/root/page/infos/bounds", 
"right").toInt64();
+const sal_Int64 nPageValBottom = getXPath(pDump, 
"/root/page/infos/bounds", "bottom").toInt64();
+
+const sal_Int64 nShape1ValTop
+= getXPath(pDump, "/root/page/body/txt/anchored/fly[1]/infos/bounds", 
"top").toInt64();
+const sal_Int64 nShape2ValLeft
+= getXPath(pDump, "/root/page/body/txt/anchored/fly[2]/infos/bounds", 
"left").toInt64();
+const sal_Int64 nShape3ValRight
+= getXPath(pDump, "/root/page/body/txt/anchored/fly[3]/infos/bounds", 
"right").toInt64();
+const sal_Int64 nShape4ValBottom
+= getXPath(pDump, "/root/page/body/txt/anchored/fly[4]/infos/bounds", 
"bottom").toInt64();
+
+CPPUNIT_ASSERT_MESSAGE("The whole top textbox is inside the page!",
+   nPageValTop > nShape1ValTop);
+CPPUNIT_ASSERT_MESSAGE("The whole left textbox is inside the page!",
+   nPageValLeft > nShape2ValLeft);
+CPPUNIT_ASSERT_MESSAGE("The whole right textbox is inside the page!",
+   nPageValRight < nShape3ValRight);
+CPPUNIT_ASSERT_MESSAGE("The whole bottom textbox is inside the page!",
+   nPageValBottom < nShape4ValBottom);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineFlysInFlys)
 {
 

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

2021-01-05 Thread Attila Szűcs (via logerrit)
 sw/inc/IDocumentSettingAccess.hxx |1 +
 sw/qa/extras/layout/data/tdf124423.docx   |binary
 sw/qa/extras/layout/data/tdf124423.odt|binary
 sw/qa/extras/layout/layout.cxx|   19 +++
 sw/source/core/doc/DocumentSettingManager.cxx |   13 -
 sw/source/core/inc/DocumentSettingManager.hxx |2 +-
 sw/source/core/layout/fly.cxx |7 +++
 sw/source/filter/ww8/ww8par.cxx   |2 ++
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   18 ++
 writerfilter/source/dmapper/DomainMapper.cxx  |1 +
 10 files changed, 61 insertions(+), 2 deletions(-)

New commits:
commit fdfdfb991855db4888619cc2924654bbb98ea538
Author: Attila Szűcs 
AuthorDate: Mon Jun 29 15:55:28 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Tue Jan 5 20:15:27 2021 +0100

tdf#124423 sw: fix AutoSize width frames of DOCX

Add layout compatibility option FRAME_AUTOWIDTH_WITH_MORE_PARA
to keep paragraph area width of AutoSize width frames with
more than one paragraph.

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: Iab8926b6219ac92ef1ab7488bdef1d3f2b47c396
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97425
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit c78221a5ad98939f3fb9ca6af4a2d2d2a63ff6ee)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108728
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 2388b3ad45d5..f7de2f72786a 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -108,6 +108,7 @@ enum class DocumentSettingId
 PROTECT_BOOKMARKS,
 PROTECT_FIELDS,
 HEADER_SPACING_BELOW_LAST_PARA,
+FRAME_AUTOWIDTH_WITH_MORE_PARA,
 };
 
  /** Provides access to settings of a document
diff --git a/sw/qa/extras/layout/data/tdf124423.docx 
b/sw/qa/extras/layout/data/tdf124423.docx
new file mode 100644
index ..d48cc60b2923
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf124423.docx differ
diff --git a/sw/qa/extras/layout/data/tdf124423.odt 
b/sw/qa/extras/layout/data/tdf124423.odt
new file mode 100644
index ..2202c93c5c46
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf124423.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index f276ac82b491..28657f40c236 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -4292,6 +4292,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134548)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124423)
+{
+createDoc("tdf124423.docx");
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+sal_Int32 nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", 
"width").toInt32();
+sal_Int32 nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", 
"width").toInt32();
+sal_Int32 nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", 
"width").toInt32();
+CPPUNIT_ASSERT_EQUAL(nPageWidth, nFly2Width);
+CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
+
+createDoc("tdf124423.odt");
+pXmlDoc = parseLayoutDump();
+nFly1Width = getXPath(pXmlDoc, "(//fly)[1]/infos/prtBounds", 
"width").toInt32();
+nFly2Width = getXPath(pXmlDoc, "(//fly)[2]/infos/prtBounds", 
"width").toInt32();
+nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", 
"width").toInt32();
+CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly2Width);
+CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index ca68d3e306ce..fcb95f1d6534 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -97,7 +97,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
)
 mbDisableOffPagePositioning ( false ),
 mbProtectBookmarks(false),
 mbProtectFields(false),
-mbHeaderSpacingBelowLastPara(false)
+mbHeaderSpacingBelowLastPara(false),
+mbFrameAutowidthWithMorePara(false)
 
 // COMPATIBILITY FLAGS END
 {
@@ -229,6 +230,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
 case DocumentSettingId::PROTECT_BOOKMARKS: return mbProtectBookmarks;
 case DocumentSettingId::PROTECT_FIELDS: return mbProtectFields;
 case DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA: return 
mbHeaderSpacingBelowLastPara;
+case DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA: return 
mbFrameAutowidthWithMorePara;
 default:
 OSL_FAIL("Invalid setting id");
 }
@@ -480,6 +482,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
 case