summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Bakos <bakos.attilakaroly@nisz.hu>2020-08-06 13:49:43 +0200
committerGabor Kelemen <kelemen.gabor2@nisz.hu>2020-10-14 10:17:49 +0200
commit2db4b25cccd32cb69fe256f913d0a95878cd42bb (patch)
tree79069a84919d5b23ce9d3145c374f623c68e66d0
parentcb239773b8f574cb08a82908bb32cc3f7a16e308 (diff)
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit b6850bbe95418ecfde404be1696548f18d200c9b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104161 Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r--sw/inc/anchoredobject.hxx6
-rw-r--r--sw/qa/extras/layout/data/tdf106153.docxbin0 -> 10461 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx29
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport8.cxx11
-rw-r--r--sw/source/core/draw/dflyobj.cxx2
-rw-r--r--sw/source/core/layout/anchoredobject.cxx9
-rw-r--r--sw/source/core/layout/flylay.cxx2
-rw-r--r--sw/source/core/objectpositioning/anchoredobjectposition.cxx36
8 files changed, 54 insertions, 41 deletions
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 <mbTmpConsiderWrapInfluence>
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 000000000000..cba072360d4c
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf106153.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index b8272d9bc514..9a657ff3f8fd 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -1158,6 +1158,35 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf134277)
xmlXPathNodeSetGetLength(pXmlNodes));
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106153)
+{
+ load(DATA_DIRECTORY, "tdf106153.docx");
+ xmlDocPtr 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)
{
loadURL("private:factory/swriter", nullptr);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index b60a20cbd2eb..bac79320a5dc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -488,17 +488,6 @@ DECLARE_OOXMLEXPORT_TEST(testTDF91122, "tdf91122.docx")
}
}
-DECLARE_OOXMLEXPORT_TEST(testTDF91260, "tdf91260.docx")
-{
- /*
- * textbox can't extend beyond the page bottom
- * solution: shrinking textbox (its text frame) height, if needed
- */
- uno::Reference<text::XTextRange> xFrame(getShape(1), uno::UNO_QUERY);
- CPPUNIT_ASSERT(xFrame->getString().startsWith( "Lorem ipsum" ) );
- CPPUNIT_ASSERT_EQUAL(sal_Int32(3454), getProperty<sal_Int32>(xFrame, "Height"));
-}
-
DECLARE_OOXMLEXPORT_TEST(testFdo74357, "fdo74357.docx")
{
// Floating table wasn't converted to a textframe.
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index e21f3f35b992..1c14e3f8edaf 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -527,7 +527,7 @@ void SwVirtFlyDrawObj::wrap_DoPaintObject(
RestoreMapMode aRestoreMapModeIfNeeded( pShell );
// paint the FlyFrame (use standard VCL-Paint)
- m_pFlyFrame->PaintSwFrame( *pShell->GetOut(), GetFlyFrame()->getFrameArea() );
+ m_pFlyFrame->PaintSwFrame( *pShell->GetOut(), m_pFlyFrame->GetPageFrame()->getFrameArea());
}
}
}
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index 0914fad4d1c7..e475a4c0a19a 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -737,6 +737,15 @@ bool SwAnchoredObject::IsFormatPossible() const
return GetFrameFormat().GetDoc()->getIDocumentDrawModelAccess().IsVisibleLayerId( GetDrawObj()->GetLayer() );
}
+bool SwAnchoredObject::IsDraggingOffPageAllowed(const SwFrameFormat* pFrameFormat)
+{
+ OSL_ASSERT(pFrameFormat);
+ const bool bDisablePositioning = pFrameFormat->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING);
+ const bool bIsWrapThrough = pFrameFormat->GetSurround().GetSurround() == text::WrapTextMode::WrapTextMode_THROUGH;
+
+ return bDisablePositioning && bIsWrapThrough;
+}
+
// --> #i3317#
void SwAnchoredObject::SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrapInfluence )
{
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 4a7030ea241e..756df25a7b8c 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -493,7 +493,7 @@ void SwFlyFreeFrame::CheckClip( const SwFormatFrameSize &rSz )
const bool bBot = nBot > nClipBot;
const bool bRig = nRig > nClipRig;
- if ( bBot || bRig )
+ if (( bBot || bRig ) && !IsDraggingOffPageAllowed(FindFrameFormat(GetDrawObj())))
{
bool bAgain = false;
// #i37068# - no move, if it's requested
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index ad3f7cd8ee46..6935714e7c82 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -39,6 +39,7 @@
#include <IDocumentSettingAccess.hxx>
#include <textboxhelper.hxx>
#include <fmtsrnd.hxx>
+#include <svx/sdtagitm.hxx>
using namespace ::com::sun::star;
using namespace objectpositioning;
@@ -408,9 +409,10 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch
const bool bCheckBottom ) const
{
SwTwips nAdjustedRelPosY = nProposedRelPosY;
+ if (SwAnchoredObject::IsDraggingOffPageAllowed(FindFrameFormat(&mrDrawObj)))
+ return nAdjustedRelPosY;
- const Size aObjSize( GetAnchoredObj().GetObjRect().SSize() );
-
+ const Size aObjSize(GetAnchoredObj().GetObjRect().SSize());
// determine the area of 'page' alignment frame, to which the vertical
// position is restricted.
// #i28701# - Extend restricted area for the vertical
@@ -459,8 +461,7 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch
// tdf#112443 if position is completely off-page
// return the proposed position and do not adjust it...
// tdf#120839 .. unless anchored to char (anchor can jump on other page)
- bool bDisablePositioning = mpFrameFormat->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING);
-
+ const bool bDisablePositioning = mpFrameFormat->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING);
if ( bDisablePositioning && !IsAnchoredToChar() && nTopOfAnch + nAdjustedRelPosY > aPgAlignArea.Right() )
{
return nProposedRelPosY;
@@ -509,30 +510,6 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch
{
nAdjustedRelPosY = aPgAlignArea.Top() - nTopOfAnch;
}
-
- // tdf#91260 - allow textboxes extending beyond the page bottom
- // tdf#101627 - the patch a4dee94afed9ade6ac50237c8d99a6e49d3bebc1
- // for tdf#91260 causes problems if the textbox
- // is anchored in the footer, so exclude this case
- if ( !( GetAnchorFrame().GetUpper() && GetAnchorFrame().GetUpper()->IsFooterFrame() )
- && nAdjustedRelPosY < nProposedRelPosY )
- {
- const SwFrameFormat* pFormat = &(GetFrameFormat());
- if ( GetObject().IsTextBox() )
- {
- // shrink textboxes to extend beyond the page bottom
- SwFrameFormat* pFrameFormat = ::FindFrameFormat(&GetObject());
- SwFormatFrameSize aSize(pFormat->GetFrameSize());
- SwTwips nShrinked = aSize.GetHeight() - (nProposedRelPosY - nAdjustedRelPosY);
- if (nShrinked >= 0) {
- aSize.SetHeight( nShrinked );
- pFrameFormat->SetFormatAttr(aSize);
- }
- nAdjustedRelPosY = nProposedRelPosY;
- } else if ( SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT) )
- // when the shape has a textbox, use only the proposed vertical position
- nAdjustedRelPosY = nProposedRelPosY;
- }
}
return nAdjustedRelPosY;
}
@@ -548,6 +525,9 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustHoriRelPos(
{
SwTwips nAdjustedRelPosX = _nProposedRelPosX;
+ if (SwAnchoredObject::IsDraggingOffPageAllowed(FindFrameFormat(&mrDrawObj)))
+ return nAdjustedRelPosX;
+
const SwFrame& rAnchorFrame = GetAnchorFrame();
const bool bVert = rAnchorFrame.IsVertical();