[Libreoffice-commits] core.git: Branch 'feature/borderline2' - 328 commits - accessibility/AllLangMoTarget_acc.mk accessibility/AllLangResTarget_acc.mk accessibility/inc accessibility/Module_accessibility.mk accessibility/source avmedia/AllLangMoTarget_avmedia.mk avmedia/AllLangResTarget_avmedia.mk avmedia/inc avmedia/Module_avmedia.mk avmedia/source basctl/AllLangMoTarget_basctl.mk basctl/AllLangResTarget_basctl.mk basctl/inc basctl/Module_basctl.mk basctl/sdi basctl/source basctl/uiconfig basegfx/source basic/AllLangMoTarget_sb.mk basic/AllLangResTarget_sb.mk basic/inc basic/Library_sb.mk basic/Module_basic.mk basic/qa basic/source bin/count-src-resources bin/find-unused-defines-in-hrc-files.py bin/lint-ui.py bin/lo-xlate-lang bin/run bin/update_pch canvas/source chart2/AllLangMoTarget_chart.mk chart2/AllLangResTarget_chartcontroller.mk chart2/CppunitTest_chart2_export.mk chart2/CppunitTest_chart2_import.mk chart2/CppunitTest_chart2_trendcalculators.mk chart2/inc chart2/Library_chartcontroller. mk chart2/Module_chart2.mk chart2/source chart2/uiconfig codemaker/source comphelper/Library_comphelper.mk comphelper/source compilerplugins/clang config_host.mk.in configmgr/source configure.ac connectivity/AllLangMoTarget_cnr.mk connectivity/AllLangResTarget_cnr.mk connectivity/AllLangResTarget_sdberr.mk connectivity/Configuration_writer.mk connectivity/CppunitTest_connectivity_ado.mk connectivity/CppunitTest_connectivity_commontools.mk connectivity/inc connectivity/Library_ado.mk connectivity/Library_calc.mk connectivity/Library_dbtools.mk connectivity/Library_evoab.mk connectivity/Library_file.mk connectivity/Library_firebird_sdbc.mk connectivity/Library_mork.mk connectivity/Library_mysql.mk connectivity/Library_writer.mk connectivity/Module_connectivity.mk connectivity/qa connectivity/registry connectivity/source cppcanvas/CppunitTest_cppcanvas_emfplus.mk cppcanvas/inc cppcanvas/source cppuhelper/source cppu/source cui/AllLangMoTarget_cui.mk cui/AllLangResTarget_cui.mk cui/inc cui/Library_cui.mk cui/Module_cui.mk cui/source cui/uiconfig dbaccess/AllLangMoTarget_dba.mk dbaccess/AllLangResTarget_dba.mk dbaccess/AllLangResTarget_dbmm.mk dbaccess/AllLangResTarget_dbu.mk dbaccess/AllLangResTarget_sdbt.mk dbaccess/CppunitTest_dbaccess_dialog_save.mk dbaccess/CppunitTest_dbaccess_empty_stdlib_save.mk dbaccess/CppunitTest_dbaccess_hsqldb_test.mk dbaccess/CppunitTest_dbaccess_macros_test.mk dbaccess/CppunitTest_dbaccess_nolib_save.mk dbaccess/CppunitTest_dbaccess_RowSetClones.mk dbaccess/inc dbaccess/Library_dba.mk dbaccess/Library_dbaxml.mk dbaccess/Library_dbmm.mk dbaccess/Library_dbu.mk dbaccess/Library_sdbt.mk dbaccess/Module_dbaccess.mk dbaccess/source dbaccess/uiconfig desktop/AllLangMoTarget_dkt.mk desktop/AllLangResTarget_deploymentgui.mk desktop/AllLangResTarget_deployment.mk desktop/AllLangResTarget_dkt.mk desktop/inc desktop/Library_deploymentmisc.mk desktop/Library_deployment.mk desktop/Library_sofficeapp.mk desktop/Module_desktop.mk desktop/source des ktop/uiconfig desktop/unx download.lst drawinglayer/inc drawinglayer/Library_drawinglayer.mk drawinglayer/source dtrans/source editeng/AllLangMoTarget_editeng.mk editeng/AllLangResTarget_editeng.mk editeng/inc editeng/Library_editeng.mk editeng/Module_editeng.mk editeng/source editeng/uiconfig embeddedobj/source emfio/CppunitTest_emfio_emf_test.mk emfio/CppunitTest_emfio_wmf_test.mk emfio/emfio.component emfio/inc emfio/Library_emfio.mk emfio/Makefile emfio/Module_emfio.mk emfio/qa emfio/README emfio/source extensions/AllLangMoTarget_pcr.mk extensions/AllLangResTarget_abp.mk extensions/AllLangResTarget_bib.mk extensions/AllLangResTarget_dbp.mk extensions/AllLangResTarget_pcr.mk extensions/AllLangResTarget_scn.mk extensions/AllLangResTarget_upd.mk extensions/CppunitTest_extensions_test_update.mk extensions/inc extensions/Library_res.mk extensions/Library_scn.mk extensions/Library_updchk.mk extensions/Module_extensions.mk extensions/source extensions/uiconfig external/cppunit external /libmwaw external/libstaroffice external/libwps external/libxmlsec filter/AllLangMoTarget_flt.mk filter/AllLangResTarget_eps.mk filter/AllLangResTarget_pdffilter.mk filter/AllLangResTarget_t602filter.mk filter/AllLangResTarget_xsltdlg.mk filter/CppunitTest_filter_eps_test.mk filter/inc filter/Library_gie.mk filter/Library_graphicfilter.mk filter/Library_t602filter.mk filter/Module_filter.mk filter/source filter/uiconfig forms/AllLangMoTarget_frm.mk forms/AllLangResTarget_frm.mk forms/inc forms/Library_frm.mk forms/Module_forms.mk forms/source formula/AllLangMoTarget_for.mk formula/AllLangResTarget_for.mk formula/AllLangResTarget_forui.mk formula/inc formula/Library_for.mk formula/Module_formula.mk formula/source formula/uiconfig fpicker/AllLangMoTarget_fps.mk fpicker/AllLangResTarget_fps_office.mk fpicker/inc fpicker/Library_fps_aqua.mk fpicker/Library_fps.mk fpicker/Module_fpicker.mk fpicker/source fpicker/uiconfig framework/AllLangMoTarget_fwk.mk framework/AllLangResTarget_fwe.mk framework/inc framework/Library_fwe.mk framework/Module_framework.mk framework/qa framework/source helpcompiler/inc helpcompiler/source helpcontent2 hwpfilter/source i18nlangtag/source i18npool/inc i18npool/qa i18npool/source i18nutil/source icon-themes/galaxy idlc/inc idlc/source idl/inc idl/source include/android include/basic include/codemaker include/comphelper include/connectivity include/drawinglayer include/editeng include/formula include/fpicker include/framework include/i18nlangtag include/i18nutil include/LibreOfficeKit include/linguistic include/oox include/osl include/registry include/rsc include/rtl include/sal include/sax include/sfx2 include/sot include/svl include/svtools include/svx include/toolkit include/tools include/unotools include/vcl include/xmloff instsetoo_native/CustomTarget_setup.mk io/source l10ntools/Executable_transex3.mk l10ntools/Executable_uiex.mk l10ntools/Module_l10ntools.mk l10ntools/source leak-suppress.txt libreofficekit/qa libreofficekit/READM E libreofficekit/source lingucomponent/source linguistic/inc linguistic/source Makefile.in odk/docs odk/examples offapi/com offapi/type_reference offapi/UnoApi_offapi.mk officecfg/Configuration_officecfg.mk officecfg/registry oovbaapi/ooo oovbaapi/UnoApi_oovbaapi.mk oox/inc oox/source opencl/inc opencl/source package/inc package/source postprocess/CustomTarget_registry.mk postprocess/Rdb_services.mk pyuno/source readlicense_oo/license registry/source reportdesign/AllLangMoTarget_rpt.mk reportdesign/AllLangResTarget_rpt.mk reportdesign/AllLangResTarget_rptui.mk reportdesign/inc reportdesign/Library_rpt.mk reportdesign/Module_reportdesign.mk reportdesign/source reportdesign/uiconfig RepositoryExternal.mk Repository.mk RepositoryModule_build.mk RepositoryModule_host.mk rsc/documentation rsc/Executable_rsc.mk rsc/inc rsc/Makefile rsc/Module_rsc.mk rsc/README rsc/source salhelper/source sal/osl sal/qa sal/rtl sal/textenc sax/inc sax/source scaddins/AllLangMoTarget_sca.mk scaddins/AllLang ResTarget_analysis.mk scaddins/AllLangResTarget_date.mk scaddins/AllLangResTarget_pricing.mk scaddins/inc scaddins/Library_analysis.mk scaddins/Library_date.mk scaddins/Library_pricing.mk scaddins/Module_scaddins.mk scaddins/source sc/AllLangMoTarget_sc.mk sc/AllLangResTarget_sc.mk sccomp/AllLangMoTarget_scc.mk sccomp/AllLangResTarget_solver.mk sccomp/inc sccomp/Library_solver.mk sccomp/Module_sccomp.mk sccomp/source sc/CppunitTest_sc_filters_test.mk sc/CppunitTest_sc_macros_test.mk sc/CppunitTest_sc_screenshots.mk sc/CppunitTest_sc_tiledrendering.mk schema/odf1.0 sc/inc sc/Library_sc.mk sc/Library_vbaobj.mk sc/Module_sc.mk scp2/inc scp2/InstallModule_ooo.mk scp2/macros scp2/source sc/qa scripting/source sc/sdi sc/source sc/uiconfig sc/workben sd/AllLangMoTarget_sd.mk sd/AllLangResTarget_sd.mk sd/CppunitTest_sd_export_ooxml1.mk sd/CppunitTest_sd_export_ooxml2.mk sd/CppunitTest_sd_export_tests.mk sd/CppunitTest_sd_filters_test.mk sd/CppunitTest_sd_html_export_tests.mk sd/CppunitTest_ sd_import_tests.mk sd/CppunitTest_sd_misc_tests.mk sd/CppunitTest_sd_svg_export_tests.mk sd/CppunitTest_sd_tiledrendering.mk sdext/source sd/inc sd/Library_sd.mk sd/Module_sd.mk sd/qa sd/sdi sd/source sd/uiconfig setup_native/source sfx2/AllLangMoTarget_sfx2.mk sfx2/AllLangResTarget_sfx2.mk sfx2/inc sfx2/Library_sfx.mk sfx2/Module_sfx2.mk sfx2/sdi sfx2/source sfx2/uiconfig shell/source slideshow/inc solenv/bin solenv/CompilerTest_compilerplugins_clang.mk solenv/doc solenv/gbuild solenv/qa soltools/cpp soltools/mkdepend sot/source starmath/AllLangMoTarget_sm.mk starmath/AllLangResTarget_sm.mk starmath/inc starmath/Library_sm.mk starmath/Module_starmath.mk starmath/qa starmath/source starmath/uiconfig store/source svgio/inc svgio/qa svgio/source svl/AllLangMoTarget_svl.mk svl/AllLangResTarget_svl.mk svl/Library_svl.mk svl/Module_svl.mk svl/qa svl/source svl/unx svtools/AllLangMoTarget_svt.mk svtools/AllLangResTarget_svt.mk svtools/inc svtools/Library_svt.mk svtools/Module_svtools.mk s vtools/source svtools/uiconfig svx/AllLangMoTarget_svx.mk svx/AllLangResTarget_gal.mk svx/AllLangResTarget_svx.mk svx/inc svx/Library_svxcore.mk svx/Module_svx.mk svx/sdi svx/source svx/uiconfig sw/AllLangMoTarget_sw.mk sw/AllLangResTarget_sw.mk sw/CppunitTest_sw_filters_test.mk sw/CppunitTest_sw_htmlexport.mk sw/CppunitTest_sw_mailmerge.mk sw/CppunitTest_sw_ooxmlexport8.mk sw/CppunitTest_sw_ooxmlimport.mk sw/CppunitTest_sw_rtfimport.mk sw/CppunitTest_sw_ww8export.mk sw/inc sw/Library_sw.mk sw/Library_swui.mk sw/Module_sw.mk sw/ooxmlexport_setup.mk sw/qa sw/sdi sw/source sw/uiconfig test/source toolkit/source tools/inc tools/Library_tl.mk tools/qa tools/source ucbhelper/source ucb/source udkapi/com uitest/uitest uitest/writer_tests unodevtools/source unoidl/source unotools/source unoxml/source uui/AllLangMoTarget_uui.mk uui/AllLangResTarget_uui.mk uui/inc uui/Library_uui.mk uui/Module_uui.mk uui/source uui/uiconfig vbahelper/inc vbahelper/source vcl/AllLangMoTarget_vcl.mk vcl/AllLan gResTarget_vcl.mk vcl/backendtest vcl/commonfuzzer.mk vcl/CppunitTest_vcl_filters_test.mk vcl/CppunitTest_vcl_wmf_test.mk vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Module_vcl.mk vcl/opengl vcl/osx vcl/qa vcl/source vcl/uiconfig vcl/unx vcl/win vcl/workben winaccessibility/inc winaccessibility/Library_winaccessibility.mk winaccessibility/source wizards/AllLangMoTarget_wiz.mk wizards/AllLangResTarget_dbw.mk wizards/com wizards/Module_wizards.mk wizards/Pyuno_commonwizards.mk wizards/source writerfilter/source writerperfect/AllLangMoTarget_wpt.mk writerperfect/AllLangResTarget_writerperfect.mk writerperfect/CppunitTest_writerperfect_draw.mk writerperfect/CppunitTest_writerperfect_impress.mk writerperfect/inc writerperfect/Module_writerperfect.mk writerperfect/source writerperfect/uiconfig xmlhelp/source xmloff/dtd xmloff/inc xmloff/source xmlscript/source xmlsecurity/AllLangMoTarget_xsc.mk xmlsecurity/AllLangResTarget_xsec.mk xmlsecurity/inc xmlsecurity/Library_xsec_xmlsec.mk xmlsecu rity/Module_xmlsecurity.mk xmlsecurity/source xmlsecurity/uiconfig xmlsecurity/util xmlsecurity/workben

