Commit fe993130 authored by Thomas Zander's avatar Thomas Zander

* Allow KWCanvas to get keyboard input

* Refactor to avoid using KoTextShape directly (which we can't since its
  in a plugin)
* Add KoTextTool to allow editing of the text frames in KWord :)
* Provide KoShape::shapeId() setter/getter
* Provide a 'userData' class per KoShape which the application + plugin
  can implement to store data in there since you can't use a class in a
  plugin as well as in an application.
* Various api docs fixes cleanups
* Alter the ToolFactory to use a string instead of a QPixmap for the icon.

svn path=/trunk/koffice/; revision=555165
parent fee16f14
...@@ -30,6 +30,7 @@ set(flake_SRCS ...@@ -30,6 +30,7 @@ set(flake_SRCS
KoRectangleShapeFactory.cpp KoRectangleShapeFactory.cpp
KoPathShapeFactory.cpp KoPathShapeFactory.cpp
KoShapeFactory.cpp KoShapeFactory.cpp
KoShapeUserData.cpp
) )
kde4_automoc(${flake_SRCS}) kde4_automoc(${flake_SRCS})
......
...@@ -174,4 +174,11 @@ bool KoSelection::isSelected(const KoShape *object) const { ...@@ -174,4 +174,11 @@ bool KoSelection::isSelected(const KoShape *object) const {
return false; return false;
} }
KoShape *KoSelection::firstSelectedObject(KoFlake::SelectionType strip) const {
KoSelectionSet set = selectedObjects(strip);
if(set.isEmpty())
return 0;
return *(set.begin());
}
#include "KoSelection.moc" #include "KoSelection.moc"
...@@ -69,6 +69,12 @@ public: ...@@ -69,6 +69,12 @@ public:
* of a grouped object if the group-parent is itself also in the set. * of a grouped object if the group-parent is itself also in the set.
*/ */
virtual const KoSelectionSet selectedObjects(KoFlake::SelectionType strip = KoFlake::FullSelection) const; virtual const KoSelectionSet selectedObjects(KoFlake::SelectionType strip = KoFlake::FullSelection) const;
/**
* Return the first selected object, or 0 if there is nothing selected.
* @param strip if StrippedSelection, the returned list will not include any children
* of a grouped object if the group-parent is itself also in the set.
*/
KoShape *firstSelectedObject(KoFlake::SelectionType strip = KoFlake::FullSelection) const;
/// return if the object is selected /// return if the object is selected
virtual bool isSelected(const KoShape *object) const; virtual bool isSelected(const KoShape *object) const;
/// return the selection count /// return the selection count
......
...@@ -26,9 +26,11 @@ ...@@ -26,9 +26,11 @@
#include "KoPointerEvent.h" #include "KoPointerEvent.h"
#include "KoInsets.h" #include "KoInsets.h"
#include "KoShapeBorderModel.h" #include "KoShapeBorderModel.h"
#include "KoShapeUserData.h"
#include <QPainter> #include <QPainter>
#include <QtDebug> #include <QtDebug>
#include <QVariant>
#include <QPainterPath> #include <QPainterPath>
KoShape::KoShape() KoShape::KoShape()
...@@ -47,12 +49,14 @@ KoShape::KoShape() ...@@ -47,12 +49,14 @@ KoShape::KoShape()
, m_locked( false ) , m_locked( false )
, m_keepAspect( false ) , m_keepAspect( false )
, m_repaintManager(0) , m_repaintManager(0)
, m_userData(0)
{ {
recalcMatrix(); recalcMatrix();
} }
KoShape::~KoShape() KoShape::~KoShape()
{ {
delete m_userData;
} }
void KoShape::paintDecorations(QPainter &painter, KoViewConverter &converter, bool selected) { void KoShape::paintDecorations(QPainter &painter, KoViewConverter &converter, bool selected) {
...@@ -301,6 +305,16 @@ void KoShape::moveBy(double distanceX, double distanceY) { ...@@ -301,6 +305,16 @@ void KoShape::moveBy(double distanceX, double distanceY) {
setAbsolutePosition(QPointF(p.x() + distanceX, p.y() + distanceY)); setAbsolutePosition(QPointF(p.x() + distanceX, p.y() + distanceY));
} }
void KoShape::setUserData(KoShapeUserData *userData) {
if(m_userData)
delete m_userData;
m_userData = userData;
}
KoShapeUserData *KoShape::userData() const {
return m_userData;
}
// static // static
void KoShape::applyConversion(QPainter &painter, const KoViewConverter &converter) { void KoShape::applyConversion(QPainter &painter, const KoViewConverter &converter) {
double zoomX, zoomY; double zoomX, zoomY;
......
...@@ -32,12 +32,14 @@ ...@@ -32,12 +32,14 @@
class QPainter; class QPainter;
class QRectF; class QRectF;
class QPainterPath; class QPainterPath;
class QVariant;
class KoSelection; class KoSelection;
class KoPointerEvent; class KoPointerEvent;
class KoShapeContainer; class KoShapeContainer;
class KoRepaintManager; class KoRepaintManager;
class KoShapeBorderModel; class KoShapeBorderModel;
class KoShapeUserData;
/** /**
* *
...@@ -429,6 +431,32 @@ public: ...@@ -429,6 +431,32 @@ public:
*/ */
void moveBy(double distanceX, double distanceY); void moveBy(double distanceX, double distanceY);
/**
* Set a data object on the shape to be used by an application.
* This is specifically usefull when a shape is created in a plugin and that data from that
* shape should be accessible outside the plugin.
* @param userData the new user data, or 0 to delete the current one.
*/
void setUserData(KoShapeUserData *userData);
/**
* Return the current userData.
*/
KoShapeUserData *userData() const;
/**
* Return the Id of this shape, indentifying the type of shape by the id of the factory.
* @see KoShapeFactory::shapeId()
* @return the id of the shape-type
*/
const QString & shapeId() const { return m_shapeId; }
/**
* Set the Id of this shape. A shapeFactory is expected to set the Id at creation
* so applications can find out what kind of shape this is.
* @see KoShapeFactory::shapeId()
* @param id the ID from the factory that created this shape
*/
void setShapeId(const QString &id) { m_shapeId = id; }
protected: protected:
QMatrix m_invMatrix; ///< The inverted matrix; for convenience QMatrix m_invMatrix; ///< The inverted matrix; for convenience
QBrush m_backgroundBrush; ///< Stands for the background color / fill etc. QBrush m_backgroundBrush; ///< Stands for the background color / fill etc.
...@@ -460,6 +488,7 @@ private: ...@@ -460,6 +488,7 @@ private:
QSizeF m_size; // size in pt QSizeF m_size; // size in pt
QPointF m_pos; // position (top left) in pt QPointF m_pos; // position (top left) in pt
QString m_shapeId;
QMatrix m_matrix; QMatrix m_matrix;
...@@ -476,6 +505,7 @@ private: ...@@ -476,6 +505,7 @@ private:
friend class KoShapeManager; friend class KoShapeManager;
friend class KoShapeContainer; friend class KoShapeContainer;
void setRepaintManager(KoRepaintManager *manager); void setRepaintManager(KoRepaintManager *manager);
KoShapeUserData *m_userData;
/** /**
* Create a matrix that describes all the transformations done on this shape. * Create a matrix that describes all the transformations done on this shape.
......
...@@ -87,7 +87,7 @@ public: ...@@ -87,7 +87,7 @@ public:
* This method should be implemented by factories to create a shape that the user * This method should be implemented by factories to create a shape that the user
* gets when doing a base insert. For example from a script. The created shape * gets when doing a base insert. For example from a script. The created shape
* should have its values set to good defaults that the user can then adjust further if * should have its values set to good defaults that the user can then adjust further if
* needed. * needed. Including the KoShape:setShapeId(), with the Id from this factory
* The default shape position is not relevant, it will be moved by the caller. * The default shape position is not relevant, it will be moved by the caller.
* @return a new shape * @return a new shape
*/ */
...@@ -95,6 +95,7 @@ public: ...@@ -95,6 +95,7 @@ public:
/** /**
* This method should be implemented by factories to create a shape based on a set of * This method should be implemented by factories to create a shape based on a set of
* properties that are specifically made for this shape-type. * properties that are specifically made for this shape-type.
* This method should also set this factories shapeId on the shape using KoShape::setShapeId()
* @return a new shape * @return a new shape
* @see KoShapeTemplate::properties * @see KoShapeTemplate::properties
*/ */
...@@ -110,6 +111,10 @@ public: ...@@ -110,6 +111,10 @@ public:
* @return the id for the shape this factory creates. * @return the id for the shape this factory creates.
*/ */
const QString & shapeId() const; const QString & shapeId() const;
/**
* Return all the templates this factory knows about.
* Each template shows a different way to create a shape this factory is specialized in.
*/
const QList<KoShapeTemplate> templates() const { return m_templates; } const QList<KoShapeTemplate> templates() const { return m_templates; }
/** /**
* return a translated tooltip Text for a selector of shapes * return a translated tooltip Text for a selector of shapes
...@@ -117,8 +122,8 @@ public: ...@@ -117,8 +122,8 @@ public:
*/ */
const QString & toolTip() const; const QString & toolTip() const;
/** /**
* return an icon for this tool for a selector of shapes * return the basename of i the icon for this tool for a selector of shapes
* @return an icon for this tool * @return the basename of the icon for this selector of shapes
*/ */
const QString & icon() const; const QString & icon() const;
/** /**
...@@ -129,6 +134,11 @@ public: ...@@ -129,6 +134,11 @@ public:
protected: protected:
/**
* Add a template with the properties of a speficic type of shape this factory can generate
* using the createShape() method.
* @param params the new template this factory knows to produce
*/
void addTemplate(KoShapeTemplate params); void addTemplate(KoShapeTemplate params);
/** /**
* Set the tooltip to be used for a selector of shapes * Set the tooltip to be used for a selector of shapes
......
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander <zander@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.
*/
#include "KoShapeUserData.moc"
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander <zander@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 KOSHAPEUSERDATA_H
#define KOSHAPEUSERDATA_H
#include <QObject>
#include <koffice_export.h>
/**
* The KoShapeUserData class is used to associate custom data with a shape.
*
* KoShapeUserData provides an abstract interface for container classes
* that are used to associate application-specific user data with shapes in KoShape
* Generally, subclasses of this class provide functions to allow data to
* be stored and retrieved, and instances are attached to KoShape using
* KoShape::setUserData(). This makes it possible to store additional data per
* shape in a way that allows applications to not know the implementation of a
* specific KoShape extending class.
* Each subclass should provide a reimplementation of the destructor to ensure that
* any private data is automatically cleaned up when user data objects are deleted.
* Please note that this object is a QObject to allow a
* qobject_cast<MyData*> (shape->userData()) to work which is usefull in an environment
* where classes from plugins may not be castable using a static_cast or a dynamic_cast
*/
class FLAKE_EXPORT KoShapeUserData : public QObject {
Q_OBJECT
public:
/// Constructor
KoShapeUserData() {}
virtual ~KoShapeUserData() {}
};
#endif
...@@ -46,7 +46,7 @@ class FLAKE_EXPORT KoTool : public QObject ...@@ -46,7 +46,7 @@ class FLAKE_EXPORT KoTool : public QObject
public: public:
/** /**
* Constructor, normally only called by the factory (see KoTooLFactory) * Constructor, normally only called by the factory (see KoToolFactory)
* @param canvas the canvas interface this tool will work for. * @param canvas the canvas interface this tool will work for.
*/ */
KoTool(KoCanvasBase *canvas ); KoTool(KoCanvasBase *canvas );
...@@ -95,7 +95,7 @@ public: ...@@ -95,7 +95,7 @@ public:
/** /**
* Return if dragging (moving with the mouse down) to the edge of a canvas should scroll the * Return if dragging (moving with the mouse down) to the edge of a canvas should scroll the
* canvas. * canvas (default is true).
* @return if this tool wants mouse events to cause scrolling of canvas. * @return if this tool wants mouse events to cause scrolling of canvas.
*/ */
virtual bool wantsAutoScroll(); virtual bool wantsAutoScroll();
......
...@@ -46,7 +46,7 @@ const QString& KoToolFactory::toolTip() const { ...@@ -46,7 +46,7 @@ const QString& KoToolFactory::toolTip() const {
return m_tooltip; return m_tooltip;
} }
const QPixmap& KoToolFactory::icon() const { const QString& KoToolFactory::icon() const {
return m_icon; return m_icon;
} }
...@@ -66,7 +66,7 @@ void KoToolFactory::setToolType(const QString & toolType) { ...@@ -66,7 +66,7 @@ void KoToolFactory::setToolType(const QString & toolType) {
m_toolType = toolType; m_toolType = toolType;
} }
void KoToolFactory::setIcon(const QPixmap & icon) { void KoToolFactory::setIcon(const QString & icon) {
m_icon = icon; m_icon = icon;
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <klocale.h> #include <klocale.h>
#include <QObject> #include <QObject>
#include <QPixmap>
/** /**
* A factory for KoTool objects. * A factory for KoTool objects.
...@@ -102,10 +101,10 @@ public: ...@@ -102,10 +101,10 @@ public:
*/ */
const QString &toolTip() const; const QString &toolTip() const;
/** /**
* return an icon for this tool * return the basename of the icon for this tool
* @return an icon for this tool * @return the basename of the icon for this tool
*/ */
virtual const QPixmap& icon() const; const QString& icon() const;
/** /**
* Return the id of the shape we can process. * Return the id of the shape we can process.
* This is the shape ID the tool we create is associated with. So a TextTool for a TextShape. * This is the shape ID the tool we create is associated with. So a TextTool for a TextShape.
...@@ -126,10 +125,10 @@ protected: ...@@ -126,10 +125,10 @@ protected:
void setToolType(const QString & toolType); void setToolType(const QString & toolType);
/** /**
* Set an icon to be used in the toolBox. * Set an icon to be used in the toolBox.
* @param icon the pixmap from the iconLoader * @param iconName the basename (without extention) of the icon
* @see KIconLoader * @see KIconLoader
*/ */
void setIcon(const QPixmap & icon); void setIcon(const QString & iconName);
/** /**
* Set the priority of this tool, as it is shown in the toolBox; lower number means * Set the priority of this tool, as it is shown in the toolBox; lower number means
* it will be show more to the front of the list. * it will be show more to the front of the list.
...@@ -149,10 +148,9 @@ private: ...@@ -149,10 +148,9 @@ private:
QString m_toolType; QString m_toolType;
QString m_tooltip; QString m_tooltip;
QString m_activationId; QString m_activationId;
QPixmap m_icon; QString m_icon;
const QString m_name, m_id; const QString m_name, m_id;
int m_priority; int m_priority;
}; };
#endif #endif
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <KoInteractionToolFactory.h> #include <KoInteractionToolFactory.h>
#include <KoShapeControllerBase.h> #include <KoShapeControllerBase.h>
#include <KoCanvasController.h> #include <KoCanvasController.h>
#include <KoShapeRegistry.h>
#include "kactioncollection.h" #include "kactioncollection.h"
#include "kdebug.h" #include "kdebug.h"
...@@ -72,6 +73,7 @@ void KoToolManager::setup() { ...@@ -72,6 +73,7 @@ void KoToolManager::setup() {
m_defaultTool = new ToolHelper(new KoInteractionToolFactory(this, QStringList())); m_defaultTool = new ToolHelper(new KoInteractionToolFactory(this, QStringList()));
m_tools.append(m_defaultTool); m_tools.append(m_defaultTool);
KoShapeRegistry::instance();
KoToolRegistry *registry = KoToolRegistry::instance(); KoToolRegistry *registry = KoToolRegistry::instance();
foreach(KoID id, registry->listKeys()) { foreach(KoID id, registry->listKeys()) {
ToolHelper *t = new ToolHelper(registry->get(id)); ToolHelper *t = new ToolHelper(registry->get(id));
......
...@@ -19,8 +19,6 @@ set(libkohyphen_SRCS ...@@ -19,8 +19,6 @@ set(libkohyphen_SRCS
# KoComplexText.cpp not compiled # KoComplexText.cpp not compiled
set(kotext_LIB_SRCS ${libkohyphen_SRCS} set(kotext_LIB_SRCS ${libkohyphen_SRCS}
KoTextShape.cpp
KoTextShapeFactory.cpp
KoRichText.cpp KoRichText.cpp
KoTextZoomHandler.cpp KoTextZoomHandler.cpp
KoBorder.cpp KoBorder.cpp
...@@ -67,6 +65,7 @@ set(kotext_LIB_SRCS ${libkohyphen_SRCS} ...@@ -67,6 +65,7 @@ set(kotext_LIB_SRCS ${libkohyphen_SRCS}
KoParagStyle.cpp KoParagStyle.cpp
KoTextBookmark.cpp KoTextBookmark.cpp
KoBorderPreview.cpp KoBorderPreview.cpp
KoTextShapeData.cpp
) )
kde4_automoc(${kotext_LIB_SRCS}) kde4_automoc(${kotext_LIB_SRCS})
...@@ -89,7 +88,7 @@ kde4_add_ui3_files(kotext_LIB_SRCS ...@@ -89,7 +88,7 @@ kde4_add_ui3_files(kotext_LIB_SRCS
kde4_add_library(kotext SHARED ${kotext_LIB_SRCS}) kde4_add_library(kotext SHARED ${kotext_LIB_SRCS})
target_link_libraries(kotext ${KDE4_KSPELL2_LIBS} kutils kofficecore kofficeui ) target_link_libraries(kotext ${KDE4_KSPELL2_LIBS} flake kutils kofficecore kofficeui )
set_target_properties(kotext PROPERTIES VERSION ${GENERIC_KOFFICE_LIB_VERSION} SOVERSION ${GENERIC_KOFFICE_LIB_SOVERSION} ) set_target_properties(kotext PROPERTIES VERSION ${GENERIC_KOFFICE_LIB_VERSION} SOVERSION ${GENERIC_KOFFICE_LIB_SOVERSION} )
install_targets(${LIB_INSTALL_DIR} kotext ) install_targets(${LIB_INSTALL_DIR} kotext )
...@@ -97,8 +96,10 @@ install_targets(${LIB_INSTALL_DIR} kotext ) ...@@ -97,8 +96,10 @@ install_targets(${LIB_INSTALL_DIR} kotext )
########### Flake Plugin library ############### ########### Flake Plugin library ###############
set(kotext2_PART_SRCS set(kotext2_PART_SRCS
KoTextShape.cpp KoTextShape.cpp
KoTextShapeFactory.cpp KoTextShapeFactory.cpp
KoTextTool.cpp
KoTextToolFactory.cpp
) )
kde4_automoc(${kotext2_PART_SRCS}) kde4_automoc(${kotext2_PART_SRCS})
...@@ -107,7 +108,7 @@ kde4_add_plugin(kotext2 ${kotext2_PART_SRCS}) ...@@ -107,7 +108,7 @@ kde4_add_plugin(kotext2 ${kotext2_PART_SRCS})
kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} kotext2 ) kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} kotext2 )
target_link_libraries(kotext2 flake) target_link_libraries(kotext2 kotext flake kofficeui)
install_targets(${PLUGIN_INSTALL_DIR} kotext2 ) install_targets(${PLUGIN_INSTALL_DIR} kotext2 )
......
...@@ -28,13 +28,12 @@ ...@@ -28,13 +28,12 @@
// ############ KoTextShape ################ // ############ KoTextShape ################
KoTextShape::KoTextShape() KoTextShape::KoTextShape()
: m_document(0)
{ {
setDocument(new QTextDocument()); m_textShapeData = new KoTextShapeData();
setUserData(m_textShapeData);
} }
KoTextShape::~KoTextShape() { KoTextShape::~KoTextShape() {
delete m_document;
} }
void KoTextShape::paint(QPainter &painter, KoViewConverter &converter) { void KoTextShape::paint(QPainter &painter, KoViewConverter &converter) {
...@@ -43,21 +42,7 @@ void KoTextShape::paint(QPainter &painter, KoViewConverter &converter) { ...@@ -43,21 +42,7 @@ void KoTextShape::paint(QPainter &painter, KoViewConverter &converter) {
QAbstractTextDocumentLayout::PaintContext pc; QAbstractTextDocumentLayout::PaintContext pc;
pc.cursorPosition = -1; pc.cursorPosition = -1;
m_document->setPageSize(size()); QTextDocument *doc = m_textShapeData->document();
m_document->documentLayout()->draw( &painter, pc); doc->setPageSize(size());
} doc->documentLayout()->draw( &painter, pc);
void KoTextShape::setDocument(QTextDocument *document) {
Q_ASSERT(document);
delete m_document;
m_document = document;
// The following avoids the normal case where the glyph metrices are rounded to integers and
// hinted to the screen by freetype, which you of course don't want for WYSIWYG
m_document->setUseDesignMetrics(true);
}
QTextDocument *KoTextShape::takeDocument() {
QTextDocument *doc = m_document;
m_document = 0;
return doc;
} }
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#ifndef KOTEXTSHAPE_H #ifndef KOTEXTSHAPE_H
#define KOTEXTSHAPE_H #define KOTEXTSHAPE_H
#include <koffice_export.h>
#include <KoShape.h> #include <KoShape.h>
#include <KoTextShapeData.h>
#include <QTextDocument> #include <QTextDocument>
#include <QPainter> #include <QPainter>
...@@ -31,20 +31,15 @@ ...@@ -31,20 +31,15 @@
#define KoTextShape_SHAPEID "TextShapeID" #define KoTextShape_SHAPEID "TextShapeID"
class KOTEXT_EXPORT KoTextShape : public KoShape { class KoTextShape : public KoShape {
public: public:
KoTextShape(); KoTextShape();
virtual ~KoTextShape(); virtual ~KoTextShape();
void paint(QPainter &painter, KoViewConverter &converter); void paint(QPainter &painter, KoViewConverter &converter);
void setDocument(QTextDocument *document);
QTextDocument *document() { return m_document; }
QTextDocument *takeDocument();
private: private:
QTextDocument *m_document; KoTextShapeData *m_textShapeData;
}; };
#endif #endif
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander <zander@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.
*/
#include "KoTextShapeData.h"
#include <QTextDocument>
KoTextShapeData::KoTextShapeData()
: m_ownsDocument(false)
{
m_document = new QTextDocument();
}
KoTextShapeData::~KoTextShapeData() {
if(m_ownsDocument)
delete m_document;
}
void KoTextShapeData::setDocument(QTextDocument *document, bool transferOwnership) {
Q_ASSERT(document);
if(m_ownsDocument)
delete m_document;
m_document = document;
// The following avoids the normal case where the glyph metrices are rounded to integers and
// hinted to the screen by freetype, which you of course don't want for WYSIWYG
m_document->setUseDesignMetrics(true);
m_ownsDocument = transferOwnership;
}
QTextDocument *KoTextShapeData::document() {
return m_document;
}
#include "KoTextShapeData.moc"
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander <zander@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 KOTEXTSHAPEDATA_H
#define KOTEXTSHAPEDATA_H
#include <KoShapeUserData.h>
#include <koffice_export.h>
class QTextDocument;