Bump version to 5.0-14
[LibreOffice.git] / shell / source / win32 / shlxthandler / propsheets / document_statistic.cxx
blob2b00713e3641ad9c7ce34df62003cd77b1185857
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifdef _MSC_VER
22 #pragma warning (disable : 4786 4503)
23 #endif
24 #include "document_statistic.hxx"
25 #include "internal/utilities.hxx"
26 #include "internal/metainforeader.hxx"
27 #include "internal/resource.h"
28 #include "internal/fileextensions.hxx"
29 #include "internal/config.hxx"
30 #include "internal/iso8601_converter.hxx"
32 const bool READONLY = false;
33 const bool WRITEABLE = true;
35 document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor)
37 File_Type_t file_type = get_file_type(document_name);
39 if (WRITER == file_type)
40 return document_statistic_reader_ptr(new writer_document_statistic_reader(document_name, meta_info_accessor));
41 else if (CALC == file_type)
42 return document_statistic_reader_ptr(new calc_document_statistic_reader(document_name, meta_info_accessor));
43 else
44 return document_statistic_reader_ptr(new draw_impress_math_document_statistic_reader(document_name, meta_info_accessor));
48 document_statistic_reader::document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
49 document_name_(document_name),
50 meta_info_accessor_(meta_info_accessor)
53 document_statistic_reader::~document_statistic_reader()
56 void document_statistic_reader::read(statistic_group_list_t* group_list)
58 group_list->clear();
59 fill_description_section(meta_info_accessor_, group_list);
60 fill_origin_section(meta_info_accessor_, group_list);
63 std::string document_statistic_reader::get_document_name() const
65 return document_name_;
68 void document_statistic_reader::fill_origin_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
70 statistic_item_list_t il;
72 il.push_back(statistic_item(GetResString(IDS_AUTHOR), meta_info_accessor->getTagData( META_INFO_AUTHOR ), READONLY));
74 il.push_back(statistic_item(GetResString(IDS_MODIFIED),
75 iso8601_date_to_local_date(meta_info_accessor->getTagData(META_INFO_MODIFIED )), READONLY));
77 il.push_back(statistic_item(GetResString(IDS_DOCUMENT_NUMBER), meta_info_accessor->getTagData( META_INFO_DOCUMENT_NUMBER ), READONLY));
79 il.push_back(statistic_item(GetResString(IDS_EDITING_TIME),
80 iso8601_duration_to_local_duration(meta_info_accessor->getTagData( META_INFO_EDITING_TIME )), READONLY));
82 group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il));
85 writer_document_statistic_reader::writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
86 document_statistic_reader(document_name, meta_info_accessor)
89 void writer_document_statistic_reader::fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
91 statistic_item_list_t il;
93 il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY));
94 il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
95 il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY));
96 il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY));
97 il.push_back(statistic_item(GetResString(IDS_PAGES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY));
98 il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY));
99 il.push_back(statistic_item(GetResString(IDS_GRAPHICS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_DRAWS) , READONLY));
100 il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
101 il.push_back(statistic_item(GetResString(IDS_PARAGRAPHS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PARAGRAPHS) , READONLY));
102 il.push_back(statistic_item(GetResString(IDS_WORDS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_WORDS) , READONLY));
103 il.push_back(statistic_item(GetResString(IDS_CHARACTERS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CHARACTERS) , READONLY));
105 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
108 calc_document_statistic_reader::calc_document_statistic_reader(
109 const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
110 document_statistic_reader(document_name, meta_info_accessor)
113 void calc_document_statistic_reader::fill_description_section(
114 CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list)
116 statistic_item_list_t il;
118 il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY));
119 il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
120 il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY));
121 il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY));
122 il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY));
123 il.push_back(statistic_item(GetResString(IDS_CELLS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CELLS) , READONLY));
124 il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
126 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
129 draw_impress_math_document_statistic_reader::draw_impress_math_document_statistic_reader(
130 const std::string& document_name, CMetaInfoReader* meta_info_accessor) :
131 document_statistic_reader(document_name, meta_info_accessor)
134 void draw_impress_math_document_statistic_reader::fill_description_section(
135 CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
137 statistic_item_list_t il;
139 il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY));
140 il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY));
141 il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY));
142 il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY));
143 il.push_back(statistic_item(GetResString(IDS_PAGES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY));
144 il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY));
146 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */