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