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 
23 
24 #ifndef LAYOUT_CORE_TABLE_HXX
25 #define LAYOUT_CORE_TABLE_HXX
26 
27 #include <layout/core/box-base.hxx>
28 
29 namespace layoutimpl
30 {
31 
32 class Table : public Box_Base
33 {
34 public:
35     // Children properties
36     struct ChildData : public Box_Base::ChildData
37     {
38         sal_Bool mbExpand[ 2 ];
39         sal_Int32 mnColSpan;
40         sal_Int32 mnRowSpan;
41         int mnLeftCol;
42         int mnRightCol;
43         int mnTopRow;
44         int mnBottomRow;
45 
46         ChildData( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild );
47         bool isVisible();
48     };
49 
50     struct ChildProps : public Box_Base::ChildProps
51     {
52         ChildProps( ChildData *pData );
53     };
54 
55 protected:
56 
57     // a group of children; either a column or a row
58     struct GroupData
59     {
60         sal_Bool mbExpand;
61         int mnSize;  // request size (width or height)
GroupDatalayoutimpl::Table::GroupData62         GroupData() : mbExpand( false ), mnSize( 0 ) {}
63     };
64 
65     // Table properties
66     sal_Int32 mnColsLen;
67     std::vector< GroupData > maCols;
68     std::vector< GroupData > maRows;
69     int mnColExpandables, mnRowExpandables;
70 
71     ChildData *createChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild );
72     ChildProps *createChildProps( Box_Base::ChildData* pData );
73 
74 public:
75     Table();
76 
77     // css::awt::XLayoutContainer
78     virtual void SAL_CALL addChild( const css::uno::Reference< css::awt::XLayoutConstrains >& Child )
79         throw (css::uno::RuntimeException, css::awt::MaxChildrenException);
80 
81     virtual void SAL_CALL allocateArea( const css::awt::Rectangle &rArea )
82         throw (css::uno::RuntimeException);
83 
84     virtual css::awt::Size SAL_CALL getMinimumSize()
85         throw(css::uno::RuntimeException);
86 
87     // unimplemented:
hasHeightForWidth()88     virtual sal_Bool SAL_CALL hasHeightForWidth()
89         throw(css::uno::RuntimeException)
90     { return false; }
getHeightForWidth(sal_Int32)91     virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 /*nWidth*/ )
92     throw(css::uno::RuntimeException)
93     { return maRequisition.Height; }
94 };
95 
96 } //  namespace layoutimpl
97 
98 #endif /* LAYOUT_CORE_TABLE_HXX */
99