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
This commit is contained in:
@@ -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: */
|
@@ -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: */
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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: */
|
Binary file not shown.
Before Width: | Height: | Size: 318 B |
@@ -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 enth<74>lt die vorkompilierte Typinformation
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// ZU ERLEDIGEN: Verweis auf alle zus<75>tzlichen Header-Dateien, die Sie in STDAFX.H
|
||||
// und nicht in dieser Datei ben<65>tigen
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -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: */
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
@@ -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: */
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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: */
|
Binary file not shown.
Before Width: | Height: | Size: 318 B |
@@ -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 enth<74>lt die vorkompilierte Typinformation
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// ZU ERLEDIGEN: Verweis auf alle zus<75>tzlichen Header-Dateien, die Sie in STDAFX.H
|
||||
// und nicht in dieser Datei ben<65>tigen
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -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: */
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
@@ -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: */
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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: */
|
Binary file not shown.
Before Width: | Height: | Size: 318 B |
@@ -1 +0,0 @@
|
||||
registerAllTestFunction
|
@@ -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: */
|
@@ -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
|
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
File diff suppressed because it is too large
Load Diff
@@ -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: */
|
@@ -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: */
|
@@ -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: */
|
Reference in New Issue
Block a user