[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kword/part
From: Thomas Zander <zander () kde ! org>
Date: 2010-12-18 9:43:58
Message-ID: 20101218094358.6CCBD3E1F3 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1207472 by zander:
Add test and implement TODO
M +10 -0 frames/KWCopyShape.cpp
M +3 -1 frames/KWCopyShape.h
M +2 -1 frames/KWFrame.cpp
M +14 -3 frames/KWFrameSet.cpp
M +12 -2 frames/KWFrameSet.h
M +7 -0 tests/CMakeLists.txt
A tests/TestFrames.cpp [License: GPL (v2+)]
A tests/TestFrames.h [License: GPL (v2+)]
--- trunk/koffice/kword/part/frames/KWCopyShape.cpp #1207471:1207472
@@ -49,6 +49,9 @@
void KWCopyShape::paint(QPainter &painter, const KoViewConverter &converter)
{
+ if (!m_original)
+ return;
+
painter.setClipRect(QRectF(QPointF(0, 0), converter.documentToView(size()))
.adjusted(-2, -2, 2, 2), // adjust for anti aliassing.
Qt::IntersectClip);
@@ -102,16 +105,23 @@
void KWCopyShape::paintDecorations(QPainter &painter, const KoViewConverter \
&converter, const KoCanvasBase *canvas) {
+ if (m_original)
m_original->paintDecorations(painter, converter, canvas);
}
QPainterPath KWCopyShape::outline() const
{
+ if (!m_original)
+ return QPainterPath();
+
return m_original->outline();
}
void KWCopyShape::saveOdf(KoShapeSavingContext &context) const
{
+ if (!m_original)
+ return;
+
KWCopyShape *me = const_cast<KWCopyShape*>(this);
me->setAdditionalAttribute("draw:copy-of", m_original->name());
saveOdfAttributes(context, OdfAllAttributes);
--- trunk/koffice/kword/part/frames/KWCopyShape.h #1207471:1207472
@@ -1,5 +1,5 @@
/* This file is part of the KDE project
- * Copyright (C) 2006, 2009 Thomas Zander <zander@kde.org>
+ * Copyright (C) 2006, 2010 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
@@ -53,6 +53,8 @@
virtual bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext \
&context);
KoShape *original() {return m_original;}
+ void resetOriginal() {m_original=0;}
+
private:
KoShape *m_original;
const KWPageManager *m_pageManager;
--- trunk/koffice/kword/part/frames/KWFrame.cpp #1207471:1207472
@@ -50,10 +50,11 @@
KWFrame::~KWFrame()
{
+ KoShape *myShape = m_shape;
m_shape = 0; // no delete is needed as the shape deletes us.
if (m_frameSet) {
bool justMe = m_frameSet->frameCount() == 1;
- m_frameSet->removeFrame(this); // first remove me so we won't get double \
deleted. + m_frameSet->removeFrame(this, myShape); // first remove me so we \
won't get double deleted. if (justMe)
delete m_frameSet;
m_frameSet = 0;
--- trunk/koffice/kword/part/frames/KWFrameSet.cpp #1207471:1207472
@@ -20,6 +20,7 @@
#include "KWFrameSet.h"
#include "KWFrame.h"
#include <KoColorBackground.h>
+#include "KWCopyShape.h"
#include <kdebug.h>
@@ -46,11 +47,21 @@
emit frameAdded(frame);
}
-void KWFrameSet::removeFrame(KWFrame *frame)
+void KWFrameSet::removeFrame(KWFrame *frame, KoShape *shape)
{
Q_ASSERT(frame);
- // TODO loop over all frames to see if there is a copy frame that references the \
removed frame; if it
- // does, then mark it as 'unused'.
+ if (!frame->isCopy()) {
+ QList<KWFrame*>::Iterator iter = m_frames.end();
+ // iter over all copy frames, which are all at the end.
+ for (--iter; iter != m_frames.begin(); --iter) {
+ KWCopyShape *copy = dynamic_cast<KWCopyShape*>((*iter)->shape());
+ if (copy == 0)
+ break;
+ if (copy->original() == shape)
+ copy->resetOriginal();
+ }
+ }
+
if (m_frames.removeAll(frame)) {
frame->setFrameSet(0);
emit frameRemoved(frame);
--- trunk/koffice/kword/part/frames/KWFrameSet.h #1207471:1207472
@@ -21,11 +21,11 @@
#define KWFRAMESET_H
#include "KWord.h"
+#include "KWFrame.h"
#include "kword_export.h"
#include <QObject>
-class KWFrame;
/**
* A frameSet holds a number of frames (zero or more) and a frameSet holds the
@@ -47,12 +47,22 @@
* @see frameAdded()
*/
void addFrame(KWFrame *frame);
+
/**
* Remove a previously added Frame
* @param frame the frame to remove
+ * @param shape the shape of the frame
+ * You shouldn't use this method in most cases but the convinience version with \
only a single + * parameter
+ */
+ void removeFrame(KWFrame *frame, KoShape *shape);
+
+ /**
+ * Remove a previously added Frame
+ * @param frame the frame to remove
* @see frameRemoved()
*/
- void removeFrame(KWFrame *frame);
+ void removeFrame(KWFrame *frame) {removeFrame(frame, frame->shape());}
/**
* Give this frameSet a name.
--- trunk/koffice/kword/part/tests/CMakeLists.txt #1207471:1207472
@@ -58,12 +58,19 @@
target_link_libraries(TestTextFrameSorting kwordprivate ${QT_QTTEST_LIBRARY})
########### next target ###############
+
set(TestTextFrameManagement_test_SRCS TestTextFrameManagement.cpp)
kde4_add_unit_test(TestTextFrameManagement TESTNAME \
kword-part-frame-TestTextFrameManagement ${TestTextFrameManagement_test_SRCS}) \
target_link_libraries(TestTextFrameManagement kwordprivate ${QT_QTTEST_LIBRARY})
########### next target ###############
+set(TestFrames_test_SRCS TestFrames.cpp)
+kde4_add_unit_test(TestFrames TESTNAME kword-part-frame-TestFrames \
${TestFrames_test_SRCS}) +target_link_libraries(TestFrames kwordprivate \
${QT_QTTEST_LIBRARY}) +
+########### next target ###############
+
if( Soprano_FOUND )
set(TestRdf_SRCS TestRdf.cpp )
kde4_add_unit_test(TestRdf TESTNAME kword-part-TestRdf ${TestRdf_SRCS})
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic