summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2022-04-25 17:21:16 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2022-04-27 09:53:37 +0200
commit44bd338c3911c530dddba54d8634ad35b4754503 (patch)
treeca7db7e1b6d70b3d24b5e886a3bcbe6b1296e473
parentc460576707a6c8f47efdc2d8010927edc7d1c2dc (diff)
more work
-rw-r--r--framework/IwyuFilter_framework.yaml2
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx54
-rw-r--r--include/vcl/image.hxx1
-rw-r--r--include/vcl/outdev.hxx10
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/ui/XUIConfigurationManager3.idl49
-rw-r--r--vcl/source/control/button.cxx2
-rw-r--r--vcl/source/gdi/virdev.cxx1
-rw-r--r--vcl/source/image/Image.cxx6
-rw-r--r--vcl/source/image/ImplImageTree.cxx1
-rw-r--r--vcl/source/outdev/outdev.cxx28
-rw-r--r--vcl/source/window/toolbox.cxx2
-rw-r--r--vcl/source/window/window.cxx50
13 files changed, 151 insertions, 56 deletions
diff --git a/framework/IwyuFilter_framework.yaml b/framework/IwyuFilter_framework.yaml
index 88b8dfae4ae3..441e1fbe2a77 100644
--- a/framework/IwyuFilter_framework.yaml
+++ b/framework/IwyuFilter_framework.yaml
@@ -41,6 +41,8 @@ excludelist:
framework/source/fwe/helper/configimporter.cxx:
# Actually used
- com/sun/star/ui/XUIConfigurationManager2.hpp
+ # Actually used
+ - com/sun/star/ui/XUIConfigurationManager3.hpp
framework/source/fwe/helper/undomanagerhelper.cxx:
# Actually used
- com/sun/star/document/XUndoManager.hpp
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index b3b443b99d5c..881bd2b8f490 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -40,7 +40,7 @@
#include <com/sun/star/ui/ConfigurationEvent.hpp>
#include <com/sun/star/ui/DocumentAcceleratorConfiguration.hpp>
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
-#include <com/sun/star/ui/XUIConfigurationManager2.hpp>
+#include <com/sun/star/ui/XUIConfigurationManager3.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -71,7 +71,7 @@ namespace {
class UIConfigurationManager : public ::cppu::WeakImplHelper<
css::lang::XServiceInfo ,
- css::ui::XUIConfigurationManager2 >
+ css::ui::XUIConfigurationManager3 >
{
public:
virtual OUString SAL_CALL getImplementationName() override
@@ -124,6 +124,9 @@ public:
virtual void SAL_CALL setStorage( const css::uno::Reference< css::embed::XStorage >& Storage ) override;
virtual sal_Bool SAL_CALL hasStorage() override;
+ // XUIConfigurationManager3
+ virtual css::uno::Reference<css::uno::XInterface> SAL_CALL getScaledImageManager(::sal_Int16 nScalePercentage) override;
+
private:
// private data types
enum NotifyOp
@@ -193,7 +196,7 @@ private:
std::mutex m_mutex;
comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners;
comphelper::OInterfaceContainerHelper4<css::ui::XUIConfigurationListener> m_aConfigListeners;
- rtl::Reference< ImageManager > m_xImageManager;
+ std::unordered_map<sal_Int16, rtl::Reference<ImageManager>> m_xImageManagers;
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAccConfig;
};
@@ -698,16 +701,17 @@ void SAL_CALL UIConfigurationManager::dispose()
{
SolarMutexGuard g;
- try
- {
- if ( m_xImageManager.is() )
- m_xImageManager->dispose();
- }
- catch ( const Exception& )
- {
- }
+ for (auto xImageManager : m_xImageManagers)
+ try
+ {
+ if (xImageManager.second.is())
+ xImageManager.second->dispose();
+ }
+ catch (const Exception&)
+ {
+ }
- m_xImageManager.clear();
+ m_xImageManagers.clear();
m_aUIElements.clear();
m_xDocConfigStorage.clear();
m_bModified = false;
@@ -1115,14 +1119,18 @@ void SAL_CALL UIConfigurationManager::insertSettings( const OUString& NewResourc
}
}
-Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager()
+Reference< XInterface > SAL_CALL UIConfigurationManager::getScaledImageManager(sal_Int16 nScaleFactor)
{
if ( m_bDisposed )
throw DisposedException();
- if ( !m_xImageManager.is() )
+ rtl::Reference<ImageManager> xImageManager;
+
+ auto const & aManagerIter = m_xImageManagers.find(nScaleFactor);
+ if (aManagerIter == m_xImageManagers.end())
{
- m_xImageManager = new ImageManager( m_xContext, /*bForModule*/false );
+ xImageManager = new ImageManager(m_xContext, /*bForModule*/ false);
+ m_xImageManagers[nScaleFactor] = xImageManager;
Sequence<Any> aPropSeq(comphelper::InitAnyPropertySequence(
{
@@ -1130,10 +1138,17 @@ Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager()
{"ModuleIdentifier", Any(OUString())},
}));
- m_xImageManager->initialize( aPropSeq );
+ xImageManager->initialize( aPropSeq );
}
+ else
+ xImageManager = aManagerIter->second;
+
+ return Reference<XInterface>(static_cast<cppu::OWeakObject*>(xImageManager.get()), UNO_QUERY);
+}
- return Reference< XInterface >( static_cast<cppu::OWeakObject*>(m_xImageManager.get()), UNO_QUERY );
+Reference<XInterface> SAL_CALL UIConfigurationManager::getImageManager()
+{
+ return getScaledImageManager(100);
}
Reference< XAcceleratorConfiguration > SAL_CALL UIConfigurationManager::getShortCutManager()
@@ -1187,8 +1202,9 @@ void SAL_CALL UIConfigurationManager::setStorage( const Reference< XStorage >& S
if ( m_xAccConfig.is() )
m_xAccConfig->setStorage( m_xDocConfigStorage );
- if ( m_xImageManager )
- m_xImageManager->setStorage( m_xDocConfigStorage );
+ auto const & aManagerIter = m_xImageManagers.find(100);
+ if (aManagerIter != m_xImageManagers.end())
+ aManagerIter->second->setStorage(m_xDocConfigStorage);
if ( m_xDocConfigStorage.is() )
{
diff --git a/include/vcl/image.hxx b/include/vcl/image.hxx
index 6c130bf4cd2b..8f3f75176396 100644
--- a/include/vcl/image.hxx
+++ b/include/vcl/image.hxx
@@ -46,6 +46,7 @@ public:
explicit Image(OUString const & rPNGFileUrl);
explicit Image(StockImage, OUString const & rPNGFilePath);
+ void setScalePercentage(sal_Int32);
Size GetSizePixel() const;
BitmapEx GetBitmapEx() const;
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 4c2277c1830c..1b26e492e072 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -380,8 +380,14 @@ protected:
///@{
public:
- SAL_DLLPRIVATE void SetDPIX( sal_Int32 nDPIX ) { mnDPIX = nDPIX; }
- SAL_DLLPRIVATE void SetDPIY( sal_Int32 nDPIY ) { mnDPIY = nDPIY; }
+ SAL_DLLPRIVATE void SetDPIX(sal_Int32 nDPIX);
+ SAL_DLLPRIVATE void SetDPIY(sal_Int32 nDPIY);
+
+ /** Sets the DPI values
+ *
+ * Use <= 0 to keep the old value
+ */
+ SAL_DLLPRIVATE void SetDPI(sal_Int32 nDPIX, sal_Int32 nDPIY);
OutDevType GetOutDevType() const { return meOutDevType; }
virtual bool IsVirtual() const;
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index a9b92639a667..0fb2287cf342 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -4064,6 +4064,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui,\
XUIConfigurationListener \
XUIConfigurationManager \
XUIConfigurationManager2 \
+ XUIConfigurationManager3 \
XUIConfigurationManagerSupplier \
XUIConfigurationPersistence \
XUIConfigurationStorage \
diff --git a/offapi/com/sun/star/ui/XUIConfigurationManager3.idl b/offapi/com/sun/star/ui/XUIConfigurationManager3.idl
new file mode 100644
index 000000000000..c028afcd9ca6
--- /dev/null
+++ b/offapi/com/sun/star/ui/XUIConfigurationManager3.idl
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef __com_sun_star_ui_XUIConfigurationManager3_idl__
+#define __com_sun_star_ui_XUIConfigurationManager3_idl__
+
+#include <com/sun/star/ui/XUIConfigurationManager2.idl>
+
+module com { module sun { module star { module ui {
+
+/**
+ @since LibreOffice 7.4
+*/
+
+interface XUIConfigurationManager3 : ::com::sun::star::ui::XUIConfigurationManager2
+{
+ /** retrieves the image manager from the user interface configuration
+ manager with a particular scaled percentage.
+
+ @param nImageType
+ specifies the image type for this operation.
+
+ @return
+ the image manager of the user interface configuration manager.
+ */
+ com::sun::star::uno::XInterface getScaledImageManager([in] short nScalePercentage);
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index e6e731f79ee5..6a5953447838 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -142,6 +142,8 @@ void Button::SetModeImage( const Image& rImage )
Image const & Button::GetModeImage( ) const
{
+ if (!!(mpButtonData->maImage))
+ mpButtonData->maImage.setScalePercentage(GetOutDev()->GetDPIScalePercentage());
return mpButtonData->maImage;
}
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 146a4865a7a4..0241d609474b 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -143,6 +143,7 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
ImplSVData* pSVData = ImplGetSVData();
+ assert(pOutDev);
if ( !pOutDev )
pOutDev = ImplGetDefaultWindow()->GetOutDev();
if( !pOutDev )
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index 1336f561fc3f..b6476c46d124 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -76,6 +76,12 @@ void Image::ImplInit(const BitmapEx& rBitmapEx)
mpImplData = std::make_shared<ImplImage>(rBitmapEx);
}
+void Image::setScalePercentage(sal_Int32 nScale)
+{
+ if (mpImplData)
+ mpImplData->setScalePercentage(nScale);
+}
+
OUString Image::GetStock() const
{
if (mpImplData)
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index 94ccb84d844f..5d9f1b527c38 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -339,6 +339,7 @@ OUString ImplImageTree::fallbackStyle(std::u16string_view rsStyle)
bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, BitmapEx & rBitmap, bool localized,
const ImageLoadFlags eFlags, sal_Int32 nScalePercentage)
{
+// assert(nScalePercentage != 100 && eFlags != ImageLoadFlags::IgnoreScalingFactor);
OUString aCurrentStyle(rStyle);
while (!aCurrentStyle.isEmpty())
{
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 775ff1525bbb..a2f5137d0e19 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -818,4 +818,32 @@ void OutputDevice::ImplDisposeCanvas()
}
}
+sal_Int32 lcl_updateScalePercentage(sal_Int32 nDPIX, sal_Int32 nDPIY)
+{
+ return round((nDPIX + nDPIY) * 100 / (96 * 2));
+}
+
+void OutputDevice::SetDPIX(sal_Int32 nDPIX)
+{
+ assert(nDPIX >= 0);
+ mnDPIX = nDPIX;
+ mnDPIScalePercentage = lcl_updateScalePercentage(mnDPIX, mnDPIY);
+}
+
+void OutputDevice::SetDPIY(sal_Int32 nDPIY)
+{
+ assert(nDPIY >= 0);
+ mnDPIY = nDPIY;
+ mnDPIScalePercentage = lcl_updateScalePercentage(mnDPIX, mnDPIY);
+}
+
+void OutputDevice::SetDPI(sal_Int32 nDPIX, sal_Int32 nDPIY)
+{
+ if (nDPIX > 0)
+ mnDPIX = nDPIX;
+ if (nDPIY > 0)
+ mnDPIY = nDPIY;
+ mnDPIScalePercentage = lcl_updateScalePercentage(mnDPIX, mnDPIY);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 64879c682d2c..4634742bd83a 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1479,6 +1479,7 @@ bool ToolBox::ImplCalcItem()
// we're drawing images only
if ( bImage || !bText )
{
+ item.maImage.setScalePercentage(GetOutDev()->GetDPIScalePercentage());
item.maItemSize = item.maImage.GetSizePixel();
}
else
@@ -1499,6 +1500,7 @@ bool ToolBox::ImplCalcItem()
}
else
{
+ item.maImage.setScalePercentage(GetOutDev()->GetDPIScalePercentage());
item.maItemSize = item.maImage.GetSizePixel();
}
}
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 4726fcc375bb..43bb67c20edf 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -915,27 +915,6 @@ void WindowOutputDevice::ReleaseGraphics( bool bRelease )
mpNextGraphics = nullptr;
}
-static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
-{
-#ifndef MACOSX
- // Setting of HiDPI is unfortunately all only a heuristic; and to add
- // insult to an injury, the system is constantly lying to us about
- // the DPI and whatnot
- // eg. fdo#77059 - set the value from which we do consider the
- // screen HiDPI to greater than 168
- if (nDPI > 216) // 96 * 2 + 96 / 4
- return 250;
- else if (nDPI > 168) // 96 * 2 - 96 / 4
- return 200;
- else if (nDPI > 120) // 96 * 1.5 - 96 / 4
- return 150;
-#else
- (void)nDPI;
-#endif
-
- return 100;
-}
-
void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
{
SAL_WARN_IF( !mpWindowImpl->mbFrame && !pParent && GetType() != WindowType::FIXEDIMAGE, "vcl.window",
@@ -1088,16 +1067,18 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
{
if ( pParent )
{
- GetOutDev()->mnDPIX = pParent->mpWindowImpl->mpFrame->GetDPIX();
- GetOutDev()->mnDPIY = pParent->mpWindowImpl->mpFrame->GetDPIY();
+ sal_Int32 nDPIX, nDPIY;
+ pParent->mpWindowImpl->mpFrame->GetDPI(nDPIX, nDPIY);
+ GetOutDev()->SetDPI(nDPIX, nDPIY);
}
else
{
OutputDevice *pOutDev = GetOutDev();
if ( pOutDev->AcquireGraphics() )
{
- GetOutDev()->mnDPIX = mpWindowImpl->mpFrame->GetDPIX();
- GetOutDev()->mnDPIY = mpWindowImpl->mpFrame->GetDPIY();
+ sal_Int32 nDPIX, nDPIY;
+ mpWindowImpl->mpFrame->GetDPI(nDPIX, nDPIY);
+ GetOutDev()->SetDPI(nDPIX, nDPIY);
}
}
@@ -1146,11 +1127,9 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
}
// setup the scale factor for HiDPI displays
-#if 0
- mpWindowImpl->mxOutDev->mnDPIScalePercentage = CountDPIScaleFactor(GetOutDev()->mnDPIY);
- GetOutDev()->mnDPIX = mnDPIX;
- mpWindowImpl->mxOutDev->mnDPIY = GetOutDev()->mnDPIY;
-#endif
+ sal_Int32 nDPIX, nDPIY;
+ mpWindowImpl->mpFrame->GetDPI(nDPIX, nDPIY);
+ GetOutDev()->SetDPI(nDPIX, nDPIY);
if (!utl::ConfigManager::IsFuzzing())
{
@@ -1351,16 +1330,17 @@ void Window::ImplInitResolutionSettings()
if (mpWindowImpl->mbFrame)
{
// setup the scale factor for HiDPI displays
- GetOutDev()->mnDPIScalePercentage = CountDPIScaleFactor(GetOutDev()->mnDPIY);
+ sal_Int32 nDPIX, nDPIY;
+ mpWindowImpl->mpFrame->GetDPI(nDPIX, nDPIY);
+ GetOutDev()->SetDPI(nDPIX, nDPIY);
+ SAL_DEBUG(__func__ << " " << GetOutDev()->mnDPIScalePercentage);
const StyleSettings& rStyleSettings = GetOutDev()->mxSettings->GetStyleSettings();
SetPointFont(*GetOutDev(), rStyleSettings.GetAppFont());
}
else if ( mpWindowImpl->mpParent )
{
OutputDevice *pParentOutDev = mpWindowImpl->mpParent->GetOutDev();
- GetOutDev()->mnDPIX = pParentOutDev->mnDPIX;
- GetOutDev()->mnDPIY = pParentOutDev->mnDPIY;
- GetOutDev()->mnDPIScalePercentage = pParentOutDev->mnDPIScalePercentage;
+ GetOutDev()->SetDPI(pParentOutDev->mnDPIX, pParentOutDev->mnDPIY);
}
// update the recalculated values for logical units
@@ -2777,7 +2757,7 @@ void Window::setPosSizePixel( tools::Long nX, tools::Long nY,
// Adjust resize with the hack of different client size and frame geometries to fix
// native menu bars. Eventually this should be replaced by proper mnTopBorder usage.
sal_Int32 nNewWidth, nNewHeight;
- pWindow->mpWindowImpl->mpFrame->GetClientSize(nNewWidth, nNewHeight);
+ pWindow->mpWindowImpl->mpFrame->GetClientSize(nNewWidth, nNewHeight);
// Resize should be called directly. If we haven't
// set the correct size, we get a second resize from