kspread
- kspread
- plugins
- scripting
- kspreadcore
23#include <kspread_map.h>
24#include <kspread_sheet.h>
26namespace Kross { namespace KSpreadCore {
28Doc::Doc(KSpread::Doc* doc)
29 : Kross::Api::Class< Doc>( "KSpreadDocument"), m_doc(doc)
31 this->addFunction0< Sheet >( "currentSheet", this, &Doc::currentSheet);
32 this->addFunction1< Sheet, Kross::Api::Variant >( "sheetByName", this, &Doc::sheetByName);
33 this->addFunction0< Kross::Api::Variant >( "sheetNames", this, &Doc::sheetNames);
35 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >( "addSheet", this, &Doc::addSheet);
36 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >( "removeSheet", this, &Doc::removeSheet);
38 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >( "loadNativeXML", this, &Doc::loadNativeXML);
39 this->addFunction0< Kross::Api::Variant >( "saveNativeXML", this, &Doc::saveNativeXML);
41 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >( "openUrl", this, &Doc::openUrl);
42 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >( "saveUrl", this, &Doc::saveUrl);
43 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >( "import", this, &Doc::import);
44 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >( "exp0rt", this, &Doc::exp0rt);
52const TQString Doc::getClassName() const {
53 return "Kross::KSpreadCore::Doc";
56Sheet* Doc::currentSheet()
58 return new Sheet(m_doc->displaySheet(), m_doc);
61Sheet* Doc::sheetByName( const TQString& name)
63 TQPtrListIterator<KSpread::Sheet> it (m_doc->map()->sheetList());
64 for( ; it.current(); ++it )
65 if(it.current()->sheetName() == name)
66 return new Sheet(it.current(), m_doc);
70TQStringList Doc::sheetNames()
73 TQPtrListIterator<KSpread::Sheet> it (m_doc->map()->sheetList());
74 for( ; it.current(); ++it )
75 names.append( it.current()->sheetName() );
79bool Doc::addSheet( const TQString& sheetname)
81 KSpread::Sheet* sheet = m_doc->map()->createSheet();
83 if(! sheet->setSheetName(sheetname)) {
87 m_doc->map()->addSheet(sheet);
93bool Doc::removeSheet( const TQString& sheetname)
95 KSpread::Sheet* sheet = m_doc->map()->findSheet(sheetname);
97 m_doc->map()->takeSheet(sheet);
103bool Doc::loadNativeXML( const TQString& xml) {
105 if(! doc.setContent(xml, true))
107 return m_doc->loadXML(0, doc);
110TQString Doc::saveNativeXML() {
111 return m_doc->saveXML().toString(2);
114bool Doc::openUrl( const TQString& url)
116 return m_doc->openURL(url);
119bool Doc::saveUrl( const TQString& url)
121 return m_doc->saveAs(url);
124bool Doc::import( const TQString& url)
126 return m_doc->import(url);
129bool Doc::exp0rt( const TQString& url)
131 return m_doc->exp0rt(url);
|