Add filename arg to fop_to_save_document()

This commit is contained in:
David Capello 2015-04-06 12:01:08 -03:00
parent d9259afc04
commit 0a4e710ad7
3 changed files with 11 additions and 9 deletions

View File

@ -73,8 +73,8 @@ private:
static void save_document_in_background(Context* context, Document* document, static void save_document_in_background(Context* context, Document* document,
bool mark_as_saved, const std::string& fn_format) bool mark_as_saved, const std::string& fn_format)
{ {
base::UniquePtr<FileOp> fop(fop_to_save_document(context, document, base::UniquePtr<FileOp> fop(fop_to_save_document(context,
fn_format.c_str())); document, document->filename().c_str(), fn_format.c_str()));
if (!fop) if (!fop)
return; return;

View File

@ -108,7 +108,8 @@ int save_document(Context* context, doc::Document* document)
int ret; int ret;
FileOp* fop = fop_to_save_document(context, FileOp* fop = fop_to_save_document(context,
static_cast<app::Document*>(document), ""); static_cast<app::Document*>(document),
document->filename().c_str(), "");
if (!fop) if (!fop)
return -1; return -1;
@ -223,7 +224,8 @@ done:;
return fop; return fop;
} }
FileOp* fop_to_save_document(Context* context, Document* document, const char* fn_format_arg) FileOp* fop_to_save_document(Context* context, Document* document,
const char* filename, const char* fn_format_arg)
{ {
FileOp *fop; FileOp *fop;
bool fatal; bool fatal;
@ -236,9 +238,9 @@ FileOp* fop_to_save_document(Context* context, Document* document, const char* f
fop->document = document; fop->document = document;
// Get the extension of the filename (in lower case) // Get the extension of the filename (in lower case)
std::string extension = base::string_to_lower(base::get_file_extension(fop->document->filename())); std::string extension = base::string_to_lower(base::get_file_extension(filename));
PRINTF("Saving document \"%s\" (%s)\n", fop->document->filename().c_str(), extension.c_str()); PRINTF("Saving document \"%s\" (%s)\n", filename, extension.c_str());
// Get the format through the extension of the filename // Get the format through the extension of the filename
fop->format = FileFormatsManager::instance() fop->format = FileFormatsManager::instance()
@ -363,7 +365,7 @@ FileOp* fop_to_save_document(Context* context, Document* document, const char* f
if (fop->format->support(FILE_SUPPORT_SEQUENCES)) { if (fop->format->support(FILE_SUPPORT_SEQUENCES)) {
fop_prepare_for_sequence(fop); fop_prepare_for_sequence(fop);
std::string fn = fop->document->filename(); std::string fn = filename;
std::string fn_format = fn_format_arg; std::string fn_format = fn_format_arg;
bool default_format = false; bool default_format = false;
@ -415,7 +417,7 @@ FileOp* fop_to_save_document(Context* context, Document* document, const char* f
} }
} }
else else
fop->filename = fop->document->filename(); fop->filename = filename;
// Configure output format? // Configure output format?
if (fop->format->support(FILE_SUPPORT_GET_FORMAT_OPTIONS)) { if (fop->format->support(FILE_SUPPORT_GET_FORMAT_OPTIONS)) {

View File

@ -123,7 +123,7 @@ namespace app {
// Low-level routines to load/save documents. // Low-level routines to load/save documents.
FileOp* fop_to_load_document(Context* context, const char* filename, int flags); FileOp* fop_to_load_document(Context* context, const char* filename, int flags);
FileOp* fop_to_save_document(Context* context, Document* document, const char* fn_format); FileOp* fop_to_save_document(Context* context, Document* document, const char* filename, const char* fn_format);
void fop_operate(FileOp* fop, IFileOpProgress* progress); void fop_operate(FileOp* fop, IFileOpProgress* progress);
void fop_done(FileOp* fop); void fop_done(FileOp* fop);
void fop_stop(FileOp* fop); void fop_stop(FileOp* fop);