Armin Le Grand Armin.Le.Grand at cib.de
Fri Jul 21 19:19:55 UTC 2017


Rebased ref, commits from common ancestor:
commit f9427dc98be255af64a8c34c1e923680b3f9fe75
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Fri Jul 21 17:34:40 2017 +0200

    borderline: first versionj with line end adaptions
    
    Added usage of defined extensions to the BorderLinePrimitive,
    also added a first version to detect all cuts with adjacent
    borders and produce the correct extensions, for single and
    double lines. Not completely happy with it, but a first
    version
    
    Change-Id: I4b12a6cc0a70278bd5c506e9b3b2c5c126930dad

diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index 84ea9fff10ca..a9822d6bcd06 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -144,8 +144,8 @@ namespace drawinglayer
                     // single line, only inside values used, no vertical offsets
                     addPolygonStrokePrimitive2D(
                         rContainer,
-                        getStart(),
-                        getEnd(),
+                        getStart() - (aVector * getExtendLeftStart()),
+                        getEnd() + (aVector * getExtendLeftEnd()),
                         getRGBColorLeft(),
                         getLeftWidth(),
                         getStyle(),
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index c193285b1a25..de93c9372d88 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -345,6 +345,153 @@ double lcl_GetExtent(
     return nCut;
 }
 
+void getOffsetsFromStyle(const Style& rStyle, std::vector< double >& offsets)
+{
+    if (rStyle.Prim())
+    {
+        if (rStyle.Dist() && rStyle.Secn())
+        {
+            // both lines used (or all three), push four values, from outer to inner
+            switch (rStyle.GetRefMode())
+            {
+            case RefMode::Centered:
+            {
+                const double fHalfFullWidth(rStyle.GetWidth() * 0.5);
+                offsets.push_back(-fHalfFullWidth);
+                offsets.push_back(rStyle.Prim() - fHalfFullWidth);
+                offsets.push_back((rStyle.Prim() + rStyle.Dist()) - fHalfFullWidth);
+                offsets.push_back(fHalfFullWidth);
+                break;
+            }
+            case RefMode::Begin:
+                offsets.push_back(0.0);
+                offsets.push_back(rStyle.Prim());
+                offsets.push_back(rStyle.Prim() + rStyle.Dist());
+                offsets.push_back(rStyle.GetWidth());
+                break;
+            default: // case RefMode::End:
+            {
+                const double fFullWidth(rStyle.GetWidth());
+                offsets.push_back(-fFullWidth);
+                offsets.push_back(rStyle.Prim() - fFullWidth);
+                offsets.push_back((rStyle.Prim() + rStyle.Dist()) - fFullWidth);
+                offsets.push_back(0.0);
+                break;
+            }
+            }
+        }
+        else
+        {
+            // one line used, push two values, from outer to inner
+            switch (rStyle.GetRefMode())
+            {
+            case RefMode::Centered:
+                offsets.push_back(rStyle.Prim() * -0.5);
+                offsets.push_back(rStyle.Prim() * 0.5);
+                break;
+            case RefMode::Begin:
+                offsets.push_back(0.0);
+                offsets.push_back(rStyle.Prim());
+                break;
+            default: // case RefMode::End:
+                offsets.push_back(-rStyle.Prim());
+                offsets.push_back(0.0);
+                break;
+            }
+        }
+    }
+}
+
+void compareToStyle(
+    const basegfx::B2DPoint& rOrigin,
+    const basegfx::B2DVector& rOtherVector,
+    const basegfx::B2DVector& rOtherUnifiedPerpendicular,
+    const std::vector< double >& rOtherOffsets,
+    const Style& rStyle,
+    const basegfx::B2DVector& rMyVector,
+    std::vector< std::vector< double >>& rOtherCuts)
+{
+    if (rStyle.Prim())
+    {
+        std::vector< double > myOffsets;
+
+        // get offsets from outer to inner (two or four, depending on style)
+        getOffsetsFromStyle(rStyle, myOffsets);
+
+        if (!myOffsets.empty())
+        {
+            const basegfx::B2DVector aMyUnifiedPerpendicular(basegfx::getNormalizedPerpendicular(rMyVector));
+
+            for (size_t a(0); a < rOtherOffsets.size(); a++)
+            {
+                const basegfx::B2DPoint aOtherPos(rOrigin + (rOtherUnifiedPerpendicular * rOtherOffsets[a]));
+
+                for (size_t b(0); b < myOffsets.size(); b++)
+                {
+                    const basegfx::B2DPoint aMyPos(rOrigin + (aMyUnifiedPerpendicular * myOffsets[b]));
+                    double fCut(0.0);
+                    basegfx::tools::findCut(
+                        aOtherPos,
+                        rOtherVector,
+                        aMyPos,
+                        rMyVector,
+                        CutFlagValue::LINE,
+                        &fCut);
+
+                    rOtherCuts[a].push_back(fCut);
+                }
+            }
+        }
+    }
+}
+
+double getMinMaxCut(bool bMin, const std::vector< double >& rVector)
+{
+    if (rVector.empty())
+    {
+        return 0.0;
+    }
+
+    if (1 == rVector.size())
+    {
+        return rVector[0];
+    }
+
+    double fRetval(rVector[0]);
+
+    for (size_t a(1); a < rVector.size(); a++)
+    {
+        fRetval = bMin ? std::min(fRetval, rVector[a]) : std::max(fRetval, rVector[a]);
+    }
+
+    return fRetval;
+}
+
+std::vector< double > getMinMaxCuts(bool bMin, const std::vector< std::vector< double >>& rCuts)
+{
+    std::vector< double > aRetval(rCuts.size());
+
+    for (size_t a(0); a < rCuts.size(); a++)
+    {
+        aRetval[a] = getMinMaxCut(bMin, rCuts[a]);
+    }
+
+    return aRetval;
+}
+
+bool areCutsEmpty(std::vector< std::vector< double >>& rCuts)
+{
+    for (const auto& rVec : rCuts)
+    {
+        if (!rVec.empty())
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
 void CreateBorderPrimitives(
     drawinglayer::primitive2d::Primitive2DContainer& rTarget,
     const basegfx::B2DPoint& rOrigin,
@@ -363,7 +510,158 @@ void CreateBorderPrimitives(
     const DiagStyle& /*rRFromBL*/,
     const Color* pForceColor)
 {
-    if (rBorder.Prim() || rBorder.Secn())
+    static bool bCheckNewStuff(true);
+
+    if (bCheckNewStuff && rBorder.Prim())
+    {
+        double mfExtendLeftStart(0.0);
+        double mfExtendLeftEnd(0.0);
+        double mfExtendRightStart(0.0);
+        double mfExtendRightEnd(0.0);
+        std::vector< double > myOffsets;
+        getOffsetsFromStyle(rBorder, myOffsets);
+        const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
+        const double fLength(rX.getLength());
+
+        if (2 == myOffsets.size())
+        {
+            std::vector< std::vector< double >> myCutsS(myOffsets.size());
+            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rLFromT, rY, myCutsS);
+            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rLFromB, rY, myCutsS);
+            std::vector< double > nMinCutsS(getMinMaxCuts(true, myCutsS));
+            mfExtendLeftStart = ((nMinCutsS[0] + nMinCutsS[1]) * 0.5) * -1.0 * fLength;
+
+            std::vector< std::vector< double >> myCutsE(myOffsets.size());
+            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rRFromT, rY, myCutsE);
+            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rRFromB, rY, myCutsE);
+            std::vector< double > nMinCutsE(getMinMaxCuts(false, myCutsE));
+            mfExtendLeftEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
+
+        }
+        else if (4 == myOffsets.size())
+        {
+            {
+                std::vector< double > myOffsetsA;
+                myOffsetsA.push_back(myOffsets[0]);
+                myOffsetsA.push_back(myOffsets[1]);
+
+                std::vector< std::vector< double >> myCutsS(myOffsetsA.size());
+                std::vector< double > nMinCutsS;
+                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rLFromT, rY, myCutsS);
+
+                if (!areCutsEmpty(myCutsS))
+                {
+                    nMinCutsS = getMinMaxCuts(false, myCutsS);
+                }
+                else
+                {
+                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rLFromB, rY, myCutsS);
+                    nMinCutsS = getMinMaxCuts(true, myCutsS);
+                }
+
+                mfExtendLeftStart = ((nMinCutsS[0] + nMinCutsS[1]) * 0.5) * -1.0 * fLength;
+
+                std::vector< std::vector< double >> myCutsE(myOffsetsA.size());
+                std::vector< double > nMinCutsE;
+                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rRFromT, rY, myCutsE);
+
+                if (!areCutsEmpty(myCutsE))
+                {
+                    nMinCutsE = getMinMaxCuts(true, myCutsE);
+                }
+                else
+                {
+                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rRFromB, rY, myCutsE);
+                    nMinCutsE = getMinMaxCuts(false, myCutsE);
+                }
+
+                mfExtendLeftEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
+            }
+
+            {
+                std::vector< double > myOffsetsB;
+                myOffsetsB.push_back(myOffsets[2]);
+                myOffsetsB.push_back(myOffsets[3]);
+
+                std::vector< std::vector< double >> myCutsS(myOffsetsB.size());
+                std::vector< double > nMinCutsS;
+                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rLFromB, rY, myCutsS);
+
+                if (!areCutsEmpty(myCutsS))
+                {
+                    nMinCutsS = getMinMaxCuts(false, myCutsS);
+                }
+                else
+                {
+                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rLFromT, rY, myCutsS);
+                    nMinCutsS = getMinMaxCuts(true, myCutsS);
+                }
+
+                mfExtendRightStart = ((nMinCutsS[0] + nMinCutsS[1]) * 0.5) * -1.0 * fLength;
+
+                std::vector< std::vector< double >> myCutsE(myOffsetsB.size());
+                std::vector< double > nMinCutsE;
+                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rRFromB, rY, myCutsE);
+
+                if (!areCutsEmpty(myCutsE))
+                {
+                    nMinCutsE = getMinMaxCuts(true, myCutsE);
+                }
+                else
+                {
+                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rRFromT, rY, myCutsE);
+                    nMinCutsE = getMinMaxCuts(false, myCutsE);
+                }
+
+                mfExtendRightEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
+            }
+        }
+
+        // do not forget RefMode offset, primitive will assume RefMode::Centered
+        basegfx::B2DVector aRefModeOffset;
+
+        if (RefMode::Centered != rBorder.GetRefMode())
+        {
+            const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
+            const double fHalfWidth(rBorder.GetWidth() * 0.5);
+
+            if (RefMode::Begin == rBorder.GetRefMode())
+            {
+                // move aligned below vector
+                aRefModeOffset = aPerpendX * fHalfWidth;
+            }
+            else if (RefMode::End == rBorder.GetRefMode())
+            {
+                // move aligned above vector
+                aRefModeOffset = aPerpendX * -fHalfWidth;
+            }
+        }
+
+        // create start/end for RefMode::Centered
+        const basegfx::B2DPoint aStart(rOrigin + aRefModeOffset);
+        const basegfx::B2DPoint aEnd(aStart + rX);
+
+        rTarget.append(
+            drawinglayer::primitive2d::Primitive2DReference(
+                new drawinglayer::primitive2d::BorderLinePrimitive2D(
+                    aStart,
+                    aEnd,
+                    rBorder.Prim(),
+                    rBorder.Dist(),
+                    rBorder.Secn(),
+                    mfExtendLeftStart,
+                    mfExtendLeftEnd,
+                    mfExtendRightStart,
+                    mfExtendRightEnd,
+                    (pForceColor ? *pForceColor : rBorder.GetColorSecn()).getBColor(),
+                    (pForceColor ? *pForceColor : rBorder.GetColorPrim()).getBColor(),
+                    (pForceColor ? *pForceColor : rBorder.GetColorGap()).getBColor(),
+                    rBorder.UseGapColor(),
+                    rBorder.Type(),
+                    rBorder.PatternScale())));
+    }
+
+    if (!bCheckNewStuff && (rBorder.Prim() || rBorder.Secn()))
     {
         basegfx::B2DPoint aStart(rOrigin);
         basegfx::B2DPoint aEnd(rOrigin + rX);
commit 2d561a61cf68671a11030e2cff279cd04e7dcdef
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Thu Jul 20 15:11:30 2017 +0200

    borderline: adaptions to primitives
    
    Handling and paint of borderlines greatly adapted
    to primitive usage. Solved the double paint mechanisn
    to no longer use the sc-local special cases. The
    svx tooling for borderline paint is now the only one
    and was extended to also handle diagonal lines.
    Big cleanups/removals of old paint to OutputDevice
    and sc-specific rendering. All other app-usages
    of borderline also adapted. Preparations for careful
    line-start/end adaption prepared and possible due to
    unified coordinate-system usages and basegfx class-usage
    
    Change-Id: If9e4efcfc0fe25e14d4052907038ca5cf222a432

diff --git a/include/svx/framelink.hxx b/include/svx/framelink.hxx
index b907958a0789..b0c11e2b5f8c 100644
--- a/include/svx/framelink.hxx
+++ b/include/svx/framelink.hxx
@@ -32,6 +32,7 @@
 class Point;
 namespace tools { class Rectangle; }
 class OutputDevice;
+namespace svx { namespace frame { class Cell; }}
 
 namespace svx {
 namespace frame {
@@ -157,6 +158,9 @@ public:
     /** Returns this style mirrored, if it is a double frame style, otherwise a simple copy. */
     Style               Mirror() const;
 
+    /** return the Cell using this style (if set) */
+    const Cell* GetUsingCell() const { return mpUsingCell; }
+
 private:
     Color               maColorPrim;
     Color               maColorSecn;
@@ -168,6 +172,13 @@ private:
     double              mfSecn;     /// Width of secondary (right or bottom) line.
     double              mfPatternScale; /// Scale used for line pattern spacing.
     SvxBorderLineStyle  mnType;
+
+    /// need information which cell this style info comes from due to needed
+    /// rotation info (which is in the cell). Rotation depends on the cell.
+    /// Encapsulated using a single static friend method that is the single
+    /// allowed instance to set/modify this value
+    friend void exclusiveSetUsigCellAtStyle(Style& rStyle, const Cell* pCell);
+    const Cell*         mpUsingCell;
 };
 
 bool operator==( const Style& rL, const Style& rR );
@@ -277,78 +288,6 @@ inline double GetVerDiagAngle( const tools::Rectangle& rRect )
  */
 SVX_DLLPUBLIC long GetTLDiagOffset( long nVerOffs, long nDiagOffs, double fAngle );
 
-/** Returns an X coordinate for a diagonal frame border in the specified height.
-
-    This function is for usage with the bottom-left end of a bottom-left to
-    top-right diagonal frame border, connected to the left end of a horizontal
-    frame border.
-
-    The function returns the relative X position (i.e. for a polygon) of the
-    diagonal frame border according to the specified relative Y position. The
-    mentioned positions are relative to the reference point of both frame
-    borders.
-
-             Primary -->/     /<--- Secondary
-                       /     /
-                      /     /       The function calculates the X position of i.e.
-    - - - - - - - - -/- - -X <----- this point (relative from X of reference point).
-      ^         +---/     /------------------------------------------------
-     nVerOffs   |  /     / <--- The diagonal frame border.
-      v         | /  |  /
-    - - - - - - |  --+--  <---- Reference point for horizontal and diagonal frame borders.
-                |    |
-                |               The horizontal frame border.
-                +----------------------------------------------------------
-
-    @param nVerOffs
-        The vertical position of the point to be calculated, relative to the Y
-        coordinate of the reference point.
-    @param nDiagOffs
-        The width offset across the diagonal frame border (0 = middle),
-        regardless of the gradient of the diagonal frame border (always
-        vertical to the direction of the diagonal frame border). This value is
-        not related in any way to the reference point. For details about
-        relative width offsets, see description of class Style.
-    @param fAngle
-        Inner (right) angle between diagonal and horizontal frame border.
- */
-long GetBLDiagOffset( long nVerOffs, long nDiagOffs, double fAngle );
-
-/** Returns an X coordinate for a diagonal frame border in the specified height.
-
-    This function is for usage with the bottom-right end of a top-left to
-    bottom-right diagonal frame border, connected to the right end of a
-    horizontal frame border.
-
-    @param nDiagOffs
-        The width offset across the diagonal frame border (0 = middle),
-        regardless of the gradient of the diagonal frame border (always
-        vertical to the direction of the diagonal frame border). This value is
-        not related in any way to the reference point. For details about
-        relative width offsets, see description of class Style.
-    @param fAngle
-        Inner (left) angle between diagonal and horizontal frame border.
- */
-long GetBRDiagOffset( long nDiagOffs, double fAngle );
-
-/** Returns an X coordinate for a diagonal frame border in the specified height.
-
-    This function is for usage with the top-right end of a bottom-left to
-    top-right diagonal frame border, connected to the right end of a horizontal
-    frame border.
-
-    @param nDiagOffs
-        The width offset across the diagonal frame border (0 = middle),
-        regardless of the gradient of the diagonal frame border (always
-        vertical to the direction of the diagonal frame border). This value is
-        not related in any way to the reference point. For details about
-        relative width offsets, see description of class Style.
-    @param fAngle
-        Inner (left) angle between diagonal and horizontal frame border.
- */
-long GetTRDiagOffset( long nDiagOffs, double fAngle );
-
-
 /** Checks whether two horizontal frame borders are "connectable".
 
     Two borders are "connectable" in terms of this function, if both can be
@@ -431,8 +370,11 @@ SVX_DLLPUBLIC bool CheckFrameBorderConnectable(
  */
 SVX_DLLPUBLIC void CreateBorderPrimitives(
     drawinglayer::primitive2d::Primitive2DContainer&    rTarget,        /// target for created primitives
-    const Point&        rLPos,          /// Reference point for left end of the processed frame border.
-    const Point&        rRPos,          /// Reference point for right end of the processed frame border.
+
+    const basegfx::B2DPoint&    rOrigin,    /// start point of borderline
+    const basegfx::B2DVector&   rX,         /// X-Axis with length
+    const basegfx::B2DVector&   rY,         /// Y-Axis for perpendicular, normalized. Does *not* need to be perpendicular, but may express a rotation
+
     const Style&        rBorder,        /// Style of the processed frame border.
 
     const DiagStyle&    rLFromTR,       /// Diagonal frame border from top-right to left end of rBorder.
@@ -447,15 +389,16 @@ SVX_DLLPUBLIC void CreateBorderPrimitives(
     const Style&        rRFromB,        /// Vertical frame border from bottom to right end of rBorder.
     const DiagStyle&    rRFromBL,       /// Diagonal frame border from bottom-left to right end of rBorder.
 
-    const Color*        pForceColor,    /// If specified, overrides frame border color.
-    const long          rRotationT = 9000, /// Angle of the top slanted frames in 100th of degree
-    const long          rRotationB = 9000  /// Angle of the bottom slanted frames in 100th of degree
+    const Color*        pForceColor     /// If specified, overrides frame border color.
 );
 
 SVX_DLLPUBLIC void CreateBorderPrimitives(
     drawinglayer::primitive2d::Primitive2DContainer&    rTarget,        /// target for created primitives
-    const Point&        rLPos,          /// Reference point for left end of the processed frame border.
-    const Point&        rRPos,          /// Reference point for right end of the processed frame border.
+
+    const basegfx::B2DPoint&    rOrigin,    /// start point of borderline
+    const basegfx::B2DVector&   rX,         /// X-Axis with length
+    const basegfx::B2DVector&   rY,         /// Y-Axis for perpendicular, normalized. Does *not* need to be perpendicular, but may express a rotation
+
     const Style&        rBorder,        /// Style of the processed frame border.
 
     const Style&        rLFromT,        /// Vertical frame border from top to left end of rBorder.
@@ -466,9 +409,7 @@ SVX_DLLPUBLIC void CreateBorderPrimitives(
     const Style&        rRFromR,        /// Horizontal frame border from right to right end of rBorder.
     const Style&        rRFromB,        /// Vertical frame border from bottom to right end of rBorder.
 
-    const Color*        pForceColor,    /// If specified, overrides frame border color.
-    const long          rRotationT = 9000, /// Angle of the top slanted frame in 100th of degrees
-    const long          rRotationB = 9000  /// Angle of the bottom slanted frame in 100th of degrees
+    const Color*        pForceColor     /// If specified, overrides frame border color.
 );
 
 /** Draws both diagonal frame borders, regards all connected frame styles.
@@ -479,164 +420,11 @@ The function preserves all settings of the passed output device.
 */
 SVX_DLLPUBLIC void CreateDiagFrameBorderPrimitives(
     drawinglayer::primitive2d::Primitive2DContainer&    rTarget,        /// target for created primitives
-    const basegfx::B2DRange&                            rRange,         /// geometrical definition for both diagonal frame borders.
 
-    const Style&        rTLBR,          /// Style of the processed top-left to bottom-right diagonal frame border.
-    const Style&        rBLTR,          /// Style of the processed bottom-left to top-right diagonal frame border.
-
-    const Style&        rTLFromB,       /// Vertical frame border from bottom to top-left end of rTLBR.
-    const Style&        rTLFromR,       /// Horizontal frame border from right to top-left end of rTLBR.
-    const Style&        rBRFromT,       /// Vertical frame border from top to bottom-right end of rTLBR.
-    const Style&        rBRFromL,       /// Horizontal frame border from left to bottom-right end of rTLBR.
-
-    const Style&        rBLFromT,       /// Vertical frame border from top to bottom-left end of rBLTR.
-    const Style&        rBLFromR,       /// Horizontal frame border from right to bottom-left end of rBLTR.
-    const Style&        rTRFromB,       /// Vertical frame border from bottom to top-right end of rBLTR.
-    const Style&        rTRFromL,       /// Horizontal frame border from left to top-right end of rBLTR.
-
-    const Color*        pForceColor,        /// If specified, overrides frame border color.
-    const long          nRotationT = 9000,  /// Angle of the top slanted frame in 100th of degrees
-    const long          nRotationB = 9000   /// Angle of the bottom slanted frame in 100th of degrees
-);
-
-/** Draws a horizontal frame border, regards all connected frame styles.
-
-    The frame style to draw is passed as parameter rBorder. The function
-    calculates the adjustment in X direction for left and right end of primary
-    and secondary line of the frame border (the style may present a double
-    line). The line ends may differ according to the connected frame styles
-    coming from top, bottom, left, right, and/or diagonal.
-
-    Thick frame styles are always drawn centered (in width) to the passed
-    reference points. The Y coordinates of both reference points must be equal
-    (the line cannot be drawn slanted).
-
-    The function preserves all settings of the passed output device.
-
-    All parameters starting with "rL" refer to the left end of the processed
-    frame border, all parameters starting with "rR" refer to the right end.
-    The following part of the parameter name starting with "From" specifies
-    where the frame border comes from. Example: "rLFromTR" means the frame
-    border coming from top-right, connected to the left end of rBorder (and
-    therefore a diagonal frame border).
-
-    The follong picture shows the meaning of all passed parameters:
-
-                 rLFromT      /                   \      rRFromT
-                    |       /                       \       |
-                    |   rLFromTR               rRFromTL     |
-                    |   /                               \   |
-                    | /                                   \ |
-    --- rLFromL ---   ============== rBorder ==============   --- rRFromR ---
-                    | \                                   / |
-                    |   \                               /   |
-                    |   rLFromBR               rRFromBL     |
-                    |       \                       /       |
-                 rLFromB      \                   /      rRFromB
- */
-SVX_DLLPUBLIC void DrawHorFrameBorder(
-    OutputDevice&       rDev,           /// The output device used to draw the frame border.
-
-    const Point&        rLPos,          /// Reference point for left end of the processed frame border.
-    const Point&        rRPos,          /// Reference point for right end of the processed frame border.
-    const Style&        rBorder,        /// Style of the processed frame border.
-
-    const DiagStyle&    rLFromTR,       /// Diagonal frame border from top-right to left end of rBorder.
-    const Style&        rLFromT,        /// Vertical frame border from top to left end of rBorder.
-    const Style&        rLFromL,        /// Horizontal frame border from left to left end of rBorder.
-    const Style&        rLFromB,        /// Vertical frame border from bottom to left end of rBorder.
-    const DiagStyle&    rLFromBR,       /// Diagonal frame border from bottom-right to left end of rBorder.
-
-    const DiagStyle&    rRFromTL,       /// Diagonal frame border from top-left to right end of rBorder.
-    const Style&        rRFromT,        /// Vertical frame border from top to right end of rBorder.
-    const Style&        rRFromR,        /// Horizontal frame border from right to right end of rBorder.
-    const Style&        rRFromB,        /// Vertical frame border from bottom to right end of rBorder.
-    const DiagStyle&    rRFromBL,       /// Diagonal frame border from bottom-left to right end of rBorder.
-
-    const Color*        pForceColor = nullptr /// If specified, overrides frame border color.
-);
-
-
-/** Draws a vertical frame border, regards all connected frame styles.
-
-    The frame style to draw is passed as parameter rBorder. The function
-    calculates the adjustment in Y direction for top and bottom end of primary
-    and secondary line of the frame border (the style may present a double
-    line). The line ends may differ according to the connected frame styles
-    coming from left, right, top, bottom, and/or diagonal.
-
-    Thick frame styles are always drawn centered (in width) to the passed
-    reference points. The X coordinates of both reference points must be equal
-    (the line cannot be drawn slanted).
-
-    The function preserves all settings of the passed output device.
-
-    All parameters starting with "rT" refer to the top end of the processed
-    frame border, all parameters starting with "rB" refer to the bottom end.
-    The following part of the parameter name starting with "From" specifies
-    where the frame border comes from. Example: "rTFromBL" means the frame
-    border coming from bottom-left, connected to the top end of rBorder (and
-    therefore a diagonal frame border).
-
-    The follong picture shows the meaning of all passed parameters:
-
-                    |
-                 rTFromT
-                    |
-                    |
-    --- rTFromL ---   --- rTFromR ---
-                  / # \
-                /   #   \
-        rTFromBL    #   rTFromBR
-            /       #       \
-          /         #         \
-                    #
-                 rBorder
-                    #
-          \         #         /
-            \       #       /
-        rBFromTL    #   rBFromTR
-                \   #   /
-                  \ # /
-    --- rBFromL ---   --- rBFromR ---
-                    |
-                    |
-                 rBFromB
-                    |
- */
-SVX_DLLPUBLIC void DrawVerFrameBorder(
-    OutputDevice&       rDev,           /// The output device used to draw the frame border.
-
-    const Point&        rTPos,          /// Reference point for top end of the processed frame border.
-    const Point&        rBPos,          /// Reference point for bottom end of the processed frame border.
-    const Style&        rBorder,        /// Style of the processed frame border.
-
-    const DiagStyle&    rTFromBL,       /// Diagonal frame border from bottom-right to top end of rBorder.
-    const Style&        rTFromL,        /// Horizontal frame border from left to top end of rBorder.
-    const Style&        rTFromT,        /// Vertical frame border from top to top end of rBorder.
-    const Style&        rTFromR,        /// Horizontal frame border from right to top end of rBorder.
-    const DiagStyle&    rTFromBR,       /// Diagonal frame border from bottom-right to top end of rBorder.
-
-    const DiagStyle&    rBFromTL,       /// Diagonal frame border from top-left to bottom end of rBorder.
-    const Style&        rBFromL,        /// Horizontal frame border from left to bottom end of rBorder.
-    const Style&        rBFromB,        /// Vertical frame border from bottom to bottom end of rBorder.
-    const Style&        rBFromR,        /// Horizontal frame border from right to bottom end of rBorder.
-    const DiagStyle&    rBFromTR,       /// Diagonal frame border from top-right to bottom end of rBorder.
-
-    const Color*        pForceColor = nullptr /// If specified, overrides frame border color.
-);
-
-
-/** Draws both diagonal frame borders, regards all connected frame styles.
-
-    One or both passed diagonal frame styles may be invisible.
-
-    The function preserves all settings of the passed output device.
- */
-SVX_DLLPUBLIC void DrawDiagFrameBorders(
-    OutputDevice&       rDev,           /// The output device used to draw the frame border.
+    const basegfx::B2DPoint&                            rOrigin,        /// Origin of the coordinate system spawning the cell
+    const basegfx::B2DVector&                           rXAxis,         /// X-Axis of the coordinate system spawning the cell
+    const basegfx::B2DVector&                           rYAxis,         /// Y-Axis of the coordinate system spawning the cell
 
-    const tools::Rectangle&    rRect,          /// Rectangle for both diagonal frame borders.
     const Style&        rTLBR,          /// Style of the processed top-left to bottom-right diagonal frame border.
     const Style&        rBLTR,          /// Style of the processed bottom-left to top-right diagonal frame border.
 
@@ -650,8 +438,7 @@ SVX_DLLPUBLIC void DrawDiagFrameBorders(
     const Style&        rTRFromB,       /// Vertical frame border from bottom to top-right end of rBLTR.
     const Style&        rTRFromL,       /// Horizontal frame border from left to top-right end of rBLTR.
 
-    const Color*        pForceColor,    /// If specified, overrides frame border color.
-    bool                bDiagDblClip    /// true = Use clipping for crossing double frame borders.
+    const Color*        pForceColor     /// If specified, overrides frame border color.
 );
 
 
diff --git a/include/svx/framelinkarray.hxx b/include/svx/framelinkarray.hxx
index 9208f67b46ae..15d8dcf1d9cf 100644
--- a/include/svx/framelinkarray.hxx
+++ b/include/svx/framelinkarray.hxx
@@ -23,6 +23,7 @@
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <svx/framelink.hxx>
 #include <svx/svxdllapi.h>
+#include <svx/rotmodit.hxx>
 #include <memory>
 #include <vector>
 
@@ -119,6 +120,12 @@ public:
     /** Sets the bottom frame style of the specified row. Ignores merged ranges. */
     void                SetRowStyleBottom( size_t nRow, const Style& rStyle );
 
+    /** Sets the rotation parameters of the cell (nCol,nRow). Ignores merged ranges. */
+    void                SetCellRotation(size_t nCol, size_t nRow, SvxRotateMode eRotMode, double fOrientation);
+
+    /** Check if at least one cell is rotated */
+    bool                HasCellRotation() const;
+
     /** Returns the left frame style of the cell (nCol,nRow).
         Returns thicker of own left style or right style of the cell to the left.
         Returns the style only if visible (i.e. at left border of a merged range).
@@ -246,9 +253,6 @@ public:
             clipped too. This array can handle only one clip range at a time. */
     void                SetClipRange( size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow );
 
-    /** Returns the rectangle (output coordinates) of the current clipping range. */
-    tools::Rectangle           GetClipRangeRectangle() const;
-
     // cell coordinates -------------------------------------------------------
 
     /** Sets the X output coordinate of the left column. */
@@ -313,14 +317,6 @@ public:
         Returns the vertical angle of merged ranges. */
     double              GetVerDiagAngle( size_t nCol, size_t nRow ) const;
 
-    /** Specifies whether to use polygon clipping to draw diagonal frame borders.
-        @descr
-            If enabled, diagonal frame borders are drawn interrupted, if they are
-            crossed by a double frame border. Polygon clipping is very expensive
-            and should only be used for very small output devices (i.e. in the
-            Border tab page). Default after construction is OFF. */
-    void                SetUseDiagDoubleClipping( bool bSet );
-
     // mirroring --------------------------------------------------------------
 
     /** Mirrors the entire array horizontally. */
@@ -336,16 +332,6 @@ public:
                             size_t nLastCol, size_t nLastRow,
                             const Color* pForceColor ) const;
 
-    /** Draws the part of the specified range, that is inside the clipping range.
-        @param pForceColor
-            If not NULL, only this color will be used to draw all frame borders. */
-    void                DrawRange( OutputDevice& rDev,
-                            size_t nFirstCol, size_t nFirstRow,
-                            size_t nLastCol, size_t nLastRow ) const;
-
-    /** Draws the part of the array, that is inside the clipping range. */
-    void                DrawArray(OutputDevice& rDev) const;
-
     /** Draws the part of the array, that is inside the clipping range. */
     void                DrawArray(drawinglayer::processor2d::BaseProcessor2D& rProcessor) const;
 
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index e5aadd52ac4f..a7d991275817 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -936,7 +936,6 @@ void ScDocument::FillInfo(
 
     svx::frame::Array& rArray = rTabInfo.maArray;
     rArray.Initialize( nColCount, nRowCount );
-    rArray.SetUseDiagDoubleClipping( false );
 
     for( size_t nRow = 0; nRow < nRowCount; ++nRow )
     {
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 8aeee70791e1..5345b69141bb 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -196,7 +196,6 @@ private:
 
     bool    bSnapPixel;
 
-    bool    bAnyRotated;        // internal
     bool    bAnyClipped;        // internal
     bool    bTabProtected;
     bool    bLayoutRTL;
@@ -302,7 +301,7 @@ public:
                     // with logic MapMode set!
     void    DrawEdit(bool bPixelToLogic);
 
-    void    FindRotated();
+    void    SetCellRotations();
     void    DrawRotated(bool bPixelToLogic);        // logical
 
     void    DrawClear();
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
index 0a7f9de81a50..8fd590944c79 100644
--- a/sc/source/ui/miscdlgs/autofmt.cxx
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -36,6 +36,7 @@
 #include <vcl/builderfactory.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <comphelper/processfactory.hxx>
+#include <drawinglayer/processor2d/processor2dtools.hxx>
 
 #include "strings.hrc"
 #include "scmod.hxx"
@@ -393,7 +394,19 @@ void ScAutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext)
 
         // 3) border
         if (pCurData->GetIncludeFrame())
-            maArray.DrawArray(rRenderContext);
+        {
+            const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
+            std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
+                drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
+                    rRenderContext,
+                    aNewViewInformation2D));
+
+            if (pProcessor2D)
+            {
+                maArray.DrawArray(*pProcessor2D.get());
+                pProcessor2D.reset();
+            }
+        }
     }
 }
 
@@ -401,7 +414,7 @@ void ScAutoFmtPreview::Init()
 {
     SetBorderStyle( WindowBorderStyle::MONO );
     maArray.Initialize( 5, 5 );
-    maArray.SetUseDiagDoubleClipping( false );
+//    maArray.SetUseDiagDoubleClipping( false );
     mnLabelColWidth = 0;
     mnDataColWidth1 = 0;
     mnDataColWidth2 = 0;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 68a1ec5fb461..a0ea195f3e14 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -699,6 +699,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
         pContentDev->SetMapMode(aCurrentMapMode);
     }
 
+    // check for and set cell rotations at OutputData to have it available
+    // in the svx tooling to render the borders
+    aOutputData.SetCellRotations();
+
     if ( rDoc.HasBackgroundDraw( nTab, aDrawingRectLogic ) )
     {
         pContentDev->SetMapMode(MapUnit::MapPixel);
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index b6d73631aca6..f4db5fec5b09 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -183,7 +183,6 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
     bShowSpellErrors( false ),
     bMarkClipped( false ), // sal_False for printer/metafile etc.
     bSnapPixel( false ),
-    bAnyRotated( false ),
     bAnyClipped( false ),
     mpTargetPaintWindow(nullptr), // #i74769# use SdrPaintWindow direct
     mpSpellCheckCxt(nullptr)
@@ -618,7 +617,7 @@ void ScOutputData::SetPagebreakMode( ScPageBreakData* pPageData )
     }
 }
 
