read PDF from memory
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "czeitnachweis.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QRegExp>
|
||||
#include <QSettings>
|
||||
@@ -222,6 +224,11 @@ void cMonthlyView::setDate(const QDate& date)
|
||||
ui->m_lpResturlaubLabel->setText(QString(tr("Resturlaub %1:")).arg(date.addMonths(-1).toString("MMMM yyyy")));
|
||||
ui->m_lpUeberstunden->setText(secs2String(m_lpMonthlyBooking->ueberstunden(), 3));
|
||||
|
||||
// if(!m_lpMonthlyBooking->timesheet().isEmpty())
|
||||
// {
|
||||
// cZeitnachweis zeitnachweis(m_lpMonthlyBooking->timesheet());
|
||||
// }
|
||||
|
||||
updatePDF();
|
||||
displaySummary();
|
||||
|
||||
|
||||
+46
-9
@@ -1,11 +1,8 @@
|
||||
#include "czeitnachweis.h"
|
||||
|
||||
#include <podofo/podofo.h>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
using namespace PoDoFo;
|
||||
|
||||
cEntry::cEntry(entry type) :
|
||||
m_type(type),
|
||||
m_day(-1),
|
||||
@@ -64,7 +61,6 @@ cEntry* cEntryList::add(cEntry::entry type)
|
||||
|
||||
cZeitnachweis::cZeitnachweis(const QString& fileName, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_fileName(fileName),
|
||||
m_gedrucktAm(QDate()),
|
||||
m_mitarbeiterNummer(""),
|
||||
m_mitarbeiterName(""),
|
||||
@@ -83,9 +79,33 @@ cZeitnachweis::cZeitnachweis(const QString& fileName, QObject *parent) :
|
||||
m_monatssummeAnger(0),
|
||||
m_reisezeiten(0)
|
||||
{
|
||||
loadFile();
|
||||
loadFile(fileName);
|
||||
}
|
||||
|
||||
cZeitnachweis::cZeitnachweis(const QByteArray& buffer, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_gedrucktAm(QDate()),
|
||||
m_mitarbeiterNummer(""),
|
||||
m_mitarbeiterName(""),
|
||||
m_azpRegel(""),
|
||||
m_personalbereich(""),
|
||||
m_kostenstelle(""),
|
||||
m_von(QDate()),
|
||||
m_bis(QDate()),
|
||||
m_glzSaldoVorperiode(0),
|
||||
m_glzSaldoAktPeriode(0),
|
||||
m_uestLtDurchrechnungsz(0),
|
||||
m_glzSaldoGesamt(0),
|
||||
m_resturlaubstage(0),
|
||||
m_angeordneteUest(0),
|
||||
m_ersatzruhe(0),
|
||||
m_monatssummeAnger(0),
|
||||
m_reisezeiten(0)
|
||||
{
|
||||
loadBuffer(buffer);
|
||||
}
|
||||
|
||||
|
||||
void cZeitnachweis::setValues(const QDate& /*von*/, const QDate& /*bis*/, const int& day)
|
||||
{
|
||||
cEntry* lpEntry = m_entryList.add(cEntry::entry_normal);
|
||||
@@ -101,20 +121,37 @@ void cZeitnachweis::setValues(const QDate& /*von*/, const QDate& /*bis*/, const
|
||||
lpEntry->setBis(end);
|
||||
}
|
||||
|
||||
bool cZeitnachweis::loadFile()
|
||||
bool cZeitnachweis::loadFile(const QString &fileName)
|
||||
{
|
||||
PdfMemDocument pdf(m_fileName.toStdWString().c_str());
|
||||
PdfMemDocument pdf(fileName.toStdWString().c_str());
|
||||
if(!pdf.IsLoaded())
|
||||
return(false);
|
||||
|
||||
return(loadPDF(pdf));
|
||||
}
|
||||
|
||||
bool cZeitnachweis::loadBuffer(const QByteArray& buffer)
|
||||
{
|
||||
PdfMemDocument pdf;
|
||||
|
||||
pdf.LoadFromBuffer(buffer.data(), buffer.length());
|
||||
|
||||
if(!pdf.IsLoaded())
|
||||
return(false);
|
||||
|
||||
return(loadPDF(pdf));
|
||||
}
|
||||
|
||||
bool cZeitnachweis::loadPDF(const PdfMemDocument& pdfDocument)
|
||||
{
|
||||
qreal xPos = 0.0;
|
||||
qreal yPos = 0.0;
|
||||
qreal oldYPos = -1.0;
|
||||
QStringList lines;
|
||||
|
||||
for(int pn = 0; pn < pdf.GetPageCount();pn++)
|
||||
for(int pn = 0; pn < pdfDocument.GetPageCount();pn++)
|
||||
{
|
||||
PdfPage* page = pdf.GetPage(pn);
|
||||
PdfPage* page = pdfDocument.GetPage(pn);
|
||||
|
||||
PdfContentsTokenizer tok(page);
|
||||
const char* token = nullptr;
|
||||
|
||||
+9
-3
@@ -2,6 +2,8 @@
|
||||
#define CZEITNACHWEIS_H
|
||||
|
||||
|
||||
#include <podofo/podofo.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDate>
|
||||
@@ -12,6 +14,8 @@
|
||||
#include <QList>
|
||||
|
||||
|
||||
using namespace PoDoFo;
|
||||
|
||||
class cEntry
|
||||
{
|
||||
public:
|
||||
@@ -56,12 +60,12 @@ class cZeitnachweis : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cZeitnachweis(const QString& fileName, QObject *parent = nullptr);
|
||||
explicit cZeitnachweis(const QByteArray& buffer, QObject *parent = nullptr);
|
||||
|
||||
bool loadFile();
|
||||
bool loadFile(const QString& fileName);
|
||||
bool loadBuffer(const QByteArray& buffer);
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
|
||||
QDate m_gedrucktAm;
|
||||
QString m_mitarbeiterNummer;
|
||||
QString m_mitarbeiterName;
|
||||
@@ -82,6 +86,8 @@ private:
|
||||
|
||||
cEntryList m_entryList;
|
||||
|
||||
bool loadPDF(const PdfMemDocument& pdfDocument);
|
||||
|
||||
void setValues(const QDate& von, const QDate& bis, const int& day);
|
||||
void setValues(const QDate& von, const QDate& bis, const int& day, const QTime& start, const QTime& end);
|
||||
|
||||
|
||||
+5
-5
@@ -21,13 +21,13 @@ win32-msvc* {
|
||||
|
||||
win32-g++ {
|
||||
message("mingw")
|
||||
# INCLUDEPATH += C:\dev\3rdParty\PoDoFo\include
|
||||
# LIBS += -LC:\dev\3rdParty\PoDoFo\lib -lpodofo.dll
|
||||
INCLUDEPATH += C:\dev\3rdParty\PoDoFo\include
|
||||
LIBS += -LC:\dev\3rdParty\PoDoFo\lib -lpodofo.dll
|
||||
}
|
||||
|
||||
unix {
|
||||
message("*nix")
|
||||
# LIBS += -lpodofo
|
||||
LIBS += -lpodofo
|
||||
}
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
@@ -52,7 +52,7 @@ SOURCES += \
|
||||
common.cpp \
|
||||
cpublicholiday.cpp \
|
||||
cvacation.cpp \
|
||||
# czeitnachweis.cpp \
|
||||
czeitnachweis.cpp \
|
||||
main.cpp \
|
||||
cmainwindow.cpp
|
||||
|
||||
@@ -65,7 +65,7 @@ HEADERS += \
|
||||
cmonthlyview.h \
|
||||
common.h \
|
||||
cpublicholiday.h \
|
||||
# czeitnachweis.h \
|
||||
czeitnachweis.h \
|
||||
cvacation.h
|
||||
|
||||
FORMS += \
|
||||
|
||||
Reference in New Issue
Block a user