Skip to content

Commit

Permalink
tdf#150786 use a 'standard' theme for form controls
Browse files Browse the repository at this point in the history
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 <caolanm@redhat.com>
  • Loading branch information
Caolán McNamara committed Oct 4, 2022
1 parent 437abb3 commit ea36e05
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions forms/source/component/Edit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

}

Expand Down
18 changes: 17 additions & 1 deletion forms/source/component/FormComponent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions forms/source/inc/FormComponent.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions forms/source/inc/frm_strings.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion forms/source/inc/property.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions include/svx/svdmodel.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sc/source/core/data/drwlayer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, OUString _aName ) :
bHyphenatorSet( false )
{
SetVOCInvalidationIsReliable(true);
m_bThemedControls = false;

pGlobalDrawPersist = nullptr; // Only use once

Expand Down
2 changes: 2 additions & 0 deletions sd/source/core/drawdoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
8 changes: 8 additions & 0 deletions svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() );
Expand Down
1 change: 1 addition & 0 deletions svx/source/svdraw/svdmodel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions sw/source/core/draw/drawdoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SwDrawModel::SwDrawModel(SwDoc& rDoc)
: FmFormModel(&rDoc.GetAttrPool(), rDoc.GetDocShell())
, m_rDoc(rDoc)
{
m_bThemedControls = false;
SetScaleUnit( MapUnit::MapTwip );
SetSwapGraphics();

Expand Down
18 changes: 18 additions & 0 deletions toolkit/source/controls/unocontrol.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ea36e05

Please sign in to comment.