1 2 /* This file is part of the KDE project 3 * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or ( at your option ) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef KPRPLACEHOLDER_H 22 #define KPRPLACEHOLDER_H 23 24 #include <QString> 25 #include <QRectF> 26 27 #include "KoXmlReaderForward.h" 28 class KoXmlWriter; 29 30 class KPrPlaceholder 31 { 32 public: 33 KPrPlaceholder(); 34 ~KPrPlaceholder(); 35 36 /** 37 * @brief Load the presentation:placeholder 38 * 39 * as OO uses absolute values and in stage we use relative values for the placeholders 40 * we need to pass the page size in case the placeholder is saved in absolute values so it 41 * can be converted to relative ones. 42 */ 43 bool loadOdf( const KoXmlElement &element, const QRectF & pageSize ); 44 void saveOdf( KoXmlWriter & xmlWriter ); 45 46 QString presentationObject() const; 47 48 /** 49 * Calculate object rect according to the page size 50 * 51 * @param pageSize The size of the page 52 */ 53 QRectF rect( const QSizeF & pageSize ); 54 55 /** 56 * Fix wrongly saved data from OO 57 * 58 * fix for wrong saved data from OO somehow they save negative values for width and height sometimes 59 * It will take the values from rect to update the width or height if they are negative 60 * <style:presentation-page-layout style:name="AL10T12"> 61 * <presentation:placeholder presentation:object="title" svg:x="2.057cm" svg:y="1.743cm" svg:width="23.911cm" svg:height="3.507cm"/> 62 * <presentation:placeholder presentation:object="outline" svg:x="2.057cm" svg:y="5.838cm" svg:width="11.669cm" svg:height="13.23cm"/> 63 * <presentation:placeholder presentation:object="object" svg:x="14.309cm" svg:y="5.838cm" svg:width="-0.585cm" svg:height="6.311cm"/> 64 * <presentation:placeholder presentation:object="object" svg:x="14.309cm" svg:y="12.748cm" svg:width="-0.585cm" svg:height="-0.601cm"/> 65 * </style:presentation-page-layout> 66 * 67 */ 68 void fix( const QRectF & rect ); 69 70 /** 71 * Check the placeholders are identical 72 */ 73 bool operator==( const KPrPlaceholder & other ) const; 74 75 bool operator<( const KPrPlaceholder & other ) const; 76 77 /** 78 * Compare the position of the placeholder 79 */ 80 static bool comparePosition( const KPrPlaceholder & p1, const KPrPlaceholder & p2 ); 81 82 private: 83 qreal percent( const KoXmlElement & element, const char * type, qreal absolute ); 84 85 QString m_presentationObject; 86 /** 87 * Describes the position on the page as a relative value to the page size 88 * So the values should be between 0 and 100 might be bigger but does not make 89 * much sense. 90 */ 91 QRectF m_relativeSize; 92 }; 93 94 #endif /* KPRPLACEHOLDER_H */ 95