summaryrefslogtreecommitdiff
path: root/vcl/ios/source
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/ios/source')
-rw-r--r--vcl/ios/source/app/saldata.cxx72
-rw-r--r--vcl/ios/source/app/salinst.cxx806
-rw-r--r--vcl/ios/source/app/salnstimer.mm48
-rw-r--r--vcl/ios/source/app/salsys.cxx239
-rw-r--r--vcl/ios/source/app/saltimer.cxx93
-rw-r--r--vcl/ios/source/app/vcluiapp.mm90
-rw-r--r--vcl/ios/source/dtrans/iOSTransferable.cxx179
-rw-r--r--vcl/ios/source/dtrans/iOSTransferable.hxx86
-rw-r--r--vcl/ios/source/dtrans/ios_clipboard.cxx377
-rw-r--r--vcl/ios/source/dtrans/ios_clipboard.hxx173
-rw-r--r--vcl/ios/source/dtrans/service_entry.cxx62
-rw-r--r--vcl/ios/source/gdi/salgdicommon.cxx1599
-rw-r--r--vcl/ios/source/gdi/salgdiutils.cxx304
-rw-r--r--vcl/ios/source/gdi/salnativewidgets.cxx249
-rw-r--r--vcl/ios/source/gdi/salvd.cxx249
-rw-r--r--vcl/ios/source/window/salframe.cxx1106
-rw-r--r--vcl/ios/source/window/salframeview.mm263
-rw-r--r--vcl/ios/source/window/salmenu.cxx62
-rw-r--r--vcl/ios/source/window/salobj.cxx201
19 files changed, 0 insertions, 6258 deletions
diff --git a/vcl/ios/source/app/saldata.cxx b/vcl/ios/source/app/saldata.cxx
deleted file mode 100644
index f06b139364a3..000000000000
--- a/vcl/ios/source/app/saldata.cxx
+++ /dev/null
@@ -1,72 +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 "ios/saldata.hxx"
-#include "ios/saluimenu.h"
-#include "ios/salinst.h"
-
-oslThreadKey SalData::s_aAutoReleaseKey = 0;
-
-SalData::SalData()
-:
- mpTimerProc( NULL ),
- mpFirstInstance( NULL ),
- mpFirstObject( NULL ),
- mpFirstVD( NULL ),
- mpFirstPrinter( NULL ),
- mpFontList( NULL ),
- mxRGBSpace( CGColorSpaceCreateDeviceRGB( ) ),
- mxGraySpace( CGColorSpaceCreateDeviceGray( ) ),
- mxP50Space( NULL ),
- mxP50Pattern( NULL ),
- mnDPIX( 0 ),
- mnDPIY( 0 )
-{
- if( s_aAutoReleaseKey == 0 )
- s_aAutoReleaseKey = osl_createThreadKey( NULL );
-}
-
-SalData::~SalData()
-{
- CGPatternRelease( mxP50Pattern );
- CGColorSpaceRelease( mxP50Space );
- CGColorSpaceRelease( mxRGBSpace );
- CGColorSpaceRelease( mxGraySpace );
-}
-
-void SalData::ensureThreadAutoreleasePool()
-{
- NSAutoreleasePool* pPool = nil;
- if( s_aAutoReleaseKey )
- {
- pPool = reinterpret_cast<NSAutoreleasePool*>( osl_getThreadKeyData( s_aAutoReleaseKey ) );
- if( ! pPool )
- {
- pPool = [[NSAutoreleasePool alloc] init];
- osl_setThreadKeyData( s_aAutoReleaseKey, pPool );
- }
- }
- else
- {
- OSL_FAIL( "no autorelease key" );
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/app/salinst.cxx b/vcl/ios/source/app/salinst.cxx
deleted file mode 100644
index 91dd16077d18..000000000000
--- a/vcl/ios/source/app/salinst.cxx
+++ /dev/null
@@ -1,806 +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 <stdio.h>
-
-#include "tools/fsys.hxx"
-#include "tools/getprocessworkingdir.hxx"
-#include <tools/solarmutex.hxx>
-
-#include "osl/process.h"
-
-#include "rtl/ustrbuf.hxx"
-
-#include "vcl/svapp.hxx"
-#include "vcl/window.hxx"
-#include "vcl/timer.hxx"
-#include "vcl/solarmutex.hxx"
-
-#include "ios/saldata.hxx"
-#include "ios/salinst.h"
-#include "ios/salframe.h"
-#include "ios/salobj.h"
-#include "ios/salsys.h"
-#include "ios/salvd.h"
-#include "quartz/salbmp.h"
-#include "ios/salprn.h"
-#include "ios/saltimer.h"
-#include "ios/vcluiapp.h"
-
-#include "print.h"
-#include "impbmp.hxx"
-#include "salimestatus.hxx"
-
-#include <comphelper/processfactory.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
-#include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-
-using namespace std;
-using namespace ::com::sun::star;
-
-extern sal_Bool ImplSVMain();
-
-static int* gpnInit = 0;
-static bool bNoSVMain = true;
-// -----------------------------------------------------------------------
-
-class IosDelayedSettingsChanged : public Timer
-{
- bool mbInvalidate;
- public:
- IosDelayedSettingsChanged( bool bInvalidate ) :
- mbInvalidate( bInvalidate )
- {
- }
-
- virtual void Timeout()
- {
- SalData* pSalData = GetSalData();
- if( ! pSalData->maFrames.empty() )
- pSalData->maFrames.front()->CallCallback( SALEVENT_SETTINGSCHANGED, NULL );
-
- if( mbInvalidate )
- {
- for( std::list< IosSalFrame* >::iterator it = pSalData->maFrames.begin();
- it != pSalData->maFrames.end(); ++it )
- {
- if( (*it)->mbShown )
- (*it)->SendPaintEvent( NULL );
- }
- }
- Stop();
- delete this;
- }
-};
-
-void IosSalInstance::delayedSettingsChanged( bool bInvalidate )
-{
- osl::SolarGuard aGuard( *mpSalYieldMutex );
- IosDelayedSettingsChanged* pTimer = new IosDelayedSettingsChanged( bInvalidate );
- pTimer->SetTimeout( 50 );
- pTimer->Start();
-}
-
-
-// the AppEventList must be available before any SalData/SalInst/etc. objects are ready
-typedef std::list<const ApplicationEvent*> AppEventList;
-AppEventList IosSalInstance::aAppEventList;
-
-// initialize the VCL_UIApplication object
-static void initUIApp()
-{
- [VCL_UIApplication sharedApplication];
-
- SalData::ensureThreadAutoreleasePool();
-}
-
-sal_Bool ImplSVMainHook( int * pnInit )
-{
- char sMain[] = "main";
- gpnInit = pnInit;
-
- bNoSVMain = false;
- initUIApp();
-
- char* pArgv[] = { sMain, NULL };
- UIApplicationMain( 1, pArgv, NULL, NULL );
-
- return TRUE; // indicate that ImplSVMainHook is implemented
-}
-
-// =======================================================================
-
-void SalAbort( const rtl::OUString& rErrorText, bool bDumpCore )
-{
- if( rErrorText.isEmpty() )
- fprintf( stderr, "Application Error " );
- else
- fprintf( stderr, "%s ",
- rtl::OUStringToOString( rErrorText, osl_getThreadTextEncoding() ).getStr() );
- if( bDumpCore )
- abort();
- else
- _exit(1);
-}
-
-// -----------------------------------------------------------------------
-
-void InitSalData()
-{
- SalData *pSalData = new SalData;
- SetSalData( pSalData );
-}
-
-// -----------------------------------------------------------------------
-
-const ::rtl::OUString& SalGetDesktopEnvironment()
-{
- static OUString aDesktopEnvironment( "CocoaTouch" );
- return aDesktopEnvironment;
-}
-
-// -----------------------------------------------------------------------
-
-void DeInitSalData()
-{
- SalData *pSalData = GetSalData();
- delete pSalData;
- SetSalData( NULL );
-}
-
-// -----------------------------------------------------------------------
-
-void InitSalMain()
-{
- // I doubt anything is needed on iOS
-}
-
-// =======================================================================
-
-SalYieldMutex::SalYieldMutex()
-{
- mnCount = 0;
- mnThreadId = 0;
-}
-
-void SalYieldMutex::acquire()
-{
- SolarMutexObject::acquire();
- mnThreadId = osl::Thread::getCurrentIdentifier();
- mnCount++;
-}
-
-void SalYieldMutex::release()
-{
- if ( mnThreadId == osl::Thread::getCurrentIdentifier() )
- {
- if ( mnCount == 1 )
- mnThreadId = 0;
- mnCount--;
- }
- SolarMutexObject::release();
-}
-
-sal_Bool SalYieldMutex::tryToAcquire()
-{
- if ( SolarMutexObject::tryToAcquire() )
- {
- mnThreadId = osl::Thread::getCurrentIdentifier();
- mnCount++;
- return sal_True;
- }
- else
- return sal_False;
-}
-
-// -----------------------------------------------------------------------
-
-// some convenience functions regarding the yield mutex, aka solar mutex
-
-sal_Bool ImplSalYieldMutexTryToAcquire()
-{
- IosSalInstance* pInst = (IosSalInstance*) GetSalData()->mpFirstInstance;
- if ( pInst )
- return pInst->mpSalYieldMutex->tryToAcquire();
- else
- return FALSE;
-}
-
-void ImplSalYieldMutexAcquire()
-{
- IosSalInstance* pInst = (IosSalInstance*) GetSalData()->mpFirstInstance;
- if ( pInst )
- pInst->mpSalYieldMutex->acquire();
-}
-
-void ImplSalYieldMutexRelease()
-{
- IosSalInstance* pInst = (IosSalInstance*) GetSalData()->mpFirstInstance;
- if ( pInst )
- pInst->mpSalYieldMutex->release();
-}
-
-// =======================================================================
-
-SalInstance* CreateSalInstance()
-{
- // this is the case for not using SVMain
- // not so good
- if( bNoSVMain )
- initUIApp();
-
- SalData* pSalData = GetSalData();
- DBG_ASSERT( pSalData->mpFirstInstance == NULL, "more than one instance created" );
- IosSalInstance* pInst = new IosSalInstance;
-
- // init instance (only one instance in this version !!!)
- pSalData->mpFirstInstance = pInst;
- // this one is for outside IosSalInstance::Yield
- SalData::ensureThreadAutoreleasePool();
- // no focus rects on NWF ios
- ImplGetSVData()->maNWFData.mbNoFocusRects = true;
- ImplGetSVData()->maNWFData.mbNoActiveTabTextRaise = true;
- ImplGetSVData()->maNWFData.mbCenteredTabs = true;
- ImplGetSVData()->maNWFData.mbProgressNeedsErase = true;
- ImplGetSVData()->maNWFData.mbCheckBoxNeedsErase = true;
- ImplGetSVData()->maNWFData.mnStatusBarLowerRightOffset = 10;
- ImplGetSVData()->maGDIData.mbNoXORClipping = true;
- ImplGetSVData()->maWinData.mbNoSaveBackground = true;
-
- return pInst;
-}
-
-// -----------------------------------------------------------------------
-
-void DestroySalInstance( SalInstance* pInst )
-{
- delete pInst;
-}
-
-// -----------------------------------------------------------------------
-
-IosSalInstance::IosSalInstance()
-{
- mpSalYieldMutex = new SalYieldMutex;
- mpSalYieldMutex->acquire();
- ::tools::SolarMutex::SetSolarMutex( mpSalYieldMutex );
- maMainThread = osl::Thread::getCurrentIdentifier();
- mbWaitingYield = false;
- maUserEventListMutex = osl_createMutex();
- mnActivePrintJobs = 0;
- maWaitingYieldCond = osl_createCondition();
-}
-
-// -----------------------------------------------------------------------
-
-IosSalInstance::~IosSalInstance()
-{
- ::tools::SolarMutex::SetSolarMutex( 0 );
- mpSalYieldMutex->release();
- delete mpSalYieldMutex;
- osl_destroyMutex( maUserEventListMutex );
- osl_destroyCondition( maWaitingYieldCond );
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::wakeupYield()
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::PostUserEvent( IosSalFrame* pFrame, sal_uInt16 nType, void* pData )
-{
- osl_acquireMutex( maUserEventListMutex );
- maUserEvents.push_back( SalUserEvent( pFrame, pData, nType ) );
- osl_releaseMutex( maUserEventListMutex );
-
- // notify main loop that an event has arrived
- wakeupYield();
-}
-
-// -----------------------------------------------------------------------
-
-osl::SolarMutex* IosSalInstance::GetYieldMutex()
-{
- return mpSalYieldMutex;
-}
-
-// -----------------------------------------------------------------------
-
-sal_uLong IosSalInstance::ReleaseYieldMutex()
-{
- SalYieldMutex* pYieldMutex = mpSalYieldMutex;
- if ( pYieldMutex->GetThreadId() ==
- osl::Thread::getCurrentIdentifier() )
- {
- sal_uLong nCount = pYieldMutex->GetAcquireCount();
- sal_uLong n = nCount;
- while ( n )
- {
- pYieldMutex->release();
- n--;
- }
-
- return nCount;
- }
- else
- return 0;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::AcquireYieldMutex( sal_uLong nCount )
-{
- SalYieldMutex* pYieldMutex = mpSalYieldMutex;
- while ( nCount )
- {
- pYieldMutex->acquire();
- nCount--;
- }
-}
-
-// -----------------------------------------------------------------------
-
-bool IosSalInstance::CheckYieldMutex()
-{
- bool bRet = true;
-
- SalYieldMutex* pYieldMutex = mpSalYieldMutex;
- if ( pYieldMutex->GetThreadId() != osl::Thread::getCurrentIdentifier())
- {
- bRet = false;
- }
-
- return bRet;
-}
-
-// -----------------------------------------------------------------------
-
-bool IosSalInstance::isUIAppThread() const
-{
- return osl::Thread::getCurrentIdentifier() == maMainThread;
-}
-
-// -----------------------------------------------------------------------
-
-class ReleasePoolHolder
-{
- NSAutoreleasePool* mpPool;
- public:
- ReleasePoolHolder() : mpPool( [[NSAutoreleasePool alloc] init] ) {}
- ~ReleasePoolHolder() { [mpPool release]; }
-};
-
-void IosSalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents )
-{
- // ensure that the per thread autorelease pool is top level and
- // will therefore not be destroyed by cocoa implicitly
- SalData::ensureThreadAutoreleasePool();
-
- // NSAutoreleasePool documentation suggests we should have
- // an own pool for each yield level
- ReleasePoolHolder aReleasePool;
-
- // Release all locks so that we don't deadlock when we pull pending
- // events from the event queue
- bool bDispatchUser = true;
- while( bDispatchUser )
- {
- sal_uLong nCount = ReleaseYieldMutex();
-
- // get one user event
- osl_acquireMutex( maUserEventListMutex );
- SalUserEvent aEvent( NULL, NULL, 0 );
- if( ! maUserEvents.empty() )
- {
- aEvent = maUserEvents.front();
- maUserEvents.pop_front();
- }
- else
- bDispatchUser = false;
- osl_releaseMutex( maUserEventListMutex );
-
- AcquireYieldMutex( nCount );
-
- // dispatch it
- if( aEvent.mpFrame && IosSalFrame::isAlive( aEvent.mpFrame ) )
- {
- aEvent.mpFrame->CallCallback( aEvent.mnType, aEvent.mpData );
- osl_setCondition( maWaitingYieldCond );
- // return if only one event is asked for
- if( ! bHandleAllCurrentEvents )
- return;
- }
- }
-
- // handle event queue
- // events mye be only handled in the thread the app was created
- if( mnActivePrintJobs == 0 )
- {
- // we need to be woken up by a cocoa-event
- // if a user event should be posted by the event handling below
- bool bOldWaitingYield = mbWaitingYield;
- mbWaitingYield = bWait;
-
- mbWaitingYield = bOldWaitingYield;
-
- // collect update rectangles
- const std::list< IosSalFrame* > rFrames( GetSalData()->maFrames );
- for( std::list< IosSalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it )
- {
- if( (*it)->mbShown && ! (*it)->maInvalidRect.IsEmpty() )
- {
- (*it)->Flush( (*it)->maInvalidRect );
- (*it)->maInvalidRect.SetEmpty();
- }
- }
- osl_setCondition( maWaitingYieldCond );
- }
-}
-
-// -----------------------------------------------------------------------
-
-bool IosSalInstance::AnyInput( sal_uInt16 nType )
-{
- if( nType & VCL_INPUT_APPEVENT )
- {
- if( ! aAppEventList.empty() )
- return true;
- if( nType == VCL_INPUT_APPEVENT )
- return false;
- }
-
- if( nType & VCL_INPUT_TIMER )
- {
- if( IosSalTimer::pRunningTimer )
- {
- NSDate* pDt = [IosSalTimer::pRunningTimer fireDate];
- if( pDt && [pDt timeIntervalSinceNow] < 0 )
- {
- return true;
- }
- }
- }
- return false;
-}
-
-// -----------------------------------------------------------------------
-
-SalFrame* IosSalInstance::CreateChildFrame( SystemParentData*, sal_uLong /*nSalFrameStyle*/ )
-{
- return NULL;
-}
-
-// -----------------------------------------------------------------------
-
-SalFrame* IosSalInstance::CreateFrame( SalFrame* pParent, sal_uLong nSalFrameStyle )
-{
- SalData::ensureThreadAutoreleasePool();
-
- SalFrame* pFrame = new IosSalFrame( pParent, nSalFrameStyle );
- return pFrame;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::DestroyFrame( SalFrame* pFrame )
-{
- delete pFrame;
-}
-
-// -----------------------------------------------------------------------
-
-SalObject* IosSalInstance::CreateObject( SalFrame* pParent, SystemWindowData* /* pWindowData */, sal_Bool /* bShow */ )
-{
- // SystemWindowData is meaningless on Mac OS X
- IosSalObject *pObject = NULL;
-
- if ( pParent )
- pObject = new IosSalObject( static_cast<IosSalFrame*>(pParent) );
-
- return pObject;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::DestroyObject( SalObject* pObject )
-{
- delete ( pObject );
-}
-
-// -----------------------------------------------------------------------
-
-SalPrinter* IosSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
-{
- (void) pInfoPrinter;
- return NULL;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::DestroyPrinter( SalPrinter* pPrinter )
-{
- delete pPrinter;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
-{
- // ???
- (void) pList;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* )
-{
- // ???
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo )
-{
- delete pInfo;
-}
-
-// -----------------------------------------------------------------------
-
-rtl::OUString IosSalInstance::GetDefaultPrinter()
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- // ???
- return maDefaultPrinter;
-}
-
-// -----------------------------------------------------------------------
-
-SalInfoPrinter* IosSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
- ImplJobSetup* pSetupData )
-{
- (void) pQueueInfo;
- (void) pSetupData;
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- SalInfoPrinter* pNewInfoPrinter = NULL;
-
- // ???
-
- return pNewInfoPrinter;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- delete pPrinter;
-}
-
-// -----------------------------------------------------------------------
-
-SalSystem* IosSalInstance::CreateSystem()
-{
- return new IosSalSystem();
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::DestroySystem( SalSystem* pSystem )
-{
- delete pSystem;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::SetEventCallback( void*, bool(*)(void*,void*,int) )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::SetErrorEventCallback( void*, bool(*)(void*,void*,int) )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void* IosSalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes )
-{
- rReturnedBytes = 1;
- rReturnedType = AsciiCString;
- return (void*)"";
-}
-
-void IosSalInstance::AddToRecentDocumentList(const rtl::OUString& /*rFileUrl*/, const rtl::OUString& /*rMimeType*/)
-{
-}
-
-// -----------------------------------------------------------------------
-
-SalTimer* IosSalInstance::CreateSalTimer()
-{
- return new IosSalTimer();
-}
-
-// -----------------------------------------------------------------------
-
-SalSystem* IosSalInstance::CreateSalSystem()
-{
- return new IosSalSystem();
-}
-
-// -----------------------------------------------------------------------
-
-SalBitmap* IosSalInstance::CreateSalBitmap()
-{
- return new QuartzSalBitmap();
-}
-
-// -----------------------------------------------------------------------
-
-SalSession* IosSalInstance::CreateSalSession()
-{
- return NULL;
-}
-
-// -----------------------------------------------------------------------
-
-class IOsImeStatus : public SalI18NImeStatus
-{
-public:
- IOsImeStatus() {}
- virtual ~IOsImeStatus() {}
-
- // asks whether there is a status window available
- // to toggle into menubar
- virtual bool canToggle() { return false; }
- virtual void toggle() {}
-};
-
-// -----------------------------------------------------------------------
-
-SalI18NImeStatus* IosSalInstance::CreateI18NImeStatus()
-{
- return new IOsImeStatus();
-}
-
-// -----------------------------------------------------------------------
-
-// YieldMutexReleaser
-YieldMutexReleaser::YieldMutexReleaser() : mnCount( 0 )
-{
- SalData* pSalData = GetSalData();
- if( ! pSalData->mpFirstInstance->isUIAppThread() )
- {
- SalData::ensureThreadAutoreleasePool();
- mnCount = pSalData->mpFirstInstance->ReleaseYieldMutex();
- }
-}
-
-YieldMutexReleaser::~YieldMutexReleaser()
-{
- if( mnCount != 0 )
- GetSalData()->mpFirstInstance->AcquireYieldMutex( mnCount );
-}
-
-//////////////////////////////////////////////////////////////
-rtl::OUString GetOUString( CFStringRef rStr )
-{
- if( rStr == 0 )
- return rtl::OUString();
- CFIndex nLength = CFStringGetLength( rStr );
- if( nLength == 0 )
- return rtl::OUString();
- const UniChar* pConstStr = CFStringGetCharactersPtr( rStr );
- if( pConstStr )
- return rtl::OUString( pConstStr, nLength );
- UniChar* pStr = reinterpret_cast<UniChar*>( rtl_allocateMemory( sizeof(UniChar)*nLength ) );
- CFRange aRange = { 0, nLength };
- CFStringGetCharacters( rStr, aRange, pStr );
- rtl::OUString aRet( pStr, nLength );
- rtl_freeMemory( pStr );
- return aRet;
-}
-
-rtl::OUString GetOUString( NSString* pStr )
-{
- if( ! pStr )
- return rtl::OUString();
- int nLen = [pStr length];
- if( nLen == 0 )
- return rtl::OUString();
-
- rtl::OUStringBuffer aBuf( nLen+1 );
- aBuf.setLength( nLen );
- [pStr getCharacters: const_cast<sal_Unicode*>(aBuf.getStr())];
- return aBuf.makeStringAndClear();
-}
-
-CFStringRef CreateCFString( const rtl::OUString& rStr )
-{
- return CFStringCreateWithCharacters(kCFAllocatorDefault, rStr.getStr(), rStr.getLength() );
-}
-
-NSString* CreateNSString( const rtl::OUString& rStr )
-{
- return [[NSString alloc] initWithCharacters: rStr.getStr() length: rStr.getLength()];
-}
-
-CGImageRef CreateCGImage( const Image& rImage )
-{
- BitmapEx aBmpEx( rImage.GetBitmapEx() );
- Bitmap aBmp( aBmpEx.GetBitmap() );
-
- if( ! aBmp || ! aBmp.ImplGetImpBitmap() )
- return NULL;
-
- // simple case, no transparency
- QuartzSalBitmap* pSalBmp = static_cast<QuartzSalBitmap*>(aBmp.ImplGetImpBitmap()->ImplGetSalBitmap());
-
- if( ! pSalBmp )
- return NULL;
-
- CGImageRef xImage = NULL;
- if( ! (aBmpEx.IsAlpha() || aBmpEx.IsTransparent() ) )
- xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- else if( aBmpEx.IsAlpha() )
- {
- AlphaMask aAlphaMask( aBmpEx.GetAlpha() );
- Bitmap aMask( aAlphaMask.GetBitmap() );
- QuartzSalBitmap* pMaskBmp = static_cast<QuartzSalBitmap*>(aMask.ImplGetImpBitmap()->ImplGetSalBitmap());
- if( pMaskBmp )
- xImage = pSalBmp->CreateWithMask( *pMaskBmp, 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- else
- xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- }
- else if( aBmpEx.GetTransparentType() == TRANSPARENT_BITMAP )
- {
- Bitmap aMask( aBmpEx.GetMask() );
- QuartzSalBitmap* pMaskBmp = static_cast<QuartzSalBitmap*>(aMask.ImplGetImpBitmap()->ImplGetSalBitmap());
- if( pMaskBmp )
- xImage = pSalBmp->CreateWithMask( *pMaskBmp, 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- else
- xImage = pSalBmp->CreateCroppedImage( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight );
- }
- else if( aBmpEx.GetTransparentType() == TRANSPARENT_COLOR )
- {
- Color aTransColor( aBmpEx.GetTransparentColor() );
- SalColor nTransColor = MAKE_SALCOLOR( aTransColor.GetRed(), aTransColor.GetGreen(), aTransColor.GetBlue() );
- xImage = pSalBmp->CreateColorMask( 0, 0, pSalBmp->mnWidth, pSalBmp->mnHeight, nTransColor );
- }
-
- return xImage;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/app/salnstimer.mm b/vcl/ios/source/app/salnstimer.mm
deleted file mode 100644
index db0e37a6ce31..000000000000
--- a/vcl/ios/source/app/salnstimer.mm
+++ /dev/null
@@ -1,48 +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 "ios/saltimer.h"
-#include "ios/salnstimer.h"
-#include "ios/salinst.h"
-#include "ios/saldata.hxx"
-
-#include "svdata.hxx"
-
-@implementation TimerCallbackCaller
--(void)timerElapsed:(NSTimer*)pTimer
-{
- (void)pTimer;
- ImplSVData* pSVData = ImplGetSVData();
- if( IosSalTimer::bDispatchTimer )
- {
- if( pSVData->mpSalTimer )
- {
- YIELD_GUARD;
- pSVData->mpSalTimer->CallCallback();
-
- // NSTimer does not end nextEventMatchingMask of NSApplication
- // so we need to wakeup a waiting Yield to inform it something happened
- GetSalData()->mpFirstInstance->wakeupYield();
- }
- }
-}
-@end
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/app/salsys.cxx b/vcl/ios/source/app/salsys.cxx
deleted file mode 100644
index 37ac4e4d99b1..000000000000
--- a/vcl/ios/source/app/salsys.cxx
+++ /dev/null
@@ -1,239 +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 "rtl/ustrbuf.hxx"
-
-#include "vcl/button.hxx"
-
-#include "ios/salsys.h"
-#include "ios/saldata.hxx"
-#include "ios/salinst.h"
-
-#include "svids.hrc"
-
-using ::rtl::OUString;
-
-// =======================================================================
-
-IosSalSystem::~IosSalSystem()
-{
-}
-
-unsigned int IosSalSystem::GetDisplayScreenCount()
-{
- NSArray* pScreens = [UIScreen screens];
- return pScreens ? [pScreens count] : 1;
-}
-
-Rectangle IosSalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
-{
- NSArray* pScreens = [UIScreen screens];
- Rectangle aRet;
- UIScreen* pScreen = nil;
- if( pScreens && nScreen < [pScreens count] )
- pScreen = [pScreens objectAtIndex: nScreen];
- else
- pScreen = [UIScreen mainScreen];
-
- if( pScreen )
- {
- CGRect aFrame = pScreen.bounds;
- aRet = Rectangle( Point( static_cast<long int>(aFrame.origin.x), static_cast<long int>(aFrame.origin.y) ),
- Size( static_cast<long int>(aFrame.size.width), static_cast<long int>(aFrame.size.height) ) );
- }
- return aRet;
-}
-
-Rectangle IosSalSystem::GetDisplayScreenWorkAreaPosSizePixel( unsigned int nScreen )
-{
- NSArray* pScreens = [UIScreen screens];
- Rectangle aRet;
- UIScreen* pScreen = nil;
- if( pScreens && nScreen < [pScreens count] )
- pScreen = [pScreens objectAtIndex: nScreen];
- else
- pScreen = [UIScreen mainScreen];
-
- if( pScreen )
- {
- CGRect aFrame = pScreen.applicationFrame;
- aRet = Rectangle( Point( static_cast<long int>(aFrame.origin.x), static_cast<long int>(aFrame.origin.y) ),
- Size( static_cast<long int>(aFrame.size.width), static_cast<long int>(aFrame.size.height) ) );
- }
- return aRet;
-}
-
-rtl::OUString IosSalSystem::GetDisplayScreenName( unsigned int nScreen )
-{
- NSArray* pScreens = [UIScreen screens];
- OUString aRet;
- if( nScreen < [pScreens count] )
- {
- ResMgr* pMgr = ImplGetResMgr();
- if( pMgr )
- {
- String aScreenName( ResId( SV_MAC_SCREENNNAME, *pMgr ) );
- aScreenName.SearchAndReplaceAllAscii( "%d", OUString::number( nScreen ) );
- aRet = aScreenName;
- }
- }
- return aRet;
-}
-
-static NSString* getStandardString( int nButtonId, bool bUseResources )
-{
- rtl::OUString aText;
- if( bUseResources )
- {
- aText = Button::GetStandardText( nButtonId );
- }
- if( ! aText.getLength() ) // this is for bad cases, we might be missing the vcl resource
- {
- switch( nButtonId )
- {
- case BUTTON_OK: aText = rtl::OUString( "OK" );break;
- case BUTTON_ABORT: aText = rtl::OUString( "Abort" );break;
- case BUTTON_CANCEL: aText = rtl::OUString( "Cancel" );break;
- case BUTTON_RETRY: aText = rtl::OUString( "Retry" );break;
- case BUTTON_YES: aText = rtl::OUString( "Yes" );break;
- case BUTTON_NO : aText = rtl::OUString( "No" );break;
- }
- }
- return aText.getLength() ? CreateNSString( aText) : nil;
-}
-
-@interface MessageboxDelegate : NSObject <UIAlertViewDelegate>
-{
- int *_resultPtr;
-}
-- (id)initWithResultPtr:(int *)resultPtr;
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
-@end
-
-@implementation MessageboxDelegate
-- (id)initWithResultPtr:(int *)resultPtr
-{
- _resultPtr = resultPtr;
- return [super init];
-}
-
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
- (void) alertView;
-
- *_resultPtr = buttonIndex;
-}
-@end
-
-int IosSalSystem::ShowNativeMessageBox( const rtl::OUString& rTitle,
- const rtl::OUString& rMessage,
- int nButtonCombination,
- int nDefaultButton, bool bUseResources)
-{
- NSString* pTitle = CreateNSString( rTitle );
- NSString* pMessage = CreateNSString( rMessage );
-
- struct id_entry
- {
- int nCombination;
- int nDefaultButton;
- int nTextIds[3];
- } aButtonIds[] =
- {
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, { BUTTON_OK, -1, -1 } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK, { BUTTON_OK, BUTTON_CANCEL, -1 } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, { BUTTON_CANCEL, BUTTON_OK, -1 } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT, { BUTTON_ABORT, BUTTON_IGNORE, BUTTON_RETRY } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY, { BUTTON_RETRY, BUTTON_IGNORE, BUTTON_ABORT } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE, { BUTTON_IGNORE, BUTTON_IGNORE, BUTTON_ABORT } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES, { BUTTON_YES, BUTTON_NO, BUTTON_CANCEL } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO, { BUTTON_NO, BUTTON_YES, BUTTON_CANCEL } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, { BUTTON_CANCEL, BUTTON_YES, BUTTON_NO } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES, { BUTTON_YES, BUTTON_NO, -1 } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO, { BUTTON_NO, BUTTON_YES, -1 } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY, { BUTTON_RETRY, BUTTON_CANCEL, -1 } },
- { SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL, SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL, { BUTTON_CANCEL, BUTTON_RETRY, -1 } }
- };
-
- NSString* pDefText = nil;
- NSString* pAltText = nil;
- NSString* pOthText = nil;
-
- unsigned int nC;
- for( nC = 0; nC < sizeof(aButtonIds)/sizeof(aButtonIds[0]); nC++ )
- {
- if( aButtonIds[nC].nCombination == nButtonCombination )
- {
- if( aButtonIds[nC].nDefaultButton == nDefaultButton )
- {
- if( aButtonIds[nC].nTextIds[0] != -1 )
- pDefText = getStandardString(
- aButtonIds[nC].nTextIds[0], bUseResources );
- if( aButtonIds[nC].nTextIds[1] != -1 )
- pAltText = getStandardString(
- aButtonIds[nC].nTextIds[1], bUseResources );
- if( aButtonIds[nC].nTextIds[2] != -1 )
- pOthText = getStandardString(
- aButtonIds[nC].nTextIds[2], bUseResources );
- break;
- }
- }
- }
-
- int nResult = 1; // ???
- // How to do the delegate when this is C++?
- MessageboxDelegate *delegate = [[MessageboxDelegate alloc] initWithResultPtr: &nResult];
- UIAlertView *view = [[UIAlertView alloc] initWithTitle: pTitle message: pMessage delegate: delegate
- cancelButtonTitle: @"Cancel" otherButtonTitles: nil];
- [view show];
- [view dealloc];
- [delegate dealloc];
-
- if( pTitle )
- [pTitle release];
- if( pMessage )
- [pMessage release];
- if( pDefText )
- [pDefText release];
- if( pAltText )
- [pAltText release];
- if( pOthText )
- [pOthText release];
-
- int nRet = 0;
- if( nC < sizeof(aButtonIds)/sizeof(aButtonIds[0]) && nResult >= 1 && nResult <= 3 )
- {
- int nPressed = aButtonIds[nC].nTextIds[nResult-1];
- switch( nPressed )
- {
- case BUTTON_NO: nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO; break;
- case BUTTON_YES: nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES; break;
- case BUTTON_OK: nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK; break;
- case BUTTON_CANCEL: nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL; break;
- case BUTTON_ABORT: nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT; break;
- case BUTTON_RETRY: nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY; break;
- case BUTTON_IGNORE: nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE; break;
- }
- }
-
- return nRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/app/saltimer.cxx b/vcl/ios/source/app/saltimer.cxx
deleted file mode 100644
index d5a8bc434f8f..000000000000
--- a/vcl/ios/source/app/saltimer.cxx
+++ /dev/null
@@ -1,93 +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 "ios/saltimer.h"
-#include "ios/salnstimer.h"
-#include "ios/saldata.hxx"
-#include "ios/salframe.h"
-#include "ios/salinst.h"
-
-// =======================================================================
-
-NSTimer* IosSalTimer::pRunningTimer = nil;
-bool IosSalTimer::bDispatchTimer = false;
-
-
-void ImplSalStartTimer( sal_uLong nMS )
-{
- SalData* pSalData = GetSalData();
- if( pSalData->mpFirstInstance->isUIAppThread() )
- {
- IosSalTimer::bDispatchTimer = true;
- NSTimeInterval aTI = double(nMS)/1000.0;
- if( IosSalTimer::pRunningTimer != nil )
- {
- if( [IosSalTimer::pRunningTimer timeInterval] == aTI )
- // set new fire date
- [IosSalTimer::pRunningTimer setFireDate: [NSDate dateWithTimeIntervalSinceNow: aTI]];
- else
- {
- [IosSalTimer::pRunningTimer invalidate];
- IosSalTimer::pRunningTimer = nil;
- }
- }
- if( IosSalTimer::pRunningTimer == nil )
- {
- IosSalTimer::pRunningTimer = [NSTimer scheduledTimerWithTimeInterval: aTI
- target: [[[TimerCallbackCaller alloc] init] autorelease]
- selector: @selector(timerElapsed:)
- userInfo: nil
- repeats: YES];
- }
- }
- else
- {
- SalData::ensureThreadAutoreleasePool();
- // post an event so we can get into the main thread
- // ???
- }
-}
-
-void ImplSalStopTimer()
-{
- IosSalTimer::bDispatchTimer = false;
-}
-
-IosSalTimer::IosSalTimer( )
-{
-}
-
-IosSalTimer::~IosSalTimer()
-{
- ImplSalStopTimer();
-}
-
-void IosSalTimer::Start( sal_uLong nMS )
-{
- ImplSalStartTimer( nMS );
-}
-
-void IosSalTimer::Stop()
-{
- ImplSalStopTimer();
-}
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/app/vcluiapp.mm b/vcl/ios/source/app/vcluiapp.mm
deleted file mode 100644
index 7344937f0212..000000000000
--- a/vcl/ios/source/app/vcluiapp.mm
+++ /dev/null
@@ -1,90 +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 "rtl/ustrbuf.hxx"
-
-#include "vcl/window.hxx"
-#include "vcl/svapp.hxx"
-#include "vcl/cmdevt.hxx"
-
-#include "ios/vcluiapp.h"
-#include "ios/salinst.h"
-#include "ios/saldata.hxx"
-#include "ios/salframe.h"
-#include "ios/salframeview.h"
-
-#include "impimagetree.hxx"
-
-@implementation VCL_UIApplication
--(void)sendEvent:(UIEvent*)pEvent
-{
- [super sendEvent: pEvent];
-}
-
--(void)sendSuperEvent:(UIEvent*)pEvent
-{
- [super sendEvent: pEvent];
-}
-
--(BOOL)application: (UIApplication*)app openFile: (NSString*)pFile
-{
- (void)app;
- const rtl::OUString aFile( GetOUString( pFile ) );
- return YES;
-}
-
--(void)application: (UIApplication*) app openFiles: (NSArray*)files
-{
- (void)app;
- rtl::OUStringBuffer aFileList( 256 );
-
- NSEnumerator* it = [files objectEnumerator];
- NSString* pFile = nil;
-
- while( (pFile = [it nextObject]) != nil )
- {
- const rtl::OUString aFile( GetOUString( pFile ) );
- }
-
- if( aFileList.getLength() )
- {
- // we have no back channel here, we have to assume success, in which case
- // replyToOpenOrPrint does not need to be called according to documentation
- // [app replyToOpenOrPrint: NSApplicationDelegateReplySuccess];
- const ApplicationEvent* pAppEvent = new ApplicationEvent(ApplicationEvent::TYPE_OPEN, aFileList.makeStringAndClear());
- IosSalInstance::aAppEventList.push_back( pAppEvent );
- }
-}
-
--(void)addFallbackMenuItem: (UIMenuItem*)pNewItem
-{
- // ???
- (void) pNewItem;
-}
-
--(void)removeFallbackMenuItem: (UIMenuItem*)pItem
-{
- // ???
- (void) pItem;
-}
-
-@end
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/dtrans/iOSTransferable.cxx b/vcl/ios/source/dtrans/iOSTransferable.cxx
deleted file mode 100644
index 2ff71156c01d..000000000000
--- a/vcl/ios/source/dtrans/iOSTransferable.cxx
+++ /dev/null
@@ -1,179 +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 <sal/types.h>
-
-#include "iOSTransferable.hxx"
-
-using namespace std;
-using namespace osl;
-using namespace cppu;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::datatransfer;
-using namespace com::sun::star::io;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::container;
-
-using ::rtl::OUString;
-
-namespace // private
-{
- bool isValidFlavor( const DataFlavor& aFlavor )
- {
- size_t len = aFlavor.MimeType.getLength();
- Type dtype = aFlavor.DataType;
- return ((len > 0) && ((dtype == getCppuType((Sequence<sal_Int8>*)0)) || (dtype == getCppuType((OUString*)0))));
- }
-
-} // namespace private
-
-
-iOSTransferable::iOSTransferable(const Reference<XMimeContentTypeFactory> rXMimeCntFactory,
- UIPasteboard* pasteboard) :
- mrXMimeCntFactory(rXMimeCntFactory),
- mPasteboard(pasteboard)
-{
- [mPasteboard retain];
-
- initClipboardItemList();
-}
-
-
-iOSTransferable::~iOSTransferable()
-{
- [mPasteboard release];
-}
-
-
-Any SAL_CALL iOSTransferable::getTransferData( const DataFlavor& aFlavor )
- throw( UnsupportedFlavorException, IOException, RuntimeException )
-{
- if (!isValidFlavor(aFlavor) || !isDataFlavorSupported(aFlavor))
- {
- throw UnsupportedFlavorException(OUString("IosClipboard: Unsupported data flavor"),
- static_cast<XTransferable*>(this));
- }
-
- throw UnsupportedFlavorException(OUString("IosClipboard: Unsupported data flavor"),
- static_cast<XTransferable*>(this));
- // ???
- return Any();
-}
-
-
-bool iOSTransferable::isUnicodeText(const DataFlavor& flavor)
-{
- return (flavor.DataType == getCppuType((OUString*)0));
-}
-
-
-Sequence< DataFlavor > SAL_CALL iOSTransferable::getTransferDataFlavors( )
- throw( RuntimeException )
-{
- return mFlavorList;
-}
-
-
-sal_Bool SAL_CALL iOSTransferable::isDataFlavorSupported(const DataFlavor& aFlavor)
- throw( RuntimeException )
-{
- for (sal_Int32 i = 0; i < mFlavorList.getLength(); i++)
- if (compareDataFlavors(aFlavor, mFlavorList[i]))
- return sal_True;
-
- return sal_False;
-}
-
-
-void iOSTransferable::initClipboardItemList()
-{
- NSArray* pboardFormats = [mPasteboard pasteboardTypes];
-
- if (pboardFormats == NULL)
- {
- throw RuntimeException(OUString("IosClipboard: Cannot get clipboard data"),
- static_cast<XTransferable*>(this));
- }
-
- // ???
-}
-
-
-/* Compares two DataFlavors. Returns true if both DataFlavor have the same media type
- and the number of parameter and all parameter values do match otherwise false
- is returned.
- */
-bool iOSTransferable::compareDataFlavors(const DataFlavor& lhs, const DataFlavor& rhs )
-{
- try
- {
- Reference<XMimeContentType> xLhs(mrXMimeCntFactory->createMimeContentType(lhs.MimeType));
- Reference<XMimeContentType> xRhs(mrXMimeCntFactory->createMimeContentType(rhs.MimeType));
-
- if (!xLhs->getFullMediaType().equalsIgnoreAsciiCase(xRhs->getFullMediaType()) ||
- !cmpAllContentTypeParameter(xLhs, xRhs))
- {
- return false;
- }
- }
- catch( IllegalArgumentException& )
- {
- OSL_FAIL( "Invalid content type detected" );
- return false;
- }
-
- return true;
-}
-
-
-bool iOSTransferable::cmpAllContentTypeParameter(const Reference<XMimeContentType> xLhs,
- const Reference<XMimeContentType> xRhs) const
-{
- Sequence<OUString> xLhsFlavors = xLhs->getParameters();
- Sequence<OUString> xRhsFlavors = xRhs->getParameters();
-
- // Stop here if the number of parameters is different already
- if (xLhsFlavors.getLength() != xRhsFlavors.getLength())
- return false;
-
- try
- {
- OUString pLhs;
- OUString pRhs;
-
- for (sal_Int32 i = 0; i < xLhsFlavors.getLength(); i++)
- {
- pLhs = xLhs->getParameterValue(xLhsFlavors[i]);
- pRhs = xRhs->getParameterValue(xLhsFlavors[i]);
-
- if (!pLhs.equalsIgnoreAsciiCase(pRhs))
- {
- return false;
- }
- }
- }
- catch(IllegalArgumentException&)
- {
- return false;
- }
-
- return true;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/dtrans/iOSTransferable.hxx b/vcl/ios/source/dtrans/iOSTransferable.hxx
deleted file mode 100644
index 843875cf0f01..000000000000
--- a/vcl/ios/source/dtrans/iOSTransferable.hxx
+++ /dev/null
@@ -1,86 +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 .
- */
-
-
-#ifndef _TRANSFERABLE_HXX_
-#define _TRANSFERABLE_HXX_
-
-#include <com/sun/star/datatransfer/XTransferable.hpp>
-#include <cppuhelper/implbase1.hxx>
-#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
-#include <com/sun/star/datatransfer/XMimeContentType.hpp>
-
-#include <premac.h>
-#import <UIKit/UIKit.h>
-#include <postmac.h>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/utility.hpp>
-#include <vector>
-
-
-class iOSTransferable : public ::cppu::WeakImplHelper1<com::sun::star::datatransfer::XTransferable>,
- private ::boost::noncopyable
-{
-public:
- typedef com::sun::star::uno::Sequence< sal_Int8 > ByteSequence_t;
-
- explicit iOSTransferable(com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory> rXMimeCntFactory,
- UIPasteboard* pasteboard);
-
- virtual ~iOSTransferable();
-
- //------------------------------------------------------------------------
- // XTransferable
- //------------------------------------------------------------------------
-
- virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
- throw( ::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException );
-
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( )
- throw( ::com::sun::star::uno::RuntimeException );
-
- virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor )
- throw( ::com::sun::star::uno::RuntimeException );
-
- //------------------------------------------------------------------------
- // Helper functions not part of the XTransferable interface
- //------------------------------------------------------------------------
-
- void initClipboardItemList();
-
- //com::sun::star::uno::Any getClipboardItemData(ClipboardItemPtr_t clipboardItem);
-
- bool isUnicodeText(const com::sun::star::datatransfer::DataFlavor& flavor);
-
- bool compareDataFlavors( const com::sun::star::datatransfer::DataFlavor& lhs,
- const com::sun::star::datatransfer::DataFlavor& rhs );
-
- bool cmpAllContentTypeParameter( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType > xLhs,
- const com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentType > xRhs ) const;
-
-private:
- com::sun::star::uno::Sequence< com::sun::star::datatransfer::DataFlavor > mFlavorList;
- ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory> mrXMimeCntFactory;
- UIPasteboard* mPasteboard;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/dtrans/ios_clipboard.cxx b/vcl/ios/source/dtrans/ios_clipboard.cxx
deleted file mode 100644
index a7fc7af8ff9d..000000000000
--- a/vcl/ios/source/dtrans/ios_clipboard.cxx
+++ /dev/null
@@ -1,377 +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 "ios_clipboard.hxx"
-
-#include "iOSTransferable.hxx"
-#include <com/sun/star/datatransfer/MimeContentTypeFactory.hpp>
-#include "comphelper/makesequence.hxx"
-#include "comphelper/processfactory.hxx"
-
-#include <boost/assert.hpp>
-
-using namespace com::sun::star::datatransfer;
-using namespace com::sun::star::datatransfer::clipboard;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::uno;
-using namespace cppu;
-using namespace osl;
-using namespace std;
-using namespace comphelper;
-
-using ::rtl::OUString;
-
-@implementation EventListener;
-
--(EventListener*)initWithIosClipboard: (IosClipboard*) pcb
-{
- self = [super init];
-
- if (self)
- pIosClipboard = pcb;
-
- return self;
-}
-
--(void)pasteboard:(UIPasteboard*)sender provideDataForType:(NSString*)type
-{
- if( pIosClipboard )
- pIosClipboard->provideDataForType(sender, type);
-}
-
--(void)applicationDidBecomeActive:(NSNotification*)aNotification
-{
- if( pIosClipboard )
- pIosClipboard->applicationDidBecomeActive(aNotification);
-}
-
--(void)disposing
-{
- pIosClipboard = NULL;
-}
-
-@end
-
-
-OUString clipboard_getImplementationName()
-{
- return OUString("com.sun.star.datatransfer.clipboard.IosClipboard");
-}
-
-Sequence<OUString> clipboard_getSupportedServiceNames()
-{
- return makeSequence(OUString("com.sun.star.datatransfer.clipboard.SystemClipboard"));
-}
-
-
-IosClipboard::IosClipboard(UIPasteboard* pasteboard, bool bUseSystemPasteboard) :
- WeakComponentImplHelper3<XSystemClipboard, XFlushableClipboard, XServiceInfo>(m_aMutex),
- mIsSystemPasteboard(bUseSystemPasteboard)
-{
- Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
-
- mrXMimeCntFactory = MimeContentTypeFactory::create(xContext);
-
-#if 0 // ???
- mpDataFlavorMapper = DataFlavorMapperPtr_t(new DataFlavorMapper());
-#endif
- if (pasteboard != NULL)
- {
- mPasteboard = pasteboard;
- mIsSystemPasteboard = false;
- }
- else
- {
- mPasteboard = bUseSystemPasteboard ? [UIPasteboard generalPasteboard] :
- [UIPasteboard pasteboardWithName: @"org.libreoffice.pboard" create: YES];
-
- if (mPasteboard == nil)
- {
- throw RuntimeException(OUString("IosClipboard: Cannot create pasteboard"),
- static_cast<XClipboardEx*>(this));
- }
- }
-
- [mPasteboard retain];
-
- mEventListener = [[EventListener alloc] initWithIosClipboard: this];
-
- if (mEventListener == nil)
- {
- [mPasteboard release];
-
- throw RuntimeException(
- OUString("IosClipboard: Cannot create pasteboard change listener"),
- static_cast<XClipboardEx*>(this));
- }
-
- if (mIsSystemPasteboard)
- {
- NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
-
- [notificationCenter addObserver: mEventListener
- selector: @selector(applicationDidBecomeActive:)
- name: @"UIApplicationDidBecomeActiveNotification"
- object: [UIApplication sharedApplication]];
- }
-
- mPasteboardChangeCount = [mPasteboard changeCount];
-}
-
-
-IosClipboard::~IosClipboard()
-{
- if (mIsSystemPasteboard)
- {
- [[NSNotificationCenter defaultCenter] removeObserver: mEventListener];
- }
-
- [mEventListener disposing];
- [mEventListener release];
- [mPasteboard release];
-}
-
-
-Reference<XTransferable> SAL_CALL IosClipboard::getContents() throw(RuntimeException)
-{
- MutexGuard aGuard(m_aMutex);
-
- // Shortcut: If we are clipboard owner already we don't need
- // to drag the data through the system clipboard
- if (mXClipboardContent.is())
- {
- return mXClipboardContent;
- }
-
- return Reference<XTransferable>(new iOSTransferable(mrXMimeCntFactory,
- mPasteboard));
-}
-
-
-void SAL_CALL IosClipboard::setContents(const Reference<XTransferable>& /*xTransferable*/,
- const Reference<XClipboardOwner>& /*xClipboardOwner*/)
- throw( RuntimeException )
-{
-#if 0 // ???
- NSArray* types = xTransferable.is() ?
- mpDataFlavorMapper->flavorSequenceToTypesArray(xTransferable->getTransferDataFlavors()) :
- [NSArray array];
-
- ClearableMutexGuard aGuard(m_aMutex);
-
- Reference<XClipboardOwner> oldOwner(mXClipboardOwner);
- mXClipboardOwner = xClipboardOwner;
-
- Reference<XTransferable> oldContent(mXClipboardContent);
- mXClipboardContent = xTransferable;
-
- mPasteboardChangeCount = [mPasteboard declareTypes: types owner: mEventListener];
-
- aGuard.clear();
-
- // if we are already the owner of the clipboard
- // then fire lost ownership event
- if (oldOwner.is())
- {
- fireLostClipboardOwnershipEvent(oldOwner, oldContent);
- }
-
- fireClipboardChangedEvent();
-#endif
-}
-
-
-OUString SAL_CALL IosClipboard::getName() throw( RuntimeException )
-{
- return OUString();
-}
-
-
-sal_Int8 SAL_CALL IosClipboard::getRenderingCapabilities() throw( RuntimeException )
-{
- return 0;
-}
-
-
-void SAL_CALL IosClipboard::addClipboardListener(const Reference< XClipboardListener >& listener)
- throw( RuntimeException )
-{
- MutexGuard aGuard(m_aMutex);
-
- if (!listener.is())
- throw IllegalArgumentException(OUString("empty reference"),
- static_cast<XClipboardEx*>(this), 1);
-
- mClipboardListeners.push_back(listener);
-}
-
-
-void SAL_CALL IosClipboard::removeClipboardListener(const Reference< XClipboardListener >& listener)
- throw( RuntimeException )
-{
- MutexGuard aGuard(m_aMutex);
-
- if (!listener.is())
- throw IllegalArgumentException(OUString("empty reference"),
- static_cast<XClipboardEx*>(this), 1);
-
- mClipboardListeners.remove(listener);
-}
-
-
-void IosClipboard::applicationDidBecomeActive(NSNotification*)
-{
- ClearableMutexGuard aGuard(m_aMutex);
-
- int currentPboardChgCount = [mPasteboard changeCount];
-
- if (currentPboardChgCount != mPasteboardChangeCount)
- {
- mPasteboardChangeCount = currentPboardChgCount;
-
- // Clear clipboard content and owner and send lostOwnership
- // notification to the old clipboard owner as well as
- // ClipboardChanged notification to any clipboard listener
- Reference<XClipboardOwner> oldOwner(mXClipboardOwner);
- mXClipboardOwner = Reference<XClipboardOwner>();
-
- Reference<XTransferable> oldContent(mXClipboardContent);
- mXClipboardContent = Reference<XTransferable>();
-
- aGuard.clear();
-
- if (oldOwner.is())
- {
- fireLostClipboardOwnershipEvent(oldOwner, oldContent);
- }
-
- fireClipboardChangedEvent();
- }
-}
-
-
-void IosClipboard::fireClipboardChangedEvent()
-{
- ClearableMutexGuard aGuard(m_aMutex);
-
- list<Reference< XClipboardListener > > listeners(mClipboardListeners);
- ClipboardEvent aEvent;
-
- if (listeners.begin() != listeners.end())
- {
- aEvent = ClipboardEvent(static_cast<OWeakObject*>(this), getContents());
- }
-
- aGuard.clear();
-
- while (listeners.begin() != listeners.end())
- {
- if (listeners.front().is())
- {
- try { listeners.front()->changedContents(aEvent); }
- catch (RuntimeException&) { }
- }
- listeners.pop_front();
- }
-}
-
-
-void IosClipboard::fireLostClipboardOwnershipEvent(Reference<XClipboardOwner> oldOwner, Reference<XTransferable> oldContent)
-{
- BOOST_ASSERT(oldOwner.is());
-
- try { oldOwner->lostOwnership(static_cast<XClipboardEx*>(this), oldContent); }
- catch(RuntimeException&) { }
-}
-
-
-void IosClipboard::provideDataForType(UIPasteboard* /*sender*/, NSString* /*type*/)
-{
-#if 0 // ???
- if( mXClipboardContent.is() )
- {
- DataProviderPtr_t dp = mpDataFlavorMapper->getDataProvider(type, mXClipboardContent);
- NSData* pBoardData = NULL;
-
- if (dp.get() != NULL)
- {
- pBoardData = (NSData*)dp->getSystemData();
- [sender setData: pBoardData forType: type];
- }
- }
-#endif
-}
-
-
-//------------------------------------------------
-// XFlushableClipboard
-//------------------------------------------------
-
-void SAL_CALL IosClipboard::flushClipboard()
- throw(RuntimeException)
-{
-#if 0 // ???
- if (mXClipboardContent.is())
- {
- Sequence<DataFlavor> flavorList = mXClipboardContent->getTransferDataFlavors();
- sal_uInt32 nFlavors = flavorList.getLength();
-
- for (sal_uInt32 i = 0; i < nFlavors; i++)
- {
- NSString* sysType = mpDataFlavorMapper->openOfficeToSystemFlavor(flavorList[i]);
-
- if (sysType != NULL)
- {
- provideDataForType(mPasteboard, sysType);
- }
- }
- mXClipboardContent.clear();
- }
-#endif
-}
-
-
-UIPasteboard* IosClipboard::getPasteboard() const
-{
- return mPasteboard;
-}
-
-
-//-------------------------------------------------
-// XServiceInfo
-//-------------------------------------------------
-
-OUString SAL_CALL IosClipboard::getImplementationName() throw( RuntimeException )
-{
- return clipboard_getImplementationName();
-}
-
-
-sal_Bool SAL_CALL IosClipboard::supportsService( const OUString& /*ServiceName*/ ) throw( RuntimeException )
-{
- return sal_False;
-}
-
-
-Sequence< OUString > SAL_CALL IosClipboard::getSupportedServiceNames() throw( RuntimeException )
-{
- return clipboard_getSupportedServiceNames();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/dtrans/ios_clipboard.hxx b/vcl/ios/source/dtrans/ios_clipboard.hxx
deleted file mode 100644
index 1c3dc40392af..000000000000
--- a/vcl/ios/source/dtrans/ios_clipboard.hxx
+++ /dev/null
@@ -1,173 +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 .
- */
-
-#ifndef _IOS_CLIPBOARD_HXX_
-#define _IOS_CLIPBOARD_HXX_
-
-#include <rtl/ustring.hxx>
-#include <sal/types.h>
-#include <cppuhelper/compbase3.hxx>
-#include <com/sun/star/datatransfer/XTransferable.hpp>
-#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
-#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
-#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
-#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
-#include <com/sun/star/datatransfer/clipboard/XSystemClipboard.hpp>
-#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
-#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <cppuhelper/basemutex.hxx>
-#include <com/sun/star/lang/XMultiComponentFactory.hpp>
-
-#include <boost/utility.hpp>
-#include <list>
-
-#include <premac.h>
-#import <UIKit/UIKit.h>
-#include <postmac.h>
-
-class IosClipboard;
-
-@interface EventListener : NSObject
-{
- IosClipboard* pIosClipboard;
-}
-
-// Init the pasteboard change listener with a reference to the OfficeClipboard
-// instance
-- (EventListener*)initWithIosClipboard: (IosClipboard*) pcb;
-
-// Promiss resolver function
-- (void)pasteboard:(UIPasteboard*)sender provideDataForType:(NSString *)type;
-
--(void)applicationDidBecomeActive:(NSNotification*)aNotification;
-
--(void)disposing;
-@end
-
-
-class IosClipboard : public ::cppu::BaseMutex,
- public ::cppu::WeakComponentImplHelper3< com::sun::star::datatransfer::clipboard::XSystemClipboard,
- com::sun::star::datatransfer::clipboard::XFlushableClipboard,
- com::sun::star::lang::XServiceInfo >,
- private ::boost::noncopyable
-{
-public:
- /* Create a clipboard instance.
-
- @param pasteboard
- If not equal NULL the instance will be instantiated with the provided
- pasteboard reference and 'bUseSystemClipboard' will be ignored
-
- @param bUseSystemClipboard
- If 'pasteboard' is NULL 'bUseSystemClipboard' determines whether the
- system clipboard will be created (bUseSystemClipboard == true) or if
- the DragPasteboard if bUseSystemClipboard == false
- */
- IosClipboard(UIPasteboard* pasteboard = NULL,
- bool bUseSystemClipboard = true);
-
- ~IosClipboard();
-
- //------------------------------------------------
- // XClipboard
- //------------------------------------------------
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents()
- throw( ::com::sun::star::uno::RuntimeException );
-
- virtual void SAL_CALL setContents( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
- const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
- throw( ::com::sun::star::uno::RuntimeException );
-
- virtual ::rtl::OUString SAL_CALL getName()
- throw( ::com::sun::star::uno::RuntimeException );
-
- //------------------------------------------------
- // XClipboardEx
- //------------------------------------------------
-
- virtual sal_Int8 SAL_CALL getRenderingCapabilities()
- throw( ::com::sun::star::uno::RuntimeException );
-
- //------------------------------------------------
- // XClipboardNotifier
- //------------------------------------------------
-
- virtual void SAL_CALL addClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
- throw( ::com::sun::star::uno::RuntimeException );
-
- virtual void SAL_CALL removeClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
- throw( ::com::sun::star::uno::RuntimeException );
-
- //------------------------------------------------
- // XFlushableClipboard
- //------------------------------------------------
-
- virtual void SAL_CALL flushClipboard( ) throw( com::sun::star::uno::RuntimeException );
-
- //------------------------------------------------
- // XServiceInfo
- //------------------------------------------------
-
- virtual ::rtl::OUString SAL_CALL getImplementationName()
- throw(::com::sun::star::uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
- throw(::com::sun::star::uno::RuntimeException);
-
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
- throw(::com::sun::star::uno::RuntimeException);
-
- /* Get a reference to the used pasteboard.
- */
- UIPasteboard* getPasteboard() const;
-
- /* Notify the current clipboard owner that he is no longer the clipboard owner.
- */
- void fireLostClipboardOwnershipEvent(::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner> oldOwner,
- ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > oldContent);
-
- void pasteboardChangedOwner();
-
- void provideDataForType(UIPasteboard* sender, NSString* type);
-
- void applicationDidBecomeActive(NSNotification* aNotification);
-
-private:
-
- /* Notify all registered XClipboardListener that the clipboard content
- has changed.
- */
- void fireClipboardChangedEvent();
-
-private:
- ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory > mrXMimeCntFactory;
- ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener > > mClipboardListeners;
- ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > mXClipboardContent;
- com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner > mXClipboardOwner;
- bool mIsSystemPasteboard;
- UIPasteboard* mPasteboard;
- int mPasteboardChangeCount;
- EventListener* mEventListener;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/dtrans/service_entry.cxx b/vcl/ios/source/dtrans/service_entry.cxx
deleted file mode 100644
index 98f743463eda..000000000000
--- a/vcl/ios/source/dtrans/service_entry.cxx
+++ /dev/null
@@ -1,62 +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 "osl/diagnose.h"
-
-#include "vcl/svapp.hxx"
-
-#include "ios/saldata.hxx"
-#include "ios/salinst.h"
-
-#include "ios_clipboard.hxx"
-
-using namespace ::osl;
-using namespace ::rtl;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::cppu;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::datatransfer::clipboard;
-
-
-uno::Reference< XInterface > IosSalInstance::CreateClipboard( const Sequence< Any >& i_rArguments )
-{
- if ( Application::IsHeadlessModeEnabled() )
- return SalInstance::CreateClipboard( i_rArguments );
-
- SalData* pSalData = GetSalData();
- if( ! pSalData->mxClipboard.is() )
- pSalData->mxClipboard = uno::Reference<XInterface>(static_cast< XClipboard* >(new IosClipboard()), UNO_QUERY);
- return pSalData->mxClipboard;
-}
-
-uno::Reference<XInterface> IosSalInstance::CreateDragSource()
-{
- // ???
- return SalInstance::CreateDragSource();
-}
-
-uno::Reference<XInterface> IosSalInstance::CreateDropTarget()
-{
- // ???
- return SalInstance::CreateDropTarget();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/gdi/salgdicommon.cxx b/vcl/ios/source/gdi/salgdicommon.cxx
deleted file mode 100644
index 947c7194c96e..000000000000
--- a/vcl/ios/source/gdi/salgdicommon.cxx
+++ /dev/null
@@ -1,1599 +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 <sal/types.h>
-#include <osl/file.hxx>
-#include <osl/endian.h>
-
-#include "basegfx/polygon/b2dpolygon.hxx"
-
-#include "quartz/salbmp.h"
-#include "coretext/salgdi.h"
-
-#include "fontsubset.hxx"
-#include "region.h"
-#include "sft.hxx"
-
-using namespace vcl;
-
-//typedef unsigned char Boolean; // copied from MacTypes.h, should be properly included
-typedef std::vector<unsigned char> ByteVector;
-
-static const basegfx::B2DPoint aHalfPointOfs ( 0.5, 0.5 );
-
-static void AddPolygonToPath( CGMutablePathRef xPath,
- const ::basegfx::B2DPolygon& rPolygon,
- bool bClosePath, bool bPixelSnap, bool bLineDraw )
-{
- // short circuit if there is nothing to do
- const int nPointCount = rPolygon.count();
- if( nPointCount <= 0 )
- {
- return;
- }
- (void)bPixelSnap; // TODO
- const CGAffineTransform* pTransform = NULL;
-
- const bool bHasCurves = rPolygon.areControlPointsUsed();
- for( int nPointIdx = 0, nPrevIdx = 0;; nPrevIdx = nPointIdx++ )
- {
- int nClosedIdx = nPointIdx;
- if( nPointIdx >= nPointCount )
- {
- // prepare to close last curve segment if needed
- if( bClosePath && (nPointIdx == nPointCount) )
- {
- nClosedIdx = 0;
- }
- else
- {
- break;
- }
- }
-
- ::basegfx::B2DPoint aPoint = rPolygon.getB2DPoint( nClosedIdx );
-
- if( bPixelSnap)
- {
- // snap device coordinates to full pixels
- aPoint.setX( basegfx::fround( aPoint.getX() ) );
- aPoint.setY( basegfx::fround( aPoint.getY() ) );
- }
-
- if( bLineDraw )
- {
- aPoint += aHalfPointOfs;
- }
- if( !nPointIdx )
- {
- // first point => just move there
- CGPathMoveToPoint( xPath, pTransform, aPoint.getX(), aPoint.getY() );
- continue;
- }
-
- bool bPendingCurve = false;
- if( bHasCurves )
- {
- bPendingCurve = rPolygon.isNextControlPointUsed( nPrevIdx );
- bPendingCurve |= rPolygon.isPrevControlPointUsed( nClosedIdx );
- }
-
- if( !bPendingCurve ) // line segment
- {
- CGPathAddLineToPoint( xPath, pTransform, aPoint.getX(), aPoint.getY() );
- }
- else // cubic bezier segment
- {
- basegfx::B2DPoint aCP1 = rPolygon.getNextControlPoint( nPrevIdx );
- basegfx::B2DPoint aCP2 = rPolygon.getPrevControlPoint( nClosedIdx );
- if( bLineDraw )
- {
- aCP1 += aHalfPointOfs;
- aCP2 += aHalfPointOfs;
- }
- CGPathAddCurveToPoint( xPath, pTransform, aCP1.getX(), aCP1.getY(),
- aCP2.getX(), aCP2.getY(), aPoint.getX(), aPoint.getY() );
- }
- }
-
- if( bClosePath )
- {
- CGPathCloseSubpath( xPath );
- }
-}
-
-static void AddPolyPolygonToPath( CGMutablePathRef xPath,
- const ::basegfx::B2DPolyPolygon& rPolyPoly,
- bool bPixelSnap, bool bLineDraw )
-{
- // short circuit if there is nothing to do
- const int nPolyCount = rPolyPoly.count();
- if( nPolyCount <= 0 )
- {
- return;
- }
- for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
- {
- const ::basegfx::B2DPolygon rPolygon = rPolyPoly.getB2DPolygon( nPolyIdx );
- AddPolygonToPath( xPath, rPolygon, true, bPixelSnap, bLineDraw );
- }
-}
-
-sal_Bool QuartzSalGraphics::CreateFontSubset( const rtl::OUString& rToFile,
- const PhysicalFontFace* pFontData,
- long* pGlyphIDs, sal_uInt8* pEncoding,
- sal_Int32* pGlyphWidths, int nGlyphCount,
- FontSubsetInfo& rInfo )
-{
- // TODO: move more of the functionality here into the generic subsetter code
-
- // prepare the requested file name for writing the font-subset file
- rtl::OUString aSysPath;
- if( osl_File_E_None != osl_getSystemPathFromFileURL( rToFile.pData, &aSysPath.pData ) )
- return sal_False;
- const rtl_TextEncoding aThreadEncoding = osl_getThreadTextEncoding();
- const rtl::OString aToFile( rtl::OUStringToOString( aSysPath, aThreadEncoding ) );
-
- // get the raw-bytes from the font to be subset
- ByteVector aBuffer;
- bool bCffOnly = false;
- if( !GetRawFontData( pFontData, aBuffer, &bCffOnly ) )
- return sal_False;
-
- // handle CFF-subsetting
- if( bCffOnly )
- {
- // provide the raw-CFF data to the subsetter
- ByteCount nCffLen = aBuffer.size();
- rInfo.LoadFont( FontSubsetInfo::CFF_FONT, &aBuffer[0], nCffLen );
-
- // NOTE: assuming that all glyphids requested on Ios are fully translated
-
- // make the subsetter provide the requested subset
- FILE* pOutFile = fopen( aToFile.getStr(), "wb" );
- bool bRC = rInfo.CreateFontSubset( FontSubsetInfo::TYPE1_PFB, pOutFile, NULL,
- pGlyphIDs, pEncoding, nGlyphCount, pGlyphWidths );
- fclose( pOutFile );
- return bRC;
- }
-
- // TODO: modernize psprint's horrible fontsubset C-API
- // this probably only makes sense after the switch to another SCM
- // that can preserve change history after file renames
-
- // prepare data for psprint's font subsetter
- TrueTypeFont* pSftFont = NULL;
- int nRC = ::OpenTTFontBuffer( (void*)&aBuffer[0], aBuffer.size(), 0, &pSftFont);
- if( nRC != SF_OK )
- return sal_False;
-
- // get details about the subsetted font
- TTGlobalFontInfo aTTInfo;
- ::GetTTGlobalFontInfo( pSftFont, &aTTInfo );
- rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF;
- rInfo.m_aPSName = String( aTTInfo.psname, RTL_TEXTENCODING_UTF8 );
- rInfo.m_aFontBBox = Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ),
- Point( aTTInfo.xMax, aTTInfo.yMax ) );
- rInfo.m_nCapHeight = aTTInfo.yMax; // Well ...
- rInfo.m_nAscent = aTTInfo.winAscent;
- rInfo.m_nDescent = aTTInfo.winDescent;
- // mac fonts usually do not have an OS2-table
- // => get valid ascent/descent values from other tables
- if( !rInfo.m_nAscent )
- rInfo.m_nAscent = +aTTInfo.typoAscender;
- if( !rInfo.m_nAscent )
- rInfo.m_nAscent = +aTTInfo.ascender;
- if( !rInfo.m_nDescent )
- rInfo.m_nDescent = +aTTInfo.typoDescender;
- if( !rInfo.m_nDescent )
- rInfo.m_nDescent = -aTTInfo.descender;
-
- // subset glyphs and get their properties
- // take care that subset fonts require the NotDef glyph in pos 0
- int nOrigCount = nGlyphCount;
- sal_uInt16 aShortIDs[ 256 ];
- sal_uInt8 aTempEncs[ 256 ];
-
- int nNotDef = -1;
- for( int i = 0; i < nGlyphCount; ++i )
- {
- aTempEncs[i] = pEncoding[i];
- sal_uInt32 nGlyphIdx = pGlyphIDs[i] & GF_IDXMASK;
- if( pGlyphIDs[i] & GF_ISCHAR )
- {
- bool bVertical = (pGlyphIDs[i] & GF_ROTMASK) != 0;
- nGlyphIdx = ::MapChar( pSftFont, static_cast<sal_uInt16>(nGlyphIdx), bVertical );
- if( nGlyphIdx == 0 && pFontData->IsSymbolFont() )
- {
- // #i12824# emulate symbol aliasing U+FXXX <-> U+0XXX
- nGlyphIdx = pGlyphIDs[i] & GF_IDXMASK;
- nGlyphIdx = (nGlyphIdx & 0xF000) ? (nGlyphIdx & 0x00FF) : (nGlyphIdx | 0xF000 );
- nGlyphIdx = ::MapChar( pSftFont, static_cast<sal_uInt16>(nGlyphIdx), bVertical );
- }
- }
- aShortIDs[i] = static_cast<sal_uInt16>( nGlyphIdx );
- if( !nGlyphIdx )
- if( nNotDef < 0 )
- nNotDef = i; // first NotDef glyph found
- }
-
- if( nNotDef != 0 )
- {
- // add fake NotDef glyph if needed
- if( nNotDef < 0 )
- nNotDef = nGlyphCount++;
-
- // NotDef glyph must be in pos 0 => swap glyphids
- aShortIDs[ nNotDef ] = aShortIDs[0];
- aTempEncs[ nNotDef ] = aTempEncs[0];
- aShortIDs[0] = 0;
- aTempEncs[0] = 0;
- }
- DBG_ASSERT( nGlyphCount < 257, "too many glyphs for subsetting" );
-
- // TODO: where to get bVertical?
- const bool bVertical = false;
-
- // fill the pGlyphWidths array
- // while making sure that the NotDef glyph is at index==0
- TTSimpleGlyphMetrics* pGlyphMetrics =
- ::GetTTSimpleGlyphMetrics( pSftFont, aShortIDs, nGlyphCount, bVertical );
- if( !pGlyphMetrics )
- return sal_False;
- sal_uInt16 nNotDefAdv = pGlyphMetrics[0].adv;
- pGlyphMetrics[0].adv = pGlyphMetrics[nNotDef].adv;
- pGlyphMetrics[nNotDef].adv = nNotDefAdv;
- for( int i = 0; i < nOrigCount; ++i )
- pGlyphWidths[i] = pGlyphMetrics[i].adv;
- free( pGlyphMetrics );
-
- // write subset into destination file
- nRC = ::CreateTTFromTTGlyphs( pSftFont, aToFile.getStr(), aShortIDs,
- aTempEncs, nGlyphCount, 0, NULL, 0 );
- ::CloseTTFont(pSftFont);
- return (nRC == SF_OK);
-}
-
-static inline void alignLinePoint( const SalPoint* i_pIn, float& o_fX, float& o_fY )
-{
- o_fX = static_cast<float>(i_pIn->mnX ) + 0.5;
- o_fY = static_cast<float>(i_pIn->mnY ) + 0.5;
-}
-
-void QuartzSalGraphics::copyBits( const SalTwoRect *pPosAry, SalGraphics *pSrcGraphics )
-{
- if( !pSrcGraphics )
- {
- pSrcGraphics = this;
- }
- //from unix salgdi2.cxx
- //[FIXME] find a better way to prevent calc from crashing when width and height are negative
- if( pPosAry->mnSrcWidth <= 0
- || pPosAry->mnSrcHeight <= 0
- || pPosAry->mnDestWidth <= 0
- || pPosAry->mnDestHeight <= 0 )
- {
- return;
- }
-
- // accelerate trivial operations
- /*const*/ QuartzSalGraphics* pSrc = static_cast<QuartzSalGraphics*>(pSrcGraphics);
- const bool bSameGraphics = (this == pSrc) ||
- (mbWindow && mpFrame && pSrc->mbWindow && (mpFrame == pSrc->mpFrame));
- if( bSameGraphics &&
- (pPosAry->mnSrcWidth == pPosAry->mnDestWidth) &&
- (pPosAry->mnSrcHeight == pPosAry->mnDestHeight))
- {
- // short circuit if there is nothing to do
- if( (pPosAry->mnSrcX == pPosAry->mnDestX) &&
- (pPosAry->mnSrcY == pPosAry->mnDestY))
- return;
- // use copyArea() if source and destination context are identical
- copyArea( pPosAry->mnDestX, pPosAry->mnDestY, pPosAry->mnSrcX, pPosAry->mnSrcY,
- pPosAry->mnSrcWidth, pPosAry->mnSrcHeight, 0 );
- return;
- }
-
- ApplyXorContext();
- pSrc->ApplyXorContext();
-
- DBG_ASSERT( pSrc->mxLayer!=NULL, "QuartzSalGraphics::copyBits() from non-layered graphics" );
-
- const CGPoint aDstPoint = { static_cast<CGFloat>(+pPosAry->mnDestX - pPosAry->mnSrcX), static_cast<CGFloat>(pPosAry->mnDestY - pPosAry->mnSrcY) };
- if( (pPosAry->mnSrcWidth == pPosAry->mnDestWidth &&
- pPosAry->mnSrcHeight == pPosAry->mnDestHeight) &&
- (!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) ) // workaround a Quartz crasher
- {
- // in XOR mode the drawing context is redirected to the XOR mask
- // if source and target are identical then copyBits() paints onto the target context though
- CGContextRef xCopyContext = mrContext;
- if( mpXorEmulation && mpXorEmulation->IsEnabled() )
- {
- if( pSrcGraphics == this )
- {
- xCopyContext = mpXorEmulation->GetTargetContext();
- }
- }
- CGContextSaveGState( xCopyContext );
- const CGRect aDstRect = { { static_cast<CGFloat>(pPosAry->mnDestX), static_cast<CGFloat>(pPosAry->mnDestY) }, { static_cast<CGFloat>(pPosAry->mnDestWidth), static_cast<CGFloat>(pPosAry->mnDestHeight) } };
- CGContextClipToRect( xCopyContext, aDstRect );
-
- // draw at new destination
- // NOTE: flipped drawing gets disabled for this, else the subimage would be drawn upside down
- if( pSrc->IsFlipped() )
- {
- CGContextTranslateCTM( xCopyContext, 0, +mnHeight ); CGContextScaleCTM( xCopyContext, +1, -1 );
- }
- // TODO: pSrc->size() != this->size()
- ::CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, pSrc->mxLayer );
- CGContextRestoreGState( xCopyContext );
- // mark the destination rectangle as updated
- RefreshRect( aDstRect );
- }
- else
- {
- SalBitmap* pBitmap = pSrc->getBitmap( pPosAry->mnSrcX, pPosAry->mnSrcY,
- pPosAry->mnSrcWidth, pPosAry->mnSrcHeight );
-
- if( pBitmap )
- {
- SalTwoRect aPosAry( *pPosAry );
- aPosAry.mnSrcX = 0;
- aPosAry.mnSrcY = 0;
- drawBitmap( &aPosAry, *pBitmap );
- delete pBitmap;
- }
- }
-}
-
-static void DrawPattern50( void*, CGContextRef rContext )
-{
- static const CGRect aRects[2] = { { {0,0}, { 2, 2 } }, { { 2, 2 }, { 2, 2 } } };
- CGContextAddRects( rContext, aRects, 2 );
- CGContextFillPath( rContext );
-}
-
-static void getBoundRect( sal_uLong nPoints, const SalPoint *pPtAry, long &rX, long& rY, long& rWidth, long& rHeight )
-{
- long nX1 = pPtAry->mnX;
- long nX2 = nX1;
- long nY1 = pPtAry->mnY;
- long nY2 = nY1;
- for( sal_uLong n = 1; n < nPoints; n++ )
- {
- if( pPtAry[n].mnX < nX1 )
- {
- nX1 = pPtAry[n].mnX;
- }
- else if( pPtAry[n].mnX > nX2 )
- {
- nX2 = pPtAry[n].mnX;
- }
- if( pPtAry[n].mnY < nY1 )
- {
- nY1 = pPtAry[n].mnY;
- }
- else if( pPtAry[n].mnY > nY2 )
- {
- nY2 = pPtAry[n].mnY;
- }
- }
- rX = nX1;
- rY = nY1;
- rWidth = nX2 - nX1 + 1;
- rHeight = nY2 - nY1 + 1;
-}
-
-static SalColor ImplGetROPSalColor( SalROPColor nROPColor )
-{
- SalColor nSalColor;
- if ( nROPColor == SAL_ROP_0 )
- {
- nSalColor = MAKE_SALCOLOR( 0, 0, 0 );
- }
- else
- {
- nSalColor = MAKE_SALCOLOR( 255, 255, 255 );
- }
- return nSalColor;
-}
-
-// apply the XOR mask to the target context if active and dirty
-void QuartzSalGraphics::ApplyXorContext()
-{
- if( !mpXorEmulation )
- {
- return;
- }
- if( mpXorEmulation->UpdateTarget() )
- {
- RefreshRect( 0, 0, mnWidth, mnHeight ); // TODO: refresh minimal changerect
- }
-}
-
-void QuartzSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY,
- long nSrcWidth, long nSrcHeight, sal_uInt16 /*nFlags*/ )
-{
- ApplyXorContext();
-
- DBG_ASSERT( mxLayer!=NULL, "QuartzSalGraphics::copyArea() for non-layered graphics" );
-
- // in XOR mode the drawing context is redirected to the XOR mask
- // copyArea() always works on the target context though
- CGContextRef xCopyContext = mrContext;
- if( mpXorEmulation && mpXorEmulation->IsEnabled() )
- {
- xCopyContext = mpXorEmulation->GetTargetContext();
- }
- // drawing a layer onto its own context causes trouble on OSX => copy it first
- // TODO: is it possible to get rid of this unneeded copy more often?
- // e.g. on OSX>=10.5 only this situation causes problems:
- // mnBitmapDepth && (aDstPoint.x + pSrc->mnWidth) > mnWidth
- CGLayerRef xSrcLayer = mxLayer;
- // TODO: if( mnBitmapDepth > 0 )
- {
- const CGSize aSrcSize = { static_cast<CGFloat>(nSrcWidth), static_cast<CGFloat>(nSrcHeight) };
- xSrcLayer = ::CGLayerCreateWithContext( xCopyContext, aSrcSize, NULL );
- const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer );
- CGPoint aSrcPoint = { static_cast<CGFloat>(-nSrcX), static_cast<CGFloat>(-nSrcY) };
- if( IsFlipped() )
- {
- ::CGContextTranslateCTM( xSrcContext, 0, +nSrcHeight );
- ::CGContextScaleCTM( xSrcContext, +1, -1 );
- aSrcPoint.y = (nSrcY + nSrcHeight) - mnHeight;
- }
- ::CGContextDrawLayerAtPoint( xSrcContext, aSrcPoint, mxLayer );
- }
-
- // draw at new destination
- const CGPoint aDstPoint = { static_cast<CGFloat>(+nDstX), static_cast<CGFloat>(+nDstY) };
- ::CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer );
-
- // cleanup
- if( xSrcLayer != mxLayer )
- {
- CGLayerRelease( xSrcLayer );
- }
- // mark the destination rectangle as updated
- RefreshRect( nDstX, nDstY, nSrcWidth, nSrcHeight );
-
-}
-
-void QuartzSalGraphics::copyResolution( QuartzSalGraphics& rGraphics )
-{
- if( !rGraphics.mnRealDPIY && rGraphics.mbWindow && rGraphics.mpFrame )
- {
- rGraphics.initResolution( rGraphics.mpFrame->mpWindow );
- }
- mnRealDPIX = rGraphics.mnRealDPIX;
- mnRealDPIY = rGraphics.mnRealDPIY;
- mfFakeDPIScale = rGraphics.mfFakeDPIScale;
-}
-
-bool QuartzSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
- const SalBitmap& rSrcBitmap,
- const SalBitmap& rAlphaBmp )
-{
- // An image mask can't have a depth > 8 bits (should be 1 to 8 bits)
- if( rAlphaBmp.GetBitCount() > 8 )
- {
- return false;
- }
- // are these two tests really necessary? (see vcl/unx/source/gdi/salgdi2.cxx)
- // horizontal/vertical mirroring not implemented yet
- if( rTR.mnDestWidth < 0 || rTR.mnDestHeight < 0 )
- {
- return false;
- }
-
- const QuartzSalBitmap& rSrcSalBmp = static_cast<const QuartzSalBitmap&>(rSrcBitmap);
- const QuartzSalBitmap& rMaskSalBmp = static_cast<const QuartzSalBitmap&>(rAlphaBmp);
- CGImageRef xMaskedImage = rSrcSalBmp.CreateWithMask( rMaskSalBmp, rTR.mnSrcX,
- rTR.mnSrcY, rTR.mnSrcWidth,
- rTR.mnSrcHeight );
- if( !xMaskedImage )
- {
- return false;
- }
- if ( CheckContext() )
- {
- const CGRect aDstRect = { { static_cast<CGFloat>(rTR.mnDestX), static_cast<CGFloat>(rTR.mnDestY) }, { static_cast<CGFloat>(rTR.mnDestWidth), static_cast<CGFloat>(rTR.mnDestHeight) } };
- CGContextDrawImage( mrContext, aDstRect, xMaskedImage );
- RefreshRect( aDstRect );
- }
-
- CGImageRelease(xMaskedImage);
- return true;
-}
-
-bool QuartzSalGraphics::drawAlphaRect( long nX, long nY, long nWidth,
- long nHeight, sal_uInt8 nTransparency )
-{
- if( !CheckContext() )
- {
- return true;
- }
- // save the current state
- CGContextSaveGState( mrContext );
- CGContextSetAlpha( mrContext, (100-nTransparency) * (1.0/100) );
-
- CGRect aRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nWidth-1), static_cast<CGFloat>(nHeight-1) } };
- if( IsPenVisible() )
- {
- aRect.origin.x += 0.5;
- aRect.origin.y += 0.5;
- }
-
- CGContextBeginPath( mrContext );
- CGContextAddRect( mrContext, aRect );
- CGContextDrawPath( mrContext, kCGPathFill );
-
- // restore state
- CGContextRestoreGState(mrContext);
- RefreshRect( aRect );
- return true;
-}
-
-void QuartzSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap )
-{
- if( !CheckContext() )
- {
- return;
- }
- const QuartzSalBitmap& rBitmap = static_cast<const QuartzSalBitmap&>(rSalBitmap);
- CGImageRef xImage = rBitmap.CreateCroppedImage( (int)pPosAry->mnSrcX, (int)pPosAry->mnSrcY,
- (int)pPosAry->mnSrcWidth, (int)pPosAry->mnSrcHeight );
- if( !xImage )
- {
- return;
- }
- const CGRect aDstRect = { { static_cast<CGFloat>(pPosAry->mnDestX), static_cast<CGFloat>(pPosAry->mnDestY) },
- { static_cast<CGFloat>(pPosAry->mnDestWidth), static_cast<CGFloat>(pPosAry->mnDestHeight) } };
- CGContextDrawImage( mrContext, aDstRect, xImage );
- CGImageRelease( xImage );
- RefreshRect( aDstRect );
-}
-
-void QuartzSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap,SalColor )
-{
- OSL_FAIL("not implemented for color masking!");
- drawBitmap( pPosAry, rSalBitmap );
-}
-
-void QuartzSalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap,
- const SalBitmap& rTransparentBitmap )
-{
- if( !CheckContext() )
- {
- return;
- }
- const QuartzSalBitmap& rBitmap = static_cast<const QuartzSalBitmap&>(rSalBitmap);
- const QuartzSalBitmap& rMask = static_cast<const QuartzSalBitmap&>(rTransparentBitmap);
- CGImageRef xMaskedImage( rBitmap.CreateWithMask( rMask, pPosAry->mnSrcX, pPosAry->mnSrcY,
- pPosAry->mnSrcWidth, pPosAry->mnSrcHeight ) );
- if( !xMaskedImage )
- {
- return;
- }
- const CGRect aDstRect = { { static_cast<CGFloat>(pPosAry->mnDestX), static_cast<CGFloat>(pPosAry->mnDestY) },
- { static_cast<CGFloat>(pPosAry->mnDestWidth), static_cast<CGFloat>(pPosAry->mnDestHeight) } };
- CGContextDrawImage( mrContext, aDstRect, xMaskedImage );
- CGImageRelease( xMaskedImage );
- RefreshRect( aDstRect );
-}
-
-sal_Bool QuartzSalGraphics::drawEPS( long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/,
- void* /*pEpsData*/, sal_uLong /*nByteCount*/ )
-{
- return sal_False;
-}
-
-void QuartzSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
-{
- if( nX1 == nX2 && nY1 == nY2 )
- {
- // #i109453# platform independent code expects at least one pixel to be drawn
- drawPixel( nX1, nY1 );
- return;
- }
-
- if( !CheckContext() )
- {
- return;
- }
- CGContextBeginPath( mrContext );
- CGContextMoveToPoint( mrContext, static_cast<float>(nX1)+0.5, static_cast<float>(nY1)+0.5 );
- CGContextAddLineToPoint( mrContext, static_cast<float>(nX2)+0.5, static_cast<float>(nY2)+0.5 );
- CGContextDrawPath( mrContext, kCGPathStroke );
-
- Rectangle aRefreshRect( nX1, nY1, nX2, nY2 );
-}
-
-void QuartzSalGraphics::drawMask( const SalTwoRect* pPosAry,
- const SalBitmap& rSalBitmap,
- SalColor nMaskColor )
-{
- if( !CheckContext() )
- {
- return;
- }
- const QuartzSalBitmap& rBitmap = static_cast<const QuartzSalBitmap&>(rSalBitmap);
- CGImageRef xImage = rBitmap.CreateColorMask( pPosAry->mnSrcX, pPosAry->mnSrcY,
- pPosAry->mnSrcWidth, pPosAry->mnSrcHeight,
- nMaskColor );
- if( !xImage )
- {
- return;
- }
- const CGRect aDstRect = { { static_cast<CGFloat>(pPosAry->mnDestX), static_cast<CGFloat>(pPosAry->mnDestY) },
- { static_cast<CGFloat>(pPosAry->mnDestWidth), static_cast<CGFloat>(pPosAry->mnDestHeight) } };
- CGContextDrawImage( mrContext, aDstRect, xImage );
- CGImageRelease( xImage );
- RefreshRect( aDstRect );
-}
-
-void QuartzSalGraphics::drawPixel( long nX, long nY )
-{
- // draw pixel with current line color
- ImplDrawPixel( nX, nY, maLineColor );
-}
-
-void QuartzSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor )
-{
- const RGBAColor aPixelColor( nSalColor );
- ImplDrawPixel( nX, nY, aPixelColor );
-}
-
-bool QuartzSalGraphics::drawPolyLine(
- const ::basegfx::B2DPolygon& rPolyLine,
- double fTransparency,
- const ::basegfx::B2DVector& rLineWidths,
- basegfx::B2DLineJoin eLineJoin,
- com::sun::star::drawing::LineCap eLineCap)
-{
- // short circuit if there is nothing to do
- const int nPointCount = rPolyLine.count();
- if( nPointCount <= 0 )
- {
- return true;
- }
- // reject requests that cannot be handled yet
- if( rLineWidths.getX() != rLineWidths.getY() )
- {
- return false;
- }
- // #i101491# Ios does not support B2DLINEJOIN_NONE; return false to use
- // the fallback (own geometry preparation)
- // #i104886# linejoin-mode and thus the above only applies to "fat" lines
- if( (basegfx::B2DLINEJOIN_NONE == eLineJoin) &&
- (rLineWidths.getX() > 1.3) )
- {
- return false;
- }
-
- // setup line attributes
- CGLineJoin aCGLineJoin = kCGLineJoinMiter;
- switch( eLineJoin )
- {
- case ::basegfx::B2DLINEJOIN_NONE: aCGLineJoin = /*TODO?*/kCGLineJoinMiter; break;
- case ::basegfx::B2DLINEJOIN_MIDDLE: aCGLineJoin = /*TODO?*/kCGLineJoinMiter; break;
- case ::basegfx::B2DLINEJOIN_BEVEL: aCGLineJoin = kCGLineJoinBevel; break;
- case ::basegfx::B2DLINEJOIN_MITER: aCGLineJoin = kCGLineJoinMiter; break;
- case ::basegfx::B2DLINEJOIN_ROUND: aCGLineJoin = kCGLineJoinRound; break;
- }
-
- // setup cap attribute
- CGLineCap aCGLineCap(kCGLineCapButt);
-
- switch(eLineCap)
- {
- default: // com::sun::star::drawing::LineCap_BUTT:
- {
- aCGLineCap = kCGLineCapButt;
- break;
- }
- case com::sun::star::drawing::LineCap_ROUND:
- {
- aCGLineCap = kCGLineCapRound;
- break;
- }
- case com::sun::star::drawing::LineCap_SQUARE:
- {
- aCGLineCap = kCGLineCapSquare;
- break;
- }
- }
-
- // setup poly-polygon path
- CGMutablePathRef xPath = CGPathCreateMutable();
- AddPolygonToPath( xPath, rPolyLine, rPolyLine.isClosed(), !getAntiAliasB2DDraw(), true );
-
- const CGRect aRefreshRect = CGPathGetBoundingBox( xPath );
-#ifndef NO_I97317_WORKAROUND
- // #i97317# workaround for Quartz having problems with drawing small polygons
- if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) )
-#endif
- {
- // use the path to prepare the graphics context
- CGContextSaveGState( mrContext );
- CGContextAddPath( mrContext, xPath );
- // draw path with antialiased line
- CGContextSetShouldAntialias( mrContext, true );
- CGContextSetAlpha( mrContext, 1.0 - fTransparency );
- CGContextSetLineJoin( mrContext, aCGLineJoin );
- CGContextSetLineCap( mrContext, aCGLineCap );
- CGContextSetLineWidth( mrContext, rLineWidths.getX() );
- CGContextDrawPath( mrContext, kCGPathStroke );
- CGContextRestoreGState( mrContext );
-
- // mark modified rectangle as updated
- RefreshRect( aRefreshRect );
- }
-
- CGPathRelease( xPath );
-
- return true;
-}
-
-sal_Bool QuartzSalGraphics::drawPolyLineBezier( sal_uLong, const SalPoint*, const sal_uInt8* )
-{
- return sal_False;
-}
-
-bool QuartzSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly,
- double fTransparency )
-{
- // short circuit if there is nothing to do
- const int nPolyCount = rPolyPoly.count();
- if( nPolyCount <= 0 )
- {
- return true;
- }
- // ignore invisible polygons
- if( (fTransparency >= 1.0) || (fTransparency < 0) )
- {
- return true;
- }
- // setup poly-polygon path
- CGMutablePathRef xPath = CGPathCreateMutable();
- for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
- {
- const ::basegfx::B2DPolygon rPolygon = rPolyPoly.getB2DPolygon( nPolyIdx );
- AddPolygonToPath( xPath, rPolygon, true, !getAntiAliasB2DDraw(), IsPenVisible() );
- }
-
- const CGRect aRefreshRect = CGPathGetBoundingBox( xPath );
-#ifndef NO_I97317_WORKAROUND
- // #i97317# workaround for Quartz having problems with drawing small polygons
- if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) )
-#endif
- {
- // use the path to prepare the graphics context
- CGContextSaveGState( mrContext );
- CGContextBeginPath( mrContext );
- CGContextAddPath( mrContext, xPath );
-
- // draw path with antialiased polygon
- CGContextSetShouldAntialias( mrContext, true );
- CGContextSetAlpha( mrContext, 1.0 - fTransparency );
- CGContextDrawPath( mrContext, kCGPathEOFillStroke );
- CGContextRestoreGState( mrContext );
-
- // mark modified rectangle as updated
- RefreshRect( aRefreshRect );
- }
-
- CGPathRelease( xPath );
-
- return true;
-}
-
-void QuartzSalGraphics::drawPolyPolygon( sal_uLong nPolyCount, const sal_uLong *pPoints, PCONSTSALPOINT *ppPtAry )
-{
- if( nPolyCount <= 0 )
- return;
- if( !CheckContext() )
- return;
-
- // find bound rect
- long leftX = 0, topY = 0, maxWidth = 0, maxHeight = 0;
- getBoundRect( pPoints[0], ppPtAry[0], leftX, topY, maxWidth, maxHeight );
- for( sal_uLong n = 1; n < nPolyCount; n++ )
- {
- long nX = leftX, nY = topY, nW = maxWidth, nH = maxHeight;
- getBoundRect( pPoints[n], ppPtAry[n], nX, nY, nW, nH );
- if( nX < leftX )
- {
- maxWidth += leftX - nX;
- leftX = nX;
- }
- if( nY < topY )
- {
- maxHeight += topY - nY;
- topY = nY;
- }
- if( nX + nW > leftX + maxWidth )
- {
- maxWidth = nX + nW - leftX;
- }
- if( nY + nH > topY + maxHeight )
- {
- maxHeight = nY + nH - topY;
- }
- }
-
- // prepare drawing mode
- CGPathDrawingMode eMode;
- if( IsBrushVisible() && IsPenVisible() )
- {
- eMode = kCGPathEOFillStroke;
- }
- else if( IsPenVisible() )
- {
- eMode = kCGPathStroke;
- }
- else if( IsBrushVisible() )
- {
- eMode = kCGPathEOFill;
- }
- else
- {
- return;
- }
- // convert to CGPath
- CGContextBeginPath( mrContext );
- if( IsPenVisible() )
- {
- for( sal_uLong nPoly = 0; nPoly < nPolyCount; nPoly++ )
- {
- const sal_uLong nPoints = pPoints[nPoly];
- if( nPoints > 1 )
- {
- const SalPoint *pPtAry = ppPtAry[nPoly];
- float fX, fY;
- alignLinePoint( pPtAry, fX, fY );
- CGContextMoveToPoint( mrContext, fX, fY );
- pPtAry++;
- for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ )
- {
- alignLinePoint( pPtAry, fX, fY );
- CGContextAddLineToPoint( mrContext, fX, fY );
- }
- CGContextClosePath(mrContext);
- }
- }
- }
- else
- {
- for( sal_uLong nPoly = 0; nPoly < nPolyCount; nPoly++ )
- {
- const sal_uLong nPoints = pPoints[nPoly];
- if( nPoints > 1 )
- {
- const SalPoint *pPtAry = ppPtAry[nPoly];
- CGContextMoveToPoint( mrContext, pPtAry->mnX, pPtAry->mnY );
- pPtAry++;
- for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ )
- {
- CGContextAddLineToPoint( mrContext, pPtAry->mnX, pPtAry->mnY );
- }
- CGContextClosePath(mrContext);
- }
- }
- }
-
- CGContextDrawPath( mrContext, eMode );
-
- RefreshRect( leftX, topY, maxWidth, maxHeight );
-}
-
-void QuartzSalGraphics::drawPolygon( sal_uLong nPoints, const SalPoint *pPtAry )
-{
- if( nPoints <= 1 )
- return;
- if( !CheckContext() )
- return;
-
- long nX = 0, nY = 0, nWidth = 0, nHeight = 0;
- getBoundRect( nPoints, pPtAry, nX, nY, nWidth, nHeight );
-
- CGPathDrawingMode eMode;
- if( IsBrushVisible() && IsPenVisible() )
- {
- eMode = kCGPathEOFillStroke;
- }
- else if( IsPenVisible() )
- {
- eMode = kCGPathStroke;
- }
- else if( IsBrushVisible() )
- {
- eMode = kCGPathEOFill;
- }
- else
- {
- return;
- }
- CGContextBeginPath( mrContext );
-
- if( IsPenVisible() )
- {
- float fX, fY;
- alignLinePoint( pPtAry, fX, fY );
- CGContextMoveToPoint( mrContext, fX, fY );
- pPtAry++;
- for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ )
- {
- alignLinePoint( pPtAry, fX, fY );
- CGContextAddLineToPoint( mrContext, fX, fY );
- }
- }
- else
- {
- CGContextMoveToPoint( mrContext, pPtAry->mnX, pPtAry->mnY );
- pPtAry++;
- for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ )
- {
- CGContextAddLineToPoint( mrContext, pPtAry->mnX, pPtAry->mnY );
- }
- }
-
- CGContextDrawPath( mrContext, eMode );
- RefreshRect( nX, nY, nWidth, nHeight );
-}
-
-sal_Bool QuartzSalGraphics::drawPolygonBezier( sal_uLong, const SalPoint*, const sal_uInt8* )
-{
- return sal_False;
-}
-
-sal_Bool QuartzSalGraphics::drawPolyPolygonBezier( sal_uLong, const sal_uLong*,
- const SalPoint* const*, const sal_uInt8* const* )
-{
- return sal_False;
-}
-
-void QuartzSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight )
-{
- if( !CheckContext() )
- {
- return;
- }
- CGRect aRect( CGRectMake(nX, nY, nWidth, nHeight) );
- if( IsPenVisible() )
- {
- aRect.origin.x += 0.5;
- aRect.origin.y += 0.5;
- aRect.size.width -= 1;
- aRect.size.height -= 1;
- }
-
- if( IsBrushVisible() )
- {
- CGContextFillRect( mrContext, aRect );
- }
- if( IsPenVisible() )
- {
- CGContextStrokeRect( mrContext, aRect );
- }
- RefreshRect( nX, nY, nWidth, nHeight );
-}
-
-
-void QuartzSalGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry )
-{
- if( nPoints < 1 )
- {
- return;
- }
- if( !CheckContext() )
- {
- return;
- }
-
- long nX = 0, nY = 0, nWidth = 0, nHeight = 0;
- getBoundRect( nPoints, pPtAry, nX, nY, nWidth, nHeight );
-
- float fX, fY;
- CGContextBeginPath( mrContext );
- alignLinePoint( pPtAry, fX, fY );
- CGContextMoveToPoint( mrContext, fX, fY );
- pPtAry++;
- for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ )
- {
- alignLinePoint( pPtAry, fX, fY );
- CGContextAddLineToPoint( mrContext, fX, fY );
- }
- CGContextDrawPath( mrContext, kCGPathStroke );
-
- RefreshRect( nX, nY, nWidth, nHeight );
-}
-
-sal_uInt16 QuartzSalGraphics::GetBitCount() const
-{
- sal_uInt16 nBits = mnBitmapDepth ? mnBitmapDepth : 32;//24;
- return nBits;
-}
-
-SalBitmap* QuartzSalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
-{
- DBG_ASSERT( mxLayer, "QuartzSalGraphics::getBitmap() with no layer" );
-
- ApplyXorContext();
-
- QuartzSalBitmap* pBitmap = new QuartzSalBitmap;
- if( !pBitmap->Create( mxLayer, mnBitmapDepth, nX, nY, nDX, nDY, !mbWindow ) )
- {
- delete pBitmap;
- pBitmap = NULL;
- }
-
- return pBitmap;
-}
-
-SystemGraphicsData QuartzSalGraphics::GetGraphicsData() const
-{
- SystemGraphicsData aRes;
- aRes.nSize = sizeof(aRes);
- aRes.rCGContext = mrContext;
- return aRes;
-}
-
-long QuartzSalGraphics::GetGraphicsWidth() const
-{
- long w = 0;
- if( mrContext && (mbWindow || mbVirDev) )
- {
- w = mnWidth;
- }
-
- if( w == 0 )
- {
- if( mbWindow && mpFrame )
- {
- w = mpFrame->maGeometry.nWidth;
- }
- }
- return w;
-}
-
-SalColor QuartzSalGraphics::getPixel( long nX, long nY )
-{
- // return default value on printers or when out of bounds
- if( !mxLayer || (nX < 0) || (nX >= mnWidth) ||
- (nY < 0) || (nY >= mnHeight))
- {
- return COL_BLACK;
- }
- // prepare creation of matching a CGBitmapContext
- CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace;
- CGBitmapInfo aCGBmpInfo = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big;
-#if defined OSL_BIGENDIAN
- struct{ unsigned char b, g, r, a; } aPixel;
-#else
- struct{ unsigned char a, r, g, b; } aPixel;
-#endif
-
- // create a one-pixel bitmap context
- // TODO: is it worth to cache it?
- CGContextRef xOnePixelContext =
- ::CGBitmapContextCreate( &aPixel, 1, 1, 8, sizeof(aPixel),
- aCGColorSpace, aCGBmpInfo );
-
- // update this graphics layer
- ApplyXorContext();
-
- // copy the requested pixel into the bitmap context
- if( IsFlipped() )
- {
- nY = mnHeight - nY;
- }
- const CGPoint aCGPoint = { static_cast<CGFloat>(-nX), static_cast<CGFloat>(-nY)};
- CGContextDrawLayerAtPoint( xOnePixelContext, aCGPoint, mxLayer );
- CGContextRelease( xOnePixelContext );
-
- SalColor nSalColor = MAKE_SALCOLOR( aPixel.r, aPixel.g, aPixel.b );
- return nSalColor;
-}
-
-void QuartzSalGraphics::GetResolution( long& rDPIX, long& rDPIY )
-{
- if( !mnRealDPIY )
- {
- initResolution( (mbWindow && mpFrame) ? mpFrame->mpWindow : nil );
- }
-
- rDPIX = static_cast<long>(mfFakeDPIScale * mnRealDPIX);
- rDPIY = static_cast<long>(mfFakeDPIScale * mnRealDPIY);
-}
-
-void QuartzSalGraphics::ImplDrawPixel( long nX, long nY, const RGBAColor& rColor )
-{
- if( !CheckContext() )
- {
- return;
- }
- // overwrite the fill color
- CGContextSetFillColor( mrContext, rColor.AsArray() );
- // draw 1x1 rect, there is no pixel drawing in Quartz
- CGRect aDstRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { 1, 1 } };
- CGContextFillRect( mrContext, aDstRect );
- RefreshRect( aDstRect );
- // reset the fill color
- CGContextSetFillColor( mrContext, maFillColor.AsArray() );
-}
-
-void QuartzSalGraphics::initResolution( UIWindow* )
-{
- // #i100617# read DPI only once; there is some kind of weird caching going on
- // if the main screen changes
- // FIXME: this is really unfortunate and needs to be investigated
-
- SalData* pSalData = GetSalData();
- if( pSalData->mnDPIX == 0 || pSalData->mnDPIY == 0 )
- {
- UIScreen* pScreen = [UIScreen mainScreen];
-
- mnRealDPIX = mnRealDPIY = 160;
- if( pScreen )
- {
- mnRealDPIX *= [pScreen scale];
- mnRealDPIY *= [pScreen scale];
- }
- else
- {
- OSL_FAIL( "no screen found" );
- }
-
- pSalData->mnDPIX = mnRealDPIX;
- pSalData->mnDPIY = mnRealDPIY;
- }
- else
- {
- mnRealDPIX = pSalData->mnDPIX;
- mnRealDPIY = pSalData->mnDPIY;
- }
-
- mfFakeDPIScale = 1.0;
-}
-
-void QuartzSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags )
-{
- if ( CheckContext() )
- {
- CGRect aCGRect = CGRectMake( nX, nY, nWidth, nHeight);
- CGContextSaveGState(mrContext);
-
- if ( nFlags & SAL_INVERT_TRACKFRAME )
- {
- const float dashLengths[2] = { 4.0, 4.0 }; // for drawing dashed line
- CGContextSetBlendMode( mrContext, kCGBlendModeDifference );
- CGContextSetRGBStrokeColor ( mrContext, 1.0, 1.0, 1.0, 1.0 );
- CGContextSetLineDash ( mrContext, 0, dashLengths, 2 );
- CGContextSetLineWidth( mrContext, 2.0);
- CGContextStrokeRect ( mrContext, aCGRect );
- }
- else if ( nFlags & SAL_INVERT_50 )
- {
- //CGContextSetAllowsAntialiasing( mrContext, false );
- CGContextSetBlendMode(mrContext, kCGBlendModeDifference);
- CGContextAddRect( mrContext, aCGRect );
- Pattern50Fill();
- }
- else // just invert
- {
- CGContextSetBlendMode(mrContext, kCGBlendModeDifference);
- CGContextSetRGBFillColor ( mrContext,1.0, 1.0, 1.0 , 1.0 );
- CGContextFillRect ( mrContext, aCGRect );
- }
- CGContextRestoreGState( mrContext);
- RefreshRect( aCGRect );
- }
-}
-
-void QuartzSalGraphics::invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nSalFlags )
-{
- CGPoint* CGpoints ;
- if ( CheckContext() )
- {
- CGContextSaveGState(mrContext);
- CGpoints = makeCGptArray(nPoints,pPtAry);
- CGContextAddLines ( mrContext, CGpoints, nPoints );
- if ( nSalFlags & SAL_INVERT_TRACKFRAME )
- {
- const float dashLengths[2] = { 4.0, 4.0 }; // for drawing dashed line
- CGContextSetBlendMode( mrContext, kCGBlendModeDifference );
- CGContextSetRGBStrokeColor ( mrContext, 1.0, 1.0, 1.0, 1.0 );
- CGContextSetLineDash ( mrContext, 0, dashLengths, 2 );
- CGContextSetLineWidth( mrContext, 2.0);
- CGContextStrokePath ( mrContext );
- }
- else if ( nSalFlags & SAL_INVERT_50 )
- {
- CGContextSetBlendMode(mrContext, kCGBlendModeDifference);
- Pattern50Fill();
- }
- else // just invert
- {
- CGContextSetBlendMode( mrContext, kCGBlendModeDifference );
- CGContextSetRGBFillColor( mrContext, 1.0, 1.0, 1.0, 1.0 );
- CGContextFillPath( mrContext );
- }
- const CGRect aRefreshRect = CGContextGetClipBoundingBox(mrContext);
- CGContextRestoreGState( mrContext);
- delete [] CGpoints;
- RefreshRect( aRefreshRect );
- }
-}
-
-void QuartzSalGraphics::Pattern50Fill()
-{
- static const float aFillCol[4] = { 1,1,1,1 };
- static const CGPatternCallbacks aCallback = { 0, &DrawPattern50, NULL };
- if( ! GetSalData()->mxP50Space )
- {
- GetSalData()->mxP50Space = CGColorSpaceCreatePattern( GetSalData()->mxRGBSpace );
- }
- if( ! GetSalData()->mxP50Pattern )
- {
- GetSalData()->mxP50Pattern = CGPatternCreate( NULL, CGRectMake( 0, 0, 4, 4 ),
- CGAffineTransformIdentity, 4, 4,
- kCGPatternTilingConstantSpacing,
- false, &aCallback );
- }
- CGContextSetFillColorSpace( mrContext, GetSalData()->mxP50Space );
- CGContextSetFillPattern( mrContext, GetSalData()->mxP50Pattern, aFillCol );
- CGContextFillPath( mrContext );
-}
-
-
-void QuartzSalGraphics::ResetClipRegion()
-{
- // release old path and indicate no clipping
- if( mxClipPath )
- {
- CGPathRelease( mxClipPath );
- mxClipPath = NULL;
- }
- if( CheckContext() )
- {
- SetState();
- }
-}
-
-void QuartzSalGraphics::SetLineColor()
-{
- maLineColor.SetAlpha( 0.0 ); // transparent
- if( CheckContext() )
- {
- CGContextSetStrokeColor( mrContext, maLineColor.AsArray() );
- }
-}
-
-void QuartzSalGraphics::SetLineColor( SalColor nSalColor )
-{
- maLineColor = RGBAColor( nSalColor );
- if( CheckContext() )
- {
- CGContextSetStrokeColor( mrContext, maLineColor.AsArray() );
- }
-}
-
-void QuartzSalGraphics::SetFillColor()
-{
- maFillColor.SetAlpha( 0.0 ); // transparent
- if( CheckContext() )
- {
- CGContextSetFillColor( mrContext, maFillColor.AsArray() );
- }
-}
-
-void QuartzSalGraphics::SetFillColor( SalColor nSalColor )
-{
- maFillColor = RGBAColor( nSalColor );
- if( CheckContext() )
- {
- CGContextSetFillColor( mrContext, maFillColor.AsArray() );
- }
-}
-
-bool QuartzSalGraphics::supportsOperation( OutDevSupportType eType ) const
-{
- bool bRet = false;
- switch( eType )
- {
- case OutDevSupport_TransparentRect:
- case OutDevSupport_B2DClip:
- case OutDevSupport_B2DDraw:
- bRet = true;
- break;
- default: break;
- }
- return bRet;
-}
-
-bool QuartzSalGraphics::setClipRegion( const Region& i_rClip )
-{
- // release old clip path
- if( mxClipPath )
- {
- CGPathRelease( mxClipPath );
- mxClipPath = NULL;
- }
- mxClipPath = CGPathCreateMutable();
-
- // set current path, either as polypolgon or sequence of rectangles
- if( i_rClip.HasPolyPolygon() )
- {
- basegfx::B2DPolyPolygon aClip( const_cast<Region&>(i_rClip).ConvertToB2DPolyPolygon() );
- AddPolyPolygonToPath( mxClipPath, aClip, !getAntiAliasB2DDraw(), false );
- }
- else
- {
- long nX, nY, nW, nH;
- ImplRegionInfo aInfo;
- bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
- while( bRegionRect )
- {
- if( nW && nH )
- {
- CGRect aRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nW), static_cast<CGFloat>(nH) } };
- CGPathAddRect( mxClipPath, NULL, aRect );
- }
- bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
- }
- }
- // set the current path as clip region
- if( CheckContext() )
- {
- SetState();
- }
- return true;
-}
-
-void QuartzSalGraphics::SetROPFillColor( SalROPColor nROPColor )
-{
- if( ! mbPrinter )
- SetFillColor( ImplGetROPSalColor( nROPColor ) );
-}
-
-void QuartzSalGraphics::SetROPLineColor( SalROPColor nROPColor )
-{
- if( ! mbPrinter )
- SetLineColor( ImplGetROPSalColor( nROPColor ) );
-}
-
-void QuartzSalGraphics::SetXORMode( bool bSet, bool bInvertOnly )
-{
- // return early if XOR mode remains unchanged
- if( mbPrinter )
- {
- return;
- }
- if( ! bSet && mnXorMode == 2 )
- {
- CGContextSetBlendMode( mrContext, kCGBlendModeNormal );
- mnXorMode = 0;
- return;
- }
- else if( bSet && bInvertOnly && mnXorMode == 0)
- {
- CGContextSetBlendMode( mrContext, kCGBlendModeDifference );
- mnXorMode = 2;
- return;
- }
-
- if( (mpXorEmulation == NULL) && !bSet )
- {
- return;
- }
- if( (mpXorEmulation != NULL) && (bSet == mpXorEmulation->IsEnabled()) )
- {
- return;
- }
- if( !CheckContext() )
- {
- return;
- }
- // prepare XOR emulation
- if( !mpXorEmulation )
- {
- mpXorEmulation = new XorEmulation();
- mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer );
- }
-
- // change the XOR mode
- if( bSet )
- {
- mpXorEmulation->Enable();
- mrContext = mpXorEmulation->GetMaskContext();
- mnXorMode = 1;
- }
- else
- {
- mpXorEmulation->UpdateTarget();
- mpXorEmulation->Disable();
- mrContext = mpXorEmulation->GetTargetContext();
- mnXorMode = 0;
- }
-}
-
-void QuartzSalGraphics::updateResolution()
-{
- DBG_ASSERT( mbWindow, "updateResolution on inappropriate graphics" );
-
- initResolution( (mbWindow && mpFrame) ? mpFrame->mpWindow : nil );
-}
-
-
-// -----------------------------------------------------------
-
-XorEmulation::XorEmulation()
-: m_xTargetLayer( NULL )
-, m_xTargetContext( NULL )
-, m_xMaskContext( NULL )
-, m_xTempContext( NULL )
-, m_pMaskBuffer( NULL )
-, m_pTempBuffer( NULL )
-, m_nBufferLongs( 0 )
-, m_bIsEnabled( false )
-{}
-
-XorEmulation::~XorEmulation()
-{
- Disable();
- SetTarget( 0, 0, 0, NULL, NULL );
-}
-
-void XorEmulation::SetTarget( int nWidth, int nHeight, int nTargetDepth,
- CGContextRef xTargetContext, CGLayerRef xTargetLayer )
-{
- // prepare to replace old mask+temp context
- if( m_xMaskContext )
- {
- // cleanup the mask context
- CGContextRelease( m_xMaskContext );
- delete[] m_pMaskBuffer;
- m_xMaskContext = NULL;
- m_pMaskBuffer = NULL;
-
- // cleanup the temp context if needed
- if( m_xTempContext )
- {
- CGContextRelease( m_xTempContext );
- delete[] m_pTempBuffer;
- m_xTempContext = NULL;
- m_pTempBuffer = NULL;
- }
- }
-
- // return early if there is nothing more to do
- if( !xTargetContext )
- {
- return;
- }
- // retarget drawing operations to the XOR mask
- m_xTargetLayer = xTargetLayer;
- m_xTargetContext = xTargetContext;
-
- // prepare creation of matching CGBitmaps
- CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace;
- CGBitmapInfo aCGBmpInfo = kCGImageAlphaNoneSkipFirst;
- int nBitDepth = nTargetDepth;
- if( !nBitDepth )
- {
- nBitDepth = 32;
- }
- int nBytesPerRow = (nBitDepth == 16) ? 2 : 4;
- const size_t nBitsPerComponent = (nBitDepth == 16) ? 5 : 8;
- if( nBitDepth <= 8 )
- {
- aCGColorSpace = GetSalData()->mxGraySpace;
- aCGBmpInfo = kCGImageAlphaNone;
- nBytesPerRow = 1;
- }
- nBytesPerRow *= nWidth;
- m_nBufferLongs = (nHeight * nBytesPerRow + sizeof(sal_uLong)-1) / sizeof(sal_uLong);
-
- // create a XorMask context
- m_pMaskBuffer = new sal_uLong[ m_nBufferLongs ];
- m_xMaskContext = ::CGBitmapContextCreate( m_pMaskBuffer,
- nWidth, nHeight,
- nBitsPerComponent, nBytesPerRow,
- aCGColorSpace, aCGBmpInfo );
- // reset the XOR mask to black
- memset( m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong) );
-
- // a bitmap context will be needed for manual XORing
- // create one unless the target context is a bitmap context
- if( nTargetDepth )
- m_pTempBuffer = (sal_uLong*)CGBitmapContextGetData( m_xTargetContext );
- if( !m_pTempBuffer )
- {
- // create a bitmap context matching to the target context
- m_pTempBuffer = new sal_uLong[ m_nBufferLongs ];
- m_xTempContext = ::CGBitmapContextCreate( m_pTempBuffer,
- nWidth, nHeight,
- nBitsPerComponent, nBytesPerRow,
- aCGColorSpace, aCGBmpInfo );
- }
-
- // initialize XOR mask context for drawing
- CGContextSetFillColorSpace( m_xMaskContext, aCGColorSpace );
- CGContextSetStrokeColorSpace( m_xMaskContext, aCGColorSpace );
- CGContextSetShouldAntialias( m_xMaskContext, false );
-
- // improve the XorMask's XOR emulation a litte
- // NOTE: currently only enabled for monochrome contexts
- if( aCGColorSpace == GetSalData()->mxGraySpace )
- {
- CGContextSetBlendMode( m_xMaskContext, kCGBlendModeDifference );
- }
- // intialize the transformation matrix to the drawing target
- const CGAffineTransform aCTM = CGContextGetCTM( xTargetContext );
- CGContextConcatCTM( m_xMaskContext, aCTM );
- if( m_xTempContext )
- {
- CGContextConcatCTM( m_xTempContext, aCTM );
- }
- // initialize the default XorMask graphics state
- CGContextSaveGState( m_xMaskContext );
-}
-
-bool XorEmulation::UpdateTarget()
-{
- if( !IsEnabled() )
- {
- return false;
- }
- // update the temp bitmap buffer if needed
- if( m_xTempContext )
- {
- CGContextDrawLayerAtPoint( m_xTempContext, CGPointZero, m_xTargetLayer );
- }
- // do a manual XOR with the XorMask
- // this approach suffices for simple color manipulations
- // and also the complex-clipping-XOR-trick used in metafiles
- const sal_uLong* pSrc = m_pMaskBuffer;
- sal_uLong* pDst = m_pTempBuffer;
- for( int i = m_nBufferLongs; --i >= 0;)
- {
- *(pDst++) ^= *(pSrc++);
- }
- // write back the XOR results to the target context
- if( m_xTempContext )
- {
- CGImageRef xXorImage = CGBitmapContextCreateImage( m_xTempContext );
- const int nWidth = (int)CGImageGetWidth( xXorImage );
- const int nHeight = (int)CGImageGetHeight( xXorImage );
- // TODO: update minimal changerect
- const CGRect aFullRect = { { 0, 0 }, { static_cast<CGFloat>(nWidth), static_cast<CGFloat>(nHeight) } };
- CGContextDrawImage( m_xTargetContext, aFullRect, xXorImage );
- CGImageRelease( xXorImage );
- }
-
- // reset the XorMask to black again
- // TODO: not needed for last update
- memset( m_pMaskBuffer, 0, m_nBufferLongs * sizeof(sal_uLong) );
-
- // TODO: return FALSE if target was not changed
- return true;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/gdi/salgdiutils.cxx b/vcl/ios/source/gdi/salgdiutils.cxx
deleted file mode 100644
index fc499e450743..000000000000
--- a/vcl/ios/source/gdi/salgdiutils.cxx
+++ /dev/null
@@ -1,304 +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 "basebmp/scanlineformats.hxx"
-#include "basebmp/color.hxx"
-
-#include "basegfx/range/b2drectangle.hxx"
-#include "basegfx/range/b2irange.hxx"
-#include "basegfx/vector/b2ivector.hxx"
-#include "basegfx/polygon/b2dpolygon.hxx"
-#include "basegfx/polygon/b2dpolygontools.hxx"
-
-#include "vcl/svapp.hxx"
-
-#include "coretext/salgdi.h"
-#include "ios/salframe.h"
-#include "ios/saldata.hxx"
-
-// ----------------------------------------------------------------------
-
-void QuartzSalGraphics::SetWindowGraphics( IosSalFrame* pFrame )
-{
- mpFrame = pFrame;
-
- mbWindow = true;
- mbPrinter = false;
- mbVirDev = false;
-}
-
-void QuartzSalGraphics::SetPrinterGraphics( CGContextRef xContext, long nDPIX, long nDPIY, double fScale )
-{
- mbWindow = false;
- mbPrinter = true;
- mbVirDev = false;
-
- mrContext = xContext;
- mfFakeDPIScale = fScale;
- mnRealDPIX = nDPIX;
- mnRealDPIY = nDPIY;
-
- // a previously set clip path is now invalid
- if( mxClipPath )
- {
- CGPathRelease( mxClipPath );
- mxClipPath = NULL;
- }
-
- if( mrContext )
- {
- CGContextSetFillColorSpace( mrContext, GetSalData()->mxRGBSpace );
- CGContextSetStrokeColorSpace( mrContext, GetSalData()->mxRGBSpace );
- CGContextSaveGState( mrContext );
- SetState();
- }
-}
-
-void QuartzSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContext,
- int nBitmapDepth )
-{
- mbWindow = false;
- mbPrinter = false;
- mbVirDev = true;
-
- // set graphics properties
- mxLayer = xLayer;
- mrContext = xContext;
- mnBitmapDepth = nBitmapDepth;
-
- // return early if the virdev is being destroyed
- if( !xContext )
- return;
-
- // get new graphics properties
- if( !mxLayer )
- {
- mnWidth = CGBitmapContextGetWidth( mrContext );
- mnHeight = CGBitmapContextGetHeight( mrContext );
- }
- else
- {
- const CGSize aSize = CGLayerGetSize( mxLayer );
- mnWidth = static_cast<int>(aSize.width);
- mnHeight = static_cast<int>(aSize.height);
- }
-
- // prepare graphics for drawing
- const CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace;
- CGContextSetFillColorSpace( mrContext, aCGColorSpace );
- CGContextSetStrokeColorSpace( mrContext, aCGColorSpace );
-
- // re-enable XorEmulation for the new context
- if( mpXorEmulation )
- {
- mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer );
- if( mpXorEmulation->IsEnabled() )
- mrContext = mpXorEmulation->GetMaskContext();
- }
-
- // initialize stack of CGContext states
- CGContextSaveGState( mrContext );
- SetState();
-}
-
-// ----------------------------------------------------------------------
-
-void QuartzSalGraphics::InvalidateContext()
-{
- UnsetState();
- mrContext = 0;
-}
-
-// ----------------------------------------------------------------------
-
-void QuartzSalGraphics::UnsetState()
-{
- if( mrContext )
- {
- CGContextRestoreGState( mrContext );
- mrContext = 0;
- }
- if( mxClipPath )
- {
- CGPathRelease( mxClipPath );
- mxClipPath = NULL;
- }
-}
-
-void QuartzSalGraphics::SetState()
-{
- CGContextRestoreGState( mrContext );
- CGContextSaveGState( mrContext );
-
- // setup clipping
- if( mxClipPath )
- {
- CGContextBeginPath( mrContext ); // discard any existing path
- CGContextAddPath( mrContext, mxClipPath ); // set the current path to the clipping path
- CGContextClip( mrContext ); // use it for clipping
- }
-
- // set RGB colorspace and line and fill colors
- CGContextSetFillColor( mrContext, maFillColor.AsArray() );
- CGContextSetStrokeColor( mrContext, maLineColor.AsArray() );
- CGContextSetShouldAntialias( mrContext, false );
- if( mnXorMode == 2 )
- CGContextSetBlendMode( mrContext, kCGBlendModeDifference );
-}
-
-// ----------------------------------------------------------------------
-
-bool QuartzSalGraphics::CheckContext()
-{
- if( mbWindow && mpFrame != NULL )
- {
- const unsigned int nWidth = mpFrame->maGeometry.nWidth;
- const unsigned int nHeight = mpFrame->maGeometry.nHeight;
-
- CGContextRef rReleaseContext = 0;
- CGLayerRef rReleaseLayer = NULL;
-
- // check if a new drawing context is needed (e.g. after a resize)
- if( (unsigned(mnWidth) != nWidth) || (unsigned(mnHeight) != nHeight) )
- {
- mnWidth = nWidth;
- mnHeight = nHeight;
- // prepare to release the corresponding resources
- rReleaseContext = mrContext;
- rReleaseLayer = mxLayer;
- mrContext = NULL;
- mxLayer = NULL;
- }
-
- if( !mrContext )
- {
-#if 0 // No idea
- const CGSize aLayerSize = {nWidth,nHeight};
- UIGraphicsContext* puiGContext = [UIGraphicsContext graphicsContextWithWindow: mpFrame->getWindow()];
- CGContextRef xCGContext = reinterpret_cast<CGContextRef>([pUIGContext graphicsPort]);
- mxLayer = CGLayerCreateWithContext( xCGContext, aLayerSize, NULL );
- if( mxLayer )
- mrContext = CGLayerGetContext( mxLayer );
-#endif
- if( mrContext )
- {
- // copy original layer to resized layer
- if( rReleaseLayer )
- CGContextDrawLayerAtPoint( mrContext, CGPointZero, rReleaseLayer );
-
- CGContextTranslateCTM( mrContext, 0, nHeight );
- CGContextScaleCTM( mrContext, 1.0, -1.0 );
- CGContextSetFillColorSpace( mrContext, GetSalData()->mxRGBSpace );
- CGContextSetStrokeColorSpace( mrContext, GetSalData()->mxRGBSpace );
- CGContextSaveGState( mrContext );
- SetState();
-
- // re-enable XOR emulation for the new context
- if( mpXorEmulation )
- mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer );
- }
- }
-
- if( rReleaseLayer )
- CGLayerRelease( rReleaseLayer );
- else if( rReleaseContext )
- CGContextRelease( rReleaseContext );
- }
-
- DBG_ASSERT( mrContext || mbPrinter, "<<<WARNING>>> QuartzSalGraphics::CheckContext() FAILED!!!!\n" );
- return (mrContext != NULL);
-}
-
-CGContextRef QuartzSalGraphics::GetContext()
-{
- if(!mrContext)
- {
- CheckContext();
- }
- return mrContext;
-}
-
-void QuartzSalGraphics::RefreshRect(float lX, float lY, float lWidth, float lHeight)
-{
- if( ! mbWindow ) // view only on Window graphics
- return;
-
- if( mpFrame )
- {
- // update a little more around the designated rectangle
- // this helps with antialiased rendering
- const Rectangle aVclRect(Point(static_cast<long int>(lX-1),
- static_cast<long int>(lY-1) ),
- Size( static_cast<long int>(lWidth+2),
- static_cast<long int>(lHeight+2) ) );
- mpFrame->maInvalidRect.Union( aVclRect );
- }
-}
-
-CGPoint* QuartzSalGraphics::makeCGptArray(sal_uLong nPoints, const SalPoint* pPtAry)
-{
- CGPoint *CGpoints = new CGPoint[nPoints];
- if ( CGpoints )
- {
- for(sal_uLong i=0;i<nPoints;i++)
- {
- CGpoints[i].x = (float)(pPtAry[i].mnX);
- CGpoints[i].y = (float)(pPtAry[i].mnY);
- }
- }
- return CGpoints;
-}
-
-// -----------------------------------------------------------------------
-
-void QuartzSalGraphics::UpdateWindow( CGRect& )
-{
-#if 0 // Sigh, this is just basically a copy of the "aqua" code and not
- // applicable to iOS.
-
- if( !mpFrame )
- return;
- UIGraphicsContext* pContext = [UIGraphicsContext currentContext];
- if( (mxLayer != NULL) && (pContext != NULL) )
- {
- CGContextRef rCGContext = reinterpret_cast<CGContextRef>([pContext graphicsPort]);
-
- CGMutablePathRef rClip = mpFrame->getClipPath();
- if( rClip )
- {
- CGContextSaveGState( rCGContext );
- CGContextBeginPath( rCGContext );
- CGContextAddPath( rCGContext, rClip );
- CGContextClip( rCGContext );
- }
-
- ApplyXorContext();
- CGContextDrawLayerAtPoint( rCGContext, CGPointZero, mxLayer );
- if( rClip ) // cleanup clipping
- CGContextRestoreGState( rCGContext );
- }
- else
- DBG_ASSERT( mpFrame->mbInitShow, "UpdateWindow called on uneligible graphics" );
-#endif
-}
-
-// -----------------------------------------------------------------------
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/gdi/salnativewidgets.cxx b/vcl/ios/source/gdi/salnativewidgets.cxx
deleted file mode 100644
index c3023e19245e..000000000000
--- a/vcl/ios/source/gdi/salnativewidgets.cxx
+++ /dev/null
@@ -1,249 +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 "vcl/salnativewidgets.hxx"
-#include "vcl/decoview.hxx"
-#include "vcl/svapp.hxx"
-#include "vcl/timer.hxx"
-
-#include "coretext/salgdi.h"
-#include "ios/saldata.hxx"
-#include "ios/salframe.h"
-
-#include "premac.h"
-#include <UIKit/UIKit.h>
-#include "postmac.h"
-
-
-/*
- * IsNativeControlSupported()
- * --------------------------
- * Returns sal_True if the platform supports native
- * drawing of the control defined by nPart.
- *
- */
-sal_Bool QuartzSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart )
-{
- bool bOk = sal_False;
-
- // Native controls are now defaults
- // If you want to disable experimental native controls code,
- // just set the environment variable SAL_NO_NWF to something
- // and vcl controls will be used as default again.
-
- switch( nType )
- {
- case CTRL_PUSHBUTTON:
- case CTRL_RADIOBUTTON:
- case CTRL_CHECKBOX:
- case CTRL_LISTNODE:
- if( nPart == PART_ENTIRE_CONTROL )
- return true;
- break;
-
- case CTRL_SCROLLBAR:
- if( nPart == PART_DRAW_BACKGROUND_HORZ ||
- nPart == PART_DRAW_BACKGROUND_VERT ||
- nPart == PART_ENTIRE_CONTROL ||
- nPart == HAS_THREE_BUTTONS )
- return true;
- break;
-
- case CTRL_SLIDER:
- if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA )
- return true;
- break;
-
- case CTRL_EDITBOX:
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == HAS_BACKGROUND_TEXTURE )
- return true;
- break;
-
- case CTRL_MULTILINE_EDITBOX:
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == HAS_BACKGROUND_TEXTURE )
- return true;
- break;
-
- case CTRL_SPINBOX:
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == PART_ALL_BUTTONS ||
- nPart == HAS_BACKGROUND_TEXTURE )
- return true;
- break;
-
- case CTRL_SPINBUTTONS:
- return false;
- break;
-
- case CTRL_COMBOBOX:
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == HAS_BACKGROUND_TEXTURE )
- return true;
- break;
-
- case CTRL_LISTBOX:
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == PART_WINDOW ||
- nPart == HAS_BACKGROUND_TEXTURE ||
- nPart == PART_SUB_EDIT
- )
- return true;
- break;
-
- case CTRL_TAB_ITEM:
- case CTRL_TAB_PANE:
- case CTRL_TAB_BODY: // see vcl/source/window/tabpage.cxx
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == PART_TABS_DRAW_RTL ||
- nPart == HAS_BACKGROUND_TEXTURE )
- return true;
- break;
-
- // when PART_BUTTON is used, toolbar icons are not highlighted when mouse rolls over.
- // More Ios compliant
- case CTRL_TOOLBAR:
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == PART_DRAW_BACKGROUND_HORZ ||
- nPart == PART_DRAW_BACKGROUND_VERT)
- return true;
- break;
-
- case CTRL_WINDOW_BACKGROUND:
- if ( nPart == PART_BACKGROUND_WINDOW ||
- nPart == PART_BACKGROUND_DIALOG )
- return true;
- break;
-
- case CTRL_MENUBAR:
- if( nPart == PART_ENTIRE_CONTROL )
- return true;
- break;
-
- case CTRL_TOOLTIP: // ** TO DO
- break;
-
- case CTRL_MENU_POPUP:
- if( nPart == PART_ENTIRE_CONTROL ||
- nPart == PART_MENU_ITEM ||
- nPart == PART_MENU_ITEM_CHECK_MARK ||
- nPart == PART_MENU_ITEM_RADIO_MARK)
- return true;
- break;
- case CTRL_PROGRESS:
- case CTRL_INTROPROGRESS:
- if( nPart == PART_ENTIRE_CONTROL )
- return true;
- break;
- case CTRL_FRAME:
- if( nPart == PART_BORDER )
- return true;
- break;
- case CTRL_LISTNET:
- if( nPart == PART_ENTIRE_CONTROL )
- return true;
- break;
- }
-
- return bOk;
-}
-
-/*
- * HitTestNativeControl()
- *
- * If the return value is sal_True, bIsInside contains information whether
- * aPos was or was not inside the native widget specified by the
- * nType/nPart combination.
- */
-sal_Bool QuartzSalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
- const Point& rPos, sal_Bool& rIsInside )
-{
- (void) nType;
- (void) nPart;
- (void) rControlRegion;
- (void) rPos;
- (void) rIsInside;
- return sal_False;
-}
-
-UInt32 QuartzSalGraphics::getState( ControlState nState )
-{
- (void) nState;
- return 0;
-}
-
-UInt32 QuartzSalGraphics::getTrackState( ControlState nState )
-{
- (void) nState;
- return 0;
-}
-
-/*
- * DrawNativeControl()
- *
- * Draws the requested control described by nPart/nState.
- *
- * rControlRegion: The bounding region of the complete control in VCL frame coordinates.
- * aValue: An optional value (tristate/numerical/string)
- * aCaption: A caption or title string (like button text etc)
- */
-sal_Bool QuartzSalGraphics::drawNativeControl(ControlType nType,
- ControlPart nPart,
- const Rectangle& rControlRegion,
- ControlState nState,
- const ImplControlValue& aValue,
- const rtl::OUString& )
-{
- (void) nType;
- (void) nPart;
- (void) rControlRegion;
- (void) nState;
- (void) aValue;
- return sal_False;
-}
-
-/*
- * GetNativeControlRegion()
- *
- * If the return value is sal_True, rNativeBoundingRegion
- * contains the true bounding region covered by the control
- * including any adornment, while rNativeContentRegion contains the area
- * within the control that can be safely drawn into without drawing over
- * the borders of the control.
- *
- * rControlRegion: The bounding region of the control in VCL frame coordinates.
- * aValue: An optional value (tristate/numerical/string)
- * aCaption: A caption or title string (like button text etc)
- */
-sal_Bool QuartzSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState /*nState*/,
- const ImplControlValue& aValue, const rtl::OUString&,
- Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion )
-
-{
- (void) nType;
- (void) nPart;
- (void) rControlRegion;
- (void) aValue;
- (void) rNativeBoundingRegion;
- (void) rNativeContentRegion;
- return sal_False;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/gdi/salvd.cxx b/vcl/ios/source/gdi/salvd.cxx
deleted file mode 100644
index 6e32a22126e3..000000000000
--- a/vcl/ios/source/gdi/salvd.cxx
+++ /dev/null
@@ -1,249 +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 "vcl/svapp.hxx"
-#include "vcl/sysdata.hxx"
-
-#include "ios/salvd.h"
-#include "ios/salinst.h"
-#include "coretext/salgdi.h"
-#include "ios/saldata.hxx"
-#include "ios/salframe.h"
-
-// -----------------------------------------------------------------------
-
-SalVirtualDevice* IosSalInstance::CreateVirtualDevice( SalGraphics* pGraphics,
- long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData )
-{
- // #i92075# can be called first in a thread
- SalData::ensureThreadAutoreleasePool();
-
- return new IosSalVirtualDevice( static_cast< QuartzSalGraphics* >( pGraphics ), nDX, nDY, nBitCount, pData );
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalInstance::DestroyVirtualDevice( SalVirtualDevice* pDevice )
-{
- delete pDevice;
-}
-
-// =======================================================================
-
-IosSalVirtualDevice::IosSalVirtualDevice( QuartzSalGraphics* pGraphic, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData )
-: mbGraphicsUsed( false )
-, mxBitmapContext( NULL )
-, mnBitmapDepth( 0 )
-, mxLayer( NULL )
-{
- if( pGraphic && pData && pData->rCGContext )
- {
- // Create virtual device based on existing SystemGraphicsData
- // We ignore nDx and nDY, as the desired size comes from the SystemGraphicsData
- mbForeignContext = true; // the mxContext is from pData
- mpGraphics = new QuartzSalGraphics( /*pGraphic*/ );
- mpGraphics->SetVirDevGraphics( mxLayer, pData->rCGContext );
- }
- else
- {
- // create empty new virtual device
- mbForeignContext = false; // the mxContext is created within VCL
- mpGraphics = new QuartzSalGraphics(); // never fails
- mnBitmapDepth = nBitCount;
-
- // inherit resolution from reference device
- if( pGraphic )
- {
- IosSalFrame* pFrame = pGraphic->getGraphicsFrame();
- if( pFrame && IosSalFrame::isAlive( pFrame ) )
- {
- mpGraphics->setGraphicsFrame( pFrame );
- mpGraphics->copyResolution( *pGraphic );
- }
- }
-
- if( nDX && nDY )
- SetSize( nDX, nDY );
-
- // NOTE: if SetSize does not succeed, we just ignore the nDX and nDY
- }
-}
-
-// -----------------------------------------------------------------------
-
-IosSalVirtualDevice::~IosSalVirtualDevice()
-{
- if( mpGraphics )
- {
- mpGraphics->SetVirDevGraphics( NULL, NULL );
- delete mpGraphics;
- mpGraphics = 0;
- }
- Destroy();
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalVirtualDevice::Destroy()
-{
- if( mbForeignContext ) {
- // Do not delete mxContext that we have received from outside VCL
- mxLayer = NULL;
- return;
- }
-
- if( mxLayer )
- {
- if( mpGraphics )
- mpGraphics->SetVirDevGraphics( NULL, NULL );
- CGLayerRelease( mxLayer );
- mxLayer = NULL;
- }
-
- if( mxBitmapContext )
- {
- void* pRawData = CGBitmapContextGetData( mxBitmapContext );
- rtl_freeMemory( pRawData );
- CGContextRelease( mxBitmapContext );
- mxBitmapContext = NULL;
- }
-}
-
-// -----------------------------------------------------------------------
-
-SalGraphics* IosSalVirtualDevice::GetGraphics()
-{
- if( mbGraphicsUsed || !mpGraphics )
- return 0;
-
- mbGraphicsUsed = true;
- return mpGraphics;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalVirtualDevice::ReleaseGraphics( SalGraphics* )
-{
- mbGraphicsUsed = false;
-}
-
-// -----------------------------------------------------------------------
-
-sal_Bool IosSalVirtualDevice::SetSize( long nDX, long nDY )
-{
- if( mbForeignContext )
- {
- // Do not delete/resize mxContext that we have received from outside VCL
- return true;
- }
-
- if( mxLayer )
- {
- const CGSize aSize = CGLayerGetSize( mxLayer );
- if( (nDX == aSize.width) && (nDY == aSize.height) )
- {
- // Yay, we do not have to do anything :)
- return true;
- }
- }
-
- Destroy();
-
- // create a Quartz layer matching to the intended virdev usage
- CGContextRef xCGContext = NULL;
- if( mnBitmapDepth && (mnBitmapDepth < 16) )
- {
- mnBitmapDepth = 8; // TODO: are 1bit vdevs worth it?
- const CGColorSpaceRef aCGColorSpace = GetSalData()->mxGraySpace;
- const CGBitmapInfo aCGBmpInfo = kCGImageAlphaNone;
- const int nBytesPerRow = (mnBitmapDepth * nDX + 7) / 8;
-
- void* pRawData = rtl_allocateMemory( nBytesPerRow * nDY );
- mxBitmapContext = ::CGBitmapContextCreate( pRawData, nDX, nDY,
- mnBitmapDepth, nBytesPerRow, aCGColorSpace, aCGBmpInfo );
- xCGContext = mxBitmapContext;
- }
- else
- {
- // default to a UIView target context
- IosSalFrame* pSalFrame = mpGraphics->getGraphicsFrame();
- if( !pSalFrame && !GetSalData()->maFrames.empty() )
- pSalFrame = *GetSalData()->maFrames.begin();
- if( pSalFrame )
- {
-#if 0 // No idea...
- // #i91990#
- UIWindow* pWindow = pSalFrame->getWindow();
- if ( pWindow )
- {
- UIGraphicsContext* pUIContext = [UIGraphicsContext graphicsContextWithWindow: pWindow];
- if( pUIContext )
- xCGContext = reinterpret_cast<CGContextRef>([pUIContext graphicsPort]);
- }
- else
-#endif
- {
- // fall back to a bitmap context
- mnBitmapDepth = 32;
- const CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace;
- const CGBitmapInfo aCGBmpInfo = kCGImageAlphaNoneSkipFirst;
- const int nBytesPerRow = (mnBitmapDepth * nDX) / 8;
-
- void* pRawData = rtl_allocateMemory( nBytesPerRow * nDY );
- mxBitmapContext = ::CGBitmapContextCreate( pRawData, nDX, nDY,
- 8, nBytesPerRow, aCGColorSpace, aCGBmpInfo );
- xCGContext = mxBitmapContext;
- }
- }
- }
-
- DBG_ASSERT( xCGContext, "no context" );
-
- const CGSize aNewSize = { static_cast<CGFloat>(nDX), static_cast<CGFloat>(nDY) };
- mxLayer = CGLayerCreateWithContext( xCGContext, aNewSize, NULL );
-
- if( mxLayer && mpGraphics )
- {
- // get the matching Quartz context
- CGContextRef xDrawContext = CGLayerGetContext( mxLayer );
- mpGraphics->SetVirDevGraphics( mxLayer, xDrawContext, mnBitmapDepth );
- }
-
- return (mxLayer != NULL);
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalVirtualDevice::GetSize( long& rWidth, long& rHeight )
-{
- if( mxLayer )
- {
- const CGSize aSize = CGLayerGetSize( mxLayer );
- rWidth = static_cast<long>(aSize.width);
- rHeight = static_cast<long>(aSize.height);
- }
- else
- {
- rWidth = 0;
- rHeight = 0;
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/window/salframe.cxx b/vcl/ios/source/window/salframe.cxx
deleted file mode 100644
index 43cc7ba24a45..000000000000
--- a/vcl/ios/source/window/salframe.cxx
+++ /dev/null
@@ -1,1106 +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 <string>
-
-#include "rtl/ustrbuf.hxx"
-
-#include "osl/file.h"
-
-#include "vcl/svapp.hxx"
-#include "vcl/window.hxx"
-#include "vcl/timer.hxx"
-
-#include "ios/saldata.hxx"
-#include "coretext/salgdi.h"
-#include "ios/salframe.h"
-#include "ios/salmenu.h"
-#include "ios/saltimer.h"
-#include "ios/salinst.h"
-#include "ios/salframeview.h"
-
-#include "salwtype.hxx"
-
-using namespace std;
-
-// =======================================================================
-
-IosSalFrame* IosSalFrame::s_pCaptureFrame = NULL;
-
-// =======================================================================
-
-IosSalFrame::IosSalFrame( SalFrame* pParent, sal_uLong salFrameStyle ) :
- mpWindow(nil),
- mpView(nil),
- mpGraphics(NULL),
- mpParent(NULL),
- mnMinWidth(0),
- mnMinHeight(0),
- mnMaxWidth(0),
- mnMaxHeight(0),
- mbGraphics(false),
- mbShown(false),
- mbInitShow(true),
- mbPresentation( false ),
- mnStyle( salFrameStyle ),
- mnStyleMask( 0 ),
- mnLastEventTime( 0 ),
- mnLastModifierFlags( 0 ),
- mpMenu( NULL ),
- mnExtStyle( 0 ),
- mePointerStyle( POINTER_ARROW ),
- mrClippingPath( 0 ),
- mnICOptions( 0 )
-{
- maSysData.nSize = sizeof( SystemEnvData );
-
- mpParent = dynamic_cast<IosSalFrame*>(pParent);
-
- initWindowAndView();
-
- SalData* pSalData = GetSalData();
- pSalData->maFrames.push_front( this );
- pSalData->maFrameCheck.insert( this );
-}
-
-// -----------------------------------------------------------------------
-
-IosSalFrame::~IosSalFrame()
-{
- // cleanup clipping stuff
- ResetClipRegion();
-
- SalData* pSalData = GetSalData();
- pSalData->maFrames.remove( this );
- pSalData->maFrameCheck.erase( this );
-
- DBG_ASSERT( this != s_pCaptureFrame, "capture frame destroyed" );
- if( this == s_pCaptureFrame )
- s_pCaptureFrame = NULL;
-
- delete mpGraphics;
-
- if ( mpView ) {
- [mpView release];
- }
- if ( mpWindow )
- [mpWindow release];
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::initWindowAndView()
-{
- // initialize mirroring parameters
- // FIXME: screens changing
- UIScreen * pScreen = [mpWindow screen];
- if( pScreen == nil )
- pScreen = [UIScreen mainScreen];
- maScreenRect = [pScreen applicationFrame];
-
- // calculate some default geometry
- CGRect aVisibleRect = [pScreen applicationFrame];
- CocoaTouchToVCL( aVisibleRect );
-
- maGeometry.nX = static_cast<int>(aVisibleRect.origin.x + aVisibleRect.size.width / 10);
- maGeometry.nY = static_cast<int>(aVisibleRect.origin.y + aVisibleRect.size.height / 10);
- maGeometry.nWidth = static_cast<unsigned int>(aVisibleRect.size.width * 0.8);
- maGeometry.nHeight = static_cast<unsigned int>(aVisibleRect.size.height * 0.8);
-
- // calculate style mask
- if( (mnStyle & SAL_FRAME_STYLE_FLOAT) ||
- (mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) )
- ;
- else if( mnStyle & SAL_FRAME_STYLE_DEFAULT )
- {
- // make default window "maximized"
- maGeometry.nX = static_cast<int>(aVisibleRect.origin.x);
- maGeometry.nY = static_cast<int>(aVisibleRect.origin.y);
- maGeometry.nWidth = static_cast<int>(aVisibleRect.size.width);
- maGeometry.nHeight = static_cast<int>(aVisibleRect.size.height);
- }
- else
- {
- if( (mnStyle & SAL_FRAME_STYLE_MOVEABLE) )
- {
- }
- }
-
- mpWindow = [[SalFrameWindow alloc] initWithSalFrame: this];
- mpView = [[SalFrameView alloc] initWithSalFrame: this];
-
- maSysData.pView = mpView;
-
- UpdateFrameGeometry();
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::CocoaTouchToVCL( CGRect& io_rRect, bool bRelativeToScreen )
-{
- if( bRelativeToScreen )
- io_rRect.origin.y = maScreenRect.size.height - (io_rRect.origin.y+io_rRect.size.height);
- else
- io_rRect.origin.y = maGeometry.nHeight - (io_rRect.origin.y+io_rRect.size.height);
-}
-
-void IosSalFrame::VCLToCocoaTouch( CGRect& io_rRect, bool bRelativeToScreen )
-{
- if( bRelativeToScreen )
- io_rRect.origin.y = maScreenRect.size.height - (io_rRect.origin.y+io_rRect.size.height);
- else
- io_rRect.origin.y = maGeometry.nHeight - (io_rRect.origin.y+io_rRect.size.height);
-}
-
-void IosSalFrame::CocoaTouchToVCL( CGPoint& io_rPoint, bool bRelativeToScreen )
-{
- if( bRelativeToScreen )
- io_rPoint.y = maScreenRect.size.height - io_rPoint.y;
- else
- io_rPoint.y = maGeometry.nHeight - io_rPoint.y;
-}
-
-void IosSalFrame::VCLToCocoaTouch( CGPoint& io_rPoint, bool bRelativeToScreen )
-{
- if( bRelativeToScreen )
- io_rPoint.y = maScreenRect.size.height - io_rPoint.y;
- else
- io_rPoint.y = maGeometry.nHeight - io_rPoint.y;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::screenParametersChanged()
-{
- UpdateFrameGeometry();
-
- if( mpGraphics )
- mpGraphics->updateResolution();
- CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
-}
-
-// -----------------------------------------------------------------------
-
-SalGraphics* IosSalFrame::GetGraphics()
-{
- if ( mbGraphics )
- return NULL;
-
- if ( !mpGraphics )
- {
- mpGraphics = new QuartzSalGraphics;
- mpGraphics->SetWindowGraphics( this );
- }
-
- mbGraphics = TRUE;
- return mpGraphics;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::ReleaseGraphics( SalGraphics *pGraphics )
-{
- (void)pGraphics;
- DBG_ASSERT( pGraphics == mpGraphics, "graphics released on wrong frame" );
- mbGraphics = FALSE;
-}
-
-// -----------------------------------------------------------------------
-
-sal_Bool IosSalFrame::PostEvent( void *pData )
-{
- GetSalData()->mpFirstInstance->PostUserEvent( this, SALEVENT_USEREVENT, pData );
- return TRUE;
-}
-
-// -----------------------------------------------------------------------
-void IosSalFrame::SetTitle(const rtl::OUString& /* rTitle */)
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetIcon( sal_uInt16 )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetRepresentedURL( const rtl::OUString& /* i_rDocURL */ )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::initShow()
-{
- mbInitShow = false;
- {
- Rectangle aScreenRect;
- GetWorkArea( aScreenRect );
- if( mpParent ) // center relative to parent
- {
- // center on parent
- long nNewX = mpParent->maGeometry.nX + ((long)mpParent->maGeometry.nWidth - (long)maGeometry.nWidth)/2;
- if( nNewX < aScreenRect.Left() )
- nNewX = aScreenRect.Left();
- if( long(nNewX + maGeometry.nWidth) > aScreenRect.Right() )
- nNewX = aScreenRect.Right() - maGeometry.nWidth-1;
- long nNewY = mpParent->maGeometry.nY + ((long)mpParent->maGeometry.nHeight - (long)maGeometry.nHeight)/2;
- if( nNewY < aScreenRect.Top() )
- nNewY = aScreenRect.Top();
- if( nNewY > aScreenRect.Bottom() )
- nNewY = aScreenRect.Bottom() - maGeometry.nHeight-1;
- SetPosSize( nNewX - mpParent->maGeometry.nX,
- nNewY - mpParent->maGeometry.nY,
- 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y );
- }
- else if( ! (mnStyle & SAL_FRAME_STYLE_SIZEABLE) )
- {
- // center on screen
- long nNewX = (aScreenRect.GetWidth() - maGeometry.nWidth)/2;
- long nNewY = (aScreenRect.GetHeight() - maGeometry.nHeight)/2;
- SetPosSize( nNewX, nNewY, 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y );
- }
- }
-}
-
-void IosSalFrame::SendPaintEvent( const Rectangle* pRect )
-{
- SalPaintEvent aPaintEvt( 0, 0, maGeometry.nWidth, maGeometry.nHeight, true );
- if( pRect )
- {
- aPaintEvt.mnBoundX = pRect->Left();
- aPaintEvt.mnBoundY = pRect->Top();
- aPaintEvt.mnBoundWidth = pRect->GetWidth();
- aPaintEvt.mnBoundHeight = pRect->GetHeight();
- }
-
- CallCallback(SALEVENT_PAINT, &aPaintEvt);
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::Show(sal_Bool bVisible, sal_Bool bNoActivate)
-{
- if ( !mpWindow )
- return;
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- mbShown = bVisible;
- if(bVisible)
- {
- if( mbInitShow )
- initShow();
-
- CallCallback(SALEVENT_RESIZE, 0);
- // trigger filling our backbuffer
- SendPaintEvent();
-
- if( !bNoActivate )
- [mpWindow makeKeyAndVisible];
-#if 0 // ???
- if( mpParent )
- {
- /* #i92674# #i96433# we do not want an invisible parent to show up (which adding a visible
- child implicitly does). However we also do not want a parentless toolbar.
-
- HACK: try to decide when we should not insert a child to its parent
- floaters and ownerdraw windows have not yet shown up in cases where
- we don't want the parent to become visible
- */
- if( mpParent->mbShown || (mnStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_FLOAT) ) )
- {
- [mpParent->mpWindow addChildWindow: mpWindow];
- }
- }
-
- if( mbPresentation )
- [mpWindow makeMainWindow];
-#endif
- }
- else
- {
-#if 0 // ???
- if( mpParent && [mpWindow parentWindow] == mpParent->mpWindow )
- [mpParent->mpWindow removeChildWindow: mpWindow];
-#endif
- }
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::Enable( sal_Bool )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetMinClientSize( long nWidth, long nHeight )
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- mnMinWidth = nWidth;
- mnMinHeight = nHeight;
-
- if( mpWindow )
- {
- // Always add the decoration as the dimension concerns only
- // the content rectangle
- nWidth += maGeometry.nLeftDecoration + maGeometry.nRightDecoration;
- nHeight += maGeometry.nTopDecoration + maGeometry.nBottomDecoration;
-
-#if 0 // ???
- CGSize aSize = { nWidth, nHeight };
- // Size of full window (content+structure) although we only
- // have the client size in arguments
- [mpWindow setMinSize: aSize];
-#endif
- }
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetMaxClientSize( long nWidth, long nHeight )
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- mnMaxWidth = nWidth;
- mnMaxHeight = nHeight;
-
- if( mpWindow )
- {
- // Always add the decoration as the dimension concerns only
- // the content rectangle
- nWidth += maGeometry.nLeftDecoration + maGeometry.nRightDecoration;
- nHeight += maGeometry.nTopDecoration + maGeometry.nBottomDecoration;
-
- // Carbon windows can't have a size greater than 32767x32767
- if (nWidth>32767) nWidth=32767;
- if (nHeight>32767) nHeight=32767;
-
-#if 0 // ???
- CGSize aSize = { nWidth, nHeight };
- // Size of full window (content+structure) although we only
- // have the client size in arguments
- [mpWindow setMaxSize: aSize];
-#endif
- }
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetClientSize( long /*nWidth*/, long /*nHeight*/ )
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- if( mpWindow )
- {
-#if 0 // ???
- CGSize aSize = { nWidth, nHeight };
- [mpWindow setContentSize: aSize];
-#endif
- UpdateFrameGeometry();
- if( mbShown )
- // trigger filling our backbuffer
- SendPaintEvent();
- }
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::GetClientSize( long& rWidth, long& rHeight )
-{
- if( mbShown || mbInitShow )
- {
- rWidth = maGeometry.nWidth;
- rHeight = maGeometry.nHeight;
- }
- else
- {
- rWidth = 0;
- rHeight = 0;
- }
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetWindowState( const SalFrameState* pState )
-{
- // ???
-
- // get new geometry
- UpdateFrameGeometry();
-
- sal_uInt16 nEvent = 0;
- if( pState->mnMask & (SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_Y) )
- {
- mbPositioned = true;
- nEvent = SALEVENT_MOVE;
- }
-
- if( pState->mnMask & (SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT) )
- {
- mbSized = true;
- nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE;
- }
- // send event that we were moved/sized
- if( nEvent )
- CallCallback( nEvent, NULL );
-
- if( mbShown && mpWindow )
- {
- // trigger filling our backbuffer
- SendPaintEvent();
- }
-}
-
-// -----------------------------------------------------------------------
-
-sal_Bool IosSalFrame::GetWindowState( SalFrameState* pState )
-{
- if ( !mpWindow )
- return FALSE;
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- pState->mnMask = SAL_FRAMESTATE_MASK_X |
- SAL_FRAMESTATE_MASK_Y |
- SAL_FRAMESTATE_MASK_WIDTH |
- SAL_FRAMESTATE_MASK_HEIGHT |
- SAL_FRAMESTATE_MASK_STATE;
-
-#if 0 // ???
- CGRect aStateRect = [mpWindow frame];
- aStateRect = [UIWindow contentRectForFrameRect: aStateRect styleMask: mnStyleMask];
- CocoaTouchToVCL( aStateRect );
- pState->mnX = long(aStateRect.origin.x);
- pState->mnY = long(aStateRect.origin.y);
- pState->mnWidth = long(aStateRect.size.width);
- pState->mnHeight = long(aStateRect.size.height);
-#endif
- pState->mnState = SAL_FRAMESTATE_MAXIMIZED;
-
- return TRUE;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetScreenNumber(unsigned int /*nScreen*/)
-{
- // ???
-}
-
-void IosSalFrame::SetApplicationID( const rtl::OUString &/*rApplicationID*/ )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::ShowFullScreen( sal_Bool /*bFullScreen*/, sal_Int32 /*nDisplay*/ )
-{
- // ???
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::StartPresentation( sal_Bool /*bStart*/ )
-{
- if ( !mpWindow )
- return;
-
- // ???
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetAlwaysOnTop( sal_Bool )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::ToTop(sal_uInt16 /*nFlags*/)
-{
- if ( !mpWindow )
- return;
-
- // ???
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetPointer( PointerStyle /*ePointerStyle*/ )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetPointerPos( long /* nX */ , long /* nY */ )
-{
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::Flush( void )
-{
- // ???
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::Flush( const Rectangle& /*rRect*/ )
-{
- // ???
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::Sync()
-{
- // ???
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetInputContext( SalInputContext* pContext )
-{
- if (!pContext)
- {
- mnICOptions = 0;
- return;
- }
-
- mnICOptions = pContext->mnOptions;
-
- if(!(pContext->mnOptions & SAL_INPUTCONTEXT_TEXT))
- return;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::EndExtTextInput( sal_uInt16 )
-{
-}
-
-// -----------------------------------------------------------------------
-
-rtl::OUString IosSalFrame::GetKeyName( sal_uInt16 nKeyCode )
-{
- static std::map< sal_uInt16, rtl::OUString > aKeyMap;
- if( aKeyMap.empty() )
- {
- sal_uInt16 i;
- for( i = KEY_A; i <= KEY_Z; i++ )
- aKeyMap[ i ] = rtl::OUString( sal_Unicode( 'A' + (i - KEY_A) ) );
- for( i = KEY_0; i <= KEY_9; i++ )
- aKeyMap[ i ] = rtl::OUString( sal_Unicode( '0' + (i - KEY_0) ) );
- for( i = KEY_F1; i <= KEY_F26; i++ )
- {
- rtl::OUStringBuffer aKey( 3 );
- aKey.append( sal_Unicode( 'F' ) );
- aKey.append( sal_Int32( i - KEY_F1 + 1 ) );
- aKeyMap[ i ] = aKey.makeStringAndClear();
- }
-
- aKeyMap[ KEY_DOWN ] = rtl::OUString( sal_Unicode( 0x21e3 ) );
- aKeyMap[ KEY_UP ] = rtl::OUString( sal_Unicode( 0x21e1 ) );
- aKeyMap[ KEY_LEFT ] = rtl::OUString( sal_Unicode( 0x21e0 ) );
- aKeyMap[ KEY_RIGHT ] = rtl::OUString( sal_Unicode( 0x21e2 ) );
- aKeyMap[ KEY_HOME ] = rtl::OUString( sal_Unicode( 0x2196 ) );
- aKeyMap[ KEY_END ] = rtl::OUString( sal_Unicode( 0x2198 ) );
- aKeyMap[ KEY_PAGEUP ] = rtl::OUString( sal_Unicode( 0x21de ) );
- aKeyMap[ KEY_PAGEDOWN ] = rtl::OUString( sal_Unicode( 0x21df ) );
- aKeyMap[ KEY_RETURN ] = rtl::OUString( sal_Unicode( 0x21a9 ) );
- aKeyMap[ KEY_ESCAPE ] = rtl::OUString( "esc" );
- aKeyMap[ KEY_TAB ] = rtl::OUString( sal_Unicode( 0x21e5 ) );
- aKeyMap[ KEY_BACKSPACE ]= rtl::OUString( sal_Unicode( 0x232b ) );
- aKeyMap[ KEY_SPACE ] = rtl::OUString( sal_Unicode( 0x2423 ) );
- aKeyMap[ KEY_DELETE ] = rtl::OUString( sal_Unicode( 0x2326 ) );
- aKeyMap[ KEY_ADD ] = rtl::OUString( sal_Unicode( '+' ) );
- aKeyMap[ KEY_SUBTRACT ] = rtl::OUString( sal_Unicode( '-' ) );
- aKeyMap[ KEY_DIVIDE ] = rtl::OUString( sal_Unicode( '/' ) );
- aKeyMap[ KEY_MULTIPLY ] = rtl::OUString( sal_Unicode( '*' ) );
- aKeyMap[ KEY_POINT ] = rtl::OUString( sal_Unicode( '.' ) );
- aKeyMap[ KEY_COMMA ] = rtl::OUString( sal_Unicode( ',' ) );
- aKeyMap[ KEY_LESS ] = rtl::OUString( sal_Unicode( '<' ) );
- aKeyMap[ KEY_GREATER ] = rtl::OUString( sal_Unicode( '>' ) );
- aKeyMap[ KEY_EQUAL ] = rtl::OUString( sal_Unicode( '=' ) );
- aKeyMap[ KEY_OPEN ] = rtl::OUString( sal_Unicode( 0x23cf ) );
-
- /* yet unmapped KEYCODES:
- aKeyMap[ KEY_INSERT ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_CUT ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_COPY ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_PASTE ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_UNDO ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_REPEAT ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_FIND ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_PROPERTIES ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_FRONT ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_CONTEXTMENU ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_MENU ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_HELP ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_HANGUL_HANJA ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_DECIMAL ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_TILDE ] = rtl::OUString( sal_Unicode( ) );
- aKeyMap[ KEY_QUOTELEFT ]= rtl::OUString( sal_Unicode( ) );
- */
-
- }
-
- rtl::OUStringBuffer aResult( 16 );
-
- sal_uInt16 nUnmodifiedCode = (nKeyCode & KEY_CODE);
- std::map< sal_uInt16, rtl::OUString >::const_iterator it = aKeyMap.find( nUnmodifiedCode );
- if( it != aKeyMap.end() )
- {
- if( (nKeyCode & KEY_SHIFT) != 0 )
- aResult.append( sal_Unicode( 0x21e7 ) );
- if( (nKeyCode & KEY_MOD1) != 0 )
- aResult.append( sal_Unicode( 0x2318 ) );
- // we do not really handle Alt (see below)
- // we map it to MOD3, whichis actually Command
- if( (nKeyCode & (KEY_MOD2|KEY_MOD3)) != 0 )
- aResult.append( sal_Unicode( 0x2303 ) );
-
- aResult.append( it->second );
- }
-
- return aResult.makeStringAndClear();
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::getResolution( long& o_rDPIX, long& o_rDPIY )
-{
- if( ! mpGraphics )
- {
- GetGraphics();
- ReleaseGraphics( mpGraphics );
- }
- mpGraphics->GetResolution( o_rDPIX, o_rDPIY );
-}
-
-void IosSalFrame::UpdateSettings( AllSettings& rSettings )
-{
- if ( !mpWindow )
- return;
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- StyleSettings aStyleSettings = rSettings.GetStyleSettings();
-
- // Background Color
- Color aBackgroundColor = Color( 0xEC, 0xEC, 0xEC );
- aStyleSettings.Set3DColors( aBackgroundColor );
- aStyleSettings.SetFaceColor( aBackgroundColor );
- Color aInactiveTabColor( aBackgroundColor );
- aInactiveTabColor.DecreaseLuminance( 32 );
- aStyleSettings.SetInactiveTabColor( aInactiveTabColor );
-
- aStyleSettings.SetDialogColor( aBackgroundColor );
- aStyleSettings.SetLightBorderColor( aBackgroundColor );
- Color aShadowColor( aStyleSettings.GetShadowColor() );
- aShadowColor.IncreaseLuminance( 32 );
- aStyleSettings.SetShadowColor( aShadowColor );
-
- // get the system font settings
- Font aAppFont = aStyleSettings.GetAppFont();
- long nDPIX = 72, nDPIY = 72;
- getResolution( nDPIX, nDPIY );
-
- aStyleSettings.SetToolbarIconSize( nDPIY > 160 ? STYLE_TOOLBAR_ICONSIZE_LARGE : STYLE_TOOLBAR_ICONSIZE_SMALL );
-
- aStyleSettings.SetCursorBlinkTime( 500 );
-
- // no mnemonics on iOs
- aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_NOMNEMONICS );
-
- // images in menus false for iOS
- aStyleSettings.SetPreferredUseImagesInMenus( false );
- aStyleSettings.SetHideDisabledMenuItems( sal_True );
- aStyleSettings.SetAcceleratorsInContextMenus( sal_False );
-
- rSettings.SetStyleSettings( aStyleSettings );
-}
-
-// -----------------------------------------------------------------------
-
-const SystemEnvData* IosSalFrame::GetSystemData() const
-{
- return &maSysData;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::SetPosSize(long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt16 nFlags)
-{
- if ( !mpWindow )
- return;
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- sal_uInt16 nEvent = 0;
-
- if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y))
- {
- mbPositioned = true;
- nEvent = SALEVENT_MOVE;
- }
-
- if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
- {
- mbSized = true;
- nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE;
- }
-
-#if 0 // ???
- CGRect aFrameRect = [mpWindow frame];
- CGRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask];
-
- // position is always relative to parent frame
- CGRect aParentContentRect;
-
- if( mpParent )
- {
- if( Application::GetSettings().GetLayoutRTL() )
- {
- if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 )
- nX = mpParent->maGeometry.nWidth - nWidth-1 - nX;
- else
- nX = mpParent->maGeometry.nWidth - static_cast<long int>( aContentRect.size.width-1) - nX;
- }
- CGRect aParentFrameRect = [mpParent->mpWindow frame];
- aParentContentRect = [NSWindow contentRectForFrameRect: aParentFrameRect styleMask: mpParent->mnStyleMask];
- }
- else
- aParentContentRect = maScreenRect; // use screen if no parent
-
- CocoaTouchToVCL( aContentRect );
- CocoaTouchToVCL( aParentContentRect );
-
- bool bPaint = false;
- if( (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) != 0 )
- {
- if( nWidth != aContentRect.size.width || nHeight != aContentRect.size.height )
- bPaint = true;
- }
-
- // use old window pos if no new pos requested
- if( (nFlags & SAL_FRAME_POSSIZE_X) != 0 )
- aContentRect.origin.x = nX + aParentContentRect.origin.x;
- if( (nFlags & SAL_FRAME_POSSIZE_Y) != 0)
- aContentRect.origin.y = nY + aParentContentRect.origin.y;
-
- // use old size if no new size requested
- if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 )
- aContentRect.size.width = nWidth;
- if( (nFlags & SAL_FRAME_POSSIZE_HEIGHT) != 0)
- aContentRect.size.height = nHeight;
-
- VCLToCocoaTouch( aContentRect );
-
- // do not display yet, we need to update our backbuffer
- {
- [mpWindow setFrame: [NSWindow frameRectForContentRect: aContentRect styleMask: mnStyleMask] display: NO];
- }
-
- UpdateFrameGeometry();
-
- if (nEvent)
- CallCallback(nEvent, NULL);
-
- if( mbShown && bPaint )
- {
- // trigger filling our backbuffer
- SendPaintEvent();
-
- // now inform the system that the views need to be drawn
- [mpWindow display];
- }
-#endif
-}
-
-void IosSalFrame::GetWorkArea( Rectangle& rRect )
-{
- if ( !mpWindow )
- return;
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- UIScreen* pScreen = [mpWindow screen];
- if( pScreen == nil )
- pScreen = [UIScreen mainScreen];
- CGRect aRect = [pScreen applicationFrame];
- CocoaTouchToVCL( aRect );
- rRect.Left() = static_cast<long>(aRect.origin.x);
- rRect.Top() = static_cast<long>(aRect.origin.y);
- rRect.Right() = static_cast<long>(aRect.origin.x + aRect.size.width - 1);
- rRect.Bottom() = static_cast<long>(aRect.origin.y + aRect.size.height - 1);
-}
-
-SalPointerState IosSalFrame::GetPointerState()
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- SalPointerState state;
- state.mnState = 0;
-
- // ???
-
- return state;
-}
-
-SalFrame::SalIndicatorState IosSalFrame::GetIndicatorState()
-{
- SalIndicatorState aState;
- aState.mnState = 0;
- return aState;
-}
-
-void IosSalFrame::SimulateKeyPress( sal_uInt16 /*nKeyCode*/ )
-{
-}
-
-bool IosSalFrame::SetPluginParent( SystemParentData* )
-{
- // plugin parent may be killed unexpectedly by
- // plugging process;
-
- //TODO: implement
- return sal_False;
-}
-
-sal_Bool IosSalFrame::MapUnicodeToKeyCode( sal_Unicode , LanguageType , KeyCode& )
-{
- // not supported yet
- return FALSE;
-}
-
-LanguageType IosSalFrame::GetInputLanguage()
-{
- //TODO: implement
- return LANGUAGE_DONTKNOW;
-}
-
-void IosSalFrame::DrawMenuBar()
-{
-}
-
-void IosSalFrame::SetMenu( SalMenu* /*pSalMenu*/ )
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- // ???
-}
-
-void IosSalFrame::SetExtendedFrameStyle( SalExtStyle /*nStyle*/ )
-{
- // ???
-}
-
-SalFrame* IosSalFrame::GetParent() const
-{
- return mpParent;
-}
-
-void IosSalFrame::SetParent( SalFrame* pNewParent )
-{
- bool bShown = mbShown;
- // remove from child list
- Show( FALSE );
- mpParent = (IosSalFrame*)pNewParent;
- // insert to correct parent and paint
- Show( bShown );
-}
-
-void IosSalFrame::UpdateFrameGeometry()
-{
- if ( !mpWindow )
- {
- return;
- }
-
- // keep in mind that view and window coordinates are lower left
- // whereas vcl's are upper left
-
-#if 0 // ???
- // update screen rect
- NSScreen * pScreen = [mpWindow screen];
- if( pScreen )
- {
- maScreenRect = [pScreen frame];
- NSArray* pScreens = [NSScreen screens];
- if( pScreens )
- maGeometry.nDisplayScreenNumber = [pScreens indexOfObject: pScreen];
- }
-
- CGRect aFrameRect = [mpWindow frame];
-
- CGRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask];
-
- // release old track rect
- [mpView removeTrackingRect: mnTrackingRectTag];
- // install the new track rect
- CGRect aTrackRect = { { 0, 0 }, aContentRect.size };
- mnTrackingRectTag = [mpView addTrackingRect: aTrackRect owner: mpView userData: nil assumeInside: NO];
-
- // convert to vcl convention
- CocoaTouchToVCL( aFrameRect );
- CocoaTouchToVCL( aContentRect );
-
- maGeometry.nX = static_cast<int>(aContentRect.origin.x);
- maGeometry.nY = static_cast<int>(aContentRect.origin.y);
-
- maGeometry.nLeftDecoration = static_cast<unsigned int>(aContentRect.origin.x - aFrameRect.origin.x);
- maGeometry.nRightDecoration = static_cast<unsigned int>((aFrameRect.origin.x + aFrameRect.size.width) -
- (aContentRect.origin.x + aContentRect.size.width));
-
- maGeometry.nTopDecoration = static_cast<unsigned int>(aContentRect.origin.y - aFrameRect.origin.y);
- maGeometry.nBottomDecoration = static_cast<unsigned int>((aFrameRect.origin.y + aFrameRect.size.height) -
- (aContentRect.origin.y + aContentRect.size.height));
-
- maGeometry.nWidth = static_cast<unsigned int>(aContentRect.size.width);
- maGeometry.nHeight = static_cast<unsigned int>(aContentRect.size.height);
-#endif
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalFrame::CaptureMouse( sal_Bool bCapture )
-{
- /* Remark:
- we'll try to use a pidgin version of capture mouse
- on MacOSX (neither carbon nor cocoa) there is a
- CaptureMouse equivalent (in Carbon there is TrackMouseLocation
- but this is useless to use since it is blocking)
-
- However on cocoa the active frame seems to get mouse events
- also outside the window, so we'll try to forward mouse events
- to the capture frame in the hope that one of our frames
- gets a mouse event.
-
- This will break as soon as the user activates another app, but
- a mouse click will normally lead to a release of the mouse anyway.
-
- Let's see how far we get this way. Alternatively we could use one
- large overlay window like we did for the carbon implementation,
- however that is resource intensive.
- */
-
- if( bCapture )
- s_pCaptureFrame = this;
- else if( ! bCapture && s_pCaptureFrame == this )
- s_pCaptureFrame = NULL;
-}
-
-void IosSalFrame::ResetClipRegion()
-{
- if ( !mpWindow )
- {
- return;
- }
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- // release old path and indicate no clipping
- CGPathRelease( mrClippingPath );
- mrClippingPath = NULL;
-
- if( mpWindow )
- {
- [mpWindow setOpaque: YES];
- }
-}
-
-void IosSalFrame::BeginSetClipRegion( sal_uLong nRects )
-{
- if ( !mpWindow )
- {
- return;
- }
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- // release old path
- if( mrClippingPath )
- {
- CGPathRelease( mrClippingPath );
- mrClippingPath = NULL;
- }
-
- if( maClippingRects.size() > SAL_CLIPRECT_COUNT && nRects < maClippingRects.size() )
- {
- std::vector<CGRect> aEmptyVec;
- maClippingRects.swap( aEmptyVec );
- }
- maClippingRects.clear();
- maClippingRects.reserve( nRects );
-}
-
-void IosSalFrame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
-{
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- if( nWidth && nHeight )
- {
- CGRect aRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nWidth), static_cast<CGFloat>(nHeight) } };
- VCLToCocoaTouch( aRect, false );
- maClippingRects.push_back( CGRectMake(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height) );
- }
-}
-
-void IosSalFrame::EndSetClipRegion()
-{
- if ( !mpWindow )
- {
- return;
- }
-
- // #i113170# may not be the main thread if called from UNO API
- SalData::ensureThreadAutoreleasePool();
-
- if( ! maClippingRects.empty() )
- {
- mrClippingPath = CGPathCreateMutable();
- CGPathAddRects( mrClippingPath, NULL, &maClippingRects[0], maClippingRects.size() );
- }
- if( mpWindow )
- {
- [mpWindow setOpaque: (mrClippingPath != NULL) ? NO : YES];
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/window/salframeview.mm b/vcl/ios/source/window/salframeview.mm
deleted file mode 100644
index 0ca3441fe814..000000000000
--- a/vcl/ios/source/window/salframeview.mm
+++ /dev/null
@@ -1,263 +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 <sal/alloca.h>
-#include <sal/macros.h>
-
-#include "vcl/window.hxx"
-#include "vcl/svapp.hxx"
-
-#include "ios/salinst.h"
-#include "coretext/salgdi.h"
-#include "ios/salframe.h"
-#include "ios/salframeview.h"
-
-#define WHEEL_EVENT_FACTOR 1.5
-
-@implementation SalFrameWindow
--(id)initWithSalFrame: (IosSalFrame*)pFrame
-{
- mpFrame = pFrame;
-#if 0
- CGRect aRect = { { pFrame->maGeometry.nX, pFrame->maGeometry.nY },
- { pFrame->maGeometry.nWidth, pFrame->maGeometry.nHeight } };
- NSWindow* pNSWindow = [super initWithContentRect: aRect styleMask: mpFrame->getStyleMask() backing: NSBackingStoreBuffered defer: NO ];
- [pNSWindow useOptimizedDrawing: YES]; // OSX recommendation when there are no overlapping subviews within the receiver
- return pNSWindow;
-#endif
- return nil;
-}
-
--(IosSalFrame*)getSalFrame
-{
- return mpFrame;
-}
-
--(void)displayIfNeeded
-{
- if( GetSalData() && GetSalData()->mpFirstInstance )
- {
- osl::SolarMutex* pMutex = GetSalData()->mpFirstInstance->GetYieldMutex();
- if( pMutex )
- {
- pMutex->acquire();
- // ??? [super displayIfNeeded];
- pMutex->release();
- }
- }
-}
-
--(BOOL)canBecomeKeyWindow
-{
- if( (mpFrame->mnStyle &
- ( SAL_FRAME_STYLE_FLOAT |
- SAL_FRAME_STYLE_TOOLTIP |
- SAL_FRAME_STYLE_INTRO
- )) == 0 )
- return YES;
- if( (mpFrame->mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) != 0 )
- return YES;
- if( (mpFrame->mnStyle & SAL_FRAME_STYLE_FLOAT_FOCUSABLE) )
- return YES;
- // ??? return [super canBecomeKeyWindow];
- return NO;
-}
-
--(void)windowDidBecomeKey: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
-#if 0
- static const sal_uLong nGuessDocument = SAL_FRAME_STYLE_MOVEABLE|
- SAL_FRAME_STYLE_SIZEABLE|
- SAL_FRAME_STYLE_CLOSEABLE;
-#endif
- mpFrame->CallCallback( SALEVENT_GETFOCUS, 0 );
- mpFrame->SendPaintEvent(); // repaint controls as active
- }
-}
-
--(void)windowDidResignKey: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
- mpFrame->CallCallback(SALEVENT_LOSEFOCUS, 0);
- mpFrame->SendPaintEvent(); // repaint controls as inactive
- }
-}
-
--(void)windowDidChangeScreen: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- mpFrame->screenParametersChanged();
-}
-
--(void)windowDidMove: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
- mpFrame->UpdateFrameGeometry();
- mpFrame->CallCallback( SALEVENT_MOVE, 0 );
- }
-}
-
--(void)windowDidResize: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
- mpFrame->UpdateFrameGeometry();
- mpFrame->CallCallback( SALEVENT_RESIZE, 0 );
- mpFrame->SendPaintEvent();
- }
-}
-
--(void)windowDidMiniaturize: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
- mpFrame->mbShown = false;
- mpFrame->UpdateFrameGeometry();
- mpFrame->CallCallback( SALEVENT_RESIZE, 0 );
- }
-}
-
--(void)windowDidDeminiaturize: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
- mpFrame->mbShown = true;
- mpFrame->UpdateFrameGeometry();
- mpFrame->CallCallback( SALEVENT_RESIZE, 0 );
- }
-}
-
--(BOOL)windowShouldClose: (NSNotification*)pNotification
-{
- (void)pNotification;
- YIELD_GUARD;
-
- BOOL bRet = YES;
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
- // #i84461# end possible input
- mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 );
- if( IosSalFrame::isAlive( mpFrame ) )
- {
- mpFrame->CallCallback( SALEVENT_CLOSE, 0 );
- bRet = NO; // application will close the window or not, AppKit shouldn't
- }
- }
-
- return bRet;
-}
-
-@end
-
-@implementation SalFrameView
-
--(id)initWithSalFrame: (IosSalFrame*)pFrame
-{
- // ???
-
- (void) pFrame;
- mfLastMagnifyTime = 0.0;
- return self;
-}
-
--(IosSalFrame*)getSalFrame
-{
- return mpFrame;
-}
-
--(BOOL)acceptsFirstResponder
-{
- return YES;
-}
-
--(BOOL)isOpaque
-{
- return mpFrame ? (mpFrame->getClipPath() != 0 ? NO : YES) : YES;
-}
-
-// helper class similar to a osl::SolarGuard for the SalYieldMutex
-// the difference is that it only does tryToAcquire instead of aquire
-// so dreaded deadlocks like #i93512# are prevented
-class TryGuard
-{
-public:
- TryGuard() { mbGuarded = ImplSalYieldMutexTryToAcquire(); }
- ~TryGuard() { if( mbGuarded ) ImplSalYieldMutexRelease(); }
- bool IsGuarded() { return mbGuarded; }
-private:
- bool mbGuarded;
-};
-
--(void)drawRect: (CGRect)aRect
-{
- // HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex
- TryGuard aTryGuard;
- if( !aTryGuard.IsGuarded() )
- {
- // NOTE: the mpFrame access below is not guarded yet!
- // TODO: mpFrame et al need to be guarded by an independent mutex
- QuartzSalGraphics* pGraphics = (mpFrame && IosSalFrame::isAlive(mpFrame)) ? mpFrame->mpGraphics : NULL;
- if( pGraphics )
- {
- pGraphics->RefreshRect( aRect );
- }
- return;
- }
-
- if( mpFrame && IosSalFrame::isAlive( mpFrame ) )
- {
- if( mpFrame->mpGraphics )
- {
- mpFrame->mpGraphics->UpdateWindow( aRect );
- if( mpFrame->getClipPath() ) {
- // ??? [mpFrame->getWindow() invalidateShadow];
- }
- }
- }
-}
-
-@end
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/window/salmenu.cxx b/vcl/ios/source/window/salmenu.cxx
deleted file mode 100644
index 50c262e25713..000000000000
--- a/vcl/ios/source/window/salmenu.cxx
+++ /dev/null
@@ -1,62 +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 "rtl/ustrbuf.hxx"
-
-#include "vcl/cmdevt.hxx"
-#include "vcl/floatwin.hxx"
-#include "vcl/window.hxx"
-#include "vcl/svapp.hxx"
-
-#include "ios/saldata.hxx"
-#include "ios/salinst.h"
-#include "ios/salmenu.h"
-#include "ios/salframe.h"
-
-#include "svids.hrc"
-#include "window.h"
-
-// =======================================================================
-
-SalMenu* IosSalInstance::CreateMenu( sal_Bool /*bMenuBar*/, Menu* /*pVCLMenu*/ )
-{
- // ???
- return NULL;
-}
-
-void IosSalInstance::DestroyMenu( SalMenu* pSalMenu )
-{
- delete pSalMenu;
-}
-
-SalMenuItem* IosSalInstance::CreateMenuItem( const SalItemParams* /*pItemData*/ )
-{
- // ???
- return NULL;
-}
-
-void IosSalInstance::DestroyMenuItem( SalMenuItem* pSalMenuItem )
-{
- delete pSalMenuItem;
-}
-
-
-// =======================================================================
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/window/salobj.cxx b/vcl/ios/source/window/salobj.cxx
deleted file mode 100644
index 6543f4c26ed9..000000000000
--- a/vcl/ios/source/window/salobj.cxx
+++ /dev/null
@@ -1,201 +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 <string.h>
-
-#include "ios/saldata.hxx"
-#include "ios/salobj.h"
-#include "ios/salframe.h"
-
-// =======================================================================
-
-IosSalObject::IosSalObject( IosSalFrame* pFrame ) :
- mpFrame( pFrame ),
- mnClipX( -1 ),
- mnClipY( -1 ),
- mnClipWidth( -1 ),
- mnClipHeight( -1 ),
- mbClip( false ),
- mnX( 0 ),
- mnY( 0 ),
- mnWidth( 20 ),
- mnHeight( 20 )
-{
- maSysData.nSize = sizeof( maSysData );
- maSysData.pView = NULL;
-
- CGRect aInitFrame = { { 0, 0 }, { 20, 20 } };
- maSysData.pView = [[UIView alloc] initWithFrame: aInitFrame];
-}
-
-// -----------------------------------------------------------------------
-
-IosSalObject::~IosSalObject()
-{
- if( maSysData.pView )
- {
- UIView *pView = maSysData.pView;
- [pView removeFromSuperview];
- [pView release];
- }
-#if 0 // ???
- if( mpClipView )
- {
- [mpClipView removeFromSuperview];
- [mpClipView release];
- }
-#endif
-}
-
-/*
- sadly there seems to be no way to impose clipping on a child view,
- especially a QTMovieView which seems to ignore the current context
- completely. Also there is no real way to shape a window; on Ios a
- similar effect to non-rectangular windows is achieved by using a
- non-opaque window and not painting where one wants the background
- to shine through.
-
- With respect to SalObject this leaves us to having an NSClipView
- containing the child view. Even a QTMovieView respects the boundaries of
- that, which gives us a clip "region" consisting of one rectangle.
- This is gives us an 80% solution only, though.
-*/
-
-// -----------------------------------------------------------------------
-
-void IosSalObject::ResetClipRegion()
-{
- mbClip = false;
- setClippedPosSize();
-}
-
-// -----------------------------------------------------------------------
-
-sal_uInt16 IosSalObject::GetClipRegionType()
-{
- return SAL_OBJECT_CLIP_INCLUDERECTS;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalObject::BeginSetClipRegion( sal_uLong )
-{
- mbClip = false;
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
-{
- if( mbClip )
- {
- if( nX < mnClipX )
- {
- mnClipWidth += mnClipX - nX;
- mnClipX = nX;
- }
- if( nX + nWidth > mnClipX + mnClipWidth )
- mnClipWidth = nX + nWidth - mnClipX;
- if( nY < mnClipY )
- {
- mnClipHeight += mnClipY - nY;
- mnClipY = nY;
- }
- if( nY + nHeight > mnClipY + mnClipHeight )
- mnClipHeight = nY + nHeight - mnClipY;
- }
- else
- {
- mnClipX = nX;
- mnClipY = nY;
- mnClipWidth = nWidth;
- mnClipHeight = nHeight;
- mbClip = true;
- }
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalObject::EndSetClipRegion()
-{
- setClippedPosSize();
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight )
-{
- mnX = nX;
- mnY = nY;
- mnWidth = nWidth;
- mnHeight = nHeight;
- setClippedPosSize();
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalObject::setClippedPosSize()
-{
- CGRect aViewRect = { { 0, 0 }, { static_cast<CGFloat>(mnWidth), static_cast<CGFloat>(mnHeight) } };
- if( maSysData.pView )
- {
- UIView *pView = maSysData.pView;
- [pView setFrame: aViewRect];
- }
-
- CGRect aClipViewRect = { { static_cast<CGFloat>(mnX), static_cast<CGFloat>(mnY) }, { static_cast<CGFloat>(mnWidth), static_cast<CGFloat>(mnHeight) } };
- CGPoint aClipPt = { 0, 0 };
- if( mbClip )
- {
- aClipViewRect.origin.x += mnClipX;
- aClipViewRect.origin.y += mnClipY;
- aClipViewRect.size.width = mnClipWidth;
- aClipViewRect.size.height = mnClipHeight;
- aClipPt.x = mnClipX;
- if( mnClipY == 0 )
- aClipPt.y = mnHeight - mnClipHeight;
- }
-
- mpFrame->VCLToCocoaTouch( aClipViewRect, false );
-#if 0 // ???
- [mpClipView setFrame: aClipViewRect];
-
- [mpClipView scrollToPoint: aClipPt];
-#endif
-}
-
-// -----------------------------------------------------------------------
-
-void IosSalObject::Show( sal_Bool /*bVisible*/ )
-{
-#if 0 // ???
- if( mpClipView )
- [mpClipView setHidden: (bVisible ? NO : YES)];
-#endif
-}
-
-// -----------------------------------------------------------------------
-
-const SystemEnvData* IosSalObject::GetSystemData() const
-{
- return &maSysData;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */