1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: navibar.cxx,v $
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 ************************************************************************/
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
;
48 //************************ SubRowItem ***************************//
57 bool i_bFirstOfRow
= false );
61 Element
& o_rOut
) const;
69 SubRowItem::SubRowItem( const char * i_sText
,
76 bFirstOfRow(i_bFirstOfRow
)
78 csv_assert( NOT
csv::no_str(i_sLink
) );
81 SubRowItem::~SubRowItem()
86 SubRowItem::Write2( Element
& o_rOut
) const
89 if ( NOT bFirstOfRow
)
90 o_rOut
<< new XmlCode( "| " );
92 o_rOut
<< new XmlCode( " " );
97 >> *new Link( sLink
.c_str() )
98 >> *new AnElement( "font" )
99 << new AnAttribute("size","-2")
106 >> *new AnElement( "font" )
107 << new AnAttribute("size","-2")
114 //************************ SubRow ***************************//
120 const char * i_sTitle
);
124 const char * i_sText
,
125 const char * i_sLink
,
128 Table
& o_rOut
) const;
130 typedef std::vector
< DYN SubRowItem
* > List_Items
;
132 List_Items aItemList
;
136 SubRow::SubRow( const char * i_sTitle
)
140 StreamStr
sUp(i_sTitle
,0);
142 sTitle
= sUp
.c_str();
147 for ( List_Items::iterator it
= aItemList
.begin();
148 it
!= aItemList
.end();
156 SubRow::AddItem( const char * i_sText
,
157 const char * i_sLink
,
160 aItemList
.push_back( new SubRowItem(i_sText
, i_sLink
, i_bActive
, aItemList
.empty()) );
164 SubRow::Write2( Table
& o_rOut
) const
166 TableRow
* pRow
= new TableRow
;
169 if (sTitle
.length() > 0)
171 Element
& rCell1
= pRow
->AddCell();
173 << new WidthAttr("20%")
174 >> *new AnElement( "font" )
175 << new AnAttribute("size","-2")
180 Element
& rCell2
= pRow
->AddCell();
181 for ( List_Items::const_iterator it
= aItemList
.begin();
182 it
!= aItemList
.end();
185 (*it
)->Write2( rCell2
);
190 } // anonymous namespace
194 //************************* CheshireCat ***********************//
197 typedef std::vector
< DYN SubRow
* > List_SubRows
;
199 struct NavigationBar::CheshireCat
202 List_SubRows aSubRows
;
203 const OuputPage_Environment
*
208 const OuputPage_Environment
&
214 CheshireCat::CheshireCat( const OuputPage_Environment
& i_rEnv
)
215 : aMainRow( i_rEnv
),
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
) )
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;
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;
264 NavigationBar::~NavigationBar()
266 csv::erase_container_of_heap_ptrs( pi
->aSubRows
);
270 NavigationBar::MakeSubRow( const char * i_sTitle
)
272 pi
->aSubRows
.push_back( new SubRow(i_sTitle
) );
276 NavigationBar::AddItem( const char * i_sName
,
277 const char * i_sLink
,
280 csv_assert( pi
->aSubRows
.size() > 0 );
281 StreamStr
sName(i_sName
, 0);
284 StreamLock
aSum(100);
285 pi
->aSubRows
.back()->AddItem( sName
.c_str(),
286 aSum() << "#" << i_sLink
<< c_str
,
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
;
299 << new AnAttribute( "class", "navisub" )
300 << new AnAttribute( "cellpadding", "0" )
301 << new AnAttribute( "cellspacing", "3" );
310 NavigationBar::Write_SubRows() const
312 for ( List_SubRows::const_iterator it
= pi
->aSubRows
.begin();
313 it
!= pi
->aSubRows
.end();
316 (*it
)->Write2( *pSubRowsTable
);