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.

102 lines
3.0KB

  1. /* This file is part of the KDE project
  2. Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. * Boston, MA 02110-1301, USA.
  15. */
  16. #include <kdebug.h>
  17. #include <kstandarddirs.h>
  18. #include "kspread_aboutdata.h"
  19. #include "kspread_doc.h"
  20. #include "KSpreadAppIface.h"
  21. #include "kspread_factory.h"
  22. using namespace KSpread;
  23. TDEInstance* Factory::s_global = 0;
  24. DCOPObject* Factory::s_dcopObject = 0;
  25. TDEAboutData* Factory::s_aboutData = 0;
  26. Factory::Factory( TQObject* parent, const char* name )
  27. : KoFactory( parent, name )
  28. {
  29. //kdDebug(36001) << "Factory::Factory()" << endl;
  30. // Create our instance, so that it becomes TDEGlobal::instance if the
  31. // main app is KSpread.
  32. (void)global();
  33. (void)dcopObject();
  34. }
  35. Factory::~Factory()
  36. {
  37. //kdDebug(36001) << "Factory::~Factory()" << endl;
  38. delete s_aboutData;
  39. s_aboutData=0;
  40. delete s_global;
  41. s_global = 0L;
  42. delete s_dcopObject;
  43. s_dcopObject = 0L;
  44. }
  45. KParts::Part* Factory::createPartObject( TQWidget *parentWidget, const char *widgetName, TQObject* parent, const char* name, const char* classname, const TQStringList & )
  46. {
  47. bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
  48. Doc *doc = new Doc( parentWidget, widgetName, parent, name, !bWantKoDocument );
  49. if ( !bWantKoDocument )
  50. doc->setReadWrite( false );
  51. return doc;
  52. }
  53. TDEAboutData* Factory::aboutData()
  54. {
  55. if( !s_aboutData )
  56. s_aboutData = newAboutData();
  57. return s_aboutData;
  58. }
  59. TDEInstance* Factory::global()
  60. {
  61. if ( !s_global )
  62. {
  63. s_global = new TDEInstance(aboutData());
  64. s_global->dirs()->addResourceType( "kspread_template",
  65. TDEStandardDirs::kde_default("data") + "kspread/templates/");
  66. s_global->dirs()->addResourceType( "toolbar",
  67. TDEStandardDirs::kde_default("data") + "koffice/toolbar/");
  68. s_global->dirs()->addResourceType( "extensions", TDEStandardDirs::kde_default("data") + "kspread/extensions/");
  69. s_global->dirs()->addResourceType( "sheet-styles", TDEStandardDirs::kde_default("data") + "kspread/sheetstyles/");
  70. // Tell the iconloader about share/apps/koffice/icons
  71. s_global->iconLoader()->addAppDir("koffice");
  72. }
  73. return s_global;
  74. }
  75. DCOPObject* Factory::dcopObject()
  76. {
  77. if ( !s_dcopObject )
  78. s_dcopObject = new AppIface;
  79. return s_dcopObject;
  80. }
  81. #include "kspread_factory.moc"