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