xref: /AOO41X/main/autodoc/source/display/toolkit/hf_title.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include <toolkit/hf_title.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
33*cdf0e10cSrcweir #include <stdlib.h>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir const String C_sTitleBorder("0");
37*cdf0e10cSrcweir const String C_sTitleWidth("100%");
38*cdf0e10cSrcweir const String C_sTitlePadding("5");
39*cdf0e10cSrcweir const String C_sTitleSpacing("3");
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir const String C_sSubTitleBorder("1");
42*cdf0e10cSrcweir const String C_sSubTitleWidth("100%");
43*cdf0e10cSrcweir const String C_sSubTitlePadding("5");
44*cdf0e10cSrcweir const String C_sSubTitleSpacing("0");
45*cdf0e10cSrcweir const String C_sColSpan("colspan");
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir HF_TitleTable::HF_TitleTable( Xml::Element & o_rOut )
49*cdf0e10cSrcweir     :   HtmlMaker(o_rOut >> *new Html::Table( C_sTitleBorder,
50*cdf0e10cSrcweir 											  C_sTitleWidth,
51*cdf0e10cSrcweir 											  C_sTitlePadding,
52*cdf0e10cSrcweir 											  C_sTitleSpacing )
53*cdf0e10cSrcweir 				            << new Html::ClassAttr("title-table")
54*cdf0e10cSrcweir 				            << new Html::StyleAttr("margin-bottom:6pt;") )
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir HF_TitleTable::~HF_TitleTable()
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir }
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir void
63*cdf0e10cSrcweir HF_TitleTable::Produce_Title( const char * i_title )
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     Add_Row()
66*cdf0e10cSrcweir         << new Html::ClassAttr("title")
67*cdf0e10cSrcweir         << i_title;
68*cdf0e10cSrcweir }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir void
71*cdf0e10cSrcweir HF_TitleTable::Produce_Title( const char *        i_annotations,
72*cdf0e10cSrcweir                               const char *        i_title )
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir     if (csv::no_str(i_annotations))
75*cdf0e10cSrcweir     {
76*cdf0e10cSrcweir         Produce_Title(i_title);
77*cdf0e10cSrcweir         return;
78*cdf0e10cSrcweir     }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     Xml::Element &
81*cdf0e10cSrcweir         rRow = Add_Row();
82*cdf0e10cSrcweir     rRow
83*cdf0e10cSrcweir         << new Html::ClassAttr("title");
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     Xml::Element &
86*cdf0e10cSrcweir         rTable = rRow
87*cdf0e10cSrcweir                     >> *new Html::Table()
88*cdf0e10cSrcweir                         << new Html::ClassAttr("title-table")
89*cdf0e10cSrcweir                         << new Html::WidthAttr("99%");
90*cdf0e10cSrcweir     Xml::Element &
91*cdf0e10cSrcweir         rInnerRow = rTable
92*cdf0e10cSrcweir                         >> *new Html::TableRow;
93*cdf0e10cSrcweir     rInnerRow
94*cdf0e10cSrcweir         >> *new Html::TableCell
95*cdf0e10cSrcweir             << new Html::WidthAttr("25%")
96*cdf0e10cSrcweir             << new Html::ClassAttr("title2")
97*cdf0e10cSrcweir             << i_annotations;
98*cdf0e10cSrcweir     rInnerRow
99*cdf0e10cSrcweir         >> *new Html::TableCell
100*cdf0e10cSrcweir             << new Html::WidthAttr("50%")
101*cdf0e10cSrcweir             << new Html::ClassAttr("title")
102*cdf0e10cSrcweir             << i_title;
103*cdf0e10cSrcweir     rInnerRow
104*cdf0e10cSrcweir         >> *new Html::TableCell
105*cdf0e10cSrcweir             << new Html::WidthAttr("*");
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir Xml::Element &
109*cdf0e10cSrcweir HF_TitleTable::Add_Row()
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir     return CurOut()
112*cdf0e10cSrcweir             >> *new Html::TableRow
113*cdf0e10cSrcweir                 >> *new Html::TableCell;
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir inline const char *
118*cdf0e10cSrcweir get_SubTitleCssClass(HF_SubTitleTable::E_SubLevel i_eSubTitleLevel)
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir     return i_eSubTitleLevel == HF_SubTitleTable::sublevel_1
121*cdf0e10cSrcweir             ?   "subtitle"
122*cdf0e10cSrcweir             :   "crosstitle";
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir HF_SubTitleTable::HF_SubTitleTable( Xml::Element &      o_rOut,
127*cdf0e10cSrcweir                                     const String &      i_label,
128*cdf0e10cSrcweir                                     const String &      i_title,
129*cdf0e10cSrcweir                                     int                 i_nColumns,
130*cdf0e10cSrcweir                                     E_SubLevel          i_eSubTitleLevel )
131*cdf0e10cSrcweir     :   HtmlMaker( o_rOut
132*cdf0e10cSrcweir                     << new Html::Label(i_label)
133*cdf0e10cSrcweir                     >> *new Html::Table( C_sSubTitleBorder,
134*cdf0e10cSrcweir 										 C_sSubTitleWidth,
135*cdf0e10cSrcweir 										 C_sSubTitlePadding,
136*cdf0e10cSrcweir 										 C_sSubTitleSpacing )
137*cdf0e10cSrcweir 			            << new Html::ClassAttr(get_SubTitleCssClass(i_eSubTitleLevel)) )
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir     csv_assert(i_nColumns > 0);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     if (i_eSubTitleLevel == sublevel_3)
142*cdf0e10cSrcweir         return;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     Xml::Element &
145*cdf0e10cSrcweir         rCell = CurOut()
146*cdf0e10cSrcweir                     >> *new Html::TableRow
147*cdf0e10cSrcweir                         >> *new Html::TableCell
148*cdf0e10cSrcweir                         << new Html::ClassAttr(get_SubTitleCssClass(i_eSubTitleLevel)) ;
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     if (i_nColumns > 1)
151*cdf0e10cSrcweir     {
152*cdf0e10cSrcweir         StreamLock sl(20);
153*cdf0e10cSrcweir         String sColumns = sl() << i_nColumns << c_str;
154*cdf0e10cSrcweir         rCell
155*cdf0e10cSrcweir             << new Xml::AnAttribute(C_sColSpan, sColumns);
156*cdf0e10cSrcweir     }
157*cdf0e10cSrcweir     rCell
158*cdf0e10cSrcweir         << i_title;
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir HF_SubTitleTable::~HF_SubTitleTable()
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir Xml::Element &
166*cdf0e10cSrcweir HF_SubTitleTable::Add_Row()
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir     return CurOut() >> *new Html::TableRow;
169*cdf0e10cSrcweir }
170