/* Copyright (C) 2000, S.R.Haque . 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 #include #include #include const int PptXml::s_area = 30512; PptXml::PptXml( const myFile &mainStream, const myFile ¤tUser, 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 "&" to "&" first to avoid // accidentally converting user text into one of the other escape // sequences. text.replace('&', "&"); text.replace('<', "<"); text.replace('>', ">"); // Needed to avoid ]]> // Strictly, there is no need to encode " or ', but we do so to allow // them to co-exist! text.replace('"', """); text.replace('\'', "'"); } const TQString PptXml::getXml() const { TQString body = "\n" "\n" " \n" " \n" " \n" " \n"; body += m_pages; body += " \n" "
\n" " \n" " \n" " \n" " \n" "

\n" " \n" "

\n" "
\n" " \n" " \n" " \n" " \n" "

\n" " \n" "

\n" " \n"; body += m_titles; body += " \n" " \n"; body += m_notes; body += " \n" " \n"; body += m_text; body += " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n"; body += m_embedded; body += "
\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 += " \n" "\n\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" " \n"; } } void PptXml::gotSlide(PptSlide &slide) { static const unsigned pageHeight = 510; TQ_UINT16 numbOfPholders = 0; m_pages += " \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 += " \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"