Patch level : 10.0 376
Files correlati : ba8.exe ve1.exe Ricompilazione Demo : [ ] Commento : Uniformato spessore linee in sede di stampa report su carta e/o pdf git-svn-id: svn://10.65.10.50/trunk@19115 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
68bae27fdb
commit
32f27bfb34
@ -82,16 +82,27 @@ BUTTON DLG_NULL 2 2
|
||||
BEGIN
|
||||
END
|
||||
|
||||
BUTTON DLG_EDIT 10 2
|
||||
BUTTON DLG_EXPORT 2 2
|
||||
BEGIN
|
||||
PROMPT 3 1 "~Edit"
|
||||
PROMPT 5 1 "~Excel"
|
||||
PICTURE TOOL_EXCEL
|
||||
MESSAGE EXIT,88
|
||||
END
|
||||
|
||||
BUTTON DLG_EDIT 2 2
|
||||
BEGIN
|
||||
PROMPT 6 1 "~Edit"
|
||||
PICTURE TOOL_EDIT
|
||||
MESSAGE EXIT,69
|
||||
END
|
||||
|
||||
BUTTON DLG_NULL 2 2
|
||||
BEGIN
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 2 2
|
||||
BEGIN
|
||||
PROMPT 5 1 ""
|
||||
PROMPT 7 1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
@ -837,7 +837,7 @@ bool ini_set_string(const char* file, const char* paragraph, const char* name, c
|
||||
bool ini_get_bool(const char* file, const char* para, const char* name, bool defval, int idx)
|
||||
{
|
||||
const char b = ini_get_string(file, para, name, defval ? "1" : "0", idx)[0];
|
||||
return strchr("XY1", b) != NULL;
|
||||
return b ? (strchr("XY1", b) != NULL) : defval;
|
||||
}
|
||||
|
||||
bool ini_get_bool(int cfg, const char* para, const char* name, bool defval, int idx)
|
||||
@ -858,6 +858,11 @@ bool ini_set_int(const char* file, const char* paragraph, const char* name, int
|
||||
return ini_set_string(file, paragraph, name, value, idx);
|
||||
}
|
||||
|
||||
bool ini_set_bool(const char* file, const char* paragraph, const char* name, bool val, int idx)
|
||||
{
|
||||
return ini_set_string(file, paragraph, name, val ? "1" : "0", idx);
|
||||
}
|
||||
|
||||
const TString& ini_get_string(int cfg, const char* paragraph, const char* name, const char* defval, int idx)
|
||||
{
|
||||
DECLARE_FILENAME(cfg);
|
||||
@ -882,6 +887,12 @@ bool ini_set_int(int cfg, const char* paragraph, const char* name, int val, int
|
||||
return ini_set_int(filename, paragraph, name, val, idx);
|
||||
}
|
||||
|
||||
bool ini_set_bool(int cfg, const char* paragraph, const char* name, bool val, int idx)
|
||||
{
|
||||
DECLARE_FILENAME(cfg);
|
||||
return ini_set_string(filename, paragraph, name, val ? "1" : "0", idx);
|
||||
}
|
||||
|
||||
const TString& get_oem_info(const char* varname)
|
||||
{
|
||||
static int oem = ini_get_int(CONFIG_OEM, "MAIN", "OEM");
|
||||
|
@ -180,6 +180,7 @@ public:
|
||||
bool ini_get_bool (const char* file, const char* para, const char* name, bool defval = false, int idx = -1);
|
||||
int ini_get_int (const char* file, const char* para, const char* name, int defval = 0, int idx = -1);
|
||||
const TString& ini_get_string(const char* file, const char* para, const char* name, const char* defval = "", int idx = -1);
|
||||
bool ini_set_bool (const char* file, const char* para, const char* name, bool val, int idx = -1);
|
||||
bool ini_set_int (const char* file, const char* para, const char* name, int val, int idx = -1);
|
||||
bool ini_set_string(const char* file, const char* para, const char* name, const char* val, int idx = -1);
|
||||
|
||||
@ -187,6 +188,7 @@ bool ini_set_string(const char* file, const char* para, const char* na
|
||||
bool ini_get_bool (int cfg, const char* para, const char* name, bool defval = false, int idx = -1);
|
||||
int ini_get_int (int cfg, const char* para, const char* name, int defval = 0, int idx = -1);
|
||||
const TString& ini_get_string(int cfg, const char* para, const char* name, const char* defval = "", int idx = -1);
|
||||
bool ini_set_bool (int cfg, const char* para, const char* name, bool val, int idx = -1);
|
||||
bool ini_set_int (int cfg, const char* para, const char* name, int val, int idx = -1);
|
||||
bool ini_set_string(int cfg, const char* para, const char* name, const char* val, int idx = -1);
|
||||
|
||||
|
@ -176,12 +176,11 @@ TRecnotype TODBC_recordset::items() const
|
||||
{
|
||||
if (_items == 0)
|
||||
{
|
||||
TString sql; parsed_text(sql);
|
||||
XVT_ODBC oc = connection();
|
||||
if (oc != NULL)
|
||||
{
|
||||
TString sql; parsed_text(sql);
|
||||
TPerformance_profiler prof("ODBC count");
|
||||
|
||||
TRecnotype& i = (TRecnotype&)_items;
|
||||
if (!_columns_loaded)
|
||||
{
|
||||
@ -284,12 +283,11 @@ bool TODBC_recordset::move_to(TRecnotype n)
|
||||
|
||||
if (n < _first_row || n >= _first_row+_page.items())
|
||||
{
|
||||
TString sql; parsed_text(sql);
|
||||
XVT_ODBC oc = connection();
|
||||
if (oc == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
TString sql; parsed_text(sql);
|
||||
if (tot > _pagesize && sql.find("LIMIT ") < 0)
|
||||
{
|
||||
const int semicolon = sql.rfind(';');
|
||||
@ -360,30 +358,33 @@ const TVariant& TODBC_recordset::get(const char* name) const
|
||||
return TRecordset::get(name);
|
||||
}
|
||||
|
||||
void TODBC_recordset::parsed_text(TString& sql) const
|
||||
{
|
||||
TRecordset::parsed_text(sql);
|
||||
|
||||
if (sql.starts_with("ODBC(", true))
|
||||
{
|
||||
const int par = sql.find(')');
|
||||
if (par > 0)
|
||||
{
|
||||
TToken_string conn(sql.sub(5, par), ',');
|
||||
sql.ltrim(par+1);
|
||||
sql.trim();
|
||||
|
||||
TString dsn = conn.get(); dsn.strip("\"");
|
||||
TString usr = conn.get(); usr.strip("\"");
|
||||
TString pwd = conn.get(); pwd.strip("\"");
|
||||
TString dir = conn.get(); dir.strip("\"");
|
||||
if (!((TODBC_recordset*)this)->connect(dsn, usr, pwd, dir))
|
||||
error_box(TR("Impossibile connettersi al DSN %s"), (const char*)dsn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TODBC_recordset::set(const char* sql)
|
||||
{
|
||||
reset();
|
||||
_sql = sql;
|
||||
if (_sql.starts_with("ODBC", true))
|
||||
{
|
||||
_sql.ltrim(4); _sql.trim();
|
||||
if (_sql[0] == '(')
|
||||
{
|
||||
const int par = _sql.find(')');
|
||||
if (par > 0)
|
||||
{
|
||||
TToken_string conn(_sql.sub(1, par), ',');
|
||||
_sql.ltrim(par+1); _sql.trim();
|
||||
|
||||
TString dsn = conn.get(); dsn.strip("\"");
|
||||
TString usr = conn.get(); usr.strip("\"");
|
||||
TString pwd = conn.get(); pwd.strip("\"");
|
||||
TString dir = conn.get(); dir.strip("\"");
|
||||
if (!connect(dsn, usr, pwd, dir))
|
||||
error_box(TR("Impossibile connettersi al DSN %s"), (const char*)dsn);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_sql.find("SELECT") >= 0 || _sql.find("select") >= 0)
|
||||
find_and_reset_vars();
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ protected:
|
||||
XVT_ODBC connection() const;
|
||||
void reset();
|
||||
const TArray* row(TRecnotype n);
|
||||
virtual void parsed_text(TString& sql) const;
|
||||
|
||||
public:
|
||||
virtual TRecnotype items() const;
|
||||
|
@ -928,19 +928,14 @@ TPrintrow::~TPrintrow()
|
||||
|
||||
TObject *TPrintrow::dup () const
|
||||
{
|
||||
return new TPrintrow (*this);
|
||||
return new TPrintrow(*this);
|
||||
}
|
||||
|
||||
const char *TPrintrow::class_name () const
|
||||
{
|
||||
return "Printrow";
|
||||
}
|
||||
{ return "Printrow"; }
|
||||
|
||||
word TPrintrow::class_id()
|
||||
const
|
||||
{
|
||||
return CLASS_PRINTROW;
|
||||
}
|
||||
word TPrintrow::class_id() const
|
||||
{ return CLASS_PRINTROW; }
|
||||
|
||||
TPrintrow& TPrintrow::reset()
|
||||
{
|
||||
@ -2228,3 +2223,178 @@ bool TPrinter::is_landscape() const
|
||||
xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, _print_rcd, &ph, &pw, NULL, NULL);
|
||||
return pw > ph;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTabulator
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTab_info : public TObject
|
||||
{
|
||||
int _start, _end;
|
||||
|
||||
public:
|
||||
int intersection(int s, int e) const;
|
||||
int intersection(const TTab_info& i) const { return intersection(i._start, i._end); }
|
||||
|
||||
void set_start(int s) { _start = s; }
|
||||
void set_end(int e) { _end = e; }
|
||||
void set(int s, int e) { _start = s; _end = e; }
|
||||
int start() const { return _start; }
|
||||
int end() const { return _end; }
|
||||
int width() const { return _end - _start + 1; }
|
||||
bool operator==(const TTab_info& ti) const { return _start == ti.start() && _end == ti.end(); }
|
||||
|
||||
TTab_info(int s, int e) { set(s, e); }
|
||||
};
|
||||
|
||||
int TTab_info::intersection(int s, int e) const
|
||||
{
|
||||
int i = 0;
|
||||
if (e >= _start && s <= _end)
|
||||
i = min(_end, e) - max(_start, s);
|
||||
return i;
|
||||
}
|
||||
|
||||
void TTabulator::add(int s, int e)
|
||||
{
|
||||
if (e >= s)
|
||||
_tab.add(new TTab_info(s, e));
|
||||
}
|
||||
|
||||
void TTabulator::split(int s0, int e0, int s1, int e1)
|
||||
{
|
||||
if (s0 >= (s1+e1)/2 && e0 <= e1+1)
|
||||
{
|
||||
add(s1, s0-1);
|
||||
add(s0, max(e1, e0));
|
||||
return;
|
||||
}
|
||||
if (s1 >= (s0+e0)/2 && e1 <= e0+1)
|
||||
{
|
||||
add(s0, s1-1);
|
||||
add(s1, max(e0,e1));
|
||||
return;
|
||||
}
|
||||
add(min(s0,s1), max(e0,e1));
|
||||
/*
|
||||
int a[4] = { s0, e0, s1, e1 };
|
||||
|
||||
int i, j;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = i+1; j < 4; j++)
|
||||
{
|
||||
if (a[i] > a[j])
|
||||
{ const int tmp = a[i]; a[i] = a[j]; a[j] = tmp; }
|
||||
}
|
||||
}
|
||||
|
||||
int t = 3;
|
||||
for (i = 0; i < t; i++)
|
||||
{
|
||||
j = i+1;
|
||||
if (abs(a[i]-a[j]) <= 1)
|
||||
{
|
||||
if (i < 2)
|
||||
a[i] = a[j] = min(a[i],a[j]);
|
||||
else
|
||||
a[i] = a[j] = max(a[i],a[j]);
|
||||
t--;
|
||||
for (j = i+1; j <= t; j++)
|
||||
a[j] = a[j+1];
|
||||
}
|
||||
}
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
a[t-1]++;
|
||||
for (i = 0; i < t; i++)
|
||||
add(a[i], a[i+1]-1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
int TTabulator::find_column(int column, int width) const
|
||||
{
|
||||
int start = column;
|
||||
int end = column + width - 1;
|
||||
|
||||
int index = -1, inter = 0;
|
||||
FOR_EACH_ARRAY_ITEM(_tab, t, obj)
|
||||
{
|
||||
TTab_info& ti = *(TTab_info*)obj;
|
||||
const int i = ti.intersection(start, end);
|
||||
if (i > inter)
|
||||
{
|
||||
inter = i;
|
||||
index = t;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
static int tab_compare(const TObject** o0, const TObject** o1)
|
||||
{
|
||||
const TTab_info& t0 = *(TTab_info*)*o0;
|
||||
const TTab_info& t1 = *(TTab_info*)*o1;
|
||||
return t0.start() - t1.start();
|
||||
}
|
||||
|
||||
void TTabulator::add_field(int column, int width)
|
||||
{
|
||||
int start = column;
|
||||
int end = column + width - 1;
|
||||
int index = find_column(column, width);
|
||||
if (index >= 0)
|
||||
{
|
||||
const TTab_info& ti = (const TTab_info&)_tab[index];
|
||||
if (ti.intersection(start, end) < width)
|
||||
{
|
||||
split(start, end, ti.start(), ti.end());
|
||||
_tab.destroy(index, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
add(start, end);
|
||||
}
|
||||
|
||||
bool TTabulator::empty() const
|
||||
{
|
||||
return _tab.items() <= 1;
|
||||
}
|
||||
|
||||
void TTabulator::sort()
|
||||
{
|
||||
if (empty())
|
||||
{
|
||||
_tab.destroy();
|
||||
for (int i = 0; i < 256; i += 8)
|
||||
add(i, i+7);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tab.sort(tab_compare);
|
||||
for (int i = _tab.last(); i > 0; i--)
|
||||
{
|
||||
TTab_info& t0 = (TTab_info&)_tab[i-1];
|
||||
TTab_info& t1 = (TTab_info&)_tab[i];
|
||||
if (t1 == t0 || t1.width() <= 0)
|
||||
_tab.destroy(i);
|
||||
else
|
||||
{
|
||||
if (t1.start() - t0.end() >= 8)
|
||||
{
|
||||
_tab.insert(new TTab_info(t0.end()+1, t1.start()-1), i);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int center = (t0.end() + t1.start())/2;
|
||||
t0.set_end(center);
|
||||
t1.set_start(center+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -762,6 +762,21 @@ public:
|
||||
virtual ~TFile_printer();
|
||||
};
|
||||
|
||||
class TTabulator : public TObject
|
||||
{
|
||||
TArray _tab;
|
||||
|
||||
protected:
|
||||
void add(int s, int e);
|
||||
void split(int s0, int e0, int s1, int e1);
|
||||
|
||||
public:
|
||||
void add_field(int column, int width);
|
||||
void sort();
|
||||
int find_column(int column, int width) const;
|
||||
bool empty() const;
|
||||
};
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @func Ritorna la stampante corrente
|
||||
|
@ -469,6 +469,13 @@ TReport_field* TReport_section::find_field(int id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int TReport_section::code(TString& code) const
|
||||
{
|
||||
code.format("%c%d", type(), level());
|
||||
return level();
|
||||
}
|
||||
|
||||
|
||||
// Determina se e' possibile mantenere la sezione nella stessa pagina della successiva
|
||||
bool TReport_section::keep_with_next() const
|
||||
{ return _keep_with_next && type() == 'H' && level() > 1; }
|
||||
@ -1527,7 +1534,8 @@ void TReport_field::print(TBook& book) const
|
||||
const TRectangle& pr = print_rect(book); // Calcolo rettangolo dopo aver settato il font!
|
||||
book.set_text_align(horizontal_alignment(), vertical_alignment());
|
||||
book.set_text_color(fore_color(), back_color());
|
||||
book.draw_text(pr, _picture);
|
||||
TString8 sec_code; section().code(sec_code);
|
||||
book.draw_text(pr, _picture, sec_code);
|
||||
}
|
||||
else
|
||||
print_rect(book);
|
||||
@ -1547,18 +1555,20 @@ void TReport_field::print(TBook& book) const
|
||||
book.set_font(print_font());
|
||||
book.set_text_align(horizontal_alignment(), vertical_alignment());
|
||||
book.set_text_color(fore_color(), back_color());
|
||||
TString8 sec_code; section().code(sec_code);
|
||||
|
||||
if (dynamic_height() || _rct.height() > 100) // Multiriga?
|
||||
{
|
||||
TString_array para;
|
||||
TRectangle rect = get_draw_rect();
|
||||
book.compute_text_frame(str, print_font(), rect, para);
|
||||
print_rect(_draw_rct, book); // Stampa eventuale cornice
|
||||
book.draw_text(_draw_rct, para); // Stampa paragrafo
|
||||
print_rect(_draw_rct, book); // Stampa eventuale cornice
|
||||
book.draw_text(_draw_rct, para, sec_code); // Stampa paragrafo
|
||||
}
|
||||
else
|
||||
{
|
||||
const TRectangle& pr = print_rect(book);
|
||||
book.draw_text(pr, str);
|
||||
book.draw_text(pr, str, sec_code);
|
||||
if (link().full())
|
||||
book.draw_link(pr, str, link());
|
||||
}
|
||||
|
@ -180,6 +180,7 @@ public:
|
||||
|
||||
char type() const { return _type; }
|
||||
int level() const { return _level; }
|
||||
int code(TString& code) const; // code = _type+_level = "B12"
|
||||
|
||||
int width() const { return _size.x; }
|
||||
int height() const { return _size.y; }
|
||||
|
@ -265,7 +265,7 @@ protected:
|
||||
public:
|
||||
virtual PNT log2dev(long lx, long ly) const;
|
||||
void update_scroll_range();
|
||||
short log2dev(long size) const;
|
||||
short book2pix(int size) const;
|
||||
|
||||
TAssoc_array& alinks() { return _alinks; }
|
||||
TPointer_array& plinks() { return _plinks; }
|
||||
@ -275,9 +275,9 @@ public:
|
||||
virtual ~TPrint_preview_window();
|
||||
};
|
||||
|
||||
short TPrint_preview_window::log2dev(long sz) const
|
||||
short TPrint_preview_window::book2pix(int sz) const
|
||||
{
|
||||
return short(sz * _zoom / 60);
|
||||
return short(sz * _zoom / 720);
|
||||
}
|
||||
|
||||
PNT TPrint_preview_window::log2dev(long lx, long ly) const
|
||||
@ -419,15 +419,15 @@ void TPrint_preview_window::popup_menu(EVENT* ep)
|
||||
{
|
||||
MENU_ITEM menu[16]; // Stiamo larghi
|
||||
memset(menu, 0, sizeof(menu));
|
||||
menu[0].tag = POPUP_FIRST; menu[0].text = (char*)PR("Prima"); menu[0].enabled = _page > 1;
|
||||
menu[1].tag = POPUP_PREV; menu[1].text = (char*)PR("Indietro"); menu[1].enabled = _page > 1;
|
||||
menu[2].tag = POPUP_NEXT; menu[2].text = (char*)PR("Avanti"); menu[2].enabled = _page < _book->pages();
|
||||
menu[3].tag = POPUP_LAST; menu[3].text = (char*)PR("Ultima"); menu[3].enabled = _page < _book->pages();
|
||||
menu[0].tag = POPUP_FIRST; menu[0].text = (char*)TR("Prima"); menu[0].enabled = _page > 1;
|
||||
menu[1].tag = POPUP_PREV; menu[1].text = (char*)TR("Indietro"); menu[1].enabled = _page > 1;
|
||||
menu[2].tag = POPUP_NEXT; menu[2].text = (char*)TR("Avanti"); menu[2].enabled = _page < _book->pages();
|
||||
menu[3].tag = POPUP_LAST; menu[3].text = (char*)TR("Ultima"); menu[3].enabled = _page < _book->pages();
|
||||
menu[4].tag = -1; menu[4].separator = true;
|
||||
menu[5].tag = POPUP_ZOOMIN; menu[5].text = (char*)PR("Zoom +"); menu[5].enabled = _zoom < 300;
|
||||
menu[6].tag = POPUP_ZOOMOUT; menu[6].text = (char*)PR("Zoom -"); menu[6].enabled = _zoom > 35;
|
||||
menu[5].tag = POPUP_ZOOMIN; menu[5].text = (char*)TR("Zoom +"); menu[5].enabled = _zoom < 300;
|
||||
menu[6].tag = POPUP_ZOOMOUT; menu[6].text = (char*)TR("Zoom -"); menu[6].enabled = _zoom > 35;
|
||||
menu[7].tag = -1; menu[7].separator = true;
|
||||
menu[8].tag = POPUP_GRID; menu[8].text = (char*)PR("Griglia"); menu[8].enabled = true;
|
||||
menu[8].tag = POPUP_GRID; menu[8].text = (char*)TR("Griglia"); menu[8].enabled = true;
|
||||
menu[8].checkable = true; menu[8].checked = _grid;
|
||||
|
||||
const PNT& p = ep->v.mouse.where;
|
||||
@ -622,14 +622,12 @@ TPrint_preview_window::TPrint_preview_window(int x, int y, int dx, int dy, WINDO
|
||||
_page(1), _zoom(100), _grid(false)
|
||||
{
|
||||
_pixmap = true;
|
||||
TConfig ini(CONFIG_GUI, "Preview");
|
||||
_grid = ini.get_bool("Grid");
|
||||
_grid = ini_get_bool(CONFIG_GUI, "Preview", "Grid");
|
||||
}
|
||||
|
||||
TPrint_preview_window::~TPrint_preview_window()
|
||||
{
|
||||
TConfig ini(CONFIG_GUI, "Preview");
|
||||
ini.set("Grid", _grid ? "X" : "");
|
||||
ini_set_string(CONFIG_GUI, "Preview", "Grid", _grid ? "X" : "");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -769,15 +767,13 @@ protected:
|
||||
bool is_ok() const { return win() != NULL_WIN; }
|
||||
virtual PNT log2dev(long x, long y) const;
|
||||
|
||||
|
||||
public:
|
||||
bool print_doc(const TFilename& name);
|
||||
|
||||
TWindow_printer(PRINT_RCD* rcd, const char* title);
|
||||
|
||||
~TWindow_printer();
|
||||
};
|
||||
|
||||
// Converte da coordinate espresse in 1/720 di pollice a coordinate fisiche su carta
|
||||
PNT TWindow_printer::log2dev(long x, long y) const
|
||||
{
|
||||
PNT ptdev;
|
||||
@ -845,6 +841,13 @@ PNT TBook::log2pix(const TPoint& ptlog) const
|
||||
return _printwin->log2dev(ptdev.x, ptdev.y);
|
||||
}
|
||||
|
||||
// Converte da coordinate di stampa (1/720 di pollice) in pixel
|
||||
short TBook::book2pix(int t) const
|
||||
{
|
||||
const PNT pnt = _printwin->log2dev(t, 0);
|
||||
return pnt.h;
|
||||
}
|
||||
|
||||
int TBook::compute_text_frame(const TString& tmp, const TReport_font& font, TRectangle& rect, TString_array& para) const
|
||||
{
|
||||
// Calcola la larghezza massima e l'altezza di 10 righe
|
||||
@ -1013,7 +1016,7 @@ void TBook::set_clip(long top, long bottom)
|
||||
*_out << "</clip>" << endl;
|
||||
}
|
||||
|
||||
void TBook::draw_text(const TRectangle& r, const char* txt)
|
||||
void TBook::draw_text(const TRectangle& r, const char* txt, const char* section)
|
||||
{
|
||||
if (txt && *txt)
|
||||
{
|
||||
@ -1021,17 +1024,18 @@ void TBook::draw_text(const TRectangle& r, const char* txt)
|
||||
if (str.full())
|
||||
{
|
||||
define_frame(r);
|
||||
*_out << "<text>" << endl << str << endl << "</text>" << endl;
|
||||
*_out << "<text owner=" << section << ">" << endl
|
||||
<< str << endl << "</text>" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TBook::draw_text(const TRectangle& r, const TString_array& txt)
|
||||
void TBook::draw_text(const TRectangle& r, const TString_array& txt, const char* section)
|
||||
{
|
||||
if (!txt.empty())
|
||||
{
|
||||
define_frame(r);
|
||||
*_out << "<text>" << endl;
|
||||
*_out << "<text owner=" << section << ">" << endl;
|
||||
for (int i = 0; i < txt.items(); i++)
|
||||
{
|
||||
const char* line = txt.row(i);
|
||||
@ -1182,7 +1186,7 @@ int get_xml_int(const TString& line, const char* attr, int def)
|
||||
|
||||
void TBook::print_doc(TWindow& win, const TFilename& name)
|
||||
{
|
||||
const bool print = win.win() == 883;
|
||||
const bool print = win.win() == PRINTER_WIN;
|
||||
|
||||
if (print)
|
||||
{
|
||||
@ -1235,6 +1239,8 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
TPrint_preview_window& pw = (TPrint_preview_window&)win;
|
||||
pw.alinks().destroy();
|
||||
}
|
||||
else
|
||||
xvt_rect_set_null(&visible);
|
||||
|
||||
TToken_string str(1024, '=');
|
||||
|
||||
@ -1336,8 +1342,8 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
if (str.starts_with("<brush "))
|
||||
{
|
||||
// <brush color=%u pattern=%u />
|
||||
COLOR col = str.get_long(1);
|
||||
PAT_STYLE pat = (PAT_STYLE)str.get_long();
|
||||
const COLOR col = str.get_long(1);
|
||||
const PAT_STYLE pat = (PAT_STYLE)str.get_long();
|
||||
if (pat <= PAT_HOLLOW)
|
||||
win.hide_brush();
|
||||
else
|
||||
@ -1347,10 +1353,12 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
if (str.starts_with("<clip"))
|
||||
{
|
||||
xvt_dwin_set_clip(w, &rct);
|
||||
continue;
|
||||
} else
|
||||
if (str.starts_with("</clip"))
|
||||
{
|
||||
xvt_dwin_set_clip(w, NULL);
|
||||
continue;
|
||||
} else
|
||||
if (str == "<ellipse/>")
|
||||
{
|
||||
@ -1364,8 +1372,8 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
const long y = str.get_long();
|
||||
const long dx= str.get_long();
|
||||
const long dy= str.get_long();
|
||||
_rect.set(x, y, dx, dy);
|
||||
win.log2dev(_rect, rct);
|
||||
_rect.set(x, y, dx, dy); // Rettangolo in 1/720 di pollice
|
||||
win.log2dev(_rect, rct); // Rettangolo in pixel su carta
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<font "))
|
||||
@ -1394,7 +1402,6 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
else
|
||||
img->draw(w, rct);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if (str == "<line/>")
|
||||
@ -1403,7 +1410,6 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
const PNT to = { rct.bottom, rct.right };
|
||||
xvt_dwin_draw_set_pos(w, fr);
|
||||
xvt_dwin_draw_line(w, to);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (str == "<pages/>")
|
||||
@ -1422,27 +1428,19 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
win.hide_pen();
|
||||
else
|
||||
{
|
||||
int thickness = 0;
|
||||
if (width > 0)
|
||||
double t = 0;
|
||||
if (preview)
|
||||
{
|
||||
if (preview)
|
||||
{
|
||||
const TPrint_preview_window& pw = (const TPrint_preview_window&)win;
|
||||
thickness = pw.log2dev(width);
|
||||
}
|
||||
else
|
||||
thickness = width * _phr / 72; // Converte width in 72' di pollice
|
||||
const TPrint_preview_window& pw = (const TPrint_preview_window&)win;
|
||||
t = pw.book2pix(width ? 100*width : 50)/10.0;
|
||||
if (t < 1.0) // Sfuma le linee sottili in anteprima
|
||||
col = blend_colors(col, COLOR_WHITE, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (preview)
|
||||
{
|
||||
const TPrint_preview_window& pw = (const TPrint_preview_window&)win;
|
||||
const double alpha = pw.log2dev(20)/100.0;
|
||||
if (alpha < 1.0)
|
||||
col = blend_colors(col, COLOR_WHITE, alpha);
|
||||
}
|
||||
t = book2pix(width ? 10*width : 5); // width e' in 1/72 di pollice
|
||||
}
|
||||
const int thickness = short(t+0.5); // Arrotonda all'unita' piu' vicina
|
||||
win.set_pen(col, thickness);
|
||||
}
|
||||
continue;
|
||||
@ -1462,7 +1460,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
xvt_dwin_draw_roundrect(w, &rct, rad, rad);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<text>"))
|
||||
if (str.starts_with("<text ")) // <text owner=B1>
|
||||
{
|
||||
paragrafo.destroy();
|
||||
while (!ifs.eof())
|
||||
@ -1475,7 +1473,6 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
advanced_draw_paragraph(win.win(), paragrafo, rct,
|
||||
_horizontal_alignment, _vertical_alignment,
|
||||
default_10row_height);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<text_align "))
|
||||
@ -1524,6 +1521,9 @@ bool TBook::export_text(TFilename& fname, bool signature)
|
||||
if (fname.ends_with(".pdf", true))
|
||||
return export_pdf(fname, signature);
|
||||
|
||||
if (fname.ends_with(".xls", true))
|
||||
return export_excel(fname, signature);
|
||||
|
||||
TToken_string str(1024, '=');
|
||||
|
||||
ifstream ifs(_file);
|
||||
@ -1622,7 +1622,7 @@ bool TBook::export_text(TFilename& fname, bool signature)
|
||||
default : line.overwrite(str, col); break;
|
||||
}
|
||||
} else
|
||||
if (str == "<text>")
|
||||
if (str.starts_with("<text ")) // <text owner=B1>
|
||||
{
|
||||
TString stringona;
|
||||
while (!ifs.eof())
|
||||
@ -1667,6 +1667,162 @@ bool TBook::export_text(TFilename& fname, bool signature)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void reformat_excel(TString& str)
|
||||
{
|
||||
str.trim();
|
||||
|
||||
if (str.not_empty())
|
||||
{
|
||||
bool is_number = true;
|
||||
bool is_mig = false;
|
||||
bool is_dec = false;
|
||||
for (int i = 0; str[i]; i++)
|
||||
{
|
||||
if (strchr("0123456789.,", str[i]) != NULL)
|
||||
{
|
||||
if (str[i] == '.') is_mig = true;
|
||||
if (str[i] == ',') is_dec = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_number = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_number && (is_dec || is_mig))
|
||||
{
|
||||
if (is_mig)
|
||||
str.strip(".");
|
||||
if (is_dec)
|
||||
str.replace(',', '.');
|
||||
const real n = str;
|
||||
str = n.stringe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TBook::export_excel(TFilename& fname, bool signature)
|
||||
{
|
||||
TTabulator tab;
|
||||
|
||||
int row = 0, col = 0, wid = 0;
|
||||
TToken_string str(1024, '=');
|
||||
|
||||
const TPoint res = page_res();
|
||||
|
||||
if (tab.empty()) // dummy test
|
||||
{
|
||||
ifstream ifs(_file);
|
||||
while (!ifs.eof())
|
||||
{
|
||||
ifs.getline(str.get_buffer(), str.size());
|
||||
|
||||
if (str.starts_with("<frame "))
|
||||
{
|
||||
// <frame x=%ld y=%ld dx=%ld dy=%ld />
|
||||
const long x = str.get_long(1);
|
||||
const long y = str.get_long();
|
||||
const long w = str.get_long();
|
||||
row = y * lpi() / res.y;
|
||||
col = x * cpi() / res.x;
|
||||
wid = w * cpi() / res.x;
|
||||
} else
|
||||
if (str.starts_with("<text owner=B"))
|
||||
{
|
||||
// <text owner=B1>
|
||||
const char* section = str.get(1);
|
||||
if (section[0] == 'B' && section[1] > '0')
|
||||
tab.add_field(col, wid);
|
||||
// Raggiunge fine del testo
|
||||
while (str != "</text>" && !ifs.eof())
|
||||
ifs.getline(str.get_buffer(), str.size());
|
||||
} else
|
||||
if (str.starts_with("</page"))
|
||||
break;
|
||||
}
|
||||
tab.sort();
|
||||
}
|
||||
if (!tab.empty())
|
||||
{
|
||||
TString_array page;
|
||||
|
||||
ifstream ifs(_file);
|
||||
ofstream ofs(fname);
|
||||
|
||||
short pageno = 0;
|
||||
while (!ifs.eof())
|
||||
{
|
||||
ifs.getline(str.get_buffer(), str.size());
|
||||
if (str.starts_with("<frame "))
|
||||
{
|
||||
const long x = str.get_long(1);
|
||||
const long y = str.get_long();
|
||||
const long w = str.get_long();
|
||||
row = y * lpi() / res.y;
|
||||
col = x * cpi() / res.x;
|
||||
wid = w * cpi() / res.x;
|
||||
} else
|
||||
if (str.starts_with("<text "))
|
||||
{
|
||||
const char* section = str.get(1);
|
||||
bool do_export = section[1] > '0';
|
||||
if (!do_export)
|
||||
{
|
||||
switch (section[0])
|
||||
{
|
||||
case 'H': do_export = (pageno == 1); break; // Stampa gli header solo sulla prima pagina
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
while (!ifs.eof())
|
||||
{
|
||||
ifs.getline(str.get_buffer(), str.size());
|
||||
if (str == "</text>")
|
||||
break;
|
||||
if (do_export && str.full())
|
||||
{
|
||||
const int pos = tab.find_column(col, wid);
|
||||
if (pos >= 0)
|
||||
{
|
||||
TToken_string* line = (TToken_string*)page.objptr(row);
|
||||
if (line == NULL)
|
||||
{
|
||||
line = new TToken_string(256,'\t');
|
||||
page.add(line, row);
|
||||
}
|
||||
reformat_excel(str);
|
||||
line->add(str, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (str.starts_with("<page"))
|
||||
{
|
||||
pageno = str.get_int(1);
|
||||
} else
|
||||
if (str.starts_with("</page"))
|
||||
{
|
||||
FOR_EACH_ARRAY_ROW(page, i, line) if (line->full())
|
||||
{
|
||||
ofs << *line << endl; // Stampo e...
|
||||
line->cut(0); // ... svuoto
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (signature && main_app().has_module(FDAUT))
|
||||
{
|
||||
char outfile[_MAX_PATH] = "";
|
||||
if (xvt_sign_file(fname, outfile))
|
||||
fname = outfile;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TBook::init()
|
||||
{
|
||||
if (is_pdf())
|
||||
@ -1674,7 +1830,7 @@ bool TBook::init()
|
||||
int size;
|
||||
_rcd = xvt_print_create_by_name(&size, XVT_PDF_PRINTER_NAME);
|
||||
if (_pw > _ph) // width > height -> landscape
|
||||
xvt_app_escape (XVT_ESC_SET_PRINTER_INFO, _rcd, &_ph, &_pw, &_pvr, &_phr); //
|
||||
xvt_app_escape (XVT_ESC_SET_PRINTER_INFO, _rcd, &_ph, &_pw, &_pvr, &_phr);
|
||||
}
|
||||
else
|
||||
_rcd = printer().get_printrcd();
|
||||
@ -1700,7 +1856,6 @@ bool TBook::init()
|
||||
return _printwin->win() != NULL_WIN;
|
||||
}
|
||||
|
||||
|
||||
void TBook::split_file(int colonne)
|
||||
{
|
||||
TProgind pi(pages(), TR("Rigenerazione pagine"), true, true);
|
||||
@ -1862,7 +2017,6 @@ bool TBook::split_file_if_needed()
|
||||
{
|
||||
if (_max_frame.x > 100 && _max_frame.y > 100) // Evita calcolo splitting se possibile
|
||||
{
|
||||
|
||||
const TPoint sheet(_pw, _ph);
|
||||
|
||||
const int spp = _max_frame.x > sheet.x ? (_max_frame.x+sheet.x-1) / sheet.x : 1;
|
||||
@ -2012,6 +2166,12 @@ bool TBook::esporta()
|
||||
if (ok)
|
||||
xvt_sys_goto_url(fname, "open");
|
||||
break;
|
||||
case 'X':
|
||||
case 'x':
|
||||
ok = export_excel(fname, signature);
|
||||
if (ok)
|
||||
xvt_sys_goto_url(fname, "open");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -2393,8 +2553,7 @@ bool TReport_book::init(TReport& rep)
|
||||
if (save_profile && !pr.manual_setup())
|
||||
{
|
||||
const TString profile = rep.filename().name();
|
||||
TConfig prini(CONFIG_STAMPE, profile);
|
||||
const TString& rep_printer = prini.get("Name");
|
||||
const TString& rep_printer = ini_get_string(CONFIG_STAMPE, profile, "Name");
|
||||
const TString& cur_printer = pr.printername();
|
||||
if (rep_printer.full() && rep_printer != cur_printer)
|
||||
{
|
||||
|
@ -37,6 +37,7 @@ protected:
|
||||
virtual bool init();
|
||||
TPoint log2dev(const TPoint& ptlog) const;
|
||||
PNT log2pix(const TPoint& ptlog) const;
|
||||
short book2pix(int thickness) const;
|
||||
void print_doc(TWindow& win, const TFilename& name);
|
||||
void close_output();
|
||||
|
||||
@ -61,8 +62,8 @@ public:
|
||||
virtual void draw_ellipse(const TRectangle& rect);
|
||||
virtual void draw_line(const TRectangle& rect);
|
||||
virtual void draw_image(const TRectangle& rect, const char* filename);
|
||||
virtual void draw_text(const TRectangle& rect, const char* text);
|
||||
virtual void draw_text(const TRectangle& rect, const TString_array& text);
|
||||
virtual void draw_text(const TRectangle& rect, const char* text, const char* owner);
|
||||
virtual void draw_text(const TRectangle& rect, const TString_array& text, const char* owner);
|
||||
virtual void draw_link(const TRectangle& rect, const char* text, const char* link);
|
||||
virtual void draw_book_pages(const TRectangle& r);
|
||||
virtual void set_clip(long top, long bottom);
|
||||
@ -89,6 +90,7 @@ public:
|
||||
virtual bool archive(const char* repname, bool signature);
|
||||
virtual bool preview();
|
||||
|
||||
virtual bool export_excel(TFilename& fname, bool signature);
|
||||
virtual bool export_pdf(TFilename& fname, bool signature);
|
||||
virtual bool export_text(TFilename& fname, bool signature);
|
||||
virtual bool send_mail(TFilename& fname, bool signature);
|
||||
|
@ -266,7 +266,7 @@ TSheet_control::TSheet_control(
|
||||
}
|
||||
|
||||
// Attenzione: negli sheet molto grandi succede che rd.right < 0
|
||||
RCT rd; xi_get_def_rect(listdef, (XinRect *) &rd);
|
||||
XI_RCT rd; xi_get_def_rect(listdef, &rd);
|
||||
if (rd.right < 0 || (rd.right - rd.left) > (rct.right - rct.left))
|
||||
l->width = rct.right - rct.left;
|
||||
|
||||
@ -296,7 +296,7 @@ TSheet_control::TSheet_control(
|
||||
XI_OBJ** column = xi_get_member_list(_obj, &num);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
RCT rct; xi_get_rect(column[i], (XinRect*)&rct);
|
||||
XI_RCT rct; xi_get_rect(column[i], &rct);
|
||||
_default_width[i] = rct.right - rct.left;
|
||||
}
|
||||
}
|
||||
@ -359,14 +359,14 @@ void TSheet_control::update(long n)
|
||||
{
|
||||
int num = 0;
|
||||
const long* handle = xi_get_list_info(_obj, &num);
|
||||
|
||||
bool scroll_first = items() == 0; // || !owner().mask().is_running();
|
||||
const long tot = items();
|
||||
bool scroll_first = tot == 0; // || !owner().mask().is_running();
|
||||
if (!scroll_first)
|
||||
{
|
||||
int first = 0, last = 0;
|
||||
xi_get_visible_rows(_obj, &first, &last);
|
||||
n = handle[first];
|
||||
scroll_first = n > items();
|
||||
scroll_first = n > tot;
|
||||
}
|
||||
|
||||
if (scroll_first)
|
||||
@ -760,7 +760,7 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
{
|
||||
case 'C': // Set value for "checkable" cell
|
||||
{
|
||||
const bool on = col == 0 ? checked(rec) : row(rec).get_char(col) > ' ';
|
||||
const bool on = col == 0 ? checked(rec) : row(rec).get_char(col) > '0';
|
||||
xiev->v.cell_request.icon_rid = on ? ICO_CHECK_ON : ICO_CHECK_OFF;
|
||||
}
|
||||
break;
|
||||
@ -771,14 +771,14 @@ bool TSheet_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
{
|
||||
const real r = row(rec).get(col);
|
||||
TCurrency c(r);
|
||||
src = c.string(TRUE);
|
||||
src = c.string(true);
|
||||
}
|
||||
break;
|
||||
case 'P': // Set value for "price" cell
|
||||
{
|
||||
const real r = row(rec).get(col);
|
||||
TPrice c(r);
|
||||
src = c.string(TRUE);
|
||||
src = c.string(true);
|
||||
}
|
||||
break;
|
||||
default: // Set value for "normal" cell
|
||||
|
@ -28,6 +28,7 @@ KEY spotlite_ask_name(TFilename& pdf)
|
||||
TApplication& a = main_app();
|
||||
const bool can_arc = a.has_module(RSAUT);
|
||||
const bool can_sign = can_arc && a.has_module(FDAUT);
|
||||
msk.enable(DLG_EXPORT, can_arc);
|
||||
msk.enable(DLG_PDF, can_arc);
|
||||
msk.enable(DLG_SIGNPDF, can_sign);
|
||||
|
||||
@ -72,6 +73,10 @@ KEY spotlite_ask_name(TFilename& pdf)
|
||||
case 'e':
|
||||
pdf.ext("txt");
|
||||
break;
|
||||
case 'X':
|
||||
case 'x':
|
||||
pdf.ext("xls");
|
||||
break;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
110
include/text.cpp
110
include/text.cpp
@ -418,24 +418,21 @@ void TTextfile::read_line (
|
||||
//
|
||||
// @rdesc Ritorna la stringa di caratteri ed eventualmente con i campi sostituiti
|
||||
// se la relazione non e' NULL
|
||||
const char *TTextfile::line(
|
||||
const char* TTextfile::line(
|
||||
long j, // @parm Riga di cui ritornare la stringa
|
||||
long pos, // @parm Colonna di cui ritornare la stringa
|
||||
int howmuch) // @parm Numero di caratteri utili della stringa da ritornare (default -1)
|
||||
int howmuch) // @parm Numero di caratteri utili della stringa da ritornare (default -1)
|
||||
|
||||
// @comm Se <p howmuch> assume valore -1 ritorna tutta la pagina
|
||||
{
|
||||
if (_cur_line != j)
|
||||
read_line (j);
|
||||
|
||||
*TEXT_TMP = '\0';
|
||||
/*
|
||||
_line.restart ();
|
||||
for (int i = 0; i < _line.items (); i++)
|
||||
strcat (TEXT_TMP, (const char *) _line.get ());
|
||||
*/
|
||||
FOR_EACH_TOKEN(_line, l)
|
||||
strcat (TEXT_TMP, l);
|
||||
if (howmuch != -1)
|
||||
|
||||
if (howmuch >= 0)
|
||||
{
|
||||
if (((unsigned int)pos+howmuch) < strlen(TEXT_TMP))
|
||||
TEXT_TMP[pos+howmuch] = '\0';
|
||||
@ -776,11 +773,9 @@ bool TTextfile::write (
|
||||
TPoint * from, // @parm Punto da cui iniziare a scrivere il testo
|
||||
TPoint * to) // @parm Punto a cui terminare di scrivere il testo
|
||||
{
|
||||
bool ok = FALSE;
|
||||
FILE *fp;
|
||||
if ((fp = fopen (path, "w")) != NULL)
|
||||
FILE* fp = fopen(path, "w");
|
||||
if (fp != NULL)
|
||||
{
|
||||
ok = TRUE;
|
||||
TString s(512);
|
||||
long starty = from == NULL ? 0l : from->y;
|
||||
int startx = from == NULL ? 0 : (int) from->x;
|
||||
@ -805,7 +800,7 @@ bool TTextfile::write (
|
||||
}
|
||||
else
|
||||
warning_box ("Impossibile scrivere il file %s; scrittura fallita", path);
|
||||
return ok;
|
||||
return fp != NULL;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -839,6 +834,91 @@ void TTextfile::write(
|
||||
}
|
||||
}
|
||||
|
||||
// Determina il tipo di una stringa: 0=ignoto; 1=stringa; 2=numero
|
||||
static int str_type(TString& str)
|
||||
{
|
||||
str.trim();
|
||||
bool is_string = false;
|
||||
bool is_number = str.full();
|
||||
for (int i=0; str[i]; i++)
|
||||
{
|
||||
if (isalnum(str[i]))
|
||||
is_string = true;
|
||||
if (strchr("0123456789,.", str[i]) == NULL)
|
||||
is_number = false;
|
||||
}
|
||||
if (is_number)
|
||||
{
|
||||
str.strip(".");
|
||||
str.replace(',', '.');
|
||||
const real r(str);
|
||||
str = r.stringe();
|
||||
}
|
||||
return is_number ? 2 : (is_string ? 1 : 0);
|
||||
}
|
||||
|
||||
bool TTextfile::write_xls(const TFilename& xls)
|
||||
{
|
||||
const int headerlen = printer().headersize();
|
||||
const int footerlen = printer().footersize();
|
||||
const int pagelen = printer().formlen();
|
||||
TString str;
|
||||
|
||||
TTabulator tab;
|
||||
for (long j = headerlen; j < _lines && j < pagelen; j++)
|
||||
{
|
||||
const int row = j % pagelen;
|
||||
if (row >= headerlen && row < pagelen-footerlen)
|
||||
{
|
||||
read_line(j);
|
||||
int x = 0;
|
||||
for (const char* cp = piece(); cp; cp = piece())
|
||||
{
|
||||
str = cp;
|
||||
const int len = str.len();
|
||||
if (str.full())
|
||||
{
|
||||
if (str_type(str) > 0)
|
||||
tab.add_field(x, len);
|
||||
}
|
||||
x += len;
|
||||
}
|
||||
}
|
||||
}
|
||||
tab.sort();
|
||||
|
||||
TToken_string riga(256, '\t');
|
||||
|
||||
ofstream out(xls);
|
||||
for (long j = 0; j < _lines; j++)
|
||||
{
|
||||
const int row = j % pagelen;
|
||||
// Esporto la testata solo nella prima pagina ed il footer solo nell'ultima
|
||||
if ((row < headerlen && j >= pagelen) || (row >= pagelen-footerlen && row < _lines-pagelen))
|
||||
continue;
|
||||
|
||||
read_line(j);
|
||||
riga.cut(0);
|
||||
int x = 0;
|
||||
for (const char* cp = piece(); cp; cp = piece())
|
||||
{
|
||||
str = cp;
|
||||
const int len = str.len();
|
||||
const int st = str_type(str);
|
||||
if (st > 0)
|
||||
{
|
||||
const int pos = tab.find_column(x, len);
|
||||
if (pos >= 0)
|
||||
riga.add(str, pos);
|
||||
}
|
||||
x += len;
|
||||
}
|
||||
if (riga.full())
|
||||
out << riga << endl;
|
||||
}
|
||||
return xls.exist();
|
||||
}
|
||||
|
||||
void TTextfile::destroy ()
|
||||
{
|
||||
CHECK(_istemp, "destroy() chiamata su testo permanente!");
|
||||
@ -848,8 +928,8 @@ void TTextfile::destroy ()
|
||||
fclose (_index);
|
||||
if (_instr)
|
||||
fclose (_instr);
|
||||
remove ((const char *) _filename);
|
||||
remove ((const char *) _indname);
|
||||
_filename.fremove();
|
||||
_indname.fremove();
|
||||
_page_start = _lines = 0l;
|
||||
_page_end = _cur_line = -1l;
|
||||
_accept = TRUE;
|
||||
|
@ -137,7 +137,7 @@ public:
|
||||
void print();
|
||||
// @cmember Chiude l'aggiunta di nuove linee
|
||||
void freeze()
|
||||
{ _accept = FALSE; }
|
||||
{ _accept = false; }
|
||||
// @cmember Ritorna se e' possibile aggiungere delle nuove righe (TRUE se non vengono accettate)
|
||||
bool frozen()
|
||||
{ return !_accept; }
|
||||
@ -173,6 +173,9 @@ public:
|
||||
bool write(const char* path, TPoint* from = NULL, TPoint* to = NULL);
|
||||
// @cmember Scrive il testo (non formattato) su TString_array
|
||||
void write(TString_array& a, TPoint* from = NULL, TPoint* to = NULL);
|
||||
// @cmember Scrive il testo (non formattato) su file xls (tab separated text)
|
||||
bool write_xls(const TFilename& xls);
|
||||
|
||||
// @cmember Disfa tutto e svuota il file
|
||||
void destroy();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <printapp.h>
|
||||
#include <spotlite.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
#include <viswin.h>
|
||||
|
||||
#include <bagn005.h>
|
||||
@ -2264,6 +2265,11 @@ bool TViswin::call_editor()
|
||||
if (ok)
|
||||
spotlite_notify(pdf);
|
||||
break;
|
||||
case 'X':
|
||||
ok = _txt.write_xls(pdf);
|
||||
if (ok)
|
||||
::edit_url(pdf);
|
||||
break;
|
||||
case 'E':
|
||||
if (_isselection)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user