File: wvSummary.c

package info (click to toggle)
abiword 0.7.7-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 20,604 kB
  • ctags: 18,358
  • sloc: cpp: 88,791; ansic: 66,296; sh: 7,777; makefile: 3,397; xml: 687; perl: 361; awk: 273; sed: 36; csh: 28
file content (184 lines) | stat: -rw-r--r-- 3,775 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include <stdlib.h>
#include <stdio.h>
#include "wv.h"

/*
This is a simple example that take an ole file and prints the
title and the last modified time of the document according to
the summaryinformation stream

Caolan.McNamara@ul.ie
*/

int main(int argc,char **argv)
	{
	char szTemp[256];
	SummaryInfo si;
	int ret;
	U16 yr, mon, day, hr, min, sec;
	U32 along;
	FILE *s;

	wvInitError();

	if (argc < 2)
		{
		printf("Usage: wvSummary oledocument\n");
		return(1);
		}
	
	ret = wvOLESummaryStream(argv[1],&s);
	if (ret)
		{
		fprintf(stderr,"sorry problem with getting ole streams from %s\n",argv[1]);
		return(ret);
		}

	if (s == NULL)
		{
		printf("no summary stream\n");
		return(0);
		}

	ret = wvSumInfoOpenStream(&si,s);

	if (ret)
		{
		fprintf(stderr,"open stream failed\n");
		return(ret);
		}


	ret = wvSumInfoGetString(szTemp, 256, PID_TITLE, &si);

	if (!ret)
		printf("The title is %s\n",szTemp);
	else
		printf("no title found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_SUBJECT, &si);

	if (!ret)
		printf("The subject is %s\n",szTemp);
	else
		printf("no subject found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_AUTHOR, &si);

	if (!ret)
		printf("The author is %s\n",szTemp);
	else
		printf("no author found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_KEYWORDS, &si);

	if (!ret)
		printf("The keywords are %s\n",szTemp);
	else
		printf("no keywords found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_COMMENTS, &si);

	if (!ret)
		printf("The comments are %s\n",szTemp);
	else
		printf("no comments found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_TEMPLATE, &si);

	if (!ret)
		printf("The template was %s\n",szTemp);
	else
		printf("no template found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_LASTAUTHOR, &si);

	if (!ret)
		printf("The last author was %s\n",szTemp);
	else
		printf("no last author found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_REVNUMBER, &si);

	if (!ret)
		printf("The rev no was %s\n",szTemp);
	else
		printf("no rev no found\n");

	ret = wvSumInfoGetString(szTemp, 256, PID_APPNAME, &si);

	if (!ret)
		printf("The app name was %s\n",szTemp);
	else
		printf("no app name found\n");

	ret = wvSumInfoGetTime(&yr, &mon, &day, &hr, &min, &sec,PID_TOTAL_EDITTIME,&si);

	if (!ret)
	    printf("Total edit time was %d/%d/%d %d:%d:%d\n",day,mon,yr,hr,min,sec);
	else
		printf("no total edit time found\n");


	ret = wvSumInfoGetTime(&yr, &mon, &day, &hr, &min, &sec,PID_LASTPRINTED,&si);

	if (!ret)
	    printf("Last printed on %d/%d/%d %d:%d:%d\n",day,mon,yr,hr,min,sec);
	else
		printf("no last printed time found\n");

	ret = wvSumInfoGetTime(&yr, &mon, &day, &hr, &min, &sec,PID_CREATED,&si);

	if (!ret)
	    printf("Created on %d/%d/%d %d:%d:%d\n",day,mon,yr,hr,min,sec);
	else
		printf("no creation time found\n");

	ret = wvSumInfoGetTime(&yr, &mon, &day, &hr, &min, &sec,PID_LASTSAVED,&si);

	if (!ret)
	    printf("Last Saved on %d/%d/%d %d:%d:%d\n",day,mon,yr,hr,min,sec);
	else
		printf("no lastsaved date found\n");

	ret = wvSumInfoGetLong(&along,PID_PAGECOUNT, &si);

	if (!ret)
	    printf("PageCount is %d\n",along);
	else
		printf("no pagecount\n");

	ret = wvSumInfoGetLong(&along,PID_WORDCOUNT, &si);

	if (!ret)
	    printf("WordCount is %d\n",along);
	else
		printf("no wordcount\n");


	ret = wvSumInfoGetLong(&along,PID_CHARCOUNT, &si);

	if (!ret)
	    printf("CharCount is %d\n",along);
	else
		printf("no charcount\n");

	ret = wvSumInfoGetLong(&along,PID_SECURITY, &si);

	if (!ret)
	    printf("Security is %d\n",along);
	else
		printf("no security\n");

	ret = wvSumInfoGetPreview(szTemp, 256, PID_THUMBNAIL, &si);

	if (!ret)
	    printf("preview is %s\n",szTemp);
	else
		printf("no preview found\n");

	wvReleaseSummaryInfo(&si);

	fclose(s);
	return(ret);
	}