1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <precomp.h> 29 #include "cre_link.hxx" 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <ary/cpp/c_class.hxx> 34 #include <ary/cpp/c_define.hxx> 35 #include <ary/cpp/c_enum.hxx> 36 #include <ary/cpp/c_enuval.hxx> 37 #include <ary/cpp/c_funct.hxx> 38 #include <ary/cpp/c_gate.hxx> 39 #include <ary/cpp/c_macro.hxx> 40 #include <ary/cpp/c_namesp.hxx> 41 #include <ary/cpp/c_tydef.hxx> 42 #include <ary/cpp/c_vari.hxx> 43 #include <ary/cpp/cp_ce.hxx> 44 #include <ary/loc/loc_file.hxx> 45 #include <ary/loc/locp_le.hxx> 46 #include "hdimpl.hxx" 47 #include "opageenv.hxx" 48 #include "strconst.hxx" 49 50 51 52 53 54 LinkCreator::LinkCreator( char * o_rOutput, 55 uintt i_nOutputSize ) 56 : pOut(o_rOutput), 57 nOutMaxSize(i_nOutputSize), 58 pEnv(0) 59 { 60 } 61 62 LinkCreator::~LinkCreator() 63 { 64 } 65 66 void 67 LinkCreator::do_Process( const ary::cpp::Namespace & i_rData ) 68 { 69 Create_PrePath( i_rData ); 70 strcat( pOut, "index.html" ); // KORR_FUTURE // SAFE STRCAT (#100211# - checked) 71 } 72 73 void 74 LinkCreator::do_Process( const ary::cpp::Class & i_rData ) 75 { 76 Create_PrePath( i_rData ); 77 strcat( pOut, ClassFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 78 } 79 80 void 81 LinkCreator::do_Process( const ary::cpp::Enum & i_rData ) 82 { 83 Create_PrePath( i_rData ); 84 strcat( pOut, EnumFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 85 } 86 87 void 88 LinkCreator::do_Process( const ary::cpp::Typedef & i_rData ) 89 { 90 Create_PrePath( i_rData ); 91 strcat( pOut, TypedefFileName(i_rData.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 92 } 93 94 void 95 LinkCreator::do_Process( const ary::cpp::Function & i_rData ) 96 { 97 Create_PrePath( i_rData ); 98 99 if ( i_rData.Protection() != ary::cpp::PROTECT_global ) 100 { 101 strcat( pOut, "o.html" ); // SAFE STRCAT (#100211# - checked) 102 } 103 else 104 { 105 csv_assert(i_rData.Location().IsValid()); 106 const ary::loc::File & 107 rFile = pEnv->Gate().Locations().Find_File(i_rData.Location()); 108 strcat( pOut, HtmlFileName("o-", rFile.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 109 } 110 111 csv_assert(pEnv != 0); 112 strcat( pOut, OperationLink(pEnv->Gate(), i_rData.LocalName(), i_rData.CeId()) ); // SAFE STRCAT (#100211# - checked) 113 } 114 115 void 116 LinkCreator::do_Process( const ary::cpp::Variable & i_rData ) 117 { 118 Create_PrePath( i_rData ); 119 120 if ( i_rData.Protection() != ary::cpp::PROTECT_global ) 121 { 122 strcat( pOut, "d.html" ); // SAFE STRCAT (#100211# - checked) 123 } 124 else 125 { 126 csv_assert(i_rData.Location().IsValid()); 127 const ary::loc::File & 128 rFile = pEnv->Gate().Locations().Find_File(i_rData.Location()); 129 strcat( pOut, HtmlFileName("d-", rFile.LocalName().c_str()) ); // SAFE STRCAT (#100211# - checked) 130 } 131 132 strcat( pOut, DataLink(i_rData.LocalName()) ); // SAFE STRCAT (#100211# - checked) 133 } 134 135 void 136 LinkCreator::do_Process( const ary::cpp::EnumValue & i_rData ) 137 { 138 const ary::cpp::CodeEntity * 139 pEnum = pEnv->Gate().Ces().Search_Ce(i_rData.Owner()); 140 if (pEnum == 0) 141 return; 142 143 pEnum->Accept(*this); 144 strcat(pOut, "#"); // SAFE STRCAT (#100211# - checked) 145 strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked) 146 } 147 148 void 149 LinkCreator::do_Process( const ary::cpp::Define & i_rData ) 150 { 151 // KORR_FUTURE 152 // Only valid from Index: 153 154 *pOut = '\0'; 155 strcat(pOut, "../def-all.html#"); // SAFE STRCAT (#100211# - checked) 156 strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked) 157 } 158 159 void 160 LinkCreator::do_Process( const ary::cpp::Macro & i_rData ) 161 { 162 // KORR_FUTURE 163 // Only valid from Index: 164 165 *pOut = '\0'; 166 strcat(pOut, "../def-all.html#"); // SAFE STRCAT (#100211# - checked) 167 strcat(pOut, i_rData.LocalName().c_str()); // SAFE STRCAT (#100211# - checked) 168 } 169 170 171 namespace 172 { 173 174 class NameScope_const_iterator 175 { 176 public: 177 NameScope_const_iterator( 178 ary::cpp::Ce_id i_nId, 179 const ary::cpp::Gate & 180 i_rGate ); 181 182 operator bool() const { return pCe != 0; } 183 const String & operator*() const; 184 185 void go_up(); 186 187 private: 188 const ary::cpp::CodeEntity * 189 pCe; 190 const ary::cpp::Gate * 191 pGate; 192 }; 193 194 195 NameScope_const_iterator::NameScope_const_iterator( 196 ary::cpp::Ce_id i_nId, 197 const ary::cpp::Gate & i_rGate ) 198 : pCe(i_rGate.Ces().Search_Ce(i_nId)), 199 pGate(&i_rGate) 200 { 201 } 202 203 const String & 204 NameScope_const_iterator::operator*() const 205 { 206 return pCe ? pCe->LocalName() 207 : String::Null_(); 208 } 209 210 void 211 NameScope_const_iterator::go_up() 212 { 213 if (pCe == 0) 214 return; 215 pCe = pGate->Ces().Search_Ce(pCe->Owner()); 216 } 217 218 219 void Recursive_CreatePath( 220 char * o_pOut, 221 const NameScope_const_iterator & 222 i_it ); 223 224 void 225 Recursive_CreatePath( char * o_pOut, 226 const NameScope_const_iterator & i_it ) 227 { 228 if (NOT i_it) 229 return; 230 231 NameScope_const_iterator it( i_it ); 232 it.go_up(); 233 if (NOT it) 234 return; // Global Namespace 235 Recursive_CreatePath( o_pOut, it ); 236 237 strcat( o_pOut, (*i_it).c_str() ); // SAFE STRCAT (#100211# - checked) 238 strcat( o_pOut, "/" ); // SAFE STRCAT (#100211# - checked) 239 } 240 241 242 } // anonymous namespace 243 244 245 246 247 248 void 249 LinkCreator::Create_PrePath( const ary::cpp::CodeEntity & i_rData ) 250 { 251 *pOut = NULCH; 252 253 if ( pEnv->CurNamespace() != 0 ) 254 { 255 if ( pEnv->CurClass() 256 ? pEnv->CurClass()->CeId() == i_rData.Owner() 257 : pEnv->CurNamespace()->CeId() == i_rData.Owner() ) 258 return; 259 260 strcat( pOut, PathUp(pEnv->Depth() - 1) ); // SAFE STRCAT (#100211# - checked) 261 } 262 else 263 { // Within Index 264 strcat( pOut, "../names/" ); // SAFE STRCAT (#100211# - checked) 265 } 266 267 NameScope_const_iterator it( i_rData.Owner(), pEnv->Gate() ); 268 Recursive_CreatePath( pOut, it ); 269 } 270