summaryrefslogtreecommitdiffstats
path: root/filters/olefilters/powerpoint97/pptxml.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'filters/olefilters/powerpoint97/pptxml.cpp')
-rw-r--r--filters/olefilters/powerpoint97/pptxml.cpp317
1 files changed, 317 insertions, 0 deletions
diff --git a/filters/olefilters/powerpoint97/pptxml.cpp b/filters/olefilters/powerpoint97/pptxml.cpp
new file mode 100644
index 000000000..42be4de5c
--- /dev/null
+++ b/filters/olefilters/powerpoint97/pptxml.cpp
@@ -0,0 +1,317 @@
+/*
+ Copyright (C) 2000, S.R.Haque <shaheedhaque@hotmail.com>.
+ This file is part of the KDE project
+
+ 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.
+
+DESCRIPTION
+*/
+
+#include <pptdoc.h>
+#include <pptxml.h>
+#include <tqobject.h>
+#include <KoGlobal.h>
+
+const int PptXml::s_area = 30512;
+
+PptXml::PptXml(
+ const myFile &mainStream,
+ const myFile &currentUser,
+ const myFile &pictures):
+ PptDoc(
+ mainStream,
+ currentUser,
+ pictures)
+{
+ m_isConverted = false;
+ m_success = false;
+ m_half = false;
+ m_y = 0;
+}
+
+PptXml::~PptXml()
+{
+}
+
+bool PptXml::convert()
+{
+ if (!m_isConverted)
+ {
+ // m_y = 30;
+ m_success = parse();
+ m_isConverted = true;
+ }
+ return m_success;
+}
+
+void PptXml::encode(TQString &text)
+{
+ // When encoding the stored form of text to its run-time form,
+ // be sure to do the conversion for "&amp;" to "&" first to avoid
+ // accidentally converting user text into one of the other escape
+ // sequences.
+
+ text.replace('&', "&amp;");
+ text.replace('<', "&lt;");
+ text.replace('>', "&gt;"); // Needed to avoid ]]>
+
+ // Strictly, there is no need to encode " or ', but we do so to allow
+ // them to co-exist!
+
+ text.replace('"', "&quot;");
+ text.replace('\'', "&apos;");
+}
+
+const TQString PptXml::getXml() const
+{
+ TQString body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE DOC>\n"
+ "<DOC mime=\"application/x-kpresenter\" email=\"reggie@kde.org\" syntaxVersion=\"2\" author=\"Reginald Stadlbauer\" editor=\"Powerpoint import filter\">\n"
+ " <PAPER ptWidth=\"680\" unit=\"0\" format=\"5\" orientation=\"0\" ptHeight=\"510\">\n"
+ " <PAPERBORDERS ptRight=\"0\" ptBottom=\"0\" ptLeft=\"0\" ptTop=\"0\"/>\n"
+ " </PAPER>\n"
+ " <BACKGROUND rastX=\"10\" rastY=\"10\" color=\"#ffffff\">\n";
+ body += m_pages;
+ body += " </BACKGROUND>\n"
+ " <HEADER show=\"0\">\n"
+ " <ORIG x=\"0\" y=\"0\"/>\n"
+ " <SIZE width=\"680\" height=\"20\"/>\n"
+ " <PEN width=\"1\" style=\"0\" color=\"#000000\"/>\n"
+ " <TEXTOBJ>\n"
+ " <P/>\n"
+ " </TEXTOBJ>\n"
+ " </HEADER>\n"
+ " <FOOTER show=\"0\">\n"
+ " <ORIG x=\"0\" y=\"430\"/>\n"
+ " <SIZE width=\"680\" height=\"20\"/>\n"
+ " <PEN width=\"1\" style=\"0\" color=\"#000000\"/>\n"
+ " <TEXTOBJ>\n"
+ " <P/>\n"
+ " </TEXTOBJ>\n"
+ " </FOOTER>\n"
+ " <PAGETITLES>\n";
+ body += m_titles;
+ body += " </PAGETITLES>\n"
+ " <PAGENOTES>\n";
+ body += m_notes;
+ body += " </PAGENOTES>\n"
+ " <OBJECTS>\n";
+ body += m_text;
+ body += " </OBJECTS>\n"
+ " <INFINITLOOP value=\"0\"/>\n"
+ " <MANUALSWITCH value=\"1\"/>\n"
+ " <PRESSPEED value=\"1\"/>\n"
+ " <PRESSLIDES value=\"0\"/>\n"
+ " <SELSLIDES>\n"
+ " <SLIDE nr=\"0\" show=\"1\"/>\n"
+ " </SELSLIDES>\n"
+ " <PIXMAPS>\n"
+ " </PIXMAPS>\n"
+ " <CLIPARTS>\n"
+ " </CLIPARTS>\n";
+ body += m_embedded;
+ body += "</DOC>\n";
+ //kdDebug(s_area) << body << endl;
+ return body;
+}
+
+void PptXml::gotDrawing(
+ unsigned id,
+ TQString type,
+ unsigned length,
+ const char *data)
+{
+ TQString ourKey;
+ TQString uid;
+ TQString mimeType;
+ TQString filterArgs;
+
+ // Send the picture to the outside world and get back the UID.
+
+ ourKey = "vectorGraphic" + TQString::number(id) + "." + type;
+ if (type == "msod")
+ {
+ filterArgs = "shape-id=";
+ filterArgs += TQString::number(id);
+ filterArgs += ";delay-stream=";
+ filterArgs += TQString::number(0);
+ }
+ emit signalSavePart(
+ ourKey,
+ uid,
+ mimeType,
+ type,
+ length,
+ data);
+
+ // Add an entry to the list of embedded objects too. TBD: fix
+ // RECT and FRAME settings.
+if (mimeType != "application/x-kontour")
+{
+ m_embedded += " <EMBEDDED>\n"
+ "<OBJECT url=\"" +
+ uid +
+ "\" mime=\"" +
+ mimeType +
+ "\">\n<RECT x=\"30\" y=\"190\" w=\"120\" h=\"80\"/>\n"
+ "</OBJECT>\n"
+ "<SETTINGS>\n"
+ "<EFFECTS effect=\"0\" effect2=\"0\"/>\n"
+ "<PEN red=\"0\" green=\"0\" blue=\"0\" width=\"1\" style=\"0\"/>\n"
+ "<BRUSH red=\"0\" green=\"0\" blue=\"0\" style=\"0\"/>\n"
+ "<PRESNUM value=\"0\"/>\n"
+ "<ANGLE value=\"0\"/>\n"
+ "<FILLTYPE value=\"0\"/>\n"
+ "<GRADIENT red1=\"255\" green1=\"0\" blue1=\"0\" red2=\"0\" green2=\"255\" blue2=\"0\" type=\"1\" unbalanced=\"0\" xfactor=\"100\" yfactor=\"100\"/>\n"
+ "<DISAPPEAR effect=\"0\" doit=\"0\" num=\"1\"/>\n"
+ "</SETTINGS>\n"
+ " </EMBEDDED>\n";
+}
+}
+
+void PptXml::gotSlide(PptSlide &slide)
+{
+ static const unsigned pageHeight = 510;
+ TQ_UINT16 numbOfPholders = 0;
+ m_pages += " <PAGE/>\n";
+ numbOfPholders = slide.getNumberOfPholders();
+ for(TQ_UINT16 i = 0; i < numbOfPholders; i++)
+ {
+ slide.gotoPlaceholder(i);
+ setPlaceholder(slide);
+ }
+ m_y += pageHeight;
+}
+
+void PptXml::setPlaceholder(PptSlide &slide)
+{
+ TQString xml_friendly;
+ unsigned i = 0;
+ bool bulletedList = false; //is this a bulleted list?
+ TQ_UINT16 type; //type of text
+ TQString x; //x of placeholder
+ TQString align; //align of text
+ TQString height ; //height of placeholder
+ TQString width ; //width of placeholder
+ TQString pointSize; //font size
+
+ xml_friendly = *slide.getPlaceholderText().at(i);
+ encode(xml_friendly);
+
+ type = slide.getPlaceholderType();
+ TQ_UINT16 y = 0;
+
+ switch (type)
+ {
+ case TITLE_TEXT:
+ y = 30;
+ height = TQString::number(55);
+ x = TQString::number(30);
+ width = TQString::number(610);
+ align = TQString::number(ALIGN_CENTER);
+ pointSize = TQString::number(44);
+ bulletedList = false;
+ m_titles += " <Title title=\"" + xml_friendly + "\" />\n";
+ break;
+ case CENTER_TITLE_TEXT:
+ y = 130;
+ x = TQString::number(45);
+ height = TQString::number(55);
+ width = TQString::number(610);
+ align = TQString::number(ALIGN_CENTER);
+ pointSize = TQString::number(44);
+ bulletedList = false;
+ m_titles += " <Title title=\"" + xml_friendly + "\" />\n";
+ break;
+ case CENTER_BODY_TEXT:
+ y = 200;
+ x = TQString::number(35);
+ height = TQString::number(37);
+ width = TQString::number(610);
+ align = TQString::number(ALIGN_CENTER);
+ pointSize = TQString::number(32);
+ bulletedList = false;
+ break;
+ case NOTES_TEXT:
+ m_notes += " <Note note=\"\" />\n";
+ break;
+ case BODY_TEXT:
+ y = 130;
+ x = TQString::number(35);
+ height = TQString::number(268);
+ width = TQString::number(610);
+ align = TQString::number(ALIGN_LEFT);
+ pointSize = TQString::number(28);
+ bulletedList = true;
+ break;
+ case OTHER_TEXT:
+ case HALF_BODY_TEXT:
+ case QUARTER_BODY_TEXT:
+ y = 130;
+ if(m_half)
+ {
+ x = TQString::number(335);
+ width = TQString::number(300);
+ m_half = false;
+ }
+ else
+ {
+ x = TQString::number(30);
+ width = TQString::number(300);
+ m_half = true;
+ }
+ height = TQString::number(268);
+ align = TQString::number(ALIGN_LEFT);
+ pointSize = TQString::number(28);
+ bulletedList = true;
+ break;
+ default:
+ return;
+ break;
+ }
+
+ m_text += "<OBJECT type=\"4\">\n"
+ " <ORIG x=\""+x+"\" y=\""+TQString::number(y + m_y)+"\"/>\n"
+ " <SIZE width=\""+width+"\" height=\""+ height +"\"/>\n"
+ " <PEN width=\"1\" style=\"0\" color=\"#000000\"/>\n"
+ " <TEXTOBJ>\n"
+ " <P align=\""+align+"\">\n";
+ if(bulletedList)
+ m_text += " <COUNTER numberingtype=\"0\" type=\"10\" depth=\"0\" />\n";
+ m_text += " <TEXT family=\"utopia\" pointSize=\""+pointSize+"\" color=\"#000000\">";
+
+ for (i = 0; i < slide.getPlaceholderText().count(); i++)
+ {
+ xml_friendly = *slide.getPlaceholderText().at(i);
+ encode(xml_friendly);
+ m_text += xml_friendly;
+ if (i < slide.getPlaceholderText().count() - 1)
+ {
+ m_text += "</TEXT>\n"
+ " </P>\n"
+ " <P align=\"1\">\n";
+ if(bulletedList)
+ m_text += " <COUNTER numberingtype=\"0\" type=\"10\" depth=\"0\" />\n";
+ m_text += " <TEXT family=\"utopia\" pointSize=\""+pointSize+"\" color=\"#000000\">";
+ }
+ }
+ m_text += "</TEXT>\n"
+ " </P>\n"
+ " </TEXTOBJ>\n"
+ "</OBJECT>";
+
+}
+
+#include "pptxml.moc"