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   // first column (A) is 0, first row is 0
00058   Cell* cell( unsigned column, unsigned row, bool autoCreate = true );
00059 
00060   Column* column( unsigned index, bool autoCreate = true );
00061 
00062   Row* row( unsigned index, bool autoCreate = true );
00063 
00064   bool visible() const;
00065   void setVisible( bool v );
00066 
00067   bool protect() const;
00068   void setProtect( bool p );
00069 
00070   /*
00071    *   &P  current page number
00072    *   &D  current date
00073    *   &T  current time
00074    *   &A  sheet name
00075    *   &F  file name without path
00076    *   &Z  file path without file name
00077    *   &G  picture
00078    *   &B  bold on/off
00079    *   &I  italic on/off
00080    *   &U  underlining on/off
00081    *   &E  double underlining on/off
00082    *   &S  strikeout on/off
00083    *   &X  superscript on/off
00084    *   &Y  subscript on/off
00085    *
00086    *   &"<fontname>"  set font name
00087    *   &"<fontname>,<fontstyle>" set font name and style
00088    *   &<fontheight>  set font height
00089 
00090    */
00091 
00092   UString leftHeader() const;
00093   void setLeftHeader( const UString& h );
00094   UString centerHeader() const;
00095   void setCenterHeader( const UString& h );
00096   UString rightHeader() const;
00097   void setRightHeader( const UString& h );
00098 
00099   UString leftFooter() const;
00100   void setLeftFooter( const UString& f );
00101   UString centerFooter() const;
00102   void setCenterFooter( const UString& f );
00103   UString rightFooter() const;
00104   void setRightFooter( const UString& f );
00105 
00106   // left margin, in points (pt)
00107   double leftMargin() const;
00108   void setLeftMargin( double m );
00109 
00110   // right margin, in points (pt)
00111   double rightMargin() const;
00112   void setRightMargin( double m );
00113 
00114   // top margin, in points (pt)
00115   double topMargin() const;
00116   void setTopMargin( double m );
00117   
00118   // bottom margin, in points (pt)
00119   double bottomMargin() const;
00120   void setBottomMargin( double m );
00121 
00122   unsigned maxRow() const;
00123   unsigned maxColumn() const;
00124 
00125 private:
00126   // no copy or assign
00127   Sheet( const Sheet& );
00128   Sheet& operator=( const Sheet& );
00129   
00130   class Private;
00131   Private *d;  
00132 };
00133 
00134 class Column
00135 {
00136 public:
00137 
00138   Column( Sheet* sheet, unsigned index );
00139   
00140   virtual ~Column();
00141   
00142   Sheet* sheet() const;
00143   
00144   unsigned index() const;
00145   
00146   // width of column, in pt
00147   double width() const;
00148   
00149   // set the width of column, in pt
00150   void setWidth( double w );
00151   
00152   const Format& format() const;
00153   
00154   void setFormat( const Format& f );
00155   
00156   void setFormatIndex( int index );
00157   
00158   int formatIndex() const;
00159   
00160   bool visible() const;
00161   
00162   void setVisible( bool v );
00163 
00164 private:
00165   // no copy or assign
00166   Column( const Column& );
00167   Column& operator=( const Column& );
00168   
00169   class Private;
00170   Private *d;  
00171 };
00172 
00173 class Row
00174 {
00175 public:
00176 
00177   Row( Sheet* sheet, unsigned index );
00178   
00179   virtual ~Row();
00180   
00181   Sheet* sheet() const;
00182   
00183   unsigned index() const;
00184   
00185   // height of row, in pt
00186   double height() const;
00187   
00188   // set the height of row, in pt
00189   void setHeight( double w );
00190   
00191   const Format& format() const;
00192   
00193   void setFormat( const Format& f );
00194   
00195   void setFormatIndex( int index );
00196   
00197   int formatIndex() const;
00198   
00199   bool visible() const;
00200   
00201   void setVisible( bool v );
00202 
00203 private:
00204   // no copy or assign
00205   Row( const Row& );
00206   Row& operator=( const Row& );
00207   
00208   class Private;
00209   Private *d;  
00210 };
00211 
00212 
00213 }
00214 
00215 #endif // SWINDER_SHEET_H
00216 
KDE Home | KDE Accessibility Home | Description of Access Keys