kword

KWFrameSet.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999, 2000 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2005 Thomas Zander <zander@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef frame_set_h
22#define frame_set_h
23
24#include "KWFrame.h"
25#include <tqptrvector.h>
26#include <tqptrlist.h>
27#include "tqdom.h"
28
29class KWAnchor;
30class KWFrame;
31class KWFrameSetEdit;
32class KWPageManager;
33class KWTableFrameSet;
34class KWTextFrameSet;
36class KWTextParag;
37class KWView;
38class KWordFrameSetIface;
40
41class KoSavingContext;
42class KoTextDocument;
43class KoTextFormat;
44class KoTextParag;
45class KoXmlWriter;
46
47class KCommand;
48class TQPoint;
49class TQProgressDialog;
50
51
61class KWFrameSet : public TQObject
62{
63 TQ_OBJECT
64
65public:
67 KWFrameSet( KWDocument *doc );
69 virtual ~KWFrameSet();
70
71 virtual KWordFrameSetIface* dcopObject();
72
76 virtual FrameSetType type() const { return FT_BASE; }
77
78 virtual void addTextFrameSets( TQPtrList<KWTextFrameSet> & /*lst*/, bool /*onlyReadWrite*/ = false ) {};
79 virtual bool ownLine() const { return false;}
80
91 enum Info { FI_BODY = 0, FI_FIRST_HEADER = 1, FI_EVEN_HEADER = 2, FI_ODD_HEADER = 3,
92 FI_FIRST_FOOTER = 4, FI_EVEN_FOOTER = 5, FI_ODD_FOOTER = 6,
93 FI_FOOTNOTE = 7 };
95 Info frameSetInfo()const { return m_info; }
97 void setFrameSetInfo( Info fi ) { m_info = fi; }
98
99 bool isAHeader() const;
100 bool isAFooter() const;
101 bool isHeaderOrFooter() const { return isAHeader() || isAFooter(); }
102 bool isFootEndNote() const;
103 const char* headerFooterTag() const; // for OASIS saving
104
105 virtual bool isFootNote() const { return false; }
106 virtual bool isEndNote() const { return false; }
107
108 bool isMainFrameset() const;
109 bool isMoveable() const;
110
111 // frame management
112 virtual void addFrame( KWFrame *_frame, bool recalc = true );
113
119 virtual void deleteFrame( unsigned int num, bool remove = true, bool recalc = true );
120
126 void deleteFrame( KWFrame *frm, bool remove = true, bool recalc = true ); // calls the virtual one
127
129 virtual void frameDeleted( KWFrame* /*frm*/, bool /*recalc*/ ) {}
130
131 void deleteAllFrames();
132 void deleteAllCopies();
133
135 KWFrame *frameAtPos( double _x, double _y ) const;
136
143 bool isFrameAtPos( const KWFrame* frame, const TQPoint& nPoint, bool borderOfFrameOnly=false ) const;
144
146 KWFrame *frame( unsigned int _num ) const;
147
156 static KWFrame * settingsFrame( const KWFrame* frame );
157
159 const TQPtrList<KWFrame> &frameIterator() const { return m_frames; }
161 int frameFromPtr( KWFrame *frame );
163 unsigned int frameCount() const { return m_frames.count(); }
164
166 bool isDeleted() const { return m_frames.isEmpty(); }
167
169 virtual KWFrameSetEdit * createFrameSetEdit( KWCanvas * ) { return 0; }
170
185 virtual void createEmptyRegion( const TQRect & crect, TQRegion & emptyRegion, KWViewMode *viewMode );
186
208 virtual void drawContents( TQPainter *painter, const TQRect &crect,
209 const TQColorGroup &cg, bool onlyChanged, bool resetChanged,
210 KWFrameSetEdit *edit, KWViewMode *viewMode,
211 KWFrameViewManager *frameViewManager );
212
230 TQPainter *painter, const TQRect &crect,
231 const TQColorGroup &cg, bool, bool,
232 KWFrameSetEdit *edit, KWViewMode *viewMode,
233 KWFrame *settingsFrame, bool drawUnderlyingFrames );
234
243 void drawFrameBorder( TQPainter *painter, KWFrame *frame, KWFrame *settingsFrame,
244 const TQRect &crect, KWViewMode *viewMode );
245
265 virtual void drawFrame( KWFrame *frame, TQPainter *painter, const TQRect &fcrect, const TQRect &crect,
266 const TQPoint& translationOffset,
267 KWFrame *settingsFrame, const TQColorGroup &cg, bool onlyChanged, bool resetChanged,
268 KWFrameSetEdit *edit, KWViewMode *viewMode, bool drawUnderlyingFrames );
269
286 virtual void drawFrameContents( KWFrame * frame, TQPainter *painter, const TQRect& fcrect,
287 const TQColorGroup &cg, bool onlyChanged, bool resetChanged,
288 KWFrameSetEdit * edit, KWViewMode *viewMode );
289
293 virtual void drawPadding( KWFrame *frame, TQPainter *p, const TQRect &fcrect, const TQColorGroup &cg, KWViewMode *viewMode);
294
296 UpdateFramesInPage = 1,
297 SortFrames = 2
298 // next one is 4, not 3 ;)
299 };
304 virtual void updateFrames( int flags = 0xff );
305
308 const TQPtrList<KWFrame> & framesInPage( int pageNum ) const;
309
311 bool hasFramesInPageArray() const { return !m_framesInPage.isEmpty(); }
312
314 virtual void layout() {}
315 virtual void invalidate() {}
316
318 virtual TQDomElement save( TQDomElement &parentElem, bool saveFrames = true ) = 0;
320 virtual TQDomElement toXML( TQDomElement &parentElem, bool saveFrames = true )
321 { return save( parentElem, saveFrames ); }
323 virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context, bool saveFrames ) const = 0;
326 virtual bool canBeSavedAsInlineCharacter() const { return true; }
327
329 virtual void load( TQDomElement &framesetElem, bool loadFrames = true );
330 KWFrame* loadOasisFrame( const TQDomElement& tag, KoOasisContext& context );
332 virtual void fromXML( TQDomElement &framesetElem, bool loadFrames = true, bool /*useNames*/ = true )
333 { load( framesetElem, loadFrames ); }
334
335 virtual TQString toPlainText() const { return TQString(); }
336
337 //virtual void preparePrinting( TQPainter *, TQProgressDialog *, int & ) { }
338
341 virtual void finalize();
342
343 virtual int paragraphs() { return 0; }
344 virtual int paragraphsSelected() { return 0; }
345 virtual bool statistics( TQProgressDialog * /*progress*/, ulong & /*charsWithSpace*/, ulong & /*charsWithoutSpace*/, ulong & /*words*/,
346 ulong & /*sentences*/, ulong & /*syllables*/, ulong & /*lines*/, bool /*process only selected */ ) { return true; }
347
348 KWDocument* kWordDocument() const { return m_doc; }
349
351 virtual bool canRemovePage( int num );
352
353 //Note: none of those floating-frameset methods creates undo/redo
354 //They are _called_ by the undo/redo commands.
355
357 void setFloating();
362 void setAnchored( KWTextFrameSet* textfs, KoTextParag* parag, int index, bool placeHolderExists = false, bool repaint = true );
366 void setAnchored( KWTextFrameSet* textfs, int paragId, int index, bool placeHolderExists = false, bool repaint = true );
368 void setAnchored( KWTextFrameSet* textfs );
370 void setFixed();
372 bool isFloating() const { return m_anchorTextFs; }
374 KWTextFrameSet * anchorFrameset() const { return m_anchorTextFs; }
376 void setAnchorFrameset(KWTextFrameSet * textfs) { m_anchorTextFs = textfs; }
378 KWAnchor * findAnchor( int frameNum );
380 virtual void setAnchorFormat( KoTextFormat* /*format*/, int /*frameNum*/ ) {}
381
383 virtual KWAnchor * createAnchor( KoTextDocument *txt, int frameNum );
384
387 virtual void moveFloatingFrame( int frameNum, const KoPoint &position );
390 virtual KoSize floatingFrameSize( int frameNum = 0 );
394 KoRect floatingFrameRect( int frameNum = 0 );
397 virtual int floatingFrameBaseline( int /*frameNum*/ ) { return -1; }
399 virtual KCommand * anchoredObjectCreateCommand( int frameNum );
401 virtual KCommand * anchoredObjectDeleteCommand( int frameNum );
402
406 void setGroupManager( KWTableFrameSet *gm ) { m_groupmanager = gm; }
408 KWTableFrameSet *groupmanager()const { return m_groupmanager; }
409
410 bool isProtectSize()const { return m_protectSize; }
411 void setProtectSize( bool _b);
412
422 bool isVisible( KWViewMode* viewMode = 0L ) const;
423
425 virtual void setVisible( bool v );
426
428 TQString name() const { return m_name; }
429 void setName( const TQString &name );
430
433
436
437#ifndef NDEBUG
438 virtual void printDebug();
439 virtual void printDebug( KWFrame * );
440#endif
441
442 virtual KWTextFrameSet* nextTextObject( KWFrameSet * ) { return 0L;}
443
444 bool isPaintedBy( KWFrameSet* fs ) const;
445
447 virtual void setZOrder();
448
449 virtual void setProtectContent ( bool protect ) = 0;
450 virtual bool protectContent() const = 0;
451
452 void setPageManager(KWPageManager *pm) { m_pageManager = pm; }
453 KWPageManager* pageManager() const { return m_pageManager; }
454
455signals:
456
460 void repaintChanged( KWFrameSet * frameset );
461
462 void sigFrameAdded(KWFrame*);
463 void sigFrameRemoved(KWFrame*);
464
465 void sigNameChanged(KWFrameSet*);
466
467protected:
468
470 void saveCommon( TQDomElement &parentElem, bool saveFrames );
471
476 TQRegion frameClipRegion( TQPainter * painter, KWFrame *frame, const TQRect & crect,
477 KWViewMode * viewMode );
478
479 void deleteAnchor( KWAnchor * anchor );
480 virtual void deleteAnchors();
481 virtual void createAnchors( KoTextParag * parag, int index, bool placeHolderExists = false, bool repaint = true );
482
483
484 KWDocument *m_doc; // Document
485 TQPtrList<KWFrame> m_frames; // Our frames
486
487 // Cached info for optimization
489 TQPtrVector< TQPtrList<KWFrame> > m_framesInPage;
493 TQPtrList<KWFrame> m_emptyList; // ## make static pointer to save memory ?
494
495 Info m_info;
496 KWTableFrameSet *m_groupmanager;
497 bool m_visible;
498 bool m_protectSize;
499 TQString m_name;
500 KWTextFrameSet * m_anchorTextFs;
501 KWordFrameSetIface *m_dcop;
502 KWPageManager *m_pageManager;
503};
504
505#endif
An anchor is a special character, or 'custom item'.
Definition KWAnchor.h:35
Class: KWCanvas This class is responsible for the rendering of the frames to the screen as well as th...
Definition KWCanvas.h:61
This object is created to edit a particular frameset in a particular view The view's canvas creates i...
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
Definition KWFrameSet.h:62
void drawFrameAndBorders(KWFrame *frame, TQPainter *painter, const TQRect &crect, const TQColorGroup &cg, bool, bool, KWFrameSetEdit *edit, KWViewMode *viewMode, KWFrame *settingsFrame, bool drawUnderlyingFrames)
This one is called by drawContents for each frame.
void repaintChanged(KWFrameSet *frameset)
Emitted when something has changed in this frameset, so that all views repaint it.
KWAnchor * findAnchor(int frameNum)
Return the anchor object for this frame number.
virtual void setVisible(bool v)
set the visibility of the frameset.
virtual void layout()
relayout text in frames, so that it flows correctly around other frames
Definition KWFrameSet.h:314
virtual void moveFloatingFrame(int frameNum, const KoPoint &position)
Move the frame frameNum to the given position - this is called when the frame is anchored and the anc...
virtual void setAnchorFormat(KoTextFormat *, int)
Tell this frame the format of it's anchor.
Definition KWFrameSet.h:380
void drawFrameBorder(TQPainter *painter, KWFrame *frame, KWFrame *settingsFrame, const TQRect &crect, KWViewMode *viewMode)
Paint the borders for one frame of this frameset.
virtual void deleteFrame(unsigned int num, bool remove=true, bool recalc=true)
Delete a frame from the set of frames this frameSet has.
static KWFrame * settingsFrame(const KWFrame *frame)
Returns the original frame that the param frame is a copy off, or the frame itself.
void setNewFrameBehavior(KWFrame::NewFrameBehavior nfb)
set newFrameBehavior on all frames, see KWFrame for specifics
virtual FrameSetType type() const
The type of frameset.
Definition KWFrameSet.h:76
virtual void drawPadding(KWFrame *frame, TQPainter *p, const TQRect &fcrect, const TQColorGroup &cg, KWViewMode *viewMode)
Draw the padding area inside of a specific frame of this frameSet.
@ SortFrames
kwtextframeset only
Definition KWFrameSet.h:297
int m_firstPage
always equal to m_framesInPage[0].first()->pageNumber() :)
Definition KWFrameSet.h:491
Info
The different types of textFramesets (that TEXT is important here!) FI_BODY = normal text frames.
Definition KWFrameSet.h:91
const TQPtrList< KWFrame > & frameIterator() const
Iterator over the child frames.
Definition KWFrameSet.h:159
virtual void finalize()
Called once the frameset has been completely loaded or constructed.
virtual KWFrameSetEdit * createFrameSetEdit(KWCanvas *)
Create a framesetedit object to edit this frameset in canvas.
Definition KWFrameSet.h:169
virtual bool canBeSavedAsInlineCharacter() const
If the frameset is inline, is it ok to save it inside an oasis <text:p>? If not, KWAnchor will create...
Definition KWFrameSet.h:326
virtual void drawContents(TQPainter *painter, const TQRect &crect, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode, KWFrameViewManager *frameViewManager)
Paint this frameset.
void setAnchored(KWTextFrameSet *textfs, KoTextParag *parag, int index, bool placeHolderExists=false, bool repaint=true)
Make this frameset anchored, with the anchor at paragId,index in the text frameset textfs.
virtual void createEmptyRegion(const TQRect &crect, TQRegion &emptyRegion, KWViewMode *viewMode)
Let the caller know which parts of emptyRegion we do not claim, and thus the caller is free to paint ...
bool isDeleted() const
True if the frameset was deleted (but not destroyed, since it's in the undo/redo)
Definition KWFrameSet.h:166
virtual int floatingFrameBaseline(int)
Get the 'baseline' to use for the "floating frame" identified by frameNum.
Definition KWFrameSet.h:397
TQPtrVector< TQPtrList< KWFrame > > m_framesInPage
This array provides a direct access to the frames on page N.
Definition KWFrameSet.h:489
virtual void drawFrame(KWFrame *frame, TQPainter *painter, const TQRect &fcrect, const TQRect &crect, const TQPoint &translationOffset, KWFrame *settingsFrame, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode, bool drawUnderlyingFrames)
Draw a particular frame of this frameset.
virtual ~KWFrameSet()
destructor
virtual KWAnchor * createAnchor(KoTextDocument *txt, int frameNum)
Create an anchor for the floating frame identified by frameNum.
int frameFromPtr(KWFrame *frame)
Get frame number.
virtual bool canRemovePage(int num)
Return true if page num can be removed, as far as this frameset is concerned.
unsigned int frameCount() const
Get number of child frames.
Definition KWFrameSet.h:163
virtual void load(TQDomElement &framesetElem, bool loadFrames=true)
load from XML - when loading
bool isFloating() const
Return true if this frameset is floating (inline), false if it's fixed.
Definition KWFrameSet.h:372
virtual void frameDeleted(KWFrame *, bool)
Called by deleteFrame when it really deletes a frame (remove=true), to remove it from the table too.
Definition KWFrameSet.h:129
virtual void updateFrames(int flags=0xff)
Called when our frames change, or when another frameset's frames change.
void saveCommon(TQDomElement &parentElem, bool saveFrames)
save the common attributes for the frameset
virtual void setZOrder()
set z-order for all frames
TQPtrList< KWFrame > m_emptyList
always empty, for convenience in framesInPage
Definition KWFrameSet.h:493
KWTableFrameSet * groupmanager() const
returns the groupManager this frameset belongs to.
Definition KWFrameSet.h:408
virtual KoSize floatingFrameSize(int frameNum=0)
Get the size of the "floating frame" identified by frameNum.
virtual TQDomElement toXML(TQDomElement &parentElem, bool saveFrames=true)
save to XML - when copying to clipboard
Definition KWFrameSet.h:320
virtual void fromXML(TQDomElement &framesetElem, bool loadFrames=true, bool=true)
load from XML - when pasting from clipboard
Definition KWFrameSet.h:332
KWTextFrameSet * anchorFrameset() const
Return the frameset in which our anchor is - assuming isFloating()
Definition KWFrameSet.h:374
void setFrameBehavior(KWFrame::FrameBehavior fb)
set frameBehavior on all frames, see KWFrame for specifics
void setFixed()
Make this frameset fixed, i.e. not anchored.
KWFrame * frame(unsigned int _num) const
get a frame by number
void setFloating()
Make this frameset floating (anchored), as close to its current position as possible.
TQString name() const
get/set frameset name. For tables in particular, this must be unique
Definition KWFrameSet.h:428
TQRegion frameClipRegion(TQPainter *painter, KWFrame *frame, const TQRect &crect, KWViewMode *viewMode)
Determine the clipping rectangle for drawing the contents of frame with painter in the rectangle deli...
const TQPtrList< KWFrame > & framesInPage(int pageNum) const
Return list of frames in page pageNum.
void setAnchorFrameset(KWTextFrameSet *textfs)
Sets the frameset in which we are about to become inline. Used for OASIS loading.
Definition KWFrameSet.h:376
Info frameSetInfo() const
Returns the type of TextFrameSet this is.
Definition KWFrameSet.h:95
virtual KCommand * anchoredObjectCreateCommand(int frameNum)
Store command for creating an anchored object.
virtual void saveOasis(KoXmlWriter &writer, KoSavingContext &context, bool saveFrames) const =0
Save to OASIS format.
virtual void drawFrameContents(KWFrame *frame, TQPainter *painter, const TQRect &fcrect, const TQColorGroup &cg, bool onlyChanged, bool resetChanged, KWFrameSetEdit *edit, KWViewMode *viewMode)
Implement this one instead of drawFrame to benefit from double-buffering AND transparency handling (p...
void setFrameSetInfo(Info fi)
Set the type of TextFrameSet this is.
Definition KWFrameSet.h:97
bool isVisible(KWViewMode *viewMode=0L) const
Returns true if the frameset is visible.
bool isFrameAtPos(const KWFrame *frame, const TQPoint &nPoint, bool borderOfFrameOnly=false) const
Return if the point is on the frame.
KoRect floatingFrameRect(int frameNum=0)
Get the rect of the "floating frame" identified by frameNum, in coordinates RELATIVE TO THE PARENT FR...
bool hasFramesInPageArray() const
Allows to detect that updateFrames() hasn't been called yet (e.g.
Definition KWFrameSet.h:311
KWFrame * frameAtPos(double _x, double _y) const
retrieve frame from x and y coords (unzoomed coords)
virtual KCommand * anchoredObjectDeleteCommand(int frameNum)
Store command for deleting an anchored object.
void setGroupManager(KWTableFrameSet *gm)
make this frameset part of a groupmanager
Definition KWFrameSet.h:406
virtual TQDomElement save(TQDomElement &parentElem, bool saveFrames=true)=0
save to XML - when saving
Class that knows about all the (visible) frames in the document and will act as a manager between the...
This class represents a single frame.
Definition KWFrame.h:68
NewFrameBehavior
What happens on new page (create a new frame and reconnect, no followup, make copy)
Definition KWFrame.h:132
FrameBehavior
what should happen when the frame is full
Definition KWFrame.h:116
The Page Manager manages all the pages a document contains and separates all the frames the document ...
This class implements tables by acting as the manager for the frame(set)s which make up the table cel...
Object that is created to edit a Text frame set (KWTextFrameSet).
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.
This class extends KoTextParag for KWord-specific formatting stuff, custom items, loading and saving.
Definition KWTextParag.h:41
Abstract base class for KWCanvas's view modes.
Definition KWViewMode.h:48