Commit 3ce90777 authored by Casper Boemann's avatar Casper Boemann

Move text run around attributes from Words frame class to flake's KoShape

parent ba5b4184
......@@ -101,7 +101,9 @@ KoShapePrivate::KoShapePrivate(KoShape *shape)
detectCollision(false),
protectContent(false),
cacheMode(KoShape::NoCache),
cache(0)
cache(0),
textRunAroundSide(KoShape::BiggestRunAroundSide),
textRunAroundDistance(1.0)
{
connectors.append(QPointF(0.5, 0.0));
connectors.append(QPointF(1.0, 0.5));
......@@ -764,6 +766,40 @@ QSet<KoEventAction *> KoShape::eventActions() const
return d->eventActions;
}
KoShape::TextRunAroundSide KoShape::textRunAroundSide() const
{
Q_D(const KoShape);
return d->textRunAroundSide;
}
void KoShape::setTextRunAroundSide(TextRunAroundSide side, Through runThrought)
{
Q_D(KoShape);
d->textRunAroundSide = side;
if (side == RunThrough) {
if (runThrought == Background) {
setRunThrough(-1);
} else {
setRunThrough(1);
}
} else {
setRunThrough(0);
}
}
qreal KoShape::textRunAroundDistance() const
{
Q_D(const KoShape);
return d->textRunAroundDistance;
}
void KoShape::setTextRunAroundDistance(qreal distance)
{
Q_D(KoShape);
d->textRunAroundDistance = distance;
}
void KoShape::setBackground(KoShapeBackground *fill)
{
Q_D(KoShape);
......@@ -1478,6 +1514,34 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
for (; it != d->additionalAttributes.constEnd(); ++it) {
context.xmlWriter().addAttribute(it.key().toUtf8(), it.value());
}
QString value;
switch (textRunAroundSide()) {
case BiggestRunAroundSide:
value = "biggest";
break;
case LeftRunAroundSide:
value = "left";
break;
case RightRunAroundSide:
value = "right";
break;
case AutoRunAroundSide:
value = "dynamic";
break;
case BothRunAroundSide:
value = "parallel";
break;
case NoRunAround:
value = "none";
break;
case RunThrough:
value = "run-through";
break;
}
context.xmlWriter().addAttribute("style:wrap", value);
context.xmlWriter().addAttribute("fo:margin", QString::number(textRunAroundDistance()) + "pt");
}
}
......
......@@ -132,6 +132,25 @@ public:
ScaledCache, ///< cache at every zoomlevel
};
/// The behavior text should do when intersecting this shape.
enum TextRunAroundSide {
BiggestRunAroundSide, ///< Run other text around the side that has the most space
LeftRunAroundSide, ///< Run other text around the left side of the frame
RightRunAroundSide, ///< Run other text around the right side of the frame
AutoRunAroundSide, ///< Run other text dynamically around both sides of the shape, provided there is sufficient space left
BothRunAroundSide, ///< Run other text around both sides of the shape
NoRunAround, ///< The text will be completely avoiding the frame by keeping the horizontal space that this frame occupies blank.
RunThrough ///< The text will completely ignore the frame and layout as if it was not there
};
/**
* TODO
*/
enum Through {
Background,
Foreground
};
/**
* @brief Constructor
*/
......@@ -323,6 +342,29 @@ public:
*/
QSet<KoEventAction *> eventActions() const;
/**
* Return the side text should flow around this shape.
*/
TextRunAroundSide textRunAroundSide() const;
/**
* Set the side text should flow around this shape.
* @param side the requested side
*/
void setTextRunAroundSide(TextRunAroundSide side, Through runThrought = Background);
/**
* The space between this shape's edge and text that runs around this shape.
* @return the space around this shape to keep free from text
*/
qreal textRunAroundDistance() const;
/**
* Set the space between this shape's edge and the text that run around this shape.
* @param distance the space around this shape to keep free from text
*/
void setTextRunAroundDistance(qreal distance);
/**
* Set the background of the shape.
* A shape background can be a plain color, a gradient, a pattern, be fully transparent
......
......@@ -122,6 +122,10 @@ public:
KoShapeCache *cache;
KoShape::TextRunAroundSide textRunAroundSide;
qreal textRunAroundDistance;
/**
* @return the shape cache if there is one, else 0
*/
......
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