Skip to content

Commit

Permalink
add embed annotations in file command
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisFeldbusch committed Jan 29, 2024
1 parent 73ea2f4 commit 84a87eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pdf_viewer/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,10 @@ void Document::import_annotations() {
}
}

void Document::embed_annotations_in_file() {
embed_annotations(file_name);
}

void Document::embed_annotations(std::wstring new_file_path) {

std::unordered_map<int, fz_page*> cached_pages;
Expand Down
1 change: 1 addition & 0 deletions pdf_viewer/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class Document {
int get_page_offset();
void set_page_offset(int new_offset);
void embed_annotations(std::wstring new_file_path);
void embed_annotations_in_file();
void get_pdf_annotations(std::vector<BookMark>& pdf_bookmarks, std::vector<Highlight>& pdf_highlights, std::vector<FreehandDrawing>& pdf_drawings);
void import_annotations();
std::vector<PagelessDocumentRect> get_page_flat_words(int page);
Expand Down
15 changes: 15 additions & 0 deletions pdf_viewer/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4169,6 +4169,20 @@ class ReloadCommand : public Command {

};

class EmbedAnnotationsInFileCommand : public Command {
public:
EmbedAnnotationsInFileCommand(MainWidget* w) : Command(w) {};
void perform() {
widget->doc()->embed_annotations_in_file();
widget->reload(false);
}

std::string get_name() {
return "embed_annotations_in_file";
}

};

class ReloadNoFlickerCommand : public Command {
public:
ReloadNoFlickerCommand(MainWidget* w) : Command(w) {};
Expand Down Expand Up @@ -6206,6 +6220,7 @@ CommandManager::CommandManager(ConfigManager* config_manager) {
new_commands["toggle_horizontal_scroll_lock"] = [](MainWidget* widget) {return std::make_unique< ToggleHorizontalLockCommand>(widget); };
new_commands["execute"] = [](MainWidget* widget) {return std::make_unique< ExecuteCommand>(widget); };
new_commands["embed_annotations"] = [](MainWidget* widget) {return std::make_unique< EmbedAnnotationsCommand>(widget); };
new_commands["embed_annotations_in_file"] = [](MainWidget* widget) {return std::make_unique< EmbedAnnotationsInFileCommand>(widget); };
new_commands["import_annotations"] = [](MainWidget* widget) {return std::make_unique< ImportAnnotationsCommand>(widget); };
new_commands["copy_window_size_config"] = [](MainWidget* widget) {return std::make_unique< CopyWindowSizeConfigCommand>(widget); };
new_commands["toggle_select_highlight"] = [](MainWidget* widget) {return std::make_unique< ToggleSelectHighlightCommand>(widget); };
Expand Down

0 comments on commit 84a87eb

Please sign in to comment.