1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <precomp.h> 29 #include <toolkit/hf_navi_main.hxx> 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <cosv/tpl/tpltools.hxx> 34 35 36 37 //******************** MainItem and derived ones ***************// 38 class HF_MainItem : public HtmlMaker 39 { 40 public: 41 virtual ~HF_MainItem() {} 42 void Produce_Item() const { do_ProduceItem(); } 43 protected: 44 HF_MainItem( 45 Xml::Element & o_out ) 46 : HtmlMaker(o_out) {} 47 private: 48 virtual void do_ProduceItem() const = 0; 49 }; 50 51 52 namespace 53 { 54 55 class StdItem : public HF_MainItem 56 { 57 public: 58 StdItem( 59 Xml::Element & o_out, 60 const char * i_sText, 61 const char * i_sLink ); 62 63 ~StdItem(); 64 private: 65 virtual void do_ProduceItem() const; 66 67 // DATA 68 String sText; 69 String sLink; 70 }; 71 72 class SelfItem : public HF_MainItem 73 { 74 public: 75 SelfItem( 76 Xml::Element & o_out, 77 const char * i_sText ); 78 ~SelfItem(); 79 private: 80 virtual void do_ProduceItem() const; 81 82 // DATA 83 String sText; 84 }; 85 86 class NoneItem : public HF_MainItem 87 { 88 public: 89 NoneItem( 90 Xml::Element & o_out, 91 const char * i_sText ); 92 ~NoneItem(); 93 private: 94 virtual void do_ProduceItem() const; 95 96 // DATA 97 String sText; 98 }; 99 100 } // anonymous namespace 101 102 103 104 //******************** HF_NaviMainRow ***************// 105 106 107 108 HF_NaviMainRow::HF_NaviMainRow( Xml::Element & o_out ) 109 : HtmlMaker(o_out), 110 aItems(), 111 pRow(0) 112 { 113 aItems.reserve(5); 114 115 pRow = 116 &( CurOut() 117 >> *new Html::Table 118 << new Html::ClassAttr("navimain") 119 << new Xml::AnAttribute( "border", "0" ) 120 << new Xml::AnAttribute( "cellpadding", "3" ) 121 >> *new Html::TableRow 122 ); 123 } 124 125 HF_NaviMainRow::~HF_NaviMainRow() 126 { 127 csv::erase_container_of_heap_ptrs(aItems); 128 } 129 130 void 131 HF_NaviMainRow::Add_StdItem( const char * i_sText, 132 const char * i_sLink ) 133 { 134 aItems.push_back(new StdItem( *pRow,i_sText,i_sLink )); 135 } 136 137 void 138 HF_NaviMainRow::Add_SelfItem( const char * i_sText ) 139 { 140 aItems.push_back(new SelfItem( *pRow,i_sText )); 141 } 142 143 void 144 HF_NaviMainRow::Add_NoneItem( const char * i_sText ) 145 { 146 aItems.push_back(new NoneItem( *pRow,i_sText )); 147 } 148 149 void 150 HF_NaviMainRow::Produce_Row() 151 { 152 ItemList::iterator itEnd = aItems.end(); 153 for ( ItemList::iterator iter = aItems.begin(); 154 iter != itEnd; 155 ++iter ) 156 { 157 (*iter)->Produce_Item(); 158 } 159 } 160 161 162 163 164 //******************** MainItem and derived ones ***************// 165 166 namespace 167 { 168 169 StdItem::StdItem( Xml::Element & o_out, 170 const char * i_sText, 171 const char * i_sLink ) 172 : HF_MainItem(o_out), 173 sText(i_sText), 174 sLink(i_sLink) 175 { 176 } 177 178 StdItem::~StdItem() 179 { 180 } 181 182 void 183 StdItem::do_ProduceItem() const 184 { 185 Xml::Element & 186 rCell = CurOut() >>* new Html::TableCell; 187 rCell 188 << new Html::ClassAttr( "navimain" ) 189 >> *new Html::Link(sLink.c_str()) 190 << new Html::ClassAttr( "navimain" ) 191 << sText.c_str(); 192 } 193 194 SelfItem::SelfItem( Xml::Element & o_out, 195 const char * i_sText ) 196 : HF_MainItem(o_out), 197 sText(i_sText) 198 { 199 } 200 201 SelfItem::~SelfItem() 202 { 203 } 204 205 void 206 SelfItem::do_ProduceItem() const 207 { 208 Xml::Element & 209 rCell = CurOut() >>* new Html::TableCell; 210 rCell 211 << new Html::ClassAttr( "navimainself" ) 212 << sText.c_str(); 213 } 214 215 NoneItem::NoneItem( Xml::Element & o_out, 216 const char * i_sText ) 217 : HF_MainItem(o_out), 218 sText(i_sText) 219 { 220 } 221 222 NoneItem::~NoneItem() 223 { 224 } 225 226 void 227 NoneItem::do_ProduceItem() const 228 { 229 Xml::Element & 230 rCell = CurOut() >>* new Html::TableCell; 231 rCell 232 << new Html::ClassAttr( "navimainnone" ) 233 << sText.c_str(); 234 } 235 236 } // anonymous namespace 237 238 239