diff options
Diffstat (limited to 'kugar/part')
-rw-r--r-- | kugar/part/Makefile.am | 35 | ||||
-rw-r--r-- | kugar/part/kugar.desktop | 76 | ||||
-rw-r--r-- | kugar/part/kugar_about.h | 53 | ||||
-rw-r--r-- | kugar/part/kugar_factory.cpp | 92 | ||||
-rw-r--r-- | kugar/part/kugar_factory.h | 36 | ||||
-rw-r--r-- | kugar/part/kugar_part.cpp | 259 | ||||
-rw-r--r-- | kugar/part/kugar_part.h | 68 | ||||
-rw-r--r-- | kugar/part/kugar_view.cpp | 131 | ||||
-rw-r--r-- | kugar/part/kugar_view.h | 53 | ||||
-rw-r--r-- | kugar/part/kugarpart.desktop | 118 | ||||
-rw-r--r-- | kugar/part/kugarpart.rc | 21 | ||||
-rw-r--r-- | kugar/part/kugartemplate.dtd | 155 | ||||
-rw-r--r-- | kugar/part/main.cpp | 44 |
13 files changed, 1141 insertions, 0 deletions
diff --git a/kugar/part/Makefile.am b/kugar/part/Makefile.am new file mode 100644 index 00000000..65abd539 --- /dev/null +++ b/kugar/part/Makefile.am @@ -0,0 +1,35 @@ +INCLUDES = -I$(srcdir)/../lib $(KOFFICE_INCLUDES) $(all_includes) + +lib_LTLIBRARIES = +kde_module_LTLIBRARIES = libkugarpart.la +libkugarpart_la_SOURCES = kugar_part.cpp kugar_factory.cpp kugar_view.cpp +libkugarpart_la_LDFLAGS = $(all_libraries) -module -avoid-version +libkugarpart_la_LIBADD = ../lib/libkugarlib.la $(LIB_KPARTS) $(LIB_KDEPRINT) $(LIB_KOFFICECORE) + +libkugarpart_la_METASOURCES = AUTO + +xdg_apps_DATA = kugar.desktop + +rcdir = $(kde_datadir)/kugar +rc_DATA = kugarpart.rc + +dtddir = $(kde_datadir)/kugar/dtd +dtd_DATA = kugartemplate.dtd + +EXTRA_DIST = \ + kugar_part.h \ + $(xdg_apps_DATA) \ + $(rc_DATA) \ + $(dtd_DATA) + +CLEANFILES = kugarpart_meta_unload.cpp + + +## The kdeinit loadable module and executable +kdeinit_LTLIBRARIES = kugar.la +bin_PROGRAMS = +kugar_la_SOURCES = main.cpp +kugar_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kugar_la_LIBADD = $(LIB_KOFFICECORE) + +kde_services_DATA = kugarpart.desktop diff --git a/kugar/part/kugar.desktop b/kugar/part/kugar.desktop new file mode 100644 index 00000000..7789ce04 --- /dev/null +++ b/kugar/part/kugar.desktop @@ -0,0 +1,76 @@ +[Desktop Entry] +Name=Kugar +Name[hi]=कुगर +Name[lo]=ຄູການ +Name[ne]=कुगर +Name[th]=คูการ์ +Exec=kugar %u +Icon=kugar +MimeType=application/x-kugar;application/x-vnd.kde.kugar.mixed +Type=Application +DocPath=kugar/index.html +GenericName=Report Generator +GenericName[af]=Raporteer Genereerder +GenericName[ar]=مُوَلِّد التَّقارير +GenericName[az]=Raport Yaradıcısı +GenericName[bg]=Генератор на отчети +GenericName[bs]=Generator izvještaja +GenericName[ca]=Generador d'informes +GenericName[cs]=Generátor reportů +GenericName[cy]=Cynhyrchydd Adroddiad +GenericName[da]=Rapportgenerator +GenericName[de]=Bericht-Erstellung +GenericName[el]=Δημιουργός αναφορών +GenericName[eo]=Raporto-kreilo +GenericName[es]=Generador de informes +GenericName[et]=Aruandegeneraator +GenericName[eu]=Txosten-sortzailea +GenericName[fa]=مولد گزارش +GenericName[fi]=Raporttigeneraattori +GenericName[fr]=Générateur de rapports +GenericName[fy]=Reportgenerator +GenericName[gl]=Xerador de informes +GenericName[he]=יוצר דו"חות +GenericName[hi]=रपट सृजक +GenericName[hr]=Program za generiranje izvještaja +GenericName[hu]=Jelentéskészítő +GenericName[is]=Skýrsluskrifari +GenericName[it]=Generatore di rapporti +GenericName[ja]=レポート生成 +GenericName[km]=កម្មវិធីបង្កើតរបាយការណ៍ +GenericName[lo]=ເຄື່ອງມືສ້າງລາຍງານ +GenericName[lt]=Raportų generatorius +GenericName[lv]=Atskaišu ģenerators +GenericName[ms]=Penjana Laporan +GenericName[mt]=Ġeneratur tar-Rapporti +GenericName[nb]=Rapport-oppretter +GenericName[nds]=Bericht-Maker +GenericName[ne]=प्रतिवेदन सर्जक +GenericName[nl]=Rapportengenerator +GenericName[nn]=Rapportgenerator +GenericName[pl]=Generator raportów +GenericName[pt]=Geração de Relatórios +GenericName[pt_BR]=Gerador de Relatórios +GenericName[ro]=Generator de rapoarte +GenericName[ru]=Отчёты +GenericName[se]=Raportaráhkadeaddji +GenericName[sk]=Generátor reportov +GenericName[sl]=Ustvarjanje poročil +GenericName[sr]=Програм за прављење извештаја +GenericName[sr@Latn]=Program za pravljenje izveštaja +GenericName[sv]=Rapportgenerator +GenericName[tg]=Ҳисоби Тавлидкунанда +GenericName[th]=เครื่องมือสร้างรายงาน +GenericName[tr]=Rapor Oluşturma Programı +GenericName[uk]=Генератор звітів +GenericName[uz]=Hisobot yaratuvchi +GenericName[uz@cyrillic]=Ҳисобот яратувчи +GenericName[wa]=Djenerateu d' rapoirts +GenericName[xh]=Umenzi we Ngxelo +GenericName[zh_CN]=报告生成器 +GenericName[zh_TW]=報告產生器 +Terminal=false +X-KDE-NativeMimeType=application/x-vnd.kde.kugar.mixed +Categories=Qt;KDE;Office;X-KDE-More; +# Not ready for public consumption, so hide it from the menus +NoDisplay=true diff --git a/kugar/part/kugar_about.h b/kugar/part/kugar_about.h new file mode 100644 index 00000000..d2740fcf --- /dev/null +++ b/kugar/part/kugar_about.h @@ -0,0 +1,53 @@ +/*************************************************************************** + kugar_about.h - description + ------------------- + begin : Mon Nov 25 17:45:00 CET 2002 + copyright : (C) 2002 by Joseph Wenninger + email : jowenn@kde.org +***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KUGAR_ABOUT_H +#define KUGAR_ABOUT_H + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include <kaboutdata.h> +#include <klocale.h> + +KAboutData *newKugarAboutData() +{ + KAboutData * aboutData = new KAboutData( "kugar", I18N_NOOP( "Kugar" ), + VERSION, I18N_NOOP( "Report viewer(generator)" ), KAboutData::License_GPL, + I18N_NOOP( "(c) 1999-2006, The Kugar Team" ), 0, "http://www.koffice.org" ); + + aboutData->addAuthor( "Alexander Dymo", + I18N_NOOP( "Maintainer, Report Designer, Kugar library enhancements" ), "cloudtemple@mksat.net", + "http://www.cloudtemple.mksat.net" ); + aboutData->addAuthor( "Joseph Wenninger", + I18N_NOOP( "Smaller fixes and Kexi integration" ), "jowenn@kde.org", + "" ); + aboutData->addAuthor( "Joris Marcillac", + I18N_NOOP( "Direct database support" ), "joris@marcillac.org", + "" ); + aboutData->addAuthor( "Phil Thompson", + I18N_NOOP( "Former maintainer" ), "phil@river-bank.demon.co.uk", + "" ); + aboutData->addAuthor( "Keith Davis (Mutiny Bay Software)", + I18N_NOOP( "Original author of Metaphrast" ), "info@mutinybaysoftware.com", + "http://www.mutinybaysoftware.com" ); + aboutData->setTranslator( I18N_NOOP( "_: NAME OF TRANSLATORS\nYour names" ), I18N_NOOP( "_: EMAIL OF TRANSLATORS\nYour emails" ) ); + return aboutData; +} +#endif diff --git a/kugar/part/kugar_factory.cpp b/kugar/part/kugar_factory.cpp new file mode 100644 index 00000000..19db5a96 --- /dev/null +++ b/kugar/part/kugar_factory.cpp @@ -0,0 +1,92 @@ +// Copyright (c) 2000 Phil Thompson <phil@river-bank.demon.co.uk> +// +// This file contains the implementation of the Kugar KPart. + + +#include <klocale.h> +#include <kstandarddirs.h> +#include <kinstance.h> +#include <kaboutdata.h> +#include <kglobal.h> +#include <kiconloader.h> + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include "kugar_factory.h" +#include "kugar_part.h" +#include "kugar_about.h" + +KInstance *KugarFactory::s_instance = 0L; +KAboutData *KugarFactory::s_aboutdata = 0L; + + +// The part's entry point. + +K_EXPORT_COMPONENT_FACTORY( libkugarpart, KugarFactory ) + + +// The factory ctor. + +KugarFactory::KugarFactory( QObject *parent, const char* name ) : KoFactory( parent, name ) +{ + global(); +} + +KInstance* KugarFactory::global() +{ + if ( !s_instance ) + { + s_instance = new KInstance( aboutData() ); + s_instance->iconLoader() ->addAppDir( "koffice" ); + s_instance->iconLoader() ->addAppDir( "kugar" ); + + } + return s_instance; +} + +// The factory dtor. + +KugarFactory::~KugarFactory() +{ + delete s_instance; + s_instance = 0; + delete s_aboutdata; + s_aboutdata = 0; +} + +KAboutData *KugarFactory::aboutData() +{ + if ( !s_aboutdata ) + s_aboutdata = newKugarAboutData(); + return s_aboutdata; +} + +// Create a new part. + +KParts::Part* KugarFactory::createPartObject( QWidget *parentWidget, const char *widgetName, + QObject* parent, const char* name, const char* classname, const QStringList & data ) +{ + QString forcedUserTemplate; + for ( QStringList::const_iterator it = data.begin();it != data.end();++it ) + { + QString tmp = ( *it ); + if ( tmp.startsWith( "template=" ) ) + forcedUserTemplate = tmp.right( tmp.length() - 9 ); + } + + bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 ); + // parentWidget and widgetName are used by KoDocument for the "readonly+singleView" case. + KugarPart *part = new KugarPart( parentWidget, widgetName, parent, name, !bWantKoDocument ); + + // if ( !bWantKoDocument ) + part->setReadWrite( false ); + + part->setForcedUserTemplate( forcedUserTemplate ); + return part; + //return ( new KugarPart(parentWidget,name,forcedUserTemplate)); +} + + +#include "kugar_factory.moc" diff --git a/kugar/part/kugar_factory.h b/kugar/part/kugar_factory.h new file mode 100644 index 00000000..70ad6317 --- /dev/null +++ b/kugar/part/kugar_factory.h @@ -0,0 +1,36 @@ +// Copyright (c) 2000 Phil Thompson <phil@river-bank.demon.co.uk> +// +// This file contains the definition of the interface to the Kugar KPart. + + +#ifndef _KUGAR_FACTORY_H +#define _KUGAR_FACTORY_H + + +#include <KoFactory.h> +#include <kaboutdata.h> + +class KInstance; + + +class KugarFactory : public KoFactory +{ + Q_OBJECT +public: + KugarFactory( QObject* parent = 0, const char* name = 0 ); + ~KugarFactory(); + + virtual KParts::Part *createPartObject( QWidget *parentWidget = 0, const char *widgetName = 0, + QObject *parent = 0, const char *name = 0, const char *classname = "KoDocument", + const QStringList &args = QStringList() ); + + static KInstance* global(); + + // _Creates_ a KAboutData but doesn't keep ownership + static KAboutData* aboutData(); +private: + static KInstance* s_instance; + static KAboutData* s_aboutdata; +}; + +#endif diff --git a/kugar/part/kugar_part.cpp b/kugar/part/kugar_part.cpp new file mode 100644 index 00000000..158f26db --- /dev/null +++ b/kugar/part/kugar_part.cpp @@ -0,0 +1,259 @@ +// Copyright (c) 2000 Phil Thompson <phil@river-bank.demon.co.uk> +// +// This file contains the implementation of the Kugar KPart. + + +#include <kapplication.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kinstance.h> +#include <kaboutdata.h> +#include <kaction.h> +#include <kstdaction.h> +#include <kmessagebox.h> +#include <kio/netaccess.h> +#include <qfile.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <qwidget.h> +#include <kfiledialog.h> +#include <kdebug.h> +#include <KoStore.h> + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include "kugar_part.h" +#include "kugar_view.h" +#include "kugar_factory.h" + +#include <KoFilterManager.h> + +KugarPart::KugarPart( QWidget *parentWidget, const char *widgetName, + QObject* parent, const char* name, bool singleViewMode ) + : KoDocument( parentWidget, widgetName, parent, name, singleViewMode ), + m_templateOk( false ) +{ + setInstance( KugarFactory::global(), false ); + m_reportEngine = new Kugar::MReportEngine(); + connect( m_reportEngine, SIGNAL( preferedTemplate( const QString & ) ), + SLOT( slotPreferredTemplate( const QString & ) ) ); +} + +KugarPart::~KugarPart() +{ + m_reportEngine->removeRef(); + // closeURL(); +} + +bool KugarPart::loadOasis( const QDomDocument&, KoOasisStyles&, + const QDomDocument&, KoStore* ) +{ + return false; +} + +bool KugarPart::saveOasis( KoStore*, KoXmlWriter* ) +{ + return false; +} + +bool KugarPart::loadXML( QIODevice *file, const QDomDocument & /*doc*/ ) +{ + m_docURL = url(); + bool ok = true; + if ( file ) + { + file->reset(); + m_reportData=QString(file->readAll()); + + if ( m_reportData.length() != 0 ) + { + ok = m_reportEngine->setReportData( m_reportData ); + + if ( m_templateOk ) + { + m_reportEngine->renderReport(); + if ( ok ) + { + QPtrList<KoView> vs = views(); + if ( vs.count() ) + { + for ( KoView * v = vs.first();v;v = vs.next() ) + { + ok = static_cast<KugarView*>( v->qt_cast( "KugarView" ) ) ->renderReport(); + if ( !ok ) + break; + } + } + } + } + if ( !ok ) + KMessageBox::sorry( 0, i18n( "Invalid data file %1" ).arg( m_file ) ); + } + else + { + ok = false; + KMessageBox::sorry( 0, i18n( "The zero sized data file %1 can't be rendered" ).arg( m_file ) ); + } + + } + else + { + ok = false; + KMessageBox::sorry( 0, i18n( "Unable to open data file: %1" ).arg( m_file ) ); + } + + return ok; +} + +bool KugarPart::initDoc( InitDocFlags /*flags*/, QWidget* /*parentWidget*/ ) +{ + QString filename; + bool ok = false; + + KFileDialog *dialog = + new KFileDialog( QString::null, QString::null, 0L, "file dialog", true ); + dialog->setMimeFilter( KoFilterManager::mimeFilter( KoDocument::readNativeFormatMimeType(), + KoFilterManager::Import ) ); + if ( dialog->exec() != QDialog::Accepted ) + { + delete dialog; + return false; + } + + KURL url( dialog->selectedURL() ); + delete dialog; + + if ( url.isEmpty() ) + return false; + + if ( url.isValid() ) + { + ok = openURL( url ); + } + return ok; + + // If nothing is loaded, do initialize here + return TRUE; +} + +KoView* KugarPart::createViewInstance( QWidget* parent, const char* name ) +{ + KugarView * v = new KugarView( this, parent, name ); + if ( m_templateOk ) + v->renderReport(); + return v; +} + + +void KugarPart::slotPreferredTemplate( const QString &tpl ) +{ + KURL url( tpl ); + QString localtpl; + bool isTemp = false; + + if ( !url.isValid() ) + { +/* kdDebug() << "mailformed url" << endl;*/ + if ( tpl.find( '/' ) >= 0 ) + { + if ( tpl.startsWith( "." ) ) + { + KURL tmpURL( m_docURL ); + tmpURL.setFileName( "" ); + tmpURL.addPath( tpl ); + if ( KIO::NetAccess::download( tmpURL, localtpl ) ) + isTemp = true; + else + KMessageBox::sorry( 0, i18n( "Unable to download template file: %1" ).arg( url.prettyURL() ) ); + } + else + localtpl = tpl; + } + else + { + QString former_localtpl = localtpl; + localtpl = kapp -> dirs() -> findResource( "data", "kugar/templates/" + tpl ); + if ( localtpl.isEmpty() ) + { + KURL tmpURL( m_docURL ); + tmpURL.setFileName( "" ); + tmpURL.addPath( tpl ); + if ( KIO::NetAccess::download( tmpURL, localtpl ) ) + isTemp = true; + else + KMessageBox::sorry( 0, i18n( "Unable to download template file: %1" ).arg( url.prettyURL() ) ); + } + } + } + else + { + if ( KIO::NetAccess::download( url, localtpl ) ) + isTemp = true; + else + KMessageBox::sorry( 0, i18n( "Unable to download template file: %1" ).arg( url.prettyURL() ) ); + } + +/* kdDebug() << "localtpl: " << localtpl.latin1() << endl;*/ + if ( !localtpl.isEmpty() ) + { + QFile f( localtpl ); + + if ( f.open( IO_ReadOnly ) ) + { +/* kdDebug() << "localtpl opened" << endl;*/ + // Try to find out whether it is a mime multi part file + char buf[ 5 ]; + if ( f.readBlock( buf, 4 ) == 4 ) + { + bool isRawXML = ( strncasecmp( buf, "<?xm", 4 ) == 0 ); + f.close(); + + if ( isRawXML ) + { +/* kdDebug() << "RawXML" << endl;*/ + f.open( IO_ReadOnly ); + if ( !m_reportEngine -> setReportTemplate( &f ) ) + KMessageBox::sorry( 0, i18n( "Invalid template file: %1" ).arg( localtpl ) ); + else + { + m_templateOk = true; +/* kdDebug() << "Setting m_templateOk" << endl;*/ + } + f.close(); + } + else + { + KoStore *tmpStore = KoStore::createStore( localtpl, KoStore::Read ); + if ( tmpStore->open( "maindoc.xml" ) ) + { + if ( !m_reportEngine -> setReportTemplate( tmpStore->device() ) ) + KMessageBox::sorry( 0, i18n( "%1 is not a valid Kugar Designer template file." ).arg( localtpl ) ); + else + m_templateOk = true; + tmpStore->close(); + } + else + KMessageBox::sorry( 0, i18n( "%1 is not a valid Kugar Designer template file." ).arg( localtpl ) ); + + delete tmpStore; + } + + } + else + { + f.close(); + KMessageBox::sorry( 0, i18n( "Couldn't read the beginning of the template file: %1" ).arg( localtpl ) ); + } + + } + else + KMessageBox::sorry( 0, i18n( "Unable to open template file: %1" ).arg( localtpl ) ); + + if ( isTemp ) + KIO::NetAccess::removeTempFile( localtpl ); + } +} + +#include "kugar_part.moc" diff --git a/kugar/part/kugar_part.h b/kugar/part/kugar_part.h new file mode 100644 index 00000000..3f54e42c --- /dev/null +++ b/kugar/part/kugar_part.h @@ -0,0 +1,68 @@ +// Copyright (c) 2000 Phil Thompson <phil@river-bank.demon.co.uk> +// +// This file contains the definition of the interface to the Kugar KPart. + + +#ifndef _KUGAR_PART_H +#define _KUGAR_PART_H + +#include <KoDocument.h> + +#include "mpagecollection.h" +#include "mreportengine.h" + +class KInstance; +class KugarBrowserExtension; + +class KugarPart: public KoDocument +{ + Q_OBJECT + +public: + KugarPart( QWidget *parentWidget = 0, const char *widgetName = 0, + QObject* parent = 0, + const char* name = 0, bool singleViewMode = false ); + virtual ~KugarPart(); + + virtual bool initDoc( InitDocFlags flags, QWidget* parentWidget = 0 ); + + virtual bool loadOasis( const QDomDocument&, KoOasisStyles&, + const QDomDocument&, KoStore* ); + virtual bool saveOasis( KoStore*, KoXmlWriter* ); + + virtual bool loadXML( QIODevice *, const QDomDocument & ); + // virtual QDomDocument saveXML(); + + virtual void paintContent( QPainter&, const QRect&, + bool /*transparent*/ = false, + double /*zoomX*/ = 1.0, double /*zoomY*/ = 1.0 ) + { + ; + } + + Kugar::MReportEngine *reportEngine() + { + return m_reportEngine; + } + +protected: + virtual KoView* createViewInstance( QWidget* parent, const char* name ); + +public slots: + void setForcedUserTemplate( const QString &/*name*/ ) + { + ; + } + +private slots: + void slotPreferredTemplate( const QString & ); + +private: + QString m_reportData; + Kugar::MReportEngine *m_reportEngine; + bool m_templateOk; + KURL m_docURL; +}; + + +#endif diff --git a/kugar/part/kugar_view.cpp b/kugar/part/kugar_view.cpp new file mode 100644 index 00000000..14a32bca --- /dev/null +++ b/kugar/part/kugar_view.cpp @@ -0,0 +1,131 @@ +// Copyright (c) 2000 Phil Thompson <phil@river-bank.demon.co.uk> +// +// This file contains the implementation of the Kugar KPart. + + +#include <kapplication.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kinstance.h> +#include <kaboutdata.h> +#include <kaction.h> +#include <kstdaction.h> +#include <kmessagebox.h> +#include <kio/netaccess.h> +#include <qfile.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <qlayout.h> + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include "kugar_part.h" +#include "kugar_view.h" +#include "kugar_factory.h" + + +// The view ctor. + +KugarView::KugarView( KugarPart *part, QWidget *parent, const char *name ) + : KoView( part, parent, name ) +{ + setInstance( KugarFactory::global() ); + + ( new QVBoxLayout( this ) ) ->setAutoAdd( true ); + view = new Kugar::MReportViewer( part->reportEngine(), this ); + + view -> setFocusPolicy( QWidget::ClickFocus ); + view -> show(); + + // setWidget(view); + + // m_extension = new KugarBrowserExtension(this); + + + // Define the actions. + + KStdAction::prior( view, SLOT( slotPrevPage() ), actionCollection(), "kuPrevPage" ); + KStdAction::next( view, SLOT( slotNextPage() ), actionCollection(), "kuNextPage" ); + KStdAction::firstPage( view, SLOT( slotFirstPage() ), actionCollection(), "kuFirstPage" ); + KStdAction::lastPage( view, SLOT( slotLastPage() ), actionCollection(), "kuLastPage" ); + + setXMLFile( "kugarpart.rc" ); + +} + + +// The view dtor. + +KugarView::~KugarView() +{} + +void KugarView::setupPrinter( KPrinter &printer ) +{ + view->setupPrinter( printer ); +} + +void KugarView::print( KPrinter &printer ) +{ + view->printReport( printer ); +} + + + + +#if 0 +// Open a data file. + +bool KugarPart::openFile() +{ + bool ok = false; + QFile f( m_file ); + + if ( f.open( IO_ReadOnly ) ) + { + if ( view -> setReportData( &f ) ) + { + if ( view -> renderReport() ) + ok = true; + } + else + KMessageBox::sorry( this, i18n( "Invalid data file: %1" ).arg( m_file ) ); + + f.close(); + } + else + KMessageBox::sorry( this, i18n( "Unable to open data file: %1" ).arg( m_file ) ); + + return ok; +} + + +// Close the data file. + +bool KugarPart::closeURL() +{ + // Nothing to do. + + return true; +} + + +// Print the report. + +void KugarPart::print() +{ + view -> printReport(); +} + +#endif + + +bool KugarView::renderReport() +{ + return ( view -> renderReport() ); +} + + + +#include "kugar_view.moc" diff --git a/kugar/part/kugar_view.h b/kugar/part/kugar_view.h new file mode 100644 index 00000000..a6838737 --- /dev/null +++ b/kugar/part/kugar_view.h @@ -0,0 +1,53 @@ +// Copyright (c) 2000 Phil Thompson <phil@river-bank.demon.co.uk> +// +// This file contains the definition of the interface to the Kugar KPart. + + +#ifndef _KUGAR_VIEW_H +#define _KUGAR_VIEW_H + +#include "mreportviewer.h" + +#include <KoView.h> + +class KugarPart; + +class KugarView: public KoView +{ + Q_OBJECT + +public: + KugarView( KugarPart *part, QWidget *parent, const char *name ); + virtual ~KugarView(); + + void setForcedUserTemplate( const QString &name ); + + void updateReadWrite( bool ) + { + ; + } + + bool renderReport(); + + bool setReportTemplate( const QString &data ) + { + return view -> setReportTemplate( data ); + } + + + virtual void setupPrinter( KPrinter &printer ); + virtual void print( KPrinter &printer ); + + + + //protected: + // virtual bool openFile(); + // virtual bool closeURL(); + + +private: + Kugar::MReportViewer *view; + QString m_forcedUserTemplate; +}; + +#endif diff --git a/kugar/part/kugarpart.desktop b/kugar/part/kugarpart.desktop new file mode 100644 index 00000000..ad9f125d --- /dev/null +++ b/kugar/part/kugarpart.desktop @@ -0,0 +1,118 @@ +[Desktop Entry] +Name=KOffice Report Generator Component +Name[bg]=Компонент за генератор на отчети в KOffice +Name[ca]=Component generador d'informes de KOffice +Name[cy]=Cydran Gynhyrchydd Adroddiad KOffice +Name[da]=Koffice rapportgeneratorkomponent +Name[de]=KOffice-Komponente für Berichterstellung +Name[el]=Συστατικό δημιουργίας αναφορών του KOffice +Name[eo]=KOffice raportgenera komponanto +Name[es]=Componente de generación de informes de KOffice +Name[et]=KOffice'i aruandegeneraatori komponent +Name[eu]=KOffice-en txosten sortzailearen osagaia +Name[fa]=مؤلفۀ مولد گزارش KOffice +Name[fi]=KOfficen raporttigeneraattori +Name[fr]=Composant générateur de rapports de KOffice +Name[fy]=KOffice rapportgeneratorkomponint +Name[gl]=Componente de Xeración de Informes de KOffice +Name[he]=רכיב של KOffice ליצירת דו"חות +Name[hi]=के-ऑफ़िस रपट सृजक अवयव +Name[hu]=KOffice jelentéskészítő komponens +Name[is]=Skýrsluskrifarahluti KOffice +Name[it]=Componente per la generazione dei rapporti di KOffice +Name[ja]=KOffice レポート生成コンポーネント +Name[km]=សមាសភាគបង្កើនរបាយការណ៍ KOffice +Name[lv]=KOffice atskaišu ģeneratora komponente +Name[ms]=Komponen Penjana Laporan KOffice +Name[nb]=Rapportopprettings-komponent for KOffice +Name[nds]=Berichtopstell-Komponent för KOffice +Name[ne]=केडीई कार्यालय प्रतिवेदन सर्जक अवयव +Name[nl]=Koffice Rapportgeneratorcomponent +Name[nn]=Rapportgenerator-komponent for KOffice +Name[pl]=Komponent generowania raportów dla KOffice +Name[pt]=Componente de Geração de Relatórios do KOffice +Name[pt_BR]=Componente Gerador de Relatórios do KOffice +Name[ru]=Компонент генератора отчётов KOffice +Name[sk]=Komponent generátor správ KOffice +Name[sl]=Komponenta ustvarjanja poročil za KOffice +Name[sr]=KOffice-ова компонента за прављење извештаја +Name[sr@Latn]=KOffice-ova komponenta za pravljenje izveštaja +Name[sv]=Koffice-rapportgeneratorkomponent +Name[tg]=Компоненти муваллиди гузоришҳои KOffice +Name[tr]=KOffice Rapor Oluşturma Programı +Name[uk]=Компонент створення звітів KOffice +Name[uz]=KOffice hisobot tuzish komponenti +Name[uz@cyrillic]=KOffice ҳисобот тузиш компоненти +Name[wa]=Componint djenerateu d' rapoirts di KOffice +Name[zh_CN]=KOffice 报告生成组件 +Name[zh_TW]=KOffice 報告產生元件 +MimeType=application/x-kugar;application/x-vnd.kde.kugar.mixed +Type=Service +Terminal=false +ServiceTypes=KOfficePart,KParts/ReadOnlyPart,Browser/View +X-KDE-Library=libkugarpart +X-KDE-NativeMimeType=application/x-vnd.kde.kugar.mixed +GenericName=Report Generator +GenericName[af]=Raporteer Genereerder +GenericName[ar]=مُوَلِّد التَّقارير +GenericName[az]=Raport Yaradıcısı +GenericName[bg]=Генератор на отчети +GenericName[bs]=Generator izvještaja +GenericName[ca]=Generador d'informes +GenericName[cs]=Generátor reportů +GenericName[cy]=Cynhyrchydd Adroddiad +GenericName[da]=Rapportgenerator +GenericName[de]=Bericht-Erstellung +GenericName[el]=Δημιουργός αναφορών +GenericName[eo]=Raporto-kreilo +GenericName[es]=Generador de informes +GenericName[et]=Aruandegeneraator +GenericName[eu]=Txosten-sortzailea +GenericName[fa]=مولد گزارش +GenericName[fi]=Raporttigeneraattori +GenericName[fr]=Générateur de rapports +GenericName[fy]=Reportgenerator +GenericName[gl]=Xerador de informes +GenericName[he]=יוצר דו"חות +GenericName[hi]=रपट सृजक +GenericName[hr]=Program za generiranje izvještaja +GenericName[hu]=Jelentéskészítő +GenericName[is]=Skýrsluskrifari +GenericName[it]=Generatore di rapporti +GenericName[ja]=レポート生成 +GenericName[km]=កម្មវិធីបង្កើតរបាយការណ៍ +GenericName[lo]=ເຄື່ອງມືສ້າງລາຍງານ +GenericName[lt]=Raportų generatorius +GenericName[lv]=Atskaišu ģenerators +GenericName[ms]=Penjana Laporan +GenericName[mt]=Ġeneratur tar-Rapporti +GenericName[nb]=Rapport-oppretter +GenericName[nds]=Bericht-Maker +GenericName[ne]=प्रतिवेदन सर्जक +GenericName[nl]=Rapportengenerator +GenericName[nn]=Rapportgenerator +GenericName[pl]=Generator raportów +GenericName[pt]=Geração de Relatórios +GenericName[pt_BR]=Gerador de Relatórios +GenericName[ro]=Generator de rapoarte +GenericName[ru]=Отчёты +GenericName[se]=Raportaráhkadeaddji +GenericName[sk]=Generátor reportov +GenericName[sl]=Ustvarjanje poročil +GenericName[sr]=Програм за прављење извештаја +GenericName[sr@Latn]=Program za pravljenje izveštaja +GenericName[sv]=Rapportgenerator +GenericName[tg]=Ҳисоби Тавлидкунанда +GenericName[th]=เครื่องมือสร้างรายงาน +GenericName[tr]=Rapor Oluşturma Programı +GenericName[uk]=Генератор звітів +GenericName[uz]=Hisobot yaratuvchi +GenericName[uz@cyrillic]=Ҳисобот яратувчи +GenericName[wa]=Djenerateu d' rapoirts +GenericName[xh]=Umenzi we Ngxelo +GenericName[zh_CN]=报告生成器 +GenericName[zh_TW]=報告產生器 +Icon=kugar +# Not ready for public consumption, so hide it from the menus and from koshell +NoDisplay=true + diff --git a/kugar/part/kugarpart.rc b/kugar/part/kugarpart.rc new file mode 100644 index 00000000..5f11d8f7 --- /dev/null +++ b/kugar/part/kugarpart.rc @@ -0,0 +1,21 @@ +<!DOCTYPE kpargui> +<kpartgui name="kugar" > + <MenuBar> + <Menu name="view" > + <Text>&View</Text> + <Separator/> + <Action name="kuPrevPage" /> + <Action name="kuNextPage" /> + <Separator/> + <Action name="kuFirstPage" /> + <Action name="kuLastPage" /> + </Menu> + </MenuBar> + <ToolBar name="Metaphrast-ToolBar" > + <Action name="kuPrevPage" /> + <Action name="kuNextPage" /> + <Action name="kuFirstPage" /> + <Action name="kuLastPage" /> + </ToolBar> +<!-- <StatusBar/> --> +</kpartgui> diff --git a/kugar/part/kugartemplate.dtd b/kugar/part/kugartemplate.dtd new file mode 100644 index 00000000..a91fbd61 --- /dev/null +++ b/kugar/part/kugartemplate.dtd @@ -0,0 +1,155 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- The DTD for a Kugar template. --> + + +<!ELEMENT KugarTemplate (ReportHeader, PageHeader, DetailHeader*, Detail*, DetailFooter*, PageFooter, ReportFooter)> +<!ATTLIST KugarTemplate + PageSize CDATA #REQUIRED + PageOrientation CDATA #REQUIRED + TopMargin CDATA #REQUIRED + BottomMargin CDATA #REQUIRED + LeftMargin CDATA #REQUIRED + RightMargin CDATA #REQUIRED> + +<!ELEMENT ReportHeader (Line*, Label*, Special*)> +<!ATTLIST ReportHeader + Height CDATA #REQUIRED + PrintFrequency CDATA #REQUIRED> + +<!ELEMENT PageHeader (Line*, Label*, Special*)> +<!ATTLIST PageHeader + Height CDATA #REQUIRED + PrintFrequency CDATA #REQUIRED> + +<!ELEMENT DetailHeader (Line*, Label*, Special*)> +<!ATTLIST DetailHeader + Height CDATA #REQUIRED + Level CDATA #REQUIRED> + +<!ELEMENT Detail (Line*, Label*, Special*, Field*)> +<!ATTLIST Detail + Height CDATA #REQUIRED + Level CDATA #REQUIRED> + +<!ELEMENT DetailFooter (Line*, Label*, Special*)> +<!ATTLIST DetailFooter + Height CDATA #REQUIRED + Level CDATA #REQUIRED> + +<!ELEMENT PageFooter (Line*, Label*, Special*)> +<!ATTLIST PageFooter + Height CDATA #REQUIRED + PrintFrequency CDATA #REQUIRED> + +<!ELEMENT ReportFooter (Line*, Label*, Special*, CalculatedField*)> +<!ATTLIST ReportFooter + Height CDATA #REQUIRED + PrintFrequency CDATA #REQUIRED> + +<!ELEMENT Line EMPTY> +<!ATTLIST Line + X1 CDATA #REQUIRED + Y1 CDATA #REQUIRED + X2 CDATA #REQUIRED + Y2 CDATA #REQUIRED + Width CDATA #REQUIRED + Color CDATA #REQUIRED + Style CDATA #REQUIRED> + +<!ELEMENT Label EMPTY> +<!ATTLIST Label + Text CDATA #REQUIRED + X CDATA #REQUIRED + Y CDATA #REQUIRED + Width CDATA #REQUIRED + Height CDATA #REQUIRED + BackgroundColor CDATA #REQUIRED + ForegroundColor CDATA #REQUIRED + BorderColor CDATA #REQUIRED + BorderWidth CDATA #REQUIRED + BorderStyle CDATA #REQUIRED + FontFamily CDATA #REQUIRED + FontSize CDATA #REQUIRED + FontWeight CDATA #REQUIRED + FontItalic CDATA #REQUIRED + HAlignment CDATA #REQUIRED + VAlignment CDATA #REQUIRED + WordWrap CDATA #REQUIRED> + +<!ELEMENT Field EMPTY> +<!ATTLIST Field + Field CDATA #REQUIRED + Text CDATA #REQUIRED + X CDATA #REQUIRED + Y CDATA #REQUIRED + Width CDATA #REQUIRED + Height CDATA #REQUIRED + BackgroundColor CDATA #REQUIRED + ForegroundColor CDATA #REQUIRED + BorderColor CDATA #REQUIRED + BorderWidth CDATA #REQUIRED + BorderStyle CDATA #REQUIRED + FontFamily CDATA #REQUIRED + FontSize CDATA #REQUIRED + FontWeight CDATA #REQUIRED + FontItalic CDATA #REQUIRED + HAlignment CDATA #REQUIRED + VAlignment CDATA #REQUIRED + WordWrap CDATA #REQUIRED + DataType CDATA #REQUIRED + DateFormat CDATA #REQUIRED + Precision CDATA #REQUIRED + Currency CDATA #REQUIRED + NegValueColor CDATA #REQUIRED + CommaSeparator CDATA #REQUIRED> + +<!ELEMENT CalculatedField EMPTY> +<!ATTLIST CalculatedField + CalculationType CDATA #REQUIRED + Field CDATA #REQUIRED + Text CDATA #REQUIRED + X CDATA #REQUIRED + Y CDATA #REQUIRED + Width CDATA #REQUIRED + Height CDATA #REQUIRED + BackgroundColor CDATA #REQUIRED + ForegroundColor CDATA #REQUIRED + BorderColor CDATA #REQUIRED + BorderWidth CDATA #REQUIRED + BorderStyle CDATA #REQUIRED + FontFamily CDATA #REQUIRED + FontSize CDATA #REQUIRED + FontWeight CDATA #REQUIRED + FontItalic CDATA #REQUIRED + HAlignment CDATA #REQUIRED + VAlignment CDATA #REQUIRED + WordWrap CDATA #REQUIRED + DataType CDATA #REQUIRED + DateFormat CDATA #REQUIRED + Precision CDATA #REQUIRED + Currency CDATA #REQUIRED + NegValueColor CDATA #REQUIRED + CommaSeparator CDATA #REQUIRED> + +<!ELEMENT Special EMPTY> +<!ATTLIST Special + Type CDATA #REQUIRED + Text CDATA #REQUIRED + X CDATA #REQUIRED + Y CDATA #REQUIRED + Width CDATA #REQUIRED + Height CDATA #REQUIRED + BackgroundColor CDATA #REQUIRED + ForegroundColor CDATA #REQUIRED + BorderColor CDATA #REQUIRED + BorderWidth CDATA #REQUIRED + BorderStyle CDATA #REQUIRED + FontFamily CDATA #REQUIRED + FontSize CDATA #REQUIRED + FontWeight CDATA #REQUIRED + FontItalic CDATA #REQUIRED + HAlignment CDATA #REQUIRED + VAlignment CDATA #REQUIRED + WordWrap CDATA #REQUIRED + DateFormat CDATA #REQUIRED> diff --git a/kugar/part/main.cpp b/kugar/part/main.cpp new file mode 100644 index 00000000..e37c7799 --- /dev/null +++ b/kugar/part/main.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + main.cpp - description + ------------------- + begin : Mon Nov 25 17:45:00 CET 2002 + copyright : (C) 2002 by Joseph Wenninger + email : jowenn@kde.org +***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <KoApplication.h> +#include <kcmdlineargs.h> +#include <dcopclient.h> + +#include "kugar_about.h" + +static KCmdLineOptions options[] = + { + { "+[File]", I18N_NOOP( "File to open" ), 0 }, + // INSERT YOUR COMMANDLINE OPTIONS HERE + KCmdLineLastOption + }; + +extern "C" KUGAR_EXPORT int kdemain( int argc, char *argv[] ) +{ + + KCmdLineArgs::init( argc, argv, newKugarAboutData() ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + KoApplication app; + + if ( !app.start() ) + return 1; + + app.exec(); + return 0; +} |