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.
27 #include <svl/svdde.hxx>
28 #include <o3tl/char16_t2wchar_t.hxx>
30 #include <osl/thread.h>
31 #include <sot/exchange.hxx>
35 xImp
.reset(new DdeDataImp
);
36 xImp
->hData
= nullptr;
38 xImp
->pData
= nullptr;
39 xImp
->nFmt
= SotClipboardFormatId::STRING
;
42 DdeData::DdeData(const void* p
, tools::Long n
, SotClipboardFormatId f
)
44 xImp
.reset(new DdeDataImp
);
45 xImp
->hData
= nullptr;
51 DdeData::DdeData( const OUString
& s
)
53 xImp
.reset(new DdeDataImp
);
54 xImp
->hData
= nullptr;
55 xImp
->pData
= s
.getStr();
56 xImp
->nData
= s
.getLength()+1;
57 xImp
->nFmt
= SotClipboardFormatId::STRING
;
60 DdeData::DdeData(const DdeData
& rData
)
62 xImp
.reset(new DdeDataImp
);
63 xImp
->hData
= rData
.xImp
->hData
;
64 xImp
->nData
= rData
.xImp
->nData
;
65 xImp
->pData
= rData
.xImp
->pData
;
66 xImp
->nFmt
= rData
.xImp
->nFmt
;
70 DdeData::DdeData(DdeData
&& rData
) noexcept
71 : xImp(std::move(rData
.xImp
))
77 if (xImp
&& xImp
->hData
)
78 DdeUnaccessData(xImp
->hData
);
84 xImp
->pData
= DdeAccessData(xImp
->hData
, &xImp
->nData
);
87 SotClipboardFormatId
DdeData::GetFormat() const
92 void DdeData::SetFormat(SotClipboardFormatId nFmt
)
97 void const * DdeData::getData() const
102 tools::Long
DdeData::getSize() const
107 DdeData
& DdeData::operator=(const DdeData
& rData
)
109 if ( &rData
!= this )
112 xImp
= std::move(tmp
.xImp
);
118 DdeData
& DdeData::operator=(DdeData
&& rData
) noexcept
120 xImp
= std::move(rData
.xImp
);
124 sal_uInt32
DdeData::GetExternalFormat(SotClipboardFormatId nFmt
)
128 case SotClipboardFormatId::STRING
:
130 case SotClipboardFormatId::BITMAP
:
132 case SotClipboardFormatId::GDIMETAFILE
:
133 return CF_METAFILEPICT
;
136 OUString
aName( SotExchange::GetFormatName( nFmt
) );
137 if( !aName
.isEmpty() )
138 return RegisterClipboardFormatW( o3tl::toW(aName
.getStr()) );
141 return static_cast<sal_uInt32
>(nFmt
);
144 SotClipboardFormatId
DdeData::GetInternalFormat(sal_uLong nFmt
)
149 return SotClipboardFormatId::STRING
;
151 return SotClipboardFormatId::BITMAP
;
152 case CF_METAFILEPICT
:
153 return SotClipboardFormatId::GDIMETAFILE
;
159 if(GetClipboardFormatNameW( nFmt
, szName
, SAL_N_ELEMENTS(szName
) ))
160 return SotExchange::RegisterFormatName( OUString(o3tl::toU(szName
)) );
164 return static_cast<SotClipboardFormatId
>(nFmt
);
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */