summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorPatrick Jaap <patrick.jaap@tu-dresden.de>2017-11-29 12:41:33 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-01-04 10:18:37 +0100
commit529924a29ce6f688337f91de9dcf1aa9869e91ad (patch)
treeb474f361529914bcf7a922987c87fb08f5315334 /sw/source/core
parent83e9a46615089de6979c950a2b62e0464e93e486 (diff)
tdf#112443 disable off-page content positioning
Disable the positioning for objects that are completely off-page. During import, LO writer forces content always back to the page and causes unwanted content on the page in constrast to MSO. To achive this the top/left position of the content is compared to the bottom/right border of the clipping region. A new compatibility flag OFF_PAGE_POSITIONING is introduced for legacy rendering of legacy documents. A unit test demonstrates the issue. It resolves tdf#112443. Change-Id: I263c129f9f09ed909ad777a34f8b9ffc84d871e4 Reviewed-on: https://gerrit.libreoffice.org/43313 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit 8d62b79f168180c6992eb483ec864d473050635f) Reviewed-on: https://gerrit.libreoffice.org/47260
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx7
-rw-r--r--sw/source/core/inc/DocumentSettingManager.hxx1
-rw-r--r--sw/source/core/layout/flylay.cxx6
-rw-r--r--sw/source/core/objectpositioning/anchoredobjectposition.cxx18
4 files changed, 31 insertions, 1 deletions
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 47c513e1486e..77de92017537 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -87,7 +87,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbPropLineSpacingShrinksFirstLine(true),
mbSubtractFlys(false),
mApplyParagraphMarkFormatToNumbering(false),
- mbLastBrowseMode( false )
+ mbLastBrowseMode( false ),
+ mbDisableOffPagePositioning ( false )
// COMPATIBILITY FLAGS END
{
@@ -202,6 +203,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
case DocumentSettingId::EMBED_FONTS: return mEmbedFonts;
case DocumentSettingId::EMBED_SYSTEM_FONTS: return mEmbedSystemFonts;
case DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: return mApplyParagraphMarkFormatToNumbering;
+ case DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING: return mbDisableOffPagePositioning;
default:
OSL_FAIL("Invalid setting id");
}
@@ -416,6 +418,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
case DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING:
mApplyParagraphMarkFormatToNumbering = value;
break;
+ case DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING:
+ mbDisableOffPagePositioning = value;
+ break;
default:
OSL_FAIL("Invalid setting id");
}
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index 81dca8d42780..5f762d099ca8 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -154,6 +154,7 @@ class DocumentSettingManager :
bool mApplyParagraphMarkFormatToNumbering;
bool mbLastBrowseMode : 1;
+ bool mbDisableOffPagePositioning; // tdf#112443
public:
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 42e488a6b1b3..8a3af6c27006 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -495,6 +495,9 @@ void SwFlyFreeFrame::CheckClip( const SwFormatFrameSize &rSz )
{
const long nOld = getFrameArea().Top();
+ // tdf#112443 disable positioning if content is completely off page
+ bool bDisableOffPagePositioning = GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING);
+ if ( !bDisableOffPagePositioning || nOld <= nClipBot)
{
SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
aFrm.Pos().Y() = std::max( aClip.Top(), nClipBot - aFrm.Height() );
@@ -512,6 +515,9 @@ void SwFlyFreeFrame::CheckClip( const SwFormatFrameSize &rSz )
{
const long nOld = getFrameArea().Left();
+ // tdf#112443 disable positioning if content is completely off page
+ bool bDisableOffPagePositioning = GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING);
+ if ( !bDisableOffPagePositioning || nOld <= nClipRig )
{
SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
aFrm.Pos().X() = std::max( aClip.Left(), nClipRig - aFrm.Width() );
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 0e7ec2e72ce0..94afc9ddc38d 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -455,6 +455,15 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch
}
else
{
+ /// tdf#112443 if position is completely off-page
+ // return the proposed position and do not adjust it.
+ bool bDisablePositioning = mpFrameFormat->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING);
+
+ if ( bDisablePositioning && nTopOfAnch + nAdjustedRelPosY > aPgAlignArea.Right() )
+ {
+ return nProposedRelPosY;
+ }
+
if ( bCheckBottom &&
nTopOfAnch + nAdjustedRelPosY + aObjSize.Width() >
aPgAlignArea.Right() )
@@ -471,6 +480,15 @@ SwTwips SwAnchoredObjectPosition::ImplAdjustVertRelPos( const SwTwips nTopOfAnch
}
else
{
+ // tdf#112443 if position is completely off-page
+ // return the proposed position and do not adjust it.
+ bool bDisablePositioning = mpFrameFormat->getIDocumentSettingAccess().get(DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING);
+
+ if ( bDisablePositioning && nTopOfAnch + nAdjustedRelPosY > aPgAlignArea.Bottom() )
+ {
+ return nProposedRelPosY;
+ }
+
// #i31805# - consider value of <bCheckBottom>
if ( bCheckBottom &&
nTopOfAnch + nAdjustedRelPosY + aObjSize.Height() >