LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/display/idl - hfi_globalindex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 63 63 100.0 %
Date: 2012-12-27 Functions: 10 11 90.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <precomp.h>
      21             : #include "hfi_globalindex.hxx"
      22             : 
      23             : 
      24             : // NOT FULLY DEFINED SERVICES
      25             : #include <cosv/tpl/tpltools.hxx>
      26             : #include <ary/idl/i_ce.hxx>
      27             : #include <ary/idl/i_types4idl.hxx>
      28             : #include <ary/idl/i_module.hxx>
      29             : #include <toolkit/hf_title.hxx>
      30             : #include "hfi_navibar.hxx"
      31             : #include "hfi_typetext.hxx"
      32             : #include "hi_linkhelper.hxx"
      33             : 
      34             : 
      35             : 
      36             : 
      37             : namespace
      38             : {
      39             : 
      40             : /**
      41             : */
      42             : enum E_Types
      43             : {
      44             :         t_service           = 0,
      45             :         t_interface         = 1,
      46             :         t_struct            = 2,
      47             :         t_exception         = 3,
      48             :         t_enum              = 4,
      49             :         t_typedef           = 5,
      50             :         t_constantsgroup    = 6,
      51             :         t_property          = 7,
      52             :         t_function          = 8,
      53             :         t_structelement     = 9,
      54             :         t_enumvalue         = 10,
      55             :         t_constant          = 11,
      56             :         t_module            = 12,
      57             :         t_singleton         = 13,
      58             :         t_attribute         = 14,
      59             :         t_siservice         = 15,
      60             :         t_sisingleton       = 16,
      61             :         t_MAX
      62             : };
      63             : 
      64           1 : String  G_sDummy;
      65             : 
      66             : 
      67             : /*  RC-Ids for IDL types (see reposy.cxx):
      68             : 
      69             :     Module              2000
      70             :     Interface           2001
      71             :     Function            2002
      72             :     Service             2003
      73             :     Property            2004
      74             : 
      75             :     Enum                2005
      76             :     EnumValue           2006
      77             :     Typedef             2007
      78             :     Struct              2008
      79             :     StructElement       2009
      80             : 
      81             :     Exception           2010
      82             :     ConstantGroup       2011
      83             :     Constant            2012
      84             :     Singleton           2013
      85             :     Attribute           2014
      86             :     SglIfcService       2015
      87             :     SglIfcSingleton     2016
      88             : */
      89             : const int C_nNumberOfIdlTypes = 17;
      90             : const char *    C_sTypeNames[C_nNumberOfIdlTypes] =
      91             :                     { "module ",    "interface ",   "function ",    "service ",     "property ",
      92             :                       "enum ",      "value ",       "typedef ",     "struct ",      "field ",
      93             :                       "exception ", "constants group ", "constant ","singleton ",   "attribute ",
      94             :                       "service",    "singleton"
      95             :                     };
      96             : const char *    C_sOwnerNames[C_nNumberOfIdlTypes] =
      97             :                     { "module ",    "module ",      "interface ",   "module ",      "service ",
      98             :                       "module ",    "enum ",        "module ",      "module ",      "", // could be struct or exception
      99             :                       "module ",    "module ",      "constants group ", "module ",  "interface ",
     100             :                       "module",     "module"
     101             :                     };
     102             : const intt C_nNamesArrayOffset = intt(ary::idl::Module::class_id);
     103             : const int C_nIxField = 9;
     104             : 
     105             : 
     106           1 : HF_IdlGlobalIndex::PageData     G_PageData;
     107             : 
     108             : }   // end anonymous namespace
     109             : 
     110             : 
     111             : inline void
     112       19526 : HF_IdlGlobalIndex::write_EntryItself( Xml::Element &               o_destination,
     113             :                                       const ary::idl::CodeEntity & i_ce,
     114             :                                       const HF_IdlTypeText &       i_typeLinkWriter ) const
     115             : {
     116       19526 :     i_typeLinkWriter.Produce_IndexLink(o_destination, i_ce);
     117       19526 :     o_destination << " - ";
     118       19526 : }
     119             : 
     120             : 
     121          27 : HF_IdlGlobalIndex::HF_IdlGlobalIndex( Environment &     io_rEnv,
     122             :                                       Xml::Element &    o_rOut )
     123          27 :     :   HtmlFactory_Idl(io_rEnv, &o_rOut)
     124             : {
     125          27 : }
     126             : 
     127          27 : HF_IdlGlobalIndex::~HF_IdlGlobalIndex()
     128             : {
     129          27 : }
     130             : 
     131             : void
     132          27 : HF_IdlGlobalIndex::Produce_Page(ary::idl::alphabetical_index::E_Letter i_letter) const
     133             : {
     134          27 :     make_Navibar();
     135             : 
     136             :     HF_TitleTable
     137          27 :         aTitle(CurOut());
     138          27 :     StreamLock sl(100);
     139          27 :     aTitle.Produce_Title( sl()
     140          27 :                           << "Global Index "
     141             :                           << ( i_letter != ary::idl::alphabetical_index::non_alpha
     142             :                                 ?   char(int(i_letter)-'a'+'A')
     143          54 :                                 :   '_' )
     144          27 :                           << c_str );
     145             : 
     146             :     // Letters Index
     147          27 :     aTitle.Add_Row()
     148             :         << new Xml::XmlCode(
     149             :             "<p align=\"center\"><a href=\"index-1.html\"><b>A</b></a> <a href=\"index-2.html\"><b>B</b></a> <a href=\"index-3.html\"><b>C</b></a> <a href=\"index-4.html\"><b>D</b></a> <a href=\"index-5.html\"><b>E</b></a> <a href=\"index-6.html\"><b>F</b></a> <a href=\"index-7.html\"><b>G</b></a> <a href=\"index-8.html\"><b>H</b></a> <a href=\"index-9.html\"><b>I</b></a> <a href=\"index-10.html\"><b>J</b></a>"
     150             :             " <a href=\"index-11.html\"><b>K</b></a> <a href=\"index-12.html\"><b>L</b></a> <a href=\"index-13.html\"><b>M</b></a> <a href=\"index-14.html\"><b>N</b></a> <a href=\"index-15.html\"><b>O</b></a> <a href=\"index-16.html\"><b>P</b></a> <a href=\"index-17.html\"><b>Q</b></a> <a href=\"index-18.html\"><b>R</b></a> <a href=\"index-19.html\"><b>S</b></a> <a href=\"index-20.html\"><b>T</b></a>"
     151          54 :             " <a href=\"index-21.html\"><b>U</b></a> <a href=\"index-22.html\"><b>V</b></a> <a href=\"index-23.html\"><b>W</b></a> <a href=\"index-24.html\"><b>X</b></a> <a href=\"index-25.html\"><b>Y</b></a> <a href=\"index-26.html\"><b>Z</b></a> <a href=\"index-27.html\"><b>_</b></a></p>" );
     152             : 
     153          27 :     Out().Enter(CurOut() >> *new Html::DefList);
     154             : 
     155          27 :     csv::erase_container(G_PageData);
     156          27 :     Env().Data().Get_IndexData(G_PageData, i_letter);
     157             : 
     158             :     // Helper object to produce links to the index Entries.
     159          27 :     HF_IdlTypeText aTypeLinkWriter(Env(),HF_IdlTypeText::use_for_javacompatible_index);
     160             : 
     161          27 :     PageData::const_iterator itEnd = G_PageData.end();
     162       19553 :     for ( PageData::const_iterator iter = G_PageData.begin();
     163             :           iter != itEnd;
     164             :           ++iter )
     165             :     {
     166       19526 :         produce_Line(iter, aTypeLinkWriter);
     167             :     }   // end for
     168             : 
     169          27 :     Out().Leave();
     170          27 :     CurOut() << new Html::HorizontalLine;
     171          27 : }
     172             : 
     173             : void
     174          27 : HF_IdlGlobalIndex::make_Navibar() const
     175             : {
     176             :     HF_IdlNavigationBar
     177          27 :         aNaviBar(Env(), CurOut());
     178          27 :     aNaviBar.Produce_IndexMainRow();
     179             : 
     180          27 :     CurOut() << new Html::HorizontalLine();
     181          27 : }
     182             : 
     183             : void
     184       19526 : HF_IdlGlobalIndex::produce_Line( PageData::const_iterator i_entry,
     185             :                                  const HF_IdlTypeText &   i_typeLinkWriter) const
     186             : {
     187             :     const client &
     188       19526 :         rCe = Env().Data().Find_Ce(*i_entry);
     189       19526 :     if (NOT rCe.Owner().IsValid())
     190       19526 :         return; // Omit global namespace.
     191             : 
     192             :     // The destination for the created output:
     193       19526 :     Xml::Element & rDT = CurOut() >> *new Html::DefListTerm;
     194             : 
     195             :     /** The following code is intended to produce an output that
     196             :         will be recognized by the context help system of Forte.
     197             :         That is reached by making it similar to the indices, that
     198             :         Javadoc produces.
     199             :         If the link to the Entry contains a hashmark, the Forte-Help
     200             :         requires following a link to the owner.
     201             :         But if there is no hashmark, the following link must go to
     202             :         the same Entry again. Doesn't make really sense :-(, but that's
     203             :         like it is.
     204             :     */
     205       19526 :     write_EntryItself(rDT,rCe,i_typeLinkWriter);
     206       19526 :     if (rCe.SightLevel() == ary::idl::sl_Member)
     207       15274 :         write_OwnerOfEntry(rDT,rCe,i_typeLinkWriter);
     208             :     else
     209        4252 :         write_EntrySecondTime(rDT,rCe,i_typeLinkWriter);
     210             : 
     211             :     // This produces an empty "<dd></dd>", which is also needed to reach
     212             :     //   similarity to the Javadoc index:
     213       19526 :     CurOut() << new Html::DefListDefinition;
     214             : }
     215             : 
     216             : void
     217       15274 : HF_IdlGlobalIndex::write_OwnerOfEntry( Xml::Element &               o_destination,
     218             :                                        const ary::idl::CodeEntity & i_ce,
     219             :                                        const HF_IdlTypeText &       i_typeLinkWriter ) const
     220             : {
     221             :     const client &
     222       15274 :         rOwner = Env().Data().Find_Ce(i_ce.Owner());
     223             : 
     224       15274 :     int nIx = int(i_ce.AryClass() - C_nNamesArrayOffset);
     225             :     csv_assert(csv::in_range(0,nIx,C_nNumberOfIdlTypes));
     226             : 
     227       15274 :     o_destination << C_sTypeNames[nIx]
     228       15274 :                   << "in ";
     229       15274 :     if (nIx != C_nIxField)
     230             :     {
     231       13791 :         o_destination << C_sOwnerNames[nIx];
     232             :     }
     233             :     else
     234             :     {
     235             :         uintt
     236        1483 :             nOwnerIx = rOwner.AryClass() - C_nNamesArrayOffset;
     237             :         csv_assert(
     238             :             nOwnerIx < static_cast< unsigned int >(C_nNumberOfIdlTypes));
     239        1483 :         o_destination << C_sTypeNames[nOwnerIx];
     240             :     }
     241       15274 :     i_typeLinkWriter.Produce_IndexOwnerLink(o_destination, rOwner);
     242       15274 : }
     243             : 
     244             : void
     245        4252 : HF_IdlGlobalIndex::write_EntrySecondTime( Xml::Element &                o_destination,
     246             :                                           const ary::idl::CodeEntity &  i_ce,
     247             :                                           const HF_IdlTypeText &        i_typeLinkWriter ) const
     248             : {
     249        4252 :     int nIx = int(i_ce.AryClass() - C_nNamesArrayOffset);
     250             :     csv_assert(csv::in_range(0,nIx,C_nNumberOfIdlTypes));
     251             : 
     252        4252 :     o_destination << C_sTypeNames[nIx]
     253        4252 :                   << " ";
     254        4252 :     i_typeLinkWriter.Produce_IndexSecondEntryLink(o_destination, i_ce);
     255        4255 : }
     256             : 
     257             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10