1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cr_index.cxx,v $
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 ************************************************************************/
32 #include "cr_index.hxx"
36 #include "../support/syshelp.hxx"
37 #include "xmltree.hxx"
39 #include "cr_html.hxx"
42 extern unsigned C_nSupportedServicesIndex
;
44 char C_sLineEnd
[] = "\n";
46 char C_sFileBegin
[] = "<HTML><HEAD></HEAD><BODY bgcolor=\"#ffffff\">\n";
47 char C_sFileEnd
[] = "</BODY></HTML>\n";
48 char C_sTableBegin
[] = "<TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=0><TBODY>\n";
49 char C_sTableEnd
[] = "</TBODY></TABLE>\n";
50 char C_sService
[] = "SupportedService";
51 char C_sModule
[] = "ModuleName";
52 char C_sComponentname
[] = "ComponentName";
59 Index::Index( const char * i_sOutputDirectory
,
60 const char * i_sIdlRootPath
,
61 const List
<Simstr
> & )
62 : aService2Module(20),
64 sOutputDirectory(i_sOutputDirectory
),
65 sIdlRootPath(i_sIdlRootPath
)
68 ::sIdlRootPath
= i_sIdlRootPath
;
76 Index::GatherData( const List
<Simstr
> & i_rInputFileList
)
78 for ( unsigned i
= 0; i
< i_rInputFileList
.size(); ++i
)
80 ReadFile( i_rInputFileList
[i
].str() );
85 Index::WriteOutput( const char * i_sOuputFile
)
87 std::ofstream
aOut( i_sOuputFile
, std::ios::out
);
90 std::cerr
<< "Error: Indexfile \""
92 << "\" could not be created."
97 WriteStr(aOut
, C_sFileBegin
);
99 WriteStr(aOut
, "<H2>Module Descriptions Index</H2>");
100 WriteStr(aOut
, C_sLineEnd
);
103 WriteTableFromHeap( aOut
, aService2Module
, C_sService
, C_sModule
, lt_html
);
104 WriteTableFromHeap( aOut
, aModule2Service
, C_sModule
, C_sService
, lt_idl
);
106 WriteStr( aOut
, C_sFileEnd
);
111 Index::InsertSupportedService( const Simstr
& i_sService
)
113 aService2Module
.InsertValue( i_sService
, sCurModule
);
114 aModule2Service
.InsertValue( sCurModule
, i_sService
);
118 Index::ReadFile( const char * i_sFilename
)
120 static char sOutputHtml
[1020];
122 ModuleDescription aModule
;
123 X2CParser
aParser(aModule
);
126 bool bResult
= aParser
.Parse(i_sFilename
);
129 std::cerr
<< "Error: File \""
131 << "\" could not be parsed."
137 CreateHtmlFileName( sOutputHtml
, aModule
);
138 HtmlCreator
aHtmlCreator( sOutputHtml
, aModule
, sIdlRootPath
);
142 sCurModule
= aModule
.ModuleName();
144 List
< const MultipleTextElement
* > aSupportedServices
;
145 aModule
.Get_SupportedServices(aSupportedServices
);
147 for ( unsigned s
= 0; s
< aSupportedServices
.size(); ++s
)
149 aSupportedServices
[s
]->Insert2Index(*this);
154 Index::CreateHtmlFileName( char * o_sOutputHtml
,
155 const ModuleDescription
& i_rModule
)
157 if ( strlen(sOutputDirectory
.str()) + strlen(i_rModule
.ModuleName()) > 1000 )
159 strcpy( o_sOutputHtml
, "too-long-filename.html"); // STRCPY SAFE HERE
163 strcpy( o_sOutputHtml
, sOutputDirectory
.str() ); // STRCPY SAFE HERE
164 #if defined(WNT) || defined(OS2)
165 strcat(o_sOutputHtml
, "\\"); // STRCAT SAFE HERE
167 strcat(o_sOutputHtml
, "/"); // STRCAT SAFE HERE
169 #error WNT or UNX have to be defined.
171 strcat( o_sOutputHtml
, i_rModule
.ModuleName() ); // STRCAT SAFE HERE
172 strcat( o_sOutputHtml
, ".html" ); // STRCAT SAFE HERE
177 Index::WriteTableFromHeap( std::ostream
& o_rOut
,
179 const char * i_sIndexValue
,
180 const char * i_sIndexReference
,
181 E_LinkType i_eLinkType
)
183 WriteStr(o_rOut
, "<H3><BR>");
184 WriteStr(o_rOut
, i_sIndexValue
);
185 WriteStr(o_rOut
, " -> ");
186 WriteStr(o_rOut
, i_sIndexReference
);
187 WriteStr(o_rOut
, "</H3>\n");
189 WriteStr(o_rOut
, C_sTableBegin
);
190 WriteHeap( o_rOut
, i_rHeap
, i_eLinkType
);
191 WriteStr(o_rOut
, C_sTableEnd
);
196 Index::WriteHeap( std::ostream
& o_rOut
,
198 E_LinkType i_eLinkType
)
200 static Simstr S_sKey
;
201 static char C_sSpaceInName
[] = " ";
205 WriteStr( o_rOut
, "<TR><TD width=33% valign=\"top\">" );
207 for ( HeapItem
* pHeapTop
= i_rHeap
.ReleaseTop();
209 pHeapTop
= i_rHeap
.ReleaseTop() )
211 if ( S_sKey
!= pHeapTop
->Key() )
213 const char * pStart
= pHeapTop
->Key().str();
214 const char * pBreak
= strstr( pStart
, " in ");
218 WriteStr( o_rOut
, "</TD></TR>\n" );
219 WriteStr( o_rOut
, "<TR><TD width=33% valign=\"top\">" );
223 WriteStr( o_rOut
, pStart
);
226 o_rOut
.write( pStart
, pBreak
- pStart
);
227 WriteStr( o_rOut
, C_sSpaceInName
);
228 WriteStr( o_rOut
, pBreak
);
230 WriteStr( o_rOut
, "</TD><TD width=66%>" );
231 S_sKey
= pHeapTop
->Key();
235 WriteStr( o_rOut
, "<BR>" );
237 WriteName( o_rOut
, sIdlRootPath
, pHeapTop
->Value(), i_eLinkType
);
241 WriteStr( o_rOut
, "</TD></TR>\n" );
246 /** Übersicht der Struktur
264 ProjectBuildDependency*
265 RuntimeModuleDependency*