Update ooo320-m1
[ooovba.git] / autodoc / source / display / idl / hi_display.cxx
blob26f816e9d30ff3aa04b56dce8229bb631969458a
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: hi_display.cxx,v $
10 * $Revision: 1.7 $
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 <idl/hi_display.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/file.hxx>
37 #include <ary/idl/i_ce.hxx>
38 #include <ary/idl/i_module.hxx>
39 #include <ary/getncast.hxx>
40 #include <toolkit/out_tree.hxx>
41 #include <cfrstd.hxx>
42 #include "hi_ary.hxx"
43 #include "hi_env.hxx"
44 #include "hi_main.hxx"
47 extern const String C_sCssFilename_Idl;
50 inline bool
51 HtmlDisplay_Idl::IsModule( const ary::idl::CodeEntity & i_ce ) const
53 return ary::is_type<ary::idl::Module>(i_ce);
56 inline const ary::idl::Module &
57 HtmlDisplay_Idl::Module_Cast( const ary::idl::CodeEntity & i_ce ) const
59 return ary::ary_cast<ary::idl::Module>(i_ce);
65 HtmlDisplay_Idl::HtmlDisplay_Idl()
66 : pCurPageEnv(),
67 pMainDisplay()
71 HtmlDisplay_Idl::~HtmlDisplay_Idl()
75 void
76 HtmlDisplay_Idl::do_Run( const char * i_sOutputDirectory,
77 const ary::idl::Gate & i_rAryGate,
78 const display::CorporateFrame & i_rLayout )
80 SetRunData( i_sOutputDirectory, i_rAryGate, i_rLayout );
82 Create_StartFile();
83 Create_CssFile();
84 Create_FilesInNameTree();
85 Create_IndexFiles();
86 Create_FilesInProjectTree();
87 Create_PackageList();
88 Create_HelpFile();
91 void
92 HtmlDisplay_Idl::SetRunData( const char * i_sOutputDirectory,
93 const ary::idl::Gate & i_rAryGate,
94 const display::CorporateFrame & i_rLayout )
96 csv::ploc::Path aOutputDir( i_sOutputDirectory, true );
97 pCurPageEnv = new HtmlEnvironment_Idl( aOutputDir, i_rAryGate, i_rLayout );
98 pMainDisplay = new MainDisplay_Idl(*pCurPageEnv);
101 void
102 HtmlDisplay_Idl::Create_StartFile()
106 void
107 HtmlDisplay_Idl::Create_FilesInNameTree()
109 Cout() << "\nCreate files in subtree namespaces ..." << Endl();
111 const ary::idl::Module &
112 rGlobalNamespace = pCurPageEnv->Data().GlobalNamespace();
113 pCurPageEnv->Goto_Directory( pCurPageEnv->OutputTree().NamesRoot(), true );
115 RecursiveDisplay_Module(rGlobalNamespace);
117 Cout() << "... done." << Endl();
120 void
121 HtmlDisplay_Idl::Create_IndexFiles()
123 Cout() << "\nCreate files in subtree index ..." << Endl();
124 pCurPageEnv->Goto_Directory( pCurPageEnv->OutputTree().IndexRoot(), true );
125 pMainDisplay->WriteGlobalIndices();
126 Cout() << "... done.\n" << Endl();
129 typedef ary::Dyn_StdConstIterator<ary::idl::Ce_id> Dyn_CeIterator;
130 typedef ary::StdConstIterator<ary::idl::Ce_id> CeIterator;
132 void
133 HtmlDisplay_Idl::RecursiveDisplay_Module( const ary::idl::Module & i_module )
135 i_module.Accept(*pMainDisplay);
137 Dyn_CeIterator
138 aMembers;
139 i_module.Get_Names(aMembers);
141 for ( CeIterator & iter = *aMembers;
142 iter;
143 ++iter )
145 const ary::idl::CodeEntity &
146 rCe = pCurPageEnv->Data().Find_Ce(*iter);
148 if ( NOT IsModule(rCe) )
149 rCe.Accept(*pMainDisplay);
150 else
152 pCurPageEnv->Goto_DirectoryLevelDown( rCe.LocalName(), true );
153 RecursiveDisplay_Module( Module_Cast(rCe) );
154 pCurPageEnv->Goto_DirectoryLevelUp();
156 } // end for
159 void
160 HtmlDisplay_Idl::Create_FilesInProjectTree()
164 void
165 HtmlDisplay_Idl::Create_PackageList()
167 #if 0
168 Cout() << "\nCreate package list ..." << std::flush;
170 pCurPageEnv->CurPosition() = pCurPageEnv->OutputTree().Root();
172 // KORR
173 // ...
175 Cout() << " done." << Endl();
176 #endif // 0
179 void
180 HtmlDisplay_Idl::Create_HelpFile()
184 void
185 HtmlDisplay_Idl::Create_CssFile()
187 Cout() << "\nCreate css file ..." << Endl();
189 pCurPageEnv->Goto_Directory( pCurPageEnv->OutputTree().Root(), true );
190 pCurPageEnv->Set_CurFile( C_sCssFilename_Idl );
192 StreamLock
193 slCurFilePath(700);
194 pCurPageEnv->Get_CurFilePath(slCurFilePath());
196 csv::File
197 aCssFile(slCurFilePath().c_str(), csv::CFM_CREATE);
198 csv::OpenCloseGuard
199 aOpenGuard(aCssFile);
200 if (NOT aOpenGuard)
202 Cerr() << "Can't create file " << slCurFilePath().c_str() << "." << Endl();
203 return;
206 aCssFile.write("/* Autodoc css file for IDL documentation */\n\n\n");
207 aCssFile.write(pCurPageEnv->Layout().CssStyle());
208 aCssFile.write("\n\n\n");
209 aCssFile.write(pCurPageEnv->Layout().CssStylesExplanation());