24#include <rtl/ustring.hxx>
26#include <osl/thread.h>
49 UINT nCode, UINT nCbType, HCONV hConv, HSZ hText1, HSZ hText2,
50 HDDEDATA hData, ULONG_PTR, ULONG_PTR )
57 case XTYP_WILDCONNECT:
59 std::vector<HSZPAIR> aPairs;
61 WCHAR chTopicBuf[256];
63 DdeQueryStringW( pInst->
hDdeInstSvr, hText1, chTopicBuf,
68 if (hText2 && !(*pService->pName == hText2))
71 OUString sTopics(pService->Topics().replaceAll(
"\n",
"").replaceAll(
"\r",
""));
72 if (sTopics.isEmpty())
75 for (sal_Int32
n = 0; -1 !=
n;)
77 OUString s(sTopics.getToken(0,
'\t',
n));
78 if (hText1 && s != o3tl::toU(chTopicBuf))
84 auto& pair = aPairs.emplace_back();
85 pair.hszSvc = pService->pName->getHSZ();
86 pair.hszTopic = pTopic->pName->getHSZ();
93 aPairs.emplace_back();
95 HDDEDATA
h = DdeCreateDataHandle(
97 reinterpret_cast<LPBYTE
>(aPairs.data()),
98 sizeof(HSZPAIR) * aPairs.size(),
99 0,
nullptr, nCbType, 0);
106 return reinterpret_cast<HDDEDATA
>(DDE_FACK);
109 case XTYP_CONNECT_CONFIRM:
112 if (
auto pTopic =
FindTopic(*pService, hText1))
117 pService->m_vConv.emplace_back( pC );
127 for (
size_t i = 0,
n = rpService->m_vConv.size();
i <
n; ++
i )
129 pC = rpService->m_vConv[
i ].get();
130 if ( pC->
hConv == hConv )
131 pService = rpService;
136 return reinterpret_cast<HDDEDATA
>(DDE_FNOTPROCESSED);
139 if ( nCode == XTYP_DISCONNECT)
142 auto it = std::find_if(pService->
m_vConv.begin(), pService->
m_vConv.end(),
143 [&pC](
const std::unique_ptr<Conversation>& rxConv) { return rxConv.get() == pC; });
144 if (it != pService->
m_vConv.end())
149 bool bExec = nCode == XTYP_EXECUTE;
152 if (pTopic && !bExec && pService->
HasCbFormat(nCbType))
153 pItem =
FindItem( *pTopic, hText2 );
157 if ( !pItem && !bExec )
158 return static_cast<HDDEDATA
>(DDE_FNOTPROCESSED);
162 pTopic->
aItem.clear();
174 if ( pTopic->
aItem == SZDDESYS_ITEM_TOPICS )
175 aRes = pService->
Topics();
176 else if ( pTopic->
aItem == SZDDESYS_ITEM_SYSITEMS )
178 else if ( pTopic->
aItem == SZDDESYS_ITEM_STATUS )
179 aRes = pService->
Status();
180 else if ( pTopic->
aItem == SZDDESYS_ITEM_FORMATS )
182 else if ( pTopic->
aItem == SZDDESYS_ITEM_HELP )
187 if ( !aRes.isEmpty() )
192 else if( DDEGETPUTITEM == pItem->
nType )
204 static_cast<LPBYTE
>(
const_cast<void *
>(
pData->xImp->pData)),
218 d.xImp->hData = hData;
221 if( DDEGETPUTITEM == pItem->
nType )
224 bRes = pTopic->
Put( &
d );
227 return reinterpret_cast<HDDEDATA
>(DDE_FACK);
229 return reinterpret_cast<HDDEDATA
>(DDE_FNOTPROCESSED);
237 std::vector<DdeItem*>::iterator it(std::find(pTopic->
aItems.begin(),
240 if (it != pTopic->
aItems.end())
243 std::vector<DdeItem*>::iterator iter;
244 iter = std::find_if(pTopic->
aItems.begin(), pTopic->
aItems.end(),
245 [&hText2](
const DdeItem* pDdeItem) { return *pDdeItem->pName == hText2; });
246 if (iter != pTopic->
aItems.end())
255 pTopic->
aItems.push_back(pItem);
257 pItem = iter != pTopic->
aItems.end() ? *iter :
nullptr;
265 return reinterpret_cast<HDDEDATA
>(
TRUE);
269 return reinterpret_cast<HDDEDATA
>(
TRUE);
274 aExec.
xImp->hData = hData;
287 return reinterpret_cast<HDDEDATA
>(DDE_FACK);
289 return reinterpret_cast<HDDEDATA
>(DDE_FNOTPROCESSED);
298 auto aI = std::find_if(rSvc.begin(), rSvc.end(),
299 [&hService](
const DdeService* s) { return *s->pName == hService; });
300 if (aI != rSvc.end())
308 std::vector<DdeTopic*> &rTopics = rService.
aTopics;
310 auto iter = std::find_if(rTopics.begin(), rTopics.end(),
311 [&hTopic](
const DdeTopic* pTopic) { return *pTopic->pName == hTopic; });
312 if (iter != rTopics.end())
320 std::vector<DdeItem*>::iterator iter;
321 std::vector<DdeItem*> &rItems = rTopic.
aItems;
324 bool bContinue =
false;
328 iter = std::find_if(rItems.begin(), rItems.end(),
329 [&hItem](
const DdeItem* pItem) { return *pItem->pName == hItem; });
330 if (iter != rItems.end())
332 bContinue = !bContinue;
339 bContinue = rTopic.
MakeItem( OUString(o3tl::toU(chBuf)) );
357 nStatus = sal::static_int_cast< short >(
361 CBF_SKIP_REGISTRATIONS |
362 CBF_SKIP_UNREGISTRATIONS, 0 ) );
372 if (
nStatus == DMLERR_NO_ERROR )
375 DNS_REGISTER | DNS_FILTEROFF ) )
380 AddFormat( SotClipboardFormatId::STRING );
436 [&rTopic](
const DdeTopic* pTopic) { return DdeCmpStringHandles(pTopic->pName->getHSZ(), rTopic.pName->getHSZ()) == 0; });
445 if( pC->pTopic == &rTopic )
486 for (
auto& rpItem :
aItems)
488 rpItem->pMyTopic =
nullptr;
502 return GetName() == SZDDESYS_TOPIC;
508 if( DDEGETPUTITEM == r.
nType )
530 [&r](
const DdeItem* pItem) { return DdeCmpStringHandles(pItem->pName->getHSZ(), r.pName->getHSZ()) == 0; });
532 if ( iter !=
aItems.end() )
534 (*iter)->pMyTopic =
nullptr;
545 [&rItem](
const DdeItem* pItem) { return pItem->GetName().equals(rItem) && pItem->pImpData; });
552 for (
const auto& rpItem : rTopic.
aItems)
636 pItem->
pImpData =
new std::vector<DdeItemImpData>;
637 if (DDEGETPUTITEM == pItem->
nType)
646 if ((*pItem->
pImpData)[ --
n ].nHCnv == nHCnv)
661 for(
size_t n = 0;
n < pItem->
pImpData->size(); ++
n )
664 if(
pData->nHCnv == nHCnv )
676 if (DDEGETPUTITEM == pItem->
nType)
704 nType = DDEGETPUTITEM;
710 nType = DDEGETPUTITEM;
716 nType = DDEGETPUTITEM;
736 for (
const auto& rpTopic :
aTopics )
738 if ( rpTopic->GetName() == SZDDESYS_TOPIC )
741 for (
const auto& rpItem : rpTopic->aItems )
745 s += rpItem->GetName();
760 for (
const auto& rpTopic :
aTopics )
764 s += rpTopic->GetName();
SVL_DLLPRIVATE void Lock()
static SotClipboardFormatId GetInternalFormat(sal_uLong nFmt)
static sal_uInt32 GetExternalFormat(SotClipboardFormatId nFmt)
std::unique_ptr< DdeDataImp > xImp
virtual void AdviseLoop(bool)
DdeGetPutItem(const sal_Unicode *p)
virtual DdeData * Get(SotClipboardFormatId)
virtual bool Put(const DdeData *)
DdeServices * pServicesSvr
static HDDEDATA CALLBACK SvrCallback(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, ULONG_PTR, ULONG_PTR)
static void DecMonitor(DdeItem *pItem, HCONV)
static DdeTopic * FindTopic(DdeService &, HSZ)
static DdeService * FindService(HSZ)
static void DisconnectTopic(DdeTopic &, HCONV)
static void IncMonitor(DdeItem *pItem, HCONV)
static DdeItem * FindItem(DdeTopic &, HSZ)
std::vector< DdeItemImpData > * pImpData
DdeItem(const sal_Unicode *)
static DdeServices & GetServices()
std::vector< DdeTopic * > aTopics
void RemoveTopic(const DdeTopic &)
void AddFormat(SotClipboardFormatId)
void AddTopic(const DdeTopic &)
SVL_DLLPRIVATE bool HasCbFormat(sal_uInt32)
DdeService(SAL_UNUSED_PARAMETER const OUString &)
bool HasFormat(SotClipboardFormatId)
std::vector< std::unique_ptr< Conversation > > m_vConv
void RemoveFormat(SotClipboardFormatId)
std::vector< sal_uInt32 > aFormats
const OUString & toOUString() const
void NotifyClient(const OUString &)
virtual bool MakeItem(const OUString &rItem)
std::vector< DdeItem * > aItems
void RemoveItem(const DdeItem &)
virtual bool StartAdviseLoop()
DdeTopic(SAL_UNUSED_PARAMETER const OUString &)
virtual bool Put(const DdeData *)
virtual bool Execute(const OUString *)
DdeItem * AddItem(const DdeItem &)
virtual DdeData * Get(SotClipboardFormatId)
void InsertItem(DdeItem *)
DdeInstData * ImpInitInstData()
DdeInstData * ImpGetInstData()
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< sal_Int32[]> pData
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
::std::vector< DdeService * > DdeServices