Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _FMTCLDS_HXX
29 : : #define _FMTCLDS_HXX
30 : :
31 : : #include <editeng/borderline.hxx>
32 : : #include <tools/color.hxx>
33 : : #include <svl/poolitem.hxx>
34 : : #include "swdllapi.h"
35 : : #include <hintids.hxx>
36 : : #include <format.hxx>
37 : : #include <boost/ptr_container/ptr_vector.hpp>
38 : :
39 : : // ColumnDescriptor
40 : : class SwColumn
41 : : {
42 : : sal_uInt16 nWish; // Desired width, borders included.
43 : : // It is inversely proportional to the ratio of
44 : : // desired width environment / current width column.
45 : : sal_uInt16 nUpper; // Top border.
46 : : sal_uInt16 nLower; // Bottom border.
47 : : sal_uInt16 nLeft; // Left border.
48 : : sal_uInt16 nRight; // Right border.
49 : :
50 : : public:
51 : : SwColumn();
52 : :
53 : : sal_Bool operator==( const SwColumn & ) const;
54 : :
55 : :
56 : 84 : void SetWishWidth( sal_uInt16 nNew ) { nWish = nNew; }
57 : : void SetUpper( sal_uInt16 nNew ) { nUpper = nNew; }
58 : : void SetLower( sal_uInt16 nNew ) { nLower = nNew; }
59 : 66 : void SetLeft ( sal_uInt16 nNew ) { nLeft = nNew; }
60 : 66 : void SetRight( sal_uInt16 nNew ) { nRight = nNew; }
61 : :
62 : 60 : sal_uInt16 GetWishWidth() const { return nWish; }
63 : 60 : sal_uInt16 GetUpper() const { return nUpper; }
64 : 60 : sal_uInt16 GetLower() const { return nLower; }
65 : 468 : sal_uInt16 GetLeft () const { return nLeft; }
66 : 468 : sal_uInt16 GetRight() const { return nRight; }
67 : : };
68 : :
69 : : typedef boost::ptr_vector<SwColumn> SwColumns;
70 : :
71 : : enum SwColLineAdj
72 : : {
73 : : COLADJ_NONE,
74 : : COLADJ_TOP,
75 : : COLADJ_CENTER,
76 : : COLADJ_BOTTOM
77 : : };
78 : :
79 : : class SW_DLLPUBLIC SwFmtCol : public SfxPoolItem
80 : : {
81 : : editeng::SvxBorderStyle eLineStyle; //style of the separator line
82 : : sal_uLong nLineWidth; // Width of the separator line.
83 : : Color aLineColor; // Color of the separator line.
84 : :
85 : : sal_uInt16 nLineHeight; // Percentile height of lines.
86 : : // (Based on height of columns including UL).
87 : :
88 : : SwColLineAdj eAdj; // Line will be adjusted top, centered or bottom.
89 : :
90 : : SwColumns aColumns; // Information concerning the columns.
91 : : sal_uInt16 nWidth; // Total desired width of all columns.
92 : :
93 : : sal_Bool bOrtho; // Only if this flag is set, the setting of GutterWidth will
94 : : // be accompanied by a "visual rearrangement".
95 : : // The flag must be reset if widths of columns or borders are changed.
96 : : // When it is set (again) the visual arrangement is recalculated.
97 : : // The flag is initially set.
98 : :
99 : : SW_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct );
100 : :
101 : : public:
102 : : SwFmtCol();
103 : : SwFmtCol( const SwFmtCol& );
104 : : ~SwFmtCol();
105 : :
106 : : SwFmtCol& operator=( const SwFmtCol& );
107 : :
108 : : // "pure virtual methods" of SfxPoolItem
109 : : virtual int operator==( const SfxPoolItem& ) const;
110 : : virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const;
111 : : virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
112 : : SfxMapUnit eCoreMetric,
113 : : SfxMapUnit ePresMetric,
114 : : String &rText,
115 : : const IntlWrapper* pIntl = 0 ) const;
116 : :
117 : : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
118 : : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
119 : :
120 : 605 : const SwColumns &GetColumns() const { return aColumns; }
121 : 18 : SwColumns &GetColumns() { return aColumns; }
122 : 3469 : sal_uInt16 GetNumCols() const { return aColumns.size(); }
123 : :
124 : 89 : editeng::SvxBorderStyle GetLineStyle() const { return eLineStyle;}
125 : 149 : sal_uLong GetLineWidth() const { return nLineWidth;}
126 : 89 : const Color& GetLineColor() const { return aLineColor;}
127 : :
128 : :
129 : 1130 : SwColLineAdj GetLineAdj() const { return eAdj; }
130 : 730 : sal_Bool IsOrtho() const { return bOrtho; }
131 : 817 : sal_uInt16 GetWishWidth() const { return nWidth; }
132 : 828 : sal_uInt8 GetLineHeight()const { return nLineHeight; }
133 : :
134 : : // Return USHRT_MAX if ambiguous.
135 : : // Return smallest width if bMin is true.
136 : : sal_uInt16 GetGutterWidth( sal_Bool bMin = sal_False ) const;
137 : :
138 : 0 : void SetLineStyle(editeng::SvxBorderStyle eStyle) { eLineStyle = eStyle;}
139 : 0 : void SetLineWidth(sal_uLong nLWidth) { nLineWidth = nLWidth;}
140 : 0 : void SetLineColor(const Color& rCol ) { aLineColor = rCol;}
141 : 0 : void SetLineHeight( sal_uInt8 nNew ) { nLineHeight = nNew; }
142 : 0 : void SetLineAdj( SwColLineAdj eNew ){ eAdj = eNew; }
143 : 9 : void SetWishWidth( sal_uInt16 nNew ) { nWidth = nNew; }
144 : :
145 : : // This function allows to (repeatedly) initialize the columns.
146 : : // The Ortho flag is set automatically.
147 : : void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
148 : :
149 : : // Adjusts borders for columns in aColumns.
150 : : // If flag bOrtho is set, columns are visually re-arranged.
151 : : // If the flag is not set, columns widths are not changed and
152 : : // borders are adjusted.
153 : : void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct );
154 : :
155 : : // This too re-arranges columns automatically if flag is set.
156 : : // Only in this case the second parameter is needed and evaluated.
157 : : void SetOrtho( sal_Bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
158 : :
159 : : //For the reader
160 : 9 : void _SetOrtho( sal_Bool bNew ) { bOrtho = bNew; }
161 : :
162 : : // Calculates current width of column nCol.
163 : : // The ratio of desired width of this column to return value is
164 : : // proportional to ratio of total desired value to nAct.
165 : : sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
166 : :
167 : : // As above except that it returns the width of PrtArea -
168 : : // that corresponds to what constitutes the column for the user.
169 : : sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
170 : : };
171 : :
172 : 1970 : inline const SwFmtCol &SwAttrSet::GetCol(sal_Bool bInP) const
173 : 1970 : { return (const SwFmtCol&)Get( RES_COL,bInP); }
174 : :
175 : 1964 : inline const SwFmtCol &SwFmt::GetCol(sal_Bool bInP) const
176 : 1964 : { return aSet.GetCol(bInP); }
177 : :
178 : : #endif
179 : :
180 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|