~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kivio/kiviopart/KIvioMapIface.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#include "KIvioMapIface.h"
 
21
 
 
22
#include "kivio_map.h"
 
23
#include "kivio_doc.h"
 
24
#include "kivio_page.h"
 
25
 
 
26
#include <kapplication.h>
 
27
#include <dcopclient.h>
 
28
#include <kdebug.h>
 
29
 
 
30
KIvioMapIface::KIvioMapIface( KivioMap* map )
 
31
    : DCOPObject( map )
 
32
{
 
33
    m_map = map;
 
34
}
 
35
 
 
36
DCOPRef KIvioMapIface::page( const QString& name )
 
37
{
 
38
    KivioPage* t = m_map->findPage( name );
 
39
    if ( !t )
 
40
        return DCOPRef();
 
41
 
 
42
    return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
 
43
}
 
44
 
 
45
DCOPRef KIvioMapIface::pageByIndex( int index )
 
46
{
 
47
    KivioPage* t = m_map->pageList().at( index );
 
48
    if ( !t )
 
49
    {
 
50
        kdDebug(43000) << "+++++ No page found at index " << index << endl;
 
51
        return DCOPRef();
 
52
    }
 
53
 
 
54
    kdDebug(43000) << "+++++++ Returning page " << t->QObject::name() << endl;
 
55
 
 
56
    return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
 
57
}
 
58
 
 
59
int KIvioMapIface::pageCount() const
 
60
{
 
61
    return m_map->count();
 
62
}
 
63
 
 
64
QStringList KIvioMapIface::pageNames() const
 
65
{
 
66
    QStringList names;
 
67
 
 
68
    QPtrList<KivioPage>& lst = m_map->pageList();
 
69
    QPtrListIterator<KivioPage> it( lst );
 
70
    for( ; it.current(); ++it )
 
71
        names.append( it.current()->name() );
 
72
 
 
73
    return names;
 
74
}
 
75
 
 
76
QValueList<DCOPRef> KIvioMapIface::pages()
 
77
{
 
78
    QValueList<DCOPRef> t;
 
79
 
 
80
    QPtrList<KivioPage>& lst = m_map->pageList();
 
81
    QPtrListIterator<KivioPage> it( lst );
 
82
    for( ; it.current(); ++it )
 
83
        t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
 
84
 
 
85
    return t;
 
86
}
 
87
 
 
88
DCOPRef KIvioMapIface::insertPage( const QString& name )
 
89
{
 
90
    if ( m_map->findPage( name ) )
 
91
        return page( name );
 
92
 
 
93
    KivioPage* t = new KivioPage( m_map, name );
 
94
    t->setPageName( name );
 
95
    m_map->doc()->addPage( t );
 
96
 
 
97
    return page( name );
 
98
}
 
99
 
 
100
bool KIvioMapIface::processDynamic(const QCString &fun, const QByteArray &/*data*/,
 
101
                                     QCString& replyType, QByteArray &replyData)
 
102
{
 
103
    // Does the name follow the pattern "foobar()" ?
 
104
    uint len = fun.length();
 
105
    if ( len < 3 )
 
106
        return FALSE;
 
107
 
 
108
    if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
 
109
        return FALSE;
 
110
 
 
111
    KivioPage* t = m_map->findPage( fun.left( len - 2 ).data() );
 
112
    if ( !t )
 
113
        return FALSE;
 
114
 
 
115
    replyType = "DCOPRef";
 
116
    QDataStream out( replyData, IO_WriteOnly );
 
117
    out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
 
118
    return TRUE;
 
119
}