1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hdimpl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 // NOT FULLY DEFINED SERVICES
38 #include <ary/ceslot.hxx>
39 #include <ary/qualiname.hxx>
40 #include <ary/cpp/c_class.hxx>
41 #include <ary/cpp/c_de.hxx>
42 #include <ary/cpp/c_enum.hxx>
43 #include <ary/cpp/c_funct.hxx>
44 #include <ary/cpp/c_gate.hxx>
45 #include <ary/cpp/cp_ce.hxx>
46 #include <udm/html/htmlitem.hxx>
47 #include "cre_link.hxx"
48 #include "hd_docu.hxx"
49 #include "html_kit.hxx"
50 #include "opageenv.hxx"
51 #include "pagemake.hxx"
52 #include "strconst.hxx"
58 //******************** HtmlDisplay_Impl *********************//
60 HtmlDisplay_Impl::~HtmlDisplay_Impl()
64 HtmlDisplay_Impl::HtmlDisplay_Impl( OuputPage_Environment
& io_rEnv
)
71 //******************** Free Functions *********************//
79 DisplaySlot( ary::Display
& o_rDisplay
,
80 const ary::AryGroup
& i_rGroup
,
81 ary::SlotAccessId i_nSlot
)
83 ary::Slot_AutoPtr
pSlot( i_rGroup
.Create_Slot(i_nSlot
) );
84 pSlot
->StoreAt( o_rDisplay
);
89 PathUp( uintt i_nLevels
)
91 static char sResult
[300];
94 for ( uintt lev
= 0; lev
< i_nLevels
; ++lev
)
96 strcat( sResult
, "../"); // SAFE STRCAT (#100211# - checked)
102 PathPerLevelsUp( uintt i_nLevels
,
103 const char * i_nPathBelowDestinationLevel
)
105 static char sResult
[500];
106 strcpy( sResult
, PathUp(i_nLevels
) ); // SAFE STRCPY (#100211# - checked)
107 // KORR_FUTURE: Make it still safer here:
108 strcat( sResult
, i_nPathBelowDestinationLevel
); // SAFE STRCAT (#100211# - checked)
114 PathPerRoot( const OuputPage_Environment
& i_rEnv
,
115 const char * i_sPathFromRootDir
)
117 return PathPerLevelsUp( i_rEnv
.Depth(), i_sPathFromRootDir
);
121 PathPerNamespace( const OuputPage_Environment
& i_rEnv
,
122 const char * i_sPathFromNamespaceDir
)
124 const ary::cpp::Namespace
* pNsp
= i_rEnv
.CurNamespace();
128 uintt nCount
= i_rEnv
.Depth() - (pNsp
->Depth() + 1) ;
129 csv_assert( nCount
< 100 );
130 return PathPerLevelsUp( nCount
, i_sPathFromNamespaceDir
);
134 HtmlFileName( const char * i_sPrefix
,
135 const char * i_sEntityName
)
137 // KORR_FUTURE: Make it still safer here:
138 static char sResult
[300];
139 strcpy( sResult
, i_sPrefix
); // SAFE STRCPY (#100211# - checked)
140 strcat( sResult
, i_sEntityName
); // SAFE STRCAT (#100211# - checked)
141 strcat( sResult
, ".html" ); // SAFE STRCAT (#100211# - checked)
146 Path2Class( uintt i_nLevelsUp
,
147 const char * i_sClassLocalName
)
149 return PathPerLevelsUp( i_nLevelsUp
, ClassFileName(i_sClassLocalName
) );
153 Path2Child( const char * i_sFileName
,
154 const char * i_sSubDir
)
156 static char sResult
[400];
157 if ( i_sSubDir
!= 0 )
159 // KORR_FUTURE: Make it still safer here:
160 strcpy( sResult
, i_sSubDir
); // SAFE STRCPY (#100211# - checked)
161 strcat( sResult
, "/" ); // SAFE STRCAT (#100211# - checked)
168 strcat( sResult
, i_sFileName
); // SAFE STRCAT (#100211# - checked)
173 Path2ChildNamespace( const char * i_sLocalName
)
175 return Path2Child( C_sHFN_Namespace
, i_sLocalName
);
179 OperationLink( const ary::cpp::Gate
& ,
180 const String
& i_sOpName
,
181 ary::cpp::Ce_id i_nOpId
,
182 const char * i_sPrePath
)
187 sResult
= slResult();
198 return sResult
.c_str();
202 DataLink( const String
& i_sLocalName
,
203 const char * i_sPrePath
)
208 sResult
= slResult();
215 return sResult
.c_str();
219 Get_LinkedTypeText( csi::xml::Element
& o_rOut
,
220 const OuputPage_Environment
& i_rEnv
,
221 ary::cpp::Type_id i_nId
,
222 bool i_bWithAbsolutifier
)
224 if (NOT i_nId
.IsValid())
227 const char * sPreName
= "";
228 const char * sName
= "";
229 const char * sPostName
= "";
231 bool bTypeExists
= Get_TypeText( sPreName
,
236 if ( NOT bTypeExists
)
239 if ( NOT i_bWithAbsolutifier AND
strncmp(sPreName
,"::",2) == 0 )
242 const ary::cpp::CodeEntity
*
243 pCe
= i_rEnv
.Gate().Search_RelatedCe(i_nId
);
248 sLink
= Link2Ce(i_rEnv
,*pCe
);
252 if ( strstr(sPreName
,"com::sun::star") != 0 )
254 static StreamStr
aLink(400);
256 aLink
<< PathPerRoot(i_rEnv
, "../../common/ref");
257 if ( *sPreName
!= ':' )
259 for ( const char * s
= sPreName
;
275 sLink
= aLink
.c_str();
277 } // endif( pCe != 0 )
282 o_Goon
= sLink
.length() > 0
283 ? o_rOut
>> * new html::Link( sLink
.c_str() )
292 Create_ChildListLabel( csi::xml::Element
& o_rParentElement
,
293 const char * i_sLabel
)
295 if ( NOT
csv::no_str(i_sLabel
) )
298 >> *new html::Label(i_sLabel
)
303 DYN
csi::html::Table
&
304 Create_ChildListTable( const char * i_sTitle
)
307 dpTable
= new html::Table
;
309 << new html::ClassAttr( "childlist")
310 << new xml::AnAttribute( "border", "1" )
311 << new xml::AnAttribute( "cellpadding", "5" )
312 << new xml::AnAttribute( "cellspacing", "0" )
313 << new html::WidthAttr( "100%" );
316 rRow
= dpTable
->AddRow();
318 << new html::ClassAttr("subtitle")
319 >> *new html::TableCell
320 << new xml::AnAttribute( "colspan","2" )
321 >> *new html::Headline(4)
327 Link2Ce( const OuputPage_Environment
& i_rEnv
,
328 const ary::cpp::CodeEntity
& i_rCe
)
332 static char sLink
[nMaxSize
];
333 static LinkCreator
aLinkCreator( &sLink
[0], nMaxSize
);
336 aLinkCreator
.SetEnv(i_rEnv
);
337 i_rCe
.Accept(aLinkCreator
);
343 Link2CppDefinition( const OuputPage_Environment
& i_rEnv
,
344 const ary::cpp::DefineEntity
& i_rDef
)
348 static char sLink
[nMaxSize
];
349 static LinkCreator
aLinkCreator( &sLink
[0], nMaxSize
);
352 aLinkCreator
.SetEnv(i_rEnv
);
353 i_rDef
.Accept(aLinkCreator
);
358 const ary::cpp::CodeEntity
*
359 FindUnambiguousCe( const OuputPage_Environment
& i_rEnv
,
360 const ary::QualifiedName
& i_rQuName
,
361 const ary::cpp::Class
* i_pJustDocumentedClass
)
363 if ( i_rEnv
.CurNamespace() == 0 )
366 const ary::cpp::CodeEntity
* ret
= 0;
368 if ( NOT i_rQuName
.IsQualified() )
370 if ( i_pJustDocumentedClass
!= 0 )
371 ret
= i_rEnv
.Gate().Ces().Search_CeLocal( i_rQuName
.LocalName(),
372 i_rQuName
.IsFunction(),
373 *i_rEnv
.CurNamespace(),
374 i_pJustDocumentedClass
);
378 ret
= i_rEnv
.Gate().Ces().Search_CeLocal( i_rQuName
.LocalName(),
379 i_rQuName
.IsFunction(),
380 *i_rEnv
.CurNamespace(),
386 return i_rEnv
.Gate().Ces().Search_CeAbsolute( *i_rEnv
.CurNamespace(),
391 ShowDocu_On( csi::xml::Element
& o_rOut
,
392 Docu_Display
& io_rDisplay
,
393 const ary::cpp::CppEntity
& i_rRE
)
395 if (i_rRE
.Docu().Data() != 0)
397 io_rDisplay
.Assign_Out( o_rOut
);
398 io_rDisplay
.Process(i_rRE
.Docu());
399 io_rDisplay
.Unassign_Out();
404 WriteOut_TokenList( csi::xml::Element
& o_rOut
,
405 const StringVector
& i_rTokens
,
406 const char * i_sSeparator
)
408 if ( i_rTokens
.size() > 0 )
410 StringVector::const_iterator
411 it
= i_rTokens
.begin();
412 StringVector::const_iterator
413 itEnd
= i_rTokens
.end();
416 for ( ++it
; it
!= itEnd
; ++it
)
418 o_rOut
<< i_sSeparator
<< *it
;
425 EraseLeadingSpace( String
& io_rStr
)
427 if ( *io_rStr
.c_str() < 33 AND io_rStr
.length() > 0 )
429 const unsigned char * pNew
;
430 for ( pNew
= (const unsigned char * ) io_rStr
.c_str();
431 *pNew
< 33 AND
*pNew
!= 0;
433 String
sNew( (const char*)pNew
);
439 WriteOut_LinkedFunctionText( csi::xml::Element
& o_rTitleOut
,
440 adcdisp::ParameterTable
& o_rParameters
,
441 const ary::cpp::Function
& i_rFunction
,
442 const OuputPage_Environment
& i_rEnv
,
444 bool * o_bIsVirtual
)
447 const ary::cpp::FunctionFlags
& rFlags
= i_rFunction
.Flags();
448 if ( rFlags
.IsStaticLocal() OR rFlags
.IsStaticMember() )
449 o_rTitleOut
<< "static ";
450 if ( rFlags
.IsExplicit() )
451 o_rTitleOut
<< "explicit ";
452 if ( rFlags
.IsMutable() )
453 o_rTitleOut
<< "mutable ";
454 if ( i_rFunction
.Virtuality() != ary::cpp::VIRTUAL_none
)
455 o_rTitleOut
<< "virtual ";
456 // o_rTitleOut << new html::LineBreak;
458 Get_LinkedTypeText( o_rTitleOut
, i_rEnv
, i_rFunction
.ReturnType() );
464 << i_rFunction
.LocalName();
469 csi::xml::Element
* pOutLast
= &o_rTitleOut
;
472 FunctionParam_Iterator fit
;
473 fit
.Assign(i_rFunction
);
477 o_rParameters
.AddEntry();
478 Get_LinkedTypeText( o_rParameters
.Type(), i_rEnv
, fit
.CurType() );
479 o_rParameters
.Type() << " ";
480 o_rParameters
.Name() << " " << fit
.CurName();
482 for ( ++fit
; fit
; ++fit
)
484 o_rParameters
.Name() << ",";
485 o_rParameters
.AddEntry();
486 Get_LinkedTypeText( o_rParameters
.Type(), i_rEnv
, fit
.CurType() );
487 o_rParameters
.Name() << fit
.CurName();
490 pOutLast
= &o_rParameters
.Name();
491 o_rParameters
.Name() << " ";
495 if ( fit
.IsFunctionConst() )
497 *pOutLast
<< " const";
498 if ( o_bIsConst
!= 0 )
501 if ( fit
.IsFunctionVolatile() )
503 *pOutLast
<< " volatile";
504 if ( o_bIsVirtual
!= 0 )
505 *o_bIsVirtual
= true;
509 const std::vector
< ary::cpp::Type_id
> *
510 pThrow
= i_rFunction
.Exceptions();
513 std::vector
< ary::cpp::Type_id
>::const_iterator
514 it
= pThrow
->begin();
515 std::vector
< ary::cpp::Type_id
>::const_iterator
516 it_end
= pThrow
->end();
520 o_rParameters
.AddEntry();
521 pOutLast
= &o_rParameters
.Name();
523 o_rParameters
.Name() << " throw( ";
524 Get_LinkedTypeText(o_rParameters
.Name(), i_rEnv
, *it
);
526 for ( ++it
; it
!= it_end
; ++it
)
528 o_rParameters
.Name() << ", ";
529 Get_LinkedTypeText(o_rParameters
.Name(), i_rEnv
, *it
);
531 o_rParameters
.Name() << " )";
535 *pOutLast
<< " throw()";
540 if ( i_rFunction
.Virtuality() == ary::cpp::VIRTUAL_abstract
)
549 } // namespace dshelp