Source Code (Use browser search to find items of interest.)

Class Index

kspread'KSpreadMap (./koffice/kspread/kspread_map.h:44)

class KSpreadMap : public QObject
{
public:
  /**
   * Created an empty map.
   */
  KSpreadMap( KSpreadDoc *_doc, const char* name = 0 );
  /**
   * This deletes all tables contained in this map.
   */
  virtual ~KSpreadMap();

  QDomElement save( QDomDocument& doc );
  bool loadXML( const QDomElement& mymap );
  bool loadChildren( KoStore* _store );

  bool saveChildren( KoStore* _store, const char *_path );
  /*
   * @return true if one of the direct children wants to
   *              be saved embedded. If there are no children or if
   *              every direct child saves itself into its own file
   *              then false is returned.
   *
   */
  bool hasToWriteMultipart();

  /**
   * @param _table becomes added to the map.
   */
  void addTable( KSpreadTable *_table );

  /**
   * @param _tables becomes removed from the map. This won't delete the table.
   */
  void removeTable( KSpreadTable *_table );

  /**
   * The table named @param _from is being moved to the table @param _to.
   * If @param _before is true @param _from is inserted before (after otherwise)   * @param _to.
   */
  void moveTable( const char* _from, const char* to, bool _before = true );

  KSpreadTable* findTable( const QString & _name );

  KSpreadTable* initialActiveTable() { return m_initialActiveTable; }
  int initialMarkerColumn() { return m_initialMarkerColumn; }
  int initialMarkerRow() { return m_initialMarkerRow; }

  /**
   * Use the @ref #nextTable function to get all the other tables.
   * Attention: Function is not reentrant.
   *
   * @return a pointer to the first table in this map.
   */
  KSpreadTable* firstTable() { return m_lstTables.first();  }

  /**
   * Call @ref #firstTable first. This will set the list pointer to
   * the first table. Attention: Function is not reentrant.
   *
   * @return a pointer to the next table in this map.
   */
  KSpreadTable* nextTable() { return m_lstTables.next();  }

  QList<KSpreadTable>& tableList() { return m_lstTables; }

  /**
   * @return amount of tables in this map.
   */
  int count() { return m_lstTables.count(); }

  void update();

  /**
   * Needed for the printing Extension KOffice::Print
   */
  void draw( QPaintDevice* _dev, long int _width, long int _height,
	       float _scale );

  virtual DCOPObject* dcopObject();

  KSpreadDoc* doc();

private:
  /**
   * List of all tables in this map. The list has autodelete turned on.
   */
  QList<KSpreadTable> m_lstTables;

  /**
   * Pointer to the part which holds this map.
   */
  KSpreadDoc *m_pDoc;

  /**
   * Set from the XML
   */
  KSpreadTable * m_initialActiveTable;
  int m_initialMarkerColumn;
  int m_initialMarkerRow;

  DCOPObject* m_dcop;
};

kspread'KSpreadMap::KSpreadMap() (./koffice/kspread/kspread_map.cc:36)

KSpreadMap::KSpreadMap( KSpreadDoc *_doc, const char* name )
    : QObject( _doc, name )
{
  m_pDoc = _doc;
  m_dcop = 0;
  m_initialActiveTable = 0L;
  m_initialMarkerColumn = 0;
  m_initialMarkerRow = 0;

  m_lstTables.setAutoDelete( true );
}


kspread'KSpreadMap::~KSpreadMap() (./koffice/kspread/kspread_map.cc:48)

KSpreadMap::~KSpreadMap()
{
    delete m_dcop;
}


kspread'KSpreadMap::addTable() (./koffice/kspread/kspread_map.cc:53)

void KSpreadMap::addTable( KSpreadTable *_table )
{
  m_lstTables.append( _table );
}


kspread'KSpreadMap::removeTable() (./koffice/kspread/kspread_map.cc:58)

void KSpreadMap::removeTable( KSpreadTable *_table )
{
  m_lstTables.setAutoDelete( false );
  m_lstTables.removeRef( _table );
  m_lstTables.setAutoDelete( true );
}


kspread'KSpreadMap::moveTable() (./koffice/kspread/kspread_map.cc:65)

void KSpreadMap::moveTable( const char* _from, const char* _to, bool _before )
{
  KSpreadTable* tablefrom = findTable( _from );
  KSpreadTable* tableto = findTable( _to );

  int from = m_lstTables.find( tablefrom ) ;
  int to = m_lstTables.find( tableto ) ;
  if ( !_before )
  ++to;

  if ( to > (int)m_lstTables.count() )
  {
    m_lstTables.append( tablefrom );
    m_lstTables.take( from );
  }
  else if ( from < to )
  {
    m_lstTables.insert( to, tablefrom );
    m_lstTables.take( from );
  }
  else
  {
    m_lstTables.take( from );
    m_lstTables.insert( to, tablefrom );
  }
}


kspread'KSpreadMap::save() (./koffice/kspread/kspread_map.cc:92)

QDomElement KSpreadMap::save( QDomDocument& doc )
{
  QDomElement mymap = doc.createElement( "map" );
  // Save visual info for the first view, such as active table and active cell
  // It looks like a hack, but reopening a document creates only one view anyway (David)
  KSpreadCanvas * canvas = static_cast<KSpreadView*>(this->doc()->firstView())->canvasWidget();
  mymap.setAttribute( "activeTable", canvas->activeTable()->name() );
  mymap.setAttribute( "markerColumn", canvas->markerColumn() );
  mymap.setAttribute( "markerRow", canvas->markerRow() );

  QListIterator<KSpreadTable> it( m_lstTables );
  for( ; it.current(); ++it )
  {
    QDomElement e = it.current()->save( doc );
    if ( e.isNull() )
      return e;
    mymap.appendChild( e );
  }

  return mymap;
}


kspread'KSpreadMap::loadXML() (./koffice/kspread/kspread_map.cc:114)

bool KSpreadMap::loadXML( const QDomElement& mymap )
{
  QString activeTable = mymap.attribute( "activeTable" );
  m_initialMarkerColumn = mymap.attribute( "markerColumn" ).toInt();
  m_initialMarkerRow = mymap.attribute( "markerRow" ).toInt();
  QDomNode n = mymap.firstChild();
  while( !n.isNull() )
  {
    QDomElement e = n.toElement();
    if ( !e.isNull() && e.tagName() == "table" )
    {
      KSpreadTable *t = m_pDoc->createTable();
      m_pDoc->addTable( t );
      if ( !t->loadXML( e ) )
	return false;
    }
    n = n.nextSibling();
  }

  if (!activeTable.isEmpty())
  {
    // Used by KSpreadView's constructor
    m_initialActiveTable = findTable( activeTable );
  }

  return true;
}


kspread'KSpreadMap::update() (./koffice/kspread/kspread_map.cc:142)

void KSpreadMap::update()
{
  QListIterator<KSpreadTable> it( m_lstTables );
  for( ; it.current(); ++it )
    it.current()->update();
}


kspread'KSpreadMap::findTable() (./koffice/kspread/kspread_map.cc:149)

KSpreadTable* KSpreadMap::findTable( const QString & _name )
{
    KSpreadTable *t;

    for ( t = m_lstTables.first(); t != 0L; t = m_lstTables.next() )
    {
	if ( _name == t->tableName() )
	    return t;
    }

    return 0L;
}


kspread'KSpreadMap::saveChildren() (./koffice/kspread/kspread_map.cc:162)

bool KSpreadMap::saveChildren( KoStore* _store, const char *_path )
{
  QListIterator<KSpreadTable> it( m_lstTables );
  for( ; it.current(); ++it )
  {
    // set the child document's url to an internal url (ex: "tar:/0/1")
    QString path = QString( "%1/%2" ).arg( _path ).arg( it.current()->tableName() );
    if ( !it.current()->saveChildren( _store, path ) )
      return false;
  }
  return true;
}


kspread'KSpreadMap::loadChildren() (./koffice/kspread/kspread_map.cc:175)

bool KSpreadMap::loadChildren( KoStore* _store )
{
  QListIterator<KSpreadTable> it( m_lstTables );
  for( ; it.current(); ++it )
    if ( !it.current()->loadChildren( _store ) )
      return false;

  return true;
}


kspread'KSpreadMap::hasToWriteMultipart() (./koffice/kspread/kspread_map.cc:185)

bool KSpreadMap::hasToWriteMultipart()
{
  QListIterator<KSpreadTable> it( m_lstTables );
  for( ; it.current(); ++it )
  {
    if ( it.current()->hasToWriteMultipart() )
      return true;
  }

  return false;
}

// ######### Torben: Is that really needed ?
// ### The header says 'Needed for the printing extension KOffice::Print' (David)

kspread'KSpreadMap::draw() (./koffice/kspread/kspread_map.cc:199)

void KSpreadMap::draw( QPaintDevice* _dev, long int _width, long int _height,
		       float _scale )
{
  // Only the view knows about the active table. So we can just assume that
  // embedded KSpread documents do only have one table
  if ( m_lstTables.first() )
    m_lstTables.first()->draw( _dev, _width, _height, _scale );
}


kspread'KSpreadMap::dcopObject() (./koffice/kspread/kspread_map.cc:208)

DCOPObject* KSpreadMap::dcopObject()
{
    if ( !m_dcop )
	m_dcop = new KSpreadMapIface( this );

    return m_dcop;
}


kspread'KSpreadMap::doc() (./koffice/kspread/kspread_map.cc:216)

KSpreadDoc* KSpreadMap::doc()
{
    return m_pDoc;
}