summaryrefslogtreecommitdiff
path: root/dtrans
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-20 08:26:01 +0000
committerTino Rachui <tra@openoffice.org>2001-03-20 08:26:01 +0000
commite40c8c132e2c7aff2237b29f5ee5415bbdb58744 (patch)
tree6a41050cf305b0cb7504f96f12b3616e93a1e7cc /dtrans
parentdd1aba4c3364333d6b7e141f7b341863ecebb433 (diff)
*** empty log message ***
Diffstat (limited to 'dtrans')
-rw-r--r--dtrans/source/win32/dtobj/DataFmtTransl.cxx68
-rw-r--r--dtrans/source/win32/dtobj/DataFmtTransl.hxx15
-rw-r--r--dtrans/source/win32/dtobj/FetcList.cxx79
-rw-r--r--dtrans/source/win32/dtobj/FetcList.hxx17
-rw-r--r--dtrans/source/win32/dtobj/FmtFilter.cxx105
-rw-r--r--dtrans/source/win32/dtobj/FmtFilter.hxx13
-rw-r--r--dtrans/source/win32/dtobj/TxtCnvtHlp.cxx58
-rw-r--r--dtrans/source/win32/dtobj/TxtCnvtHlp.hxx22
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.cxx123
-rw-r--r--dtrans/source/win32/dtobj/XTDataObject.hxx6
10 files changed, 307 insertions, 199 deletions
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.cxx b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
index 6bc650a3c496..9f6845d8f9d2 100644
--- a/dtrans/source/win32/dtobj/DataFmtTransl.cxx
+++ b/dtrans/source/win32/dtobj/DataFmtTransl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DataFmtTransl.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tra $ $Date: 2001-03-19 09:11:03 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -198,7 +198,7 @@ DataFlavor CDataFormatTranslator::getDataFlavorFromFormatEtc( const Reference< X
Any aAny;
aAny <<= static_cast< sal_Int32 >( aClipformat );
- if ( isOemOrAnsiTextClipformat( aClipformat ) )
+ if ( isOemOrAnsiTextFormat( aClipformat ) )
{
aFlavor.MimeType = OUString::createFromAscii( "text/plain;charset=" );
aFlavor.MimeType += getTextCharsetFromClipboard( refXTransferable, aClipformat );
@@ -241,6 +241,20 @@ DataFlavor CDataFormatTranslator::getDataFlavorFromFormatEtc( const Reference< X
//
//------------------------------------------------------------------------
+CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformatName( const OUString& aClipFmtName ) const
+{
+ // check parameter
+ if ( !aClipFmtName.getLength( ) )
+ return CFormatEtc( CF_INVALID );
+
+ CLIPFORMAT cf = RegisterClipboardFormatW( aClipFmtName.getStr( ) );
+ return getFormatEtcForClipformat( cf );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
OUString CDataFormatTranslator::getClipboardFormatName( CLIPFORMAT aClipformat ) const
{
OSL_PRECOND( CF_INVALID != aClipformat, "Invalid clipboard format" );
@@ -280,11 +294,49 @@ CFormatEtc SAL_CALL CDataFormatTranslator::getFormatEtcForClipformat( CLIPFORMAT
//
//------------------------------------------------------------------------
-inline
-sal_Bool SAL_CALL CDataFormatTranslator::isOemOrAnsiTextClipformat( CLIPFORMAT aClipformat ) const
+sal_Bool SAL_CALL CDataFormatTranslator::isOemOrAnsiTextFormat( CLIPFORMAT cf ) const
+{
+ return ( (cf == CF_TEXT) || (cf == CF_OEMTEXT) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CDataFormatTranslator::isUnicodeTextFormat( CLIPFORMAT cf ) const
+{
+ return ( cf == CF_UNICODETEXT );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CDataFormatTranslator::isTextFormat( CLIPFORMAT cf ) const
{
- return ( (aClipformat == CF_TEXT) ||
- (aClipformat == CF_OEMTEXT) );
+ return ( isOemOrAnsiTextFormat( cf ) || isUnicodeTextFormat( cf ) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CDataFormatTranslator::isHTMLFormat( CLIPFORMAT cf ) const
+{
+ OUString clipFormatName = getClipboardFormatName( cf );
+ return ( clipFormatName == OUString::createFromAscii( "HTML Format" ) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CDataFormatTranslator::isTextHtmlFormat( CLIPFORMAT cf ) const
+{
+ OUString clipFormatName = getClipboardFormatName( cf );
+
+ return ( clipFormatName.equalsIgnoreCase(
+ OUString::createFromAscii( "HTML (HyperText Markup Language)" ) ) );
}
//------------------------------------------------------------------------
@@ -334,7 +386,7 @@ LCID SAL_CALL CDataFormatTranslator::getCurrentLocaleFromClipboard(
OUString SAL_CALL CDataFormatTranslator::getTextCharsetFromClipboard(
const Reference< XTransferable >& refXTransferable, CLIPFORMAT aClipformat ) const
{
- OSL_ASSERT( isOemOrAnsiTextClipformat( aClipformat ) );
+ OSL_ASSERT( isOemOrAnsiTextFormat( aClipformat ) );
OUString charset;
if ( CF_TEXT == aClipformat )
diff --git a/dtrans/source/win32/dtobj/DataFmtTransl.hxx b/dtrans/source/win32/dtobj/DataFmtTransl.hxx
index ca03da95268f..53e04eeb07c3 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.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-09 08:46:46 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -105,11 +105,16 @@ public:
const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& refXTransferable, const FORMATETC& aFormatEtc ) const;
CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT cf ) const;
-
-private:
+ CFormatEtc SAL_CALL getFormatEtcForClipformatName( const rtl::OUString& aClipFmtName ) const;
rtl::OUString SAL_CALL getClipboardFormatName( CLIPFORMAT aClipformat ) const;
- sal_Bool SAL_CALL isOemOrAnsiTextClipformat( CLIPFORMAT aClipformat ) const;
+ sal_Bool SAL_CALL isHTMLFormat( CLIPFORMAT cf ) const;
+ sal_Bool SAL_CALL isTextHtmlFormat( CLIPFORMAT cf ) const;
+ sal_Bool SAL_CALL isOemOrAnsiTextFormat( CLIPFORMAT cf ) const;
+ sal_Bool SAL_CALL isUnicodeTextFormat( CLIPFORMAT cf ) const;
+ sal_Bool SAL_CALL isTextFormat( CLIPFORMAT cf ) const;
+
+private:
LCID SAL_CALL getCurrentLocaleFromClipboard( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& refXTransferable ) const;
rtl::OUString SAL_CALL getTextCharsetFromClipboard(
const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& refXTransferable, CLIPFORMAT aClipformat ) const;
diff --git a/dtrans/source/win32/dtobj/FetcList.cxx b/dtrans/source/win32/dtobj/FetcList.cxx
index c0e0df266960..1209300f9574 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.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tra $ $Date: 2001-03-19 13:02:38 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -270,23 +270,24 @@ void SAL_CALL CFormatRegistrar::RegisterFormats(
for( sal_Int32 i = 0; i < nFlavors; i++ )
{
aFlavor = aFlavorList[i];
- CFormatEtc fetc = dataFlavorToFormatEtc( aFlavor );
+ CFormatEtc fetc = m_DataFormatTranslator.getFormatEtcFromDataFlavor( aFlavor );
if ( !needsToSynthesizeAccompanyFormats( fetc ) )
aFormatEtcContainer.addFormatEtc( fetc );
else
{
// if we haven't registered any text format up to now
- if ( isTextFormat( fetc.getClipformat() ) && !bUnicodeRegistered )
+ if ( m_DataFormatTranslator.isTextFormat( fetc.getClipformat() ) && !bUnicodeRegistered )
{
// if the transferable supports unicode text we ignore
// any further text format the transferable offers
// because we can create it from Unicode text in addition
// we register CF_TEXT for non unicode clients
- if ( isUnicodeTextFormat( fetc.getClipformat() ) )
+ if ( m_DataFormatTranslator.isUnicodeTextFormat( fetc.getClipformat() ) )
{
aFormatEtcContainer.addFormatEtc( fetc ); // add CF_UNICODE
- aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_TEXT ) ); // add CF_TEXT
+ aFormatEtcContainer.addFormatEtc(
+ m_DataFormatTranslator.getFormatEtcForClipformat( CF_TEXT ) ); // add CF_TEXT
bUnicodeRegistered = sal_True;
}
else if ( !hasUnicodeFlavor( aXTransferable ) )
@@ -302,14 +303,18 @@ void SAL_CALL CFormatRegistrar::RegisterFormats(
{
m_TxtCodePage = txtCP;
- aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_UNICODETEXT ) );
+ aFormatEtcContainer.addFormatEtc(
+ m_DataFormatTranslator.getFormatEtcForClipformat( CF_UNICODETEXT ) );
if ( !IsOEMCP( m_TxtCodePage ) )
- aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_TEXT ) );
+ aFormatEtcContainer.addFormatEtc(
+ m_DataFormatTranslator.getFormatEtcForClipformat( CF_TEXT ) );
else
- aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_OEMTEXT ) );
+ aFormatEtcContainer.addFormatEtc(
+ m_DataFormatTranslator.getFormatEtcForClipformat( CF_OEMTEXT ) );
- aFormatEtcContainer.addFormatEtc( getFormatEtcForClipformat( CF_LOCALE ) );
+ aFormatEtcContainer.addFormatEtc(
+ m_DataFormatTranslator.getFormatEtcForClipformat( CF_LOCALE ) );
// we save the flavor so it's easier when
// queried for it in XTDataObject::GetData(...)
@@ -320,6 +325,13 @@ void SAL_CALL CFormatRegistrar::RegisterFormats(
}
else // Html (Hyper Text...)
{
+ // we add text/html ( HTML (HyperText Markup Language) )
+ aFormatEtcContainer.addFormatEtc( fetc );
+
+ // and HTML Format
+ OUString htmlFormat( OUString::createFromAscii( "HTML Format" ) );
+ aFormatEtcContainer.addFormatEtc(
+ m_DataFormatTranslator.getFormatEtcForClipformatName( htmlFormat ) );
}
}
}
@@ -356,40 +368,20 @@ sal_uInt32 SAL_CALL CFormatRegistrar::getRegisteredTextCodePage( ) const
//
//------------------------------------------------------------------------
-inline
-sal_Bool SAL_CALL CFormatRegistrar::isOemOrAnsiTextFormat( CLIPFORMAT cf ) const
-{
- return ( (cf == CF_TEXT) || (cf == CF_OEMTEXT) );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-inline
-sal_Bool SAL_CALL CFormatRegistrar::isUnicodeTextFormat( CLIPFORMAT cf ) const
-{
- return ( cf == CF_UNICODETEXT );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-inline
-sal_Bool SAL_CALL CFormatRegistrar::isTextFormat( CLIPFORMAT cf ) const
+DataFlavor SAL_CALL CFormatRegistrar::getRegisteredTextFlavor( ) const
{
- return ( isOemOrAnsiTextFormat( cf ) ||
- isUnicodeTextFormat( cf ) );
+ return m_RegisteredTextFlavor;
}
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------
-CFormatEtc SAL_CALL CFormatRegistrar::dataFlavorToFormatEtc( const DataFlavor& aFlavor ) const
+sal_Bool SAL_CALL CFormatRegistrar::isSynthesizeableFormat( const CFormatEtc& aFormatEtc ) const
{
- return m_DataFormatTranslator.getFormatEtcFromDataFlavor( aFlavor );
+ return ( m_DataFormatTranslator.isOemOrAnsiTextFormat( aFormatEtc.getClipformat() ) ||
+ m_DataFormatTranslator.isUnicodeTextFormat( aFormatEtc.getClipformat() ) ||
+ m_DataFormatTranslator.isHTMLFormat( aFormatEtc.getClipformat() ) );
}
//------------------------------------------------------------------------
@@ -399,8 +391,9 @@ CFormatEtc SAL_CALL CFormatRegistrar::dataFlavorToFormatEtc( const DataFlavor& a
inline
sal_Bool SAL_CALL CFormatRegistrar::needsToSynthesizeAccompanyFormats( const CFormatEtc& aFormatEtc ) const
{
- return ( isOemOrAnsiTextFormat( aFormatEtc.getClipformat() ) ||
- isUnicodeTextFormat( aFormatEtc.getClipformat() ) );
+ return ( m_DataFormatTranslator.isOemOrAnsiTextFormat( aFormatEtc.getClipformat() ) ||
+ m_DataFormatTranslator.isUnicodeTextFormat( aFormatEtc.getClipformat() ) ||
+ m_DataFormatTranslator.isTextHtmlFormat( aFormatEtc.getClipformat( ) ) );
}
//------------------------------------------------------------------------
@@ -442,16 +435,6 @@ OUString SAL_CALL CFormatRegistrar::getCharsetFromDataFlavor( const DataFlavor&
//
//------------------------------------------------------------------------
-inline
-CFormatEtc SAL_CALL CFormatRegistrar::getFormatEtcForClipformat( CLIPFORMAT aClipformat ) const
-{
- return m_DataFormatTranslator.getFormatEtcForClipformat( aClipformat );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
sal_Bool SAL_CALL CFormatRegistrar::hasUnicodeFlavor( const Reference< XTransferable >& aXTransferable ) const
{
CFormatEtc fetc( CF_UNICODETEXT );
diff --git a/dtrans/source/win32/dtobj/FetcList.hxx b/dtrans/source/win32/dtobj/FetcList.hxx
index 8a61a9a1b601..766e0b4428c8 100644
--- a/dtrans/source/win32/dtobj/FetcList.hxx
+++ b/dtrans/source/win32/dtobj/FetcList.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FetcList.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tra $ $Date: 2001-03-19 13:02:37 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -159,18 +159,15 @@ public:
sal_uInt32 SAL_CALL getRegisteredTextCodePage( ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL getRegisteredTextFlavor( ) const;
-private:
- sal_Bool SAL_CALL isOemOrAnsiTextFormat( CLIPFORMAT cf ) const;
- sal_Bool SAL_CALL isUnicodeTextFormat( CLIPFORMAT cf ) const;
- sal_Bool SAL_CALL isTextFormat( CLIPFORMAT cf ) const;
- CFormatEtc SAL_CALL dataFlavorToFormatEtc( const com::sun::star::datatransfer::DataFlavor& aFlavor ) const;
+ sal_Bool SAL_CALL isSynthesizeableFormat( const CFormatEtc& aFormatEtc ) const;
sal_Bool SAL_CALL needsToSynthesizeAccompanyFormats( const CFormatEtc& aFormatEtc ) const;
- sal_Bool SAL_CALL isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) const;
+private:
+ sal_Bool SAL_CALL isEqualCurrentSystemCodePage( sal_uInt32 aCodePage ) const;
rtl::OUString SAL_CALL getCharsetFromDataFlavor( const com::sun::star::datatransfer::DataFlavor& aFlavor );
- CFormatEtc SAL_CALL getFormatEtcForClipformat( CLIPFORMAT aClipformat ) const;
- sal_Bool SAL_CALL hasUnicodeFlavor( const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable ) const;
+ sal_Bool SAL_CALL hasUnicodeFlavor(
+ const com::sun::star::uno::Reference< com::sun::star::datatransfer::XTransferable >& aXTransferable ) const;
sal_Bool SAL_CALL findLocaleForTextCodePage( );
diff --git a/dtrans/source/win32/dtobj/FmtFilter.cxx b/dtrans/source/win32/dtobj/FmtFilter.cxx
index 6c809d80583a..de2f195f6ebe 100644
--- a/dtrans/source/win32/dtobj/FmtFilter.cxx
+++ b/dtrans/source/win32/dtobj/FmtFilter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FmtFilter.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: ka $ $Date: 2001-03-16 12:57:31 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,11 +71,13 @@
#include <osl/diagnose.h>
#endif
+
//------------------------------------------------------------------------
// namespace directives
//------------------------------------------------------------------------
using namespace com::sun::star::uno;
+using rtl::OString;
//------------------------------------------------------------------------
// implementation
@@ -237,4 +239,101 @@ Sequence< sal_Int8 > SAL_CALL OOBmpToWinDIB( Sequence< sal_Int8 >& aOOBmp )
aOOBmp.getLength( ) - sizeof( BITMAPFILEHEADER ) );
return winDIBStream;
-} \ No newline at end of file
+}
+
+//------------------------------------------------------------------------------
+// converts the openoffice text/html clipboard format to the HTML Format
+// well known under MS Windows
+// the MS HTML Format has a header before the real html data
+//
+// Version:1.0 Version number of the clipboard. Staring is 0.9
+// StartHTML: Byte count from the beginning of the clipboard to the start
+// of the context, or -1 if no context
+// EndHTML: Byte count from the beginning of the clipboard to the end
+// of the context, or -1 if no context
+// StartFragment: Byte count from the beginning of the clipboard to the
+// start of the fragment
+// EndFragment: Byte count from the beginning of the clipboard to the
+// end of the fragment
+// StartSelection: Byte count from the beginning of the clipboard to the
+// start of the selection
+// EndSelection: Byte count from the beginning of the clipboard to the
+// end of the selection
+//
+// StartSelection and EndSelection are optional
+// The fragment should be preceded and followed by the HTML comments
+// <!--StartFragment--> and <!--EndFragment--> (no space between !-- and the
+// text
+//------------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL TextHtmlToHTMLFormat( Sequence< sal_Int8 >& aTextHtml )
+{
+ OSL_ASSERT( aTextHtml.getLength( ) > 0 );
+
+ // check parameter
+ if ( !(aTextHtml.getLength( ) > 0) )
+ return Sequence< sal_Int8 >( );
+
+ // we create a buffer with the approximated size of
+ // the HTML Format header
+ char aHTMLFmtHdr[120];
+
+ rtl_zeroMemory( aHTMLFmtHdr, sizeof( aHTMLFmtHdr ) );
+
+ // fill the buffer with dummy values to calc the
+ // exact length
+ wsprintf(
+ aHTMLFmtHdr,
+ "Version:1.0\nStartHTML:%010d\nEndHTML:%010d\nStartFragment:%010d\nEndFragment:%010d\n", 0, 0, 0, 0 );
+
+ sal_uInt32 lHTMLFmtHdr = rtl_str_getLength( aHTMLFmtHdr );
+
+ OString startHtmlTag( "<HTML>" );
+ OString endHtmlTag( "</HTML>" );
+ OString startBodyTag( "<BODY>" );
+ OString endBodyTag( "</BODY" );
+
+ OString textHtml(
+ reinterpret_cast< const sal_Char* >( aTextHtml.getConstArray( ) ),
+ aTextHtml.getLength( ) );
+
+ sal_Int32 nStartHtml = textHtml.search( startHtmlTag );
+ sal_Int32 nEndHtml = textHtml.search( endHtmlTag );
+ sal_Int32 nStartFrgmt = textHtml.search( startBodyTag );
+ sal_Int32 nEndFrgmt = textHtml.search( endBodyTag );
+
+ Sequence< sal_Int8 > aHTMLFmtSequence;
+
+ if ( (nStartHtml > -1) && (nEndHtml > -1) && (nStartFrgmt > -1) && (nEndFrgmt > -1) )
+ {
+ nStartHtml = nStartHtml + lHTMLFmtHdr - 1; // we start one before <HTML> Word 2000 does also so
+ nEndHtml = nEndHtml + lHTMLFmtHdr + endHtmlTag.getLength( ) + 1; // our SOffice 5.2 wants 2 behind </HTML>?
+ nStartFrgmt = nStartFrgmt + startBodyTag.getLength( ) + lHTMLFmtHdr; // after the <BODY> tag
+ nEndFrgmt = nEndFrgmt + lHTMLFmtHdr;
+
+ // fill the html header
+ rtl_zeroMemory( aHTMLFmtHdr, sizeof( aHTMLFmtHdr ) );
+
+ wsprintf(
+ aHTMLFmtHdr,
+ "Version:1.0\nStartHTML:%010d\nEndHTML:%010d\nStartFragment:%010d\nEndFragment:%010d\n",
+ nStartHtml, nEndHtml, nStartFrgmt, nEndFrgmt );
+
+ // we add space for a trailing \0
+ aHTMLFmtSequence.realloc( lHTMLFmtHdr + aTextHtml.getLength( ) + 1 );
+ rtl_zeroMemory( aHTMLFmtSequence.getArray( ), aHTMLFmtSequence.getLength( ) );
+
+ // copy the HTML Format header
+ rtl_copyMemory(
+ static_cast< LPVOID >( aHTMLFmtSequence.getArray( ) ),
+ static_cast< LPVOID >( aHTMLFmtHdr ), lHTMLFmtHdr );
+
+ // concat the text/html
+ rtl_copyMemory(
+ static_cast< LPVOID >( aHTMLFmtSequence.getArray( ) + lHTMLFmtHdr ),
+ static_cast< LPVOID >( aTextHtml.getArray( ) ),
+ aTextHtml.getLength( ) );
+ }
+
+ return aHTMLFmtSequence;
+}
diff --git a/dtrans/source/win32/dtobj/FmtFilter.hxx b/dtrans/source/win32/dtobj/FmtFilter.hxx
index 73f76a551d23..cc39c83d2561 100644
--- a/dtrans/source/win32/dtobj/FmtFilter.hxx
+++ b/dtrans/source/win32/dtobj/FmtFilter.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FmtFilter.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: ka $ $Date: 2001-03-16 12:58:01 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,4 +99,13 @@ com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL WinDIBToOOBMP( const com::sun
------------------------------------------------------------------------*/
com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL OOBmpToWinDIB( com::sun::star::uno::Sequence< sal_Int8 >& aOOBmp );
+/*------------------------------------------------------------------------
+ input:
+ aTextHtml - a sequence of text/html which will be converted to the
+ HTML Format; the HTML Format has header before the real html data
+ the Format is described in the MSDN Library under HTML Clipboard
+ Format
+------------------------------------------------------------------------*/
+com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL TextHtmlToHTMLFormat( com::sun::star::uno::Sequence< sal_Int8 >& aTextHtml );
+
#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dtobj/TxtCnvtHlp.cxx b/dtrans/source/win32/dtobj/TxtCnvtHlp.cxx
index 6e3137bab979..697158947494 100644
--- a/dtrans/source/win32/dtobj/TxtCnvtHlp.cxx
+++ b/dtrans/source/win32/dtobj/TxtCnvtHlp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TxtCnvtHlp.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:54:52 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,7 +86,6 @@ using namespace ::com::sun::star::uno;
// assuming a '\0' terminated string if no length specified
//------------------------------------------------------------------
-inline
int CalcBuffSizeForTextConversion( LPCSTR lpMultiByteString, int nLen = -1 )
{
return ( MultiByteToWideChar( CP_ACP,
@@ -101,7 +100,6 @@ int CalcBuffSizeForTextConversion( LPCSTR lpMultiByteString, int nLen = -1 )
// assuming a '\0' terminated string if no length specified
//------------------------------------------------------------------
-inline
int CalcBuffSizeForTextConversion( LPCWSTR lpWideCharString, int nLen = -1 )
{
return WideCharToMultiByte( CP_ACP,
@@ -120,7 +118,9 @@ int CalcBuffSizeForTextConversion( LPCWSTR lpWideCharString, int nLen = -1 )
// the buffer
//------------------------------------------------------------------
-int MultiByteToWideCharEx( UINT cp_src, LPCSTR lpMultiByteString,
+int MultiByteToWideCharEx( UINT cp_src,
+ LPCSTR lpMultiByteString,
+ sal_uInt32 lenStr,
CStgTransferHelper& refDTransHelper,
BOOL bEnsureTrailingZero )
{
@@ -128,7 +128,7 @@ int MultiByteToWideCharEx( UINT cp_src, LPCSTR lpMultiByteString,
OSL_ASSERT( NULL != lpMultiByteString );
// calculate the required buff size
- int reqSize = CalcBuffSizeForTextConversion( lpMultiByteString );
+ int reqSize = CalcBuffSizeForTextConversion( lpMultiByteString, lenStr );
if ( bEnsureTrailingZero )
reqSize += sizeof( sal_Unicode );
@@ -143,7 +143,7 @@ int MultiByteToWideCharEx( UINT cp_src, LPCSTR lpMultiByteString,
return MultiByteToWideChar( cp_src,
0,
lpMultiByteString,
- -1,
+ lenStr,
static_cast< LPWSTR >( ptrHGlob.GetMemPtr( ) ),
ptrHGlob.MemSize( ) );
}
@@ -154,7 +154,9 @@ int MultiByteToWideCharEx( UINT cp_src, LPCSTR lpMultiByteString,
// the buffer
//------------------------------------------------------------------
-int WideCharToMultiByteEx( UINT cp_dest, LPCWSTR lpWideCharString,
+int WideCharToMultiByteEx( UINT cp_dest,
+ LPCWSTR lpWideCharString,
+ sal_uInt32 lenStr,
CStgTransferHelper& refDTransHelper,
BOOL bEnsureTrailingZero )
{
@@ -162,7 +164,7 @@ int WideCharToMultiByteEx( UINT cp_dest, LPCWSTR lpWideCharString,
OSL_ASSERT( NULL != lpWideCharString );
// calculate the required buff size
- int reqSize = CalcBuffSizeForTextConversion( lpWideCharString );
+ int reqSize = CalcBuffSizeForTextConversion( lpWideCharString, lenStr );
if ( bEnsureTrailingZero )
reqSize += sizeof( sal_Int8 );
@@ -177,46 +179,10 @@ int WideCharToMultiByteEx( UINT cp_dest, LPCWSTR lpWideCharString,
return WideCharToMultiByte( cp_dest,
0,
lpWideCharString,
- -1,
+ lenStr,
static_cast< LPSTR >( ptrHGlob.GetMemPtr( ) ),
ptrHGlob.MemSize( ),
NULL,
NULL );
}
-//------------------------------------------------------------------
-// iterates through a sequence of dataflavors in order to find
-// the first non unicode character set
-//------------------------------------------------------------------
-/*
-BOOL FindFirstTextDataFlavor( const Sequence< DataFlavor >& dflvList, DataFlavor& aTxtDFlv )
-{
- sal_Int32 nDFlv = dflvList.getLength( );
- sal_Bool bRet = sal_False;
-
- for ( sal_Int32 i = 0; i < nDFlv; ++i )
- {
- if ( MimeIsTextPlainAnyCharset( dflvList[i].MimeType ) )
- {
- aTxtDFlv = dflvList[i];
- bRet = sal_True;
- break;
- }
- }
-
- return bRet;
-}
-
-//------------------------------------------------------------------
-// given a list of dataflavors this function searches for the
-// best dataflavor used to be converted into the destination
-// dataflavor
-//------------------------------------------------------------------
-
-BOOL FindBestDataFlavorForTextConversion( const DataFlavor& destDFlv,
- const Sequence< DataFlavor >& suppDFlv,
- DataFlavor& bestDFlv )
-{
- return FindFirstTextDataFlavor( suppDFlv, bestDFlv );
-}
-*/ \ No newline at end of file
diff --git a/dtrans/source/win32/dtobj/TxtCnvtHlp.hxx b/dtrans/source/win32/dtobj/TxtCnvtHlp.hxx
index 04bebc691420..49962a3dec4d 100644
--- a/dtrans/source/win32/dtobj/TxtCnvtHlp.hxx
+++ b/dtrans/source/win32/dtobj/TxtCnvtHlp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TxtCnvtHlp.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-02-27 07:54:44 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,14 +81,16 @@
// deklarations
//------------------------------------------------------------------------
-int MultiByteToWideCharEx( UINT cp_src, LPCSTR lpMultiByteString, CStgTransferHelper& refDTransHelper, BOOL bEnsureTrailingZero = TRUE );
-int WideCharToMultiByteEx( UINT cp_dest, LPCWSTR lpWideCharString, CStgTransferHelper& refDTransHelper, BOOL bEnsureTrailingZero = TRUE );
+int MultiByteToWideCharEx( UINT cp_src,
+ LPCSTR lpMultiByteString,
+ sal_uInt32 lenStr,
+ CStgTransferHelper& refDTransHelper,
+ BOOL bEnsureTrailingZero = TRUE );
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-BOOL FindBestDataFlavorForTextConversion( const ::com::sun::star::datatransfer::DataFlavor& dfDest,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& seqSupportedDF,
- ::com::sun::star::datatransfer::DataFlavor& bestDF );
+int WideCharToMultiByteEx( UINT cp_dest,
+ LPCWSTR lpWideCharString,
+ sal_uInt32 lenStr,
+ CStgTransferHelper& refDTransHelper,
+ BOOL bEnsureTrailingZero = TRUE );
#endif \ No newline at end of file
diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx
index f61ac0a0a3d7..d96949ed19cb 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.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: tra $ $Date: 2001-03-19 13:02:38 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -210,9 +210,8 @@ STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium
{
HRESULT hr = DV_E_FORMATETC;
- if ( isSynthesizeableFormat( pFormatetc ) )
- hr = renderSynthesizedFormatAndSetupStgMedium(
- *pFormatetc, *pmedium );
+ if ( m_FormatRegistrar.isSynthesizeableFormat( *pFormatetc ) )
+ hr = renderSynthesizedFormatAndSetupStgMedium( *pFormatetc, *pmedium );
return hr;
}
@@ -232,36 +231,6 @@ STDMETHODIMP CXTDataObject::GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium
return S_OK;
}
-/*
- FORMATETC fetc;
-
- synthesize format
- if ( requested format is unicodetext ) // implies the transferable has really only text
- {
- fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_TEXT );
- aFlavor = formatEtcToDataFlavor( fetc );
-
- get transfer data
- convert transfer data to unicode text
- transfer result to storage
- }
- else // implies the transferable has really only unicodetext
- {
- fetc = m_DataFormatTranslator.getFormatEtcForClipformat( CF_UNICODETEXT );
- aFlavor = formatEtcToDataFlavor( fetc );
-
- get transfer data
- if ( request is for ansi text )
- convert transfer data to text using the CP_ACP
- else
- convert transfer data to oemtext using CP_OEMCP
-
- transfer result to storage
- }
-
- transfer data to storage
-*/
-
//------------------------------------------------------------------------
//
//------------------------------------------------------------------------
@@ -372,7 +341,7 @@ void SAL_CALL CXTDataObject::renderAnyDataAndSetupStgMedium(
aAny >>= clipDataStream;
sal_uInt32 nRequiredMemSize = 0;
- if ( isOemOrAnsiTextFormat( fetc.cfFormat ) )
+ if ( m_DataFormatTranslator.isOemOrAnsiTextFormat( fetc.cfFormat ) )
nRequiredMemSize = sizeof( sal_Int8 ) * clipDataStream.getLength( ) + 1;
// prepare data for transmision
@@ -417,7 +386,7 @@ HRESULT SAL_CALL CXTDataObject::renderSynthesizedFormatAndSetupStgMedium( FORMAT
if ( CF_UNICODETEXT == fetc.cfFormat )
// the transferable seems to have only text
renderSynthesizedUnicodeAndSetupStgMedium( fetc, stgmedium );
- else if ( isOemOrAnsiTextFormat( fetc.cfFormat ) )
+ else if ( m_DataFormatTranslator.isOemOrAnsiTextFormat( fetc.cfFormat ) )
// the transferable seems to have only unicode text
renderSynthesizedTextAndSetupStgMedium( fetc, stgmedium );
else
@@ -428,7 +397,7 @@ HRESULT SAL_CALL CXTDataObject::renderSynthesizedFormatAndSetupStgMedium( FORMAT
{
hr = DV_E_FORMATETC;
}
- catch( CInvalidFormatEtcException& ex )
+ catch( CInvalidFormatEtcException& )
{
OSL_ENSURE( sal_False, "Unexpected exception" );
}
@@ -445,25 +414,52 @@ HRESULT SAL_CALL CXTDataObject::renderSynthesizedFormatAndSetupStgMedium( FORMAT
}
//------------------------------------------------------------------------
-//
+// the transferable must have only text, so we will synthesize unicode text
//------------------------------------------------------------------------
void SAL_CALL CXTDataObject::renderSynthesizedUnicodeAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium )
{
OSL_ASSERT( CF_UNICODETEXT == fetc.cfFormat );
- //m_FormatRegistrar.getRegisteredTextCodePage( );
+ Any aAny = m_XTransferable->getTransferData( m_FormatRegistrar.getRegisteredTextFlavor( ) );
+ Sequence< sal_Int8 > aText;
+ aAny >>= aText;
+
+ CStgTransferHelper stgTransfHelper;
+
+ MultiByteToWideCharEx(
+ m_FormatRegistrar.getRegisteredTextCodePage( ),
+ reinterpret_cast< char* >( aText.getArray( ) ),
+ aText.getLength( ),
+ stgTransfHelper );
+ setupStgMedium( fetc, stgTransfHelper, stgmedium );
}
//------------------------------------------------------------------------
-//
+// the transferable must have only unicode text so we will sythesize text
//------------------------------------------------------------------------
void SAL_CALL CXTDataObject::renderSynthesizedTextAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium )
{
- OSL_ASSERT( isOemOrAnsiTextFormat( fetc.cfFormat ) );
+ OSL_ASSERT( m_DataFormatTranslator.isOemOrAnsiTextFormat( fetc.cfFormat ) );
+
+ DataFlavor aFlavor = formatEtcToDataFlavor(
+ m_DataFormatTranslator.getFormatEtcForClipformat( CF_UNICODETEXT ) );
+ Any aAny = m_XTransferable->getTransferData( aFlavor );
+ OUString aUnicodeText;
+ aAny >>= aUnicodeText;
+
+ CStgTransferHelper stgTransfHelper;
+
+ WideCharToMultiByteEx(
+ GetACP( ),
+ static_cast< const sal_Unicode* >( aUnicodeText.getStr( ) ),
+ aUnicodeText.getLength( ),
+ stgTransfHelper );
+
+ setupStgMedium( fetc, stgTransfHelper, stgmedium );
}
//------------------------------------------------------------------------
@@ -472,7 +468,29 @@ void SAL_CALL CXTDataObject::renderSynthesizedTextAndSetupStgMedium( FORMATETC&
void SAL_CALL CXTDataObject::renderSynthesizedHtmlAndSetupStgMedium( FORMATETC& fetc, STGMEDIUM& stgmedium )
{
+ OSL_ASSERT( m_DataFormatTranslator.isHTMLFormat( fetc.cfFormat ) );
+
+ DataFlavor aFlavor;
+ // creating a DataFlavor on the fly
+ aFlavor.MimeType = OUString::createFromAscii( "text/html" );
+ aFlavor.DataType = getCppuType( (Sequence< sal_Int8 >*)0 );
+
+ Any aAny = m_XTransferable->getTransferData( aFlavor );
+
+ Sequence< sal_Int8 > aTextHtmlSequence;
+ aAny >>= aTextHtmlSequence;
+
+ Sequence< sal_Int8 > aHTMLFormatSequence = TextHtmlToHTMLFormat( aTextHtmlSequence );
+
+ sal_uInt32 nBytesToTransfer = aHTMLFormatSequence.getLength( );
+
+ renderDataAndSetupStgMedium(
+ reinterpret_cast< const sal_Int8* >( aHTMLFormatSequence.getArray( ) ),
+ fetc,
+ 0,
+ nBytesToTransfer,
+ stgmedium );
}
//------------------------------------------------------------------------
@@ -600,17 +618,6 @@ DataFlavor SAL_CALL CXTDataObject::formatEtcToDataFlavor( const FORMATETC& aForm
//
//------------------------------------------------------------------------
-sal_Bool SAL_CALL CXTDataObject::isSynthesizeableFormat( LPFORMATETC lpFormatEtc ) const
-{
- return ( (lpFormatEtc->cfFormat == CF_TEXT) ||
- (lpFormatEtc->cfFormat == CF_OEMTEXT) ||
- (lpFormatEtc->cfFormat == CF_UNICODETEXT) );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
inline
void CXTDataObject::validateFormatEtc( LPFORMATETC lpFormatEtc ) const
{
@@ -690,16 +697,6 @@ void SAL_CALL CXTDataObject::invalidateStgMedium( STGMEDIUM& stgmedium ) const
//------------------------------------------------------------------------
inline
-sal_Bool SAL_CALL CXTDataObject::isOemOrAnsiTextFormat( const CLIPFORMAT& aClipformat ) const
-{
- return ( (aClipformat == CF_TEXT) || (aClipformat == CF_OEMTEXT) );
-}
-
-//------------------------------------------------------------------------
-//
-//------------------------------------------------------------------------
-
-inline
HRESULT SAL_CALL CXTDataObject::translateStgExceptionCode( HRESULT hr ) const
{
HRESULT hrTransl;
diff --git a/dtrans/source/win32/dtobj/XTDataObject.hxx b/dtrans/source/win32/dtobj/XTDataObject.hxx
index 409b68159057..e6fc161724fc 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.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tra $ $Date: 2001-03-19 13:02:38 $
+ * last change: $Author: tra $ $Date: 2001-03-20 09:26:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -141,7 +141,6 @@ public:
private:
void validateFormatEtc( LPFORMATETC lpFormatEtc ) const;
com::sun::star::datatransfer::DataFlavor SAL_CALL formatEtcToDataFlavor( const FORMATETC& aFormatEtc ) const;
- sal_Bool SAL_CALL isSynthesizeableFormat( LPFORMATETC lpFormatEtc ) const;
void SAL_CALL renderDataAndSetupStgMedium( const sal_Int8* lpStorage,
const FORMATETC& fetc,
sal_uInt32 nInitStgSize,
@@ -163,7 +162,6 @@ private:
void SAL_CALL invalidateStgMedium( STGMEDIUM& stgmedium ) const;
- sal_Bool SAL_CALL isOemOrAnsiTextFormat( const CLIPFORMAT& aClipformat ) const;
HRESULT SAL_CALL translateStgExceptionCode( HRESULT hr ) const;
private: