void clipboard::copy(const ContextReader& reader) { ASSERT(reader.document() != NULL); if (!copy_from_document(*reader.location())) { Console console; console.printf("Can't copying an image portion from the current layer\n"); } }
void saveAsDialog(const ContextReader& reader, const char* dlgTitle, bool markAsSaved) { const Document* document = reader.document(); std::string filename; if (!m_filename.empty()) { filename = m_filename; } else { filename = document->filename(); char exts[4096]; get_writable_extensions(exts, sizeof(exts)); for (;;) { std::string newfilename = app::show_file_selector(dlgTitle, filename, exts); if (newfilename.empty()) return; filename = newfilename; // Ask if the user wants overwrite the existent file. int ret = 0; if (base::is_file(filename)) { ret = ui::Alert::show("Warning<<The file already exists, overwrite it?<<%s||&Yes||&No||&Cancel", base::get_file_name(filename).c_str()); // Check for read-only attribute. if (ret == 1) { if (!confirmReadonly(filename)) ret = 2; // Select file again. else break; } } else break; // "yes": we must continue with the operation... if (ret == 1) { break; } // "cancel" or <esc> per example: we back doing nothing else if (ret != 2) return; // "no": we must back to select other file-name } } { ContextWriter writer(reader); Document* documentWriter = writer.document(); std::string oldFilename = documentWriter->filename(); // Change the document file name documentWriter->setFilename(filename.c_str()); m_selectedFilename = filename; // Save the document save_document_in_background(writer.context(), documentWriter, markAsSaved); if (documentWriter->isModified()) documentWriter->setFilename(oldFilename); update_screen_for_document(documentWriter); } }