1f8e2c85aSAndrew Rist /**************************************************************
2*b6a5f44bSmseidel  *
3f8e2c85aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e2c85aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e2c85aSAndrew Rist  * distributed with this work for additional information
6f8e2c85aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e2c85aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e2c85aSAndrew Rist  * "License"); you may not use this file except in compliance
9f8e2c85aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b6a5f44bSmseidel  *
11f8e2c85aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b6a5f44bSmseidel  *
13f8e2c85aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e2c85aSAndrew Rist  * software distributed under the License is distributed on an
15f8e2c85aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e2c85aSAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e2c85aSAndrew Rist  * specific language governing permissions and limitations
18f8e2c85aSAndrew Rist  * under the License.
19*b6a5f44bSmseidel  *
20f8e2c85aSAndrew Rist  *************************************************************/
21f8e2c85aSAndrew Rist 
22f8e2c85aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_shell.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef _MSC_VER
28cdf0e10cSrcweir #pragma warning (disable : 4786 4503)
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include "document_statistic.hxx"
31cdf0e10cSrcweir #include "internal/utilities.hxx"
32cdf0e10cSrcweir #include "internal/metainforeader.hxx"
33cdf0e10cSrcweir #include "internal/resource.h"
34cdf0e10cSrcweir #include "internal/fileextensions.hxx"
35cdf0e10cSrcweir #include "internal/config.hxx"
36cdf0e10cSrcweir #include "internal/iso8601_converter.hxx"
37cdf0e10cSrcweir 
38*b6a5f44bSmseidel //#####################################
39cdf0e10cSrcweir const bool READONLY  = false;
40cdf0e10cSrcweir const bool WRITEABLE = true;
41*b6a5f44bSmseidel 
42cdf0e10cSrcweir //#####################################
create_document_statistic_reader(const std::string & document_name,CMetaInfoReader * meta_info_accessor)43cdf0e10cSrcweir document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor)
44cdf0e10cSrcweir {
45*b6a5f44bSmseidel 	File_Type_t file_type = get_file_type(document_name);
46*b6a5f44bSmseidel 
47cdf0e10cSrcweir 	if (WRITER == file_type)
48*b6a5f44bSmseidel 		return document_statistic_reader_ptr(new writer_document_statistic_reader(document_name, meta_info_accessor));
49cdf0e10cSrcweir 	else if (CALC == file_type)
50*b6a5f44bSmseidel 		return document_statistic_reader_ptr(new calc_document_statistic_reader(document_name, meta_info_accessor));
51cdf0e10cSrcweir 	else
52*b6a5f44bSmseidel 		return document_statistic_reader_ptr(new draw_impress_math_document_statistic_reader(document_name, meta_info_accessor));
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //#####################################
document_statistic_reader(const std::string & document_name,CMetaInfoReader * meta_info_accessor)57cdf0e10cSrcweir document_statistic_reader::document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
58*b6a5f44bSmseidel 	document_name_(document_name),
59*b6a5f44bSmseidel 	meta_info_accessor_(meta_info_accessor)
60cdf0e10cSrcweir {}
61cdf0e10cSrcweir 
62*b6a5f44bSmseidel //#####################################
~document_statistic_reader()63*b6a5f44bSmseidel document_statistic_reader::~document_statistic_reader()
64cdf0e10cSrcweir {}
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //#####################################
read(statistic_group_list_t * group_list)67cdf0e10cSrcweir void document_statistic_reader::read(statistic_group_list_t* group_list)
68cdf0e10cSrcweir {
69*b6a5f44bSmseidel 	group_list->clear();
70*b6a5f44bSmseidel 	fill_description_section(meta_info_accessor_, group_list);
71*b6a5f44bSmseidel 	fill_origin_section(meta_info_accessor_, group_list);
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //#####################################
get_document_name() const75cdf0e10cSrcweir std::string document_statistic_reader::get_document_name() const
76cdf0e10cSrcweir {
77*b6a5f44bSmseidel 	return document_name_;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //#####################################
fill_origin_section(CMetaInfoReader * meta_info_accessor,statistic_group_list_t * group_list)81cdf0e10cSrcweir void document_statistic_reader::fill_origin_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
82cdf0e10cSrcweir {
83*b6a5f44bSmseidel 	statistic_item_list_t il;
84*b6a5f44bSmseidel 
85*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_AUTHOR), meta_info_accessor->getTagData( META_INFO_AUTHOR ), READONLY));
86*b6a5f44bSmseidel 
87*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_MODIFIED),
88*b6a5f44bSmseidel 		iso8601_date_to_local_date(meta_info_accessor->getTagData(META_INFO_MODIFIED )), READONLY));
89*b6a5f44bSmseidel 
90*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_DOCUMENT_NUMBER), meta_info_accessor->getTagData( META_INFO_DOCUMENT_NUMBER ), READONLY));
91*b6a5f44bSmseidel 
92*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_EDITING_TIME),
93*b6a5f44bSmseidel 		iso8601_duration_to_local_duration(meta_info_accessor->getTagData( META_INFO_EDITING_TIME )), READONLY));
94*b6a5f44bSmseidel 
95*b6a5f44bSmseidel 	group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il));
96cdf0e10cSrcweir }
97*b6a5f44bSmseidel 
98cdf0e10cSrcweir //#####################################
writer_document_statistic_reader(const std::string & document_name,CMetaInfoReader * meta_info_accessor)99cdf0e10cSrcweir writer_document_statistic_reader::writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
100*b6a5f44bSmseidel 	document_statistic_reader(document_name, meta_info_accessor)
101cdf0e10cSrcweir {}
102cdf0e10cSrcweir 
103cdf0e10cSrcweir //#####################################
fill_description_section(CMetaInfoReader * meta_info_accessor,statistic_group_list_t * group_list)104cdf0e10cSrcweir void writer_document_statistic_reader::fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
105cdf0e10cSrcweir {
106*b6a5f44bSmseidel 	statistic_item_list_t il;
107*b6a5f44bSmseidel 
108*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_TITLE),    meta_info_accessor->getTagData( META_INFO_TITLE ),       READONLY));
109*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
110*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_SUBJECT),  meta_info_accessor->getTagData( META_INFO_SUBJECT ),     READONLY));
111*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ),    READONLY));
112*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_PAGES),    meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY));
113*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY));
114*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_GRAPHICS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_DRAWS) , READONLY));
115*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) ,    READONLY));
116*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_PARAGRAPHS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PARAGRAPHS) , READONLY));
117*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_WORDS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_WORDS) , READONLY));
118*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_CHARACTERS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CHARACTERS) , READONLY));
119*b6a5f44bSmseidel 
120*b6a5f44bSmseidel 	group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
121cdf0e10cSrcweir }
122*b6a5f44bSmseidel 
123cdf0e10cSrcweir //#######################################
calc_document_statistic_reader(const std::string & document_name,CMetaInfoReader * meta_info_accessor)124cdf0e10cSrcweir calc_document_statistic_reader::calc_document_statistic_reader(
125*b6a5f44bSmseidel 	const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
126*b6a5f44bSmseidel 	document_statistic_reader(document_name, meta_info_accessor)
127cdf0e10cSrcweir {}
128cdf0e10cSrcweir 
129cdf0e10cSrcweir //#######################################
fill_description_section(CMetaInfoReader * meta_info_accessor,statistic_group_list_t * group_list)130cdf0e10cSrcweir void calc_document_statistic_reader::fill_description_section(
131*b6a5f44bSmseidel 	CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list)
132cdf0e10cSrcweir {
133*b6a5f44bSmseidel 	statistic_item_list_t il;
134*b6a5f44bSmseidel 
135*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_TITLE),       meta_info_accessor->getTagData( META_INFO_TITLE ),       READONLY));
136*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_COMMENTS),    meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
137*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_SUBJECT),     meta_info_accessor->getTagData( META_INFO_SUBJECT ),     READONLY));
138*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_KEYWORDS),    meta_info_accessor->getTagData(META_INFO_KEYWORDS ),    READONLY));
139*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_TABLES),      meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) ,  READONLY));
140*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_CELLS),       meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CELLS) ,   READONLY));
141*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
142*b6a5f44bSmseidel 
143*b6a5f44bSmseidel 	group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir //#######################################
draw_impress_math_document_statistic_reader(const std::string & document_name,CMetaInfoReader * meta_info_accessor)147cdf0e10cSrcweir draw_impress_math_document_statistic_reader::draw_impress_math_document_statistic_reader(
148*b6a5f44bSmseidel 	const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
149*b6a5f44bSmseidel 	document_statistic_reader(document_name, meta_info_accessor)
150cdf0e10cSrcweir {}
151cdf0e10cSrcweir 
152cdf0e10cSrcweir //#######################################
fill_description_section(CMetaInfoReader * meta_info_accessor,statistic_group_list_t * group_list)153cdf0e10cSrcweir void draw_impress_math_document_statistic_reader::fill_description_section(
154*b6a5f44bSmseidel 	CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
155cdf0e10cSrcweir {
156*b6a5f44bSmseidel 	statistic_item_list_t il;
157*b6a5f44bSmseidel 
158*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_TITLE),       meta_info_accessor->getTagData( META_INFO_TITLE ),       READONLY));
159*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_COMMENTS),    meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
160*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_SUBJECT),     meta_info_accessor->getTagData( META_INFO_SUBJECT ),     READONLY));
161*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_KEYWORDS),    meta_info_accessor->getTagData(META_INFO_KEYWORDS ),    READONLY));
162*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_PAGES),       meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) ,   READONLY));
163*b6a5f44bSmseidel 	il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
164*b6a5f44bSmseidel 
165*b6a5f44bSmseidel 	group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
166cdf0e10cSrcweir }
167*b6a5f44bSmseidel 
168*b6a5f44bSmseidel /* vim: set noet sw=4 ts=4: */
169