KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.4KB

  1. /* This file is part of the KDE project
  2. Copyright 2004 Ariya Hidayat <ariya@kde.org>
  3. Copyright 2003 David Faure <faure@kde.org>
  4. Copyright 2001 Philipp Mueller <philipp.mueller@gmx.de>
  5. Copyright 2001 Laurent Montel <montel@kde.org>
  6. Copyright 2002 Werner Trobin <trobin@kde.org>
  7. Copyright 1999 Torben Weis <weis@kde.org>
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Library General Public License for more details.
  16. You should have received a copy of the GNU Library General Public License
  17. along with this library; see the file COPYING.LIB. If not, write to
  18. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301, USA.
  20. */
  21. #include "KSpreadAppIface.h"
  22. #include "kspread_doc.h"
  23. #include <dcopclient.h>
  24. #include <kapplication.h>
  25. using namespace KSpread;
  26. AppIface::AppIface()
  27. : DCOPObject( "Application" )
  28. {
  29. }
  30. DCOPRef AppIface::createDoc()
  31. {
  32. Doc* doc = new Doc();
  33. doc->initDoc(KoDocument::InitDocFileNew);
  34. return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
  35. }
  36. DCOPRef AppIface::createDoc( const TQString& name )
  37. {
  38. // ######### Torben: Check for duplicate names here
  39. Doc* doc = new Doc( 0, name.latin1() );
  40. doc->initDoc( KoDocument::InitDocEmpty, 0 );
  41. return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
  42. }
  43. TQMap<TQString,DCOPRef> AppIface::documents()
  44. {
  45. TQMap<TQString,DCOPRef> map;
  46. TQValueList<Doc*> lst = Doc::documents();
  47. TQValueListIterator<Doc*> it = lst.begin();
  48. for( ; it != lst.end(); ++it )
  49. {
  50. map[ TQString( (*it)->name() ) ] =
  51. DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
  52. }
  53. return map;
  54. }
  55. DCOPRef AppIface::document( const TQString& name )
  56. {
  57. TQValueList<Doc*> lst = Doc::documents();
  58. TQValueListIterator<Doc*> it = lst.begin();
  59. for( ; it != lst.end(); ++it )
  60. if ( name == (*it)->name() )
  61. return DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
  62. return DCOPRef();
  63. }