diff --git a/src/control/Control.cpp b/src/control/Control.cpp index b75a26f7..827f4674 100644 --- a/src/control/Control.cpp +++ b/src/control/Control.cpp @@ -2074,6 +2074,9 @@ void Control::exportAsPdf() { this->scheduler->addJob(job, JOB_PRIORITY_NONE); } else { delete job; + + // The job blocked, so we have to unblock, because the job unblocks only after run + unblock(); } } diff --git a/src/control/XournalMain.cpp b/src/control/XournalMain.cpp index cbff1442..150e002f 100644 --- a/src/control/XournalMain.cpp +++ b/src/control/XournalMain.cpp @@ -70,15 +70,17 @@ int XournalMain::run(int argc, char * argv[]) { GOptionContext * context = context = g_option_context_new("FILE"); bool optNoWarnSVN = false; + bool optNoPdfCompress = false; gchar ** optFilename = NULL; gchar * pdfFilename = NULL; int openAtPageNumber = -1; GOptionEntry options[] = { - { "no-warn-svn", 'w', 0, G_OPTION_ARG_NONE, &optNoWarnSVN, "Do not warn this is a development release", NULL }, - { "create-pdf", 'p', 0, G_OPTION_ARG_FILENAME, &pdfFilename, "PDF output filename" , NULL}, - { "page", 'n', 0, G_OPTION_ARG_INT, &openAtPageNumber, "Jump to Page (first Page: 1)", "N" }, - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &optFilename, "" , NULL}, + { "no-warn-svn", 'w', 0, G_OPTION_ARG_NONE, &optNoWarnSVN, "Do not warn this is a development release", NULL }, + { "pdf-no-compress", 0, 0, G_OPTION_ARG_NONE, &optNoPdfCompress, "Don't compress PDF files (for debugging)", NULL }, + { "create-pdf", 'p', 0, G_OPTION_ARG_FILENAME, &pdfFilename, "PDF output filename", NULL }, + { "page", 'n', 0, G_OPTION_ARG_INT, &openAtPageNumber, "Jump to Page (first Page: 1)", "N" }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &optFilename, "", NULL }, { NULL } }; @@ -98,6 +100,10 @@ int XournalMain::run(int argc, char * argv[]) { // Init threads (used for our Sheduler, Jobs) g_thread_init(NULL); + if(optNoPdfCompress) { + PdfWriter::setCompressPdfOutput(false); + } + if (pdfFilename && optFilename && *optFilename) { return exportPdf(*optFilename, pdfFilename); } diff --git a/src/control/jobs/BlockingJob.cpp b/src/control/jobs/BlockingJob.cpp index 827d5725..e002dc13 100644 --- a/src/control/jobs/BlockingJob.cpp +++ b/src/control/jobs/BlockingJob.cpp @@ -12,7 +12,6 @@ BlockingJob::BlockingJob(Control * control, const char * name) { BlockingJob::~BlockingJob() { XOJ_CHECK_TYPE(BlockingJob); - control->unblock(); this->control = NULL; XOJ_RELEASE_TYPE(BlockingJob); diff --git a/src/control/tools/EditSelection.cpp b/src/control/tools/EditSelection.cpp index abef4253..d83b72f5 100644 --- a/src/control/tools/EditSelection.cpp +++ b/src/control/tools/EditSelection.cpp @@ -11,8 +11,6 @@ #include "../../undo/FontUndoAction.h" #include "../../gui/XournalView.h" #include "../../gui/pageposition/PagePositionHandler.h" - -// TODO: debug #include "../../control/Control.h" #include "../../model/Document.h" @@ -294,11 +292,6 @@ UndoAction * EditSelection::setSize(ToolSize size, const double * thiknessPen, c } if (found) { - double x1 = this->x; - double x2 = this->x + this->width; - double y1 = this->y; - double y2 = this->y + this->height; - this->deleteViewBuffer(); this->view->getXournal()->repaintSelection(); @@ -332,11 +325,6 @@ UndoAction * EditSelection::setColor(int color) { } if (found) { - double x1 = this->x; - double x2 = this->x + this->width; - double y1 = this->y; - double y2 = this->y + this->height; - this->deleteViewBuffer(); this->view->getXournal()->repaintSelection(); @@ -556,12 +544,49 @@ void EditSelection::mouseMove(double x, double y) { int ry = this->getYOnViewAbsolute(); PageView * v = pp->getBestMatchingView(rx, ry, this->getViewWidth(), this->getViewHeight()); - // TODO: Debug - if (v) { - int pageNr = this->view->getXournal()->getControl()->getDocument()->indexOf(v->getPage()); - printf("best matching page: %i\n", pageNr); - } else { - printf("no matching page found\n"); + if(v && v != this->view) { + XournalView * xournal = this->view->getXournal(); + int pageNr = xournal->getControl()->getDocument()->indexOf(v->getPage()); + + xournal->pageSelected(pageNr); + + translateToView(v); + } +} + +/** + * Translate all coordinates which are relative to the current view to the new view, + * and set the attribute view to the new view + */ +void EditSelection::translateToView(PageView * v) { + double zoom = view->getXournal()->getZoom(); + + double absoluteX = getXOnViewAbsolute(); + double absoluteY = getYOnViewAbsolute(); + + int aX1 = getXOnViewAbsolute(); + int aY1 = getYOnViewAbsolute(); + + + absoluteX -= v->getX(); + absoluteY -= v->getY(); + + this->relativeX = absoluteX / zoom - this->x; + this->relativeY = absoluteY / zoom - this->y; + + + + this->view = v; + + + int aX2 = getXOnViewAbsolute(); + int aY2 = getYOnViewAbsolute(); + + if(aX1 != aX2) { + printf("aX1 != aX2!! %i / %i\n", aX1, aX2); + } + if(aY1 != aY2) { + printf("aY1 != aY2!! %i / %i\n", aY1, aY2); } } diff --git a/src/control/tools/EditSelection.h b/src/control/tools/EditSelection.h index fa770e51..4ac32619 100644 --- a/src/control/tools/EditSelection.h +++ b/src/control/tools/EditSelection.h @@ -193,15 +193,25 @@ private: */ void finalizeSelection(); + /** + * Translate all coordinates which are relative to the current view to the new view, + * and set the attribute view to the new view + */ + void translateToView(PageView * v); + private: // DATA XOJ_TYPE_ATTRIB; /** - * The size + * The position relative to the current view */ double x; double y; + + /** + * The size + */ double width; double height; diff --git a/src/gui/pageposition/PageViewIndex.cpp b/src/gui/pageposition/PageViewIndex.cpp index e3088f83..61c03327 100644 --- a/src/gui/pageposition/PageViewIndex.cpp +++ b/src/gui/pageposition/PageViewIndex.cpp @@ -91,21 +91,14 @@ PageView * PageViewIndex::getHighestIntersects() { PageViewIndexEntry * b = NULL; - // TODO: Debug - printf("----------------\n"); - for(GList * l = this->data; l != NULL;l = l->next) { PageViewIndexEntry * e = (PageViewIndexEntry *)l->data; - printf("->%i\n", e->area); - if(b == NULL || b->area < e->area) { b = e; } } - printf("\n"); - if(b != NULL) { return b->view; } diff --git a/src/pdf/PdfExport.cpp b/src/pdf/PdfExport.cpp index 14380101..fc5c9da3 100644 --- a/src/pdf/PdfExport.cpp +++ b/src/pdf/PdfExport.cpp @@ -150,6 +150,7 @@ bool PdfExport::writePagesindex() { for (GList * l = this->pageIds; l != NULL; l = l->next) { int id = *((int *) l->data); this->writer->writef("%i 0 R ", id); + pageCount++; } this->writer->write("]\n"); this->writer->writef("/Count %i\n", pageCount); @@ -538,7 +539,7 @@ String PdfExport::getLastError() { bool PdfExport::createPdf(String uri, GList * range) { XOJ_CHECK_TYPE(PdfExport); - // TODO: LOW PRIO: handle bookmakrs correct + // TODO: LOW PRIO: handle bookmarks correct if (range == NULL) { this->lastError = "No pages to export!"; diff --git a/src/pdf/PdfWriter.cpp b/src/pdf/PdfWriter.cpp index 53a6690b..a97a1889 100644 --- a/src/pdf/PdfWriter.cpp +++ b/src/pdf/PdfWriter.cpp @@ -6,6 +6,8 @@ #include "../util/GzHelper.h" +bool PdfWriter::compressPdfOutput = true; + PdfWriter::PdfWriter(PdfXRef * xref) { XOJ_INIT_TYPE(PdfWriter); @@ -15,8 +17,6 @@ PdfWriter::PdfWriter(PdfXRef * xref) { this->dataCount = 0; this->xref = xref; this->objectId = 3; - - this->compressOutput = true; } PdfWriter::~PdfWriter() { @@ -32,6 +32,10 @@ PdfWriter::~PdfWriter() { XOJ_RELEASE_TYPE(PdfWriter); } +void PdfWriter::setCompressPdfOutput(bool compress) { + PdfWriter::compressPdfOutput = compress; +} + void PdfWriter::close() { XOJ_CHECK_TYPE(PdfWriter); @@ -224,7 +228,7 @@ void PdfWriter::endStream() { GString * data = NULL; GString * compressed = NULL; - if (this->compressOutput) { + if (PdfWriter::compressPdfOutput) { compressed = GzHelper::gzcompress(this->stream); } diff --git a/src/pdf/PdfWriter.h b/src/pdf/PdfWriter.h index 46111cc2..4a0d5bec 100644 --- a/src/pdf/PdfWriter.h +++ b/src/pdf/PdfWriter.h @@ -45,12 +45,15 @@ public: int getNextObjectId(); int getDataCount(); +public: + static void setCompressPdfOutput(bool compress); + private: XOJ_TYPE_ATTRIB; - int dataCount; - bool compressOutput; + static bool compressPdfOutput; + int dataCount; bool inStream; GString * stream;