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 "nav_main.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx> 34*cdf0e10cSrcweir #include <ary/cpp/c_ce.hxx> 35*cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx> 36*cdf0e10cSrcweir #include <ary/cpp/c_namesp.hxx> 37*cdf0e10cSrcweir #include <ary/cpp/c_class.hxx> 38*cdf0e10cSrcweir #include <ary/loc/loc_file.hxx> 39*cdf0e10cSrcweir #include <udm/html/htmlitem.hxx> 40*cdf0e10cSrcweir #include "hdimpl.hxx" 41*cdf0e10cSrcweir #include "opageenv.hxx" 42*cdf0e10cSrcweir #include "strconst.hxx" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir using namespace ::csi::html; 46*cdf0e10cSrcweir using namespace ::csi::xml; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir const String sOverview("Overview"); 50*cdf0e10cSrcweir const String sNamespace("Namespace"); 51*cdf0e10cSrcweir const String sClass("Class"); 52*cdf0e10cSrcweir const String sTree("Tree"); 53*cdf0e10cSrcweir const String sProject("Project"); 54*cdf0e10cSrcweir const String sFile("File"); 55*cdf0e10cSrcweir const String sIndex("Index"); 56*cdf0e10cSrcweir const String sHelp("Help"); 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir //******************** MainItem and derived ones ***************// 61*cdf0e10cSrcweir class MainItem 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir public: 64*cdf0e10cSrcweir virtual ~MainItem() {} 65*cdf0e10cSrcweir void Write2( 66*cdf0e10cSrcweir TableRow & o_rOut ); 67*cdf0e10cSrcweir private: 68*cdf0e10cSrcweir virtual void do_Write2( 69*cdf0e10cSrcweir TableRow & o_rOut ) = 0; 70*cdf0e10cSrcweir }; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir inline void 73*cdf0e10cSrcweir MainItem::Write2( TableRow & o_rOut ) 74*cdf0e10cSrcweir { do_Write2(o_rOut); } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir namespace 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir class MainRowItem : public MainItem 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir public: 83*cdf0e10cSrcweir MainRowItem( 84*cdf0e10cSrcweir const String & i_sText, 85*cdf0e10cSrcweir const char * i_sLink, 86*cdf0e10cSrcweir const char * i_sTip ); 87*cdf0e10cSrcweir ~MainRowItem(); 88*cdf0e10cSrcweir private: 89*cdf0e10cSrcweir enum E_Style { eSelf, eNo, eStd }; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir virtual void do_Write2( 92*cdf0e10cSrcweir TableRow & o_rOut ); 93*cdf0e10cSrcweir String sText; 94*cdf0e10cSrcweir String sLink; 95*cdf0e10cSrcweir String sTip; 96*cdf0e10cSrcweir }; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir MainRowItem::MainRowItem( const String & i_sText, 99*cdf0e10cSrcweir const char * i_sLink, 100*cdf0e10cSrcweir const char * i_sTip ) 101*cdf0e10cSrcweir : sText(i_sText), 102*cdf0e10cSrcweir sLink(i_sLink), 103*cdf0e10cSrcweir sTip(i_sTip) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir MainRowItem::~MainRowItem() 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir void 112*cdf0e10cSrcweir MainRowItem::do_Write2( TableRow & o_rOut ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir TableCell & rCell = o_rOut.AddCell(); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir rCell 117*cdf0e10cSrcweir << new ClassAttr( "navimain" ) 118*cdf0e10cSrcweir << new XmlCode(" ") 119*cdf0e10cSrcweir >> *new Link(sLink.c_str()) 120*cdf0e10cSrcweir << sText.c_str(); 121*cdf0e10cSrcweir rCell 122*cdf0e10cSrcweir << new XmlCode(" "); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir class SelectedItem : public MainItem 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir public: 129*cdf0e10cSrcweir SelectedItem( 130*cdf0e10cSrcweir const String & i_sText ) 131*cdf0e10cSrcweir : sText(i_sText) {} 132*cdf0e10cSrcweir private: 133*cdf0e10cSrcweir virtual void do_Write2( 134*cdf0e10cSrcweir TableRow & o_rOut ); 135*cdf0e10cSrcweir String sText; 136*cdf0e10cSrcweir }; 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir void 139*cdf0e10cSrcweir SelectedItem::do_Write2( TableRow & o_rOut ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir TableCell & rCell = o_rOut.AddCell(); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir rCell 144*cdf0e10cSrcweir << new ClassAttr( "navimainself" ) 145*cdf0e10cSrcweir << new XmlCode(" ") 146*cdf0e10cSrcweir << sText.c_str() 147*cdf0e10cSrcweir << new XmlCode(" "); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir class UnavailableItem : public MainItem 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir public: 153*cdf0e10cSrcweir UnavailableItem( 154*cdf0e10cSrcweir const String & i_sText ) 155*cdf0e10cSrcweir : sText(i_sText) {} 156*cdf0e10cSrcweir private: 157*cdf0e10cSrcweir virtual void do_Write2( 158*cdf0e10cSrcweir TableRow & o_rOut ); 159*cdf0e10cSrcweir String sText; 160*cdf0e10cSrcweir }; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir void 163*cdf0e10cSrcweir UnavailableItem::do_Write2( TableRow & o_rOut ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir TableCell & rCell = o_rOut.AddCell(); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir rCell 168*cdf0e10cSrcweir << new ClassAttr( "navimainnone" ) 169*cdf0e10cSrcweir << new XmlCode(" ") 170*cdf0e10cSrcweir << sText.c_str() 171*cdf0e10cSrcweir << new XmlCode(" "); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir } // anonymous namespace 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir //************************ MainRow ***************************// 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir MainRow::MainRow( const OuputPage_Environment & i_rEnv ) 179*cdf0e10cSrcweir : // aItems, 180*cdf0e10cSrcweir pEnv(&i_rEnv) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir MainRow::~MainRow() 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir csv::erase_container_of_heap_ptrs(aItems); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir void 190*cdf0e10cSrcweir MainRow::SetupItems_Overview() 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir Create_ItemList_Global( eSelf, eStd, eStd ); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir void 196*cdf0e10cSrcweir MainRow::SetupItems_AllDefs() 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir Create_ItemList_Global( eStd, eStd, eStd ); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir void 202*cdf0e10cSrcweir MainRow::SetupItems_Index() 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir Create_ItemList_Global( eStd, eSelf, eStd ); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir void 208*cdf0e10cSrcweir MainRow::SetupItems_Help() 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir Create_ItemList_Global( eStd, eStd, eSelf ); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir void 214*cdf0e10cSrcweir MainRow::SetupItems_Ce( const ary::cpp::CodeEntity & i_rCe ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir csv_assert( pEnv->CurNamespace() != 0 ); 217*cdf0e10cSrcweir bool bIsNamespace = i_rCe.Id() == pEnv->CurNamespace()->Id(); 218*cdf0e10cSrcweir bool bHasClass = pEnv->CurClass() != 0; 219*cdf0e10cSrcweir bool bIsClass = dynamic_cast< const ary::cpp::Class * >(&i_rCe) != 0; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir Create_ItemList_InDirTree_Cpp( 222*cdf0e10cSrcweir ( bIsNamespace ? eSelf : eStd ), 223*cdf0e10cSrcweir ( bIsClass ? eSelf : bHasClass ? eStd : eNo ), 224*cdf0e10cSrcweir eNo, 0 ); 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir void 228*cdf0e10cSrcweir MainRow::SetupItems_FunctionGroup() 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir Create_ItemList_InDirTree_Cpp( 231*cdf0e10cSrcweir eStd, 232*cdf0e10cSrcweir (pEnv->CurClass() != 0 ? eStd : eNo), 233*cdf0e10cSrcweir eNo, 0 ); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir void 237*cdf0e10cSrcweir MainRow::SetupItems_DataGroup() 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir SetupItems_FunctionGroup(); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir void 243*cdf0e10cSrcweir MainRow::Write2( csi::xml::Element & o_rOut ) const 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir Table * pTable = new Table; 246*cdf0e10cSrcweir o_rOut 247*cdf0e10cSrcweir >> *pTable 248*cdf0e10cSrcweir << new AnAttribute( "class", "navimain" ) 249*cdf0e10cSrcweir << new AnAttribute( "border", "0" ) 250*cdf0e10cSrcweir << new AnAttribute( "cellpadding", "1" ) 251*cdf0e10cSrcweir << new AnAttribute( "cellspacing", "0" ); 252*cdf0e10cSrcweir TableRow & rRow = pTable->AddRow(); 253*cdf0e10cSrcweir rRow 254*cdf0e10cSrcweir << new AnAttribute( "align", "center" ) 255*cdf0e10cSrcweir << new AnAttribute( "valign", "top" ); 256*cdf0e10cSrcweir for ( ItemList::const_iterator it = aItems.begin(); 257*cdf0e10cSrcweir it != aItems.end(); 258*cdf0e10cSrcweir ++it ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir (*it)->Write2( rRow ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir void 265*cdf0e10cSrcweir MainRow::Create_ItemList_Global( E_Style i_eOverview, 266*cdf0e10cSrcweir E_Style i_eIndex, 267*cdf0e10cSrcweir E_Style i_eHelp ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir if ( i_eOverview == eStd ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir String sLinkOverview = ( i_eIndex == eSelf 272*cdf0e10cSrcweir ? dshelp::PathPerLevelsUp( 273*cdf0e10cSrcweir 1, 274*cdf0e10cSrcweir C_sHFN_Overview ) 275*cdf0e10cSrcweir : C_sHFN_Overview ); 276*cdf0e10cSrcweir Add_Item( i_eOverview, sOverview, sLinkOverview.c_str(), "" ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir else 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir Add_Item( i_eOverview, sOverview, "", "" ); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir if ( i_eIndex == eSelf ) 284*cdf0e10cSrcweir Add_Item( eStd, sNamespace, "../names/index.html", "" ); 285*cdf0e10cSrcweir else 286*cdf0e10cSrcweir Add_Item( eStd, sNamespace, "names/index.html", "" ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir Add_Item( eNo, sClass, "", "" ); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir if ( i_eIndex == eStd ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir Add_Item( i_eIndex, sIndex, C_sPath_Index, "" ); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir else 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir Add_Item( i_eIndex, sIndex, "", "" ); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir if ( i_eHelp == eStd ) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir String sLinkHelp = ( i_eIndex == eSelf 302*cdf0e10cSrcweir ? PathPerLevelsUp(1,C_sHFN_Help) 303*cdf0e10cSrcweir : C_sHFN_Help ); 304*cdf0e10cSrcweir Add_Item( i_eHelp, sHelp, sLinkHelp.c_str(), "" ); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir else 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir Add_Item( i_eHelp, sHelp, "", "" ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir void 313*cdf0e10cSrcweir MainRow::Create_ItemList_InDirTree_Cpp( E_Style i_eNsp, 314*cdf0e10cSrcweir E_Style i_eClass, 315*cdf0e10cSrcweir E_Style , 316*cdf0e10cSrcweir const char * ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir String 319*cdf0e10cSrcweir sLinkOverview = PathPerRoot(*pEnv, C_sHFN_Overview); 320*cdf0e10cSrcweir Add_Item( eStd, sOverview, sLinkOverview.c_str(), "" ); 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir if (i_eNsp == eStd) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir String sLinkNamespace = PathPerNamespace(*pEnv, "index.html"); 325*cdf0e10cSrcweir Add_Item( i_eNsp, sNamespace, sLinkNamespace.c_str(), "" ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir else 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir Add_Item( i_eNsp, sNamespace, "", "" ); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir if (i_eClass == eStd) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir csv_assert( pEnv->CurClass() != 0 ); 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir StreamLock sLinkClass(300); 337*cdf0e10cSrcweir sLinkClass() << PathPerNamespace(*pEnv, "c-") 338*cdf0e10cSrcweir << pEnv->CurClass()->LocalName() 339*cdf0e10cSrcweir << ".html"; 340*cdf0e10cSrcweir StreamLock sTipClass(300); 341*cdf0e10cSrcweir sTipClass() << "Class " 342*cdf0e10cSrcweir << pEnv->CurClass()->LocalName(); 343*cdf0e10cSrcweir Add_Item( i_eClass, sClass, sLinkClass().c_str(), sTipClass().c_str() ); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir else 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir Add_Item( i_eClass, sClass, "", "" ); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir Add_Item( eStd, sIndex, PathPerRoot(*pEnv, C_sPath_Index), "" ); 352*cdf0e10cSrcweir String 353*cdf0e10cSrcweir sLinkHelp = PathPerRoot(*pEnv, "help.html"); 354*cdf0e10cSrcweir Add_Item( eStd, sHelp, sLinkHelp.c_str(), "" ); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir void 358*cdf0e10cSrcweir MainRow::Add_Item( E_Style i_eStyle, 359*cdf0e10cSrcweir const String & i_sText, 360*cdf0e10cSrcweir const char * i_sLink, 361*cdf0e10cSrcweir const char * i_sTip ) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir switch (i_eStyle) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir case eStd: aItems.push_back( new MainRowItem(i_sText, i_sLink, i_sTip) ); 366*cdf0e10cSrcweir break; 367*cdf0e10cSrcweir case eNo: aItems.push_back( new UnavailableItem(i_sText) ); 368*cdf0e10cSrcweir break; 369*cdf0e10cSrcweir case eSelf: aItems.push_back( new SelectedItem(i_sText) ); 370*cdf0e10cSrcweir break; 371*cdf0e10cSrcweir default: 372*cdf0e10cSrcweir csv_assert(false); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir 378