Update ooo320-m1
[ooovba.git] / autodoc / source / display / idl / hi_factory.cxx
blob180c9814b27808cff77978b479084bc3554fb276
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_factory.cxx,v $
10 * $Revision: 1.16 $
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 "hi_factory.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_ce.hxx>
37 #include <toolkit/hf_title.hxx>
38 #include "hfi_doc.hxx"
39 #include "hfi_navibar.hxx"
40 #include "hfi_tag.hxx"
41 #include "hfi_typetext.hxx"
42 #include "hi_linkhelper.hxx"
45 extern const String
46 C_sCellStyle_SummaryLeft("imsum_left");
47 extern const String
48 C_sCellStyle_SummaryRight("imsum_right");
49 extern const String
50 C_sCellStyle_MDetail("imdetail");
51 extern const String
52 C_sMemberTitle("membertitle");
55 namespace
58 const char C_sSpace[92] = " "
59 " "
60 " ";
64 void
65 HtmlFactory_Idl::produce_SummaryDeclaration( Xml::Element & o_row,
66 const client & i_ce ) const
68 produce_InternalLink(o_row, i_ce);
71 void
72 HtmlFactory_Idl::produce_InternalLink( Xml::Element & o_screen,
73 const client & i_ce ) const
75 StreamLock aLocalLink(100);
76 aLocalLink() << "#" << i_ce.LocalName();
78 o_screen
79 >> *new Html::TableCell
80 << new Html::ClassAttr( C_sCellStyle_SummaryLeft )
81 >> *new Html::Link( aLocalLink().c_str() )
82 << i_ce.LocalName();
85 void
86 HtmlFactory_Idl::produce_ShortDoc( Xml::Element & o_screen,
87 const client & i_ce ) const
89 Xml::Element &
90 rDetailsRowCell = o_screen
91 >> *new Html::TableCell
92 << new Html::ClassAttr( C_sCellStyle_SummaryRight );
93 HF_IdlShortDocu
94 aLinkDoc(Env(), rDetailsRowCell);
95 aLinkDoc.Produce_byData( i_ce );
97 rDetailsRowCell << new Xml::XmlCode("&nbsp;");
100 // KORR_FUTURE: Does not belong here (implementation inheritance)!
101 void
102 HtmlFactory_Idl::produce_Bases( Xml::Element & o_screen,
103 const client & i_ce,
104 const String & i_sLabel ) const
106 ary::idl::Type_id nBaseT = baseOf(i_ce);
107 if ( nBaseT.IsValid() )
109 HF_DocEntryList
110 aDocList( o_screen );
111 aDocList.Produce_Term(i_sLabel);
113 int nDepth = 0;
114 Xml::Element &
115 rBaseList = aDocList.Produce_Definition()
116 >> *new Xml::AnElement("pre")
117 << new Xml::AnAttribute("style","font-family:monospace;");
118 rBaseList
119 >> *new Html::Strong
120 << i_ce.LocalName();
121 rBaseList
122 << "\n";
123 recursive_ShowBases( rBaseList,
124 nBaseT,
125 nDepth );
129 void
130 HtmlFactory_Idl::produce_Members( ce_list & it_list,
131 const String & i_summaryTitle,
132 const String & i_summaryLabel,
133 const String & i_detailsTitle,
134 const String & i_detailsLabel,
135 const E_MemberViewType i_viewType ) const
137 csv_assert( it_list );
139 Dyn< HF_SubTitleTable > pSummary;
140 if ( ( i_viewType == viewtype_summary )
141 || ( i_viewType == viewtype_complete )
144 pSummary = new HF_SubTitleTable(
145 CurOut(),
146 i_summaryLabel,
147 i_summaryTitle,
148 2 );
151 Dyn< HF_SubTitleTable > pDetails;
152 if ( ( i_viewType == viewtype_details )
153 || ( i_viewType == viewtype_complete )
156 pDetails = new HF_SubTitleTable(
157 CurOut(),
158 i_detailsLabel,
159 i_detailsTitle,
160 1 );
163 for ( ; it_list.operator bool(); ++it_list )
165 const ary::idl::CodeEntity &
166 rCe = Env().Data().Find_Ce(*it_list);
168 if ( pSummary )
170 Xml::Element &
171 rSummaryRow = pSummary->Add_Row();
172 produce_SummaryDeclaration(rSummaryRow, rCe);
173 // produce_InternalLink(rSummaryRow, rCe);
174 produce_ShortDoc(rSummaryRow, rCe);
177 if ( pDetails )
178 produce_MemberDetails(*pDetails, rCe);
182 void
183 HtmlFactory_Idl::produce_Title( HF_TitleTable & o_title,
184 const String & i_label,
185 const client & i_ce ) const
187 StreamLock
188 slAnnotations(200);
189 get_Annotations(slAnnotations(), i_ce);
190 StreamLock
191 slTitle(200);
192 slTitle() << i_label << " " << i_ce.LocalName();
193 o_title.Produce_Title( slAnnotations().c_str(),
194 slTitle().c_str() );
197 void
198 HtmlFactory_Idl::get_Annotations( StreamStr & o_out,
199 const client & i_ce ) const
201 const ary::doc::OldIdlDocu *
202 doc = Get_IdlDocu(i_ce.Docu());
203 if (doc != 0)
205 if (doc->IsDeprecated())
206 o_out << "deprecated ";
207 if (NOT doc->IsPublished())
208 o_out << "unpublished ";
211 // KORR
212 // Need to display "unpublished", if there is no docu.
215 void
216 HtmlFactory_Idl::write_Docu( Xml::Element & o_screen,
217 const client & i_ce ) const
219 const ary::doc::OldIdlDocu *
220 doc = Get_IdlDocu(i_ce.Docu());
221 if (doc != 0)
223 HF_DocEntryList
224 aDocuList( o_screen );
225 HF_IdlDocu
226 aDocu( Env(), aDocuList );
227 aDocu.Produce_byDocu4Reference(*doc, i_ce);
230 write_ManualLinks(o_screen, i_ce);
233 void
234 HtmlFactory_Idl::write_ManualLinks( Xml::Element & o_screen,
235 const client & i_ce ) const
237 const StringVector &
238 rLinks2Descrs = i_ce.Secondaries().Links2DescriptionInManual();
239 if ( rLinks2Descrs.size() == 0 )
240 return;
242 o_screen
243 >> *new Html::Label(C_sLocalManualLinks.c_str()+1) // Leave out the leading '#'.
244 << " ";
245 HF_DocEntryList
246 aDocuList( o_screen );
247 aDocuList.Produce_Term("Developers Guide");
248 csv_assert(rLinks2Descrs.size() % 2 == 0);
249 for ( StringVector::const_iterator it = rLinks2Descrs.begin();
250 it != rLinks2Descrs.end();
251 ++it )
253 Xml::Element &
254 rLink = aDocuList.Produce_Definition() >> *new Html::Link( Env().Link2Manual(*it));
255 if ( (*(it+1)).empty() )
256 // HACK KORR_FUTURE
257 // Research what happens with manual links which contain normal characters
258 // in non-utf-8 texts. And research, why utfF-8 does not work here.
259 rLink << new Xml::XmlCode(*it);
260 else
261 rLink << new Xml::XmlCode( *(it+1) );
262 ++it;
263 } // end for
266 void
267 HtmlFactory_Idl::produce_MemberDetails( HF_SubTitleTable & ,
268 const client & ) const
270 // Dummy, which does not need to do anything.
273 void
274 HtmlFactory_Idl::recursive_ShowBases( Xml::Element & o_screen,
275 type_id i_baseType,
276 int & io_nDepth ) const
278 // Show this base
279 ++io_nDepth;
280 const ary::idl::CodeEntity *
281 pCe = Env().Linker().Search_CeFromType(i_baseType);
283 csv_assert(io_nDepth > 0);
284 if (io_nDepth > 30)
285 io_nDepth = 30;
286 o_screen
287 << (C_sSpace + 93 - 3*io_nDepth)
288 << new csi::xml::XmlCode("&#x2517")
289 << " ";
291 if (pCe == 0)
293 HF_IdlTypeText
294 aText( Env(), o_screen, false );
295 aText.Produce_byData( i_baseType );
296 o_screen
297 << "\n";
298 --io_nDepth;
299 return;
302 HF_IdlTypeText
303 aBaseLink( Env(), o_screen, true );
304 aBaseLink.Produce_byData(pCe->CeId());
305 o_screen
306 << "\n";
308 // Bases
309 ary::idl::Type_id
310 nBaseT = baseOf(*pCe);
311 if (nBaseT.IsValid())
312 recursive_ShowBases(o_screen,nBaseT,io_nDepth);
314 --io_nDepth;
315 return;
318 HtmlFactory_Idl::type_id
319 HtmlFactory_Idl::inq_BaseOf( const client & ) const
321 // Unused dummy.
322 return type_id(0);