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_title.hxx> 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <stdlib.h> 34 35 36 const String C_sTitleBorder("0"); 37 const String C_sTitleWidth("100%"); 38 const String C_sTitlePadding("5"); 39 const String C_sTitleSpacing("3"); 40 41 const String C_sSubTitleBorder("1"); 42 const String C_sSubTitleWidth("100%"); 43 const String C_sSubTitlePadding("5"); 44 const String C_sSubTitleSpacing("0"); 45 const String C_sColSpan("colspan"); 46 47 48 HF_TitleTable::HF_TitleTable( Xml::Element & o_rOut ) 49 : HtmlMaker(o_rOut >> *new Html::Table( C_sTitleBorder, 50 C_sTitleWidth, 51 C_sTitlePadding, 52 C_sTitleSpacing ) 53 << new Html::ClassAttr("title-table") 54 << new Html::StyleAttr("margin-bottom:6pt;") ) 55 { 56 } 57 58 HF_TitleTable::~HF_TitleTable() 59 { 60 } 61 62 void 63 HF_TitleTable::Produce_Title( const char * i_title ) 64 { 65 Add_Row() 66 << new Html::ClassAttr("title") 67 << i_title; 68 } 69 70 void 71 HF_TitleTable::Produce_Title( const char * i_annotations, 72 const char * i_title ) 73 { 74 if (csv::no_str(i_annotations)) 75 { 76 Produce_Title(i_title); 77 return; 78 } 79 80 Xml::Element & 81 rRow = Add_Row(); 82 rRow 83 << new Html::ClassAttr("title"); 84 85 Xml::Element & 86 rTable = rRow 87 >> *new Html::Table() 88 << new Html::ClassAttr("title-table") 89 << new Html::WidthAttr("99%"); 90 Xml::Element & 91 rInnerRow = rTable 92 >> *new Html::TableRow; 93 rInnerRow 94 >> *new Html::TableCell 95 << new Html::WidthAttr("25%") 96 << new Html::ClassAttr("title2") 97 << i_annotations; 98 rInnerRow 99 >> *new Html::TableCell 100 << new Html::WidthAttr("50%") 101 << new Html::ClassAttr("title") 102 << i_title; 103 rInnerRow 104 >> *new Html::TableCell 105 << new Html::WidthAttr("*"); 106 } 107 108 Xml::Element & 109 HF_TitleTable::Add_Row() 110 { 111 return CurOut() 112 >> *new Html::TableRow 113 >> *new Html::TableCell; 114 } 115 116 117 inline const char * 118 get_SubTitleCssClass(HF_SubTitleTable::E_SubLevel i_eSubTitleLevel) 119 { 120 return i_eSubTitleLevel == HF_SubTitleTable::sublevel_1 121 ? "subtitle" 122 : "crosstitle"; 123 } 124 125 126 HF_SubTitleTable::HF_SubTitleTable( Xml::Element & o_rOut, 127 const String & i_label, 128 const String & i_title, 129 int i_nColumns, 130 E_SubLevel i_eSubTitleLevel ) 131 : HtmlMaker( o_rOut 132 << new Html::Label(i_label) 133 >> *new Html::Table( C_sSubTitleBorder, 134 C_sSubTitleWidth, 135 C_sSubTitlePadding, 136 C_sSubTitleSpacing ) 137 << new Html::ClassAttr(get_SubTitleCssClass(i_eSubTitleLevel)) ) 138 { 139 csv_assert(i_nColumns > 0); 140 141 if (i_eSubTitleLevel == sublevel_3) 142 return; 143 144 Xml::Element & 145 rCell = CurOut() 146 >> *new Html::TableRow 147 >> *new Html::TableCell 148 << new Html::ClassAttr(get_SubTitleCssClass(i_eSubTitleLevel)) ; 149 150 if (i_nColumns > 1) 151 { 152 StreamLock sl(20); 153 String sColumns = sl() << i_nColumns << c_str; 154 rCell 155 << new Xml::AnAttribute(C_sColSpan, sColumns); 156 } 157 rCell 158 << i_title; 159 } 160 161 HF_SubTitleTable::~HF_SubTitleTable() 162 { 163 } 164 165 Xml::Element & 166 HF_SubTitleTable::Add_Row() 167 { 168 return CurOut() >> *new Html::TableRow; 169 } 170