diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /filters/kivio | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
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
Diffstat (limited to 'filters/kivio')
-rw-r--r-- | filters/kivio/Makefile.am | 1 | ||||
-rw-r--r-- | filters/kivio/imageexport/Makefile.am | 18 | ||||
-rw-r--r-- | filters/kivio/imageexport/kivio_image_export.desktop | 52 | ||||
-rw-r--r-- | filters/kivio/imageexport/kivio_imageexport.cpp | 178 | ||||
-rw-r--r-- | filters/kivio/imageexport/kivio_imageexport.h | 39 | ||||
-rw-r--r-- | filters/kivio/imageexport/kivio_imageexportdialog.cpp | 105 | ||||
-rw-r--r-- | filters/kivio/imageexport/kivio_imageexportdialog.h | 51 | ||||
-rw-r--r-- | filters/kivio/imageexport/kivio_imageexportwidget.ui | 203 |
8 files changed, 647 insertions, 0 deletions
diff --git a/filters/kivio/Makefile.am b/filters/kivio/Makefile.am new file mode 100644 index 00000000..4130552b --- /dev/null +++ b/filters/kivio/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = imageexport
\ No newline at end of file diff --git a/filters/kivio/imageexport/Makefile.am b/filters/kivio/imageexport/Makefile.am new file mode 100644 index 00000000..dce78335 --- /dev/null +++ b/filters/kivio/imageexport/Makefile.am @@ -0,0 +1,18 @@ +INCLUDES = -I$(srcdir) $(KOFFICE_INCLUDES) \ + -I$(top_srcdir)/kivio/kiviopart \ + -I$(top_srcdir)/kivio/kiviopart/kiviosdk \ + -I$(top_srcdir)/kivio/kiviopart/config \ + -I$(top_builddir)/kivio/kiviopart/config \ + $(all_includes) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = libkivioimageexport.la + +libkivioimageexport_la_SOURCES = kivio_imageexport.cpp \ + kivio_imageexportwidget.ui kivio_imageexportdialog.cpp +libkivioimageexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined +libkivioimageexport_la_LIBADD = $(top_builddir)/kivio/kiviopart/libkiviocommon.la $(KOFFICE_LIBS) + +service_DATA = kivio_image_export.desktop +servicedir = $(kde_servicesdir) diff --git a/filters/kivio/imageexport/kivio_image_export.desktop b/filters/kivio/imageexport/kivio_image_export.desktop new file mode 100644 index 00000000..ad5a52d9 --- /dev/null +++ b/filters/kivio/imageexport/kivio_image_export.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Type=Service +Name=Kivio Image Export Filter +Name[ar]=مرشح تصدير Image لدى Kivio +Name[bg]=Филтър за експортиране на изображения в Kivio +Name[br]=Sil ezporzh skeudenn evit Kivio +Name[ca]=Filtre d'exportació d'imatges per a Kivio +Name[da]=Kivio billedeksportfilter +Name[de]=Kivio Bild-Exportfilter +Name[el]=Φίλτρο εξαγωγής εικόνας του Kivio +Name[eo]=Kivio-bildeksportfiltrilo +Name[es]=Filtro de exportación a imagen de Kivio +Name[et]=Kivio pildi ekspordifilter +Name[fa]=پالایۀ صادرات تصویر Kivio +Name[fi]=Kivio kuva -vientisuodin +Name[fr]=Filtre d'exportation d'images de Kivio +Name[fy]=Kiviofilter foar ôfbylding-eksport +Name[ga]=Scagaire Easpórtála Íomhá Kivio +Name[gl]=Filtro de Exportación de Imaxe para Kivio +Name[he]=Kivio מסנן יצוא תמונה +Name[hr]=Kivio filtar izvoza slika +Name[hu]=Kivio képexportáló szűrő +Name[is]=Kivio mynd útflutningssía +Name[it]=Filtro di esportazione delle immagini di Kivio +Name[ja]=Kivio 画像 エクスポートフィルタ +Name[km]=តម្រងនាំចេញរូបភាពសម្រាប់ Kivio +Name[lt]=Kivio Image eksportavimo filtras +Name[lv]=Kivio attēla eksporta filtrs +Name[nb]=Bilde-eksportfilter for Kivio +Name[nds]=Bild-Exportfilter för Kivio +Name[ne]=किभियो छवि निर्यात फिल्टर +Name[nl]=Kivio-filter voor afbeeldingsexport +Name[pl]=Filtr eksportu do obrazków z Kivio +Name[pt]=Filtro de Exportação de Imagem para o Kivio +Name[pt_BR]=Filtro de Exportação de Imagem para o Kivio +Name[ru]=Фильтр экспорта схем Kivio +Name[se]=Kivio govvaolggosfievrridansilli +Name[sk]=Exportný filter obrázkov Kivio +Name[sl]=Izvozni filter za slike za Kivio +Name[sr]=Kivio-ов филтер за извоз слика +Name[sr@Latn]=Kivio-ov filter za izvoz slika +Name[sv]=Kivio bildexportfilter +Name[uk]=Фільтр експорту зображення для Kivio +Name[uz]=Kivio rasm eksport filteri +Name[uz@cyrillic]=Kivio расм экспорт филтери +Name[zh_CN]=Kivio 图像导出过滤器 +Name[zh_TW]=Kivio 圖片匯出過濾程式 +X-KDE-Import=application/x-kivio +X-KDE-Export=image/png,image/jpeg,image/x-bmp +X-KDE-Weight=1 +X-KDE-Library=libkivioimageexport +ServiceTypes=KOfficeFilter diff --git a/filters/kivio/imageexport/kivio_imageexport.cpp b/filters/kivio/imageexport/kivio_imageexport.cpp new file mode 100644 index 00000000..e5a6600c --- /dev/null +++ b/filters/kivio/imageexport/kivio_imageexport.cpp @@ -0,0 +1,178 @@ +/* This file is part of the KDE project + Copyright (C) 2005-2006 Peter Simonsson <[email protected]> + Copyright (C) 2006 Kåre Särs <[email protected]> + + 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 "kivio_imageexport.h" + +#include <qdom.h> +#include <qcstring.h> +#include <qpixmap.h> +#include <qpainter.h> +#include <qsize.h> +#include <qstringlist.h> + +#include <kmessagebox.h> +#include <klocale.h> +#include <kgenericfactory.h> +#include <kdebug.h> + +#include <KoStore.h> +#include <KoFilterChain.h> +#include <KoZoomHandler.h> + +#include "kivio_doc.h" +#include "kivio_page.h" +#include "kivio_map.h" +#include "kivio_screen_painter.h" + +#include "kivio_imageexportdialog.h" + +typedef KGenericFactory<Kivio::ImageExport, KoFilter> KivioImageExportFactory; +K_EXPORT_COMPONENT_FACTORY( libkivioimageexport, KivioImageExportFactory("KivioImageExport") ) + +namespace Kivio +{ + +ImageExport::ImageExport(KoFilter *, const char *, const QStringList&) + : KoFilter() +{ + KGlobal::locale()->insertCatalogue("kofficefilters"); +} + +KoFilter::ConversionStatus ImageExport::convert(const QCString& from, const QCString& to) +{ + if(from != "application/x-kivio") { + return KoFilter::BadMimeType; + } + + QString format; + + if(to == "image/png") { + format = "PNG"; + } else if(to == "image/jpeg") { + format = "JPEG"; + } else if(to == "image/x-bmp") { + format = "BMP"; + } else if(to == "image/x-eps") { + format = "EPS"; + } else if(to == "image/x-portable-bitmap") { + format = "PBM"; + } else if(to == "image/x-pcx") { + format = "PCX"; + } else if(to == "image/x-portable-pixmap") { + format = "PPM"; + } else if(to == "image/x-rgb") { + format = "RGB"; + } else if(to == "image/x-xpm") { + format = "XPM"; + } else if(to == "image/jp2") { + format = "JP2"; + } else { + return KoFilter::BadMimeType; + } + + KoStoreDevice* storeIn = m_chain->storageFile("root", KoStore::Read); + + if (!storeIn) { + KMessageBox::error(0, i18n("Failed to read data."), i18n( "Export Error" )); + return KoFilter::FileNotFound; + } + + // Get the XML tree. + QDomDocument domIn; + domIn.setContent(storeIn); + + KivioDoc doc; + + if(!doc.loadXML(0, domIn)) { + KMessageBox::error(0, i18n("Malformed XML data."), i18n("Export Error")); + return KoFilter::WrongFormat; + } + + ImageExportDialog dlg; + + QStringList pageNames; + QPtrList<KivioPage> pageList = doc.map()->pageList(); + QPtrListIterator<KivioPage> it(pageList); + + for(; it.current() != 0; ++it) { + pageNames.append(it.current()->pageName()); + } + + dlg.setPageList(pageNames); + + dlg.setInitialDPI(300); + dlg.setInitialmargin(10); + + if(dlg.exec() != QDialog::Accepted) { + return KoFilter::UserCancelled; + } + + KivioPage* page = doc.map()->findPage(dlg.selectedPage()); + + if(!page) { + kdDebug() << "The page named " << dlg.selectedPage() << " wasn't found!!" << endl; + return KoFilter::InternalError; + } + + float z = (float)dlg.imageDPI()/(float)KoGlobal::dpiX(); + KoZoomHandler zoom; + zoom.setZoomAndResolution(qRound(z * 100), KoGlobal::dpiX(), KoGlobal::dpiY()); + + QSize size; + if(dlg.usePageBorders()) { + size = QSize(zoom.zoomItX(page->paperLayout().ptWidth), zoom.zoomItY(page->paperLayout().ptHeight)); + } else { + size = zoom.zoomSize(page->getRectForAllStencils().size()); + } + + kdDebug() << "KoGlobal::dpiX() " << KoGlobal::dpiX() << " KoGlobal::dpiY() " << KoGlobal::dpiY() << endl; + + int border = dlg.margin(); + + size.setWidth(size.width() + (border * 2)); + size.setHeight(size.height() + (border * 2)); + + QPixmap pixmap = QPixmap(size); + pixmap.fill(Qt::white); + KivioScreenPainter kpainter; + kpainter.start(&pixmap); + + float translationX = border; + float translationY = border; + + if(!dlg.usePageBorders()) { + QPoint point = zoom.zoomPoint(page->getRectForAllStencils().topLeft()); + translationX -= point.x(); + translationY -= point.y(); + } + + kpainter.setTranslation(translationX, translationY); + page->printContent(kpainter, &zoom); + + if(!pixmap.save(m_chain->outputFile(), format.local8Bit())) { + return KoFilter::CreationError; + } + + return KoFilter::OK; +} + +} + +#include "kivio_imageexport.moc" diff --git a/filters/kivio/imageexport/kivio_imageexport.h b/filters/kivio/imageexport/kivio_imageexport.h new file mode 100644 index 00000000..f538ce24 --- /dev/null +++ b/filters/kivio/imageexport/kivio_imageexport.h @@ -0,0 +1,39 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Peter Simonsson <[email protected]> + + 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 KIVIO_IMAGEEXPORT_H +#define KIVIO_IMAGEEXPORT_H + +#include <KoFilter.h> + +namespace Kivio +{ + +class ImageExport : public KoFilter +{ + Q_OBJECT + public: + ImageExport(KoFilter *, const char *, const QStringList&); + + virtual KoFilter::ConversionStatus convert(const QCString& from, const QCString& to); +}; + +} + +#endif diff --git a/filters/kivio/imageexport/kivio_imageexportdialog.cpp b/filters/kivio/imageexport/kivio_imageexportdialog.cpp new file mode 100644 index 00000000..0ed61397 --- /dev/null +++ b/filters/kivio/imageexport/kivio_imageexportdialog.cpp @@ -0,0 +1,105 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Peter Simonsson <[email protected]> + + 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 "kivio_imageexportdialog.h" + +#include <qspinbox.h> +#include <qcheckbox.h> + +#include <kcombobox.h> +#include <klocale.h> +#include <kapplication.h> + +#include "kivio_imageexportwidget.h" + +namespace Kivio +{ + +ImageExportDialog::ImageExportDialog(QWidget* parent, const char* name) + : KDialogBase(parent, name, false, i18n("Export to Image"), Ok|Cancel) +{ + kapp->restoreOverrideCursor(); + m_mainWidget = new ImageExportWidget(this); + setMainWidget(m_mainWidget); +} + +void ImageExportDialog::setPageList(const QStringList& pages) +{ + m_mainWidget->m_pageCombo->clear(); + m_mainWidget->m_pageCombo->insertStringList(pages); +} + +void ImageExportDialog::setInitialDPI(const int dpi) +{ + if (dpi <= 72) m_mainWidget->m_DPIcomboBox->setCurrentItem(0); + else if (dpi <= 96) m_mainWidget->m_DPIcomboBox->setCurrentItem(1); + else if (dpi <= 150) m_mainWidget->m_DPIcomboBox->setCurrentItem(2); + else if (dpi <= 300) m_mainWidget->m_DPIcomboBox->setCurrentItem(3); + else if (dpi <= 600) m_mainWidget->m_DPIcomboBox->setCurrentItem(4); + else if (dpi <= 720) m_mainWidget->m_DPIcomboBox->setCurrentItem(5); + else if (dpi <= 1200) m_mainWidget->m_DPIcomboBox->setCurrentItem(6); +} + +void ImageExportDialog::setInitialmargin(const int margin) +{ + m_mainWidget->m_marginSpinBox->setValue(margin); +} + +QString ImageExportDialog::selectedPage() const +{ + return m_mainWidget->m_pageCombo->currentText(); +} + +int ImageExportDialog::imageDPI() const +{ + switch (m_mainWidget->m_DPIcomboBox->currentItem()) + { + case 0: + return 72; + case 1: + return 96; + case 2: + return 150; + case 3: + return 300; + case 4: + return 600; + case 5: + return 720; + case 6: + return 1200; + default: + return 300; + } +} + +bool ImageExportDialog::usePageBorders() const +{ + return (m_mainWidget->m_exportAreaCombo->currentItem() == 1); +} + + +int ImageExportDialog::margin() const +{ + return m_mainWidget->m_marginSpinBox->value(); +} + +} + +#include "kivio_imageexportdialog.moc" diff --git a/filters/kivio/imageexport/kivio_imageexportdialog.h b/filters/kivio/imageexport/kivio_imageexportdialog.h new file mode 100644 index 00000000..72d1e9ab --- /dev/null +++ b/filters/kivio/imageexport/kivio_imageexportdialog.h @@ -0,0 +1,51 @@ +/* This file is part of the KDE project + Copyright (C) 2005 Peter Simonsson <[email protected]> + + 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 KIVIO_IMAGEEXPORTDIALOG_H +#define KIVIO_IMAGEEXPORTDIALOG_H + +#include <kdialogbase.h> + +namespace Kivio +{ + +class ImageExportWidget; + +class ImageExportDialog : public KDialogBase +{ + Q_OBJECT + public: + ImageExportDialog(QWidget* parent = 0, const char* name = 0); + + void setPageList(const QStringList& pages); + void setInitialDPI(const int dpi); + void setInitialmargin(const int margin); + + QString selectedPage() const; + bool usePageBorders() const; + int imageDPI() const; + int margin() const; + + private: + ImageExportWidget* m_mainWidget; +}; + +} + +#endif diff --git a/filters/kivio/imageexport/kivio_imageexportwidget.ui b/filters/kivio/imageexport/kivio_imageexportwidget.ui new file mode 100644 index 00000000..00241fcf --- /dev/null +++ b/filters/kivio/imageexport/kivio_imageexportwidget.ui @@ -0,0 +1,203 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>Kivio::ImageExportWidget</class> +<widget class="QWidget"> + <property name="name"> + <cstring>Kivio::ImageExportWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>296</width> + <height>132</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <spacer row="5" column="1"> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>m_pageLabel</cstring> + </property> + <property name="text"> + <string>Page:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>m_exportAreaLabel</cstring> + </property> + <property name="text"> + <string>Area to export:</string> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>m_DPILabel</cstring> + </property> + <property name="text"> + <string>Bitmap DPI:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Set the resolution of the resulting bitmap image</string> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>m_marginLabel</cstring> + </property> + <property name="text"> + <string>Margin (Pixels):</string> + </property> + </widget> + <spacer row="3" column="2"> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>60</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QSpinBox" row="4" column="1"> + <property name="name"> + <cstring>m_marginSpinBox</cstring> + </property> + </widget> + <spacer row="4" column="2"> + <property name="name"> + <cstring>spacer4_2_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>70</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QComboBox" row="3" column="1"> + <item> + <property name="text"> + <string>72</string> + </property> + </item> + <item> + <property name="text"> + <string>96</string> + </property> + </item> + <item> + <property name="text"> + <string>150</string> + </property> + </item> + <item> + <property name="text"> + <string>300</string> + </property> + </item> + <item> + <property name="text"> + <string>600</string> + </property> + </item> + <item> + <property name="text"> + <string>720</string> + </property> + </item> + <item> + <property name="text"> + <string>1200</string> + </property> + </item> + <property name="name"> + <cstring>m_DPIcomboBox</cstring> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Set the resolution of the resulting bitmap image</string> + </property> + </widget> + <widget class="Line" row="2" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>line1</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="KComboBox" row="1" column="1" rowspan="1" colspan="2"> + <item> + <property name="text"> + <string>Objects on Page</string> + </property> + </item> + <item> + <property name="text"> + <string>Complete Page</string> + </property> + </item> + <property name="name"> + <cstring>m_exportAreaCombo</cstring> + </property> + </widget> + <widget class="KComboBox" row="0" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>m_pageCombo</cstring> + </property> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +<includehints> + <includehint>kcombobox.h</includehint> + <includehint>kcombobox.h</includehint> +</includehints> +</UI> |