diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-11-23 21:41:21 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-11-23 21:43:31 +0100 |
commit | b73abe292eda22c2332ff819a1ca5f66d0ee7d9f (patch) | |
tree | c7d5fa57956fcdd7dca456d643d38e33713ccecb /sal | |
parent | f337e95fb50c9edc10aca859aaf08baab5294d2e (diff) |
Remove dead sal/workben/ stuff
All this is probably dead for ages, yet it repeatedly got modified over the
years by clean-up commits, be they driven by cppunit or grep.
Change-Id: I69443f5b25f24bb5735e7179c915f27b4742fcb5
Diffstat (limited to 'sal')
42 files changed, 0 insertions, 7145 deletions
diff --git a/sal/workben/clipboardwben/testcopy/StdAfx.cpp b/sal/workben/clipboardwben/testcopy/StdAfx.cpp deleted file mode 100644 index bac4b51b2b25..000000000000 --- a/sal/workben/clipboardwben/testcopy/StdAfx.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// stdafx.cpp : source file which only includes the standard header files -// TestWin32.pch is a pre-compiled header file -// stdafx.obj contains the pre-compiled type information - -#include "stdafx.h" - -// TO DO: Reference all additional header files required by STDAFX.H -// rather than by this file - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testcopy/StdAfx.h b/sal/workben/clipboardwben/testcopy/StdAfx.h deleted file mode 100644 index 10768f6e7c60..000000000000 --- a/sal/workben/clipboardwben/testcopy/StdAfx.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -// stdafx.h : Include-Datei für Standard-System-Include-Dateien, -// oder projektspezifische Include-Dateien, die häufig benutzt, aber -// in unregelmässigen Abständen geandert werden. - -#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) -#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden - -// Windows-Header-Dateien: -#include <windows.h> - -// Header-Dateien der C-Laufzeit -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> - -// Lokale Header-Dateien - -// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein. - -#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testcopy/TestWin32.ico b/sal/workben/clipboardwben/testcopy/TestWin32.ico Binary files differdeleted file mode 100644 index 255ff3be4fba..000000000000 --- a/sal/workben/clipboardwben/testcopy/TestWin32.ico +++ /dev/null diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx deleted file mode 100644 index 9a5ea91424f0..000000000000 --- a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx +++ /dev/null @@ -1,388 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/diagnose.h> - -#include "XTDataObject.hxx" - -#include <windows.h> -#include <ole2.h> - -// OTWrapperDataObject - -CXTDataObject::CXTDataObject( LONG nRefCntInitVal ) : - m_nRefCnt( nRefCntInitVal ) -{ -} - -CXTDataObject::~CXTDataObject( ) -{ -} - -// IUnknown->QueryInterface - -STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject ) -{ - OSL_ASSERT( NULL != ppvObject ); - - if ( NULL == ppvObject ) - return E_INVALIDARG; - - HRESULT hr = E_NOINTERFACE; - - *ppvObject = NULL; - - if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) ) - { - *ppvObject = static_cast< IUnknown* >( this ); - ( (LPUNKNOWN)*ppvObject )->AddRef( ); - hr = S_OK; - } - - return hr; -} - -// IUnknown->AddRef - -STDMETHODIMP_(ULONG) CXTDataObject::AddRef( ) -{ - return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) ); -} - -// IUnknown->Release - -STDMETHODIMP_(ULONG) CXTDataObject::Release( ) -{ - // we need a helper variable because it's - // not allowed to access a member variable - // after an object is destroyed - ULONG nRefCnt = static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) ); - - if ( 0 == nRefCnt ) - { - delete this; - } - - return nRefCnt; -} - -// IDataObject->GetData -// warning: 'goto' ahead (to easy error handling without using exceptions) - -STDMETHODIMP CXTDataObject::GetData(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ) -{ - OSL_ASSERT( ( NULL != pFormatetc ) && - ( !IsBadReadPtr( (LPVOID)pFormatetc, sizeof( FORMATETC ) ) ) ); - OSL_ASSERT( ( NULL != pmedium ) && - ( !IsBadWritePtr( (LPVOID)pmedium, sizeof( STGMEDIUM ) ) ) ); - - if ( ( NULL == pFormatetc ) || ( NULL == pmedium ) ) - return E_INVALIDARG; - - HRESULT hr = E_FAIL; - - if ( CF_TEXT == pFormatetc->cfFormat ) - { - LPSTREAM lpStream; - - hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream ); - if ( SUCCEEDED( hr ) ) - { - char buff[] = "Hello World, How are you!"; - - hr = lpStream->Write( buff, sizeof( buff ) * sizeof( char ), NULL ); - if ( SUCCEEDED( hr ) ) - { - HGLOBAL hGlob; - - GetHGlobalFromStream( lpStream, &hGlob ); - - pmedium->tymed = TYMED_HGLOBAL; - pmedium->hGlobal = hGlob; - pmedium->pUnkForRelease = NULL; - } - lpStream->Release( ); - hr = S_OK; - } - else - { - pmedium->tymed = TYMED_NULL; - } - } - else if ( CF_UNICODETEXT == pFormatetc->cfFormat ) - { - WCHAR buff[] = L"Hello World, How are you!"; - LPSTREAM lpStream; - - hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream ); - if ( SUCCEEDED( hr ) ) - { - hr = lpStream->Write( buff, sizeof( buff ) * sizeof( WCHAR ), NULL ); - if ( SUCCEEDED( hr ) ) - { - HGLOBAL hGlob; - - GetHGlobalFromStream( lpStream, &hGlob ); - - pmedium->tymed = TYMED_HGLOBAL; - pmedium->hGlobal = hGlob; - pmedium->pUnkForRelease = NULL; - } - lpStream->Release( ); - hr = S_OK; - } - else - { - pmedium->tymed = TYMED_NULL; - } - } - - return hr; -} - -// IDataObject->EnumFormatEtc - -STDMETHODIMP CXTDataObject::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc ) -{ - if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) ) - return E_INVALIDARG; - - *ppenumFormatetc = NULL; - - HRESULT hr = E_FAIL; - - if ( DATADIR_GET == dwDirection ) - { - *ppenumFormatetc = new CEnumFormatEtc( this ); - static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( ); - hr = S_OK; - } - - return hr; -} - -// IDataObject->QueryGetData - -STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc ) -{ - return E_NOTIMPL; -} - -// IDataObject->GetDataHere - -STDMETHODIMP CXTDataObject::GetDataHere( LPFORMATETC, LPSTGMEDIUM ) -{ - return E_NOTIMPL; -} - -// IDataObject->GetCanonicalFormatEtc - -STDMETHODIMP CXTDataObject::GetCanonicalFormatEtc( LPFORMATETC, LPFORMATETC ) -{ - return E_NOTIMPL; -} - -// IDataObject->SetData - -STDMETHODIMP CXTDataObject::SetData( LPFORMATETC, LPSTGMEDIUM, BOOL ) -{ - return E_NOTIMPL; -} - -// IDataObject->DAdvise - -STDMETHODIMP CXTDataObject::DAdvise( LPFORMATETC, DWORD, LPADVISESINK, DWORD * ) -{ - return E_NOTIMPL; -} - -// IDataObject->DUnadvise - -STDMETHODIMP CXTDataObject::DUnadvise( DWORD ) -{ - return E_NOTIMPL; -} - -// IDataObject->EnumDAdvise - -STDMETHODIMP CXTDataObject::EnumDAdvise( LPENUMSTATDATA * ) -{ - return E_NOTIMPL; -} - -// for our convenience - -CXTDataObject::operator IDataObject*( ) -{ - return static_cast< IDataObject* >( this ); -} - -// CEnumFormatEtc - -CEnumFormatEtc::CEnumFormatEtc( LPUNKNOWN pUnkDataObj ) : - m_nRefCnt( 0 ), - m_pUnkDataObj( pUnkDataObj ), - m_nCurrentPos( 0 ) -{ - m_cfFormats[0] = CF_UNICODETEXT; - m_cfFormats[1] = CF_TEXT; -} - -CEnumFormatEtc::~CEnumFormatEtc( ) -{ -} - -// IUnknown->QueryInterface - -STDMETHODIMP CEnumFormatEtc::QueryInterface( REFIID iid, LPVOID* ppvObject ) -{ - if ( NULL == ppvObject ) - return E_INVALIDARG; - - HRESULT hr = E_NOINTERFACE; - - *ppvObject = NULL; - - if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IEnumFORMATETC ) == iid ) ) - { - *ppvObject = static_cast< IUnknown* >( this ); - static_cast< LPUNKNOWN >( *ppvObject )->AddRef( ); - hr = S_OK; - } - - return hr; -} - -// IUnknown->AddRef - -STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef( ) -{ - // keep the dataobject alive - m_pUnkDataObj->AddRef( ); - return InterlockedIncrement( &m_nRefCnt ); -} - -// IUnknown->Release - -STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( ) -{ - // release the outer dataobject - m_pUnkDataObj->Release( ); - - // we need a helper variable because it's - // not allowed to access a member variable - // after an object is destroyed - ULONG nRefCnt = InterlockedDecrement( &m_nRefCnt ); - if ( 0 == nRefCnt ) - delete this; - - return nRefCnt; -} - -// IEnumFORMATETC->Next - -STDMETHODIMP CEnumFormatEtc::Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched ) -{ - OSL_ASSERT( ( ( celt > 0 ) && ( NULL != rgelt ) ) || - ( ( 0 == celt ) && ( NULL == rgelt ) ) ); - - if ( ( 0 != celt ) && ( NULL == rgelt ) ) - return E_INVALIDARG; - - ULONG ulFetched = 0; - ULONG ulToFetch = celt; - HRESULT hr = S_FALSE; - - while( ( m_nCurrentPos < sizeof( m_cfFormats ) ) && ( ulToFetch > 0 ) ) - { - OSL_ASSERT( !IsBadWritePtr( (LPVOID)rgelt, sizeof( FORMATETC ) ) ); - - rgelt->cfFormat = m_cfFormats[m_nCurrentPos]; - rgelt->ptd = NULL; - rgelt->dwAspect = DVASPECT_CONTENT; - rgelt->lindex = -1; - rgelt->tymed = TYMED_HGLOBAL; - - ++m_nCurrentPos; - ++rgelt; - --ulToFetch; - ++ulFetched; - } - - if ( ulFetched == celt ) - hr = S_OK; - - if ( NULL != pceltFetched ) - { - OSL_ASSERT( !IsBadWritePtr( (LPVOID)pceltFetched, sizeof( ULONG ) ) ); - *pceltFetched = ulFetched; - } - - return hr; -} - -// IEnumFORMATETC->Skip - -STDMETHODIMP CEnumFormatEtc::Skip( ULONG celt ) -{ - HRESULT hr = S_FALSE; - - if ( ( m_nCurrentPos + celt ) < sizeof( m_cfFormats ) ) - { - m_nCurrentPos += celt; - hr = S_OK; - } - - return hr; -} - -// IEnumFORMATETC->Reset - -STDMETHODIMP CEnumFormatEtc::Reset( ) -{ - m_nCurrentPos = 0; - return S_OK; -} - -// IEnumFORMATETC->Clone - -STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum ) -{ - OSL_ASSERT( NULL != ppenum ); - - if ( NULL == ppenum ) - return E_INVALIDARG; - - HRESULT hr = E_FAIL; - - *ppenum = NULL; - - CEnumFormatEtc* pCEnumFEtc = new CEnumFormatEtc( m_pUnkDataObj ); - if ( NULL != pCEnumFEtc ) - { - pCEnumFEtc->m_nCurrentPos = m_nCurrentPos; - *ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc ); - static_cast< LPUNKNOWN >( *ppenum )->AddRef( ); - hr = NOERROR; - } - - return hr; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.hxx b/sal/workben/clipboardwben/testcopy/XTDataObject.hxx deleted file mode 100644 index 3b71d78d7adb..000000000000 --- a/sal/workben/clipboardwben/testcopy/XTDataObject.hxx +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SAL_WORKBEN_CLIPBOARDWBEN_TESTCOPY_XTDATAOBJECT_HXX -#define INCLUDED_SAL_WORKBEN_CLIPBOARDWBEN_TESTCOPY_XTDATAOBJECT_HXX - -/* -#include <com/sun/star/datatransfer/XTransferable.hpp> -#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> -#include "WinClipboard.hxx" -*/ - -#include <windows.h> -#include <ole2.h> -#include <objidl.h> - -class EnumFormatEtc; - -class CXTDataObject : public IDataObject -{ -public: - explicit CXTDataObject(LONG nRefCntInitVal = 0); - ~CXTDataObject( ); - - // ole interface implementation - - //IUnknown - STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject); - STDMETHODIMP_( ULONG ) AddRef( ); - STDMETHODIMP_( ULONG ) Release( ); - - //IDataObject - STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); - STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium ); - STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc ); - STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut ); - STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease ); - STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc ); - STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection ); - STDMETHODIMP DUnadvise( DWORD dwConnection ); - STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise ); - - operator IDataObject*( ); - - // notification handler - //void SAL_CALL LostOwnership( ); - - //sal_Int64 SAL_CALL QueryDataSize( ); - - // retrieve the data from the source - // necessary so that - //void SAL_CALL GetAllDataFromSource( ); - -private: - LONG m_nRefCnt; - //CWinClipboard& m_rCWinClipboard; - //const const css::uno::Reference< css::datatransfer::clipboard::XClipboardOwner >& m_rXClipboardOwner; - //const const css::uno::Reference< css::datatransfer::XTransferable >& m_rXTDataSource; - - //friend class CWinClipboard; - friend class CEnumFormatEtc; -}; - -class CEnumFormatEtc : public IEnumFORMATETC -{ -public: - explicit CEnumFormatEtc(LPUNKNOWN pUnkDataObj); - ~CEnumFormatEtc( ); - - // IUnknown - STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject ); - STDMETHODIMP_( ULONG ) AddRef( ); - STDMETHODIMP_( ULONG ) Release( ); - - //IEnumFORMATETC - STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched ); - STDMETHODIMP Skip( ULONG celt ); - STDMETHODIMP Reset( ); - STDMETHODIMP Clone( IEnumFORMATETC** ppenum ); - -private: - LONG m_nRefCnt; - LPUNKNOWN m_pUnkDataObj; - ULONG m_nCurrentPos; - CLIPFORMAT m_cfFormats[2]; -}; - -typedef CEnumFormatEtc *PCEnumFormatEtc; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testcopy/cbcpytest.cxx b/sal/workben/clipboardwben/testcopy/cbcpytest.cxx deleted file mode 100644 index 27f0fe204dd0..000000000000 --- a/sal/workben/clipboardwben/testcopy/cbcpytest.cxx +++ /dev/null @@ -1,348 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// TestWin32.cpp : Defines the entry point for the application. - -#define _WIN32_DCOM -#undef _UNICODE - -#include "stdafx.h" - -#include <windows.h> - -#include <ole2.h> -#include <objidl.h> -#include <objbase.h> -#include <process.h> -#include <olectl.h> -#include <stdlib.h> -#include <malloc.h> -#include <..\..\inc\systools\win32\MtaOleClipb.h> -#include "XTDataObject.hxx" - -#include "resource.h" - -#define MAX_LOADSTRING 100 -#undef USE_MTACB - -#define MSG_FLUSHCLIPBOARD WM_USER + 1 - -// Global variables: -HINSTANCE hInst; // current instance -TCHAR szTitle[MAX_LOADSTRING]; // Text of the title -TCHAR szWindowClass[MAX_LOADSTRING]; // Text of the title -ATOM MyRegisterClass( HINSTANCE hInstance ); -BOOL InitInstance( HINSTANCE, int ); -LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); -LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM ); -void CopyClipboardData(HWND hwndParent); -void FlushClipboard( ); -void PasteData( HWND hWnd ); -void SetLocale(); - -LPSTREAM g_pStm = NULL; -char* pTextBuff = NULL; -DWORD lData = 0; -CXTDataObject* g_xtDo = NULL; -HWND g_hWnd; -HANDLE g_hEvent; -BOOL g_bEnd; - -// a thread function - -unsigned int _stdcall ThreadProc(LPVOID pParam) -{ - while( !g_bEnd ) - { - WaitForSingleObject( g_hEvent, INFINITE ); - SendMessage( g_hWnd, MSG_FLUSHCLIPBOARD, WPARAM(0), LPARAM(0) ); - } - - return 0; -} - -// WinMain - -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow ) -{ - // TODO: Add code here. - MSG msg; - HACCEL hAccelTable; - HRESULT hr = E_FAIL; - - // it's important to initialize ole - // in order to use the clipboard -#ifdef USE_MTACB - hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); -#else - hr = OleInitialize( NULL ); -#endif - - // Initialize global strings - LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadString(hInstance, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING); - MyRegisterClass(hInstance); - - // Initialization of the applications to carry out: - if( !InitInstance( hInstance, nCmdShow ) ) - { - return FALSE; - } - - hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN32); - - // Main message loop: - while( GetMessage(&msg, NULL, 0, 0) ) - { - if( !TranslateAccelerator (msg.hwnd, hAccelTable, &msg) ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - - // uninitializing the ole libraries -#ifdef USE_MTACB - CoUninitialize( ); -#else - OleUninitialize( ); -#endif - - CloseHandle( g_hEvent ); - - return msg.wParam; -} - -// FUNCTION: MyRegisterClass() -// -// PURPOSE: Registers the window class. -// -// COMMENTS: -// This function and its usage are only necessary if this code -// needs to be compatible with Win32 systems prior to 'RegisterClassEx' -// function, which was added to Windows 95. If it important to call -// this function to allow the use of small icons in the correct proportions. - -ATOM MyRegisterClass( HINSTANCE hInstance ) -{ - WNDCLASSEX wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = (WNDPROC)WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN32); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = (LPCTSTR)IDC_TESTWIN32; - wcex.lpszClassName = _T(szWindowClass); - wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); - - return RegisterClassEx(&wcex); -} - -// FUNCTION: InitInstance(HANDLE, int) -// -// PURPOSE: Saves instance access number and creates main window -// -// Comments: -// In this function, the instance access number is stored in a global variable -// and the main program window is displayed. - -BOOL InitInstance( HINSTANCE hInstance, int nCmdShow ) -{ - hInst = hInstance; // Store instance access number in our global variable. - - g_hWnd = CreateWindowEx(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); - - if( !g_hWnd ) - { - return FALSE; - } - - ShowWindow( g_hWnd, nCmdShow ); - UpdateWindow( g_hWnd ); - - return TRUE; -} - -// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) -// -// PURPOSE: Processes messages for the main window. -// -// WM_COMMAND - Handle application menu -// WM_PAINT - Display main windows -// WM_DESTROY - Output completion message and return - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId; - PAINTSTRUCT ps; - HDC hdc; - TCHAR szHello[MAX_LOADSTRING]; - - LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); - - switch( message ) - { - case WM_COMMAND: - wmId = LOWORD(wParam); - // Analyze menu selections: - switch( wmId ) - { - case IDD_COPY: - CopyClipboardData(hWnd); - break; - case IDD_PASTE2: - PasteData(hWnd); - break; - case IDD_LOCALE: - SetLocale(); - break; - case IDM_EXIT: - DestroyWindow( hWnd ); - break; - - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } - break; - - case WM_PAINT: - hdc = BeginPaint (hWnd, &ps); - // TODO: Add any code for drawing - RECT rt; - GetClientRect( hWnd, &rt ); - - if ( NULL != pTextBuff ) - { - DrawText( hdc, pTextBuff, lData, &rt, DT_CENTER ); - } - else - { - DrawText( hdc, szHello, strlen(szHello), &rt, DT_CENTER ); - } - - EndPaint( hWnd, &ps ); - break; - - case WM_DESTROY: - g_bEnd = TRUE; - SetEvent( g_hEvent ); - FlushClipboard( ); - PostQuitMessage( 0 ); - break; - - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } - return 0; -} - -// copy data into the clipboard - -void CopyClipboardData( HWND hWnd ) -{ - g_xtDo = new CXTDataObject( 1 ); -#ifdef USE_MTACB - MTASetClipboard( static_cast< IDataObject* >( g_xtDo ) ); -#else - OleSetClipboard( static_cast< IDataObject* >( g_xtDo ) ); -#endif -} - -// flush the content into the clipboard - -void FlushClipboard( ) -{ - if ( NULL != g_xtDo ) - { -#ifdef USE_MTACB - HRESULT hr = MTAIsCurrentClipboard( static_cast< IDataObject* >( g_xtDo ) ); - if ( S_OK == hr ) - MTAFlushClipboard( ); -#else - HRESULT hr = OleIsCurrentClipboard( static_cast< IDataObject* >( g_xtDo ) ); - if ( S_OK == hr ) - OleFlushClipboard( ); -#endif - - static_cast< IDataObject* >( g_xtDo )->Release( ); - } -} - -void PasteData(HWND hWnd) -{ - IDataObject* pDataObj; - - //FlushClipboard( ); - - HRESULT hr = OleGetClipboard( &pDataObj ); - if ( SUCCEEDED( hr ) ) - { - FORMATETC fetc; - STGMEDIUM stgmedium; - - fetc.cfFormat = CF_LOCALE; - fetc.ptd = NULL; - fetc.dwAspect = DVASPECT_CONTENT; - fetc.lindex = -1; - fetc.tymed = TYMED_HGLOBAL; - - hr = pDataObj->GetData( &fetc, &stgmedium ); - if ( SUCCEEDED( hr ) ) - { - LPVOID lpData = GlobalLock( stgmedium.hGlobal ); - - if ( NULL != lpData ) - { - LCID lcid = *( (WORD*)lpData ); - - WORD langID = LANGIDFROMLCID( lcid ); - WORD sublangID = SUBLANGID( langID ); - - TCHAR buff[6]; - int cbWritten = GetLocaleInfo( lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof( buff ) ); - cbWritten = GetLocaleInfo( lcid, LOCALE_IDEFAULTCODEPAGE, buff, sizeof( buff ) ); - - GlobalUnlock( stgmedium.hGlobal ); - } - else - { - DWORD dwLastError = GetLastError( ); - } - - ReleaseStgMedium( &stgmedium ); - } - } -} - -void SetLocale() -{ - LCID threadLcid = GetThreadLocale(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testcopy/cbcpytest.rc b/sal/workben/clipboardwben/testcopy/cbcpytest.rc deleted file mode 100644 index fba2f72a8472..000000000000 --- a/sal/workben/clipboardwben/testcopy/cbcpytest.rc +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -//Microsoft Developer Studio generated resource script. - -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS - - -// Generated from the TEXTINCLUDE 2 resource. - -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -#include "resource.h" - - -#undef APSTUDIO_READONLY_SYMBOLS - - -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - - - -// Icon - - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_TESTWIN32 ICON DISCARDABLE "TestWin32.ICO" -IDI_SMALL ICON DISCARDABLE "SMALL.ICO" - - - -// Menu - - -IDC_TESTWIN32 MENU DISCARDABLE -BEGIN - POPUP "&Datei" - BEGIN - MENUITEM "&Copy", IDD_COPY - MENUITEM "Paste", IDD_PASTE2 - MENUITEM "Set Locale", IDD_LOCALE - MENUITEM SEPARATOR - MENUITEM "&Beenden", IDM_EXIT - END -END - - - - -// Accelerator - - -IDC_TESTWIN32 ACCELERATORS MOVEABLE PURE -BEGIN - "?", IDM_ABOUT, ASCII, ALT - "/", IDM_ABOUT, ASCII, ALT -END - - -#ifdef APSTUDIO_INVOKED - - -// TEXTINCLUDE - - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""resource.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -#endif // APSTUDIO_INVOKED - - - - -// String Table - - -STRINGTABLE DISCARDABLE -BEGIN - IDS_APP_TITLE "TestWin32" - IDS_HELLO "Hallo Welt!" - IDC_TESTWIN32 "TESTWIN32" -END - -#endif // German (Germany) resources - - - - -#ifndef APSTUDIO_INVOKED - - -// Generated from the TEXTINCLUDE 3 resource. - - - - -#endif // not APSTUDIO_INVOKED - diff --git a/sal/workben/clipboardwben/testcopy/makefile.mk b/sal/workben/clipboardwben/testcopy/makefile.mk deleted file mode 100644 index 17e0764c4748..000000000000 --- a/sal/workben/clipboardwben/testcopy/makefile.mk +++ /dev/null @@ -1,58 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ=..$/..$/.. - -PRJNAME=sal -TARGET=cbcpytest -LIBTARGET=NO - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -CFLAGS+= $(LFS_CFLAGS) -CXXFLAGS+= $(LFS_CFLAGS) - -# --- Files -------------------------------------------------------- - -# -# test clipboard paste -# - # --- Resources ---------------------------------------------------- - RCFILES= cbcpytest.rc - - OBJFILES= $(OBJ)$/cbcpytest.obj $(OBJ)$/XTDataObject.obj - - APP1TARGET= $(TARGET) - APP1OBJS= $(OBJFILES) - APP1NOSAL= TRUE - APP1NOSVRES= $(RES)$/$(TARGET).res - - APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB) $(SALLIB) - - APP1LIBS=$(LB)$/iole9x.lib \ - $(LB)$/tools32.lib - - APP1DEPN= makefile.mk $(APP1NOSVRES) - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - - diff --git a/sal/workben/clipboardwben/testcopy/resource.h b/sal/workben/clipboardwben/testcopy/resource.h deleted file mode 100644 index 1c8fac62c973..000000000000 --- a/sal/workben/clipboardwben/testcopy/resource.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by cbcpytest.rc - -#define IDC_MYICON 2 -#define IDD_TESTWIN32_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDS_APP_TITLE 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDS_HELLO 106 -#define IDI_TESTWIN32 107 -#define IDI_SMALL 108 -#define IDC_TESTWIN32 109 -#define IDR_MAINFRAME 128 -#define IDD_PASTE 32771 -#define IDD_COPY 32771 -#define IDD_PASTE2 32772 -#define IDD_LOCALE 32773 -#define IDC_STATIC -1 - -// Next default values for new objects - -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32774 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testcopy/small.ico b/sal/workben/clipboardwben/testcopy/small.ico Binary files differdeleted file mode 100644 index 8f94d9aa8285..000000000000 --- a/sal/workben/clipboardwben/testcopy/small.ico +++ /dev/null diff --git a/sal/workben/clipboardwben/testpaste/StdAfx.cpp b/sal/workben/clipboardwben/testpaste/StdAfx.cpp deleted file mode 100644 index 635136666af7..000000000000 --- a/sal/workben/clipboardwben/testpaste/StdAfx.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet -// TestWin32.pch ist die vorkompilierte Header-Datei -// stdafx.obj enthlt die vorkompilierte Typinformation - -#include "stdafx.h" - -// ZU ERLEDIGEN: Verweis auf alle zustzlichen Header-Dateien, die Sie in STDAFX.H -// und nicht in dieser Datei bentigen - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testpaste/StdAfx.h b/sal/workben/clipboardwben/testpaste/StdAfx.h deleted file mode 100644 index 9a5dc4dc525d..000000000000 --- a/sal/workben/clipboardwben/testpaste/StdAfx.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -// stdafx.h : Include-Datei für Standard-System-Include-Dateien, -// oder projektspezifische Include-Dateien, die häufig benutzt, aber -// in unregelmäßigen Abständen geändert werden. - -#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) -#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden - -// Windows-Header-Dateien: -#include <windows.h> - -// Header-Dateien der C-Laufzeit -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> - -// Lokale Header-Dateien - -// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein. - -#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testpaste/TestWin32.ico b/sal/workben/clipboardwben/testpaste/TestWin32.ico Binary files differdeleted file mode 100644 index 255ff3be4fba..000000000000 --- a/sal/workben/clipboardwben/testpaste/TestWin32.ico +++ /dev/null diff --git a/sal/workben/clipboardwben/testpaste/cbptest.cxx b/sal/workben/clipboardwben/testpaste/cbptest.cxx deleted file mode 100644 index dfdbad1c344b..000000000000 --- a/sal/workben/clipboardwben/testpaste/cbptest.cxx +++ /dev/null @@ -1,404 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// TestWin32.cpp : Defines the entry point for the application - -#define _WIN32_DCOM - -#include "stdafx.h" - -#include <windows.h> - -#include <ole2.h> -#include <objidl.h> -#include <objbase.h> -#include <process.h> -#include <olectl.h> -#include <stdlib.h> -#include <malloc.h> -#include <..\..\inc\systools\win32\MtaOleClipb.h> - -#include "resource.h" - -#define MAX_LOADSTRING 100 - -// Global variables: -HINSTANCE hInst; // current instance -WCHAR szTitle[MAX_LOADSTRING]; // Text for title -WCHAR szWindowClass[MAX_LOADSTRING]; // Text for title -ATOM MyRegisterClass( HINSTANCE hInstance ); -BOOL InitInstance( HINSTANCE, int ); -LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); -LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM ); -void PasteClipboardData(HWND hwndParent); -void PasteClipboardData2(HWND hwndParent); - -LPSTREAM g_pStm = NULL; -char* pTextBuff = NULL; -DWORD lData = 0; - -// a thread function - -unsigned int _stdcall ThreadProc(LPVOID pParam) -{ - IDataObject* pIDataObj = NULL; - FORMATETC formatETC; - STGMEDIUM stgMedium; - LPVOID pGlobMem; - HWND hwnd; - DWORD sizeGlobBuff; - HRESULT hr; - - hwnd = (HWND)pParam; - - OleInitialize( NULL ); - - hr = OleGetClipboard( &pIDataObj ); - - hr = CoGetInterfaceAndReleaseStream( - g_pStm, - __uuidof(IDataObject), - reinterpret_cast<LPVOID*>(&pIDataObj)); - - formatETC.cfFormat = CF_TEXT; - formatETC.ptd = NULL; - formatETC.dwAspect = DVASPECT_CONTENT; - formatETC.lindex = -1; - formatETC.tymed = TYMED_HGLOBAL; - - hr = pIDataObj->GetData( &formatETC, &stgMedium ); - pGlobMem = GlobalLock( stgMedium.hGlobal ); - if ( NULL != pGlobMem ) - { - if ( NULL != pTextBuff ) - { - free( pTextBuff ); - } - - sizeGlobBuff = GlobalSize( stgMedium.hGlobal ); - pTextBuff = (char*)malloc( sizeGlobBuff + 1 ); - ZeroMemory( pTextBuff, sizeGlobBuff + 1 ); - - memcpy( pTextBuff, pGlobMem, sizeGlobBuff ); - lData = sizeGlobBuff; - - InvalidateRect( hwnd, NULL, TRUE ); - UpdateWindow( hwnd ); - } - - GlobalUnlock( stgMedium.hGlobal ); - - ReleaseStgMedium( &stgMedium ); - - pIDataObj->Release(); - - //CoUninitialize( ); - - OleUninitialize( ); - - return 0; -} - -// WinMain - -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow ) -{ - // TODO: Add code here. - MSG msg; - HACCEL hAccelTable; - HRESULT hr = E_FAIL; - - // it's important to initialize ole - // in order to use the clipboard - //hr = OleInitialize( NULL ); - hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); - //hr = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ); - - // Initialize global strings - LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadStringW(hInstance, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING); - MyRegisterClass(hInstance); - - // Initialization of the application to perform: - if( !InitInstance( hInstance, nCmdShow ) ) - { - return FALSE; - } - - hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN32); - - // Main message loop: - while( GetMessage(&msg, NULL, 0, 0) ) - { - if( !TranslateAccelerator (msg.hwnd, hAccelTable, &msg) ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - - // uninitializing the ole libraries - //OleUninitialize( ); - CoUninitialize( ); - - return msg.wParam; -} - -// -// FUNCTION: MyRegisterClass() -// -// PURPOSE: Registers the window class -// -// COMMENTS: -// This function and its usage are only necessary if this code -// needs to be compatible with Win32 systems prior to 'RegisterClassEx' -// function, which was added to Windows 95. If it important to call -// this function to allow the use of small icons in the correct proportions. - -ATOM MyRegisterClass( HINSTANCE hInstance ) -{ - WNDCLASSEXW wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = (WNDPROC)WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN32); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = (LPCWSTR)IDC_TESTWIN32; - wcex.lpszClassName = szWindowClass; - wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); - - return RegisterClassExW(&wcex); -} - -// -// FUNCTION: InitInstance(HANDLE, int) -// -// PURPOSE: Saves instance handle and creates main window -// -// COMMENTS: -// In this function, the instance access number is stored in a global variable -// and the main program window is displayed. -// -BOOL InitInstance( HINSTANCE hInstance, int nCmdShow ) -{ - HWND hWnd; - - hInst = hInstance; // Store instance access number in our global variable - - hWnd = CreateWindowExW(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); - - if( !hWnd ) - { - return FALSE; - } - - ShowWindow( hWnd, nCmdShow ); - UpdateWindow( hWnd ); - - return TRUE; -} - -// -// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) -// -// PURPOSE: Processes messages for the main window. -// -// WM_COMMAND - Handle application menu -// WM_PAINT - Display main windows -// WM_DESTROY - Output completion message and return -// - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId; - PAINTSTRUCT ps; - HDC hdc; - TCHAR szHello[MAX_LOADSTRING]; - - LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); - - switch( message ) - { - case WM_COMMAND: - wmId = LOWORD(wParam); - // Analyze menu selections - switch( wmId ) - { - case IDD_PASTE: - //PasteClipboardData(hWnd); - PasteClipboardData2(hWnd); - break; - - case IDM_EXIT: - DestroyWindow( hWnd ); - break; - - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } - break; - - case WM_PAINT: - hdc = BeginPaint (hWnd, &ps); - // TODO: Add any code for drawing - RECT rt; - GetClientRect( hWnd, &rt ); - - if ( NULL != pTextBuff ) - { - DrawText( hdc, pTextBuff, lData, &rt, DT_CENTER ); - } - else - { - DrawText( hdc, szHello, strlen(szHello), &rt, DT_CENTER ); - } - - EndPaint( hWnd, &ps ); - break; - - case WM_DESTROY: - PostQuitMessage( 0 ); - break; - - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } - return 0; -} - -void PasteClipboardData2(HWND hwndParent) -{ - IDataObject* pIDataObject; - HRESULT hr; - FORMATETC formatETC; - STGMEDIUM stgMedium; - LPVOID pGlobMem; - HWND hwnd; - DWORD sizeGlobBuff; - - hr = MTAGetClipboard( &pIDataObject ); - if ( SUCCEEDED( hr ) ) - { - formatETC.cfFormat = CF_TEXT; - formatETC.ptd = NULL; - formatETC.dwAspect = DVASPECT_CONTENT; - formatETC.lindex = -1; - formatETC.tymed = TYMED_HGLOBAL; - - hr = pIDataObject->GetData( &formatETC, &stgMedium ); - pGlobMem = GlobalLock( stgMedium.hGlobal ); - if ( NULL != pGlobMem ) - { - if ( NULL != pTextBuff ) - { - free( pTextBuff ); - } - - sizeGlobBuff = GlobalSize( stgMedium.hGlobal ); - pTextBuff = (char*)malloc( sizeGlobBuff + 1 ); - ZeroMemory( pTextBuff, sizeGlobBuff + 1 ); - - memcpy( pTextBuff, pGlobMem, sizeGlobBuff ); - lData = sizeGlobBuff; - - InvalidateRect( hwndParent, NULL, TRUE ); - UpdateWindow( hwndParent ); - } - - GlobalUnlock( stgMedium.hGlobal ); - - ReleaseStgMedium( &stgMedium ); - - pIDataObject->Release(); - } -} - -// clipboard handling - -/* -void PasteClipboardData(HWND hwndParent) -{ - IDataObject* pIDataObj = NULL; - HRESULT hr = E_FAIL; - unsigned int dwId; - - hr = OleGetClipboard( &pIDataObj ); - if ( SUCCEEDED( hr ) ) - { - HRESULT hr = CoMarshalInterThreadInterfaceInStream( - __uuidof(IDataObject), //The IID of interface to be marshaled - pIDataObj, //The interface pointer - &g_pStm //IStream pointer - ); - - HANDLE hThread = (HANDLE)_beginthreadex( - NULL, //Security - 0, //Stack Size - ThreadProc, //Start Address - NULL, //Parmeter - (unsigned int)hwndParent, //Creation Flag - &dwId //Thread Id - ); - - //Wait for the thread to finish execution - //A thread handle is signaled is thread execution - //is complete - for(;;) - { - DWORD dwRet = ::MsgWaitForMultipleObjects( - 1, //Count of objects - &hThread, //pointer to the array of objects - FALSE, //Wait for all objects? - INFINITE, //Wait How Long? - QS_ALLINPUT //Wait for all messages - ); - - //This means that the object is signaled - if ( dwRet != WAIT_OBJECT_0 + 1 ) - break; - - //Remove the messages from the queue - MSG msg; - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) - { - //Not essential - TranslateMessage(&msg); - //Let the windowproc handle the message - DispatchMessage(&msg); - } - } - - CloseHandle( hThread ); - pIDataObj->Release(); - } -} -*/ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testpaste/cbptest.rc b/sal/workben/clipboardwben/testpaste/cbptest.rc deleted file mode 100644 index 5b0adb7f07e2..000000000000 --- a/sal/workben/clipboardwben/testpaste/cbptest.rc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -//Microsoft Developer Studio generated resource script. - -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS - - -// Generated from the TEXTINCLUDE 2 resource. - -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -#include "resource.h" - - -#undef APSTUDIO_READONLY_SYMBOLS - - -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - - - -// Icon - - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_TESTWIN32 ICON DISCARDABLE "TestWin32.ICO" -IDI_SMALL ICON DISCARDABLE "SMALL.ICO" - - - -// Menu - - -IDC_TESTWIN32 MENU DISCARDABLE -BEGIN - POPUP "&Datei" - BEGIN - MENUITEM "&Paste", IDD_PASTE - MENUITEM SEPARATOR - MENUITEM "&Beenden", IDM_EXIT - END -END - - - - -// Accelerator - - -IDC_TESTWIN32 ACCELERATORS MOVEABLE PURE -BEGIN - "?", IDM_ABOUT, ASCII, ALT - "/", IDM_ABOUT, ASCII, ALT -END - - -#ifdef APSTUDIO_INVOKED - - -// TEXTINCLUDE - - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""resource.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -#endif // APSTUDIO_INVOKED - - - - -// String Table - - -STRINGTABLE DISCARDABLE -BEGIN - IDS_APP_TITLE "TestWin32" - IDS_HELLO "Hallo Welt!" - IDC_TESTWIN32 "TESTWIN32" -END - -#endif // German (Germany) resources - - - - -#ifndef APSTUDIO_INVOKED - - -// Generated from the TEXTINCLUDE 3 resource. - - - - -#endif // not APSTUDIO_INVOKED - diff --git a/sal/workben/clipboardwben/testpaste/makefile.mk b/sal/workben/clipboardwben/testpaste/makefile.mk deleted file mode 100644 index ca804217ec7e..000000000000 --- a/sal/workben/clipboardwben/testpaste/makefile.mk +++ /dev/null @@ -1,58 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ=..$/..$/.. - -PRJNAME=sal -TARGET=cbptest -LIBTARGET=NO - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -CFLAGS+= $(LFS_CFLAGS) -CXXFLAGS+= $(LFS_CFLAGS) - -# --- Files -------------------------------------------------------- - -# -# test clipboard paste -# - # --- Resources ---------------------------------------------------- - RCFILES= cbptest.rc - - OBJFILES= $(OBJ)$/cbptest.obj - - APP1TARGET= $(TARGET) - APP1OBJS= $(OBJFILES) - APP1NOSAL= TRUE - APP1NOSVRES= $(RES)$/$(TARGET).res - - APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB) - - APP1LIBS=$(LB)$/ole9x.lib \ - $(LB)$/tools32.lib - - APP1DEPN= makefile.mk $(APP1NOSVRES) - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - - diff --git a/sal/workben/clipboardwben/testpaste/resource.h b/sal/workben/clipboardwben/testpaste/resource.h deleted file mode 100644 index 8eda4e8fedc1..000000000000 --- a/sal/workben/clipboardwben/testpaste/resource.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by mtacb.rc - -#define IDC_MYICON 2 -#define IDD_TESTWIN32_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDS_APP_TITLE 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDS_HELLO 106 -#define IDI_TESTWIN32 107 -#define IDI_SMALL 108 -#define IDC_TESTWIN32 109 -#define IDR_MAINFRAME 128 -#define IDD_PASTE 32771 -#define IDC_STATIC -1 - -// Next default values for new objects - -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32772 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testpaste/small.ico b/sal/workben/clipboardwben/testpaste/small.ico Binary files differdeleted file mode 100644 index 8f94d9aa8285..000000000000 --- a/sal/workben/clipboardwben/testpaste/small.ico +++ /dev/null diff --git a/sal/workben/clipboardwben/testviewer/StdAfx.cpp b/sal/workben/clipboardwben/testviewer/StdAfx.cpp deleted file mode 100644 index 635136666af7..000000000000 --- a/sal/workben/clipboardwben/testviewer/StdAfx.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet -// TestWin32.pch ist die vorkompilierte Header-Datei -// stdafx.obj enthlt die vorkompilierte Typinformation - -#include "stdafx.h" - -// ZU ERLEDIGEN: Verweis auf alle zustzlichen Header-Dateien, die Sie in STDAFX.H -// und nicht in dieser Datei bentigen - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testviewer/StdAfx.h b/sal/workben/clipboardwben/testviewer/StdAfx.h deleted file mode 100644 index 9a5dc4dc525d..000000000000 --- a/sal/workben/clipboardwben/testviewer/StdAfx.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -// stdafx.h : Include-Datei für Standard-System-Include-Dateien, -// oder projektspezifische Include-Dateien, die häufig benutzt, aber -// in unregelmäßigen Abständen geändert werden. - -#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) -#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden - -// Windows-Header-Dateien: -#include <windows.h> - -// Header-Dateien der C-Laufzeit -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> - -// Lokale Header-Dateien - -// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein. - -#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testviewer/TestWin32.ico b/sal/workben/clipboardwben/testviewer/TestWin32.ico Binary files differdeleted file mode 100644 index 255ff3be4fba..000000000000 --- a/sal/workben/clipboardwben/testviewer/TestWin32.ico +++ /dev/null diff --git a/sal/workben/clipboardwben/testviewer/cbvtest.cxx b/sal/workben/clipboardwben/testviewer/cbvtest.cxx deleted file mode 100644 index 8a43de4b6996..000000000000 --- a/sal/workben/clipboardwben/testviewer/cbvtest.cxx +++ /dev/null @@ -1,326 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#define _WIN32_DCOM - -#include "stdafx.h" - -#include <windows.h> - -#include <ole2.h> -#include <objidl.h> -#include <objbase.h> -#include <process.h> -#include <olectl.h> -#include <stdlib.h> -#include <malloc.h> -#include <crtdbg.h> -#include <..\..\inc\systools\win32\MtaOleClipb.h> - -#include "resource.h" - -#define MAX_LOADSTRING 100 - -HINSTANCE g_hInst; // current instance -HWND g_hwndMain; -WCHAR szTitle[MAX_LOADSTRING]; // Text for title -WCHAR szWindowClass[MAX_LOADSTRING]; // Text for title -LPSTREAM g_pStm = NULL; -char* pTextBuff = NULL; -DWORD lData = 0; -UINT g_nCBChanges = 0; - -ATOM MyRegisterClass( HINSTANCE hInstance ); -BOOL InitInstance( HINSTANCE, int ); -HMENU GetSubMenuHandle( HWND hwndParent, UINT uiTopLevelIndex ); -BOOL IsClipboardViewer( HWND hwndParent ); -void SwitchMenuState( HWND hwndParent ); -void RegisterClipboardViewer( BOOL bRegister ); -void ShowAvailableClipboardFormats( HWND hWnd, HDC hdc, PAINTSTRUCT ps, RECT rcWnd ); -void ClearClipboardContent( HWND hWnd ); - -void CALLBACK OnClipboardContentChange(); -LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); -LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM ); - -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow ) -{ - // TODO: Add code here. - MSG msg; - HACCEL hAccelTable; - HRESULT hr = E_FAIL; - - // it's important to initialize ole - // in order to use the clipboard - //hr = OleInitialize( NULL ); - hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ); - - g_hInst = hInstance; - - // Initialize global strings - LoadStringW(g_hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadStringW(g_hInst, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING); - MyRegisterClass(g_hInst); - - // Initialization of the applications to carry out - if( !InitInstance( g_hInst, nCmdShow ) ) - { - return FALSE; - } - - hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN32); - - // Main message loop: - while( GetMessage(&msg, NULL, 0, 0) ) - { - if( !TranslateAccelerator (msg.hwnd, hAccelTable, &msg) ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - - // uninitializing the ole libraries - //OleUninitialize( ); - CoUninitialize( ); - - return msg.wParam; -} - -// -// FUNCTION: MyRegisterClass() -// -// PURPOSE: Registers the window class. -// -// COMMENTS: -// This function and its usage are only necessary if this code -// needs to be compatible with Win32 systems prior to 'RegisterClassEx' -// function, which was added to Windows 95. If it important to call -// this function to allow the use of small icons in the correct proportions. -// -ATOM MyRegisterClass( HINSTANCE hInstance ) -{ - WNDCLASSEXW wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = (WNDPROC)WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN32); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = (LPCWSTR)IDC_TESTWIN32; - wcex.lpszClassName = szWindowClass; - wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); - - return RegisterClassExW(&wcex); -} - -// -// FUNKTION: InitInstance(HANDLE, int) -// -// PURPOSE: Saves instance access number and creates main window -// -// Comments: -// In this function, the instance access number is stored in a global variable -// and the main program window is displayed. -// - -BOOL InitInstance( HINSTANCE hInstance, int nCmdShow ) -{ - g_hwndMain = CreateWindowExW(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); - - if( !IsWindow( g_hwndMain ) ) - { - return FALSE; - } - - ShowWindow( g_hwndMain, nCmdShow ); - UpdateWindow( g_hwndMain ); - - return TRUE; -} - -// -// FUNKTION: WndProc(HWND, unsigned, WORD, LONG) -// -// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) -// -// PURPOSE: Processes messages for the main window. -// -// WM_COMMAND - Handle application menu -// WM_PAINT - Display main windows -// WM_DESTROY - Output completion message and return -// -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId; - PAINTSTRUCT ps; - HDC hdc; - WCHAR szHello[MAX_LOADSTRING]; - - LoadStringW(g_hInst, IDS_HELLO, szHello, MAX_LOADSTRING); - - switch( message ) - { - case WM_CREATE: - ClearClipboardContent( hWnd ); - break; - - case WM_COMMAND: - wmId = LOWORD(wParam); - // Analyze menu selections: - switch( wmId ) - { - case IDD_CBVIEWER: - SwitchMenuState( hWnd ); - RegisterClipboardViewer( IsClipboardViewer( hWnd ) ); - break; - - case IDM_EXIT: - DestroyWindow( hWnd ); - break; - - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } - break; - - case WM_PAINT: - hdc = BeginPaint (hWnd, &ps); - // TODO: Add any code for drawing - RECT rt; - GetClientRect( hWnd, &rt ); - - if ( IsClipboardViewer( g_hwndMain ) ) - { - ShowAvailableClipboardFormats( hWnd, hdc, ps, rt ); - } - else - { - WCHAR wcString[MAX_LOADSTRING]; - LoadStringW(g_hInst, IDS_MSG_CBVIEWER_IS_OFF, wcString, MAX_LOADSTRING); - DrawTextW( hdc, wcString, wcslen( wcString ), &rt, DT_CENTER ); - } - - EndPaint( hWnd, &ps ); - break; - - case WM_DESTROY: - PostQuitMessage( 0 ); - break; - - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } - return 0; -} - -HMENU GetSubMenuHandle( HWND hwndParent, UINT uiTopLevelIndex ) -{ - HMENU hMenuMain = GetMenu( hwndParent ); - _ASSERT( IsMenu( hMenu ) ); - - HMENU hSubMenu = GetSubMenu( hMenuMain, uiTopLevelIndex ); - _ASSERT( IsMenu( hSubMenu ) ); - - return hSubMenu; -} - -BOOL IsClipboardViewer( HWND hwndParent ) -{ - HMENU hSubMenu = GetSubMenuHandle( hwndParent, 0 ); - UINT uiMState = GetMenuState( hSubMenu, 0, MF_BYPOSITION ); - return ( MF_CHECKED == uiMState ); -} - -void SwitchMenuState( HWND hwndParent ) -{ - HMENU hSubMenu = GetSubMenuHandle( hwndParent, 0 ); - WCHAR wcMenuString[MAX_LOADSTRING]; - - if ( IsClipboardViewer( hwndParent ) ) - { - LoadStringW(g_hInst, IDS_CBVIEWER_OFF, wcMenuString, MAX_LOADSTRING); - ModifyMenuW( hSubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_CBVIEWER, wcMenuString ); - CheckMenuItem( hSubMenu, 0, MF_BYPOSITION | MF_UNCHECKED ); - } - else - { - LoadStringW(g_hInst, IDS_CBVIEWER_ON, wcMenuString, MAX_LOADSTRING); - ModifyMenuW( hSubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_CBVIEWER, wcMenuString ); - CheckMenuItem( hSubMenu, 0, MF_BYPOSITION | MF_CHECKED ); - } -} - -void RegisterClipboardViewer( BOOL bRegister ) -{ - if ( bRegister ) - MTARegisterClipboardViewer( OnClipboardContentChange ); - else // unregister - MTARegisterClipboardViewer( NULL ); - - InvalidateRect( g_hwndMain, NULL, TRUE ); - UpdateWindow( g_hwndMain ); -} - -void ShowAvailableClipboardFormats( HWND hWnd, HDC hdc, PAINTSTRUCT ps, RECT rcWnd ) -{ - if ( !OpenClipboard( hWnd ) ) - { - WCHAR szErrMsg[] = { L"Couldn't open the clipboard" }; - DrawTextW( hdc, szErrMsg, wcslen( szErrMsg ), &rcWnd, DT_CENTER ); - return; - } - else - { - WCHAR szCBChangedMsg[100]; - - wsprintfW( szCBChangedMsg, L"Clipboard content changed %d", g_nCBChanges ); - DrawTextW( hdc, szCBChangedMsg, wcslen( szCBChangedMsg ), &rcWnd, DT_CENTER ); - - CloseClipboard( ); - } -} - -void ClearClipboardContent( HWND hWnd ) -{ - if ( OpenClipboard( hWnd ) ) - { - EmptyClipboard( ); - CloseClipboard( ); - } -} - -// clipboard viewer callback function -void CALLBACK OnClipboardContentChange() -{ - ++g_nCBChanges; - InvalidateRect( g_hwndMain, NULL, TRUE ); - UpdateWindow( g_hwndMain ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testviewer/cbvtest.rc b/sal/workben/clipboardwben/testviewer/cbvtest.rc deleted file mode 100644 index 047cc790ca47..000000000000 --- a/sal/workben/clipboardwben/testviewer/cbvtest.rc +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -//Microsoft Developer Studio generated resource script. - -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS - - -// Generated from the TEXTINCLUDE 2 resource. - -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -#include "resource.h" - - -#undef APSTUDIO_READONLY_SYMBOLS - - -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - - - -// Icon - - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_TESTWIN32 ICON DISCARDABLE "TestWin32.ICO" -IDI_SMALL ICON DISCARDABLE "SMALL.ICO" - - - -// Menu - - -IDC_TESTWIN32 MENU DISCARDABLE -BEGIN - POPUP "&Datei" - BEGIN - MENUITEM "&CB Viewer off", IDD_CBVIEWER - MENUITEM SEPARATOR - MENUITEM "&Beenden", IDM_EXIT - END -END - - - - -// Accelerator - - -IDC_TESTWIN32 ACCELERATORS MOVEABLE PURE -BEGIN - "?", IDM_ABOUT, ASCII, ALT - "/", IDM_ABOUT, ASCII, ALT -END - - -#ifdef APSTUDIO_INVOKED - - -// TEXTINCLUDE - - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""resource.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -#endif // APSTUDIO_INVOKED - - - - -// String Table - - -STRINGTABLE DISCARDABLE -BEGIN - IDS_APP_TITLE "TestWin32" - IDS_HELLO "Hallo Welt!" - IDC_TESTWIN32 "TESTWIN32" - IDS_CBVIEWER_ON "CB Viewer on" - IDS_CBVIEWER_OFF "CB Viewer off" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_MSG_CBVIEWER_IS_OFF "Clipboard Viewer inactive!" -END - -#endif // German (Germany) resources - - - - -#ifndef APSTUDIO_INVOKED - - -// Generated from the TEXTINCLUDE 3 resource. - - - - -#endif // not APSTUDIO_INVOKED - diff --git a/sal/workben/clipboardwben/testviewer/makefile.mk b/sal/workben/clipboardwben/testviewer/makefile.mk deleted file mode 100644 index 3bdc58af738b..000000000000 --- a/sal/workben/clipboardwben/testviewer/makefile.mk +++ /dev/null @@ -1,58 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ=..$/..$/.. - -PRJNAME=sal -TARGET=cbvtest -LIBTARGET=NO - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -CFLAGS+= $(LFS_CFLAGS) -CXXFLAGS+= $(LFS_CFLAGS) - -# --- Files -------------------------------------------------------- - -# -# test clipboard paste -# - # --- Resources ---------------------------------------------------- - RCFILES= cbvtest.rc - - OBJFILES= $(OBJ)$/cbvtest.obj - - APP1TARGET= $(TARGET) - APP1OBJS= $(OBJFILES) - APP1NOSAL= TRUE - APP1NOSVRES= $(RES)$/$(TARGET).res - - APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB) - - APP1LIBS=$(LB)$/iole9x.lib \ - $(LB)$/tools32.lib - - APP1DEPN= makefile.mk $(APP1NOSVRES) - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - - diff --git a/sal/workben/clipboardwben/testviewer/resource.h b/sal/workben/clipboardwben/testviewer/resource.h deleted file mode 100644 index 3bd18adc497d..000000000000 --- a/sal/workben/clipboardwben/testviewer/resource.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by cbvtest.rc - -#define IDC_MYICON 2 -#define IDD_TESTWIN32_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDS_APP_TITLE 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDS_HELLO 106 -#define IDI_TESTWIN32 107 -#define IDI_SMALL 108 -#define IDC_TESTWIN32 109 -#define IDS_CBVIEWER_ON 110 -#define IDS_CBVIEWER_OFF 111 -#define IDS_MSG_CBVIEWER_IS_OFF 112 -#define IDR_MAINFRAME 128 -#define IDD_PASTE 32771 -#define IDD_CBVIEWER 32771 -#define IDC_STATIC -1 - -// Next default values for new objects - -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32772 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/clipboardwben/testviewer/small.ico b/sal/workben/clipboardwben/testviewer/small.ico Binary files differdeleted file mode 100644 index 8f94d9aa8285..000000000000 --- a/sal/workben/clipboardwben/testviewer/small.ico +++ /dev/null diff --git a/sal/workben/export.exp b/sal/workben/export.exp deleted file mode 100644 index 8a37bf2291a8..000000000000 --- a/sal/workben/export.exp +++ /dev/null @@ -1 +0,0 @@ -registerAllTestFunction
\ No newline at end of file diff --git a/sal/workben/getlocaleinfotest.cxx b/sal/workben/getlocaleinfotest.cxx deleted file mode 100644 index b9bd0343fe14..000000000000 --- a/sal/workben/getlocaleinfotest.cxx +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <rtl/locale.h> -#include <osl/nlsupport.h> -#include <rtl/ustring.hxx> - -int _cdecl main( int argc, char * argv[] ) -{ - rtl::OUString lang("de"); - rtl::OUString country("DE"); - rtl_TextEncoding rtlTextEnc; - - rtl_Locale* rtlLocale = - rtl_locale_register( lang.getStr( ), country.getStr( ), NULL ); - - if ( rtlLocale ) - rtlTextEnc = osl_getTextEncodingFromLocale( rtlLocale ); - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/makefile.mk b/sal/workben/makefile.mk deleted file mode 100644 index b7141a73d9db..000000000000 --- a/sal/workben/makefile.mk +++ /dev/null @@ -1,215 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ=.. - -PRJNAME=sal -TARGET=workben -LIBTARGET=NO -TARGETTYPE=CUI -NO_DEFAULT_STL=YES - - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -CFLAGS+=$(LFS_CFLAGS) -CXXFLAGS+=$(LFS_CFLAGS) - -# --- Files -------------------------------------------------------- - -# -# t_readline -# -OBJFILES+=\ - $(OBJ)$/t_readline.obj - -APP1TARGET=t_readline -APP1OBJS=$(OBJ)$/t_readline.obj -APP1STDLIBS=$(SALLIB) -APP1DEPN=$(SLB)$/sal.lib -APP1RPATH=UREBIN - -# -# testfile -# -OBJFILES+=\ - $(OBJ)$/testfile.obj - -APP1TARGET=testfile -APP1OBJS=$(OBJ)$/testfile.obj -APP1STDLIBS=$(SALLIB) -APP1DEPN=$(SLB)$/sal.lib - -# -# testpipe -# -OBJFILES+=\ - $(OBJ)$/testpipe.obj - -APP2TARGET=testpipe -APP2OBJS=$(OBJ)$/testpipe.obj -APP2STDLIBS=$(SALLIB) -APP2DEPN=$(SLB)$/sal.lib - -# -# testpip2 -# -OBJFILES+=\ - $(OBJ)$/testpip2.obj - -APP3TARGET=testpip2 -APP3OBJS=$(OBJ)$/testpip2.obj -APP3STDLIBS=$(SALLIB) -APP3DEPN=$(SLB)$/sal.lib - -# -# testproc -# -OBJFILES+=\ - $(OBJ)$/testproc.obj - -APP4TARGET=testproc -APP4OBJS=$(OBJ)$/testproc.obj -APP4STDLIBS=$(SALLIB) -APP4DEPN=$(SLB)$/sal.lib - -# -# measure_oustrings -# -OBJFILES+=\ - $(OBJ)$/measure_oustrings.obj - -.IF "$(ENABLE_VALGRIND)" == "TRUE" -CFLAGSCXX+=-DHAVE_VALGRIND_HEADERS -.ENDIF - -APP6TARGET=measure_oustrings -APP6OBJS=$(OBJ)$/measure_oustrings.obj -APP6STDLIBS=$(SALLIB) -APP6DEPN=$(SLB)$/sal.lib - -# -# t_random. -# -OBJFILES+=\ - $(OBJ)$/t_random.obj - -APP7TARGET=t_random -APP7OBJS=$(OBJ)$/t_random.obj -APP7STDLIBS=$(SALLIB) -APP7DEPN=$(SLB)$/sal.lib - -# -# t_cipher -# -OBJFILES+=\ - $(OBJ)$/t_cipher.obj - -APP8TARGET=t_cipher -APP8OBJS=$(OBJ)$/t_cipher.obj -APP8STDLIBS=$(SALLIB) -APP8DEPN=$(SLB)$/sal.lib - -# -# t_digest. -# -OBJFILES+=\ - $(OBJ)$/t_digest.obj - -APP9TARGET=t_digest -APP9OBJS=$(OBJ)$/t_digest.obj -APP9STDLIBS=$(SALLIB) -APP9DEPN=$(SLB)$/sal.lib - -# -# getlitest -# -.IF "$(TESTAPP)" == "getlocaleinfotest" -OBJFILES+=\ - $(OBJ)$/getlocaleinfotest.obj - -APP10TARGET=getlitest -APP10OBJS=$(OBJ)$/getlocaleinfotest.obj - -APP10STDLIBS=\ - $(KERNEL32LIB) - -APP10LIBS=\ - $(LB)$/kernel9x.lib\ - $(LB)$/isal.lib - -APP10DEPN=$(LB)$/isal.lib -.ENDIF - -.IF "$(TESTAPP)" == "test_osl_getVolInfo" - -SHL10OBJS=$(SLO)$/t_osl_getVolInfo.obj -SHL10TARGET=togvi - -.IF "$(OS)" == "WNT" -APP10STDLIBS=$(KERNEL32LIB) -SHL10STDLIBS=$(LB)$/isal.lib -SHL10STDLIBS+=$(SOLARLIBDIR)$/cppunit.lib -.ENDIF - -.IF "$(OS)" != "WNT" -SHL10STDLIBS=$(LB)$/libsal.so -SHL10STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF - -SHL10IMPLIB=i$(SHL1TARGET) -SHL10DEF=$(MISC)$/$(SHL1TARGET).def -DEF10NAME=$(SHL1TARGET) -DEF10EXPORTFILE=export.exp -.ENDIF - -.IF "$(TESTAPP)" == "test_osl_joinProcess" -OBJFILES+=\ - $(OBJ)$/t_ojp_exe.obj -APP10TARGET=ojpx -APP10OBJS=$(OBJ)$/t_ojp_exe.obj - -.IF "$(OS)" != "WNT" -APP10STDLIBS=$(LB)$/libsal.so -.ENDIF - -SHL10OBJS=$(SLO)$/t_osl_joinProcess.obj -SHL10TARGET=tojp - -.IF "$(OS)" == "WNT" -APP10STDLIBS=$(KERNEL32LIB) -SHL10STDLIBS=$(LB)$/isal.lib -SHL10STDLIBS+=$(SOLARLIBDIR)$/cppunit.lib -.ENDIF - -.IF "$(OS)" != "WNT" -SHL10STDLIBS=$(LB)$/libsal.so -SHL10STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF - -SHL10IMPLIB=i$(SHL1TARGET) -SHL10DEF=$(MISC)$/$(SHL1TARGET).def -DEF10NAME=$(SHL1TARGET) -DEF10EXPORTFILE=export.exp -.ENDIF - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/sal/workben/measure_oustrings.cxx b/sal/workben/measure_oustrings.cxx deleted file mode 100644 index eeca8ccf2906..000000000000 --- a/sal/workben/measure_oustrings.cxx +++ /dev/null @@ -1,262 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <sal/main.h> -#include <rtl/ustring.hxx> -#include <osl/time.h> -#include <osl/process.h> - -#include <iostream> -#include <sstream> -#include <fstream> - -#if defined HAVE_VALGRIND_HEADERS -# include <valgrind/callgrind.h> -int COUNT = 1; -#else -# define CALLGRIND_DUMP_STATS_AT -# define CALLGRIND_START_INSTRUMENTATION -# define CALLGRIND_STOP_INSTRUMENTATION -# define CALLGRIND_ZERO_STATS -int COUNT = 10000000; -#endif - -#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L -# define HAVE_CXX_Ox 1 -#endif - -#ifdef HAVE_CXX_Ox -# define SAL_DECLARE_UTF16(str) u ## str -#elif __SIZEOF_WCHAR_T__ == 2 -# define SAL_DECLARE_UTF16(str) L ## str -#endif - -#ifdef SAL_DECLARE_UTF16 -# define RTL_CONSTASCII_USTRINGPARAM_WIDE(str) \ - reinterpret_cast<const sal_Unicode*>(SAL_DECLARE_UTF16(str)), (SAL_N_ELEMENTS(str)-1) -#endif - -#define RTL_CONSTASCII_USTRINGPARAM_CLASSIC(str) \ - str, ((sal_Int32)(SAL_N_ELEMENTS(str)-1)), RTL_TEXTENCODING_ASCII_US - -int currenttest = 1; -oslProcessInfo pidinfo; - -class TimerMeasure -{ -private: - const char *m_pMessage; - sal_uInt32 m_nStartTime, m_nEndTime; -public: - explicit TimerMeasure(const char *pMessage) - : m_pMessage(pMessage) - { - m_nStartTime = osl_getGlobalTimer(); - CALLGRIND_START_INSTRUMENTATION - CALLGRIND_ZERO_STATS - } - - ~TimerMeasure() - { - CALLGRIND_STOP_INSTRUMENTATION - CALLGRIND_DUMP_STATS_AT(m_pMessage); - m_nEndTime = osl_getGlobalTimer(); - std::cout << m_pMessage << std::endl; - std::cout << " callgrind Instruction cost is: " << std::flush; - - std::stringstream aFileName; - aFileName << "callgrind.out." << pidinfo.Ident << "." << currenttest; - - std::ifstream myfile(aFileName.str(), std::ios::in); - if (myfile.is_open()) - { - std::stringstream aGetGrindStats; - aGetGrindStats << "callgrind_annotate " << aFileName.str() << - " | grep TOTALS | sed 's/ PROGRAM TOTALS//'"; - system(aGetGrindStats.str().c_str()); - myfile.close(); - } - else - std::cout << "Unavailable" << std::endl; - currenttest++; -#ifndef HAVE_CALLGRIND - std::cout << " Elapsed tools::Time is: " << m_nEndTime - m_nStartTime << "ms" << std::endl; -#endif - } -}; - -#define TIME(msg, test) \ -{\ - { test } /*Run the test one to shake out any firsttime lazy loading stuff*/ \ - TimerMeasure aMeasure(msg);\ - for (int i = 0; i < COUNT; ++i)\ - test\ -} - -SAL_IMPLEMENT_MAIN() -{ - CALLGRIND_STOP_INSTRUMENTATION - CALLGRIND_ZERO_STATS - - pidinfo.Size = sizeof(pidinfo); - osl_getProcessInfo(0, osl_Process_IDENTIFIER, &pidinfo); - -#ifdef HAVE_CALLGRIND - std::cout << "Execute using: valgrind --tool=callgrind ./measure_oustrings" << std::endl; -#else - //get my cpu fan up to speed :-) - for (int i = 0; i < 10000000; ++i) - { - rtl::OUString sFoo(rtl::OUString::createFromAscii("X")); - rtl::OUString sBar(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("X")); - rtl::OUString sBaz(static_cast<sal_Unicode>('X')); - rtl::OUString sNone; - } -#endif - - std::cout << "--Empty Strings Construction--" << std::endl; - - TIME - ( - "rtl::OUString()", - rtl::OUString sFoo; - ) - - TIME - ( - "rtl::OUString::createFromAscii()", - rtl::OUString sFoo(rtl::OUString::createFromAscii("")); - ) - - std::cout << "--Single Chars Construction--" << std::endl; - - TIME - ( - "rtl::OUString(static_cast<sal_Unicode>('X')", - rtl::OUString sBaz(static_cast<sal_Unicode>('X')); - ) - -#ifdef SAL_DECLARE_UTF16 - TIME - ( - "rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_WIDE(\"X\"))", - rtl::OUString sBar(RTL_CONSTASCII_USTRINGPARAM_WIDE("X")); - ) -#endif - - TIME - ( - "rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_CLASSIC(\"X\"))", - rtl::OUString sBar(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("X")); - ) - - TIME - ( - "rtl::OUString::createFromAscii(\"X\")", - rtl::OUString sFoo(rtl::OUString::createFromAscii("X")); - ) - - std::cout << "--MultiChar Strings Construction--" << std::endl; - -#ifdef SAL_DECLARE_UTF16 - TIME - ( - "rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_WIDE(\"XXXXXXXX\"))", - rtl::OUString sBar(RTL_CONSTASCII_USTRINGPARAM_WIDE("XXXXXXXXXXXXXXX")); - ) -#endif - - TIME - ( - "rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_CLASSIC(\"XXXXXXXX\"))", - rtl::OUString sBar(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("XXXXXXXXXXXXXXX")); - ) - - TIME - ( - "rtl::OUString::createFromAscii(\"XXXXXXXX\")", - rtl::OUString sFoo(rtl::OUString::createFromAscii("XXXXXXXXXXXXXXX")); - ) - - std::cout << "--Ascii Unequal Comparison--" << std::endl; - - rtl::OUString sCompare(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("XXXXXXXXXXXXXXX")); - - TIME - ( - "rtl::OUString::equalsAsciiL", - sCompare.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("apple")); - ) - - rtl::OUString sUnequalCompareTo(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("apple")); - - TIME - ( - "operator==(precreated OUString(\"apple\"))", - sCompare == sUnequalCompareTo; - ) - - TIME - ( - "rtl::OUString::equalsAscii", - sCompare.equalsAscii("apple"); - ) - - //(const sal_Char*, sal_Int32) version has different semantics - TIME - ( - "rtl::OUString::compareToAscii (const sal_Char*)", - sCompare.compareToAscii("apple"); - ) - - TIME - ( - "operator==(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_CLASSIC(\"apple\")))", - sCompare == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("apple")); - ) - - std::cout << "--Ascii Equal Comparison--" << std::endl; - - TIME - ( - "rtl::OUString::equalsAsciiL", - sCompare.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("XXXXXXXXXXXXXXX")); - ) - - rtl::OUString sEqualCompareTo(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("XXXXXXXXXXXXXXX")); - - TIME - ( - "operator==(precreated OUString(\"XXXXXXXXXXXXXXX\"))", - sCompare == sEqualCompareTo; - ) - - TIME - ( - "rtl::OUString::equalsAscii", - sCompare.equalsAscii("XXXXXXXXXXXXXXX"); - ) - - //(const sal_Char*, sal_Int32) version has different semantics - TIME - ( - "rtl::OUString::compareToAscii (const sal_Char*)", - sCompare.compareToAscii("XXXXXXXXXXXXXXX"); - ) - - TIME - ( - "operator==(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_CLASSIC(\"XXXXXXXXXXXXXXX\"))", - sCompare == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM_CLASSIC("XXXXXXXXXXXXXXX")); - ) - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/t_cipher.c b/sal/workben/t_cipher.c deleted file mode 100644 index dd802e08c441..000000000000 --- a/sal/workben/t_cipher.c +++ /dev/null @@ -1,392 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#include <sal/types.h> -#include <sal/macros.h> -#include <osl/diagnose.h> -#include <rtl/cipher.h> - -#include <stdio.h> -#include <string.h> - -#define NUM_VARIABLE_KEY_TESTS 34 -#define NUM_SET_KEY_TESTS 24 - -/* plaintext bytes -- left halves */ -unsigned long plaintext_l[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = { - 0x00000000l, 0xFFFFFFFFl, 0x10000000l, 0x11111111l, 0x11111111l, - 0x01234567l, 0x00000000l, 0x01234567l, 0x01A1D6D0l, 0x5CD54CA8l, - 0x0248D438l, 0x51454B58l, 0x42FD4430l, 0x059B5E08l, 0x0756D8E0l, - 0x762514B8l, 0x3BDD1190l, 0x26955F68l, 0x164D5E40l, 0x6B056E18l, - 0x004BD6EFl, 0x480D3900l, 0x437540C8l, 0x072D43A0l, 0x02FE5577l, - 0x1D9D5C50l, 0x30553228l, 0x01234567l, 0x01234567l, 0x01234567l, - 0xFFFFFFFFl, 0x00000000l, 0x00000000l, 0xFFFFFFFFl, 0xFEDCBA98l, - 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, - 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, - 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, - 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, - 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l }; - -/* plaintext bytes -- right halves */ -unsigned long plaintext_r[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = { - 0x00000000l, 0xFFFFFFFFl, 0x00000001l, 0x11111111l, 0x11111111l, - 0x89ABCDEFl, 0x00000000l, 0x89ABCDEFl, 0x39776742l, 0x3DEF57DAl, - 0x06F67172l, 0x2DDF440Al, 0x59577FA2l, 0x51CF143Al, 0x774761D2l, - 0x29BF486Al, 0x49372802l, 0x35AF609Al, 0x4F275232l, 0x759F5CCAl, - 0x09176062l, 0x6EE762F2l, 0x698F3CFAl, 0x77075292l, 0x8117F12Al, - 0x18F728C2l, 0x6D6F295Al, 0x89ABCDEFl, 0x89ABCDEFl, 0x89ABCDEFl, - 0xFFFFFFFFl, 0x00000000l, 0x00000000l, 0xFFFFFFFFl, 0x76543210l, - 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, - 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, - 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, - 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, - 0x76543210l, 0x76543210l, 0x76543210l }; - -/* key bytes for variable key tests */ -unsigned char variable_key[NUM_VARIABLE_KEY_TESTS][8] = { - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, - { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 }, - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, - { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 }, - { 0x7C, 0xA1, 0x10, 0x45, 0x4A, 0x1A, 0x6E, 0x57 }, - { 0x01, 0x31, 0xD9, 0x61, 0x9D, 0xC1, 0x37, 0x6E }, - { 0x07, 0xA1, 0x13, 0x3E, 0x4A, 0x0B, 0x26, 0x86 }, - { 0x38, 0x49, 0x67, 0x4C, 0x26, 0x02, 0x31, 0x9E }, - { 0x04, 0xB9, 0x15, 0xBA, 0x43, 0xFE, 0xB5, 0xB6 }, - { 0x01, 0x13, 0xB9, 0x70, 0xFD, 0x34, 0xF2, 0xCE }, - { 0x01, 0x70, 0xF1, 0x75, 0x46, 0x8F, 0xB5, 0xE6 }, - { 0x43, 0x29, 0x7F, 0xAD, 0x38, 0xE3, 0x73, 0xFE }, - { 0x07, 0xA7, 0x13, 0x70, 0x45, 0xDA, 0x2A, 0x16 }, - { 0x04, 0x68, 0x91, 0x04, 0xC2, 0xFD, 0x3B, 0x2F }, - { 0x37, 0xD0, 0x6B, 0xB5, 0x16, 0xCB, 0x75, 0x46 }, - { 0x1F, 0x08, 0x26, 0x0D, 0x1A, 0xC2, 0x46, 0x5E }, - { 0x58, 0x40, 0x23, 0x64, 0x1A, 0xBA, 0x61, 0x76 }, - { 0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xB0, 0x07 }, - { 0x49, 0x79, 0x3E, 0xBC, 0x79, 0xB3, 0x25, 0x8F }, - { 0x4F, 0xB0, 0x5E, 0x15, 0x15, 0xAB, 0x73, 0xA7 }, - { 0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF }, - { 0x01, 0x83, 0x10, 0xDC, 0x40, 0x9B, 0x26, 0xD6 }, - { 0x1C, 0x58, 0x7F, 0x1C, 0x13, 0x92, 0x4F, 0xEF }, - { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - { 0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E }, - { 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, - { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 }}; - -/* key bytes for set key tests */ -unsigned char set_key[24] = { - 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87, - 0x78, 0x69, 0x5A, 0x4B, 0x3C, 0x2D, 0x1E, 0x0F, - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; - -/* ciphertext bytes -- left halves */ -unsigned long ciphertext_l[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = { - 0x4EF99745l, 0x51866FD5l, 0x7D856F9Al, 0x2466DD87l, 0x61F9C380l, - 0x7D0CC630l, 0x4EF99745l, 0x0ACEAB0Fl, 0x59C68245l, 0xB1B8CC0Bl, - 0x1730E577l, 0xA25E7856l, 0x353882B1l, 0x48F4D088l, 0x432193B7l, - 0x13F04154l, 0x2EEDDA93l, 0xD887E039l, 0x5F99D04Fl, 0x4A057A3Bl, - 0x452031C1l, 0x7555AE39l, 0x53C55F9Cl, 0x7A8E7BFAl, 0xCF9C5D7Al, - 0xD1ABB290l, 0x55CB3774l, 0xFA34EC48l, 0xA7907951l, 0xC39E072Dl, - 0x014933E0l, 0xF21E9A77l, 0x24594688l, 0x6B5C5A9Cl, 0xF9AD597Cl, - 0xE91D21C1l, 0xE9C2B70Al, 0xBE1E6394l, 0xB39E4448l, 0x9457AA83l, - 0x8BB77032l, 0xE87A244El, 0x15750E7Al, 0x122BA70Bl, 0x3A833C9Al, - 0x9409DA87l, 0x884F8062l, 0x1F85031Cl, 0x79D9373Al, 0x93142887l, - 0x03429E83l, 0xA4299E27l, 0xAFD5AED1l, 0x10851C0El, 0xE6F51ED7l, - 0x64A6E14Al, 0x80C7D7D4l, 0x05044B62l }; - -/* ciphertext bytes -- right halves */ -unsigned long ciphertext_r[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = { - 0x6198DD78l, 0xB85ECB8Al, 0x613063F2l, 0x8B963C9Dl, 0x2281B096l, - 0xAFDA1EC7l, 0x6198DD78l, 0xC6A0A28Dl, 0xEB05282Bl, 0x250F09A0l, - 0x8BEA1DA4l, 0xCF2651EBl, 0x09CE8F1Al, 0x4C379918l, 0x8951FC98l, - 0xD69D1AE5l, 0xFFD39C79l, 0x3C2DA6E3l, 0x5B163969l, 0x24D3977Bl, - 0xE4FADA8El, 0xF59B87BDl, 0xB49FC019l, 0x937E89A3l, 0x4986ADB5l, - 0x658BC778l, 0xD13EF201l, 0x47B268B2l, 0x08EA3CAEl, 0x9FAC631Dl, - 0xCDAFF6E4l, 0xB71C49BCl, 0x5754369Al, 0x5D9E0A5Al, 0x49DB005El, - 0xD961A6D6l, 0x1BC65CF3l, 0x08640F05l, 0x1BDB1E6El, 0xB1928C0Dl, - 0xF960629Dl, 0x2CC85E82l, 0x4F4EC577l, 0x3AB64AE0l, 0xFFC537F6l, - 0xA90F6BF2l, 0x5060B8B4l, 0x19E11968l, 0x714CA34Fl, 0xEE3BE15Cl, - 0x8CE2D14Bl, 0x469FF67Bl, 0xC1BC96A8l, 0x3858DA9Fl, 0x9B9DB21Fl, - 0xFD36B46Fl, 0x5A5479ADl, 0xFA52D080l }; - -static sal_uInt8 cbc_key[16] = -{ - 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 -}; -static sal_uInt8 cbc_iv[8] = -{ - 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 -}; - -static sal_Char cbc_data[40] = "7654321 Now is the time for "; - -static sal_uInt8 arcfour_key[6][30] = -{ - { 8, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, - { 8, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, - { 8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 4, 0xef, 0x01, 0x23, 0x45 }, - { 8, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, - { 4, 0xef, 0x01, 0x23, 0x45 } -}; -static sal_uInt8 arcfour_data_len[6] = -{ - 8, 8, 8, 20, 28, 10 -}; -static sal_uInt8 arcfour_data[6][30] = -{ - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff }, - { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, - 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, - 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, - 0x12, 0x34, 0x56, 0x78, 0xff }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff } -}; - -#if OSL_DEBUG_LEVEL > 0 -static sal_uInt8 ecb_ok[32] = -{ - 0x2A, 0xFD, 0x7D, 0xAA, 0x60, 0x62, 0x6B, 0xA3, - 0x86, 0x16, 0x46, 0x8C, 0xC2, 0x9C, 0xF6, 0xE1, - 0x29, 0x1E, 0x81, 0x7C, 0xC7, 0x40, 0x98, 0x2D, - 0x6F, 0x87, 0xAC, 0x5F, 0x17, 0x1A, 0xAB, 0xEA -}; -static sal_uInt8 cbc_ok[32] = -{ - 0x6B, 0x77, 0xB4, 0xD6, 0x30, 0x06, 0xDE, 0xE6, - 0x05, 0xB1, 0x56, 0xE2, 0x74, 0x03, 0x97, 0x93, - 0x58, 0xDE, 0xB9, 0xE7, 0x15, 0x46, 0x16, 0xD9, - 0x59, 0xF1, 0x65, 0x2B, 0xD5, 0xFF, 0x92, 0xCC -}; -static sal_uInt8 cfb_ok[] = -{ - 0xE7, 0x32, 0x14, 0xA2, 0x82, 0x21, 0x39, 0xCA, - 0xF2, 0x6E, 0xCF, 0x6D, 0x2E, 0xB9, 0xE7, 0x6E, - 0x3D, 0xA3, 0xDE, 0x04, 0xD1, 0x51, 0x72, 0x00, - 0x51, 0x9D, 0x57, 0xA6, 0xC3 -}; -static sal_uInt8 arcfour_ok[6][30] = -{ - { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96, 0x00}, - { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79, 0x00}, - { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a, 0x00}, - { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf, - 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba, - 0x36, 0xb6, 0x78, 0x58, 0x00 }, - { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89, - 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c, - 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87, - 0x40, 0x01, 0x1e, 0xcf, 0x00 }, - { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf, - 0xbd, 0x61, 0x00} -}; -#endif - -int SAL_CALL main (void) -{ - rtlCipher cipher; - - /* ECB */ - cipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB); - OSL_ASSERT(cipher != 0); - if (cipher != 0) - { - rtlCipherError result; - sal_uInt8 ecb_in[40], ecb_out[40]; - sal_uInt32 length = strlen(cbc_data) + 1; - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionBoth, - cbc_key, sizeof(cbc_key), NULL, 0); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (ecb_out, 0, sizeof(ecb_out)); - result = rtl_cipher_encode ( - cipher, cbc_data, length, ecb_out, sizeof(ecb_out)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (ecb_out, ecb_ok, sizeof(ecb_ok)) == 0); - - memset (ecb_in, 0, sizeof(ecb_in)); - result = rtl_cipher_decode ( - cipher, ecb_out, length, ecb_in, sizeof(ecb_in)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (ecb_in, cbc_data, length) == 0); - - rtl_cipher_destroy (cipher); - } - - /* CBC */ - cipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC); - OSL_ASSERT(cipher != 0); - if (cipher != 0) - { - rtlCipherError result; - sal_uInt8 cbc_in[40], cbc_out[40]; - sal_uInt32 length = strlen(cbc_data) + 1; - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionEncode, - cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv)); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (cbc_out, 0, sizeof(cbc_out)); - result = rtl_cipher_encode ( - cipher, cbc_data, length, cbc_out, sizeof(cbc_out)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (cbc_out, cbc_ok, sizeof(cbc_ok)) == 0); - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionDecode, - cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv)); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (cbc_in, 0, sizeof(cbc_in)); - result = rtl_cipher_decode ( - cipher, cbc_out, length, cbc_in, sizeof(cbc_in)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (cbc_in, cbc_data, length) == 0); - - rtl_cipher_destroy (cipher); - } - - /* CFB */ - cipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream); - OSL_ASSERT(cipher != 0); - if (cipher != 0) - { - rtlCipherError result; - sal_uInt8 cfb_in[40], cfb_out[40]; - sal_uInt32 length = strlen(cbc_data) + 1; - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionEncode, - cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv)); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (cfb_out, 0, sizeof(cfb_out)); - result = rtl_cipher_encode ( - cipher, cbc_data, length, cfb_out, sizeof(cfb_out)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (cfb_out, cfb_ok, sizeof(cfb_ok)) == 0); - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionDecode, - cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv)); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (cfb_in, 0, sizeof(cfb_in)); - result = rtl_cipher_decode ( - cipher, cfb_out, length, cfb_in, sizeof(cfb_in)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (cfb_in, cbc_data, length) == 0); - - rtl_cipher_destroy (cipher); - } - - /* ARCFOUR */ - cipher = rtl_cipher_create (rtl_Cipher_AlgorithmARCFOUR, rtl_Cipher_ModeStream); - OSL_ASSERT(cipher != 0); - if (cipher != 0) - { - rtlCipherError result; - sal_uInt8 arcfour_out[40]; - sal_Size length; - int i, n; - - n = SAL_N_ELEMENTS(arcfour_data_len); - for (i = 0; i < n; i++) - { - length = arcfour_data_len[i]; - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionBoth, - &(arcfour_key[i][1]), arcfour_key[i][0], 0, 0); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (arcfour_out, 0, sizeof(arcfour_out)); - result = rtl_cipher_encode ( - cipher, &(arcfour_data[i][0]), length, - arcfour_out, sizeof(arcfour_out)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (arcfour_out, arcfour_ok[i], length) == 0); - } - - n = arcfour_data_len[3]; - for (i = 1; i < n; i++) - { - length = i; - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionBoth, - &(arcfour_key[3][1]), arcfour_key[3][0], 0, 0); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (arcfour_out, 0, sizeof(arcfour_out)); - result = rtl_cipher_encode ( - cipher, &(arcfour_data[3][0]), length, - arcfour_out, sizeof(arcfour_out)); - OSL_ASSERT(result == rtl_Cipher_E_None); - OSL_ASSERT(memcmp (arcfour_out, arcfour_ok[3], length) == 0); - OSL_ASSERT(arcfour_out[length] == 0); - } - - n = arcfour_data_len[3]; - for (i = 1; i < n; i++) - { - length = i; - - result = rtl_cipher_init ( - cipher, rtl_Cipher_DirectionBoth, - &(arcfour_key[3][1]), arcfour_key[3][0], 0, 0); - OSL_ASSERT(result == rtl_Cipher_E_None); - - memset (arcfour_out, 0, sizeof(arcfour_out)); - result = rtl_cipher_encode ( - cipher, &(arcfour_data[3][0]), length, - &(arcfour_out[0]), sizeof(arcfour_out)); - OSL_ASSERT(result == rtl_Cipher_E_None); - - result = rtl_cipher_encode ( - cipher, &(arcfour_data[3][length]), n - length, - &(arcfour_out[length]), sizeof(arcfour_out) - length); - OSL_ASSERT(result == rtl_Cipher_E_None); - - OSL_ASSERT(memcmp (arcfour_out, arcfour_ok[3], length) == 0); - } - - rtl_cipher_destroy (cipher); - } - - /* Done */ - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/t_digest.c b/sal/workben/t_digest.c deleted file mode 100644 index 2372206950d3..000000000000 --- a/sal/workben/t_digest.c +++ /dev/null @@ -1,366 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <rtl/digest.h> - -static const char *digest_in_MD[] = -{ - "", - "a", - "abc", - "message digest", - "abcdefghijklmnopqrstuvwxyz", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - "12345678901234567890123456789012345678901234567890123456789012345678901234567890", - NULL, -}; - -static const char *digest_out_MD2[]= -{ - "8350e5a3e24c153df2275c9f80692773", - "32ec01ec4a6dac72c0ab96fb34c0b5d1", - "da853b0d3f88d99b30283a69e6ded6bb", - "ab4f496bfb2a530b219ff33031fe06b0", - "4e8ddff3650292ab5a4108c3aa47940b", - "da33def2a42df13975352846c30338cd", - "d5976f79d83d3a0dc9806c3c66f3efd8", -}; - -static const char *digest_out_MD5[]= -{ - "d41d8cd98f00b204e9800998ecf8427e", - "0cc175b9c0f1b6a831c399e269772661", - "900150983cd24fb0d6963f7d28e17f72", - "f96b697d7cb7938d525a2f31aaf161d0", - "c3fcd3d76192e4007dfb496cca67e13b", - "d174ab98d277d9f5a5611c2c9f419d9f", - "57edf4a22be3c955ac49da2e2107b67a", -}; - -static const char *digest_in_SHA[]= -{ - "abc", - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - NULL, -}; - -static const char *digest_out_SHA_0[]= -{ - "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880", - "d2516ee1acfa5baf33dfc1c471e438449ef134c8", -}; - -static const char *digest_out_SHA_1[]= -{ - "a9993e364706816aba3e25717850c26c9cd0d89d", - "84983e441c3bd26ebaae4aa1f95129e5e54670f1", -}; - -static const char *digest_bigout_SHA_0= - "3232affa48628a26653b5aaa44541fd90d690603"; - -static const char *digest_bigout_SHA_1= - "34aa973cd4c4daa4f61eeb2bdbad27316534016f"; - -static const char digest_key_HMAC_MD5_1[] = -{ - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x00 -}; -static const char digest_key_HMAC_MD5_2[] = -{ - /* "Jefe" */ - 'J', 'e', 'f', 'e', - 0x00 -}; -static const unsigned char digest_key_HMAC_MD5_3[] = -{ - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0x00 -}; -static const char *digest_key_HMAC_MD5[] = -{ - (const char*)&digest_key_HMAC_MD5_1, - (const char*)&digest_key_HMAC_MD5_2, /* "Jefe", */ - (const char*)&digest_key_HMAC_MD5_3, - NULL -}; - -static const unsigned char digest_in_HMAC_MD5_3[] = -{ - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, - 0x00 -}; -static const char *digest_in_HMAC_MD5[] = -{ - "Hi There", - "what do ya want for nothing?", - (const char*)&digest_in_HMAC_MD5_3, - NULL -}; - -static const char *digest_out_HMAC_MD5[] = -{ - "9294727a3638bb1c13f48ef8158bfc9d", - "750c783e6ab0b503eaa86e310a5db738", - "56be34521d144c88dbb8c733f0e8b3f6", - NULL -}; -static const char *digest_out_HMAC_SHA1[] = -{ - /* unofficial, i.e. not verified */ - "675b0b3a1b4ddf4e124872da6c2f632bfed957e9", - "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79", - "d730594d167e35d5956fd8003d0db3d3f46dc7bb", - NULL -}; - -static char *pt (unsigned char *md, int length) -{ - int i; - static char buf[80]; - - for (i=0; i<length; i++) - sprintf(&(buf[i*2]),"%02x",md[i]); - - return buf; -} - -int SAL_CALL main (void) -{ - const char **P,**R, **Q; - char *p; - int i=1, err=0; - - unsigned char md[80]; - unsigned char buffer[1000]; - - rtlDigest Digest; - - P=digest_in_MD; - R=digest_out_MD2; - i = 1; - while (*P) - { - rtl_digest_MD2 (*P, strlen(*P), md, sizeof(md)); - - p=pt (md, RTL_DIGEST_LENGTH_MD2); - if (strcmp (p, *R)) - { - printf("error calculating MD2 on '%s'\n",*P); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (MD2) %d ok\n",i); - i++; - R++; - P++; - } - - P=digest_in_MD; - R=digest_out_MD5; - i=1; - while (*P) - { - rtl_digest_MD5 (*P, strlen(*P), md, sizeof(md)); - - p=pt (md, RTL_DIGEST_LENGTH_MD5); - if (strcmp (p, *R)) - { - printf("error calculating MD5 on '%s'\n",*P); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (MD5) %d ok\n",i); - i++; - R++; - P++; - } - - P=digest_in_SHA; - R=digest_out_SHA_0; - i=1; - while (*P) - { - rtl_digest_SHA (*P, strlen(*P), md, sizeof(md)); - - p=pt (md, RTL_DIGEST_LENGTH_SHA); - if (strcmp (p, *R)) - { - printf("error calculating SHA-0 on '%s'\n",*P); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (SHA-0) %d ok\n",i); - i++; - R++; - P++; - } - - memset (buffer, 'a', sizeof(buffer)); - R = &digest_bigout_SHA_0; - - Digest = rtl_digest_createSHA(); - for (i=0; i<1000; i++) - rtl_digest_updateSHA (Digest, buffer, sizeof(buffer)); - - rtl_digest_getSHA (Digest, md, sizeof(md)); - rtl_digest_destroySHA (Digest); - - p=pt (md, RTL_DIGEST_LENGTH_SHA); - if (strcmp (p, *R)) - { - printf("error calculating SHA-0 on '%s'\n",p); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (SHA-0) n ok\n"); - - P=digest_in_SHA; - R=digest_out_SHA_1; - i=1; - while (*P) - { - rtl_digest_SHA1 (*P, strlen(*P), md, sizeof(md)); - - p=pt (md, RTL_DIGEST_LENGTH_SHA1); - if (strcmp (p, *R)) - { - printf("error calculating SHA-1 on '%s'\n",*P); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (SHA-1) %d ok\n",i); - i++; - R++; - P++; - } - - memset (buffer, 'a', sizeof(buffer)); - R = &digest_bigout_SHA_1; - - Digest = rtl_digest_createSHA1(); - for (i=0; i<1000; i++) - rtl_digest_updateSHA1 (Digest, buffer, sizeof(buffer)); - - rtl_digest_getSHA1 (Digest, md, sizeof(md)); - rtl_digest_destroySHA1 (Digest); - - p=pt (md, RTL_DIGEST_LENGTH_SHA1); - if (strcmp (p, *R)) - { - printf("error calculating SHA-1 on '%s'\n",p); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (SHA-1) n ok\n"); - - P=digest_in_HMAC_MD5; - Q=digest_key_HMAC_MD5; - R=digest_out_HMAC_MD5; - Digest = rtl_digest_createHMAC_MD5(); - i = 1; - while (*P) - { - rtl_digest_initHMAC_MD5 (Digest, (const sal_uInt8*)(*Q), strlen(*Q)); - rtl_digest_updateHMAC_MD5 (Digest, *P, strlen(*P)); - rtl_digest_getHMAC_MD5 (Digest, md, sizeof(md)); - - p=pt (md, RTL_DIGEST_LENGTH_HMAC_MD5); - if (strcmp (p, *R)) - { - printf("error calculating HMAC-MD5 on '%s'\n",*P); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (HMAC-MD5) %d ok\n",i); - i++; - R++; - P++; - Q++; - } - rtl_digest_destroyHMAC_MD5 (Digest); - - P=digest_in_HMAC_MD5; - Q=digest_key_HMAC_MD5; - R=digest_out_HMAC_SHA1; - Digest = rtl_digest_createHMAC_SHA1(); - i = 1; - while (*P) - { - rtl_digest_initHMAC_SHA1 (Digest, (const sal_uInt8*)(*Q), strlen(*Q)); - rtl_digest_updateHMAC_SHA1 (Digest, (const sal_uInt8*)(*P), strlen(*P)); - rtl_digest_getHMAC_SHA1 (Digest, md, sizeof(md)); - - p=pt (md, RTL_DIGEST_LENGTH_HMAC_SHA1); - if (strcmp (p, *R)) - { - printf("error calculating HMAC-SHA-1 on '%s'\n",*P); - printf("got %s instead of %s\n",p,*R); - err++; - } - else - printf("test (HMAC-SHA-1) %d ok\n",i); - i++; - P++; - Q++; - R++; - } - rtl_digest_destroyHMAC_SHA1 (Digest); - - P=digest_in_HMAC_MD5; - Q=digest_key_HMAC_MD5; - rtl_digest_PBKDF2 ( - md, RTL_DIGEST_LENGTH_MD5, /* [out] derived key */ - (const sal_uInt8*)(Q[1]), strlen(Q[1]), /* [in] password */ - (const sal_uInt8*)(P[1]), strlen(P[1]), /* [in] salt */ - 1000); /* [in] iteration count */ - - p=pt (md, RTL_DIGEST_LENGTH_MD5); - if (strcmp (p, "6349e09cb6b8c1485cfa9780ee3264df")) - { - printf("error calculating PBKDF2 on '%s'\n", P[1]); - err++; - } - else - printf("test (PBKDF2) %d ok\n", 1); - - return err; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/t_ojp_exe.cxx b/sal/workben/t_ojp_exe.cxx deleted file mode 100644 index 8cd71267cdeb..000000000000 --- a/sal/workben/t_ojp_exe.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include <windows.h> -#else -# include <unistd.h> -#endif - -#include <stdio.h> - -int main(int argc, char* argv[]) -{ - printf("osl process test executable started:\n"); - -#ifdef _WIN32 - Sleep(5000); -#else - sleep(5); -#endif - - printf("osl process test executable ended:\n"); - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/t_osl_getVolInfo.cxx b/sal/workben/t_osl_getVolInfo.cxx deleted file mode 100644 index abb1cb5c1758..000000000000 --- a/sal/workben/t_osl_getVolInfo.cxx +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/types.h> -#include <cppunit/simpleheader.hxx> -#include <osl/file.h> -#include <rtl/ustring.hxx> - -#ifdef _WIN32 -# define TEST_PATH_1 "c:\\" -# define TEST_PATH_2 "c:\\mnt\\MSDN" -# define TEST_PATH_3 "c:\\Program Files" -# define TEST_PATH_4 "\\\\Tra-1\\mnt\\c" -# define TEST_PATH_5 "\\\\Tra-1\\mnt" -# define TEST_PATH_6 "\\\\Tra-1\\mnt\\c\\" -#else // UNX -# define TEST_PATH_1 "/net/athene/export/home/tra" -# define TEST_PATH_2 "/net/athene/export/home/tra/" -# define TEST_PATH_3 "/" -# define TEST_PATH_4 "." -# define TEST_PATH_5 "/net/athene/export/home/tra/projects" -# define TEST_PATH_6 "/blah" -#endif - -void test_getVolumeInformation(const rtl::OUString& path_url) - { - oslVolumeInfo vi; - memset((void*)&vi, 0, sizeof(vi)); - vi.uStructSize = sizeof(vi); - vi.pDeviceHandle = NULL; - - oslFileError err = osl_getVolumeInformation( - path_url.pData, - &vi, - osl_VolumeInfo_Mask_Attributes | - osl_VolumeInfo_Mask_TotalSpace | - osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FreeSpace | - osl_VolumeInfo_Mask_MaxNameLength | - osl_VolumeInfo_Mask_MaxPathLength | - osl_VolumeInfo_Mask_FileSystemName | - osl_VolumeInfo_Mask_DeviceHandle); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_getVolumeInformation failed", - err == osl_File_E_None - ); - } - -class TestClass_osl_getVolumeInformation : public CppUnit::TestFixture -{ -public: - - /*------------------------------------- - Start a process and join with this - process specify a timeout so that - osl_joinProcessWithTimeout returns - osl_Process_E_TimedOut - -------------------------------------*/ - - void test_osl_getVolumeInformation() - { - rtl::OUString path = rtl::OUString(TEST_PATH_1); - rtl::OUString path_url; - osl_getFileURLFromSystemPath(path.pData, &path_url.pData); - test_getVolumeInformation(path_url); - - path = rtl::OUString(TEST_PATH_2); - osl_getFileURLFromSystemPath(path.pData, &path_url.pData); - test_getVolumeInformation(path_url); - - path = rtl::OUString(TEST_PATH_3); - osl_getFileURLFromSystemPath(path.pData, &path_url.pData); - test_getVolumeInformation(path_url); - - path = rtl::OUString(TEST_PATH_4); - osl_getFileURLFromSystemPath(path.pData, &path_url.pData); - test_getVolumeInformation(path_url); - - path = rtl::OUString(TEST_PATH_5); - osl_getFileURLFromSystemPath(path.pData, &path_url.pData); - test_getVolumeInformation(path_url); - - path = rtl::OUString(TEST_PATH_6); - osl_getFileURLFromSystemPath(path.pData, &path_url.pData); - test_getVolumeInformation(path_url); - } - - CPPUNIT_TEST_SUITE( TestClass_osl_getVolumeInformation ); - CPPUNIT_TEST( test_osl_getVolumeInformation ); - CPPUNIT_TEST_SUITE_END( ); -}; - -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestClass_osl_getVolumeInformation, "Test osl_getVolumeInformation"); - -NOADDITIONAL; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/t_osl_joinProcess.cxx b/sal/workben/t_osl_joinProcess.cxx deleted file mode 100644 index 08fd6c543608..000000000000 --- a/sal/workben/t_osl_joinProcess.cxx +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/types.h> -#include <cppunit/simpleheader.hxx> -#include <osl/process.h> -#include <rtl/ustring.hxx> -#include <unistd.h> -#include <signal.h> - -#ifdef _WIN32 - const rtl::OUString IMAGE_NAME("ojpx.exe"); -#else - const rtl::OUString IMAGE_NAME("ojpx"); -#endif - -const rtl::OUString CWD("."); - -class Test_osl_Process : public CppUnit::TestFixture -{ -public: - - /*------------------------------------- - Start a process and join with this - process specify a timeout so that - osl_joinProcessWithTimeout returns - osl_Process_E_TimedOut - -------------------------------------*/ - - void test_osl_joinProcessWithTimeout_timeout_failure() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity(); - oslProcessError osl_error = osl_executeProcess( - IMAGE_NAME.pData, - NULL, - 0, - osl_Process_NORMAL, - security, - CWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_createProcess failed", - osl_error == osl_Process_E_None - ); - - TimeValue timeout; - timeout.Seconds = 1; - timeout.Nanosec = 0; - - osl_error = osl_joinProcessWithTimeout(process, &timeout); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_joinProcessWithTimeout returned without timeout failure", - osl_Process_E_TimedOut == osl_error - ); - - osl_error = osl_terminateProcess(process); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_terminateProcess failed", - osl_error == osl_Process_E_None - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process specify a timeout so that - osl_joinProcessWithTimeout returns - osl_Process_E_None - -------------------------------------*/ - - void test_osl_joinProcessWithTimeout_without_timeout_failure() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity(); - oslProcessError osl_error = osl_executeProcess( - IMAGE_NAME.pData, - NULL, - 0, - osl_Process_NORMAL, - security, - CWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_createProcess failed", - osl_error == osl_Process_E_None - ); - - TimeValue timeout; - timeout.Seconds = 10; - timeout.Nanosec = 0; - - osl_error = osl_joinProcessWithTimeout(process, &timeout); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_joinProcessWithTimeout returned with failure", - osl_Process_E_None == osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process specify an infinite timeout - -------------------------------------*/ - - void test_osl_joinProcessWithTimeout_infinite() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity(); - oslProcessError osl_error = osl_executeProcess( - IMAGE_NAME.pData, - NULL, - 0, - osl_Process_NORMAL, - security, - CWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_createProcess failed", - osl_error == osl_Process_E_None - ); - - osl_error = osl_joinProcessWithTimeout(process, NULL); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_joinProcessWithTimeout returned with failure", - osl_Process_E_None == osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process using osl_joinProcess - -------------------------------------*/ - - void test_osl_joinProcess() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity(); - oslProcessError osl_error = osl_executeProcess( - IMAGE_NAME.pData, - NULL, - 0, - osl_Process_NORMAL, - security, - CWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_createProcess failed", - osl_error == osl_Process_E_None - ); - - osl_error = osl_joinProcess(process); - - CPPUNIT_ASSERT_MESSAGE - ( - "osl_joinProcess returned with failure", - osl_Process_E_None == osl_error - ); - - osl_freeProcessHandle(process); - } - - CPPUNIT_TEST_SUITE(Test_osl_Process); - CPPUNIT_TEST(test_osl_joinProcessWithTimeout_timeout_failure); - CPPUNIT_TEST(test_osl_joinProcessWithTimeout_without_timeout_failure); - CPPUNIT_TEST(test_osl_joinProcessWithTimeout_infinite); - CPPUNIT_TEST(test_osl_joinProcess); - CPPUNIT_TEST_SUITE_END(); -}; - -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test_osl_Process, "Test_osl_Process"); - -NOADDITIONAL; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/t_random.c b/sal/workben/t_random.c deleted file mode 100644 index d0d73441dfe8..000000000000 --- a/sal/workben/t_random.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <rtl/random.h> - -static char *pt (unsigned char *md, int length) -{ - int i; - static char buf[80]; - - for (i=0; i<length; i++) - sprintf(&(buf[i*2]),"%02x",md[i]); - - return buf; -} - -/* - * main. - */ -int SAL_CALL main (void) -{ - rtlRandomPool pool; - pool = rtl_random_createPool(); - if (pool) - { - unsigned char buffer[1000]; - - rtl_random_getBytes (pool, buffer, 8); - printf ("random: %s\n", pt (buffer, 8)); - } - rtl_random_destroyPool (pool); - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/t_readline.c b/sal/workben/t_readline.c deleted file mode 100644 index c824f10a9abf..000000000000 --- a/sal/workben/t_readline.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "osl/file.h" - -#include "osl/diagnose.h" -#include "rtl/ustring.h" -#include "rtl/byteseq.h" - -#include <stdio.h> - -/* main */ -int main (int argc, char ** argv) -{ - if (argc > 1) - { - oslFileError result; - oslFileHandle hFile = 0; - - rtl_uString * pSystemPath = 0; - rtl_uString * pFileUrl = 0; - - rtl_uString_newFromAscii (&pSystemPath, argv[1]); - - result = osl_getFileURLFromSystemPath (pSystemPath, &pFileUrl); - rtl_uString_release (pSystemPath), pSystemPath = 0; - if (result != osl_File_E_None) - return result; - - result = osl_openFile (pFileUrl, &hFile, osl_File_OpenFlag_Read); - rtl_uString_release (pFileUrl), pFileUrl = 0; - if (result == osl_File_E_None) - { - sal_Sequence * pBuffer = 0; - for ( ;; ) - { - sal_Int32 i, n; - - result = osl_readLine (hFile, &pBuffer); - if (result != osl_File_E_None) - break; - for (i = 0, n = pBuffer->nElements; i < n; i++) - printf ("%c", (char)(pBuffer->elements[i])); - printf("\n"); - } - - rtl_byte_sequence_release (pBuffer), pBuffer = 0; - (void) osl_closeFile (hFile); - } - } - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/test.cxx b/sal/workben/test.cxx deleted file mode 100644 index faed0d8822ee..000000000000 --- a/sal/workben/test.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <stdio.h> - -#if (defined UNX) -int main( int argc, char * argv[] ) -#else -int _cdecl main( int argc, char * argv[] ) -#endif -{ - void test_int64(); - test_int64(); - - void test_profile(); - test_profile(); - - void test_OString(); - test_OString(); - -/* void test_OWString(); */ -/* test_OWString(); */ - -/* void test_OStringBuffer(); */ -/* test_OStringBuffer(); */ - -/* void test_OWStringBuffer(); */ -/* test_OWStringBuffer(); */ - -/* void test_OString2OWStringAndViceVersa(); */ -/* test_OString2OWStringAndViceVersa(); */ - - void test_uuid(); - test_uuid(); - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/testfile.cxx b/sal/workben/testfile.cxx deleted file mode 100644 index 3b3590f3bbce..000000000000 --- a/sal/workben/testfile.cxx +++ /dev/null @@ -1,2550 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#define UNICODE - -#include <osl/file.hxx> -#include <osl/process.h> -#include <osl/time.h> -#include <rtl/alloc.h> -#include <rtl/ustring.hxx> -#include <stdio.h> -#include <string.h> -#include <time.h> - -#ifdef UNX -#include <wchar.h> -#endif - -#ifdef _WIN32 -#include <windows.h> -#endif - -using namespace osl; - -rtl::OUString root; - -rtl::OUString dir1; -rtl::OUString dir2; -rtl::OUString dir_on_server; -rtl::OUString dir_not_exist; -rtl::OUString dir_not_exist_on_server; -rtl::OUString dir_wrong_semantic; - -rtl::OUString file1; -rtl::OUString file2; -rtl::OUString file3; -rtl::OUString file_on_server; -rtl::OUString file_not_exist; - -void print_error(const ::rtl::OString& str, FileBase::RC rc); - -void PressKey() -{ - printf("\nPress Return !\n"); - getchar(); -} - -void printFileName(const ::rtl::OUString& str) -{ - rtl::OString aString; - - aString = rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - - printf( "%s", aString.getStr() ); - - return; -} - -// Initialization - -sal_Bool testLineBreak( sal_Char *pCount , sal_uInt64 nLen , sal_uInt32 *cLineBreak ) -{ - sal_Bool fSuccess=sal_False; - *cLineBreak=0; - - if (nLen==0) - return fSuccess; - - if ( *pCount==13 ) - { - if (nLen>=1 && *(pCount+1)==10) - *cLineBreak=2; - else - *cLineBreak=1; - - if (nLen>=2 && *(pCount+2)==10) - (*cLineBreak)++; - - fSuccess=sal_True; - } - else if ( *pCount==10 ) - { - *cLineBreak=1; - fSuccess=sal_True; - } - - return fSuccess; -} - -// Initialization - -sal_Bool Initialize() -{ - DirectoryItem aItem; - FileStatus aStatus( osl_FileStatus_Mask_All ); - rtl_uString *strExeFileURL=NULL; - oslProcessError ProcessError; - - rtl::OUString iniFileURL; - File *pFile; - - FileBase::RC rc; - - sal_uInt64 uBytesRequested; - sal_uInt64 uBytesRead; - sal_Char *pBuffer; - sal_Char *pBegin; - sal_Char *pCount; - - rtl::OUString dir[12]; - - // Open to the ini-file - - ProcessError=osl_getExecutableFile(&strExeFileURL); - - if ( ProcessError == osl_Process_E_None) - { - sal_Unicode *pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL); - - // Search for the last slash in the Path - while (*pExeFileCount!=L'/' && pExeFileCount>rtl_uString_getStr(strExeFileURL)) - pExeFileCount--; - - // iniFileURL = strExeFileURL without the filename of the exe-File - iniFileURL=rtl::OUString( rtl_uString_getStr(strExeFileURL) ,(int) (pExeFileCount-rtl_uString_getStr(strExeFileURL)) ); - - // add "/testfile.ini" to iniFileURL - iniFileURL+=rtl::OUString("/testfile.ini"); - - // Open the ini-File - pFile=new File( iniFileURL ); - rc=pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write ); - if ( rc!=FileBase::E_None ) - { - rtl_uString_release(strExeFileURL); - return sal_False; - } - } - else - { - rtl_uString_release(strExeFileURL); - return sal_False; - } - - // Get filesize of the ini-File - - rc=DirectoryItem::get( iniFileURL, aItem ); - if ( rc!=FileBase::E_None ) - return sal_False; - - rc=aItem.getFileStatus( aStatus ); - if ( rc!=FileBase::E_None ) - return sal_False; - - uBytesRequested=aStatus.getFileSize(); - - // read ini-File - rc=pFile->setPos( osl_Pos_Absolut, 0 ); - pBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32) (uBytesRequested+1)*sizeof(sal_Char) ); - memset( pBuffer, 0, (sal_uInt32)(uBytesRequested+1)*sizeof(sal_Char) ); - - rc=pFile->read( pBuffer , uBytesRequested , uBytesRead ); - if ( rc!=FileBase::E_None ) - return sal_False; - - pBegin=pBuffer; - pCount=pBegin; - - for ( int i=0 ; i<12 ; i++ ) - { - sal_uInt32 cLineBrake=0; - while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && *pCount!='=') - pCount++; - - pCount++; - pBegin=pCount; - - while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && !testLineBreak(pCount,uBytesRead-(pCount-pBuffer), &cLineBrake)) - pCount++; - - dir[i]=rtl::OUString(pBegin, pCount-pBegin, RTL_TEXTENCODING_ASCII_US); - - pCount+=cLineBrake; - pBegin=pCount; - } - - root=rtl::OUString(dir[0]); - dir1=rtl::OUString(dir[1]); - dir2=rtl::OUString(dir[2]); - dir_on_server=rtl::OUString(dir[3]); - dir_not_exist=rtl::OUString(dir[4]); - dir_not_exist_on_server=rtl::OUString(dir[5]); - dir_wrong_semantic=rtl::OUString(dir[6]); - - file1=rtl::OUString(dir[7]); - file2=rtl::OUString(dir[8]); - file3=rtl::OUString(dir[9]); - file_on_server=rtl::OUString(dir[10]); - file_not_exist=rtl::OUString(dir[11]); - - // close the ini-file - rc=pFile->close(); - - rtl_freeMemory( pBuffer ); - - // Create directories - rc=Directory::create( dir1 ); - if ( rc!=FileBase::E_None ) - return sal_False; - - rc=Directory::create( dir2 ); - if ( rc!=FileBase::E_None ) - return sal_False; - - rc=Directory::create( dir_on_server ); - if ( rc!=FileBase::E_None ) - return sal_False; - - pFile=new File( file1 ); - rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - if ( rc!=FileBase::E_None ) - return sal_False; - rc=pFile->close(); - delete pFile; - - pFile=new File( file2 ); - rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - if ( rc!=FileBase::E_None ) - return sal_False; - rc=pFile->close(); - delete pFile; - - pFile=new File( file_on_server ); - rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - if ( rc!=FileBase::E_None ) - return sal_False; - rc=pFile->close(); - delete pFile; - - return sal_True; -} - -// Shutdown - -sal_Bool Shutdown() -{ - sal_Bool fSuccess=sal_True; - FileBase::RC rc; - File *pFile; - - // remove created files - - pFile=new File( file1 ); - rc=pFile->remove( file1 ); - if ( rc!=FileBase::E_None ) - fSuccess=sal_False; - delete pFile; - - pFile=new File( file2 ); - rc=pFile->remove( file2 ); - if ( rc!=FileBase::E_None ) - fSuccess=sal_False; - delete pFile; - - // remove created directories - - rc=Directory::remove( dir1 ); - if ( rc!=FileBase::E_None ) - fSuccess=sal_False; - - rc=Directory::remove( dir2 ); - if ( rc!=FileBase::E_None ) - fSuccess=sal_False; - - // remove created file on the server - - pFile=new File( file_on_server ); - rc=pFile->remove( file_on_server ); - if ( rc!=FileBase::E_None ) - fSuccess=sal_False; - delete pFile; - - // remove created directory on the server - - rc=Directory::remove( dir_on_server ); - if ( rc!=FileBase::E_None ) - fSuccess=sal_False; - - return fSuccess; -} - -// helper functions - -// Show FileType -void showFileType( FileStatus::Type aType ) -{ - if ( aType==FileStatus::Directory ) - printf( "FileType: Directory \n" ); - else if ( aType==FileStatus::Volume ) - printf( "FileType: Volume \n" ); - else if ( aType==FileStatus::Regular ) - printf( "FileType: Regular \n" ); - else if ( aType==FileStatus::Unknown ) - printf( "FileType: Unknown \n" ); - -} - -// Show Attributes -void showAttributes( sal_uInt64 uAttributes ) -{ - if ( uAttributes==0 ) - printf( "No Attributes \n" ); - if ( uAttributes & osl_File_Attribute_ReadOnly ) - printf( "Attribute: ReadOnly \n" ); - if ( uAttributes & osl_File_Attribute_Hidden ) - printf( "Attribute: Hidden \n" ); - if ( uAttributes & osl_File_Attribute_Executable ) - printf( "Attribute: Executable \n"); - if ( uAttributes & osl_File_Attribute_GrpWrite ) - printf( "Attribute: GrpWrite \n"); - if ( uAttributes & osl_File_Attribute_GrpRead ) - printf( "Attribute: GrpRead \n" ); - if ( uAttributes & osl_File_Attribute_GrpExe ) - printf( "Attribute: GrpExe \n" ); - if ( uAttributes & osl_File_Attribute_OwnWrite ) - printf( "Attribute: OwnWrite \n"); - if ( uAttributes & osl_File_Attribute_OwnRead ) - printf( "Attribute: OwnRead \n" ); - if ( uAttributes & osl_File_Attribute_OwnExe ) - printf( "Attribute: OwnExe \n" ); - if ( uAttributes & osl_File_Attribute_OthWrite ) - printf( "Attribute: OthWrite \n" ); - if ( uAttributes & osl_File_Attribute_OthRead ) - printf( "Attribute: OthRead \n"); - if ( uAttributes & osl_File_Attribute_OthExe ) - printf( "Attribute: OthExe \n" ); - - return; -} - -// Show Time -void showTime( TimeValue aTime ) -{ - TimeValue aLocalTimeVal, aSystemTimeVal , aSysTimeVal; - oslDateTime aDateTime, aSystemTime; - - if ( osl_getLocalTimeFromSystemTime( &aTime, &aLocalTimeVal ) ) - { - if ( osl_getDateTimeFromTimeValue( &aLocalTimeVal, &aDateTime ) ) - { - printf("\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds); - } - else - printf("Error !\n"); - } - - if ( osl_getDateTimeFromTimeValue( &aTime, &aSystemTime ) ) - { - printf("SystemTime: \t\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aSystemTime.Day, aSystemTime.Month, aSystemTime.Year, aSystemTime.Hours, aSystemTime.Minutes, aSystemTime.Seconds); - } - else - printf("Error !\n"); - - //Verify - - if ( osl_getTimeValueFromDateTime( &aSystemTime, &aSystemTimeVal ) ) - { - if ( ( aSystemTimeVal.Seconds == aTime.Seconds ) && ( aSystemTimeVal.Nanosec == aTime.Nanosec )) - printf ("Verify : TimeValue : ok! \n"); - else - { - printf ("Verify : TimeValue : Error! \n"); - printf ("aTime : %u \n", aTime.Seconds); - printf ("aSystemTimeVal : %u \n", aSystemTimeVal.Seconds); - } - } - else - printf ("Verify : TimeValue : Error! \n"); - - if ( osl_getSystemTimeFromLocalTime( &aLocalTimeVal , &aSysTimeVal ) ) - { - if ( ( aSysTimeVal.Seconds == aTime.Seconds ) && ( aSysTimeVal.Nanosec == aTime.Nanosec )) - printf ("Verify : SystemTime : ok! \n"); - else - { - printf ("Verify : SystemTime : Error! \n"); - printf ("aTime : %u\n", aTime.Seconds); - printf ("aSystemTimeVal : %u\n", aSysTimeVal.Seconds); - } - } - else - printf ("Verify : SystemTime : Error! \n"); - - return; -} - -TimeValue getSystemTime() -{ - TimeValue aTime; - time_t ltime; - - time( <ime ); - - aTime.Seconds = ltime; - aTime.Nanosec = 0; - - return aTime; -} - -// DirectoryOpenAndCloseTest - -void DirectoryOpenAndCloseTest() -{ - FileBase::RC rc; - Directory *pDir; - - printf( "--------------------------------------------\n"); - printf( "Directory-Open-And-Close-Test\n"); - printf( "--------------------------------------------\n\n"); - - // open an existing directory - - pDir=new Directory( dir1 ); - printf( "Open an existing directory: "); - printFileName( dir1 ); - printf( "\n" ); - - rc= pDir->open(); - print_error( rtl::OString( "Open Directory" ), rc ); - - if ( pDir->isOpen() ) - { - print_error( rtl::OString( "Directory is Open" ), rc ); - } - - // Close Directory - rc=pDir->close(); - print_error( rtl::OString( "Close Directory" ), rc ); - - delete pDir; - printf( "\n" ); - - // open a not existing directory - - pDir=new Directory( dir_not_exist ); - - printf( "Open a not existing directory: "); - printFileName( dir_not_exist ); - printf( "\n" ); - - rc= pDir->open(); - - print_error( rtl::OString( "Open Directory" ), rc ); - - delete pDir; - - printf( "\n" ); - - // open a directory with a wrong semantic - - pDir=new Directory( dir_wrong_semantic ); - - printf( "Open a directory with a wrong semantic: "); - printFileName( dir_wrong_semantic ); - printf( "\n" ); - - rc= pDir->open(); - print_error( rtl::OString( "Open Directory" ), rc ); - - delete pDir; - - printf( "\n" ); - - // open an existing directory on a server - - pDir=new Directory( dir_on_server ); - - printf( "Open an existing directory on a server: "); - printFileName( dir_on_server ); - printf( "\n" ); - - rc= pDir->open(); - print_error( rtl::OString( "Open Directory" ), rc ); - - // Close Directory - rc=pDir->close(); - print_error( rtl::OString( "Close Directory" ), rc ); - - delete pDir; - printf( "\n" ); - - // open a not existing directory on a server - - pDir=new Directory( dir_not_exist_on_server ); - - printf( "Open a not existing directory on a server: "); - printFileName( dir_not_exist_on_server ); - printf( "\n" ); - - rc= pDir->open(); - print_error( rtl::OString( "Open Directory" ), rc ); - - delete pDir; - printf( "\n" ); - - // Close a not existing directory - - pDir=new Directory( dir_not_exist ); - printf( "Close a not existing directory: "); - printFileName( dir_not_exist ); - printf( "\n" ); - - rc=pDir->close(); - print_error( rtl::OString( "Close Directory" ), rc ); - - PressKey(); - return; - -} - -// DirectoryCreateAndRemoveTest - -void DirectoryCreateAndRemoveTest() -{ - FileBase::RC rc,rc1; - Directory *pDir; - - printf( "--------------------------------------------\n" ); - printf( "Directory-Create-And-Remove-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - // Create directory - - printf( "Create a not existing directory: "); - printFileName( dir_not_exist ); - printf( "\n" ); - - rc=Directory::create( dir_not_exist) ; - print_error( rtl::OString( "Create Directory" ), rc ); - - // Verify - pDir=new Directory( dir_not_exist ); - - rc= pDir->open(); - print_error( rtl::OString( "Verify" ), rc ); - pDir->close(); - delete pDir; - - printf( "\n" ); - - // Create a directory on a server - - printf( "Create a not existing directory on a server: "); - printFileName( dir_not_exist_on_server ); - printf( "\n" ); - - rc=Directory::create( dir_not_exist_on_server ); - print_error( rtl::OString( "Create Directory" ), rc ); - - // Verify - pDir=new Directory( dir_not_exist_on_server ); - rc= pDir->open(); - print_error( rtl::OString( "Verify" ), rc ); - pDir->close(); - delete pDir; - - printf( "\n" ); - - // Remove Directories - - printf( "Remove the created directories: \n" ); - - rc=Directory::remove( dir_not_exist ); - - rc1=Directory::remove( dir_not_exist_on_server ); - - if ( rc==FileBase::E_None && rc1==FileBase::E_None ) - print_error( rtl::OString( "Remove Directories" ), FileBase::E_None ); - else if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Remove local Directory" ),rc ); - else - print_error( rtl::OString( "Remove Directory on a server" ),rc1 ); - - printf( "\n" ); - - // Remove a not existing directory - - printf( "Remove a not existing directory: "); - printFileName( dir_not_exist ); - printf( "\n" ); - - rc=Directory::remove( dir_not_exist ); - print_error( rtl::OString( "Remove" ),rc ); - - PressKey(); - return; -} - -// FileOpenAndCloseTest - -static void FileOpenAndCloseTest() -{ - FileBase::RC rc; - - printf( "--------------------------------------------\n" ); - printf( "File-Open-And-Close-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - File *pFile; - - pFile=new File( file1 ); - - printf( "Open an existing file: "); - printFileName( file1 ); - printf( "\n" ); - - // open an existing file (Read) - - rc=pFile->open( osl_File_OpenFlag_Read ); - print_error( rtl::OString( "Open File (Read)" ), rc ); - - // close the file - - rc=pFile->close(); - print_error( rtl::OString( "Close File" ), rc ); - - printf( "\n" ); - - // open an existing file (Write) - - rc=pFile->open( osl_File_OpenFlag_Write ); - print_error( rtl::OString( "Open File (Write)" ), rc ); - - // close the file - - rc=pFile->close(); - print_error( rtl::OString( "Close File" ), rc ); - - printf( "\n" ); - - // close the file a second time - - rc=pFile->close(); - print_error( rtl::OString( "Close the file a second time" ), rc ); - - delete pFile; - PressKey(); -} - -// FileCreateAndRemoveTest - -void FileCreateAndRemoveTest() -{ - FileBase::RC rc; - File *pFile; - - printf( "--------------------------------------------\n" ); - printf( "File-Create-And-Remove-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - pFile=new File( file_not_exist ); - - printf( "Create File: "); - printFileName( file_not_exist ); - printf( "\n" ); - - // open (create) a not existing file (Read and write) - - rc = pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - - print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc ); - - // close the file - - rc=pFile->close(); - print_error( rtl::OString( "Close File" ), rc ); - - // remove the file - - rc=pFile->remove( file_not_exist ); - print_error( rtl::OString(" Remove File" ), rc ); - - printf( "\n" ); - - // remove the same file a second time - - rc=pFile->remove( file_not_exist ); - print_error( rtl::OString( "Remove a not existing File" ), rc ); - - // remove an open file - - pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - - rc=pFile->remove( file_not_exist ); - print_error( rtl::OString( "Remove an open File" ), rc ); - - pFile->close(); - pFile->remove( file_not_exist ); - - PressKey(); - - return; -} - -// FileWriteAndReadTest - -void FileWriteAndReadTest() -{ - FileBase::RC rc; - - sal_uInt64 uWritten; - sal_uInt64 uRead; - const sal_Char *pWriteBuffer="Hier kommt der Osterhase !"; - sal_uInt64 nLen=strlen( pWriteBuffer ); - sal_Char *pReadBuffer; - - printf( "--------------------------------------------\n" ); - printf( "File-Write-And-Read-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - File *pFile; - - pFile=new File( file_not_exist ); - - printf( "Create File: "); - printFileName( file_not_exist ); - printf("\n"); - - // open (create) a not existing file (Read and write) - - rc = pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - - print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc ); - - printf( "\n" ); - - // write a string to the file - - rc=pFile->write( pWriteBuffer , nLen , uWritten ); - print_error( rtl::OString( "Write File" ), rc ); - - if(uWritten==nLen) - printf( "Verify: OK! \n" ); - else - printf( "Verify: Error\n" ); - - printf( "\n" ); - - // move the filepointer to the beginning - - rc=pFile->setPos( osl_Pos_Absolut , 0 ); - print_error( rtl::OString( "Set FilePointer to the beginning of the file" ), rc ); - - printf( "\n" ); - - // read the string - - pReadBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32)(nLen+1)*sizeof(sal_Char) ); - memset( pReadBuffer, 0, (sal_uInt32)(nLen+1)*sizeof(sal_Char) ); - rc=pFile->read( pReadBuffer , nLen,uRead ); - print_error( rtl::OString( "Read File" ), rc ); - - if (strcmp(pWriteBuffer, pReadBuffer)==0) - { - printf( "Verify: OK !\n" ); - printf( "Text: %s\n",pReadBuffer ); - } - else - printf( "Verify: Error\n" ); - - rtl_freeMemory( pReadBuffer ); - - printf( "\n" ); - - // close the file - rc=pFile->close(); - print_error( rtl::OString( "Close File" ), rc ); - - // remove the file - rc=pFile->remove( file_not_exist ); - print_error( rtl::OString( "Remove File" ), rc ); - - PressKey(); - - return; - -} - -// FileCopyMoveTest - -void FileCopyAndMoveTest() -{ - FileBase::RC rc; - - printf( "--------------------------------------------\n" ); - printf( "File-Copy-Move-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - File *pFile; - rtl::OUString destPath(dir2); - - // FileCopyTest - - destPath+=rtl::OUString("/"); - destPath+=file3; - - printf( "Copy the file "); - printFileName( file1 ); - printf( " to "); - printFileName( destPath ); - printf( "\n" ); - - rc=File::copy( file1 , destPath ); - print_error( rtl::OString( "FileCopy" ), rc ); - - pFile=new File( destPath ); - - rc=pFile->open( osl_File_OpenFlag_Read ); - if ( rc == FileBase::E_None) - { - printf( "Verify: OK!\n" ); - pFile->close(); - File::remove( destPath ); - } - else - printf( "Verify: Error!\n" ); - - delete pFile; - - printf( "\n" ); - - // Copy a file to a not existing directory - - destPath=rtl::OUString( dir_not_exist ); - destPath+=rtl::OUString("/"); - destPath+=file3; - - printf( "Copy a file to a not existing directory \n"); - printf( "Copy the file %s to %s\n", - rtl::OUStringToOString( file1, RTL_TEXTENCODING_ASCII_US ).getStr(), - rtl::OUStringToOString( destPath, RTL_TEXTENCODING_ASCII_US ).getStr() ); - - rc=File::copy( file1, destPath ); - print_error( rtl::OString( "FileCopy" ), rc ); - - printf( "\n" ); - - // Copy a directory - - printf( "Copy the directory: "); - printFileName( dir1 ); - printf( " to "); - printFileName( dir2 ); - printf( "\n" ); - - rc=File::copy( dir1 , dir2 ); - print_error( rtl::OString( "FileCopy" ), rc ); - - printf( "\n" ); - - // FileMoveTest - - destPath=rtl::OUString( dir2 ); - destPath+=rtl::OUString("/"); - destPath+=file3; - - printf( "Move the file "); - printFileName( file1 ); - printf( " to "); - printFileName( destPath ); - printf( "\n" ); - - rc=File::move( file1, destPath ); - print_error( rtl::OString( "FileMove" ), rc ); - - pFile=new File( destPath ); - - rc=pFile->open( osl_File_OpenFlag_Read ); - if ( rc==FileBase::E_None ) - { - pFile->close(); - - delete pFile; - pFile=new File( file1 ); - - rc=pFile->open( osl_File_OpenFlag_Read ); - - if ( rc!=FileBase::E_None ) - { - printf( "Verify: OK!\n" ); - File::move( destPath, file1 ); - } - else - { - printf( "Verify: Error!\n" ); - pFile->close(); - File::remove( destPath ); - } - } - else - printf( "Verify: Error!\n" ); - - delete pFile; - - printf( "\n" ); - - // Move a file to a not existing directory - - destPath=rtl::OUString( dir_not_exist ); - destPath+=rtl::OUString("/"); - destPath+=file3; - - printf( "Move a file to a not existing directory: \n"); - printf( "Move the file "); - printFileName( file1 ); - printf( " to "); - printFileName( destPath ); - printf( "\n" ); - - rc=File::move( file1 , destPath ); - print_error( rtl::OString( "FileMove" ), rc ); - - printf( "\n" ); - - // Move a directory - - printf( "Move a directory: \n"); - - printf( "Move the directory "); - printFileName( dir1 ); - printf( " to "); - printFileName( dir_not_exist ); - printf( "\n" ); - - rc=File::move( dir1 , dir_not_exist); - print_error( rtl::OString( "FileMove" ), rc ); - - if ( rc == FileBase::E_None ) - File::move( dir_not_exist , dir1); - - printf( "\n" ); - - PressKey(); - return; -} - -// FileSizeTest - -void FileSizeTest() -{ - FileBase::RC rc; - sal_uInt64 filesize; - DirectoryItem aItem; - - printf( "--------------------------------------------\n" ); - printf( "File-Size-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - File aFile( file_not_exist ); - - printf( "Create File: "); - printFileName( file_not_exist ); - printf( "\n\n"); - - rc = aFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc ); - printf( "\n" ); - - if ( rc == FileBase::E_None ) - { - - // Set Filesize to 5000 - - printf( "Set FileSize to 5000\n" ); - rc=aFile.setSize( 5000 ); - print_error( rtl::OString( "Set FileSize" ), rc ); - - printf( "\n" ); - printf( "Verify:\n" ); - - // Check whether Filesize is set to 5000 - - rc=DirectoryItem::get( file_not_exist, aItem ); - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - if ( rc == FileBase::E_None ) - { - FileStatus rStatus( osl_FileStatus_Mask_FileSize ); - rc=aItem.getFileStatus( rStatus ); - print_error( rtl::OString( "Get FileStatus" ), rc ); - - if ( rc == FileBase::E_None ) - { - filesize=rStatus.getFileSize(); - - if ( filesize == 5000 ) - printf( "\nOK : FileSize: %" SAL_PRIuUINT64 "\n", filesize ); - else - printf( "\nError : FileSize: %" SAL_PRIuUINT64 "\n", filesize ); - } - } - - printf( "\n" ); - - // Set Filesize to -1 - - printf( "Set FileSize to -1\n" ); - rc=aFile.setSize( -1 ); - print_error( rtl::OString( "Set FileSize" ), rc ); - - printf( "\n" ); - - // close the file - rc=aFile.close(); - print_error( rtl::OString( "Close File" ), rc ); - - // remove the file - rc=File::remove( file_not_exist ); - print_error( rtl::OString( "Remove File" ), rc ); - } - - PressKey(); - - return; -} - -// FilePointerTest - -void FilePointerTest() -{ - FileBase::RC rc; - sal_uInt64 filepointer; - - printf( "--------------------------------------------\n" ); - printf( "File-Pointer-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - File rFile( file_not_exist ); - - printf( "Create File: "); - printFileName( file_not_exist ); - printf( "\n\n"); - - rc = rFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); - print_error( rtl::OString( "Create and Open File (Read & Write) "), rc ); - printf( "\n" ); - - if ( rc==FileBase::E_None ) - { - - // get the position of the filepointer - - rc =rFile.getPos( filepointer ); - print_error( rtl::OString( "GetPos" ), rc ); - printf( "Position of the FilePointer: %" SAL_PRIuUINT64 "\n", filepointer ); - - printf( "\n" ); - - // set the filepointer at the end of a file - - printf( "Set FileSize to 5000\n" ); - rFile.setSize( 5000 ); - - printf( "Set the FilePointer at the end of the file (5000)\n" ); - rc=rFile.setPos( osl_Pos_End,0 ); - print_error( rtl::OString( "SetPos" ), rc ); - - rc=rFile.getPos( filepointer ); - - if ( filepointer==5000 ) - { - print_error( rtl::OString( "GetPos" ), rc ); - printf( "\nVerify: OK !\n" ); - printf( "Filepointer-Position: %" SAL_PRIuUINT64 "\n",filepointer ); - } - else - { - print_error( rtl::OString( "GetPos" ), rc ); - printf( "\nFilePointer-Test: Error\n" ); - printf( "Filepointer-Position: %" SAL_PRIuUINT64 " != 5000 \n",filepointer ); - } - - printf( "\n" ); - - // close the file - rc=rFile.close(); - print_error( rtl::OString( "Close File" ), rc ); - - // remove the file - rc=File::remove( file_not_exist ); - print_error( rtl::OString( "Remove File" ), rc ); - } - - PressKey(); - - return; -} - -// FileAttributesTest - -void verifyFileAttributes() -{ - FileBase::RC rc; - DirectoryItem aItem; - FileStatus rStatus( osl_FileStatus_Mask_Attributes ); - - printf( "\nVerify:\n" ); - - rc=DirectoryItem::get( file1, aItem ); - - if ( rc==FileBase::E_None ) - { - rc=aItem.getFileStatus( rStatus ); - - if ( rc==FileBase::E_None ) - { - sal_uInt64 uAttributes=rStatus.getAttributes(); - showAttributes(uAttributes); - printf( "\n" ); - } - else - print_error( rtl::OString( "Get FileStatus" ), rc ); - } - else - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - return; -} - -#ifdef UNX -void FileAttributesTest() -{ - FileBase::RC rc; - - printf( "--------------------------------------------\n" ); - printf( "File-Attributes-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - printf( "File: "); - printFileName( file1 ); - printf( "\n\n" ); - - rc=File::setAttributes( file1, osl_File_Attribute_GrpWrite ); - print_error( rtl::OString( "Set Attribute: GrpWrite" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_GrpRead ); - print_error( rtl::OString( "Set Attribute: GrpRead" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_GrpExe ); - print_error( rtl::OString( "Set Attribute: GrpExe" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_OwnWrite ); - print_error( rtl::OString( "Set Attribute: OwnWrite" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_OwnRead ); - print_error( rtl::OString( "Set Attribute: OwnRead" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_OwnExe ); - print_error( rtl::OString( "Set Attribute: OwnExe" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_OthWrite ); - print_error( rtl::OString( "Set Attribute: OthWrite" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_OthRead ); - print_error( rtl::OString( "Set Attribute: OthRead" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_OthExe ); - print_error( rtl::OString( "Set Attribute: OthExe" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - if ( rc!=FileBase::E_None ) - print_error( rtl::OString( "Reset Attributes" ), rc ); - - rc=File::setAttributes( file1, osl_File_Attribute_GrpWrite | osl_File_Attribute_GrpRead | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnWrite | osl_File_Attribute_OwnRead | osl_File_Attribute_OwnExe | osl_File_Attribute_OthWrite | osl_File_Attribute_OthRead | osl_File_Attribute_OthExe ); - print_error( rtl::OString( "Set all Attributes" ), rc ); - - verifyFileAttributes(); - - PressKey(); - - return; -} -#endif - -#ifdef _WIN32 -void FileAttributesTest() -{ - FileBase::RC rc; - - printf( "--------------------------------------------\n" ); - printf( "File-Attributes-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - printf( "File: "); - printFileName( file1 ); - printf( "\n\n" ); - - rc=File::setAttributes( file1, osl_File_Attribute_ReadOnly ); - print_error( rtl::OString( "Set Attribute: ReadOnly" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - print_error( rtl::OString( "Reset Attributes" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, osl_File_Attribute_Hidden ); - print_error( rtl::OString( "Set Attribute: Hidden" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - print_error( rtl::OString( "Reset Attributes" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, osl_File_Attribute_Hidden | osl_File_Attribute_ReadOnly ); - print_error( rtl::OString( "Set Attribute: Hidden & ReadOnly" ), rc ); - - verifyFileAttributes(); - - rc=File::setAttributes( file1, 0 ); - print_error( rtl::OString( "Reset Attributes") , rc ); - - verifyFileAttributes(); - - PressKey(); - - return; -} -#endif - -// FileTimeTest - -void FileTimeTest() -{ - FileBase::RC rc; - - DirectoryItem aItem; - - struct tm sSysCreationTime; - sSysCreationTime.tm_sec = 0; - sSysCreationTime.tm_min = 20; - sSysCreationTime.tm_hour = 12; - sSysCreationTime.tm_mday = 4; - sSysCreationTime.tm_mon = 9; - sSysCreationTime.tm_year = 99; - - struct tm sSysAccessTime; - sSysAccessTime.tm_sec = 0; - sSysAccessTime.tm_min = 40; - sSysAccessTime.tm_hour = 1; - sSysAccessTime.tm_mday = 6; - sSysAccessTime.tm_mon = 5; - sSysAccessTime.tm_year = 98; - - struct tm sSysModifyTime; - sSysModifyTime.tm_sec = 0; - sSysModifyTime.tm_min = 1; - sSysModifyTime.tm_hour = 24; - sSysModifyTime.tm_mday = 13; - sSysModifyTime.tm_mon = 11; - sSysModifyTime.tm_year = 95; - - sal_uInt32 aSysCreationTime = mktime( &sSysCreationTime ); - sal_uInt32 aSysAccessTime = mktime( &sSysAccessTime ); - sal_uInt32 aSysModifyTime = mktime( &sSysModifyTime ); - - TimeValue aCreationTime = { aSysCreationTime, 0}; - TimeValue aAccessTime = { aSysAccessTime, 0}; - TimeValue aModifyTime = { aSysModifyTime, 0}; - - TimeValue aCreationTimeRead; - TimeValue aAccessTimeRead; - TimeValue aModifyTimeRead; - - printf( "--------------------------------------------\n" ); - printf( "File-Time-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - printf( "File: "); - printFileName( file1 ); - printf( "\n\n" ); - - printf( "CreationTime \t : "); - showTime( aCreationTime ); - - printf( "\nAccessTime \t : "); - showTime( aAccessTime ); - - printf( "\nModifyTime \t : "); - showTime( aModifyTime ); - - // setTime - - printf( "\n" ); - rc=File::setTime( file1 , aCreationTime , aAccessTime , aModifyTime ); - print_error( rtl::OString( "SetTime" ), rc ); - - // Verify - - FileStatus rStatus( osl_FileStatus_Mask_CreationTime | osl_FileStatus_Mask_AccessTime | osl_FileStatus_Mask_ModifyTime); - - printf( "\nVerify:\n" ); - - rc=DirectoryItem::get( file1, aItem ); - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - if ( rc==FileBase::E_None ) - { - rc=aItem.getFileStatus( rStatus ); - print_error( rtl::OString( "Get FileStatus" ), rc ); - printf( "\n" ); - - if ( rc==FileBase::E_None ) - { - - // GetCreationTime - - aCreationTimeRead=rStatus.getCreationTime(); -#ifdef _WIN32 - if ( aCreationTime.Seconds == aCreationTimeRead.Seconds && aCreationTime.Nanosec == aCreationTimeRead.Nanosec ) - printf( "GetCreationTime: ok : " ); - else - printf( "GetCreationTime: Error : " ); - - showTime( aCreationTimeRead ); - printf( "\n" ); -#endif - - // GetAccessTime - - aAccessTimeRead=rStatus.getAccessTime(); - - if ( aAccessTime.Seconds == aAccessTimeRead.Seconds && aAccessTime.Nanosec == aAccessTimeRead.Nanosec ) - printf( "GetAccessTime: ok : " ); - else - printf( "GetAccessTime: Error : " ); - - showTime( aAccessTimeRead ); - printf( "\n" ); - - // GetModifyTime - - aModifyTimeRead=rStatus.getModifyTime(); - - if ( aModifyTime.Seconds == aModifyTimeRead.Seconds && aModifyTime.Nanosec == aModifyTimeRead.Nanosec ) - printf( "GetModifyTime: ok : " ); - else - printf( "GetModifyTime: Error : " ); - - showTime( aModifyTimeRead ); - printf( "\n" ); - } - } - - PressKey(); - return; -} - -// DirectoryItemTest - -void DirectoryItemTest() -{ - FileBase::RC rc; - Directory *pDir; - DirectoryItem aItem; - FileStatus *pStatus; - File *pFile; - - printf( "--------------------------------------------\n" ); - printf( "Directory-Item-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - // get DirectoryItem from an existing directory - - printf( "Get DirectoryItem from an existing Directory: "); - printFileName( dir1 ); - printf( "\n"); - - rc=DirectoryItem::get( dir1 , aItem ); - print_error( rtl::OString( "GetDirectoryItem" ), rc ); - - pStatus=new FileStatus( osl_FileStatus_Mask_All ); - rc=aItem.getFileStatus( *pStatus ); - - if ( rc==FileBase::E_None ) - { - printf( "GetFileStatus: FileURL: "); - printFileName(pStatus->getFileURL() ); - printf( "\n" ); - } - - delete pStatus; - - printf( "\n" ); - - // get DirectoryItem from a not existing directory - - printf( "Get DirectoryItem from a not existing Directory: "); - printFileName( dir_not_exist ); - printf( "\n" ); - - rc=DirectoryItem::get( dir_not_exist , aItem ); - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - printf( "\n" ); - - // get DirectoryItem from an existing file - - printf( "Get DirectoryItem from an existing File: "); - printFileName( file1 ); - printf( "\n" ); - - rc=DirectoryItem::get( file1 , aItem ); - print_error( rtl::OString( "GetDirectoryItem" ), rc ); - - pStatus=new FileStatus( osl_FileStatus_Mask_All ); - rc=aItem.getFileStatus( *pStatus ); - - if ( rc==FileBase::E_None ) - { - printf( "GetFileStatus: FileURL: "); - printFileName( pStatus->getFileURL() ); - printf( "\n" ); - } - - delete pStatus; - - printf( "\n" ); - - // get DirectoryItem from a not existing file - - printf( "Get DirectoryItem from a not existing File: "); - printFileName( file_not_exist ); - printf( "\n" ); - - rc=DirectoryItem::get( file_not_exist , aItem ); - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - printf( "\n" ); - - // get DirectoryItem from a directory with a wrong semantic - - printf( "Get DirectoryItem from a Directory with a wrong semantic: "); - printFileName( dir_not_exist ); - printf( "\n" ); - - rc=DirectoryItem::get( dir_wrong_semantic, aItem ); - print_error( rtl::OString( "Get DirectoryItem" ),rc ); - - printf( "\n" ); - - // get DirectoryItem from a file-handle - - pFile=new File( file1 ); - - rc=pFile->open( osl_File_OpenFlag_Read ); - if ( rc==FileBase::E_None ) - { - printf( "Get DirectoryItem from a File-Handle: "); - printFileName( file1 ); - printf( "\n" ); - - rc=DirectoryItem::get( file1 , aItem ); - print_error( rtl::OString( "GetDirectoryItem" ), rc ); - - pStatus=new FileStatus( osl_FileStatus_Mask_All ); - rc=aItem.getFileStatus( *pStatus ); - - if ( rc==FileBase::E_None ) - { - printf( "GetFileStatus: FileURL: "); - printFileName( pStatus->getFileURL() ); - printf( "\n"); - } - - delete pStatus; - - pFile->close(); - } - - delete pFile; - - printf( "\n" ); - - // get DirectoryItem - - printf( "Get DirectoryItem from an empty File-Handle\n" ); - rc=DirectoryItem::get( file1 , aItem ); - print_error( rtl::OString( "GetDirectoryItem" ), rc ); - - printf( "\n" ); - - // GetNextItem from a directory - - pDir=new Directory( dir1 ); - printf( "Get next DirectoryItem from a directory: "); - printFileName( dir1); - printf( "\n" ); - - rc= pDir->open(); - print_error( rtl::OString( "Open Directory" ), rc ); - - printf( "\n" ); - - if ( pDir->isOpen() ) - { - - // get all files from the directory - - rtl::OUString str; - rtl::OUString str1[2]; - - aItem=DirectoryItem(); - rc=pDir->getNextItem( aItem ); - print_error( rtl::OString( "GetNextItem" ),rc ); - - while( rc==FileBase::E_None ) - { - - FileStatus rStatus( osl_FileStatus_Mask_All ); - aItem.getFileStatus( rStatus ); - - str=rStatus.getFileName(); - printf( "Filename: "); - printFileName( str ); - printf( "\n"); - - aItem=DirectoryItem(); - rc=pDir->getNextItem( aItem ); - print_error( rtl::OString( "GetNextItem" ),rc ); - } - - printf( "\n" ); - - // Reset-Test - - for (int i=0; i<2; i++) - { - aItem=DirectoryItem(); - rc=pDir->reset(); - rc=pDir->getNextItem( aItem ); - - FileStatus rStatus( osl_FileStatus_Mask_All ); - aItem.getFileStatus( rStatus ); - - str1[i]=rStatus.getFileName(); - } - - if ( str1[0] == str1[1] ) - print_error( rtl::OString( "Reset" ),FileBase::E_None ); - else - print_error( rtl::OString( "Reset" ),FileBase::E_invalidError ); - - printf( "\n" ); - - // Close Directory - rc=pDir->close(); - print_error( rtl::OString( "Close Directory" ), rc ); - } - - printf( "\n"); - - // GetNextItem from a closed directory - - printf( "Get next DirectoryItem from a closed directory: "); - printFileName( dir1 ); - printf( "\n" ); - - aItem=DirectoryItem(); - rc=pDir->getNextItem( aItem ); - print_error( rtl::OString( "GetNextItem" ),rc ); - - delete pDir; - - PressKey(); - return; -} - -// FileStatusTest (for different types) - -void FileStatusTest( FileStatus *pStatus ) -{ - - // GetFileType of the directory - - FileStatus::Type aType; - - printf( "\ngetFileType:\n" ); - aType=pStatus->getFileType(); - showFileType( aType ); - - // GetAttributes - - sal_uInt64 uAttributes; - - printf( "\ngetAttributes:\n" ); - uAttributes=pStatus->getAttributes(); - showAttributes( uAttributes ); - - // GetCreationTime - - TimeValue aCreationTime; - - printf( "\ngetCreationTime:\n" ); - aCreationTime=pStatus->getCreationTime(); - - printf( "CreationTime: " ); - showTime( aCreationTime ); - - // GetAccessTime - - TimeValue aAccessTime; - - printf( "\ngetAccessTime:\n" ); - aAccessTime=pStatus->getAccessTime(); - - printf( "AccessTime: " ); - showTime( aAccessTime ); - - // GetModifyTime - - TimeValue aModifyTime; - - printf( "\ngetModifyTime:\n" ); - aModifyTime=pStatus->getModifyTime(); - - printf( "ModifyTime: " ); - showTime( aModifyTime ); - - // GetFileSize - - sal_uInt64 FileSize; - - printf( "\ngetFileSize:\n" ); - - FileSize=pStatus->getFileSize(); - printf( "FileSize: %" SAL_PRIuUINT64 "\n", FileSize); - - // GetFileName - - rtl::OUString FileName; - - printf( "\ngetFileName:\n" ); - - FileName=pStatus->getFileName(); - printf( "FileName: "); - printFileName( FileName ); - printf( "\n" ); - - // GetFileURL - - rtl::OUString FileURL; - - printf( "\ngetFileURL:\n" ); - - FileURL=pStatus->getFileURL(); - printf( "FileURL: "); - printFileName( FileURL ); - printf( "\n" ); - - // GetLinkTargetURL - - rtl::OUString LinkTargetURL; - - printf( "\ngetLinkTargetURL:\n"); - - LinkTargetURL=pStatus->getLinkTargetURL(); - printf( "LinkTargetURL: "); - printFileName( LinkTargetURL ); - printf( "\n" ); - - return; -} - -// DirectoryFileStatusTest - -void DirectoryFileStatusTest() -{ - FileBase::RC rc; - DirectoryItem aItem; - - printf( "--------------------------------------------\n" ); - printf( "Directory-FileStatus-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - printf( "FileStatus of the directory: "); - printFileName( dir1 ); - printf( "\n" ); - - aItem=DirectoryItem(); - - rc=DirectoryItem::get( dir1, aItem ); - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - if ( rc==FileBase::E_None ) - { - FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All ); - rc=aItem.getFileStatus( *pStatus ); - - FileStatusTest( pStatus ); - - delete pStatus; - } - - printf( "\n" ); - - PressKey(); - return; -} - -// FileFileStatusTest - -void FileFileStatusTest() -{ - FileBase::RC rc; - DirectoryItem aItem; - - printf( "--------------------------------------------\n" ); - printf( "File-FileStatus-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - printf( "FileStatus of the file: "); - printFileName( file1 ); - printf( "\n" ); - - aItem=DirectoryItem(); - - rc=DirectoryItem::get( file1 , aItem ); - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - if ( rc==FileBase::E_None ) - { - FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All ); - rc=aItem.getFileStatus( *pStatus ); - - FileStatusTest( pStatus ); - - delete pStatus; - } - - printf( "\n" ); - - PressKey(); - return; -} - -// VolumeFileStatusTest - -void VolumeFileStatusTest() -{ - FileBase::RC rc; - DirectoryItem aItem; - - printf( "--------------------------------------------\n" ); - printf( "Volume-FileStatus-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - printf( "FileStatus of the Volume: "); - printFileName( root ); - printf( "\n" ); - - aItem=DirectoryItem(); - - rc=DirectoryItem::get( root , aItem ); - print_error( rtl::OString( "Get DirectoryItem" ), rc ); - - if ( rc==FileBase::E_None ) - { - FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All) ; - rc=aItem.getFileStatus( *pStatus ); - - FileStatusTest( pStatus ); - - delete pStatus; - } - - printf( "\n" ); - - PressKey(); - return; -} - -// VolumeInfoTest - -void VolumeInfoTest() -{ - FileBase::RC rc; - - printf( "--------------------------------------------\n" ); - printf( "Volume-Info-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - printf( "VolumeInfo of the volume "); - printFileName( root ); - - printf( "\n" ); - - VolumeInfo rInfo( osl_VolumeInfo_Mask_FreeSpace ); - rc=Directory::getVolumeInfo( root , rInfo ); - print_error( rtl::OString( "GetVolumeInfo" ),rc ); - - printf( "\n" ); - - // getRemoteFlag - - if ( rInfo.getRemoteFlag() ) - printf( "RemoteFlag: Yes\n" ); - else - printf( "RemoteFlag: No\n" ); - - // getRemoveableFlag - - if ( rInfo.getRemoveableFlag() ) - printf( "RemoveableFlag: Yes\n" ); - else - printf( "RemoveableFlag: No\n" ); - - // getTotalSpace - - sal_uInt64 TotalSpace; - TotalSpace=rInfo.getTotalSpace(); - printf( "Total Space: %" SAL_PRIuUINT64 "\n",TotalSpace ); - - // getFreeSpace - - sal_uInt64 FreeSpace; - FreeSpace=rInfo.getFreeSpace(); - printf( "Free Space: %" SAL_PRIuUINT64 "\n",FreeSpace ); - - // getUsedSpace - - sal_uInt64 UsedSpace; - UsedSpace=rInfo.getUsedSpace(); - printf( "Used Space: %" SAL_PRIuUINT64 "\n",UsedSpace ); - - // getMaxNameLength - - sal_uInt32 MaxNameLength; - MaxNameLength=rInfo.getMaxNameLength(); - printf( "MaxNameLength: %" SAL_PRIuUINT32 "\n",MaxNameLength ); - - // getMaxPathLength - - sal_uInt32 MaxPathLength; - MaxPathLength=rInfo.getMaxPathLength(); - printf( "MaxPathLength: %" SAL_PRIuUINT32 "\n",MaxPathLength ); - - // getFileSystemName - - rtl::OUString FileSystemName; - FileSystemName=rInfo.getFileSystemName(); - printf( "File-System-Name: "); - printFileName( FileSystemName ); - printf( "\n" ); - - PressKey(); - return; -} - -// FileBaseTest - -void ConvertPathTest(rtl::OUString& strPath) -{ - FileBase::RC rc; - - rtl::OUString strNormPath; - rtl::OUString strFileURL; - rtl::OUString strNormPathFromFileURL; - rtl::OUString strSystemPath; - - // normalizePath - - rc=FileBase::getFileURLFromSystemPath( strPath, strNormPath ); - - if ( rc == FileBase::E_None ) - { - printf( "Normalized Path: \t\t"); - printFileName( strNormPath ); - printf( "\n" ); - } - else - printf( "normalizePath: Error \n" ); - - // getFileURLFromSystemPath - - if ( !strNormPath.isEmpty() ) - { - rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL ); - - if ( rc == FileBase::E_None ) - { - printf( "File-URL: \t\t\t"); - printFileName( strFileURL ); - printf( "\n" ); - } - else - printf( "getFileURLFromSystemPath: Error \n" ); - } - else - printf( "getFileURLFromSystemPath: not tested \n" ); - - // getNormalizedPathFromFileURL - - if ( !strFileURL.isEmpty() ) - { - rc=FileBase::getSystemPathFromFileURL( strFileURL, strNormPathFromFileURL ); - - if ( rc == FileBase::E_None ) - { - printf( "Normalized Path from File-URL: \t"); - printFileName( strNormPathFromFileURL ); - printf( "\n" ); - } - else - printf( "getNormalizedPathFromFileURL: Error \n" ); - } - else - printf( "getNormalizedPathFromFileURL: not tested \n" ); - - // getSystemPathFromFileURL - - if ( !strNormPath.isEmpty() ) - { - rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath ); - - if ( rc == FileBase::E_None ) - { - printf( "System-Path: \t\t\t"); - printFileName( strSystemPath ); - printf( "\n"); - } - else - printf( "getSystemPathFromFileURL: Error \n" ); - } - else - printf( "getSystemPathFromFileURL: not tested \n" ); - - // Verify - - if ( strNormPathFromFileURL == strNormPath ) - printf( "\nVerify: OK ! ( Normalized-Path == Normalized-Path-From-File-URL )\n" ); - else - printf( "\nVerify: Error ! ( Normalized-Path != Normalized-Path-From-File-URL )\n" ); - - return; -} - -void FileBaseTest() -{ - printf( "--------------------------------------------\n" ); - printf( "FileBase-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - // ConvertPath-Test (Local File) - - printf( "- Local File: "); - printFileName( file1 ); - printf( "\n\n" ); - - ConvertPathTest(file1); - - // ConvertPath-Test (File on a server) - - printf( "\n- File on server: "); - printFileName( file_on_server ); - printf( "\n\n" ); - ConvertPathTest(file_on_server); - - PressKey(); - - return; -} - -// AbsolutePathTest - -void DoAbsolutePathTest(rtl::OUString strDirBase, rtl::OUString strRelative) -{ - FileBase::RC rc; - - rtl::OUString strAbsolute; - - printf( "Base-Directory: \t"); - printFileName( strDirBase ); - printf( "\n" ); - printf( "Relative-Path: \t\t"); - printFileName ( strRelative ); - printf( "\n" ); - - rc=FileBase::getAbsoluteFileURL( strDirBase, strRelative, strAbsolute ); - - if ( rc == FileBase::E_None ) - { - printf( "Absolute-Path: \t\t"); - printFileName ( strAbsolute ); - printf( "\n" ); - } - else - printf( "Absolute-Path: Error \n" ); - - printf( "\n" ); - return; -} - -void AbsolutePathTest() -{ - printf( "--------------------------------------------\n" ); - printf( "AbsolutePath-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - DoAbsolutePathTest(dir1, rtl::OUString(".")); - DoAbsolutePathTest(dir1, rtl::OUString("..")); - DoAbsolutePathTest(dir1, rtl::OUString("../..")); - DoAbsolutePathTest(dir1, rtl::OUString("../HUHU")); - - DoAbsolutePathTest(dir_on_server, rtl::OUString(".")); - DoAbsolutePathTest(dir_on_server, rtl::OUString("..")); - DoAbsolutePathTest(dir_on_server, rtl::OUString("../..")); - DoAbsolutePathTest(dir_on_server, rtl::OUString("../HUHU")); - - PressKey(); - return; -} - -// searchPathTest - -void SearchPathTest() -{ - FileBase::RC rc; - - rtl::OUString strNormPath(file1); - rtl::OUString strFileURL; - rtl::OUString strSystemPath; - rtl::OUString strResultPath; - - printf( "--------------------------------------------\n" ); - printf( "SearchPath-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL ); - print_error( rtl::OString( "getFileURLFromSystemPath" ), rc ); - rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath ); - print_error( rtl::OString( "getSystemPathFromFileURL" ), rc ); - - // searchFileURL (with a normalized path) - - if ( !strNormPath.isEmpty() ) - { - printf( "\nSearch-Normalized-Path (with a normalized path) : "); - printFileName ( strNormPath ); - printf( "\n" ); - - rc=FileBase::searchFileURL( strNormPath , rtl::OUString() , strResultPath ); - - if ( rc == FileBase::E_None ) - { - printf( "Result: \t\t\t"); - printFileName ( strResultPath ); - printf( "\n" ); - } - else - printf( "searchFileURL (with a normalized path): Error\n" ); - } - else - printf( "searchFileURL (with a normalized path): not tested\n" ); - - // searchFileURL (with a File-URL) - - if ( !strFileURL.isEmpty() ) - { - printf( "\nSearch-Normalized-Path (with a FileURL) : "); - printFileName( strFileURL ); - printf( "\n" ); - - rc=FileBase::searchFileURL( strFileURL , rtl::OUString() , strResultPath ); - - if ( rc == FileBase::E_None ) - { - printf( "Result: \t\t\t"); - printFileName ( strResultPath ); - printf( "\n" ); - } - else - printf( "searchFileURL (with a FileURL path): Error\n" ); - } - else - printf( "searchFileURL (with a FileURL path): not tested\n" ); - - // searchFileURL (with a systempath) - - if ( !strSystemPath.isEmpty() ) - { - printf( "\nSearch-Normalized-Path (with a SystemPath) : "); - printFileName( strSystemPath ); - printf( "\n" ); - - rc=FileBase::searchFileURL( strSystemPath , rtl::OUString() , strResultPath ); - - if ( rc == FileBase::E_None ) - { - printf( "Result: \t\t\t"); - printFileName( strResultPath ); - printf( "\n" ); - } - else - printf( "searchFileURL (with a systempath): Error\n" ); - } - else - printf( "searchFileURL (with a systempath): not tested\n" ); - - // searchFileURL (File and no searchpath) - - printf( "\nsearchFileURL: File (no searchpath) : "); - printFileName( file3 ); - printf( "\n" ); - - rc=FileBase::searchFileURL( file3 , rtl::OUString("") , strResultPath ); - - if ( rc == FileBase::E_None ) - { - printf( "Result: \t\t\t"); - printFileName( strResultPath ); - printf( "\n" ); - } - else - printf( "searchFileURL: File not found: OK ! \n" ); - - // searchFileURL (File and Path) - - printf( "\nsearchFileURL: File : "); - printFileName( file3 ); - printf( "\tSearchPath "); - printFileName( dir1 ); - printf( "\n"); - - rc=FileBase::searchFileURL( file3 , dir1 , strResultPath ); - - if ( rc == FileBase::E_None ) - { - printf( "Result: \t\t\t"); - printFileName( strResultPath ); - printf( "\n"); - } - else - printf( "searchFileURL: File not found: Error\n" ); - - // searchFileURL (File and searchpath with two entries) - - rtl::OUString strSearchPath( dir_not_exist ); - strSearchPath+=rtl::OUString(";"); - strSearchPath+=dir_on_server; - - printf( "\nsearchFileURL: File : "); - printFileName( file3 ); - printf( "SearchPath "); - printFileName( strSearchPath ); - printf( "\n"); - - rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath ); - - if ( rc == FileBase::E_None ) - { - printf( "Result: \t\t\t"); - printFileName( strResultPath ); - printf( "\n" ); - } - else - printf( "searchFileURL: File not found: Error\n" ); - - // searchFileURL (File and searchpath (with a wrong semantic)) - - strSearchPath=rtl::OUString( dir_wrong_semantic ); - - printf( "\nsearchFileURL: File : "); - printFileName( file3 ); - printf( "SearchPath "); - printFileName( strSearchPath ); - printf( "\n"); - - rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath ); - - if ( rc == FileBase::E_None ) - printf( "Error: Wrong Semantich but no error occurs !\n" ); - else - printf( "searchFileURL: File not found: OK !\n" ); - - return; -} - -// CanonicalNameTest - -void getCanonicalNameTest(rtl::OUString strPath) -{ - FileBase::RC rc; - - rtl::OUString strValid; - - printf( "Original-Name: \t\t"); - printFileName( strPath ); - printf( "\n" ); - - rc=FileBase::getCanonicalName( strPath, strValid ); - - if ( rc == FileBase::E_None) - { - printf( "Canonical-Name: \t"); - printFileName( strValid ); - printf( "\n"); - - } - else - printf( "Canonical-Name: Error \n" ); - - printf( "\n" ); - return; -} - -void CanonicalNameTest() -{ - printf( "--------------------------------------------\n" ); - printf( "CanonicalName-Test\n" ); - printf( "--------------------------------------------\n\n" ); - - getCanonicalNameTest( dir1 ); - getCanonicalNameTest( dir_on_server ); - getCanonicalNameTest( file1 ); - getCanonicalNameTest( file_on_server ); - - PressKey(); - return; -} - -// print_error - -void print_error( const ::rtl::OString& str, FileBase::RC rc ) -{ - - printf( "%s : ", str.getStr() ); - switch(rc) - { - case FileBase::E_None: - printf("OK !\n"); - break; - case FileBase::E_PERM: - printf("E_PERM\n"); - break; - case FileBase::E_NOENT: - printf("E_NOENT\n"); - break; - case FileBase::E_SRCH: - printf("E_SRCH\n"); - break; - case FileBase::E_INTR: - printf("E_INTR\n"); - break; - case FileBase::E_IO: - printf("E_IO\n"); - break; - case FileBase::E_NXIO: - printf("E_NXIO\n"); - break; - case FileBase::E_2BIG: - printf("E_2BIG\n"); - break; - case FileBase::E_NOEXEC: - printf("E_NOEXEC\n"); - break; - case FileBase::E_BADF: - printf("E_BADF\n"); - break; - case FileBase::E_CHILD: - printf("E_CHILD\n"); - break; - case FileBase::E_AGAIN: - printf("E_AGAIN\n"); - break; - case FileBase::E_NOMEM: - printf("E_NOMEM\n"); - break; - case FileBase::E_ACCES: - printf("E_ACCES\n"); - break; - case FileBase::E_FAULT: - printf("E_FAULT\n"); - break; - case FileBase::E_BUSY: - printf("E_BUSY\n"); - break; - case FileBase::E_EXIST: - printf("E_EXIST\n"); - break; - case FileBase::E_XDEV: - printf("E_XDEV\n"); - break; - case FileBase::E_NODEV: - printf("E_NODEV\n"); - break; - case FileBase::E_NOTDIR: - printf("E_NOTDIR\n"); - break; - case FileBase::E_ISDIR: - printf("E_ISDIR\n"); - break; - case FileBase::E_INVAL: - printf("E_INVAL\n"); - break; - case FileBase::E_NFILE: - printf("E_NFILE\n"); - break; - case FileBase::E_MFILE: - printf("E_MFILE\n"); - break; - case FileBase::E_NOTTY: - printf("E_NOTTY\n"); - break; - case FileBase::E_FBIG: - printf("E_FBIG\n"); - break; - case FileBase::E_NOSPC: - printf("E_NOSPC\n"); - break; - case FileBase::E_SPIPE: - printf("E_SPIPE\n"); - break; - case FileBase::E_ROFS: - printf("E_ROFS\n"); - break; - case FileBase::E_MLINK: - printf("E_MLINK\n"); - break; - case FileBase::E_PIPE: - printf("E_PIPE\n"); - break; - case FileBase::E_DOM: - printf("E_DOM\n"); - break; - case FileBase::E_RANGE: - printf("E_RANGE\n"); - break; - case FileBase::E_DEADLK: - printf("E_DEADLK\n"); - break; - case FileBase::E_NAMETOOLONG: - printf("E_NAMETOOLONG\n"); - break; - case FileBase::E_NOLCK: - printf("E_NOLCK\n"); - break; - case FileBase::E_NOSYS: - printf("E_NOSYS\n"); - break; - case FileBase::E_NOTEMPTY: - printf("E_NOTEMPTY\n"); - break; - case FileBase::E_LOOP: - printf("E_LOOP\n"); - break; - case FileBase::E_ILSEQ: - printf("E_ILSEQ\n"); - break; - case FileBase::E_NOLINK: - printf("E_NOLINK\n"); - break; - case FileBase::E_MULTIHOP: - printf("E_MULTIHOP\n"); - break; - case FileBase::E_USERS: - printf("E_USERS\n"); - break; - case FileBase::E_OVERFLOW: - printf("E_OVERFLOW\n"); - break; - default: - printf("E_Unknown\n"); - break; - } - return; -} - -// main - -#if defined(_WIN32) - #define MAIN _cdecl main -#else - #define MAIN main -#endif - -int MAIN( int argc, char* argv[] ) -{ - //Initialization - sal_Bool fSuccess=Initialize(); - if ( !fSuccess ) - { - printf("Error during Initialization"); - return -1; - } - - if (argc==1) - { - DirectoryOpenAndCloseTest(); - DirectoryCreateAndRemoveTest(); - - FileOpenAndCloseTest(); - FileCreateAndRemoveTest(); - FileWriteAndReadTest(); - FileCopyAndMoveTest(); - FileSizeTest(); - FilePointerTest(); - FileAttributesTest(); - FileTimeTest(); - DirectoryItemTest(); - DirectoryFileStatusTest(); - VolumeFileStatusTest(); - FileFileStatusTest(); - VolumeInfoTest(); - FileBaseTest(); - SearchPathTest(); - AbsolutePathTest(); - CanonicalNameTest(); - } - // command line arguments ? - else - { - int i=1; - - while (i<argc) - { - if (strcmp(argv[i], "doc")==0) - DirectoryOpenAndCloseTest(); - else if (strcmp(argv[i], "dcr")==0) - DirectoryCreateAndRemoveTest(); - else if (strcmp(argv[i], "foc")==0) - FileOpenAndCloseTest(); - else if (strcmp(argv[i], "fcr")==0) - FileCreateAndRemoveTest(); - else if (strcmp(argv[i], "fwr")==0) - FileWriteAndReadTest(); - else if (strcmp(argv[i], "fcm")==0) - FileCopyAndMoveTest(); - else if (strcmp(argv[i], "fs")==0) - FileSizeTest(); - else if (strcmp(argv[i], "fp")==0) - FilePointerTest(); - else if (strcmp(argv[i], "fa")==0) - FileAttributesTest(); - else if (strcmp(argv[i], "ft")==0) - FileTimeTest(); - else if (strcmp(argv[i], "di")==0) - DirectoryItemTest(); - else if (strcmp(argv[i], "dfs")==0) - DirectoryFileStatusTest(); - else if (strcmp(argv[i], "vfs")==0) - VolumeFileStatusTest(); - else if (strcmp(argv[i], "ffs")==0) - FileFileStatusTest(); - else if (strcmp(argv[i], "vi")==0) - VolumeInfoTest(); - else if (strcmp(argv[i], "fb")==0) - FileBaseTest(); - else if (strcmp(argv[i], "sp")==0) - SearchPathTest(); - else if (strcmp(argv[i], "ap")==0) - AbsolutePathTest(); - else if (strcmp(argv[i], "cn")==0) - CanonicalNameTest(); - - i++; - } - } - - // Shutdown - fSuccess=Shutdown(); - if ( !fSuccess ) - { - printf("Error during Shutdown"); - return -1; - } - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/testpip2.cxx b/sal/workben/testpip2.cxx deleted file mode 100644 index 87fcd705ae71..000000000000 --- a/sal/workben/testpip2.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <stdio.h> -#include <stdlib.h> - -#include <osl/pipe.h> - -// eindeutiger Name für die Pipe -const char pszPipeName[] = "TestPipe"; - -oslPipe Pipe; - -void fail( const char * pszText, int retval ) -{ - fprintf( stderr, "TestPipe Client: %s", pszText ); - fprintf( stderr, "TestPipe Client: test failed, ErrNo: %d.\n", retval ); - exit( retval ); -} - -/* - * Teste die Pipe-Implementation in osl - */ - -int main() -{ - char szBuffer[ 256 ]; - rtl_uString* ustrPipeName=0; - sal_Int32 nChars; - - rtl_uString_newFromAscii(&ustrPipeName,pszPipeName); - - // erzeuge die Pipe - Pipe = osl_createPipe( ustrPipeName, osl_Pipe_OPEN, 0 ); - - if( !Pipe ) - fail( "unable to open pipe.\n", - osl_getLastPipeError(NULL)); - - // empfange Daten vom Server - nChars = osl_receivePipe( Pipe, szBuffer, 256 ); - - if( nChars < 0 ) - fail( "unable to read from pipe.\n", - osl_getLastPipeError( Pipe ) ); - - printf( "TestPipe Client: data received: %s.\n", szBuffer ); - - // Sende die Daten wieder zurück. - nChars = osl_sendPipe( Pipe, szBuffer, nChars ); - - if( nChars < 0 ) - fail( "unable to write on pipe.\n", - osl_getLastPipeError( Pipe ) ); - - // schliesse die Pipe - osl_releasePipe( Pipe ); - - printf( "TestPipe Client: test passed.\n" ); - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/testpipe.cxx b/sal/workben/testpipe.cxx deleted file mode 100644 index 2e405aaa81e0..000000000000 --- a/sal/workben/testpipe.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <osl/pipe.h> -#include <osl/process.h> -#include <rtl/ustring.h> - -// clear Name for the Pipe -const char pszPipeName[] = "TestPipe"; -const char szTestString[] = "This is a test"; -char szBuffer[256]; - -const char * cp; -size_t n; -sal_Int32 nChars; - -// osl specific variables -oslPipe Pipe; -oslPipe C1Pipe; -oslProcess Process = NULL; -oslProcessError ProcessError; -oslProcessInfo ProcessInfo; - -void fail( const char * pszText, int retval ) -{ - fprintf( stderr, "TestPipe Server: %s", pszText ); - fprintf( stderr, "TestPipe Server: test failed, ErrNo: %d.\n", retval ); - - if( Process ) osl_freeProcessHandle( Process ); - exit( retval ); -} - -/* - * Test the Pipe-Implementation in osl - */ - -int main (int argc, const char *argv[]) -{ - // create the Pipe - rtl_uString* ustrPipeName=0; - rtl_uString* ustrExeName=0; - - rtl_uString_newFromAscii(&ustrPipeName,pszPipeName); - rtl_uString_newFromAscii(&ustrExeName, "//./tmp/testpip2.exe"); - - Pipe = osl_createPipe( ustrPipeName, osl_Pipe_CREATE, 0 ); - - if( !Pipe ) - fail( "unable to create Pipe.\n", - osl_getLastPipeError(NULL)); - - // start client process - ProcessError = osl_executeProcess( ustrExeName, - NULL, - 0, - osl_Process_NORMAL, - 0, - NULL, - NULL, - 0, - &Process ); - - if( ProcessError != osl_Process_E_None ) - fail( "unable to start client.\n", ProcessError ); - - // wait for connection - C1Pipe = osl_acceptPipe( Pipe ); - - if( !C1Pipe ) - fail( "unable to connect to client.\n", - osl_getLastPipeError( Pipe )); - - if( argc > 1 ) - { - cp = argv[1]; - n = strlen( cp ) + 1; - } - else - { - cp = szTestString; - n = sizeof(szTestString); - } - - // send TestString to Client - nChars = osl_sendPipe( C1Pipe, cp, n ); - - if( nChars < 0 ) - fail( "unable to write on pipe.\n", - osl_getLastPipeError( Pipe ) ); - - // receive data from the server - nChars = osl_receivePipe( C1Pipe, szBuffer, 256 ); - - if( nChars < 0 ) - fail( "unable to read from pipe.\n", - osl_getLastPipeError( C1Pipe ) ); - - printf( "TestPipe Server: received data: %s.\n", szBuffer ); - - // wait until the client-program terminates - ProcessError = osl_joinProcess( Process ); - - if( ProcessError != osl_Process_E_None ) - fail( "unable to wait for client.\n", - ProcessError ); - - // investigate the return-value of the client-program - ProcessInfo.Size = sizeof( ProcessInfo ); - - ProcessError = osl_getProcessInfo( Process, osl_Process_EXITCODE, &ProcessInfo ); - - if( ProcessError != osl_Process_E_None ) - fail( "unable to receive return value of client process.\n", - ProcessError ); - - if( ProcessInfo.Code != 0 ) - fail( "client aborted.\n", ProcessInfo.Code ); - - // give the handle for the free client-process - osl_freeProcessHandle( Process ); - - // close the pipes - osl_releasePipe( C1Pipe ); - osl_releasePipe( Pipe ); - - printf( "TestPipe Server: test passed.\n" ); - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/workben/testproc.cxx b/sal/workben/testproc.cxx deleted file mode 100644 index 91d0e60fe5f8..000000000000 --- a/sal/workben/testproc.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/process.h> -#include <stdio.h> - -#if defined(_WIN32) - #define MAIN _cdecl main -#else - #define MAIN main -#endif - -int MAIN() -{ - //oslProcess Process; - sal_uInt32 nArgCount; - sal_uInt32 index; - rtl_uString* ustrExeFile=0; - rtl_uString* ustrArg=0; - - nArgCount=osl_getCommandArgCount(); - - fprintf(stderr,"Arg Count == %i\n\n",nArgCount); - - for ( index = 0 ; index <= nArgCount+1 ; index++ ) - { - fprintf(stderr,"Getting Arg No . %i\n",index); - - osl_getCommandArg(index,&ustrArg); - - fprintf(stderr,"done ...\n\n"); - } - - osl_getExecutableFile(&ustrExeFile); - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |