#include "GuiDocumentClipboard.h"
#include "GuiParserManager.h"
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
parsing
::
xml
;
using
namespace
stream
;
namespace
document_clipboard_visitors
{
class
:
public
,
public
::
{
public
:
()
{
}
virtual
void
(
*
)
{
FOREACH(Ptr<DocumentRun>, childRun, run->runs)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
childRun
);)
{
childRun
(
this
);
}
}
void
(
*
)
override
{
}
void
(
DocumentStylePropertiesRun
*
)
override
{
(
);
}
void
(
DocumentStyleApplicationRun
*
)
override
{
(
);
}
void
(
*
)
override
{
(
);
}
void
(
*
)
override
{
}
void
(
DocumentEmbeddedObjectRun
*
)
override
{
}
void
(
*
)
override
{
(
);
}
};
class
ModifyDocumentForClipboardVisitor
:
public
{
public
:
ModifyDocumentForClipboardVisitor
()
{
}
void
(
*
)
override
{
for
(
=
->
.
() -
1
;
i
>=
0
;
i
--)
{
auto
=
->
i
];
if
(
childRun
.
<
DocumentEmbeddedObjectRun
>())
{
->
.
(
i
);
}
}
::
(
);
}
};
class
:
public
{
public
:
<
<
>>
;
()
{
}
void
(
*
)
override
{
->
=
L"res://Image_"
+
(
.
());
.
(
);
}
};
}
using
namespace
document_clipboard_visitors
;
void
ModifyDocumentForClipboard
(
<
>
)
{
ModifyDocumentForClipboardVisitor
;
FOREACH(Ptr<DocumentParagraphRun>, paragraph, model->paragraphs)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
paragraph
);)
{
paragraph
(&
visitor
);
}
}
<
>
LoadDocumentFromClipboardStream
(
stream
::
&
)
{
auto
=
<
>();
auto
=
<
>();
tempResource
(
L"Document"
,
tempResourceItem
);
auto
=
<
>(
tempResource
,
L""
);
internal
::
(
);
{
;
=
0
;
reader
title
version
;
if
(
title
!=
L"WCF_Document"
||
version
<
1
)
{
return
nullptr
;
}
}
;
reader
xmlText
;
<
>
;
auto
=
()->
<
>(
L"XML"
);
auto
=
parser
->Parse({},
xmlText
,
errors
);
if
(
errors
.
() >
0
)
return
nullptr
;
{
=
0
;
reader
count
;
for
(
=
0
;
i
<
count
;
i
++)
{
;
reader
(
&)
memoryStream
;
if
(
auto
=
()->
()->
(
memoryStream
))
{
auto
=
<
>();
imageItem
(
L"Image"
,
<
>(
image
,
0
));
tempResource
(
L"Image_"
+
(
i
),
imageItem
);
}
}
}
auto
=
::
(
tempResourceItem
,
xml
,
tempResolver
,
errors
);
return
document
;
}
void
SaveDocumentToClipboardStream
(
<
>
,
stream
::
&
)
{
;
FOREACH(Ptr<DocumentParagraphRun>, paragraph, model->paragraphs)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
paragraph
);)
{
paragraph
(&
visitor
);
}
internal
::
(
);
{
=
L"WCF_Document"
;
=
1
;
writer
title
version
;
}
{
auto
=
([&](
&
)
{
auto
=
();
(
xml
,
streamWriter
);
});
writer
xmlText
;
}
{
= (
)
visitor
.
.
();
writer
count
;
FOREACH(Ptr<DocumentImageRun>, imageRun, visitor.imageRuns)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
visitor
.
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
imageRun
);)
{
;
if
(
imageRun
)
{
auto
=
imageRun
();
if
(
format
==
::
)
{
format
=
::
;
}
imageRun
(
memoryStream
,
format
);
}
writer
(
stream
::
&)
memoryStream
;
}
}
}
}
}