xref: /AOO41X/main/autodoc/source/display/idl/hfi_hierarchy.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "hfi_hierarchy.hxx"
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <udm/html/htmlitem.hxx>
34 #include <ary/stdconstiter.hxx>
35 #include <ary/idl/i_ce.hxx>
36 #include <ary/idl/i_gate.hxx>
37 #include <ary/idl/i_type.hxx>
38 #include <ary/idl/ik_interface.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/idl/ip_type.hxx>
41 #include "hfi_interface.hxx"
42 #include "hfi_typetext.hxx"
43 #include "hi_env.hxx"
44 
45 
46 
47 HF_IdlBaseNode::HF_IdlBaseNode( const TYPE &            i_rType,
48 								const GATE &            i_rGate,
49 								intt                    i_nPositionOffset,
50 								HF_IdlBaseNode &        io_rDerived )
51     :   nType(i_rType.TypeId()),
52         aBases(),
53         nCountBases(0),
54         nPosition(i_nPositionOffset),
55         pDerived(&io_rDerived)
56 {
57     Ce_id nCe = i_rGate.Types().Search_CeRelatedTo(nType);
58     if (nCe.IsValid())
59     {
60         GatherBases(i_rGate.Ces().Find_Ce(nCe), i_rGate);
61     }
62 }
63 
64 HF_IdlBaseNode::~HF_IdlBaseNode()
65 {
66 }
67 
68 void
69 HF_IdlBaseNode::FillPositionList( std::vector< const HF_IdlBaseNode* > & o_rPositionList ) const
70 {
71     for ( BaseList::const_iterator it = aBases.begin();
72           it != aBases.end();
73           ++it )
74     {
75         (*it)->FillPositionList(o_rPositionList);
76     }  // end for
77 
78     o_rPositionList.push_back(this);
79 }
80 
81 void
82 HF_IdlBaseNode::GatherBases( const CE &       i_rCe,
83 							 const GATE &     i_rGate )
84 {
85     ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
86         aHelp;
87     ary::idl::ifc_interface::attr::Get_Bases(aHelp,i_rCe);
88 
89     for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *aHelp;
90           it.operator bool();
91           ++it )
92     {
93         const TYPE &
94             rBaseType = i_rGate.Types().Find_Type((*it).Type());
95 
96         Dyn<HF_IdlBaseNode>
97             pBaseNode( new HF_IdlBaseNode( rBaseType,
98 										   i_rGate,
99 										   nPosition,
100 										   *this )
101                      );
102 
103         intt nAddedBases = pBaseNode->BaseCount() + 1;
104         nCountBases += nAddedBases;
105         nPosition += nAddedBases;
106         aBases.push_back( pBaseNode.Release() );
107     }   // end for
108 }
109 
110 
111 void
112 Write_BaseHierarchy( csi::xml::Element &            o_rOut,
113                      HtmlEnvironment_Idl &          i_env,
114                      const ary::idl::CodeEntity &   i_ce )
115 {
116     csi::xml::Element &
117         rPre = o_rOut
118                >> *new csi::xml::AnElement("pre")
119                    << new csi::html::StyleAttr("font-family:monospace;");
120 
121     std::vector<uintt>
122         aSetColumns;
123     rPre
124         >> *new csi::html::Strong
125             << i_ce.LocalName();
126     rPre
127         << "\n";
128     Write_Bases( rPre,
129                  i_env,
130                  i_ce,
131                          aSetColumns );
132     rPre
133         << "\n";
134 
135 }
136 
137 
138 void
139 Write_Bases( csi::xml::Element &            o_out,
140              HtmlEnvironment_Idl &          i_env,
141              const ary::idl::CodeEntity &   i_rCe,
142              std::vector<uintt> &           io_setColumns )
143 {
144     ary::Dyn_StdConstIterator<ary::idl::CommentedRelation>
145         aHelp;
146     ary::idl::ifc_interface::attr::Get_Bases(aHelp,i_rCe);
147 
148     for ( ary::StdConstIterator<ary::idl::CommentedRelation> & it = *aHelp;
149           it.operator bool();
150           // NO INCREMENT HERE, see below
151         )
152     {
153         ary::idl::Type_id
154             nType = (*it).Type();
155         ++it;
156         bool
157             bThereComesMore = it.operator bool();
158 
159         ary::idl::Ce_id
160             nCe = i_env.Gate().Types().Search_CeRelatedTo(nType);
161         if (nCe.IsValid())
162         {
163             // KORR_FUTURE
164             //   Rather check for id(!) of com::sun::star::uno::XInterface.
165             if (i_env.Gate().Ces().Find_Ce(nCe).LocalName() == "XInterface")
166                 continue;
167         }
168 
169         for (uintt i = 0; i < io_setColumns.size(); ++i)
170         {
171             if (io_setColumns[i] == 1)
172                 o_out << new csi::xml::XmlCode("&#x2503");
173             else
174                 o_out << "  ";
175             o_out << " ";
176         }
177 
178         if (bThereComesMore)
179             o_out << new csi::xml::XmlCode("&#x2523");
180         else
181             o_out << new csi::xml::XmlCode("&#x2517");
182         o_out << " ";
183 
184         HF_IdlTypeText
185             aDisplay( i_env, o_out, true, i_env.CurPageCe());
186         aDisplay.Produce_byData(nType);
187         o_out << "\n";
188 
189         if (nCe.IsValid())
190         {
191             io_setColumns.push_back(bThereComesMore ? 1 : 0);
192 
193             const ary::idl::CodeEntity &
194                 rCe = i_env.Gate().Ces().Find_Ce(nCe);
195             Write_Bases( o_out,
196                          i_env,
197                          rCe,
198                          io_setColumns );
199             io_setColumns.pop_back();
200         }
201     }   // end for
202 }
203