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: nav_main.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 "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>
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 ***************//
67 virtual ~MainItem() {}
71 virtual void do_Write2(
72 TableRow
& o_rOut
) = 0;
76 MainItem::Write2( TableRow
& o_rOut
)
77 { do_Write2(o_rOut
); }
83 class MainRowItem
: public MainItem
87 const String
& i_sText
,
89 const char * i_sTip
);
92 enum E_Style
{ eSelf
, eNo
, eStd
};
94 virtual void do_Write2(
101 MainRowItem::MainRowItem( const String
& i_sText
,
102 const char * i_sLink
,
103 const char * i_sTip
)
110 MainRowItem::~MainRowItem()
115 MainRowItem::do_Write2( TableRow
& o_rOut
)
117 TableCell
& rCell
= o_rOut
.AddCell();
120 << new ClassAttr( "navimain" )
121 << new XmlCode(" ")
122 >> *new Link(sLink
.c_str())
125 << new XmlCode(" ");
129 class SelectedItem
: public MainItem
133 const String
& i_sText
)
136 virtual void do_Write2(
142 SelectedItem::do_Write2( TableRow
& o_rOut
)
144 TableCell
& rCell
= o_rOut
.AddCell();
147 << new ClassAttr( "navimainself" )
148 << new XmlCode(" ")
150 << new XmlCode(" ");
153 class UnavailableItem
: public MainItem
157 const String
& i_sText
)
160 virtual void do_Write2(
166 UnavailableItem::do_Write2( TableRow
& o_rOut
)
168 TableCell
& rCell
= o_rOut
.AddCell();
171 << new ClassAttr( "navimainnone" )
172 << new XmlCode(" ")
174 << new XmlCode(" ");
177 } // anonymous namespace
179 //************************ MainRow ***************************//
181 MainRow::MainRow( const OuputPage_Environment
& i_rEnv
)
189 csv::erase_container_of_heap_ptrs(aItems
);
193 MainRow::SetupItems_Overview()
195 Create_ItemList_Global( eSelf
, eStd
, eStd
);
199 MainRow::SetupItems_AllDefs()
201 Create_ItemList_Global( eStd
, eStd
, eStd
);
205 MainRow::SetupItems_Index()
207 Create_ItemList_Global( eStd
, eSelf
, eStd
);
211 MainRow::SetupItems_Help()
213 Create_ItemList_Global( eStd
, eStd
, eSelf
);
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
),
231 MainRow::SetupItems_FunctionGroup()
233 Create_ItemList_InDirTree_Cpp(
235 (pEnv
->CurClass() != 0 ? eStd
: eNo
),
240 MainRow::SetupItems_DataGroup()
242 SetupItems_FunctionGroup();
246 MainRow::Write2( csi::xml::Element
& o_rOut
) const
248 Table
* pTable
= new Table
;
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();
257 << new AnAttribute( "align", "center" )
258 << new AnAttribute( "valign", "top" );
259 for ( ItemList::const_iterator it
= aItems
.begin();
263 (*it
)->Write2( rRow
);
268 MainRow::Create_ItemList_Global( E_Style i_eOverview
,
272 if ( i_eOverview
== eStd
)
274 String sLinkOverview
= ( i_eIndex
== eSelf
275 ? dshelp::PathPerLevelsUp(
279 Add_Item( i_eOverview
, sOverview
, sLinkOverview
.c_str(), "" );
283 Add_Item( i_eOverview
, sOverview
, "", "" );
286 if ( i_eIndex
== eSelf
)
287 Add_Item( eStd
, sNamespace
, "../names/index.html", "" );
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
, "" );
299 Add_Item( i_eIndex
, sIndex
, "", "" );
302 if ( i_eHelp
== eStd
)
304 String sLinkHelp
= ( i_eIndex
== eSelf
305 ? PathPerLevelsUp(1,C_sHFN_Help
)
307 Add_Item( i_eHelp
, sHelp
, sLinkHelp
.c_str(), "" );
311 Add_Item( i_eHelp
, sHelp
, "", "" );
316 MainRow::Create_ItemList_InDirTree_Cpp( E_Style i_eNsp
,
322 sLinkOverview
= PathPerRoot(*pEnv
, C_sHFN_Overview
);
323 Add_Item( eStd
, sOverview
, sLinkOverview
.c_str(), "" );
327 String sLinkNamespace
= PathPerNamespace(*pEnv
, "index.html");
328 Add_Item( i_eNsp
, sNamespace
, sLinkNamespace
.c_str(), "" );
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()
343 StreamLock
sTipClass(300);
344 sTipClass() << "Class "
345 << pEnv
->CurClass()->LocalName();
346 Add_Item( i_eClass
, sClass
, sLinkClass().c_str(), sTipClass().c_str() );
350 Add_Item( i_eClass
, sClass
, "", "" );
354 Add_Item( eStd
, sIndex
, PathPerRoot(*pEnv
, C_sPath_Index
), "" );
356 sLinkHelp
= PathPerRoot(*pEnv
, "help.html");
357 Add_Item( eStd
, sHelp
, sLinkHelp
.c_str(), "" );
361 MainRow::Add_Item( E_Style i_eStyle
,
362 const String
& i_sText
,
363 const char * i_sLink
,
364 const char * i_sTip
)
368 case eStd
: aItems
.push_back( new MainRowItem(i_sText
, i_sLink
, i_sTip
) );
370 case eNo
: aItems
.push_back( new UnavailableItem(i_sText
) );
372 case eSelf
: aItems
.push_back( new SelectedItem(i_sText
) );