kpresenter

KPrPage.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
3 Copyright (C) 2004-2005 Thorsten Zachmann <zachmann@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 KPRPAGE_H
22#define KPRPAGE_H
23
24#include <tqwidget.h>
25#include <tqptrlist.h>
26#include "global.h"
27#include <KoBrush.h>
28#include <KoPoint.h>
29#include <KoRect.h>
30#include <KoStyleCollection.h> // for KoStyleChangeDefMap
31#include <tqvariant.h>
32#include <KoDocumentChild.h>
33#include <KoPictureCollection.h>
34
35class KMacroCommand;
36class KoSavingContext;
37class KURL;
38class KPrTextView;
39class KPrObject;
40class KPrDocument;
41class KPrView;
42class KoDocumentEntry;
43class KoPageLayout;
44class KCommand;
45class KoPointArray;
46class DCOPObject;
47class KPrTextObject;
48class KoTextObject;
49class KPrPixmapObject;
50class KPrPartObject;
51class KPrBackGround;
52
53class KoXmlWriter;
54class KoGenStyles;
55class KoPen;
56
57
58class KPrPage
59{
60public:
67 KPrPage(KPrDocument *_doc, KPrPage *masterPage = 0 );
68
72 virtual ~KPrPage();
73
77 virtual DCOPObject* dcopObject();
78
82 KPrDocument * kPresenterDoc() const {return m_doc; }
83
89 TQString manualTitle()const;
90
96 void insertManualTitle(const TQString & title);
97
108 TQString pageTitle( const TQString &_title = TQString() ) const;
109
115 void setNoteText( const TQString &_text );
116
122 TQString noteText( )const;
123
129 void setMasterPage( KPrPage *_masterPage ) { m_masterPage = _masterPage; }
130
136 KPrPage * masterPage() const { return m_masterPage; }
137
144 bool isMasterPage() const;
145
151 const TQPtrList<KPrObject> & objectList() const { return m_objectList; }
152
160 KPrObject *getObject( int num );
161
170 void appendObject( KPrObject *_obj );
171
180 void appendObjects( const TQValueList<KPrObject *> &objects );
181
190 void replaceObject( KPrObject *oldObject, KPrObject *newObject );
191
199 int takeObject( KPrObject *object );
200
209 KCommand * deleteSelectedObjects();
210
220 void insertObject( KPrObject *object, int pos );
221
225 void completeLoading( bool _clean, int lastObj );
226
236 void unifyObjectName( KPrObject *object );
237
243 KoRect getPageRect() const;
244
250 TQRect getZoomPageRect()const;
251
257 void setObjectList( TQPtrList<KPrObject> objectLlist ) {
258 m_objectList.setAutoDelete( false ); m_objectList = objectLlist; m_objectList.setAutoDelete( false );
259 }
260
266 unsigned int objNums() const { return m_objectList.count(); }
267
275 int numTextObject() const;
286 KPrTextObject *textFrameSet( unsigned int _num ) const;
287
293 int numSelected() const;
294
298 void pasteObjs( const TQByteArray & data, int nbCopy = 1, double angle = 0.0 ,
299 double _increaseX=0.0, double increaseY = 0.0, double moveX=0.0, double moveY=0.0);
300
304 KCommand * replaceObjs( bool createUndoRedo, double _orastX, double _orastY,
305 const TQColor & _txtBackCol, const TQColor & _otxtBackCol);
306
310 void copyObjs(TQDomDocument &doc, TQDomElement &presenter, TQValueList<KoPictureKey> & lst) const;
311
318 KPrObject* getSelectedObj() const;
319
328 TQPtrList<KPrObject> getSelectedObjects( bool withoutHeaderFooter = false ) const;
329
336 KPrPixmapObject* getSelectedImage() const;
337
346 KCommand * setImageEffect(ImageEffect eff, TQVariant param1, TQVariant param2, TQVariant param3);
347
354 void groupObjects();
355
361 void ungroupObjects( KMacroCommand ** macro );
362
366 void raiseObjs( bool forward );
367
371 void lowerObjs( bool backward );
372
373 KCommand* setPen( const KoPen &pen, LineEnd lb, LineEnd le, int flags );
374 KCommand* setBrush( const TQBrush &brush, FillType ft, const TQColor& g1, const TQColor &g2,
375 BCType gt, bool unbalanced, int xfactor, int yfactor, int flags );
376
380 KCommand * insertObject( const TQString &name, KPrObject * object, const KoRect &r, bool addCommand = true );
381
382 virtual KPrPartObject* insertObject( const KoRect&, KoDocumentEntry& );
383
384 void insertRectangle( const KoRect &r, const KoPen & pen, const TQBrush &brush, FillType ft,
385 const TQColor &g1, const TQColor & g2,BCType gt, int rndX, int rndY,
386 bool unbalanced, int xfactor, int yfactor );
387
388 void insertCircleOrEllipse( const KoRect &r, const KoPen &pen, const TQBrush &brush, FillType ft,
389 const TQColor &g1, const TQColor &g2, BCType gt, bool unbalanced, int xfactor, int yfactor );
390
391 void insertPie( const KoRect &r, const KoPen &pen, const TQBrush &brush, FillType ft,
392 const TQColor &g1, const TQColor &g2,BCType gt, PieType pt, int _angle, int _len,
393 LineEnd lb,LineEnd le,bool unbalanced, int xfactor, int yfactor );
394
395 KPrTextObject* insertTextObject( const KoRect& r, const TQString& text = TQString(), KPrView *_view = 0L );
396 void insertLine( const KoRect &r, const KoPen &pen, LineEnd lb, LineEnd le, LineType lt );
397
398 void insertAutoform( const KoRect &r, const KoPen &pen, const TQBrush &brush, LineEnd lb, LineEnd le,
399 FillType ft,const TQColor &g1, const TQColor &g2, BCType gt, const TQString &fileName,
400 bool unbalanced,int xfactor, int yfactor );
401
402 void insertFreehand( const KoPointArray &points, const KoRect &r, const KoPen &pen,LineEnd lb, LineEnd le );
403 void insertPolyline( const KoPointArray &points, const KoRect &r, const KoPen &pen,LineEnd lb, LineEnd le );
404 void insertQuadricBezierCurve( const KoPointArray &points, const KoPointArray &allPoints, const KoRect &r,
405 const KoPen &pen,LineEnd lb, LineEnd le );
406 void insertCubicBezierCurve( const KoPointArray &points, const KoPointArray &allPoints, const KoRect &r,
407 const KoPen &pen,LineEnd lb, LineEnd le );
408
409 void insertPolygon( const KoPointArray &points, const KoRect &r, const KoPen &pen, const TQBrush &brush,
410 FillType ft,const TQColor &g1, const TQColor &g2, BCType gt, bool unbalanced,
411 int xfactor, int yfactor, bool _checkConcavePolygon, int _cornersValue, int _sharpnessValue );
412
413 void insertClosedLine( const KoPointArray &points, const KoRect &r, const KoPen &pen, const TQBrush &brush,
414 FillType ft,const TQColor &g1, const TQColor &g2,
415 BCType gt, bool unbalanced, int xfactor, int yfactor, ToolEditMode _mode );
416
417 void slotRepaintVariable();
418 void recalcPageNum();
419 void changePicture( const KURL & url, TQWidget *parent );
420 void insertPicture( const TQString &filename, const KoPoint &pos );
421 void insertPicture( const TQString &_file, const KoRect &_rect );
422
423 void enableEmbeddedParts( bool f );
424
425 KPrBackGround *background() { return m_kpbackground; }
426
427 void makeUsedPixmapList();
428
429 void setBackColor( const TQColor &backColor1, const TQColor &backColor2, BCType bcType,
430 bool unbalanced, int xfactor, int yfactor );
431 void setBackPicture( const KoPictureKey & key );
432 bool getBackUnbalanced( )const;
433 void setBackView( BackView backView );
434 void setBackType( BackType backType );
435
436 void setPageEffect( PageEffect pageEffect );
437 void setPageEffectSpeed( EffectSpeed pageEffectSpeed );
438 void setPageTimer( int pageTimer );
439 void setPageSoundEffect( bool soundEffect );
440 void setPageSoundFileName( const TQString &fileName );
441 BackType getBackType( ) const ;
442 BackView getBackView( )const ;
443 KoPictureKey getBackPictureKey( )const ;
444 KoPicture getBackPicture( )const ;
445 TQColor getBackColor1( )const ;
446 TQColor getBackColor2()const ;
447 int getBackXFactor()const ;
448 int getBackYFactor( )const;
449 BCType getBackColorType( )const;
450 PageEffect getPageEffect( )const;
451 EffectSpeed getPageEffectSpeed() const;
452 int getPageTimer( )const;
453 bool getPageSoundEffect( )const;
454 TQString getPageSoundFileName()const;
455
456
457 void setUseMasterBackground( bool useMasterBackground );
458 bool useMasterBackground() const;
459
463 TQValueList<int> getEffectSteps() const;
464
465 bool isSlideSelected() const {return m_selectedSlides;}
466 void slideSelected(bool _b){m_selectedSlides=_b;}
467
468 void setInsPictureFile( const TQString &_file ) { m_pictureFile = _file; }
469
470 TQString insPictureFile() const { return m_pictureFile; }
471
472 void deSelectAllObj();
473 void deSelectObj( KPrObject *kpobject );
474 TQDomElement saveObjects( TQDomDocument &doc, TQDomElement &objects, double yoffset,
475 int saveOnlyPage ) const;
476
477 bool oneObjectTextExist(bool forceAllTextObject = true) ;
478 bool oneObjectTextSelected();
479 bool isOneObjectSelected();
480 bool haveASelectedPartObj();
481 bool haveASelectedGroupObj();
482 bool haveASelectedPixmapObj();
483
492 KoRect getRealRect( bool all ) const;
493 bool chPic( KPrView *_view);
494
495 //return command when we move object
496 KCommand *moveObject(KPrView *_view, double diffx, double diffy);
497 KCommand *moveObject(KPrView *m_view,const KoPoint &_move,bool key);
498
499 KCommand *rotateSelectedObjects(float _newAngle, bool addAngle=false);
500 KCommand *shadowObj(ShadowDirection dir,int dist, const TQColor &col);
501
502 TQPtrList<KoTextObject> allTextObjects() const;
503 void addTextObjects(TQPtrList<KoTextObject>& lst) const;
504
505 void repaintObj();
506
507 KPrObject * getCursor(const TQPoint &pos );
508 KPrObject * getCursor(const KoPoint &pos );
509
516 KPrObject* getObjectAt( const KoPoint &pos, bool withoutProtected = false ) const;
517 KPrPixmapObject * picViewOrigHelper() const;
518 void applyStyleChange( KoStyleChangeDefMap changed );
519
520 void reactivateBgSpellChecking(bool refreshTextObj);
521
522 bool canMoveOneObject() const;
523 KCommand *alignVertical(VerticalAlignmentType _type );
524 void changeTabStopValue ( double _tabStop );
525 bool savePicture( KPrView *_view ) const;
526 bool findTextObject( KPrObject *obj );
527 KPrObject *nextTextObject(KPrTextObject *obj);
528
529 void getAllObjectSelectedList(TQPtrList<KPrObject> &lst,bool force = false );
530 void getAllEmbeddedObjectSelected(TQPtrList<KoDocumentChild> &embeddedObjects );
531
532 void load( const TQDomElement &element );
533 void loadOasis( KoOasisContext & context );
534
535 TQDomElement save( TQDomDocument &doc );
536
537 bool saveOasisPage( KoStore *store, KoXmlWriter &xmlWriter, int posPage, KoSavingContext& context,
538 int & indexObj, int &partIndexObj, KoXmlWriter* manifestWriter, TQMap<TQString, int> &pageNames ) const;
539 TQString saveOasisPageStyle( KoStore *store, KoGenStyles& mainStyles ) const;
540 TQString saveOasisPageEffect() const;
541 TQString saveOasisAdditionalPageEffect() const;
542 bool saveOasisNote( KoXmlWriter &xmlWriter ) const;
543
544 bool hasHeader() const { return m_bHasHeader; }
545 bool hasFooter() const { return m_bHasFooter; }
546 void setHeader( bool b, bool _updateDoc = true );
547 void setFooter( bool b, bool _updateDoc = true );
548
549 void setDisplayObjectFromMasterPage( bool _b );
550 bool displayObjectFromMasterPage() const { return m_displayObjectFromMasterPage;}
551
552 void setDisplayBackground( bool _b );
553 bool displayBackground() const { return m_displayBackground; }
554
555 TQString oasisNamePage( int posPage ) const;
556
557private:
558 void makeUsedPixmapListForGroupObject( KPrObject *_obj );
559 void completeLoadingForGroupObject( KPrObject *_obj );
560 bool objectNameExists( KPrObject *object, TQPtrList<KPrObject> &list );
561 void saveOasisObject( KoStore *store, KoXmlWriter &xmlWriter, KoSavingContext& context, int & indexObj, int &partIndexObj, KoXmlWriter* manifestWriter ) const;
562
563
564 // list of objects
565 TQPtrList<KPrObject> m_objectList;
566 KPrDocument *m_doc;
567 KPrPage *m_masterPage;
568 KPrBackGround *m_kpbackground;
569 TQString m_manualTitle;
570 TQString m_noteText;
571 DCOPObject *m_dcop;
572 bool m_selectedSlides;
573
574 TQString m_pictureFile;
575 bool m_bHasHeader, m_bHasFooter;
576 bool m_useMasterBackground;
577
578
579 bool m_displayObjectFromMasterPage;
580
581 bool m_displayBackground;
582
586 PageEffect m_pageEffect;
590 EffectSpeed m_pageEffectSpeed;
591
595 // ### This could be simply !soundFileName.isEmpty()...
596 bool m_soundEffect;
600 TQString m_soundFileName;
604 int m_pageTimer;
605};
606#endif //KPRPAGE_H