-void ScOutputData::FindRotated()
+void ScOutputData::SetCellRotations()
 {
     //! save nRotMax
     SCCOL nRotMax = nX2;
@@ -652,8 +651,16 @@ void ScOutputData::FindRotated()
                     ScRotateDir nDir = pPattern->GetRotateDir( pCondSet );
                     if (nDir != ScRotateDir::NONE)
                     {
+                        // Needed for CellInfo internal decisions (bg fill, ...)
                         pInfo->nRotateDir = nDir;
-                        bAnyRotated = true;
+
+                        // add rotation info to Array information
+                        const long nAttrRotate(pPattern->GetRotateVal(pCondSet));
+                        const SvxRotateMode eRotMode((SvxRotateMode)static_cast<const SvxRotateModeItem&>(pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue());
+                        const double fOrient((bLayoutRTL ? -1.0 : 1.0) * nAttrRotate * F_PI18000); // 1/100th degrees -> [0..2PI]
+                        svx::frame::Array& rArray = mrTabInfo.maArray;
+
+                        rArray.SetCellRotation(nY+1, nX+1, eRotMode, fOrient);
                     }
                 }
             }
@@ -985,8 +992,6 @@ void drawCells(vcl::RenderContext& rRenderContext, const Color* pColor, const Sv
 
 void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext)
 {
-    FindRotated();              //! from the outside?
-
     Size aOnePixel = rRenderContext.PixelToLogic(Size(1,1));
     long nOneXLogic = aOnePixel.Width();
     long nOneYLogic = aOnePixel.Height();
@@ -1380,8 +1385,10 @@ void ScOutputData::DrawFrame(vcl::RenderContext& rRenderContext)
 
     const Color* pForceColor = bUseSingleColor ? &aSingleColor : nullptr;
 
-    if (bAnyRotated)
+    if (mrTabInfo.maArray.HasCellRotation())
+    {
         DrawRotatedFrame(rRenderContext, pForceColor);        // removes the lines that must not be painted here
+    }
 
     long nInitPosX = nScrX;
     if ( bLayoutRTL )
@@ -1617,16 +1624,16 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext, const Co
                     SvxRotateMode eRotMode = (SvxRotateMode)static_cast<const SvxRotateModeItem&>(
                                     pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
 
-                    if ( nAttrRotate )
+                    if (nAttrRotate)
                     {
-                        if (nX<nX1)         // compute negative position
+                        if (nX < nX1)         // compute negative position
                         {
                             nPosX = nInitPosX;
                             SCCOL nCol = nX1;
                             while (nCol > nX)
                             {
                                 --nCol;
-                                nPosX -= nLayoutSign * (long) pRowInfo[0].pCellInfo[nCol+1].nWidth;
+                                nPosX -= nLayoutSign * (long)pRowInfo[0].pCellInfo[nCol + 1].nWidth;
                             }
                         }
 
@@ -1636,248 +1643,100 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext, const Co
                         long nTop = nPosY - 1;
                         long nBottom = nPosY + nRowHeight - 1;
                         long nTopLeft = nPosX - nLayoutSign;
-                        long nTopRight = nPosX + ( nColWidth - 1 ) * nLayoutSign;
+                        long nTopRight = nPosX + (nColWidth - 1) * nLayoutSign;
                         long nBotLeft = nTopLeft;
                         long nBotRight = nTopRight;
 
                         // inclusion of the sign here hasn't been decided yet
                         // (if not, the extension of the non-rotated background must also be changed)
                         double nRealOrient = nLayoutSign * nAttrRotate * F_PI18000;     // 1/100th degrees
-                        double nCos = cos( nRealOrient );
-                        double nSin = sin( nRealOrient );
+                        double nCos = cos(nRealOrient);
+                        double nSin = sin(nRealOrient);
                         //! restrict !!!
-                        long nSkew = (long) ( nRowHeight * nCos / nSin );
+                        long nSkew = (long)(nRowHeight * nCos / nSin);
 
                         switch (eRotMode)
                         {
-                            case SVX_ROTATE_MODE_BOTTOM:
-                                nTopLeft += nSkew;
-                                nTopRight += nSkew;
-                                break;
-                            case SVX_ROTATE_MODE_CENTER:
-                                nSkew /= 2;
-                                nTopLeft += nSkew;
-                                nTopRight += nSkew;
-                                nBotLeft -= nSkew;
-                                nBotRight -= nSkew;
-                                break;
-                            case SVX_ROTATE_MODE_TOP:
-                                nBotLeft -= nSkew;
-                                nBotRight -= nSkew;
-                                break;
-                            default:
-                            {
-                                // added to avoid warnings
-                            }
+                        case SVX_ROTATE_MODE_BOTTOM:
+                            nTopLeft += nSkew;
+                            nTopRight += nSkew;
+                            break;
+                        case SVX_ROTATE_MODE_CENTER:
+                            nSkew /= 2;
+                            nTopLeft += nSkew;
+                            nTopRight += nSkew;
+                            nBotLeft -= nSkew;
+                            nBotRight -= nSkew;
+                            break;
+                        case SVX_ROTATE_MODE_TOP:
+                            nBotLeft -= nSkew;
+                            nBotRight -= nSkew;
+                            break;
+                        default:
+                        {
+                            // added to avoid warnings
+                        }
                         }
 
                         Point aPoints[4];
-                        aPoints[0] = Point( nTopLeft, nTop );
-                        aPoints[1] = Point( nTopRight, nTop );
-                        aPoints[2] = Point( nBotRight, nBottom );
-                        aPoints[3] = Point( nBotLeft, nBottom );
+                        aPoints[0] = Point(nTopLeft, nTop);
+                        aPoints[1] = Point(nTopRight, nTop);
+                        aPoints[2] = Point(nBotRight, nBottom);
+                        aPoints[3] = Point(nBotLeft, nBottom);
 
                         const SvxBrushItem* pBackground = pInfo->pBackground;
                         if (!pBackground)
-                            pBackground = static_cast<const SvxBrushItem*>( &pPattern->GetItem(
-                                                ATTR_BACKGROUND, pCondSet ));
+                            pBackground = static_cast<const SvxBrushItem*>(&pPattern->GetItem(
+                                ATTR_BACKGROUND, pCondSet));
                         if (bCellContrast)
                         {
                             //  high contrast for cell borders and backgrounds -> empty background
                             pBackground = ScGlobal::GetEmptyBrushItem();
                         }
-                        if(!pInfo->pColorScale)
+                        if (!pInfo->pColorScale)
                         {
                             const Color& rColor = pBackground->GetColor();
-                            if ( rColor.GetTransparency() != 255 )
+                            if (rColor.GetTransparency() != 255)
                             {
                                 //  draw background only for the changed row itself
                                 //  (background doesn't extend into other cells).
                                 //  For the borders (rotated and normal), clipping should be
                                 //  set if the row isn't changed, but at least the borders
                                 //  don't cover the cell contents.
-                                if ( rThisRowInfo.bChanged )
+                                if (rThisRowInfo.bChanged)
                                 {
-                                    tools::Polygon aPoly( 4, aPoints );
+                                    tools::Polygon aPoly(4, aPoints);
 
                                     // for DrawPolygon, whitout Pen one pixel is left out
                                     // to the right and below...
-                                    if ( rColor.GetTransparency() == 0 )
+                                    if (rColor.GetTransparency() == 0)
                                         rRenderContext.SetLineColor(rColor);
                                     else
                                         rRenderContext.SetLineColor();
                                     rRenderContext.SetFillColor(rColor);
-                                    rRenderContext.DrawPolygon( aPoly );
+                                    rRenderContext.DrawPolygon(aPoly);
                                 }
                             }
                         }
                         else
                         {
-                            tools::Polygon aPoly( 4, aPoints );
+                            tools::Polygon aPoly(4, aPoints);
                             const Color* pColor = pInfo->pColorScale.get();
 
                             // for DrawPolygon, whitout Pen one pixel is left out
                             // to the right and below...
-                            if ( pColor->GetTransparency() == 0 )
+                            if (pColor->GetTransparency() == 0)
                                 rRenderContext.SetLineColor(*pColor);
                             else
                                 rRenderContext.SetLineColor();
                             rRenderContext.SetFillColor(*pColor);
-                            rRenderContext.DrawPolygon( aPoly );
+                            rRenderContext.DrawPolygon(aPoly);
 
                         }
-
-                        svx::frame::Style aTopLine, aBottomLine, aLeftLine, aRightLine;
-
-                        if ( nX < nX1 || nX > nX2 )     // Attributes in FillInfo not set
-                        {
-                            //! consider page borders for printing !!!!!
-                            const ::editeng::SvxBorderLine* pLeftLine;
-                            const ::editeng::SvxBorderLine* pTopLine;
-                            const ::editeng::SvxBorderLine* pRightLine;
-                            const ::editeng::SvxBorderLine* pBottomLine;
-                            mpDoc->GetBorderLines( nX, nY, nTab,
-                                    &pLeftLine, &pTopLine, &pRightLine, &pBottomLine );
-                            aTopLine.Set( pTopLine, mnPPTY );
-                            aBottomLine.Set( pBottomLine, mnPPTY );
-                            aLeftLine.Set( pLeftLine, mnPPTX );
-                            aRightLine.Set( pRightLine, mnPPTX );
-                        }
-                        else
-                        {
-                            size_t nCol = lclGetArrayColFromCellInfoX( nArrX, nX1, nX2, bLayoutRTL );
-                            aTopLine = rArray.GetCellStyleTop( nCol, nRow );
-                            aBottomLine = rArray.GetCellStyleBottom( nCol, nRow );
-                            aLeftLine = rArray.GetCellStyleLeft( nCol, nRow );
-                            aRightLine = rArray.GetCellStyleRight( nCol, nRow );
-                            // in RTL mode the array is already mirrored -> swap back left/right borders
-                            if( bLayoutRTL )
-                                std::swap( aLeftLine, aRightLine );
-                        }
-
-                        // Horizontal lines
-                        if (aTopLine.Prim() || aTopLine.Secn())
-                        {
-                            long nUpperRotate = lcl_getRotate( mpDoc, nTab, nX, nY - 1 );
-                            drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
-                            svx::frame::CreateBorderPrimitives(
-                                aSequence,
-                                aPoints[bLayoutRTL?1:0], aPoints[bLayoutRTL?0:1], aTopLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                aLeftLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                aRightLine,
-                                pForceColor, nUpperRotate, nAttrRotate );
-                            pProcessor->process(aSequence);
-                        }
-
-                        if (aBottomLine.Prim() || aBottomLine.Secn())
-                        {
-                            long nLowerRotate = lcl_getRotate( mpDoc, nTab, nX, nY + 1 );
-                            drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
-                            svx::frame::CreateBorderPrimitives(
-                                aSequence,
-                                aPoints[bLayoutRTL?2:3], aPoints[bLayoutRTL?3:2], aBottomLine,
-                                aLeftLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                aRightLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                pForceColor, 18000 - nAttrRotate, 18000 - nLowerRotate );
-                            pProcessor->process(aSequence);
-                        }
-
-                        // Vertical slanted lines
-                        if (aLeftLine.Prim() || aLeftLine.Secn())
-                        {
-                            long nLeftRotate = lcl_getRotate( mpDoc, nTab, nX - 1, nY );
-                            drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
-                            svx::frame::CreateBorderPrimitives(
-                                aSequence,
-                                aPoints[0], aPoints[3], aLeftLine,
-                                aTopLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                aBottomLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                pForceColor, nAttrRotate, nLeftRotate );
-                            pProcessor->process(aSequence);
-                        }
-
-                        if (aRightLine.Prim() || aRightLine.Secn())
-                        {
-                            long nRightRotate = lcl_getRotate( mpDoc, nTab, nX + 1, nY );
-                            drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
-                            svx::frame::CreateBorderPrimitives(
-                                aSequence,
-                                aPoints[1], aPoints[2], aRightLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                aTopLine,
-                                svx::frame::Style(),
-                                svx::frame::Style(),
-                                aBottomLine,
-                                pForceColor, 18000 - nRightRotate, 18000 - nAttrRotate );
-                            pProcessor->process(aSequence);
-                        }
                     }
                 }
                 nPosX += nColWidth * nLayoutSign;
             }
