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 <toolkit/hf_linachain.hxx>
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <toolkit/out_position.hxx>
28 
29 
30 
HF_LinkedNameChain(Xml::Element & o_rOut)31 HF_LinkedNameChain::HF_LinkedNameChain( Xml::Element & o_rOut )
32     :   HtmlMaker( o_rOut
33                         >> *new Html::Paragraph
34                             << new Html::ClassAttr("namechain") )
35 {
36 }
37 
~HF_LinkedNameChain()38 HF_LinkedNameChain::~HF_LinkedNameChain()
39 {
40 }
41 
42 void
Produce_CompleteChain(const output::Position & i_curPosition,F_LinkMaker i_linkMaker) const43 HF_LinkedNameChain::Produce_CompleteChain( const output::Position & i_curPosition,
44 										   F_LinkMaker              i_linkMaker ) const
45 {
46     produce_Level(i_curPosition.RelatedNode(), i_curPosition, i_linkMaker);
47 }
48 
49 void
Produce_CompleteChain_forModule(const output::Position & i_curPosition,F_LinkMaker i_linkMaker) const50 HF_LinkedNameChain::Produce_CompleteChain_forModule( const output::Position &  i_curPosition,
51 													 F_LinkMaker               i_linkMaker ) const
52 {
53 	if (i_curPosition.Depth() == 0)
54 		return;
55     produce_Level(*i_curPosition.RelatedNode().Parent(), i_curPosition, i_linkMaker);
56 }
57 
58 
59 
60 namespace
61 {
62 
63 StreamStr aLinkBuf(200);
64 
65 }
66 
67 void
produce_Level(output::Node & i_levelNode,const output::Position & i_startPosition,F_LinkMaker i_linkMaker) const68 HF_LinkedNameChain::produce_Level( output::Node &           i_levelNode,
69 								   const output::Position & i_startPosition,
70 								   F_LinkMaker              i_linkMaker ) const
71 {
72     if ( i_levelNode.Depth() > 0 )
73     {
74         produce_Level( *i_levelNode.Parent(),
75                        i_startPosition,
76                        i_linkMaker );
77     }
78 
79     aLinkBuf.reset();
80 
81     String
82         sFileName = (*i_linkMaker)(i_levelNode.Name());
83     output::Position
84         aLevelPos(i_levelNode, sFileName);
85 
86     i_startPosition.Get_LinkTo(aLinkBuf, aLevelPos);
87 
88     if ( i_levelNode.Depth() > 0 )
89     {
90         CurOut()
91         >> *new Html::Link(aLinkBuf.c_str())
92             << new Html::ClassAttr("namechain")
93             << i_levelNode.Name();
94         CurOut() << " :: ";
95     }
96     else
97     {
98         CurOut()
99         >> *new Html::Link(aLinkBuf.c_str())
100             << new Html::ClassAttr("namechain")
101             << "::";
102         CurOut() << " ";
103     }
104 }
105