From 8362bf63dea22bbf6736609b0f49c152f975eb63 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 20 Jan 2010 01:29:50 +0000 Subject: Added old abandoned KDE3 version of koffice git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- filters/kspread/html/CHANGELOG | 11 + filters/kspread/html/Makefile.am | 18 + filters/kspread/html/exportdialog.cc | 113 ++++++ filters/kspread/html/exportdialog.h | 63 +++ filters/kspread/html/exportwidget.ui | 310 +++++++++++++++ filters/kspread/html/htmlexport.cc | 475 +++++++++++++++++++++++ filters/kspread/html/htmlexport.h | 81 ++++ filters/kspread/html/kspread_html_export.desktop | 72 ++++ filters/kspread/html/status.html | 173 +++++++++ 9 files changed, 1316 insertions(+) create mode 100644 filters/kspread/html/CHANGELOG create mode 100644 filters/kspread/html/Makefile.am create mode 100644 filters/kspread/html/exportdialog.cc create mode 100644 filters/kspread/html/exportdialog.h create mode 100644 filters/kspread/html/exportwidget.ui create mode 100644 filters/kspread/html/htmlexport.cc create mode 100644 filters/kspread/html/htmlexport.h create mode 100644 filters/kspread/html/kspread_html_export.desktop create mode 100644 filters/kspread/html/status.html (limited to 'filters/kspread/html') diff --git a/filters/kspread/html/CHANGELOG b/filters/kspread/html/CHANGELOG new file mode 100644 index 00000000..0147160f --- /dev/null +++ b/filters/kspread/html/CHANGELOG @@ -0,0 +1,11 @@ +=== KOffice 1.4 === +- New configuration dialog to tweak HTML export +- Make borders optional +- Ability to select which sheets to be exported. +- Ability to write each table to a new page. +- A Table Of Contents is generated on top of each page. +- Choose the number of pixels between cells. +- Don't add one column and row too much. +- Don't export empty sheets. +- Let the user choose encoding. +- Linkage of external stylesheets. \ No newline at end of file diff --git a/filters/kspread/html/Makefile.am b/filters/kspread/html/Makefile.am new file mode 100644 index 00000000..87018feb --- /dev/null +++ b/filters/kspread/html/Makefile.am @@ -0,0 +1,18 @@ +####### General stuff + +INCLUDES= -I$(srcdir) -I$(top_srcdir)/kspread $(KOFFICE_INCLUDES) \ + $(KOTEXT_INCLUDES) $(all_includes) + +####### Files + +kde_module_LTLIBRARIES = libkspreadhtmlexport.la + +libkspreadhtmlexport_la_SOURCES = htmlexport.cc exportdialog.cc exportwidget.ui +libkspreadhtmlexport_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +libkspreadhtmlexport_la_LIBADD = $(KOFFICE_LIBS) ../../../kspread/libkspreadcommon.la + +METASOURCES = AUTO + +service_DATA = kspread_html_export.desktop + +servicedir = $(kde_servicesdir) diff --git a/filters/kspread/html/exportdialog.cc b/filters/kspread/html/exportdialog.cc new file mode 100644 index 00000000..78276def --- /dev/null +++ b/filters/kspread/html/exportdialog.cc @@ -0,0 +1,113 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Bram Schoenmakers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +ExportDialog::ExportDialog( QWidget *parent, const char *name ) + : KDialogBase( parent, name, true, i18n("Export Sheet to HTML"), Ok|Cancel, No, true ), m_mainwidget( new ExportWidget( this ) ) +{ + kapp->restoreOverrideCursor(); + + connect( m_mainwidget->mCustomButton, SIGNAL( toggled( bool ) ), + m_mainwidget->mCustomURL, SLOT( setEnabled( bool ) ) ); + connect( m_mainwidget->mSelectAllButton, SIGNAL( clicked() ), SLOT( selectAll() ) ); + connect( m_mainwidget->mDeselectAllButton, SIGNAL( clicked() ), + m_mainwidget->mSheets, SLOT( clearSelection() ) ); + + m_mainwidget->mEncodingBox->insertItem( i18n( "Recommended: UTF-8" ) ); + m_mainwidget->mEncodingBox->insertItem( i18n( "Locale (%1)" ).arg( KGlobal::locale()->codecForEncoding()->name() ) ); + + m_mainwidget->mCustomURL->setMode( KFile::ExistingOnly ); + + setMainWidget( m_mainwidget ); +} + +void ExportDialog::selectAll() +{ + m_mainwidget->mSheets->selectAll( true ); +} + +ExportDialog::~ExportDialog() +{ + kapp->setOverrideCursor(Qt::waitCursor); +} + +QTextCodec *ExportDialog::encoding() const +{ + if( m_mainwidget->mEncodingBox->currentItem() == 1 ) // locale selected + return KGlobal::locale()->codecForEncoding(); + + return QTextCodec::codecForName( "utf8" ); // utf8 is default +} + +bool ExportDialog::useBorders() const +{ + return m_mainwidget->mUseBorders->isChecked(); +} + +bool ExportDialog::separateFiles() const +{ + return m_mainwidget->mSeparateFiles->isChecked(); +} + +QString ExportDialog::customStyleURL() const +{ + QString url = m_mainwidget->mCustomURL->url(); + if( m_mainwidget->mCustomButton->isChecked() && KURL( url ).isValid() ) + return url; + + return QString::null; +} + +void ExportDialog::setSheets( const QStringList &list ) +{ + m_mainwidget->mSheets->insertStringList( list ); + selectAll(); +} + +QStringList ExportDialog::sheets() const +{ + QStringList list; + for( uint i = 0; i < m_mainwidget->mSheets->count() ; i++ ) + { + if( m_mainwidget->mSheets->isSelected( i ) ) + list.append( m_mainwidget->mSheets->text( i ) ); + } + return list; +} + +int ExportDialog::pixelsBetweenCells() const +{ + return m_mainwidget->mPixelsBetweenCells->value(); +} + +#include diff --git a/filters/kspread/html/exportdialog.h b/filters/kspread/html/exportdialog.h new file mode 100644 index 00000000..4a460554 --- /dev/null +++ b/filters/kspread/html/exportdialog.h @@ -0,0 +1,63 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Bram Schoenmakers + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef EXPORTDIALOG_H +#define EXPORTDIALOG_H + +#include + +class ExportWidget; + +class ExportDialog : public KDialogBase +{ + Q_OBJECT + public: + ExportDialog( QWidget *parent = 0, const char *name = 0 ); + ~ExportDialog(); + + void setSheets( const QStringList & ); + QStringList sheets() const; + + /** + Returns preferred encoding. Defaults to UTF-8. + */ + QTextCodec *encoding() const; + + /** + Returns a valid URL if the custom button was selected. + Else, it will return QString::null. + */ + QString customStyleURL() const; + + /** + Returns true if borders should be shown, false if borders + should be hidden. + */ + bool useBorders() const; + + bool separateFiles() const; + + int pixelsBetweenCells() const; + protected slots: + void selectAll(); + private: + ExportWidget *m_mainwidget; +}; + +#endif diff --git a/filters/kspread/html/exportwidget.ui b/filters/kspread/html/exportwidget.ui new file mode 100644 index 00000000..d81ef40b --- /dev/null +++ b/filters/kspread/html/exportwidget.ui @@ -0,0 +1,310 @@ + +ExportWidget + + + ExportWidget + + + + 0 + 0 + 256 + 413 + + + + + unnamed + + + 0 + + + + layout1 + + + + unnamed + + + + textLabel1 + + + En&coding: + + + mEncodingBox + + + + + mEncodingBox + + + With this option you can define the encoding of the HTML file. The recommended encoding (UTF8) is selected as default. + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + + + groupBox3 + + + Sheet Selection + + + + unnamed + + + + mSheets + + + Multi + + + + + layout7 + + + + unnamed + + + + mSelectAllButton + + + Select &All + + + Click here to select all sheets in the list. + + + + + mDeselectAllButton + + + Desele&ct All + + + Click here to select all sheets in the list. + + + + + spacer3 + + + Horizontal + + + Expanding + + + + 330 + 20 + + + + + + + + mSeparateFiles + + + Use &separate files for each table + + + This option will make the HTML export filter generate a new page for each sheet. If you disable this option, all sheets are written on one page. + + + + + + + buttonGroup4 + + + Style + + + + unnamed + + + + mDefaultButton + + + Use &default style + + + true + + + Select this option to use the default fonts and colors for the HTML page. + + + + + mCustomButton + + + Use &external stylesheet: + + + Select this option to specify a separate stylesheet for the HTML page. You can select or type on in the field below. + + + + + mCustomURL + + + false + + + In this field you can enter an URL for your stylesheet. It is possible to point to a stylesheet on disk, or to somewhere on the Internet. + + + + + + + groupBox2 + + + Layout + + + + unnamed + + + + mUseBorders + + + Use &borders + + + true + + + Use this option to enable or disable borders around the cells. + + + + + layout4 + + + + unnamed + + + + textLabel1_2 + + + Pi&xels between cells: + + + mPixelsBetweenCells + + + Use this option to define how many pixels there should be between the cells. This effect is better visible if you check <b>Use borders</b> too. + + + + + mPixelsBetweenCells + + + + 1 + 0 + 0 + 0 + + + + 25 + + + Use this option to define how many pixels there should be between the cells. This effect is better visible if you check <b>Use borders</b> too. + + + + + spacer5_2 + + + Horizontal + + + Expanding + + + + 16 + 20 + + + + + + + + + + spacer5 + + + Vertical + + + Expanding + + + + 20 + 16 + + + + + + + + kurlrequester.h + klineedit.h + kpushbutton.h + + diff --git a/filters/kspread/html/htmlexport.cc b/filters/kspread/html/htmlexport.cc new file mode 100644 index 00000000..76c6ee83 --- /dev/null +++ b/filters/kspread/html/htmlexport.cc @@ -0,0 +1,475 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Eva Brucherseifer + Copyright (C) 2005 Bram Schoenmakers + based on kspread csv export filter by David Faure + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace KSpread; + +typedef KGenericFactory HTMLExportFactory; +K_EXPORT_COMPONENT_FACTORY( libkspreadhtmlexport, HTMLExportFactory( "kofficefilters" ) ) + +const QString html_table_tag = "table"; +const QString html_table_options = QString(" border=\"%1\" cellspacing=\"%2\""); +const QString html_row_tag = "tr"; +const QString html_row_options = ""; +const QString html_cell_tag = "td"; +const QString html_cell_options = ""; +const QString html_bold = "b"; +const QString html_italic = "i"; +const QString html_underline = "u"; +const QString html_right= "right"; +const QString html_left= "left"; +const QString html_center= "center"; +const QString html_top="top"; +const QString html_bottom="bottom"; +const QString html_middle="middle"; +const QString html_h1="h1"; + +HTMLExport::HTMLExport(KoFilter *, const char *, const QStringList&) : + KoFilter(), m_dialog( new ExportDialog() ) +{ +} + +HTMLExport::~HTMLExport() +{ + delete m_dialog; +} + +// HTML enitities, AFAIK we don't need to escape " to " (dnaber): +const QString strAmp ("&"); +const QString nbsp (" "); +const QString strLt ("<"); +const QString strGt (">"); + +// The reason why we use the KoDocument* approach and not the QDomDocument +// approach is because we don't want to export formulas but values ! +KoFilter::ConversionStatus HTMLExport::convert( const QCString& from, const QCString& to ) +{ + if(to!="text/html" || from!="application/x-kspread") + { + kdWarning(30501) << "Invalid mimetypes " << to << " " << from << endl; + return KoFilter::NotImplemented; + } + + KoDocument* document = m_chain->inputDocument(); + + if ( !document ) + return KoFilter::StupidError; + + if( !::qt_cast( document ) ) // it's safer that way :) + { + kdWarning(30501) << "document isn't a KSpread::Doc but a " << document->className() << endl; + return KoFilter::NotImplemented; + } + + const Doc * ksdoc=static_cast(document); + + if( ksdoc->mimeType() != "application/x-kspread" ) + { + kdWarning(30501) << "Invalid document mimetype " << ksdoc->mimeType() << endl; + return KoFilter::NotImplemented; + } + + Sheet *sheet = ksdoc->map()->firstSheet(); + QString filenameBase = m_chain->outputFile(); + filenameBase = filenameBase.left( filenameBase.findRev( '.' ) ); + + QStringList sheets; + while( sheet != 0 ) + { + int rows = 0; + int columns = 0; + detectFilledCells( sheet, rows, columns ); + m_rowmap[ sheet->sheetName() ] = rows; + m_columnmap[ sheet->sheetName() ] = columns; + + if( rows > 0 && columns > 0 ) + { + sheets.append( sheet->sheetName() ); + } + sheet = ksdoc->map()->nextSheet(); + } + m_dialog->setSheets( sheets ); + + if( m_dialog->exec() == QDialog::Rejected ) + return KoFilter::UserCancelled; + + sheets = m_dialog->sheets(); + QString str; + for( uint i = 0; i < sheets.count() ; ++i ) + { + sheet = ksdoc->map()->findSheet( sheets[i] ); + + QString file = fileName( filenameBase, sheet->sheetName(), sheets.count() > 1 ); + + if( m_dialog->separateFiles() || sheets[i] == sheets.first() ) + { + str = QString::null; + openPage( sheet, document, str ); + writeTOC( sheets, filenameBase, str ); + } + + convertSheet( sheet, str, m_rowmap[ sheet->sheetName() ], m_columnmap[ sheet->sheetName() ] ); + + if( m_dialog->separateFiles() || sheets[i] == sheets.last() ) + { + closePage( str ); + QFile out(file); + if(!out.open(IO_WriteOnly)) { + kdError(30501) << "Unable to open output file!" << endl; + out.close(); + return KoFilter::FileNotFound; + } + QTextStream streamOut(&out); + streamOut.setCodec( m_dialog->encoding() ); + streamOut << str << endl; + out.close(); + } + + if( !m_dialog->separateFiles() ) + { + createSheetSeparator( str ); + } + + } + + emit sigProgress(100); + return KoFilter::OK; +} + +void HTMLExport::openPage( Sheet *sheet, KoDocument *document, QString &str ) +{ + QString title; + KoDocumentInfo *info = document->documentInfo(); + KoDocumentInfoAbout *aboutPage = static_cast(info->page( "about" )); + if ( aboutPage && !aboutPage->title().isEmpty() ) + title = aboutPage->title() + " - "; + + title += sheet->sheetName(); + + // header + str = " \n"; + str += "\n"; + str += "\n"; + str += "\n").arg( m_dialog->encoding()->mimeName() ); + str += "\n"; + + // Insert stylesheet + if( !m_dialog->customStyleURL().isEmpty() ) + { + str += "customStyleURL(); + str += "\" title=\"Style\" >\n"; + } + + str += "" + title + "\n"; + str += "\n"; + str += QString("\n").arg( + sheet->isRightToLeft()?"rtl":"ltr"); + + str += "\n"; +} + +void HTMLExport::closePage( QString &str ) +{ + str += "

