1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <precomp.h>
23 #include "hfi_doc.hxx"
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_ce.hxx>
28 #include <ary/doc/d_oldidldocu.hxx>
29 #include <ary_i/d_token.hxx>
30 #include <toolkit/hf_docentry.hxx>
31 #include "hfi_tag.hxx"
32 #include "hi_ary.hxx"
33 
34 
35 
36 
HF_IdlDocu(Environment & io_rEnv,HF_DocEntryList & o_rOut)37 HF_IdlDocu::HF_IdlDocu( Environment &       io_rEnv,
38                         HF_DocEntryList &   o_rOut )
39     :   HtmlFactory_Idl( io_rEnv, &o_rOut.CurOut() ),
40         rOut(o_rOut)
41 {
42 }
43 
~HF_IdlDocu()44 HF_IdlDocu::~HF_IdlDocu()
45 {
46 }
47 
48 void
Produce_fromCodeEntity(const client & i_ce) const49 HF_IdlDocu::Produce_fromCodeEntity( const client & i_ce ) const
50 {
51     const ce_info *
52         i_pDocu = Get_IdlDocu(i_ce.Docu());
53     if (i_pDocu != 0)
54         Produce_byDocuAndScope(*i_pDocu, &i_ce, i_ce);
55 }
56 
57 void
Produce_fromReference(const ce_info & i_rDocuForReference,const client & i_rScopeGivingCe) const58 HF_IdlDocu::Produce_fromReference( const ce_info &   i_rDocuForReference,
59                                    const client &    i_rScopeGivingCe ) const
60 {
61     Produce_byDocuAndScope(i_rDocuForReference, 0, i_rScopeGivingCe );
62 }
63 
64 void
Produce_byDocuAndScope(const ce_info & i_rDocu,const client * i_pClient,const client & i_rScopeGivingCe) const65 HF_IdlDocu::Produce_byDocuAndScope( const ce_info & i_rDocu,
66 									const client *  i_pClient,
67 									const client &  i_rScopeGivingCe ) const
68 {
69     bool bShort = NOT i_rDocu.Short().IsEmpty();
70     bool bDescr = NOT i_rDocu.Description().IsEmpty();
71 
72     if ( i_rDocu.IsDeprecated()
73 	     OR (
74              (i_pClient != 0 ? i_pClient->SightLevel() == ary::idl::sl_File : false)
75 	         AND NOT i_rDocu.IsPublished()
76             )
77 	     OR i_rDocu.IsOptional() )
78     {   // any usage restriction
79         rOut.Produce_Term("Usage Restrictions");
80 
81         if ( i_rDocu.IsDeprecated() )
82             rOut.Produce_Definition() >> *new Html::Italic << "deprecated";
83         if ( (i_pClient != 0 ? i_pClient->SightLevel() == ary::idl::sl_File : false)
84              AND NOT i_rDocu.IsPublished() )
85             rOut.Produce_Definition() >> *new Html::Italic << "not published";
86         if ( i_rDocu.IsOptional() )
87             rOut.Produce_Definition() >> *new Html::Italic << "optional";
88 
89         if ( i_rDocu.IsDeprecated() AND
90              // KORR_FUTURE
91              // Workaround, because DocuTex2::IsEmpty() does not
92              //   calculate whitespace tokens only as empty.
93              i_rDocu.DeprecatedText().Tokens().size() > 1 )
94         {
95             rOut.Produce_Term("Deprecation Info");
96 
97             HF_IdlDocuTextDisplay
98                 aDescription( Env(), 0, i_rScopeGivingCe);
99             aDescription.Out().Enter( rOut.Produce_Definition() );
100             i_rDocu.DeprecatedText().DisplayAt( aDescription );
101             aDescription.Out().Leave();
102         }
103     }   // end if (<any usage restriction>)
104 
105     if ( bShort OR bDescr )
106     {
107         rOut.Produce_Term("Description");
108         HF_IdlDocuTextDisplay
109                 aDescription( Env(), 0, i_rScopeGivingCe);
110         if (bShort)
111         {
112             aDescription.Out().Enter( rOut.Produce_Definition() );
113             i_rDocu.Short().DisplayAt( aDescription );
114             aDescription.Out().Leave();
115         }
116         if (bDescr)
117         {
118             aDescription.Out().Enter( rOut.Produce_Definition() );
119             i_rDocu.Description().DisplayAt( aDescription );
120             aDescription.Out().Leave();
121         }
122     }
123 
124     std::vector< csi::dsapi::DT_SeeAlsoAtTag* >
125         aSeeAlsosWithoutText;
126     std::vector< csi::dsapi::DT_SeeAlsoAtTag* >
127         aSeeAlsosWithText;
128 
129     for ( std::vector< ary::inf::AtTag2* >::const_iterator
130                 iter = i_rDocu.Tags().begin();
131           iter != i_rDocu.Tags().end();
132           ++iter )
133     {
134         csi::dsapi::DT_SeeAlsoAtTag*
135             pSeeAlso = dynamic_cast< csi::dsapi::DT_SeeAlsoAtTag * >(*iter);
136         if (pSeeAlso != 0 )
137         {
138             if ( pSeeAlso->Text().IsEmpty() )
139             {
140                 aSeeAlsosWithoutText.push_back(pSeeAlso);
141             }
142             else
143             {
144                 aSeeAlsosWithText.push_back(pSeeAlso);
145             }
146             continue;
147         }
148 
149         if ( strlen( (*iter)->Title() ) > 0 )
150         {
151             HF_IdlTag
152                     aTag(Env(), i_rScopeGivingCe);
153             Xml::Element &
154                 rTerm = rOut.Produce_Term();
155             aTag.Produce_byData( rTerm,
156                                  rOut.Produce_Definition(),
157                                  *(*iter) );
158         }
159     }   // end for
160 
161     if (aSeeAlsosWithoutText.size() > 0)
162     {
163         HF_IdlTag
164             aSeeAlsoTag(Env(),  i_rScopeGivingCe);
165         Xml::Element &
166             rTerm = rOut.Produce_Term();
167         aSeeAlsoTag.Produce_byData( rTerm,
168                                     rOut.Produce_Definition(),
169                                     aSeeAlsosWithoutText );
170     }
171 
172     for ( std::vector< csi::dsapi::DT_SeeAlsoAtTag* >::const_iterator
173                 itSee2 = aSeeAlsosWithText.begin();
174           itSee2 != aSeeAlsosWithText.end();
175           ++itSee2 )
176     {
177         HF_IdlTag
178             aTag(Env(),  i_rScopeGivingCe);
179         Xml::Element &
180             rTerm = rOut.Produce_Term();
181             aTag.Produce_byData( rTerm,
182                                  rOut.Produce_Definition(),
183                                  *(*itSee2) );
184     }   // end for
185 }
186