-
-            // delete the lines for normal output only afterwards in the second step
-
-            nX = nX1 > 0 ? (nX1-1) : static_cast<SCCOL>(0);
-            for (; nX<=nX2+1; nX++)         // visible part +- 1
-            {
-                sal_uInt16 nArrX = nX + 1;
-                CellInfo& rInfo = rThisRowInfo.pCellInfo[nArrX];
-                if ( rInfo.nRotateDir > ScRotateDir::Standard &&
-                        !rInfo.bHOverlapped && !rInfo.bVOverlapped )
-                {
-                    size_t nCol = lclGetArrayColFromCellInfoX( nArrX, nX1, nX2, bLayoutRTL );
-
-                    // horizontal: extend adjacent line
-                    // (only when the rotated cell has a border)
-                    ScRotateDir nDir = rInfo.nRotateDir;
-                    if ( rArray.GetCellStyleTop( nCol, nRow ).Prim() )
-                    {
-                        svx::frame::Style aStyle( lcl_FindHorLine( mpDoc, nX, nY, nTab, nDir, true ), mnPPTY );
-                        rArray.SetCellStyleTop( nCol, nRow, aStyle );
-                        if( nRow > 0 )
-                            rArray.SetCellStyleBottom( nCol, nRow - 1, aStyle );
-                    }
-                    if ( rArray.GetCellStyleBottom( nCol, nRow ).Prim() )
-                    {
-                        svx::frame::Style aStyle( lcl_FindHorLine( mpDoc, nX, nY, nTab, nDir, false ), mnPPTY );
-                        rArray.SetCellStyleBottom( nCol, nRow, aStyle );
-                        if( nRow + 1 < rArray.GetRowCount() )
-                            rArray.SetCellStyleTop( nCol, nRow + 1, aStyle );
-                    }
-
-                    // always remove vertical borders
-                    if( !rArray.IsMergedOverlappedLeft( nCol, nRow ) )
-                    {
-                        rArray.SetCellStyleLeft( nCol, nRow, svx::frame::Style() );
-                        if( nCol > 0 )
-                            rArray.SetCellStyleRight( nCol - 1, nRow, svx::frame::Style() );
-                    }
-                    if( !rArray.IsMergedOverlappedRight( nCol, nRow ) )
-                    {
-                        rArray.SetCellStyleRight( nCol, nRow, svx::frame::Style() );
-                        if( nCol + 1 < rArray.GetColCount() )
-                            rArray.SetCellStyleLeft( nCol + 1, nRow, svx::frame::Style() );
-                    }
-
-                    // remove diagonal borders
-                    rArray.SetCellStyleTLBR( nCol, nRow, svx::frame::Style() );
-                    rArray.SetCellStyleBLTR( nCol, nRow, svx::frame::Style() );
-                }
-            }
         }
         nPosY += nRowHeight;
     }
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 7191d2875910..7658a3765fe1 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -4632,8 +4632,10 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
 
     pEngine.reset();
 
-    if (bAnyRotated)
+    if (mrTabInfo.maArray.HasCellRotation())
+    {
         DrawRotated(bPixelToLogic);     //! call from outside ?
+    }
 }
 
 void ScOutputData::DrawRotated(bool bPixelToLogic)
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index 3dd1b5fa1e2b..c193285b1a25 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -44,146 +44,6 @@ namespace frame {
 
 namespace {
 
-typedef std::vector< Point > PointVec;
-
-
-// Link result structs for horizontal and vertical lines and borders.
-
-/** Result struct used by the horizontal/vertical frame link functions.
-
-    This struct is used to return coordinate offsets for one end of a single
-    line in a frame border, i.e. the left end of the primary line of a
-    horizontal frame border.
-
-    1) Usage for horizontal lines
-
-    If this struct is returned by the lclLinkHorFrameBorder() function, each
-    member refers to the X coordinate of one edge of a single line end in a
-    horizontal frame border. They specify an offset to modify this coordinate
-    when the line is painted. The values in this struct may change a
-    rectangular line shape into a line with slanted left or right border, which
-    is used to connect the line with diagonal lines.
-
-    Usage for a left line end:          Usage for a right line end:
-                mnOffs1                         mnOffs1
-                <------->                       <------->
-                    +-------------------------------+
-                    | the original horizontal line  |
-                    +-------------------------------+
-                <------->                       <------->
-                mnOffs2                         mnOffs2
-
-    2) Usage for vertical lines
-
-    If this struct is returned by the lclLinkVerFrameBorder() function, each
-    member refers to the Y coordinate of one edge of a single line end in a
-    vertical frame border. They specify an offset to modify this coordinate
-    when the line is painted. The values in this struct may change a
-    rectangular line shape into a line with slanted top or bottom border, which
-    is used to connect the line with diagonal lines.
-
-    Usage for a top line end:       mnOffs1 ^               ^ mnOffs2
-                                            |   +-------+   |
-                                            v   |       |   v
-                                                |       |
-                                                |       |
-                the original vertical line ---> |       |
-                                                |       |
-                                                |       |
-                                            ^   |       |   ^
-                                            |   +-------+   |
-    Usage for a bottom line end:    mnOffs1 v               v mnOffs2
- */
-struct LineEndResult
-{
-    long                mnOffs1;    /// Offset for top or left edge, dependent of context.
-    long                mnOffs2;    /// Offset for bottom or right edge, dependent of context
-
-    explicit     LineEndResult() : mnOffs1( 0 ), mnOffs2( 0 ) {}
-
-    void         Swap() { std::swap( mnOffs1, mnOffs2 ); }
-    void         Negate() { mnOffs1 = -mnOffs1; mnOffs2 = -mnOffs2; }
-};
-
-/** Result struct used by the horizontal/vertical frame link functions.
-
-    This struct contains the linking results for one end of a frame border,
-    including both the primary and secondary line ends.
- */
-struct BorderEndResult
-{
-    LineEndResult       maPrim;     /// Result for primary line.
-    LineEndResult       maSecn;     /// Result for secondary line.
-    LineEndResult       maGap;      /// Result for gap line.
-
-    void         Negate() { maPrim.Negate(); maSecn.Negate(); maGap.Negate(); }
-};
-
-/** Result struct used by the horizontal/vertical frame link functions.
-
-    This struct contains the linking results for both frame border ends, and
-    therefore for the complete frame border.
- */
-struct BorderResult
-{
-    BorderEndResult     maBeg;      /// Result for begin of border line (left or top end).
-    BorderEndResult     maEnd;      /// Result for end of border line (right or bottom end).
-};
-
-
-// Link result structs for diagonal lines and borders.
-
-/** Result struct used by the diagonal frame link functions.
-
-    This struct contains the linking results for one line of a diagonal frame
-    border.
- */
-struct DiagLineResult
-{
-    long                mnLClip;    /// Offset for left border of clipping rectangle.
-    long                mnRClip;    /// Offset for right border of clipping rectangle.
-    long                mnTClip;    /// Offset for top border of clipping rectangle.
-    long                mnBClip;    /// Offset for bottom border of clipping rectangle.
-
-    explicit     DiagLineResult() : mnLClip( 0 ), mnRClip( 0 ), mnTClip( 0 ), mnBClip( 0 ) {}
-};
-
-/** Result struct used by the diagonal frame link functions.
-
-    This struct contains the linking results for one diagonal frame border.
- */
-struct DiagBorderResult
-{
-    DiagLineResult      maPrim;     /// Result for primary line.
-    DiagLineResult      maSecn;     /// Result for secondary line.
-};
-
-/** Result struct used by the diagonal frame link functions.
-
-    This struct contains the linking results for both diagonal frame borders.
- */
-struct DiagBordersResult
-{
-    DiagBorderResult    maTLBR;     /// Result for top-left to bottom-right frame border.
-    DiagBorderResult    maBLTR;     /// Result for bottom-left to top-right frame border.
-};
-
-
-/** A helper struct containing two points of a line.
- */
-struct LinePoints
-{
-    Point               maBeg;      /// Start position of the line.
-    Point               maEnd;      /// End position of the line.
-
-    explicit            LinePoints( const Point& rBeg, const Point& rEnd ) :
-                            maBeg( rBeg ), maEnd( rEnd ) {}
-    explicit            LinePoints( const tools::Rectangle& rRect, bool bTLBR ) :
-                            maBeg( bTLBR ? rRect.TopLeft() : rRect.TopRight() ),
-                            maEnd( bTLBR ? rRect.BottomRight() : rRect.BottomLeft() ) {}
-};
-
-
 /** Rounds and casts a double value to a long value. */
 inline long lclD2L( double fValue )
 {
@@ -196,920 +56,6 @@ double lclScaleValue( double nValue, double fScale, sal_uInt16 nMaxWidth )
     return std::min<double>(nValue * fScale, nMaxWidth);
 }
 
-
-// Line width offset calculation.
-
-/** Returns the start offset of the single/primary line across the frame border.
-
-    All following lclGet*Beg() and lclGet*End() functions return sub units to
-    increase the computational accuracy, where 256 sub units are equal to
-    1 map unit of the used OutputDevice.
-
-    The following pictures show the upper end of a vertical frame border and
-    illustrates the return values of all following lclGet*Beg() and lclGet*End()
-    functions. The first picture shows a single frame border, the second picture
-    shows a double frame border.
-
-    The functions regard the reference point handling mode of the passed border
-    style.
-    RefMode::Centered:
-        All returned offsets are relative to the middle position of the frame
-        border (offsets left of the middle are returned negative, offsets right
-        of the middle are returned positive).
-    RefMode::Begin:
-        All returned offsets are relative to the begin of the frame border
-        (lclGetBeg() always returns 0).
-    RefMode::End:
-        All returned offsets are relative to the end of the frame border
-        (lclGetEnd() always returns 0).
-
-                                                        |<- lclGetEnd()
-                       |<- lclGetBeforeBeg()            |<- lclGetPrimEnd()
-                       |                                |
-                       ||<- lclGetBeg()                 ||<- lclGetBehindEnd()
-                       ||                               ||
-                       |#################################|
-       direction of |   #################################
-          the frame |   #################################
-          border is |   #################################
-           vertical |   #################################
-                    v   #################################
-                                        |
-                                        |<- middle of the frame border
-
-                                         lclGetDistEnd() ->||<- lclGetSecnBeg()
-                                                           ||
-          lclGetBeg() ->|   lclGetDistBeg() ->|            ||           |<- lclGetEnd()
-                        |                     |            ||           |
-    lclGetBeforeBeg()->||  lclGetPrimEnd() ->||            ||           ||<- lclGetBehindEnd()
-                       ||                    ||            ||           ||
-                       |######################|            |#############|
-       direction of |   ######################              #############
-          the frame |   ######################              #############
-          border is |   ######################              #############
-           vertical |   ######################  |           #############
-                    v   ######################  |           #############
-                        primary line            |           secondary line
-                                                |
-                                                |<- middle of the frame border
-
-    @return
-        The start offset of the single/primary line relative to the reference
-        position of the frame border (sub units; 0 for invisible or one pixel
-        wide single frame styles).
- */
-long lclGetBeg( const Style& rBorder )
-{
-    long nPos = 0;
-    switch( rBorder.GetRefMode() )
-    {
-        case RefMode::Centered:  if( rBorder.Prim() ) nPos = -128 * (rBorder.GetWidth() - 1); break;
-        case RefMode::End:       if( rBorder.Prim() ) nPos = -256 * (rBorder.GetWidth() - 1); break;
-        case RefMode::Begin:     break;
-    }
-    return nPos;
-}
-
-/** Returns the end offset of the single/secondary line across the frame border.
-    @descr  See description of lclGetBeg() for an illustration.
-    @return  The end offset of the single/secondary line relative to the
-    reference position of the frame border (sub units; 0 for invisible or one
-    pixel wide single frame styles). */
-long lclGetEnd( const Style& rBorder )
-{
-    long nPos = 0;
-    switch( rBorder.GetRefMode() )
-    {
-        case RefMode::Centered:  if( rBorder.Prim() ) nPos = 128 * (rBorder.GetWidth() - 1); break;
-        case RefMode::Begin:     if( rBorder.Prim() ) nPos = 256 * (rBorder.GetWidth() - 1); break;
-        case RefMode::End:     break;
-    }
-    return nPos;
-}
-
-/** Returns the end offset of the primary line across the frame border.
-    @descr  See description of lclGetBeg() for an illustration.
-    @return  The end offset of the primary line relative to the reference
-    position of the frame border (sub units; the end of the primary line in a
-    double frame style, otherwise the same as lclGetEnd()). */
-inline long lclGetPrimEnd( const Style& rBorder )
-{ return rBorder.Prim() ? (lclGetBeg( rBorder ) + 256 * (rBorder.Prim() - 1)) : 0; }
-
-/** Returns the start offset of the secondary line across the frame border.
-    @descr  See description of lclGetBeg() for an illustration.
-    @return  The start offset of the secondary line relative to the reference
-    position of the frame border (sub units; 0 for single/invisible border
-    styles). */
-inline long lclGetSecnBeg( const Style& rBorder )
-{ return rBorder.Secn() ? (lclGetEnd( rBorder ) - 256 * (rBorder.Secn() - 1)) : 0; }
-
-/** Returns the start offset of the distance space across the frame border.
-    @descr  See description of lclGetBeg() for an illustration.
-    @return  The start offset of the distance space relative to the reference
-    position of the frame border (sub units; 0 for single/invisible border
-    styles). */
-inline long lclGetDistBeg( const Style& rBorder )
-{ return rBorder.Secn() ? (lclGetBeg( rBorder ) + 256 * rBorder.Prim()) : 0; }
-
-/** Returns the end offset of the distance space across the frame border.
-    @descr  See description of lclGetBeg() for an illustration.
-    @return  The end offset of the distance space relative to the reference
-    position of the frame border (sub units; 0 for single/invisible border
-    styles). */
-inline long lclGetDistEnd( const Style& rBorder )
-{ return rBorder.Secn() ? (lclGetEnd( rBorder ) - 256 * rBorder.Secn()) : 0; }
-
-/** Returns the offset before start of single/primary line across the frame border.
-    @descr  See description of lclGetBeg() for an illustration.
-    @return  The offset directly before start of single/primary line relative
-    to the reference position of the frame border (sub units; a value one less
-    than lclGetBeg() for visible frame styles, or 0 for invisible frame style). */
-inline long lclGetBeforeBeg( const Style& rBorder )
-{ return rBorder.Prim() ? (lclGetBeg( rBorder ) - 256) : 0; }
-
-/** Returns the offset behind end of single/secondary line across the frame border.
-    @descr  See description of lclGetBeg() for an illustration.
-    @return  The offset directly behind end of single/secondary line relative
-    to the reference position of the frame border (sub units; a value one
-    greater than lclGetEnd() for visible frame styles, or 0 for invisible frame
-    style). */
-inline long lclGetBehindEnd( const Style& rBorder )
-{ return rBorder.Prim() ? (lclGetEnd( rBorder ) + 256) : 0; }
-
-
-// Linking functions
-
-
-// Linking of single horizontal line ends.
-
-/** Calculates X offsets for the left end of a single horizontal frame border.
-
-    See DrawHorFrameBorder() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for the
-        X coordinates of the left line end.
- */
-void lclLinkLeftEnd_Single(
-        LineEndResult& rResult, const Style& rBorder,
-        const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR )
-{
-    // both vertical and diagonal frame borders are double
-    if( rLFromT.Secn() && rLFromB.Secn() && rLFromTR.Secn() && rLFromBR.Secn() )
-    {
-        // take left position of upper and lower secondary start
-        rResult.mnOffs1 = GetBLDiagOffset( lclGetBeg( rBorder ), lclGetSecnBeg( rLFromTR ), rLFromTR.GetAngle() );
-        rResult.mnOffs2 = GetTLDiagOffset( lclGetEnd( rBorder ), lclGetSecnBeg( rLFromBR ), rLFromBR.GetAngle() );
-    }
-    else
-    {
-        // both vertical frame borders are double
-        if( rLFromT.Secn() && rLFromB.Secn() )
-        {
-            rResult.mnOffs1 = (!rLFromTR.Secn() && !rLFromBR.Secn() && rtl::math::approxEqual(rLFromT.GetWidth(), rLFromB.GetWidth())) ?
-                // don't overdraw vertical borders with equal width
-                lclGetBehindEnd( rLFromT ) :
-                // take leftmost start of both secondary lines (#46488#)
-                std::min( lclGetSecnBeg( rLFromT ), lclGetSecnBeg( rLFromB ) );
-        }
-
-        // single border with equal width coming from left
-        else if( !rLFromL.Secn() && rtl::math::approxEqual(rLFromL.Prim(), rBorder.Prim()) )
-            // draw to connection point
-            rResult.mnOffs1 = 0;
-
-        // single border coming from left
-        else if( !rLFromL.Secn() && rLFromL.Prim() )
-        {
-            if( rtl::math::approxEqual(rLFromL.Prim(), rBorder.Prim()) )
-                // draw to reference position, if from left has equal width
-                rResult.mnOffs1 = 0;
-            else
-                rResult.mnOffs1 = (rLFromL < rBorder) ?
-                    // take leftmost start of both frame borders, if from left is thinner
-                    std::min( lclGetBeg( rLFromT ), lclGetBeg( rLFromB ) ) :
-                    // do not overdraw vertical, if from left is thicker
-                    std::max( lclGetBehindEnd( rLFromT ), lclGetBehindEnd( rLFromB ) );
-        }
-
-        // no border coming from left
-        else if( !rLFromL.Prim() )
-            // don't overdraw vertical borders with equal width
-            rResult.mnOffs1 = rtl::math::approxEqual(rLFromT.GetWidth(), rLFromB.GetWidth()) ?
-                lclGetBehindEnd( rLFromT ) :
-                std::min( lclGetBeg( rLFromT ), lclGetBeg( rLFromB ) );
-
-        // double frame border coming from left and from top
-        else if( rLFromT.Secn() )
-            // do not overdraw the vertical double frame border
-            rResult.mnOffs1 = lclGetBehindEnd( rLFromT );
-
-        // double frame border coming from left and from bottom
-        else if( rLFromB.Secn() )
-            // do not overdraw the vertical double frame border
-            rResult.mnOffs1 = lclGetBehindEnd( rLFromB );
-
-        // double frame border coming from left, both vertical frame borders are single or off
-        else
-            // draw from leftmost start of both frame borders, if from left is not thicker
-            rResult.mnOffs1 = (rLFromL <= rBorder) ?
-                std::min( lclGetBeg( rLFromT ), lclGetBeg( rLFromB ) ) :
-                std::max( lclGetBehindEnd( rLFromT ), lclGetBehindEnd( rLFromB ) );
-
-        // bottom-left point is equal to top-left point (results in rectangle)
-        rResult.mnOffs2 = rResult.mnOffs1;
-    }
-}
-
-/** Calculates X offsets for the left end of a primary horizontal line.
-
-    See DrawHorFrameBorder() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for the
-        X coordinates of the left end of the primary line.
- */
-void lclLinkLeftEnd_Prim(
-        LineEndResult& rResult, const Style& rBorder,
-        const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& /*rLFromBR*/ )
-{
-    // double diagonal frame border coming from top right
-    if( rLFromTR.Secn() )
-    {
-        // draw from where secondary diagonal line meets the own primary
-        rResult.mnOffs1 = GetBLDiagOffset( lclGetBeg( rBorder ), lclGetSecnBeg( rLFromTR ), rLFromTR.GetAngle() );
-        rResult.mnOffs2 = GetBLDiagOffset( lclGetPrimEnd( rBorder ), lclGetSecnBeg( rLFromTR ), rLFromTR.GetAngle() );
-    }
-
-    // no or single diagonal frame border - ignore it
-    else
-    {
-        // double frame border coming from top
-        if( rLFromT.Secn() )
-            // draw from left edge of secondary vertical
-            rResult.mnOffs1 = lclGetSecnBeg( rLFromT );
-
-        // double frame border coming from left (from top is not double)
-        else if( rLFromL.Secn() )
-            // do not overdraw single frame border coming from top
-            rResult.mnOffs1 = rtl::math::approxEqual(rLFromL.GetWidth(), rBorder.GetWidth()) ?
-                0 : lclGetBehindEnd( rLFromT );
-
-        // double frame border coming from bottom (from top and from left are not double)
-        else if( rLFromB.Secn() )
-            // draw from left edge of primary vertical from bottom
-            rResult.mnOffs1 = lclGetBeg( rLFromB );
-
-        // no other frame border is double
-        else
-            // do not overdraw vertical frame borders
-            rResult.mnOffs1 = std::max( lclGetBehindEnd( rLFromT ), lclGetBehindEnd( rLFromB ) );
-
-        // bottom-left point is equal to top-left point (results in rectangle)
-        rResult.mnOffs2 = rResult.mnOffs1;
-    }
-}
-
-/** Calculates X offsets for the left end of a secondary horizontal line.
-
-    See DrawHorFrameBorder() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for the
-        X coordinates of the left end of the secondary line.
- */
-void lclLinkLeftEnd_Secn(
-        LineEndResult& rResult, const Style& rBorder,
-        const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR )
-{
-    /*  Recycle lclLinkLeftEnd_Prim() function with mirrored horizontal borders. */
-    lclLinkLeftEnd_Prim( rResult, rBorder.Mirror(), rLFromBR, rLFromB, rLFromL.Mirror(), rLFromT, rLFromTR );
-    rResult.Swap();
-}
-
-void lclLinkLeftEnd_Gap(
-        LineEndResult& rResult, const Style& rBorder,
-        const DiagStyle& /*rLFromTR*/, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& /*rLFromBR*/ )
-
-{
-    if ( rLFromT.Secn() )
-        rResult.mnOffs1 = lclGetDistBeg( rLFromT );
-    else if ( rLFromL.Secn( ) )
-        rResult.mnOffs1 = rtl::math::approxEqual( rLFromL.GetWidth(), rBorder.GetWidth() ) ?
-            0 : lclGetBehindEnd( rLFromT );
-    else if ( rLFromB.Secn( ) )
-        rResult.mnOffs1 = lclGetDistBeg( rLFromB );
-    else
-        rResult.mnOffs1 = std::max( lclGetBehindEnd( rLFromT ), lclGetBehindEnd( rLFromB ) );
-
-    rResult.mnOffs2 = rResult.mnOffs1;
-}
-
-// Linking of horizontal frame border ends.
-
-/** Calculates X offsets for the left end of a horizontal frame border.
-
-    This function can be used for single and double frame borders.
-    See DrawHorFrameBorder() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for the
-        X coordinates of the left end of the line(s) in the frame border.
- */
-void lclLinkLeftEnd(
-        BorderEndResult& rResult, const Style& rBorder,
-        const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR )
-{
-    if( rBorder.Secn() )
-    {
-        // current frame border is double
-        lclLinkLeftEnd_Prim( rResult.maPrim, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
-        lclLinkLeftEnd_Secn( rResult.maSecn, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
-        lclLinkLeftEnd_Gap( rResult.maGap, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
-    }
-    else if( rBorder.Prim() )
-    {
-        // current frame border is single
-        lclLinkLeftEnd_Single( rResult.maPrim, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
-    }
-    else
-    {
-        SAL_WARN( "svx.dialog", "lclLinkLeftEnd - called for invisible frame style" );
-    }
-}
-
-/** Calculates X offsets for the right end of a horizontal frame border.
-
-    This function can be used for single and double frame borders.
-    See DrawHorFrameBorder() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for the
-        X coordinates of the right end of the line(s) in the frame border.
- */
-void lclLinkRightEnd(
-        BorderEndResult& rResult, const Style& rBorder,
-        const DiagStyle& rRFromTL, const Style& rRFromT, const Style& rRFromR, const Style& rRFromB, const DiagStyle& rRFromBL )
-{
-    /*  Recycle lclLinkLeftEnd() function with mirrored vertical borders. */
-    lclLinkLeftEnd( rResult, rBorder, rRFromTL.Mirror(), rRFromT.Mirror(), rRFromR, rRFromB.Mirror(), rRFromBL.Mirror() );
-    rResult.Negate();
-}
-
-
-// Linking of horizontal and vertical frame borders.
-
-/** Calculates X offsets for all line ends of a horizontal frame border.
-
-    This function can be used for single and double frame borders.
-    See DrawHorFrameBorder() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for the
-        X coordinates of both ends of the line(s) in the frame border. To get
-        the actual X coordinates to draw the lines, these offsets have to be
-        added to the X coordinates of the reference points of the frame border
-        (the offsets may be negative).
- */
-void lclLinkHorFrameBorder(
-        BorderResult& rResult, const Style& rBorder,
-        const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR,
-        const DiagStyle& rRFromTL, const Style& rRFromT, const Style& rRFromR, const Style& rRFromB, const DiagStyle& rRFromBL )
-{
-    lclLinkLeftEnd( rResult.maBeg, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
-    lclLinkRightEnd( rResult.maEnd, rBorder, rRFromTL, rRFromT, rRFromR, rRFromB, rRFromBL );
-}
-
-/** Calculates Y offsets for all line ends of a vertical frame border.
-
-    This function can be used for single and double frame borders.
-    See DrawVerFrameBorder() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for the
-        Y coordinates of both ends of the line(s) in the frame border. To get
-        the actual Y coordinates to draw the lines, these offsets have to be
-        added to the Y coordinates of the reference points of the frame border
-        (the offsets may be negative).
- */
-void lclLinkVerFrameBorder(
-        BorderResult& rResult, const Style& rBorder,
-        const DiagStyle& rTFromBL, const Style& rTFromL, const Style& rTFromT, const Style& rTFromR, const DiagStyle& rTFromBR,
-        const DiagStyle& rBFromTL, const Style& rBFromL, const Style& rBFromB, const Style& rBFromR, const DiagStyle& rBFromTR )
-{
-    /*  Recycle lclLinkHorFrameBorder() function with correct parameters. The
-        frame border is virtually mirrored at the top-left to bottom-right
-        diagonal. rTFromBR and rBFromTL are mirrored to process their primary
-        and secondary lines correctly. */
-    lclLinkHorFrameBorder( rResult, rBorder,
-        rTFromBL, rTFromL, rTFromT, rTFromR, rTFromBR.Mirror(),
-        rBFromTL.Mirror(), rBFromL, rBFromB, rBFromR, rBFromTR );
-}
-
-
-// Linking of diagonal frame borders.
-
-/** Calculates clipping offsets for a top-left to bottom-right frame border.
-
-    This function can be used for single and double frame borders.
-    See DrawDiagFrameBorders() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for all
-        borders of the reference rectangle containing the diagonal frame border.
- */
-void lclLinkTLBRFrameBorder(
-        DiagBorderResult& rResult, const Style& rBorder,
-        const Style& rTLFromB, const Style& rTLFromR, const Style& rBRFromT, const Style& rBRFromL )
-{
-    bool bIsDbl = rBorder.Secn() != 0;
-
-    rResult.maPrim.mnLClip = lclGetBehindEnd( rTLFromB );
-    rResult.maPrim.mnRClip = (bIsDbl && rBRFromT.Secn()) ? lclGetEnd( rBRFromT ) : lclGetBeforeBeg( rBRFromT );
-    rResult.maPrim.mnTClip = (bIsDbl && rTLFromR.Secn()) ? lclGetBeg( rTLFromR ) : lclGetBehindEnd( rTLFromR );
-    rResult.maPrim.mnBClip = lclGetBeforeBeg( rBRFromL );
-
-    if( bIsDbl )
-    {
-        rResult.maSecn.mnLClip = rTLFromB.Secn() ? lclGetBeg( rTLFromB ) : lclGetBehindEnd( rTLFromB );
-        rResult.maSecn.mnRClip = lclGetBeforeBeg( rBRFromT );
-        rResult.maSecn.mnTClip = lclGetBehindEnd( rTLFromR );
-        rResult.maSecn.mnBClip = rBRFromL.Secn() ? lclGetEnd( rBRFromL ) : lclGetBeforeBeg( rBRFromL );
-    }
-}
-
-/** Calculates clipping offsets for a bottom-left to top-right frame border.
-
-    This function can be used for single and double frame borders.
-    See DrawDiagFrameBorders() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for all
-        borders of the reference rectangle containing the diagonal frame border.
- */
-void lclLinkBLTRFrameBorder(
-        DiagBorderResult& rResult, const Style& rBorder,
-        const Style& rBLFromT, const Style& rBLFromR, const Style& rTRFromB, const Style& rTRFromL )
-{
-    bool bIsDbl = rBorder.Secn() != 0;
-
-    rResult.maPrim.mnLClip = lclGetBehindEnd( rBLFromT );
-    rResult.maPrim.mnRClip = (bIsDbl && rTRFromB.Secn()) ? lclGetEnd( rTRFromB ) : lclGetBeforeBeg( rTRFromB );
-    rResult.maPrim.mnTClip = lclGetBehindEnd( rTRFromL );
-    rResult.maPrim.mnBClip = (bIsDbl && rBLFromR.Secn()) ? lclGetEnd( rBLFromR ) : lclGetBeforeBeg( rBLFromR );
-
-    if( bIsDbl )
-    {
-        rResult.maSecn.mnLClip = rBLFromT.Secn() ? lclGetBeg( rBLFromT ) : lclGetBehindEnd( rBLFromT );
-        rResult.maSecn.mnRClip = lclGetBeforeBeg( rTRFromB );
-        rResult.maSecn.mnTClip = rTRFromL.Secn() ? lclGetBeg( rTRFromL ) : lclGetBehindEnd( rTRFromL );
-        rResult.maSecn.mnBClip = lclGetBeforeBeg( rBLFromR );
-    }
-}
-
-/** Calculates clipping offsets for both diagonal frame borders.
-
-    This function can be used for single and double frame borders.
-    See DrawDiagFrameBorders() function for a description of all parameters.
-
-    @param rResult
-        (out-param) The contained values (sub units) specify offsets for all
-        borders of the reference rectangle containing the diagonal frame
-        borders.
- */
-void lclLinkDiagFrameBorders(
-        DiagBordersResult& rResult, const Style& rTLBR, const Style& rBLTR,
-        const Style& rTLFromB, const Style& rTLFromR, const Style& rBRFromT, const Style& rBRFromL,
-        const Style& rBLFromT, const Style& rBLFromR, const Style& rTRFromB, const Style& rTRFromL )
-{
-    lclLinkTLBRFrameBorder( rResult.maTLBR, rTLBR, rTLFromB, rTLFromR, rBRFromT, rBRFromL );
-    lclLinkBLTRFrameBorder( rResult.maBLTR, rBLTR, rBLFromT, rBLFromR, rTRFromB, rTRFromL );
-}
-
-
-// Drawing functions
-
-
-// Simple helper functions
-
-/** Converts sub units to OutputDevice map units. */
-inline long lclToMapUnit( long nSubUnits )
-{
-    return ((nSubUnits < 0) ? (nSubUnits - 127) : (nSubUnits + 128)) / 256;
-}
-
-/** Converts a point in sub units to an OutputDevice point. */
-inline Point lclToMapUnit( long nSubXPos, long nSubYPos )
-{
-    return Point( lclToMapUnit( nSubXPos ), lclToMapUnit( nSubYPos ) );
-}
-
-/** Returns a polygon constructed from a vector of points. */
-inline tools::Polygon lclCreatePolygon( const PointVec& rPoints )
-{
-    return tools::Polygon( static_cast< sal_uInt16 >( rPoints.size() ), &rPoints[ 0 ] );
-}
-
-/** Returns a polygon constructed from the five passed points. */
-vcl::Region lclCreatePolygon( const Point& rP1, const Point& rP2, const Point& rP3, const Point& rP4, const Point& rP5 )
-{
-    PointVec aPoints;
-    aPoints.reserve( 5 );
-    aPoints.push_back( rP1 );
-    aPoints.push_back( rP2 );
-    aPoints.push_back( rP3 );
-    aPoints.push_back( rP4 );
-    aPoints.push_back( rP5 );
-    return vcl::Region(lclCreatePolygon(aPoints));
-}
-
-/** Sets the color of the passed frame style to the output device.
-
-    Sets the line color and fill color in the output device.
-
-    @param rDev
-        The output device the color has to be set to. The old colors are pushed
-        onto the device's stack and can be restored with a call to
-        OutputDevice::Pop(). Please take care about the correct calling order
-        of Pop() if this function is used with other functions pushing
-        something onto the stack.
-    @param rStyle
-        The border style that contains the line color to be set to the device.
- */
-void lclSetColorToOutDev( OutputDevice& rDev, const Color& rColor, const Color* pForceColor )
-{
-    rDev.Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
-    rDev.SetLineColor( pForceColor ? *pForceColor : rColor );
-    rDev.SetFillColor( pForceColor ? *pForceColor : rColor );
-}
-
-
-// Drawing of horizontal frame borders.
-
-/** Draws a horizontal thin or thick line into the passed output device.
-
-    The X coordinates of the edges of the line are adjusted according to the
-    passed LineEndResult structs. A one pixel wide line can be drawn dotted.
- */
-void lclDrawHorLine(
-        OutputDevice& rDev,
-        const Point& rLPos, const LineEndResult& rLRes,
-        const Point& rRPos, const LineEndResult& rRRes,
-        long nTOffs, long nBOffs, SvxBorderLineStyle nDashing )
-{
-    LinePoints aTPoints( rLPos + lclToMapUnit( rLRes.mnOffs1, nTOffs ), rRPos + lclToMapUnit( rRRes.mnOffs1, nTOffs ) );
-    LinePoints aBPoints( rLPos + lclToMapUnit( rLRes.mnOffs2, nBOffs ), rRPos + lclToMapUnit( rRRes.mnOffs2, nBOffs ) );
-
-    sal_uInt32 nWidth = lclToMapUnit( std::abs( nTOffs ) ) + lclToMapUnit( std::abs( nBOffs ) );
-    if ( ( nTOffs >= 0 && nBOffs >= 0 ) || ( nTOffs <= 0 && nBOffs <= 0 ) )
-        nWidth = std::abs( lclToMapUnit( nTOffs ) - lclToMapUnit( nBOffs ) ) + 1;
-    Point rLMid = ( aTPoints.maBeg + aBPoints.maBeg ) / 2;
-    Point rRMid = ( aTPoints.maEnd + aBPoints.maEnd ) / 2;
-
-    ::svtools::DrawLine( rDev, rLMid, rRMid, nWidth, nDashing );
-}
-
-/** Draws a horizontal frame border into the passed output device.
-
-    @param rLPos
-        The top-left or bottom-left reference point of the diagonal frame border.
-    @param rRPos
-        The top-right or bottom-right reference point of the diagonal frame border.
-    @param rBorder
-        The frame style used to draw the border.
-    @param rResult
-        The X coordinates of the edges of all lines of the frame border are
-        adjusted according to the offsets contained here.
- */
-void lclDrawHorFrameBorder(
-        OutputDevice& rDev, const Point& rLPos, const Point& rRPos,
-        const Style& rBorder, const BorderResult& rResult, const Color* pForceColor )
-{
-    DBG_ASSERT( rBorder.Prim(), "svx::frame::lclDrawHorFrameBorder - line not visible" );
-    DBG_ASSERT( rLPos.X() <= rRPos.X(), "svx::frame::lclDrawHorFrameBorder - wrong order of line ends" );
-    DBG_ASSERT( rLPos.Y() == rRPos.Y(), "svx::frame::lclDrawHorFrameBorder - line not horizontal" );
-    if( rLPos.X() <= rRPos.X() )
-    {
-        if ( rBorder.UseGapColor( ) )
-        {
-            lclSetColorToOutDev( rDev, rBorder.GetColorGap(), pForceColor );
-            lclDrawHorLine( rDev, rLPos, rResult.maBeg.maGap, rRPos, rResult.maEnd.maGap,
-                   lclGetPrimEnd( rBorder ), lclGetSecnBeg( rBorder ), rBorder.Type() );
-            rDev.Pop(); // Gap color
-        }
-
-        lclSetColorToOutDev( rDev, rBorder.GetColorPrim(), pForceColor );
-        lclDrawHorLine( rDev, rLPos, rResult.maBeg.maPrim, rRPos, rResult.maEnd.maPrim,
-            lclGetBeg( rBorder ), lclGetPrimEnd( rBorder ), rBorder.Type() );
-        rDev.Pop(); // colors
-
-        if( rBorder.Secn() )
-        {
-            lclSetColorToOutDev( rDev, rBorder.GetColorSecn(), pForceColor );
-            lclDrawHorLine( rDev, rLPos, rResult.maBeg.maSecn, rRPos, rResult.maEnd.maSecn,
-                lclGetSecnBeg( rBorder ), lclGetEnd( rBorder ), rBorder.Type() );
-            rDev.Pop(); // colors
-        }
-    }
-}
-
-
-// Drawing of vertical frame borders.
-
-/** Draws a vertical thin or thick line into the passed output device.
-
-    The Y coordinates of the edges of the line are adjusted according to the
-    passed LineEndResult structs. A one pixel wide line can be drawn dotted.
- */
-void lclDrawVerLine(
-        OutputDevice& rDev,
-        const Point& rTPos, const LineEndResult& rTRes,
-        const Point& rBPos, const LineEndResult& rBRes,
-        long nLOffs, long nROffs, SvxBorderLineStyle nDashing )
-{
-    LinePoints aLPoints( rTPos + lclToMapUnit( nLOffs, rTRes.mnOffs1 ), rBPos + lclToMapUnit( nLOffs, rBRes.mnOffs1 ) );
-    LinePoints aRPoints( rTPos + lclToMapUnit( nROffs, rTRes.mnOffs2 ), rBPos + lclToMapUnit( nROffs, rBRes.mnOffs2 ) );
-
-    sal_uInt32 nWidth = lclToMapUnit( std::abs( nLOffs ) ) + lclToMapUnit( std::abs( nROffs ) );
-    if ( ( nLOffs >= 0 && nROffs >= 0 ) || ( nLOffs <= 0 && nROffs <= 0 ) )
-        nWidth = std::abs( lclToMapUnit( nLOffs ) - lclToMapUnit( nROffs ) ) + 1;
-    Point rTMid = ( aLPoints.maBeg + aRPoints.maBeg ) / 2;
-    Point rBMid = ( aLPoints.maEnd + aRPoints.maEnd ) / 2;
-
-    ::svtools::DrawLine( rDev, rTMid, rBMid, nWidth, nDashing );
-}
-
-/** Draws a vertical frame border into the passed output device.
-
-    @param rTPos
-        The top-left or top-right reference point of the diagonal frame border.
-    @param rBPos
-        The bottom-left or bottom-right reference point of the diagonal frame border.
-    @param rBorder
-        The frame style used to draw the border.
-    @param rResult
-        The Y coordinates of the edges of all lines of the frame border are
-        adjusted according to the offsets contained here.
- */
-void lclDrawVerFrameBorder(
-        OutputDevice& rDev, const Point& rTPos, const Point& rBPos,
-        const Style& rBorder, const BorderResult& rResult, const Color* pForceColor )
-{
-    DBG_ASSERT( rBorder.Prim(), "svx::frame::lclDrawVerFrameBorder - line not visible" );
-    DBG_ASSERT( rTPos.Y() <= rBPos.Y(), "svx::frame::lclDrawVerFrameBorder - wrong order of line ends" );
-    DBG_ASSERT( rTPos.X() == rBPos.X(), "svx::frame::lclDrawVerFrameBorder - line not vertical" );
-    if( rTPos.Y() <= rBPos.Y() )
-    {
-        if ( rBorder.UseGapColor( ) )
-        {
-            lclSetColorToOutDev( rDev, rBorder.GetColorGap(), pForceColor );
-            lclDrawVerLine( rDev, rTPos, rResult.maBeg.maGap, rBPos, rResult.maEnd.maGap,
-                   lclGetPrimEnd( rBorder ), lclGetSecnBeg( rBorder ), rBorder.Type() );
-            rDev.Pop(); // Gap color
-        }
-
-        lclSetColorToOutDev( rDev, rBorder.GetColorPrim(), pForceColor );
-        lclDrawVerLine( rDev, rTPos, rResult.maBeg.maPrim, rBPos, rResult.maEnd.maPrim,
-            lclGetBeg( rBorder ), lclGetPrimEnd( rBorder ), rBorder.Type() );
-        rDev.Pop(); // colors
-        if( rBorder.Secn() )
-        {
-            lclSetColorToOutDev( rDev, rBorder.GetColorSecn(), pForceColor );
-            lclDrawVerLine( rDev, rTPos, rResult.maBeg.maSecn, rBPos, rResult.maEnd.maSecn,
-                lclGetSecnBeg( rBorder ), lclGetEnd( rBorder ), rBorder.Type() );
-            rDev.Pop(); // colors
-        }
-    }
-}
-
-
-// Drawing of diagonal frame borders, includes clipping functions.
-
-/** Returns the drawing coordinates for a diagonal thin line.
-
-    This function can be used for top-left to bottom-right and for bottom-left
-    to top-right lines.
-
-    @param rRect
-        The reference rectangle of the diagonal frame border.
-    @param bTLBR
-        true = top-left to bottom-right; false = bottom-left to top-right.
-    @param nDiagOffs
-        Width offset (sub units) across the diagonal frame border.
-    @return
-        A struct containg start and end position of the diagonal line.
- */
-LinePoints lclGetDiagLineEnds( const tools::Rectangle& rRect, bool bTLBR, long nDiagOffs )
-{
-    LinePoints aPoints( rRect, bTLBR );
-    bool bVert = rRect.GetWidth() < rRect.GetHeight();
-    double fAngle = bVert ? GetVerDiagAngle( rRect ) : GetHorDiagAngle( rRect );
-    // vertical top-left to bottom-right borders are handled mirrored
-    if( bVert && bTLBR )
-        nDiagOffs = -nDiagOffs;
-    long nTOffs = bTLBR ? GetTLDiagOffset( 0, nDiagOffs, fAngle ) : GetTRDiagOffset( nDiagOffs, fAngle );
-    long nBOffs = bTLBR ? GetBRDiagOffset( nDiagOffs, fAngle ) : GetBLDiagOffset( 0, nDiagOffs, fAngle );
-    // vertical bottom-left to top-right borders are handled with exchanged end points
-    if( bVert && !bTLBR )
-        std::swap( nTOffs, nBOffs );
-    (bVert ? aPoints.maBeg.Y() : aPoints.maBeg.X()) += lclToMapUnit( nTOffs );
-    (bVert ? aPoints.maEnd.Y() : aPoints.maEnd.X()) += lclToMapUnit( nBOffs );
-    return aPoints;
-}
-
-
-// Clipping functions for diagonal frame borders.
-
-/** Limits the clipping region to the inner area of a rectangle.
-
-    Takes the values from the passed DiagLineResult struct into account. They
-    may specify to not clip one or more borders of a rectangle.
-
-    @param rDev
-        The output device with the clipping region to be modified. The old
-        clipping region is pushed onto the device's stack and can be restored
-        with a call to OutputDevice::Pop(). Please take care about the correct
-        calling order of Pop() if this function is used with other functions
-        pushing something onto the stack.
-    @param rRect
-        The reference rectangle of the diagonal frame borders.
-    @param rResult
-        The result struct containing modifies for each border of the reference
-        rectangle.
- */
-void lclPushDiagClipRect( OutputDevice& rDev, const tools::Rectangle& rRect, const DiagLineResult& rResult )
-{
-    // PixelToLogic() regards internal offset of the output device
-    tools::Rectangle aClipRect( rRect );
-    aClipRect.Left()   += lclToMapUnit( rResult.mnLClip );
-    aClipRect.Top()    += lclToMapUnit( rResult.mnTClip );
-    aClipRect.Right()  += lclToMapUnit( rResult.mnRClip );
-    aClipRect.Bottom() += lclToMapUnit( rResult.mnBClip );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list