[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Kivio Image Export
From:       Kåre_Särs <kare.sars () kolumbus ! fi>
Date:       2006-11-30 11:16:58
Message-ID: 200611301316.58945.kare.sars () kolumbus ! fi
[Download RAW message or body]

Hi!

I have been using Kivio and want to be able to include the flowcharts in 
OpenOffice but the export functionality only exports to bitmaps and the 
bitmap resolution is the same as the DPI settings of the monitor (which is 
far too low for printing).

I tried to hardcode a higher DPI in the export filter, but that generated 
bigger boxes and lines but the font stayed the same size. So when that failed 
I made a patch that would simulate higher DPI by changing the zoom. Why 
didn't the DPI change work?

My patch:
- removes the custom size checkbox and replases it with a DPI combobox 
defaulting to 300 DPI.

- makes "Objects on Page" the default as you probably only want the objects if 
you plan to include them in another document.

- sets the default margin to 10 pixels.

It would be nice to be able to export all pages at once. The filenames could 
be the names of the pages. What do you think?

/Kåre

Ps. I attached the patch. The same patch can also be found at 
http://www.kolumbus.fi/kare.sars/kivio_patch2.patch along with a kubuntu Edgy 
deb (I'm compiling a 1.6.1 deb right now).

["kivio_patch2.patch" (text/x-diff)]

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 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>342</width>
-            <height>181</height>
+            <width>296</width>
+            <height>124</height>
         </rect>
     </property>
+    <property name="caption">
+        <string>Kivio::ImageExportWidget</string>
+    </property>
     <grid>
         <property name="name">
             <cstring>unnamed</cstring>
@@ -19,7 +22,24 @@
         <property name="margin">
             <number>0</number>
         </property>
-        <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+        <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>
@@ -27,231 +47,151 @@
                 <string>Page:</string>
             </property>
         </widget>
-        <widget class="KComboBox" row="0" column="2" rowspan="1" colspan="2">
+        <widget class="QLabel" row="1" column="0">
             <property name="name">
-                <cstring>m_pageCombo</cstring>
-            </property>
-        </widget>
-        <widget class="KComboBox" row="1" column="2" rowspan="1" colspan="2">
-            <item>
-                <property name="text">
-                    <string>Complete Page</string>
+                <cstring>m_exportAreaLabel</cstring>
                 </property>
-            </item>
-            <item>
                 <property name="text">
-                    <string>Area of Objects on Page</string>
-                </property>
-            </item>
-            <property name="name">
-                <cstring>m_exportAreaCombo</cstring>
+                <string>Area to export:</string>
             </property>
         </widget>
-        <widget class="QLabel" row="1" column="0" rowspan="1" colspan="2">
+        <widget class="QLabel" row="3" column="0">
             <property name="name">
-                <cstring>m_exportAreaLabel</cstring>
+                <cstring>m_DPILabel</cstring>
             </property>
             <property name="text">
-                <string>Area to export:</string>
+                <string>Bitmap DPI:</string>
+            </property>
+            <property name="toolTip" stdset="0">
+                <string>Set the resolution of the resulting bitmap image</string>
             </property>
         </widget>
-        <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="4">
+        <widget class="QLabel" row="4" column="0">
             <property name="name">
-                <cstring>m_customSizeCheckBox</cstring>
+                <cstring>m_marginLabel</cstring>
             </property>
             <property name="text">
-                <string>Custom size (in pixels):</string>
+                <string>Margin (Pixels):</string>
             </property>
         </widget>
-        <spacer row="3" column="0">
+        <spacer row="3" column="2">
             <property name="name">
-                <cstring>spacer1</cstring>
+                <cstring>spacer7</cstring>
             </property>
             <property name="orientation">
                 <enum>Horizontal</enum>
             </property>
             <property name="sizeType">
-                <enum>Fixed</enum>
+                <enum>Expanding</enum>
             </property>
             <property name="sizeHint">
                 <size>
-                    <width>16</width>
-                    <height>20</height>
+                    <width>60</width>
+                    <height>21</height>
                 </size>
             </property>
         </spacer>
-        <spacer row="4" column="0">
+        <widget class="QSpinBox" row="4" column="1">
             <property name="name">
-                <cstring>spacer1_2</cstring>
+                <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>Fixed</enum>
+                <enum>Expanding</enum>
             </property>
             <property name="sizeHint">
                 <size>
-                    <width>16</width>
+                    <width>70</width>
                     <height>20</height>
                 </size>
             </property>
         </spacer>
-        <widget class="QLabel" row="4" column="1">
-            <property name="name">
-                <cstring>m_heightLabel</cstring>
-            </property>
-            <property name="enabled">
-                <bool>false</bool>
-            </property>
+        <widget class="QComboBox" row="3" column="1">
+            <item>
             <property name="text">
-                <string>Height:</string>
+                    <string>72</string>
             </property>
-        </widget>
-        <widget class="QLabel" row="3" column="1">
-            <property name="name">
-                <cstring>m_widthLabel</cstring>
+            </item>
+            <item>
+                <property name="text">
+                    <string>96</string>
             </property>
-            <property name="enabled">
-                <bool>false</bool>
+            </item>
+            <item>
+                <property name="text">
+                    <string>150</string>
             </property>
+            </item>
+            <item>
             <property name="text">
-                <string>Width:</string>
+                    <string>300</string>
             </property>
-        </widget>
-        <widget class="QSpinBox" row="3" column="2">
-            <property name="name">
-                <cstring>m_widthSpinBox</cstring>
+            </item>
+            <item>
+                <property name="text">
+                    <string>600</string>
             </property>
-            <property name="enabled">
-                <bool>false</bool>
+            </item>
+            <item>
+                <property name="text">
+                    <string>720</string>
             </property>
-            <property name="maxValue">
-                <number>10000</number>
+            </item>
+            <item>
+                <property name="text">
+                    <string>1200</string>
             </property>
-        </widget>
-        <widget class="QSpinBox" row="4" column="2">
+            </item>
             <property name="name">
-                <cstring>m_heightSpinBox</cstring>
-            </property>
-            <property name="enabled">
-                <bool>false</bool>
+                <cstring>m_DPIcomboBox</cstring>
             </property>
-            <property name="maxValue">
-                <number>10000</number>
+            <property name="toolTip" stdset="0">
+                <string>Set the resolution of the resulting bitmap image</string>
             </property>
         </widget>
-        <spacer row="3" column="3">
+        <widget class="Line" row="2" column="0" rowspan="1" colspan="3">
             <property name="name">
-                <cstring>spacer4</cstring>
+                <cstring>line1</cstring>
             </property>
-            <property name="orientation">
-                <enum>Horizontal</enum>
+            <property name="frameShape">
+                <enum>HLine</enum>
             </property>
-            <property name="sizeType">
-                <enum>Expanding</enum>
-            </property>
-            <property name="sizeHint">
-                <size>
-                    <width>41</width>
-                    <height>20</height>
-                </size>
-            </property>
-        </spacer>
-        <spacer row="4" column="3">
-            <property name="name">
-                <cstring>spacer4_2</cstring>
+            <property name="frameShadow">
+                <enum>Sunken</enum>
             </property>
             <property name="orientation">
                 <enum>Horizontal</enum>
             </property>
-            <property name="sizeType">
-                <enum>Expanding</enum>
-            </property>
-            <property name="sizeHint">
-                <size>
-                    <width>41</width>
-                    <height>20</height>
-                </size>
-            </property>
-        </spacer>
-        <spacer row="6" column="2">
-            <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="5" column="0" rowspan="1" colspan="2">
-            <property name="name">
-                <cstring>m_marginLabel</cstring>
+        </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>Margin:</string>
+                    <string>Complete Page</string>
             </property>
-        </widget>
-        <widget class="QSpinBox" row="5" column="2">
+            </item>
             <property name="name">
-                <cstring>m_marginSpinBox</cstring>
+                <cstring>m_exportAreaCombo</cstring>
             </property>
         </widget>
-        <spacer row="5" column="3">
+        <widget class="KComboBox" row="0" column="1" rowspan="1" colspan="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>165</width>
-                    <height>20</height>
-                </size>
+                <cstring>m_pageCombo</cstring>
             </property>
-        </spacer>
+        </widget>
     </grid>
 </widget>
-<customwidgets>
-</customwidgets>
-<connections>
-    <connection>
-        <sender>m_customSizeCheckBox</sender>
-        <signal>toggled(bool)</signal>
-        <receiver>m_widthLabel</receiver>
-        <slot>setEnabled(bool)</slot>
-    </connection>
-    <connection>
-        <sender>m_customSizeCheckBox</sender>
-        <signal>toggled(bool)</signal>
-        <receiver>m_widthSpinBox</receiver>
-        <slot>setEnabled(bool)</slot>
-    </connection>
-    <connection>
-        <sender>m_customSizeCheckBox</sender>
-        <signal>toggled(bool)</signal>
-        <receiver>m_heightLabel</receiver>
-        <slot>setEnabled(bool)</slot>
-    </connection>
-    <connection>
-        <sender>m_customSizeCheckBox</sender>
-        <signal>toggled(bool)</signal>
-        <receiver>m_heightSpinBox</receiver>
-        <slot>setEnabled(bool)</slot>
-    </connection>
-</connections>
 <layoutdefaults spacing="6" margin="11"/>
 <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
 <includehints>



_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic