xref: /aoo41x/main/sw/source/ui/frmdlg/colmgr.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "hintids.hxx"
30cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "frmmgr.hxx"
33cdf0e10cSrcweir #include "frmfmt.hxx"
34cdf0e10cSrcweir #include "colmgr.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir // PRIVATE METHODES ------------------------------------------------------
38cdf0e10cSrcweir /*------------------------------------------------------------------------
39cdf0e10cSrcweir  Beschreibung:	Spaltenbreite auf aktuelle Breite einstellen
40cdf0e10cSrcweir ------------------------------------------------------------------------*/
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
FitToActualSize(SwFmtCol & rCol,sal_uInt16 nWidth)44cdf0e10cSrcweir void FitToActualSize(SwFmtCol& rCol, sal_uInt16 nWidth)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	const sal_uInt16 nCount = rCol.GetColumns().Count();
47cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < nCount; ++i)
48cdf0e10cSrcweir 	{
49cdf0e10cSrcweir 		const sal_uInt16 nTmp = rCol.CalcColWidth(i, nWidth);
50cdf0e10cSrcweir 		rCol.GetColumns()[i]->SetWishWidth(nTmp);
51cdf0e10cSrcweir 	}
52cdf0e10cSrcweir 	rCol.SetWishWidth(nWidth);
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // PUBLIC METHODES -------------------------------------------------------
57cdf0e10cSrcweir /*------------------------------------------------------------------------
58cdf0e10cSrcweir  Beschreibung:	Setzen Spaltenanzahl und Gutterwidth
59cdf0e10cSrcweir ------------------------------------------------------------------------*/
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
SetCount(sal_uInt16 nCount,sal_uInt16 nGutterWidth)63cdf0e10cSrcweir void SwColMgr::SetCount(sal_uInt16 nCount, sal_uInt16  nGutterWidth)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	aFmtCol.Init(nCount, nGutterWidth, nWidth);
66cdf0e10cSrcweir 	aFmtCol.SetWishWidth(nWidth);
67cdf0e10cSrcweir 	aFmtCol.SetGutterWidth(nGutterWidth, nWidth);
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
GetGutterWidth(sal_uInt16 nPos) const72cdf0e10cSrcweir sal_uInt16 SwColMgr::GetGutterWidth( sal_uInt16 nPos ) const
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	sal_uInt16 nRet;
75cdf0e10cSrcweir 	if(nPos == USHRT_MAX )
76cdf0e10cSrcweir 		nRet = GetCount() > 1 ? aFmtCol.GetGutterWidth() : DEF_GUTTER_WIDTH;
77cdf0e10cSrcweir 	else
78cdf0e10cSrcweir 	{
79cdf0e10cSrcweir 		DBG_ASSERT(nPos < GetCount() - 1, "Spalte ueberindiziert" );
80cdf0e10cSrcweir 		const SwColumns& rCols = aFmtCol.GetColumns();
81cdf0e10cSrcweir 		nRet = rCols.GetObject(nPos)->GetRight() + rCols.GetObject(nPos + 1)->GetLeft();
82cdf0e10cSrcweir 	}
83cdf0e10cSrcweir 	return nRet;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir /*-----------------22.10.96 14.28-------------------
87cdf0e10cSrcweir 
88cdf0e10cSrcweir --------------------------------------------------*/
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
SetGutterWidth(sal_uInt16 nGutterWidth,sal_uInt16 nPos)91cdf0e10cSrcweir void SwColMgr::SetGutterWidth(sal_uInt16 nGutterWidth, sal_uInt16 nPos )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	if(nPos == USHRT_MAX)
94cdf0e10cSrcweir 		aFmtCol.SetGutterWidth(nGutterWidth, nWidth);
95cdf0e10cSrcweir 	else
96cdf0e10cSrcweir 	{
97cdf0e10cSrcweir 		DBG_ASSERT(nPos < GetCount() - 1, "Spalte ueberindiziert" );
98cdf0e10cSrcweir 		SwColumns& rCols = aFmtCol.GetColumns();
99cdf0e10cSrcweir 		sal_uInt16 nGutterWidth2 = nGutterWidth / 2;
100cdf0e10cSrcweir 		rCols.GetObject(nPos)->SetRight(nGutterWidth2);
101cdf0e10cSrcweir 		rCols.GetObject(nPos + 1)->SetLeft(nGutterWidth2);
102cdf0e10cSrcweir 	}
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir /*------------------------------------------------------------------------
106cdf0e10cSrcweir  Beschreibung:	Hoehe Trennlinie
107cdf0e10cSrcweir ------------------------------------------------------------------------*/
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
GetLineHeightPercent() const111cdf0e10cSrcweir short SwColMgr::GetLineHeightPercent() const
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	return (short)aFmtCol.GetLineHeight();
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
SetLineHeightPercent(short nPercent)118cdf0e10cSrcweir void SwColMgr::SetLineHeightPercent(short nPercent)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	ASSERT(nPercent <= 100, LineHeight darf nur bis 100 % gross  sein);
121cdf0e10cSrcweir 	aFmtCol.SetLineHeight((sal_uInt8)nPercent);
122cdf0e10cSrcweir }
123cdf0e10cSrcweir /*------------------------------------------------------------------------
124cdf0e10cSrcweir  Beschreibung:	Spaltenbreite
125cdf0e10cSrcweir ------------------------------------------------------------------------*/
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 
GetColWidth(sal_uInt16 nIdx) const129cdf0e10cSrcweir sal_uInt16 SwColMgr::GetColWidth(sal_uInt16 nIdx) const
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	ASSERT(nIdx < GetCount(), Spaltenarray ueberindiziert.);
132cdf0e10cSrcweir 	return aFmtCol.CalcPrtColWidth(nIdx, nWidth);
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
SetColWidth(sal_uInt16 nIdx,sal_uInt16 nWd)137cdf0e10cSrcweir void SwColMgr::SetColWidth(sal_uInt16 nIdx, sal_uInt16 nWd)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir 	ASSERT(nIdx < GetCount(), Spaltenarray ueberindiziert.);
140cdf0e10cSrcweir 	aFmtCol.GetColumns()[nIdx]->SetWishWidth(nWd);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir /*--------------------------------------------------------------------
145cdf0e10cSrcweir 	Beschreibung: 	Groesse neu setzen
146cdf0e10cSrcweir  --------------------------------------------------------------------*/
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 
SetActualWidth(sal_uInt16 nW)150cdf0e10cSrcweir void SwColMgr::SetActualWidth(sal_uInt16 nW)
151cdf0e10cSrcweir {
152cdf0e10cSrcweir 	nWidth = nW;
153cdf0e10cSrcweir 	::FitToActualSize(aFmtCol, nW);
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir /*--------------------------------------------------------------------
157cdf0e10cSrcweir 	Beschreibung: ctor
158cdf0e10cSrcweir  --------------------------------------------------------------------*/
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 
SwColMgr(const SfxItemSet & rSet,sal_uInt16 nActWidth)162cdf0e10cSrcweir SwColMgr::SwColMgr(const SfxItemSet& rSet, sal_uInt16 nActWidth) :
163cdf0e10cSrcweir 	aFmtCol((const SwFmtCol&)rSet.Get(RES_COL)),
164cdf0e10cSrcweir 	nWidth(nActWidth)
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	if(nWidth == USHRT_MAX)
167cdf0e10cSrcweir 	{
168cdf0e10cSrcweir 		nWidth = (sal_uInt16)((const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE)).GetWidth();
169cdf0e10cSrcweir 		if (nWidth < MINLAY)
170cdf0e10cSrcweir 			nWidth = USHRT_MAX;
171cdf0e10cSrcweir 		const SvxLRSpaceItem &rLR = (const SvxLRSpaceItem&)rSet.Get(RES_LR_SPACE);
172cdf0e10cSrcweir         nWidth = nWidth - (sal_uInt16)rLR.GetLeft();
173cdf0e10cSrcweir         nWidth = nWidth - (sal_uInt16)rLR.GetRight();
174cdf0e10cSrcweir 	}
175cdf0e10cSrcweir 	::FitToActualSize(aFmtCol, nWidth);
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
~SwColMgr()181cdf0e10cSrcweir SwColMgr::~SwColMgr() {}
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
188