Commit 72d18c9e authored by Thorsten Zachmann's avatar Thorsten Zachmann
Browse files

Add workaround for loading partial circles from OO

When saving a partion circle/ellipse LO/OO saved the svg:width, svg:height
svg:x and svg:y as there would be a full circle. However according to ODF the
values should be dervived from the bounding box of the displayed shape.

This fixes the problem that the circles in the file attached to the bugreport are displayed

OK to backport?

BUG: 239410
parent ff9c8a89
......@@ -256,3 +256,14 @@ bool KoOdfWorkaround::fixAutoGrow(KoTextShapeDataBase::ResizeMethod method, KoSh
return fix;
bool KoOdfWorkaround::fixEllipse(const QString &kind, KoShapeLoadingContext &context)
bool radiusGiven = false;
if (context.odfLoadingContext().generatorType() == KoOdfLoadingContext::OpenOffice) {
if (kind == "section" || kind == "arc") {
radiusGiven = true;
return radiusGiven;
......@@ -106,6 +106,13 @@ namespace KoOdfWorkaround
* This methods returns true if we need to adjust the layout. The adjusting is handled at a different place.
FLAKE_EXPORT bool fixAutoGrow(KoTextShapeDataBase::ResizeMethod method, KoShapeLoadingContext &context);
* OpenOffice and LibreOffice do not set the svg:width, svg:height, svg:x and svg:y correctly when saving
* parts of draw:ellipses or draw:circle
* This method returns true when the width, height, x and y is given for the full circle
FLAKE_EXPORT bool fixEllipse(const QString &kind, KoShapeLoadingContext &context);
......@@ -27,6 +27,7 @@
#include <KoXmlWriter.h>
#include <KoXmlNS.h>
#include <KoUnit.h>
#include <KoOdfWorkaround.h>
#include <SvgSavingContext.h>
#include <SvgLoadingContext.h>
#include <SvgUtil.h>
......@@ -92,6 +93,8 @@ bool EllipseShape::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &c
bool radiusGiven = true;
QString kind = element.attributeNS(KoXmlNS::draw, "kind", "full");
if (element.hasAttributeNS( KoXmlNS::svg, "rx") && element.hasAttributeNS(KoXmlNS::svg, "ry")) {
qreal rx = KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "rx"));
qreal ry = KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "ry"));
......@@ -102,7 +105,11 @@ bool EllipseShape::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &c
} else {
size.setWidth(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "width", QString())));
size.setHeight(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "height", QString())));
radiusGiven = KoOdfWorkaround::fixEllipse(kind, context);
radiusGiven = false;
......@@ -118,7 +125,6 @@ bool EllipseShape::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &c
QString kind = element.attributeNS(KoXmlNS::draw, "kind", "full");
if (kind == "section")
else if (kind == "cut")
Supports Markdown
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