1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef DOCUMENT_STATISTIC_HXX_INCLUDED
25 #define DOCUMENT_STATISTIC_HXX_INCLUDED
26 
27 #include <utility>
28 #include <string>
29 #include <vector>
30 #include "internal/metainforeader.hxx"
31 
32 
33 //------------------------------------
34 //
35 //------------------------------------
36 
37 struct statistic_item
38 {
39     statistic_item();
40 
statistic_itemstatistic_item41     statistic_item(
42         const std::wstring& title,
43         const std::wstring& value,
44         bool editable) :
45         title_(title),
46         value_(value),
47         editable_(editable)
48     {}
49 
50     std::wstring title_;
51     std::wstring value_;
52     bool editable_;
53 };
54 
55 //------------------------------------
56 //
57 //------------------------------------
58 
59 typedef std::vector<statistic_item>                     statistic_item_list_t;
60 typedef std::pair<std::wstring, statistic_item_list_t>  statistic_group_t;
61 typedef std::vector<statistic_group_t>                  statistic_group_list_t;
62 
63 //------------------------------------
64 //
65 //------------------------------------
66 
67 class document_statistic_reader;
68 typedef std::auto_ptr<document_statistic_reader> document_statistic_reader_ptr;
69 
70 document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
71 
72 //------------------------------------
73 //
74 //------------------------------------
75 
76 class document_statistic_reader
77 {
78 public:
79     virtual ~document_statistic_reader();
80 
81     void read(statistic_group_list_t* group_list);
82 
83     std::string get_document_name() const;
84 
85 protected:
86     document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
87 
88     virtual void fill_description_section(CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list) = 0;
89 
90     virtual void fill_origin_section( CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list);
91 
92 private:
93     std::string document_name_;
94 	CMetaInfoReader* meta_info_accessor_;
95 
96     friend document_statistic_reader_ptr create_document_statistic_reader(
97         const std::string& document_name, CMetaInfoReader* meta_info_accessor);
98 };
99 
100 //------------------------------------
101 //
102 //------------------------------------
103 
104 class writer_document_statistic_reader : public document_statistic_reader
105 {
106 protected:
107     writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
108 
109     virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list);
110 
111     friend document_statistic_reader_ptr create_document_statistic_reader(
112         const std::string& document_name, CMetaInfoReader* meta_info_accessor);
113 };
114 
115 //------------------------------------
116 //
117 //------------------------------------
118 
119 class calc_document_statistic_reader : public document_statistic_reader
120 {
121 protected:
122     calc_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
123 
124     virtual void fill_description_section( CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list);
125 
126     friend document_statistic_reader_ptr create_document_statistic_reader(
127         const std::string& document_name, CMetaInfoReader* meta_info_accessor);
128 };
129 
130 //------------------------------------
131 //
132 //------------------------------------
133 
134 class draw_impress_math_document_statistic_reader : public document_statistic_reader
135 {
136 protected:
137     draw_impress_math_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor);
138 
139     virtual void fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list);
140 
141     friend document_statistic_reader_ptr create_document_statistic_reader(
142         const std::string& document_name, CMetaInfoReader* meta_info_accessor);
143 };
144 
145 #endif
146