Update ooo320-m1
[ooovba.git] / svx / source / dialog / swframeexample.cxx
blobfc72b665adf677748114b1fd6a6420cd7f6ba887
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swframeexample.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
35 #include <tools/poly.hxx>
36 #include <vcl/metric.hxx>
37 #include <vcl/svapp.hxx>
38 #include <svtools/colorcfg.hxx>
39 #include <swframeexample.hxx>
40 #include <com/sun/star/text/TextContentAnchorType.hpp>
41 #include <com/sun/star/text/HoriOrientation.hpp>
42 #include <com/sun/star/text/VertOrientation.hpp>
43 #include <com/sun/star/text/RelOrientation.hpp>
44 #include <com/sun/star/text/WrapTextMode.hpp>
46 using namespace ::com::sun::star::text;
48 #define FLYINFLY_BORDER 3
49 #define DEMOTEXT "Ij"
50 #define C2S(cChar) UniString::CreateFromAscii(cChar)
53 SvxSwFrameExample::SvxSwFrameExample( Window *pParent, const ResId& rResID ) :
55 Window(pParent, rResID),
57 nHAlign (HoriOrientation::CENTER),
58 nHRel (RelOrientation::FRAME),
59 nVAlign (VertOrientation::TOP),
60 nVRel (RelOrientation::PRINT_AREA),
61 nWrap (WrapTextMode_NONE),
62 nAnchor (TextContentAnchorType_AT_PAGE),
63 bTrans (FALSE),
64 aRelPos (Point(0,0))
66 InitColors_Impl();
67 SetMapMode(MAP_PIXEL);
70 SvxSwFrameExample::~SvxSwFrameExample()
74 void SvxSwFrameExample::InitColors_Impl( void )
76 const StyleSettings& rSettings = GetSettings().GetStyleSettings();
77 m_aBgCol = Color( rSettings.GetWindowColor() ); // old: COL_WHITE
79 BOOL bHC = m_aBgCol.IsDark();
81 m_aFrameColor = Color( COL_LIGHTGREEN );
82 m_aAlignColor = Color( COL_LIGHTRED );
83 m_aTransColor = Color( COL_TRANSPARENT );
85 m_aTxtCol = bHC?
86 svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor :
87 Color( COL_GRAY ); // old: COL_GRAY
88 m_aPrintAreaCol = bHC? m_aTxtCol : Color( COL_GRAY );
89 m_aBorderCol = m_aTxtCol; // old: COL_BLACK;
90 m_aBlankCol = bHC? m_aTxtCol : Color( COL_LIGHTGRAY );
91 m_aBlankFrameCol = bHC? m_aTxtCol : Color( COL_GRAY );
94 void SvxSwFrameExample::DataChanged( const DataChangedEvent& rDCEvt )
96 Window::DataChanged( rDCEvt );
98 if( rDCEvt.GetType() == DATACHANGED_SETTINGS && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
99 InitColors_Impl();
102 void SvxSwFrameExample::InitAllRects_Impl()
104 // const Size aSz(GetOutputSizePixel());
106 // Seite
107 // aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3));
108 aPage.SetSize( GetOutputSizePixel() );
110 ULONG nOutWPix = aPage.GetWidth();
111 ULONG nOutHPix = aPage.GetHeight();
113 // PrintArea
114 ULONG nLBorder;
115 ULONG nRBorder;
116 ULONG nTBorder;
117 ULONG nBBorder;
119 ULONG nLTxtBorder;
120 ULONG nRTxtBorder;
121 ULONG nTTxtBorder;
122 ULONG nBTxtBorder;
124 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
126 nLBorder = 14;
127 nRBorder = 10;
128 nTBorder = 10;
129 nBBorder = 15;
131 nLTxtBorder = 8;
132 nRTxtBorder = 4;
133 nTTxtBorder = 2;
134 nBTxtBorder = 2;
136 else
138 nLBorder = 2;
139 nRBorder = 2;
140 nTBorder = 2;
141 nBBorder = 2;
143 nLTxtBorder = 2;
144 nRTxtBorder = 2;
145 nTTxtBorder = 2;
146 nBTxtBorder = 2;
148 aPagePrtArea = Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
150 // Beispiel-Text: Vorbereiten fuer die Textausgabe
151 // Eine Textzeile
152 aTextLine = aPagePrtArea;
153 aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
154 aTextLine.Left() += nLTxtBorder;
155 aTextLine.Right() -= nRTxtBorder;
156 aTextLine.Move(0, nTTxtBorder);
158 // Rechteck um Absatz incl. Raender
159 USHORT nLines = (USHORT)((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder)
160 / (aTextLine.GetHeight() + 2));
161 aPara = aPagePrtArea;
162 aPara.SetSize(Size(aPara.GetWidth(),
163 (aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder));
165 // Rechteck um Absatz ohne Raender
166 aParaPrtArea = aPara;
167 aParaPrtArea.Left() += nLTxtBorder;
168 aParaPrtArea.Right() -= nRTxtBorder;
169 aParaPrtArea.Top() += nTTxtBorder;
170 aParaPrtArea.Bottom() -= nBTxtBorder;
172 if (nAnchor == TextContentAnchorType_AS_CHARACTER || nAnchor == TextContentAnchorType_AT_CHARACTER)
174 Font aFont = OutputDevice::GetDefaultFont(
175 DEFAULTFONT_LATIN_TEXT, Application::GetSettings().GetLanguage(),
176 DEFAULTFONT_FLAGS_ONLYONE, this );
177 aFont.SetColor( m_aTxtCol );
178 aFont.SetFillColor( m_aBgCol );
179 aFont.SetWeight(WEIGHT_NORMAL);
181 if (nAnchor == TextContentAnchorType_AS_CHARACTER)
183 aFont.SetSize(Size(0, aParaPrtArea.GetHeight() - 2));
184 SetFont(aFont);
185 aParaPrtArea.SetSize(Size(GetTextWidth(C2S(DEMOTEXT)), GetTextHeight()));
187 else
189 aFont.SetSize(Size(0, aParaPrtArea.GetHeight() / 2));
190 SetFont(aFont);
191 aAutoCharFrame.SetSize(Size(GetTextWidth('A'), GetTextHeight()));
192 aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2,
193 aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2));
197 // Innerer Frame fuer am Frame verankerte Rahmen
198 aFrameAtFrame = aPara;
199 aFrameAtFrame.Left() += 9;
200 aFrameAtFrame.Right() -= 5;
201 aFrameAtFrame.Bottom() += 5;
202 aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5));
204 // Groesse des zu positionierenden Rahmens
205 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
207 ULONG nLFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nLBorder : nLTxtBorder;
208 ULONG nRFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nRBorder : nRTxtBorder;
210 switch (nHRel)
212 case RelOrientation::PAGE_LEFT:
213 case RelOrientation::FRAME_LEFT:
214 aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
215 break;
217 case RelOrientation::PAGE_RIGHT:
218 case RelOrientation::FRAME_RIGHT:
219 aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
220 break;
222 default:
223 aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3);
224 break;
226 aFrmSize.Width() = Max(5L, aFrmSize.Width());
227 aFrmSize.Height() = Max(5L, aFrmSize.Height());
229 else
231 ULONG nFreeWidth = aPagePrtArea.GetWidth() - GetTextWidth(C2S(DEMOTEXT));
233 aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3);
234 aDrawObj.SetSize(Size(Max(5L, (long)nFreeWidth / 3L), Max(5L, aFrmSize.Height() * 3L)));
235 aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2));
236 aParaPrtArea.Right() = aDrawObj.Right();
240 void SvxSwFrameExample::CalcBoundRect_Impl(Rectangle &rRect)
242 switch (nAnchor)
244 case TextContentAnchorType_AT_PAGE:
246 switch (nHRel)
248 case RelOrientation::FRAME:
249 case RelOrientation::PAGE_FRAME:
250 rRect.Left() = aPage.Left();
251 rRect.Right() = aPage.Right();
252 break;
254 case RelOrientation::PRINT_AREA:
255 case RelOrientation::PAGE_PRINT_AREA:
256 rRect.Left() = aPagePrtArea.Left();
257 rRect.Right() = aPagePrtArea.Right();
258 break;
260 case RelOrientation::PAGE_LEFT:
261 rRect.Left() = aPage.Left();
262 rRect.Right() = aPagePrtArea.Left();
263 break;
265 case RelOrientation::PAGE_RIGHT:
266 rRect.Left() = aPagePrtArea.Right();
267 rRect.Right() = aPage.Right();
268 break;
271 switch (nVRel)
273 case RelOrientation::PRINT_AREA:
274 case RelOrientation::PAGE_PRINT_AREA:
275 rRect.Top() = aPagePrtArea.Top();
276 rRect.Bottom() = aPagePrtArea.Bottom();
277 break;
279 case RelOrientation::FRAME:
280 case RelOrientation::PAGE_FRAME:
281 rRect.Top() = aPage.Top();
282 rRect.Bottom() = aPage.Bottom();
283 break;
286 break;
288 case TextContentAnchorType_AT_FRAME:
290 switch (nHRel)
292 case RelOrientation::FRAME:
293 case RelOrientation::PAGE_FRAME:
294 rRect.Left() = aFrameAtFrame.Left();
295 rRect.Right() = aFrameAtFrame.Right();
296 break;
298 case RelOrientation::PRINT_AREA:
299 case RelOrientation::PAGE_PRINT_AREA:
300 rRect.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
301 rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
302 break;
304 case RelOrientation::PAGE_RIGHT:
305 rRect.Left() = aFrameAtFrame.Left();
306 rRect.Right() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
307 break;
309 case RelOrientation::PAGE_LEFT:
310 rRect.Left() = aFrameAtFrame.Right();
311 rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
312 break;
315 switch (nVRel)
317 case RelOrientation::FRAME:
318 case RelOrientation::PAGE_FRAME:
319 rRect.Top() = aFrameAtFrame.Top();
320 rRect.Bottom() = aFrameAtFrame.Bottom();
321 break;
323 case RelOrientation::PRINT_AREA:
324 case RelOrientation::PAGE_PRINT_AREA:
325 rRect.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
326 rRect.Bottom() = aFrameAtFrame.Bottom() - FLYINFLY_BORDER;
327 break;
330 break;
331 case TextContentAnchorType_AT_PARAGRAPH:
332 case TextContentAnchorType_AT_CHARACTER:
334 switch (nHRel)
336 case RelOrientation::FRAME:
337 rRect.Left() = aPara.Left();
338 rRect.Right() = aPara.Right();
339 break;
341 case RelOrientation::PRINT_AREA:
342 rRect.Left() = aParaPrtArea.Left();
343 rRect.Right() = aParaPrtArea.Right();
344 break;
346 case RelOrientation::PAGE_LEFT:
347 rRect.Left() = aPage.Left();
348 rRect.Right() = aPagePrtArea.Left();
349 break;
351 case RelOrientation::PAGE_RIGHT:
352 rRect.Left() = aPagePrtArea.Right();
353 rRect.Right() = aPage.Right();
354 break;
356 case RelOrientation::PAGE_FRAME:
357 rRect.Left() = aPage.Left();
358 rRect.Right() = aPage.Right();
359 break;
361 case RelOrientation::PAGE_PRINT_AREA:
362 rRect.Left() = aPagePrtArea.Left();
363 rRect.Right() = aPagePrtArea.Right();
364 break;
366 case RelOrientation::FRAME_LEFT:
367 rRect.Left() = aPara.Left();
368 rRect.Right() = aParaPrtArea.Left();
369 break;
371 case RelOrientation::FRAME_RIGHT:
372 rRect.Left() = aParaPrtArea.Right();
373 rRect.Right() = aPara.Right();
374 break;
376 case RelOrientation::CHAR:
377 rRect.Left() = aAutoCharFrame.Left();
378 rRect.Right() = aAutoCharFrame.Left();
379 break;
382 switch (nVRel)
384 case RelOrientation::FRAME:
385 rRect.Top() = aPara.Top();
386 rRect.Bottom() = aPara.Bottom();
387 break;
389 case RelOrientation::PRINT_AREA:
390 rRect.Top() = aParaPrtArea.Top();
391 rRect.Bottom() = aParaPrtArea.Bottom();
392 break;
394 case RelOrientation::CHAR:
395 if (nVAlign != VertOrientation::NONE &&
396 nVAlign != VertOrientation::CHAR_BOTTOM)
397 rRect.Top() = aAutoCharFrame.Top();
398 else
399 rRect.Top() = aAutoCharFrame.Bottom();
400 rRect.Bottom() = aAutoCharFrame.Bottom();
401 break;
402 // OD 12.11.2003 #i22341#
403 case RelOrientation::TEXT_LINE:
404 rRect.Top() = aAutoCharFrame.Top();
405 rRect.Bottom() = aAutoCharFrame.Top();
406 break;
409 break;
411 case TextContentAnchorType_AS_CHARACTER:
412 rRect.Left() = aParaPrtArea.Left();
413 rRect.Right() = aParaPrtArea.Right();
415 switch (nVAlign)
417 case VertOrientation::NONE:
418 case VertOrientation::TOP:
419 case VertOrientation::CENTER:
420 case VertOrientation::BOTTOM:
422 FontMetric aMetric(GetFontMetric());
424 rRect.Top() = aParaPrtArea.Bottom() - aMetric.GetDescent();
425 rRect.Bottom() = rRect.Top();
427 break;
429 default:
431 case VertOrientation::LINE_TOP:
432 case VertOrientation::LINE_CENTER:
433 case VertOrientation::LINE_BOTTOM:
434 rRect.Top() = aParaPrtArea.Top();
435 rRect.Bottom() = aDrawObj.Bottom();
436 break;
438 case VertOrientation::CHAR_TOP:
439 case VertOrientation::CHAR_CENTER:
440 case VertOrientation::CHAR_BOTTOM:
441 rRect.Top() = aParaPrtArea.Top();
442 rRect.Bottom() = aParaPrtArea.Bottom();
443 break;
445 break;
447 default:
448 break;
452 Rectangle SvxSwFrameExample::DrawInnerFrame_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor)
454 DrawRect_Impl(rRect, rFillColor, rBorderColor);
456 // Bereich, zu dem relativ positioniert wird, bestimmen
457 Rectangle aRect(rRect); // aPagePrtArea = Default
458 CalcBoundRect_Impl(aRect);
460 if (nAnchor == TextContentAnchorType_AT_FRAME && &rRect == &aPagePrtArea)
462 // Testabsatz zeichnen
463 Rectangle aTxt(aTextLine);
464 sal_Int32 nStep = aTxt.GetHeight() + 2;
465 USHORT nLines = (USHORT)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
467 for (USHORT i = 0; i < nLines; i++)
469 if (i == nLines - 1)
470 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
471 DrawRect_Impl(aTxt, m_aTxtCol, m_aTransColor);
472 aTxt.Move(0, nStep);
476 return aRect;
479 void SvxSwFrameExample::Paint(const Rectangle&)
481 InitAllRects_Impl();
483 // Schatten zeichnen
484 // Rectangle aShadow(aPage);
485 // aShadow += Point(3, 3);
486 // DrawRect_Impl(aShadow, Color(COL_GRAY), aTransColor);
488 // Seite zeichnen
489 DrawRect_Impl( aPage, m_aBgCol, m_aBorderCol );
491 // PrintArea zeichnen
492 Rectangle aRect = DrawInnerFrame_Impl( aPagePrtArea, m_aTransColor, m_aPrintAreaCol );
494 if (nAnchor == TextContentAnchorType_AT_FRAME)
495 aRect = DrawInnerFrame_Impl( aFrameAtFrame, m_aBgCol, m_aBorderCol );
497 long lXPos = 0;
498 long lYPos = 0;
500 // Horizontale Ausrichtung
502 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
504 switch (nHAlign)
506 case HoriOrientation::RIGHT:
508 lXPos = aRect.Right() - aFrmSize.Width() + 1;
509 break;
511 case HoriOrientation::CENTER:
513 lXPos = aRect.Left() + (aRect.GetWidth() - aFrmSize.Width()) / 2;
514 break;
516 case HoriOrientation::NONE:
518 lXPos = aRect.Left() + aRelPos.X();
519 break;
522 default: // HoriOrientation::LEFT
523 lXPos = aRect.Left();
524 break;
527 else
528 lXPos = aRect.Right() + 2;
530 // Vertikale Ausrichtung
532 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
534 switch (nVAlign)
536 case VertOrientation::BOTTOM:
537 case VertOrientation::LINE_BOTTOM:
539 // OD 12.11.2003 #i22341#
540 if ( nVRel != RelOrientation::TEXT_LINE )
542 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
544 else
546 lYPos = aRect.Top();
548 break;
550 case VertOrientation::CENTER:
551 case VertOrientation::LINE_CENTER:
553 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
554 break;
556 case VertOrientation::NONE:
558 // OD 12.11.2003 #i22341#
559 if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE )
560 lYPos = aRect.Top() + aRelPos.Y();
561 else
562 lYPos = aRect.Top() - aRelPos.Y();
563 break;
565 default:
566 // OD 12.11.2003 #i22341#
567 if ( nVRel != RelOrientation::TEXT_LINE )
569 lYPos = aRect.Top();
571 else
573 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
575 break;
578 else
580 switch(nVAlign)
582 case VertOrientation::CENTER:
583 case VertOrientation::CHAR_CENTER:
584 case VertOrientation::LINE_CENTER:
585 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
586 break;
588 case VertOrientation::TOP:
589 case VertOrientation::CHAR_BOTTOM:
590 case VertOrientation::LINE_BOTTOM:
591 lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
592 break;
594 /* case VertOrientation::NONE:
595 case VertOrientation::BOTTOM:
596 case VertOrientation::CHAR_TOP:
597 case VertOrientation::LINE_TOP:*/
598 default:
599 lYPos = aRect.Top() - aRelPos.Y();
600 break;
604 Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize);
606 Rectangle *pOuterFrame = &aPage;
608 if (nAnchor == TextContentAnchorType_AT_FRAME)
609 pOuterFrame = &aFrameAtFrame;
611 if (aFrmRect.Left() < pOuterFrame->Left())
612 aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0);
613 if (aFrmRect.Right() > pOuterFrame->Right())
614 aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0);
616 if (aFrmRect.Top() < pOuterFrame->Top())
617 aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top());
618 if (aFrmRect.Bottom() > pOuterFrame->Bottom())
619 aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom());
621 // Testabsatz zeichnen
622 const long nTxtLineHeight = aTextLine.GetHeight();
623 Rectangle aTxt(aTextLine);
624 sal_Int32 nStep;
625 USHORT nLines;
627 if (nAnchor == TextContentAnchorType_AT_FRAME)
629 aTxt.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
630 aTxt.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
631 aTxt.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
632 aTxt.Bottom() = aTxt.Top() + aTextLine.GetHeight() - 1;
634 nStep = aTxt.GetHeight() + 2;
635 nLines = (USHORT)(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3)
636 / (aTxt.GetHeight() + 2));
638 else
640 nStep = aTxt.GetHeight() + 2;
641 nLines = (USHORT)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
644 if (nAnchor != TextContentAnchorType_AS_CHARACTER)
646 // Text simulieren
648 const long nOldR = aTxt.Right();
649 const long nOldL = aTxt.Left();
651 // OD 12.11.2003 #i22341#
652 const bool bIgnoreWrap = nAnchor == TextContentAnchorType_AT_CHARACTER &&
653 ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR ||
654 nVRel == RelOrientation::TEXT_LINE );
656 for (USHORT i = 0; i < nLines; ++i)
658 if (i == (nLines - 1))
659 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
661 if (aTxt.IsOver(aFrmRect) && nAnchor != TextContentAnchorType_AS_CHARACTER && !bIgnoreWrap)
663 switch(nWrap)
665 case WrapTextMode_NONE:
666 aTxt.Top() = aFrmRect.Bottom() + nTxtLineHeight;
667 aTxt.Bottom() = aTxt.Top() + nTxtLineHeight - 1;
668 break;
670 case WrapTextMode_LEFT:
671 aTxt.Right() = aFrmRect.Left();
672 break;
674 case WrapTextMode_RIGHT:
675 aTxt.Left() = aFrmRect.Right();
676 break;
679 if (pOuterFrame->IsInside(aTxt))
680 DrawRect_Impl( aTxt, m_aTxtCol, m_aTransColor );
682 aTxt.Move(0, nStep);
683 aTxt.Right() = nOldR;
684 aTxt.Left() = nOldL;
686 aTxt.Move(0, -nStep);
688 if (nAnchor != TextContentAnchorType_AT_FRAME && aTxt.Bottom() > aParaPrtArea.Bottom())
690 // Text wurde durch Rahmen verdraengt, daher Para-Hoehe anpassen
691 ULONG nDiff = aTxt.Bottom() - aParaPrtArea.Bottom();
692 aParaPrtArea.Bottom() += nDiff;
693 aPara.Bottom() += nDiff;
695 CalcBoundRect_Impl(aRect);
697 aParaPrtArea.Bottom() -= nDiff;
698 aPara.Bottom() -= nDiff;
700 if (nAnchor == TextContentAnchorType_AT_CHARACTER && bIgnoreWrap)
701 DrawText(aAutoCharFrame, 'A');
703 else
705 DrawText(aParaPrtArea, C2S(DEMOTEXT));
706 DrawRect_Impl(aDrawObj, m_aBlankCol, m_aBlankFrameCol );
709 // Rechteck zeichnen, zu dem der Rahmen ausgerichtet wird:
710 DrawRect_Impl(aRect, m_aTransColor, m_aAlignColor);
712 // Frame anzeigen
713 BOOL bDontFill = (nAnchor == TextContentAnchorType_AT_CHARACTER && aFrmRect.IsOver(aAutoCharFrame)) ? TRUE : bTrans;
714 DrawRect_Impl( aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor );
717 void SvxSwFrameExample::SetRelPos(const Point& rP)
719 aRelPos = rP;
721 if (aRelPos.X() > 0)
722 aRelPos.X() = 5;
723 if (aRelPos.X() < 0)
724 aRelPos.X() = -5;
726 if (aRelPos.Y() > 0)
727 aRelPos.Y() = 5;
728 if (aRelPos.Y() < 0)
729 aRelPos.Y() = -5;
732 void SvxSwFrameExample::DrawRect_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor)
734 SetFillColor(rFillColor);
735 SetLineColor(rLineColor);
736 Window::DrawRect(rRect);