Migliorata esportazione in Excel di stampe vecchio stile
git-svn-id: svn://10.65.10.50/branches/R_10_00@22980 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f7b3d60860
commit
3de99221c0
@ -6,6 +6,7 @@
|
||||
#define ANG_NATGIU "NATGIU"
|
||||
#define ANG_STATOSOC "STATOSOC"
|
||||
#define ANG_SITSOC "SITSOC"
|
||||
#define ANG_CAPSOC "CAPSOC"
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,18 +1,14 @@
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#ifndef INCL_XVTH
|
||||
#include <xvt.h>
|
||||
#ifndef __DICTION_H
|
||||
#include <diction.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ASSOC_H
|
||||
#include <assoc.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DICTION_H
|
||||
#include <diction.h>
|
||||
#endif
|
||||
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message link (printapp -> relapp)
|
||||
|
@ -94,6 +94,8 @@
|
||||
#define DOC_CIG "CIG"
|
||||
#define DOC_CONTSEP "CONTSEP"
|
||||
#define DOC_NOLEGGIO "NOLEGGIO"
|
||||
#define DOC_MODPAG "MODPAG"
|
||||
#define DOC_CONTRATTO "CONTRATTO"
|
||||
#define DOC_PAF "PAF"
|
||||
|
||||
// Virtuali
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Disble annoying vsprintf warnings
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <about.h>
|
||||
#include <automask.h>
|
||||
#include <colors.h>
|
||||
@ -31,6 +34,7 @@ HIDDEN void smart_trim(
|
||||
)
|
||||
|
||||
{
|
||||
/*
|
||||
switch (mode)
|
||||
{
|
||||
case 1: s.ltrim(); break;
|
||||
@ -38,6 +42,9 @@ HIDDEN void smart_trim(
|
||||
case 3: s.trim(); break;
|
||||
default: break;
|
||||
}
|
||||
*/
|
||||
if (mode & 2) s.rtrim();
|
||||
if (mode & 1) s.ltrim();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -56,7 +63,7 @@ TMask_field::TField_Flags::TField_Flags()
|
||||
roman = read_only = false;
|
||||
firm = ghost = false;
|
||||
password = false;
|
||||
trim = 3;
|
||||
trim = 0x3;
|
||||
pipeallowed = false;
|
||||
user = false;
|
||||
}
|
||||
@ -407,7 +414,8 @@ void TMask_field::construct(TScanner& scanner, WINDOW parent)
|
||||
long mod = _modules->last_one();
|
||||
for (; mod > BAAUT; mod--)
|
||||
{
|
||||
if (in_module(mod) && main_app().has_module(mod))
|
||||
const word m = (word)mod;
|
||||
if (in_module(m) && main_app().has_module(m))
|
||||
break;
|
||||
}
|
||||
if (mod <= 0)
|
||||
@ -3090,8 +3098,31 @@ void TReal_field::create(WINDOW w)
|
||||
TMask_field::set(prefix().get_codditta());
|
||||
}
|
||||
else
|
||||
if (automagic())
|
||||
TMask_field::set(TDate(TODAY).year());
|
||||
if (automagic() && size() == 4 && decimals() == 0)
|
||||
{
|
||||
const TDate oggi(TODAY);
|
||||
int anno = oggi.year(); // Anno solare o ...
|
||||
if (has_query_button() && browse() != NULL && browse()->cursor() != NULL)
|
||||
{
|
||||
TCursor& cur = *browse()->cursor();
|
||||
const TRectype& esc = cur.curr();
|
||||
if (esc.num() == LF_TAB) // ... codice esercizio?
|
||||
{
|
||||
const TRecnotype ne = cur.items();
|
||||
for (cur = ne-1; cur.ok(); --cur)
|
||||
{
|
||||
const TDate dataini = esc.get("D0");
|
||||
const TDate datafin = esc.get("D1");
|
||||
if (oggi >= dataini && oggi <= datafin)
|
||||
{
|
||||
anno = esc.get_int("CODTAB");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TMask_field::set(anno);
|
||||
}
|
||||
}
|
||||
|
||||
bool TReal_field::parse_item(TScanner& scanner)
|
||||
@ -3642,8 +3673,7 @@ void TList_field::add_list()
|
||||
}
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
char num[4]; sprintf(num, "%02d", i);
|
||||
_codes.add(num);
|
||||
_codes.add(format("%02d", i));
|
||||
_values.add(itom(i));
|
||||
}
|
||||
|
||||
|
@ -2332,7 +2332,7 @@ bool TPrinter::is_landscape() const
|
||||
|
||||
class TTab_info : public TObject
|
||||
{
|
||||
int _start, _end;
|
||||
int _start, _end, _col;
|
||||
|
||||
public:
|
||||
int intersection(int s, int e) const;
|
||||
@ -2340,11 +2340,14 @@ public:
|
||||
|
||||
void set_start(int s) { _start = s; }
|
||||
void set_end(int e) { _end = e; }
|
||||
void set(int s, int e) { _start = s; _end = e; }
|
||||
void set_column(int c) { _col = c; }
|
||||
void set(int s, int e) { _start = s; _end = e; _col = -1; }
|
||||
int start() const { return _start; }
|
||||
int end() const { return _end; }
|
||||
int width() const { return _end - _start + 1; }
|
||||
int column() const { return _col; }
|
||||
bool operator==(const TTab_info& ti) const { return _start == ti.start() && _end == ti.end(); }
|
||||
bool operator!=(const TTab_info& ti) const { return _start != ti.start() || _end != ti.end(); }
|
||||
|
||||
TTab_info(int s, int e) { set(s, e); }
|
||||
};
|
||||
@ -2378,82 +2381,52 @@ void TTabulator::split(int s0, int e0, int s1, int 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
|
||||
bool TTabulator::find_column(int column, int width, int &idx, int& col) const
|
||||
{
|
||||
int start = column;
|
||||
int end = column + width - 1;
|
||||
int inter = 0;
|
||||
|
||||
int index = -1, inter = 0;
|
||||
idx = col = -1;
|
||||
|
||||
FOR_EACH_ARRAY_ITEM(_tab, t, obj)
|
||||
{
|
||||
TTab_info& ti = *(TTab_info*)obj;
|
||||
const TTab_info& ti = *(TTab_info*)obj;
|
||||
const int i = ti.intersection(start, end);
|
||||
if (i > inter)
|
||||
{
|
||||
inter = i;
|
||||
index = t;
|
||||
idx = t;
|
||||
col = ti.column();
|
||||
}
|
||||
}
|
||||
return index;
|
||||
return idx >= 0;
|
||||
}
|
||||
|
||||
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();
|
||||
int d = t0.start() - t1.start();
|
||||
if (d == 0)
|
||||
d = t0.end() - t1.end();
|
||||
return d;
|
||||
}
|
||||
|
||||
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)
|
||||
int idx, col;
|
||||
if (find_column(column, width, idx, col))
|
||||
{
|
||||
const TTab_info& ti = (const TTab_info&)_tab[index];
|
||||
const TTab_info& ti = (const TTab_info&)_tab[idx];
|
||||
if (ti.intersection(start, end) < width)
|
||||
{
|
||||
split(start, end, ti.start(), ti.end());
|
||||
_tab.destroy(index, true);
|
||||
_tab.destroy(idx, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2484,19 +2457,36 @@ void TTabulator::sort()
|
||||
_tab.destroy(i);
|
||||
else
|
||||
{
|
||||
if (t1.start() - t0.end() >= 8)
|
||||
const int gap = t1.start() - t0.end();
|
||||
if (gap > 0)
|
||||
{
|
||||
_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);
|
||||
if (gap >= 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int col = 0;
|
||||
for (int i = 0; i < _tab.items(); i++)
|
||||
{
|
||||
TTab_info& ti = (TTab_info&)_tab[i];
|
||||
if (i > 0)
|
||||
{
|
||||
const TTab_info& tj = (const TTab_info&)_tab[i-1];
|
||||
if (ti.start() > tj.start())
|
||||
col++;
|
||||
}
|
||||
ti.set_column(col);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -782,7 +782,7 @@ protected:
|
||||
public:
|
||||
void add_field(int column, int width);
|
||||
void sort();
|
||||
int find_column(int column, int width) const;
|
||||
bool find_column(int column, int width, int &idx, int& col) const;
|
||||
bool empty() const;
|
||||
};
|
||||
|
||||
|
@ -327,7 +327,7 @@ TTimerind::~TTimerind()
|
||||
bool TProgress_monitor::set_status(long n)
|
||||
{
|
||||
// Aggiunsto timer iniziale se necessario
|
||||
if (_status <= 0 && n <= 0)
|
||||
if (_status <= 0L && n <= 0L)
|
||||
_start = clock();
|
||||
|
||||
// Se sono passati 1 secondi e sono a meno di metà lavoro allora crea la TProgind
|
||||
@ -349,6 +349,17 @@ void TProgress_monitor::set_text(const char* msg)
|
||||
_pi->set_text(_txt);
|
||||
}
|
||||
|
||||
void TProgress_monitor::set_max(long tot)
|
||||
{
|
||||
if (tot != _total)
|
||||
{
|
||||
_total = tot;
|
||||
if (_pi != NULL)
|
||||
_pi->setmax(tot);
|
||||
set_status(_status = 0L); // Forza aggiornamento timer e barra
|
||||
}
|
||||
}
|
||||
|
||||
TProgress_monitor::TProgress_monitor(long items, const char* txt, bool cancancel)
|
||||
: _total(items), _txt(txt), _status(0), _cancellable(cancancel), _pi(NULL), _start(clock())
|
||||
{
|
||||
|
@ -173,6 +173,7 @@ class TProgress_monitor : public TObject
|
||||
|
||||
public:
|
||||
virtual bool set_status(long n);
|
||||
void set_max(long tot);
|
||||
bool add_status(long i = 1) { return set_status(_status+i); }
|
||||
void set_text(const char* msg);
|
||||
|
||||
|
@ -1282,22 +1282,21 @@ const char *real::ita2eng (const char *s)
|
||||
__string = tmp.get_buffer(strlen(s));
|
||||
|
||||
int j = 0;
|
||||
if (s)
|
||||
for (int i = 0; s[i]; i++)
|
||||
for (int i = 0; s[i]; i++)
|
||||
{
|
||||
switch (s[i])
|
||||
{
|
||||
switch (s[i])
|
||||
{
|
||||
case ' ':
|
||||
case '.':
|
||||
break;
|
||||
case ',':
|
||||
__string[j++] = '.';
|
||||
break;
|
||||
default:
|
||||
__string[j++] = s[i];
|
||||
break;
|
||||
}
|
||||
case ' ':
|
||||
case '.':
|
||||
break;
|
||||
case ',':
|
||||
__string[j++] = '.';
|
||||
break;
|
||||
default:
|
||||
__string[j++] = s[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
__string[j] = '\0';
|
||||
}
|
||||
return __string;
|
||||
@ -1310,9 +1309,9 @@ bool real::is_null(const char *s)
|
||||
{
|
||||
for (const char* n = s; *n; n++)
|
||||
{
|
||||
if (strchr("123456789", *n) != NULL)
|
||||
if (*n >= '1' && *n <= '9')
|
||||
{
|
||||
z = FALSE;
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
if (strchr(" ,-.0", *n) == NULL)
|
||||
@ -1331,7 +1330,7 @@ bool real::is_natural (const char *s)
|
||||
s++; // Remove leading spaces before
|
||||
if (*s)
|
||||
{
|
||||
while (isdigit(*s))
|
||||
while (*s >= '0' && *s <= '9') // isdigit may fail on non ASCII characters
|
||||
s++;
|
||||
ok = *s == '\0';
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ bool TRelation_application::autonum(
|
||||
k = get_next_key();
|
||||
#ifdef DBG
|
||||
if (k.full())
|
||||
NFCHECK("'const char* get_next_key()' is deprecated: implement 'bool get_next_key(TToken_string&)'");
|
||||
xvt_dm_popup_warning("'const char* get_next_key()' is deprecated: implement 'bool get_next_key(TToken_string&)'");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1827,8 +1827,8 @@ bool TBook::export_excel(TFilename& fname, bool signature)
|
||||
break;
|
||||
if (do_export && str.full())
|
||||
{
|
||||
const int pos = tab.find_column(col, wid);
|
||||
if (pos >= 0)
|
||||
int idx, pos;
|
||||
if (tab.find_column(col, wid, idx, pos))
|
||||
{
|
||||
TToken_string* line = (TToken_string*)page.objptr(row);
|
||||
if (line == NULL)
|
||||
|
@ -838,13 +838,16 @@ void TTextfile::write(
|
||||
static int str_type(TString& str)
|
||||
{
|
||||
str.trim();
|
||||
if (str.empty())
|
||||
return 0;
|
||||
bool is_string = false;
|
||||
bool is_number = str.full();
|
||||
bool is_number = true;
|
||||
for (int i=0; str[i]; i++)
|
||||
{
|
||||
if (isalnum(str[i]))
|
||||
const char c = str[i];
|
||||
if (c < '\0' || isalnum(c))
|
||||
is_string = true;
|
||||
if (strchr("0123456789,.", str[i]) == NULL)
|
||||
if (strchr("0123456789,.", c) == NULL)
|
||||
is_number = false;
|
||||
}
|
||||
if (is_number)
|
||||
@ -859,29 +862,48 @@ static int str_type(TString& str)
|
||||
|
||||
bool TTextfile::write_xls(const TFilename& xls)
|
||||
{
|
||||
const int headerlen = printer().headersize();
|
||||
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++)
|
||||
int tabstart = 1;
|
||||
int tabstop = pagelen - footerlen;
|
||||
if (_lines < tabstop) tabstop = _lines;
|
||||
|
||||
if (headerlen <= 0) // Cerca di capire l'inizio della testata
|
||||
{
|
||||
const int row = j % pagelen;
|
||||
if (row >= headerlen && row < pagelen-footerlen)
|
||||
for (long j = 1; j < 12 && j < tabstop; j++)
|
||||
{
|
||||
read_line(j);
|
||||
int x = 0;
|
||||
for (const char* cp = piece(); cp; cp = piece())
|
||||
str = piece(); str.trim();
|
||||
if (str.len() >= 64 && (str.starts_with("________") || str.starts_with("--------") || str.starts_with("========")))
|
||||
{
|
||||
str = cp;
|
||||
const int len = str.len();
|
||||
if (str.full() && str_type(str) > 0)
|
||||
tab.add_field(x, len);
|
||||
x += len;
|
||||
if (tabstart <= 1)
|
||||
tabstart = j+1;
|
||||
else
|
||||
{
|
||||
tabstop = j;
|
||||
headerlen = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TTabulator tab;
|
||||
for (long j = tabstart; j < tabstop; j++)
|
||||
{
|
||||
read_line(j);
|
||||
int x = 0;
|
||||
for (const char* cp = piece(); cp; cp = piece())
|
||||
{
|
||||
str = cp;
|
||||
const int len = str.len();
|
||||
if (str_type(str) > 0)
|
||||
tab.add_field(x, len);
|
||||
x += len;
|
||||
}
|
||||
}
|
||||
tab.sort();
|
||||
|
||||
TToken_string riga(256, '\t');
|
||||
@ -904,9 +926,14 @@ bool TTextfile::write_xls(const TFilename& xls)
|
||||
const int st = str_type(str);
|
||||
if (st > 0)
|
||||
{
|
||||
const int pos = tab.find_column(x, len);
|
||||
if (pos >= 0)
|
||||
int idx, pos;
|
||||
if (tab.find_column(x, len, idx, pos))
|
||||
{
|
||||
const char* old = riga.get(pos);
|
||||
if (old && *old)
|
||||
str.insert(old);
|
||||
riga.add(str, pos);
|
||||
}
|
||||
}
|
||||
x += len;
|
||||
}
|
||||
|
@ -561,9 +561,9 @@ long daytime()
|
||||
}
|
||||
|
||||
// DON'T cache this bool because hostname can be local or server
|
||||
static bool is_aga_station(const char* hostname)
|
||||
static bool is_sirio_station(const char* hostname)
|
||||
{
|
||||
const char* const ranger[] = { "BATMOBILE", "KIRK", "KLINGON", "MOBILE", "PCTRUFFELLI", "SPOCK", NULL };
|
||||
const char* const ranger[] = { "NBKCORRADIW81", "KIRK", "KLINGON", "MOBILE", "PCTRUFFELLI", "SPOCK", NULL };
|
||||
for (int i = 0; ranger[i]; i++)
|
||||
if (xvt_str_compare_ignoring_case(hostname, ranger[i]) == 0)
|
||||
return true;
|
||||
@ -577,8 +577,8 @@ bool is_power_station()
|
||||
{
|
||||
const TDongle& d = dongle();
|
||||
if ((d.local() && (d.number() == 0 || d.number()==1045)) ||
|
||||
(d.network() && is_aga_station(d.server_name())))
|
||||
ps = is_aga_station(get_hostname());
|
||||
(d.network() && is_sirio_station(d.server_name())))
|
||||
ps = is_sirio_station(get_hostname());
|
||||
else
|
||||
ps = FALSE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user