[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - 3 commits - include/unotools officecfg/registry sw/inc sw/source sw/uiconfig unotools/source

Miklos Vajna vmiklos at collabora.co.uk
Wed May 31 11:44:05 UTC 2017


 include/unotools/compatibility.hxx                                |    1 
 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                                |   43 ++++++----
 sw/source/core/view/viewsh.cxx                                    |    6 +
 sw/source/ui/config/optcomp.cxx                                   |   16 +++
 sw/uiconfig/swriter/ui/optcompatpage.ui                           |    1 
 unotools/source/config/compatibility.cxx                          |    4 
 10 files changed, 63 insertions(+), 21 deletions(-)

New commits:
commit 4900b5c3516c5144f5ce31bc112cadc71e5a5afe
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.
    
    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>
    (cherry picked from commit f85ded43446b17fbfdd868cc057ba39666d3d7cb)
    Reviewed-on: https://gerrit.libreoffice.org/38263

diff --git a/include/unotools/compatibility.hxx b/include/unotools/compatibility.hxx
index defbabdf8563..5a4e2f7922ef 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -59,6 +59,7 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityEntry
             ExpandWordSpace,
             ProtectForm,
             MsWordTrailingBlanks,
+            SubtractFlysAnchoredAtFlys,
 
             /* Should be at the end. Do not remove it. */
             INVALID
diff --git a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
index 90394f22dafe..f71c66205871 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
@@ -116,6 +116,12 @@
         </info>
         <value>false</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 17fe5f6f2c9f..1678e26eea3e 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -418,6 +418,8 @@ public:
 
     void SetMsWordCompTrailingBlanks( bool _bMsWordCompTrailingBlanks );
 
+    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 8ce4de7d028c..7cbcd8b4a689 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -917,6 +917,12 @@ void SwViewShell::SetMsWordCompTrailingBlanks( bool _bMsWordCompTrailingBlanks )
     }
 }
 
+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 3dc5d377ace0..4feaf12b3684 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -114,7 +114,8 @@ sal_uLong convertBools2Ulong_Impl
     bool _bConsiderWrappingStyle,
     bool _bExpandWordSpace,
     bool _bProtectForm,
-    bool _bMsWordCompTrailingBlanks
+    bool _bMsWordCompTrailingBlanks,
+    bool bSubtractFlysAnchoredAtFlys
 )
 {
     sal_uLong nRet = 0;
@@ -158,6 +159,9 @@ sal_uLong convertBools2Ulong_Impl
     nSetBit = nSetBit << 1;
     if ( _bMsWordCompTrailingBlanks )
         nRet |= nSetBit;
+    nSetBit = nSetBit << 1;
+    if (bSubtractFlysAnchoredAtFlys)
+        nRet |= nSetBit;
 
     return nRet;
 }
@@ -241,7 +245,8 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
             aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ConsiderWrappingStyle ),
             aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ExpandWordSpace ),
             aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ProtectForm ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::MsWordTrailingBlanks ) );
+            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::MsWordTrailingBlanks ),
+            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::SubtractFlysAnchoredAtFlys ) );
         m_pFormattingLB->SetEntryData( nPos, reinterpret_cast<void*>((sal_IntPtr)nOptions) );
     }
 
@@ -313,7 +318,8 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
             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::MS_WORD_COMP_TRAILING_BLANKS ) );
+            rIDocumentSettingAccess.get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ),
+            rIDocumentSettingAccess.get( DocumentSettingId::SUBTRACT_FLYS ) );
     }
     return nRet;
 }
@@ -401,6 +407,10 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet*  )
                         m_pWrtShell->SetMsWordCompTrailingBlanks( bChecked );
                         break;
 
+                    case SvtCompatibilityEntry::Index::SubtractFlysAnchoredAtFlys:
+                        m_pWrtShell->SetSubtractFlysAnchoredAtFlys(bChecked);
+                        break;
+
                     default:
                         break;
                 }
diff --git a/sw/uiconfig/swriter/ui/optcompatpage.ui b/sw/uiconfig/swriter/ui/optcompatpage.ui
index 3c2eb9330dae..c391925553bf 100644
--- a/sw/uiconfig/swriter/ui/optcompatpage.ui
+++ b/sw/uiconfig/swriter/ui/optcompatpage.ui
@@ -66,6 +66,7 @@
                       <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">MS Word-compatible trailing blanks</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 91b3e53e5929..bea5cb841a3b 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -61,6 +61,7 @@ SvtCompatibilityEntry::SvtCompatibilityEntry()
     setValue<bool>( Index::ExpandWordSpace, true );
     setValue<bool>( Index::ProtectForm, false );
     setValue<bool>( Index::MsWordTrailingBlanks, false );
+    setValue<bool>( Index::SubtractFlysAnchoredAtFlys, false );
 
     setDefaultEntry( false );
 }
@@ -90,7 +91,8 @@ OUString SvtCompatibilityEntry::getName( const Index rIdx )
         "ConsiderWrappingStyle",
         "ExpandWordSpace",
         "ProtectForm",
-        "MsWordCompTrailingBlanks"
+        "MsWordCompTrailingBlanks",
+        "SubtractFlysAnchoredAtFlys"
     };
 
     /* Size of sPropertyName array not equal size of the SvtCompatibilityEntry::Index enum class */
commit c547cf9b8c14062b2e6bb3ba9ee6541bd9e16fba
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)
    Reviewed-on: https://gerrit.libreoffice.org/38262

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index bb6ca5a7e2eb..008e26f9efef 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1532,6 +1532,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)
 {
@@ -1666,7 +1681,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
@@ -1684,14 +1699,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 657a01ef00064f8f7cf7e81582f44064417321a8
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)
    Reviewed-on: https://gerrit.libreoffice.org/38261

diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 87a7b43c9055..4156753cf966 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 81453b10487c..b9093eb523c5 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 1cd629dacba3..bb6ca5a7e2eb 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1533,7 +1533,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;
@@ -1666,6 +1666,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
@@ -1683,12 +1684,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)
@@ -1854,6 +1857,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())
@@ -1916,18 +1920,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);
@@ -4681,7 +4674,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 );
     }
@@ -6588,10 +6582,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
@@ -6608,7 +6604,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)


More information about the Libreoffice-commits mailing list