svl: remove #include windows.h from svdde.hxx

Move Win32 stuff over to DdeInternal class where it can be better
encapsulated.

Change-Id: Ia3d4c72cf7ad1b7d54bef5d175c579cd426407e7
This commit is contained in:
Michael Stahl
2016-10-07 17:44:02 +02:00
parent ce650fc1cd
commit d211dafa9e
3 changed files with 35 additions and 39 deletions

View File

@@ -28,13 +28,6 @@
#include <tools/link.hxx> #include <tools/link.hxx>
#include <vector> #include <vector>
#if defined _WIN32
#include <prewin.h>
#include <windows.h>
#include <postwin.h>
#include <ddeml.h>
#endif
class DdeString; class DdeString;
class DdeData; class DdeData;
class DdeConnection; class DdeConnection;
@@ -213,11 +206,6 @@ class SVL_DLLPUBLIC DdeItem
DdeTopic* pMyTopic; DdeTopic* pMyTopic;
DdeItemImp* pImpData; DdeItemImp* pImpData;
#if defined _WIN32
void IncMonitor( HCONV );
void DecMonitor( HCONV );
#endif
protected: protected:
sal_uInt8 nType; sal_uInt8 nType;
@@ -248,9 +236,6 @@ public:
class SVL_DLLPUBLIC DdeTopic class SVL_DLLPUBLIC DdeTopic
{ {
#if defined _WIN32
SVL_DLLPRIVATE void Disconnect( HCONV );
#endif
public: public:
virtual DdeData* Get(SotClipboardFormatId); virtual DdeData* Get(SotClipboardFormatId);

View File

@@ -49,6 +49,9 @@ public:
static DdeService* FindService( HSZ ); static DdeService* FindService( HSZ );
static DdeTopic* FindTopic( DdeService&, HSZ ); static DdeTopic* FindTopic( DdeService&, HSZ );
static DdeItem* FindItem( DdeTopic&, HSZ ); static DdeItem* FindItem( DdeTopic&, HSZ );
static void DisconnectTopic(DdeTopic &, HCONV);
static void IncMonitor(DdeItem *pItem, HCONV);
static void DecMonitor(DdeItem *pItem, HCONV);
}; };

View File

@@ -194,7 +194,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
found: found:
if ( nCode == XTYP_DISCONNECT) if ( nCode == XTYP_DISCONNECT)
{ {
pC->pTopic->Disconnect( hConv ); DisconnectTopic(*pC->pTopic, hConv);
for ( ConvList::iterator it = pService->pConv->begin(); for ( ConvList::iterator it = pService->pConv->begin();
it != pService->pConv->end(); it != pService->pConv->end();
++it ++it
@@ -326,13 +326,13 @@ found:
if (pItem) if (pItem)
{ {
pItem->IncMonitor( hConv ); IncMonitor(pItem, hConv);
} }
} }
return (HDDEDATA)sal_True; return (HDDEDATA)sal_True;
case XTYP_ADVSTOP: case XTYP_ADVSTOP:
pItem->DecMonitor( hConv ); DecMonitor(pItem, hConv);
return (HDDEDATA)sal_True; return (HDDEDATA)sal_True;
case XTYP_EXECUTE: case XTYP_EXECUTE:
@@ -669,11 +669,13 @@ void DdeTopic::NotifyClient( const OUString& rItem )
} }
} }
void DdeTopic::Disconnect( HCONV nId ) void DdeInternal::DisconnectTopic(DdeTopic & rTopic, HCONV nId)
{ {
std::vector<DdeItem*>::iterator iter; std::vector<DdeItem*>::iterator iter;
for (iter = aItems.begin(); iter != aItems.end(); ++iter) for (iter = rTopic.aItems.begin(); iter != rTopic.aItems.end(); ++iter)
(*iter)->DecMonitor( nId ); {
DecMonitor(*iter, nId);
}
} }
DdeData* DdeTopic::Get(SotClipboardFormatId /*nFmt*/) DdeData* DdeTopic::Get(SotClipboardFormatId /*nFmt*/)
@@ -750,47 +752,53 @@ void DdeItem::NotifyClient()
} }
} }
void DdeItem::IncMonitor( HCONV nHCnv ) void DdeInternal::IncMonitor(DdeItem *const pItem, HCONV nHCnv)
{ {
if( !pImpData ) if (!pItem->pImpData)
{ {
pImpData = new DdeItemImp; pItem->pImpData = new DdeItemImp;
if( DDEGETPUTITEM == nType ) if (DDEGETPUTITEM == pItem->nType)
((DdeGetPutItem*)this)->AdviseLoop( true ); {
static_cast<DdeGetPutItem*>(pItem)->AdviseLoop( true );
}
} }
else else
{ {
for( sal_uInt16 n = pImpData->size(); n; ) for (size_t n = pItem->pImpData->size(); n; )
if( (*pImpData)[ --n ].nHCnv == nHCnv )
{ {
++(*pImpData)[ n ].nHCnv; if ((*pItem->pImpData)[ --n ].nHCnv == nHCnv)
{
++(*pItem->pImpData)[ n ].nHCnv;
return ; return ;
} }
} }
pImpData->push_back( DdeItemImpData( nHCnv ) );
} }
void DdeItem::DecMonitor( HCONV nHCnv ) pItem->pImpData->push_back( DdeItemImpData( nHCnv ) );
}
void DdeInternal::DecMonitor(DdeItem *const pItem, HCONV nHCnv)
{ {
if( pImpData ) if (pItem->pImpData)
{ {
for( sal_uInt16 n = 0; n < pImpData->size(); ++n ) for( sal_uInt16 n = 0; n < pItem->pImpData->size(); ++n )
{ {
DdeItemImpData* pData = &(*pImpData)[n]; DdeItemImpData* pData = &(*pItem->pImpData)[n];
if( pData->nHCnv == nHCnv ) if( pData->nHCnv == nHCnv )
{ {
if( !pData->nCnt || !--pData->nCnt ) if( !pData->nCnt || !--pData->nCnt )
{ {
if( 1 < pImpData->size() ) if (1 < pItem->pImpData->size())
{ {
pImpData->erase(pImpData->begin() + n); pItem->pImpData->erase(pItem->pImpData->begin() + n);
} }
else else
{ {
delete pImpData, pImpData = 0; delete pItem->pImpData, pItem->pImpData = 0;
if( DDEGETPUTITEM == nType ) if (DDEGETPUTITEM == pItem->nType)
((DdeGetPutItem*)this)->AdviseLoop( false ); {
static_cast<DdeGetPutItem*>(pItem)->AdviseLoop(false);
}
} }
} }
return ; return ;