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 "hfi_hierarchy.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
33*cdf0e10cSrcweir #include <udm/html/htmlitem.hxx>
34*cdf0e10cSrcweir #include <ary/stdconstiter.hxx>
35*cdf0e10cSrcweir #include <ary/idl/i_ce.hxx>
36*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
37*cdf0e10cSrcweir #include <ary/idl/i_type.hxx>
38*cdf0e10cSrcweir #include <ary/idl/ik_interface.hxx>
39*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
40*cdf0e10cSrcweir #include <ary/idl/ip_type.hxx>
41*cdf0e10cSrcweir #include "hfi_interface.hxx"
42*cdf0e10cSrcweir #include "hfi_typetext.hxx"
43*cdf0e10cSrcweir #include "hi_env.hxx"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir HF_IdlBaseNode::HF_IdlBaseNode( const TYPE &            i_rType,
48*cdf0e10cSrcweir 								const GATE &            i_rGate,
49*cdf0e10cSrcweir 								intt                    i_nPositionOffset,
50*cdf0e10cSrcweir 								HF_IdlBaseNode &        io_rDerived )
51*cdf0e10cSrcweir     :   nType(i_rType.TypeId()),
52*cdf0e10cSrcweir         aBases(),
53*cdf0e10cSrcweir         nCountBases(0),
54*cdf0e10cSrcweir         nPosition(i_nPositionOffset),
55*cdf0e10cSrcweir         pDerived(&io_rDerived)
56*cdf0e10cSrcweir {
57*cdf0e10cSrcweir     Ce_id nCe = i_rGate.Types().Search_CeRelatedTo(nType);
58*cdf0e10cSrcweir     if (nCe.IsValid())
59*cdf0e10cSrcweir     {
60*cdf0e10cSrcweir         GatherBases(i_rGate.Ces().Find_Ce(nCe), i_rGate);
61*cdf0e10cSrcweir     }
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir HF_IdlBaseNode::~HF_IdlBaseNode()
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir }
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir void
69*cdf0e10cSrcweir HF_IdlBaseNode::FillPositionList( std::vector< const HF_IdlBaseNode* > & o_rPositionList ) const
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir     for ( BaseList::const_iterator it = aBases.begin();
72*cdf0e10cSrcweir           it != aBases.end();
73*cdf0e10cSrcweir           ++it )
74*cdf0e10cSrcweir     {
75*cdf0e10cSrcweir         (*it)->FillPositionList(o_rPositionList);
76*cdf0e10cSrcweir     }  // end for
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     o_rPositionList.push_back(this);
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir void
82*cdf0e10cSrcweir HF_IdlBaseNode::GatherBases( const CE &       i_rCe,
83*cdf0e10cSrcweir 							 const GATE &     i_rGate )
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir     ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
86*cdf0e10cSrcweir         aHelp;
87*cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Bases(aHelp,i_rCe);
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *aHelp;
90*cdf0e10cSrcweir           it.operator bool();
91*cdf0e10cSrcweir           ++it )
92*cdf0e10cSrcweir     {
93*cdf0e10cSrcweir         const TYPE &
94*cdf0e10cSrcweir             rBaseType = i_rGate.Types().Find_Type((*it).Type());
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir         Dyn<HF_IdlBaseNode>
97*cdf0e10cSrcweir             pBaseNode( new HF_IdlBaseNode( rBaseType,
98*cdf0e10cSrcweir 										   i_rGate,
99*cdf0e10cSrcweir 										   nPosition,
100*cdf0e10cSrcweir 										   *this )
101*cdf0e10cSrcweir                      );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir         intt nAddedBases = pBaseNode->BaseCount() + 1;
104*cdf0e10cSrcweir         nCountBases += nAddedBases;
105*cdf0e10cSrcweir         nPosition += nAddedBases;
106*cdf0e10cSrcweir         aBases.push_back( pBaseNode.Release() );
107*cdf0e10cSrcweir     }   // end for
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir void
112*cdf0e10cSrcweir Write_BaseHierarchy( csi::xml::Element &            o_rOut,
113*cdf0e10cSrcweir                      HtmlEnvironment_Idl &          i_env,
114*cdf0e10cSrcweir                      const ary::idl::CodeEntity &   i_ce )
115*cdf0e10cSrcweir {
116*cdf0e10cSrcweir     csi::xml::Element &
117*cdf0e10cSrcweir         rPre = o_rOut
118*cdf0e10cSrcweir                >> *new csi::xml::AnElement("pre")
119*cdf0e10cSrcweir                    << new csi::html::StyleAttr("font-family:monospace;");
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     std::vector<uintt>
122*cdf0e10cSrcweir         aSetColumns;
123*cdf0e10cSrcweir     rPre
124*cdf0e10cSrcweir         >> *new csi::html::Strong
125*cdf0e10cSrcweir             << i_ce.LocalName();
126*cdf0e10cSrcweir     rPre
127*cdf0e10cSrcweir         << "\n";
128*cdf0e10cSrcweir     Write_Bases( rPre,
129*cdf0e10cSrcweir                  i_env,
130*cdf0e10cSrcweir                  i_ce,
131*cdf0e10cSrcweir                          aSetColumns );
132*cdf0e10cSrcweir     rPre
133*cdf0e10cSrcweir         << "\n";
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir void
139*cdf0e10cSrcweir Write_Bases( csi::xml::Element &            o_out,
140*cdf0e10cSrcweir              HtmlEnvironment_Idl &          i_env,
141*cdf0e10cSrcweir              const ary::idl::CodeEntity &   i_rCe,
142*cdf0e10cSrcweir              std::vector<uintt> &           io_setColumns )
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir     ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
145*cdf0e10cSrcweir         aHelp;
146*cdf0e10cSrcweir     ary::idl::ifc_interface::attr::Get_Bases(aHelp,i_rCe);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *aHelp;
149*cdf0e10cSrcweir           it.operator bool();
150*cdf0e10cSrcweir           // NO INCREMENT HERE, see below
151*cdf0e10cSrcweir         )
152*cdf0e10cSrcweir     {
153*cdf0e10cSrcweir         ary::idl::Type_id
154*cdf0e10cSrcweir             nType = (*it).Type();
155*cdf0e10cSrcweir         ++it;
156*cdf0e10cSrcweir         bool
157*cdf0e10cSrcweir             bThereComesMore = it.operator bool();
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir         ary::idl::Ce_id
160*cdf0e10cSrcweir             nCe = i_env.Gate().Types().Search_CeRelatedTo(nType);
161*cdf0e10cSrcweir         if (nCe.IsValid())
162*cdf0e10cSrcweir         {
163*cdf0e10cSrcweir             // KORR_FUTURE
164*cdf0e10cSrcweir             //   Rather check for id(!) of com::sun::star::uno::XInterface.
165*cdf0e10cSrcweir             if (i_env.Gate().Ces().Find_Ce(nCe).LocalName() == "XInterface")
166*cdf0e10cSrcweir                 continue;
167*cdf0e10cSrcweir         }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir         for (uintt i = 0; i < io_setColumns.size(); ++i)
170*cdf0e10cSrcweir         {
171*cdf0e10cSrcweir             if (io_setColumns[i] == 1)
172*cdf0e10cSrcweir                 o_out << new csi::xml::XmlCode("&#x2503");
173*cdf0e10cSrcweir             else
174*cdf0e10cSrcweir                 o_out << "  ";
175*cdf0e10cSrcweir             o_out << " ";
176*cdf0e10cSrcweir         }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         if (bThereComesMore)
179*cdf0e10cSrcweir             o_out << new csi::xml::XmlCode("&#x2523");
180*cdf0e10cSrcweir         else
181*cdf0e10cSrcweir             o_out << new csi::xml::XmlCode("&#x2517");
182*cdf0e10cSrcweir         o_out << " ";
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir         HF_IdlTypeText
185*cdf0e10cSrcweir             aDisplay( i_env, o_out, true, i_env.CurPageCe());
186*cdf0e10cSrcweir         aDisplay.Produce_byData(nType);
187*cdf0e10cSrcweir         o_out << "\n";
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         if (nCe.IsValid())
190*cdf0e10cSrcweir         {
191*cdf0e10cSrcweir             io_setColumns.push_back(bThereComesMore ? 1 : 0);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir             const ary::idl::CodeEntity &
194*cdf0e10cSrcweir                 rCe = i_env.Gate().Ces().Find_Ce(nCe);
195*cdf0e10cSrcweir             Write_Bases( o_out,
196*cdf0e10cSrcweir                          i_env,
197*cdf0e10cSrcweir                          rCe,
198*cdf0e10cSrcweir                          io_setColumns );
199*cdf0e10cSrcweir             io_setColumns.pop_back();
200*cdf0e10cSrcweir         }
201*cdf0e10cSrcweir     }   // end for
202*cdf0e10cSrcweir }
203