1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1995, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
////////////////////////////////////////////////////////////////////////////////
23
#include "texteditdialog.h"
24
#include "fileselectiondialog.h"
25
#include "finddialog.h"
26
#include "replacedialog.h"
27
#include "questiondialog.h"
28
#include "inputfile.h"
29
#include "outputfile.h"
35
#include "editstubs.h"
40
Document::Document(Config *c, EditWindow *e, Viewer *v) {
44
mwwidget = mainwindow->GetWidget();
45
ifile = new InputFile();
46
ofile = new OutputFile();
47
(void)System::GetCwd(&dir);
51
saveSelection = False;
54
tool = (Toolkit::ToolType)e->GetTool();
55
suffix = Toolkit::DOCUMENT_SUFFIXES[tool];
56
(void)System::GetLoginName(&login);
57
toolName = Toolkit::TOOL_NAMES[tool];
58
toolName += "-version-";
59
toolName += Version::TOOLKIT_VERSION;
60
fileFormat = Version::FILE_FORMAT;
61
name = Toolkit::DOCUMENT_DEFAULT + suffix;
62
docType = Toolkit::DOCUMENT_TYPES[tool];
64
(void)System::GetTime(&createdOn);
75
void Document::CreateDialogs() {
76
sourceEditDialog = new TextEditDialog(mwwidget);
77
sourceEditDialog->Initialize();
78
sourceEditDialog->SetTitle("Document Source Editor");
79
sourceEditDialog->SetCancelCallback(0, 0);
80
sourceEditDialog->SetOKButtonLabel("Save");
81
sourceEditDialog->SetOKCallback(EditStubs::DocumentSourceOKCB, this);
82
sourceEditDialog->SetTextSize(12, 60);
83
docAnnotationDialog = new TextEditDialog(mwwidget);
84
docAnnotationDialog->Initialize();
85
docAnnotationDialog->SetTitle("Document Annotation Editor");
86
docAnnotationDialog->SetCancelCallback(0, 0);
87
docAnnotationDialog->SetOKCallback(EditStubs::AnnotationOKCB, this);
88
docAnnotationDialog->SetTextSize(12, 60);
89
eltAnnotationDialog = new TextEditDialog(GetMainWindow()->GetWidget());
90
eltAnnotationDialog->Initialize();
91
eltAnnotationDialog->SetTitle("Annotation Editor");
92
eltAnnotationDialog->SetCancelCallback(0, 0);
93
eltAnnotationDialog->SetTextSize(12, 60);
94
fileSelectionDialog = new FileSelectionDialog(mwwidget);
95
fileSelectionDialog->Initialize();
96
fileSelectionDialog->SetTitle("Document File Selector");
97
fileSelectionDialog->SetCancelCallback(EditStubs::CancelFSCB, this);
98
infoDialog = new TextViewDialog(mwwidget);
99
infoDialog->Initialize();
100
infoDialog->SetTextSize(23, 60);
101
infoDialog->SetTitle("Document Info");
102
checkDialog = new TextViewDialog(mwwidget);
103
checkDialog->Initialize();
104
checkDialog->SetTextSize(12, 72);
105
checkDialog->SetTitle("Check Document");
106
findDialog = new FindDialog(mwwidget);
107
findDialog->Initialize();
108
findDialog->SetOKCallback(EditStubs::FindNextCB, this);
109
findDialog->SetApplyCallback(EditStubs::FindAllCB, this);
110
findDialog->ManageSubstringToggle(True);
111
findDialog->SetTitle("Find text");
112
replaceDialog = new ReplaceDialog(mwwidget);
113
replaceDialog->Initialize();
114
replaceDialog->SetTitle("Replace text");
115
replaceDialog->SetOKCallback(EditStubs::ReplaceFindCB, this);
116
replaceDialog->SetReplaceCallback(EditStubs::ReplaceNextCB, this);
117
replaceDialog->SetApplyCallback(EditStubs::ReplaceAllCB, this);
118
replaceDialog->ManageSubstringToggle(True);
121
Document::~Document() {
125
delete sourceEditDialog;
126
delete docAnnotationDialog;
127
delete eltAnnotationDialog;
128
delete fileSelectionDialog;
131
void Document::UpdateWindow() {
132
UpdateDirectory(&dir);
133
mainwindow->SetModified(changes != 0);
134
mainwindow->SetDocumentName(&name);
135
mainwindow->SetDocumentType(&docType);
138
void Document::UpdateDirectory(const string *s) {
139
mainwindow->SetDirName(s);
140
sourceEditDialog->SetDirectory(s);
141
docAnnotationDialog->SetDirectory(s);
142
eltAnnotationDialog->SetDirectory(s);
143
fileSelectionDialog->SetDirectory(s);
146
void Document::New() {
147
SetStatus("action: new");
149
if (AskSave() == False)
152
string path = dir + Toolkit::DOCUMENT_DEFAULT + suffix;
153
// delete document contents.
161
/* virtual */ void Document::Initialize() {
162
SetHierarchic(False);
166
void Document::NewFile(const string *f) {
168
if (!path.endsWith(suffix)) {
169
string txt = "File name should have suffix '" + suffix + "'";
170
if (mainwindow->IsDoMap()) {
171
(new MessageDialog(mwwidget, MessageDialog::WARNING))->
172
Show("Warning", &txt);
176
std::cerr << txt << std::endl;
178
// delete original suffix.
179
path.setSuffix(suffix);
181
System::GiveFile(&path, &dir, &name); // get name from path.
183
(void)System::GetTime(&createdOn);
190
mainwindow->SetModified(False);
191
mainwindow->SetDocumentName(&name);
192
mainwindow->EnableDocumentSource(False);
193
string txt = name + " [New Document]";
199
void Document::Load() {
200
SetStatus("action: load");
202
string ext = "*" + suffix;
203
fileSelectionDialog->SetTitle("Load document");
204
fileSelectionDialog->ManageOptionMenu(False);
205
fileSelectionDialog->SetExtension(&ext);
206
fileSelectionDialog->SetOKCallback(EditStubs::LoadOKCB, this);
207
fileSelectionDialog->SetDefaultFile("");
208
fileSelectionDialog->Popup();
211
void Document::Append() {
212
SetStatus("action: append");
214
string ext = "*" + suffix;
215
fileSelectionDialog->SetTitle("Append document");
216
fileSelectionDialog->SetExtension(&ext);
217
fileSelectionDialog->SetOKCallback(EditStubs::LoadOKCB, this);
218
fileSelectionDialog->SetDefaultFile("");
219
fileSelectionDialog->Popup();
222
void Document::SetFSDir() {
223
fileSelectionDialog->GetDirectory(&dir);
224
UpdateDirectory(&dir);
227
void Document::LoadSave(const string *file) {
229
string tmp; // make sure that the loaded
230
System::GiveFile(file, &tmp); // file is not overwritten.
232
if (AskSave() == False)
238
void Document::DoLoad(const string *path) {
239
mainwindow->SetCursor(MouseCursor::WATCH);
240
if ((*path)[0] != '/')
241
// make absolute path name.
242
fileName = dir + *path;
246
if (!fileName.getSuffix(suf))
247
fileName.setSuffix(suffix);
248
string txt = "loading from " + fileName;
250
// is it an non-existent file ?
251
if (!System::FileExists(fileName.getstr())) {
253
mainwindow->SetCursor(MouseCursor::LEFT_PTR);
256
if (Load(&fileName)) {
258
mainwindow->SetDocumentName(&name);
259
mainwindow->SetModified(False);
261
txt = name + " appended";
264
txt = name + " loaded";
265
mainwindow->EnableDocumentSource(True);
272
SetStatus("append document failed");
274
SetStatus("load document failed");
276
mainwindow->SetCursor(MouseCursor::LEFT_PTR);
279
bool Document::Load(const string *file) {
280
// open file for reading.
282
if (!ifile->Good()) {
283
string txt = "Can not open\n'" + *file + "'";
284
ShowDialog(MessageDialog::ERROR, "Error", &txt);
288
// Check if it is not a directory etc.
289
if (!System::FileRegular(file->getstr())) {
290
string txt = "'" + *file + "'\nis not a regular file";
291
ShowDialog(MessageDialog::ERROR, "Error", &txt);
304
bool Document::LoadHeader() {
305
// Check and load document info.
307
if (!(CheckDocInfo() &&
308
viewer->Check(ifile, loadFormat) &&
312
else { // we are loading
313
if (!(LoadDocInfo() && viewer->Load(ifile, loadFormat)
320
bool Document::CheckDocInfo() {
321
// Checks but does not actually read in the storage and document info;
323
// Check storage info and load file format (into loadFormat).
325
; // try to continue.
327
if (loadFormat < 1.08) {
328
if ( !ifile->ReadAttribute("Generator", &val) ||
329
!ifile->ReadStringAttribute("Written", &val) ||
330
!ifile->LookupChar('}'))
334
if ( !ifile->ReadAttribute("GeneratedFrom", &val) ||
335
!ifile->ReadAttribute("WrittenBy", &val) ||
336
!ifile->ReadStringAttribute("WrittenOn", &val) ||
337
!ifile->LookupChar('}'))
340
// Check document info
341
// dname = "Document" or "Diagram" (older versions).
342
if (!ifile->ReadWord(&val) ||
343
((val != "Diagram") && (val != "Document")) ||
344
!ifile->ReadWord(&val) ||
345
!ifile->LookupChar('{') ||
346
!CheckDocumentType())
348
if (!ifile->ReadAttribute("Name", &val))
350
if (!ifile->ReadAttribute("Author", &val))
352
if (loadFormat < 1.08) {
353
if (!ifile->ReadStringAttribute("Created", &val))
357
if (!ifile->ReadStringAttribute("CreatedOn", &val))
360
if (loadFormat >= 1.09) {
361
if (!ifile->ReadStringAttribute("Annotation", &val))
364
if ( loadFormat >= 1.32 && Toolkit::HierarchicEditor(
365
GetMainWindow()->GetTool()) ) {
366
if ( ! ifile->ReadAttribute("Hierarchy", &val) )
369
if (!ifile->LookupChar('}'))
374
bool Document::LoadDocInfo() {
376
// Load and Check storage info.
379
if (loadFormat < 1.08) {
380
if (!ifile->ReadAttribute("Generator", &generatedFrom))
383
if (!ifile->ReadStringAttribute("Written", &writtenOn))
387
if (!ifile->ReadAttribute("GeneratedFrom", &generatedFrom))
389
if (!ifile->ReadAttribute("WrittenBy", &writtenBy))
391
if (!ifile->ReadStringAttribute("WrittenOn", &writtenOn))
394
if (!ifile->LookupChar('}'))
396
// Load and Check document info.
397
// dname = "Document" or "Diagram" (older versions).
399
if (!ifile->ReadWord(&dname) ||
400
((dname != "Diagram") && (dname != "Document")))
402
if (loadFormat < 1.20) // in past documents had an extra id.
403
if (!ifile->ReadWord(&val))
405
if (!ifile->LookupChar('{') || !CheckDocumentType())
407
if (!ifile->ReadAttribute("Name", &name))
409
if (!ifile->ReadAttribute("Author", &author))
411
// file is copied or moved?
413
System::GiveFile(&fileName, &f);
414
if (name != f && mainwindow->IsDoMap()) {
415
string txt = "The file " + f + " contains the document named\n"
416
+ name + " (apparently the file is moved or copied).\n"
417
"Do you wish to set the file name as new document "
419
QuestionDialog q(mwwidget, False);
421
q.SetMessageString(&txt);
422
q.SetTitle("file name as document name?");
423
int answer = q.GetAnswer();
424
if (answer == QuestionDialog::YES)
427
if (loadFormat < 1.08) {
428
if (!ifile->ReadStringAttribute("Created", &createdOn))
432
if (!ifile->ReadStringAttribute("CreatedOn", &createdOn))
435
if (loadFormat >= 1.09) {
436
if (!ifile->ReadStringAttribute("Annotation", &annotation))
439
if ( loadFormat >= 1.33 && Toolkit::HierarchicEditor(
440
GetMainWindow()->GetTool()) ) {
441
if ( ! ifile->ReadAttribute("Hierarchy", &val))
443
SetHierarchic(val %= "True");
445
SetHierarchic(False);
446
if (!ifile->LookupChar('}'))
448
if (!name.endsWith(suffix)) {
449
// string txt = "File name should have suffix '" + suffix + "'";
450
// ShowDialog(MessageDialog::WARNING, "Warning", &txt);
451
name.setSuffix(suffix);
456
bool Document::CheckFormat() {
457
string val = "Storage";
458
// look for storage clause.
459
if (!(ifile->LookupWord(&val) && ifile->LookupChar('{'))) {
460
string txt = "This file does not contain a loadable document";
461
ShowDialog(MessageDialog::ERROR, "File error", &txt);
464
// Load file format number.
465
if (!(ifile->ReadAttribute("Format", &val)))
467
loadFormat = val.todouble();
468
// Check file format number.
469
if (loadFormat < 1.0) {
470
string txt = "I found an obsolete file format";
471
ShowDialog(MessageDialog::ERROR, "File format error", &txt);
472
loadFormat = fileFormat;
475
else if (loadFormat > fileFormat) {
476
string txt = "This file format is newer than the current";
477
txt += "\nthis could give problems reading this document";
478
ShowDialog(MessageDialog::WARNING, "File format warning", &txt);
479
loadFormat = fileFormat;
485
bool Document::CheckDocumentType() {
487
// Check document type.
488
if (!(ifile->ReadStringAttribute("Type", &val)))
490
if (val != Toolkit::DOCUMENT_TYPES[tool])
492
// error("Warning: trying to read a \"%s\" with %s\n",
493
// val.getstr(), Toolkit::TOOL_NAMES[tool]);
497
void Document::Save() {
498
SetStatus("action: save");
502
saveName = dir + name;
507
void Document::PrepareSaveDialog() {
511
string ext = "*" + suffix;
512
fileSelectionDialog->ManageOptionMenu(False);
513
fileSelectionDialog->SetExtension(&ext);
516
void Document::SaveAs() {
517
SetStatus("action: save as");
518
saveSelection = False;
520
fileSelectionDialog->SetTitle("Save document to file");
521
fileSelectionDialog->SetOKCallback(EditStubs::SaveAsOKCB, this);
522
fileSelectionDialog->SetDefaultFile(&saveName);
523
fileSelectionDialog->Popup();
526
void Document::SaveSelectionAs() {
527
SetStatus("action: save selection as");
528
saveSelection = True;
530
fileSelectionDialog->SetTitle("Save selection to file");
531
fileSelectionDialog->SetOKCallback(EditStubs::SaveAsOKCB, this);
532
fileSelectionDialog->Popup();
535
void Document::DoSaveAs(const string *p) {
537
mainwindow->SetCursor(MouseCursor::WATCH);
538
if (System::FileExists(path.getstr()) &&
539
!System::FileRegular(path.getstr())) {
540
string txt = "'" + path + "'\n is not a regular file";
541
ShowDialog(MessageDialog::ERROR, "Error", &txt);
542
SetStatus("document is not saved");
543
mainwindow->SetCursor(MouseCursor::LEFT_PTR);
546
// make extension always .suffix
547
if (!path.endsWith(suffix)) {
548
path.setSuffix(suffix);
551
string file, directory;
552
System::GiveFile(&path, &directory, &file);
555
path = directory + '/' + Toolkit::DOCUMENT_DEFAULT + suffix;
557
string txt = "saving to " + path;
559
// Check if file already exists and the user _wants_ to overwrite it.
560
if (!MayWrite(&path)) {
561
SetStatus("document is not saved");
562
mainwindow->SetCursor(MouseCursor::LEFT_PTR);
565
// the chosen file name will be the document name.
566
string oldName = name;
568
// check and give document new name.
569
if (!NewName(&file)) {
570
SetStatus("illegal name so document is not saved");
571
mainwindow->SetCursor(MouseCursor::LEFT_PTR);
576
if (Save(&saveName)) {
577
txt = name + " saved";
581
SetStatus("save document failed");
584
// restore old document name.
586
mainwindow->SetDocumentName(&name);
588
mainwindow->SetCursor(MouseCursor::LEFT_PTR);
591
bool Document::Save(const string *file) {
592
// create or overwrite file
594
if (!ofile->Good()) {
595
string txt = "'" + *file +
596
"'\n can not be created or overwritten";
597
ShowDialog(MessageDialog::ERROR, "Error", &txt);
601
SaveDocInfo(); // write document info.
602
viewer->Save(ofile); // write view options.
603
SaveEditInfo(); // write editor defaults.
605
ofile->Close();// close file
606
// reset changes counter of document when it is entirely saved.
607
if (!saveSelection) {
609
mainwindow->SetModified(False);
614
void Document::SaveDocInfo() {
616
// begin storage info
617
(*ofile) << "Storage " << '\n';
619
// write current format.
620
// I do not trust operator<<(double).
621
string x = fileFormat;
622
(*ofile) << "\t{ " << "Format " << x << " }\n";
623
// write name of tool.
624
(*ofile) << "\t{ " << "GeneratedFrom " << toolName << " }\n";
626
(void)System::GetTime(&val);
627
(*ofile) << "\t{ " << "WrittenBy " << login << " }\n";
628
// write current time.
629
(void)System::GetTime(&val);
630
(*ofile) << "\t{ " << "WrittenOn " << '"' << val << '"' << " }\n";
633
// begin document info
634
(*ofile) << "Document \n{\n"
635
// write document type.
636
"\t{ Type \"" << docType << "\" }\n"
637
// write document name.
638
"\t{ Name " << name << " }\n"
639
// write document author.
640
"\t{ Author " << author << " }\n"
641
// write document creation date.
642
"\t{ CreatedOn \"" << createdOn << "\" }\n"
643
// write document annotation.
645
<< annotation << "\" }\n";
646
if ( Toolkit::HierarchicEditor(GetMainWindow()->GetTool()) ) {
647
// write hierarchic document flag
648
(*ofile) << "\t{ Hierarchy " <<
649
(isHierarchic ? "True" : "False") << " }\n";
651
// end document info.
655
void Document::SaveEditInfo() { }
657
void Document::ShowSource() {
658
SetStatus("action: show document source");
659
sourceEditDialog->SetTitle(&fileName);
660
sourceEditDialog->LoadFile(&fileName);
661
sourceEditDialog->Popup();
662
sourceEditDialog->SetStatus(&fileName);
665
void Document::SaveSource() {
666
if (sourceEditDialog->SaveFile(&fileName))
667
SetStatus("action: document source saved");
669
SetStatus("ok, did not save");
672
void Document::ShowDocInfo() {
673
SetStatus("action: document info");
675
string temp = "Current tool info\n";
676
temp += "---------------------\n";
680
temp += "File format: ";
686
System::GetTime(&val);
687
temp += "Current date: ";
690
temp += "Directory: ";
693
temp += "Number of changes: ";
697
temp += "Current document info\n";
698
temp += "---------------------\n";
708
temp += "Created on: ";
712
temp += "Loaded file info\n";
713
temp += "---------------------\n";
715
temp += "File name:";
718
temp += "Loaded format: ";
721
temp += "Generated from: ";
722
temp += generatedFrom;
724
temp += "Written by: ";
727
temp += "Written on: ";
732
temp += "None: document is created by current tool\n";
733
infoDialog->SetTextString(&temp);
737
void Document::ShowSummary() {
738
SetStatus("action: document summary");
739
ShowDialog(MessageDialog::INFORMATION, "Document summary",
740
"Nothing to summarize\n");
743
void Document::CheckDocument() {
744
SetStatus("action: check document syntax");
745
ShowDialog(MessageDialog::INFORMATION, "Check document syntax",
746
"There are no checks for this document type\n");
749
void Document::ModelCheckProperty() {
750
SetStatus("action: model check property");
751
ShowDialog(MessageDialog::INFORMATION,
752
"Model check property",
753
"There are no checks for this document type\n");
756
void Document::ClearTrace() {
757
SetStatus("action: clear trace");
758
ShowDialog(MessageDialog::INFORMATION,
760
"Not needed for this document type\n");
763
void Document::Annotate() {
764
SetStatus("action: annotate document");
765
string txt = "Annotation of " + name;
766
docAnnotationDialog->SetTitle(&txt);
767
docAnnotationDialog->SetTextString(&annotation);
768
docAnnotationDialog->Popup();
769
docAnnotationDialog->SetStatus(&txt);
772
void Document::Find() {
773
SetStatus("action: find");
777
void Document::Replace() {
778
SetStatus("action: replace");
779
replaceDialog->Popup();
782
void Document::SetAnnotation(const string *a) {
784
SetStatus("document annotation updated");
788
void Document::Quit() {
789
SetStatus("action: quit");
790
viewer->TextModeOff();
797
if (config->GetAskBeforeQuit()) {
798
string txt = "Are you sure you want to quit ";
799
txt += Toolkit::TOOL_NAMES[tool];
801
QuestionDialog q(mwwidget, False);
803
q.SetTitle("Quit confirmation");
804
q.SetMessageString(&txt);
805
answer = q.GetAnswer();
806
if (answer == QuestionDialog::NO)
809
// delete mainwindow and consequently the rest of the gang.
813
bool Document::AskSave() {
814
string txt = "Document '" + name + "' has been modified "
815
"\nDo you want to save it first?";
816
QuestionDialog q(mwwidget, True);
818
q.SetTitle("Document modified");
819
q.SetMessageString(&txt);
820
int answer = q.GetAnswer();
821
if (answer == QuestionDialog::YES) {
822
saveSelection = False;
823
saveName = dir + name;
824
if (!Save(&saveName))
827
else if (answer == QuestionDialog::CANCEL)
832
bool Document::NewName(const string *n) {
837
// name has a suffix but not the required suffix then give error msg.
839
if (newName.getSuffix(suf) && suf != suffix) {
841
txt = "Document name should have suffix '" + suffix + "'";
843
// add suffix when necessary.
844
if (!newName.endsWith(suffix))
845
newName.setSuffix(suffix);
848
if (newName == suffix)
849
newName = Toolkit::DOCUMENT_DEFAULT + suffix;
851
// Check for illegal chars.
852
for (unsigned i=0; i<newName.length(); i++) {
853
unsigned char c = (unsigned char) newName[i];
854
if (c == '/' || c == '{' || c == '}' || c == '"') {
856
string cs = (char) c;
857
txt = "Document name should not contain the"
858
" character '" + cs + "'";
860
else if (!isprint(c)) {
862
txt = "Document name should not contain"
863
" unprintable characters";
865
else if (isspace(c)) {
867
txt = "Document name should not contain"
868
" white space characters";
872
ShowDialog(MessageDialog::ERROR, "Error", &txt);
873
mainwindow->SetDocumentName(&name);
874
SetStatus("document could not be renamed");
877
mainwindow->SetDocumentName(&newName);
881
viewer->Refresh(); // refresh document header/footer (if any)
882
txt = "document renamed to " + name;
888
void Document::NewDir(const string *newdir) {
889
if (!System::DirExists(newdir->getstr())) {
890
string txt = *newdir + "\nis a non-existent directory";
891
ShowDialog(MessageDialog::ERROR, "Error", &txt);
892
UpdateDirectory(&dir);
893
SetStatus("change directory failed");
898
if (dir[dir.length()-1] != '/')
900
UpdateDirectory(&dir);
901
string txt = "change dir to " + dir;
902
viewer->GetPrintFileSelectionDialog()->SetDirectory(&dir);
907
bool Document::IsDefault() {
908
string t = Toolkit::DOCUMENT_DEFAULT;
909
return (name.startsWith(t) != 0);
912
void Document::IncChanges() {
913
mainwindow->SetModified(0 != ++changes);
916
void Document::DecChanges() {
917
mainwindow->SetModified(0 != --changes);
920
bool Document::MayWrite(const string *path) {
921
if (System::FileExists(path->getstr())) {
922
string txt = "'" + *path +
923
"'\nalready exists. Do you want to overwrite it ?";
924
QuestionDialog q(mwwidget, False);
926
q.SetTitle("Question");
927
q.SetMessageString(&txt);
928
int answer = q.GetAnswer();
929
if (answer == QuestionDialog::NO)
935
void Document::ReportCheck(int errors, const string *msg) {
936
SetStatus("action: report check document results");
939
// get rid of carr. returns in text labels.
940
text.replace('\r', ' ');
941
checkDialog->SetTextString(&text);
942
checkDialog->Popup();
945
ShowDialog(MessageDialog::INFORMATION, "Check document",
946
"No violations found\n");
950
void Document::ShowDialog(MessageDialog::DialogType t, const char *title,
951
const char *text) const {
952
if (!mainwindow->IsDoMap()) {
953
// mainwindow is not mapped, print to stderr.
954
std::cerr << title << ": " << text << std::endl;
957
MessageDialog *d = new MessageDialog(mwwidget, t);
961
// I dont know why but otherwise I got crashes.
964
d->SetMessageString(text);
969
void Document::SetHierarchic(bool set) {
970
isHierarchic = AllowHierarchic() ? set : False;