summaryrefslogtreecommitdiffstats
path: root/kword/KWPartFrameSet.h
blob: 25609c1a734af00f81a70f9b94be6ec0c7f2aa8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* This file is part of the KDE project
   Copyright (C) 2002 David Faure <faure@kde.org>
   Copyright (C) 2005 Thomas Zander <zander@kde.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2, as published by the Free Software Foundation.

   This program 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 program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KWPARTFRAMESET_H
#define KWPARTFRAMESET_H

#include "KWFrameSet.h"
class KWDocumentChild;
class KWFramePartMoveCommand;
/**
 * @short A frameset that contains an embedded object (a KWDocumentChild)
 */
class KWPartFrameSet : public KWFrameSet
{
    Q_OBJECT
  TQ_OBJECT
public:
    KWPartFrameSet( KWDocument *_doc, KWDocumentChild *_child, const TQString & name );

    /// Used for OASIS loading
    KWPartFrameSet( KWDocument* doc, const TQDomElement& frameTag,
                    const TQDomElement& objectTag, KoOasisContext& context );

    virtual ~KWPartFrameSet();

    virtual KWordFrameSetIface* dcopObject();


    /** The type of frameset. Use this to differentiate between different instantiations of
     *  the framesets. Each implementation will return a different frameType.
     */
    virtual FrameSetType type() const { return FT_PART; }

    virtual KWFrameSetEdit * createFrameSetEdit( KWCanvas * );

    KWDocumentChild *getChild() const { return m_child; }
    void setChild( KWDocumentChild* child );

    /**
     * Update the tqgeometry of m_child based on the tqgeometry of the frame.
     */
    void updateChildGeometry();

    virtual void drawFrameContents( KWFrame * frame, TQPainter *painter, const TQRect & fcrect,
                                    const TQColorGroup &cg, bool onlyChanged, bool resetChanged,
                                    KWFrameSetEdit * edit, KWViewMode *viewMode );

    virtual void createEmptyRegion( const TQRect &crect, TQRegion &emptyRegion, KWViewMode *viewMode );

    virtual TQDomElement save( TQDomElement &parentElem, bool saveFrames = true );
    virtual void load( TQDomElement &attributes, bool loadFrames = true );
    virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context, bool saveFrames ) const;


    /**
     * Called by KWView when the object is being edited (activated).
     * Allows to store the initial position.
     */
    void startEditing();
    /**
     * Called by KWView when the object is not being edited anymore (deactivated).
     * Allows to create a frame-move command if the frame was moved.
     */
    void endEditing();

    /**
     * Move the frame 'frameNum' to the given position and
     * move the document child window with it
     * This is called when the frame is anchored and the anchor moves (see KWAnchor).
    */
    virtual void moveFloatingFrame( int frameNum, const KoPoint &position );

#ifndef NDEBUG
    virtual void printDebug();
#endif

    /**
    *   Delete a frame from the set of frames this frameSet has.
    *   @param num The frameNumber to be removed.
    *   @param remove passing true means that there can not be an undo of the action.
    *   @param recalc do an updateFrames()
    */
    void deleteFrame( unsigned int num, bool remove = true, bool recalc = true );

    void setDeleted( bool on = true );

    virtual void storeInternal();

    virtual void setProtectContent (  bool protect ) { m_protectContent = protect; }
    virtual bool protectContent() const { return m_protectContent; }

private slots:
    void slotChildChanged();

private:
    KWDocumentChild *m_child;
    KWFramePartMoveCommand *m_cmdMoveChild;
    bool m_protectContent;
};

#if 0
class KWPartFrameSetEdit :  public TQObject, public KWFrameSetEdit
{
    //Q_OBJECT
  TQ_OBJECT
public:
    KWPartFrameSetEdit( KWPartFrameSet * fs, KWCanvas * canvas );
    virtual ~KWPartFrameSetEdit();

    virtual DCOPObject* dcopObject();


    KWPartFrameSet * partFrameSet() const
    {
        return static_cast<KWPartFrameSet*>(frameSet());
    }

    // Events forwarded by the canvas (when being in "edit" mode)
    //virtual void mousePressEvent( TQMouseEvent *, const TQPoint &, const KoPoint & );
    //virtual void mouseDoubleClickEvent( TQMouseEvent *, const TQPoint &, const KoPoint & );
//private slots:
    void slotChildActivated(bool);
private:
    DCOPObject *m_dcop;
};
#endif

#include <KoDocumentChild.h>
class KWDocument;

/******************************************************************/
/* Class: KWDocumentChild                                              */
/******************************************************************/
class KWDocumentChild : public KoDocumentChild
{
public:
    KWDocumentChild( KWDocument *_wdoc, const TQRect& _rect, KoDocument *_doc );
    KWDocumentChild( KWDocument *_wdoc );
    ~KWDocumentChild();

    KWDocument* parent()const
    { return m_pKWordDoc; }

    virtual void setDocument( KoDocument *doc, const TQRect &tqgeometry );

    void setPartFrameSet( KWPartFrameSet* fs ) { m_partFrameSet = fs; }
    KWPartFrameSet * partFrameSet() const { return m_partFrameSet; }
    virtual KoDocument* hitTest( const TQPoint& p, const TQWMatrix& _matrix = TQWMatrix() );

private:
    KWDocument *m_pKWordDoc;
    KWPartFrameSet *m_partFrameSet;
};

#endif // KWPARTFRAMESET_H