[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/qa sw/source
Daniel Arato (NISZ) (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 1 12:52:08 UTC 2021
sw/qa/core/layout/data/textbox-phantom-change.docx |binary
sw/qa/core/layout/layout.cxx | 20 ++++++++++++++
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2 -
sw/source/core/draw/dcontact.cxx | 29 ++++++++++++++++++++-
4 files changed, 49 insertions(+), 2 deletions(-)
New commits:
commit 800bdfd06fd41b1305852f01d5a2aaaf33da9431
Author: Daniel Arato (NISZ) <arato.daniel at nisz.hu>
AuthorDate: Mon Nov 16 11:53:47 2020 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Mon Mar 1 13:51:33 2021 +0100
tdf#135198 tdf#138050 sw editing: fix text box position sync
Follow-up to commit c9eb53f200225f2ee6ca695e1326843a487aee51
(tdf#135198 sw editing: text box fell out of its shape)
Every time a shape is repositioned, make sure the text box
inside the shape follows the shape.
The previous solution to this bug, the one implemented in
SwObjectFormatterTextFrame::DoFormatObjs, was a little
more cumbersome. This one should produce fewer regressions,
I hope.
Change-Id: I3e88eb8616cd299cabb7b74b188ab7220746ec89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106421
Tested-by: Jenkins
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 59fec754a1523eede0f19a59e4eeeff593a4d688)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111704
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sw/qa/core/layout/data/textbox-phantom-change.docx b/sw/qa/core/layout/data/textbox-phantom-change.docx
new file mode 100644
index 000000000000..75ac039561f6
Binary files /dev/null and b/sw/qa/core/layout/data/textbox-phantom-change.docx differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index b4fc9f3a5176..57f7c49a8eae 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -10,6 +10,13 @@
#include <swmodeltestbase.hxx>
#include <vcl/gdimtf.hxx>
+
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <unotxdoc.hxx>
+#include <drawdoc.hxx>
+#include <IDocumentDrawModelAccess.hxx>
+#include <IDocumentState.hxx>
#include <svx/svdpage.hxx>
#include <wrtsh.hxx>
@@ -149,6 +156,19 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testContinuousEndnotesMoveBackwards)
assertXPath(pLayout, "/root/page[2]/ftncont", 1);
}
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxNotModifiedOnOpen)
+{
+ // tdf#138050: a freshly opened document containing a shape with a text box
+ // should not appear to be modified
+ load(DATA_DIRECTORY, "textbox-phantom-change.docx");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+
+ // Without the fix in place this test would have shown that the document
+ // was modified due to a fix to tdf#135198
+ CPPUNIT_ASSERT(!pDoc->getIDocumentState().IsModified());
+}
+
CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxAutoGrowVertical)
{
load(DATA_DIRECTORY, "textbox-autogrow-vertical.docx");
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index f932e9739800..3ed3e2b6bc24 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1018,7 +1018,7 @@ DECLARE_OOXMLIMPORT_TEST(textboxWpsOnly, "textbox-wps-only.docx")
if ( nsScreen.frame.size.width * scaleFactor > 4000 )
return;
#endif
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2805), getProperty<sal_Int32>(xFrame, "VertOrientPosition"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5304), getProperty<sal_Int32>(xFrame, "VertOrientPosition"));
}
DECLARE_OOXMLIMPORT_TEST(testGroupshapeRelsize, "groupshape-relsize.docx")
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index ad672260a834..050c041b92c5 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -50,6 +50,8 @@
#include <unodraw.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentLayoutAccess.hxx>
+#include <IDocumentState.hxx>
+#include <IDocumentUndoRedo.hxx>
#include <doc.hxx>
#include <hints.hxx>
#include <txtfrm.hxx>
@@ -1261,7 +1263,6 @@ void SwDrawContact::Changed_( const SdrObject& rObj,
const SwFormatVertOrient& rVert = GetFormat()->GetVertOrient();
if ( nYPosDiff != 0 )
{
-
if ( rVert.GetRelationOrient() == text::RelOrientation::CHAR ||
rVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
{
@@ -1314,6 +1315,32 @@ void SwDrawContact::Changed_( const SdrObject& rObj,
// may affect the size of the underlying textbox.
lcl_textBoxSizeNotify(GetFormat());
}
+
+ // tdf#135198: keep text box together with its shape
+ SwRect aObjRect(rObj.GetSnapRect());
+ const SwPageFrame* rPageFrame = pAnchoredDrawObj->GetPageFrame();
+ if (rPageFrame && rPageFrame->isFrameAreaPositionValid())
+ {
+ SwDoc* const pDoc = GetFormat()->GetDoc();
+
+ // avoid Undo creation
+ ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
+
+ // hide any artificial "changes" made by synchronizing the textbox position
+ const bool bEnableSetModified = pDoc->getIDocumentState().IsEnableSetModified();
+ pDoc->getIDocumentState().SetEnableSetModified(false);
+
+ SfxItemSet aSyncSet(pDoc->GetAttrPool(),
+ svl::Items<RES_VERT_ORIENT, RES_ANCHOR>{});
+ aSyncSet.Put(SwFormatVertOrient(aObjRect.Top() - rPageFrame->getFrameArea().Top(),
+ text::VertOrientation::NONE,
+ text::RelOrientation::PAGE_FRAME));
+ aSyncSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, pAnchoredDrawObj->GetPageFrame()->GetPhyPageNum()));
+
+ SwTextBoxHelper::syncFlyFrameAttr(*GetFormat(), aSyncSet);
+
+ pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified);
+ }
}
break;
case SdrUserCallType::ChangeAttr:
More information about the Libreoffice-commits
mailing list