Menu

[r97]: / src / xmlcopyeditor.h  Maximize  Restore  History

Download this file

517 lines (496 with data), 14.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
/*
* Copyright 2005-2007 Gerald Schmidt.
*
* This file is part of Xml Copy Editor.
*
* Xml Copy Editor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* Xml Copy Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xml Copy Editor; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef XMLCOPYEDITOR_H
#define XMLCOPYEDITOR_H
#define NEWFINDREPLACE 1
#include <wx/wx.h>
#include <wx/fdrepdlg.h>
#include <wx/filename.h>
#include <wx/wxhtml.h>
#include <wx/image.h>
#include <wx/imagpng.h>
#include <wx/utils.h>
#include <wx/docview.h>
#include <wx/propdlg.h>
#include <wx/generic/propdlg.h>
#include <wx/sysopt.h>
#include <wx/datetime.h>
#include <wx/log.h>
#include <wx/clipbrd.h>
#include <wx/strconv.h>
#include <wx/html/helpctrl.h>
#include <wx/snglinst.h>
#include <wx/ipc.h>
#include <wx/intl.h>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <memory>
#include <vector>
#include <stdexcept>
#include "xmldoc.h"
#include "myhtmlpane.h"
#include "xmlencodinghandler.h"
#include "myipc.h"
#include "xmlcopyeditorcopy.h"
#include <wx/aui/framemanager.h>
enum
{
STATUS_HIDDEN = 1,
STATUS_PROTECTED,
STATUS_MODIFIED,
STATUS_POSITION,
ID_TOOLBAR = wxID_HIGHEST + 1,
ID_XML_TOOLBAR,
ID_NOTEBOOK,
ID_LOCATION_PANEL,
ID_INSERT_CHILD_PANEL,
ID_INSERT_SIBLING_PANEL,
ID_INSERT_ENTITY_PANEL,
ID_FIND_REPLACE_PANEL,
ID_FIND_PANEL,
ID_COMMAND,
ID_VALIDATION_PANE,
ID_LOCATION_PANE_VISIBLE,
ID_PREVIOUS_DOCUMENT,
ID_NEXT_DOCUMENT,
ID_OPTIONS,
ID_IMPORT_MSWORD,
ID_HIDE_PANE,
ID_HOME,
ID_PASTE_NEW_DOCUMENT,
ID_PRINT_SETUP,
ID_FEEDBACK,
ID_TOOLBAR_VISIBLE,
ID_PROTECT_TAGS,
ID_SHOW_TAGS,
ID_HIDE_ATTRIBUTES,
ID_HIDE_TAGS,
ID_REPLACE,
ID_GLOBAL_REPLACE,
ID_COLOR_SCHEME_DEFAULT,
ID_COLOR_SCHEME_DEFAULT_BACKGROUND,
ID_COLOR_SCHEME_REDUCED_GLARE,
ID_COLOR_SCHEME_NONE,
ID_NOTEBOOK_STYLE_FLAT,
ID_NOTEBOOK_STYLE_VC8,
ID_NOTEBOOK_STYLE_VC8_COLOR,
ID_DOWNLOAD_SOURCE,
ID_OPEN_LARGE_FILE,
ID_RELOAD,
ID_WRAP_WORDS,
// IDs to be activated only if a document is open
ID_SPLIT_TAB_TOP,
ID_SPLIT_TAB_RIGHT,
ID_SPLIT_TAB_BOTTOM,
ID_SPLIT_TAB_LEFT,
ID_FIND,
ID_FIND_AGAIN,
ID_GOTO,
ID_PRINT,
ID_WORD_COUNT,
ID_PRINT_PREVIEW,
ID_INSERT_CHILD,
ID_INSERT_SIBLING,
ID_INSERT_TWIN,
ID_INSERT_ENTITY,
ID_INSERT_SYMBOL,
ID_CHECK_WELLFORMED,
ID_VALIDATE_DTD,
ID_VALIDATE_RELAX_NG,
ID_VALIDATE_W3C_SCHEMA,
ID_XPATH,
ID_XSLT,
ID_XSLT_TEI_FO,
ID_XSLT_TEI_HTML,
ID_XSLT_TEI_XHTML,
ID_XSLT_TEI_LATEX,
ID_XSLT_DOCBOOK_FO,
ID_XSLT_DOCBOOK_HTML,
ID_XSLT_DOCBOOK_XHTML,
ID_XSLT_DOCBOOK_WORDML,
ID_XSLT_WORDML_DOCBOOK,
ID_ASSOCIATE_DTD_PUBLIC,
ID_ASSOCIATE_DTD_SYSTEM,
ID_ASSOCIATE_W3C_SCHEMA,
ID_ASSOCIATE_W3C_SCHEMA_NS,
ID_ASSOCIATE_XSL,
ID_PRETTYPRINT,
ID_ENCODING,
ID_SPELL,
ID_STYLE,
ID_FONT_SMALLER,
ID_FONT_NORMAL,
ID_FONT_LARGER,
ID_BROWSER,
ID_TOGGLE_FOLD,
ID_FOLD_ALL,
ID_UNFOLD_ALL,
ID_VALIDATE_PRESET1,
ID_VALIDATE_PRESET2,
ID_VALIDATE_PRESET3,
ID_VALIDATE_PRESET4,
ID_VALIDATE_PRESET5,
ID_VALIDATE_PRESET6,
ID_VALIDATE_PRESET7,
ID_VALIDATE_PRESET8,
ID_VALIDATE_PRESET9,
ID_EXPORT_MSWORD,
// icon constants
CONST_WARNING,
CONST_STOP,
CONST_INFO,
CONST_QUESTION
};
class MyApp : public wxApp
{
public:
MyApp();
~MyApp();
virtual bool OnInit();
virtual void OnUnhandledException();
virtual bool OnExceptionInMainLoop();
#ifndef __WXMSW__
virtual void HandleEvent ( wxEvtHandler *handler, wxEventFunction func, wxEvent& event ) const;
#endif
protected:
wxLocale myLocale;
private:
wxSingleInstanceChecker *checker;
MyServer *server;
MyClient *client;
MyClientConnection *connection;
bool singleInstanceCheck;
int lang;
std::auto_ptr<wxConfig> config;
};
// forward declarations
class MyNotebook;
class wxAuiNotebookEvent;
class LocationPanel;
class InsertPanel;
class CommandPanel;
#ifdef NEWFINDREPLACE
class FindReplacePanel;
#endif
class MyFrame : public wxFrame
{
public:
MyFrame (
const wxString& title,
wxConfig *configParameter,
wxLocale& locale,
bool singleInstanceCheck,
int langParameter );
~MyFrame();
void OnActivateApp ( wxActivateEvent& event );
void OnAbout ( wxCommandEvent& event );
void OnCheckWellformedness ( wxCommandEvent& event );
void OnClose ( wxCommandEvent& event );
void OnCloseAll ( wxCommandEvent& event );
void OnClosePane ( wxCommandEvent& event );
void OnCut ( wxCommandEvent& event );
void OnCopy ( wxCommandEvent& event );
void OnPaste ( wxCommandEvent& event );
void OnPasteNewDocument ( wxCommandEvent& event );
void OnPrintSetup ( wxCommandEvent &event );
void OnPrintPreview ( wxCommandEvent &event );
void OnPrint ( wxCommandEvent &event );
void OnFind ( wxCommandEvent& event );
void OnFindAgain ( wxCommandEvent& event );
void OnFindReplace ( wxCommandEvent& event );
void OnCommand ( wxCommandEvent& event );
void OnGlobalReplace ( wxCommandEvent& event );
void OnWordCount ( wxCommandEvent& event );
void OnFeedback ( wxCommandEvent& event );
void OnSplitTab ( wxCommandEvent& event );
void OnFontSmaller ( wxCommandEvent& event );
void OnFontMedium ( wxCommandEvent& event );
void OnFontLarger ( wxCommandEvent& event );
void OnImportMSWord ( wxCommandEvent& event );
void OnInsertChild ( wxCommandEvent& event );
void OnInsertSibling ( wxCommandEvent& event );
void OnInsertTwin ( wxCommandEvent& event );
void OnInsertEntity ( wxCommandEvent& event );
void OnInsertSymbol ( wxCommandEvent& event );
void OnExportMSWord ( wxCommandEvent& event );
void OnBrowser ( wxCommandEvent& event );
void OnHelp ( wxCommandEvent& event );
void OnGoto ( wxCommandEvent& event );
void OnIconize ( wxIconizeEvent& event );
void OnNew ( wxCommandEvent& event );
void OnOpen ( wxCommandEvent& event );
void OnPrettyPrint ( wxCommandEvent& event );
void OnEncoding ( wxCommandEvent& event );
void OnQuit ( wxCommandEvent& event );
void OnSave ( wxCommandEvent& event );
void OnSaveAs ( wxCommandEvent& event );
void OnReload ( wxCommandEvent& event );
void OnUndo ( wxCommandEvent& event );
void OnRedo ( wxCommandEvent& event );
void OnSpelling ( wxCommandEvent& event );
//void OnStyle ( wxCommandEvent& event );
void OnPreviousDocument ( wxCommandEvent& event );
void OnNextDocument ( wxCommandEvent& event );
void OnOptions ( wxCommandEvent& event );
void OnHistoryFile ( wxCommandEvent& event );
void OnDialogFind ( wxFindDialogEvent& event );
void OnDialogReplace ( wxFindDialogEvent& event );
void OnDialogReplaceAll ( wxFindDialogEvent& event );
void OnFrameClose ( wxCloseEvent& event );
void OnIdle ( wxIdleEvent& event );
void OnUpdateClosePane ( wxUpdateUIEvent& event );
void OnUpdateCloseAll ( wxUpdateUIEvent& event );
void OnUpdateSaveUndo ( wxUpdateUIEvent& event );
void OnUpdatePreviousDocument ( wxUpdateUIEvent& event );
void OnUpdateSavedOnly ( wxUpdateUIEvent& event );
void OnUpdateNextDocument ( wxUpdateUIEvent& event );
void OnUpdateRedo ( wxUpdateUIEvent& event );
void OnUpdateCutCopy ( wxUpdateUIEvent& event );
void OnUpdateFindAgain ( wxUpdateUIEvent& event );
void OnUpdatePaste ( wxUpdateUIEvent& event );
void OnUpdateDocRange ( wxUpdateUIEvent& event );
void OnUpdateReplaceRange ( wxUpdateUIEvent& event );
void OnUpdateReload ( wxUpdateUIEvent& event );
void OnUpdateLocationPaneVisible ( wxUpdateUIEvent& event );
void OnValidateDTD ( wxCommandEvent& event );
void OnValidateRelaxNG ( wxCommandEvent& event );
void OnValidateSchema ( wxCommandEvent& event );
void OnXPath ( wxCommandEvent& event );
void OnXslt ( wxCommandEvent& event );
void OnValidatePreset ( wxCommandEvent& event );
void OnHome ( wxCommandEvent& event );
void OnDownloadSource ( wxCommandEvent& event );
void OnKeyPressed ( wxKeyEvent& event );
void OnToolbarVisible ( wxCommandEvent& event );
void OnLocationPaneVisible ( wxCommandEvent& event );
void OnProtectTags ( wxCommandEvent& event );
void OnVisibilityState ( wxCommandEvent& event );
void OnColorScheme ( wxCommandEvent& event );
void OnAssociate ( wxCommandEvent& event );
void OnPageClosing ( wxAuiNotebookEvent& event );
void OnToggleFold ( wxCommandEvent& event );
void OnFoldAll ( wxCommandEvent& event );
void OnUnfoldAll ( wxCommandEvent& event );
void OnRevert ( wxCommandEvent& event );
void OnWrapWords ( wxCommandEvent& event );
#ifdef __WXMSW__
void OnDropFiles ( wxDropFilesEvent& event );
#endif
void setStrictScrolling ( bool b );
void validateRelaxNG (
XmlDoc *doc,
const wxString& schemaName,
wxString& fileName );
void navigate ( const wxString& url );
void closePane();
void closeFindReplacePane();
void closeCommandPane();
bool closeActiveDocument();
bool getHandleCommandLineFlag();
// public to allow access outside MyFrame constructor
void handleCommandLine();
MyNotebook *getNotebook()
{
return mainBook;
}
// public to allow access from CommandPanel
XmlDoc *getActiveDocument();
void newDocument ( const wxString& s, const wxString& path = wxEmptyString, bool canSave = false );
void newDocument ( const std::string& s, const std::string& path = "", bool canSave = false );
void statusProgress ( const wxString& s );
// public to allow InsertPanel access
void messagePane ( const wxString& s,
int iconType = CONST_INFO,
bool forcePane = false );
// public to allow IPC access
bool openFile ( wxString& fileName, bool largeFile = false );
bool isOpen ( const wxString& fileName );
bool activateTab ( const wxString& fileName );
void reloadTab();
private:
wxAuiManager manager;
wxConfig *config; // owned by MyApp
wxLocale& myLocale;
bool singleInstanceCheck;
int lang, lastPos;
wxLogNull logTarget;
std::auto_ptr<wxHtmlEasyPrinting> htmlPrinting;
std::auto_ptr<wxFindReplaceDialog> findDialog;
std::auto_ptr<wxHtmlHelpController> helpController;
wxBoxSizer *frameSizer;
wxMenuBar *menuBar;
wxToolBar *toolBar;
LocationPanel *locationPanel;
InsertPanel *insertChildPanel, *insertSiblingPanel, *insertEntityPanel;
#ifdef NEWFINDREPLACE
FindReplacePanel *findReplacePanel;
#endif
CommandPanel *commandPanel;
XmlDoc *lastDoc;
wxMenu *fileMenu, *xmlMenu, *viewMenu, *colorSchemeMenu;
std::vector<wxMenu *> menuVector;
MyNotebook *mainBook;
MyHtmlPane *htmlReport;
std::string catalogPath, xslDtdPath, rssDtdPath, lzxDtdPath, xtmDtdPath,
xliffDtdPath;
std::pair<int, int> controlCoordinates;
std::map<std::string, std::map<std::string, std::set<std::string> > >
promptMap;
std::map<int, wxString> validationPresetMap;
std::set<wxString> openFileSet;
std::set<wxString> openLargeFileSet;
std::vector<wxString> tempFileVector;
int documentCount,
framePosX,
framePosY,
frameWidth,
frameHeight,
notebookStyle,
visibilityState,
commandOutput;
wxPoint stylePosition, aboutPosition;
wxSize styleSize;
wxString applicationDir,
ruleSetPreset,
dictionaryPreset,
filterPreset,
ruleSetDir,
filterDir,
binDir,
templateDir,
helpDir,
rngDir,
htmlDir,
pngDir,
xpathExpression,
lastDtdPublic,
lastDtdSystem,
lastSchema,
lastSchemaNamespace,
lastXslStylesheet,
lastSchemaNamespaceAux,
lastRelaxNGSchema,
lastDtdPublicAux,
openTabsOnClose,
browserCommand,
layout,
defaultLayout,
lastParent,
lastGrandparent,
commandString;
bool globalReplaceAllDocuments,
toolbarVisible,
protectTags,
handleCommandLineFlag,
rememberOpenTabs,
libxmlNetAccess,
deletePageVetoed,
saveBom,
unlimitedUndo,
#ifdef __WXMSW__
useCoolBar,
useCoolBarOnStart,
#endif
restoreLayout,
showLocationPane,
showInsertChildPane,
showInsertSiblingPane,
showInsertEntityPane,
expandInternalEntities,
validateAsYouType,
restoreFocusToNotebook,
showFullPathOnFrame,
findRegex,
commandSync;
wxBitmap newBitmap,
new16Bitmap,
openBitmap,
open16Bitmap,
searchBitmap,
saveBitmap,
saveGrBitmap,
save16Bitmap,
printPreviewBitmap,
printBitmap,
print16Bitmap,
undoBitmap,
undo16Bitmap,
redoBitmap,
redo16Bitmap,
cutBitmap,
copyBitmap,
pasteBitmap,
findBitmap,
spellingBitmap,
spellingGrBitmap,
spelling16Bitmap,
helpBitmap,
internetBitmap,
internetGrBitmap,
hyperlinkBitmap,
filtersBitmap,
checkWellformedBitmap,
checkValidBitmap;
wxFileHistory history;
wxFindReplaceData findData;
XmlCtrlProperties properties, largeFileProperties;
// member functions
bool panelHasFocus();
bool saveFile (
XmlDoc *doc,
wxString& fileName,
bool checkLastModified = true );
int getFileType ( const wxString& fileName );
long getNotebookStyleMask();
wxString getLinuxBrowser();
bool isSpecialFileType ( const wxString& fileName );
wxString getHtmlBuffer();
void encodingMessage();
void save();
void saveAs();
void displaySavedStatus ( int bytes );
void addSafeSeparator ( wxToolBar *toolBar );
void findAgain ( wxString s, int flags );
void updateFileMenu ( bool deleteExisting = true );
void documentOk ( const wxString& status );
void applyEditorProperties ( bool zoomOnly = false );
void xmliseWideTextNode ( wxString& s );
void updatePaths();
void importMSWord ( const wxString& path );
void showTopBars ( bool b );
void modifiedMessage();
void loadBitmaps();
void openRememberedTabs();
void getRawText ( XmlDoc *doc, std::string& buffer );
void updateToolbar();
std::string getApproximateEncoding ( char *docBuffer, size_t docBufferLen );
bool saveRawUtf8 (
const std::string& fileNameLocal,
std::string& bufferUtf8,
bool ignoreEncoding = false,
bool isXml = true );
void removeUtf8Bom ( std::string& buffer );
std::string getAuxPath ( const std::string& fileName );
wxMenuBar *getMenuBar();
wxToolBar *getToolBar();
DECLARE_EVENT_TABLE()
};
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.