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_cmds.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <ary/ary.hxx>
34 #include <autodoc/displaying.hxx>
35 #include <autodoc/dsp_html_std.hxx>
36 #include <display/corframe.hxx>
37 #include <adc_cl.hxx>
38 
39 
40 namespace autodoc
41 {
42 namespace command
43 {
44 
45 extern const String C_opt_Include("-I:");
46 
47 extern const String C_opt_Verbose("-v");
48 
49 extern const String C_opt_Parse("-parse");
50 extern const String C_opt_Name("-name");
51 extern const String C_opt_LangAll("-lg");
52 extern const String C_opt_ExtensionsAll("-extg");
53 extern const String C_opt_DevmanFile("-dvgfile");
54 extern const String C_opt_SinceFile("-sincefile");
55 
56 extern const String C_arg_Cplusplus("c++");
57 extern const String C_arg_Idl("idl");
58 extern const String C_arg_Java("java");
59 
60 extern const String C_opt_Project("-p");
61 //extern const String C_opt_Lang;
62 //extern const String C_opt_Extensions;
63 extern const String C_opt_SourceDir("-d");
64 extern const String C_opt_SourceTree("-t");
65 extern const String C_opt_SourceFile("-f");
66 
67 extern const String C_opt_CreateHtml("-html");
68 extern const String C_opt_DevmanRoot("-dvgroot");
69 
70 //extern const String C_opt_CreateXml("-xml");
71 //extern const String C_opt_Load("-load");
72 //extern const String C_opt_Save("-save");
73 
74 extern const String C_opt_ExternNamespace("-extnsp");
75 extern const String C_opt_ExternRoot("-extroot");
76 
77 
78 
79 //**************************        CreateHTML    ***********************//
80 
81 CreateHtml::CreateHtml()
82     :   sOutputRootDirectory(),
83         sDevelopersManual_HtmlRoot()
84 {
85 }
86 
87 CreateHtml::~CreateHtml()
88 {
89 }
90 
91 void
92 CreateHtml::do_Init( opt_iter &          it,
93                      opt_iter            itEnd )
94 {
95     ++it;
96     CHECKOPT( it != itEnd && (*it).char_at(0) != '-',
97               "output directory", C_opt_CreateHtml );
98     sOutputRootDirectory = *it;
99 
100     for ( ++it;
101           it != itEnd AND (*it == C_opt_DevmanRoot);
102           ++it )
103     {
104         if (*it == C_opt_DevmanRoot)
105         {
106             ++it;
107             CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
108                       "HTML root directory of Developers Guide",
109                       C_opt_DevmanRoot );
110             sDevelopersManual_HtmlRoot = *it;
111         }
112     }   // end for
113 }
114 
115 bool
116 CreateHtml::do_Run() const
117 {
118     if ( CommandLine::Get_().IdlUsed() )
119         run_Idl();
120     if ( CommandLine::Get_().CppUsed() )
121         run_Cpp();
122     return true;
123 }
124 
125 int
126 CreateHtml::inq_RunningRank() const
127 {
128     return static_cast<int>(rank_CreateHtml);
129 }
130 
131 void
132 CreateHtml::run_Idl() const
133 {
134     const ary::idl::Gate &
135         rGate = CommandLine::Get_().TheRepository().Gate_Idl();
136 
137     Cout() << "Creating HTML-output into the directory "
138               << sOutputRootDirectory
139               << "."
140               << Endl();
141 
142     const DisplayToolsFactory_Ifc &
143         rToolsFactory = DisplayToolsFactory_Ifc::GetIt_();
144     Dyn<autodoc::HtmlDisplay_Idl_Ifc>
145         pDisplay( rToolsFactory.Create_HtmlDisplay_Idl() );
146 
147     DYN display::CorporateFrame &   // KORR_FUTURE: Remove the need for const_cast
148         drFrame = const_cast< display::CorporateFrame& >(rToolsFactory.Create_StdFrame());
149     if (NOT DevelopersManual_HtmlRoot().empty())
150         drFrame.Set_DevelopersGuideHtmlRoot( DevelopersManual_HtmlRoot() );
151 
152     pDisplay->Run( sOutputRootDirectory,
153                    rGate,
154                    drFrame );
155 }
156 
157 void
158 CreateHtml::run_Cpp() const
159 {
160     const ary::Repository &
161         rReposy = CommandLine::Get_().TheRepository();
162     const ary::cpp::Gate &
163         rGate = rReposy.Gate_Cpp();
164 
165     const DisplayToolsFactory_Ifc &
166         rToolsFactory = DisplayToolsFactory_Ifc::GetIt_();
167     Dyn< autodoc::HtmlDisplay_UdkStd >
168         pDisplay( rToolsFactory.Create_HtmlDisplay_UdkStd() );
169 
170     pDisplay->Run( sOutputRootDirectory,
171                    rGate,
172                    rToolsFactory.Create_StdFrame() );
173 }
174 
175 
176 }   // namespace command
177 }   // namespace autodoc
178