diff --git a/include/msksheet.cpp b/include/msksheet.cpp index 26be3b353..1ec63c72a 100755 --- a/include/msksheet.cpp +++ b/include/msksheet.cpp @@ -1028,8 +1028,17 @@ void TSpreadsheet::mask2str(int rec) #endif } #if XVT_OS == XVT_OS_WIN - CHECK(_needs_update == -1 || _needs_update == rec, "Can't update two records"); - _needs_update = rec; + if (_needs_update != rec) + { + if (_needs_update >= 0) + { +#ifdef DBG + warning_box("Double update: %d and %d", _needs_update, rec); +#endif + update_rec(_needs_update); + } + _needs_update = rec; + } #endif } diff --git a/include/printer.cpp b/include/printer.cpp index 7c92ae619..40e8519f9 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -816,7 +816,7 @@ HIDDEN bool font_handler(TMask_field& f, KEY key) TPrinter::TPrinter() : _date (TODAY), _multiple_link (FALSE), _frozen (FALSE), _isgraphics (TRUE), _lines_per_inch (6), _ch_size (12), _ncopies(1), _export_header(FALSE), - _export_header_len(0) + _export_header_len(0), _vf(NULL) #if XVT_OS == XVT_OS_WIN , _print_rcd(NULL) #endif @@ -1370,7 +1370,8 @@ bool TPrinter::open() else #endif if (_printertype == screenvis) - { + { + CHECK(_vf == NULL, "Print preview already open"); _vf = new TViswin (NULL, "Anteprima di stampa", TRUE, TRUE, _linksdescr.items () > 0); _vf->open_modal (); @@ -1649,6 +1650,20 @@ int TPrinter::set_bookmark(const char* txt, int father) } +void TPrinter::print_txt(TTextfile& txt) +{ +#if XVT_OS == XVT_OS_WIN + PrintWhat._prcd = _print_rcd; + PrintWhat._txt = &txt; + PrintWhat._graphics = _isgraphics; + PrintWhat._charsize = _ch_size; + xvt_print_open(); + xvt_print_start_thread (start_winprint, (long) (&PrintWhat)); + xvt_print_close(); +#endif +} + + void TPrinter::close () { const bool isfirstpage = (_currentpage == 1 && _frompage == 0) || @@ -1670,42 +1685,32 @@ void TPrinter::close () _vf->close_print(); const KEY key = _vf->run (); if (_vf->is_open ()) _vf->close_modal (); - delete _vf; + _bookmarks.destroy(); freeze (FALSE); - _bookmarks.destroy(); - _vf = NULL; if (key == K_CTRL+'S') { _isopen = FALSE; _currentrow = _currentpage = 1; - _printertype = winprinter; - main_app().print(); - _printertype = screenvis; + print_txt(_vf->text()); } + + delete _vf; _vf = NULL; } else if (_printertype == export) { - if (!_exportfile.empty() && _txt.lines() > 0L) + if (_exportfile.not_empty() && _txt.lines() > 0L) { ofstream txt((const char*)_exportfile); for (long i = 0; i < _txt.lines(); i++) - { txt << _txt.line_formatted(i) << '\n'; - } txt.close(); } } #if XVT_OS == XVT_OS_WIN else if (_printertype == winprinter && _txt.lines() > 0L) -{ - PrintWhat._prcd = _print_rcd; - PrintWhat._txt = &_txt; - PrintWhat._graphics = _isgraphics; - PrintWhat._charsize = _ch_size; - xvt_print_open(); - xvt_print_start_thread (start_winprint, (long) (&PrintWhat)); - xvt_print_close(); +{ + print_txt(_txt); } else if (_printertype == fileprinter) { @@ -1817,7 +1822,6 @@ TFile_printer::~TFile_printer () bool TFile_printer::set () { TMask m ("bagn004"); - KEY tasto; int f; // diff --git a/include/printer.h b/include/printer.h index df56b6138..2d69f7415 100755 --- a/include/printer.h +++ b/include/printer.h @@ -201,6 +201,7 @@ protected: bool printfooter(); void save_configuration(); + void print_txt(TTextfile& txt); public: diff --git a/include/viswin.h b/include/viswin.h index 4bac3bbb7..c477717ec 100755 --- a/include/viswin.h +++ b/include/viswin.h @@ -153,7 +153,9 @@ public: void close_print(); bool frozen() { return _frozen; } void abort_print(); + long lines() { return _txt.lines(); } + TTextfile& text() { return _txt; } void goto_end(); void goto_top();