" + i18n("Top") + "

\n"; + str += "\n"; + str += "\n\n"; +} + +void HTMLExport::convertSheet( Sheet *sheet, QString &str, int iMaxUsedRow, int iMaxUsedColumn ) +{ + QString emptyLines; + + // Either we get hold of KSpreadTable::m_dctCells and apply the old method below (for sorting) + // or, cleaner and already sorted, we use KSpreadTable's API (slower probably, though) + int iMaxRow = sheet->maxRow(); + + if( !m_dialog->separateFiles() ) + str += "sheetName().lower().stripWhiteSpace() + "\">\n"; + + str += ("

" + sheet->sheetName() + "


\n"); + + // this is just a bad approximation which fails for documents with less than 50 rows, but + // we don't need any progress stuff there anyway :) (Werner) + int value=0; + int step=iMaxRow > 50 ? iMaxRow/50 : 1; + int i=1; + + str += "<" + html_table_tag + html_table_options.arg( m_dialog->useBorders() ? "1" : "0" ).arg( m_dialog->pixelsBetweenCells() ) + + QString("dir=\"%1\">\n").arg(sheet->isRightToLeft()?"rtl":"ltr"); + + unsigned int nonempty_cells_prev=0; + + for ( int currentrow = 1 ; currentrow <= iMaxUsedRow ; ++currentrow, ++i ) + { + if(i>step) { + value+=2; + emit sigProgress(value); + i=0; + } + + QString separators; + QString line; + unsigned int nonempty_cells=0; + unsigned int colspan_cells=0; + + for ( int currentcolumn = 1 ; currentcolumn <= iMaxUsedColumn ; currentcolumn++ ) + { + Cell * cell = sheet->cellAt( currentcolumn, currentrow, false ); + colspan_cells=cell->extraXCells(); + if (cell->needsPrinting()) + nonempty_cells++; + QString text; + QColor bgcolor = cell->bgColor(currentcolumn,currentrow); + // FIXME: some formatting seems to be missing with cell->text(), e.g. + // "208.00" in KSpread will be "208" in HTML (not always?!) + bool link = false; + + if ( !cell->link().isEmpty() ) + { + if ( localReferenceAnchor(cell->link()) ) + { + text = cell->text(); + } + else + { + text = "
link() + "\">" + cell->text() + ""; + link = true; + } + } + else + text=cell->strOutText(); +#if 0 + switch( cell->content() ) { + case Cell::Text: + text = cell->text(); + break; + case Cell::RichText: + case Cell::VisualFormula: + text = cell->text(); // untested + break; + case Cell::Formula: + cell->calc( TRUE ); // Incredible, cells are not calculated if the document was just opened + text = cell->valueString(); + break; + } + text = cell->prefix(currentrow, currentcolumn) + " " + text + " " + + cell->postfix(currentrow, currentcolumn); +#endif + line += " <" + html_cell_tag + html_cell_options; + if (text.isRightToLeft() != sheet->isRightToLeft()) + line += QString(" dir=\"%1\" ").arg(text.isRightToLeft()?"rtl":"ltr"); + if (bgcolor.isValid() && bgcolor.name()!="#ffffff") // change color only for non-white cells + line += " bgcolor=\"" + bgcolor.name() + "\""; + + switch((Format::Align)cell->defineAlignX()) + { + case Format::Left: + line+=" align=\"" + html_left +"\""; + break; + case Format::Right: + line+=" align=\"" + html_right +"\""; + break; + case Format::Center: + line+=" align=\"" + html_center +"\""; + break; + case Format::Undefined: + break; + } + switch((Format::AlignY)cell-> format()->alignY(currentrow, currentcolumn)) + { + case Format::Top: + line+=" valign=\"" + html_top +"\""; + break; + case Format::Middle: + line+=" valign=\"" + html_middle +"\""; + break; + case Format::Bottom: + line+=" valign=\"" + html_bottom +"\""; + break; + case Format::UndefinedY: + break; + } + line+=" width=\""+QString::number(cell->width())+"\""; + line+=" height=\""+QString::number(cell->height())+"\""; + + if (cell->extraXCells()>0) + { + QString tmp; + int extra_cells=cell->extraXCells(); + line += " colspan=\"" + tmp.setNum(extra_cells+1) + "\""; + currentcolumn += extra_cells; + } + text = text.stripWhiteSpace(); + if( text.at(0) == '!' ) { + // this is supposed to be markup, just remove the '!': + text = text.right(text.length()-1); + } else if ( !link ) { + // Escape HTML characters. + text.replace ('&' , strAmp) + .replace ('<' , strLt) + .replace ('>' , strGt) + .replace (' ' , nbsp); + } + line += ">\n"; + + if (cell->format()->textFontBold(currentcolumn,currentrow)) + { + text.insert(0, "<" + html_bold + ">"); + text.append(""); + } + if (cell->format()->textFontItalic(currentcolumn,currentrow)) + { + text.insert(0, "<" + html_italic + ">"); + text.append(""); + } + if (cell->format()->textFontUnderline(currentcolumn,currentrow)) + { + text.insert(0, "<" + html_underline + ">"); + text.append(""); + } + QColor textColor = cell->format()->textColor(currentcolumn,currentrow); + if (textColor.isValid() && textColor.name()!="#000000") // change color only for non-default text + { + text.insert(0, ""); + text.append(""); + } + line += " " + text; + line += "\n \n"; + } + + if (nonempty_cells == 0 && nonempty_cells_prev == 0) { + nonempty_cells_prev = nonempty_cells; + // skip line if there's more than one empty line + continue; + } else { + nonempty_cells_prev = nonempty_cells; + str += emptyLines; + str += "<" + html_row_tag + html_row_options + ">\n"; + str += line; + str += ""; + emptyLines = QString::null; + // Append a CR, but in a temp string -> if no other real line, + // then those will be dropped + emptyLines += "\n"; + } + } + str += "\n\n
\n"; +} + +void HTMLExport::createSheetSeparator( QString &str ) +{ + str += ("

