1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_shell.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifdef _MSC_VER 32*cdf0e10cSrcweir #pragma warning (disable : 4786 4503) 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #include "document_statistic.hxx" 35*cdf0e10cSrcweir #include "internal/utilities.hxx" 36*cdf0e10cSrcweir #include "internal/metainforeader.hxx" 37*cdf0e10cSrcweir #include "internal/resource.h" 38*cdf0e10cSrcweir #include "internal/fileextensions.hxx" 39*cdf0e10cSrcweir #include "internal/config.hxx" 40*cdf0e10cSrcweir #include "internal/iso8601_converter.hxx" 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir //##################################### 43*cdf0e10cSrcweir const bool READONLY = false; 44*cdf0e10cSrcweir const bool WRITEABLE = true; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //##################################### 47*cdf0e10cSrcweir document_statistic_reader_ptr create_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir File_Type_t file_type = get_file_type(document_name); 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir if (WRITER == file_type) 52*cdf0e10cSrcweir return document_statistic_reader_ptr(new writer_document_statistic_reader(document_name, meta_info_accessor)); 53*cdf0e10cSrcweir else if (CALC == file_type) 54*cdf0e10cSrcweir return document_statistic_reader_ptr(new calc_document_statistic_reader(document_name, meta_info_accessor)); 55*cdf0e10cSrcweir else 56*cdf0e10cSrcweir return document_statistic_reader_ptr(new draw_impress_math_document_statistic_reader(document_name, meta_info_accessor)); 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir //##################################### 61*cdf0e10cSrcweir document_statistic_reader::document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) : 62*cdf0e10cSrcweir document_name_(document_name), 63*cdf0e10cSrcweir meta_info_accessor_(meta_info_accessor) 64*cdf0e10cSrcweir {} 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //##################################### 67*cdf0e10cSrcweir document_statistic_reader::~document_statistic_reader() 68*cdf0e10cSrcweir {} 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir //##################################### 71*cdf0e10cSrcweir void document_statistic_reader::read(statistic_group_list_t* group_list) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir group_list->clear(); 74*cdf0e10cSrcweir fill_description_section(meta_info_accessor_, group_list); 75*cdf0e10cSrcweir fill_origin_section(meta_info_accessor_, group_list); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir //##################################### 79*cdf0e10cSrcweir std::string document_statistic_reader::get_document_name() const 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir return document_name_; 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir //##################################### 85*cdf0e10cSrcweir void document_statistic_reader::fill_origin_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir statistic_item_list_t il; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_AUTHOR), meta_info_accessor->getTagData( META_INFO_AUTHOR ), READONLY)); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_MODIFIED), 92*cdf0e10cSrcweir iso8601_date_to_local_date(meta_info_accessor->getTagData(META_INFO_MODIFIED )), READONLY)); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_DOCUMENT_NUMBER), meta_info_accessor->getTagData( META_INFO_DOCUMENT_NUMBER ), READONLY)); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_EDITING_TIME), 97*cdf0e10cSrcweir iso8601_duration_to_local_duration(meta_info_accessor->getTagData( META_INFO_EDITING_TIME )), READONLY)); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir group_list->push_back(statistic_group_t(GetResString(IDS_ORIGIN), il)); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir //##################################### 103*cdf0e10cSrcweir writer_document_statistic_reader::writer_document_statistic_reader(const std::string& document_name, CMetaInfoReader* meta_info_accessor) : 104*cdf0e10cSrcweir document_statistic_reader(document_name, meta_info_accessor) 105*cdf0e10cSrcweir {} 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir //##################################### 108*cdf0e10cSrcweir void writer_document_statistic_reader::fill_description_section(CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir statistic_item_list_t il; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY)); 113*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY)); 114*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY)); 115*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY)); 116*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_PAGES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY)); 117*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY)); 118*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_GRAPHICS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_DRAWS) , READONLY)); 119*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY)); 120*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_PARAGRAPHS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PARAGRAPHS) , READONLY)); 121*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_WORDS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_WORDS) , READONLY)); 122*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_CHARACTERS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CHARACTERS) , READONLY)); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il)); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir //####################################### 128*cdf0e10cSrcweir calc_document_statistic_reader::calc_document_statistic_reader( 129*cdf0e10cSrcweir const std::string& document_name, CMetaInfoReader* meta_info_accessor) : 130*cdf0e10cSrcweir document_statistic_reader(document_name, meta_info_accessor) 131*cdf0e10cSrcweir {} 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir //####################################### 134*cdf0e10cSrcweir void calc_document_statistic_reader::fill_description_section( 135*cdf0e10cSrcweir CMetaInfoReader *meta_info_accessor,statistic_group_list_t* group_list) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir statistic_item_list_t il; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY)); 140*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY)); 141*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY)); 142*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY)); 143*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_TABLES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_TABLES) , READONLY)); 144*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_CELLS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_CELLS) , READONLY)); 145*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY)); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il)); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir //####################################### 151*cdf0e10cSrcweir draw_impress_math_document_statistic_reader::draw_impress_math_document_statistic_reader( 152*cdf0e10cSrcweir const std::string& document_name, CMetaInfoReader* meta_info_accessor) : 153*cdf0e10cSrcweir document_statistic_reader(document_name, meta_info_accessor) 154*cdf0e10cSrcweir {} 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir //####################################### 157*cdf0e10cSrcweir void draw_impress_math_document_statistic_reader::fill_description_section( 158*cdf0e10cSrcweir CMetaInfoReader *meta_info_accessor, statistic_group_list_t* group_list) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir statistic_item_list_t il; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_TITLE), meta_info_accessor->getTagData( META_INFO_TITLE ), READONLY)); 163*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_COMMENTS), meta_info_accessor->getTagData( META_INFO_DESCRIPTION ), READONLY)); 164*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_SUBJECT), meta_info_accessor->getTagData( META_INFO_SUBJECT ), READONLY)); 165*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_KEYWORDS), meta_info_accessor->getTagData(META_INFO_KEYWORDS ), READONLY)); 166*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_PAGES), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_PAGES) , READONLY)); 167*cdf0e10cSrcweir il.push_back(statistic_item(GetResString(IDS_OLE_OBJECTS), meta_info_accessor->getTagAttribute( META_INFO_DOCUMENT_STATISTIC,META_INFO_OBJECTS) , READONLY)); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir group_list->push_back(statistic_group_t(GetResString(IDS_DESCRIPTION), il)); 170*cdf0e10cSrcweir } 171