forms/source/component/Edit.cxx | 1 forms/source/component/FormComponent.cxx | 18 ++++++++++++++- forms/source/inc/FormComponent.hxx | 1 forms/source/inc/frm_strings.hxx | 2 + forms/source/inc/property.hxx | 2 - include/svx/svdmodel.hxx | 2 + sc/source/core/data/drwlayer.cxx | 1 sd/source/core/drawdoc.cxx | 2 + svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx | 8 ++++++ svx/source/svdraw/svdmodel.cxx | 1 sw/source/core/draw/drawdoc.cxx | 1 toolkit/source/controls/unocontrol.cxx | 18 +++++++++++++++ 12 files changed, 55 insertions(+), 2 deletions(-)
New commits: commit ea36e0502c0bc381577cfa1b1a7fedf0f05d1d72 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Oct 4 12:42:33 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Oct 4 21:17:46 2022 +0200 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 Change-Id: I816d7ebaf793e5eac7bd937d44c1db0371145199 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140942 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/forms/source/component/Edit.cxx b/forms/source/component/Edit.cxx index 27ea6cc9982d..580e4f3a9f0e 100644 --- a/forms/source/component/Edit.cxx +++ b/forms/source/component/Edit.cxx @@ -382,6 +382,7 @@ void OEditModel::describeAggregateProperties( Sequence< Property >& _rAggregateP RemoveProperty( _rAggregateProps, PROPERTY_NAME ); RemoveProperty( _rAggregateProps, PROPERTY_TAG ); RemoveProperty( _rAggregateProps, PROPERTY_NATIVE_LOOK ); + RemoveProperty( _rAggregateProps, PROPERTY_STANDARD_THEME ); } diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 2c882145ffd1..9b5558eed5e6 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -496,6 +496,7 @@ OControlModel::OControlModel( ,m_nTabIndex(FRM_DEFAULT_TABINDEX) ,m_nClassId(FormComponentType::CONTROL) ,m_bNativeLook( false ) + ,m_bStandardTheme( false ) ,m_bGenerateVbEvents( false ) ,m_nControlTypeinMSO(0) // 0 : default value is create from AOO ,m_nObjIDinMSO(INVALID_OBJ_ID_IN_MSO) @@ -548,6 +549,7 @@ OControlModel::OControlModel( const OControlModel* _pOriginal, const Reference< m_nTabIndex = _pOriginal->m_nTabIndex; m_nClassId = _pOriginal->m_nClassId; m_bNativeLook = _pOriginal->m_bNativeLook; + m_bStandardTheme = _pOriginal->m_bStandardTheme; m_bGenerateVbEvents = _pOriginal->m_bGenerateVbEvents; m_nControlTypeinMSO = _pOriginal->m_nControlTypeinMSO; m_nObjIDinMSO = _pOriginal->m_nObjIDinMSO; @@ -871,6 +873,9 @@ Any OControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const case PROPERTY_ID_NATIVE_LOOK: aReturn <<= true; break; + case PROPERTY_ID_STANDARD_THEME: + aReturn <<= false; + break; case PROPERTY_ID_GENERATEVBAEVENTS: aReturn <<= false; break; @@ -909,6 +914,9 @@ void OControlModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) con case PROPERTY_ID_NATIVE_LOOK: _rValue <<= m_bNativeLook; break; + case PROPERTY_ID_STANDARD_THEME: + _rValue <<= m_bStandardTheme; + break; case PROPERTY_ID_GENERATEVBAEVENTS: _rValue <<= m_bGenerateVbEvents; break; @@ -946,6 +954,9 @@ sal_Bool OControlModel::convertFastPropertyValue( case PROPERTY_ID_NATIVE_LOOK: bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bNativeLook); break; + case PROPERTY_ID_STANDARD_THEME: + bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bStandardTheme); + break; case PROPERTY_ID_GENERATEVBAEVENTS: bModified = tryPropertyValue(_rConvertedValue, _rOldValue, _rValue, m_bGenerateVbEvents); break; @@ -988,6 +999,9 @@ void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const A case PROPERTY_ID_NATIVE_LOOK: OSL_VERIFY( _rValue >>= m_bNativeLook ); break; + case PROPERTY_ID_STANDARD_THEME: + OSL_VERIFY( _rValue >>= m_bStandardTheme ); + break; case PROPERTY_ID_GENERATEVBAEVENTS: OSL_VERIFY( _rValue >>= m_bGenerateVbEvents ); break; @@ -1009,12 +1023,14 @@ void OControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const A void OControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - _rProps.realloc(7); + _rProps.realloc(8); css::beans::Property* pProperties = _rProps.getArray(); *pProperties++ = css::beans::Property(PROPERTY_CLASSID, PROPERTY_ID_CLASSID, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); *pProperties++ = css::beans::Property(PROPERTY_NAME, PROPERTY_ID_NAME, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); *pProperties++ = css::beans::Property(PROPERTY_NATIVE_LOOK, PROPERTY_ID_NATIVE_LOOK, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_STANDARD_THEME, PROPERTY_ID_STANDARD_THEME, cppu::UnoType<bool>::get(), + css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); *pProperties++ = css::beans::Property(PROPERTY_TAG, PROPERTY_ID_TAG, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::BOUND); *pProperties++ = css::beans::Property(PROPERTY_GENERATEVBAEVENTS, PROPERTY_ID_GENERATEVBAEVENTS, cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::TRANSIENT); *pProperties++ = css::beans::Property(PROPERTY_CONTROL_TYPE_IN_MSO, PROPERTY_ID_CONTROL_TYPE_IN_MSO, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index 833cd90df561..0a0ec19be553 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -321,6 +321,7 @@ protected: sal_Int16 m_nTabIndex; // index within the taborder sal_Int16 m_nClassId; // type of the control bool m_bNativeLook; // should the control use the native platform look? + bool m_bStandardTheme; // should the default control colors be 'standard' or use the native platform theme? bool m_bGenerateVbEvents; // should the control generate fake vba events //added for exporting OCX control sal_Int16 m_nControlTypeinMSO; //keep the MS office control type for exporting to MS binary file diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx index 79f23aa46985..5dbceb886cc8 100644 --- a/forms/source/inc/frm_strings.hxx +++ b/forms/source/inc/frm_strings.hxx @@ -216,6 +216,8 @@ inline constexpr OUStringLiteral PROPERTY_HIDEINACTIVESELECTION = u"HideInactive inline constexpr OUStringLiteral PROPERTY_HIGHLIGHT_COLOR = u"HighlightColor"; inline constexpr OUStringLiteral PROPERTY_HIGHLIGHT_TEXT_COLOR = u"HighlightTextColor"; +inline constexpr OUStringLiteral PROPERTY_STANDARD_THEME = u"StandardTheme"; + inline constexpr OUStringLiteral PROPERTY_SHOW_POSITION = u"ShowPosition"; inline constexpr OUStringLiteral PROPERTY_SHOW_NAVIGATION = u"ShowNavigation"; inline constexpr OUStringLiteral PROPERTY_SHOW_RECORDACTIONS = u"ShowRecordActions"; diff --git a/forms/source/inc/property.hxx b/forms/source/inc/property.hxx index e6879950a18b..54d19a03d319 100644 --- a/forms/source/inc/property.hxx +++ b/forms/source/inc/property.hxx @@ -57,7 +57,7 @@ namespace frm #define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22) #define PROPERTY_ID_GRAPHIC (PROPERTY_ID_START + 23) #define PROPERTY_ID_GROUP_NAME (PROPERTY_ID_START + 24) - // free +#define PROPERTY_ID_STANDARD_THEME (PROPERTY_ID_START + 25) // free // free // free diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index 4e76bc4e1478..7c23b5a24712 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -198,6 +198,7 @@ protected: std::unique_ptr<SdrUndoGroup> m_pCurrentUndoGroup; // For multi-level sal_uInt16 m_nUndoLevel; // undo nesting bool m_bIsWriter:1; // to clean up pMyPool from 303a + bool m_bThemedControls:1; // If false UnoControls should not use theme colors bool mbUndoEnabled:1; // If false no undo is recorded or we are during the execution of an undo action bool mbChanged:1; bool m_bPagNumsDirty:1; @@ -268,6 +269,7 @@ private: public: SVX_DLLPRIVATE virtual bool IsCreatingDataObj() const { return false; } bool IsTransportContainer() const { return m_bTransportContainer; } + bool AreControlsThemed() { return m_bThemedControls; } bool IsPasteResize() const { return m_bPasteResize; } void SetPasteResize(bool bOn) { m_bPasteResize=bOn; } // If a custom Pool is put here, the class will call methods diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 78c32baabea1..c6d10e78830c 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -240,6 +240,7 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, OUString _aName ) : bHyphenatorSet( false ) { SetVOCInvalidationIsReliable(true); + m_bThemedControls = false; pGlobalDrawPersist = nullptr; // Only use once diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 182ffe7f2c30..254bcf0ce9bd 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -139,6 +139,8 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) , mbEmbedFontScriptComplex(true) , mnImagePreferredDPI(0) { + m_bThemedControls = false; + mpDrawPageListWatcher.reset(new ImpDrawPageListWatcher(*this)); mpMasterPageListWatcher.reset(new ImpMasterPageListWatcher(*this)); diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index 540c7e827df8..46d2dc9980e2 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/awt/XView.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/awt/InvalidateStyle.hpp> #include <com/sun/star/util/XModeChangeListener.hpp> @@ -117,6 +118,7 @@ namespace sdr::contact { using ::com::sun::star::awt::XView; using ::com::sun::star::awt::WindowEvent; using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::beans::XPropertySetInfo; using ::com::sun::star::lang::XComponent; using ::com::sun::star::awt::XWindowPeer; using ::com::sun::star::beans::XPropertyChangeListener; @@ -1089,6 +1091,12 @@ namespace sdr::contact { Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); _out_rControl = Reference<XControl>( xContext->getServiceManager()->createInstanceWithContext(sControlServiceName, xContext), UNO_QUERY_THROW ); + // tdf#150886 for calc/writer/impress make forms ignore the platform theme + Reference<XPropertySet> xModelProperties(xControlModel, UNO_QUERY); + Reference<XPropertySetInfo> xInfo = xModelProperties ? xModelProperties->getPropertySetInfo() : nullptr; + if (xInfo && xInfo->hasPropertyByName("StandardTheme")) + xModelProperties->setPropertyValue("StandardTheme", Any(!_rUnoObject.getSdrModelFromSdrObject().AreControlsThemed())); + // knit the model and the control _out_rControl.setModel( xControlModel ); const tools::Rectangle aRect( _rUnoObject.GetLogicRect() ); diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 535850f582c1..3feb1ae0669b 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -106,6 +106,7 @@ SdrModel::SdrModel(SfxItemPool* pPool, comphelper::IEmbeddedHelper* pEmbeddedHel , m_pLinkManager(nullptr) , m_nUndoLevel(0) , m_bIsWriter(true) + , m_bThemedControls(true) , mbUndoEnabled(true) , mbChanged(false) , m_bPagNumsDirty(false) diff --git a/sw/source/core/draw/drawdoc.cxx b/sw/source/core/draw/drawdoc.cxx index 0f4d16116f45..6d86df36b6bb 100644 --- a/sw/source/core/draw/drawdoc.cxx +++ b/sw/source/core/draw/drawdoc.cxx @@ -37,6 +37,7 @@ SwDrawModel::SwDrawModel(SwDoc& rDoc) : FmFormModel(&rDoc.GetAttrPool(), rDoc.GetDocShell()) , m_rDoc(rDoc) { + m_bThemedControls = false; SetScaleUnit( MapUnit::MapTwip ); SetSwapGraphics(); diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index c9a757d7dbf2..a3d0a251c382 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -1317,6 +1317,24 @@ void UnoControl::createPeer( const Reference< XToolkit >& rxToolkit, const Refer xView->setGraphics( xGraphics ); + // tdf#150886 if false use the same settings for widgets regardless of theme + // for consistency of document across platforms and in pdf/print output + if (xInfo->hasPropertyByName("StandardTheme")) + { + aVal = xPSet->getPropertyValue("StandardTheme"); + bool bUseStandardTheme = false; + aVal >>= bUseStandardTheme; + if (bUseStandardTheme) + { + VclPtr<vcl::Window> pVclPeer = VCLUnoHelper::GetWindow(getPeer()); + AllSettings aAllSettings = pVclPeer->GetSettings(); + StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); + aStyleSettings.SetStandardStyles(); + aAllSettings.SetStyleSettings(aStyleSettings); + pVclPeer->SetSettings(aAllSettings); + } + } + peerCreated(); mbCreatingPeer = false;