Debian Codegraph @

shell/source/win32/shlxthandler/propsheets/document_statistic.cxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21 #include "document_statistic.hxx"
22 #include <utilities.hxx>
23 #include <metainforeader.hxx>
24 #include <resource.h>
25 #include <fileextensions.hxx>
26 #include <config.hxx>
27 #include <iso8601_converter.hxx>
28
29 const bool READONLY = false;
30
31 document_statistic_reader_ptr create_document_statistic_reader(const std::wstring& document_name, CMetaInfoReader* meta_info_accessor)
32 {
33 File_Type_t file_type = get_file_type(document_name);
34
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));
39 else
40 return document_statistic_reader_ptr(new draw_impress_math_document_statistic_reader(document_name, meta_info_accessor));
41 }
42
43
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)
47 {}
48
49 document_statistic_reader::~document_statistic_reader()
50 {}
51
52 void document_statistic_reader::read(statistic_group_list_t* group_list)
53 {
54 group_list->clear();
55 fill_description_section(meta_info_accessor_, group_list);
56 fill_origin_section(meta_info_accessor_, group_list);
57 }
58
59 std::wstring document_statistic_reader::get_document_name() const
60 {
61 return document_name_;
62 }
63
64 void document_statistic_reader::fill_origin_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
65 {
66 statistic_item_list_t il;
67
68 il.push_back(statistic_item(GetResString(IDS_AUTHOR), meta_info_accessor->getTagData( META_INFO_AUTHOR ), READONLY));
69
70 il.push_back(statistic_item(GetResString(IDS_MODIFIED),
71 iso8601_date_to_local_date(meta_info_accessor->getTagData(META_INFO_MODIFIED )), READONLY));
72
73 il.push_back(statistic_item(GetResString(IDS_DOCUMENT_NUMBER), meta_info_accessor->getTagData( META_INFO_DOCUMENT_NUMBER ), READONLY));
74
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));
77
78 group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il));
79 }
80
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)
83 {}
84
85 void writer_document_statistic_reader::fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
86 {
87 statistic_item_list_t il;
88
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));
100
101 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
102 }
103
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)
107 {}
108
109 void calc_document_statistic_reader::fill_description_section(
110 CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list)
111 {
112 statistic_item_list_t il;
113
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));
121
122 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
123 }
124
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)
128 {}
129
130 void draw_impress_math_document_statistic_reader::fill_description_section(
131 CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
132 {
133 statistic_item_list_t il;
134
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));
141
142 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
143 }
144
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */