1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cre_link.cxx,v $
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 ************************************************************************/
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>
50 #include "opageenv.hxx"
51 #include "strconst.hxx"
57 LinkCreator::LinkCreator( char * o_rOutput
,
60 nOutMaxSize(i_nOutputSize
),
65 LinkCreator::~LinkCreator()
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)
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)
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)
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)
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)
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)
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)
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)
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());
146 pEnum
->Accept(*this);
147 strcat(pOut
, "#"); // SAFE STRCAT (#100211# - checked)
148 strcat(pOut
, i_rData
.LocalName().c_str()); // SAFE STRCAT (#100211# - checked)
152 LinkCreator::do_Process( const ary::cpp::Define
& i_rData
)
155 // Only valid from Index:
158 strcat(pOut
, "../def-all.html#"); // SAFE STRCAT (#100211# - checked)
159 strcat(pOut
, i_rData
.LocalName().c_str()); // SAFE STRCAT (#100211# - checked)
163 LinkCreator::do_Process( const ary::cpp::Macro
& i_rData
)
166 // Only valid from Index:
169 strcat(pOut
, "../def-all.html#"); // SAFE STRCAT (#100211# - checked)
170 strcat(pOut
, i_rData
.LocalName().c_str()); // SAFE STRCAT (#100211# - checked)
177 class NameScope_const_iterator
180 NameScope_const_iterator(
181 ary::cpp::Ce_id i_nId
,
182 const ary::cpp::Gate
&
185 operator bool() const { return pCe
!= 0; }
186 const String
& operator*() const;
191 const ary::cpp::CodeEntity
*
193 const ary::cpp::Gate
*
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
)),
207 NameScope_const_iterator::operator*() const
209 return pCe
? pCe
->LocalName()
214 NameScope_const_iterator::go_up()
218 pCe
= pGate
->Ces().Search_Ce(pCe
->Owner());
222 void Recursive_CreatePath(
224 const NameScope_const_iterator
&
228 Recursive_CreatePath( char * o_pOut
,
229 const NameScope_const_iterator
& i_it
)
234 NameScope_const_iterator
it( i_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
252 LinkCreator::Create_PrePath( const ary::cpp::CodeEntity
& i_rData
)
256 if ( pEnv
->CurNamespace() != 0 )
258 if ( pEnv
->CurClass()
259 ? pEnv
->CurClass()->CeId() == i_rData
.Owner()
260 : pEnv
->CurNamespace()->CeId() == i_rData
.Owner() )
263 strcat( pOut
, PathUp(pEnv
->Depth() - 1) ); // SAFE STRCAT (#100211# - checked)
267 strcat( pOut
, "../names/" ); // SAFE STRCAT (#100211# - checked)
270 NameScope_const_iterator
it( i_rData
.Owner(), pEnv
->Gate() );
271 Recursive_CreatePath( pOut
, it
);