summaryrefslogtreecommitdiffstats
path: root/tools/tdefile-plugins/abiword
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 00:54:22 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 00:54:22 -0600
commit038b18b2df1da40baab30d62171766048a948095 (patch)
treeba99d50e3e7b3f2eccb63ba71aea4f6163ede37a /tools/tdefile-plugins/abiword
parentd0baf2961c379b31587c6542625018c6177474d0 (diff)
downloadkoffice-038b18b2df1da40baab30d62171766048a948095.tar.gz
koffice-038b18b2df1da40baab30d62171766048a948095.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tools/tdefile-plugins/abiword')
-rw-r--r--tools/tdefile-plugins/abiword/Makefile.am22
-rw-r--r--tools/tdefile-plugins/abiword/tdefile_abiword.cpp145
-rw-r--r--tools/tdefile-plugins/abiword/tdefile_abiword.desktop49
-rw-r--r--tools/tdefile-plugins/abiword/tdefile_abiword.h43
4 files changed, 259 insertions, 0 deletions
diff --git a/tools/tdefile-plugins/abiword/Makefile.am b/tools/tdefile-plugins/abiword/Makefile.am
new file mode 100644
index 00000000..4bd75a15
--- /dev/null
+++ b/tools/tdefile-plugins/abiword/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for gnumeric file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(KOFFICE_INCLUDES) $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = tdefile_abiword.h
+
+kde_module_LTLIBRARIES = tdefile_abiword.la
+
+tdefile_abiword_la_SOURCES = tdefile_abiword.cpp
+tdefile_abiword_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -ltdecore -ltdeui $(LIB_QT) -lkjs -ltdefx -lkio -ltdeparts
+tdefile_abiword_la_LIBADD = $(KOFFICE_LIBS)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+services_DATA = tdefile_abiword.desktop
+servicesdir = $(kde_servicesdir)
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/tdefile_abiword.pot
diff --git a/tools/tdefile-plugins/abiword/tdefile_abiword.cpp b/tools/tdefile-plugins/abiword/tdefile_abiword.cpp
new file mode 100644
index 00000000..59a645f7
--- /dev/null
+++ b/tools/tdefile-plugins/abiword/tdefile_abiword.cpp
@@ -0,0 +1,145 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2005 Laurent Montel <montel@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 version 2.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+#include "tdefile_abiword.h"
+
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kfilterdev.h>
+
+#include <tqdom.h>
+#include <tqfile.h>
+#include <tqdatetime.h>
+#include <kdebug.h>
+
+typedef KGenericFactory<AbiwordPlugin> AbiwordFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_abiword, AbiwordFactory( "tdefile_abiword" ))
+
+AbiwordPlugin::AbiwordPlugin(TQObject *parent, const char *name,
+ const TQStringList &args)
+
+ : KFilePlugin(parent, name, args)
+{
+ init();
+}
+
+void AbiwordPlugin::init()
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "application/x-abiword" );
+
+ KFileMimeTypeInfo::GroupInfo* group = 0L;
+
+ group = addGroupInfo(info, "DocumentInfo", i18n("Document Information"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ item = addItemInfo(group, "Author", i18n("Author"), TQVariant::String);
+ setHint(item, KFileMimeTypeInfo::Author);
+ item = addItemInfo(group, "Title", i18n("Title"), TQVariant::String);
+ setHint(item, KFileMimeTypeInfo::Name);
+ item = addItemInfo(group, "Abstract", i18n("Abstract"), TQVariant::String);
+ setHint(item, KFileMimeTypeInfo::Description);
+}
+
+bool AbiwordPlugin::readInfo( KFileMetaInfo& info, uint what)
+{
+ if ( info.path().isEmpty() ) // remote file
+ return false;
+
+ //Find the last extension
+ TQString strExt;
+ const int result=info.path().findRev('.');
+ if (result>=0)
+ {
+ strExt=info.path().mid(result);
+ }
+ TQString strMime; // Mime type of the compressor (default: unknown)
+ if ((strExt==".gz")||(strExt==".GZ") //in case of .abw.gz (logical extension)
+ ||(strExt==".zabw")||(strExt==".ZABW")) //in case of .zabw (extension used prioritary with AbiWord)
+ {
+ // Compressed with gzip
+ strMime="application/x-gzip";
+ kdDebug() << "Compression: gzip" << endl;
+ }
+ else if ((strExt==".bz2")||(strExt==".BZ2") //in case of .abw.bz2 (logical extension)
+ ||(strExt==".bzabw")||(strExt==".BZABW")) //in case of .bzabw (extension used prioritary with AbiWord)
+ {
+ // Compressed with bzip2
+ strMime="application/x-bzip2";
+ kdDebug() << "Compression: bzip2" << endl;
+ }
+
+ KFileMetaInfoGroup group = appendGroup(info, "DocumentInfo");
+ TQIODevice* in = KFilterDev::deviceForFile(info.path(),strMime);
+ if ( !in )
+ {
+ kdError() << "Cannot create device for uncompressing! Aborting!" << endl;
+ return false;
+ }
+
+ if (!in->open(IO_ReadOnly))
+ {
+ kdError() << "Cannot open file for uncompressing! Aborting!" << endl;
+ delete in;
+ return false;
+ }
+ TQDomDocument doc;
+ doc.setContent( in );
+ in->close();
+ TQDomElement docElem = doc.documentElement();
+ TQDomNode summary = docElem.namedItem("metadata");
+ TQDomNode m_item = summary.namedItem("m");
+
+ TQString author;
+ TQString title;
+ TQString abstract;
+
+ while( !m_item.isNull() )
+ {
+ kdDebug()<<" m_item.toElement().text: "<<m_item.toElement().text()<<endl;
+ TQString key = m_item.toElement().attribute( "key" );
+ if ( key.isEmpty() )
+ continue;
+ else if ( key=="dc.creator" )
+ author=m_item.toElement().text();
+ else if ( key=="dc.description" )
+ abstract=m_item.toElement().text();
+ else if ( key=="dc.title" )
+ title=m_item.toElement().text();
+ else
+ kdDebug()<<" Other key :"<<key<<endl;
+ m_item = m_item.nextSibling();
+ }
+ appendItem(group, "Author", stringItem( author ));
+ appendItem(group, "Title", stringItem( title ));
+ appendItem(group, "Abstract", stringItem( abstract ));
+
+ delete in;
+ return true;
+}
+
+TQString AbiwordPlugin::stringItem( const TQString &name )
+{
+ return name.isEmpty() ? i18n("*Unknown*") : name;
+}
+
+
+#include "tdefile_abiword.moc"
diff --git a/tools/tdefile-plugins/abiword/tdefile_abiword.desktop b/tools/tdefile-plugins/abiword/tdefile_abiword.desktop
new file mode 100644
index 00000000..eb22207d
--- /dev/null
+++ b/tools/tdefile-plugins/abiword/tdefile_abiword.desktop
@@ -0,0 +1,49 @@
+[Desktop Entry]
+Type=Service
+Name=Abiword Info
+Name[bg]=Информация за Abiword
+Name[br]=Titouroù Abiword
+Name[ca]=Informació Abiword
+Name[cy]=Gwybodaeth Abiword
+Name[da]=Abiword-info
+Name[el]=Πληροφορίες Abiword
+Name[eo]=Abiword-informo
+Name[es]=Información de Abiword
+Name[et]=Abiword'i info
+Name[fa]=اطلاعات Abiword
+Name[fi]=Abiword-tiedot
+Name[fr]=Informations sur Abiword
+Name[fy]=Abiword ynfo
+Name[ga]=Eolas faoi Abiword
+Name[gl]=Información de Abiword
+Name[he]=מידע של Abiword
+Name[hu]=Abiword-információ
+Name[is]=Abiword upplýsingar
+Name[it]=Informazioni su Abiword
+Name[ja]=Abiword 情報
+Name[km]=ព័ត៌មាន Abiword
+Name[lt]=Abiword informacija
+Name[lv]=Abiword informācija
+Name[nb]=Abiword-info
+Name[nds]=Abiword-Info
+Name[ne]=एबीआई वर्ड सूचना
+Name[nl]=Abiword-info
+Name[pl]=Informacje o Abiword
+Name[pt]=Informação do Abiword
+Name[pt_BR]=Informação do Abiword
+Name[ru]=Информация AbiWord
+Name[se]=Abiword-dieđut
+Name[sl]=Informacije o Abiword
+Name[sr]=Информације Abiword-а
+Name[sr@Latn]=Informacije Abiword-a
+Name[sv]=Abiword-information
+Name[uk]=Інформація Abiword
+Name[uz]=Abiword hujjati haqida maʼlumot
+Name[uz@cyrillic]=Abiword ҳужжати ҳақида маълумот
+Name[zh_CN]=Abiword 信息
+Name[zh_TW]=Abiword 資訊
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_abiword
+MimeType=application/x-abiword
+PreferredGroups=DocumentInfo
+PreferredItems=Author,Title,Abstract
diff --git a/tools/tdefile-plugins/abiword/tdefile_abiword.h b/tools/tdefile-plugins/abiword/tdefile_abiword.h
new file mode 100644
index 00000000..0b09acb8
--- /dev/null
+++ b/tools/tdefile-plugins/abiword/tdefile_abiword.h
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2005 Laurent Montel montel@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 version 2.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __KFILE_ABIWORD_H__
+#define __KFILE_ABIWORD_H__
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+class TQDomNode;
+
+class AbiwordPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ AbiwordPlugin( TQObject *parent, const char *name, const TQStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what);
+
+private:
+ void init();
+ TQString stringItem( const TQString &name );
+};
+
+#endif