LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/display/idl - hi_env.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 82 86 95.3 %
Date: 2012-12-27 Functions: 13 13 100.0 %
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 "hi_env.hxx"
      22             : 
      23             : 
      24             : // NOT FULLY DEFINED SERVICES
      25             : #include <cosv/ploc_dir.hxx>
      26             : #include <cfrstd.hxx>
      27             : #include <toolkit/out_tree.hxx>
      28             : #include "hi_ary.hxx"
      29             : #include "hi_linkhelper.hxx"
      30             : 
      31             : 
      32             : 
      33           1 : const String C_s_index_files("index-files");
      34             : 
      35           1 : const String C_sUseFileSuffix("-use.html");
      36           1 : const String C_IndexA_FileName("index-1.html");
      37             : 
      38             : 
      39           1 : HtmlEnvironment_Idl::HtmlEnvironment_Idl( const csv::ploc::Path &           i_rOutputDir,
      40             :                                           const ary::idl::Gate &            i_rGate,
      41             :                                           const display::CorporateFrame &   i_rLayout )
      42             :     :   aOutputRoot(i_rOutputDir),
      43           1 :         pData(new AryAccess(i_rGate)),
      44             :         pGate(&i_rGate),
      45           1 :         pOutputTree(new output::Tree),
      46             :         aCurPosition(pOutputTree->Root()),
      47             :         pCurPageCe(0),
      48             :         pLayout(&i_rLayout),
      49           3 :         pLinker()
      50             : {
      51           1 :     StringVector    aHelp;
      52           1 :     pOutputTree->Set_NamesRoot(aHelp);
      53             : 
      54           1 :     aHelp.push_back(output::IndexFilesDirName());
      55           1 :     pOutputTree->Set_IndexRoot(aHelp);
      56             : 
      57           1 :     (*aHelp.begin()) = String("com");
      58           1 :     aHelp.push_back(String("sun"));
      59           1 :     aHelp.push_back(String("star"));
      60           1 :     pOutputTree->Set_Overview(aHelp, output::ModuleFileName() );
      61             : 
      62           1 :     pLinker = new LinkHelper(*this);
      63           1 : }
      64             : 
      65           1 : HtmlEnvironment_Idl::~HtmlEnvironment_Idl()
      66             : {
      67           1 : }
      68             : 
      69             : namespace
      70             : {
      71           1 : StringVector    G_aChain;
      72             : }
      73             : 
      74             : void
      75           3 : HtmlEnvironment_Idl::Goto_Directory( output::Position   i_pos,
      76             :                                      bool               i_bCreateDirectoryIfNecessary )
      77             : {
      78           3 :     aCurPosition = i_pos;
      79           3 :     aCurPath = aOutputRoot.MyPath();
      80             : 
      81           3 :     aCurPosition.Get_Chain(G_aChain);
      82          12 :     for ( StringVector::const_iterator it = G_aChain.begin();
      83           8 :           it != G_aChain.end();
      84             :           ++it )
      85             :     {
      86           1 :         aCurPath.DirChain() += *it;
      87             :     }
      88             : 
      89           3 :     if (i_bCreateDirectoryIfNecessary)
      90           3 :         create_Directory(aCurPath);
      91           3 : }
      92             : 
      93             : void
      94         118 : HtmlEnvironment_Idl::Goto_DirectoryLevelDown( const String & i_subDirName,
      95             :                                               bool           i_bCreateDirectoryIfNecessary )
      96             : {
      97         118 :     aCurPosition +=(i_subDirName);
      98             : 
      99         118 :     aCurPath.SetFile(String::Null_());
     100         118 :     aCurPath.DirChain() += i_subDirName;
     101             : 
     102         118 :     if (i_bCreateDirectoryIfNecessary)
     103         118 :         create_Directory(aCurPath);
     104         118 : }
     105             : 
     106             : void
     107         118 : HtmlEnvironment_Idl::Goto_DirectoryLevelUp()
     108             : {
     109         118 :     aCurPosition -= 1;
     110             : 
     111         118 :     aCurPath.SetFile(String::Null_());
     112         118 :     aCurPath.DirChain() -= 1;
     113         118 : }
     114             : 
     115             : void
     116        7832 : HtmlEnvironment_Idl::Set_CurFile( const String & i_fileName )
     117             : {
     118        7832 :     aCurPath.SetFile(i_fileName);
     119        7832 : }
     120             : 
     121             : void
     122         121 : HtmlEnvironment_Idl::create_Directory( const csv::ploc::Path & i_path )
     123             : 
     124             : {
     125         121 :     csv::ploc::Directory aCurDir(i_path);
     126         121 :     if (NOT aCurDir.Exists())
     127         119 :         aCurDir.PhysicalCreate();
     128         121 : }
     129             : 
     130             : inline bool
     131        7746 : IsAbsoluteLink(const char * i_link)
     132             : {
     133             :     const char
     134        7746 :         shttp[] = "http://";
     135             :     const char
     136        7746 :         sfile[] = "file://";
     137             :     const int
     138        7746 :         csize = sizeof shttp - 1;
     139             :     csv_assert(csize == sizeof sfile - 1);
     140             : 
     141        7746 :     return      strncmp(i_link,shttp,csize) == 0
     142        7746 :             OR  strncmp(i_link,sfile,csize) == 0;
     143             : }
     144             : 
     145             : 
     146             : const char *
     147        3873 : HtmlEnvironment_Idl::Link2Manual( const String & i_link ) const
     148             : {
     149        3873 :     if ( IsAbsoluteLink(i_link.c_str()) )
     150           0 :         return i_link;
     151             : 
     152        3873 :     static StreamStr aLink_(200);
     153        3873 :     aLink_.reset();
     154             :     String
     155        3873 :         sDvgRoot(pLayout->DevelopersGuideHtmlRoot());
     156        3873 :     if (sDvgRoot.empty())
     157           0 :         sDvgRoot = "../DevelopersGuide";
     158             : 
     159             :     // KORR_FUTURE
     160             :     // Enhance performance by calculating this only one time:
     161        3873 :     if ( NOT IsAbsoluteLink(sDvgRoot.c_str()) )
     162           0 :         aCurPosition.Get_LinkToRoot(aLink_);
     163        3873 :     aLink_ << sDvgRoot
     164        3873 :            << "/"
     165        3873 :            << i_link;
     166        3873 :     return aLink_.c_str();
     167             : }
     168             : 
     169             : String
     170          10 : HtmlEnvironment_Idl::CurPageCe_AsText() const
     171             : {
     172          10 :     return CurPageCe_AsFile(".html");
     173             : }
     174             : 
     175             : String
     176         111 : HtmlEnvironment_Idl::CurPageCe_AsFile(const char * i_sEnding) const
     177             : {
     178         111 :     if (pCurPageCe == 0)
     179           0 :         return String::Null_();
     180             : 
     181         111 :     static StringVector aModule_;
     182         111 :     String sCe;
     183         111 :     String sDummy;
     184         111 :     Data().Get_CeText(aModule_, sCe, sDummy, *pCurPageCe);
     185         111 :     StreamLock slCe(500);
     186         111 :     if (aModule_.size() > 0)
     187         111 :         slCe().operator_join(aModule_.begin(), aModule_.end(), "/");
     188         111 :     if (NOT sCe.empty())
     189         111 :         slCe() << "/" << sCe << i_sEnding;
     190         111 :     return String(slCe().c_str());
     191           3 : }
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10