20#include "KoApplication.h"
24#include <dcopclient.h>
25#include <KoApplicationIface.h>
26#include <KoQueryTrader.h>
27#include <KoDocument.h>
28#include <KoMainWindow.h>
30#include <tdecmdlineargs.h>
32#include <kdesktopfile.h>
33#include <tdemessagebox.h>
34#include <kstandarddirs.h>
37void tqt_generate_epsf(
bool b );
39static const TDECmdLineOptions options[]=
41 {
"print", I18N_NOOP(
"Only print and exit"),0},
42 {
"template", I18N_NOOP(
"Open a new document with a template"), 0},
43 {
"dpi <dpiX,dpiY>", I18N_NOOP(
"Override display DPI"), 0},
47bool KoApplication::m_starting =
true;
49class KoApplicationPrivate
52 KoApplicationPrivate() {
59 : TDEApplication( initHack() )
61 d =
new KoApplicationPrivate;
64 KoGlobal::initialize();
68 dcopClient()->setDefaultObject( d->m_appIface->objId() );
74bool KoApplication::initHack()
76 TDECmdLineArgs::addCmdLineOptions( options, I18N_NOOP(
"KOffice"),
"koffice",
"kde" );
81class KoApplication::ResetStarting
85 KoApplication::m_starting =
false;
91 ResetStarting resetStarting;
92 Q_UNUSED( resetStarting );
98 kdError( 30003 ) << instanceName() <<
"part.desktop not found." << endl;
99 kdError( 30003 ) <<
"Run 'tde-config --path services' to see which directories were searched, assuming kde startup had the same environment as your current shell." << endl;
100 kdError( 30003 ) <<
"Check your installation (did you install KOffice in a different prefix than TDE, without adding the prefix to /etc/tderc ?)" << endl;
105 TDECmdLineArgs *args= TDECmdLineArgs::parsedArgs();
106 int argsCount = args->count();
108 TDECmdLineArgs *koargs = TDECmdLineArgs::parsedArgs(
"koffice");
109 TQCString dpiValues = koargs->getOption(
"dpi" );
110 if ( !dpiValues.isEmpty() ) {
111 int sep = dpiValues.find( TQRegExp(
"[x, ]" ) );
116 dpiY = dpiValues.mid( sep+1 ).toInt( &ok );
117 dpiValues.truncate( sep );
120 dpiX = dpiValues.toInt( &ok );
122 if ( !dpiY ) dpiY = dpiX;
123 KoGlobal::setDPI( dpiX, dpiY );
135 TQObject::connect(doc, TQ_SIGNAL(sigProgress(
int)), shell, TQ_SLOT(slotProgress(
int)));
147 TQObject::disconnect(doc, TQ_SIGNAL(sigProgress(
int)), shell, TQ_SLOT(slotProgress(
int)));
149 bool print = koargs->isSet(
"print");
150 bool doTemplate = koargs->isSet(
"template");
156 short int nPrinted = 0;
157 for(
int i=0; i < argsCount; i++ )
170 if ( args->url(i).isLocalFile() && TQFile::exists(args->url(i).path()) )
172 paths << TQString(args->url(i).path());
173 kdDebug(30003) <<
"using full path..." << endl;
175 TQString desktopName(args->arg(i));
176 TQString appName = TDEGlobal::instance()->instanceName();
178 paths = TDEGlobal::dirs()->findAllResources(
"data", appName +
"/templates/*/" + desktopName );
179 if ( paths.isEmpty()) {
180 paths = TDEGlobal::dirs()->findAllResources(
"data", appName +
"/templates/" + desktopName );
182 if ( paths.isEmpty()) {
185 }
else if ( paths.count() > 1 ) {
191 if ( !paths.isEmpty() ) {
193 templateBase.setPath(paths[0]);
194 KDesktopFile templateInfo(paths[0]);
196 TQString templateName = templateInfo.readURL();
198 templateURL.setPath( templateBase.directory() +
"/" + templateName );
203 kdDebug(30003) <<
"Template loaded..." << endl;
206 KMessageBox::error(0L, i18n(
"Template %1 failed to load.").arg(templateURL.prettyURL()) );
213 shell->
print(
false );
240 delete d->m_appIface;
246 return KoApplication::m_starting;
249#include <KoApplication.moc>
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
virtual TDEInstance * instance() const
DCOP interface for any KOffice application (entry point)
virtual ~KoApplication()
Destructor.
virtual bool start()
Call this to start the application.
KoApplication()
Creates an application object, adds some standard directories and initializes kimgio.
Represents an available KOffice component that supports the document interface.
KoDocument * createDoc(KoDocument *parent=0, const char *name=0) const
Uses the factory of the component to create a document.
The KOffice document class.
void resetURL()
Sets the document URL to empty URL KParts doesn't allow this, but KOffice apps have e....
bool checkAutoSaveFile()
Called by koApplication to check for an autosave file in $HOME.
virtual void setEmpty()
Sets the document to empty.
virtual void addShell(KoMainWindow *shell)
Appends the shell to the list of shells which show this document as their root document.
static KService::Ptr readNativeService(TDEInstance *instance=0)
With the help of instance or TDEApplication::instance() this method figures out which ....
virtual void showStartUpWidget(KoMainWindow *parent, bool alwaysShow=false)
Creates and shows the start up widget.
virtual void setTitleModified()
Tells the document that its title has been modified, either because the modified status changes (this...
Main window for a KOffice application.
void print(bool quick)
Prints the document.
virtual void setRootDocument(KoDocument *doc)
Called when a document is assigned to this mainwindow.
virtual bool openDocument(const KURL &url)
Load the desired document and show it.