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