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