#include "../../../Resources/GuiDocumentClipboard.h"
#include "WindowsClipboardService.h"
#include "WindowsImageService.h"
#include "../GDI/WinGDI.h"
namespace
{
namespace
{
namespace
{
using
namespace
parsing
::
xml
;
using
namespace
collections
;
bool
::
(
)
{
=
0
;
while
(
currentFormat
= ::
(
currentFormat
))
{
if
(
currentFormat
==
)
{
return
true
;
}
}
return
false
;
}
::
(
*
)
:service(
)
{
}
::
()
{
();
}
bool
::
()
{
return ContainsFormat(CF_UNICODETEXT);
}
::
()
{
;
HANDLE handle = ::GetClipboardData(CF_UNICODETEXT);
if
(
handle
!=
0
)
{
wchar_t
*
= (
wchar_t
*)::
(
handle
);
result
=
buffer
;
::
(
handle
);
}
return
result
;
}
bool
::
()
{
return
(
->
);
}
<
>
::
()
{
= ::
(
->
);
if
(
handle
!=
0
)
{
auto
= ::
(
handle
);
auto
= ::
(
handle
);
stream
::
(
buffer
, (
)
size
);
auto
=
LoadDocumentFromClipboardStream
(
memoryStream
);
::
(
handle
);
return
document
;
}
return
nullptr
;
}
bool
::
()
{
return ContainsFormat(CF_BITMAP);
}
<
>
::
()
{
HBITMAP handle = (HBITMAP)::GetClipboardData(CF_BITMAP);
if
(
handle
!=
0
)
{
return
(
handle
);
}
return
nullptr
;
}
void
::
()
{
if
(
->
)
{
::
();
->
=
nullptr
;
}
}
void
::
(
,
stream
::
&
)
{
.
(
0
);
HGLOBAL data = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)memoryStream.Size());
auto
= ::
(
data
);
.
(
buffer
, (
)
.
());
::
(
data
);
::
(
,
data
);
}
::
(
*
)
:service(
)
{
}
::
()
{
}
void
::
(
const
&
)
{
;
}
void
::
(
<
>
)
{
;
if
(!
)
{
(
true
);
}
if
(!
&&
.
() ==
1
)
{
<
>
=
0
];
while
(
container
)
{
if
(
container
.
() !=
1
)
goto
FAILED;
if
(
auto
=
container
0
].
<
>())
{
imageRun
;
break
;
}
else
{
container
container
0
].
<
>();
}
}
FAILED:;
}
ModifyDocumentForClipboard
(
);
}
void
::
(
<
>
)
{
;
}
bool
::
()
{
if
(
->
)
{
->
->
();
}
if
(!::
(
->
))
return
false
;
::
();
if
(
)
{
= (
.
().
() +
1
) *
sizeof
(
wchar_t
);
HGLOBAL data = ::GlobalAlloc(GMEM_MOVEABLE, size);
auto
= (
wchar_t
*)::
(
data
);
(
buffer
,
.
().
(),
size
);
::
(
data
);
::SetClipboardData(CF_UNICODETEXT, data);
}
if
(
)
{
{
stream
::
;
SaveDocumentToClipboardStream
(
,
memoryStream
);
(
->
,
memoryStream
);
}
{
stream
::
;
(
,
memoryStream
);
(
->
,
memoryStream
);
}
{
stream
::
;
SaveDocumentToHtmlClipboardStream
(
,
memoryStream
);
(
->
,
memoryStream
);
}
}
if
(
&&
()>
0
)
{
if
(
auto
=
(
(
0
)))
{
=
0
;
=
0
;
wicBitmap
->
(&
width
, &
height
);
auto
=
<
>((
)
width
, (
)
height
,
::
,
true
);
;
rect
.
=
0
;
rect
.
=
0
;
rect
.
= (
)
width
;
rect
.
= (
)
height
;
wicBitmap
->
(&
rect
, (
)
bitmap
(), (
)(
bitmap
()*
height
), (
*)
bitmap
()[
0
]);
stream
::
;
bitmap
(
memoryStream
,
true
);
SetClipboardData(CF_DIBV5, memoryStream);
}
}
::
();
return
true
;
}
class
WindowsFakeClipboardReader
:
public
,
public
{
public
:
bool
()
override
{
return
false
; }
()
override
{
return
L""
; }
bool
()
override
{
return
false
; }
<
>
()
override
{
return
nullptr
; }
bool
()
override
{
return
false
; }
<
>
()
override
{
return
nullptr
; }
};
::
()
{
WCF_Document = ::RegisterClipboardFormat(L"GacUI Document Format");
= ::
(
L"GacUI Document Format"
);
WCF_RTF = ::RegisterClipboardFormat(L"Rich Text Format");
= ::
(
L"Rich Text Format"
);
WCF_HTML = ::RegisterClipboardFormat(L"HTML Format");
}
<
>
::
()
{
if
(!
)
{
if
(!::
(
))
return
new
WindowsFakeClipboardReader
;
=
new
(
this
);
}
return
;
}
<
>
::
()
{
return
new
(
this
);
}
void
::
(
)
{
=
;
=
;
{
::
RemoveClipboardFormatListener
(
oldHandle
);
}
else
{
::
AddClipboardFormatListener
(
);
}
}
}
}
}