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 <adc_msg.hxx> 30 31 32 // NOT FULLY DEFINED SERVICES 33 #include <cosv/file.hxx> 34 #include <cosv/tpl/tpltools.hxx> 35 36 37 namespace autodoc 38 { 39 40 41 Messages::Messages() 42 : aMissingDocs(), 43 aParseErrors(), 44 aInvalidConstSymbols(), 45 aUnresolvedLinks(), 46 aTypeVsMemberMisuses() 47 { 48 } 49 50 Messages::~Messages() 51 { 52 } 53 54 void 55 Messages::WriteFile(const String & i_sOutputFilePath) 56 { 57 csv::File 58 aOut(i_sOutputFilePath, csv::CFM_CREATE); 59 aOut.open(); 60 61 // KORR_FUTURE Enable this when appropriate: 62 WriteParagraph( aOut, 63 aParseErrors, 64 "Incompletely Parsed Files", 65 "Stopped parsing at " ); 66 67 WriteParagraph( aOut, 68 aMissingDocs, 69 "Entities Without Documentation", 70 " in " ); 71 72 WriteParagraph( aOut, 73 aInvalidConstSymbols, 74 "Incorrectly Written Const Symbols", 75 " in " ); 76 77 WriteParagraph( aOut, 78 aUnresolvedLinks, 79 "Unresolved Links", 80 " in\n " ); 81 82 WriteParagraph( aOut, 83 aTypeVsMemberMisuses, 84 "Confusion or Misuse of <Type> vs. <Member>", 85 " in " ); 86 aOut.close(); 87 } 88 89 void 90 Messages::Out_MissingDoc( const String & i_sEntity, 91 const String & i_sFile, 92 uintt i_nLine) 93 { 94 AddValue( aMissingDocs, 95 i_sEntity, 96 i_sFile, 97 i_nLine ); 98 } 99 100 void 101 Messages::Out_ParseError( const String & i_sFile, 102 uintt i_nLine) 103 { 104 aParseErrors[Location(i_sFile,i_nLine)] = String::Null_(); 105 } 106 107 void 108 Messages::Out_InvalidConstSymbol( const String & i_sText, 109 const String & i_sFile, 110 uintt i_nLine) 111 { 112 AddValue( aInvalidConstSymbols, 113 i_sText, 114 i_sFile, 115 i_nLine ); 116 } 117 118 void 119 Messages::Out_UnresolvedLink( const String & i_sLinkText, 120 const String & i_sFile, 121 uintt i_nLine) 122 { 123 AddValue( aUnresolvedLinks, 124 i_sLinkText, 125 i_sFile, 126 i_nLine ); 127 } 128 129 void 130 Messages::Out_TypeVsMemberMisuse( const String & i_sLinkText, 131 const String & i_sFile, 132 uintt i_nLine) 133 { 134 AddValue( aTypeVsMemberMisuses, 135 i_sLinkText, 136 i_sFile, 137 i_nLine ); 138 } 139 140 Messages & 141 Messages::The_() 142 { 143 static Messages TheMessages_; 144 return TheMessages_; 145 } 146 147 void 148 Messages::AddValue( MessageMap & o_dest, 149 const String & i_sText, 150 const String & i_sFile, 151 uintt i_nLine ) 152 { 153 String & 154 rDest = o_dest[Location(i_sFile,i_nLine)]; 155 StreamLock 156 slDest(2000); 157 if (NOT rDest.empty()) 158 slDest() << rDest; 159 slDest() << "\n " << i_sText; 160 rDest = slDest().c_str(); 161 } 162 163 void 164 Messages::WriteParagraph( csv::File & o_out, 165 const MessageMap & i_source, 166 const String & i_title, 167 const String & ) 168 { 169 StreamStr aLine(2000); 170 171 // Write title of paragraph: 172 aLine << i_title 173 << "\n"; 174 o_out.write(aLine.c_str()); 175 176 aLine.seekp(0); 177 for (uintt i = i_title.size(); i > 0; --i) 178 { 179 aLine << '-'; 180 } 181 aLine << "\n\n"; 182 o_out.write(aLine.c_str()); 183 184 // Write Content 185 MessageMap::const_iterator it = i_source.begin(); 186 MessageMap::const_iterator itEnd = i_source.end(); 187 for ( ; it != itEnd; ++it ) 188 { 189 aLine.seekp(0); 190 aLine << (*it).first.sFile; 191 // Nobody wants to see this, if we don't know the line: 192 if ((*it).first.nLine != 0) 193 { 194 aLine << ", line " 195 << (*it).first.nLine; 196 } 197 if (NOT (*it).second.empty()) 198 { 199 aLine << ':' 200 << (*it).second 201 << "\n"; 202 } 203 o_out.write(aLine.c_str()); 204 } 205 o_out.write("\n\n\n"); 206 } 207 208 } // namespace autodoc 209