/* * Copyright (c) 2004, Nate Nielsen * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the * above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or * other materials provided with the distribution. * * The names of contributors to this software may not be * used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * * CONTRIBUTORS * Nate Nielsen * */ #ifndef __RTFFORMATTING_H__ #define __RTFFORMATTING_H__ /* * RtfFormatting * * For keeping track of all the various transient formatting options * within a given Rtf group. Any supported text options (not block) * should be added here. */ class RtfFormatting { public: RtfFormatting() { resetText(); resetPara(); } RtfFormatting(const RtfFormatting& format) { copy(format); } bool textEquals(const RtfFormatting& format) const { return m_bold == format.m_bold && m_italic == format.m_italic && m_strike == format.m_italic && m_hidden == format.m_hidden && m_underline == format.m_underline && m_color == format.m_color && m_highlight == format.m_highlight && m_suscript == format.m_suscript && m_font == format.m_font && m_fsize == format.m_fsize && m_charstyle == format.m_charstyle; } bool paraEquals(RtfFormatting& format) const { return m_style == format.m_style && m_list == format.m_list && m_inTbl == format.m_inTbl && m_align == format.m_align && m_indent == format.m_indent; } void copy(const RtfFormatting& format) { m_bold = format.m_bold; m_italic = format.m_italic; m_strike = format.m_italic; m_hidden = format.m_hidden; m_underline = format.m_underline; m_color = format.m_color; m_highlight = format.m_highlight; m_suscript = format.m_suscript; m_font = format.m_font; m_fsize = format.m_fsize; m_charstyle = format.m_charstyle; m_style = format.m_style; m_list = format.m_list; m_inTbl = format.m_inTbl; m_align = format.m_align; m_indent = format.m_indent; } void resetText() { m_bold = m_italic = m_strike = m_underline = m_hidden = false; m_color = -1; m_highlight = -1; m_suscript = 0; m_fsize = -1; m_font = -1; m_charstyle = -1; } void resetPara() { m_style = m_list = -1; m_inTbl = false; m_align = LEFT; m_indent = 0; } bool textIsBold() const { return m_bold; } bool textIsItalic() const { return m_italic; } bool textIsStrike() const { return m_strike; } bool textIsUnderline() const { return m_underline; } bool textIsHidden() const { return m_hidden; } int textColor() const { return m_color; } int textHighlight() const { return m_highlight; } int textSuScript() const { return m_suscript; } int textFont() const { return m_font; } int textFontSize() const { return m_fsize; } int textStyle() { return m_charstyle; } int paraStyle() const { return m_style; } int paraList() const { return m_list; } bool paraInTable() const { return m_inTbl; } int paraAlign() const { return m_align; } int paraIndent() const { return m_indent; } void textSetBold(bool bold) { m_bold = bold; } void textSetItalic(bool italic) { m_italic = italic; } void textSetStrike(bool strike) { m_strike = strike; } void textSetUnderline(bool underline) { m_underline = underline; } void textSetHidden(bool hidden) { m_hidden = hidden; } void textSetColor(int color) { m_color = color; } void textSetHighlight(int color) { m_highlight = color; } void textSetSuScript(int suscript) { m_suscript = suscript; } void textSetFont(int font) { m_font = font; } void textSetFontSize(int fsize) { m_fsize = fsize == 24 ? -1 : fsize; } // default font size is always 24 void textSetStyle(int style) { m_charstyle = style; } void paraSetStyle(int style) { m_style = style; } void paraSetList(int list) { m_list = list; } void paraSetTable(bool inTable) { m_inTbl = inTable; } void paraSetAlign(int align) { m_align = align; } void paraSetIndent(int indent) { m_indent = indent; } enum { SUPERSCRIPT = 1, SUBSCRIPT }; enum { LEFT = 0, CENTER, RIGHT, JUSTIFY }; protected: bool m_bold; bool m_italic; bool m_strike; bool m_underline; bool m_hidden; int m_suscript; int m_color; int m_highlight; int m_font; int m_fsize; int m_charstyle; int m_style; int m_list; bool m_inTbl; int m_align; int m_indent; }; #endif // __RTFFORMATTING_H__