wxMaxima
Loading...
Searching...
No Matches
MaximaFileIO.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
33#ifndef MAXIMAFILEIO_H
34#define MAXIMAFILEIO_H
35
36#include <wx/string.h>
37
38class wxMaxima;
39class Worksheet;
40class wxStringTokenizer;
41
49{
50public:
51 explicit MaximaFileIO(wxMaxima &wxm) : m_wxMaxima(wxm) {}
52
54 bool OpenMACFile(const wxString &file, Worksheet *document,
55 bool clearDocument = true);
56
58 bool OpenWXMFile(const wxString &file, Worksheet *document,
59 bool clearDocument = true);
60
63 bool OpenWXMXFile(const wxString &file, Worksheet *document,
64 bool clearDocument = true);
65
67 bool OpenXML(const wxString &file, Worksheet *document);
68
71 bool CheckWXMXVersion(const wxString &docversion);
72
76 wxString ReadPotentiallyUnclosedTag(wxStringTokenizer &lines,
77 wxString firstLine, int depth = 0);
78
81 bool OpenFile(const wxString &file, const wxString &command = {});
82
84 bool SaveFile(bool forceSave = false);
85
87 bool AutoSave();
88
89private:
98 void ReportSaveFailed();
99
102 bool m_saveFailedBoxPending = false;
103
106 wxMaxima &m_wxMaxima;
107};
108
109#endif // MAXIMAFILEIO_H
The worksheet file loaders/savers extracted from the wxMaxima god class.
Definition: MaximaFileIO.h:49
bool OpenFile(const wxString &file, const wxString &command={})
Opens a file: picks the loader by extension (or hands the file to Maxima via load()/batch()/demo() fo...
Definition: MaximaFileIO.cpp:606
wxString ReadPotentiallyUnclosedTag(wxStringTokenizer &lines, wxString firstLine, int depth=0)
Reassembles a cell whose closing XML tag went missing in a damaged .wxmx, used by OpenWXMXFile's reco...
Definition: MaximaFileIO.cpp:174
bool CheckWXMXVersion(const wxString &docversion)
Warns if a document was saved by a newer wxMaxima; returns false if it is too new to open at all.
Definition: MaximaFileIO.cpp:516
bool OpenXML(const wxString &file, Worksheet *document)
Loads a bare content.xml (extracted from a .wxmx) into the worksheet.
Definition: MaximaFileIO.cpp:541
bool OpenMACFile(const wxString &file, Worksheet *document, bool clearDocument=true)
Loads a Maxima/xMaxima batch file (.mac/.out) into the worksheet.
Definition: MaximaFileIO.cpp:49
bool OpenWXMFile(const wxString &file, Worksheet *document, bool clearDocument=true)
Loads a plain-text wxMaxima worksheet (.wxm) into the worksheet.
Definition: MaximaFileIO.cpp:108
bool OpenWXMXFile(const wxString &file, Worksheet *document, bool clearDocument=true)
Loads a zipped wxMaxima worksheet (.wxmx) into the worksheet, with several fallback strategies for re...
Definition: MaximaFileIO.cpp:229
bool SaveFile(bool forceSave=false)
Saves the worksheet, prompting for a name (Save As) if needed or forced.
Definition: MaximaFileIO.cpp:750
bool AutoSave()
Saves the project to a temp file (autosave), or to its real file.
Definition: MaximaFileIO.cpp:881
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:116
Definition: wxMaxima.h:75