1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "document_statistic.hxx"
22 #include <utilities.hxx>
23 #include <metainforeader.hxx>
25 #include <fileextensions.hxx>
27 #include <iso8601_converter.hxx>
29 const bool READONLY
= false;
31 document_statistic_reader_ptr
create_document_statistic_reader(const std::wstring
& document_name
, CMetaInfoReader
* meta_info_accessor
)
33 File_Type_t file_type
= get_file_type(document_name
);
35 if (WRITER
== file_type
)
36 return document_statistic_reader_ptr(new writer_document_statistic_reader(document_name
, meta_info_accessor
));
37 else if (CALC
== file_type
)
38 return document_statistic_reader_ptr(new calc_document_statistic_reader(document_name
, meta_info_accessor
));
40 return document_statistic_reader_ptr(new draw_impress_math_document_statistic_reader(document_name
, meta_info_accessor
));
44 document_statistic_reader::document_statistic_reader(const std::wstring
& document_name
, CMetaInfoReader
* meta_info_accessor
) :
45 document_name_(document_name
),
46 meta_info_accessor_(meta_info_accessor
)
49 document_statistic_reader::~document_statistic_reader()
52 void document_statistic_reader::read(statistic_group_list_t
* group_list
)
55 fill_description_section(meta_info_accessor_
, group_list
);
56 fill_origin_section(meta_info_accessor_
, group_list
);
59 std::wstring
document_statistic_reader::get_document_name() const
61 return document_name_
;
64 void document_statistic_reader::fill_origin_section(CMetaInfoReader
*meta_info_accessor
, statistic_group_list_t
* group_list
)
66 statistic_item_list_t il
;
68 il
.push_back(statistic_item(GetResString(IDS_AUTHOR
), meta_info_accessor
->getTagData( META_INFO_AUTHOR
), READONLY
));
70 il
.push_back(statistic_item(GetResString(IDS_MODIFIED
),
71 iso8601_date_to_local_date(meta_info_accessor
->getTagData(META_INFO_MODIFIED
)), READONLY
));
73 il
.push_back(statistic_item(GetResString(IDS_DOCUMENT_NUMBER
), meta_info_accessor
->getTagData( META_INFO_DOCUMENT_NUMBER
), READONLY
));
75 il
.push_back(statistic_item(GetResString(IDS_EDITING_TIME
),
76 iso8601_duration_to_local_duration(meta_info_accessor
->getTagData( META_INFO_EDITING_TIME
)), READONLY
));
78 group_list
->push_back(statistic_group_t(GetResString(IDS_ORIGIN
), il
));
81 writer_document_statistic_reader::writer_document_statistic_reader(const std::wstring
& document_name
, CMetaInfoReader
* meta_info_accessor
) :
82 document_statistic_reader(document_name
, meta_info_accessor
)
85 void writer_document_statistic_reader::fill_description_section(CMetaInfoReader
*meta_info_accessor
, statistic_group_list_t
* group_list
)
87 statistic_item_list_t il
;
89 il
.push_back(statistic_item(GetResString(IDS_TITLE
), meta_info_accessor
->getTagData( META_INFO_TITLE
), READONLY
));
90 il
.push_back(statistic_item(GetResString(IDS_COMMENTS
), meta_info_accessor
->getTagData( META_INFO_DESCRIPTION
), READONLY
));
91 il
.push_back(statistic_item(GetResString(IDS_SUBJECT
), meta_info_accessor
->getTagData( META_INFO_SUBJECT
), READONLY
));
92 il
.push_back(statistic_item(GetResString(IDS_KEYWORDS
), meta_info_accessor
->getTagData(META_INFO_KEYWORDS
), READONLY
));
93 il
.push_back(statistic_item(GetResString(IDS_PAGES
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_PAGES
) , READONLY
));
94 il
.push_back(statistic_item(GetResString(IDS_TABLES
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_TABLES
) , READONLY
));
95 il
.push_back(statistic_item(GetResString(IDS_GRAPHICS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_DRAWS
) , READONLY
));
96 il
.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_OBJECTS
) , READONLY
));
97 il
.push_back(statistic_item(GetResString(IDS_PARAGRAPHS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_PARAGRAPHS
) , READONLY
));
98 il
.push_back(statistic_item(GetResString(IDS_WORDS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_WORDS
) , READONLY
));
99 il
.push_back(statistic_item(GetResString(IDS_CHARACTERS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_CHARACTERS
) , READONLY
));
101 group_list
->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION
), il
));
104 calc_document_statistic_reader::calc_document_statistic_reader(
105 const std::wstring
& document_name
, CMetaInfoReader
* meta_info_accessor
) :
106 document_statistic_reader(document_name
, meta_info_accessor
)
109 void calc_document_statistic_reader::fill_description_section(
110 CMetaInfoReader
*meta_info_accessor
,statistic_group_list_t
* group_list
)
112 statistic_item_list_t il
;
114 il
.push_back(statistic_item(GetResString(IDS_TITLE
), meta_info_accessor
->getTagData( META_INFO_TITLE
), READONLY
));
115 il
.push_back(statistic_item(GetResString(IDS_COMMENTS
), meta_info_accessor
->getTagData( META_INFO_DESCRIPTION
), READONLY
));
116 il
.push_back(statistic_item(GetResString(IDS_SUBJECT
), meta_info_accessor
->getTagData( META_INFO_SUBJECT
), READONLY
));
117 il
.push_back(statistic_item(GetResString(IDS_KEYWORDS
), meta_info_accessor
->getTagData(META_INFO_KEYWORDS
), READONLY
));
118 il
.push_back(statistic_item(GetResString(IDS_TABLES
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_TABLES
) , READONLY
));
119 il
.push_back(statistic_item(GetResString(IDS_CELLS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_CELLS
) , READONLY
));
120 il
.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_OBJECTS
) , READONLY
));
122 group_list
->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION
), il
));
125 draw_impress_math_document_statistic_reader::draw_impress_math_document_statistic_reader(
126 const std::wstring
& document_name
, CMetaInfoReader
* meta_info_accessor
) :
127 document_statistic_reader(document_name
, meta_info_accessor
)
130 void draw_impress_math_document_statistic_reader::fill_description_section(
131 CMetaInfoReader
*meta_info_accessor
, statistic_group_list_t
* group_list
)
133 statistic_item_list_t il
;
135 il
.push_back(statistic_item(GetResString(IDS_TITLE
), meta_info_accessor
->getTagData( META_INFO_TITLE
), READONLY
));
136 il
.push_back(statistic_item(GetResString(IDS_COMMENTS
), meta_info_accessor
->getTagData( META_INFO_DESCRIPTION
), READONLY
));
137 il
.push_back(statistic_item(GetResString(IDS_SUBJECT
), meta_info_accessor
->getTagData( META_INFO_SUBJECT
), READONLY
));
138 il
.push_back(statistic_item(GetResString(IDS_KEYWORDS
), meta_info_accessor
->getTagData(META_INFO_KEYWORDS
), READONLY
));
139 il
.push_back(statistic_item(GetResString(IDS_PAGES
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_PAGES
) , READONLY
));
140 il
.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS
), meta_info_accessor
->getTagAttribute( META_INFO_DOCUMENT_STATISTIC
,META_INFO_OBJECTS
) , READONLY
));
142 group_list
->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION
), il
));
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */