From koffice-devel Thu Nov 30 11:16:58 2006 From: =?iso-8859-1?q?K=E5re_S=E4rs?= Date: Thu, 30 Nov 2006 11:16:58 +0000 To: koffice-devel Subject: Kivio Image Export Message-Id: <200611301316.58945.kare.sars () kolumbus ! fi> X-MARC-Message: https://marc.info/?l=koffice-devel&m=116489799520770 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_q2rbFk8bFeZtFdS" --Boundary-00=_q2rbFk8bFeZtFdS Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi! I have been using Kivio and want to be able to include the flowcharts in=20 OpenOffice but the export functionality only exports to bitmaps and the=20 bitmap resolution is the same as the DPI settings of the monitor (which is= =20 far too low for printing). I tried to hardcode a higher DPI in the export filter, but that generated=20 bigger boxes and lines but the font stayed the same size. So when that fail= ed=20 I made a patch that would simulate higher DPI by changing the zoom. Why=20 didn't the DPI change work? My patch: =2D removes the custom size checkbox and replases it with a DPI combobox=20 defaulting to 300 DPI. =2D makes "Objects on Page" the default as you probably only want the objec= ts if=20 you plan to include them in another document. =2D sets the default margin to 10 pixels. It would be nice to be able to export all pages at once. The filenames coul= d=20 be the names of the pages. What do you think? /K=E5re Ps. I attached the patch. The same patch can also be found at=20 http://www.kolumbus.fi/kare.sars/kivio_patch2.patch along with a kubuntu Ed= gy=20 deb (I'm compiling a 1.6.1 deb right now). --Boundary-00=_q2rbFk8bFeZtFdS Content-Type: text/x-diff; charset="us-ascii"; name="kivio_patch2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kivio_patch2.patch" diff -uwr orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexport.cpp new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexport.cpp --- orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexport.cpp 2006-10-07 16:33:03.000000000 +0300 +++ new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexport.cpp 2006-11-26 22:53:10.000000000 +0200 @@ -113,39 +113,34 @@ pageNames.append(it.current()->pageName()); } - KoZoomHandler zoom; - dlg.setPageList(pageNames); - KivioPage* page = doc.map()->firstPage(); - QSize size = QSize(zoom.zoomItX(page->paperLayout().ptWidth), zoom.zoomItY(page->paperLayout().ptHeight)); - dlg.setInitialCustomSize(size); + + dlg.setInitialDPI(300); + dlg.setInitialmargin(10); if(dlg.exec() != QDialog::Accepted) { return KoFilter::UserCancelled; } - page = doc.map()->findPage(dlg.selectedPage()); + 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()); } - if(dlg.useCustomSize()) { - QSize customSize = dlg.customSize(); - float zw = (float)customSize.width() / (float)size.width(); - float zh = (float)customSize.height() / (float)size.height(); - float z = QMIN(zw, zh); - - zoom.setZoomAndResolution(qRound(z * 100), KoGlobal::dpiX(), KoGlobal::dpiY()); - size = customSize; - } + kdDebug() << "KoGlobal::dpiX() " << KoGlobal::dpiX() << " KoGlobal::dpiY() " << KoGlobal::dpiY() << endl; int border = dlg.margin(); diff -uwr orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.cpp new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.cpp --- orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.cpp 2006-10-07 16:33:03.000000000 +0300 +++ new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.cpp 2006-11-26 23:00:05.000000000 +0200 @@ -45,36 +45,56 @@ m_mainWidget->m_pageCombo->insertStringList(pages); } -void ImageExportDialog::setInitialCustomSize(const QSize& size) +void ImageExportDialog::setInitialDPI(const int dpi) { - m_mainWidget->m_widthSpinBox->setValue(size.width()); - m_mainWidget->m_heightSpinBox->setValue(size.height()); + 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); } -QString ImageExportDialog::selectedPage() const +void ImageExportDialog::setInitialmargin(const int margin) { - return m_mainWidget->m_pageCombo->currentText(); + m_mainWidget->m_marginSpinBox->setValue(margin); } -bool ImageExportDialog::usePageBorders() const +QString ImageExportDialog::selectedPage() const { - return (m_mainWidget->m_exportAreaCombo->currentItem() == 0); + return m_mainWidget->m_pageCombo->currentText(); } -bool ImageExportDialog::useCustomSize() const +int ImageExportDialog::imageDPI() const { - return m_mainWidget->m_customSizeCheckBox->isChecked(); + 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; + } } -QSize ImageExportDialog::customSize() const +bool ImageExportDialog::usePageBorders() const { - QSize size; - size.setWidth(m_mainWidget->m_widthSpinBox->value()); - size.setHeight(m_mainWidget->m_heightSpinBox->value()); - - return size; + return (m_mainWidget->m_exportAreaCombo->currentItem() == 1); } + int ImageExportDialog::margin() const { return m_mainWidget->m_marginSpinBox->value(); diff -uwr orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.h new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.h --- orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.h 2006-10-07 16:33:03.000000000 +0300 +++ new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportdialog.h 2006-11-26 22:44:39.000000000 +0200 @@ -34,12 +34,12 @@ ImageExportDialog(QWidget* parent = 0, const char* name = 0); void setPageList(const QStringList& pages); - void setInitialCustomSize(const QSize& size); + void setInitialDPI(const int dpi); + void setInitialmargin(const int margin); QString selectedPage() const; bool usePageBorders() const; - bool useCustomSize() const; - QSize customSize() const; + int imageDPI() const; int margin() const; private: diff -uwr orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportwidget.ui new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportwidget.ui --- orig/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportwidget.ui 2006-10-07 16:33:03.000000000 +0300 +++ new/koffice-1.6.0/filters/kivio/imageexport/kivio_imageexportwidget.ui 2006-11-26 22:03:53.000000000 +0200 @@ -8,10 +8,13 @@ 0 0 - 342 - 181 + 296 + 124 + + Kivio::ImageExportWidget + unnamed @@ -19,7 +22,24 @@ 0 - + + + spacer3 + + + Vertical + + + Expanding + + + + 20 + 40 + + + + m_pageLabel @@ -27,231 +47,151 @@ Page: - + - m_pageCombo - - - - - - Complete Page + m_exportAreaLabel - - - Area of Objects on Page - - - - m_exportAreaCombo + Area to export: - + - m_exportAreaLabel + m_DPILabel - Area to export: + Bitmap DPI: + + + Set the resolution of the resulting bitmap image - + - m_customSizeCheckBox + m_marginLabel - Custom size (in pixels): + Margin (Pixels): - + - spacer1 + spacer7 Horizontal - Fixed + Expanding - 16 - 20 + 60 + 21 - + - spacer1_2 + m_marginSpinBox + + + + + spacer4_2_2 Horizontal - Fixed + Expanding - 16 + 70 20 - - - m_heightLabel - - - false - + + - Height: + 72 - - - - m_widthLabel + + + + 96 - - false + + + + 150 + + - Width: + 300 - - - - m_widthSpinBox + + + + 600 - - false + + + + 720 - - 10000 + + + + 1200 - - + - m_heightSpinBox - - - false + m_DPIcomboBox - - 10000 + + Set the resolution of the resulting bitmap image - + - spacer4 + line1 - - Horizontal + + HLine - - Expanding - - - - 41 - 20 - - - - - - spacer4_2 + + Sunken Horizontal - - Expanding - - - - 41 - 20 - - - - - - spacer3 - - - Vertical - - - Expanding - - - - 20 - 40 - - - - - - m_marginLabel + + + + + Objects on Page + + - Margin: + Complete Page - - + - m_marginSpinBox + m_exportAreaCombo - + - spacer4_2_2 - - - Horizontal - - - Expanding - - - - 165 - 20 - + m_pageCombo - + - - - - - m_customSizeCheckBox - toggled(bool) - m_widthLabel - setEnabled(bool) - - - m_customSizeCheckBox - toggled(bool) - m_widthSpinBox - setEnabled(bool) - - - m_customSizeCheckBox - toggled(bool) - m_heightLabel - setEnabled(bool) - - - m_customSizeCheckBox - toggled(bool) - m_heightSpinBox - setEnabled(bool) - - --Boundary-00=_q2rbFk8bFeZtFdS Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@kde.org https://mail.kde.org/mailman/listinfo/koffice-devel --Boundary-00=_q2rbFk8bFeZtFdS--