Mercurial > mercurial > hgweb_xdwtools.cgi
view xdwaddpage.cpp @ 11:3cecce3b2ce3
add (f)lex file.
author | pyon@macmini |
---|---|
date | Fri, 15 Jun 2018 18:44:44 +0900 (2018-06-15) |
parents | c1ebc8b218f2 |
children |
line wrap: on
line source
/*-------------------------------------------------------------------------------- * �@�\: * DocuWorks�����Ƀy�[�W�ԍ����ӂ� *-------------------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <xdw_api.h> #include <xdwapian.h> void print_error(int code) { switch (code) { case XDW_E_NOT_INSTALLED: fprintf(stderr, "DocuWorks���C���X�g�[������Ă��܂���B"); break; case XDW_E_FILE_NOT_FOUND: fprintf(stderr, "�w�肳�ꂽ�t�@�C����������܂���B"); break; case XDW_E_ACCESSDENIED: case XDW_E_INVALID_NAME: case XDW_E_BAD_NETPATH: fprintf(stderr, "�w�肳�ꂽ�t�@�C�����J�����Ƃ��ł��܂���B"); break; case XDW_E_BAD_FORMAT: fprintf(stderr, "�w�肳�ꂽ�t�@�C���͐������t�H�[�}�b�g�ł͂���܂���B"); break; case XDW_E_INVALID_ACCESS: fprintf(stderr, "�w�肳�ꂽ��������錠��������܂���B"); break; default: fprintf(stderr, "�G���[�R�[�h:%x\n", code); fprintf(stderr, "�G���[���������܂����B"); break; } } int add_annotation(XDW_DOCUMENT_HANDLE h, int page, int x, int y, char* string, int* sz, int tr) { // �e�L�X�g�A�m�e�[�V�������쐬���� XDW_ANNOTATION_HANDLE annoation; int api_result = XDW_AddAnnotation( h, XDW_AID_TEXT, page, x, y, NULL, &annoation, NULL); if (api_result < 0) return api_result; // �쐬�����A�m�e�[�V�����ɕ������ݒ肷�� api_result = XDW_SetAnnotationAttribute( h, annoation, XDW_ATN_Text, XDW_ATYPE_STRING, string, 0, NULL); // �����e�L�X�g api_result = XDW_SetAnnotationAttribute( h, annoation, XDW_ATN_FontSize, XDW_ATYPE_INT, reinterpret_cast<char*>(sz), 0, NULL); // �t�H���g�T�C�Y if ( tr ) { int color = XDW_COLOR_NONE; api_result = XDW_SetAnnotationAttribute( h, annoation, XDW_ATN_BackColor, XDW_ATYPE_INT, reinterpret_cast<char*>(&color), 0, NULL); } return api_result; } int main(int argc, char** argv) { int api_result = 0; if (argc != 2) { fprintf(stderr, "�g�p���@:\n"); fprintf(stderr, "xdwaddpage �����t�@�C����\n"); return 0; } char in_path[_MAX_PATH]; _fullpath(in_path, argv[1], _MAX_PATH); // �����n���h�����J�� XDW_DOCUMENT_HANDLE h = NULL; XDW_OPEN_MODE_EX mode = { sizeof(XDW_OPEN_MODE_EX), XDW_OPEN_UPDATE, XDW_AUTH_NODIALOGUE }; api_result = XDW_OpenDocumentHandle(in_path, &h, (XDW_OPEN_MODE*)&mode); if (api_result < 0) { print_error(api_result); return 0; } // XDW_GetDocumentInformation��p���đ��y�[�W���� XDW_DOCUMENT_INFO info = { sizeof(XDW_DOCUMENT_INFO), 0 }; XDW_GetDocumentInformation(h, &info); int last_page = info.nPages; int sz = 80; // �����T�C�Y int tr = 1; // �����t���O char pagenum[12]; // �A�m�e�[�V������\��t���� for (int i = 1; i <= last_page; i++) { sprintf( pagenum, "%05d-%05d", i, last_page ); //api_result = add_annotation( h, i, 1700, 5600, pagenum, &sz, tr ); // ���� api_result = add_annotation( h, i, 18500, 28500, pagenum, &sz, tr ); // �E�� if (api_result < 0) { print_error(api_result); break; } } // �ύX���t�@�C���ɔ��f���� if (api_result >= 0) { api_result = XDW_SaveDocument(h, NULL); } // �����n���h������� XDW_CloseDocumentHandle(h, NULL); if (api_result < 0) return 0; return 1; }