From dde234b6955a421d51d2b37e4fc3972c660146f0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 11 Dec 2012 14:59:39 +0200 Subject: fdo#46808, remove awt::DisplayAccess service. This service was never documented in an IDL file. All it did was provide a wrapper around some VCL module API. Now that we can link the VCL stuff into SD and SDEXT, just access the API directly. Change-Id: Ic0ba34c2bca797baa7319878d98cfe3a4ec59d4d --- embeddedobj/source/general/docholder.cxx | 21 +- framework/inc/services.h | 1 - framework/inc/services/layoutmanager.hxx | 1 - framework/source/layoutmanager/layoutmanager.cxx | 19 +- sd/source/ui/dlg/present.cxx | 20 +- sd/source/ui/slideshow/SlideShowRestarter.cxx | 22 +- sd/source/ui/slideshow/slideshow.cxx | 23 +- sdext/source/presenter/PresenterScreen.cxx | 26 +- sdext/source/presenter/PresenterScreen.hxx | 4 - vcl/Library_vcl.mk | 1 - vcl/inc/vcl/svapp.hxx | 8 +- vcl/source/app/svapp.cxx | 23 ++ vcl/source/components/display.cxx | 363 ----------------------- vcl/source/components/factory.cxx | 10 - vcl/vcl.android.component | 3 - vcl/vcl.headless.component | 3 - vcl/vcl.ios.component | 3 - vcl/vcl.macosx.component | 3 - vcl/vcl.unx.component | 3 - vcl/vcl.windows.component | 3 - vcl/win/source/window/salframe.cxx | 41 +-- 21 files changed, 69 insertions(+), 532 deletions(-) delete mode 100644 vcl/source/components/display.cxx diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx index c7e63d86ee03..f30eb5e1a6b0 100644 --- a/embeddedobj/source/general/docholder.cxx +++ b/embeddedobj/source/general/docholder.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -910,26 +911,20 @@ uno::Reference< frame::XFrame > DocumentHolder::GetDocFrame() if( xHWindow.is() ) { - uno::Reference< beans::XPropertySet > xMonProps( m_xFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess" ) ) ), uno::UNO_QUERY_THROW ); - const rtl::OUString sPropName( RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) ); - sal_Int32 nDisplay = 0; - xMonProps->getPropertyValue( sPropName ) >>= nDisplay; - - uno::Reference< container::XIndexAccess > xMultiMon( xMonProps, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xMonitor( xMultiMon->getByIndex( nDisplay ), uno::UNO_QUERY_THROW ); - awt::Rectangle aWorkRect; - xMonitor->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WorkArea" ) ) ) >>= aWorkRect; + sal_Int32 nDisplay = Application::GetDisplayBuiltInScreen(); + + Rectangle aWorkRect = Application::GetWorkAreaPosSizePixel( nDisplay ); awt::Rectangle aWindowRect = xHWindow->getPosSize(); - if (( aWindowRect.Width < aWorkRect.Width) && ( aWindowRect.Height < aWorkRect.Height )) + if (( aWindowRect.Width < aWorkRect.GetWidth()) && ( aWindowRect.Height < aWorkRect.GetHeight() )) { - int OffsetX = ( aWorkRect.Width - aWindowRect.Width ) / 2 + aWorkRect.X; - int OffsetY = ( aWorkRect.Height - aWindowRect.Height ) /2 + aWorkRect.Y; + int OffsetX = ( aWorkRect.GetWidth() - aWindowRect.Width ) / 2 + aWorkRect.Left(); + int OffsetY = ( aWorkRect.GetHeight() - aWindowRect.Height ) /2 + aWorkRect.Top(); xHWindow->setPosSize( OffsetX, OffsetY, aWindowRect.Width, aWindowRect.Height, awt::PosSize::POS ); } else { - xHWindow->setPosSize( aWorkRect.X, aWorkRect.Y, aWorkRect.Width, aWorkRect.Height, awt::PosSize::POSSIZE ); + xHWindow->setPosSize( aWorkRect.Left(), aWorkRect.Top(), aWorkRect.GetWidth(), aWorkRect.GetHeight(), awt::PosSize::POSSIZE ); } xHWindow->setVisible( sal_True ); diff --git a/framework/inc/services.h b/framework/inc/services.h index 7ab2c837895a..e815122c3138 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -80,7 +80,6 @@ namespace framework{ #define SERVICENAME_STRINGABBREVIATION DECLARE_ASCII("com.sun.star.util.UriAbbreviation" ) #define SERVICENAME_IMAGEMANAGER DECLARE_ASCII("com.sun.star.ui.ImageManager" ) #define SERVICENAME_TABWINDOWSERVICE DECLARE_ASCII("com.sun.star.ui.dialogs.TabContainerWindow" ) -#define SERVICENAME_DISPLAYACCESS DECLARE_ASCII("com.sun.star.awt.DisplayAccess" ) #define SERVICENAME_PANELFACTORY DECLARE_ASCII("com.sun.star.ui.PanelFactory" ) #define SERVICENAME_MODELWINSERVICE DECLARE_ASCII("com.sun.star.ui.ModelWinService" ) diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index 9e813a73cfc8..e45794caae11 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -286,7 +286,6 @@ namespace framework css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; /** reference to factory, which has created this instance. */ css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; - css::uno::Reference< css::container::XIndexAccess > m_xDisplayAccess; css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xModuleCfgMgr; css::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocCfgMgr; diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index a91642888977..ece410cc8432 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -113,7 +113,6 @@ LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceM , LayoutManager_PBase( *(static_cast< ::cppu::OBroadcastHelper* >(this)) ) , m_xSMGR( xServiceManager ) , m_xURLTransformer( URLTransformer::create(::comphelper::getComponentContext(xServiceManager)) ) - , m_xDisplayAccess( xServiceManager->createInstance( SERVICENAME_DISPLAYACCESS ), UNO_QUERY ) , m_nLockCount( 0 ) , m_bActive( false ) , m_bInplaceMenuSet( false ) @@ -2472,25 +2471,15 @@ sal_Bool LayoutManager::implts_resizeContainerWindow( const awt::Size& rContaine Reference< awt::XWindow > xContainerWindow = m_xContainerWindow; Reference< awt::XTopWindow2 > xContainerTopWindow = m_xContainerTopWindow; Reference< awt::XWindow > xComponentWindow = m_xFrame->getComponentWindow(); - Reference< container::XIndexAccess > xDisplayAccess = m_xDisplayAccess; aReadLock.unlock(); // calculate the maximum size we have for the container window - awt::Rectangle aWorkArea; - try - { - sal_Int32 nDisplay = xContainerTopWindow->getDisplay(); - Reference< beans::XPropertySet > xDisplayInfo( xDisplayAccess->getByIndex( nDisplay ), UNO_QUERY_THROW ); - OSL_VERIFY( xDisplayInfo->getPropertyValue( ::rtl::OUString( "WorkArea" ) ) >>= aWorkArea ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } + sal_Int32 nDisplay = xContainerTopWindow->getDisplay(); + Rectangle aWorkArea = Application::GetWorkAreaPosSizePixel( nDisplay ); - if (( aWorkArea.Width > 0 ) && ( aWorkArea.Height > 0 )) + if (( aWorkArea.GetWidth() > 0 ) && ( aWorkArea.GetHeight() > 0 )) { - if (( rContainerSize.Width > aWorkArea.Width ) || ( rContainerSize.Height > aWorkArea.Height )) + if (( rContainerSize.Width > aWorkArea.GetWidth() ) || ( rContainerSize.Height > aWorkArea.GetHeight() )) return sal_False; // Strictly, this is not correct. If we have a multi-screen display (css.awt.DisplayAccess.MultiDisplay == true), // the the "effective work area" would be much larger than the work area of a single display, since we could in theory diff --git a/sd/source/ui/dlg/present.cxx b/sd/source/ui/dlg/present.cxx index 5b94cb347e02..1e1a8125cd10 100644 --- a/sd/source/ui/dlg/present.cxx +++ b/sd/source/ui/dlg/present.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include "sdattr.hxx" #include "present.hxx" @@ -176,13 +177,11 @@ void SdStartPresentationDlg::InitMonitorSettings() { try { - Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); - Reference< XIndexAccess > xMultiMon( xFactory->createInstance("com.sun.star.awt.DisplayAccess" ), UNO_QUERY_THROW ); maGrpMonitor.Show( true ); maFtMonitor.Show( true ); maLBMonitor.Show( true ); - mnMonitors = xMultiMon->getCount(); + mnMonitors = Application::GetScreenCount(); if( mnMonitors <= 1 ) { @@ -191,19 +190,8 @@ void SdStartPresentationDlg::InitMonitorSettings() } else { - sal_Bool bUnifiedDisplay = false; - sal_Int32 nExternalIndex = 0; - Reference< XPropertySet > xMonProps( xMultiMon, UNO_QUERY ); - if( xMonProps.is() ) try - { - const OUString sPropName1( "IsUnifiedDisplay" ); - xMonProps->getPropertyValue( sPropName1 ) >>= bUnifiedDisplay; - const OUString sPropName2( "ExternalDisplay" ); - xMonProps->getPropertyValue( sPropName2 ) >>= nExternalIndex; - } - catch( Exception& ) - { - } + sal_Bool bUnifiedDisplay = Application::IsUnifiedDisplay(); + sal_Int32 nExternalIndex = Application::GetDisplayExternalScreen(); sal_Int32 nSelectedIndex (-1); sal_Int32 nDefaultExternalIndex (-1); diff --git a/sd/source/ui/slideshow/SlideShowRestarter.cxx b/sd/source/ui/slideshow/SlideShowRestarter.cxx index ad452d80d67e..90ed5146ac6e 100644 --- a/sd/source/ui/slideshow/SlideShowRestarter.cxx +++ b/sd/source/ui/slideshow/SlideShowRestarter.cxx @@ -42,7 +42,7 @@ SlideShowRestarter::SlideShowRestarter ( : mnEventId(0), mpSlideShow(rpSlideShow), mpViewShellBase(pViewShellBase), - mnDisplayCount(GetDisplayCount()), + mnDisplayCount(Application::GetScreenCount()), mpDispatcher(pViewShellBase->GetViewFrame()->GetDispatcher()), mnCurrentSlideNumber(0) { @@ -77,30 +77,12 @@ void SlideShowRestarter::Restart (bool bForce) LINK(this, SlideShowRestarter, EndPresentation)); } -sal_Int32 SlideShowRestarter::GetDisplayCount (void) -{ - const Reference xContext ( - ::comphelper::getProcessComponentContext() ); - Reference xFactory ( - xContext->getServiceManager(), UNO_QUERY); - if ( ! xFactory.is()) - return 0; - - Reference xIndexAccess ( - xFactory->createInstanceWithContext("com.sun.star.awt.DisplayAccess",xContext), - UNO_QUERY); - if ( ! xIndexAccess.is()) - return 0; - - return xIndexAccess->getCount(); -} - IMPL_LINK_NOARG(SlideShowRestarter, EndPresentation) { mnEventId = 0; if (mpSlideShow.is()) { - if (mnDisplayCount!=GetDisplayCount()) + if (mnDisplayCount != (sal_Int32)Application::GetScreenCount()) { mpSlideShow->end(); diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx index 9980082e99b3..af2033e8560b 100644 --- a/sd/source/ui/slideshow/slideshow.cxx +++ b/sd/source/ui/slideshow/slideshow.cxx @@ -101,25 +101,6 @@ namespace { private: ::boost::shared_ptr mpRestarter; }; - - /** Return the default display id (or -1 when that can not be - determined.) - */ - sal_Int32 GetExternalDisplay (void) - { - try - { - Reference< XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); - Reference< XPropertySet > xMonProps(xFactory->createInstance( "com.sun.star.awt.DisplayAccess" ), UNO_QUERY_THROW ); - sal_Int32 nPrimaryIndex (-1); - if (xMonProps->getPropertyValue( "ExternalDisplay" ) >>= nPrimaryIndex) - return nPrimaryIndex; - } - catch( Exception& ) - { - } - return -1; - } } @@ -573,7 +554,7 @@ void SAL_CALL SlideShow::setPropertyValue( const OUString& aPropertyName, const { // Convert value to true display id. if (nDisplay == 0) - nDisplay = GetExternalDisplay(); + nDisplay = Application::GetDisplayExternalScreen(); else if (nDisplay < 0) nDisplay = -1; else @@ -665,7 +646,7 @@ Any SAL_CALL SlideShow::getPropertyValue( const OUString& PropertyName ) throw(U SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS); const sal_Int32 nDisplay (pOptions->GetDisplay()); // Convert true display id to the previously used schema. - if (nDisplay == GetExternalDisplay()) + if (nDisplay == (sal_Int32)Application::GetDisplayExternalScreen()) return Any(sal_Int32(0)); else if (nDisplay < 0) return Any(sal_Int32(-1)); diff --git a/sdext/source/presenter/PresenterScreen.cxx b/sdext/source/presenter/PresenterScreen.cxx index d4fadf6e9597..41133a1c0863 100644 --- a/sdext/source/presenter/PresenterScreen.cxx +++ b/sdext/source/presenter/PresenterScreen.cxx @@ -39,6 +39,7 @@ #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -409,13 +410,6 @@ void PresenterScreen::InitializePresenterScreen (void) } } -css::uno::Reference PresenterScreen::GetDisplayAccess() const -{ - Reference xContext (mxContextWeak); - Reference xFactory (xContext->getServiceManager(), UNO_QUERY_THROW); - return Reference( xFactory->createInstanceWithContext(A2S("com.sun.star.awt.DisplayAccess"), xContext), UNO_QUERY_THROW); -} - void PresenterScreen::SwitchMonitors() { try { @@ -429,9 +423,8 @@ void PresenterScreen::SwitchMonitors() return; // Adapt that display number to be the 'default' setting of 0 if it matches - sal_Int32 nExternalDisplay = 0; - Reference xDisplayProperties = GetDisplayAccess(); - xDisplayProperties->getPropertyValue(A2S("ExternalDisplay")) >>= nExternalDisplay; + sal_Int32 nExternalDisplay = Application::GetDisplayExternalScreen(); + if (nNewScreen == nExternalDisplay) nNewScreen = 0; // screen zero is best == the primary display else @@ -473,7 +466,6 @@ sal_Int32 PresenterScreen::GetPresenterScreenNumber ( return -1; } - Reference xDisplayProperties = GetDisplayAccess(); if (nDisplayNumber > 0) { nScreenNumber = nDisplayNumber - 1; @@ -481,18 +473,14 @@ sal_Int32 PresenterScreen::GetPresenterScreenNumber ( else if (nDisplayNumber == 0) { // A display number value of 0 indicates the primary screen. - // Instantiate the DisplayAccess service to find out which - // screen number that is. - if (nDisplayNumber <= 0 && xDisplayProperties.is()) - xDisplayProperties->getPropertyValue(A2S("ExternalDisplay")) >>= nScreenNumber; + // Find out which screen number that is. + if (nDisplayNumber <= 0) + nScreenNumber = Application::GetDisplayExternalScreen(); } // We still have to determine the number of screens to decide // whether the presenter screen may be shown at all. - Reference xIndexAccess (xDisplayProperties, UNO_QUERY); - if ( ! xIndexAccess.is()) - return -1; - nScreenCount = xIndexAccess->getCount(); + nScreenCount = Application::GetScreenCount(); if (nScreenCount < 2 || nDisplayNumber > nScreenCount) { diff --git a/sdext/source/presenter/PresenterScreen.hxx b/sdext/source/presenter/PresenterScreen.hxx index cc0102b235be..16a3e05ccb2c 100644 --- a/sdext/source/presenter/PresenterScreen.hxx +++ b/sdext/source/presenter/PresenterScreen.hxx @@ -228,10 +228,6 @@ private: */ css::uno::Reference GetMainPaneId ( const css::uno::Reference& rxPresentation) const; - - /** Gets the display access property bag - */ - css::uno::Reference GetDisplayAccess () const; }; } } diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 57fd4cfe083a..af314880a29b 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -125,7 +125,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/app/unohelp2 \ vcl/source/app/unohelp \ vcl/source/app/vclevent \ - vcl/source/components/display \ vcl/source/components/dtranscomp \ vcl/source/components/factory \ vcl/source/components/fontident \ diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx index d95e44b65cdb..0a1aa569d5cf 100644 --- a/vcl/inc/vcl/svapp.hxx +++ b/vcl/inc/vcl/svapp.hxx @@ -282,18 +282,20 @@ public: // (e.g. Xserver with Xinerama, Windows) // false: different screens are separate and windows cannot be moved // between them (e.g. Xserver with multiple screens) - SAL_DLLPRIVATE static bool IsUnifiedDisplay(); + static bool IsUnifiedDisplay(); // if IsUnifiedDisplay() == true the return value will be // nearest screen of the target rectangle // in case of IsUnifiedDisplay() == false the return value // will always be GetDisplayDefaultScreen() SAL_DLLPRIVATE static unsigned int GetBestScreen( const Rectangle& ); - SAL_DLLPRIVATE static Rectangle GetWorkAreaPosSizePixel( unsigned int nScreen ); + static Rectangle GetWorkAreaPosSizePixel( unsigned int nScreen ); // This returns the LCD screen number for a laptop, or the primary // external VGA display for a desktop machine - it is where a presenter // console should be rendered if there are other (non-built-in) screens // present. - SAL_DLLPRIVATE static unsigned int GetDisplayBuiltInScreen(); + static unsigned int GetDisplayBuiltInScreen(); + // Practically, this means - Get the screen we should run a presentation on. + static unsigned int GetDisplayExternalScreen(); SAL_DLLPRIVATE static rtl::OUString GetDisplayScreenName( unsigned int nScreen ); static const LocaleDataWrapper& GetAppLocaleDataWrapper(); diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 6a799cd20c8c..1a799876bb0a 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -1238,6 +1238,29 @@ unsigned int Application::GetDisplayBuiltInScreen() return pSys ? pSys->GetDisplayBuiltInScreen() : 0; } +unsigned int Application::GetDisplayExternalScreen() +{ + // This is really unpleasant, in theory we could have multiple + // external displays etc. + int nExternal(0); + switch (GetDisplayBuiltInScreen()) + { + case 0: + nExternal = 1; + break; + case 1: + nExternal = 0; + break; + default: + // When the built-in display is neither 0 nor 1 + // then place the full-screen presentation on the + // first available screen. + nExternal = 0; + break; + } + return nExternal; +} + Rectangle Application::GetScreenPosSizePixel( unsigned int nScreen ) { SalSystem* pSys = ImplGetSalSystem(); diff --git a/vcl/source/components/display.cxx b/vcl/source/components/display.cxx deleted file mode 100644 index f1862bc2d228..000000000000 --- a/vcl/source/components/display.cxx +++ /dev/null @@ -1,363 +0,0 @@ -/* -*- 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 . - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - - -using ::rtl::OUString; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; - -// ----------------------------------------------------------------------- - -namespace vcl -{ - -class DisplayInfo : public ::cppu::WeakAggImplHelper3< XPropertySet, XPropertySetInfo, XServiceInfo > -{ -public: - DisplayInfo( sal_uInt32 nDisplayScreen ); - - // XPropertySet - virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (RuntimeException); - virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException); - virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - - // XPropertySetInfo - virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException); - virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException); - virtual ::sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); - -private: - sal_uInt32 mnDisplayScreen; -}; - -static const char* pScreenAreaName = "ScreenArea"; -static const char* pWorkAreaName = "WorkArea"; -static const char* pScreenName = "ScreenName"; - -// -------------------------------------------------------------------- - -DisplayInfo::DisplayInfo( sal_uInt32 nDisplayScreen ) -: mnDisplayScreen( nDisplayScreen ) -{ -} - -// XPropertySet -Reference< XPropertySetInfo > SAL_CALL DisplayInfo::getPropertySetInfo() throw (RuntimeException) -{ - return this; -} - -void SAL_CALL DisplayInfo::setPropertyValue( const OUString& /*aPropertyName* */, const Any& /*aValue*/ ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) -{ - throw PropertyVetoException(); -} - -Any SAL_CALL DisplayInfo::getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) -{ - Rectangle aRect; - if( PropertyName.equalsAscii( pScreenAreaName ) ) - { - aRect = Application::GetScreenPosSizePixel( mnDisplayScreen ); - } - else if( PropertyName.equalsAscii( pWorkAreaName ) ) - { - aRect = Application::GetWorkAreaPosSizePixel( mnDisplayScreen ); - } - else if( PropertyName.equalsAscii( pScreenName ) ) - { - return Any( Application::GetDisplayScreenName( mnDisplayScreen ) ); - } - else - throw UnknownPropertyException(); - - return Any( com::sun::star::awt::Rectangle( aRect.Left(), aRect.Top(), aRect.getWidth(), aRect.getHeight() ) ); -} - -void SAL_CALL DisplayInfo::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} -void SAL_CALL DisplayInfo::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} -void SAL_CALL DisplayInfo::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} -void SAL_CALL DisplayInfo::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} - -// XPropertySetInfo -Sequence< Property > SAL_CALL DisplayInfo::getProperties() throw (RuntimeException) -{ - Sequence< Property > aProps(2); - aProps[0] = getPropertyByName( OUString::createFromAscii( pScreenAreaName ) ); - aProps[1] = getPropertyByName( OUString::createFromAscii( pWorkAreaName ) ); - return aProps; -} - -Property SAL_CALL DisplayInfo::getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException) -{ - if( aName.equalsAscii( pScreenAreaName ) || - aName.equalsAscii( pWorkAreaName ) ) - return Property( aName, 0, ::getCppuType( (::com::sun::star::awt::Rectangle const *)0 ), PropertyAttribute::READONLY ); - throw UnknownPropertyException(); -} - -::sal_Bool SAL_CALL DisplayInfo::hasPropertyByName( const OUString& Name ) throw (RuntimeException) -{ - return Name.equalsAscii( pScreenAreaName ) || - Name.equalsAscii( pWorkAreaName ); -} - -// XServiceInfo -OUString SAL_CALL DisplayInfo::getImplementationName() throw (RuntimeException) -{ - return OUString(RTL_CONSTASCII_USTRINGPARAM("vcl::DisplayInfo")); -} - -::sal_Bool SAL_CALL DisplayInfo::supportsService( const OUString& ServiceName ) throw (RuntimeException) -{ - Sequence< OUString > aSN( getSupportedServiceNames() ); - for( sal_Int32 nService = 0; nService < aSN.getLength(); nService++ ) - { - if( aSN[nService] == ServiceName ) - return sal_True; - } - return sal_False; -} - -Sequence< OUString > SAL_CALL DisplayInfo::getSupportedServiceNames() throw (RuntimeException) -{ - OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.DisplayInfo")); - return Sequence< OUString >(&aServiceName, 1); -} - -// ==================================================================== - -class DisplayAccess : public ::cppu::WeakAggImplHelper4< XPropertySet, XPropertySetInfo, XIndexAccess, XServiceInfo > -{ -public: - DisplayAccess (); - - // XPropertySet - virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (RuntimeException); - virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException); - virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException); - - // XPropertySetInfo - virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException); - virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException); - virtual ::sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException); - - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount() throw (RuntimeException); - virtual Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException); - - // XElementAccess - virtual Type SAL_CALL getElementType() throw (RuntimeException); - virtual ::sal_Bool SAL_CALL hasElements() throw (RuntimeException); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); -}; - -Sequence< OUString > DisplayAccess_getSupportedServiceNames() -{ - OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess" ) ); - return Sequence< OUString >( &aServiceName, 1 ); -} - -OUString DisplayAccess_getImplementationName() -{ - return OUString( RTL_CONSTASCII_USTRINGPARAM( "vcl::DisplayAccess" ) ); -} - -Reference< XInterface > SAL_CALL DisplayAccess_createInstance( const Reference< XMultiServiceFactory >& ) -{ - return static_cast< ::cppu::OWeakObject * >( new DisplayAccess ); -} - -DisplayAccess::DisplayAccess() -{ -} - -static const char* pUnifiedDisplayName = "IsUnifiedDisplay"; -static const char* pDefaultDisplayName = "DefaultDisplay"; -static const char* pBuiltInDisplayName = "BuiltInDisplay"; -static const char* pExternalDisplayName = "ExternalDisplay"; - -// XPropertySet -Reference< XPropertySetInfo > SAL_CALL DisplayAccess::getPropertySetInfo() throw (RuntimeException) -{ - return this; -} - -void SAL_CALL DisplayAccess::setPropertyValue( const OUString& /*aPropertyName* */, const Any& /*aValue*/ ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) -{ - throw PropertyVetoException(); -} - -Any SAL_CALL DisplayAccess::getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) -{ - Any aRet; - if( PropertyName.equalsAscii( pUnifiedDisplayName ) ) - { - aRet <<= sal_Bool( Application::IsUnifiedDisplay() ); - } - else if( PropertyName.equalsAscii( pDefaultDisplayName ) || // Unhelpful name, legacy setting - PropertyName.equalsAscii( pBuiltInDisplayName ) ) - { - aRet <<= sal_Int32( Application::GetDisplayBuiltInScreen() ); - } - else if( PropertyName.equalsAscii( pExternalDisplayName ) ) - { - // This is really unpleasant, in theory we could have multiple - // external displays etc. - sal_Int32 nExternal(0); - switch (Application::GetDisplayBuiltInScreen()) - { - case 0: - nExternal = 1; - break; - case 1: - nExternal = 0; - break; - default: - // When the built-in display is neither 0 nor 1 - // then place the full-screen presentation on the - // first available screen. - nExternal = 0; - break; - } - aRet <<= nExternal; - } - else - throw UnknownPropertyException(); - - return aRet; -} - -void SAL_CALL DisplayAccess::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} -void SAL_CALL DisplayAccess::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} -void SAL_CALL DisplayAccess::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} -void SAL_CALL DisplayAccess::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException) {} - -// XPropertySetInfo -Sequence< Property > SAL_CALL DisplayAccess::getProperties() throw (RuntimeException) -{ - Sequence< Property > aProps(4); - aProps[0] = getPropertyByName( OUString::createFromAscii( pUnifiedDisplayName ) ); - aProps[1] = getPropertyByName( OUString::createFromAscii( pDefaultDisplayName ) ); - aProps[2] = getPropertyByName( OUString::createFromAscii( pBuiltInDisplayName ) ); - aProps[3] = getPropertyByName( OUString::createFromAscii( pExternalDisplayName ) ); - return aProps; -} - -Property SAL_CALL DisplayAccess::getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException) -{ - if( aName.equalsAscii( pUnifiedDisplayName ) ) - return Property( aName, 0, ::getCppuType( (sal_Bool const *)0 ), PropertyAttribute::READONLY ); - - if( aName.equalsAscii( pDefaultDisplayName ) || - aName.equalsAscii( pBuiltInDisplayName ) || - aName.equalsAscii( pExternalDisplayName ) ) - return Property( aName, 0, ::getCppuType( (sal_Int32 const *)0 ), PropertyAttribute::READONLY ); - - throw UnknownPropertyException(); -} - -::sal_Bool SAL_CALL DisplayAccess::hasPropertyByName( const OUString& Name ) throw (RuntimeException) -{ - return Name.equalsAscii( pUnifiedDisplayName ) || - Name.equalsAscii( pDefaultDisplayName ) || - Name.equalsAscii( pBuiltInDisplayName ) || - Name.equalsAscii( pExternalDisplayName ); -} - -// XIndexAccess -::sal_Int32 SAL_CALL DisplayAccess::getCount() throw (RuntimeException) -{ - return Application::GetScreenCount(); -} - -Any SAL_CALL DisplayAccess::getByIndex( ::sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException) -{ - if( (Index < 0) || (Index >= getCount()) ) - throw IndexOutOfBoundsException(); - - return makeAny( Reference< XPropertySet >( new DisplayInfo( Index ) ) ); -} - -// XElementAccess -Type SAL_CALL DisplayAccess::getElementType() throw (RuntimeException) -{ - return XPropertySet::static_type(); -} - -::sal_Bool SAL_CALL DisplayAccess::hasElements() throw (RuntimeException) -{ - return true; -} - -// XServiceInfo -OUString SAL_CALL DisplayAccess::getImplementationName() throw (RuntimeException) -{ - return DisplayAccess_getImplementationName(); -} - -::sal_Bool SAL_CALL DisplayAccess::supportsService( const OUString& ServiceName ) throw (RuntimeException) -{ - Sequence< OUString > aSN( DisplayAccess_getSupportedServiceNames() ); - for( sal_Int32 nService = 0; nService < aSN.getLength(); nService++ ) - { - if( aSN[nService] == ServiceName ) - return sal_True; - } - return sal_False; -} - -Sequence< OUString > SAL_CALL DisplayAccess::getSupportedServiceNames() throw (RuntimeException) -{ - return DisplayAccess_getSupportedServiceNames(); -} - -} // namespace vcl - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/components/factory.cxx b/vcl/source/components/factory.cxx index 85bc7ee7ce9a..eb7c05bcce1f 100644 --- a/vcl/source/components/factory.cxx +++ b/vcl/source/components/factory.cxx @@ -37,10 +37,6 @@ extern Reference< XInterface > SAL_CALL vcl_session_createInstance( const Refere namespace vcl { -extern Sequence< OUString > SAL_CALL DisplayAccess_getSupportedServiceNames(); -extern OUString SAL_CALL DisplayAccess_getImplementationName(); -extern Reference< XInterface > SAL_CALL DisplayAccess_createInstance( const Reference< XMultiServiceFactory > & ); - extern Sequence< OUString > SAL_CALL FontIdentificator_getSupportedServiceNames(); extern OUString SAL_CALL FontIdentificator_getImplementationName(); extern Reference< XInterface > SAL_CALL FontIdentificator_createInstance( const Reference< XMultiServiceFactory > & ); @@ -84,12 +80,6 @@ extern "C" { xMgr, vcl_session_getImplementationName(), vcl_session_createInstance, vcl_session_getSupportedServiceNames() ); } - else if( vcl::DisplayAccess_getImplementationName().equalsAscii( pImplementationName ) ) - { - xFactory = ::cppu::createSingleFactory( - xMgr, vcl::DisplayAccess_getImplementationName(), vcl::DisplayAccess_createInstance, - vcl::DisplayAccess_getSupportedServiceNames() ); - } else if( vcl::FontIdentificator_getImplementationName().equalsAscii( pImplementationName ) ) { xFactory = ::cppu::createSingleFactory( diff --git a/vcl/vcl.android.component b/vcl/vcl.android.component index 299d8b36ed21..53ebfe36e74c 100644 --- a/vcl/vcl.android.component +++ b/vcl/vcl.android.component @@ -22,9 +22,6 @@ - - - diff --git a/vcl/vcl.headless.component b/vcl/vcl.headless.component index 299d8b36ed21..53ebfe36e74c 100644 --- a/vcl/vcl.headless.component +++ b/vcl/vcl.headless.component @@ -22,9 +22,6 @@ - - - diff --git a/vcl/vcl.ios.component b/vcl/vcl.ios.component index 299d8b36ed21..53ebfe36e74c 100644 --- a/vcl/vcl.ios.component +++ b/vcl/vcl.ios.component @@ -22,9 +22,6 @@ - - - diff --git a/vcl/vcl.macosx.component b/vcl/vcl.macosx.component index d0e7b408a612..5842d9a61500 100644 --- a/vcl/vcl.macosx.component +++ b/vcl/vcl.macosx.component @@ -31,9 +31,6 @@ - - - diff --git a/vcl/vcl.unx.component b/vcl/vcl.unx.component index cf51164c193e..35968751b743 100644 --- a/vcl/vcl.unx.component +++ b/vcl/vcl.unx.component @@ -31,9 +31,6 @@ - - - diff --git a/vcl/vcl.windows.component b/vcl/vcl.windows.component index 2e303fdaf8a1..921f299440b8 100644 --- a/vcl/vcl.windows.component +++ b/vcl/vcl.windows.component @@ -22,9 +22,6 @@ - - - diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index f2110d54677b..b673c463f59b 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -783,40 +783,27 @@ static void ImplSalCalcFullScreenSize( const WinSalFrame* pFrame, try { - uno::Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); - uno::Reference< XIndexAccess > xMultiMon( xFactory->createInstance( "com.sun.star.awt.DisplayAccess" ), UNO_QUERY_THROW ); - sal_Int32 nMonitors = xMultiMon->getCount(); + sal_Int32 nMonitors = Application::GetScreenCount(); if( (pFrame->mnDisplay >= 0) && (pFrame->mnDisplay < nMonitors) ) { - uno::Reference< XPropertySet > xMonitor( xMultiMon->getByIndex( pFrame->mnDisplay ), UNO_QUERY_THROW ); - com::sun::star::awt::Rectangle aRect; - if( xMonitor->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ScreenArea" ) ) ) >>= aRect ) - { - nScreenX = aRect.X; - nScreenY = aRect.Y; - nScreenDX = aRect.Width+1; // difference between java/awt convention and vcl - nScreenDY = aRect.Height+1; // difference between java/awt convention and vcl - } + com::sun::star::awt::Rectangle aRect = Application::GetScreenPosSizePixel( pFrame->mnDisplay ); + nScreenX = aRect.X; + nScreenY = aRect.Y; + nScreenDX = aRect.Width+1; // difference between java/awt convention and vcl + nScreenDY = aRect.Height+1; // difference between java/awt convention and vcl } else { Rectangle aCombined; - uno::Reference< XPropertySet > xMonitor( xMultiMon->getByIndex( 0 ), UNO_QUERY_THROW ); - com::sun::star::awt::Rectangle aRect; - if( xMonitor->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ScreenArea" ) ) ) >>= aRect ) + com::sun::star::awt::Rectangle aRect = Application::GetScreenPosSizePixel( 0 ); + aCombined.Left() = aRect.X; + aCombined.Top() = aRect.Y; + aCombined.Right() = aRect.X + aRect.Width; + aCombined.Bottom() = aRect.Y + aRect.Height; + for( sal_Int32 i = 1 ; i < nMonitors ; i++ ) { - aCombined.Left() = aRect.X; - aCombined.Top() = aRect.Y; - aCombined.Right() = aRect.X + aRect.Width; - aCombined.Bottom() = aRect.Y + aRect.Height; - for( sal_Int32 i = 1 ; i < nMonitors ; i++ ) - { - xMonitor = uno::Reference< XPropertySet >( xMultiMon->getByIndex(i), UNO_QUERY_THROW ); - if( xMonitor->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ScreenArea" ) ) ) >>= aRect ) - { - aCombined.Union( Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ); - } - } + aRect = Application::GetScreenPosSizePixel( i ); + aCombined.Union( Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ); } nScreenX = aCombined.Left(); nScreenY = aCombined.Top(); -- cgit