wxMaxima
Loading...
Searching...
No Matches
Functions
WorksheetExport.h File Reference

Document serializers extracted from the Worksheet class. More...

#include <wx/gdicmn.h>
#include <wx/string.h>
#include <wx/textfile.h>
#include <memory>
#include <vector>
Include dependency graph for WorksheetExport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool WorksheetExport::ExportToHTML (GroupCell *tree, Configuration *configuration, const wxString &file, ViewCellPointers *cellPointers, GroupCell *hCaret)
 Export the tree to an HTML file.
 
std::unique_ptr< CellWorksheetExport::CopySelection (Cell *start, Cell *end, bool asData=false)
 Copy the cell range into a fresh list of cells.
 
wxSize WorksheetExport::CopyToFile (const wxString &file, Cell *start, Cell *end, bool asData, double scale, const Configuration *const *configuration)
 Render the cell range into an image file; returns the image's size.
 
bool WorksheetExport::ExportToTeX (GroupCell *tree, Configuration *configuration, const wxString &file, ViewCellPointers *cellPointers, GroupCell *hCaret)
 Export the tree to a LaTeX document; images go to a <name>_img directory.
 
void WorksheetExport::ExportToMAC (wxTextFile &output, GroupCell *tree, bool wxm, const std::vector< int > &cellMap, bool fixReorderedIndices)
 Serialize the tree as .wxm (wxm = true) or .mac lines into output.
 
void WorksheetExport::AddLineToFile (wxTextFile &output, const wxString &s)
 Add a (possibly multi-line) string to output as individual lines.
 
void WorksheetExport::CalculateReorderedCellIndices (GroupCell *tree, int &cellIndex, std::vector< int > &cellMap)
 Determine the (iN)/(oN) indices a fresh evaluation would assign.
 
wxString WorksheetExport::RTFStart (Configuration *configuration)
 The RTF document header: font, color and stylesheet tables.
 
wxString WorksheetExport::RTFEnd ()
 The RTF document footer matching RTFStart().
 
wxString WorksheetExport::SelectionToSelfContainedHTML (GroupCell *startGroup, GroupCell *endGroup, Configuration *configuration)
 Render a range of GroupCells as one self-contained HTML document (GH #2265/#2266/#2267): the stylesheet is inlined into a <style> element and every image is inlined as a base64 data: URI, so the result has no external file references at all and can be dropped straight onto the clipboard for "Copy as HTML" or otherwise used outside the context of the original document's directory.
 

Detailed Description

Document serializers extracted from the Worksheet class.

These functions turn a worksheet's cell tree into HTML, LaTeX and .mac/.wxm batch files, plus the RTF document frame used by the clipboard code. They are document functionality, not view functionality: they read only the cell tree and the Configuration, never the scrolling/cursor/mouse state, which is why they live outside the Worksheet class. Worksheet keeps thin wrappers that add the view-side bracketing (busy cursor, clip-region toggling, the saved-flag and backup-file dance).

test_WorksheetExport pins the byte-exact output of everything in here.

Function Documentation

◆ CalculateReorderedCellIndices()

void WorksheetExport::CalculateReorderedCellIndices ( GroupCell tree,
int &  cellIndex,
std::vector< int > &  cellMap 
)

Determine the (iN)/(oN) indices a fresh evaluation would assign.

Fills cellMap with old-index -> new-index so ExportToMAC can renumber references inside the exported code.

◆ CopySelection()

std::unique_ptr< Cell > WorksheetExport::CopySelection ( Cell start,
Cell end,
bool  asData = false 
)

Copy the cell range into a fresh list of cells.

Parameters
asData
  • true: The cells are copied in the cell list order.
  • false: The cells are copied in the draw list order

◆ ExportToHTML()

bool WorksheetExport::ExportToHTML ( GroupCell tree,
Configuration configuration,
const wxString &  file,
ViewCellPointers cellPointers,
GroupCell hCaret 
)

Export the tree to an HTML file.

Writes the HTML to file and the stylesheet, the equation images (in the format selected by Configuration::HTMLequationFormat()) and a .wxmx copy of the document into a <name>_htmlimg directory next to it.

Parameters
cellPointersand
hCaretare only passed through to the embedded .wxmx copy, which stores the cursor position.

◆ ExportToMAC()

void WorksheetExport::ExportToMAC ( wxTextFile &  output,
GroupCell tree,
bool  wxm,
const std::vector< int > &  cellMap,
bool  fixReorderedIndices 
)

Serialize the tree as .wxm (wxm = true) or .mac lines into output.

Parameters
cellMapWith fixReorderedIndices, the (iN)/(oN) indices are rewritten through this map (see CalculateReorderedCellIndices) so the numbering matches a fresh evaluation order.

◆ SelectionToSelfContainedHTML()

wxString WorksheetExport::SelectionToSelfContainedHTML ( GroupCell startGroup,
GroupCell endGroup,
Configuration configuration 
)

Render a range of GroupCells as one self-contained HTML document (GH #2265/#2266/#2267): the stylesheet is inlined into a <style> element and every image is inlined as a base64 data: URI, so the result has no external file references at all and can be dropped straight onto the clipboard for "Copy as HTML" or otherwise used outside the context of the original document's directory.

Unlike ExportToHTML() this never touches the user's own files: any temporary files it needs (images have to be rendered to a real path, see OutCommon.cpp's PrivateTempDir() for why) are written to and cleaned up from a private, mode-0700 scratch directory.

Parameters
startGroup

param endGroup The inclusive range of top-level cells to render (both must be non-null and endGroup must be reachable from startGroup via GetNext()).

Returns
the HTML document, or an empty string if the private scratch directory couldn't be created.