/* Crossmark importer/exporter * Copyright (C) 2006 Marc Maurer * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #include "ie_imp_Crossmark.h" IE_Imp_Crossmark_Sniffer::IE_Imp_Crossmark_Sniffer() : IE_ImpSniffer(IE_MIMETYPE_CROSSMARK) { } IE_Imp_Crossmark_Sniffer::~IE_Imp_Crossmark_Sniffer() { } // supported suffixes static IE_SuffixConfidence IE_Imp_Crossmark_Sniffer__SuffixConfidence[] = { { "xm", UT_CONFIDENCE_PERFECT }, { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_Imp_Crossmark_Sniffer::getSuffixConfidence () { return IE_Imp_Crossmark_Sniffer__SuffixConfidence; } UT_Confidence_t IE_Imp_Crossmark_Sniffer::recognizeContents (const char * szBuf, UT_uint32 iNumbytes) { return UT_CONFIDENCE_ZILCH; } UT_Error IE_Imp_Crossmark_Sniffer::constructImporter (PD_Document * pDocument, IE_Imp ** ppie) { *ppie = new IE_Imp_Crossmark(pDocument); return UT_OK; } bool IE_Imp_Crossmark_Sniffer::getDlgLabels (const char ** pszDesc, const char ** pszSuffixList, IEFileType * ft) { *pszDesc = "Crossmark (.xm)"; *pszSuffixList = "*.xm"; *ft = getFileType(); return true; } /****************************************************************************/ /****************************************************************************/ IE_Imp_Crossmark::IE_Imp_Crossmark(PD_Document * pDocument) : IE_Imp (pDocument) { } IE_Imp_Crossmark::~IE_Imp_Crossmark() { } UT_Error IE_Imp_Crossmark::_loadFile (GsfInput * input) { stream::Input* cmInput = stream::createGsfInput(input); if (cmInput) { Source::Source source(*cmInput, *static_cast(this)); source.sputter(); // TODO: free cmInput return UT_OK; } return UT_ERROR; } void IE_Imp_Crossmark::pasteFromBuffer (PD_DocumentRange *, unsigned char *, unsigned int, const char *) { // nada } void IE_Imp_Crossmark::_appendSection(int numColumns) { UT_DEBUGMSG(("IE_Imp_Crossmark::_appendSection()\n")); UT_UTF8String props; UT_LocaleTransactor lt(LC_NUMERIC, "C"); UT_UTF8String_sprintf(props, "columns:%d", numColumns); const gchar * propsArray[3]; propsArray[0] = "props"; propsArray[1] = props.utf8_str(); propsArray[2] = NULL ; appendStrux(PTX_Section, (const gchar**)propsArray); } void IE_Imp_Crossmark::pushDocument() { UT_DEBUGMSG(("IE_Imp_Crossmark::pushDocument()\n")); // NOTE: open a section for a start, as libcrossmark will // never ask to open one _appendSection(1); } void IE_Imp_Crossmark::popDocument() { UT_DEBUGMSG(("IE_Imp_Crossmark::popDocument()\n")); // ignore } void IE_Imp_Crossmark::text(gchar const *str) { UT_DEBUGMSG(("IE_Imp_Crossmark::text()\n")); // TODO: Check if a block (and section) is already opened for safety UT_UCS4String ucs4(str); appendSpan(ucs4.ucs4_str(), ucs4.length()); } void IE_Imp_Crossmark::pushStyle(document::Style::Type type) { UT_DEBUGMSG(("IE_Imp_Crossmark::pushStyle()\n")); } void IE_Imp_Crossmark::popStyle(document::Style::Type unused) { UT_DEBUGMSG(("IE_Imp_Crossmark::pushStyle()\n")); // TODO: implement me } void IE_Imp_Crossmark::pushBlock(document::Block::Type type) { UT_DEBUGMSG(("IE_Imp_Crossmark::pushBlock()\n")); switch (type) { case document::Block::BLOCKQUOTE: { UT_UTF8String propBuffer; const gchar* propsArray[3]; propsArray[0] = "props"; propsArray[1] = propBuffer.utf8_str(); propsArray[2] = NULL; appendStrux(PTX_Block, propsArray); } break; case document::Block::PARAGRAPH: { UT_UTF8String propBuffer; const gchar* propsArray[3]; propsArray[0] = "props"; propsArray[1] = propBuffer.utf8_str(); propsArray[2] = NULL; appendStrux(PTX_Block, propsArray); } break; case document::Block::HEADING_1: // TODO: implement me break; case document::Block::HEADING_2: // TODO: implement me break; case document::Block::HEADING_3: // TODO: implement me break; case document::Block::HEADING_4: // TODO: implement me break; default: UT_ASSERT(UT_SHOULD_NOT_HAPPEN); } } void IE_Imp_Crossmark::pushHeading(int level) { UT_DEBUGMSG(("IE_Imp_Crossmark::pushHeading()\n")); // TODO: implement me } void IE_Imp_Crossmark::popBlock() { UT_DEBUGMSG(("IE_Imp_Crossmark::popBlock()\n")); // ignore }