Changeset View
Changeset View
Standalone View
Standalone View
filters/karbon/image/ImageExport.cpp
Show All 34 Lines | |||||
35 | 35 | | |||
36 | #include <KoShapePainter.h> | 36 | #include <KoShapePainter.h> | ||
37 | #include <KoFilter.h> | 37 | #include <KoFilter.h> | ||
38 | #include <KoFilterChain.h> | 38 | #include <KoFilterChain.h> | ||
39 | #include <KoFilterManager.h> | 39 | #include <KoFilterManager.h> | ||
40 | #include <KoZoomHandler.h> | 40 | #include <KoZoomHandler.h> | ||
41 | #include <KoUnit.h> | 41 | #include <KoUnit.h> | ||
42 | #include <KoDialog.h> | 42 | #include <KoDialog.h> | ||
43 | #include <KoPAPageBase.h> | ||||
43 | 44 | | |||
44 | #include <kpluginfactory.h> | 45 | #include <kpluginfactory.h> | ||
45 | 46 | | |||
46 | #include <QImage> | 47 | #include <QImage> | ||
47 | 48 | | |||
48 | K_PLUGIN_FACTORY_WITH_JSON(PngExportFactory, "calligra_filter_karbon2image.json", | 49 | K_PLUGIN_FACTORY_WITH_JSON(PngExportFactory, "calligra_filter_karbon2image.json", | ||
49 | registerPlugin<ImageExport>();) | 50 | registerPlugin<ImageExport>();) | ||
50 | 51 | | |||
Show All 21 Lines | 60 | { | |||
72 | 73 | | |||
73 | KoDocument* document = m_chain->inputDocument(); | 74 | KoDocument* document = m_chain->inputDocument(); | ||
74 | if (! document) | 75 | if (! document) | ||
75 | return KoFilter::ParsingError; | 76 | return KoFilter::ParsingError; | ||
76 | 77 | | |||
77 | KarbonDocument* doc = dynamic_cast<KarbonDocument*>(document); | 78 | KarbonDocument* doc = dynamic_cast<KarbonDocument*>(document); | ||
78 | if (doc) { | 79 | if (doc) { | ||
79 | KoShapePainter painter; | 80 | KoShapePainter painter; | ||
80 | painter.setShapes(doc->shapes()); | 81 | QList<KoPAPageBase*> pages = doc->pages(); | ||
82 | if (pages.isEmpty()) { | ||||
83 | return KoFilter::WrongFormat; | ||||
84 | } | ||||
85 | // TODO: Handle multiple pages | ||||
86 | painter.setShapes(pages.at(0)->shapes()); | ||||
81 | 87 | | |||
82 | // get the bounding rect of the content | 88 | // get the bounding rect of the content | ||
83 | QRectF shapesRect = painter.contentRect(); | 89 | QRectF shapesRect = painter.contentRect(); | ||
84 | // get the size in point | 90 | // get the size in point | ||
85 | QSizeF pointSize = shapesRect.size(); | 91 | QSizeF pointSize = shapesRect.size(); | ||
86 | // get the size in pixel (100% zoom) | 92 | // get the size in pixel (100% zoom) | ||
87 | KoZoomHandler zoomHandler; | 93 | KoZoomHandler zoomHandler; | ||
88 | QSize pixelSize = zoomHandler.documentToView(pointSize).toSize(); | 94 | QSize pixelSize = zoomHandler.documentToView(pointSize).toSize(); | ||
Show All 40 Lines |