[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Patch to save anchors in KWord
From: Pinaraf <pinaraf () gmail ! com>
Date: 2007-08-20 19:58:38
Message-ID: 2d74a35c0708201258x655f7230j920159c564ffe726 () mail ! gmail ! com
[Download RAW message or body]
Hi
I wrote a patch to support saving anchors and their attached shapes for KWord.
Since this patch affects KoShape, I prefer having it reviewed before I
commit (I don't want to receive death threat email)
The main issue with this patch is that it adds a KoTextAnchor *
private member in KoShape. It may add a dependency from flake to
kotext, but it compiles and runs without any additionnal compilation
or linking dependency.
Thanks
Pierre
--------------------------------------------------------------------------------------------------------------
Here is the patch :
Index: kword/part/frames/KWFrame.cpp
===================================================================
--- kword/part/frames/KWFrame.cpp (révision 699400)
+++ kword/part/frames/KWFrame.cpp (copie de travail)
@@ -78,6 +78,8 @@
}
void KWFrame::saveOdf(KoShapeSavingContext & context) {
+ if (shape()->getAnchor())
+ return;
KoXmlWriter &writer = context.xmlWriter();
const bool mainTextFrame =
context.isSet(KoShapeSavingContext::MainTextFrame);
if (!mainTextFrame) {
Index: libs/flake/KoShape.h
===================================================================
--- libs/flake/KoShape.h (révision 699400)
+++ libs/flake/KoShape.h (copie de travail)
@@ -49,6 +49,7 @@
class KoShapeSavingContext;
class KoCanvasBase;
class KoShapeLoadingContext;
+class KoTextAnchor;
/**
*
@@ -606,6 +607,9 @@
*/
void deleteLater();
+ void attachAnchor (KoTextAnchor *anchor);
+ KoTextAnchor *getAnchor ();
+
protected:
/* ** loading saving helper methods */
Index: libs/flake/KoShape.cpp
===================================================================
--- libs/flake/KoShape.cpp (révision 699400)
+++ libs/flake/KoShape.cpp (copie de travail)
@@ -69,6 +69,7 @@
appData(0),
backgroundBrush(Qt::NoBrush),
border(0),
+ anchor(0),
me(shape)
{
}
@@ -117,6 +118,8 @@
QBrush backgroundBrush; ///< Stands for the background color / fill etc.
KoShapeBorderModel *border; ///< points to a border, or 0 if
there is no border
QList<KoShapeConnection*> connections;
+ KoTextAnchor *anchor;
+
KoShape *me;
};
@@ -938,7 +941,14 @@
// end loading & saving methods
+void KoShape::attachAnchor (KoTextAnchor *anchor) {
+ d->anchor = anchor;
+}
+KoTextAnchor *KoShape::getAnchor () {
+ return d->anchor;
+}
+
// static
void KoShape::applyConversion(QPainter &painter, const
KoViewConverter &converter) {
double zoomX, zoomY;
Index: libs/kotext/KoTextAnchor.h
===================================================================
--- libs/kotext/KoTextAnchor.h (révision 699400)
+++ libs/kotext/KoTextAnchor.h (copie de travail)
@@ -108,6 +108,7 @@
/// set the new offset. Causes a new layout soon.
void setOffset(const QPointF &offset);
+ void saveOdf (KoShapeSavingContext & context);
private:
class Private;
Private * const d;
Index: libs/kotext/KoTextAnchor.cpp
===================================================================
--- libs/kotext/KoTextAnchor.cpp (révision 699400)
+++ libs/kotext/KoTextAnchor.cpp (copie de travail)
@@ -22,6 +22,8 @@
#include "KoTextShapeContainerModel.h"
#include <KoShapeContainer.h>
+#include <KoXmlWriter.h>
+#include <KoShapeSavingContext.h>
#include <QTextInlineObject>
#include <QFontMetricsF>
@@ -83,6 +85,7 @@
: KoInlineObject(false),
d(new Private(this, shape))
{
+ shape->attachAnchor(this);
}
KoTextAnchor::~KoTextAnchor() {
@@ -174,3 +177,23 @@
d->relayout();
}
+void KoTextAnchor::saveOdf (KoShapeSavingContext & context) {
+ KoXmlWriter &writer = context.xmlWriter();
+ writer.startElement("draw:frame");
+ /*
+ ODF: 9.3 Frames
+ The attributes that may be associated with the <draw:frame> element are:
+ Position, Size (relative sizes, see below), Style, Layer,
Z-Index, ID, Caption ID and
+ Transformation – see section 9.2.15.
+ Text anchor, table background, draw end position – see section 9.2.16
+ Presentation class – see section 9.6.1
+ Copy frames
+ */
+
+ shape()->saveOdfFrameAttributes(context);
+ writer.addAttribute("text:anchor-type", "paragraph");
+ shape()->saveOdf(context);
+ writer.endElement();
+}
+
+
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic