[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa sw/source
Daniel Arato (NISZ) (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 26 15:40:23 UTC 2020
sw/qa/core/layout/data/textbox-phantom-change.docx |binary
sw/qa/core/layout/layout.cxx | 14 ++++++++
sw/source/core/draw/dcontact.cxx | 29 +++++++++++++++++-
sw/source/core/layout/objectformattertxtfrm.cxx | 33 ---------------------
4 files changed, 42 insertions(+), 34 deletions(-)
New commits:
commit cc04f0b6ff5a5e35cfc9dea1a98ea27b0efe6d5d
Author: Daniel Arato (NISZ) <arato.daniel at nisz.hu>
AuthorDate: Mon Nov 16 11:53:47 2020 +0100
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Nov 26 16:39:46 2020 +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/+/106681
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
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 15f2c4edb846..2151b870da13 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -16,6 +16,7 @@
#include <unotxdoc.hxx>
#include <drawdoc.hxx>
#include <IDocumentDrawModelAccess.hxx>
+#include <IDocumentState.hxx>
#include <svx/svdpage.hxx>
char const DATA_DIRECTORY[] = "/sw/qa/core/layout/data/";
@@ -180,6 +181,19 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTextBoxStaysInsideShape)
assertXPath(pXmlDoc, "//fly/infos/bounds", "bottom", "7184");
}
+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/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 8707bcbaeb84..bece3f460079 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>
@@ -1262,7 +1264,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 )
{
@@ -1315,6 +1316,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:
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx
index 85313839f889..bf066909251f 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -345,39 +345,6 @@ bool SwObjectFormatterTextFrame::DoFormatObjs()
( !mrAnchorTextFrame.IsFollow() &&
AtLeastOneObjIsTmpConsiderWrapInfluence() ) ) )
{
- // tdf#135198: force text box to stay inside shape after layout changes
- if (SwSortedObjs* pDrawObjs = mrAnchorTextFrame.GetDrawObjs())
- {
- // N.B.: avoid using ranged for because the iterator might get invalidated
- for (size_t i = 0; i < pDrawObjs->size(); ++i)
- {
- SwAnchoredObject* const pObj = (*pDrawObjs)[i];
- SwFrameFormat& rFormat = pObj->GetFrameFormat();
- if (SwTextBoxHelper::isTextBox(&rFormat, RES_DRAWFRMFMT))
- {
- if (const SwPageFrame* pPageFrame = pObj->GetPageFrame())
- {
- SwDoc* pDoc = rFormat.GetDoc();
-
- // avoid Undo creation,
- ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
-
- SfxItemSet aSet(pDoc->GetAttrPool(),
- svl::Items<RES_VERT_ORIENT, RES_ANCHOR>{});
-
- const SwRect& rPageFrameArea = pPageFrame->getFrameArea();
- aSet.Put(SwFormatVertOrient(pObj->GetObjRect().Top() - rPageFrameArea.Top(),
- text::VertOrientation::NONE,
- text::RelOrientation::PAGE_FRAME));
-
- aSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, pObj->GetPageFrame()->GetPhyPageNum()));
-
- SwTextBoxHelper::syncFlyFrameAttr(rFormat, aSet);
- }
- }
- }
- }
-
const bool bDoesAnchorHadPrev = ( mrAnchorTextFrame.GetIndPrev() != nullptr );
// Format anchor text frame after its objects are formatted.
More information about the Libreoffice-commits
mailing list