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 "protarea.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include "hdimpl.hxx"
34 
35 
36 inline UINT8
37 ProtectionArea::Index( ary::cpp::E_ClassKey i_eClassKey ) const
38 {
39  	return i_eClassKey == ary::cpp::CK_class
40                 ?   0
41                 :   i_eClassKey == ary::cpp::CK_struct
42                         ?   1
43                         :   2;
44 }
45 
46 
47 
48 ProtectionArea::ProtectionArea( const char *        i_sLabel,
49                                 const char *        i_sTitle )
50     :   pSglTable( new S_Slot_Table(i_sTitle) ),
51         aClassesTables(),
52         sLabel(i_sLabel)
53 {
54 }
55 
56 ProtectionArea::~ProtectionArea()
57 {
58 
59 }
60 
61 csi::html::Table &
62 ProtectionArea::GetTable()
63 {
64     csv_assert(pSglTable);
65 
66     return pSglTable->GetTable();
67 }
68 
69 csi::html::Table &
70 ProtectionArea::GetTable( ary::cpp::E_ClassKey i_eClassKey )
71 {
72     csv_assert(aClassesTables[Index(i_eClassKey)]);
73     return aClassesTables[Index(i_eClassKey)]->GetTable();
74 }
75 
76 DYN csi::html::Table *
77 ProtectionArea::ReleaseTable()
78 {
79     csv_assert(pSglTable);
80     return pSglTable->ReleaseTable();
81 }
82 
83 DYN csi::html::Table *
84 ProtectionArea::ReleaseTable( ary::cpp::E_ClassKey i_eClassKey )
85 {
86     csv_assert(aClassesTables[Index(i_eClassKey)]);
87     return aClassesTables[Index(i_eClassKey)]->ReleaseTable();
88 }
89 
90 const char *
91 ProtectionArea::Label() const
92 {
93     return sLabel;
94 }
95 
96 
97 bool
98 ProtectionArea::WasUsed_Area() const
99 {
100     if ( pSglTable )
101     {
102      	return pSglTable->WasUsed();
103     }
104 
105     typedef const Dyn<ProtectionArea::S_Slot_Table> cdyntab;
106 
107     // Workaround a maybe compiler bug in Solaris5-CC ?
108     //   should normally work without the cast,
109     //   because that is exactly the genuine type, given:
110     return static_cast< cdyntab& >(aClassesTables[0])->WasUsed()
111            OR static_cast< cdyntab& >(aClassesTables[1])->WasUsed()
112            OR static_cast< cdyntab& >(aClassesTables[2])->WasUsed();
113 }
114 
115 //*******************        S_Slot_Table        **********************//
116 
117 ProtectionArea::
118 S_Slot_Table::S_Slot_Table(const char * i_sTitle)
119     :   sTableTitle(i_sTitle)
120 {
121 }
122 
123 ProtectionArea::
124 S_Slot_Table::~S_Slot_Table()
125 {
126 }
127 
128 csi::html::Table &
129 ProtectionArea::
130 S_Slot_Table::GetTable()
131 {
132     return pTable
133                 ?   *pTable
134                 :   *( pTable = &Create_ChildListTable(sTableTitle) );
135 }
136 
137 
138 
139