xref: /trunk/main/sw/source/core/inc/drawdev.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DRAWDEV_HXX
29 #define _DRAWDEV_HXX
30 
31 #include "swrect.hxx"
32 
33 #ifndef _OUTDEV_HXX //autogen
34 #include <vcl/outdev.hxx>
35 #endif
36 
37 /*************************************************************************
38  *                          class SwDrawDev
39  *
40  * Alle Draw-Methoden werden um den Offset *pPos verschoben.
41  *************************************************************************/
42 
43 class SwDrawDev
44 {
45     OutputDevice  *pOut;
46     const Point *pPos;
47 
48 public:
49     inline SwDrawDev( OutputDevice *pOutDev, const Point *pPosition )
50         :pOut(pOutDev), pPos(pPosition) { }
51 
52     inline OutputDevice *GetOut() { return pOut; }
53 
54     // Ausgabemethoden
55     inline void DrawText( const Point& rStart, const String& rTxt,
56                           const sal_uInt16 nIdx = 0,
57                           const sal_uInt16 nLen = STRING_LEN );
58     inline void DrawStretchText( const Point& rStart, sal_uInt16 nWidth,
59                           const String& rTxt,
60                           const sal_uInt16 nIdx = 0,
61                           const sal_uInt16 nLen = STRING_LEN );
62     inline void DrawTextArray( const Point& rStart,
63                           const String& rTxt,
64                           long *pKernArray = 0,
65                           const sal_uInt16 nIdx = 0,
66                           const sal_uInt16 nLen = STRING_LEN);
67     inline void DrawLine( const Point& rStart, const Point& rEnd );
68     inline void DrawRect( const SwRect& rRect,
69                           const sal_uInt16 nHorzRount = 0,
70                           const sal_uInt16 nVertRound = 0 );
71 
72     inline const Point *GetOrigin() const {return pPos; }
73 };
74 
75 /*************************************************************************
76  *                      SwDrawDev::DrawText
77  *************************************************************************/
78 
79 inline void SwDrawDev::DrawText( const Point& rStart, const String& rTxt,
80                                  const sal_uInt16 nIdx, const sal_uInt16 nLen )
81 {
82     if( !pPos )
83         pOut->DrawText( rStart, rTxt, nIdx, nLen );
84     else
85         pOut->DrawText( rStart - *pPos, rTxt, nIdx, nLen );
86 }
87 
88 /*************************************************************************
89  *                      SwDrawDev::DrawStretchText
90  *************************************************************************/
91 
92 inline void SwDrawDev::DrawStretchText( const Point& rStart, sal_uInt16 nWidth,
93        const String& rTxt, const sal_uInt16 nIdx, const sal_uInt16 nLen )
94 {
95     if( !pPos )
96         pOut->DrawStretchText( rStart, nWidth, rTxt, nIdx, nLen );
97     else
98         pOut->DrawStretchText( rStart - *pPos, nWidth, rTxt, nIdx, nLen );
99 }
100 
101 /*************************************************************************
102  *                      SwDrawDev::DrawTextArray
103  *************************************************************************/
104 
105 inline void SwDrawDev::DrawTextArray( const Point& rStart, const String& rTxt,
106             long *pKernArray, const sal_uInt16 nIdx, const sal_uInt16 nLen )
107 {
108     if( !pPos )
109         pOut->DrawTextArray( rStart, rTxt, pKernArray, nIdx, nLen );
110     else
111         pOut->DrawTextArray( rStart - *pPos, rTxt, pKernArray, nIdx, nLen );
112 }
113 
114 /*************************************************************************
115  *                      SwDrawDev::DrawLine
116  *************************************************************************/
117 
118 inline void SwDrawDev::DrawLine( const Point& rStart, const Point& rEnd )
119 {
120     if( !pPos )
121         pOut->DrawLine( rStart, rEnd );
122     else
123         pOut->DrawLine( rStart - *pPos, rEnd - *pPos );
124 }
125 
126 /*************************************************************************
127  *                      SwDrawDev::DrawRect
128  *************************************************************************/
129 
130 inline void SwDrawDev::DrawRect( const SwRect& rRect,
131                       const sal_uInt16 nHorzRound, const sal_uInt16 nVertRound )
132 {
133     SwRect aRect( rRect );
134     if( pPos )
135         aRect.Pos() -= *pPos;
136     pOut->DrawRect( aRect.SVRect(), nHorzRound, nVertRound );
137 }
138 
139 
140 #endif
141