1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 // ATTENTION: We assume StarView Clipboard format numbers and Windows
22 // Format numbers to be the same! If that's not the case, we need to
23 // adapt the code here. The implementation uses the conversions here.
29 #include <svl/svdde.hxx>
31 #include <osl/thread.h>
35 pImp
= new DdeDataImp
;
39 pImp
->nFmt
= SotClipboardFormatId::STRING
;
42 DdeData::DdeData(const void* p
, long n
, SotClipboardFormatId f
)
44 pImp
= new DdeDataImp
;
46 pImp
->pData
= (LPBYTE
)p
;
51 DdeData::DdeData( const OUString
& s
)
53 pImp
= new DdeDataImp
;
55 pImp
->pData
= (LPBYTE
)s
.getStr();
56 pImp
->nData
= s
.getLength()+1;
57 pImp
->nFmt
= SotClipboardFormatId::STRING
;
60 DdeData::DdeData( const DdeData
& rData
)
62 pImp
= new DdeDataImp
;
63 pImp
->hData
= rData
.pImp
->hData
;
64 pImp
->nData
= rData
.pImp
->nData
;
65 pImp
->pData
= rData
.pImp
->pData
;
66 pImp
->nFmt
= rData
.pImp
->nFmt
;
72 if ( pImp
&& pImp
->hData
)
73 DdeUnaccessData( pImp
->hData
);
80 pImp
->pData
= DdeAccessData( pImp
->hData
, (LPDWORD
) &pImp
->nData
);
83 SotClipboardFormatId
DdeData::GetFormat() const
88 void DdeData::SetFormat(SotClipboardFormatId nFmt
)
93 DdeData::operator const void*() const
98 DdeData::operator long() const
103 DdeData
& DdeData::operator = ( const DdeData
& rData
)
105 if ( &rData
!= this )
107 DdeData
tmp( rData
);
116 sal_uLong
DdeData::GetExternalFormat(SotClipboardFormatId nFmt
)
120 case SotClipboardFormatId::STRING
:
122 case SotClipboardFormatId::BITMAP
:
124 case SotClipboardFormatId::GDIMETAFILE
:
125 return CF_METAFILEPICT
;
129 OUString
aName( SotExchange::GetFormatName( nFmt
) );
130 if( !aName
.isEmpty() )
131 return RegisterClipboardFormat( reinterpret_cast<LPCWSTR
>(aName
.getStr()) );
135 return static_cast<sal_uLong
>(nFmt
);
138 SotClipboardFormatId
DdeData::GetInternalFormat(sal_uLong nFmt
)
143 return SotClipboardFormatId::STRING
;
145 return SotClipboardFormatId::BITMAP
;
146 case CF_METAFILEPICT
:
147 return SotClipboardFormatId::GDIMETAFILE
;
154 if(GetClipboardFormatName( nFmt
, szName
, sizeof(szName
) ))
155 return SotExchange::RegisterFormatName( OUString(reinterpret_cast<const sal_Unicode
*>(szName
)) );
160 return static_cast<SotClipboardFormatId
>(nFmt
);
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */