1 /* This file is part of the KDE project
2  * Copyright (C) 2011 Thorsten Zachmann <zachmann@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include "KoTextSoftPageBreak.h"
21 
22 #include <KoShapeSavingContext.h>
23 #include <KoXmlReader.h>
24 #include <KoXmlWriter.h>
25 
26 #include <QTextInlineObject>
27 #include <QPainter>
28 
29 // Include Q_UNSUSED classes, for building on Windows
30 #include <KoShapeLoadingContext.h>
31 
KoTextSoftPageBreak()32 KoTextSoftPageBreak::KoTextSoftPageBreak()
33 {
34 }
35 
~KoTextSoftPageBreak()36 KoTextSoftPageBreak::~KoTextSoftPageBreak()
37 {
38 }
39 
loadOdf(const KoXmlElement & element,KoShapeLoadingContext & context)40 bool KoTextSoftPageBreak::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context)
41 {
42     Q_UNUSED(element)
43     Q_UNUSED(context)
44     return true;
45 }
46 
saveOdf(KoShapeSavingContext & context)47 void KoTextSoftPageBreak::saveOdf(KoShapeSavingContext &context)
48 {
49     KoXmlWriter &writer = context.xmlWriter();
50     writer.startElement("text:soft-page-break");
51     writer.endElement();
52 }
53 
updatePosition(const QTextDocument * document,int posInDocument,const QTextCharFormat & format)54 void KoTextSoftPageBreak::updatePosition(const QTextDocument *document,
55                                          int posInDocument, const QTextCharFormat &format)
56 {
57     Q_UNUSED(document)
58     Q_UNUSED(posInDocument)
59     Q_UNUSED(format)
60 }
61 
resize(const QTextDocument * document,QTextInlineObject & object,int posInDocument,const QTextCharFormat & format,QPaintDevice * pd)62 void KoTextSoftPageBreak::resize(const QTextDocument *document, QTextInlineObject &object,
63                                  int posInDocument, const QTextCharFormat &format, QPaintDevice *pd)
64 {
65     Q_UNUSED(document)
66     Q_UNUSED(object)
67     Q_UNUSED(posInDocument)
68     Q_UNUSED(format)
69     Q_UNUSED(pd)
70     object.setWidth(0); // set the width to 0 as otherwise it is negative which results in the text being moved to left
71     object.setAscent(0);
72     object.setDescent(0);
73 }
74 
paint(QPainter & painter,QPaintDevice * pd,const QTextDocument * document,const QRectF & rect,const QTextInlineObject & object,int posInDocument,const QTextCharFormat & format)75 void KoTextSoftPageBreak::paint(QPainter &painter, QPaintDevice *pd, const QTextDocument *document,
76                                 const QRectF &rect, const QTextInlineObject &object, int posInDocument, const QTextCharFormat &format)
77 {
78     Q_UNUSED(painter)
79     Q_UNUSED(pd)
80     Q_UNUSED(document)
81     Q_UNUSED(rect)
82     Q_UNUSED(object)
83     Q_UNUSED(posInDocument)
84     Q_UNUSED(format)
85     // TODO have a way to display the soft page break
86 }
87