summaryrefslogtreecommitdiffstats
path: root/kounavail
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 /kounavail
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 'kounavail')
-rw-r--r--kounavail/Makefile.am16
-rw-r--r--kounavail/README15
-rw-r--r--kounavail/kounavail.cc177
-rw-r--r--kounavail/kounavail.desktop62
-rw-r--r--kounavail/kounavail.h108
-rw-r--r--kounavail/test-kounavail.kwdbin0 -> 2105 bytes
-rw-r--r--kounavail/test-kounavail2.kwdbin0 -> 1476 bytes
7 files changed, 378 insertions, 0 deletions
diff --git a/kounavail/Makefile.am b/kounavail/Makefile.am
new file mode 100644
index 00000000..3db20e67
--- /dev/null
+++ b/kounavail/Makefile.am
@@ -0,0 +1,16 @@
+INCLUDES = $(KOFFICE_INCLUDES) $(all_includes)
+
+## The part
+kde_module_LTLIBRARIES = libkounavailpart.la
+libkounavailpart_la_SOURCES = kounavail.cc
+libkounavailpart_la_LDFLAGS = $(KDE_PLUGIN)
+libkounavailpart_la_LIBADD = $(LIB_KOFFICECORE)
+
+METASOURCES = AUTO
+noinst_HEADERS = kounavail.h
+
+kdelnk_DATA = kounavail.desktop
+kdelnkdir = $(kde_servicesdir)
+
+messages:
+ $(XGETTEXT) *.cc -o $(podir)/kounavail.pot
diff --git a/kounavail/README b/kounavail/README
new file mode 100644
index 00000000..426cf0b0
--- /dev/null
+++ b/kounavail/README
@@ -0,0 +1,15 @@
+This is simply an empty part, that is loaded and displayed when a
+document contains an invalid part
+- either because the handler for this part isn't available
+- or because the embedded document is external (out of the store) and unavailable
+
+The goal of the part is to show a placeholder in the document, to tell
+about the unavailable part, but also to be able to save itself as it was,
+so that it's possible to edit a document with a missing child document
+without losing information.
+
+Test documents:
+test-kounavail.kwd points to an invalid mimetype (case 1)
+test-kounavail2.kwd points to a non-existing external document (case 2)
+
+David Faure <faure@kde.org>
diff --git a/kounavail/kounavail.cc b/kounavail/kounavail.cc
new file mode 100644
index 00000000..a704eea4
--- /dev/null
+++ b/kounavail/kounavail.cc
@@ -0,0 +1,177 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 David Faure <faure@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 "kounavail.h"
+
+#include <qpainter.h>
+#include <qiconset.h>
+#include <kaction.h>
+#include <kinstance.h>
+#include <kstdaction.h>
+#include <klocale.h>
+#include <kaboutdata.h>
+#include <kdebug.h>
+#include <kglobalsettings.h>
+#include <qapplication.h>
+
+KoUnavailPart::KoUnavailPart( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name )
+ : KoDocument( parentWidget, widgetName, parent, name, false /*singleViewMode*/ )
+{
+ setReadWrite( false );
+}
+
+KoView* KoUnavailPart::createViewInstance( QWidget* parent, const char* name )
+{
+ return new KoUnavailView( this, parent, name );
+}
+
+bool KoUnavailPart::loadOasis( const QDomDocument& doc, KoOasisStyles&, const QDomDocument&, KoStore* )
+{
+ m_doc = doc;
+ return true;
+}
+
+bool KoUnavailPart::loadXML( QIODevice *, const QDomDocument &doc )
+{
+ // Simply keep a copy of the whole document ;)
+ m_doc = doc;
+ return true;
+}
+
+bool KoUnavailPart::saveFile()
+{
+ kdDebug() << "KoUnavailPart::saveFile m_url=" << m_url.prettyURL() << endl;
+ // This is called if the part points to an external file
+ // In that case we have nothing to save, the file was unavailable !
+ return true;
+}
+
+QDomDocument KoUnavailPart::saveXML()
+{
+ kdDebug() << "KoUnavailPart::saveXML" << endl;
+ return m_doc;
+}
+
+
+bool KoUnavailPart::saveOasis(KoStore*, KoXmlWriter*)
+{
+ // TODO
+ return false;
+}
+
+void KoUnavailPart::setMimeType( const QCString& mime )
+{
+ kdDebug() << "KoUnavailPart::setMimeType " << mime << endl;
+ m_mimetype = mime;
+}
+
+void KoUnavailPart::paintContent( QPainter& painter, const QRect& rect, bool /*transparent*/,
+ double /*zoomX*/, double /*zoomY*/ )
+{
+ painter.save();
+ painter.setPen( QApplication::palette().color( QPalette::Active, QColorGroup::Text ) );
+ // 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 );
+
+ QFont defaultFont = KGlobalSettings::generalFont();
+ defaultFont.setPointSize( 16 ); // ###
+ painter.setFont( defaultFont );
+ //painter.drawText( 20, 20, m_reason );
+ painter.drawText( rect, Qt::AlignCenter | Qt::WordBreak, m_reason );
+ painter.restore();
+}
+
+KoUnavailView::KoUnavailView( KoUnavailPart* part, QWidget* parent, const char* name )
+ : KoView( part, parent, name )
+{
+ setInstance( KoUnavailFactory::global() );
+ //setXMLFile( "kounavail.rc" );
+}
+
+void KoUnavailView::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();
+}
+
+K_EXPORT_COMPONENT_FACTORY( libkounavailpart, KoUnavailFactory )
+
+KInstance* KoUnavailFactory::s_global = 0L;
+KAboutData* KoUnavailFactory::s_aboutData = 0L;
+
+KoUnavailFactory::KoUnavailFactory( QObject* parent, const char* name )
+ : KoFactory( parent, name )
+{
+ global();
+}
+
+KoUnavailFactory::~KoUnavailFactory()
+{
+ delete s_aboutData;
+ s_aboutData = 0L;
+ delete s_global;
+ s_global = 0L;
+}
+
+KParts::Part* KoUnavailFactory::createPartObject( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, const char*, const QStringList & )
+{
+ return new KoUnavailPart( parentWidget, widgetName, parent, name );
+}
+
+KAboutData* KoUnavailFactory::aboutData()
+{
+ if ( !s_aboutData )
+ {
+ static const char* description=I18N_NOOP("KoUnavail KOffice Program");
+ static const char* version="0.1";
+ s_aboutData=new KAboutData( "kounavail", I18N_NOOP("KoUnavail"),
+ version, description, KAboutData::License_LGPL,
+ "(c) 2001, David Faure");
+ s_aboutData->addAuthor("David Faure",0, "faure@kde.org");
+ }
+ return s_aboutData;
+}
+
+KInstance* KoUnavailFactory::global()
+{
+ if ( !s_global )
+ {
+ s_global = new KInstance( aboutData() );
+ // Tell the iconloader about share/apps/koffice/icons
+ //s_global->iconLoader()->addAppDir("koffice");
+ }
+ return s_global;
+}
+
+#include "kounavail.moc"
diff --git a/kounavail/kounavail.desktop b/kounavail/kounavail.desktop
new file mode 100644
index 00000000..b78cbff6
--- /dev/null
+++ b/kounavail/kounavail.desktop
@@ -0,0 +1,62 @@
+[Desktop Entry]
+Name=Unavailable KOffice Document
+Name[af]=Onbeskikbaar Koffice Dokument
+Name[ar]=مستند KOffice غير متوفر
+Name[az]=Mövcud olmayan KOffice Sənədi
+Name[bg]=Неналичен документ на KOffice
+Name[bs]=Nedostupan KOffice dokument
+Name[ca]=Document KOffice no disponible
+Name[cs]=Nedostupný dokument KOffice
+Name[cy]=Dogfen KOffice sydd Ddim Ar Gael
+Name[da]=Utilgængeligt KOffice-dokument
+Name[de]=Nicht verfügbares KOffice-Dokument
+Name[el]=Μη διαθέσιμο έγγραφο του KOffice
+Name[eo]=Neuzebla KOffice-dokumento
+Name[es]=Documento de KOffice no disponible
+Name[et]=Kättesaamatu KOffice'i dokument
+Name[eu]=KOffice-en dokumentu eskuragaitza
+Name[fa]=سند غیرقابل دسترس KOffice
+Name[fi]=Tuntematon KOffice-asiakirja
+Name[fr]=Document KOffice non disponible
+Name[fy]=Net beskikber KOffice-dokumint
+Name[gl]=Documento KOffice Non Disponíbel
+Name[he]=מסמך לא זמין של KOffice
+Name[hr]=Nedostupan KOffice dokument
+Name[hu]=Elérhetetlen KOffice dokumentum
+Name[is]=Ófáanlegt KOffice skjal
+Name[it]=Documento KOffice non disponibile
+Name[ja]=利用不可能な KOffice ドキュメント
+Name[km]= ឯកសារ KOffice ដែល​មិនអាច​រក​បាន​
+Name[lo]=ບໍ່ມີເອກກະສານຂອງຊຸດໂປຣແກຣມສຳນັກງານ K
+Name[lt]=Neprieinamas KOffice dokumentas
+Name[lv]=Nepieejams KOffice dokuments
+Name[ms]=Dokumen KOffice Tak Tersedia
+Name[mt]=Dokument KOffice mhux disponibbli
+Name[nb]=Utilgjengelig KOffice-dokument
+Name[nds]=Nich verföögbor KOffice-Dokment
+Name[ne]=उपलब्ध नभएको केडीई कार्यालय कागजात
+Name[nl]=Niet beschikbaar KOffice-document
+Name[nn]=Utilgjengeleg KOffice-dokument
+Name[pl]=Niedostępny dokument KOffice
+Name[pt]=Documento KOffice Não Disponível
+Name[pt_BR]=Documento do KOffice indisponível
+Name[ro]=Document KOffice nedisponibil
+Name[ru]=Недоступный элемент KOffice
+Name[se]=Ii olamuttus KOffice-dokumeanta
+Name[sk]=Nedostupný dokument KOffice
+Name[sl]=Nerazpoložljiv dokument KOffice
+Name[sr]=Недоступан KOffice-ов документ
+Name[sr@Latn]=Nedostupan KOffice-ov dokument
+Name[sv]=Otillgängligt Koffice-dokument
+Name[tg]=Ҳуҷҷати KOffice Имконнопазир
+Name[th]=ไม่มีเอกสารของโปรแกรมชุดสำนักงาน K
+Name[tr]=Kullanılamayan KOffice Belgesi
+Name[uk]=Недоступний документ KOffice
+Name[uz]=Mavjud boʻlmagan KOffice hujjati
+Name[uz@cyrillic]=Мавжуд бўлмаган KOffice ҳужжати
+Name[xh]=Uxhwebu lwe KOffice Olungekhoyo
+Name[zh_CN]=不可用的 KOffice 文档
+Name[zh_TW]=無法取得的 KOffice 文件
+X-KDE-Library=libkounavailpart
+Type=Service
+ServiceTypes=KOfficePart
diff --git a/kounavail/kounavail.h b/kounavail/kounavail.h
new file mode 100644
index 00000000..dab3a002
--- /dev/null
+++ b/kounavail/kounavail.h
@@ -0,0 +1,108 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 David Faure <faure@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 KOUNAVAIL_H
+#define KOUNAVAIL_H
+
+#include <KoDocument.h>
+
+class KoUnavailPart : public KoDocument
+{
+ Q_OBJECT
+ Q_PROPERTY( QCString mimetype READ nativeFormatMimeType WRITE setMimeType )
+ Q_PROPERTY( QString unavailReason READ unavailReason WRITE setUnavailReason )
+ Q_PROPERTY( QString realURL READ realURL WRITE setRealURL )
+public:
+ KoUnavailPart( QWidget *parentWidget = 0, const char *widgetName = 0, QObject* parent = 0, const char* name = 0 );
+
+ virtual void paintContent( QPainter& painter, const QRect& rect, bool transparent = FALSE, double zoomX = 1.0, double zoomY = 1.0 );
+
+ virtual bool initDoc(InitDocFlags, QWidget* = 0) { return true; }
+ virtual bool loadOasis( const QDomDocument& doc, KoOasisStyles& oasisStyles, const QDomDocument& settings, KoStore* );
+ virtual bool saveOasis(KoStore*, KoXmlWriter*);
+
+ virtual bool loadXML( QIODevice *, const QDomDocument & );
+ virtual bool saveFile();
+ virtual QDomDocument saveXML();
+ virtual bool saveChildren( KoStore* /*_store*/ ) { return true; }
+
+ /** This is called by KoDocumentChild::save */
+ virtual QCString nativeFormatMimeType() const { return m_mimetype; }
+ /** This is called by KoDocumentChild::createUnavailDocument */
+ void setMimeType( const QCString& mime );
+ // keep in sync with koDocumentChild.h
+ enum UnavailReason { DocumentNotFound, HandlerNotFound };
+ /** This is called by KoDocumentChild::createUnavailDocument */
+ void setUnavailReason( const QString& reason ) { m_reason = reason; }
+ // stupid moc - I want a write-only property !
+ QString unavailReason() const { return m_reason; }
+ /** This is called by KoDocumentChild::createUnavailDocument
+ * Note the trick: we directly modify the URL of the document,
+ * the one returned by KPart's url()
+ */
+ void setRealURL( const QString& u ) { m_url = u; }
+ // stupid moc again
+ QString realURL() const { return m_url.url(); }
+
+protected:
+ virtual KoView* createViewInstance( QWidget* parent, const char* name );
+
+ QDomDocument m_doc;
+ QCString m_mimetype;
+ QString m_reason;
+};
+
+#include <KoView.h>
+
+class KoUnavailView : public KoView
+{
+ Q_OBJECT
+public:
+ KoUnavailView( KoUnavailPart* part, QWidget* parent = 0, const char* name = 0 );
+
+protected:
+ virtual void paintEvent( QPaintEvent* );
+ virtual void updateReadWrite( bool ) {}
+};
+
+#include <KoFactory.h>
+
+class KInstance;
+class KAboutData;
+
+class KoUnavailFactory : public KoFactory
+{
+ Q_OBJECT
+public:
+ KoUnavailFactory( QObject* parent = 0, const char* name = 0 );
+ ~KoUnavailFactory();
+
+ 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/kounavail/test-kounavail.kwd b/kounavail/test-kounavail.kwd
new file mode 100644
index 00000000..a072ffb5
--- /dev/null
+++ b/kounavail/test-kounavail.kwd
Binary files differ
diff --git a/kounavail/test-kounavail2.kwd b/kounavail/test-kounavail2.kwd
new file mode 100644
index 00000000..1c4f6e8e
--- /dev/null
+++ b/kounavail/test-kounavail2.kwd
Binary files differ