summaryrefslogtreecommitdiff
path: root/sal/inc/systools
diff options
context:
space:
mode:
Diffstat (limited to 'sal/inc/systools')
-rw-r--r--sal/inc/systools/win32/AutoSystoolInit.hxx62
-rw-r--r--sal/inc/systools/win32/StrConvert.h132
-rw-r--r--sal/inc/systools/win32/SyncObjects.hxx110
-rw-r--r--sal/inc/systools/win32/advapi9x.h209
-rw-r--r--sal/inc/systools/win32/comdlg9x.h80
-rw-r--r--sal/inc/systools/win32/comptr.hxx233
-rw-r--r--sal/inc/systools/win32/comtools.hxx194
-rw-r--r--sal/inc/systools/win32/kernel9x.h383
-rw-r--r--sal/inc/systools/win32/mpr9x.h72
-rw-r--r--sal/inc/systools/win32/shell9x.h101
-rw-r--r--sal/inc/systools/win32/snprintf.h80
-rw-r--r--sal/inc/systools/win32/user9x.h192
-rw-r--r--sal/inc/systools/win32/uwinapi.h121
13 files changed, 1969 insertions, 0 deletions
diff --git a/sal/inc/systools/win32/AutoSystoolInit.hxx b/sal/inc/systools/win32/AutoSystoolInit.hxx
new file mode 100644
index 000000000000..d212ff83c334
--- /dev/null
+++ b/sal/inc/systools/win32/AutoSystoolInit.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _AUTOSYSTOOLINIT_HXX_
+#define _AUTOSYSTOOLINIT_HXX_
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+//------------------------------------------------------------------------
+// class used to automatically initialize/deinitialize the systools
+//------------------------------------------------------------------------
+
+class OAutoSystoolInit
+{
+ typedef void ( WINAPI *LPFNINIT_T )( );
+ typedef void ( WINAPI *LPFNDEINIT_T )( );
+
+public:
+ OAutoSystoolInit( LPFNINIT_T lpfnInit, LPFNDEINIT_T lpfnDeInit ) :
+ m_lpfnDeInit( lpfnDeInit )
+ {
+ if ( NULL != lpfnInit )
+ lpfnInit( );
+ }
+
+ ~OAutoSystoolInit( )
+ {
+ if ( NULL != m_lpfnDeInit )
+ m_lpfnDeInit( );
+ }
+
+private:
+ LPFNDEINIT_T m_lpfnDeInit; // address of the deinit function
+};
+
+#endif
diff --git a/sal/inc/systools/win32/StrConvert.h b/sal/inc/systools/win32/StrConvert.h
new file mode 100644
index 000000000000..f22f68cda46a
--- /dev/null
+++ b/sal/inc/systools/win32/StrConvert.h
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _STRCONVERT_H_
+#define _STRCONVERT_H_
+
+#include <windows.h>
+
+#ifdef NDEBUG
+#define STRCONVERT_H_HAD_NDEBUG
+#undef NDEBUG
+#endif
+#if OSL_DEBUG_LEVEL == 0
+#define NDEBUG
+#endif
+#include <assert.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+int AllocNecessarySpaceAndCopyWStr2Str( LPCWSTR lpcwstrString, LPSTR* lppStr );
+int AllocSpaceAndCopyWStr2Str( LPCWSTR lpcwstrString, DWORD nWCharsToCopy, LPSTR* lppStr );
+int CalcLenDblNullTerminatedWStr( LPCWSTR lpcwstrString );
+int CalcLenDblNullTerminatedStr( LPCSTR lpcstrString );
+void FreeSpaceStr( LPSTR lpszString );
+
+/* WC2MB allocates a sufficient amount of memory on stack and converts
+ the wide char parameter to multi byte string using the actual code
+ page.
+
+ @Param: wcStr - a wide char string
+ mbStr - the corresponding multi byte string
+
+ NOTE: due to the use of _alloca, this must be a macro and no function
+*/
+
+#define WC2MB( wcStr, mbStr ) \
+if( wcStr ) \
+{ \
+ int needed = WideCharToMultiByte( CP_ACP, 0, wcStr, -1, NULL, 0, NULL, NULL ); \
+ if( needed > 0 ) \
+ { \
+ int copied; \
+ mbStr = _alloca( needed * sizeof( CHAR ) ); \
+ copied = WideCharToMultiByte( CP_ACP, 0, wcStr, -1, mbStr, needed, NULL, NULL ); \
+ assert( copied == needed ); \
+ } \
+}
+
+
+/* WideCharListGetMultiByteLength
+ calculates the needed length of a corresponding the multi byte string
+ list for a wide char string list.
+
+ @Param: cp - the code page to use for convertion.
+ wcList - a double '\0' terminated wide char string list.
+*/
+
+int WideCharListGetMultiByteLength( UINT codepage, LPCWSTR wcList );
+
+/* WideCharListToMultiByteList
+ converts a double '\0' terminated list of wide char strings to a
+ multi byte string list.
+
+ @Param: cp - the code page to use for convertion.
+ wcList - a double '\0' terminated wide char string list.
+ mbList - a double '\0' terminated multi byte string list.
+ dwSize - size of buffer for multi byte string list.
+*/
+
+int WideCharListToMultiByteList( UINT codepage, LPCWSTR wcList, LPSTR mbList, DWORD dwSize );
+
+
+/* WCL2MBL allocates a sufficient amount of memory on stack and converts
+ the wide char list parameter to multi byte string list using the actual
+ code page.
+
+ @Param: wcList - a wide char string list
+ mbList - the corresponding multi byte string list
+
+ NOTE: due to the use of _alloca, this must be a macro and no function
+*/
+
+#define WCL2MBL( wcList, mbList ) \
+if( wcList ) \
+{ \
+ int needed = WideCharListGetMultiByteLength( CP_ACP, wcList ); \
+ if( needed > 0 ) \
+ { \
+ int copied; \
+ mbList = _alloca( needed * sizeof( CHAR ) ); \
+ copied = WideCharListToMultiByteList( CP_ACP, wcList, mbList, needed ); \
+ assert( copied == needed ); \
+ } \
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// Restore NDEBUG state
+#ifdef STRCONVERT_H_HAD_NDEBUG
+#define NDEBUG
+#else
+#undef NDEBUG
+#endif
+
+#endif
diff --git a/sal/inc/systools/win32/SyncObjects.hxx b/sal/inc/systools/win32/SyncObjects.hxx
new file mode 100644
index 000000000000..87057bab6296
--- /dev/null
+++ b/sal/inc/systools/win32/SyncObjects.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+
+#ifndef _SYNCOBJECTS_HXX_
+#define _SYNCOBJECTS_HXX_
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#include <windows.h>
+
+//------------------------------------------------------------------------
+// a simple helper template for automatic locking/unlocking
+//------------------------------------------------------------------------
+
+template< class LOCK >
+class CLockGuard
+{
+public:
+ CLockGuard( LOCK* aLock ) :
+ m_pLock( aLock )
+ {
+ m_pLock->Lock( );
+ }
+
+ ~CLockGuard( )
+ {
+ m_pLock->Unlock( );
+ }
+
+private:
+ LOCK* m_pLock;
+};
+
+//------------------------------------------------------------------------
+// a interface base class for different locking sub classes
+//------------------------------------------------------------------------
+
+class CSyncObject
+{
+public:
+ virtual ~CSyncObject( ) = 0;
+
+ virtual int Lock( ) = 0;
+ virtual int Unlock( ) = 0;
+};
+
+//------------------------------------------------------------------------
+// if no synchronization is necessary this class will be used
+// declaring the functions as inline safes runtime overhead
+//------------------------------------------------------------------------
+
+class CNullLock
+{
+public:
+ inline virtual ~CNullLock ( ) {};
+ inline virtual int Lock( ) {};
+ inline virtual int Unlock() {};
+};
+
+//------------------------------------------------------------------------
+// a minimal wrapper for a win32 critical section
+//------------------------------------------------------------------------
+
+class CCriticalSection : public CSyncObject
+{
+public:
+ CCriticalSection( );
+ virtual ~CCriticalSection( );
+
+ // both functions return always 0
+ // because the win32 critsec functions
+ // don't return any return code
+ virtual int Lock( );
+ virtual int Unlock( );
+
+private:
+ CRITICAL_SECTION m_critSec;
+};
+
+
+typedef CLockGuard< CSyncObject > SyncObjLockGuard_t;
+
+#endif
diff --git a/sal/inc/systools/win32/advapi9x.h b/sal/inc/systools/win32/advapi9x.h
new file mode 100644
index 000000000000..302df89c50c3
--- /dev/null
+++ b/sal/inc/systools/win32/advapi9x.h
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the shlobj.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+// begin obsolete Win32 API functions -->
+#ifdef RegOpenKey
+#undef RegOpenKey
+#endif
+#ifdef RegEnumKey
+#undef RegEnumKey
+#endif
+#ifdef RegCreateKey
+#undef RegCreateKey
+#endif
+#ifdef RegQueryValue
+#undef RegQueryValue
+#endif
+#ifdef RegSetValue
+#undef RegSetValue
+#endif
+// <-- end obsolete Win32 functions
+
+#ifdef RegOpenKeyExW
+#undef RegOpenKeyExW
+#endif
+#ifdef RegEnumKeyExW
+#undef RegEnumKeyExW
+#endif
+#ifdef RegCreateKeyExW
+#undef RegCreateKeyExW
+#endif
+#ifdef RegDeleteKeyW
+#undef RegDeleteKeyW
+#endif
+#ifdef RegEnumValueW
+#undef RegEnumValueW
+#endif
+#ifdef RegQueryValueExW
+#undef RegQueryValueExW
+#endif
+#ifdef RegSetValueExW
+#undef RegSetValueExW
+#endif
+#ifdef RegDeleteValueW
+#undef RegDeleteValueW
+#endif
+#ifdef RegQueryInfoKeyW
+#undef RegQueryInfoKeyW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define ADVAPI9X_API extern
+
+ //------------------------------------------------------------------------
+// declare function pointers to the appropriate shell functions
+//------------------------------------------------------------------------
+
+ADVAPI9X_API LONG (WINAPI * lpfnRegOpenKeyExW) (
+ HKEY hKey, // handle to open key
+ LPCWSTR lpSubKey, // subkey name
+ DWORD ulOptions, // reserved
+ REGSAM samDesired, // security access mask
+ PHKEY phkResult // handle to open key
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegEnumKeyExW) (
+ HKEY hKey, // handle to key to enumerate
+ DWORD dwIndex, // subkey index
+ LPWSTR lpName, // subkey name
+ LPDWORD lpcName, // size of subkey buffer
+ LPDWORD lpReserved, // reserved
+ LPWSTR lpClass, // class string buffer
+ LPDWORD lpcClass, // size of class string buffer
+ PFILETIME lpftLastWriteTime // last write time
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegCreateKeyExW)(
+ HKEY hKey, // handle to open key
+ LPCWSTR lpSubKey, // subkey name
+ DWORD Reserved, // reserved
+ LPWSTR lpClass, // class string
+ DWORD dwOptions, // special options
+ REGSAM samDesired, // desired security access
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes, // inheritance
+ PHKEY phkResult, // key handle
+ LPDWORD lpdwDisposition // disposition value buffer
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegDeleteKeyW) (
+ HKEY hKey, // handle to open key
+ LPCWSTR lpSubKey // subkey name
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegEnumValueW) (
+ HKEY hKey, // handle to key to query
+ DWORD dwIndex, // index of value to query
+ LPWSTR lpValueName, // value buffer
+ LPDWORD lpcValueName, // size of value buffer
+ LPDWORD lpReserved, // reserved
+ LPDWORD lpType, // type buffer
+ LPBYTE lpData, // data buffer
+ LPDWORD lpcbData // size of data buffer
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegQueryValueExW) (
+ HKEY hKey, // handle to key
+ LPCWSTR lpValueName, // value name
+ LPDWORD lpReserved, // reserved
+ LPDWORD lpType, // type buffer
+ LPBYTE lpData, // data buffer
+ LPDWORD lpcbData // size of data buffer
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegSetValueExW)(
+ HKEY hKey, // handle to key
+ LPCWSTR lpValueName, // value name
+ DWORD Reserved, // reserved
+ DWORD dwType, // value type
+ CONST BYTE *lpData, // value data
+ DWORD cbData // size of value data
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegDeleteValueW) (
+ HKEY hKey, // handle to key
+ LPCWSTR lpValueName // value name
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegQueryInfoKeyW) (
+ HKEY hKey, // handle to key to query
+ LPWSTR lpClassW, // address of buffer for class string
+ LPDWORD lpcbClass, // address of size of class string buffer
+ LPDWORD lpReserved, // reserved
+ LPDWORD lpcSubKeys, // address of buffer for number of
+ // subkeys
+ LPDWORD lpcbMaxSubKeyLen, // address of buffer for longest subkey
+ // name length
+ LPDWORD lpcbMaxClassLen, // address of buffer for longest class
+ // string length
+ LPDWORD lpcValues, // address of buffer for number of value
+ // entries
+ LPDWORD lpcbMaxValueNameLen, // address of buffer for longest
+ // value name length
+ LPDWORD lpcbMaxValueLen, // address of buffer for longest value
+ // data length
+ LPDWORD lpcbSecurityDescriptor, // address of buffer for security
+ // descriptor length
+ PFILETIME lpftLastWriteTime // address of buffer for last write time
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define RegOpenKeyExW lpfnRegOpenKeyExW
+#define RegEnumKeyExW lpfnRegEnumKeyExW
+#define RegCreateKeyExW lpfnRegCreateKeyExW
+#define RegDeleteKeyW lpfnRegDeleteKeyW
+#define RegEnumValueW lpfnRegEnumValueW
+#define RegQueryValueExW lpfnRegQueryValueExW
+#define RegSetValueExW lpfnRegSetValueExW
+#define RegDeleteValueW lpfnRegDeleteValueW
+#define RegQueryInfoKeyW lpfnRegQueryInfoKeyW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/comdlg9x.h b/sal/inc/systools/win32/comdlg9x.h
new file mode 100644
index 000000000000..ce51bbe61ced
--- /dev/null
+++ b/sal/inc/systools/win32/comdlg9x.h
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifndef _COMMDLG_H_
+#include <commdlg.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the shlobj.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef GetOpenFileNameW
+#undef GetOpenFileNameW
+#endif
+
+#ifdef GetSaveFileNameW
+#undef GetSaveFileNameW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define COMDLG9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate comdlg functions
+//------------------------------------------------------------------------
+
+COMDLG9X_API BOOL ( WINAPI * lpfnGetOpenFileNameW ) ( LPOPENFILENAMEW lpofn );
+COMDLG9X_API BOOL ( WINAPI * lpfnGetSaveFileNameW ) ( LPOPENFILENAMEW lpofn );
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define GetOpenFileNameW lpfnGetOpenFileNameW
+#define GetSaveFileNameW lpfnGetSaveFileNameW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/comptr.hxx b/sal/inc/systools/win32/comptr.hxx
new file mode 100644
index 000000000000..1e880494b0ea
--- /dev/null
+++ b/sal/inc/systools/win32/comptr.hxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef COMPTR_HXX
+#define COMPTR_HXX
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <shobjidl.h>
+
+template< class T_INTERFACE ,
+ REFIID P_IID = IID_NULL ,
+ REFCLSID P_CLSID = CLSID_NULL >
+class ComPtr
+{
+ public:
+
+ //---------------------------------------------------------------------
+ /** initialize com ptr with null.
+ */
+ ComPtr()
+ {
+ m_pInterface = NULL;
+ }
+
+ //---------------------------------------------------------------------
+ /** initialize com ptr with given interface.
+ */
+ ComPtr(T_INTERFACE* pInterface)
+ {
+ m_pInterface = pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+ }
+
+ //---------------------------------------------------------------------
+ /** copy ctor.
+ */
+ ComPtr(const ComPtr< T_INTERFACE, P_IID, P_CLSID >& aCopy)
+ {
+ m_pInterface = aCopy.m_pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+ }
+
+ //---------------------------------------------------------------------
+ /** initialize object by quering external object for the right interface.
+ */
+ ComPtr(IUnknown* pIUnknown)
+ {
+ if (pIUnknown)
+ pIUnknown->QueryInterface(P_IID, (void**)&m_pInterface);
+ }
+
+ //---------------------------------------------------------------------
+ /** deinitialize com object right.
+ */
+ ~ComPtr()
+ {
+ release();
+ }
+
+ public:
+
+ //---------------------------------------------------------------------
+ HRESULT create()
+ {
+ return CoCreateInstance(P_CLSID, NULL, CLSCTX_ALL, P_IID, (void**)&m_pInterface);
+ }
+
+ //---------------------------------------------------------------------
+ operator T_INTERFACE*() const
+ {
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE& operator*() const
+ {
+ return *m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE** operator&()
+ {
+ return &m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator->() const
+ {
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator=(T_INTERFACE* pInterface)
+ {
+ if ( equals(pInterface) )
+ return m_pInterface;
+
+ m_pInterface->Release();
+ m_pInterface = pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator=(IUnknown* pIUnknown)
+ {
+ if (pIUnknown)
+ pIUnknown->QueryInterface(P_IID, (void**)&m_pInterface);
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator=(const ComPtr< T_INTERFACE, P_IID, P_CLSID >& aCopy)
+ {
+ m_pInterface = aCopy.m_pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* get() const
+ {
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ void attach(T_INTERFACE* pInterface)
+ {
+ if (pInterface)
+ {
+ m_pInterface->Release();
+ m_pInterface = pInterface;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* detach()
+ {
+ T_INTERFACE* pInterface = m_pInterface;
+ m_pInterface = NULL;
+ return pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ void release()
+ {
+ if (m_pInterface)
+ {
+ m_pInterface->Release();
+ m_pInterface = NULL;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ template< class T_QUERYINTERFACE >
+ HRESULT query(T_QUERYINTERFACE** pQuery)
+ {
+ return m_pInterface->QueryInterface(__uuidof(T_QUERYINTERFACE), (void**)pQuery);
+ }
+
+ //---------------------------------------------------------------------
+ HRESULT query(REFIID rIID ,
+ void** pQuery)
+ {
+ return m_pInterface->QueryInterface(rIID, pQuery);
+ }
+
+ //---------------------------------------------------------------------
+ HRESULT unknown(IUnknown** pQuery)
+ {
+ return m_pInterface->QueryInterface(IID_IUnknown, (void**)pQuery);
+ }
+
+ //---------------------------------------------------------------------
+ ::sal_Bool equals(IUnknown* pCheck)
+ {
+ if (
+ ( ! m_pInterface ) &&
+ ( ! pCheck )
+ )
+ return sal_True;
+
+ IUnknown* pCurrent = NULL;
+ m_pInterface->QueryInterface(IID_IUnknown, (void**)&pCurrent);
+
+ ::sal_Bool bEquals = (pCheck == pCurrent);
+ pCurrent->Release();
+
+ return bEquals;
+ }
+
+ //---------------------------------------------------------------------
+ ::sal_Bool is()
+ {
+ return (m_pInterface != 0);
+ }
+
+ private:
+ T_INTERFACE* m_pInterface;
+};
+
+#endif
diff --git a/sal/inc/systools/win32/comtools.hxx b/sal/inc/systools/win32/comtools.hxx
new file mode 100644
index 000000000000..096015517a35
--- /dev/null
+++ b/sal/inc/systools/win32/comtools.hxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#include <string>
+#include <stdexcept>
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+namespace sal
+{
+namespace systools
+{
+ typedef int HRESULT;
+
+ /* Simple exception class for propagating COM errors */
+ class ComError : public std::runtime_error
+ {
+ public:
+ ComError(const std::string& message, HRESULT hr) :
+ std::runtime_error(message),
+ hr_(hr)
+ {}
+
+ HRESULT GetHresult() const
+ {
+ return hr_;
+ }
+
+ private:
+ HRESULT hr_;
+ };
+
+ /* A simple COM smart pointer template */
+ template <typename T>
+ class COMReference
+ {
+ public:
+ COMReference() :
+ com_ptr_(NULL)
+ {
+ }
+
+ explicit COMReference(T* comptr) :
+ com_ptr_(comptr)
+ {
+ addRef();
+ }
+
+ /* Explicitly controllable whether AddRef will be called or not */
+ COMReference(T* comptr, bool bAddRef) :
+ com_ptr_(comptr)
+ {
+ if (bAddRef)
+ addRef();
+ }
+
+ COMReference(const COMReference<T>& other) :
+ com_ptr_(other.com_ptr_)
+ {
+ addRef();
+ }
+
+ COMReference<T>& operator=(const COMReference<T>& other)
+ {
+ if (other.com_ptr_)
+ other.com_ptr_->AddRef();
+ release();
+ com_ptr_ = other.com_ptr_;
+ return *this;
+ }
+
+ COMReference<T>& operator=(T* comptr)
+ {
+ release();
+ com_ptr_ = comptr;
+ addRef();
+ return *this;
+ }
+
+ ~COMReference()
+ {
+ release();
+ }
+
+ template<typename InterfaceType>
+ COMReference<InterfaceType> QueryInterface(REFIID iid)
+ {
+ COMReference<InterfaceType> ip;
+ HRESULT hr = E_FAIL;
+ if (com_ptr_)
+ hr = com_ptr_->QueryInterface(iid, reinterpret_cast<LPVOID*>(&ip));
+
+ if (FAILED(hr))
+ throw ComError("QueryInterface failed: Interface not supported!", hr);
+
+ return ip;
+ }
+
+ T* operator->() const
+ {
+ return com_ptr_;
+ }
+
+ T& operator*() const
+ {
+ return *com_ptr_;
+ }
+
+ /* Necessary for assigning com_ptr_ from functions like
+ CoCreateInstance which require a 'void**' */
+ T** operator&()
+ {
+ release();
+ com_ptr_ = NULL;
+ return &com_ptr_;
+ }
+
+ T* get() const
+ {
+ return com_ptr_;
+ }
+
+ COMReference<T>& clear()
+ {
+ release();
+ com_ptr_ = NULL;
+ return *this;
+ }
+
+ bool is() const
+ {
+ return (com_ptr_ != NULL);
+ }
+
+ private:
+ ULONG addRef()
+ {
+ ULONG cnt = 0;
+ if (com_ptr_)
+ cnt = com_ptr_->AddRef();
+ return cnt;
+ }
+
+ ULONG release()
+ {
+ ULONG cnt = 0;
+ if (com_ptr_)
+ cnt = com_ptr_->Release();
+ return cnt;
+ }
+
+ private:
+ T* com_ptr_;
+ };
+
+} // systools
+} // sal
+
+/* Typedefs for some popular COM interfaces */
+typedef sal::systools::COMReference<IDataObject> IDataObjectPtr;
+typedef sal::systools::COMReference<IStream> IStreamPtr;
+typedef sal::systools::COMReference<IEnumFORMATETC> IEnumFORMATETCPtr;
+
diff --git a/sal/inc/systools/win32/kernel9x.h b/sal/inc/systools/win32/kernel9x.h
new file mode 100644
index 000000000000..647e7d58542d
--- /dev/null
+++ b/sal/inc/systools/win32/kernel9x.h
@@ -0,0 +1,383 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the winbase.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef LoadLibraryW
+#undef LoadLibraryW
+#endif
+
+#ifdef LoadLibraryExW
+#undef LoadLibraryExW
+#endif
+
+#ifdef GetModuleFileNameW
+#undef GetModuleFileNameW
+#endif
+
+#ifdef GetLogicalDriveStringsW
+#undef GetLogicalDriveStringsW
+#endif
+
+#ifdef DeleteFileW
+#undef DeleteFileW
+#endif
+
+#ifdef CopyFileW
+#undef CopyFileW
+#endif
+
+#ifdef MoveFileW
+#undef MoveFileW
+#endif
+
+#ifdef MoveFileExW
+#undef MoveFileExW
+#endif
+
+#ifdef CreateFileW
+#undef CreateFileW
+#endif
+
+#ifdef RemoveDirectoryW
+#undef RemoveDirectoryW
+#endif
+
+#ifdef CreateDirectoryW
+#undef CreateDirectoryW
+#endif
+
+#ifdef CreateDirectoryExW
+#undef CreateDirectoryExW
+#endif
+
+#ifdef CreateFileW
+#undef CreateFileW
+#endif
+
+#ifdef GetLongPathNameW
+#undef GetLongPathNameW
+#endif
+
+#ifdef GetLocaleInfoW
+#undef GetLocaleInfoW
+#endif
+
+#ifdef GetFullPathNameW
+#undef GetFullPathNameW
+#endif
+
+#ifdef CreateProcessW
+#undef CreateProcessW
+#endif
+
+#ifdef CreateProcessAsUserW
+#undef CreateProcessAsUserW
+#endif
+
+#ifdef GetEnvironmentVariableW
+#undef GetEnvironmentVariableW
+#endif
+
+#ifdef GetDriveTypeW
+#undef GetDriveTypeW
+#endif
+
+#ifdef GetCurrentDirectoryW
+#undef GetCurrentDirectoryW
+#endif
+
+#ifdef SetCurrentDirectoryW
+#undef SetCurrentDirectoryW
+#endif
+
+#ifdef GetVolumeInformationW
+#undef GetVolumeInformationW
+#endif
+
+
+#ifdef GetDiskFreeSpaceExA
+#undef GetDiskFreeSpaceExA
+#endif
+
+#ifdef GetDiskFreeSpaceExW
+#undef GetDiskFreeSpaceExW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define KERNEL9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate kernel functions
+//------------------------------------------------------------------------
+
+//BOOL WINAPI RegisterServiceProcess( DWORD dwProcessID, BOOL fRegister );
+
+KERNEL9X_API HMODULE (WINAPI *lpfnLoadLibraryExW ) (
+ LPCWSTR lpLibFileName, // file name of module
+ HANDLE hFile, // reserved, must be NULL
+ DWORD dwFlags // entry-point execution option
+);
+
+KERNEL9X_API DWORD (WINAPI *lpfnGetModuleFileNameW ) (
+ HMODULE hModule, // handle to module
+ LPWSTR lpFilename, // file name of module
+ DWORD nSize // size of buffer
+);
+
+KERNEL9X_API DWORD (WINAPI *lpfnGetLogicalDriveStringsW ) (
+ DWORD nBufferLength, // size of buffer
+ LPWSTR lpBuffer // drive strings buffer
+);
+
+KERNEL9X_API HANDLE ( WINAPI *lpfnCreateFileW )(
+ LPCWSTR lpFileName,
+ DWORD dwDesiredAccess,
+ DWORD dwShareMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDisposition,
+ DWORD dwFlagsAndAttributes,
+ HANDLE hTemplateFile
+);
+
+KERNEL9X_API DWORD WINAPI GetCanonicalPathNameA(
+ LPCSTR lpszPath, // file name
+ LPSTR lpszCanonicalPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+KERNEL9X_API DWORD WINAPI GetCanonicalPathNameW(
+ LPCWSTR lpszPath, // file name
+ LPWSTR lpszCanonicalPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+KERNEL9X_API HANDLE ( WINAPI * lpfnCreateFileW ) (
+ LPCWSTR lpFileName,
+ DWORD dwDesiredAccess,
+ DWORD dwShareMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDisposition,
+ DWORD dwFlagsAndAttributes,
+ HANDLE hTemplateFile );
+
+KERNEL9X_API BOOL (WINAPI *lpfnDeleteFileW ) (
+ LPCWSTR lpFileName // file name
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnCopyFileW ) (
+ LPCWSTR lpExistingFileName, // file name
+ LPCWSTR lpNewFileName, // new file name
+ BOOL bFailIfExist // operation if file exists
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnMoveFileW ) (
+ LPCWSTR lpExistingFileName, // file name
+ LPCWSTR lpNewFileName // new file name
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnMoveFileExW ) (
+ LPCWSTR lpExistingFileName, // file name
+ LPCWSTR lpNewFileName, // new file name
+ DWORD dwFlags // move options
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnRemoveDirectoryW ) (
+ LPCWSTR lpPathName // directory name
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateDirectoryW ) (
+ LPCWSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes );
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateDirectoryExW ) (
+ LPCWSTR lpTemplateDirectory,
+ LPCWSTR lpNewDirectory,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes );
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetLongPathNameW ) (
+ LPCWSTR lpszShortPath, // file name
+ LPWSTR lpszLongPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+// GetCanonicalPath is a tool function with no exact counterpart
+// in the win32 api; we use nevertheless a function pointer
+// because every variable etc. must root in the Kernel9x.lib else
+// we loose our AutoSystoolInit object during linking
+KERNEL9X_API DWORD ( WINAPI * lpfnGetCanonicalPathW ) (
+ LPCWSTR lpszPath, // file name
+ LPWSTR lpszCanonicalPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+KERNEL9X_API int ( WINAPI* lpfnGetLocaleInfoW ) (
+ LCID Locale, // locale identifier
+ LCTYPE LCType, // information type
+ LPWSTR lpLCData, // information buffer
+ int cchData // size of buffer
+);
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetFullPathNameW )(
+ LPCWSTR lpFileName, // file name
+ DWORD nBufferLength, // size of path buffer
+ LPWSTR lpBuffer, // path buffer
+ LPWSTR *lpFilePart // address of file name in path
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateProcessW )(
+ LPCWSTR lpApplicationName, // name of executable module
+ LPWSTR lpCommandLine, // command line string
+ LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
+ LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
+ BOOL bInheritHandles, // handle inheritance option
+ DWORD dwCreationFlags, // creation flags
+ LPVOID lpEnvironment, // new environment block
+ LPCWSTR lpCurrentDirectory, // current directory name
+ LPSTARTUPINFOW lpStartupInfo, // startup information
+ LPPROCESS_INFORMATION lpProcessInformation // process information
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateProcessAsUserW )(
+ HANDLE hToken, // handle to user token
+ LPCWSTR lpApplicationName, // name of executable module
+ LPWSTR lpCommandLine, // command-line string
+ LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
+ LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
+ BOOL bInheritHandles, // inheritance option
+ DWORD dwCreationFlags, // creation flags
+ LPVOID lpEnvironment, // new environment block
+ LPCWSTR lpCurrentDirectory, // current directory name
+ LPSTARTUPINFOW lpStartupInfo, // startup information
+ LPPROCESS_INFORMATION lpProcessInformation // process information
+);
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetEnvironmentVariableW )(
+ LPCWSTR lpName, // environment variable name
+ LPWSTR lpBuffer, // buffer for variable value
+ DWORD nSize // size of buffer
+);
+
+
+KERNEL9X_API UINT ( WINAPI * lpfnGetDriveTypeW )(
+ LPCWSTR lpRootPathName // root directory
+);
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetCurrentDirectoryW )(
+ DWORD nBufferLength, // size of directory buffer
+ LPWSTR lpBuffer // directory buffer
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnSetCurrentDirectoryW )(
+ LPCWSTR lpPathName // new directory name
+);
+
+// GetVolumeInformation
+KERNEL9X_API BOOL ( WINAPI* lpfnGetVolumeInformationW )(
+ LPCWSTR lpRootPathName, // root directory
+ LPWSTR lpVolumeNameBuffer, // volume name buffer
+ DWORD nVolumeNameSize, // length of name buffer
+ LPDWORD lpVolumeSerialNumber, // volume serial number
+ LPDWORD lpMaximumComponentLength, // maximum file name length
+ LPDWORD lpFileSystemFlags, // file system options
+ LPWSTR lpFileSystemName, // file system name buffer
+ DWORD nFileSystemNameSize // length of file system name buffer
+);
+
+// GetDiskFreeSpaceExA
+KERNEL9X_API BOOL (WINAPI *lpfnGetDiskFreeSpaceExA)(
+ LPCSTR lpDirectoryName, // directory name
+ PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
+ PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
+ PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
+);
+
+// GetDiskFreeSpaceExW
+KERNEL9X_API BOOL (WINAPI *lpfnGetDiskFreeSpaceExW)(
+ LPCWSTR lpDirectoryName, // directory name
+ PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
+ PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
+ PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define LoadLibraryExW lpfnLoadLibraryExW
+#define LoadLibraryW(c) LoadLibraryExW(c, NULL, 0)
+#define GetModuleFileNameW lpfnGetModuleFileNameW
+#define GetLogicalDriveStringsW lpfnGetLogicalDriveStringsW
+#define CreateFileW lpfnCreateFileW
+#define DeleteFileW lpfnDeleteFileW
+#define CopyFileW lpfnCopyFileW
+#define MoveFileW lpfnMoveFileW
+#define MoveFileExW lpfnMoveFileExW
+#define RemoveDirectoryW lpfnRemoveDirectoryW
+#define CreateDirectoryW lpfnCreateDirectoryW
+#define CreateDirectoryExW lpfnCreateDirectoryExW
+#define GetLongPathNameW lpfnGetLongPathNameW
+#define GetFullPathNameW lpfnGetFullPathNameW
+
+#define GetCanonicalPath lpfnGetCanonicalPathW
+#define GetLocaleInfoW lpfnGetLocaleInfoW
+
+#define CreateProcessW lpfnCreateProcessW
+#define CreateProcessAsUserW lpfnCreateProcessAsUserW
+#define GetEnvironmentVariableW lpfnGetEnvironmentVariableW
+#define GetDriveTypeW lpfnGetDriveTypeW
+
+#define GetCurrentDirectoryW lpfnGetCurrentDirectoryW
+#define SetCurrentDirectoryW lpfnSetCurrentDirectoryW
+
+#define GetVolumeInformationW lpfnGetVolumeInformationW
+#define GetDiskFreeSpaceExA lpfnGetDiskFreeSpaceExA
+#define GetDiskFreeSpaceExW lpfnGetDiskFreeSpaceExW
+
+#ifdef __cplusplus
+}
+#endif
+
+
diff --git a/sal/inc/systools/win32/mpr9x.h b/sal/inc/systools/win32/mpr9x.h
new file mode 100644
index 000000000000..15b122025381
--- /dev/null
+++ b/sal/inc/systools/win32/mpr9x.h
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the winuser.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef WNetGetConnectionW
+#undef WNetGetConnectionW
+#endif
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define MPR9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate user32 functions
+//------------------------------------------------------------------------
+
+MPR9X_API DWORD (WINAPI *lpfnWNetGetConnectionW)(
+ LPCWSTR lpLocalName, // pointer to local name
+ LPWSTR lpRemoteName, // pointer to buffer for remote name
+ LPDWORD lpnLength // pointer to buffer size, in characters
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define WNetGetConnectionW lpfnWNetGetConnectionW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/shell9x.h b/sal/inc/systools/win32/shell9x.h
new file mode 100644
index 000000000000..30716314830d
--- /dev/null
+++ b/sal/inc/systools/win32/shell9x.h
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _SHELL9X_H_
+#define _SHELL9X_H_
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifndef _SHLOBJ_H_
+#include <shlobj.h>
+#endif
+
+#include <shellapi.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the shlobj.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef CommandLineToArgvW
+#undef CommandLineToArgvW
+#endif
+
+#ifdef SHBrowseForFolderW
+#undef SHBrowseForFolderW
+#endif
+
+#ifdef SHGetPathFromIDListW
+#undef SHGetPathFromIDListW
+#endif
+
+#ifdef ShellExecuteExW
+#undef ShellExecuteExW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define SHELL9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate shell functions
+//------------------------------------------------------------------------
+
+SHELL9X_API LPWSTR * ( WINAPI * lpfnCommandLineToArgvW ) ( LPCWSTR lpCmdLine, int *pNumArgs );
+SHELL9X_API LPITEMIDLIST ( WINAPI * lpfnSHBrowseForFolderW ) ( LPBROWSEINFOW lpbi );
+SHELL9X_API BOOL ( WINAPI * lpfnSHGetPathFromIDListW ) ( LPCITEMIDLIST pidl, LPWSTR pszPath );
+
+SHELL9X_API BOOL ( WINAPI * lpfnShellExecuteExW ) ( LPSHELLEXECUTEINFOW lpExecInfo );
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define CommandLineToArgvW lpfnCommandLineToArgvW
+#define SHBrowseForFolderW lpfnSHBrowseForFolderW
+#define SHGetPathFromIDListW lpfnSHGetPathFromIDListW
+
+#define ShellExecuteExW lpfnShellExecuteExW
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sal/inc/systools/win32/snprintf.h b/sal/inc/systools/win32/snprintf.h
new file mode 100644
index 000000000000..79441f032fee
--- /dev/null
+++ b/sal/inc/systools/win32/snprintf.h
@@ -0,0 +1,80 @@
+#ifndef _SNPRINTF_H
+#define _SNPRINTF_H
+
+#if !defined(_WIN32)
+#error ERROR: Only Win32 target supported!
+#endif
+
+/* Macros for Unicode/ANSI support like in TCHAR.H */
+
+#ifdef _UNICODE
+#define sntprintf snwprintf
+#define vsntprintf vsnwprintf
+#else
+#define sntprintf snprintf
+#define vsntprintf vsnprintf
+#endif
+
+/* Define needed types if they are not yet defined */
+
+#if 0
+# ifndef _INC_STDARG
+# include <stdarg.h>
+# endif
+#else
+# ifndef _VA_LIST_DEFINED
+ typedef char * va_list;
+# define _VA_LIST_DEFINED
+# endif
+#endif
+
+#if 0
+# ifndef _INC_WCHAR
+# include <wchar.h>
+# endif
+#else
+# ifndef _WCHAR_T_DEFINED
+ typedef unsigned short wchar_t;
+# define _WCHAR_T_DEFINED
+# endif
+#endif
+
+#ifndef _SNPRINTF_DLLIMPORT
+#define _SNPRINTF_DLLIMPORT __declspec( dllimport )
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Implementations of snprintf following the ISO/IEC 9899:1999 (ISO C99)
+ standard.
+ The difference compared to _snprintf is that the buffer always is zero
+ terminated (unless count is zero) and the return value is the number of
+ characters (not including terminating zero) that would have been written
+ even if the buffer wasn't large
+ enough to hold the string. */
+
+
+
+/* UNICODE version */
+_SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
+
+/* SBCS and MBCS version */
+_SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
+
+/* Conflict with STL_port inline implementation */
+#if 0
+/* UNICODE version */
+_SNPRINTF_DLLIMPORT int __cdecl vsnwprintf( wchar_t *buffer, size_t count, const wchar_t *format, va_list ap );
+
+/* SBCS and MBCS version */
+_SNPRINTF_DLLIMPORT int __cdecl vsnprintf( char *buffer, size_t count, const char *format, va_list ap );
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNPRINTF_H */
diff --git a/sal/inc/systools/win32/user9x.h b/sal/inc/systools/win32/user9x.h
new file mode 100644
index 000000000000..da30bf222836
--- /dev/null
+++ b/sal/inc/systools/win32/user9x.h
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the winuser.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef SendMessageW
+#undef SendMessageW
+#endif
+
+#ifdef CreateWindowExW
+#undef CreateWindowExW
+#endif
+
+#ifdef RegisterClassExW
+#undef RegisterClassExW
+#endif
+
+#ifdef UnregisterClassW
+#undef UnregisterClassW
+#endif
+
+#ifdef RegisterClipboardFormatW
+#undef RegisterClipboardFormatW
+#endif
+
+#ifdef GetClipboardFormatNameW
+#undef GetClipboardFormatNameW
+#endif
+
+#ifdef SetWindowTextW
+#undef SetWindowTextW
+#endif
+
+#ifdef GetWindowTextW
+#undef GetWindowTextW
+#endif
+
+#ifdef InsertMenuItemW
+#undef InsertMenuItemW
+#endif
+
+#ifndef DrawTextW
+#undef DrawTextW
+#endif
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define USER9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate user32 functions
+//------------------------------------------------------------------------
+
+USER9X_API LRESULT ( WINAPI * lpfnSendMessageW) (
+ HWND hWnd, // handle to the destination window
+ UINT Msg, // message
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+);
+
+USER9X_API HWND ( WINAPI * lpfnCreateWindowExW ) (
+ DWORD dwExStyle, // extended window style
+ LPCWSTR lpClassName, // registered class name
+ LPCWSTR lpWindowName, // window name
+ DWORD dwStyle, // window style
+ int x, // horizontal position of window
+ int y, // vertical position of window
+ int nWidth, // window width
+ int nHeight, // window height
+ HWND hWndParent, // handle to parent or owner window
+ HMENU hMenu, // menu handle or child identifier
+ HINSTANCE hInstance, // handle to application instance
+ LPVOID lpParam // window-creation data
+);
+
+USER9X_API ATOM ( WINAPI * lpfnRegisterClassExW ) (
+ CONST WNDCLASSEXW* lpwcx // class data
+);
+
+USER9X_API BOOL ( WINAPI * lpfnUnregisterClassW ) (
+ LPCWSTR lpClassName, // class name
+ HINSTANCE hInstance // handle to application instance
+);
+
+USER9X_API UINT (WINAPI * lpfnRegisterClipboardFormatW) (
+ LPCWSTR lpszFormat // name of new format
+);
+
+USER9X_API int ( WINAPI * lpfnGetClipboardFormatNameW ) (
+ UINT format, // clipboard format to retrieve
+ LPWSTR lpszFormatName, // format name
+ int cchMaxCount // length of format name buffer
+);
+
+USER9X_API BOOL ( WINAPI * lpfnSetWindowTextW ) (
+ HWND hWnd,
+ LPCWSTR lpString
+);
+
+USER9X_API int ( WINAPI * lpfnGetWindowTextW ) (
+ HWND hWnd, // handle to the window or control
+ LPWSTR lpString, // text buffer
+ int nMaxCount // length of text buffer
+);
+
+USER9X_API BOOL ( WINAPI * lpfnInsertMenuItemW ) (
+ HMENU hMenu, // handle to menu
+ UINT uItem, // identifier or position
+ BOOL fByPosition, // meaning of uItem
+ LPCMENUITEMINFOW lpmii // menu item information
+);
+
+USER9X_API int ( WINAPI * lpfnDrawTextW ) (
+ HDC hDC, // handle to DC
+ LPCWSTR lpString, // text to draw
+ int nCount, // text length
+ LPRECT lpRect, // formatting dimensions
+ UINT uFormat // text-drawing options
+);
+
+USER9X_API BOOL ( WINAPI * lpfnDrawStateW ) (
+ HDC hdc, // handle to device context
+ HBRUSH hbr, // handle to brush
+ DRAWSTATEPROC lpOutputFunc, // callback function
+ LPARAM lData, // image information
+ WPARAM wData, // more image information
+ int x, // horizontal location
+ int y, // vertical location
+ int cx, // image width
+ int cy, // image height
+ UINT fuFlags // image type and state
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define SendMessageW lpfnSendMessageW
+#define CreateWindowExW lpfnCreateWindowExW
+#define RegisterClassExW lpfnRegisterClassExW
+#define UnregisterClassW lpfnUnregisterClassW
+#define RegisterClipboardFormatW lpfnRegisterClipboardFormatW
+#define GetClipboardFormatNameW lpfnGetClipboardFormatNameW
+#define SetWindowTextW lpfnSetWindowTextW
+#define GetWindowTextW lpfnGetWindowTextW
+#define InsertMenuItemW lpfnInsertMenuItemW
+#define DrawTextW lpfnDrawTextW
+#define DrawStateW lpfnDrawStateW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/uwinapi.h b/sal/inc/systools/win32/uwinapi.h
new file mode 100644
index 000000000000..8c55ae6cf275
--- /dev/null
+++ b/sal/inc/systools/win32/uwinapi.h
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifdef _UWINAPI_
+# define _KERNEL32_
+# define _USER32_
+# define _SHELL32_
+#endif
+
+#ifndef _WINDOWS_
+#ifdef _MSC_VER
+# pragma warning(push,1) /* disable warnings within system headers */
+#endif
+# include <windows.h>
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+#endif
+
+#ifdef __MINGW32__
+#include <basetyps.h>
+#ifdef _UWINAPI_
+#define WINBASEAPI
+#endif
+#endif
+
+/** GetUserDomain
+
+The GetUserDomain function retrieves the name of the NT domain the user is
+logged in.
+
+Parameters
+ @param lpBuffer
+ [out] Pointer to a buffer that receives a null-terminated string
+ containing the domain name.
+ @param nBufferSize
+ [in] Specifies the size, in TCHARs, of the buffer pointed to
+ by the lpBuffer parameter.
+
+
+Return Values
+ @return
+ If the function succeeds, the return value is the number of TCHARs stored
+ into the buffer pointed to by lpBuffer, not including the terminating
+ null character.
+
+ If the domain name can't be retrieved, the return value is zero.
+
+ If the buffer pointed to by lpBuffer is not large enough, the return value
+ is the buffer size, in TCHARs, required to hold the value string and its
+ terminating null character.
+
+Remarks
+ Windows 95/98/Me: If the user is not logged in onto a NT domain server
+ the name of the workgroup is returned.
+
+Requirements
+ Windows NT/2000/XP: Included in Windows NT 4 and later.
+ Windows 95/98/Me: Included in Windows 95 and later.
+ Header: Declared in Uwinapi.h; include Uwinapi.h.
+ Library: Use Uwinapi.lib.
+ Unicode: Implemented as Unicode and ANSI versions on Windows 95/98/Me/NT/2000/XP.
+
+See Also
+@see
+*/
+
+EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainA( LPSTR lpBuffer, DWORD nBuffserSize );
+EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainW( LPWSTR lpBuffer, DWORD nBuffserSize );
+
+#ifdef UNICODE
+#define GetUserDomain GetUserDomainW
+#else
+#define GetUserDomain GetUserDomainA
+#endif
+
+EXTERN_C WINBASEAPI DWORD WINAPI GetProcessId( HANDLE hProcess );
+
+/* macro that calculates the count of elements of a static array */
+
+#define elementsof(buf) (sizeof(buf) / sizeof((buf)[0]))
+
+#ifdef __cplusplus
+
+inline bool IsValidHandle(HANDLE handle)
+{
+ return handle != INVALID_HANDLE_VALUE && handle != NULL;
+}
+
+#else /* __cplusplus */
+
+#define IsValidHandle(Handle) ((DWORD)(Handle) + 1 > 1)
+
+#endif /* __cplusplus */
+