• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ie_imp_WordPerfect.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 2001 AbiSource, Inc.
00005  * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
00006  * Copyright (C) 2001-2003 William Lachance (william.lachance@sympatico.ca)
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00021  * 02110-1301 USA.
00022  */
00023 
00024 /* See bug 1764
00025  * This product is not manufactured, approved, or supported by
00026  * Corel Corporation or Corel Corporation Limited."
00027  */
00028 
00029 #ifndef IE_IMP_WP_H
00030 #define IE_IMP_WP_H
00031 
00032 #include <stdio.h>
00033 #include <librevenge/librevenge.h>
00034 #include "ie_imp.h"
00035 #include "ut_string.h"
00036 #include "ut_string_class.h"
00037 #include "ut_growbuf.h"
00038 #include "ut_mbtowc.h"
00039 #include "pd_Document.h"
00040 #include "fl_AutoNum.h"
00041 #include "fl_TableLayout.h"
00042 #include "fp_types.h"
00043 
00044 using namespace std;
00045 
00046 #define WP6_NUM_LIST_LEVELS 8  // see WP6FileStructure.h
00047 
00048 // ABI_ListDefinition: tracks information on the list
00049 class ABI_ListDefinition
00050 {
00051 public:
00052     ABI_ListDefinition(int iOutlineHash);
00053     void setListID(const int iLevel, const UT_uint32 iID) { m_iListIDs[iLevel-1] = iID; }
00054     UT_uint32 getListID(const int iLevel) const { return m_iListIDs[iLevel-1]; }
00055     FL_ListType getListType(const int iLevel) const { return m_listTypes[iLevel-1]; }
00056     void setListType(const int iLevel, const char type);
00057     void incrementLevelNumber(const int iLevel) { m_iListNumbers[iLevel - 1]++; }
00058     void setLevelNumber(const int iLevel, const int iNumber) { m_iListNumbers[iLevel - 1] = iNumber; }
00059     void setListLeftOffset(const int iLevel, const float listLeftOffset) { m_listLeftOffset[iLevel - 1] = listLeftOffset; }
00060     void setListMinLabelWidth(const int iLevel, const float listMinLabelWidth) { m_listMinLabelWidth[iLevel - 1] = listMinLabelWidth; }
00061     int getLevelNumber(const int iLevel) const { return m_iListNumbers[iLevel - 1]; }
00062     float getListLeftOffset(const int iLevel) const { return m_listLeftOffset[iLevel - 1]; }
00063     float getListMinLabelWidth(const int iLevel) const { return m_listMinLabelWidth[iLevel - 1]; }
00064     int getOutlineHash() const { return m_iOutlineHash; }
00065 
00066 private:
00067     //int m_iWPOutlineHash; // we don't use this information in AbiWord, only for id purposes during filtering
00068     UT_uint32 m_iListIDs[WP6_NUM_LIST_LEVELS];
00069     int m_iListNumbers[WP6_NUM_LIST_LEVELS];
00070     FL_ListType m_listTypes[WP6_NUM_LIST_LEVELS];
00071     float m_listLeftOffset[WP6_NUM_LIST_LEVELS];
00072     float m_listMinLabelWidth[WP6_NUM_LIST_LEVELS];
00073     int m_iOutlineHash;
00074 };
00075 
00076 class IE_Imp_WordPerfect_Sniffer : public IE_ImpSniffer
00077 {
00078     friend class IE_Imp;
00079     friend class IE_Imp_WordPerfect;
00080 
00081 public:
00082     IE_Imp_WordPerfect_Sniffer();
00083     virtual ~IE_Imp_WordPerfect_Sniffer();
00084 
00085     virtual const IE_SuffixConfidence * getSuffixConfidence ();
00086     virtual UT_Confidence_t recognizeContents (GsfInput * input);
00087     virtual const IE_MimeConfidence * getMimeConfidence () { return NULL; }
00088     virtual bool getDlgLabels (const char ** szDesc,
00089                    const char ** szSuffixList,
00090                    IEFileType * ft);
00091     virtual UT_Error constructImporter (PD_Document * pDocument,
00092                     IE_Imp ** ppie);
00093 };
00094 
00095 class IE_Imp_WordPerfect : public IE_Imp, public librevenge::RVNGTextInterface
00096 {
00097 public:
00098     IE_Imp_WordPerfect(PD_Document * pDocument);
00099     virtual ~IE_Imp_WordPerfect();
00100 
00101     virtual void pasteFromBuffer(PD_DocumentRange * pDocRange,
00102                  UT_uint8 * pData, UT_uint32 lenData, const char * szEncoding = 0);
00103 
00104     virtual void setDocumentMetaData(const librevenge::RVNGPropertyList &propList);
00105 
00106     virtual void startDocument(const librevenge::RVNGPropertyList &propList);
00107     virtual void endDocument();
00108 
00109     virtual void defineEmbeddedFont(const librevenge::RVNGPropertyList & /* propList */) {}
00110 
00111     virtual void definePageStyle(const librevenge::RVNGPropertyList &) {}
00112     virtual void openPageSpan(const librevenge::RVNGPropertyList &propList);
00113     virtual void closePageSpan() {}
00114     virtual void openHeader(const librevenge::RVNGPropertyList &propList);
00115     virtual void closeHeader();
00116     virtual void openFooter(const librevenge::RVNGPropertyList &propList);
00117     virtual void closeFooter();
00118 
00119     virtual void defineSectionStyle(const librevenge::RVNGPropertyList &) {}
00120     virtual void openSection(const librevenge::RVNGPropertyList &propList);
00121     virtual void closeSection() {}
00122 
00123     virtual void defineParagraphStyle(const librevenge::RVNGPropertyList &) {}
00124     virtual void openParagraph(const librevenge::RVNGPropertyList &propList);
00125     virtual void closeParagraph() {}
00126 
00127     virtual void defineCharacterStyle(const librevenge::RVNGPropertyList &) {}
00128     virtual void openSpan(const librevenge::RVNGPropertyList &propList);
00129     virtual void closeSpan() {}
00130 
00131     virtual void openLink(const librevenge::RVNGPropertyList & /* propList */) {}
00132     virtual void closeLink() {}
00133 
00134     virtual void insertTab();
00135     virtual void insertText(const librevenge::RVNGString &text);
00136     virtual void insertSpace();
00137     virtual void insertLineBreak();
00138     virtual void insertField(const librevenge::RVNGPropertyList & /* propList */) {}
00139 
00140     virtual void openOrderedListLevel(const librevenge::RVNGPropertyList &propList);
00141     virtual void openUnorderedListLevel(const librevenge::RVNGPropertyList &propList);
00142     virtual void closeOrderedListLevel();
00143     virtual void closeUnorderedListLevel();
00144     virtual void openListElement(const librevenge::RVNGPropertyList &propList);
00145     virtual void closeListElement() {}
00146 
00147     virtual void openFootnote(const librevenge::RVNGPropertyList &propList);
00148     virtual void closeFootnote();
00149     virtual void openEndnote(const librevenge::RVNGPropertyList &propList);
00150     virtual void closeEndnote();
00151     virtual void openComment(const librevenge::RVNGPropertyList & /* propList */) {}
00152     virtual void closeComment() {}
00153     virtual void openTextBox(const librevenge::RVNGPropertyList & /* propList */) {}
00154     virtual void closeTextBox() {}
00155 
00156     virtual void openTable(const librevenge::RVNGPropertyList &propList);
00157     virtual void openTableRow(const librevenge::RVNGPropertyList &propList);
00158     virtual void closeTableRow() {}
00159     virtual void openTableCell(const librevenge::RVNGPropertyList &propList);
00160     virtual void closeTableCell() {}
00161     virtual void insertCoveredTableCell(const librevenge::RVNGPropertyList & /* propList */) {}
00162     virtual void closeTable();
00163 
00164     virtual void openFrame(const librevenge::RVNGPropertyList & /* propList */) {}
00165     virtual void closeFrame() {}
00166 
00167     virtual void openGroup(const librevenge::RVNGPropertyList & /* propList */) {}
00168     virtual void closeGroup() {}
00169 
00170     virtual void defineGraphicStyle(const librevenge::RVNGPropertyList & /* propList */) {}
00171     virtual void drawRectangle(const librevenge::RVNGPropertyList & /* propList */) {}
00172     virtual void drawEllipse(const librevenge::RVNGPropertyList & /* propList */) {}
00173     virtual void drawPolygon(const librevenge::RVNGPropertyList & /* propList */) {}
00174     virtual void drawPolyline(const librevenge::RVNGPropertyList & /* propList */) {}
00175     virtual void drawPath(const librevenge::RVNGPropertyList & /* propList */) {}
00176     virtual void drawConnector(const librevenge::RVNGPropertyList & /* propList */) {}
00177 
00178     virtual void insertBinaryObject(const librevenge::RVNGPropertyList & /* propList */) {}
00179     virtual void insertEquation(const librevenge::RVNGPropertyList & /* propList */) {}
00180 
00181 protected:
00182     virtual UT_Error _loadFile(GsfInput * input);
00183     UT_Error                            _appendSection(int numColumns, const float, const float);
00184 //    UT_Error                          _appendSpan(const guint32 textAttributeBits, const char *fontName, const float fontSize, UT_uint32 listTag = 0);
00185     UT_Error                            _appendListSpan(UT_uint32 listTag);
00186 //    UT_Error                          _appendParagraph(const guint8 paragraphJustification, const guint32 textAttributeBits,
00187 //                                       const gchar *fontName, const float fontSize, const float lineSpacing);
00188     UT_Error                            _updateDocumentOrderedListDefinition(ABI_ListDefinition *pListDefinition,
00189                                                      int iLevel, const char listType,
00190                                                      const UT_UTF8String &sTextBeforeNumber,
00191                                                      const UT_UTF8String &sTextAfterNumber,
00192                                                      int iStartingNumber);
00193     UT_Error                            _updateDocumentUnorderedListDefinition(ABI_ListDefinition *pListDefinition,
00194                                                        int level);
00195 private:
00196     // section props
00197     float                               m_leftPageMargin;
00198     float                               m_rightPageMargin;
00199     float                               m_leftSectionMargin;
00200     float                               m_rightSectionMargin;
00201     int                                 m_sectionColumnsCount;
00202     UT_sint8                            m_headerId; // -1 means no header
00203     UT_sint8                            m_footerId; // -1 means no footer
00204     UT_uint32                           m_nextFreeId;
00205 
00206     // paragraph props
00207     float                               m_topMargin;
00208     float                               m_bottomMargin;
00209     float                               m_leftMarginOffset;
00210     float                               m_rightMarginOffset;
00211     float                               m_textIndent;
00212 
00213     // state handling that libwpd can't account for
00214     //UT_StringPtrMap                       m_listStylesHash;
00215     ABI_ListDefinition *                m_pCurrentListDefinition;
00216     bool                                m_bParagraphChanged;
00217     bool                                m_bParagraphInSection;
00218     bool                                m_bInSection;
00219     bool                                m_bSectionChanged;
00220     bool                                m_bRequireBlock;
00221 
00222     int                                 m_iCurrentListLevel;
00223     bool                                m_bInCell;
00224 
00225     // HACK HACK HACK
00226     int                                 m_bHdrFtrOpenCount;
00227 };
00228 
00229 #ifdef HAVE_LIBWPS
00230 
00231 class IE_Imp_MSWorks_Sniffer : public IE_ImpSniffer
00232 {
00233     friend class IE_Imp;
00234     friend class IE_Imp_MSWorks;
00235 
00236 public:
00237     IE_Imp_MSWorks_Sniffer();
00238     virtual ~IE_Imp_MSWorks_Sniffer();
00239 
00240     virtual const IE_SuffixConfidence * getSuffixConfidence ();
00241     virtual UT_Confidence_t recognizeContents (GsfInput * input);
00242     virtual const IE_MimeConfidence * getMimeConfidence () { return NULL; }
00243     virtual bool getDlgLabels (const char ** szDesc,
00244                    const char ** szSuffixList,
00245                    IEFileType * ft);
00246     virtual UT_Error constructImporter (PD_Document * pDocument,
00247                     IE_Imp ** ppie);
00248 };
00249 
00250 #endif
00251 
00252 #endif /* IE_IMP_WP_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1