summaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /example
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'example')
-rw-r--r--example/Makefile.am38
-rw-r--r--example/README2
-rw-r--r--example/configure.in.in4
-rw-r--r--example/configure.in.in.koffice108
-rw-r--r--example/example.desktop62
-rw-r--r--example/example.rc12
-rw-r--r--example/example_aboutdata.h42
-rw-r--r--example/example_factory.cc82
-rw-r--r--example/example_factory.h47
-rw-r--r--example/example_part.cc96
-rw-r--r--example/example_part.h46
-rw-r--r--example/example_readonly.rc7
-rw-r--r--example/example_view.cc76
-rw-r--r--example/example_view.h49
-rw-r--r--example/examplepart.desktop59
-rw-r--r--example/main.cc45
-rw-r--r--example/x-vnd.kde.example.desktop10
17 files changed, 785 insertions, 0 deletions
diff --git a/example/Makefile.am b/example/Makefile.am
new file mode 100644
index 000000000..55b98290f
--- /dev/null
+++ b/example/Makefile.am
@@ -0,0 +1,38 @@
+
+INCLUDES = $(KOFFICE_INCLUDES) $(all_includes)
+
+## The part
+kde_module_LTLIBRARIES = libexamplepart.la
+libexamplepart_la_SOURCES = example_part.cc \
+ example_view.cc example_factory.cc
+libexamplepart_la_LDFLAGS = $(KDE_PLUGIN)
+libexamplepart_la_LIBADD = $(LIB_KOFFICEUI)
+
+## The kdeinit loadable module and executable
+kdeinit_LTLIBRARIES = example.la
+lib_LTLIBRARIES =
+bin_PROGRAMS =
+example_la_SOURCES = main.cc
+example_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+example_la_LIBADD = $(LIB_KOFFICEUI)
+
+METASOURCES = AUTO
+
+kdelnk_DATA = example.desktop
+kdelnkdir = $(kde_appsdir)/Office
+
+# Note: for your application, the mime type should be defined in
+# kdelibs CVS HEAD and a compatibility entry should be added in
+# the directory koffice/mimetypes/kde??
+# where ?? is the version number of the last stable kde(libs) release.
+kdemime_DATA = x-vnd.kde.example.desktop
+kdemimedir = $(kde_mimedir)/application
+
+rc_DATA = example.rc example_readonly.rc
+rcdir = $(kde_datadir)/example
+
+messages: rc.cpp
+ $(XGETTEXT) rc.cpp *.cc example_aboutdata.h -o $(podir)/example.pot
+kde_services_DATA = examplepart.desktop
+
+include $(top_srcdir)/admin/Doxyfile.am
diff --git a/example/README b/example/README
new file mode 100644
index 000000000..8b3933fc4
--- /dev/null
+++ b/example/README
@@ -0,0 +1,2 @@
+If you want this example to be compiled (or if you want to compile your app
+based on that example), remove the 'configure.in.in' file! \ No newline at end of file
diff --git a/example/configure.in.in b/example/configure.in.in
new file mode 100644
index 000000000..904df8069
--- /dev/null
+++ b/example/configure.in.in
@@ -0,0 +1,4 @@
+dnl This is here so that example isn't compiled and intalled by default.
+dnl Do NOT put this file in your application, if you want it compiled !
+
+DO_NOT_COMPILE="$DO_NOT_COMPILE example"
diff --git a/example/configure.in.in.koffice b/example/configure.in.in.koffice
new file mode 100644
index 000000000..69d9f75ba
--- /dev/null
+++ b/example/configure.in.in.koffice
@@ -0,0 +1,108 @@
+dnl Rename this file configure.in.in to have a check for KOffice in during configure
+
+dnl
+dnl Check for koffice. Argument is the minimum required version, in the form a.b.c.
+dnl This check *aborts* if koffice wasn't found or was too old.
+dnl If you only have an optional koffice requirement you'll have to change the test.
+dnl
+AC_DEFUN(AC_PATH_KOFFICE,
+[
+ dnl TODO: use AC_CACHE_VAL
+
+ if test -z "$1"; then
+ koffice_minver_maj=1
+ koffice_minver_min=2
+ koffice_minver_pat=94
+ else
+ koffice_minver_maj=`echo "$1" | sed -e "s/^\(.*\)\..*\..*$/\1/"`
+ koffice_minver_min=`echo "$1" | sed -e "s/^.*\.\(.*\)\..*$/\1/"`
+ koffice_minver_pat=`echo "$1" | sed -e "s/^.*\..*\.\(.*\)$/\1/"`
+ fi
+
+ AC_REQUIRE([AC_PATH_QT])
+
+ AC_MSG_CHECKING([for KOffice])
+
+ koffice_incdir=$kde_includes
+ koffice_libdir=$kde_libraries
+
+ AC_ARG_WITH(koffice-includes,
+ [ --with-koffice-includes=DIR where include files for KOffice are installed ],
+ [ koffice_incdir="$withval"] )
+ AC_ARG_WITH(koffice-libs,
+ [ --with-koffice-libs=DIR where libs for KOffice are installed ],
+ [ koffice_libdir="$withval"] )
+
+ if ! test -f "$koffice_incdir/kofficeversion.h"; then
+ AC_MSG_ERROR([Cannot find KOffice headers in $ac_koffice_includes. Please check your installation, or use --with-koffice-includes.])
+ fi
+
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+
+ ac_cxxflags_safe="$CXXFLAGS"
+ ac_ldflags_safe="$LDFLAGS"
+ ac_libs_safe="$LIBS"
+ CXXFLAGS="$CXXFLAGS -I$koffice_incdir $KDE_INCLUDES $all_includes"
+ LDFLAGS="$LDFLAGS $KDE_LDFLAGS $QT_LDFLAGS $all_libraries $USER_LDFLAGS $KDE_MT_LDFLAGS"
+ LIBS="$LIBS -lkofficeui $LIBQT"
+
+ AC_TRY_COMPILE(
+ [
+#include "confdefs.h"
+#include <kofficeversion.h>
+#if ! KOFFICE_IS_VERSION($koffice_minver_maj,$koffice_minver_min,$koffice_minver_pat)
+#error 1
+#endif
+ ],
+ [],
+ [ have_koffice="yes" ],
+ [
+ have_koffice="no"; dnl in case someone wants to turn the error below into a warning
+ AC_MSG_ERROR("Your KOffice version is too old. Please upgrade to at least $koffice_minver_maj.$koffice_minver_min.$koffice_minver_pat")
+ ])
+
+ dnl Ok it's the right version. Now, does it link ok?
+
+ cat > conftest.$ac_ext <<EOF
+#include <koApplication.h>
+int main( int, char ** )
+{
+ KoApplication app;
+ return 0;
+}
+EOF
+
+ if AC_TRY_EVAL(ac_link) && test -s conftest; then
+ rm -f conftest*
+ else
+ have_koffice="no"
+ rm -f conftest*
+ AC_MSG_ERROR([Cannot link small KOffice application. For more details look at config.log])
+ fi
+
+ CXXFLAGS="$ac_cxxflags_safe"
+ LDFLAGS="$ac_ldflags_safe"
+ LIBS="$ac_libs_safe"
+
+ AC_LANG_RESTORE
+
+ dnl Success, prepare the variables for the Makefile.am
+
+ KOFFICE_INCLUDES=""
+ if test "$koffice_incdir" != "/usr/include"; then
+ KOFFICE_INCLUDES="-I$koffice_incdir"
+ fi
+ KOFFICE_LDFLAGS=""
+ if test "$koffice_libdir" != "/usr/lib"; then
+ KOFFICE_LDFLAGS="-L$koffice_libdir"
+ fi
+ AC_SUBST(KOFFICE_LDFLAGS)
+
+ LIB_KOFFICE="-lkofficeui"
+ AC_SUBST(LIB_KOFFICE)
+
+ AC_MSG_RESULT([libraries $koffice_libdir, headers $koffice_incdir])
+])
+
+AC_PATH_KOFFICE
diff --git a/example/example.desktop b/example/example.desktop
new file mode 100644
index 000000000..e8c401563
--- /dev/null
+++ b/example/example.desktop
@@ -0,0 +1,62 @@
+[Desktop Entry]
+Name=KOffice Example Application
+Name[ar]=تطبيق مثالي لِــ KOffice
+Name[bg]=Примерна програма за KOffice
+Name[br]=Meziant skouer KOffice
+Name[ca]=Aplicació KOffice d'exemple
+Name[cs]=Příklad KOffice aplikace
+Name[cy]=Cymhwysiad Enghreifftiol KOffice
+Name[da]=KOffice eksempel-program
+Name[de]=KOffice-Beispielprogramm
+Name[el]=Παράδειγμα εφαρμογής του KOffice
+Name[eo]=KOffice Ekzempla Aplikaĵo
+Name[es]=Aplicación de ejemplo de KOffice
+Name[et]=KOffice'i näidisrakendus
+Name[eu]=KOffice-en adibidezko aplikazioa
+Name[fa]=کاربرد نمونۀ KOffice
+Name[fi]=KOfficen esimerkkiohjelma
+Name[fr]=Application-exemple KOffice
+Name[fy]=Foarbyldapplikaasje foar KOffice
+Name[ga]=Feidhmchlár Samplach KOffice
+Name[gl]=Aplicación Exemplo de KOffice
+Name[he]=תוכנית לדוגמה של KOffice
+Name[hi]=के-ऑफ़िस उदाहरण अनुप्रयोग
+Name[hr]=Primjer aplikacije za KOffice
+Name[hu]=KOffice mintaalkalmazás
+Name[is]=KOffice sýniforrit
+Name[it]=Applicazione KOffice di esempio
+Name[ja]=KOffice サンプルアプリケーション
+Name[km]=កម្មវិធី​ឧទាហរណ៍​សម្រាប់ KOffice
+Name[lv]=KOffice programmas piemērs
+Name[ms]=Aplikasi Contoh KOffice
+Name[nb]=Eksempelprogram for KOffice
+Name[nds]=Bispeelprogramm för KOffice
+Name[ne]=केडीई कार्यालय उदाहरण अनुप्रयोग
+Name[nl]=Voorbeeldtoepassing voor KOffice
+Name[nn]=Dømeprogram for KOffice
+Name[pa]=KOffice ਉਦਾਹਰਨ ਕਾਰਜ
+Name[pl]=Przykładowy program KOffice
+Name[pt]=Aplicação Exemplo do KOffice
+Name[pt_BR]=Aplicativo de Exemplo do KOffice
+Name[ro]=Exemplu de aplicaţie KOffice
+Name[ru]=Пример приложения KOffice
+Name[se]=KOffice-ovdamearkaprográmma
+Name[sk]=Príklad aplikácie KOffice
+Name[sl]=Vzorčni program KOffice
+Name[sr]=Пример KOffice-овог програма
+Name[sr@Latn]=Primer KOffice-ovog programa
+Name[sv]=Koffice-exempelprogram
+Name[ta]=K office எடுத்துக்காட்டு பயன்பாடுகள்
+Name[tg]=Нусхаи Барномаи KOffice
+Name[tr]=Koffice Örnek Uygulama
+Name[uk]=Приклад програми KOffice
+Name[uz]=KOffice namuna dasturi
+Name[uz@cyrillic]=KOffice намуна дастури
+Name[wa]=Programe di mostraedje di KOffice
+Name[zh_CN]=KOffice 应用程序范例
+Name[zh_TW]=KOffice 範例應用程式
+Exec=example
+MimeType=application/x-example
+Type=Application
+Icon=example
+X-KDE-NativeMimeType=application/x-example
diff --git a/example/example.rc b/example/example.rc
new file mode 100644
index 000000000..b3339591f
--- /dev/null
+++ b/example/example.rc
@@ -0,0 +1,12 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Example" version="1">
+<MenuBar>
+ <Menu name="Edit"><text>Edit</text>
+ <Action name="copy"/>
+ <Action name="cut"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="editToolBar"><Text>Edit</Text>
+ <Action name="copy"/>
+ <Action name="cut"/>
+</ToolBar>
+</kpartgui>
diff --git a/example/example_aboutdata.h b/example/example_aboutdata.h
new file mode 100644
index 000000000..a4ed180d0
--- /dev/null
+++ b/example/example_aboutdata.h
@@ -0,0 +1,42 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef EXAMPLE_ABOUTDATA
+#define EXAMPLE_ABOUTDATA
+
+#include <kaboutdata.h>
+#include <klocale.h>
+
+static const char* description=I18N_NOOP("Example KOffice Program");
+static const char* version="0.1";
+
+KAboutData * newExampleAboutData()
+{
+ // Change this, of course
+ // The first argument of the KAboutData constructor is the instance name.
+ // It is very important, it's what's used for many things, like the subdir in share/apps, etc.
+ // It must also match the name of the application's .desktop file.
+ KAboutData * aboutData=new KAboutData( "example", I18N_NOOP("Example"),
+ version, description, KAboutData::License_GPL,
+ "(c) 1998-2000, Torben Weis");
+ aboutData->addAuthor("Torben Weis",0, "weis@kde.org");
+ return aboutData;
+}
+
+#endif
diff --git a/example/example_factory.cc b/example/example_factory.cc
new file mode 100644
index 000000000..e3b46cf31
--- /dev/null
+++ b/example/example_factory.cc
@@ -0,0 +1,82 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <example_factory.h>
+#include <example_part.h>
+#include <example_aboutdata.h>
+#include <kinstance.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+K_EXPORT_COMPONENT_FACTORY( libexamplepart, ExampleFactory )
+
+KInstance* ExampleFactory::s_global = 0L;
+KAboutData* ExampleFactory::s_aboutData = 0L;
+
+ExampleFactory::ExampleFactory( QObject* parent, const char* name )
+ : KoFactory( parent, name )
+{
+ global();
+}
+
+ExampleFactory::~ExampleFactory()
+{
+ delete s_aboutData;
+ s_aboutData = 0L;
+ delete s_global;
+ s_global = 0L;
+}
+
+KParts::Part* ExampleFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char* classname, const QStringList & )
+{
+ // If classname is "KoDocument", our host is a koffice application
+ // otherwise, the host wants us as a simple part, so switch to readonly and single view.
+ bool bWantKoDocument = ( strcmp( classname, "KoDocument" ) == 0 );
+
+ // parentWidget and widgetName are used by KoDocument for the "readonly+singleView" case.
+ ExamplePart *part = new ExamplePart( parentWidget, widgetName, parent, name, !bWantKoDocument );
+
+ if ( !bWantKoDocument )
+ part->setReadWrite( false );
+
+ return part;
+}
+
+KAboutData* ExampleFactory::aboutData()
+{
+ if ( !s_aboutData )
+ s_aboutData = newExampleAboutData();
+ return s_aboutData;
+}
+
+KInstance* ExampleFactory::global()
+{
+ if ( !s_global )
+ {
+ s_global = new KInstance( aboutData() );
+ // Add any application-specific resource directories here
+
+ // Tell the iconloader about share/apps/koffice/icons
+ s_global->iconLoader()->addAppDir("koffice");
+ }
+ return s_global;
+}
+
+#include <example_factory.moc>
diff --git a/example/example_factory.h b/example/example_factory.h
new file mode 100644
index 000000000..1df863252
--- /dev/null
+++ b/example/example_factory.h
@@ -0,0 +1,47 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef EXAMPLE_FACTORY_H
+#define EXAMPLE_FACTORY_H
+
+#include <KoFactory.h>
+
+class KInstance;
+class KAboutData;
+
+class ExampleFactory : public KoFactory
+{
+ Q_OBJECT
+public:
+ ExampleFactory( QObject* parent = 0, const char* name = 0 );
+ ~ExampleFactory();
+
+ 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_global;
+ static KAboutData* s_aboutData;
+};
+
+#endif
diff --git a/example/example_part.cc b/example/example_part.cc
new file mode 100644
index 000000000..e459040a4
--- /dev/null
+++ b/example/example_part.cc
@@ -0,0 +1,96 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "example_part.h"
+#include "example_factory.h"
+#include "example_view.h"
+
+#include <qpainter.h>
+
+ExamplePart::ExamplePart( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, bool singleViewMode )
+ : KoDocument( parentWidget, widgetName, parent, name, singleViewMode )
+{
+ setInstance( ExampleFactory::global(), false );
+}
+
+bool ExamplePart::initDoc(InitDocFlags flags, QWidget* parentWidget)
+{
+ // If nothing is loaded, do initialize here
+ // Most KOffice applications use the template dialog here, with code like:
+/*
+ KoTemplateChooseDia::DialogType dlgtype;
+ if (initDocFlags() != KoDocument::InitDocFileNew )
+ dlgtype = KoTemplateChooseDia::Everything;
+ else
+ dlgtype = KoTemplateChooseDia::OnlyTemplates;
+
+ KoTemplateChooseDia::ReturnType ret = KoTemplateChooseDia::choose(
+ .... )
+*/
+ return TRUE;
+}
+
+KoView* ExamplePart::createViewInstance( QWidget* parent, const char* name )
+{
+ return new ExampleView( this, parent, name );
+}
+
+bool ExamplePart::loadXML( QIODevice *, const QDomDocument & )
+{
+ // TODO load the document from the QDomDocument
+ return true;
+}
+
+QDomDocument ExamplePart::saveXML()
+{
+ // TODO save the document into a QDomDocument
+ return QDomDocument();
+}
+
+bool ExamplePart::loadOasis( const QDomDocument & doc, KoOasisStyles& oasisStyles,
+ const QDomDocument & settings, KoStore* store )
+{
+ // TODO load the document from the QDomDocument
+ return true;
+}
+
+bool ExamplePart::saveOasis( KoStore* store, KoXmlWriter* manifestWriter )
+{
+ // TODO save the document to the KoStore;
+ return true;
+}
+
+void ExamplePart::paintContent( QPainter& painter, const QRect& rect, bool /*transparent*/,
+ double /*zoomX*/, double /*zoomY*/ )
+{
+ // ####### handle transparency
+
+ // Need to draw only the document rectangle described in the parameter rect.
+ int left = rect.left() / 20;
+ int right = rect.right() / 20 + 1;
+ int top = rect.top() / 20;
+ int bottom = rect.bottom() / 20 + 1;
+
+ for( int x = left; x < right; ++x )
+ painter.drawLine( x * 20, top * 20, x * 20, bottom * 20 );
+ for( int y = left; y < right; ++y )
+ painter.drawLine( left * 20, y * 20, right * 20, y * 20 );
+}
+
+#include "example_part.moc"
diff --git a/example/example_part.h b/example/example_part.h
new file mode 100644
index 000000000..5945f8e4d
--- /dev/null
+++ b/example/example_part.h
@@ -0,0 +1,46 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef EXAMPLE_PART_H
+#define EXAMPLE_PART_H
+
+#include <KoDocument.h>
+
+class ExamplePart : public KoDocument
+{
+ Q_OBJECT
+public:
+ ExamplePart( QWidget *parentWidget = 0, const char *widgetName = 0, QObject* parent = 0, const char* name = 0, bool singleViewMode = false );
+
+ virtual void paintContent( QPainter& painter, const QRect& rect, bool transparent = FALSE, double zoomX = 1.0, double zoomY = 1.0 );
+
+ virtual bool initDoc(InitDocFlags flags, QWidget* parentWidget=0);
+
+ virtual bool loadXML( QIODevice *, const QDomDocument & );
+ virtual QDomDocument saveXML();
+
+ virtual bool loadOasis( const QDomDocument & doc, KoOasisStyles& oasisStyles,
+ const QDomDocument & settings, KoStore* store );
+ virtual bool saveOasis( KoStore* store, KoXmlWriter* manifestWriter );
+
+protected:
+ virtual KoView* createViewInstance( QWidget* parent, const char* name );
+};
+
+#endif
diff --git a/example/example_readonly.rc b/example/example_readonly.rc
new file mode 100644
index 000000000..fab57057d
--- /dev/null
+++ b/example/example_readonly.rc
@@ -0,0 +1,7 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Example" version="1">
+<MenuBar>
+ <Menu name="edit"><text>&amp;Edit</text>
+ <Action name="copy"/>
+ </Menu>
+</MenuBar>
+</kpartgui>
diff --git a/example/example_view.cc b/example/example_view.cc
new file mode 100644
index 000000000..2e97a2065
--- /dev/null
+++ b/example/example_view.cc
@@ -0,0 +1,76 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "example_view.h"
+#include "example_factory.h"
+#include "example_part.h"
+
+#include <qpainter.h>
+#include <qiconset.h>
+#include <kaction.h>
+#include <kstdaction.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+ExampleView::ExampleView( ExamplePart* part, QWidget* parent, const char* name )
+ : KoView( part, parent, name )
+{
+ setInstance( ExampleFactory::global() );
+ if ( !part->isReadWrite() ) // readonly case, e.g. when embedded into konqueror
+ setXMLFile( "example_readonly.rc" ); // simplified GUI
+ else
+ setXMLFile( "example.rc" );
+ KStdAction::copy(this, SLOT( copy() ), actionCollection(), "copy" );
+ KStdAction::cut(this, SLOT( cut() ), actionCollection(), "cut" );
+ // Note: Prefer KStdAction::* to any custom action if possible.
+ //m_cut = new KAction( i18n("&Cut"), "editcut", 0, this, SLOT( cut() ),
+ // actionCollection(), "cut");
+}
+
+void ExampleView::paintEvent( QPaintEvent* ev )
+{
+ QPainter painter;
+ painter.begin( this );
+
+ // ### TODO: Scaling
+
+ // Let the document do the drawing
+ koDocument()->paintEverything( painter, ev->rect(), FALSE, this );
+
+ painter.end();
+}
+
+void ExampleView::updateReadWrite( bool /*readwrite*/ )
+{
+#ifdef __GNUC__
+#warning TODO
+#endif
+}
+
+void ExampleView::copy()
+{
+ kdDebug(31000) << "ExampleView::copy(): COPY called" << endl;
+}
+
+void ExampleView::cut()
+{
+ kdDebug(31000) << "ExampleView::cut(): CUT called" << endl;
+}
+
+#include "example_view.moc"
diff --git a/example/example_view.h b/example/example_view.h
new file mode 100644
index 000000000..932af33aa
--- /dev/null
+++ b/example/example_view.h
@@ -0,0 +1,49 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef EXAMPLE_VIEW
+#define EXAMPLE_VIEW
+
+#include <KoView.h>
+
+class KAction;
+class QPaintEvent;
+
+class ExamplePart;
+
+class ExampleView : public KoView
+{
+ Q_OBJECT
+public:
+ ExampleView( ExamplePart* part, QWidget* parent = 0, const char* name = 0 );
+
+protected slots:
+ void cut();
+ void copy();
+
+protected:
+ void paintEvent( QPaintEvent* );
+
+ virtual void updateReadWrite( bool readwrite );
+
+private:
+ //KAction* m_cut;
+};
+
+#endif
diff --git a/example/examplepart.desktop b/example/examplepart.desktop
new file mode 100644
index 000000000..a96fa13e1
--- /dev/null
+++ b/example/examplepart.desktop
@@ -0,0 +1,59 @@
+[Desktop Entry]
+Name=KOffice Example Component
+Name[ar]=مكوّن KOffice مثالي
+Name[bg]=Примерен модул за KOffice
+Name[ca]=Component KOffice d'exemple
+Name[cs]=Ukázková KOffice komponenta
+Name[cy]=Cydran Enghreifftiol KOffice
+Name[da]=KOffice eksempel-komponent
+Name[de]=KOffice-Beispielkomponente
+Name[el]=Παράδειγμα συστατικού του KOffice
+Name[eo]=KOffice Ekzempla Komponanto
+Name[es]=Componente de ejemplo de KOffice
+Name[et]=KOffice'i näidiskomponent
+Name[eu]=KOffice-en adibidezko osagaia
+Name[fa]=مؤلفۀ نمونۀ KOffice
+Name[fi]=KOfficen esimerkkikomponentti
+Name[fr]=Composant-exemple KOffice
+Name[fy]=Foarbyldkomponint foar KOffice
+Name[ga]=Comhpháirt Shamplach KOffice
+Name[gl]=Componente Exemplo de KOffice
+Name[he]=רכיב לדוגמה של KOffice
+Name[hi]=के-ऑफ़िस उदाहरण अवयव
+Name[hr]=Primjer komponente za KOffice
+Name[hu]=KOffice mintakomponens
+Name[is]=KOffice sýnihluti
+Name[it]=Componente di esempio di KOffice
+Name[ja]=KOffice サンプルコンポーネント
+Name[km]=សមាសភាគ​ឧទាហរណ៍​សម្រាប់ KOffice
+Name[lv]=KOffice piemēra komponents
+Name[ms]=Komponen Contoh KOffice
+Name[nb]=Eksempelkomponent for KOffice
+Name[nds]=Bispeelmodulen för KOffice
+Name[ne]=केडीई कार्यालय उदाहरण अवयव
+Name[nl]=Voorbeeldcomponent voor KOffice
+Name[nn]=Dømekomponent for KOffice
+Name[pa]=KOffice ਉਦਾਹਰਨ ਭਾਗ
+Name[pl]=Przykładowy komponent KOffice
+Name[pt]=Componente Exemplo do KOffice
+Name[pt_BR]=Componente de Exemplo do KOffice
+Name[ru]=Пример компонента KOffice
+Name[se]=KOffice-ovdamearkaoassi
+Name[sk]=Príklad modulu KOffice
+Name[sl]=Vzorčna komponenta KOffice
+Name[sr]=Пример KOffice-ове компоненте
+Name[sr@Latn]=Primer KOffice-ove komponente
+Name[sv]=Koffice-exempelkomponent
+Name[ta]=K office எடுத்துக்காட்டு பயன்பாடுகள்
+Name[tg]=Мисоли Барномаи KOffice
+Name[tr]=KOffice Örnek Bileşeni
+Name[uk]=Приклад компонента KOffice
+Name[wa]=Componint di mostraedje di KOffice
+Name[zh_CN]=KOffice 组件范例
+Name[zh_TW]=KOffice 範例元件
+X-KDE-Library=libexamplepart
+MimeType=application/x-example
+Type=Service
+ServiceTypes=KOfficePart,KParts/ReadOnlyPart,KParts/ReadWritePart
+X-KDE-NativeMimeType=application/x-example
+Icon=example
diff --git a/example/main.cc b/example/main.cc
new file mode 100644
index 000000000..e12a1242d
--- /dev/null
+++ b/example/main.cc
@@ -0,0 +1,45 @@
+/* This file is part of the KDE project
+ Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
+
+ 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <KoApplication.h>
+#include <KoDocument.h>
+#include <KoMainWindow.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <dcopclient.h>
+#include "example_aboutdata.h"
+#include <koffice_export.h>
+
+static const KCmdLineOptions options[]=
+{
+ {"+[file]", I18N_NOOP("File to open"),0},
+ KCmdLineLastOption
+};
+
+extern "C" EXAMPLE_EXPORT int kdemain( int argc, char **argv )
+{
+ KCmdLineArgs::init( argc, argv, newExampleAboutData() );
+ KCmdLineArgs::addCmdLineOptions( options );
+ KoApplication app;
+
+ if (!app.start()) // parses command line args, create initial docs and shells
+ return 1;
+ return app.exec();
+}
+
diff --git a/example/x-vnd.kde.example.desktop b/example/x-vnd.kde.example.desktop
new file mode 100644
index 000000000..9140b74f8
--- /dev/null
+++ b/example/x-vnd.kde.example.desktop
@@ -0,0 +1,10 @@
+# KDE Config File
+[Desktop Entry]
+MimeType=application/x-vnd.kde.example
+#Comment=...
+Type=MimeType
+Patterns=*.xmpl;
+X-KDE-AutoEmbed=false
+[Property::X-KDE-NativeExtension]
+Type=QString
+Value=.xmpl