Update ooo320-m1
[ooovba.git] / autodoc / source / display / html / navibar.cxx
blob275b13e01897f8e44b82a4f530424006fe377127
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: navibar.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include "navibar.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
37 #include "nav_main.hxx"
38 #include "opageenv.hxx"
41 using namespace csi::xml;
42 using namespace csi::html;
45 namespace
48 //************************ SubRowItem ***************************//
50 class SubRowItem
52 public:
53 SubRowItem(
54 const char * i_sText,
55 const char * i_sLink,
56 bool i_bActive,
57 bool i_bFirstOfRow = false );
58 ~SubRowItem();
60 void Write2(
61 Element & o_rOut ) const;
62 private:
63 String sText;
64 String sLink;
65 bool bIsActive;
66 bool bFirstOfRow;
69 SubRowItem::SubRowItem( const char * i_sText,
70 const char * i_sLink,
71 bool i_bActive,
72 bool i_bFirstOfRow )
73 : sText(i_sText),
74 sLink(i_sLink),
75 bIsActive(i_bActive),
76 bFirstOfRow(i_bFirstOfRow)
78 csv_assert( NOT csv::no_str(i_sLink) );
81 SubRowItem::~SubRowItem()
85 void
86 SubRowItem::Write2( Element & o_rOut ) const
88 o_rOut << new Sbr;
89 if ( NOT bFirstOfRow )
90 o_rOut << new XmlCode( "|&nbsp;" );
91 else
92 o_rOut << new XmlCode( "&nbsp;" );
94 if ( bIsActive )
96 o_rOut
97 >> *new Link( sLink.c_str() )
98 >> *new AnElement( "font" )
99 << new AnAttribute("size","-2")
100 >> *new Bold
101 << sText.c_str();
103 else
105 o_rOut
106 >> *new AnElement( "font" )
107 << new AnAttribute("size","-2")
108 << sText.c_str();
114 //************************ SubRow ***************************//
116 class SubRow
118 public:
119 SubRow(
120 const char * i_sTitle );
121 ~SubRow();
123 void AddItem(
124 const char * i_sText,
125 const char * i_sLink,
126 bool i_bActive );
127 void Write2(
128 Table & o_rOut ) const;
129 private:
130 typedef std::vector< DYN SubRowItem * > List_Items;
132 List_Items aItemList;
133 String sTitle;
136 SubRow::SubRow( const char * i_sTitle )
137 // : // aItemList,
138 // sTitle
140 StreamStr sUp(i_sTitle,0);
141 sUp.to_upper();
142 sTitle = sUp.c_str();
145 SubRow::~SubRow()
147 for ( List_Items::iterator it = aItemList.begin();
148 it != aItemList.end();
149 ++it )
151 delete (*it);
155 inline void
156 SubRow::AddItem( const char * i_sText,
157 const char * i_sLink,
158 bool i_bActive )
160 aItemList.push_back( new SubRowItem(i_sText, i_sLink, i_bActive, aItemList.empty()) );
163 void
164 SubRow::Write2( Table & o_rOut ) const
166 TableRow * pRow = new TableRow;
167 o_rOut << pRow;
169 if (sTitle.length() > 0)
171 Element & rCell1 = pRow->AddCell();
172 rCell1
173 << new WidthAttr("20%")
174 >> *new AnElement( "font" )
175 << new AnAttribute("size","-2")
176 << sTitle
177 << ":";
180 Element & rCell2 = pRow->AddCell();
181 for ( List_Items::const_iterator it = aItemList.begin();
182 it != aItemList.end();
183 ++it )
185 (*it)->Write2( rCell2 );
190 } // anonymous namespace
194 //************************* CheshireCat ***********************//
197 typedef std::vector< DYN SubRow * > List_SubRows;
199 struct NavigationBar::CheshireCat
201 MainRow aMainRow;
202 List_SubRows aSubRows;
203 const OuputPage_Environment *
204 pEnv;
207 CheshireCat(
208 const OuputPage_Environment &
209 i_rEnv );
210 ~CheshireCat();
213 NavigationBar::
214 CheshireCat::CheshireCat( const OuputPage_Environment & i_rEnv )
215 : aMainRow( i_rEnv ),
216 pEnv( & i_rEnv )
220 NavigationBar::
221 CheshireCat::~CheshireCat()
223 csv::erase_container_of_heap_ptrs( aSubRows );
227 //************************ NavigationBar *******************//
229 NavigationBar::NavigationBar( const OuputPage_Environment & i_rEnv,
230 E_GlobalLocation i_eLocation )
231 : pi( new CheshireCat(i_rEnv) )
233 switch (i_eLocation)
235 case LOC_Overview: pi->aMainRow.SetupItems_Overview(); break;
236 case LOC_AllDefs: pi->aMainRow.SetupItems_AllDefs(); break;
237 case LOC_Index: pi->aMainRow.SetupItems_Index(); break;
238 case LOC_Help: pi->aMainRow.SetupItems_Help(); break;
239 default:
240 csv_assert(false);
244 NavigationBar::NavigationBar( const OuputPage_Environment & i_rEnv,
245 const ary::cpp::CodeEntity & i_rCe )
246 : pi( new CheshireCat(i_rEnv) )
248 pi->aMainRow.SetupItems_Ce( i_rCe );
251 NavigationBar::NavigationBar( const OuputPage_Environment & i_rEnv,
252 E_CeGatheringType i_eCeGatheringType )
253 : pi( new CheshireCat(i_rEnv) )
255 switch (i_eCeGatheringType)
257 case CEGT_operations: pi->aMainRow.SetupItems_FunctionGroup(); break;
258 case CEGT_data: pi->aMainRow.SetupItems_DataGroup(); break;
259 default:
260 csv_assert(false);
264 NavigationBar::~NavigationBar()
266 csv::erase_container_of_heap_ptrs( pi->aSubRows );
269 void
270 NavigationBar::MakeSubRow( const char * i_sTitle )
272 pi->aSubRows.push_back( new SubRow(i_sTitle) );
275 void
276 NavigationBar::AddItem( const char * i_sName,
277 const char * i_sLink,
278 bool i_bValid )
280 csv_assert( pi->aSubRows.size() > 0 );
281 StreamStr sName(i_sName, 0);
282 sName.to_upper();
284 StreamLock aSum(100);
285 pi->aSubRows.back()->AddItem( sName.c_str(),
286 aSum() << "#" << i_sLink << c_str,
287 i_bValid );
290 void
291 NavigationBar::Write( Element & o_rOut,
292 bool i_bWithSubRows ) const
294 pi->aMainRow.Write2( o_rOut );
296 const_cast< NavigationBar* >(this)->pSubRowsTable = new Table;
297 o_rOut << pSubRowsTable;
298 *pSubRowsTable
299 << new AnAttribute( "class", "navisub" )
300 << new AnAttribute( "cellpadding", "0" )
301 << new AnAttribute( "cellspacing", "3" );
303 if (i_bWithSubRows)
305 Write_SubRows();
309 void
310 NavigationBar::Write_SubRows() const
312 for ( List_SubRows::const_iterator it = pi->aSubRows.begin();
313 it != pi->aSubRows.end();
314 ++it )
316 (*it)->Write2( *pSubRowsTable );