[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - 5 commits - filter/source include/unotools include/vcl officecfg/registry sw/inc sw/source sw/uiconfig unotools/source vcl/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed May 31 14:19:19 UTC 2017
filter/source/pdf/pdfexport.cxx | 8 +-
include/unotools/compatibility.hxx | 7 +
include/vcl/pdfwriter.hxx | 2
officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs | 6 +
sw/inc/viewsh.hxx | 2
sw/source/core/doc/notxtfrm.cxx | 3
sw/source/core/inc/frmtool.hxx | 2
sw/source/core/layout/paintfrm.cxx | 38 +++++++---
sw/source/core/view/viewsh.cxx | 6 +
sw/source/ui/config/optcomp.cxx | 29 +++++--
sw/uiconfig/swriter/ui/optcompatpage.ui | 1
unotools/source/config/compatibility.cxx | 24 ++++--
vcl/source/gdi/pdfwriter.cxx | 2
vcl/source/gdi/pdfwriter_impl.cxx | 4 -
vcl/source/gdi/pdfwriter_impl.hxx | 10 +-
15 files changed, 104 insertions(+), 40 deletions(-)
New commits:
commit 115577b1c3cf42f4831d79be41f512fa21383832
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri May 26 18:13:54 2017 +0200
tdf#108056 sw: add UI to disable SubtractFlysAnchoredAtFlys compat option
There is a reason this is off by default, make it a bit more easier for
users to not depend this option when they don't actually need it.
(cherry picked from commit f85ded43446b17fbfdd868cc057ba39666d3d7cb)
Conflicts:
include/unotools/compatibility.hxx
officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
sw/inc/viewsh.hxx
sw/source/ui/config/optcomp.cxx
sw/uiconfig/swriter/ui/optcompatpage.ui
unotools/source/config/compatibility.cxx
Change-Id: I21c5b942c6021fa21840779e1a9f53055fbf279f
Reviewed-on: https://gerrit.libreoffice.org/38081
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/include/unotools/compatibility.hxx b/include/unotools/compatibility.hxx
index 229190c42415..8f4ce5a2ee12 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -40,7 +40,8 @@ enum CompatibilityOptions
COPT_USE_OUR_TEXTWRAPPING,
COPT_CONSIDER_WRAPPINGSTYLE,
COPT_EXPAND_WORDSPACE,
- COPT_PROTECT_FORM
+ COPT_PROTECT_FORM,
+ COPT_SUBTRACT_FLYS_ANCHORED_AT_FLYS
};
/*-************************************************************************************************************
@@ -61,6 +62,7 @@ enum CompatibilityOptions
#define COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE "ConsiderWrappingStyle"
#define COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE "ExpandWordSpace"
#define COMPATIBILITY_PROPERTYNAME_PROTECTFORM "ProtectForm"
+#define COMPATIBILITY_PROPERTYNAME_SUBTRACT_FLYS_ANCHORED_AT_FLYS "SubtractFlysAnchoredAtFlys"
#define COMPATIBILITY_DEFAULT_NAME "_default"
@@ -132,7 +134,8 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions: public utl::detail::Options
bool bUseOurTextWrapping,
bool bConsiderWrappingStyle,
bool bExpandWordSpace,
- bool bProtectForm );
+ bool bProtectForm,
+ bool bSubtractFlysAnchoredAtFlys );
bool IsUsePrtDevice() const;
bool IsAddSpacing() const;
diff --git a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
index 12179ba285d1..365f282d85b7 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
@@ -104,6 +104,12 @@
</info>
<value>true</value>
</prop>
+ <prop oor:name="SubtractFlysAnchoredAtFlys" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Use LibreOffice 4.3 anchoring paint order</desc>
+ </info>
+ <value>false</value>
+ </prop>
</group>
</templates>
<component>
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 1d5a34b6c343..7dc28460c20a 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -416,6 +416,8 @@ public:
void SetProtectForm( bool _bProtectForm );
+ void SetSubtractFlysAnchoredAtFlys(bool bSubtractFlysAnchoredAtFlys);
+
// DOCUMENT COMPATIBILITY FLAGS END
// Calls Idle-formatter of Layout.
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 8e05c85e7653..923ed6205876 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -899,6 +899,12 @@ void SwViewShell::SetProtectForm( bool _bProtectForm )
}
+void SwViewShell::SetSubtractFlysAnchoredAtFlys(bool bSubtractFlysAnchoredAtFlys)
+{
+ IDocumentSettingAccess& rIDSA = getIDocumentSettingAccess();
+ rIDSA.set(DocumentSettingId::SUBTRACT_FLYS, bSubtractFlysAnchoredAtFlys);
+}
+
void SwViewShell::Reformat()
{
SwWait aWait( *GetDoc()->GetDocShell(), true );
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 2e72a027984b..65c826fd62ed 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -57,13 +57,14 @@ struct CompatibilityItem
bool m_bConsiderWrappingStyle;
bool m_bExpandWordSpace;
bool m_bProtectForm;
+ bool m_bSubtractFlysAnchoredAtFlys;
bool m_bIsDefault;
CompatibilityItem( const OUString& _rName, const OUString& _rModule,
bool _bUsePrtMetrics, bool _bAddSpacing, bool _bAddSpacingAtPages,
bool _bUseOurTabStops, bool _bNoExtLeading, bool _bUseLineSpacing,
bool _bAddTableSpacing, bool _bUseObjPos, bool _bUseOurTextWrapping,
- bool _bConsiderWrappingStyle, bool _bExpandWordSpace, bool _bProtectForm,
+ bool _bConsiderWrappingStyle, bool _bExpandWordSpace, bool _bProtectForm, bool _bSubtractFlysAnchoredAtFlys,
bool _bIsDefault ) :
m_sName ( _rName ),
@@ -80,6 +81,7 @@ struct CompatibilityItem
m_bConsiderWrappingStyle( _bConsiderWrappingStyle ),
m_bExpandWordSpace ( _bExpandWordSpace ),
m_bProtectForm ( _bProtectForm),
+ m_bSubtractFlysAnchoredAtFlys ( _bSubtractFlysAnchoredAtFlys),
m_bIsDefault ( _bIsDefault ) {}
};
@@ -102,7 +104,7 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt
get(m_pOptionsLB, "options");
get(m_pDefaultPB, "default");
- for (sal_Int32 nId = COPT_USE_PRINTERDEVICE; nId <= COPT_PROTECT_FORM; ++nId)
+ for (sal_Int32 nId = COPT_USE_PRINTERDEVICE; nId <= COPT_SUBTRACT_FLYS_ANCHORED_AT_FLYS; ++nId)
{
const OUString sEntry = m_pFormattingLB->GetEntry(nId);
SvTreeListEntry* pEntry = m_pOptionsLB->SvTreeListBox::InsertEntry( sEntry );
@@ -153,7 +155,8 @@ sal_uLong convertBools2Ulong_Impl
bool _bUseOurTextWrapping,
bool _bConsiderWrappingStyle,
bool _bExpandWordSpace,
- bool _bProtectForm
+ bool _bProtectForm,
+ bool bSubtractFlysAnchoredAtFlys
)
{
sal_uLong nRet = 0;
@@ -194,6 +197,9 @@ sal_uLong convertBools2Ulong_Impl
nSetBit = nSetBit << 1;
if ( _bProtectForm )
nRet |= nSetBit;
+ nSetBit = nSetBit << 1;
+ if (bSubtractFlysAnchoredAtFlys)
+ nRet |= nSetBit;
return nRet;
}
@@ -235,6 +241,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
bool bConsiderWrappingStyle = false;
bool bExpandWordSpace = false;
bool bProtectForm = false;
+ bool bSubtractFlysAnchoredAtFlys = false;
const sal_Int32 nCount = aList.getLength();
for ( sal_Int32 i = 0; i < nCount; ++i )
{
@@ -271,6 +278,8 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
aValue.Value >>= bExpandWordSpace;
else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_PROTECTFORM )
aValue.Value >>= bProtectForm;
+ else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_SUBTRACT_FLYS_ANCHORED_AT_FLYS )
+ aValue.Value >>= bSubtractFlysAnchoredAtFlys;
}
const bool bIsUserEntry = sName == "_user";
@@ -280,7 +289,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
sName, sModule, bUsePrtMetrics, bAddSpacing,
bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
bUseLineSpacing, bAddTableSpacing, bUseObjPos,
- bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace, bProtectForm,
+ bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace, bProtectForm, bSubtractFlysAnchoredAtFlys,
bIsDefaultEntry );
m_pImpl->m_aList.push_back( aItem );
@@ -306,7 +315,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
bUsePrtMetrics, bAddSpacing, bAddSpacingAtPages,
bUseOurTabStops, bNoExtLeading, bUseLineSpacing,
bAddTableSpacing, bUseObjPos, bUseOurTextWrapping,
- bConsiderWrappingStyle, bExpandWordSpace, bProtectForm );
+ bConsiderWrappingStyle, bExpandWordSpace, bProtectForm, bSubtractFlysAnchoredAtFlys );
m_pFormattingLB->SetEntryData( nPos, reinterpret_cast<void*>((sal_IntPtr)nOptions) );
}
@@ -394,7 +403,8 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
rIDocumentSettingAccess.get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING),
rIDocumentSettingAccess.get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION),
!rIDocumentSettingAccess.get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK),
- rIDocumentSettingAccess.get(DocumentSettingId::PROTECT_FORM));
+ rIDocumentSettingAccess.get(DocumentSettingId::PROTECT_FORM),
+ rIDocumentSettingAccess.get( DocumentSettingId::SUBTRACT_FLYS ));
}
return nRet;
}
@@ -410,7 +420,7 @@ void SwCompatibilityOptPage::WriteOptions()
pItem->m_bNoExtLeading, pItem->m_bUseLineSpacing,
pItem->m_bAddTableSpacing, pItem->m_bUseObjPos,
pItem->m_bUseOurTextWrapping, pItem->m_bConsiderWrappingStyle,
- pItem->m_bExpandWordSpace, pItem->m_bProtectForm );
+ pItem->m_bExpandWordSpace, pItem->m_bProtectForm, pItem->m_bSubtractFlysAnchoredAtFlys );
}
VclPtr<SfxTabPage> SwCompatibilityOptPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
@@ -488,6 +498,11 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet* )
m_pWrtShell->SetProtectForm( bChecked );
bModified = true;
}
+ else if ( COPT_SUBTRACT_FLYS_ANCHORED_AT_FLYS == nOption )
+ {
+ m_pWrtShell->SetSubtractFlysAnchoredAtFlys( bChecked );
+ bModified = true;
+ }
}
nSavedOptions = nSavedOptions >> 1;
diff --git a/sw/uiconfig/swriter/ui/optcompatpage.ui b/sw/uiconfig/swriter/ui/optcompatpage.ui
index 4ba4e48f1b72..9675da0782be 100644
--- a/sw/uiconfig/swriter/ui/optcompatpage.ui
+++ b/sw/uiconfig/swriter/ui/optcompatpage.ui
@@ -65,6 +65,7 @@
<item translatable="yes">Consider wrapping style when positioning objects</item>
<item translatable="yes">Expand word space on lines with manual line breaks in justified paragraphs</item>
<item translatable="yes">Protect form</item>
+ <item translatable="yes">Use LibreOffice 4.3 anchoring paint order (in current document)</item>
<item translatable="yes"><User settings></item>
</items>
</object>
diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx
index cd86de8b32e8..ef15a7bdfd01 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -57,8 +57,9 @@ using namespace ::com::sun::star::beans;
#define PROPERTYNAME_CONSIDERWRAPSTYLE COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
#define PROPERTYNAME_EXPANDWORDSPACE COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
#define PROPERTYNAME_PROTECTFORM COMPATIBILITY_PROPERTYNAME_PROTECTFORM
+#define PROPERTYNAME_SUBTRACT_FLYS_ANCHORED_AT_FLYS COMPATIBILITY_PROPERTYNAME_SUBTRACT_FLYS_ANCHORED_AT_FLYS
-#define PROPERTYCOUNT 14
+#define PROPERTYCOUNT 15
#define OFFSET_NAME 0
#define OFFSET_MODULE 1
@@ -74,6 +75,7 @@ using namespace ::com::sun::star::beans;
#define OFFSET_CONSIDERWRAPPINGSTYLE 11
#define OFFSET_EXPANDWORDSPACE 12
#define OFFSET_PROTECTFORM 13
+#define OFFSET_SUBTRACT_FLYS_ANCHORED_AT_FLYS 14
// private declarations!
@@ -89,7 +91,7 @@ struct SvtCompatibilityEntry
bNoExtLeading( false ), bUseLineSpacing( false ),
bAddTableSpacing( false ), bUseObjPos( false ),
bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
- bExpandWordSpace( true ), bProtectForm( false ) {}
+ bExpandWordSpace( true ), bProtectForm( false ), bSubtractFlysAnchoredAtFlys(false) {}
SvtCompatibilityEntry(
const OUString& _rName, const OUString& _rNewModule ) :
sName( _rName ), sModule( _rNewModule ),
@@ -98,7 +100,7 @@ struct SvtCompatibilityEntry
bNoExtLeading( false ), bUseLineSpacing( false ),
bAddTableSpacing( false ), bUseObjPos( false ),
bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
- bExpandWordSpace( true ), bProtectForm( false ) {}
+ bExpandWordSpace( true ), bProtectForm( false ), bSubtractFlysAnchoredAtFlys(false) {}
inline void SetUsePrtMetrics( bool _bSet ) { bUsePrtMetrics = _bSet; }
inline void SetAddSpacing( bool _bSet ) { bAddSpacing = _bSet; }
@@ -112,6 +114,7 @@ struct SvtCompatibilityEntry
inline void SetConsiderWrappingStyle( bool _bSet ) { bConsiderWrappingStyle = _bSet; }
inline void SetExpandWordSpace( bool _bSet ) { bExpandWordSpace = _bSet; }
inline void SetProtectForm( bool _bSet ) { bProtectForm = _bSet; }
+ inline void SetSubtractFlysAnchoredAtFlys( bool _bSet ) { bSubtractFlysAnchoredAtFlys = _bSet; }
public:
OUString sName;
@@ -128,6 +131,7 @@ struct SvtCompatibilityEntry
bool bConsiderWrappingStyle;
bool bExpandWordSpace;
bool bProtectForm;
+ bool bSubtractFlysAnchoredAtFlys;
};
/*-****************************************************************************************************************
@@ -261,7 +265,8 @@ class SvtCompatibilityOptions_Impl : public ConfigItem
bool _bUseOurTextWrapping,
bool _bConsiderWrappingStyle,
bool _bExpandWordSpace,
- bool _bProtectForm );
+ bool _bProtectForm,
+ bool _bSubtractFlysAnchoredAtFlys );
inline bool IsUsePrtDevice() const { return m_aDefOptions.bUsePrtMetrics; }
inline bool IsAddSpacing() const { return m_aDefOptions.bAddSpacing; }
@@ -437,6 +442,7 @@ void SvtCompatibilityOptions_Impl::ImplCommit()
lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ].Name = sNode + PROPERTYNAME_CONSIDERWRAPSTYLE;
lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1 ].Name = sNode + PROPERTYNAME_EXPANDWORDSPACE;
lPropertyValues[ OFFSET_PROTECTFORM - 1 ].Name = sNode + PROPERTYNAME_PROTECTFORM;
+ lPropertyValues[ OFFSET_SUBTRACT_FLYS_ANCHORED_AT_FLYS - 1 ].Name = sNode + PROPERTYNAME_SUBTRACT_FLYS_ANCHORED_AT_FLYS;
lPropertyValues[ OFFSET_MODULE - 1 ].Value <<= aItem.sModule;
lPropertyValues[ OFFSET_USEPRTMETRICS - 1 ].Value <<= aItem.bUsePrtMetrics;
@@ -451,6 +457,7 @@ void SvtCompatibilityOptions_Impl::ImplCommit()
lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ].Value <<= aItem.bConsiderWrappingStyle;
lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1 ].Value <<= aItem.bExpandWordSpace;
lPropertyValues[ OFFSET_PROTECTFORM - 1 ].Value <<= aItem.bProtectForm;
+ lPropertyValues[ OFFSET_SUBTRACT_FLYS_ANCHORED_AT_FLYS - 1 ].Value <<= aItem.bSubtractFlysAnchoredAtFlys;
SetSetProperties( SETNODE_ALLFILEFORMATS, lPropertyValues );
}
@@ -488,7 +495,8 @@ void SvtCompatibilityOptions_Impl::AppendItem( const OUString& _sName,
bool _bUseOurTextWrapping,
bool _bConsiderWrappingStyle,
bool _bExpandWordSpace,
- bool _bProtectForm )
+ bool _bProtectForm,
+ bool _bSubtractFlysAnchoredAtFlys )
{
SvtCompatibilityEntry aItem( _sName, _sModule );
aItem.SetUsePrtMetrics( _bUsePrtMetrics );
@@ -503,6 +511,7 @@ void SvtCompatibilityOptions_Impl::AppendItem( const OUString& _sName,
aItem.SetConsiderWrappingStyle( _bConsiderWrappingStyle );
aItem.SetExpandWordSpace( _bExpandWordSpace );
aItem.SetProtectForm( _bProtectForm );
+ aItem.SetSubtractFlysAnchoredAtFlys( _bSubtractFlysAnchoredAtFlys );
m_aOptions.AppendEntry( aItem );
// default item reset?
@@ -631,14 +640,15 @@ void SvtCompatibilityOptions::AppendItem( const OUString& sName,
bool bUseOurTextWrapping,
bool bConsiderWrappingStyle,
bool bExpandWordSpace,
- bool bProtectForm )
+ bool bProtectForm,
+ bool bSubtractFlysAnchoredAtFlys )
{
MutexGuard aGuard( GetOwnStaticMutex() );
m_pImpl->AppendItem(
sName, sModule, bUsePrtMetrics, bAddSpacing,
bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
bUseLineSpacing, bAddTableSpacing, bUseObjPos,
- bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace, bProtectForm );
+ bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace, bProtectForm, bSubtractFlysAnchoredAtFlys );
}
bool SvtCompatibilityOptions::IsUsePrtDevice() const
commit 0a73929a8225227fe540c5920c15382bc61dec61
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri May 26 17:27:15 2017 +0200
tdf#108056 sw SubtractFlys: add missing expansion of the clip path
With this finally the bugdoc has no more unexpected white lines around
the fly frame. In the non-SubtractFlys case DrawFillAttributes() already
did an expansion of the clip path, but this was overwritten in case the
layout flag was set.
Fix the problem by taking care of this in lcl_SubtractFlys() itself.
Change-Id: Iac91279f8bc19588e763425aff5cb800e793da83
Reviewed-on: https://gerrit.libreoffice.org/38079
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 0714d2f3009bbb24501561c1a8e96a6feb9a42ca)
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index a2b9df5e4360..db06709f5969 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1537,6 +1537,21 @@ static void lcl_ExtendLeftAndRight( SwRect& _rRect,
}
}
+/// Returns a range suitable for subtraction when lcl_SubtractFlys() is used.
+/// Otherwise DrawFillAttributes() expands the clip path itself.
+static basegfx::B2DRange lcl_ShrinkFly(const SwRect& rRect)
+{
+ static MapMode aMapMode(MapUnit::MapTwip);
+ static const Size aSingleUnit = Application::GetDefaultDevice()->PixelToLogic(Size(1, 1), aMapMode);
+
+ double x1 = rRect.Left() + aSingleUnit.getWidth();
+ double y1 = rRect.Top() + aSingleUnit.getHeight();
+ double x2 = rRect.Right() - aSingleUnit.getWidth();
+ double y2 = rRect.Bottom() - aSingleUnit.getHeight();
+
+ return basegfx::B2DRange(x1, y1, x2, y2);
+}
+
static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
const SwRect &rRect, SwRegionRects &rRegion, basegfx::tools::B2DClipState& rClipState, SwPaintProperties & rProperties)
{
@@ -1671,7 +1686,7 @@ static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
const SwBorderAttrs &rAttrs = *aAccess.Get();
::lcl_CalcBorderRect( aRect, pFly, rAttrs, true, rProperties );
rRegion -= aRect;
- rClipState.subtractRange(basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()));
+ rClipState.subtractRange(lcl_ShrinkFly(aRect));
continue;
}
else
@@ -1689,14 +1704,14 @@ static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
const SwBorderAttrs &rAttrs = *aAccess.Get();
::lcl_CalcBorderRect( aRect, pFly, rAttrs, true, rProperties );
rRegion -= aRect;
- rClipState.subtractRange(basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()));
+ rClipState.subtractRange(lcl_ShrinkFly(aRect));
}
else
{
SwRect aRect( pFly->Prt() );
aRect += pFly->Frame().Pos();
rRegion -= aRect;
- rClipState.subtractRange(basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()));
+ rClipState.subtractRange(lcl_ShrinkFly(aRect));
}
}
if (gProp.pSRetoucheFly == gProp.pSRetoucheFly2)
commit 096bda90377caa7a3e2a7c52cbbd8553901dfb88
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri May 26 13:54:27 2017 +0200
tdf#108056 sw SubtractFlys: work with a polypolygon directly
In case the intention is that the clip rectangle should include the
page, except a fly frame, we built a list of rectangles that covered
this area. This introduces the problem if adjacent rectangles don't join
perfectly.
Instead allow lcl_SubtractFlys() to work on a clip state directly, this
way the clip polypolygon will only contain two paths (the page rectangle
and the rectangle of the fly), so rounding errors can't happen.
Change-Id: I5b2e9a382aa7d16f3b16509670de754b5e00bd6d
Reviewed-on: https://gerrit.libreoffice.org/38066
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 87d62a6222932d36c91d7b69240c7bccbf4e46be)
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 5ac99b8da9be..aafbdbf04471 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -186,7 +186,8 @@ static void lcl_ClearArea( const SwFrame &rFrame,
if ( rFrame.GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigRect, false ) )
{
SwRegionRects const region(rPtArea);
- const bool bDone(::DrawFillAttributes(aFillAttributes, aOrigRect, region, rOut));
+ basegfx::tools::B2DClipState aClipState;
+ const bool bDone(::DrawFillAttributes(aFillAttributes, aOrigRect, region, aClipState, rOut));
if(!bDone)
{
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index e01595783154..c428e42c2117 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -27,6 +27,7 @@
#include <editeng/lrspitem.hxx>
#include <swfont.hxx>
#include <flyfrm.hxx>
+#include <basegfx/tools/b2dclipstate.hxx>
class SwPageFrame;
class SwFlyFrame;
@@ -68,6 +69,7 @@ bool DrawFillAttributes(
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes,
const SwRect& rOriginalLayoutRect,
const SwRegionRects& rPaintRegion,
+ const basegfx::tools::B2DClipState& rClipState,
OutputDevice& rOut);
void paintGraphicUsingPrimitivesHelper(
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index d8d6cc79340d..a2b9df5e4360 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1538,7 +1538,7 @@ static void lcl_ExtendLeftAndRight( SwRect& _rRect,
}
static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
- const SwRect &rRect, SwRegionRects &rRegion, SwPaintProperties & rProperties)
+ const SwRect &rRect, SwRegionRects &rRegion, basegfx::tools::B2DClipState& rClipState, SwPaintProperties & rProperties)
{
const SwSortedObjs& rObjs = *pPage->GetSortedObjs();
const SwFlyFrame* pSelfFly = pFrame->IsInFly() ? pFrame->FindFlyFrame() : gProp.pSRetoucheFly2;
@@ -1671,6 +1671,7 @@ static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
const SwBorderAttrs &rAttrs = *aAccess.Get();
::lcl_CalcBorderRect( aRect, pFly, rAttrs, true, rProperties );
rRegion -= aRect;
+ rClipState.subtractRange(basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()));
continue;
}
else
@@ -1688,12 +1689,14 @@ static void lcl_SubtractFlys( const SwFrame *pFrame, const SwPageFrame *pPage,
const SwBorderAttrs &rAttrs = *aAccess.Get();
::lcl_CalcBorderRect( aRect, pFly, rAttrs, true, rProperties );
rRegion -= aRect;
+ rClipState.subtractRange(basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()));
}
else
{
SwRect aRect( pFly->Prt() );
aRect += pFly->Frame().Pos();
rRegion -= aRect;
+ rClipState.subtractRange(basegfx::B2DRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()));
}
}
if (gProp.pSRetoucheFly == gProp.pSRetoucheFly2)
@@ -1859,6 +1862,7 @@ bool DrawFillAttributes(
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes,
const SwRect& rOriginalLayoutRect,
const SwRegionRects& rPaintRegion,
+ const basegfx::tools::B2DClipState& rClipState,
vcl::RenderContext& rOut)
{
if(rFillAttributes.get() && rFillAttributes->isUsed())
@@ -1921,18 +1925,7 @@ bool DrawFillAttributes(
// tdf#86578 the awful lcl_SubtractFlys hack
if (rPaintRegion.size() > 1 || rPaintRegion[0] != rPaintRegion.GetOrigin())
{
- tools::PolyPolygon tempRegion;
- for (size_t i = 0; i < rPaintRegion.size(); ++i)
- {
- // Don't use SwRect::SvRect() here, as the clip
- // rectangle is supposed to cover everything outside
- // the flys, so the Width() - 1 isn't correct.
- const SwRect& rRect = rPaintRegion[i];
- tools::Rectangle aRectangle(rRect.Pos().getX(), rRect.Pos().getY(), rRect.Pos().getX() + rRect.SSize().getWidth(), rRect.Pos().getY() + rRect.SSize().getHeight());
- tempRegion.Insert(tools::Polygon(aRectangle));
- }
- basegfx::B2DPolyPolygon const maskRegion( tempRegion.getB2DPolyPolygon());
-
+ basegfx::B2DPolyPolygon const maskRegion(rClipState.getClipPoly());
primitives.resize(1);
primitives[0] = new drawinglayer::primitive2d::MaskPrimitive2D(
maskRegion, rSequence);
@@ -4680,7 +4673,8 @@ void SwFrame::PaintBorderLine( const SwRect& rRect,
pPage->GetFormat()->GetDoc()->getIDocumentSettingAccess().get(DocumentSettingId::SUBTRACT_FLYS))
{
SwRegionRects aRegion( aOut, 4 );
- ::lcl_SubtractFlys( this, pPage, aOut, aRegion, gProp );
+ basegfx::tools::B2DClipState aClipState;
+ ::lcl_SubtractFlys( this, pPage, aOut, aRegion, aClipState, gProp );
for ( size_t i = 0; i < aRegion.size(); ++i )
gProp.pSLines->AddLineRect( aRegion[i], pColor, nStyle, pTab, nSubCol, gProp );
}
@@ -6590,10 +6584,12 @@ void SwFrame::PaintBackground( const SwRect &rRect, const SwPageFrame *pPage,
}
SwRegionRects aRegion( aRect );
+ basegfx::B2DPolygon aB2DPolygon{tools::Polygon(aRect.SVRect()).getB2DPolygon()};
+ basegfx::tools::B2DClipState aClipState{basegfx::B2DPolyPolygon(aB2DPolygon)};
if (pPage->GetSortedObjs() &&
pSh->GetDoc()->getIDocumentSettingAccess().get(DocumentSettingId::SUBTRACT_FLYS))
{
- ::lcl_SubtractFlys( this, pPage, aRect, aRegion, gProp );
+ ::lcl_SubtractFlys( this, pPage, aRect, aRegion, aClipState, gProp );
}
// OD 06.08.2002 #99657# - determine, if background transparency
@@ -6610,7 +6606,7 @@ void SwFrame::PaintBackground( const SwRect &rRect, const SwPageFrame *pPage,
if(aFillAttributes->isUsed())
{
// check if really something is painted
- bDone = DrawFillAttributes(aFillAttributes, aOrigBackRect, aRegion, *pOut);
+ bDone = DrawFillAttributes(aFillAttributes, aOrigBackRect, aRegion, aClipState, *pOut);
}
if(!bDone)
commit 50f309b15f4f47cb357fff04503390f65ae08de1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu May 25 16:37:04 2017 +0200
tdf#108056 PDF export: work with double page size
Our coordinate system has the origo in the top left corner, PDF's one is
at the bottom left corner. So the page height affects the coordinate of
all widths and y positions. That page width is 870.25 in the case of the
bugdoc, but it was handled as 870 due to the integer rounding. The
coordinates and heights are now closer to the expected ones.
(cherry picked from commit a05dc747caf5b8fef6bd95a999cb6098f2b4dbc7)
Conflicts:
include/vcl/pdfwriter.hxx
Change-Id: I9c7d77298df3850bbc170c9ace18120900d7e3fa
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index e62fc108c86c..e75a52f9c228 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -1018,12 +1018,14 @@ void PDFExport::showErrors( const std::set< vcl::PDFWriter::ErrorCode >& rErrors
bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData& rPDFExtOutDevData, const GDIMetaFile& rMtf )
{
- const Size aSizePDF( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MapUnit::MapPoint ) );
+ basegfx::B2DPolygon aSize(tools::Polygon(Rectangle(Point(0, 0), rMtf.GetPrefSize())).getB2DPolygon());
+ basegfx::B2DPolygon aSizePDF(OutputDevice::LogicToLogic(aSize, rMtf.GetPrefMapMode(), MapUnit::MapPoint));
+ basegfx::B2DRange aRangePDF(aSizePDF.getB2DRange());
Point aOrigin;
Rectangle aPageRect( aOrigin, rMtf.GetPrefSize() );
bool bRet = true;
- rWriter.NewPage( aSizePDF.Width(), aSizePDF.Height() );
+ rWriter.NewPage( aRangePDF.getWidth(), aRangePDF.getHeight() );
rWriter.SetMapMode( rMtf.GetPrefMapMode() );
vcl::PDFWriter::PlayMetafileContext aCtx;
@@ -1051,7 +1053,7 @@ bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData&
rPDFExtOutDevData.ResetSyncData();
if (!msWatermark.isEmpty())
- ImplWriteWatermark( rWriter, aSizePDF );
+ ImplWriteWatermark( rWriter, Size(aRangePDF.getWidth(), aRangePDF.getHeight()) );
return bRet;
}
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index f4dba18efc84..5f1e45f6cfff 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -693,7 +693,7 @@ The following structure describes the permissions used in PDF security
Colors and other state information MUST
be set again or are undefined.
*/
- void NewPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, Orientation eOrientation = Inherit );
+ void NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation = Inherit );
/** Play a metafile like an outputdevice would do
*/
struct PlayMetafileContext
diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx
index d54a327e5f4c..410c672c9438 100644
--- a/vcl/source/gdi/pdfwriter.cxx
+++ b/vcl/source/gdi/pdfwriter.cxx
@@ -53,7 +53,7 @@ OutputDevice* PDFWriter::GetReferenceDevice()
return xImplementation->getReferenceDevice();
}
-void PDFWriter::NewPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, Orientation eOrientation )
+void PDFWriter::NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation )
{
xImplementation->newPage( nPageWidth, nPageHeight, eOrientation );
}
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 8c3575cdca14..c7eaa00c90b6 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1117,7 +1117,7 @@ void PDFWriterImpl::ResourceDict::append( OStringBuffer& rBuf, sal_Int32 nFontDi
rBuf.append( "]\n>>\n" );
};
-PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation )
+PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation )
:
m_pWriter( pWriter ),
m_nPageWidth( nPageWidth ),
@@ -2267,7 +2267,7 @@ LogicalFontInstance* PdfBuiltinFontFace::CreateFontInstance( FontSelectPattern&
}
-void PDFWriterImpl::newPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation )
+void PDFWriterImpl::newPage( double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation )
{
endPage();
m_nCurrentPage = m_aPages.size();
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index e1750ab8b73b..01b7bb76963a 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -116,8 +116,8 @@ public:
struct PDFPage
{
PDFWriterImpl* m_pWriter;
- sal_Int32 m_nPageWidth; // in inch/72
- sal_Int32 m_nPageHeight; // in inch/72
+ double m_nPageWidth; // in inch/72
+ double m_nPageHeight; // in inch/72
PDFWriter::Orientation m_eOrientation;
sal_Int32 m_nPageObject;
sal_Int32 m_nPageIndex;
@@ -131,7 +131,7 @@ public:
sal_uInt32 m_nDuration;
bool m_bHasWidgets;
- PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
+ PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation );
~PDFPage();
void beginStream();
@@ -172,7 +172,7 @@ public:
// appends a horizontal waveline with vertical offset (helper for drawWaveLine)
void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer& rBuffer ) const;
- sal_Int32 getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; }
+ double getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; }
};
friend struct PDFPage;
@@ -1089,7 +1089,7 @@ public:
OutputDevice* getReferenceDevice();
/* document structure */
- void newPage( sal_Int32 nPageWidth , sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
+ void newPage( double nPageWidth , double nPageHeight, PDFWriter::Orientation eOrientation );
bool emit();
const std::set< PDFWriter::ErrorCode > & getErrors() const { return m_aErrors;}
void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); }
commit ba3f665270006ced34292cd47eabe771a4878869
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu May 25 10:27:47 2017 +0200
tdf#108056 sw SubtractFlys: fix off-by-one error in clip rectangle calculation
See commit c5cf8824a619401627f18abc7b3049551c71ac2a (tdf#86578: sw: fix
rendering of legacy documents with fly anchored at fly, 2015-04-10) for
the context, this fixes the vertical unexpected thin white lines of the
bugdoc.
Change-Id: I5bb0536e84a8486440748ac9ebb24b22344cc03f
Reviewed-on: https://gerrit.libreoffice.org/38015
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit e6bdcfb8e0bdd456f81d4391df355a76be13afd3)
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index ba8fdc916207..d8d6cc79340d 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1924,7 +1924,12 @@ bool DrawFillAttributes(
tools::PolyPolygon tempRegion;
for (size_t i = 0; i < rPaintRegion.size(); ++i)
{
- tempRegion.Insert( tools::Polygon(rPaintRegion[i].SVRect()));
+ // Don't use SwRect::SvRect() here, as the clip
+ // rectangle is supposed to cover everything outside
+ // the flys, so the Width() - 1 isn't correct.
+ const SwRect& rRect = rPaintRegion[i];
+ tools::Rectangle aRectangle(rRect.Pos().getX(), rRect.Pos().getY(), rRect.Pos().getX() + rRect.SSize().getWidth(), rRect.Pos().getY() + rRect.SSize().getHeight());
+ tempRegion.Insert(tools::Polygon(aRectangle));
}
basegfx::B2DPolyPolygon const maskRegion( tempRegion.getB2DPolyPolygon());
More information about the Libreoffice-commits
mailing list