Commit 13b4abb0 authored by Thorsten Zachmann's avatar Thorsten Zachmann

o Added class for working around bugs in odf implementations

o Added workaround for bug in OO that saves a line with the width of 0
  when saving a cosmetic line.

svn path=/trunk/koffice/; revision=944793
parent 605d5587
......@@ -84,6 +84,7 @@ set(flake_SRCS
KoImageData.cpp
KoImageData_p.cpp
KoImageCollection.cpp
KoOdfWorkaround.cpp
commands/KoShapeGroupCommand.cpp
commands/KoShapeAlignCommand.cpp
commands/KoShapeBackgroundCommand.cpp
......@@ -204,6 +205,7 @@ install(
KoToolManager.h
KoToolFactory.h
KoToolRegistry.h
KoOdfWorkaround.h
DESTINATION
${INCLUDE_INSTALL_DIR} COMPONENT Devel
)
/* This file is part of the KDE project
Copyright (C) 2009 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoOdfWorkaround.h"
#include "KoShapeLoadingContext.h"
#include <KoOdfLoadingContext.h>
#include <QPen>
#include <kdebug.h>
// TODO only parse the generator string once so we don't have a string compare for every loaded shape
void KoOdfWorkaround::fixPenWidth(QPen & pen, KoShapeLoadingContext &context)
{
if (context.odfLoadingContext().generator().startsWith("OpenOffice.org") && pen.widthF() == 0.0) {
pen.setWidthF(0.5);
kDebug(30003) << "Work around OO bug with pen width 0";
}
}
/* This file is part of the KDE project
Copyright (C) 2009 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOODFWORKAROUND_H
#define KOODFWORKAROUND_H
#include "flake_export.h"
class KoShapeLoadingContext;
class QPen;
/**
* This class should contain all workarounds to correct problems with differenet ODF
* implementations. If you need to access application specifc things please inherit this
* class.
* All calls to methods of this class should be wrapped into ifndefs like e.g.
*
* #ifndef NWORKAROUND_ODF_BUGS
* KoOdfWorkaround::fixPenWidth(pen, context);
* #endif
*/
class FLAKE_EXPORT KoOdfWorkaround
{
public:
/**
* OpenOffice handels a line with the width of 0 as a cosmetic line but in svg it makes the line invisible.
* To show it in koffice use a very small line width. However this is not a cosmetic line.
*/
static void fixPenWidth(QPen & pen, KoShapeLoadingContext &context);
};
#endif /* KOODFWORKAROUND_H */
......@@ -43,6 +43,7 @@
#include "KoShapeShadow.h"
#include "KoEventAction.h"
#include "KoEventActionRegistry.h"
#include "KoOdfWorkaround.h"
#include <KoXmlReader.h>
#include <KoXmlWriter.h>
......@@ -981,7 +982,10 @@ KoShapeBorderModel * KoShape::loadOdfStroke(const KoXmlElement & element, KoShap
} else {
border->setColor(pen.color());
}
#ifndef NWORKAROUND_ODF_BUGS
KoOdfWorkaround::fixPenWidth(pen, context);
#endif
border->setLineWidth(pen.widthF());
border->setJoinStyle(pen.joinStyle());
border->setLineStyle(pen.style(), pen.dashPattern());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment