xref: /aoo41x/main/sw/source/core/inc/drawdev.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DRAWDEV_HXX
25cdf0e10cSrcweir #define _DRAWDEV_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "swrect.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #ifndef _OUTDEV_HXX //autogen
30cdf0e10cSrcweir #include <vcl/outdev.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /*************************************************************************
34cdf0e10cSrcweir  *							class SwDrawDev
35cdf0e10cSrcweir  *
36cdf0e10cSrcweir  * Alle Draw-Methoden werden um den Offset *pPos verschoben.
37cdf0e10cSrcweir  *************************************************************************/
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class SwDrawDev
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	OutputDevice  *pOut;
42cdf0e10cSrcweir 	const Point *pPos;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir public:
SwDrawDev(OutputDevice * pOutDev,const Point * pPosition)45cdf0e10cSrcweir 	inline SwDrawDev( OutputDevice *pOutDev, const Point *pPosition )
46cdf0e10cSrcweir 		:pOut(pOutDev), pPos(pPosition) { }
47cdf0e10cSrcweir 
GetOut()48cdf0e10cSrcweir 	inline OutputDevice *GetOut() { return pOut; }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 	// Ausgabemethoden
51cdf0e10cSrcweir 	inline void DrawText( const Point& rStart, const String& rTxt,
52cdf0e10cSrcweir 						  const sal_uInt16 nIdx = 0,
53cdf0e10cSrcweir 						  const sal_uInt16 nLen = STRING_LEN );
54cdf0e10cSrcweir 	inline void DrawStretchText( const Point& rStart, sal_uInt16 nWidth,
55cdf0e10cSrcweir 						  const String& rTxt,
56cdf0e10cSrcweir 						  const sal_uInt16 nIdx = 0,
57cdf0e10cSrcweir 						  const sal_uInt16 nLen = STRING_LEN );
58cdf0e10cSrcweir 	inline void DrawTextArray( const Point& rStart,
59cdf0e10cSrcweir 						  const String& rTxt,
60cdf0e10cSrcweir 						  long *pKernArray = 0,
61cdf0e10cSrcweir 						  const sal_uInt16 nIdx = 0,
62cdf0e10cSrcweir 						  const sal_uInt16 nLen = STRING_LEN);
63cdf0e10cSrcweir 	inline void DrawLine( const Point& rStart, const Point& rEnd );
64cdf0e10cSrcweir 	inline void DrawRect( const SwRect& rRect,
65cdf0e10cSrcweir 						  const sal_uInt16 nHorzRount = 0,
66cdf0e10cSrcweir 						  const sal_uInt16 nVertRound = 0 );
67cdf0e10cSrcweir 
GetOrigin() const68cdf0e10cSrcweir 	inline const Point *GetOrigin() const {return pPos; }
69cdf0e10cSrcweir };
70cdf0e10cSrcweir 
71cdf0e10cSrcweir /*************************************************************************
72cdf0e10cSrcweir  *						SwDrawDev::DrawText
73cdf0e10cSrcweir  *************************************************************************/
74cdf0e10cSrcweir 
DrawText(const Point & rStart,const String & rTxt,const sal_uInt16 nIdx,const sal_uInt16 nLen)75cdf0e10cSrcweir inline void SwDrawDev::DrawText( const Point& rStart, const String& rTxt,
76cdf0e10cSrcweir 								 const sal_uInt16 nIdx, const sal_uInt16 nLen )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 	if( !pPos )
79cdf0e10cSrcweir 		pOut->DrawText( rStart, rTxt, nIdx, nLen );
80cdf0e10cSrcweir 	else
81cdf0e10cSrcweir 		pOut->DrawText( rStart - *pPos, rTxt, nIdx, nLen );
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir /*************************************************************************
85cdf0e10cSrcweir  *						SwDrawDev::DrawStretchText
86cdf0e10cSrcweir  *************************************************************************/
87cdf0e10cSrcweir 
DrawStretchText(const Point & rStart,sal_uInt16 nWidth,const String & rTxt,const sal_uInt16 nIdx,const sal_uInt16 nLen)88cdf0e10cSrcweir inline void SwDrawDev::DrawStretchText( const Point& rStart, sal_uInt16 nWidth,
89cdf0e10cSrcweir 	   const String& rTxt, const sal_uInt16 nIdx, const sal_uInt16 nLen )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	if( !pPos )
92cdf0e10cSrcweir 		pOut->DrawStretchText( rStart, nWidth, rTxt, nIdx, nLen );
93cdf0e10cSrcweir 	else
94cdf0e10cSrcweir 		pOut->DrawStretchText( rStart - *pPos, nWidth, rTxt, nIdx, nLen );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir /*************************************************************************
98cdf0e10cSrcweir  *						SwDrawDev::DrawTextArray
99cdf0e10cSrcweir  *************************************************************************/
100cdf0e10cSrcweir 
DrawTextArray(const Point & rStart,const String & rTxt,long * pKernArray,const sal_uInt16 nIdx,const sal_uInt16 nLen)101cdf0e10cSrcweir inline void SwDrawDev::DrawTextArray( const Point& rStart, const String& rTxt,
102cdf0e10cSrcweir 			long *pKernArray, const sal_uInt16 nIdx, const sal_uInt16 nLen )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	if( !pPos )
105cdf0e10cSrcweir 		pOut->DrawTextArray( rStart, rTxt, pKernArray, nIdx, nLen );
106cdf0e10cSrcweir 	else
107cdf0e10cSrcweir 		pOut->DrawTextArray( rStart - *pPos, rTxt, pKernArray, nIdx, nLen );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir /*************************************************************************
111cdf0e10cSrcweir  *						SwDrawDev::DrawLine
112cdf0e10cSrcweir  *************************************************************************/
113cdf0e10cSrcweir 
DrawLine(const Point & rStart,const Point & rEnd)114cdf0e10cSrcweir inline void SwDrawDev::DrawLine( const Point& rStart, const Point& rEnd )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	if( !pPos )
117cdf0e10cSrcweir 		pOut->DrawLine( rStart, rEnd );
118cdf0e10cSrcweir 	else
119cdf0e10cSrcweir 		pOut->DrawLine( rStart - *pPos, rEnd - *pPos );
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir /*************************************************************************
123cdf0e10cSrcweir  *						SwDrawDev::DrawRect
124cdf0e10cSrcweir  *************************************************************************/
125cdf0e10cSrcweir 
DrawRect(const SwRect & rRect,const sal_uInt16 nHorzRound,const sal_uInt16 nVertRound)126cdf0e10cSrcweir inline void SwDrawDev::DrawRect( const SwRect& rRect,
127cdf0e10cSrcweir 					  const sal_uInt16 nHorzRound, const sal_uInt16 nVertRound )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	SwRect aRect( rRect );
130cdf0e10cSrcweir 	if( pPos )
131cdf0e10cSrcweir 		aRect.Pos() -= *pPos;
132cdf0e10cSrcweir 	pOut->DrawRect( aRect.SVRect(), nHorzRound, nVertRound );
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
136cdf0e10cSrcweir #endif
137