Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / dialog / swframeexample.cxx
bloba4c74611689333a0b026676106aff8ce39bc4702
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 <tools/poly.hxx>
21 #include <vcl/builder.hxx>
22 #include <vcl/metric.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/settings.hxx>
25 #include <svtools/colorcfg.hxx>
26 #include <svx/swframeexample.hxx>
27 #include <com/sun/star/text/TextContentAnchorType.hpp>
28 #include <com/sun/star/text/HoriOrientation.hpp>
29 #include <com/sun/star/text/VertOrientation.hpp>
30 #include <com/sun/star/text/RelOrientation.hpp>
31 #include <com/sun/star/text/WrapTextMode.hpp>
33 using namespace ::com::sun::star::text;
35 #define FLYINFLY_BORDER 3
36 #define DEMOTEXT "Ij"
38 SvxSwFrameExample::SvxSwFrameExample( Window *pParent, WinBits nStyle ) :
40 Window(pParent, nStyle),
42 nHAlign (HoriOrientation::CENTER),
43 nHRel (RelOrientation::FRAME),
44 nVAlign (VertOrientation::TOP),
45 nVRel (RelOrientation::PRINT_AREA),
46 nWrap (WrapTextMode_NONE),
47 nAnchor (TextContentAnchorType_AT_PAGE),
48 bTrans (false),
49 aRelPos (Point(0,0))
51 InitColors_Impl();
52 SetMapMode(MAP_PIXEL);
55 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxSwFrameExample(Window *pParent, VclBuilder::stringmap &)
57 return new SvxSwFrameExample(pParent, 0);
60 Size SvxSwFrameExample::GetOptimalSize() const
62 return LogicToPixel(Size(52, 86), MapMode(MAP_APPFONT));
65 SvxSwFrameExample::~SvxSwFrameExample()
69 void SvxSwFrameExample::InitColors_Impl( void )
71 const StyleSettings& rSettings = GetSettings().GetStyleSettings();
72 m_aBgCol = Color( rSettings.GetWindowColor() );
74 bool bHC = rSettings.GetHighContrastMode();
76 m_aFrameColor = Color( COL_LIGHTGREEN );
77 m_aAlignColor = Color( COL_LIGHTRED );
78 m_aTransColor = Color( COL_TRANSPARENT );
80 m_aTxtCol = bHC?
81 svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor :
82 Color( COL_GRAY );
83 m_aPrintAreaCol = bHC? m_aTxtCol : Color( COL_GRAY );
84 m_aBorderCol = m_aTxtCol;
85 m_aBlankCol = bHC? m_aTxtCol : Color( COL_LIGHTGRAY );
86 m_aBlankFrameCol = bHC? m_aTxtCol : Color( COL_GRAY );
89 void SvxSwFrameExample::DataChanged( const DataChangedEvent& rDCEvt )
91 Window::DataChanged( rDCEvt );
93 if( rDCEvt.GetType() == DATACHANGED_SETTINGS && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
94 InitColors_Impl();
97 void SvxSwFrameExample::InitAllRects_Impl()
99 aPage.SetSize( GetOutputSizePixel() );
101 sal_uIntPtr nOutWPix = aPage.GetWidth();
102 sal_uIntPtr nOutHPix = aPage.GetHeight();
104 // PrintArea
105 sal_uIntPtr nLBorder;
106 sal_uIntPtr nRBorder;
107 sal_uIntPtr nTBorder;
108 sal_uIntPtr nBBorder;
110 sal_uIntPtr nLTxtBorder;
111 sal_uIntPtr nRTxtBorder;
112 sal_uIntPtr nTTxtBorder;
113 sal_uIntPtr nBTxtBorder;
115 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
117 nLBorder = 14;
118 nRBorder = 10;
119 nTBorder = 10;
120 nBBorder = 15;
122 nLTxtBorder = 8;
123 nRTxtBorder = 4;
124 nTTxtBorder = 2;
125 nBTxtBorder = 2;
127 else
129 nLBorder = 2;
130 nRBorder = 2;
131 nTBorder = 2;
132 nBBorder = 2;
134 nLTxtBorder = 2;
135 nRTxtBorder = 2;
136 nTTxtBorder = 2;
137 nBTxtBorder = 2;
139 aPagePrtArea = Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
141 // Example text: Preparing for the text output
142 // A line of text
143 aTextLine = aPagePrtArea;
144 aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
145 aTextLine.Left() += nLTxtBorder;
146 aTextLine.Right() -= nRTxtBorder;
147 aTextLine.Move(0, nTTxtBorder);
149 // Rectangle to edges including paragraph
150 sal_uInt16 nLines = (sal_uInt16)((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder)
151 / (aTextLine.GetHeight() + 2));
152 aPara = aPagePrtArea;
153 aPara.SetSize(Size(aPara.GetWidth(),
154 (aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder));
156 // Rectangle around paragraph without borders
157 aParaPrtArea = aPara;
158 aParaPrtArea.Left() += nLTxtBorder;
159 aParaPrtArea.Right() -= nRTxtBorder;
160 aParaPrtArea.Top() += nTTxtBorder;
161 aParaPrtArea.Bottom() -= nBTxtBorder;
163 if (nAnchor == TextContentAnchorType_AS_CHARACTER || nAnchor == TextContentAnchorType_AT_CHARACTER)
165 Font aFont = OutputDevice::GetDefaultFont(
166 DEFAULTFONT_LATIN_TEXT, Application::GetSettings().GetLanguageTag().getLanguageType(),
167 DEFAULTFONT_FLAGS_ONLYONE, this );
168 aFont.SetColor( m_aTxtCol );
169 aFont.SetFillColor( m_aBgCol );
170 aFont.SetWeight(WEIGHT_NORMAL);
172 if (nAnchor == TextContentAnchorType_AS_CHARACTER)
174 aFont.SetSize(Size(0, aParaPrtArea.GetHeight() - 2));
175 SetFont(aFont);
176 aParaPrtArea.SetSize(Size(GetTextWidth(OUString(DEMOTEXT)), GetTextHeight()));
178 else
180 aFont.SetSize(Size(0, aParaPrtArea.GetHeight() / 2));
181 SetFont(aFont);
182 aAutoCharFrame.SetSize(Size(GetTextWidth(OUString('A')), GetTextHeight()));
183 aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2,
184 aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2));
188 // Inner Frame anchored at the Frame
189 aFrameAtFrame = aPara;
190 aFrameAtFrame.Left() += 9;
191 aFrameAtFrame.Right() -= 5;
192 aFrameAtFrame.Bottom() += 5;
193 aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5));
195 // Size of the frame to be positioned
196 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
198 sal_uIntPtr nLFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nLBorder : nLTxtBorder;
199 sal_uIntPtr nRFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nRBorder : nRTxtBorder;
201 switch (nHRel)
203 case RelOrientation::PAGE_LEFT:
204 case RelOrientation::FRAME_LEFT:
205 aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
206 break;
208 case RelOrientation::PAGE_RIGHT:
209 case RelOrientation::FRAME_RIGHT:
210 aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
211 break;
213 default:
214 aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3);
215 break;
217 aFrmSize.Width() = std::max(5L, aFrmSize.Width());
218 aFrmSize.Height() = std::max(5L, aFrmSize.Height());
220 else
222 sal_uIntPtr nFreeWidth = aPagePrtArea.GetWidth() - GetTextWidth(OUString(DEMOTEXT));
224 aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3);
225 aDrawObj.SetSize(Size(std::max(5L, (long)nFreeWidth / 3L), std::max(5L, aFrmSize.Height() * 3L)));
226 aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2));
227 aParaPrtArea.Right() = aDrawObj.Right();
231 void SvxSwFrameExample::CalcBoundRect_Impl(Rectangle &rRect)
233 switch (nAnchor)
235 case TextContentAnchorType_AT_PAGE:
237 switch (nHRel)
239 case RelOrientation::FRAME:
240 case RelOrientation::PAGE_FRAME:
241 rRect.Left() = aPage.Left();
242 rRect.Right() = aPage.Right();
243 break;
245 case RelOrientation::PRINT_AREA:
246 case RelOrientation::PAGE_PRINT_AREA:
247 rRect.Left() = aPagePrtArea.Left();
248 rRect.Right() = aPagePrtArea.Right();
249 break;
251 case RelOrientation::PAGE_LEFT:
252 rRect.Left() = aPage.Left();
253 rRect.Right() = aPagePrtArea.Left();
254 break;
256 case RelOrientation::PAGE_RIGHT:
257 rRect.Left() = aPagePrtArea.Right();
258 rRect.Right() = aPage.Right();
259 break;
262 switch (nVRel)
264 case RelOrientation::PRINT_AREA:
265 case RelOrientation::PAGE_PRINT_AREA:
266 rRect.Top() = aPagePrtArea.Top();
267 rRect.Bottom() = aPagePrtArea.Bottom();
268 break;
270 case RelOrientation::FRAME:
271 case RelOrientation::PAGE_FRAME:
272 rRect.Top() = aPage.Top();
273 rRect.Bottom() = aPage.Bottom();
274 break;
277 break;
279 case TextContentAnchorType_AT_FRAME:
281 switch (nHRel)
283 case RelOrientation::FRAME:
284 case RelOrientation::PAGE_FRAME:
285 rRect.Left() = aFrameAtFrame.Left();
286 rRect.Right() = aFrameAtFrame.Right();
287 break;
289 case RelOrientation::PRINT_AREA:
290 case RelOrientation::PAGE_PRINT_AREA:
291 rRect.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
292 rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
293 break;
295 case RelOrientation::PAGE_RIGHT:
296 rRect.Left() = aFrameAtFrame.Left();
297 rRect.Right() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
298 break;
300 case RelOrientation::PAGE_LEFT:
301 rRect.Left() = aFrameAtFrame.Right();
302 rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
303 break;
306 switch (nVRel)
308 case RelOrientation::FRAME:
309 case RelOrientation::PAGE_FRAME:
310 rRect.Top() = aFrameAtFrame.Top();
311 rRect.Bottom() = aFrameAtFrame.Bottom();
312 break;
314 case RelOrientation::PRINT_AREA:
315 case RelOrientation::PAGE_PRINT_AREA:
316 rRect.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
317 rRect.Bottom() = aFrameAtFrame.Bottom() - FLYINFLY_BORDER;
318 break;
321 break;
322 case TextContentAnchorType_AT_PARAGRAPH:
323 case TextContentAnchorType_AT_CHARACTER:
325 switch (nHRel)
327 case RelOrientation::FRAME:
328 rRect.Left() = aPara.Left();
329 rRect.Right() = aPara.Right();
330 break;
332 case RelOrientation::PRINT_AREA:
333 rRect.Left() = aParaPrtArea.Left();
334 rRect.Right() = aParaPrtArea.Right();
335 break;
337 case RelOrientation::PAGE_LEFT:
338 rRect.Left() = aPage.Left();
339 rRect.Right() = aPagePrtArea.Left();
340 break;
342 case RelOrientation::PAGE_RIGHT:
343 rRect.Left() = aPagePrtArea.Right();
344 rRect.Right() = aPage.Right();
345 break;
347 case RelOrientation::PAGE_FRAME:
348 rRect.Left() = aPage.Left();
349 rRect.Right() = aPage.Right();
350 break;
352 case RelOrientation::PAGE_PRINT_AREA:
353 rRect.Left() = aPagePrtArea.Left();
354 rRect.Right() = aPagePrtArea.Right();
355 break;
357 case RelOrientation::FRAME_LEFT:
358 rRect.Left() = aPara.Left();
359 rRect.Right() = aParaPrtArea.Left();
360 break;
362 case RelOrientation::FRAME_RIGHT:
363 rRect.Left() = aParaPrtArea.Right();
364 rRect.Right() = aPara.Right();
365 break;
367 case RelOrientation::CHAR:
368 rRect.Left() = aAutoCharFrame.Left();
369 rRect.Right() = aAutoCharFrame.Left();
370 break;
373 switch (nVRel)
375 case RelOrientation::FRAME:
376 rRect.Top() = aPara.Top();
377 rRect.Bottom() = aPara.Bottom();
378 break;
380 case RelOrientation::PRINT_AREA:
381 rRect.Top() = aParaPrtArea.Top();
382 rRect.Bottom() = aParaPrtArea.Bottom();
383 break;
385 case RelOrientation::CHAR:
386 if (nVAlign != VertOrientation::NONE &&
387 nVAlign != VertOrientation::CHAR_BOTTOM)
388 rRect.Top() = aAutoCharFrame.Top();
389 else
390 rRect.Top() = aAutoCharFrame.Bottom();
391 rRect.Bottom() = aAutoCharFrame.Bottom();
392 break;
393 // OD 12.11.2003 #i22341#
394 case RelOrientation::TEXT_LINE:
395 rRect.Top() = aAutoCharFrame.Top();
396 rRect.Bottom() = aAutoCharFrame.Top();
397 break;
400 break;
402 case TextContentAnchorType_AS_CHARACTER:
403 rRect.Left() = aParaPrtArea.Left();
404 rRect.Right() = aParaPrtArea.Right();
406 switch (nVAlign)
408 case VertOrientation::NONE:
409 case VertOrientation::TOP:
410 case VertOrientation::CENTER:
411 case VertOrientation::BOTTOM:
413 FontMetric aMetric(GetFontMetric());
415 rRect.Top() = aParaPrtArea.Bottom() - aMetric.GetDescent();
416 rRect.Bottom() = rRect.Top();
418 break;
420 default:
422 case VertOrientation::LINE_TOP:
423 case VertOrientation::LINE_CENTER:
424 case VertOrientation::LINE_BOTTOM:
425 rRect.Top() = aParaPrtArea.Top();
426 rRect.Bottom() = aDrawObj.Bottom();
427 break;
429 case VertOrientation::CHAR_TOP:
430 case VertOrientation::CHAR_CENTER:
431 case VertOrientation::CHAR_BOTTOM:
432 rRect.Top() = aParaPrtArea.Top();
433 rRect.Bottom() = aParaPrtArea.Bottom();
434 break;
436 break;
438 default:
439 break;
443 Rectangle SvxSwFrameExample::DrawInnerFrame_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor)
445 DrawRect_Impl(rRect, rFillColor, rBorderColor);
447 // Bereich, zu dem relativ positioniert wird, bestimmen
448 Rectangle aRect(rRect); // aPagePrtArea = Default
449 CalcBoundRect_Impl(aRect);
451 if (nAnchor == TextContentAnchorType_AT_FRAME && &rRect == &aPagePrtArea)
453 // Testabsatz zeichnen
454 Rectangle aTxt(aTextLine);
455 sal_Int32 nStep = aTxt.GetHeight() + 2;
456 sal_uInt16 nLines = (sal_uInt16)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
458 for (sal_uInt16 i = 0; i < nLines; i++)
460 if (i == nLines - 1)
461 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
462 DrawRect_Impl(aTxt, m_aTxtCol, m_aTransColor);
463 aTxt.Move(0, nStep);
467 return aRect;
470 void SvxSwFrameExample::Paint(const Rectangle&)
472 InitAllRects_Impl();
474 // Draw page
475 DrawRect_Impl( aPage, m_aBgCol, m_aBorderCol );
477 // Draw PrintArea
478 Rectangle aRect = DrawInnerFrame_Impl( aPagePrtArea, m_aTransColor, m_aPrintAreaCol );
480 if (nAnchor == TextContentAnchorType_AT_FRAME)
481 aRect = DrawInnerFrame_Impl( aFrameAtFrame, m_aBgCol, m_aBorderCol );
483 long lXPos = 0;
484 long lYPos = 0;
486 // Horizontal alignment
487 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
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
513 lXPos = aRect.Right() + 2;
515 // Vertical Alignment
516 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
518 switch (nVAlign)
520 case VertOrientation::BOTTOM:
521 case VertOrientation::LINE_BOTTOM:
523 // #i22341#
524 if ( nVRel != RelOrientation::TEXT_LINE )
526 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
528 else
530 lYPos = aRect.Top();
532 break;
534 case VertOrientation::CENTER:
535 case VertOrientation::LINE_CENTER:
537 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
538 break;
540 case VertOrientation::NONE:
542 // #i22341#
543 if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE )
544 lYPos = aRect.Top() + aRelPos.Y();
545 else
546 lYPos = aRect.Top() - aRelPos.Y();
547 break;
549 default:
550 // #i22341#
551 if ( nVRel != RelOrientation::TEXT_LINE )
553 lYPos = aRect.Top();
555 else
557 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
559 break;
562 else
564 switch(nVAlign)
566 case VertOrientation::CENTER:
567 case VertOrientation::CHAR_CENTER:
568 case VertOrientation::LINE_CENTER:
569 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
570 break;
572 case VertOrientation::TOP:
573 case VertOrientation::CHAR_BOTTOM:
574 case VertOrientation::LINE_BOTTOM:
575 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
576 break;
578 default:
579 lYPos = aRect.Top() - aRelPos.Y();
580 break;
584 Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize);
586 Rectangle *pOuterFrame = &aPage;
588 if (nAnchor == TextContentAnchorType_AT_FRAME)
589 pOuterFrame = &aFrameAtFrame;
591 if (aFrmRect.Left() < pOuterFrame->Left())
592 aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0);
593 if (aFrmRect.Right() > pOuterFrame->Right())
594 aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0);
596 if (aFrmRect.Top() < pOuterFrame->Top())
597 aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top());
598 if (aFrmRect.Bottom() > pOuterFrame->Bottom())
599 aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom());
601 // Draw Test paragraph
602 const long nTxtLineHeight = aTextLine.GetHeight();
603 Rectangle aTxt(aTextLine);
604 sal_Int32 nStep;
605 sal_uInt16 nLines;
607 if (nAnchor == TextContentAnchorType_AT_FRAME)
609 aTxt.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
610 aTxt.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
611 aTxt.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
612 aTxt.Bottom() = aTxt.Top() + aTextLine.GetHeight() - 1;
614 nStep = aTxt.GetHeight() + 2;
615 nLines = (sal_uInt16)(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3)
616 / (aTxt.GetHeight() + 2));
618 else
620 nStep = aTxt.GetHeight() + 2;
621 nLines = (sal_uInt16)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
624 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
626 // Simulate text
627 const long nOldR = aTxt.Right();
628 const long nOldL = aTxt.Left();
630 // #i22341#
631 const bool bIgnoreWrap = nAnchor == TextContentAnchorType_AT_CHARACTER &&
632 ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR ||
633 nVRel == RelOrientation::TEXT_LINE );
635 for (sal_uInt16 i = 0; i < nLines; ++i)
637 if (i == (nLines - 1))
638 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
640 if (aTxt.IsOver(aFrmRect) && nAnchor != TextContentAnchorType_AS_CHARACTER && !bIgnoreWrap)
642 switch(nWrap)
644 case WrapTextMode_NONE:
645 aTxt.Top() = aFrmRect.Bottom() + nTxtLineHeight;
646 aTxt.Bottom() = aTxt.Top() + nTxtLineHeight - 1;
647 break;
649 case WrapTextMode_LEFT:
650 aTxt.Right() = aFrmRect.Left();
651 break;
653 case WrapTextMode_RIGHT:
654 aTxt.Left() = aFrmRect.Right();
655 break;
658 if (pOuterFrame->IsInside(aTxt))
659 DrawRect_Impl( aTxt, m_aTxtCol, m_aTransColor );
661 aTxt.Move(0, nStep);
662 aTxt.Right() = nOldR;
663 aTxt.Left() = nOldL;
665 aTxt.Move(0, -nStep);
667 if (nAnchor != TextContentAnchorType_AT_FRAME && aTxt.Bottom() > aParaPrtArea.Bottom())
669 // Text has been replaced by frame, so adjust parameters height
670 sal_uIntPtr nDiff = aTxt.Bottom() - aParaPrtArea.Bottom();
671 aParaPrtArea.Bottom() += nDiff;
672 aPara.Bottom() += nDiff;
674 CalcBoundRect_Impl(aRect);
676 aParaPrtArea.Bottom() -= nDiff;
677 aPara.Bottom() -= nDiff;
679 if (nAnchor == TextContentAnchorType_AT_CHARACTER && bIgnoreWrap)
680 DrawText(aAutoCharFrame, OUString('A'));
682 else
684 DrawText(aParaPrtArea, OUString(DEMOTEXT));
685 DrawRect_Impl(aDrawObj, m_aBlankCol, m_aBlankFrameCol );
688 // Draw rectangle on which the frame is aligned:
689 DrawRect_Impl(aRect, m_aTransColor, m_aAlignColor);
691 // Frame View
692 bool bDontFill = (nAnchor == TextContentAnchorType_AT_CHARACTER && aFrmRect.IsOver(aAutoCharFrame)) ? sal_True : bTrans;
693 DrawRect_Impl( aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor );
696 void SvxSwFrameExample::SetRelPos(const Point& rP)
698 aRelPos = rP;
700 if (aRelPos.X() > 0)
701 aRelPos.X() = 5;
702 if (aRelPos.X() < 0)
703 aRelPos.X() = -5;
705 if (aRelPos.Y() > 0)
706 aRelPos.Y() = 5;
707 if (aRelPos.Y() < 0)
708 aRelPos.Y() = -5;
711 void SvxSwFrameExample::DrawRect_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor)
713 SetFillColor(rFillColor);
714 SetLineColor(rLineColor);
715 Window::DrawRect(rRect);
720 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */