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/brushitem.hxx>
31 : #include <editeng/frmdiritem.hxx>
32 : #include <vcl/bitmap.hxx>
33 : #include <vcl/builder.hxx>
34 : #include <vcl/graph.hxx>
35 : #include <tgrditem.hxx>
36 : #include <viewopt.hxx>
37 : #include "colex.hxx"
38 : #include "colmgr.hxx"
39 :
40 : /*-----------------------------------------------------------------------
41 : Description: Taking the updated values from the set
42 : -----------------------------------------------------------------------*/
43 0 : void SwPageExample::UpdateExample( const SfxItemSet& rSet )
44 : {
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 : const SvxPageItem* 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 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwColExample(Window *pParent, VclBuilder::stringmap &)
293 : {
294 0 : return new SwColExample(pParent);
295 : }
296 :
297 0 : SwColumnOnlyExample::SwColumnOnlyExample(Window* pParent)
298 : : Window(pParent)
299 0 : , m_aFrmSize(1,1)
300 : {
301 0 : SetMapMode( MapMode( MAP_TWIP ) );
302 0 : m_aWinSize = GetOptimalSize();
303 0 : m_aWinSize.Height() -= 4;
304 0 : m_aWinSize.Width() -= 4;
305 :
306 0 : m_aWinSize = PixelToLogic( m_aWinSize );
307 :
308 0 : SetBorderStyle( WINDOW_BORDER_MONO );
309 :
310 0 : m_aFrmSize = SvxPaperInfo::GetPaperSize(PAPER_A4);// DIN A4
311 0 : ::FitToActualSize(m_aCols, (sal_uInt16)m_aFrmSize.Width());
312 :
313 0 : long nHeight = m_aFrmSize.Height();
314 0 : Fraction aScale( m_aWinSize.Height(), nHeight );
315 0 : MapMode aMapMode( GetMapMode() );
316 0 : aMapMode.SetScaleX( aScale );
317 0 : aMapMode.SetScaleY( aScale );
318 0 : SetMapMode( aMapMode );
319 0 : }
320 :
321 0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwColumnOnlyExample(Window *pParent, VclBuilder::stringmap &)
322 : {
323 0 : return new SwColumnOnlyExample(pParent);
324 : }
325 :
326 0 : void SwColumnOnlyExample::Paint( const Rectangle& /*rRect*/ )
327 : {
328 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
329 0 : const Color& rFieldColor = rStyleSettings.GetFieldColor();
330 0 : const Color& rDlgColor = rStyleSettings.GetDialogColor();
331 0 : const Color& rFieldTextColor = SwViewOption::GetFontColor();
332 0 : Color aGrayColor(COL_LIGHTGRAY);
333 0 : if(rFieldColor == aGrayColor)
334 0 : aGrayColor.Invert();
335 :
336 0 : Size aLogSize(PixelToLogic(GetOutputSizePixel()));
337 0 : Rectangle aCompleteRect(Point(0,0), aLogSize);
338 0 : SetLineColor(rDlgColor);
339 0 : SetFillColor(rDlgColor);
340 0 : DrawRect(aCompleteRect);
341 :
342 0 : SetLineColor( rFieldTextColor );
343 0 : Point aTL( (aLogSize.Width() - m_aFrmSize.Width()) / 2,
344 0 : (aLogSize.Height() - m_aFrmSize.Height()) / 2);
345 0 : Rectangle aRect(aTL, m_aFrmSize);
346 :
347 : //draw a shadow rectangle
348 0 : SetFillColor( Color(COL_GRAY) );
349 0 : Rectangle aShadowRect(aRect);
350 0 : aShadowRect.Move(aTL.Y(), aTL.Y());
351 0 : DrawRect(aShadowRect);
352 :
353 0 : SetFillColor( rFieldColor );
354 0 : DrawRect(aRect);
355 :
356 0 : SetFillColor( aGrayColor );
357 :
358 : //column separator?
359 0 : long nLength = aLogSize.Height() - 2 * aTL.Y();
360 0 : Point aUp( aTL );
361 0 : Point aDown( aTL.X(), nLength );
362 0 : bool bLines = false;
363 0 : if(m_aCols.GetLineAdj() != COLADJ_NONE)
364 : {
365 0 : bLines = true;
366 :
367 0 : sal_uInt16 nPercent = m_aCols.GetLineHeight();
368 0 : if( nPercent != 100 )
369 : {
370 0 : nLength -= nLength * nPercent / 100;
371 0 : switch(m_aCols.GetLineAdj())
372 : {
373 0 : case COLADJ_BOTTOM: aUp.Y() += nLength; break;
374 0 : case COLADJ_TOP: aDown.Y() -= nLength; break;
375 : case COLADJ_CENTER:
376 0 : aUp.Y() += nLength / 2;
377 0 : aDown.Y() -= nLength / 2;
378 0 : break;
379 : default:; //prevent warning
380 : }
381 : }
382 :
383 : }
384 0 : const SwColumns& rCols = m_aCols.GetColumns();
385 0 : sal_uInt16 nColCount = rCols.size();
386 0 : if( nColCount )
387 : {
388 0 : DrawRect(aRect);
389 0 : SetFillColor( rFieldColor );
390 0 : Rectangle aFrmRect(aTL, m_aFrmSize);
391 0 : long nSum = aTL.X();
392 0 : for(sal_uInt16 i = 0; i < nColCount; i++)
393 : {
394 0 : const SwColumn* pCol = &rCols[i];
395 0 : aFrmRect.Left() = nSum + pCol->GetLeft();//nSum + pCol->GetLeft() + aTL.X();
396 0 : nSum += pCol->GetWishWidth();
397 0 : aFrmRect.Right() = nSum - pCol->GetRight();
398 0 : DrawRect(aFrmRect);
399 : }
400 0 : if(bLines )
401 : {
402 0 : nSum = aTL.X();
403 0 : for(sal_uInt16 i = 0; i < nColCount - 1; i++)
404 : {
405 0 : nSum += rCols[i].GetWishWidth();
406 0 : aUp.X() = nSum;
407 0 : aDown.X() = nSum;
408 0 : DrawLine(aUp, aDown);
409 : }
410 : }
411 : }
412 0 : }
413 :
414 0 : void SwColumnOnlyExample::SetColumns(const SwFmtCol& rCol)
415 : {
416 0 : m_aCols = rCol;
417 0 : sal_uInt16 nWishSum = m_aCols.GetWishWidth();
418 0 : long nFrmWidth = m_aFrmSize.Width();
419 0 : SwColumns& rCols = m_aCols.GetColumns();
420 0 : sal_uInt16 nColCount = rCols.size();
421 :
422 0 : for(sal_uInt16 i = 0; i < nColCount; i++)
423 : {
424 0 : SwColumn* pCol = &rCols[i];
425 0 : long nWish = pCol->GetWishWidth();
426 0 : nWish *= nFrmWidth;
427 0 : nWish /= nWishSum;
428 0 : pCol->SetWishWidth((sal_uInt16)nWish);
429 0 : long nLeft = pCol->GetLeft();
430 0 : nLeft *= nFrmWidth;
431 0 : nLeft /= nWishSum;
432 0 : pCol->SetLeft((sal_uInt16)nLeft);
433 0 : long nRight = pCol->GetRight();
434 0 : nRight *= nFrmWidth;
435 0 : nRight /= nWishSum;
436 0 : pCol->SetRight((sal_uInt16)nRight);
437 : }
438 : // #97495# make sure that the automatic column width's are always equal
439 0 : if(nColCount && m_aCols.IsOrtho())
440 : {
441 0 : sal_Int32 nColumnWidthSum = 0;
442 : sal_uInt16 i;
443 0 : for(i = 0; i < nColCount; ++i)
444 : {
445 0 : SwColumn* pCol = &rCols[i];
446 0 : nColumnWidthSum += pCol->GetWishWidth();
447 0 : nColumnWidthSum -= (pCol->GetRight() + pCol->GetLeft());
448 : }
449 0 : nColumnWidthSum /= nColCount;
450 0 : for(i = 0; i < nColCount; ++i)
451 : {
452 0 : SwColumn* pCol = &rCols[i];
453 0 : pCol->SetWishWidth( static_cast< sal_uInt16 >(nColumnWidthSum + pCol->GetRight() + pCol->GetLeft()));
454 : }
455 : }
456 0 : }
457 :
458 0 : Size SwColumnOnlyExample::GetOptimalSize() const
459 : {
460 0 : return LogicToPixel(Size(75, 46), MapMode(MAP_APPFONT));
461 : }
462 :
463 0 : SwPageGridExample::~SwPageGridExample()
464 : {
465 0 : delete pGridItem;
466 0 : }
467 :
468 0 : void SwPageGridExample::DrawPage( const Point& rOrg,
469 : const sal_Bool bSecond,
470 : const sal_Bool bEnabled )
471 : {
472 0 : SwPageExample::DrawPage(rOrg, bSecond, bEnabled);
473 0 : if(pGridItem && pGridItem->GetGridType())
474 : {
475 : //paint the grid now
476 0 : Color aLineColor = pGridItem->GetColor();
477 0 : if(aLineColor.GetColor() == COL_AUTO)
478 : {
479 0 : aLineColor = GetFillColor();
480 0 : aLineColor.Invert();
481 : }
482 0 : SetLineColor(aLineColor);
483 0 : long nL = GetLeft();
484 0 : long nR = GetRight();
485 :
486 0 : if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond )
487 : {
488 : // rotate for mirrored
489 0 : nL = GetRight();
490 0 : nR = GetLeft();
491 : }
492 :
493 0 : Rectangle aRect;
494 0 : aRect.Right() = rOrg.X() + GetSize().Width() - nR;
495 0 : aRect.Left() = rOrg.X() + nL;
496 0 : aRect.Top() = rOrg.Y() + GetTop()
497 0 : + GetHdHeight() + GetHdDist();
498 0 : aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom()
499 0 : - GetFtHeight() - GetFtDist();
500 :
501 : //increase the values to get a 'viewable' preview
502 0 : sal_Int32 nBaseHeight = pGridItem->GetBaseHeight() * 3;
503 0 : sal_Int32 nRubyHeight = pGridItem->GetRubyHeight() * 3;
504 :
505 : //detect height of rectangles
506 : Rectangle aRubyRect(aRect.TopLeft(),
507 : m_bVertical ?
508 : Size(nRubyHeight, aRect.GetHeight()) :
509 0 : Size(aRect.GetWidth(), nRubyHeight));
510 : Rectangle aCharRect(aRect.TopLeft(),
511 : m_bVertical ?
512 : Size(nBaseHeight, aRect.GetHeight()) :
513 0 : Size(aRect.GetWidth(), nBaseHeight));
514 :
515 0 : sal_Int32 nLineHeight = nBaseHeight + nRubyHeight;
516 :
517 : //detect count of rectangles
518 0 : sal_Int32 nLines = (m_bVertical ? aRect.GetWidth(): aRect.GetHeight()) / nLineHeight;
519 0 : if(nLines > pGridItem->GetLines())
520 0 : nLines = pGridItem->GetLines();
521 :
522 : // determine start position
523 0 : if(m_bVertical)
524 : {
525 0 : sal_Int16 nXStart = static_cast< sal_Int16 >(aRect.GetWidth() / 2 - nLineHeight * nLines /2);
526 0 : aRubyRect.Move(nXStart, 0);
527 0 : aCharRect.Move(nXStart, 0);
528 : }
529 : else
530 : {
531 0 : sal_Int16 nYStart = static_cast< sal_Int16 >(aRect.GetHeight() / 2 - nLineHeight * nLines /2);
532 0 : aRubyRect.Move(0, nYStart);
533 0 : aCharRect.Move(0, nYStart);
534 : }
535 :
536 0 : if(pGridItem->IsRubyTextBelow())
537 0 : m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight);
538 : else
539 0 : m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight);
540 :
541 : //vertical lines
542 0 : bool bBothLines = pGridItem->GetGridType() == GRID_LINES_CHARS;
543 0 : SetFillColor( Color( COL_TRANSPARENT ) );
544 0 : sal_Int32 nXMove = m_bVertical ? nLineHeight : 0;
545 0 : sal_Int32 nYMove = m_bVertical ? 0 : nLineHeight;
546 0 : for(sal_Int32 nLine = 0; nLine < nLines; nLine++)
547 : {
548 0 : DrawRect(aRubyRect);
549 0 : DrawRect(aCharRect);
550 0 : if(bBothLines)
551 : {
552 0 : Point aStart = aCharRect.TopLeft();
553 0 : Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft();
554 0 : while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right())
555 : {
556 0 : DrawLine(aStart, aEnd);
557 0 : if(m_bVertical)
558 0 : aStart.Y() = aEnd.Y() += nBaseHeight;
559 : else
560 0 : aStart.X() = aEnd.X() += nBaseHeight;
561 : }
562 : }
563 0 : aRubyRect.Move(nXMove, nYMove);
564 0 : aCharRect.Move(nXMove, nYMove);
565 : }
566 : }
567 0 : }
568 :
569 0 : void SwPageGridExample::UpdateExample( const SfxItemSet& rSet )
570 : {
571 0 : DELETEZ(pGridItem);
572 : //get the grid information
573 0 : if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, sal_True))
574 0 : pGridItem = (SwTextGridItem*)((const SwTextGridItem&)rSet.Get(RES_TEXTGRID)).Clone();
575 0 : if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR, sal_True ))
576 : {
577 : const SvxFrameDirectionItem& rDirItem =
578 0 : (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
579 0 : m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT||
580 0 : rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT;
581 : }
582 0 : SwPageExample::UpdateExample(rSet);
583 0 : }
584 :
585 0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwPageGridExample(Window *pParent, VclBuilder::stringmap &)
586 : {
587 0 : return new SwPageGridExample(pParent);
588 99 : }
589 :
590 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|