include/vcl/vclenum.hxx                |    7 +++++--
 toolkit/source/controls/unocontrol.cxx |    5 +++++
 vcl/source/window/brdwin.cxx           |    2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 001c0934aab5c33b37a75798deb84c20b4b9d365
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Aug 1 15:58:21 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 2 18:33:32 2024 +0200

    tdf#155636 tdf#155637 tdf#156962 Consistently use non-native controls
    
    Since
    
        commit ea36e0502c0bc381577cfa1b1a7fedf0f05d1d72
        Date:   Tue Oct 4 12:42:33 2022 +0100
    
            tdf#150786 use a 'standard' theme for form controls
    
            i.e. ignore system theme so we get the same results on export to pdf
            regardless of the theme (esp dark) and don't follow the system theme
            when hosted with a writer/calc/impress document (do continue to use
            system theme for StarBasic dialogs as seen in BasicIDE)
    
            Didn't reuse 'NativeWidgetLook' for this because is currently 
defaults
            off, while we currently do use the colors derived from the system 
theme
            even when this is off, its really the NWF flag to render using the
            platform theming engine
    
    , form controls in Writer/Calc/Impress documents are
    supposed to no longer make use of the system theme,
    but use style settings independent of the platform
    and system style/theme set.
    
    However, `ImplSmallBorderWindowView::Init` could still
    decide to enable native drawing of borders, in which case
    it would enable transparency for the control and the control
    background color would no longer be seen with at least the Qt-based
    VCL plugins after
    
        commit 0e14dbc9ecdf6abae3ae3089e3b4e22f27dd4cb1
        Date:   Thu May 4 10:24:53 2023 +0100
    
            Resolves: tdf#155029 set StandardStyles before updateFromModel
    
    e.g. for the multiline edit control in attachment 195659
    from tdf#155637, where `mbNWFBorder = true;` would be set like this:
    
        #0  ImplSmallBorderWindowView::Init(OutputDevice*, long, long) 
(this=0x55af6388e700, pDev=0x55af62d49770, nWidth=214, nHeight=365) at 
vcl/source/window/brdwin.cxx:458
        #1  0x00007fed4de9f168 in ImplBorderWindow::InitView() 
(this=0x55af638bdb50) at vcl/source/window/brdwin.cxx:1793
        #2  0x00007fed4dea08f4 in ImplBorderWindow::UpdateView(bool, Size 
const&) (this=0x55af638bdb50, bNewView=true, rNewOutSize=Size = {...}) at 
vcl/source/window/brdwin.cxx:1808
        #3  0x00007fed4dea0847 in 
ImplBorderWindow::DataChanged(DataChangedEvent const&) (this=0x55af638bdb50, 
rDCEvt=...) at vcl/source/window/brdwin.cxx:1771
        #4  0x00007fed4de6fc32 in 
vcl::WindowOutputDevice::SetSettings(AllSettings const&, bool) 
(this=0x55af62d49770, rSettings=..., bChild=false) at 
vcl/source/window/settings.cxx:68
        #5  0x00007fed4de6fb19 in 
vcl::WindowOutputDevice::SetSettings(AllSettings const&, bool) 
(this=0x55af62d49420, rSettings=..., bChild=false) at 
vcl/source/window/settings.cxx:52
        #6  0x00007fed4de6fa8f in 
vcl::WindowOutputDevice::SetSettings(AllSettings const&) (this=0x55af62d49420, 
rSettings=...) at vcl/source/window/settings.cxx:44
        #7  0x00007fed4e12d376 in vcl::Window::SetSettings(AllSettings const&) 
(this=0x55af62fbb530, rSettings=...) at vcl/source/window/window3.cxx:209
        #8  0x00007fed501e3374 in 
UnoControl::createPeer(com::sun::star::uno::Reference<com::sun::star::awt::XToolkit>
 const&, com::sun::star::uno::Reference<com::sun::star::awt::XWindowPeer> 
const&)
            (this=0x55af62c79380, rxToolkit=empty uno::Reference, 
rParentPeer=uno::Reference to (VCLXContainer *) 0x55af61cbc178) at 
toolkit/source/controls/unocontrol.cxx:1299
        #9  0x00007fed5023dc39 in 
UnoEditControl::createPeer(com::sun::star::uno::Reference<com::sun::star::awt::XToolkit>
 const&, com::sun::star::uno::Reference<com::sun::star::awt::XWindowPeer> 
const&)
            (this=0x55af62c79380, rxToolkit=empty uno::Reference, 
rParentPeer=uno::Reference to (VCLXContainer *) 0x55af61cbc178) at 
toolkit/source/controls/unocontrols.cxx:241
        #10 0x00007fed05f6009f in 
frm::ORichTextControl::createPeer(com::sun::star::uno::Reference<com::sun::star::awt::XToolkit>
 const&, com::sun::star::uno::Reference<com::sun::star::awt::XWindowPeer> 
const&)
            (this=0x55af62c79380, _rToolkit=empty uno::Reference, 
_rParentPeer=uno::Reference to (VCLXContainer *) 0x55af61cbc178) at 
forms/source/richtext/richtextcontrol.cxx:163
        #11 0x00007fed05e34126 in 
frm::OControl::createPeer(com::sun::star::uno::Reference<com::sun::star::awt::XToolkit>
 const&, com::sun::star::uno::Reference<com::sun::star::awt::XWindowPeer> 
const&)
            (this=0x55af61e17c60, _rxToolkit=empty uno::Reference, 
_rxParent=uno::Reference to (VCLXContainer *) 0x55af61cbc178) at 
forms/source/component/FormComponent.cxx:272
        #12 0x00007fed50201095 in 
UnoControlContainer::impl_createControlPeerIfNecessary(com::sun::star::uno::Reference<com::sun::star::awt::XControl>
 const&)
            (this=0x55af5eb108c0, _rxControl=uno::Reference to 
(frm::OEditControl *) 0x55af61e17cc8) at 
toolkit/source/controls/unocontrolcontainer.cxx:595
        #13 0x00007fed501ff973 in 
UnoControlContainer::impl_addControl(com::sun::star::uno::Reference<com::sun::star::awt::XControl>
 const&, rtl::OUString const*)
            (this=0x55af5eb108c0, _rxControl=uno::Reference to 
(frm::OEditControl *) 0x55af61e17cc8, _pName=0x55af5f0d2670) at 
toolkit/source/controls/unocontrolcontainer.cxx:608
        #14 0x00007fed50201183 in UnoControlContainer::addControl(rtl::OUString 
const&, com::sun::star::uno::Reference<com::sun::star::awt::XControl> const&)
            (this=0x55af5eb108c0, rName="com.sun.star.form.control.TextField", 
rControl=uno::Reference to (frm::OEditControl *) 0x55af61e17cc8) at 
toolkit/source/controls/unocontrolcontainer.cxx:628
        #15 0x00007fed517f1aff in 
sdr::contact::ViewObjectContactOfUnoControl_Impl::createControlForDevice(sdr::contact::(anonymous
 namespace)::IPageViewAccess const&, OutputDevice const&, SdrUnoObj const&, 
basegfx::B2DHomMatrix const&, basegfx::B2DHomMatrix const&, 
sdr::contact::(anonymous namespace)::ControlHolder&) (_rPageView=..., 
_rDevice=..., _rUnoObject=..., _rInitialViewTransformation=..., 
_rInitialZoomNormalization=..., _out_rControl=...)
            at svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx:1126
        #16 0x00007fed517ee55b in 
sdr::contact::ViewObjectContactOfUnoControl_Impl::impl_ensureControl_nothrow(sdr::contact::(anonymous
 namespace)::IPageViewAccess const&, OutputDevice const&, basegfx::B2DHomMatrix 
const&)
            (this=0x55af6389c6b0, _rPageView=..., _rDevice=..., 
_rInitialViewTransformation=...) at 
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx:1044
        #17 0x00007fed517ee1d2 in 
sdr::contact::ViewObjectContactOfUnoControl_Impl::ensureControl(basegfx::B2DHomMatrix
 const*) (this=0x55af6389c6b0, _pInitialViewTransformationOrNULL=0x55af6380a1f0)
            at svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx:960
        #18 0x00007fed517f36a1 in sdr::contact::(anonymous 
namespace)::LazyControlCreationPrimitive2D::create2DDecomposition(drawinglayer::geometry::ViewInformation2D
 const&) const (this=0x55af61d38c40, _rViewInformation=...)
            at svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx:1545
        #19 0x00007fed5467691a in 
drawinglayer::primitive2d::BufferedDecompositionPrimitive2D::get2DDecomposition(drawinglayer::primitive2d::Primitive2DDecompositionVisitor&,
 drawinglayer::geometry::ViewInformation2D const&) const
            (this=0x55af61d38c40, rVisitor=..., rViewInformation=...) at 
drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx:133
        #20 0x00007fed517f358c in sdr::contact::(anonymous 
namespace)::LazyControlCreationPrimitive2D::get2DDecomposition(drawinglayer::primitive2d::Primitive2DDecompositionVisitor&,
 drawinglayer::geometry::ViewInformation2D const&) const
            (this=0x55af61d38c40, rVisitor=..., _rViewInformation=...) at 
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx:1530
        [...]
    
    Introduce a new flag `WindowBorderStyle::NONATIVEBORDER`
    and set it for the newly created control in `UnoControl::createPeer`
    if the use of the "standard theme" instead of the system style
    is enabled.
    
    Evaluate the flag in `ImplSmallBorderWindowView::Init`
    to never enable native drawing if it is set to consistently
    not apply system styling for such controls.
    
    Change-Id: Ib12685a3cf98acba035899221feb536f40cda84c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171396
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/include/vcl/vclenum.hxx b/include/vcl/vclenum.hxx
index f1938105a996..8d37156a3eec 100644
--- a/include/vcl/vclenum.hxx
+++ b/include/vcl/vclenum.hxx
@@ -111,11 +111,14 @@ enum class WindowBorderStyle : sal_Int16
     MENU              = 0x0010,
     NWF               = 0x0020,
     NOBORDER          = 0x1000,
-    REMOVEBORDER      = 0x2000
+    REMOVEBORDER      = 0x2000,
+    // Never use native border, used to ensure consistency of form controls
+    // inside documents across platforms and in pdf/print output
+    NONATIVEBORDER    = 0x4000,
 };
 namespace o3tl
 {
-    template<> struct typed_flags<WindowBorderStyle> : 
is_typed_flags<WindowBorderStyle, 0x3033> {};
+    template<> struct typed_flags<WindowBorderStyle> : 
is_typed_flags<WindowBorderStyle, 0x7033> {};
 }
 
 enum class TimeFormat
diff --git a/toolkit/source/controls/unocontrol.cxx 
b/toolkit/source/controls/unocontrol.cxx
index b13ffa02d20f..1065ca2f14ac 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -1292,6 +1292,11 @@ void UnoControl::createPeer( const Reference< XToolkit 
>& rxToolkit, const Refer
         if (bUseStandardTheme)
         {
             VclPtr<vcl::Window> pVclPeer = VCLUnoHelper::GetWindow(getPeer());
+
+            WindowBorderStyle nStyle = pVclPeer->GetBorderStyle();
+            nStyle |= WindowBorderStyle::NONATIVEBORDER;
+            pVclPeer->SetBorderStyle(nStyle);
+
             AllSettings aAllSettings = pVclPeer->GetSettings();
             StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
             aStyleSettings.SetStandardStyles();
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index fb7c3a1b2db4..8429ee33b52d 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -428,7 +428,7 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, 
tools::Long nWidth, to
             // control this border belongs to
             ControlType aCtrlType = ControlType::Generic;
             ControlPart aCtrlPart = ControlPart::Entire;
-            if (pCtrl)
+            if (pCtrl && !(pCtrl->GetBorderStyle() & 
WindowBorderStyle::NONATIVEBORDER))
             {
                 switch( pCtrl->GetType() )
                 {

Reply via email to