LibreOffice Module shell (master) 1
document_statistic.cxx
Go to the documentation of this file.
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
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
29const bool READONLY = false;
30
31document_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
44document_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
50{}
51
53{
54 group_list->clear();
57}
58
60{
61 return document_name_;
62}
63
65{
67
68 il.push_back(statistic_item(GetResString(IDS_AUTHOR), meta_info_accessor->getTagData( META_INFO_AUTHOR ), READONLY));
69
72
74
77
78 group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il));
79}
81writer_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
86{
88
89 il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), 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));
100
101 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
102}
103
105 const std::wstring& document_name, CMetaInfoReader* meta_info_accessor) :
106 document_statistic_reader(document_name, meta_info_accessor)
107{}
108
110 CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list)
111{
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));
121
122 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
123}
124
126 const std::wstring& document_name, CMetaInfoReader* meta_info_accessor) :
127 document_statistic_reader(document_name, meta_info_accessor)
128{}
129
131 CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list)
132{
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));
141
142 group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il));
143}
144
145/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::wstring getTagData(const std::wstring &TagName)
Get a specific tag content, compound tags will be returned as comma separated list.
std::wstring getTagAttribute(const std::wstring &TagName, const std::wstring &AttributeName)
Get a specific attribute content.
virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t *group_list) override
calc_document_statistic_reader(const std::wstring &document_name, CMetaInfoReader *meta_info_accessor)
void read(statistic_group_list_t *group_list)
std::wstring get_document_name() const
document_statistic_reader(const std::wstring &document_name, CMetaInfoReader *meta_info_accessor)
CMetaInfoReader * meta_info_accessor_
virtual void fill_origin_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t *group_list)
virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t *group_list)=0
virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t *group_list) override
draw_impress_math_document_statistic_reader(const std::wstring &document_name, CMetaInfoReader *meta_info_accessor)
virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t *group_list) override
writer_document_statistic_reader(const std::wstring &document_name, CMetaInfoReader *meta_info_accessor)
#define META_INFO_CELLS
Definition: config.hxx:48
#define META_INFO_AUTHOR
Definition: config.hxx:35
#define META_INFO_DRAWS
Definition: config.hxx:43
#define META_INFO_MODIFIED
Definition: config.hxx:50
#define META_INFO_CHARACTERS
Definition: config.hxx:47
#define META_INFO_OBJECTS
Definition: config.hxx:44
#define META_INFO_WORDS
Definition: config.hxx:46
#define META_INFO_DOCUMENT_NUMBER
Definition: config.hxx:51
#define META_INFO_EDITING_TIME
Definition: config.hxx:52
#define META_INFO_DOCUMENT_STATISTIC
Definition: config.hxx:49
#define META_INFO_SUBJECT
Definition: config.hxx:36
#define META_INFO_PARAGRAPHS
Definition: config.hxx:45
#define META_INFO_KEYWORDS
Definition: config.hxx:37
#define META_INFO_TITLE
Definition: config.hxx:34
#define META_INFO_DESCRIPTION
Definition: config.hxx:39
#define META_INFO_TABLES
Definition: config.hxx:42
#define META_INFO_PAGES
Definition: config.hxx:41
const bool READONLY
document_statistic_reader_ptr create_document_statistic_reader(const std::wstring &document_name, CMetaInfoReader *meta_info_accessor)
std::unique_ptr< document_statistic_reader > document_statistic_reader_ptr
std::vector< statistic_item > statistic_item_list_t
std::vector< statistic_group_t > statistic_group_list_t
std::pair< std::wstring, statistic_item_list_t > statistic_group_t
File_Type_t get_file_type(const Filepath_t &file_name)
Return the type of a file.
File_Type_t
Return the type of a file.
@ WRITER
@ CALC
std::wstring iso8601_duration_to_local_duration(const std::wstring &iso8601duration)
std::wstring iso8601_date_to_local_date(const std::wstring &isoDate)
#define IDS_COMMENTS
Definition: resource.h:38
#define IDS_PARAGRAPHS
Definition: resource.h:43
#define IDS_MODIFIED
Definition: resource.h:59
#define IDS_SUBJECT
Definition: resource.h:35
#define IDS_GRAPHICS
Definition: resource.h:41
#define IDS_DESCRIPTION
Definition: resource.h:62
#define IDS_WORDS
Definition: resource.h:44
#define IDS_PAGES
Definition: resource.h:39
#define IDS_TITLE
Definition: resource.h:34
#define IDS_TABLES
Definition: resource.h:40
#define IDS_CHARACTERS
Definition: resource.h:45
#define IDS_ORIGIN
Definition: resource.h:47
#define IDS_DOCUMENT_NUMBER
Definition: resource.h:60
#define IDS_EDITING_TIME
Definition: resource.h:61
#define IDS_CELLS
Definition: resource.h:50
#define IDS_KEYWORDS
Definition: resource.h:37
#define IDS_OLE_OBJECTS
Definition: resource.h:42
#define IDS_AUTHOR
Definition: resource.h:36
std::wstring GetResString(int ResId)
Retrieve a string from the resources of this module.
Definition: utilities.cxx:81