Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vcl/window.hxx>
30 : :
31 : : #include "hintids.hxx"
32 : : #include "viewsh.hxx"
33 : : #include "virtoutp.hxx"
34 : : #include "viewopt.hxx"
35 : : #include "rootfrm.hxx"
36 : : // OD 12.11.2002 #96272# - include declaration for <SetMappingForVirtDev>
37 : : #include "setmapvirtdev.hxx"
38 : :
39 : : #if OSL_DEBUG_LEVEL > 1
40 : :
41 : : /*************************************************************************
42 : : * class DbgRect
43 : : *************************************************************************/
44 : :
45 : : class DbgRect
46 : : {
47 : : OutputDevice *pOut;
48 : : public:
49 : : DbgRect( OutputDevice *pOut, const Rectangle &rRect,
50 : : const ColorData eColor = COL_LIGHTBLUE );
51 : : };
52 : :
53 : : inline DbgRect::DbgRect( OutputDevice *pOutDev, const Rectangle &rRect,
54 : : const ColorData eColor )
55 : : :pOut( pOutDev )
56 : : {
57 : : if( pOut )
58 : : {
59 : : pOut->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
60 : : pOut->SetLineColor( eColor );
61 : : pOut->SetFillColor();
62 : : pOut->DrawRect( rRect );
63 : : pOut->Pop();
64 : : }
65 : : }
66 : :
67 : : #endif
68 : :
69 : : /* The SWLayVout class manages the virtual output devices.
70 : : * RootFrm has a static member of this class which is created in _FrmInit
71 : : * and destroyed in _FrmFinit.
72 : : * */
73 : :
74 : 0 : sal_Bool SwRootFrm::FlushVout()
75 : : {
76 [ # # ]: 0 : if( SwRootFrm::pVout->IsFlushable() )
77 : : {
78 : 0 : SwRootFrm::pVout->_Flush();
79 : 0 : return sal_True;
80 : : }
81 : 0 : return sal_False;
82 : : }
83 : :
84 : 9175 : sal_Bool SwRootFrm::HasSameRect( const SwRect& rRect )
85 : : {
86 [ - + ]: 9175 : if( SwRootFrm::pVout->IsFlushable() )
87 : 0 : return ( rRect == SwRootFrm::pVout->GetOrgRect() );
88 : 9175 : return sal_False;
89 : : }
90 : :
91 : : /** method to set mapping/pixel offset for virtual output device
92 : :
93 : : OD 12.11.2002 #96272# - method implements two solutions for the mapping of
94 : : the virtual output device:
95 : : The old solution set the origin of the mapping mode, which will be used in
96 : : the virtual output device. This causes several paint errors, because of the
97 : : different roundings in the virtual output device and the original output device.
98 : : The new solution avoids the rounding differences between virtual and original
99 : : output device by setting a pixel offset at the virtual output device.
100 : : A define controls, which solution is used, in order to switch in escalation
101 : : back to old solution.
102 : :
103 : : @author OD
104 : :
105 : : @param _pOrgOutDev
106 : : input parameter - constant instance of the original output device, for which
107 : : the virtual output device is created.
108 : :
109 : : @param _pVirDev
110 : : input/output parameter - instance of the virtual output device.
111 : :
112 : : @param _pMapMode
113 : : input/output parameter - instance of the mapping mode, which will be set
114 : : at the virtual output device.
115 : :
116 : : @param _rNewOrigin
117 : : input parameter - constant instance of the origin, which will be used in
118 : : the virtual output device
119 : : */
120 : : // define to control, if old or new solution for setting the mapping for
121 : : // an virtual output device is used.
122 : 0 : void SetMappingForVirtDev( const Point& _rNewOrigin,
123 : : MapMode* ,
124 : : const OutputDevice* _pOrgOutDev,
125 : : VirtualDevice* _pVirDev )
126 : : {
127 : : // new solution: set pixel offset at virtual output device
128 [ # # ]: 0 : Point aPixelOffset = _pOrgOutDev->LogicToPixel( _rNewOrigin );
129 [ # # ]: 0 : _pVirDev->SetPixelOffset( Size( -aPixelOffset.X(), -aPixelOffset.Y() ) );
130 : 0 : }
131 : :
132 : :
133 : : /*************************************************************************
134 : : * SwVOut::DoesFit()
135 : : *************************************************************************/
136 : :
137 : : // rSize must be pixel coordinates!
138 : 0 : sal_Bool SwLayVout::DoesFit( const Size &rNew )
139 : : {
140 [ # # ]: 0 : if( rNew.Height() > VIRTUALHEIGHT )
141 : 0 : return sal_False;
142 [ # # ][ # # ]: 0 : if( rNew.Width() <= 0 || rNew.Height() <= 0 )
[ # # ]
143 : 0 : return sal_False;
144 [ # # ]: 0 : if( rNew.Width() <= aSize.Width() )
145 : 0 : return sal_True;
146 [ # # ]: 0 : if( !pVirDev )
147 : : {
148 [ # # ]: 0 : pVirDev = new VirtualDevice();
149 : 0 : pVirDev->SetLineColor();
150 [ # # ]: 0 : if( pOut )
151 : : {
152 [ # # ]: 0 : if( pVirDev->GetFillColor() != pOut->GetFillColor() )
153 : 0 : pVirDev->SetFillColor( pOut->GetFillColor() );
154 : : }
155 : : }
156 : :
157 [ # # ]: 0 : if( rNew.Width() > aSize.Width() )
158 : : {
159 : 0 : aSize.Width() = rNew.Width();
160 [ # # ]: 0 : if( !pVirDev->SetOutputSizePixel( aSize ) )
161 : : {
162 [ # # ]: 0 : delete pVirDev;
163 : 0 : pVirDev = NULL;
164 : 0 : aSize.Width() = 0;
165 : 0 : return sal_False;
166 : : }
167 : : }
168 : 0 : return sal_True;
169 : : }
170 : :
171 : : /*************************************************************************
172 : : * SwLayVout::Enter
173 : : *************************************************************************/
174 : : /// OD 27.09.2002 #103636# - change 2nd parameter <rRect> - no longer <const>
175 : : /// in order to return value of class member variable <aRect>, if virtual
176 : : /// output is used.
177 : : /// <aRect> contains the rectangle that represents the area the virtual
178 : : /// output device is used for and that is flushed at the end.
179 : 0 : void SwLayVout::Enter( ViewShell *pShell, SwRect &rRect, sal_Bool bOn )
180 : : {
181 : 0 : Flush();
182 : :
183 : : #ifdef DBG_UTIL
184 : : if( pShell->GetViewOptions()->IsTest3() )
185 : : {
186 : : ++nCount;
187 : : return;
188 : : }
189 : : #endif
190 : :
191 [ # # ][ # # ]: 0 : bOn = bOn && !nCount && rRect.HasArea() && pShell->GetWin();
[ # # ][ # # ]
192 : 0 : ++nCount;
193 [ # # ]: 0 : if( bOn )
194 : : {
195 : 0 : pSh = pShell;
196 : 0 : pOut = NULL;
197 : 0 : OutputDevice *pO = pSh->GetOut();
198 : : // We don't cheat on printers or virtual output devices...
199 [ # # ]: 0 : if( OUTDEV_WINDOW != pO->GetOutDevType() )
200 : : return;
201 : :
202 : 0 : pOut = pO;
203 [ # # ]: 0 : Size aPixSz( pOut->PixelToLogic( Size( 1,1 )) );
204 : 0 : SwRect aTmp( rRect );
205 : 0 : aTmp.SSize().Width() += aPixSz.Width()/2 + 1;
206 : 0 : aTmp.SSize().Height()+= aPixSz.Height()/2 + 1;
207 [ # # ][ # # ]: 0 : Rectangle aTmpRect( pO->LogicToPixel( aTmp.SVRect() ) );
208 : :
209 : : OSL_ENSURE( !pSh->GetWin()->IsReallyVisible() ||
210 : : aTmpRect.GetWidth() <= pSh->GetWin()->GetOutputSizePixel().Width() + 2,
211 : : "Paintwidth bigger than visarea?" );
212 : : // Does the rectangle fit in our buffer?
213 [ # # ][ # # ]: 0 : if( !DoesFit( aTmpRect.GetSize() ) )
[ # # ]
214 : : {
215 : 0 : pOut = NULL;
216 : : return;
217 : : }
218 : :
219 [ # # ][ # # ]: 0 : aRect = SwRect( pO->PixelToLogic( aTmpRect ) );
220 : :
221 [ # # ]: 0 : SetOutDev( pSh, pVirDev );
222 : :
223 [ # # ]: 0 : if( pVirDev->GetFillColor() != pOut->GetFillColor() )
224 [ # # ]: 0 : pVirDev->SetFillColor( pOut->GetFillColor() );
225 : :
226 [ # # ]: 0 : MapMode aMapMode( pOut->GetMapMode() );
227 : : // OD 12.11.2002 #96272# - use method to set mapping
228 : : //aMapMode.SetOrigin( Point(0,0) - aRect.Pos() );
229 [ # # ]: 0 : ::SetMappingForVirtDev( aRect.Pos(), &aMapMode, pOut, pVirDev );
230 : :
231 [ # # ][ # # ]: 0 : if( aMapMode != pVirDev->GetMapMode() )
232 [ # # ]: 0 : pVirDev->SetMapMode( aMapMode );
233 : :
234 : : /// OD 27.09.2002 #103636# - set value of parameter <rRect>
235 [ # # ]: 0 : rRect = aRect;
236 : : }
237 : : }
238 : :
239 : : /*************************************************************************
240 : : * SwLayVout::Flush()
241 : : *************************************************************************/
242 : :
243 : 0 : void SwLayVout::_Flush()
244 : : {
245 : : OSL_ENSURE( pVirDev, "SwLayVout::DrawOut: nothing left Toulouse" );
246 : 0 : pOut->DrawOutDev( aRect.Pos(), aRect.SSize(),
247 : 0 : aRect.Pos(), aRect.SSize(), *pVirDev );
248 : 0 : SetOutDev( pSh, pOut );
249 : 0 : pOut = NULL;
250 : 0 : }
251 : :
252 : :
253 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|