Commit c4b16a30 authored by Thorsten Zachmann's avatar Thorsten Zachmann

o Undo the typedef -> #define as also the defines where not working.

  Therefore I added KoXmlReaderForward.h to do the forward declaration.
o Started to add loading methods to KoShape.  

svn path=/trunk/koffice/; revision=664223
parent 1d8c8941
...@@ -32,9 +32,12 @@ ...@@ -32,9 +32,12 @@
#include "KoShapeUserData.h" #include "KoShapeUserData.h"
#include "KoShapeApplicationData.h" #include "KoShapeApplicationData.h"
#include "KoShapeSavingContext.h" #include "KoShapeSavingContext.h"
#include "KoShapeLoadingContext.h"
#include "KoViewConverter.h" #include "KoViewConverter.h"
#include <KoXmlReader.h>
#include <KoXmlWriter.h> #include <KoXmlWriter.h>
#include <KoXmlNS.h>
#include <KoGenStyles.h> #include <KoGenStyles.h>
#include <KoGenStyle.h> #include <KoGenStyle.h>
...@@ -648,6 +651,21 @@ QString KoShape::style( KoShapeSavingContext *context ) const ...@@ -648,6 +651,21 @@ QString KoShape::style( KoShapeSavingContext *context ) const
return context->mainStyles().lookup( style, context->isSet( KoShapeSavingContext::PresentationShape ) ? "pr" : "gr" ); return context->mainStyles().lookup( style, context->isSet( KoShapeSavingContext::PresentationShape ) ? "pr" : "gr" );
} }
bool KoShape::loadOdfAttributes( const KoXmlElement & element, KoShapeLoadingContext &context, int attributes )
{
if ( attributes & OdfMandatories ) {
if ( element.hasAttributeNS( KoXmlNS::draw, "layer" ) ) {
KoShapeLayer * layer = context.layer( element.attributeNS( KoXmlNS::draw, "layer" ) );
if ( layer ) {
setParent( layer );
}
}
}
return true;
}
void KoShape::saveOdfFrameAttributes(KoShapeSavingContext *context) { void KoShape::saveOdfFrameAttributes(KoShapeSavingContext *context) {
saveOdfAttributes(context, FrameAttributes); saveOdfAttributes(context, FrameAttributes);
context->addOption(KoShapeSavingContext::FrameOpened); context->addOption(KoShapeSavingContext::FrameOpened);
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <flake_export.h> #include <flake_export.h>
#include <KoXmlReaderForward.h>
class QPainter; class QPainter;
class QRectF; class QRectF;
class QPainterPath; class QPainterPath;
...@@ -50,6 +52,7 @@ class KoShapeApplicationData; ...@@ -50,6 +52,7 @@ class KoShapeApplicationData;
class KoShapeSavingContext; class KoShapeSavingContext;
class KoCanvasBase; class KoCanvasBase;
class KoGenStyle; class KoGenStyle;
class KoShapeLoadingContext;
/** /**
* *
...@@ -132,6 +135,16 @@ public: ...@@ -132,6 +135,16 @@ public:
*/ */
virtual void paintDecorations(QPainter &painter, const KoViewConverter &converter, const KoCanvasBase *canvas); virtual void paintDecorations(QPainter &painter, const KoViewConverter &converter, const KoCanvasBase *canvas);
/**
* Load a shape from odf
*
* @param context the KoShapeLoadingContext used for loading
* @param element element which represents the shape in odf
*
* TODO make it pure virtual
*/
virtual bool loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context ) { Q_UNUSED(element); Q_UNUSED(context); return true; }
/** /**
* @brief store the shape data as ODF XML. * @brief store the shape data as ODF XML.
* This is the method that will be called when saving a shape as a described in¬ * This is the method that will be called when saving a shape as a described in¬
...@@ -575,6 +588,15 @@ protected: ...@@ -575,6 +588,15 @@ protected:
FrameAttributes = OdfMandatories | OdfSize | OdfPosition | OdfTransformation FrameAttributes = OdfMandatories | OdfSize | OdfPosition | OdfTransformation
}; };
/**
* This method is used during loading of the shape to load common attributes
*
* @param context the KoShapeLoadingContext used for loading
* @param element element which represents the shape in odf
* @param attributes a number of OdfAttribute items to state which attributes to load.
*/
bool loadOdfAttributes( const KoXmlElement & element, KoShapeLoadingContext &context, int attributes );
/** /**
* This method can be used while saving the shape as ODF to add the data * This method can be used while saving the shape as ODF to add the data
* stored on this shape to the current element. * stored on this shape to the current element.
......
...@@ -19,7 +19,17 @@ ...@@ -19,7 +19,17 @@
#include "KoShapeLoadingContext.h" #include "KoShapeLoadingContext.h"
KoShapeLoadingContext::KoShapeLoadingContext() KoShapeLoadingContext::KoShapeLoadingContext( KoOasisLoadingContext & context )
: m_context( context )
{ {
} }
KoOasisLoadingContext & KoShapeLoadingContext::koLoadingContext()
{
return m_context;
}
KoShapeLayer * KoShapeLoadingContext::layer( const QString & layerName )
{
return m_layers.value( layerName, 0 );
}
...@@ -19,14 +19,34 @@ ...@@ -19,14 +19,34 @@
#ifndef KOSHAPELOADINGCONTEXT_H #ifndef KOSHAPELOADINGCONTEXT_H
#define KOSHAPELOADINGCONTEXT_H #define KOSHAPELOADINGCONTEXT_H
#include <QMap>
#include <QString>
#include <flake_export.h> #include <flake_export.h>
class KoOasisLoadingContext;
class KoShapeLayer;
class KoShape;
/** /**
* Context passed to shapes during loading * Context passed to shapes during loading
*/ */
class FLAKE_EXPORT KoShapeLoadingContext class FLAKE_EXPORT KoShapeLoadingContext
{ {
public: public:
KoShapeLoadingContext(); KoShapeLoadingContext( KoOasisLoadingContext & context );
KoOasisLoadingContext & koLoadingContext();
KoShapeLayer * layer( const QString & layerName );
void addShapeId( KoShape * shape, const QString & id );
private:
KoOasisLoadingContext &m_context;
QMap<QString, KoShapeLayer*> m_layers;
QMap<int, KoShape*> m_drawIds;
}; };
#endif /* KOSHAPELOADINGCONTEXT_H */ #endif /* KOSHAPELOADINGCONTEXT_H */
...@@ -33,12 +33,12 @@ class QTextDecoder; ...@@ -33,12 +33,12 @@ class QTextDecoder;
#ifdef KOXML_USE_QDOM #ifdef KOXML_USE_QDOM
#define KoXmlNode QDomNode typedef QDomNode KoXmlNode;
#define KoXmlElement QDomElement typedef QDomElement KoXmlElement;
#define KoXmlText QDomText typedef QDomText KoXmlText;
#define KoXmlCDATASection QDomCDATASection typedef QDomCDATASection KoXmlCDATASection;
#define KoXmlDocumentType QDomDocumentType typedef QDomDocumentType KoXmlDocumentType;
#define KoXmlDocument QDomDocument typedef QDomDocument KoXmlDocument;
#else #else
......
/* This file is part of the KDE project
Copyright (C) 2005-2006 Ariya Hidayat <ariya@kde.org>
Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KOXMLREADERFORWARD_H
#define KOXMLREADERFORWARD_H
#define KOXML_USE_QDOM
#ifdef KOXML_USE_QDOM
#include <qdom.h>
typedef QDomNode KoXmlNode;
typedef QDomElement KoXmlElement;
typedef QDomText KoXmlText;
typedef QDomCDATASection KoXmlCDATASection;
typedef QDomDocumentType KoXmlDocumentType;
typedef QDomDocument KoXmlDocument;
#else
class KoXmlElement;
class KoXmlText;
class KoXmlCDATASection;
class KoXmlDocumentType;
class KoXmlDocument;
class KoXmlNodeData;
#endif
#endif // KOXMLREADERFORWARD_H
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