diff --git a/lib/kofficecore/koApplication.cc b/lib/kofficecore/koApplication.cc index 2db374e2db..2d2bd9103f 100644 --- a/lib/kofficecore/koApplication.cc +++ b/lib/kofficecore/koApplication.cc @@ -1,39 +1,83 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include +#include -KoApplication::KoApplication(int &argc, char **argv, - const QString& rAppName) - : OPApplication(argc, argv, rAppName), - kded( argc, argv, opapp_orb ) +KoApplication::KoApplication(int &argc, char **argv, const QString& rAppName) + : OPApplication(argc, argv, rAppName) + , kded( argc, argv, opapp_orb ) + , m_params( argc, argv ) + , m_bWithGUI( true ) { KGlobal::locale()->insertCatalogue("koffice"); KGlobal::iconLoader()->insertDirectory(0, kde_datadir() + "/koffice/toolbar"); KGlobal::iconLoader()->insertDirectory(3, localkdedir() + "/share/apps/koffice/toolbar"); } -KoApplication::~KoApplication() {} +KoApplication::~KoApplication() +{ + // checking wether start the app as server or not + QStringList::Iterator it; + if( m_params.find( "--server", "-s", true, it ) ) + { + m_bWithGUI = false; + m_params.del( it ); + } } +void KoApplication::start() +{ + KoMainWindow* pShell; + QStringList openFiles; + + if( m_bWithGUI ) + { + for( uint i = 0; i < m_params.count(); i++ ) + { + if( m_params.get( i ).left( 1 ) != "-" ) + { + openFiles.append( m_params.get( i ) ); + } + } + if( openFiles.isEmpty() ) + { + pShell = createNewShell(); + pShell->show(); + pShell->newDocument(); + } + else + { + QStringList::Iterator it; + + for( it = openFiles.begin() ; it != openFiles.end() ; ++it ) + { + pShell = createNewShell(); + pShell->show(); + pShell->openDocument( *it, "" ); + } + } + } +} + #include "koApplication.moc" diff --git a/lib/kofficecore/koApplication.h b/lib/kofficecore/koApplication.h index 76a523e2b5..b8e2a3c053 100644 --- a/lib/kofficecore/koApplication.h +++ b/lib/kofficecore/koApplication.h @@ -1,39 +1,47 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __ko_app_h__ #define __ko_app_h__ #include #include +#include + +class KoMainWindow; class KoApplication : public OPApplication { Q_OBJECT public: KoApplication( int &argc, char **argv, const QString& rAppName = 0); virtual ~KoApplication(); + virtual KoMainWindow* createNewShell() = 0; + virtual void start(); + private: KdedInstance kded; + KStartParams m_params; + bool m_bWithGUI; }; #endif diff --git a/lib/kofficecore/koMainWindow.h b/lib/kofficecore/koMainWindow.h index d4583d77a4..23aff44f74 100644 --- a/lib/kofficecore/koMainWindow.h +++ b/lib/kofficecore/koMainWindow.h @@ -1,110 +1,113 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __ko_main_window_h__ #define __ko_main_window_h__ #include #include #include #include class OPMenu; class OPMenuBar; class KoFrame; class KoMainWindowIf; class KoDocument; class KoViewIf; class KoMainWindow : public OPMainWindow { Q_OBJECT public: KoMainWindow( const char *_name = 0L ); ~KoMainWindow(); virtual OPMainWindowIf* interface(); virtual KoMainWindowIf* koInterface(); virtual void createFileMenu( OPMenuBar* ); virtual void createHelpMenu( OPMenuBar* ); virtual void setRootPart( unsigned long _part_id ); virtual void setRootPart( KoViewIf* _view ); virtual void cleanUp(); virtual KOffice::Document_ptr document() = 0L; virtual KOffice::View_ptr view() = 0L; KoFrame *getFrame() { return m_pFrame; } + + virtual bool newDocument() = 0; + virtual bool openDocument( const char* _filename, const char* _format ) = 0; protected slots: virtual void slotActivePartChanged( unsigned long _new_part_id, unsigned long _old_opart_id ); virtual void slotFileNew(); virtual void slotFileOpen(); virtual void slotFileSave(); virtual void slotFileSaveAs(); virtual void slotFilePrint(); virtual void slotFileClose(); virtual void slotFileQuit(); virtual void slotHelpAbout(); protected: OPMenu* m_pFileMenu; OPMenu* m_pHelpMenu; int m_idMenuFile_New; int m_idMenuFile_Open; int m_idMenuFile_Save; int m_idMenuFile_SaveAs; int m_idMenuFile_Print; int m_idMenuFile_Close; int m_idMenuFile_Quit; int m_idMenuHelp_About; enum { TOOLBAR_NEW, TOOLBAR_OPEN, TOOLBAR_SAVE, TOOLBAR_PRINT }; KoFrame* m_pFrame; KoMainWindowIf* m_pKoInterface; }; class KoMainWindowIf : virtual public OPMainWindowIf, virtual public KOffice::MainWindow_skel { public: KoMainWindowIf( KoMainWindow* _main ); ~KoMainWindowIf(); // IDL virtual void setMarkedPart( OpenParts::Id id ); virtual KOffice::Document_ptr document(); virtual KOffice::View_ptr view(); virtual CORBA::Boolean partClicked( OpenParts::Id _part_id, CORBA::Long _button ); protected: void unmarkPart(); KoMainWindow* m_pKoMainWindow; OpenParts::Id m_iMarkedPart; }; #endif