merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / display / html / cre_link.cxx
blob5a8c89f448e5c748c2e39a126c555e04475ceabe
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cre_link.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include "cre_link.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/cpp/c_class.hxx>
37 #include <ary/cpp/c_define.hxx>
38 #include <ary/cpp/c_enum.hxx>
39 #include <ary/cpp/c_enuval.hxx>
40 #include <ary/cpp/c_funct.hxx>
41 #include <ary/cpp/c_gate.hxx>
42 #include <ary/cpp/c_macro.hxx>
43 #include <ary/cpp/c_namesp.hxx>
44 #include <ary/cpp/c_tydef.hxx>
45 #include <ary/cpp/c_vari.hxx>
46 #include <ary/cpp/cp_ce.hxx>
47 #include <ary/loc/loc_file.hxx>
48 #include <ary/loc/locp_le.hxx>
49 #include "hdimpl.hxx"
50 #include "opageenv.hxx"
51 #include "strconst.hxx"
57 LinkCreator::LinkCreator( char * o_rOutput,
58 uintt i_nOutputSize )
59 : pOut(o_rOutput),
60 nOutMaxSize(i_nOutputSize),
61 pEnv(0)
65 LinkCreator::~LinkCreator()
69 void
70 LinkCreator::do_Process( const ary::cpp::Namespace & i_rData )
72 Create_PrePath( i_rData );
73 strcat( pOut, "index.html" ); // KORR_FUTURE // SAFE STRCAT (#100211# - checked)
76 void
77 LinkCreator::do_Process( const ary::cpp::Class & i_rData )
79 Create_PrePath( i_rData );
80 strcat( pOut, ClassFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked)
83 void
84 LinkCreator::do_Process( const ary::cpp::Enum & i_rData )
86 Create_PrePath( i_rData );
87 strcat( pOut, EnumFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked)
90 void
91 LinkCreator::do_Process( const ary::cpp::Typedef & i_rData )
93 Create_PrePath( i_rData );
94 strcat( pOut, TypedefFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked)
97 void
98 LinkCreator::do_Process( const ary::cpp::Function & i_rData )
100 Create_PrePath( i_rData );
102 if ( i_rData.Protection() != ary::cpp::PROTECT_global )
104 strcat( pOut, "o.html" ); // SAFE STRCAT (#100211# - checked)
106 else
108 csv_assert(i_rData.Location().IsValid());
109 const ary::loc::File &
110 rFile = pEnv->Gate().Locations().Find_File(i_rData.Location());
111 strcat( pOut, HtmlFileName("o-", rFile.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked)
114 csv_assert(pEnv != 0);
115 strcat( pOut, OperationLink(pEnv->Gate(), i_rData.LocalName(), i_rData.CeId()) ); // SAFE STRCAT (#100211# - checked)
118 void
119 LinkCreator::do_Process( const ary::cpp::Variable & i_rData )
121 Create_PrePath( i_rData );
123 if ( i_rData.Protection() != ary::cpp::PROTECT_global )
125 strcat( pOut, "d.html" ); // SAFE STRCAT (#100211# - checked)
127 else
129 csv_assert(i_rData.Location().IsValid());
130 const ary::loc::File &
131 rFile = pEnv->Gate().Locations().Find_File(i_rData.Location());
132 strcat( pOut, HtmlFileName("d-", rFile.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked)
135 strcat( pOut, DataLink(i_rData.LocalName()) ); // SAFE STRCAT (#100211# - checked)
138 void
139 LinkCreator::do_Process( const ary::cpp::EnumValue & i_rData )
141 const ary::cpp::CodeEntity *
142 pEnum = pEnv->Gate().Ces().Search_Ce(i_rData.Owner());
143 if (pEnum == 0)
144 return;
146 pEnum->Accept(*this);
147 strcat(pOut, "#"); // SAFE STRCAT (#100211# - checked)
148 strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked)
151 void
152 LinkCreator::do_Process( const ary::cpp::Define & i_rData )
154 // KORR_FUTURE
155 // Only valid from Index:
157 *pOut = '\0';
158 strcat(pOut, "../def-all.html#"); // SAFE STRCAT (#100211# - checked)
159 strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked)
162 void
163 LinkCreator::do_Process( const ary::cpp::Macro & i_rData )
165 // KORR_FUTURE
166 // Only valid from Index:
168 *pOut = '\0';
169 strcat(pOut, "../def-all.html#"); // SAFE STRCAT (#100211# - checked)
170 strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked)
174 namespace
177 class NameScope_const_iterator
179 public:
180 NameScope_const_iterator(
181 ary::cpp::Ce_id i_nId,
182 const ary::cpp::Gate &
183 i_rGate );
185 operator bool() const { return pCe != 0; }
186 const String & operator*() const;
188 void go_up();
190 private:
191 const ary::cpp::CodeEntity *
192 pCe;
193 const ary::cpp::Gate *
194 pGate;
198 NameScope_const_iterator::NameScope_const_iterator(
199 ary::cpp::Ce_id i_nId,
200 const ary::cpp::Gate & i_rGate )
201 : pCe(i_rGate.Ces().Search_Ce(i_nId)),
202 pGate(&i_rGate)
206 const String &
207 NameScope_const_iterator::operator*() const
209 return pCe ? pCe->LocalName()
210 : String::Null_();
213 void
214 NameScope_const_iterator::go_up()
216 if (pCe == 0)
217 return;
218 pCe = pGate->Ces().Search_Ce(pCe->Owner());
222 void Recursive_CreatePath(
223 char * o_pOut,
224 const NameScope_const_iterator &
225 i_it );
227 void
228 Recursive_CreatePath( char * o_pOut,
229 const NameScope_const_iterator & i_it )
231 if (NOT i_it)
232 return;
234 NameScope_const_iterator it( i_it );
235 it.go_up();
236 if (NOT it)
237 return; // Global Namespace
238 Recursive_CreatePath( o_pOut, it );
240 strcat( o_pOut, (*i_it).c_str() ); // SAFE STRCAT (#100211# - checked)
241 strcat( o_pOut, "/" ); // SAFE STRCAT (#100211# - checked)
245 } // anonymous namespace
251 void
252 LinkCreator::Create_PrePath( const ary::cpp::CodeEntity & i_rData )
254 *pOut = NULCH;
256 if ( pEnv->CurNamespace() != 0 )
258 if ( pEnv->CurClass()
259 ? pEnv->CurClass()->CeId() == i_rData.Owner()
260 : pEnv->CurNamespace()->CeId() == i_rData.Owner() )
261 return;
263 strcat( pOut, PathUp(pEnv->Depth() - 1) ); // SAFE STRCAT (#100211# - checked)
265 else
266 { // Within Index
267 strcat( pOut, "../names/" ); // SAFE STRCAT (#100211# - checked)
270 NameScope_const_iterator it( i_rData.Owner(), pEnv->Gate() );
271 Recursive_CreatePath( pOut, it );