Eneboo - Documentación para desarrolladores
|
00001 /* 00002 odf-gen: Simple API to generate OpenDocument documents. 00003 Copyright (C) 2009 Pablo Jorge, FuDePAN 00004 00005 This file is part of the odf-gen project. 00006 00007 odf-gen is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 odf-gen is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with odf-gen. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef STYLE_H 00022 #define STYLE_H 00023 00024 #include <iostream> 00025 00026 class Style 00027 { 00028 public: 00029 enum StyleFlags { 00030 NONE = 0, 00031 BORDER_BOTTOM = (1 << 0), 00032 BORDER_LEFT = (1 << 1), 00033 BORDER_RIGHT = (1 << 2), 00034 BORDER_TOP = (1 << 3), 00035 ALIGN_LEFT = (1 << 4), 00036 ALIGN_CENTER = (1 << 5), 00037 ALIGN_RIGHT = (1 << 6), 00038 TEXT_BOLD = (1 << 7), 00039 TEXT_ITALIC = (1 << 8), 00040 TEXT_UNDERLINE = (1 << 9), 00041 }; 00042 00043 Style(StyleFlags flags = NONE) 00044 : _flags(flags) 00045 {} 00046 00047 Style &operator = (StyleFlags flags) { 00048 _flags = flags; 00049 return *this; 00050 } 00051 00052 Style &operator |= (const Style &other) { 00053 _flags = (Style::StyleFlags)(_flags | other._flags); 00054 return *this; 00055 } 00056 00057 bool operator !() const { 00058 return !_flags; 00059 } 00060 00061 bool operator & (StyleFlags flags) const { 00062 return (_flags & flags); 00063 } 00064 00065 std::ostream &operator << (std::ostream &ostream) const { 00066 if (this->operator & (BORDER_BOTTOM)) 00067 ostream << "border-bottom,"; 00068 if (this->operator & (BORDER_LEFT)) 00069 ostream << "border-left,"; 00070 if (this->operator & (BORDER_RIGHT)) 00071 ostream << "border-right,"; 00072 if (this->operator & (BORDER_TOP)) 00073 ostream << "border-top,"; 00074 if (this->operator & (ALIGN_LEFT)) 00075 ostream << "align-left,"; 00076 if (this->operator & (ALIGN_CENTER)) 00077 ostream << "align-center,"; 00078 if (this->operator & (ALIGN_RIGHT)) 00079 ostream << "align-right,"; 00080 if (this->operator & (TEXT_BOLD)) 00081 ostream << "text-bold,"; 00082 if (this->operator & (TEXT_ITALIC)) 00083 ostream << "text-italic,"; 00084 if (this->operator & (TEXT_UNDERLINE)) 00085 ostream << "text-underline,"; 00086 00087 return ostream; 00088 } 00089 00090 private: 00091 StyleFlags _flags; 00092 }; 00093 00094 inline 00095 std::ostream &operator << (std::ostream &ostream, 00096 const Style &style) 00097 { 00098 return style.operator << (ostream); 00099 } 00100 00101 #endif // STYLE_H