getting the filter name for export

presentation
morrolinux 7 years ago
parent 8f93dabee9
commit e5642b6976
  1. 8
      src/control/jobs/BaseExportJob.cpp
  2. 1
      src/control/jobs/BaseExportJob.h
  3. 42
      src/control/jobs/PdfExportJob.cpp
  4. 10
      src/control/jobs/PdfExportJob.h

@ -35,6 +35,14 @@ void BaseExportJob::addFileFilterToDialog(string name, string pattern)
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
}
string BaseExportJob::getFilterName()
{
XOJ_CHECK_TYPE(BaseExportJob);
GtkFileFilter* filter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog));
return gtk_file_filter_get_name(filter);
}
void BaseExportJob::prepareSavePath(path& path)
{
XOJ_CHECK_TYPE(BaseExportJob);

@ -34,6 +34,7 @@ public:
public:
virtual bool showFilechooser();
string getFilterName();
protected:
void initDialog();

@ -4,6 +4,7 @@
#include "pdf/base/XojPdfExportFactory.h"
#include <i18n.h>
#include <iostream>
PdfExportJob::PdfExportJob(Control* control)
@ -22,6 +23,7 @@ void PdfExportJob::addFilterToDialog()
XOJ_CHECK_TYPE(PdfExportJob);
addFileFilterToDialog(_C("PDF files"), "*.pdf");
addFileFilterToDialog(_C("PDF Without paper style"), "*.pdf");
}
void PdfExportJob::prepareSavePath(path& path)
@ -58,14 +60,52 @@ bool PdfExportJob::isUriValid(string& uri)
return false;
}
std::cout<<"PdfExportJob::isUriValid\n";
string filterName = BaseExportJob::getFilterName();
std::cout<<"FilterName: "<<filterName<<"\n";
return true;
}
void PdfExportJob::resetBackgroundType(Document* doc, PageType* pt, ResetActionType action)
{
XOJ_CHECK_TYPE(PdfExportJob);
size_t count = doc->getPageCount();
if (action == ACTION_RESET)
{
/** apply "plain" paper style to all pages before export */
for (int i=0; i<count ; i++)
{
pt[i] = doc->getPage(i)->getBackgroundType();
doc->getPage(i)->setBackgroundType(PageType("plain"));
}
}
if (action == ACTION_RESTORE)
{
/** restore each page to its original style */
for (int i=0; i<count ; i++)
{
doc->getPage(i)->setBackgroundType(pt[i]);
}
}
}
void PdfExportJob::run()
{
XOJ_CHECK_TYPE(PdfExportJob);
Document* doc = control->getDocument();
size_t count = doc->getPageCount();
PageType pt[count];
resetBackgroundType(doc, pt, ACTION_RESET);
doc->lock();
XojPdfExport* pdfe = XojPdfExportFactory::createExport(doc, control);
doc->unlock();
@ -83,5 +123,7 @@ void PdfExportJob::run()
}
delete pdfe;
resetBackgroundType(doc, pt, ACTION_RESTORE);
}

@ -13,6 +13,15 @@
#include "BaseExportJob.h"
class Document;
class PageType;
enum ResetActionType
{
ACTION_RESET = 0,
ACTION_RESTORE = 1
};
class PdfExportJob : public BaseExportJob
{
public:
@ -28,6 +37,7 @@ protected:
virtual void addFilterToDialog();
virtual void prepareSavePath(path& path);
virtual bool isUriValid(string& uri);
void resetBackgroundType(Document* doc, PageType* pt, ResetActionType action);
private:
XOJ_TYPE_ATTRIB;

Loading…
Cancel
Save