Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

table.cc

00001 /*
00002 *  Name:      table.cc
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   HTML table
00005 *  Date:      $Date: 2003/04/14 00:18:35 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 1994-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #include <algorithm>
00027 #include <mpcl/text/html/table.hh>
00028 #include <mpcl/text/html/table_row.hh>
00029 
00030 
00031 //
00032 //  C O N S T R U C T O R S
00033 //
00034 
00035 mpcl::text::html::TTable::
00036 TTable ( const char* pkcIDENTIFIER ,
00037          const char* pkcCAPTION    ,
00038          const char* pkcALIGN      ) :
00039   mpcl::text::html::TContainer (pkcIDENTIFIER)
00040 {
00041 
00042   tAttributeMap ["class-identifier"] = "table";
00043   tAttributeMap.bind ("caption",     pkcCAPTION);
00044   tAttributeMap.bind ("halign",      pkcALIGN);
00045   tAttributeMap.bind ("width",       "");
00046   tAttributeMap.bind ("border",      "");
00047   tAttributeMap.bind ("cellspacing", "");
00048   tAttributeMap.bind ("cellpadding", "");
00049   tAttributeMap.bind ("bgcolor",     "");
00050   gIsQualified = true;
00051 
00052 }  // TTable()
00053 
00054 
00055 //
00056 //  S E L E C T O R S
00057 //
00058 
00059 mpcl::text::html::QTTag mpcl::text::html::TTable::
00060 findOrInsertTag (const TString& rkyIDENTIFIER)
00061 {
00062 
00063   TStringToTagMap::iterator   I;
00064   bool                        gHasMoreIdentifiers;
00065 // <DELETE id="smart-pointers">
00066 //   QTContainer                 qtContainer;
00067 //   QTTableRow                  qtRow;
00068 // </DELETE>
00069   TContainer*                 ptContainer;
00070   QTTag                       qtRow;
00071   QTTag                       qtTag;
00072   TString                     yFirstIdentifierPart;
00073   TString                     yLastIdentifierPart;
00074   std::size_t                 zOffset;
00075 
00076   zOffset             = rkyIDENTIFIER.find (kcIdentifierSeparator);
00077   gHasMoreIdentifiers = ( TString::npos != zOffset );
00078   if ( !gHasMoreIdentifiers )
00079   {
00080     yFirstIdentifierPart = rkyIDENTIFIER;
00081   }
00082   else
00083   {
00084     yFirstIdentifierPart = rkyIDENTIFIER.substr (0, zOffset);
00085     yLastIdentifierPart  = rkyIDENTIFIER.substr (zOffset + 1);
00086   }
00087 
00088   //
00089   //  Searches in for the row called yFirstIdentifierPart.
00090   //
00091   I = tStringToTagMap.find (rkyIDENTIFIER);
00092   if ( I != tStringToTagMap.end() )
00093   {
00094     if ( !gHasMoreIdentifiers )
00095     {
00096       qtTag = I->second;
00097     }
00098     else
00099     {
00100 // <DELETE id="smart-pointers">
00101 //       DynamicCast (qtContainer, I->second);
00102 //       qtTag = qtContainer->findOrInsertTag (yLastIdentifierPart);
00103 // </DELETE>
00104       ptContainer = I->second.dynamicCast<TContainer*>();
00105       qtTag       = ptContainer->findOrInsertTag (yLastIdentifierPart);
00106     }
00107   }
00108   else if ( isDynamiclyLoadable() && !gHasMoreIdentifiers )
00109   {
00110     //
00111     //  There is no such row, so inserts a new one.
00112     //
00113     qtRow                           = new TTableRow();
00114     qtRow->attribute ("identifier") = rkyIDENTIFIER;
00115     insert (qtRow);
00116     qtTag = qtRow;
00117   }
00118   if ( !qtTag )
00119   {
00120     TString   yMessage = Format ("there is no tag called '%s'", rkyIDENTIFIER.c_str());
00121 
00122     throw TConstraintException (yMessage, __FILE__, __LINE__);
00123   }
00124   return qtTag;
00125 
00126 }  // findOrInsertTag()

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18