summaryrefslogtreecommitdiffstats
path: root/filters/kpresenter
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 /filters/kpresenter
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 'filters/kpresenter')
-rw-r--r--filters/kpresenter/Makefile.am1
-rw-r--r--filters/kpresenter/bmp/Makefile.am24
-rw-r--r--filters/kpresenter/bmp/bmpexport.cpp81
-rw-r--r--filters/kpresenter/bmp/bmpexport.h38
-rw-r--r--filters/kpresenter/bmp/kpresenter_bmp_export.desktop53
-rw-r--r--filters/kpresenter/jpeg/Makefile.am24
-rw-r--r--filters/kpresenter/jpeg/jpegexport.cpp82
-rw-r--r--filters/kpresenter/jpeg/jpegexport.h38
-rw-r--r--filters/kpresenter/jpeg/kpresenter_jpeg_export.desktop52
-rw-r--r--filters/kpresenter/kword/Makefile.am12
-rw-r--r--filters/kpresenter/kword/kprkword.cc466
-rw-r--r--filters/kpresenter/kword/kprkword.desktop57
-rw-r--r--filters/kpresenter/kword/kprkword.h45
-rw-r--r--filters/kpresenter/kword/status.html88
-rw-r--r--filters/kpresenter/libimageexport/Makefile.am20
-rw-r--r--filters/kpresenter/libimageexport/imageexport.cpp99
-rw-r--r--filters/kpresenter/libimageexport/imageexport.h45
-rw-r--r--filters/kpresenter/magicpoint/Makefile.am5
-rw-r--r--filters/kpresenter/magicpoint/kpresenter_magicpoint_import.desktop62
-rwxr-xr-xfilters/kpresenter/magicpoint/mgp2kpr.py417
-rw-r--r--filters/kpresenter/mng/Makefile.am24
-rw-r--r--filters/kpresenter/mng/kpresenter_mng_export.desktop52
-rw-r--r--filters/kpresenter/mng/mngexport.cpp78
-rw-r--r--filters/kpresenter/mng/mngexport.h38
-rw-r--r--filters/kpresenter/ooimpress/Makefile.am21
-rw-r--r--filters/kpresenter/ooimpress/kpresenter_ooimpress_export.desktop63
-rw-r--r--filters/kpresenter/ooimpress/kpresenter_ooimpress_import.desktop64
-rw-r--r--filters/kpresenter/ooimpress/ooimpressexport.cc1160
-rw-r--r--filters/kpresenter/ooimpress/ooimpressexport.h92
-rw-r--r--filters/kpresenter/ooimpress/ooimpressimport.cc2433
-rw-r--r--filters/kpresenter/ooimpress/ooimpressimport.h120
-rw-r--r--filters/kpresenter/ooimpress/status.html227
-rw-r--r--filters/kpresenter/ooimpress/stylefactory.cc1629
-rw-r--r--filters/kpresenter/ooimpress/stylefactory.h282
-rw-r--r--filters/kpresenter/png/Makefile.am24
-rw-r--r--filters/kpresenter/png/kpresenter_png_export.desktop52
-rw-r--r--filters/kpresenter/png/pngexport.cpp78
-rw-r--r--filters/kpresenter/png/pngexport.h38
-rw-r--r--filters/kpresenter/powerpoint/Makefile.am2
-rw-r--r--filters/kpresenter/powerpoint/import/Makefile.am14
-rw-r--r--filters/kpresenter/powerpoint/import/kpresenter_powerpoint_import.desktop51
-rw-r--r--filters/kpresenter/powerpoint/import/powerpointimport.cc1592
-rw-r--r--filters/kpresenter/powerpoint/import/powerpointimport.h83
-rw-r--r--filters/kpresenter/powerpoint/libppt/Makefile.am5
-rw-r--r--filters/kpresenter/powerpoint/libppt/libppt.h31
-rw-r--r--filters/kpresenter/powerpoint/libppt/objects.cpp426
-rw-r--r--filters/kpresenter/powerpoint/libppt/objects.h206
-rw-r--r--filters/kpresenter/powerpoint/libppt/pole.cpp1317
-rw-r--r--filters/kpresenter/powerpoint/libppt/pole.h177
-rw-r--r--filters/kpresenter/powerpoint/libppt/powerpoint.cpp6201
-rw-r--r--filters/kpresenter/powerpoint/libppt/powerpoint.h2533
-rw-r--r--filters/kpresenter/powerpoint/libppt/presentation.cpp91
-rw-r--r--filters/kpresenter/powerpoint/libppt/presentation.h86
-rw-r--r--filters/kpresenter/powerpoint/libppt/slide.cpp138
-rw-r--r--filters/kpresenter/powerpoint/libppt/slide.h61
-rw-r--r--filters/kpresenter/powerpoint/libppt/testppt.cpp42
-rw-r--r--filters/kpresenter/powerpoint/libppt/ustring.cpp675
-rw-r--r--filters/kpresenter/powerpoint/libppt/ustring.h395
-rw-r--r--filters/kpresenter/svg/Makefile.am21
-rw-r--r--filters/kpresenter/svg/kpresenter_svg_export.desktop52
-rw-r--r--filters/kpresenter/svg/svgexport.cc100
-rw-r--r--filters/kpresenter/svg/svgexport.h38
-rw-r--r--filters/kpresenter/xbm/Makefile.am24
-rw-r--r--filters/kpresenter/xbm/kpresenter_xbm_export.desktop51
-rw-r--r--filters/kpresenter/xbm/xbmexport.cpp78
-rw-r--r--filters/kpresenter/xbm/xbmexport.h38
-rw-r--r--filters/kpresenter/xpm/Makefile.am24
-rw-r--r--filters/kpresenter/xpm/kpresenter_xpm_export.desktop51
-rw-r--r--filters/kpresenter/xpm/xpmexport.cpp78
-rw-r--r--filters/kpresenter/xpm/xpmexport.h38
70 files changed, 22903 insertions, 0 deletions
diff --git a/filters/kpresenter/Makefile.am b/filters/kpresenter/Makefile.am
new file mode 100644
index 00000000..83598811
--- /dev/null
+++ b/filters/kpresenter/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = libimageexport png bmp xbm xpm mng svg jpeg kword ooimpress
diff --git a/filters/kpresenter/bmp/Makefile.am b/filters/kpresenter/bmp/Makefile.am
new file mode 100644
index 00000000..ece3480f
--- /dev/null
+++ b/filters/kpresenter/bmp/Makefile.am
@@ -0,0 +1,24 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ -I$(top_srcdir)/filters/libdialogfilter \
+ -I$(top_srcdir)/filters/kpresenter/libimageexport \
+ $(all_includes)
+
+####### Files
+
+kde_module_LTLIBRARIES = libkpresenterbmpexport.la
+
+libkpresenterbmpexport_la_SOURCES = bmpexport.cpp
+libkpresenterbmpexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined
+libkpresenterbmpexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la ../../../filters/libdialogfilter/libdialogfilter.la ../libimageexport/libkpresenterimageexport.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ bmpexport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_bmp_export.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/bmp/bmpexport.cpp b/filters/kpresenter/bmp/bmpexport.cpp
new file mode 100644
index 00000000..b2ecfe0f
--- /dev/null
+++ b/filters/kpresenter/bmp/bmpexport.cpp
@@ -0,0 +1,81 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 <qpixmap.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+#include <kgenericfactory.h>
+#include <KoDocument.h>
+
+#include "KPrDocument.h"
+#include "KPrView.h"
+#include "KPrCanvas.h"
+#include "bmpexport.h"
+#include "exportsizedia.h"
+
+typedef KGenericFactory<BmpExport, KoFilter> bmpExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libkpresenterbmpexport, bmpExportFactory( "bmpexport" ) )
+
+BmpExport::BmpExport(KoFilter *fil, const char *name, const QStringList&lst)
+ : ImageExport(fil,name,lst)
+{
+}
+
+BmpExport::~BmpExport()
+{
+}
+
+bool BmpExport::extraImageAttribute()
+{
+ ExportSizeDia *exportDialog = new ExportSizeDia( width, height,
+ 0, "exportdialog");
+ bool ret = false;
+ if (exportDialog->exec()) {
+ width = exportDialog->width();
+ height = exportDialog->height();
+ ret = true;
+ kdDebug() << "PNG Export: size = [" << width << "," << height << "]" << endl;
+ }
+ delete exportDialog;
+ return ret;
+}
+
+
+bool BmpExport::saveImage( QString fileName)
+{
+ bool ret = pixmap.save( fileName, "BMP" );
+ // Save the image.
+ if ( !ret ) {
+ KMessageBox::error( 0, i18n( "Failed to write file." ),
+ i18n( "BMP Export Error" ) );
+ }
+ return ret;
+}
+
+const char * BmpExport::exportFormat()
+{
+ return "image/x-bmp";
+}
+
+#include "bmpexport.moc"
+
diff --git a/filters/kpresenter/bmp/bmpexport.h b/filters/kpresenter/bmp/bmpexport.h
new file mode 100644
index 00000000..6e4f29bf
--- /dev/null
+++ b/filters/kpresenter/bmp/bmpexport.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 __BMPEXPORT_H__
+#define __BMPEXPORT_H__
+
+#include "imageexport.h"
+
+class BmpExport : public ImageExport
+{
+ Q_OBJECT
+
+public:
+ BmpExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~BmpExport();
+ virtual bool saveImage( QString fileName);
+ virtual bool extraImageAttribute();
+ virtual const char * exportFormat();
+};
+
+#endif // __PNGEXPORT_H__
+
diff --git a/filters/kpresenter/bmp/kpresenter_bmp_export.desktop b/filters/kpresenter/bmp/kpresenter_bmp_export.desktop
new file mode 100644
index 00000000..f47dd4eb
--- /dev/null
+++ b/filters/kpresenter/bmp/kpresenter_bmp_export.desktop
@@ -0,0 +1,53 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter BMP Export Filter
+Name[ar]=مرشح تصدير BMP لدى KPresenter
+Name[bg]=Филтър за експортиране от KPresenter в BMP
+Name[br]=Sil ezporzh BMB evit KPresenter
+Name[ca]=Filtre d'exportació BMP per a KPresenter
+Name[cy]=Hidlen Allforio BMP KPresenter
+Name[da]=KPræsenter BMP-eksportfilter
+Name[de]=KPresenter BMP-Exportfilter
+Name[el]=Φίλτρο εξαγωγής BMP του KPresenter
+Name[eo]=KPresenter BMP-eksportfiltrilo
+Name[es]=Filtro de exportación a BMP para KPresenter
+Name[et]=KPresenteri BMP ekspordifilter
+Name[fa]=پالایۀ صادرات KPresenter BMP
+Name[fi]=KPresenter BMP -vientisuodin
+Name[fr]=Filtre d'exportation BMP de KPresenter
+Name[fy]=BMP-Eksportfilter foarKPresenter
+Name[ga]=Scagaire Easpórtála BMP KPresenter
+Name[gl]=Filtro de Exportación de BMP para KPresenter
+Name[he]=KPresenter מסנן יצוא
+Name[hr]=KPresenter BMP filtar izvoza
+Name[hu]=KPresenter BMP exportszűrő
+Name[is]=KPresenter BMP útflutningssía
+Name[it]=Filtro di esportazione BMP per KPresenter
+Name[ja]=KPresenter BMP エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ BMP សម្រាប់ KPresenter
+Name[lt]=KPresenter BMP eksportavimo filtras
+Name[lv]=KPresenter BMP eksporta filtrs
+Name[nb]=BMP-eksportfilter for KPresenter
+Name[nds]=BMP-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता बीएमपी निर्यात फिल्टर
+Name[nl]=BMP-exportfilter voor KPresenter
+Name[pl]=Filtr eksportu do formatu BMP z KPresenter
+Name[pt]=Filtro de Exportação de BMP para o KPresenter
+Name[pt_BR]=Filtro de Exportação de BMP para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в BMP
+Name[se]=KPresenter BMP-olggosfievrridansilli
+Name[sk]=Exportný filter KPresenter BMP
+Name[sl]=Izvozni filter BMP za KPresenter
+Name[sr]=KChart-ов филтер за извоз у BMP
+Name[sr@Latn]=KChart-ov filter za izvoz u BMP
+Name[sv]=Kpresenter BMP-exportfilter
+Name[uk]=Фільтр експорту BMP для KPresenter
+Name[uz]=KPresenter BMP eksport filteri
+Name[uz@cyrillic]=KPresenter BMP экспорт филтери
+Name[zh_CN]=KPresenter BMP 导出过滤器
+Name[zh_TW]=KPresenter BMP 匯出過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Export=image/x-bmp
+X-KDE-Weight=1
+X-KDE-Library=libkpresenterbmpexport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/jpeg/Makefile.am b/filters/kpresenter/jpeg/Makefile.am
new file mode 100644
index 00000000..9f5106c2
--- /dev/null
+++ b/filters/kpresenter/jpeg/Makefile.am
@@ -0,0 +1,24 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ -I$(top_srcdir)/filters/libdialogfilter \
+ -I$(top_srcdir)/filters/kpresenter/libimageexport \
+ $(all_includes)
+
+####### Files
+
+kde_module_LTLIBRARIES = libkpresenterjpegexport.la
+
+libkpresenterjpegexport_la_SOURCES = jpegexport.cpp
+libkpresenterjpegexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined
+libkpresenterjpegexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la ../../../filters/libdialogfilter/libdialogfilter.la ../libimageexport/libkpresenterimageexport.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ jpegexport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_jpeg_export.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/jpeg/jpegexport.cpp b/filters/kpresenter/jpeg/jpegexport.cpp
new file mode 100644
index 00000000..b62d985d
--- /dev/null
+++ b/filters/kpresenter/jpeg/jpegexport.cpp
@@ -0,0 +1,82 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 <qpixmap.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+#include <kgenericfactory.h>
+#include <KoDocument.h>
+
+#include "KPrDocument.h"
+#include "KPrView.h"
+#include "KPrCanvas.h"
+#include "jpegexport.h"
+#include "exportsizedia.h"
+
+typedef KGenericFactory<JpegExport, KoFilter> jpegExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libkpresenterjpegexport, jpegExportFactory( "jpegexport" ) )
+
+JpegExport::JpegExport(KoFilter *fil, const char *name, const QStringList&lst)
+ : ImageExport(fil,name,lst)
+{
+}
+
+JpegExport::~JpegExport()
+{
+}
+
+bool JpegExport::extraImageAttribute()
+{
+ bool ret = false;
+ ExportSizeDia *exportDialog = new ExportSizeDia( width, height,
+ 0, "exportdialog");
+ if (exportDialog->exec()) {
+ width = exportDialog->width();
+ height = exportDialog->height();
+
+ kdDebug() << "MNG Export: size = [" << width << "," << height << "]" << endl;
+ ret = true;
+ }
+ delete exportDialog;
+ return ret;
+}
+
+
+bool JpegExport::saveImage( QString fileName)
+{
+ bool ret = pixmap.save( fileName, "JPEG" );
+ // Save the image.
+ if ( !ret ) {
+ KMessageBox::error( 0, i18n( "Failed to write file." ),
+ i18n( "JPEG Export Error" ) );
+ }
+ return ret;
+}
+
+const char * JpegExport::exportFormat()
+{
+ return "image/jpeg";
+}
+
+#include "jpegexport.moc"
+
diff --git a/filters/kpresenter/jpeg/jpegexport.h b/filters/kpresenter/jpeg/jpegexport.h
new file mode 100644
index 00000000..873e463f
--- /dev/null
+++ b/filters/kpresenter/jpeg/jpegexport.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 __XPMEXPORT_H__
+#define __XPMEXPORT_H__
+
+#include "imageexport.h"
+
+class JpegExport : public ImageExport
+{
+ Q_OBJECT
+
+public:
+ JpegExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~JpegExport();
+ virtual bool saveImage( QString fileName);
+ virtual bool extraImageAttribute();
+ virtual const char * exportFormat();
+};
+
+#endif // __XPMEXPORT_H__
+
diff --git a/filters/kpresenter/jpeg/kpresenter_jpeg_export.desktop b/filters/kpresenter/jpeg/kpresenter_jpeg_export.desktop
new file mode 100644
index 00000000..868eac79
--- /dev/null
+++ b/filters/kpresenter/jpeg/kpresenter_jpeg_export.desktop
@@ -0,0 +1,52 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter JPEG Export Filter
+Name[ar]=مرشح تصدير JPEG لدى KPresenter
+Name[bg]=Филтър за експортиране от Kpresenter в JPEG
+Name[br]=Sil ezporzh JPEG evit KPresenter
+Name[ca]=Filtre d'exportació JPEG per a KPresenter
+Name[da]=KPræsenter JPEG-eksportfilter
+Name[de]=KPresenter JPEG-Exportfilter
+Name[el]=Φίλτρο εξαγωγής JPEG του KPresenter
+Name[eo]=KPresenter JPEG-eksportfiltrilo
+Name[es]=Filtro de exportación a JPEG para KPresenter
+Name[et]=KPresenteri JPEG ekspordifilter
+Name[fa]=پالایۀ صادرات KPresenter JPEG
+Name[fi]=KPresenter JPEG -vientisuodin
+Name[fr]=Filtre d'exportation JPEG de KPresenter
+Name[fy]=JPEG-Eksportfilter foar KPresenter
+Name[ga]=Scagaire Easpórtála JPEG KPresenter
+Name[gl]=Filtro de Exportación de JPEG para KPresenter
+Name[he]=KPresenter JPEG מסנן יצוא
+Name[hr]=KPresenter JPEG filtar izvoza
+Name[hu]=KPresenter JPEG exportszűrő
+Name[is]=KPresenter JPEG útflutningssía
+Name[it]=Filtro di esportazione JPEG per KPresenter
+Name[ja]=KPresenter JPEG エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ JPEG សម្រាប់ KPresenter
+Name[lt]=KPresenter JPEG eksportavimo filtras
+Name[lv]=KPresenter JPEG eksporta filtrs
+Name[nb]=JPEG-eksportfilter for KPresenter
+Name[nds]=JPEG-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता जेपीईजी निर्यात फिल्टर
+Name[nl]=JPEG-exportfilter voor KPresenter
+Name[pl]=Filtr eksportu do formatu JPEG z KPresenter
+Name[pt]=Filtro de Exportação de JPEG para o KPresenter
+Name[pt_BR]=Filtro de Exportação de JPEG para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в JPEG
+Name[se]=KPresnter JPEG-olggosfievrridansilli
+Name[sk]=Exportný filter KPresenter JPEG
+Name[sl]=Izvozni filter JPEG za KPresenter
+Name[sr]=KChart-ов филтер за извоз у JPEG
+Name[sr@Latn]=KChart-ov filter za izvoz u JPEG
+Name[sv]=Kpresenter JPEG-exportfilter
+Name[uk]=Фільтр експорту JPEG для KPresenter
+Name[uz]=KPresenter JPEG eksport filteri
+Name[uz@cyrillic]=KPresenter JPEG экспорт филтери
+Name[zh_CN]=KPresenter JPEG 导出过滤器
+Name[zh_TW]=KPresenter JPEG 匯出過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Export=image/jpeg
+X-KDE-Weight=1
+X-KDE-Library=libkpresenterjpegexport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/kword/Makefile.am b/filters/kpresenter/kword/Makefile.am
new file mode 100644
index 00000000..0e579f5c
--- /dev/null
+++ b/filters/kpresenter/kword/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) $(all_includes)
+
+kde_module_LTLIBRARIES = libkprkword.la
+
+libkprkword_la_SOURCES = kprkword.cc
+libkprkword_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
+libkprkword_la_LIBADD = $(KOFFICE_LIBS)
+
+METASOURCES = AUTO
+
+service_DATA = kprkword.desktop
+servicedir = $(kde_servicesdir)
diff --git a/filters/kpresenter/kword/kprkword.cc b/filters/kpresenter/kword/kprkword.cc
new file mode 100644
index 00000000..a0cd7ab4
--- /dev/null
+++ b/filters/kpresenter/kword/kprkword.cc
@@ -0,0 +1,466 @@
+/* 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 <config.h>
+
+#include <kgenericfactory.h>
+#include <KoStoreDevice.h>
+#include <KoFilterChain.h>
+#include <KoGlobal.h>
+#include <kprkword.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <qsortedlist.h>
+#include <qcolor.h>
+
+typedef KGenericFactory<KprKword, KoFilter> KprKwordFactory;
+K_EXPORT_COMPONENT_FACTORY( libkprkword, KprKwordFactory( "kofficefilters" ) )
+
+KprKword::KprKword(KoFilter *, const char *, const QStringList&) :
+ KoFilter(),
+ outdoc( "DOC" )
+{
+}
+
+// This filter can act as an import filter for KWord and as an export
+// filter for KPresenter (isn't our architecture really nice ? :)
+// This is why we use the file-to-file method, not a QDomDoc one.
+KoFilter::ConversionStatus KprKword::convert( const QCString& from, const QCString& to )
+{
+ if(to!="application/x-kword" || from!="application/x-kpresenter")
+ return KoFilter::NotImplemented;
+
+ KoStoreDevice* inpdev = m_chain->storageFile( "root", KoStore::Read );
+ if ( !inpdev )
+ {
+ kdError(30502) << "Unable to open input stream" << endl;
+ return KoFilter::StorageCreationError;
+ }
+
+ inpdoc.setContent( inpdev );
+
+
+ outdoc.appendChild( outdoc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
+ QDomElement kwdoc = outdoc.createElement( "DOC" );
+ kwdoc.setAttribute( "editor", "KprKword converter" );
+ kwdoc.setAttribute( "mime", "application/x-kword" );
+ kwdoc.setAttribute( "syntaxVersion", 1 );
+ outdoc.appendChild( kwdoc );
+
+ QDomElement paper = outdoc.createElement( "PAPER" );
+ kwdoc.appendChild( paper );
+ paper.setAttribute( "format", 1 ); // A4. How on earth could I know what the user really wants ? :)
+ paper.setAttribute( "width", 595 );
+ paper.setAttribute( "height", 841 );
+ QDomElement borders = outdoc.createElement( "PAPERBORDERS" );
+ paper.appendChild( borders );
+ borders.setAttribute( "left", 28 );
+ borders.setAttribute( "top", 42 );
+ borders.setAttribute( "right", 28 );
+ borders.setAttribute( "bottom", 42 );
+
+ QDomElement framesets = outdoc.createElement( "FRAMESETS" );
+ kwdoc.appendChild( framesets );
+
+ frameset = outdoc.createElement( "FRAMESET" );
+ framesets.appendChild( frameset );
+ frameset.setAttribute( "frameType", 1 ); // text
+ frameset.setAttribute( "frameInfo", 0 ); // body
+ QDomElement frame = outdoc.createElement( "FRAME" );
+ frameset.appendChild( frame );
+ frame.setAttribute( "left", 28 );
+ frame.setAttribute( "top", 42 );
+ frame.setAttribute( "right", 566 );
+ frame.setAttribute( "bottom", 798 );
+ frame.setAttribute( "autoCreateNewFrame", 1 );
+ frame.setAttribute( "newFrameBehaviour", 0 );
+
+ titleStyleName = i18n("Slide Title");
+
+ // Convert !
+
+ convert();
+
+ // Create a style for the slide titles
+
+ QDomElement styles = outdoc.createElement( "STYLES" );
+ kwdoc.appendChild( styles );
+
+ QDomElement style = outdoc.createElement( "STYLE" );
+ styles.appendChild( style );
+ QDomElement elem = outdoc.createElement( "NAME" );
+ style.appendChild( elem );
+ elem.setAttribute( "value", titleStyleName );
+ elem = outdoc.createElement( "FOLLOWING" );
+ style.appendChild( elem );
+ elem.setAttribute( "name", "Standard" ); // no i18n here!
+
+ QDomElement counter = outdoc.createElement( "COUNTER" );
+ style.appendChild( counter );
+ counter.setAttribute( "type", 1 ); // numbered
+ counter.setAttribute( "depth", 0 );
+ counter.setAttribute( "start", 1 );
+ counter.setAttribute( "numberingtype", 1 ); // chapter
+ counter.setAttribute( "righttext", "." );
+
+ QDomElement format = outdoc.createElement( "FORMAT" );
+ style.appendChild( format );
+ QDomElement font = outdoc.createElement( "FONT" );
+ format.appendChild( font );
+ font.setAttribute( "name", titleFont ); // found when reading the first title
+ QDomElement size = outdoc.createElement( "SIZE" );
+ format.appendChild( size );
+ size.setAttribute( "value", 24 );
+ QDomElement bold = outdoc.createElement( "WEIGHT" );
+ format.appendChild( bold );
+ bold.setAttribute( "value", 75 );
+
+ // Create the standard style
+ style = outdoc.createElement( "STYLE" );
+ styles.appendChild( style );
+ elem = outdoc.createElement( "NAME" );
+ style.appendChild( elem );
+ elem.setAttribute( "value", "Standard" ); // no i18n here!
+ format = outdoc.createElement( "FORMAT" );
+ style.appendChild( format ); // empty format == use defaults
+
+ // Write output file
+
+ KoStoreDevice* out = m_chain->storageFile( "root", KoStore::Write );
+ if(!out) {
+ kdError(30502) << "Unable to open output file!" << endl;
+ return KoFilter::StorageCreationError;
+ }
+ QCString cstring = outdoc.toCString(); // utf-8 already
+ out->writeBlock( cstring.data(), cstring.length() );
+ return KoFilter::OK;
+}
+
+// This class is used to sort the objects by y position
+class KprObject {
+ public:
+ double y;
+ QDomElement elem;
+ bool operator < ( const KprObject & c ) const
+ {
+ return y < c.y;
+ }
+ bool operator == ( const KprObject & c ) const
+ {
+ return y == c.y;
+ }
+};
+
+void KprKword::convert()
+{
+ QDomElement docElem = inpdoc.documentElement();
+ QDomElement paper = docElem.namedItem( "PAPER" ).toElement();
+ int ptPageHeight = paper.attribute( "ptHeight" ).toInt();
+
+ QDomElement objects = docElem.namedItem( "OBJECTS" ).toElement();
+ if ( objects.isNull() )
+ return;
+
+ QSortedList< KprObject > objList;
+ objList.setAutoDelete( true );
+
+ QDomNodeList lst = objects.elementsByTagName( "OBJECT" );
+ uint lstcount = lst.count();
+ for ( uint item = 0 ; item < lstcount ; ++item )
+ {
+ QDomElement object = lst.item( item ).toElement();
+ if ( object.attribute( "type" ).toInt() == 4 ) // we only care about text objs
+ {
+ QDomElement orig = object.namedItem( "ORIG" ).toElement();
+ if ( !orig.isNull() )
+ {
+ KprObject * obj = new KprObject;
+ obj->y = orig.attribute( "y" ).toDouble();
+ obj->elem = object;
+ objList.inSort( obj );
+ }
+ }
+ }
+
+ int curPage = -1;
+ //kdDebug() << "found " << objList.count() << " objects" << endl;
+
+ for ( QPtrListIterator<KprObject> it(objList); it.current(); ++it )
+ {
+ QDomElement elem = it.current()->elem;
+ // Detect the first object of each page
+ int page = int( it.current()->y / ptPageHeight );
+ bool isTitle = ( page > curPage );
+ //kdDebug() << "KprKword::convert y=" << it.current()->y << " ptPageHeight=" << ptPageHeight
+ // << " isTitle=" << isTitle << endl;
+ curPage = page;
+
+ QDomElement textObj = elem.namedItem( "TEXTOBJ" ).toElement();
+ if (textObj.isNull())
+ continue;
+ // For each paragraph in this text object...
+ QDomNodeList lst = textObj.elementsByTagName( "P" );
+ uint lstcount = lst.count();
+ for ( uint item = 0; item < lstcount ; ++item )
+ {
+ QDomElement p = lst.item( item ).toElement();
+
+ // Create paragraph in KWord doc
+ QDomElement parag = outdoc.createElement( "PARAGRAPH" );
+ frameset.appendChild( parag );
+
+ QDomElement outFormatsElem = outdoc.createElement( "FORMATS" );
+
+ QString text;
+ // For each text element in the paragraph...
+ QDomElement textElem = p.firstChild().toElement();
+
+ QDomElement counter = p.namedItem( "COUNTER" ).toElement();
+ QDomElement indent=p.namedItem("INDENTS").toElement();
+ QDomElement lineSpacing=p.namedItem( "LINESPACING" ).toElement();
+ QDomElement offset=p.namedItem("OFFSETS").toElement();
+ QDomElement leftBorder = p.namedItem( "LEFTBORDER" ).toElement();
+ QDomElement rightBorder = p.namedItem( "RIGHTBORDER" ).toElement();
+ QDomElement topBorder = p.namedItem( "TOPBORDER" ).toElement();
+ QDomElement bottomBorder = p.namedItem( "BOTTOMBORDER" ).toElement();
+
+ QDomElement shadow=p.namedItem("SHADOW").toElement();
+
+ for ( ; !textElem.isNull() ; textElem = textElem.nextSibling().toElement() )
+ {
+ int oldLen = text.length();
+ text += textElem.text();
+ //kdDebug() << "KprKword::convert text now " << text << endl;
+ QDomElement outFormatElem = outdoc.createElement( "FORMAT" );
+
+ if ( textElem.attribute( "italic" ).toInt() )
+ {
+ QDomElement e = outdoc.createElement("ITALIC");
+ e.setAttribute( "value", 1 );
+ outFormatElem.appendChild( e );
+ }
+ QColor underlineColor;
+ if ( textElem.hasAttribute("underlinecolor" ))
+ {
+ underlineColor =QColor(textElem.attribute("underlinecolor" ));
+ }
+ QString underlineStyleLine;
+ if ( textElem.hasAttribute("underlinestyleline"))
+ {
+ underlineStyleLine = textElem.attribute("underlinestyleline");
+ }
+ if ( textElem.hasAttribute("underline" ))
+ {
+ QDomElement e = outdoc.createElement("UNDERLINE");
+ QString value = textElem.attribute( "underline" );
+ if ( value == "double" )
+ {
+ e.setAttribute( "value", "double" );
+ }
+ else if ( value == "single" )
+ {
+ e.setAttribute( "value", "double" );
+ }
+ else
+ {
+ e.setAttribute( "value", (bool)value.toInt() ? "1" :"0" );
+ }
+ if ( underlineColor.isValid())
+ {
+ e.setAttribute("underlinecolor", underlineColor.name());
+ }
+ if ( !underlineStyleLine.isEmpty() )
+ e.setAttribute("styleline", underlineStyleLine);
+ outFormatElem.appendChild( e );
+
+ }
+
+ QString strikeOutStyleLine;
+ if ( textElem.hasAttribute("strikeoutstyleline"))
+ {
+ strikeOutStyleLine = textElem.attribute("strikeoutstyleline");
+ }
+ QString strikeOutValue;
+ if ( textElem.hasAttribute("strikeOut"))
+ {
+ strikeOutValue = textElem.attribute("strikeOut");
+ }
+
+ if( !strikeOutValue.isEmpty())
+ {
+ QDomElement e = outdoc.createElement("STRIKEOUT");
+ e.setAttribute( "value", strikeOutValue );
+ if ( !strikeOutStyleLine.isEmpty())
+ e.setAttribute("styleline", strikeOutStyleLine);
+ outFormatElem.appendChild( e );
+ }
+ /*if ( textElem.attribute( "bold" ).toInt() )
+ {
+ QDomElement e = outdoc.createElement("WEIGHT");
+ e.setAttribute( "value", 75 );
+ outFormatElem.appendChild( e );
+ }*/ // doesn't look good
+ if ( titleFont.isEmpty() && isTitle )
+ titleFont = textElem.attribute( "family" );
+
+ // Family and point size are voluntarily NOT passed over.
+ if ( !textElem.attribute( "color" ).isEmpty())
+ {
+ QColor col;
+ col.setNamedColor(textElem.attribute( "color" ));
+ QDomElement e = outdoc.createElement("COLOR");
+ e.setAttribute( "red", col.red() );
+ e.setAttribute( "green", col.green() );
+ e.setAttribute( "blue", col.blue() );
+ outFormatElem.appendChild( e );
+ }
+ if ( !textElem.attribute("textbackcolor").isEmpty())
+ {
+ QColor col;
+ col.setNamedColor(textElem.attribute( "textbackcolor" ));
+ QDomElement e = outdoc.createElement("TEXTBACKGROUNDCOLOR");
+ e.setAttribute( "red", col.red() );
+ e.setAttribute( "green", col.green() );
+ e.setAttribute( "blue", col.blue() );
+ outFormatElem.appendChild( e );
+ }
+
+ //before VERTICAL align
+ double relative = 0;
+ if( textElem.attribute("relativetextsize").toDouble())
+ {
+ relative = textElem.attribute("relativetextsize").toDouble();
+ }
+
+
+ if( textElem.attribute("VERTALIGN").toInt())
+ {
+ QDomElement e = outdoc.createElement("VERTALIGN");
+ e.setAttribute( "value", textElem.attribute("VERTALIGN").toInt() );
+ if ( relative != 0)
+ e.setAttribute( "relativetextsize", relative );
+ outFormatElem.appendChild( e );
+ }
+
+ if( textElem.hasAttribute("shadowtext"))
+ {
+ QDomElement e = outdoc.createElement("SHADOWTEXT");
+ e.setAttribute( "value", textElem.attribute("shadowtext").toInt() );
+ outFormatElem.appendChild( e );
+ }
+
+ if( textElem.hasAttribute("offsetfrombaseline"))
+ {
+ QDomElement e = outdoc.createElement("OFFSETFROMBASELINE");
+ e.setAttribute( "value", textElem.attribute("offsetfrombaseline").toInt() );
+ outFormatElem.appendChild( e );
+ }
+
+ if( textElem.hasAttribute("wordbyword"))
+ {
+ QDomElement e = outdoc.createElement("WORDBYWORD");
+ e.setAttribute( "value", textElem.attribute("wordbyword").toInt() );
+ outFormatElem.appendChild( e );
+ }
+
+ if( textElem.hasAttribute("fontattribute"))
+ {
+ QDomElement e = outdoc.createElement("FONTATTRIBUTE");
+ e.setAttribute( "value", textElem.attribute("fontattribute") );
+ outFormatElem.appendChild( e );
+ }
+ if( textElem.hasAttribute("language"))
+ {
+ QDomElement e = outdoc.createElement("LANGUAGE");
+ e.setAttribute( "value", textElem.attribute("language") );
+ outFormatElem.appendChild( e );
+ }
+ if ( !outFormatElem.firstChild().isNull() )
+ {
+ outFormatElem.setAttribute( "id", 1 ); // normal exte
+ outFormatElem.setAttribute( "pos", oldLen );
+ outFormatElem.setAttribute( "len", text.length() - oldLen );
+ outFormatsElem.appendChild( outFormatElem );
+ }
+
+ } // end "for each text element"
+
+ // KPresenter seems to save a trailing space (bug!)
+ int len = text.length();
+ if ( len > 0 && text[ len - 1 ] == ' ' )
+ text.truncate( len - 1 );
+
+ QDomElement outTextElem = outdoc.createElement( "TEXT" );
+ parag.appendChild( outTextElem );
+ outTextElem.appendChild( outdoc.createTextNode( text ) );
+
+ if ( !outFormatsElem.firstChild().isNull() ) // Do we have formats to save ?
+ parag.appendChild( outFormatsElem );
+
+ QDomElement layoutElem = outdoc.createElement( "LAYOUT" );
+ parag.appendChild( layoutElem );
+ QDomElement nameElem = outdoc.createElement( "NAME" );
+ layoutElem.appendChild( nameElem );
+ nameElem.setAttribute( "value", isTitle ? titleStyleName : QString("Standard") );
+ QDomElement align=outdoc.createElement("FLOW");
+ if(p.hasAttribute("align"))
+ {
+ switch(p.attribute( "align" ).toInt())
+ {
+ case 1:
+ align.setAttribute( "align","left");
+ break;
+ case 2:
+ align.setAttribute( "align","right");
+ break;
+ case 4:
+ align.setAttribute( "align","center");
+ break;
+ case 8:
+ align.setAttribute( "align","justify");
+ break;
+ }
+ }
+ if(!counter.isNull() )
+ layoutElem.appendChild( counter );
+ if(!indent.isNull())
+ layoutElem.appendChild( indent );
+ if(!lineSpacing.isNull())
+ layoutElem.appendChild( lineSpacing );
+ if(!offset.isNull())
+ layoutElem.appendChild( offset);
+ if(!leftBorder.isNull())
+ layoutElem.appendChild(leftBorder);
+ if(!rightBorder.isNull())
+ layoutElem.appendChild(rightBorder);
+ if(!topBorder.isNull())
+ layoutElem.appendChild(topBorder);
+ if(!bottomBorder.isNull())
+ layoutElem.appendChild(bottomBorder);
+ if(!align.isNull())
+ layoutElem.appendChild(align);
+ if(!shadow.isNull())
+ layoutElem.appendChild(shadow);
+ // Only the first parag of the top text object is set to the 'title' style
+ isTitle = false;
+ }
+ }
+}
+
+#include <kprkword.moc>
diff --git a/filters/kpresenter/kword/kprkword.desktop b/filters/kpresenter/kword/kprkword.desktop
new file mode 100644
index 00000000..bf4ff228
--- /dev/null
+++ b/filters/kpresenter/kword/kprkword.desktop
@@ -0,0 +1,57 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter KWord Filter
+Name[ar]=مِرْشَح KPresenter->KWord
+Name[bg]=Филтър KPresenter-> KWord
+Name[br]=Sil KWord KPresenter
+Name[ca]=Filtre de KWord per a KPresenter
+Name[cs]=Filtr pro převod KPresenter->KWord
+Name[cy]=Hidlen KWord KPresenter
+Name[da]=KPræsenter KWord-filter
+Name[de]=KPresenter KWord-Filter
+Name[el]=KPresenter KWord φίλτρο
+Name[eo]=KPresenter KWord-filtrilo
+Name[es]=Filtro de KWord para KPresenter
+Name[et]=KPresenteri KWordi filter
+Name[eu]=KPresenter-en KWord iragazkia
+Name[fa]=پالایۀ KPresenter KWord
+Name[fi]=KPresenter KWord -suodin
+Name[fr]=Filtre KWord pour KPresenter
+Name[fy]=KWord-filter foar KPresenter
+Name[ga]=Scagaire KWord KPresenter
+Name[gl]=Filtro de KWord para KPresenter
+Name[he]=מסנן ייבוא מ־KWord ל־KPresenter
+Name[hr]=KPresenter filtar za KWord
+Name[hu]=KPresenter KWord szűrő
+Name[is]=KPresenter KWord sía
+Name[it]=Filtro da KPresenter a KWord
+Name[ja]=KPresenter KWord フィルタ
+Name[km]=តម្រង KWord សម្រាប់ KPresenter
+Name[lt]=KPresenter KWord filtras
+Name[lv]=KPresenter KWord filtrs
+Name[ms]=Penapis KPresenter KWord
+Name[nb]=KPresenter KWord-filter
+Name[nds]=KWord-Filter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता केडीई शब्द फिल्टर
+Name[nl]=KWord-filter voor KPresenter
+Name[nn]=KWord-filter for KPresenter
+Name[pl]=Filtr KPresenter formatu KWord
+Name[pt]=Filtro de KWord para o KPresenter
+Name[pt_BR]=Filtro do KPresenter->KWord
+Name[ru]=Фильтр экспорта документов KWord в KPresenter
+Name[se]=KPresentera KWord-silli
+Name[sk]=Filter pre prevod KPresenter- KWord
+Name[sl]=Filter za KPresenter v KWord
+Name[sr]=KPresenter-ов филтер за KWord
+Name[sr@Latn]=KPresenter-ov filter za KWord
+Name[sv]=Kpresenter Kword-filter
+Name[uk]=Фільтр KWord для KPresenter
+Name[uz]=KPresenter uchun KWord filteri
+Name[uz@cyrillic]=KPresenter учун KWord филтери
+Name[zh_CN]=KPresenter KWord 过滤器
+Name[zh_TW]=KPresenter KWord 過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Weight=1
+X-KDE-Export=application/x-kword
+X-KDE-Library=libkprkword
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/kword/kprkword.h b/filters/kpresenter/kword/kprkword.h
new file mode 100644
index 00000000..5e0aed2d
--- /dev/null
+++ b/filters/kpresenter/kword/kprkword.h
@@ -0,0 +1,45 @@
+/* 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 KPRKWORD_H
+#define KPRKWORD_H
+
+#include <KoFilter.h>
+#include <qdom.h>
+
+class KprKword : public KoFilter {
+
+ Q_OBJECT
+
+public:
+ KprKword(KoFilter *parent, const char *name, const QStringList&);
+
+ virtual ~KprKword() {}
+
+ virtual KoFilter::ConversionStatus convert( const QCString& from, const QCString& to );
+
+protected:
+ void convert();
+ QDomDocument inpdoc;
+ QDomDocument outdoc;
+ QDomElement frameset;
+ QString titleStyleName;
+ QString titleFont;
+};
+#endif // KPRKWORD_H
diff --git a/filters/kpresenter/kword/status.html b/filters/kpresenter/kword/status.html
new file mode 100644
index 00000000..2c669e0c
--- /dev/null
+++ b/filters/kpresenter/kword/status.html
@@ -0,0 +1,88 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>KOffice filters status: ASCII FILTER</title>
+</head>
+<body text="#000000" bgcolor="#FFFFFF" link="#000099" vlink="#666666" alink="#666666">
+<A NAME="START">&nbsp;</A>
+
+<BR>
+<center>
+ <h1>
+ KOffice filters status: &nbsp;&nbsp;<i>KPRESENTER->KWORD FILTER</i>
+ </h1>
+</center>
+
+<hr NOSHADE SIZE=2 WIDTH="70%">
+
+<font size="-1"><b>
+ <A HREF="#export">Export</A>
+</b></font>
+
+<center>
+ <a NAME="export"></a>
+</center>
+
+<center>
+<table BORDER=0 CELLSPACING=0 BGCOLOR="#000000" WIDTH="100%">
+ <tr>
+ <td>
+ <table BORDER=0 CELLPADDING=2 BGCOLOR="#FFFFFF" WIDTH="100%">
+ <tr BGCOLOR="#FFDDDD">
+ <td COLSPAN="2">
+ <center><b><i><font size="+1">
+ <BR>Export KPresenter to KWord.<BR>
+ This can be useful as a starting point for writing a document
+ about a presentation.<BR>
+ </font></i></b></center>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP WIDTH="1%" NOWRAP><b><font size="+1">Last update</font></b></td>
+ <td>10 Apr 2001</td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">Features</font></b></td>
+ <td>Export a presentation into a KWord text document</td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Todo</font></b></td>
+ <td>-</td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">History</font></b></td>
+ <td>
+ 10 Apr 2001 Initial version<br>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Authors</font></b></td>
+ <td>
+ <a href="mailto:faure@kde.org">David Faure</a>&nbsp;&nbsp;
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">Links</font></b></td>
+ <td>-</td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Progress report </font></b></td>
+ <td>-</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</center>
+<A HREF="#START"><font size="-1"><b>Up</b></font></A>
+
+</body>
+</html>
diff --git a/filters/kpresenter/libimageexport/Makefile.am b/filters/kpresenter/libimageexport/Makefile.am
new file mode 100644
index 00000000..a4eb6010
--- /dev/null
+++ b/filters/kpresenter/libimageexport/Makefile.am
@@ -0,0 +1,20 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ $(all_includes)
+
+####### Files
+
+lib_LTLIBRARIES = libkpresenterimageexport.la
+
+libkpresenterimageexport_la_SOURCES = imageexport.cpp
+libkpresenterimageexport_la_LDFLAGS = $(all_libraries) -version-info 4:0 -no-undefined
+libkpresenterimageexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ imageexport.h
+
+METASOURCES = AUTO
+
+
diff --git a/filters/kpresenter/libimageexport/imageexport.cpp b/filters/kpresenter/libimageexport/imageexport.cpp
new file mode 100644
index 00000000..7611a936
--- /dev/null
+++ b/filters/kpresenter/libimageexport/imageexport.cpp
@@ -0,0 +1,99 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 <qpixmap.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+#include <kgenericfactory.h>
+#include <KoDocument.h>
+
+#include "KPrDocument.h"
+#include "KPrView.h"
+#include "KPrCanvas.h"
+#include "imageexport.h"
+
+ImageExport::ImageExport(KoFilter *, const char *, const QStringList&)
+ : KoFilter()
+{
+}
+
+ImageExport::~ImageExport()
+{
+}
+
+
+KoFilter::ConversionStatus
+ImageExport::convert(const QCString& from, const QCString& to)
+{
+ KoDocument * document = m_chain->inputDocument();
+
+ if ( !document )
+ return KoFilter::StupidError;
+
+ if ( strcmp(document->className(), "KPrDocument") != 0)
+ {
+ kdWarning() << "document isn't a KPrDocument but a "
+ << document->className() << endl;
+ return KoFilter::NotImplemented;
+ }
+
+ // Check for proper conversion.
+ if ( from != "application/x-kpresenter" || to != exportFormat() )
+ {
+ kdWarning() << "Invalid mimetypes " << to << " " << from << endl;
+ return KoFilter::NotImplemented;
+ }
+ KPrDocument * kpresenterdoc = const_cast<KPrDocument *>(static_cast<const KPrDocument *>(document));
+
+ if ( kpresenterdoc->mimeType() != "application/x-kpresenter" )
+ {
+ kdWarning() << "Invalid document mimetype " << kpresenterdoc->mimeType() << endl;
+ return KoFilter::NotImplemented;
+ }
+ KoPageLayout layoutPage= kpresenterdoc->pageLayout();
+ width = int( layoutPage.ptWidth );
+ height = int( layoutPage.ptHeight );
+ if (extraImageAttribute())
+ {
+ KPrView* view = static_cast<KPrView*>( kpresenterdoc->views().getFirst());
+ if ( view ) // no view if embedded document
+ {
+ KPrCanvas * canvas = view->getCanvas();
+ canvas->drawPageInPix( pixmap, view->getCurrPgNum()-1, 0, true, width,height );
+ }
+ else //when it's embedded we use just it.
+ {
+ pixmap = QPixmap(width, height);
+ QPainter painter(&pixmap);
+ kpresenterdoc->paintContent(painter, pixmap.rect(), false);
+ }
+ if( !saveImage( m_chain->outputFile()))
+ return KoFilter::CreationError;
+ return KoFilter::OK;
+ }
+ return KoFilter::UserCancelled;
+}
+
+
+#include "imageexport.moc"
+
diff --git a/filters/kpresenter/libimageexport/imageexport.h b/filters/kpresenter/libimageexport/imageexport.h
new file mode 100644
index 00000000..e5dfeb81
--- /dev/null
+++ b/filters/kpresenter/libimageexport/imageexport.h
@@ -0,0 +1,45 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 __IMAGEEXPORT_H__
+#define __IMAGEEXPORT_H__
+
+#include <KoFilter.h>
+
+class QPixmap;
+class ImageExport : public KoFilter
+{
+ Q_OBJECT
+
+public:
+ ImageExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~ImageExport();
+
+ virtual KoFilter::ConversionStatus convert(const QCString& from, const QCString& to);
+ virtual bool extraImageAttribute() { return true;};
+ virtual bool saveImage( QString fileName) = 0;
+ virtual const char* exportFormat() = 0;
+protected:
+ int width;
+ int height;
+ QPixmap pixmap;
+};
+
+#endif // __IMAGEEXPORT_H__
+
diff --git a/filters/kpresenter/magicpoint/Makefile.am b/filters/kpresenter/magicpoint/Makefile.am
new file mode 100644
index 00000000..a7b01ade
--- /dev/null
+++ b/filters/kpresenter/magicpoint/Makefile.am
@@ -0,0 +1,5 @@
+bin_SCRIPTS = mgp2kpr.py
+
+service_DATA = kpresenter_magicpoint_import.desktop
+
+servicedir = $(kde_servicesdir)
diff --git a/filters/kpresenter/magicpoint/kpresenter_magicpoint_import.desktop b/filters/kpresenter/magicpoint/kpresenter_magicpoint_import.desktop
new file mode 100644
index 00000000..947c6ba7
--- /dev/null
+++ b/filters/kpresenter/magicpoint/kpresenter_magicpoint_import.desktop
@@ -0,0 +1,62 @@
+[Desktop Entry]
+Type=Service
+Exec=mgp2kpr.py
+Name=Magicpoint Import Filter for KPresenter
+Name[ar]=مِرْشَح استيراد Magicpoint لدى KPresenter
+Name[bg]=Филтър за импортиране от Magicpoint в KPresenter
+Name[br]=Sil enporzh Magicpoint evit KPresenter
+Name[ca]=Filtre d'importació Magicpoint per a KPresenter
+Name[cs]=Importní filtr Magicpoint pro KPresenter
+Name[cy]=Hidlen Fewnforio Magicpoint i KPresenter
+Name[da]=Magicpoint import-filter for KPresenter
+Name[de]=KPresenter Magicpoint-Importfilter
+Name[el]=Φίλτρο εισαγωγής Magicpoint για το KPresenter
+Name[eo]=Magicpoint-importfiltrilo por KPresenter
+Name[es]=Filtro de importación de Magicpoint para KPresenter
+Name[et]=KPresenteri Magicpoint'i impordifilter
+Name[eu]=KPresenter-en Magicpoint inportaziorako iragazkia
+Name[fa]=پالایۀ واردات Magicpoint برای KPresenter
+Name[fi]=Magicpoint-tuontisuodin KPresenterille
+Name[fr]=Filtre d'importation Magicpoint pour KPresenter
+Name[fy]=Magicpoint-Ymportfilter foar Kpresenter
+Name[gl]=Filtro de Importación de Magicpoint para KPresenter
+Name[he]=מסנן ייבוא מ־MagicPoint ל־KPresenter
+Name[hi]=के-प्रेज़ेन्टर के लिए मैजिक पाइन्ट आयात छननी
+Name[hr]=Magicpoint filtar uvoza za KPresenter
+Name[hu]=Magicpoint importszűrő a KPresenterhez
+Name[is]=Magicpoint innflutningssía fyrir KPresenter
+Name[it]=Filtro di importazione Magicpoint per KPresenter
+Name[ja]=KPresenter Magicpoint インポートフィルタ
+Name[km]=តម្រង​នាំចូល Magicpoint សម្រាប់ KPresenter
+Name[lo]= ຕົວຕອງການນຳເຂົ້າ CSV ຂອງກະດາດຄຳນວນ K
+Name[lt]=Magicpoint importavimo filtras skirtas KPresenter
+Name[lv]=Magicpoint importa filtrs priekš KPresenter
+Name[ms]=Penapis Import Magicpoint bagi KPresenter
+Name[nb]=Magicpoint-importfilter for KPresenter
+Name[nds]=Magicpoint-Importfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ताका लागि म्याजिकबिन्दु निर्यात फिल्टर
+Name[nl]=Magicpoint-importfilter voor KPresenter
+Name[nn]=Magicpoint-importfilter for KPresenter
+Name[pl]=Filtr importu z Magicpoint dla KPresenter
+Name[pt]=Filtro de Importação de Magicpoint para o KPresenter
+Name[pt_BR]=Filtro de Importação Magicpoint para o KPresenter
+Name[ru]=Фильтр импорта презентаций Magicpoint в KPresenter
+Name[se]=KPresenter:a Magicpoint-sisafievrridansilli
+Name[sk]=Filter pre import Magicpoint pre KPresenter
+Name[sl]=Uvozni filter Magicpoint za KPresenter
+Name[sr]=KPresenter-ов филтер за увоз из Magicpoint-а
+Name[sr@Latn]=KPresenter-ov filter za uvoz iz Magicpoint-a
+Name[sv]=Magicpoint-importfilter för Kpresenter
+Name[ta]=மாயப்புள்ளி ஏற்றுமதி வடிகட்டி kpresenter
+Name[tg]=Филтри Воридоти Magicpoint барои KPresenter
+Name[tr]=KPresenter için Magicpoint Alma Filtresi
+Name[uk]=Фільтр імпорту Magicpoint для KPresenter
+Name[uz]=KPresenter uchun Magicpoint import filteri
+Name[uz@cyrillic]=KPresenter учун Magicpoint импорт филтери
+Name[wa]=Passete Magicpoint d' intrêye po KPresenter
+Name[xh]=Isihluzi Sokurhweba ngaphakathi kwi Magicpoint ye KPresenter
+Name[zh_CN]=KPresenter 的 Magicpoint 导入过滤器
+Name[zh_TW]=KPresenter 的 Magicpoint Import 匯入過濾程式
+X-KDE-Wrapper-Export=application/x-kpresenter
+X-KDE-Wrapper-Import=application/x-magicpoint
+ServiceTypes=KOfficeGenericFilter
diff --git a/filters/kpresenter/magicpoint/mgp2kpr.py b/filters/kpresenter/magicpoint/mgp2kpr.py
new file mode 100755
index 00000000..97527471
--- /dev/null
+++ b/filters/kpresenter/magicpoint/mgp2kpr.py
@@ -0,0 +1,417 @@
+#!/usr/bin/env python
+
+"""This script converts a Magicpoint presentation and outputs
+a KPresenter document (XML).
+
+Magicpoint's homepage: http://www.mew.org/mgp/
+KPresenter's homepage: http://www.koffice.org/kpresenter
+
+This is free software, released under GPL v2.
+Author: Lukas Tinkl <lukas@kde.org>, 2002
+
+TODO (in order of priority):
+DONE: support linespacing
+DONE: support bullets
+DONE: support bold/italic faces
+- support parsing the document defaults (%default and %tab)
+- support horizontal bars (hard to position them properly)
+- make it use the ZIP store instead of a plain XML file (needed for images below)
+- support images
+- support for MNG animations (KPresenter doesn't know about them ATM)
+
+$Id: mgp2kpr.py 186390 2002-10-29 15:39:40Z lukas $
+"""
+
+import os, sys
+import fileinput
+import string
+from xml.dom.DOMImplementation import implementation
+from xml.dom import Document
+from xml.dom import Element
+from xml.dom.ext import PrettyPrint
+
+def getYDpi():
+ """Utility function; parses xdpyinfo output and returns the vertical DPI of the X display.
+ Needed to transform the %-like font size into real font point size.
+ """
+ pipe=os.popen("(xdpyinfo | grep dot | cut -b21-22) 2>/dev/null", "r")
+ if pipe:
+ dpi=pipe.read().strip()
+ if dpi:
+ return dpi
+ return 75
+
+PAGE_WIDTH=680
+Y_OFFSET=510
+
+class MgpImporter:
+ def __init__(self):
+ "Constructor"
+ self.charset="iso8859-1"
+ self.pageCount=-1 #page counter
+ self.defFonts={} #default (symbolic) font names
+ self.useDefaults=1 #use page default values?
+ self.ydpi=int(getYDpi()) #Y DPI
+
+ self.__reset() #init properties
+
+ def __reset(self):
+ self.alignment="1" #text alignment, left
+ self.vgap=1 #line spacing
+
+ #font properties
+ self.fontName="standard"
+ self.fontItalic=0
+ self.fontBold=0
+ self.fontSize=24 #default (approximated) font size (5%)
+ self.textColor="white"
+
+ # background properties
+ self.backtype="0"
+ self.backview="0"
+ self.bctype="0" #single color (0) or gradient (>0)
+ self.color1="black"
+ self.color2="white"
+
+ def __setFontSize(self, command):
+ tokens=string.split(command,' ')
+ self.fontSize=int(Y_OFFSET/self.ydpi*72*float(tokens[1].strip())/100)
+ #print self.fontSize
+
+ def __setLineSpacing(self, command):
+ tokens=string.split(command,' ')
+ self.vgap=int(tokens[1].strip())
+
+ def __setupDefaultFonts(self,command):
+ tokens=string.split(command,' ')
+ _key=string.replace(tokens[1], '"', '')
+ _val=string.replace(tokens[3], '"', '')
+ self.defFonts[_key]=_val
+ #print self.defFonts
+
+ def __setFontIndirect(self,command):
+ tokens=string.split(command,' ')
+ _font=string.replace(tokens[1], '"', '')
+ if _font in self.defFonts.keys(): #we have a "default" font, find it in the map
+ self.__setFont(None,self.defFonts[_font])
+ #print self.defFonts[_font]
+
+ def __setFont(self,command,font=""):
+ if command:
+ tokens=string.split(command,' ')
+ font=string.replace(tokens[1], '"', '').strip() #XLFD-like, eg: mincho-medium-r (family-weight-slant)
+
+ _numDash=string.find(font,"-") #find dashes
+
+ if (_numDash==-1): #mincho
+ self.fontName=font
+ return
+ else: #mincho-medium-r
+ _xlfd=string.split(font, "-")
+ self.fontName=_xlfd[0]
+ if (_xlfd[1]=="bold" or _xlfd[1]=="semibold" or _xlfd[1]=="demibold" or _xlfd[1]=="demi bold"): #this sucks :)
+ self.fontBold=1
+ else:
+ self.fontBold=0
+
+ if (_xlfd[2]=="i"):
+ self.fontItalic=1
+ else:
+ self.fontItalic=0
+
+ #print self.fontName
+
+ def __setBgColor(self, command):
+ tokens=string.split(command,' ')
+ self.bctype="0"
+ self.color1=string.replace(tokens[1].strip(),'"', '') #strip quotes and \n
+
+ def __setBgGradient(self, command):
+ tokens=string.split(command,' ')
+ #xsize=tokens[1]
+ #ysize=tokens[2]
+ #numcolors=tokens[3] or "256"
+ #zoomflag=tokens[5] or "0"
+
+ try:
+ dir=tokens[4]
+ self.color1=string.replace(tokens[6].strip(),'"', '') #strip quotes and \n
+ self.color2=string.replace(tokens[7].strip(),'"', '')
+ except:
+ self.bctype="0"
+ self.color1="black"
+ self.color2="white"
+ return
+
+ if (dir=="0"): #vertical
+ value="1"
+ elif (dir=="90"): #horizontal
+ value="2"
+ elif (dir=="180"): #vertical, swapped colors
+ value="1"
+ self.color1,self.color2=self.color2,self.color1
+ elif (dir=="270"): #horizontal, swapped colors
+ value="2"
+ self.color1,self.color2=self.color2,self.color1
+ elif (dir=="45"): #diagonal 1
+ value="3"
+ elif (dir=="135"): #diagonal 2
+ value="4" #TODO swap colors for diagonals too?
+ elif (dir=="-45"): #circular, what an easter egg ;)
+ value="5"
+ else:
+ value="1"
+
+ self.bctype=value
+
+ def __setAlign(self,command):
+ tokens=string.split(command,' ')
+ if (tokens[0]=='leftfill'): #justify
+ self.alignment="8"
+ elif (tokens[0]=='right'):
+ self.alignment="2"
+ elif (tokens[0]=='center'):
+ self.alignment="4"
+ else:
+ self.alignment="1" #left
+ #print self.alignment
+
+ def __setBackground(self,parent):
+ pageElem=self.document.createElement("PAGE")
+
+ elem=self.document.createElement("BACKTYPE") #color
+ elem.setAttribute("value", self.backtype)
+ pageElem.appendChild(elem)
+
+ elem=self.document.createElement("BACKVIEW") #always zoomed
+ elem.setAttribute("value", self.backview)
+ pageElem.appendChild(elem)
+
+ elem=self.document.createElement("BCTYPE") #single color
+ elem.setAttribute("value", self.bctype)
+ pageElem.appendChild(elem)
+
+ elem=self.document.createElement("BACKCOLOR1") #1st color
+ elem.setAttribute("color", self.color1)
+ pageElem.appendChild(elem)
+
+ if (self.bctype!="0"):
+ elem=self.document.createElement("BACKCOLOR2") #2nd color
+ elem.setAttribute("color", self.color2)
+ pageElem.appendChild(elem)
+
+ parent.appendChild(pageElem)
+
+ def __handlePage(self,parent,bgParent):
+ if (self.pageCount!=-1):
+ self.__setBackground(bgParent) #set the background for this page
+
+ self.pageCount=self.pageCount+1
+ objElem=self.document.createElement("OBJECT") #KPresenter text object
+ objElem.setAttribute("type", "4")
+
+ elem=self.document.createElement("ORIG") #object position
+ elem.setAttribute("x", "30")
+ elem.setAttribute("y", str(self.pageCount*Y_OFFSET+30))
+ objElem.appendChild(elem)
+
+ elem=self.document.createElement("SIZE") #object size
+ elem.setAttribute("width", "610")
+ elem.setAttribute("height", "440")
+ objElem.appendChild(elem)
+
+ self.textElem=self.document.createElement("TEXTOBJ") #text object
+ ### para comes here
+
+ objElem.appendChild(self.textElem)
+ parent.appendChild(objElem)
+
+ self.useDefaults=1
+ self.__reset()
+
+ def __handleText(self,line):
+ indent=-1
+
+ pElem=self.document.createElement("P") #paragraph
+ pElem.setAttribute("align", self.alignment)
+
+ elem=self.document.createElement("NAME") #style name
+ elem.setAttribute("value", "Standard") ###is this needed at all?
+ pElem.appendChild(elem)
+
+ if (self.useDefaults==0):
+ elem=self.document.createElement("LINESPACING") #linespacing
+ elem.setAttribute("type", "custom")
+ elem.setAttribute("spacingvalue", str(self.fontSize * self.vgap / 100.0))
+ pElem.appendChild(elem)
+
+ if (line.startswith('\t\t\t\t')): #bullets
+ indent=85
+ type=8
+ elif (line.startswith('\t\t\t')):
+ indent=56.6
+ type=11
+ elif (line.startswith('\t\t')):
+ indent=28.3
+ type=9
+ elif (line.startswith('\t')):
+ indent=0
+ type=10
+
+ if not indent==-1:
+ line=string.lstrip(line)
+
+ elem=self.document.createElement("INDENTS") #indentation (for bullet)
+ elem.setAttribute("left", str(indent))
+ pElem.appendChild(elem)
+
+ elem=self.document.createElement("COUNTER") #counter (for bullet)
+ elem.setAttribute("numberingtype", "0") #bullet numbering
+ elem.setAttribute("type", str(type)) #bullet type
+ #elem.setAttribute("depth", "0") #???
+ pElem.appendChild(elem)
+
+ elem=self.document.createElement("TEXT") #paragraph text
+ #elem.setAttribute("VERTALIGN", "0")
+ elem.setAttribute("family", self.fontName)
+ elem.setAttribute("pointSize", str(self.fontSize))
+ elem.setAttribute("color", self.textColor)
+
+ if (self.fontBold!=0):
+ elem.setAttribute("bold", "1")
+
+ if (self.fontItalic!=0):
+ elem.setAttribute("italic", "1")
+
+ text=self.document.createTextNode(unicode(line, self.charset, 'ignore'))
+ elem.appendChild(text)
+ pElem.appendChild(elem)
+ self.textElem.appendChild(pElem)
+
+ #print "*** text: " + line
+
+ def __setCharset(self,command):
+ tokens=string.split(command,' ')
+ self.charset=tokens[1].strip()
+
+ def __setTextColor(self,command):
+ tokens=string.split(command,' ')
+ self.textColor=string.replace(tokens[1].strip(),'"', '') #strip quotes
+ #print self.textColor
+
+ def __handleBar(self,command):
+ tokens=string.split(command,' ')
+
+ try:
+ color=string.replace(tokens[1].strip(),'"', '') #strip quotes and \n
+ width=tokens[2].strip()/1000*Y_OFFSET #in per mils of display height
+ start=tokens[3].strip()/100*PAGE_WIDTH #start position percent of display width
+ length=tokens[4].strip()/100*PAGE_WIDTH #length percent of display width
+ except: #default values
+ color=self.textColor
+ width=0.01*Y_OFFSET
+ start=0
+ length=PAGE_WIDTH
+
+
+ def __setPaper(self,parent):
+ paperElem=self.document.createElement("PAPER")
+ paperElem.setAttribute("ptWidth", str(PAGE_WIDTH))
+ paperElem.setAttribute("ptHeight", str(Y_OFFSET))
+ paperElem.setAttribute("orientation", "0") #landscape
+ paperElem.setAttribute("format", "5") #screen
+ paperElem.setAttribute("unit", "0") #mm
+
+ borderElem=self.document.createElement("PAPERBORDERS")
+ borderElem.setAttribute("ptLeft","0")
+ borderElem.setAttribute("ptRight","0")
+ borderElem.setAttribute("ptTop","0")
+ borderElem.setAttribute("ptBottom","0")
+
+ paperElem.appendChild(borderElem)
+
+ parent.appendChild(paperElem)
+
+ def convert(self, fileIn, fileOut=None):
+ """Parses the Magicpoint document and returns a KPresenter XML document.
+
+ fileIn: path to the input file
+ fileOut: path to the output file, or sys.stdout if omitted
+ """
+ doctype=implementation.createDocumentType("DOC", "-//KDE//DTD kpresenter 1.2//EN",
+ "http://www.koffice.org/DTD/kpresenter-1.2.dtd")
+ self.document=implementation.createDocument("http://www.koffice.org/DTD/kpresenter", "DOC", doctype)
+
+ rootElem=self.document.documentElement #the root "DOC" element
+ rootElem.setAttribute("mime", "application/x-kpresenter")
+ rootElem.setAttribute("syntaxVersion", "2")
+ rootElem.setAttribute("editor", "mgp2kpr import filter, (c) Lukas Tinkl, 2002")
+
+ self.__setPaper(rootElem)
+ bgElem=self.document.createElement("BACKGROUND")
+ objsElem=self.document.createElement("OBJECTS")
+
+ self.textElem=self.document.createElement("TEXTOBJ") #default text object
+
+ for line in fileinput.input(fileIn):
+ if (line.startswith('#') or line.startswith('%%')): #skip comments
+ continue
+ elif (line.startswith('%')): #commands
+ commands=string.split(string.replace(line, '%', ''),',') #list of commands, comma separated, remove '%'
+ for command in commands:
+ command=command.strip().lower()
+ #print command
+ if (command.lower().startswith('page')): #new page
+ self.__handlePage(objsElem, bgElem)
+ elif (command.startswith('bgrad')): #background gradient
+ self.__setBgGradient(command)
+ elif (command.startswith('deffont')): #default fonts
+ self.__setupDefaultFonts(command)
+ elif (command.startswith('default')): #document defaults TODO!!!
+ pass
+ elif (command.startswith('xfont')): #font
+ self.__setFont(command)
+ elif (command.startswith('font')): #font from default fonts
+ self.__setFontIndirect(command)
+ elif (command.startswith('size')): #font size
+ self.__setFontSize(command)
+ elif (command.startswith('left') or
+ command.startswith('center') or
+ command.startswith('right')): #text alignment
+ self.__setAlign(command)
+ elif (command.startswith('charset')): #charset
+ self.__setCharset(command)
+ elif (command.startswith('fore')): #font color
+ self.__setTextColor(command)
+ elif (command.startswith('back')): #background color
+ self.__setBgColor(command)
+ elif (command.startswith('bar')): #horizontal line
+ self.__handleBar(command)
+ elif (command.startswith('vgap')): #line spacing
+ self.__setLineSpacing(command)
+ elif (command.startswith('nodefault')): #use default page values?
+ self.useDefaults=0
+ else:
+ continue
+ else:
+ self.__handleText(line) #text
+
+ self.__setBackground(bgElem) #flush the background
+
+ rootElem.appendChild(bgElem)
+ rootElem.appendChild(objsElem)
+ self.document.appendChild(rootElem)
+
+ if fileOut:
+ PrettyPrint(self.document, open(fileOut[0], "w"))
+ else:
+ PrettyPrint(self.document, sys.stdout)
+
+if __name__ == '__main__':
+ if (len(sys.argv)==1 or len(sys.argv)>3):
+ print """Magicpoint to KPresenter converter, (c) Lukas Tinkl <lukas@kde.org>, 2002
+ Usage: mgp2kpr infile.mgp [outfile.kpr]
+ If you give only one parameter, it will output to stdout."""
+ else:
+ importer=MgpImporter()
+ importer.convert(sys.argv[1], sys.argv[2:])
diff --git a/filters/kpresenter/mng/Makefile.am b/filters/kpresenter/mng/Makefile.am
new file mode 100644
index 00000000..92cc0f3d
--- /dev/null
+++ b/filters/kpresenter/mng/Makefile.am
@@ -0,0 +1,24 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ -I$(top_srcdir)/filters/libdialogfilter \
+ -I$(top_srcdir)/filters/kpresenter/libimageexport \
+ $(all_includes)
+
+####### Files
+
+kde_module_LTLIBRARIES = libkpresentermngexport.la
+
+libkpresentermngexport_la_SOURCES = mngexport.cpp
+libkpresentermngexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined
+libkpresentermngexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la ../../../filters/libdialogfilter/libdialogfilter.la ../libimageexport/libkpresenterimageexport.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ mngexport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_mng_export.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/mng/kpresenter_mng_export.desktop b/filters/kpresenter/mng/kpresenter_mng_export.desktop
new file mode 100644
index 00000000..ebb619b6
--- /dev/null
+++ b/filters/kpresenter/mng/kpresenter_mng_export.desktop
@@ -0,0 +1,52 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter MNG Export Filter
+Name[ar]=مرشح تصدير MNG لدى KPresenter
+Name[bg]=Филтър за експортиране от Kpresenter в MNG
+Name[br]=Sil ezporzh MNG evit KPresenter
+Name[ca]=Filtre d'exportació MNG per a KPresenter
+Name[da]=KPræsenter MNG-eksportfilter
+Name[de]=KPresenter MNG-Exportfilter
+Name[el]=Φίλτρο εξαγωγής MNG του KPresenter
+Name[eo]=KPresenter MNG-eksportfiltrilo
+Name[es]=Filtro de exportación a MNG para KPresenter
+Name[et]=KPresenteri MNG ekspordifilter
+Name[fa]=پالایۀ صادرات KPresenter MNG
+Name[fi]=KPresenter MNG -vientisuodin
+Name[fr]=Filtre d'exportation MNG de KPresenter
+Name[fy]=MNG-Eksportfilter foar KPresenter
+Name[ga]=Scagaire Easpórtála MNG KPresenter
+Name[gl]=Filtro de Exportación de MNG para KPresenter
+Name[he]=KPresenter MNG מסנן יצוא
+Name[hr]=KPresenter MNG filtar izvoza
+Name[hu]=KPresenter MNG exportszűrő
+Name[is]=KPresenter MNG útflutningssía
+Name[it]=Filtro di esportazione MNG per KPresenter
+Name[ja]=KPresenter MNG エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ MNG សម្រាប់ KPresenter
+Name[lt]=KPresenter MNG eksportavimo filtras
+Name[lv]=KPresenter MNG eksporta filtrs
+Name[nb]=MNG-eksportfilter for KPresenter
+Name[nds]=MNG-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता एमएनजी निर्यात फिल्टर
+Name[nl]=MNG-exportfilter voor KPresenter
+Name[pl]=Filtr eksportu do formatu MNG z KPresenter
+Name[pt]=Filtro de Exportação de MNG para o KPresenter
+Name[pt_BR]=Filtro de Exportação de MNG para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в MNG
+Name[se]=KPresenter MNG-olggosfievrridansilli
+Name[sk]=Exportný filter KPresenter MNG
+Name[sl]=Izvozni filter MNG za KPresenter
+Name[sr]=KChart-ов филтер за извоз у MNG
+Name[sr@Latn]=KChart-ov filter za izvoz u MNG
+Name[sv]=Kpresenter MNG-exportfilter
+Name[uk]=Фільтр експорту MNG для KPresenter
+Name[uz]=KPresenter MNG eksport filteri
+Name[uz@cyrillic]=KPresenter MNG экспорт филтери
+Name[zh_CN]=KPresenter MNG 导出过滤器
+Name[zh_TW]=KPresenter MNG 匯出過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Export=video/x-mng
+X-KDE-Weight=1
+X-KDE-Library=libkpresentermngexport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/mng/mngexport.cpp b/filters/kpresenter/mng/mngexport.cpp
new file mode 100644
index 00000000..f56f4c77
--- /dev/null
+++ b/filters/kpresenter/mng/mngexport.cpp
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 <qpixmap.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+#include <kgenericfactory.h>
+#include <KoDocument.h>
+
+#include "mngexport.h"
+#include "exportsizedia.h"
+
+typedef KGenericFactory<MngExport, KoFilter> mngExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libkpresentermngexport, mngExportFactory( "mngexport" ) )
+
+MngExport::MngExport(KoFilter *fil, const char *name, const QStringList&lst)
+ : ImageExport(fil,name,lst)
+{
+}
+
+MngExport::~MngExport()
+{
+}
+
+bool MngExport::extraImageAttribute()
+{
+ bool ret = false;
+ ExportSizeDia *exportDialog = new ExportSizeDia( width, height,
+ 0, "exportdialog");
+ if (exportDialog->exec()) {
+ width = exportDialog->width();
+ height = exportDialog->height();
+ ret = true;
+ kdDebug() << "MNG Export: size = [" << width << "," << height << "]" << endl;
+ }
+ delete exportDialog;
+ return ret;
+}
+
+
+bool MngExport::saveImage( QString fileName)
+{
+ bool ret = pixmap.save( fileName, "MNG" );
+ // Save the image.
+ if ( !ret ) {
+ KMessageBox::error( 0, i18n( "Failed to write file." ),
+ i18n( "MNG Export Error" ) );
+ }
+ return ret;
+}
+
+const char * MngExport::exportFormat()
+{
+ return "video/x-mng";
+}
+
+#include "mngexport.moc"
+
diff --git a/filters/kpresenter/mng/mngexport.h b/filters/kpresenter/mng/mngexport.h
new file mode 100644
index 00000000..c479b1e0
--- /dev/null
+++ b/filters/kpresenter/mng/mngexport.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 __XPMEXPORT_H__
+#define __XPMEXPORT_H__
+
+#include "imageexport.h"
+
+class MngExport : public ImageExport
+{
+ Q_OBJECT
+
+public:
+ MngExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~MngExport();
+ virtual bool saveImage( QString fileName);
+ virtual bool extraImageAttribute();
+ virtual const char * exportFormat();
+};
+
+#endif // __XPMEXPORT_H__
+
diff --git a/filters/kpresenter/ooimpress/Makefile.am b/filters/kpresenter/ooimpress/Makefile.am
new file mode 100644
index 00000000..b69dc04c
--- /dev/null
+++ b/filters/kpresenter/ooimpress/Makefile.am
@@ -0,0 +1,21 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir)/../../liboofilter $(KOFFICE_INCLUDES) $(all_includes)
+
+####### Files
+kde_module_LTLIBRARIES = libooimpressimport.la libooimpressexport.la
+
+
+libooimpressimport_la_SOURCES = ooimpressimport.cc
+libooimpressimport_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
+libooimpressimport_la_LIBADD = ../../liboofilter/liboofilter.la $(KOFFICE_LIBS)
+
+libooimpressexport_la_SOURCES = ooimpressexport.cc stylefactory.cc
+libooimpressexport_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
+libooimpressexport_la_LIBADD = ../../liboofilter/liboofilter.la $(KOFFICE_LIBS)
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_ooimpress_import.desktop kpresenter_ooimpress_export.desktop
+
+servicedir = $(kde_servicesdir)
diff --git a/filters/kpresenter/ooimpress/kpresenter_ooimpress_export.desktop b/filters/kpresenter/ooimpress/kpresenter_ooimpress_export.desktop
new file mode 100644
index 00000000..d645efbf
--- /dev/null
+++ b/filters/kpresenter/ooimpress/kpresenter_ooimpress_export.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+Type=Service
+Name=OpenOffice.org Impress Export Filter for KPresenter
+Name[ar]=مِرْشَح استيراد OpenOffice.org Impress لدى KPresenter
+Name[bg]=Филтър за експортиране от OpenOffice.org Impress в KPresenter
+Name[br]=Sil ezporzh OpenOffice.org Impress evit KPresenter
+Name[ca]=Filtre d'exportació OpenOffice.org Impress per a KPresenter
+Name[cs]=OpenOffice.org Impress exportní filtr pro KPresenter
+Name[cy]=Hidlen Allforio Impress OpenOffice.org ar gyfer KPresenter
+Name[da]=OpenOffice.org Impress eksport-filter for KPresenter
+Name[de]=KPresenter OpenOffice.org-Impress-Exportfilter
+Name[el]=Φίλτρο εξαγωγής OpenOffice.org Impress για το KPresenter
+Name[es]=Filtro de importación de OpenOffice.org Impress para KPresenter
+Name[et]=KPresenteri OpenOffice.org Impress'i ekspordifilter
+Name[eu]=KPresenter-en OpenOffice.org Impress esportaziorako iragazkia
+Name[fa]=پالایۀ صادرات OpenOffice.org Impress برای KPresenter
+Name[fi]=OpenOffice.org Impress -vientisuodin KPresenterille
+Name[fr]=Filtre d'exportation OpenOffice.org Impress pour KPresenter
+Name[fy]=OpenOffice.org Impress-Eksportfilter foar KPresenter
+Name[gl]=Filtro de Exportación de OpenOffice.org Impress para KPresenter
+Name[he]=מסנן ייצוא מ־KPresenter ל־OpenOffice.org Impress
+Name[hi]=के-प्रेज़ेन्टर के लिए ओपन-ऑफ़िस.ऑर्ग इम्प्रेस निर्यात छननी
+Name[hr]=OpenOffice.org Impress filtar izvoza za KPresenter
+Name[hu]=OpenOffice.org Impress exportszűrő a KPresenterhez
+Name[is]=OpenOffice.org Impress útflutningssía fyrir KPresenter
+Name[it]=Filtro di esportazione OpenOffice.org Impress per KPresenter
+Name[ja]=KPresenter OpenOffice.org Impress エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ OpenOffice.org Impress សម្រាប់ KPresenter
+Name[lt]=OpenOffice.org Impress eksportavimo filtras skirtas KPresenter
+Name[lv]=OpenOffice.org Impress eksporta filtrs priekš KPresenter
+Name[ms]=Penapis Eksport OpenOffice.org Impress bagi KPresenter
+Name[nb]=OpenOffice.org Impress-eksportfilter for KPresenter
+Name[nds]="OpenOffice.org Impress"-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ताका लागि OpenOffice.org इम्प्रेस निर्यात फिल्टर
+Name[nl]=OpenOffice.org Impress-exportfilter voor KPresenter
+Name[nn]=OpenOffice.org Impress-eksportfilter for KPresenter
+Name[pl]=Filtr eksportu do OpenOffice.org Impress dla KPresenter
+Name[pt]=Filtro de Exportação de OpenOffice.org Impress para o KPresenter
+Name[pt_BR]=Filtro de Exportação OpenOffice.org Impress para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в OpenOffice.org Impress
+Name[se]=KPresenter:a OpenOffice.org Impress-olggosfievrridansilli
+Name[sk]=Filter pre import OpenOffice.org Impress pre KPresenter
+Name[sl]=Izvozni filter OpenOffice.org Impress za KPresenter
+Name[sr]=KPresenter-ов филтер за извоз у OpenOffice Impress
+Name[sr@Latn]=KPresenter-ov filter za izvoz u OpenOffice Impress
+Name[sv]=OpenOffice.org Impress-exportfilter för Kpresenter
+Name[ta]=openoffice.org Impress ஏற்றுமதி வடிகட்டி kpresenter
+Name[tg]=Филтри Содироти OpenOffice.org Impress барои KPresenter
+Name[tr]=KPresenter için OpenOffice.org Impress Alma Filtresi
+Name[uk]=Фільтр експорту презентацій OpenOffice.org для KPresenter
+Name[uz]=KPresenter uchun OpenOffice.org Impress eksport filteri
+Name[uz@cyrillic]=KPresenter учун OpenOffice.org Impress экспорт филтери
+Name[wa]=Passete OpenOffice.org Impress di rexhowe po KPresenter
+Name[zh_CN]=KPresenter 的 OpenOffice.org Impress 导出过滤器
+Name[zh_TW]=KPresenter 的 OpenOffice.org Impress 匯出過濾程式
+X-KDE-Export=application/vnd.sun.xml.impress
+X-KDE-Import=application/x-kpresenter
+X-KDE-Weight=1
+X-KDE-Library=libooimpressexport
+X-KDE-LibraryMajor=1
+X-KDE-LibraryMinor=0
+X-KDE-LibraryDependencies=
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/ooimpress/kpresenter_ooimpress_import.desktop b/filters/kpresenter/ooimpress/kpresenter_ooimpress_import.desktop
new file mode 100644
index 00000000..b5b5a79f
--- /dev/null
+++ b/filters/kpresenter/ooimpress/kpresenter_ooimpress_import.desktop
@@ -0,0 +1,64 @@
+[Desktop Entry]
+Type=Service
+Name=OpenOffice.org Impress Import Filter for KPresenter
+Name[ar]=مِرْشَح استيراد OpenOffice.org Impress لدى KPresenter
+Name[bg]=Филтър за импортиране от OpenOffice.org Impress в KPresenter
+Name[br]=Sil enporzh OpenOffice.org Impress evit KPresenter
+Name[ca]=Filtre d'importació OpenOffice.org Impress per a KPresenter
+Name[cs]=OpenOffice.org Impress importní filtr pro KPresenter
+Name[cy]=Hidlen Fewnforio OpenOffice.org Impress i KPresenter
+Name[da]=OpenOffice.org Impress import-filter for KPresenter
+Name[de]=KPresenter OpenOffice.org-Impress-Importfilter
+Name[el]=Φίλτρο εισαγωγής OpenOffice.org Impress για το KPresenter
+Name[es]=Filtro de importación de Impress para KPresenter
+Name[et]=KPresenteri OpenOffice.org Impress'i impordifilter
+Name[eu]=KPresenter-en OpenOffice.org Impress inportaziorako iragazkia
+Name[fa]=پالایۀ صادرات OpenOffice.org Impress برای KPresenter
+Name[fi]=OpenOffice.org Impress -tuontisuodin KPresenterille
+Name[fr]=Filtre d'importation OpenOffice.org Impress pour KPresenter
+Name[fy]=OpenOffice.org Impress-Ymportfilter foar KPresenter
+Name[gl]=Filtro de Importación de OpenOffice.org Impress para KPresenter
+Name[he]=מסנן ייבוא מ־OpenOffice.org Impress ל־KPresenter
+Name[hi]=के-प्रेज़ेन्टर के लिए ओपन-ऑफ़िस.ऑर्ग इम्प्रेस आयात छननी
+Name[hr]=OpenOffice.org Impress filtar uvoza za KPresenter
+Name[hu]=OpenOffice Impress importszűrő a KPresenterhez
+Name[is]=OpenOffice.org Impress innflutningssía fyrir KPresenter
+Name[it]=Filtro di importazione OpenOffice.org Impress per KPresenter
+Name[ja]=KPresenter OpenOffice.org Impress インポートフィルタ
+Name[km]=តម្រង​នាំចូល OpenOffice.org Impress សម្រាប់ KPresenter
+Name[lo]= ຕົວຕອງການນຳເຂົ້າ CSV ຂອງກະດາດຄຳນວນ K
+Name[lt]=OpenOffice.org Impress importavimo filtras skirtas KPresenter
+Name[lv]=OpenOffice.org Impress importa filtrs priekš KPresenter
+Name[ms]=Penapis Import OpenOffice.org Impress bagi KPresenter
+Name[nb]=OpenOffice.org Impress-importfilter for KPresenter
+Name[nds]="OpenOffice.org Impress"-Importfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ताका लागि OpenOffice.org इम्प्रेस निर्यात फिल्टर
+Name[nl]=OpenOffice.org Impress-importfilter voor KPresenter
+Name[nn]=OpenOffice.org Impress-importfilter for KPresenter
+Name[pl]=Filtr importu z OpenOffice.org Impress dla KSpread
+Name[pt]=Filtro de Importação de OpenOffice.org Impress para o KPresenter
+Name[pt_BR]=Filtro de Importação OpenOffice.org Impress para o KPresenter
+Name[ru]=Фильтр импорта презентаций OpenOffice.org Impress в KPresenter
+Name[se]=KPresenter:a OpenOffice.org Impress-sisafievrridansilli
+Name[sk]=Filter pre import OpenOffice.org Impress pre KPresenter
+Name[sl]=Uvozni filter OpenOffice.org Impress za KPresenter
+Name[sr]=KPresenter-ов филтер за увоз из OpenOffice Impress-а
+Name[sr@Latn]=KPresenter-ov filter za uvoz iz OpenOffice Impress-a
+Name[sv]=OpenOffice Impress-importfilter för Kpresenter
+Name[ta]=openoffice.org impress இறக்குமதி வடிகட்டி for kpresenter
+Name[tg]=Филтри Воридоти OpenOffice.org Impress барои KPresenter
+Name[tr]=KPresenter için OpenOffice.org Impress Alma Filtresi
+Name[uk]=Фільтр імпорту презентацій OpenOffice.org для KPresenter
+Name[uz]=KPresenter uchun OpenOffice.org Impress import filteri
+Name[uz@cyrillic]=KPresenter учун OpenOffice.org Impress импорт филтери
+Name[xh]=OpenOffice.org Iphawula Isihluzi Sorhwebo se KPresenter
+Name[zh_CN]=KPresenter 的 OpenOffice.org Impress 导入过滤器
+Name[zh_TW]=KPresenter 的 OpenOffice.org Impress 匯入過濾程式
+X-KDE-Export=application/x-kpresenter
+X-KDE-Import=application/vnd.sun.xml.impress,application/vnd.sun.xml.impress.template
+X-KDE-Weight=1
+X-KDE-Library=libooimpressimport
+X-KDE-LibraryMajor=1
+X-KDE-LibraryMinor=0
+X-KDE-LibraryDependencies=
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/ooimpress/ooimpressexport.cc b/filters/kpresenter/ooimpress/ooimpressexport.cc
new file mode 100644
index 00000000..27d0781d
--- /dev/null
+++ b/filters/kpresenter/ooimpress/ooimpressexport.cc
@@ -0,0 +1,1160 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Percy Leonhardt
+
+ 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 "ooimpressexport.h"
+
+#include <qdom.h>
+#include <qfile.h>
+#include <qdatetime.h>
+
+#include <kdebug.h>
+#include <kgenericfactory.h>
+#include <KoFilterChain.h>
+#include <KoGlobal.h>
+#include <KoUnit.h>
+
+typedef KGenericFactory<OoImpressExport, KoFilter> OoImpressExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libooimpressexport, OoImpressExportFactory( "kofficefilters" ) )
+
+
+OoImpressExport::OoImpressExport( KoFilter *, const char *, const QStringList & )
+ : KoFilter()
+ , m_currentPage( 0 )
+ , m_objectIndex( 0 )
+ , m_pageHeight( 0 )
+ , m_activePage( 0 )
+ , m_gridX( -1.0 )
+ , m_gridY( -1.0 )
+ , m_snapToGrid( false )
+ , m_pictureIndex( 0 )
+ , m_storeinp( 0L )
+ , m_storeout( 0L )
+{
+}
+
+OoImpressExport::~OoImpressExport()
+{
+ delete m_storeout;
+ delete m_storeinp;
+}
+
+KoFilter::ConversionStatus OoImpressExport::convert( const QCString & from,
+ const QCString & to )
+{
+ kdDebug(30518) << "Entering Ooimpress Export filter: " << from << " - " << to << endl;
+
+ if ( ( to != "application/vnd.sun.xml.impress") || (from != "application/x-kpresenter" ) )
+ {
+ kdWarning(30518) << "Invalid mimetypes " << to << " " << from << endl;
+ return KoFilter::NotImplemented;
+ }
+
+ // read in the KPresenter file
+ KoFilter::ConversionStatus preStatus = openFile();
+
+ if ( preStatus != KoFilter::OK )
+ return preStatus;
+
+ QDomImplementation impl;
+ QDomDocument meta( impl.createDocumentType( "office:document-meta",
+ "-//OpenOffice.org//DTD OfficeDocument 1.0//EN",
+ "office.dtd" ) );
+
+ createDocumentMeta( meta );
+
+ // store document meta
+ m_storeout = KoStore::createStore( m_chain->outputFile(), KoStore::Write, "", KoStore::Zip );
+
+ if ( !m_storeout )
+ {
+ kdWarning(30518) << "Couldn't open the requested file." << endl;
+ return KoFilter::FileNotFound;
+ }
+
+ if ( !m_storeout->open( "meta.xml" ) )
+ {
+ kdWarning(30518) << "Couldn't open the file 'meta.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+
+ QCString metaString = meta.toCString();
+ //kdDebug(30518) << "meta :" << metaString << endl;
+ m_storeout->write( metaString , metaString.length() );
+ m_storeout->close();
+
+ QDomDocument content( impl.createDocumentType( "office:document-content",
+ "-//OpenOffice.org//DTD OfficeDocument 1.0//EN",
+ "office.dtd" ) );
+
+ createDocumentContent( content );
+
+ // add the automatic styles
+ m_styleFactory.addAutomaticStyles( content, m_styles );
+
+ // store document content
+ if ( !m_storeout->open( "content.xml" ) )
+ {
+ kdWarning(30518) << "Couldn't open the file 'content.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+
+ QCString contentString = content.toCString();
+ //kdDebug(30518) << "content :" << contentString << endl;
+ m_storeout->write( contentString , contentString.length() );
+ m_storeout->close();
+
+ QDomDocument settings( impl.createDocumentType( "office:document-content",
+ "-//OpenOffice.org//DTD OfficeDocument 1.0//EN",
+ "office.dtd" ) );
+
+ createDocumentSettings( settings );
+
+ // store document content
+ if ( !m_storeout->open( "settings.xml" ) )
+ {
+ kdWarning(30518) << "Couldn't open the file 'settings.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+
+ QCString settingsString = settings.toCString();
+ //kdDebug(30518) << "content :" << settingsString << endl;
+ m_storeout->write( settingsString , settingsString.length() );
+ m_storeout->close();
+
+
+ QDomDocument styles( impl.createDocumentType( "office:document-styles",
+ "-//OpenOffice.org//DTD OfficeDocument 1.0//EN",
+ "office.dtd" ) );
+
+ createDocumentStyles( styles );
+
+ // store document styles
+ if ( !m_storeout->open( "styles.xml" ) )
+ {
+ kdWarning(30518) << "Couldn't open the file 'styles.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+
+ QCString stylesString = styles.toCString();
+ //kdDebug(30518) << "styles :" << stylesString << endl;
+ m_storeout->write( stylesString , stylesString.length() );
+ m_storeout->close();
+
+ QDomDocument manifest( impl.createDocumentType( "manifest:manifest",
+ "-//OpenOffice.org//DTD Manifest 1.0//EN",
+ "Manifest.dtd" ) );
+
+ createDocumentManifest( manifest );
+
+ // store document manifest
+ m_storeout->enterDirectory( "META-INF" );
+ if ( !m_storeout->open( "manifest.xml" ) )
+ {
+ kdWarning(30518) << "Couldn't open the file 'META-INF/manifest.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+
+ QCString manifestString = manifest.toCString();
+ //kdDebug(30518) << "manifest :" << manifestString << endl;
+ m_storeout->write( manifestString , manifestString.length() );
+ m_storeout->close();
+
+ return KoFilter::OK;
+}
+
+KoFilter::ConversionStatus OoImpressExport::openFile()
+{
+ m_storeinp = KoStore::createStore( m_chain->inputFile(), KoStore::Read );
+
+ if ( !m_storeinp )
+ {
+ kdWarning(30518) << "Couldn't open the requested file." << endl;
+ return KoFilter::FileNotFound;
+ }
+
+ if ( !m_storeinp->open( "maindoc.xml" ) )
+ {
+ kdWarning(30518) << "This file doesn't seem to be a valid KPresenter file" << endl;
+ return KoFilter::WrongFormat;
+ }
+
+ m_maindoc.setContent( m_storeinp->device() );
+ m_storeinp->close();
+
+ if ( m_storeinp->open( "documentinfo.xml" ) )
+ {
+ m_documentinfo.setContent( m_storeinp->device() );
+ m_storeinp->close();
+ }
+ else
+ kdWarning(30518) << "Documentinfo do not exist!" << endl;
+
+ emit sigProgress( 10 );
+
+ return KoFilter::OK;
+}
+
+void OoImpressExport::createDocumentMeta( QDomDocument & docmeta )
+{
+ docmeta.appendChild( docmeta.createProcessingInstruction( "xml","version=\"1.0\" encoding=\"UTF-8\"" ) );
+
+ QDomElement content = docmeta.createElement( "office:document-meta" );
+ content.setAttribute( "xmlns:office", "http://openoffice.org/2000/office" );
+ content.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
+ content.setAttribute( "xmlns:dc", "http://purl.org/dc/elements/1.1/" );
+ content.setAttribute( "xmlns:meta", "http://openoffice.org/2000/meta" );
+ content.setAttribute( "office:version", "1.0" );
+
+ QDomNode meta = docmeta.createElement( "office:meta" );
+
+ QDomElement generator = docmeta.createElement( "meta:generator" );
+ generator.appendChild( docmeta.createTextNode( "KPresenter 1.5" ) );
+ meta.appendChild( generator );
+
+ QDomNode i = m_documentinfo.namedItem( "document-info" );
+ if ( !i.isNull() )
+ {
+ QDomNode n = i.namedItem( "author" ).namedItem( "full-name" );
+ if ( !n.isNull() )
+ {
+ QDomElement fullName = n.toElement();
+ QDomElement creator = docmeta.createElement( "meta:initial-creator" );
+ creator.appendChild( docmeta.createTextNode( fullName.text() ) );
+ meta.appendChild( creator );
+
+ creator = docmeta.createElement( "meta:creator" );
+ creator.appendChild( docmeta.createTextNode( fullName.text() ) );
+ meta.appendChild( creator );
+ }
+ n = i.namedItem( "about" ).namedItem( "abstract" );
+ if ( !n.isNull() )
+ {
+ QDomElement user = docmeta.createElement( "dc:description" );
+ user.appendChild( n.firstChild() );
+ meta.appendChild( user );
+ }
+ n = i.namedItem( "about" ).namedItem( "keyword" );
+ if ( !n.isNull() )
+ {
+ QDomElement text = n.toElement();
+ QDomElement key = docmeta.createElement( "meta:keywords" );
+ QDomElement keyword = docmeta.createElement( "meta:keyword" );
+ key.appendChild( keyword );
+ keyword.appendChild( docmeta.createTextNode( text.text() ) );
+ meta.appendChild( key );
+ }
+ n = i.namedItem( "about" ).namedItem( "subject" );
+ if ( !n.isNull() )
+ {
+ QDomElement text = n.toElement();
+ QDomElement subjet = docmeta.createElement( "dc:subject" );
+ subjet.appendChild( docmeta.createTextNode( text.text() ) );
+ meta.appendChild( subjet );
+ }
+ n = i.namedItem( "about" ).namedItem( "title" );
+ if ( !n.isNull() )
+ {
+ QDomElement text = n.toElement();
+ QDomElement title = docmeta.createElement( "dc:title" );
+ title.appendChild( docmeta.createTextNode( text.text() ) );
+ meta.appendChild( title );
+ }
+ }
+
+// QDomElement statistic = docmeta.createElement( "meta:document-statistic" );
+// statistic.setAttribute( "meta:object-count", 0 );
+// meta.appendChild( data );
+
+ content.appendChild( meta );
+ docmeta.appendChild( content );
+}
+
+void OoImpressExport::createDocumentStyles( QDomDocument & docstyles )
+{
+ docstyles.appendChild( docstyles.createProcessingInstruction( "xml","version=\"1.0\" encoding=\"UTF-8\"" ) );
+
+ QDomElement content = docstyles.createElement( "office:document-content" );
+ content.setAttribute( "xmlns:office", "http://openoffice.org/2000/office" );
+ content.setAttribute( "xmlns:style", "http://openoffice.org/2000/style" );
+ content.setAttribute( "xmlns:text", "http://openoffice.org/2000/text" );
+ content.setAttribute( "xmlns:table", "http://openoffice.org/2000/table" );
+ content.setAttribute( "xmlns:draw", "http://openoffice.org/2000/drawing" );
+ content.setAttribute( "xmlns:fo", "http://www.w3.org/1999/XSL/Format" );
+ content.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
+ content.setAttribute( "xmlns:number", "http://openoffice.org/2000/datastyle" );
+ content.setAttribute( "xmlns:svg", "http://www.w3.org/2000/svg" );
+ content.setAttribute( "xmlns:chart", "http://openoffice.org/2000/chart" );
+ content.setAttribute( "xmlns:dr3d", "http://openoffice.org/2000/dr3d" );
+ content.setAttribute( "xmlns:math", "http://www.w3.org/1998/Math/MathML" );
+ content.setAttribute( "xmlns:form", "http://openoffice.org/2000/form" );
+ content.setAttribute( "xmlns:script", "http://openoffice.org/2000/script" );
+ content.setAttribute( "office:version", "1.0" );
+
+ // order important here!
+ QDomElement styles = docstyles.createElement( "office:styles" );
+ m_styleFactory.addOfficeStyles( docstyles, styles );
+ content.appendChild( styles );
+
+ QDomElement automatic = docstyles.createElement( "office:automatic-styles" );
+ m_styleFactory.addOfficeAutomatic( docstyles, automatic );
+ content.appendChild( automatic );
+
+ QDomElement master = docstyles.createElement( "office:master-styles" );
+ m_styleFactory.addOfficeMaster( docstyles, master );
+ content.appendChild( master );
+
+ docstyles.appendChild( content );
+}
+
+void OoImpressExport::createDocumentSettings( QDomDocument & docsetting )
+{
+ docsetting.appendChild( docsetting.createProcessingInstruction( "xml","version=\"1.0\" encoding=\"UTF-8\"" ) );
+
+ QDomElement setting = docsetting.createElement( "office:document-settings" );
+ setting.setAttribute( "xmlns:office", "http://openoffice.org/2000/office");
+ setting.setAttribute( "xmlns:config", "http://openoffice.org/2001/config" );
+ setting.setAttribute( "office:class", "presentation" );
+ setting.setAttribute( "office:version", "1.0" );
+
+ QDomElement begin = docsetting.createElement( "office:settings" );
+
+ QDomElement configItem = docsetting.createElement("config:config-item-set" );
+ configItem.setAttribute( "config:name", "view-settings" );
+
+ QDomElement mapIndexed = docsetting.createElement( "config:config-item-map-indexed" );
+ mapIndexed.setAttribute("config:name", "Views" );
+ configItem.appendChild( mapIndexed );
+
+ //<config:config-item-map-indexed config:name="Views">
+
+ QDomElement mapItem = docsetting.createElement("config:config-item-map-entry" );
+
+ QDomElement attribute = docsetting.createElement("config:config-item" );
+ attribute.setAttribute( "config:name", "SnapLinesDrawing" );
+ attribute.setAttribute( "config:type", "string" );
+ attribute.appendChild( docsetting.createTextNode( m_helpLine ) );
+ mapItem.appendChild( attribute );
+ //<config:config-item config:name="SnapLinesDrawing" config:type="string">H5983V700V10777H4518V27601P50000,9000P8021,2890</config:config-item>
+
+ attribute = docsetting.createElement("config:config-item" );
+ attribute.setAttribute( "config:name", "IsSnapToGrid" );
+ attribute.setAttribute( "config:type", "boolean" );
+ attribute.appendChild( docsetting.createTextNode( m_snapToGrid ? "true" : "false" ) );
+ mapItem.appendChild( attribute );
+
+ if ( m_gridX >=0 )
+ {
+ attribute = docsetting.createElement("config:config-item" );
+ attribute.setAttribute( "config:name", "GridFineWidth" );
+ attribute.setAttribute( "config:type", "int" );
+ attribute.appendChild( docsetting.createTextNode( QString::number( ( int ) ( KoUnit::toMM( ( m_gridX ) )*100 ) ) ) );
+ mapItem.appendChild( attribute );
+ }
+
+ if ( m_gridY >=0 )
+ {
+ attribute = docsetting.createElement("config:config-item" );
+ attribute.setAttribute( "config:name", "GridFineHeight" );
+ attribute.setAttribute( "config:type", "int" );
+ attribute.appendChild( docsetting.createTextNode( QString::number( ( int ) ( KoUnit::toMM( ( m_gridY ) )*100 ) ) ) );
+ mapItem.appendChild( attribute );
+ }
+
+ attribute = docsetting.createElement("config:config-item" );
+ attribute.setAttribute( "config:name", "SelectedPage" );
+ attribute.setAttribute( "config:type", "short" );
+ attribute.appendChild( docsetting.createTextNode( QString::number( m_activePage ) ) );
+ mapItem.appendChild( attribute );
+
+
+ mapIndexed.appendChild( mapItem );
+
+ begin.appendChild( configItem );
+
+ setting.appendChild( begin );
+
+
+ docsetting.appendChild( setting );
+
+}
+
+void OoImpressExport::createDocumentContent( QDomDocument & doccontent )
+{
+ doccontent.appendChild( doccontent.createProcessingInstruction( "xml","version=\"1.0\" encoding=\"UTF-8\"" ) );
+
+ QDomElement content = doccontent.createElement( "office:document-content" );
+ content.setAttribute( "xmlns:office", "http://openoffice.org/2000/office");
+ content.setAttribute( "xmlns:style", "http://openoffice.org/2000/style" );
+ content.setAttribute( "xmlns:text", "http://openoffice.org/2000/text" );
+ content.setAttribute( "xmlns:table", "http://openoffice.org/2000/table" );
+ content.setAttribute( "xmlns:draw", "http://openoffice.org/2000/drawing" );
+ content.setAttribute( "xmlns:fo", "http://www.w3.org/1999/XSL/Format" );
+ content.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
+ content.setAttribute( "xmlns:number", "http://openoffice.org/2000/datastyle" );
+ content.setAttribute( "xmlns:svg", "http://www.w3.org/2000/svg" );
+ content.setAttribute( "xmlns:chart", "http://openoffice.org/2000/chart" );
+ content.setAttribute( "xmlns:dr3d", "http://openoffice.org/2000/dr3d" );
+ content.setAttribute( "xmlns:math", "http://www.w3.org/1998/Math/MathML" );
+ content.setAttribute( "xmlns:form", "http://openoffice.org/2000/form" );
+ content.setAttribute( "xmlns:script", "http://openoffice.org/2000/script" );
+ content.setAttribute( "xmlns:presentation", "http://openoffice.org/2000/presentation" );
+ content.setAttribute( "office:class", "presentation" );
+ content.setAttribute( "office:version", "1.0" );
+
+ QDomElement script = doccontent.createElement( "office:script" );
+ content.appendChild( script );
+
+ m_styles = doccontent.createElement( "office:automatic-styles" );
+ content.appendChild( m_styles );
+
+ QDomElement body = doccontent.createElement( "office:body" );
+ exportBody( doccontent, body );
+ content.appendChild( body );
+
+ doccontent.appendChild( content );
+}
+
+void OoImpressExport::createDocumentManifest( QDomDocument & docmanifest )
+{
+ docmanifest.appendChild( docmanifest.createProcessingInstruction( "xml","version=\"1.0\" encoding=\"UTF-8\"" ) );
+
+ QDomElement manifest = docmanifest.createElement( "manifest:manifest" );
+ manifest.setAttribute( "xmlns:manifest", "http://openoffice.org/2001/manifest" );
+
+ QDomElement entry = docmanifest.createElement( "manifest:file-entry" );
+ entry.setAttribute( "manifest:media-type", "application/vnd.sun.xml.impress" );
+ entry.setAttribute( "manifest:full-path", "/" );
+ manifest.appendChild( entry );
+
+ QMap<QString, QString>::Iterator it;
+ for ( it = m_pictureLst.begin(); it != m_pictureLst.end(); ++it )
+ {
+ entry = docmanifest.createElement( "manifest:file-entry" );
+ entry.setAttribute( "manifest:media-type", it.data() );
+ entry.setAttribute( "manifest:full-path", it.key() );
+ manifest.appendChild( entry );
+ }
+
+ entry = docmanifest.createElement( "manifest:file-entry" );
+ entry.setAttribute( "manifest:media-type", "text/xml" );
+ entry.setAttribute( "manifest:full-path", "content.xml" );
+ manifest.appendChild( entry );
+
+ entry = docmanifest.createElement( "manifest:file-entry" );
+ entry.setAttribute( "manifest:media-type", "text/xml" );
+ entry.setAttribute( "manifest:full-path", "styles.xml" );
+ manifest.appendChild( entry );
+
+ entry = docmanifest.createElement( "manifest:file-entry" );
+ entry.setAttribute( "manifest:media-type", "text/xml" );
+ entry.setAttribute( "manifest:full-path", "meta.xml" );
+ manifest.appendChild( entry );
+
+ entry = docmanifest.createElement( "manifest:file-entry" );
+ entry.setAttribute( "manifest:media-type", "text/xml" );
+ entry.setAttribute( "manifest:full-path", "settings.xml" );
+ manifest.appendChild( entry );
+
+ docmanifest.appendChild( manifest );
+}
+
+QString OoImpressExport::pictureKey( QDomElement &elem )
+{
+ // Default date/time is the *nix epoch: 1970-01-01 00:00:00,000
+ int year=1970, month=1, day=1;
+ int hour=0, minute=0, second=0, msec=0; // We must initialize to zero, as not all compilers are C99-compliant
+ if ( elem.tagName() == "KEY" )
+ {
+ if( elem.hasAttribute( "year" ) )
+ year=elem.attribute( "year" ).toInt();
+ if( elem.hasAttribute( "month" ) )
+ month=elem.attribute( "month" ).toInt();
+ if( elem.hasAttribute( "day" ) )
+ day=elem.attribute( "day" ).toInt();
+ if( elem.hasAttribute( "hour" ) )
+ hour=elem.attribute( "hour" ).toInt();
+ if( elem.hasAttribute( "minute" ) )
+ minute=elem.attribute( "minute" ).toInt();
+ if( elem.hasAttribute( "second" ) )
+ second=elem.attribute( "second" ).toInt();
+ if( elem.hasAttribute( "msec" ) )
+ msec=elem.attribute( "msec" ).toInt();
+ }
+ QDateTime key;
+ key.setDate( QDate( year, month, day ) );
+ key.setTime( QTime( hour, minute, second, msec ) );
+ return key.toString();
+}
+
+void OoImpressExport::createPictureList( QDomNode &pictures )
+{
+ pictures = pictures.firstChild();
+ for( ; !pictures.isNull(); pictures = pictures.nextSibling() )
+ {
+ if ( pictures.isElement() )
+ {
+ QDomElement element = pictures.toElement();
+ if ( element.tagName() == "KEY" )
+ {
+ //kdDebug(30518)<<"element.attribute( name ) :"<<element.attribute( "name" )<<endl;
+ m_kpresenterPictureLst.insert( pictureKey( element ), element.attribute( "name" ) );
+ }
+ else
+ kdDebug(30518)<<" Tag not recognize :"<<element.tagName()<<endl;
+ }
+ }
+}
+
+void OoImpressExport::createAttribute( QDomNode &attributeValue )
+{
+ QDomElement elem = attributeValue.toElement();
+ if(elem.hasAttribute("activePage"))
+ m_activePage=elem.attribute("activePage").toInt();
+ if(elem.hasAttribute("gridx"))
+ m_gridX = elem.attribute("gridx").toDouble();
+ if(elem.hasAttribute("gridy"))
+ m_gridY = elem.attribute("gridy").toDouble();
+ if(elem.hasAttribute("snaptogrid"))
+ m_snapToGrid = (bool)elem.attribute("snaptogrid").toInt();
+}
+
+void OoImpressExport::createHelpLine( QDomNode &helpline )
+{
+ helpline = helpline.firstChild();
+ QDomElement helplines;
+ for( ; !helpline.isNull(); helpline = helpline.nextSibling() )
+ {
+ if ( helpline.isElement() )
+ {
+ helplines = helpline.toElement();
+ if ( helplines.tagName()=="Vertical" )
+ {
+ int tmpX = ( int ) ( KoUnit::toMM( helplines.attribute("value").toDouble() )*100 );
+ m_helpLine+="V"+QString::number( tmpX );
+ }
+ else if ( helplines.tagName()=="Horizontal" )
+ {
+ int tmpY = ( int ) ( KoUnit::toMM( helplines.attribute("value").toDouble() )*100 );
+ m_helpLine+="H"+QString::number( tmpY );
+ }
+ else if ( helplines.tagName()=="HelpPoint" )
+ {
+ QString str( "P%1,%2" );
+ int tmpX = ( int ) ( KoUnit::toMM( helplines.attribute("posX").toDouble() )*100 );
+ int tmpY = ( int ) ( KoUnit::toMM( helplines.attribute("posY").toDouble() )*100 );
+ m_helpLine+=str.arg( QString::number( tmpX ) ).arg( QString::number( tmpY ) );
+ }
+ }
+ }
+ //kdDebug(30518)<<"m_helpLine :"<<m_helpLine<<endl;
+}
+
+
+void OoImpressExport::exportBody( QDomDocument & doccontent, QDomElement & body )
+{
+ QDomNode doc = m_maindoc.namedItem( "DOC" );
+ QDomNode paper = doc.namedItem( "PAPER" );
+ QDomNode background = doc.namedItem( "BACKGROUND" );
+ QDomNode header = doc.namedItem( "HEADER" );
+ QDomNode footer = doc.namedItem( "FOOTER" );
+ QDomNode titles = doc.namedItem( "PAGETITLES" );
+ QDomNode notes = doc.namedItem( "PAGENOTES" );
+ QDomNode objects = doc.namedItem( "OBJECTS" );
+ QDomNode pictures = doc.namedItem( "PICTURES" );
+ QDomNode sounds = doc.namedItem( "SOUNDS" );
+ QDomNode helpline = doc.namedItem( "HELPLINES" );
+ QDomNode attributeValue = doc.namedItem( "ATTRIBUTES" );
+ QDomNode infiniLoop = doc.namedItem( "INFINITLOOP" );
+ QDomNode manualSwitch = doc.namedItem( "MANUALSWITCH" );
+ QDomNode customSlideShow = doc.namedItem( "CUSTOMSLIDESHOWCONFIG" );
+ QDomNode customSlideShowDefault = doc.namedItem( "DEFAULTCUSTOMSLIDESHOWNAME" );
+
+ QDomNode bgpage = background.firstChild();
+
+ createPictureList( pictures );
+
+ createHelpLine( helpline );
+
+ createAttribute( attributeValue );
+
+ // store the paper settings
+ QDomElement p = paper.toElement();
+ m_masterPageStyle = m_styleFactory.createPageMasterStyle( p );
+ m_pageHeight = p.attribute( "ptHeight" ).toFloat();
+
+ m_currentPage = 1;
+
+ // parse all pages
+ QDomNode note = notes.firstChild();
+ for ( QDomNode title = titles.firstChild(); !title.isNull() && !note.isNull();
+ title = title.nextSibling(), note = note.nextSibling() )
+ {
+ // create the page style and ignore the fact that there may
+ // be less backgrounds than pages
+ QDomElement bg = bgpage.toElement();
+ QString ps = m_styleFactory.createPageStyle( bg );
+ bgpage = bgpage.nextSibling();
+
+ QDomElement t = title.toElement();
+ QDomElement drawPage = doccontent.createElement( "draw:page" );
+ drawPage.setAttribute( "draw:name", t.attribute( "title" ) );
+ drawPage.setAttribute( "draw:style-name", ps );
+ drawPage.setAttribute( "draw:id", m_currentPage );
+ drawPage.setAttribute( "draw:master-page-name", m_masterPageStyle );
+
+ appendObjects( doccontent, objects, drawPage );
+
+ QDomElement noteElement = note.toElement();
+ appendNote( doccontent, noteElement, drawPage );
+ body.appendChild( drawPage );
+ m_currentPage++;
+ }
+ int infiniLoopValue = -1;
+ int manualSwitchValue = -1;
+ if ( !infiniLoop.isNull() && infiniLoop.toElement().hasAttribute( "value" ))
+ {
+ bool ok;
+ int val = infiniLoop.toElement().attribute( "value" ).toInt( &ok );
+ if ( ok )
+ infiniLoopValue = val;
+ }
+ if ( !manualSwitch.isNull() && manualSwitch.toElement().hasAttribute( "value" ))
+ {
+ bool ok;
+ int val = manualSwitch.toElement().attribute( "value" ).toInt( &ok );
+ if ( ok )
+ manualSwitchValue = val;
+ }
+ if ( infiniLoopValue != -1 || manualSwitchValue != -1 || !customSlideShowDefault.isNull())
+ {
+ QDomElement settings = doccontent.createElement( "presentation:settings" );
+ if ( infiniLoopValue !=-1 )
+ settings.setAttribute( "presentation:force-manual", ( manualSwitchValue==1 ) ? "true" : "false" );
+ if ( manualSwitchValue != -1 )
+ settings.setAttribute( "presentation:endless", ( infiniLoopValue==1 ) ? "true": "false" );
+ if ( !customSlideShowDefault.isNull() )
+ settings.setAttribute( "presentation:show", customSlideShowDefault.toElement().attribute( "name" ) );
+
+ if ( !customSlideShow.isNull() )
+ {
+ for ( QDomNode customPage = customSlideShow.firstChild(); !customPage.isNull();
+ customPage = customPage.nextSibling() )
+ {
+ QDomElement show = customPage.toElement();
+ if ( !show.isNull() && show.tagName()=="CUSTOMSLIDESHOW" )
+ {
+ QDomElement showElement = doccontent.createElement( "presentation:show" );
+ showElement.setAttribute( "presentation:name",show.attribute( "name" ) );
+ showElement.setAttribute( "presentation:pages",show.attribute( "pages" ) );
+ settings.appendChild( showElement );
+ }
+ }
+ }
+ body.appendChild( settings );
+ }
+}
+
+
+void OoImpressExport::appendObjects(QDomDocument & doccontent, QDomNode &objects, QDomElement &drawPage)
+{
+ // I am not sure if objects are always stored sorted so I parse all
+ // of them to find the ones belonging to a certain page.
+ for ( QDomNode object = objects.firstChild(); !object.isNull();
+ object = object.nextSibling() )
+ {
+ QDomElement o = object.toElement();
+
+ QDomElement orig = o.namedItem( "ORIG" ).toElement();
+ float y = orig.attribute( "y" ).toFloat();
+
+ if ( y < m_pageHeight * ( m_currentPage - 1 ) ||
+ y >= m_pageHeight * m_currentPage )
+ continue; // object not on current page
+
+ switch( o.attribute( "type" ).toInt() )
+ {
+ case 0: // image
+ appendPicture( doccontent, o, drawPage );
+ break;
+ case 1: // line
+ appendLine( doccontent, o, drawPage );
+ break;
+ case 2: // rectangle
+ appendRectangle( doccontent, o, drawPage );
+ break;
+ case 3: // circle, ellipse
+ appendEllipse( doccontent, o, drawPage );
+ break;
+ case 4: // textbox
+ appendTextbox( doccontent, o, drawPage );
+ break;
+ case 5:
+ kdDebug(30518)<<" autoform not implemented\n";
+ break;
+ case 6:
+ kdDebug(30518)<<" clipart not implemented\n";
+ break;
+ case 8: // pie, chord, arc
+ appendEllipse( doccontent, o, drawPage, true );
+ break;
+ case 9: //part
+ kdDebug(30518)<<" part object not implemented \n";
+ break;
+ case 10:
+ appendGroupObject( doccontent, o, drawPage );
+ break;
+ case 11:
+ kdDebug(30518)<<" free hand not implemented\n";
+ break;
+ case 12: // polyline
+ appendPolyline( doccontent, o, drawPage );
+ break;
+ case 13: //OT_QUADRICBEZIERCURVE = 13
+ case 14: //OT_CUBICBEZIERCURVE = 14
+ //todo
+ // "draw:path"
+ break;
+ case 15: // polygon
+ case 16: // close polygone
+ appendPolyline( doccontent, o, drawPage, true /*polygon*/ );
+ break;
+ }
+ ++m_objectIndex;
+ }
+
+}
+
+void OoImpressExport::appendGroupObject( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QDomElement groupElement = doc.createElement( "draw:g" );
+ QDomNode objects = source.namedItem( "OBJECTS" );
+ appendObjects( doc, objects, groupElement);
+ target.appendChild( groupElement );
+}
+
+void OoImpressExport::appendNote( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QString noteText = source.attribute("note");
+ //kdDebug(30518)<<"noteText :"<<noteText<<endl;
+ if ( noteText.isEmpty() )
+ return;
+ QDomElement noteElement = doc.createElement( "presentation:notes" );
+ QDomElement noteTextBox = doc.createElement( "draw:text-box" );
+
+ //TODO : add draw:text-box size :
+ //<draw:text-box draw:style-name="gr2" draw:text-style-name="P2" draw:layer="layout" svg:width="13.336cm" svg:height="56.288cm" svg:x="-0.54cm" svg:y="-14.846cm">
+
+ QStringList text = QStringList::split( "\n", noteText );
+ for ( QStringList::Iterator it = text.begin(); it != text.end(); ++it ) {
+ QDomElement tmp = doc.createElement( "text:p" );
+ tmp.appendChild( doc.createTextNode( *it ) );
+ noteTextBox.appendChild( tmp );
+ }
+ noteElement.appendChild( noteTextBox );
+ target.appendChild( noteElement );
+}
+
+void OoImpressExport::appendTextbox( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QDomElement textbox = doc.createElement( "draw:text-box" );
+
+ QDomNode textobject = source.namedItem( "TEXTOBJ" );
+
+ // create the graphic style
+ QString gs = m_styleFactory.createGraphicStyle( source );
+ textbox.setAttribute( "draw:style-name", gs );
+
+ // set the geometry
+ set2DGeometry( source, textbox );
+
+ // parse every paragraph
+ for ( QDomNode paragraph = textobject.firstChild(); !paragraph.isNull();
+ paragraph = paragraph.nextSibling() )
+ {
+ QDomElement p = paragraph.toElement();
+ appendParagraph( doc, p, textbox );
+ }
+
+ target.appendChild( textbox );
+}
+
+void OoImpressExport::appendParagraph( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QDomElement paragraph = doc.createElement( "text:p" );
+
+ // create the paragraph style
+ QString ps = m_styleFactory.createParagraphStyle( source );
+ paragraph.setAttribute( "text:style-name", ps );
+
+ // parse every text element
+ for ( QDomNode text = source.firstChild(); !text.isNull();
+ text = text.nextSibling() )
+ {
+ if ( text.nodeName() == "TEXT" )
+ {
+ QDomElement t = text.toElement();
+ appendText( doc, t, paragraph );
+ }
+ }
+
+ // take care of lists
+ QDomNode counter = source.namedItem( "COUNTER" );
+ if ( !counter.isNull() )
+ {
+ QDomElement c = counter.toElement();
+ int type = c.attribute( "type" ).toInt();
+
+ int level = 1;
+ if ( c.hasAttribute( "depth" ) )
+ level = c.attribute( "depth" ).toInt() + 1;
+
+ QDomElement endOfList = target;
+ for ( int l = 0; l < level; l++ )
+ {
+ QDomElement list;
+ if ( type == 1 )
+ {
+ list = doc.createElement( "text:ordered-list" );
+ list.setAttribute( "text:continue-numbering", "true" );
+ }
+ else
+ list = doc.createElement( "text:unordered-list" );
+
+ if ( l == 0 )
+ {
+ // create the list style
+ QString ls = m_styleFactory.createListStyle( c );
+ list.setAttribute( "text:style-name", ls );
+ }
+
+ QDomElement item = doc.createElement( "text:list-item" );
+ list.appendChild( item );
+ endOfList.appendChild( list );
+ endOfList = item;
+ }
+
+ endOfList.appendChild( paragraph );
+ }
+ else
+ target.appendChild( paragraph );
+}
+
+void OoImpressExport::appendText( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QDomElement textspan = doc.createElement( "text:span" );
+
+ // create the text style
+ QString ts = m_styleFactory.createTextStyle( source );
+ textspan.setAttribute( "text:style-name", ts );
+
+ textspan.appendChild( doc.createTextNode( source.text() ) );
+ target.appendChild( textspan );
+}
+
+void OoImpressExport::appendPicture( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QDomElement image = doc.createElement( "draw:image" );
+
+ // create the graphic style
+ QString gs = m_styleFactory.createGraphicStyle( source );
+ image.setAttribute( "draw:style-name", gs );
+ QDomElement key = source.namedItem( "KEY" ).toElement();
+
+ QString pictureName = QString( "Picture/Picture%1" ).arg( m_pictureIndex );
+
+ image.setAttribute( "xlink:type", "simple" );
+ image.setAttribute( "xlink:show", "embed" );
+ image.setAttribute( "xlink:actuate", "onLoad");
+
+ if ( !key.isNull() )
+ {
+ QString str = pictureKey( key );
+ QString returnstr = m_kpresenterPictureLst[str];
+ const int pos=returnstr.findRev('.');
+ if (pos!=-1)
+ {
+ const QString extension( returnstr.mid(pos+1) );
+ pictureName +="."+extension;
+ }
+
+ if ( m_storeinp->open( returnstr ) )
+ {
+ if ( m_storeout->open( pictureName ) )
+ {
+ QByteArray data(8*1024);
+ uint total = 0;
+ for ( int block = 0; ( block = m_storeinp->read(data.data(), data.size()) ) > 0;
+ total += block )
+ m_storeout->write(data.data(), data.size());
+ m_storeout->close();
+ m_storeinp->close();
+ }
+ }
+ }
+ image.setAttribute( "xlink:href", "#" + pictureName );
+
+// set the geometry
+ set2DGeometry( source, image );
+ target.appendChild( image );
+
+ m_pictureLst.insert( pictureName , "image/png" );
+
+ ++m_pictureIndex;
+}
+
+
+void OoImpressExport::appendLine( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QDomElement line = doc.createElement( "draw:line" );
+
+ // create the graphic style
+ QString gs = m_styleFactory.createGraphicStyle( source );
+ line.setAttribute( "draw:style-name", gs );
+
+ // set the geometry
+ setLineGeometry( source, line );
+
+ target.appendChild( line );
+}
+
+void OoImpressExport::appendRectangle( QDomDocument & doc, QDomElement & source, QDomElement & target )
+{
+ QDomElement rectangle = doc.createElement( "draw:rect" );
+
+ // create the graphic style
+ QString gs = m_styleFactory.createGraphicStyle( source );
+ rectangle.setAttribute( "draw:style-name", gs );
+
+ // set the geometry
+ set2DGeometry( source, rectangle );
+
+ target.appendChild( rectangle );
+}
+
+void OoImpressExport::appendPolyline( QDomDocument & doc, QDomElement & source, QDomElement & target, bool _poly)
+{
+ QDomElement polyline = doc.createElement( _poly ? "draw:polygon" : "draw:polyline" );
+
+ // create the graphic style
+ QString gs = m_styleFactory.createGraphicStyle( source );
+ polyline.setAttribute( "draw:style-name", gs );
+
+ // set the geometry
+ set2DGeometry( source, polyline, false, true /*multipoint*/ );
+
+ target.appendChild( polyline );
+}
+
+void OoImpressExport::appendEllipse( QDomDocument & doc, QDomElement & source, QDomElement & target, bool pieObject )
+{
+ QDomElement size = source.namedItem( "SIZE" ).toElement();
+
+ double width = size.attribute( "width" ).toDouble();
+ double height = size.attribute( "height" ).toDouble();
+
+ QDomElement ellipse = doc.createElement( (width == height) ? "draw:circle" : "draw:ellipse" );
+
+ // create the graphic style
+ QString gs = m_styleFactory.createGraphicStyle( source );
+ ellipse.setAttribute( "draw:style-name", gs );
+
+ // set the geometry
+ set2DGeometry( source, ellipse, pieObject );
+
+ target.appendChild( ellipse );
+}
+
+void OoImpressExport::set2DGeometry( QDomElement & source, QDomElement & target, bool pieObject, bool multiPoint )
+{
+ QDomElement orig = source.namedItem( "ORIG" ).toElement();
+ QDomElement size = source.namedItem( "SIZE" ).toElement();
+ QDomElement name = source.namedItem( "OBJECTNAME").toElement();
+ float y = orig.attribute( "y" ).toFloat();
+ y -= m_pageHeight * ( m_currentPage - 1 );
+
+ QDomElement angle = source.namedItem( "ANGLE").toElement();
+ if ( !angle.isNull() )
+ {
+ QString returnAngle = rotateValue( angle.attribute( "value" ).toDouble() );
+ if ( !returnAngle.isEmpty() )
+ target.setAttribute("draw:transform",returnAngle );
+ }
+
+ target.setAttribute( "draw:id", QString::number( m_objectIndex ) );
+ target.setAttribute( "svg:x", StyleFactory::toCM( orig.attribute( "x" ) ) );
+ target.setAttribute( "svg:y", QString( "%1cm" ).arg( KoUnit::toCM( y ) ) );
+ target.setAttribute( "svg:width", StyleFactory::toCM( size.attribute( "width" ) ) );
+ target.setAttribute( "svg:height", StyleFactory::toCM( size.attribute( "height" ) ) );
+ QString nameStr = name.attribute("objectName");
+ if( !nameStr.isEmpty() )
+ target.setAttribute( "draw:name", nameStr );
+ if ( pieObject )
+ {
+ QDomElement pie = source.namedItem( "PIETYPE").toElement();
+ if( !pie.isNull() )
+ {
+ int typePie = pie.attribute("value").toInt();
+ switch( typePie )
+ {
+ case 0:
+ target.setAttribute( "draw:kind", "section");
+ break;
+ case 1:
+ target.setAttribute( "draw:kind", "arc");
+ break;
+ case 2:
+ target.setAttribute( "draw:kind", "cut");
+ break;
+ default:
+ kdDebug(30518)<<" type unknown : "<<typePie<<endl;
+ break;
+ }
+ }
+ else
+ target.setAttribute( "draw:kind", "section");//by default
+ QDomElement pieAngle = source.namedItem( "PIEANGLE").toElement();
+ int startangle = 45;
+ if( !pieAngle.isNull() )
+ {
+ startangle = (pieAngle.attribute("value").toInt())/16;
+ target.setAttribute( "draw:start-angle", startangle);
+ }
+ else
+ {
+ //default value take it into kppieobject
+ target.setAttribute( "draw:start-angle", 45 );
+ }
+ QDomElement pieLength = source.namedItem( "PIELENGTH").toElement();
+ if( !pieLength.isNull() )
+ {
+ int value = pieLength.attribute("value").toInt();
+ value = value /16;
+ value = value + startangle;
+ target.setAttribute( "draw:end-angle", value );
+ }
+ else
+ {
+ //default value take it into kppieobject
+ //default is 90 into kpresenter
+ target.setAttribute( "draw:end-angle", (90+startangle) );
+ }
+ }
+ if ( multiPoint )
+ {
+ //loadPoint
+ QDomElement point = source.namedItem( "POINTS" ).toElement();
+ if ( !point.isNull() ) {
+ QDomElement elemPoint = point.firstChild().toElement();
+ QString listOfPoint;
+ int maxX=0;
+ int maxY=0;
+ while ( !elemPoint.isNull() ) {
+ if ( elemPoint.tagName() == "Point" ) {
+ int tmpX = 0;
+ int tmpY = 0;
+ if( elemPoint.hasAttribute( "point_x" ) )
+ tmpX = ( int ) ( KoUnit::toMM( elemPoint.attribute( "point_x" ).toDouble() )*100 );
+ if( elemPoint.hasAttribute( "point_y" ) )
+ tmpY = ( int ) ( KoUnit::toMM(elemPoint.attribute( "point_y" ).toDouble() )*100 );
+ if ( !listOfPoint.isEmpty() )
+ listOfPoint += QString( " %1,%2" ).arg( tmpX ).arg( tmpY );
+ else
+ listOfPoint = QString( "%1,%2" ).arg( tmpX ).arg( tmpY );
+ maxX = QMAX( maxX, tmpX );
+ maxY = QMAX( maxY, tmpY );
+ }
+ elemPoint = elemPoint.nextSibling().toElement();
+ }
+ target.setAttribute( "draw:points", listOfPoint );
+ target.setAttribute( "svg:viewBox", QString( "0 0 %1 %2" ).arg( maxX ).arg( maxY ) );
+ }
+ }
+}
+
+QString OoImpressExport::rotateValue( double val )
+{
+ QString str;
+ if ( val!=0.0 )
+ {
+ double value = -1 * ( ( double )val* M_PI )/180.0;
+ str=QString( "rotate (%1)" ).arg( value );
+ }
+ return str;
+}
+
+
+void OoImpressExport::setLineGeometry( QDomElement & source, QDomElement & target )
+{
+ QDomElement orig = source.namedItem( "ORIG" ).toElement();
+ QDomElement size = source.namedItem( "SIZE" ).toElement();
+ QDomElement linetype = source.namedItem( "LINETYPE" ).toElement();
+ QDomElement name = source.namedItem( "OBJECTNAME").toElement();
+ QDomElement angle = source.namedItem( "ANGLE").toElement();
+ if ( !angle.isNull() )
+ {
+ QString returnAngle = rotateValue( angle.attribute( "value" ).toDouble() );
+ if ( !returnAngle.isEmpty() )
+ target.setAttribute("draw:transform",returnAngle );
+ }
+ float x1 = orig.attribute( "x" ).toFloat();
+ float y1 = orig.attribute( "y" ).toFloat();
+ float x2 = size.attribute( "width" ).toFloat();
+ float y2 = size.attribute( "height" ).toFloat();
+ int type = 0;
+ if ( !linetype.isNull() )
+ type = linetype.attribute( "value" ).toInt();
+ y1 -= m_pageHeight * ( m_currentPage - 1 );
+ x2 += x1;
+ y2 += y1;
+
+ target.setAttribute( "draw:id", QString::number( m_objectIndex ) );
+ QString xpos1 = StyleFactory::toCM( orig.attribute( "x" ) );
+ QString xpos2 = QString( "%1cm" ).arg( KoUnit::toCM( x2 ) );
+
+ if ( type == 0 )
+ {
+ target.setAttribute( "svg:y1", QString( "%1cm" ).arg( KoUnit::toCM( y2/2.0 ) ) );
+ target.setAttribute( "svg:y2", QString( "%1cm" ).arg( KoUnit::toCM( y2/2.0 ) ) );
+ }
+ else if ( type == 1 )
+ {
+ target.setAttribute( "svg:y1", QString( "%1cm" ).arg( KoUnit::toCM( y1 ) ) );
+ target.setAttribute( "svg:y2", QString( "%1cm" ).arg( KoUnit::toCM( y2 ) ) );
+ xpos1 = QString( "%1cm" ).arg( KoUnit::toCM( x1/2.0 ) );
+ xpos2 = xpos1;
+ }
+ else if ( type == 3 ) // from left bottom to right top
+ {
+ target.setAttribute( "svg:y1", QString( "%1cm" ).arg( KoUnit::toCM( y2 ) ) );
+ target.setAttribute( "svg:y2", QString( "%1cm" ).arg( KoUnit::toCM( y1 ) ) );
+ }
+ else // from left top to right bottom
+ {
+ target.setAttribute( "svg:y1", QString( "%1cm" ).arg( KoUnit::toCM( y1 ) ) );
+ target.setAttribute( "svg:y2", QString( "%1cm" ).arg( KoUnit::toCM( y2 ) ) );
+ }
+ target.setAttribute( "svg:x1", xpos1 );
+ target.setAttribute( "svg:x2", xpos2 );
+
+ QString nameStr = name.attribute("objectName");
+ if( !nameStr.isEmpty() )
+ target.setAttribute( "draw:name", nameStr );
+}
+
+#include "ooimpressexport.moc"
diff --git a/filters/kpresenter/ooimpress/ooimpressexport.h b/filters/kpresenter/ooimpress/ooimpressexport.h
new file mode 100644
index 00000000..9ab3d153
--- /dev/null
+++ b/filters/kpresenter/ooimpress/ooimpressexport.h
@@ -0,0 +1,92 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Percy Leonhardt
+
+ 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 OOIMPRESSEXPORT_H
+#define OOIMPRESSEXPORT_H
+
+#include "stylefactory.h"
+
+#include <qdom.h>
+
+#include <KoFilter.h>
+
+class QDomElement;
+class KoStore;
+
+class OoImpressExport : public KoFilter
+{
+ Q_OBJECT
+public:
+ OoImpressExport( KoFilter * parent, const char * name, const QStringList & );
+ virtual ~OoImpressExport();
+
+ virtual KoFilter::ConversionStatus convert( const QCString & from,
+ const QCString & to );
+
+private:
+ KoFilter::ConversionStatus openFile();
+
+ void exportBody( QDomDocument & doccontent, QDomElement & body );
+ void createDocumentMeta( QDomDocument & docmeta );
+ void createDocumentStyles( QDomDocument & docstyles );
+ void createDocumentContent( QDomDocument & doccontent );
+ void createDocumentManifest( QDomDocument & docmanifest );
+ void createDocumentSettings( QDomDocument & docsetting );
+ void appendTextbox( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ void appendParagraph( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ void appendText( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ void appendLine( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ void appendRectangle( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ void appendEllipse( QDomDocument & doc, QDomElement & source, QDomElement & target, bool pieObject = false );
+ void set2DGeometry( QDomElement & source, QDomElement & target, bool pieObject = false, bool multiPoint = false );
+ void setLineGeometry( QDomElement & source, QDomElement & target );
+ void appendPolyline( QDomDocument & doc, QDomElement & source, QDomElement & target, bool polygone = false);
+ void appendPicture( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ void createPictureList( QDomNode &pictures );
+ void appendNote( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ void appendGroupObject( QDomDocument & doc, QDomElement & source, QDomElement & target );
+ QString rotateValue( double val );
+ QString pictureKey( QDomElement &element );
+ void createHelpLine( QDomNode &helpline );
+ void createAttribute( QDomNode &attributeValue );
+ void appendObjects(QDomDocument & doccontent, QDomNode &objects, QDomElement &drawPage);
+
+ int m_currentPage;
+ int m_objectIndex;
+ float m_pageHeight;
+ StyleFactory m_styleFactory;
+ QString m_masterPageStyle;
+ QDomElement m_styles;
+ QDomDocument m_maindoc;
+ QDomDocument m_documentinfo;
+ QMap<QString, QString> m_pictureLst;
+
+ QString m_helpLine;
+ int m_activePage;
+ double m_gridX, m_gridY;
+ bool m_snapToGrid;
+
+ //load from kpresenter file format
+ QMap<QString, QString> m_kpresenterPictureLst;
+ int m_pictureIndex;
+ KoStore *m_storeinp;
+ KoStore *m_storeout;
+};
+
+#endif
diff --git a/filters/kpresenter/ooimpress/ooimpressimport.cc b/filters/kpresenter/ooimpress/ooimpressimport.cc
new file mode 100644
index 00000000..be6c094d
--- /dev/null
+++ b/filters/kpresenter/ooimpress/ooimpressimport.cc
@@ -0,0 +1,2433 @@
+// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
+/* This file is part of the KDE project
+ Copyright (C) 2002 Laurent Montel <lmontel@mandrakesoft.com>
+ Copyright (c) 2003 Lukas Tinkl <lukas@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 "ooimpressimport.h"
+
+#include <math.h>
+
+#include <qregexp.h>
+#include <qdatetime.h>
+#include <qfileinfo.h>
+#include <qdir.h>
+
+#include <kzip.h>
+#include <karchive.h>
+#include <kdebug.h>
+#include <KoUnit.h>
+#include <KoDocumentInfo.h>
+#include <KoDocument.h>
+
+#include <kgenericfactory.h>
+#include <KoFilterChain.h>
+#include <KoGlobal.h>
+#include <ooutils.h>
+#include <KoDom.h>
+#include <KoOasisSettings.h>
+
+typedef KGenericFactory<OoImpressImport, KoFilter> OoImpressImportFactory;
+K_EXPORT_COMPONENT_FACTORY( libooimpressimport, OoImpressImportFactory( "kofficefilters" ) )
+
+
+OoImpressImport::OoImpressImport( KoFilter *, const char *, const QStringList & )
+ : KoFilter(),
+ m_numPicture( 1 ),
+ m_numSound(1),
+ m_styles( 23, true ),
+ m_styleStack( ooNS::style, ooNS::fo )
+{
+ m_styles.setAutoDelete( true );
+ m_listStyles.setAutoDelete( true );
+}
+
+OoImpressImport::~OoImpressImport()
+{
+ QDictIterator<animationList> it( m_animations ); // See QDictIterator
+ for( ; it.current(); ++it )
+ {
+ delete it.current()->element;
+ }
+ m_animations.clear();
+}
+
+KoFilter::ConversionStatus OoImpressImport::convert( QCString const & from, QCString const & to )
+{
+ kdDebug(30518) << "Entering Ooimpress Import filter: " << from << " - " << to << endl;
+
+ if ( (from != "application/vnd.sun.xml.impress" && from != "application/vnd.sun.xml.impress.template" )
+ || to != "application/x-kpresenter" )
+ {
+ kdWarning(30518) << "Invalid mimetypes " << from << " " << to << endl;
+ return KoFilter::NotImplemented;
+ }
+
+ m_zip = new KZip( m_chain->inputFile() );
+
+ if ( !m_zip->open( IO_ReadOnly ) )
+ {
+ kdError(30518) << "Couldn't open the requested file "<< m_chain->inputFile() << endl;
+ delete m_zip;
+ return KoFilter::FileNotFound;
+ }
+
+ KoFilter::ConversionStatus preStatus = openFile();
+
+ if ( preStatus != KoFilter::OK )
+ {
+ m_zip->close();
+ delete m_zip;
+ return preStatus;
+ }
+
+ QDomDocument docinfo;
+ createDocumentInfo( docinfo );
+
+ // store document info
+ KoStoreDevice* out = m_chain->storageFile( "documentinfo.xml", KoStore::Write );
+ if( out )
+ {
+ QCString info = docinfo.toCString();
+ //kdDebug(30518) << " info :" << info << endl;
+ // WARNING: we cannot use KoStore::write(const QByteArray&) because it gives an extra NULL character at the end.
+ out->writeBlock( info , info.length() );
+ }
+
+ QDomDocument doccontent;
+ createDocumentContent( doccontent );
+
+ // store document content
+ out = m_chain->storageFile( "maindoc.xml", KoStore::Write );
+ if( out )
+ {
+ QCString content = doccontent.toCString();
+ kdDebug(30518) << " content :" << content << endl;
+ out->writeBlock( content , content.length() );
+ }
+
+ m_zip->close();
+ delete m_zip;
+
+ kdDebug(30518) << "######################## OoImpressImport::convert done ####################" << endl;
+ return KoFilter::OK;
+}
+
+// Very related to OoWriterImport::openFile()
+KoFilter::ConversionStatus OoImpressImport::openFile()
+{
+ KoFilter::ConversionStatus status = loadAndParse( "content.xml", m_content );
+ if ( status != KoFilter::OK )
+ {
+ kdError(30518) << "Content.xml could not be parsed correctly! Aborting!" << endl;
+ return status;
+ }
+
+ // We do not stop if the following calls fail.
+ QDomDocument styles;
+ loadAndParse( "styles.xml", styles );
+ loadAndParse( "meta.xml", m_meta );
+ loadAndParse( "settings.xml", m_settings );
+
+ emit sigProgress( 10 );
+ createStyleMap( styles );
+
+ return KoFilter::OK;
+}
+
+KoFilter::ConversionStatus OoImpressImport::loadAndParse(const QString& filename, QDomDocument& doc)
+{
+ return OoUtils::loadAndParse( filename, doc, m_zip);
+}
+
+// Very related to OoWriterImport::createDocumentInfo
+void OoImpressImport::createDocumentInfo( QDomDocument &docinfo )
+{
+ docinfo = KoDocument::createDomDocument( "document-info" /*DTD name*/, "document-info" /*tag name*/, "1.1" );
+
+ OoUtils::createDocumentInfo(m_meta, docinfo);
+ //kdDebug(30518) << " meta-info :" << m_meta.toCString() << endl;
+}
+
+void OoImpressImport::createDocumentContent( QDomDocument &doccontent )
+{
+ QDomDocument doc = KoDocument::createDomDocument( "kpresenter", "DOC", "1.2" );
+ QDomElement docElement = doc.documentElement();
+ docElement.setAttribute( "editor", "KPresenter" );
+ docElement.setAttribute( "mime", "application/x-kpresenter" );
+ docElement.setAttribute( "syntaxVersion", "2" );
+
+ QDomElement content = m_content.documentElement();
+
+ // content.xml contains some automatic-styles that we need to store
+ QDomNode automaticStyles = KoDom::namedItemNS( content, ooNS::office, "automatic-styles" );
+ if ( !automaticStyles.isNull() )
+ insertStyles( automaticStyles.toElement() );
+
+ QDomNode body = KoDom::namedItemNS( content, ooNS::office, "body" );
+ if ( body.isNull() )
+ return;
+
+ QDomElement customSlideShow = doc.createElement( "CUSTOMSLIDESHOWCONFIG" );
+
+ // presentation settings
+ QDomElement settings = KoDom::namedItemNS( body, ooNS::presentation, "settings");
+ if (!settings.isNull())
+ {
+ if (settings.attributeNS( ooNS::presentation, "endless", QString::null)=="true")
+ {
+ QDomElement infElem = doc.createElement("INFINITLOOP");
+ infElem.setAttribute("value", 1);
+ docElement.appendChild(infElem);
+ }
+
+ if (settings.attributeNS( ooNS::presentation, "show-end-of-presentation-slide", QString::null)=="true")
+ {
+ QDomElement infElem = doc.createElement("SHOWENDOFPRESENTATIONSLIDE");
+ infElem.setAttribute("value", 1);
+ docElement.appendChild(infElem);
+ }
+
+ if (settings.attributeNS( ooNS::presentation, "force-manual", QString::null)=="true")
+ {
+ QDomElement manualElem = doc.createElement("MANUALSWITCH");
+ manualElem.setAttribute("value", 1);
+ docElement.appendChild(manualElem);
+ }
+ if ( settings.hasAttributeNS( ooNS::presentation, "show") )
+ {
+ QDomElement defaultPage = doc.createElement("DEFAULTCUSTOMSLIDESHOWNAME");
+ defaultPage.setAttribute("name", settings.attributeNS( ooNS::presentation, "show", QString::null) );
+ docElement.appendChild(defaultPage);
+ }
+ }
+
+ QDomElement presentationShow;
+ forEachElement( presentationShow, settings )
+ {
+ if ( presentationShow.localName()=="show" && presentationShow.namespaceURI() == ooNS::presentation )
+ {
+ if ( presentationShow.hasAttributeNS( ooNS::presentation, "pages") &&
+ presentationShow.hasAttributeNS( ooNS::presentation, "name"))
+ {
+ QDomElement slide=doc.createElement("CUSTOMSLIDESHOW");
+ slide.setAttribute( "pages", presentationShow.attributeNS( ooNS::presentation, "pages", QString::null ));
+ slide.setAttribute( "name", presentationShow.attributeNS( ooNS::presentation, "name", QString::null ));
+ customSlideShow.appendChild( slide );
+ }
+ }
+ }
+ // it seems that ooimpress has different paper-settings for every slide.
+ // we take the settings of the first slide for the whole document.
+ QDomElement drawPage = KoDom::namedItemNS( body, ooNS::draw, "page" );
+ if ( drawPage.isNull() ) // no slides? give up.
+ return;
+
+ QDomElement objectElement = doc.createElement( "OBJECTS" );
+ QDomElement pictureElement = doc.createElement( "PICTURES" );
+ QDomElement pageTitleElement = doc.createElement( "PAGETITLES" );
+ QDomElement pageNoteElement = doc.createElement( "PAGENOTES" );
+ QDomElement backgroundElement = doc.createElement( "BACKGROUND" );
+ QDomElement soundElement = doc.createElement( "SOUNDS" );
+ QDomElement selSlideElement = doc.createElement( "SELSLIDES" );
+ QDomElement helpLineElement = doc.createElement( "HELPLINES" );
+ QDomElement attributeElement = doc.createElement( "ATTRIBUTES" );
+ QDomElement *master = m_styles[drawPage.attributeNS( ooNS::draw, "master-page-name", QString::null )];
+
+ appendObject(*master, doc, soundElement,pictureElement,pageNoteElement,objectElement, 0, true);
+
+ QDomElement *style = m_styles[master->attributeNS( ooNS::style, "page-master-name", QString::null )];
+ QDomElement properties = KoDom::namedItemNS( *style, ooNS::style, "properties" );
+ //kdDebug(30518)<<" master->attribute( draw:style-name ) :"<<master->attributeNS( ooNS::draw, "style-name", QString::null )<<endl;
+ QDomElement *backgroundStyle = m_stylesPresentation[ master->attributeNS( ooNS::draw, "style-name", QString::null ).isEmpty() ? "Standard-background" : master->attributeNS( ooNS::draw, "style-name", QString::null ) ];
+
+ //kdDebug(30518)<<" backgroundStyle :"<<backgroundStyle<<endl;
+ double pageHeight;
+ QDomElement paperElement = doc.createElement( "PAPER" );
+ if ( properties.isNull() )
+ {
+ paperElement.setAttribute( "ptWidth", CM_TO_POINT(28) );
+ paperElement.setAttribute( "ptHeight", CM_TO_POINT(21) );
+ paperElement.setAttribute( "unit", 0 );
+ paperElement.setAttribute( "format", 5 );
+ paperElement.setAttribute( "tabStopValue", 42.5198 );
+ paperElement.setAttribute( "orientation", 0 );
+ pageHeight = 21;
+
+ QDomElement paperBorderElement = doc.createElement( "PAPERBORDERS" );
+ paperBorderElement.setAttribute( "ptRight", 0 );
+ paperBorderElement.setAttribute( "ptBottom", 0 );
+ paperBorderElement.setAttribute( "ptLeft", 0 );
+ paperBorderElement.setAttribute( "ptTop", 0 );
+ paperElement.appendChild( paperBorderElement );
+ }
+ else
+ {
+ paperElement.setAttribute( "ptWidth", KoUnit::parseValue(properties.attributeNS( ooNS::fo, "page-width", QString::null ) ) );
+ paperElement.setAttribute( "ptHeight", KoUnit::parseValue(properties.attributeNS( ooNS::fo, "page-height", QString::null ) ) );
+// paperElement.setAttribute( "unit", 0 );
+// paperElement.setAttribute( "format", 5 );
+// paperElement.setAttribute( "tabStopValue", 42.5198 );
+// paperElement.setAttribute( "orientation", 0 );
+ // Keep pageHeight in cm to avoid rounding-errors that would
+ // get multiplied with every new slide.
+
+ if (properties.attributeNS( ooNS::style, "print-orientation", QString::null)=="portrait")
+ paperElement.setAttribute("orientation", 0);
+ else if (properties.attributeNS( ooNS::style, "print-orientation", QString::null)=="landscape")
+ paperElement.setAttribute("orientation", 1);
+
+
+
+ pageHeight = properties.attributeNS( ooNS::fo, "page-height", QString::null ).remove( "cm" ).toDouble();
+
+ QDomElement paperBorderElement = doc.createElement( "PAPERBORDERS" );
+ paperBorderElement.setAttribute( "ptRight", KoUnit::parseValue( properties.attributeNS( ooNS::fo, "margin-right", QString::null ) ) );
+ paperBorderElement.setAttribute( "ptBottom", KoUnit::parseValue( properties.attributeNS( ooNS::fo, "margin-bottom", QString::null ) ) );
+ paperBorderElement.setAttribute( "ptLeft", KoUnit::parseValue( properties.attributeNS( ooNS::fo, "margin-left", QString::null ) ) );
+ paperBorderElement.setAttribute( "ptTop", KoUnit::parseValue( properties.attributeNS( ooNS::fo, "margin-top", QString::null ) ) );
+ paperElement.appendChild( paperBorderElement );
+ }
+
+
+ // parse all pages
+ forEachElement( drawPage, body )
+ {
+ if ( drawPage.localName()=="page" && drawPage.namespaceURI() == ooNS::draw && drawPage.hasAttributeNS( ooNS::draw, "id" ))
+ {
+ m_styleStack.clear(); // remove all styles
+ fillStyleStack( drawPage );
+ m_styleStack.save();
+ int pagePos = drawPage.attributeNS( ooNS::draw, "id", QString::null ).toInt() - 1;
+ // take care of a possible page background or slide transition or sound
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "fill" )
+ || m_styleStack.hasAttributeNS( ooNS::presentation, "transition-style" ))
+ {
+ appendBackgroundPage( doc, backgroundElement,pictureElement, soundElement );
+ }
+ else if ( !m_styleStack.hasAttributeNS( ooNS::draw, "fill" ) && backgroundStyle)
+ {
+ m_styleStack.save();
+ m_styleStack.push( *backgroundStyle );
+ appendBackgroundPage( doc, backgroundElement,pictureElement, soundElement );
+ m_styleStack.restore();
+ kdDebug(30518)<<" load standard bacground \n";
+ }
+ if ( m_styleStack.hasAttributeNS( ooNS::presentation, "visibility" ) )
+ {
+ QString str = m_styleStack.attributeNS( ooNS::presentation, "visibility" );
+ QDomElement slide = doc.createElement("SLIDE");
+ slide.setAttribute( "nr", pagePos );
+ slide.setAttribute( "show", ( ( str=="hidden" ) ? "0" : "1" ));
+ selSlideElement.appendChild( slide );
+
+ //todo add support
+ kdDebug(30518)<<"m_styleStack.hasAttribute( presentation:visibility ) :"<<str<<" position page "<<pagePos<<endl;
+ }
+ // set the pagetitle
+ QDomElement titleElement = doc.createElement( "Title" );
+ titleElement.setAttribute( "title", drawPage.attributeNS( ooNS::draw, "name", QString::null ) );
+ pageTitleElement.appendChild( titleElement );
+
+ // The '+1' is necessary to avoid that objects that start on the first line
+ // of a slide will show up on the last line of the previous slide.
+ double offset = CM_TO_POINT( ( drawPage.attributeNS( ooNS::draw, "id", QString::null ).toInt() - 1 ) * pageHeight ) + 1;
+
+ // animations (object effects)
+ createPresentationAnimation(KoDom::namedItemNS( drawPage, ooNS::presentation, "animations") );
+
+ // parse all objects
+ appendObject(drawPage, doc, soundElement,pictureElement,pageNoteElement,objectElement, offset);
+
+ //m_animations.clear();
+ m_styleStack.restore();
+ }
+ }
+
+ docElement.appendChild( paperElement );
+ docElement.appendChild( backgroundElement );
+ if ( parseSettings( doc, helpLineElement, attributeElement ) )
+ docElement.appendChild( helpLineElement );
+ docElement.appendChild( attributeElement );
+ docElement.appendChild( pageTitleElement );
+ docElement.appendChild( pageNoteElement );
+ docElement.appendChild( objectElement );
+ docElement.appendChild( selSlideElement );
+ docElement.appendChild( customSlideShow );
+ docElement.appendChild( soundElement );
+ docElement.appendChild( pictureElement );
+
+ doccontent.appendChild( doc );
+}
+
+bool OoImpressImport::parseSettings( QDomDocument &doc, QDomElement &helpLineElement, QDomElement &attributeElement )
+{
+ bool foundElement = false;
+ KoOasisSettings settings( m_settings, ooNS::office, ooNS::config );
+ KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" );
+ //setUnit(KoUnit::unit(viewSettings.parseConfigItemString("unit")));
+ KoOasisSettings::IndexedMap viewMap = viewSettings.indexedMap( "Views" );
+ KoOasisSettings::Items firstView = viewMap.entry( 0 );
+ //<config:config-item config:name="SnapLinesDrawing" config:type="string">V7939H1139</config:config-item>
+ //by default show line
+
+ if ( !firstView.isNull() )
+ {
+ QString str = firstView.parseConfigItemString( "SnapLinesDrawing" );
+ if ( !str.isEmpty() )
+ {
+ parseHelpLine( doc, helpLineElement, str );
+ //display it by default
+ helpLineElement.setAttribute( "show", true );
+ foundElement = true;
+ }
+
+ int gridX = firstView.parseConfigItemInt( "GridFineWidth" );
+ int gridY = firstView.parseConfigItemInt( "GridFineHeight" );
+ bool snapToGrid = firstView.parseConfigItemBool( "IsSnapToGrid" );
+ int selectedPage = firstView.parseConfigItemInt( "SelectedPage" );
+
+ attributeElement.setAttribute( "activePage", selectedPage );
+ attributeElement.setAttribute( "gridx", MM_TO_POINT( gridX / 100.0 ) );
+ attributeElement.setAttribute( "gridy", MM_TO_POINT( gridY / 100.0 ) );
+ attributeElement.setAttribute( "snaptogrid", (int)snapToGrid );
+
+ }
+
+ //kdDebug(30518)<<" gridX :"<<gridX<<" gridY :"<<gridY<<" snapToGrid :"<<snapToGrid<<" selectedPage :"<<selectedPage<<endl;
+ return foundElement;
+}
+
+void OoImpressImport::parseHelpLine( QDomDocument &doc,QDomElement &helpLineElement, const QString &text )
+{
+ QString str;
+ int newPos = text.length()-1; //start to element = 1
+ for ( int pos = text.length()-1; pos >=0;--pos )
+ {
+ if ( text[pos]=='P' )
+ {
+
+ //point
+ str = text.mid( pos+1, ( newPos-pos ) );
+ QDomElement point=doc.createElement("HelpPoint");
+
+ //kdDebug(30518)<<" point element :"<< str <<endl;
+ QStringList listVal = QStringList::split( ",", str );
+ int posX = ( listVal[0].toInt()/100 );
+ int posY = ( listVal[1].toInt()/100 );
+ point.setAttribute("posX", MM_TO_POINT( posX ));
+ point.setAttribute("posY", MM_TO_POINT( posY ));
+
+ helpLineElement.appendChild( point );
+ newPos = pos-1;
+ }
+ else if ( text[pos]=='V' )
+ {
+ QDomElement lines=doc.createElement("Vertical");
+ //vertical element
+ str = text.mid( pos+1, ( newPos-pos ) );
+ //kdDebug(30518)<<" vertical :"<< str <<endl;
+ int posX = ( str.toInt()/100 );
+ lines.setAttribute( "value", MM_TO_POINT( posX ) );
+ helpLineElement.appendChild( lines );
+
+ newPos = ( pos-1 );
+
+ }
+ else if ( text[pos]=='H' )
+ {
+ //horizontal element
+ QDomElement lines=doc.createElement("Horizontal");
+ str = text.mid( pos+1, ( newPos-pos ) );
+ //kdDebug(30518)<<" horizontal :"<< str <<endl;
+ int posY = ( str.toInt()/100 );
+ lines.setAttribute( "value", MM_TO_POINT( posY ) );
+ helpLineElement.appendChild( lines );
+ newPos = pos-1;
+ }
+ }
+}
+
+void OoImpressImport::appendObject(QDomNode & drawPage, QDomDocument & doc, QDomElement & soundElement, QDomElement & pictureElement, QDomElement & pageNoteElement, QDomElement &objectElement, double offset, bool sticky)
+{
+ QDomElement o;
+ forEachElement( o, drawPage )
+ {
+ const QString localName = o.localName();
+ const QString ns = o.namespaceURI();
+ const QString drawID = o.attributeNS( ooNS::draw, "id", QString::null);
+ m_styleStack.save();
+
+ QDomElement e;
+ if ( localName == "text-box" && ns == ooNS::draw ) // textbox
+ {
+ fillStyleStack( o, sticky );
+ e = doc.createElement( "OBJECT" );
+ e.setAttribute( "type", 4 );
+ if ( sticky )
+ e.setAttribute( "sticky", "1" );
+ append2DGeometry( doc, e, o, (int)offset );
+ appendName(doc, e, o);
+ appendPen( doc, e );
+ appendBrush( doc, e );
+ appendRounding( doc, e, o );
+ appendShadow( doc, e );
+ appendObjectEffect(doc, e, o, soundElement);
+ e.appendChild( parseTextBox( doc, o ) );
+ }
+ else if ( localName == "rect" && ns == ooNS::draw ) // rectangle
+ {
+ fillStyleStack( o, sticky );
+ e = doc.createElement( "OBJECT" );
+ e.setAttribute( "type", 2 );
+ if ( sticky )
+ e.setAttribute( "sticky", "1" );
+ append2DGeometry( doc, e, o, (int)offset );
+ appendName(doc, e, o);
+ appendPen( doc, e );
+ appendBrush( doc, e );
+ appendRounding( doc, e, o );
+ appendShadow( doc, e );
+
+ appendObjectEffect(doc, e, o, soundElement);
+ }
+ else if ( ( localName == "circle" || localName == "ellipse" ) && ns == ooNS::draw )
+ {
+ fillStyleStack( o, sticky );
+ e = doc.createElement( "OBJECT" );
+ if ( sticky )
+ e.setAttribute( "sticky", "1" );
+ append2DGeometry( doc, e, o, (int)offset );
+ appendName(doc, e, o);
+ appendPen( doc, e );
+ appendShadow( doc, e );
+ appendLineEnds( doc, e );
+ appendObjectEffect(doc, e, o, soundElement);
+
+ if ( o.hasAttributeNS( ooNS::draw, "kind" ) ) // pie, chord or arc
+ {
+ e.setAttribute( "type", 8 );
+ appendPie( doc, e, o );
+ QDomElement type = doc.createElement( "PIETYPE" );
+
+ QString kind = o.attributeNS( ooNS::draw, "kind", QString::null );
+ if ( kind == "section" )
+ {
+ appendBrush( doc, e );
+ type.setAttribute( "value", 0 );
+ }
+ else if ( kind == "cut" )
+ {
+ appendBrush( doc, e );
+ type.setAttribute( "value", 2 );
+ }
+ else if ( kind == "arc" )
+ {
+ // arc has no brush
+ type.setAttribute( "value", 1 );
+ }
+ e.appendChild( type );
+ }
+ else // circle or ellipse
+ {
+ e.setAttribute( "type", 3 );
+ appendBrush( doc, e );
+ }
+ }
+ else if ( localName == "line" && ns == ooNS::draw ) // line
+ {
+ fillStyleStack( o, sticky );
+ e = doc.createElement( "OBJECT" );
+ e.setAttribute( "type", 1 );
+ if ( sticky )
+ e.setAttribute( "sticky", "1" );
+ bool orderEndStartLine = appendLineGeometry( doc, e, o, (int)offset );
+ appendName(doc, e, o);
+ appendPen( doc, e );
+ appendBrush( doc, e );
+ appendShadow( doc, e );
+ appendLineEnds( doc, e, orderEndStartLine );
+ appendObjectEffect(doc, e, o, soundElement);
+ }
+ else if ( localName=="polyline" && ns == ooNS::draw ) { // polyline
+ fillStyleStack(o, sticky);
+ e = doc.createElement("OBJECT");
+ e.setAttribute("type", 12);
+ if ( sticky )
+ e.setAttribute( "sticky", "1" );
+ append2DGeometry(doc, e, o, (int)offset);
+ appendName(doc, e, o);
+ appendPoints(doc, e, o);
+ appendPen(doc, e);
+ appendBrush(doc, e);
+ appendLineEnds(doc, e);
+ //appendShadow(doc, e);
+ appendObjectEffect(doc, e, o, soundElement);
+ }
+ else if ( localName=="polygon" && ns == ooNS::draw ) { // polygon
+ fillStyleStack(o, sticky);
+ e = doc.createElement("OBJECT");
+ e.setAttribute("type", 16);
+ if ( sticky )
+ e.setAttribute( "sticky", "1" );
+ append2DGeometry(doc, e, o, (int)offset);
+ appendName(doc, e, o);
+ appendPoints(doc, e, o);
+ appendPen(doc, e);
+ appendBrush(doc, e);
+ //appendLineEnds(doc, e);
+ //appendShadow(doc, e);
+ appendObjectEffect(doc, e, o, soundElement);
+ }
+ else if ( localName == "image" && ns == ooNS::draw ) // image
+ {
+ fillStyleStack( o, sticky );
+ e = doc.createElement( "OBJECT" );
+ e.setAttribute( "type", 0 );
+ if ( sticky )
+ e.setAttribute( "sticky", "1" );
+ append2DGeometry( doc, e, o, (int)offset );
+ appendName(doc, e, o);
+ appendImage( doc, e, pictureElement, o );
+ appendObjectEffect(doc, e, o, soundElement);
+ }
+ else if ( localName == "object" && ns == ooNS::draw )
+ {
+ //todo add part object
+ }
+ else if ( localName == "g" && ns == ooNS::draw )
+ {
+ //todo add group object
+ }
+ else if ( localName == "path" && ns == ooNS::draw )
+ {
+ //todo add path object (freehand/cubic/quadricbeziercurve
+ }
+ else if ( localName == "notes" && ns == ooNS::presentation ) // notes
+ {
+ QDomNode textBox = KoDom::namedItemNS( o, ooNS::draw, "text-box" );
+ if ( !textBox.isNull() )
+ {
+ QString note;
+ QDomElement t;
+ forEachElement( t, textBox )
+ {
+ // We don't care about styles as they are not supported in kpresenter.
+ // Only add a linebreak for every child.
+ note += t.text() + "\n";
+ }
+ QDomElement notesElement = doc.createElement( "Note" );
+ notesElement.setAttribute( "note", note );
+ pageNoteElement.appendChild( notesElement );
+ }
+ }
+ else
+ {
+ kdDebug(30518) << "Unsupported object '" << localName << "'" << endl;
+ m_styleStack.restore();
+ continue;
+ }
+
+ objectElement.appendChild( e );
+ m_styleStack.restore();
+ }
+}
+
+void OoImpressImport::appendBackgroundPage( QDomDocument &doc, QDomElement &backgroundElement, QDomElement & pictureElement, QDomElement &soundElement)
+{
+ QDomElement bgPage = doc.createElement( "PAGE" );
+
+ // background
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "fill" ) )
+ {
+ const QString fill = m_styleStack.attributeNS( ooNS::draw, "fill" );
+ if ( fill == "solid" )
+ {
+ QDomElement backColor1 = doc.createElement( "BACKCOLOR1" );
+ backColor1.setAttribute( "color", m_styleStack.attributeNS( ooNS::draw, "fill-color" ) );
+ bgPage.appendChild( backColor1 );
+
+ QDomElement bcType = doc.createElement( "BCTYPE" );
+ bcType.setAttribute( "value", 0 ); // plain
+ bgPage.appendChild( bcType );
+
+ QDomElement backType = doc.createElement( "BACKTYPE" );
+ backType.setAttribute( "value", 0 ); // color/gradient
+ bgPage.appendChild( backType );
+ }
+ else if ( fill == "gradient" )
+ {
+ QString style = m_styleStack.attributeNS( ooNS::draw, "fill-gradient-name" );
+ QDomElement* draw = m_draws[style];
+ appendBackgroundGradient( doc, bgPage, *draw );
+ }
+ else if ( fill == "bitmap" )
+ {
+ QString style = m_styleStack.attributeNS( ooNS::draw, "fill-image-name" );
+ QDomElement* draw = m_draws[style];
+ appendBackgroundImage( doc, bgPage, pictureElement, *draw );
+
+ QDomElement backView = doc.createElement( "BACKVIEW" );
+ if ( m_styleStack.hasAttributeNS( ooNS::style, "repeat" ) )
+ {
+ QString repeat = m_styleStack.attributeNS( ooNS::style, "repeat" );
+ if ( repeat == "stretch" )
+ backView.setAttribute( "value", 0 ); // zoomed
+ else if ( repeat == "no-repeat" )
+ backView.setAttribute( "value", 1 ); // centered
+ else
+ backView.setAttribute( "value", 2 ); // use tiled as default
+ }
+ else
+ backView.setAttribute( "value", 2 ); // use tiled as default
+ bgPage.appendChild( backView );
+
+ QDomElement backType = doc.createElement( "BACKTYPE" );
+ backType.setAttribute( "value", 1 ); // image
+ bgPage.appendChild( backType );
+ }
+ }
+
+ if ( m_styleStack.hasAttributeNS( ooNS::presentation, "duration" ) )
+ {
+ QString str = m_styleStack.attributeNS( ooNS::presentation, "duration");
+ kdDebug(30518)<<"styleStack.hasAttribute(presentation:duration ) :"<<str<<endl;
+ //convert date duration
+ int hour( str.mid( 2, 2 ).toInt() );
+ int minute( str.mid( 5, 2 ).toInt() );
+ int second( str.mid( 8, 2 ).toInt() );
+ int pageTimer = second + minute*60 + hour*60*60;
+ QDomElement pgEffect = doc.createElement("PGTIMER");
+ pgEffect.setAttribute( "timer", pageTimer );
+ bgPage.appendChild(pgEffect);
+ }
+ // slide transition
+ if (m_styleStack.hasAttributeNS( ooNS::presentation, "transition-style"))
+ {
+ QDomElement pgEffect = doc.createElement("PGEFFECT");
+
+ const QString effect = m_styleStack.attributeNS( ooNS::presentation, "transition-style");
+ //kdDebug(30518) << "Transition name: " << effect << endl;
+ int pef;
+
+ if (effect=="vertical-stripes" || effect=="vertical-lines") // PEF_BLINDS_VER
+ pef=14;
+ else if (effect=="horizontal-stripes" || effect=="horizontal-lines") // PEF_BLINDS_HOR
+ pef=13;
+ else if (effect=="spiralin-left" || effect=="spiralin-right"
+ || effect== "spiralout-left" || effect=="spiralout-right") // PEF_SURROUND1
+ pef=11;
+ else if (effect=="fade-from-upperleft") // PEF_STRIPS_RIGHT_DOWN
+ pef=39;
+ else if (effect=="fade-from-upperright") // PEF_STRIPS_LEFT_DOWN
+ pef=37;
+ else if (effect=="fade-from-lowerleft") // PEF_STRIPS_RIGHT_UP
+ pef=38;
+ else if (effect=="fade-from-lowerright") // PEF_STRIPS_LEFT_UP
+ pef=36;
+ else if (effect=="fade-from-top") // PEF_COVER_DOWN
+ pef=19;
+ else if (effect=="fade-from-bottom") // PEF_COVER_UP
+ pef=21;
+ else if (effect=="fade-from-left") // PEF_COVER_RIGHT
+ pef=25;
+ else if (effect=="fade-from-right") // PEF_COVER_LEFT
+ pef=23;
+ else if (effect=="fade-to-center") // PEF_CLOSE_ALL
+ pef=3;
+ else if (effect=="fade-from-center") // PEF_OPEN_ALL
+ pef=6;
+ else if (effect=="open-vertical") // PEF_OPEN_HORZ; really, no kidding ;)
+ pef=4;
+ else if (effect=="open-horizontal") // PEF_OPEN_VERT
+ pef=5;
+ else if (effect=="close-vertical") // PEF_CLOSE_HORZ
+ pef=1;
+ else if (effect=="close-horizontal") // PEF_CLOSE_VERT
+ pef=2;
+ else if (effect=="dissolve") // PEF_DISSOLVE; perfect hit ;)
+ pef=35;
+ else if (effect=="horizontal-checkerboard") // PEF_CHECKBOARD_ACROSS
+ pef=17;
+ else if (effect=="vertical-checkerboard") // PEF_CHECKBOARD_DOWN
+ pef=18;
+ else if (effect=="roll-from-left") // PEF_UNCOVER_RIGHT
+ pef=26;
+ else if (effect=="roll-from-right") // PEF_UNCOVER_LEFT
+ pef=24;
+ else if (effect=="roll-from-bottom") // PEF_UNCOVER_UP
+ pef=22;
+ else if (effect=="roll-from-top") // PEF_UNCOVER_DOWN
+ pef=20;
+ else if (effect=="random") // PEF_RANDOM
+ pef=-1;
+ else // we choose a random transition instead of the unsupported ones ;)
+ pef=-1;
+
+ pgEffect.setAttribute("value", pef);
+ bgPage.appendChild(pgEffect);
+ }
+
+ // slide transition sound
+ if (m_styleStack.hasChildNodeNS( ooNS::presentation, "sound"))
+ {
+ QString soundUrl = storeSound(m_styleStack.childNodeNS( ooNS::presentation, "sound"),
+ soundElement, doc);
+
+ if (!soundUrl.isNull())
+ {
+ QDomElement pseElem = doc.createElement("PGSOUNDEFFECT");
+ pseElem.setAttribute("soundEffect", 1);
+ pseElem.setAttribute("soundFileName", soundUrl);
+
+ bgPage.appendChild(pseElem);
+ }
+ }
+
+ backgroundElement.appendChild(bgPage);
+}
+
+void OoImpressImport::appendName(QDomDocument& doc, QDomElement& e, const QDomElement& object)
+{
+ if( object.hasAttributeNS( ooNS::draw, "name" ))
+ {
+ QDomElement name = doc.createElement( "OBJECTNAME" );
+ name.setAttribute( "objectName", object.attributeNS( ooNS::draw, "name", QString::null ));
+ e.appendChild( name );
+ }
+}
+
+void OoImpressImport::append2DGeometry( QDomDocument& doc, QDomElement& e, const QDomElement& object, int offset )
+{
+ QDomElement orig = doc.createElement( "ORIG" );
+ orig.setAttribute( "x", KoUnit::parseValue( object.attributeNS( ooNS::svg, "x", QString::null ) ) );
+ orig.setAttribute( "y", KoUnit::parseValue( object.attributeNS( ooNS::svg, "y", QString::null ) ) + offset );
+ e.appendChild( orig );
+
+ QDomElement size = doc.createElement( "SIZE" );
+ size.setAttribute( "width", KoUnit::parseValue( object.attributeNS( ooNS::svg, "width", QString::null ) ) );
+ size.setAttribute( "height", KoUnit::parseValue( object.attributeNS( ooNS::svg, "height", QString::null ) ) );
+ e.appendChild( size );
+ if( object.hasAttributeNS( ooNS::draw, "transform" ))
+ {
+ kdDebug(30518)<<" object transform \n";
+ //todo parse it
+ QString transform = object.attributeNS( ooNS::draw, "transform", QString::null );
+ if( transform.contains("rotate ("))
+ {
+ //kdDebug(30518)<<" rotate object \n";
+ transform = transform.remove("rotate (" );
+ transform = transform.left(transform.find(")"));
+ //kdDebug(30518)<<" transform :"<<transform<<endl;
+ bool ok;
+ double radian = transform.toDouble(&ok);
+ if( ok )
+ {
+ QDomElement angle = doc.createElement( "ANGLE" );
+ //angle is defined as a radian in oo but degree into kpresenter.
+ angle.setAttribute("value", (-1 * ((radian*180)/M_PI)));
+
+ e.appendChild( angle );
+ }
+ }
+ }
+}
+
+//return true if (x1 < x2) necessary to load correctly start-line and end-line
+bool OoImpressImport::appendLineGeometry( QDomDocument& doc, QDomElement& e, const QDomElement& object, int offset )
+{
+ double x1 = KoUnit::parseValue( object.attributeNS( ooNS::svg, "x1", QString::null ) );
+ double y1 = KoUnit::parseValue( object.attributeNS( ooNS::svg, "y1", QString::null ) );
+ double x2 = KoUnit::parseValue( object.attributeNS( ooNS::svg, "x2", QString::null ) );
+ double y2 = KoUnit::parseValue( object.attributeNS( ooNS::svg, "y2", QString::null ) );
+
+ double x = QMIN( x1, x2 );
+ double y = QMIN( y1, y2 );
+
+ QDomElement orig = doc.createElement( "ORIG" );
+ orig.setAttribute( "x", x );
+ orig.setAttribute( "y", y + offset );
+ e.appendChild( orig );
+
+ QDomElement size = doc.createElement( "SIZE" );
+ size.setAttribute( "width", fabs( x1 - x2 ) );
+ size.setAttribute( "height", fabs( y1 - y2 ) );
+ e.appendChild( size );
+
+ QDomElement linetype = doc.createElement( "LINETYPE" );
+ if ( ( x1 < x2 && y1 < y2 ) || ( x1 > x2 && y1 > y2 ) )
+ linetype.setAttribute( "value", 2 );
+ else
+ linetype.setAttribute( "value", 3 );
+
+ e.appendChild( linetype );
+ return (x1 < x2);
+}
+
+void OoImpressImport::appendPen( QDomDocument& doc, QDomElement& e )
+{
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "stroke" ))
+ {
+ QDomElement pen = doc.createElement( "PEN" );
+ if ( m_styleStack.attributeNS( ooNS::draw, "stroke" ) == "none" )
+ pen.setAttribute( "style", 0 );
+ else if ( m_styleStack.attributeNS( ooNS::draw, "stroke" ) == "solid" )
+ pen.setAttribute( "style", 1 );
+ else if ( m_styleStack.attributeNS( ooNS::draw, "stroke" ) == "dash" )
+ {
+ QString style = m_styleStack.attributeNS( ooNS::draw, "stroke-dash" );
+ if ( style == "Ultrafine Dashed" || style == "Fine Dashed" ||
+ style == "Fine Dashed (var)" || style == "Dashed (var)" )
+ pen.setAttribute( "style", 2 );
+ else if ( style == "Fine Dotted" || style == "Ultrafine Dotted (var)" ||
+ style == "Line with Fine Dots" )
+ pen.setAttribute( "style", 3 );
+ else if ( style == "3 Dashes 3 Dots (var)" || style == "Ultrafine 2 Dots 3 Dashes" )
+ pen.setAttribute( "style", 4 );
+ else if ( style == "2 Dots 1 Dash" )
+ pen.setAttribute( "style", 5 );
+ }
+
+ if ( m_styleStack.hasAttributeNS( ooNS::svg, "stroke-width" ) )
+ pen.setAttribute( "width", (int) KoUnit::parseValue( m_styleStack.attributeNS( ooNS::svg, "stroke-width" ) ) );
+ if ( m_styleStack.hasAttributeNS( ooNS::svg, "stroke-color" ) )
+ pen.setAttribute( "color", m_styleStack.attributeNS( ooNS::svg, "stroke-color" ) );
+ e.appendChild( pen );
+ }
+}
+
+void OoImpressImport::appendBrush( QDomDocument& doc, QDomElement& e )
+{
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "fill" ) )
+ {
+ const QString fill = m_styleStack.attributeNS( ooNS::draw, "fill" );
+ //kdDebug(30518)<<"void OoImpressImport::appendBrush( QDomDocument& doc, QDomElement& e ) :"<<fill<<endl;
+ if ( fill == "solid" )
+ {
+ QDomElement brush = doc.createElement( "BRUSH" );
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "transparency" ) )
+ {
+ QString transparency = m_styleStack.attributeNS( ooNS::draw, "transparency" );
+ transparency = transparency.remove( '%' );
+ int value = transparency.toInt();
+ if ( value >= 94 && value <= 99 )
+ {
+ brush.setAttribute( "style", 2 );
+ }
+ else if ( value>=64 && value <= 93 )
+ {
+ brush.setAttribute( "style", 3 );
+ }
+ else if ( value>=51 && value <= 63 )
+ {
+ brush.setAttribute( "style", 4 );
+ }
+ else if ( value>=38 && value <= 50 )
+ {
+ brush.setAttribute( "style", 5 );
+ }
+ else if ( value>=13 && value <= 37 )
+ {
+ brush.setAttribute( "style", 6 );
+ }
+ else if ( value>=7 && value <= 12 )
+ {
+ brush.setAttribute( "style", 7 );
+ }
+ else if ( value>=1 && value <= 6 )
+ {
+ brush.setAttribute( "style", 8 );
+ }
+ }
+ else
+ brush.setAttribute( "style", 1 );
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "fill-color" ) )
+ brush.setAttribute( "color", m_styleStack.attributeNS( ooNS::draw, "fill-color" ) );
+ e.appendChild( brush );
+ }
+ else if ( fill == "hatch" )
+ {
+ QDomElement brush = doc.createElement( "BRUSH" );
+ QString style = m_styleStack.attributeNS( ooNS::draw, "fill-hatch-name" );
+ QDomElement* draw = m_draws[style];
+ if ( draw )
+ {
+ if( draw->hasAttributeNS( ooNS::draw, "color" ) )
+ brush.setAttribute( "color", draw->attributeNS( ooNS::draw, "color", QString::null ) );
+ int angle = 0;
+ if( draw->hasAttributeNS( ooNS::draw, "rotation" ))
+ {
+ angle = (draw->attributeNS( ooNS::draw, "rotation", QString::null ).toInt())/10;
+ kdDebug(30518)<<"angle :"<<angle<<endl;
+ }
+ if( draw->hasAttributeNS( ooNS::draw, "style" ))
+ {
+ QString styleHash = draw->attributeNS( ooNS::draw, "style", QString::null );
+ if( styleHash == "single")
+ {
+ switch( angle )
+ {
+ case 0:
+ case 180:
+ brush.setAttribute( "style", 9 );
+ break;
+ case 45:
+ case 225:
+ brush.setAttribute( "style", 12 );
+ break;
+ case 90:
+ case 270:
+ brush.setAttribute( "style", 10 );
+ break;
+ case 135:
+ case 315:
+ brush.setAttribute( "style", 13 );
+ break;
+ default:
+ //todo fixme when we will have a kopaint
+ kdDebug(30518)<<" draw:rotation 'angle' : "<<angle<<endl;
+ break;
+ }
+ }
+ else if( styleHash == "double")
+ {
+ switch( angle )
+ {
+ case 0:
+ case 180:
+ case 90:
+ case 270:
+ brush.setAttribute("style", 11 );
+ break;
+ case 45:
+ case 135:
+ case 225:
+ case 315:
+ brush.setAttribute("style",14 );
+ break;
+ default:
+ //todo fixme when we will have a kopaint
+ kdDebug(30518)<<" draw:rotation 'angle' : "<<angle<<endl;
+ break;
+ }
+
+ }
+ else if( styleHash == "triple")
+ {
+ kdDebug(30518)<<" it is not implemented :( \n";
+ }
+
+ }
+ }
+ e.appendChild( brush );
+ }
+ else if ( fill == "gradient" )
+ {
+ // We have to set a brush with brushstyle != no background fill
+ // otherwise the properties dialog for the object won't
+ // display the preview for the gradient.
+ QDomElement brush = doc.createElement( "BRUSH" );
+ brush.setAttribute( "style", 1 );
+ e.appendChild( brush );
+
+ QDomElement gradient = doc.createElement( "GRADIENT" );
+ QString style = m_styleStack.attributeNS( ooNS::draw, "fill-gradient-name" );
+
+ QDomElement* draw = m_draws[style];
+ if ( draw )
+ {
+ gradient.setAttribute( "color1", draw->attributeNS( ooNS::draw, "start-color", QString::null ) );
+ gradient.setAttribute( "color2", draw->attributeNS( ooNS::draw, "end-color", QString::null ) );
+
+ QString type = draw->attributeNS( ooNS::draw, "style", QString::null );
+ //kdDebug(30518)<<" type !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :"<<type<<endl;
+ if ( type == "linear" )
+ {
+ int angle = draw->attributeNS( ooNS::draw, "angle", QString::null ).toInt() / 10;
+
+ // make sure the angle is between 0 and 359
+ angle = abs( angle );
+ angle -= ( (int) ( angle / 360 ) ) * 360;
+
+ // What we are trying to do here is to find out if the given
+ // angle belongs to a horizontal, vertical or diagonal gradient.
+ int lower, upper, nearAngle = 0;
+ for ( lower = 0, upper = 45; upper < 360; lower += 45, upper += 45 )
+ {
+ if ( upper >= angle )
+ {
+ int distanceToUpper = abs( angle - upper );
+ int distanceToLower = abs( angle - lower );
+ nearAngle = distanceToUpper > distanceToLower ? lower : upper;
+ break;
+ }
+ }
+ kdDebug(30518)<<"nearAngle :"<<nearAngle<<endl;
+ // nearAngle should now be one of: 0, 45, 90, 135, 180...
+ if ( nearAngle == 0 || nearAngle == 180 )
+ gradient.setAttribute( "type", 1 ); // horizontal
+ else if ( nearAngle == 90 || nearAngle == 270 )
+ gradient.setAttribute( "type", 2 ); // vertical
+ else if ( nearAngle == 45 || nearAngle == 225 )
+ gradient.setAttribute( "type", 3 ); // diagonal 1
+ else if ( nearAngle == 135 || nearAngle == 315 )
+ gradient.setAttribute( "type", 4 ); // diagonal 2
+ }
+ else if ( type == "radial" || type == "ellipsoid" )
+ gradient.setAttribute( "type", 5 ); // circle
+ else if ( type == "square" || type == "rectangular" )
+ gradient.setAttribute( "type", 6 ); // rectangle
+ else if ( type == "axial" )
+ gradient.setAttribute( "type", 7 ); // pipecross
+
+ // Hard to map between x- and y-center settings of ooimpress
+ // and (un-)balanced settings of kpresenter. Let's try it.
+ int x, y;
+ if ( draw->hasAttributeNS( ooNS::draw, "cx" ) )
+ x = draw->attributeNS( ooNS::draw, "cx", QString::null ).remove( '%' ).toInt();
+ else
+ x = 50;
+
+ if ( draw->hasAttributeNS( ooNS::draw, "cy" ) )
+ y = draw->attributeNS( ooNS::draw, "cy", QString::null ).remove( '%' ).toInt();
+ else
+ y = 50;
+
+ if ( x == 50 && y == 50 )
+ {
+ gradient.setAttribute( "unbalanced", 0 );
+ gradient.setAttribute( "xfactor", 100 );
+ gradient.setAttribute( "yfactor", 100 );
+ }
+ else
+ {
+ gradient.setAttribute( "unbalanced", 1 );
+ // map 0 - 100% to -200 - 200
+ gradient.setAttribute( "xfactor", 4 * x - 200 );
+ gradient.setAttribute( "yfactor", 4 * y - 200 );
+ }
+ }
+ e.appendChild( gradient );
+
+ QDomElement fillType = doc.createElement( "FILLTYPE" );
+ fillType.setAttribute( "value", 1 );
+ e.appendChild( fillType );
+ }
+ }
+}
+
+void OoImpressImport::appendPie( QDomDocument& doc, QDomElement& e, const QDomElement& object )
+{
+ QDomElement angle = doc.createElement( "PIEANGLE" );
+ int start = (int) ( object.attributeNS( ooNS::draw, "start-angle", QString::null ).toDouble() );
+ angle.setAttribute( "value", start * 16 );
+ e.appendChild( angle );
+
+ QDomElement length = doc.createElement( "PIELENGTH" );
+ int end = (int) ( object.attributeNS( ooNS::draw, "end-angle", QString::null ).toDouble() );
+ if ( end < start )
+ length.setAttribute( "value", ( 360 - start + end ) * 16 );
+ else
+ length.setAttribute( "value", ( end - start ) * 16 );
+ e.appendChild( length );
+}
+
+void OoImpressImport::appendImage( QDomDocument& doc, QDomElement& e, QDomElement& p,
+ const QDomElement& object )
+{
+ QString fileName = storeImage( object );
+
+ // create a key for the picture
+ QTime time = QTime::currentTime();
+ QDate date = QDate::currentDate();
+
+ QDomElement image = doc.createElement( "KEY" );
+ image.setAttribute( "msec", time.msec() );
+ image.setAttribute( "second", time.second() );
+ image.setAttribute( "minute", time.minute() );
+ image.setAttribute( "hour", time.hour() );
+ image.setAttribute( "day", date.day() );
+ image.setAttribute( "month", date.month() );
+ image.setAttribute( "year", date.year() );
+ image.setAttribute( "filename", fileName );
+ e.appendChild( image );
+
+ QDomElement settings = doc.createElement( "PICTURESETTINGS" );
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "color-mode" ) && ( m_styleStack.attributeNS( ooNS::draw, "color-mode" )=="greyscale" ) )
+ settings.setAttribute( "grayscal", 1 );
+ else
+ settings.setAttribute( "grayscal", 0 );
+
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "luminance" ) )
+ {
+ QString str( m_styleStack.attributeNS( ooNS::draw, "luminance" ) );
+ str = str.remove( '%' );
+ settings.setAttribute( "bright", str );
+ }
+ else
+ settings.setAttribute( "bright", 0 );
+
+ settings.setAttribute( "mirrorType", 0 );
+ settings.setAttribute( "swapRGB", 0 );
+ settings.setAttribute( "depth", 0 );
+ e.appendChild( settings );
+
+ QDomElement effects = doc.createElement( "EFFECTS" );
+ bool hasEffect = false;
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "contrast" ) )
+ {
+ QString str( m_styleStack.attributeNS( ooNS::draw, "contrast" ) );
+ str = str.remove( '%' );
+ int val = str.toInt();
+ val = ( int )( 255.0 *val/100.0 );
+ effects.setAttribute( "type", "5" );
+ effects.setAttribute( "param1", QString::number( val ) );
+ hasEffect = true;
+ }
+ if ( hasEffect )
+ e.appendChild( effects );
+
+ QDomElement key = image.cloneNode().toElement();
+ key.setAttribute( "name", "pictures/" + fileName );
+ p.appendChild( key );
+}
+
+void OoImpressImport::appendBackgroundImage( QDomDocument& doc, QDomElement& e,
+ QDomElement& p, const QDomElement& object )
+{
+ QString fileName = storeImage( object );
+
+ // create a key for the picture
+ QTime time = QTime::currentTime();
+ QDate date = QDate::currentDate();
+
+ QDomElement image = doc.createElement( "BACKPICTUREKEY" );
+ image.setAttribute( "msec", time.msec() );
+ image.setAttribute( "second", time.second() );
+ image.setAttribute( "minute", time.minute() );
+ image.setAttribute( "hour", time.hour() );
+ image.setAttribute( "day", date.day() );
+ image.setAttribute( "month", date.month() );
+ image.setAttribute( "year", date.year() );
+ image.setAttribute( "filename", fileName );
+ e.appendChild( image );
+
+ QDomElement key = image.cloneNode().toElement();
+ key.setTagName( "KEY" );
+ key.setAttribute( "name", "pictures/" + fileName );
+ p.appendChild( key );
+}
+
+void OoImpressImport::appendBackgroundGradient( QDomDocument& doc, QDomElement& e,
+ const QDomElement& object )
+{
+ QDomElement backColor1 = doc.createElement( "BACKCOLOR1" );
+ backColor1.setAttribute( "color", object.attributeNS( ooNS::draw, "start-color", QString::null ) );
+ e.appendChild( backColor1 );
+
+ QDomElement backColor2 = doc.createElement( "BACKCOLOR2" );
+ backColor2.setAttribute( "color", object.attributeNS( ooNS::draw, "end-color", QString::null ) );
+ e.appendChild( backColor2 );
+
+ QDomElement backType = doc.createElement( "BACKTYPE" );
+ backType.setAttribute( "value", 0 ); // color/gradient
+ e.appendChild( backType );
+
+ QDomElement bcType = doc.createElement( "BCTYPE" );
+ QString type = object.attributeNS( ooNS::draw, "style", QString::null );
+ if ( type == "linear" )
+ {
+ int angle = object.attributeNS( ooNS::draw, "angle", QString::null ).toInt() / 10;
+
+ // make sure the angle is between 0 and 359
+ angle = abs( angle );
+ angle -= ( (int) ( angle / 360 ) ) * 360;
+
+ // What we are trying to do here is to find out if the given
+ // angle belongs to a horizontal, vertical or diagonal gradient.
+ int lower, upper, nearAngle = 0;
+ for ( lower = 0, upper = 45; upper < 360; lower += 45, upper += 45 )
+ {
+ if ( upper >= angle )
+ {
+ int distanceToUpper = abs( angle - upper );
+ int distanceToLower = abs( angle - lower );
+ nearAngle = distanceToUpper > distanceToLower ? lower : upper;
+ break;
+ }
+ }
+
+ // nearAngle should now be one of: 0, 45, 90, 135, 180...
+ if ( nearAngle == 0 || nearAngle == 180 )
+ bcType.setAttribute( "value", 1 ); // horizontal
+ else if ( nearAngle == 90 || nearAngle == 270 )
+ bcType.setAttribute( "value", 2 ); // vertical
+ else if ( nearAngle == 45 || nearAngle == 225 )
+ bcType.setAttribute( "value", 3 ); // diagonal 1
+ else if ( nearAngle == 135 || nearAngle == 315 )
+ bcType.setAttribute( "value", 4 ); // diagonal 2
+ }
+ else if ( type == "radial" || type == "ellipsoid" )
+ bcType.setAttribute( "value", 5 ); // circle
+ else if ( type == "square" || type == "rectangular" )
+ bcType.setAttribute( "value", 6 ); // rectangle
+ else if ( type == "axial" )
+ bcType.setAttribute( "value", 7 ); // pipecross
+
+ e.appendChild( bcType );
+
+ QDomElement bGradient = doc.createElement( "BGRADIENT" );
+
+ // Hard to map between x- and y-center settings of ooimpress
+ // and (un-)balanced settings of kpresenter. Let's try it.
+ int x, y;
+ if ( object.hasAttributeNS( ooNS::draw, "cx" ) )
+ x = object.attributeNS( ooNS::draw, "cx", QString::null ).remove( '%' ).toInt();
+ else
+ x = 50;
+
+ if ( object.hasAttributeNS( ooNS::draw, "cy" ) )
+ y = object.attributeNS( ooNS::draw, "cy", QString::null ).remove( '%' ).toInt();
+ else
+ y = 50;
+
+ if ( x == 50 && y == 50 )
+ {
+ bGradient.setAttribute( "unbalanced", 0 );
+ bGradient.setAttribute( "xfactor", 100 );
+ bGradient.setAttribute( "yfactor", 100 );
+ }
+ else
+ {
+ bGradient.setAttribute( "unbalanced", 1 );
+ // map 0 - 100% to -200 - 200
+ bGradient.setAttribute( "xfactor", 4 * x - 200 );
+ bGradient.setAttribute( "yfactor", 4 * y - 200 );
+ }
+
+ e.appendChild( bGradient );
+}
+
+void OoImpressImport::appendRounding( QDomDocument& doc, QDomElement& e, const QDomElement& object )
+{
+ if ( object.hasAttributeNS( ooNS::draw, "corner-radius" ) )
+ {
+ // kpresenter uses percent, ooimpress uses cm ... hmm?
+ QDomElement rounding = doc.createElement( "RNDS" );
+ int corner = static_cast<int>(KoUnit::parseValue(object.attributeNS( ooNS::draw, "corner-radius", QString::null)));
+ rounding.setAttribute( "x", corner );
+ rounding.setAttribute( "y", corner );
+ e.appendChild( rounding );
+ }
+}
+
+void OoImpressImport::appendShadow( QDomDocument& doc, QDomElement& e )
+{
+ // Note that ooimpress makes a difference between shadowed text and
+ // a shadowed object while kpresenter only knows the attribute 'shadow'.
+ // This means that a shadowed textobject in kpresenter will always show
+ // a shadowed text but no shadow for the object itself.
+
+ // make sure this is a textobject or textspan
+ if ( !e.hasAttribute( "type" ) ||
+ ( e.hasAttribute( "type" ) && e.attribute( "type" ) == "4" ) )
+ {
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "text-shadow" ) &&
+ m_styleStack.attributeNS( ooNS::fo, "text-shadow" ) != "none" )
+ {
+ // use the shadow attribute to indicate a text-shadow
+ QDomElement shadow = doc.createElement( "SHADOW" );
+ QString distance = m_styleStack.attributeNS( ooNS::fo, "text-shadow" );
+ distance.truncate( distance.find( ' ' ) );
+ shadow.setAttribute( "distance", KoUnit::parseValue( distance ) );
+ shadow.setAttribute( "direction", 5 );
+ shadow.setAttribute( "color", "#a0a0a0" );
+ e.appendChild( shadow );
+ }
+ }
+ else if ( m_styleStack.hasAttributeNS( ooNS::draw, "shadow" ) &&
+ m_styleStack.attributeNS( ooNS::draw, "shadow" ) == "visible" )
+ {
+ // use the shadow attribute to indicate an object-shadow
+ QDomElement shadow = doc.createElement( "SHADOW" );
+ double x = KoUnit::parseValue( m_styleStack.attributeNS( ooNS::draw, "shadow-offset-x" ) );
+ double y = KoUnit::parseValue( m_styleStack.attributeNS( ooNS::draw, "shadow-offset-y" ) );
+
+ if ( x < 0 && y < 0 )
+ {
+ shadow.setAttribute( "direction", 1 );
+ shadow.setAttribute( "distance", (int) fabs ( x ) );
+ }
+ else if ( x == 0 && y < 0 )
+ {
+ shadow.setAttribute( "direction", 2 );
+ shadow.setAttribute( "distance", (int) fabs ( y ) );
+ }
+ else if ( x > 0 && y < 0 )
+ {
+ shadow.setAttribute( "direction", 3 );
+ shadow.setAttribute( "distance", (int) fabs ( x ) );
+ }
+ else if ( x > 0 && y == 0 )
+ {
+ shadow.setAttribute( "direction", 4 );
+ shadow.setAttribute( "distance", (int) fabs ( x ) );
+ }
+ else if ( x > 0 && y > 0 )
+ {
+ shadow.setAttribute( "direction", 5 );
+ shadow.setAttribute( "distance", (int) fabs ( x ) );
+ }
+ else if ( x == 0 && y > 0 )
+ {
+ shadow.setAttribute( "direction", 6 );
+ shadow.setAttribute( "distance", (int) fabs ( y ) );
+ }
+ else if ( x < 0 && y > 0 )
+ {
+ shadow.setAttribute( "direction", 7 );
+ shadow.setAttribute( "distance", (int) fabs ( x ) );
+ }
+ else if ( x < 0 && y == 0 )
+ {
+ shadow.setAttribute( "direction", 8 );
+ shadow.setAttribute( "distance", (int) fabs ( x ) );
+ }
+
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "shadow-color" ) )
+ shadow.setAttribute( "color", m_styleStack.attributeNS( ooNS::draw, "shadow-color" ) );
+
+ e.appendChild( shadow );
+ }
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "size-protect" ) || m_styleStack.hasAttributeNS( ooNS::draw, "move-protect" ) )
+ {
+ bool b = ( m_styleStack.attributeNS( ooNS::draw, "size-protect" ) == "true" ) || ( m_styleStack.attributeNS( ooNS::draw, "move-protect" ) == "true" );
+ if ( b )
+ {
+ QDomElement protect = doc.createElement( "PROTECT" );
+ protect.setAttribute("state" , b);
+ e.appendChild(protect);
+ }
+ }
+}
+
+void OoImpressImport::appendLineEnds( QDomDocument& doc, QDomElement& e, bool orderEndStartLine)
+{
+ const char* attr = orderEndStartLine ? "marker-start" : "marker-end";
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, attr ) )
+ {
+ QDomElement lineBegin = doc.createElement( "LINEBEGIN" );
+ QString type = m_styleStack.attributeNS( ooNS::draw, attr );
+ if ( type == "Arrow" || type == "Small Arrow" || type == "Rounded short Arrow" ||
+ type == "Symmetric Arrow" || type == "Rounded large Arrow" || type == "Arrow concave" )
+ lineBegin.setAttribute( "value", 1 );
+ else if ( type == "Square" )
+ lineBegin.setAttribute( "value", 2 );
+ else if ( type == "Circle" || type == "Square 45" )
+ lineBegin.setAttribute( "value", 3 );
+ else if ( type == "Line Arrow" )
+ lineBegin.setAttribute( "value", 4 );
+ else if ( type == "Dimension Lines" )
+ lineBegin.setAttribute( "value", 5 );
+ else if ( type == "Double Arrow" )
+ lineBegin.setAttribute( "value", 6 );
+ e.appendChild( lineBegin );
+ }
+ attr = orderEndStartLine ? "marker-end" : "marker-start";
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, attr ) )
+ {
+ QDomElement lineEnd = doc.createElement( "LINEEND" );
+ QString type = m_styleStack.attributeNS( ooNS::draw, attr );
+ if ( type == "Arrow" || type == "Small Arrow" || type == "Rounded short Arrow" ||
+ type == "Symmetric Arrow" || type == "Rounded large Arrow" || type == "Arrow concave" )
+ lineEnd.setAttribute( "value", 1 );
+ else if ( type == "Square" )
+ lineEnd.setAttribute( "value", 2 );
+ else if ( type == "Circle" || type == "Square 45" )
+ lineEnd.setAttribute( "value", 3 );
+ else if ( type == "Line Arrow" )
+ lineEnd.setAttribute( "value", 4 );
+ else if ( type == "Dimension Lines" )
+ lineEnd.setAttribute( "value", 5 );
+ else if ( type == "Double Arrow" )
+ lineEnd.setAttribute( "value", 6 );
+ e.appendChild( lineEnd );
+ }
+}
+
+void OoImpressImport::appendTextObjectMargin( QDomDocument& /*doc*/, QDomElement& e )
+{
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "padding" ) )
+ {
+ double tmpValue = KoUnit::parseValue(m_styleStack.attributeNS( ooNS::fo, "padding" ) );
+ e.setAttribute( "btoppt", tmpValue );
+ e.setAttribute( "bbottompt", tmpValue );
+ e.setAttribute( "bleftpt", tmpValue );
+ e.setAttribute( "brightpt", tmpValue );
+ }
+ else
+ {
+ if( m_styleStack.hasAttributeNS( ooNS::fo, "padding-top" ) )
+ e.setAttribute( "btoppt", KoUnit::parseValue( m_styleStack.attributeNS( ooNS::fo, "padding-top" ) ) );
+ if( m_styleStack.hasAttributeNS( ooNS::fo, "padding-bottom" ) )
+ e.setAttribute( "bbottompt", KoUnit::parseValue( m_styleStack.attributeNS( ooNS::fo, "padding-bottom" ) ) );
+ if( m_styleStack.hasAttributeNS( ooNS::fo, "padding-left" ) )
+ e.setAttribute( "bleftpt", KoUnit::parseValue( m_styleStack.attributeNS( ooNS::fo, "padding-left" ) ) );
+ if( m_styleStack.hasAttributeNS( ooNS::fo, "padding-right" ) )
+ e.setAttribute( "brightpt", KoUnit::parseValue( m_styleStack.attributeNS( ooNS::fo, "padding-right" ) ) );
+ }
+}
+
+QDomElement OoImpressImport::parseTextBox( QDomDocument& doc, const QDomElement& textBox )
+{
+ QDomElement textObjectElement = doc.createElement( "TEXTOBJ" );
+ appendTextObjectMargin( doc, textObjectElement );
+
+ // vertical alignment
+ if ( m_styleStack.hasAttributeNS( ooNS::draw, "textarea-vertical-align" ) )
+ {
+ QString alignment = m_styleStack.attributeNS( ooNS::draw, "textarea-vertical-align" );
+ if ( alignment == "top" )
+ textObjectElement.setAttribute( "verticalAlign", "top" );
+ else if ( alignment == "middle" )
+ textObjectElement.setAttribute( "verticalAlign", "center" );
+ else if ( alignment == "bottom" )
+ textObjectElement.setAttribute( "verticalAlign", "bottom" );
+
+ textObjectElement.setAttribute("verticalValue", 0.0);
+ }
+
+ parseParagraphs( doc, textObjectElement, textBox );
+
+ return textObjectElement;
+}
+
+void OoImpressImport::parseParagraphs( QDomDocument& doc, QDomElement& textObjectElement, const QDomElement& parent )
+{
+ QDomElement t;
+ forEachElement( t, parent )
+ {
+ m_styleStack.save();
+ const QString localName = t.localName();
+ const QString ns = t.namespaceURI();
+ const bool isTextNS = ns == ooNS::text;
+
+ QDomElement e;
+ if ( isTextNS && localName == "p" ) // text paragraph
+ e = parseParagraph( doc, t );
+ else if ( isTextNS && localName == "h" ) // heading - can this happen in ooimpress?
+ {
+ e = parseParagraph( doc, t );
+ }
+ else if ( isTextNS && ( localName == "unordered-list" || localName == "ordered-list" ) )
+ {
+ parseList( doc, textObjectElement, t );
+ m_styleStack.restore();
+ continue;
+ }
+ // TODO text:sequence-decls
+ else
+ {
+ kdDebug(30518) << "Unsupported texttype '" << localName << "'" << endl;
+ }
+
+ if ( !e.isNull() )
+ textObjectElement.appendChild( e );
+ m_styleStack.restore(); // remove the styles added by the paragraph or list
+ }
+}
+
+void OoImpressImport::applyListStyle( QDomElement& paragraph )
+{
+ // Spec: see 3.3.5 p137
+ if ( m_listStyleStack.hasListStyle() && m_nextItemIsListItem ) {
+ //const QDomElement listStyle = m_listStyleStack.currentListStyle();
+ //bool heading = paragraph.localName() == "h";
+ m_nextItemIsListItem = false;
+ /*int level = heading ? paragraph.attributeNS( ooNS::text, "level", QString::null ).toInt()
+ : m_listStyleStack.level();*/
+
+ QDomElement counter = paragraph.ownerDocument().createElement( "COUNTER" );
+ counter.setAttribute( "numberingtype", 0 );
+ counter.setAttribute( "depth", 0 );
+
+ if ( m_insideOrderedList )
+ counter.setAttribute( "type", 1 );
+ else
+ counter.setAttribute( "type", 10 ); // a disc bullet
+ paragraph.appendChild( counter );
+ }
+}
+
+static QDomElement findListLevelStyle( QDomElement& fullListStyle, int level )
+{
+ QDomElement listLevelItem;
+ forEachElement( listLevelItem, fullListStyle )
+ {
+ if ( listLevelItem.attributeNS( ooNS::text, "level", QString::null ).toInt() == level )
+ return listLevelItem;
+ }
+ return QDomElement();
+}
+
+bool OoImpressImport::pushListLevelStyle( const QString& listStyleName, int level )
+{
+ QDomElement* fullListStyle = m_listStyles[listStyleName];
+ if ( !fullListStyle ) {
+ kdWarning(30518) << "List style " << listStyleName << " not found!" << endl;
+ return false;
+ }
+ else
+ return pushListLevelStyle( listStyleName, *fullListStyle, level );
+}
+
+bool OoImpressImport::pushListLevelStyle( const QString& listStyleName, // for debug only
+ QDomElement& fullListStyle, int level )
+{
+ // Find applicable list-level-style for level
+ int i = level;
+ QDomElement listLevelStyle;
+ while ( i > 0 && listLevelStyle.isNull() ) {
+ listLevelStyle = findListLevelStyle( fullListStyle, i );
+ --i;
+ }
+ if ( listLevelStyle.isNull() ) {
+ kdWarning(30518) << "List level style for level " << level << " in list style " << listStyleName << " not found!" << endl;
+ return false;
+ }
+ kdDebug(30518) << "Pushing list-level-style from list-style " << listStyleName << " level " << level << endl;
+ m_listStyleStack.push( listLevelStyle );
+ return true;
+}
+
+void OoImpressImport::parseList( QDomDocument& doc, QDomElement& textObjectElement, const QDomElement& list )
+{
+ //kdDebug(30518) << k_funcinfo << "parseList"<< endl;
+
+ m_insideOrderedList = ( list.localName() == "ordered-list" );
+ QString oldListStyleName = m_currentListStyleName;
+ if ( list.hasAttributeNS( ooNS::text, "style-name" ) )
+ m_currentListStyleName = list.attributeNS( ooNS::text, "style-name", QString::null );
+ bool listOK = !m_currentListStyleName.isEmpty();
+ const int level = m_listStyleStack.level() + 1;
+ //kdDebug(30518) << k_funcinfo << " listOK=" << listOK << " level=" << level << endl;
+ if ( listOK )
+ listOK = pushListLevelStyle( m_currentListStyleName, level );
+
+ // Iterate over list items
+ QDomElement listItem;
+ forEachElement( listItem, list )
+ {
+ // It's either list-header (normal text on top of list) or list-item
+ m_nextItemIsListItem = ( listItem.localName() != "list-header" );
+ m_restartNumbering = -1;
+ if ( listItem.hasAttributeNS( ooNS::text, "start-value" ) )
+ m_restartNumbering = listItem.attributeNS( ooNS::text, "start-value", QString::null ).toInt();
+ // ### Oasis: can be p h or list only.
+ parseParagraphs( doc, textObjectElement, listItem );
+ m_restartNumbering = -1;
+ }
+ if ( listOK )
+ m_listStyleStack.pop();
+ m_currentListStyleName = oldListStyleName;
+}
+
+QDomElement OoImpressImport::parseParagraph( QDomDocument& doc, const QDomElement& paragraph )
+{
+ QDomElement p = doc.createElement( "P" );
+
+ // parse the paragraph-properties
+ fillStyleStack( paragraph );
+
+ // Style name
+ QString styleName = m_styleStack.userStyleName("paragraph");
+ if ( !styleName.isEmpty() )
+ {
+ QDomElement nameElem = doc.createElement("NAME");
+ nameElem.setAttribute("value", styleName);
+ p.appendChild(nameElem);
+ }
+
+ // Paragraph alignment
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "text-align" ) )
+ {
+ QString align = m_styleStack.attributeNS( ooNS::fo, "text-align" );
+ if ( align == "center" )
+ p.setAttribute( "align", 4 );
+ else if ( align == "justify" )
+ p.setAttribute( "align", 8 );
+ else if ( align == "start" )
+ p.setAttribute( "align", 0 );
+ else if ( align == "end" )
+ p.setAttribute( "align", 2 );
+ }
+ else
+ p.setAttribute( "align", 0 ); // use left aligned as default
+
+
+ // Offset before and after paragraph
+ OoUtils::importTopBottomMargin( p, m_styleStack );
+
+ // Indentation (margins)
+ OoUtils::importIndents( p, m_styleStack );
+
+ // Line spacing
+ OoUtils::importLineSpacing( p, m_styleStack );
+
+ // Tabulators
+ OoUtils::importTabulators( p, m_styleStack );
+
+ // Borders
+ OoUtils::importBorders( p, m_styleStack );
+
+ applyListStyle( p );
+
+ uint pos = 0;
+
+ m_styleStack.save();
+ // parse every childnode of the paragraph
+ parseSpanOrSimilar( doc, paragraph, p, pos);
+ m_styleStack.restore(); // remove possible garbage (should not be needed)
+
+ return p;
+}
+
+void OoImpressImport::parseSpanOrSimilar( QDomDocument& doc, const QDomElement& parent,
+ QDomElement& outputParagraph, uint& pos)
+{
+ // Parse every child node of the parent
+ // Can't use forEachElement here since we also care about text nodes
+ for( QDomNode node = parent.firstChild(); !node.isNull(); node = node.nextSibling() )
+ {
+ QDomElement ts = node.toElement();
+ QString textData;
+ const QString localName( ts.localName() );
+ const QString ns = ts.namespaceURI();
+ const bool isTextNS = ns == ooNS::text;
+ QDomText t = node.toText();
+
+ // Try to keep the order of the tag names by probability of happening
+ if ( isTextNS && localName == "span" ) // text:span
+ {
+ m_styleStack.save();
+ fillStyleStack( ts );
+ parseSpanOrSimilar( doc, ts, outputParagraph, pos);
+ m_styleStack.restore();
+ }
+ else if ( isTextNS && localName == "s" ) // text:s
+ {
+ textData = OoUtils::expandWhitespace(ts);
+ }
+ else if ( isTextNS && localName == "tab-stop" ) // text:tab-stop
+ {
+ // KPresenter currently uses \t.
+ // Known bug: a line with only \t\t\t\t isn't loaded - XML (QDom) strips out whitespace.
+ // One more good reason to switch to <text:tab-stop> instead...
+ textData = '\t';
+ }
+ else if ( isTextNS && localName == "line-break" )
+ {
+ textData = '\n';
+ }
+ else if ( localName == "image" && ns == ooNS::draw )
+ {
+ textData = '#'; // anchor placeholder
+ // TODO
+ }
+ else if ( isTextNS && localName == "a" )
+ {
+ m_styleStack.save();
+ QString href( ts.attributeNS( ooNS::xlink, "href", QString::null) );
+ if ( href.startsWith("#") )
+ {
+ // We have a reference to a bookmark (### TODO)
+ // As we do not support it now, treat it as a <text:span> without formatting
+ parseSpanOrSimilar( doc, ts, outputParagraph, pos);
+ }
+ else
+ {
+#if 0 // TODO
+ // The problem is that KPresenter's hyperlink text is not inside the normal text, but for OOWriter it is nearly a <text:span>
+ // So we have to fake.
+ QDomElement fakeParagraph, fakeFormats;
+ uint fakePos=0;
+ QString text;
+ parseSpanOrSimilar( doc, ts, fakeParagraph, fakeFormats, text, fakePos);
+ textData = '#'; // hyperlink placeholder
+ QDomElement linkElement (doc.createElement("LINK"));
+ linkElement.setAttribute("hrefName",ts.attributeNS( ooNS::xlink, "href", QString::null));
+ linkElement.setAttribute("linkName",text);
+ appendVariable(doc, ts, pos, "STRING", 9, text, linkElement);
+#endif
+ }
+ m_styleStack.restore();
+ }
+ else if ( isTextNS &&
+ (localName == "date" // fields
+ || localName == "time"
+ || localName == "page-number"
+ || localName == "file-name"
+ || localName == "author-name"
+ || localName == "author-initials" ) )
+ {
+ textData = "#"; // field placeholder
+ appendField(doc, outputParagraph, ts, pos);
+ }
+ else if ( t.isNull() ) // no textnode, we must ignore
+ {
+ kdWarning(30518) << "Ignoring tag " << ts.tagName() << endl;
+ continue;
+ }
+ else
+ textData = t.data();
+
+ pos += textData.length();
+
+ QDomElement text = saveHelper(textData, doc);
+
+ kdDebug(30518) << k_funcinfo << "Para text is: " << textData << endl;
+
+ if (m_styleStack.hasAttributeNS( ooNS::fo, "language" )) {
+ QString lang = m_styleStack.attributeNS( ooNS::fo, "language" );
+ if (lang=="en")
+ text.setAttribute("language", "en_US");
+ else
+ text.setAttribute("language", lang);
+ }
+
+ // parse the text-properties
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "color" ) ) {
+ kdDebug(30518) << "color=" << m_styleStack.attributeNS( ooNS::fo, "color" ) << endl;
+ text.setAttribute( "color", m_styleStack.attributeNS( ooNS::fo, "color" ) );
+ }
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "font-family" ) // 3.10.9
+ || m_styleStack.hasAttributeNS( ooNS::style, "font-name") )//3.10.8
+ {
+ // 'Thorndale/Albany' are not known outside OpenOffice so we substitute them
+ // with 'Times New Roman/Arial' that look nearly the same.
+ if ( m_styleStack.attributeNS( ooNS::fo, "font-family" ) == "Thorndale" )
+ text.setAttribute( "family", "Times New Roman" );
+ else if ( m_styleStack.attributeNS( ooNS::fo, "font-family" ) == "Albany" )
+ text.setAttribute( "family", "Arial" );
+ else
+ text.setAttribute( "family", m_styleStack.attributeNS( ooNS::fo, "font-family" ).remove( "'" ) );
+ }
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "font-size" ) )
+ {
+ double pointSize = m_styleStack.fontSize();
+ text.setAttribute( "pointSize", qRound(pointSize) ); // KPresenter uses toInt()!
+ }
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "font-weight" ) ) // 3.10.24
+ if ( m_styleStack.attributeNS( ooNS::fo, "font-weight" ) == "bold" )
+ text.setAttribute( "bold", 1 );
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "font-style" ) )
+ if ( m_styleStack.attributeNS( ooNS::fo, "font-style" ) == "italic" )
+ text.setAttribute( "italic", 1 );
+
+ if ( m_styleStack.hasAttributeNS( ooNS::style, "text-position" ) ) // 3.10.17
+ {
+ QString text_position = m_styleStack.attributeNS( ooNS::style, "text-position");
+ QString value;
+ QString relativetextsize;
+ OoUtils::importTextPosition( text_position, value, relativetextsize );
+ text.setAttribute( "VERTALIGN", value );
+ if ( !relativetextsize.isEmpty() )
+ text.setAttribute( "relativetextsize", relativetextsize );
+ }
+
+ bool wordByWord = (m_styleStack.hasAttributeNS( ooNS::fo, "score-spaces"))// 3.10.25
+ && (m_styleStack.attributeNS( ooNS::fo, "score-spaces") == "false");
+
+ // strikeout
+ if ( m_styleStack.hasAttributeNS( ooNS::style, "text-crossing-out")// 3.10.6
+ && m_styleStack.attributeNS( ooNS::style, "text-crossing-out") != "none")
+ {
+ QString strikeOutType = m_styleStack.attributeNS( ooNS::style, "text-crossing-out" );
+ if ( strikeOutType =="double-line" )
+ {
+ text.setAttribute( "strikeOut", "double" );
+ text.setAttribute( "strikeoutstyleline", "solid" );
+ }
+ else if ( strikeOutType =="thick-line" )
+ {
+ text.setAttribute( "strikeOut", "single-bold" );
+ text.setAttribute( "strikeoutstyleline", "solid" );
+ }
+ else //if ( strikeOutType == "single-line" ) //fall back to the default strikeout
+ {
+ text.setAttribute( "strikeOut", "single" );
+ text.setAttribute( "strikeoutstyleline", "solid" );
+ }
+
+ if (wordByWord)
+ text.setAttribute("wordbyword", 1);
+ }
+
+ // underlining
+ if ( m_styleStack.hasAttributeNS( ooNS::style, "text-underline" ) ) // 3.10.22
+ {
+ QString underline;
+ QString styleline;
+ OoUtils::importUnderline( m_styleStack.attributeNS( ooNS::style, "text-underline" ),
+ underline, styleline );
+ QString underLineColor = m_styleStack.attributeNS( ooNS::style, "text-underline-color" );// 3.10.23
+
+ text.setAttribute( "value", underline );
+ text.setAttribute( "styleline", styleline );
+
+ if ( !underLineColor.isEmpty() && underLineColor != "font-color" )
+ text.setAttribute("underlinecolor", underLineColor);
+ if ( wordByWord )
+ text.setAttribute("wordbyword", 1);
+ }
+#if 0 // strange ooimpress doesn't implement it
+ // Small caps, lowercase, uppercase
+ if ( m_styleStack.hasAttributeNS( ooNS::fo, "font-variant" ) // 3.10.1
+ || m_styleStack.hasAttributeNS( ooNS::fo, "text-transform" ) ) // 3.10.2
+ {
+ QDomElement fontAttrib( doc.createElement( "FONTATTRIBUTE" ) );
+ bool smallCaps = m_styleStack.attributeNS( ooNS::fo, "font-variant" ) == "small-caps";
+ if ( smallCaps )
+ {
+ text.setAttribute( "fontattribute", "smallcaps" );
+ } else
+ {
+ // Both KWord/KPresenter and OO use "uppercase" and "lowercase".
+ // TODO in KWord: "capitalize".
+ text.setAttribute( "fontattribute", m_styleStack.attributeNS( ooNS::fo, "text-transform" ) );
+ }
+ }
+#endif
+ // background color (property of the paragraph in OOo, of the text in kword/kpresenter)
+ if (m_styleStack.hasAttributeNS( ooNS::fo, "background-color" ))
+ {
+ QString bgColor = m_styleStack.attributeNS( ooNS::fo, "background-color");
+ if (bgColor != "transparent")
+ text.setAttribute("textbackcolor", bgColor);
+ }
+
+ appendShadow( doc, outputParagraph ); // this is necessary to take care of shadowed paragraphs
+ outputParagraph.appendChild( text );
+ } // for each text span
+}
+
+void OoImpressImport::createStyleMap( QDomDocument &docstyles )
+{
+ QDomElement styles = docstyles.documentElement();
+ if ( styles.isNull() )
+ return;
+
+ QDomNode fixedStyles = KoDom::namedItemNS( styles, ooNS::office, "styles" );
+ if ( !fixedStyles.isNull() )
+ {
+ insertDraws( fixedStyles.toElement() );
+ insertStyles( fixedStyles.toElement() );
+ insertStylesPresentation( fixedStyles.toElement() );
+ }
+
+ QDomNode automaticStyles = KoDom::namedItemNS( styles, ooNS::office, "automatic-styles" );
+ if ( !automaticStyles.isNull() )
+ {
+ insertStyles( automaticStyles.toElement() );
+ insertStylesPresentation( automaticStyles.toElement() );
+ }
+ QDomNode masterStyles = KoDom::namedItemNS( styles, ooNS::office, "master-styles" );
+ if ( !masterStyles.isNull() )
+ insertStyles( masterStyles.toElement() );
+}
+
+void OoImpressImport::insertDraws( const QDomElement& styles )
+{
+ QDomElement e;
+ forEachElement( e, styles )
+ {
+ if ( !e.hasAttributeNS( ooNS::draw, "name" ) )
+ continue;
+
+ QString name = e.attributeNS( ooNS::draw, "name", QString::null );
+ m_draws.insert( name, new QDomElement( e ) );
+ }
+}
+
+void OoImpressImport::insertStyles( const QDomElement& styles )
+{
+ QDomElement e;
+ forEachElement( e, styles )
+ {
+ const QString localName = e.localName();
+ const QString ns = e.namespaceURI();
+ if ( !e.hasAttributeNS( ooNS::style, "name" ) )
+ continue;
+
+ const QString name = e.attributeNS( ooNS::style, "name", QString::null );
+ if ( localName == "list-style" && ns == ooNS::text ) {
+ QDomElement* ep = new QDomElement( e );
+ m_listStyles.insert( name, ep );
+ kdDebug(30518) << "List style: '" << name << "' loaded " << endl;
+ }
+ else
+ {
+ m_styles.insert( name, new QDomElement( e ) );
+ kdDebug(30518) << "Style: '" << name << "' loaded " << endl;
+ }
+ }
+}
+
+void OoImpressImport::insertStylesPresentation( const QDomElement& styles )
+{
+ QDomElement e;
+ forEachElement( e, styles )
+ {
+ if ( !e.hasAttributeNS( ooNS::style, "name" ) )
+ continue;
+
+ QString name = e.attributeNS( ooNS::style, "name", QString::null );
+ m_stylesPresentation.insert( name, new QDomElement( e ) );
+ //kdDebug(30518) << "Style: '" << name << "' loaded " << endl;
+ }
+}
+
+void OoImpressImport::fillStyleStack( const QDomElement& object, bool sticky )
+{
+ // find all styles associated with an object and push them on the stack
+ if ( object.hasAttributeNS( ooNS::presentation, "style-name" ) )
+ {
+ kdDebug(30518)<<" presentation:style-name **************************** :"<<object.attributeNS( ooNS::presentation, "style-name", QString::null )<<endl;
+ if ( sticky )
+ addStyles( m_stylesPresentation[object.attributeNS( ooNS::presentation, "style-name", QString::null )] );
+ else
+ addStyles( m_styles[object.attributeNS( ooNS::presentation, "style-name", QString::null )] );
+ }
+ if ( object.hasAttributeNS( ooNS::draw, "style-name" ) )
+ addStyles( m_styles[object.attributeNS( ooNS::draw, "style-name", QString::null )] );
+
+ if ( object.hasAttributeNS( ooNS::draw, "text-style-name" ) )
+ addStyles( m_styles[object.attributeNS( ooNS::draw, "text-style-name", QString::null )] );
+
+ if ( object.hasAttributeNS( ooNS::text, "style-name" ) ) {
+ QString styleName = object.attributeNS( ooNS::text, "style-name", QString::null );
+ //kdDebug(30518) << "adding style " << styleName << endl;
+ addStyles( m_styles[styleName] );
+ }
+}
+
+void OoImpressImport::addStyles( const QDomElement* style )
+{
+ kdDebug(30518)<<" addStyle :" << style->attributeNS( ooNS::style, "name", QString::null ) <<endl;
+ // this function is necessary as parent styles can have parents themself
+ if ( style->hasAttributeNS( ooNS::style, "parent-style-name" ) )
+ {
+ //kdDebug(30518)<<"m_styles[style->attribute( style:parent-style-name )] :"<<m_styles[style->attributeNS( ooNS::style, "parent-style-name", QString::null )]<<endl;
+ addStyles( m_styles[style->attributeNS( ooNS::style, "parent-style-name", QString::null )] );
+ }
+ //kdDebug(30518)<<" void OoImpressImport::addStyles( const QDomElement* style ) :"<<style<<endl;
+ m_styleStack.push( *style );
+}
+
+QString OoImpressImport::storeImage( const QDomElement& object )
+{
+ // store the picture
+ QString url = object.attributeNS( ooNS::xlink, "href", QString::null ).remove( '#' );
+ KArchiveFile* file = (KArchiveFile*) m_zip->directory()->entry( url );
+
+ QString extension = url.mid( url.find( '.' ) );
+ QString fileName = QString( "picture%1" ).arg( m_numPicture++ ) + extension;
+ KoStoreDevice* out = m_chain->storageFile( "pictures/" + fileName, KoStore::Write );
+
+ if ( file && out )
+ {
+ QByteArray buffer = file->data();
+ out->writeBlock( buffer.data(), buffer.size() );
+ }
+
+ return fileName;
+}
+
+QString OoImpressImport::storeSound(const QDomElement & object, QDomElement & p, QDomDocument & doc)
+{
+ QFileInfo fi(m_chain->inputFile()); // handle relative URLs
+ QDir::setCurrent(fi.dirPath(true));
+ fi.setFile(object.attributeNS( ooNS::xlink, "href", QString::null));
+ QString url = fi.absFilePath();
+
+ //kdDebug(30518) << "Sound URL: " << url << endl;
+
+ QFile file(url);
+ if (!file.exists())
+ return QString::null;
+
+ QString extension = url.mid( url.find( '.' ) );
+ QString fileName = QString( "sound%1" ).arg( m_numSound++ ) + extension;
+ fileName = "sounds/" + fileName;
+ KoStoreDevice* out = m_chain->storageFile( fileName, KoStore::Write );
+
+ if (out)
+ {
+ if (!file.open(IO_ReadOnly))
+ return QString::null;
+
+ QByteArray data(8*1024);
+
+ uint total = 0;
+ for ( int block = 0; ( block = file.readBlock(data.data(), data.size()) ) > 0;
+ total += block )
+ out->writeBlock(data.data(), data.size());
+
+ Q_ASSERT(total == fi.size());
+
+ file.close();
+ }
+ else
+ return QString::null;
+
+ QDomElement key = doc.createElement("FILE");
+ key.setAttribute("name", fileName);
+ key.setAttribute("filename", url);
+ p.appendChild(key);
+
+ return url;
+}
+
+QDomElement OoImpressImport::saveHelper(const QString &tmpText, QDomDocument &doc)
+{
+ QDomElement element=doc.createElement("TEXT");
+
+ if(tmpText.stripWhiteSpace().isEmpty()) // ### careful, this also strips \t and \n ....
+ // working around a bug in QDom
+ element.setAttribute("whitespace", tmpText.length());
+
+ element.appendChild(doc.createTextNode(tmpText));
+ return element;
+}
+
+void OoImpressImport::appendPoints(QDomDocument& doc, QDomElement& e, const QDomElement& object)
+{
+ QDomElement ptsElem = doc.createElement("POINTS");
+
+ QStringList ptList = QStringList::split(' ', object.attributeNS( ooNS::draw, "points", QString::null));
+
+ QString pt_x, pt_y;
+ double tmp_x, tmp_y;
+ for (QStringList::Iterator it = ptList.begin(); it != ptList.end(); ++it)
+ {
+ QDomElement point = doc.createElement("Point");
+
+ tmp_x = (*it).section(',',0,0).toInt() / 100;
+ tmp_y = (*it).section(',',1,1).toInt() / 100;
+
+ pt_x.setNum(tmp_x);
+ pt_x+="mm";
+
+ pt_y.setNum(tmp_y);
+ pt_y+="mm";
+
+ point.setAttribute("point_x", KoUnit::parseValue(pt_x));
+ point.setAttribute("point_y", KoUnit::parseValue(pt_y));
+ ptsElem.appendChild(point);
+ }
+
+ e.appendChild(ptsElem);
+}
+
+void OoImpressImport::appendField(QDomDocument& doc, QDomElement& e, const QDomElement& object, uint pos)
+{
+ const QString tag = object.localName();
+ const QString ns = object.namespaceURI();
+ const bool isTextNS = ns == ooNS::text;
+
+ QDomElement custom = doc.createElement("CUSTOM");
+ custom.setAttribute("pos", pos);
+ QDomElement variable = doc.createElement("VARIABLE");
+
+ if (isTextNS && tag == "date")
+ {
+ QDateTime dt(QDate::fromString(object.attributeNS( ooNS::text, "date-value", QString::null), Qt::ISODate));
+
+ bool fixed = (object.hasAttributeNS( ooNS::text, "fixed") && object.attributeNS( ooNS::text, "fixed", QString::null)=="true");
+
+ if (!dt.isValid()) {
+ dt = QDateTime::currentDateTime(); // OOo docs say so :)
+ fixed = false;
+ }
+
+ QDomElement typeElem = doc.createElement("TYPE");
+ typeElem.setAttribute("key", "DATE0locale"); // ### find out the correlation between KOffice and OOo date/time types
+ typeElem.setAttribute("type", 0); // VT_DATE
+ typeElem.setAttribute("text", object.text());
+
+ variable.appendChild(typeElem);
+
+ const QDate date(dt.date());
+ const QTime time(dt.time());
+ QDomElement dateElement = doc.createElement("DATE");
+ dateElement.setAttribute("subtype", fixed ? 0 : 1); // VST_DATE_FIX, VST_DATE_CURRENT
+ dateElement.setAttribute("fix", fixed ? 1 : 0);
+ dateElement.setAttribute("day", date.day());
+ dateElement.setAttribute("month", date.month());
+ dateElement.setAttribute("year", date.year());
+ dateElement.setAttribute("hour", time.hour());
+ dateElement.setAttribute("minute", time.minute());
+ dateElement.setAttribute("second", time.second());
+ if (object.hasAttributeNS( ooNS::text, "date-adjust"))
+ dateElement.setAttribute("correct", object.attributeNS( ooNS::text, "date-adjust", QString::null));
+
+ variable.appendChild(dateElement);
+ }
+ else if (isTextNS && tag == "time")
+ {
+ // Use QDateTime to work around a possible problem of QTime::FromString in Qt 3.2.2
+ QDateTime dt(QDateTime::fromString(object.attributeNS( ooNS::text, "time-value", QString::null), Qt::ISODate));
+
+ bool fixed = (object.hasAttributeNS( ooNS::text, "fixed") && object.attributeNS( ooNS::text, "fixed", QString::null)=="true");
+
+ if (!dt.isValid()) {
+ dt = QDateTime::currentDateTime(); // OOo docs say so :)
+ fixed = false;
+ }
+
+ QDomElement typeElem = doc.createElement("TYPE");
+ typeElem.setAttribute("key", "TIMElocale"); // ### find out the correlation between KOffice and OOo date/time types
+ typeElem.setAttribute("type", 2); // VT_TIME
+ typeElem.setAttribute("text", object.text());
+
+ variable.appendChild(typeElem);
+
+ const QTime time(dt.time());
+ QDomElement timeElement = doc.createElement("TIME");
+ timeElement.setAttribute("subtype", fixed ? 0 : 1); // VST_TIME_FIX, VST_TIME_CURRENT
+ timeElement.setAttribute("fix", fixed ? 1 : 0);
+ timeElement.setAttribute("hour", time.hour());
+ timeElement.setAttribute("minute", time.minute());
+ timeElement.setAttribute("second", time.second());
+ /*if (object.hasAttributeNS( ooNS::text, "time-adjust"))
+ timeElem.setAttribute("correct", object.attributeNS( ooNS::text, "time-adjust", QString::null));*/ // ### TODO
+
+ variable.appendChild(timeElement);
+ }
+ else if (isTextNS && tag == "page-number")
+ {
+ QDomElement typeElem = doc.createElement("TYPE");
+ typeElem.setAttribute("key", "NUMBER");
+ typeElem.setAttribute("type", 4); // VT_PGNUM
+ typeElem.setAttribute("text", object.text());
+
+ variable.appendChild(typeElem);
+
+ QDomElement pgNumElem = doc.createElement("PGNUM");
+
+ int subtype = 0; // VST_PGNUM_CURRENT
+
+ if (object.hasAttributeNS( ooNS::text, "select-page"))
+ {
+ const QString select = object.attributeNS( ooNS::text, "select-page", QString::null);
+
+ if (select == "previous")
+ subtype = 3; // VST_PGNUM_PREVIOUS
+ else if (select == "next")
+ subtype = 4; // VST_PGNUM_NEXT
+ else
+ subtype = 0; // VST_PGNUM_CURRENT
+ }
+
+ pgNumElem.setAttribute("subtype", subtype);
+ pgNumElem.setAttribute("value", object.text());
+
+ variable.appendChild(pgNumElem);
+ }
+ else if (isTextNS && tag == "file-name")
+ {
+ QDomElement typeElem = doc.createElement("TYPE");
+ typeElem.setAttribute("key", "STRING");
+ typeElem.setAttribute("type", 8); // VT_FIELD
+ typeElem.setAttribute("text", object.text());
+
+ variable.appendChild(typeElem);
+
+ int subtype = 5;
+
+ if (object.hasAttributeNS( ooNS::text, "display"))
+ {
+ const QString display = object.attributeNS( ooNS::text, "display", QString::null);
+
+ if (display == "path")
+ subtype = 1; // VST_DIRECTORYNAME
+ else if (display == "name")
+ subtype = 6; // VST_FILENAMEWITHOUTEXTENSION
+ else if (display == "name-and-extension")
+ subtype = 0; // VST_FILENAME
+ else
+ subtype = 5; // VST_PATHFILENAME
+ }
+
+ QDomElement fileNameElem = doc.createElement("FIELD");
+ fileNameElem.setAttribute("subtype", subtype);
+ fileNameElem.setAttribute("value", object.text());
+
+ variable.appendChild(fileNameElem);
+ }
+ else if (isTextNS && tag == "author-name"
+ || isTextNS && tag == "author-initials")
+ {
+ QDomElement typeElem = doc.createElement("TYPE");
+ typeElem.setAttribute("key", "STRING");
+ typeElem.setAttribute("type", 8); // VT_FIELD
+ typeElem.setAttribute("text", object.text());
+
+ variable.appendChild(typeElem);
+
+ int subtype = 2; // VST_AUTHORNAME
+
+ if (isTextNS && tag == "author-initials")
+ subtype = 16; // VST_INITIAL
+
+ QDomElement authorElem = doc.createElement("FIELD");
+ authorElem.setAttribute("subtype", subtype);
+ authorElem.setAttribute("value", object.text());
+
+ variable.appendChild(authorElem);
+ }
+
+ custom.appendChild(variable);
+ e.appendChild(custom);
+}
+
+void OoImpressImport::createPresentationAnimation(const QDomElement& element)
+{
+ int order = 0;
+ QDomElement e;
+ forEachElement( e, element )
+ {
+ const QString localName = e.localName();
+ const QString ns = e.namespaceURI();
+ if ( ns == ooNS::presentation && localName == "show-shape" && e.hasAttributeNS( ooNS::draw, "shape-id" ) )
+ {
+ QString name = e.attributeNS( ooNS::draw, "shape-id", QString::null );
+ //kdDebug(30518)<<" insert animation style : name :"<<name<<endl;
+ animationList *lst = new animationList;
+ QDomElement* ep = new QDomElement( e );
+ lst->element = ep;
+ lst->order = order;
+ m_animations.insert( name, lst );
+ ++order;
+ }
+ }
+}
+
+QDomElement OoImpressImport::findAnimationByObjectID(const QString & id, int & order)
+{
+ kdDebug(30518)<<"QDomElement OoImpressImport::findAnimationByObjectID(const QString & id) :"<<id<<endl;
+ if (m_animations.isEmpty() )
+ return QDomElement();
+
+ animationList *animation = m_animations[id];
+ //kdDebug(30518)<<"QDomElement *animation = m_animations[id]; :"<<animation<<endl;
+ if ( !animation )
+ return QDomElement();
+ for (QDomNode node = *( animation->element ); !node.isNull(); node = node.nextSibling())
+ {
+ QDomElement e = node.toElement();
+ order = animation->order;
+ kdDebug(30518)<<"e.tagName() :"<<e.tagName()<<" e.attribute(draw:shape-id) :"<<e.attributeNS( ooNS::draw, "shape-id", QString::null)<<endl;
+ if (e.tagName()=="presentation:show-shape" && e.attributeNS( ooNS::draw, "shape-id", QString::null)==id)
+ return e;
+ }
+
+ return QDomElement();
+}
+
+
+void OoImpressImport::appendObjectEffect(QDomDocument& doc, QDomElement& e, const QDomElement& object,
+ QDomElement& sound)
+{
+ int order = 0;
+ QDomElement origEffect = findAnimationByObjectID(object.attributeNS( ooNS::draw, "id", QString::null), order).toElement();
+
+ if (origEffect.isNull())
+ return;
+
+ QString effect = origEffect.attributeNS( ooNS::presentation, "effect", QString::null);
+ QString dir = origEffect.attributeNS( ooNS::presentation, "direction", QString::null);
+ QString speed = origEffect.attributeNS( ooNS::presentation, "speed", QString::null);
+ kdDebug(30518)<<"speed :"<<speed<<endl;
+ //todo implement speed value.
+
+ int effVal=0;
+ //kdDebug(30518)<<" effect :"<<effect<<" dir :"<<dir<<endl;
+ if (effect=="fade")
+ {
+ if (dir=="from-right")
+ effVal=10; // EF_WIPE_RIGHT
+ else if (dir=="from-left")
+ effVal=9; // EF_WIPE_LEFT
+ else if (dir=="from-top")
+ effVal=11; // EF_WIPE_TOP
+ else if (dir=="from-bottom")
+ effVal=12; // EF_WIPE_BOTTOM
+ else
+ return;
+ }
+ else if (effect=="move")
+ {
+ if (dir=="from-right")
+ effVal=1; // EF_COME_RIGHT
+ else if (dir=="from-left")
+ effVal=2; // EF_COME_LEFT
+ else if (dir=="from-top")
+ effVal=3; // EF_COME_TOP
+ else if (dir=="from-bottom")
+ effVal=4; // EF_COME_BOTTOM
+ else if (dir=="from-upper-right")
+ effVal=5; // EF_COME_RIGHT_TOP
+ else if (dir=="from-lower-right")
+ effVal=6; // EF_COME_RIGHT_BOTTOM
+ else if (dir=="from-upper-left")
+ effVal=7; // EF_COME_LEFT_TOP
+ else if (dir=="from-lower-left")
+ effVal=8; // EF_COME_LEFT_BOTTOM
+ else
+ return;
+ }
+ else
+ return; // sorry, no more supported effects :(
+
+ QDomElement effElem = doc.createElement("EFFECTS");
+ effElem.setAttribute("effect", effVal);
+ e.appendChild(effElem);
+
+ QDomElement presNum = doc.createElement( "PRESNUM" );
+ presNum.setAttribute("value", order);
+ e.appendChild( presNum );
+
+ // sound effect
+ QDomElement origSoundEff = KoDom::namedItemNS( origEffect, ooNS::presentation, "sound");
+ if (!origSoundEff.isNull())
+ {
+ QString soundUrl = storeSound(origSoundEff, sound, doc);
+
+ if (!soundUrl.isNull())
+ {
+ QDomElement pseElem = doc.createElement("APPEARSOUNDEFFECT");
+ pseElem.setAttribute("appearSoundEffect", 1);
+ pseElem.setAttribute("appearSoundFileName", soundUrl);
+
+ e.appendChild(pseElem);
+ }
+ }
+}
+
+#include "ooimpressimport.moc"
diff --git a/filters/kpresenter/ooimpress/ooimpressimport.h b/filters/kpresenter/ooimpress/ooimpressimport.h
new file mode 100644
index 00000000..403daf98
--- /dev/null
+++ b/filters/kpresenter/ooimpress/ooimpressimport.h
@@ -0,0 +1,120 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Laurent Montel <lmontel@mandrakesoft.com>
+ Copyright (c) 2003 Lukas Tinkl <lukas@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 OoImpress_IMPORT_H__
+#define OoImpress_IMPORT_H__
+
+#include <KoFilter.h>
+#include <KoStore.h>
+
+#include <qdom.h>
+#include <qdict.h>
+#include <qcolor.h>
+#include <KoStyleStack.h>
+#include <liststylestack.h>
+
+class KZip;
+
+struct animationList
+{
+ QDomElement *element;
+ int order;
+};
+
+class OoImpressImport : public KoFilter
+{
+ Q_OBJECT
+public:
+ OoImpressImport( KoFilter * parent, const char * name, const QStringList & );
+ virtual ~OoImpressImport();
+
+ virtual KoFilter::ConversionStatus convert( QCString const & from, QCString const & to );
+
+private:
+ void createDocumentInfo( QDomDocument &docinfo );
+ void createDocumentContent( QDomDocument &doccontent );
+ void createStyleMap( QDomDocument &docstyles );
+ void insertDraws( const QDomElement& styles );
+ void insertStyles( const QDomElement& styles );
+ void insertStylesPresentation( const QDomElement& styles );
+
+ void fillStyleStack( const QDomElement& object,bool sticky = false );
+ void addStyles( const QDomElement* style );
+ void appendName(QDomDocument& doc, QDomElement& e, const QDomElement& object);
+ void append2DGeometry( QDomDocument& doc, QDomElement& e, const QDomElement& object, int offset );
+ bool appendLineGeometry( QDomDocument& doc, QDomElement& e, const QDomElement& object, int offset );
+ void appendPoints(QDomDocument& doc, QDomElement& e, const QDomElement& object);
+ void appendPie( QDomDocument& doc, QDomElement& e, const QDomElement& object );
+ void appendImage( QDomDocument& doc, QDomElement& e, QDomElement& p, const QDomElement& object );
+ void appendBackgroundImage( QDomDocument& doc, QDomElement& e, QDomElement& p, const QDomElement& object );
+ void appendBackgroundGradient( QDomDocument& doc, QDomElement& e, const QDomElement& object );
+ void appendRounding( QDomDocument& doc, QDomElement& e, const QDomElement& object );
+ void appendPen( QDomDocument& doc, QDomElement& e );
+ void appendBrush( QDomDocument& doc, QDomElement& e );
+ void appendShadow( QDomDocument& doc, QDomElement& e );
+ void appendLineEnds( QDomDocument& doc, QDomElement& e, bool _orderEndStartLine = true );
+ void appendTextObjectMargin( QDomDocument& doc, QDomElement& e );
+ void appendField(QDomDocument& doc, QDomElement& e, const QDomElement& object, uint pos);
+ void createPresentationAnimation(const QDomElement& element);
+ QDomElement findAnimationByObjectID(const QString & id, int & order);
+
+ void appendObjectEffect(QDomDocument& doc, QDomElement& e, const QDomElement& object, QDomElement& sound);
+ void appendBackgroundPage( QDomDocument &doc, QDomElement &e,QDomElement & pictureElement, QDomElement &soundElement );
+
+ QDomElement saveHelper(const QString &tmpText, QDomDocument &doc);
+ void appendObject(QDomNode & drawPage, QDomDocument & doc, QDomElement & soundElement, QDomElement & pictureElement, QDomElement & pageNoteElement, QDomElement &objectElement,double offset, bool sticky = false);
+
+ QString storeImage( const QDomElement& object );
+ QString storeSound(const QDomElement & object, QDomElement & p, QDomDocument & doc);
+ QDomElement parseTextBox( QDomDocument& doc, const QDomElement& textBox );
+ bool pushListLevelStyle( const QString& listStyleName, int level );
+ bool pushListLevelStyle( const QString& listStyleName, QDomElement& fullListStyle, int level );
+ void applyListStyle( QDomElement& paragraph );
+ void parseList( QDomDocument& doc, QDomElement& textObjectElement, const QDomElement& list );
+ void parseParagraphs( QDomDocument& doc, QDomElement& textObjectElement, const QDomElement& textBox );
+ QDomElement parseParagraph( QDomDocument& doc, const QDomElement& paragraph );
+ void parseSpanOrSimilar( QDomDocument& doc, const QDomElement& parent,
+ QDomElement& outputParagraph, uint& pos);
+ bool parseSettings( QDomDocument &doc, QDomElement &helpLineElement, QDomElement &attributeElement );
+ void parseHelpLine( QDomDocument &doc,QDomElement &helpLineElement, const QString &text );
+
+ KoFilter::ConversionStatus openFile();
+ KoFilter::ConversionStatus loadAndParse(const QString& filename, QDomDocument& doc);
+
+ int m_numPicture;
+ int m_numSound;
+ QDomDocument m_content;
+ QDomDocument m_meta;
+ QDomDocument m_settings;
+ QDict<QDomElement> m_styles, m_draws, m_stylesPresentation;
+ QDict<QDomElement> m_listStyles;
+ QDict<animationList> m_animations;
+
+ bool m_insideOrderedList;
+ bool m_nextItemIsListItem; // only the first elem inside list-item is numbered
+ int m_restartNumbering;
+ QString m_currentListStyleName;
+
+ KZip * m_zip;
+ KoStyleStack m_styleStack;
+ ListStyleStack m_listStyleStack;
+};
+
+#endif
diff --git a/filters/kpresenter/ooimpress/status.html b/filters/kpresenter/ooimpress/status.html
new file mode 100644
index 00000000..b0062c04
--- /dev/null
+++ b/filters/kpresenter/ooimpress/status.html
@@ -0,0 +1,227 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <title>KOffice filters status: OpenOffice.org Impress Filter</title>
+</head>
+<body text="#000000" bgcolor="#FFFFFF" link="#000099" vlink="#666666" alink="#666666">
+<A NAME="START">&nbsp;</A>
+
+<BR>
+<center>
+ <h1>
+ KOffice filters status: &nbsp;&nbsp;<i>OpenOffice.org Impress Filter</i>
+ </h1>
+</center>
+
+<hr NOSHADE SIZE=2 WIDTH="70%">
+
+<font size="-1"><b>
+ <A HREF="#import">Import</A> |
+ <A HREF="#export">Export</A>
+</b></font>
+
+<BR><BR><BR>
+<center><a NAME="import"></a></center>
+
+<A HREF="#START"><font size="-1"><b>Up</b></font></A>
+<center>
+<table BORDER=0 CELLSPACING=0 BGCOLOR="#000000" WIDTH="100%">
+ <tr>
+ <td>
+ <table BORDER=0 CELLPADDING=2 BGCOLOR="#FFFFFF" WIDTH="100%">
+
+ <tr BGCOLOR="#DDFFDD">
+ <td COLSPAN="2">
+ <center><b><i><font size="+1">
+ <BR>
+ Import OpenOffice.org Impress for KPresenter<BR>
+ <BR>
+ </font></i></b></center>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP WIDTH="1%" NOWRAP><b><font size="+1">Last update</font></b></td>
+ <td>March 06, 2005</td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">Features</font></b></td>
+ <td>
+ - Objects: text (including list), circle, ellipse (including pie, arc and chord),
+ rectangle, line, image, polyline, polygon<br>
+ - Slide titles<br>
+ - Paper settings<br>
+ - Notes<br>
+ - Slide background (solid, gradient and image)<br>
+ - Line settings (width, style and color)<br>
+ - Fill settings (solid, gradient)<br>
+ - Line ends (arrows)<br>
+ - Rounding (for rectangles)<br>
+ - Shadow<br>
+ - Text margins<br>
+ - Vertical alignment for text<br>
+ - Text style (underline, sub/super script, bold, italic, strikeout, background color)<br>
+ - Paragraph style (line spacing, offset before/after paragraph, indent first/right/left, borders)<br>
+ - Presentation settings<br>
+ - Slide transitions<br>
+ - Sound<br>
+ - Fields (number of pages, author, date &amp; time)<br>
+ - Effects (for objects) and order effect<br>
+ - Slide duration transition<br>
+ - Picture effect<br>
+ - Animation object order<br>
+ - HelpLine <br>
+ - Custom Slide Show <br>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Todo</font></b></td>
+ <td>
+ - Video (not supported by KPresenter)<br>
+ - Embedded documents<br>
+ - Objects: path, 3D objects (not supported by KPresenter)<br>
+ - Load Layer (kpresenter doesn't support it but we can d�ine it as sticky object <br>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">History</font></b></td>
+ <td>January 11, 2003: Initial Revision</td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Authors</font></b></td>
+ <td><a href="mailto:percy@eris23.de">Percy Leonhardt</a><br>
+ <a href="mailto:montel@kde.org">Laurent Montel</a><br>
+ <a href="mailto:lukas@kde.org">Luk&aacute;&scaron; Tinkl</a>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">Links</font></b></td>
+ <td>
+ <a href="http://www.koffice.org/kpresenter/">KPresenter homepage</a><br>
+ <a href="http://xml.openoffice.org">xml.openoffice.org</a>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Progress report </font></b></td>
+ <td>-</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</center>
+<A HREF="#START"><font size="-1"><b>Up</b></font></A>
+
+<br><br><br>
+
+<hr NOSHADE SIZE=1>
+<br><br><br>
+
+
+<center>
+ <a NAME="export"></a>
+</center>
+
+<A HREF="#START"><font size="-1"><b>Up</b></font></A>
+<center>
+<table BORDER=0 CELLSPACING=0 BGCOLOR="#000000" WIDTH="100%">
+ <tr>
+ <td>
+ <table BORDER=0 CELLPADDING=2 BGCOLOR="#FFFFFF" WIDTH="100%">
+ <tr BGCOLOR="#FFDDDD">
+ <td COLSPAN="2">
+ <center><b><i><font size="+1">
+ <BR>Export KPresenter to OpenOffice.org Impress<BR><BR>
+ </font></i></b></center>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP WIDTH="1%" NOWRAP><b><font size="+1">Last update</font></b></td>
+ <td>March 06, 2005</td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">Features</font></b></td>
+ <td>
+ - Objects: text (including list), circle, ellipse, rectangle, line, image, pie, arc, chord, polyline, polygon<br>
+ - Slide titles<br>
+ - Paper settings<br>
+ - Slide background (solid)<br>
+ - Line settings (width, style and color)<br>
+ - Fill settings (solid, gradient)<br>
+ - Rounding (for rectangles)<br>
+ - Shadow<br>
+ - Text style (underline, sub/super script, bold, italic, strikeout, background color)<br>
+ - Paragraph style (line spacing, offset before/after paragraph, indent first/right/left, borders)<br>
+ - Slide transitions<br>
+ - Object rotate<br>
+ - Slide duration transition<br>
+ - Objects: image<br>
+ - Settings element (snap line drawing)<br>
+ - Export Transparency<br>
+ - Export Group Object<br>
+ - Vertical alignment for text<br>
+ - Text margins<br>
+ - Export title/keyword/subject<br>
+ - Custom Slide Show<br>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Todo</font></b></td>
+ <td>
+ - Presentation settings<br>
+ - Slide background (gradient and image)<br>
+ - Line ends (arrows)<br>
+ - Notes<br>
+ - Sound<br>
+ - Fields (number of pages, author, date &amp; time)<br>
+ - Effects (for objects)<br>
+ - Video (not supported by KPresenter)<br>
+ - Embedded documents<br>
+ - Objects: path, 3D objects (not supported by KPresenter)<br>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">History</font></b></td>
+ <td>July 01, 2003: Initial Revision</td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Authors</font></b></td>
+ <td>
+ <a href="mailto:percy@eris23.de">Percy Leonhardt</a><br>
+ <a href="mailto:montel@kde.org">Montel Laurent</a><br>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#CCCCFF">
+ <td VALIGN=TOP><b><font size="+1">Links</font></b></td>
+ <td>
+ <a href="http://www.koffice.org/kpresenter/">KPresenter homepage</a><br>
+ <a href="http://xml.openoffice.org">xml.openoffice.org</a>
+ </td>
+ </tr>
+
+ <tr BGCOLOR="#EEEEFF">
+ <td VALIGN=TOP><b><font size="+1">Progress report </font></b></td>
+ <td>---</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</center>
+<A HREF="#START"><font size="-1"><b>Up</b></font></A>
+
+</body>
+</html>
diff --git a/filters/kpresenter/ooimpress/stylefactory.cc b/filters/kpresenter/ooimpress/stylefactory.cc
new file mode 100644
index 00000000..0c7d9a2c
--- /dev/null
+++ b/filters/kpresenter/ooimpress/stylefactory.cc
@@ -0,0 +1,1629 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Percy Leonhardt
+
+ 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 "stylefactory.h"
+
+#include <qcolor.h>
+#include <qdatetime.h>
+#include <KoUnit.h>
+#include <kdebug.h>
+
+StyleFactory::StyleFactory()
+{
+ m_strokeDashStyles.setAutoDelete( true );
+ m_gradientStyles.setAutoDelete( true );
+ m_hatchStyles.setAutoDelete( true );
+ m_markerStyles.setAutoDelete( true );
+ m_fillImageStyles.setAutoDelete( true );
+ m_listStyles.setAutoDelete( true );
+ m_pageStyles.setAutoDelete( true );
+ m_textStyles.setAutoDelete( true );
+ m_graphicStyles.setAutoDelete( true );
+ m_paragraphStyles.setAutoDelete( true );
+ m_pageMasterStyles.setAutoDelete( true );
+
+ // create standard graphic style
+ GraphicStyle * graphicStyle;
+ graphicStyle = new GraphicStyle ( "standard", "solid", "0cm", "0x000000",
+ "hidden", "0.3cm", "0.3cm", "0x808080",
+ "0cm", "0cm", "0cm", "0cm", "0x000000",
+ "false", "none", "Thorndale", "24pt",
+ "normal", "none", "none", "normal",
+ "100%", "start", "solid", "0x00b8ff",
+ "false" );
+
+ m_graphicStyles.append( graphicStyle );
+}
+
+StyleFactory::~StyleFactory()
+{
+}
+
+void StyleFactory::addOfficeStyles( QDomDocument & doc, QDomElement & styles )
+{
+ StrokeDashStyle * sd;
+ for ( sd = m_strokeDashStyles.first(); sd ; sd = m_strokeDashStyles.next() )
+ sd->toXML( doc, styles );
+
+ GradientStyle * g;
+ for ( g = m_gradientStyles.first(); g ; g = m_gradientStyles.next() )
+ g->toXML( doc, styles );
+
+ MarkerStyle * m;
+ for ( m = m_markerStyles.first(); m ; m = m_markerStyles.next() )
+ m->toXML( doc, styles );
+
+ HatchStyle * h;
+ for ( h = m_hatchStyles.first(); h ; h = m_hatchStyles.next() )
+ h->toXML( doc, styles );
+
+ GraphicStyle * gr;
+ gr = m_graphicStyles.first(); // skip the "standard" style
+ gr->toXML( doc, styles );
+}
+
+void StyleFactory::addOfficeMaster( QDomDocument & doc, QDomElement & master )
+{
+ PageMasterStyle * p;
+ for ( p = m_pageMasterStyles.first(); p ; p = m_pageMasterStyles.next() )
+ {
+ QDomElement masterPage = doc.createElement( "style:master-page" );
+ masterPage.setAttribute( "style:name", p->style() );
+ masterPage.setAttribute( "style:page-master-name", p->name() );
+ masterPage.setAttribute( "draw:style-name", "dp1" );
+ master.appendChild( masterPage );
+ }
+}
+
+void StyleFactory::addOfficeAutomatic( QDomDocument & doc, QDomElement & automatic )
+{
+ PageMasterStyle * p;
+ for ( p = m_pageMasterStyles.first(); p ; p = m_pageMasterStyles.next() )
+ {
+ p->toXML( doc, automatic );
+ }
+}
+
+void StyleFactory::addAutomaticStyles( QDomDocument & doc, QDomElement & autoStyles )
+{
+ ListStyle * l;
+ for ( l = m_listStyles.first(); l ; l = m_listStyles.next() )
+ l->toXML( doc, autoStyles );
+
+ PageStyle * p;
+ for ( p = m_pageStyles.first(); p ; p = m_pageStyles.next() )
+ p->toXML( doc, autoStyles );
+
+ TextStyle * t;
+ for ( t = m_textStyles.first(); t ; t = m_textStyles.next() )
+ t->toXML( doc, autoStyles );
+
+ GraphicStyle * g;
+ g = m_graphicStyles.first(); // skip the "standard" style
+ for ( g = m_graphicStyles.next(); g ; g = m_graphicStyles.next() )
+ g->toXML( doc, autoStyles );
+
+ ParagraphStyle * pg;
+ for ( pg = m_paragraphStyles.first(); pg ; pg = m_paragraphStyles.next() )
+ pg->toXML( doc, autoStyles );
+}
+
+QString StyleFactory::createStrokeDashStyle( int style )
+{
+ StrokeDashStyle * newStrokeDashStyle, * sd;
+ newStrokeDashStyle = new StrokeDashStyle( style );
+ for ( sd = m_strokeDashStyles.first(); sd ; sd = m_strokeDashStyles.next() )
+ {
+ if ( sd->name() == newStrokeDashStyle->name() )
+ {
+ delete newStrokeDashStyle;
+ return sd->name();
+ }
+ }
+
+ m_strokeDashStyles.append( newStrokeDashStyle );
+ return newStrokeDashStyle->name();
+}
+
+QString StyleFactory::createGradientStyle( QDomElement & gradient )
+{
+ GradientStyle * newGradientStyle, * g;
+ newGradientStyle = new GradientStyle( gradient, m_gradientStyles.count() + 1 );
+ for ( g = m_gradientStyles.first(); g ; g = m_gradientStyles.next() )
+ {
+ if ( g->name() == newGradientStyle->name() )
+ {
+ delete newGradientStyle;
+ return g->name();
+ }
+ }
+
+ m_gradientStyles.append( newGradientStyle );
+ return newGradientStyle->name();
+}
+
+QString StyleFactory::createMarkerStyle( int style )
+{
+ MarkerStyle * newMarkerStyle, * m;
+ newMarkerStyle = new MarkerStyle( style );
+ for ( m = m_markerStyles.first(); m ; m = m_markerStyles.next() )
+ {
+ if ( m->name() == newMarkerStyle->name() )
+ {
+ delete newMarkerStyle;
+ return m->name();
+ }
+ }
+
+ m_markerStyles.append( newMarkerStyle );
+ return newMarkerStyle->name();
+}
+
+QString StyleFactory::createHatchStyle( int style, QString & color )
+{
+ HatchStyle * newHatchStyle, * h;
+ newHatchStyle = new HatchStyle( style, color );
+ for ( h = m_hatchStyles.first(); h ; h = m_hatchStyles.next() )
+ {
+ if ( h->name() == newHatchStyle->name() )
+ {
+ delete newHatchStyle;
+ return h->name();
+ }
+ }
+
+ m_hatchStyles.append( newHatchStyle );
+ return newHatchStyle->name();
+}
+
+QString StyleFactory::createListStyle( QDomElement & e )
+{
+ ListStyle * newListStyle, * l;
+ newListStyle = new ListStyle( e, m_listStyles.count() + 1 );
+ for ( l = m_listStyles.first(); l ; l = m_listStyles.next() )
+ {
+ if ( *l == *newListStyle )
+ {
+ delete newListStyle;
+ return l->name();
+ }
+ }
+
+ m_listStyles.append( newListStyle );
+ return newListStyle->name();
+}
+
+QString StyleFactory::createPageStyle( QDomElement & e )
+{
+ PageStyle * newPageStyle, * p;
+ newPageStyle = new PageStyle( this, e, m_pageStyles.count() + 1 );
+ for ( p = m_pageStyles.first(); p ; p = m_pageStyles.next() )
+ {
+ if ( *p == *newPageStyle )
+ {
+ delete newPageStyle;
+ return p->name();
+ }
+ }
+
+ m_pageStyles.append( newPageStyle );
+ return newPageStyle->name();
+}
+
+QString StyleFactory::createTextStyle( QDomElement & e )
+{
+ TextStyle * newTextStyle, * t;
+ newTextStyle = new TextStyle( e, m_textStyles.count() + 1 );
+ for ( t = m_textStyles.first(); t ; t = m_textStyles.next() )
+ {
+ if ( *t == *newTextStyle )
+ {
+ delete newTextStyle;
+ return t->name();
+ }
+ }
+
+ m_textStyles.append( newTextStyle );
+ return newTextStyle->name();
+}
+
+QString StyleFactory::createGraphicStyle( QDomElement & e )
+{
+ GraphicStyle * newGraphicStyle, * g;
+ newGraphicStyle = new GraphicStyle( this, e, m_graphicStyles.count() );
+ for ( g = m_graphicStyles.first(); g ; g = m_graphicStyles.next() )
+ {
+ if ( *g == *newGraphicStyle )
+ {
+ delete newGraphicStyle;
+ return g->name();
+ }
+ }
+
+ m_graphicStyles.append( newGraphicStyle );
+ return newGraphicStyle->name();
+}
+
+QString StyleFactory::createParagraphStyle( QDomElement & e )
+{
+ ParagraphStyle * newParagraphStyle, * p;
+ newParagraphStyle = new ParagraphStyle( e, m_paragraphStyles.count() + 1 );
+ for ( p = m_paragraphStyles.first(); p ; p = m_paragraphStyles.next() )
+ {
+ if ( *p == *newParagraphStyle )
+ {
+ delete newParagraphStyle;
+ return p->name();
+ }
+ }
+
+ m_paragraphStyles.append( newParagraphStyle );
+ return newParagraphStyle->name();
+}
+
+QString StyleFactory::createPageMasterStyle( QDomElement & e )
+{
+ PageMasterStyle * newPMStyle, * p;
+ newPMStyle = new PageMasterStyle( e, m_pageMasterStyles.count() );
+ for ( p = m_pageMasterStyles.first(); p ; p = m_pageMasterStyles.next() )
+ {
+ if ( *p == *newPMStyle )
+ {
+ delete newPMStyle;
+ return p->style();
+ }
+ }
+
+ m_pageMasterStyles.append( newPMStyle );
+ return newPMStyle->style();
+}
+
+QString StyleFactory::toCM( const QString & point )
+{
+ double pt = point.toFloat();
+ double cm = KoUnit::toCM( pt );
+ return QString( "%1cm" ).arg ( cm );
+}
+
+StrokeDashStyle::StrokeDashStyle( int style )
+{
+ switch ( style )
+ {
+ case 2:
+ m_name = "Fine Dashed";
+ m_style = "rect";
+ m_dots1 = "1";
+ m_dots1_length = "0.508cm";
+ m_dots2 = "1";
+ m_dots2_length = "0.508cm";
+ m_distance = "0.508cm";
+ break;
+ case 3:
+ m_name = "Fine Dotted";
+ m_style = "rect";
+ m_dots1 = "1";
+ m_distance = "0.257cm";
+ break;
+ case 4:
+ m_name = "Ultrafine 1 Dot 1 Dash";
+ m_style = "rect";
+ m_dots1 = "1";
+ m_dots1_length = "0.051cm";
+ m_dots2 = "1";
+ m_dots2_length = "0.254cm";
+ m_distance = "0.127cm";
+ break;
+ case 5:
+ m_name = "2 Dots 1 Dash";
+ m_style = "rect";
+ m_dots1 = "2";
+ m_dots2 = "1";
+ m_dots2_length = "0.203cm";
+ m_distance = "0.203cm";
+ break;
+ }
+}
+
+void StrokeDashStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement strokeDash = doc.createElement( "draw:stroke-dash" );
+ strokeDash.setAttribute( "draw:name", m_name );
+ if ( !m_style.isNull() )
+ strokeDash.setAttribute( "draw:style", m_style );
+ if ( !m_dots1.isNull() )
+ strokeDash.setAttribute( "draw:dots1", m_dots1 );
+ if ( !m_dots1_length.isNull() )
+ strokeDash.setAttribute( "draw:dots1-length", m_dots1_length );
+ if ( !m_dots2.isNull() )
+ strokeDash.setAttribute( "draw:dots2", m_dots2 );
+ if ( !m_dots2_length.isNull() )
+ strokeDash.setAttribute( "draw:dots2-length", m_dots2_length );
+ if ( !m_distance.isNull() )
+ strokeDash.setAttribute( "draw:distance", m_distance );
+
+ e.appendChild( strokeDash );
+}
+
+GradientStyle::GradientStyle( QDomElement & gradient, int index )
+{
+ m_name = QString( "Gradient %1" ).arg( index );
+ m_start_intensity = "100%";
+ m_end_intensity = "100%";
+ m_border = "0%";
+
+ int type = 1;
+ if ( gradient.nodeName() == "PAGE" )
+ {
+ // gradient from page background
+ QDomElement backColor1 = gradient.namedItem( "BACKCOLOR1" ).toElement();
+ QDomElement backColor2 = gradient.namedItem( "BACKCOLOR2" ).toElement();
+ QDomElement bcType = gradient.namedItem( "BCTYPE" ).toElement();
+ QDomElement bGradient = gradient.namedItem( "BGRADIENT" ).toElement();
+
+ if ( !backColor1.isNull() )
+ m_start_color = backColor1.attribute( "color" );
+ if ( !backColor2.isNull() )
+ m_end_color = backColor2.attribute( "color" );
+ if ( !bcType.isNull() )
+ type = bcType.attribute( "value" ).toInt();
+ if ( !bGradient.isNull() )
+ {
+ if ( bGradient.attribute( "unbalanced" ) == "0" )
+ {
+ m_cx = "50%";
+ m_cy = "50%";
+ }
+ else
+ {
+ int cx = bGradient.attribute( "xfactor" ).toInt();
+ int cy = bGradient.attribute( "yfactor" ).toInt();
+ m_cx = QString( "%1%" ).arg( cx / 4 + 50 );
+ m_cy = QString( "%1%" ).arg( cy / 4 + 50 );
+ }
+ }
+
+ }
+ else
+ {
+ // gradient from object
+ if ( gradient.hasAttribute( "color1" ) )
+ m_start_color = gradient.attribute( "color1" );
+ if ( gradient.hasAttribute( "color2" ) )
+ m_end_color = gradient.attribute( "color2" );
+ if ( gradient.hasAttribute( "type" ) )
+ type = gradient.attribute( "type" ).toInt();
+ if ( gradient.hasAttribute( "unbalanced" ) )
+ {
+ if ( gradient.attribute( "unbalanced" ) == "0" )
+ {
+ m_cx = "50%";
+ m_cy = "50%";
+ }
+ else
+ {
+ int cx = gradient.attribute( "xfactor" ).toInt();
+ int cy = gradient.attribute( "yfactor" ).toInt();
+ m_cx = QString( "%1%" ).arg( cx / 4 + 50 );
+ m_cy = QString( "%1%" ).arg( cy / 4 + 50 );
+ }
+ }
+
+ }
+
+ switch ( type )
+ {
+ case 1:
+ m_style = "linear";
+ m_angle = "0";
+ break;
+ case 2:
+ m_style = "linear";
+ m_angle = "900";
+ break;
+ case 3:
+ m_style = "linear";
+ m_angle = "450";
+ break;
+ case 4:
+ m_style = "linear";
+ m_angle = "135";
+ break;
+ case 5:
+ m_style = "radial";
+ m_angle = "0";
+ break;
+ case 6:
+ m_style = "square";
+ m_angle = "0";
+ break;
+ case 7:
+ m_style = "axial";
+ m_angle = "0";
+ break;
+ }
+}
+
+void GradientStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement gradient = doc.createElement( "draw:gradient" );
+ gradient.setAttribute( "draw:name", m_name );
+ if ( !m_style.isNull() )
+ gradient.setAttribute( "draw:style", m_style );
+ if ( !m_start_color.isNull() )
+ gradient.setAttribute( "draw:start-color", m_start_color );
+ if ( !m_end_color.isNull() )
+ gradient.setAttribute( "draw:end-color", m_end_color );
+ if ( !m_start_intensity.isNull() )
+ gradient.setAttribute( "draw:start-intensity", m_start_intensity );
+ if ( !m_end_intensity.isNull() )
+ gradient.setAttribute( "draw:end-intensity", m_end_intensity );
+ if ( !m_angle.isNull() )
+ gradient.setAttribute( "draw:angle", m_angle );
+ if ( !m_border.isNull() )
+ gradient.setAttribute( "draw:border", m_border );
+ if ( !m_cx.isNull() )
+ gradient.setAttribute( "draw:cx", m_cx );
+ if ( !m_cy.isNull() )
+ gradient.setAttribute( "draw:cy", m_cy );
+
+ e.appendChild( gradient );
+}
+
+MarkerStyle::MarkerStyle( int style )
+{
+ // Markers are not working because OOImpress depends on the sequence
+ // of the attributes in the draw:marker tag. svg:ViewBox has to be in
+ // front of svg:d in order to work.
+
+ switch ( style )
+ {
+ case 1:
+ m_name = "Arrow";
+ m_viewBox = "0 0 20 30";
+ m_d = "m10 0-10 30h20z";
+ break;
+ case 2:
+ m_name = "Square";
+ m_viewBox = "0 0 10 10";
+ m_d = "m0 0h10v10h-10z";
+ break;
+ case 3:
+ m_name = "Circle";
+ m_viewBox = "0 0 1131 1131";
+ m_d = "m462 1118-102-29-102-51-93-72-72-93-51-102-29-102-13-105 13-102 29-106 51-102 72-89 93-72 102-50 102-34 106-9 101 9 106 34 98 50 93 72 72 89 51 102 29 106 13 102-13 105-29 102-51 102-72 93-93 72-98 51-106 29-101 13z";
+ break;
+ case 4:
+ m_name = "Line Arrow";
+ m_viewBox = "0 0 1122 2243";
+ m_d = "m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z";
+ break;
+ case 5:
+ m_name = "Dimension Lines";
+ m_viewBox = "0 0 836 110";
+ m_d = "m0 0h278 278 280v36 36 38h-278-278-280v-36-36z";
+ break;
+ case 6:
+ case 7:
+ m_name = "Double Arrow";
+ m_viewBox = "0 0 1131 1918";
+ m_d = "m737 1131h394l-564-1131-567 1131h398l-398 787h1131z";
+ break;
+ }
+}
+
+void MarkerStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement marker = doc.createElement( "draw:marker" );
+ marker.setAttribute( "draw:name", m_name );
+ if ( !m_viewBox.isNull() )
+ marker.setAttribute( "svg:viewBox", m_viewBox );
+ if ( !m_d.isNull() )
+ marker.setAttribute( "svg:d", m_d );
+
+ e.appendChild( marker );
+}
+
+HatchStyle::HatchStyle( int style, QString & color )
+{
+ m_color = color;
+
+ switch ( style )
+ {
+ case 9:
+ m_name = m_color + " 0 Degrees";
+ m_style = "single";
+ m_distance = "0.102cm";
+ m_rotation = "0";
+ break;
+ case 10:
+ m_name = m_color + " 90 Degrees";
+ m_style = "single";
+ m_distance = "0.102cm";
+ m_rotation = "900";
+ break;
+ case 11:
+ m_name = m_color + " Crossed 0 Degrees";
+ m_style = "double";
+ m_distance = "0.076cm";
+ m_rotation = "900";
+ break;
+ case 12:
+ m_name = m_color + " 45 Degrees";
+ m_style = "single";
+ m_distance = "0.102cm";
+ m_rotation = "450";
+ break;
+ case 13:
+ m_name = m_color + " -45 Degrees";
+ m_style = "single";
+ m_distance = "0.102cm";
+ m_rotation = "3150";
+ break;
+ case 14:
+ m_name = m_color + " Crossed 45 Degrees";
+ m_style = "double";
+ m_distance = "0.076cm";
+ m_rotation = "450";
+ break;
+ }
+}
+
+void HatchStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement hatch = doc.createElement( "draw:hatch" );
+ hatch.setAttribute( "draw:name", m_name );
+ if ( !m_style.isNull() )
+ hatch.setAttribute( "draw:style", m_style );
+ if ( !m_color.isNull() )
+ hatch.setAttribute( "draw:color", m_color );
+ if ( !m_distance.isNull() )
+ hatch.setAttribute( "draw:distance", m_distance );
+ if ( !m_rotation.isNull() )
+ hatch.setAttribute( "draw:rotation", m_rotation );
+
+ e.appendChild( hatch );
+}
+
+FillImageStyle::FillImageStyle( QString & name )
+{
+
+}
+
+void FillImageStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+
+}
+
+PageMasterStyle::PageMasterStyle( QDomElement & e, const uint index )
+{
+ QDomNode borders = e.namedItem( "PAPERBORDERS" );
+ QDomElement b = borders.toElement();
+
+ m_name = QString( "PM%1" ).arg( index );
+ m_style = QString( "Default%1" ).arg( index );
+ m_margin_top = StyleFactory::toCM( b.attribute( "ptTop" ) );
+ m_margin_bottom = StyleFactory::toCM( b.attribute( "ptBottom" ) );
+ m_margin_left = StyleFactory::toCM( b.attribute( "ptLeft" ) );
+ m_margin_right = StyleFactory::toCM( b.attribute( "ptRight" ) );
+ m_page_width = StyleFactory::toCM( e.attribute( "ptWidth" ) );
+ m_page_height = StyleFactory::toCM( e.attribute( "ptHeight" ) );
+ m_orientation = "landscape";
+}
+
+void PageMasterStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement style = doc.createElement( "style:page-master" );
+ style.setAttribute( "style:name", "PM0" );
+
+ QDomElement properties = doc.createElement( "style:properties" );
+ properties.setAttribute( "fo:margin-top", m_margin_top );
+ properties.setAttribute( "fo:margin-bottom", m_margin_bottom );
+ properties.setAttribute( "fo:margin-left", m_margin_left );
+ properties.setAttribute( "fo:margin-right", m_margin_right );
+ properties.setAttribute( "fo:page-width", m_page_width );
+ properties.setAttribute( "fo:page-height", m_page_height );
+ properties.setAttribute( "fo:print-orientation", m_orientation );
+
+ style.appendChild( properties );
+ e.appendChild( style );
+}
+
+bool PageMasterStyle::operator==( const PageMasterStyle & pageMasterStyle ) const
+{
+ return ( m_margin_top == pageMasterStyle.m_margin_top &&
+ m_margin_bottom == pageMasterStyle.m_margin_bottom &&
+ m_margin_left == pageMasterStyle.m_margin_left &&
+ m_margin_right == pageMasterStyle.m_margin_right &&
+ m_page_width == pageMasterStyle.m_page_width &&
+ m_page_height == pageMasterStyle.m_page_height &&
+ m_orientation == pageMasterStyle.m_orientation );
+}
+
+PageStyle::PageStyle( StyleFactory * styleFactory, QDomElement & e, const uint index )
+{
+ QDomElement backMaster = e.namedItem( "BACKMASTER" ).toElement();
+ if( !backMaster.isNull())
+ {
+ int tmp=0;
+ if(backMaster.hasAttribute("displayBackground"))
+ tmp = backMaster.attribute("displayBackground").toInt();
+ m_bg_visible = (tmp==1) ? "true" : "false";
+ tmp = 0;
+ if(backMaster.hasAttribute("displayMasterPageObject"))
+ tmp = backMaster.attribute("displayMasterPageObject").toInt();
+ m_bg_objects_visible = (tmp==1) ? "true" : "false";
+ }
+ else
+ {
+ m_bg_visible = "true";
+ m_bg_objects_visible = "true";
+ }
+
+ m_name = QString( "dp%1" ).arg( index );
+
+ // check if this is an empty page tag
+ if ( !e.hasChildNodes() )
+ return;
+
+ QDomElement backType = e.namedItem( "BACKTYPE" ).toElement();
+ if ( backType.isNull() || backType.attribute( "value" ) == "0" )
+ {
+ // color
+ QDomElement bcType = e.namedItem( "BCTYPE" ).toElement();
+ if ( bcType.isNull() || bcType.attribute( "value" ) == "0" )
+ {
+ // plain
+ QDomElement backColor = e.namedItem( "BACKCOLOR1" ).toElement();
+ m_fill = "solid";
+ m_fill_color = backColor.attribute( "color" );
+ }
+ else
+ {
+ // gradient
+ m_fill = "gradient";
+ m_fill_gradient_name = styleFactory->createGradientStyle( e );
+ }
+ }
+ else
+ {
+ // picture
+ }
+
+ QDomElement pageDuration = e.namedItem( "PGTIMER" ).toElement();
+ if ( !pageDuration.isNull() )
+ {
+
+ QTime time;
+ time = time.addSecs( pageDuration.attribute("timer").toInt() );
+ QString hours( QString::number( time.hour() ).rightJustify( 2, '0' ) );
+ QString ms( QString::number( time.minute() ).rightJustify( 2, '0' ) );
+ QString sec( QString::number( time.second() ).rightJustify( 2, '0' ) );
+
+
+ //ISO8601 chapter 5.5.3.2
+ //QDate doesn't encode it as this format.
+ m_page_duration = QString( "PT%1H%2M%3S" ).arg( hours ).arg( ms ).arg( sec );
+ }
+
+ QDomElement pageEffect = e.namedItem( "PGEFFECT" ).toElement();
+ if ( !pageEffect.isNull() )
+ {
+ int tmp=0;
+ if(pageEffect.hasAttribute("value"))
+ tmp=pageEffect.attribute("value").toInt();
+ kdDebug(30518)<<" tmp :"<<tmp<<endl;
+ switch( tmp )
+ {
+ case -1:
+ m_page_effect = "random";
+ break;
+ case 1:
+ m_page_effect = "close-vertical";
+ break;
+ case 2:
+ m_page_effect = "close-horizontal";
+ break;
+ case 3:
+ m_page_effect = "fade-to-center";
+ break;
+ case 4:
+ m_page_effect = "open-vertical";
+ break;
+ case 5:
+ m_page_effect = "open-horizontal";
+ break;
+ case 6:
+ m_page_effect = "fade-from-center";
+ break;
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 11:
+ m_page_effect = "spiralin-left";
+ break;
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 19:
+ m_page_effect = "fade-from-top";
+ break;
+ case 20:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 21:
+ m_page_effect = "fade-from-bottom";
+ break;
+ case 22:
+ m_page_effect = "roll-from-bottom";
+ break;
+ case 23:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 24:
+ m_page_effect = "roll-from-right";
+ break;
+ case 25:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 26:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 27:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 28:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 29:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 30:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 31:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 32:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 33:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 34:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ case 35:
+ m_page_effect = "dissolve";
+ break;
+ case 36:
+ m_page_effect = "fade-from-lowerright";
+ break;
+ case 37:
+ m_page_effect = "fade-from-upperright";
+ break;
+ case 38:
+ m_page_effect = "fade-from-lowerleft";
+ break;
+ case 39:
+ m_page_effect = "fade-from-upperleft";
+ break;
+ case 40:
+ kdDebug(30518)<<" this style is not defined :"<<tmp<<endl;
+ break;
+ default:
+ kdDebug(30518)<<" style page effect not define : "<<tmp<<endl;
+ break;
+ }
+ }
+}
+
+void PageStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement style = doc.createElement( "style:style" );
+ style.setAttribute( "style:name", m_name );
+ style.setAttribute( "style:family", "drawing-page" );
+
+ QDomElement properties = doc.createElement( "style:properties" );
+ properties.setAttribute( "presentation:background-visible", m_bg_visible );
+ properties.setAttribute( "presentation:background-objects-visible",
+ m_bg_objects_visible );
+ if ( !m_page_duration.isEmpty() )
+ {
+ properties.setAttribute( "presentation:duration", m_page_duration );
+ properties.setAttribute( "presentation:transition-type", "automatic" );
+ }
+ if ( !m_page_effect.isEmpty() )
+ properties.setAttribute( "presentation:transition-style",
+ m_page_effect );
+ if ( !m_fill.isNull() )
+ properties.setAttribute( "draw:fill", m_fill );
+ if ( !m_fill_color.isNull() )
+ properties.setAttribute( "draw:fill-color", m_fill_color );
+ if ( !m_fill_image_name.isNull() )
+ properties.setAttribute( "draw:fill-image-name", m_fill_image_name );
+ if ( !m_fill_image_width.isNull() )
+ properties.setAttribute( "draw:fill-image-width", m_fill_image_width );
+ if ( !m_fill_image_height.isNull() )
+ properties.setAttribute( "draw:fill-image-height", m_fill_image_height );
+ if ( !m_fill_image_ref_point.isNull() )
+ properties.setAttribute( "draw:fill-image-ref-point", m_fill_image_ref_point );
+ if ( !m_fill_gradient_name.isNull() )
+ properties.setAttribute( "draw:fill-gradient-name", m_fill_gradient_name );
+ if ( !m_repeat.isNull() )
+ properties.setAttribute( "style:repeat", m_repeat );
+
+ style.appendChild( properties );
+ e.appendChild( style );
+}
+
+bool PageStyle::operator==( const PageStyle & pageStyle ) const
+{
+ return ( m_bg_visible == pageStyle.m_bg_visible &&
+ m_bg_objects_visible == pageStyle.m_bg_objects_visible &&
+ m_fill == pageStyle.m_fill &&
+ m_fill_color == pageStyle.m_fill_color &&
+ m_fill_image_name == pageStyle.m_fill_image_name &&
+ m_fill_image_width == pageStyle.m_fill_image_width &&
+ m_fill_image_height == pageStyle.m_fill_image_height &&
+ m_fill_image_ref_point == pageStyle.m_fill_image_ref_point &&
+ m_fill_gradient_name == pageStyle.m_fill_gradient_name &&
+ m_repeat == pageStyle.m_repeat &&
+ m_page_effect == pageStyle.m_page_effect &&
+ m_page_duration == pageStyle.m_page_duration );
+}
+
+TextStyle::TextStyle( QDomElement & e, const uint index )
+{
+ m_name = QString( "T%1" ).arg( index );
+ if ( e.hasAttribute( "family" ) )
+ m_font_family = e.attribute( "family" );
+ if ( e.hasAttribute( "pointSize" ) )
+ m_font_size = QString( "%1pt" ).arg( e.attribute( "pointSize" ) );
+ if ( e.hasAttribute( "color" ) )
+ m_color = e.attribute( "color" );
+ if ( e.hasAttribute( "bold" ) && e.attribute( "bold" ) == "1" )
+ m_font_weight = "bold";
+ if ( e.hasAttribute( "italic" ) && e.attribute( "italic" ) == "1" )
+ m_font_style = "italic";
+ if ( e.hasAttribute( "strikeOut" ) )
+ {
+ if ( e.attribute( "strikeOut" ) == "single" )
+ m_text_crossing_out = "single-line";
+ else if ( e.attribute( "strikeOut" ) == "single-bold" )
+ m_text_crossing_out = "thick-line";
+ else if ( e.attribute( "strikeOut" ) == "double" )
+ m_text_crossing_out = "double-line";
+ }
+ if ( e.hasAttribute( "underline" ) )
+ {
+ QString underline = e.attribute( "underline" );
+ QString style = e.attribute( "underlinestyleline" );
+ m_text_underline_color = e.attribute( "underlinecolor" );
+
+ if ( style == "solid" )
+ {
+ if ( underline == "1" )
+ m_text_underline = "single";
+ else if ( underline == "single-bold" )
+ m_text_underline = "bold";
+ else if ( underline == "double" )
+ m_text_underline = "double";
+ else if ( underline == "wave" )
+ m_text_underline = "wave";
+ }
+ else if ( style == "dot" )
+ {
+ if ( underline == "1" )
+ m_text_underline = "dotted";
+ else if ( underline == "single-bold" )
+ m_text_underline = "bold-dotted";
+ }
+ else if ( style == "dash" )
+ m_text_underline = "dash";
+ }
+}
+
+void TextStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement style = doc.createElement( "style:style" );
+ style.setAttribute( "style:name", m_name );
+ style.setAttribute( "style:family", "text" );
+
+ QDomElement properties = doc.createElement( "style:properties" );
+ if ( !m_font_size.isNull() )
+ properties.setAttribute( "fo:font-size", m_font_size );
+ if ( !m_font_family.isNull() )
+ properties.setAttribute( "fo:font-family", m_font_family );
+ if ( !m_font_family_generic.isNull() )
+ properties.setAttribute( "fo:font-family-generic", m_font_family_generic );
+ if ( !m_color.isNull() )
+ properties.setAttribute( "fo:color", m_color );
+ if ( !m_font_pitch.isNull() )
+ properties.setAttribute( "style:font-pitch", m_font_pitch );
+ if ( !m_font_style.isNull() )
+ properties.setAttribute( "fo:font-style", m_font_style );
+ if ( !m_font_weight.isNull() )
+ properties.setAttribute( "fo:font-weight", m_font_weight );
+ if ( !m_text_shadow.isNull() )
+ properties.setAttribute( "fo:text-shadow", m_text_shadow );
+ if ( !m_text_underline.isNull() )
+ properties.setAttribute( "style:text-underline", m_text_underline );
+ if ( !m_text_underline_color.isNull() )
+ properties.setAttribute( "style:text-underline-color", m_text_underline_color );
+ if ( !m_text_crossing_out.isNull() )
+ properties.setAttribute( "style:text-crossing-out", m_text_crossing_out );
+
+ style.appendChild( properties );
+ e.appendChild( style );
+}
+
+bool TextStyle::operator==( const TextStyle & textStyle ) const
+{
+ return ( m_font_size == textStyle.m_font_size &&
+ m_font_family == textStyle.m_font_family &&
+ m_font_family_generic == textStyle.m_font_family_generic &&
+ m_color == textStyle.m_color &&
+ m_font_pitch == textStyle.m_font_pitch &&
+ m_font_style == textStyle.m_font_style &&
+ m_font_weight == textStyle.m_font_weight &&
+ m_text_shadow == textStyle.m_text_shadow &&
+ m_text_underline == textStyle.m_text_underline &&
+ m_text_underline_color == textStyle.m_text_underline_color &&
+ m_text_crossing_out == textStyle.m_text_crossing_out );
+}
+
+GraphicStyle::GraphicStyle( StyleFactory * styleFactory, QDomElement & e, const uint index )
+{
+ QDomNode pen = e.namedItem( "PEN" );
+ QDomNode brush = e.namedItem( "BRUSH" );
+ QDomNode linebegin = e.namedItem( "LINEBEGIN" );
+ QDomNode lineend = e.namedItem( "LINEEND" );
+ QDomNode gradient = e.namedItem( "GRADIENT" );
+ QDomNode shadow = e.namedItem( "SHADOW" );
+ QDomNode textObject = e.namedItem( "TEXTOBJ" );
+ if ( !textObject.isNull() )
+ {
+ QDomElement textObjectElement = textObject.toElement();
+ if ( textObjectElement.hasAttribute( "verticalAlign" ) )
+ {
+ m_textAlignment = textObjectElement.attribute("verticalAlign");
+ if ( m_textAlignment == "center" )
+ m_textAlignment = "middle";
+ }
+ if ( textObjectElement.hasAttribute( "bleftpt" ) )
+ {
+ m_textMarginLeft = QString( "%1pt" ).arg( textObjectElement.attribute( "bleftpt" ) );
+ }
+ if ( textObjectElement.hasAttribute( "bbottompt" ) )
+ {
+ m_textMarginBottom = QString( "%1pt" ).arg( textObjectElement.attribute( "bbottompt" ) );
+ }
+ if ( textObjectElement.hasAttribute( "btoppt" ) )
+ {
+ m_textMarginTop = QString( "%1pt" ).arg( textObjectElement.attribute( "btoppt" ) );
+ }
+ if ( textObjectElement.hasAttribute( "brightpt" ) )
+ {
+ m_textMarginRight = QString( "%1pt" ).arg( textObjectElement.attribute( "brightpt" ) );
+ }
+
+ }
+ kdDebug(30518)<<" alignment :"<<m_textAlignment<<endl;
+
+ m_name = QString( "gr%1" ).arg( index );
+ if ( !pen.isNull() )
+ {
+ QDomElement p = pen.toElement();
+ m_stroke_width = StyleFactory::toCM( p.attribute( "width" ) );
+ m_stroke_color = p.attribute( "color" );
+
+ int style = p.attribute( "style" ).toInt();
+ if ( style == 1 )
+ m_stroke = "solid";
+ else if ( style >= 2 && style <= 5 )
+ {
+ m_stroke = "dash";
+ m_stroke_dash = styleFactory->createStrokeDashStyle( style );
+ }
+ else
+ m_stroke = "none";
+ }
+
+ if ( !brush.isNull() )
+ {
+ QDomElement b = brush.toElement();
+ m_fill_color = b.attribute( "color" );
+
+ int style = b.attribute( "style" ).toInt();
+ if ( style == 1 )
+ m_fill = "solid";
+ else if ( style >= 9 && style <= 14 )
+ {
+ m_fill = "hatch";
+ m_fill_hatch_name = styleFactory->createHatchStyle( style, m_fill_color );
+ }
+ else if ( style >= 2 && style <= 8 )
+ {
+ if ( style == 2 )
+ m_transparency = "94%";
+ else if ( style == 3 )
+ m_transparency = "88%";
+ else if ( style == 4 )
+ m_transparency = "63%";
+ else if ( style == 5 )
+ m_transparency = "50%";
+ else if ( style == 6 )
+ m_transparency = "37%";
+ else if ( style == 7 )
+ m_transparency = "12%";
+ else if ( style == 8 )
+ m_transparency = "6%";
+ }
+ }
+ else if ( !gradient.isNull() )
+ {
+ QDomElement g = gradient.toElement();
+ m_fill = "gradient";
+ m_fill_gradient_name = styleFactory->createGradientStyle( g );
+ }
+ else
+ m_fill = "none";
+
+ if ( !linebegin.isNull() )
+ {
+ QDomElement lb = linebegin.toElement();
+ m_marker_start_width = "0.25cm";
+
+ int style = lb.attribute( "value" ).toInt();
+ m_marker_start = styleFactory->createMarkerStyle( style );
+ }
+
+ if ( !lineend.isNull() )
+ {
+ QDomElement le = lineend.toElement();
+ m_marker_end_width = "0.25cm";
+
+ int style = le.attribute( "value" ).toInt();
+ m_marker_end = styleFactory->createMarkerStyle( style );
+ }
+
+ if ( !shadow.isNull() )
+ {
+ QDomElement s = shadow.toElement();
+ m_shadow = "visible";
+ m_shadow_color = s.attribute( "color" );
+
+ int direction = s.attribute( "direction" ).toInt();
+ QString distance = StyleFactory::toCM( s.attribute( "distance" ) );
+ switch ( direction )
+ {
+ case 1:
+ m_shadow_offset_x = "-" + distance;
+ m_shadow_offset_y = "-" + distance;
+ break;
+ case 2:
+ m_shadow_offset_x = "0cm";
+ m_shadow_offset_y = "-" + distance;
+ break;
+ case 3:
+ m_shadow_offset_x = distance;
+ m_shadow_offset_y = "-" + distance;
+ break;
+ case 4:
+ m_shadow_offset_x = distance;
+ m_shadow_offset_y = "0cm";
+ break;
+ case 5:
+ m_shadow_offset_x = distance;
+ m_shadow_offset_y = distance;
+ break;
+ case 6:
+ m_shadow_offset_x = "0cm";
+ m_shadow_offset_y = distance;
+ break;
+ case 7:
+ m_shadow_offset_x = "-" + distance;
+ m_shadow_offset_y = distance;
+ break;
+ case 8:
+ m_shadow_offset_x = "-" + distance;
+ m_shadow_offset_y = "0cm";
+ break;
+ }
+ }
+}
+
+GraphicStyle::GraphicStyle( const char * name,
+ const char * stroke, const char * stroke_color,
+ const char * stroke_width, const char * shadow,
+ const char * shadow_offset_x, const char * shadow_offset_y,
+ const char * shadow_color, const char * margin_left,
+ const char * margin_right, const char * margin_top,
+ const char * margin_bottom, const char * color,
+ const char * text_outline, const char * text_crossing_out,
+ const char * font_family, const char * font_size,
+ const char * font_style, const char * text_shadow,
+ const char * text_underline, const char * font_weight,
+ const char * line_height, const char * text_align,
+ const char * fill, const char * fill_color,
+ const char * enable_numbering )
+ : m_name( name )
+ , m_stroke( stroke )
+ , m_stroke_color( stroke_color )
+ , m_stroke_width( stroke_width )
+ , m_shadow( shadow )
+ , m_shadow_offset_x( shadow_offset_x )
+ , m_shadow_offset_y( shadow_offset_y )
+ , m_shadow_color( shadow_color )
+ , m_margin_left( margin_left )
+ , m_margin_right( margin_right )
+ , m_margin_top( margin_top )
+ , m_margin_bottom( margin_bottom )
+ , m_color( color )
+ , m_text_outline( text_outline )
+ , m_text_crossing_out( text_crossing_out )
+ , m_font_family( font_family )
+ , m_font_size( font_size )
+ , m_font_style( font_style )
+ , m_text_shadow( text_shadow )
+ , m_text_underline( text_underline )
+ , m_font_weight( font_weight )
+ , m_line_height( line_height )
+ , m_text_align( text_align )
+ , m_fill( fill )
+ , m_fill_color( fill_color )
+ , m_enable_numbering( enable_numbering )
+{
+}
+
+
+void GraphicStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement style = doc.createElement( "style:style" );
+ style.setAttribute( "style:name", m_name );
+ style.setAttribute( "style:family", "graphics" );
+ if ( m_name != "standard" )
+ style.setAttribute( "style:parent-style-name", "standard" );
+
+ QDomElement properties = doc.createElement( "style:properties" );
+ if ( !m_stroke.isNull() )
+ properties.setAttribute( "draw:stroke", m_stroke );
+ if ( !m_stroke_dash.isNull() )
+ properties.setAttribute( "draw:stroke-dash", m_stroke_dash );
+ if ( !m_stroke_color.isNull() )
+ properties.setAttribute( "svg:stroke-color", m_stroke_color );
+ if ( !m_stroke_width.isNull() )
+ properties.setAttribute( "svg:stroke-width", m_stroke_width );
+ if ( !m_shadow.isNull() )
+ properties.setAttribute( "draw:shadow", m_shadow );
+ if ( !m_shadow_offset_x.isNull() )
+ properties.setAttribute( "draw:shadow-offset-x", m_shadow_offset_x );
+ if ( !m_shadow_offset_y.isNull() )
+ properties.setAttribute( "draw:shadow-offset-y", m_shadow_offset_y );
+ if ( !m_shadow_color.isNull() )
+ properties.setAttribute( "draw:shadow-color", m_shadow_color );
+ if ( !m_margin_left.isNull() )
+ properties.setAttribute( "fo:margin-left", m_margin_left );
+ if ( !m_margin_right.isNull() )
+ properties.setAttribute( "fo:margin-right", m_margin_right );
+ if ( !m_margin_top.isNull() )
+ properties.setAttribute( "fo:margin-top", m_margin_top );
+ if ( !m_margin_bottom.isNull() )
+ properties.setAttribute( "fo:margin-bottom", m_margin_bottom );
+ if ( !m_color.isNull() )
+ properties.setAttribute( "fo:color", m_color );
+ if ( !m_text_outline.isNull() )
+ properties.setAttribute( "style:text-outline", m_text_outline );
+ if ( !m_text_crossing_out.isNull() )
+ properties.setAttribute( "style:text-crossing-out", m_text_crossing_out );
+ if ( !m_font_family.isNull() )
+ properties.setAttribute( "fo:font-family", m_font_family );
+ if ( !m_font_size.isNull() )
+ properties.setAttribute( "fo:font-size", m_font_size );
+ if ( !m_font_style.isNull() )
+ properties.setAttribute( "fo:font-style", m_font_style );
+ if ( !m_text_shadow.isNull() )
+ properties.setAttribute( "fo:text-shadow", m_text_shadow );
+ if ( !m_text_underline.isNull() )
+ properties.setAttribute( "style:text-underline", m_text_underline );
+ if ( !m_font_weight.isNull() )
+ properties.setAttribute( "fo:font-weight", m_font_weight );
+ if ( !m_line_height.isNull() )
+ properties.setAttribute( "fo:line-height", m_line_height );
+ if ( !m_text_align.isNull() )
+ properties.setAttribute( "fo:text-align", m_text_align );
+ if ( !m_fill.isNull() )
+ properties.setAttribute( "draw:fill", m_fill );
+ if ( !m_fill_color.isNull() )
+ properties.setAttribute( "draw:fill-color", m_fill_color );
+ if ( !m_fill_hatch_name.isNull() )
+ properties.setAttribute( "draw:fill-hatch-name", m_fill_hatch_name );
+ if ( !m_enable_numbering.isNull() )
+ properties.setAttribute( "text:enable-numbering", m_enable_numbering );
+ if ( !m_marker_start.isNull() )
+ properties.setAttribute( "draw:marker-start", m_marker_start );
+ if ( !m_marker_start_width.isNull() )
+ properties.setAttribute( "draw:marker-start-width", m_marker_start_width );
+ if ( !m_marker_end.isNull() )
+ properties.setAttribute( "draw:marker-end", m_marker_end );
+ if ( !m_marker_end_width.isNull() )
+ properties.setAttribute( "draw:marker-end-width", m_marker_end_width );
+ if ( !m_fill_gradient_name.isNull() )
+ properties.setAttribute( "draw:fill-gradient-name", m_fill_gradient_name );
+ if ( !m_transparency.isNull() )
+ properties.setAttribute( "draw:transparency", m_transparency );
+ if ( !m_textAlignment.isNull() )
+ properties.setAttribute( "draw:textarea-vertical-align", m_textAlignment );
+ if ( !m_textMarginLeft.isNull() )
+ properties.setAttribute( "fo:padding-left", m_textMarginLeft );
+ if ( !m_textMarginBottom.isNull() )
+ properties.setAttribute( "fo:padding-bottom", m_textMarginBottom );
+ if ( !m_textMarginTop.isNull() )
+ properties.setAttribute( "fo:padding-top", m_textMarginTop );
+ if ( !m_textMarginRight.isNull() )
+ properties.setAttribute( "fo:padding-right", m_textMarginRight );
+
+
+ style.appendChild( properties );
+ e.appendChild( style );
+}
+
+bool GraphicStyle::operator==( const GraphicStyle & graphicStyle ) const
+{
+ return ( m_stroke == graphicStyle.m_stroke &&
+ m_stroke_dash == graphicStyle.m_stroke_dash &&
+ m_stroke_color == graphicStyle.m_stroke_color &&
+ m_stroke_width == graphicStyle.m_stroke_width &&
+ m_shadow == graphicStyle.m_shadow &&
+ m_shadow_offset_x == graphicStyle.m_shadow_offset_x &&
+ m_shadow_offset_y == graphicStyle.m_shadow_offset_y &&
+ m_shadow_color == graphicStyle.m_shadow_color &&
+ m_margin_left == graphicStyle.m_margin_left &&
+ m_margin_right == graphicStyle.m_margin_right &&
+ m_margin_top == graphicStyle.m_margin_top &&
+ m_margin_bottom == graphicStyle.m_margin_bottom &&
+ m_color == graphicStyle.m_color &&
+ m_text_outline == graphicStyle.m_text_outline &&
+ m_text_crossing_out == graphicStyle.m_text_crossing_out &&
+ m_font_family == graphicStyle.m_font_family &&
+ m_font_size == graphicStyle.m_font_size &&
+ m_font_style == graphicStyle.m_font_style &&
+ m_text_shadow == graphicStyle.m_text_shadow &&
+ m_text_underline == graphicStyle.m_text_underline &&
+ m_font_weight == graphicStyle.m_font_weight &&
+ m_line_height == graphicStyle.m_line_height &&
+ m_text_align == graphicStyle.m_text_align &&
+ m_fill == graphicStyle.m_fill &&
+ m_fill_color == graphicStyle.m_fill_color &&
+ m_fill_hatch_name == graphicStyle.m_fill_hatch_name &&
+ m_enable_numbering == graphicStyle.m_enable_numbering &&
+ m_marker_start == graphicStyle.m_marker_start &&
+ m_marker_start_width == graphicStyle.m_marker_start_width &&
+ m_marker_end == graphicStyle.m_marker_end &&
+ m_marker_end_width == graphicStyle.m_marker_end_width &&
+ m_fill_gradient_name == graphicStyle.m_fill_gradient_name &&
+ m_transparency == graphicStyle.m_transparency &&
+ m_textAlignment == graphicStyle.m_textAlignment &&
+ m_textMarginLeft == graphicStyle.m_textMarginLeft &&
+ m_textMarginBottom == graphicStyle.m_textMarginBottom &&
+ m_textMarginTop == graphicStyle.m_textMarginTop &&
+ m_textMarginRight == graphicStyle.m_textMarginRight);
+}
+
+ParagraphStyle::ParagraphStyle( QDomElement & e, const uint index )
+{
+ // some defaults that may be overwritten
+ m_margin_left = "0cm";
+ m_margin_right = "0cm";
+ m_text_indent = "0cm";
+
+ QDomNode shadow = e.namedItem( "SHADOW" );
+ QDomNode indents = e.namedItem( "INDENTS" );
+ QDomNode offsets = e.namedItem( "OFFSETS" );
+ QDomNode leftBorder = e.namedItem( "LEFTBORDER" );
+ QDomNode rightBorder = e.namedItem( "RIGHTBORDER" );
+ QDomNode topBorder = e.namedItem( "TOPBORDER" );
+ QDomNode bottomBorder = e.namedItem( "BOTTOMBORDER" );
+ QDomNode lineSpacing = e.namedItem( "LINESPACING" );
+ QDomNode counter = e.namedItem( "COUNTER" );
+
+ m_name = QString( "P%1" ).arg( index );
+ if ( e.hasAttribute( "align" ) )
+ {
+ int align = e.attribute( "align" ).toInt();
+ switch ( align )
+ {
+ case 0: // left
+ m_text_align = "start";
+ break;
+ case 2: // right
+ m_text_align = "end";
+ break;
+ case 4: // center
+ m_text_align = "center";
+ break;
+ case 8: // justify
+ m_text_align = "justify";
+ break;
+ }
+ }
+
+ if ( !shadow.isNull() )
+ {
+ QDomElement s = shadow.toElement();
+ QString distance = QString( "%1pt" ).arg( s.attribute( "distance" ) );
+ m_text_shadow = distance + " " + distance;
+ }
+
+ if ( !indents.isNull() )
+ {
+ QDomElement i = indents.toElement();
+ m_margin_left = StyleFactory::toCM( i.attribute( "left" ) );
+ m_margin_right = StyleFactory::toCM( i.attribute( "right" ) );
+ m_text_indent = StyleFactory::toCM( i.attribute( "first" ) );
+ }
+
+ if ( !offsets.isNull() )
+ {
+ QDomElement o = offsets.toElement();
+ m_margin_top = StyleFactory::toCM( o.attribute( "before" ) );
+ m_margin_bottom = StyleFactory::toCM( o.attribute( "after" ) );
+ }
+
+ if ( !leftBorder.isNull() )
+ m_border_left = parseBorder( leftBorder.toElement() );
+ if ( !rightBorder.isNull() )
+ m_border_right = parseBorder( rightBorder.toElement() );
+ if ( !topBorder.isNull() )
+ m_border_top = parseBorder( topBorder.toElement() );
+ if ( !bottomBorder.isNull() )
+ m_border_bottom = parseBorder( bottomBorder.toElement() );
+
+ if ( !lineSpacing.isNull() )
+ {
+ QDomElement l = lineSpacing.toElement();
+ QString type = l.attribute( "type" );
+
+ if ( type == "single" )
+ m_line_height = "100%";
+ else if ( type == "oneandhalf" )
+ m_line_height = "150%";
+ else if ( type == "double" )
+ m_line_height = "200%";
+ else if ( type == "multiple" )
+ m_line_height = QString( "%1%" ).arg( l.attribute( "spacingvalue" ).toInt() * 100 );
+ else if ( type == "custom" )
+ m_line_spacing = StyleFactory::toCM( l.attribute( "spacingvalue" ) );
+ else if ( type == "atleast" )
+ m_line_height_at_least = StyleFactory::toCM( l.attribute( "spacingvalue" ) );
+ }
+
+ if ( !counter.isNull() )
+ m_enable_numbering = "true";
+}
+
+void ParagraphStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement style = doc.createElement( "style:style" );
+ style.setAttribute( "style:name", m_name );
+ style.setAttribute( "style:family", "paragraph" );
+
+ QDomElement properties = doc.createElement( "style:properties" );
+ if ( !m_margin_left.isNull() )
+ properties.setAttribute( "fo:margin-left", m_margin_left );
+ if ( !m_margin_right.isNull() )
+ properties.setAttribute( "fo:margin-right", m_margin_right );
+ if ( !m_text_indent.isNull() )
+ properties.setAttribute( "fo:text-indent", m_text_indent );
+ if ( !m_text_align.isNull() )
+ properties.setAttribute( "fo:text-align", m_text_align );
+ if ( !m_enable_numbering.isNull() )
+ properties.setAttribute( "text:enable-numbering", m_enable_numbering );
+ if ( !m_text_shadow.isNull() )
+ properties.setAttribute( "fo:text-shadow", m_text_shadow );
+ if ( !m_margin_top.isNull() )
+ properties.setAttribute( "fo:margin-top", m_margin_top );
+ if ( !m_margin_bottom.isNull() )
+ properties.setAttribute( "fo:margin-bottom", m_margin_bottom );
+ if ( !m_border_left.isNull() )
+ properties.setAttribute( "fo:border-left", m_border_left );
+ if ( !m_border_right.isNull() )
+ properties.setAttribute( "fo:border-right", m_border_right );
+ if ( !m_border_top.isNull() )
+ properties.setAttribute( "fo:border-top", m_border_top );
+ if ( !m_border_bottom.isNull() )
+ properties.setAttribute( "fo:border-bottom", m_border_bottom );
+ if ( !m_line_height.isNull() )
+ properties.setAttribute( "fo:line-height", m_line_height );
+ if ( !m_line_height_at_least.isNull() )
+ properties.setAttribute( "style:line-height-at-least", m_line_height_at_least );
+ if ( !m_line_spacing.isNull() )
+ properties.setAttribute( "style:line-spacing", m_line_spacing );
+
+ style.appendChild( properties );
+ e.appendChild( style );
+}
+
+bool ParagraphStyle::operator==( const ParagraphStyle & paragraphStyle ) const
+{
+ return ( m_margin_left == paragraphStyle.m_margin_left &&
+ m_margin_right == paragraphStyle.m_margin_right &&
+ m_text_indent == paragraphStyle.m_text_indent &&
+ m_text_align == paragraphStyle.m_text_align &&
+ m_enable_numbering == paragraphStyle.m_enable_numbering &&
+ m_text_shadow == paragraphStyle.m_text_shadow &&
+ m_margin_top == paragraphStyle.m_margin_top &&
+ m_margin_bottom == paragraphStyle.m_margin_bottom &&
+ m_border_left == paragraphStyle.m_border_left &&
+ m_border_right == paragraphStyle.m_border_right &&
+ m_border_top == paragraphStyle.m_border_top &&
+ m_border_bottom == paragraphStyle.m_border_bottom &&
+ m_line_height == paragraphStyle.m_line_height &&
+ m_line_height_at_least == paragraphStyle.m_line_height_at_least &&
+ m_line_spacing == paragraphStyle.m_line_spacing );
+}
+
+QString ParagraphStyle::parseBorder( QDomElement e )
+{
+ QString style;
+ int _style = e.attribute( "style" ).toInt();
+ if ( _style == 5 )
+ style = "double";
+ else
+ style = "solid";
+
+ QString width = StyleFactory::toCM( e.attribute( "width" ) );
+
+ QColor color( e.attribute( "red" ).toInt(),
+ e.attribute( "green" ).toInt(),
+ e.attribute( "blue" ).toInt() );
+
+ return QString( "%1 %2 %3" ).arg( width ).arg( style ).arg( color.name() );
+}
+
+ListStyle::ListStyle( QDomElement & e, const uint index )
+{
+ // setting some default values
+ m_min_label_width = 0.6;
+ m_color = "#000000";
+ m_font_size = "100%";
+
+ m_name = QString( "L%1" ).arg( index );
+
+ if ( e.hasAttribute( "type" ) )
+ {
+ int type = e.attribute( "type" ).toInt();
+ switch ( type )
+ {
+ case 1: // arabic numbers
+ m_listLevelStyle = LLS_NUMBER;
+ m_num_suffix = ".";
+ m_num_format = "1";
+ break;
+ case 2: // lower alphabetical
+ m_listLevelStyle = LLS_NUMBER;
+ m_num_suffix = ".";
+ m_num_format = "a";
+ break;
+ case 3: // upper alphabetical
+ m_listLevelStyle = LLS_NUMBER;
+ m_num_suffix = ".";
+ m_num_format = "A";
+ break;
+ case 4: // lower roman
+ m_listLevelStyle = LLS_NUMBER;
+ m_num_suffix = ".";
+ m_num_format = "i";
+ break;
+ case 5: // upper roman
+ m_listLevelStyle = LLS_NUMBER;
+ m_num_suffix = ".";
+ m_num_format = "I";
+ break;
+ case 6: // custom
+ m_listLevelStyle = LLS_BULLET;
+ if ( e.hasAttribute( "text" ) )
+ m_bullet_char = e.attribute( "text" );
+ break;
+ case 8: // circle bullet
+ m_listLevelStyle = LLS_BULLET;
+ break;
+ case 9: // square bullet
+ m_listLevelStyle = LLS_BULLET;
+ break;
+ case 10: // disc bullet
+ m_listLevelStyle = LLS_BULLET;
+ break;
+ case 11: // box bullet
+ m_listLevelStyle = LLS_BULLET;
+ break;
+ }
+ }
+
+ if ( e.hasAttribute( "bulletfont" ) )
+ m_font_family = e.attribute( "bulletfont" );
+}
+
+void ListStyle::toXML( QDomDocument & doc, QDomElement & e ) const
+{
+ QDomElement style = doc.createElement( "text:list-style" );
+ style.setAttribute( "style:name", m_name );
+
+ for ( int level = 1; level <= 10; level++ )
+ {
+ QDomElement listLevelStyle;
+ if ( m_listLevelStyle == LLS_NUMBER )
+ {
+ listLevelStyle = doc.createElement( "text:list-level-style-number" );
+ listLevelStyle.setAttribute( "text:level", level );
+ if ( !m_num_suffix.isNull() )
+ listLevelStyle.setAttribute( "style:num-suffix", m_num_suffix );
+ if ( !m_num_format.isNull() )
+ listLevelStyle.setAttribute( "style:num-format", m_num_format );
+ }
+ else
+ {
+ listLevelStyle = doc.createElement( "text:list-level-style-bullet" );
+ listLevelStyle.setAttribute( "text:level", level );
+ if ( !m_bullet_char.isNull() )
+ listLevelStyle.setAttribute( "text:bullet-char", m_bullet_char );
+ }
+
+ QDomElement properties = doc.createElement( "style:properties" );
+ if ( level > 1 )
+ {
+ properties.setAttribute( "text:min-label-width",
+ QString( "%1cm" ).arg( m_min_label_width ) );
+ properties.setAttribute( "text:space-before",
+ QString( "%1cm" ).arg( m_min_label_width * ( level - 1 ) ) );
+ }
+
+ if ( !m_color.isNull() )
+ properties.setAttribute( "fo:color", m_color );
+ if ( !m_font_size.isNull() )
+ properties.setAttribute( "fo:font-size", m_font_size );
+ if ( !m_font_family.isNull() )
+ properties.setAttribute( "fo:font-family", m_font_family );
+
+ listLevelStyle.appendChild( properties );
+ style.appendChild( listLevelStyle );
+ }
+ e.appendChild( style );
+}
+
+bool ListStyle::operator==( const ListStyle & listStyle ) const
+{
+ return ( m_listLevelStyle == listStyle.m_listLevelStyle &&
+ m_num_suffix == listStyle.m_num_suffix &&
+ m_num_format == listStyle.m_num_format &&
+ m_bullet_char == listStyle.m_bullet_char &&
+ m_min_label_width == listStyle.m_min_label_width &&
+ m_color == listStyle.m_color &&
+ m_font_size == listStyle.m_font_size &&
+ m_font_family == listStyle.m_font_family );
+}
diff --git a/filters/kpresenter/ooimpress/stylefactory.h b/filters/kpresenter/ooimpress/stylefactory.h
new file mode 100644
index 00000000..9de6a548
--- /dev/null
+++ b/filters/kpresenter/ooimpress/stylefactory.h
@@ -0,0 +1,282 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Percy Leonhardt
+
+ 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 STYLEFACTORY_H
+#define STYLEFACTORY_H
+
+#include <qptrlist.h>
+#include <qstring.h>
+
+#include <qdom.h>
+
+class StyleFactory;
+
+class StrokeDashStyle
+{
+public:
+ StrokeDashStyle( int style );
+ ~StrokeDashStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ QString name() const { return m_name; };
+
+private:
+ StrokeDashStyle() {};
+
+ QString m_name, m_style, m_dots1, m_dots2, m_dots1_length, m_dots2_length,
+ m_distance;
+};
+
+class GradientStyle
+{
+public:
+ GradientStyle( QDomElement & gradient, int index );
+ ~GradientStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ QString name() const { return m_name; };
+
+private:
+ GradientStyle() {};
+
+ QString m_name, m_style, m_cx, m_cy, m_start_color, m_end_color,
+ m_start_intensity, m_end_intensity, m_angle, m_border;
+};
+
+class MarkerStyle
+{
+public:
+ MarkerStyle( int style );
+ ~MarkerStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ QString name() const { return m_name; };
+
+private:
+ MarkerStyle() {};
+
+ QString m_name, m_viewBox, m_d;
+};
+
+class HatchStyle
+{
+public:
+ HatchStyle( int style, QString & color );
+ ~HatchStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ QString name() const { return m_name; };
+
+private:
+ HatchStyle() {};
+
+ QString m_name, m_style, m_color, m_distance, m_rotation;
+};
+
+class FillImageStyle
+{
+public:
+ FillImageStyle( QString & name );
+ ~FillImageStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+
+private:
+ FillImageStyle() {};
+
+ QString m_name, m_href, m_type, m_show, m_actuate;
+};
+
+class PageMasterStyle
+{
+public:
+ PageMasterStyle( QDomElement & e, const uint index );
+ ~PageMasterStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ bool operator==( const PageMasterStyle & pageMasterStyle ) const;
+ QString name() const { return m_name; };
+ QString style() const { return m_style; };
+
+private:
+ PageMasterStyle() {};
+
+ QString m_name, m_page_width, m_page_height, m_orientation, m_style;
+ QString m_margin_top, m_margin_bottom, m_margin_left, m_margin_right;
+};
+
+class PageStyle
+{
+public:
+ PageStyle( StyleFactory * styleFactory, QDomElement & e, const uint index );
+ ~PageStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ bool operator==( const PageStyle & pageStyle ) const;
+ QString name() const { return m_name; };
+
+private:
+ PageStyle() {};
+
+ QString m_name, m_bg_visible, m_bg_objects_visible, m_fill, m_fill_color,
+ m_fill_image_name, m_fill_image_width, m_fill_image_height,
+ m_fill_image_ref_point, m_fill_gradient_name, m_repeat, m_page_effect,
+ m_page_duration;
+};
+
+class TextStyle
+{
+public:
+ TextStyle( QDomElement & e, const uint index );
+ ~TextStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ bool operator==( const TextStyle & textStyle ) const;
+ QString name() const { return m_name; };
+
+private:
+ TextStyle() {};
+
+ QString m_name, m_font_size, m_font_family, m_font_family_generic,
+ m_color, m_font_pitch, m_font_style, m_font_weight, m_text_shadow,
+ m_text_underline, m_text_underline_color, m_text_crossing_out;
+};
+
+class GraphicStyle
+{
+public:
+ GraphicStyle( StyleFactory * styleFactory, QDomElement & e, const uint index );
+ GraphicStyle( const char * name,
+ const char * stroke, const char * stroke_color,
+ const char * stroke_width, const char * shadow,
+ const char * shadow_offset_x, const char * shadow_offset_y,
+ const char * shadow_color, const char * margin_left,
+ const char * margin_right, const char * margin_top,
+ const char * margin_bottom, const char * color,
+ const char * text_outline, const char * text_crossing_out,
+ const char * font_family, const char * font_size,
+ const char * font_style, const char * text_shadow,
+ const char * text_underline, const char * font_weight,
+ const char * line_height, const char * text_align,
+ const char * fill, const char * fill_color,
+ const char * enable_numbering );
+ ~GraphicStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ bool operator==( const GraphicStyle & graphicStyle ) const;
+ QString name() const { return m_name; };
+
+private:
+ GraphicStyle() {};
+
+ QString m_name, m_stroke, m_stroke_color, m_stroke_width, m_shadow,
+ m_shadow_offset_x, m_shadow_offset_y, m_shadow_color, m_margin_left,
+ m_margin_right, m_margin_top, m_margin_bottom, m_color, m_text_outline,
+ m_text_crossing_out, m_font_family, m_font_size, m_font_style,
+ m_text_shadow, m_text_underline, m_font_weight, m_line_height,
+ m_text_align, m_fill, m_fill_color, m_enable_numbering, m_stroke_dash,
+ m_fill_hatch_name, m_marker_start, m_marker_start_width,
+ m_marker_end, m_marker_end_width, m_fill_gradient_name, m_transparency, m_textAlignment,
+ m_textMarginLeft, m_textMarginBottom, m_textMarginTop, m_textMarginRight;
+};
+
+class ParagraphStyle
+{
+public:
+ ParagraphStyle( QDomElement & e, const uint index );
+ ~ParagraphStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ bool operator==( const ParagraphStyle & paragraphStyle ) const;
+ QString name() const { return m_name; };
+
+private:
+ ParagraphStyle() {};
+ QString parseBorder( QDomElement e );
+
+ QString m_name, m_margin_left, m_margin_right, m_text_indent, m_text_align,
+ m_enable_numbering, m_text_shadow, m_margin_top, m_margin_bottom,
+ m_border_left, m_border_right, m_border_top, m_border_bottom,
+ m_line_height, m_line_height_at_least, m_line_spacing;
+};
+
+class ListStyle
+{
+public:
+ ListStyle( QDomElement & e, const uint index );
+ ~ListStyle() {};
+
+ void toXML( QDomDocument & doc, QDomElement & e ) const;
+ bool operator==( const ListStyle & listStyle ) const;
+ QString name() const { return m_name; };
+
+private:
+ ListStyle() {};
+
+ typedef enum {
+ LLS_NUMBER,
+ LLS_BULLET
+ } list_level_style_t;
+
+ float m_min_label_width;
+ list_level_style_t m_listLevelStyle;
+ QString m_name, m_num_suffix, m_num_format, m_bullet_char, m_color,
+ m_font_size, m_font_family;
+};
+
+class StyleFactory
+{
+public:
+ StyleFactory();
+ ~StyleFactory();
+
+ void addOfficeStyles( QDomDocument & doc, QDomElement & styles );
+ void addOfficeMaster( QDomDocument & doc, QDomElement & master );
+ void addOfficeAutomatic( QDomDocument & doc, QDomElement & automatic );
+ void addAutomaticStyles( QDomDocument & doc, QDomElement & autoStyles );
+
+ QString createStrokeDashStyle( int style );
+ QString createGradientStyle( QDomElement & gradient );
+ QString createMarkerStyle( int style );
+ QString createHatchStyle( int style, QString & color );
+ QString createListStyle( QDomElement & e );
+ QString createPageStyle( QDomElement & e );
+ QString createTextStyle( QDomElement & e );
+ QString createGraphicStyle( QDomElement & e );
+ QString createParagraphStyle( QDomElement & e );
+ QString createPageMasterStyle( QDomElement & e );
+
+ static QString toCM( const QString & point );
+
+private:
+ QPtrList<StrokeDashStyle> m_strokeDashStyles;
+ QPtrList<GradientStyle> m_gradientStyles;
+ QPtrList<HatchStyle> m_hatchStyles;
+ QPtrList<MarkerStyle> m_markerStyles;
+ QPtrList<FillImageStyle> m_fillImageStyles;
+ QPtrList<ListStyle> m_listStyles;
+ QPtrList<PageStyle> m_pageStyles;
+ QPtrList<TextStyle> m_textStyles;
+ QPtrList<GraphicStyle> m_graphicStyles;
+ QPtrList<ParagraphStyle> m_paragraphStyles;
+ QPtrList<PageMasterStyle> m_pageMasterStyles;
+};
+
+#endif
diff --git a/filters/kpresenter/png/Makefile.am b/filters/kpresenter/png/Makefile.am
new file mode 100644
index 00000000..0568bfcf
--- /dev/null
+++ b/filters/kpresenter/png/Makefile.am
@@ -0,0 +1,24 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ -I$(top_srcdir)/filters/libdialogfilter \
+ -I$(top_srcdir)/filters/kpresenter/libimageexport \
+ $(all_includes)
+
+####### Files
+
+kde_module_LTLIBRARIES = libkpresenterpngexport.la
+
+libkpresenterpngexport_la_SOURCES = pngexport.cpp
+libkpresenterpngexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined
+libkpresenterpngexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la ../../../filters/libdialogfilter/libdialogfilter.la ../libimageexport/libkpresenterimageexport.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ pngexport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_png_export.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/png/kpresenter_png_export.desktop b/filters/kpresenter/png/kpresenter_png_export.desktop
new file mode 100644
index 00000000..d6ec865f
--- /dev/null
+++ b/filters/kpresenter/png/kpresenter_png_export.desktop
@@ -0,0 +1,52 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter PNG Export Filter
+Name[bg]=Филтър за експортиране от Kpresenter в PNG
+Name[br]=Sil ezporzh PNG evit KPresenter
+Name[ca]=Filtre d'exportació PNG per a KPresenter
+Name[cy]=Hidlen Allforio PNG KPresenter
+Name[da]=KPresenter PNG-eksportfilter
+Name[de]=KPresenter PNG-Exportfilter
+Name[el]=Φίλτρο εξαγωγής PNG του KPresenter
+Name[eo]=KPresenter PNG-eksportfiltrilo
+Name[es]=Filtro de exportación a PNG para KPresenter
+Name[et]=KPresenteri PNG ekspordifilter
+Name[fa]=پالایۀ صادرات KPresenter PNG
+Name[fi]=KPresenter PNG -vientisuodin
+Name[fr]=Filtre d'exportation PNG de KPresenter
+Name[fy]=PMG-Eksportfilter foar KPresenter
+Name[ga]=Scagaire Easpórtála PNG KPresenter
+Name[gl]=Filtro de Exportación de PNG para KPresenter
+Name[he]=KPresenter PNG מסנן יצוא
+Name[hr]=KPresenter PNG filtar izvoza
+Name[hu]=KPresenter PNG exportszűrő
+Name[is]=KPresenter PNG útflutningssía
+Name[it]=Filtro di esportazione PNG per KPresenter
+Name[ja]=KPresenter PNG エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ PNG សម្រាប់ KPresenter
+Name[lt]=KPresenter PNG eksportavimo filtras
+Name[lv]=KPresenter PNG eksporta filtrs
+Name[nb]=PNG-eksportfilter for KPresenter
+Name[nds]=PNG-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता पीएनजी निर्यात फिल्टर
+Name[nl]=KPresenter PNG Exportfilter
+Name[pl]=Filtr eksportu do formatu PNG dla KPresenter
+Name[pt]=Filtro de Exportação de PNG para o KPresenter
+Name[pt_BR]=Filtro de Exportação de PNG para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в PNG
+Name[se]=KPresenter PNG-olggosfievrridansilli
+Name[sk]=Exportný filter KPresenter PNG
+Name[sl]=Izvozni filter PNG za KPresenter
+Name[sr]=KPresenter-ов филтер за извоз у PNG
+Name[sr@Latn]=KPresenter-ov filter za izvoz u PNG
+Name[sv]=Kpresenter PNG-exportfilter
+Name[uk]=Фільтр експорту PNG для KPresenter
+Name[uz]=KPresenter PNG eksport filteri
+Name[uz@cyrillic]=KPresenter PNG экспорт филтери
+Name[zh_CN]=KPresenter PNG 导出过滤器
+Name[zh_TW]=KPresenter PNG 匯出過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Export=image/png
+X-KDE-Weight=1
+X-KDE-Library=libkpresenterpngexport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/png/pngexport.cpp b/filters/kpresenter/png/pngexport.cpp
new file mode 100644
index 00000000..571e7864
--- /dev/null
+++ b/filters/kpresenter/png/pngexport.cpp
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 <qpixmap.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+#include <kgenericfactory.h>
+#include <KoDocument.h>
+
+#include "pngexport.h"
+#include "exportsizedia.h"
+
+typedef KGenericFactory<PngExport, KoFilter> PngExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libkpresenterpngexport, PngExportFactory( "pngexport" ) )
+
+PngExport::PngExport(KoFilter *fil, const char *name, const QStringList&lst)
+ : ImageExport(fil,name,lst)
+{
+}
+
+PngExport::~PngExport()
+{
+}
+
+bool PngExport::extraImageAttribute()
+{
+ bool ret = false;
+ ExportSizeDia *exportDialog = new ExportSizeDia( width, height,
+ 0, "exportdialog");
+ if (exportDialog->exec()) {
+ width = exportDialog->width();
+ height = exportDialog->height();
+ ret = true;
+ kdDebug() << "PNG Export: size = [" << width << "," << height << "]" << endl;
+ }
+ delete exportDialog;
+ return ret;
+}
+
+const char * PngExport::exportFormat()
+{
+ return "image/png";
+}
+
+bool PngExport::saveImage( QString fileName)
+{
+ bool ret = pixmap.save( fileName, "PNG" );
+ // Save the image.
+ if ( !ret ) {
+ KMessageBox::error( 0, i18n( "Failed to write file." ),
+ i18n( "PNG Export Error" ) );
+ }
+ return ret;
+}
+
+
+#include "pngexport.moc"
+
diff --git a/filters/kpresenter/png/pngexport.h b/filters/kpresenter/png/pngexport.h
new file mode 100644
index 00000000..8856dbd8
--- /dev/null
+++ b/filters/kpresenter/png/pngexport.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 __PNGEXPORT_H__
+#define __PNGEXPORT_H__
+
+#include "imageexport.h"
+
+class PngExport : public ImageExport
+{
+ Q_OBJECT
+
+public:
+ PngExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~PngExport();
+ virtual bool saveImage( QString fileName);
+ virtual bool extraImageAttribute();
+ virtual const char * exportFormat();
+};
+
+#endif // __PNGEXPORT_H__
+
diff --git a/filters/kpresenter/powerpoint/Makefile.am b/filters/kpresenter/powerpoint/Makefile.am
new file mode 100644
index 00000000..cd80ba13
--- /dev/null
+++ b/filters/kpresenter/powerpoint/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = libppt import
+
diff --git a/filters/kpresenter/powerpoint/import/Makefile.am b/filters/kpresenter/powerpoint/import/Makefile.am
new file mode 100644
index 00000000..91f27887
--- /dev/null
+++ b/filters/kpresenter/powerpoint/import/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES = -I$(srcdir) -I$(srcdir)/../libppt $(KOFFICE_INCLUDES) $(all_includes)
+
+kde_module_LTLIBRARIES = libpowerpointimport.la
+
+libpowerpointimport_la_SOURCES = powerpointimport.cc
+libpowerpointimport_la_LIBADD = $(KOFFICE_LIBS) ../libppt/libppt.la
+libpowerpointimport_la_LDFLAGS = -module $(KDE_PLUGIN)
+noinst_HEADERS = powerpointimport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_powerpoint_import.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/powerpoint/import/kpresenter_powerpoint_import.desktop b/filters/kpresenter/powerpoint/import/kpresenter_powerpoint_import.desktop
new file mode 100644
index 00000000..99def008
--- /dev/null
+++ b/filters/kpresenter/powerpoint/import/kpresenter_powerpoint_import.desktop
@@ -0,0 +1,51 @@
+[Desktop Entry]
+Type=Service
+Name=Microsoft PowerPoint Import Filter for KPresenter
+Name[bg]=Филтър за импортиране от Microsoft PowerPoint в KPresenter
+Name[br]=Sil enporzh Microsoft PowerPoint evit KPresenter
+Name[ca]=Filtre d'importació Microsoft PowerPoint per a KPresenter
+Name[cy]=Hidlen Fewnforio Microsoft PowerPoint i KPresenter
+Name[da]=Microsoft Powerpoint import-filter for KPresenter
+Name[de]=KPresenter Microsoft PowerPoint-Importfilter
+Name[el]=Φίλτρο εισαγωγής Microsoft PowerPoint για το KPresenter
+Name[es]=Filtro de importación de Microsoft PowerPoint para KPresenter
+Name[et]=KPresenteri Microsoft PowerPoint'i impordifilter
+Name[fa]=پالایۀ واردات Microsoft PowerPoint برای KPresenter
+Name[fi]=Microsoft PowerPoint -tuontisuodin KPresenterille
+Name[fr]=Filtre d'importation Microsoft PowerPoint pour KPresenter
+Name[fy]=Microsoft PowerPoint-Ymportfilter foar KPresenter
+Name[ga]=Scagaire Iompórtála Microsoft PowerPoint le haghaidh KSpread
+Name[gl]=Filtro de Importación de Microsoft PowerPoint para KPresenter
+Name[he]=Microsoft PowerPoint מסנן יבוא ל-KPresenter
+Name[hr]=Microsoft PowerPoint filtar uvoza za KPresenter
+Name[hu]=Microsoft PowerPoint importszűrő a KPresenterhez
+Name[is]=Microsoft PowerPoint innflutningssía fyrir KPresenter
+Name[it]=Filtro di importazione Microsoft PowerPoint per KPresenter
+Name[ja]=KPresenter Microsoft PowerPoint インポートフィルタ
+Name[km]=តម្រង​នាំចូល Microsoft PowerPoint សម្រាប់ KPresenter
+Name[lt]=Microsoft PowerPoint importavimo filtras skirtas KPresenter
+Name[lv]=Microsoft PowerPoint importa filtrs priekš KPresenter
+Name[nb]=Microsoft PowerPoint-importfilter for KPresenter
+Name[nds]="Microsoft PowerPoint"-Importfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ताका लागि माइक्रोसफ्ट पावरपोइन्ट आयात फिल्टर
+Name[nl]= Microsoft Powerpoint importfilter voor KPresenter
+Name[pl]=Filtr importu formatu Microsoft PowerPoint dla KPresenter
+Name[pt]=Filtro de Importação do Microsoft PowerPoint para o KPresenter
+Name[pt_BR]=Filtro de Importação do Microsoft PowerPoint para o KPresenter
+Name[ru]=Фильтр импорта презентаций Microsoft PowerPoint в KPresenter
+Name[se]=KPresenter Microsoft PowerPoint-sisafievrridansilli
+Name[sk]=Filter pre import z Microsoft Power Point-u pre KPresenter
+Name[sl]=Uvozni filter Microsoft PowerPoint za KPresenter
+Name[sr]=KPresenter-ов филтер за увоз из Microsoft-овог PowerPoint-а
+Name[sr@Latn]=KPresenter-ov filter za uvoz iz Microsoft-ovog PowerPoint-a
+Name[sv]=Microsoft PowerPoint-importfilter för Kpresenter
+Name[uk]=Фільтр імпорту Microsoft PowerPoint для KPresenter
+Name[uz]=KPresenter MS PowerPoint import filteri
+Name[uz@cyrillic]=KPresenter MS PowerPoint импорт филтери
+Name[zh_CN]=KPresenter 的 Microsoft PowerPoint 导入过滤器
+Name[zh_TW]=KPresenter 的 Microsoft PowerPoint 匯入過濾程式
+X-KDE-Export=application/vnd.oasis.opendocument.presentation
+X-KDE-Import=application/mspowerpoint
+X-KDE-Weight=1
+X-KDE-Library=libpowerpointimport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/powerpoint/import/powerpointimport.cc b/filters/kpresenter/powerpoint/import/powerpointimport.cc
new file mode 100644
index 00000000..761e4f0d
--- /dev/null
+++ b/filters/kpresenter/powerpoint/import/powerpointimport.cc
@@ -0,0 +1,1592 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 <config.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <powerpointimport.h>
+#include <powerpointimport.moc>
+
+#include <qbuffer.h>
+#include <qcstring.h>
+#include <qfile.h>
+#include <qstring.h>
+#include <qtextstream.h>
+
+#include <kdebug.h>
+#include <KoFilterChain.h>
+#include <KoGlobal.h>
+#include <KoUnit.h>
+#include <kgenericfactory.h>
+
+#include <KoXmlWriter.h>
+
+#include "libppt.h"
+#include <iostream>
+#include <math.h>
+
+using namespace Libppt;
+
+typedef KGenericFactory<PowerPointImport, KoFilter> PowerPointImportFactory;
+K_EXPORT_COMPONENT_FACTORY( libpowerpointimport,
+ PowerPointImportFactory( "kofficefilters" ) )
+
+namespace Libppt {
+
+inline QConstString string( const Libppt::UString& str )
+{
+ return QConstString( reinterpret_cast<const QChar*>( str.data() ), str.length() );
+}
+
+}
+
+class PowerPointImport::Private
+{
+public:
+ QString inputFile;
+ QString outputFile;
+
+ Presentation *presentation;
+};
+
+
+PowerPointImport::PowerPointImport ( QObject*, const char*, const QStringList& )
+ : KoFilter()
+{
+ d = new Private;
+}
+
+PowerPointImport::~PowerPointImport()
+{
+ delete d;
+}
+
+KoFilter::ConversionStatus PowerPointImport::convert( const QCString& from, const QCString& to )
+{
+ if ( from != "application/mspowerpoint" )
+ return KoFilter::NotImplemented;
+
+ if ( to != "application/vnd.oasis.opendocument.presentation" )
+ return KoFilter::NotImplemented;
+
+ d->inputFile = m_chain->inputFile();
+ d->outputFile = m_chain->outputFile();
+
+ // open inputFile
+ d->presentation = new Presentation;
+ if( !d->presentation->load( d->inputFile.local8Bit() ) )
+ {
+ delete d->presentation;
+ d->presentation = 0;
+ return KoFilter::StupidError;
+ }
+
+ // create output store
+ KoStore* storeout;
+ storeout = KoStore::createStore( d->outputFile, KoStore::Write,
+ "application/vnd.oasis.opendocument.presentation", KoStore::Zip );
+
+ if ( !storeout )
+ {
+ kdWarning() << "Couldn't open the requested file." << endl;
+ return KoFilter::FileNotFound;
+ }
+
+ // store document content
+ if ( !storeout->open( "content.xml" ) )
+ {
+ kdWarning() << "Couldn't open the file 'content.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+ storeout->write( createContent() );
+ storeout->close();
+
+ // store document styles
+ if ( !storeout->open( "styles.xml" ) )
+ {
+ kdWarning() << "Couldn't open the file 'styles.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+ storeout->write( createStyles() );
+ storeout->close();
+
+ // store document manifest
+ storeout->enterDirectory( "META-INF" );
+ if ( !storeout->open( "manifest.xml" ) )
+ {
+ kdWarning() << "Couldn't open the file 'META-INF/manifest.xml'." << endl;
+ return KoFilter::CreationError;
+ }
+ storeout->write( createManifest() );
+ storeout->close();
+
+
+ // we are done!
+ delete d->presentation;
+ delete storeout;
+ d->inputFile = QString::null;
+ d->outputFile = QString::null;
+ d->presentation = 0;
+
+ return KoFilter::OK;
+}
+
+QByteArray PowerPointImport::createStyles()
+{
+ KoXmlWriter* stylesWriter;
+ QByteArray stylesData;
+ QBuffer stylesBuffer( stylesData );
+
+ QString pageWidth = QString("%1pt").arg( d->presentation->masterSlide()->pageWidth() );
+ QString pageHeight = QString("%1pt").arg( d->presentation->masterSlide()->pageHeight() );
+
+ stylesBuffer.open( IO_WriteOnly );
+ stylesWriter = new KoXmlWriter( &stylesBuffer );
+
+ stylesWriter->startDocument( "office:document-styles" );
+ stylesWriter->startElement( "office:document-styles" );
+ stylesWriter->addAttribute( "xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" );
+ stylesWriter->addAttribute( "xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" );
+ stylesWriter->addAttribute( "xmlns:presentation", "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" );
+ stylesWriter->addAttribute( "xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" );
+ stylesWriter->addAttribute( "xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0" );
+ stylesWriter->addAttribute( "xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" );
+ stylesWriter->addAttribute( "office:version","1.0" );
+
+ // office:styles
+ stylesWriter->startElement( "office:styles" );
+ stylesWriter->endElement();
+
+ // office:automatic-styles
+ stylesWriter->startElement( "office:automatic-styles" );
+ stylesWriter->startElement( "style:page-layout" );
+ stylesWriter->addAttribute( "style:name","pm1" );
+ stylesWriter->addAttribute( "style:page-usage","all" );
+ stylesWriter->startElement( "style:page-layout-properties" );
+ stylesWriter->addAttribute( "fo:margin-bottom","0pt" );
+ stylesWriter->addAttribute( "fo:margin-left","0pt" );
+ stylesWriter->addAttribute( "fo:margin-right","0pt" );
+ stylesWriter->addAttribute( "fo:margin-top","0pt" );
+ stylesWriter->addAttribute( "fo:page-height", pageHeight );
+ stylesWriter->addAttribute( "fo:page-width", pageWidth );
+ stylesWriter->addAttribute( "style:print-orientation","landscape" );
+ stylesWriter->endElement(); // style:page-layout-properties
+ stylesWriter->endElement(); // style:page-layout
+
+ stylesWriter->startElement( "style:style" );
+ stylesWriter->addAttribute( "style:name","dp1" );
+ stylesWriter->addAttribute( "style:family","drawing-page" );
+ stylesWriter->startElement( "style:drawing-page-properties" );
+ stylesWriter->addAttribute( "draw:background-size","border" );
+ stylesWriter->addAttribute( "draw:fill","solid" );
+ stylesWriter->addAttribute( "draw:fill-color","#ffffff" );
+ stylesWriter->endElement(); // style:drawing-page-properties
+ stylesWriter->endElement(); // style:style
+
+ stylesWriter->startElement( "style:style" );
+ stylesWriter->addAttribute( "style:name","P1" );
+ stylesWriter->addAttribute( "style:family","paragraph" );
+ stylesWriter->startElement( "style:paragraph-properties" );
+ stylesWriter->addAttribute( "fo:margin-left","0cm" );
+ stylesWriter->addAttribute( "fo:margin-right","0cm" );
+ stylesWriter->addAttribute( "fo:text-indent","0cm" );
+ stylesWriter->endElement(); // style:paragraph-properties
+ stylesWriter->startElement( "style:text-properties" );
+ stylesWriter->addAttribute( "fo:font-size","14pt" );
+ stylesWriter->addAttribute( "style:font-size-asian","14pt" );
+ stylesWriter->addAttribute( "style:font-size-complex","14pt" );
+ stylesWriter->endElement(); // style:text-properties
+ stylesWriter->endElement(); // style:style
+
+ stylesWriter->startElement( "text:list-style" );
+ stylesWriter->addAttribute( "style:name","L2" );
+ stylesWriter->startElement( "text:list-level-style-bullet" );
+ stylesWriter->addAttribute( "text:level","1" );
+ stylesWriter->addAttribute( "text:bullet-char","●" );
+ stylesWriter->startElement( "style:text-properties" );
+ stylesWriter->addAttribute( "fo:font-family","StarSymbol" );
+ stylesWriter->addAttribute( "font-pitch","variable" );
+ stylesWriter->addAttribute( "fo:color","#000000" );
+ stylesWriter->addAttribute( "fo:font-size","45%" );
+ stylesWriter->endElement(); // style:text-properties
+ stylesWriter->endElement(); // text:list-level-style-bullet
+ stylesWriter->endElement(); // text:list-style
+
+ stylesWriter->endElement(); // office:automatic-styles
+
+ // office:master-stylesborder
+ stylesWriter->startElement( "office:master-styles" );
+ stylesWriter->startElement( "style:master-page" );
+ stylesWriter->addAttribute( "style:name", "Standard" );
+ stylesWriter->addAttribute( "style:page-layout-name", "pm1" );
+ stylesWriter->addAttribute( "draw:style-name", "dp1" );
+ stylesWriter->endElement();
+ stylesWriter->endElement();
+
+ stylesWriter->endElement(); // office:document-styles
+ stylesWriter->endDocument();
+ delete stylesWriter;
+
+ // for troubleshooting only !!
+ QString dbg;
+ for( unsigned i=0; i<stylesData.size(); i++ )
+ dbg.append( stylesData[i] );
+ qDebug("\nstyles.xml:\n%s\n", dbg.latin1() );
+
+ return stylesData;
+}
+
+
+QByteArray PowerPointImport::createContent()
+{
+ KoXmlWriter* contentWriter;
+ QByteArray contentData;
+ QBuffer contentBuffer( contentData );
+
+ contentBuffer.open( IO_WriteOnly );
+ contentWriter = new KoXmlWriter( &contentBuffer );
+
+ contentWriter->startDocument( "office:document-content" );
+ contentWriter->startElement( "office:document-content" );
+ contentWriter->addAttribute( "xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" );
+ contentWriter->addAttribute( "xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0" );
+ contentWriter->addAttribute( "xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" );
+ contentWriter->addAttribute( "xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" );
+ contentWriter->addAttribute( "xmlns:presentation", "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" );
+ contentWriter->addAttribute( "xmlns:svg","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" );
+ contentWriter->addAttribute( "office:version","1.0" );
+
+ // office:automatic-styles
+
+ drawingObjectCounter = 0;
+ contentWriter->startElement( "office:automatic-styles" );
+ for( unsigned c=0; c < d->presentation->slideCount(); c++ )
+ {
+ Slide* slide = d->presentation->slide( c );
+ processSlideForStyle( c, slide, contentWriter );
+ }
+ contentWriter->endElement();
+
+
+
+ // office:body
+
+ contentWriter->startElement( "office:body" );
+ contentWriter->startElement( "office:presentation" );
+
+ drawingObjectCounter = 0;
+ for( unsigned c=0; c < d->presentation->slideCount(); c++ )
+ {
+ Slide* slide = d->presentation->slide( c );
+ processSlideForBody( c, slide, contentWriter );
+ }
+
+ contentWriter->endElement(); // office:presentation
+ contentWriter->endElement(); // office:body
+
+ contentWriter->endElement(); // office:document-content
+ contentWriter->endDocument();
+ delete contentWriter;
+
+ // for troubleshooting only !!
+ QString dbg;
+ for( unsigned i=0; i<contentData.size(); i++ )
+ dbg.append( contentData[i] );
+ qDebug("\ncontent.xml:\n%s\n", dbg.latin1() );
+
+ return contentData;
+}
+
+QByteArray PowerPointImport::createManifest()
+{
+ KoXmlWriter* manifestWriter;
+ QByteArray manifestData;
+ QBuffer manifestBuffer( manifestData );
+
+ manifestBuffer.open( IO_WriteOnly );
+ manifestWriter = new KoXmlWriter( &manifestBuffer );
+
+ manifestWriter->startDocument( "manifest:manifest" );
+ manifestWriter->startElement( "manifest:manifest" );
+ manifestWriter->addAttribute( "xmlns:manifest",
+ "urn:oasis:names:tc:openoffice:xmlns:manifest:1.0" );
+
+ manifestWriter->addManifestEntry( "/", "application/vnd.oasis.opendocument.presentation" );
+ manifestWriter->addManifestEntry( "styles.xml", "text/xml" );
+ manifestWriter->addManifestEntry( "content.xml", "text/xml" );
+
+ manifestWriter->endElement();
+ manifestWriter->endDocument();
+ delete manifestWriter;
+
+ // for troubleshooting only !!
+ QString dbg;
+ for( unsigned i=0; i<manifestData.size(); i++ )
+ dbg.append( manifestData[i] );
+ qDebug("\nmanifest.xml:\n%s\n", dbg.latin1() );
+
+ return manifestData;
+}
+
+void PowerPointImport::processEllipse (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:ellipse" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->endElement(); // draw:ellipse
+}
+
+void PowerPointImport::processRectangle (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject ) return;
+ if( !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:rect" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ if ( drawObject->hasProperty ( "libppt:rotation" ) )
+ {
+
+ double rotAngle = drawObject->getDoubleProperty("libppt:rotation" );
+ double xMid = ( drawObject->left() + 0.5*drawObject->width() );
+ double yMid = ( drawObject->top() + 0.5*drawObject->height() );
+ double xVec = drawObject->left()- xMid;
+ double yVec = yMid - drawObject->top();
+
+ double xNew = xVec*cos(rotAngle) - yVec*sin(rotAngle);
+ double yNew = xVec*sin(rotAngle) + yVec*cos(rotAngle);
+ QString rot = QString("rotate (%1) translate (%2mm %3mm)").arg(rotAngle).arg(xNew+xMid).arg(yMid-yNew);
+ xmlWriter->addAttribute( "draw:transform", rot );
+ }
+ else
+ {
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ }
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->endElement(); // draw:rect
+}
+
+void PowerPointImport::processRoundRectangle (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+
+
+ if ( drawObject->hasProperty ( "libppt:rotation" ) )
+ {
+ double rotAngle = drawObject->getDoubleProperty("libppt:rotation" );
+
+
+
+ if ( rotAngle > 0.785399 ) // > 45 deg
+ { xmlWriter->addAttribute( "svg:width", heightStr );
+ xmlWriter->addAttribute( "svg:height", widthStr );
+ double xMid = ( drawObject->left() - 0.5*drawObject->height() );
+ double yMid = ( drawObject->top() + 0.5*drawObject->width() );
+ double xVec = drawObject->left()- xMid;
+ double yVec = drawObject->top()- yMid;
+
+ double xNew = xVec*cos(rotAngle) - yVec*sin(rotAngle);
+ double yNew = xVec*sin(rotAngle) + yVec*cos(rotAngle);
+ QString rot = QString("rotate (%1) translate (%2mm %3mm)").arg(rotAngle).arg(xNew+xMid).arg(yMid+yNew);
+ xmlWriter->addAttribute( "draw:transform", rot );
+ }
+ else
+ { xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ double xMid = ( drawObject->left() + 0.5*drawObject->width() );
+ double yMid = ( drawObject->top() + 0.5*drawObject->height() );
+ double xVec = drawObject->left()- xMid;
+ double yVec = yMid - drawObject->top();
+
+ double xNew = xVec*cos(rotAngle) - yVec*sin(rotAngle);
+ double yNew = xVec*sin(rotAngle) + yVec*cos(rotAngle);
+ QString rot = QString("rotate (%1) translate (%2mm %3mm)").arg(rotAngle).arg(xNew+xMid).arg(yMid-yNew);
+ xmlWriter->addAttribute( "draw:transform", rot );
+ }
+
+
+ }
+ else
+ { xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ }
+ // xmlWriter->addAttribute( "svg:x", xStr );
+ // xmlWriter->addAttribute( "svg:y", yStr );
+
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ xmlWriter->addAttribute( "draw:type", "round-rectangle");
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 /3" );
+ xmlWriter->addAttribute( "draw:name", "f0" );
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "right-?f0 " );
+ xmlWriter->addAttribute( "draw:name", "f1" );
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "bottom-?f0 " );
+ xmlWriter->addAttribute( "draw:name", "f2" );
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "left+?f0 " );
+ xmlWriter->addAttribute( "draw:name", "f3" );
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "top+?f0 " );
+ xmlWriter->addAttribute( "draw:name", "f4" );
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->endElement(); // draw:enhanced-geometry
+ xmlWriter->endElement(); // draw:custom-shape
+}
+
+void PowerPointImport::processDiamond (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 0 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 10 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ xmlWriter->addAttribute( "draw:type", "diamond");
+ xmlWriter->endElement();
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->endElement();
+}
+
+void PowerPointImport::processTriangle (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ /* draw IsocelesTriangle or RightTriangle */
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 2.5 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 0 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 10 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 7.5 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+
+ if (drawObject->hasProperty("draw:mirror-vertical"))
+ {
+ xmlWriter->addAttribute("draw:mirror-vertical","true");
+ }
+ if ( drawObject->hasProperty("draw:mirror-horizontal"))
+ {
+ xmlWriter->addAttribute("draw:mirror-horizontal","true");
+ }
+ if ( drawObject->hasProperty ( "libppt:rotation" ) )
+ { // draw:transform="rotate (1.5707963267946) translate (6.985cm 14.181cm)"
+
+ double rotAngle = drawObject->getDoubleProperty("libppt:rotation" );
+ double xMid = ( drawObject->left() + 0.5*drawObject->width() );
+ double yMid = ( drawObject->top() + 0.5*drawObject->height() );
+ QString rot = QString("rotate (%1) translate (%2cm %3cm)").arg(rotAngle).arg(xMid).arg(yMid);
+ xmlWriter->addAttribute( "draw:transform", rot );
+ }
+ if (drawObject->shape() == DrawObject::RightTriangle)
+ {
+ xmlWriter->addAttribute( "draw:type", "right-triangle");
+ }
+ else if (drawObject->shape() == DrawObject::IsoscelesTriangle)
+ {
+ xmlWriter->addAttribute( "draw:type", "isosceles-triangle");
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 " );
+ xmlWriter->addAttribute( "draw:name", "f0" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 /2" );
+ xmlWriter->addAttribute( "draw:name", "f1" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f1 +10800" );
+ xmlWriter->addAttribute( "draw:name", "f2" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 *2/3" );
+ xmlWriter->addAttribute( "draw:name", "f3" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f3 +7200" );
+ xmlWriter->addAttribute( "draw:name", "f4" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f0 " );
+ xmlWriter->addAttribute( "draw:name", "f5" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f5 /2" );
+ xmlWriter->addAttribute( "draw:name", "f6" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f6 " );
+ xmlWriter->addAttribute( "draw:name", "f7" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:handle" );
+ xmlWriter->addAttribute( "draw:handle-range-x-maximum", 21600);
+ xmlWriter->addAttribute( "draw:handle-range-x-minimum", 0);
+ xmlWriter->addAttribute( "draw:handle-position","$0 top");
+ xmlWriter->endElement();
+ }
+
+ xmlWriter->endElement(); // enhanced-geometry
+ xmlWriter->endElement(); // custom-shape
+}
+
+void PowerPointImport::processTrapezoid (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 2.5 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 0 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ if ( drawObject->hasProperty("draw:mirror-vertical") )
+ {
+ xmlWriter->addAttribute("draw:mirror-vertical","true");
+ }
+ if ( drawObject->hasProperty("draw:mirror-horizontal"))
+ {
+ xmlWriter->addAttribute("draw:mirror-horizontal","true");
+ }
+ xmlWriter->addAttribute( "draw:type", "trapezoid" );
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-$0 " );
+ xmlWriter->addAttribute( "draw:name", "f0" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0" );
+ xmlWriter->addAttribute( "draw:name", "f1" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 *10/18" );
+ xmlWriter->addAttribute( "draw:name", "f2" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f2 +1750");
+ xmlWriter->addAttribute( "draw:name", "f3" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f3" );
+ xmlWriter->addAttribute( "draw:name", "f4" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 /2" );
+ xmlWriter->addAttribute( "draw:name", "f5" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f5" );
+ xmlWriter->addAttribute( "draw:name", "f6" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:handle" );
+ xmlWriter->addAttribute( "draw:handle-range-x-maximum", 10800);
+ xmlWriter->addAttribute( "draw:handle-range-x-minimum", 0);
+ xmlWriter->addAttribute("draw:handle-position","$0 bottom");
+ xmlWriter->endElement();
+ xmlWriter->endElement(); // enhanced-geometry
+ xmlWriter->endElement(); // custom-shape
+}
+
+void PowerPointImport::processParallelogram (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 6.25 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 4.5 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 8.75 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 3.75 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 1.25 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ if (drawObject->hasProperty("draw:mirror-vertical"))
+ {
+ xmlWriter->addAttribute("draw:mirror-vertical","true");
+ }
+ if ( drawObject->hasProperty("draw:mirror-horizontal"))
+ {
+ xmlWriter->addAttribute("draw:mirror-horizontal","true");
+ }
+ xmlWriter->addAttribute( "draw:type", "parallelogram" );
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 " );
+ xmlWriter->addAttribute( "draw:name", "f0" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-$0" );
+ xmlWriter->addAttribute( "draw:name", "f1" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 *10/24" );
+ xmlWriter->addAttribute( "draw:name", "f2" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f2 +1750");
+ xmlWriter->addAttribute( "draw:name", "f3" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f3" );
+ xmlWriter->addAttribute( "draw:name", "f4" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f0 /2" );
+ xmlWriter->addAttribute( "draw:name", "f5" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "10800+?f5" );
+ xmlWriter->addAttribute( "draw:name", "f6" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f0-10800 " );
+ xmlWriter->addAttribute( "draw:name", "f7" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "if(?f7,?f12,0" );
+ xmlWriter->addAttribute( "draw:name", "f8" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "10800-?f5" );
+ xmlWriter->addAttribute( "draw:name", "f9" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "if(?f7, ?f12, 21600");
+ xmlWriter->addAttribute( "draw:name", "f10" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f5" );
+ xmlWriter->addAttribute( "draw:name", "f11" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600*10800/?f0" );
+ xmlWriter->addAttribute( "draw:name", "f12" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f12" );
+ xmlWriter->addAttribute( "draw:name", "f13" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:handle" );
+ xmlWriter->addAttribute( "draw:handle-range-x-maximum", 21600);
+ xmlWriter->addAttribute( "draw:handle-range-x-minimum", 0);
+ xmlWriter->addAttribute("draw:handle-position","$0 top");
+ xmlWriter->endElement();
+ xmlWriter->endElement(); // enhanced-geometry
+ xmlWriter->endElement(); // custom-shape
+}
+
+void PowerPointImport::processHexagon (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 0 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 10 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ xmlWriter->addAttribute( "draw:type", "hexagon" );
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 " );
+ xmlWriter->addAttribute( "draw:name", "f0" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-$0" );
+ xmlWriter->addAttribute( "draw:name", "f1" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 *100/234" );
+ xmlWriter->addAttribute( "draw:name", "f2" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "?f2 +1700");
+ xmlWriter->addAttribute( "draw:name", "f3" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "21600-?f3" );
+ xmlWriter->addAttribute( "draw:name", "f4" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:handle" );
+ xmlWriter->addAttribute( "draw:handle-range-x-maximum", 10800);
+ xmlWriter->addAttribute( "draw:handle-range-x-minimum", 0);
+ xmlWriter->addAttribute("draw:handle-position","$0 top");
+ xmlWriter->endElement();
+ xmlWriter->endElement(); // enhanced-geometry
+ xmlWriter->endElement(); // custom-shape
+}
+
+void PowerPointImport::processOctagon (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 0 );
+ xmlWriter->addAttribute( "svg:y", 4.782 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 10 );
+ xmlWriter->addAttribute( "svg:y", 4.782 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ xmlWriter->addAttribute( "draw:type", "octagon" );
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "left+$0 " );
+ xmlWriter->addAttribute( "draw:name", "f0" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "top+$0 " );
+ xmlWriter->addAttribute( "draw:name", "f1" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "right-$0 " );
+ xmlWriter->addAttribute( "draw:name", "f2" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "bottom-$0 ");
+ xmlWriter->addAttribute( "draw:name", "f3" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0 /2" );
+ xmlWriter->addAttribute( "draw:name", "f4" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "left+?f4 " );
+ xmlWriter->addAttribute( "draw:name", "f5" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "top+?f4 " );
+ xmlWriter->addAttribute( "draw:name", "f6" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "right-?f4 " );
+ xmlWriter->addAttribute( "draw:name", "f7" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "bottom-?f4 ");
+ xmlWriter->addAttribute( "draw:name", "f8" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:handle" );
+ xmlWriter->addAttribute( "draw:handle-range-x-maximum", 10800);
+ xmlWriter->addAttribute( "draw:handle-range-x-minimum", 0);
+ xmlWriter->addAttribute("draw:handle-position","$0 top");
+ xmlWriter->endElement();
+ xmlWriter->endElement(); // enhanced-geometry
+ xmlWriter->endElement(); // custom-shape
+}
+
+void PowerPointImport::processArrow (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+
+ if (drawObject->shape() == DrawObject::RightArrow)
+ xmlWriter->addAttribute( "draw:type", "right-arrow" );
+ else if (drawObject->shape() == DrawObject::LeftArrow)
+ xmlWriter->addAttribute( "draw:type", "left-arrow" );
+ else if (drawObject->shape() == DrawObject::UpArrow)
+ xmlWriter->addAttribute( "draw:type", "up-arrow" );
+ else if (drawObject->shape() == DrawObject::DownArrow)
+ xmlWriter->addAttribute( "draw:type", "down-arrow" );
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","$1");
+ xmlWriter->addAttribute( "draw:name","f0");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","$0");
+ xmlWriter->addAttribute( "draw:name","f1");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","21600-$1");
+ xmlWriter->addAttribute( "draw:name","f2");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","21600-?f1");
+ xmlWriter->addAttribute( "draw:name","f3");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","?f3 *?f0 /10800");
+ xmlWriter->addAttribute( "draw:name","f4");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","?f1 +?f4 " );
+ xmlWriter->addAttribute( "draw:name","f5");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","?f1 *?f0 /10800");
+ xmlWriter->addAttribute( "draw:name","f6");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula","?f1 -?f6 ");
+ xmlWriter->addAttribute( "draw:name","f7");
+ xmlWriter->endElement(); // draw:equation
+ xmlWriter->startElement( "draw:handle" );
+ if ( drawObject->shape() == DrawObject::RightArrow | drawObject->shape() == DrawObject::LeftArrow )
+ {
+ xmlWriter->addAttribute( "draw:handle-range-x-maximum", 21600);
+ xmlWriter->addAttribute( "draw:handle-range-x-minimum", 0);
+ xmlWriter->addAttribute("draw:handle-position","$0 $1");
+ xmlWriter->addAttribute("draw:handle-range-y-maximum",10800);
+ xmlWriter->addAttribute("draw:handle-range-y-minimum",0);
+ }
+ else if ( drawObject->shape() == DrawObject::UpArrow | drawObject->shape() == DrawObject::DownArrow )
+ {
+ xmlWriter->addAttribute( "draw:handle-range-x-maximum", 10800);
+ xmlWriter->addAttribute( "draw:handle-range-x-minimum", 0);
+ xmlWriter->addAttribute("draw:handle-position","$1 $0");
+ xmlWriter->addAttribute("draw:handle-range-y-maximum",21600);
+ xmlWriter->addAttribute("draw:handle-range-y-minimum",0);
+ }
+ xmlWriter->endElement(); // draw:handle
+ xmlWriter->endElement(); // draw:enhanced-geometry
+ xmlWriter->endElement(); // draw:custom-shape
+}
+
+void PowerPointImport::processLine (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter) return;
+
+ QString x1Str = QString("%1mm").arg( drawObject->left() );
+ QString y1Str = QString("%1mm").arg( drawObject->top() );
+ QString x2Str = QString("%1mm").arg( drawObject->left() + drawObject->width() );
+ QString y2Str = QString("%1mm").arg( drawObject->top() + drawObject->height() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ if ( drawObject->hasProperty("draw:mirror-vertical") )
+ { QString temp = y1Str;
+ y1Str = y2Str;
+ y2Str = temp;
+ }
+ if ( drawObject->hasProperty("draw:mirror-horizontal") )
+ { QString temp = x1Str;
+ x1Str = x2Str;
+ x2Str = temp;
+ }
+
+ xmlWriter->startElement( "draw:line" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:y1", y1Str );
+ xmlWriter->addAttribute( "svg:y2", y2Str );
+ xmlWriter->addAttribute( "svg:x1", x1Str );
+ xmlWriter->addAttribute( "svg:x2", x2Str );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+
+ xmlWriter->endElement();
+}
+
+void PowerPointImport::processSmiley (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject ||!xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 0 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 1.461 );
+ xmlWriter->addAttribute( "svg:y", 1.461 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 0 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 1.461 );
+ xmlWriter->addAttribute( "svg:y", 8.536 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 10 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 8.536 );
+ xmlWriter->addAttribute( "svg:y", 1.461 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ xmlWriter->addAttribute( "draw:type", "smiley" );
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "$0-15510 " );
+ xmlWriter->addAttribute( "draw:name", "f0" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "17520-?f0" );
+ xmlWriter->addAttribute( "draw:name", "f1" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:equation" );
+ xmlWriter->addAttribute( "draw:formula", "15510+?f0" );
+ xmlWriter->addAttribute( "draw:name", "f2" );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:handle" );
+ xmlWriter->addAttribute( "draw:position", 10800);
+ xmlWriter->addAttribute( "draw:handle-range-y-maximum", 17520);
+ xmlWriter->addAttribute( "draw:handle-range-y-minimum", 15510);
+ xmlWriter->addAttribute("draw:handle-position","$0 top");
+ xmlWriter->endElement();
+ xmlWriter->endElement(); // enhanced-geometry
+ xmlWriter->endElement(); // custom-shape
+}
+
+void PowerPointImport::processHeart (DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:custom-shape" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 1 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 1.43 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 5 );
+ xmlWriter->addAttribute( "svg:y", 10 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:glue-point" );
+ xmlWriter->addAttribute( "svg:x", 8.553 );
+ xmlWriter->addAttribute( "svg:y", 5 );
+ xmlWriter->endElement();
+ xmlWriter->startElement( "draw:enhanced-geometry" );
+ xmlWriter->addAttribute( "draw:type", "heart" );
+
+ xmlWriter->endElement(); // enhanced-geometry
+ xmlWriter->endElement(); // custom-shape
+}
+
+void PowerPointImport::processFreeLine (DrawObject* drawObject, KoXmlWriter* xmlWriter)
+{
+ if( !drawObject ||!xmlWriter ) return;
+
+ QString widthStr = QString("%1mm").arg( drawObject->width() );
+ QString heightStr = QString("%1mm").arg( drawObject->height() );
+ QString xStr = QString("%1mm").arg( drawObject->left() );
+ QString yStr = QString("%1mm").arg( drawObject->top() );
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "draw:path" );
+ xmlWriter->addAttribute( "draw:style-name", styleName );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->endElement(); // path
+}
+
+void PowerPointImport::processDrawingObjectForBody( DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+
+ if( !drawObject || !xmlWriter ) return;
+
+ drawingObjectCounter++;
+
+
+ if (drawObject->shape() == DrawObject::Ellipse)
+ {
+ processEllipse (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Rectangle)
+ {
+ processRectangle (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::RoundRectangle)
+ {
+ processRoundRectangle (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Diamond)
+ {
+ processDiamond (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::IsoscelesTriangle |
+ drawObject->shape() == DrawObject::RightTriangle)
+ {
+ processTriangle (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Trapezoid)
+ {
+ processTrapezoid (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Parallelogram)
+ {
+ processParallelogram( drawObject, xmlWriter);
+ }
+ else if (drawObject->shape() == DrawObject::Hexagon)
+ {
+ processHexagon ( drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Octagon)
+ {
+ processOctagon ( drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::RightArrow |
+ drawObject->shape() == DrawObject::LeftArrow |
+ drawObject->shape() == DrawObject::UpArrow |
+ drawObject->shape() == DrawObject::DownArrow )
+ {
+ processArrow ( drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Line)
+ {
+ processLine ( drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Smiley)
+ {
+ processSmiley (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::Heart)
+ {
+ processHeart (drawObject, xmlWriter );
+ }
+ else if (drawObject->shape() == DrawObject::FreeLine)
+ {
+ processFreeLine (drawObject, xmlWriter );
+ }
+}
+
+void PowerPointImport::processGroupObjectForBody( GroupObject* groupObject, KoXmlWriter* xmlWriter )
+{
+ if( !groupObject || !xmlWriter ) return;
+ if( !groupObject->objectCount() ) return;
+
+ xmlWriter->startElement( "draw:g" );
+
+ for( unsigned i = 0; i < groupObject->objectCount(); i++ )
+ {
+ Object* object = groupObject->object( i );
+ if( object )
+ processObjectForBody( object, xmlWriter );
+ }
+
+ xmlWriter->endElement(); // draw:g
+}
+
+void PowerPointImport::processTextObjectForBody( TextObject* textObject, KoXmlWriter* xmlWriter )
+{
+ if( !textObject || !xmlWriter ) return;
+
+ QString classStr = "subtitle";
+ if( textObject->type() == TextObject::Title )
+ classStr = "title";
+// QString pStr = string( textObject->text() ).string();
+ QString pStr;
+
+ QString widthStr = QString("%1mm").arg( textObject->width() );
+ QString heightStr = QString("%1mm").arg( textObject->height() );
+ QString xStr = QString("%1mm").arg( textObject->left() );
+ QString yStr = QString("%1mm").arg( textObject->top() );
+
+ xmlWriter->startElement( "draw:frame" );
+ xmlWriter->addAttribute( "presentation:style-name", "pr1" );
+ xmlWriter->addAttribute( "draw:layer", "layout" );
+ xmlWriter->addAttribute( "svg:width", widthStr );
+ xmlWriter->addAttribute( "svg:height", heightStr );
+ xmlWriter->addAttribute( "svg:x", xStr );
+ xmlWriter->addAttribute( "svg:y", yStr );
+ xmlWriter->addAttribute( "presentation:class", classStr );
+ xmlWriter->startElement( "draw:text-box" );
+
+ // count error if i begins with 0
+ for (unsigned i=0; i<textObject->listSize(); i++)
+ {
+ pStr = Libppt::string(textObject->text(i)).string();
+ if (textObject->bulletFlag(i) == 1 )
+ {
+ xmlWriter->startElement( "text:list" );
+ xmlWriter->addAttribute( "text:style-name","L2");
+ xmlWriter->startElement( "text:list-item" );
+ xmlWriter->startElement( "text:p" );
+ xmlWriter->addAttribute( "text:style-name", "P1" );
+ xmlWriter->addTextSpan( pStr );
+ xmlWriter->endElement(); // text:p
+ xmlWriter->endElement(); // text:list-item
+ xmlWriter->endElement(); // text:list
+ }
+ else
+ {
+ xmlWriter->startElement( "text:p" );
+ xmlWriter->addAttribute( "text:style-name", "P1" );
+ xmlWriter->addTextSpan( pStr );
+ xmlWriter->endElement(); // text:p
+ }
+ }
+
+ xmlWriter->endElement(); // draw:text-box
+ xmlWriter->endElement(); // draw:frame
+
+
+}
+
+void PowerPointImport::processObjectForBody( Object* object, KoXmlWriter* xmlWriter )
+{
+ if( !object || !xmlWriter) return;
+
+ if( object->isText() )
+ processTextObjectForBody( static_cast<TextObject*>(object), xmlWriter );
+ else if( object->isGroup() )
+ processGroupObjectForBody( static_cast<GroupObject*>(object), xmlWriter );
+ else if( object->isDrawing() )
+ processDrawingObjectForBody( static_cast<DrawObject*>(object), xmlWriter );
+}
+
+void PowerPointImport::processSlideForBody( unsigned slideNo, Slide* slide, KoXmlWriter* xmlWriter )
+{
+ if( !slide || !xmlWriter ) return;
+
+ QString nameStr = Libppt::string( slide->title() ).string();
+ if( nameStr.isEmpty() )
+ nameStr = QString("page%1").arg(slideNo+1);
+
+ QString styleNameStr = QString("dp%1").arg(slideNo+1);
+
+ xmlWriter->startElement( "draw:page" );
+ xmlWriter->addAttribute( "draw:master-page-name", "Default" );
+ xmlWriter->addAttribute( "draw:name", nameStr );
+ xmlWriter->addAttribute( "draw:style-name", styleNameStr );
+ xmlWriter->addAttribute( "presentation:presentation-page-layout-name", "AL1T0");
+
+ GroupObject* root = slide->rootObject();
+ if( root )
+ for( unsigned i = 0; i < root->objectCount(); i++ )
+ {
+ Object* object = root->object( i );
+ if( object )
+ processObjectForBody( object, xmlWriter );
+ }
+
+ xmlWriter->endElement(); // draw:page
+}
+
+void PowerPointImport::processSlideForStyle( unsigned , Slide* slide, KoXmlWriter* xmlWriter )
+{
+ if( !slide || !xmlWriter ) return;
+
+ GroupObject* root = slide->rootObject();
+ if( root )
+ for( unsigned i = 0; i < root->objectCount(); i++ )
+ {
+ Object* object = root->object( i );
+ if( object )
+ processObjectForStyle( object, xmlWriter );
+ }
+}
+
+void PowerPointImport::processObjectForStyle( Object* object, KoXmlWriter* xmlWriter )
+{
+ if( !object || !xmlWriter ) return;
+
+ if( object->isText() )
+ processTextObjectForStyle( static_cast<TextObject*>(object), xmlWriter );
+ else if( object->isGroup() )
+ processGroupObjectForStyle( static_cast<GroupObject*>(object), xmlWriter );
+ else if( object->isDrawing() )
+ processDrawingObjectForStyle( static_cast<DrawObject*>(object), xmlWriter );
+}
+
+void PowerPointImport::processTextObjectForStyle( TextObject* textObject, KoXmlWriter* xmlWriter )
+{
+ if( !textObject || !xmlWriter ) return;
+}
+
+void PowerPointImport::processGroupObjectForStyle( GroupObject* groupObject, KoXmlWriter* xmlWriter )
+{
+ if( !groupObject ||!xmlWriter ) return;
+}
+
+QString hexname( const Color &c )
+{
+ QColor qc( c.red, c.green, c.blue );
+ return qc.name();
+}
+
+void PowerPointImport::processDrawingObjectForStyle( DrawObject* drawObject, KoXmlWriter* xmlWriter )
+{
+ if( !drawObject || !xmlWriter) return;
+
+ drawingObjectCounter++;
+ QString styleName = QString("gr%1").arg( drawingObjectCounter );
+
+ xmlWriter->startElement( "style:style" );
+ xmlWriter->addAttribute( "style:name", styleName );
+ xmlWriter->addAttribute( "style:family", "graphic" );
+ xmlWriter->addAttribute( "style:parent-style-name", "standard" );
+
+ xmlWriter->startElement( "style:graphic-properties" );
+/*
+ if (drawObject->hasProperty("draw:stroke") )
+ {
+ xmlWriter->addAttribute( "draw:stroke", "dash" );
+ std::string s = drawObject->getStrProperty("draw:stroke-dash");
+ QString ss( s.c_str() );
+ xmlWriter->addAttribute( "draw:stroke-dash", ss );
+ } else xmlWriter->addAttribute( "draw:stroke", "dash" );
+*/
+ if (drawObject->hasProperty( "libppt:invisibleLine" ))
+ {
+ if (drawObject->getBoolProperty("libppt:invisibleLine") == true)
+ xmlWriter->addAttribute( "draw:stroke", "none" );
+ }
+ else if( drawObject->hasProperty( "draw:stroke" ) )
+ { if (drawObject->getStrProperty( "draw:stroke" ) == "dash")
+ {
+ xmlWriter->addAttribute( "draw:stroke", "dash" );
+ std::string s = drawObject->getStrProperty("draw:stroke-dash");
+ QString ss( s.c_str() );
+ xmlWriter->addAttribute( "draw:stroke-dash", ss );
+ qDebug("=============stroke dash===================");
+// qDebug("test %g\n",angka);
+ }
+ else if (drawObject->getStrProperty( "draw:stroke" ) == "solid")
+ xmlWriter->addAttribute( "draw:stroke", "solid" );
+ }
+
+
+ if( drawObject->hasProperty( "svg:stroke-width" ) )
+ {
+ double strokeWidth = drawObject->getDoubleProperty("svg:stroke-width" );
+ xmlWriter->addAttribute( "svg:stroke-width",QString("%1mm").arg( strokeWidth ) );
+ }
+
+ if( drawObject->hasProperty( "svg:stroke-color" ) )
+ {
+ Color strokeColor = drawObject->getColorProperty("svg:stroke-color" );
+ xmlWriter->addAttribute( "svg:stroke-color", hexname( strokeColor ) );
+ }
+
+ if( drawObject->hasProperty( "draw:marker-start" ) )
+ {
+ std::string s = drawObject->getStrProperty("draw:marker-start");
+ QString ss( s.c_str() );
+ xmlWriter->addAttribute( "draw:marker-start", ss );
+ }
+ if( drawObject->hasProperty( "draw:marker-end" ) )
+ {
+ std::string s = drawObject->getStrProperty("draw:marker-end");
+ QString ss( s.c_str() );
+ xmlWriter->addAttribute( "draw:marker-end", ss);
+ }
+/* if( drawObject->hasProperty( "draw:marker-start-length" ) )
+ {
+ std::string s = drawObject->getStrProperty("draw:marker-start-length");
+ QString ss( s.c_str() );
+ xmlWriter->addAttribute("draw:marker-start-length", ss );
+ }
+ if( drawObject->hasProperty( "draw:marker-end-length" ) )
+ {
+ std::string s = drawObject->getStrProperty("draw:marker-end-length");
+ QString ss( s.c_str() );
+ xmlWriter->addAttribute( "draw:marker-end-length", ss);
+ } */
+
+ if( drawObject->hasProperty( "draw:marker-start-width" ) )
+ {
+ double strokeWidth = drawObject->getDoubleProperty("svg:stroke-width" );
+ double arrowWidth = (drawObject->getDoubleProperty("draw:marker-start-width") * strokeWidth);
+ xmlWriter->addAttribute( "draw:marker-start-width",QString("%1cm").arg( arrowWidth ) );
+ }
+
+ if( drawObject->hasProperty( "draw:marker-end-width" ) )
+ {
+ double strokeWidth = drawObject->getDoubleProperty("svg:stroke-width" );
+ double arrowWidth = (drawObject->getDoubleProperty("draw:marker-end-width") * strokeWidth);
+ xmlWriter->addAttribute( "draw:marker-end-width",QString("%1cm").arg( arrowWidth ) );
+ }
+
+
+
+ if( drawObject->hasProperty( "draw:fill" ) )
+ {
+ std::string s = drawObject->getStrProperty("draw:fill");
+ QString ss( s.c_str() );
+ xmlWriter->addAttribute( "draw:fill", ss);
+ }
+
+
+
+ if( drawObject->hasProperty( "draw:fill-color" ) )
+ {
+ Color fillColor = drawObject->getColorProperty("draw:fill-color" );
+ xmlWriter->addAttribute( "draw:fill-color", hexname( fillColor ) );
+
+ } else xmlWriter->addAttribute( "draw:fill-color", "#99ccff" );
+
+#if 0
+ if( drawObject->hasProperty( "draw:shadow-color" ) )
+ {
+ xmlWriter->addAttribute( "draw:shadow", "visible" );
+ Color shadowColor = drawObject->getColorProperty("draw:shadow-color" );
+ xmlWriter->addAttribute( "draw:shadow-color", hexname( shadowColor ) );
+ }
+ else xmlWriter->addAttribute( "draw:shadow", "hidden" );
+#endif
+
+ if( drawObject->hasProperty( "draw:shadow-opacity" ) )
+ {
+ double opacity = drawObject->getDoubleProperty("draw:shadow-opacity") ;
+ xmlWriter->addAttribute( "draw:shadow-opacity",QString("%1%").arg( opacity ) );
+ }
+
+ if( drawObject->hasProperty( "draw:shadow-offset-x" ) )
+ {
+ double offset = drawObject->getDoubleProperty("draw:shadow-offset-x") ;
+ xmlWriter->addAttribute( "draw:shadow-offset-x",QString("%1cm").arg( offset ) );
+ }
+
+ if( drawObject->hasProperty( "draw:shadow-offset-y" ) )
+ {
+ double offset = drawObject->getDoubleProperty("draw:shadow-offset-y");
+ xmlWriter->addAttribute( "draw:shadow-offset-y",QString("%1cm").arg( offset ) );
+ }
+
+
+ xmlWriter->endElement();
+
+ xmlWriter->endElement();
+}
+
diff --git a/filters/kpresenter/powerpoint/import/powerpointimport.h b/filters/kpresenter/powerpoint/import/powerpointimport.h
new file mode 100644
index 00000000..6c6774ab
--- /dev/null
+++ b/filters/kpresenter/powerpoint/import/powerpointimport.h
@@ -0,0 +1,83 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 POWERPOINTIMPORT_H
+#define POWERPOINTIMPORT_H
+
+#include <KoFilter.h>
+#include <KoStore.h>
+
+#include <qcstring.h>
+
+#include "libppt.h"
+
+using namespace Libppt;
+
+class KoXmlWriter;
+
+class PowerPointImport : public KoFilter
+{
+Q_OBJECT
+
+public:
+ PowerPointImport ( QObject *parent, const char* name, const QStringList& );
+ virtual ~PowerPointImport();
+ virtual KoFilter::ConversionStatus convert( const QCString& from,
+ const QCString& to );
+
+private:
+ class Private;
+ Private* d;
+
+ QByteArray createManifest();
+ QByteArray createStyles();
+ QByteArray createContent();
+
+ int drawingObjectCounter;
+
+ void processSlideForBody( unsigned slideNo, Slide* slide, KoXmlWriter* xmlWriter );
+ void processObjectForBody( Object* object, KoXmlWriter* xmlWriter );
+ void processGroupObjectForBody( GroupObject* groupObject, KoXmlWriter* xmlWriter );
+ void processDrawingObjectForBody( DrawObject* drawObject, KoXmlWriter* xmlWriter );
+ void processTextObjectForBody( TextObject* textObject, KoXmlWriter* xmlWriter );
+
+
+ void processSlideForStyle( unsigned slideNo, Slide* slide, KoXmlWriter* xmlWriter );
+ void processObjectForStyle( Object* object, KoXmlWriter* xmlWriter );
+ void processGroupObjectForStyle( GroupObject* groupObject, KoXmlWriter* xmlWriter );
+ void processDrawingObjectForStyle( DrawObject* drawObject, KoXmlWriter* xmlWriter );
+ void processTextObjectForStyle( TextObject* textObject, KoXmlWriter* xmlWriter );
+
+ void processEllipse(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processRectangle(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processRoundRectangle(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processDiamond(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processTriangle(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processTrapezoid(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processParallelogram(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processHexagon(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processOctagon(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processArrow(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processLine(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processSmiley(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processHeart(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+ void processFreeLine(DrawObject* drawObject, KoXmlWriter* xmlWriter);
+};
+
+#endif // POWERPOINTIMPORT_H
diff --git a/filters/kpresenter/powerpoint/libppt/Makefile.am b/filters/kpresenter/powerpoint/libppt/Makefile.am
new file mode 100644
index 00000000..f4f7c98a
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/Makefile.am
@@ -0,0 +1,5 @@
+INCLUDES= -I$(srcdir) -I$(srcdir)/.. $(all_includes)
+
+noinst_LTLIBRARIES = libppt.la
+libppt_la_SOURCES = slide.cpp objects.cpp presentation.cpp pole.cpp powerpoint.cpp ustring.cpp
+
diff --git a/filters/kpresenter/powerpoint/libppt/libppt.h b/filters/kpresenter/powerpoint/libppt/libppt.h
new file mode 100644
index 00000000..1eee666f
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/libppt.h
@@ -0,0 +1,31 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 LIBPPT_H
+#define LIBPPT_H
+
+#include "presentation.h"
+#include "slide.h"
+#include "objects.h"
+
+#include "ustring.h"
+#include "powerpoint.h"
+
+
+#endif /* LIBPPT_H */
diff --git a/filters/kpresenter/powerpoint/libppt/objects.cpp b/filters/kpresenter/powerpoint/libppt/objects.cpp
new file mode 100644
index 00000000..29870cbd
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/objects.cpp
@@ -0,0 +1,426 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 "objects.h"
+#include "ustring.h"
+
+#include <string>
+#include <map>
+#include <vector>
+#include <iostream>
+
+using namespace Libppt;
+
+class PropertyValue
+{
+public:
+ enum { InvalidType, IntType, DoubleType, StringType, BoolType, ColorType } type;
+ bool b;
+ int i;
+ double d;
+ std::string s;
+ Color c;
+
+ PropertyValue()
+ {
+ type = InvalidType;
+ b = false;
+ i = 0;
+ d = 0.0;
+
+
+ }
+};
+
+class Object::Private
+{
+public:
+ int id;
+ double top;
+ double left;
+ double width;
+ double height;
+ bool background;
+ std::map<std::string,PropertyValue> properties;
+};
+
+Object::Object()
+{
+ d = new Private;
+ d->id = -1;
+ d->top = 0.0;
+ d->left = 0.0;
+ d->width = 10.0;
+ d->height = 3.0;
+ d->background = false;
+}
+
+Object::~Object()
+{
+ delete d;
+}
+
+int Object::id() const
+{
+ return d->id;
+}
+
+void Object::setId( int id )
+{
+ d->id = id;
+}
+
+double Object::top() const
+{
+ return d->top;
+}
+
+double Object::left() const
+{
+ return d->left;
+}
+
+double Object::width() const
+{
+ return d->width;
+}
+
+double Object::height() const
+{
+ return d->height;
+}
+
+void Object::setTop( double top )
+{
+ d->top = top;
+}
+
+void Object::setLeft( double left )
+{
+ d->left = left;
+}
+
+void Object::setWidth( double width )
+{
+ d->width = width;
+}
+
+void Object::setHeight( double height)
+{
+ d->height = height;
+}
+
+bool Object::isBackground() const
+{
+ return d->background;
+}
+
+void Object::setBackground( bool bg )
+{
+ d->background = bg;
+}
+
+bool Object::hasProperty( std::string name )
+{
+ std::map<std::string,PropertyValue>::const_iterator i;
+ i = d->properties.find( name );
+ if( i == d->properties.end() )
+ return false;
+ else
+ return true;
+}
+
+void Object::setProperty( std::string name, std::string value )
+{
+ PropertyValue pv;
+ pv.type = PropertyValue::StringType;
+ pv.s = value;
+ d->properties[ name ] = pv;
+}
+
+void Object::setProperty( std::string name, int value )
+ {
+ PropertyValue pv;
+ pv.type = PropertyValue::IntType;
+ pv.i = value;
+ d->properties[ name ] = pv;
+}
+
+void Object::setProperty( std::string name, double value )
+{
+ PropertyValue pv;
+ pv.type = PropertyValue::DoubleType;
+ pv.d = value;
+ d->properties[ name ] = pv;
+}
+
+void Object::setProperty( std::string name, bool value )
+{
+ PropertyValue pv;
+ pv.type = PropertyValue::BoolType;
+ pv.b = value;
+ d->properties[ name ] = pv;
+}
+
+void Object::setProperty( std::string name, Color value )
+{
+ PropertyValue pv;
+ pv.type = PropertyValue::ColorType;
+ pv.c = value;
+ d->properties[ name ] = pv;
+}
+
+int Object::getIntProperty( std::string name )
+{
+ PropertyValue pv;
+ pv = d->properties[ name ];
+ if( pv.type == PropertyValue::IntType )
+ return pv.i;
+ else
+ return 0;
+}
+
+double Object::getDoubleProperty( std::string name )
+{
+ PropertyValue pv;
+ pv = d->properties[ name ];
+ if( pv.type == PropertyValue::DoubleType )
+ return pv.d;
+ else
+ return 0;
+}
+
+bool Object::getBoolProperty( std::string name )
+{
+ PropertyValue pv;
+ pv = d->properties[ name ];
+ if( pv.type == PropertyValue::BoolType )
+ return pv.b;
+ else
+ return false;
+
+}
+
+std::string Object::getStrProperty( std::string name )
+{
+ PropertyValue pv;
+ pv = d->properties[ name ];
+ if( pv.type == PropertyValue::StringType )
+ return pv.s;
+ else
+ return "NoString";
+}
+
+Color Object::getColorProperty(std::string name)
+{
+ PropertyValue pv;
+ pv = d->properties[ name ];
+ if( pv.type == PropertyValue::ColorType )
+ return pv.c;
+ else
+ return Color(153,204,255); // #99ccff
+
+}
+
+class TextObject::Private
+{
+public:
+ unsigned type;
+ std::vector<UString> text;
+ unsigned listSize;
+ std::vector<bool> bulletFlag;
+};
+
+TextObject::TextObject(): Object()
+{
+ d = new Private;
+}
+
+TextObject::~TextObject()
+{
+ delete d;
+}
+
+unsigned TextObject::type() const
+{
+ return d->type;
+}
+
+unsigned TextObject::listSize() const
+{
+ return d->text.size();
+}
+
+const char* TextObject::typeAsString() const
+{
+ switch( d->type )
+ {
+ case Title : return "Title";
+ case Body : return "Body";
+ case Notes : return "Notes";
+ case NotUsed : return "NotUsed";
+ case Other : return "Other";
+ case CenterBody : return "CenterBody";
+ case CenterTitle : return "CenterTitle";
+ case HalfBody : return "HalfBody";
+ case QuarterBody : return "QuarterBody";
+ default: break;
+ }
+
+ return "Unknown";
+}
+
+bool TextObject::bulletFlag( unsigned index ) const
+{
+ return d->bulletFlag[index];
+}
+
+void TextObject::setBulletFlag( bool flag )
+{
+ d->bulletFlag.push_back( flag );
+}
+
+
+void TextObject::setType( unsigned type )
+{
+ d->type = type;
+}
+
+UString TextObject::text( unsigned index) const
+{
+ return d->text[index];
+}
+
+void TextObject::setText( const UString& text )
+{
+ d->text.push_back( text );
+}
+
+void TextObject::convertFrom( Object* object )
+{
+ setId( object->id() );
+ setLeft( object->left() );
+ setTop( object->top() );
+ setWidth( object->width() );
+ setHeight( object->height() );
+
+ if( object->isText() )
+ {
+ TextObject* textObj = static_cast<TextObject*>( object );
+ setType( textObj->type() );
+ // jgn lupa diganti : setText( textObj->text() );
+ }
+}
+
+class GroupObject::Private
+{
+public:
+ std::vector<Object*> objects;
+};
+
+GroupObject::GroupObject()
+{
+ d = new Private;
+}
+
+GroupObject::~GroupObject()
+{
+ for( unsigned i=0; i<d->objects.size(); i++ )
+ delete d->objects[i];
+ delete d;
+}
+
+unsigned GroupObject::objectCount() const
+{
+ return d->objects.size();
+}
+
+Object* GroupObject::object( unsigned i )
+{
+ return d->objects[i];
+}
+
+void GroupObject::addObject( Object* object )
+{
+ d->objects.push_back( object );
+}
+
+void GroupObject::takeObject( Object* object )
+{
+ std::vector<Object*> result;
+ for( unsigned i=0; i<d->objects.size(); i++ )
+ {
+ Object* obj = d->objects[i];
+ if( obj != object )
+ result.push_back( obj );
+ }
+
+ d->objects.clear();
+ for( unsigned j=0; j<result.size(); j++ )
+ d->objects.push_back( result[j] );
+}
+
+class DrawObject::Private
+{
+public:
+ unsigned shape;
+ bool isVerFlip;
+ bool isHorFlip;
+};
+
+DrawObject::DrawObject()
+{
+ d = new Private;
+ d->shape = None;
+}
+
+DrawObject::~DrawObject()
+{
+ delete d;
+}
+
+unsigned DrawObject::shape() const
+{
+ return d->shape;
+}
+
+void DrawObject::setShape( unsigned s )
+{
+ d->shape = s;
+}
+
+bool DrawObject::isVerFlip() const
+{
+ return d->isVerFlip;
+}
+
+void DrawObject::setVerFlip( bool isVerFlip )
+{
+ d->isVerFlip = isVerFlip;
+}
+
+bool DrawObject::isHorFlip() const
+{
+ return d->isHorFlip;
+}
+
+void DrawObject::setHorFlip( bool isHorFlip )
+{
+ d->isHorFlip = isHorFlip;
+}
diff --git a/filters/kpresenter/powerpoint/libppt/objects.h b/filters/kpresenter/powerpoint/libppt/objects.h
new file mode 100644
index 00000000..823e2a75
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/objects.h
@@ -0,0 +1,206 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 LIBPPT_OBJECTS
+#define LIBPPT_OBJECTS
+
+#include "ustring.h"
+#include <string>
+
+
+namespace Libppt
+{
+
+class Color
+{
+public:
+ unsigned red, green, blue;
+ Color(){ red = green = blue = 0; }
+ Color( unsigned r, unsigned g, unsigned b )
+ { red = r; green = g; blue = b; }
+ Color( const Color& c )
+ { red = c.red; green = c.green; blue = c.blue; }
+ Color& operator=( const Color& c )
+ { red = c.red; green = c.green; blue = c.blue; return *this; }
+};
+
+class Object
+{
+public:
+ Object();
+ virtual ~Object();
+
+ int id() const;
+ void setId( int id );
+
+ virtual bool isText() const { return false; }
+ virtual bool isPicture() const { return false; }
+ virtual bool isGroup() const { return false; }
+ virtual bool isDrawing() const { return false; }
+
+ // all is in mm
+
+ double top() const;
+ double left() const;
+ double width() const;
+ double height() const;
+ void setTop( double top );
+ void setLeft( double left );
+ void setWidth( double width );
+ void setHeight( double height );
+
+ bool isBackground() const;
+ void setBackground( bool bg );
+
+
+ bool hasProperty( std::string name );
+
+ void setProperty( std::string name, int value );
+ void setProperty( std::string name, double value );
+ void setProperty( std::string name, std::string value );
+ void setProperty( std::string name, bool value );
+ void setProperty( std::string name, Color value );
+ void setProperty( std::string name, const char* value )
+ { setProperty( name, std::string(value) ); }
+
+ int getIntProperty( std::string name );
+ double getDoubleProperty( std::string name );
+ bool getBoolProperty( std::string name );
+ std::string getStrProperty( std::string name );
+ Color getColorProperty(std::string name);
+
+private:
+ // no copy or assign
+ Object( const Object& );
+ Object& operator=( const Object& );
+
+ class Private;
+ Private* d;
+};
+
+class TextObject: public Object
+{
+public:
+
+ enum {
+ Title = 0,
+ Body = 1,
+ Notes = 2,
+ NotUsed = 3,
+ Other = 4, // text in a shape
+ CenterBody = 5, // subtitle in title slide
+ CenterTitle = 6, // title in title slide
+ HalfBody = 7, // body in two-column slide
+ QuarterBody = 8 // body in four-body slide
+ };
+
+ TextObject();
+ virtual ~TextObject();
+ virtual bool isText() const { return true; }
+ unsigned type() const;
+ void setType( unsigned type );
+ const char* typeAsString() const;
+ UString text(unsigned index) const;
+ void setText( const UString& text );
+ unsigned listSize() const;
+ bool bulletFlag(unsigned index) const;
+ void setBulletFlag( bool flag ) ;
+ void convertFrom( Object* object );
+
+private:
+ // no copy or assign
+ TextObject( const TextObject& );
+ TextObject& operator=( const TextObject& );
+
+ class Private;
+ Private* d;
+};
+
+class GroupObject: public Object
+{
+public:
+ GroupObject();
+ virtual ~GroupObject();
+ virtual bool isGroup() const { return true; }
+ unsigned objectCount() const;
+ Object* object( unsigned index );
+ void addObject( Object* object );
+ void takeObject( Object* object );
+
+private:
+ // no copy or assign
+ GroupObject( const GroupObject& );
+ GroupObject& operator=( const GroupObject& );
+
+ class Private;
+ Private* d;
+
+};
+
+class DrawObject: public Object
+{
+public:
+
+ enum {
+ None = 0,
+ Rectangle,
+ RoundRectangle,
+ Circle,
+ Ellipse,
+ Diamond,
+ RightArrow,
+ LeftArrow,
+ UpArrow,
+ DownArrow,
+ IsoscelesTriangle,
+ RightTriangle,
+ Parallelogram,
+ Trapezoid,
+ Hexagon,
+ Octagon,
+ Line,
+ Smiley,
+ Heart,
+ FreeLine
+ };
+
+ DrawObject();
+ virtual ~DrawObject();
+ virtual bool isDrawing() const { return true; }
+
+ unsigned shape() const;
+ void setShape( unsigned s );
+
+ bool isVerFlip() const;
+ void setVerFlip( bool vFlip );
+ bool isHorFlip() const;
+ void setHorFlip( bool hFlip );
+
+private:
+ // no copy or assign
+ DrawObject( const DrawObject& );
+ DrawObject& operator=( const DrawObject& );
+
+ class Private;
+ Private* d;
+};
+
+}
+
+#endif /* LIBPPT_OBJECTS */
diff --git a/filters/kpresenter/powerpoint/libppt/pole.cpp b/filters/kpresenter/powerpoint/libppt/pole.cpp
new file mode 100644
index 00000000..2a78b79f
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/pole.cpp
@@ -0,0 +1,1317 @@
+/* POLE - Portable C++ library to access OLE Storage
+ Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the authors nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <fstream>
+#include <iostream>
+#include <list>
+#include <string>
+#include <vector>
+
+#include "pole.h"
+
+// enable to activate debugging output
+// #define POLE_DEBUG
+
+namespace POLE
+{
+
+class Header
+{
+ public:
+ unsigned char id[8]; // signature, or magic identifier
+ unsigned b_shift; // bbat->blockSize = 1 << b_shift
+ unsigned s_shift; // sbat->blockSize = 1 << s_shift
+ unsigned num_bat; // blocks allocated for big bat
+ unsigned dirent_start; // starting block for directory info
+ unsigned threshold; // switch from small to big file (usually 4K)
+ unsigned sbat_start; // starting block index to store small bat
+ unsigned num_sbat; // blocks allocated for small bat
+ unsigned mbat_start; // starting block to store meta bat
+ unsigned num_mbat; // blocks allocated for meta bat
+ unsigned long bb_blocks[109];
+
+ Header();
+ bool valid();
+ void load( const unsigned char* buffer );
+ void save( unsigned char* buffer );
+ void debug();
+};
+
+class AllocTable
+{
+ public:
+ static const unsigned Eof;
+ static const unsigned Avail;
+ static const unsigned Bat;
+ static const unsigned MetaBat;
+ unsigned blockSize;
+ AllocTable();
+ void clear();
+ unsigned long count();
+ void resize( unsigned long newsize );
+ void preserve( unsigned long n );
+ void set( unsigned long index, unsigned long val );
+ unsigned unused();
+ void setChain( std::vector<unsigned long> );
+ std::vector<unsigned long> follow( unsigned long start );
+ unsigned long operator[](unsigned long index );
+ void load( const unsigned char* buffer, unsigned len );
+ void save( unsigned char* buffer );
+ unsigned size();
+ void debug();
+ private:
+ std::vector<unsigned long> data;
+ AllocTable( const AllocTable& );
+ AllocTable& operator=( const AllocTable& );
+};
+
+class DirEntry
+{
+ public:
+ bool valid; // false if invalid (should be skipped)
+ std::string name; // the name, not in unicode anymore
+ bool dir; // true if directory
+ unsigned long size; // size (not valid if directory)
+ unsigned long start; // starting block
+ unsigned prev; // previous sibling
+ unsigned next; // next sibling
+ unsigned child; // first child
+};
+
+class DirTree
+{
+ public:
+ static const unsigned End;
+ DirTree();
+ void clear();
+ unsigned entryCount();
+ DirEntry* entry( unsigned index );
+ DirEntry* entry( const std::string& name, bool create=false );
+ int indexOf( DirEntry* e );
+ int parent( unsigned index );
+ std::string fullName( unsigned index );
+ std::vector<unsigned> children( unsigned index );
+ void load( unsigned char* buffer, unsigned len );
+ void save( unsigned char* buffer );
+ unsigned size();
+ void debug();
+ private:
+ std::vector<DirEntry> entries;
+ DirTree( const DirTree& );
+ DirTree& operator=( const DirTree& );
+};
+
+class StorageIO
+{
+ public:
+ Storage* storage; // owner
+ std::string filename; // filename
+ std::fstream file; // associated with above name
+ int result; // result of operation
+ bool opened; // true if file is opened
+ unsigned long filesize; // size of the file
+
+ Header* header; // storage header
+ DirTree* dirtree; // directory tree
+ AllocTable* bbat; // allocation table for big blocks
+ AllocTable* sbat; // allocation table for small blocks
+
+ std::vector<unsigned long> sb_blocks; // blocks for "small" files
+
+ std::list<Stream*> streams;
+
+ StorageIO( Storage* storage, const char* filename );
+ ~StorageIO();
+
+ bool open();
+ void close();
+ void flush();
+ void load();
+ void create();
+
+ unsigned long loadBigBlocks( std::vector<unsigned long> blocks, unsigned char* buffer, unsigned long maxlen );
+
+ unsigned long loadBigBlock( unsigned long block, unsigned char* buffer, unsigned long maxlen );
+
+ unsigned long loadSmallBlocks( std::vector<unsigned long> blocks, unsigned char* buffer, unsigned long maxlen );
+
+ unsigned long loadSmallBlock( unsigned long block, unsigned char* buffer, unsigned long maxlen );
+
+ StreamIO* streamIO( const std::string& name );
+
+ private:
+ // no copy or assign
+ StorageIO( const StorageIO& );
+ StorageIO& operator=( const StorageIO& );
+
+};
+
+class StreamIO
+{
+ public:
+ StorageIO* io;
+ DirEntry* entry;
+ std::string fullName;
+ bool eof;
+ bool fail;
+
+ StreamIO( StorageIO* io, DirEntry* entry );
+ ~StreamIO();
+ unsigned long size();
+ void seek( unsigned long pos );
+ unsigned long tell();
+ int getch();
+ unsigned long read( unsigned char* data, unsigned long maxlen );
+ unsigned long read( unsigned long pos, unsigned char* data, unsigned long maxlen );
+
+
+ private:
+ std::vector<unsigned long> blocks;
+
+ // no copy or assign
+ StreamIO( const StreamIO& );
+ StreamIO& operator=( const StreamIO& );
+
+ // pointer for read
+ unsigned long m_pos;
+
+ // simple cache system to speed-up getch()
+ unsigned char* cache_data;
+ unsigned long cache_size;
+ unsigned long cache_pos;
+ void updateCache();
+};
+
+} // namespace POLE
+
+using namespace POLE;
+
+static inline unsigned long readU16( const unsigned char* ptr )
+{
+ return ptr[0]+(ptr[1]<<8);
+}
+
+static inline unsigned long readU32( const unsigned char* ptr )
+{
+ return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
+}
+
+static inline void writeU16( unsigned char* ptr, unsigned long data )
+{
+ ptr[0] = (unsigned char)(data & 0xff);
+ ptr[1] = (unsigned char)((data >> 8) & 0xff);
+}
+
+static inline void writeU32( unsigned char* ptr, unsigned long data )
+{
+ ptr[0] = (unsigned char)(data & 0xff);
+ ptr[1] = (unsigned char)((data >> 8) & 0xff);
+ ptr[2] = (unsigned char)((data >> 16) & 0xff);
+ ptr[3] = (unsigned char)((data >> 24) & 0xff);
+}
+
+static const unsigned char pole_magic[] =
+ { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 };
+
+// =========== Header ==========
+
+Header::Header()
+{
+ b_shift = 9;
+ s_shift = 6;
+ num_bat = 0;
+ dirent_start = 0;
+ threshold = 4096;
+ sbat_start = 0;
+ num_sbat = 0;
+ mbat_start = 0;
+ num_mbat = 0;
+
+ for( unsigned i = 0; i < 8; i++ )
+ id[i] = pole_magic[i];
+ for( unsigned i=0; i<109; i++ )
+ bb_blocks[i] = AllocTable::Avail;
+}
+
+bool Header::valid()
+{
+ if( threshold != 4096 ) return false;
+ if( num_bat == 0 ) return false;
+ if( (num_bat > 109) && (num_bat > (num_mbat * 127) + 109)) return false;
+ if( (num_bat < 109) && (num_mbat != 0) ) return false;
+ if( s_shift > b_shift ) return false;
+ if( b_shift <= 6 ) return false;
+ if( b_shift >=31 ) return false;
+
+ return true;
+}
+
+void Header::load( const unsigned char* buffer )
+{
+ b_shift = readU16( buffer + 0x1e );
+ s_shift = readU16( buffer + 0x20 );
+ num_bat = readU32( buffer + 0x2c );
+ dirent_start = readU32( buffer + 0x30 );
+ threshold = readU32( buffer + 0x38 );
+ sbat_start = readU32( buffer + 0x3c );
+ num_sbat = readU32( buffer + 0x40 );
+ mbat_start = readU32( buffer + 0x44 );
+ num_mbat = readU32( buffer + 0x48 );
+
+ for( unsigned i = 0; i < 8; i++ )
+ id[i] = buffer[i];
+ for( unsigned i=0; i<109; i++ )
+ bb_blocks[i] = readU32( buffer + 0x4C+i*4 );
+}
+
+void Header::save( unsigned char* buffer )
+{
+ memset( buffer, 0, 0x4c );
+ memcpy( buffer, pole_magic, 8 ); // ole signature
+ writeU32( buffer + 8, 0 ); // unknown
+ writeU32( buffer + 12, 0 ); // unknown
+ writeU32( buffer + 16, 0 ); // unknown
+ writeU16( buffer + 24, 0x003e ); // revision ?
+ writeU16( buffer + 26, 3 ); // version ?
+ writeU16( buffer + 28, 0xfffe ); // unknown
+ writeU16( buffer + 0x1e, b_shift );
+ writeU16( buffer + 0x20, s_shift );
+ writeU32( buffer + 0x2c, num_bat );
+ writeU32( buffer + 0x30, dirent_start );
+ writeU32( buffer + 0x38, threshold );
+ writeU32( buffer + 0x3c, sbat_start );
+ writeU32( buffer + 0x40, num_sbat );
+ writeU32( buffer + 0x44, mbat_start );
+ writeU32( buffer + 0x48, num_mbat );
+
+ for( unsigned i=0; i<109; i++ )
+ writeU32( buffer + 0x4C+i*4, bb_blocks[i] );
+}
+
+void Header::debug()
+{
+ std::cout << std::endl;
+ std::cout << "b_shift " << b_shift << std::endl;
+ std::cout << "s_shift " << s_shift << std::endl;
+ std::cout << "num_bat " << num_bat << std::endl;
+ std::cout << "dirent_start " << dirent_start << std::endl;
+ std::cout << "threshold " << threshold << std::endl;
+ std::cout << "sbat_start " << sbat_start << std::endl;
+ std::cout << "num_sbat " << num_sbat << std::endl;
+ std::cout << "mbat_start " << mbat_start << std::endl;
+ std::cout << "num_mbat " << num_mbat << std::endl;
+
+ unsigned s = (num_bat<=109) ? num_bat : 109;
+ std::cout << "bat blocks: ";
+ for( unsigned i = 0; i < s; i++ )
+ std::cout << bb_blocks[i] << " ";
+ std::cout << std::endl;
+}
+
+// =========== AllocTable ==========
+
+const unsigned AllocTable::Avail = 0xffffffff;
+const unsigned AllocTable::Eof = 0xfffffffe;
+const unsigned AllocTable::Bat = 0xfffffffd;
+const unsigned AllocTable::MetaBat = 0xfffffffc;
+
+AllocTable::AllocTable()
+{
+ blockSize = 4096;
+ // initial size
+ resize( 128 );
+}
+
+unsigned long AllocTable::count()
+{
+ return data.size();
+}
+
+void AllocTable::resize( unsigned long newsize )
+{
+ unsigned oldsize = data.size();
+ data.resize( newsize );
+ if( newsize > oldsize )
+ for( unsigned i = oldsize; i<newsize; i++ )
+ data[i] = Avail;
+}
+
+// make sure there're still free blocks
+void AllocTable::preserve( unsigned long n )
+{
+ std::vector<unsigned long> pre;
+ for( unsigned i=0; i < n; i++ )
+ pre.push_back( unused() );
+}
+
+unsigned long AllocTable::operator[]( unsigned long index )
+{
+ unsigned long result;
+ result = data[index];
+ return result;
+}
+
+void AllocTable::set( unsigned long index, unsigned long value )
+{
+ if( index >= count() ) resize( index + 1);
+ data[ index ] = value;
+}
+
+void AllocTable::setChain( std::vector<unsigned long> chain )
+{
+ if( chain.size() )
+ {
+ for( unsigned i=0; i<chain.size()-1; i++ )
+ set( chain[i], chain[i+1] );
+ set( chain[ chain.size()-1 ], AllocTable::Eof );
+ }
+}
+
+// follow
+std::vector<unsigned long> AllocTable::follow( unsigned long start )
+{
+ std::vector<unsigned long> chain;
+
+ if( start >= count() ) return chain;
+
+ unsigned long p = start;
+ while( p < count() )
+ {
+ if( p == (unsigned long)Eof ) break;
+ if( p == (unsigned long)Bat ) break;
+ if( p == (unsigned long)MetaBat ) break;
+ if( p >= count() ) break;
+ chain.push_back( p );
+ if( data[p] >= count() ) break;
+ p = data[ p ];
+ }
+
+ return chain;
+}
+
+unsigned AllocTable::unused()
+{
+ // find first available block
+ for( unsigned i = 0; i < data.size(); i++ )
+ if( data[i] == Avail )
+ return i;
+
+ // completely full, so enlarge the table
+ unsigned block = data.size();
+ resize( data.size()+10 );
+ return block;
+}
+
+void AllocTable::load( const unsigned char* buffer, unsigned len )
+{
+ resize( len / 4 );
+ for( unsigned i = 0; i < count(); i++ )
+ set( i, readU32( buffer + i*4 ) );
+}
+
+// return space required to save this dirtree
+unsigned AllocTable::size()
+{
+ return count() * 4;
+}
+
+void AllocTable::save( unsigned char* buffer )
+{
+ for( unsigned i = 0; i < count(); i++ )
+ writeU32( buffer + i*4, data[i] );
+}
+
+void AllocTable::debug()
+{
+ std::cout << "block size " << data.size() << std::endl;
+ for( unsigned i=0; i< data.size(); i++ )
+ {
+ if( data[i] == Avail ) continue;
+ std::cout << i << ": ";
+ if( data[i] == Eof ) std::cout << "[eof]";
+ else if( data[i] == Bat ) std::cout << "[bat]";
+ else if( data[i] == MetaBat ) std::cout << "[metabat]";
+ else std::cout << data[i];
+ std::cout << std::endl;
+ }
+}
+
+// =========== DirTree ==========
+
+const unsigned DirTree::End = 0xffffffff;
+
+DirTree::DirTree()
+{
+ clear();
+}
+
+void DirTree::clear()
+{
+ // leave only root entry
+ entries.resize( 1 );
+ entries[0].valid = true;
+ entries[0].name = "Root Entry";
+ entries[0].dir = true;
+ entries[0].size = 0;
+ entries[0].start = End;
+ entries[0].prev = End;
+ entries[0].next = End;
+ entries[0].child = End;
+}
+
+unsigned DirTree::entryCount()
+{
+ return entries.size();
+}
+
+DirEntry* DirTree::entry( unsigned index )
+{
+ if( index >= entryCount() ) return (DirEntry*) 0;
+ return &entries[ index ];
+}
+
+int DirTree::indexOf( DirEntry* e )
+{
+ for( unsigned i = 0; i < entryCount(); i++ )
+ if( entry( i ) == e ) return i;
+
+ return -1;
+}
+
+int DirTree::parent( unsigned index )
+{
+ // brute-force, basically we iterate for each entries, find its children
+ // and check if one of the children is 'index'
+ for( unsigned j=0; j<entryCount(); j++ )
+ {
+ std::vector<unsigned> chi = children( j );
+ for( unsigned i=0; i<chi.size();i++ )
+ if( chi[i] == index )
+ return j;
+ }
+
+ return -1;
+}
+
+std::string DirTree::fullName( unsigned index )
+{
+ // don't use root name ("Root Entry"), just give "/"
+ if( index == 0 ) return "/";
+
+ std::string result = entry( index )->name;
+ result.insert( 0, "/" );
+ int p = parent( index );
+ DirEntry * _entry = 0;
+ while( p > 0 )
+ {
+ _entry = entry( p );
+ if (_entry->dir && _entry->valid)
+ {
+ result.insert( 0, _entry->name);
+ result.insert( 0, "/" );
+ }
+ --p;
+ index = p;
+ if( index <= 0 ) break;
+ }
+ return result;
+}
+
+// given a fullname (e.g "/ObjectPool/_1020961869"), find the entry
+// if not found and create is false, return 0
+// if create is true, a new entry is returned
+DirEntry* DirTree::entry( const std::string& name, bool create )
+{
+ if( !name.length() ) return (DirEntry*)0;
+
+ // quick check for "/" (that's root)
+ if( name == "/" ) return entry( 0 );
+
+ // split the names, e.g "/ObjectPool/_1020961869" will become:
+ // "ObjectPool" and "_1020961869"
+ std::list<std::string> names;
+ std::string::size_type start = 0, end = 0;
+ if( name[0] == '/' ) start++;
+ while( start < name.length() )
+ {
+ end = name.find_first_of( '/', start );
+ if( end == std::string::npos ) end = name.length();
+ names.push_back( name.substr( start, end-start ) );
+ start = end+1;
+ }
+
+ // start from root
+ int index = 0 ;
+
+ // trace one by one
+ std::list<std::string>::iterator it;
+
+ for( it = names.begin(); it != names.end(); ++it )
+ {
+ // find among the children of index
+ std::vector<unsigned> chi = children( index );
+ unsigned child = 0;
+ for( unsigned i = 0; i < chi.size(); i++ )
+ {
+ DirEntry* ce = entry( chi[i] );
+ if( ce )
+ if( ce->valid && ( ce->name.length()>1 ) )
+ if( ce->name == *it )
+ child = chi[i];
+ }
+
+ // traverse to the child
+ if( child > 0 ) index = child;
+ else
+ {
+ // not found among children
+ if( !create ) return (DirEntry*)0;
+
+ // create a new entry
+ unsigned parent = index;
+ entries.push_back( DirEntry() );
+ index = entryCount()-1;
+ DirEntry* e = entry( index );
+ e->valid = true;
+ e->name = *it;
+ e->dir = false;
+ e->size = 0;
+ e->start = 0;
+ e->child = End;
+ e->prev = End;
+ e->next = entry(parent)->child;
+ entry(parent)->child = index;
+ }
+ }
+
+ return entry( index );
+}
+
+// helper function: recursively find siblings of index
+void dirtree_find_siblings( DirTree* dirtree, std::vector<unsigned>& result,
+ unsigned index )
+{
+ DirEntry* e = dirtree->entry( index );
+ if( !e ) return;
+ if( !e->valid ) return;
+
+ // prevent infinite loop
+ for( unsigned i = 0; i < result.size(); i++ )
+ if( result[i] == index ) return;
+
+ // add myself
+ result.push_back( index );
+
+ // visit previous sibling, don't go infinitely
+ unsigned prev = e->prev;
+ if( ( prev > 0 ) && ( prev < dirtree->entryCount() ) )
+ {
+ for( unsigned i = 0; i < result.size(); i++ )
+ if( result[i] == prev ) prev = 0;
+ if( prev ) dirtree_find_siblings( dirtree, result, prev );
+ }
+
+ // visit next sibling, don't go infinitely
+ unsigned next = e->next;
+ if( ( next > 0 ) && ( next < dirtree->entryCount() ) )
+ {
+ for( unsigned i = 0; i < result.size(); i++ )
+ if( result[i] == next ) next = 0;
+ if( next ) dirtree_find_siblings( dirtree, result, next );
+ }
+}
+
+std::vector<unsigned> DirTree::children( unsigned index )
+{
+ std::vector<unsigned> result;
+
+ DirEntry* e = entry( index );
+ if( e ) if( e->valid && e->child < entryCount() )
+ dirtree_find_siblings( this, result, e->child );
+
+ return result;
+}
+
+void DirTree::load( unsigned char* buffer, unsigned size )
+{
+ entries.clear();
+
+ for( unsigned i = 0; i < size/128; i++ )
+ {
+ unsigned p = i * 128;
+
+ // would be < 32 if first char in the name isn't printable
+ unsigned prefix = 32;
+
+ // parse name of this entry, which stored as Unicode 16-bit
+ std::string name;
+ int name_len = readU16( buffer + 0x40+p );
+ if( name_len > 64 ) name_len = 64;
+ for( int j=0; ( buffer[j+p]) && (j<name_len); j+= 2 )
+ name.append( 1, buffer[j+p] );
+
+ // first char isn't printable ? remove it...
+ if( buffer[p] < 32 )
+ {
+ prefix = buffer[0];
+ name.erase( 0,1 );
+ }
+
+ // 2 = file (aka stream), 1 = directory (aka storage), 5 = root
+ unsigned type = buffer[ 0x42 + p];
+
+ DirEntry e;
+ e.valid = true;
+ e.name = name;
+ e.start = readU32( buffer + 0x74+p );
+ e.size = readU32( buffer + 0x78+p );
+ e.prev = readU32( buffer + 0x44+p );
+ e.next = readU32( buffer + 0x48+p );
+ e.child = readU32( buffer + 0x4C+p );
+ e.dir = ( type!=2 );
+
+ // sanity checks
+ if( (type != 2) && (type != 1 ) && (type != 5 ) ) e.valid = false;
+ if( name_len < 1 ) e.valid = false;
+
+ entries.push_back( e );
+ }
+}
+
+// return space required to save this dirtree
+unsigned DirTree::size()
+{
+ return entryCount() * 128;
+}
+
+void DirTree::save( unsigned char* buffer )
+{
+ memset( buffer, 0, size() );
+
+ // root is fixed as "Root Entry"
+ DirEntry* root = entry( 0 );
+ std::string name = "Root Entry";
+ for( unsigned j = 0; j < name.length(); j++ )
+ buffer[ j*2 ] = name[j];
+ writeU16( buffer + 0x40, name.length()*2 + 2 );
+ writeU32( buffer + 0x74, 0xffffffff );
+ writeU32( buffer + 0x78, 0 );
+ writeU32( buffer + 0x44, 0xffffffff );
+ writeU32( buffer + 0x48, 0xffffffff );
+ writeU32( buffer + 0x4c, root->child );
+ buffer[ 0x42 ] = 5;
+ buffer[ 0x43 ] = 1;
+
+ for( unsigned i = 1; i < entryCount(); i++ )
+ {
+ DirEntry* e = entry( i );
+ if( !e ) continue;
+ if( e->dir )
+ {
+ e->start = 0xffffffff;
+ e->size = 0;
+ }
+
+ // max length for name is 32 chars
+ std::string name = e->name;
+ if( name.length() > 32 )
+ name.erase( 32, name.length() );
+
+ // write name as Unicode 16-bit
+ for( unsigned j = 0; j < name.length(); j++ )
+ buffer[ i*128 + j*2 ] = name[j];
+
+ writeU16( buffer + i*128 + 0x40, name.length()*2 + 2 );
+ writeU32( buffer + i*128 + 0x74, e->start );
+ writeU32( buffer + i*128 + 0x78, e->size );
+ writeU32( buffer + i*128 + 0x44, e->prev );
+ writeU32( buffer + i*128 + 0x48, e->next );
+ writeU32( buffer + i*128 + 0x4c, e->child );
+ buffer[ i*128 + 0x42 ] = e->dir ? 1 : 2;
+ buffer[ i*128 + 0x43 ] = 1; // always black
+ }
+}
+
+void DirTree::debug()
+{
+ for( unsigned i = 0; i < entryCount(); i++ )
+ {
+ DirEntry* e = entry( i );
+ if( !e ) continue;
+ std::cout << i << ": ";
+ if( !e->valid ) std::cout << "INVALID ";
+ std::cout << e->name << " ";
+ if( e->dir ) std::cout << "(Dir) ";
+ else std::cout << "(File) ";
+ std::cout << e->size << " ";
+ std::cout << "s:" << e->start << " ";
+ std::cout << "(";
+ if( e->child == End ) std::cout << "-"; else std::cout << e->child;
+ std::cout << " ";
+ if( e->prev == End ) std::cout << "-"; else std::cout << e->prev;
+ std::cout << ":";
+ if( e->next == End ) std::cout << "-"; else std::cout << e->next;
+ std::cout << ")";
+ std::cout << std::endl;
+ }
+}
+
+// =========== StorageIO ==========
+
+StorageIO::StorageIO( Storage* st, const char* fname )
+{
+ storage = st;
+ filename = fname;
+ result = Storage::Ok;
+ opened = false;
+
+ header = new Header();
+ dirtree = new DirTree();
+ bbat = new AllocTable();
+ sbat = new AllocTable();
+
+ filesize = 0;
+ bbat->blockSize = 1 << header->b_shift;
+ sbat->blockSize = 1 << header->s_shift;
+}
+
+StorageIO::~StorageIO()
+{
+ if( opened ) close();
+ delete sbat;
+ delete bbat;
+ delete dirtree;
+ delete header;
+}
+
+bool StorageIO::open()
+{
+ // already opened ? close first
+ if( opened ) close();
+
+ load();
+
+ return result == Storage::Ok;
+}
+
+void StorageIO::load()
+{
+ unsigned char* buffer = 0;
+ unsigned long buflen = 0;
+ std::vector<unsigned long> blocks;
+
+ // open the file, check for error
+ result = Storage::OpenFailed;
+ file.open( filename.c_str(), std::ios::binary | std::ios::in );
+ if( !file.good() ) return;
+
+ // find size of input file
+ file.seekg( 0, std::ios::end );
+ filesize = file.tellg();
+
+ // load header
+ buffer = new unsigned char[512];
+ file.seekg( 0 );
+ file.read( (char*)buffer, 512 );
+ header->load( buffer );
+ delete[] buffer;
+
+ // check OLE magic id
+ result = Storage::NotOLE;
+ for( unsigned i=0; i<8; i++ )
+ if( header->id[i] != pole_magic[i] )
+ return;
+
+ // sanity checks
+ result = Storage::BadOLE;
+ if( !header->valid() ) return;
+ if( header->threshold != 4096 ) return;
+
+ // important block size
+ bbat->blockSize = 1 << header->b_shift;
+ sbat->blockSize = 1 << header->s_shift;
+
+ // find blocks allocated to store big bat
+ // the first 109 blocks are in header, the rest in meta bat
+ blocks.clear();
+ blocks.resize( header->num_bat );
+ for( unsigned i = 0; i < 109; i++ )
+ if( i >= header->num_bat ) break;
+ else blocks[i] = header->bb_blocks[i];
+ if( (header->num_bat > 109) && (header->num_mbat > 0) )
+ {
+ unsigned char* buffer2 = new unsigned char[ bbat->blockSize ];
+ unsigned k = 109;
+ unsigned mblock = header->mbat_start;
+ for( unsigned r = 0; r < header->num_mbat; r++ )
+ {
+ loadBigBlock( mblock, buffer2, bbat->blockSize );
+ for( unsigned s=0; s < bbat->blockSize-4; s+=4 )
+ {
+ if( k >= header->num_bat ) break;
+ else blocks[k++] = readU32( buffer2 + s );
+ }
+ mblock = readU32( buffer2 + bbat->blockSize-4 );
+ }
+ delete[] buffer2;
+ }
+
+ // load big bat
+ buflen = blocks.size()*bbat->blockSize;
+ if( buflen > 0 )
+ {
+ buffer = new unsigned char[ buflen ];
+ loadBigBlocks( blocks, buffer, buflen );
+ bbat->load( buffer, buflen );
+ delete[] buffer;
+ }
+
+ // load small bat
+ blocks.clear();
+ blocks = bbat->follow( header->sbat_start );
+ buflen = blocks.size()*bbat->blockSize;
+ if( buflen > 0 )
+ {
+ buffer = new unsigned char[ buflen ];
+ loadBigBlocks( blocks, buffer, buflen );
+ sbat->load( buffer, buflen );
+ delete[] buffer;
+ }
+
+ // load directory tree
+ blocks.clear();
+ blocks = bbat->follow( header->dirent_start );
+ buflen = blocks.size()*bbat->blockSize;
+ buffer = new unsigned char[ buflen ];
+ loadBigBlocks( blocks, buffer, buflen );
+ dirtree->load( buffer, buflen );
+ unsigned sb_start = readU32( buffer + 0x74 );
+ delete[] buffer;
+
+ // fetch block chain as data for small-files
+ sb_blocks = bbat->follow( sb_start ); // small files
+
+ // for troubleshooting, just enable this block
+#if 0
+ header->debug();
+ sbat->debug();
+ bbat->debug();
+ dirtree->debug();
+#endif
+
+ // so far so good
+ result = Storage::Ok;
+ opened = true;
+}
+
+void StorageIO::create()
+{
+ // std::cout << "Creating " << filename << std::endl;
+
+ file.open( filename.c_str(), std::ios::out|std::ios::binary );
+ if( !file.good() )
+ {
+ std::cerr << "Can't create " << filename << std::endl;
+ result = Storage::OpenFailed;
+ return;
+ }
+
+ // so far so good
+ opened = true;
+ result = Storage::Ok;
+}
+
+void StorageIO::flush()
+{
+ /* Note on Microsoft implementation:
+ - directory entries are stored in the last block(s)
+ - BATs are as second to the last
+ - Meta BATs are third to the last
+ */
+}
+
+void StorageIO::close()
+{
+ if( !opened ) return;
+
+ file.close();
+ opened = false;
+
+ std::list<Stream*>::iterator it;
+ for( it = streams.begin(); it != streams.end(); ++it )
+ delete *it;
+}
+
+StreamIO* StorageIO::streamIO( const std::string& name )
+{
+ // sanity check
+ if( !name.length() ) return (StreamIO*)0;
+
+ // search in the entries
+ DirEntry* entry = dirtree->entry( name );
+ //if( entry) std::cout << "FOUND\n";
+ if( !entry ) return (StreamIO*)0;
+ //if( !entry->dir ) std::cout << " NOT DIR\n";
+ if( entry->dir ) return (StreamIO*)0;
+
+ StreamIO* result = new StreamIO( this, entry );
+ result->fullName = name;
+
+ return result;
+}
+
+unsigned long StorageIO::loadBigBlocks( std::vector<unsigned long> blocks,
+ unsigned char* data, unsigned long maxlen )
+{
+ // sentinel
+ if( !data ) return 0;
+ if( !file.good() ) return 0;
+ if( blocks.size() < 1 ) return 0;
+ if( maxlen == 0 ) return 0;
+
+ // read block one by one, seems fast enough
+ unsigned long bytes = 0;
+ for( unsigned long i=0; (i < blocks.size() ) & ( bytes<maxlen ); i++ )
+ {
+ unsigned long block = blocks[i];
+ unsigned long pos = bbat->blockSize * ( block+1 );
+ unsigned long p = (bbat->blockSize < maxlen-bytes) ? bbat->blockSize : maxlen-bytes;
+ if( pos + p > filesize ) p = filesize - pos;
+ file.seekg( pos );
+ file.read( (char*)data + bytes, p );
+ bytes += p;
+ }
+
+ return bytes;
+}
+
+unsigned long StorageIO::loadBigBlock( unsigned long block,
+ unsigned char* data, unsigned long maxlen )
+{
+ // sentinel
+ if( !data ) return 0;
+ if( !file.good() ) return 0;
+
+ // wraps call for loadBigBlocks
+ std::vector<unsigned long> blocks;
+ blocks.resize( 1 );
+ blocks[ 0 ] = block;
+
+ return loadBigBlocks( blocks, data, maxlen );
+}
+
+// return number of bytes which has been read
+unsigned long StorageIO::loadSmallBlocks( std::vector<unsigned long> blocks,
+ unsigned char* data, unsigned long maxlen )
+{
+ // sentinel
+ if( !data ) return 0;
+ if( !file.good() ) return 0;
+ if( blocks.size() < 1 ) return 0;
+ if( maxlen == 0 ) return 0;
+
+ // our own local buffer
+ unsigned char* buf = new unsigned char[ bbat->blockSize ];
+
+ // read small block one by one
+ unsigned long bytes = 0;
+ for( unsigned long i=0; ( i<blocks.size() ) & ( bytes<maxlen ); i++ )
+ {
+ unsigned long block = blocks[i];
+
+ // find where the small-block exactly is
+ unsigned long pos = block * sbat->blockSize;
+ unsigned long bbindex = pos / bbat->blockSize;
+ if( bbindex >= sb_blocks.size() ) break;
+
+ loadBigBlock( sb_blocks[ bbindex ], buf, bbat->blockSize );
+
+ // copy the data
+ unsigned offset = pos % bbat->blockSize;
+ unsigned long p = (maxlen-bytes < bbat->blockSize-offset ) ? maxlen-bytes : bbat->blockSize-offset;
+ p = (sbat->blockSize<p ) ? sbat->blockSize : p;
+ memcpy( data + bytes, buf + offset, p );
+ bytes += p;
+ }
+
+ delete[] buf;
+
+ return bytes;
+}
+
+unsigned long StorageIO::loadSmallBlock( unsigned long block,
+ unsigned char* data, unsigned long maxlen )
+{
+ // sentinel
+ if( !data ) return 0;
+ if( !file.good() ) return 0;
+
+ // wraps call for loadSmallBlocks
+ std::vector<unsigned long> blocks;
+ blocks.resize( 1 );
+ blocks.assign( 1, block );
+
+ return loadSmallBlocks( blocks, data, maxlen );
+}
+
+// =========== StreamIO ==========
+
+StreamIO::StreamIO( StorageIO* s, DirEntry* e)
+{
+ io = s;
+ entry = e;
+ eof = false;
+ fail = false;
+
+ m_pos = 0;
+
+ if( entry->size >= io->header->threshold )
+ blocks = io->bbat->follow( entry->start );
+ else
+ blocks = io->sbat->follow( entry->start );
+
+ // prepare cache
+ cache_pos = 0;
+ cache_size = 4096; // optimal ?
+ cache_data = new unsigned char[cache_size];
+ updateCache();
+}
+
+// FIXME tell parent we're gone
+StreamIO::~StreamIO()
+{
+ delete[] cache_data;
+}
+
+void StreamIO::seek( unsigned long pos )
+{
+ m_pos = pos;
+}
+
+unsigned long StreamIO::tell()
+{
+ return m_pos;
+}
+
+int StreamIO::getch()
+{
+ // past end-of-file ?
+ if( m_pos > entry->size ) return -1;
+
+ // need to update cache ?
+ if( !cache_size || ( m_pos < cache_pos ) ||
+ ( m_pos >= cache_pos + cache_size ) )
+ updateCache();
+
+ // something bad if we don't get good cache
+ if( !cache_size ) return -1;
+
+ int data = cache_data[m_pos - cache_pos];
+ m_pos++;
+
+ return data;
+}
+
+unsigned long StreamIO::read( unsigned long pos, unsigned char* data, unsigned long maxlen )
+{
+ // sanity checks
+ if( !data ) return 0;
+ if( maxlen == 0 ) return 0;
+
+ unsigned long totalbytes = 0;
+
+ if ( entry->size < io->header->threshold )
+ {
+ // small file
+ unsigned long index = pos / io->sbat->blockSize;
+
+ if( index >= blocks.size() ) return 0;
+
+ unsigned char* buf = new unsigned char[ io->sbat->blockSize ];
+ unsigned long offset = pos % io->sbat->blockSize;
+ while( totalbytes < maxlen )
+ {
+ if( index >= blocks.size() ) break;
+ io->loadSmallBlock( blocks[index], buf, io->bbat->blockSize );
+ unsigned long count = io->sbat->blockSize - offset;
+ if( count > maxlen-totalbytes ) count = maxlen-totalbytes;
+ memcpy( data+totalbytes, buf + offset, count );
+ totalbytes += count;
+ offset = 0;
+ index++;
+ }
+ delete[] buf;
+
+ }
+ else
+ {
+ // big file
+ unsigned long index = pos / io->bbat->blockSize;
+
+ if( index >= blocks.size() ) return 0;
+
+ unsigned char* buf = new unsigned char[ io->bbat->blockSize ];
+ unsigned long offset = pos % io->bbat->blockSize;
+ while( totalbytes < maxlen )
+ {
+ if( index >= blocks.size() ) break;
+ io->loadBigBlock( blocks[index], buf, io->bbat->blockSize );
+ unsigned long count = io->bbat->blockSize - offset;
+ if( count > maxlen-totalbytes ) count = maxlen-totalbytes;
+ memcpy( data+totalbytes, buf + offset, count );
+ totalbytes += count;
+ index++;
+ offset = 0;
+ }
+ delete [] buf;
+
+ }
+
+ return totalbytes;
+}
+
+unsigned long StreamIO::read( unsigned char* data, unsigned long maxlen )
+{
+ unsigned long bytes = read( tell(), data, maxlen );
+ m_pos += bytes;
+ return bytes;
+}
+
+void StreamIO::updateCache()
+{
+ // sanity check
+ if( !cache_data ) return;
+
+ cache_pos = m_pos - ( m_pos % cache_size );
+ unsigned long bytes = cache_size;
+ if( cache_pos + bytes > entry->size ) bytes = entry->size - cache_pos;
+ cache_size = read( cache_pos, cache_data, bytes );
+}
+
+
+// =========== Storage ==========
+
+Storage::Storage( const char* filename )
+{
+ io = new StorageIO( this, filename );
+}
+
+Storage::~Storage()
+{
+ delete io;
+}
+
+int Storage::result()
+{
+ return io->result;
+}
+
+bool Storage::open()
+{
+ return io->open();
+}
+
+void Storage::close()
+{
+ io->close();
+}
+
+std::list<std::string> Storage::entries( const std::string& path )
+{
+ std::list<std::string> result;
+ DirTree* dt = io->dirtree;
+ DirEntry* e = dt->entry( path, false );
+ if( e && e->dir )
+ {
+ unsigned parent = dt->indexOf( e );
+ std::vector<unsigned> children = dt->children( parent );
+ for( unsigned i = 0; i < children.size(); i++ )
+ result.push_back( dt->entry( children[i] )->name );
+ }
+
+ return result;
+}
+
+bool Storage::isDirectory( const std::string& name )
+{
+ DirEntry* e = io->dirtree->entry( name, false );
+ return e ? e->dir : false;
+}
+
+// =========== Stream ==========
+
+Stream::Stream( Storage* storage, const std::string& name )
+{
+ io = storage->io->streamIO( name );
+}
+
+// FIXME tell parent we're gone
+Stream::~Stream()
+{
+ delete io;
+}
+
+std::string Stream::fullName()
+{
+ return io ? io->fullName : std::string();
+}
+
+unsigned long Stream::tell()
+{
+ return io ? io->tell() : 0;
+}
+
+void Stream::seek( unsigned long newpos )
+{
+ if( io ) io->seek( newpos );
+}
+
+unsigned long Stream::size()
+{
+ return io ? io->entry->size : 0;
+}
+
+int Stream::getch()
+{
+ return io ? io->getch() : 0;
+}
+
+unsigned long Stream::read( unsigned char* data, unsigned long maxlen )
+{
+ return io ? io->read( data, maxlen ) : 0;
+}
+
+bool Stream::eof()
+{
+ return io ? io->eof : false;
+}
+
+bool Stream::fail()
+{
+ return io ? io->fail : true;
+}
diff --git a/filters/kpresenter/powerpoint/libppt/pole.h b/filters/kpresenter/powerpoint/libppt/pole.h
new file mode 100644
index 00000000..61256b8f
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/pole.h
@@ -0,0 +1,177 @@
+/* POLE - Portable C++ library to access OLE Storage
+ Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the authors nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef POLE_H
+#define POLE_H
+
+#include <string>
+#include <list>
+
+namespace POLE
+{
+
+class StorageIO;
+class Stream;
+class StreamIO;
+
+class Storage
+{
+ friend class Stream;
+ friend class StreamOut;
+
+public:
+
+ // for Storage::result()
+ enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError };
+
+ /**
+ * Constructs a storage with name filename.
+ **/
+ Storage( const char* filename );
+
+ /**
+ * Destroys the storage.
+ **/
+ ~Storage();
+
+ /**
+ * Opens the storage. Returns true if no error occurs.
+ **/
+ bool open();
+
+ /**
+ * Closes the storage.
+ **/
+ void close();
+
+ /**
+ * Returns the error code of last operation.
+ **/
+ int result();
+
+ /**
+ * Finds all stream and directories in given path.
+ **/
+ std::list<std::string> entries( const std::string& path = "/" );
+
+ /**
+ * Returns true if specified entry name is a directory.
+ */
+ bool isDirectory( const std::string& name );
+
+ /**
+ * Finds and returns a stream with the specified name.
+ * If reuse is true, this function returns the already created stream
+ * (if any). Otherwise it will create the stream.
+ *
+ * When errors occur, this function returns NULL.
+ *
+ * You do not need to delete the created stream, it will be handled
+ * automatically.
+ **/
+ Stream* stream( const std::string& name, bool reuse = true );
+ //Stream* stream( const std::string& name, int mode = Stream::ReadOnly, bool reuse = true );
+
+private:
+ StorageIO* io;
+
+ // no copy or assign
+ Storage( const Storage& );
+ Storage& operator=( const Storage& );
+
+};
+
+class Stream
+{
+ friend class Storage;
+ friend class StorageIO;
+
+public:
+
+ /**
+ * Creates a new stream.
+ */
+ // name must be absolute, e.g "/Workbook"
+ Stream( Storage* storage, const std::string& name );
+
+ /**
+ * Destroys the stream.
+ */
+ ~Stream();
+
+ /**
+ * Returns the full stream name.
+ */
+ std::string fullName();
+
+ /**
+ * Returns the stream size.
+ **/
+ unsigned long size();
+
+ /**
+ * Returns the current read/write position.
+ **/
+ unsigned long tell();
+
+ /**
+ * Sets the read/write position.
+ **/
+ void seek( unsigned long pos );
+
+ /**
+ * Reads a byte.
+ **/
+ int getch();
+
+ /**
+ * Reads a block of data.
+ **/
+ unsigned long read( unsigned char* data, unsigned long maxlen );
+
+ /**
+ * Returns true if the read/write position is past the file.
+ **/
+ bool eof();
+
+ /**
+ * Returns true whenever error occurs.
+ **/
+ bool fail();
+
+private:
+ StreamIO* io;
+
+ // no copy or assign
+ Stream( const Stream& );
+ Stream& operator=( const Stream& );
+};
+
+}
+
+#endif // POLE_H
diff --git a/filters/kpresenter/powerpoint/libppt/powerpoint.cpp b/filters/kpresenter/powerpoint/libppt/powerpoint.cpp
new file mode 100644
index 00000000..af035c69
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/powerpoint.cpp
@@ -0,0 +1,6201 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 "powerpoint.h"
+#include "presentation.h"
+#include "slide.h"
+#include "pole.h"
+#include "objects.h"
+
+#include <iostream>
+#include <iomanip>
+
+#include <vector>
+#include <map>
+
+#include <kdebug.h>
+#include <stdio.h>
+
+// Use anonymous namespace to cover following functions
+namespace{
+
+static inline unsigned long readU16( const void* p )
+{
+ const unsigned char* ptr = (const unsigned char*) p;
+ return ptr[0]+(ptr[1]<<8);
+}
+
+static inline signed long readS16( const void* p )
+{
+ const unsigned char* ptr = (const unsigned char*) p;
+ return ptr[0]+(ptr[1]<<8);
+}
+
+static inline unsigned long readU32( const void* p )
+{
+ const unsigned char* ptr = (const unsigned char*) p;
+ return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
+}
+
+static inline signed long readS32( const void* p )
+{
+ const unsigned char* ptr = (const unsigned char*) p;
+ return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
+}
+
+}
+
+namespace Libppt
+{
+std::ostream& operator<<( std::ostream& s, UString ustring )
+{
+ char* str = ustring.ascii();
+ s << str;
+ return s;
+}
+
+}
+
+
+using namespace Libppt;
+
+
+// ========== base record ==========
+
+const unsigned int Record::id = 0; // invalid of-course
+
+Record::Record()
+{
+ stream_position = 0;
+ record_instance = 0;
+ record_parent = 0;
+}
+
+Record::~Record()
+{
+}
+
+Record* Record::create( unsigned type )
+{
+ Record* record = 0;
+
+ if( type == BookmarkCollectionContainer::id )
+ record = new BookmarkCollectionContainer();
+
+ else if( type == DocumentContainer::id )
+ record = new DocumentContainer();
+
+ else if( type == EnvironmentContainer::id )
+ record = new EnvironmentContainer();
+
+ else if( type == ExObjListContainer::id )
+ record = new ExObjListContainer();
+
+ else if( type == ExOleObjStgContainer::id )
+ record = new ExOleObjStgContainer();
+
+ else if( type == ExHyperlinkContainer::id )
+ record = new ExHyperlinkContainer();
+
+ else if( type == ExEmbedContainer::id )
+ record = new ExEmbedContainer();
+
+ else if( type == ExLinkContainer::id )
+ record = new ExLinkContainer();
+
+ else if( type == FontCollectionContainer::id )
+ record = new FontCollectionContainer();
+
+ else if( type == HandoutContainer::id )
+ record = new HandoutContainer();
+
+ else if( type == HeadersFootersContainer::id )
+ record = new HeadersFootersContainer();
+
+ else if( type == ListContainer::id )
+ record = new ListContainer();
+
+ else if( type == SlideContainer::id )
+ record = new SlideContainer();
+
+ else if( type == SlideBaseContainer::id )
+ record = new SlideBaseContainer();
+
+ else if( type == MainMasterContainer::id )
+ record = new MainMasterContainer();
+
+ else if( type == NotesContainer::id )
+ record = new NotesContainer();
+
+ else if( type == RunArrayContainer::id )
+ record = new RunArrayContainer();
+
+ else if( type == SlideListWithTextContainer::id )
+ record = new SlideListWithTextContainer();
+
+ else if( type == SlideViewInfoContainer::id )
+ record = new SlideViewInfoContainer();
+
+ else if( type == SorterViewInfoContainer::id )
+ record = new SorterViewInfoContainer();
+
+ else if( type == SrKinsokuContainer::id )
+ record = new SrKinsokuContainer();
+
+ else if( type == SummaryContainer::id )
+ record = new SummaryContainer();
+
+ else if( type == OutlineViewInfoContainer::id )
+ record = new OutlineViewInfoContainer();
+
+ else if( type == ProgStringTagContainer ::id )
+ record = new ProgStringTagContainer ();
+
+ else if( type == PPDrawingGroupContainer ::id )
+ record = new PPDrawingGroupContainer ();
+
+ else if( type == PPDrawingContainer ::id )
+ record = new PPDrawingContainer ();
+
+ else if( type == ProgBinaryTagContainer ::id )
+ record = new ProgBinaryTagContainer ();
+
+ else if( type == ProgTagsContainer ::id )
+ record = new ProgTagsContainer ();
+
+ else if( type == VBAInfoContainer::id )
+ record = new VBAInfoContainer();
+
+ else if( type == ViewInfoContainer::id )
+ record = new ViewInfoContainer();
+
+
+ else if( type == msofbtDgContainer::id )
+ record = new msofbtDgContainer();
+
+ else if( type == msofbtSpgrContainer::id )
+ record = new msofbtSpgrContainer();
+
+ else if( type == msofbtSpContainer::id )
+ record = new msofbtSpContainer();
+
+ else if( type == msofbtDggContainer::id )
+ record = new msofbtDggContainer();
+
+ else if( type == msofbtBstoreContainer::id )
+ record = new msofbtBstoreContainer();
+
+ else if( type == msofbtSolverContainer::id )
+ record = new msofbtSolverContainer();
+
+
+ else if( type == BookmarkEntityAtom::id )
+ record = new BookmarkEntityAtom();
+
+ else if( type == CStringAtom::id )
+ record = new CStringAtom();
+
+ else if( type == ColorSchemeAtom::id )
+ record = new ColorSchemeAtom();
+
+ else if( type == CurrentUserAtom::id )
+ record = new CurrentUserAtom();
+
+ else if( type == DocumentAtom::id )
+ record = new DocumentAtom();
+
+ else if( type == EndDocumentAtom::id )
+ record = new EndDocumentAtom();
+
+ else if( type == ExEmbedAtom::id )
+ record = new ExEmbedAtom();
+
+ else if( type == ExHyperlinkAtom::id )
+ record = new ExHyperlinkAtom();
+
+ else if( type == ExLinkAtom::id )
+ record = new ExLinkAtom();
+
+ else if( type == ExObjListAtom::id )
+ record = new ExObjListAtom();
+
+ else if( type == ExOleObjAtom::id )
+ record = new ExOleObjAtom();
+
+ else if( type == FontEntityAtom::id )
+ record = new FontEntityAtom();
+
+ else if( type == GuideAtom::id )
+ record = new GuideAtom();
+
+ else if( type == HeadersFootersAtom ::id )
+ record = new HeadersFootersAtom ();
+
+ else if( type == NotesAtom::id )
+ record = new NotesAtom();
+
+ else if( type == PersistIncrementalBlockAtom::id )
+ record = new PersistIncrementalBlockAtom();
+
+ else if( type == Record1043::id )
+ record = new Record1043 ();
+
+ else if( type == Record1044::id )
+ record = new Record1044 ();
+
+ else if( type == SrKinsokuAtom::id )
+ record = new SrKinsokuAtom();
+
+ else if( type == SlideAtom::id )
+ record = new SlideAtom();
+
+ else if( type == SlidePersistAtom::id )
+ record = new SlidePersistAtom();
+
+ else if( type == StyleTextPropAtom::id )
+ record = new StyleTextPropAtom();
+
+ else if( type == SlideViewInfoAtom::id )
+ record = new SlideViewInfoAtom();
+
+ else if( type == SSDocInfoAtom ::id )
+ record = new SSDocInfoAtom();
+
+ else if( type == SSlideLayoutAtom ::id )
+ record = new SSlideLayoutAtom();
+
+ else if( type == SSSlideInfoAtom ::id )
+ record = new SSSlideInfoAtom();
+
+ else if( type == TextHeaderAtom ::id )
+ record = new TextHeaderAtom();
+
+ else if( type == TextBookmarkAtom ::id )
+ record = new TextBookmarkAtom();
+
+ else if( type == TextBytesAtom::id )
+ record = new TextBytesAtom ();
+
+ else if( type == TextCharsAtom::id )
+ record = new TextCharsAtom ();
+
+ else if( type == TextSpecInfoAtom ::id )
+ record = new TextSpecInfoAtom();
+
+ else if( type == TxCFStyleAtom ::id )
+ record = new TxCFStyleAtom();
+
+ else if( type == TxMasterStyleAtom ::id )
+ record = new TxMasterStyleAtom();
+
+ else if( type == TxPFStyleAtom ::id )
+ record = new TxPFStyleAtom();
+
+ else if( type == TxSIStyleAtom ::id )
+ record = new TxSIStyleAtom();
+
+ else if( type == UserEditAtom::id )
+ record = new UserEditAtom();
+
+ else if( type == ViewInfoAtom::id )
+ record = new ViewInfoAtom();
+
+ else if( type == msofbtDgAtom::id )
+ record = new msofbtDgAtom() ;
+
+ else if( type == msofbtSpgrAtom::id )
+ record = new msofbtSpgrAtom() ;
+
+ else if( type == msofbtSpAtom::id )
+ record = new msofbtSpAtom() ;
+
+ else if( type == msofbtOPTAtom::id )
+ record = new msofbtOPTAtom() ;
+
+ else if( type == msofbtChildAnchorAtom::id )
+ record = new msofbtChildAnchorAtom() ;
+
+ else if( type == msofbtClientAnchorAtom::id )
+ record = new msofbtClientAnchorAtom() ;
+
+ else if( type == msofbtClientDataAtom::id )
+ record = new msofbtClientDataAtom() ;
+
+ else if( type == msofbtClientTextboxAtom::id )
+ record = new msofbtClientTextboxAtom() ;
+
+ else if( type == msofbtDggAtom::id )
+ record = new msofbtDggAtom() ;
+
+ else if( type == msofbtColorMRUAtom::id )
+ record = new msofbtColorMRUAtom() ;
+
+ else if( type == msofbtSplitMenuColorsAtom::id )
+ record = new msofbtSplitMenuColorsAtom() ;
+
+ else if( type == msofbtBSEAtom::id )
+ record = new msofbtBSEAtom() ;
+
+ else if( type == msofbtCLSIDAtom::id )
+ record = new msofbtCLSIDAtom() ;
+
+ else if( type == msofbtRegroupItemsAtom::id )
+ record = new msofbtRegroupItemsAtom() ;
+
+ else if( type == msofbtColorSchemeAtom::id )
+ record = new msofbtColorSchemeAtom() ;
+
+ else if( type == msofbtClientTextboxAtom::id )
+ record = new msofbtClientTextboxAtom() ;
+
+ else if( type == msofbtAnchorAtom::id )
+ record = new msofbtAnchorAtom() ;
+
+ else if( type == msofbtOleObjectAtom::id )
+ record = new msofbtOleObjectAtom() ;
+
+ else if( type == msofbtDeletedPsplAtom::id )
+ record = new msofbtDeletedPsplAtom() ;
+
+ else if( type == msofbtConnectorRuleAtom::id )
+ record = new msofbtConnectorRuleAtom() ;
+
+ else if( type == msofbtAlignRuleAtom::id )
+ record = new msofbtAlignRuleAtom() ;
+
+ else if( type == msofbtArcRuleAtom::id )
+ record = new msofbtArcRuleAtom() ;
+
+ else if( type == msofbtClientRuleAtom::id )
+ record = new msofbtClientRuleAtom() ;
+
+ else if( type == msofbtCalloutRuleAtom::id )
+ record = new msofbtCalloutRuleAtom() ;
+
+ else if( type == msofbtSelectionAtom::id )
+ record = new msofbtSelectionAtom() ;
+
+return record;
+}
+
+void Record::setParent( Record* parent )
+{
+ record_parent = parent;
+}
+
+const Record* Record::parent() const
+{
+ return record_parent;
+}
+
+void Record::setPosition( unsigned pos )
+{
+ stream_position = pos;
+}
+
+unsigned Record::position() const
+{
+ return stream_position;
+}
+
+void Record::setInstance( unsigned instance )
+{
+ record_instance = instance;
+}
+
+unsigned Record::instance() const
+{
+ return record_instance;
+}
+
+void Record::setData( unsigned, const unsigned char* )
+{
+}
+
+void Record::setData( unsigned, const unsigned char*, unsigned )
+{
+}
+
+void Record::dump( std::ostream& ) const
+{
+ // nothing to dump
+}
+
+// ========== Container ==========
+
+Container::Container()
+{
+}
+
+// ========== BookmarkCollectionContainer ==========
+
+const unsigned int BookmarkCollectionContainer::id = 2019;
+
+BookmarkCollectionContainer::BookmarkCollectionContainer()
+{
+}
+
+// ========== msofbtDggContainer ==========
+
+const unsigned int msofbtDggContainer::id = 61440; /* F000 */
+
+msofbtDggContainer::msofbtDggContainer()
+{
+}
+
+// ========== msofbtBstoreContainer ==========
+
+const unsigned int msofbtBstoreContainer::id = 61441; /* F001 */
+
+msofbtBstoreContainer::msofbtBstoreContainer()
+{
+}
+
+// ========== msofbtDgContainer ==========
+
+const unsigned int msofbtDgContainer::id = 61442; /* F002 */
+
+msofbtDgContainer::msofbtDgContainer()
+{
+}
+
+// ========== msofbtSpgrContainer ==========
+
+const unsigned int msofbtSpgrContainer::id = 61443; /* F003*/
+
+msofbtSpgrContainer::msofbtSpgrContainer()
+{
+}
+
+// ========== msofbtSpContainer ==========
+
+const unsigned int msofbtSpContainer::id = 61444; /* F004 */
+
+msofbtSpContainer::msofbtSpContainer()
+{
+}
+
+// ========== msofbtSolverContainer ==========
+
+const unsigned int msofbtSolverContainer::id = 61445; /* F005 */
+
+msofbtSolverContainer::msofbtSolverContainer()
+{
+}
+
+
+// ========== DocumentContainer ==========
+
+const unsigned int DocumentContainer::id = 1000;
+
+DocumentContainer::DocumentContainer()
+{
+}
+
+// ========== NotesContainer ==========
+
+const unsigned int NotesContainer::id = 1008;
+
+NotesContainer::NotesContainer()
+{
+}
+
+// ========== ExOleObjStgContainer ==========
+
+const unsigned int ExOleObjStgContainer::id = 4113;
+
+ExOleObjStgContainer::ExOleObjStgContainer()
+{
+}
+
+// ========== FontCollectionContainer ==========
+
+const unsigned int FontCollectionContainer::id = 2005;
+
+FontCollectionContainer::FontCollectionContainer()
+{
+}
+
+
+// ========== ExObjListContainer ==========
+
+const unsigned int ExObjListContainer::id = 1033;
+
+ExObjListContainer::ExObjListContainer()
+{
+}
+
+// ========== SlideContainer ==========
+
+const unsigned int SlideContainer::id = 1006;
+
+SlideContainer::SlideContainer()
+{
+}
+
+// ========== SlideBaseContainer ==========
+
+const unsigned int SlideBaseContainer::id = 1004;
+
+SlideBaseContainer::SlideBaseContainer()
+{
+}
+
+// ========== SlideListWithTextContainer ==========
+
+const unsigned int SlideListWithTextContainer::id = 4080;
+
+SlideListWithTextContainer::SlideListWithTextContainer()
+{
+}
+
+// ========== SlideViewInfoContainer ==========
+
+const unsigned int SlideViewInfoContainer::id = 1018;
+
+SlideViewInfoContainer::SlideViewInfoContainer()
+{
+}
+
+// ========== OutlineViewInfoContainer ==========
+
+const unsigned int OutlineViewInfoContainer::id = 1031;
+
+OutlineViewInfoContainer::OutlineViewInfoContainer()
+{
+}
+
+// ========== SorterViewInfoContainer ==========
+
+const unsigned int SorterViewInfoContainer::id = 1032;
+
+SorterViewInfoContainer::SorterViewInfoContainer()
+{
+}
+
+// ========== HandoutContainer ==========
+
+const unsigned int HandoutContainer::id = 4041;
+
+HandoutContainer::HandoutContainer()
+{
+}
+
+// ========== ListContainer ==========
+
+const unsigned int ListContainer::id = 2000;
+
+ListContainer::ListContainer()
+{
+}
+
+// ========== ExEmbedContainer ==========
+
+const unsigned int ExEmbedContainer::id = 4044;
+
+ExEmbedContainer::ExEmbedContainer()
+{
+}
+
+// ========== ExLinkContainer ==========
+
+const unsigned int ExLinkContainer::id = 4046;
+
+ExLinkContainer::ExLinkContainer()
+{
+}
+
+// ========== ExHyperlinkContainer ==========
+
+const unsigned int ExHyperlinkContainer::id = 4055;
+
+ExHyperlinkContainer::ExHyperlinkContainer()
+{
+}
+
+// ========== MainMasterContainer ==========
+
+const unsigned int MainMasterContainer::id = 1016;
+
+MainMasterContainer::MainMasterContainer()
+{
+}
+
+// ========== EnvironmentContainer ==========
+
+const unsigned int EnvironmentContainer::id = 1010;
+
+EnvironmentContainer::EnvironmentContainer()
+{
+}
+
+// ========== HeadersFootersContainer ==========
+
+const unsigned int HeadersFootersContainer::id = 4057;
+
+HeadersFootersContainer::HeadersFootersContainer()
+{
+}
+
+// ========== RunArrayContainer ==========
+
+const unsigned int RunArrayContainer::id = 2028;
+
+RunArrayContainer::RunArrayContainer()
+{
+}
+
+// ========== SrKinsokuContainer ==========
+
+const unsigned int SrKinsokuContainer::id = 4040;
+
+SrKinsokuContainer::SrKinsokuContainer()
+{
+}
+
+// ========== ProgTagsContainer ==========
+
+const unsigned int ProgTagsContainer::id = 5000;
+
+ProgTagsContainer::ProgTagsContainer()
+{
+}
+
+// ========== ProgBinaryTagContainer ==========
+
+const unsigned int ProgBinaryTagContainer::id = 5002;
+
+ProgBinaryTagContainer::ProgBinaryTagContainer()
+{
+}
+
+// ========== ProgStringTagContainer ==========
+
+const unsigned int ProgStringTagContainer::id = 5001;
+
+ProgStringTagContainer::ProgStringTagContainer()
+{
+}
+
+// ========== PPDrawingGroupContainer ==========
+
+const unsigned int PPDrawingGroupContainer::id = 1035;
+
+PPDrawingGroupContainer::PPDrawingGroupContainer()
+{
+}
+
+// ========== PPDrawingContainer ==========
+
+const unsigned int PPDrawingContainer::id = 1036;
+
+PPDrawingContainer::PPDrawingContainer()
+{
+}
+
+// ========== SummaryContainer ==========
+
+const unsigned int SummaryContainer::id = 1026;
+
+SummaryContainer::SummaryContainer()
+{
+}
+
+// ========== VBAInfoContainer ==========
+
+const unsigned int VBAInfoContainer::id = 1023;
+
+VBAInfoContainer::VBAInfoContainer()
+{
+}
+
+// ========== ViewInfoContainer ==========
+
+const unsigned int ViewInfoContainer::id = 1020;
+
+ViewInfoContainer::ViewInfoContainer()
+{
+}
+
+// ========== CStringAtom ==========
+
+const unsigned int CStringAtom::id = 4026;
+
+class CStringAtom::Private
+{
+public:
+ UString ustring;
+};
+
+
+CStringAtom::CStringAtom()
+{
+ d = new Private;
+}
+
+CStringAtom::~CStringAtom()
+{
+ delete d;
+}
+
+UString CStringAtom::ustring() const
+{
+ return d->ustring;
+}
+
+void CStringAtom::setUString( const UString& ustr )
+{
+ d->ustring = ustr;
+}
+
+void CStringAtom::setData( unsigned size, const unsigned char* data )
+{
+ UString str;
+ for( unsigned k=0; k<(size/2); k++ )
+ {
+ unsigned uchar = readU16( data + k*2 );
+ if (uchar == 0x0d)
+ {
+ uchar = 0x0b;
+// std::cout << "found 0x0d in CStringAtom " << std::endl;
+ }
+ str.append( UString(uchar) );
+ }
+ setUString( str );
+}
+
+void CStringAtom::dump( std::ostream& out ) const
+{
+ out << "CStringAtom" << std::endl;
+ out << "String : [" << ustring() << "]" << std::endl;
+}
+
+// ========== DocumentAtom ==========
+
+const unsigned int DocumentAtom::id = 1001;
+
+class DocumentAtom::Private
+{
+public:
+ int slideWidth;
+ int slideHeight;
+ int notesWidth;
+ int notesHeight;
+ int zoomNumer;
+ int zoomDenom;
+ int notesMasterPersist;
+ int handoutMasterPersist;
+ int firstSlideNum;
+ int slideSizeType;
+ int saveWithFonts;
+ int omitTitlePlace;
+ int rightToLeft;
+ int showComments;
+};
+
+DocumentAtom::DocumentAtom()
+{
+ d = new Private;
+ d->slideWidth = 5760; // 10 inches
+ d->slideHeight = 4320; // 7.5 inches
+ d->notesWidth = 4320;
+ d->notesHeight = 5760;
+ d->zoomNumer = 1;
+ d->zoomDenom = 2;
+ d->notesMasterPersist = 0;
+ d->handoutMasterPersist = 0;
+ d->firstSlideNum = 0;
+ d->slideSizeType = 0;
+ d->saveWithFonts = 0;
+ d->omitTitlePlace = 0;
+ d->rightToLeft = 0 ;
+ d->showComments = 0;
+}
+
+DocumentAtom::~DocumentAtom()
+{
+ delete d;
+}
+
+int DocumentAtom::slideWidth() const
+{
+ return d->slideWidth;
+}
+
+void DocumentAtom::setSlideWidth( int w )
+{
+ d->slideWidth = w;
+}
+
+int DocumentAtom::slideHeight() const
+{
+ return d->slideHeight;
+}
+
+void DocumentAtom::setSlideHeight( int h )
+{
+ d->slideHeight = h;
+}
+
+int DocumentAtom::notesWidth() const
+{
+ return d->notesWidth;
+}
+
+void DocumentAtom::setNotesWidth( int nw )
+{
+ d->notesWidth = nw;
+}
+
+int DocumentAtom::notesHeight() const
+{
+ return d->notesHeight;
+}
+
+void DocumentAtom::setNotesHeight( int nh )
+{
+ d->notesHeight = nh;
+}
+
+int DocumentAtom::zoomNumer () const
+{
+ return d->zoomNumer;
+}
+
+void DocumentAtom::setZoomNumer( int numer )
+{
+ d->zoomNumer = numer;
+}
+
+int DocumentAtom::zoomDenom() const
+{
+ return d->zoomDenom;
+}
+
+void DocumentAtom::setZoomDenom( int denom )
+{
+ d->zoomDenom = denom;
+}
+
+int DocumentAtom::notesMasterPersist() const
+{
+ return d->notesMasterPersist;
+}
+
+void DocumentAtom::setNotesMasterPersist( int notesMasterPersist )
+{
+ d->notesMasterPersist = notesMasterPersist;
+}
+
+int DocumentAtom::handoutMasterPersist() const
+{
+ return d->handoutMasterPersist;
+}
+
+void DocumentAtom::setHandoutMasterPersist(int handoutMasterPersist)
+{
+ d->handoutMasterPersist = handoutMasterPersist;
+}
+
+int DocumentAtom::firstSlideNum() const
+{
+ return d->firstSlideNum;
+}
+
+void DocumentAtom::setFirstSlideNum( int firstSlideNum )
+{
+ d->firstSlideNum = firstSlideNum;
+}
+
+int DocumentAtom::slideSizeType() const
+{
+ return d->slideSizeType;
+}
+
+void DocumentAtom::setSlideSizeType( int slideSizeType )
+{
+ d->slideSizeType = slideSizeType;
+}
+
+int DocumentAtom::saveWithFonts() const
+{
+ return d->saveWithFonts;
+}
+
+void DocumentAtom::setSaveWithFonts( int saveWithFonts )
+{
+ d->saveWithFonts = saveWithFonts;
+}
+
+int DocumentAtom::omitTitlePlace() const
+{
+ return d->omitTitlePlace;
+}
+
+void DocumentAtom::setOmitTitlePlace( int omitTitlePlace )
+{
+ d->omitTitlePlace = omitTitlePlace;
+}
+
+int DocumentAtom::rightToLeft() const
+{
+ return d->rightToLeft;
+}
+
+void DocumentAtom::setRightToLeft( int rightToLeft )
+{
+ d->rightToLeft = rightToLeft;
+}
+
+int DocumentAtom::showComments() const
+{
+ return d->showComments;
+}
+
+void DocumentAtom::setShowComments( int showComments)
+{
+ d->showComments = showComments;
+}
+
+void DocumentAtom::setData( unsigned , const unsigned char* data )
+{
+ setSlideWidth( readU32( data+0 ) );
+ setSlideHeight( readU32( data+4 ) );
+ setNotesWidth( readU32( data+8 ) );
+ setNotesHeight( readU32( data+12 ) );
+ setZoomNumer( readS32( data+16 ) );
+ setZoomDenom( readS32( data+20) );
+ setNotesMasterPersist( readU32( data+24 ) );
+ setHandoutMasterPersist ( readU32( data+28 ) );
+ setFirstSlideNum( readU16( data+32 ) );
+ setSlideSizeType( readS16( data+34 ) );
+ setSaveWithFonts(data[36]);
+ setOmitTitlePlace(data[37]);
+ setRightToLeft(data[38]);
+ setShowComments(data[39]);
+}
+
+void DocumentAtom::dump( std::ostream& out ) const
+{
+ out << "DocumentAtom" << std::endl;
+ out << "slide width " << slideWidth() << std::endl;
+ out << "slide height " << slideHeight() << std::endl;
+ out << "notes width " << notesWidth() << std::endl;
+ out << "notes height " << notesHeight() << std::endl;
+ out << "zoom numer " << zoomNumer() << std::endl;
+ out << "zoom denum " << zoomDenom() << std::endl;
+ out << "notesMasterPersist " << notesMasterPersist() << std::endl;
+ out << "handoutMasterPersist " << handoutMasterPersist() << std::endl;
+ out << "firstSlideNum " << firstSlideNum() << std::endl;
+ out << "slideSizeType " << slideSizeType() << std::endl;
+ out << "saveWithFonts " << saveWithFonts() << std::endl;
+ out << "omitTitlePlace " << omitTitlePlace() << std::endl;
+ out << "rightToLeft " << rightToLeft() << std::endl;
+ out << "showComments " << showComments() << std::endl;
+}
+
+// ========== EndDocumentAtom ==========
+
+const unsigned int EndDocumentAtom::id = 1002;
+
+EndDocumentAtom::EndDocumentAtom()
+{
+}
+
+void EndDocumentAtom::dump( std::ostream& out ) const
+{
+ out << "EndDocumentAtom" << std::endl;
+}
+
+
+// ========== FontEntityAtom ==========
+
+const unsigned int FontEntityAtom::id = 4023;
+
+class FontEntityAtom::Private
+{
+public:
+ UString ustring;
+ int charset;
+ int clipPrecision;
+ int quality;
+ int pitchAndFamily;
+
+};
+
+FontEntityAtom::FontEntityAtom()
+{
+ d = new Private;
+ d->charset = 0;
+ d->clipPrecision = 0;
+ d->quality = 0;
+ d->pitchAndFamily = 0;
+}
+
+FontEntityAtom::~FontEntityAtom()
+{
+ delete d;
+}
+
+UString FontEntityAtom::ustring() const
+{
+ return d->ustring;
+}
+
+void FontEntityAtom::setUString( const UString& ustring )
+{
+ d->ustring = ustring;
+}
+
+int FontEntityAtom::charset() const
+{
+ return d->charset;
+}
+
+void FontEntityAtom::setCharset( int charset )
+{
+ d->charset = charset;
+}
+
+int FontEntityAtom::clipPrecision() const
+{
+ return d->clipPrecision;
+}
+
+void FontEntityAtom::setClipPrecision( int clipPrecision)
+{
+ d->clipPrecision = clipPrecision ;
+}
+
+int FontEntityAtom::quality() const
+{
+ return d->quality;
+}
+
+void FontEntityAtom::setQuality( int quality )
+{
+ d->quality = quality;
+}
+
+int FontEntityAtom::pitchAndFamily() const
+{
+ return d->pitchAndFamily;
+}
+
+void FontEntityAtom::setPitchAndFamily( int pitchAndFamily )
+{
+ d->pitchAndFamily = pitchAndFamily;
+}
+
+void FontEntityAtom::setData( unsigned , const unsigned char* data )
+{
+
+ UString str;
+ for( unsigned k=0; k<32; k++ )
+ {
+ unsigned uchar = readU16( data + k*2 );
+ str.append( UString(uchar) );
+ }
+ setUString( str );
+ setCharset( data[64] );
+ setClipPrecision( data[65] );
+ setQuality( data[66] );
+ setPitchAndFamily( data[67] );
+}
+
+void FontEntityAtom::dump( std::ostream& out ) const
+{
+ out << "FontEntityAtom" << std::endl;
+ out << "String : [" << ustring() << "]" << std::endl;
+ out << "Charset " << charset() << std::endl;
+ out << "ClipPrecision " << clipPrecision() << std::endl;
+ out << "Quality " << quality() << std::endl;
+ out << "PitchAndFamily " << pitchAndFamily() << std::endl;
+}
+
+// ========== TextCharsAtom ==========
+
+const unsigned int TextCharsAtom::id = 4000;
+
+
+class TextCharsAtom::Private
+{
+public:
+ std::vector<unsigned> index;
+ std::vector<UString> ustring;
+};
+
+TextCharsAtom::TextCharsAtom()
+{
+ d = new Private;
+}
+
+TextCharsAtom::~TextCharsAtom()
+{
+ delete d;
+}
+
+unsigned TextCharsAtom::listSize() const
+{
+ return d->ustring.size();
+}
+
+UString TextCharsAtom::strValue( unsigned index ) const
+{
+ return d->ustring[index];
+}
+
+void TextCharsAtom::setText( UString ustring )
+{
+ d->ustring.push_back( ustring );
+}
+
+void TextCharsAtom::setData( unsigned size, const unsigned char* data )
+{
+ UString tempStr;
+ int index = 0;
+
+ for( unsigned k=0; k<((0.5*size) + 1); k++ )
+ {
+ unsigned uchar = readU16( data + k*2 );
+ if ( (uchar == 0x0b) | (uchar == 0x0d) | (k == 0.5*size) )
+ {
+ setText(tempStr);
+ index++;
+ tempStr = "";
+ }
+ else
+ tempStr.append( UString(uchar) );
+
+ if ( ( uchar & 0xff00 ) == 0xf000 )
+ { // handle later
+ std::cout << "got a symbol at " << k << "th character" << std::endl;
+ }
+
+ }
+}
+
+void TextCharsAtom::dump( std::ostream& out ) const
+{
+ out << "TextCharsAtom" << std::endl;
+ out << "listSize " << listSize() << std::endl;
+
+ for (uint i=0; i<listSize() ; i++)
+ {
+ out << "String " << i << " [" << strValue(i) << "]" << std::endl;
+ }
+
+}
+
+
+// ========== GuideAtom ==========
+
+const unsigned int GuideAtom::id = 1019;
+
+class GuideAtom::Private
+{
+public:
+ int type;
+ int pos;
+};
+
+GuideAtom::GuideAtom ()
+{
+ d = new Private;
+ d->type = 0;
+ d->pos = 0;
+}
+
+GuideAtom::~GuideAtom ()
+{
+ delete d;
+}
+
+int GuideAtom::type() const
+{
+ return d->type;
+}
+
+void GuideAtom::setType(int type)
+{
+ d->type= type;
+}
+
+int GuideAtom::pos() const
+{
+ return d->pos;
+}
+
+void GuideAtom::setPos(int pos)
+{
+ d->pos= pos;
+}
+
+void GuideAtom::setData( unsigned , const unsigned char* data )
+{
+ setType( readS32( data + 0 ) );
+ setPos( readS32( data + 4 ) );
+}
+
+void GuideAtom::dump( std::ostream& out ) const
+{
+ out << "GuideAtom" << std::endl;
+ out << "type " << type() << std::endl;
+ out << "pos " << pos() << std::endl;
+}
+
+
+// ========== SSlideLayoutAtom ==========
+
+const unsigned int SSlideLayoutAtom::id = 1015;
+
+class SSlideLayoutAtom ::Private
+{
+public:
+ int geom;
+ int placeholderId;
+};
+
+SSlideLayoutAtom::SSlideLayoutAtom ()
+{
+ d = new Private;
+ d->geom = 0;
+ d->placeholderId = 0;
+}
+
+SSlideLayoutAtom::~SSlideLayoutAtom ()
+{
+ delete d;
+}
+
+int SSlideLayoutAtom::geom() const
+{
+ return d->geom;
+}
+
+void SSlideLayoutAtom::setGeom(int geom)
+{
+ d->geom= geom;
+}
+
+int SSlideLayoutAtom::placeholderId() const
+{
+ return d->placeholderId;
+}
+
+void SSlideLayoutAtom::setPlaceholderId(int placeholderId)
+{
+ d->placeholderId= placeholderId;
+}
+
+void SSlideLayoutAtom ::setData( unsigned , const unsigned char* data )
+{
+ setGeom( readS32( data + 0 ) );
+ setPlaceholderId( data [4] );
+}
+
+void SSlideLayoutAtom ::dump( std::ostream& out ) const
+{
+ out << "SSlideLayoutAtom" << std::endl;
+ out << "geom " << geom() << std::endl;
+ out << "placeholderId " << placeholderId() << std::endl;
+}
+
+// ========== ExLinkAtom ==========
+
+const unsigned int ExLinkAtom::id = 4049;
+
+class ExLinkAtom ::Private
+{
+public:
+ int exObjId;
+ int flags;
+ int unavailable;
+};
+
+ExLinkAtom::ExLinkAtom ()
+{
+ d = new Private;
+ d->exObjId = 0;
+ d->flags = 0;
+ d->unavailable = 0;
+}
+
+ExLinkAtom::~ExLinkAtom ()
+{
+ delete d;
+}
+
+int ExLinkAtom::exObjId() const
+{
+ return d->exObjId;
+}
+
+void ExLinkAtom::setExObjId(int exObjId)
+{
+ d->exObjId= exObjId;
+}
+
+int ExLinkAtom::flags() const
+{
+ return d->flags;
+}
+
+void ExLinkAtom::setFlags(int flags)
+{
+ d->flags= flags;
+}
+
+int ExLinkAtom::unavailable() const
+{
+ return d->unavailable;
+}
+
+void ExLinkAtom::setUnavailable(int unavailable)
+{
+ d->unavailable= unavailable;
+}
+
+void ExLinkAtom ::setData( unsigned , const unsigned char* data )
+{
+ setExObjId( readU32( data + 0 ) );
+ setFlags( readU16( data + 4 ) );
+ setUnavailable( data [6] );
+
+}
+
+void ExLinkAtom ::dump( std::ostream& out ) const
+{
+ out << "ExLinkAtom" << std::endl;
+ out << "exObjId " << exObjId() << std::endl;
+ out << "flags " << flags() << std::endl;
+ out << "unavailable " << unavailable() << std::endl;
+}
+
+// ========== NotesAtom ==========
+
+const unsigned int NotesAtom::id = 1009;
+
+class NotesAtom ::Private
+{
+public:
+ int slideId;
+ int flags;
+};
+
+NotesAtom::NotesAtom ()
+{
+ d = new Private;
+ d->slideId = 0;
+ d->flags = 0;
+}
+
+NotesAtom::~NotesAtom ()
+{
+ delete d;
+}
+
+int NotesAtom::slideId() const
+{
+ return d->slideId;
+}
+
+void NotesAtom::setSlideId(int slideId)
+{
+ d->slideId= slideId;
+}
+
+int NotesAtom::flags() const
+{
+ return d->flags;
+}
+
+void NotesAtom::setFlags(int flags)
+{
+ d->flags= flags;
+}
+
+void NotesAtom ::setData( unsigned , const unsigned char* data )
+{
+ setSlideId( readS32( data + 0 ) );
+ setFlags( readU16( data + 4 ) );
+}
+
+void NotesAtom ::dump( std::ostream& out ) const
+{
+ out << "NotesAtom" << std::endl;
+ out << "slideId " << slideId() << std::endl;
+ out << "flags " << flags() << std::endl;
+}
+
+
+// ========== ExObjListAtom ==========
+
+const unsigned int ExObjListAtom::id = 1034;
+
+class ExObjListAtom ::Private
+{
+public:
+ int objectIdSeed;
+};
+
+ExObjListAtom::ExObjListAtom ()
+{
+ d = new Private;
+ d->objectIdSeed = 0;
+}
+
+ExObjListAtom::~ExObjListAtom ()
+{
+ delete d;
+}
+
+int ExObjListAtom::objectIdSeed() const
+{
+ return d->objectIdSeed;
+}
+
+void ExObjListAtom::setObjectIdSeed(int objectIdSeed)
+{
+ d->objectIdSeed= objectIdSeed;
+}
+
+void ExObjListAtom ::setData( unsigned , const unsigned char* data )
+{ // check later for valid value
+ setObjectIdSeed( readU32( data + 0 ) );
+}
+
+void ExObjListAtom ::dump( std::ostream& out ) const
+{
+ out << "ExObjListAtom" << std::endl;
+ out << "objectIdSeed " << objectIdSeed() << std::endl;
+}
+
+
+// ========== ExEmbedAtom ==========
+
+const unsigned int ExEmbedAtom::id = 4045;
+
+class ExEmbedAtom ::Private
+{
+public:
+ int followColorScheme;
+ int cantLockServerB;
+ int noSizeToServerB;
+ int isTable;
+};
+
+ExEmbedAtom::ExEmbedAtom ()
+{
+ d = new Private;
+ d->followColorScheme = 0;
+ d->cantLockServerB = 0;
+ d->noSizeToServerB = 0;
+ d->isTable = 0;
+}
+
+ExEmbedAtom::~ExEmbedAtom ()
+{
+ delete d;
+}
+
+int ExEmbedAtom::followColorScheme() const
+{
+ return d->followColorScheme;
+}
+
+void ExEmbedAtom::setFollowColorScheme(int followColorScheme)
+{
+ d->followColorScheme= followColorScheme;
+}
+
+int ExEmbedAtom::cantLockServerB() const
+{
+ return d->cantLockServerB;
+}
+
+void ExEmbedAtom::setCantLockServerB(int cantLockServerB)
+{
+ d->cantLockServerB= cantLockServerB;
+}
+
+int ExEmbedAtom::noSizeToServerB() const
+{
+ return d->noSizeToServerB;
+}
+
+void ExEmbedAtom::setNoSizeToServerB(int noSizeToServerB)
+{
+ d->noSizeToServerB= noSizeToServerB;
+}
+
+int ExEmbedAtom::isTable() const
+{
+ return d->isTable;
+}
+
+void ExEmbedAtom::setIsTable(int isTable)
+{
+ d->isTable= isTable;
+}
+
+void ExEmbedAtom ::setData( unsigned , const unsigned char* data )
+{
+ setFollowColorScheme( readS32( data + 0 ) );
+ setCantLockServerB( data [4] );
+ setNoSizeToServerB( data[5] );
+ setIsTable( data[6] );
+}
+
+void ExEmbedAtom ::dump( std::ostream& out ) const
+{
+ out << "ExEmbedAtom" << std::endl;
+ out << "followColorScheme " << followColorScheme() << std::endl;
+ out << "cantLockServerB " << cantLockServerB() << std::endl;
+ out << "noSizeToServerB " << noSizeToServerB() << std::endl;
+ out << "isTable " << isTable() << std::endl;
+}
+
+// ========== ExOleObjAtom ==========
+
+const unsigned int ExOleObjAtom::id = 4035;
+
+class ExOleObjAtom ::Private
+{
+public:
+ int drawAspect;
+ int type;
+ int objID;
+ int subType;
+ int objStgDataRef;
+ int isBlank;
+};
+
+ExOleObjAtom::ExOleObjAtom ()
+{
+ d = new Private;
+ d->drawAspect = 0;
+ d->type = 0;
+ d->objID = 0;
+ d->subType = 0;
+ d->objStgDataRef = 0;
+ d->isBlank = 0;
+}
+
+ExOleObjAtom::~ExOleObjAtom ()
+{
+ delete d;
+}
+
+int ExOleObjAtom::drawAspect() const
+{
+ return d->drawAspect;
+}
+
+void ExOleObjAtom::setDrawAspect(int drawAspect)
+{
+ d->drawAspect= drawAspect;
+}
+
+int ExOleObjAtom::type() const
+{
+ return d->type;
+}
+
+void ExOleObjAtom::setType(int type)
+{
+ d->type= type;
+}
+
+int ExOleObjAtom::objID() const
+{
+ return d->objID;
+}
+
+void ExOleObjAtom::setObjID(int objID)
+{
+ d->objID= objID;
+}
+
+int ExOleObjAtom::subType() const
+{
+ return d->subType;
+}
+
+void ExOleObjAtom::setSubType(int subType)
+{
+ d->subType= subType;
+}
+
+int ExOleObjAtom::objStgDataRef() const
+{
+ return d->objStgDataRef;
+}
+
+void ExOleObjAtom::setObjStgDataRef(int objStgDataRef)
+{
+ d->objStgDataRef= objStgDataRef;
+}
+
+int ExOleObjAtom::isBlank() const
+{
+ return d->isBlank;
+}
+
+void ExOleObjAtom::setIsBlank(int isBlank)
+{
+ d->isBlank= isBlank;
+}
+
+void ExOleObjAtom ::setData( unsigned , const unsigned char* data )
+{
+ setDrawAspect( readU32( data + 0 ) );
+ setType( readS32( data + 4 ) );
+ setObjID( readS32( data + 8 ) );
+ setSubType( readS32( data + 12 ) );
+ setObjStgDataRef( readS32( data + 16 ) );
+ setIsBlank( data[20] );
+}
+
+void ExOleObjAtom ::dump( std::ostream& out ) const
+{
+ out << "ExOleObjAtom" << std::endl;
+ out << "drawAspect " << drawAspect() << std::endl;
+ out << "type " << type() << std::endl;
+ out << "objID " << objID() << std::endl;
+ out << "subType " << subType() << std::endl;
+ out << "objID " << objID() << std::endl;
+ out << "objStgDataRef " << objStgDataRef() << std::endl;
+ out << "isBlank " << isBlank() << std::endl;
+}
+
+// ========== ExHyperlinkAtom ==========
+
+const unsigned int ExHyperlinkAtom::id = 4051;
+
+class ExHyperlinkAtom ::Private
+{
+public:
+ int objID;
+};
+
+ExHyperlinkAtom ::ExHyperlinkAtom ()
+{
+ d = new Private;
+ d->objID = 0;
+}
+
+ExHyperlinkAtom ::~ExHyperlinkAtom ()
+{
+ delete d;
+}
+
+int ExHyperlinkAtom ::objID() const
+{
+ return d->objID;
+}
+
+void ExHyperlinkAtom ::setObjID(int objID)
+{
+ d->objID = objID;
+}
+
+void ExHyperlinkAtom::setData( unsigned , const unsigned char* data )
+{
+ setObjID( readU32( data + 0 ) );
+}
+
+void ExHyperlinkAtom ::dump( std::ostream& out ) const
+{
+ out << "ExHyperlinkAtom" << std::endl;
+ out << "objID " << objID() << std::endl;
+}
+
+
+// ========== PersistIncrementalBlockAtom ==========
+
+const unsigned int PersistIncrementalBlockAtom::id = 6002;
+
+class PersistIncrementalBlockAtom::Private
+{
+public:
+ std::vector<unsigned long> references;
+ std::vector<unsigned long> offsets;
+};
+
+PersistIncrementalBlockAtom::PersistIncrementalBlockAtom()
+{
+ d = new Private;
+}
+
+PersistIncrementalBlockAtom::~PersistIncrementalBlockAtom()
+{
+ delete d;
+}
+
+unsigned PersistIncrementalBlockAtom::entryCount() const
+{
+ return d->references.size();
+}
+
+unsigned long PersistIncrementalBlockAtom::reference( unsigned index ) const
+{
+ unsigned long r = 0;
+ if( index < d->references.size() )
+ r = d->references[index];
+ return r;
+}
+
+unsigned long PersistIncrementalBlockAtom::offset( unsigned index ) const
+{
+ unsigned long ofs = 0;
+ if( index < d->offsets.size() )
+ ofs = d->offsets[index];
+ return ofs;
+}
+
+void PersistIncrementalBlockAtom ::setData( unsigned size, const unsigned char* data )
+{
+ d->references.clear();
+ d->offsets.clear();
+
+ unsigned ofs = 0;
+ while( ofs < size )
+ {
+ long k = readU32( data+ ofs );
+ unsigned count = k>>20;
+ unsigned start = k&0xfffff;
+ ofs += 4;
+ for( unsigned c=0; c < count; c++, ofs+=4 )
+ {
+ if( ofs >= size ) break;
+ long of = readU32( data + ofs );
+ d->references.push_back( start+c );
+ d->offsets.push_back( of );
+ }
+ }
+}
+
+void PersistIncrementalBlockAtom ::dump( std::ostream& out ) const
+{
+ out << "PersistIncrementalBlockAtom" << std::endl;
+ for( unsigned i = 0; i < entryCount(); i++ )
+ out << " Ref #" << reference(i) << " at offset " << offset(i) << std::endl;
+}
+
+
+// ========== HeadersFootersAtom ==========
+
+const unsigned int HeadersFootersAtom::id = 4058;
+
+class HeadersFootersAtom ::Private
+{
+public:
+ int formatId;
+ int flags;
+};
+
+HeadersFootersAtom::HeadersFootersAtom ()
+{
+ d = new Private;
+ d->formatId = 0;
+ d->flags = 0;
+}
+
+HeadersFootersAtom::~HeadersFootersAtom ()
+{
+ delete d;
+}
+
+int HeadersFootersAtom::formatId() const
+{
+ return d->formatId;
+}
+
+void HeadersFootersAtom::setFormatId(int formatId)
+{
+ d->formatId= formatId;
+}
+
+int HeadersFootersAtom::flags() const
+{
+ return d->flags;
+}
+
+void HeadersFootersAtom::setFlags(int flags)
+{
+ d->flags= flags;
+}
+
+void HeadersFootersAtom::setData( unsigned , const unsigned char* data )
+{
+ setFormatId( readS16( data + 0 ) );
+ setFlags( readU16( data + 2 ) );
+}
+
+void HeadersFootersAtom::dump( std::ostream& out ) const
+{
+ out << "HeadersFootersAtom" << std::endl;
+ out << "formatId " << formatId() << std::endl;
+ out << "flags " << flags() << std::endl;
+}
+
+
+// ========== ColorSchemeAtom ==========
+
+const unsigned int ColorSchemeAtom::id = 2032;
+
+class ColorSchemeAtom ::Private
+{
+public:
+ int background;
+ int textAndLines;
+ int shadows;
+ int titleText;
+ int fills;
+ int accent;
+ int accentAndHyperlink;
+ int accentAndFollowedHyperlink;
+
+};
+
+ColorSchemeAtom::ColorSchemeAtom ()
+{
+ d = new Private;
+ d->background = 0 ;
+ d->textAndLines = 0;
+ d->shadows = 0 ;
+ d->titleText = 0 ;
+ d->fills = 0;
+ d->accent = 0;
+ d->accentAndHyperlink = 0;
+ d->accentAndFollowedHyperlink = 0;
+}
+
+
+ColorSchemeAtom::~ColorSchemeAtom ()
+{
+ delete d;
+}
+
+int ColorSchemeAtom::background() const
+{
+ return d->background;
+}
+
+void ColorSchemeAtom::setBackground( int background )
+{
+ d->background = background;
+}
+
+int ColorSchemeAtom::textAndLines() const
+{
+ return d->textAndLines;
+}
+
+void ColorSchemeAtom::setTextAndLines( int textAndLines )
+{
+ d->textAndLines = textAndLines;
+}
+
+int ColorSchemeAtom::shadows() const
+{
+ return d->shadows;
+}
+
+void ColorSchemeAtom::setShadows( int shadows )
+{
+ d->shadows = shadows;
+}
+
+int ColorSchemeAtom::titleText() const
+{
+ return d->titleText;
+}
+
+void ColorSchemeAtom::setTitleText( int titleText )
+{
+ d->titleText = titleText;
+}
+
+int ColorSchemeAtom::fills() const
+{
+ return d->fills;
+}
+
+void ColorSchemeAtom::setFills( int fills )
+{
+ d->fills = fills;
+}
+
+int ColorSchemeAtom::accent() const
+{
+ return d->accent;
+}
+
+void ColorSchemeAtom::setAccent( int accent )
+{
+ d->accent = accent;
+}
+
+int ColorSchemeAtom::accentAndHyperlink() const
+{
+ return d->accentAndHyperlink;
+}
+
+void ColorSchemeAtom::setAccentAndHyperlink ( int accentAndHyperlink )
+{
+ d->accentAndHyperlink = accentAndHyperlink;
+}
+
+int ColorSchemeAtom::accentAndFollowedHyperlink() const
+{
+ return d->accentAndFollowedHyperlink;
+}
+
+void ColorSchemeAtom::setAccentAndFollowedHyperlink( int accentAndFollowedHyperlink )
+{
+ d->accentAndFollowedHyperlink = accentAndFollowedHyperlink;
+}
+
+void ColorSchemeAtom ::setData( unsigned , const unsigned char* data )
+{
+ setBackground( readS32( data + 0 ) );
+ setTextAndLines( readU32( data + 4 ) );
+ setShadows( readU32( data + 8 ) );
+ setTitleText( readU32( data + 12 ) );
+ setFills( readU32( data + 16 ) );
+ setAccent( readU32( data + 20 ) );
+ setAccentAndHyperlink( readU32( data + 24 ) );
+ setAccentAndFollowedHyperlink( readU32( data + 28 ) );
+
+}
+
+void ColorSchemeAtom ::dump( std::ostream& out ) const
+{
+ out << "ColorSchemeAtom" << std::endl;
+ out << "background " << background() << std::endl;
+ out << " R " << ( (background() >> 0 ) & 0xff ) ;
+ out << " G " << ( (background() >> 8 ) & 0xff ) ;
+ out << " B " << ( (background() >> 16 ) & 0xff ) ;
+ out << " I " << ( (background() >> 24 ) & 0xff ) << std::endl;
+ out << "text and Lines " << textAndLines() << std::endl;
+ out << " R " << ( ( textAndLines() >> 0 ) & 0xff ) ;
+ out << " G " << ( ( textAndLines() >> 8 ) & 0xff ) ;
+ out << " B " << ( ( textAndLines() >> 16 ) & 0xff ) ;
+ out << " I " << ( ( textAndLines() >> 24 ) & 0xff ) << std::endl;
+ out << "shadows " << shadows() << std::endl;
+ out << " R " << ( ( shadows() >> 0 ) & 0xff ) ;
+ out << " G " << ( ( shadows() >> 8 ) & 0xff ) ;
+ out << " B " << ( ( shadows() >> 16 ) & 0xff ) ;
+ out << " I " << ( ( shadows() >> 24 ) & 0xff ) << std::endl;
+ out << "titleText " << titleText() << std::endl;
+ out << " R " << ( ( titleText() >> 0 ) & 0xff ) ;
+ out << " G " << ( ( titleText() >> 8 ) & 0xff ) ;
+ out << " B " << ( ( titleText() >> 16 ) & 0xff ) ;
+ out << " I " << ( ( titleText() >> 24 ) & 0xff ) << std::endl;
+ out << "fills " << fills() << std::endl;
+ out << " R " << ( ( fills() >> 0 ) & 0xff ) ;
+ out << " G " << ( ( fills() >> 8 ) & 0xff ) ;
+ out << " B " << ( ( fills() >> 16 ) & 0xff ) ;
+ out << " I " << ( ( fills() >> 24 ) & 0xff ) << std::endl;
+ out << "accent " << accent() << std::endl;
+ out << " R " << ( ( accent() >> 0 ) & 0xff ) ;
+ out << " G " << ( ( accent() >> 8 ) & 0xff ) ;
+ out << " B " << ( ( accent() >> 16 ) & 0xff ) ;
+ out << " I " << ( ( accent() >> 24 ) & 0xff ) << std::endl;
+ out << "accentAndHyperlink " << accentAndHyperlink() << std::endl;
+ out << " R " << ( ( accentAndHyperlink() >> 0 ) & 0xff ) ;
+ out << " G " << ( ( accentAndHyperlink() >> 8 ) & 0xff ) ;
+ out << " B " << ( ( accentAndHyperlink() >> 16 ) & 0xff ) ;
+ out << " I " << ( ( accentAndHyperlink() >> 24 ) & 0xff ) << std::endl;
+ out << "accentAndFollowedHyperlink " << accentAndFollowedHyperlink() << std::endl;
+ out << " R " << ( ( accentAndFollowedHyperlink() >> 0 ) & 0xff ) ;
+ out << " G " << ( ( accentAndFollowedHyperlink() >> 8 ) & 0xff ) ;
+ out << " B " << ( ( accentAndFollowedHyperlink() >> 16 ) & 0xff ) ;
+ out << " I " << ( ( accentAndFollowedHyperlink() >> 24 ) & 0xff ) << std::endl;
+}
+
+
+// ========== CurrentUserAtom ==========
+
+const unsigned int CurrentUserAtom::id = 4086;
+
+class CurrentUserAtom ::Private
+{
+public:
+ int size;
+ int magic;
+ int offsetToCurrentEdit;
+ int lenUserName;
+ int docFileVersion;
+ int majorVersion;
+ int minorVersion;
+};
+
+CurrentUserAtom::CurrentUserAtom ()
+{
+ d = new Private;
+ d->size = 0 ;
+ d->magic = 0 ;
+ d->offsetToCurrentEdit = 0;
+ d->lenUserName = 0 ;
+ d->docFileVersion = 0 ;
+ d->majorVersion = 0;
+ d->minorVersion = 0;
+}
+
+CurrentUserAtom::~CurrentUserAtom ()
+{
+ delete d;
+}
+
+int CurrentUserAtom::size() const
+{
+ return d->size;
+}
+
+void CurrentUserAtom::setSize( int size )
+{
+ d->size = size;
+}
+
+int CurrentUserAtom::magic() const
+{
+ return d->magic;
+}
+
+void CurrentUserAtom::setMagic( int magic )
+{
+ d->magic = magic;
+}
+
+int CurrentUserAtom::offsetToCurrentEdit() const
+{
+ return d->offsetToCurrentEdit;
+}
+
+void CurrentUserAtom::setOffsetToCurrentEdit( int offsetToCurrentEdit )
+{
+ d->offsetToCurrentEdit = offsetToCurrentEdit;
+}
+
+int CurrentUserAtom::lenUserName() const
+{
+ return d->lenUserName;
+}
+
+void CurrentUserAtom::setLenUserName( int lenUserName )
+{
+ d->lenUserName = lenUserName;
+}
+
+int CurrentUserAtom::docFileVersion() const
+{
+ return d->docFileVersion;
+}
+
+void CurrentUserAtom::setDocFileVersion( int docFileVersion )
+{
+ d->docFileVersion = docFileVersion;
+}
+
+int CurrentUserAtom::majorVersion() const
+{
+ return d->majorVersion;
+}
+
+void CurrentUserAtom::setMajorVersion( int majorVersion )
+{
+ d->majorVersion = majorVersion;
+}
+
+int CurrentUserAtom::minorVersion() const
+{
+ return d->minorVersion;
+}
+
+void CurrentUserAtom::setMinorVersion( int minorVersion )
+{
+ d->minorVersion = minorVersion;
+}
+
+void CurrentUserAtom ::setData( unsigned , const unsigned char* data )
+{
+ setSize( readU32( data + 0 ) );
+ setMagic( readU32( data + 4 ) );
+ setOffsetToCurrentEdit( readU32( data + 8 ) );
+ setLenUserName( readU16( data + 12 ) );
+ setDocFileVersion( readU32( data + 14 ) );
+ setMajorVersion( data[18] );
+ setMinorVersion( data[19] );
+}
+
+void CurrentUserAtom ::dump( std::ostream& out ) const
+{
+ out << " CurrentUserAtom" << std::endl;
+ out << " size " << size() << std::endl;
+ out << " magic " << magic() << std::endl;
+ out << " offsetToCurrentEdit " << offsetToCurrentEdit() << std::endl;
+ out << " lenUserName " << lenUserName() << std::endl;
+ out << " docFileVersion " << docFileVersion() << std::endl;
+ out << " majorVersion " << majorVersion() << std::endl;
+ out << " minorVersion " << minorVersion() << std::endl;
+}
+
+
+// ========== UserEditAtom ==========
+
+const unsigned int UserEditAtom::id = 4085;
+
+class UserEditAtom::Private
+{
+public:
+ int lastSlideId;
+ int majorVersion;
+ int minorVersion;
+ unsigned long offsetLastEdit;
+ unsigned long offsetPersistDir;
+ unsigned long documentRef;
+};
+
+UserEditAtom::UserEditAtom()
+{
+ d = new Private;
+ d->lastSlideId = 0;
+ d->majorVersion = 0;
+ d->minorVersion = 0;
+}
+
+UserEditAtom::~UserEditAtom()
+{
+ delete d;
+}
+
+int UserEditAtom::lastSlideId() const
+{
+ return d->lastSlideId;
+}
+
+void UserEditAtom::setLastSlideId( int id )
+{
+ d->lastSlideId = id;
+}
+
+int UserEditAtom::majorVersion() const
+{
+ return d->majorVersion;
+}
+
+void UserEditAtom::setMajorVersion( int majorVersion )
+{
+ d->majorVersion = majorVersion;
+}
+
+int UserEditAtom::minorVersion() const
+{
+ return d->minorVersion;
+}
+
+void UserEditAtom::setMinorVersion( int minorVersion )
+{
+ d->minorVersion = minorVersion;
+}
+
+unsigned long UserEditAtom::offsetLastEdit() const
+{
+ return d->offsetLastEdit;
+}
+
+void UserEditAtom::setOffsetLastEdit( unsigned long ofs )
+{
+ d->offsetLastEdit = ofs;
+}
+
+unsigned long UserEditAtom::offsetPersistDir() const
+{
+ return d->offsetPersistDir;
+}
+
+void UserEditAtom::setOffsetPersistDir( unsigned long ofs ) const
+{
+ d->offsetPersistDir = ofs;
+}
+
+unsigned long UserEditAtom::documentRef() const
+{
+ return d->documentRef;
+}
+
+void UserEditAtom::setDocumentRef( unsigned long ref ) const
+{
+ d->documentRef = ref;
+}
+
+void UserEditAtom::setData( unsigned , const unsigned char* data )
+{
+ setLastSlideId( readU32( data + 0 ) );
+ setMinorVersion( readU16( data + 4 ) );
+ setMajorVersion( readU16( data + 6 ) );
+ setOffsetLastEdit( readU32( data + 8 ) );
+ setOffsetPersistDir( readU32( data + 12 ) );
+ setDocumentRef( readU32( data + 16 ) );
+}
+
+void UserEditAtom::dump( std::ostream& out ) const
+{
+ out << " UserEditAtom" << std::endl;
+ out << " LastSlideID " << lastSlideId() << std::endl;
+ out << " MajorVersion " << majorVersion() << std::endl;
+ out << " MinorVersion " << minorVersion() << std::endl;
+ out << " Offset Last Edit " << offsetLastEdit() << std::endl;
+ out << " Offset Persist Dir " << offsetPersistDir() << std::endl;
+ out << " Document Ref " << documentRef() << std::endl;
+}
+
+// ========== TextBookmarkAtom ==========
+
+const unsigned int TextBookmarkAtom::id = 4007;
+
+class TextBookmarkAtom::Private
+{
+public:
+ int begin;
+ int end;
+ int bookmarkID;
+};
+
+TextBookmarkAtom::TextBookmarkAtom()
+{
+ d = new Private;
+ d->begin = 0;
+ d->end = 0;
+ d->bookmarkID = 0;
+}
+
+TextBookmarkAtom::~TextBookmarkAtom()
+{
+ delete d;
+}
+
+int TextBookmarkAtom::begin() const
+{
+ return d->begin;
+}
+
+void TextBookmarkAtom::setBegin( int begin )
+{
+ d->begin = begin;
+}
+
+int TextBookmarkAtom::end() const
+{
+ return d->end;
+}
+
+void TextBookmarkAtom::setEnd( int end )
+{
+ d->end = end;
+}
+
+int TextBookmarkAtom::bookmarkID() const
+{
+ return d->bookmarkID;
+}
+
+void TextBookmarkAtom::setBookmarkID( int bookmarkID )
+{
+ d->bookmarkID = bookmarkID;
+}
+
+void TextBookmarkAtom::setData( unsigned , const unsigned char* data )
+{
+ setBegin( readU32( data + 0 ) );
+ setEnd( readU32( data + 4 ) );
+ setBookmarkID( readU32( data + 8 ) );
+}
+
+void TextBookmarkAtom::dump( std::ostream& out ) const
+{
+ out << "TextBookmarkAtom" << std::endl;
+ out << "begin " << begin() << std::endl;
+ out << "end " << end() << std::endl;
+ out << "bookmarkID " << bookmarkID() << std::endl;
+}
+
+// ========== BookmarkEntityAtom ==========
+
+const unsigned int BookmarkEntityAtom::id = 4048;
+
+class BookmarkEntityAtom::Private
+{
+public:
+ int bookmarkID;
+ int bookmarkName;
+};
+
+BookmarkEntityAtom::BookmarkEntityAtom()
+{
+ d = new Private;
+ d->bookmarkID = 0;
+ d->bookmarkName = 0;
+}
+
+BookmarkEntityAtom::~BookmarkEntityAtom()
+{
+ delete d;
+}
+
+int BookmarkEntityAtom::bookmarkID() const
+{
+ return d->bookmarkID;
+}
+
+void BookmarkEntityAtom::setBookmarkID( int bookmarkID )
+{
+ d->bookmarkID = bookmarkID;
+}
+
+int BookmarkEntityAtom::bookmarkName() const
+{
+ return d->bookmarkName;
+}
+
+void BookmarkEntityAtom::setBookmarkName( int bookmarkName )
+{
+ d->bookmarkName = bookmarkName;
+}
+
+void BookmarkEntityAtom::setData( unsigned , const unsigned char* data )
+{
+ setBookmarkID( readU32( data + 0 ) );
+ setBookmarkName( readU16( data + 4 ) );
+}
+
+void BookmarkEntityAtom::dump( std::ostream& out ) const
+{
+ out << "BookmarkEntityAtom" << std::endl;
+ out << "bookmarkID " << bookmarkID() << std::endl;
+ out << "bookmarkName " << bookmarkName() << std::endl;
+}
+
+// ========== SSDocInfoAtom ==========
+
+const unsigned int SSDocInfoAtom::id = 1025;
+
+class SSDocInfoAtom::Private
+{
+public:
+ int penColorRed;
+ int penColorGreen;
+ int penColorBlue;
+ int penColorIndex;
+ int restartTime;
+ int startSlide;
+ int endSlide;
+ int namedShow;
+ int flags;
+};
+
+SSDocInfoAtom::SSDocInfoAtom()
+{
+ d = new Private;
+ d->penColorRed = 0;
+ d->penColorGreen = 0;
+ d->penColorBlue = 0;
+ d->penColorIndex = 0;
+ d->restartTime = 0;
+ d->startSlide = 0;
+ d->endSlide = 0;
+ d->namedShow = 0;
+ d->flags = 0;
+}
+
+SSDocInfoAtom::~SSDocInfoAtom()
+{
+ delete d;
+}
+
+int SSDocInfoAtom::penColorRed() const
+{
+ return d->penColorRed;
+}
+
+void SSDocInfoAtom::setPenColorRed( int penColorRed )
+{
+ d->penColorRed = penColorRed;
+}
+
+int SSDocInfoAtom::penColorGreen() const
+{
+ return d->penColorGreen;
+}
+
+void SSDocInfoAtom::setPenColorGreen( int penColorGreen )
+{
+ d->penColorGreen = penColorGreen;
+}
+
+int SSDocInfoAtom::penColorBlue() const
+{
+ return d->penColorBlue;
+}
+
+void SSDocInfoAtom::setPenColorBlue( int penColorBlue )
+{
+ d->penColorBlue = penColorBlue;
+}
+
+int SSDocInfoAtom::penColorIndex() const
+{
+ return d->penColorIndex;
+}
+
+void SSDocInfoAtom::setPenColorIndex( int penColorIndex )
+{
+ d->penColorIndex = penColorIndex;
+}
+
+int SSDocInfoAtom::restartTime() const
+{
+ return d->restartTime;
+}
+
+void SSDocInfoAtom::setRestartTime( int restartTime )
+{
+ d->restartTime = restartTime;
+}
+
+int SSDocInfoAtom::startSlide() const
+{
+ return d->startSlide;
+}
+
+void SSDocInfoAtom::setStartSlide( int startSlide )
+{
+ d->startSlide = startSlide;
+}
+
+int SSDocInfoAtom::endSlide() const
+{
+ return d->endSlide;
+}
+
+void SSDocInfoAtom::setEndSlide( int endSlide )
+{
+ d->endSlide = endSlide;
+}
+
+int SSDocInfoAtom::namedShow() const
+{
+ return d->namedShow;
+}
+
+void SSDocInfoAtom::setNamedShow( int namedShow )
+{
+ d->namedShow = namedShow;
+}
+
+int SSDocInfoAtom::flags() const
+{
+ return d->flags;
+}
+
+void SSDocInfoAtom::setFlags( int flags )
+{
+ d->flags = flags;
+}
+
+void SSDocInfoAtom::setData( unsigned , const unsigned char* data )
+{
+ setPenColorRed( data[0] );
+ setPenColorGreen( data[1] );
+ setPenColorBlue( data[2]);
+ setPenColorIndex( data[3] );
+ setRestartTime( readS32( data + 4 ) );
+ setStartSlide( readS16( data + 8 ) );
+ setEndSlide( readS16( data + 10 ) );
+ setNamedShow( readU16( data + 12 ) ); // 2 bytes repeat 32x
+ setFlags( readU16( data + 76 ) ); // offset correct ?
+}
+
+void SSDocInfoAtom::dump( std::ostream& out ) const
+{
+ out << "UserEditAtom" << std::endl;
+ out << "penColorRed " << penColorRed() << std::endl;
+ out << "penColorGreen " << penColorGreen() << std::endl;
+ out << "penColorBlue " << penColorBlue() << std::endl;
+ out << "penColorIndex " << penColorIndex() << std::endl;
+ out << "restartTime " << restartTime() << std::endl;
+ out << "startSlide " << startSlide() << std::endl;
+ out << "endSlide " << endSlide() << std::endl;
+ out << "namedShow " << namedShow() << std::endl;
+ out << "Flags " << flags() << std::endl;
+}
+
+// ========== SrKinsokuAtom ==========
+
+const unsigned int SrKinsokuAtom::id = 4050;
+
+SrKinsokuAtom::SrKinsokuAtom()
+{
+}
+
+SrKinsokuAtom::~SrKinsokuAtom()
+{
+}
+
+void SrKinsokuAtom::dump( std::ostream& out ) const
+{
+ out << "SrKinsokuAtom - not yet implemented" << std::endl;
+}
+
+// ========== TxMasterStyleAtom ==========
+
+const unsigned int TxMasterStyleAtom::id = 4003;
+
+TxMasterStyleAtom::TxMasterStyleAtom()
+{
+}
+
+TxMasterStyleAtom::~TxMasterStyleAtom()
+{
+}
+
+void TxMasterStyleAtom::dump( std::ostream& out ) const
+{
+ out << "TxMasterStyleAtom - not yet implemented" << std::endl;
+}
+
+// ========== SlideViewInfoAtom ==========
+
+const unsigned int SlideViewInfoAtom::id = 1022;
+
+class SlideViewInfoAtom ::Private
+{
+public:
+ int showGuides;
+ int snapToGrid;
+ int snapToShape;
+};
+
+SlideViewInfoAtom::SlideViewInfoAtom ()
+{
+ d = new Private;
+ d->showGuides = 0;
+ d->snapToGrid = 0;
+ d->snapToShape = 0;
+}
+
+SlideViewInfoAtom::~SlideViewInfoAtom ()
+{
+ delete d;
+}
+
+int SlideViewInfoAtom::showGuides() const
+{
+ return d->showGuides;
+}
+
+void SlideViewInfoAtom::setShowGuides(int showGuides)
+{
+ d->showGuides= showGuides;
+}
+
+int SlideViewInfoAtom::snapToGrid() const
+{
+ return d->snapToGrid;
+}
+
+void SlideViewInfoAtom::setSnapToGrid(int snapToGrid)
+{
+ d->snapToGrid= snapToGrid;
+}
+
+int SlideViewInfoAtom::snapToShape() const
+{
+ return d->snapToShape;
+}
+
+void SlideViewInfoAtom::setSnapToShape(int snapToShape)
+{
+ d->snapToGrid= snapToShape;
+}
+
+void SlideViewInfoAtom ::setData( unsigned , const unsigned char* data )
+{
+ setShowGuides(data[0]);
+ setSnapToGrid(data[1]);
+ setSnapToShape(data[2]);
+}
+
+void SlideViewInfoAtom ::dump( std::ostream& out ) const
+{
+ out << "SlideViewInfoAtom" << std::endl;
+ out << "showGuides " << showGuides() << std::endl;
+ out << "snapToGrid " << snapToGrid() << std::endl;
+ out << "snapToShape " << snapToShape() << std::endl;
+}
+
+// ========== ViewInfoAtom ==========
+
+const unsigned int ViewInfoAtom::id = 1021;
+
+class ViewInfoAtom ::Private
+{
+public:
+ int curScaleXNum;
+ int curScaleXDen;
+ int curScaleYNum;
+ int curScaleYDen;
+ int prevScaleXNum;
+ int prevScaleXDen;
+ int prevScaleYNum;
+ int prevScaleYDen;
+ int viewSizeX;
+ int viewSizeY;
+ int originX;
+ int originY;
+ int varScale;
+ int draftMode;
+ int padding;
+};
+
+ViewInfoAtom::ViewInfoAtom ()
+{
+ d = new Private;
+ d->curScaleXNum = 0;
+ d->curScaleXDen = 0;
+ d->curScaleYNum = 0;
+ d->curScaleYDen = 0;
+ d->prevScaleXNum = 0;
+ d->prevScaleXDen = 0;
+ d->prevScaleYNum = 0;
+ d->prevScaleYDen = 0;
+ d->viewSizeX = 0;
+ d->viewSizeY = 0;
+ d->originX = 0;
+ d->originY = 0;
+ d->varScale = 0;
+ d->draftMode = 0;
+ d->padding = 0;
+}
+
+ViewInfoAtom::~ViewInfoAtom ()
+{
+ delete d;
+}
+
+int ViewInfoAtom::varScale() const
+{
+ return d->varScale;
+}
+
+void ViewInfoAtom::setVarScale(int varScale)
+{
+ d->varScale= varScale;
+}
+
+int ViewInfoAtom::draftMode() const
+{
+ return d->draftMode;
+}
+
+void ViewInfoAtom::setDraftMode(int draftMode)
+{
+ d->draftMode= draftMode;
+}
+
+int ViewInfoAtom::padding() const
+{
+ return d->padding;
+}
+
+void ViewInfoAtom::setPadding(int padding)
+{
+ d->padding= padding;
+}
+
+int ViewInfoAtom::viewSizeX() const
+{
+ return d->viewSizeX;
+}
+
+void ViewInfoAtom::setViewSizeX(int viewSizeX)
+{
+ d->viewSizeX= viewSizeX;
+}
+
+int ViewInfoAtom::viewSizeY() const
+{
+ return d->viewSizeY;
+}
+
+void ViewInfoAtom::setViewSizeY(int viewSizeY)
+{
+ d->viewSizeY= viewSizeY;
+}
+
+int ViewInfoAtom::originX() const
+{
+ return d->originX;
+}
+
+void ViewInfoAtom::setOriginX(int originX)
+{
+ d->originX= originX;
+}
+
+int ViewInfoAtom::originY() const
+{
+ return d->originY;
+}
+
+void ViewInfoAtom::setOriginY (int originY)
+{
+ d->originY= originY;
+}
+
+int ViewInfoAtom::prevScaleXNum() const
+{
+ return d->prevScaleXNum;
+}
+
+void ViewInfoAtom::setPrevScaleXNum(int prevScaleXNum)
+{
+ d->prevScaleXNum= prevScaleXNum;
+}
+
+int ViewInfoAtom::prevScaleXDen() const
+{
+ return d->prevScaleXDen;
+}
+
+void ViewInfoAtom::setPrevScaleXDen(int prevScaleXDen)
+{
+ d->prevScaleXDen= prevScaleXDen;
+}
+
+int ViewInfoAtom::prevScaleYNum() const
+{
+ return d->prevScaleYNum;
+}
+
+void ViewInfoAtom::setPrevScaleYNum(int prevScaleYNum)
+{
+ d->prevScaleYNum= prevScaleYNum;
+}
+
+int ViewInfoAtom::prevScaleYDen() const
+{
+ return d->prevScaleYDen;
+}
+
+void ViewInfoAtom::setPrevScaleYDen(int prevScaleYDen)
+{
+ d->prevScaleYDen= prevScaleYDen;
+}
+
+int ViewInfoAtom::curScaleXNum() const
+{
+ return d->curScaleXNum;
+}
+
+void ViewInfoAtom::setCurScaleXNum(int curScaleXNum)
+{
+ d->curScaleXNum= curScaleXNum;
+}
+
+int ViewInfoAtom::curScaleXDen() const
+{
+ return d->curScaleXDen;
+}
+
+void ViewInfoAtom::setCurScaleXDen(int curScaleXDen)
+{
+ d->curScaleXDen= curScaleXDen;
+}
+
+int ViewInfoAtom::curScaleYNum() const
+{
+ return d->curScaleYNum;
+}
+
+void ViewInfoAtom::setCurScaleYNum(int curScaleYNum)
+{
+ d->curScaleYNum= curScaleYNum;
+}
+
+int ViewInfoAtom::curScaleYDen() const
+{
+ return d->curScaleYDen;
+}
+
+void ViewInfoAtom::setCurScaleYDen(int curScaleYDen)
+{
+ d->curScaleYDen= curScaleYDen;
+}
+
+void ViewInfoAtom ::setData( unsigned , const unsigned char* data )
+{
+ setCurScaleXNum(readS32( data + 0));
+ setCurScaleXDen(readS32( data + 4 ));
+ setCurScaleYNum(readS32( data + 8));
+ setCurScaleYDen(readS32( data + 12 ));
+ setPrevScaleXNum(readS32( data + 16 ));
+ setPrevScaleXDen(readS32( data + 20 ));
+ setPrevScaleYNum(readS32( data + 24 ));
+ setPrevScaleYDen(readS32( data + 28 ));
+ setViewSizeX(readS32( data + 32 ));
+ setViewSizeY(readS32( data + 36 ));
+ setOriginX(readS32( data + 40 ));
+ setOriginY(readS32( data + 44));
+ setVarScale(data[48]);
+ setDraftMode(data[49]);
+ setPadding(readU16( data + 50 ));
+}
+
+void ViewInfoAtom ::dump( std::ostream& out ) const
+{
+ out << "ViewInfoAtom" << std::endl;
+ out << "curScaleXNum " << curScaleXNum() << std::endl;
+ out << "curScaleXDen " << curScaleXDen() << std::endl;
+ out << "curScaleYNum " << curScaleYNum() << std::endl;
+ out << "curScaleYDen " << curScaleYDen() << std::endl;
+ out << "prevScaleXNum " << prevScaleXNum() << std::endl;
+ out << "prevScaleXDen " << prevScaleXNum() << std::endl;
+ out << "prevScaleYNum " << prevScaleYNum() << std::endl;
+ out << "prevScaleYDen " << prevScaleYNum() << std::endl;
+ out << "viewSizeX " << viewSizeX() << std::endl;
+ out << "viewSizeY " << viewSizeY() << std::endl;
+ out << "originX " << originX() << std::endl;
+ out << "originY " << originY() << std::endl;
+ out << "varScale " << varScale() << std::endl;
+ out << "draftMode " << draftMode() << std::endl;
+ out << "padding " << padding() << std::endl;
+}
+
+// ========== StyleTextPropAtom ==========
+
+const unsigned int StyleTextPropAtom ::id = 4001;
+
+class StyleTextPropAtom::Private
+{
+public:
+ unsigned stringLength;
+ struct PropAtomData
+ {
+ PropAtomData()
+ : charCount(0)
+ , depth(0)
+ , bulletOn(0)
+ , bulletHardFont(0)
+ , bulletHardColor(0)
+ , bulletChar(0)
+ , bulletFont(0)
+ , bulletHeight(0)
+ , bulletColor(0)
+ , align(0)
+ , lineFeed(0)
+ , upperDist(0)
+ , lowerDist(0)
+ , asianLB1(0)
+ , asianLB2(0)
+ , asianLB3(0)
+ , biDi(0)
+ {}
+
+ int charCount;
+ int depth;
+ unsigned bulletOn;
+ unsigned bulletHardFont;
+ unsigned bulletHardColor;
+ unsigned bulletChar;
+ unsigned bulletFont;
+ unsigned bulletHeight;
+ unsigned bulletColor;
+ unsigned align;
+ unsigned lineFeed;
+ int upperDist;
+ int lowerDist;
+ int asianLB1;
+ int asianLB2;
+ int asianLB3;
+ unsigned biDi;
+ };
+ std::vector<PropAtomData> atomData;
+
+ int charMask;
+ int charCount2;
+ int charFlags;
+};
+
+StyleTextPropAtom::StyleTextPropAtom()
+{
+ d = new Private;
+ d->charMask = 0;
+ d->charCount2 = 0;
+ d->charFlags = 0;
+}
+
+StyleTextPropAtom::~StyleTextPropAtom()
+{
+ delete d;
+}
+
+unsigned StyleTextPropAtom::listSize() const
+{
+ return d->atomData.size();
+}
+
+int StyleTextPropAtom::charCount( unsigned index ) const
+{
+ return d->atomData[index].charCount;
+}
+
+int StyleTextPropAtom::depth( unsigned index ) const
+{
+ return d->atomData[index].depth;
+}
+
+int StyleTextPropAtom::bulletOn( unsigned index ) const
+{
+ return d->atomData[index].bulletOn;
+}
+
+int StyleTextPropAtom::bulletHardFont( unsigned index ) const
+{
+ return d->atomData[index].bulletHardFont;
+}
+
+int StyleTextPropAtom::bulletHardColor( unsigned index ) const
+{
+ return d->atomData[index].bulletHardColor;
+}
+
+int StyleTextPropAtom::bulletChar( unsigned index ) const
+{
+ return d->atomData[index].bulletChar;
+}
+
+int StyleTextPropAtom::bulletFont( unsigned index ) const
+{
+ return d->atomData[index].bulletFont;
+}
+
+int StyleTextPropAtom::bulletHeight( unsigned index ) const
+{
+ return d->atomData[index].bulletHeight;
+}
+
+int StyleTextPropAtom::bulletColor( unsigned index ) const
+{
+ return d->atomData[index].bulletColor;
+}
+
+int StyleTextPropAtom::lineFeed( unsigned index ) const
+{
+ return d->atomData[index].lineFeed;
+}
+
+int StyleTextPropAtom::upperDist( unsigned index ) const
+{
+ return d->atomData[index].upperDist;
+}
+
+int StyleTextPropAtom::lowerDist( unsigned index ) const
+{
+ return d->atomData[index].lowerDist;
+}
+
+int StyleTextPropAtom::align( unsigned index ) const
+{
+ return d->atomData[index].align;
+}
+
+int StyleTextPropAtom::asianLB1( unsigned index ) const
+{
+ return d->atomData[index].asianLB1;
+}
+
+int StyleTextPropAtom::asianLB2( unsigned index ) const
+{
+ return d->atomData[index].asianLB2;
+}
+
+int StyleTextPropAtom::asianLB3( unsigned index ) const
+{
+ return d->atomData[index].asianLB3;
+}
+
+int StyleTextPropAtom::biDi( unsigned index ) const
+{
+ return d->atomData[index].biDi;
+}
+
+int StyleTextPropAtom::charMask() const
+{
+ return d->charMask;
+}
+
+void StyleTextPropAtom::setCharMask( int charMask )
+{
+ d->charMask = charMask;
+}
+
+int StyleTextPropAtom::charFlags() const
+{
+ return d->charFlags;
+}
+
+void StyleTextPropAtom::setCharFlags( int charFlags )
+{
+ d->charFlags = charFlags;
+}
+
+void StyleTextPropAtom::setData( unsigned /*size*/, const unsigned char* data, unsigned lastSize )
+{
+ unsigned charRead = 0;
+ unsigned charCount = 0;
+ unsigned stringLength = unsigned( (0.5*lastSize) + 1 );
+
+ bool isTextPropAtom = true;
+ unsigned k=0;
+
+ while ( charRead < stringLength )
+ {
+ if ( isTextPropAtom == true )
+ {
+ Private::PropAtomData atomData;
+ charCount = readU32(data+k) - 1;
+ k += 4;
+ atomData.charCount = charCount;
+ atomData.depth = readU16(data+k);
+ k += 2;
+ unsigned mask = readU32(data+6);
+ k += 4;
+
+ if ( mask & 0xF )
+ {
+ int bulletFlag = readU16(data+k);
+ k += 2;
+ atomData.bulletOn = ( bulletFlag & 1 ) ? 1 : 0;
+ atomData.bulletHardFont = ( bulletFlag & 2 ) ? 1 : 0;
+ atomData.bulletHardColor = ( bulletFlag & 4 ) ? 1 : 0;
+ }
+
+ if ( mask & 0x0080 )
+ {
+ atomData.bulletChar = readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0x0010 )
+ {
+ atomData.bulletFont = readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0x0040 )
+ {
+ atomData.bulletHeight = readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0x0020 )
+ {
+ atomData.bulletColor = readU32(data+k);
+ k += 4;
+ }
+
+ if ( mask & 0x0F00 )
+ {
+ if ( mask & 0x800 )
+ {
+ unsigned dummy = readU16(data+k);
+ atomData.align = ( dummy & 3 );
+ k += 2;
+ }
+ if ( mask & 0x400 )
+ {
+ /*unsigned dummy =*/ readU16(data+k);
+ k += 2;
+ }
+ if ( mask & 0x200 )
+ {
+ /*unsigned dummy =*/ readU16(data+k);
+ k += 2;
+ }
+ if ( mask & 0x100 )
+ {
+ /*unsigned dummy =*/ readU16(data+k);
+ k += 2;
+ }
+ }
+
+ if ( mask & 0x1000 )
+ {
+ atomData.lineFeed = readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0x2000 )
+ {
+ atomData.upperDist = readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0x4000 )
+ {
+ atomData.lowerDist = readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0x8000 )
+ {
+ /*unsigned dummy =*/ readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0x10000 )
+ {
+ /*unsigned dummy =*/ readU16(data+k);
+ k += 2;
+ }
+
+ if ( mask & 0xe0000 )
+ {
+ unsigned dummy = readU16(data+k);
+ if ( mask & 0x20000 )
+ atomData.asianLB1 = dummy & 1;
+ if ( mask & 0x40000 )
+ atomData.asianLB2 = (dummy >> 1) & 1;
+ if ( mask & 0x80000 )
+ atomData.asianLB3 = (dummy >> 2) & 1;
+
+ k += 2;
+ }
+
+ if ( mask & 0x200000 )
+ {
+ atomData.biDi = readU16(data+k);
+ k += 2;
+ }
+ d->atomData.push_back( atomData );
+ }
+ else
+ {
+ std::cout << "isTextPropAtom == false " << std::endl;
+ charCount = stringLength;
+ Private::PropAtomData atomData;
+ atomData.charCount = charCount;
+ d->atomData.push_back( atomData );
+ }
+
+ if ( ( charCount > stringLength ) || ( stringLength - ( charRead + charCount ) < 0 ) )
+ {
+ isTextPropAtom = false;
+ charCount = stringLength - charRead;
+ Private::PropAtomData atomData;
+ atomData.charCount = charCount;
+ d->atomData.push_back( atomData );
+ }
+
+ charRead += charCount + 1;
+
+ // std::cout << "k = " << k << std::endl;
+ }
+
+
+ /* charRead = 0;
+ while ( charRead < stringLength )
+ {
+ std::cout << "in second while-loop " << std::endl;
+ if ( (isTextPropAtom == false) && (k < size) )
+ {
+ unsigned charCount = readU16(data+k) ;
+ setCharCount (charCount);
+ k += 2;
+ unsigned dummy = readU16(data+k);
+ k += 2;else setAlign( dummy & 3 );
+ int charToRead = size - (charRead + charCount);
+ // std::cout << "charToRead = " << charToRead << std::endl;
+ if (charToRead < 0)
+ {
+ charCount = size - charRead;
+ if ( charToRead < -1 )
+ {
+ isTextPropAtom = false;
+ }
+ }
+ unsigned charMask = readU16(data+k) ;
+ k += 2;
+ setCharMask ( charMask );
+ if ( charMask )
+ {
+ setCharFlags( readU16(data+k) );
+ k += 2;
+ }
+ // std::cout << "k = " << k << std::endl;
+
+ static unsigned charAttrTable[16] =
+ { 16, 21, 22, 23, 17, 18, 19, 20, 24, 25, 26, 27, 28, 29, 30, 31 };
+
+ for ( int i = 0; i < 16; i++ )
+ {
+ int j = charAttrTable[ i ];
+ if ( charMask & ( 1 << j ) )
+ {
+ switch ( j )
+ {
+ case 23: //PPT_CharAttr_Symbol
+ { else setAlign( dummy & 3 );
+ unsigned setSymbolFont= (readU16(data+k));
+ std::cout << "setSymbolFont = " << setSymbolFont << std::endl;
+ //setSymbolFont(readU16(data+k));
+ } break;
+ case 16: //PPT_CharAttr_Font
+ {
+ unsigned setFont= (readU16(data+k));
+ std::cout << "setFont = " << setFont << std::endl;
+ //setFont(readU16(data+k));
+ } break;
+ case 21: //PPT_CharAttr_AsianOrComplexFont
+ {
+ unsigned setAsianOrComplexFont= (readU16(data+k));
+ std::cout << "setAsianOrComplexFont = " << setAsianOrComplexFont << std::endl;
+ //setAsianOrComplexFont(readU16(data+k));
+ } break;
+ case 22: // PPT_CharAttr_Unknown2
+ { unsigned setUnknown= (readU16(data+k));
+ std::cout << "setUnknown = " << setUnknown << std::endl;
+ //setUnknown(readU16(data+k));
+ } break;
+ case 17: //PPT_CharAttr_Fontvoid Record::setData( unsigned, const unsigned char* )
+ { unsigned setFonttPropAtomHeight= (readU16(data+k));
+ std::cout << "setFontHeight = " << setFontHeight << std::endl;
+ //setFontHeight(readU16(data+k));
+ } break;
+ case 18: //PPT_CharAttr_FontColor
+ { unsigned setFontColor= (readU32(data+k));
+ std::cout << "setFontColor = " << setFontColor << std::endl;
+ //setFontColor(readU32(data+k));
+ k +=2;
+ } break;
+ case 19://PPT_CharAttr_Escapement
+ { unsigned setEscapement= (readU16(data+k));
+ std::cout << "setEscapement = " << setEscapement << std::endl;
+ //setEscapement(readU32(data+k));
+ } break;
+ default:
+ { unsigned dummy = readU16(data+k);
+ std::cout << "default " << dummy << std::endl;
+ }
+ }
+ k +=2;
+ }
+ }
+powerpoint.cpp:3370: warning: convert
+ std::cout << "k = " << k << std::endl;
+ }
+ else
+ {
+ charRead = stringLength;
+ }
+ } */
+
+}
+
+
+void StyleTextPropAtom::dump( std::ostream& out ) const
+{
+ out << "StyleTextPropAtom" << std::endl;
+ out << "listSize " << listSize() << std::endl << std::endl;
+ for ( unsigned i = 0; i < listSize(); i++)
+ {
+ out << "charCount " << charCount(i) << std::endl;
+ out << "depth " << depth(i) << std::endl;
+ out << "isBulletOn " << bulletOn(i) << std::endl;
+ out << "isbulletHardFont " << bulletHardFont(i) << std::endl;
+ out << "isbulletHardColor " << bulletHardColor(i) << std::endl;
+ out << "bulletChar " << bulletChar(i) << std::endl;
+ out << "bulletFont " << bulletFont(i) << std::endl;
+ out << "bulletHeight " << bulletHeight(i) << std::endl;
+ out << "bulletColor " << std::endl;
+ out << " R " << ((bulletColor(i) >>0) & 0xff) << std::endl;
+ out << " G " << ((bulletColor(i) >>8) & 0xff) << std::endl;
+ out << " B " << ((bulletColor(i) >>16) & 0xff) << std::endl;
+ out << " I " << ((bulletColor(i) >>24) & 0xff) << std::endl;
+ out << "align " << align(i) << std::endl;
+ out << "lineFeed " << lineFeed(i) << std::endl;
+ out << "upperDist " << upperDist(i) << std::endl;
+ out << "lowerDist " << lowerDist(i) << std::endl;
+ out << "biDi " << biDi(i) << std::endl;
+
+ out << std::endl;
+ }
+// out << "charMask " << charMask() << std::endl;
+// out << "charFlags " << charFlags() << std::endl;
+
+}
+
+
+
+// ========== TxCFStyleAtom ==========
+
+const unsigned int TxCFStyleAtom ::id = 4004;
+
+
+class TxCFStyleAtom ::Private
+{
+public:
+ int flags1;
+ int flags2;
+ int flags3;
+ int n1;
+ int fontHeight;
+ int fontColor;
+};
+
+TxCFStyleAtom ::TxCFStyleAtom ()
+{
+ d = new Private;
+ d->flags1 = 0;
+ d->flags2 = 0;
+ d->flags3 = 0;
+ d->n1 = 0;
+ d->fontHeight = 0;
+ d->fontColor = 0;
+}
+
+TxCFStyleAtom ::~TxCFStyleAtom ()
+{
+ delete d;
+}
+
+int TxCFStyleAtom::flags1() const
+{
+ return d->flags1;
+}
+
+void TxCFStyleAtom::setFlags1( int flags1 )
+{
+ d->flags1 = flags1;
+}
+
+int TxCFStyleAtom::flags2() const
+{
+ return d->flags2;
+}
+
+void TxCFStyleAtom::setFlags2( int flags2 )
+{
+ d->flags2 = flags2;
+}
+
+int TxCFStyleAtom::flags3() const
+{
+ return d->flags3;
+}
+
+void TxCFStyleAtom::setFlags3( int flags3 )
+{
+ d->flags3 = flags3;
+}
+
+int TxCFStyleAtom::n1() const
+{
+ return d->n1;
+}
+
+void TxCFStyleAtom::setN1( int n1 )
+{
+ d->n1 = n1;
+}
+
+int TxCFStyleAtom::fontHeight() const
+{
+ return d->fontHeight;
+}
+
+void TxCFStyleAtom::setFontHeight( int fontHeight )
+{
+ d->fontHeight = fontHeight;
+}
+
+int TxCFStyleAtom::fontColor() const
+{
+ return d->fontColor;
+}
+
+void TxCFStyleAtom::setFontColor( int fontColor )
+{
+ d->fontColor = fontColor;
+}
+
+void TxCFStyleAtom::setData( unsigned , const unsigned char* data )
+{
+ setFlags1(readU16( data + 0));
+ setFlags2(readU16( data + 2));
+ setFlags3(readU16( data + 4));
+ setN1(readU32( data + 6));
+ setFontHeight(readU16( data + 10));
+ setFontColor(readU32( data + 12));
+}
+
+void TxCFStyleAtom ::dump( std::ostream& out ) const
+{
+ out << "TxCFStyleAtom " << std::endl;
+ out << "flags1 " << flags1() << std::endl;
+ out << "flags2 " << flags2() << std::endl;
+ out << "flags3 " << flags3() << std::endl;
+ out << "n1 " << n1() << std::endl;
+ out << "font height " << fontHeight() << std::endl;
+ out << "font color " << fontColor() << std::endl;
+}
+
+// ========== TxPFStyleAtom ==========
+
+const unsigned int TxPFStyleAtom::id = 4005;
+
+TxPFStyleAtom::TxPFStyleAtom()
+{
+}
+
+TxPFStyleAtom::~TxPFStyleAtom()
+{
+}
+
+void TxPFStyleAtom::dump( std::ostream& out ) const
+{
+ out << "TxPFStyleAtom - need special parse code" << std::endl;
+}
+
+// ========== TxSIStyleAtom ==========
+
+const unsigned int TxSIStyleAtom ::id = 4009;
+
+TxSIStyleAtom ::TxSIStyleAtom ()
+{
+}
+
+TxSIStyleAtom ::~TxSIStyleAtom ()
+{
+}
+
+void TxSIStyleAtom ::dump( std::ostream& out ) const
+{
+ out << "TxSIStyleAtom - need special parse code" << std::endl;
+}
+
+// ========== Record1043 ==========
+
+const unsigned int Record1043::id = 1043;
+
+Record1043::Record1043()
+{
+}
+
+void Record1043::dump( std::ostream& out ) const
+{
+ out << "Record1043 - not known" << std::endl;
+}
+
+// ========== Record1044 ==========
+
+const unsigned int Record1044::id = 1044;
+
+Record1044::Record1044()
+{
+}
+
+void Record1044::dump( std::ostream& out ) const
+{
+ out << "Record1044 - not known" << std::endl;
+}
+
+// ========== SlideAtom ==========
+
+const unsigned int SlideAtom::id = 1007;
+
+class SlideAtom::Private
+{
+public:
+ int layoutGeom;
+ int layoutPlaceholderId1;
+ int layoutPlaceholderId2;
+ int layoutPlaceholderId3;
+ int layoutPlaceholderId4;
+ int layoutPlaceholderId5;
+ int layoutPlaceholderId6;
+ int layoutPlaceholderId7;
+ int layoutPlaceholderId8;
+ int masterId;
+ int notesId;
+ int flags;
+};
+
+SlideAtom::SlideAtom()
+{
+ d = new Private;
+ d->layoutGeom = 0;
+ d->layoutPlaceholderId1 = 0;
+ d->layoutPlaceholderId2 = 0;
+ d->layoutPlaceholderId3 = 0;
+ d->layoutPlaceholderId4 = 0;
+ d->layoutPlaceholderId5 = 0;
+ d->layoutPlaceholderId6 = 0;
+ d->layoutPlaceholderId7 = 0;
+ d->layoutPlaceholderId8 = 0;
+ d->masterId = 0;
+ d->notesId = 0;
+ d->flags = 0;
+}
+
+SlideAtom::~SlideAtom()
+{
+ delete d;
+}
+
+int SlideAtom::layoutGeom() const
+{
+ return d->layoutGeom;
+}
+
+void SlideAtom::setLayoutGeom(int layoutGeom )
+{
+ d->layoutGeom = layoutGeom;
+}
+
+
+int SlideAtom::layoutPlaceholderId() const
+{
+ return d->layoutPlaceholderId1;
+ return d->layoutPlaceholderId2;
+ return d->layoutPlaceholderId3;
+ return d->layoutPlaceholderId4;
+ return d->layoutPlaceholderId5;
+ return d->layoutPlaceholderId6;
+ return d->layoutPlaceholderId7;
+ return d->layoutPlaceholderId8;
+}
+
+void SlideAtom::setLayoutPlaceholderId(int layoutPlaceholderId1, int layoutPlaceholderId2,int layoutPlaceholderId3,int layoutPlaceholderId4,int layoutPlaceholderId5,int layoutPlaceholderId6,int layoutPlaceholderId7,int layoutPlaceholderId8)
+{
+ d->layoutPlaceholderId1 = layoutPlaceholderId1;
+ d->layoutPlaceholderId2 = layoutPlaceholderId2;
+ d->layoutPlaceholderId3 = layoutPlaceholderId3;
+ d->layoutPlaceholderId4 = layoutPlaceholderId4;
+ d->layoutPlaceholderId5 = layoutPlaceholderId5;
+ d->layoutPlaceholderId6 = layoutPlaceholderId6;
+ d->layoutPlaceholderId7 = layoutPlaceholderId7;
+ d->layoutPlaceholderId8 = layoutPlaceholderId8;
+}
+
+int SlideAtom::masterId() const
+{
+ return d->masterId;
+}
+
+void SlideAtom::setMasterId(int masterId )
+{
+ d->masterId = masterId;
+}
+
+int SlideAtom::notesId() const
+{
+ return d->notesId;
+}
+
+void SlideAtom::setNotesId(int notesId)
+{
+ d->notesId = notesId;
+}
+
+int SlideAtom::flags() const
+{
+ return d->flags;
+}
+
+void SlideAtom::setFlags( int flags)
+{
+ d->flags = flags;
+}
+
+void SlideAtom::setData( unsigned , const unsigned char* data )
+{
+ setLayoutGeom(readS32( data + 0 ) );
+ setLayoutPlaceholderId (data[4], data[5], data[6], data[7], data[8], data[9], data[10],data[11]);
+ setMasterId( readS32( data + 12 ) );
+ setNotesId( readS32( data + 16 ) );
+ setFlags( readU16( data + 20 ) );
+}
+
+void SlideAtom::dump( std::ostream& out ) const
+{
+ out << "SlideAtom" << std::endl;
+ out << "layoutGeom " << layoutGeom() << std::endl;
+ // out << "layoutPlaceholderId " << layoutPlaceholderId() <<std::endl;
+ out << "layoutPlaceholderId1 " << d->layoutPlaceholderId1 <<std::endl;
+ out << "layoutPlaceholderId2 " << d->layoutPlaceholderId2 <<std::endl;
+ out << "layoutPlaceholderId3 " << d->layoutPlaceholderId3 <<std::endl;
+ out << "layoutPlaceholderId4 " << d->layoutPlaceholderId4 <<std::endl;
+ out << "layoutPlaceholderId5 " << d->layoutPlaceholderId5 <<std::endl;
+ out << "layoutPlaceholderId6 " << d->layoutPlaceholderId6 <<std::endl;
+ out << "layoutPlaceholderId7 " << d->layoutPlaceholderId7 <<std::endl;
+ out << "layoutPlaceholderId8 " << d->layoutPlaceholderId8 <<std::endl;
+ out << "masterId " << masterId() << std::endl;
+ out << "notesId " << notesId() << std::endl;
+ out << "flags " << flags() << std::endl;
+}
+
+// ========== SSSlideInfoAtom ==========
+
+const unsigned int SSSlideInfoAtom::id = 1017;
+
+class SSSlideInfoAtom ::Private
+{
+public:
+ int transType;
+ int speed;
+ int direction;
+ int slideTime;
+ int buildFlags;
+ int soundRef;
+};
+
+SSSlideInfoAtom ::SSSlideInfoAtom ()
+{
+ d = new Private;
+ d->transType = 0;
+ d->speed = 0;
+ d->direction = 0;
+ d->slideTime = 0;
+ d->buildFlags = 0;
+ d->soundRef = 0;
+}
+
+SSSlideInfoAtom ::~SSSlideInfoAtom ()
+{
+ delete d;
+}
+
+int SSSlideInfoAtom ::transType() const
+{
+ return d->transType;
+}
+
+void SSSlideInfoAtom ::settransType(int transType)
+{
+ d->transType = transType;
+}
+
+int SSSlideInfoAtom ::speed() const
+{
+ return d->transType;
+}
+
+void SSSlideInfoAtom ::setspeed(int speed)
+{
+ d->speed = speed;
+}
+
+int SSSlideInfoAtom ::direction() const
+{
+ return d->transType;
+}
+
+void SSSlideInfoAtom ::setdirection(int direction)
+{
+ d->direction = direction;
+}
+
+int SSSlideInfoAtom ::slideTime() const
+{
+ return d->slideTime;
+}
+
+void SSSlideInfoAtom ::setslideTime(int slideTime)
+{
+ d->slideTime = slideTime;
+}
+
+int SSSlideInfoAtom ::buildFlags() const
+{
+ return d->buildFlags;
+}
+
+void SSSlideInfoAtom ::setbuildFlags(int buildFlags)
+{
+ d->buildFlags = buildFlags;
+}
+
+int SSSlideInfoAtom ::soundRef() const
+{
+ return d->soundRef;
+}
+
+void SSSlideInfoAtom ::setsoundRef(int soundRef)
+{
+ d->soundRef = soundRef;
+}
+
+void SSSlideInfoAtom ::setData( unsigned , const unsigned char* data )
+{
+ settransType( readU32( data + 0 ) );
+ setspeed(readS32( data + 4 ));
+ setdirection(readS32( data + 8 ));
+ setslideTime(readS32( data + 12 ));
+ setbuildFlags(readS32( data + 16 ));
+ setsoundRef(readS32( data + 20 ));
+}
+
+void SSSlideInfoAtom ::dump( std::ostream& out ) const
+{
+ out << "SSSlideInfoAtom" << std::endl;
+ out << "transType " << transType() << std::endl;
+ out << "speed " << speed() << std::endl;
+ out << "direction " << direction() << std::endl;
+ out << "slideTime " << slideTime() << std::endl;
+ out << "buildFlags " << buildFlags() << std::endl;
+ out << "soundRef " << soundRef() << std::endl;
+}
+
+// ========== TextHeaderAtom ==========
+
+const unsigned int TextHeaderAtom::id = 3999;
+
+class TextHeaderAtom ::Private
+{
+public:
+ int textType;
+};
+
+TextHeaderAtom ::TextHeaderAtom ()
+{
+ d = new Private;
+ d->textType = 0;
+}
+
+TextHeaderAtom ::~TextHeaderAtom ()
+{
+ delete d;
+}
+
+int TextHeaderAtom ::textType() const
+{
+ return d->textType;
+}
+
+void TextHeaderAtom ::setTextType( int type )
+{
+ d->textType = type;
+}
+
+void TextHeaderAtom ::setData( unsigned size, const unsigned char* data )
+{
+ if( size < 4 ) return;
+ setTextType( readU32( data + 0 ) );
+}
+
+void TextHeaderAtom ::dump( std::ostream& out ) const
+{
+ out << "TextHeaderAtom" << std::endl;
+ out << " textType " << textType() << std::endl;
+}
+
+// ========== TextBytesAtom ==========
+
+const unsigned int TextBytesAtom::id = 4008;
+
+class TextBytesAtom::Private
+{
+public:
+ std::vector<unsigned> index;
+ std::vector<UString> ustring;
+ unsigned stringLength;
+};
+
+TextBytesAtom::TextBytesAtom()
+{
+ d = new Private;
+}
+
+TextBytesAtom::~TextBytesAtom()
+{
+ delete d;
+}
+
+unsigned TextBytesAtom::listSize() const
+{
+ return d->ustring.size();
+}
+
+unsigned TextBytesAtom::stringLength() const
+{
+ return d->stringLength;
+}
+
+void TextBytesAtom::setStringLength( unsigned stringLength )
+{
+ d->stringLength = stringLength;
+}
+
+UString TextBytesAtom::strValue( unsigned index ) const
+{
+ return d->ustring[index];
+}
+
+void TextBytesAtom::setText( UString ustring )
+{
+ d->ustring.push_back( ustring );
+}
+
+void TextBytesAtom::setData( unsigned size, const unsigned char* data )
+{
+ UString tempStr;
+ int index = 0;
+ unsigned length = 0;
+ for( unsigned k=0; k<(size + 1); k++ )
+ {
+ unsigned uchar = data[k];
+ if ( (uchar == 0x0b) | (uchar == 0x0d) | (k == size) )
+ {
+ setText(tempStr);
+ index++;
+ tempStr = "";
+ }
+ else
+ tempStr.append( UString(uchar) );
+
+ if ( ( uchar & 0xff00 ) == 0xf000 )
+ { // handle later
+ std::cout << "got a symbol at " << k << "th character" << std::endl;
+ }
+ length++;
+ }
+
+ setStringLength(length);
+}
+
+void TextBytesAtom::dump( std::ostream& out ) const
+{
+ out << "TextBytesAtom" << std::endl;
+ out << "stringLength " << stringLength() << std::endl;
+ out << "listSize " << listSize() << std::endl;
+ for (uint i=0; i<listSize() ; i++)
+ {
+ out << "String " << i << " [" << strValue(i) << "]" << std::endl;
+ }
+
+}
+
+
+// ========== TextSpecInfoAtom ==========
+
+const unsigned int TextSpecInfoAtom::id = 4010;
+
+class TextSpecInfoAtom::Private
+{
+public:
+ int charCount;
+ int flags;
+};
+
+TextSpecInfoAtom::TextSpecInfoAtom ()
+{
+ d = new Private;
+ d->charCount = 0;
+ d->flags = 0;
+}
+
+TextSpecInfoAtom::~TextSpecInfoAtom ()
+{
+ delete d;
+}
+
+int TextSpecInfoAtom::charCount() const
+{
+ return d->charCount;
+}
+
+void TextSpecInfoAtom::setCharCount(int charCount)
+{
+ d->charCount = charCount;
+}
+
+int TextSpecInfoAtom::flags() const
+{
+ return d->flags;
+}
+
+void TextSpecInfoAtom::setFlags(int flags)
+{
+ d->flags = flags;
+}
+
+void TextSpecInfoAtom::setData( unsigned , const unsigned char* data )
+{
+ setCharCount( readU32( data + 0 ) );
+ setFlags( readU32( data + 4 ) );
+
+}
+
+void TextSpecInfoAtom::dump( std::ostream& out ) const
+{
+ out << "TextSpecInfoAtom" << std::endl;
+ out << "charCount " << charCount() << std::endl;
+ out << "flags " << flags() << std::endl;
+}
+
+// ========== SlidePersistAtom ==========
+
+const unsigned int SlidePersistAtom::id = 1011;
+
+class SlidePersistAtom::Private
+{
+public:
+ int psrReference;
+ int flags;
+ int numberTexts;
+ int slideId;
+ int reserved;
+};
+
+SlidePersistAtom::SlidePersistAtom ()
+{
+ d = new Private;
+ d->psrReference = 0;
+ d->flags = 0;
+ d->numberTexts=0;
+ d->slideId=0;
+ d->reserved=0;
+ }
+
+SlidePersistAtom::~SlidePersistAtom ()
+{
+ delete d;
+}
+
+int SlidePersistAtom::psrReference() const
+{
+ return d->psrReference;
+}
+
+void SlidePersistAtom::setPsrReference( int psrReference )
+{
+ d->psrReference = psrReference;
+}
+
+int SlidePersistAtom::flags() const
+{
+ return d->flags;
+}
+
+void SlidePersistAtom::setFlags( int flags )
+{
+ d->flags = flags;
+}
+
+int SlidePersistAtom::numberTexts() const
+{
+ return d->numberTexts;
+}
+
+void SlidePersistAtom::setNumberTexts( int numberTexts )
+{
+ d->numberTexts = numberTexts;
+}
+
+int SlidePersistAtom::slideId() const
+{
+ return d->slideId;
+}
+
+void SlidePersistAtom::setSlideId( int slideId )
+{
+ d->slideId = slideId;
+}
+
+int SlidePersistAtom::reserved() const
+{
+ return d->reserved;
+}
+
+void SlidePersistAtom::setReserved( int reserved )
+{
+ d->reserved = reserved;
+}
+
+void SlidePersistAtom::setData( unsigned size, const unsigned char* data )
+{
+ if( size < 20 ) return;
+
+ setPsrReference( readU32( data + 0 ) );
+ setFlags( readU32( data + 4 ) );
+ setNumberTexts( readS32( data + 8 ) );
+ setSlideId( readS32( data + 12 ) );
+ setReserved(readU32( data + 16) );
+}
+
+void SlidePersistAtom ::dump( std::ostream& out ) const
+{
+ out << "SlidePersistAtom" << std::endl;
+ out << "psrReference " << psrReference() << std::endl;
+ out << "flags " << flags() << std::endl;
+ out << "numberTexts " << numberTexts() << std::endl;
+ out << "slideId " << slideId() << std::endl;
+ out << "reserved " << reserved() << " always 0."<<std::endl;
+}
+
+// ========== msofbtDgAtom ==========
+
+const unsigned int msofbtDgAtom::id = 61448; /* F008 */
+
+msofbtDgAtom ::msofbtDgAtom ()
+{
+}
+
+msofbtDgAtom ::~msofbtDgAtom ()
+{
+}
+
+void msofbtDgAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtDgAtom " << std::endl;
+}
+
+// ========== msofbtSpgrAtom ==========
+
+const unsigned int msofbtSpgrAtom::id = 61449; /* F009 */
+
+msofbtSpgrAtom ::msofbtSpgrAtom ()
+{
+}
+
+msofbtSpgrAtom ::~msofbtSpgrAtom ()
+{
+}
+
+void msofbtSpgrAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtSpgrAtom " << std::endl;
+}
+
+// ========== msofbtSpAtom ==========
+
+const unsigned int msofbtSpAtom::id = 61450; /* F00A */
+
+class msofbtSpAtom::Private
+{
+public:
+ unsigned long shapeId;
+ unsigned long persistentFlag;
+ bool background;
+ bool hFlip;
+ bool vFlip;
+};
+
+msofbtSpAtom ::msofbtSpAtom ()
+{
+ d = new Private;
+ d->shapeId = 0;
+ d->persistentFlag = 0;
+ d->background = false;
+ d->hFlip = false;
+ d->vFlip = false;
+}
+
+msofbtSpAtom ::~msofbtSpAtom ()
+{
+ delete d;
+}
+
+unsigned long msofbtSpAtom::shapeId() const
+{
+ return d->shapeId;
+}
+
+void msofbtSpAtom::setShapeId( unsigned long id )
+{
+ d->shapeId = id;
+}
+
+const char* msofbtSpAtom::shapeTypeAsString() const
+{
+ switch( instance() )
+ {
+ case 0: return "msosptMin";
+ case 1: return "msosptRectangle";
+ case 2: return "msosptRoundRectangle";
+ case 3: return "msosptEllipse";
+ case 4: return "msosptDiamond";
+ case 5: return "msosptIsoscelesTriangle";
+ case 6: return "msosptRightTriangle";
+ case 7: return "msosptParallelogram";
+ case 8: return "msosptTrapezoid";
+ case 9: return "msosptHexagon";
+ case 10: return "msosptOctagon";
+ case 11: return "msosptPlus";
+ case 12: return "msosptStar";
+ case 13: return "msosptArrow";
+ case 14: return "msosptThickArrow";
+ case 15: return "msosptHomePlate";
+ case 16: return "msosptCube";
+ case 17: return "msosptBalloon";
+ case 18: return "msosptSeal";
+ case 19: return "msosptArc";
+ case 20: return "msosptLine";
+ case 21: return "msosptPlaque";
+ case 22: return "msosptCan =";
+ case 23: return "msosptDonut";
+ case 24: return "msosptTextSimple";
+ case 25: return "msosptTextOctagon";
+ case 26: return "msosptTextHexagon";
+ case 27: return "msosptTextCurve";
+ case 28: return "msosptTextOnRing";
+ case 29: return "msosptTextRing";
+ case 30: return "msosptTextOnCurve";
+ case 31: return "msosptTextOnRing";
+ case 32: return "msosptStraightConnector1";
+ case 75: return "msosptPictureFrame";
+ case 74: return "msosptHeart";
+ case 96: return "msosptSmileyFace";
+ case 202: return "msosptTextBox";
+ default: break;
+ };
+ return "Unknown";
+}
+
+unsigned long msofbtSpAtom::persistentFlag() const
+{
+ return d->persistentFlag;
+}
+
+void msofbtSpAtom::setPersistentFlag( unsigned long persistentFlag )
+{
+ d->persistentFlag = persistentFlag;
+}
+
+bool msofbtSpAtom::isBackground() const
+{
+ return d->background;
+}
+
+void msofbtSpAtom::setBackground( bool bg )
+{
+ d->background = bg;
+}
+
+bool msofbtSpAtom::isVerFlip() const
+{
+ return d->vFlip;
+}
+
+void msofbtSpAtom::setVerFlip( bool vFlip )
+{
+ d->vFlip = vFlip;
+}
+
+bool msofbtSpAtom::isHorFlip() const
+{
+ return d->hFlip;
+}
+
+void msofbtSpAtom::setHorFlip( bool hFlip )
+{
+ d->hFlip = hFlip;
+}
+
+void msofbtSpAtom::setData( unsigned size, const unsigned char* data )
+{
+ if( size < 8 ) return;
+
+ setShapeId( readU32( data + 0 ) );
+ setPersistentFlag( readU32( data + 4 ) );
+
+ unsigned flag = readU16( data + 4 );
+ setBackground( flag & 0x800 );
+ setVerFlip( flag & 0x80 );
+ setHorFlip( flag & 0x40 );
+}
+
+void msofbtSpAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtSpAtom " << std::endl;
+}
+
+// ========== msofbtOPTAtom ==========
+
+const unsigned int msofbtOPTAtom::id = 61451; /* F00B */
+
+class msofbtOPTAtom::Private
+{
+public:
+ std::vector<unsigned> ids;
+ std::vector<unsigned long> values;
+};
+
+msofbtOPTAtom ::msofbtOPTAtom ()
+{
+ d = new Private;
+}
+
+msofbtOPTAtom ::~msofbtOPTAtom ()
+{
+ delete d;
+}
+
+unsigned msofbtOPTAtom ::propertyCount() const
+{
+ return d->ids.size();
+}
+
+unsigned msofbtOPTAtom ::propertyId( unsigned index ) const
+{
+ return d->ids[index];
+}
+
+unsigned long msofbtOPTAtom ::propertyValue( unsigned index ) const
+{
+ return d->values[index];
+}
+
+void msofbtOPTAtom::setProperty( unsigned id, unsigned long val )
+{
+ d->ids.push_back( id );
+ d->values.push_back( val );
+}
+
+void msofbtOPTAtom::setData( unsigned size, const unsigned char* data )
+{
+ unsigned i = 0;
+ unsigned comp_len = 0;
+
+ d->ids.clear();
+ d->values.clear();
+
+ while( i < size )
+ {
+ unsigned x = readU16( data+i );
+ unsigned int id = x & 0x3fff;
+ bool comp = x & 0x8000;
+ unsigned long val = readU32( data + i + 2 );
+ if( comp )
+ comp_len += val;
+ i += 6;
+ setProperty( id, val );
+ }
+}
+
+void msofbtOPTAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtOPTAtom " << std::endl;
+}
+
+
+// ========== msofbtChildAnchorAtom ==========
+
+const unsigned int msofbtChildAnchorAtom::id = 61455; /* F00F */
+
+msofbtChildAnchorAtom ::msofbtChildAnchorAtom ()
+{
+}
+
+msofbtChildAnchorAtom ::~msofbtChildAnchorAtom ()
+{
+}
+
+void msofbtChildAnchorAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtChildAnchorAtom " << std::endl;
+}
+
+// ========== msofbtClientAnchorAtom ==========
+
+const unsigned int msofbtClientAnchorAtom::id = 61456; /* F010 */
+
+class msofbtClientAnchorAtom::Private
+{
+public:
+ int left;
+ int top;
+ int right;
+ int bottom;
+};
+
+msofbtClientAnchorAtom::msofbtClientAnchorAtom ()
+{
+ d = new Private;
+ d->left = 0;
+ d->top = 0;
+ d->right=0;
+ d->bottom=0;
+ }
+
+msofbtClientAnchorAtom ::~msofbtClientAnchorAtom ()
+{
+ delete d;
+}
+
+int msofbtClientAnchorAtom ::left() const
+{
+ return d->left;
+}
+
+void msofbtClientAnchorAtom ::setLeft( int left )
+{
+ d->left = left;
+}
+
+int msofbtClientAnchorAtom ::top() const
+{
+ return d->top;
+}
+
+void msofbtClientAnchorAtom ::setTop( int top )
+{
+ d->top = top;
+}
+
+int msofbtClientAnchorAtom ::right() const
+{
+ return d->right;
+}
+
+void msofbtClientAnchorAtom ::setRight( int right )
+{
+ d->right = right;
+}
+
+int msofbtClientAnchorAtom ::bottom() const
+{
+ return d->bottom;
+}
+
+void msofbtClientAnchorAtom ::setBottom( int bottom )
+{
+ d->bottom = bottom;
+}
+
+void msofbtClientAnchorAtom ::setData( unsigned , const unsigned char* data )
+{
+ setTop( readU16( data + 0 ) );
+ setLeft( readU16( data + 2 ) );
+ setRight( readU16( data + 4 ) );
+ setBottom( readU16( data + 6 ) );
+}
+
+void msofbtClientAnchorAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtClientAnchorAtom " << std::endl;
+ out << "left " << left() << std::endl;
+ out << "top " << top() << std::endl;
+ out << "right " << right() << std::endl;
+ out << "bottom " << bottom() << std::endl;
+
+}
+
+// ========== msofbtClientDataAtom ==========
+
+const unsigned int msofbtClientDataAtom::id = 61457; /* F011 */
+
+class msofbtClientDataAtom::Private
+{
+public:
+ unsigned placementId;
+ unsigned placeholderId;
+};
+
+msofbtClientDataAtom::msofbtClientDataAtom ()
+{
+ d = new Private;
+ d->placementId = 0;
+ d->placeholderId = 0;
+}
+
+msofbtClientDataAtom::~msofbtClientDataAtom ()
+{
+ delete d;
+}
+
+unsigned msofbtClientDataAtom::placementId() const
+{
+ return d->placementId;
+}
+
+void msofbtClientDataAtom::setPlacementId( unsigned id )
+{
+ d->placementId = id;
+}
+
+unsigned msofbtClientDataAtom::placeholderId() const
+{
+ return d->placeholderId;
+}
+
+void msofbtClientDataAtom::setPlaceholderId( unsigned id )
+{
+ d->placeholderId = id;
+}
+
+const char* msofbtClientDataAtom::placeholderIdAsString() const
+{
+ switch( d->placeholderId )
+ {
+ case 0: return "None";
+ case 1: return "Master title";
+ case 2: return "Master body";
+ case 3: return "Master centered title";
+ case 4: return "Master notes slide image";
+ case 5: return "Master notes body image";
+ case 6: return "Master date";
+ case 7: return "Master slide number";
+ case 8: return "Master footer";
+ case 9: return "Master header";
+ case 10: return "Master subtitle";
+ case 11: return "Generic text object";
+ case 12: return "Title";
+ case 13: return "Body";
+ case 14: return "Notes body";
+ case 15: return "Centered title";
+ case 16: return "Subtitle";
+ case 17: return "Vertical text title";
+ case 18: return "Vertical text body";
+ case 19: return "Notes slide image";
+ case 20: return "Object";
+ case 21: return "Graph";
+ case 22: return "Table";
+ case 23: return "Clip Art";
+ case 24: return "Organization Chart";
+ case 25: return "Media Clip";
+ default: break;
+ };
+
+ return "Unknown";
+}
+
+
+// 00 00 c3 0b ===> OEPlaceholderAtom
+// 08 00 00 00
+// 00 00 00 00 ===> Placement ID
+// 0f ====> Placeholder ID
+// 00 =====> Size of placeholder
+// 9e 00
+
+void msofbtClientDataAtom::setData( unsigned size, const unsigned char* data )
+{
+ if( size < 12 ) return;
+ setPlacementId( readU16( data+8 ) );
+ setPlaceholderId( data[12]-1 );
+}
+
+void msofbtClientDataAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtClientDataAtom " << std::endl;
+}
+
+// ========== msofbtDggAtom ==========
+
+const unsigned int msofbtDggAtom::id = 61446; /* F011 */
+
+msofbtDggAtom ::msofbtDggAtom ()
+{
+}
+
+msofbtDggAtom ::~msofbtDggAtom ()
+{
+}
+
+void msofbtDggAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtDggAtom " << std::endl;
+}
+
+// ========== msofbtClientTextboxAtom ==========
+
+const unsigned int msofbtClientTextboxAtom::id = 61453; /* F00D */
+
+class msofbtClientTextboxAtom::Private
+{
+public:
+ UString ustring;
+};
+
+msofbtClientTextboxAtom::msofbtClientTextboxAtom()
+{
+ d = new Private;
+}
+
+msofbtClientTextboxAtom::~msofbtClientTextboxAtom()
+{
+ delete d;
+}
+
+UString msofbtClientTextboxAtom::ustring() const
+{
+ return d->ustring;
+}
+
+void msofbtClientTextboxAtom::setUString( const UString& ustr )
+{
+ d->ustring = ustr;
+}
+
+void msofbtClientTextboxAtom::setData( unsigned size, const unsigned char* data )
+{
+ UString str;
+ for( unsigned k=0; k<size/2; k++ )
+ {
+ unsigned uchar = readU16( data + k*2 );
+ str.append( UString(uchar) );
+ }
+ setUString( str );
+}
+
+void msofbtClientTextboxAtom::dump( std::ostream& out ) const
+{
+ out << "msofbtClientTextboxAtom" << std::endl;
+ out << "String : [" << ustring() << "]" << std::endl;
+}
+
+/*
+msofbtClientTextboxAtom ::msofbtClientTextboxAtom ()
+{
+}
+
+msofbtClientTextboxAtom ::~msofbtClientTextboxAtom ()
+{
+}
+
+void msofbtClientTextboxAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtClientTextboxAtom " << std::endl;
+}
+*/
+
+// ========== msofbtDeletedPsplAtom ==========
+
+const unsigned int msofbtDeletedPsplAtom::id = 61725; /* F11D */
+
+msofbtDeletedPsplAtom ::msofbtDeletedPsplAtom ()
+{
+}
+
+msofbtDeletedPsplAtom ::~msofbtDeletedPsplAtom ()
+{
+}
+
+void msofbtDeletedPsplAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtDeletedPsplAtom " << std::endl;
+}
+
+// ========== msofbtAnchorAtom ==========
+
+const unsigned int msofbtAnchorAtom::id = 61454; /* F00E */
+
+msofbtAnchorAtom ::msofbtAnchorAtom ()
+{
+}
+
+msofbtAnchorAtom ::~msofbtAnchorAtom ()
+{
+}
+
+void msofbtAnchorAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtAnchorAtom " << std::endl;
+}
+
+// ========== msofbtColorMRUAtom ==========
+
+const unsigned int msofbtColorMRUAtom::id = 61722; /* F11A */
+
+msofbtColorMRUAtom ::msofbtColorMRUAtom ()
+{
+}
+
+msofbtColorMRUAtom ::~msofbtColorMRUAtom ()
+{
+}
+
+void msofbtColorMRUAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtColorMRUAtom " << std::endl;
+}
+
+// ========== msofbtOleObjectAtom ==========
+
+const unsigned int msofbtOleObjectAtom::id = 61727; /* F11F */
+
+msofbtOleObjectAtom ::msofbtOleObjectAtom ()
+{
+}
+
+msofbtOleObjectAtom ::~msofbtOleObjectAtom ()
+{
+}
+
+void msofbtOleObjectAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtOleObjectAtom " << std::endl;
+}
+
+// ========== msofbtSplitMenuColorsAtom ==========
+
+const unsigned int msofbtSplitMenuColorsAtom::id = 61726; /* F11E */
+
+class msofbtSplitMenuColorsAtom::Private
+{
+public:
+ unsigned fillColor;
+ unsigned lineColor;
+ unsigned shadowColor;
+ unsigned threeDColor;
+};
+
+msofbtSplitMenuColorsAtom ::msofbtSplitMenuColorsAtom ()
+{
+ d = new Private;
+ d->fillColor = 0;
+ d->lineColor = 0;
+ d->shadowColor = 0;
+ d->threeDColor = 0;
+}
+
+msofbtSplitMenuColorsAtom ::~msofbtSplitMenuColorsAtom ()
+{
+ delete d;
+}
+
+unsigned msofbtSplitMenuColorsAtom::fillColor() const
+{
+ return d->fillColor;
+}
+
+void msofbtSplitMenuColorsAtom::setFillColor( unsigned fillColor )
+{
+ d->fillColor = fillColor;
+}
+
+unsigned msofbtSplitMenuColorsAtom::lineColor() const
+{
+ return d->lineColor;
+}
+
+void msofbtSplitMenuColorsAtom::setLineColor( unsigned lineColor )
+{
+ d->lineColor = lineColor;
+}
+
+unsigned msofbtSplitMenuColorsAtom::shadowColor() const
+{
+ return d->shadowColor;
+}
+
+void msofbtSplitMenuColorsAtom::setShadowColor( unsigned shadowColor )
+{
+ d->shadowColor = shadowColor;
+}
+
+unsigned msofbtSplitMenuColorsAtom::threeDColor() const
+{
+ return d->threeDColor;
+}
+
+void msofbtSplitMenuColorsAtom::setThreeDColor( unsigned threeDColor )
+{
+ d->threeDColor = threeDColor;
+}
+
+void msofbtSplitMenuColorsAtom::setData( unsigned , const unsigned char* data )
+{
+ setFillColor( readU32( data+0 ) );
+ setLineColor( readU32( data+4 ) );
+ setShadowColor( readU32( data+8 ) );
+ setThreeDColor( readU32( data+12 ) );
+}
+
+void msofbtSplitMenuColorsAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtSplitMenuColorsAtom " << std::endl;
+ out << "fillColor" << fillColor() << std::endl;
+ out << "lineColor" << lineColor() << std::endl;
+ out << "shadowColor" << shadowColor() << std::endl;
+ out << "threeDColor" << threeDColor() << std::endl;
+}
+
+// ========== msofbtBSEAtom ==========
+
+const unsigned int msofbtBSEAtom::id = 61447; /* F007 */
+
+msofbtBSEAtom ::msofbtBSEAtom ()
+{
+}
+
+msofbtBSEAtom ::~msofbtBSEAtom ()
+{
+}
+
+void msofbtBSEAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtBSEAtom " << std::endl;
+}
+
+// ========== msofbtCLSIDAtom ==========
+
+const unsigned int msofbtCLSIDAtom::id = 61462; /* F016 */
+
+msofbtCLSIDAtom ::msofbtCLSIDAtom ()
+{
+}
+
+msofbtCLSIDAtom ::~msofbtCLSIDAtom ()
+{
+}
+
+void msofbtCLSIDAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtCLSIDAtom " << std::endl;
+}
+
+// ========== msofbtRegroupItemsAtom ==========
+
+const unsigned int msofbtRegroupItemsAtom::id = 61720; /* F118 */
+
+msofbtRegroupItemsAtom ::msofbtRegroupItemsAtom ()
+{
+}
+
+msofbtRegroupItemsAtom ::~msofbtRegroupItemsAtom ()
+{
+}
+
+void msofbtRegroupItemsAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtRegroupItemsAtom " << std::endl;
+}
+
+// ========== msofbtColorSchemeAtom ==========
+
+const unsigned int msofbtColorSchemeAtom::id = 61728; /* F120 */
+
+msofbtColorSchemeAtom ::msofbtColorSchemeAtom ()
+{
+}
+
+msofbtColorSchemeAtom ::~msofbtColorSchemeAtom ()
+{
+}
+
+void msofbtColorSchemeAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtColorSchemeAtom " << std::endl;
+}
+
+// ========== msofbtConnectorRuleAtom ==========
+
+const unsigned int msofbtConnectorRuleAtom::id = 61458; /* F012 */
+
+msofbtConnectorRuleAtom ::msofbtConnectorRuleAtom ()
+{
+}
+
+msofbtConnectorRuleAtom ::~msofbtConnectorRuleAtom ()
+{
+}
+
+void msofbtConnectorRuleAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtConnectorRuleAtom " << std::endl;
+}
+
+// ========== msofbtAlignRuleAtom ==========
+
+const unsigned int msofbtAlignRuleAtom::id = 61459; /* F013 */
+
+class msofbtAlignRuleAtom ::Private
+{
+public:
+ int ruid;
+ int align;
+ int cProxies;
+};
+
+
+msofbtAlignRuleAtom ::msofbtAlignRuleAtom ()
+{ d = new Private;
+ d->ruid = 0;
+ d->align = 0;
+ d->cProxies = 0;
+}
+
+msofbtAlignRuleAtom ::~msofbtAlignRuleAtom ()
+{
+ delete d;
+}
+
+int msofbtAlignRuleAtom::ruid() const
+{
+ return d->ruid;
+}
+
+void msofbtAlignRuleAtom::setRuid( int ruid )
+{
+ d->ruid = ruid;
+}
+
+int msofbtAlignRuleAtom::align() const
+{
+ return d->align;
+}
+
+void msofbtAlignRuleAtom::setAlign( int ruid )
+{
+ d->ruid = ruid;
+}
+
+int msofbtAlignRuleAtom::cProxies() const
+{
+ return d->cProxies;
+}
+
+void msofbtAlignRuleAtom::setCProxies( int cProxies )
+{
+ d->cProxies = cProxies;
+}
+
+void msofbtAlignRuleAtom::setData( unsigned , const unsigned char* data )
+{
+ setRuid( readU32( data+0 ) );
+ setAlign( readU32( data+4 ) );
+ setCProxies( readU32( data+8 ) );
+}
+
+void msofbtAlignRuleAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtAlignRuleAtom " << std::endl;
+ out << "ruid" << ruid() << std::endl;
+ out << "align " << align() << std::endl;
+ out << "cProxies " << cProxies() << std::endl;
+}
+
+
+// ========== msofbtArcRuleAtom ==========
+
+const unsigned int msofbtArcRuleAtom::id = 61460; /* F014 */
+
+msofbtArcRuleAtom ::msofbtArcRuleAtom ()
+{
+}
+
+msofbtArcRuleAtom ::~msofbtArcRuleAtom ()
+{
+}
+
+void msofbtArcRuleAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtArcRuleAtom " << std::endl;
+}
+
+// ========== msofbtClientRuleAtom ==========
+
+const unsigned int msofbtClientRuleAtom::id = 61461; /* F015 */
+
+msofbtClientRuleAtom ::msofbtClientRuleAtom ()
+{
+}
+
+msofbtClientRuleAtom ::~msofbtClientRuleAtom ()
+{
+}
+
+void msofbtClientRuleAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtClientRuleAtom " << std::endl;
+}
+
+// ========== msofbtCalloutRuleAtom ==========
+
+const unsigned int msofbtCalloutRuleAtom::id = 61463; /* F017 */
+
+msofbtCalloutRuleAtom ::msofbtCalloutRuleAtom ()
+{
+}
+
+msofbtCalloutRuleAtom ::~msofbtCalloutRuleAtom ()
+{
+}
+
+void msofbtCalloutRuleAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtCalloutRuleAtom " << std::endl;
+}
+
+// ========== msofbtSelectionAtom ==========
+
+const unsigned int msofbtSelectionAtom::id = 61465; /* F019 */
+
+msofbtSelectionAtom ::msofbtSelectionAtom ()
+{
+}
+
+msofbtSelectionAtom ::~msofbtSelectionAtom ()
+{
+}
+
+void msofbtSelectionAtom ::dump( std::ostream& out ) const
+{
+ out << "msofbtSelectionAtom " << std::endl;
+}
+
+// ========== PPTReader ==========
+
+class PPTReader::Private
+{
+public:
+ Libppt::Presentation* presentation; // put result here
+
+ POLE::Stream* userStream; // "/Current User"
+ POLE::Stream* docStream; // "/PowerPoint Document"
+
+ std::vector<long> persistenceList;
+ std::map<int,Libppt::Slide*> slideMap;
+ Libppt::Slide* currentSlide;
+ unsigned currentTextType;
+ unsigned currentTextId;
+
+ GroupObject* currentGroup;
+ Object* currentObject;
+ bool isShapeGroup;
+};
+
+
+PPTReader::PPTReader()
+{
+ d = new Private;
+ d->presentation = 0;
+
+ d->userStream = 0;
+ d->docStream = 0;
+
+ d->persistenceList.clear();
+ d->slideMap.clear();
+ d->currentSlide = 0;
+ d->currentTextType = 0;
+ d->currentTextId = 0;
+ d->isShapeGroup = false;
+}
+
+PPTReader::~PPTReader()
+{
+ delete d;
+}
+
+bool PPTReader::load( Presentation* pr, const char* filename )
+{
+ bool result = false;
+
+ // initialization
+ d->presentation = pr;
+ d->docStream = 0;
+ d->userStream = 0;
+ d->persistenceList.clear();
+ d->slideMap.clear();
+ d->currentSlide = 0;
+ d->currentTextType = 0;
+ d->currentTextId = 0;
+ d->currentGroup = 0;
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+
+ POLE::Storage storage( filename );
+ if( !storage.open() )
+ {
+ std::cerr << "Cannot open " << filename << std::endl;
+ }
+ else
+ {
+ // file is MS Office document
+ // check whether it's PowerPoint presentation of not
+ std::cout << "Loading file " << filename << std::endl;
+ d->docStream = new POLE::Stream( &storage, "/PowerPoint Document" );
+ d->userStream = new POLE::Stream( &storage, "/Current User" );
+
+ if( d->docStream->fail() || d->userStream->fail() )
+ {
+ // not PowerPoint, we need to quit
+ storage.close();
+ std::cerr << filename << " is not PowerPoint presentation" << std::endl;
+ delete d->docStream;
+ d->docStream = 0;
+ return false;
+ }
+ else
+ {
+ // so here is PowerPoint stuff
+ loadUserEdit();
+
+ d->presentation->clear();
+ loadMaster();
+ loadSlides();
+ loadDocument();
+
+ result = true;
+ std::cout << std::endl << filename << " loaded. Done." << std::endl;
+ }
+
+ // clean-up
+ storage.close();
+ delete d->docStream;
+ delete d->userStream;
+ d->presentation = 0;
+ d->docStream = 0;
+ d->userStream = 0;
+ d->persistenceList.clear();
+ d->slideMap.clear();
+ d->currentSlide = 0;
+ d->currentTextType = 0;
+ d->currentTextId = 0;
+ d->currentGroup = 0;
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+ }
+
+ return result;
+}
+
+void PPTReader::loadUserEdit()
+{
+ unsigned char buffer[128];
+ unsigned long currentUserEditAtom = 0;
+ std::vector<unsigned long> userEditList;
+ std::vector<unsigned long> lastEditList;
+ std::vector<unsigned long> persistDirList;
+ std::vector<unsigned long> usefulPersistDirList;
+ std::map<int,unsigned long> persistenceMap;
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Parsing Current User information" << std::endl;
+ std::cout << "================================================" << std::endl;
+#endif
+
+ // read one record from "/Current User" stream
+ d->userStream->seek( 0 );
+ unsigned bytes_read = d->userStream->read( buffer, 8 );
+ if( bytes_read != 8 ) return;
+ unsigned long type = readU16( buffer + 2 );
+ unsigned long size = readU32( buffer + 4 );
+
+ // sanity checks
+ if( ( size < 20 ) || ( size > sizeof(buffer) ) )
+ {
+ std::cerr << "ERROR: CurrentUserAtom is not recognized" << std::endl;
+ return;
+ }
+
+ // the first in "/Current User" must be CurrentUserAtom
+ if( type != CurrentUserAtom::id )
+ {
+ std::cerr << "ERROR: First in /Current User is not CurrentUserAtom" << std::endl;
+ return;
+ }
+ else
+ {
+ d->userStream->read( buffer, size );
+ CurrentUserAtom* atom = new CurrentUserAtom;
+ atom->setData( size, buffer );
+ currentUserEditAtom = atom->offsetToCurrentEdit();
+#ifdef LIBPPT_DEBUG
+#if 0
+ d->userStream->read( buffer, atom->lenUserName()*2 );
+ std::cout << "Found username: ";
+ for( unsigned b=0; b<atom->lenUserName()*2; b+=2 )
+ std::cout << (char)buffer[b];
+ std::cout << std::endl;
+#endif
+ atom->dump( std::cout );
+#endif
+ delete atom;
+ }
+
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Scanning for all UserEdit atoms" << std::endl;
+ std::cout << "================================================" << std::endl;
+#endif
+
+ d->docStream->seek( 0 );
+ unsigned long stream_size = d->docStream->size();
+ while( d->docStream->tell() < stream_size )
+ {
+ // get record type and data size
+ unsigned long pos = d->docStream->tell();
+ unsigned bytes_read = d->docStream->read( buffer, 8 );
+ if( bytes_read != 8 ) break;
+
+ unsigned long type = readU16( buffer + 2 );
+ unsigned long size = readU32( buffer + 4 );
+ unsigned long nextpos = d->docStream->tell() + size;
+
+ // we only care for UserEditAtom
+ if( type == UserEditAtom::id )
+ if( size < sizeof(buffer) )
+ {
+ d->docStream->read( buffer, size );
+ UserEditAtom* atom = new UserEditAtom;
+ atom->setData( size, buffer );
+ userEditList.push_back( pos );
+ lastEditList.push_back( atom->offsetLastEdit() );
+ persistDirList.push_back( atom->offsetPersistDir() );
+#ifdef LIBPPT_DEBUG
+ std::cout << "Found at pos " << pos << " size is " << size << std::endl;
+#endif
+ atom->dump( std::cout );
+ delete atom;
+ }
+
+ d->docStream->seek( nextpos );
+ }
+
+#ifdef LIBPPT_DEBUG
+ std::cout << "Found: " << userEditList.size() << " UserEdit atom(s) " << std::endl;
+#endif
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Constructing UserEdit list" << std::endl;
+ std::cout << "================================================" << std::endl;
+#endif
+
+ bool stop = true;
+ do
+ {
+ stop = true;
+
+#ifdef LIBPPT_DEBUG
+ std::cout << "Searching for UserEdit at offset " << currentUserEditAtom << std::endl;
+#endif
+ // search current user edit
+ for( unsigned k=0; k < userEditList.size(); k++ )
+ if( (userEditList[k] = currentUserEditAtom) )
+ {
+ stop = false;
+ usefulPersistDirList.push_back( persistDirList[k] );
+ currentUserEditAtom = lastEditList[k];
+#ifdef LIBPPT_DEBUG
+ std::cout << " found... ";
+ std::cout << " persistence at offset " << persistDirList[k];
+ if( lastEditList[k] != 0 )
+ std::cout << " previous is " << lastEditList[k];
+ std::cout << std::endl;
+#endif
+ break;
+ }
+ }
+ while( !stop && (currentUserEditAtom!=0) );
+
+ // sanity check
+ if( usefulPersistDirList.size() == 0 )
+ {
+ std::cerr << "ERROR: No useful UserEdit information !" << std::endl;
+ return;
+ }
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Searching for persistence information" << std::endl;
+ std::cout << "================================================" << std::endl;
+#endif
+
+ unsigned max = 0;
+
+ for( unsigned j = 0; j < usefulPersistDirList.size(); j++ )
+ {
+ unsigned long offset = usefulPersistDirList[j];
+
+ d->docStream->seek( 0 );
+ while( d->docStream->tell() < stream_size )
+ {
+ unsigned long pos = d->docStream->tell();
+ unsigned bytes_read = d->docStream->read( buffer, 8 );
+ if( bytes_read != 8 ) break;
+
+ unsigned long type = readU16( buffer + 2 );
+ unsigned long size = readU32( buffer + 4 );
+ unsigned long nextpos = d->docStream->tell() + size;
+
+ // we only care for PersistIncrementalBlockAtom
+ if( pos == offset ) //TODO VERIFY IT
+ if( type == PersistIncrementalBlockAtom::id )
+ {
+ unsigned char* buf = new unsigned char[ size ];
+ d->docStream->read( buf, size );
+ PersistIncrementalBlockAtom* atom = new PersistIncrementalBlockAtom;
+ atom->setData( size, buf );
+ delete [] buf;
+
+
+#ifdef LIBPPT_DEBUG
+ std::cout << "Found at pos " << pos << " size is " << size << std::endl;
+ atom->dump( std::cout );
+#endif
+
+ for( unsigned m = 0; m < atom->entryCount(); m++ )
+ {
+ unsigned long ref = atom->reference(m);
+ unsigned long ofs = atom->offset(m);
+ // if it is already there, ignore !!
+ if( !persistenceMap.count( ref ) )
+ persistenceMap[ref] = ofs;
+ max = (ref > max) ? ref : max;
+ }
+ delete atom;
+ }
+
+ d->docStream->seek( nextpos );
+ }
+ }
+
+ // convert to a good list
+ for( unsigned n = 0; n <= max; n++ )
+ {
+ unsigned long ofs = -1;
+ if( persistenceMap.count( n ) )
+ ofs = persistenceMap[n];
+ d->persistenceList.push_back( ofs );
+ }
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Final persistence list" << std::endl;
+ for( unsigned nn = 1; nn < d->persistenceList.size(); nn++ )
+ std::cout << " #" << nn << ": " << d->persistenceList[nn] << std::endl;
+ std::cout << std::endl;
+#endif
+
+}
+
+void PPTReader::loadMaster()
+{
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Loading master" << std::endl;
+ std::cout << "================================================" << std::endl;
+#endif
+
+ d->docStream->seek( 0 );
+ unsigned long stream_size = d->docStream->size();
+ while( d->docStream->tell() < stream_size )
+ {
+ unsigned char buffer[8];
+ unsigned long pos = d->docStream->tell();
+ unsigned bytes_read = d->docStream->read( buffer, 8 );
+ if( bytes_read != 8 ) break;
+
+ unsigned long type = readU16( buffer + 2 );
+ unsigned long size = readU32( buffer + 4 );
+ unsigned long nextpos = d->docStream->tell() + size;
+
+ // we only care for MainMasterContainer....
+ if( type == MainMasterContainer::id )
+ if( indexPersistence( pos ) )
+ {
+#ifdef LIBPPT_DEBUG
+ std::cout << "Found at pos " << pos << " size is " << size << std::endl;
+ std::cout << std::endl;
+#endif
+ Slide* master = new Slide( d->presentation );
+ d->presentation->setMasterSlide( master );
+ d->currentSlide = master;
+ MainMasterContainer* container = new MainMasterContainer;
+ handleContainer( container, type, size );
+ delete container;
+ }
+
+ d->docStream->seek( nextpos );
+ }
+ d->currentSlide = 0;
+}
+
+void PPTReader::loadSlides()
+{
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Loading all slide containers" << std::endl;
+ std::cout << "================================================" << std::endl;
+#endif
+
+ int totalSlides = 0;
+
+ d->docStream->seek( 0 );
+ unsigned long stream_size = d->docStream->size();
+ while( d->docStream->tell() < stream_size )
+ {
+ unsigned char buffer[8];
+ unsigned long pos = d->docStream->tell();
+ unsigned bytes_read = d->docStream->read( buffer, 8 );
+ if( bytes_read != 8 ) break;
+
+ unsigned long type = readU16( buffer + 2 );
+ unsigned long size = readU32( buffer + 4 );
+ unsigned long nextpos = d->docStream->tell() + size;
+
+ unsigned k = 0;
+
+ // we only care for SlideContainer....
+ if( type == SlideContainer::id )
+ if( (k = indexPersistence( pos )) )
+ {
+ // create a new slide, make it current
+ Slide* s = new Slide( d->presentation );
+ d->slideMap[ k ] = s;
+ d->presentation->appendSlide( s );
+ d->currentSlide = s;
+ d->currentTextId = 0;
+ d->currentTextType = TextObject::Body;
+
+#ifdef LIBPPT_DEBUG
+ std::cout << "SLIDE #" << totalSlides+1 << std::endl;
+ std::cout << "Found at pos " << pos << " size is " << size << std::endl;
+ std::cout << "Reference #" << k << std::endl;
+ std::cout << std::endl;
+#endif
+
+ // process all atoms inside
+ SlideContainer* container = new SlideContainer;
+ handleContainer( container, type, size );
+ delete container;
+
+ totalSlides++;
+ }
+
+ d->docStream->seek( nextpos );
+ }
+
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Total: " << totalSlides << " slides" << std::endl;
+#endif
+}
+
+void PPTReader::loadDocument()
+{
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl;
+ std::cout << "Loading document content" << std::endl;
+ std::cout << "================================================" << std::endl;
+#endif
+
+ d->currentSlide = 0;
+ d->currentGroup = 0;
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+
+ d->docStream->seek( 0 );
+ unsigned long stream_size = d->docStream->size();
+ while( d->docStream->tell() < stream_size )
+ {
+ unsigned char buffer[8];
+ unsigned long pos = d->docStream->tell();
+ unsigned bytes_read = d->docStream->read( buffer, 8 );
+ if( bytes_read != 8 ) break;
+
+ unsigned long type = readU16( buffer + 2 );
+ unsigned long size = readU32( buffer + 4 );
+ unsigned long nextpos = d->docStream->tell() + size;
+
+ // we only care for DocumentContainer....
+ if( type == DocumentContainer::id )
+ if( indexPersistence( pos ) )
+ {
+#ifdef LIBPPT_DEBUG
+ std::cout << "Found at pos " << pos << " size is " << size << std::endl;
+ std::cout << std::endl;
+#endif
+ DocumentContainer* container = new DocumentContainer;
+ container->setPosition( pos );
+ handleContainer( container, type, size );
+ delete container;
+ }
+
+ d->docStream->seek( nextpos );
+ }
+
+}
+
+int PPTReader::indexPersistence( unsigned long ofs )
+{
+ for( unsigned k=1; k < d->persistenceList.size(); k++ )
+ if( (d->persistenceList[k] == ofs) )
+ return k;
+
+ return 0;
+}
+
+void PPTReader::loadRecord( Record* parent )
+{
+ // FIXME
+ unsigned char buffer[65536];
+
+ // get record type and data size
+ unsigned long pos = d->docStream->tell();
+ unsigned bytes_read = d->docStream->read( buffer, 8 );
+ if( bytes_read != 8 ) return;
+
+ unsigned instance = readU16( buffer ) >> 4;
+ unsigned long type = readU16( buffer + 2 );
+ unsigned long size = readU32( buffer + 4 );
+ unsigned long nextpos = d->docStream->tell() + size;
+ unsigned lastSize;
+ // create the record using the factory
+ Record* record = Record::create( type );
+ if( record )
+ {
+ record->setParent( parent );
+ record->setPosition( pos );
+ record->setInstance( instance );
+
+ if( !record->isContainer() )
+ {
+ d->docStream->read( buffer, size );
+ // special treatment for StyleTextPropAtom
+ if ( type == StyleTextPropAtom::id )
+ record->setData(size, buffer, lastSize);
+ else
+ record->setData( size, buffer );
+ handleRecord( record, type );
+ }
+ else
+ handleContainer( static_cast<Container*>( record ), type, size );
+
+ delete record;
+ }
+ lastSize = size;
+ d->docStream->seek( nextpos );
+}
+
+void PPTReader::handleRecord( Record* record, int type )
+{
+ if( !record ) return;
+
+ switch( type )
+ {
+ case DocumentAtom::id:
+ handleDocumentAtom( static_cast<DocumentAtom*>(record) ); break;
+ case SlidePersistAtom::id:
+ handleSlidePersistAtom( static_cast<SlidePersistAtom*>(record) ); break;
+ case TextHeaderAtom::id:
+ handleTextHeaderAtom( static_cast<TextHeaderAtom*>(record) ); break;
+ case TextCharsAtom::id:
+ handleTextCharsAtom( static_cast<TextCharsAtom*>(record) ); break;
+ case TextBytesAtom::id:
+ handleTextBytesAtom( static_cast<TextBytesAtom*>(record) ); break;
+ case StyleTextPropAtom::id:
+ handleStyleTextPropAtom( static_cast<StyleTextPropAtom*>(record) ); break;
+ case ColorSchemeAtom::id:
+ handleColorSchemeAtom( static_cast<ColorSchemeAtom*>(record) ); break;
+
+ case msofbtSpgrAtom::id:
+ handleEscherGroupAtom( static_cast<msofbtSpgrAtom*>(record) ); break;
+ case msofbtSpAtom::id:
+ handleEscherSpAtom( static_cast<msofbtSpAtom*>(record) ); break;
+ case msofbtOPTAtom::id:
+ handleEscherPropertiesAtom( static_cast<msofbtOPTAtom*>(record) ); break;
+ case msofbtClientDataAtom::id:
+ handleEscherClientDataAtom( static_cast<msofbtClientDataAtom*>(record) ); break;
+ case msofbtClientAnchorAtom::id:
+ handleEscherClientAnchorAtom( static_cast<msofbtClientAnchorAtom*>(record) ); break;
+ case msofbtClientTextboxAtom::id:
+ handleEscherTextBoxAtom( static_cast<msofbtClientTextboxAtom*>(record) ); break;
+
+ default: break;
+ }
+}
+
+void PPTReader::handleContainer( Container* container, int type, unsigned size )
+{
+ if( !container || !container->isContainer() ) return;
+
+ unsigned long nextpos = d->docStream->tell() + size - 6;
+
+ switch( type )
+ {
+ case msofbtDgContainer::id:
+ handleDrawingContainer( static_cast<msofbtDgContainer*>(container), size ); break;
+ case msofbtSpgrContainer::id:
+ handleEscherGroupContainer( static_cast<msofbtSpgrContainer*>(container), size ); break;
+ case msofbtSpContainer::id:
+ handleSPContainer( static_cast<msofbtSpContainer*>(container), size ); break;
+ default:
+ while( d->docStream->tell() < nextpos )
+ loadRecord( container );
+ }
+}
+
+void PPTReader::handleDocumentAtom( DocumentAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+
+ double pageWidth = atom->slideWidth() * 0.125; // pt, in cm * 0.0440972
+ double pageHeight = atom->slideHeight() * 0.125; // pt
+
+ d->presentation->masterSlide()->setPageWidth( pageWidth );
+ d->presentation->masterSlide()->setPageHeight ( pageHeight );
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl<< "page width = " << pageWidth << std::endl;
+ std::cout << std::endl<< "page height = " << pageHeight << std::endl;
+#endif
+}
+
+void PPTReader::handleSlidePersistAtom( SlidePersistAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+
+ //int id = atom->slideId();
+ unsigned ref = atom->psrReference();
+
+ d->currentSlide = d->slideMap[ ref ];
+ d->currentTextId = 0;
+ d->currentTextType = TextObject::Body;
+
+#ifdef LIBPPT_DEBUG
+ std::cout << std::endl<< "Slide id = " << id << std::endl;
+#endif
+}
+
+void PPTReader::handleTextHeaderAtom( TextHeaderAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+
+ d->currentTextId++;
+ d->currentTextType = atom->textType();
+}
+
+void PPTReader::handleTextCharsAtom( TextCharsAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentTextId ) return;
+
+ int placeId = d->currentTextId-1;
+ TextObject* text = d->currentSlide->textObject( placeId );
+ if( !text )
+ {
+ std::cerr << "No place for text object! " << placeId << std::endl;
+ return;
+ }
+
+ text->setType( d->currentTextType );
+
+ for (uint i=0; i<atom->listSize(); i++)
+ {
+ text->setText(atom->strValue(i));
+ // qDebug("=====================text list ================");
+ }
+
+ if( (d->currentTextType == TextObject::Title) | (d->currentTextType == TextObject::CenterTitle) )
+ for (unsigned i=0; i<atom->listSize(); i++)
+ d->currentSlide->setTitle( atom->strValue(i) );
+
+
+
+#ifdef LIBPPT_DEBUG
+ std::cout << " Text Object " << atom->ustring().ascii();
+ std::cout << " placed at " << placeId << std::endl;
+#endif
+
+}
+
+void PPTReader::handleTextBytesAtom( TextBytesAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentTextId ) return;
+
+ int placeId = d->currentTextId-1;
+ TextObject* text = d->currentSlide->textObject( placeId );
+ if( !text )
+ {
+ std::cerr << "No place for text object! " << placeId << std::endl;
+ return;
+ }
+
+ text->setType( d->currentTextType );
+
+ for (uint i=0; i<atom->listSize(); i++)
+ {
+ text->setText(atom->strValue(i));
+ // qDebug("=====================text list ================");
+ }
+
+ if( (d->currentTextType == TextObject::Title) | (d->currentTextType == TextObject::CenterTitle) )
+ for (unsigned i=0; i<atom->listSize(); i++)
+ d->currentSlide->setTitle( atom->strValue(i) );
+
+
+
+#ifdef LIBPPT_DEBUG
+ std::cout << " Text Object " << atom->ustring().ascii();
+ std::cout << " placed at " << placeId << std::endl;
+#endif
+}
+
+void PPTReader::handleStyleTextPropAtom ( StyleTextPropAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentTextId ) return;
+
+ int placeId = d->currentTextId-1;
+ TextObject* text = d->currentSlide->textObject( placeId );
+
+ for (uint i=0; i<atom->listSize(); i++)
+ {
+ if (atom->bulletOn(i) == 1)
+ text->setBulletFlag(true);
+ else /* if (atom->bulletOn(i) == 0) */
+ text->setBulletFlag(false);
+ }
+
+}
+
+void PPTReader::handleColorSchemeAtom( ColorSchemeAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+
+}
+
+std::string spaces( int x )
+{
+ std::string str;
+ for( int i=0; i<x; i++ )
+ str += ' ';
+ return str;
+}
+
+void dumpGroup( GroupObject* obj, unsigned indent );
+
+void dumpObject( Object* obj, unsigned indent )
+{
+ std::cout << spaces(indent) << "Top: " << obj->top() << std::endl;
+ std::cout << spaces(indent) << "Left: " << obj->left() << std::endl;
+
+ if( obj->isGroup() )
+ {
+ std::cout << spaces(indent) << "This is a group" << std::endl;
+ GroupObject* gr = static_cast<GroupObject*>(obj);
+ dumpGroup( gr, indent+2 );
+ }
+}
+
+void dumpGroup( GroupObject* obj, unsigned indent )
+{
+ for( unsigned i=0; i <obj->objectCount(); i++ )
+ {
+ std::cout << spaces(indent) << "Object #" << i+1 << std::endl;
+ Object* o = obj->object(i);
+ dumpObject( o, indent+2 );
+ }
+}
+
+void dumpSlide( Slide* slide )
+{
+ std::cout << "Slide: " << slide->title().ascii() << std::endl;
+ GroupObject* root = slide->rootObject();
+ dumpGroup( root, 0 );
+ std::cout << std::endl;
+}
+
+
+void PPTReader::handleDrawingContainer( msofbtDgContainer* container, unsigned size )
+{
+ if( !container ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+
+ d->currentGroup = new GroupObject();
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+
+ unsigned long nextpos = d->docStream->tell() + size - 6;
+ while( d->docStream->tell() < nextpos )
+ loadRecord( container );
+
+ for( unsigned i=0; i<d->currentGroup->objectCount(); i++ )
+ {
+ Object* obj = d->currentGroup->object(i);
+ if( ( i == 0 ) && ( obj->isGroup() ) )
+ {
+ d->currentGroup->takeObject( obj );
+ d->currentSlide->setRootObject( (GroupObject*)obj );
+ break;
+ }
+ }
+
+ delete d->currentGroup;
+ d->currentGroup = 0;
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+}
+
+void PPTReader::handleEscherGroupContainer( msofbtSpgrContainer* container, unsigned size )
+{
+ if( !container ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentGroup ) return;
+
+ GroupObject* lastGroup = d->currentGroup;
+
+ d->currentGroup = new GroupObject();
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+
+ unsigned long nextpos = d->docStream->tell() + size - 6;
+ while( d->docStream->tell() < nextpos )
+ loadRecord( container );
+
+ lastGroup->addObject( d->currentGroup ); // FIXME only if patriarch
+ d->currentGroup = lastGroup;
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+}
+
+void PPTReader::handleSPContainer( msofbtSpContainer* container, unsigned size )
+{
+ if( !container ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentGroup ) return;
+
+ d->isShapeGroup = false;
+
+ unsigned long nextpos = d->docStream->tell() + size - 6;
+ while( d->docStream->tell() < nextpos )
+ loadRecord( container );
+
+ if( d->currentObject )
+ if( !d->isShapeGroup )
+ d->currentGroup->addObject( d->currentObject );
+
+ d->currentObject = 0;
+ d->isShapeGroup = false;
+}
+
+void PPTReader::handleEscherGroupAtom( msofbtSpgrAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentGroup ) return;
+
+ // set rect bound of current group
+
+ // this is shape for the group, no need to
+ d->isShapeGroup = true;
+}
+
+void PPTReader::handleEscherSpAtom( msofbtSpAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentGroup ) return;
+
+ DrawObject* drawObject = new DrawObject;
+
+ drawObject->setBackground( atom->isBackground() );
+
+ unsigned sh = DrawObject::None;
+ switch( atom->instance() )
+ {
+ case msofbtSpAtom::msosptRectangle: sh = DrawObject::Rectangle; break;
+ case msofbtSpAtom::msosptRoundRectangle: sh = DrawObject::RoundRectangle; break;
+ case msofbtSpAtom::msosptEllipse: sh = DrawObject::Ellipse; break;
+ case msofbtSpAtom::msosptDiamond: sh = DrawObject::Diamond; break;
+ case msofbtSpAtom::msosptIsoscelesTriangle: sh = DrawObject::IsoscelesTriangle; break;
+ case msofbtSpAtom::msosptRightTriangle: sh = DrawObject::RightTriangle; break;
+ case msofbtSpAtom::msosptParallelogram: sh = DrawObject::Parallelogram; break;
+ case msofbtSpAtom::msosptTrapezoid: sh = DrawObject::Trapezoid; break;
+ case msofbtSpAtom::msosptHexagon: sh = DrawObject::Hexagon; break;
+ case msofbtSpAtom::msosptOctagon: sh = DrawObject::Octagon; break;
+
+ case msofbtSpAtom::msosptArrow: sh = DrawObject::LeftArrow; break;
+ case msofbtSpAtom::msosptDownArrow: sh = DrawObject::DownArrow; break;
+ case msofbtSpAtom::msosptUpArrow: sh = DrawObject::UpArrow; break;
+ case msofbtSpAtom::msosptLeftArrow: sh = DrawObject::LeftArrow; break;
+
+ case msofbtSpAtom::msosptLine: sh = DrawObject::Line; break;
+ case msofbtSpAtom::msosptSmileyFace: sh = DrawObject::Smiley; break;
+ case msofbtSpAtom::msosptHeart: sh = DrawObject::Heart; break;
+ case msofbtSpAtom::msosptMin: sh = DrawObject::FreeLine; break;
+
+ default: break;
+ }
+
+ drawObject->setShape( sh );
+/*
+ if (atom->isVerFlip() == true)
+ d->currentObject->setProperty( "draw:mirror-vertical", "true");
+
+ if (atom->isHorFlip() == true)
+ d->currentObject->setProperty( "draw:mirror-horizontal", "true");
+*/
+ d->currentObject = drawObject;
+
+ if (atom->isVerFlip() == true)
+ d->currentObject->setProperty( "draw:mirror-vertical", "true");
+
+ if (atom->isHorFlip() == true)
+ d->currentObject->setProperty( "draw:mirror-horizontal", "true");
+
+
+}
+
+void PPTReader::handleEscherClientDataAtom( msofbtClientDataAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentGroup ) return;
+ if( !d->currentObject ) return;
+
+ TextObject* textObject = 0;
+ if( !d->currentObject->isText() )
+ {
+ textObject = new TextObject();
+ textObject->convertFrom( d->currentObject );
+ delete d->currentObject;
+ d->currentObject = textObject;
+ }
+ else
+ textObject = static_cast<TextObject*>( d->currentObject );
+
+ switch( atom->placeholderId() )
+ {
+ case msofbtClientDataAtom::MasterTitle:
+ case msofbtClientDataAtom::Title:
+ textObject->setType( TextObject::Title ); break;
+
+ case msofbtClientDataAtom::MasterBody:
+ case msofbtClientDataAtom::MasterSubtitle:
+ case msofbtClientDataAtom::Body:
+ case msofbtClientDataAtom::Subtitle:
+ textObject->setType( TextObject::Body ); break;
+
+ case msofbtClientDataAtom::MasterCenteredTitle:
+ case msofbtClientDataAtom::CenteredTitle:
+ textObject->setType( TextObject::CenterTitle ); break;
+
+ default:
+ textObject->setType( TextObject::Other ); break;
+ break;
+ }
+
+ textObject->setId( atom->placementId() );
+}
+
+void PPTReader::handleEscherClientAnchorAtom( msofbtClientAnchorAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentGroup ) return;
+ if( !d->currentObject ) return;
+
+ d->currentObject->setLeft( atom->left()*25.4/576 );
+ d->currentObject->setTop( atom->top()*25.4/576 );
+ d->currentObject->setWidth( (atom->right()-atom->left())*25.4/576 );
+ d->currentObject->setHeight( (atom->bottom()-atom->top())*25.4/576 );
+}
+
+void PPTReader::handleEscherTextBoxAtom( msofbtClientTextboxAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentGroup ) return;
+ if( !d->currentObject ) return;
+
+ TextObject* textObject = 0;
+ if( !d->currentObject->isText() )
+ {
+ textObject = new TextObject();
+ textObject->convertFrom( d->currentObject );
+ delete d->currentObject;
+ d->currentObject = textObject;
+ }
+ else
+ textObject = static_cast<TextObject*>( d->currentObject );
+
+ textObject->setType( TextObject::Other );
+ textObject->setText( atom->ustring() );
+ textObject->setBulletFlag( false );
+}
+
+Color convertFromLong( unsigned long i )
+{
+ unsigned r = (i & 0xff);
+ unsigned g = (i>>8) & 0xff;
+ unsigned b = (i>>16) & 0xff;
+ //unsigned index = (i>>24) & 0xff;
+ return Color( r, g, b );
+}
+
+void PPTReader::handleEscherPropertiesAtom( msofbtOPTAtom* atom )
+{
+ if( !atom ) return;
+ if( !d->presentation ) return;
+ if( !d->currentSlide ) return;
+ if( !d->currentGroup ) return;
+ if( !d->currentObject ) return;
+
+ for( unsigned c=0; c<atom->propertyCount(); c++ )
+ {
+ unsigned pid = atom->propertyId(c);
+ signed long pvalue = atom->propertyValue(c);
+
+ switch( pid )
+ {
+ case msofbtOPTAtom::FillColor:
+ d->currentObject->setProperty( "draw:fill-color", convertFromLong(pvalue) );
+ break;
+ case msofbtOPTAtom::LineColor:
+ d->currentObject->setProperty( "svg:stroke-color", convertFromLong(pvalue) );
+ break;
+ case msofbtOPTAtom::LineWidth:
+ d->currentObject->setProperty( "svg:stroke-width", pvalue*(25.4/(12700*72) ));
+ break;
+ case msofbtOPTAtom::Rotation:
+ { double deg = pvalue/65536.00 ;
+ if (deg > 180.00) deg = 360.00 - deg; // in range (-180,180) deg
+ d->currentObject->setProperty( "libppt:rotation", (deg*0.0174533) ) ;// rad
+ } break;
+ case msofbtOPTAtom::FillType:
+ switch( pvalue )
+ {
+ case msofbtOPTAtom::FillSolid:
+ d->currentObject->setProperty( "draw:fill", "solid"); break;
+ case msofbtOPTAtom::FillPattern:
+ d->currentObject->setProperty( "draw:fill", "solid"); break;
+ default:
+ d->currentObject->setProperty( "draw:fill", "solid"); break;
+ }
+ break;
+ case msofbtOPTAtom::LineDashing:
+ switch( pvalue )
+ {
+ case msofbtOPTAtom::LineSolid :
+ {d->currentObject->setProperty( "draw:stroke", "solid");
+ //qDebug("=====================solid================");
+ } break;
+ case msofbtOPTAtom::LineDashSys :
+ {
+ d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
+ //qDebug("===================== solid================");
+ } break;
+ case msofbtOPTAtom::LineDotSys :
+ {
+ d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_3");
+ //qDebug("===================== dash 2================");
+ } break;
+ case msofbtOPTAtom::LineDashDotSys :
+ {
+ d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
+ //qDebug("===================== dash 3================");
+ } break;
+ case msofbtOPTAtom::LineDashDotDotSys :
+ { d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
+ //qDebug("===================== dash 4================");
+ } break;
+ case msofbtOPTAtom::LineDotGEL :
+ { d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
+ //qDebug("===================== dash 5================");
+ } break;
+ case msofbtOPTAtom::LineDashGEL :
+ { d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_4");
+ //qDebug("===================== dash 6================");
+ } break;
+ case msofbtOPTAtom::LineLongDashGEL :
+ { d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_6");
+ //qDebug("=====================dash 7================");
+ } break;
+ case msofbtOPTAtom::LineDashDotGEL :
+ { d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_5");
+ //qDebug("=====================dash 8================");
+ } break;
+ case msofbtOPTAtom::LineLongDashDotGEL :
+ { d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_7");
+ //qDebug("=====================dash 9================");
+ } break;
+ case msofbtOPTAtom::LineLongDashDotDotGEL :
+ { d->currentObject->setProperty( "draw:stroke", "dash");
+ d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_8");
+ //qDebug("=====================dash 10================");
+ } break;
+ default:
+ d->currentObject->setProperty( "draw:stroke", "solid"); break;
+ } break;
+
+ case msofbtOPTAtom::FlagNoLineDrawDash:
+ { if (pvalue == 589824 )
+ d->currentObject->setProperty( "libppt:invisibleLine", true );
+ } break;
+
+ case msofbtOPTAtom::LineStartArrowhead:
+ {
+ switch( pvalue )
+ {
+ case msofbtOPTAtom::LineNoEnd : break;
+ case msofbtOPTAtom::LineArrowEnd :
+ d->currentObject->setProperty( "draw:marker-start", "msArrowEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowStealthEnd :
+ d->currentObject->setProperty( "draw:marker-start", "msArrowStealthEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowDiamondEnd :
+ d->currentObject->setProperty( "draw:marker-start", "msArrowDiamondEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowOvalEnd :
+ d->currentObject->setProperty( "draw:marker-start", "msArrowOvalEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowOpenEnd :
+ d->currentObject->setProperty( "draw:marker-start", "msArrowOpenEnd_20_5" ); break;
+ default : break;
+ }
+ } break;
+
+ case msofbtOPTAtom::LineStartArrowWidth:
+ {
+ switch ( pvalue )
+ {
+ case msofbtOPTAtom::LineNarrowArrow :
+ d->currentObject->setProperty( "draw:marker-start-width", 0.2 ); break;
+ case msofbtOPTAtom::LineMediumWidthArrow :
+ d->currentObject->setProperty( "draw:marker-start-width", 0.3 ); break;
+ case msofbtOPTAtom::LineWideArrow :
+ d->currentObject->setProperty( "draw:marker-start-width", 0.4 ); break;
+ default : break;
+ }
+ } break;
+
+ case msofbtOPTAtom::LineEndArrowhead:
+ {
+ switch( pvalue )
+ {
+ case msofbtOPTAtom::LineNoEnd : break;
+ case msofbtOPTAtom::LineArrowEnd :
+ d->currentObject->setProperty( "draw:marker-end", "msArrowEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowStealthEnd :
+ d->currentObject->setProperty( "draw:marker-end", "msArrowStealthEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowDiamondEnd :
+ d->currentObject->setProperty( "draw:marker-end", "msArrowDiamondEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowOvalEnd :
+ d->currentObject->setProperty( "draw:marker-end", "msArrowOvalEnd_20_5" ); break;
+ case msofbtOPTAtom::LineArrowOpenEnd :
+ d->currentObject->setProperty( "draw:marker-end", "msArrowOpenEnd_20_5" ); break;
+ default : break;
+ }
+ } break;
+
+
+/*
+ case msofbtOPTAtom::LineStartArrowLength:
+ {
+ switch ( pvalue )
+ {
+ case msofbtOPTAtom::LineShortArrow :
+ d->currentObject->setProperty( "draw:marker-end-length", "0.2cm" ); break;
+ case msofbtOPTAtom::LineMediumLenArrow :
+ d->currentObject->setProperty( "draw:marker-end-length", "0.4cm" ); break;
+ case msofbtOPTAtom::LineLongArrow :
+ d->currentObject->setProperty( "draw:marker-end-length", "0.6cm" ); break;
+ default : break;
+ }
+ } break;
+*/
+ case msofbtOPTAtom::LineEndArrowWidth:
+ {
+ switch ( pvalue )
+ {
+ case msofbtOPTAtom::LineNarrowArrow :
+ d->currentObject->setProperty( "draw:marker-end-width", 0.2 ); break;
+ case msofbtOPTAtom::LineMediumWidthArrow :
+ d->currentObject->setProperty( "draw:marker-end-width", 0.3 ); break;
+ case msofbtOPTAtom::LineWideArrow :
+ d->currentObject->setProperty( "draw:marker-end-width", 0.4 ); break;
+ default : break;
+ }
+ } break;
+/*
+ case msofbtOPTAtom::LineEndArrowLength:
+ {
+ switch ( pvalue )
+ {
+ case msofbtOPTAtom::LineShortArrow :
+ d->currentObject->setProperty( "draw:marker-end-length", "0.2cm" ); break;
+ case msofbtOPTAtom::LineMediumLenArrow :
+ d->currentObject->setProperty( "draw:marker-end-length", "0.4cm" ); break;
+ case msofbtOPTAtom::LineLongArrow :
+ d->currentObject->setProperty( "draw:marker-end-length", "0.6cm" ); break;
+ default : break;
+ }
+ } break;
+*/
+ #if 0
+ case msofbtOPTAtom::ShadowColor:
+ {
+ d->currentObject->setProperty( "draw:shadow-color", convertFromLong(pvalue) );
+ } break;
+ case msofbtOPTAtom::ShadowOpacity:
+ {
+ d->currentObject->setProperty( "draw:shadow-opacity", 100.0-(pvalue/(65536.0)) );
+ } break;
+ case msofbtOPTAtom::ShadowOffsetX:
+ {
+ d->currentObject->setProperty("draw:shadow-offset-x",(pvalue*2.54/(12700*72)));
+ } break;
+ case msofbtOPTAtom::ShadowOffsetY:
+ {
+ d->currentObject->setProperty("draw:shadow-offset-y",(pvalue*2.54/(12700*72)));
+ } break;
+#endif
+ } // switch pid
+
+ } // for
+
+} // handleEscherPropertiesAtom
diff --git a/filters/kpresenter/powerpoint/libppt/powerpoint.h b/filters/kpresenter/powerpoint/libppt/powerpoint.h
new file mode 100644
index 00000000..49950817
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/powerpoint.h
@@ -0,0 +1,2533 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 LIBPPT_POWERPOINT
+#define LIBPPT_POWERPOINT
+
+#include <iostream>
+#include "ustring.h"
+
+namespace Libppt
+{
+
+// forward declaration
+class Presentation;
+
+class Record
+{
+public:
+
+ /**
+ Static ID of the record. Subclasses should override this value
+ with the id of the record they handle.
+ */
+ static const unsigned int id;
+
+ virtual unsigned int rtti(){
+ return this->id;
+ }
+
+ /**
+ Creates a new generic record.
+ */
+ Record();
+
+ /**
+ Destroys the record.
+ */
+ virtual ~Record();
+
+ /**
+ * Record factory, create a new record of specified type.
+ */
+ static Record* create( unsigned type );
+
+ /**
+ * Returns true if this is a Container.
+ */
+ virtual bool isContainer() const { return false; }
+
+ void setParent( Record* parent );
+
+ const Record* parent() const;
+
+ /**
+ Sets the data for this record.
+ */
+ virtual void setData( unsigned size, const unsigned char* data );
+ virtual void setData( unsigned size, const unsigned char* data, unsigned lastSize );
+
+ /**
+ Sets the position of the record in the OLE stream.
+ */
+ void setPosition( unsigned pos );
+
+ /**
+ Gets the position of this record in the OLE stream.
+ */
+ unsigned position() const;
+
+ void setInstance( unsigned inst );
+ unsigned instance() const;
+
+ /**
+ Returns the name of the record. For debugging only.
+ */
+ virtual const char* name(){ return "Unknown"; }
+
+ /**
+ Dumps record information to output stream. For debugging only.
+ */
+ virtual void dump( std::ostream& out ) const;
+
+protected:
+
+ // position of this record in the OLE stream
+ unsigned stream_position;
+
+ unsigned record_instance;
+
+ Record* record_parent;
+
+private:
+ // no copy or assign
+ Record( const Record& );
+ Record& operator=( const Record& );
+};
+
+// Container is a special record, it is for holding another records
+class Container: public Record
+{
+public:
+ Container();
+ virtual bool isContainer() const { return true; }
+ const char* name(){ return "Container"; }
+
+private:
+ // no copy or assign
+ Container( const Container& );
+ Container& operator=( const Container& );
+};
+
+
+class BookmarkCollectionContainer: public Container
+{
+public:
+ static const unsigned int id;
+ BookmarkCollectionContainer();
+ const char* name(){ return "BookmarkCollectionContainer"; }
+
+private:
+ // no copy or assign
+ BookmarkCollectionContainer( const BookmarkCollectionContainer& );
+ BookmarkCollectionContainer& operator=( const BookmarkCollectionContainer& );
+};
+
+class DocumentContainer: public Container
+{
+public:
+ static const unsigned int id;
+ DocumentContainer();
+ const char* name(){ return "DocumentContainer"; }
+
+private:
+ // no copy or assign
+ DocumentContainer( const DocumentContainer& );
+ DocumentContainer& operator=( const DocumentContainer& );
+};
+
+class EnvironmentContainer: public Container
+{
+public:
+ static const unsigned int id;
+ EnvironmentContainer();
+ const char* name(){ return "EnvironmentContainer"; }
+
+private:
+ // no copy or assign
+ EnvironmentContainer( const EnvironmentContainer& );
+ EnvironmentContainer& operator=( const EnvironmentContainer& );
+};
+
+class ExObjListContainer: public Container
+{
+public:
+ static const unsigned int id;
+ ExObjListContainer();
+ const char* name(){ return "ExObjListContainer"; }
+
+private:
+ // no copy or assign
+ ExObjListContainer( const ExObjListContainer& );
+ ExObjListContainer& operator=( const ExObjListContainer& );
+};
+
+class ExHyperlinkContainer : public Container
+{
+public:
+ static const unsigned int id;
+ ExHyperlinkContainer ();
+ const char* name(){ return "ExHyperlinkContainer "; }
+
+private:
+ // no copy or assign
+ ExHyperlinkContainer ( const ExHyperlinkContainer & );
+ ExHyperlinkContainer & operator=( const ExHyperlinkContainer & );
+};
+
+class ExEmbedContainer : public Container
+{
+public:
+ static const unsigned int id;
+ ExEmbedContainer ();
+ const char* name(){ return "ExEmbedContainer "; }
+
+private:
+ // no copy or assign
+ ExEmbedContainer ( const ExEmbedContainer & );
+ ExEmbedContainer & operator=( const ExEmbedContainer & );
+};
+
+class ExLinkContainer : public Container
+{
+public:
+ static const unsigned int id;
+ ExLinkContainer ();
+ const char* name(){ return "ExLinkContainer "; }
+
+private:
+ // no copy or assign
+ ExLinkContainer ( const ExLinkContainer & );
+ ExLinkContainer & operator=( const ExLinkContainer & );
+};
+
+class RunArrayContainer: public Container
+{
+public:
+ static const unsigned int id;
+ RunArrayContainer();
+
+ const char* name(){ return "RunArrayContainer"; }
+
+private:
+ // no copy or assign
+ RunArrayContainer( const RunArrayContainer& );
+ RunArrayContainer& operator=( const RunArrayContainer& );
+};
+
+class ExOleObjStgContainer: public Container
+{
+public:
+ static const unsigned int id;
+ ExOleObjStgContainer();
+ const char* name(){ return "ExOleObjStgContainer"; }
+
+private:
+ // no copy or assign
+ ExOleObjStgContainer( const ExOleObjStgContainer& );
+ ExOleObjStgContainer& operator=( const ExOleObjStgContainer& );
+};
+
+class FontCollectionContainer: public Container
+{
+public:
+ static const unsigned int id;
+ FontCollectionContainer();
+ const char* name(){ return "FontCollectionContainer"; }
+
+private:
+ // no copy or assign
+ FontCollectionContainer( const FontCollectionContainer& );
+ FontCollectionContainer& operator=( const FontCollectionContainer& );
+};
+
+class HandoutContainer: public Container
+{
+public:
+ static const unsigned int id;
+ HandoutContainer();
+ const char* name(){ return "HandoutContainer"; }
+
+private:
+ // no copy or assign
+ HandoutContainer( const HandoutContainer& );
+ HandoutContainer& operator=( const HandoutContainer& );
+};
+
+class HeadersFootersContainer: public Container
+{
+public:
+ static const unsigned int id;
+ HeadersFootersContainer();
+ const char* name(){ return "HeadersFootersContainer"; }
+
+private:
+ // no copy or assign
+ HeadersFootersContainer( const DocumentContainer& );
+ HeadersFootersContainer& operator=( const DocumentContainer& );
+};
+
+class ListContainer: public Container
+{
+public:
+ static const unsigned int id;
+ ListContainer();
+ const char* name(){ return "ListContainer"; }
+
+private:
+ // no copy or assign
+ ListContainer( const ListContainer& );
+ ListContainer& operator=( const ListContainer& );
+};
+
+class MainMasterContainer: public Container
+{
+public:
+ static const unsigned int id;
+ MainMasterContainer();
+ const char* name(){ return "MainMasterContainer"; }
+
+private:
+ // no copy or assign
+ MainMasterContainer( const MainMasterContainer& );
+ MainMasterContainer& operator=( const MainMasterContainer& );
+};
+
+class NotesContainer: public Container
+{
+public:
+ static const unsigned int id;
+ NotesContainer();
+ const char* name(){ return "NotesContainer"; }
+
+private:
+ // no copy or assign
+ NotesContainer( const NotesContainer& );
+ NotesContainer& operator=( const NotesContainer& );
+};
+
+class OutlineViewInfoContainer : public Container
+{
+public:
+ static const unsigned int id;
+ OutlineViewInfoContainer ();
+ const char* name(){ return "OutlineViewInfoContainer "; }
+
+private:
+ // no copy or assign
+ OutlineViewInfoContainer ( const OutlineViewInfoContainer & );
+ OutlineViewInfoContainer & operator=( const OutlineViewInfoContainer & );
+};
+
+class PPDrawingContainer : public Container
+{
+public:
+ static const unsigned int id;
+ PPDrawingContainer ();
+ const char* name(){ return "PPDrawingContainer "; }
+
+private:
+ // no copy or assign
+ PPDrawingContainer ( const PPDrawingContainer & );
+ PPDrawingContainer & operator=( const PPDrawingContainer & );
+};
+
+class PPDrawingGroupContainer : public Container
+{
+public:
+ static const unsigned int id;
+ PPDrawingGroupContainer ();
+ const char* name(){ return "PPDrawingGroupContainer "; }
+
+private:
+ // no copy or assign
+ PPDrawingGroupContainer ( const PPDrawingGroupContainer & );
+ PPDrawingGroupContainer & operator=( const PPDrawingGroupContainer & );
+};
+
+class ProgBinaryTagContainer: public Container
+{
+public:
+ static const unsigned int id;
+ ProgBinaryTagContainer();
+ const char* name(){ return "ProgBinaryTagContainer"; }
+
+private:
+ // no copy or assign
+ ProgBinaryTagContainer( const ProgBinaryTagContainer& );
+ ProgBinaryTagContainer& operator=( const ProgBinaryTagContainer& );
+};
+
+class ProgStringTagContainer: public Container
+{
+public:
+ static const unsigned int id;
+ ProgStringTagContainer();
+ const char* name(){ return "ProgStringTagContainer"; }
+
+private:
+ // no copy or assign
+ ProgStringTagContainer( const ProgStringTagContainer& );
+ ProgStringTagContainer& operator=( const ProgStringTagContainer& );
+};
+
+class ProgTagsContainer : public Container
+{
+public:
+ static const unsigned int id;
+ ProgTagsContainer ();
+ const char* name(){ return "ProgTagsContainer "; }
+
+private:
+ // no copy or assign
+ ProgTagsContainer ( const ProgTagsContainer & );
+ ProgTagsContainer & operator=( const ProgTagsContainer & );
+};
+
+class SlideContainer: public Container
+{
+public:
+ static const unsigned int id;
+ SlideContainer();
+ const char* name(){ return "SlideContainer"; }
+
+private:
+ // no copy or assign
+ SlideContainer( const SlideContainer& );
+ SlideContainer& operator=( const SlideContainer& );
+};
+
+class SlideBaseContainer: public Container
+{
+public:
+ static const unsigned int id;
+ SlideBaseContainer();
+ const char* name(){ return "SlideBaseContainer"; }
+
+private:
+ // no copy or assign
+ SlideBaseContainer( const SlideBaseContainer& );
+ SlideBaseContainer& operator=( const SlideBaseContainer& );
+};
+
+class SlideListWithTextContainer: public Container
+{
+public:
+ static const unsigned int id;
+ SlideListWithTextContainer();
+ const char* name(){ return "SlideListWithTextContainer"; }
+
+private:
+ // no copy or assign
+ SlideListWithTextContainer( const SlideListWithTextContainer& );
+ SlideListWithTextContainer& operator=( const SlideListWithTextContainer& );
+};
+
+class SlideViewInfoContainer: public Container
+{
+public:
+ static const unsigned int id;
+ SlideViewInfoContainer();
+ const char* name(){ return "SlideViewInfoContainer"; }
+
+private:
+ // no copy or assign
+ SlideViewInfoContainer( const SlideViewInfoContainer& );
+ SlideViewInfoContainer& operator=( const SlideViewInfoContainer& );
+};
+
+class SorterViewInfoContainer : public Container
+{
+public:
+ static const unsigned int id;
+ SorterViewInfoContainer ();
+ const char* name(){ return "SorterViewInfoContainer "; }
+
+private:
+ // no copy or assign
+ SorterViewInfoContainer ( const SorterViewInfoContainer & );
+ SorterViewInfoContainer & operator=( const SorterViewInfoContainer & );
+};
+
+class SummaryContainer : public Container
+{
+public:
+ static const unsigned int id;
+ SummaryContainer ();
+ const char* name(){ return "SummaryContainer "; }
+
+private:
+ // no copy or assign
+ SummaryContainer ( const SummaryContainer & );
+ SummaryContainer & operator=( const SummaryContainer & );
+};
+
+class SrKinsokuContainer: public Container
+{
+public:
+ static const unsigned int id;
+ SrKinsokuContainer();
+ const char* name(){ return "SrKinsokuContainer"; }
+
+private:
+ // no copy or assign
+ SrKinsokuContainer( const SrKinsokuContainer& );
+ SrKinsokuContainer& operator=( const SrKinsokuContainer& );
+};
+
+class VBAInfoContainer: public Container
+{
+public:
+ static const unsigned int id;
+ VBAInfoContainer();
+ const char* name(){ return "VBAInfoContainer"; }
+
+private:
+ // no copy or assign
+ VBAInfoContainer( const VBAInfoContainer& );
+ VBAInfoContainer& operator=( const VBAInfoContainer& );
+};
+
+class ViewInfoContainer: public Container
+{
+public:
+ static const unsigned int id;
+ ViewInfoContainer();
+ const char* name(){ return "ViewInfoContainer"; }
+
+private:
+ // no copy or assign
+ ViewInfoContainer( const ViewInfoContainer& );
+ ViewInfoContainer& operator=( const ViewInfoContainer& );
+};
+
+class msofbtDgContainer: public Container
+{
+public:
+ static const unsigned int id;
+ msofbtDgContainer();
+ const char* name(){ return "msofbtDgContainer"; }
+
+private:
+ // no copy or assign
+ msofbtDgContainer( const msofbtDgContainer& );
+ msofbtDgContainer& operator=( const msofbtDgContainer& );
+};
+
+class msofbtSpContainer: public Container
+{
+public:
+ static const unsigned int id;
+ msofbtSpContainer();
+ const char* name(){ return "msofbtSpContainer"; }
+
+private:
+ // no copy or assign
+ msofbtSpContainer( const msofbtSpContainer& );
+ msofbtSpContainer& operator=( const msofbtSpContainer& );
+};
+
+class msofbtSpgrContainer: public Container
+{
+public:
+ static const unsigned int id;
+ msofbtSpgrContainer();
+ const char* name(){ return "msofbtSpgrContainer"; }
+
+private:
+ // no copy or assign
+ msofbtSpgrContainer( const msofbtSpgrContainer& );
+ msofbtSpgrContainer& operator=( const msofbtSpgrContainer& );
+};
+
+class msofbtDggContainer: public Container
+{
+public:
+ static const unsigned int id;
+ msofbtDggContainer();
+ const char* name(){ return "msofbtDggContainer"; }
+
+private:
+ // no copy or assign
+ msofbtDggContainer( const msofbtDggContainer& );
+ msofbtDggContainer& operator=( const msofbtDggContainer& );
+};
+
+class msofbtBstoreContainer: public Container
+{
+public:
+ static const unsigned int id;
+ msofbtBstoreContainer();
+ const char* name(){ return "msofbtBstoreContainer"; }
+
+private:
+ // no copy or assign
+ msofbtBstoreContainer( const msofbtBstoreContainer& );
+ msofbtBstoreContainer& operator=( const msofbtBstoreContainer& );
+};
+
+class msofbtSolverContainer: public Container
+{
+public:
+ static const unsigned int id;
+ msofbtSolverContainer();
+ const char* name(){ return "msofbtSolverContainer"; }
+
+private:
+ // no copy or assign
+ msofbtSolverContainer( const msofbtSolverContainer& );
+ msofbtSolverContainer& operator=( const msofbtSolverContainer& );
+};
+
+class BookmarkEntityAtom : public Record
+{
+public:
+ static const unsigned int id;
+ BookmarkEntityAtom ();
+ ~BookmarkEntityAtom ();
+
+ int bookmarkID() const;
+ void setBookmarkID( int bookmarkID );
+ int bookmarkName() const;
+ void setBookmarkName( int bookmarkName );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "BookmarkEntityAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ BookmarkEntityAtom ( const BookmarkEntityAtom & );
+ BookmarkEntityAtom & operator=( const BookmarkEntityAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class CStringAtom: public Record
+{
+public:
+ static const unsigned int id;
+ CStringAtom();
+ ~CStringAtom();
+
+ UString ustring() const;
+ void setUString( const UString& ustr );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "CStringAtom"; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ CStringAtom( const CStringAtom& );
+ CStringAtom& operator=( const CStringAtom& );
+
+ class Private;
+ Private *d;
+};
+
+class ColorSchemeAtom : public Record
+{
+public:
+ static const unsigned int id;
+ ColorSchemeAtom();
+ ~ColorSchemeAtom();
+
+ int background() const;
+ void setBackground( int background );
+ int textAndLines() const;
+ void setTextAndLines( int textAndLines );
+ int shadows() const;
+ void setShadows( int shadows );
+ int titleText() const;
+ void setTitleText( int titleText );
+ int fills() const;
+ void setFills( int fills );
+ int accent() const;
+ void setAccent( int accent );
+ int accentAndHyperlink() const;
+ void setAccentAndHyperlink ( int accentAndHyperlink );
+ int accentAndFollowedHyperlink() const;
+ void setAccentAndFollowedHyperlink( int accentAndFollowedHyperlink );
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ColorSchemeAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ ColorSchemeAtom ( const ColorSchemeAtom & );
+ ColorSchemeAtom & operator=( const ColorSchemeAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class CurrentUserAtom : public Record
+{
+public:
+ static const unsigned int id;
+ CurrentUserAtom();
+ ~CurrentUserAtom();
+
+ int size() const;
+ void setSize( int size );
+ int magic() const;
+ void setMagic( int magic );
+ int offsetToCurrentEdit() const;
+ void setOffsetToCurrentEdit( int offsetToCurrentEdit );
+ int lenUserName() const;
+ void setLenUserName( int lenUserName );
+ int docFileVersion() const;
+ void setDocFileVersion( int docFileVersion );
+ int majorVersion() const;
+ void setMajorVersion( int majorVersion );
+ int minorVersion() const;
+ void setMinorVersion ( int minorVersion );
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ColorSchemeAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ CurrentUserAtom ( const CurrentUserAtom & );
+ CurrentUserAtom & operator=( const CurrentUserAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class DocumentAtom : public Record
+{
+public:
+ static const unsigned int id;
+ DocumentAtom();
+ ~DocumentAtom();
+
+ int slideWidth() const;
+ void setSlideWidth( int w );
+ int slideHeight() const;
+ void setSlideHeight( int h );
+ int notesWidth() const;
+ void setNotesWidth( int nw );
+ int notesHeight() const;
+ void setNotesHeight( int nh );
+ int zoomNumer() const;
+ void setZoomNumer( int numer );
+ int zoomDenom() const;
+ void setZoomDenom( int denom );
+
+ int notesMasterPersist() const;
+ void setNotesMasterPersist( int notesMasterPersist );
+
+ int handoutMasterPersist() const;
+ void setHandoutMasterPersist(int handoutMasterPersist);
+
+ int firstSlideNum() const;
+ void setFirstSlideNum( int firstSlideNum );
+
+ int slideSizeType() const;
+ void setSlideSizeType( int slideSizeType );
+
+ int saveWithFonts() const;
+ void setSaveWithFonts( int saveWithFonts );
+
+ int omitTitlePlace() const;
+ void setOmitTitlePlace( int omitTitlePlace );
+
+ int rightToLeft() const;
+ void setRightToLeft( int rightToLeft );
+
+ int showComments() const;
+ void setShowComments( int showComments);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "DocumentAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ DocumentAtom ( const DocumentAtom & );
+ DocumentAtom & operator=( const DocumentAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class EndDocumentAtom: public Record
+{
+public:
+ static const unsigned int id;
+ EndDocumentAtom();
+ const char* name(){ return "EndDocumentAtom"; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ EndDocumentAtom( const EndDocumentAtom& );
+ EndDocumentAtom& operator=( const EndDocumentAtom& );
+};
+
+class ExObjListAtom : public Record
+{
+public:
+ static const unsigned int id;
+ ExObjListAtom();
+ ~ExObjListAtom();
+
+ int objectIdSeed() const;
+ void setObjectIdSeed( int objectIdSeed );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ExObjListAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ ExObjListAtom ( const ExObjListAtom & );
+ ExObjListAtom & operator=( const ExObjListAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class ExHyperlinkAtom : public Record
+{
+public:
+ static const unsigned int id;
+ ExHyperlinkAtom ();
+ ~ExHyperlinkAtom ();
+
+ int objID() const;
+ void setObjID (int objID);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ExHyperlinkAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ ExHyperlinkAtom ( const ExHyperlinkAtom & );
+ ExHyperlinkAtom & operator=( const ExHyperlinkAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class ExLinkAtom : public Record
+{
+public:
+ static const unsigned int id;
+ ExLinkAtom();
+ ~ExLinkAtom();
+
+ int exObjId() const;
+ void setExObjId( int exObjId);
+ int flags() const;
+ void setFlags( int flags);
+ int unavailable() const;
+ void setUnavailable( int unavailable);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ExLinkAtom"; }
+ void dump( std::ostream& out ) const;
+private:
+ // no copy or assign
+ ExLinkAtom ( const ExLinkAtom & );
+ ExLinkAtom & operator=( const ExLinkAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class ExOleObjAtom : public Record
+{
+public:
+ static const unsigned int id;
+ ExOleObjAtom ();
+ ~ExOleObjAtom ();
+
+ int drawAspect() const;
+ void setDrawAspect(int drawAspect);
+ int type() const;
+ void setType(int type);
+ int objID() const;
+ void setObjID(int objID);
+ int subType() const;
+ void setSubType(int subType);
+ int objStgDataRef() const;
+ void setObjStgDataRef(int objStgDataRef);
+ int isBlank() const;
+ void setIsBlank(int isBlank);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ExOleObjAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ ExOleObjAtom ( const ExOleObjAtom & );
+ ExOleObjAtom & operator=( const ExOleObjAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class ExEmbedAtom : public Record
+{
+public:
+ static const unsigned int id;
+ ExEmbedAtom ();
+ ~ExEmbedAtom ();
+
+ int followColorScheme() const;
+ void setFollowColorScheme(int followColorScheme);
+ int cantLockServerB() const;
+ void setCantLockServerB(int cantLockServerB);
+ int noSizeToServerB() const;
+ void setNoSizeToServerB(int noSizeToServerB);
+ int isTable() const;
+ void setIsTable(int isTable);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ExEmbedAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ ExEmbedAtom ( const ExEmbedAtom & );
+ ExEmbedAtom & operator=( const ExEmbedAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class FontEntityAtom : public Record
+{
+public:
+ static const unsigned int id;
+ FontEntityAtom();
+ ~FontEntityAtom();
+
+ UString ustring() const;
+ void setUString( const UString& ustr );
+ int charset() const;
+ void setCharset( int charset ) ;
+ int clipPrecision() const;
+ void setClipPrecision( int clipPrecision);
+ int quality() const;
+ void setQuality( int quality );
+ int pitchAndFamily() const;
+ void setPitchAndFamily( int pitchAndFamily );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "FontEntityAtom"; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ FontEntityAtom ( const FontEntityAtom & );
+ FontEntityAtom & operator=( const FontEntityAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class GuideAtom : public Record
+{
+public:
+ static const unsigned int id;
+ GuideAtom ();
+ ~GuideAtom ();
+
+ int type() const;
+ void setType(int type);
+ int pos() const;
+ void setPos(int pos);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "GuideAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ GuideAtom ( const GuideAtom & );
+ GuideAtom & operator=( const GuideAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class HeadersFootersAtom : public Record
+{
+public:
+ static const unsigned int id;
+ HeadersFootersAtom ();
+ ~HeadersFootersAtom ();
+
+ int formatId() const;
+ void setFormatId( int slideId );
+ int flags() const;
+ void setFlags( int flags );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "HeadersFootersAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ HeadersFootersAtom ( const HeadersFootersAtom & );
+ HeadersFootersAtom & operator=( const HeadersFootersAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class NotesAtom : public Record
+{
+public:
+ static const unsigned int id;
+ NotesAtom();
+ ~NotesAtom();
+
+ int slideId() const;
+ void setSlideId( int slideId );
+ int flags() const;
+ void setFlags( int flags );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "NotesAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ NotesAtom ( const NotesAtom & );
+ NotesAtom & operator=( const NotesAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class PersistIncrementalBlockAtom : public Record
+{
+public:
+ static const unsigned int id;
+ PersistIncrementalBlockAtom();
+ ~PersistIncrementalBlockAtom();
+
+ unsigned entryCount() const;
+ unsigned long reference( unsigned index ) const;
+ unsigned long offset( unsigned index ) const;
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "PersistIncrementalBlockAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ PersistIncrementalBlockAtom ( const PersistIncrementalBlockAtom & );
+ PersistIncrementalBlockAtom & operator=( const PersistIncrementalBlockAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class Record1043 : public Record
+{
+public:
+ static const unsigned int id;
+ Record1043 ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "Record1043 "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ Record1043 ( const Record1043 & );
+ Record1043 & operator=( const Record1043 & );
+
+ class Private;
+ Private *d;
+};
+
+class Record1044 : public Record
+{
+public:
+ static const unsigned int id;
+ Record1044 ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "Record1044 "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ Record1044 ( const Record1044 & );
+ Record1044 & operator=( const Record1044 & );
+
+ class Private;
+ Private *d;
+};
+
+class SSlideLayoutAtom : public Record
+{
+public:
+ static const unsigned int id;
+ SSlideLayoutAtom ();
+ ~SSlideLayoutAtom ();
+
+ int geom() const;
+ void setGeom( int geom);
+ int placeholderId() const;
+ void setPlaceholderId( int placeholderId);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "SSlideLayoutAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ SSlideLayoutAtom ( const SSlideLayoutAtom & );
+ SSlideLayoutAtom & operator=( const SSlideLayoutAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class SlideViewInfoAtom : public Record
+{
+public:
+ static const unsigned int id;
+ SlideViewInfoAtom ();
+ ~SlideViewInfoAtom ();
+
+ int showGuides() const;
+ void setShowGuides( int showGuides);
+ int snapToGrid() const;
+ void setSnapToGrid( int snapToGrid);
+ int snapToShape() const;
+ void setSnapToShape( int snapToShape);
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "SlideViewInfoAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ SlideViewInfoAtom ( const SlideViewInfoAtom & );
+ SlideViewInfoAtom & operator=( const SlideViewInfoAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class SlidePersistAtom : public Record
+{
+public:
+ static const unsigned int id;
+ SlidePersistAtom ();
+ virtual ~SlidePersistAtom ();
+
+ int psrReference() const;
+ void setPsrReference( int psrReference );
+ int flags() const;
+ void setFlags( int flags );
+ int numberTexts() const;
+ void setNumberTexts( int numberTexts );
+ int slideId() const;
+ void setSlideId( int slideId );
+ int reserved() const;
+ void setReserved(int reserved);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "SlidePersistAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ SlidePersistAtom ( const SlidePersistAtom & );
+ SlidePersistAtom & operator=( const SlidePersistAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class SSDocInfoAtom : public Record
+{
+public:
+ static const unsigned int id;
+ SSDocInfoAtom ();
+ ~SSDocInfoAtom ();
+
+ int penColorRed() const;
+ void setPenColorRed( int penColorRed );
+ int penColorGreen() const;
+ void setPenColorGreen( int penColorGreen );
+ int penColorBlue() const;
+ void setPenColorBlue( int penColorBlue );
+ int penColorIndex() const;
+ void setPenColorIndex( int penColorIndex );
+ int restartTime() const;
+ void setRestartTime( int restartTime );
+ int startSlide() const;
+ void setStartSlide( int startSlide );
+ int endSlide() const;
+ void setEndSlide( int endSlide );
+ int namedShow() const;
+ void setNamedShow(int namedShow);
+ int flags() const;
+ void setFlags(int flags);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "SSDocInfoAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ SSDocInfoAtom ( const SSDocInfoAtom & );
+ SSDocInfoAtom & operator=( const SSDocInfoAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class StyleTextPropAtom : public Record
+{
+public:
+ static const unsigned int id;
+ StyleTextPropAtom ();
+ ~StyleTextPropAtom ();
+
+ // paragraph properties
+ int charCount( unsigned index ) const;
+ int depth( unsigned index ) const;
+ int bulletOn ( unsigned index ) const;
+ int bulletHardFont( unsigned index ) const;
+ int bulletHardColor( unsigned index ) const;
+ int bulletChar ( unsigned index ) const;
+ int bulletFont( unsigned index ) const;
+ int bulletHeight( unsigned index ) const;
+ int bulletColor( unsigned index ) const;
+ int align( unsigned index ) const;
+ int lineFeed( unsigned index ) const;
+ int upperDist( unsigned index ) const;
+ int lowerDist( unsigned index ) const;
+ int asianLB1( unsigned index ) const;
+ int asianLB2( unsigned index ) const;
+ int asianLB3( unsigned index ) const;
+ int biDi( unsigned index ) const;
+
+// character properties
+ int charMask() const;
+ int charFlags() const;
+
+ unsigned listSize() const;
+
+ void setData( unsigned size, const unsigned char* data, unsigned lastSize );
+ const char* name(){ return "StyleTextPropAtom "; }
+ void dump( std::ostream& out ) const;
+private:
+ // character properties
+ void setCharMask ( int charMask );
+ void setCharFlags( int charFlags );
+
+ // no copy or assign
+ StyleTextPropAtom ( const StyleTextPropAtom & );
+ StyleTextPropAtom & operator=( const StyleTextPropAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class SlideAtom: public Record
+{
+public:
+ static const unsigned int id;
+ SlideAtom();
+ ~SlideAtom();
+
+ int layoutGeom() const;
+ void setLayoutGeom( int layoutGeom );
+ // see OEPlaceHolderAtom
+ int layoutPlaceholderId() const;
+ // void setLayoutPlaceholderId(int layoutPlaceholderId);
+ void setLayoutPlaceholderId(int layoutPlaceholderId1, int layoutPlaceholderId2,int layoutPlaceholderId3,int layoutPlaceholderId4,int layoutPlaceholderId5,int layoutPlaceholderId6,int layoutPlaceholderId7,int layoutPlaceholderId8);
+ int masterId() const;
+ void setMasterId( int masterId );
+ int notesId() const;
+ void setNotesId( int notesId );
+ int flags() const;
+ void setFlags( int flags );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "SlideAtom"; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ SlideAtom( const SlideAtom& );
+ SlideAtom& operator=( const SlideAtom& );
+
+ class Private;
+ Private *d;
+};
+
+class SSSlideInfoAtom: public Record
+{
+public:
+ static const unsigned int id;
+ SSSlideInfoAtom();
+ ~SSSlideInfoAtom();
+
+ int transType() const;
+ void settransType( int transType );
+ int speed() const;
+ void setspeed(int speed);
+ int direction() const;
+ void setdirection( int direction );
+ int slideTime() const;
+ void setslideTime( int slideTime );
+ int buildFlags() const;
+ void setbuildFlags( int buildFlags );
+ int soundRef() const;
+ void setsoundRef( int soundRef );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "SSSlideInfoAtom"; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ SSSlideInfoAtom( const SSSlideInfoAtom& );
+ SSSlideInfoAtom& operator=( const SSSlideInfoAtom& );
+
+ class Private;
+ Private *d;
+};
+
+class SrKinsokuAtom : public Record
+{
+public:
+ static const unsigned int id;
+ SrKinsokuAtom ();
+ ~SrKinsokuAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "SrKinsokuAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ SrKinsokuAtom ( const SrKinsokuAtom & );
+ SrKinsokuAtom & operator=( const SrKinsokuAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class TxMasterStyleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TxMasterStyleAtom();
+ ~TxMasterStyleAtom();
+
+ const char* name(){ return "TxMasterStyleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TxMasterStyleAtom ( const TxMasterStyleAtom & );
+ TxMasterStyleAtom & operator=( const TxMasterStyleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class TxCFStyleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TxCFStyleAtom ();
+ ~TxCFStyleAtom ();
+
+ int flags1() const;
+ void setFlags1( int flags1 );
+ int flags2() const;
+ void setFlags2( int flags2 );
+ int flags3() const;
+ void setFlags3( int flags3 );
+ int n1() const;
+ void setN1( int n1 );
+ int fontHeight() const;
+ void setFontHeight( int fontHeight );
+ int fontColor() const;
+ void setFontColor( int fontColor );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "TxCFStyleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TxCFStyleAtom ( const TxCFStyleAtom & );
+ TxCFStyleAtom & operator=( const TxCFStyleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+
+class TextCharsAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TextCharsAtom ();
+ ~TextCharsAtom ();
+
+ unsigned listSize() const;
+ UString strValue( unsigned index ) const;
+ void setText( UString ustring );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "TextCharsAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TextCharsAtom ( const TextCharsAtom & );
+ TextCharsAtom & operator=( const TextCharsAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class TxPFStyleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TxPFStyleAtom ();
+ ~TxPFStyleAtom ();
+
+ const char* name(){ return "TxPFStyleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TxPFStyleAtom ( const TxPFStyleAtom & );
+ TxPFStyleAtom & operator=( const TxPFStyleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class TxSIStyleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TxSIStyleAtom ();
+ ~TxSIStyleAtom ();
+
+ const char* name(){ return "TxSIStyleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TxSIStyleAtom ( const TxSIStyleAtom & );
+ TxSIStyleAtom & operator=( const TxSIStyleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class TextHeaderAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TextHeaderAtom ();
+ ~TextHeaderAtom ();
+
+ int textType() const;
+ void setTextType( int type );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "TextHeaderAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TextHeaderAtom ( const TextHeaderAtom & );
+ TextHeaderAtom & operator=( const TextHeaderAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class TextSpecInfoAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TextSpecInfoAtom ();
+ ~TextSpecInfoAtom ();
+
+ int charCount() const;
+ void setCharCount( int txSpecInfo );
+ int flags() const;
+ void setFlags( int flags );
+
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "TextSpecInfoAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TextSpecInfoAtom ( const TextSpecInfoAtom & );
+ TextSpecInfoAtom & operator=( const TextSpecInfoAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class TextBookmarkAtom: public Record
+{
+public:
+ static const unsigned int id;
+ TextBookmarkAtom();
+ ~TextBookmarkAtom();
+
+ int begin() const;
+ void setBegin( int begin );
+ int end() const;
+ void setEnd( int end );
+ int bookmarkID() const;
+ void setBookmarkID( int bookmarkID );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "TextBookmarkAtom"; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TextBookmarkAtom( const TextBookmarkAtom& );
+ TextBookmarkAtom& operator=( const TextBookmarkAtom& );
+
+ class Private;
+ Private *d;
+};
+
+class TextBytesAtom : public Record
+{
+public:
+ static const unsigned int id;
+ TextBytesAtom ();
+ ~TextBytesAtom ();
+
+ unsigned listSize() const;
+ unsigned stringLength() const;
+ void setStringLength( unsigned stringLength );
+
+ UString strValue( unsigned index ) const;
+ void setText( UString ustring );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "TextBytesAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ TextBytesAtom ( const TextBytesAtom & );
+ TextBytesAtom & operator=( const TextBytesAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class UserEditAtom: public Record
+{
+public:
+ static const unsigned int id;
+ UserEditAtom();
+ ~UserEditAtom();
+
+ int lastSlideId() const;
+ void setLastSlideId( int id );
+ int majorVersion() const;
+ void setMajorVersion( int majorVersion );
+ int minorVersion() const;
+ void setMinorVersion( int minorVersion );
+
+ unsigned long offsetLastEdit() const;
+ void setOffsetLastEdit( unsigned long ofs );
+ unsigned long offsetPersistDir() const;
+ void setOffsetPersistDir( unsigned long ofs ) const;
+ unsigned long documentRef() const;
+ void setDocumentRef( unsigned long ref ) const;
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "UserEditAtom"; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ UserEditAtom( const UserEditAtom& );
+ UserEditAtom& operator=( const UserEditAtom& );
+
+ class Private;
+ Private *d;
+};
+
+class ViewInfoAtom : public Record
+{
+public:
+ static const unsigned int id;
+ ViewInfoAtom ();
+ ~ViewInfoAtom ();
+
+ int curScaleXNum() const;
+ void setCurScaleXNum( int curScaleXNum);
+ int curScaleXDen() const;
+ void setCurScaleXDen( int curScaleXDen);
+ int curScaleYNum() const;
+ void setCurScaleYNum( int curScaleYNum);
+ int curScaleYDen() const;
+ void setCurScaleYDen( int curScaleYDen);
+ int prevScaleXNum() const;
+ void setPrevScaleXNum( int prevScaleXNum);
+ int prevScaleXDen() const;
+ void setPrevScaleXDen( int prevScaleXDen);
+ int prevScaleYNum() const;
+ void setPrevScaleYNum( int prevScaleYNum);
+ int prevScaleYDen() const;
+ void setPrevScaleYDen( int prevScaleYDen);
+ int viewSizeX() const;
+ void setViewSizeX( int viewSizeX);
+ int viewSizeY() const;
+ void setViewSizeY( int viewSizeY);
+ int originX() const;
+ void setOriginX( int originX);
+ int originY() const;
+ void setOriginY( int originY);
+ int varScale() const;
+ void setVarScale( int varScale);
+ int draftMode() const;
+ void setDraftMode( int draftMode);
+ int padding() const;
+ void setPadding( int padding);
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "ViewInfoAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ ViewInfoAtom ( const ViewInfoAtom & );
+ ViewInfoAtom & operator=( const ViewInfoAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtDgAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtDgAtom ();
+ ~msofbtDgAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtDgAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtDgAtom ( const msofbtDgAtom & );
+ msofbtDgAtom & operator=( const msofbtDgAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtSpgrAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtSpgrAtom ();
+ ~msofbtSpgrAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtSpgrAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtSpgrAtom ( const msofbtSpgrAtom & );
+ msofbtSpgrAtom & operator=( const msofbtSpgrAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtSpAtom : public Record
+{
+public:
+ enum
+ {
+ msosptMin = 0,
+ msosptNotPrimitive = msosptMin,
+ msosptRectangle = 1,
+ msosptRoundRectangle = 2,
+ msosptEllipse = 3,
+ msosptDiamond = 4,
+ msosptIsoscelesTriangle = 5,
+ msosptRightTriangle = 6,
+ msosptParallelogram = 7,
+ msosptTrapezoid = 8,
+ msosptHexagon = 9,
+ msosptOctagon = 10,
+ msosptPlus = 11,
+ msosptStar = 12,
+ msosptArrow = 13,
+ msosptThickArrow = 14,
+ msosptHomePlate = 15,
+ msosptCube = 16,
+ msosptBalloon = 17,
+ msosptSeal = 18,
+ msosptArc = 19,
+ msosptLine = 20,
+ msosptPlaque = 21,
+ msosptCan = 22,
+ msosptDonut = 23,
+ msosptTextSimple = 24,
+ msosptTextOctagon = 25,
+ msosptTextHexagon = 26,
+ msosptTextCurve = 27,
+ msosptTextWave = 28,
+ msosptTextRing = 29,
+ msosptTextOnCurve = 30,
+ msosptTextOnRing = 31,
+ msosptStraightConnector1 = 32,
+ msosptBentConnector2 = 33,
+ msosptBentConnector3 = 34,
+ msosptBentConnector4 = 35,
+ msosptBentConnector5 = 36,
+ msosptCurvedConnector2 = 37,
+ msosptCurvedConnector3 = 38,
+ msosptCurvedConnector4 = 39,
+ msosptCurvedConnector5 = 40,
+ msosptCallout1 = 41,
+ msosptCallout2 = 42,
+ msosptCallout3 = 43,
+ msosptAccentCallout1 = 44,
+ msosptAccentCallout2 = 45,
+ msosptAccentCallout3 = 46,
+ msosptBorderCallout1 = 47,
+ msosptBorderCallout2 = 48,
+ msosptBorderCallout3 = 49,
+ msosptAccentBorderCallout1 = 50,
+ msosptAccentBorderCallout2 = 51,
+ msosptAccentBorderCallout3 = 52,
+ msosptRibbon = 53,
+ msosptRibbon2 = 54,
+ msosptChevron = 55,
+ msosptPentagon = 56,
+ msosptNoSmoking = 57,
+ msosptSeal8 = 58,
+ msosptSeal16 = 59,
+ msosptSeal32 = 60,
+ msosptWedgeRectCallout = 61,
+ msosptWedgeRRectCallout = 62,
+ msosptWedgeEllipseCallout = 63,
+ msosptWave = 64,
+ msosptFoldedCorner = 65,
+ msosptLeftArrow = 66,
+ msosptDownArrow = 67,
+ msosptUpArrow = 68,
+ msosptLeftRightArrow = 69,
+ msosptUpDownArrow = 70,
+ msosptIrregularSeal1 = 71,
+ msosptIrregularSeal2 = 72,
+ msosptLightningBolt = 73,
+ msosptHeart = 74,
+ msosptPictureFrame = 75,
+ msosptQuadArrow = 76,
+ msosptLeftArrowCallout = 77,
+ msosptRightArrowCallout = 78,
+ msosptUpArrowCallout = 79,
+ msosptDownArrowCallout = 80,
+ msosptLeftRightArrowCallout = 81,
+ msosptUpDownArrowCallout = 82,
+ msosptQuadArrowCallout = 83,
+ msosptBevel = 84,
+ msosptLeftBracket = 85,
+ msosptRightBracket = 86,
+ msosptLeftBrace = 87,
+ msosptRightBrace = 88,
+ msosptLeftUpArrow = 89,
+ msosptBentUpArrow = 90,
+ msosptBentArrow = 91,
+ msosptSeal24 = 92,
+ msosptStripedRightArrow = 93,
+ msosptNotchedRightArrow = 94,
+ msosptBlockArc = 95,
+ msosptSmileyFace = 96,
+ msosptVerticalScroll = 97,
+ msosptHorizontalScroll = 98,
+ msosptCircularArrow = 99,
+ msosptNotchedCircularArrow = 100,
+ msosptUturnArrow = 101,
+ msosptCurvedRightArrow = 102,
+ msosptCurvedLeftArrow = 103,
+ msosptCurvedUpArrow = 104,
+ msosptCurvedDownArrow = 105,
+ msosptCloudCallout = 106,
+ msosptEllipseRibbon = 107,
+ msosptEllipseRibbon2 = 108,
+ msosptFlowChartProcess = 109,
+ msosptFlowChartDecision = 110,
+ msosptFlowChartInputOutput = 111,
+ msosptFlowChartPredefinedProcess = 112,
+ msosptFlowChartInternalStorage = 113,
+ msosptFlowChartDocument = 114,
+ msosptFlowChartMultidocument = 115,
+ msosptFlowChartTerminator = 116,
+ msosptFlowChartPreparation = 117,
+ msosptFlowChartManualInput = 118,
+ msosptFlowChartManualOperation = 119,
+ msosptFlowChartConnector = 120,
+ msosptFlowChartPunchedCard = 121,
+ msosptFlowChartPunchedTape = 122,
+ msosptFlowChartSummingJunction = 123,
+ msosptFlowChartOr = 124,
+ msosptFlowChartCollate = 125,
+ msosptFlowChartSort = 126,
+ msosptFlowChartExtract = 127,
+ msosptFlowChartMerge = 128,
+ msosptFlowChartOfflineStorage = 129,
+ msosptFlowChartOnlineStorage = 130,
+ msosptFlowChartMagneticTape = 131,
+ msosptFlowChartMagneticDisk = 132,
+ msosptFlowChartMagneticDrum = 133,
+ msosptFlowChartDisplay = 134,
+ msosptFlowChartDelay = 135,
+ msosptTextPlainText = 136,
+ msosptTextStop = 137,
+ msosptTextTriangle = 138,
+ msosptTextTriangleInverted = 139,
+ msosptTextChevron = 140,
+ msosptTextChevronInverted = 141,
+ msosptTextRingInside = 142,
+ msosptTextRingOutside = 143,
+ msosptTextArchUpCurve = 144,
+ msosptTextArchDownCurve = 145,
+ msosptTextCircleCurve = 146,
+ msosptTextButtonCurve = 147,
+ msosptTextArchUpPour = 148,
+ msosptTextArchDownPour = 149,
+ msosptTextCirclePour = 150,
+ msosptTextButtonPour = 151,
+ msosptTextCurveUp = 152,
+ msosptTextCurveDown = 153,
+ msosptTextCascadeUp = 154,
+ msosptTextCascadeDown = 155,
+ msosptTextWave1 = 156,
+ msosptTextWave2 = 157,
+ msosptTextWave3 = 158,
+ msosptTextWave4 = 159,
+ msosptTextInflate = 160,
+ msosptTextDeflate = 161,
+ msosptTextInflateBottom = 162,
+ msosptTextDeflateBottom = 163,
+ msosptTextInflateTop = 164,
+ msosptTextDeflateTop = 165,
+ msosptTextDeflateInflate = 166,
+ msosptTextDeflateInflateDeflate = 167,
+ msosptTextFadeRight = 168,
+ msosptTextFadeLeft = 169,
+ msosptTextFadeUp = 170,
+ msosptTextFadeDown = 171,
+ msosptTextSlantUp = 172,
+ msosptTextSlantDown = 173,
+ msosptTextCanUp = 174,
+ msosptTextCanDown = 175,
+ msosptFlowChartAlternateProcess = 176,
+ msosptFlowChartOffpageConnector = 177,
+ msosptCallout90 = 178,
+ msosptAccentCallout90 = 179,
+ msosptBorderCallout90 = 180,
+ msosptAccentBorderCallout90 = 181,
+ msosptLeftRightUpArrow = 182,
+ msosptSun = 183,
+ msosptMoon = 184,
+ msosptBracketPair = 185,
+ msosptBracePair = 186,
+ msosptSeal4 = 187,
+ msosptDoubleWave = 188,
+ msosptActionButtonBlank = 189,
+ msosptActionButtonHome = 190,
+ msosptActionButtonHelp = 191,
+ msosptActionButtonInformation = 192,
+ msosptActionButtonForwardNext = 193,
+ msosptActionButtonBackPrevious = 194,
+ msosptActionButtonEnd = 195,
+ msosptActionButtonBeginning = 196,
+ msosptActionButtonReturn = 197,
+ msosptActionButtonDocument = 198,
+ msosptActionButtonSound = 199,
+ msosptActionButtonMovie = 200,
+ msosptHostControl = 201,
+ msosptTextBox = 202,
+ msosptMax,
+ msosptNil = 0x0FFF
+ } ;
+
+ static const unsigned int id;
+ msofbtSpAtom ();
+ ~msofbtSpAtom ();
+
+ unsigned long shapeId() const;
+ void setShapeId( unsigned long id );
+ const char* shapeTypeAsString() const;
+ unsigned long persistentFlag() const;
+ void setPersistentFlag( unsigned long persistentFlag );
+
+ bool isBackground() const;
+ void setBackground( bool bg );
+ bool isVerFlip() const;
+ void setVerFlip( bool vFlip );
+ bool isHorFlip() const;
+ void setHorFlip( bool hFlip );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtSpAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtSpAtom ( const msofbtSpAtom & );
+ msofbtSpAtom & operator=( const msofbtSpAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtOPTAtom : public Record
+{
+public:
+ enum { // PID
+ Rotation = 4,
+ FillType = 384,
+ FillColor = 385,
+ LineColor = 448,
+ LineOpacity = 449,
+ LineBackColor = 450,
+ LineType = 452,
+ LineWidth = 459,
+ LineDashing = 462,
+ LineStartArrowhead = 464,
+ LineEndArrowhead = 465,
+ LineStartArrowWidth = 466,
+ LineStartArrowLength = 467,
+ LineEndArrowWidth = 468,
+ LineEndArrowLength = 469,
+ FlagNoLineDrawDash = 511,
+ ShadowColor = 513,
+ ShadowOpacity = 516,
+ ShadowOffsetX = 517,
+ ShadowOffsetY = 518
+ };
+
+ enum {
+ FillSolid, // Fill with a solid color
+ FillPattern, // Fill with a pattern (bitmap)
+ FillTexture, // A texture (pattern with its own color map)
+ FillPicture, // Center a picture in the shape
+ FillShade, // Shade from start to end points
+ FillShadeCenter, // Shade from bounding rectangle to end point
+ FillShadeShape, // Shade from shape outline to end point
+ FillShadeScale, // Similar to msofillShade, but the fillAngle
+ FillShadeTitle, // special type - shade to title --- for PP
+ FillBackground // Use the background fill color/pattern
+ }; // MSOFILLTYPE
+
+ enum {
+ LineSolid, // Solid (continuous) pen 0
+ LineDashSys, // PS_DASH system dash style 1
+ LineDotSys, // PS_DOT system dash style 2
+ LineDashDotSys, // PS_DASHDOT system dash style 3
+ LineDashDotDotSys, // PS_DASHDOTDOT system dash style 4
+ LineDotGEL, // square dot style 5
+ LineDashGEL, // dash style 6
+ LineLongDashGEL, // long dash style 7
+ LineDashDotGEL, // dash short dash 8
+ LineLongDashDotGEL, // long dash short dash 9
+ LineLongDashDotDotGEL // long dash short dash short dash 10
+ }; // MSOLINEDASHING
+
+
+ enum {
+ LineNoEnd,
+ LineArrowEnd,
+ LineArrowStealthEnd,
+ LineArrowDiamondEnd,
+ LineArrowOvalEnd,
+ LineArrowOpenEnd
+ }; // MSOLINEEND - line end effect
+
+
+ enum {
+ LineNarrowArrow,
+ LineMediumWidthArrow,
+ LineWideArrow
+ }; // MSOLINEENDWIDTH - size of arrowhead
+
+ enum {
+ LineShortArrow,
+ LineMediumLenArrow,
+ LineLongArrow
+ }; // MSOLINEENDLENGTH - size of arrowhead
+
+ static const unsigned int id;
+ msofbtOPTAtom ();
+ ~msofbtOPTAtom ();
+
+ unsigned propertyCount() const;
+ unsigned propertyId( unsigned index ) const;
+ unsigned long propertyValue( unsigned index ) const;
+ void setProperty( unsigned id, unsigned long value );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtOPTAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtOPTAtom ( const msofbtOPTAtom & );
+ msofbtOPTAtom & operator=( const msofbtOPTAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtChildAnchorAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtChildAnchorAtom ();
+ ~msofbtChildAnchorAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtChildAnchorAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtChildAnchorAtom ( const msofbtChildAnchorAtom & );
+ msofbtChildAnchorAtom & operator=( const msofbtChildAnchorAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtClientAnchorAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtClientAnchorAtom ();
+ ~msofbtClientAnchorAtom ();
+
+ int left() const;
+ void setLeft( int left );
+ int top() const;
+ void setTop( int top );
+ int right() const;
+ void setRight( int right );
+ int bottom() const;
+ void setBottom( int bottom );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtClientAnchorAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtClientAnchorAtom ( const msofbtClientAnchorAtom & );
+ msofbtClientAnchorAtom & operator=( const msofbtClientAnchorAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtClientDataAtom : public Record
+{
+public:
+ enum
+ { None = 0,
+ MasterTitle,
+ MasterBody,
+ MasterCenteredTitle,
+ MasterNotesSlideImage,
+ MasterNotesBodyImage,
+ MasterDate,
+ MasterSlideNumber,
+ MasterFooter,
+ MasterHeader,
+ MasterSubtitle,
+ Generic,
+ Title,
+ Body,
+ NotesBody,
+ CenteredTitle,
+ Subtitle,
+ VerticalTextTitle,
+ VerticalTextBody,
+ NotesSlideImage,
+ Object,
+ Graph,
+ Table,
+ ClipArt,
+ OrganizationChart,
+ MediaClip
+ };
+
+ static const unsigned int id;
+ msofbtClientDataAtom ();
+ ~msofbtClientDataAtom ();
+
+ unsigned placementId() const;
+ void setPlacementId( unsigned id );
+ unsigned placeholderId() const;
+ void setPlaceholderId( unsigned id );
+ const char* placeholderIdAsString() const;
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtClientDataAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtClientDataAtom ( const msofbtClientDataAtom & );
+ msofbtClientDataAtom & operator=( const msofbtClientDataAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtClientTextboxAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtClientTextboxAtom ();
+ ~msofbtClientTextboxAtom ();
+
+ UString ustring() const;
+ void setUString( const UString& ustr );
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtClientTextboxAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtClientTextboxAtom ( const msofbtClientTextboxAtom & );
+ msofbtClientTextboxAtom & operator=( const msofbtClientTextboxAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtOleObjectAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtOleObjectAtom ();
+ ~msofbtOleObjectAtom ();
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtOleObjectAtom "; }
+ void dump( std::ostream& out ) const;
+private:
+ // no copy or assign
+ msofbtOleObjectAtom ( const msofbtOleObjectAtom & );
+ msofbtOleObjectAtom & operator=( const msofbtOleObjectAtom & );
+ class Private;
+ Private *d;
+};
+
+class msofbtDeletedPsplAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtDeletedPsplAtom ();
+ ~msofbtDeletedPsplAtom ();
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtDeletedPsplAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtDeletedPsplAtom ( const msofbtDeletedPsplAtom & );
+ msofbtDeletedPsplAtom & operator=( const msofbtDeletedPsplAtom & );
+ class Private;
+ Private *d;
+
+};
+
+class msofbtDggAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtDggAtom ();
+ ~msofbtDggAtom ();
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtDggAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtDggAtom ( const msofbtDggAtom & );
+ msofbtDggAtom & operator=( const msofbtDggAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtColorMRUAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtColorMRUAtom ();
+ ~msofbtColorMRUAtom ();
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtColorMRUAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtColorMRUAtom ( const msofbtColorMRUAtom & );
+ msofbtColorMRUAtom & operator=( const msofbtColorMRUAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtSplitMenuColorsAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtSplitMenuColorsAtom ();
+ ~msofbtSplitMenuColorsAtom ();
+
+ unsigned fillColor() const;
+ void setFillColor( unsigned fillColor );
+ unsigned lineColor() const;
+ void setLineColor( unsigned lineColor );
+ unsigned shadowColor() const;
+ void setShadowColor( unsigned shadowColor );
+ unsigned threeDColor() const;
+ void setThreeDColor( unsigned threeDColor );
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtSplitMenuColorsAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtSplitMenuColorsAtom ( const msofbtSplitMenuColorsAtom & );
+ msofbtSplitMenuColorsAtom & operator=( const msofbtSplitMenuColorsAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtBSEAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtBSEAtom ();
+ ~msofbtBSEAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtBSEAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtBSEAtom ( const msofbtBSEAtom & );
+ msofbtBSEAtom & operator=( const msofbtBSEAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtCLSIDAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtCLSIDAtom ();
+ ~msofbtCLSIDAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtCLSIDAtom "; }
+ void dump( std::ostream& out ) const;
+
+
+private:
+ // no copy or assign
+ msofbtCLSIDAtom ( const msofbtCLSIDAtom & );
+ msofbtCLSIDAtom & operator=( const msofbtCLSIDAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtRegroupItemsAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtRegroupItemsAtom ();
+ ~msofbtRegroupItemsAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtRegroupItemsAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtRegroupItemsAtom ( const msofbtRegroupItemsAtom & );
+ msofbtRegroupItemsAtom & operator=( const msofbtRegroupItemsAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtColorSchemeAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtColorSchemeAtom ();
+ ~msofbtColorSchemeAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtColorSchemeAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtColorSchemeAtom ( const msofbtColorSchemeAtom & );
+ msofbtColorSchemeAtom & operator=( const msofbtColorSchemeAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtAnchorAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtAnchorAtom ();
+ ~msofbtAnchorAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtAnchorAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtAnchorAtom ( const msofbtAnchorAtom & );
+ msofbtAnchorAtom & operator=( const msofbtAnchorAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtConnectorRuleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtConnectorRuleAtom ();
+ ~msofbtConnectorRuleAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtConnectorRuleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtConnectorRuleAtom ( const msofbtConnectorRuleAtom & );
+ msofbtConnectorRuleAtom & operator=( const msofbtConnectorRuleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtAlignRuleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtAlignRuleAtom ();
+ ~msofbtAlignRuleAtom ();
+
+ int ruid() const; // rule ID
+ void setRuid( int ruid );
+ int align() const;
+ void setAlign( int align );// alignment
+ int cProxies() const;
+ void setCProxies( int cProxies );// number of shapes governed by rule
+
+ void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtAlignRuleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtAlignRuleAtom ( const msofbtAlignRuleAtom & );
+ msofbtAlignRuleAtom & operator=( const msofbtAlignRuleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtArcRuleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtArcRuleAtom ();
+ ~msofbtArcRuleAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtArcRuleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtArcRuleAtom ( const msofbtArcRuleAtom & );
+ msofbtArcRuleAtom & operator=( const msofbtArcRuleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtClientRuleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtClientRuleAtom ();
+ ~msofbtClientRuleAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtClientRuleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtClientRuleAtom ( const msofbtClientRuleAtom & );
+ msofbtClientRuleAtom & operator=( const msofbtClientRuleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtCalloutRuleAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtCalloutRuleAtom ();
+ ~msofbtCalloutRuleAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtCalloutRuleAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtCalloutRuleAtom ( const msofbtCalloutRuleAtom & );
+ msofbtCalloutRuleAtom & operator=( const msofbtCalloutRuleAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class msofbtSelectionAtom : public Record
+{
+public:
+ static const unsigned int id;
+ msofbtSelectionAtom ();
+ ~msofbtSelectionAtom ();
+
+ // void setData( unsigned size, const unsigned char* data );
+ const char* name(){ return "msofbtSelectionAtom "; }
+ void dump( std::ostream& out ) const;
+
+private:
+ // no copy or assign
+ msofbtSelectionAtom ( const msofbtSelectionAtom & );
+ msofbtSelectionAtom & operator=( const msofbtSelectionAtom & );
+
+ class Private;
+ Private *d;
+};
+
+class PPTReader
+{
+public:
+ PPTReader();
+ virtual ~PPTReader();
+ bool load( Presentation* pr, const char* filename );
+
+protected:
+
+ void loadUserEdit();
+ void loadMaster();
+ void loadSlides();
+ void loadDocument();
+ int indexPersistence( unsigned long offset );
+
+ void loadRecord( Record* parent );
+ void handleRecord( Record* record, int type );
+ void handleContainer( Container* container, int type, unsigned size );
+
+ void handleDocumentAtom( DocumentAtom* r );
+ void handleSlidePersistAtom( SlidePersistAtom* r );
+ void handleTextHeaderAtom( TextHeaderAtom* r );
+ void handleTextCharsAtom( TextCharsAtom* r );
+ void handleTextBytesAtom( TextBytesAtom* r );
+ void handleStyleTextPropAtom ( StyleTextPropAtom* r );
+ void handleColorSchemeAtom( ColorSchemeAtom* r );
+
+ void handleDrawingContainer( msofbtDgContainer* r, unsigned size );
+ void handleEscherGroupContainer( msofbtSpgrContainer* r, unsigned size );
+ void handleSPContainer( msofbtSpContainer* r, unsigned size );
+ void handleEscherGroupAtom( msofbtSpgrAtom* r );
+ void handleEscherSpAtom( msofbtSpAtom* r );
+ void handleEscherPropertiesAtom( msofbtOPTAtom* atom );
+ void handleEscherClientDataAtom( msofbtClientDataAtom* r );
+ void handleEscherClientAnchorAtom( msofbtClientAnchorAtom* r );
+ void handleEscherTextBoxAtom( msofbtClientTextboxAtom* r);
+
+private:
+ // no copy or assign
+ PPTReader( const PPTReader& );
+ PPTReader& operator=( const PPTReader& );
+
+ class Private;
+ Private* d;
+};
+
+}
+
+#endif /* LIBPPT_POWERPOINT */
diff --git a/filters/kpresenter/powerpoint/libppt/presentation.cpp b/filters/kpresenter/powerpoint/libppt/presentation.cpp
new file mode 100644
index 00000000..6aaf7e2b
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/presentation.cpp
@@ -0,0 +1,91 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 "presentation.h"
+#include "slide.h"
+#include "powerpoint.h"
+
+#include <vector>
+
+using namespace Libppt;
+
+class Presentation::Private
+{
+public:
+ Slide* masterSlide;
+ std::vector<Slide*> slides;
+};
+
+Presentation::Presentation()
+{
+ d = new Private;
+ d->masterSlide = 0;
+}
+
+Presentation::~Presentation()
+{
+ clear();
+ delete d;
+}
+
+void Presentation::clear()
+{
+ // FIXME use iterator
+ for( unsigned i=0; i<slideCount(); i++ )
+ delete slide( i );
+ d->slides.clear();
+ delete d->masterSlide;
+ d->masterSlide = 0;
+}
+
+bool Presentation::load( const char* filename )
+{
+ PPTReader* reader = new PPTReader;
+ bool result = reader->load( this, filename );
+ delete reader;
+ return result;
+}
+
+void Presentation::appendSlide( Slide* slide )
+{
+ d->slides.push_back( slide );
+}
+
+unsigned Presentation::slideCount() const
+{
+ return d->slides.size();
+}
+
+Slide* Presentation::slide( unsigned index )
+{
+ if( index >= slideCount() ) return (Slide*)0;
+ return d->slides[index];
+}
+
+
+Slide* Presentation::masterSlide()
+{
+ return d->masterSlide;
+}
+
+void Presentation::setMasterSlide( Slide* masterSlide )
+{
+ delete d->masterSlide;
+ d->masterSlide = masterSlide;
+}
diff --git a/filters/kpresenter/powerpoint/libppt/presentation.h b/filters/kpresenter/powerpoint/libppt/presentation.h
new file mode 100644
index 00000000..78d75823
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/presentation.h
@@ -0,0 +1,86 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 LIBPPT_PRESENTATION
+#define LIBPPT_PRESENTATION
+
+
+namespace Libppt
+{
+
+class Slide;
+
+class Presentation
+{
+public:
+
+ /*
+ * Constructs a new presentation.
+ */
+ Presentation();
+
+ /*
+ * Destroys the presentation.
+ */
+ ~Presentation();
+
+ /*
+ * Clears the presentation, i.e. makes it as if it is just constructed.
+ */
+ void clear();
+
+ /*
+ * Loads the presentation file. Returns false if error occurred.
+ */
+ bool load( const char* filename );
+
+ /*
+ * Appends a new slide.
+ */
+ void appendSlide( Slide* slide );
+
+ /*
+ * Returns the number of slides in this presentation. A newly created
+ * presentation has no slide, i.e. slideCount() returns 0.
+ */
+ unsigned slideCount() const;
+
+ /*
+ * Returns a slide at given index. If index is invalid (e.g. larger
+ * than total number of slides), this function returns NULL.
+ */
+
+ Slide* slide( unsigned index );
+
+ Slide* masterSlide();
+ void setMasterSlide( Slide* master );
+
+private:
+ // no copy or assign
+ Presentation( const Presentation& );
+ Presentation& operator=( const Presentation& );
+
+ class Private;
+ Private* d;
+};
+
+
+}
+
+#endif /* LIBPPT_PRESENTATION */
diff --git a/filters/kpresenter/powerpoint/libppt/slide.cpp b/filters/kpresenter/powerpoint/libppt/slide.cpp
new file mode 100644
index 00000000..e336dc30
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/slide.cpp
@@ -0,0 +1,138 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 "slide.h"
+#include "presentation.h"
+#include "ustring.h"
+#include "objects.h"
+
+#include <vector>
+#include <iostream>
+
+
+using namespace Libppt;
+
+class Slide::Private
+{
+public:
+ Presentation* presentation;
+ UString title;
+ GroupObject* rootObject;
+
+ double pageWidth;
+ double pageHeight;
+};
+
+Slide::Slide( Presentation* pr )
+{
+ d = new Private;
+ d->presentation = pr;
+ d->rootObject = new GroupObject;
+ d->pageWidth = 0.0;
+ d->pageHeight = 0.0;
+}
+
+Slide::~Slide()
+{
+ delete d->rootObject;
+ delete d;
+}
+
+void Slide::clear()
+{
+ d->title = UString::null;
+ setRootObject( 0 );
+ d->rootObject = new GroupObject;
+}
+
+UString Slide::title() const
+{
+ return d->title;
+}
+
+void Slide::setTitle( const UString& t )
+{
+ UChar* s = new UChar[t.length()];
+ int len = 0;
+
+ // filter crazy characters
+ for( int i=0; i<t.length(); i++ )
+ if( t[i] != UChar(11) )
+ s[len++] = t[i];
+
+ d->title = UString( s, len );
+ delete [] s;
+}
+
+GroupObject *Slide::rootObject()
+{
+ return d->rootObject;
+}
+
+void Slide::setRootObject( GroupObject* root )
+{
+ delete d->rootObject;
+ d->rootObject = root;
+}
+
+TextObject* recursiveSearch( GroupObject* group, unsigned placeId )
+{
+ if( group )
+ for( unsigned i=0; i<group->objectCount(); i++ )
+ {
+ Object* object = group->object(i);
+ if( object->isText() )
+ {
+ TextObject* textObject = static_cast<TextObject*>(object);
+ if( textObject)
+ if( textObject->id() == (int)placeId )
+ return textObject;
+ }
+ if( object->isGroup() )
+ return recursiveSearch( static_cast<GroupObject*>(object), placeId );
+ }
+
+ return 0;
+}
+
+
+TextObject* Slide::textObject( unsigned placeId )
+{
+ return recursiveSearch( d->rootObject, placeId );
+}
+
+double Slide::pageWidth() const
+{
+ return d->pageWidth;
+}
+
+void Slide::setPageWidth( double pageWidth )
+{
+ d->pageWidth = pageWidth;
+}
+
+double Slide::pageHeight() const
+{
+ return d->pageHeight;
+}
+
+void Slide::setPageHeight( double pageHeight )
+{
+ d->pageHeight = pageHeight;
+}
diff --git a/filters/kpresenter/powerpoint/libppt/slide.h b/filters/kpresenter/powerpoint/libppt/slide.h
new file mode 100644
index 00000000..d47ba841
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/slide.h
@@ -0,0 +1,61 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 LIBPPT_SLIDE
+#define LIBPPT_SLIDE
+
+#include "ustring.h"
+
+
+namespace Libppt
+{
+
+class Presentation;
+class GroupObject;
+class TextObject;
+
+class Slide
+{
+public:
+ Slide( Presentation* presentation );
+ ~Slide();
+ void clear();
+ UString title() const;
+ void setTitle( const UString& title );
+ GroupObject* rootObject();
+ void setRootObject( GroupObject *);
+ TextObject* textObject( unsigned placeId );
+
+ double pageWidth() const;
+ void setPageWidth( double pageWidth ) ;
+ double pageHeight() const;
+ void setPageHeight( double pageHeight ) ;
+
+private:
+ // no copy or assign
+ Slide( const Slide& );
+ Slide& operator=( const Slide& );
+
+ class Private;
+ Private* d;
+};
+
+}
+
+#endif /* LIBPPT_SLIDE */
diff --git a/filters/kpresenter/powerpoint/libppt/testppt.cpp b/filters/kpresenter/powerpoint/libppt/testppt.cpp
new file mode 100644
index 00000000..5ab9c4d5
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/testppt.cpp
@@ -0,0 +1,42 @@
+/* libppt - library to read PowerPoint presentation
+ Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
+
+ 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 "presentation.h"
+
+#include <iostream>
+
+int main( int argc, char** argv )
+{
+ if( argc < 2 )
+ {
+ std::cout << "Usage:" << std::endl;
+ std::cout << " testppt filename" << std::endl;
+ return -1;
+ }
+
+ char* filename = argv[1];
+
+
+ Libppt::Presentation* p;
+ p = new Libppt::Presentation;
+ p->load( filename );
+ delete p;
+
+ return 0;
+}
diff --git a/filters/kpresenter/powerpoint/libppt/ustring.cpp b/filters/kpresenter/powerpoint/libppt/ustring.cpp
new file mode 100644
index 00000000..b0a44e56
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/ustring.cpp
@@ -0,0 +1,675 @@
+// -*- c-basic-offset: 2 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2000 Harri Porten (porten@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 "ustring.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#define USTRING_SIMPLIFIED
+
+#ifdef USTRING_SIMPLIFIED
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#endif
+
+
+#ifndef USTRING_SIMPLIFIED
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+
+#endif
+
+namespace Libppt {
+#ifdef WORDS_BIGENDIAN
+ unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
+ unsigned char Inf_Bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
+#elif defined(arm)
+ unsigned char NaN_Bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
+ unsigned char Inf_Bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
+#else
+ unsigned char NaN_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
+ unsigned char Inf_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
+#endif
+
+ const double NaN = *( reinterpret_cast<const double*>( NaN_Bytes ) );
+ const double Inf = *( reinterpret_cast<const double*>( Inf_Bytes ) );
+}
+
+using namespace Libppt;
+
+#ifdef USTRING_SIMPLIFIED
+bool Libppt::isNaN(double)
+{
+ return false;
+}
+#else
+bool Libppt::isNaN(double d)
+{
+#ifdef HAVE_FUNC_ISNAN
+ return isnan(d);
+#elif defined HAVE_FLOAT_H
+ return _isnan(d) != 0;
+#else
+ return !(d == d);
+#endif
+}
+#endif
+
+#ifdef USTRING_SIMPLIFIED
+bool Libppt::isPosInf(double)
+{
+ return false;
+}
+#else
+bool Libppt::isPosInf(double d)
+{
+#if defined(HAVE_FUNC_ISINF)
+ return (isinf(d) == 1);
+#elif HAVE_FUNC_FINITE
+ return finite(d) == 0 && d == d; // ### can we distinguish between + and - ?
+#elif HAVE_FUNC__FINITE
+ return _finite(d) == 0 && d == d; // ###
+#else
+ return false;
+#endif
+}
+#endif
+
+#ifdef USTRING_SIMPLIFIED
+bool Libppt::isNegInf(double)
+{
+ return false;
+}
+#else
+bool Libppt::isNegInf(double d)
+{
+#if defined(HAVE_FUNC_ISINF)
+ return (isinf(d) == -1);
+#elif HAVE_FUNC_FINITE
+ return finite(d) == 0 && d == d; // ###
+#elif HAVE_FUNC__FINITE
+ return _finite(d) == 0 && d == d; // ###
+#else
+ return false;
+#endif
+}
+#endif
+
+CString::CString(const char *c)
+{
+ data = new char[strlen(c)+1];
+ strcpy(data, c);
+}
+
+CString::CString(const CString &b)
+{
+ data = new char[b.length()+1];
+ strcpy(data, b.c_str());
+}
+
+CString::~CString()
+{
+ delete [] data;
+}
+
+CString &CString::append(const CString &t)
+{
+ char *n;
+ if (data) {
+ n = new char[strlen(data)+t.length()+1];
+ strcpy(n, data);
+ } else {
+ n = new char[t.length()+1];
+ n[0] = '\0';
+ }
+ strcat(n, t.c_str());
+
+ delete [] data;
+ data = n;
+
+ return *this;
+}
+
+CString &CString::operator=(const char *c)
+{
+ if (data)
+ delete [] data;
+ data = new char[strlen(c)+1];
+ strcpy(data, c);
+
+ return *this;
+}
+
+CString &CString::operator=(const CString &str)
+{
+ if (this == &str)
+ return *this;
+
+ if (data)
+ delete [] data;
+ data = new char[str.length()+1];
+ strcpy(data, str.c_str());
+
+ return *this;
+}
+
+CString &CString::operator+=(const CString &str)
+{
+ return append(CString(str.c_str()));
+}
+
+int CString::length() const
+{
+ return strlen(data);
+}
+
+bool Libppt::operator==(const Libppt::CString& c1, const Libppt::CString& c2)
+{
+ return (strcmp(c1.c_str(), c2.c_str()) == 0);
+}
+
+UChar UChar::null;
+UString::Rep UString::Rep::null = { 0, 0, 1 };
+UString UString::null;
+static char *statBuffer = 0L;
+
+UChar::UChar(const UCharReference &c)
+ : uc( c.unicode() )
+{
+}
+
+UChar UChar::toLower() const
+{
+ // ### properly support unicode tolower
+ if (uc >= 256 || islower(uc))
+ return *this;
+
+ return UChar(tolower(uc));
+}
+
+UChar UChar::toUpper() const
+{
+ if (uc >= 256 || isupper(uc))
+ return *this;
+
+ return UChar(toupper(uc));
+}
+
+UCharReference& UCharReference::operator=(UChar c)
+{
+ str->detach();
+ if (offset < str->rep->len)
+ *(str->rep->dat + offset) = c;
+ /* TODO: lengthen string ? */
+ return *this;
+}
+
+UChar& UCharReference::ref() const
+{
+ if (offset < str->rep->len)
+ return *(str->rep->dat + offset);
+ else
+ return UChar::null;
+}
+
+namespace {
+ // return an uninitialized UChar array of size s
+ static inline UChar* allocateChars(int s)
+ {
+ // work around default UChar constructor code
+ return reinterpret_cast<UChar*>(new short[s]);
+ }
+}
+
+UString::Rep *UString::Rep::create(UChar *d, int l)
+{
+ Rep *r = new Rep;
+ r->dat = d;
+ r->len = l;
+ r->rc = 1;
+
+ return r;
+}
+
+UString::UString()
+{
+ null.rep = &Rep::null;
+ attach(&Rep::null);
+}
+
+UString::UString(char c)
+{
+ UChar *d = allocateChars( 1 );
+ d[0] = UChar(0, c);
+ rep = Rep::create(d, 1);
+}
+
+UString::UString(UChar c)
+{
+ UChar *d = allocateChars( 1 );
+ d[0] = c;
+ rep = Rep::create(d, 1);
+}
+
+UString::UString(const char *c)
+{
+ attach(&Rep::null);
+ operator=(c);
+}
+
+UString::UString(const UChar *c, int length)
+{
+ UChar *d = allocateChars( length );
+ memcpy(d, c, length * sizeof(UChar));
+ rep = Rep::create(d, length);
+}
+
+UString::UString(UChar *c, int length, bool copy)
+{
+ UChar *d;
+ if (copy) {
+ d = allocateChars( length );
+ memcpy(d, c, length * sizeof(UChar));
+ } else
+ d = c;
+ rep = Rep::create(d, length);
+}
+
+UString::UString(const UString &b)
+{
+ attach(b.rep);
+}
+
+UString::~UString()
+{
+ release();
+}
+
+UString UString::from(int i)
+{
+ char buf[40];
+ sprintf(buf, "%d", i);
+
+ return UString(buf);
+}
+
+UString UString::from(unsigned int u)
+{
+ char buf[40];
+ sprintf(buf, "%u", u);
+
+ return UString(buf);
+}
+
+UString UString::from(double d)
+{
+ char buf[40];
+
+ if (d == -0)
+ strcpy(buf,"0");
+ else if (isNaN(d))
+ strcpy(buf,"NaN");
+ else if (isPosInf(d))
+ strcpy(buf,"Infinity");
+ else if (isNegInf(d))
+ strcpy(buf,"-Infinity");
+ else
+ sprintf(buf, "%.16g", d); // does the right thing
+
+ // ECMA 3rd ed. 9.8.1 9 e: "with no leading zeros"
+ int buflen = strlen(buf);
+ if (buflen >= 4 && buf[buflen-4] == 'e' && buf[buflen-2] == '0') {
+ buf[buflen-2] = buf[buflen-1];
+ buf[buflen-1] = 0;
+ }
+
+ return UString(buf);
+}
+
+UString &UString::append(const UString &t)
+{
+ int l = length();
+ UChar *n = allocateChars( l+t.length() );
+ memcpy(n, data(), l * sizeof(UChar));
+ memcpy(n+l, t.data(), t.length() * sizeof(UChar));
+ release();
+ rep = Rep::create(n, l + t.length());
+
+ return *this;
+}
+
+CString UString::cstring() const
+{
+ return CString(ascii());
+}
+
+char *UString::ascii() const
+{
+ if (statBuffer)
+ delete [] statBuffer;
+
+ statBuffer = new char[length()+1];
+ for(int i = 0; i < length(); i++)
+ statBuffer[i] = data()[i].low();
+ statBuffer[length()] = '\0';
+
+ return statBuffer;
+}
+
+UString &UString::operator=(const char *c)
+{
+ release();
+ int l = c ? strlen(c) : 0;
+ UChar *d = allocateChars( l );
+ for (int i = 0; i < l; i++)
+ d[i].uc = static_cast<unsigned char>( c[i] );
+ rep = Rep::create(d, l);
+
+ return *this;
+}
+
+UString &UString::operator=(const UString &str)
+{
+ str.rep->ref();
+ release();
+ rep=str.rep;
+
+ return *this;
+}
+
+UString &UString::operator+=(const UString &s)
+{
+ return append(s);
+}
+
+bool UString::is8Bit() const
+{
+ const UChar *u = data();
+ for(int i = 0; i < length(); i++, u++)
+ if (u->uc > 0xFF)
+ return false;
+
+ return true;
+}
+
+UChar UString::operator[](int pos) const
+{
+ if (pos >= length())
+ return UChar::null;
+
+ return static_cast<const UChar *>( data() )[pos];
+}
+
+UCharReference UString::operator[](int pos)
+{
+ /* TODO: boundary check */
+ return UCharReference(this, pos);
+}
+
+double UString::toDouble( bool tolerant ) const
+{
+ double d;
+
+ if (!is8Bit())
+ return NaN;
+
+ CString str = cstring();
+ const char *c = str.c_str();
+
+ // skip leading white space
+ while (isspace(*c))
+ c++;
+
+ // empty string ?
+ if (*c == '\0')
+ return tolerant ? NaN : 0.0;
+
+ // hex number ?
+ if (*c == '0' && (*(c+1) == 'x' || *(c+1) == 'X')) {
+ c++;
+ d = 0.0;
+ while (*(++c)) {
+ if (*c >= '0' && *c <= '9')
+ d = d * 16.0 + *c - '0';
+ else if ((*c >= 'A' && *c <= 'F') || (*c >= 'a' && *c <= 'f'))
+ d = d * 16.0 + (*c & 0xdf) - 'A' + 10.0;
+ else
+ break;
+ }
+ } else {
+ // regular number ?
+ char *end;
+ d = strtod(c, &end);
+ if ((d != 0.0 || end != c) && d != HUGE_VAL && d != -HUGE_VAL) {
+ c = end;
+ } else {
+ // infinity ?
+ d = 1.0;
+ if (*c == '+')
+ c++;
+ else if (*c == '-') {
+ d = -1.0;
+ c++;
+ }
+ if (strncmp(c, "Infinity", 8) != 0)
+ return NaN;
+ d = d * Inf;
+ c += 8;
+ }
+ }
+
+ // allow trailing white space
+ while (isspace(*c))
+ c++;
+ // don't allow anything after - unless tolerant=true
+ if ( !tolerant && *c != '\0')
+ d = NaN;
+
+ return d;
+}
+
+unsigned long UString::toULong(bool *ok) const
+{
+ double d = toDouble();
+ bool b = true;
+
+ if (isNaN(d) || d != static_cast<unsigned long>(d)) {
+ b = false;
+ d = 0;
+ }
+
+ if (ok)
+ *ok = b;
+
+ return static_cast<unsigned long>(d);
+}
+
+int UString::find(const UString &f, int pos) const
+{
+ if (isNull())
+ return -1;
+ long fsize = f.length() * sizeof(UChar);
+ if (pos < 0)
+ pos = 0;
+ const UChar *end = data() + length() - f.length();
+ for (const UChar *c = data() + pos; c <= end; c++)
+ if (!memcmp(c, f.data(), fsize))
+ return (c-data());
+
+ return -1;
+}
+
+int UString::rfind(const UString &f, int pos) const
+{
+ if (isNull())
+ return -1;
+ if (pos + f.length() >= length())
+ pos = length() - f.length();
+ long fsize = f.length() * sizeof(UChar);
+ for (const UChar *c = data() + pos; c >= data(); c--) {
+ if (!memcmp(c, f.data(), fsize))
+ return (c-data());
+ }
+
+ return -1;
+}
+
+UString UString::substr(int pos, int len) const
+{
+ if (isNull())
+ return UString();
+ if (pos < 0)
+ pos = 0;
+ else if (pos >= static_cast<int>( length() ))
+ pos = length();
+ if (len < 0)
+ len = length();
+ if (pos + len >= static_cast<int>( length() ))
+ len = length() - pos;
+
+ UChar *tmp = allocateChars( len );
+ memcpy(tmp, data()+pos, len * sizeof(UChar));
+ UString result(tmp, len);
+ delete [] tmp;
+
+ return result;
+}
+
+void UString::attach(Rep *r)
+{
+ rep = r;
+ rep->ref();
+}
+
+void UString::detach()
+{
+ if (rep->rc > 1) {
+ int l = length();
+ UChar *n = allocateChars( l );
+ memcpy(n, data(), l * sizeof(UChar));
+ release();
+ rep = Rep::create(n, l);
+ }
+}
+
+void UString::release()
+{
+ if (!rep->deref()) {
+ delete [] rep->dat;
+ delete rep;
+ }
+}
+
+bool Libppt::operator==(const UString& s1, const UString& s2)
+{
+ if (s1.rep->len != s2.rep->len)
+ return false;
+
+ return (memcmp(s1.rep->dat, s2.rep->dat,
+ s1.rep->len * sizeof(UChar)) == 0);
+}
+
+bool Libppt::operator==(const UString& s1, const char *s2)
+{
+ if (s2 == 0L && s1.isNull())
+ return true;
+
+ if (s1.length() != static_cast<int>( strlen(s2) ))
+ return false;
+
+ const UChar *u = s1.data();
+ while (*s2) {
+ if (u->uc != *s2 )
+ return false;
+ s2++;
+ u++;
+ }
+
+ return true;
+}
+
+bool Libppt::operator<(const UString& s1, const UString& s2)
+{
+ const int l1 = s1.length();
+ const int l2 = s2.length();
+ const int lmin = l1 < l2 ? l1 : l2;
+ const UChar *c1 = s1.data();
+ const UChar *c2 = s2.data();
+ int l = 0;
+ while (l < lmin && *c1 == *c2) {
+ c1++;
+ c2++;
+ l++;
+ }
+ if (l < lmin)
+ return (c1->unicode() < c2->unicode());
+
+ return (l1 < l2);
+}
+
+UString Libppt::operator+(const UString& s1, const UString& s2)
+{
+ UString tmp(s1);
+ tmp.append(s2);
+
+ return tmp;
+}
+
+
+UConstString::UConstString( UChar* data, unsigned int length ) : UString( data, length, false )
+{
+}
+
+UConstString::~UConstString()
+{
+ if ( rep->rc > 1 ) {
+ int l = length();
+ UChar* n = allocateChars( l );
+ memcpy( n, data(), l * sizeof( UChar ) );
+ rep->dat = n;
+ }
+ else
+ rep->dat = 0;
+}
diff --git a/filters/kpresenter/powerpoint/libppt/ustring.h b/filters/kpresenter/powerpoint/libppt/ustring.h
new file mode 100644
index 00000000..dfadbc7d
--- /dev/null
+++ b/filters/kpresenter/powerpoint/libppt/ustring.h
@@ -0,0 +1,395 @@
+// -*- c-basic-offset: 2 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2000 Harri Porten (porten@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 LIBPPT_USTRING_H_
+#define LIBPPT_USTRING_H_
+
+namespace Libppt {
+
+ /**
+ * @return True if d is not a number (platform support required).
+ */
+ bool isNaN(double d);
+
+ bool isPosInf(double d);
+ bool isNegInf(double d);
+
+ class UCharReference;
+ class UString;
+ class UConstString;
+
+ /**
+ * @short Unicode character.
+ *
+ * UChar represents a 16 bit Unicode character. It's internal data
+ * representation is compatible to XChar2b and QChar. It's therefore
+ * possible to exchange data with X and Qt with shallow copies.
+ */
+ struct UChar {
+ /**
+ * Construct a character with value 0.
+ */
+ UChar();
+ /**
+ * Construct a character with the value denoted by the arguments.
+ * @param h higher byte
+ * @param l lower byte
+ */
+ UChar(unsigned char h , unsigned char l);
+ /**
+ * Construct a character with the given value.
+ * @param u 16 bit Unicode value
+ */
+ UChar(unsigned short u);
+ UChar(const UCharReference &c);
+ /**
+ * @return The higher byte of the character.
+ */
+ unsigned char high() const { return uc >> 8; }
+ /**
+ * @return The lower byte of the character.
+ */
+ unsigned char low() const { return uc & 0xFF; }
+ /**
+ * @return the 16 bit Unicode value of the character
+ */
+ unsigned short unicode() const { return uc; }
+ public:
+ /**
+ * @return The character converted to lower case.
+ */
+ UChar toLower() const;
+ /**
+ * @return The character converted to upper case.
+ */
+ UChar toUpper() const;
+ /**
+ * A static instance of UChar(0).
+ */
+ static UChar null;
+ private:
+ friend class UCharReference;
+ friend class UString;
+ friend bool operator==(const UChar &c1, const UChar &c2);
+ friend bool operator==(const UString& s1, const char *s2);
+ friend bool operator<(const UString& s1, const UString& s2);
+
+ unsigned short uc;
+ };
+
+ inline UChar::UChar() : uc(0) { }
+ inline UChar::UChar(unsigned char h , unsigned char l) : uc(h << 8 | l) { }
+ inline UChar::UChar(unsigned short u) : uc(u) { }
+
+ /**
+ * @short Dynamic reference to a string character.
+ *
+ * UCharReference is the dynamic counterpart of @ref UChar. It's used when
+ * characters retrieved via index from a @ref UString are used in an
+ * assignment expression (and therefore can't be treated as being const):
+ * <pre>
+ * UString s("hello world");
+ * s[0] = 'H';
+ * </pre>
+ *
+ * If that sounds confusing your best bet is to simply forget about the
+ * existance of this class and treat is as being identical to @ref UChar.
+ */
+ class UCharReference {
+ friend class UString;
+ UCharReference(UString *s, unsigned int off) : str(s), offset(off) { }
+ public:
+ /**
+ * Set the referenced character to c.
+ */
+ UCharReference& operator=(UChar c);
+ /**
+ * Same operator as above except the argument that it takes.
+ */
+ UCharReference& operator=(char c) { return operator=(UChar(c)); }
+ /**
+ * @return Unicode value.
+ */
+ unsigned short unicode() const { return ref().unicode(); }
+ /**
+ * @return Lower byte.
+ */
+ unsigned char low() const { return ref().uc & 0xFF; }
+ /**
+ * @return Higher byte.
+ */
+ unsigned char high() const { return ref().uc >> 8; }
+ /**
+ * @return Character converted to lower case.
+ */
+ UChar toLower() const { return ref().toLower(); }
+ /**
+ * @return Character converted to upper case.
+ */
+ UChar toUpper() const { return ref().toUpper(); }
+ private:
+ // not implemented, can only be constructed from UString
+ UCharReference();
+
+ UChar& ref() const;
+ UString *str;
+ int offset;
+ };
+
+ /**
+ * @short 8 bit char based string class
+ */
+ class CString {
+ public:
+ CString() : data(0L) { }
+ explicit CString(const char *c);
+ CString(const CString &);
+
+ ~CString();
+
+ CString &append(const CString &);
+ CString &operator=(const char *c);
+ CString &operator=(const CString &);
+ CString &operator+=(const CString &);
+
+ int length() const;
+ const char *c_str() const { return data; }
+ private:
+ char *data;
+ };
+
+ /**
+ * @short Unicode string class
+ */
+ class UString {
+ friend bool operator==(const UString&, const UString&);
+ friend class UCharReference;
+ friend class UConstString;
+ /**
+ * @internal
+ */
+ struct Rep {
+ friend class UString;
+ friend bool operator==(const UString&, const UString&);
+ static Rep *create(UChar *d, int l);
+ inline UChar *data() const { return dat; }
+ inline int length() const { return len; }
+
+ inline void ref() { rc++; }
+ inline int deref() { return --rc; }
+
+ UChar *dat;
+ int len;
+ int rc;
+ static Rep null;
+ };
+
+ public:
+ /**
+ * Constructs a null string.
+ */
+ UString();
+ /**
+ * Constructs a string from the single character c.
+ */
+ explicit UString(char c);
+ /**
+ * Constructs a string from the single character c.
+ */
+ explicit UString(UChar c);
+ /**
+ * Constructs a string from a classical zero determined char string.
+ */
+ explicit UString(const char *c);
+ /**
+ * Constructs a string from an array of Unicode characters of the specified
+ * length.
+ */
+ UString(const UChar *c, int length);
+ /**
+ * If copy is false a shallow copy of the string will be created. That
+ * means that the data will NOT be copied and you'll have to guarantee that
+ * it doesn't get deleted during the lifetime of the UString object.
+ */
+ UString(UChar *c, int length, bool copy);
+ /**
+ * Copy constructor. Makes a shallow copy only.
+ */
+ UString(const UString &);
+ /**
+ * Destructor. If this handle was the only one holding a reference to the
+ * string the data will be freed.
+ */
+ ~UString();
+
+ /**
+ * Constructs a string from an int.
+ */
+ static UString from(int i);
+ /**
+ * Constructs a string from an unsigned int.
+ */
+ static UString from(unsigned int u);
+ /**
+ * Constructs a string from a double.
+ */
+ static UString from(double d);
+
+ /**
+ * Append another string.
+ */
+ UString &append(const UString &);
+
+ /**
+ * @return The string converted to the 8-bit string type @ref CString().
+ */
+ CString cstring() const;
+ /**
+ * Convert the Unicode string to plain ASCII chars chopping of any higher
+ * bytes. This method should only be used for *debugging* purposes as it
+ * is neither Unicode safe nor free from side effects. In order not to
+ * waste any memory the char buffer is static and *shared* by all UString
+ * instances.
+ */
+ char *ascii() const;
+
+ /**
+ * Assignment operator.
+ */
+ UString &operator=(const char *c);
+ /**
+ * Assignment operator.
+ */
+ UString &operator=(const UString &);
+ /**
+ * Appends the specified string.
+ */
+ UString &operator+=(const UString &s);
+
+ /**
+ * @return A pointer to the internal Unicode data.
+ */
+ const UChar* data() const { return rep->data(); }
+ /**
+ * @return True if null.
+ */
+ bool isNull() const { return (rep == &Rep::null); }
+ /**
+ * @return True if null or zero length.
+ */
+ bool isEmpty() const { return (!rep->len); }
+ /**
+ * Use this if you want to make sure that this string is a plain ASCII
+ * string. For example, if you don't want to lose any information when
+ * using @ref cstring() or @ref ascii().
+ *
+ * @return True if the string doesn't contain any non-ASCII characters.
+ */
+ bool is8Bit() const;
+ /**
+ * @return The length of the string.
+ */
+ int length() const { return rep->length(); }
+ /**
+ * Const character at specified position.
+ */
+ UChar operator[](int pos) const;
+ /**
+ * Writable reference to character at specified position.
+ */
+ UCharReference operator[](int pos);
+
+ /**
+ * Attempts an conversion to a number. Apart from floating point numbers,
+ * the algorithm will recognize hexadecimal representations (as
+ * indicated by a 0x or 0X prefix) and +/- Infinity.
+ * Returns NaN if the conversion failed.
+ * @param tolerant if true, toDouble can tolerate garbage after the number.
+ */
+ double toDouble(bool tolerant=false) const;
+ /**
+ * Attempts an conversion to an unsigned long integer. ok will be set
+ * according to the success.
+ */
+ unsigned long toULong(bool *ok = 0L) const;
+ /**
+ * @return Position of first occurence of f starting at position pos.
+ * -1 if the search was not successful.
+ */
+ int find(const UString &f, int pos = 0) const;
+ /**
+ * @return Position of first occurence of f searching backwards from
+ * position pos.
+ * -1 if the search was not successful.
+ */
+ int rfind(const UString &f, int pos) const;
+ /**
+ * @return The sub string starting at position pos and length len.
+ */
+ UString substr(int pos = 0, int len = -1) const;
+ /**
+ * Static instance of a null string.
+ */
+ static UString null;
+
+ private:
+ void attach(Rep *r);
+ void detach();
+ void release();
+ Rep *rep;
+ };
+
+ inline bool operator==(const UChar &c1, const UChar &c2) {
+ return (c1.uc == c2.uc);
+ }
+ inline bool operator!=(const UChar &c1, const UChar &c2) {
+ return !(c1 == c2);
+ }
+ bool operator==(const UString& s1, const UString& s2);
+ inline bool operator!=(const UString& s1, const UString& s2) {
+ return !Libppt::operator==(s1, s2);
+ }
+ bool operator<(const UString& s1, const UString& s2);
+ bool operator==(const UString& s1, const char *s2);
+ inline bool operator!=(const UString& s1, const char *s2) {
+ return !Libppt::operator==(s1, s2);
+ }
+ inline bool operator==(const char *s1, const UString& s2) {
+ return operator==(s2, s1);
+ }
+ inline bool operator!=(const char *s1, const UString& s2) {
+ return !Libppt::operator==(s1, s2);
+ }
+ bool operator==(const CString& s1, const CString& s2);
+ UString operator+(const UString& s1, const UString& s2);
+
+
+ class UConstString : private UString {
+ public:
+ UConstString( UChar* data, unsigned int length );
+ ~UConstString();
+
+ const UString& string() const { return *this; }
+ };
+
+}
+
+#endif /* LIBPPT_USTRING_H_ */
diff --git a/filters/kpresenter/svg/Makefile.am b/filters/kpresenter/svg/Makefile.am
new file mode 100644
index 00000000..4783e9f8
--- /dev/null
+++ b/filters/kpresenter/svg/Makefile.am
@@ -0,0 +1,21 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ $(all_includes)
+
+####### Files
+kde_module_LTLIBRARIES = libkpresentersvgexport.la
+
+libkpresentersvgexport_la_SOURCES = svgexport.cc
+libkpresentersvgexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined
+libkpresentersvgexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ svgexport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_svg_export.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/svg/kpresenter_svg_export.desktop b/filters/kpresenter/svg/kpresenter_svg_export.desktop
new file mode 100644
index 00000000..be387dc5
--- /dev/null
+++ b/filters/kpresenter/svg/kpresenter_svg_export.desktop
@@ -0,0 +1,52 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter SVG Export Filter
+Name[bg]=Филтър за експортиране от KPresenter в SVG
+Name[br]=Sil ezporzh SVG evit KPresenter
+Name[ca]=Filtre d'exportació SVG per a KPresenter
+Name[cy]=Hidlen Allforio SVG KPresenter
+Name[da]=KPresenter SVG-eksportfilter
+Name[de]=KPresenter SVG-Exportfilter
+Name[el]=Φίλτρο εξαγωγής SVG του KPresenter
+Name[eo]=KPresenter PNG-eksportfiltrilo
+Name[es]=Filtro de exportación a SVG para KPresenter
+Name[et]=KPresenteri SVG ekspordifilter
+Name[fa]=پالایۀ صادرات KPresenter SVG
+Name[fi]=KPresenter SVG -vientisuodin
+Name[fr]=Filtre d'exportation SVG de KPresenter
+Name[fy]=SVG-Eksportfilter foar KPresenter
+Name[ga]=Scagaire Easpórtála SVG KPresenter
+Name[gl]=Filtro de Exportación de SVG para KPresenter
+Name[he]=KPresenter SVG מסנן יצוא
+Name[hr]=KPresenter SVG filtar izvoza
+Name[hu]=KPresenter SVG exportszűrő
+Name[is]=KPresenter SVG útflutningssía
+Name[it]=Filtro di esportazione SVG per KPresenter
+Name[ja]=KPresenter SVG エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ SVG សម្រាប់ KPresenter
+Name[lt]=KPresenter SVG eksportavimo filtras
+Name[lv]=KPresenter SVG eksporta filtrs
+Name[nb]=SVG-eksportfilter for KPresenter
+Name[nds]=SVG-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता एसभीजी निर्यात फिल्टर
+Name[nl]=KPresenter SVG Exportfilter
+Name[pl]=Filtr eksportu do formatu SVG dla KPresenter
+Name[pt]=Filtro de Exportação de SVG para o KPresenter
+Name[pt_BR]=Filtro de Exportação de SVG para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в SVG
+Name[se]=KPresenter SVG-olggosfievrridansilli
+Name[sk]=Exportný filter KPresenter SVG
+Name[sl]=Izvozni filter SVG za KPresenter
+Name[sr]=KPresenter-ов филтер за извоз у SVG
+Name[sr@Latn]=KPresenter-ov filter za izvoz u SVG
+Name[sv]=Kpresenter SVG-exportfilter
+Name[uk]=Фільтр експорту SVG для KPresenter
+Name[uz]=KPresenter SVG eksport filteri
+Name[uz@cyrillic]=KPresenter SVG экспорт филтери
+Name[zh_CN]=KPresenter SVG 导出过滤器
+Name[zh_TW]=KPresenter SVG 匯出過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Export=image/svg+xml
+X-KDE-Weight=1
+X-KDE-Library=libkpresentersvgexport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/svg/svgexport.cc b/filters/kpresenter/svg/svgexport.cc
new file mode 100644
index 00000000..2be6eea1
--- /dev/null
+++ b/filters/kpresenter/svg/svgexport.cc
@@ -0,0 +1,100 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@kde.org>
+ code based on svgexport.cc from Inge Wallin <inge@lysator.liu.se>
+
+ 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 <qpicture.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+//#include <KoStoreDevice.h>
+#include <kgenericfactory.h>
+
+#include "KPrDocument.h"
+#include "KPrView.h"
+#include "KPrCanvas.h"
+
+#include "svgexport.h"
+
+
+typedef KGenericFactory<SvgExport, KoFilter> SvgExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libkpresentersvgexport, SvgExportFactory( "svgexport" ) )
+
+SvgExport::SvgExport(KoFilter *, const char *, const QStringList&)
+ : KoFilter()
+{
+}
+
+SvgExport::~SvgExport()
+{
+}
+
+
+KoFilter::ConversionStatus
+SvgExport::convert(const QCString& from, const QCString& to)
+{
+ KoDocument * document = m_chain->inputDocument();
+
+ if ( !document )
+ return KoFilter::StupidError;
+
+ if ( strcmp(document->className(), "KPrDocument") != 0)
+ {
+ kdWarning() << "document isn't a KPrDocument but a "
+ << document->className() << endl;
+ return KoFilter::NotImplemented;
+ }
+
+ // Check for proper conversion.
+ if ( from != "application/x-kpresenter" || to != "image/svg+xml" )
+ {
+ kdWarning() << "Invalid mimetypes " << to << " " << from << endl;
+ return KoFilter::NotImplemented;
+ }
+ KPrDocument * kpresenterdoc = const_cast<KPrDocument *>(static_cast<const KPrDocument *>(document));
+
+ if ( kpresenterdoc->mimeType() != "application/x-kpresenter" )
+ {
+ kdWarning() << "Invalid document mimetype " << kpresenterdoc->mimeType() << endl;
+ return KoFilter::NotImplemented;
+ }
+ KoPageLayout layoutPage= kpresenterdoc->pageLayout();
+ int width = int( layoutPage.ptWidth );
+ int height = int( layoutPage.ptHeight );
+
+ QPicture picture;
+ QPainter painter(&picture);
+ QRect rect(QPoint(0, 0), QPoint(width, height));
+ kpresenterdoc->paintContent(painter, rect, false);
+ painter.end();
+
+ if ( !picture.save( m_chain->outputFile(), "SVG" ) ) {
+ KMessageBox::error( 0, i18n( "Failed to write file." ),
+ i18n( "SVG Export Error" ) );
+ }
+
+ return KoFilter::OK;
+}
+
+
+#include "svgexport.moc"
+
+
diff --git a/filters/kpresenter/svg/svgexport.h b/filters/kpresenter/svg/svgexport.h
new file mode 100644
index 00000000..7b4583b3
--- /dev/null
+++ b/filters/kpresenter/svg/svgexport.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@kde.org>
+ code based on svgexport.cc from Inge Wallin <inge@lysator.liu.se>
+
+ 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 __SVGEXPORT_H__
+#define __SVGEXPORT_H__
+
+#include <KoFilter.h>
+
+class SvgExport : public KoFilter
+{
+ Q_OBJECT
+
+public:
+ SvgExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~SvgExport();
+
+ virtual KoFilter::ConversionStatus convert(const QCString& from, const QCString& to);
+};
+
+#endif // __SVGEXPORT_H__
+
diff --git a/filters/kpresenter/xbm/Makefile.am b/filters/kpresenter/xbm/Makefile.am
new file mode 100644
index 00000000..1d794f76
--- /dev/null
+++ b/filters/kpresenter/xbm/Makefile.am
@@ -0,0 +1,24 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ -I$(top_srcdir)/filters/libdialogfilter \
+ -I$(top_srcdir)/filters/kpresenter/libimageexport \
+ $(all_includes)
+
+####### Files
+
+kde_module_LTLIBRARIES = libkpresenterxbmexport.la
+
+libkpresenterxbmexport_la_SOURCES = xbmexport.cpp
+libkpresenterxbmexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined
+libkpresenterxbmexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la ../../../filters/libdialogfilter/libdialogfilter.la ../libimageexport/libkpresenterimageexport.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ xbmexport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_xbm_export.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/xbm/kpresenter_xbm_export.desktop b/filters/kpresenter/xbm/kpresenter_xbm_export.desktop
new file mode 100644
index 00000000..890a0b3a
--- /dev/null
+++ b/filters/kpresenter/xbm/kpresenter_xbm_export.desktop
@@ -0,0 +1,51 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter XBM Export Filter
+Name[bg]=Филтър за експортиране от KPresenter в BMP
+Name[br]=Sil ezporzh XBM evit KPresenter
+Name[ca]=Filtre d'exportació XBM per a KPresenter
+Name[da]=KPresenter XBM-eksportfilter
+Name[de]=KPresenter XBM-Exportfilter
+Name[el]=Φίλτρο εξαγωγής XBM του KPresenter
+Name[eo]=KPresenter XBM-eksportfiltrilo
+Name[es]=Filtro de exportación a XBM para KPresenter
+Name[et]=KPresenteri XBM-i filter
+Name[fa]=پالایۀ صادرات KPresenter XBM
+Name[fi]=KPresenter XBM -vientisuodin
+Name[fr]=Filtre d'exportation XBM de KPresenter
+Name[fy]=XBM-Eksportfilter foar KPresenter
+Name[ga]=Scagaire Easpórtála XBM KPresenter
+Name[gl]=Filtro de Exportación de XBM para KPresenter
+Name[he]=KPresenter XBM מסנן יצוא
+Name[hr]=KPresenter XBM filtar izvoza
+Name[hu]=KPresenter XBM exportszűrő
+Name[is]=KPresenter XBM útflutningssía
+Name[it]=Filtro di esportazione XBM per KPresenter
+Name[ja]=KPresenter XBM エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ XBM សម្រាប់ KPresenter
+Name[lt]=KPresenter XBM eksportavimo filtras
+Name[lv]=KPresenter XBM eksporta filtrs
+Name[nb]=XBM-eksportfilter for KPresenter
+Name[nds]=XBM-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता एक्सबीएम निर्यात फिल्टर
+Name[nl]=KPresenter XBM Exportfilter
+Name[pl]=Filtr eksportu do formatu XBM dla KPresenter
+Name[pt]=Filtro de Exportação de XBM para o KPresenter
+Name[pt_BR]=Filtro de Exportação de XBM para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в XBM
+Name[se]=KPresenter XBM-olggosfievrridansilli
+Name[sk]=Exportný filter KPresenter XBM
+Name[sl]=Izvozni filter XBM za KPresenter
+Name[sr]=KPresenter-ов филтер за извоз у XBM
+Name[sr@Latn]=KPresenter-ov filter za izvoz u XBM
+Name[sv]=Kpresenter XBM-exportfilter
+Name[uk]=Фільтр експорту XBM для KPresenter
+Name[uz]=KPresenter XBM eksport filteri
+Name[uz@cyrillic]=KPresenter XBM экспорт филтери
+Name[zh_CN]=KPresenter XBM 导出过滤器
+Name[zh_TW]=KPresenter XBM 匯出過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Export=image/x-xbm
+X-KDE-Weight=1
+X-KDE-Library=libkpresenterxbmexport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/xbm/xbmexport.cpp b/filters/kpresenter/xbm/xbmexport.cpp
new file mode 100644
index 00000000..148288dc
--- /dev/null
+++ b/filters/kpresenter/xbm/xbmexport.cpp
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 <qpixmap.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+#include <kgenericfactory.h>
+#include <KoDocument.h>
+
+#include "xbmexport.h"
+#include "exportsizedia.h"
+
+typedef KGenericFactory<XbmExport, KoFilter> xbmExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libkpresenterxbmexport, xbmExportFactory( "xbmexport" ) )
+
+XbmExport::XbmExport(KoFilter *fil, const char *name, const QStringList&lst)
+ : ImageExport(fil,name,lst)
+{
+}
+
+XbmExport::~XbmExport()
+{
+}
+
+bool XbmExport::extraImageAttribute()
+{
+ bool ret = false;
+ ExportSizeDia *exportDialog = new ExportSizeDia( width, height,
+ 0, "exportdialog");
+ if (exportDialog->exec()) {
+ width = exportDialog->width();
+ height = exportDialog->height();
+ ret = true;
+ kdDebug() << "Xbm Export: size = [" << width << "," << height << "]" << endl;
+ }
+ delete exportDialog;
+ return ret;
+}
+
+
+bool XbmExport::saveImage( QString fileName)
+{
+ bool ret = pixmap.save( fileName, "XBM" );
+ // Save the image.
+ if ( !ret ) {
+ KMessageBox::error( 0, i18n( "Failed to write file." ),
+ i18n( "Xbm Export Error" ) );
+ }
+ return ret;
+}
+
+const char * XbmExport::exportFormat()
+{
+ return "image/x-xbm";
+}
+
+#include "xbmexport.moc"
+
diff --git a/filters/kpresenter/xbm/xbmexport.h b/filters/kpresenter/xbm/xbmexport.h
new file mode 100644
index 00000000..065e52d5
--- /dev/null
+++ b/filters/kpresenter/xbm/xbmexport.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 __XBMEXPORT_H__
+#define __XBMEXPORT_H__
+
+#include "imageexport.h"
+
+class XbmExport : public ImageExport
+{
+ Q_OBJECT
+
+public:
+ XbmExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~XbmExport();
+ virtual bool saveImage( QString fileName);
+ virtual bool extraImageAttribute();
+ virtual const char * exportFormat();
+};
+
+#endif // __XBMEXPORT_H__
+
diff --git a/filters/kpresenter/xpm/Makefile.am b/filters/kpresenter/xpm/Makefile.am
new file mode 100644
index 00000000..ffc86c25
--- /dev/null
+++ b/filters/kpresenter/xpm/Makefile.am
@@ -0,0 +1,24 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir) $(KOFFICE_INCLUDES) \
+ -I$(top_srcdir)/kpresenter \
+ -I$(top_srcdir)/lib/kotext \
+ -I$(top_srcdir)/filters/libdialogfilter \
+ -I$(top_srcdir)/filters/kpresenter/libimageexport \
+ $(all_includes)
+
+####### Files
+
+kde_module_LTLIBRARIES = libkpresenterxpmexport.la
+
+libkpresenterxpmexport_la_SOURCES = xpmexport.cpp
+libkpresenterxpmexport_la_LDFLAGS = -module $(KDE_PLUGIN) -no-undefined
+libkpresenterxpmexport_la_LIBADD = ../../../kpresenter/libkpresenterprivate.la ../../../filters/libdialogfilter/libdialogfilter.la ../libimageexport/libkpresenterimageexport.la $(KOFFICE_LIBS)
+noinst_HEADERS = \
+ xpmexport.h
+
+METASOURCES = AUTO
+
+service_DATA = kpresenter_xpm_export.desktop
+servicedir = $(kde_servicesdir)
+
diff --git a/filters/kpresenter/xpm/kpresenter_xpm_export.desktop b/filters/kpresenter/xpm/kpresenter_xpm_export.desktop
new file mode 100644
index 00000000..5174e996
--- /dev/null
+++ b/filters/kpresenter/xpm/kpresenter_xpm_export.desktop
@@ -0,0 +1,51 @@
+[Desktop Entry]
+Type=Service
+Name=KPresenter XPM Export Filter
+Name[bg]=Филтър за експортиране от KPresenter в XPM
+Name[br]=Sil ezporzh XPM evit KPresenter
+Name[ca]=Filtre d'exportació XPM per a KPresenter
+Name[da]=KPresenter XPM-eksportfilter
+Name[de]=KPresenter XPM-Exportfilter
+Name[el]=Φίλτρο εξαγωγής XPM του KPresenter
+Name[eo]=KPresenter XBM-eksportfiltrilo
+Name[es]=Filtro de exportación a XPM para KPresenter
+Name[et]=KPresenteri XPM-i filter
+Name[fa]=پالایۀ صادرات KPresenter XPM
+Name[fi]=KPresenter XPM -vientisuodin
+Name[fr]=Filtre d'exportation XPM de KPresenter
+Name[fy]=XPM-Eksportfilter foar KPresenter
+Name[ga]=Scagaire Easpórtála XPM KPresenter
+Name[gl]=Filtro de Exportación de XPM para KPresenter
+Name[he]=KPresenter XPM מסנן יצוא
+Name[hr]=KPresenter XPM filtar izvoza
+Name[hu]=KPresenter XPM exportszűrő
+Name[is]=KPresenter XPM útflutningssía
+Name[it]=Filtro di esportazione XPM per KPresenter
+Name[ja]=KPresenter XPM エクスポートフィルタ
+Name[km]=តម្រង​នាំចេញ XPM សម្រាប់ KPresenter
+Name[lt]=KPresenter XPM eksportavimo filtras
+Name[lv]=KPresenter XPM eksporta filtrs
+Name[nb]=XPM_eksportfilter for KPresenter
+Name[nds]=XPM-Exportfilter för KPresenter
+Name[ne]=केडीई प्रस्तुतकर्ता एक्सपीएम निर्यात फिल्टर
+Name[nl]=KPresenter XPM Exportfilter
+Name[pl]=Filtr eksportu do formatu XPM dla KPresenter
+Name[pt]=Filtro de Exportação de XPM para o KPresenter
+Name[pt_BR]=Filtro de Exportação de XPM para o KPresenter
+Name[ru]=Фильтр экспорта презентаций KPresenter в XPM
+Name[se]=KPresenter XPM-olggosfievrridansilli
+Name[sk]=Exportný filter KPresenter XPM
+Name[sl]=Izvozni filter XPM za KPresenter
+Name[sr]=KPresenter-ов филтер за извоз у XPM
+Name[sr@Latn]=KPresenter-ov filter za izvoz u XPM
+Name[sv]=Kpresenter XPM-exportfilter
+Name[uk]=Фільтр експорту XPM для KPresenter
+Name[uz]=KPresenter XPM eksport filteri
+Name[uz@cyrillic]=KPresenter XPM экспорт филтери
+Name[zh_CN]=KPresenter XPM 导出过滤器
+Name[zh_TW]=KPresenter XPM 匯出過濾程式
+X-KDE-Import=application/x-kpresenter
+X-KDE-Export=image/x-xpm
+X-KDE-Weight=1
+X-KDE-Library=libkpresenterxpmexport
+ServiceTypes=KOfficeFilter
diff --git a/filters/kpresenter/xpm/xpmexport.cpp b/filters/kpresenter/xpm/xpmexport.cpp
new file mode 100644
index 00000000..1456504e
--- /dev/null
+++ b/filters/kpresenter/xpm/xpmexport.cpp
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 <qpixmap.h>
+#include <qpainter.h>
+
+#include <kmessagebox.h>
+
+#include <KoFilterChain.h>
+#include <KoStore.h>
+#include <kgenericfactory.h>
+#include <KoDocument.h>
+
+#include "xpmexport.h"
+#include "exportsizedia.h"
+
+typedef KGenericFactory<XpmExport, KoFilter> xpmExportFactory;
+K_EXPORT_COMPONENT_FACTORY( libkpresenterxpmexport, xpmExportFactory( "xpmexport" ) )
+
+XpmExport::XpmExport(KoFilter *fil, const char *name, const QStringList&lst)
+ : ImageExport(fil,name,lst)
+{
+}
+
+XpmExport::~XpmExport()
+{
+}
+
+bool XpmExport::extraImageAttribute()
+{
+ bool ret = false;
+ ExportSizeDia *exportDialog = new ExportSizeDia( width, height,
+ 0, "exportdialog");
+ if (exportDialog->exec()) {
+ width = exportDialog->width();
+ height = exportDialog->height();
+ ret = true;
+ kdDebug() << "Xpm Export: size = [" << width << "," << height << "]" << endl;
+ }
+ delete exportDialog;
+ return ret;
+}
+
+
+bool XpmExport::saveImage( QString fileName)
+{
+ bool ret = pixmap.save( fileName, "XPM" );
+ // Save the image.
+ if ( !ret ) {
+ KMessageBox::error( 0, i18n( "Failed to write file." ),
+ i18n( "Xpm Export Error" ) );
+ }
+ return ret;
+}
+
+const char * XpmExport::exportFormat()
+{
+ return "image/x-xpm";
+}
+
+#include "xpmexport.moc"
+
diff --git a/filters/kpresenter/xpm/xpmexport.h b/filters/kpresenter/xpm/xpmexport.h
new file mode 100644
index 00000000..8ccec46c
--- /dev/null
+++ b/filters/kpresenter/xpm/xpmexport.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Laurent Montel <montel@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 __XPMEXPORT_H__
+#define __XPMEXPORT_H__
+
+#include "imageexport.h"
+
+class XpmExport : public ImageExport
+{
+ Q_OBJECT
+
+public:
+ XpmExport(KoFilter *parent, const char *name, const QStringList&);
+ virtual ~XpmExport();
+ virtual bool saveImage( QString fileName);
+ virtual bool extraImageAttribute();
+ virtual const char * exportFormat();
+};
+
+#endif // __XPMEXPORT_H__
+