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