filters

workbook.cpp

00001 /* Swinder - Portable library for spreadsheet 
00002    Copyright (C) 2003 Ariya Hidayat <ariya@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008    
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA
00018 */
00019 
00020 #include "workbook.h"
00021 #include "sheet.h"
00022 #include "excel.h"
00023 
00024 #include <iostream>
00025 #include <vector>
00026 
00027 using namespace Swinder;
00028 
00029 class Workbook::Private
00030 {
00031 public:
00032   std::vector<Sheet*> sheets;
00033   bool autoCalc;
00034   bool passwordProtected;
00035 };
00036 
00037 Workbook::Workbook()
00038 {
00039   d = new Workbook::Private();
00040   d->autoCalc = true;
00041   d->passwordProtected = false;
00042 }
00043 
00044 Workbook::~Workbook()
00045 {
00046   clear();
00047   delete d;
00048 }
00049 
00050 void Workbook::clear()
00051 {
00052   // FIXME use iterator
00053   for( unsigned i=0; i<sheetCount(); i++ )
00054   {
00055     Sheet* s = sheet( i );
00056     delete s;
00057     }
00058   d->sheets.clear();
00059 }
00060 
00061 bool Workbook::load( const char* filename )
00062 {
00063   ExcelReader* reader = new ExcelReader;
00064   bool result = reader->load( this, filename );
00065   delete reader;
00066   return result;
00067 }
00068 
00069 void Workbook::appendSheet( Sheet* sheet )
00070 {
00071   d->sheets.push_back( sheet );
00072 }
00073 
00074 unsigned Workbook::sheetCount() const
00075 {
00076   return d->sheets.size();
00077 }
00078 
00079 Sheet* Workbook::sheet( unsigned index )
00080 {
00081   if( index >= sheetCount() ) return (Sheet*)0;
00082   return d->sheets[index];
00083 }
00084 
00085 bool Workbook::autoCalc() const
00086 {
00087   return d->autoCalc;
00088 }
00089 
00090 void Workbook::setAutoCalc( bool a )
00091 {
00092   d->autoCalc = a;
00093 }
00094 
00095 bool Workbook::isPasswordProtected() const
00096 {
00097   return d->passwordProtected;
00098 }
00099 
00100 void Workbook::setPasswordProtected( bool p )
00101 {
00102   d->passwordProtected = p;
00103 }
00104 
00105 
00106 
00107 
KDE Home | KDE Accessibility Home | Description of Access Keys