merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / exes / adc_uni / adc_msg.cxx
blob95c1d88c625d7b850b0e14a85749757391c48904
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: adc_msg.cxx,v $
10 * $Revision: 1.8 $
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 <adc_msg.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/file.hxx>
37 #include <cosv/tpl/tpltools.hxx>
40 namespace autodoc
44 Messages::Messages()
45 : aMissingDocs(),
46 aParseErrors(),
47 aInvalidConstSymbols(),
48 aUnresolvedLinks(),
49 aTypeVsMemberMisuses()
53 Messages::~Messages()
57 void
58 Messages::WriteFile(const String & i_sOutputFilePath)
60 csv::File
61 aOut(i_sOutputFilePath, csv::CFM_CREATE);
62 aOut.open();
64 // KORR_FUTURE Enable this when appropriate:
65 WriteParagraph( aOut,
66 aParseErrors,
67 "Incompletely Parsed Files",
68 "Stopped parsing at " );
70 WriteParagraph( aOut,
71 aMissingDocs,
72 "Entities Without Documentation",
73 " in " );
75 WriteParagraph( aOut,
76 aInvalidConstSymbols,
77 "Incorrectly Written Const Symbols",
78 " in " );
80 WriteParagraph( aOut,
81 aUnresolvedLinks,
82 "Unresolved Links",
83 " in\n " );
85 WriteParagraph( aOut,
86 aTypeVsMemberMisuses,
87 "Confusion or Misuse of <Type> vs. <Member>",
88 " in " );
89 aOut.close();
92 void
93 Messages::Out_MissingDoc( const String & i_sEntity,
94 const String & i_sFile,
95 uintt i_nLine)
97 AddValue( aMissingDocs,
98 i_sEntity,
99 i_sFile,
100 i_nLine );
103 void
104 Messages::Out_ParseError( const String & i_sFile,
105 uintt i_nLine)
107 aParseErrors[Location(i_sFile,i_nLine)] = String::Null_();
110 void
111 Messages::Out_InvalidConstSymbol( const String & i_sText,
112 const String & i_sFile,
113 uintt i_nLine)
115 AddValue( aInvalidConstSymbols,
116 i_sText,
117 i_sFile,
118 i_nLine );
121 void
122 Messages::Out_UnresolvedLink( const String & i_sLinkText,
123 const String & i_sFile,
124 uintt i_nLine)
126 AddValue( aUnresolvedLinks,
127 i_sLinkText,
128 i_sFile,
129 i_nLine );
132 void
133 Messages::Out_TypeVsMemberMisuse( const String & i_sLinkText,
134 const String & i_sFile,
135 uintt i_nLine)
137 AddValue( aTypeVsMemberMisuses,
138 i_sLinkText,
139 i_sFile,
140 i_nLine );
143 Messages &
144 Messages::The_()
146 static Messages TheMessages_;
147 return TheMessages_;
150 void
151 Messages::AddValue( MessageMap & o_dest,
152 const String & i_sText,
153 const String & i_sFile,
154 uintt i_nLine )
156 String &
157 rDest = o_dest[Location(i_sFile,i_nLine)];
158 StreamLock
159 slDest(2000);
160 if (NOT rDest.empty())
161 slDest() << rDest;
162 slDest() << "\n " << i_sText;
163 rDest = slDest().c_str();
166 void
167 Messages::WriteParagraph( csv::File & o_out,
168 const MessageMap & i_source,
169 const String & i_title,
170 const String & )
172 StreamStr aLine(2000);
174 // Write title of paragraph:
175 aLine << i_title
176 << "\n";
177 o_out.write(aLine.c_str());
179 aLine.seekp(0);
180 for (uintt i = i_title.size(); i > 0; --i)
182 aLine << '-';
184 aLine << "\n\n";
185 o_out.write(aLine.c_str());
187 // Write Content
188 MessageMap::const_iterator it = i_source.begin();
189 MessageMap::const_iterator itEnd = i_source.end();
190 for ( ; it != itEnd; ++it )
192 aLine.seekp(0);
193 aLine << (*it).first.sFile;
194 // Nobody wants to see this, if we don't know the line:
195 if ((*it).first.nLine != 0)
197 aLine << ", line "
198 << (*it).first.nLine;
200 if (NOT (*it).second.empty())
202 aLine << ':'
203 << (*it).second
204 << "\n";
206 o_out.write(aLine.c_str());
208 o_out.write("\n\n\n");
211 } // namespace autodoc