Update ooo320-m1
[ooovba.git] / autodoc / source / display / html / nav_main.cxx
blob56bf549e7238e94dd9c3e7052df9d4cf9f2588dd
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: nav_main.cxx,v $
10 * $Revision: 1.9 $
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 "nav_main.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
37 #include <ary/cpp/c_ce.hxx>
38 #include <ary/cpp/c_gate.hxx>
39 #include <ary/cpp/c_namesp.hxx>
40 #include <ary/cpp/c_class.hxx>
41 #include <ary/loc/loc_file.hxx>
42 #include <udm/html/htmlitem.hxx>
43 #include "hdimpl.hxx"
44 #include "opageenv.hxx"
45 #include "strconst.hxx"
48 using namespace ::csi::html;
49 using namespace ::csi::xml;
52 const String sOverview("Overview");
53 const String sNamespace("Namespace");
54 const String sClass("Class");
55 const String sTree("Tree");
56 const String sProject("Project");
57 const String sFile("File");
58 const String sIndex("Index");
59 const String sHelp("Help");
63 //******************** MainItem and derived ones ***************//
64 class MainItem
66 public:
67 virtual ~MainItem() {}
68 void Write2(
69 TableRow & o_rOut );
70 private:
71 virtual void do_Write2(
72 TableRow & o_rOut ) = 0;
75 inline void
76 MainItem::Write2( TableRow & o_rOut )
77 { do_Write2(o_rOut); }
80 namespace
83 class MainRowItem : public MainItem
85 public:
86 MainRowItem(
87 const String & i_sText,
88 const char * i_sLink,
89 const char * i_sTip );
90 ~MainRowItem();
91 private:
92 enum E_Style { eSelf, eNo, eStd };
94 virtual void do_Write2(
95 TableRow & o_rOut );
96 String sText;
97 String sLink;
98 String sTip;
101 MainRowItem::MainRowItem( const String & i_sText,
102 const char * i_sLink,
103 const char * i_sTip )
104 : sText(i_sText),
105 sLink(i_sLink),
106 sTip(i_sTip)
110 MainRowItem::~MainRowItem()
114 void
115 MainRowItem::do_Write2( TableRow & o_rOut )
117 TableCell & rCell = o_rOut.AddCell();
119 rCell
120 << new ClassAttr( "navimain" )
121 << new XmlCode("&nbsp;")
122 >> *new Link(sLink.c_str())
123 << sText.c_str();
124 rCell
125 << new XmlCode("&nbsp;");
129 class SelectedItem : public MainItem
131 public:
132 SelectedItem(
133 const String & i_sText )
134 : sText(i_sText) {}
135 private:
136 virtual void do_Write2(
137 TableRow & o_rOut );
138 String sText;
141 void
142 SelectedItem::do_Write2( TableRow & o_rOut )
144 TableCell & rCell = o_rOut.AddCell();
146 rCell
147 << new ClassAttr( "navimainself" )
148 << new XmlCode("&nbsp;")
149 << sText.c_str()
150 << new XmlCode("&nbsp;");
153 class UnavailableItem : public MainItem
155 public:
156 UnavailableItem(
157 const String & i_sText )
158 : sText(i_sText) {}
159 private:
160 virtual void do_Write2(
161 TableRow & o_rOut );
162 String sText;
165 void
166 UnavailableItem::do_Write2( TableRow & o_rOut )
168 TableCell & rCell = o_rOut.AddCell();
170 rCell
171 << new ClassAttr( "navimainnone" )
172 << new XmlCode("&nbsp;")
173 << sText.c_str()
174 << new XmlCode("&nbsp;");
177 } // anonymous namespace
179 //************************ MainRow ***************************//
181 MainRow::MainRow( const OuputPage_Environment & i_rEnv )
182 : // aItems,
183 pEnv(&i_rEnv)
187 MainRow::~MainRow()
189 csv::erase_container_of_heap_ptrs(aItems);
192 void
193 MainRow::SetupItems_Overview()
195 Create_ItemList_Global( eSelf, eStd, eStd );
198 void
199 MainRow::SetupItems_AllDefs()
201 Create_ItemList_Global( eStd, eStd, eStd );
204 void
205 MainRow::SetupItems_Index()
207 Create_ItemList_Global( eStd, eSelf, eStd );
210 void
211 MainRow::SetupItems_Help()
213 Create_ItemList_Global( eStd, eStd, eSelf );
216 void
217 MainRow::SetupItems_Ce( const ary::cpp::CodeEntity & i_rCe )
219 csv_assert( pEnv->CurNamespace() != 0 );
220 bool bIsNamespace = i_rCe.Id() == pEnv->CurNamespace()->Id();
221 bool bHasClass = pEnv->CurClass() != 0;
222 bool bIsClass = dynamic_cast< const ary::cpp::Class * >(&i_rCe) != 0;
224 Create_ItemList_InDirTree_Cpp(
225 ( bIsNamespace ? eSelf : eStd ),
226 ( bIsClass ? eSelf : bHasClass ? eStd : eNo ),
227 eNo, 0 );
230 void
231 MainRow::SetupItems_FunctionGroup()
233 Create_ItemList_InDirTree_Cpp(
234 eStd,
235 (pEnv->CurClass() != 0 ? eStd : eNo),
236 eNo, 0 );
239 void
240 MainRow::SetupItems_DataGroup()
242 SetupItems_FunctionGroup();
245 void
246 MainRow::Write2( csi::xml::Element & o_rOut ) const
248 Table * pTable = new Table;
249 o_rOut
250 >> *pTable
251 << new AnAttribute( "class", "navimain" )
252 << new AnAttribute( "border", "0" )
253 << new AnAttribute( "cellpadding", "1" )
254 << new AnAttribute( "cellspacing", "0" );
255 TableRow & rRow = pTable->AddRow();
256 rRow
257 << new AnAttribute( "align", "center" )
258 << new AnAttribute( "valign", "top" );
259 for ( ItemList::const_iterator it = aItems.begin();
260 it != aItems.end();
261 ++it )
263 (*it)->Write2( rRow );
267 void
268 MainRow::Create_ItemList_Global( E_Style i_eOverview,
269 E_Style i_eIndex,
270 E_Style i_eHelp )
272 if ( i_eOverview == eStd )
274 String sLinkOverview = ( i_eIndex == eSelf
275 ? dshelp::PathPerLevelsUp(
277 C_sHFN_Overview )
278 : C_sHFN_Overview );
279 Add_Item( i_eOverview, sOverview, sLinkOverview.c_str(), "" );
281 else
283 Add_Item( i_eOverview, sOverview, "", "" );
286 if ( i_eIndex == eSelf )
287 Add_Item( eStd, sNamespace, "../names/index.html", "" );
288 else
289 Add_Item( eStd, sNamespace, "names/index.html", "" );
291 Add_Item( eNo, sClass, "", "" );
293 if ( i_eIndex == eStd )
295 Add_Item( i_eIndex, sIndex, C_sPath_Index, "" );
297 else
299 Add_Item( i_eIndex, sIndex, "", "" );
302 if ( i_eHelp == eStd )
304 String sLinkHelp = ( i_eIndex == eSelf
305 ? PathPerLevelsUp(1,C_sHFN_Help)
306 : C_sHFN_Help );
307 Add_Item( i_eHelp, sHelp, sLinkHelp.c_str(), "" );
309 else
311 Add_Item( i_eHelp, sHelp, "", "" );
315 void
316 MainRow::Create_ItemList_InDirTree_Cpp( E_Style i_eNsp,
317 E_Style i_eClass,
318 E_Style ,
319 const char * )
321 String
322 sLinkOverview = PathPerRoot(*pEnv, C_sHFN_Overview);
323 Add_Item( eStd, sOverview, sLinkOverview.c_str(), "" );
325 if (i_eNsp == eStd)
327 String sLinkNamespace = PathPerNamespace(*pEnv, "index.html");
328 Add_Item( i_eNsp, sNamespace, sLinkNamespace.c_str(), "" );
330 else
332 Add_Item( i_eNsp, sNamespace, "", "" );
335 if (i_eClass == eStd)
337 csv_assert( pEnv->CurClass() != 0 );
339 StreamLock sLinkClass(300);
340 sLinkClass() << PathPerNamespace(*pEnv, "c-")
341 << pEnv->CurClass()->LocalName()
342 << ".html";
343 StreamLock sTipClass(300);
344 sTipClass() << "Class "
345 << pEnv->CurClass()->LocalName();
346 Add_Item( i_eClass, sClass, sLinkClass().c_str(), sTipClass().c_str() );
348 else
350 Add_Item( i_eClass, sClass, "", "" );
354 Add_Item( eStd, sIndex, PathPerRoot(*pEnv, C_sPath_Index), "" );
355 String
356 sLinkHelp = PathPerRoot(*pEnv, "help.html");
357 Add_Item( eStd, sHelp, sLinkHelp.c_str(), "" );
360 void
361 MainRow::Add_Item( E_Style i_eStyle,
362 const String & i_sText,
363 const char * i_sLink,
364 const char * i_sTip )
366 switch (i_eStyle)
368 case eStd: aItems.push_back( new MainRowItem(i_sText, i_sLink, i_sTip) );
369 break;
370 case eNo: aItems.push_back( new UnavailableItem(i_sText) );
371 break;
372 case eSelf: aItems.push_back( new SelectedItem(i_sText) );
373 break;
374 default:
375 csv_assert(false);