Warning, file /office/calligra/libs/flake/KoOdfWorkaround.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2009 Thorsten Zachmann <zachmann@kde.org> 0003 Copyright (C) 2011 Jan Hambrecht <jaham@gmx.net> 0004 Copyright (C) 2011 Lukáš Tvrdý <lukas.tvrdy@ixonos.com> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #ifndef KOODFWORKAROUND_H 0023 #define KOODFWORKAROUND_H 0024 0025 #include "flake_export.h" 0026 #include "KoTextShapeDataBase.h" 0027 #include <qnamespace.h> 0028 0029 #include <QSharedPointer> 0030 0031 class KoXmlElement; 0032 class KoShape; 0033 class KoShapeLoadingContext; 0034 class QPen; 0035 class QColor; 0036 class QString; 0037 class KoColorBackground; 0038 0039 /** 0040 * This class should contain all workarounds to correct problems with different ODF 0041 * implementations. If you need to access application specific things please create a 0042 * new namespace in the application you need it in 0043 * All calls to methods of this class should be wrapped into ifndefs like e.g. 0044 * 0045 * @code 0046 * #ifndef NWORKAROUND_ODF_BUGS 0047 * KoOdfWorkaround::fixPenWidth(pen, context); 0048 * #endif 0049 * @endcode 0050 */ 0051 namespace KoOdfWorkaround 0052 { 0053 /** 0054 * OpenOffice rotates counterclockwize while odf/svg spec says clockwize, 0055 * and OO also uses 'rad' as default unit while odf specifies 'deg'. 0056 * See https://bugs.documentfoundation.org/show_bug.cgi?id=48342 0057 */ 0058 FLAKE_EXPORT void fixRotate(QStringList ¶ms, KoShapeLoadingContext &context); 0059 0060 /** 0061 * OpenOffice skews counterclockwize while odf/svg spec says clockwize, 0062 * and OO also uses 'rad' as default unit while odf specifies 'deg'. 0063 */ 0064 FLAKE_EXPORT void fixSkew(QStringList ¶ms, KoShapeLoadingContext &context); 0065 0066 /** 0067 * OpenOffice handles a line with the width of 0 as a cosmetic line but in svg it makes the line invisible. 0068 * To show it in calligra use a very small line width. However this is not a cosmetic line. 0069 */ 0070 FLAKE_EXPORT void fixPenWidth(QPen &pen, KoShapeLoadingContext &context); 0071 0072 /** 0073 * OpenOffice < 3.0 does not store the draw:enhanced-path for draw:type="ellipse" 0074 * Add the path needed for the ellipse 0075 */ 0076 FLAKE_EXPORT void fixEnhancedPath(QString &path, const KoXmlElement &element, KoShapeLoadingContext &context); 0077 0078 /** 0079 * OpenOffice interchanges the position coordinates for polar handles. 0080 * According to the specification the first coordinate is the angle, the 0081 * second coordinates is the radius. OpenOffice does it the other way around. 0082 */ 0083 FLAKE_EXPORT void fixEnhancedPathPolarHandlePosition(QString &position, const KoXmlElement &element, KoShapeLoadingContext &context); 0084 0085 FLAKE_EXPORT bool fixMissingStroke(QPen &pen, const KoXmlElement &element, KoShapeLoadingContext &context, const KoShape *shape = 0); 0086 FLAKE_EXPORT QColor fixMissingFillColor(const KoXmlElement &element, KoShapeLoadingContext &context); 0087 FLAKE_EXPORT bool fixMissingStyle_DisplayLabel(const KoXmlElement &element, KoShapeLoadingContext &context); 0088 0089 FLAKE_EXPORT QSharedPointer<KoColorBackground> fixBackgroundColor(const KoShape *shape, KoShapeLoadingContext &context); 0090 0091 /** 0092 * Old versions of ooimpress does not set the placeholder for shapes that should have it set 0093 * See open office issue http://www.openoffice.org/issues/show_bug.cgi?id=96406 0094 * And kde bug https://bugs.kde.org/show_bug.cgi?id=185354 0095 */ 0096 FLAKE_EXPORT void setFixPresentationPlaceholder(bool fix, KoShapeLoadingContext &context); 0097 FLAKE_EXPORT bool fixPresentationPlaceholder(); 0098 FLAKE_EXPORT void fixPresentationPlaceholder(KoShape *shape); 0099 0100 /** 0101 * OpenOffice and LibreOffice save gluepoint positions wrong when no align is specified. 0102 * According to the specification for the above situation, the position should be saved 0103 * as percent values relative to the shapes center point. OpenOffice seems to write 0104 * these percent values converted to length units, where the millimeter value corresponds 0105 * to the correct percent value (i.e. -5cm = -50mm = -50%). 0106 */ 0107 FLAKE_EXPORT void fixGluePointPosition(QString &positionString, KoShapeLoadingContext &context); 0108 0109 /** 0110 * OpenOffice and LibreOffice does not conform to the specification about default value 0111 * of the svg:fill-rule. If this attribute is missing, according the spec, the initial 0112 * value is nonzero, but OOo uses evenodd. Because we are conform to the spec, we need 0113 * to set what OOo display. 0114 * See http://www.w3.org/TR/SVG/painting.html#FillRuleProperty 0115 */ 0116 FLAKE_EXPORT void fixMissingFillRule(Qt::FillRule &fillRule, KoShapeLoadingContext &context); 0117 0118 /** 0119 * OpenOffice resizes text shapes with autogrow in both directions. If the text box is saved to 0120 * small the text will not fit and it needs to be adjusted during the first layout. 0121 * This methods returns true if we need to adjust the layout. The adjusting is handled at a different place. 0122 */ 0123 FLAKE_EXPORT bool fixAutoGrow(KoTextShapeDataBase::ResizeMethod method, KoShapeLoadingContext &context); 0124 0125 /** 0126 * OpenOffice and LibreOffice do not set the svg:width, svg:height, svg:x and svg:y correctly when saving 0127 * parts of draw:ellipses or draw:circle 0128 * This method returns true when the width, height, x and y is given for the full circle 0129 */ 0130 FLAKE_EXPORT bool fixEllipse(const QString &kind, KoShapeLoadingContext &context); 0131 0132 /** 0133 * Calligra did use the bad strings "Formula.hidden" and "protected Formula.hidden" as values 0134 * for style:cell-protect, instead of "formula-hidden" and "protected formula-hidden". 0135 * This method fixes the bad strings to the correct ones. 0136 */ 0137 FLAKE_EXPORT void fixBadFormulaHiddenForStyleCellProtect(QString &value); 0138 0139 /** 0140 * Calligra used to store text:time-value with a "0-00-00T" prefix 0141 * This method removes that prefix. 0142 */ 0143 FLAKE_EXPORT void fixBadDateForTextTime(QString &value); 0144 0145 /** 0146 * OpenOffice.org used to write the "rect(...)" value for fo:clip without 0147 * separating the 4 offset values by commas. 0148 * This method changes the string with the offset values to have commas as separators. 0149 */ 0150 FLAKE_EXPORT void fixClipRectOffsetValuesString(QString &offsetValuesString); 0151 0152 /** 0153 * LibreOffice used to write text:style-name attribute for table:table-template element, 0154 * which is not a valid attribute for the element. 0155 */ 0156 FLAKE_EXPORT QString fixTableTemplateName(const KoXmlElement &e); 0157 0158 /** 0159 * LibreOffice used to write text:style-name attribute for 0160 * table:first-row, table:last-row, table:first-column, 0161 * table:last-column, table:odd-rows, table:odd-columns, 0162 * table:body elements, which is not a valid attribute for the element. 0163 */ 0164 FLAKE_EXPORT QString fixTableTemplateCellStyleName(const KoXmlElement &e); 0165 0166 /** 0167 * LibreOffice used to have a bug with handling of z command in svg path. 0168 * This resulted in broken marker path used (and copied also to Calligra). 0169 * This methods substitutes known old marker paths with the latest (fixed) 0170 * path variant. 0171 */ 0172 FLAKE_EXPORT void fixMarkerPath(QString &path); 0173 } 0174 0175 #endif /* KOODFWORKAROUND_H */