1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
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
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
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
4256b35d86SArmin Le Grand // UUUU
4356b35d86SArmin Le Grand #include <svx/unobrushitemhelper.hxx>
4456b35d86SArmin Le Grand
45cdf0e10cSrcweir /*-----------------------------------------------------------------------
46*309cb347Smseidel 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 );
69cdf0e10cSrcweir 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
12856b35d86SArmin Le Grand if(SFX_ITEM_SET == rHeaderSet.GetItemState(RES_BACKGROUND))
129cdf0e10cSrcweir {
13056b35d86SArmin Le Grand // UUUU create FillAttributes from SvxBrushItem //SetHdColor(rItem.GetColor());
13156b35d86SArmin Le Grand const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(RES_BACKGROUND));
13256b35d86SArmin Le Grand SfxItemSet aTempSet(*rHeaderSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
13356b35d86SArmin Le Grand
13456b35d86SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
13556b35d86SArmin Le Grand setHeaderFillAttributes(
13656b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
13756b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper(
13856b35d86SArmin Le Grand aTempSet)));
139cdf0e10cSrcweir }
14056b35d86SArmin Le Grand
141cdf0e10cSrcweir if ( rHeaderSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir const SvxBoxItem& rItem =
144cdf0e10cSrcweir (const SvxBoxItem&)rHeaderSet.Get( RES_BOX );
145cdf0e10cSrcweir SetHdBorder( rItem );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir }
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
175cdf0e10cSrcweir if( rFooterSet.GetItemState( RES_BACKGROUND ) == SFX_ITEM_SET )
176cdf0e10cSrcweir {
17756b35d86SArmin Le Grand // UUUU create FillAttributes from SvxBrushItem //SetFtColor(rItem.GetColor());
17856b35d86SArmin Le Grand const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rFooterSet.Get(RES_BACKGROUND));
17956b35d86SArmin Le Grand SfxItemSet aTempSet(*rFooterSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
18056b35d86SArmin Le Grand
18156b35d86SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
18256b35d86SArmin Le Grand setFooterFillAttributes(
18356b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
18456b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper(
18556b35d86SArmin Le Grand aTempSet)));
186cdf0e10cSrcweir }
18756b35d86SArmin Le Grand
188cdf0e10cSrcweir if( rFooterSet.GetItemState( RES_BOX ) == SFX_ITEM_SET )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir const SvxBoxItem& rItem =
191cdf0e10cSrcweir (const SvxBoxItem&)rFooterSet.Get( RES_BOX );
192cdf0e10cSrcweir SetFtBorder( rItem );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir }
195cdf0e10cSrcweir else
196cdf0e10cSrcweir SetFooter( sal_False );
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
19956b35d86SArmin Le Grand if(SFX_ITEM_SET == rSet.GetItemState(RES_BACKGROUND, sal_False, &pItem))
200cdf0e10cSrcweir {
20156b35d86SArmin Le Grand // UUUU create FillAttributes from SvxBrushItem
20256b35d86SArmin Le Grand const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem);
20356b35d86SArmin Le Grand SfxItemSet aTempSet(*rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
20456b35d86SArmin Le Grand
20556b35d86SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
20656b35d86SArmin Le Grand setPageFillAttributes(
20756b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
20856b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper(
20956b35d86SArmin Le Grand aTempSet)));
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
212cdf0e10cSrcweir Invalidate();
213cdf0e10cSrcweir }
214cdf0e10cSrcweir /*-----------------------------------------------------------------------
215*309cb347Smseidel 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 {
223cdf0e10cSrcweir SwPageExample::DrawPage( rOrg, bSecond, bEnabled );
224cdf0e10cSrcweir sal_uInt16 nColumnCount;
225cdf0e10cSrcweir 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
237cdf0e10cSrcweir SetFillColor( Color( COL_LIGHTGRAY ) );
238cdf0e10cSrcweir Rectangle aRect;
239cdf0e10cSrcweir aRect.Right() = rOrg.X() + GetSize().Width() - nR;
240cdf0e10cSrcweir aRect.Left() = rOrg.X() + nL;
241cdf0e10cSrcweir aRect.Top() = rOrg.Y() + GetTop()
242cdf0e10cSrcweir + GetHdHeight() + GetHdDist();
243cdf0e10cSrcweir aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
244cdf0e10cSrcweir - GetFtHeight() - GetFtDist();
245cdf0e10cSrcweir DrawRect(aRect);
246cdf0e10cSrcweir
24756b35d86SArmin Le Grand // UUUU
24856b35d86SArmin Le Grand const Rectangle aDefineRect(aRect);
24956b35d86SArmin Le Grand
25056b35d86SArmin Le Grand // UUUU
25156b35d86SArmin Le Grand const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes = getPageFillAttributes();
25256b35d86SArmin Le Grand
25356b35d86SArmin Le Grand if(!rFillAttributes.get() || !rFillAttributes->isUsed())
254cdf0e10cSrcweir {
25556b35d86SArmin Le Grand // UUUU If there is no fill, use fallback color
256cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
257cdf0e10cSrcweir const Color& rFieldColor = rStyleSettings.GetFieldColor();
25856b35d86SArmin Le Grand
25956b35d86SArmin Le Grand setPageFillAttributes(
26056b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr(
26156b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper(
26256b35d86SArmin Le Grand rFieldColor)));
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265*309cb347Smseidel // #97495# make sure that the automatic column width's are always equal
266cdf0e10cSrcweir sal_Bool bAutoWidth = pColMgr->IsAutoWidth();
267cdf0e10cSrcweir sal_Int32 nAutoColWidth = 0;
268cdf0e10cSrcweir if(bAutoWidth)
269cdf0e10cSrcweir {
270cdf0e10cSrcweir sal_Int32 nColumnWidthSum = 0;
271cdf0e10cSrcweir sal_uInt16 i;
272cdf0e10cSrcweir for(i = 0; i < nColumnCount; ++i)
273cdf0e10cSrcweir nColumnWidthSum += pColMgr->GetColWidth( i );
274cdf0e10cSrcweir nAutoColWidth = nColumnWidthSum / nColumnCount;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
277cdf0e10cSrcweir sal_uInt16 i;
278cdf0e10cSrcweir for( i = 0; i < nColumnCount; i++)
279cdf0e10cSrcweir {
280cdf0e10cSrcweir if(!bAutoWidth)
281cdf0e10cSrcweir nAutoColWidth = pColMgr->GetColWidth( i );
282cdf0e10cSrcweir aRect.Right() = aRect.Left() + nAutoColWidth;
28356b35d86SArmin Le Grand
28456b35d86SArmin Le Grand // UUUU use primitive draw command
28556b35d86SArmin Le Grand drawFillAttributes(getPageFillAttributes(), aRect, aDefineRect);
28656b35d86SArmin Le Grand
287cdf0e10cSrcweir if(i < nColumnCount - 1)
288cdf0e10cSrcweir aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i);
289cdf0e10cSrcweir }
290cdf0e10cSrcweir if(pColMgr->HasLine())
291cdf0e10cSrcweir {
292cdf0e10cSrcweir Point aUp( rOrg.X() + nL, rOrg.Y() + GetTop() );
293cdf0e10cSrcweir Point aDown( rOrg.X() + nL, rOrg.Y() + GetSize().Height()
294cdf0e10cSrcweir - GetBottom() - GetFtHeight() - GetFtDist() );
295cdf0e10cSrcweir
296cdf0e10cSrcweir if( pColMgr->GetLineHeightPercent() != 100 )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir long nLength = aDown.Y() - aUp.Y();
299cdf0e10cSrcweir nLength -= nLength * pColMgr->GetLineHeightPercent() / 100;
300cdf0e10cSrcweir switch(pColMgr->GetAdjust())
301cdf0e10cSrcweir {
302cdf0e10cSrcweir case COLADJ_BOTTOM: aUp.Y() += nLength; break;
303cdf0e10cSrcweir case COLADJ_TOP: aDown.Y() -= nLength; break;
304cdf0e10cSrcweir case COLADJ_CENTER:
305cdf0e10cSrcweir aUp.Y() += nLength / 2;
306cdf0e10cSrcweir aDown.Y() -= nLength / 2;
307cdf0e10cSrcweir break;
308cdf0e10cSrcweir default:; // prevent warning
309cdf0e10cSrcweir }
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir int nDist;
313cdf0e10cSrcweir for( i = 0; i < nColumnCount - 1; i++)
314cdf0e10cSrcweir {
315cdf0e10cSrcweir int nGutter = pColMgr->GetGutterWidth(i);
316cdf0e10cSrcweir nDist = pColMgr->GetColWidth( i ) + nGutter;
317cdf0e10cSrcweir nDist -= (i == 0) ?
318cdf0e10cSrcweir nGutter/2 :
319cdf0e10cSrcweir 0;
320cdf0e10cSrcweir aUp.X() += nDist;
321cdf0e10cSrcweir aDown.X() += nDist;
322cdf0e10cSrcweir DrawLine( aUp, aDown );
323cdf0e10cSrcweir
324cdf0e10cSrcweir }
325cdf0e10cSrcweir }
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),
336cdf0e10cSrcweir m_aFrmSize(1,1)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir SetMapMode( MapMode( MAP_TWIP ) );
339cdf0e10cSrcweir m_aWinSize = GetOutputSizePixel();
340cdf0e10cSrcweir m_aWinSize.Height() -= 4;
341cdf0e10cSrcweir m_aWinSize.Width() -= 4;
342cdf0e10cSrcweir
343cdf0e10cSrcweir m_aWinSize = PixelToLogic( m_aWinSize );
344cdf0e10cSrcweir
345cdf0e10cSrcweir SetBorderStyle( WINDOW_BORDER_MONO );
346cdf0e10cSrcweir
347*309cb347Smseidel m_aFrmSize = SvxPaperInfo::GetPaperSize(PAPER_A4); // DIN A4 TODO: Can we get the size of the frame here?
348cdf0e10cSrcweir ::FitToActualSize(m_aCols, (sal_uInt16)m_aFrmSize.Width());
349cdf0e10cSrcweir
350cdf0e10cSrcweir long nHeight = m_aFrmSize.Height();
351cdf0e10cSrcweir Fraction aScale( m_aWinSize.Height(), nHeight );
352cdf0e10cSrcweir MapMode aMapMode( GetMapMode() );
353cdf0e10cSrcweir aMapMode.SetScaleX( aScale );
354cdf0e10cSrcweir aMapMode.SetScaleY( aScale );
355cdf0e10cSrcweir 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 {
365cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
366cdf0e10cSrcweir const Color& rFieldColor = rStyleSettings.GetFieldColor();
367cdf0e10cSrcweir const Color& rDlgColor = rStyleSettings.GetDialogColor();
368cdf0e10cSrcweir const Color& rFieldTextColor = SwViewOption::GetFontColor();
369cdf0e10cSrcweir Color aGrayColor(COL_LIGHTGRAY);
370cdf0e10cSrcweir if(rFieldColor == aGrayColor)
371cdf0e10cSrcweir aGrayColor.Invert();
372cdf0e10cSrcweir
373cdf0e10cSrcweir Size aLogSize(PixelToLogic(GetOutputSizePixel()));
374cdf0e10cSrcweir Rectangle aCompleteRect(Point(0,0), aLogSize);
375cdf0e10cSrcweir SetLineColor(rDlgColor);
376cdf0e10cSrcweir SetFillColor(rDlgColor);
377cdf0e10cSrcweir DrawRect(aCompleteRect);
378cdf0e10cSrcweir
379cdf0e10cSrcweir SetLineColor( rFieldTextColor );
380cdf0e10cSrcweir Point aTL( (aLogSize.Width() - m_aFrmSize.Width()) / 2,
381cdf0e10cSrcweir (aLogSize.Height() - m_aFrmSize.Height()) / 2);
382cdf0e10cSrcweir Rectangle aRect(aTL, m_aFrmSize);
383cdf0e10cSrcweir
384cdf0e10cSrcweir // draw a shadow rectangle
3854a9f3b39Smseidel // SetFillColor( Color(COL_GRAY) );
3864a9f3b39Smseidel // Rectangle aShadowRect(aRect);
3874a9f3b39Smseidel // aShadowRect.Move(aTL.Y(), aTL.Y());
3884a9f3b39Smseidel // DrawRect(aShadowRect);
389cdf0e10cSrcweir
390cdf0e10cSrcweir SetFillColor( rFieldColor );
391cdf0e10cSrcweir DrawRect(aRect);
392cdf0e10cSrcweir
393cdf0e10cSrcweir SetFillColor( aGrayColor );
394cdf0e10cSrcweir
395cdf0e10cSrcweir // Spaltentrenner?
396cdf0e10cSrcweir long nLength = aLogSize.Height() - 2 * aTL.Y();
397cdf0e10cSrcweir Point aUp( aTL );
398cdf0e10cSrcweir Point aDown( aTL.X(), nLength );
399cdf0e10cSrcweir sal_Bool bLines = sal_False;
400cdf0e10cSrcweir if(m_aCols.GetLineAdj() != COLADJ_NONE)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir bLines = sal_True;
403cdf0e10cSrcweir
404cdf0e10cSrcweir sal_uInt16 nPercent = m_aCols.GetLineHeight();
405cdf0e10cSrcweir if( nPercent != 100 )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir nLength -= nLength * nPercent / 100;
408cdf0e10cSrcweir switch(m_aCols.GetLineAdj())
409cdf0e10cSrcweir {
410cdf0e10cSrcweir case COLADJ_BOTTOM: aUp.Y() += nLength; break;
411cdf0e10cSrcweir case COLADJ_TOP: aDown.Y() -= nLength; break;
412cdf0e10cSrcweir case COLADJ_CENTER:
413cdf0e10cSrcweir aUp.Y() += nLength / 2;
414cdf0e10cSrcweir aDown.Y() -= nLength / 2;
415cdf0e10cSrcweir break;
416cdf0e10cSrcweir default:; // prevent warning
417cdf0e10cSrcweir }
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir }
421cdf0e10cSrcweir const SwColumns& rCols = m_aCols.GetColumns();
422cdf0e10cSrcweir sal_uInt16 nColCount = rCols.Count();
423cdf0e10cSrcweir if( nColCount )
424cdf0e10cSrcweir {
425cdf0e10cSrcweir DrawRect(aRect);
426cdf0e10cSrcweir SetFillColor( rFieldColor );
427cdf0e10cSrcweir Rectangle aFrmRect(aTL, m_aFrmSize);
428cdf0e10cSrcweir long nSum = aTL.X();
429cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nColCount; i++)
430cdf0e10cSrcweir {
431cdf0e10cSrcweir SwColumn* pCol = rCols[i];
432cdf0e10cSrcweir aFrmRect.Left() = nSum + pCol->GetLeft(); // nSum + pCol->GetLeft() + aTL.X();
433cdf0e10cSrcweir nSum += pCol->GetWishWidth();
434cdf0e10cSrcweir aFrmRect.Right() = nSum - pCol->GetRight();
435cdf0e10cSrcweir DrawRect(aFrmRect);
436cdf0e10cSrcweir }
437cdf0e10cSrcweir if(bLines )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir nSum = aTL.X();
440cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nColCount - 1; i++)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir nSum += rCols[i]->GetWishWidth();
443cdf0e10cSrcweir aUp.X() = nSum;
444cdf0e10cSrcweir aDown.X() = nSum;
445cdf0e10cSrcweir DrawLine(aUp, aDown);
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
451cdf0e10cSrcweir /*-----------------25.10.96 12.05-------------------
452cdf0e10cSrcweir
453cdf0e10cSrcweir --------------------------------------------------*/
454cdf0e10cSrcweir
455cdf0e10cSrcweir
SetColumns(const SwFmtCol & rCol)456cdf0e10cSrcweir void SwColumnOnlyExample::SetColumns(const SwFmtCol& rCol)
457cdf0e10cSrcweir {
458cdf0e10cSrcweir m_aCols = rCol;
459cdf0e10cSrcweir sal_uInt16 nWishSum = m_aCols.GetWishWidth();
460cdf0e10cSrcweir long nFrmWidth = m_aFrmSize.Width();
461cdf0e10cSrcweir SwColumns& rCols = m_aCols.GetColumns();
462cdf0e10cSrcweir sal_uInt16 nColCount = rCols.Count();
463cdf0e10cSrcweir
464cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nColCount; i++)
465cdf0e10cSrcweir {
466cdf0e10cSrcweir SwColumn* pCol = rCols[i];
467cdf0e10cSrcweir long nWish = pCol->GetWishWidth();
468cdf0e10cSrcweir nWish *= nFrmWidth;
469cdf0e10cSrcweir nWish /= nWishSum;
470cdf0e10cSrcweir pCol->SetWishWidth((sal_uInt16)nWish);
471cdf0e10cSrcweir long nLeft = pCol->GetLeft();
472cdf0e10cSrcweir nLeft *= nFrmWidth;
473cdf0e10cSrcweir nLeft /= nWishSum;
474cdf0e10cSrcweir pCol->SetLeft((sal_uInt16)nLeft);
475cdf0e10cSrcweir long nRight = pCol->GetRight();
476cdf0e10cSrcweir nRight *= nFrmWidth;
477cdf0e10cSrcweir nRight /= nWishSum;
478cdf0e10cSrcweir pCol->SetRight((sal_uInt16)nRight);
479cdf0e10cSrcweir }
480cdf0e10cSrcweir // #97495# make sure that the automatic column width's are always equal
481cdf0e10cSrcweir if(nColCount && m_aCols.IsOrtho())
482cdf0e10cSrcweir {
483cdf0e10cSrcweir sal_Int32 nColumnWidthSum = 0;
484cdf0e10cSrcweir sal_uInt16 i;
485cdf0e10cSrcweir for(i = 0; i < nColCount; ++i)
486cdf0e10cSrcweir {
487cdf0e10cSrcweir SwColumn* pCol = rCols[i];
488cdf0e10cSrcweir nColumnWidthSum += pCol->GetWishWidth();
489cdf0e10cSrcweir nColumnWidthSum -= (pCol->GetRight() + pCol->GetLeft());
490cdf0e10cSrcweir }
491cdf0e10cSrcweir nColumnWidthSum /= nColCount;
492cdf0e10cSrcweir for(i = 0; i < nColCount; ++i)
493cdf0e10cSrcweir {
494cdf0e10cSrcweir SwColumn* pCol = rCols[i];
495cdf0e10cSrcweir pCol->SetWishWidth( static_cast< sal_uInt16 >(nColumnWidthSum + pCol->GetRight() + pCol->GetLeft()));
496cdf0e10cSrcweir }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir }
499cdf0e10cSrcweir /* -----------------------------08.02.2002 11:44------------------------------
500cdf0e10cSrcweir
501cdf0e10cSrcweir ---------------------------------------------------------------------------*/
~SwPageGridExample()502cdf0e10cSrcweir SwPageGridExample::~SwPageGridExample()
503cdf0e10cSrcweir {
504cdf0e10cSrcweir delete pGridItem;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir /* -----------------------------08.02.2002 11:48------------------------------
507cdf0e10cSrcweir
508cdf0e10cSrcweir ---------------------------------------------------------------------------*/
509cdf0e10cSrcweir #define MAX_ROWS 10
510cdf0e10cSrcweir #define MAX_LINES 15
DrawPage(const Point & rOrg,const sal_Bool bSecond,const sal_Bool bEnabled)511cdf0e10cSrcweir void SwPageGridExample::DrawPage( const Point& rOrg,
512cdf0e10cSrcweir const sal_Bool bSecond,
513cdf0e10cSrcweir const sal_Bool bEnabled )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir SwPageExample::DrawPage(rOrg, bSecond, bEnabled);
516cdf0e10cSrcweir if(pGridItem && pGridItem->GetGridType())
517cdf0e10cSrcweir {
518cdf0e10cSrcweir // paint the grid now
519cdf0e10cSrcweir Color aLineColor = pGridItem->GetColor();
520cdf0e10cSrcweir if(aLineColor.GetColor() == COL_AUTO)
521cdf0e10cSrcweir {
522cdf0e10cSrcweir aLineColor = GetFillColor();
523cdf0e10cSrcweir aLineColor.Invert();
524cdf0e10cSrcweir }
525cdf0e10cSrcweir SetLineColor(aLineColor);
526cdf0e10cSrcweir 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
536cdf0e10cSrcweir 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
544cdf0e10cSrcweir // increase the values to get a 'viewable' preview
545cdf0e10cSrcweir sal_Int32 nBaseHeight = pGridItem->GetBaseHeight() * 3;
546cdf0e10cSrcweir sal_Int32 nRubyHeight = pGridItem->GetRubyHeight() * 3;
547cdf0e10cSrcweir
548cdf0e10cSrcweir // detect height of rectangles
549cdf0e10cSrcweir Rectangle aRubyRect(aRect.TopLeft(),
550cdf0e10cSrcweir m_bVertical ?
551cdf0e10cSrcweir Size(nRubyHeight, aRect.GetHeight()) :
552cdf0e10cSrcweir Size(aRect.GetWidth(), nRubyHeight));
553cdf0e10cSrcweir Rectangle aCharRect(aRect.TopLeft(),
554cdf0e10cSrcweir m_bVertical ?
555cdf0e10cSrcweir Size(nBaseHeight, aRect.GetHeight()) :
556cdf0e10cSrcweir Size(aRect.GetWidth(), nBaseHeight));
557cdf0e10cSrcweir
558cdf0e10cSrcweir sal_Int32 nLineHeight = nBaseHeight + nRubyHeight;
559cdf0e10cSrcweir
560cdf0e10cSrcweir // detect count of rectangles
561cdf0e10cSrcweir sal_Int32 nLines = (m_bVertical ? aRect.GetWidth(): aRect.GetHeight()) / nLineHeight;
562cdf0e10cSrcweir if(nLines > pGridItem->GetLines())
563cdf0e10cSrcweir nLines = pGridItem->GetLines();
564cdf0e10cSrcweir
565cdf0e10cSrcweir // determine start position
566cdf0e10cSrcweir if(m_bVertical)
567cdf0e10cSrcweir {
568cdf0e10cSrcweir sal_Int16 nXStart = static_cast< sal_Int16 >(aRect.GetWidth() / 2 - nLineHeight * nLines /2);
569cdf0e10cSrcweir aRubyRect.Move(nXStart, 0);
570cdf0e10cSrcweir aCharRect.Move(nXStart, 0);
571cdf0e10cSrcweir }
572cdf0e10cSrcweir else
573cdf0e10cSrcweir {
574cdf0e10cSrcweir sal_Int16 nYStart = static_cast< sal_Int16 >(aRect.GetHeight() / 2 - nLineHeight * nLines /2);
575cdf0e10cSrcweir aRubyRect.Move(0, nYStart);
576cdf0e10cSrcweir aCharRect.Move(0, nYStart);
577cdf0e10cSrcweir }
578cdf0e10cSrcweir
579cdf0e10cSrcweir if(pGridItem->IsRubyTextBelow())
580cdf0e10cSrcweir m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight);
581cdf0e10cSrcweir else
582cdf0e10cSrcweir m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight);
583cdf0e10cSrcweir
584cdf0e10cSrcweir // vertical lines
585cdf0e10cSrcweir sal_Bool bBothLines = pGridItem->GetGridType() == GRID_LINES_CHARS;
586cdf0e10cSrcweir SetFillColor( Color( COL_TRANSPARENT ) );
587cdf0e10cSrcweir sal_Int32 nXMove = m_bVertical ? nLineHeight : 0;
588cdf0e10cSrcweir sal_Int32 nYMove = m_bVertical ? 0 : nLineHeight;
589cdf0e10cSrcweir for(sal_Int32 nLine = 0; nLine < nLines; nLine++)
590cdf0e10cSrcweir {
591cdf0e10cSrcweir DrawRect(aRubyRect);
592cdf0e10cSrcweir DrawRect(aCharRect);
593cdf0e10cSrcweir if(bBothLines)
594cdf0e10cSrcweir {
595cdf0e10cSrcweir Point aStart = aCharRect.TopLeft();
596cdf0e10cSrcweir Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft();
597cdf0e10cSrcweir while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
598cdf0e10cSrcweir {
599cdf0e10cSrcweir DrawLine(aStart, aEnd);
600cdf0e10cSrcweir if(m_bVertical)
601cdf0e10cSrcweir aStart.Y() = aEnd.Y() += nBaseHeight;
602cdf0e10cSrcweir else
603cdf0e10cSrcweir aStart.X() = aEnd.X() += nBaseHeight;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir }
606cdf0e10cSrcweir aRubyRect.Move(nXMove, nYMove);
607cdf0e10cSrcweir aCharRect.Move(nXMove, nYMove);
608cdf0e10cSrcweir }
609cdf0e10cSrcweir }
610cdf0e10cSrcweir }
611cdf0e10cSrcweir /* -----------------------------08.02.2002 11:48------------------------------
612cdf0e10cSrcweir
613cdf0e10cSrcweir ---------------------------------------------------------------------------*/
UpdateExample(const SfxItemSet & rSet)614cdf0e10cSrcweir void SwPageGridExample::UpdateExample( const SfxItemSet& rSet )
615cdf0e10cSrcweir {
616cdf0e10cSrcweir DELETEZ(pGridItem);
617cdf0e10cSrcweir // get the grid information
618cdf0e10cSrcweir if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, sal_True))
619cdf0e10cSrcweir pGridItem = (SwTextGridItem*)((const SwTextGridItem&)rSet.Get(RES_TEXTGRID)).Clone();
620cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR, sal_True ))
621cdf0e10cSrcweir {
622cdf0e10cSrcweir const SvxFrameDirectionItem& rDirItem =
623cdf0e10cSrcweir (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
624cdf0e10cSrcweir m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
625cdf0e10cSrcweir rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
626cdf0e10cSrcweir }
627cdf0e10cSrcweir SwPageExample::UpdateExample(rSet);
628cdf0e10cSrcweir }
629cdf0e10cSrcweir
6304a9f3b39Smseidel /* vim: set noet sw=4 ts=4: */
631