Commit 7f1af03b authored by Thomas Zander's avatar Thomas Zander

Move code to private, make some loading methods const.

svn path=/trunk/koffice/; revision=1083171
parent bebba0e0
......@@ -158,6 +158,20 @@ void KoShapePrivate::removeShapeManager(KoShapeManager *manager)
{
shapeManagers.remove(manager);
}
// static
QString KoShapePrivate::getStyleProperty(const char *property, const KoXmlElement & element, KoShapeLoadingContext & context)
{
Q_UNUSED(element);
KoStyleStack &styleStack = context.odfLoadingContext().styleStack();
QString value;
if (styleStack.hasProperty(KoXmlNS::draw, property)) {
value = styleStack.property(KoXmlNS::draw, property);
}
return value;
}
// ======== KoShape
......@@ -1058,22 +1072,9 @@ bool KoShape::loadOdfAttributes(const KoXmlElement & element, KoShapeLoadingCont
return true;
}
QString KoShape::getStyleProperty(const char *property, const KoXmlElement & element, KoShapeLoadingContext & context)
{
Q_UNUSED(element);
KoStyleStack &styleStack = context.odfLoadingContext().styleStack();
QString value;
if (styleStack.hasProperty(KoXmlNS::draw, property)) {
value = styleStack.property(KoXmlNS::draw, property);
}
return value;
}
KoShapeBackground * KoShape::loadOdfFill(const KoXmlElement & element, KoShapeLoadingContext & context)
KoShapeBackground *KoShape::loadOdfFill(const KoXmlElement &element, KoShapeLoadingContext &context) const
{
QString fill = getStyleProperty("fill", element, context);
QString fill = KoShapePrivate::getStyleProperty("fill", element, context);
KoShapeBackground * bg = 0;
if (fill == "solid" || fill == "hatch")
bg = new KoColorBackground();
......@@ -1096,12 +1097,12 @@ KoShapeBackground * KoShape::loadOdfFill(const KoXmlElement & element, KoShapeLo
return bg;
}
KoShapeBorderModel * KoShape::loadOdfStroke(const KoXmlElement & element, KoShapeLoadingContext & context)
KoShapeBorderModel *KoShape::loadOdfStroke(const KoXmlElement &element, KoShapeLoadingContext &context) const
{
KoStyleStack &styleStack = context.odfLoadingContext().styleStack();
KoOdfStylesReader &stylesReader = context.odfLoadingContext().stylesReader();
QString stroke = getStyleProperty("stroke", element, context);
QString stroke = KoShapePrivate::getStyleProperty("stroke", element, context);
if (stroke == "solid" || stroke == "dash") {
QPen pen = KoOdfGraphicStyles::loadOdfStrokeStyle(styleStack, stroke, stylesReader);
......@@ -1128,10 +1129,10 @@ KoShapeBorderModel * KoShape::loadOdfStroke(const KoXmlElement & element, KoShap
}
}
KoShapeShadow * KoShape::loadOdfShadow(const KoXmlElement & element, KoShapeLoadingContext & context)
KoShapeShadow *KoShape::loadOdfShadow(const KoXmlElement &element, KoShapeLoadingContext &context) const
{
KoStyleStack &styleStack = context.odfLoadingContext().styleStack();
QString shadowStyle = getStyleProperty("shadow", element, context);
QString shadowStyle = KoShapePrivate::getStyleProperty("shadow", element, context);
if (shadowStyle == "visible" || shadowStyle == "hidden") {
KoShapeShadow * shadow = new KoShapeShadow();
QColor shadowColor(styleStack.property(KoXmlNS::draw, "shadow-color"));
......
......@@ -906,19 +906,13 @@ protected:
virtual void loadStyle(const KoXmlElement &element, KoShapeLoadingContext &context);
/// Loads the fill style
//QBrush loadOdfFill( const KoXmlElement & element, KoShapeLoadingContext & context );
KoShapeBackground *loadOdfFill(const KoXmlElement &element, KoShapeLoadingContext &context);
KoShapeBackground *loadOdfFill(const KoXmlElement &element, KoShapeLoadingContext &context) const;
/// Loads the stroke style
KoShapeBorderModel *loadOdfStroke(const KoXmlElement &element, KoShapeLoadingContext &context);
KoShapeBorderModel *loadOdfStroke(const KoXmlElement &element, KoShapeLoadingContext &context) const;
/// Loads the shadow style
KoShapeShadow *loadOdfShadow(const KoXmlElement &element, KoShapeLoadingContext &context);
/**
* Fills the style stack and returns the value of the given style property (e.g fill, stroke).
*/
QString getStyleProperty(const char *property, const KoXmlElement &element, KoShapeLoadingContext &context);
KoShapeShadow *loadOdfShadow(const KoXmlElement &element, KoShapeLoadingContext &context) const;
/* ** end loading saving */
......
......@@ -35,6 +35,11 @@ public:
void addShapeManager(KoShapeManager *manager);
void removeShapeManager(KoShapeManager *manager);
/**
* Fills the style stack and returns the value of the given style property (e.g fill, stroke).
*/
static QString getStyleProperty(const char *property, const KoXmlElement &element, KoShapeLoadingContext &context);
/// calls update on the shape where the border is.
void updateBorder();
......
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