" + i18n("Top") + "

\n" ); + str += "
\n"; +} + +void HTMLExport::writeTOC( const QStringList &sheets, const QString &base, QString &str ) +{ + // don't create TOC for 1 sheet + if( sheets.count() == 1 ) + return; + + str += "

\n"; + + for( uint i = 0 ; i < sheets.count() ; ++i ) + { + str += "separateFiles() ) + { + str += fileName( base, sheets[i], sheets.count() > 1 ); + } + else + { + str += "#" + sheets[i].lower().stripWhiteSpace(); + } + + str += "\">" + sheets[i] + "\n"; + if( i != sheets.count() -1 ) + str += " - "; + } + + str += "


\n"; +} + +QString HTMLExport::fileName( const QString &base, const QString &sheetName, bool multipleFiles ) +{ + QString fileName = base; + if( m_dialog->separateFiles() && multipleFiles ) + { + fileName += "-" + sheetName; + } + fileName += ".html"; + + return fileName; +} + +void HTMLExport::detectFilledCells( Sheet *sheet, int &rows, int &columns ) +{ + int iMaxColumn = sheet->maxColumn(); + int iMaxRow = sheet->maxRow(); + rows = 0; + columns = 0; + + for ( int currentrow = 1 ; currentrow <= iMaxRow ; ++currentrow) + { + Cell * cell = 0L; + int iUsedColumn=0; + for ( int currentcolumn = 1 ; currentcolumn <= iMaxColumn ; currentcolumn++ ) + { + cell = sheet->cellAt( currentcolumn, currentrow, false ); + QString text; + if ( !cell->isDefault() && !cell->isEmpty() ) + { + iUsedColumn = currentcolumn; + } + } + if (cell) + iUsedColumn += cell->extraXCells(); + if (iUsedColumn > columns) + columns = iUsedColumn; + if ( iUsedColumn > 0 ) + rows = currentrow; + } +} + +#include diff --git a/filters/kspread/html/htmlexport.h b/filters/kspread/html/htmlexport.h new file mode 100644 index 00000000..1952c9af --- /dev/null +++ b/filters/kspread/html/htmlexport.h @@ -0,0 +1,81 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Eva Brucherseifer + Copyright (C) 2005 Bram Schoenmakers + based on kspread csv export filter by David Faure + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef HTMLEXPORT_TEST_H +#define HTMLEXPORT_TEST_H + +#include + +class ExportDialog; +class KoDocument; + +namespace KSpread +{ +class Sheet; +} + +class HTMLExport : public KoFilter { + Q_OBJECT +public: + HTMLExport(KoFilter *parent, const char*name, const QStringList&); + virtual ~HTMLExport(); + + virtual KoFilter::ConversionStatus convert( const QCString& from, const QCString& to ); + private: + /** Writes the top of the page in HTML to @par str */ + void openPage( KSpread::Sheet *sheet,KoDocument *document, QString &str); + + /** Closes a page in HTML */ + void closePage( QString &); + + /** + Converts @par sheet to HTML and writes to @par str. + */ + void convertSheet( KSpread::Sheet *sheet, QString &str, int, int); + + /** Writes a bar and a link to the top to @par str. */ + void createSheetSeparator( QString & ); + + /** Writes the table of contents */ + void writeTOC( const QStringList &, const QString &, QString & ); + + /** + Returns a filename based on the @par base filename and the options + defined in the dialog. + */ + QString fileName( const QString &base, const QString &, bool ); + + /** + Detects which rows and columsn of the given @par sheet are used and + writes the number of them to @par row and @par column. + */ + void detectFilledCells( KSpread::Sheet *sheet, int &rows, int &colums ); + private: + ExportDialog *m_dialog; + + typedef QMap Rows; + Rows m_rowmap; + typedef QMap Columns; + Columns m_columnmap; +}; + +#endif + diff --git a/filters/kspread/html/kspread_html_export.desktop b/filters/kspread/html/kspread_html_export.desktop new file mode 100644 index 00000000..7164cf9a --- /dev/null +++ b/filters/kspread/html/kspread_html_export.desktop @@ -0,0 +1,72 @@ +[Desktop Entry] +Type=Service +Name=HTML Export Filter for KSpread +Name[af]=Html Voer uit Filter vir Kspread +Name[ar]=مِرْشَح تصدير HTML لدى KSpread +Name[az]=KSpread üçün HTML Vermə Süzgəci +Name[bg]=Филтър за експортиране от KSpread в HTML +Name[br]=Sil ezporzh HTML evit KSpread +Name[bs]=HTML Export Filter za KSpread +Name[ca]=Filtre d'exportació HTML per a KSpread +Name[cs]=HTML exportní filtr pro KSpread +Name[cy]=Hidlen Allforio HTML i KSpread +Name[da]=HTML-eksportfilter for KSpread +Name[de]=KSpread HTML-Exportfilter +Name[el]=Φίλτρο εξαγωγής HTML για το KSpread +Name[eo]=HTML-eksportfiltrilo por KSpread +Name[es]=Filtro de exportación HTML para KSpread +Name[et]=KSpreadi HTML-i ekspordifilter +Name[eu]=KSpread-en HTML esportaziorako iragazkia +Name[fa]=پالایۀ صادرات زنگام برای KSpread +Name[fi]=HTML-vientisuodin KSpeadiin +Name[fr]=Filtre d'exportation HTML de KSpread +Name[fy]=HTML-Eksportfilter foar KSpread +Name[ga]=Scagaire Easpórtála HTML le haghaidh KSpread +Name[gl]=Filtro de Exportación de HTML para KSpread +Name[he]=מסנן ייצוא מ־KSpread ל־HTML +Name[hi]=के-स्प्रेड के लिए एचटीएमएल निर्यात छननी +Name[hr]=HTML filtar izvoza za KSpread +Name[hu]=HTML exportszűrő a KSpreadhez +Name[is]=HTML útflutningssía fyrir KSpread +Name[it]=Filtro di esportazione HTML per KSpread +Name[ja]=KSpread HTML エクスポートフィルタ +Name[km]=តម្រង​នាំចេញ HTML សម្រាប់ KSpread +Name[lo]= ຕົວຕອງການສົ່ງອອກ HTML ຂອງກະດາດຄຳນວນ K +Name[lt]=HTML eksporto filtras skirtas KSpread +Name[lv]=HTML eksporta filtrs priekš KSpread +Name[ms]=Penapis Eksport HTML bagi KSpread +Name[mt]=Filtru għall-esportazzjoni ta' fajls HTML minn ġo KSpread +Name[nb]=HTML-eksportfilter for KSpread +Name[nds]=HTML-Exportfilter för KSpread +Name[ne]=केडीई स्प्रिेडका लागि एचटीएमएल निर्यात फिल्टर +Name[nl]=HTML-Exportfilter voor KSpread +Name[nn]=HTML-eksportfilter for KSpread +Name[pl]=Filtr eksportu do formatu HTML dla KSpread +Name[pt]=Filtro de Exportação de HTML para o KSpread +Name[pt_BR]=Filtro de Exportação HTML para o KSpread +Name[ro]=Filtru exportare KSpread pentru HTML +Name[ru]=Фильтр экспорта таблиц KSpread в HTML +Name[se]=KSpread:a HTML-olggosfievrridansilli +Name[sk]=HTML filter pre export z KSpread +Name[sl]=Izvozni filter HTML za Kspread +Name[sr]=KSpread-ов филтер за извоз у HTML +Name[sr@Latn]=KSpread-ov filter za izvoz u HTML +Name[sv]=HTML-exportfilter för Kspread +Name[ta]=KSpread HTML ஏற்றுமதி வடிகட்டி +Name[tg]=Филтри Содироти HTML барои KSpread +Name[th]=ตัวกรองการส่งออก HTML ของกระดาษคำนวณ K +Name[tr]=KSpread için HTML Aktarma Filtresi +Name[uk]=Фільтр експорту HTML для KSpread +Name[uz]=KSpread uchun HTML eksport filteri +Name[uz@cyrillic]=KSpread учун HTML экспорт филтери +Name[ven]=Filithara yau u bvisela nga nnda ya HTML ya u phadaladza ha K +Name[wa]=Passete HTML di rexhowe po KSpread +Name[xh]=HTML Yesihluzi Sokurhweba ngaphandle se KSpread +Name[zh_CN]=KSpread 的 HTML 导出过滤器 +Name[zh_TW]=KSpread 的 HTML 匯出過濾程式 +Name[zu]=HTML IceboExport Filter for KSpread +X-KDE-Export=text/html +X-KDE-Import=application/x-kspread +X-KDE-Weight=50 +X-KDE-Library=libkspreadhtmlexport +ServiceTypes=KOfficeFilter diff --git a/filters/kspread/html/status.html b/filters/kspread/html/status.html new file mode 100644 index 00000000..a625bfd2 --- /dev/null +++ b/filters/kspread/html/status.html @@ -0,0 +1,173 @@ + + + + + KOffice filters status: HTML FILTER + + +  + +
+
+

+ KOffice filters status:   HTML - Hypertext Markup Language +

+
+ +
+ + + Import | + Export + + +


+
+ +Up +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Import HTML for kspread
+
+
+
Last update?
Features?
Todo + ? +
History?
Authors?
Links?
Progress report ?
+
+
+Up + +


+ +
+


+ + +
+ +
+ +Up +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
Export kspread to HTML

+
+
Last update7 April 2005 by Bram Schoenmakers
Features +
    +
  • User can select which sheet(s) to export
  • +
  • Borders are optional
  • +
  • Cell spacing is configurable
  • +
  • Background color cells
  • +
  • Cell width/height
  • +
  • Option between all-in-one page or one sheet per page
  • +
  • User can select encoding
  • +
+
Todo
    +
  • Text fonts
  • +
  • Row-/colspan cells
  • +
+
History-
Authors + Eva Brucherseifer  
+ Bram Schoenmakers
+ This filter is based on the CSV filter by + David Faure and + Werner Trobin. +
Links-
Progress report ---
+
+
+Up + + + -- cgit v1.2.1