Files correlati : ba0 ba8 Ricompilazione Demo : [ ] Commento : ba0 aggiunto meccanismo di chiusura automatica in caso di installazione modulo sys ba8 aggiunto converitore di form primordiale git-svn-id: svn://10.65.10.50/trunk@12048 c028cbd2-c16b-5b4b-a496-9718f37d4682
169 lines
3.3 KiB
C++
Executable File
169 lines
3.3 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <automask.h>
|
|
#include <defmask.h>
|
|
#include <execp.h>
|
|
#include <form.h>
|
|
#include <prefix.h>
|
|
#include <scanner.h>
|
|
|
|
#include "ba8302.h"
|
|
#include "ba8400.h"
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TFormer_mask
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TFormer_mask : public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
void import();
|
|
|
|
public:
|
|
TFormer_mask();
|
|
};
|
|
|
|
void TFormer_mask::import_use()
|
|
{
|
|
}
|
|
|
|
void TFormer_mask::import_use(TReport& rep) const
|
|
{
|
|
TScanner scan(get(F_FORM));
|
|
|
|
TString use;
|
|
int parse_use = 0;
|
|
while (scan.ok())
|
|
{
|
|
const TString& line = scan.line();
|
|
if (line.empty())
|
|
break;
|
|
|
|
if (parse_use == 0 && line.starts_with("US"))
|
|
parse_use = 1;
|
|
|
|
if (parse_use == 1)
|
|
{
|
|
if (line.starts_with("EN"))
|
|
{
|
|
parse_use = 2;
|
|
break;
|
|
}
|
|
else
|
|
use << line << '\n';
|
|
}
|
|
|
|
}
|
|
|
|
if (!use.blank())
|
|
rep.set_recordset(use);
|
|
}
|
|
|
|
void TFormer_mask::import_sections(TReport& rep) const
|
|
{
|
|
TExportable_form frm(get(F_FORM));
|
|
frm.export_section('G', odd_page, rep, 'B', 0);
|
|
frm.export_section('B', odd_page, rep, 'B', 2);
|
|
}
|
|
|
|
void TFormer_mask::import()
|
|
{
|
|
TReport rep;
|
|
import_use(rep);
|
|
import_sections(rep);
|
|
rep.save(get(F_REPORT));
|
|
}
|
|
|
|
bool TFormer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
switch (o.dlg())
|
|
{
|
|
case F_FORM:
|
|
if (e == fe_modify)
|
|
{
|
|
TFilename output = get(F_REPORT);
|
|
TFilename path = output.path();
|
|
if (path.empty())
|
|
{
|
|
path = firm2dir(-1);
|
|
path.add("custom");
|
|
}
|
|
const TFilename input = o.get();
|
|
output = path;
|
|
output.add(input.name());
|
|
output.ext("rep");
|
|
output.lower();
|
|
set(F_REPORT, output);
|
|
enable(DLG_ELABORA, input.exist());
|
|
}
|
|
break;
|
|
case F_REPORT:
|
|
if (e == fe_modify)
|
|
{
|
|
const TFilename output = get(F_REPORT);
|
|
enable(DLG_PRINT, output.exist());
|
|
}
|
|
break;
|
|
case DLG_ELABORA:
|
|
if (e == fe_button)
|
|
{
|
|
const TFilename output = get(F_REPORT);
|
|
if (output.exist())
|
|
{
|
|
if (!yesno_box(TR("Il file %s esiste gia':\nSi desidera sovrascriverlo?"), (const char*)output))
|
|
return false;
|
|
}
|
|
import();
|
|
enable(DLG_PRINT, output.exist());
|
|
}
|
|
break;
|
|
case DLG_PRINT:
|
|
if (e == fe_button)
|
|
{
|
|
const TFilename output = get(F_REPORT);
|
|
if (output.exist())
|
|
{
|
|
TString cmd;
|
|
cmd << "ba8 -2 " << output;
|
|
TExternal_app app(cmd);
|
|
app.run();
|
|
return false; // Altrimenti esce dalla maschera
|
|
}
|
|
else
|
|
return error_box(TR("Il file %s non esiste"), (const char*)output);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
TFormer_mask::TFormer_mask() : TAutomask("ba8400a")
|
|
{
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TFormer_app
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TFormer_app : public TSkeleton_application
|
|
{
|
|
protected:
|
|
virtual void main_loop();
|
|
};
|
|
|
|
void TFormer_app::main_loop()
|
|
{
|
|
TFormer_mask m;
|
|
m.run();
|
|
}
|
|
|
|
int ba8400(int argc, char* argv[])
|
|
{
|
|
TFormer_app app;
|
|
app.run(argc, argv, TR("Form Converter"));
|
|
return 0;
|
|
}
|