File indexing completed on 2025-01-12 10:34:24

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2010 Nokia
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "writer.h"
0008 
0009 #include "KoGenStyles.h"
0010 
0011 Writer::Writer(KoXmlWriter& xmlWriter, KoGenStyles& kostyles,
0012                bool stylesxml_)
0013         : xOffset(0),
0014         yOffset(0),
0015         scaleX(1),
0016         scaleY(1),
0017         g_rotation(0),
0018         g_flipH(0),
0019         g_flipV(0),
0020         xml(xmlWriter),
0021         styles(kostyles),
0022         stylesxml(stylesxml_)
0023 {
0024 }
0025 
0026 Writer Writer::transform(const QRectF& oldCoords, const QRectF &newCoords) const
0027 {
0028     Writer w(xml, styles, stylesxml);
0029     w.xOffset = xOffset + oldCoords.x() * scaleX;
0030     w.yOffset = yOffset + oldCoords.y() * scaleY;
0031     w.scaleX = scaleX * oldCoords.width() / newCoords.width();
0032     w.scaleY = scaleY * oldCoords.height() / newCoords.height();
0033     w.xOffset -= w.scaleX * newCoords.x();
0034     w.yOffset -= w.scaleY * newCoords.y();
0035     w.g_rotation = g_rotation;
0036     w.g_flipH = g_flipH;
0037     w.g_flipV = g_flipV;
0038     return w;
0039 }
0040 
0041 qreal Writer::vLength(qreal length) const
0042 {
0043     return length*scaleY;
0044 }
0045 
0046 qreal Writer::hLength(qreal length) const
0047 {
0048     return length*scaleX;
0049 }
0050 
0051 qreal Writer::vOffset(qreal offset) const
0052 {
0053     return yOffset + offset*scaleY;
0054 }
0055 
0056 qreal Writer::hOffset(qreal offset) const
0057 {
0058     return xOffset + offset*scaleX;
0059 }