1 // 2 // aegis - project change supervisor 3 // Copyright (C) 1999, 2001, 2002, 2005, 2006, 2008, 2012 Peter Miller 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 3 of the License, or (at 8 // your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 // General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 // 18 19 #ifndef LIBAEGIS_WIDE_OUTPUT_HEADER_H 20 #define LIBAEGIS_WIDE_OUTPUT_HEADER_H 21 22 #include <common/ac/time.h> 23 24 #include <common/wstring.h> 25 #include <libaegis/wide_output.h> 26 27 /** 28 * The wide_output_header class is used to add page headers to the output. 29 */ 30 class wide_output_header: 31 public wide_output 32 { 33 public: 34 typedef aegis_shared_ptr<wide_output_header> hpointer; 35 36 /** 37 * The destructor. 38 */ 39 ~wide_output_header(); 40 41 private: 42 /** 43 * The constructor. 44 * 45 * @param deeper 46 * where to write the filtered output 47 */ 48 wide_output_header(const wide_output::pointer &deeper); 49 50 public: 51 /** 52 * The open class method is used to create new dynamically 53 * allocated instances of this class. 54 */ 55 static hpointer open(const wide_output::pointer &deeper); 56 57 void title(const nstring &first, const nstring &second); 58 59 static void title(wide_output::pointer fp,const nstring & l1,const nstring & l2)60 title(wide_output::pointer fp, const nstring &l1, const nstring &l2) 61 { 62 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 63 if (hp) 64 hp->title(l1, l2); 65 } 66 67 void need(int); 68 69 void need1(int); 70 71 static void need1(wide_output::pointer fp,int x)72 need1(wide_output::pointer fp, int x) 73 { 74 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 75 if (hp) 76 hp->need1(x); 77 } 78 79 void eject(); 80 81 static void eject(wide_output::pointer fp)82 eject(wide_output::pointer fp) 83 { 84 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 85 if (hp) 86 hp->eject(); 87 } 88 89 bool is_at_top_of_page(); 90 91 static bool is_at_top_of_page(wide_output::pointer fp)92 is_at_top_of_page(wide_output::pointer fp) 93 { 94 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 95 return (hp && hp->is_at_top_of_page()); 96 } 97 98 protected: 99 // See base class for documentation. 100 nstring filename(); 101 102 // See base class for documentation. 103 int page_width(); 104 105 // See base class for documentation. 106 int page_length(); 107 108 // See base class for documentation. 109 const char *type_name() const; 110 111 // See base class for documentation. 112 void write_inner(const wchar_t *data, size_t len); 113 114 // See base class for documentation. 115 void flush_inner(); 116 117 // See base class for documentation. 118 void end_of_line_inner(); 119 120 private: 121 pointer deeper; 122 wstring title1; 123 wstring title2; 124 int line_number; 125 int length; 126 int width; 127 bool is_a_printer; 128 int column; 129 int page_number; 130 time_t page_time; 131 bool already_top_diverted; 132 133 void left_and_right(const wstring &lhs, const char *rhs); 134 void top_of_page_processing(); 135 void bottom_of_page_processing(); 136 137 /** 138 * The default constructor. Do not use. 139 */ 140 wide_output_header(); 141 142 /** 143 * The copy constructor. Do not use. 144 */ 145 wide_output_header(const wide_output_header &); 146 147 /** 148 * The assignment operator. Do not use. 149 */ 150 wide_output_header &operator=(const wide_output_header &); 151 }; 152 153 #endif // LIBAEGIS_WIDE_OUTPUT_HEADER_H 154 // vim: set ts=8 sw=4 et : 155