22#ifndef CLIPBOARDCONTENTS_H
23#define CLIPBOARDCONTENTS_H
58#include <wx/dataobj.h>
61#include <wx/metafile.h>
83 explicit LazyValue(std::function<T()> renderer) : m_renderer(std::move(renderer)) {}
86 bool IsOffered()
const {
return m_value.has_value() ||
static_cast<bool>(m_renderer); }
91 const T &
Get()
const {
94 m_value = m_renderer();
103 mutable std::function<T()> m_renderer;
104 mutable std::optional<T> m_value;
131 Configuration *GetConfiguration()
const {
return m_configuration; }
137 std::unique_ptr<GroupCell> m_group;
138 std::unique_ptr<Cell> m_cells;
168#if wxUSE_ENH_METAFILE
185 size_t GetDataSize()
const override;
186 bool GetDataHere(
void *buf)
const override;
188 bool SetData(
size_t len,
const void *buf)
override;
192 using wxDataObjectSimple::GetDataSize;
193 using wxDataObjectSimple::GetDataHere;
194 using wxDataObjectSimple::SetData;
197 std::shared_ptr<const LazyValue<std::string>> m_data;
212 wxBitmap GetBitmap()
const override;
213 size_t GetDataSize()
const override;
214 bool GetDataHere(
void *buf)
const override;
215 size_t GetDataSize(
const wxDataFormat &format)
const override;
216 bool GetDataHere(
const wxDataFormat &format,
void *buf)
const override;
221 std::shared_ptr<const LazyValue<wxBitmap>> m_bitmap;
222 mutable bool m_rendered =
false;
242 size_t GetDataSize()
const override;
243 bool GetDataHere(
void *buf)
const override;
245 bool SetData(
size_t len,
const void *buf)
override;
249 using wxDataObjectSimple::GetDataSize;
250 using wxDataObjectSimple::GetDataHere;
251 using wxDataObjectSimple::SetData;
256 const std::string &Png()
const;
257 std::shared_ptr<const LazyValue<wxBitmap>> m_bitmap;
258 mutable std::optional<std::string> m_png;
261#if wxUSE_ENH_METAFILE
263class LazyEnhMetaFileDataObject final :
public wxEnhMetaFileDataObject
266 explicit LazyEnhMetaFileDataObject(
269 wxEnhMetaFile GetMetafile()
const override;
270 size_t GetDataSize(
const wxDataFormat &format)
const override;
271 bool GetDataHere(
const wxDataFormat &format,
void *buf)
const override;
276 std::shared_ptr<const LazyValue<wxEnhMetaFile>> m_metafile;
277 mutable bool m_rendered =
false;
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
A private copy of the cells a copy was made from.
Definition: ClipboardContents.h:116
Configuration *const * GetConfigurationPointer() const
The configuration, in the form BitmapOut, Svgout and Emfout want it.
Definition: ClipboardContents.h:130
const Cell * GetCells() const
The snapshot's cells. Renderers that don't consume their input use this.
Definition: ClipboardContents.h:126
std::unique_ptr< Cell > CopyCells() const
A fresh copy of the cells, for renderers that take ownership of theirs.
Definition: ClipboardContents.cpp:41
The configuration storage for the current worksheet.
Definition: Configuration.h:101
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
A bitmap that is only drawn when a program asks for it.
Definition: ClipboardContents.h:208
A clipboard format whose bytes are rendered when a program asks for them.
Definition: ClipboardContents.h:180
bool SetData(size_t len, const void *buf) override
Pasting into a LazyDataObject is not supported.
Definition: ClipboardContents.cpp:60
The same bitmap, as PNG bytes, for ports that can only hand over bytes.
Definition: ClipboardContents.h:235
bool SetData(size_t len, const void *buf) override
Pasting into a LazyPngDataObject is not supported.
Definition: ClipboardContents.cpp:143
static wxDataFormat GetDataFormat()
The format this is offered under: image/png.
Definition: ClipboardContents.cpp:111
A value that is computed the first time it is asked for.
Definition: ClipboardContents.h:80
const T & Get() const
The value, computed now if this is the first request.
Definition: ClipboardContents.h:91
bool IsRendered() const
Has the value been computed yet?
Definition: ClipboardContents.h:88
bool IsOffered() const
Is there a value, or a way to compute one?
Definition: ClipboardContents.h:86
Everything one copy operation puts on the clipboard.
Definition: ClipboardContents.h:153
wxString text
The selection as plain text.
Definition: ClipboardContents.h:157
LazyValue< std::string > mathML
A MathML document, UTF-8 encoded.
Definition: ClipboardContents.h:161
LazyValue< wxBitmap > bitmap
A bitmap image. Invalid if it could not be drawn.
Definition: ClipboardContents.h:167
LazyValue< std::string > xml
Copied cells as a self-contained XML document, UTF-8 encoded.
Definition: ClipboardContents.h:159
LazyValue< std::string > svg
A SVG image.
Definition: ClipboardContents.h:165
LazyValue< std::string > rtf
An RTF document with OMML maths, UTF-8 encoded.
Definition: ClipboardContents.h:163
wxString wxm
The selection as .wxm batch code.
Definition: ClipboardContents.h:155