kpresenter

KPrPage.h

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
00004    Copyright (C) 2004-2005 Thorsten Zachmann <zachmann@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KPRPAGE_H
00023 #define KPRPAGE_H
00024 
00025 #include <qwidget.h>
00026 #include <qptrlist.h>
00027 #include "global.h"
00028 #include <KoBrush.h>
00029 #include <KoPoint.h>
00030 #include <KoRect.h>
00031 #include <KoStyleCollection.h> // for KoStyleChangeDefMap
00032 #include <qvariant.h>
00033 #include <KoDocumentChild.h>
00034 #include <KoPictureCollection.h>
00035 
00036 class KMacroCommand;
00037 class KoSavingContext;
00038 class KURL;
00039 class KPrTextView;
00040 class KPrObject;
00041 class KPrDocument;
00042 class KPrView;
00043 class KoDocumentEntry;
00044 class KoPageLayout;
00045 class KCommand;
00046 class KoPointArray;
00047 class DCOPObject;
00048 class KPrTextObject;
00049 class KoTextObject;
00050 class KPrPixmapObject;
00051 class KPrPartObject;
00052 class KPrBackGround;
00053 
00054 class KoXmlWriter;
00055 class KoGenStyles;
00056 class KoPen;
00057 
00058 
00059 class KPrPage
00060 {
00061 public:
00068     KPrPage(KPrDocument *_doc, KPrPage *masterPage = 0 );
00069 
00073     virtual ~KPrPage();
00074 
00078     virtual DCOPObject* dcopObject();
00079 
00083     KPrDocument * kPresenterDoc() const {return m_doc; }
00084 
00090     QString manualTitle()const;
00091 
00097     void insertManualTitle(const QString & title);
00098 
00109     QString pageTitle( const QString &_title = QString() ) const;
00110 
00116     void setNoteText( const QString &_text );
00117 
00123     QString noteText( )const;
00124 
00130     void setMasterPage( KPrPage *_masterPage ) { m_masterPage = _masterPage; }
00131 
00137     KPrPage * masterPage() const { return m_masterPage; }
00138 
00145     bool isMasterPage() const;
00146 
00152     const QPtrList<KPrObject> & objectList() const { return m_objectList; }
00153 
00161     KPrObject *getObject( int num );
00162 
00171     void appendObject( KPrObject *_obj );
00172 
00181     void appendObjects( const QValueList<KPrObject *> &objects );
00182 
00191     void replaceObject( KPrObject *oldObject, KPrObject *newObject );
00192 
00200     int takeObject( KPrObject *object );
00201 
00210     KCommand * deleteSelectedObjects();
00211 
00221     void insertObject( KPrObject *object, int pos );
00222 
00226     void completeLoading( bool _clean, int lastObj );
00227 
00237     void unifyObjectName( KPrObject *object );
00238 
00244     KoRect getPageRect() const;
00245 
00251     QRect getZoomPageRect()const;
00252 
00258     void setObjectList( QPtrList<KPrObject> objectLlist ) {
00259         m_objectList.setAutoDelete( false ); m_objectList = objectLlist; m_objectList.setAutoDelete( false );
00260     }
00261 
00267     unsigned int objNums() const { return m_objectList.count(); }
00268 
00276     int numTextObject() const;
00287     KPrTextObject *textFrameSet( unsigned int _num ) const;
00288 
00294     int numSelected() const;
00295 
00299     void pasteObjs( const QByteArray & data, int nbCopy = 1, double angle = 0.0 ,
00300                     double _increaseX=0.0, double increaseY = 0.0, double moveX=0.0, double moveY=0.0);
00301 
00305     KCommand * replaceObjs( bool createUndoRedo, double _orastX, double _orastY,
00306                             const QColor & _txtBackCol, const QColor & _otxtBackCol);
00307 
00311     void copyObjs(QDomDocument &doc, QDomElement &presenter, QValueList<KoPictureKey> & lst) const;
00312 
00319     KPrObject* getSelectedObj() const;
00320 
00329     QPtrList<KPrObject> getSelectedObjects( bool withoutHeaderFooter = false ) const;
00330 
00337     KPrPixmapObject* getSelectedImage() const;
00338 
00347     KCommand * setImageEffect(ImageEffect eff, QVariant param1, QVariant param2, QVariant param3);
00348 
00355     void groupObjects();
00356 
00362     void ungroupObjects( KMacroCommand ** macro );
00363 
00367     void raiseObjs( bool forward );
00368 
00372     void lowerObjs( bool backward );
00373 
00374     KCommand* setPen( const KoPen &pen, LineEnd lb, LineEnd le, int flags );
00375     KCommand* setBrush( const QBrush &brush, FillType ft, const  QColor& g1, const QColor &g2,
00376                         BCType gt, bool unbalanced, int xfactor, int yfactor, int flags );
00377 
00381     KCommand * insertObject( const QString &name, KPrObject * object, const KoRect &r, bool addCommand = true );
00382 
00383     virtual KPrPartObject* insertObject( const KoRect&, KoDocumentEntry& );
00384 
00385     void insertRectangle( const KoRect &r, const KoPen & pen, const QBrush &brush, FillType ft,
00386                           const QColor &g1, const QColor & g2,BCType gt, int rndX, int rndY,
00387                           bool unbalanced, int xfactor, int yfactor );
00388 
00389     void insertCircleOrEllipse( const KoRect &r, const KoPen &pen, const QBrush &brush, FillType ft,
00390                                 const QColor &g1, const QColor &g2, BCType gt, bool unbalanced, int xfactor, int yfactor );
00391 
00392     void insertPie( const KoRect &r, const KoPen &pen, const QBrush &brush, FillType ft,
00393                     const QColor &g1, const QColor &g2,BCType gt, PieType pt, int _angle, int _len,
00394                     LineEnd lb,LineEnd le,bool unbalanced, int xfactor, int yfactor );
00395 
00396     KPrTextObject*  insertTextObject( const KoRect& r, const QString& text = QString::null, KPrView *_view = 0L );
00397     void insertLine( const KoRect &r, const KoPen &pen, LineEnd lb, LineEnd le, LineType lt );
00398 
00399     void insertAutoform( const KoRect &r, const KoPen &pen, const QBrush &brush, LineEnd lb, LineEnd le,
00400                          FillType ft,const QColor &g1, const QColor &g2, BCType gt, const QString &fileName,
00401                          bool unbalanced,int xfactor, int yfactor );
00402 
00403     void insertFreehand( const KoPointArray &points, const KoRect &r, const KoPen &pen,LineEnd lb, LineEnd le );
00404     void insertPolyline( const KoPointArray &points, const KoRect &r, const KoPen &pen,LineEnd lb, LineEnd le );
00405     void insertQuadricBezierCurve( const KoPointArray &points, const KoPointArray &allPoints, const KoRect &r,
00406                                    const KoPen &pen,LineEnd lb, LineEnd le );
00407     void insertCubicBezierCurve( const KoPointArray &points, const KoPointArray &allPoints, const KoRect &r,
00408                                  const KoPen &pen,LineEnd lb, LineEnd le );
00409 
00410     void insertPolygon( const KoPointArray &points, const KoRect &r, const KoPen &pen, const QBrush &brush,
00411                         FillType ft,const QColor &g1, const QColor &g2, BCType gt, bool unbalanced,
00412                         int xfactor, int yfactor, bool _checkConcavePolygon, int _cornersValue, int _sharpnessValue );
00413 
00414     void insertClosedLine( const KoPointArray &points, const KoRect &r, const KoPen &pen, const QBrush &brush,
00415                            FillType ft,const QColor &g1, const QColor &g2,
00416                            BCType gt, bool unbalanced, int xfactor, int yfactor, ToolEditMode _mode );
00417 
00418     void slotRepaintVariable();
00419     void recalcPageNum();
00420     void changePicture( const KURL & url, QWidget *parent );
00421     void insertPicture( const QString &filename, const KoPoint &pos );
00422     void insertPicture( const QString &_file, const KoRect &_rect );
00423 
00424     void enableEmbeddedParts( bool f );
00425 
00426     KPrBackGround *background() { return m_kpbackground; }
00427 
00428     void makeUsedPixmapList();
00429 
00430     void setBackColor( const QColor &backColor1, const QColor &backColor2, BCType bcType,
00431                        bool unbalanced, int xfactor, int yfactor );
00432     void setBackPicture( const KoPictureKey & key );
00433     bool getBackUnbalanced(  )const;
00434     void setBackView( BackView backView );
00435     void setBackType( BackType backType );
00436 
00437     void setPageEffect(  PageEffect pageEffect );
00438     void setPageEffectSpeed( EffectSpeed pageEffectSpeed );
00439     void setPageTimer(  int pageTimer );
00440     void setPageSoundEffect(  bool soundEffect );
00441     void setPageSoundFileName(  const QString &fileName );
00442     BackType getBackType(  ) const ;
00443     BackView getBackView( )const ;
00444     KoPictureKey getBackPictureKey( )const ;
00445     KoPicture getBackPicture( )const ;
00446     QColor getBackColor1( )const ;
00447     QColor getBackColor2()const ;
00448     int getBackXFactor()const ;
00449     int getBackYFactor( )const;
00450     BCType getBackColorType( )const;
00451     PageEffect getPageEffect( )const;
00452     EffectSpeed getPageEffectSpeed() const;
00453     int getPageTimer(  )const;
00454     bool getPageSoundEffect( )const;
00455     QString getPageSoundFileName()const;
00456 
00457 
00458     void setUseMasterBackground( bool useMasterBackground );
00459     bool useMasterBackground() const;
00460 
00464     QValueList<int> getEffectSteps() const;
00465 
00466     bool isSlideSelected() const {return  m_selectedSlides;}
00467     void slideSelected(bool _b){m_selectedSlides=_b;}
00468 
00469     void setInsPictureFile( const QString &_file ) { m_pictureFile = _file; }
00470 
00471     QString insPictureFile() const { return m_pictureFile; }
00472 
00473     void deSelectAllObj();
00474     void deSelectObj( KPrObject *kpobject );
00475     QDomElement saveObjects( QDomDocument &doc, QDomElement &objects, double yoffset,
00476                              int saveOnlyPage ) const;
00477 
00478     bool oneObjectTextExist(bool forceAllTextObject = true) ;
00479     bool oneObjectTextSelected();
00480     bool isOneObjectSelected();
00481     bool haveASelectedPartObj();
00482     bool haveASelectedGroupObj();
00483     bool haveASelectedPixmapObj();
00484 
00493     KoRect getRealRect( bool all ) const;
00494     bool chPic( KPrView *_view);
00495 
00496     //return command when we move object
00497     KCommand *moveObject(KPrView *_view, double diffx, double diffy);
00498     KCommand *moveObject(KPrView *m_view,const KoPoint &_move,bool key);
00499 
00500     KCommand *rotateSelectedObjects(float _newAngle, bool addAngle=false);
00501     KCommand *shadowObj(ShadowDirection dir,int dist, const QColor &col);
00502 
00503     QPtrList<KoTextObject> allTextObjects() const;
00504     void addTextObjects(QPtrList<KoTextObject>& lst) const;
00505 
00506     void repaintObj();
00507 
00508     KPrObject * getCursor(const QPoint &pos );
00509     KPrObject * getCursor(const KoPoint &pos );
00510 
00517     KPrObject* getObjectAt( const KoPoint &pos, bool withoutProtected = false ) const;
00518     KPrPixmapObject * picViewOrigHelper() const;
00519     void applyStyleChange( KoStyleChangeDefMap changed );
00520 
00521     void reactivateBgSpellChecking(bool refreshTextObj);
00522 
00523     bool canMoveOneObject() const;
00524     KCommand *alignVertical( VerticalAlignmentType _type );
00525     void changeTabStopValue ( double _tabStop );
00526     bool savePicture( KPrView *_view ) const;
00527     bool findTextObject( KPrObject *obj );
00528     KPrObject *nextTextObject(KPrTextObject *obj);
00529 
00530     void getAllObjectSelectedList(QPtrList<KPrObject> &lst,bool force = false );
00531     void getAllEmbeddedObjectSelected(QPtrList<KoDocumentChild> &embeddedObjects );
00532 
00533     void load( const QDomElement &element );
00534     void loadOasis( KoOasisContext & context );
00535 
00536     QDomElement save( QDomDocument &doc );
00537 
00538     bool saveOasisPage( KoStore *store, KoXmlWriter &xmlWriter, int posPage, KoSavingContext& context, 
00539                        int & indexObj, int &partIndexObj, KoXmlWriter* manifestWriter, QMap<QString, int> &pageNames ) const;
00540     QString saveOasisPageStyle( KoStore *store, KoGenStyles& mainStyles ) const;
00541     QString saveOasisPageEffect() const;
00542     QString saveOasisAdditionalPageEffect() const;
00543     bool saveOasisNote( KoXmlWriter &xmlWriter ) const;
00544 
00545     bool hasHeader() const { return m_bHasHeader; }
00546     bool hasFooter() const { return m_bHasFooter; }
00547     void setHeader( bool b, bool _updateDoc = true );
00548     void setFooter( bool b, bool _updateDoc = true );
00549 
00550     void setDisplayObjectFromMasterPage( bool _b );
00551     bool displayObjectFromMasterPage() const { return m_displayObjectFromMasterPage;}
00552 
00553     void setDisplayBackground( bool _b );
00554     bool displayBackground() const { return m_displayBackground; }
00555 
00556     QString oasisNamePage( int posPage ) const;
00557 
00558 private:
00559     void makeUsedPixmapListForGroupObject( KPrObject *_obj );
00560     void completeLoadingForGroupObject( KPrObject *_obj );
00561     bool objectNameExists( KPrObject *object, QPtrList<KPrObject> &list );
00562     void saveOasisObject( KoStore *store, KoXmlWriter &xmlWriter, KoSavingContext& context, int & indexObj, int &partIndexObj,  KoXmlWriter* manifestWriter ) const;
00563 
00564 
00565     // list of objects
00566     QPtrList<KPrObject> m_objectList;
00567     KPrDocument *m_doc;
00568     KPrPage *m_masterPage;
00569     KPrBackGround *m_kpbackground;
00570     QString m_manualTitle;
00571     QString m_noteText;
00572     DCOPObject *m_dcop;
00573     bool m_selectedSlides;
00574 
00575     QString m_pictureFile;
00576     bool m_bHasHeader, m_bHasFooter;
00577     bool m_useMasterBackground;
00578 
00579 
00580     bool m_displayObjectFromMasterPage;
00581 
00582     bool m_displayBackground;
00583 
00587     PageEffect m_pageEffect;
00591     EffectSpeed m_pageEffectSpeed;
00592 
00596     // ### This could be simply !soundFileName.isEmpty()...
00597     bool m_soundEffect;
00601     QString m_soundFileName;
00605     int m_pageTimer;
00606 };
00607 #endif //KPRPAGE_H
KDE Home | KDE Accessibility Home | Description of Access Keys