|
wxMaxima
|
Safety net for the multi-format clipboard / drag-and-drop payload of Worksheet. More...
#include <wx/app.h>#include <wx/bitmap.h>#include <wx/dataobj.h>#include <wx/dcmemory.h>#include <wx/dir.h>#include <wx/filename.h>#include <wx/frame.h>#include <wx/image.h>#include <wx/log.h>#include <wx/mstream.h>#include <wx/xml/xml.h>#include "Configuration.h"#include "Dirstructure.h"#include "MathParser.h"#include "worksheet/Worksheet.h"#include "worksheet/WorksheetExport.h"#include "cells/GroupCell.h"#include <cstdlib>#include <string>#include <vector>#include <unistd.h>#include <catch2/catch.hpp>Data Structures | |
| class | TestApp |
Macros | |
| #define | WXM_CORPUS_DIR "." |
| #define | CATCH_CONFIG_RUNNER |
Functions | |
| SCENARIO ("The whole-cell (cut/copy-cells) clipboard object is well-formed") | |
| SCENARIO ("The selection (copy-as-output) clipboard object is well-formed") | |
| SCENARIO ("Copy as HTML renders a self-contained document (GH #2265/#2266/#2267)") | |
| SCENARIO ("SelectionToSelfContainedHTML rejects a null range (GH #2265)") | |
| wxDECLARE_APP (TestApp) | |
| int | main (int argc, char **argv) |
Safety net for the multi-format clipboard / drag-and-drop payload of Worksheet.
When wxMaxima copies (or cuts, or drag-exports) a selection it advertises the same content under many flavors at once - the .wxm batch code, MathML (under two mime types), RTF (under two mime types), plain text, and a bitmap. Those live inside one wxDataObjectComposite / CompositeDataObject. A composite whose children collide on a wxDataFormat, or whose children carry no retrievable data, is a latent clipboard bug (and trips a wxWidgets assertion when it is handed to the real clipboard).
Worksheet::CreateSelectionDataObject() and Worksheet::CreateCellsDataObject() are the exact builders Copy()/CopyCells() use, factored out so the composite can be inspected without opening the (headless-unfriendly) system clipboard. This test builds them over a real document and pins the invariants:
GH #2264: "Copy as RTF" pasted into MS Word was silently ignored. RTF was only advertised under the MIME-style names "application/rtf"/"text/rtf" - what GTK/Linux word processors look for - but Windows registers CF_RTF under the literal name "Rich Text Format" (via RegisterClipboardFormat), which is the name Word's clipboard handler actually looks up. Neither MIME name matches it, so on Windows Word found no RTF data on the clipboard at all. Fixed by additionally advertising RTF under a third wxDataFormat with that exact name (RtfDataObject3 / Worksheet::m_rtfFormat3) and making it the preferred flavor everywhere RTF is offered; this test pins its presence and that it is now the winning "preferred" format.
GH #2265/#2266/#2267: "Copy as HTML" – WorksheetExport:: SelectionToSelfContainedHTML() renders a GroupCell range into one self-contained HTML document (inline <style>, no external file references), for Worksheet::CopyHTML()'s dedicated context-menu command. It can't itself be exercised via the real system clipboard here (same headless-unfriendly reason as the rest of this file), but it is a pure function of the cell tree, so it is tested directly: the returned document must carry its own stylesheet inline and never point at a file outside itself, and it must clean up whatever private scratch directory it used to render into.