summaryrefslogtreecommitdiffstats
path: root/kate/app/katedocmanageriface.cpp
blob: 5ef01a1dfda7b477451ef8ac7700338026587c77 (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
/* This file is part of the KDE project
   Copyright (C) 2003 Ian Reinhart Geiser <geiseri@kde.org>

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

#include "katedocmanageriface.h"

#include "katedocmanager.h"

#include <kdebug.h>

KateDocManagerDCOPIface::KateDocManagerDCOPIface (KateDocManager *dm) : DCOPObject ("KateDocumentManager"), m_dm (dm)
{

}

// bit more error save than the forcing c cast ;()
DCOPRef KateDocManagerDCOPIface::document (uint n)
{
  Kate::Document *doc = m_dm->document(n);

  if (!doc)
    return DCOPRef ();

  DCOPObject *obj = static_cast<DCOPObject*>(doc->qt_cast("DCOPObject"));

  if (!obj)
    return DCOPRef ();

  return DCOPRef (obj);
}

DCOPRef KateDocManagerDCOPIface::activeDocument ()
{
  Kate::Document *doc = m_dm->activeDocument();

  if (!doc)
    return DCOPRef ();

  DCOPObject *obj = static_cast<DCOPObject*>(doc->qt_cast("DCOPObject"));

  if (!obj)
    return DCOPRef ();

  return DCOPRef (obj);
}

uint KateDocManagerDCOPIface::activeDocumentNumber ()
{
  Kate::Document *doc = m_dm->activeDocument();

  if (doc)
    return doc->documentNumber ();
  
  return 0;
}

DCOPRef KateDocManagerDCOPIface::documentWithID (uint id)
{
  Kate::Document *doc = m_dm->documentWithID (id);

  if (!doc)
    return DCOPRef ();

  DCOPObject *obj = static_cast<DCOPObject*>(doc->qt_cast("DCOPObject"));

  if (!obj)
    return DCOPRef ();

  return DCOPRef (obj);
}

DCOPRef KateDocManagerDCOPIface::openURL (KURL url, TQString encoding)
{
  Kate::Document *doc = m_dm->openURL (url, encoding);

  if (!doc)
    return DCOPRef ();

  DCOPObject *obj = static_cast<DCOPObject*>(doc->qt_cast("DCOPObject"));

  if (!obj)
    return DCOPRef ();

  return DCOPRef (obj);
}

bool KateDocManagerDCOPIface::closeDocument(uint n)
{
  return m_dm->closeDocument(n);
}

bool KateDocManagerDCOPIface::closeDocumentWithID(uint id)
{
  return m_dm->closeDocumentWithID (id);
}

bool KateDocManagerDCOPIface::closeAllDocuments()
{
  return m_dm->closeAllDocuments();
}

bool KateDocManagerDCOPIface::isOpen(KURL url)
{
  return m_dm->isOpen (url);
}

uint KateDocManagerDCOPIface::documents ()
{
  return m_dm->documents();
}

int KateDocManagerDCOPIface::findDocument (KURL url)
{
  return m_dm->findDocument (url);
}