summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-22 13:16:09 +0000
committerTino Rachui <tra@openoffice.org>2001-03-22 13:16:09 +0000
commit710e1bf0bf38efec224089cf93132e502353ed75 (patch)
treece0b26a4382790fb880d3db283a04d500434f373
parent5fdd95a0641b94dac09b919bcfaa5ff49604163d (diff)
*** empty log message ***
-rw-r--r--dtrans/source/inc/MtaOleClipb.hxx20
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.cxx7
-rw-r--r--dtrans/source/win32/clipb/exports.dxp1
-rw-r--r--dtrans/source/win32/dtobj/DOTransferable.cxx162
-rw-r--r--dtrans/source/win32/dtobj/DOTransferable.hxx15
-rw-r--r--dtrans/source/win32/dtobj/DataFmtTransl.hxx8
-rw-r--r--dtrans/source/win32/dtobj/FetcList.cxx9
-rw-r--r--dtrans/source/win32/dtobj/XNotifyingDataObject.cxx10
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.cxx59
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.hxx13
-rw-r--r--dtrans/source/win32/misc/ImplHelper.cxx26
-rw-r--r--dtrans/source/win32/mtaole/MtaOleClipb.cxx75
12 files changed, 292 insertions, 113 deletions
diff --git a/dtrans/source/inc/MtaOleClipb.hxx b/dtrans/source/inc/MtaOleClipb.hxx
index 872aeca4348a..19157b83e963 100644
--- a/dtrans/source/inc/MtaOleClipb.hxx
+++ b/dtrans/source/inc/MtaOleClipb.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: MtaOleClipb.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-16 16:33:30 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:13:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,9 +66,20 @@
#include <sal/types.h>
#endif
-//#include <windows.h>
#include <objidl.h>
+/*
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+LRESULT CALLBACK mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
+
+#ifdef __cplusplus
+}
+#endif
+*/
+
//--------------------------------------------------------
// the Mta-Ole clipboard class is for internal use only!
// only one instance of this class should be created, the
@@ -134,6 +145,7 @@ private:
unsigned m_uOleThreadId;
HANDLE m_hEvtThrdReady;
HWND m_hwndMtaOleReqWnd;
+ ATOM m_MtaOleReqWndClassAtom;
HWND m_hwndNextClipViewer;
LPFNC_CLIPVIEWER_CALLBACK_t m_pfncClipViewerCallback;
sal_Bool m_bInRegisterClipViewer;
@@ -144,6 +156,8 @@ private:
private:
CMtaOleClipboard( const CMtaOleClipboard& );
CMtaOleClipboard& operator=( const CMtaOleClipboard& );
+
+ friend LRESULT CALLBACK mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
};
#endif \ No newline at end of file
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx
index 044845a1e808..2be823575b88 100644
--- a/dtrans/source/win32/clipb/WinClipbImpl.cxx
+++ b/dtrans/source/win32/clipb/WinClipbImpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipbImpl.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tra $ $Date: 2001-03-19 09:10:02 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:13:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -254,8 +254,7 @@ void SAL_CALL CWinClipbImpl::unregisterClipboardViewer( )
void SAL_CALL CWinClipbImpl::dispose() throw( RuntimeException )
{
- OSL_ENSURE( (NULL != m_pCurrentClipContent),
- "Clipboard was not flushed before shutdown!" );
+ OSL_ENSURE( !m_pCurrentClipContent, "Clipboard was not flushed before shutdown!" );
}
//------------------------------------------------------------------------
diff --git a/dtrans/source/win32/clipb/exports.dxp b/dtrans/source/win32/clipb/exports.dxp
index 028ac4175990..f72beb0fcb31 100644
--- a/dtrans/source/win32/clipb/exports.dxp
+++ b/dtrans/source/win32/clipb/exports.dxp
@@ -1,3 +1,4 @@
component_getImplementationEnvironment
component_writeInfo
component_getFactory
+
diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx
index eddf6f5322f7..b2fad9cd82bb 100644
--- a/dtrans/source/win32/dtobj/DOTransferable.cxx
+++ b/dtrans/source/win32/dtobj/DOTransferable.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DOTransferable.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:15:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,8 +83,12 @@
#include "DTransHelper.hxx"
#endif
-#ifndef _RTL_TENCINFO_H
-#include <rtl/tencinfo.h>
+#ifndef _IMPLHELPER_HXX_
+#include "..\misc\ImplHelper.hxx"
+#endif
+
+#ifndef _TXTCNVTHLP_HXX_
+#include "TxtCnvtHlp.hxx"
#endif
#ifndef _MIMEATTRIB_HXX_
@@ -148,7 +152,9 @@ CDOTransferable::CDOTransferable(
const Reference< XMultiServiceFactory >& ServiceManager, IDataObjectPtr rDataObject ) :
m_rDataObject( rDataObject ),
m_SrvMgr( ServiceManager ),
- m_DataFormatTranslator( m_SrvMgr )
+ m_DataFormatTranslator( m_SrvMgr ),
+ m_bUnicodeRegistered( sal_False ),
+ m_TxtFormatOnClipboard( CF_INVALID )
{
}
@@ -167,14 +173,31 @@ Any SAL_CALL CDOTransferable::getTransferData( const DataFlavor& aFlavor )
// convert dataflavor to formatetc
//------------------------------------------------
- CFormatEtc fetc = dataFlavorToFormatEtc( aFlavor );
+ CFormatEtc fetc = m_DataFormatTranslator.getFormatEtcFromDataFlavor( aFlavor );
OSL_ASSERT( CF_INVALID != fetc.getClipformat() );
//------------------------------------------------
// get the data from clipboard in a byte stream
//------------------------------------------------
- ByteSequence_t clipDataStream = getClipboardData( fetc );
+ ByteSequence_t clipDataStream;
+
+ try
+ {
+ clipDataStream = getClipboardData( fetc );
+ }
+ catch( UnsupportedFlavorException& )
+ {
+ if ( m_DataFormatTranslator.isUnicodeTextFormat( fetc.getClipformat( ) ) &&
+ m_bUnicodeRegistered )
+ {
+ OUString aUnicodeText = synthesizeUnicodeText( );
+ Any aAny = makeAny( aUnicodeText );
+ return aAny;
+ }
+ else
+ throw; // pass through exception
+ }
//------------------------------------------------
// return the data as any
@@ -217,6 +240,10 @@ sal_Bool SAL_CALL CDOTransferable::isDataFlavorSupported( const DataFlavor& aFla
// only once; if the client of this Transferable will hold a reference
// to it und the underlying clipboard content changes, the client does
// possible operate on a invalid list
+// if there is only text on the clipboard we will also offer unicode text
+// an synthesize this format on the fly if requested, to accomplish this
+// we save the first offered text format which we will later use for the
+// conversion
//------------------------------------------------------------------------
void SAL_CALL CDOTransferable::initFlavorList( )
@@ -237,7 +264,28 @@ void SAL_CALL CDOTransferable::initFlavorList( )
continue;
DataFlavor aFlavor = formatEtcToDataFlavor( fetc );
- addSupportedFlavor( aFlavor );
+
+ // if text or oemtext is offered we also pretend to have unicode text
+ if ( m_DataFormatTranslator.isOemOrAnsiTextFormat( fetc.cfFormat ) &&
+ !m_bUnicodeRegistered )
+ {
+ addSupportedFlavor( aFlavor );
+
+ m_TxtFormatOnClipboard = fetc.cfFormat;
+ m_bUnicodeRegistered = sal_True;
+
+ // register unicode text as accompany format
+ aFlavor = formatEtcToDataFlavor(
+ m_DataFormatTranslator.getFormatEtcForClipformat( CF_UNICODETEXT ) );
+ addSupportedFlavor( aFlavor );
+ }
+ else if ( (CF_UNICODETEXT == fetc.cfFormat) && !m_bUnicodeRegistered )
+ {
+ addSupportedFlavor( aFlavor );
+ m_bUnicodeRegistered = sal_True;
+ }
+ else
+ addSupportedFlavor( aFlavor );
// see MSDN IEnumFORMATETC
CoTaskMemFree( fetc.ptd );
@@ -266,45 +314,49 @@ void SAL_CALL CDOTransferable::addSupportedFlavor( const DataFlavor& aFlavor )
// helper function
//------------------------------------------------------------------------
-inline
-CFormatEtc SAL_CALL CDOTransferable::dataFlavorToFormatEtc( const DataFlavor& aFlavor ) const
+//inline
+DataFlavor SAL_CALL CDOTransferable::formatEtcToDataFlavor( const FORMATETC& aFormatEtc )
{
- return m_DataFormatTranslator.getFormatEtcFromDataFlavor( aFlavor );
+ DataFlavor aFlavor;
+ LCID lcid = 0;
+
+ // for non-unicode text format we must provid a locale to get
+ // the character-set of the text, if there is no locale on the
+ // clipboard we assume the text is in a charset appropriate for
+ // the current thread locale
+ if ( (CF_TEXT == aFormatEtc.cfFormat) || (CF_OEMTEXT == aFormatEtc.cfFormat) )
+ lcid = getLocaleFromClipboard( );
+
+ return m_DataFormatTranslator.getDataFlavorFromFormatEtc( aFormatEtc, lcid );
}
//------------------------------------------------------------------------
-// helper function
+// returns the current locale on clipboard; if there is no locale on
+// clipboard the function returns the current thread locale
//------------------------------------------------------------------------
-//inline
-DataFlavor SAL_CALL CDOTransferable::formatEtcToDataFlavor( const FORMATETC& aFormatEtc )
+LCID SAL_CALL CDOTransferable::getLocaleFromClipboard( )
{
- DataFlavor aFlavor;
LCID lcid = GetThreadLocale( );
try
{
- // for non-unicode text format we must provid a locale to get
- // the character-set of the text, if there is no locale on the
- // clipboard we assume the text is in a charset appropriate for
- // the current thread locale
- if ( (CF_TEXT == aFormatEtc.cfFormat) || (CF_OEMTEXT == aFormatEtc.cfFormat) )
- {
- CFormatEtc fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_LOCALE );
- ByteSequence_t aLCIDSeq = getClipboardData( fetc );
- lcid = *(reinterpret_cast<LCID*>( aLCIDSeq.getArray( ) ) );
- }
- }
- catch( UnsupportedFlavorException& )
- {
- // no locale on clipboard, we take the default
+ CFormatEtc fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_LOCALE );
+ ByteSequence_t aLCIDSeq = getClipboardData( fetc );
+ lcid = *(reinterpret_cast<LCID*>( aLCIDSeq.getArray( ) ) );
+
+ // because of a Win95/98 Bug; there the high word
+ // of a locale has the same value as the
+ // low word e.g. 0x07040704 that's not right
+ // correct is 0x00000704
+ lcid &= 0x0000FFFF;
}
catch(...)
{
- OSL_ENSURE( sal_False, "Unexpected" );
+ // we take the default locale
}
- return m_DataFormatTranslator.getDataFlavorFromFormatEtc( aFormatEtc, lcid );
+ return lcid;
}
//------------------------------------------------------------------------
@@ -313,7 +365,7 @@ DataFlavor SAL_CALL CDOTransferable::formatEtcToDataFlavor( const FORMATETC& aFo
// allocated etc.
//------------------------------------------------------------------------
-CDOTransferable::ByteSequence_t CDOTransferable::getClipboardData( CFormatEtc& aFormatEtc )
+CDOTransferable::ByteSequence_t SAL_CALL CDOTransferable::getClipboardData( CFormatEtc& aFormatEtc )
{
STGMEDIUM stgmedium;
HRESULT hr = m_rDataObject->GetData( aFormatEtc, &stgmedium );
@@ -360,6 +412,52 @@ CDOTransferable::ByteSequence_t CDOTransferable::getClipboardData( CFormatEtc& a
//
//------------------------------------------------------------------------
+OUString SAL_CALL CDOTransferable::synthesizeUnicodeText( )
+{
+ ByteSequence_t aTextSequence;
+ CFormatEtc fetc;
+ LCID lcid = getLocaleFromClipboard( );
+ sal_uInt32 cpForTxtCnvt;
+
+ if ( CF_TEXT == m_TxtFormatOnClipboard )
+ {
+ fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_TEXT );
+ aTextSequence = getClipboardData( fetc );
+
+ // determine the codepage used for text conversion
+ cpForTxtCnvt = getWinCPFromLocaleId( lcid, LOCALE_IDEFAULTANSICODEPAGE ).toInt32( );
+ }
+ else if ( CF_OEMTEXT == m_TxtFormatOnClipboard )
+ {
+ fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_OEMTEXT );
+ aTextSequence = getClipboardData( fetc );
+
+ // determine the codepage used for text conversion
+ cpForTxtCnvt = getWinCPFromLocaleId( lcid, LOCALE_IDEFAULTCODEPAGE ).toInt32( );
+ }
+ else
+ OSL_ASSERT( sal_False );
+
+ CStgTransferHelper stgTransferHelper;
+
+ // convert the text
+ sal_Int32 lStr = MultiByteToWideCharEx(
+ cpForTxtCnvt,
+ reinterpret_cast< char* >( aTextSequence.getArray( ) ),
+ -1, // \0 terminated string
+ stgTransferHelper,
+ sal_True );
+
+ CRawHGlobalPtr ptrHGlob( stgTransferHelper );
+ sal_Unicode* pWChar = reinterpret_cast< sal_Unicode* >( ptrHGlob.GetMemPtr( ) );
+
+ return OUString( pWChar, (lStr - 1) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
void CDOTransferable::clipDataToByteStream( STGMEDIUM stgmedium, ByteSequence_t& aByteSequence )
{
CStgTransferHelper memTransferHelper;
diff --git a/dtrans/source/win32/dtobj/DOTransferable.hxx b/dtrans/source/win32/dtobj/DOTransferable.hxx
index decd239adc29..00e8205a7681 100644
--- a/dtrans/source/win32/dtobj/DOTransferable.hxx
+++ b/dtrans/source/win32/dtobj/DOTransferable.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DOTransferable.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 15:45:14 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:15:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -127,16 +127,19 @@ private:
void SAL_CALL initFlavorList( );
- void SAL_CALL addSupportedFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
- CFormatEtc SAL_CALL dataFlavorToFormatEtc( const com::sun::star::datatransfer::DataFlavor& aFlavor ) const;
+ void SAL_CALL addSupportedFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc );
ByteSequence_t SAL_CALL getClipboardData( CFormatEtc& aFormatEtc );
- void SAL_CALL clipDataToByteStream( STGMEDIUM stgmedium, ByteSequence_t& aByteSequence );
+ rtl::OUString SAL_CALL synthesizeUnicodeText( );
+
+ void SAL_CALL clipDataToByteStream( STGMEDIUM stgmedium, ByteSequence_t& aByteSequence );
::com::sun::star::uno::Any SAL_CALL byteStreamToAny( ByteSequence_t& aByteStream, const com::sun::star::uno::Type& aRequestedDataType );
rtl::OUString SAL_CALL byteStreamToOUString( ByteSequence_t& aByteStream );
+ LCID SAL_CALL getLocaleFromClipboard( );
+
sal_Bool SAL_CALL compareDataFlavors( const com::sun::star::datatransfer::DataFlavor& lhs,
const com::sun::star::datatransfer::DataFlavor& rhs );
@@ -153,6 +156,8 @@ private:
CDataFormatTranslator m_DataFormatTranslator;
com::sun::star::uno::Reference< com::sun::star::datatransfer::XMimeContentTypeFactory > m_rXMimeCntFactory;
::osl::Mutex m_aMutex;
+ sal_Bool m_bUnicodeRegistered;
+ CLIPFORMAT m_TxtFormatOnClipboard;
// non supported operations
private:
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.hxx b/dtrans/source/win32/dtobj/DataFmtTransl.hxx
index ddc2be2b01d4..1234abbe44a0 100644
--- a/dtrans/source/win32/dtobj/DataFmtTransl.hxx
+++ b/dtrans/source/win32/dtobj/DataFmtTransl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DataFmtTransl.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:15:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -104,8 +104,8 @@ public:
com::sun::star::datatransfer::DataFlavor getDataFlavorFromFormatEtc(
const FORMATETC& aFormatEtc, LCID lcid = GetThreadLocale( ) ) const;
- CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT cf ) const;
- CFormatEtc SAL_CALL getFormatEtcForClipformatName( const rtl::OUString& aClipFmtName ) const;
+ CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT cf ) const;
+ CFormatEtc SAL_CALL getFormatEtcForClipformatName( const rtl::OUString& aClipFmtName ) const;
rtl::OUString SAL_CALL getClipboardFormatName( CLIPFORMAT aClipformat ) const;
sal_Bool SAL_CALL isHTMLFormat( CLIPFORMAT cf ) const;
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx
index c8720ac47e9f..720ed816941f 100644
--- a/dtrans/source/win32/dtobj/FetcList.cxx
+++ b/dtrans/source/win32/dtobj/FetcList.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FetcList.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:15:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -110,8 +110,8 @@ using namespace std;
//
//------------------------------------------------------------------------
-LCID CFormatRegistrar::m_TxtLocale = 0;
-sal_uInt32 CFormatRegistrar::m_TxtCodePage = GetACP( );
+LCID CFormatRegistrar::m_TxtLocale = 0;
+sal_uInt32 CFormatRegistrar::m_TxtCodePage = GetACP( );
//------------------------------------------------------------------------
//
@@ -510,6 +510,7 @@ sal_Bool SAL_CALL CFormatRegistrar::isLocaleAnsiCodePage( LCID lcid, sal_uInt32
BOOL CALLBACK CFormatRegistrar::EnumLocalesProc( LPSTR lpLocaleStr )
{
+ // the lpLocaleStr parametere is hexadecimal
LCID lcid = strtol( lpLocaleStr, NULL, 16 );
if ( isLocaleAnsiCodePage( lcid, CFormatRegistrar::m_TxtCodePage ) ||
diff --git a/dtrans/source/win32/dtobj/XNotifyingDataObject.cxx b/dtrans/source/win32/dtobj/XNotifyingDataObject.cxx
index 512865dbf890..34dd093fdc7b 100644
--- a/dtrans/source/win32/dtobj/XNotifyingDataObject.cxx
+++ b/dtrans/source/win32/dtobj/XNotifyingDataObject.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XNotifyingDataObject.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-03-16 16:31:54 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:15:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,12 +67,6 @@
#include <osl/diagnose.h>
#endif
-/*
-#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARDEX_HPP_
-#include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp>
-#endif
-*/
-
#ifndef _XNOTIFYINGDATAOBJECT_HXX_
#include "XNotifyingDataObject.hxx"
#endif
diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx
index 88bf18666069..aa9c3ea0f27e 100644
--- a/dtrans/source/win32/dtobj/XTDataObject.cxx
+++ b/dtrans/source/win32/dtobj/XTDataObject.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XTDataObject.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: tra $ $Date: 2001-03-20 13:39:33 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:16:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -335,6 +335,15 @@ void SAL_CALL CXTDataObject::renderAnyDataAndSetupStgMedium(
// spec. an do throw an UnsupportedFlavorException
// so we must check the any
if ( !aAny.hasValue( ) )
+ {
+ OSL_ENSURE( sal_False, "XTransferable should throw an exception if ask for an unsupported flavor" );
+ throw UnsupportedFlavorException( );
+ }
+
+ // unfortunately not all transferables fulfill the
+ // spec. an do throw an UnsupportedFlavorException
+ // so we must check the any
+ if ( !aAny.hasValue( ) )
throw UnsupportedFlavorException( );
Sequence< sal_Int8 > clipDataStream;
@@ -351,17 +360,8 @@ void SAL_CALL CXTDataObject::renderAnyDataAndSetupStgMedium(
// transfer data
if ( CF_METAFILEPICT == fetc.cfFormat )
{
-/*!!! KA => TRA: doesn't work !!!
- HMETAFILEPICT hMfPict = OOMFPictToWinMFPict( clipDataStream );
- renderDataAndSetupStgMedium(
- reinterpret_cast< sal_Int8* >( &hMfPict ),
- fetc,
- 0,
- sizeof( HMETAFILEPICT ),
- stgmedium );
-*/
- stgmedium.tymed = TYMED_MFPICT;
- stgmedium.hMetaFilePict = OOMFPictToWinMFPict( clipDataStream );
+ stgmedium.tymed = TYMED_MFPICT;
+ stgmedium.hMetaFilePict = OOMFPictToWinMFPict( clipDataStream );
stgmedium.pUnkForRelease = NULL;
}
else
@@ -422,6 +422,16 @@ void SAL_CALL CXTDataObject::renderSynthesizedUnicodeAndSetupStgMedium( FORMATET
OSL_ASSERT( CF_UNICODETEXT == fetc.cfFormat );
Any aAny = m_XTransferable->getTransferData( m_FormatRegistrar.getRegisteredTextFlavor( ) );
+
+ // unfortunately not all transferables fulfill the
+ // spec. an do throw an UnsupportedFlavorException
+ // so we must check the any
+ if ( !aAny.hasValue( ) )
+ {
+ OSL_ENSURE( sal_False, "XTransferable should throw an exception if ask for an unsupported flavor" );
+ throw UnsupportedFlavorException( );
+ }
+
Sequence< sal_Int8 > aText;
aAny >>= aText;
@@ -448,6 +458,16 @@ void SAL_CALL CXTDataObject::renderSynthesizedTextAndSetupStgMedium( FORMATETC&
m_DataFormatTranslator.getFormatEtcForClipformat( CF_UNICODETEXT ) );
Any aAny = m_XTransferable->getTransferData( aFlavor );
+
+ // unfortunately not all transferables fulfill the
+ // spec. an do throw an UnsupportedFlavorException
+ // so we must check the any
+ if ( !aAny.hasValue( ) )
+ {
+ OSL_ENSURE( sal_False, "XTransferable should throw an exception if ask for an unsupported flavor" );
+ throw UnsupportedFlavorException( );
+ }
+
OUString aUnicodeText;
aAny >>= aUnicodeText;
@@ -478,6 +498,15 @@ void SAL_CALL CXTDataObject::renderSynthesizedHtmlAndSetupStgMedium( FORMATETC&
Any aAny = m_XTransferable->getTransferData( aFlavor );
+ // unfortunately not all transferables fulfill the
+ // spec. an do throw an UnsupportedFlavorException
+ // so we must check the any
+ if ( !aAny.hasValue( ) )
+ {
+ OSL_ENSURE( sal_False, "XTransferable should throw an exception if ask for an unsupported flavor" );
+ throw UnsupportedFlavorException( );
+ }
+
Sequence< sal_Int8 > aTextHtmlSequence;
aAny >>= aTextHtmlSequence;
@@ -631,9 +660,7 @@ void CXTDataObject::validateFormatEtc( LPFORMATETC lpFormatEtc ) const
if ( lpFormatEtc->lindex != -1 )
throw CInvalidFormatEtcException( DV_E_LINDEX );
- if ( !(lpFormatEtc->dwAspect & DVASPECT_CONTENT) /*&&
- !(lpFormatEtc->dwAspect & DVASPECT_COPY) &&
- !(lpFormatEtc->dwAspect & DVASPECT_LINK)*/ &&
+ if ( !(lpFormatEtc->dwAspect & DVASPECT_CONTENT) &&
!(lpFormatEtc->dwAspect & DVASPECT_SHORTNAME) )
throw CInvalidFormatEtcException( DV_E_DVASPECT );
diff --git a/dtrans/source/win32/dtobj/XTDataObject.hxx b/dtrans/source/win32/dtobj/XTDataObject.hxx
index e6fc161724fc..5df93956c12a 100644
--- a/dtrans/source/win32/dtobj/XTDataObject.hxx
+++ b/dtrans/source/win32/dtobj/XTDataObject.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XTDataObject.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:16:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -139,8 +139,8 @@ public:
operator IDataObject*( );
private:
- void validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const;
+
void SAL_CALL renderDataAndSetupStgMedium( const sal_Int8* lpStorage,
const FORMATETC& fetc,
sal_uInt32 nInitStgSize,
@@ -152,14 +152,15 @@ private:
void SAL_CALL renderAnyDataAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
HRESULT SAL_CALL renderSynthesizedFormatAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
- void SAL_CALL renderSynthesizedUnicodeAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
- void SAL_CALL renderSynthesizedTextAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
- void SAL_CALL renderSynthesizedHtmlAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
+ void SAL_CALL renderSynthesizedUnicodeAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
+ void SAL_CALL renderSynthesizedTextAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
+ void SAL_CALL renderSynthesizedHtmlAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium );
void SAL_CALL setupStgMedium( const FORMATETC& fetc,
CStgTransferHelper& stgTransHlp,
STGMEDIUM& stgmedium );
+ void validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
void SAL_CALL invalidateStgMedium( STGMEDIUM& stgmedium ) const;
HRESULT SAL_CALL translateStgExceptionCode( HRESULT hr ) const;
diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx
index 0d7888cb6984..8b9df47c12a4 100644
--- a/dtrans/source/win32/misc/ImplHelper.cxx
+++ b/dtrans/source/win32/misc/ImplHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ImplHelper.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: tra $ $Date: 2001-03-19 13:03:00 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:14:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -143,6 +143,25 @@ OUString SAL_CALL getWinCPFromLocaleId( LCID lcid, LCTYPE lctype )
{
OSL_ASSERT( IsValidLocale( lcid, LCID_SUPPORTED ) );
+ // we set an default value
+ OUString winCP;
+
+ // set an default value
+ sal_Unicode wcstr[10];
+
+ if ( LOCALE_IDEFAULTCODEPAGE == lctype )
+ {
+ _itow( GetOEMCP( ), wcstr, 10 );
+ winCP = OUString( wcstr, wcslen( wcstr ) );
+ }
+ else if ( LOCALE_IDEFAULTANSICODEPAGE == lctype )
+ {
+ _itow( GetACP( ), wcstr, 10 );
+ winCP = OUString( wcstr, wcslen( wcstr ) );
+ }
+ else
+ OSL_ASSERT( sal_False );
+
// we use the GetLocaleInfoA because don't want to provide
// a unicode wrapper function for Win9x in sal/systools
char buff[6];
@@ -151,9 +170,6 @@ OUString SAL_CALL getWinCPFromLocaleId( LCID lcid, LCTYPE lctype )
OSL_ASSERT( nResult );
- // we set an default value
- OUString winCP = OUString::createFromAscii( "1252" );
-
if ( nResult )
{
sal_Int32 len = MultiByteToWideChar(
diff --git a/dtrans/source/win32/mtaole/MtaOleClipb.cxx b/dtrans/source/win32/mtaole/MtaOleClipb.cxx
index cd8b630c80a9..4f5aaf4ac19a 100644
--- a/dtrans/source/win32/mtaole/MtaOleClipb.cxx
+++ b/dtrans/source/win32/mtaole/MtaOleClipb.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: MtaOleClipb.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: tra $ $Date: 2001-03-20 14:14:28 $
+ * last change: $Author: tra $ $Date: 2001-03-22 14:14:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,8 +69,6 @@
#include <osl/diagnose.h>
#endif
-#include <systools/win32/user9x.h>
-
#include "..\..\inc\MtaOleClipb.hxx"
#ifndef _OSL_CONDITN_HXX_
@@ -90,8 +88,11 @@ using osl::Condition;
// defines
//----------------------------------------------------------------
-#define HIDDEN_CB_WNDCLS_NAME "MtaOleReqWnd_920896680C9449"
-#define CLIPSERVICE_DLL_NAME "sysdtrans.dll"
+namespace
+{
+ char CLIPSRV_DLL_NAME[] = "sysdtrans.dll";
+ char g_szWndClsName[] = "MtaOleReqWnd###";
+}
//--------------------------------------------------------
// messages constants
@@ -103,10 +104,10 @@ const sal_uInt32 MSG_REGCLIPVIEWER = WM_USER + 0x0003;
const sal_uInt32 MSG_FLUSHCLIPBOARD = WM_USER + 0x0004;
const sal_uInt32 MSG_SHUTDOWN = WM_USER + 0x0006;
-const sal_uInt32 MAX_WAITTIME = 60000;
-const sal_uInt32 MAX_OPCOMPLET_WAITTIME = 30;
-const sal_uInt32 MAX_WAIT_SHUTDOWN = 30000;
-const sal_uInt32 MAX_CLIPEVENT_PROCESSING_TIME = 5000;
+const sal_uInt32 MAX_WAITTIME = 10000; // msec
+const sal_uInt32 MAX_OPCOMPLET_WAITTIME = 10; // sec
+const sal_uInt32 MAX_WAIT_SHUTDOWN = 10000; // msec
+const sal_uInt32 MAX_CLIPEVENT_PROCESSING_TIME = 5000; // msec
const sal_Bool MANUAL_RESET = sal_True;
const sal_Bool AUTO_RESET = sal_False;
@@ -190,6 +191,7 @@ CMtaOleClipboard::CMtaOleClipboard( ) :
m_uOleThreadId( 0 ),
m_hEvtThrdReady( NULL ),
m_hwndMtaOleReqWnd( NULL ),
+ m_MtaOleReqWndClassAtom( 0 ),
m_hwndNextClipViewer( NULL ),
m_pfncClipViewerCallback( NULL )
{
@@ -233,6 +235,9 @@ CMtaOleClipboard::~CMtaOleClipboard( )
if ( NULL != m_hEvtThrdReady )
CloseHandle( m_hEvtThrdReady );
+ if ( m_MtaOleReqWndClassAtom )
+ UnregisterClassA( g_szWndClsName, NULL );
+
OSL_ENSURE( ( NULL == m_pfncClipViewerCallback ) &&
!IsWindow( m_hwndNextClipViewer ), \
"Clipboard viewer not properly unregistered" );
@@ -599,7 +604,7 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA
break;
case MSG_REGCLIPVIEWER:
- pImpl->onRegisterClipViewer( reinterpret_cast<LPFNC_CLIPVIEWER_CALLBACK_t>(wParam) );
+ pImpl->onRegisterClipViewer( reinterpret_cast<CMtaOleClipboard::LPFNC_CLIPVIEWER_CALLBACK_t>(wParam) );
aMsgCtx->aCondition->set( );
break;
@@ -616,12 +621,23 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA
DestroyWindow( pImpl->m_hwndMtaOleReqWnd );
break;
+ // under windows 95/98 the creation of the
+ // hidden target request window fails if
+ // we don't handle this message ourself
+ // because the DefWindowProc returns 0 as
+ // a result of handling WM_NCCREATE what
+ // leads to a failure of CreateWindow[Ex]!!!
+ case WM_NCCREATE:
+ lResult = TRUE;
+ break;
+
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
- return DefWindowProc( hWnd, uMsg, wParam, lParam );
+ lResult = DefWindowProc( hWnd, uMsg, wParam, lParam );
+ break;
}
return lResult;
@@ -634,23 +650,30 @@ LRESULT CALLBACK CMtaOleClipboard::mtaOleReqWndProc( HWND hWnd, UINT uMsg, WPARA
void CMtaOleClipboard::createMtaOleReqWnd( )
{
WNDCLASSEXA wcex;
- //sal_Unicode szWndClsName[] = HIDDEN_CB_WNDCLS_NAME;
- char szWndClsName[] = HIDDEN_CB_WNDCLS_NAME;
- HINSTANCE hInst = GetModuleHandleA( CLIPSERVICE_DLL_NAME );
+ HINSTANCE hInst = GetModuleHandleA( CLIPSRV_DLL_NAME );
OSL_ENSURE( NULL != hInst, "The name of the clipboard service dll must have changed" );
ZeroMemory( &wcex, sizeof( WNDCLASSEXA ) );
- wcex.cbSize = sizeof( WNDCLASSEXA );
- wcex.lpfnWndProc = static_cast< WNDPROC >( CMtaOleClipboard::mtaOleReqWndProc );
- wcex.hInstance = hInst;
- wcex.lpszClassName = szWndClsName;
-
- ATOM atom = RegisterClassExA( &wcex );
- if ( 0 != atom )
- m_hwndMtaOleReqWnd = CreateWindowExA(
- 0, szWndClsName,"", 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL );
+ wcex.cbSize = sizeof(WNDCLASSEXA);
+ wcex.style = 0;
+ wcex.lpfnWndProc = static_cast< WNDPROC >( CMtaOleClipboard::mtaOleReqWndProc );
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInst;
+ wcex.hIcon = NULL;
+ wcex.hCursor = NULL;
+ wcex.hbrBackground = NULL;
+ wcex.lpszMenuName = NULL;
+ wcex.lpszClassName = g_szWndClsName;
+ wcex.hIconSm = NULL;
+
+ m_MtaOleReqWndClassAtom = RegisterClassExA( &wcex );
+
+ if ( 0 != m_MtaOleReqWndClassAtom )
+ m_hwndMtaOleReqWnd = CreateWindowA(
+ g_szWndClsName, NULL, 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL );
}
//--------------------------------------------------------------------
@@ -673,8 +696,8 @@ unsigned int CMtaOleClipboard::run( )
// pumping messages
MSG msg;
- while( GetMessage( &msg, NULL, 0, 0 ) )
- DispatchMessage( &msg );
+ while( GetMessageA( &msg, NULL, 0, 0 ) )
+ DispatchMessageA( &msg );
nRet = 0;
}