2010-10-12 08:46:24 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2002-03-08 07:45:36 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 08:37:46 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2002-03-08 07:45:36 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2002-03-08 07:45:36 -06:00
|
|
|
*
|
2008-04-10 08:37:46 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-03-08 07:45:36 -06:00
|
|
|
*
|
2008-04-10 08:37:46 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2002-03-08 07:45:36 -06:00
|
|
|
*
|
2008-04-10 08:37:46 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2002-03-08 07:45:36 -06:00
|
|
|
*
|
2008-04-10 08:37:46 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2002-03-08 07:45:36 -06:00
|
|
|
*
|
2008-04-10 08:37:46 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2002-03-08 07:45:36 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <precomp.h>
|
|
|
|
#include "navibar.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
// NOT FULLY DEFINED SERVICES
|
2007-11-02 10:28:54 -05:00
|
|
|
#include <cosv/tpl/tpltools.hxx>
|
2002-03-08 07:45:36 -06:00
|
|
|
#include "nav_main.hxx"
|
|
|
|
#include "opageenv.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace csi::xml;
|
|
|
|
using namespace csi::html;
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
//************************ SubRowItem ***************************//
|
|
|
|
|
|
|
|
class SubRowItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SubRowItem(
|
|
|
|
const char * i_sText,
|
|
|
|
const char * i_sLink,
|
|
|
|
bool i_bActive,
|
|
|
|
bool i_bFirstOfRow = false );
|
|
|
|
~SubRowItem();
|
|
|
|
|
|
|
|
void Write2(
|
|
|
|
Element & o_rOut ) const;
|
|
|
|
private:
|
2007-11-02 10:28:54 -05:00
|
|
|
String sText;
|
|
|
|
String sLink;
|
2002-03-08 07:45:36 -06:00
|
|
|
bool bIsActive;
|
|
|
|
bool bFirstOfRow;
|
|
|
|
};
|
|
|
|
|
|
|
|
SubRowItem::SubRowItem( const char * i_sText,
|
|
|
|
const char * i_sLink,
|
|
|
|
bool i_bActive,
|
|
|
|
bool i_bFirstOfRow )
|
|
|
|
: sText(i_sText),
|
|
|
|
sLink(i_sLink),
|
|
|
|
bIsActive(i_bActive),
|
|
|
|
bFirstOfRow(i_bFirstOfRow)
|
|
|
|
{
|
|
|
|
csv_assert( NOT csv::no_str(i_sLink) );
|
|
|
|
}
|
|
|
|
|
|
|
|
SubRowItem::~SubRowItem()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SubRowItem::Write2( Element & o_rOut ) const
|
|
|
|
{
|
|
|
|
o_rOut << new Sbr;
|
|
|
|
if ( NOT bFirstOfRow )
|
|
|
|
o_rOut << new XmlCode( "| " );
|
|
|
|
else
|
|
|
|
o_rOut << new XmlCode( " " );
|
|
|
|
|
|
|
|
if ( bIsActive )
|
|
|
|
{
|
|
|
|
o_rOut
|
|
|
|
>> *new Link( sLink.c_str() )
|
|
|
|
>> *new AnElement( "font" )
|
|
|
|
<< new AnAttribute("size","-2")
|
|
|
|
>> *new Bold
|
|
|
|
<< sText.c_str();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
o_rOut
|
|
|
|
>> *new AnElement( "font" )
|
|
|
|
<< new AnAttribute("size","-2")
|
|
|
|
<< sText.c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//************************ SubRow ***************************//
|
|
|
|
|
|
|
|
class SubRow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SubRow(
|
|
|
|
const char * i_sTitle );
|
|
|
|
~SubRow();
|
|
|
|
|
|
|
|
void AddItem(
|
|
|
|
const char * i_sText,
|
|
|
|
const char * i_sLink,
|
|
|
|
bool i_bActive );
|
|
|
|
void Write2(
|
|
|
|
Table & o_rOut ) const;
|
|
|
|
private:
|
|
|
|
typedef std::vector< DYN SubRowItem * > List_Items;
|
|
|
|
|
|
|
|
List_Items aItemList;
|
2007-11-02 10:28:54 -05:00
|
|
|
String sTitle;
|
2002-03-08 07:45:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
SubRow::SubRow( const char * i_sTitle )
|
|
|
|
// : // aItemList,
|
|
|
|
// sTitle
|
|
|
|
{
|
|
|
|
StreamStr sUp(i_sTitle,0);
|
|
|
|
sUp.to_upper();
|
|
|
|
sTitle = sUp.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
SubRow::~SubRow()
|
|
|
|
{
|
2009-06-04 10:47:31 -05:00
|
|
|
for ( List_Items::iterator it = aItemList.begin();
|
|
|
|
it != aItemList.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
delete (*it);
|
|
|
|
}
|
2002-03-08 07:45:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
SubRow::AddItem( const char * i_sText,
|
|
|
|
const char * i_sLink,
|
|
|
|
bool i_bActive )
|
|
|
|
{
|
|
|
|
aItemList.push_back( new SubRowItem(i_sText, i_sLink, i_bActive, aItemList.empty()) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SubRow::Write2( Table & o_rOut ) const
|
|
|
|
{
|
|
|
|
TableRow * pRow = new TableRow;
|
|
|
|
o_rOut << pRow;
|
|
|
|
|
|
|
|
if (sTitle.length() > 0)
|
|
|
|
{
|
|
|
|
Element & rCell1 = pRow->AddCell();
|
|
|
|
rCell1
|
|
|
|
<< new WidthAttr("20%")
|
|
|
|
>> *new AnElement( "font" )
|
|
|
|
<< new AnAttribute("size","-2")
|
|
|
|
<< sTitle
|
|
|
|
<< ":";
|
|
|
|
}
|
|
|
|
|
|
|
|
Element & rCell2 = pRow->AddCell();
|
|
|
|
for ( List_Items::const_iterator it = aItemList.begin();
|
|
|
|
it != aItemList.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
(*it)->Write2( rCell2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//************************* CheshireCat ***********************//
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector< DYN SubRow * > List_SubRows;
|
|
|
|
|
|
|
|
struct NavigationBar::CheshireCat
|
|
|
|
{
|
|
|
|
MainRow aMainRow;
|
|
|
|
List_SubRows aSubRows;
|
|
|
|
const OuputPage_Environment *
|
|
|
|
pEnv;
|
|
|
|
|
|
|
|
|
|
|
|
CheshireCat(
|
|
|
|
const OuputPage_Environment &
|
|
|
|
i_rEnv );
|
|
|
|
~CheshireCat();
|
|
|
|
};
|
|
|
|
|
|
|
|
NavigationBar::
|
|
|
|
CheshireCat::CheshireCat( const OuputPage_Environment & i_rEnv )
|
|
|
|
: aMainRow( i_rEnv ),
|
|
|
|
pEnv( & i_rEnv )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigationBar::
|
|
|
|
CheshireCat::~CheshireCat()
|
|
|
|
{
|
|
|
|
csv::erase_container_of_heap_ptrs( aSubRows );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//************************ NavigationBar *******************//
|
|
|
|
|
|
|
|
NavigationBar::NavigationBar( const OuputPage_Environment & i_rEnv,
|
|
|
|
E_GlobalLocation i_eLocation )
|
|
|
|
: pi( new CheshireCat(i_rEnv) )
|
|
|
|
{
|
|
|
|
switch (i_eLocation)
|
|
|
|
{
|
|
|
|
case LOC_Overview: pi->aMainRow.SetupItems_Overview(); break;
|
|
|
|
case LOC_AllDefs: pi->aMainRow.SetupItems_AllDefs(); break;
|
|
|
|
case LOC_Index: pi->aMainRow.SetupItems_Index(); break;
|
|
|
|
case LOC_Help: pi->aMainRow.SetupItems_Help(); break;
|
|
|
|
default:
|
|
|
|
csv_assert(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigationBar::NavigationBar( const OuputPage_Environment & i_rEnv,
|
2007-11-02 10:28:54 -05:00
|
|
|
const ary::cpp::CodeEntity & i_rCe )
|
2002-03-08 07:45:36 -06:00
|
|
|
: pi( new CheshireCat(i_rEnv) )
|
|
|
|
{
|
|
|
|
pi->aMainRow.SetupItems_Ce( i_rCe );
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigationBar::NavigationBar( const OuputPage_Environment & i_rEnv,
|
2007-11-02 10:28:54 -05:00
|
|
|
E_CeGatheringType i_eCeGatheringType )
|
2002-03-08 07:45:36 -06:00
|
|
|
: pi( new CheshireCat(i_rEnv) )
|
|
|
|
{
|
2007-11-02 10:28:54 -05:00
|
|
|
switch (i_eCeGatheringType)
|
2002-03-08 07:45:36 -06:00
|
|
|
{
|
2007-11-02 10:28:54 -05:00
|
|
|
case CEGT_operations: pi->aMainRow.SetupItems_FunctionGroup(); break;
|
|
|
|
case CEGT_data: pi->aMainRow.SetupItems_DataGroup(); break;
|
|
|
|
default:
|
|
|
|
csv_assert(false);
|
2002-03-08 07:45:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigationBar::~NavigationBar()
|
|
|
|
{
|
|
|
|
csv::erase_container_of_heap_ptrs( pi->aSubRows );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NavigationBar::MakeSubRow( const char * i_sTitle )
|
|
|
|
{
|
|
|
|
pi->aSubRows.push_back( new SubRow(i_sTitle) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NavigationBar::AddItem( const char * i_sName,
|
|
|
|
const char * i_sLink,
|
|
|
|
bool i_bValid )
|
|
|
|
{
|
|
|
|
csv_assert( pi->aSubRows.size() > 0 );
|
|
|
|
StreamStr sName(i_sName, 0);
|
|
|
|
sName.to_upper();
|
|
|
|
|
|
|
|
StreamLock aSum(100);
|
|
|
|
pi->aSubRows.back()->AddItem( sName.c_str(),
|
|
|
|
aSum() << "#" << i_sLink << c_str,
|
|
|
|
i_bValid );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NavigationBar::Write( Element & o_rOut,
|
|
|
|
bool i_bWithSubRows ) const
|
|
|
|
{
|
|
|
|
pi->aMainRow.Write2( o_rOut );
|
|
|
|
|
|
|
|
const_cast< NavigationBar* >(this)->pSubRowsTable = new Table;
|
|
|
|
o_rOut << pSubRowsTable;
|
|
|
|
*pSubRowsTable
|
2007-11-02 10:28:54 -05:00
|
|
|
<< new AnAttribute( "class", "navisub" )
|
2002-03-08 07:45:36 -06:00
|
|
|
<< new AnAttribute( "cellpadding", "0" )
|
|
|
|
<< new AnAttribute( "cellspacing", "3" );
|
|
|
|
|
|
|
|
if (i_bWithSubRows)
|
|
|
|
{
|
|
|
|
Write_SubRows();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NavigationBar::Write_SubRows() const
|
|
|
|
{
|
|
|
|
for ( List_SubRows::const_iterator it = pi->aSubRows.begin();
|
|
|
|
it != pi->aSubRows.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
(*it)->Write2( *pSubRowsTable );
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 08:46:24 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|