filters

sheet.h

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 #ifndef SWINDER_SHEET_H
00021 #define SWINDER_SHEET_H
00022 
00023 #include "ustring.h"
00024 #include "format.h"
00025 
00026 namespace Swinder
00027 {
00028 
00029 class Workbook;
00030 class Cell;
00031 class Column;
00032 class Row;
00033 
00034 class Sheet
00035 {
00036 public:
00037 
00038   Sheet( Workbook* workbook );
00039 
00040   virtual ~Sheet();
00041 
00042   // get workbook that owns this sheet
00043   Workbook* workbook();
00044 
00045   /*
00046    * Clears the sheet, i.e. makes it as if it is just constructed.
00047    */
00048   void clear(); 
00049   
00050   void setName( const UString& name );
00051 
00052   UString name() const;
00053 
00054   // return cell at specified column and row
00055   // automatically create the cell if previously there is no cell there
00056   // return NULL if no cell there _and_ autoCreate is false
00057   Cell* cell( unsigned column, unsigned row, bool autoCreate = true );
00058 
00059   Column* column( unsigned index, bool autoCreate = true );
00060 
00061   Row* row( unsigned index, bool autoCreate = true );
00062 
00063   bool visible() const;
00064   void setVisible( bool v );
00065 
00066   bool protect() const;
00067   void setProtect( bool p );
00068 
00069   /*
00070    *   &P  current page number
00071    *   &D  current date
00072    *   &T  current time
00073    *   &A  sheet name
00074    *   &F  file name without path
00075    *   &Z  file path without file name
00076    *   &G  picture
00077    *   &B  bold on/off
00078    *   &I  italic on/off
00079    *   &U  underlining on/off
00080    *   &E  double underlining on/off
00081    *   &S  strikeout on/off
00082    *   &X  superscript on/off
00083    *   &Y  subscript on/off
00084    *
00085    *   &"<fontname>"  set font name
00086    *   &"<fontname>,<fontstyle>" set font name and style
00087    *   &<fontheight>  set font height
00088 
00089    */
00090 
00091   UString leftHeader() const;
00092   void setLeftHeader( const UString& h );
00093   UString centerHeader() const;
00094   void setCenterHeader( const UString& h );
00095   UString rightHeader() const;
00096   void setRightHeader( const UString& h );
00097 
00098   UString leftFooter() const;
00099   void setLeftFooter( const UString& f );
00100   UString centerFooter() const;
00101   void setCenterFooter( const UString& f );
00102   UString rightFooter() const;
00103   void setRightFooter( const UString& f );
00104 
00105   // left margin, in points (pt)
00106   double leftMargin() const;
00107   void setLeftMargin( double m );
00108 
00109   // right margin, in points (pt)
00110   double rightMargin() const;
00111   void setRightMargin( double m );
00112 
00113   // top margin, in points (pt)
00114   double topMargin() const;
00115   void setTopMargin( double m );
00116   
00117   // bottom margin, in points (pt)
00118   double bottomMargin() const;
00119   void setBottomMargin( double m );
00120 
00121   unsigned maxRow() const;
00122   unsigned maxColumn() const;
00123 
00124 private:
00125   // no copy or assign
00126   Sheet( const Sheet& );
00127   Sheet& operator=( const Sheet& );
00128   
00129   class Private;
00130   Private *d;  
00131 };
00132 
00133 class Column
00134 {
00135 public:
00136 
00137   Column( Sheet* sheet, unsigned index );
00138   
00139   virtual ~Column();
00140   
00141   Sheet* sheet() const;
00142   
00143   unsigned index() const;
00144   
00145   // width of column, in pt
00146   double width() const;
00147   
00148   // set the width of column, in pt
00149   void setWidth( double w );
00150   
00151   const Format& format() const;
00152   
00153   void setFormat( const Format& f );
00154   
00155   bool visible() const;
00156   
00157   void setVisible( bool v );
00158 
00159 private:
00160   // no copy or assign
00161   Column( const Column& );
00162   Column& operator=( const Column& );
00163   
00164   class Private;
00165   Private *d;  
00166 };
00167 
00168 class Row
00169 {
00170 public:
00171 
00172   Row( Sheet* sheet, unsigned index );
00173   
00174   virtual ~Row();
00175   
00176   Sheet* sheet() const;
00177   
00178   unsigned index() const;
00179   
00180   // height of row, in pt
00181   double height() const;
00182   
00183   // set the height of row, in pt
00184   void setHeight( double w );
00185   
00186   const Format& format() const;
00187   
00188   void setFormat( const Format& f );
00189   
00190   bool visible() const;
00191   
00192   void setVisible( bool v );
00193 
00194 private:
00195   // no copy or assign
00196   Row( const Row& );
00197   Row& operator=( const Row& );
00198   
00199   class Private;
00200   Private *d;  
00201 };
00202 
00203 
00204 }
00205 
00206 #endif // SWINDER_SHEET_H
00207 
KDE Home | KDE Accessibility Home | Description of Access Keys