diff options
Diffstat (limited to 'vcl/os2/source/app')
-rw-r--r-- | vcl/os2/source/app/makefile.mk | 56 | ||||
-rw-r--r-- | vcl/os2/source/app/printf.c | 287 | ||||
-rw-r--r-- | vcl/os2/source/app/salinfo.cxx | 164 | ||||
-rw-r--r-- | vcl/os2/source/app/salinst.cxx | 859 | ||||
-rw-r--r-- | vcl/os2/source/app/sallang.cxx | 74 | ||||
-rw-r--r-- | vcl/os2/source/app/salshl.cxx | 125 | ||||
-rw-r--r-- | vcl/os2/source/app/saltimer.cxx | 142 |
7 files changed, 0 insertions, 1707 deletions
diff --git a/vcl/os2/source/app/makefile.mk b/vcl/os2/source/app/makefile.mk deleted file mode 100644 index 9f3bfd7e89d8..000000000000 --- a/vcl/os2/source/app/makefile.mk +++ /dev/null @@ -1,56 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=SV -TARGET=salapp - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile2.pmk - -# --- Files -------------------------------------------------------- - -YD00_CXXFILES=\ - salshl.cxx \ - salinst.cxx \ - sallang.cxx \ - saltimer.cxx \ - salsys.cxx - -SLOFILES= $(SLO)$/salshl.obj \ - $(SLO)$/printf.obj \ - $(SLO)$/salinfo.obj \ - $(SLO)$/salinst.obj \ - $(SLO)$/sallang.obj \ - $(SLO)$/saltimer.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/vcl/os2/source/app/printf.c b/vcl/os2/source/app/printf.c deleted file mode 100644 index 06e75b6b8446..000000000000 --- a/vcl/os2/source/app/printf.c +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ----------------------------------------------------------------- */ -/* PRINTF: diverts PRINTF calls to an OS/2 Named Queue */ -/* Copyright (c) IBM Corporation, 1991, 1992 */ -/* ----------------------------------------------------------------- */ -/* This version for OS/2 2.x, 32-bit programs. Mike Cowlishaw */ -/* */ -/* This routine, when linked into an .EXE instead of the usual C */ -/* runtime, sends the edited result string to a named queue (if */ -/* it exists). If the queue does not exist, then all printf data */ -/* are discarded (ignored). */ -/* */ -/* The result string is accumulated until a line feed (LF) character */ -/* is received; the whole line is then sent to the queue. Lines are */ -/* automatically broken at a set (tailorable) length, if necessary. */ -/* */ -/* This routine may be tailored by altering the #defines at the */ -/* top: */ -/* */ -/* PRINTFID - An ID string that is prefixed to each line of */ -/* data before being sent to the queue. This */ -/* can be any string, or the null string. */ -/* PRINTFMAXLEN - Maximum length of string that can be formatted */ -/* in a single call. */ -/* Results are unpredictable if this length is */ -/* exceeded. Default is 250. */ -/* PRINTFLINELEN - Maximum length of a line that will be sent. */ -/* This excludes the prefix and its blank. If the */ -/* calls to printf cause a line to be generated */ -/* that is longer than this, the line will be */ -/* broken at this point. */ -/* PRINTFTHREADS - Maximum number of threads expected. This may */ -/* need to be increased if the process limitation */ -/* is removed, or you can save a little storage */ -/* by decreasing it. PRINTFs from threads larger */ -/* than this number are ignored. */ -/* PRINTFQNAME - The name of the public queue that the result */ -/* is to be sent to. Normally '\QUEUES\PRINTF32'. */ -/* Note that the \QUEUES\ part is required. */ -/* */ -/* Returns: */ -/* n: Count of data characters, if successfully received */ -/* 0: If no queue existed (i.e., no server) */ -/* <0: An error occurred (e.g., out of memory) */ -/* */ -/* Restrictions: */ -/* 1. Total length of data (length of PRINTFID, + PRINTFMAXLEN) */ -/* must be less than 32K-1. */ -/* 2. This has only been tested under IBM C Set/2 compiler. It */ -/* may need modification for other compilers. */ -/* 3. This version uses a static array to point to the per-thread */ -/* data. The code could be made read-only by hanging this */ -/* array (and the other static information) off a system-owned */ -/* anchor of some kind. */ -/* 4. To use PRINTF within other than the main thread in a */ -/* program, that thread must be started with _beginthread */ -/* (not DosCreateThread). This restriction is a consequence of */ -/* the use of C library routines (sprintf) in PRINTF, and may */ -/* not apply to all compilers. */ -/* 5. If the last PRINTF done by a thread does not end in '\n' */ -/* then the final part-line may be lost, or appear later. */ -/* */ -/* Protocol: */ -/* PRINTF writes its data to the named queue using the following */ -/* protocol: */ -/* Address -- Holds the address of the string to be sent. This */ -/* is a 0-terminated string) starting at offset 0. */ -/* Length -- The length of the data, including terminator. */ -/* A negative length indicates a BELL in the data. */ -/* Request -- Timestamp (when queue was written) in C long */ -/* integer format (as returned by time()). */ -/* This may be 0L if not required. */ -/* */ -/* Notes: */ -/* 1. PMPRINTF uses a queue and shared memory messages because: */ -/* (a) It makes collection at the receiving end very easy. */ -/* (b) I wanted to experiment with queues and shared memory. */ -/* This make not be the most cost-effective method. */ -/* 2. Typical IBM C Set/2 compiler invocation: */ -/* icc /c /Gm /O+ /Q /J /Kabgop */ -/* If you get linking errors (duplicate symbols, etc.), try */ -/* recompiling PRINTF.C with the same options as you use for */ -/* your main program. */ -/* 3. PRINTF sends the timestamp across the queue as a GMT long */ -/* integer, the result from a call to the C function time(). */ -/* This will only be correct if the environment variable TZ has */ -/* been set (e.g., TZ=EST5EDT), or you are in the same time */ -/* zone as the default for your compiler. */ -/* For more information, see the tzset() function description */ -/* in your C compiler manual. */ - -/* ----- Customization variables ----- */ -#define PRINTFID "" -#define PRINTFMAXLEN 300 -#define PRINTFLINELEN 100 -#define PRINTFTHREADS 54 -#define PRINTFQNAME "\\QUEUES\\PRINTF32" - -/* ----- Includes and externals ----- */ -#include <stdlib.h> /* standard C functions */ -#include <stddef.h> /* .. */ -#include <string.h> /* .. */ -#include <time.h> /* .. */ -#include <stdarg.h> /* .. */ -#include <stdio.h> /* (needed to pick up real name) */ -#define INCL_DOS /* Operating system definitions */ -#include <os2.h> /* For OS/2 functions */ - -#define max(a,b) (a>b ? a : b) - -/* ----- Local defines ----- */ -#define PRINTFIDSIZE sizeof(PRINTFID) -#define PRINTFMAXBUF PRINTFIDSIZE+PRINTFLINELEN - -/* ----- Per-thread output buffer and current indices into line ---- */ -struct perthread { - LONG lineindex; /* where next char */ - LONG tidemark; /* rightmost char */ - int bell; /* TRUE if line has bell */ - UCHAR line[PRINTFMAXBUF]; /* accumulator */ - }; - -/* ----- Local static variables ----- */ -static ULONG ourpid=0; /* our process ID */ -static ULONG servepid=0; /* process IDs of the server */ -static HQUEUE qhandle=0; /* handle for the queue */ -static struct perthread *tps[PRINTFTHREADS+1]; /* -> per-thread data */ - -/* ----- Local subroutine ----- */ -static int printf_(struct perthread *); - -/* ----------------------------------------------------------------- */ -/* The "printf" function. Note this has a variable number of */ -/* arguments. */ -/* ----------------------------------------------------------------- */ -int debug_printf(const char *f, ...) - { - TIB *ptib; /* process/thread id structures */ - PIB *ppib; /* .. */ - TID ourtid; /* thread ID */ - struct perthread *tp; /* pointer to per-thread data */ - int rc; /* returncode */ - ULONG urc; /* returncode */ - - urc=DosOpenQueue(&servepid, &qhandle, PRINTFQNAME); /* Open the Q */ - /* Non-0 RC means Q does not exist or cannot be opened */ - if (urc==343) return 0; /* queue does not exist, so quit */ - if (urc!=0) return -1; /* report any other error */ - - /* First determine our thread ID (and hence get access to the */ - /* correct per-thread data. If the per-thread data has not been */ - /* allocated, then allocate it now. It is never freed, once */ - /* allocated, as PRINTF is not notified of end-of-thread. */ - DosGetInfoBlocks(&ptib,&ppib); /* get process/thread info */ - ourtid=ptib->tib_ptib2->tib2_ultid; /* .. and copy TID */ - if (ourtid>PRINTFTHREADS) /* too many threads .. */ - return 0; /* .. so quit, quietly */ - tp=tps[ourtid]; /* copy to local pointer */ - if (tp==NULL) { /* uninitialized (NULL=0) */ - /* allocate a per-thread structure */ - tp=(struct perthread *)malloc(sizeof(struct perthread)); - if (tp==NULL) return -1; /* out of memory -- return error */ - tps[ourtid]=tp; /* save for future calls */ - strcpy(tp->line,PRINTFID); /* initialize: line.. */ - tp->lineindex=PRINTFIDSIZE-1; /* ..where next char */ - tp->tidemark =PRINTFIDSIZE-2; /* ..rightmost char */ - tp->bell=FALSE; /* ..if line has bell */ - if (ourpid==0) ourpid=ppib->pib_ulpid; /* save PID for all to use */ - } - - { /* Block for declarations -- only needed if queue exists, etc. */ - LONG count; /* count of characters formatted */ - UCHAR buffer[PRINTFMAXLEN+1]; /* formatting area */ - LONG i, newind; /* work */ - UCHAR ch; /* .. */ - va_list argptr; /* -> variable argument list */ - - va_start(argptr, f); /* get pointer to argument list */ - count=vsprintf(buffer, f, argptr); - va_end(argptr); /* done with variable arguments */ - - if (count<0) return count-1000;/* bad start */ - - if (count>PRINTFMAXLEN) { - /* Disaster -- we are probably "dead", but just in case we */ - /* are not, carry on with truncated data. */ - count=PRINTFMAXLEN; - } - buffer[count]='\0'; /* ensure terminated */ - /* OK, ready to go with the data now in BUFFER */ - /* We copy from the formatted string to the output (line) buffer, */ - /* taking note of certain control characters and sending a line */ - /* the queue whenever we see a LF control, or when the line */ - /* fills (causing a forced break). */ - for (i=0; ; i++) { - ch=buffer[i]; if (!ch) break; - switch(ch) { - case '\r': /* carriage return */ - tp->lineindex=PRINTFIDSIZE-1; /* back to start of line */ - break; - case '\n': /* new line */ - case '\f': /* form feed */ - rc=printf_(tp); /* print a line */ - if (rc!=0) return rc; /* error */ - break; - case '\t': /* tab */ - newind=tp->lineindex-PRINTFIDSIZE+1; /* offset into data */ - newind=tp->lineindex+5-newind%5; /* new index requested */ - if (newind>=PRINTFMAXBUF) newind=PRINTFMAXBUF; /* clamp */ - for (; tp->lineindex<newind; tp->lineindex++) { - if (tp->lineindex>tp->tidemark) { /* beyond current end */ - tp->line[tp->lineindex]=' '; /* add space */ - tp->tidemark=tp->lineindex; - } - } - break; - case '\v': /* vertical tab */ - /* ignore it */ - break; - case '\b': /* backspace */ - tp->lineindex=max(tp->lineindex-1,PRINTFIDSIZE); - break; - case '\a': /* alert (bell) */ - tp->bell=TRUE; - break; - default: /* ordinary character */ - tp->line[tp->lineindex]=ch; - if (tp->lineindex>tp->tidemark) /* is rightmost.. */ - tp->tidemark=tp->lineindex; - tp->lineindex++; /* step for next */ - } /* switch */ - if (tp->lineindex>=PRINTFMAXBUF) { - rc=printf_(tp); /* print a line */ - if (rc!=0) return rc; /* error */ - } - - } /* copy loop */ - return count; /* all formatted data processed */ - } /* block */ - } /* printf */ - -/* ----- printf_(tp) -- Local subroutine to send a line ------------ */ -/* A line has been completed (or overflowed): write it to the queue. */ -int printf_(struct perthread *tp) /* pointer to per-thread data */ - { - ULONG urc; /* unsigned returncode */ - PSZ pszTo, pszFrom; /* character pointers */ - PVOID addr; /* address of output data */ - long size; /* total size of output data */ - time_t timenow; /* holds current time */ - - tp->line[tp->tidemark+1]='\0'; /* add terminator */ - size=tp->tidemark+2; /* total length of data */ - - /* Get some shared memory that can be given away */ - urc=DosAllocSharedMem(&addr, NULL, (unsigned)size, - OBJ_GIVEABLE|PAG_WRITE|PAG_COMMIT); - if (urc!=0) return -2; /* error */ - - pszTo=addr; /* copy for clarity */ - pszFrom=&(tp->line[0]); /* pointer to source */ - strcpy(pszTo,pszFrom); /* copy the string to shared memory */ - - if (ourpid!=servepid) { /* (no giveaway needed if to self) */ - urc=DosGiveSharedMem(addr, servepid, PAG_READ); /* give access */ - if (urc!=0) return -3;} /* error */ - - /* Write the selector, size, and timestamp to the queue */ - if (tp->bell) size=-size; /* BELL passed by negation */ - time(&timenow); /* optional - else use 0 */ - urc=DosWriteQueue(qhandle, /* handle */ - (unsigned)timenow, /* 'request' (timestamp) */ - (unsigned)size, /* 'length' (length/bell) */ - addr, /* 'address' (address) */ - 0); /* priority (FIFO if enabled) */ - if (urc!=0) return -4; /* error */ - if (ourpid!=servepid) { /* if given away.. */ - urc=DosFreeMem(addr); /* .. *we* are done with it */ - if (urc!=0) return -5;} /* error */ - /* Reset the line buffer and indices */ - tp->lineindex=PRINTFIDSIZE-1; /* where next char */ - tp->tidemark =PRINTFIDSIZE-2; /* rightmost char */ - tp->bell =FALSE; /* true if line has bell */ - return 0; /* success! */ - } /* printf_ */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/os2/source/app/salinfo.cxx b/vcl/os2/source/app/salinfo.cxx deleted file mode 100644 index 08ca8b031982..000000000000 --- a/vcl/os2/source/app/salinfo.cxx +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define INCL_PM -#define INCL_DOS -#define INCL_GPI -#include <svpm.h> - -#include <tools/string.hxx> -#include <salsys.h> -#include <salframe.h> -#include <salinst.h> -#include "saldata.hxx" -#include <tools/debug.hxx> -#include <vcl/svdata.hxx> -#include <rtl/ustrbuf.hxx> -#include "vcl/window.hxx" - -#define CHAR_POINTER(THE_OUSTRING) ::rtl::OUStringToOString (THE_OUSTRING, RTL_TEXTENCODING_UTF8).pData->buffer - -class Os2SalSystem : public SalSystem -{ -public: - Os2SalSystem() {} - virtual ~Os2SalSystem(); - - virtual unsigned int GetDisplayScreenCount(); - virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ); - //virtual bool GetSalSystemDisplayInfo( DisplayInfo& rInfo ); - - virtual bool IsMultiDisplay(); - virtual unsigned int GetDefaultDisplayNumber(); - virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen ); - virtual rtl::OUString GetScreenName( unsigned int nScreen ); - - virtual int ShowNativeMessageBox( const String& rTitle, - const String& rMessage, - int nButtonCombination, - int nDefaultButton); -}; - -SalSystem* Os2SalInstance::CreateSalSystem() -{ - return new Os2SalSystem(); -} - -Os2SalSystem::~Os2SalSystem() -{ -} - -// ----------------------------------------------------------------------- - -unsigned int Os2SalSystem::GetDisplayScreenCount() -{ - return 1; -} - -Rectangle Os2SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen ) -{ - Rectangle aRet; - aRet = Rectangle( Point(), Point( WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ), - WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) ) ); - return aRet; -} - -// ----------------------------------------------------------------------- -/* We have to map the button identifier to the identifier used by the Os232 - Platform SDK to specify the default button for the MessageBox API. - The first dimension is the button combination, the second dimension - is the button identifier. -*/ -static int DEFAULT_BTN_MAPPING_TABLE[][8] = -{ - // Undefined OK CANCEL ABORT RETRY IGNORE YES NO - { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //OK - { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //OK_CANCEL - { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3, MB_DEFBUTTON1, MB_DEFBUTTON1 }, //ABORT_RETRY_IGNO - { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON3, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2 }, //YES_NO_CANCEL - { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2 }, //YES_NO - { MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1, MB_DEFBUTTON1 } //RETRY_CANCEL -}; - -static int COMBI_BTN_MAPPING_TABLE[] = -{ - MB_OK, MB_OKCANCEL, MB_ABORTRETRYIGNORE, MB_YESNO, MB_YESNOCANCEL, MB_RETRYCANCEL -}; - -int Os2SalSystem::ShowNativeMessageBox(const String& rTitle, const String& rMessage, int nButtonCombination, int nDefaultButton) -{ - DBG_ASSERT( nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK && - nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL && - nDefaultButton >= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK && - nDefaultButton <= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO, "Invalid arguments!" ); - - int nFlags = MB_APPLMODAL | MB_WARNING | COMBI_BTN_MAPPING_TABLE[nButtonCombination]; - - if (nButtonCombination >= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK && - nButtonCombination <= SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL && - nDefaultButton >= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK && - nDefaultButton <= SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO) - nFlags |= DEFAULT_BTN_MAPPING_TABLE[nButtonCombination][nDefaultButton]; - - //#107209 hide the splash screen if active - ImplSVData* pSVData = ImplGetSVData(); - if (pSVData->mpIntroWindow) - pSVData->mpIntroWindow->Hide(); - - return WinMessageBox( - HWND_DESKTOP, HWND_DESKTOP, - (PSZ)CHAR_POINTER(rMessage), - (PSZ)CHAR_POINTER(rTitle), - 0, nFlags); -} - - -unsigned int Os2SalSystem::GetDefaultDisplayNumber() -{ - return 0; -} - -bool Os2SalSystem::IsMultiDisplay() -{ - return false; -} - -Rectangle Os2SalSystem::GetDisplayWorkAreaPosSizePixel( unsigned int nScreen ) -{ - return GetDisplayScreenPosSizePixel( nScreen ); -} - -rtl::OUString Os2SalSystem::GetScreenName( unsigned int nScreen ) -{ - rtl::OUStringBuffer aBuf( 32 ); - aBuf.appendAscii( "VirtualScreen " ); - aBuf.append( sal_Int32(nScreen) ); - return aBuf.makeStringAndClear(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/os2/source/app/salinst.cxx b/vcl/os2/source/app/salinst.cxx deleted file mode 100644 index e4fd783ccb27..000000000000 --- a/vcl/os2/source/app/salinst.cxx +++ /dev/null @@ -1,859 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define INCL_DOSMISC -#define INCL_DOSMODULEMGR -#define INCL_DOSPROCESS - -#include <string.h> -#include <svpm.h> -#include <process.h> - -#define _SV_SALINST_CXX - -#include <vcl/solarmutex.hxx> -#include <tools/debug.hxx> - -#include <salids.hrc> -#include <vcl/apptypes.hxx> -#include <saldata.hxx> -#include <salinst.h> -#include <salframe.h> -#include <salobj.h> -#include <saltimer.h> -#include <salbmp.h> -#include <vcl/salimestatus.hxx> -#include <vcl/timer.hxx> -#include <tools/solarmutex.hxx> - -// ======================================================================= - -void SalAbort( const XubString& rErrorText ) -{ - ImplFreeSalGDI(); - - if( !rErrorText.Len() ) - fprintf( stderr, "Application Error " ); - else - fprintf( stderr, "%s ", - ByteString( rErrorText, gsl_getSystemTextEncoding() ).GetBuffer() ); - abort(); -} - -// ======================================================================= - -ULONG GetCurrentThreadId() -{ - PTIB pptib = NULL; - PPIB pppib = NULL; - - DosGetInfoBlocks( &pptib, &pppib ); - return pptib->tib_ptib2->tib2_ultid; -} - -// ======================================================================= - -MRESULT EXPENTRY SalComWndProc( HWND hWnd, ULONG nMsg, MPARAM nMP1, MPARAM nMP2 ); - -// ======================================================================= - -class SalYieldMutex : public vcl::SolarMutexObject -{ -public: - Os2SalInstance* mpInstData; - ULONG mnCount; - ULONG mnThreadId; - -public: - SalYieldMutex( Os2SalInstance* pInstData ); - - virtual void SAL_CALL acquire(); - virtual void SAL_CALL release(); - virtual sal_Bool SAL_CALL tryToAcquire(); - - ULONG GetAcquireCount( ULONG nThreadId ); -}; - -// ----------------------------------------------------------------------- - -SalYieldMutex::SalYieldMutex( Os2SalInstance* pInstData ) -{ - mpInstData = pInstData; - mnCount = 0; - mnThreadId = 0; -} - -// ----------------------------------------------------------------------- - -void SalYieldMutex::acquire() -{ - SolarMutexObject::acquire(); - mnCount++; - mnThreadId = GetCurrentThreadId(); -} - -// ----------------------------------------------------------------------- - -void SalYieldMutex::release() -{ - ULONG nThreadId = GetCurrentThreadId(); - if ( mnThreadId != nThreadId ) - SolarMutexObject::release(); - else - { - SalData* pSalData = GetSalData(); - if ( pSalData->mnAppThreadId != nThreadId ) - { - if ( mnCount == 1 ) - { - mpInstData->mpSalWaitMutex->acquire(); - if ( mpInstData->mnYieldWaitCount ) - WinPostMsg( mpInstData->mhComWnd, SAL_MSG_RELEASEWAITYIELD, 0, 0 ); - mnThreadId = 0; - mnCount--; - SolarMutexObject::release(); - mpInstData->mpSalWaitMutex->release(); - } - else - { - mnCount--; - SolarMutexObject::release(); - } - } - else - { - if ( mnCount == 1 ) - mnThreadId = 0; - mnCount--; - SolarMutexObject::release(); - } - } -} - -// ----------------------------------------------------------------------- - -sal_Bool SalYieldMutex::tryToAcquire() -{ - if ( SolarMutexObject::tryToAcquire() ) - { - mnCount++; - mnThreadId = GetCurrentThreadId(); - return sal_True; - } - else - return sal_False; -} - -// ----------------------------------------------------------------------- - -ULONG SalYieldMutex::GetAcquireCount( ULONG nThreadId ) -{ - if ( nThreadId == mnThreadId ) - return mnCount; - else - return 0; -} - -// ----------------------------------------------------------------------- - -void ImplSalYieldMutexAcquireWithWait() -{ - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( !pInst ) - return; - - // If we are the main thread, then we must wait with wait, because - // in if we don't reschedule, then we create deadlocks if a Windows - // Function is called from another thread. If we arn't the main thread, - // than we call qcquire directly. - ULONG nThreadId = GetCurrentThreadId(); - SalData* pSalData = GetSalData(); - if ( pSalData->mnAppThreadId == nThreadId ) - { - // Wenn wir den Mutex nicht bekommen, muessen wir solange - // warten, bis wir Ihn bekommen - BOOL bAcquire = FALSE; - do - { - if ( pInst->mpSalYieldMutex->tryToAcquire() ) - bAcquire = TRUE; - else - { - pInst->mpSalWaitMutex->acquire(); - if ( pInst->mpSalYieldMutex->tryToAcquire() ) - { - bAcquire = TRUE; - pInst->mpSalWaitMutex->release(); - } - else - { - pInst->mnYieldWaitCount++; - pInst->mpSalWaitMutex->release(); - QMSG aTmpMsg; - WinGetMsg( pSalData->mhAB, &aTmpMsg, pInst->mhComWnd, SAL_MSG_RELEASEWAITYIELD, SAL_MSG_RELEASEWAITYIELD ); - pInst->mnYieldWaitCount--; - if ( pInst->mnYieldWaitCount ) - WinPostMsg( pInst->mhComWnd, SAL_MSG_RELEASEWAITYIELD, 0 , 0 ); - } - } - } - while ( !bAcquire ); - } - else - pInst->mpSalYieldMutex->acquire(); -} - -// ----------------------------------------------------------------------- - -BOOL ImplSalYieldMutexTryToAcquire() -{ - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst ) - return pInst->mpSalYieldMutex->tryToAcquire(); - else - return FALSE; -} - -// ----------------------------------------------------------------------- - -void ImplSalYieldMutexAcquire() -{ - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst ) - pInst->mpSalYieldMutex->acquire(); -} - -// ----------------------------------------------------------------------- - -void ImplSalYieldMutexRelease() -{ - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst ) - pInst->mpSalYieldMutex->release(); -} - -// ----------------------------------------------------------------------- - -ULONG ImplSalReleaseYieldMutex() -{ - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( !pInst ) - return 0; - - SalYieldMutex* pYieldMutex = pInst->mpSalYieldMutex; - ULONG nCount = pYieldMutex->GetAcquireCount( GetCurrentThreadId() ); - ULONG n = nCount; - while ( n ) - { - pYieldMutex->release(); - n--; - } - - return nCount; -} - -// ----------------------------------------------------------------------- - -void ImplSalAcquireYieldMutex( ULONG nCount ) -{ - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( !pInst ) - return; - - SalYieldMutex* pYieldMutex = pInst->mpSalYieldMutex; - while ( nCount ) - { - pYieldMutex->acquire(); - nCount--; - } -} - -// ----------------------------------------------------------------------- - -bool Os2SalInstance::CheckYieldMutex() -{ - bool bRet = true; - SalData* pSalData = GetSalData(); - ULONG nCurThreadId = GetCurrentThreadId(); - if ( pSalData->mnAppThreadId != nCurThreadId ) - { - if ( pSalData->mpFirstInstance ) - { - SalYieldMutex* pYieldMutex = pSalData->mpFirstInstance->mpSalYieldMutex; - if ( pYieldMutex->mnThreadId != nCurThreadId ) - { - bRet = false; - } - } - } - else - { - if ( pSalData->mpFirstInstance ) - { - SalYieldMutex* pYieldMutex = pSalData->mpFirstInstance->mpSalYieldMutex; - if ( pYieldMutex->mnThreadId != nCurThreadId ) - { - bRet = false; - } - } - } - return bRet; -} - -// ======================================================================= - -void InitSalData() -{ - SalData* pSalData = new SalData; - memset( pSalData, 0, sizeof( SalData ) ); - SetSalData( pSalData ); -} - -// ----------------------------------------------------------------------- - -void DeInitSalData() -{ - SalData* pSalData = GetSalData(); - if ( pSalData->mpFontMetrics ) - delete pSalData->mpFontMetrics; - delete pSalData; - SetSalData( NULL ); -} - -// ----------------------------------------------------------------------- - -void InitSalMain() -{ - PPIB pib; - PTIB tib; - HAB hAB; - HMQ hMQ; - SalData* pData = GetAppSalData(); -#if OSL_DEBUG_LEVEL > 0 -printf("InitSalMain\n"); -#endif - - // morph application to PM - DosGetInfoBlocks(&tib, &pib); - // Change flag from VIO to PM: - if (pib->pib_ultype==2) pib->pib_ultype = 3; - - // create anchor block - hAB = WinInitialize( 0 ); - if ( !hAB ) - return; - - // create message queue - hMQ = WinCreateMsgQueue( hAB, 60 ); - if ( !hMQ ) - { - WinTerminate( hAB ); - return; - } - - if ( pData ) // Im AppServer NULL - { - // Ankerblock und Messagequeue merken - pData->mhAB = hAB; - pData->mhMQ = hMQ; - } - -} - -void DeInitSalMain() -{ -#if OSL_DEBUG_LEVEL > 0 -printf("DeInitSalMain\n"); -#endif - - SalData* pData = GetAppSalData(); - // destroy message queue and anchor block - WinDestroyMsgQueue( pData->mhMQ ); - WinTerminate( pData->mhAB ); - -} - -// ----------------------------------------------------------------------- - -SalInstance* CreateSalInstance() -{ - SalData* pSalData = GetSalData(); - - // determine the os2 version - ULONG nMayor; - ULONG nMinor; - DosQuerySysInfo( QSV_VERSION_MAJOR, QSV_VERSION_MAJOR, &nMayor, sizeof( nMayor ) ); - DosQuerySysInfo( QSV_VERSION_MINOR, QSV_VERSION_MINOR, &nMinor, sizeof( nMinor ) ); - aSalShlData.mnVersion = (USHORT)(nMayor*10 + nMinor); - - pSalData->mnAppThreadId = GetCurrentThreadId(); - - // register frame class - if ( !WinRegisterClass( pSalData->mhAB, (PSZ)SAL_FRAME_CLASSNAME, - (PFNWP)SalFrameWndProc, CS_MOVENOTIFY /* 17/08 CS_HITTEST | CS_MOVENOTIFY */, - SAL_FRAME_WNDEXTRA ) ) - { - return NULL; - } - // register subframe class - if ( !WinRegisterClass( pSalData->mhAB, (PSZ)SAL_SUBFRAME_CLASSNAME, - (PFNWP)SalFrameWndProc, CS_SAVEBITS| CS_MOVENOTIFY, - SAL_FRAME_WNDEXTRA ) ) - { - return NULL; - } - // register object class - if ( !WinRegisterClass( pSalData->mhAB, (PSZ)SAL_COM_CLASSNAME, - (PFNWP)SalComWndProc, 0, 0 )) - { - return NULL; - } - - HWND hComWnd = WinCreateWindow( HWND_OBJECT, (PCSZ)SAL_COM_CLASSNAME, - (PCSZ)"", 0, 0, 0, 0, 0, - HWND_OBJECT, HWND_TOP, - 222, NULL, NULL); - if ( !hComWnd ) - return NULL; - -#if OSL_DEBUG_LEVEL > 1 - debug_printf("CreateSalInstance hComWnd %x\n", hComWnd); -#endif - Os2SalInstance* pInst = new Os2SalInstance; - - // init instance (only one instance in this version !!!) - pSalData->mpFirstInstance = pInst; - pInst->mhAB = pSalData->mhAB; - pInst->mhMQ = pSalData->mhMQ; - pInst->mnArgc = pSalData->mnArgc; - pInst->mpArgv = pSalData->mpArgv; - pInst->mhComWnd = hComWnd; - - // AppIcon ermitteln - ImplLoadSalIcon( SAL_RESID_ICON_DEFAULT, pInst->mhAppIcon); - - // init static GDI Data - ImplInitSalGDI(); - - return pInst; -} - -// ----------------------------------------------------------------------- - -void DestroySalInstance( SalInstance* pInst ) -{ - SalData* pSalData = GetSalData(); - - // (only one instance in this version !!!) - ImplFreeSalGDI(); - -#ifdef ENABLE_IME - // IME-Daten freigeben - if ( pSalData->mpIMEData ) - ImplReleaseSALIMEData(); -#endif - - // reset instance - if ( pSalData->mpFirstInstance == pInst ) - pSalData->mpFirstInstance = NULL; - - delete pInst; -} - -// ----------------------------------------------------------------------- - -Os2SalInstance::Os2SalInstance() -{ - mhComWnd = 0; - mpSalYieldMutex = new SalYieldMutex( this ); - mpSalWaitMutex = new osl::Mutex; - mnYieldWaitCount = 0; - mpSalYieldMutex->acquire(); - ::tools::SolarMutex::SetSolarMutex( mpSalYieldMutex ); -} - -// ----------------------------------------------------------------------- - -Os2SalInstance::~Os2SalInstance() -{ - ::tools::SolarMutex::SetSolarMutex( 0 ); - mpSalYieldMutex->release(); - delete mpSalYieldMutex; - delete mpSalWaitMutex; - WinDestroyWindow( mhComWnd); -} - -// ----------------------------------------------------------------------- - -osl::SolarMutex* Os2SalInstance::GetYieldMutex() -{ - return mpSalYieldMutex; -} -// ----------------------------------------------------------------------- - -ULONG Os2SalInstance::ReleaseYieldMutex() -{ - return ImplSalReleaseYieldMutex(); -} - -// ----------------------------------------------------------------------- - -void Os2SalInstance::AcquireYieldMutex( ULONG nCount ) -{ - ImplSalAcquireYieldMutex( nCount ); -} - -// ----------------------------------------------------------------------- - -static void ImplSalYield( BOOL bWait, BOOL bHandleAllCurrentEvents ) -{ - QMSG aMsg; - bool bWasMsg = false, bOneEvent = false; - bool bQuit = false; - - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1; - do - { - if ( WinPeekMsg( pInst->mhAB, &aMsg, 0, 0, 0, PM_REMOVE ) ) - { - WinDispatchMsg( pInst->mhAB, &aMsg ); - bOneEvent = bWasMsg = true; - if (aMsg.msg == WM_QUIT) - bQuit = true; - } - else - bOneEvent = false; - } while( --nMaxEvents && bOneEvent ); - - if ( bWait && ! bWasMsg ) - { - if ( WinGetMsg( pInst->mhAB, &aMsg, 0, 0, 0 ) ) - WinDispatchMsg( pInst->mhAB, &aMsg ); - else - bQuit = true; - } - - if (bQuit) - { - ImplSalYieldMutexAcquireWithWait(); - Os2SalFrame* pFrame = GetSalData()->mpFirstFrame; - if ( pFrame ) - { - if (pFrame->CallCallback( SALEVENT_SHUTDOWN, 0 )) - WinCancelShutdown( pFrame->mhAB, FALSE ); - } - ImplSalYieldMutexRelease(); - } - -} - -// ----------------------------------------------------------------------- - -void Os2SalInstance::Yield( bool bWait, bool bHandleAllCurrentEvents ) -{ - SalYieldMutex* pYieldMutex = mpSalYieldMutex; - SalData* pSalData = GetSalData(); - ULONG nCurThreadId = GetCurrentThreadId(); - ULONG nCount = pYieldMutex->GetAcquireCount( nCurThreadId ); - ULONG n = nCount; - while ( n ) - { - pYieldMutex->release(); - n--; - } - if ( pSalData->mnAppThreadId != nCurThreadId ) - { - // #97739# A SendMessage call blocks until the called thread (here: the main thread) - // returns. During a yield however, messages are processed in the main thread that might - // result in a new message loop due to opening a dialog. Thus, SendMessage would not - // return which will block this thread! - // Solution: just give up the time slice and hope that messages are processed - // by the main thread anyway (where all windows are created) - // If the mainthread is not currently handling messages, then our SendMessage would - // also do nothing, so this seems to be reasonable. - - // #i18883# only sleep if potential deadlock scenario, ie, when a dialog is open - if( ImplGetSVData()->maAppData.mnModalMode ) - DosSleep(1); - else - WinSendMsg( mhComWnd, SAL_MSG_THREADYIELD, (MPARAM)bWait, (MPARAM)bHandleAllCurrentEvents ); - - n = nCount; - while ( n ) - { - pYieldMutex->acquire(); - n--; - } - } - else - { - ImplSalYield( bWait, bHandleAllCurrentEvents ); - - n = nCount; - while ( n ) - { - ImplSalYieldMutexAcquireWithWait(); - n--; - } - } -} - -// ----------------------------------------------------------------------- - -MRESULT EXPENTRY SalComWndProc( HWND hWnd, ULONG nMsg, - MPARAM nMP1, MPARAM nMP2 ) -{ - //debug_printf( "SalComWndProc hWnd 0x%x nMsg %d\n", hWnd, nMsg); - - switch ( nMsg ) - { - case SAL_MSG_PRINTABORTJOB: - //ImplSalPrinterAbortJobAsync( (HDC)wParam ); - break; - case SAL_MSG_THREADYIELD: - ImplSalYield( (bool)nMP1, (bool) nMP2); - return 0; - // If we get this message, because another GetMessage() call - // has recieved this message, we must post this message to - // us again, because in the other case we wait forever. - case SAL_MSG_RELEASEWAITYIELD: - { - Os2SalInstance* pInst = GetSalData()->mpFirstInstance; - if ( pInst && pInst->mnYieldWaitCount ) - WinPostMsg( hWnd, SAL_MSG_RELEASEWAITYIELD, nMP1, nMP2 ); - } - return 0; - case SAL_MSG_STARTTIMER: - ImplSalStartTimer( (ULONG)nMP2, FALSE); - return 0; - case SAL_MSG_CREATEFRAME: - return (MRESULT)ImplSalCreateFrame( GetSalData()->mpFirstInstance, (HWND)nMP2, (ULONG)nMP1 ); - case SAL_MSG_DESTROYFRAME: - delete (SalFrame*)nMP2; - return 0; - case SAL_MSG_DESTROYHWND: - //We only destroy the native window here. We do NOT destroy the SalFrame contained - //in the structure (GetWindowPtr()). - if (WinDestroyWindow((HWND)nMP2) == 0) - { - OSL_FAIL("DestroyWindow failed!"); - //Failure: We remove the SalFrame from the window structure. So we avoid that - // the window structure may contain an invalid pointer, once the SalFrame is deleted. - SetWindowPtr((HWND)nMP2, 0); - } - return 0; - case SAL_MSG_CREATEOBJECT: - return (MRESULT)ImplSalCreateObject( GetSalData()->mpFirstInstance, (Os2SalFrame*)(ULONG)nMP2 ); - case SAL_MSG_DESTROYOBJECT: - delete (SalObject*)nMP2; - return 0; - case SAL_MSG_CREATESOUND: - //return (MRESULT)((Os2SalSound*)nMP2)->ImplCreate(); - return 0; - case SAL_MSG_DESTROYSOUND: - //((Os2SalSound*)nMP2)->ImplDestroy(); - return 0; - case SAL_MSG_POSTTIMER: - SalTimerProc( 0, 0, SALTIMERPROC_RECURSIVE, (ULONG)nMP2 ); - break; - case WM_TIMER: - SalTimerProc( hWnd, 0, 0, 0 ); - break; - } - - return WinDefWindowProc( hWnd, nMsg, nMP1, nMP2 ); -} - -// ----------------------------------------------------------------------- - -bool Os2SalInstance::AnyInput( USHORT nType ) -{ - SalData* pSalData = GetSalData(); - QMSG aQMSG; - - if ( (nType & (INPUT_ANY)) == INPUT_ANY ) - { - // Any Input - if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, 0, 0, PM_NOREMOVE ) ) - return TRUE; - } - else - { - if ( nType & INPUT_MOUSE ) - { - // Test auf Mouseinput - if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, - WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE ) ) - return TRUE; - } - - if ( nType & INPUT_KEYBOARD ) - { - // Test auf Keyinput - if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, - WM_CHAR, WM_CHAR, PM_NOREMOVE ) ) - return !(SHORT1FROMMP( aQMSG.mp1 ) & KC_KEYUP); - } - - if ( nType & INPUT_PAINT ) - { - // Test auf Paintinput - if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, - WM_PAINT, WM_PAINT, PM_NOREMOVE ) ) - return TRUE; - } - - if ( nType & INPUT_TIMER ) - { - // Test auf Timerinput - if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, - WM_TIMER, WM_TIMER, PM_NOREMOVE ) ) - return TRUE; - } - - if ( nType & INPUT_OTHER ) - { - // Test auf sonstigen Input - if ( WinPeekMsg( pSalData->mhAB, &aQMSG, 0, 0, 0, PM_NOREMOVE ) ) - return TRUE; - } - } - - return FALSE; -} - -// ----------------------------------------------------------------------- - -SalFrame* Os2SalInstance::CreateChildFrame( SystemParentData* pSystemParentData, ULONG nSalFrameStyle ) -{ - // Um auf Main-Thread umzuschalten - return (SalFrame*)WinSendMsg( mhComWnd, SAL_MSG_CREATEFRAME, (MPARAM)nSalFrameStyle, (MPARAM)pSystemParentData->hWnd ); -} - -// ----------------------------------------------------------------------- - -SalFrame* Os2SalInstance::CreateFrame( SalFrame* pParent, ULONG nSalFrameStyle ) -{ - // Um auf Main-Thread umzuschalten - HWND mhWndClient; -//31/05/06 YD use client as owner(parent) so positioning will not need to -// take care of borders and captions - if ( pParent ) - mhWndClient = static_cast<Os2SalFrame*>(pParent)->mhWndClient; - else - mhWndClient = 0; - return (SalFrame*)WinSendMsg( mhComWnd, SAL_MSG_CREATEFRAME, (MPARAM)nSalFrameStyle, (MPARAM)mhWndClient ); -} - - -// ----------------------------------------------------------------------- - -void Os2SalInstance::DestroyFrame( SalFrame* pFrame ) -{ - WinSendMsg( mhComWnd, SAL_MSG_DESTROYFRAME, 0, (MPARAM)pFrame ); -} - -// ----------------------------------------------------------------------- - -SalObject* Os2SalInstance::CreateObject( SalFrame* pParent, - SystemWindowData* /*pWindowData*/, // SystemWindowData meaningless on Windows - BOOL /*bShow*/ ) -{ - // Um auf Main-Thread umzuschalten - return (SalObject*)WinSendMsg( mhComWnd, SAL_MSG_CREATEOBJECT, 0, (MPARAM)pParent ); -} - - -// ----------------------------------------------------------------------- - -void Os2SalInstance::DestroyObject( SalObject* pObject ) -{ - WinSendMsg( mhComWnd, SAL_MSG_DESTROYOBJECT, 0, (MPARAM)pObject ); -} - -// ----------------------------------------------------------------------- - -void* Os2SalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) -{ - rReturnedBytes = 1; - rReturnedType = AsciiCString; - return (void*) ""; -} - -void Os2SalInstance::AddToRecentDocumentList(const rtl::OUString& /*rFileUrl*/, const rtl::OUString& /*rMimeType*/) -{ -} - -// ----------------------------------------------------------------------- - -SalTimer* Os2SalInstance::CreateSalTimer() -{ - return new Os2SalTimer(); -} - -// ----------------------------------------------------------------------- - -SalBitmap* Os2SalInstance::CreateSalBitmap() -{ - return new Os2SalBitmap(); -} - -// ----------------------------------------------------------------------- - -class Os2ImeStatus : public SalI18NImeStatus -{ - public: - Os2ImeStatus() {} - virtual ~Os2ImeStatus() {} - - // asks whether there is a status window available - // to toggle into menubar - virtual bool canToggle() { return false; } - virtual void toggle() {} -}; - -SalI18NImeStatus* Os2SalInstance::CreateI18NImeStatus() -{ - return new Os2ImeStatus(); -} - -// ----------------------------------------------------------------------- - -const ::rtl::OUString& SalGetDesktopEnvironment() -{ - static ::rtl::OUString aDesktopEnvironment( RTL_CONSTASCII_USTRINGPARAM( "OS/2" ) ); - return aDesktopEnvironment; -} - -SalSession* Os2SalInstance::CreateSalSession() -{ - return NULL; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/os2/source/app/sallang.cxx b/vcl/os2/source/app/sallang.cxx deleted file mode 100644 index b93787013bbb..000000000000 --- a/vcl/os2/source/app/sallang.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <sallang.hxx> - -// ======================================================================= - -// ----------------------------------------------------------------------- -// English (US/UK/AUS/CAN/NZ/EIRE/SAFRICA/JAMAICA/CARRIBEAN) -static const wchar_t* aImplLangEnglishTab[LSTR_COUNT] = -{ - L"Shift", // LSTR_KEY_SHIFT - L"Ctrl", // LSTR_KEY_CTRL - L"Alt", // LSTR_KEY_ALT - L"Up", // LSTR_KEY_UP - L"Down", // LSTR_KEY_DOWN - L"Left", // LSTR_KEY_LEFT - L"Right", // LSTR_KEY_RIGHT - L"Home", // LSTR_KEY_HOME - L"End", // LSTR_KEY_END - L"PageUp", // LSTR_KEY_PAGEUP - L"PageDown", // LSTR_KEY_PAGEDOWN - L"Enter", // LSTR_KEY_RETURN - L"Esc", // LSTR_KEY_ESC - L"Tab", // LSTR_KEY_TAB - L"Backspace", // LSTR_KEY_BACKSPACE - L"Space", // LSTR_KEY_SPACE - L"Insert", // LSTR_KEY_INSERT - L"Del", // LSTR_KEY_DELETE -}; - -// ======================================================================= - -const sal_Unicode** ImplGetLangTab( LanguageType eLang ) -{ - // Sprachtabelle ermitteln - const wchar_t** pLangTab; - //switch ( International::GetNeutralLanguage( eLang ) ) - switch ( eLang ) - { - default: - pLangTab = aImplLangEnglishTab; - break; - } - - return (const sal_Unicode**)pLangTab; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/os2/source/app/salshl.cxx b/vcl/os2/source/app/salshl.cxx deleted file mode 100644 index 5974fbde8bd9..000000000000 --- a/vcl/os2/source/app/salshl.cxx +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <svpm.h> - -#define _SV_SALSHL_CXX -#include <saldata.hxx> -#include <tools/debug.hxx> - -// ======================================================================= - -SalShlData aSalShlData; - -HMODULE ImplGetModule(void); -static HMODULE mhMod = ImplGetModule(); - -// ======================================================================= - -APIRET APIENTRY DosQueryModFromEIP (HMODULE *phMod, ULONG *pObjNum, - ULONG BuffLen, PCHAR pBuff, ULONG *pOffset, ULONG Address); - -HMODULE ImplGetModule(void) -{ - HMODULE hMod; - ULONG ObjNum; - CHAR Buff[2*_MAX_PATH]; - ULONG Offset; - APIRET rc; - - // get module handle (and name) - rc = DosQueryModFromEIP( &hMod, &ObjNum, sizeof( Buff), Buff, &Offset, (ULONG)ImplGetModule); - if (rc) - return NULL; - // return module handle - aSalShlData.mhMod = hMod; - return hMod; -} - -// ======================================================================= - -HPOINTER ImplLoadSalCursor( int nId ) -{ - DBG_ASSERT( aSalShlData.mhMod, "no DLL instance handle" ); - - HPOINTER hPointer = WinLoadPointer( HWND_DESKTOP, aSalShlData.mhMod, nId ); - - DBG_ASSERT( hPointer, "pointer not found in sal resource" ); -#if OSL_DEBUG_LEVEL > 1 - if (!hPointer) - debug_printf( "ImplLoadSalCursor: pointer %d not found in sal resource\n", nId); -#endif - return hPointer; -} - -// ----------------------------------------------------------------------- - -BOOL ImplLoadSalIcon( int nId, HPOINTER& rIcon) -{ - DBG_ASSERT( aSalShlData.mhMod, "no DLL instance handle" ); - - SalData* pSalData = GetSalData(); - - // check the cache first - SalIcon *pSalIcon = pSalData->mpFirstIcon; - while( pSalIcon ) - { - if( pSalIcon->nId != nId ) - pSalIcon = pSalIcon->pNext; - else - { - rIcon = pSalIcon->hIcon; - return (rIcon != 0); - } - } - - // Try at first to load the icons from the application exe file - rIcon = WinLoadPointer( HWND_DESKTOP, NULL, nId ); - if ( !rIcon ) - { - // If the application don't provide these icons, then we try - // to load the icon from the VCL resource - rIcon = WinLoadPointer( HWND_DESKTOP, aSalShlData.mhMod, nId ); - } - - if( rIcon ) - { - // add to icon cache - pSalIcon = new SalIcon(); - pSalIcon->nId = nId; - pSalIcon->hIcon = rIcon; - pSalIcon->pNext = pSalData->mpFirstIcon; - pSalData->mpFirstIcon = pSalIcon; - } - - return (rIcon != 0); -} - -// ======================================================================= - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/os2/source/app/saltimer.cxx b/vcl/os2/source/app/saltimer.cxx deleted file mode 100644 index a27458edd793..000000000000 --- a/vcl/os2/source/app/saltimer.cxx +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <svpm.h> - -#define _SV_SALTIMER_CXX -#include <saldata.hxx> -#include <saltimer.h> -#include <salinst.h> - -// ======================================================================= - -// Maximale Periode -#define MAX_SYSPERIOD 65533 -#define IDTIMER 10 - -// ======================================================================= - -void ImplSalStartTimer( ULONG nMS, BOOL bMutex ) -{ - SalData* pSalData = GetSalData(); - - // Periode darf nicht zu gross sein, da OS2 2.11 mit USHORT arbeitet - // Remenber the time of the timer - pSalData->mnTimerMS = nMS; - if ( !bMutex ) - pSalData->mnTimerOrgMS = nMS; - - // Periode darf nicht zu gross sein, da Windows mit USHORT arbeitet - if ( nMS > MAX_SYSPERIOD ) - nMS = MAX_SYSPERIOD; - - // Gibt es einen Timer, dann zerstoren - if ( pSalData->mnTimerId ) - WinStopTimer( pSalData->mhAB, pSalData->mpFirstInstance->mhComWnd, pSalData->mnTimerId ); - - // Make a new timer with new period - pSalData->mnTimerId = WinStartTimer( pSalData->mhAB, pSalData->mpFirstInstance->mhComWnd, IDTIMER, nMS ); - pSalData->mnNextTimerTime = pSalData->mnLastEventTime + nMS; -} - -// ----------------------------------------------------------------------- - -Os2SalTimer::~Os2SalTimer() -{ -} - -// ----------------------------------------------------------------------- - -void Os2SalTimer::Start( ULONG nMS ) -{ - // Um auf Main-Thread umzuschalten - SalData* pSalData = GetSalData(); - if ( pSalData->mpFirstInstance ) - { - if ( pSalData->mnAppThreadId != GetCurrentThreadId() ) - WinPostMsg( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (MPARAM)nMS ); - else - WinSendMsg( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (MPARAM)nMS ); - } - else - ImplSalStartTimer( nMS, FALSE); -} - -// ----------------------------------------------------------------------- - -void Os2SalTimer::Stop() -{ - SalData* pSalData = GetSalData(); - - // Exitstiert ein Timer, dann diesen zerstoeren - if ( pSalData->mnTimerId ) { - WinStopTimer( pSalData->mhAB, pSalData->mpFirstInstance->mhComWnd, pSalData->mnTimerId ); - pSalData->mnTimerId = 0; - pSalData->mnNextTimerTime = 0; - } -} - -// ----------------------------------------------------------------------- - -void SalTimerProc( HWND, UINT, UINT nId, ULONG ) -{ - SalData* pSalData = GetSalData(); - ImplSVData* pSVData = ImplGetSVData(); - - // Test for MouseLeave - SalTestMouseLeave(); - - bool bRecursive = pSalData->mbInTimerProc && (nId != SALTIMERPROC_RECURSIVE); - if ( pSVData->mpSalTimer && ! bRecursive ) - { - // Try to aquire the mutex. If we don't get the mutex then we - // try this a short time later again. - if ( ImplSalYieldMutexTryToAcquire() ) - { - bRecursive = pSalData->mbInTimerProc && (nId != SALTIMERPROC_RECURSIVE); - if ( pSVData->mpSalTimer && ! bRecursive ) - { - pSalData->mbInTimerProc = TRUE; - pSVData->mpSalTimer->CallCallback(); - pSalData->mbInTimerProc = FALSE; - ImplSalYieldMutexRelease(); - - // Run the timer in the correct time, if we start this - // with a small timeout, because we don't get the mutex - if ( pSalData->mnTimerId && - (pSalData->mnTimerMS != pSalData->mnTimerOrgMS) ) - ImplSalStartTimer( pSalData->mnTimerOrgMS, FALSE ); - } - } - else - ImplSalStartTimer( 10, TRUE ); - } - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |