My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eclipsehelp.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2015 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 #include "eclipsehelp.h"
16 #include "util.h"
17 #include "config.h"
18 #include "message.h"
19 #include "doxygen.h"
20 #include <qfile.h>
21 
22 EclipseHelp::EclipseHelp() : m_depth(0), m_endtag(FALSE), m_openTags(0), m_tocfile(0)
23 {
24 }
25 
27 {
28 }
29 
31 {
32  int i;
33  for (i=0; i<m_depth; i++)
34  {
35  m_tocstream << " ";
36  }
37 }
38 
40 {
41  if (m_endtag)
42  {
43  m_tocstream << "/>" << endl;
44  m_endtag = FALSE;
45  }
46 }
47 
49 {
50  if (m_endtag)
51  {
52  m_tocstream << ">" << endl;
53  m_endtag = FALSE;
54  ++m_openTags;
55  }
56 }
57 
65 {
66  // -- read path prefix from the configuration
67  //m_pathprefix = Config_getString(ECLIPSE_PATHPREFIX);
68  //if (m_pathprefix.isEmpty()) m_pathprefix = "html/";
69 
70  // -- open the contents file
71  QCString name = Config_getString(HTML_OUTPUT) + "/toc.xml";
72  m_tocfile = new QFile(name);
73  if (!m_tocfile->open(IO_WriteOnly))
74  {
75  err("Could not open file %s for writing\n", name.data());
76  exit(1);
77  }
78 
79  // -- initialize its text stream
81  //m_tocstream.setEncoding(FTextStream::UnicodeUTF8);
82 
83  // -- write the opening tag
84  QCString title = Config_getString(PROJECT_NAME);
85  if (title.isEmpty())
86  {
87  title = "Doxygen generated documentation";
88  }
89  m_tocstream << "<toc label=\"" << convertToXML(title)
90  << "\" topic=\"" << convertToXML(m_pathprefix)
91  << "index" << Doxygen::htmlFileExtension << "\">" << endl;
92  ++ m_depth;
93 }
94 
102 {
103  closedTag(); // -- close previous tag
104 
105  // -- write ending tag
106  --m_depth;
107  m_tocstream << "</toc>" << endl;
108 
109  // -- close the content file
111  m_tocfile->close();
112  delete m_tocfile; m_tocfile = 0;
113 
114  QCString name = Config_getString(HTML_OUTPUT) + "/plugin.xml";
115  QFile pluginFile(name);
116  if (pluginFile.open(IO_WriteOnly))
117  {
118  QString docId = Config_getString(ECLIPSE_DOC_ID);
119  FTextStream t(&pluginFile);
120  t << "<plugin name=\"" << docId << "\" id=\"" << docId << "\"" << endl;
121  t << " version=\"1.0.0\" provider-name=\"Doxygen\">" << endl;
122  t << " <extension point=\"org.eclipse.help.toc\">" << endl;
123  t << " <toc file=\"toc.xml\" primary=\"true\" />" << endl;
124  t << " </extension>" << endl;
125  t << "</plugin>" << endl;
126  }
127 }
128 
133 {
134  openedTag();
135  ++m_depth;
136 }
137 
144 {
145  // -- end of the opened topic
146  closedTag();
147  --m_depth;
148 
149  if (m_openTags==m_depth)
150  {
151  --m_openTags;
152  indent();
153  m_tocstream << "</topic>" << endl;
154  }
155 }
156 
170  bool /* isDir */,
171  const char *name,
172  const char * /* ref */,
173  const char *file,
174  const char *anchor,
175  bool /* separateIndex */,
176  bool /* addToNavIndex */,
177  Definition * /*def*/)
178 {
179  // -- write the topic tag
180  closedTag();
181  if (file)
182  {
183  switch (file[0]) // check for special markers (user defined URLs)
184  {
185  case '^':
186  // URL not supported by eclipse toc.xml
187  break;
188 
189  case '!':
190  indent();
191  m_tocstream << "<topic label=\"" << convertToXML(name) << "\"";
192  m_tocstream << " href=\"" << convertToXML(m_pathprefix) << &file[1] << "\"";
193  m_endtag = TRUE;
194  break;
195 
196  default:
197  indent();
198  m_tocstream << "<topic label=\"" << convertToXML(name) << "\"";
199  m_tocstream << " href=\"" << convertToXML(m_pathprefix)
200  << file << Doxygen::htmlFileExtension;
201  if (anchor)
202  {
203  m_tocstream << "#" << anchor;
204  }
205  m_tocstream << "\"";
206  m_endtag = TRUE;
207  break;
208  }
209  }
210  else
211  {
212  indent();
213  m_tocstream << "<topic label=\"" << convertToXML(name) << "\"";
214  m_endtag = TRUE;
215  }
216 }
217 
219  Definition * /* context */,
220  MemberDef * /* md */,
221  const char * /* sectionAnchor */,
222  const char * /* title */)
223 {
224 }
225 
226 void EclipseHelp::addIndexFile(const char * /* name */)
227 {
228 }
229 
230 void EclipseHelp::addImageFile(const char * /* name */)
231 {
232 }
233 
234 void EclipseHelp::addStyleSheetFile(const char * /* name */)
235 {
236 }
237