update credits
[LibreOffice.git] / autodoc / source / display / idl / hi_env.cxx
blob73c798c7ae25dfc296c49a64fc5c1fe5e2c8f6a1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <precomp.h>
21 #include "hi_env.hxx"
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"
33 const String C_s_index_files("index-files");
35 const String C_sUseFileSuffix("-use.html");
36 const String C_IndexA_FileName("index-1.html");
39 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 pData(new AryAccess(i_rGate)),
44 pGate(&i_rGate),
45 pOutputTree(new output::Tree),
46 aCurPosition(pOutputTree->Root()),
47 pCurPageCe(0),
48 pLayout(&i_rLayout),
49 pLinker()
51 StringVector aHelp;
52 pOutputTree->Set_NamesRoot(aHelp);
54 aHelp.push_back(output::IndexFilesDirName());
55 pOutputTree->Set_IndexRoot(aHelp);
57 (*aHelp.begin()) = String("com");
58 aHelp.push_back(String("sun"));
59 aHelp.push_back(String("star"));
60 pOutputTree->Set_Overview(aHelp, output::ModuleFileName() );
62 pLinker = new LinkHelper(*this);
65 HtmlEnvironment_Idl::~HtmlEnvironment_Idl()
69 namespace
71 StringVector G_aChain;
74 void
75 HtmlEnvironment_Idl::Goto_Directory( output::Position i_pos,
76 bool i_bCreateDirectoryIfNecessary )
78 aCurPosition = i_pos;
79 aCurPath = aOutputRoot.MyPath();
81 aCurPosition.Get_Chain(G_aChain);
82 for ( StringVector::const_iterator it = G_aChain.begin();
83 it != G_aChain.end();
84 ++it )
86 aCurPath.DirChain() += *it;
89 if (i_bCreateDirectoryIfNecessary)
90 create_Directory(aCurPath);
93 void
94 HtmlEnvironment_Idl::Goto_DirectoryLevelDown( const String & i_subDirName,
95 bool i_bCreateDirectoryIfNecessary )
97 aCurPosition +=(i_subDirName);
99 aCurPath.SetFile(String::Null_());
100 aCurPath.DirChain() += i_subDirName;
102 if (i_bCreateDirectoryIfNecessary)
103 create_Directory(aCurPath);
106 void
107 HtmlEnvironment_Idl::Goto_DirectoryLevelUp()
109 aCurPosition -= 1;
111 aCurPath.SetFile(String::Null_());
112 aCurPath.DirChain() -= 1;
115 void
116 HtmlEnvironment_Idl::Set_CurFile( const String & i_fileName )
118 aCurPath.SetFile(i_fileName);
121 void
122 HtmlEnvironment_Idl::create_Directory( const csv::ploc::Path & i_path )
125 csv::ploc::Directory aCurDir(i_path);
126 if (NOT aCurDir.Exists())
127 aCurDir.PhysicalCreate();
130 inline bool
131 IsAbsoluteLink(const char * i_link)
133 const char
134 shttp[] = "http://";
135 const char
136 sfile[] = "file://";
137 const int
138 csize = sizeof shttp - 1;
139 csv_assert(csize == sizeof sfile - 1);
141 return strncmp(i_link,shttp,csize) == 0
142 OR strncmp(i_link,sfile,csize) == 0;
146 const char *
147 HtmlEnvironment_Idl::Link2Manual( const String & i_link ) const
149 if ( IsAbsoluteLink(i_link.c_str()) )
150 return i_link;
152 static StreamStr aLink_(200);
153 aLink_.reset();
154 String
155 sDvgRoot(pLayout->DevelopersGuideHtmlRoot());
156 if (sDvgRoot.empty())
157 sDvgRoot = "../DevelopersGuide";
159 // KORR_FUTURE
160 // Enhance performance by calculating this only one time:
161 if ( NOT IsAbsoluteLink(sDvgRoot.c_str()) )
162 aCurPosition.Get_LinkToRoot(aLink_);
163 aLink_ << sDvgRoot
164 << "/"
165 << i_link;
166 return aLink_.c_str();
169 String
170 HtmlEnvironment_Idl::CurPageCe_AsText() const
172 return CurPageCe_AsFile(".html");
175 String
176 HtmlEnvironment_Idl::CurPageCe_AsFile(const char * i_sEnding) const
178 if (pCurPageCe == 0)
179 return String::Null_();
181 static StringVector aModule_;
182 String sCe;
183 String sDummy;
184 Data().Get_CeText(aModule_, sCe, sDummy, *pCurPageCe);
185 StreamLock slCe(500);
186 if (aModule_.size() > 0)
187 slCe().operator_join(aModule_.begin(), aModule_.end(), "/");
188 if (NOT sCe.empty())
189 slCe() << "/" << sCe << i_sEnding;
190 return String(slCe().c_str());
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */