1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ddedata.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 // ACHTUNG: es wird angenommen, dass StarView-Clipboard-Foamatnummern
35 // und Windows-Formatnummern identisch sind! Ist dies einmal nicht der
36 // Fall, muessen die Routinen hier angepasst werden. Die Implementation
37 // verwendet die hier defineirten Konversionen.
43 #include <svtools/svdde.hxx>
45 #include <osl/thread.h>
47 #if defined( WIN ) && defined( MSC )
48 #pragma code_seg( "SVDDE_MISC_CODE" )
51 // --- DdeData::DdeData() ------------------------------------------
55 pImp
= new DdeDataImp
;
62 // --- DdeData::DdeData() ------------------------------------------
64 DdeData::DdeData( const void* p
, long n
, ULONG f
)
66 pImp
= new DdeDataImp
;
68 pImp
->pData
= (LPBYTE
)p
;
73 // --- DdeData::DdeData() ------------------------------------------
75 DdeData::DdeData( const String
& s
)
77 pImp
= new DdeDataImp
;
79 pImp
->pData
= (LPBYTE
)s
.GetBuffer();
80 pImp
->nData
= s
.Len()+1;
84 // --- DdeData::DdeData() ------------------------------------------
86 DdeData::DdeData( const DdeData
& rData
)
88 pImp
= new DdeDataImp
;
89 pImp
->hData
= rData
.pImp
->hData
;
90 pImp
->nData
= rData
.pImp
->nData
;
91 pImp
->pData
= rData
.pImp
->pData
;
92 pImp
->nFmt
= rData
.pImp
->nFmt
;
96 // --- DdeData::~DdeData() -----------------------------------------
100 if ( pImp
&& pImp
->hData
)
101 DdeUnaccessData( pImp
->hData
);
105 // --- DdeData::Lock() ---------------------------------------------
110 pImp
->pData
= DdeAccessData( pImp
->hData
, (LPDWORD
) &pImp
->nData
);
113 // --- DdeData::GetFormat() ----------------------------------------
115 ULONG
DdeData::GetFormat() const
120 void DdeData::SetFormat( ULONG nFmt
)
125 // --- DdeData::operator const char*() -----------------------------
127 DdeData::operator const void*() const
132 // --- DdeData::operator long() ------------------------------------
134 DdeData::operator long() const
139 // --- DdeData::operator =() ---------------------------------------
141 DdeData
& DdeData::operator = ( const DdeData
& rData
)
143 if ( &rData
!= this )
145 DdeData
tmp( rData
);
154 ULONG
DdeData::GetExternalFormat( ULONG nFmt
)
164 case FORMAT_GDIMETAFILE
:
165 nFmt
= CF_METAFILEPICT
;
170 #if defined(WNT) || defined(WIN) || defined( PM2 )
171 String
aName( SotExchange::GetFormatName( nFmt
) );
173 #if defined(WNT) || defined(WIN)
176 nFmt
= RegisterClipboardFormat( reinterpret_cast<LPCWSTR
>(aName
.GetBuffer()) );
182 HATOMTBL hSysTable
= WinQuerySystemAtomTable();
183 nFmt
= (ULONG
)WinAddAtom( hSysTable
, (PSZ
)aName
.GetBuffer() );
192 ULONG
DdeData::GetInternalFormat( ULONG nFmt
)
197 nFmt
= FORMAT_STRING
;
201 nFmt
= FORMAT_BITMAP
;
204 case CF_METAFILEPICT
:
205 nFmt
= FORMAT_GDIMETAFILE
;
209 #if defined(WIN) || defined(WNT)
214 if( GetClipboardFormatName( nFmt
, szName
, sizeof(szName
) ) )
215 nFmt
= SotExchange::RegisterFormatName( String(reinterpret_cast<const sal_Unicode
*>(szName
)) );
219 if( nFmt
> CF_PALETTE
)
223 HATOMTBL hSysTable
= WinQuerySystemAtomTable();
224 WinQueryAtomName( hSysTable
, (ATOM
)nFmt
, (PSZ
)szName
,
226 nFmt
= SotExchange::RegisterFormatName( String( szName
) );