[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: patch: (preliminary) fix for #31732
From:       Emmanuel Touzery <emmanuel.touzery () wanadoo ! fr>
Date:       2002-01-15 21:57:30
[Download RAW message or body]

whoops...

keep forgetting sending files.. sorry about that. the two files to add to 
kword.

emmanuel

Le Tuesday 15 January 2002 22:43, vous avez écrit :
> Hello!
>
> >Thanks for the patch... but allow me to comment on it :
>
> no problem, I actually asked for comments :O)
>
> > I totally hate code
> >duplication. It makes maintainance and debugging very difficult.
> >
> >Please use an approach similar to KPresenter's use of
> > KoTextFormatInterface.
>
> Yes, I understand, only it makes grouping the KCommand for the undo harder
> (kpresenter does not group them). actually with the new patch the undo
> actions are not grouped anymore (that is, if you select several cells in a
> table, do an action, and undo it, you'll have to click undo the number of
> selected cells, not just once).
>
> the reason is that setBold() and such doesn't return a KCommand, so i would
> need new methods like KoTextFormatInterface::startGrouping() and
> endGrouping(), but that is not very adapted for the API i guess (and would
> break a lot of code) so i don't know exactly how to solve that "nicely".
> maybe you have a better idea?
>
> note: the attached patch still has the issue of the previous patch: on undo
> the toolbar buttons are not set back properly (center text on frame, press
> undo, text is not centered anymore, but the center button is still on). i
> don't know why is that.
>
> hope you're happier with this new version anyway.
>
> emmanuel.
-- 
"Give me a lever long enough and a place to stand, and I'll move the world."
	--Archimedes
["kwtextobject.cc" (text/x-c++src)]

/* This file is part of the KDE project
   Copyright (C) 2002 the Koffice team

   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., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

#include "kwtextobject.h"
#include "kwtextframeset.h"
#include <kcommand.h>
#include <klocale.h>

KoTextFormat *KWTextFrameObject::currentFormat() const
{
 	KoTextObject *textObject = ((KWTextFrameSet*)m_frame->frameSet())->textObject();
	return textObject->currentFormat();
}

void KWTextFrameObject::setFormat( KoTextFormat * newFormat, int flags, bool zoomFont \
) {
	KoTextObject *textObject = ((KWTextFrameSet*)m_frame->frameSet())->textObject();
	textObject->textDocument()->selectAll( QTextDocument::Temp );
	KoTextFormat* format = currentFormat();
	KCommand *cmd = textObject->setFormatCommand( NULL, format, newFormat, flags, \
zoomFont, QTextDocument::Temp );  textObject->textDocument()->removeSelection( \
QTextDocument::Temp );  m_doc->addCommand( cmd );
}

const KoParagLayout * KWTextFrameObject::currentParagLayoutFormat() const
{
	KoTextObject *textObject = ((KWTextFrameSet*)m_frame->frameSet())->textObject();
	return textObject->currentParagLayoutFormat();
}

void KWTextFrameObject::setParagLayoutFormat( KoParagLayout *newLayout,int flags, int \
marginIndex) {
	KoTextObject *textObject = ((KWTextFrameSet*)m_frame->frameSet())->textObject();
	return textObject->KoTextObject::setParagLayoutFormat(newLayout, flags, \
marginIndex); }


["kwtextobject.h" (text/x-chdr)]

/* This file is part of the KDE project
   Copyright (C) 2002 the Koffice team

   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., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

#ifndef KWTEXTOBJECT_H
#define KWTEXTOBJECT_H

#include <kotextobject.h>
#include "kwdoc.h"

/**
 * This class overrides KoTextFormat methods, allowing
 * to implement "setBold", "setItalic" etc. only once, whether it applies
 * to a text selection or to complete text objects.
 */
class KWTextFrameObject: public KoTextFormatInterface
{
public:

	KWTextFrameObject(KWFrame *frame, KWDocument* doc): m_frame(frame), m_doc(doc) {}

	/** Interface for accessing the current format */
    virtual KoTextFormat * currentFormat() const;

   /** Interface for setting the modified format */
    virtual void setFormat( KoTextFormat * newFormat, int flags, bool zoomFont = false );

	virtual const KoParagLayout * currentParagLayoutFormat() const;

    virtual void setParagLayoutFormat( KoParagLayout *newLayout,int flags, int marginIndex=-1);

protected:
	KWFrame *m_frame;
	KWDocument *m_doc;

};

#endif

_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic