Bump for 3.6-28
[LibreOffice.git] / autodoc / source / display / idl / hi_env.cxx
blobdb4589efbe43e77301951c05aae2c957cfcc0a0d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <precomp.h>
30 #include "hi_env.hxx"
33 // NOT FULLY DEFINED SERVICES
34 #include <cosv/ploc_dir.hxx>
35 #include <cfrstd.hxx>
36 #include <toolkit/out_tree.hxx>
37 #include "hi_ary.hxx"
38 #include "hi_linkhelper.hxx"
42 const String C_s_index_files("index-files");
44 const String C_sUseFileSuffix("-use.html");
45 const String C_IndexA_FileName("index-1.html");
48 HtmlEnvironment_Idl::HtmlEnvironment_Idl( const csv::ploc::Path & i_rOutputDir,
49 const ary::idl::Gate & i_rGate,
50 const display::CorporateFrame & i_rLayout )
51 : aOutputRoot(i_rOutputDir),
52 pData(new AryAccess(i_rGate)),
53 pGate(&i_rGate),
54 pOutputTree(new output::Tree),
55 aCurPosition(pOutputTree->Root()),
56 pCurPageCe(0),
57 pLayout(&i_rLayout),
58 pLinker()
60 StringVector aHelp;
61 pOutputTree->Set_NamesRoot(aHelp);
63 aHelp.push_back(output::IndexFilesDirName());
64 pOutputTree->Set_IndexRoot(aHelp);
66 (*aHelp.begin()) = String("com");
67 aHelp.push_back(String("sun"));
68 aHelp.push_back(String("star"));
69 pOutputTree->Set_Overview(aHelp, output::ModuleFileName() );
71 pLinker = new LinkHelper(*this);
74 HtmlEnvironment_Idl::~HtmlEnvironment_Idl()
78 namespace
80 StringVector G_aChain;
83 void
84 HtmlEnvironment_Idl::Goto_Directory( output::Position i_pos,
85 bool i_bCreateDirectoryIfNecessary )
87 aCurPosition = i_pos;
88 aCurPath = aOutputRoot.MyPath();
90 aCurPosition.Get_Chain(G_aChain);
91 for ( StringVector::const_iterator it = G_aChain.begin();
92 it != G_aChain.end();
93 ++it )
95 aCurPath.DirChain() += *it;
98 if (i_bCreateDirectoryIfNecessary)
99 create_Directory(aCurPath);
102 void
103 HtmlEnvironment_Idl::Goto_DirectoryLevelDown( const String & i_subDirName,
104 bool i_bCreateDirectoryIfNecessary )
106 aCurPosition +=(i_subDirName);
108 aCurPath.SetFile(String::Null_());
109 aCurPath.DirChain() += i_subDirName;
111 if (i_bCreateDirectoryIfNecessary)
112 create_Directory(aCurPath);
115 void
116 HtmlEnvironment_Idl::Goto_DirectoryLevelUp()
118 aCurPosition -= 1;
120 aCurPath.SetFile(String::Null_());
121 aCurPath.DirChain() -= 1;
124 void
125 HtmlEnvironment_Idl::Set_CurFile( const String & i_fileName )
127 aCurPath.SetFile(i_fileName);
130 void
131 HtmlEnvironment_Idl::create_Directory( const csv::ploc::Path & i_path )
134 csv::ploc::Directory aCurDir(i_path);
135 if (NOT aCurDir.Exists())
136 aCurDir.PhysicalCreate();
139 inline bool
140 IsAbsoluteLink(const char * i_link)
142 const char
143 shttp[] = "http://";
144 const char
145 sfile[] = "file://";
146 const int
147 csize = sizeof shttp - 1;
148 csv_assert(csize == sizeof sfile - 1);
150 return strncmp(i_link,shttp,csize) == 0
151 OR strncmp(i_link,sfile,csize) == 0;
155 const char *
156 HtmlEnvironment_Idl::Link2Manual( const String & i_link ) const
158 if ( IsAbsoluteLink(i_link.c_str()) )
159 return i_link;
161 static StreamStr aLink_(200);
162 aLink_.reset();
163 String
164 sDvgRoot(pLayout->DevelopersGuideHtmlRoot());
165 if (sDvgRoot.empty())
166 sDvgRoot = "../DevelopersGuide";
168 // KORR_FUTURE
169 // Enhance performance by calculating this only one time:
170 if ( NOT IsAbsoluteLink(sDvgRoot.c_str()) )
171 aCurPosition.Get_LinkToRoot(aLink_);
172 aLink_ << sDvgRoot
173 << "/"
174 << i_link;
175 return aLink_.c_str();
178 String
179 HtmlEnvironment_Idl::CurPageCe_AsText() const
181 return CurPageCe_AsFile(".html");
184 String
185 HtmlEnvironment_Idl::CurPageCe_AsFile(const char * i_sEnding) const
187 if (pCurPageCe == 0)
188 return String::Null_();
190 static StringVector aModule_;
191 String sCe;
192 String sDummy;
193 Data().Get_CeText(aModule_, sCe, sDummy, *pCurPageCe);
194 StreamLock slCe(500);
195 if (aModule_.size() > 0)
196 slCe().operator_join(aModule_.begin(), aModule_.end(), "/");
197 if (NOT sCe.empty())
198 slCe() << "/" << sCe << i_sEnding;
199 return String(slCe().c_str());
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */