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