MeOS version 3.4.717

This commit is contained in:
erikmelin 2017-08-30 08:57:46 +02:00
parent 9f315504a4
commit 54cdf1c235
382 changed files with 211285 additions and 0 deletions

522
code/HTMLWriter.cpp Normal file
View File

@ -0,0 +1,522 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "gdioutput.h"
#include <vector>
#include <map>
#include <cassert>
#include <algorithm>
#include <cmath>
#include "meos_util.h"
#include "Localizer.h"
#include "gdiconstants.h"
double getLocalScale(const string &fontName, string &faceName);
string getMeosCompectVersion();
static void generateStyles(ostream &fout, bool withTbl, const list<TextInfo> &TL,
map< pair<gdiFonts, string>, pair<string, string> > &styles) {
fout << "<style type=\"text/css\">\n";
fout << "body {background-color: rgb(250,250,255)}\n";
fout << "h1 {font-family:arial,sans-serif;font-size:24px;font-weight:normal;white-space:nowrap}\n";
fout << "h2 {font-family:arial,sans-serif;font-size:20px;font-weight:normal;white-space:nowrap}\n";
fout << "h3 {font-family:arial,sans-serif;font-size:16px;font-weight:normal;white-space:nowrap}\n";
fout << "p {font-family:arial,sans-serif;font-size:12px;font-weight:normal}\n";
fout << "div {font-family:arial,sans-serif;font-size:12px;font-weight:normal}\n";
if (withTbl) {
fout << "td {font-family:arial,sans-serif;font-size:12px;font-weight:normal;white-space:nowrap}\n";
fout << "td.e0 {background-color: rgb(238,238,255)}\n";
fout << "td.e1 {background-color: rgb(245,245,255)}\n";
fout << "td.header {line-height:1.8;height:40px}\n";
fout << "td.freeheader {line-height:1.2}\n";
}
list<TextInfo>::const_iterator it=TL.begin();
int styleList = 1;
while (it != TL.end()) {
gdiFonts font = it->getGdiFont();
if (!it->font.empty() || (font == italicMediumPlus)
|| (font == fontMediumPlus)) {
if (styles.find(make_pair(font, it->font)) != styles.end()) {
++it;
continue;
}
string style = "sty" + itos(styleList++);
string element = "div";
double baseSize = 12;
switch (font) {
case boldHuge:
element = "h1";
baseSize = 24;
break;
case boldLarge:
case fontLarge:
element = "h2";
baseSize = 20;
break;
case fontMedium:
element = "h3";
baseSize = 16;
break;
case fontMediumPlus:
case italicMediumPlus:
baseSize = 18;
break;
case fontSmall:
case italicSmall:
case boldSmall:
baseSize = 10;
break;
}
string faceName;
double scale = 1.0;
if (it->font.empty()) {
faceName = "arial,sans-serif";
}
else
scale = getLocalScale(it->font, faceName);
fout << element << "." << style
<< "{font-family:" << faceName << ";font-size:"
<< itos(int(floor(scale * baseSize + 0.5)))
<< "px;font-weight:normal;white-space:nowrap}\n";
styles[make_pair(font, it->font)] = make_pair(element, style);
}
++it;
}
fout << "</style>\n";
}
static void getStyle(const map< pair<gdiFonts, string>, pair<string, string> > &styles,
gdiFonts font, const string &face, const string &extraStyle, string &starttag, string &endtag) {
starttag.clear();
endtag.clear();
string extra;
switch (font) {
case boldText:
case boldSmall:
extra = "b";
break;
case italicSmall:
case italicText:
case italicMediumPlus:
extra = "i";
break;
}
pair<gdiFonts, string> key(font, face);
map< pair<gdiFonts, string>, pair<string, string> >::const_iterator res = styles.find(key);
if (res != styles.end()) {
const pair<string, string> &stylePair = res->second;
if (!stylePair.first.empty()) {
starttag = "<" + stylePair.first;
if (!stylePair.second.empty())
starttag += " class=\"" + stylePair.second + "\"";
starttag += extraStyle;
starttag += ">";
}
if (!extra.empty()) {
starttag += "<" + extra + ">";
endtag = "</" + extra + ">";
}
if (!stylePair.first.empty()) {
endtag += "</" + stylePair.first + ">";
}
}
else {
string element;
switch(font) {
case boldHuge:
element="h1";
break;
case boldLarge:
element="h2";
break;
case fontLarge:
element="h2";
break;
case fontMedium:
element="h3";
break;
}
if (!extraStyle.empty() && element.empty())
element = "div";
if (element.size()>0) {
starttag = "<" + element + extraStyle + ">";
}
if (!extra.empty()) {
starttag += "<" + extra + ">";
endtag = "</" + extra + ">";
}
if (element.size()>0) {
endtag += "</" + element + ">";
}
}
}
bool gdioutput::writeHTML(const wstring &file, const string &title, int refreshTimeOut) const
{
ofstream fout(file.c_str());
if (fout.bad())
return false;
fout << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n" <<
" \"http://www.w3.org/TR/html4/loose.dtd\">\n\n";
fout << "<html>\n<head>\n";
fout << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
if (refreshTimeOut > 0)
fout << "<meta http-equiv=\"refresh\" content=\"" << refreshTimeOut << "\">\n";
fout << "<title>" << toUTF8(title) << "</title>\n";
map< pair<gdiFonts, string>, pair<string, string> > styles;
generateStyles(fout, false, TL, styles);
fout << "</head>\n";
fout << "<body>\n";
list<TextInfo>::const_iterator it = TL.begin();
double yscale = 1.3;
double xscale = 1.2;
int offsetY = 0;
while (it!=TL.end()) {
if (skipTextRender(it->format)) {
++it;
continue;
}
string yp = itos(int(yscale*it->yp) + offsetY);
string xp = itos(int(xscale *it->xp));
string estyle;
if (it->format!=1 && it->format!=boldSmall) {
if (it->format & textRight)
estyle = " style=\"position:absolute;left:" +
xp + "px;top:" + yp + "px\"";
else
estyle = " style=\"position:absolute;left:" +
xp + "px;top:" + yp + "px\"";
}
else {
if (it->format & textRight)
estyle = " style=\"font-weight:bold;position:absolute;left:" +
xp + "px;top:" + yp + "px\"";
else
estyle = " style=\"font-weight:bold;position:absolute;left:" +
xp + "px;top:" + yp + "px\"";
}
string starttag, endtag;
getStyle(styles, it->getGdiFont(), it->font, estyle, starttag, endtag);
if (!it->text.empty())
fout << starttag << toUTF8(encodeXML(it->text)) << endtag << endl;
if (it->format == boldLarge) {
list<TextInfo>::const_iterator next = it;
++next;
if (next == TL.end() || next->yp != it->yp)
offsetY += 7;
}
++it;
}
fout << "<p style=\"position:absolute;left:10px;top:" << int(yscale*MaxY)+15 + offsetY << "px\">";
char bf1[256];
char bf2[256];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
//fout << "Skapad av <i>MeOS</i>: " << bf1 << " "<< bf2 << "\n";
fout << toUTF8(lang.tl("Skapad av ")) + "<a href=\"http://www.melin.nu/meos\" target=\"_blank\"><i>MeOS</i></a>: " << bf1 << " "<< bf2 << "\n";
fout << "</p>\n";
fout << "</body>\n";
fout << "</html>\n";
return false;
}
string html_table_code(const string &in)
{
if (in.size()==0)
return "&nbsp;";
else {
return encodeXML(in);
}
}
bool sortTL_X(const TextInfo *a, const TextInfo *b)
{
return a->xp < b->xp;
}
bool gdioutput::writeTableHTML(const wstring &file,
const string &title, int refreshTimeOut) const
{
ofstream fout(file.c_str());
if (fout.bad())
return false;
return writeTableHTML(fout, title, false, refreshTimeOut);
}
bool gdioutput::writeTableHTML(ostream &fout,
const string &title,
bool simpleFormat,
int refreshTimeOut) const {
fout << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n" <<
" \"http://www.w3.org/TR/html4/loose.dtd\">\n\n";
fout << "<html>\n<head>\n";
fout << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
if (refreshTimeOut > 0)
fout << "<meta http-equiv=\"refresh\" content=\"" << refreshTimeOut << "\">\n";
fout << "<title>" << toUTF8(title) << "</title>\n";
map< pair<gdiFonts, string>, pair<string, string> > styles;
generateStyles(fout, true, TL, styles);
fout << "</head>\n";
fout << "<body>\n";
list<TextInfo>::const_iterator it = TL.begin();
map<int,int> tableCoordinates;
//Get x-coordinates
while (it!=TL.end()) {
tableCoordinates[it->xp]=0;
++it;
}
map<int, int>::iterator mit=tableCoordinates.begin();
int k=0;
while (mit!=tableCoordinates.end()) {
mit->second=k++;
++mit;
}
tableCoordinates[MaxX]=k;
vector<bool> sizeSet(k+1, false);
fout << "<table cellspacing=\"0\" border=\"0\">\n";
int linecounter=0;
it=TL.begin();
vector< pair<int, vector<const TextInfo *> > > rows;
rows.reserve(TL.size() / 3);
vector<int> ypRow;
int minHeight = 100000;
while (it!=TL.end()) {
int y=it->yp;
vector<const TextInfo *> row;
int subnormal = 0;
int normal = 0;
int header = 0;
int mainheader = 0;
while (it!=TL.end() && it->yp==y) {
if (!gdioutput::skipTextRender(it->format)) {
row.push_back(&*it);
switch (it->getGdiFont()) {
case fontLarge:
case boldLarge:
case boldHuge:
mainheader++;
break;
case boldText:
case italicMediumPlus:
case fontMediumPlus:
header++;
break;
case fontSmall:
case italicSmall:
subnormal++;
break;
default:
normal++;
}
}
++it;
}
if (row.empty())
continue;
bool isMainHeader = mainheader > normal;
bool isHeader = (header + mainheader) > normal;
bool isSub = subnormal > normal;
sort(row.begin(), row.end(), sortTL_X);
rows.resize(rows.size() + 1);
rows.back().first = isMainHeader ? 1 : (isHeader ? 2 : (isSub ? 3 : 0));
rows.back().second.swap(row);
int last = ypRow.size();
ypRow.push_back(y);
if (last > 0) {
minHeight = min(minHeight, ypRow[last] - ypRow[last-1]);
}
}
int numMin = 0;
for (size_t gCount = 1; gCount < rows.size(); gCount++) {
int h = ypRow[gCount] - ypRow[gCount-1];
if (h == minHeight)
numMin++;
}
if (numMin == 0)
numMin = 1;
int hdrLimit = (rows.size() / numMin) <= 4 ? int(minHeight * 1.2) : int(minHeight * 1.5);
for (size_t gCount = 1; gCount + 1 < rows.size(); gCount++) {
int type = rows[gCount].first;
int lastType = gCount > 0 ? rows[gCount-1].first : 0;
int nextType = gCount + 1 < rows.size() ? rows[gCount + 1].first : 0;
if (type == 0 && (lastType == 1 || lastType == 2) && (nextType == 1 || nextType == 2))
continue; // No reclassify
int h = ypRow[gCount] - ypRow[gCount-1];
if (h > hdrLimit && rows[gCount].first == 0)
rows[gCount].first = 2;
}
ypRow.clear();
string lineclass;
for (size_t gCount = 0; gCount < rows.size(); gCount++) {
vector<const TextInfo *> &row = rows[gCount].second;
int type = rows[gCount].first;
int lastType = gCount > 0 ? rows[gCount-1].first : 0;
int nextType = gCount + 1 < rows.size() ? rows[gCount + 1].first : 0;
vector<const TextInfo *>::iterator rit;
fout << "<tr>" << endl;
if (simpleFormat) {
}
else if (type == 1) {
lineclass = " class=\"freeheader\"";
linecounter = 0;
}
else if (type == 2) {
linecounter = 0;
lineclass = " valign=\"bottom\" class=\"header\"";
}
else {
if (type == 3)
linecounter = 1;
if ((lastType == 1 || lastType == 2) && (nextType == 1 || nextType == 2) && row.size() < 3) {
lineclass = "";
}
else
lineclass = (linecounter&1) ? " class=\"e1\"" : " class=\"e0\"";
linecounter++;
}
for (size_t k=0;k<row.size();k++) {
int thisCol=tableCoordinates[row[k]->xp];
if (k==0 && thisCol!=0)
fout << "<td" << lineclass << " colspan=\"" << thisCol << "\">&nbsp;</td>";
int nextCol;
if (row.size()==k+1)
nextCol=tableCoordinates.rbegin()->second;
else
nextCol=tableCoordinates[row[k+1]->xp];
int colspan=nextCol-thisCol;
assert(colspan>0);
string style;
if (row[k]->format&textRight)
style=" style=\"text-align:right\"";
if (colspan==1 && !sizeSet[thisCol]) {
fout << " <td" << lineclass << style << " width=\"" << int( (k+1<row.size()) ?
(row[k+1]->xp - row[k]->xp) : (MaxX-row[k]->xp)) << "\">";
sizeSet[thisCol]=true;
}
else if (colspan>1)
fout << " <td" << lineclass << style << " colspan=\"" << colspan << "\">";
else
fout << " <td" << lineclass << style << ">";
gdiFonts font = row[k]->getGdiFont();
string starttag, endtag;
getStyle(styles, font, row[k]->font, "", starttag, endtag);
fout << starttag << toUTF8(html_table_code(row[k]->text)) << endtag << "</td>" << endl;
}
fout << "</tr>\n";
row.clear();
}
fout << "</table>\n";
if (!simpleFormat) {
fout << "<br><p>";
char bf1[256];
char bf2[256];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf2, 256);
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, bf1, 256);
string meos = getMeosCompectVersion();
fout << toUTF8(lang.tl("Skapad av ")) + "<a href=\"http://www.melin.nu/meos\" target=\"_blank\"><i>MeOS "
<< meos << "</i></a>: " << bf1 << " "<< bf2 << "\n";
fout << "</p><br>\n";
}
fout << "</body>\n";
fout << "</html>\n";
return true;
}

251
code/MeOSFeatures.cpp Normal file
View File

@ -0,0 +1,251 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "oEvent.h"
#include "MeOSFeatures.h"
#include "meosexception.h"
#include "meos_util.h"
#include <cassert>
#include "classconfiginfo.h"
MeOSFeatures::MeOSFeatures(void)
{
addHead("General");
add(DrawStartList, "SL", "Prepare start lists");
add(Bib, "BB", "Bibs");
add(Clubs, "CL", "Clubs");
add(EditClub, "CC", "Edit Clubs").require(Clubs);
add(InForest, "RF", "Track runners in forest");
add(Network, "NW", "Several MeOS Clients in a network");
addHead("MeOS Features");
add(Speaker, "SP", "Använd speakerstöd");
add(SeveralStages, "ST", "Several stages");
add(Economy, "EC", "Economy and fees").require(EditClub).require(Clubs);
add(Vacancy, "VA", "Vacancies and entry cancellations").require(DrawStartList);
add(TimeAdjust, "TA", "Manual time penalties and adjustments");
add(RunnerDb, "RD", "Club and runner database").require(Clubs);
addHead("Teams and forking");
add(ForkedIndividual, "FO", "Forked individual courses");
add(Patrol, "PT", "Patrols");
add(Relay, "RL", "Relays");
add(MultipleRaces, "MR", "Several races for a runner").require(Relay);
addHead("Rogaining");
add(Rogaining, "RO", "Rogaining");
add(PointAdjust, "PA", "Manual point reductions and adjustments").require(Rogaining);
}
MeOSFeatures::FeatureDescriptor &MeOSFeatures::add(Feature feat, const char *code, const char *descr) {
assert(codeToIx.count(code) == 0);
assert(featureToIx.count(feat) == 0);
featureToIx[feat] = desc.size();
string codeS = code;
codeToIx[codeS] = desc.size();
desc.push_back(FeatureDescriptor(feat, codeS, descr));
return desc.back();
}
MeOSFeatures::FeatureDescriptor &MeOSFeatures::addHead(const char *descr) {
desc.push_back(FeatureDescriptor(_Head, "-", descr));
return desc.back();
}
bool MeOSFeatures::isHead(int featureIx) const {
return getFeature(featureIx) == _Head;
}
const string &MeOSFeatures::getHead(int featureIx) const {
if (isHead(featureIx))
return desc[featureIx].desc;
else
isHead(-1);//Throws
return _EmptyString;
}
MeOSFeatures::FeatureDescriptor::FeatureDescriptor(Feature featIn,
string codeIn,
string descIn) :
feat(featIn), code(codeIn), desc(descIn)
{
}
MeOSFeatures::~MeOSFeatures(void)
{
}
bool MeOSFeatures::hasFeature(Feature f) const {
return features.count(f) != 0;
}
void MeOSFeatures::useFeature(Feature f, bool use, oEvent &oe) {
if (use) {
const set<Feature> &dep = desc[getIndex(f)].dependsOn;
features.insert(f);
features.insert(dep.begin(), dep.end());
}
else {
if (!isRequiredInternal(f))
features.erase(f);
}
oe.getDI().setString("Features", serialize());
}
bool MeOSFeatures::isRequiredInternal(Feature f) const {
for (set<Feature>::const_iterator it = features.begin(); it != features.end(); ++it) {
if (desc[getIndex(*it)].dependsOn.count(f))
return true;
}
return false;
}
bool MeOSFeatures::isRequired(Feature f, const oEvent &oe) const {
if (isRequiredInternal(f))
return true;
if (f == Rogaining && oe.hasRogaining() && hasFeature(Rogaining))
return true;
return false;
}
int MeOSFeatures::getNumFeatures() const {
return desc.size();
}
MeOSFeatures::Feature MeOSFeatures::getFeature(int featureIx) const {
if (size_t(featureIx) < desc.size())
return desc[featureIx].feat;
else
throw meosException("Index out of bounds");
}
const string &MeOSFeatures::getDescription(Feature f) const {
return desc[getIndex(f)].desc;
}
const string &MeOSFeatures::getCode(Feature f) const {
return desc[getIndex(f)].code;
}
int MeOSFeatures::getIndex(Feature f) const {
map<Feature, int >::const_iterator res = featureToIx.find(f);
if (res == featureToIx.end())
throw meosException("Index out of bounds");
return res->second;
}
string MeOSFeatures::serialize() const {
if (features.empty())
return "NONE";
string st;
for (set<Feature>::const_iterator it = features.begin(); it != features.end(); ++it) {
if (!st.empty())
st += "+";
st += getCode(*it);
}
return st;
}
void MeOSFeatures::deserialize(const string &input, oEvent &oe) {
features.clear();
if (input == "NONE")
return;
else if (input.empty()) {
loadDefaults(oe);
}
vector<string> ff;
split(input, "+", ff);
for (size_t k = 0; k < ff.size(); k++) {
map<string, int>::iterator res = codeToIx.find(ff[k]);
if (res != codeToIx.end())
features.insert(desc[res->second].feat);
}
set<Feature> iF;
for (set<Feature>::iterator it = features.begin(); it != features.end(); ++it) {
int ix = getIndex(*it);
iF.insert(desc[ix].dependsOn.begin(), desc[ix].dependsOn.end());
}
features.insert(iF.begin(), iF.end());
}
void MeOSFeatures::loadDefaults(oEvent &oe) {
if (oe.getDCI().getInt("UseEconomy") != 0) {
features.insert(Economy);
features.insert(EditClub);
}
if (oe.getDCI().getInt("UseSpeaker") != 0)
features.insert(Speaker);
if (oe.hasRogaining())
features.insert(Rogaining);
if (oe.getDCI().getInt("SkipRunnerDb") == 0 )
features.insert(RunnerDb);
ClassConfigInfo cnf;
oe.getClassConfigurationInfo(cnf);
if (cnf.hasPatrol())
features.insert(Patrol);
if (cnf.hasRelay())
features.insert(Relay);
if (cnf.raceNStart.size() > 0) {
features.insert(Relay);
features.insert(MultipleRaces);
}
if (cnf.isMultiStageEvent())
features.insert(SeveralStages);
features.insert(Clubs);
features.insert(Network);
features.insert(ForkedIndividual);
features.insert(Vacancy);
features.insert(InForest);
features.insert(DrawStartList);
features.insert(Bib);
}
void MeOSFeatures::useAll(oEvent &oe) {
for (size_t k = 0; k < desc.size(); k++) {
if (desc[k].feat != _Head)
features.insert(desc[k].feat);
}
oe.getDI().setString("Features", serialize());
}
void MeOSFeatures::clear(oEvent &oe) {
features.clear();
oe.getDI().setString("Features", serialize());
}

103
code/MeOSFeatures.h Normal file
View File

@ -0,0 +1,103 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include <set>
#include <vector>
#include <map>
class oEvent;
class MeOSFeatures
{
public:
enum Feature {
_Head = -1,
Speaker = 0,
Economy,
Clubs,
EditClub,
SeveralStages,
Network,
TimeAdjust,
PointAdjust,
ForkedIndividual,
Patrol,
Relay,
MultipleRaces,
Rogaining,
Vacancy,
InForest,
DrawStartList,
Bib,
RunnerDb,
};
private:
struct FeatureDescriptor {
Feature feat;
string code;
string desc;
set<Feature> dependsOn;
FeatureDescriptor &require(Feature f) {
dependsOn.insert(f);
return *this;
}
FeatureDescriptor(Feature feat, string code, string desc);
};
vector<FeatureDescriptor> desc;
map<Feature, int> featureToIx;
map<string, int> codeToIx;
FeatureDescriptor &add(Feature feat, const char *code, const char *desc);
FeatureDescriptor &addHead(const char *desc);
set<Feature> features;
int getIndex(Feature f) const;
void loadDefaults(oEvent &oe);
bool isRequiredInternal(Feature f) const;
public:
MeOSFeatures(void);
~MeOSFeatures(void);
bool hasFeature(Feature f) const;
void useFeature(Feature f, bool use, oEvent &oe);
bool isRequired(Feature f, const oEvent &oe) const;
void useAll(oEvent &oe);
void clear(oEvent &oe);
int getNumFeatures() const;
Feature getFeature(int featureIx) const;
bool isHead(int featureIx) const;
const string &getHead(int featureIx) const;
const string &getDescription(Feature f) const;
const string &getCode(Feature f) const;
string serialize() const;
void deserialize(const string &input, oEvent &oe);
};

116
code/Printer.h Normal file
View File

@ -0,0 +1,116 @@
// printer.h: printing utilities.
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "gdistructures.h"
/** Data structure describing text to print.*/
struct PrintTextInfo {
float xp;
float yp;
float width;
TextInfo ti;
PrintTextInfo(const TextInfo &ti_) : xp(0), yp(0), width(0), ti(ti_) {};
PrintTextInfo() : xp(0), yp(0), width(0) {};
};
/** Data structure describing page to print*/
struct PageInfo {
float topMargin;
float bottomMargin;
float pageY;
float leftMargin;
float scaleX;
float scaleY;
bool printHeader;
bool noPrintMargin;
int nPagesTotal; //Total number of pages to print
// Transfer mm to local printing coordinates: cLocalX = cx + m, cLocalX = cy + m.
double xMM2PrintC;
double xMM2PrintK;
double yMM2PrintC;
double yMM2PrintK;
void renderPages(const list<TextInfo> &tl,
const list<RectangleInfo> &rects,
bool invertHeightY,
vector<RenderedPage> &pages);
string pageInfo(const RenderedPage &page) const;
};
/** A rendered page ready to print. */
struct RenderedPage {
int nPage; // This page number
string info;
vector<PrintTextInfo> text;
vector<RectangleInfo> rectangles;
__int64 checkSum;
RenderedPage() : checkSum(0) {}
void calculateCS(const TextInfo &text);
};
struct PrinterObject {
//Printing
HDC hDC;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
void freePrinter();
string Device;
string Driver;
DEVMODE DevMode;
set<__int64> printedPages;
int nPagesPrinted;
int nPagesPrintedTotal;
bool onlyChanged;
struct DATASET {
int pWidth_mm;
int pHeight_mm;
double pMgBottom;
double pMgTop;
double pMgRight;
double pMgLeft;
int MarginX;
int MarginY;
int PageX;
int PageY;
double Scale;
bool LastPage;
} ds;
void operator=(const PrinterObject &po);
PrinterObject();
~PrinterObject();
PrinterObject(const PrinterObject &po);
};

1232
code/RunnerDB.cpp Normal file

File diff suppressed because it is too large Load Diff

249
code/RunnerDB.h Normal file
View File

@ -0,0 +1,249 @@
#pragma once
#include <vector>
#include <map>
#include "inthashmap.h"
#include "oclub.h"
#include <hash_set>
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
const int baseNameLength=32;
//Has 0-clearing constructor. Must not contain any
//dynamic data etc.
struct RunnerDBEntryV1 {
RunnerDBEntryV1();
char name[baseNameLength];
int cardNo;
int clubNo;
char national[3];
char sex;
short int birthYear;
short int reserved;
};
struct RunnerDBEntry {
// Init from old struct
void init(const RunnerDBEntryV1 &dbe);
RunnerDBEntry();
/** Binary compatible with V1*/
char name[baseNameLength];
int cardNo;
int clubNo;
char national[3];
char sex;
short int birthYear;
short int reserved;
/** End of V1*/
__int64 extId;
void getName(string &name) const;
void setName(const char *name);
string getGivenName() const;
string getFamilyName() const;
string getNationality() const;
int getBirthYear() const {return birthYear;}
string getSex() const;
__int64 getExtId() const;
void setExtId(__int64 id);
bool isRemoved() const {return (reserved & 1) == 1;}
void remove() {reserved |= 1;}
};
typedef vector<RunnerDBEntry> RunnerDBVector;
class oDBRunnerEntry;
class oClass;
class oDBClubEntry;
class RunnerDB {
private:
oEvent *oe;
Table *runnerTable;
Table *clubTable;
bool check(const RunnerDBEntry &rde) const;
intkeymap<oClass *, __int64> runnerInEvent;
/** Init name hash lazy */
void setupNameHash() const;
void setupIdHash() const;
void setupCNHash() const;
vector<RunnerDBEntry> rdb;
vector<oDBClubEntry> cdb;
vector<oDBRunnerEntry> oRDB;
// Runner card hash
inthashmap rhash;
// Runner id hash
mutable intkeymap<int, __int64> idhash;
// Club id hash
inthashmap chash;
// Last known free index
int freeCIx;
// Name hash
mutable multimap<string, int> nhash;
// Club name hash
mutable multimap<string, int> cnhash;
static void canonizeSplitName(const string &name, vector<string> &split);
bool loadedFromServer;
/** Date when database was updated. The format is YYYYMMDD */
int dataDate;
/** Time when database was updated. The format is HH:MM:SS */
int dataTime;
void fillClubs(vector< pair<string, size_t> > &out) const;
public:
void generateRunnerTableData(Table &table, oDBRunnerEntry *addEntry);
void generateClubTableData(Table &table, oClub *addEntry);
void refreshRunnerTableData(Table &table);
void refreshClubTableData(Table &table);
void refreshTables();
Table *getRunnerTB();
Table *getClubTB();
void hasEnteredCompetition(__int64 extId);
void releaseTables();
/** Get the date, YYYY-MM-DD HH:MM:SS when database was updated */
string getDataDate() const;
/** Set the date YYYY-MM-DD HH:MM:SS when database was updated */
void setDataDate(const string &date);
/** Returns true if the database was loaded from server */
bool isFromServer() const {return loadedFromServer;}
/** Prepare for loading runner from server*/
void prepareLoadFromServer(int nrunner, int nclub);
const vector<RunnerDBEntry>& getRunnerDB() const;
const vector<oDBClubEntry>& getClubDB() const;
void clearRunners();
void clearClubs();
/** Add a club. Create a new Id if necessary*/
int addClub(oClub &c, bool createNewId);
RunnerDBEntry *addRunner(const char *name, __int64 extId,
int club, int card);
oDBRunnerEntry *addRunner();
oClub *addClub();
RunnerDBEntry *getRunnerByIndex(size_t index) const;
RunnerDBEntry *getRunnerById(__int64 extId) const;
RunnerDBEntry *getRunnerByCard(int card) const;
RunnerDBEntry *getRunnerByName(const string &name, int clubId,
int expectedBirthYear) const;
bool getClub(int clubId, string &club) const;
oClub *getClub(int clubId) const;
oClub *getClub(const string &name) const;
void saveClubs(const char *file);
void saveRunners(const char *file);
void loadRunners(const char *file);
void loadClubs(const char *file);
void updateAdd(const oRunner &r, map<int, int> &clubIdMap);
void importClub(oClub &club, bool matchName);
void compactifyClubs();
void getAllNames(vector<string> &givenName, vector<string> &familyName);
RunnerDB(oEvent *);
~RunnerDB(void);
friend class oDBRunnerEntry;
friend class oDBClubEntry;
};
class oDBRunnerEntry : public oBase {
private:
RunnerDB *db;
int index;
protected:
/** Get internal data buffers for DI */
oDataContainer &getDataBuffers(pvoid &data, pvoid &olddata, pvectorstr &strData) const;
int getDISize() const {return 0;}
void changedObject() {}
public:
int getIndex() const {return index;}
void init(RunnerDB *db_, int index_) {db=db_, index=index_; Id = index;}
const RunnerDBEntry &getRunner() const;
void addTableRow(Table &table) const;
bool inputData(int id, const string &input,
int inputId, string &output, bool noUpdate);
void fillInput(int id, vector< pair<string, size_t> > &out, size_t &selected);
oDBRunnerEntry(oEvent *oe);
virtual ~oDBRunnerEntry();
void remove();
bool canRemove() const;
string getInfo() const {return "Database Runner";}
};
class oDBClubEntry : public oClub {
private:
int index;
RunnerDB *db;
public:
oDBClubEntry(oEvent *oe, int id, int index, RunnerDB *db);
oDBClubEntry(const oClub &c, int index, RunnerDB *db);
int getTableId() const;
virtual ~oDBClubEntry();
void remove();
bool canRemove() const;
};

2341
code/SportIdent.cpp Normal file

File diff suppressed because it is too large Load Diff

227
code/SportIdent.h Normal file
View File

@ -0,0 +1,227 @@
// SportIdent.h: interface for the SportIdent class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SPORTIDENT_H__F13F5795_8FA9_4CE6_8497_7407CD590139__INCLUDED_)
#define AFX_SPORTIDENT_H__F13F5795_8FA9_4CE6_8497_7407CD590139__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
const BYTE STX=0x02;
const BYTE ETX=0x03;
const BYTE ACK=0x06;
const BYTE DLE=0x10;
const BYTE WAKEUP=0xFF;
const BYTE NAK=0x15;
// This is taken from r56 and checked in on r63
#include <vector>
struct SICard5Detect
{
BYTE code;//Code;
BYTE len;
SHORT station;
DWORD number;
WORD crc;
};
struct SIPunch
{
DWORD Code;
DWORD Time;
};
struct SICard
{
SICard() {
clear(0);
convertedTime = false;
}
// Clears the card if this == condition or condition is 0
void clear(const SICard *condition) {
if (this==condition || condition==0)
memset(this, 0, sizeof(SICard));
}
bool empty() const {return CardNumber==0;}
DWORD CardNumber;
SIPunch StartPunch;
SIPunch FinishPunch;
SIPunch CheckPunch;
DWORD nPunch;
SIPunch Punch[192];
char FirstName[21];
char LastName[21];
char Club[41];
char readOutTime[32];
bool PunchOnly;
bool convertedTime;
// Used for manual time input
int runnerId;
int relativeFinishTime;
bool statusOK;
bool statusDNF;
vector<string> codeLogData(int row) const;
static vector<string> logHeader();
unsigned calculateHash() const;
bool isManualInput() const {return runnerId != 0;}
string serializePunches() const;
void deserializePunches(const string &arg);
};
struct SI_StationData {
SI_StationData();
int stationNumber;
int stationMode;
bool extended;
bool handShake;
bool autoSend;
int radioChannel;
};
struct SI_StationInfo
{
SI_StationInfo();
HANDLE ThreadHandle;
string ComPort;
HANDLE hComm;
COMMTIMEOUTS TimeOuts;
vector<SI_StationData> data;
int stationMode() const {
if (data.empty())
return 0;
else
return data[0].stationMode;
}
bool extended() const {
if (data.empty())
return false;
bool ext = true;
for (size_t k = 0; k < data.size(); k++) {
if (!data[k].extended)
ext = false;
}
return ext;
}
//Used for TCP ports
WORD tcpPort;
int localZeroTime;
};
class SportIdent
{
protected:
bool ReadSI6Block(HANDLE hComm, BYTE *data);
bool ReadSystemData(SI_StationInfo *si, int retry=2);
bool ReadSystemDataV2(SI_StationInfo &si);
CRITICAL_SECTION SyncObj;
DWORD ZeroTime; //Used to analyse times. Seconds 0-24h (0-24*3600)
int ReadByte_delay(BYTE &byte, HANDLE hComm);
int ReadBytes_delay(BYTE *byte, DWORD buffSize, DWORD len, HANDLE hComm);
int ReadBytesDLE_delay(BYTE *byte, DWORD buffSize, DWORD len, HANDLE hComm);
int ReadByte(BYTE &byte, HANDLE hComm);
int ReadBytes(BYTE *byte, DWORD len, HANDLE hComm);
int ReadBytesDLE(BYTE *byte, DWORD len, HANDLE hComm);
// Returns zero on failure, number of bytes used on success.
int analyzeStation(BYTE *db, SI_StationData &si);
SI_StationInfo SI_Info[32];
int n_SI_Info; //Number of structures..
SI_StationInfo *Current_SI_Info; //Current SI_Info in use (for thread startup);
WORD CalcCRC(BYTE *data, DWORD length);
bool CheckCRC(BYTE *bf);
void SetCRC(BYTE *bf);
bool GetCard5Data(BYTE *data, SICard &card);
bool GetCard6Data(BYTE *data, SICard &card);
bool GetCard9Data(BYTE *data, SICard &card);
DWORD GetExtCardNumber(BYTE *data) const;
void GetSI5Data(HANDLE hComm);
void GetSI5DataExt(HANDLE hComm);
void GetSI6Data(HANDLE hComm);
void GetSI6DataExt(HANDLE hComm);
void GetSI9DataExt(HANDLE hComm);
void AnalyseSI5Time(BYTE *data, DWORD &time, DWORD &control);
bool AnalysePunch(BYTE *data, DWORD &time, DWORD &control);
void AnalyseTPunch(BYTE *data, DWORD &time, DWORD &control);
//Card read waiting to be processed.
list<SICard> ReadCards;
HWND hWndNotify;
DWORD ClassId;
volatile int tcpPortOpen;
volatile unsigned int serverSocket;
bool MonitorSI(SI_StationInfo &si);
int MonitorTCPSI(WORD port, int localZeroTime);
public:
SI_StationInfo *findStation(const string &com);
void getInfoString(const string &com, vector<string> &info);
bool IsPortOpen(const string &com);
void SetZeroTime(DWORD zt);
bool AutoDetect(list<int> &ComPorts);
void StopMonitorThread();
void StartMonitorThread(const char *com);
bool GetCard(SICard &sic);
void addCard(const SICard &sic);
void AddPunch(DWORD Time, int Station, int Card, int Mode=0);
void EnumrateSerialPorts(list<int> &ports);
void CloseCom(const char *com);
bool OpenCom(const char *com);
bool tcpAddPort(int port, DWORD zeroTime);
bool OpenComListen(const char *com, DWORD BaudRate);
SportIdent(HWND hWnd, DWORD Id);
virtual ~SportIdent();
friend void start_si_thread(void *ptr);
};
#endif // !defined(AFX_SPORTIDENT_H__F13F5795_8FA9_4CE6_8497_7407CD590139__INCLUDED_)

12
code/StdAfx.cpp Normal file
View File

@ -0,0 +1,12 @@
// stdafx.cpp : source file that includes just the standard includes
//meos.pch will be the pre-compiled header
//stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
const string _EmptyString="";
const string _VacantName="Vakant";
const string _UnkownName="N.N.";
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

55
code/StdAfx.h Normal file
View File

@ -0,0 +1,55 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOMINMAX
// Windows Header Files:
#include <windows.h>
#include <commctrl.h>
// C RunTime Header Files
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <memory.h>
#include <tchar.h>
#include <string>
#include <fstream>
#include <list>
#include <crtdbg.h>
using namespace std;
bool getUserFile(char *fileNamePath, const char *fileName);
bool getDesktopFile(char *fileNamePath, const char *fileName, const char *subFolder = 0);
bool getMeOSFile(char *FileNamePath, const char *FileName);
class gdioutput;
gdioutput *createExtraWindow(const string &tag, const string &title, int max_x = 0, int max_y = 0);
gdioutput *getExtraWindow(const string &tag, bool toForeGround);
string uniqueTag(const char *base);
void LoadPage(const string &name);
string getTempFile();
string getTempPath();
void removeTempFile(const string &file); // Delete a temporyary
void registerTempFile(const string &tempFile); //Register a file/folder as temporary => autmatic removal on exit.
const extern string _EmptyString;
const extern string _VacantName;
const extern string _UnkownName;
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)

1142
code/TabAuto.cpp Normal file

File diff suppressed because it is too large Load Diff

287
code/TabAuto.h Normal file
View File

@ -0,0 +1,287 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
#include "gdioutput.h"
#include "Printer.h"
#include <string>
#include "oListInfo.h"
using namespace std;
class TabAuto;
class gdioutput;
class oEvent;
enum AutoSyncType {SyncNone, SyncTimer, SyncDataUp};
enum Machines {
mPunchMachine,
mPrintResultsMachine,
mSplitsMachine,
mPrewarningMachine,
mOnlineResults,
mOnlineInput,
mSaveBackup,
};
class AutoMachine
{
private:
int myid;
static int uniqueId;
protected:
bool editMode;
void settingsTitle(gdioutput &gdi, char *title);
enum IntervalType {IntervalNone, IntervalMinute, IntervalSecond};
void startCancelInterval(gdioutput &gdi, char *startCommand, bool created, IntervalType type, const string &interval);
public:
static AutoMachine *getMachine(int id);
static void resetGlobalId() {uniqueId = 1;}
int getId() const {return myid;}
static AutoMachine* construct(Machines);
void setEditMode(bool em) {editMode = em;}
string name;
DWORD interval; //Interval seconds
DWORD timeout; //Timeout (TickCount)
bool synchronize;
bool synchronizePunches;
virtual void settings(gdioutput &gdi, oEvent &oe, bool created) = 0;
virtual void save(oEvent &oe, gdioutput &gdi) {}
virtual void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast) = 0;
virtual bool isEditMode() const {return editMode;}
virtual void status(gdioutput &gdi) = 0;
virtual bool stop() {return true;}
virtual AutoMachine *clone() const = 0;
AutoMachine(const string &s) : myid(uniqueId++), name(s), interval(0), timeout(0),
synchronize(false), synchronizePunches(false), editMode(false) {}
virtual ~AutoMachine() = 0 {}
};
class PrintResultMachine :
public AutoMachine
{
protected:
string exportFile;
string exportScript;
bool doExport;
bool doPrint;
bool structuredExport;
PrinterObject po;
set<int> classesToPrint;
bool pageBreak;
bool showInterResult;
bool splitAnalysis;
bool notShown;
oListInfo listInfo;
bool readOnly;
int htmlRefresh;
bool lock; // true while printing
bool errorLock; // true while showing error dialog
public:
PrintResultMachine *clone() const {
PrintResultMachine *prm = new PrintResultMachine(*this);
prm->lock = false;
prm->errorLock = false;
return prm;
}
void status(gdioutput &gdi);
void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast);
void settings(gdioutput &gdi, oEvent &oe, bool created);
PrintResultMachine(int v):AutoMachine("Resultatutskrift") {
interval=v;
pageBreak = true;
showInterResult = true;
notShown = true;
splitAnalysis = true;
lock = false;
errorLock = false;
readOnly = false;
doExport = false;
doPrint = true;
structuredExport = true;
htmlRefresh = v;
}
PrintResultMachine(int v, const oListInfo &li):AutoMachine("Utskrift / export"), listInfo(li) {
interval=v;
pageBreak = true;
showInterResult = true;
notShown = true;
splitAnalysis = true;
lock = false;
errorLock = false;
readOnly = true;
doExport = false;
doPrint = true;
structuredExport = false;
htmlRefresh = v;
}
friend class TabAuto;
};
class SaveMachine :
public AutoMachine
{
protected:
string baseFile;
int saveIter;
public:
SaveMachine *clone() const {
SaveMachine *prm = new SaveMachine(*this);
return prm;
}
void status(gdioutput &gdi);
void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast);
void settings(gdioutput &gdi, oEvent &oe, bool created);
void saveSettings(gdioutput &gdi);
SaveMachine():AutoMachine("Säkerhetskopiera") , saveIter(0) {
}
};
class PrewarningMachine :
public AutoMachine
{
protected:
string waveFolder;
set<int> controls;
set<int> controlsSI;
public:
void settings(gdioutput &gdi, oEvent &oe, bool created);
PrewarningMachine *clone() const {return new PrewarningMachine(*this);}
void status(gdioutput &gdi);
void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast);
PrewarningMachine():AutoMachine("Förvarningsröst") {}
friend class TabAuto;
};
class MySQLReconnect :
public AutoMachine
{
protected:
string error;
string timeError;
string timeReconnect;
HANDLE hThread;
public:
void settings(gdioutput &gdi, oEvent &oe, bool created);
MySQLReconnect *clone() const {return new MySQLReconnect(*this);}
void status(gdioutput &gdi);
void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast);
bool stop();
MySQLReconnect(const string &error);
virtual ~MySQLReconnect();
friend class TabAuto;
};
bool isThreadReconnecting();
class PunchMachine :
public AutoMachine
{
protected:
int radio;
public:
PunchMachine *clone() const {return new PunchMachine(*this);}
void settings(gdioutput &gdi, oEvent &oe, bool created);
void status(gdioutput &gdi);
void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast);
PunchMachine():AutoMachine("Stämplingsautomat"), radio(0) {}
friend class TabAuto;
};
class SplitsMachine :
public AutoMachine
{
protected:
string file;
set<int> classes;
int leg;
public:
SplitsMachine *clone() const {return new SplitsMachine(*this);}
void settings(gdioutput &gdi, oEvent &oe, bool created);
void status(gdioutput &gdi);
void process(gdioutput &gdi, oEvent *oe, AutoSyncType ast);
SplitsMachine() : AutoMachine("Sträcktider/WinSplits"), leg(-1) {}
friend class TabAuto;
};
class TabAuto :
public TabBase
{
private:
//DWORD printResultIntervalSec;
//DWORD printResultTimeOut;
bool editMode;
bool synchronize;
bool synchronizePunches;
void updateSyncInfo();
list<AutoMachine *> machines;
void setTimer(AutoMachine *am);
void timerCallback(gdioutput &gdi);
void syncCallback(gdioutput &gdi);
void settings(gdioutput &gdi, AutoMachine *sm, Machines type);
protected:
void clearCompetitionData();
public:
AutoMachine *getMachine(int id);
//AutoMachine *getMachine(const string &name);
bool stopMachine(AutoMachine *am);
void killMachines();
void addMachine(const AutoMachine &am) {
machines.push_back(am.clone());
setTimer(machines.back());
}
int processButton(gdioutput &gdi, const ButtonInfo &bu);
int processListBox(gdioutput &gdi, const ListBoxInfo &bu);
bool loadPage(gdioutput &gdi);
const char * getTypeStr() const {return "TAutoTab";}
TabType getType() const {return TAutoTab;}
TabAuto(oEvent *poe);
~TabAuto(void);
friend class AutoTask;
friend void tabForceSync(gdioutput &gdi, pEvent oe);
};
void tabAutoKillMachines();
void tabAutoRegister(TabAuto *ta);
void tabAutoAddMachinge(const AutoMachine &am);

211
code/TabBase.cpp Normal file
View File

@ -0,0 +1,211 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "TabBase.h"
#include "oEvent.h"
#include "TabRunner.h"
#include "TabTeam.h"
#include "TabList.h"
#include "TabSpeaker.h"
#include "TabClass.h"
#include "TabCourse.h"
#include "TabControl.h"
#include "TabClub.h"
#include "TabSI.h"
#include "TabCompetition.h"
#include "TabAuto.h"
extern oEvent *gEvent;
FixedTabs::FixedTabs() {
runnerTab = 0;
teamTab = 0;
classTab = 0;
courseTab = 0;
controlTab = 0;
siTab = 0;
listTab = 0;
cmpTab = 0;
speakerTab = 0;
clubTab = 0;
autoTab = 0;
}
FixedTabs::~FixedTabs() {
tabs.clear();
delete runnerTab;
runnerTab = 0;
delete teamTab;
teamTab = 0;
delete classTab;
classTab = 0;
delete courseTab;
courseTab = 0;
delete controlTab;
controlTab = 0;
delete siTab;
siTab = 0;
delete listTab;
listTab = 0;
delete cmpTab;
cmpTab = 0;
delete speakerTab;
speakerTab = 0;
delete clubTab;
clubTab = 0;
delete autoTab;
autoTab = 0;
}
TabBase *FixedTabs::get(const TabType tab) {
switch(tab) {
case TCmpTab:
if (!cmpTab) {
cmpTab = new TabCompetition(gEvent);
tabs.push_back(cmpTab);
}
return cmpTab;
break;
case TRunnerTab:
if (!runnerTab) {
runnerTab = new TabRunner(gEvent);
tabs.push_back(runnerTab);
}
return runnerTab;
break;
case TTeamTab:
if (!teamTab) {
teamTab = new TabTeam(gEvent);
tabs.push_back(teamTab);
}
return teamTab;
break;
case TListTab:
if (!listTab) {
listTab = new TabList(gEvent);
tabs.push_back(listTab);
}
return listTab;
break;
case TClassTab:
if (!classTab) {
classTab = new TabClass(gEvent);
tabs.push_back(classTab);
}
return classTab;
break;
case TCourseTab:
if (!courseTab) {
courseTab = new TabCourse(gEvent);
tabs.push_back(courseTab);
}
return courseTab;
break;
case TControlTab:
if (!controlTab) {
controlTab = new TabControl(gEvent);
tabs.push_back(controlTab);
}
return controlTab;
break;
case TClubTab:
if (!clubTab) {
clubTab = new TabClub(gEvent);
tabs.push_back(clubTab);
}
return clubTab;
break;
case TSpeakerTab:
if (!speakerTab) {
speakerTab = new TabSpeaker(gEvent);
tabs.push_back(speakerTab);
}
return speakerTab;
break;
case TSITab:
if (!siTab) {
siTab = new TabSI(gEvent);
tabs.push_back(siTab);
}
return siTab;
break;
case TAutoTab:
if (!autoTab) {
autoTab = new TabAuto(gEvent);
tabs.push_back(autoTab);
}
return autoTab;
break;
default:
throw new std::exception("Bad tab type");
}
return 0;
}
void FixedTabs::clearCompetitionData() {
for (size_t k = 0; k < tabs.size(); k++)
tabs[k]->clearCompetitionData();
}
TabObject::TabObject(TabBase *t)
{
tab = t;
tab->tabId = id;
}
TabObject::~TabObject()
{
//delete tab;
}
bool TabObject::loadPage(gdioutput &gdi)
{
if (tab)
return tab->loadPage(gdi);
else return false;
}

156
code/TabBase.h Normal file
View File

@ -0,0 +1,156 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "Localizer.h"
#include <typeinfo.h>
#include "gdioutput.h"
class oBase;
class oRunner;
typedef oRunner * pRunner;
class oTeam;
typedef oTeam * pTeam;
class gdioutput;
class oEvent;
enum TabType {
TRunnerTab,
TTeamTab,
TClassTab,
TCourseTab,
TControlTab,
TSITab,
TListTab,
TCmpTab,
TSpeakerTab,
TClubTab,
TAutoTab,
};
class TabBase
{
protected:
oEvent *oe;
int tabId;
virtual void clearCompetitionData() = 0;
public:
oEvent *getEvent() const {return oe;}
int getTabId() const {return tabId;}
virtual bool loadPage(gdioutput &gdi) = 0;
virtual TabType getType() const = 0;
virtual const char *getTypeStr() const = 0;
TabBase(oEvent *poe) : oe(poe), tabId(0) {}
virtual ~TabBase()=0 {}
friend class TabObject;
friend class FixedTabs;
};
class TabObject
{
protected:
mutable TabBase *tab;
public:
string name;
int id;
TabObject(TabBase *t, string n):name(n),tab(t) {}
void setId(int i){id=i; if (tab) tab->tabId=id;}
void setPage(TabBase *tb){delete tab; tab=tb;}
const type_info &getType() const {return typeid(*tab);}
const TabBase &getTab() const {return *tab;}
TabObject(const TabObject &t)
{
if (&t!=this) {
name=t.name;
id=t.id;
tab=t.tab;
//t.tab=0;
}
}
TabObject &operator=(TabObject &t)
{
if (&t!=this) {
delete tab;
name=t.name;
id=t.id;
tab=t.tab;
//t.tab=0;
}
}
TabObject(TabBase *t);
~TabObject();
bool loadPage(gdioutput &gdi);
};
class TabRunner;
class TabTeam;
class TabClass;
class TabCourse;
class TabControl;
class TabClub;
class TabSI;
class TabList;
class TabCompetition;
class TabSpeaker;
class TabAuto;
class FixedTabs {
oEvent *oe;
TabRunner *runnerTab;
TabTeam *teamTab;
TabClass *classTab;
TabCourse *courseTab;
TabControl *controlTab;
TabSI *siTab;
TabList *listTab;
TabCompetition *cmpTab;
TabSpeaker *speakerTab;
TabClub *clubTab;
TabAuto *autoTab;
vector<TabBase *> tabs;
public:
TabBase *get(TabType tag);
const vector<TabBase *> &getActiveTabs() const {return tabs;}
// Clean up competition specific data from user interface
void clearCompetitionData();
FixedTabs();
~FixedTabs();
};

3930
code/TabClass.cpp Normal file

File diff suppressed because it is too large Load Diff

161
code/TabClass.h Normal file
View File

@ -0,0 +1,161 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
#include "oEventDraw.h"
class TabClass :
public TabBase
{
struct PursuitSettings {
bool use;
int firstTime;
int maxTime;
PursuitSettings(oClass &c) {
firstTime = 3600;
use = c.interpretClassType() != ctOpen;
maxTime = 3600;
}
};
map<int, PursuitSettings> pSettings;
int pSavedDepth;
int pFirstRestart;
double pTimeScaling;
int pInterval;
class HandleCloseWindow : public GuiHandler {
TabClass *tabClass;
HandleCloseWindow(const HandleCloseWindow&);
HandleCloseWindow &operator=(const HandleCloseWindow&);
public:
HandleCloseWindow() : tabClass(0) {}
void handle(gdioutput &gdi, BaseInfo &info, GuiEventType type);
friend class TabClass;
};
HandleCloseWindow handleCloseWindow;
bool EditChanged;
int ClassId;
int currentStage;
string storedNStage;
string storedStart;
oEvent::PredefinedTypes storedPredefined;
bool showForkingGuide;
bool checkClassSelected(const gdioutput &gdi) const;
void save(gdioutput &gdi, bool skipReload);
void legSetup(gdioutput &gdi);
vector<ClassInfo> cInfo;
map<int, ClassInfo> cInfoCache;
DrawInfo drawInfo;
void setMultiDayClass(gdioutput &gdi, bool hasMulti, DrawMethod defaultMethod);
void drawDialog(gdioutput &gdi, DrawMethod method, const oClass &cls);
void pursuitDialog(gdioutput &gdi);
bool hasWarnedDirect;
bool tableMode;
DrawMethod lastDrawMethod;
int lastSeedMethod;
bool lastSeedPreventClubNb;
bool lastSeedReverse;
string lastSeedGroups;
int lastPairSize;
string lastFirstStart;
string lastInterval;
string lastNumVac;
string lastScaleFactor;
string lastMaxAfter;
bool lastHandleBibs;
// Generate a table with class settings
void showClassSettings(gdioutput &gdi);
void visualizeField(gdioutput &gdi);
// Read input from the table with class settings
void readClassSettings(gdioutput &gdi);
// Prepare for drawing by declaring starts and blocks
void prepareForDrawing(gdioutput &gdi);
void showClassSelection(gdioutput &gdi, int &bx, int &by, GUICALLBACK classesCB) const;
// Set simultaneous start in a class
void simultaneous(int classId, string time);
void updateFairForking(gdioutput &gdi, pClass pc) const;
void selectCourses(gdioutput &gdi, int legNo);
bool showMulti(bool singleOnly) const;
void defineForking(gdioutput &gdi, bool clearSettings);
vector< vector<int> > forkingSetup;
static const char *getCourseLabel(bool pool);
void getClassSettingsTable(gdioutput &gdi, GUICALLBACK cb);
void saveClassSettingsTable(gdioutput &gdi, set<int> &classModifiedFee, bool &modifiedBib);
static string getBibCode(AutoBibType bt, const string &key);
void setParallelOptions(const string &sdKey, gdioutput &gdi, pClass pc, int legno);
void updateStartData(gdioutput &gdi, pClass pc, int leg, bool updateDependent, bool forceWrite);
void updateSplitDistribution(gdioutput &gdi, int numInClass, int tot) const;
DrawMethod getDefaultMethod(bool allowPursuit) const;
void enableLoadSettings(gdioutput &gdi);
void readDrawInfo(gdioutput &gdi, DrawInfo &drawInfo);
void writeDrawInfo(gdioutput &gdi, const DrawInfo &drawInfo);
static vector< pair<string, size_t> > getPairOptions();
public:
void clearCompetitionData();
void closeWindow(gdioutput &gdi);
void saveClassSettingsTable(gdioutput &gdi);
void multiCourse(gdioutput &gdi, int nLeg);
bool loadPage(gdioutput &gdi);
void selectClass(gdioutput &gdi, int cid);
int classCB(gdioutput &gdi, int type, void *data);
int multiCB(gdioutput &gdi, int type, void *data);
const char * getTypeStr() const {return "TClassTab";}
TabType getType() const {return TClassTab;}
friend int DrawClassesCB(gdioutput *gdi, int type, void *data);
TabClass(oEvent *oe);
~TabClass(void);
};

786
code/TabClub.cpp Normal file
View File

@ -0,0 +1,786 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Stigbergsvägen 11, SE-75242 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "resource.h"
#include <commctrl.h>
#include <commdlg.h>
#include "oEvent.h"
#include "xmlparser.h"
#include "gdioutput.h"
#include "csvparser.h"
#include "SportIdent.h"
#include <cassert>
#include "meos_util.h"
#include "Table.h"
#include "gdifonts.h"
#include "meosexception.h"
#include "MeOSFeatures.h"
#include "TabCompetition.h"
#include "TabClub.h"
#include "TabList.h"
#include "csvparser.h"
#include "pdfwriter.h"
TabClub::TabClub(oEvent *poe):TabBase(poe)
{
baseFee = 0;
lowAge = 0;
highAge = 0;
filterAge = false;
onlyNoFee = false;
useManualFee = false;
}
TabClub::~TabClub(void)
{
}
void TabClub::readFeeFilter(gdioutput &gdi) {
baseFee = oe->interpretCurrency(gdi.getText("BaseFee"));
firstDate = gdi.getText("FirstDate");
lastDate = gdi.getText("LastDate");
filterAge = gdi.isChecked("FilterAge");
useManualFee = gdi.isChecked("DefaultFees");
if (filterAge) {
highAge = gdi.getTextNo("HighLimit");
lowAge = gdi.getTextNo("LowLimit");
}
onlyNoFee = gdi.isChecked("OnlyNoFee");
ListBoxInfo lbi;
gdi.getSelectedItem("ClassType", lbi);
if (lbi.data == -5)
typeS = "*";
else if (lbi.data > 0)
typeS = "::" + itos(lbi.data);
else
typeS = lbi.text;
}
void TabClub::selectClub(gdioutput &gdi, pClub pc)
{
if (pc) {
pc->synchronize();
ClubId = pc->getId();
}
else{
ClubId = 0;
}
}
void manualFees(gdioutput &gdi, bool on) {
gdi.setInputStatus("BaseFee", on);
gdi.setInputStatus("FirstDate", on);
gdi.setInputStatus("LastDate", on);
}
void ageFilter(gdioutput &gdi, bool on, bool use) {
gdi.setInputStatus("HighLimit", on & use);
gdi.setInputStatus("LowLimit", on & use);
gdi.setInputStatus("FilterAge", use);
}
int ClubsCB(gdioutput *gdi, int type, void *data)
{
TabClub &tc = dynamic_cast<TabClub &>(*gdi->getTabs().get(TClubTab));
return tc.clubCB(*gdi, type, data);
}
int TabClub::clubCB(gdioutput &gdi, int type, void *data)
{
if (type==GUI_BUTTON) {
ButtonInfo bi=*(ButtonInfo *)data;
if (bi.id=="Save") {
}
else if (bi.id == "EraseClubs") {
if (gdi.ask("Vill du ta bort alla klubbar från tävlingen? Alla deltagare blir klubblösa.")) {
oClub::clearClubs(*oe);
}
}
else if (bi.id=="Invoice") {
ListBoxInfo lbi;
gdi.getSelectedItem("Clubs", lbi);
pClub pc=oe->getClub(lbi.data);
if (pc) {
gdi.clearPage(true);
oe->calculateTeamResults(false);
oe->sortTeams(ClassStartTime, 0, true);
oe->calculateResults(oEvent::RTClassResult);
oe->sortRunners(ClassStartTime);
int pay, paid;
{
map<int, int> ppm;
map<int, string> dpm;
oClub::definedPayModes(*oe, dpm);
pc->generateInvoice(gdi, pay, paid, dpm, ppm);
}
gdi.addButton(gdi.getWidth()+20, 15, gdi.scaleLength(120),
"Cancel", "Återgå", ClubsCB, "", true, false);
gdi.addButton(gdi.getWidth()+20, 45, gdi.scaleLength(120),
"Print", "Skriv ut...", ClubsCB,
"Skriv ut fakturan", true, false);
gdi.addButton(gdi.getWidth()+20, 75, gdi.scaleLength(120),
"PDF", "PDF...", ClubsCB,
"Spara som PDF.", true, false);
gdi.refresh();
}
}
else if (bi.id=="AllInvoice") {
gdi.clearPage(false);
gdi.addString("", boldLarge, "Skapa fakturor");
gdi.addSelection("Type", 300, 100, 0, "Val av export:");
gdi.addItem("Type", lang.tl("Skriv ut alla"), oEvent::IPTAllPrint);
gdi.addItem("Type", lang.tl("Exportera alla till HTML"), oEvent::IPTAllHTML);
gdi.addItem("Type", lang.tl("Exportera alla till PDF"), oEvent::IPTAllPDF);
#ifdef _DEBUG
gdi.addItem("Type", lang.tl("Skriv ut dem utan e-post"), oEvent::IPTNoMailPrint);
gdi.addItem("Type", lang.tl("Skriv ut ej accepterade elektroniska"), oEvent::IPTNonAcceptedPrint);
gdi.addItem("Type", lang.tl("Exportera elektroniska fakturor"), oEvent::IPTElectronincHTML);
#endif
gdi.selectFirstItem("Type");
gdi.fillRight();
gdi.pushX();
gdi.addButton("DoAllInvoice", "Skapa fakturor", ClubsCB);
#ifdef _DEBUG
gdi.addButton("ImportAnswer", "Hämta svar om elektroniska fakturor", ClubsCB);
#endif
gdi.addButton("Cancel", "Avbryt", ClubsCB);
gdi.refresh();
}
else if (bi.id=="DoAllInvoice") {
ListBoxInfo lbi;
gdi.getSelectedItem("Type", lbi);
string path;
if (lbi.data > 10)
path = gdi.browseForFolder(path, 0);
gdi.clearPage(false);
oe->printInvoices(gdi, oEvent::InvoicePrintType(lbi.data), path, false);
gdi.addButton(gdi.getWidth()+20, 15, gdi.scaleLength(120),
"Cancel", "Återgå", ClubsCB, "", true, false);
if (lbi.data>10) { // To file
gdi.addButton(gdi.getWidth()+20, 45, gdi.scaleLength(120),
"Print", "Skriv ut...", ClubsCB,
"", true, false);
gdi.addButton(gdi.getWidth()+20, 75, gdi.scaleLength(120),
"PDF", "PDF...", ClubsCB,
"Spara som PDF.", true, false);
gdi.refresh();
}
else {
gdi.refresh();
gdi.print(oe, 0, false, false);
}
}
else if (bi.id=="ImportAnswer") {
vector< pair<string, string> > ft;
ft.push_back(make_pair("Textfiler", "*.txt"));
string file = gdi.browseForOpen(ft, "txt");
if (!file.empty()) {
gdi.clearPage(true);
try {
importAcceptedInvoice(gdi, file);
}
catch (std::exception &ex) {
gdi.addString("", 0, ex.what()).setColor(colorRed);
}
gdi.addButton("Cancel", "OK", ClubsCB);
}
}
else if (bi.id=="UpdateAll") {
oe->updateClubsFromDB();
gdi.getTable().update();
gdi.refresh();
}
else if (bi.id=="UpdateAllRunners") {
oe->updateClubsFromDB();
oe->updateRunnersFromDB();
gdi.getTable().update();
gdi.refresh();
}
else if (bi.id=="Update") {
pClub pc=oe->getClub(gdi.getSelectedItem("Clubs").first);
if (pc) {
pc->updateFromDB();
pc->synchronize();
gdi.getTable().update();
gdi.refresh();
}
}
else if (bi.id=="Summary") {
gdi.clearPage(false);
string nn;
oe->printInvoices(gdi, oEvent::IPTAllPrint, nn, true);
gdi.addButton(gdi.getWidth()+20, 15, gdi.scaleLength(120), "Cancel",
"Återgå", ClubsCB, "", true, false);
gdi.addButton(gdi.getWidth()+20, 45, gdi.scaleLength(120), "Print",
"Skriv ut...", ClubsCB, "Skriv ut fakturan", true, false);
gdi.refresh();
}
else if (bi.id=="Merge") {
ClubId = gdi.getSelectedItem("Clubs").first;
pClub pc = oe->getClub(ClubId);
if (pc) {
gdi.clearPage(false);
gdi.addString("", boldText, "Slå ihop klubb");
char bf[256];
sprintf_s(bf, lang.tl("help:12352").c_str(), pc->getName().c_str(), pc->getId());
gdi.addStringUT(10, bf);
gdi.addSelection("NewClub", 200, 300, 0, "Ny klubb:");
oe->fillClubs(gdi, "NewClub");
gdi.selectItemByData("NewClub", pc->getId());
gdi.removeSelected("NewClub");
gdi.pushX();
gdi.fillRight();
gdi.addButton("DoMerge", "Slå ihop", ClubsCB);
gdi.addButton("Cancel", "Avbryt", ClubsCB);
gdi.fillDown();
gdi.popX();
gdi.dropLine(2);
gdi.addStringUT(boldText, lang.tl("Klubb att ta bort: ") + pc->getName());
oe->viewClubMembers(gdi, pc->getId());
gdi.refresh();
}
}
else if (bi.id=="DoMerge") {
pClub pc1 = oe->getClub(ClubId);
pClub pc2 = oe->getClub(gdi.getSelectedItem("NewClub").first);
if (pc1==pc2)
throw std::exception("En klubb kan inte slås ihop med sig själv.");
if (pc1 && pc2)
oe->mergeClub(pc2->getId(), pc1->getId());
loadPage(gdi);
}
else if (bi.id == "InvoiceSettings") {
gdi.clearPage(true);
gdi.addString("", boldLarge, "Fakturainställningar");
gdi.dropLine();
firstInvoice = oClub::getFirstInvoiceNumber(*oe);
if (firstInvoice == 0)
firstInvoice = oe->getPropertyInt("FirstInvoice", 1000);
gdi.addInput("FirstInvoice", itos(firstInvoice), 5, 0, "Första fakturanummer:");
gdi.dropLine();
gdi.addString("", boldText, "Organisatör");
vector<string> fields;
gdi.pushY();
fields.push_back("Organizer");
fields.push_back("CareOf");
fields.push_back("Street");
fields.push_back("Address");
fields.push_back("EMail");
oe->getDI().buildDataFields(gdi, fields);
gdi.dropLine();
gdi.addString("", boldText, "Betalningsinformation");
fields.clear();
fields.push_back("Account");
fields.push_back("PaymentDue");
oe->getDI().buildDataFields(gdi, fields);
gdi.pushX();
gdi.fillRight();
gdi.addString("", normalText, "Avgifter och valuta ställer du in under");
gdi.addString("CmpSettings", normalText, "Tävlingsinställningar.", ClubsCB);
gdi.fillDown();
gdi.dropLine(2);
gdi.popX();
gdi.addString("", boldText, "Formatering");
gdi.fillRight();
gdi.addString("", 0, "Koordinater (mm) för adressfält:");
string xc = oe->getPropertyString("addressxpos", "125");
string yc = oe->getPropertyString("addressypos", "50");
gdi.addStringUT(0, "x:");
gdi.addInput("XC", xc + " [mm]", 6);
gdi.addStringUT(0, "y:");
gdi.addInput("YC", yc + " [mm]", 6);
gdi.fillDown();
gdi.popX();
TabList::customTextLines(*oe, "IVExtra", gdi);
gdi.dropLine(1);
gdi.fillRight();
gdi.addButton("SaveSettings", "Spara", ClubsCB);
gdi.addButton("Cancel", "Avbryt", ClubsCB);
gdi.dropLine(2);
gdi.setOnClearCb(ClubsCB);
oe->getDI().fillDataFields(gdi);
}
else if (bi.id == "SaveSettings") {
oe->getDI().saveDataFields(gdi);
TabList::saveExtraLines(*oe, "IVExtra", gdi);
int fn = gdi.getTextNo("FirstInvoice");
if (fn != firstInvoice && oClub::getFirstInvoiceNumber(*oe) > 0) {
if (gdi.ask("Tilldela nya fakturanummer till alla klubbar?")) {
oe->setProperty("FirstInvoice", fn);
oClub::assignInvoiceNumber(*oe, true);
}
}
else
oe->setProperty("FirstInvoice", fn);
int xc = gdi.getTextNo("XC");
int yc = gdi.getTextNo("YC");
if (xc<=0 || yc<=0)
throw meosException("Invalid coordinate (x,y)");
oe->setProperty("addressxpos", xc);
oe->setProperty("addressypos", yc);
loadPage(gdi);
}
else if (bi.id == "Fees") {
gdi.clearPage(true);
gdi.addString("", boldLarge, "Tilldela avgifter");
gdi.dropLine();
gdi.addString("", 10, "help:assignfee");
gdi.dropLine();
gdi.pushX();
gdi.addSelection("ClassType", 150, 300, 0, "Klass / klasstyp:");
vector< pair<string, size_t> > types;
vector< pair<string, size_t> > classes;
oe->fillClassTypes(types);
oe->fillClasses(classes, oEvent::extraNone, oEvent::filterNone);
types.insert(types.end(), classes.begin(), classes.end());
gdi.addItem("ClassType", types);
gdi.addItem("ClassType", lang.tl("Alla typer"), -5);
gdi.selectItemByData("ClassType", -5);
gdi.fillRight();
gdi.dropLine(2);
gdi.addCheckbox("DefaultFees", "Manuella avgifter:", ClubsCB, useManualFee);
gdi.dropLine(-1);
int px = gdi.getCX();
gdi.addInput("BaseFee", oe->formatCurrency(baseFee), 8, 0, "Avgift:");
gdi.addInput("FirstDate", firstDate, 10, 0, "Undre datumgräns:", "ÅÅÅÅ-MM-DD");
gdi.addInput("LastDate", lastDate, 10, 0, "Övre datumgräns:", "ÅÅÅÅ-MM-DD");
manualFees(gdi, useManualFee);
gdi.setCX(px);
gdi.dropLine(4);
gdi.fillRight();
gdi.addCheckbox("FilterAge", "Åldersfilter:", ClubsCB, filterAge);
gdi.dropLine(-1);
gdi.addInput("LowLimit", lowAge > 0 ? itos(lowAge) : "", 5, 0, "Undre gräns (år):");
gdi.addInput("HighLimit", highAge > 0 ? itos(highAge) : "", 5, 0, "Övre gräns (år):");
ageFilter(gdi, filterAge, useManualFee);
gdi.popX();
gdi.fillDown();
gdi.dropLine(3);
gdi.addCheckbox("OnlyNoFee", "Tilldela endast avgift till deltagare utan avgift", ClubsCB, onlyNoFee);
gdi.pushX();
gdi.fillRight();
gdi.addButton("ShowFiltered", "Visa valda deltagare", ClubsCB);
gdi.addButton("DoFees", "Tilldela avgifter", ClubsCB);
gdi.addButton("ClearFees", "Nollställ avgifter", ClubsCB);
gdi.addButton("Cancel", "Återgå", ClubsCB);
gdi.popX();
gdi.fillDown();
gdi.dropLine(2);
gdi.refresh();
}
else if (bi.id == "FilterAge") {
ageFilter(gdi, gdi.isChecked(bi.id), gdi.isChecked("DefaultFees"));
}
else if (bi.id == "DefaultFees") {
manualFees(gdi, gdi.isChecked(bi.id));
ageFilter(gdi, gdi.isChecked("FilterAge"), gdi.isChecked(bi.id));
}
else if (bi.id == "DoFees" || bi.id == "ClearFees" ||
bi.id == "ShowFiltered" || bi.id == "ResetFees") {
readFeeFilter(gdi);
int op;
if (bi.id == "DoFees") {
if (useManualFee)
op = 0;
else
op = 2;
}
else if (bi.id == "ClearFees")
op = 1;
else if (bi.id == "ResetFees")
op = 2;
else
op = 3;
gdi.restore("FeeList", false);
gdi.setRestorePoint("FeeList");
gdi.fillDown();
vector<pRunner> filtered;
oe->sortRunners(ClassStartTimeClub);
string fdate, ldate;
int lage = 0, hage = 0;
if (useManualFee) {
fdate = firstDate;
ldate = lastDate;
if (filterAge) {
lage = lowAge;
hage = highAge;
}
}
oe->selectRunners(typeS, lage, hage, fdate, ldate, !onlyNoFee, filtered);
gdi.dropLine(2);
int modified = 0;
int count = 0;
for (size_t k = 0; k<filtered.size(); k++) {
if (op != 1 && filtered[k]->isVacant())
continue;
count++;
oDataInterface di = filtered[k]->getDI();
int fee = 0;
if (op == 0 || op == 1) {
if (op == 0)
fee = baseFee;
if (di.getInt("Fee") != fee) {
di.setInt("Fee", fee);
modified++;
filtered[k]->synchronize(true);
}
}
else if (op == 2) {
filtered[k]->addClassDefaultFee(true);
if (filtered[k]->isChanged())
modified++;
filtered[k]->synchronize(true);
fee = di.getInt("Fee");
}
else
fee = di.getInt("Fee");
string info = filtered[k]->getClass() + ", " + filtered[k]->getCompleteIdentification();
gdi.addStringUT(0, info + " (" + oe->formatCurrency(fee) + ")");
if (count % 5 == 0)
gdi.dropLine();
}
gdi.dropLine();
if (count == 0)
gdi.addString("", 1, "Ingen deltagare matchar sökkriteriet").setColor(colorRed);
else if (op == 0 || op == 2)
gdi.addString("", 1, "Ändrade avgift för X deltagare#" + itos(modified)).setColor(colorGreen);
else if (op == 1)
gdi.addString("", 1, "Nollställde avgift för X deltagare#" + itos(modified)).setColor(colorGreen);
gdi.refresh();
}
else if (bi.id=="Cancel") {
loadPage(gdi);
}
else if (bi.id=="Print") {
gdi.print(oe);
}
else if (bi.id=="PDF") {
vector< pair<string, string> > ext;
ext.push_back(make_pair("Portable Document Format (PDF)", "*.pdf"));
int index;
string file=gdi.browseForSave(ext, "pdf", index);
if (!file.empty()) {
pdfwriter pdf;
pdf.generatePDF(gdi, gdi.toWide(file), lang.tl("Faktura"), oe->getDCI().getString("Organizer"), gdi.getTL());
gdi.openDoc(file.c_str());
}
}
}
else if (type==GUI_LISTBOX){
ListBoxInfo bi=*(ListBoxInfo *)data;
if (bi.id=="Clubs"){
pClub pc=oe->getClub(bi.data);
if (!pc)
throw std::exception("Internal error");
selectClub(gdi, pc);
}
}
else if (type == GUI_LINK) {
TextInfo *ti = static_cast<TextInfo*>(data);
if (ti->id == "CmpSettings") {
if (gdi.hasField("SaveSettings"))
gdi.sendCtrlMessage("SaveSettings");
TabCompetition &tc = dynamic_cast<TabCompetition &>(*gdi.getTabs().get(TCmpTab));
tc.loadPage(gdi);
gdi.selectTab(tc.getTabId());
gdi.sendCtrlMessage("Settings");
return 0;
}
}
else if (type == GUI_CLEAR) {
if (gdi.isInputChanged("")) {
if (gdi.hasField("SaveSettings")) {
gdi.sendCtrlMessage("SaveSettings");
}
}
return 1;
}
return 0;
}
bool TabClub::loadPage(gdioutput &gdi)
{
oe->checkDB();
gdi.selectTab(tabId);
if (baseFee == 0) {
if (oe->getDCI().getInt("OrdinaryEntry") > 0)
lastDate = oe->getDCI().getDate("OrdinaryEntry");
baseFee = oe->getDCI().getInt("EntryFee");
lowAge = 0;
highAge = oe->getDCI().getInt("YouthAge");
}
gdi.clearPage(false);
gdi.fillDown();
gdi.addString("", boldLarge, "Klubbar");
gdi.dropLine(0.5);
gdi.pushX();
gdi.fillRight();
gdi.addSelection("Clubs", 200, 300, ClubsCB);
oe->fillClubs(gdi, "Clubs");
gdi.selectItemByData("Clubs", ClubId);
gdi.addButton("Merge", "Ta bort / slå ihop...", ClubsCB);
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy))
gdi.addButton("Invoice", "Faktura", ClubsCB);
if (oe->useRunnerDb())
gdi.addButton("Update", "Uppdatera", ClubsCB, "Uppdatera klubbens uppgifter med data från löpardatabasen/distriktsregistret");
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Economy)) {
gdi.popX();
gdi.dropLine(3);
gdi.addString("", boldText, "Ekonomi");
gdi.popX();
gdi.dropLine(1.5);
gdi.addButton("Fees", "Avgifter...", ClubsCB);
gdi.addButton("InvoiceSettings", "Fakturainställningar...", ClubsCB);
gdi.addButton("AllInvoice", "Skapa fakturor...", ClubsCB);
gdi.addButton("Summary", "Sammanställning", ClubsCB);
}
gdi.popX();
gdi.dropLine(3);
gdi.addString("", boldText, "Hantera klubbar");
gdi.popX();
gdi.dropLine(1.5);
if (oe->useRunnerDb()) {
gdi.addButton("UpdateAll", "Uppdatera alla klubbar", ClubsCB, "Uppdatera klubbarnas uppgifter med data från löpardatabasen/distriktsregistret");
gdi.addButton("UpdateAllRunners", "Uppdatera klubbar && löpare", ClubsCB, "Uppdatera klubbarnas och löparnas uppgifter med data från löpardatabasen/distriktsregistret");
}
gdi.addButton("EraseClubs", "Radera alla klubbar", ClubsCB, "Radera alla klubbar och ta bort klubbtillhörighet");
gdi.popX();
gdi.fillDown();
gdi.dropLine(2);
gdi.addString("", 10, "help:29758");
gdi.dropLine(1);
Table *tbl=oe->getClubsTB();
gdi.addTable(tbl, gdi.getCX(), gdi.getCY());
gdi.refresh();
return true;
}
void TabClub::importAcceptedInvoice(gdioutput &gdi, const string &file) {
gdi.addString("", boldLarge, "Hämta svar om elektroniska fakturor");
gdi.fillDown();
gdi.dropLine(2);
csvparser csv;
list< vector<string> > data;
csv.parse(file, data);
list< vector<string> >::iterator it;
map<int, pair<bool, string> > hasAccepted;
for (it = data.begin(); it != data.end(); ++it) {
if (it->size() == 3) {
int id = atoi((*it)[0].c_str());
bool accepted = trim((*it)[1]) == "OK";
pClub pc = oe->getClub(id);
if (pc) {
hasAccepted[id].first = accepted;
if ( hasAccepted[id].second.empty())
hasAccepted[id].second = (*it)[2];
else
hasAccepted[id].second += ", " + (*it)[2];
}
else
gdi.addString("", 0, "Okänd klubb med id X#" + itos(id)).setColor(colorRed);
}
else
throw meosException("Bad file format.");
}
gdi.pushX();
gdi.fillNone();
int margin = gdi.getCX() + gdi.scaleLength(30);
vector<pClub> clubs;
oe->getClubs(clubs, true);
bool anyAccepted = false;
int count = 0;
for (size_t k = 0; k < clubs.size(); k++) {
map<int, pair<bool, string> >::iterator res = hasAccepted.find(clubs[k]->getId());
if (res != hasAccepted.end() && res->second.first) {
if (!anyAccepted) {
gdi.dropLine();
gdi.addString("", 1, "Accepterade elektroniska fakturor");
gdi.dropLine();
gdi.popX();
anyAccepted = true;
}
clubs[k]->getDI().setString("Invoice", "A");
gdi.addStringUT(0, itos(++count) + ".");
gdi.setCX(margin);
gdi.addStringUT(0, clubs[k]->getName() + ", " + res->second.second);
gdi.dropLine();
gdi.popX();
}
}
bool anyNotAccepted = false;
count = 0;
for (size_t k = 0; k < clubs.size(); k++) {
map<int, pair<bool, string> >::iterator res = hasAccepted.find(clubs[k]->getId());
if (res != hasAccepted.end() && !res->second.first) {
if (!anyNotAccepted) {
gdi.dropLine();
gdi.addString("", 1, "Ej accepterade elektroniska fakturor");
gdi.dropLine();
gdi.popX();
anyNotAccepted = true;
}
clubs[k]->getDI().setString("Invoice", "P");
gdi.addStringUT(0, itos(++count) + ".");
gdi.setCX(margin);
gdi.addStringUT(0, clubs[k]->getName() + ", " + res->second.second);
gdi.dropLine();
gdi.popX();
}
}
bool anyNoAnswer = false;
count = 0;
for (size_t k = 0; k < clubs.size(); k++) {
string email = clubs[k]->getDCI().getString("EMail");
bool hasMail = !email.empty() && email.find_first_of('@') != email.npos;
map<int, pair<bool, string> >::iterator res = hasAccepted.find(clubs[k]->getId());
if (res == hasAccepted.end() ) {
if (!anyNoAnswer) {
gdi.dropLine();
gdi.addString("", 1, "Klubbar som inte svarat");
gdi.dropLine();
gdi.popX();
anyNoAnswer = true;
}
gdi.addStringUT(0, itos(++count) + ".");
gdi.setCX(margin);
if (hasMail)
gdi.addStringUT(0, clubs[k]->getName());
else
gdi.addString("", 0, "X (Saknar e-post)#" + clubs[k]->getName());
gdi.dropLine();
gdi.popX();
}
}
gdi.fillDown();
gdi.dropLine();
}
void TabClub::clearCompetitionData() {
}

63
code/TabClub.h Normal file
View File

@ -0,0 +1,63 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
class TabClub :
public TabBase
{
int clubCB(gdioutput &gdi, int type, void *data);
string firstDate;
string lastDate;
bool filterAge;
bool onlyNoFee;
bool useManualFee;
int highAge;
int lowAge;
int baseFee;
string typeS;
int firstInvoice;
int ClubId;
void readFeeFilter(gdioutput &gdi);
protected:
void clearCompetitionData();
public:
void selectClub(gdioutput &gdi, pClub pc);
void importAcceptedInvoice(gdioutput &gdi, const string &file);
const char * getTypeStr() const {return "TClubTab";}
TabType getType() const {return TClubTab;}
bool loadPage(gdioutput &gdi);
TabClub(oEvent *oe);
~TabClub(void);
friend int ClubsCB(gdioutput *gdi, int type, void *data);
};

3853
code/TabCompetition.cpp Normal file

File diff suppressed because it is too large Load Diff

150
code/TabCompetition.h Normal file
View File

@ -0,0 +1,150 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
#include "oFreeImport.h"
class PrefsEditor;
class ImportFormats;
class TabCompetition :
public TabBase
{
string eventorBase;
string iofExportVersion;
void textSizeControl(gdioutput &gdi) const;
bool showConnectionPage;
bool importFile(HWND hWnd, gdioutput &gdi);
bool exportFileAs(HWND hWnd, gdioutput &gdi);
bool save(gdioutput &gdi, bool write = true);
void loadRunnerDB(gdioutput &gdi, int tableToShow, bool updateTableOnly);
// Events from Eventor
vector<CompetitionInfo> events;
list<PrefsEditor> prefsEditor;
oFreeImport fi;
string entryText;
vector<oEntryBlock> entries;
void loadConnectionPage(gdioutput &gdi);
string defaultServer;
string defaultName;
string defaultPwd;
string defaultPort;
void copyrightLine(gdioutput &gdi) const;
void loadAboutPage(gdioutput &gdi) const;
int organizorId;
int lastChangeClassType;
struct {
string name;
string careOf;
string street;
string city;
string zipCode;
string account;
string email;
} eventor;
int getOrganizer(bool updateEvent);
void getAPIKey(vector< pair<string, string> > &key) const;
void getEventorCompetitions(gdioutput &gdi,
const string &fromDate,
vector<CompetitionInfo> &events) const;
void saveSettings(gdioutput &gdi);
void loadSettings(gdioutput &gdi);
void getEventorCmpData(gdioutput &gdi, int id,
const string &eventFile,
const string &clubFile,
const string &classFile,
const string &entryFile,
const string &dbFile) const;
void loadMultiEvent(gdioutput &gdi);
void saveMultiEvent(gdioutput &gdi);
string eventorOrigin; // The command used when checking eventor
bool checkEventor(gdioutput &gdi, ButtonInfo &bi);
bool useEventor() const;
bool useEventorUTC() const;
void openCompetition(gdioutput &gdi, int id);
void selectTransferClasses(gdioutput &gdi, bool expand);
// Welcome page for new users
void welcomeToMeOS(gdioutput &gdi);
// Class id for last selected class for entry
int lastSelectedClass;
set<int> allTransfer;
void displayRunners(gdioutput &gdi, const vector<pRunner> &changedClass) const;
void meosFeatures(gdioutput &gdi, bool newGuide);
void newCompetitionGuide(gdioutput &gdi, int step);
void entryForm(gdioutput &gdi, bool isGuide);
void saveEntries(gdioutput &gdi, bool removeRemoved, bool isGuide);
void setExportOptionsStatus(gdioutput &gdi, int format) const;
void selectStartlistOptions(gdioutput &gdi);
void selectExportSplitOptions(gdioutput &gdi);
void entryChoice(gdioutput &gdi);
void createCompetition(gdioutput &gdi);
void listBackups(gdioutput &gdi);
protected:
void clearCompetitionData();
public:
const char * getTypeStr() const {return "TCmpTab";}
TabType getType() const {return TCmpTab;}
void saveMeosFeatures(gdioutput &gdi, bool write);
void updateFeatureStatus(gdioutput &gdi);
void setEventorServer(const string &server);
void setEventorUTC(bool useUTC);
int competitionCB(gdioutput &gdi, int type, void *data);
int restoreCB(gdioutput &gdi, int type, void *data);
int newGuideCB(gdioutput &gdi, int type, void *data);
bool loadPage(gdioutput &gdi);
TabCompetition(oEvent *oe);
~TabCompetition(void);
};

529
code/TabControl.cpp Normal file
View File

@ -0,0 +1,529 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "resource.h"
#include <commctrl.h>
#include <commdlg.h>
#include <algorithm>
#include "oEvent.h"
#include "xmlparser.h"
#include "gdioutput.h"
#include "csvparser.h"
#include "SportIdent.h"
#include "meos_util.h"
#include "gdifonts.h"
#include "table.h"
#include <cassert>
#include "MeOSFeatures.h"
#include "TabControl.h"
TabControl::TabControl(oEvent *poe):TabBase(poe)
{
clearCompetitionData();
}
TabControl::~TabControl(void)
{
}
void TabControl::selectControl(gdioutput &gdi, pControl pc)
{
if (pc) {
pc->synchronize();
if (pc->getStatus() == oControl::StatusStart ||
pc->getStatus() == oControl::StatusFinish) {
gdi.selectItemByData("Controls", pc->getId());
gdi.selectItemByData("Status", oControl::StatusOK);
gdi.setText("ControlID", "-", true);
gdi.setText("Code", "");
gdi.setText("Name", pc->getName());
gdi.setText("TimeAdjust", "00:00");
gdi.setText("MinTime", "-");
gdi.setText("Point", "");
controlId = pc->getId();
gdi.enableInput("Remove");
gdi.enableInput("Save");
gdi.enableEditControls(false);
gdi.enableInput("Name");
}
else {
gdi.selectItemByData("Controls", pc->getId());
gdi.selectItemByData("Status", pc->getStatus());
const int numVisit = pc->getNumVisitors(true);
const int numVisitExp = pc->getNumVisitors(false);
string info;
if (numVisit > 0) {
info = "Antal besökare X, genomsnittlig bomtid Y, största bomtid Z#" +
itos(numVisit) + " (" + itos(numVisitExp) + ")#" + getTimeMS(pc->getMissedTimeTotal() / numVisit) +
"#" + getTimeMS(pc->getMissedTimeMax());
}
else if (numVisitExp > 0) {
info = "Förväntat antal besökare: X#" + itos(numVisitExp);
}
gdi.setText("ControlID", itos(pc->getId()), true);
gdi.setText("Info", lang.tl(info), true);
gdi.setText("Code", pc->codeNumbers());
gdi.setText("Name", pc->getName());
gdi.setText("TimeAdjust", pc->getTimeAdjustS());
gdi.setText("MinTime", pc->getMinTimeS());
if (gdi.hasField("Point"))
gdi.setText("Point", pc->getRogainingPointsS());
controlId = pc->getId();
gdi.enableInput("Remove");
gdi.enableInput("Save");
gdi.enableInput("Visitors");
gdi.enableInput("Courses");
gdi.enableEditControls(true);
oControl::ControlStatus st = pc->getStatus();
if (st == oControl::StatusRogaining || st == oControl::StatusNoTiming)
gdi.disableInput("MinTime");
if (st == oControl::StatusNoTiming)
gdi.disableInput("TimeAdjust");
if (gdi.hasField("Point") && st != oControl::StatusRogaining)
gdi.disableInput("Point");
}
}
else {
gdi.selectItemByData("Controls", -1);
gdi.selectItemByData("Status", oControl::StatusOK);
gdi.setText("Code", "");
gdi.setText("Name", "");
controlId = 0;
gdi.setText("ControlID", "-", true);
gdi.setText("TimeAdjust", "00:00");
if (gdi.hasField("Point"))
gdi.setText("Point", "");
gdi.disableInput("Remove");
gdi.disableInput("Save");
gdi.disableInput("Visitors");
gdi.disableInput("Courses");
gdi.enableEditControls(false);
}
}
int ControlsCB(gdioutput *gdi, int type, void *data)
{
TabControl &tc = dynamic_cast<TabControl &>(*gdi->getTabs().get(TControlTab));
return tc.controlCB(*gdi, type, data);
}
void TabControl::save(gdioutput &gdi)
{
if (controlId==0)
return;
DWORD pcid = controlId;
pControl pc;
pc = oe->getControl(pcid, false);
if (!pc)
throw std::exception("Internal error");
if (pc->getStatus() != oControl::StatusFinish && pc->getStatus() != oControl::StatusStart) {
if (!pc->setNumbers(gdi.getText("Code")))
gdi.alert("Kodsiffran måste vara ett heltal. Flera kodsiffror måste separeras med komma.");
pc->setStatus(oControl::ControlStatus(gdi.getSelectedItem("Status").first));
pc->setTimeAdjust(gdi.getText("TimeAdjust"));
if (pc->getStatus() != oControl::StatusRogaining) {
if (pc->getStatus() != oControl::StatusNoTiming)
pc->setMinTime(gdi.getText("MinTime"));
pc->setRogainingPoints(0);
}
else {
if (gdi.hasField("Point")) {
pc->setMinTime(0);
pc->setRogainingPoints(gdi.getTextNo("Point"));
}
}
}
pc->setName(gdi.getText("Name"));
pc->synchronize();
vector< pair<string, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
oe->reEvaluateAll(set<int>(), true);
selectControl(gdi, pc);
}
static void visitorTable(Table &table, void *ptr) {
TabControl *view = (TabControl *)ptr;
view->visitorTable(table);
}
static void courseTable(Table &table, void *ptr) {
TabControl *view = (TabControl *)ptr;
view->courseTable(table);
}
void TabControl::courseTable(Table &table) const {
vector<pRunner> r;
oe->getRunners(0, 0, r, false);
map<int, int> runnersPerCourse;
for (size_t k = 0; k < r.size(); k++) {
pCourse c = r[k]->getCourse(false);
int id = c != 0 ? c->getId() : 0;
++runnersPerCourse[id];
}
vector<pCourse> crs;
oe->getCourses(crs);
int ix = 1;
for (size_t k = 0; k < crs.size(); k++) {
vector<pControl> pc;
crs[k]->getControls(pc);
int used = 0;
for (size_t j = 0; j < pc.size(); j++) {
if (pc[j]->getId() == controlId) {
used++;
}
}
oCourse &it = *crs[k];
if (used > 0) {
table.addRow(ix++, &it);
int row = 0;
table.set(row++, it, TID_ID, itos(it.getId()), false);
table.set(row++, it, TID_MODIFIED, it.getTimeStamp(), false);
table.set(row++, it, TID_COURSE, crs[k]->getName(), false);
table.set(row++, it, TID_INDEX, itos(used), false);
table.set(row++, it, TID_RUNNER, itos(runnersPerCourse[crs[k]->getId()]), false);
}
}
}
void TabControl::visitorTable(Table &table) const {
vector<pCard> c;
oe->getCards(c);
pControl pc = oe->getControl(controlId, false);
if (!pc)
return;
vector<int> n;
pc->getNumbers(n);
struct PI {
PI(int c, int type, int t) : card(c), code(type), time(t) {}
int card;
int code;
int time;
bool operator<(const PI&c) const {
if (card != c.card)
return card < c.card;
else if (code != c.code)
return code < c.code;
else
return time < c.time;
}
bool operator==(const PI&c) const {
return c.card == card && c.code == code && c.time == time;
}
};
set<PI> registeredPunches;
vector<pPunch> p;
int ix=1;
for (size_t k = 0; k< c.size(); k++) {
oCard &it = *c[k];
it.getPunches(p);
//oPunch *punch = it.getPunchByType(pc->getFirstNumber()); //XXX
for (size_t j = 0; j < p.size(); j++) {
vector<int>::iterator res = find(n.begin(), n.end(), p[j]->getTypeCode());
if (res != n.end()) {
oPunch *punch = p[j];
registeredPunches.insert(PI(it.getCardNo(), p[j]->getTypeCode(), p[j]->getAdjustedTime()));
table.addRow(ix++, &it);
int row = 0;
table.set(row++, it, TID_ID, itos(it.getId()), false);
table.set(row++, it, TID_MODIFIED, it.getTimeStamp(), false);
pRunner r = it.getOwner();
if (r) {
table.set(row++, it, TID_RUNNER, r->getName(), false);
table.set(row++, it, TID_COURSE, r->getCourseName(), false);
}
else {
table.set(row++, it, TID_RUNNER, "-", false);
table.set(row++, it, TID_COURSE, "-", false);
}
table.set(row++, it, TID_FEE, punch->isUsedInCourse() ?
lang.tl("Ja") : lang.tl("Nej"), false);
table.set(row++, it, TID_CARD, it.getCardNoString(), false);
table.set(row++, it, TID_STATUS, punch->getTime(), false);
table.set(row++, it, TID_CONTROL, punch->getType(), false);
table.set(row++, it, TID_CODES, j>0 ? p[j-1]->getType() : "-", true);
}
}
}
}
int TabControl::controlCB(gdioutput &gdi, int type, void *data)
{
if (type==GUI_BUTTON) {
ButtonInfo bi=*(ButtonInfo *)data;
if (bi.id=="Save")
save(gdi);
else if (bi.id=="Add") {
bool rogaining = false;
if (controlId>0) {
save(gdi);
pControl pc = oe->getControl(controlId, false);
rogaining = pc && pc->getStatus() == oControl::StatusRogaining;
}
pControl pc = oe->addControl(0,oe->getNextControlNumber(), "");
if (rogaining)
pc->setStatus(oControl::StatusRogaining);
vector< pair<string, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
selectControl(gdi, pc);
}
else if (bi.id=="Remove") {
DWORD cid = controlId;
if (cid==0) {
gdi.alert("Ingen kontroll vald vald.");
return 0;
}
if (oe->isControlUsed(cid))
gdi.alert("Kontrollen används och kan inte tas bort.");
else
oe->removeControl(cid);
vector< pair<string, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
selectControl(gdi, 0);
}
else if (bi.id=="SwitchMode") {
if (!tableMode)
save(gdi);
tableMode = !tableMode;
loadPage(gdi);
}
else if (bi.id=="Visitors") {
save(gdi);
Table *table=new Table(oe, 20, "Kontroll X#" + itos(controlId), "controlvisitor");
table->addColumn("Id", 70, true, true);
table->addColumn("Ändrad", 70, false);
table->addColumn("Namn", 150, false);
table->addColumn("Bana", 70, false);
table->addColumn("På banan", 70, false);
table->addColumn("Bricka", 70, true, true);
table->addColumn("Tidpunkt", 70, false);
table->addColumn("Stämpelkod", 70, true);
table->addColumn("Föregående kontroll", 70, false);
table->setGenerator(::visitorTable, this);
table->setTableProp(0);
table->update();
gdi.clearPage(false);
int xp=gdi.getCX();
gdi.fillDown();
gdi.addButton("Show", "Återgå", ControlsCB);
gdi.addTable(table, xp, gdi.getCY());
gdi.refresh();
}
else if (bi.id=="Courses") {
Table *table=new Table(oe, 20, "Kontroll X#" + itos(controlId), "controlcourse");
table->addColumn("Id", 70, true, true);
table->addColumn("Ändrad", 70, false);
table->addColumn("Bana", 70, false, true);
table->addColumn("Förekomst", 70, true, true);
table->addColumn("Antal deltagare", 70, true, true);
table->setGenerator(::courseTable, this);
table->setTableProp(0);
table->update();
gdi.clearPage(false);
int xp=gdi.getCX();
gdi.fillDown();
gdi.addButton("Show", "Återgå", ControlsCB);
gdi.addTable(table, xp, gdi.getCY());
gdi.refresh();
}
else if (bi.id=="Show") {
loadPage(gdi);
}
}
else if (type==GUI_LISTBOX){
ListBoxInfo bi=*(ListBoxInfo *)data;
if (bi.id=="Controls") {
if (gdi.isInputChanged(""))
save(gdi);
pControl pc=oe->getControl(bi.data, false);
if (!pc)
throw std::exception("Internal error");
selectControl(gdi, pc);
}
else if (bi.id == "Status" ) {
gdi.setInputStatus("MinTime", bi.data != oControl::StatusRogaining && bi.data != oControl::StatusNoTiming, true);
gdi.setInputStatus("Point", bi.data == oControl::StatusRogaining, true);
gdi.setInputStatus("TimeAdjust", bi.data != oControl::StatusNoTiming, true);
}
}
else if (type==GUI_CLEAR) {
if (controlId>0)
save(gdi);
return true;
}
return 0;
}
bool TabControl::loadPage(gdioutput &gdi)
{
oe->checkDB();
gdi.selectTab(tabId);
gdi.clearPage(false);
int xp=gdi.getCX();
const int button_w=gdi.scaleLength(90);
string switchMode;
switchMode=tableMode ? "Formulärläge" : "Tabelläge";
gdi.addButton(2, 2, button_w, "SwitchMode", switchMode,
ControlsCB, "Välj vy", false, false).fixedCorner();
if (tableMode) {
Table *tbl=oe->getControlTB();
gdi.addTable(tbl, xp, 30);
return true;
}
gdi.fillDown();
gdi.addString("", boldLarge, "Kontroller");
gdi.pushY();
gdi.addListBox("Controls", 250, 530, ControlsCB).isEdit(false).ignore(true);
gdi.setTabStops("Controls", 40, 160);
vector< pair<string, size_t> > d;
oe->fillControls(d, oEvent::CTAll);
gdi.addItem("Controls", d);
gdi.newColumn();
gdi.fillDown();
gdi.popY();
gdi.pushX();
gdi.fillRight();
gdi.addString("", 1, "Kontrollens ID-nummer:");
gdi.fillDown();
gdi.addString("ControlID", 1, "#-").setColor(colorGreen);
gdi.popX();
gdi.fillRight();
gdi.addInput("Name", "", 16, 0, "Kontrollnamn:");
gdi.addSelection("Status", 150, 100, ControlsCB, "Status:", "Ange om kontrollen fungerar och hur den ska användas.");
oe->fillControlStatus(gdi, "Status");
gdi.addInput("TimeAdjust", "", 6, 0, "Tidsjustering:");
gdi.fillDown();
gdi.addInput("MinTime", "", 6, 0, "Minsta sträcktid:");
gdi.popX();
gdi.dropLine(0.5);
gdi.addString("", 10, "help:9373");
gdi.fillRight();
gdi.dropLine(0.5);
gdi.addInput("Code", "", 16, 0, "Stämpelkod(er):");
if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Rogaining)) {
gdi.addInput("Point", "", 6, 0, "Rogaining-poäng:");
}
gdi.popX();
gdi.dropLine(3.5);
gdi.fillRight();
gdi.addButton("Save", "Spara", ControlsCB, "help:save");
gdi.disableInput("Save");
gdi.addButton("Remove", "Radera", ControlsCB);
gdi.disableInput("Remove");
gdi.addButton("Courses", "Banor...", ControlsCB);
gdi.addButton("Visitors", "Besökare...", ControlsCB);
gdi.addButton("Add", "Ny kontroll", ControlsCB);
gdi.dropLine(2.5);
gdi.popX();
gdi.fillDown();
gdi.addString("Info", 0, "").setColor(colorGreen);
gdi.dropLine(1.5);
gdi.addString("", 10, "help:89064");
selectControl(gdi, oe->getControl(controlId, false));
gdi.setOnClearCb(ControlsCB);
gdi.refresh();
return true;
}
void TabControl::clearCompetitionData() {
tableMode = false;
controlId = 0;
}

52
code/TabControl.h Normal file
View File

@ -0,0 +1,52 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
class TabControl :
public TabBase
{
int controlCB(gdioutput &gdi, int type, void *data);
bool tableMode;
int controlId;
void save(gdioutput &gdi);
protected:
void clearCompetitionData();
public:
void visitorTable(Table &table) const;
void courseTable(Table &table) const;
void selectControl(gdioutput &gdi, pControl pc);
const char * getTypeStr() const {return "TControlTab";}
TabType getType() const {return TControlTab;}
bool loadPage(gdioutput &gdi);
TabControl(oEvent *oe);
~TabControl(void);
friend int ControlsCB(gdioutput *gdi, int type, void *data);
};

1158
code/TabCourse.cpp Normal file

File diff suppressed because it is too large Load Diff

77
code/TabCourse.h Normal file
View File

@ -0,0 +1,77 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
struct ClassDrawSpecification;
enum DrawMethod;
class TabCourse :
public TabBase
{
int courseId;
/** canSwitchViewMode: 0 = no, 1 = yes, 2 = switching to legs */
void save(gdioutput &gdi, int canSwitchViewMode);
int courseCB(gdioutput &gdi, int type, void *data);
bool addedCourse;
string time_limit;
string point_limit;
string point_reduction;
void fillCourseControls(gdioutput &gdi, const string &ctrl);
void fillOtherCourses(gdioutput &gdi, oCourse &crs);
void saveLegLengths(gdioutput &gdi);
vector<ClassDrawSpecification> courseDrawClasses;
DrawMethod getDefaultMethod() const;
string encodeCourse(const string &in, bool firstStart, bool lastFinish);
void refreshCourse(const string &text, gdioutput &gdi);
const string &formatControl(int id, string &bf) const;
protected:
void clearCompetitionData();
public:
void selectCourse(gdioutput &gdi, pCourse pc);
bool loadPage(gdioutput &gdi);
const char * getTypeStr() const {return "TCourseTab";}
TabType getType() const {return TCourseTab;}
TabCourse(oEvent *oe);
~TabCourse(void);
static void runCourseImport(gdioutput& gdi, const string &filename,
oEvent *oe, bool addClasses);
static void setupCourseImport(gdioutput& gdi, GUICALLBACK cb);
friend int CourseCB(gdioutput *gdi, int type, void *data);
};

2106
code/TabList.cpp Normal file

File diff suppressed because it is too large Load Diff

115
code/TabList.h Normal file
View File

@ -0,0 +1,115 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
#include "oListInfo.h"
class LiveResult;
class ListEditor;
class MethodEditor;
class TabList :
public TabBase
{
protected:
EStdListType currentListType;
oListInfo currentList;
string SelectedList;
string lastInputNumber;
int lastLimitPer;
bool lastInterResult;
bool lastSplitState;
bool lastLargeSize;
EStdListType getTypeFromResultIndex(int ix) const;
int infoCX;
int infoCY;
static void createListButtons(gdioutput &gdi);
void generateList(gdioutput &gdi);
void selectGeneralList(gdioutput &gdi, EStdListType type);
int offsetY;
int offsetX;
set<int> lastClassSelection;
vector<LiveResult *> liveResults;
int lastSelectedResultList;
set<int> lastResultClassSelection;
int lastLeg;
int lastFilledResultClassType;
void setResultOptionsFromType(gdioutput &gdi, int data);
bool hideButtons;
bool ownWindow;
ListEditor *listEditor;
MethodEditor *methodEditor;
bool noReEvaluate;
int baseButtons(gdioutput &gdi, int extraButtons);
private:
// Not supported, copy works not.
TabList(const TabList &);
const TabList &operator = (const TabList &);
public:
bool loadPage(gdioutput &gdi);
bool loadPage(gdioutput &gdi, const string &command);
// Clear up competition specific settings
void clearCompetitionData();
static void makeClassSelection(gdioutput &gdi);
static void makeFromTo(gdioutput &gdi);
static void enableFromTo(oEvent &oe, gdioutput &gdi, bool from, bool to);
void liveResult(gdioutput &gdi, oListInfo &currentList);
int listCB(gdioutput &gdi, int type, void *data);
void loadGeneralList(gdioutput &gdi);
void rebuildList(gdioutput &gdi);
void settingsResultList(gdioutput &gdi);
enum PrintSettingsSelection {
Splits = 0,
StartInfo = 1,
};
static void splitPrintSettings(oEvent &oe, gdioutput &gdi, bool setupPrinter, TabType returnMode, PrintSettingsSelection type);
static void customTextLines(oEvent &oe, const char *dataField, gdioutput &gdi);
static void saveExtraLines(oEvent &oe, const char *dataField, gdioutput &gdi);
static void enableWideFormat(gdioutput &gdi, bool wide);
ListEditor *getListeditor() const {return listEditor;}
const char * getTypeStr() const {return "TListTab";}
TabType getType() const {return TListTab;}
TabList(oEvent *oe);
~TabList(void);
friend int ListsEventCB(gdioutput *gdi, int type, void *data);
};

50
code/TabMulti.cpp Normal file
View File

@ -0,0 +1,50 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "resource.h"
#include <commctrl.h>
#include <commdlg.h>
#include "oEvent.h"
#include "xmlparser.h"
#include "gdioutput.h"
#include "csvparser.h"
#include "SportIdent.h"
#include "TabMulti.h"
TabMulti::TabMulti(oEvent *poe):TabBase(poe)
{
}
TabMulti::~TabMulti(void)
{
}
bool TabMulti::loadPage(gdioutput &gdi)
{
return true;
}

32
code/TabMulti.h Normal file
View File

@ -0,0 +1,32 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
class TabMulti :
public TabBase
{
public:
bool loadPage(gdioutput &gdi);
TabMulti(oEvent *oe);
~TabMulti(void);
};

2744
code/TabRunner.cpp Normal file

File diff suppressed because it is too large Load Diff

114
code/TabRunner.h Normal file
View File

@ -0,0 +1,114 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
#include "Printer.h"
class Table;
class TabRunner :
public TabBase
{
private:
void addToolbar(gdioutput &gdi);
const string &getSearchString() const;
void setCardNo(gdioutput &gdi, int cardNo);
void enableControlButtons(gdioutput &gdi, bool enable, bool vacant);
void cellAction(gdioutput &gdi, DWORD id, oBase *obj);
void selectRunner(gdioutput &gdi, pRunner r);
string lastSearchExpr;
stdext::hash_set<int> lastFilter;
DWORD timeToFill;
int inputId;
int searchCB(gdioutput &gdi, int type, void *data);
int runnerCB(gdioutput &gdi, int type, void *data);
int punchesCB(gdioutput &gdi, int type, void *data);
int vacancyCB(gdioutput &gdi, int type, void *data);
int currentMode;
pRunner save(gdioutput &gdi, int runnerId, bool dontReloadRunners);
void listRunners(gdioutput &gdi, const vector<pRunner> &r, bool filterVacant) const;
void fillRunnerList(gdioutput &gdi);
int cardModeStartY;
int lastRace;
string lastFee;
int runnerId;
bool ownWindow;
bool listenToPunches;
vector< pair<int, bool> > runnersToReport;
vector<pRunner> unknown_dns;
vector<pRunner> known_dns;
vector<pRunner> known;
vector<pRunner> unknown;
void clearInForestData();
PrinterObject splitPrinter;
void showRunnerReport(gdioutput &gdi);
void runnerReport(gdioutput &gdi, int id, bool compactReport);
void showVacancyList(gdioutput &gdi, const string &method="", int classId=0);
void showCardsList(gdioutput &gdi);
bool canSetStart(pRunner r) const;
bool canSetFinish(pRunner r) const;
void warnDuplicateCard(gdioutput &gdi, int cno, pRunner r);
pRunner warnDuplicateCard(int cno, pRunner r);
int numShorteningLevels() const;
void updateNumShort(gdioutput &gdi, pCourse crs, pRunner r);
static void autoGrowCourse(gdioutput &gdi);
protected:
void clearCompetitionData();
public:
const char * getTypeStr() const {return "TRunnerTab";}
TabType getType() const {return TRunnerTab;}
void showInForestList(gdioutput &gdi);
bool loadPage(gdioutput &gdi);
bool loadPage(gdioutput &gdi, int runnerId);
TabRunner(oEvent *oe);
~TabRunner(void);
friend int runnerSearchCB(gdioutput *gdi, int type, void *data);
friend int RunnerCB(gdioutput *gdi, int type, void *data);
friend int PunchesCB(gdioutput *gdi, int type, void *data);
friend int VacancyCB(gdioutput *gdi, int type, void *data);
};

3584
code/TabSI.cpp Normal file

File diff suppressed because it is too large Load Diff

229
code/TabSI.h Normal file
View File

@ -0,0 +1,229 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
#include "SportIdent.h"
#include "Printer.h"
#include "inthashmap.h"
struct PunchInfo;
class csvparser;
class TabSI : public TabBase {
public:
enum SIMode {
ModeReadOut,
ModeAssignCards,
ModeCheckCards,
ModeEntry,
ModeCardData
};
private:
/** Try to automatcally assign a class to runner (if none is given)
Return true if runner has a class on exist */
bool autoAssignClass(pRunner r, const SICard &sic);
void checkMoreCardsInQueue(gdioutput &gdi);
pRunner autoMatch(const SICard &sic, pRunner db_r);
void processPunchOnly(gdioutput &gdi, const SICard &sic);
void startInteractive(gdioutput &gdi, const SICard &sic,
pRunner r, pRunner db_r);
bool processCard(gdioutput &gdi, pRunner runner, const SICard &csic,
bool silent=false);
bool processUnmatched(gdioutput &gdi, const SICard &csic, bool silent);
void rentCardInfo(gdioutput &gdi, int width);
bool interactiveReadout;
bool useDatabase;
bool printSplits;
bool printStartInfo;
bool manualInput;
PrinterObject splitPrinter;
list< pair<unsigned, int> > printPunchRunnerIdQueue;
void addToPrintQueue(pRunner r);
vector<PunchInfo> punches;
vector<SICard> cards;
vector<string> filterDate;
int runnerMatchedId;
bool printErrorShown;
void printProtected(gdioutput &gdi, gdioutput &gdiprint);
//Interactive card assign
SIMode mode;
int currentAssignIndex;
void printSIInfo(gdioutput &gdi, const string &port) const;
void assignCard(gdioutput &gdi, const SICard &sic);
void entryCard(gdioutput &gdi, const SICard &sic);
void updateEntryInfo(gdioutput &gdi);
void generateEntryLine(gdioutput &gdi, pRunner r);
int lastClassId;
int lastClubId;
string lastFee;
int inputId;
void showCheckCardStatus(gdioutput &gdi, const string &cmd);
string getCardInfo(bool param, vector<int> &count) const;
// Formatting for card tick off
bool checkHeader;
int cardPosX;
int cardPosY;
int cardOffsetX;
int cardNumCol;
int cardCurrentCol;
enum CardNumberFlags {
// Basic flags
CNFChecked = 1,
CNFUsed = 2,
CNFNotRented = 4,
// Combinations
CNFCheckedAndUsed = 3,
CNFCheckedNotRented = 5,
CNFRentAndNotRent = 6,
CNFCheckedRentAndNotRent = 7,
};
map<int, CardNumberFlags> checkedCardFlags;
void checkCard(gdioutput &gdi, const SICard &sic, bool updateAll);
void showReadPunches(gdioutput &gdi, vector<PunchInfo> &punches, set<string> &dates);
void showReadCards(gdioutput &gdi, vector<SICard> &cards);
void showManualInput(gdioutput &gdi);
void showAssignCard(gdioutput &gdi, bool showHelp);
pRunner getRunnerByIdentifier(int id) const;
mutable inthashmap identifierToRunnerId;
mutable int minRunnerId;
void tieCard(gdioutput &gdi);
// Insert card without converting times and with/without runner
void processInsertCard(const SICard &csic);
void generateSplits(const pRunner r, gdioutput &gdi);
int logcounter;
csvparser *logger;
string insertCardNumberField;
void insertSICardAux(gdioutput &gdi, SICard &sic);
// Ask if card is to be overwritten
bool askOverwriteCard(gdioutput &gdi, pRunner r) const;
list< pair<int, SICard> > savedCards;
int savedCardUniqueId;
SICard &getCard(int id) const;
void showModeCardData(gdioutput &gdi);
void printCard(gdioutput &gdi, int cardId, bool forPrinter) const;
void generateSplits(int cardId, gdioutput &gdi);
static int analyzePunch(SIPunch &p, int &start, int &accTime, int &days);
void createCompetitionFromCards(gdioutput &gdi);
int NC;
class EditCardData : public GuiHandler {
TabSI *tabSI;
EditCardData(const EditCardData&);
EditCardData &operator=(const EditCardData&);
public:
EditCardData() : tabSI(0) {}
void handle(gdioutput &gdi, BaseInfo &info, GuiEventType type);
friend class TabSI;
};
EditCardData editCardData;
protected:
void clearCompetitionData();
public:
// Returns true if a repeated check should be done (there is more to print)
bool checkpPrintQueue(gdioutput &gdi);
struct StoredStartInfo {
string storedName;
string storedCardNo;
string storedClub;
string storedFee;
string storedPhone;
string storedStartTime;
bool allStages;
bool rentState;
bool hasPaid;
int payMode;
DWORD age;
int storedClassId;
void clear();
void checkAge();
StoredStartInfo() : rentState(false), age(0), storedClassId(0), hasPaid(0), payMode(0), allStages(false) {}
};
StoredStartInfo storedInfo;
void generatePayModeWidget(gdioutput &gdi) const;
static bool writePayMode(gdioutput &gdi, int amount, oRunner &r);
static SportIdent &getSI(const gdioutput &gdi);
void printerSetup(gdioutput &gdi);
void generateStartInfo(gdioutput &gdi, const oRunner &r);
bool hasPrintStartInfo() const {return printStartInfo;}
void setPrintStartInfo(bool info) {printStartInfo = info;}
int siCB(gdioutput &gdi, int type, void *data);
void logCard(const SICard &card);
void setCardNumberField(const string &fieldId) {insertCardNumberField=fieldId;}
//SICard CSIC;
SICard activeSIC;
list<SICard> CardQueue;
const char * getTypeStr() const {return "TSITab";}
TabType getType() const {return TSITab;}
void insertSICard(gdioutput &gdi, SICard &sic);
void refillComPorts(gdioutput &gdi);
bool loadPage(gdioutput &gdi);
TabSI(oEvent *oe);
~TabSI(void);
};

1048
code/TabSpeaker.cpp Normal file

File diff suppressed because it is too large Load Diff

117
code/TabSpeaker.h Normal file
View File

@ -0,0 +1,117 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
class SpeakerMonitor;
class spkClassSelection {
// The currently selected leg
int selectedLeg;
// True if total results, otherwise stage results
bool total;
// Given a leg, get the corresponding (control, previous control) to watch
map<int, pair<int, int> > legToControl;
public:
spkClassSelection() : selectedLeg(0), total(false) {}
void setLeg(bool totalIn, int leg) {total = totalIn, selectedLeg=leg;}
int getLeg() const {return selectedLeg;}
bool isTotal() const {return total;}
void setControl(int controlId, int previousControl) {
legToControl[selectedLeg] = make_pair(controlId, previousControl);
}
int getControl() {
if (legToControl.count(selectedLeg)==1)
return legToControl[selectedLeg].first;
else return -1;
}
int getPreviousControl() {
if (legToControl.count(selectedLeg)==1)
return legToControl[selectedLeg].second;
else return -1;
}
};
class TabSpeaker :
public TabBase {
private:
set<int> controlsToWatch;
set<int> classesToWatch;
set<int> controlsToWatchSI;
int lastControlToWatch;
int lastClassToWatch;
set<__int64> shownEvents;
vector<oTimeLine> events;
oTimeLine::Priority watchLevel;
int watchNumber;
void generateControlList(gdioutput &gdi, int classId);
void generateControlListForLeg(gdioutput &gdi, int classId, int leg);
string lastControl;
void manualTimePage(gdioutput &gdi) const;
void storeManualTime(gdioutput &gdi);
//Curren class-
int classId;
//Map CourseNo -> selected Control.
//map<int, int> selectedControl;
map<int, spkClassSelection> selectedControl;
bool ownWindow;
void drawTimeLine(gdioutput &gdi);
void splitAnalysis(gdioutput &gdi, int xp, int yp, pRunner r);
// Runner Id:s to set priority for
vector<int> runnersToSet;
SpeakerMonitor *speakerMonitor;
SpeakerMonitor *getSpeakerMonitor();
public:
bool onClear(gdioutput &gdi);
void loadPriorityClass(gdioutput &gdi, int classId);
void savePriorityClass(gdioutput &gdi);
void updateTimeLine(gdioutput &gdi);
//Clear selection data
void clearCompetitionData();
int processButton(gdioutput &gdi, const ButtonInfo &bu);
int processListBox(gdioutput &gdi, const ListBoxInfo &bu);
int handleEvent(gdioutput &gdi, const EventInfo &ei);
const char * getTypeStr() const {return "TSpeakerTab";}
TabType getType() const {return TSpeakerTab;}
bool loadPage(gdioutput &gdi);
TabSpeaker(oEvent *oe);
~TabSpeaker(void);
};

1899
code/TabTeam.cpp Normal file

File diff suppressed because it is too large Load Diff

93
code/TabTeam.h Normal file
View File

@ -0,0 +1,93 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "tabbase.h"
struct TeamLineup;
class TabTeam :
public TabBase
{
private:
bool save(gdioutput &gdi, bool dontReloadTeams);
string lastSearchExpr;
stdext::hash_set<int> lastFilter;
DWORD timeToFill;
int inputId;
int searchCB(gdioutput &gdi, int type, void *data);
int teamId;
int classId;
void selectTeam(gdioutput &gdi, pTeam t);
void updateTeamStatus(gdioutput &gdi, pTeam t);
void loadTeamMembers(gdioutput &gdi, int ClassId,
int ClubId, pTeam t);
int shownRunners;
int shownDistinctRunners;
const string &getSearchString() const;
void fillTeamList(gdioutput &gdi);
void addToolbar(gdioutput &gdi) const;
int currentMode;
void showTeamImport(gdioutput &gdi);
void doTeamImport(gdioutput &gdi);
void saveTeamImport(gdioutput &gdi, bool useExisting);
void showAddTeamMembers(gdioutput &gdi);
void doAddTeamMembers(gdioutput &gdi);
void showRunners(gdioutput &gdi, const char *title,
const set< pair<string, int> > &rToList,
int limitX, set<int> &usedR);
void processChangeRunner(gdioutput &gdi, pTeam t, int leg, pRunner r);
pRunner findRunner(const string &name, int cardNo) const;
vector<TeamLineup> teamLineup;
// Returns true if the warning concerns the same team
bool warnDuplicateCard(gdioutput &gdi, string id, int cno, pRunner r, vector<pRunner> &allRCache);
void switchRunners(pTeam team, int leg, pRunner r, pRunner oldR);
protected:
void clearCompetitionData();
public:
const char * getTypeStr() const {return "TTeamTab";}
TabType getType() const {return TTeamTab;}
int teamCB(gdioutput &gdi, int type, void *data);
bool loadPage(gdioutput &gdi, int id);
bool loadPage(gdioutput &gdi);
TabTeam(oEvent *oe);
~TabTeam(void);
friend int teamSearchCB(gdioutput *gdi, int type, void *data);
};

2316
code/Table.cpp Normal file

File diff suppressed because it is too large Load Diff

374
code/Table.h Normal file
View File

@ -0,0 +1,374 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include <vector>
#include <map>
#include <set>
#include "oBase.h"
#include "inthashmap.h"
#define TableXMargin 40
#define TableYMargin 30
enum CellType {cellEdit, cellSelection, cellAction, cellCombo};
enum KeyCommandCode;
class Table;
typedef void (*GENERATETABLEDATA)(Table &table, void *ptr);
struct TableUpdateInfo {
bool doAdd;
bool doRefresh;
oBase *object;
int id;
TableUpdateInfo() : doAdd(false), object(0), id(0), doRefresh(false) {}
};
class TableCell
{
string contents;
RECT absPos;
DWORD id;
oBase *owner;
bool canEdit;
CellType type;
friend class TableRow;
friend class Table;
friend int tblSelectionCB(gdioutput *gdi, int type, void *data);
};
class TableRow
{
protected:
string key;
int intKey;
vector<TableCell> cells;
int id;
string *SortString;
int sInt;
int ypos;
int height;
oBase *ob;
public:
oBase *getObject() const {return ob;}
void setObject(oBase &obj);
bool operator<(const TableRow &r){return *SortString<*r.SortString;}
static bool cmpint(const TableRow &r1, const TableRow &r2) {return r1.sInt<r2.sInt;}
TableRow(int elem, oBase *object): sInt(0)
{
cells.resize(elem);
SortString=&cells[0].contents;
ob = object;
id = -1;
}
TableRow(const TableRow &t)
{
cells=t.cells;
SortString=&cells[0].contents;
ob = t.ob;
id = t.id;
}
friend class Table;
friend struct TableSortIndex;
};
class gdioutput;
struct ColInfo
{
char name[64];
mutable int width;
int baseWidth;
bool isnumeric;
int padWidthZeroSort;
bool formatRight;
RECT title;
RECT condition;
string filter;
};
struct TableSortIndex;
class Table
{
protected:
GENERATETABLEDATA generator;
void *generatorPtr;
bool doAutoSelectColumns;
int t_xpos;
int t_ypos;
int t_maxX;
int t_maxY;
static int uniqueId;
int id;
bool clearOnHide;
bool commandLock;
string tableName;
string internalName;
vector<ColInfo> Titles;
vector<int> xpos;
unsigned nTitles;
int PrevSort;
mutable int rowHeight;
int baseRowHeight;
vector<TableRow> Data;
size_t dataPointer; // Insertation pointer
vector<TableSortIndex> sortIndex;
vector<int> columns;
inthashmap idToRow;
//highlight
int highRow;
int highCol;
// Selected columns. For drag/drop and sort
int colSelected;
int startX;
int startY;
//Edit selection
int editRow;
int editCol;
// Selected rectangle
int upperRow;
int lowerRow;
int upperCol;
int lowerCol;
int upperRowOld;
int lowerRowOld;
int upperColOld;
int lowerColOld;
bool startSelect;
HWND hEdit;
//For moving objects
HDC hdcCompatible;
HBITMAP hbmStored;
int lastX;
int lastY;
// For cell seletion
HDC hdcCompatibleCell;
HBITMAP hbmStoredCell;
RECT lastCell;
bool partialCell;
//static bool filterMatchString(const string &c, const char *filt);
void highlightCell(HDC hDC, gdioutput &gdi, const TableCell &cell, DWORD color, int dx, int dy);
void moveCell(HDC hDC, gdioutput &gdi, const TableCell &cell, int dx, int dy);
void startMoveCell(HDC hDC, const TableCell &cell);
void stopMoveCell(HDC hDC, const TableCell &cell, int dx, int dy);
void restoreCell(HDC hDC, const TableCell &cell);
void moveColumn(int src, int target);
int tableWidth;
int tableHeight;
bool drawFilterLabel;
int currentSortColumn;
void initEmpty();
int getColumn(int x, bool limit = false) const;
int getRow(int y, bool limit = false) const;
void redrawCell(gdioutput &gdi, HDC hDC, int c, int r);
//Draw coordinates
int table_xp;
int table_yp;
oEvent *oe;
void clearSelectionBitmap(gdioutput *gdi, HDC hDC);
void restoreSelection(gdioutput &gdi, HDC hDC);
void drawSelection(gdioutput &gdi, HDC hDC, bool forceDraw);
TableCell &getCell(int row, int col) const; //Index as displayed
void scrollToCell(gdioutput &gdi, int row, int col);
bool destroyEditControl(gdioutput &gdi);
void getExportData(int col1, int col2, int row1, int row2,
string &html, string &txt) const;
// Delete rows in selected range. Return number of rows that could not be removed
int deleteRows(int row1, int row2);
void getRowRange(int &rowLo, int &rowHi) const;
void getColRange(int &colLo, int &colHi) const;
int ownerCounter;
DWORD tableProp;
int selectionRow;
int selectionCol;
void getRowRect(int row, RECT &rc) const;
bool compareRow(int indexA, int indexB) const;
public:
void setTableText(gdioutput &gdi, int editRow, int editCol, const string &bf);
const string &getTableText(gdioutput &gdi, int editRow, int editCol);
int getTableId() const {return id;}
static void resetTableIds() {uniqueId = 1;}
void setGenerator(GENERATETABLEDATA gen, void *genPtr) {
generatorPtr = genPtr;
generator = gen;
}
void clear();
void setClearOnHide(bool coh) {clearOnHide = coh;}
int getNumDataRows() const;
void clearCellSelection(gdioutput *gdi);
/// Return translated table name
const string& getTableName() const {return tableName;}
/// Get the internal identifier of the table
const string& getInternalName() const {return internalName;}
bool hasAutoSelect() const {return doAutoSelectColumns;}
void updateDimension(gdioutput &gdi);
void selection(gdioutput &gdi, const string &text, int data);
enum {
CAN_PASTE = 1,
CAN_INSERT = 2,
CAN_DELETE = 4,
};
bool canPaste() const {return (tableProp & CAN_PASTE) != 0;}
bool canInsert() const {return (tableProp & CAN_INSERT) != 0;}
bool canDelete() const {return (tableProp & CAN_DELETE) != 0;}
void setTableProp(DWORD w) {tableProp = w;}
void hide(gdioutput &gdi); //Ensure no edit contol is visible
void addOwnership() {ownerCounter++;}
void releaseOwnership();
void autoAdjust(gdioutput &gdi); // Adjust column widths
void autoSelectColumns();
void insertRow(gdioutput &gdi); // Insert a new row in the table
bool deleteSelection(gdioutput &gdi);
void setPosition(int x, int y, int maxX, int maxY) {t_xpos = x, t_ypos = y; t_maxX = maxX, t_maxY = maxY;}
void exportClipboard(gdioutput &gdi);
void importClipboard(gdioutput &gdi);
bool hasEditControl() {return hEdit!=0;}
struct ColSelection {
ColSelection() : selected(false), index(0) {}
string name;
bool selected;
int index;
};
vector< ColSelection > getColumns() const;
void selectColumns(const set<int> &sel);
oEvent *getEvent() const {return oe;}
void getDimension(gdioutput &gdi, int &dx, int &dy, bool filteredResult) const;
void draw(gdioutput &gdi, HDC hDC, int dx, int dy,
const RECT &screen);
void print(gdioutput &gdi, HDC hDC, int dx, int dy);
//Returns true if capture is taken
bool mouseMove(gdioutput &gdi, int x, int y);
bool mouseLeftDown(gdioutput &gdi, int x, int y);
bool mouseLeftUp(gdioutput &gdi, int x, int y);
bool mouseLeftDblClick(gdioutput &gdi, int x, int y);
bool editCell(gdioutput &gdi, int row, int col);
bool keyCommand(gdioutput &gdi, KeyCommandCode code);
void sort(int col);
void filter(int col, const string &filt, bool forceFilter=false);
int addColumn(const string &Title, int width, bool isnum, bool formatRight = false);
int addColumnPaddedSort(const string &title, int width, int padding, bool formatRight = false);
void reserve(size_t siz);
TableRow *getRowById(int rowId);
void addRow(int rowId, oBase *object);
void set(int column, oBase &owner, int id, const string &data,
bool canEdit=true, CellType type=cellEdit);
//Reload a row from data
void reloadRow(int rowId);
bool UpDown(gdioutput &gdi, int direction);
bool tabFocus(gdioutput &gdi, int direction);
bool enter(gdioutput &gdi);
void escape(gdioutput &gdi);
bool inputChange(gdioutput &gdi, HWND hEdit);
void resetColumns();
void update();
Table(oEvent *oe_, int rowHeight,
const string &name, const string &tname);
~Table(void);
friend struct TableSortIndex;
};
struct TableSortIndex {
//TableSortIndex(const Table &t) : table(&t) {}
const static Table *table;
int index;
bool operator<(const TableSortIndex &t) const {return table->compareRow(index,t.index);}
//{return table->Data[index].key < table->Data[t.index].key;}
//bool operator<=(const TableSortIndex &t) const {return table->Data[index].key <= table->Data[t.index].key;}
};
enum {TID_CLASSNAME, TID_COURSE, TID_NUM, TID_ID, TID_MODIFIED,
TID_RUNNER, TID_CLUB, TID_START, TID_TIME,
TID_FINISH, TID_STATUS, TID_RUNNINGTIME, TID_PLACE,
TID_CARD, TID_TEAM, TID_LEG, TID_CONTROL, TID_CODES, TID_FEE, TID_PAID,
TID_INPUTTIME, TID_INPUTSTATUS, TID_INPUTPOINTS, TID_INPUTPLACE,
TID_NAME, TID_NATIONAL, TID_SEX, TID_YEAR, TID_INDEX, TID_ENTER, TID_STARTNO};

134
code/TimeStamp.cpp Normal file
View File

@ -0,0 +1,134 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
// TimeStamp.cpp: implementation of the TimeStamp class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "meos.h"
#include "TimeStamp.h"
#include <algorithm>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
const __int64 minYearConstant = 2014 - 1601;
TimeStamp::TimeStamp()
{
Time=0;
//Update();
}
TimeStamp::~TimeStamp()
{
}
void TimeStamp::update(TimeStamp &ts)
{
Time=max(Time, ts.Time);
}
void TimeStamp::update()
{
SYSTEMTIME st;
GetLocalTime(&st);
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
__int64 &currenttime=*(__int64*)&ft;
Time=unsigned((currenttime/10000000L) - minYearConstant*365*24*3600);
}
int TimeStamp::getAge() const
{
SYSTEMTIME st;
GetLocalTime(&st);
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
__int64 &currenttime=*(__int64*)&ft;
int CTime=int((currenttime/10000000)-minYearConstant*365*24*3600);
return CTime-Time;
}
string TimeStamp::getStamp() const
{
__int64 ft64=(__int64(Time)+minYearConstant*365*24*3600)*10000000;
FILETIME &ft=*(FILETIME*)&ft64;
SYSTEMTIME st;
FileTimeToSystemTime(&ft, &st);
char bf[32];
sprintf_s(bf, "%d%02d%02d%02d%02d%02d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
return bf;
}
string TimeStamp::getStampString() const
{
__int64 ft64=(__int64(Time)+minYearConstant*365*24*3600)*10000000;
FILETIME &ft=*(FILETIME*)&ft64;
SYSTEMTIME st;
FileTimeToSystemTime(&ft, &st);
char bf[32];
sprintf_s(bf, "%d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
return bf;
}
void TimeStamp::setStamp(string s)
{
if (s.size()<14)
return;
SYSTEMTIME st;
memset(&st, 0, sizeof(st));
//const char *ptr=s.c_str();
//sscanf(s.c_str(), "%4hd%2hd%2hd%2hd%2hd%2hd", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
st.wYear=atoi(s.substr(0, 4).c_str());
st.wMonth=atoi(s.substr(4, 2).c_str());
st.wDay=atoi(s.substr(6, 2).c_str());
st.wHour=atoi(s.substr(8, 2).c_str());
st.wMinute=atoi(s.substr(10, 2).c_str());
st.wSecond=atoi(s.substr(12, 2).c_str());
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
__int64 &currenttime=*(__int64*)&ft;
Time = unsigned((currenttime/10000000)-minYearConstant*365*24*3600);
}

49
code/TimeStamp.h Normal file
View File

@ -0,0 +1,49 @@
// TimeStamp.h: interface for the TimeStamp class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TIMESTAMP_H__CC16BFC5_ECD9_4D76_AC98_79F802314B65__INCLUDED_)
#define AFX_TIMESTAMP_H__CC16BFC5_ECD9_4D76_AC98_79F802314B65__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
class TimeStamp
{
unsigned int Time;
public:
void setStamp(string s);
string getStamp() const;
string getStampString() const;
int getAge() const;
unsigned int getModificationTime() const {return Time;}
void update();
void update(TimeStamp &ts);
TimeStamp();
virtual ~TimeStamp();
};
#endif // !defined(AFX_TIMESTAMP_H__CC16BFC5_ECD9_4D76_AC98_79F802314B65__INCLUDED_)

338
code/autotask.cpp Normal file
View File

@ -0,0 +1,338 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include <cassert>
#include "oEvent.h"
#include "autotask.h"
#include "TabAuto.h"
#include "TabSI.h"
#include "meos_util.h"
#include "socket.h"
const int SYNC_FACTOR = 4;
//#define DEBUGPRINT
//#define NODELAY
AutoTask::AutoTask(HWND hWnd, oEvent &oeIn, gdioutput &gdiIn) : hWndMain(hWnd), oe(oeIn), gdi(gdiIn) {
currentRevision = 0;
lock = false;
lastSynchTime = 0;
lastTriedSynchTime = 0;
autoSaveTimeBase = autoSaveTime = oe.getPropertyInt("AutoSaveTimeOut", (3*60+15)*1000);
synchBaseTime = oe.getPropertyInt("SynchronizationTimeOut", 2500);
maxDelay = oe.getPropertyInt("MaximumSpeakerDelay", 10000)/SYNC_FACTOR;
}
void AutoTask::autoSave() {
if (!oe.empty()) {
string msg;
try {
if (oe.getNumRunners() > 500)
gdi.setWaitCursor(true);
DWORD tic = GetTickCount();
oe.save();
DWORD toc = GetTickCount();
if (toc > tic) {
int timeToSave = toc - tic;
int interval = max(autoSaveTimeBase, timeToSave * 10);
if (abs(interval - autoSaveTime) > 4000) {
autoSaveTime = interval;
resetSaveTimer();
}
}
}
catch(std::exception &ex) {
msg=ex.what();
}
catch(...) {
msg="Ett okänt fel inträffade.";
}
if (!msg.empty()) {
gdi.alert(msg);
}
else
gdi.addInfoBox("", "Tävlingsdata har sparats.", 10);
gdi.setWaitCursor(false);
}
}
void AutoTask::resetSaveTimer() {
KillTimer(hWndMain, 1);
SetTimer(hWndMain, 1, autoSaveTime, 0); //Autosave
}
void AutoTask::setTimers() {
SetTimer(hWndMain, 2, 100, 0); //Interface timeout
SetTimer(hWndMain, 3, synchBaseTime, 0); //DataSync
}
void AutoTask::interfaceTimeout(const vector<gdioutput *> &windows) {
TabAuto *tabAuto = dynamic_cast<TabAuto *>(gdi.getTabs().get(TAutoTab));
TabSI *tabSI = dynamic_cast<TabSI *>(gdi.getTabs().get(TSITab));
if (lock)
return;
lock = true;
string msg;
try {
DWORD tick = GetTickCount();
for (size_t k = 0; k<windows.size(); k++) {
if (windows[k])
windows[k]->CheckInterfaceTimeouts(tick);
}
if (tabAuto)
tabAuto->timerCallback(gdi);
if (tabSI)
while(tabSI->checkpPrintQueue(gdi));
}
catch(std::exception &ex) {
msg=ex.what();
}
catch(...) {
msg="Ett okänt fel inträffade.";
}
if (!msg.empty()) {
gdi.alert(msg);
gdi.setWaitCursor(false);
}
lock = false;
}
void AutoTask::addSynchTime(DWORD tick) {
if (tick > 1000 * 60)
return; // Ignore extreme times
if (synchQueue.size () > 8)
synchQueue.pop_front();
synchQueue.push_back(tick);
}
DWORD AutoTask::getAvgSynchTime() {
#ifdef NODELAY
return 0;
#else
double res = 0;
for (size_t k = 0; k < synchQueue.size(); k++) {
double sq = synchQueue[k];
res += sq*sq;
}
if (res > 0)
res = sqrt(res) / double(synchQueue.size());
return min(int(res), maxDelay);
#endif
}
void AutoTask::synchronize(const vector<gdioutput *> &windows) {
DWORD tic = GetTickCount();
DWORD avg = getAvgSynchTime();
//OutputDebugString(("AVG Update Time: " + itos(avg)).c_str());
if (tic > lastSynchTime) {
DWORD since = tic - lastSynchTime;
if (since < avg * SYNC_FACTOR) {
//OutputDebugString((" skipped: " + itos(since) + "\n").c_str());
return;
}
//else
//OutputDebugString((" check: tsl = " + itos(since) + "\n").c_str());
}
else
lastSynchTime = tic;
if (oe.hasDirectSocket()) {
// Clear any incomming messages (already in db)
vector<SocketPunchInfo> pi;
oe.getDirectSocket().getPunchQueue(pi);
}
// Store last time we tried to synch
lastTriedSynchTime = tic;
if (synchronizeImpl(windows)) {
DWORD toc = GetTickCount();
if (toc > tic)
addSynchTime(toc-tic);
lastSynchTime = toc;
#ifdef DEBUGPRINT
OutputDebugString((" updated: " + itos(toc-tic) + "\n").c_str());
#endif
}
//OutputDebugString(" no update\n");
}
void AutoTask::advancePunchInformation(const vector<gdioutput *> &windows) {
DWORD tic = GetTickCount();
DWORD avg = getAvgSynchTime();
//OutputDebugString(("Direct Update Time: " + itos(avg)).c_str());
if (tic > lastSynchTime) {
DWORD since = tic-lastSynchTime;
if (since < avg * SYNC_FACTOR) {
//OutputDebugString((" skipped: " + itos(since) + "\n").c_str());
return;
}
}
else
lastSynchTime = tic;
DWORD since = tic - lastTriedSynchTime;
if (since > DWORD(synchBaseTime*4)) { // Synchronize all instead.
synchronize(windows);
return;
}
if (advancePunchInformationImpl(windows)) {
DWORD toc = GetTickCount();
if (toc > tic)
addSynchTime(toc-tic);
lastSynchTime = toc;
#ifdef DEBUGPRINT
OutputDebugString((" direct update: " + itos(toc-tic) + "\n").c_str());
#endif
}
}
bool AutoTask::synchronizeImpl(const vector<gdioutput *> &windows) {
if (lock)
return false;
lock = true;
DWORD d=0;
bool doSync = false;
bool doSyncPunch = false;
TabAuto *tabAuto = dynamic_cast<TabAuto *>(gdi.getTabs().get(TAutoTab));
for (size_t k = 0; k<windows.size(); k++) {
if (windows[k] && windows[k]->getData("DataSync", d)) {
doSync = true;
}
if (windows[k] && windows[k]->getData("PunchSync", d)) {
doSyncPunch = true;
doSync = true;
}
}
string msg;
bool ret = false;
try {
if (doSync || (tabAuto && tabAuto->synchronize)) {
if (tabAuto && tabAuto->synchronizePunches)
doSyncPunch = true;
if ( oe.autoSynchronizeLists(doSyncPunch) || oe.getRevision() != currentRevision) {
ret = true;
if (getAvgSynchTime() > 1000)
gdi.setWaitCursor(true);
if (doSync) {
for (size_t k = 0; k<windows.size(); k++) {
if (windows[k]) {
try {
windows[k]->makeEvent("DataUpdate", "autosync", 0, 0, false);
}
catch(std::exception &ex) {
msg = ex.what();
}
catch(...) {
msg = "Ett okänt fel inträffade.";
}
}
}
}
if (tabAuto)
tabAuto->syncCallback(gdi);
}
}
oe.resetSQLChanged(false, true);
}
catch (std::exception &ex) {
msg = ex.what();
}
catch (...) {
msg = "Ett okänt fel inträffade.";
}
currentRevision = oe.getRevision();
if (!msg.empty()) {
gdi.alert(msg);
}
lock = false;
gdi.setWaitCursor(false);
return ret;
}
bool AutoTask::advancePunchInformationImpl(const vector<gdioutput *> &windows) {
DWORD d=0;
bool doSync = false;
bool doSyncPunch = false;
for (size_t k = 0; k<windows.size(); k++) {
if (windows[k] && windows[k]->getData("DataSync", d)) {
doSync = true;
}
if (windows[k] && windows[k]->getData("PunchSync", d)) {
doSyncPunch = true;
doSync = true;
}
}
//string msg;
try {
if (oe.hasDirectSocket()) {
//OutputDebugString("Advance punch info\n");
vector<SocketPunchInfo> pi;
oe.getDirectSocket().getPunchQueue(pi);
bool ret = oe.advancePunchInformation(windows, pi, doSyncPunch, doSync);
if (ret)
oe.resetSQLChanged(false, true);
return ret;
}
}
catch (std::exception &ex) {
OutputDebugString(ex.what());
//msg = ex.what();
}
catch (...) {
//msg = "Ett okänt fel inträffade.";
}
return false;
}

74
code/autotask.h Normal file
View File

@ -0,0 +1,74 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include <vector>
#include <deque>
class oEvent;
class gdioutput;
class AutoTask {
private:
oEvent &oe;
gdioutput &gdi;
AutoTask &operator=(const AutoTask &);
bool synchronizeImpl(const vector<gdioutput *> &gdi);
bool advancePunchInformationImpl(const vector<gdioutput *> &windows);
long currentRevision;
bool lock;
deque<DWORD> synchQueue;
deque<DWORD> directQueue;
DWORD lastSynchTime;
DWORD lastTriedSynchTime;
void addSynchTime(DWORD tick);
DWORD getAvgSynchTime();
HWND hWndMain;
int autoSaveTime;
int autoSaveTimeBase;
int synchBaseTime;
int maxDelay; // The maximal delay between syncs
public:
void setTimers();
void resetSaveTimer();
AutoTask(HWND hWnd, oEvent &oe, gdioutput &gdi);
void autoSave();
/** Trigger timed text updates and gdi timeouts, service timeouts. */
void interfaceTimeout(const vector<gdioutput *> &windows);
/** Read updates from SQL (if connected) and update windows due to changed competition data.*/
void synchronize(const vector<gdioutput *> &windows);
/** Fetch fast advance information.*/
void advancePunchInformation(const vector<gdioutput *> &windows);
};

BIN
code/bitmap1.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

207
code/classconfiginfo.cpp Normal file
View File

@ -0,0 +1,207 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "oEvent.h"
#include "classconfiginfo.h"
#include "meos_util.h"
void ClassConfigInfo::clear() {
individual.clear();
relay.clear();
patrol.clear();
legNStart.clear();
raceNStart.clear();
legResult.clear();
raceNRes.clear();
rogainingClasses.clear();
timeStart.clear();
hasMultiCourse = false;
hasMultiEvent = false;
hasRentedCard = false;
classWithoutCourse.clear();
maximumLegNumber = 0;
results = false;
starttimes = false;
}
bool ClassConfigInfo::empty() const {
return individual.empty() && relay.empty() && patrol.empty() && raceNStart.empty();
}
void ClassConfigInfo::getIndividual(set<int> &sel) const {
sel.insert(individual.begin(), individual.end());
}
void ClassConfigInfo::getRelay(set<int> &sel) const {
sel.insert(relay.begin(), relay.end());
}
void ClassConfigInfo::getTeamClass(set<int> &sel) const {
sel.insert(relay.begin(), relay.end());
sel.insert(patrol.begin(), patrol.end());
if (!raceNStart.empty())
sel.insert(raceNRes[0].begin(), raceNRes[0].end());
}
bool ClassConfigInfo::hasTeamClass() const {
return !relay.empty() || !patrol.empty() || !raceNRes.empty();
}
void ClassConfigInfo::getPatrol(set<int> &sel) const {
sel.insert(patrol.begin(), patrol.end());
}
void ClassConfigInfo::getRogaining(set<int> &sel) const {
sel.insert(rogainingClasses.begin(), rogainingClasses.end());
}
void ClassConfigInfo::getRaceNStart(int race, set<int> &sel) const {
if (size_t(race) < raceNStart.size() && !raceNStart[race].empty())
sel.insert(raceNStart[race].begin(), raceNStart[race].end());
else
sel.clear();
}
void ClassConfigInfo::getLegNStart(int leg, set<int> &sel) const {
if (size_t(leg) < legNStart.size() && !legNStart[leg].empty())
sel.insert(legNStart[leg].begin(), legNStart[leg].end());
else
sel.clear();
}
void ClassConfigInfo::getRaceNRes(int race, set<int> &sel) const {
if (size_t(race) < raceNRes.size() && !raceNRes[race].empty())
sel.insert(raceNRes[race].begin(), raceNRes[race].end());
else
sel.clear();
}
void ClassConfigInfo::getLegNRes(int leg, set<int> &sel) const {
map<int, vector<int> >::const_iterator res = legResult.find(leg);
if (res != legResult.end())
sel.insert(res->second.begin(), res->second.end());
else
sel.clear();
}
void oEvent::getClassConfigurationInfo(ClassConfigInfo &cnf) const
{
oClassList::const_iterator it;
cnf.clear();
cnf.hasMultiEvent = hasPrevStage() || hasNextStage();
for (it = Classes.begin(); it != Classes.end(); ++it) {
if (it->isRemoved())
continue;
cnf.maximumLegNumber = max<int>(cnf.maximumLegNumber, it->getNumStages());
ClassType ct = it->getClassType();
if (it->isRogaining())
cnf.rogainingClasses.push_back(it->getId());
if (it->getCourse() == 0)
cnf.classWithoutCourse.push_back(it->getName()); //MultiCourse not analysed...
if ( !it->hasCoursePool() ) {
for (size_t k = 0; k< it->MultiCourse.size(); k++) {
if (it->MultiCourse[k].size() > 1)
cnf.hasMultiCourse = true;
}
}
if (ct == oClassIndividual) {
cnf.individual.push_back(it->getId());
if (cnf.timeStart.empty())
cnf.timeStart.resize(1);
cnf.timeStart[0].push_back(it->getId());
}
else if (ct == oClassPatrol)
cnf.patrol.push_back(it->getId());
else if (ct == oClassRelay) {
cnf.relay.push_back(it->getId());
if (cnf.legNStart.size() < it->getNumStages())
cnf.legNStart.resize(it->getNumStages());
for (size_t k = 0; k < it->getNumStages(); k++) {
StartTypes st = it->getStartType(k);
if (st == STDrawn || st == STHunting) {
cnf.legNStart[k].push_back(it->getId());
if (cnf.timeStart.size() <= k)
cnf.timeStart.resize(k+1);
cnf.timeStart[k].push_back(it->getId());
}
LegTypes lt = it->getLegType(k);
if (!it->isOptional(k) && !it->isParallel(k) && lt != LTGroup) {
int trueN, order;
it->splitLegNumberParallel(k, trueN, order);
cnf.legResult[trueN].push_back(it->getId());
}
}
}
else if (ct == oClassIndividRelay) {
if (cnf.raceNStart.size() < it->getNumStages())
cnf.raceNStart.resize(it->getNumStages());
if (cnf.raceNRes.size() < it->getNumStages())
cnf.raceNRes.resize(it->getNumStages());
for (size_t k = 0; k < it->getNumStages(); k++) {
StartTypes st = it->getStartType(k);
if (st == STDrawn || st == STHunting) {
cnf.raceNStart[k].push_back(it->getId());
if (cnf.timeStart.size() <= k)
cnf.timeStart.resize(k+1);
cnf.timeStart[k].push_back(it->getId());
}
LegTypes lt = it->getLegType(k);
if (lt != LTIgnore && lt != LTExtra && lt != LTGroup)
cnf.raceNRes[k].push_back(it->getId());
}
}
}
oRunnerList::const_iterator rit;
for (rit = Runners.begin(); rit != Runners.end(); ++rit) {
if (rit->isRemoved())
continue;
if (rit->getDCI().getInt("CardFee") != 0) {
cnf.hasRentedCard = true;
}
RunnerStatus st = rit->getStatus();
if (st != StatusUnknown && st != StatusDNS && st != StatusNotCompetiting)
cnf.results = true;
if (rit->getStartTime() > 0)
cnf.starttimes = true;
}
}

90
code/classconfiginfo.h Normal file
View File

@ -0,0 +1,90 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include <vector>
class ClassConfigInfo {
friend class oEvent;
private:
bool results;
bool starttimes;
int maximumLegNumber;
public:
vector < vector<int> > timeStart;
vector<int> individual;
vector<int> relay;
vector<int> patrol;
vector< vector<int> > legNStart;
vector< vector<int> > raceNStart;
map<int, vector<int> > legResult; // main leg number -> class selection
vector< vector<int> > raceNRes;
vector<int> rogainingClasses;
// True if predefined forking
bool hasMultiCourse;
bool hasMultiEvent;
// True if there are rented cards
bool hasRentedCard;
vector<string> classWithoutCourse;
void clear();
bool hasIndividual() const {return individual.size()>0;}
bool hasRelay() const {return relay.size()>0;}
bool hasPatrol() const {return patrol.size()>0;}
bool hasRogaining() const {return rogainingClasses.size()>0;}
bool empty() const;
// Return true of this is an event in a sequence of events.
bool isMultiStageEvent() const {return hasMultiEvent;}
void getIndividual(set<int> &sel) const;
void getRelay(set<int> &sel) const;
void getPatrol(set<int> &sel) const;
void getTeamClass(set<int> &sel) const;
void getRogaining(set<int> &sel) const;
bool hasTeamClass() const;
void getRaceNStart(int race, set<int> &sel) const;
void getLegNStart(int leg, set<int> &sel) const;
void getRaceNRes(int race, set<int> &sel) const;
void getLegNRes(int leg, set<int> &sel) const;
void getTimeStart(int leg, set<int> &sel) const;
// Return true if the competiont has any results
bool hasResults() const {return results;}
// Return true if the competition defines any start times;
bool hasStartTimes() const {return starttimes;}
int getNumLegsTotal() const {return maximumLegNumber;}
};

1
code/cp1250.lng Normal file
View File

@ -0,0 +1 @@
encoding = EASTEUROPE

1
code/cp1255.lng Normal file
View File

@ -0,0 +1 @@
encoding = HEBREW

1254
code/csvparser.cpp Normal file

File diff suppressed because one or more lines are too long

139
code/csvparser.h Normal file
View File

@ -0,0 +1,139 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
// csvparser.h: interface for the csvparser class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CSVPARSER_H__FD04656A_1D2A_4E6C_BE23_BD66052E276E__INCLUDED_)
#define AFX_CSVPARSER_H__FD04656A_1D2A_4E6C_BE23_BD66052E276E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <vector>
#include <map>
class oEvent;
struct SICard;
class ImportFormats;
struct PunchInfo {
int code;
int card;
int time;
char date[28];
};
struct TeamLineup {
struct TeamMember {
string name;
string club;
int cardNo;
string course;
string cls;
};
string teamName;
string teamClass;
string teamClub;
vector<TeamMember> members;
};
class csvparser
{
protected:
ofstream fout;
ifstream fin;
int LineNumber;
string ErrorMessage;
// Returns true if a SI-manager line is identified
bool checkSimanLine(const oEvent &oe, const vector<char *> &sp, SICard &cards);
// Check and setup header for SIConfig import
void checkSIConfigHeader(const vector<char *> &sp);
// Return true if SIConfig line was detected
bool checkSIConfigLine(const oEvent &oe, const vector<char *> &sp, SICard &card);
enum SIConfigFields {
sicSIID,
sicCheck,
sicCheckTime,
sicCheckDOW,
sicStart,
sicStartTime,
sicStartDOW,
sicFinish,
sicFinishTime,
sicFinishDOW,
sicNumPunch,
sicRecordStart,
sicFirstName,
sicLastName,
};
map<SIConfigFields, int> siconfigmap;
const char *getSIC(SIConfigFields sic, const vector<char *> &sp) const;
// Check and process a punch line
static int selectPunchIndex(const string &competitionDate, const vector<char *> &sp,
int &cardIndex, int &timeIndex, int &dateIndex,
string &processedTime, string &date);
public:
void parse(const string &file, list< vector<string> > &dataOutput);
void importTeamLineup(const string &file,
const map<string, int> &classNameToNumber,
vector<TeamLineup> &teams);
bool openOutput(const char *file);
bool closeOutput();
bool OutputRow(vector<string> &out);
bool OutputRow(const string &row);
int nimport;
bool ImportOCAD_CSV(oEvent &event, const char *file, bool addClasses);
bool ImportOS_CSV(oEvent &event, const char *file);
bool ImportRAID(oEvent &event, const char *file);
bool importPunches(const oEvent &oe, const char *file,
vector<PunchInfo> &punches);
bool importCards(const oEvent &oe, const char *file,
vector<SICard> &punches);
int split(char *line, vector<char *> &split);
bool ImportOE_CSV(oEvent &event, const char *file);
int iscsv(const char *file);
csvparser();
virtual ~csvparser();
};
#endif // !defined(AFX_CSVPARSER_H__FD04656A_1D2A_4E6C_BE23_BD66052E276E__INCLUDED_)

2237
code/danish.lng Normal file

File diff suppressed because it is too large Load Diff

457
code/download.cpp Normal file
View File

@ -0,0 +1,457 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "Download.h"
#include <Wininet.h>
#include "Localizer.h"
#include "meos_util.h"
#include "progress.h"
#include <sys/stat.h>
#include <io.h>
#include <fcntl.h>
#include <process.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Download::Download()
{
hThread = 0;
doExit = false;
//hProgress = NULL;
fileno = 0;
hInternet = NULL;
hURL = NULL;
bytesLoaded = 0;
bytesToLoad = 1024;
success = false;
}
Download::~Download()
{
shutDown();
endDownload();
if (hInternet)
InternetCloseHandle(hInternet);
}
void __cdecl SUThread(void *ptr)
{
Download *dwl=(Download *)ptr;
dwl->initThread();
}
bool Download::createDownloadThread() {
doExit=false;
hThread=_beginthread(SUThread, 0, this);
if (hThread==-1) {
hThread=0;
return false;
}
return true;
}
void Download::shutDown()
{
if (hThread) {
doExit=true;
int m=0;
while(m<100 && hThread) {
Sleep(0);
Sleep(10);
m++;
}
//If unsuccessful ending thread, do it violently
if (hThread) {
OutputDebugString("Terminate thread...\n");
TerminateThread(HANDLE(hThread), 0);
CloseHandle(HANDLE(hThread));
}
hThread=0;
}
}
void Download::initThread()
{
int status = true;
while(!doExit && status) {
status = doDownload();
}
hThread=0;
}
void Download::initInternet() {
hInternet = InternetOpen("MeOS", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hInternet==NULL) {
DWORD ec = GetLastError();
string error = lang.tl("Error: X#" + getErrorMessage(ec));
throw std::exception(error.c_str());
}
DWORD dwTimeOut = 120 * 1000;
InternetSetOption(hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD));
InternetSetOption(hInternet, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD));
}
void Download::downloadFile(const string &url, const string &file, const vector< pair<string, string> > &headers)
{
if (hURL || !hInternet)
throw std::exception("Not inititialized");
success = false;
string hdr;
for (size_t k = 0; k<headers.size(); k++)
hdr += headers[k].first + ": " + headers[k].second + "\r\n";
string url2 = url;
hURL = InternetOpenUrl(hInternet, url2.c_str(), hdr.empty() ? 0 : hdr.c_str(), hdr.length(), INTERNET_FLAG_DONT_CACHE, 0);
if (!hURL) {
int err = GetLastError();
string msg2 = getErrorMessage(err);
DWORD em = 0, blen = 256;
char bf2[256];
InternetGetLastResponseInfo(&em, bf2, &blen);
string msg = "Failed to connect to: " + url;
msg += " " + msg2;
if (bf2[0] != 0)
msg += " (" + string(bf2) + ")";
throw std::exception(msg.c_str());
}
DWORD dwContentLen = 0;
DWORD dwBufLen = sizeof(dwContentLen);
BOOL success = HttpQueryInfo(hURL,
HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwContentLen, &dwBufLen, 0);
if (success)
setBytesToDownload(dwContentLen);
else
setBytesToDownload(0);
DWORD dwStatus = 0;
dwBufLen = sizeof(dwStatus);
success = HttpQueryInfo(hURL, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwStatus, &dwBufLen, 0);
if (success) {
if (dwStatus >= 400) {
char bf[256];
switch (dwStatus) {
case HTTP_STATUS_BAD_REQUEST:
sprintf_s(bf, "HTTP Error 400: The request could not be processed by the server due to invalid syntax.");
break;
case HTTP_STATUS_DENIED:
sprintf_s(bf, "HTTP Error 401: The requested resource requires user authentication.");
break;
case HTTP_STATUS_FORBIDDEN:
sprintf_s(bf, "HTTP Error 403: Åtkomst nekad (access is denied).");
break;
case HTTP_STATUS_NOT_FOUND:
sprintf_s(bf, "HTTP Error 404: Resursen kunde ej hittas (not found).");
break;
case HTTP_STATUS_NOT_SUPPORTED:
sprintf_s(bf, "HTTP Error 501: Förfrågan stöds ej (not supported).");
break;
case HTTP_STATUS_SERVER_ERROR:
sprintf_s(bf, "HTTP Error 500: Internt serverfel (server error).");
break;
default:
sprintf_s(bf, "HTTP Status Error %d", dwStatus);
}
throw dwException(bf, dwStatus);
}
}
fileno=_open(file.c_str(), O_BINARY|O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE);
if (fileno==-1) {
fileno=0;
endDownload();
char bf[256];
sprintf_s(bf, "Error opening '%s' for writing", file.c_str());
throw std::exception(bf);
}
bytesLoaded = 0;
return;
}
void Download::endDownload()
{
if (hURL && hInternet) {
InternetCloseHandle(hURL);
hURL=NULL;
}
if (fileno) {
_close(fileno);
fileno=0;
}
}
bool Download::doDownload()
{
if (hURL && hInternet) {
char buffer[512];
DWORD bRead;
if (InternetReadFile(hURL, buffer, 512, &bRead)) {
//Success!
if (bRead==0) {
//EOF
success=true;
endDownload();
}
else{
if (_write(fileno, buffer, bRead) != int(bRead)) {
endDownload();
return false;
}
bytesLoaded+=bRead;
return true;
}
}
}
return false;
}
void Download::setBytesToDownload(DWORD btd)
{
bytesToLoad = btd;
}
bool Download::isWorking()
{
return hThread!=0;
}
bool Download::successful()
{
return success;
}
void Download::postFile(const string &url, const string &file, const string &fileOut,
const vector< pair<string, string> > &headers, ProgressWindow &pw) {
SetLastError(0);
DWORD_PTR dw = 0;
URL_COMPONENTS uc;
memset(&uc, 0, sizeof(uc));
uc.dwStructSize = sizeof(uc);
char host[128];
char path[128];
char extra[256];
uc.lpszExtraInfo = extra;
uc.dwExtraInfoLength = sizeof(extra);
uc.lpszHostName = host;
uc.dwHostNameLength = sizeof(host);
uc.lpszUrlPath = path;
uc.dwUrlPathLength = sizeof(path);
InternetCrackUrl(url.c_str(), url.length(), ICU_ESCAPE, &uc);
int port = INTERNET_DEFAULT_HTTP_PORT;
if (uc.nScheme == INTERNET_SCHEME_HTTPS)
port = INTERNET_DEFAULT_HTTPS_PORT;
else if (uc.nPort>0)
port = uc.nPort;
HINTERNET hConnect = InternetConnect(hInternet, host, port,
NULL, NULL, INTERNET_SERVICE_HTTP, 0, dw);
bool success = false;
int errorCode = 0;
try {
success = httpSendReqEx(hConnect, path, headers, file, fileOut, pw, errorCode);
}
catch (std::exception &) {
InternetCloseHandle(hConnect);
throw;
}
InternetCloseHandle(hConnect);
if (!success) {
if (errorCode != 0)
errorCode = GetLastError();
string error = errorCode != 0 ? getErrorMessage(errorCode) : "";
if (error.empty())
error = "Ett okänt fel inträffade.";
throw std::exception(error.c_str());
}
}
bool Download::httpSendReqEx(HINTERNET hConnect, const string &dest,
const vector< pair<string, string> > &headers,
const string &upFile, const string &outFile,
ProgressWindow &pw,
int &errorCode) const {
errorCode = 0;
INTERNET_BUFFERS BufferIn;
memset(&BufferIn, 0, sizeof(BufferIn));
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );
HINTERNET hRequest = HttpOpenRequest (hConnect, "POST", dest.c_str(), NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
DWORD dwBytesRead = 0;
DWORD dwBytesWritten = 0;
BYTE pBuffer[4*1024]; // Read from file in 4K chunks
string hdr;
for (size_t k = 0; k<headers.size(); k++) {
if (!trim(headers[k].second).empty()) {
hdr += headers[k].first + ": " + headers[k].second + "\r\n";
}
}
int retry = 5;
while (retry>0) {
HANDLE hFile = CreateFile(upFile.c_str(), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == HANDLE(-1))
return false;
BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
BufferIn.dwHeadersLength = hdr.length();
BufferIn.lpcszHeader = hdr.c_str();
double totSize = BufferIn.dwBufferTotal;
if (!HttpSendRequestEx( hRequest, &BufferIn, NULL, 0, 0)) {
CloseHandle(hFile);
InternetCloseHandle(hRequest);
return false;
}
DWORD sum = 0;
do {
if (!ReadFile (hFile, pBuffer, sizeof(pBuffer), &dwBytesRead, NULL)) {
errorCode = GetLastError();
CloseHandle(hFile);
InternetCloseHandle(hRequest);
return false;
}
if (dwBytesRead > 0) {
if (!InternetWriteFile(hRequest, pBuffer, dwBytesRead, &dwBytesWritten)) {
errorCode = GetLastError();
CloseHandle(hFile);
InternetCloseHandle(hRequest);
return false;
}
}
sum += dwBytesWritten;
try {
pw.setProgress(int(1000 * double(sum) / totSize));
}
catch (std::exception &) {
CloseHandle(hFile);
InternetCloseHandle(hRequest);
throw;
}
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle(hFile);
if (!HttpEndRequest(hRequest, NULL, 0, 0)) {
DWORD error = GetLastError();
errorCode = error;
if (error == ERROR_INTERNET_FORCE_RETRY)
retry--;
else if (error == ERROR_INTERNET_TIMEOUT) {
throw std::exception("Fick inget svar i tid (ERROR_INTERNET_TIMEOUT)");
}
else {
InternetCloseHandle(hRequest);
return false;
}
}
else
retry = 0; // Done
}
DWORD dwStatus = 0;
DWORD dwBufLen = sizeof(dwStatus);
int success = HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
(LPVOID)&dwStatus, &dwBufLen, 0);
if (success) {
if (dwStatus >= 400) {
char bf[256];
switch (dwStatus) {
case HTTP_STATUS_BAD_REQUEST:
sprintf_s(bf, "HTTP Error 400: The request could not be processed by the server due to invalid syntax.");
break;
case HTTP_STATUS_DENIED:
sprintf_s(bf, "HTTP Error 401: The requested resource requires user authentication.");
break;
case HTTP_STATUS_FORBIDDEN:
sprintf_s(bf, "HTTP Error 403: Åtkomst nekad (access is denied).");
break;
case HTTP_STATUS_NOT_FOUND:
sprintf_s(bf, "HTTP Error 404: Resursen kunde ej hittas (not found).");
break;
case HTTP_STATUS_NOT_SUPPORTED:
sprintf_s(bf, "HTTP Error 501: Förfrågan stöds ej (not supported).");
break;
case HTTP_STATUS_SERVER_ERROR:
sprintf_s(bf, "HTTP Error 500: Internt serverfel (server error).");
break;
default:
sprintf_s(bf, "HTTP Status Error %d", dwStatus);
}
throw dwException(bf, dwStatus);
}
}
int fileno = _open(outFile.c_str(), O_BINARY|O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE);
do {
dwBytesRead=0;
if (InternetReadFile(hRequest, pBuffer, sizeof(pBuffer)-1, &dwBytesRead)) {
_write(fileno, pBuffer, dwBytesRead);
}
} while(dwBytesRead>0);
_close(fileno);
InternetCloseHandle(hRequest);
return true;
}

91
code/download.h Normal file
View File

@ -0,0 +1,91 @@
// Download.h: interface for the Download class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DOWNLOAD_H__DEBC6296_9CAE_4FF6_867B_DD896D0B6A7A__INCLUDED_)
#define AFX_DOWNLOAD_H__DEBC6296_9CAE_4FF6_867B_DD896D0B6A7A__INCLUDED_
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <vector>
typedef HANDLE HINTERNET;
class dwException : public std::exception {
public:
int code;
dwException(const char *msg, int id) : std::exception(msg), code(id) {}
virtual ~dwException() {}
};
class ProgressWindow;
class Download {
private:
volatile unsigned hThread;
volatile bool doExit;
//HWND hProgress;
HINTERNET hInternet;
HINTERNET hURL;
int fileno;
DWORD bytesLoaded;
DWORD bytesToLoad;
bool success;
void initThread();
bool httpSendReqEx(HINTERNET hConnect, const string &dest, const vector< pair<string, string> > &headers,
const string &upFile, const string &outFile, ProgressWindow &pw, int &errroCode) const;
public:
void postFile(const string &url, const string &file, const string &fileOut,
const vector< pair<string, string> > &headers, ProgressWindow &pw);
int processMessages();
bool successful();
bool isWorking();
void setBytesToDownload(DWORD btd);
void endDownload();
void downloadFile(const string &url, const string &file, const vector< pair<string, string> > &headers);
void initInternet();
void shutDown();
bool createDownloadThread();
void downLoadNoThread() {initThread();}
Download();
virtual ~Download();
protected:
bool doDownload();
friend void SUThread(void *ptr);
};
#endif // !defined(AFX_DOWNLOAD_H__DEBC6296_9CAE_4FF6_867B_DD896D0B6A7A__INCLUDED_)

2241
code/english.lng Normal file

File diff suppressed because it is too large Load Diff

2241
code/french.lng Normal file

File diff suppressed because it is too large Load Diff

44
code/gdiconstants.h Normal file
View File

@ -0,0 +1,44 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#ifndef GDI_CONSTANTS
#define GDI_CONSTANTS
#include "gdifonts.h"
enum KeyCommandCode {
KC_NONE,
KC_COPY,
KC_PASTE,
KC_DELETE,
KC_INSERT,
KC_PRINT,
KC_FIND,
KC_FINDBACK,
KC_REFRESH,
KC_SPEEDUP,
KC_SLOWDOWN,
KC_AUTOCOMPLETE,
};
const int GDI_BUTTON_SPACING = 8;
#endif

78
code/gdifonts.h Normal file
View File

@ -0,0 +1,78 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2012 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#pragma once
enum gdiFonts {
normalText=0,
boldText=1,
boldLarge=2,
boldHuge=3,
boldSmall=5,
italicText = 6,
italicMediumPlus = 7,
monoText = 8,
fontLarge=11,
fontMedium=12,
fontSmall=13,
fontMediumPlus=14,
italicSmall = 15,
formatIgnore = 1000,
};
const int pageNewPage=100;
//const int pageReserveHeight=101;
const int pagePageInfo=102;
const int textRight=256;
const int textCenter=512;
const int timerCanBeNegative=1024;
const int breakLines=2048;
const int fullTimeHMS = 4096;
const int timeWithTenth = 1<<13;
const int timeSeconds = 1<<14;
const int timerIgnoreSign = 1<<15;
const int Capitalize = 1<<16;
enum GDICOLOR {colorBlack = RGB(0,0,0),
colorRed = RGB(128,0,0),
colorGreen = RGB(0,128,0),
colorDarkGrey = RGB(40,40,40),
colorDarkRed = RGB(64,0,0),
colorGreyBlue = RGB(92,92,128),
colorDarkBlue = RGB(0,0,92),
colorDarkGreen = RGB(0,64,0),
colorYellow = RGB(255, 230, 0),
colorLightBlue = RGB(240,240,255),
colorLightRed = RGB(255,230,230),
colorLightGreen = RGB(180, 255, 180),
colorLightYellow = RGB(255, 255, 200),
colorLightCyan = RGB(200, 255, 255),
colorLightMagenta = RGB(255, 200, 255),
colorMediumRed = RGB(255,200,200),
colorMediumDarkRed = RGB(240,120,120),
colorWindowBar = -2,
colorDefault = -1};

76
code/gdiimpl.h Normal file
View File

@ -0,0 +1,76 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#pragma once
class gdioutput;
struct FontInfo;
class GDIImplFontSet {
HFONT Huge;
HFONT Large;
HFONT Medium;
HFONT Small;
HFONT pfLarge;
HFONT pfMedium;
HFONT pfSmall;
HFONT pfMediumPlus;
HFONT pfMono;
HFONT pfSmallItalic;
HFONT pfItalicMediumPlus;
HFONT pfItalic;
void deleteFonts();
string gdiName;
mutable vector<double> avgWidthCache;
int charSet;
public:
static float baseSize(int format, float scale);
void getInfo(FontInfo &fi) const;
GDIImplFontSet();
virtual ~GDIImplFontSet();
void init(double scale, int charSet, const string &font, const string &gdiName);
void selectFont(HDC hDC, int format) const;
HFONT getGUIFont() const {return pfMedium;}
HFONT getFont(int format) const;
double getAvgFontWidth(const gdioutput &gdi, gdiFonts font) const;
};
class GDIImplFontEnum {
private:
int width;
int height;
double relScale;
string face;
public:
GDIImplFontEnum();
virtual ~GDIImplFontEnum();
const string &getFace() const {return face;}
double getRelScale() const {return relScale;}
friend int CALLBACK enumFontProc(const LOGFONT* logFont, const TEXTMETRIC *metric, DWORD id, LPARAM lParam);
};

6544
code/gdioutput.cpp Normal file

File diff suppressed because it is too large Load Diff

654
code/gdioutput.h Normal file
View File

@ -0,0 +1,654 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
// gdioutput.h: interface for the gdioutput class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GDIOUTPUT_H__396F60F8_679F_498A_B759_DF8F6F346A4A__INCLUDED_)
#define AFX_GDIOUTPUT_H__396F60F8_679F_498A_B759_DF8F6F346A4A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <set>
#include <map>
#include <vector>
#include <hash_set>
#include <hash_map>
#include <algorithm>
class Toolbar;
class gdioutput;
class oEvent;
typedef oEvent *pEvent;
struct PrinterObject;
class GDIImplFontEnum;
class GDIImplFontSet;
class Table;
class FixedTabs;
struct PageInfo;
struct RenderedPage;
typedef int (*GUICALLBACK)(gdioutput *gdi, int type, void *data);
enum GDICOLOR;
enum KeyCommandCode;
enum gdiFonts;
#include "gdistructures.h"
#define START_YP 30
#define NOTIMEOUT 0x0AAAAAAA
typedef list<ToolInfo> ToolList;
enum FontEncoding {
ANSI, Russian, EastEurope, Hebrew
};
FontEncoding interpetEncoding(const string &enc);
struct FontInfo {
const string *name;
HFONT normal;
HFONT bold;
HFONT italic;
};
class Recorder;
class gdioutput {
protected:
string tag;
// Database error state warning
bool dbErrorState;
// Flag set to true when clearPage is called.
bool hasCleared;
bool useTables;
FontEncoding fontEncoding;
// Set to true when in test mode
bool isTestMode;
int getCharSet() const;
bool highContrast;
void deleteFonts();
void constructor(double _scale);
void updateStringPosCache();
vector<TextInfo *> shownStrings;
void enableCheckBoxLink(TextInfo &ti, bool enable);
//void CalculateCS(TextInfo &text);
//void printPage(PrinterObject &po, int StartY, int &EndY, bool calculate);
void printPage(PrinterObject &po, const PageInfo &pageInfo, RenderedPage &page);
bool startDoc(PrinterObject &po);
bool getSelectedItem(ListBoxInfo &lbi);
bool doPrint(PrinterObject &po, PageInfo &pageInfo, pEvent oe);
PrinterObject *po_default;
void restoreInternal(const RestoreInfo &ri);
void drawCloseBox(HDC hDC, RECT &Close, bool pressed);
void setFontCtrl(HWND hWnd);
list<TextInfo> TL;
//True if textlist has increasing y-values so
//that we can optimize rendering.
bool renderOptimize;
//Stored iterator used to optimize rendering
//by avoiding to loop through complete TL.
list<TextInfo>::iterator itTL;
list<ButtonInfo> BI;
stdext::hash_map<HWND, ButtonInfo *> biByHwnd;
list<InputInfo> II;
stdext::hash_map<HWND, InputInfo *> iiByHwnd;
list<ListBoxInfo> LBI;
stdext::hash_map<HWND, ListBoxInfo *> lbiByHwnd;
list<DataStore> DataInfo;
list<EventInfo> Events;
list<RectangleInfo> Rectangles;
list<TableInfo> Tables;
list<TimerInfo> timers;
Toolbar *toolbar;
ToolList toolTips;
map<string, RestoreInfo> restorePoints;
GUICALLBACK onClear;
GUICALLBACK postClear;
list<InfoBox> IBox;
list<HWND> FocusList;
struct FucusInfo {
bool wasTabbed;
HWND hWnd;
FucusInfo() : wasTabbed(false), hWnd(false) {}
FucusInfo(HWND wnd) : wasTabbed(false), hWnd(wnd) {}
};
FucusInfo currentFocus;
int lineHeight;
HWND hWndTarget;
HWND hWndAppMain;
HWND hWndToolTip;
HWND hWndTab;
HBRUSH Background;
map<string, GDIImplFontSet> fonts;
const GDIImplFontSet &getCurrentFont() const;
const GDIImplFontSet &getFont(const string &font) const;
const GDIImplFontSet &loadFont(const string &font);
mutable const GDIImplFontSet *currentFontSet;
int MaxX;
int MaxY;
int CurrentX;
int CurrentY;
int SX;
int SY;
int Direction;
int OffsetY; //Range 0 -- MaxY
int OffsetX; //Range 0 -- MaxX
//Set to true if we should not update window during "addText" operations
bool manualUpdate;
LRESULT ProcessMsgWrp(UINT iMessage, LPARAM lParam, WPARAM wParam);
void getWindowText(HWND hWnd, string &text);
double scale;
HFONT getGUIFont() const;
void resetLast() const;
mutable int lastFormet;
mutable bool lastActive;
mutable bool lastHighlight;
mutable DWORD lastColor;
mutable string lastFont;
void initCommon(double scale, const string &font);
void processButtonMessage(ButtonInfo &bi, DWORD wParam);
void processEditMessage(InputInfo &bi, DWORD wParam);
void processComboMessage(ListBoxInfo &bi, DWORD wParam);
void processListMessage(ListBoxInfo &bi, DWORD wParam);
void doEnter();
void doEscape();
bool doUpDown(int direction);
FixedTabs *tabs;
string currentFont;
vector< GDIImplFontEnum > enumeratedFonts;
double autoSpeed;
double autoPos;
mutable double lastSpeed;
mutable double autoCounter;
bool lockRefresh;
bool fullScreen;
bool hideBG;
mutable bool commandLock;
mutable DWORD commandUnlockTime;
bool hasCommandLock() const;
void setCommandLock() const;
void liftCommandLock() const;
struct ScreenStringInfo {
RECT rc;
string str;
bool reached;
ScreenStringInfo(const RECT &r, const string &s) {
rc = r;
str = s;
reached = false;
}
};
string listDescription;
mutable map<pair<int, int>, ScreenStringInfo> screenXYToString;
mutable map<string, pair<int, int> > stringToScreenXY;
mutable pair<int, int> snapshotMaxXY;
bool hasAnyTimer;
friend class InputInfo;
friend class TestMeOS;
// Recorder, the second member is true if the recorder is owned and should be deleted
pair<Recorder *, bool> recorder;
public:
void initRecorder(Recorder *rec);
Recorder &getRecorder();
string dbPress(const string &id, int extra);
string dbPress(const string &id, const char *extra);
string dbSelect(const string &id, int data);
void dbInput(const string &id, const string &test);
void dbCheck(const string &id, bool state);
string dbClick(const string &id, int extra);
void dbDblClick(const string &id, int data);
// Add the next answer for a dialog popup
void dbPushDialogAnswer(const string &answer);
mutable list<string> cmdAnswers;
int dbGetStringCount(const string &str, bool subString) const;
// Ensure list of stored answers is empty
void clearDialogAnswers(bool checkEmpty);
void internalSelect(ListBoxInfo &bi);
bool isTest() const {return isTestMode;}
const string &getTag() const {return tag;}
bool hasTag(const string &t) const {return tag == t;}
const wstring &toWide(const string &input) const;
const string &toUTF8(const string &input) const;
const string &toUTF8(const wstring &input) const;
void setEncoding(FontEncoding encoding);
FontEncoding getEncoding() const;
void getFontInfo(const TextInfo &ti, FontInfo &fi) const;
/** Return true if rendering text should be skipped for
this format. */
static bool skipTextRender(int format);
const list<TextInfo> &getTL() const {return TL;}
void getEnumeratedFonts(vector< pair<string, size_t> > &output) const;
const string &getFontName(int id);
double getRelativeFontScale(gdiFonts font, const char *fontFace) const;
bool isFullScreen() const {return fullScreen;}
void setFullScreen(bool useFullScreen);
void setAutoScroll(double speed);
void getAutoScroll(double &speed, double &pos) const;
void storeAutoPos(double pos);
int getAutoScrollDir() const {return (autoSpeed > 0 ? 1:-1);}
int setHighContrastMaxWidth();
void hideBackground(bool hide) {hideBG = hide;}
HWND getToolbarWindow() const;
bool hasToolbar() const;
void activateToolbar(bool active);
void processToolbarMessage(const string &id, void *data);
void synchronizeListScroll(const string &id1, const string &id2);
FixedTabs &getTabs();
// True if up/down is locked, i.e, don't move page
bool lockUpDown;
double getScale() const {return scale;}
void enableEditControls(bool enable);
bool hasEditControl() const;
void setFont(int size, const string &font, FontEncoding encoding);
int getButtonHeight() const;
int scaleLength(int input) const {return int(scale*input + 0.5);}
// Fill in current printer settings
void fetchPrinterSettings(PrinterObject &po) const;
void tableCB(ButtonInfo &bu, Table *t);
char *getExtra(const char *id) const;
int getExtraInt(const char *id) const;
void enableTables();
void disableTables();
void pasteText(const char *id);
bool writeHTML(const wstring &file, const string &title, int refreshTimeOut) const;
bool writeTableHTML(const wstring &file, const string &title, int refreshTimeOut) const;
bool writeTableHTML(ostream &fout,
const string &title,
bool simpleFormat,
int refreshTimeOut) const;
void print(pEvent oe, Table *t=0, bool printMeOSHeader=true, bool noMargin=false);
void print(PrinterObject &po, pEvent oe, bool printMeOSHeader=true, bool noMargin=false);
void printSetup(PrinterObject &po);
void destroyPrinterDC(PrinterObject &po);
void setSelection(const string &id, const set<int> &selection);
void getSelection(const string &id, set<int> &selection);
HWND getTarget() const {return hWndTarget;}
HWND getMain() const {return hWndAppMain;}
string browseForFolder(const string &folderStart, const char *descr);
void scrollToBottom();
void scrollTo(int x, int y);
void setOffset(int x, int y, bool update);
void selectTab(int Id);
void addTable(Table *table, int x, int y);
Table &getTable() const; //Get the (last) table. If needed, add support for named tables...
ToolInfo &addToolTip(const string &id, const string &tip, HWND hWnd, RECT *rc=0);
ToolInfo *getToolTip(const string &id);
ToolInfo &updateToolTip(const string &id, const string &tip);
HWND getToolTip(){return hWndToolTip;}
void init(HWND hWnd, HWND hMainApp, HWND hTab);
bool openDoc(const char *doc);
string browseForSave(const vector< pair<string, string> > &filter,
const string &defext, int &FilterIndex);
string browseForOpen(const vector< pair<string, string> > &filter,
const string &defext);
bool clipOffset(int PageX, int PageY, int &MaxOffsetX, int &MaxOffsetY);
RectangleInfo &addRectangle(RECT &rc, GDICOLOR Color = GDICOLOR(-1),
bool DrawBorder = true, bool addFirst = false);
RectangleInfo &getRectangle(const char *id);
DWORD makeEvent(const string &id, const string &origin,
DWORD data, int extraData, bool flushEvent);
void unregisterEvent(const string &id);
EventInfo &registerEvent(const string &id, GUICALLBACK cb);
int sendCtrlMessage(const string &id);
bool canClear();
void setOnClearCb(GUICALLBACK cb);
void setPostClearCb(GUICALLBACK cb);
void restore(const string &id="", bool DoRefresh=true);
/// Restore, but do not update client area size,
/// position, zoom, scrollbars, and do not refresh
void restoreNoUpdate(const string &id);
void setRestorePoint();
void setRestorePoint(const string &id);
bool removeControl(const string &id);
bool hideControl(const string &id);
void CheckInterfaceTimeouts(DWORD T);
bool RemoveFirstInfoBox(const string &id);
void drawBoxText(HDC hDC, RECT &tr, InfoBox &Box, bool highligh);
void drawBoxes(HDC hDC, RECT &rc);
void drawBox(HDC hDC, InfoBox &Box, RECT &pos);
void addInfoBox(string id, string text, int TimeOut=0, GUICALLBACK cb=0);
HWND getHWND() const {return hWndTarget;}
void updateObjectPositions();
void drawBackground(HDC hDC, RECT &rc);
void renderRectangle(HDC hDC, RECT *clipRegion, const RectangleInfo &ri);
void updateScrollbars() const;
void SetOffsetY(int oy){OffsetY=oy;}
void SetOffsetX(int ox){OffsetX=ox;}
int GetPageY(){return max(MaxY, 100)+60;}
int GetPageX(){return max(MaxX, 100)+100;}
int GetOffsetY(){return OffsetY;}
int GetOffsetX(){return OffsetX;}
void RenderString(TextInfo &ti, const string &text, HDC hDC);
void RenderString(TextInfo &ti, HDC hDC=0);
void calcStringSize(TextInfo &ti, HDC hDC=0) const;
void formatString(const TextInfo &ti, HDC hDC) const;
static string getTimerText(TextInfo *tit, DWORD T);
static string getTimerText(int ZeroTime, int format);
void fadeOut(string Id, int ms);
void setWaitCursor(bool wait);
void setWindowTitle(const string &title);
bool selectFirstItem(const string &name);
void removeString(string Id);
void refresh() const;
void refreshFast() const;
void takeShownStringsSnapshot();
void refreshSmartFromSnapshot(bool allowMoveOffset);
void dropLine(double lines=1){CurrentY+=int(lineHeight*lines); MaxY=max(MaxY, CurrentY);}
int getCX() const {return CurrentX;}
int getCY() const {return CurrentY;}
int getWidth() const {return MaxX;}
int getHeight() const {return MaxY;}
void getTargetDimension(int &x, int &y) const;
void setCX(int cx){CurrentX=cx;}
void setCY(int cy){CurrentY=cy;}
int getLineHeight() const {return lineHeight;}
int getLineHeight(gdiFonts font, const char *face) const;
BaseInfo *setInputFocus(const string &id, bool select=false);
InputInfo *getInputFocus();
void enableInput(const char *id, bool acceptMissing = false) {setInputStatus(id, true, acceptMissing);}
void disableInput(const char *id, bool acceptMissing = false) {setInputStatus(id, false, acceptMissing);}
void setInputStatus(const char *id, bool status, bool acceptMissing = false);
void setInputStatus(const string &id, bool status, bool acceptMissing = false)
{setInputStatus(id.c_str(), status, acceptMissing);}
void setTabStops(const string &Name, int t1, int t2=-1);
void setData(const string &id, DWORD data);
void setData(const string &id, void *data);
void *getData(const string &id) const;
void autoRefresh(bool flag) {manualUpdate = !flag;}
bool getData(const string &id, DWORD &data) const;
bool hasData(const char *id) const;
int getItemDataByName(const char *id, const char *name) const;
bool selectItemByData(const char *id, int data);
void removeSelected(const char *id);
bool selectItemByData(const string &id, int data) {
return selectItemByData(id.c_str(), data);
}
enum AskAnswer {AnswerNo = 0, AnswerYes = 1, AnswerCancel = 2};
bool ask(const string &s);
AskAnswer askCancel(const string &s);
void alert(const string &msg) const;
void fillDown(){Direction=1;}
void fillRight(){Direction=0;}
void fillNone(){Direction=-1;}
void newColumn(){CurrentY=START_YP; CurrentX=MaxX+10;}
void newRow(){CurrentY=MaxY; CurrentX=10;}
void pushX(){SX=CurrentX;}
void pushY(){SY=CurrentY;}
void popX(){CurrentX=SX;}
void popY(){CurrentY=SY;}
bool updatePos(int x, int y, int width, int height);
void adjustDimension(int width, int height);
/** Return a selected item*/
bool getSelectedItem(const string &id, ListBoxInfo &lbi);
/** Return the selected data in first, second indicates if data was available*/
pair<int, bool> getSelectedItem(const string &id);
pair<int, bool> getSelectedItem(const char *id);
bool addItem(const string &id, const string &text, size_t data = 0);
bool addItem(const string &id, const vector< pair<string, size_t> > &items);
void filterOnData(const string &id, const stdext::hash_set<int> &filter);
bool clearList(const string &id);
bool hasField(const string &id) const;
const string &getText(const char *id, bool acceptMissing = false) const;
BaseInfo &getBaseInfo(const char *id) const;
int getTextNo(const char *id, bool acceptMissing = false) const;
int getTextNo(const string &id, bool acceptMissing = false) const
{return getTextNo(id.c_str(), acceptMissing);}
const string &getText(const string &id, bool acceptMissing = false) const
{return getText(id.c_str(), acceptMissing);}
// Insert text and notify "focusList"
bool insertText(const string &id, const string &text);
void copyToClipboard(const string &html, bool convertToUTF8,
const string &txt) const;
BaseInfo *setTextTranslate(const char *id, const string &text, bool update=false);
BaseInfo *setTextTranslate(const char *id, const char *text, bool update=false);
BaseInfo *setTextTranslate(const string &id, const string &text, bool update=false);
BaseInfo *setText(const char *id, const string &text, bool update=false);
BaseInfo *setText(const char *id, int number, bool update=false);
BaseInfo *setTextZeroBlank(const char *id, int number, bool update=false);
BaseInfo *setText(const string &id, const string &text, bool update=false)
{return setText(id.c_str(), text, update);}
BaseInfo *setText(const string &id, int number, bool update=false)
{return setText(id.c_str(), number, update);}
void clearPage(bool autoRefresh, bool keepToolbar = false);
void TabFocus(int direction=1);
void Enter();
void Escape();
bool UpDown(int direction);
void keyCommand(KeyCommandCode code);
LRESULT ProcessMsg(UINT iMessage, LPARAM lParam, WPARAM wParam);
void setWindow(HWND hWnd){hWndTarget=hWnd;}
void scaleSize(double scale);
ButtonInfo &addButton(const string &id, const string &text, GUICALLBACK cb = 0, const string &tooltip="");
ButtonInfo &addButton(int x, int y, const string &id, const string &text,
GUICALLBACK cb = 0, const string &tooltop="");
ButtonInfo &addButton(int x, int y, int w, const string &id, const string &text,
GUICALLBACK cb, const string &tooltop, bool AbsPos, bool hasState);
ButtonInfo &addCheckbox(const string &id, const string &text, GUICALLBACK cb=0, bool Checked=true, const string &Help="");
ButtonInfo &addCheckbox(int x, int y, const string &id, const string &text, GUICALLBACK cb=0, bool Checked=true, const string &Help="", bool AbsPos=false);
bool isChecked(const string &id);
void check(const string &id, bool state, bool keepOriginalState = false);
bool isInputChanged(const string &exclude);
InputInfo &addInput(const string &id, const string &text="", int length=16, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
InputInfo &addInput(int x, int y, const string &id, const string &text, int length, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
InputInfo *replaceSelection(const char *id, const string &text);
InputInfo &addInputBox(const string &id, int width, int height, const string &text,
GUICALLBACK cb, const string &Explanation);
InputInfo &addInputBox(const string &id, int x, int y, int width, int height,
const string &text, GUICALLBACK cb, const string &Explanation);
ListBoxInfo &addListBox(const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="", bool multiple=false);
ListBoxInfo &addListBox(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="", bool multiple=false);
ListBoxInfo &addSelection(const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
ListBoxInfo &addSelection(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
ListBoxInfo &addCombo(const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
ListBoxInfo &addCombo(int x, int y, const string &id, int width, int height, GUICALLBACK cb=0, const string &Explanation="", const string &tooltip="");
// Grows a listbox, selection, combo in X-direction to fit current contents. Returns true if changed.
bool autoGrow(const char *id);
void setListDescription(const string &desc);
TextInfo &addString(const string &id, int format, const string &text, GUICALLBACK cb=0);
TextInfo &addString(const string &id, int yp, int xp, int format, const string &text,
int xlimit=0, GUICALLBACK cb=0, const char *fontFace = 0);
TextInfo &addString(const char *id, int format, const string &text, GUICALLBACK cb=0);
TextInfo &addString(const char *id, int yp, int xp, int format, const string &text,
int xlimit=0, GUICALLBACK cb=0, const char *fontFace = 0);
// Untranslated versions
TextInfo &addStringUT(int yp, int xp, int format, const string &text,
int xlimit=0, GUICALLBACK cb=0, const char *fontFace = 0);
TextInfo &addStringUT(int format, const string &text, GUICALLBACK cb=0);
TextInfo &addTimer(int yp, int xp, int format, DWORD ZeroTime,
int xlimit=0, GUICALLBACK cb=0, int TimeOut=NOTIMEOUT, const char *fontFace = 0);
TextInfo &addTimeout(int TimeOut, GUICALLBACK cb);
void removeTimeoutMilli(const string &id);
TimerInfo &addTimeoutMilli(int timeOut, const string &id, GUICALLBACK cb);
void timerProc(TimerInfo &timer, DWORD timeout);
void draw(HDC hDC, RECT &windowArea, RECT &drawArea);
void closeWindow();
void setDBErrorState(bool state);
friend int TablesCB(gdioutput *gdi, int type, void *data);
friend class Table;
friend gdioutput *createExtraWindow(const string &tag, const string &title, int max_x, int max_y);
gdioutput(const string &tag, double _scale, FontEncoding encoding);
gdioutput(double _scale, FontEncoding encoding, HWND hWndTarget, const PrinterObject &defprn);
virtual ~gdioutput();
};
#endif // !defined(AFX_GDIOUTPUT_H__396F60F8_679F_498A_B759_DF8F6F346A4A__INCLUDED_)

402
code/gdistructures.h Normal file
View File

@ -0,0 +1,402 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#ifndef GDI_STRUCTURES
#define GDI_STRUCTURES
#include <cassert>
#include "guihandler.h"
class BaseInfo
{
protected:
void *extra;
GuiHandler *handler;
bool dataString;
public:
bool hasEventHandler() const {
return handler != 0;
}
bool handleEvent(gdioutput &gdi, GuiEventType type) {
if (handler) {
handler->handle(gdi, *this, type);
return true;
}
return false;
}
BaseInfo():extra(0), dataString(false), handler(0) {}
virtual ~BaseInfo() {}
string id;
virtual HWND getControlWindow() const = 0;
virtual void refresh() {
InvalidateRect(getControlWindow(), 0, true);
}
BaseInfo &setExtra(const char *e) {extra=(void *)e; dataString = true; return *this;}
BaseInfo &setExtra(int e) {extra = (void *)(e); return *this;}
BaseInfo &setExtra(size_t e) {extra = (void *)(e); return *this;}
bool isExtraString() const {return dataString;}
char *getExtra() const {assert(extra == 0 || dataString); return (char *)extra;}
int getExtraInt() const {return int(extra);}
size_t getExtraSize() const {return size_t(extra);}
GuiHandler &getHandler() const;
BaseInfo &setHandler(const GuiHandler *h) {handler = const_cast<GuiHandler *>(h); return *this;}
};
class RestoreInfo : public BaseInfo
{
public:
int nLBI;
int nBI;
int nII;
int nTL;
int nRect;
int nHWND;
int nData;
int sCX;
int sCY;
int sMX;
int sMY;
int sOX;
int sOY;
int nTooltip;
int nTables;
GUICALLBACK onClear;
GUICALLBACK postClear;
HWND getControlWindow() const {throw std::exception("Unsupported");}
};
class RectangleInfo : public BaseInfo
{
private:
DWORD color;
DWORD color2;
bool drawBorder;
DWORD borderColor;
RECT rc;
bool border3D;
public:
const RECT &getRect() const {return rc;}
RectangleInfo(): color(0), color2(0), borderColor(0), border3D(false), drawBorder(false) {memset(&rc, 0, sizeof(RECT));}
RectangleInfo &setColor(GDICOLOR c) {color = c; return *this;}
RectangleInfo &setColor2(GDICOLOR c) {color2 = c; return *this;}
RectangleInfo &set3D(bool is3d) {border3D = is3d; return *this;}
RectangleInfo &setBorderColor(GDICOLOR c) {borderColor = c; return *this;}
friend class gdioutput;
friend struct PageInfo;
RectangleInfo &changeDimension(gdioutput &gdi, int dx, int dy);
HWND getControlWindow() const {throw std::exception("Unsupported");}
};
class TableInfo : public BaseInfo
{
public:
TableInfo():xp(0), yp(0), table(0) {}
int xp;
int yp;
Table *table;
HWND getControlWindow() const {throw std::exception("Unsupported");}
};
class TextInfo : public BaseInfo
{
public:
TextInfo():format(0), color(0), xlimit(0), hasTimer(false),
hasCapture(false), callBack(0), highlight(false),
active(false), lineBreakPrioity(0),
absPrintX(0), absPrintY(0), realWidth(0) {
textRect.left = 0; textRect.right = 0;
textRect.top = 0; textRect.bottom = 0;
}
TextInfo &setColor(GDICOLOR c) {color = c; return *this;}
TextInfo &changeFont(const string &fnt) {font = fnt; return *this;} //Note: size not updated
int getHeight() {return int(textRect.bottom-textRect.top);}
gdiFonts getGdiFont() const {return gdiFonts(format & 0xFF);}
// Sets absolute print coordinates in [mm]
TextInfo &setAbsPrintPos(int x, int y) {
absPrintX = x; absPrintY = y; return *this;
}
string text;
string font;
int xp;
int yp;
int format;
DWORD color;
int xlimit;
int lineBreakPrioity;
int absPrintX;
int absPrintY;
bool hasTimer;
DWORD zeroTime;
DWORD timeOut;
bool hasCapture;
GUICALLBACK callBack;
RECT textRect;
int realWidth; // The calculated actual width of the string in pixels
bool highlight;
bool active;
HWND getControlWindow() const {throw std::exception("Unsupported");}
};
class ButtonInfo : public BaseInfo
{
private:
bool originalState;
bool isEditControl;
bool checked;
bool *updateLastData;
void synchData() const {if (updateLastData) *updateLastData = checked;}
public:
ButtonInfo(): callBack(0), hWnd(0), AbsPos(false), fixedRightTop(false),
flags(0), storedFlags(0), originalState(false), isEditControl(false),
isCheckbox(false), checked(false), updateLastData(0) {}
ButtonInfo &isEdit(bool e) {isEditControl=e; return *this;}
int xp;
int yp;
int width;
string text;
HWND hWnd;
bool AbsPos;
bool fixedRightTop;
int flags;
int storedFlags;
bool isCheckbox;
bool isDefaultButton() const {return (flags&1)==1;}
bool isCancelButton() const {return (flags&2)==2;}
ButtonInfo &setSynchData(bool *variable) {updateLastData = variable; return *this;}
void moveButton(gdioutput &gdi, int xp, int yp);
void getDimension(gdioutput &gdi, int &w, int &h);
ButtonInfo &setDefault();
ButtonInfo &setCancel() {flags|=2, storedFlags|=2; return *this;}
ButtonInfo &fixedCorner() {fixedRightTop = true; return *this;}
GUICALLBACK callBack;
friend class gdioutput;
HWND getControlWindow() const {return hWnd;}
};
enum gdiFonts;
class InputInfo : public BaseInfo
{
public:
InputInfo();
string text;
bool changed() const {return text!=original;}
void ignore(bool ig) {ignoreCheck=ig;}
InputInfo &isEdit(bool e) {isEditControl=e; return *this;}
InputInfo &setBgColor(GDICOLOR c) {bgColor = c; return *this;}
InputInfo &setFgColor(GDICOLOR c) {fgColor = c; return *this;}
InputInfo &setFont(gdioutput &gdi, gdiFonts font);
GDICOLOR getBgColor() const {return bgColor;}
GDICOLOR getFgColor() const {return fgColor;}
InputInfo &setPassword(bool pwd);
HWND getControlWindow() const {return hWnd;}
InputInfo &setSynchData(string *variable) {updateLastData = variable; return *this;}
int getX() const {return xp;}
int getY() const {return yp;}
int getWidth() const {return int(width);}
private:
HWND hWnd;
GUICALLBACK callBack;
void synchData() const {if (updateLastData) *updateLastData = text;}
string *updateLastData;
int xp;
int yp;
double width;
double height;
GDICOLOR bgColor;
GDICOLOR fgColor;
bool isEditControl;
bool writeLock;
string original;
string focusText; // Test when got focus
bool ignoreCheck; // True if changed-state should be ignored
friend class gdioutput;
};
class ListBoxInfo : public BaseInfo
{
public:
ListBoxInfo() : hWnd(0), callBack(0), IsCombo(false), index(-1),
writeLock(false), ignoreCheck(false), isEditControl(true),
originalProc(0), lbiSync(0), multipleSelection(false),
xp(0), yp(0), width(0), height(0), data(0), lastTabStop(0),
updateLastData(0) {}
string text;
size_t data;
int index;
bool changed() const {return text!=original;}
void ignore(bool ig) {ignoreCheck=ig;}
ListBoxInfo &isEdit(bool e) {isEditControl=e; return *this;}
HWND getControlWindow() const {return hWnd;}
void copyUserData(ListBoxInfo &userLBI) const;
ListBoxInfo &setSynchData(int *variable) {updateLastData = variable; return *this;}
int getWidth() const {return int(width);}
int getX() const {return xp;}
int getY() const {return yp;}
bool isCombo() const {return IsCombo;}
private:
void syncData() const {if (updateLastData) *updateLastData = data;}
bool IsCombo;
int *updateLastData;
GUICALLBACK callBack;
int xp;
int yp;
double width;
double height;
HWND hWnd;
int lastTabStop;
bool multipleSelection;
bool isEditControl;
bool writeLock;
string original;
int originalIdx;
bool ignoreCheck; // True if changed-state should be ignored
map<int, int> data2Index;
// Synchronize with other list box
WNDPROC originalProc;
ListBoxInfo *lbiSync;
friend LRESULT CALLBACK GetMsgProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
friend class gdioutput;
};
class DataStore
{
public:
string id;
void *data;
};
class EventInfo : public BaseInfo
{
private:
string origin;
DWORD data;
KeyCommandCode keyEvent;
public:
KeyCommandCode getKeyCommand() const {return keyEvent;}
DWORD getData() const {return data;}
void setKeyCommand(KeyCommandCode kc) {keyEvent = kc;}
void setData(const string &origin_, DWORD d) {origin = origin_, data = d;}
const string &getOrigin() {return origin;}
EventInfo();
GUICALLBACK callBack;
HWND getControlWindow() const {throw std::exception("Unsupported");}
};
class TimerInfo : public BaseInfo
{
private:
DWORD data;
gdioutput *parent;
TimerInfo(gdioutput *gdi, GUICALLBACK cb) : parent(gdi), callBack(cb) {}
public:
BaseInfo &setExtra(void *e) {return BaseInfo::setExtra((const char *)e);}
GUICALLBACK callBack;
friend class gdioutput;
friend void CALLBACK gdiTimerProc(HWND hWnd, UINT a, UINT_PTR ptr, DWORD b);
HWND getControlWindow() const {throw std::exception("Unsupported");}
};
class InfoBox : public BaseInfo
{
public:
InfoBox() : callBack(0), HasCapture(0), HasTCapture(0), TimeOut(0) {}
string text;
GUICALLBACK callBack;
RECT TextRect;
RECT Close;
RECT BoundingBox;
bool HasCapture;
bool HasTCapture;
DWORD TimeOut;
HWND getControlWindow() const {throw std::exception("Unsupported");}
};
typedef list<TextInfo> TIList;
struct ToolInfo {
string name;
TOOLINFOW ti;
wstring tip;
int id;
};
#endif

1297
code/generalresult.cpp Normal file

File diff suppressed because it is too large Load Diff

221
code/generalresult.h Normal file
View File

@ -0,0 +1,221 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "oBase.h"
#include "parser.h"
#include "oListInfo.h"
class oAbstractRunner;
class oTeam;
class oRunner;
struct oListParam;
class xmlparser;
class xmlobject;
class GeneralResult
{
private:
const oListParam *context;
protected:
enum PrincipalSort {None, ClassWise, CourseWise};
virtual PrincipalSort getPrincipalSort() const {return ClassWise;}
virtual int score(oTeam &team, RunnerStatus st, int time, int points) const;
virtual RunnerStatus deduceStatus(oTeam &team) const;
virtual int deduceTime(oTeam &team) const;
virtual int deducePoints(oTeam &team) const;
virtual int score(oRunner &runner, RunnerStatus st, int time, int points, bool asTeamMember) const;
virtual RunnerStatus deduceStatus(oRunner &runner) const;
virtual int deduceTime(oRunner &runner, int startTime) const;
virtual int deducePoints(oRunner &runner) const;
virtual void prepareCalculations(oEvent &oe, bool prepareForTeam, int inputNumber) const;
virtual void prepareCalculations(oTeam &team) const;
virtual void prepareCalculations(oRunner &runner) const;
virtual void storeOutput(vector<int> &times, vector<int> &numbers) const;
int getListParamTimeToControl() const;
int getListParamTimeFromControl() const;
public:
void setContext(const oListParam *context);
void clearContext();
void calculateTeamResults(vector<oTeam *> &teams, oListInfo::ResultType resType, bool sortTeams, int inputNumber) const;
void calculateIndividualResults(vector<oRunner *> &runners, oListInfo::ResultType resType, bool sortRunners, int inputNumber) const;
void sortTeamMembers(vector<oRunner *> &runners) const;
template<class T> void sort(vector<T*> &rt, SortOrder so) const;
GeneralResult(void);
virtual ~GeneralResult(void);
};
class ResultAtControl : public GeneralResult {
protected:
int score(oTeam &team, RunnerStatus st, int time, int points) const;
RunnerStatus deduceStatus(oTeam &team) const;
int deduceTime(oTeam &team) const;
int deducePoints(oTeam &team) const;
int score(oRunner &runner, RunnerStatus st, int time, int points, bool asTeamMember) const;
RunnerStatus deduceStatus(oRunner &runner) const;
int deduceTime(oRunner &runner, int startTime) const;
int deducePoints(oRunner &runner) const;
};
class TotalResultAtControl : public ResultAtControl {
protected:
int deduceTime(oRunner &runner, int startTime) const;
RunnerStatus deduceStatus(oRunner &runner) const;
int score(oRunner &runner, RunnerStatus st, int time, int points, bool asTeamMember) const;
};
class DynamicResult : public GeneralResult {
public:
enum DynamicMethods {
MTScore,
MDeduceTStatus,
MDeduceTTime,
MDeduceTPoints,
MRScore,
MDeduceRStatus,
MDeduceRTime,
MDeduceRPoints,
_Mlast
};
private:
static map<string, DynamicMethods> symb2Method;
static map<DynamicMethods, pair<string, string> > method2SymbName;
static int instanceCount;
class MethodInfo {
string source;
mutable ParseNode *pn;
string description;
public:
friend class DynamicResult;
MethodInfo();
~MethodInfo();
};
vector<MethodInfo> methods;
mutable bool isCompiled;
mutable Parser parser;
string name;
string tag;
string description;
string annotation;
mutable string origin;
string timeStamp;
bool builtIn;
mutable bool readOnly;
const ParseNode *getMethod(DynamicMethods method) const;
void addSymbol(DynamicMethods method, const char *symb, const char *name);
RunnerStatus toStatus(int status) const;
void prepareCommon(oAbstractRunner &runner) const;
static string getInternalPath(const string &tag);
public:
void setReadOnly() const {readOnly = true;}
bool isReadOnly() const {return readOnly;}
const string &getTimeStamp() const {return timeStamp;}
static string undecorateTag(const string &inputTag);
long long getHashCode() const;
void getSymbols(vector< pair<string, size_t> > &symb) const;
void getSymbolInfo(int ix, string &name, string &desc) const;
void declareSymbols(DynamicMethods m, bool clear) const;
void prepareCalculations(oEvent &oe, bool prepareForTeam, int inputNumber) const;
void prepareCalculations(oTeam &team) const;
void prepareCalculations(oRunner &runner) const;
void storeOutput(vector<int> &times, vector<int> &numbers) const;
int score(oTeam &team, RunnerStatus st, int time, int points) const;
RunnerStatus deduceStatus(oTeam &team) const;
int deduceTime(oTeam &team) const;
int deducePoints(oTeam &team) const;
int score(oRunner &runner, RunnerStatus st, int time, int points, bool asTeamMember) const;
RunnerStatus deduceStatus(oRunner &runner) const;
int deduceTime(oRunner &runner, int startTime) const;
int deducePoints(oRunner &runner) const;
DynamicResult();
DynamicResult(const DynamicResult &resIn);
void operator=(const DynamicResult &ctr);
~DynamicResult();
bool hasMethod(DynamicMethods method) const {return getMethod(method) != 0;}
const string &getMethodSource(DynamicMethods method) const;
void setMethodSource(DynamicMethods method, const string &source);
void getMethodTypes(vector< pair<DynamicMethods, string> > &mt) const;
//const string &getMethodName(DynamicMethods method) const;
const string &getTag() const {return tag;}
void setTag(const string &t) {tag = t;}
void setBuiltIn() {builtIn = true;}
bool isBuiltIn() const {return builtIn;}
string getName(bool withAnnotation) const;
void setName(const string &n) {name = n;}
void setAnnotation(const string &a) {annotation = a;}
const string &getDescription() const {return description;}
void setDescription(const string &n) {description = n;}
void save(const string &file) const;
void save(xmlparser &xml) const;
void load(const string &file);
void load(const xmlobject &xDef);
void compile(bool forceRecompile) const;
void debugDumpVariables(gdioutput &gdi, bool includeSymbols) const;
void clear();
};

1027
code/german.lng Normal file

File diff suppressed because it is too large Load Diff

45
code/guihandler.h Normal file
View File

@ -0,0 +1,45 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#ifndef MEOS_GUI_HANDLER
#define MEOS_GUI_HANDLER
enum GuiEventType {GUI_BUTTON=1, GUI_INPUT=2, GUI_LISTBOX=3,
GUI_INFOBOX=4, GUI_CLEAR=5, GUI_INPUTCHANGE=6,
GUI_COMBO, GUI_COMBOCHANGE, GUI_EVENT, GUI_LINK,
GUI_TIMEOUT, GUI_POSTCLEAR, GUI_FOCUS, GUI_TIMER,
GUI_LISTBOXSELECT //DBL-click
};
class gdioutput;
class BaseInfo;
class GuiHandler {
public:
GuiHandler() {}
virtual ~GuiHandler() = 0 {}
virtual void handle(gdioutput &gdi, BaseInfo &info, GuiEventType type) = 0;
};
#endif

110
code/importformats.cpp Normal file
View File

@ -0,0 +1,110 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
// oEvent.cpp: implementation of the oEvent class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "localizer.h"
#include "importformats.h"
#include "oEvent.h"
/*
void ImportFormats::getImportFormats(vector< pair<string, size_t> > &formats) {
formats.clear();
formats.push_back(make_pair(lang.tl("Standard"), Default));
formats.push_back(make_pair(lang.tl("French Orienteering Federation"), FrenchFederationMapping));
}
int ImportFormats::getDefault(oEvent &oe) {
return oe.getPropertyString("Language", "English") == "Français" ? FrenchFederationMapping : Default;
}
*/
void ImportFormats::getExportFormats(vector< pair<string, size_t> > &types, bool exportFilter) {
types.clear();
string v;
if (exportFilter)
v = "Resultat";
else
v = "Startlista";
types.push_back(make_pair(lang.tl("IOF " + v + ", version 3.0 (xml)"), IOF30));
types.push_back(make_pair(lang.tl("IOF " + v + ", version 2.0.3 (xml)"), IOF203));
types.push_back(make_pair(lang.tl("OE Semikolonseparerad (csv)"), OE));
types.push_back(make_pair(lang.tl("Webbdokument (html)"), HTML));
}
void ImportFormats::getExportFilters(bool exportFilters, vector< pair<string, string> > &ext) {
string v;
if (exportFilters)
v = "Resultat";
else
v = "Startlista";
ext.push_back(make_pair("IOF " + v + ", version 3.0 (xml)", "*.xml"));
ext.push_back(make_pair("IOF " + v + ", version 2.0.3 (xml)", "*.xml"));
ext.push_back(make_pair("OE Semikolonseparerad (csv)", "*.csv"));
ext.push_back(make_pair("OE/French Federation of Orienteering (csv)", "*.csv"));
ext.push_back(make_pair("Webbdokument (html)", "*.html"));
}
ImportFormats::ExportFormats ImportFormats::getDefaultExportFormat(oEvent &oe) {
int def = IOF30;
return (ExportFormats)oe.getPropertyInt("ExportFormat", def);
}
ImportFormats::ExportFormats ImportFormats::setExportFormat(oEvent &oe, int raw) {
oe.setProperty("ExportFormat", raw);
return (ExportFormats)raw;
}
void ImportFormats::getOECSVLanguage(vector< pair<string, size_t> > &typeLanguages) {
typeLanguages.push_back(make_pair("English", 1));
typeLanguages.push_back(make_pair("Svenska", 2));
typeLanguages.push_back(make_pair("Deutsch", 3));
typeLanguages.push_back(make_pair("Dansk", 4));
typeLanguages.push_back(make_pair("Français", 5));
typeLanguages.push_back(make_pair("Russian", 6));
}
int ImportFormats::getDefaultCSVLanguage(oEvent &oe) {
string currentLanguage = oe.getPropertyString("Language", "English");
int defaultLanguageType = 1;
if (currentLanguage == "English")
defaultLanguageType = 1;
else if (currentLanguage == "Svenska")
defaultLanguageType = 2;
else if (currentLanguage == "Deutsch")
defaultLanguageType = 3;
else if (currentLanguage == "Dansk")
defaultLanguageType = 4;
else if (currentLanguage == "Français")
defaultLanguageType = 5;
else if (currentLanguage == "Russian(ISO 8859 - 5)")
defaultLanguageType = 6;
return defaultLanguageType;
}

64
code/importformats.h Normal file
View File

@ -0,0 +1,64 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
class oEvent;
/** Support for context specific interpretation of import/export data*/
class ImportFormats {
public:
enum ImportFormatOptions {
Default
};
//static void getImportFormats(vector< pair<string, size_t> > &formats);
//static int getDefault(oEvent &oe);
enum ExportFormats {
IOF30 = 1,
IOF203 = 2,
OE = 3,
HTML = 5
};
static void getExportFormats(vector< pair<string, size_t> > &types, bool exportFilter);
static void getExportFilters(bool exportFilters, vector< pair<string, string> > &ext);
static ExportFormats getDefaultExportFormat(oEvent &oe);
static ExportFormats setExportFormat(oEvent &oe, int raw);
ImportFormats(int opt) : option((ImportFormatOptions)opt) {}
ImportFormatOptions getOption() const {
return option;
}
static void getOECSVLanguage(vector< pair<string, size_t> > &typeLanguages);
static int getDefaultCSVLanguage(oEvent &oe);
private:
ImportFormatOptions option;
};

688
code/infoserver.cpp Normal file
View File

@ -0,0 +1,688 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "meos_util.h"
#include "infoserver.h"
#include "xmlparser.h"
#include "oEvent.h"
#include "download.h"
#include "progress.h"
#include "meosException.h"
#include "gdioutput.h"
void base64_encode(const vector<BYTE> &input, string &output);
// Encode a vector vector int {{1}, {1,2,3}, {}, {4,5}} as "1;1,2,3;;4,5"
static void packIntInt(vector< vector<int> > v, string &def) {
for (size_t j = 0; j < v.size(); j++) {
if (j>0)
def += ";";
for (size_t k = 0; k < v[j].size(); k++) {
if (k>0)
def += ",";
def += itos(v[j][k]);
}
}
}
InfoBase::InfoBase(int idIn) : id(idIn), committed(false){
}
InfoBase::InfoBase(const InfoBase &src) : id(src.id), committed(src.committed){
}
void InfoBase::operator=(const InfoBase &src) {
}
InfoBase::~InfoBase() {
}
int InfoBase::convertRelativeTime(const oBase &elem, int t) {
return t+elem.getEvent()->getZeroTimeNum();
}
InfoCompetition::InfoCompetition(int id) : InfoBase(id) {
forceComplete = true;
}
InfoRadioControl::InfoRadioControl(int id) : InfoBase(id) {
}
InfoClass::InfoClass(int id) : InfoBase(id) {
}
InfoOrganization::InfoOrganization(int id) : InfoBase(id) {
}
InfoBaseCompetitor::InfoBaseCompetitor(int id) : InfoBase(id) {
organizationId = 0;
classId = 0;
status = 0;
startTime = 0;
runningTime = 0;
}
InfoCompetitor::InfoCompetitor(int id) : InfoBaseCompetitor(id) {
totalStatus = 0;
inputTime = 0;
}
InfoTeam::InfoTeam(int id) : InfoBaseCompetitor(id) {
}
bool InfoCompetition::synchronize(oEvent &oe, const set<int> &includeCls) {
bool changed = false;
if (oe.getName() != name) {
name = oe.getName();
changed = true;
}
if (oe.getDate() != date) {
date = oe.getDate();
changed = true;
}
if (oe.getDCI().getString("Organizer") != organizer) {
organizer = oe.getDCI().getString("Organizer");
changed = true;
}
if (oe.getDCI().getString("Homepage") != homepage) {
homepage = oe.getDCI().getString("Homepage");
changed = true;
}
if (changed)
needCommit(*this);
vector<pControl> ctrl;
oe.getControls(ctrl, true);
set<int> knownId;
for (size_t k = 0; k < ctrl.size(); k++) {
if (ctrl[k]->isValidRadio()) {
vector<int> ids;
ctrl[k]->getCourseControls(ids);
for (size_t j = 0; j < ids.size(); j++) {
int id = ids[j];
knownId.insert(id);
map<int, InfoRadioControl>::iterator res = controls.find(id);
if (res == controls.end())
res = controls.insert(make_pair(id, InfoRadioControl(id))).first;
if (res->second.synchronize(*ctrl[k], ids.size() > 1 ? j+1 : 0))
needCommit(res->second);
}
}
}
// Check if something was deleted
for (map<int, InfoRadioControl>::iterator it = controls.begin(); it != controls.end();) {
if (!knownId.count(it->first)) {
controls.erase(it++);
forceComplete = true;
}
else
++it;
}
knownId.clear();
vector<pClass> cls;
oe.getClasses(cls, false);
for (size_t k = 0; k < cls.size(); k++) {
int id = cls[k]->getId();
if (!includeCls.count(id))
continue;
knownId.insert(id);
map<int, InfoClass>::iterator res = classes.find(id);
if (res == classes.end())
res = classes.insert(make_pair(id, InfoClass(id))).first;
if (res->second.synchronize(*cls[k]))
needCommit(res->second);
}
// Check if something was deleted
for (map<int, InfoClass>::iterator it = classes.begin(); it != classes.end();) {
if (!knownId.count(it->first)) {
classes.erase(it++);
forceComplete = true;
}
else
++it;
}
knownId.clear();
vector<pClub> clb;
oe.getClubs(clb, false);
for (size_t k = 0; k < clb.size(); k++) {
int id = clb[k]->getId();
knownId.insert(id);
map<int, InfoOrganization>::iterator res = organizations.find(id);
if (res == organizations.end())
res = organizations.insert(make_pair(id, InfoOrganization(id))).first;
if (res->second.synchronize(*clb[k]))
needCommit(res->second);
}
// Check if something was deleted
for (map<int, InfoOrganization>::iterator it = organizations.begin(); it != organizations.end();) {
if (!knownId.count(it->first)) {
organizations.erase(it++);
forceComplete = true;
}
else
++it;
}
knownId.clear();
vector<pTeam> t;
oe.getTeams(0, t, false);
for (size_t k = 0; k < t.size(); k++) {
if (!includeCls.count(t[k]->getClassId()))
continue;
int id = t[k]->getId();
knownId.insert(id);
map<int, InfoTeam>::iterator res = teams.find(id);
if (res == teams.end())
res = teams.insert(make_pair(id, InfoTeam(id))).first;
if (res->second.synchronize(*t[k]))
needCommit(res->second);
}
// Check if something was deleted
for (map<int, InfoTeam>::iterator it = teams.begin(); it != teams.end();) {
if (!knownId.count(it->first)) {
teams.erase(it++);
forceComplete = true;
}
else
++it;
}
knownId.clear();
vector<pRunner> r;
oe.getRunners(0, 0, r, false);
for (size_t k = 0; k < r.size(); k++) {
if (!includeCls.count(r[k]->getClassId()))
continue;
int id = r[k]->getId();
knownId.insert(id);
map<int, InfoCompetitor>::iterator res = competitors.find(id);
if (res == competitors.end())
res = competitors.insert(make_pair(id, InfoCompetitor(id))).first;
if (res->second.synchronize(*this, *r[k]))
needCommit(res->second);
}
// Check if something was deleted
for (map<int, InfoCompetitor>::iterator it = competitors.begin(); it != competitors.end();) {
if (!knownId.count(it->first)) {
competitors.erase(it++);
forceComplete = true;
}
else
++it;
}
knownId.clear();
return !toCommit.empty() || forceComplete;
}
void InfoCompetition::needCommit(InfoBase &obj) {
toCommit.push_back(&obj);
}
bool InfoRadioControl::synchronize(oControl &c, int number) {
string n = c.hasName() ? c.getName() : c.getString();
if (number > 0)
n = n + "-" + itos(number);
if (n == name)
return false;
else {
name = n;
modified();
}
return true;
}
void InfoRadioControl::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
xml.write("ctrl", prop, name);
}
bool InfoClass::synchronize(oClass &c) {
const string &n = c.getName();
int no = c.getSortIndex();
bool mod = false;
vector< vector<int> > rc;
size_t s = c.getNumStages();
if (s > 0) {
linearLegNumberToActual.clear();
for (size_t k = 0; k < s; k++) {
if (!c.isParallel(k) && !c.isOptional(k)) {
pCourse pc = c.getCourse(k, 0, true); // Get a course representative for the leg.
rc.push_back(vector<int>());
if (pc) {
vector<pControl> ctrl;
pc->getControls(ctrl);
for (size_t j = 0; j < ctrl.size(); j++) {
if (ctrl[j]->isValidRadio()) {
rc.back().push_back(pc->getCourseControlId(j));
}
}
}
}
// Setup transformation map (flat to 2D)
linearLegNumberToActual.push_back(max<int>(0, rc.size()-1));
}
}
else {
// Single stage
linearLegNumberToActual.resize(1, 0);
pCourse pc = c.getCourse(true); // Get a course representative for the leg.
rc.push_back(vector<int>());
if (pc) {
vector<pControl> ctrl;
pc->getControls(ctrl);
for (size_t j = 0; j < ctrl.size(); j++) {
if (ctrl[j]->isValidRadio()) {
//rc.back().push_back(pc->getCourseControlId(ctrl[j]->getId());
rc.back().push_back(pc->getCourseControlId(j));
}
}
}
}
if (radioControls != rc) {
radioControls = rc;
mod = true;
}
if (n != name || no != sortOrder) {
name = n;
sortOrder = no;
mod = true;
}
if (mod)
modified();
return mod;
}
void InfoClass::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
prop.push_back(make_pair("ord", itos(sortOrder)));
string def;
packIntInt(radioControls, def);
prop.push_back(make_pair("radio", def));
xml.write("cls", prop, name);
}
bool InfoOrganization::synchronize(oClub &c) {
const string &n = c.getDisplayName();
if (n == name)
return false;
else {
name = n;
modified();
}
return true;
}
void InfoOrganization::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
xml.write("org", prop, name);
}
void InfoCompetition::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("date", date));
prop.push_back(make_pair("organizer", organizer));
prop.push_back(make_pair("homepage", homepage));
xml.write("competition", prop, name);
}
void InfoBaseCompetitor::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("org", itos(organizationId)));
prop.push_back(make_pair("cls", itos(classId)));
prop.push_back(make_pair("stat", itos(status)));
prop.push_back(make_pair("st", itos(startTime)));
prop.push_back(make_pair("rt", itos(runningTime)));
xml.write("base", prop, name);
}
bool InfoBaseCompetitor::synchronizeBase(oAbstractRunner &bc) {
const string &n = bc.getName();
bool ch = false;
if (n != name) {
name = n;
ch = true;
}
int cid = bc.getClubId();
if (cid != organizationId) {
organizationId = cid;
ch = true;
}
int cls = bc.getClassId();
if (cls != classId) {
classId = cls;
ch = true;
}
int s = bc.getStatus();
if (status != s) {
status = s;
ch = true;
}
int st = -1;
if (bc.startTimeAvailable())
st = convertRelativeTime(bc, bc.getStartTime()) * 10;
if (st != startTime) {
startTime = st;
ch = true;
}
int rt = bc.getRunningTime() * 10;
if (rt != runningTime) {
runningTime = rt;
ch = true;
}
return ch;
}
bool InfoCompetitor::synchronize(const InfoCompetition &cmp, oRunner &r) {
bool ch = synchronizeBase(r);
changeTotalSt = r.getEvent()->hasPrevStage() || r.getLegNumber()>0; // Always write full attributes
int s = r.getTotalStatusInput();
if (totalStatus != s) {
totalStatus = s;
ch = true;
changeTotalSt = true;
}
int legInput = r.getTotalTimeInput() * 10;
if (legInput != inputTime) {
inputTime = legInput;
ch = true;
changeTotalSt = true;
}
vector<RadioTime> newRT;
if (r.getClassId() > 0) {
const vector<int> &radios = cmp.getControls(r.getClassId(), r.getLegNumber());
for (size_t k = 0; k < radios.size(); k++) {
RadioTime radioTime;
RunnerStatus s_split;
radioTime.radioId = radios[k];
r.getSplitTime(radioTime.radioId, s_split, radioTime.runningTime);
if (radioTime.runningTime > 0) {
radioTime.runningTime*=10;
newRT.push_back(radioTime);
}
}
}
changeRadio = radioTimes.size() > 0;//false; // Always write full attributes
if (newRT != radioTimes) {
ch = true;
changeRadio = true;
radioTimes.swap(newRT);
}
if (ch)
modified();
return ch;
}
void InfoCompetitor::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > sprop;
sprop.push_back(make_pair("id", itos(getId())));
xmlbuffer &subTag = xml.startTag("cmp", sprop);
InfoBaseCompetitor::serialize(subTag, diffOnly);
if (radioTimes.size() > 0 && (!diffOnly || changeRadio)) {
string radio;
radio.reserve(radioTimes.size() * 12);
for (size_t k = 0; k < radioTimes.size(); k++) {
if (k>0)
radio+=";";
radio+=itos(radioTimes[k].radioId);
radio+=",";
radio+=itos(radioTimes[k].runningTime);
}
vector< pair<string, string> > eprop;
subTag.write("radio", eprop, radio);
}
if (!diffOnly || changeTotalSt) {
vector< pair<string, string> > prop;
prop.push_back(make_pair("it", itos(inputTime)));
prop.push_back(make_pair("tstat", itos(totalStatus)));
subTag.write("input", prop, "");
}
xml.endTag();
}
bool InfoTeam::synchronize(oTeam &t) {
bool ch = synchronizeBase(t);
const pClass cls = t.getClassRef();
if (cls) {
vector< vector<int> > r;
size_t s = cls->getNumStages();
for (size_t k = 0; k < s; k++) {
pRunner rr = t.getRunner(k);
int rid = rr != 0 ? rr->getId() : 0;
if (cls->isParallel(k) || cls->isOptional(k)) {
if (r.empty())
r.push_back(vector<int>()); // This is not a valid case, really
r.back().push_back(rid);
}
else
r.push_back(vector<int>(1, rid));
}
if (r != competitors) {
r.swap(competitors);
ch = true;
}
}
if (ch)
modified();
return ch;
}
void InfoTeam::serialize(xmlbuffer &xml, bool diffOnly) const {
vector< pair<string, string> > prop;
prop.push_back(make_pair("id", itos(getId())));
xmlbuffer &sub = xml.startTag("tm", prop);
InfoBaseCompetitor::serialize(sub, diffOnly);
string def;
packIntInt(competitors, def);
prop.clear();
sub.write("r", prop, def);
sub.endTag();
}
const vector<int> &InfoCompetition::getControls(int classId, int legNumber) const {
map<int, InfoClass>::const_iterator res = classes.find(classId);
if (res != classes.end()) {
if (size_t(legNumber) < res->second.linearLegNumberToActual.size())
legNumber = res->second.linearLegNumberToActual[legNumber];
else
legNumber = 0;
const vector< vector<int> > &c = res->second.radioControls;
if (size_t(legNumber) < c.size())
return c[legNumber];
}
throw meosException("Internal class definition error");
}
void InfoCompetition::getCompleteXML(xmlbuffer &xml) {
xml.setComplete(true);
serialize(xml, false);
for(map<int, InfoRadioControl>::iterator it = controls.begin(); it != controls.end(); ++it) {
it->second.serialize(xml, false);
}
for(map<int, InfoClass>::iterator it = classes.begin(); it != classes.end(); ++it) {
it->second.serialize(xml, false);
}
for(map<int, InfoOrganization>::iterator it = organizations.begin(); it != organizations.end(); ++it) {
it->second.serialize(xml, false);
}
for(map<int, InfoTeam>::iterator it = teams.begin(); it != teams.end(); ++it) {
it->second.serialize(xml, false);
}
for(map<int, InfoCompetitor>::iterator it = competitors.begin(); it != competitors.end(); ++it) {
it->second.serialize(xml, false);
}
}
void InfoCompetition::getDiffXML(xmlbuffer &xml) {
if (forceComplete) {
getCompleteXML(xml);
return;
}
xml.setComplete(false);
for (list<InfoBase *>::iterator it = toCommit.begin(); it != toCommit.end(); ++it) {
(*it)->serialize(xml, true);
}
}
void InfoCompetition::commitComplete() {
toCommit.clear();
forceComplete = false;
}
static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'};
static int mod_table[] = {0, 2, 1};
void base64_encode(const vector<BYTE> &input, string &encoded_data) {
size_t input_length = input.size();
size_t output_length = 4 * ((input_length + 2) / 3);
encoded_data.resize(output_length);
for (size_t i = 0, j = 0; i < input_length;) {
unsigned octet_a = i < input_length ? input[i++] : 0;
unsigned octet_b = i < input_length ? input[i++] : 0;
unsigned octet_c = i < input_length ? input[i++] : 0;
unsigned triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 1 * 6) & 0x3F];
encoded_data[j++] = encoding_table[(triple >> 0 * 6) & 0x3F];
}
for (int i = 0; i < mod_table[input_length % 3]; i++)
encoded_data[output_length - 1 - i] = '=';
}
xmlbuffer &xmlbuffer::startTag(const char *tag, const vector< pair<string, string> > &prop) {
blocks.push_back(block());
blocks.back().tag = tag;
blocks.back().prop = prop;
blocks.back().subValues.push_back(xmlbuffer());
return blocks.back().subValues.back();
}
void xmlbuffer::endTag() {
}
void xmlbuffer::write(const char *tag,
const vector< pair<string, string> > &prop,
const string &value) {
blocks.push_back(block());
blocks.back().tag = tag;
blocks.back().prop = prop;
blocks.back().value = value;
}
void xmlbuffer::startXML(xmlparser &xml, const string &dest) {
xml.openOutput(dest.c_str(), false);
if (complete) {
xml.startTag("MOPComplete", "xmlns", "http://www.melin.nu/mop");
complete = false;
}
else
xml.startTag("MOPDiff", "xmlns", "http://www.melin.nu/mop");
}
bool xmlbuffer::commit(xmlparser &xml, int count) {
while (count>0 && !blocks.empty()) {
block &block = blocks.front();
if (block.subValues.empty()) {
xml.write(block.tag.c_str(), block.prop, block.value);
}
else {
vector<string> p2;
for (size_t k = 0; k< block.prop.size(); k++) {
p2.push_back(block.prop[k].first);
p2.push_back(block.prop[k].second);
}
xml.startTag(block.tag.c_str(), p2);
for (size_t k = 0; k < block.subValues.size(); k++)
block.subValues[k].commit(xml, numeric_limits<int>::max());
xml.endTag();
}
count--;
blocks.pop_front();
}
return !blocks.empty();
}

219
code/infoserver.h Normal file
View File

@ -0,0 +1,219 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
/** Class for keeping an external information server (online results) up-to-date */
#include <vector>
#include <map>
#include <set>
class oBase;
class oEvent;
class oClass;
class oAbstractRunner;
class oRunner;
class oTeam;
class oClub;
class oControl;
class xmlparser;
class gdioutput;
class xmlbuffer {
private:
struct block {
string tag;
vector<pair<string, string>> prop;
string value;
vector<xmlbuffer> subValues;
};
list<block> blocks;
bool complete;
public:
void setComplete(bool c) {complete = c;}
xmlbuffer &startTag(const char *tag, const vector< pair<string, string> > &prop);
void endTag();
void write(const char *tag,
const vector< pair<string, string> > &prop,
const string &value);
size_t size() const {return blocks.size();}
bool commit(xmlparser &xml, int count);
void startXML(xmlparser &xml, const string &dest);
};
class InfoBase
{
private:
bool committed;
const int id;
protected:
void modified() {committed = false;}
virtual void serialize(xmlbuffer &xml, bool diffOnly) const = 0;
// Converts a relative time to absolute time:
// number of tenths of a second since 00:00:00 on the day of
// the zero time of the competition
int convertRelativeTime(const oBase &elem, int t);
public:
int getId() const {return id;}
bool isCommitted() const {return committed;}
InfoBase(int id);
InfoBase(const InfoBase &in);
void operator=(const InfoBase &in);
virtual ~InfoBase();
friend class InfoCompetition;
};
typedef InfoBase * pInfoBase;
class InfoRadioControl : public InfoBase {
protected:
string name;
bool synchronize(oControl &c, int number);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
InfoRadioControl(int id);
virtual ~InfoRadioControl() {}
friend class InfoCompetition;
};
class InfoClass : public InfoBase {
protected:
string name;
int sortOrder;
vector< vector<int> > radioControls;
vector<int> linearLegNumberToActual;
bool synchronize(oClass &c);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
InfoClass(int id);
virtual ~InfoClass() {}
friend class InfoCompetition;
};
class InfoOrganization : public InfoBase {
protected:
string name;
bool synchronize(oClub &c);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
InfoOrganization(int id);
virtual ~InfoOrganization() {}
friend class InfoCompetition;
};
struct RadioTime {
int radioId;
int runningTime;
bool operator==(const RadioTime &t) const {
return radioId == t.radioId && runningTime == t.runningTime;
}
};
class InfoBaseCompetitor : public InfoBase {
protected:
string name;
int organizationId;
int classId;
int status;
int startTime;
int runningTime;
void serialize(xmlbuffer &xml, bool diffOnly) const;
bool synchronizeBase(oAbstractRunner &bc);
public:
InfoBaseCompetitor(int id);
virtual ~InfoBaseCompetitor() {}
};
class InfoCompetitor : public InfoBaseCompetitor {
protected:
vector<RadioTime> radioTimes;
int inputTime;
int totalStatus;
bool synchronize(const InfoCompetition &cmp, oRunner &c);
void serialize(xmlbuffer &xml, bool diffOnly) const;
bool changeTotalSt;
bool changeRadio;
public:
InfoCompetitor(int id);
virtual ~InfoCompetitor() {}
friend class InfoCompetition;
};
class InfoTeam : public InfoBaseCompetitor {
protected:
// The outer level holds legs, the inner level holds (parallel/patrol) runners on each leg.
vector< vector<int> > competitors;
bool synchronize(oTeam &t);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
InfoTeam(int id);
virtual ~InfoTeam() {}
friend class InfoCompetition;
};
class InfoCompetition : public InfoBase {
private:
string name;
string date;
string organizer;
string homepage;
protected:
bool forceComplete;
list<InfoBase *> toCommit;
map<int, InfoRadioControl> controls;
map<int, InfoClass> classes;
map<int, InfoOrganization> organizations;
map<int, InfoCompetitor> competitors;
map<int, InfoTeam> teams;
void needCommit(InfoBase &obj);
void serialize(xmlbuffer &xml, bool diffOnly) const;
public:
const vector<int> &getControls(int classId, int legNumber) const;
bool synchronize(oEvent &oe, const set<int> &classes);
void getCompleteXML(xmlbuffer &xml);
void getDiffXML(xmlbuffer &xml);
void commitComplete();
InfoCompetition(int id);
//InfoCompetition(const InfoCompetition &in);
virtual ~InfoCompetition() {}
};

27
code/inthashmap.h Normal file
View File

@ -0,0 +1,27 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#include "intkeymap.hpp"
typedef intkeymap<int> inthashmap;

78
code/intkeymap.hpp Normal file
View File

@ -0,0 +1,78 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2015 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Stigbergsvägen 7, SE-75242 UPPSALA, Sweden
************************************************************************/
template<class T, class KEY = int> class intkeymap {
private:
const static KEY NoKey = -1013;
struct keypair {
KEY key;
T value;
};
T dummy;
T tmp;
keypair *keys;
unsigned siz;
unsigned used;
intkeymap *next;
intkeymap *parent;
double allocFactor;
T noValue;
unsigned hash1;
unsigned hash2;
int level;
static int optsize(int arg);
T &rehash(int size, KEY key, const T &value);
T &get(const KEY key);
const intkeymap &operator=(const intkeymap &co);
void *lookup(KEY key) const;
public:
virtual ~intkeymap();
intkeymap(int size);
intkeymap();
intkeymap(const intkeymap &co);
bool empty() const;
int size() const;
int getAlloc() const {return siz;}
void clear();
void resize(int size);
int count(KEY key) {
return lookup(key, dummy) ? 1:0;
}
bool lookup(KEY key, T &value) const;
void insert(KEY key, const T &value);
void remove(KEY key);
void erase(KEY key) {remove(key);}
const T operator[](KEY key) const
{if (lookup(key,tmp)) return tmp; else return T();}
T &operator[](KEY key) {
return get(key);
}
};

374
code/intkeymapimpl.hpp Normal file
View File

@ -0,0 +1,374 @@
#pragma once
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2015 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Stigbergsvägen 7, SE-75242 UPPSALA, Sweden
************************************************************************/
#include "stdafx.h"
#include "intkeymap.hpp"
template <class T, class KEY> intkeymap<T, KEY>::intkeymap() {
siz = 17;
allocFactor = 1.5;
keys = new keypair[siz];
hash1 = siz / 2 + 3;
hash2 = siz / 3 + 2;
used = 0;
next = 0;
level = 0;
parent = 0;
dummy = 0;
noValue = 0;
clear();
}
template <class T, class KEY> intkeymap<T, KEY>::intkeymap(int _size)
{
allocFactor = 1.3;
siz = optsize(_size);
keys = new keypair[siz];
hash1 = siz / 2 + 3;
hash2 = siz / 3 + 2;
used = 0;
next = 0;
level = 0;
parent = 0;
dummy = T();
noValue = T();
clear();
}
template <class T, class KEY> intkeymap<T, KEY>::intkeymap(const intkeymap &co)
{
allocFactor = co.allocFactor;
siz = co.siz;
keys = new keypair[siz];
hash1 = co.hash1;
hash2 = co.hash2;
used = co.used;
level = co.level;
dummy = co.dummy;
noValue = co.noValue;
for (unsigned k=0; k<siz; k++)
keys[k] = co.keys[k];
parent = 0;
next = 0;
if (co.next) {
next = new intkeymap<T, KEY>(*co.next);
next->parent = this;
}
}
template <class T, class KEY> intkeymap<T, KEY>::~intkeymap()
{
delete[] keys;
if (next)
delete next;
}
template <class T, class KEY> void intkeymap<T, KEY>::clear()
{
for (unsigned k=0;k<siz;k++)
keys[k].key = NoKey;
used = 0;
delete next;
next = 0;
}
template <class T, class KEY> void intkeymap<T, KEY>::insert(KEY key, const T &value)
{
if (key == NoKey) {
noValue = value;
return;
}
keypair *ptr = (keypair *)lookup(key);
if (ptr) {
ptr->key = key;
ptr->value = value;
return;
}
unsigned hk = unsigned(key) % siz;
if (keys[hk].key == NoKey)
used++;
if (keys[hk].key == NoKey || keys[hk].key == key) {
keys[hk].key = key;
keys[hk].value = value;
return;
}
hk = unsigned(key + hash1) % siz;
if (keys[hk].key == NoKey)
used++;
if (keys[hk].key == NoKey || keys[hk].key == key) {
keys[hk].key = key;
keys[hk].value = value;
return;
}
hk = unsigned(key + hash2) % siz;
if (keys[hk].key == NoKey)
used++;
if (keys[hk].key == NoKey || keys[hk].key == key) {
keys[hk].key = key;
keys[hk].value = value;
return;
}
if (next) {
next->insert(key, value);
return;
}
else if (level < 3) {
next = new intkeymap<T, KEY>(siz/2);
next->level = level + 1;
next->parent = this;
next->insert(key, value);
return;
}
rehash(0, key, value);
}
template <class T, class KEY> T &intkeymap<T, KEY>::get(KEY key)
{
keypair *ptr = (keypair *)lookup(key);
if (ptr)
return ptr->value;
if (key == NoKey)
return noValue;
unsigned hk = unsigned(key) % siz;
if (keys[hk].key == NoKey) {
used++;
keys[hk].value = T();
}
if (keys[hk].key == NoKey || keys[hk].key == key) {
keys[hk].key = key;
return keys[hk].value;
}
hk = unsigned(key + hash1) % siz;
if (keys[hk].key == NoKey) {
used++;
keys[hk].value = T();
}
if (keys[hk].key == NoKey || keys[hk].key == key) {
keys[hk].key = key;
return keys[hk].value;
}
hk = unsigned(key + hash2) % siz;
if (keys[hk].key == NoKey) {
keys[hk].value = T();
used++;
}
if (keys[hk].key == NoKey || keys[hk].key == key) {
keys[hk].key = key;
return keys[hk].value;
}
if (next) {
return next->get(key);
}
else if (level < 3) {
next = new intkeymap<T, KEY>(siz/2);
next->level = level + 1;
next->parent = this;
return next->get(key);
}
return rehash(0, key, T());
}
template <class T, class KEY> void intkeymap<T, KEY>::remove(KEY key)
{
unsigned hk = unsigned(key) % siz;
if (keys[hk].key == key) {
keys[hk].key = NoKey;
used--;
return;
}
hk = unsigned(key + hash1) % siz;
if (keys[hk].key == key) {
keys[hk].key = NoKey;
used--;
return;
}
hk = unsigned(key + hash2) % siz;
if (keys[hk].key == key) {
keys[hk].key = NoKey;
used--;
return;
}
if (next) {
next->remove(key);
return;
}
}
template <class T, class KEY> T &intkeymap<T, KEY>::rehash(int _siz, KEY key, const T &value)
{
if (parent)
return parent->rehash(_siz+used, key, value);
else {
intkeymap<T, KEY> nm(int((_siz+used)*allocFactor));
if (key != NoKey)
nm.insert(key, value);
intkeymap<T, KEY> *tmap = this;
while (tmap) {
int tsize = tmap->siz;
keypair *tkeys = tmap->keys;
for (int k=0; k<tsize; k++) {
if (tkeys[k].key != NoKey)
nm.insert(tkeys[k].key, tkeys[k].value);
}
tmap = tmap->next;
}
// Swap
keypair *oldkeys = keys;
//Take next
delete next;
next = nm.next;
nm.next = 0;
if (next)
next->parent = this;
//Take keys
keys = nm.keys;
nm.keys = 0;
delete[] oldkeys;
// Copy relevant data
siz = nm.siz;
used = nm.used;
hash1 = nm.hash1;
hash2 = nm.hash2;
if (key!=NoKey)
return get(key);
return dummy;
}
}
template <class T, class KEY> bool intkeymap<T, KEY>::lookup(KEY key, T &value) const
{
keypair *ptr = (keypair *)lookup(key);
if (ptr) {
value = ptr->value;
return true;
}
else {
value = T();
return false;
}
}
template <class T, class KEY> void *intkeymap<T, KEY>::lookup(KEY key) const
{
if (key == NoKey) {
return 0;
}
unsigned hk = unsigned(key) % siz;
if (keys[hk].key == key) {
return (void *)&keys[hk];
}
hk = unsigned(key + hash1) % siz;
if (keys[hk].key == key) {
return (void *)&keys[hk];
}
hk = unsigned(key + hash2) % siz;
if (keys[hk].key == key) {
return (void *)&keys[hk];
}
if (next)
return next->lookup(key);
else
return 0;
}
template <class T, class KEY> int intkeymap<T, KEY>::optsize(int a) {
if (a<5)
a = 5;
if ((a&1) == 0)
a++;
while (true) {
if (a%3 == 0)
a+=2;
else if (a%5 == 0)
a+=2;
else if (a%7 == 0)
a+=2;
else if (a%11 == 0)
a+=2;
else if (a%13 == 0)
a+=2;
else
return a;
}
}
template <class T, class KEY> int intkeymap<T, KEY>::size() const
{
if (next)
return used + next->size();
else
return used;
}
template <class T, class KEY> bool intkeymap<T, KEY>::empty() const
{
return used==0 && (next==0 || next->empty());
}
template <class T, class KEY> void intkeymap<T, KEY>::resize(int size)
{
allocFactor = 1.0;
rehash(size, NoKey, 0);
allocFactor = 1.3;
}

3508
code/iof30interface.cpp Normal file

File diff suppressed because it is too large Load Diff

290
code/iof30interface.h Normal file
View File

@ -0,0 +1,290 @@
/************************************************************************
MeOS - Orienteering Software
Copyright (C) 2009-2017 Melin Software HB
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Melin Software HB - software@melin.nu - www.melin.nu
Eksoppsvägen 16, SE-75646 UPPSALA, Sweden
************************************************************************/
#pragma once
#include <map>
#include <set>
#include <vector>
class oEvent;
class xmlobject;
typedef vector<xmlobject> xmlList;
class xmlparser;
class gdioutput;
class oRunner;
class oClub;
class oTeam;
class oCourse;
class oControl;
class oClass;
class oDataInterface;
class oDataConstInterface;
class oAbstractRunner;
struct RunnerDBEntry;
class RunnerDB;
typedef oRunner * pRunner;
typedef oClass * pClass;
typedef oClub * pClub;
typedef oTeam * pTeam;
typedef oCourse *pCourse;
class IOF30Interface {
oEvent &oe;
int cachedStageNumber;
int entrySourceId;
bool splitLateFee;
bool useGMT; // Use GMT when exporting
// Export teams as individual
bool teamsAsIndividual;
// Unroll course loops
bool unrollLoops;
// Include data on stage number
bool includeStageRaceInfo;
void operator=(const IOF30Interface &);
struct LegInfo {
int maxRunners;
int minRunners;
LegInfo() : maxRunners(1), minRunners(1) {}
void setMinRunners(int nr) {minRunners = max(minRunners, nr); maxRunners = max(maxRunners, nr);}
void setMaxRunners(int nr) {maxRunners = max(maxRunners, nr);}
};
struct FeeInfo {
double fee;
double taxable;
double percentage; // Eventor / OLA stupidity
string currency;
string fromTime;
string toTime;
string fromBirthDate;
string toBirthDate;
bool includes(const FeeInfo &fo) const {
if (toBirthDate != fo.toBirthDate || fromBirthDate != fo.fromBirthDate)
return false;
if (!includeFrom(fromTime, fo.fromTime))
return false;
if (!includeTo(toTime, fo.toTime))
return false;
/*if (!includeFrom(fromBirthDate, fo.fromBirthDate))
return false;
if (!includeTo(toBirthDate, fo.toBirthDate))
return false;*/
return true;
}
void add(FeeInfo &fi);
string getDateKey() const {return fromTime + " - " + toTime;}
FeeInfo() : fee(0), taxable(0), percentage(0) {}
const bool operator<(const FeeInfo &fi) const {
return fee < fi.fee || (fee == fi.fee && taxable < fi.taxable);
}
private:
bool includeFrom(const string &a, const string &b) const {
if ( a > b || (b.empty() && !a.empty()) )
return false;
return true;
}
bool includeTo(const string &a, const string &b) const {
if ( (!a.empty() && a < b) || (b.empty() && !a.empty()) )
return false;
return true;
}
};
struct FeeStatistics {
double fee;
double lateFactor;
};
vector<FeeStatistics> feeStatistics;
static void getAgeLevels(const vector<FeeInfo> &fees, const vector<int> &ix,
int &normalIx, int &redIx, string &youthLimit, string &seniorLimit);
void readEvent(gdioutput &gdi, const xmlobject &xo,
map<int, vector<LegInfo> > &teamClassConfig);
pRunner readPersonEntry(gdioutput &gdi, xmlobject &xo, pTeam team,
const map<int, vector<LegInfo> > &teamClassConfig,
map<int, vector< pair<int, int> > > &personId2TeamLeg);
pRunner readPerson(gdioutput &gdi, const xmlobject &xo);
pClub readOrganization(gdioutput &gdi, const xmlobject &xo, bool saveToDB);
pClass readClass(const xmlobject &xo,
map<int, vector<LegInfo> > &teamClassConfig);
pTeam readTeamEntry(gdioutput &gdi, xmlobject &xTeam,
map<int, pair<string, int> > &bibPatterns,
const map<int, vector<LegInfo> > &teamClassConfig,
map<int, vector< pair<int, int> > > &personId2TeamLeg);
pRunner readPersonStart(gdioutput &gdi, pClass pc, xmlobject &xo, pTeam team,
const map<int, vector<LegInfo> > &teamClassConfig);
pTeam readTeamStart(gdioutput &gdi, pClass pc, xmlobject &xTeam,
map<int, pair<string, int> > &bibPatterns,
const map<int, vector<LegInfo> > &teamClassConfig);
pTeam getCreateTeam(gdioutput &gdi, const xmlobject &xTeam, bool &newTeam);
static int getIndexFromLegPos(int leg, int legorder, const vector<LegInfo> &setup);
void setupClassConfig(int classId, const xmlobject &xTeam, map<int, vector<LegInfo> > &teamClassConfig);
void setupRelayClasses(const map<int, vector<LegInfo> > &teamClassConfig);
void setupRelayClass(pClass pc, const vector<LegInfo> &teamClassConfig);
int parseISO8601Time(const xmlobject &xo);
string getCurrentTime() const;
static void getNationality(const xmlobject &xCountry, oDataInterface &di);
static void getAmount(const xmlobject &xAmount, double &amount, string &currency);
static void getAssignedFee(const xmlobject &xFee, double &fee, double &paid, double &taxable, double &percentage, string &currency);
static void getFee(const xmlobject &xFee, FeeInfo &fee);
static void getFeeAmounts(const xmlobject &xFee, double &fee, double &taxable, double &percentage, string &currency);
void writeFees(xmlparser &xml, const oRunner &r) const;
void writeAmount(xmlparser &xml, const char *tag, int amount) const;
void writeAssignedFee(xmlparser &xml, const oAbstractRunner &tr, int paidForCard) const;
void writeRentalCardService(xmlparser &xml, int cardFee, bool paid) const;
void getProps(vector<string> &props) const;
void writeClassResult(xmlparser &xml, const oClass &c, const vector<pRunner> &r,
const vector<pTeam> &t);
void writeClass(xmlparser &xml, const oClass &c);
void writeCourse(xmlparser &xml, const oCourse &c);
void writePersonResult(xmlparser &xml, const oRunner &r, bool includeCourse,
bool teamMember, bool hasInputTime);
void writeTeamResult(xmlparser &xml, const oTeam &t, bool hasInputTime);
void writeResult(xmlparser &xml, const oRunner &rPerson, const oRunner &rResultCarrier,
bool includeCourse, bool includeRaceNumber, bool teamMember, bool hasInputTime);
void writePerson(xmlparser &xml, const oRunner &r);
void writeClub(xmlparser &xml, const oClub &c, bool writeExtended) const;
void getRunnersToUse(const pClass cls, vector<pRunner> &rToUse,
vector<pTeam> &tToUse, int leg, bool includeUnknown) const;
void writeClassStartList(xmlparser &xml, const oClass &c, const vector<pRunner> &r,
const vector<pTeam> &t);
void writePersonStart(xmlparser &xml, const oRunner &r, bool includeCourse, bool teamMember);
void writeTeamStart(xmlparser &xml, const oTeam &t);
void writeStart(xmlparser &xml, const oRunner &r, bool includeCourse,
bool includeRaceNumber, bool teamMember);
pCourse haveSameCourse(const vector<pRunner> &r) const;
void writeLegOrder(xmlparser &xml, const oRunner &r) const;
// Returns zero if no stage number
int getStageNumber();
bool readXMLCompetitorDB(const xmlobject &xCompetitor);
void writeXMLCompetitorDB(xmlparser &xml, const RunnerDBEntry &rde) const;
int getStartIndex(const string &startId);
bool readControl(const xmlobject &xControl);
pCourse readCourse(const xmlobject &xcrs);
void readCourseGroups(xmlobject xClassCourse, vector< vector<pCourse> > &crs);
void bindClassCourse(oClass &pc, const vector< vector<pCourse> > &crs);
static string constructCourseName(const xmlobject &xcrs);
static string constructCourseName(const string &family, const string &name);
void classAssignmentObsolete(gdioutput &gdi, xmlList &xAssignment, const map<string, pCourse> &courses,
const map<string, vector<pCourse> > &coursesFamilies);
void classCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses,
const map<string, vector<pCourse> > &coursesFamilies);
void personCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses);
void teamCourseAssignment(gdioutput &gdi, xmlList &xAssignment,
const map<string, pCourse> &courses);
void assignTeamCourse(gdioutput &gdi, oTeam &t, xmlList &xAssignment,
const map<string, pCourse> &courses);
pCourse findCourse(gdioutput &gdi, const map<string, pCourse> &courses,
xmlobject &xPAssignment);
string writeControl(xmlparser &xml, const oControl &c, set<string> &writtenId);
void writeCourseInfo(xmlparser &xml, const oCourse &c);
void writeFullCourse(xmlparser &xml, const oCourse &c,
const map<int, string> &ctrlId2ExportId);
public:
IOF30Interface(oEvent *oe, bool forceSplitFee);
virtual ~IOF30Interface() {}
void readEventList(gdioutput &gdi, xmlobject &xo);
void readEntryList(gdioutput &gdi, xmlobject &xo, bool removeNonexisting, int &entRead, int &entFail, int &entRemoved);
void readStartList(gdioutput &gdi, xmlobject &xo, int &entRead, int &entFail);
void readClassList(gdioutput &gdi, xmlobject &xo, int &entRead, int &entFail);
void readCompetitorList(gdioutput &gdi, const xmlobject &xo, int &personCount);
void readClubList(gdioutput &gdi, const xmlobject &xo, int &clubCount);
void readCourseData(gdioutput &gdi, const xmlobject &xo, bool updateClasses, int &courseCount, int &entFail);
void writeResultList(xmlparser &xml, const set<int> &classes, int leg,
bool useUTC, bool teamsAsIndividual,
bool unrollLoops, bool includeStageInfo);
void writeStartList(xmlparser &xml, const set<int> &classes, bool useUTC,
bool teamsAsIndividual, bool includeStageInfo);
void writeEvent(xmlparser &xml);
void writeCourses(xmlparser &xml);
void writeRunnerDB(const RunnerDB &db, xmlparser &xml) const;
void writeClubDB(const RunnerDB &db, xmlparser &xml) const;
};

BIN
code/lib/libhpdf.lib Normal file

Binary file not shown.

BIN
code/lib/mysqlpp.lib Normal file

Binary file not shown.

BIN
code/lib/mysqlpp_vc15.lib Normal file

Binary file not shown.

BIN
code/lib/zlibstat.lib Normal file

Binary file not shown.

BIN
code/lib_db/libhpdf.lib Normal file

Binary file not shown.

BIN
code/lib_db/mysqlpp.lib Normal file

Binary file not shown.

Binary file not shown.

BIN
code/lib_db/zlibstat.lib Normal file

Binary file not shown.

Binary file not shown.

1562
code/libharu/hpdf.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
/*
* << Haru Free PDF Library >> -- hpdf_annotation.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_3DMEASURE_H
#define _HPDF_3DMEASURE_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------------*/
/*------ HPDF_3DMeasure -----------------------------------------------------*/
HPDF_3DMeasure
HPDF_3DC3DMeasure_New(HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Point3D firstanchorpoint,
HPDF_Point3D textanchorpoint
);
HPDF_3DMeasure
HPDF_PD33DMeasure_New(HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Point3D annotationPlaneNormal,
HPDF_Point3D firstAnchorPoint,
HPDF_Point3D secondAnchorPoint,
HPDF_Point3D leaderLinesDirection,
HPDF_Point3D measurementValuePoint,
HPDF_Point3D textYDirection,
HPDF_REAL value,
const char* unitsString
);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_3DMEASURE_H */

View File

@ -0,0 +1,95 @@
/*
* << Haru Free PDF Library >> -- hpdf_annotation.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_ANNOTATION_H
#define _HPDF_ANNOTATION_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------------*/
/*------ HPDF_Annotation -----------------------------------------------------*/
HPDF_Annotation
HPDF_Annotation_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_AnnotType type,
HPDF_Rect rect);
HPDF_Annotation
HPDF_LinkAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
HPDF_Destination dst);
HPDF_Annotation
HPDF_URILinkAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
const char *uri);
HPDF_Annotation
HPDF_3DAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
HPDF_U3D u3d);
HPDF_Annotation
HPDF_MarkupAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
const char *text,
HPDF_Encoder encoder,
HPDF_AnnotType subtype);
HPDF_Annotation
HPDF_PopupAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
HPDF_Annotation parent);
HPDF_Annotation
HPDF_StampAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
HPDF_StampAnnotName name,
const char* text,
HPDF_Encoder encoder);
HPDF_Annotation
HPDF_ProjectionAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
const char* text,
HPDF_Encoder encoder);
HPDF_BOOL
HPDF_Annotation_Validate (HPDF_Annotation annot);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_ANNOTATION_H */

View File

@ -0,0 +1,93 @@
/*
* << Haru Free PDF Library >> -- hpdf_catalog.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_CATALOG_H
#define _HPDF_CATALOG_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef HPDF_Dict HPDF_Catalog;
HPDF_Catalog
HPDF_Catalog_New (HPDF_MMgr mmgr,
HPDF_Xref xref);
HPDF_NameDict
HPDF_Catalog_GetNames (HPDF_Catalog catalog);
HPDF_STATUS
HPDF_Catalog_SetNames (HPDF_Catalog catalog,
HPDF_NameDict dict);
HPDF_Pages
HPDF_Catalog_GetRoot (HPDF_Catalog catalog);
HPDF_PageLayout
HPDF_Catalog_GetPageLayout (HPDF_Catalog catalog);
HPDF_STATUS
HPDF_Catalog_SetPageLayout (HPDF_Catalog catalog,
HPDF_PageLayout layout);
HPDF_PageMode
HPDF_Catalog_GetPageMode (HPDF_Catalog catalog);
HPDF_STATUS
HPDF_Catalog_SetPageMode (HPDF_Catalog catalog,
HPDF_PageMode mode);
HPDF_STATUS
HPDF_Catalog_SetOpenAction (HPDF_Catalog catalog,
HPDF_Destination open_action);
HPDF_STATUS
HPDF_Catalog_AddPageLabel (HPDF_Catalog catalog,
HPDF_UINT page_num,
HPDF_Dict page_label);
HPDF_UINT
HPDF_Catalog_GetViewerPreference (HPDF_Catalog catalog);
HPDF_STATUS
HPDF_Catalog_SetViewerPreference (HPDF_Catalog catalog,
HPDF_UINT value);
HPDF_BOOL
HPDF_Catalog_Validate (HPDF_Catalog catalog);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_CATALOG_H */

85
code/libharu/hpdf_conf.h Normal file
View File

@ -0,0 +1,85 @@
/*
* << Haru Free PDF Library >> -- hpdf_conf.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_CONF_H
#define _HPDF_CONF_H
#include <stdlib.h>
#include <stdio.h>
#if defined(_MSC_VER)
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES 1
#endif /* _USE_MATH_DEFINES */
#endif
#ifndef __USE_XOPEN
#define __USE_XOPEN /* for M_PI */
#endif /* __USE_XOPEN */
#include <math.h>
/*----------------------------------------------------------------------------*/
/*----- standard C library functions -----------------------------------------*/
#define HPDF_FOPEN fopen
#define HPDF_FCLOSE fclose
#define HPDF_FREAD fread
#define HPDF_FWRITE fwrite
#define HPDF_FFLUSH fflush
#define HPDF_FSEEK fseek
#define HPDF_FTELL ftell
#define HPDF_FEOF feof
#define HPDF_FERROR ferror
#define HPDF_MALLOC malloc
#define HPDF_FREE free
#define HPDF_FILEP FILE*
#define HPDF_TIME time
#define HPDF_PRINTF printf
#define HPDF_SIN sin
#define HPDF_COS cos
/*----------------------------------------------------------------------------*/
/*----- parameters in relation to performance --------------------------------*/
/* default buffer size of memory-stream-object */
#define HPDF_STREAM_BUF_SIZ 4096
/* default array size of list-object */
#define HPDF_DEF_ITEMS_PER_BLOCK 20
/* default array size of cross-reference-table */
#define HPDF_DEFALUT_XREF_ENTRY_NUM 1024
/* default array size of widths-table of cid-fontdef */
#define HPDF_DEF_CHAR_WIDTHS_NUM 128
/* default array size of page-list-tablef */
#define HPDF_DEF_PAGE_LIST_NUM 256
/* default array size of range-table of cid-fontdef */
#define HPDF_DEF_RANGE_TBL_NUM 128
/* default buffer size of memory-pool-object */
#define HPDF_MPOOL_BUF_SIZ 8192
#define HPDF_MIN_MPOOL_BUF_SIZ 256
#define HPDF_MAX_MPOOL_BUF_SIZ 1048576
/* alignment size of memory-pool-object
*/
#define HPDF_ALIGN_SIZ sizeof int;
#endif /* _HPDF_CONF_H */

View File

@ -0,0 +1,75 @@
/* include/hpdf_config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef LIBHPDF_HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef LIBHPDF_HAVE_INTTYPES_H
/* Define to 1 if you have the `png' library (-lpng). */
#define LIBHPDF_HAVE_LIBPNG 1
/* Define to 1 if you have the `z' library (-lz). */
#define LIBHPDF_HAVE_LIBZ 1
/* Define to 1 if you have the <memory.h> header file. */
#undef LIBHPDF_HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef LIBHPDF_HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#define LIBHPDF_HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define LIBHPDF_HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define LIBHPDF_HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define LIBHPDF_HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#undef LIBHPDF_HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#define LIBHPDF_HAVE_UNISTD_H 1
/* define pi */
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif /* M_PI */
/* debug build */
#undef LIBHPDF_DEBUG
/* debug trace enabled */
#undef LIBHPDF_DEBUG_TRACE
/* libpng is not available */
#undef LIBHPDF_HAVE_NOPNGLIB
/* zlib is not available */
#undef LIBHPDF_HAVE_NOZLIB
/* Define to the address where bug reports for this package should be sent. */
#undef LIBHPDF_PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef LIBHPDF_PACKAGE_NAME
/* Define to the full name and version of this package. */
#define LIBHPDF_PACKAGE_STRING "libhpdf 2.2.0"
/* Define to the one symbol short name of this package. */
#undef LIBHPDF_PACKAGE_TARNAME
/* Define to the version of this package. */
#define LIBHPDF_PACKAGE_VERSION "2.2.0"
/* Define to 1 if you have the ANSI C header files. */
#define LIBHPDF_STDC_HEADERS 1
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

549
code/libharu/hpdf_consts.h Normal file
View File

@ -0,0 +1,549 @@
/*
* << Haru Free PDF Library >> -- hpdf_consts.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_CONSTS_H
#define _HPDF_CONSTS_H
/*----------------------------------------------------------------------------*/
#define HPDF_TRUE 1
#define HPDF_FALSE 0
#define HPDF_OK 0
#define HPDF_NOERROR 0
/*----- default values -------------------------------------------------------*/
/* buffer size which is required when we convert to character string. */
#define HPDF_TMP_BUF_SIZ 512
#define HPDF_SHORT_BUF_SIZ 32
#define HPDF_REAL_LEN 11
#define HPDF_INT_LEN 11
#define HPDF_TEXT_DEFAULT_LEN 256
#define HPDF_UNICODE_HEADER_LEN 2
#define HPDF_DATE_TIME_STR_LEN 23
/* length of each item defined in PDF */
#define HPDF_BYTE_OFFSET_LEN 10
#define HPDF_OBJ_ID_LEN 7
#define HPDF_GEN_NO_LEN 5
/* default value of Graphic State */
#define HPDF_DEF_FONT "Helvetica"
#define HPDF_DEF_PAGE_LAYOUT HPDF_PAGE_LAYOUT_SINGLE
#define HPDF_DEF_PAGE_MODE HPDF_PAGE_MODE_USE_NONE
#define HPDF_DEF_WORDSPACE 0
#define HPDF_DEF_CHARSPACE 0
#define HPDF_DEF_FONTSIZE 10
#define HPDF_DEF_HSCALING 100
#define HPDF_DEF_LEADING 0
#define HPDF_DEF_RENDERING_MODE HPDF_FILL
#define HPDF_DEF_RISE 0
#define HPDF_DEF_RAISE HPDF_DEF_RISE
#define HPDF_DEF_LINEWIDTH 1
#define HPDF_DEF_LINECAP HPDF_BUTT_END
#define HPDF_DEF_LINEJOIN HPDF_MITER_JOIN
#define HPDF_DEF_MITERLIMIT 10
#define HPDF_DEF_FLATNESS 1
#define HPDF_DEF_PAGE_NUM 1
#define HPDF_BS_DEF_WIDTH 1
/* defalt page-size */
#define HPDF_DEF_PAGE_WIDTH 595.276F
#define HPDF_DEF_PAGE_HEIGHT 841.89F
/*---------------------------------------------------------------------------*/
/*----- compression mode ----------------------------------------------------*/
#define HPDF_COMP_NONE 0x00
#define HPDF_COMP_TEXT 0x01
#define HPDF_COMP_IMAGE 0x02
#define HPDF_COMP_METADATA 0x04
#define HPDF_COMP_ALL 0x0F
/* #define HPDF_COMP_BEST_COMPRESS 0x10
* #define HPDF_COMP_BEST_SPEED 0x20
*/
#define HPDF_COMP_MASK 0xFF
/*----------------------------------------------------------------------------*/
/*----- permission flags (only Revision 2 is supported)-----------------------*/
#define HPDF_ENABLE_READ 0
#define HPDF_ENABLE_PRINT 4
#define HPDF_ENABLE_EDIT_ALL 8
#define HPDF_ENABLE_COPY 16
#define HPDF_ENABLE_EDIT 32
/*----------------------------------------------------------------------------*/
/*------ viewer preferences definitions --------------------------------------*/
#define HPDF_HIDE_TOOLBAR 1
#define HPDF_HIDE_MENUBAR 2
#define HPDF_HIDE_WINDOW_UI 4
#define HPDF_FIT_WINDOW 8
#define HPDF_CENTER_WINDOW 16
#define HPDF_PRINT_SCALING_NONE 32
/*---------------------------------------------------------------------------*/
/*------ limitation of object implementation (PDF1.4) -----------------------*/
#define HPDF_LIMIT_MAX_INT 2147483647
#define HPDF_LIMIT_MIN_INT -2147483647
#define HPDF_LIMIT_MAX_REAL 32767
#define HPDF_LIMIT_MIN_REAL -32767
#define HPDF_LIMIT_MAX_STRING_LEN 65535
#define HPDF_LIMIT_MAX_NAME_LEN 127
#define HPDF_LIMIT_MAX_ARRAY 32767
#define HPDF_LIMIT_MAX_DICT_ELEMENT 4095
#define HPDF_LIMIT_MAX_XREF_ELEMENT 8388607
#define HPDF_LIMIT_MAX_GSTATE 28
#define HPDF_LIMIT_MAX_DEVICE_N 8
#define HPDF_LIMIT_MAX_DEVICE_N_V15 32
#define HPDF_LIMIT_MAX_CID 65535
#define HPDF_MAX_GENERATION_NUM 65535
#define HPDF_MIN_PAGE_HEIGHT 3
#define HPDF_MIN_PAGE_WIDTH 3
#define HPDF_MAX_PAGE_HEIGHT 14400
#define HPDF_MAX_PAGE_WIDTH 14400
#define HPDF_MIN_MAGNIFICATION_FACTOR 8
#define HPDF_MAX_MAGNIFICATION_FACTOR 3200
/*---------------------------------------------------------------------------*/
/*------ limitation of various properties -----------------------------------*/
#define HPDF_MIN_PAGE_SIZE 3
#define HPDF_MAX_PAGE_SIZE 14400
#define HPDF_MIN_HORIZONTALSCALING 10
#define HPDF_MAX_HORIZONTALSCALING 300
#define HPDF_MIN_WORDSPACE -30
#define HPDF_MAX_WORDSPACE 300
#define HPDF_MIN_CHARSPACE -30
#define HPDF_MAX_CHARSPACE 300
#define HPDF_MAX_FONTSIZE 300
#define HPDF_MAX_ZOOMSIZE 10
#define HPDF_MAX_LEADING 300
#define HPDF_MAX_LINEWIDTH 100
#define HPDF_MAX_DASH_PATTERN 100
#define HPDF_MAX_JWW_NUM 128
/*----------------------------------------------------------------------------*/
/*----- country code definition ----------------------------------------------*/
#define HPDF_COUNTRY_AF "AF" /* AFGHANISTAN */
#define HPDF_COUNTRY_AL "AL" /* ALBANIA */
#define HPDF_COUNTRY_DZ "DZ" /* ALGERIA */
#define HPDF_COUNTRY_AS "AS" /* AMERICAN SAMOA */
#define HPDF_COUNTRY_AD "AD" /* ANDORRA */
#define HPDF_COUNTRY_AO "AO" /* ANGOLA */
#define HPDF_COUNTRY_AI "AI" /* ANGUILLA */
#define HPDF_COUNTRY_AQ "AQ" /* ANTARCTICA */
#define HPDF_COUNTRY_AG "AG" /* ANTIGUA AND BARBUDA */
#define HPDF_COUNTRY_AR "AR" /* ARGENTINA */
#define HPDF_COUNTRY_AM "AM" /* ARMENIA */
#define HPDF_COUNTRY_AW "AW" /* ARUBA */
#define HPDF_COUNTRY_AU "AU" /* AUSTRALIA */
#define HPDF_COUNTRY_AT "AT" /* AUSTRIA */
#define HPDF_COUNTRY_AZ "AZ" /* AZERBAIJAN */
#define HPDF_COUNTRY_BS "BS" /* BAHAMAS */
#define HPDF_COUNTRY_BH "BH" /* BAHRAIN */
#define HPDF_COUNTRY_BD "BD" /* BANGLADESH */
#define HPDF_COUNTRY_BB "BB" /* BARBADOS */
#define HPDF_COUNTRY_BY "BY" /* BELARUS */
#define HPDF_COUNTRY_BE "BE" /* BELGIUM */
#define HPDF_COUNTRY_BZ "BZ" /* BELIZE */
#define HPDF_COUNTRY_BJ "BJ" /* BENIN */
#define HPDF_COUNTRY_BM "BM" /* BERMUDA */
#define HPDF_COUNTRY_BT "BT" /* BHUTAN */
#define HPDF_COUNTRY_BO "BO" /* BOLIVIA */
#define HPDF_COUNTRY_BA "BA" /* BOSNIA AND HERZEGOWINA */
#define HPDF_COUNTRY_BW "BW" /* BOTSWANA */
#define HPDF_COUNTRY_BV "BV" /* BOUVET ISLAND */
#define HPDF_COUNTRY_BR "BR" /* BRAZIL */
#define HPDF_COUNTRY_IO "IO" /* BRITISH INDIAN OCEAN TERRITORY */
#define HPDF_COUNTRY_BN "BN" /* BRUNEI DARUSSALAM */
#define HPDF_COUNTRY_BG "BG" /* BULGARIA */
#define HPDF_COUNTRY_BF "BF" /* BURKINA FASO */
#define HPDF_COUNTRY_BI "BI" /* BURUNDI */
#define HPDF_COUNTRY_KH "KH" /* CAMBODIA */
#define HPDF_COUNTRY_CM "CM" /* CAMEROON */
#define HPDF_COUNTRY_CA "CA" /* CANADA */
#define HPDF_COUNTRY_CV "CV" /* CAPE VERDE */
#define HPDF_COUNTRY_KY "KY" /* CAYMAN ISLANDS */
#define HPDF_COUNTRY_CF "CF" /* CENTRAL AFRICAN REPUBLIC */
#define HPDF_COUNTRY_TD "TD" /* CHAD */
#define HPDF_COUNTRY_CL "CL" /* CHILE */
#define HPDF_COUNTRY_CN "CN" /* CHINA */
#define HPDF_COUNTRY_CX "CX" /* CHRISTMAS ISLAND */
#define HPDF_COUNTRY_CC "CC" /* COCOS (KEELING) ISLANDS */
#define HPDF_COUNTRY_CO "CO" /* COLOMBIA */
#define HPDF_COUNTRY_KM "KM" /* COMOROS */
#define HPDF_COUNTRY_CG "CG" /* CONGO */
#define HPDF_COUNTRY_CK "CK" /* COOK ISLANDS */
#define HPDF_COUNTRY_CR "CR" /* COSTA RICA */
#define HPDF_COUNTRY_CI "CI" /* COTE D'IVOIRE */
#define HPDF_COUNTRY_HR "HR" /* CROATIA (local name: Hrvatska) */
#define HPDF_COUNTRY_CU "CU" /* CUBA */
#define HPDF_COUNTRY_CY "CY" /* CYPRUS */
#define HPDF_COUNTRY_CZ "CZ" /* CZECH REPUBLIC */
#define HPDF_COUNTRY_DK "DK" /* DENMARK */
#define HPDF_COUNTRY_DJ "DJ" /* DJIBOUTI */
#define HPDF_COUNTRY_DM "DM" /* DOMINICA */
#define HPDF_COUNTRY_DO "DO" /* DOMINICAN REPUBLIC */
#define HPDF_COUNTRY_TP "TP" /* EAST TIMOR */
#define HPDF_COUNTRY_EC "EC" /* ECUADOR */
#define HPDF_COUNTRY_EG "EG" /* EGYPT */
#define HPDF_COUNTRY_SV "SV" /* EL SALVADOR */
#define HPDF_COUNTRY_GQ "GQ" /* EQUATORIAL GUINEA */
#define HPDF_COUNTRY_ER "ER" /* ERITREA */
#define HPDF_COUNTRY_EE "EE" /* ESTONIA */
#define HPDF_COUNTRY_ET "ET" /* ETHIOPIA */
#define HPDF_COUNTRY_FK "FK" /* FALKLAND ISLANDS (MALVINAS) */
#define HPDF_COUNTRY_FO "FO" /* FAROE ISLANDS */
#define HPDF_COUNTRY_FJ "FJ" /* FIJI */
#define HPDF_COUNTRY_FI "FI" /* FINLAND */
#define HPDF_COUNTRY_FR "FR" /* FRANCE */
#define HPDF_COUNTRY_FX "FX" /* FRANCE, METROPOLITAN */
#define HPDF_COUNTRY_GF "GF" /* FRENCH GUIANA */
#define HPDF_COUNTRY_PF "PF" /* FRENCH POLYNESIA */
#define HPDF_COUNTRY_TF "TF" /* FRENCH SOUTHERN TERRITORIES */
#define HPDF_COUNTRY_GA "GA" /* GABON */
#define HPDF_COUNTRY_GM "GM" /* GAMBIA */
#define HPDF_COUNTRY_GE "GE" /* GEORGIA */
#define HPDF_COUNTRY_DE "DE" /* GERMANY */
#define HPDF_COUNTRY_GH "GH" /* GHANA */
#define HPDF_COUNTRY_GI "GI" /* GIBRALTAR */
#define HPDF_COUNTRY_GR "GR" /* GREECE */
#define HPDF_COUNTRY_GL "GL" /* GREENLAND */
#define HPDF_COUNTRY_GD "GD" /* GRENADA */
#define HPDF_COUNTRY_GP "GP" /* GUADELOUPE */
#define HPDF_COUNTRY_GU "GU" /* GUAM */
#define HPDF_COUNTRY_GT "GT" /* GUATEMALA */
#define HPDF_COUNTRY_GN "GN" /* GUINEA */
#define HPDF_COUNTRY_GW "GW" /* GUINEA-BISSAU */
#define HPDF_COUNTRY_GY "GY" /* GUYANA */
#define HPDF_COUNTRY_HT "HT" /* HAITI */
#define HPDF_COUNTRY_HM "HM" /* HEARD AND MC DONALD ISLANDS */
#define HPDF_COUNTRY_HN "HN" /* HONDURAS */
#define HPDF_COUNTRY_HK "HK" /* HONG KONG */
#define HPDF_COUNTRY_HU "HU" /* HUNGARY */
#define HPDF_COUNTRY_IS "IS" /* ICELAND */
#define HPDF_COUNTRY_IN "IN" /* INDIA */
#define HPDF_COUNTRY_ID "ID" /* INDONESIA */
#define HPDF_COUNTRY_IR "IR" /* IRAN (ISLAMIC REPUBLIC OF) */
#define HPDF_COUNTRY_IQ "IQ" /* IRAQ */
#define HPDF_COUNTRY_IE "IE" /* IRELAND */
#define HPDF_COUNTRY_IL "IL" /* ISRAEL */
#define HPDF_COUNTRY_IT "IT" /* ITALY */
#define HPDF_COUNTRY_JM "JM" /* JAMAICA */
#define HPDF_COUNTRY_JP "JP" /* JAPAN */
#define HPDF_COUNTRY_JO "JO" /* JORDAN */
#define HPDF_COUNTRY_KZ "KZ" /* KAZAKHSTAN */
#define HPDF_COUNTRY_KE "KE" /* KENYA */
#define HPDF_COUNTRY_KI "KI" /* KIRIBATI */
#define HPDF_COUNTRY_KP "KP" /* KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF */
#define HPDF_COUNTRY_KR "KR" /* KOREA, REPUBLIC OF */
#define HPDF_COUNTRY_KW "KW" /* KUWAIT */
#define HPDF_COUNTRY_KG "KG" /* KYRGYZSTAN */
#define HPDF_COUNTRY_LA "LA" /* LAO PEOPLE'S DEMOCRATIC REPUBLIC */
#define HPDF_COUNTRY_LV "LV" /* LATVIA */
#define HPDF_COUNTRY_LB "LB" /* LEBANON */
#define HPDF_COUNTRY_LS "LS" /* LESOTHO */
#define HPDF_COUNTRY_LR "LR" /* LIBERIA */
#define HPDF_COUNTRY_LY "LY" /* LIBYAN ARAB JAMAHIRIYA */
#define HPDF_COUNTRY_LI "LI" /* LIECHTENSTEIN */
#define HPDF_COUNTRY_LT "LT" /* LITHUANIA */
#define HPDF_COUNTRY_LU "LU" /* LUXEMBOURG */
#define HPDF_COUNTRY_MO "MO" /* MACAU */
#define HPDF_COUNTRY_MK "MK" /* MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF */
#define HPDF_COUNTRY_MG "MG" /* MADAGASCAR */
#define HPDF_COUNTRY_MW "MW" /* MALAWI */
#define HPDF_COUNTRY_MY "MY" /* MALAYSIA */
#define HPDF_COUNTRY_MV "MV" /* MALDIVES */
#define HPDF_COUNTRY_ML "ML" /* MALI */
#define HPDF_COUNTRY_MT "MT" /* MALTA */
#define HPDF_COUNTRY_MH "MH" /* MARSHALL ISLANDS */
#define HPDF_COUNTRY_MQ "MQ" /* MARTINIQUE */
#define HPDF_COUNTRY_MR "MR" /* MAURITANIA */
#define HPDF_COUNTRY_MU "MU" /* MAURITIUS */
#define HPDF_COUNTRY_YT "YT" /* MAYOTTE */
#define HPDF_COUNTRY_MX "MX" /* MEXICO */
#define HPDF_COUNTRY_FM "FM" /* MICRONESIA, FEDERATED STATES OF */
#define HPDF_COUNTRY_MD "MD" /* MOLDOVA, REPUBLIC OF */
#define HPDF_COUNTRY_MC "MC" /* MONACO */
#define HPDF_COUNTRY_MN "MN" /* MONGOLIA */
#define HPDF_COUNTRY_MS "MS" /* MONTSERRAT */
#define HPDF_COUNTRY_MA "MA" /* MOROCCO */
#define HPDF_COUNTRY_MZ "MZ" /* MOZAMBIQUE */
#define HPDF_COUNTRY_MM "MM" /* MYANMAR */
#define HPDF_COUNTRY_NA "NA" /* NAMIBIA */
#define HPDF_COUNTRY_NR "NR" /* NAURU */
#define HPDF_COUNTRY_NP "NP" /* NEPAL */
#define HPDF_COUNTRY_NL "NL" /* NETHERLANDS */
#define HPDF_COUNTRY_AN "AN" /* NETHERLANDS ANTILLES */
#define HPDF_COUNTRY_NC "NC" /* NEW CALEDONIA */
#define HPDF_COUNTRY_NZ "NZ" /* NEW ZEALAND */
#define HPDF_COUNTRY_NI "NI" /* NICARAGUA */
#define HPDF_COUNTRY_NE "NE" /* NIGER */
#define HPDF_COUNTRY_NG "NG" /* NIGERIA */
#define HPDF_COUNTRY_NU "NU" /* NIUE */
#define HPDF_COUNTRY_NF "NF" /* NORFOLK ISLAND */
#define HPDF_COUNTRY_MP "MP" /* NORTHERN MARIANA ISLANDS */
#define HPDF_COUNTRY_NO "NO" /* NORWAY */
#define HPDF_COUNTRY_OM "OM" /* OMAN */
#define HPDF_COUNTRY_PK "PK" /* PAKISTAN */
#define HPDF_COUNTRY_PW "PW" /* PALAU */
#define HPDF_COUNTRY_PA "PA" /* PANAMA */
#define HPDF_COUNTRY_PG "PG" /* PAPUA NEW GUINEA */
#define HPDF_COUNTRY_PY "PY" /* PARAGUAY */
#define HPDF_COUNTRY_PE "PE" /* PERU */
#define HPDF_COUNTRY_PH "PH" /* PHILIPPINES */
#define HPDF_COUNTRY_PN "PN" /* PITCAIRN */
#define HPDF_COUNTRY_PL "PL" /* POLAND */
#define HPDF_COUNTRY_PT "PT" /* PORTUGAL */
#define HPDF_COUNTRY_PR "PR" /* PUERTO RICO */
#define HPDF_COUNTRY_QA "QA" /* QATAR */
#define HPDF_COUNTRY_RE "RE" /* REUNION */
#define HPDF_COUNTRY_RO "RO" /* ROMANIA */
#define HPDF_COUNTRY_RU "RU" /* RUSSIAN FEDERATION */
#define HPDF_COUNTRY_RW "RW" /* RWANDA */
#define HPDF_COUNTRY_KN "KN" /* SAINT KITTS AND NEVIS */
#define HPDF_COUNTRY_LC "LC" /* SAINT LUCIA */
#define HPDF_COUNTRY_VC "VC" /* SAINT VINCENT AND THE GRENADINES */
#define HPDF_COUNTRY_WS "WS" /* SAMOA */
#define HPDF_COUNTRY_SM "SM" /* SAN MARINO */
#define HPDF_COUNTRY_ST "ST" /* SAO TOME AND PRINCIPE */
#define HPDF_COUNTRY_SA "SA" /* SAUDI ARABIA */
#define HPDF_COUNTRY_SN "SN" /* SENEGAL */
#define HPDF_COUNTRY_SC "SC" /* SEYCHELLES */
#define HPDF_COUNTRY_SL "SL" /* SIERRA LEONE */
#define HPDF_COUNTRY_SG "SG" /* SINGAPORE */
#define HPDF_COUNTRY_SK "SK" /* SLOVAKIA (Slovak Republic) */
#define HPDF_COUNTRY_SI "SI" /* SLOVENIA */
#define HPDF_COUNTRY_SB "SB" /* SOLOMON ISLANDS */
#define HPDF_COUNTRY_SO "SO" /* SOMALIA */
#define HPDF_COUNTRY_ZA "ZA" /* SOUTH AFRICA */
#define HPDF_COUNTRY_ES "ES" /* SPAIN */
#define HPDF_COUNTRY_LK "LK" /* SRI LANKA */
#define HPDF_COUNTRY_SH "SH" /* ST. HELENA */
#define HPDF_COUNTRY_PM "PM" /* ST. PIERRE AND MIQUELON */
#define HPDF_COUNTRY_SD "SD" /* SUDAN */
#define HPDF_COUNTRY_SR "SR" /* SURINAME */
#define HPDF_COUNTRY_SJ "SJ" /* SVALBARD AND JAN MAYEN ISLANDS */
#define HPDF_COUNTRY_SZ "SZ" /* SWAZILAND */
#define HPDF_COUNTRY_SE "SE" /* SWEDEN */
#define HPDF_COUNTRY_CH "CH" /* SWITZERLAND */
#define HPDF_COUNTRY_SY "SY" /* SYRIAN ARAB REPUBLIC */
#define HPDF_COUNTRY_TW "TW" /* TAIWAN, PROVINCE OF CHINA */
#define HPDF_COUNTRY_TJ "TJ" /* TAJIKISTAN */
#define HPDF_COUNTRY_TZ "TZ" /* TANZANIA, UNITED REPUBLIC OF */
#define HPDF_COUNTRY_TH "TH" /* THAILAND */
#define HPDF_COUNTRY_TG "TG" /* TOGO */
#define HPDF_COUNTRY_TK "TK" /* TOKELAU */
#define HPDF_COUNTRY_TO "TO" /* TONGA */
#define HPDF_COUNTRY_TT "TT" /* TRINIDAD AND TOBAGO */
#define HPDF_COUNTRY_TN "TN" /* TUNISIA */
#define HPDF_COUNTRY_TR "TR" /* TURKEY */
#define HPDF_COUNTRY_TM "TM" /* TURKMENISTAN */
#define HPDF_COUNTRY_TC "TC" /* TURKS AND CAICOS ISLANDS */
#define HPDF_COUNTRY_TV "TV" /* TUVALU */
#define HPDF_COUNTRY_UG "UG" /* UGANDA */
#define HPDF_COUNTRY_UA "UA" /* UKRAINE */
#define HPDF_COUNTRY_AE "AE" /* UNITED ARAB EMIRATES */
#define HPDF_COUNTRY_GB "GB" /* UNITED KINGDOM */
#define HPDF_COUNTRY_US "US" /* UNITED STATES */
#define HPDF_COUNTRY_UM "UM" /* UNITED STATES MINOR OUTLYING ISLANDS */
#define HPDF_COUNTRY_UY "UY" /* URUGUAY */
#define HPDF_COUNTRY_UZ "UZ" /* UZBEKISTAN */
#define HPDF_COUNTRY_VU "VU" /* VANUATU */
#define HPDF_COUNTRY_VA "VA" /* VATICAN CITY STATE (HOLY SEE) */
#define HPDF_COUNTRY_VE "VE" /* VENEZUELA */
#define HPDF_COUNTRY_VN "VN" /* VIET NAM */
#define HPDF_COUNTRY_VG "VG" /* VIRGIN ISLANDS (BRITISH) */
#define HPDF_COUNTRY_VI "VI" /* VIRGIN ISLANDS (U.S.) */
#define HPDF_COUNTRY_WF "WF" /* WALLIS AND FUTUNA ISLANDS */
#define HPDF_COUNTRY_EH "EH" /* WESTERN SAHARA */
#define HPDF_COUNTRY_YE "YE" /* YEMEN */
#define HPDF_COUNTRY_YU "YU" /* YUGOSLAVIA */
#define HPDF_COUNTRY_ZR "ZR" /* ZAIRE */
#define HPDF_COUNTRY_ZM "ZM" /* ZAMBIA */
#define HPDF_COUNTRY_ZW "ZW" /* ZIMBABWE */
/*----------------------------------------------------------------------------*/
/*----- lang code definition -------------------------------------------------*/
#define HPDF_LANG_AA "aa" /* Afar */
#define HPDF_LANG_AB "ab" /* Abkhazian */
#define HPDF_LANG_AF "af" /* Afrikaans */
#define HPDF_LANG_AM "am" /* Amharic */
#define HPDF_LANG_AR "ar" /* Arabic */
#define HPDF_LANG_AS "as" /* Assamese */
#define HPDF_LANG_AY "ay" /* Aymara */
#define HPDF_LANG_AZ "az" /* Azerbaijani */
#define HPDF_LANG_BA "ba" /* Bashkir */
#define HPDF_LANG_BE "be" /* Byelorussian */
#define HPDF_LANG_BG "bg" /* Bulgarian */
#define HPDF_LANG_BH "bh" /* Bihari */
#define HPDF_LANG_BI "bi" /* Bislama */
#define HPDF_LANG_BN "bn" /* Bengali Bangla */
#define HPDF_LANG_BO "bo" /* Tibetan */
#define HPDF_LANG_BR "br" /* Breton */
#define HPDF_LANG_CA "ca" /* Catalan */
#define HPDF_LANG_CO "co" /* Corsican */
#define HPDF_LANG_CS "cs" /* Czech */
#define HPDF_LANG_CY "cy" /* Welsh */
#define HPDF_LANG_DA "da" /* Danish */
#define HPDF_LANG_DE "de" /* German */
#define HPDF_LANG_DZ "dz" /* Bhutani */
#define HPDF_LANG_EL "el" /* Greek */
#define HPDF_LANG_EN "en" /* English */
#define HPDF_LANG_EO "eo" /* Esperanto */
#define HPDF_LANG_ES "es" /* Spanish */
#define HPDF_LANG_ET "et" /* Estonian */
#define HPDF_LANG_EU "eu" /* Basque */
#define HPDF_LANG_FA "fa" /* Persian */
#define HPDF_LANG_FI "fi" /* Finnish */
#define HPDF_LANG_FJ "fj" /* Fiji */
#define HPDF_LANG_FO "fo" /* Faeroese */
#define HPDF_LANG_FR "fr" /* French */
#define HPDF_LANG_FY "fy" /* Frisian */
#define HPDF_LANG_GA "ga" /* Irish */
#define HPDF_LANG_GD "gd" /* Scots Gaelic */
#define HPDF_LANG_GL "gl" /* Galician */
#define HPDF_LANG_GN "gn" /* Guarani */
#define HPDF_LANG_GU "gu" /* Gujarati */
#define HPDF_LANG_HA "ha" /* Hausa */
#define HPDF_LANG_HI "hi" /* Hindi */
#define HPDF_LANG_HR "hr" /* Croatian */
#define HPDF_LANG_HU "hu" /* Hungarian */
#define HPDF_LANG_HY "hy" /* Armenian */
#define HPDF_LANG_IA "ia" /* Interlingua */
#define HPDF_LANG_IE "ie" /* Interlingue */
#define HPDF_LANG_IK "ik" /* Inupiak */
#define HPDF_LANG_IN "in" /* Indonesian */
#define HPDF_LANG_IS "is" /* Icelandic */
#define HPDF_LANG_IT "it" /* Italian */
#define HPDF_LANG_IW "iw" /* Hebrew */
#define HPDF_LANG_JA "ja" /* Japanese */
#define HPDF_LANG_JI "ji" /* Yiddish */
#define HPDF_LANG_JW "jw" /* Javanese */
#define HPDF_LANG_KA "ka" /* Georgian */
#define HPDF_LANG_KK "kk" /* Kazakh */
#define HPDF_LANG_KL "kl" /* Greenlandic */
#define HPDF_LANG_KM "km" /* Cambodian */
#define HPDF_LANG_KN "kn" /* Kannada */
#define HPDF_LANG_KO "ko" /* Korean */
#define HPDF_LANG_KS "ks" /* Kashmiri */
#define HPDF_LANG_KU "ku" /* Kurdish */
#define HPDF_LANG_KY "ky" /* Kirghiz */
#define HPDF_LANG_LA "la" /* Latin */
#define HPDF_LANG_LN "ln" /* Lingala */
#define HPDF_LANG_LO "lo" /* Laothian */
#define HPDF_LANG_LT "lt" /* Lithuanian */
#define HPDF_LANG_LV "lv" /* Latvian,Lettish */
#define HPDF_LANG_MG "mg" /* Malagasy */
#define HPDF_LANG_MI "mi" /* Maori */
#define HPDF_LANG_MK "mk" /* Macedonian */
#define HPDF_LANG_ML "ml" /* Malayalam */
#define HPDF_LANG_MN "mn" /* Mongolian */
#define HPDF_LANG_MO "mo" /* Moldavian */
#define HPDF_LANG_MR "mr" /* Marathi */
#define HPDF_LANG_MS "ms" /* Malay */
#define HPDF_LANG_MT "mt" /* Maltese */
#define HPDF_LANG_MY "my" /* Burmese */
#define HPDF_LANG_NA "na" /* Nauru */
#define HPDF_LANG_NE "ne" /* Nepali */
#define HPDF_LANG_NL "nl" /* Dutch */
#define HPDF_LANG_NO "no" /* Norwegian */
#define HPDF_LANG_OC "oc" /* Occitan */
#define HPDF_LANG_OM "om" /* (Afan)Oromo */
#define HPDF_LANG_OR "or" /* Oriya */
#define HPDF_LANG_PA "pa" /* Punjabi */
#define HPDF_LANG_PL "pl" /* Polish */
#define HPDF_LANG_PS "ps" /* Pashto,Pushto */
#define HPDF_LANG_PT "pt" /* Portuguese */
#define HPDF_LANG_QU "qu" /* Quechua */
#define HPDF_LANG_RM "rm" /* Rhaeto-Romance */
#define HPDF_LANG_RN "rn" /* Kirundi */
#define HPDF_LANG_RO "ro" /* Romanian */
#define HPDF_LANG_RU "ru" /* Russian */
#define HPDF_LANG_RW "rw" /* Kinyarwanda */
#define HPDF_LANG_SA "sa" /* Sanskrit */
#define HPDF_LANG_SD "sd" /* Sindhi */
#define HPDF_LANG_SG "sg" /* Sangro */
#define HPDF_LANG_SH "sh" /* Serbo-Croatian */
#define HPDF_LANG_SI "si" /* Singhalese */
#define HPDF_LANG_SK "sk" /* Slovak */
#define HPDF_LANG_SL "sl" /* Slovenian */
#define HPDF_LANG_SM "sm" /* Samoan */
#define HPDF_LANG_SN "sn" /* Shona */
#define HPDF_LANG_SO "so" /* Somali */
#define HPDF_LANG_SQ "sq" /* Albanian */
#define HPDF_LANG_SR "sr" /* Serbian */
#define HPDF_LANG_SS "ss" /* Siswati */
#define HPDF_LANG_ST "st" /* Sesotho */
#define HPDF_LANG_SU "su" /* Sundanese */
#define HPDF_LANG_SV "sv" /* Swedish */
#define HPDF_LANG_SW "sw" /* Swahili */
#define HPDF_LANG_TA "ta" /* Tamil */
#define HPDF_LANG_TE "te" /* Tegulu */
#define HPDF_LANG_TG "tg" /* Tajik */
#define HPDF_LANG_TH "th" /* Thai */
#define HPDF_LANG_TI "ti" /* Tigrinya */
#define HPDF_LANG_TK "tk" /* Turkmen */
#define HPDF_LANG_TL "tl" /* Tagalog */
#define HPDF_LANG_TN "tn" /* Setswanato Tonga */
#define HPDF_LANG_TR "tr" /* Turkish */
#define HPDF_LANG_TS "ts" /* Tsonga */
#define HPDF_LANG_TT "tt" /* Tatar */
#define HPDF_LANG_TW "tw" /* Twi */
#define HPDF_LANG_UK "uk" /* Ukrainian */
#define HPDF_LANG_UR "ur" /* Urdu */
#define HPDF_LANG_UZ "uz" /* Uzbek */
#define HPDF_LANG_VI "vi" /* Vietnamese */
#define HPDF_LANG_VO "vo" /* Volapuk */
#define HPDF_LANG_WO "wo" /* Wolof */
#define HPDF_LANG_XH "xh" /* Xhosa */
#define HPDF_LANG_YO "yo" /* Yoruba */
#define HPDF_LANG_ZH "zh" /* Chinese */
#define HPDF_LANG_ZU "zu" /* Zulu */
/*----------------------------------------------------------------------------*/
/*----- Graphis mode ---------------------------------------------------------*/
#define HPDF_GMODE_PAGE_DESCRIPTION 0x0001
#define HPDF_GMODE_PATH_OBJECT 0x0002
#define HPDF_GMODE_TEXT_OBJECT 0x0004
#define HPDF_GMODE_CLIPPING_PATH 0x0008
#define HPDF_GMODE_SHADING 0x0010
#define HPDF_GMODE_INLINE_IMAGE 0x0020
#define HPDF_GMODE_EXTERNAL_OBJECT 0x0040
/*----------------------------------------------------------------------------*/
#endif /* _HPDF_CONSTS_H */

View File

@ -0,0 +1,44 @@
/*
* << Haru Free PDF Library >> -- hpdf_destination.c
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_DESTINATION_H
#define _HPDF_DESTINATION_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------------*/
/*----- HPDF_Destination -----------------------------------------------------*/
HPDF_Destination
HPDF_Destination_New (HPDF_MMgr mmgr,
HPDF_Page target,
HPDF_Xref xref);
HPDF_BOOL
HPDF_Destination_Validate (HPDF_Destination dst);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_DESTINATION_H */

162
code/libharu/hpdf_doc.h Normal file
View File

@ -0,0 +1,162 @@
/*
* << Haru Free PDF Library >> -- hpdf_doc.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_DOC_H
#define _HPDF_DOC_H
#define HPDF_SIG_BYTES 0x41504446L
#include "hpdf_catalog.h"
#include "hpdf_image.h"
#include "hpdf_pages.h"
#include "hpdf_outline.h"
#include "hpdf_ext_gstate.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HPDF_VER_DEFAULT HPDF_VER_12
typedef struct _HPDF_Doc_Rec {
HPDF_UINT32 sig_bytes;
HPDF_PDFVer pdf_version;
HPDF_MMgr mmgr;
HPDF_Catalog catalog;
HPDF_Outline outlines;
HPDF_Xref xref;
HPDF_Pages root_pages;
HPDF_Pages cur_pages;
HPDF_Page cur_page;
HPDF_List page_list;
HPDF_Error_Rec error;
HPDF_Dict info;
HPDF_Dict trailer;
HPDF_List font_mgr;
HPDF_BYTE ttfont_tag[6];
/* list for loaded fontdefs */
HPDF_List fontdef_list;
/* list for loaded encodings */
HPDF_List encoder_list;
HPDF_Encoder cur_encoder;
/* default compression mode */
HPDF_BOOL compression_mode;
HPDF_BOOL encrypt_on;
HPDF_EncryptDict encrypt_dict;
HPDF_Encoder def_encoder;
HPDF_UINT page_per_pages;
HPDF_UINT cur_page_num;
/* buffer for saving into memory stream */
HPDF_Stream stream;
} HPDF_Doc_Rec;
typedef struct _HPDF_Doc_Rec *HPDF_Doc;
HPDF_Encoder
HPDF_Doc_FindEncoder (HPDF_Doc pdf,
const char *encoding_name);
HPDF_FontDef
HPDF_Doc_FindFontDef (HPDF_Doc pdf,
const char *font_name);
HPDF_Font
HPDF_Doc_FindFont (HPDF_Doc pdf,
const char *font_name,
const char *encoding_name);
HPDF_BOOL
HPDF_Doc_Validate (HPDF_Doc pdf);
/*----- page handling -------------------------------------------------------*/
HPDF_Pages
HPDF_Doc_GetCurrentPages (HPDF_Doc pdf);
HPDF_Pages
HPDF_Doc_AddPagesTo (HPDF_Doc pdf,
HPDF_Pages parent);
HPDF_STATUS
HPDF_Doc_SetCurrentPages (HPDF_Doc pdf,
HPDF_Pages pages);
HPDF_STATUS
HPDF_Doc_SetCurrentPage (HPDF_Doc pdf,
HPDF_Page page);
/*----- font handling -------------------------------------------------------*/
HPDF_FontDef
HPDF_GetFontDef (HPDF_Doc pdf,
const char *font_name);
HPDF_STATUS
HPDF_Doc_RegisterFontDef (HPDF_Doc pdf,
HPDF_FontDef fontdef);
/*----- encoding handling ---------------------------------------------------*/
HPDF_STATUS
HPDF_Doc_RegisterEncoder (HPDF_Doc pdf,
HPDF_Encoder encoder);
/*----- encryptio------------------------------------------------------------*/
HPDF_STATUS
HPDF_Doc_SetEncryptOn (HPDF_Doc pdf);
HPDF_STATUS
HPDF_Doc_SetEncryptOff (HPDF_Doc pdf);
HPDF_STATUS
HPDF_Doc_PrepareEncryption (HPDF_Doc pdf);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_DOC_H */

318
code/libharu/hpdf_encoder.h Normal file
View File

@ -0,0 +1,318 @@
/*
* << Haru Free PDF Library >> -- hpdf_encoder.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_ENCODER_H
#define _HPDF_ENCODER_H
#include "hpdf_consts.h"
#include "hpdf_streams.h"
#ifdef __cplusplus
extern "C" {
#endif
/*-- HPDF_Encoder ---------------------------------------*/
#define HPDF_ENCODER_SIG_BYTES 0x454E4344L
/*----------------------------------------------------------------------------*/
/*------ predefined font encodings -------------------------------------------*/
#define HPDF_ENCODING_FONT_SPECIFIC "FontSpecific"
#define HPDF_ENCODING_STANDARD "StandardEncoding"
#define HPDF_ENCODING_MAC_ROMAN "MacRomanEncoding"
#define HPDF_ENCODING_WIN_ANSI "WinAnsiEncoding"
#define HPDF_ENCODING_ISO8859_2 "ISO8859-2"
#define HPDF_ENCODING_ISO8859_3 "ISO8859-3"
#define HPDF_ENCODING_ISO8859_4 "ISO8859-4"
#define HPDF_ENCODING_ISO8859_5 "ISO8859-5"
#define HPDF_ENCODING_ISO8859_6 "ISO8859-6"
#define HPDF_ENCODING_ISO8859_7 "ISO8859-7"
#define HPDF_ENCODING_ISO8859_8 "ISO8859-8"
#define HPDF_ENCODING_ISO8859_9 "ISO8859-9"
#define HPDF_ENCODING_ISO8859_10 "ISO8859-10"
#define HPDF_ENCODING_ISO8859_11 "ISO8859-11"
#define HPDF_ENCODING_ISO8859_13 "ISO8859-13"
#define HPDF_ENCODING_ISO8859_14 "ISO8859-14"
#define HPDF_ENCODING_ISO8859_15 "ISO8859-15"
#define HPDF_ENCODING_ISO8859_16 "ISO8859-16"
#define HPDF_ENCODING_CP1250 "CP1250"
#define HPDF_ENCODING_CP1251 "CP1251"
#define HPDF_ENCODING_CP1252 "CP1252"
#define HPDF_ENCODING_CP1253 "CP1253"
#define HPDF_ENCODING_CP1254 "CP1254"
#define HPDF_ENCODING_CP1255 "CP1255"
#define HPDF_ENCODING_CP1256 "CP1256"
#define HPDF_ENCODING_CP1257 "CP1257"
#define HPDF_ENCODING_CP1258 "CP1258"
#define HPDF_ENCODING_KOI8_R "KOI8-R"
/*----------------------------------------------------------------------------*/
/*----- definition for font encoding -----------------------------------------*/
#define char_NOTDEF ".notdef"
typedef enum _HPDF_EncodingType {
HPDF_STANDARD_ENCODING = 0,
HPDF_MAC_ROMAN_ENCODING,
HPDF_WIN_ANSI_ENCODING,
HPDF_FONT_SPECIFIC,
HPDF_ENCODING_EOF
} HPDF_EncodingType;
typedef struct _HPDF_ParseText_Rec {
const HPDF_BYTE *text;
HPDF_UINT index;
HPDF_UINT len;
HPDF_ByteType byte_type;
} HPDF_ParseText_Rec;
typedef struct _HPDF_Encoder_Rec *HPDF_Encoder;
typedef HPDF_ByteType
(*HPDF_Encoder_ByteType_Func) (HPDF_Encoder encoder,
HPDF_ParseText_Rec *state);
typedef HPDF_UNICODE
(*HPDF_Encoder_ToUnicode_Func) (HPDF_Encoder encoder,
HPDF_UINT16 code);
typedef char *
(*HPDF_Encoder_EncodeText_Func) (HPDF_Encoder encoder,
const char *text,
HPDF_UINT len,
HPDF_UINT *encoded_length);
typedef HPDF_STATUS
(*HPDF_Encoder_Write_Func) (HPDF_Encoder encoder,
HPDF_Stream out);
typedef HPDF_STATUS
(*HPDF_Encoder_Init_Func) (HPDF_Encoder encoder);
typedef void
(*HPDF_Encoder_Free_Func) (HPDF_Encoder encoder);
typedef struct _HPDF_Encoder_Rec {
HPDF_UINT32 sig_bytes;
char name[HPDF_LIMIT_MAX_NAME_LEN + 1];
HPDF_MMgr mmgr;
HPDF_Error error;
HPDF_EncoderType type;
HPDF_Encoder_ByteType_Func byte_type_fn;
HPDF_Encoder_ToUnicode_Func to_unicode_fn;
HPDF_Encoder_EncodeText_Func encode_text_fn;
HPDF_Encoder_Write_Func write_fn;
HPDF_Encoder_Free_Func free_fn;
HPDF_Encoder_Init_Func init_fn;
/*
char lang_code[3];
char country_code[3];
*/
void *attr;
} HPDF_Encoder_Rec;
typedef enum _HPDF_BaseEncodings {
HPDF_BASE_ENCODING_STANDARD,
HPDF_BASE_ENCODING_WIN_ANSI,
HPDF_BASE_ENCODING_MAC_ROMAN,
HPDF_BASE_ENCODING_FONT_SPECIFIC,
HPDF_BASE_ENCODING_EOF
} HPDF_BaseEncodings;
HPDF_STATUS
HPDF_Encoder_Validate (HPDF_Encoder encoder);
void
HPDF_Encoder_SetParseText (HPDF_Encoder encoder,
HPDF_ParseText_Rec *state,
const HPDF_BYTE *text,
HPDF_UINT len);
HPDF_ByteType
HPDF_Encoder_ByteType (HPDF_Encoder encoder,
HPDF_ParseText_Rec *state);
HPDF_UNICODE
HPDF_Encoder_ToUnicode (HPDF_Encoder encoder,
HPDF_UINT16 code);
void
HPDF_Encoder_Free (HPDF_Encoder encoder);
/*-- HPDF_BasicEncoder ----------------------------------*/
typedef struct _HPDF_BasicEncoderAttr_Rec *HPDF_BasicEncoderAttr;
typedef struct _HPDF_BasicEncoderAttr_Rec {
char base_encoding[HPDF_LIMIT_MAX_NAME_LEN + 1];
HPDF_BYTE first_char;
HPDF_BYTE last_char;
HPDF_UNICODE unicode_map[256];
HPDF_BOOL has_differences;
HPDF_BYTE differences[256];
} HPDF_BasicEncoderAttr_Rec;
HPDF_Encoder
HPDF_BasicEncoder_New (HPDF_MMgr mmgr,
const char *encoding_name);
void
HPDF_BasicEncoder_Free (HPDF_Encoder encoder);
HPDF_STATUS
HPDF_BasicEncoder_Write (HPDF_Encoder encoder,
HPDF_Stream out);
HPDF_UNICODE
HPDF_BasicEncoder_ToUnicode (HPDF_Encoder encoder,
HPDF_UINT16 code);
/*-- HPDF_CMapEncoder ----------------------------------*/
typedef HPDF_BOOL
(*HPDF_CMapEncoder_ByteType_Func) (HPDF_Encoder encoder,
HPDF_BYTE b);
typedef struct _HPDF_CidRange_Rec {
HPDF_UINT16 from;
HPDF_UINT16 to;
HPDF_UINT16 cid;
} HPDF_CidRange_Rec;
typedef struct _HPDF_UnicodeMap_Rec {
HPDF_UINT16 code;
HPDF_UINT16 unicode;
} HPDF_UnicodeMap_Rec;
typedef struct _HPDF_CMapEncoderAttr_Rec *HPDF_CMapEncoderAttr;
typedef struct _HPDF_CMapEncoderAttr_Rec {
HPDF_UNICODE unicode_map[256][256];
HPDF_UINT16 cid_map[256][256];
HPDF_UINT16 jww_line_head[HPDF_MAX_JWW_NUM];
HPDF_List cmap_range;
HPDF_List notdef_range;
HPDF_List code_space_range;
HPDF_WritingMode writing_mode;
char registry[HPDF_LIMIT_MAX_NAME_LEN + 1];
char ordering[HPDF_LIMIT_MAX_NAME_LEN + 1];
HPDF_INT suppliment;
HPDF_CMapEncoder_ByteType_Func is_lead_byte_fn;
HPDF_CMapEncoder_ByteType_Func is_trial_byte_fn;
HPDF_INT uid_offset;
HPDF_UINT xuid[3];
} HPDF_CMapEncoderAttr_Rec;
HPDF_Encoder
HPDF_CMapEncoder_New (HPDF_MMgr mmgr,
char *name,
HPDF_Encoder_Init_Func init_fn);
HPDF_STATUS
HPDF_CMapEncoder_InitAttr (HPDF_Encoder encoder);
void
HPDF_CMapEncoder_Free (HPDF_Encoder encoder);
HPDF_STATUS
HPDF_CMapEncoder_Write (HPDF_Encoder encoder,
HPDF_Stream out);
HPDF_UNICODE
HPDF_CMapEncoder_ToUnicode (HPDF_Encoder encoder,
HPDF_UINT16 code);
HPDF_UINT16
HPDF_CMapEncoder_ToCID (HPDF_Encoder encoder,
HPDF_UINT16 code);
HPDF_STATUS
HPDF_CMapEncoder_SetParseText (HPDF_Encoder encoder,
HPDF_ParseText_Rec *state,
const HPDF_BYTE *text,
HPDF_UINT len);
HPDF_ByteType
HPDF_CMapEncoder_ByteType (HPDF_Encoder encoder,
HPDF_ParseText_Rec *state);
HPDF_STATUS
HPDF_CMapEncoder_AddCMap (HPDF_Encoder encoder,
const HPDF_CidRange_Rec *range);
HPDF_STATUS
HPDF_CMapEncoder_AddNotDefRange (HPDF_Encoder encoder,
HPDF_CidRange_Rec range);
HPDF_STATUS
HPDF_CMapEncoder_AddCodeSpaceRange (HPDF_Encoder encoder,
HPDF_CidRange_Rec range);
void
HPDF_CMapEncoder_SetUnicodeArray (HPDF_Encoder encoder,
const HPDF_UnicodeMap_Rec *array1);
HPDF_STATUS
HPDF_CMapEncoder_AddJWWLineHead (HPDF_Encoder encoder,
const HPDF_UINT16 *code);
HPDF_BOOL
HPDF_Encoder_CheckJWWLineHead (HPDF_Encoder encoder,
const HPDF_UINT16 code);
/*-- utility functions ----------------------------------*/
const char*
HPDF_UnicodeToGryphName (HPDF_UNICODE unicode);
HPDF_UNICODE
HPDF_GryphNameToUnicode (const char *gryph_name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_ENCODER_H */

159
code/libharu/hpdf_encrypt.h Normal file
View File

@ -0,0 +1,159 @@
/*
* << Haru Free PDF Library >> -- hpdf_encrypt.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*------------------------------------------------------------------------------
*
* The code implements MD5 message-digest algorithm is based on the code
* written by Colin Plumb.
* The copyright of it is as follows.
*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*
*---------------------------------------------------------------------------*/
#ifndef HPDF_ENCRYPT_H
#define HPDF_ENCRYPT_H
#include "hpdf_mmgr.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------------*/
/*----- encrypt-dict ---------------------------------------------------------*/
#define HPDF_ID_LEN 16
#define HPDF_PASSWD_LEN 32
#define HPDF_ENCRYPT_KEY_MAX 16
#define HPDF_MD5_KEY_LEN 16
#define HPDF_PERMISSION_PAD 0xFFFFFFC0
#define HPDF_ARC4_BUF_SIZE 256
typedef struct HPDF_MD5Context
{
HPDF_UINT32 buf[4];
HPDF_UINT32 bits[2];
HPDF_BYTE in[64];
} HPDF_MD5_CTX;
typedef struct _HPDF_ARC4_Ctx_Rec {
HPDF_BYTE idx1;
HPDF_BYTE idx2;
HPDF_BYTE state[HPDF_ARC4_BUF_SIZE];
} HPDF_ARC4_Ctx_Rec;
typedef struct _HPDF_Encrypt_Rec *HPDF_Encrypt;
typedef struct _HPDF_Encrypt_Rec {
HPDF_EncryptMode mode;
/* key_len must be a multiple of 8, and between 40 to 128 */
HPDF_UINT key_len;
/* owner-password (not encrypted) */
HPDF_BYTE owner_passwd[HPDF_PASSWD_LEN];
/* user-password (not encrypted) */
HPDF_BYTE user_passwd[HPDF_PASSWD_LEN];
/* owner-password (encrypted) */
HPDF_BYTE owner_key[HPDF_PASSWD_LEN];
/* user-password (encrypted) */
HPDF_BYTE user_key[HPDF_PASSWD_LEN];
HPDF_INT permission;
HPDF_BYTE encrypt_id[HPDF_ID_LEN];
HPDF_BYTE encryption_key[HPDF_MD5_KEY_LEN + 5];
HPDF_BYTE md5_encryption_key[HPDF_MD5_KEY_LEN];
HPDF_ARC4_Ctx_Rec arc4ctx;
} HPDF_Encrypt_Rec;
void
HPDF_MD5Init (struct HPDF_MD5Context *ctx);
void
HPDF_MD5Update (struct HPDF_MD5Context *ctx,
const HPDF_BYTE *buf,
HPDF_UINT32 len);
void
HPDF_MD5Final (HPDF_BYTE digest[16],
struct HPDF_MD5Context *ctx);
void
HPDF_PadOrTrancatePasswd (const char *pwd,
HPDF_BYTE *new_pwd);
void
HPDF_Encrypt_Init (HPDF_Encrypt attr);
void
HPDF_Encrypt_CreateUserKey (HPDF_Encrypt attr);
void
HPDF_Encrypt_CreateOwnerKey (HPDF_Encrypt attr);
void
HPDF_Encrypt_CreateEncryptionKey (HPDF_Encrypt attr);
void
HPDF_Encrypt_InitKey (HPDF_Encrypt attr,
HPDF_UINT32 object_id,
HPDF_UINT16 gen_no);
void
HPDF_Encrypt_Reset (HPDF_Encrypt attr);
void
HPDF_Encrypt_CryptBuf (HPDF_Encrypt attr,
const HPDF_BYTE *src,
HPDF_BYTE *dst,
HPDF_UINT len);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_ENCRYPT_H */

View File

@ -0,0 +1,69 @@
/*
* << Haru Free PDF Library >> -- hpdf_encryptdict.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_ENCRYPTDICT_H
#define _HPDF_ENCRYPTDICT_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------*/
/*------ HPDF_EncryptDict ---------------------------------------------------*/
HPDF_EncryptDict
HPDF_EncryptDict_New (HPDF_MMgr mmgr,
HPDF_Xref xref);
void
HPDF_EncryptDict_CreateID (HPDF_EncryptDict dict,
HPDF_Dict info,
HPDF_Xref xref);
void
HPDF_EncryptDict_OnFree (HPDF_Dict obj);
HPDF_STATUS
HPDF_EncryptDict_SetPassword (HPDF_EncryptDict dict,
const char *owner_passwd,
const char *user_passwd);
HPDF_BOOL
HPDF_EncryptDict_Validate (HPDF_EncryptDict dict);
HPDF_STATUS
HPDF_EncryptDict_Prepare (HPDF_EncryptDict dict,
HPDF_Dict info,
HPDF_Xref xref);
HPDF_Encrypt
HPDF_EncryptDict_GetAttr (HPDF_EncryptDict dict);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_ENCRYPTDICT_H */

203
code/libharu/hpdf_error.h Normal file
View File

@ -0,0 +1,203 @@
/*
* << Haru Free PDF Library >> -- hpdf_error.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_ERROR_H
#define _HPDF_ERROR_H
#include "hpdf_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* error-code */
#define HPDF_ARRAY_COUNT_ERR 0x1001
#define HPDF_ARRAY_ITEM_NOT_FOUND 0x1002
#define HPDF_ARRAY_ITEM_UNEXPECTED_TYPE 0x1003
#define HPDF_BINARY_LENGTH_ERR 0x1004
#define HPDF_CANNOT_GET_PALLET 0x1005
#define HPDF_DICT_COUNT_ERR 0x1007
#define HPDF_DICT_ITEM_NOT_FOUND 0x1008
#define HPDF_DICT_ITEM_UNEXPECTED_TYPE 0x1009
#define HPDF_DICT_STREAM_LENGTH_NOT_FOUND 0x100A
#define HPDF_DOC_ENCRYPTDICT_NOT_FOUND 0x100B
#define HPDF_DOC_INVALID_OBJECT 0x100C
/* 0x100D */
#define HPDF_DUPLICATE_REGISTRATION 0x100E
#define HPDF_EXCEED_JWW_CODE_NUM_LIMIT 0x100F
/* 0x1010 */
#define HPDF_ENCRYPT_INVALID_PASSWORD 0x1011
/* 0x1012 */
#define HPDF_ERR_UNKNOWN_CLASS 0x1013
#define HPDF_EXCEED_GSTATE_LIMIT 0x1014
#define HPDF_FAILD_TO_ALLOC_MEM 0x1015
#define HPDF_FILE_IO_ERROR 0x1016
#define HPDF_FILE_OPEN_ERROR 0x1017
/* 0x1018 */
#define HPDF_FONT_EXISTS 0x1019
#define HPDF_FONT_INVALID_WIDTHS_TABLE 0x101A
#define HPDF_INVALID_AFM_HEADER 0x101B
#define HPDF_INVALID_ANNOTATION 0x101C
/* 0x101D */
#define HPDF_INVALID_BIT_PER_COMPONENT 0x101E
#define HPDF_INVALID_CHAR_MATRICS_DATA 0x101F
#define HPDF_INVALID_COLOR_SPACE 0x1020
#define HPDF_INVALID_COMPRESSION_MODE 0x1021
#define HPDF_INVALID_DATE_TIME 0x1022
#define HPDF_INVALID_DESTINATION 0x1023
/* 0x1024 */
#define HPDF_INVALID_DOCUMENT 0x1025
#define HPDF_INVALID_DOCUMENT_STATE 0x1026
#define HPDF_INVALID_ENCODER 0x1027
#define HPDF_INVALID_ENCODER_TYPE 0x1028
/* 0x1029 */
/* 0x102A */
#define HPDF_INVALID_ENCODING_NAME 0x102B
#define HPDF_INVALID_ENCRYPT_KEY_LEN 0x102C
#define HPDF_INVALID_FONTDEF_DATA 0x102D
#define HPDF_INVALID_FONTDEF_TYPE 0x102E
#define HPDF_INVALID_FONT_NAME 0x102F
#define HPDF_INVALID_IMAGE 0x1030
#define HPDF_INVALID_JPEG_DATA 0x1031
#define HPDF_INVALID_N_DATA 0x1032
#define HPDF_INVALID_OBJECT 0x1033
#define HPDF_INVALID_OBJ_ID 0x1034
#define HPDF_INVALID_OPERATION 0x1035
#define HPDF_INVALID_OUTLINE 0x1036
#define HPDF_INVALID_PAGE 0x1037
#define HPDF_INVALID_PAGES 0x1038
#define HPDF_INVALID_PARAMETER 0x1039
/* 0x103A */
#define HPDF_INVALID_PNG_IMAGE 0x103B
#define HPDF_INVALID_STREAM 0x103C
#define HPDF_MISSING_FILE_NAME_ENTRY 0x103D
/* 0x103E */
#define HPDF_INVALID_TTC_FILE 0x103F
#define HPDF_INVALID_TTC_INDEX 0x1040
#define HPDF_INVALID_WX_DATA 0x1041
#define HPDF_ITEM_NOT_FOUND 0x1042
#define HPDF_LIBPNG_ERROR 0x1043
#define HPDF_NAME_INVALID_VALUE 0x1044
#define HPDF_NAME_OUT_OF_RANGE 0x1045
/* 0x1046 */
/* 0x1047 */
#define HPDF_PAGE_INVALID_PARAM_COUNT 0x1048
#define HPDF_PAGES_MISSING_KIDS_ENTRY 0x1049
#define HPDF_PAGE_CANNOT_FIND_OBJECT 0x104A
#define HPDF_PAGE_CANNOT_GET_ROOT_PAGES 0x104B
#define HPDF_PAGE_CANNOT_RESTORE_GSTATE 0x104C
#define HPDF_PAGE_CANNOT_SET_PARENT 0x104D
#define HPDF_PAGE_FONT_NOT_FOUND 0x104E
#define HPDF_PAGE_INVALID_FONT 0x104F
#define HPDF_PAGE_INVALID_FONT_SIZE 0x1050
#define HPDF_PAGE_INVALID_GMODE 0x1051
#define HPDF_PAGE_INVALID_INDEX 0x1052
#define HPDF_PAGE_INVALID_ROTATE_VALUE 0x1053
#define HPDF_PAGE_INVALID_SIZE 0x1054
#define HPDF_PAGE_INVALID_XOBJECT 0x1055
#define HPDF_PAGE_OUT_OF_RANGE 0x1056
#define HPDF_REAL_OUT_OF_RANGE 0x1057
#define HPDF_STREAM_EOF 0x1058
#define HPDF_STREAM_READLN_CONTINUE 0x1059
/* 0x105A */
#define HPDF_STRING_OUT_OF_RANGE 0x105B
#define HPDF_THIS_FUNC_WAS_SKIPPED 0x105C
#define HPDF_TTF_CANNOT_EMBEDDING_FONT 0x105D
#define HPDF_TTF_INVALID_CMAP 0x105E
#define HPDF_TTF_INVALID_FOMAT 0x105F
#define HPDF_TTF_MISSING_TABLE 0x1060
#define HPDF_UNSUPPORTED_FONT_TYPE 0x1061
#define HPDF_UNSUPPORTED_FUNC 0x1062
#define HPDF_UNSUPPORTED_JPEG_FORMAT 0x1063
#define HPDF_UNSUPPORTED_TYPE1_FONT 0x1064
#define HPDF_XREF_COUNT_ERR 0x1065
#define HPDF_ZLIB_ERROR 0x1066
#define HPDF_INVALID_PAGE_INDEX 0x1067
#define HPDF_INVALID_URI 0x1068
#define HPDF_PAGE_LAYOUT_OUT_OF_RANGE 0x1069
#define HPDF_PAGE_MODE_OUT_OF_RANGE 0x1070
#define HPDF_PAGE_NUM_STYLE_OUT_OF_RANGE 0x1071
#define HPDF_ANNOT_INVALID_ICON 0x1072
#define HPDF_ANNOT_INVALID_BORDER_STYLE 0x1073
#define HPDF_PAGE_INVALID_DIRECTION 0x1074
#define HPDF_INVALID_FONT 0x1075
#define HPDF_PAGE_INSUFFICIENT_SPACE 0x1076
#define HPDF_PAGE_INVALID_DISPLAY_TIME 0x1077
#define HPDF_PAGE_INVALID_TRANSITION_TIME 0x1078
#define HPDF_INVALID_PAGE_SLIDESHOW_TYPE 0x1079
#define HPDF_EXT_GSTATE_OUT_OF_RANGE 0x1080
#define HPDF_INVALID_EXT_GSTATE 0x1081
#define HPDF_EXT_GSTATE_READ_ONLY 0x1082
#define HPDF_INVALID_U3D_DATA 0x1083
#define HPDF_NAME_CANNOT_GET_NAMES 0x1084
#define HPDF_INVALID_ICC_COMPONENT_NUM 0x1085
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*----- HPDF_Error ----------------------------------------------------------*/
typedef struct _HPDF_Error_Rec *HPDF_Error;
typedef struct _HPDF_Error_Rec {
HPDF_STATUS error_no;
HPDF_STATUS detail_no;
HPDF_Error_Handler error_fn;
void *user_data;
} HPDF_Error_Rec;
/* HPDF_Error_init
*
* if error_fn is NULL, the default-handlers are set as error-handler.
* user_data is used to identify the object which threw an error.
*
*/
void
HPDF_Error_Init (HPDF_Error error,
void *user_data);
void
HPDF_Error_Reset (HPDF_Error error);
HPDF_STATUS
HPDF_Error_GetCode (HPDF_Error error);
HPDF_STATUS
HPDF_Error_GetDetailCode (HPDF_Error error);
HPDF_STATUS
HPDF_SetError (HPDF_Error error,
HPDF_STATUS error_no,
HPDF_STATUS detail_no);
HPDF_STATUS
HPDF_RaiseError (HPDF_Error error,
HPDF_STATUS error_no,
HPDF_STATUS detail_no);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_ERROR_H */

View File

@ -0,0 +1,41 @@
/*
* << Haru Free PDF Library >> -- hpdf_annotation.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_EXDATA_H
#define _HPDF_EXDATA_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------------*/
/*------ HPDF_ExData -----------------------------------------------------*/
HPDF_ExData
HPDF_3DAnnotExData_New(HPDF_MMgr mmgr,
HPDF_Xref xref );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_EXDATA_H */

View File

@ -0,0 +1,41 @@
/*
* << Haru Free PDF Library >> -- hpdf_ext_gstate.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_EXT_GSTATE_H
#define _HPDF_EXT_GSTATE_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
HPDF_Dict
HPDF_ExtGState_New (HPDF_MMgr mmgr,
HPDF_Xref xref);
HPDF_BOOL
HPDF_ExtGState_Validate (HPDF_ExtGState ext_gstate);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_EXT_GSTATE_H */

115
code/libharu/hpdf_font.h Normal file
View File

@ -0,0 +1,115 @@
/*
* << Haru Free PDF Library >> -- hpdf_font.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_FONT_H
#define _HPDF_FONT_H
#include "hpdf_fontdef.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------------*/
/*----- Writing Mode ---------------------------------------------------------*/
typedef enum _HPDF_FontType {
HPDF_FONT_TYPE1 = 0,
HPDF_FONT_TRUETYPE,
HPDF_FONT_TYPE3,
HPDF_FONT_TYPE0_CID,
HPDF_FONT_TYPE0_TT,
HPDF_FONT_CID_TYPE0,
HPDF_FONT_CID_TYPE2,
HPDF_FONT_MMTYPE1
} HPDF_FontType;
typedef HPDF_Dict HPDF_Font;
typedef HPDF_TextWidth
(*HPDF_Font_TextWidths_Func) (HPDF_Font font,
const HPDF_BYTE *text,
HPDF_UINT len);
typedef HPDF_UINT
(*HPDF_Font_MeasureText_Func) (HPDF_Font font,
const HPDF_BYTE *text,
HPDF_UINT len,
HPDF_REAL width,
HPDF_REAL fontsize,
HPDF_REAL charspace,
HPDF_REAL wordspace,
HPDF_BOOL wordwrap,
HPDF_REAL *real_width);
typedef struct _HPDF_FontAttr_Rec *HPDF_FontAttr;
typedef struct _HPDF_FontAttr_Rec {
HPDF_FontType type;
HPDF_WritingMode writing_mode;
HPDF_Font_TextWidths_Func text_width_fn;
HPDF_Font_MeasureText_Func measure_text_fn;
HPDF_FontDef fontdef;
HPDF_Encoder encoder;
/* if the encoding-type is HPDF_ENCODER_TYPE_SINGLE_BYTE, the width of
* each charactors are cashed in 'widths'.
* when HPDF_ENCODER_TYPE_DOUBLE_BYTE the width is calculate each time.
*/
HPDF_INT16* widths;
HPDF_BYTE* used;
HPDF_Xref xref;
HPDF_Font descendant_font;
HPDF_Dict map_stream;
HPDF_Dict cmap_stream;
} HPDF_FontAttr_Rec;
HPDF_Font
HPDF_Type1Font_New (HPDF_MMgr mmgr,
HPDF_FontDef fontdef,
HPDF_Encoder encoder,
HPDF_Xref xref);
HPDF_Font
HPDF_TTFont_New (HPDF_MMgr mmgr,
HPDF_FontDef fontdef,
HPDF_Encoder encoder,
HPDF_Xref xref);
HPDF_Font
HPDF_Type0Font_New (HPDF_MMgr mmgr,
HPDF_FontDef fontdef,
HPDF_Encoder encoder,
HPDF_Xref xref);
HPDF_BOOL
HPDF_Font_Validate (HPDF_Font font);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_FONT_H */

406
code/libharu/hpdf_fontdef.h Normal file
View File

@ -0,0 +1,406 @@
/*
* << Haru Free PDF Library >> -- hpdf_fontdef.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_FONTDEF_H
#define _HPDF_FONTDEF_H
#include "hpdf_objects.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HPDF_FONTDEF_SIG_BYTES 0x464F4E54L
/*------ collection of flags for defining characteristics. ---*/
#define HPDF_FONT_FIXED_WIDTH 1
#define HPDF_FONT_SERIF 2
#define HPDF_FONT_SYMBOLIC 4
#define HPDF_FONT_SCRIPT 8
/* Reserved 16 */
#define HPDF_FONT_STD_CHARSET 32
#define HPDF_FONT_ITALIC 64
/* Reserved 128
Reserved 256
Reserved 512
Reserved 1024
Reserved 2048
Reserved 4096
Reserved 8192
Reserved 16384
Reserved 32768 */
#define HPDF_FONT_ALL_CAP 65536
#define HPDF_FONT_SMALL_CAP 131072
#define HPDF_FONT_FOURCE_BOLD 262144
#define HPDF_CID_W_TYPE_FROM_TO 0
#define HPDF_CID_W_TYPE_FROM_ARRAY 1
/*-- HPDF_FontDef ---------------------------------------*/
typedef struct _HPDF_CharData {
HPDF_INT16 char_cd;
HPDF_UNICODE unicode;
HPDF_INT16 width;
} HPDF_CharData;
typedef enum _HPDF_FontDefType {
HPDF_FONTDEF_TYPE_TYPE1,
HPDF_FONTDEF_TYPE_TRUETYPE,
HPDF_FONTDEF_TYPE_CID,
HPDF_FONTDEF_TYPE_UNINITIALIZED,
HPDF_FONTDEF_TYPE_EOF
} HPDF_FontDefType;
typedef struct _HPDF_CID_Width {
HPDF_UINT16 cid;
HPDF_INT16 width;
} HPDF_CID_Width;
/*----------------------------------------------------------------------------*/
/*----- HPDF_FontDef ---------------------------------------------------------*/
typedef struct _HPDF_FontDef_Rec *HPDF_FontDef;
typedef void (*HPDF_FontDef_FreeFunc) (HPDF_FontDef fontdef);
typedef void (*HPDF_FontDef_CleanFunc) (HPDF_FontDef fontdef);
typedef HPDF_STATUS (*HPDF_FontDef_InitFunc) (HPDF_FontDef fontdef);
typedef struct _HPDF_FontDef_Rec {
HPDF_UINT32 sig_bytes;
char base_font[HPDF_LIMIT_MAX_NAME_LEN + 1];
HPDF_MMgr mmgr;
HPDF_Error error;
HPDF_FontDefType type;
HPDF_FontDef_CleanFunc clean_fn;
HPDF_FontDef_FreeFunc free_fn;
HPDF_FontDef_InitFunc init_fn;
HPDF_INT16 ascent;
HPDF_INT16 descent;
HPDF_UINT flags;
HPDF_Box font_bbox;
HPDF_INT16 italic_angle;
HPDF_UINT16 stemv;
HPDF_INT16 avg_width;
HPDF_INT16 max_width;
HPDF_INT16 missing_width;
HPDF_UINT16 stemh;
HPDF_UINT16 x_height;
HPDF_UINT16 cap_height;
/* the initial value of descriptor entry is NULL.
* when first font-object besed on the fontdef object is created,
* the font-descriptor object is created and descriptor entry is set.
*/
HPDF_Dict descriptor;
HPDF_Stream data;
HPDF_BOOL valid;
void *attr;
} HPDF_FontDef_Rec;
void
HPDF_FontDef_Free (HPDF_FontDef fontdef);
void
HPDF_FontDef_Cleanup (HPDF_FontDef fontdef);
HPDF_BOOL
HPDF_FontDef_Validate (HPDF_FontDef fontdef);
/*----------------------------------------------------------------------------*/
/*----- HPDF_Type1FontDef ---------------------------------------------------*/
typedef struct _HPDF_Type1FontDefAttrRec *HPDF_Type1FontDefAttr;
typedef struct _HPDF_Type1FontDefAttrRec {
HPDF_BYTE first_char; /* Required */
HPDF_BYTE last_char; /* Required */
HPDF_CharData *widths; /* Required */
HPDF_UINT widths_count;
HPDF_INT16 leading;
char *char_set;
char encoding_scheme[HPDF_LIMIT_MAX_NAME_LEN + 1];
HPDF_UINT length1;
HPDF_UINT length2;
HPDF_UINT length3;
HPDF_BOOL is_base14font;
HPDF_BOOL is_fixed_pitch;
HPDF_Stream font_data;
} HPDF_Type1FontDefAttr_Rec;
HPDF_FontDef
HPDF_Type1FontDef_New (HPDF_MMgr mmgr);
HPDF_FontDef
HPDF_Type1FontDef_Load (HPDF_MMgr mmgr,
HPDF_Stream afm,
HPDF_Stream font_data);
HPDF_FontDef
HPDF_Type1FontDef_Duplicate (HPDF_MMgr mmgr,
HPDF_FontDef src);
HPDF_STATUS
HPDF_Type1FontDef_SetWidths (HPDF_FontDef fontdef,
const HPDF_CharData *widths);
HPDF_INT16
HPDF_Type1FontDef_GetWidthByName (HPDF_FontDef fontdef,
const char *gryph_name);
HPDF_INT16
HPDF_Type1FontDef_GetWidth (HPDF_FontDef fontdef,
HPDF_UNICODE unicode);
HPDF_FontDef
HPDF_Base14FontDef_New (HPDF_MMgr mmgr,
const char *font_name);
/*----------------------------------------------------------------------------*/
/*----- HPDF_TTFontDef ------------------------------------------------------*/
#define HPDF_TTF_FONT_TAG_LEN 6
typedef struct _HPDF_TTF_Table {
char tag[4];
HPDF_UINT32 check_sum;
HPDF_UINT32 offset;
HPDF_UINT32 length;
} HPDF_TTFTable;
typedef struct _HPDF_TTF_OffsetTbl {
HPDF_UINT32 sfnt_version;
HPDF_UINT16 num_tables;
HPDF_UINT16 search_range;
HPDF_UINT16 entry_selector;
HPDF_UINT16 range_shift;
HPDF_TTFTable *table;
} HPDF_TTF_OffsetTbl;
typedef struct _HPDF_TTF_CmapRange {
HPDF_UINT16 format;
HPDF_UINT16 length;
HPDF_UINT16 language;
HPDF_UINT16 seg_count_x2;
HPDF_UINT16 search_range;
HPDF_UINT16 entry_selector;
HPDF_UINT16 range_shift;
HPDF_UINT16 *end_count;
HPDF_UINT16 reserved_pad;
HPDF_UINT16 *start_count;
HPDF_INT16 *id_delta;
HPDF_UINT16 *id_range_offset;
HPDF_UINT16 *glyph_id_array;
HPDF_UINT glyph_id_array_count;
} HPDF_TTF_CmapRange;
typedef struct _HPDF_TTF_GryphOffsets {
HPDF_UINT32 base_offset;
HPDF_UINT32 *offsets;
HPDF_BYTE *flgs; /* 0: unused, 1: used */
} HPDF_TTF_GryphOffsets;
typedef struct _HPDF_TTF_LongHorMetric {
HPDF_UINT16 advance_width;
HPDF_INT16 lsb;
} HPDF_TTF_LongHorMetric;
typedef struct _HPDF_TTF_FontHeader {
HPDF_BYTE version_number[4];
HPDF_UINT32 font_revision;
HPDF_UINT32 check_sum_adjustment;
HPDF_UINT32 magic_number;
HPDF_UINT16 flags;
HPDF_UINT16 units_per_em;
HPDF_BYTE created[8];
HPDF_BYTE modified[8];
HPDF_INT16 x_min;
HPDF_INT16 y_min;
HPDF_INT16 x_max;
HPDF_INT16 y_max;
HPDF_UINT16 mac_style;
HPDF_UINT16 lowest_rec_ppem;
HPDF_INT16 font_direction_hint;
HPDF_INT16 index_to_loc_format;
HPDF_INT16 glyph_data_format;
} HPDF_TTF_FontHeader;
typedef struct _HPDF_TTF_NameRecord {
HPDF_UINT16 platform_id;
HPDF_UINT16 encoding_id;
HPDF_UINT16 language_id;
HPDF_UINT16 name_id;
HPDF_UINT16 length;
HPDF_UINT16 offset;
} HPDF_TTF_NameRecord;
typedef struct _HPDF_TTF_NamingTable {
HPDF_UINT16 format;
HPDF_UINT16 count;
HPDF_UINT16 string_offset;
HPDF_TTF_NameRecord *name_records;
} HPDF_TTF_NamingTable;
typedef struct _HPDF_TTFontDefAttr_Rec *HPDF_TTFontDefAttr;
typedef struct _HPDF_TTFontDefAttr_Rec {
char base_font[HPDF_LIMIT_MAX_NAME_LEN + 1];
HPDF_BYTE first_char;
HPDF_BYTE last_char;
char *char_set;
char tag_name[HPDF_TTF_FONT_TAG_LEN + 1];
char tag_name2[(HPDF_TTF_FONT_TAG_LEN + 1) * 2];
HPDF_TTF_FontHeader header;
HPDF_TTF_GryphOffsets glyph_tbl;
HPDF_UINT16 num_glyphs;
HPDF_TTF_NamingTable name_tbl;
HPDF_TTF_LongHorMetric *h_metric;
HPDF_UINT16 num_h_metric;
HPDF_TTF_OffsetTbl offset_tbl;
HPDF_TTF_CmapRange cmap;
HPDF_UINT16 fs_type;
HPDF_BYTE sfamilyclass[2];
HPDF_BYTE panose[10];
HPDF_UINT32 code_page_range1;
HPDF_UINT32 code_page_range2;
HPDF_UINT length1;
HPDF_BOOL embedding;
HPDF_BOOL is_cidfont;
HPDF_Stream stream;
} HPDF_TTFontDefAttr_Rec;
HPDF_FontDef
HPDF_TTFontDef_New (HPDF_MMgr mmgr);
HPDF_FontDef
HPDF_TTFontDef_Load (HPDF_MMgr mmgr,
HPDF_Stream stream,
HPDF_BOOL embedding);
HPDF_FontDef
HPDF_TTFontDef_Load2 (HPDF_MMgr mmgr,
HPDF_Stream stream,
HPDF_UINT index,
HPDF_BOOL embedding);
HPDF_UINT16
HPDF_TTFontDef_GetGlyphid (HPDF_FontDef fontdef,
HPDF_UINT16 unicode);
HPDF_INT16
HPDF_TTFontDef_GetCharWidth (HPDF_FontDef fontdef,
HPDF_UINT16 unicode);
HPDF_INT16
HPDF_TTFontDef_GetGidWidth (HPDF_FontDef fontdef,
HPDF_UINT16 gid);
HPDF_STATUS
HPDF_TTFontDef_SaveFontData (HPDF_FontDef fontdef,
HPDF_Stream stream);
HPDF_Box
HPDF_TTFontDef_GetCharBBox (HPDF_FontDef fontdef,
HPDF_UINT16 unicode);
void
HPDF_TTFontDef_SetTagName (HPDF_FontDef fontdef,
char *tag);
/*----------------------------------------------------------------------------*/
/*----- HPDF_CIDFontDef -----------------------------------------------------*/
typedef struct _HPDF_CIDFontDefAttrRec *HPDF_CIDFontDefAttr;
typedef struct _HPDF_CIDFontDefAttrRec {
HPDF_List widths;
HPDF_INT16 DW;
HPDF_INT16 DW2[2];
} HPDF_CIDFontDefAttr_Rec;
HPDF_FontDef
HPDF_CIDFontDef_New (HPDF_MMgr mmgr,
char *name,
HPDF_FontDef_InitFunc init_fn);
HPDF_STATUS
HPDF_CIDFontDef_AddWidth (HPDF_FontDef fontdef,
const HPDF_CID_Width *widths);
HPDF_INT16
HPDF_CIDFontDef_GetCIDWidth (HPDF_FontDef fontdef,
HPDF_UINT16 cid);
HPDF_STATUS
HPDF_CIDFontDef_ChangeStyle (HPDF_FontDef fontdef,
HPDF_BOOL bold,
HPDF_BOOL italic);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_FONTDEF_H */

View File

@ -0,0 +1,83 @@
/*
* << Haru Free PDF Library >> -- hpdf_gstate.h
*
* URL: http://libharu.org
*
* Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
* Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
* It is provided "as is" without express or implied warranty.
*
*/
#ifndef _HPDF_GSTATE_H
#define _HPDF_GSTATE_H
#include "hpdf_font.h"
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------------*/
/*------ graphic state stack -------------------------------------------------*/
typedef struct _HPDF_GState_Rec *HPDF_GState;
typedef struct _HPDF_GState_Rec {
HPDF_TransMatrix trans_matrix;
HPDF_REAL line_width;
HPDF_LineCap line_cap;
HPDF_LineJoin line_join;
HPDF_REAL miter_limit;
HPDF_DashMode dash_mode;
HPDF_REAL flatness;
HPDF_REAL char_space;
HPDF_REAL word_space;
HPDF_REAL h_scalling;
HPDF_REAL text_leading;
HPDF_TextRenderingMode rendering_mode;
HPDF_REAL text_rise;
HPDF_ColorSpace cs_fill;
HPDF_ColorSpace cs_stroke;
HPDF_RGBColor rgb_fill;
HPDF_RGBColor rgb_stroke;
HPDF_CMYKColor cmyk_fill;
HPDF_CMYKColor cmyk_stroke;
HPDF_REAL gray_fill;
HPDF_REAL gray_stroke;
HPDF_Font font;
HPDF_REAL font_size;
HPDF_WritingMode writing_mode;
HPDF_GState prev;
HPDF_UINT depth;
} HPDF_GState_Rec;
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
HPDF_GState
HPDF_GState_New (HPDF_MMgr mmgr,
HPDF_GState current);
HPDF_GState
HPDF_GState_Free (HPDF_MMgr mmgr,
HPDF_GState gstate);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _HPDF_GSTATE_H */

Some files were not shown because too many files have changed in this diff Show More