Changeset View
Changeset View
Standalone View
Standalone View
filters/karbon/wmf/WmfExport.cpp
Show All 27 Lines | |||||
28 | #include <KoFilterChain.h> | 28 | #include <KoFilterChain.h> | ||
29 | #include <KoShapeStroke.h> | 29 | #include <KoShapeStroke.h> | ||
30 | #include <KoShape.h> | 30 | #include <KoShape.h> | ||
31 | #include <KoShapeContainer.h> | 31 | #include <KoShapeContainer.h> | ||
32 | #include <KoColorBackground.h> | 32 | #include <KoColorBackground.h> | ||
33 | #include <KoGradientBackground.h> | 33 | #include <KoGradientBackground.h> | ||
34 | #include <KoPatternBackground.h> | 34 | #include <KoPatternBackground.h> | ||
35 | #include <KoUnit.h> | 35 | #include <KoUnit.h> | ||
36 | #include <KoPAPageBase.h> | ||||
37 | #include <KoPageLayout.h> | ||||
36 | 38 | | |||
37 | /* | 39 | /* | ||
38 | TODO: bs.wmf stroke in red with MSword and in brown with Words ?? | 40 | TODO: bs.wmf stroke in red with MSword and in brown with Words ?? | ||
39 | */ | 41 | */ | ||
40 | 42 | | |||
41 | K_PLUGIN_FACTORY_WITH_JSON(WmfExportFactory, "calligra_filter_karbon2wmf.json", | 43 | K_PLUGIN_FACTORY_WITH_JSON(WmfExportFactory, "calligra_filter_karbon2wmf.json", | ||
42 | registerPlugin<WmfExport>();) | 44 | registerPlugin<WmfExport>();) | ||
43 | 45 | | |||
Show All 34 Lines | 58 | { | |||
78 | 80 | | |||
79 | delete mWmf; | 81 | delete mWmf; | ||
80 | 82 | | |||
81 | return KoFilter::OK; | 83 | return KoFilter::OK; | ||
82 | } | 84 | } | ||
83 | 85 | | |||
84 | void WmfExport::paintDocument(KarbonDocument* document) | 86 | void WmfExport::paintDocument(KarbonDocument* document) | ||
85 | { | 87 | { | ||
86 | 88 | KoPAPageBase *page = document->pages().value(0); | |||
89 | if (!page) { | ||||
90 | return; | ||||
91 | } | ||||
87 | // resolution | 92 | // resolution | ||
88 | mDpi = 1000; | 93 | mDpi = 1000; | ||
89 | 94 | | |||
90 | QSizeF pageSize = document->pageSize(); | 95 | const KoPageLayout &layout = page->pageLayout(); | ||
96 | QSizeF pageSize(layout.width, layout.height); | ||||
91 | int width = static_cast<int>(POINT_TO_INCH(pageSize.width()) * mDpi); | 97 | int width = static_cast<int>(POINT_TO_INCH(pageSize.width()) * mDpi); | ||
92 | int height = static_cast<int>(POINT_TO_INCH(pageSize.height()) * mDpi); | 98 | int height = static_cast<int>(POINT_TO_INCH(pageSize.height()) * mDpi); | ||
93 | 99 | | |||
94 | mWmf->setDefaultDpi(mDpi); | 100 | mWmf->setDefaultDpi(mDpi); | ||
95 | mWmf->setWindow(0, 0, width, height); | 101 | mWmf->setWindow(0, 0, width, height); | ||
96 | 102 | | |||
97 | if ((pageSize.width() != 0) && (pageSize.height() != 0)) { | 103 | if ((pageSize.width() != 0) && (pageSize.height() != 0)) { | ||
98 | mScaleX = static_cast<double>(width) / pageSize.width(); | 104 | mScaleX = static_cast<double>(width) / pageSize.width(); | ||
99 | mScaleY = static_cast<double>(height) / pageSize.height(); | 105 | mScaleY = static_cast<double>(height) / pageSize.height(); | ||
100 | } | 106 | } | ||
101 | 107 | | |||
102 | QList<KoShape*> shapes = document->shapes(); | 108 | QList<KoShape*> shapes = page->shapes(); | ||
103 | qSort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); | 109 | qSort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); | ||
104 | 110 | | |||
105 | // Export layers. | 111 | // Export layers. | ||
106 | foreach(KoShape * shape, shapes) { | 112 | foreach(KoShape * shape, shapes) { | ||
107 | if (dynamic_cast<KoShapeContainer*>(shape)) | 113 | if (dynamic_cast<KoShapeContainer*>(shape)) | ||
108 | continue; | 114 | continue; | ||
109 | paintShape(shape); | 115 | paintShape(shape); | ||
110 | } | 116 | } | ||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |