summaryrefslogtreecommitdiff
path: root/autodoc/source/display/html/outfile.cxx
blob: f76231fe8830d8cf60a5e3baf0ffc6cd54920ad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*************************************************************************
 *
 *  $RCSfile: outfile.cxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: vg $ $Date: 2005-03-23 08:58:31 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#include <precomp.h>
#include "outfile.hxx"

// NOT FULLY DECLARED SERVICES
#include <cosv/file.hxx>
#include <udm/html/htmlitem.hxx>
#include <toolkit/out_position.hxx>
#include "strconst.hxx"


using namespace csi;
using csi::xml::AnAttribute;



#define CRLF "\n"

const char * const
    C_sStdStyle =
    "body   { background-color:#ffffff; }"CRLF
    "h1     { font-size:20pt; margin-top:3pt; margin-bottom:7pt; }"CRLF
    "h2     { font-family:Arial; font-size:16pt; margin-top:3pt; margin-bottom:5pt; }"CRLF
    "h3     { font-size:13pt; margin-top:2pt; margin-bottom:3pt; }"CRLF
    "h4     { font-size:10pt; font-weight:bold; margin-top:2pt; margin-bottom:1pt; }"CRLF
    "dl     { margin-top:1pt; margin-bottom:1pt; }"CRLF
    "dl.member  { margin-top:1pt; margin-bottom:1pt; background-color:#eeeeff; }"CRLF
    "dt     { font-size:10pt; font-weight:bold; margin-top:2pt; margin-bottom:1pt; }"CRLF
    "dt.member  { font-size:13pt; font-weight:bold; margin-top:2pt; margin-bottom:1pt; }"CRLF
    "dt.simple  { font-size:10pt; font-weight:normal; margin-top:2pt; margin-bottom:1pt; }"CRLF
    "dd     { font-size:10pt; margin-top:1pt; margin-bottom:1pt; }"CRLF
    "dd.member  { font-size:10pt; margin-top:1pt; margin-bottom:1pt; background-color:#ffffff; }"CRLF
    "p      { font-size:10pt; margin-top:3pt; margin-bottom:1pt; }"CRLF
    "pre    { font-family:monospace; font-size:10pt; margin-top:1pt; margin-bottom:1pt; }"CRLF
    "tr     { font-size:10pt; }"CRLF
    "td     { font-size:10pt; }"CRLF
    CRLF
    "dt.attention   { color:#dd0000; }"CRLF
    CRLF
    "div.title      { text-align:center;  line-height:26pt; background-color:#ccccff; }"CRLF
    ".subtitle      { background-color:#ccccff; }"CRLF
    CRLF
    "td.flagname    { background-color:#eeeeff; font-family:Arial; font-size:8pt; font-weight:bold; }"CRLF
    "td.flagyes     { font-family:Arial; font-size:8pt; font-weight:bold; }"CRLF
    "td.flagno      { font-family:Arial; font-size:8pt; }"CRLF
    "td.flagtext    { font-family:Arial; font-size:8pt; font-weight:bold; }"CRLF
    CRLF
    "td.navimain, td.navimain a"CRLF
    "               { background-color:#eeeeff; color:#000000;"CRLF
    "                 font-family:Arial; font-size:12pt; font-weight:bold; }"CRLF
    "td.navimainself"CRLF
    "               { background-color:#2222ad; color:#ffffff;"CRLF
    "                 font-family:Arial; font-size:12pt; font-weight:bold; }"CRLF
    "td.navimainnone"CRLF
    "               { background-color:#eeeeff; color:#000000;"CRLF
    "                 font-family:Arial; font-size:12pt; }"CRLF
    CRLF
    "div.define     { font-family:Arial; background-color:#ccccff; }"CRLF
    CRLF
    ".nqclass       { color:#008800; }"CRLF
    CRLF
    "h3.help        { background-color:#eeeeff; margin-top:12pt; }"CRLF
    CRLF
    ".btpubl        { color:#33ff33; }"CRLF
    ".btprot        { color:#cc9933; }"CRLF
    ".btpriv        { color:#ff6666; }"CRLF
    ".btvpubl       { color:#33ff33; font-style:italic; }"CRLF
    ".btvprot       { color:#cc9933; font-style:italic; }"CRLF
    ".btvpriv       { color:#ff6666; font-style:italic; }"CRLF
    ".btself        { font-weight:bold; }"CRLF
    ;


const char * const
    C_sCssExplanations =
    "/* Explanation of CSS classes:"CRLF
    CRLF
    "dl.member       provides coloured frame for function descriptions."CRLF
    "dd.member       makes the content of this frame white"CRLF
    CRLF
    "dt.attention    special colour for @attention remarks"CRLF
    CRLF
    "div.title       HTML page headline"CRLF
    ".subtitle       headline of lists of members and similar"CRLF
    CRLF
    "                These are for the flagtables in classes:"CRLF
    "td.flagname     Flag name."CRLF
    "td.flagyes      flag value \"yes\""CRLF
    "td.flagno       flag value \"no\""CRLF
    "td.flagtext     other flag value"CRLF
    CRLF
    CRLF
    "                These are for the main navigationbar:"CRLF
    "td.navimain, td.navimain a"CRLF
    "                Links in navibar."CRLF
    "td.navimainself Text in navibar which refers to current page."CRLF
    "td.navimainnone Text which links to nothing."CRLF
    CRLF
    CRLF
    "div.define      Subtitles on the #define/macro descriptions page"CRLF
    CRLF
    ".nqclass        special color for classes in the qualification"CRLF
    "                on top of type pages like in:"CRLF
    "                ::nsp1::nsp2::_ClassXY_::"CRLF
    CRLF
    "h3.help         Subtitles on the help page"CRLF
    CRLF
    "                These are for the base class tree on class pages:"CRLF
    ".btpubl         public base class"CRLF
    ".btprot         protected"CRLF
    ".btpriv         private"CRLF
    ".btvpubl        virtual public"CRLF
    ".btvprot        virtual protected"CRLF
    ".btvpriv        virtual private"CRLF
    ".btself         placeholder for currently displayed class"CRLF
    CRLF
    "*/"CRLF
    ;



HtmlDocuFile::HtmlDocuFile()
    :   sFilePath(),
        sTitle(),
        sCopyright(),
        nDepth(0),
        aBodyData()
{
}

void
HtmlDocuFile::SetLocation( const csv::ploc::Path &  i_rFilePath,
                           uintt                    i_depthInOutputTree )
{
    static StreamStr sPath_(1000);
    sPath_.seekp(0);
    i_rFilePath.Get( sPath_ );

    sFilePath = sPath_.c_str();
    nDepth = i_depthInOutputTree;
}

void
HtmlDocuFile::SetTitle( const char * i_sTitle )
{
    sTitle = i_sTitle;
}

void
HtmlDocuFile::SetBodyAttr( const char *        i_sAttrName,
                           const char *        i_sAttrValue )
{
    aBodyData << new AnAttribute( i_sAttrName, i_sAttrValue );
}

void
HtmlDocuFile::SetCopyright( const char * i_sCopyright )
{
    sCopyright = i_sCopyright;
}

void
HtmlDocuFile::EmptyBody()
{
     aBodyData.SetContent(0);
    aBodyData
        >> *new html::Label( "_top_" )
        << " ";

}

bool
HtmlDocuFile::CreateFile()
{
    csv::File aFile(sFilePath, csv::CFM_CREATE);
    if (NOT aFile.open())
    {
        Cerr() << "Can't create file " << sFilePath << "." << Endl();
        return false;
    }

    WriteHeader(aFile);
    WriteBody(aFile);

    // Write end
    static const char sCompletion[] = "\n</html>\n";
    aFile.write( sCompletion );

    aFile.close();
    Cout() << '.' << Flush();
    return true;
}

void
HtmlDocuFile::WriteCssFile( const csv::ploc::Path & i_rFilePath )
{
    Cout() << "\nCreate css file ..." << Endl();

    csv::File
        aCssFile(i_rFilePath, csv::CFM_CREATE);
    csv::OpenCloseGuard
        aOpenGuard(aCssFile);
    if (NOT aOpenGuard)
    {
        Cerr() << "Can't create file " << "cpp.css" << "." << Endl();
        return;
    }

    aCssFile.write("/*      Autodoc css file for C++ documentation      */\n\n\n");
    aCssFile.write(C_sStdStyle);
    aCssFile.write("\n\n\n");
    aCssFile.write(C_sCssExplanations);
}

void
HtmlDocuFile::WriteHeader( csv::File & io_aFile )
{
    static const char s1[] =
        "<html>\n<head>\n"
        "<title>";
    static const char s2[] =
        "</title>\n"
        "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
    static const char s3[] =
        "\">\n</head>\n";

    io_aFile.write( s1 );
    io_aFile.write( sTitle );
    io_aFile.write( s2 );
    io_aFile.write( output::get_UpLink(nDepth) );
    io_aFile.write( C_sHFN_Css );
    io_aFile.write( s3 );
}

void
HtmlDocuFile::WriteBody( csv::File & io_aFile )
{
    aBodyData
        >> *new html::Link( "#_top_" )
                << new html::ClassAttr( "objchapter" )
                << "Top of Page";

    if ( sCopyright.length() > 0 )
    {
        aBodyData
#ifndef COMPATIBLE_NETSCAPE_47
            >> *new html::HorizontalLine
                    <<  new html::SizeAttr( "3" );
#else
            << new xml::XmlCode("<hr size=\"3\">");
#endif

        aBodyData
            >> *new html::Paragraph
                    << new html::ClassAttr( "copyright" )
                    << new xml::AnAttribute( "align", "center" )
                    << new xml::XmlCode(sCopyright);
    }
    aBodyData.WriteOut(io_aFile);
}