1*f8e2c85aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f8e2c85aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e2c85aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e2c85aSAndrew Rist  * distributed with this work for additional information
6*f8e2c85aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e2c85aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e2c85aSAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e2c85aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f8e2c85aSAndrew Rist  *
11*f8e2c85aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f8e2c85aSAndrew Rist  *
13*f8e2c85aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e2c85aSAndrew Rist  * software distributed under the License is distributed on an
15*f8e2c85aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e2c85aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e2c85aSAndrew Rist  * specific language governing permissions and limitations
18*f8e2c85aSAndrew Rist  * under the License.
19*f8e2c85aSAndrew Rist  *
20*f8e2c85aSAndrew Rist  *************************************************************/
21*f8e2c85aSAndrew Rist 
22*f8e2c85aSAndrew 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 
38cdf0e10cSrcweir //#####################################
39cdf0e10cSrcweir const bool READONLY  = false;
40cdf0e10cSrcweir const bool WRITEABLE = true;
41cdf0e10cSrcweir 
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 {
45cdf0e10cSrcweir     File_Type_t file_type = get_file_type(document_name);
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	if (WRITER == file_type)
48cdf0e10cSrcweir 	    return document_statistic_reader_ptr(new writer_document_statistic_reader(document_name, meta_info_accessor));
49cdf0e10cSrcweir 	else if (CALC == file_type)
50cdf0e10cSrcweir 	    return document_statistic_reader_ptr(new calc_document_statistic_reader(document_name, meta_info_accessor));
51cdf0e10cSrcweir 	else
52cdf0e10cSrcweir 	    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) :
58cdf0e10cSrcweir     document_name_(document_name),
59cdf0e10cSrcweir     meta_info_accessor_(meta_info_accessor)
60cdf0e10cSrcweir {}
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //#####################################
~document_statistic_reader()63cdf0e10cSrcweir 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 {
69cdf0e10cSrcweir 	group_list->clear();
70cdf0e10cSrcweir     fill_description_section(meta_info_accessor_, group_list);
71cdf0e10cSrcweir     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 {
77cdf0e10cSrcweir     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 {
83cdf0e10cSrcweir     statistic_item_list_t il;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_AUTHOR), meta_info_accessor->getTagData( META_INFO_AUTHOR ), READONLY));
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_MODIFIED),
88cdf0e10cSrcweir         iso8601_date_to_local_date(meta_info_accessor->getTagData(META_INFO_MODIFIED )), READONLY));
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_DOCUMENT_NUMBER), meta_info_accessor->getTagData( META_INFO_DOCUMENT_NUMBER ), READONLY));
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_EDITING_TIME),
93cdf0e10cSrcweir         iso8601_duration_to_local_duration(meta_info_accessor->getTagData( META_INFO_EDITING_TIME )), READONLY));
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il));
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
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) :
100cdf0e10cSrcweir     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 {
106cdf0e10cSrcweir     statistic_item_list_t il;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_TITLE),    meta_info_accessor->getTagData( META_INFO_TITLE ),       READONLY));
109cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
110cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_SUBJECT),  meta_info_accessor->getTagData( META_INFO_SUBJECT ),     READONLY));
111cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ),    READONLY));
112cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_PAGES),    meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY));
113cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY));
114cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_GRAPHICS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_DRAWS) , READONLY));
115cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) ,    READONLY));
116cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_PARAGRAPHS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PARAGRAPHS) , READONLY));
117cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_WORDS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_WORDS) , READONLY));
118cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_CHARACTERS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CHARACTERS) , READONLY));
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir //#######################################
calc_document_statistic_reader(const std::string & document_name,CMetaInfoReader * meta_info_accessor)124cdf0e10cSrcweir calc_document_statistic_reader::calc_document_statistic_reader(
125cdf0e10cSrcweir     const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
126cdf0e10cSrcweir     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(
131cdf0e10cSrcweir     CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     statistic_item_list_t il;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_TITLE),       meta_info_accessor->getTagData( META_INFO_TITLE ),       READONLY));
136cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_COMMENTS),    meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
137cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_SUBJECT),     meta_info_accessor->getTagData( META_INFO_SUBJECT ),     READONLY));
138cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_KEYWORDS),    meta_info_accessor->getTagData(META_INFO_KEYWORDS ),    READONLY));
139cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_TABLES),      meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) ,  READONLY));
140cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_CELLS),       meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CELLS) ,   READONLY));
141cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     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(
148cdf0e10cSrcweir     const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
149cdf0e10cSrcweir     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(
154cdf0e10cSrcweir     CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     statistic_item_list_t il;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_TITLE),       meta_info_accessor->getTagData( META_INFO_TITLE ),       READONLY));
159cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_COMMENTS),    meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
160cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_SUBJECT),     meta_info_accessor->getTagData( META_INFO_SUBJECT ),     READONLY));
161cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_KEYWORDS),    meta_info_accessor->getTagData(META_INFO_KEYWORDS ),    READONLY));
162cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_PAGES),       meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) ,   READONLY));
163cdf0e10cSrcweir     il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
166cdf0e10cSrcweir }
167