Add document resize service boundary

This commit is contained in:
2026-06-03 13:09:12 +02:00
parent 9c3f56954e
commit 7c76703355
5 changed files with 149 additions and 8 deletions

View File

@@ -21,6 +21,15 @@ struct DocumentResizePlan {
bool clears_history = false;
};
class DocumentResizeServices {
public:
virtual ~DocumentResizeServices() = default;
virtual void resize_document(int width, int height) = 0;
virtual void update_title() = 0;
virtual void clear_history() = 0;
};
[[nodiscard]] inline DocumentResizeDialogState make_document_resize_dialog_state(
int current_resolution)
{
@@ -54,4 +63,20 @@ struct DocumentResizePlan {
});
}
[[nodiscard]] inline pp::foundation::Status execute_document_resize_plan(
const DocumentResizePlan& plan,
DocumentResizeServices& services)
{
if (plan.width <= 0 || plan.height <= 0) {
return pp::foundation::Status::out_of_range("resize dimensions must be positive");
}
services.resize_document(plan.width, plan.height);
services.update_title();
if (plan.clears_history) {
services.clear_history();
}
return pp::foundation::Status::success();
}
}