Changeset View
Changeset View
Standalone View
Standalone View
components/impl/TextDocumentImpl.cpp
Show All 37 Lines | |||||
38 | #include <KoZoomController.h> | 38 | #include <KoZoomController.h> | ||
39 | #include <KoZoomHandler.h> | 39 | #include <KoZoomHandler.h> | ||
40 | 40 | | |||
41 | #include <QTextDocument> | 41 | #include <QTextDocument> | ||
42 | #include <QTextFrame> | 42 | #include <QTextFrame> | ||
43 | #include <QTextLayout> | 43 | #include <QTextLayout> | ||
44 | #include <QDebug> | 44 | #include <QDebug> | ||
45 | #include <QPointer> | 45 | #include <QPointer> | ||
46 | #include <QUrlQuery> | ||||
46 | 47 | | |||
47 | #include "ComponentsKoCanvasController.h" | 48 | #include "ComponentsKoCanvasController.h" | ||
48 | #include <libs/textlayout/KoTextShapeData.h> | 49 | #include <libs/textlayout/KoTextShapeData.h> | ||
49 | 50 | | |||
50 | using namespace Calligra::Components; | 51 | using namespace Calligra::Components; | ||
51 | 52 | | |||
52 | class TextDocumentImpl::Private | 53 | class TextDocumentImpl::Private | ||
53 | { | 54 | { | ||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Line(s) | 177 | { | |||
184 | setKoDocument(d->document); | 185 | setKoDocument(d->document); | ||
185 | d->part->setDocument(d->document); | 186 | d->part->setDocument(d->document); | ||
186 | 187 | | |||
187 | d->document->setAutoSave(0); | 188 | d->document->setAutoSave(0); | ||
188 | d->document->setCheckAutoSaveFile(false); | 189 | d->document->setCheckAutoSaveFile(false); | ||
189 | 190 | | |||
190 | bool retval = false; | 191 | bool retval = false; | ||
191 | if (url.scheme() == QStringLiteral("newfile")) { | 192 | if (url.scheme() == QStringLiteral("newfile")) { | ||
193 | QUrlQuery query(url); | ||||
194 | | ||||
192 | d->document->initEmpty(); | 195 | d->document->initEmpty(); | ||
193 | KWPageStyle style = d->document->pageManager()->defaultPageStyle(); | 196 | KWPageStyle style = d->document->pageManager()->defaultPageStyle(); | ||
194 | Q_ASSERT(style.isValid()); | 197 | Q_ASSERT(style.isValid()); | ||
195 | 198 | | |||
196 | KoColumns columns; | 199 | KoColumns columns; | ||
197 | columns.count = url.queryItemValue("columncount").toInt(); | 200 | columns.count = query.queryItemValue("columncount").toInt(); | ||
198 | columns.gapWidth = url.queryItemValue("columngap").toDouble(); | 201 | columns.gapWidth = query.queryItemValue("columngap").toDouble(); | ||
199 | style.setColumns(columns); | 202 | style.setColumns(columns); | ||
200 | 203 | | |||
201 | KoPageLayout layout = style.pageLayout(); | 204 | KoPageLayout layout = style.pageLayout(); | ||
202 | layout.format = KoPageFormat::formatFromString(url.queryItemValue("pageformat")); | 205 | layout.format = KoPageFormat::formatFromString(query.queryItemValue("pageformat")); | ||
203 | layout.orientation = (KoPageFormat::Orientation)url.queryItemValue("pageorientation").toInt(); | 206 | layout.orientation = (KoPageFormat::Orientation)query.queryItemValue("pageorientation").toInt(); | ||
204 | layout.height = MM_TO_POINT(url.queryItemValue("height").toDouble()); | 207 | layout.height = MM_TO_POINT(query.queryItemValue("height").toDouble()); | ||
205 | layout.width = MM_TO_POINT(url.queryItemValue("width").toDouble()); | 208 | layout.width = MM_TO_POINT(query.queryItemValue("width").toDouble()); | ||
206 | if (url.queryItemValue("facingpages").toInt() == 1) { | 209 | if (query.queryItemValue("facingpages").toInt() == 1) { | ||
207 | layout.bindingSide = MM_TO_POINT(url.queryItemValue("leftmargin").toDouble()); | 210 | layout.bindingSide = MM_TO_POINT(query.queryItemValue("leftmargin").toDouble()); | ||
208 | layout.pageEdge = MM_TO_POINT(url.queryItemValue("rightmargin").toDouble()); | 211 | layout.pageEdge = MM_TO_POINT(query.queryItemValue("rightmargin").toDouble()); | ||
209 | layout.leftMargin = layout.rightMargin = -1; | 212 | layout.leftMargin = layout.rightMargin = -1; | ||
210 | } | 213 | } | ||
211 | else { | 214 | else { | ||
212 | layout.bindingSide = layout.pageEdge = -1; | 215 | layout.bindingSide = layout.pageEdge = -1; | ||
213 | layout.leftMargin = MM_TO_POINT(url.queryItemValue("leftmargin").toDouble()); | 216 | layout.leftMargin = MM_TO_POINT(query.queryItemValue("leftmargin").toDouble()); | ||
214 | layout.rightMargin = MM_TO_POINT(url.queryItemValue("rightmargin").toDouble()); | 217 | layout.rightMargin = MM_TO_POINT(query.queryItemValue("rightmargin").toDouble()); | ||
215 | } | 218 | } | ||
216 | layout.topMargin = MM_TO_POINT(url.queryItemValue("topmargin").toDouble()); | 219 | layout.topMargin = MM_TO_POINT(query.queryItemValue("topmargin").toDouble()); | ||
217 | layout.bottomMargin = MM_TO_POINT(url.queryItemValue("bottommargin").toDouble()); | 220 | layout.bottomMargin = MM_TO_POINT(query.queryItemValue("bottommargin").toDouble()); | ||
218 | style.setPageLayout(layout); | 221 | style.setPageLayout(layout); | ||
219 | 222 | | |||
220 | d->document->setUnit(KoUnit::fromSymbol(url.queryItemValue("unit"))); | 223 | d->document->setUnit(KoUnit::fromSymbol(query.queryItemValue("unit"))); | ||
221 | d->document->relayout(); | 224 | d->document->relayout(); | ||
222 | retval = true; | 225 | retval = true; | ||
223 | } | 226 | } | ||
224 | else if (url.scheme() == QStringLiteral("template")) { | 227 | else if (url.scheme() == QStringLiteral("template")) { | ||
225 | // Nip away the manually added template:// bit of the uri passed from the caller | 228 | // Nip away the manually added template:// bit of the uri passed from the caller | ||
226 | bool ok = d->document->loadNativeFormat(url.toString().mid(11)); | 229 | bool ok = d->document->loadNativeFormat(url.toString().mid(11)); | ||
227 | d->document->setModified(false); | 230 | d->document->setModified(false); | ||
228 | d->document->undoStack()->clear(); | 231 | d->document->undoStack()->clear(); | ||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |