1efeef26fSAndrew Rist /**************************************************************
21f7882eeSmseidel *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
101f7882eeSmseidel *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
121f7882eeSmseidel *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
191f7882eeSmseidel *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include "cmdid.h"
26cdf0e10cSrcweir #include "hintids.hxx"
27cdf0e10cSrcweir #include <algorithm>
28cdf0e10cSrcweir #include <svl/eitem.hxx>
29cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
30cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
31cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
32cdf0e10cSrcweir #include <svx/pageitem.hxx>
33cdf0e10cSrcweir #include <editeng/brshitem.hxx>
34cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
35cdf0e10cSrcweir #include <vcl/bitmap.hxx>
36cdf0e10cSrcweir #include <vcl/graph.hxx>
37cdf0e10cSrcweir #include <tgrditem.hxx>
38cdf0e10cSrcweir #include <viewopt.hxx>
39cdf0e10cSrcweir #include "colex.hxx"
40cdf0e10cSrcweir #include "colmgr.hxx"
41cdf0e10cSrcweir
42*3c2c60a8Smseidel // UUUU
4356b35d86SArmin Le Grand #include <svx/unobrushitemhelper.hxx>
4456b35d86SArmin Le Grand
45cdf0e10cSrcweir /*-----------------------------------------------------------------------
46*3c2c60a8Smseidel Description: Uebernahme der aktualisierten Werte aus dem Set
47cdf0e10cSrcweir -----------------------------------------------------------------------*/
UpdateExample(const SfxItemSet & rSet)48cdf0e10cSrcweir void SwPageExample::UpdateExample( const SfxItemSet& rSet )
49cdf0e10cSrcweir {
50cdf0e10cSrcweir const SvxPageItem* pPage = 0;
51cdf0e10cSrcweir SfxItemPool* pPool = rSet.GetPool();
52cdf0e10cSrcweir sal_uInt16 nWhich = pPool->GetWhich( SID_ATTR_PAGE );
53cdf0e10cSrcweir
54cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir // Ausrichtung
57cdf0e10cSrcweir pPage = (const SvxPageItem*)&rSet.Get( nWhich );
58cdf0e10cSrcweir
59cdf0e10cSrcweir if ( pPage )
60cdf0e10cSrcweir SetUsage( pPage->GetPageUsage() );
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
63cdf0e10cSrcweir nWhich = pPool->GetWhich( SID_ATTR_PAGE_SIZE );
64cdf0e10cSrcweir
65cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir // Orientation und Size aus dem PageItem
68cdf0e10cSrcweir const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get( nWhich );
69*3c2c60a8Smseidel SetSize( rSize.GetSize() );
70cdf0e10cSrcweir }
71cdf0e10cSrcweir nWhich = RES_LR_SPACE;
72cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir // linken und rechten Rand einstellen
75cdf0e10cSrcweir const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get( nWhich );
76cdf0e10cSrcweir
77cdf0e10cSrcweir SetLeft( rLRSpace.GetLeft() );
78cdf0e10cSrcweir SetRight( rLRSpace.GetRight() );
79cdf0e10cSrcweir }
80cdf0e10cSrcweir else
81cdf0e10cSrcweir {
82cdf0e10cSrcweir SetLeft( 0 );
83cdf0e10cSrcweir SetRight( 0 );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir nWhich = RES_UL_SPACE;
87cdf0e10cSrcweir
88cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir // oberen und unteren Rand einstellen
91cdf0e10cSrcweir const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get( nWhich );
92cdf0e10cSrcweir
93cdf0e10cSrcweir SetTop( rULSpace.GetUpper() );
94cdf0e10cSrcweir SetBottom( rULSpace.GetLower() );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir else
97cdf0e10cSrcweir {
98cdf0e10cSrcweir SetTop( 0 );
99cdf0e10cSrcweir SetBottom( 0 );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir
103cdf0e10cSrcweir // Kopfzeilen-Attribute auswerten
104cdf0e10cSrcweir const SfxPoolItem* pItem;
105cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_HEADERSET),
106cdf0e10cSrcweir sal_False, &pItem ) )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
109cdf0e10cSrcweir const SfxBoolItem& rHeaderOn =
110cdf0e10cSrcweir (const SfxBoolItem&)rHeaderSet.Get( pPool->GetWhich( SID_ATTR_PAGE_ON ) );
111cdf0e10cSrcweir
112cdf0e10cSrcweir if ( rHeaderOn.GetValue() )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir const SvxSizeItem& rSize =
115cdf0e10cSrcweir (const SvxSizeItem&)rHeaderSet.Get(pPool->GetWhich(SID_ATTR_PAGE_SIZE));
116cdf0e10cSrcweir
117cdf0e10cSrcweir const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rHeaderSet.Get(
118cdf0e10cSrcweir pPool->GetWhich(SID_ATTR_ULSPACE));
119cdf0e10cSrcweir const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rHeaderSet.Get(
120cdf0e10cSrcweir pPool->GetWhich(SID_ATTR_LRSPACE));
121cdf0e10cSrcweir
122cdf0e10cSrcweir SetHdHeight( rSize.GetSize().Height() - rUL.GetLower());
123cdf0e10cSrcweir SetHdDist( rUL.GetLower() );
124cdf0e10cSrcweir SetHdLeft( rLR.GetLeft() );
125cdf0e10cSrcweir SetHdRight( rLR.GetRight() );
126cdf0e10cSrcweir SetHeader( sal_True );
12756b35d86SArmin Le Grand
128*3c2c60a8Smseidel if(SFX_ITEM_SET == rHeaderSet.GetItemState(RES_BACKGROUND))
129*3c2c60a8Smseidel {
130*3c2c60a8Smseidel // UUUU create FillAttributes from SvxBrushItem //SetHdColor(rItem.GetColor());
131*3c2c60a8Smseidel const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(RES_BACKGROUND));
132*3c2c60a8Smseidel SfxItemSet aTempSet(*rHeaderSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
133*3c2c60a8Smseidel
134*3c2c60a8Smseidel setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
135*3c2c60a8Smseidel setHeaderFillAttributes(
136*3c2c60a8Smseidel drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
137*3c2c60a8Smseidel new drawinglayer::attribute::SdrAllFillAttributesHelper(
138*3c2c60a8Smseidel aTempSet)));
139*3c2c60a8Smseidel }
14056b35d86SArmin Le Grand
141*3c2c60a8Smseidel if ( rHeaderSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir const SvxBoxItem& rItem =
144*3c2c60a8Smseidel (const SvxBoxItem&)rHeaderSet.Get( RES_BOX );
145*3c2c60a8Smseidel SetHdBorder( rItem );
146cdf0e10cSrcweir }
147*3c2c60a8Smseidel }
148cdf0e10cSrcweir else
149cdf0e10cSrcweir SetHeader( sal_False );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_FOOTERSET),
153cdf0e10cSrcweir sal_False, &pItem ) )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
156cdf0e10cSrcweir const SfxBoolItem& rFooterOn =
157cdf0e10cSrcweir (const SfxBoolItem&)rFooterSet.Get( SID_ATTR_PAGE_ON );
158cdf0e10cSrcweir
159cdf0e10cSrcweir if ( rFooterOn.GetValue() )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir const SvxSizeItem& rSize =
162cdf0e10cSrcweir (const SvxSizeItem&)rFooterSet.Get( pPool->GetWhich( SID_ATTR_PAGE_SIZE ) );
163cdf0e10cSrcweir
164cdf0e10cSrcweir const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rFooterSet.Get(
165cdf0e10cSrcweir pPool->GetWhich( SID_ATTR_ULSPACE ) );
166cdf0e10cSrcweir const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rFooterSet.Get(
167cdf0e10cSrcweir pPool->GetWhich( SID_ATTR_LRSPACE ) );
168cdf0e10cSrcweir
169cdf0e10cSrcweir SetFtHeight( rSize.GetSize().Height() - rUL.GetUpper());
170cdf0e10cSrcweir SetFtDist( rUL.GetUpper() );
171cdf0e10cSrcweir SetFtLeft( rLR.GetLeft() );
172cdf0e10cSrcweir SetFtRight( rLR.GetRight() );
173cdf0e10cSrcweir SetFooter( sal_True );
17456b35d86SArmin Le Grand
175*3c2c60a8Smseidel if( rFooterSet.GetItemState( RES_BACKGROUND ) == SFX_ITEM_SET )
176*3c2c60a8Smseidel {
177*3c2c60a8Smseidel // UUUU create FillAttributes from SvxBrushItem //SetFtColor(rItem.GetColor());
178*3c2c60a8Smseidel const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rFooterSet.Get(RES_BACKGROUND));
179*3c2c60a8Smseidel SfxItemSet aTempSet(*rFooterSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
180*3c2c60a8Smseidel
181*3c2c60a8Smseidel setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
182*3c2c60a8Smseidel setFooterFillAttributes(
183*3c2c60a8Smseidel drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
184*3c2c60a8Smseidel new drawinglayer::attribute::SdrAllFillAttributesHelper(
185*3c2c60a8Smseidel aTempSet)));
186*3c2c60a8Smseidel }
18756b35d86SArmin Le Grand
188*3c2c60a8Smseidel if( rFooterSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir const SvxBoxItem& rItem =
191*3c2c60a8Smseidel (const SvxBoxItem&)rFooterSet.Get( RES_BOX );
192*3c2c60a8Smseidel SetFtBorder( rItem );
193cdf0e10cSrcweir }
194*3c2c60a8Smseidel }
195cdf0e10cSrcweir else
196cdf0e10cSrcweir SetFooter( sal_False );
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199*3c2c60a8Smseidel if(SFX_ITEM_SET == rSet.GetItemState(RES_BACKGROUND, sal_False, &pItem))
200*3c2c60a8Smseidel {
201*3c2c60a8Smseidel // UUUU create FillAttributes from SvxBrushItem
202*3c2c60a8Smseidel const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem);
203*3c2c60a8Smseidel SfxItemSet aTempSet(*rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
204*3c2c60a8Smseidel
205*3c2c60a8Smseidel setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
206*3c2c60a8Smseidel setPageFillAttributes(
207*3c2c60a8Smseidel drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
208*3c2c60a8Smseidel new drawinglayer::attribute::SdrAllFillAttributesHelper(
209*3c2c60a8Smseidel aTempSet)));
210*3c2c60a8Smseidel }
211cdf0e10cSrcweir
212cdf0e10cSrcweir Invalidate();
213cdf0e10cSrcweir }
214cdf0e10cSrcweir /*-----------------------------------------------------------------------
215*3c2c60a8Smseidel Description:
216cdf0e10cSrcweir -----------------------------------------------------------------------*/
217cdf0e10cSrcweir
218cdf0e10cSrcweir
DrawPage(const Point & rOrg,const sal_Bool bSecond,const sal_Bool bEnabled)219cdf0e10cSrcweir void SwColExample::DrawPage( const Point& rOrg,
220cdf0e10cSrcweir const sal_Bool bSecond,
221cdf0e10cSrcweir const sal_Bool bEnabled )
222cdf0e10cSrcweir {
223*3c2c60a8Smseidel SwPageExample::DrawPage( rOrg, bSecond, bEnabled );
224*3c2c60a8Smseidel sal_uInt16 nColumnCount;
225*3c2c60a8Smseidel if( pColMgr && 0 != (nColumnCount = pColMgr->GetCount()))
226cdf0e10cSrcweir {
227cdf0e10cSrcweir long nL = GetLeft();
228cdf0e10cSrcweir long nR = GetRight();
229cdf0e10cSrcweir
230cdf0e10cSrcweir if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir // fuer gespiegelt drehen
233cdf0e10cSrcweir nL = GetRight();
234cdf0e10cSrcweir nR = GetLeft();
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237*3c2c60a8Smseidel SetFillColor( Color( COL_LIGHTGRAY ) );
238*3c2c60a8Smseidel Rectangle aRect;
239*3c2c60a8Smseidel aRect.Right() = rOrg.X() + GetSize().Width() - nR;
240*3c2c60a8Smseidel aRect.Left() = rOrg.X() + nL;
241*3c2c60a8Smseidel aRect.Top() = rOrg.Y() + GetTop()
242*3c2c60a8Smseidel + GetHdHeight() + GetHdDist();
243*3c2c60a8Smseidel aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
244*3c2c60a8Smseidel - GetFtHeight() - GetFtDist();
245*3c2c60a8Smseidel DrawRect(aRect);
246*3c2c60a8Smseidel
247*3c2c60a8Smseidel // UUUU
248*3c2c60a8Smseidel const Rectangle aDefineRect(aRect);
249*3c2c60a8Smseidel
250*3c2c60a8Smseidel // UUUU
251*3c2c60a8Smseidel const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes = getPageFillAttributes();
252*3c2c60a8Smseidel
253*3c2c60a8Smseidel if(!rFillAttributes.get() || !rFillAttributes->isUsed())
254*3c2c60a8Smseidel {
255*3c2c60a8Smseidel // UUUU If there is no fill, use fallback color
256*3c2c60a8Smseidel const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
257*3c2c60a8Smseidel const Color& rFieldColor = rStyleSettings.GetFieldColor();
258*3c2c60a8Smseidel
259*3c2c60a8Smseidel setPageFillAttributes(
260*3c2c60a8Smseidel drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
261*3c2c60a8Smseidel new drawinglayer::attribute::SdrAllFillAttributesHelper(
262*3c2c60a8Smseidel rFieldColor)));
263*3c2c60a8Smseidel }
264*3c2c60a8Smseidel
265*3c2c60a8Smseidel // #97495# make sure that the automatic column width's are always equal
266*3c2c60a8Smseidel sal_Bool bAutoWidth = pColMgr->IsAutoWidth();
267*3c2c60a8Smseidel sal_Int32 nAutoColWidth = 0;
268*3c2c60a8Smseidel if(bAutoWidth)
269*3c2c60a8Smseidel {
270*3c2c60a8Smseidel sal_Int32 nColumnWidthSum = 0;
271*3c2c60a8Smseidel sal_uInt16 i;
272*3c2c60a8Smseidel for(i = 0; i < nColumnCount; ++i)
273*3c2c60a8Smseidel nColumnWidthSum += pColMgr->GetColWidth( i );
274*3c2c60a8Smseidel nAutoColWidth = nColumnWidthSum / nColumnCount;
275*3c2c60a8Smseidel }
276*3c2c60a8Smseidel
277*3c2c60a8Smseidel sal_uInt16 i;
278*3c2c60a8Smseidel for( i = 0; i < nColumnCount; i++)
279*3c2c60a8Smseidel {
280*3c2c60a8Smseidel if(!bAutoWidth)
281*3c2c60a8Smseidel nAutoColWidth = pColMgr->GetColWidth( i );
282*3c2c60a8Smseidel aRect.Right() = aRect.Left() + nAutoColWidth;
283*3c2c60a8Smseidel
284*3c2c60a8Smseidel // UUUU use primitive draw command
285*3c2c60a8Smseidel drawFillAttributes(getPageFillAttributes(), aRect, aDefineRect);
286*3c2c60a8Smseidel
287*3c2c60a8Smseidel if(i < nColumnCount - 1)
288*3c2c60a8Smseidel aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
289*3c2c60a8Smseidel }
290*3c2c60a8Smseidel if(pColMgr->HasLine())
291*3c2c60a8Smseidel {
292*3c2c60a8Smseidel Point aUp( rOrg.X() + nL, rOrg.Y() + GetTop() );
293*3c2c60a8Smseidel Point aDown( rOrg.X() + nL, rOrg.Y() + GetSize().Height()
294*3c2c60a8Smseidel - GetBottom() - GetFtHeight() - GetFtDist() );
295*3c2c60a8Smseidel
296*3c2c60a8Smseidel if( pColMgr->GetLineHeightPercent() != 100 )
297*3c2c60a8Smseidel {
298*3c2c60a8Smseidel long nLength = aDown.Y() - aUp.Y();
299*3c2c60a8Smseidel nLength -= nLength * pColMgr->GetLineHeightPercent() / 100;
300*3c2c60a8Smseidel switch(pColMgr->GetAdjust())
301*3c2c60a8Smseidel {
302*3c2c60a8Smseidel case COLADJ_BOTTOM: aUp.Y() += nLength; break;
303*3c2c60a8Smseidel case COLADJ_TOP: aDown.Y() -= nLength; break;
304*3c2c60a8Smseidel case COLADJ_CENTER:
305*3c2c60a8Smseidel aUp.Y() += nLength / 2;
306*3c2c60a8Smseidel aDown.Y() -= nLength / 2;
307*3c2c60a8Smseidel break;
308*3c2c60a8Smseidel default:; // prevent warning
309*3c2c60a8Smseidel }
310*3c2c60a8Smseidel }
311*3c2c60a8Smseidel
312*3c2c60a8Smseidel int nDist;
313*3c2c60a8Smseidel for( i = 0; i < nColumnCount - 1; i++)
314*3c2c60a8Smseidel {
315*3c2c60a8Smseidel int nGutter = pColMgr->GetGutterWidth(i);
316*3c2c60a8Smseidel nDist = pColMgr->GetColWidth( i ) + nGutter;
317*3c2c60a8Smseidel nDist -= (i == 0) ?
318*3c2c60a8Smseidel nGutter/2 :
319*3c2c60a8Smseidel 0;
320*3c2c60a8Smseidel aUp.X() += nDist;
321*3c2c60a8Smseidel aDown.X() += nDist;
322*3c2c60a8Smseidel DrawLine( aUp, aDown );
323*3c2c60a8Smseidel
324*3c2c60a8Smseidel }
325*3c2c60a8Smseidel }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir /*-----------------25.10.96 09.15-------------------
330cdf0e10cSrcweir
331cdf0e10cSrcweir --------------------------------------------------*/
332cdf0e10cSrcweir
333cdf0e10cSrcweir
SwColumnOnlyExample(Window * pParent,const ResId & rResId)334cdf0e10cSrcweir SwColumnOnlyExample::SwColumnOnlyExample( Window* pParent, const ResId& rResId) :
335cdf0e10cSrcweir Window(pParent, rResId),
336*3c2c60a8Smseidel m_aFrmSize(1,1)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir SetMapMode( MapMode( MAP_TWIP ) );
339*3c2c60a8Smseidel m_aWinSize = GetOutputSizePixel();
340*3c2c60a8Smseidel m_aWinSize.Height() -= 4;
341*3c2c60a8Smseidel m_aWinSize.Width() -= 4;
342cdf0e10cSrcweir
343*3c2c60a8Smseidel m_aWinSize = PixelToLogic( m_aWinSize );
344cdf0e10cSrcweir
345*3c2c60a8Smseidel SetBorderStyle( WINDOW_BORDER_MONO );
346cdf0e10cSrcweir
347*3c2c60a8Smseidel m_aFrmSize = SvxPaperInfo::GetPaperSize(PAPER_A4); // DIN A4 TODO: Can we get the size of the frame here?
348*3c2c60a8Smseidel ::FitToActualSize(m_aCols, (sal_uInt16)m_aFrmSize.Width());
349cdf0e10cSrcweir
350*3c2c60a8Smseidel long nHeight = m_aFrmSize.Height();
351*3c2c60a8Smseidel Fraction aScale( m_aWinSize.Height(), nHeight );
352*3c2c60a8Smseidel MapMode aMapMode( GetMapMode() );
353*3c2c60a8Smseidel aMapMode.SetScaleX( aScale );
354*3c2c60a8Smseidel aMapMode.SetScaleY( aScale );
355*3c2c60a8Smseidel SetMapMode( aMapMode );
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
358cdf0e10cSrcweir /*-----------------25.10.96 09.16-------------------
359cdf0e10cSrcweir
360cdf0e10cSrcweir --------------------------------------------------*/
361cdf0e10cSrcweir
362cdf0e10cSrcweir
Paint(const Rectangle &)363cdf0e10cSrcweir void SwColumnOnlyExample::Paint( const Rectangle& /*rRect*/ )
364cdf0e10cSrcweir {
365*3c2c60a8Smseidel const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
366*3c2c60a8Smseidel const Color& rFieldColor = rStyleSettings.GetFieldColor();
367*3c2c60a8Smseidel const Color& rDlgColor = rStyleSettings.GetDialogColor();
368*3c2c60a8Smseidel const Color& rFieldTextColor = SwViewOption::GetFontColor();
369*3c2c60a8Smseidel Color aGrayColor(COL_LIGHTGRAY);
370*3c2c60a8Smseidel if(rFieldColor == aGrayColor)
371*3c2c60a8Smseidel aGrayColor.Invert();
372*3c2c60a8Smseidel
373*3c2c60a8Smseidel Size aLogSize(PixelToLogic(GetOutputSizePixel()));
374*3c2c60a8Smseidel Rectangle aCompleteRect(Point(0,0), aLogSize);
375*3c2c60a8Smseidel SetLineColor(rDlgColor);
376*3c2c60a8Smseidel SetFillColor(rDlgColor);
377*3c2c60a8Smseidel DrawRect(aCompleteRect);
378*3c2c60a8Smseidel
379*3c2c60a8Smseidel SetLineColor( rFieldTextColor );
380*3c2c60a8Smseidel Point aTL( (aLogSize.Width() - m_aFrmSize.Width()) / 2,
381*3c2c60a8Smseidel (aLogSize.Height() - m_aFrmSize.Height()) / 2);
382*3c2c60a8Smseidel Rectangle aRect(aTL, m_aFrmSize);
383*3c2c60a8Smseidel
384*3c2c60a8Smseidel // draw a shadow rectangle
385*3c2c60a8Smseidel // SetFillColor( Color(COL_GRAY) );
386*3c2c60a8Smseidel // Rectangle aShadowRect(aRect);
387*3c2c60a8Smseidel // aShadowRect.Move(aTL.Y(), aTL.Y());
388*3c2c60a8Smseidel // DrawRect(aShadowRect);
389*3c2c60a8Smseidel
390*3c2c60a8Smseidel SetFillColor( rFieldColor );
391*3c2c60a8Smseidel DrawRect(aRect);
392*3c2c60a8Smseidel
393*3c2c60a8Smseidel SetFillColor( aGrayColor );
394*3c2c60a8Smseidel
395*3c2c60a8Smseidel // Spaltentrenner?
396*3c2c60a8Smseidel long nLength = aLogSize.Height() - 2 * aTL.Y();
397*3c2c60a8Smseidel Point aUp( aTL );
398*3c2c60a8Smseidel Point aDown( aTL.X(), nLength );
399*3c2c60a8Smseidel sal_Bool bLines = sal_False;
400*3c2c60a8Smseidel if(m_aCols.GetLineAdj() != COLADJ_NONE)
401*3c2c60a8Smseidel {
402*3c2c60a8Smseidel bLines = sal_True;
403*3c2c60a8Smseidel
404*3c2c60a8Smseidel sal_uInt16 nPercent = m_aCols.GetLineHeight();
405*3c2c60a8Smseidel if( nPercent != 100 )
406*3c2c60a8Smseidel {
407*3c2c60a8Smseidel nLength -= nLength * nPercent / 100;
408*3c2c60a8Smseidel switch(m_aCols.GetLineAdj())
409*3c2c60a8Smseidel {
410*3c2c60a8Smseidel case COLADJ_BOTTOM: aUp.Y() += nLength; break;
411*3c2c60a8Smseidel case COLADJ_TOP: aDown.Y() -= nLength; break;
412*3c2c60a8Smseidel case COLADJ_CENTER:
413*3c2c60a8Smseidel aUp.Y() += nLength / 2;
414*3c2c60a8Smseidel aDown.Y() -= nLength / 2;
415*3c2c60a8Smseidel break;
416*3c2c60a8Smseidel default:; // prevent warning
417*3c2c60a8Smseidel }
418*3c2c60a8Smseidel }
419*3c2c60a8Smseidel
420*3c2c60a8Smseidel }
421*3c2c60a8Smseidel const SwColumns& rCols = m_aCols.GetColumns();
422*3c2c60a8Smseidel sal_uInt16 nColCount = rCols.Count();
423*3c2c60a8Smseidel if( nColCount )
424*3c2c60a8Smseidel {
425*3c2c60a8Smseidel DrawRect(aRect);
426*3c2c60a8Smseidel SetFillColor( rFieldColor );
427*3c2c60a8Smseidel Rectangle aFrmRect(aTL, m_aFrmSize);
428*3c2c60a8Smseidel long nSum = aTL.X();
429*3c2c60a8Smseidel for(sal_uInt16 i = 0; i < nColCount; i++)
430*3c2c60a8Smseidel {
431*3c2c60a8Smseidel SwColumn* pCol = rCols[i];
432*3c2c60a8Smseidel aFrmRect.Left() = nSum + pCol->GetLeft(); // nSum + pCol->GetLeft() + aTL.X();
433*3c2c60a8Smseidel nSum += pCol->GetWishWidth();
434*3c2c60a8Smseidel aFrmRect.Right() = nSum - pCol->GetRight();
435*3c2c60a8Smseidel DrawRect(aFrmRect);
436*3c2c60a8Smseidel }
437*3c2c60a8Smseidel if(bLines )
438*3c2c60a8Smseidel {
439*3c2c60a8Smseidel nSum = aTL.X();
440*3c2c60a8Smseidel for(sal_uInt16 i = 0; i < nColCount - 1; i++)
441*3c2c60a8Smseidel {
442*3c2c60a8Smseidel nSum += rCols[i]->GetWishWidth();
443*3c2c60a8Smseidel aUp.X() = nSum;
444*3c2c60a8Smseidel aDown.X() = nSum;
445*3c2c60a8Smseidel DrawLine(aUp, aDown);
446*3c2c60a8Smseidel }
447*3c2c60a8Smseidel }
448*3c2c60a8Smseidel }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
451cdf0e10cSrcweir /*-----------------25.10.96 12.05-------------------
452cdf0e10cSrcweir
453cdf0e10cSrcweir --------------------------------------------------*/
454cdf0e10cSrcweir
455cdf0e10cSrcweir
SetColumns(const SwFmtCol & rCol)456*3c2c60a8Smseidel void SwColumnOnlyExample::SetColumns(const SwFmtCol& rCol)
457cdf0e10cSrcweir {
458*3c2c60a8Smseidel m_aCols = rCol;
459*3c2c60a8Smseidel sal_uInt16 nWishSum = m_aCols.GetWishWidth();
460*3c2c60a8Smseidel long nFrmWidth = m_aFrmSize.Width();
461*3c2c60a8Smseidel SwColumns& rCols = m_aCols.GetColumns();
462*3c2c60a8Smseidel sal_uInt16 nColCount = rCols.Count();
463*3c2c60a8Smseidel
464*3c2c60a8Smseidel for(sal_uInt16 i = 0; i < nColCount; i++)
465*3c2c60a8Smseidel {
466*3c2c60a8Smseidel SwColumn* pCol = rCols[i];
467*3c2c60a8Smseidel long nWish = pCol->GetWishWidth();
468*3c2c60a8Smseidel nWish *= nFrmWidth;
469*3c2c60a8Smseidel nWish /= nWishSum;
470*3c2c60a8Smseidel pCol->SetWishWidth((sal_uInt16)nWish);
471*3c2c60a8Smseidel long nLeft = pCol->GetLeft();
472*3c2c60a8Smseidel nLeft *= nFrmWidth;
473*3c2c60a8Smseidel nLeft /= nWishSum;
474*3c2c60a8Smseidel pCol->SetLeft((sal_uInt16)nLeft);
475*3c2c60a8Smseidel long nRight = pCol->GetRight();
476*3c2c60a8Smseidel nRight *= nFrmWidth;
477*3c2c60a8Smseidel nRight /= nWishSum;
478*3c2c60a8Smseidel pCol->SetRight((sal_uInt16)nRight);
479*3c2c60a8Smseidel }
480*3c2c60a8Smseidel // #97495# make sure that the automatic column width's are always equal
481*3c2c60a8Smseidel if(nColCount && m_aCols.IsOrtho())
482*3c2c60a8Smseidel {
483*3c2c60a8Smseidel sal_Int32 nColumnWidthSum = 0;
484*3c2c60a8Smseidel sal_uInt16 i;
485*3c2c60a8Smseidel for(i = 0; i < nColCount; ++i)
486*3c2c60a8Smseidel {
487*3c2c60a8Smseidel SwColumn* pCol = rCols[i];
488*3c2c60a8Smseidel nColumnWidthSum += pCol->GetWishWidth();
489*3c2c60a8Smseidel nColumnWidthSum -= (pCol->GetRight() + pCol->GetLeft());
490*3c2c60a8Smseidel }
491*3c2c60a8Smseidel nColumnWidthSum /= nColCount;
492*3c2c60a8Smseidel for(i = 0; i < nColCount; ++i)
493*3c2c60a8Smseidel {
494*3c2c60a8Smseidel SwColumn* pCol = rCols[i];
495*3c2c60a8Smseidel pCol->SetWishWidth( static_cast< sal_uInt16 >(nColumnWidthSum + pCol->GetRight() + pCol->GetLeft()));
496*3c2c60a8Smseidel }
497*3c2c60a8Smseidel }
498cdf0e10cSrcweir }
499cdf0e10cSrcweir /* -----------------------------08.02.2002 11:44------------------------------
500cdf0e10cSrcweir
501cdf0e10cSrcweir ---------------------------------------------------------------------------*/
~SwPageGridExample()502cdf0e10cSrcweir SwPageGridExample::~SwPageGridExample()
503cdf0e10cSrcweir {
504*3c2c60a8Smseidel delete pGridItem;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir /* -----------------------------08.02.2002 11:48------------------------------
507cdf0e10cSrcweir
508cdf0e10cSrcweir ---------------------------------------------------------------------------*/
509*3c2c60a8Smseidel #define MAX_ROWS 10
510*3c2c60a8Smseidel #define MAX_LINES 15
DrawPage(const Point & rOrg,const sal_Bool bSecond,const sal_Bool bEnabled)511cdf0e10cSrcweir void SwPageGridExample::DrawPage( const Point& rOrg,
512*3c2c60a8Smseidel const sal_Bool bSecond,
513*3c2c60a8Smseidel const sal_Bool bEnabled )
514cdf0e10cSrcweir {
515*3c2c60a8Smseidel SwPageExample::DrawPage(rOrg, bSecond, bEnabled);
516*3c2c60a8Smseidel if(pGridItem && pGridItem->GetGridType())
517*3c2c60a8Smseidel {
518*3c2c60a8Smseidel // paint the grid now
519*3c2c60a8Smseidel Color aLineColor = pGridItem->GetColor();
520*3c2c60a8Smseidel if(aLineColor.GetColor() == COL_AUTO)
521*3c2c60a8Smseidel {
522*3c2c60a8Smseidel aLineColor = GetFillColor();
523*3c2c60a8Smseidel aLineColor.Invert();
524*3c2c60a8Smseidel }
525*3c2c60a8Smseidel SetLineColor(aLineColor);
526*3c2c60a8Smseidel long nL = GetLeft();
527cdf0e10cSrcweir long nR = GetRight();
528cdf0e10cSrcweir
529cdf0e10cSrcweir if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir // fuer gespiegelt drehen
532cdf0e10cSrcweir nL = GetRight();
533cdf0e10cSrcweir nR = GetLeft();
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536*3c2c60a8Smseidel Rectangle aRect;
537cdf0e10cSrcweir aRect.Right() = rOrg.X() + GetSize().Width() - nR;
538cdf0e10cSrcweir aRect.Left() = rOrg.X() + nL;
539cdf0e10cSrcweir aRect.Top() = rOrg.Y() + GetTop()
540cdf0e10cSrcweir + GetHdHeight() + GetHdDist();
541cdf0e10cSrcweir aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
542cdf0e10cSrcweir - GetFtHeight() - GetFtDist();
543cdf0e10cSrcweir
544*3c2c60a8Smseidel // increase the values to get a 'viewable' preview
545*3c2c60a8Smseidel sal_Int32 nBaseHeight = pGridItem->GetBaseHeight() * 3;
546*3c2c60a8Smseidel sal_Int32 nRubyHeight = pGridItem->GetRubyHeight() * 3;
547*3c2c60a8Smseidel
548*3c2c60a8Smseidel // detect height of rectangles
549*3c2c60a8Smseidel Rectangle aRubyRect(aRect.TopLeft(),
550*3c2c60a8Smseidel m_bVertical ?
551*3c2c60a8Smseidel Size(nRubyHeight, aRect.GetHeight()) :
552*3c2c60a8Smseidel Size(aRect.GetWidth(), nRubyHeight));
553*3c2c60a8Smseidel Rectangle aCharRect(aRect.TopLeft(),
554*3c2c60a8Smseidel m_bVertical ?
555*3c2c60a8Smseidel Size(nBaseHeight, aRect.GetHeight()) :
556*3c2c60a8Smseidel Size(aRect.GetWidth(), nBaseHeight));
557*3c2c60a8Smseidel
558*3c2c60a8Smseidel sal_Int32 nLineHeight = nBaseHeight + nRubyHeight;
559*3c2c60a8Smseidel
560*3c2c60a8Smseidel // detect count of rectangles
561*3c2c60a8Smseidel sal_Int32 nLines = (m_bVertical ? aRect.GetWidth(): aRect.GetHeight()) / nLineHeight;
562*3c2c60a8Smseidel if(nLines > pGridItem->GetLines())
563*3c2c60a8Smseidel nLines = pGridItem->GetLines();
564*3c2c60a8Smseidel
565*3c2c60a8Smseidel // determine start position
566*3c2c60a8Smseidel if(m_bVertical)
567*3c2c60a8Smseidel {
568*3c2c60a8Smseidel sal_Int16 nXStart = static_cast< sal_Int16 >(aRect.GetWidth() / 2 - nLineHeight * nLines /2);
569*3c2c60a8Smseidel aRubyRect.Move(nXStart, 0);
570*3c2c60a8Smseidel aCharRect.Move(nXStart, 0);
571*3c2c60a8Smseidel }
572*3c2c60a8Smseidel else
573*3c2c60a8Smseidel {
574*3c2c60a8Smseidel sal_Int16 nYStart = static_cast< sal_Int16 >(aRect.GetHeight() / 2 - nLineHeight * nLines /2);
575*3c2c60a8Smseidel aRubyRect.Move(0, nYStart);
576*3c2c60a8Smseidel aCharRect.Move(0, nYStart);
577*3c2c60a8Smseidel }
578*3c2c60a8Smseidel
579*3c2c60a8Smseidel if(pGridItem->IsRubyTextBelow())
580*3c2c60a8Smseidel m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight);
581*3c2c60a8Smseidel else
582*3c2c60a8Smseidel m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight);
583*3c2c60a8Smseidel
584*3c2c60a8Smseidel // vertical lines
585*3c2c60a8Smseidel sal_Bool bBothLines = pGridItem->GetGridType() == GRID_LINES_CHARS;
586*3c2c60a8Smseidel SetFillColor( Color( COL_TRANSPARENT ) );
587*3c2c60a8Smseidel sal_Int32 nXMove = m_bVertical ? nLineHeight : 0;
588cdf0e10cSrcweir sal_Int32 nYMove = m_bVertical ? 0 : nLineHeight;
589cdf0e10cSrcweir for(sal_Int32 nLine = 0; nLine < nLines; nLine++)
590*3c2c60a8Smseidel {
591*3c2c60a8Smseidel DrawRect(aRubyRect);
592*3c2c60a8Smseidel DrawRect(aCharRect);
593*3c2c60a8Smseidel if(bBothLines)
594*3c2c60a8Smseidel {
595*3c2c60a8Smseidel Point aStart = aCharRect.TopLeft();
596*3c2c60a8Smseidel Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft();
597*3c2c60a8Smseidel while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
598*3c2c60a8Smseidel {
599*3c2c60a8Smseidel DrawLine(aStart, aEnd);
600*3c2c60a8Smseidel if(m_bVertical)
601*3c2c60a8Smseidel aStart.Y() = aEnd.Y() += nBaseHeight;
602*3c2c60a8Smseidel else
603*3c2c60a8Smseidel aStart.X() = aEnd.X() += nBaseHeight;
604*3c2c60a8Smseidel }
605*3c2c60a8Smseidel }
606*3c2c60a8Smseidel aRubyRect.Move(nXMove, nYMove);
607*3c2c60a8Smseidel aCharRect.Move(nXMove, nYMove);
608*3c2c60a8Smseidel }
609*3c2c60a8Smseidel }
610cdf0e10cSrcweir }
611cdf0e10cSrcweir /* -----------------------------08.02.2002 11:48------------------------------
612cdf0e10cSrcweir
613cdf0e10cSrcweir ---------------------------------------------------------------------------*/
UpdateExample(const SfxItemSet & rSet)614cdf0e10cSrcweir void SwPageGridExample::UpdateExample( const SfxItemSet& rSet )
615cdf0e10cSrcweir {
616*3c2c60a8Smseidel DELETEZ(pGridItem);
617*3c2c60a8Smseidel // get the grid information
618*3c2c60a8Smseidel if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, sal_True))
619*3c2c60a8Smseidel pGridItem = (SwTextGridItem*)((const SwTextGridItem&)rSet.Get(RES_TEXTGRID)).Clone();
620*3c2c60a8Smseidel if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR, sal_True ))
621cdf0e10cSrcweir {
622*3c2c60a8Smseidel const SvxFrameDirectionItem& rDirItem =
623*3c2c60a8Smseidel (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
624*3c2c60a8Smseidel m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
625*3c2c60a8Smseidel rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
626*3c2c60a8Smseidel }
627*3c2c60a8Smseidel SwPageExample::UpdateExample(rSet);
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
6301f7882eeSmseidel /* vim: set noet sw=4 ts=4: */
631