kword

KWordTableFrameSetIface.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "KWordTableFrameSetIface.h"
21#include "KWordTextFrameSetIface.h"
22#include "KWordTextFrameSetEditIface.h"
23
24#include "KWFrame.h"
25#include "KWTableFrameSet.h"
26#include <tdeapplication.h>
27#include <dcopclient.h>
28#include "KWView.h"
29#include "KWDocument.h"
30#include "KWCanvas.h"
31
32KWordTableFrameSetIface::KWordTableFrameSetIface( KWTableFrameSet *_frame )
33 : KWordFrameSetIface( _frame)
34{
35 m_table = _frame;
36}
37
38uint KWordTableFrameSetIface::nbRows()
39{
40 return m_table->getRows();
41}
42
43uint KWordTableFrameSetIface::numCols()
44{
45 return m_table->getColumns();
46}
47uint KWordTableFrameSetIface::numCells()
48{
49 return m_table->getNumCells();
50}
51
52DCOPRef KWordTableFrameSetIface::cell( int pos )
53{
54 // This method now sucks
55 KWTableFrameSet::TableIter i(m_table);
56 int p = 0;
57 for(; i && p <= pos; ++i,++p)
58 if( ! i.current() )
59 return DCOPRef();
60
61 return DCOPRef( kapp->dcopClient()->appId(),
62 i->dcopObject()->objId() );
63}
64
65DCOPRef KWordTableFrameSetIface::cell( uint row, uint col )
66{
67 if( row>=m_table->getRows() || col>= m_table->getColumns())
68 return DCOPRef();
69 return DCOPRef( kapp->dcopClient()->appId(),
70 m_table->cell(row,col)->dcopObject()->objId() );
71}
72
73DCOPRef KWordTableFrameSetIface::startEditingCell(uint row, uint col )
74{
75 if( row>=m_table->getRows() || col>= m_table->getColumns())
76 return DCOPRef();
77
78 KWDocument *doc=m_table->kWordDocument();
79 KWView* view = doc->getAllViews().first();
80 KWCanvas* canvas = view->getGUI()->canvasWidget();
81 KWTextFrameSet *m_frametext=m_table->cell(row,col);
82 if( !m_frametext || m_frametext->isDeleted())
83 return DCOPRef();
84 canvas->checkCurrentEdit(m_frametext, true);
85 return DCOPRef( kapp->dcopClient()->appId(),
86 (static_cast<KWTextFrameSetEdit *>( canvas->currentFrameSetEdit()))->dcopObject()->objId() );
87}
bool isDeleted() const
True if the frameset was deleted (but not destroyed, since it's in the undo/redo).
Definition KWFrameSet.h:166
This class implements tables by acting as the manager for the frame(set)s which make up the table cel...
unsigned int getRows() const
returns the number of rows