1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <precomp.h>
23 #include <toolkit/hf_title.hxx>
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <stdlib.h>
28 
29 
30 const String C_sTitleBorder("0");
31 const String C_sTitleWidth("100%");
32 const String C_sTitlePadding("5");
33 const String C_sTitleSpacing("3");
34 
35 const String C_sSubTitleBorder("1");
36 const String C_sSubTitleWidth("100%");
37 const String C_sSubTitlePadding("5");
38 const String C_sSubTitleSpacing("0");
39 const String C_sColSpan("colspan");
40 
41 
HF_TitleTable(Xml::Element & o_rOut)42 HF_TitleTable::HF_TitleTable( Xml::Element & o_rOut )
43     :   HtmlMaker(o_rOut >> *new Html::Table( C_sTitleBorder,
44 											  C_sTitleWidth,
45 											  C_sTitlePadding,
46 											  C_sTitleSpacing )
47 				            << new Html::ClassAttr("title-table")
48 				            << new Html::StyleAttr("margin-bottom:6pt;") )
49 {
50 }
51 
~HF_TitleTable()52 HF_TitleTable::~HF_TitleTable()
53 {
54 }
55 
56 void
Produce_Title(const char * i_title)57 HF_TitleTable::Produce_Title( const char * i_title )
58 {
59     Add_Row()
60         << new Html::ClassAttr("title")
61         << i_title;
62 }
63 
64 void
Produce_Title(const char * i_annotations,const char * i_title)65 HF_TitleTable::Produce_Title( const char *        i_annotations,
66                               const char *        i_title )
67 {
68     if (csv::no_str(i_annotations))
69     {
70         Produce_Title(i_title);
71         return;
72     }
73 
74     Xml::Element &
75         rRow = Add_Row();
76     rRow
77         << new Html::ClassAttr("title");
78 
79     Xml::Element &
80         rTable = rRow
81                     >> *new Html::Table()
82                         << new Html::ClassAttr("title-table")
83                         << new Html::WidthAttr("99%");
84     Xml::Element &
85         rInnerRow = rTable
86                         >> *new Html::TableRow;
87     rInnerRow
88         >> *new Html::TableCell
89             << new Html::WidthAttr("25%")
90             << new Html::ClassAttr("title2")
91             << i_annotations;
92     rInnerRow
93         >> *new Html::TableCell
94             << new Html::WidthAttr("50%")
95             << new Html::ClassAttr("title")
96             << i_title;
97     rInnerRow
98         >> *new Html::TableCell
99             << new Html::WidthAttr("*");
100 }
101 
102 Xml::Element &
Add_Row()103 HF_TitleTable::Add_Row()
104 {
105     return CurOut()
106             >> *new Html::TableRow
107                 >> *new Html::TableCell;
108 }
109 
110 
111 inline const char *
get_SubTitleCssClass(HF_SubTitleTable::E_SubLevel i_eSubTitleLevel)112 get_SubTitleCssClass(HF_SubTitleTable::E_SubLevel i_eSubTitleLevel)
113 {
114     return i_eSubTitleLevel == HF_SubTitleTable::sublevel_1
115             ?   "subtitle"
116             :   "crosstitle";
117 }
118 
119 
HF_SubTitleTable(Xml::Element & o_rOut,const String & i_label,const String & i_title,int i_nColumns,E_SubLevel i_eSubTitleLevel)120 HF_SubTitleTable::HF_SubTitleTable( Xml::Element &      o_rOut,
121                                     const String &      i_label,
122                                     const String &      i_title,
123                                     int                 i_nColumns,
124                                     E_SubLevel          i_eSubTitleLevel )
125     :   HtmlMaker( o_rOut
126                     << new Html::Label(i_label)
127                     >> *new Html::Table( C_sSubTitleBorder,
128 										 C_sSubTitleWidth,
129 										 C_sSubTitlePadding,
130 										 C_sSubTitleSpacing )
131 			            << new Html::ClassAttr(get_SubTitleCssClass(i_eSubTitleLevel)) )
132 {
133     csv_assert(i_nColumns > 0);
134 
135     if (i_eSubTitleLevel == sublevel_3)
136         return;
137 
138     Xml::Element &
139         rCell = CurOut()
140                     >> *new Html::TableRow
141                         >> *new Html::TableCell
142                         << new Html::ClassAttr(get_SubTitleCssClass(i_eSubTitleLevel)) ;
143 
144     if (i_nColumns > 1)
145     {
146         StreamLock sl(20);
147         String sColumns = sl() << i_nColumns << c_str;
148         rCell
149             << new Xml::AnAttribute(C_sColSpan, sColumns);
150     }
151     rCell
152         << i_title;
153 }
154 
~HF_SubTitleTable()155 HF_SubTitleTable::~HF_SubTitleTable()
156 {
157 }
158 
159 Xml::Element &
Add_Row()160 HF_SubTitleTable::Add_Row()
161 {
162     return CurOut() >> *new Html::TableRow;
163 }
164