1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <tools/poly.hxx>
33*cdf0e10cSrcweir #include <vcl/metric.hxx>
34*cdf0e10cSrcweir #include <vcl/svapp.hxx>
35*cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
36*cdf0e10cSrcweir #include <svx/swframeexample.hxx>
37*cdf0e10cSrcweir #include <com/sun/star/text/TextContentAnchorType.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/text/VertOrientation.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/text/RelOrientation.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/text/WrapTextMode.hpp>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using namespace ::com::sun::star::text;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #define FLYINFLY_BORDER 3
46*cdf0e10cSrcweir #define DEMOTEXT		"Ij"
47*cdf0e10cSrcweir #define C2S(cChar) UniString::CreateFromAscii(cChar)
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir SvxSwFrameExample::SvxSwFrameExample( Window *pParent, const ResId& rResID ) :
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 	Window(pParent, rResID),
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir     nHAlign     (HoriOrientation::CENTER),
55*cdf0e10cSrcweir     nHRel       (RelOrientation::FRAME),
56*cdf0e10cSrcweir     nVAlign     (VertOrientation::TOP),
57*cdf0e10cSrcweir     nVRel       (RelOrientation::PRINT_AREA),
58*cdf0e10cSrcweir     nWrap       (WrapTextMode_NONE),
59*cdf0e10cSrcweir     nAnchor     (TextContentAnchorType_AT_PAGE),
60*cdf0e10cSrcweir     bTrans      (sal_False),
61*cdf0e10cSrcweir     aRelPos     (Point(0,0))
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir     InitColors_Impl();
64*cdf0e10cSrcweir 	SetMapMode(MAP_PIXEL);
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir SvxSwFrameExample::~SvxSwFrameExample()
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir void SvxSwFrameExample::InitColors_Impl( void )
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir 	const StyleSettings& rSettings = GetSettings().GetStyleSettings();
74*cdf0e10cSrcweir 	m_aBgCol = Color( rSettings.GetWindowColor() );								// old: COL_WHITE
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	sal_Bool bHC = rSettings.GetHighContrastMode();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	m_aFrameColor = Color( COL_LIGHTGREEN );
79*cdf0e10cSrcweir 	m_aAlignColor = Color( COL_LIGHTRED );
80*cdf0e10cSrcweir 	m_aTransColor = Color( COL_TRANSPARENT );
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     m_aTxtCol = bHC?
83*cdf0e10cSrcweir         svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor :
84*cdf0e10cSrcweir         Color( COL_GRAY );      // old: COL_GRAY
85*cdf0e10cSrcweir 	m_aPrintAreaCol = bHC? m_aTxtCol : Color( COL_GRAY );
86*cdf0e10cSrcweir 	m_aBorderCol = m_aTxtCol;													// old: COL_BLACK;
87*cdf0e10cSrcweir 	m_aBlankCol = bHC? m_aTxtCol : Color( COL_LIGHTGRAY );
88*cdf0e10cSrcweir 	m_aBlankFrameCol = bHC? m_aTxtCol : Color( COL_GRAY );
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir void SvxSwFrameExample::DataChanged( const DataChangedEvent& rDCEvt )
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir 	Window::DataChanged( rDCEvt );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	if( rDCEvt.GetType() == DATACHANGED_SETTINGS && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
96*cdf0e10cSrcweir         InitColors_Impl();
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir void SvxSwFrameExample::InitAllRects_Impl()
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir //    const Size aSz(GetOutputSizePixel());
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	// Seite
104*cdf0e10cSrcweir //    aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3));
105*cdf0e10cSrcweir     aPage.SetSize( GetOutputSizePixel() );
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	sal_uIntPtr nOutWPix = aPage.GetWidth();
108*cdf0e10cSrcweir 	sal_uIntPtr nOutHPix = aPage.GetHeight();
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 	// PrintArea
111*cdf0e10cSrcweir 	sal_uIntPtr nLBorder;
112*cdf0e10cSrcweir 	sal_uIntPtr nRBorder;
113*cdf0e10cSrcweir 	sal_uIntPtr nTBorder;
114*cdf0e10cSrcweir 	sal_uIntPtr nBBorder;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	sal_uIntPtr nLTxtBorder;
117*cdf0e10cSrcweir 	sal_uIntPtr nRTxtBorder;
118*cdf0e10cSrcweir 	sal_uIntPtr nTTxtBorder;
119*cdf0e10cSrcweir 	sal_uIntPtr nBTxtBorder;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     if (nAnchor != TextContentAnchorType_AS_CHARACTER)
122*cdf0e10cSrcweir 	{
123*cdf0e10cSrcweir 		nLBorder = 14;
124*cdf0e10cSrcweir 		nRBorder = 10;
125*cdf0e10cSrcweir 		nTBorder = 10;
126*cdf0e10cSrcweir 		nBBorder = 15;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 		nLTxtBorder = 8;
129*cdf0e10cSrcweir 		nRTxtBorder = 4;
130*cdf0e10cSrcweir 		nTTxtBorder = 2;
131*cdf0e10cSrcweir 		nBTxtBorder = 2;
132*cdf0e10cSrcweir 	}
133*cdf0e10cSrcweir 	else
134*cdf0e10cSrcweir 	{
135*cdf0e10cSrcweir 		nLBorder = 2;
136*cdf0e10cSrcweir 		nRBorder = 2;
137*cdf0e10cSrcweir 		nTBorder = 2;
138*cdf0e10cSrcweir 		nBBorder = 2;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 		nLTxtBorder = 2;
141*cdf0e10cSrcweir 		nRTxtBorder = 2;
142*cdf0e10cSrcweir 		nTTxtBorder = 2;
143*cdf0e10cSrcweir 		nBTxtBorder = 2;
144*cdf0e10cSrcweir 	}
145*cdf0e10cSrcweir 	aPagePrtArea = Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	// Beispiel-Text: Vorbereiten fuer die Textausgabe
148*cdf0e10cSrcweir 	// Eine Textzeile
149*cdf0e10cSrcweir 	aTextLine = aPagePrtArea;
150*cdf0e10cSrcweir 	aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
151*cdf0e10cSrcweir 	aTextLine.Left()	+= nLTxtBorder;
152*cdf0e10cSrcweir 	aTextLine.Right()	-= nRTxtBorder;
153*cdf0e10cSrcweir 	aTextLine.Move(0, nTTxtBorder);
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	// Rechteck um Absatz incl. Raender
156*cdf0e10cSrcweir 	sal_uInt16 nLines = (sal_uInt16)((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder)
157*cdf0e10cSrcweir 			 / (aTextLine.GetHeight() + 2));
158*cdf0e10cSrcweir 	aPara = aPagePrtArea;
159*cdf0e10cSrcweir 	aPara.SetSize(Size(aPara.GetWidth(),
160*cdf0e10cSrcweir 		(aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder));
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	// Rechteck um Absatz ohne Raender
163*cdf0e10cSrcweir 	aParaPrtArea = aPara;
164*cdf0e10cSrcweir 	aParaPrtArea.Left()		+= nLTxtBorder;
165*cdf0e10cSrcweir 	aParaPrtArea.Right()	-= nRTxtBorder;
166*cdf0e10cSrcweir 	aParaPrtArea.Top()		+= nTTxtBorder;
167*cdf0e10cSrcweir 	aParaPrtArea.Bottom()	-= nBTxtBorder;
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     if (nAnchor == TextContentAnchorType_AS_CHARACTER || nAnchor == TextContentAnchorType_AT_CHARACTER)
170*cdf0e10cSrcweir 	{
171*cdf0e10cSrcweir         Font aFont = OutputDevice::GetDefaultFont(
172*cdf0e10cSrcweir                                 DEFAULTFONT_LATIN_TEXT, Application::GetSettings().GetLanguage(),
173*cdf0e10cSrcweir 								DEFAULTFONT_FLAGS_ONLYONE, this );
174*cdf0e10cSrcweir 		aFont.SetColor( m_aTxtCol );
175*cdf0e10cSrcweir 		aFont.SetFillColor( m_aBgCol );
176*cdf0e10cSrcweir 		aFont.SetWeight(WEIGHT_NORMAL);
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         if (nAnchor == TextContentAnchorType_AS_CHARACTER)
179*cdf0e10cSrcweir 		{
180*cdf0e10cSrcweir 			aFont.SetSize(Size(0, aParaPrtArea.GetHeight() - 2));
181*cdf0e10cSrcweir 			SetFont(aFont);
182*cdf0e10cSrcweir 			aParaPrtArea.SetSize(Size(GetTextWidth(C2S(DEMOTEXT)), GetTextHeight()));
183*cdf0e10cSrcweir 		}
184*cdf0e10cSrcweir 		else
185*cdf0e10cSrcweir 		{
186*cdf0e10cSrcweir 			aFont.SetSize(Size(0, aParaPrtArea.GetHeight() / 2));
187*cdf0e10cSrcweir 			SetFont(aFont);
188*cdf0e10cSrcweir 			aAutoCharFrame.SetSize(Size(GetTextWidth('A'), GetTextHeight()));
189*cdf0e10cSrcweir 			aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2,
190*cdf0e10cSrcweir 				aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2));
191*cdf0e10cSrcweir 		}
192*cdf0e10cSrcweir 	}
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 	// Innerer Frame fuer am Frame verankerte Rahmen
195*cdf0e10cSrcweir 	aFrameAtFrame = aPara;
196*cdf0e10cSrcweir 	aFrameAtFrame.Left() += 9;
197*cdf0e10cSrcweir 	aFrameAtFrame.Right() -= 5;
198*cdf0e10cSrcweir 	aFrameAtFrame.Bottom() += 5;
199*cdf0e10cSrcweir 	aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5));
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	// Groesse des zu positionierenden Rahmens
202*cdf0e10cSrcweir     if (nAnchor != TextContentAnchorType_AS_CHARACTER)
203*cdf0e10cSrcweir 	{
204*cdf0e10cSrcweir         sal_uIntPtr nLFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nLBorder : nLTxtBorder;
205*cdf0e10cSrcweir         sal_uIntPtr nRFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nRBorder : nRTxtBorder;
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 		switch (nHRel)
208*cdf0e10cSrcweir 		{
209*cdf0e10cSrcweir             case RelOrientation::PAGE_LEFT:
210*cdf0e10cSrcweir             case RelOrientation::FRAME_LEFT:
211*cdf0e10cSrcweir 				aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
212*cdf0e10cSrcweir 				break;
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir             case RelOrientation::PAGE_RIGHT:
215*cdf0e10cSrcweir             case RelOrientation::FRAME_RIGHT:
216*cdf0e10cSrcweir 				aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
217*cdf0e10cSrcweir 				break;
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 			default:
220*cdf0e10cSrcweir 				aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3);
221*cdf0e10cSrcweir 				break;
222*cdf0e10cSrcweir 		}
223*cdf0e10cSrcweir 		aFrmSize.Width() = Max(5L, aFrmSize.Width());
224*cdf0e10cSrcweir 		aFrmSize.Height() = Max(5L, aFrmSize.Height());
225*cdf0e10cSrcweir 	}
226*cdf0e10cSrcweir 	else
227*cdf0e10cSrcweir 	{
228*cdf0e10cSrcweir 		sal_uIntPtr nFreeWidth = aPagePrtArea.GetWidth() - GetTextWidth(C2S(DEMOTEXT));
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 		aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3);
231*cdf0e10cSrcweir 		aDrawObj.SetSize(Size(Max(5L, (long)nFreeWidth / 3L), Max(5L, aFrmSize.Height() * 3L)));
232*cdf0e10cSrcweir 		aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2));
233*cdf0e10cSrcweir 		aParaPrtArea.Right() = aDrawObj.Right();
234*cdf0e10cSrcweir 	}
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir void SvxSwFrameExample::CalcBoundRect_Impl(Rectangle &rRect)
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir 	switch (nAnchor)
240*cdf0e10cSrcweir 	{
241*cdf0e10cSrcweir         case TextContentAnchorType_AT_PAGE:
242*cdf0e10cSrcweir 		{
243*cdf0e10cSrcweir 			switch (nHRel)
244*cdf0e10cSrcweir 			{
245*cdf0e10cSrcweir                 case RelOrientation::FRAME:
246*cdf0e10cSrcweir                 case RelOrientation::PAGE_FRAME:
247*cdf0e10cSrcweir 					rRect.Left() = aPage.Left();
248*cdf0e10cSrcweir 					rRect.Right() = aPage.Right();
249*cdf0e10cSrcweir 					break;
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir                 case RelOrientation::PRINT_AREA:
252*cdf0e10cSrcweir                 case RelOrientation::PAGE_PRINT_AREA:
253*cdf0e10cSrcweir 					rRect.Left() = aPagePrtArea.Left();
254*cdf0e10cSrcweir 					rRect.Right() = aPagePrtArea.Right();
255*cdf0e10cSrcweir 					break;
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir                 case RelOrientation::PAGE_LEFT:
258*cdf0e10cSrcweir 					rRect.Left() = aPage.Left();
259*cdf0e10cSrcweir 					rRect.Right() = aPagePrtArea.Left();
260*cdf0e10cSrcweir 					break;
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir                 case RelOrientation::PAGE_RIGHT:
263*cdf0e10cSrcweir 					rRect.Left() = aPagePrtArea.Right();
264*cdf0e10cSrcweir 					rRect.Right() = aPage.Right();
265*cdf0e10cSrcweir 					break;
266*cdf0e10cSrcweir 			}
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 			switch (nVRel)
269*cdf0e10cSrcweir 			{
270*cdf0e10cSrcweir                 case RelOrientation::PRINT_AREA:
271*cdf0e10cSrcweir                 case RelOrientation::PAGE_PRINT_AREA:
272*cdf0e10cSrcweir 					rRect.Top() = aPagePrtArea.Top();
273*cdf0e10cSrcweir 					rRect.Bottom() = aPagePrtArea.Bottom();
274*cdf0e10cSrcweir 					break;
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir                 case RelOrientation::FRAME:
277*cdf0e10cSrcweir                 case RelOrientation::PAGE_FRAME:
278*cdf0e10cSrcweir 					rRect.Top() = aPage.Top();
279*cdf0e10cSrcweir 					rRect.Bottom() = aPage.Bottom();
280*cdf0e10cSrcweir 					break;
281*cdf0e10cSrcweir 			}
282*cdf0e10cSrcweir 		}
283*cdf0e10cSrcweir 		break;
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir         case TextContentAnchorType_AT_FRAME:
286*cdf0e10cSrcweir 		{
287*cdf0e10cSrcweir 			switch (nHRel)
288*cdf0e10cSrcweir 			{
289*cdf0e10cSrcweir                 case RelOrientation::FRAME:
290*cdf0e10cSrcweir                 case RelOrientation::PAGE_FRAME:
291*cdf0e10cSrcweir 					rRect.Left() = aFrameAtFrame.Left();
292*cdf0e10cSrcweir 					rRect.Right() = aFrameAtFrame.Right();
293*cdf0e10cSrcweir 					break;
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir                 case RelOrientation::PRINT_AREA:
296*cdf0e10cSrcweir                 case RelOrientation::PAGE_PRINT_AREA:
297*cdf0e10cSrcweir                     rRect.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
298*cdf0e10cSrcweir 					rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
299*cdf0e10cSrcweir 					break;
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir                 case RelOrientation::PAGE_RIGHT:
302*cdf0e10cSrcweir                     rRect.Left() = aFrameAtFrame.Left();
303*cdf0e10cSrcweir 					rRect.Right() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
304*cdf0e10cSrcweir 					break;
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir                 case RelOrientation::PAGE_LEFT:
307*cdf0e10cSrcweir                     rRect.Left() = aFrameAtFrame.Right();
308*cdf0e10cSrcweir 					rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
309*cdf0e10cSrcweir 					break;
310*cdf0e10cSrcweir 			}
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 			switch (nVRel)
313*cdf0e10cSrcweir 			{
314*cdf0e10cSrcweir                 case RelOrientation::FRAME:
315*cdf0e10cSrcweir                 case RelOrientation::PAGE_FRAME:
316*cdf0e10cSrcweir                     rRect.Top() = aFrameAtFrame.Top();
317*cdf0e10cSrcweir 					rRect.Bottom() = aFrameAtFrame.Bottom();
318*cdf0e10cSrcweir 					break;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir                 case RelOrientation::PRINT_AREA:
321*cdf0e10cSrcweir                 case RelOrientation::PAGE_PRINT_AREA:
322*cdf0e10cSrcweir                     rRect.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
323*cdf0e10cSrcweir 					rRect.Bottom() = aFrameAtFrame.Bottom() - FLYINFLY_BORDER;
324*cdf0e10cSrcweir 					break;
325*cdf0e10cSrcweir 			}
326*cdf0e10cSrcweir 		}
327*cdf0e10cSrcweir 		break;
328*cdf0e10cSrcweir         case TextContentAnchorType_AT_PARAGRAPH:
329*cdf0e10cSrcweir         case TextContentAnchorType_AT_CHARACTER:
330*cdf0e10cSrcweir 		{
331*cdf0e10cSrcweir 			switch (nHRel)
332*cdf0e10cSrcweir 			{
333*cdf0e10cSrcweir                 case RelOrientation::FRAME:
334*cdf0e10cSrcweir 					rRect.Left() = aPara.Left();
335*cdf0e10cSrcweir 					rRect.Right() = aPara.Right();
336*cdf0e10cSrcweir 					break;
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir                 case RelOrientation::PRINT_AREA:
339*cdf0e10cSrcweir 					rRect.Left() = aParaPrtArea.Left();
340*cdf0e10cSrcweir 					rRect.Right() = aParaPrtArea.Right();
341*cdf0e10cSrcweir 					break;
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir                 case RelOrientation::PAGE_LEFT:
344*cdf0e10cSrcweir 					rRect.Left() = aPage.Left();
345*cdf0e10cSrcweir 					rRect.Right() = aPagePrtArea.Left();
346*cdf0e10cSrcweir 					break;
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir                 case RelOrientation::PAGE_RIGHT:
349*cdf0e10cSrcweir 					rRect.Left() = aPagePrtArea.Right();
350*cdf0e10cSrcweir 					rRect.Right() = aPage.Right();
351*cdf0e10cSrcweir 					break;
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir                 case RelOrientation::PAGE_FRAME:
354*cdf0e10cSrcweir 					rRect.Left() = aPage.Left();
355*cdf0e10cSrcweir 					rRect.Right() = aPage.Right();
356*cdf0e10cSrcweir 					break;
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir                 case RelOrientation::PAGE_PRINT_AREA:
359*cdf0e10cSrcweir 					rRect.Left() = aPagePrtArea.Left();
360*cdf0e10cSrcweir 					rRect.Right() = aPagePrtArea.Right();
361*cdf0e10cSrcweir 					break;
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir                 case RelOrientation::FRAME_LEFT:
364*cdf0e10cSrcweir 					rRect.Left() = aPara.Left();
365*cdf0e10cSrcweir 					rRect.Right() = aParaPrtArea.Left();
366*cdf0e10cSrcweir 					break;
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir                 case RelOrientation::FRAME_RIGHT:
369*cdf0e10cSrcweir 					rRect.Left() = aParaPrtArea.Right();
370*cdf0e10cSrcweir 					rRect.Right() = aPara.Right();
371*cdf0e10cSrcweir 					break;
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir                 case RelOrientation::CHAR:
374*cdf0e10cSrcweir 					rRect.Left() = aAutoCharFrame.Left();
375*cdf0e10cSrcweir 					rRect.Right() = aAutoCharFrame.Left();
376*cdf0e10cSrcweir 					break;
377*cdf0e10cSrcweir 			}
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 			switch (nVRel)
380*cdf0e10cSrcweir 			{
381*cdf0e10cSrcweir                 case RelOrientation::FRAME:
382*cdf0e10cSrcweir 					rRect.Top() = aPara.Top();
383*cdf0e10cSrcweir 					rRect.Bottom() = aPara.Bottom();
384*cdf0e10cSrcweir 					break;
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir                 case RelOrientation::PRINT_AREA:
387*cdf0e10cSrcweir 					rRect.Top() = aParaPrtArea.Top();
388*cdf0e10cSrcweir 					rRect.Bottom() = aParaPrtArea.Bottom();
389*cdf0e10cSrcweir 					break;
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir                 case RelOrientation::CHAR:
392*cdf0e10cSrcweir                     if (nVAlign != VertOrientation::NONE &&
393*cdf0e10cSrcweir                                 nVAlign != VertOrientation::CHAR_BOTTOM)
394*cdf0e10cSrcweir 						rRect.Top() = aAutoCharFrame.Top();
395*cdf0e10cSrcweir 					else
396*cdf0e10cSrcweir 						rRect.Top() = aAutoCharFrame.Bottom();
397*cdf0e10cSrcweir 					rRect.Bottom() = aAutoCharFrame.Bottom();
398*cdf0e10cSrcweir 					break;
399*cdf0e10cSrcweir                 // OD 12.11.2003 #i22341#
400*cdf0e10cSrcweir                 case RelOrientation::TEXT_LINE:
401*cdf0e10cSrcweir                     rRect.Top() = aAutoCharFrame.Top();
402*cdf0e10cSrcweir                     rRect.Bottom() = aAutoCharFrame.Top();
403*cdf0e10cSrcweir                 break;
404*cdf0e10cSrcweir 			}
405*cdf0e10cSrcweir 		}
406*cdf0e10cSrcweir 		break;
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir         case TextContentAnchorType_AS_CHARACTER:
409*cdf0e10cSrcweir 			rRect.Left() = aParaPrtArea.Left();
410*cdf0e10cSrcweir 			rRect.Right() = aParaPrtArea.Right();
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 			switch (nVAlign)
413*cdf0e10cSrcweir 			{
414*cdf0e10cSrcweir                 case VertOrientation::NONE:
415*cdf0e10cSrcweir                 case VertOrientation::TOP:
416*cdf0e10cSrcweir                 case VertOrientation::CENTER:
417*cdf0e10cSrcweir                 case VertOrientation::BOTTOM:
418*cdf0e10cSrcweir 				{
419*cdf0e10cSrcweir 					FontMetric aMetric(GetFontMetric());
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir 					rRect.Top() = aParaPrtArea.Bottom() - aMetric.GetDescent();
422*cdf0e10cSrcweir 					rRect.Bottom() = rRect.Top();
423*cdf0e10cSrcweir 				}
424*cdf0e10cSrcweir 				break;
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 				default:
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir                 case VertOrientation::LINE_TOP:
429*cdf0e10cSrcweir                 case VertOrientation::LINE_CENTER:
430*cdf0e10cSrcweir                 case VertOrientation::LINE_BOTTOM:
431*cdf0e10cSrcweir 					rRect.Top() = aParaPrtArea.Top();
432*cdf0e10cSrcweir 					rRect.Bottom() = aDrawObj.Bottom();
433*cdf0e10cSrcweir 					break;
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir                 case VertOrientation::CHAR_TOP:
436*cdf0e10cSrcweir                 case VertOrientation::CHAR_CENTER:
437*cdf0e10cSrcweir                 case VertOrientation::CHAR_BOTTOM:
438*cdf0e10cSrcweir 					rRect.Top() = aParaPrtArea.Top();
439*cdf0e10cSrcweir 					rRect.Bottom() = aParaPrtArea.Bottom();
440*cdf0e10cSrcweir 					break;
441*cdf0e10cSrcweir 			}
442*cdf0e10cSrcweir 			break;
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 		default:
445*cdf0e10cSrcweir 			break;
446*cdf0e10cSrcweir 	}
447*cdf0e10cSrcweir }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir Rectangle SvxSwFrameExample::DrawInnerFrame_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor)
450*cdf0e10cSrcweir {
451*cdf0e10cSrcweir     DrawRect_Impl(rRect, rFillColor, rBorderColor);
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 	// Bereich, zu dem relativ positioniert wird, bestimmen
454*cdf0e10cSrcweir 	Rectangle aRect(rRect);	// aPagePrtArea = Default
455*cdf0e10cSrcweir     CalcBoundRect_Impl(aRect);
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir     if (nAnchor == TextContentAnchorType_AT_FRAME && &rRect == &aPagePrtArea)
458*cdf0e10cSrcweir 	{
459*cdf0e10cSrcweir 		// Testabsatz zeichnen
460*cdf0e10cSrcweir 		Rectangle aTxt(aTextLine);
461*cdf0e10cSrcweir         sal_Int32 nStep = aTxt.GetHeight() + 2;
462*cdf0e10cSrcweir 		sal_uInt16 nLines = (sal_uInt16)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < nLines; i++)
465*cdf0e10cSrcweir 		{
466*cdf0e10cSrcweir 			if (i == nLines - 1)
467*cdf0e10cSrcweir 				aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
468*cdf0e10cSrcweir             DrawRect_Impl(aTxt, m_aTxtCol, m_aTransColor);
469*cdf0e10cSrcweir 			aTxt.Move(0, nStep);
470*cdf0e10cSrcweir 		}
471*cdf0e10cSrcweir 	}
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	return aRect;
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir void SvxSwFrameExample::Paint(const Rectangle&)
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir     InitAllRects_Impl();
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 	// Schatten zeichnen
481*cdf0e10cSrcweir //    Rectangle aShadow(aPage);
482*cdf0e10cSrcweir //    aShadow += Point(3, 3);
483*cdf0e10cSrcweir //    DrawRect_Impl(aShadow, Color(COL_GRAY), aTransColor);
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 	// Seite zeichnen
486*cdf0e10cSrcweir     DrawRect_Impl( aPage, m_aBgCol, m_aBorderCol );
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir 	// PrintArea zeichnen
489*cdf0e10cSrcweir     Rectangle aRect = DrawInnerFrame_Impl( aPagePrtArea, m_aTransColor, m_aPrintAreaCol );
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir     if (nAnchor == TextContentAnchorType_AT_FRAME)
492*cdf0e10cSrcweir         aRect = DrawInnerFrame_Impl( aFrameAtFrame, m_aBgCol, m_aBorderCol );
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir 	long lXPos 	  = 0;
495*cdf0e10cSrcweir 	long lYPos 	  = 0;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir 	// Horizontale Ausrichtung
498*cdf0e10cSrcweir 	//
499*cdf0e10cSrcweir     if (nAnchor != TextContentAnchorType_AS_CHARACTER)
500*cdf0e10cSrcweir 	{
501*cdf0e10cSrcweir 		switch (nHAlign)
502*cdf0e10cSrcweir 		{
503*cdf0e10cSrcweir             case HoriOrientation::RIGHT:
504*cdf0e10cSrcweir 			{
505*cdf0e10cSrcweir 				lXPos = aRect.Right() - aFrmSize.Width() + 1;
506*cdf0e10cSrcweir 				break;
507*cdf0e10cSrcweir 			}
508*cdf0e10cSrcweir             case HoriOrientation::CENTER:
509*cdf0e10cSrcweir 			{
510*cdf0e10cSrcweir 				lXPos = aRect.Left() + (aRect.GetWidth() - aFrmSize.Width()) / 2;
511*cdf0e10cSrcweir 				break;
512*cdf0e10cSrcweir 			}
513*cdf0e10cSrcweir             case HoriOrientation::NONE:
514*cdf0e10cSrcweir 			{
515*cdf0e10cSrcweir 				lXPos = aRect.Left() + aRelPos.X();
516*cdf0e10cSrcweir 				break;
517*cdf0e10cSrcweir 			}
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir             default: // HoriOrientation::LEFT
520*cdf0e10cSrcweir 				lXPos = aRect.Left();
521*cdf0e10cSrcweir 				break;
522*cdf0e10cSrcweir 		}
523*cdf0e10cSrcweir 	}
524*cdf0e10cSrcweir 	else
525*cdf0e10cSrcweir        lXPos = aRect.Right() + 2;
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir 	// Vertikale Ausrichtung
528*cdf0e10cSrcweir 	//
529*cdf0e10cSrcweir     if (nAnchor != TextContentAnchorType_AS_CHARACTER)
530*cdf0e10cSrcweir 	{
531*cdf0e10cSrcweir 		switch (nVAlign)
532*cdf0e10cSrcweir 		{
533*cdf0e10cSrcweir             case VertOrientation::BOTTOM:
534*cdf0e10cSrcweir             case VertOrientation::LINE_BOTTOM:
535*cdf0e10cSrcweir 			{
536*cdf0e10cSrcweir                 // OD 12.11.2003 #i22341#
537*cdf0e10cSrcweir                 if ( nVRel != RelOrientation::TEXT_LINE )
538*cdf0e10cSrcweir                 {
539*cdf0e10cSrcweir                     lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
540*cdf0e10cSrcweir                 }
541*cdf0e10cSrcweir                 else
542*cdf0e10cSrcweir                 {
543*cdf0e10cSrcweir                     lYPos = aRect.Top();
544*cdf0e10cSrcweir                 }
545*cdf0e10cSrcweir 				break;
546*cdf0e10cSrcweir 			}
547*cdf0e10cSrcweir             case VertOrientation::CENTER:
548*cdf0e10cSrcweir             case VertOrientation::LINE_CENTER:
549*cdf0e10cSrcweir 			{
550*cdf0e10cSrcweir 				lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
551*cdf0e10cSrcweir 				break;
552*cdf0e10cSrcweir 			}
553*cdf0e10cSrcweir             case VertOrientation::NONE:
554*cdf0e10cSrcweir 			{
555*cdf0e10cSrcweir                 // OD 12.11.2003 #i22341#
556*cdf0e10cSrcweir                 if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE )
557*cdf0e10cSrcweir 					lYPos = aRect.Top() + aRelPos.Y();
558*cdf0e10cSrcweir 				else
559*cdf0e10cSrcweir 					lYPos = aRect.Top() - aRelPos.Y();
560*cdf0e10cSrcweir 				break;
561*cdf0e10cSrcweir 			}
562*cdf0e10cSrcweir 			default:
563*cdf0e10cSrcweir                 // OD 12.11.2003 #i22341#
564*cdf0e10cSrcweir                 if ( nVRel != RelOrientation::TEXT_LINE )
565*cdf0e10cSrcweir                 {
566*cdf0e10cSrcweir                     lYPos = aRect.Top();
567*cdf0e10cSrcweir                 }
568*cdf0e10cSrcweir                 else
569*cdf0e10cSrcweir                 {
570*cdf0e10cSrcweir                     lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
571*cdf0e10cSrcweir                 }
572*cdf0e10cSrcweir 				break;
573*cdf0e10cSrcweir 		}
574*cdf0e10cSrcweir 	}
575*cdf0e10cSrcweir 	else
576*cdf0e10cSrcweir 	{
577*cdf0e10cSrcweir 		switch(nVAlign)
578*cdf0e10cSrcweir 		{
579*cdf0e10cSrcweir             case VertOrientation::CENTER:
580*cdf0e10cSrcweir             case VertOrientation::CHAR_CENTER:
581*cdf0e10cSrcweir             case VertOrientation::LINE_CENTER:
582*cdf0e10cSrcweir 				lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
583*cdf0e10cSrcweir 				break;
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir             case VertOrientation::TOP:
586*cdf0e10cSrcweir             case VertOrientation::CHAR_BOTTOM:
587*cdf0e10cSrcweir             case VertOrientation::LINE_BOTTOM:
588*cdf0e10cSrcweir 				lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
589*cdf0e10cSrcweir 				break;
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir /*          case VertOrientation::NONE:
592*cdf0e10cSrcweir             case VertOrientation::BOTTOM:
593*cdf0e10cSrcweir             case VertOrientation::CHAR_TOP:
594*cdf0e10cSrcweir             case VertOrientation::LINE_TOP:*/
595*cdf0e10cSrcweir 			default:
596*cdf0e10cSrcweir 				lYPos = aRect.Top() - aRelPos.Y();
597*cdf0e10cSrcweir 				break;
598*cdf0e10cSrcweir 		}
599*cdf0e10cSrcweir 	}
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir 	Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize);
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	Rectangle *pOuterFrame = &aPage;
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir     if (nAnchor == TextContentAnchorType_AT_FRAME)
606*cdf0e10cSrcweir 		pOuterFrame = &aFrameAtFrame;
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir 	if (aFrmRect.Left() < pOuterFrame->Left())
609*cdf0e10cSrcweir 		aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0);
610*cdf0e10cSrcweir 	if (aFrmRect.Right() > pOuterFrame->Right())
611*cdf0e10cSrcweir 		aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0);
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 	if (aFrmRect.Top() < pOuterFrame->Top())
614*cdf0e10cSrcweir 		aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top());
615*cdf0e10cSrcweir 	if (aFrmRect.Bottom() > pOuterFrame->Bottom())
616*cdf0e10cSrcweir 		aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom());
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir 	// Testabsatz zeichnen
619*cdf0e10cSrcweir 	const long nTxtLineHeight = aTextLine.GetHeight();
620*cdf0e10cSrcweir 	Rectangle aTxt(aTextLine);
621*cdf0e10cSrcweir     sal_Int32 nStep;
622*cdf0e10cSrcweir     sal_uInt16 nLines;
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir     if (nAnchor == TextContentAnchorType_AT_FRAME)
625*cdf0e10cSrcweir 	{
626*cdf0e10cSrcweir 		aTxt.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
627*cdf0e10cSrcweir 		aTxt.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
628*cdf0e10cSrcweir 		aTxt.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
629*cdf0e10cSrcweir 		aTxt.Bottom() = aTxt.Top() + aTextLine.GetHeight() - 1;
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir 		nStep = aTxt.GetHeight() + 2;
632*cdf0e10cSrcweir 		nLines = (sal_uInt16)(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3)
633*cdf0e10cSrcweir 				 / (aTxt.GetHeight() + 2));
634*cdf0e10cSrcweir 	}
635*cdf0e10cSrcweir 	else
636*cdf0e10cSrcweir 	{
637*cdf0e10cSrcweir 		nStep = aTxt.GetHeight() + 2;
638*cdf0e10cSrcweir 		nLines = (sal_uInt16)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
639*cdf0e10cSrcweir 	}
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir     if (nAnchor != TextContentAnchorType_AS_CHARACTER)
642*cdf0e10cSrcweir 	{
643*cdf0e10cSrcweir 		// Text simulieren
644*cdf0e10cSrcweir 		//
645*cdf0e10cSrcweir 		const long nOldR = aTxt.Right();
646*cdf0e10cSrcweir 		const long nOldL = aTxt.Left();
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir         // OD 12.11.2003 #i22341#
649*cdf0e10cSrcweir         const bool bIgnoreWrap = nAnchor == TextContentAnchorType_AT_CHARACTER &&
650*cdf0e10cSrcweir                            ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR ||
651*cdf0e10cSrcweir                              nVRel == RelOrientation::TEXT_LINE );
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 		for (sal_uInt16 i = 0; i < nLines; ++i)
654*cdf0e10cSrcweir 		{
655*cdf0e10cSrcweir 			if (i == (nLines - 1))
656*cdf0e10cSrcweir 				aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir             if (aTxt.IsOver(aFrmRect) && nAnchor != TextContentAnchorType_AS_CHARACTER && !bIgnoreWrap)
659*cdf0e10cSrcweir 			{
660*cdf0e10cSrcweir 				switch(nWrap)
661*cdf0e10cSrcweir 				{
662*cdf0e10cSrcweir                     case WrapTextMode_NONE:
663*cdf0e10cSrcweir 						aTxt.Top() 	  = aFrmRect.Bottom() + nTxtLineHeight;
664*cdf0e10cSrcweir 						aTxt.Bottom() = aTxt.Top() + nTxtLineHeight - 1;
665*cdf0e10cSrcweir 						break;
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir                     case WrapTextMode_LEFT:
668*cdf0e10cSrcweir 						aTxt.Right() = aFrmRect.Left();
669*cdf0e10cSrcweir 						break;
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir                     case WrapTextMode_RIGHT:
672*cdf0e10cSrcweir 						aTxt.Left() = aFrmRect.Right();
673*cdf0e10cSrcweir 						break;
674*cdf0e10cSrcweir 				}
675*cdf0e10cSrcweir 			}
676*cdf0e10cSrcweir 			if (pOuterFrame->IsInside(aTxt))
677*cdf0e10cSrcweir                 DrawRect_Impl( aTxt, m_aTxtCol, m_aTransColor );
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir 			aTxt.Move(0, nStep);
680*cdf0e10cSrcweir 			aTxt.Right() = nOldR;
681*cdf0e10cSrcweir 			aTxt.Left()  = nOldL;
682*cdf0e10cSrcweir 		}
683*cdf0e10cSrcweir 		aTxt.Move(0, -nStep);
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir         if (nAnchor != TextContentAnchorType_AT_FRAME && aTxt.Bottom() > aParaPrtArea.Bottom())
686*cdf0e10cSrcweir 		{
687*cdf0e10cSrcweir 			// Text wurde durch Rahmen verdraengt, daher Para-Hoehe anpassen
688*cdf0e10cSrcweir 			sal_uIntPtr nDiff = aTxt.Bottom() - aParaPrtArea.Bottom();
689*cdf0e10cSrcweir 			aParaPrtArea.Bottom() += nDiff;
690*cdf0e10cSrcweir 			aPara.Bottom() += nDiff;
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir             CalcBoundRect_Impl(aRect);
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir 			aParaPrtArea.Bottom() -= nDiff;
695*cdf0e10cSrcweir 			aPara.Bottom() -= nDiff;
696*cdf0e10cSrcweir 		}
697*cdf0e10cSrcweir         if (nAnchor == TextContentAnchorType_AT_CHARACTER && bIgnoreWrap)
698*cdf0e10cSrcweir 			DrawText(aAutoCharFrame, 'A');
699*cdf0e10cSrcweir 	}
700*cdf0e10cSrcweir 	else
701*cdf0e10cSrcweir 	{
702*cdf0e10cSrcweir 		DrawText(aParaPrtArea, C2S(DEMOTEXT));
703*cdf0e10cSrcweir         DrawRect_Impl(aDrawObj, m_aBlankCol, m_aBlankFrameCol );
704*cdf0e10cSrcweir 	}
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir 	// Rechteck zeichnen, zu dem der Rahmen ausgerichtet wird:
707*cdf0e10cSrcweir     DrawRect_Impl(aRect, m_aTransColor, m_aAlignColor);
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir 	// Frame anzeigen
710*cdf0e10cSrcweir     sal_Bool bDontFill = (nAnchor == TextContentAnchorType_AT_CHARACTER && aFrmRect.IsOver(aAutoCharFrame)) ? sal_True : bTrans;
711*cdf0e10cSrcweir     DrawRect_Impl( aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor );
712*cdf0e10cSrcweir }
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir void SvxSwFrameExample::SetRelPos(const Point& rP)
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir 	aRelPos = rP;
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir 	if (aRelPos.X() > 0)
719*cdf0e10cSrcweir 		aRelPos.X() = 5;
720*cdf0e10cSrcweir 	if (aRelPos.X() < 0)
721*cdf0e10cSrcweir 		aRelPos.X() = -5;
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir 	if (aRelPos.Y() > 0)
724*cdf0e10cSrcweir 		aRelPos.Y() = 5;
725*cdf0e10cSrcweir 	if (aRelPos.Y() < 0)
726*cdf0e10cSrcweir 		aRelPos.Y() = -5;
727*cdf0e10cSrcweir }
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir void SvxSwFrameExample::DrawRect_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor)
730*cdf0e10cSrcweir {
731*cdf0e10cSrcweir 	SetFillColor(rFillColor);
732*cdf0e10cSrcweir 	SetLineColor(rLineColor);
733*cdf0e10cSrcweir 	Window::DrawRect(rRect);
734*cdf0e10cSrcweir }
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir 
738