#ifndef SLIDE_COMBINE_C_H #define SLIDE_COMBINE_C_H #include #include #include #include #include #include #include // 版本信息 #define APP_VERSION "2.0.0" #define MAX_PATH_LENGTH 1024 #define MAX_BUFFER_SIZE 4096 #define MAX_BOOKMARKS 1000 #define MAX_METADATA_FIELDS 50 // 错误代码 - 避免与Windows宏冲突 typedef enum { SLIDE_ERROR_NONE = 0, SLIDE_ERROR_FILE_NOT_FOUND, SLIDE_ERROR_INVALID_PATH, SLIDE_ERROR_MEMORY_ALLOCATION, SLIDE_ERROR_ENCODING_DETECTION, SLIDE_ERROR_FILE_READ, SLIDE_ERROR_FILE_WRITE } ErrorCode; // 元数据字段类型 typedef enum { FIELD_TITLE = 0, FIELD_OTHER_TITLES, FIELD_VOLUME, FIELD_ISBN, FIELD_CREATOR, FIELD_CONTRIBUTOR, FIELD_ISSUED_DATE, FIELD_PUBLISHER, FIELD_PLACE, FIELD_CLASSIFICATION_NUMBER, FIELD_PAGE, FIELD_SUBJECT, FIELD_DATE, FIELD_SPATIAL, FIELD_OTHER_ISBN, FIELD_OTHER_TIME, FIELD_URL, FIELD_COUNT } FieldType; // 字段名称映射 static const char* FIELD_NAMES[] = { "title", "Other titles", "Volume", "ISBN", "creator", "contributor", "issuedDate", "publisher", "place", "Classification number", "page", "subject", "date", "spatial", "Other ISBN", "Other time", "url" }; // 书签项结构 typedef struct { char title[256]; char page[32]; } BookmarkItem; // 文档元数据结构 typedef struct { char fields[FIELD_COUNT][256]; BookmarkItem bookmarks[MAX_BOOKMARKS]; int bookmark_count; } DocumentMetadata; // 文件组结构 typedef struct { char base_name[256]; char** files; int file_count; DocumentMetadata* metadata_docs; int metadata_count; char* output_content; } FileGroup; // 应用程序状态 typedef struct { HWND hwnd; char pdf_path[MAX_PATH_LENGTH]; char txt_path[MAX_PATH_LENGTH]; char output_path[MAX_PATH_LENGTH]; HFONT hFont; HBRUSH hBgBrush; BOOL processing; } AppState; // 函数声明 ErrorCode extract_bookmarks_from_bkmk(const char* filename, BookmarkItem* bookmarks, int* count); ErrorCode read_metadata_from_txt(const char* filename, DocumentMetadata* metadata); ErrorCode create_output_content(DocumentMetadata* docs, int count, char** output); ErrorCode save_content_to_file(const char* filename, const char* content); ErrorCode detect_file_encoding(const char* filename, char* buffer, int buffer_size); ErrorCode process_all_files(const char* pdf_path, const char* txt_path, FileGroup** groups, int* group_count); ErrorCode merge_file_group(FileGroup* group, const char* txt_source_path); ErrorCode save_all_results(FileGroup* groups, int group_count, const char* output_path); // 排序函数 int compare_bkmk_files(const void* a, const void* b); int extract_folder_number(const char* folder_name); // 字符串处理函数 char* trim_whitespace(char* str); char* utf8_to_local(const char* utf8_str); char* local_to_utf8(const char* local_str); int extract_number_from_string(const char* str); // 界面函数 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); BOOL create_main_window(HINSTANCE hInstance, int nCmdShow); void init_common_controls(); void center_window(HWND hwnd); void browse_folder(HWND hwnd, char* path, const char* title); void log_message(HWND hwnd, const char* message, BOOL is_error); void start_processing(HWND hwnd); void clear_paths(HWND hwnd); // 辅助函数 void show_error(HWND hwnd, const char* message); void show_info(HWND hwnd, const char* message); BOOL is_valid_path(const char* path); void free_memory(FileGroup* groups, int count); // 资源ID定义 #define ID_BUTTON_BROWSE_PDF 1001 #define ID_BUTTON_BROWSE_TXT 1002 #define ID_BUTTON_BROWSE_OUTPUT 1003 #define ID_BUTTON_PROCESS 1004 #define ID_BUTTON_CLEAR 1005 #define ID_BUTTON_EXIT 1006 #define ID_EDIT_PDF_PATH 2001 #define ID_EDIT_TXT_PATH 2002 #define ID_EDIT_OUTPUT_PATH 2003 #define ID_LOG_TEXT 3001 // 窗口尺寸和位置 #define WINDOW_WIDTH 600 #define WINDOW_HEIGHT 500 #define CONTROL_HEIGHT 25 #define CONTROL_MARGIN 10 #endif // SLIDE_COMBINE_C_H