Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / dialog / swframeexample.cxx
blobbe970414cf8a051c8a18fbc49e02362fa05eb795
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/metric.hxx>
21 #include <vcl/outdev.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/settings.hxx>
24 #include <svtools/colorcfg.hxx>
25 #include <svx/swframeexample.hxx>
26 #include <i18nlangtag/languagetag.hxx>
27 #include <com/sun/star/text/HoriOrientation.hpp>
28 #include <com/sun/star/text/VertOrientation.hpp>
29 #include <com/sun/star/text/RelOrientation.hpp>
31 using namespace ::com::sun::star::text;
33 #define FLYINFLY_BORDER 3
34 #define DEMOTEXT "Ij"
36 namespace {
38 void DrawRect_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect,
39 const Color &rFillColor, const Color &rLineColor)
41 rRenderContext.SetFillColor(rFillColor);
42 rRenderContext.SetLineColor(rLineColor);
43 rRenderContext.DrawRect(rRect);
48 SwFrameExample::SwFrameExample()
49 : nHAlign(HoriOrientation::CENTER)
50 , nHRel(RelOrientation::FRAME)
51 , nVAlign(VertOrientation::TOP)
52 , nVRel(RelOrientation::PRINT_AREA)
53 , nWrap(WrapTextMode_NONE)
54 , nAnchor(RndStdIds::FLY_AT_PAGE)
55 , bTrans(false)
56 , aRelPos(Point(0,0))
58 InitColors_Impl();
61 void SwFrameExample::SetDrawingArea(weld::DrawingArea* pDrawingArea)
63 CustomWidgetController::SetDrawingArea(pDrawingArea);
64 pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 16,
65 pDrawingArea->get_text_height() * 12);
68 void SwFrameExample::InitColors_Impl()
70 const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
71 m_aBgCol = rSettings.GetWindowColor();
73 bool bHC = rSettings.GetHighContrastMode();
75 m_aFrameColor = COL_LIGHTGREEN;
76 m_aAlignColor = COL_LIGHTRED;
77 m_aTransColor = COL_TRANSPARENT;
79 m_aTxtCol = bHC?
80 svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor :
81 COL_GRAY;
82 m_aPrintAreaCol = bHC? m_aTxtCol : COL_GRAY;
83 m_aBorderCol = m_aTxtCol;
84 m_aBlankCol = bHC? m_aTxtCol : COL_LIGHTGRAY;
85 m_aBlankFrameCol = bHC? m_aTxtCol : COL_GRAY;
88 void SwFrameExample::StyleUpdated()
90 InitColors_Impl();
91 CustomWidgetController::StyleUpdated();
94 void SwFrameExample::InitAllRects_Impl(vcl::RenderContext& rRenderContext)
96 aPage.SetSize(GetOutputSizePixel());
98 sal_uInt32 nOutWPix = aPage.GetWidth();
99 sal_uInt32 nOutHPix = aPage.GetHeight();
101 // PrintArea
102 sal_uInt32 nLBorder;
103 sal_uInt32 nRBorder;
104 sal_uInt32 nTBorder;
105 sal_uInt32 nBBorder;
107 sal_uInt32 nLTxtBorder;
108 sal_uInt32 nRTxtBorder;
109 sal_uInt32 nTTxtBorder;
110 sal_uInt32 nBTxtBorder;
112 if (nAnchor != RndStdIds::FLY_AS_CHAR)
114 nLBorder = 14;
115 nRBorder = 10;
116 nTBorder = 10;
117 nBBorder = 15;
119 nLTxtBorder = 8;
120 nRTxtBorder = 4;
121 nTTxtBorder = 2;
122 nBTxtBorder = 2;
124 else
126 nLBorder = 2;
127 nRBorder = 2;
128 nTBorder = 2;
129 nBBorder = 2;
131 nLTxtBorder = 2;
132 nRTxtBorder = 2;
133 nTTxtBorder = 2;
134 nBTxtBorder = 2;
136 aPagePrtArea = tools::Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
138 // Example text: Preparing for the text output
139 // A line of text
140 aTextLine = aPagePrtArea;
141 aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
142 aTextLine.AdjustLeft(nLTxtBorder );
143 aTextLine.AdjustRight( -sal_Int32(nRTxtBorder) );
144 aTextLine.Move(0, nTTxtBorder);
146 // Rectangle to edges including paragraph
147 sal_uInt16 nLines = static_cast<sal_uInt16>((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder)
148 / (aTextLine.GetHeight() + 2));
149 aPara = aPagePrtArea;
150 aPara.SetSize(Size(aPara.GetWidth(),
151 (aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder));
153 // Rectangle around paragraph without borders
154 aParaPrtArea = aPara;
155 aParaPrtArea.AdjustLeft(nLTxtBorder );
156 aParaPrtArea.AdjustRight( -sal_Int32(nRTxtBorder) );
157 aParaPrtArea.AdjustTop(nTTxtBorder );
158 aParaPrtArea.AdjustBottom( -sal_Int32(nBTxtBorder) );
160 if (nAnchor == RndStdIds::FLY_AS_CHAR || nAnchor == RndStdIds::FLY_AT_CHAR)
162 vcl::Font aFont = OutputDevice::GetDefaultFont(
163 DefaultFontType::LATIN_TEXT, Application::GetSettings().GetLanguageTag().getLanguageType(),
164 GetDefaultFontFlags::OnlyOne, &rRenderContext );
165 aFont.SetColor( m_aTxtCol );
166 aFont.SetFillColor( m_aBgCol );
167 aFont.SetWeight(WEIGHT_NORMAL);
169 if (nAnchor == RndStdIds::FLY_AS_CHAR)
171 aFont.SetFontSize(Size(0, aParaPrtArea.GetHeight() - 2));
172 rRenderContext.SetFont(aFont);
173 aParaPrtArea.SetSize(Size(rRenderContext.GetTextWidth(DEMOTEXT), rRenderContext.GetTextHeight()));
175 else
177 aFont.SetFontSize(Size(0, aParaPrtArea.GetHeight() / 2));
178 rRenderContext.SetFont(aFont);
179 aAutoCharFrame.SetSize(Size(rRenderContext.GetTextWidth(OUString('A')), GetTextHeight()));
180 aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2,
181 aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2));
185 // Inner Frame anchored at the Frame
186 aFrameAtFrame = aPara;
187 aFrameAtFrame.AdjustLeft(9 );
188 aFrameAtFrame.AdjustRight( -5 );
189 aFrameAtFrame.AdjustBottom(5 );
190 aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5));
192 // Size of the frame to be positioned
193 if (nAnchor != RndStdIds::FLY_AS_CHAR)
195 sal_uInt32 nLFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nLBorder : nLTxtBorder;
196 sal_uInt32 nRFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nRBorder : nRTxtBorder;
198 switch (nHRel)
200 case RelOrientation::PAGE_LEFT:
201 case RelOrientation::FRAME_LEFT:
202 aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
203 break;
205 case RelOrientation::PAGE_RIGHT:
206 case RelOrientation::FRAME_RIGHT:
207 aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
208 break;
210 default:
211 aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3);
212 break;
214 aFrmSize.setWidth( std::max(tools::Long(5), aFrmSize.Width()) );
215 aFrmSize.setHeight( std::max(tools::Long(5), aFrmSize.Height()) );
217 else
219 sal_uInt32 nFreeWidth = aPagePrtArea.GetWidth() - rRenderContext.GetTextWidth(DEMOTEXT);
221 aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3);
222 aDrawObj.SetSize(Size(std::max(tools::Long(5), tools::Long(nFreeWidth / 3)), std::max(tools::Long(5), aFrmSize.Height() * 3)));
223 aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2));
224 aParaPrtArea.SetRight( aDrawObj.Right() );
228 void SwFrameExample::CalcBoundRect_Impl(const vcl::RenderContext& rRenderContext, tools::Rectangle &rRect)
230 switch (nAnchor)
232 case RndStdIds::FLY_AT_PAGE:
234 switch (nHRel)
236 case RelOrientation::FRAME:
237 case RelOrientation::PAGE_FRAME:
238 rRect.SetLeft( aPage.Left() );
239 rRect.SetRight( aPage.Right() );
240 break;
242 case RelOrientation::PRINT_AREA:
243 case RelOrientation::PAGE_PRINT_AREA:
244 rRect.SetLeft( aPagePrtArea.Left() );
245 rRect.SetRight( aPagePrtArea.Right() );
246 break;
248 case RelOrientation::PAGE_LEFT:
249 rRect.SetLeft( aPage.Left() );
250 rRect.SetRight( aPagePrtArea.Left() );
251 break;
253 case RelOrientation::PAGE_RIGHT:
254 rRect.SetLeft( aPagePrtArea.Right() );
255 rRect.SetRight( aPage.Right() );
256 break;
259 switch (nVRel)
261 case RelOrientation::PRINT_AREA:
262 case RelOrientation::PAGE_PRINT_AREA:
263 rRect.SetTop( aPagePrtArea.Top() );
264 rRect.SetBottom( aPagePrtArea.Bottom() );
265 break;
267 case RelOrientation::FRAME:
268 case RelOrientation::PAGE_FRAME:
269 rRect.SetTop( aPage.Top() );
270 rRect.SetBottom( aPage.Bottom() );
271 break;
274 break;
276 case RndStdIds::FLY_AT_FLY:
278 switch (nHRel)
280 case RelOrientation::FRAME:
281 case RelOrientation::PAGE_FRAME:
282 rRect.SetLeft( aFrameAtFrame.Left() );
283 rRect.SetRight( aFrameAtFrame.Right() );
284 break;
286 case RelOrientation::PRINT_AREA:
287 case RelOrientation::PAGE_PRINT_AREA:
288 rRect.SetLeft( aFrameAtFrame.Left() + FLYINFLY_BORDER );
289 rRect.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER );
290 break;
292 case RelOrientation::PAGE_RIGHT:
293 rRect.SetLeft( aFrameAtFrame.Left() );
294 rRect.SetRight( aFrameAtFrame.Left() + FLYINFLY_BORDER );
295 break;
297 case RelOrientation::PAGE_LEFT:
298 rRect.SetLeft( aFrameAtFrame.Right() );
299 rRect.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER );
300 break;
303 switch (nVRel)
305 case RelOrientation::FRAME:
306 case RelOrientation::PAGE_FRAME:
307 rRect.SetTop( aFrameAtFrame.Top() );
308 rRect.SetBottom( aFrameAtFrame.Bottom() );
309 break;
311 case RelOrientation::PRINT_AREA:
312 case RelOrientation::PAGE_PRINT_AREA:
313 rRect.SetTop( aFrameAtFrame.Top() + FLYINFLY_BORDER );
314 rRect.SetBottom( aFrameAtFrame.Bottom() - FLYINFLY_BORDER );
315 break;
318 break;
319 case RndStdIds::FLY_AT_PARA:
320 case RndStdIds::FLY_AT_CHAR:
322 switch (nHRel)
324 case RelOrientation::FRAME:
325 rRect.SetLeft( aPara.Left() );
326 rRect.SetRight( aPara.Right() );
327 break;
329 case RelOrientation::PRINT_AREA:
330 rRect.SetLeft( aParaPrtArea.Left() );
331 rRect.SetRight( aParaPrtArea.Right() );
332 break;
334 case RelOrientation::PAGE_LEFT:
335 rRect.SetLeft( aPage.Left() );
336 rRect.SetRight( aPagePrtArea.Left() );
337 break;
339 case RelOrientation::PAGE_RIGHT:
340 rRect.SetLeft( aPagePrtArea.Right() );
341 rRect.SetRight( aPage.Right() );
342 break;
344 case RelOrientation::PAGE_FRAME:
345 rRect.SetLeft( aPage.Left() );
346 rRect.SetRight( aPage.Right() );
347 break;
349 case RelOrientation::PAGE_PRINT_AREA:
350 rRect.SetLeft( aPagePrtArea.Left() );
351 rRect.SetRight( aPagePrtArea.Right() );
352 break;
354 case RelOrientation::FRAME_LEFT:
355 rRect.SetLeft( aPara.Left() );
356 rRect.SetRight( aParaPrtArea.Left() );
357 break;
359 case RelOrientation::FRAME_RIGHT:
360 rRect.SetLeft( aParaPrtArea.Right() );
361 rRect.SetRight( aPara.Right() );
362 break;
364 case RelOrientation::CHAR:
365 rRect.SetLeft( aAutoCharFrame.Left() );
366 rRect.SetRight( aAutoCharFrame.Left() );
367 break;
370 switch (nVRel)
372 case RelOrientation::FRAME:
373 rRect.SetTop( aPara.Top() );
374 rRect.SetBottom( aPara.Bottom() );
375 break;
377 case RelOrientation::PRINT_AREA:
378 rRect.SetTop( aParaPrtArea.Top() );
379 rRect.SetBottom( aParaPrtArea.Bottom() );
380 break;
382 case RelOrientation::CHAR:
383 if (nVAlign != VertOrientation::NONE &&
384 nVAlign != VertOrientation::CHAR_BOTTOM)
385 rRect.SetTop( aAutoCharFrame.Top() );
386 else
387 rRect.SetTop( aAutoCharFrame.Bottom() );
388 rRect.SetBottom( aAutoCharFrame.Bottom() );
389 break;
390 // OD 12.11.2003 #i22341#
391 case RelOrientation::TEXT_LINE:
392 rRect.SetTop( aAutoCharFrame.Top() );
393 rRect.SetBottom( aAutoCharFrame.Top() );
394 break;
397 break;
399 case RndStdIds::FLY_AS_CHAR:
400 rRect.SetLeft( aParaPrtArea.Left() );
401 rRect.SetRight( aParaPrtArea.Right() );
403 switch (nVAlign)
405 case VertOrientation::NONE:
406 case VertOrientation::TOP:
407 case VertOrientation::CENTER:
408 case VertOrientation::BOTTOM:
410 FontMetric aMetric(rRenderContext.GetFontMetric());
412 rRect.SetTop( aParaPrtArea.Bottom() - aMetric.GetDescent() );
413 rRect.SetBottom( rRect.Top() );
415 break;
417 default:
419 case VertOrientation::LINE_TOP:
420 case VertOrientation::LINE_CENTER:
421 case VertOrientation::LINE_BOTTOM:
422 rRect.SetTop( aParaPrtArea.Top() );
423 rRect.SetBottom( aDrawObj.Bottom() );
424 break;
426 case VertOrientation::CHAR_TOP:
427 case VertOrientation::CHAR_CENTER:
428 case VertOrientation::CHAR_BOTTOM:
429 rRect.SetTop( aParaPrtArea.Top() );
430 rRect.SetBottom( aParaPrtArea.Bottom() );
431 break;
433 break;
435 default:
436 break;
440 tools::Rectangle SwFrameExample::DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect,
441 const Color &rFillColor, const Color &rBorderColor)
443 DrawRect_Impl(rRenderContext, rRect, rFillColor, rBorderColor);
445 // determine the area relative to which the positioning happens
446 tools::Rectangle aRect(rRect); // aPagePrtArea = Default
447 CalcBoundRect_Impl(rRenderContext, aRect);
449 if (nAnchor == RndStdIds::FLY_AT_FLY && &rRect == &aPagePrtArea)
451 // draw text paragraph
452 tools::Rectangle aTxt(aTextLine);
453 sal_Int32 nStep = aTxt.GetHeight() + 2;
454 sal_uInt16 nLines = static_cast<sal_uInt16>(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
456 for (sal_uInt16 i = 0; i < nLines; i++)
458 if (i == nLines - 1)
459 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
460 DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor);
461 aTxt.Move(0, nStep);
465 return aRect;
468 void SwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
470 rRenderContext.SetMapMode(MapMode(MapUnit::MapPixel));
472 InitAllRects_Impl(rRenderContext);
474 // Draw page
475 DrawRect_Impl(rRenderContext, aPage, m_aBgCol, m_aBorderCol);
477 // Draw PrintArea
478 tools::Rectangle aRect = DrawInnerFrame_Impl(rRenderContext, aPagePrtArea, m_aTransColor, m_aPrintAreaCol);
480 if (nAnchor == RndStdIds::FLY_AT_FLY)
481 aRect = DrawInnerFrame_Impl(rRenderContext, aFrameAtFrame, m_aBgCol, m_aBorderCol);
483 tools::Long lXPos = 0;
484 tools::Long lYPos = 0;
486 // Horizontal alignment
487 if (nAnchor != RndStdIds::FLY_AS_CHAR)
489 switch (nHAlign)
491 case HoriOrientation::RIGHT:
493 lXPos = aRect.Right() - aFrmSize.Width() + 1;
494 break;
496 case HoriOrientation::CENTER:
498 lXPos = aRect.Left() + (aRect.GetWidth() - aFrmSize.Width()) / 2;
499 break;
501 case HoriOrientation::NONE:
503 lXPos = aRect.Left() + aRelPos.X();
504 break;
507 default: // HoriOrientation::LEFT
508 lXPos = aRect.Left();
509 break;
512 else
514 lXPos = aRect.Right() + 2;
517 // Vertical Alignment
518 if (nAnchor != RndStdIds::FLY_AS_CHAR)
520 switch (nVAlign)
522 case VertOrientation::BOTTOM:
523 case VertOrientation::LINE_BOTTOM:
525 // #i22341#
526 if ( nVRel != RelOrientation::TEXT_LINE )
528 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
530 else
532 lYPos = aRect.Top();
534 break;
536 case VertOrientation::CENTER:
537 case VertOrientation::LINE_CENTER:
539 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
540 break;
542 case VertOrientation::NONE:
544 // #i22341#
545 if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE )
546 lYPos = aRect.Top() + aRelPos.Y();
547 else
548 lYPos = aRect.Top() - aRelPos.Y();
549 break;
551 default:
552 // #i22341#
553 if ( nVRel != RelOrientation::TEXT_LINE )
555 lYPos = aRect.Top();
557 else
559 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
561 break;
564 else
566 switch(nVAlign)
568 case VertOrientation::CENTER:
569 case VertOrientation::CHAR_CENTER:
570 case VertOrientation::LINE_CENTER:
571 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
572 break;
574 case VertOrientation::TOP:
575 case VertOrientation::CHAR_BOTTOM:
576 case VertOrientation::LINE_BOTTOM:
577 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
578 break;
580 default:
581 lYPos = aRect.Top() - aRelPos.Y();
582 break;
586 tools::Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize);
588 tools::Rectangle* pOuterFrame = &aPage;
590 if (nAnchor == RndStdIds::FLY_AT_FLY)
591 pOuterFrame = &aFrameAtFrame;
593 if (aFrmRect.Left() < pOuterFrame->Left())
594 aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0);
595 if (aFrmRect.Right() > pOuterFrame->Right())
596 aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0);
598 if (aFrmRect.Top() < pOuterFrame->Top())
599 aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top());
600 if (aFrmRect.Bottom() > pOuterFrame->Bottom())
601 aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom());
603 // Draw Test paragraph
604 const tools::Long nTxtLineHeight = aTextLine.GetHeight();
605 tools::Rectangle aTxt(aTextLine);
606 sal_Int32 nStep;
607 sal_uInt16 nLines;
609 if (nAnchor == RndStdIds::FLY_AT_FLY)
611 aTxt.SetLeft( aFrameAtFrame.Left() + FLYINFLY_BORDER );
612 aTxt.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER );
613 aTxt.SetTop( aFrameAtFrame.Top() + FLYINFLY_BORDER );
614 aTxt.SetBottom( aTxt.Top() + aTextLine.GetHeight() - 1 );
616 nStep = aTxt.GetHeight() + 2;
617 nLines = static_cast<sal_uInt16>(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3)
618 / (aTxt.GetHeight() + 2));
620 else
622 nStep = aTxt.GetHeight() + 2;
623 nLines = static_cast<sal_uInt16>(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
626 if (nAnchor != RndStdIds::FLY_AS_CHAR)
628 // Simulate text
629 const tools::Long nOldR = aTxt.Right();
630 const tools::Long nOldL = aTxt.Left();
632 // #i22341#
633 const bool bIgnoreWrap = nAnchor == RndStdIds::FLY_AT_CHAR &&
634 ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR ||
635 nVRel == RelOrientation::TEXT_LINE );
637 for (sal_uInt16 i = 0; i < nLines; ++i)
639 if (i == (nLines - 1))
640 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
642 if (aTxt.IsOver(aFrmRect) && nAnchor != RndStdIds::FLY_AS_CHAR && !bIgnoreWrap)
644 switch(nWrap)
646 case WrapTextMode_NONE:
647 aTxt.SetTop( aFrmRect.Bottom() + nTxtLineHeight );
648 aTxt.SetBottom( aTxt.Top() + nTxtLineHeight - 1 );
649 break;
651 case WrapTextMode_LEFT:
652 aTxt.SetRight( aFrmRect.Left() );
653 break;
655 case WrapTextMode_RIGHT:
656 aTxt.SetLeft( aFrmRect.Right() );
657 break;
658 default: break;
661 if (pOuterFrame->IsInside(aTxt))
662 DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor );
664 aTxt.Move(0, nStep);
665 aTxt.SetRight( nOldR );
666 aTxt.SetLeft( nOldL );
668 aTxt.Move(0, -nStep);
670 if (nAnchor != RndStdIds::FLY_AT_FLY && aTxt.Bottom() > aParaPrtArea.Bottom())
672 // Text has been replaced by frame, so adjust parameters height
673 sal_Int32 nDiff = aTxt.Bottom() - aParaPrtArea.Bottom();
674 aParaPrtArea.AdjustBottom(nDiff );
675 aPara.AdjustBottom(nDiff );
677 CalcBoundRect_Impl(rRenderContext, aRect);
679 aParaPrtArea.AdjustBottom( -nDiff );
680 aPara.AdjustBottom( -nDiff );
682 if (nAnchor == RndStdIds::FLY_AT_CHAR && bIgnoreWrap)
683 rRenderContext.DrawText(aAutoCharFrame, OUString('A'));
685 else
687 rRenderContext.DrawText(aParaPrtArea, OUString(DEMOTEXT));
688 DrawRect_Impl(rRenderContext, aDrawObj, m_aBlankCol, m_aBlankFrameCol );
691 // Draw rectangle on which the frame is aligned:
692 DrawRect_Impl(rRenderContext, aRect, m_aTransColor, m_aAlignColor);
694 // Frame View
695 bool bDontFill = (nAnchor == RndStdIds::FLY_AT_CHAR && aFrmRect.IsOver(aAutoCharFrame)) || bTrans;
696 DrawRect_Impl(rRenderContext, aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor);
699 void SwFrameExample::SetRelPos(const Point& rP)
701 aRelPos = rP;
703 if (aRelPos.X() > 0)
704 aRelPos.setX( 5 );
705 if (aRelPos.X() < 0)
706 aRelPos.setX( -5 );
708 if (aRelPos.Y() > 0)
709 aRelPos.setY( 5 );
710 if (aRelPos.Y() < 0)
711 aRelPos.setY( -5 );
714 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */