IWORKText.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libetonyek project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef IWORKTEXT_H_INCLUDED
00011 #define IWORKTEXT_H_INCLUDED
00012 
00013 #include "IWORKText_fwd.h"
00014 
00015 #include <deque>
00016 #include <stack>
00017 
00018 #include <glm/glm.hpp>
00019 
00020 #include <librevenge/librevenge.h>
00021 
00022 #include "IWORKStyle_fwd.h"
00023 #include "IWORKStyleStack.h"
00024 #include "IWORKOutputElements.h"
00025 
00026 namespace libetonyek
00027 {
00028 
00029 class IWORKLanguageManager;
00030 class IWORKTextRecorder;
00031 
00032 class IWORKText
00033 {
00034 public:
00035   IWORKText(const IWORKLanguageManager &langManager, bool discardEmptyContent);
00036   ~IWORKText();
00037 
00038   void setRecorder(const boost::shared_ptr<IWORKTextRecorder> &recorder);
00039   const boost::shared_ptr<IWORKTextRecorder> &getRecorder() const;
00040 
00042   void pushBaseLayoutStyle(const IWORKStylePtr_t &style);
00044   void pushBaseParagraphStyle(const IWORKStylePtr_t &style);
00045 
00047   void setLayoutStyle(const IWORKStylePtr_t &style);
00049   void flushLayout();
00050 
00052   void setListStyle(const IWORKStylePtr_t &style);
00054   void setListLevel(const unsigned level);
00056   void flushList();
00057 
00059   void setParagraphStyle(const IWORKStylePtr_t &style);
00061   void flushParagraph();
00062 
00064   void setSpanStyle(const IWORKStylePtr_t &style);
00066   void setLanguage(const IWORKStylePtr_t &style);
00068   void flushSpan();
00069 
00070   void openLink(const std::string &url);
00071   void closeLink();
00072 
00073   void insertText(const std::string &text);
00074   void insertTab();
00075   void insertSpace();
00076   void insertLineBreak();
00077 
00078   void insertInlineContent(const IWORKOutputElements &elements);
00079   void insertBlockContent(const IWORKOutputElements &elements);
00080 
00081   bool empty() const;
00082 
00083   void draw(IWORKOutputElements &elements);
00084 
00085 private:
00086   void openSection();
00087   void closeSection();
00088   bool needsSection() const;
00089 
00090   void handleListLevelChange(unsigned level);
00091 
00092   void openPara();
00093   void closePara();
00094   void fillParaPropList(librevenge::RVNGPropertyList &propList);
00095 
00096   void openSpan();
00097   void closeSpan();
00098 
00099 private:
00100   const IWORKLanguageManager &m_langManager;
00101 
00102   IWORKStyleStack m_layoutStyleStack;
00103   IWORKStyleStack m_paraStyleStack;
00104 
00105   IWORKOutputElements m_elements;
00106 
00107   IWORKStylePtr_t m_layoutStyle;
00108   bool m_inSection;
00109   mutable librevenge::RVNGPropertyList m_sectionProps;
00110   mutable bool m_checkedSection;
00111 
00112   IWORKStylePtr_t m_listStyle;
00113   unsigned m_listLevel;
00114   unsigned m_inListLevel;
00116   std::stack<bool> m_isOrderedStack;
00117 
00118   IWORKStylePtr_t m_paraStyle;
00119   bool m_inPara;
00120   bool m_ignoreEmptyPara;
00121 
00122   IWORKStylePtr_t m_spanStyle;
00123   IWORKStylePtr_t m_langStyle;
00124   bool m_spanStyleChanged;
00125   bool m_inSpan;
00126 
00127   IWORKStylePtr_t m_oldSpanStyle;
00128 
00129   boost::shared_ptr<IWORKTextRecorder> m_recorder;
00130 };
00131 
00132 }
00133 
00134 #endif // IWORKTEXT_H_INCLUDED
00135 
00136 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */