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