1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include "hi_factory.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
33*cdf0e10cSrcweir #include <ary/idl/i_ce.hxx>
34*cdf0e10cSrcweir #include <toolkit/hf_title.hxx>
35*cdf0e10cSrcweir #include "hfi_doc.hxx"
36*cdf0e10cSrcweir #include "hfi_navibar.hxx"
37*cdf0e10cSrcweir #include "hfi_tag.hxx"
38*cdf0e10cSrcweir #include "hfi_typetext.hxx"
39*cdf0e10cSrcweir #include "hi_linkhelper.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir extern const String
43*cdf0e10cSrcweir     C_sCellStyle_SummaryLeft("imsum_left");
44*cdf0e10cSrcweir extern const String
45*cdf0e10cSrcweir     C_sCellStyle_SummaryRight("imsum_right");
46*cdf0e10cSrcweir extern const String
47*cdf0e10cSrcweir     C_sCellStyle_MDetail("imdetail");
48*cdf0e10cSrcweir extern const String
49*cdf0e10cSrcweir     C_sMemberTitle("membertitle");
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir const char C_sSpace[92] = "                              "
56*cdf0e10cSrcweir                           "                              "
57*cdf0e10cSrcweir                           "                               ";
58*cdf0e10cSrcweir }
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir void
62*cdf0e10cSrcweir HtmlFactory_Idl::produce_SummaryDeclaration( Xml::Element &      o_row,
63*cdf0e10cSrcweir 											 const client &      i_ce ) const
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     produce_InternalLink(o_row, i_ce);
66*cdf0e10cSrcweir }
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir void
69*cdf0e10cSrcweir HtmlFactory_Idl::produce_InternalLink( Xml::Element &  o_screen,
70*cdf0e10cSrcweir                                        const client &  i_ce ) const
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir     StreamLock aLocalLink(100);
73*cdf0e10cSrcweir     aLocalLink() << "#" << i_ce.LocalName();
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir     o_screen
76*cdf0e10cSrcweir         >> *new Html::TableCell
77*cdf0e10cSrcweir             << new Html::ClassAttr( C_sCellStyle_SummaryLeft )
78*cdf0e10cSrcweir             >> *new Html::Link( aLocalLink().c_str() )
79*cdf0e10cSrcweir                 << i_ce.LocalName();
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir void
83*cdf0e10cSrcweir HtmlFactory_Idl::produce_ShortDoc( Xml::Element &   o_screen,
84*cdf0e10cSrcweir                                    const client &   i_ce ) const
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir     Xml::Element &
87*cdf0e10cSrcweir         rDetailsRowCell = o_screen
88*cdf0e10cSrcweir                             >> *new Html::TableCell
89*cdf0e10cSrcweir                                 << new Html::ClassAttr( C_sCellStyle_SummaryRight );
90*cdf0e10cSrcweir     HF_IdlShortDocu
91*cdf0e10cSrcweir         aLinkDoc(Env(), rDetailsRowCell);
92*cdf0e10cSrcweir     aLinkDoc.Produce_byData( i_ce );
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     rDetailsRowCell << new Xml::XmlCode("&nbsp;");
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir // KORR_FUTURE: Does not belong here (implementation inheritance)!
98*cdf0e10cSrcweir void
99*cdf0e10cSrcweir HtmlFactory_Idl::produce_Bases( Xml::Element &   o_screen,
100*cdf0e10cSrcweir                                 const client &   i_ce,
101*cdf0e10cSrcweir                                 const String &   i_sLabel ) const
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir     ary::idl::Type_id nBaseT = baseOf(i_ce);
104*cdf0e10cSrcweir     if ( nBaseT.IsValid() )
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         HF_DocEntryList
107*cdf0e10cSrcweir             aDocList( o_screen );
108*cdf0e10cSrcweir         aDocList.Produce_Term(i_sLabel);
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         int nDepth = 0;
111*cdf0e10cSrcweir         Xml::Element &
112*cdf0e10cSrcweir             rBaseList = aDocList.Produce_Definition()
113*cdf0e10cSrcweir                                 >> *new Xml::AnElement("pre")
114*cdf0e10cSrcweir                                     << new Xml::AnAttribute("style","font-family:monospace;");
115*cdf0e10cSrcweir         rBaseList
116*cdf0e10cSrcweir             >> *new Html::Strong
117*cdf0e10cSrcweir                 << i_ce.LocalName();
118*cdf0e10cSrcweir         rBaseList
119*cdf0e10cSrcweir             << "\n";
120*cdf0e10cSrcweir         recursive_ShowBases( rBaseList,
121*cdf0e10cSrcweir                              nBaseT,
122*cdf0e10cSrcweir                              nDepth );
123*cdf0e10cSrcweir     }
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir void
127*cdf0e10cSrcweir HtmlFactory_Idl::produce_Members( ce_list &               it_list,
128*cdf0e10cSrcweir                                   const String &          i_summaryTitle,
129*cdf0e10cSrcweir                                   const String &          i_summaryLabel,
130*cdf0e10cSrcweir                                   const String &          i_detailsTitle,
131*cdf0e10cSrcweir                                   const String &          i_detailsLabel,
132*cdf0e10cSrcweir                                   const E_MemberViewType  i_viewType ) const
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir     csv_assert( it_list );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     Dyn< HF_SubTitleTable > pSummary;
137*cdf0e10cSrcweir     if  (   ( i_viewType == viewtype_summary )
138*cdf0e10cSrcweir         ||  ( i_viewType == viewtype_complete )
139*cdf0e10cSrcweir         )
140*cdf0e10cSrcweir     {
141*cdf0e10cSrcweir         pSummary = new HF_SubTitleTable(
142*cdf0e10cSrcweir                 CurOut(),
143*cdf0e10cSrcweir                 i_summaryLabel,
144*cdf0e10cSrcweir                 i_summaryTitle,
145*cdf0e10cSrcweir                 2 );
146*cdf0e10cSrcweir     }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     Dyn< HF_SubTitleTable > pDetails;
149*cdf0e10cSrcweir     if  (   ( i_viewType == viewtype_details )
150*cdf0e10cSrcweir         ||  ( i_viewType == viewtype_complete )
151*cdf0e10cSrcweir         )
152*cdf0e10cSrcweir     {
153*cdf0e10cSrcweir         pDetails = new HF_SubTitleTable(
154*cdf0e10cSrcweir                 CurOut(),
155*cdf0e10cSrcweir                 i_detailsLabel,
156*cdf0e10cSrcweir                 i_detailsTitle,
157*cdf0e10cSrcweir                 1 );
158*cdf0e10cSrcweir     }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     for ( ; it_list.operator bool(); ++it_list )
161*cdf0e10cSrcweir     {
162*cdf0e10cSrcweir         const ary::idl::CodeEntity &
163*cdf0e10cSrcweir             rCe = Env().Data().Find_Ce(*it_list);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         if ( pSummary )
166*cdf0e10cSrcweir         {
167*cdf0e10cSrcweir             Xml::Element &
168*cdf0e10cSrcweir                 rSummaryRow = pSummary->Add_Row();
169*cdf0e10cSrcweir             produce_SummaryDeclaration(rSummaryRow, rCe);
170*cdf0e10cSrcweir //            produce_InternalLink(rSummaryRow, rCe);
171*cdf0e10cSrcweir             produce_ShortDoc(rSummaryRow, rCe);
172*cdf0e10cSrcweir         }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir         if ( pDetails )
175*cdf0e10cSrcweir             produce_MemberDetails(*pDetails, rCe);
176*cdf0e10cSrcweir     }
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir void
180*cdf0e10cSrcweir HtmlFactory_Idl::produce_Title( HF_TitleTable &     o_title,
181*cdf0e10cSrcweir                                 const String &      i_label,
182*cdf0e10cSrcweir                                 const client &      i_ce ) const
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     StreamLock
185*cdf0e10cSrcweir         slAnnotations(200);
186*cdf0e10cSrcweir     get_Annotations(slAnnotations(), i_ce);
187*cdf0e10cSrcweir     StreamLock
188*cdf0e10cSrcweir         slTitle(200);
189*cdf0e10cSrcweir     slTitle() << i_label << " " << i_ce.LocalName();
190*cdf0e10cSrcweir     o_title.Produce_Title( slAnnotations().c_str(),
191*cdf0e10cSrcweir                            slTitle().c_str() );
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir void
195*cdf0e10cSrcweir HtmlFactory_Idl::get_Annotations( StreamStr &         o_out,
196*cdf0e10cSrcweir                                   const client &      i_ce ) const
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir     const ary::doc::OldIdlDocu *
199*cdf0e10cSrcweir         doc = Get_IdlDocu(i_ce.Docu());
200*cdf0e10cSrcweir     if (doc != 0)
201*cdf0e10cSrcweir     {
202*cdf0e10cSrcweir         if (doc->IsDeprecated())
203*cdf0e10cSrcweir             o_out << "deprecated ";
204*cdf0e10cSrcweir         if (NOT doc->IsPublished())
205*cdf0e10cSrcweir             o_out << "unpublished ";
206*cdf0e10cSrcweir     }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     // KORR
209*cdf0e10cSrcweir     //  Need to display "unpublished", if there is no docu.
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir void
213*cdf0e10cSrcweir HtmlFactory_Idl::write_Docu( Xml::Element &     o_screen,
214*cdf0e10cSrcweir                              const client &     i_ce ) const
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir     const ary::doc::OldIdlDocu *
217*cdf0e10cSrcweir         doc = Get_IdlDocu(i_ce.Docu());
218*cdf0e10cSrcweir     if (doc != 0)
219*cdf0e10cSrcweir     {
220*cdf0e10cSrcweir         HF_DocEntryList
221*cdf0e10cSrcweir             aDocuList( o_screen );
222*cdf0e10cSrcweir         HF_IdlDocu
223*cdf0e10cSrcweir             aDocu( Env(), aDocuList );
224*cdf0e10cSrcweir         aDocu.Produce_fromCodeEntity(i_ce);
225*cdf0e10cSrcweir     }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     write_ManualLinks(o_screen, i_ce);
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir void
231*cdf0e10cSrcweir HtmlFactory_Idl::write_ManualLinks( Xml::Element &  o_screen,
232*cdf0e10cSrcweir                                     const client &  i_ce ) const
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir     const StringVector &
235*cdf0e10cSrcweir         rLinks2Descrs = i_ce.Secondaries().Links2DescriptionInManual();
236*cdf0e10cSrcweir     if ( rLinks2Descrs.size() == 0 )
237*cdf0e10cSrcweir         return;
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     o_screen
240*cdf0e10cSrcweir         >> *new Html::Label(C_sLocalManualLinks.c_str()+1)  // Leave out the leading '#'.
241*cdf0e10cSrcweir             << " ";
242*cdf0e10cSrcweir     HF_DocEntryList
243*cdf0e10cSrcweir         aDocuList( o_screen );
244*cdf0e10cSrcweir     aDocuList.Produce_Term("Developers Guide");
245*cdf0e10cSrcweir     csv_assert(rLinks2Descrs.size() % 2 == 0);
246*cdf0e10cSrcweir     for ( StringVector::const_iterator it = rLinks2Descrs.begin();
247*cdf0e10cSrcweir           it != rLinks2Descrs.end();
248*cdf0e10cSrcweir           ++it )
249*cdf0e10cSrcweir     {
250*cdf0e10cSrcweir         Xml::Element &
251*cdf0e10cSrcweir             rLink = aDocuList.Produce_Definition() >> *new Html::Link( Env().Link2Manual(*it));
252*cdf0e10cSrcweir         if ( (*(it+1)).empty() )
253*cdf0e10cSrcweir             // HACK KORR_FUTURE
254*cdf0e10cSrcweir             // Research what happens with manual links which contain normal characters
255*cdf0e10cSrcweir             // in non-utf-8 texts. And research, why utfF-8 does not work here.
256*cdf0e10cSrcweir             rLink << new Xml::XmlCode(*it);
257*cdf0e10cSrcweir         else
258*cdf0e10cSrcweir             rLink << new Xml::XmlCode( *(it+1) );
259*cdf0e10cSrcweir         ++it;
260*cdf0e10cSrcweir     }   // end for
261*cdf0e10cSrcweir }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir void
264*cdf0e10cSrcweir HtmlFactory_Idl::produce_MemberDetails(  HF_SubTitleTable &  ,
265*cdf0e10cSrcweir                                          const client &      ) const
266*cdf0e10cSrcweir {
267*cdf0e10cSrcweir     // Dummy, which does not need to do anything.
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir void
271*cdf0e10cSrcweir HtmlFactory_Idl::recursive_ShowBases( Xml::Element &     o_screen,
272*cdf0e10cSrcweir                                       type_id            i_baseType,
273*cdf0e10cSrcweir                                       int &              io_nDepth ) const
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir     // Show this base
276*cdf0e10cSrcweir     ++io_nDepth;
277*cdf0e10cSrcweir     const ary::idl::CodeEntity *
278*cdf0e10cSrcweir         pCe = Env().Linker().Search_CeFromType(i_baseType);
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir     csv_assert(io_nDepth > 0);
281*cdf0e10cSrcweir     if (io_nDepth > 30)
282*cdf0e10cSrcweir         io_nDepth = 30;
283*cdf0e10cSrcweir     o_screen
284*cdf0e10cSrcweir         << (C_sSpace + 93 - 3*io_nDepth)
285*cdf0e10cSrcweir         << new csi::xml::XmlCode("&#x2517")
286*cdf0e10cSrcweir         << " ";
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir     if (pCe == 0)
289*cdf0e10cSrcweir     {
290*cdf0e10cSrcweir         HF_IdlTypeText
291*cdf0e10cSrcweir             aText( Env(), o_screen, false );
292*cdf0e10cSrcweir         aText.Produce_byData( i_baseType );
293*cdf0e10cSrcweir         o_screen
294*cdf0e10cSrcweir             << "\n";
295*cdf0e10cSrcweir         --io_nDepth;
296*cdf0e10cSrcweir         return;
297*cdf0e10cSrcweir     }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     HF_IdlTypeText
300*cdf0e10cSrcweir         aBaseLink( Env(), o_screen, true );
301*cdf0e10cSrcweir     aBaseLink.Produce_byData(pCe->CeId());
302*cdf0e10cSrcweir     o_screen
303*cdf0e10cSrcweir         << "\n";
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir     // Bases
306*cdf0e10cSrcweir     ary::idl::Type_id
307*cdf0e10cSrcweir         nBaseT = baseOf(*pCe);
308*cdf0e10cSrcweir     if (nBaseT.IsValid())
309*cdf0e10cSrcweir         recursive_ShowBases(o_screen,nBaseT,io_nDepth);
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     --io_nDepth;
312*cdf0e10cSrcweir     return;
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir HtmlFactory_Idl::type_id
316*cdf0e10cSrcweir HtmlFactory_Idl::inq_BaseOf( const client & ) const
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir     // Unused dummy.
319*cdf0e10cSrcweir     return type_id(0);
320*cdf0e10cSrcweir }
321*cdf0e10cSrcweir 
322