Commit 55940b16 authored by C. Boemann's avatar C. Boemann

Move KoShapeAnchor from kotext to flake

This is needed to support better anchoring ui as well as paste of shapes in the
Text Tool
parent 225fa623
......@@ -32,6 +32,7 @@ set(flake_SRCS
KoPathSegment.cpp
KoSelection.cpp
KoShape.cpp
KoShapeAnchor.cpp
KoShapeBasedDocumentBase.cpp
KoShapeApplicationData.cpp
KoShapeContainer.cpp
......@@ -275,6 +276,7 @@ install(
KoRTree.h
KoSelection.h
KoShape.h
KoShapeAnchor.h
KoShapeStrokeModel.h
KoToolSelection.h
KoShapeContainer.h
......
......@@ -103,7 +103,8 @@ KoShapePrivate::KoShapePrivate(KoShape *shape)
textRunAroundDistanceRight(0.0),
textRunAroundDistanceBottom(0.0),
textRunAroundThreshold(0.0),
textRunAroundContour(KoShape::ContourFull)
textRunAroundContour(KoShape::ContourFull),
anchor(0)
{
connectors[KoConnectionPoint::TopConnectionPoint] = KoConnectionPoint::defaultConnectionPoint(KoConnectionPoint::TopConnectionPoint);
connectors[KoConnectionPoint::RightConnectionPoint] = KoConnectionPoint::defaultConnectionPoint(KoConnectionPoint::RightConnectionPoint);
......@@ -993,6 +994,18 @@ void KoShape::setTextRunAroundContour(KoShape::TextRunAroundContour contour)
d->textRunAroundContour = contour;
}
void KoShape::setAnchor(KoShapeAnchor *anchor)
{
Q_D(KoShape);
d->anchor = anchor;
}
KoShapeAnchor *KoShape::anchor() const
{
Q_D(const KoShape);
return d->anchor;
}
void KoShape::setBackground(KoShapeBackground *fill)
{
Q_D(KoShape);
......
......@@ -64,6 +64,7 @@ class KoFilterEffectStack;
class KoSnapData;
class KoClipPath;
class KoShapePaintingContext;
class KoShapeAnchor;
/**
*
......@@ -465,6 +466,16 @@ public:
*/
void setTextRunAroundContour(TextRunAroundContour contour);
/**
* Set the KoShapeAnchor
*/
void setAnchor(KoShapeAnchor *anchor);
/**
* Return the KoShapeAnchor, or 0
*/
KoShapeAnchor *anchor() const;
/**
* Set the background of the shape.
* A shape background can be a plain color, a gradient, a pattern, be fully transparent
......
......@@ -23,7 +23,6 @@
#include "KoShapeAnchor.h"
#include "KoStyleStack.h"
#include "KoOdfLoadingContext.h"
#include "KoTextRange.h"
#include <KoShapeContainer.h>
#include <KoXmlWriter.h>
......
......@@ -21,7 +21,7 @@
#ifndef KOSHAPEANCHOR_H
#define KOSHAPEANCHOR_H
#include "kotext_export.h"
#include "flake_export.h"
#include <QPointF>
......@@ -45,7 +45,8 @@ class QTextDocument;
* -as-char
* -char, paragraph anchor
*
* If it's a page anchor it just provide the info about how the shape relates to a page number.
* If it's a page anchor it just provide the info about how the shape relates to a page with a specific
* page number.
*
* For the other types of anchoring it has to have a TextLocation in a QTextDocument. This TextLocation
* can either be an inline character (type as-char) or a position (type char or paragraph) The
......@@ -58,9 +59,9 @@ class QTextDocument;
* which are both implemented as subclasses of TextLocation
*
* The position of the shape relative to the anchor is called the offset. It's loaded by loadOdf().
* @see PlacementStrategy for more information about the layout of anchors/shapes in Words.
* @see PlacementStrategy for more information about the layout of anchors/shapes.
*/
class KOTEXT_EXPORT KoShapeAnchor
class FLAKE_EXPORT KoShapeAnchor
{
public:
/**
......@@ -71,7 +72,12 @@ public:
PlacementStrategy(){};
virtual ~PlacementStrategy(){};
/**
* Reparent the anchored shape to not have a parent shape container (and model)
*
*/
virtual void detachFromModel() = 0;
/**
* Reparent the anchored shape under an appropriate shape container (and model)
*
......
......@@ -98,6 +98,7 @@ public:
qreal textRunAroundDistanceBottom;
qreal textRunAroundThreshold;
KoShape::TextRunAroundContour textRunAroundContour;
KoShapeAnchor *anchor;
/// Convert connection point position from shape coordinates, taking alignment into account
void convertFromShapeCoordinates(KoConnectionPoint &point, const QSizeF &shapeSize) const;
......
......@@ -41,7 +41,6 @@ set(kotext_LIB_SRCS
KoSection.cpp
KoTextLocator.cpp
KoTextReference.cpp
KoShapeAnchor.cpp
KoAnchorInlineObject.cpp
KoAnchorTextRange.cpp
KoTextShapeSavingContext.cpp
......@@ -170,7 +169,6 @@ install(
KoInlineTextObjectManager.h
KoAnchorInlineObject.h
KoAnchorTextRange.h
KoShapeAnchor.h
KoTextBlockBorderData.h
KoTextBlockData.h
KoTextDocument.h
......
......@@ -1464,7 +1464,8 @@ KoShape *KoTextLoader::loadShape(const KoXmlElement &element, QTextCursor &curso
KoShapeAnchor *anchor = new KoShapeAnchor(shape);
anchor->loadOdf(element, d->context);
d->textSharedData->shapeInserted(shape, element, d->context, anchor);
shape->setAnchor(anchor);
d->textSharedData->shapeInserted(shape, element, d->context);
// page anchored shapes are handled differently
if (anchor->anchorType() == KoShapeAnchor::AnchorPage && shape->hasAdditionalAttribute("text:anchor-page-number")) {
......
......@@ -654,11 +654,10 @@ KoOdfBibliographyConfiguration KoTextSharedLoadingData::bibliographyConfiguratio
return d->bibliographyConfiguration;
}
void KoTextSharedLoadingData::shapeInserted(KoShape *shape, const KoXmlElement &element, KoShapeLoadingContext &/*context*/, KoShapeAnchor *anchor)
void KoTextSharedLoadingData::shapeInserted(KoShape *shape, const KoXmlElement &element, KoShapeLoadingContext &/*context*/)
{
d->insertedShapes.append(shape);
Q_UNUSED(element);
Q_UNUSED(anchor);
}
QList<KoShape *> KoTextSharedLoadingData::insertedShapes() const
......
......@@ -195,7 +195,7 @@ protected:
* @param shape a shape that has finished loading.
* @param element the xml element that represents the shape being inserted.
*/
virtual void shapeInserted(KoShape *shape, const KoXmlElement &element, KoShapeLoadingContext &context, KoShapeAnchor *anchor);
virtual void shapeInserted(KoShape *shape, const KoXmlElement &element, KoShapeLoadingContext &context);
private:
enum StyleType {
......
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