changeset 0:c1ebc8b218f2

xdwtools source code.
author pyon@macmini
date Sun, 29 Mar 2015 18:11:58 +0900 (2015-03-29)
parents
children 9341384c2785
files xdw2txt.cpp xdw2txtb.cpp xdwaddatn.cpp xdwaddpage.cpp xdwdelpage.cpp xdwextpage.cpp xdwgrep.cpp xdwinsert.cpp xdwopt.cpp xdwpages.cpp xdwpush.cpp xdwshift.cpp xdwsplit.cpp
diffstat 13 files changed, 1194 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdw2txt.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,82 @@
+/* xdwapi�̃T���v��2
+
+�@�\:
+  DocuWorks�������̃e�L�X�g�����e�L�X�g�t�@�C���ɏo�͂���
+�g�p���@:
+  xdw2txt �����t�@�C���� �ۑ���e�L�X�g�t�@�C����
+
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if ( argc != 3) {
+  		fprintf(stderr, "�g�p���@: xdw2txt �����t�@�C���� �ۑ���e�L�X�g�t�@�C����");
+		return 0;
+	}
+
+	char in_path[_MAX_PATH], out_path[_MAX_PATH];
+	_fullpath(in_path,  argv[1], _MAX_PATH);
+	_fullpath(out_path, argv[2], _MAX_PATH);
+
+	int page = 0;
+
+	// �����n���h�����J��
+	XDW_DOCUMENT_HANDLE h = NULL;
+	XDW_OPEN_MODE_EX mode = {
+		sizeof(XDW_OPEN_MODE_EX), XDW_OPEN_READONLY, XDW_AUTH_NODIALOGUE };
+	api_result = XDW_OpenDocumentHandle(in_path, &h, (XDW_OPEN_MODE*)&mode);
+	if (api_result < 0) {
+		print_error(api_result);
+		return 0;
+	}
+
+    api_result = XDW_GetFullText(h, out_path, NULL);
+
+	if (api_result < 0) print_error(api_result);
+
+	// �����n���h����‚���
+	XDW_CloseDocumentHandle(h, NULL);
+
+	return (api_result >= 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdw2txtb.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,91 @@
+/* xdw2txtB
+
+�@�\:
+  DocuWorks��������w�肵���y�[�W���ƂɃe�L�X�g�𒊏o
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 2 ) {
+		fprintf(stderr, "�g�p���@: xdw2txtb �����t�@�C����");
+		return 0;
+	}
+
+    int nPage;
+	char in_path[_MAX_PATH], out_path[_MAX_PATH];
+
+    _fullpath(in_path,  argv[1], _MAX_PATH);
+    _fullpath(out_path, argv[2], _MAX_PATH);
+
+	// �����n���h�����J��
+	XDW_DOCUMENT_HANDLE h = NULL;
+	XDW_OPEN_MODE_EX mode = {
+		sizeof(XDW_OPEN_MODE_EX), XDW_OPEN_READONLY, 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, 0, 0 };
+	XDW_GetDocumentInformation(h, &info);
+    nPage = info.nPages;
+
+    long datasize;
+    char* lpszvalue;
+    // ���C������
+    for ( int i=1; i<=nPage; i++ ) {
+        datasize = XDW_GetPageTextToMemory( h, i, NULL, 0, NULL );
+        lpszvalue = (char*)malloc( sizeof(char)*datasize);
+        XDW_GetPageTextToMemory( h, i, lpszvalue, datasize, NULL );
+        printf( "%s\n", lpszvalue );
+        free(lpszvalue);
+    }
+
+	if (api_result < 0) print_error(api_result);
+
+	// �����n���h����‚���
+	XDW_CloseDocumentHandle(h, NULL);
+
+	return (api_result >= 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwaddatn.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,136 @@
+/*--------------------------------------------------------------------------------
+ * �@�\:
+ *  DocuWorks�����̂��ׂẴy�[�W�Ƀe�L�X�g�A�m�e�[�V������\��t����
+ *-------------------------------------------------------------------------------*/
+
+#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*>(XDW_COLOR_NONE), 0, NULL); // �w�i����
+			h, annoation, XDW_ATN_BackColor, XDW_ATYPE_INT, reinterpret_cast<char*>(&color), 0, NULL); // �w�i����
+    }
+
+	return api_result;
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 8) {
+		fprintf(stderr, "�g�p���@:\n");
+        fprintf(stderr, "xdwaddatn �����t�@�C���� ���������� X���W Y���W �}�������� �T�C�Y �g�����X�y�A�����g\n");
+		fprintf(stderr, "    ex. : xdwaddatn hoge.xdw searchtext 500 1000 Boooo! 120 1    # �w�i����\n");
+		fprintf(stderr, "    ex. : xdwaddatn hoge.xdw searchtext 500 1000 Boooo! 120 0    # �w�i��\n");
+		fprintf(stderr, "    ex. : xdwaddatn hoge.xdw *          500 1000 Boooo! 120 0    # ���ׂẴy�[�W��\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;
+
+    XDW_FOUND_HANDLE pFoundHandle = NULL;
+
+
+    int x = atoi( argv[3] );
+    int y = atoi( argv[4] );
+    int sz = atoi( argv[6] );
+    int tr = atoi( argv[7] );   // �����t���O
+
+	// �A�m�e�[�V������\��t����
+	if ( !strcmp( "*", argv[2] ) ) {	// ���ׂẴy�[�W
+		for (int i = 1; i <= last_page; i++) {
+			api_result = add_annotation(h, i, x, y, argv[5], &sz, tr);
+			if (api_result < 0) {
+				print_error(api_result);
+				break;
+			}
+		}
+	} 
+	else {
+		for (int i = 1; i <= last_page; i++) {
+			api_result = XDW_FindTextInPage( h, i, argv[2], NULL, &pFoundHandle, NULL );
+			if ( pFoundHandle != NULL ) {   // �����q�b�g
+				api_result = add_annotation(h, i, x, y, argv[5], &sz, tr);
+				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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwaddpage.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,116 @@
+/*--------------------------------------------------------------------------------
+ * �@�\:
+ *  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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwdelpage.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,81 @@
+/*--------------------------------------------------------------------------------
+ * �@�\:
+ *  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 main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 3) {
+		fprintf(stderr, "�g�p���@:\n");
+        fprintf(stderr, "xdwdelpage �����t�@�C���� �y�[�W\n");
+		return 0;
+	}
+
+	char in_path[_MAX_PATH];
+	_fullpath(in_path, argv[1], _MAX_PATH);
+    int p = atoi(argv[2]);
+
+	// �����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;
+	}
+    // �폜
+    api_result = XDW_DeletePage( h, p, NULL );
+	if (api_result < 0) {
+		print_error(api_result);
+		return 0;
+	}
+
+	// �ύ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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwextpage.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,79 @@
+/* xdwapi�̃T���v��
+
+�@�\:
+  DocuWorks��������w�肵���y�[�W�𒊏o
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 4 ) {
+		fprintf(stderr, "�g�p���@: xdwextpage �����t�@�C���� ���o�y�[�W �o�̓t�@�C����");
+		return 0;
+	}
+
+    int nPage;
+	char in_path[_MAX_PATH], out_path[_MAX_PATH];
+
+    nPage = atoi( argv[2] );
+    _fullpath(in_path,  argv[1], _MAX_PATH);
+    _fullpath(out_path, argv[3], _MAX_PATH);
+
+	// �����n���h�����J��
+	XDW_DOCUMENT_HANDLE h = NULL;
+	XDW_OPEN_MODE_EX mode = {
+		sizeof(XDW_OPEN_MODE_EX), XDW_OPEN_READONLY, XDW_AUTH_NODIALOGUE };
+	api_result = XDW_OpenDocumentHandle(in_path, &h, (XDW_OPEN_MODE*)&mode);
+	if (api_result < 0) {
+		print_error(api_result);
+		return 0;
+	}
+
+	api_result = XDW_GetPage( h, nPage, out_path, NULL );
+
+	if (api_result < 0) print_error(api_result);
+
+	// �����n���h����‚���
+	XDW_CloseDocumentHandle(h, NULL);
+
+	return (api_result >= 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwgrep.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,118 @@
+/* xdwapi�̃T���v��
+
+�@�\:
+  DocuWorks������GREP
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 3 && argc != 4) {
+		fprintf(stderr, "�g�p���@: xdwgrep �������� �����t�@�C����");
+		fprintf(stderr, "�g�p���@: xdwgrep -v �������� �����t�@�C����");
+		fprintf(stderr, "\n���������̓_�u���N�H�[�g�ł�����");
+		return 0;
+	}
+
+	char in_path[_MAX_PATH], out_path[_MAX_PATH];
+    char buf[256], searchtext[256];
+    int rev_flag=0;
+
+	if (argc == 3) {
+        sprintf( searchtext, "%s", argv[1] );
+        sprintf( in_path,    "%s", argv[2] );
+    }
+	if (argc == 4 && !strcmp( argv[1], "-v" ) ) {
+        rev_flag=1;
+        sprintf( searchtext, "%s", argv[2] );
+        sprintf( in_path,    "%s", argv[3] );
+    }
+    sprintf( out_path, "%s.xdw", searchtext );
+
+	sprintf( buf, "copy %s %s", in_path, out_path );
+	system( buf );
+
+	int page = 0;
+
+    _fullpath(out_path, out_path, _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(out_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, 0, 0 };
+	XDW_GetDocumentInformation(h, &info);
+	int last_page = info.nPages;
+    XDW_FOUND_HANDLE pFoundHandle = NULL;
+
+    if ( !rev_flag ) {
+        for ( int i=last_page; i>=1; i-- ) {
+            api_result = XDW_FindTextInPage( h, i, searchtext, NULL, &pFoundHandle, NULL );
+
+            if ( pFoundHandle == NULL ) {
+                api_result = XDW_DeletePage( h, i, NULL );
+            }
+            XDW_CloseFoundHandle( pFoundHandle );
+        }
+    }
+    else {
+        for ( int i=last_page; i>=1; i-- ) {
+            api_result = XDW_FindTextInPage( h, i, searchtext, NULL, &pFoundHandle, NULL );
+
+            if ( pFoundHandle != NULL ) {
+                api_result = XDW_DeletePage( h, i, NULL );
+            }
+            XDW_CloseFoundHandle( pFoundHandle );
+        }
+    }
+
+	// �����n���h����‚���
+    XDW_SaveDocument( h, NULL );
+	XDW_CloseDocumentHandle(h, NULL);
+
+	return (api_result >= 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwinsert.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,83 @@
+/*--------------------------------------------------------------------------------
+ * �@�\:
+ *  DocuWorks�����ɕ�Docuworks�t�@�C����}������
+ *-------------------------------------------------------------------------------*/
+
+#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 main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 4) {
+		fprintf(stderr, "�g�p���@:\n");
+        fprintf(stderr, "xdwinsert �����t�@�C���� �y�[�W �}���t�@�C����\n");
+		return 0;
+	}
+
+	char in_path[_MAX_PATH];
+	_fullpath(in_path, argv[1], _MAX_PATH);
+	char insert_path[_MAX_PATH];
+    int p = atoi(argv[2]);
+	_fullpath(insert_path, argv[3], _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;
+	}
+    // �}��
+    api_result = XDW_InsertDocument( h, p, insert_path, NULL );
+	if (api_result < 0) {
+		print_error(api_result);
+		return 0;
+	}
+
+	// �ύ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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwopt.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,62 @@
+/* xdwapi�̃T���v��
+
+�@�\:
+  DocuWorks�����̍œK��
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 3 ) {
+		fprintf(stderr, "�g�p���@: xdwopt �����t�@�C���� �o�̓t�@�C����");
+		return 0;
+	}
+
+	char in_path[_MAX_PATH], out_path[_MAX_PATH];
+
+    _fullpath(in_path,  argv[1], _MAX_PATH);
+    _fullpath(out_path, argv[2], _MAX_PATH);
+
+	api_result = XDW_OptimizeDocument( in_path, out_path, NULL );
+
+	return (api_result >= 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwpages.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,78 @@
+/* xdwapi�̃T���v��
+
+�@�\:
+  DocuWorks�����̑��y�[�W����Ԃ�
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if ( argc != 2 ) {
+		fprintf(stderr, "�g�p���@: xdwpages �����t�@�C����");
+		return 0;
+	}
+
+	char in_path[_MAX_PATH];
+    
+    sprintf( in_path, "%s", argv[1] );
+    
+	// �����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, 0, 0 };
+	XDW_GetDocumentInformation( h, &info );
+	printf("%d\n", info.nPages);	
+
+	// �����n���h����‚���
+	XDW_CloseDocumentHandle( h, NULL );
+
+	return (api_result >= 0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwpush.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,83 @@
+/* 
+
+�@�\:
+  DocuWorks�����̖����ɕʂ̃t�@�C����lj�����
+�g�p���@:
+  xdwpush �����t�@�C���� �lj�����t�@�C����
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 3) {
+		fprintf(stderr, "�g�p���@: xdwpush �����t�@�C���� �lj�����t�@�C����");
+		return 0;
+	}
+
+	char in_path[_MAX_PATH], add_path[_MAX_PATH];
+	_fullpath(in_path,  argv[1], _MAX_PATH);
+	_fullpath(add_path, argv[2], _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, 0, 0 };
+	XDW_GetDocumentInformation(h, &info);
+	int last_page = info.nPages;
+
+	api_result = XDW_InsertDocument( h, last_page+1, add_path, NULL );
+	if (api_result < 0) print_error(api_result);
+
+	XDW_SaveDocument(h,NULL);
+	// �����n���h����‚���
+	XDW_CloseDocumentHandle(h, NULL);
+
+	return (api_result >= 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwshift.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,77 @@
+/* 
+
+�@�\:
+  DocuWorks�����̐擪�y�[�W���폜����
+�g�p���@:
+  xdwshift �����t�@�C����
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 2) {
+		fprintf(stderr, "�g�p���@: xdwshift �����t�@�C����");
+		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;
+	}
+
+	api_result = XDW_DeletePage( h, 1, NULL );
+	if (api_result < 0) print_error(api_result);
+
+	XDW_SaveDocument(h,NULL);
+	// �����n���h����‚���
+	XDW_CloseDocumentHandle(h, NULL);
+
+	return (api_result >= 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdwsplit.cpp	Sun Mar 29 18:11:58 2015 +0900
@@ -0,0 +1,108 @@
+/* xdwsplit
+
+�@�\:
+  DocuWorks�������w��y�[�W�����Ƃɕ���
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <io.h>
+
+#include <windows.h>
+
+#include <xdw_api.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_FILE_EXISTS:
+		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���[���������܂����B");
+		break;
+	}
+}
+
+int main(int argc, char** argv)
+{
+	int api_result = 0;
+
+	if (argc != 3 ) {
+		fprintf(stderr, "�g�p���@: xdwsplit SP �����t�@�C����");
+		return 0;
+	}
+
+    int sPage, nPage;
+	char in_path[_MAX_PATH], out_path[_MAX_PATH];
+
+	sPage = atoi(argv[1]);
+    _fullpath(in_path, argv[2], _MAX_PATH);
+    
+	// �����n���h�����J��
+	XDW_DOCUMENT_HANDLE h = NULL;
+	XDW_OPEN_MODE_EX mode = { sizeof(XDW_OPEN_MODE_EX), XDW_OPEN_READONLY, 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, 0, 0 };
+	XDW_GetDocumentInformation(h, &info);
+    nPage = info.nPages;
+	// �����n���h����‚���
+	XDW_CloseDocumentHandle(h, NULL);
+
+	if (nPage <= sPage) {
+		fprintf(stderr, "���y�[�W�������������y�[�W�����w�肵�Ă��������B");
+		return 0;
+	}
+
+	char buf[_MAX_PATH];
+	int i = 1;
+	int z = 1;
+	if (nPage % sPage == 0) z = 0;
+    // ���C������
+    while ( i <= nPage/sPage + z ) {
+		
+		sprintf(buf, "%03d.xdw", i);
+		_fullpath(out_path, buf, _MAX_PATH);
+
+		sprintf(buf, "copy %s %s", in_path, out_path);
+		system(buf);
+
+		XDW_OPEN_MODE_EX mode = { sizeof(XDW_OPEN_MODE_EX), XDW_OPEN_UPDATE, XDW_AUTH_NODIALOGUE };
+		api_result = XDW_OpenDocumentHandle(out_path, &h, (XDW_OPEN_MODE*)&mode);
+		
+		for ( int j = nPage; j >= 1; j-- ) {
+			if ( j > sPage * i  ||  j <= sPage * (i-1) ) 
+				api_result = XDW_DeletePage(h, j, NULL);
+		}
+		
+		// �����n���h����‚���
+		XDW_SaveDocument(h, NULL);
+		XDW_CloseDocumentHandle(h, NULL);
+		
+		i++;
+	}
+}
+