Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <editeng/eeitem.hxx>
21 : #include <svx/svdograf.hxx>
22 : #include <svx/svdoole2.hxx>
23 : #include <svx/svdoutl.hxx>
24 : #include <svx/svdpage.hxx>
25 : #include <svx/svdpagv.hxx>
26 : #include <svx/svdview.hxx>
27 : #include <vcl/svapp.hxx>
28 :
29 : #include "output.hxx"
30 : #include "drwlayer.hxx"
31 : #include "document.hxx"
32 : #include "tabvwsh.hxx"
33 : #include "fillinfo.hxx"
34 :
35 : #include <svx/fmview.hxx>
36 :
37 : // STATIC DATA -----------------------------------------------------------
38 :
39 : SdrObject* pSkipPaintObj = NULL;
40 :
41 : //==================================================================
42 :
43 : // #i72502#
44 1 : Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
45 : {
46 1 : Rectangle aRect;
47 : SCCOL nCol;
48 1 : Point aOffset;
49 1 : long nLayoutSign(bLayoutRTL ? -1 : 1);
50 :
51 1 : for (nCol=0; nCol<nX1; nCol++)
52 0 : aOffset.X() -= mpDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
53 1 : aOffset.Y() -= mpDoc->GetRowHeight( 0, nY1-1, nTab );
54 :
55 1 : long nDataWidth = 0;
56 5 : for (nCol=nX1; nCol<=nX2; nCol++)
57 4 : nDataWidth += mpDoc->GetColWidth( nCol, nTab );
58 :
59 1 : if ( bLayoutRTL )
60 0 : aOffset.X() += nDataWidth;
61 :
62 1 : aRect.Left() = aRect.Right() = -aOffset.X();
63 1 : aRect.Top() = aRect.Bottom() = -aOffset.Y();
64 :
65 1 : Point aMMOffset( aOffset );
66 1 : aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
67 1 : aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
68 :
69 1 : if (!bMetaFile)
70 0 : aMMOffset += Point( nLogStX, nLogStY );
71 :
72 5 : for (nCol=nX1; nCol<=nX2; nCol++)
73 4 : aRect.Right() += mpDoc->GetColWidth( nCol, nTab );
74 1 : aRect.Bottom() += mpDoc->GetRowHeight( nY1, nY2, nTab );
75 :
76 1 : aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS);
77 1 : aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS);
78 1 : aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS);
79 1 : aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
80 :
81 1 : if(pViewShell || pDrawView)
82 : {
83 1 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
84 :
85 1 : if(pLocalDrawView)
86 : {
87 : // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
88 1 : MapMode aOldMode = mpDev->GetMapMode();
89 1 : if (!bMetaFile)
90 0 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
91 :
92 : // #i74769# work with SdrPaintWindow directly
93 : // #i76114# pass bDisableIntersect = true, because the intersection of the table area
94 : // with the Window's paint region can be empty
95 1 : Region aRectRegion(aRect);
96 1 : mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(mpDev, aRectRegion, true);
97 : OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
98 :
99 1 : if (!bMetaFile)
100 0 : mpDev->SetMapMode( aOldMode );
101 : }
102 : }
103 :
104 1 : return aMMOffset;
105 : }
106 :
107 : // #i72502#
108 1 : void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
109 : {
110 : // #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
111 : // painted with offset
112 1 : MapMode aOldMode = mpDev->GetMapMode();
113 :
114 1 : if (!bMetaFile)
115 : {
116 0 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
117 : }
118 :
119 1 : if(pViewShell || pDrawView)
120 : {
121 1 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
122 :
123 1 : if(pLocalDrawView)
124 : {
125 : // #i74769# work with SdrPaintWindow directly
126 1 : pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
127 1 : mpTargetPaintWindow = 0;
128 : }
129 : }
130 :
131 : // #i74768#
132 1 : if (!bMetaFile)
133 : {
134 0 : mpDev->SetMapMode( aOldMode );
135 1 : }
136 1 : }
137 :
138 : // #i72502#
139 3 : void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
140 : {
141 3 : bool bHideAllDrawingLayer(false);
142 :
143 3 : if(pViewShell || pDrawView)
144 : {
145 3 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
146 :
147 3 : if(pLocalDrawView)
148 : {
149 3 : bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
150 3 : && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
151 : }
152 : }
153 :
154 : // #109985#
155 3 : if(bHideAllDrawingLayer || (!mpDoc->GetDrawLayer()))
156 : {
157 3 : return;
158 : }
159 :
160 3 : MapMode aOldMode = mpDev->GetMapMode();
161 :
162 3 : if (!bMetaFile)
163 : {
164 0 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
165 : }
166 :
167 : // #109985#
168 3 : DrawSelectiveObjects( nLayer );
169 :
170 3 : if (!bMetaFile)
171 : {
172 0 : mpDev->SetMapMode( aOldMode );
173 3 : }
174 : }
175 :
176 : // #109985#
177 3 : void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
178 : {
179 3 : ScDrawLayer* pModel = mpDoc->GetDrawLayer();
180 3 : if (!pModel)
181 0 : return;
182 :
183 : // #i46362# high contrast mode (and default text direction) must be handled
184 : // by the application, so it's still needed when using DrawLayer().
185 :
186 3 : SdrOutliner& rOutl = pModel->GetDrawOutliner();
187 3 : rOutl.EnableAutoColor( mbUseStyleColor );
188 : rOutl.SetDefaultHorizontalTextDirection(
189 3 : (EEHorizontalTextDirection)mpDoc->GetEditTextDirection( nTab ) );
190 :
191 : // #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
192 : // LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
193 : // so it's not a performance problem to call UseHyphenator even when it's not needed.
194 :
195 3 : pModel->UseHyphenator();
196 :
197 3 : sal_uLong nOldDrawMode = mpDev->GetDrawMode();
198 3 : if ( mbUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
199 : {
200 : mpDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
201 0 : DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
202 : }
203 :
204 : // #109985#
205 3 : if(pViewShell || pDrawView)
206 : {
207 3 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
208 :
209 3 : if(pLocalDrawView)
210 : {
211 3 : SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
212 :
213 3 : if(pPageView)
214 : {
215 3 : pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), mpDev);
216 : }
217 : }
218 : }
219 :
220 3 : mpDev->SetDrawMode(nOldDrawMode);
221 :
222 : // #109985#
223 3 : return;
224 : }
225 :
226 : // Teile nur fuer Bildschirm
227 :
228 : // #109985#
229 0 : void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
230 : {
231 0 : sal_Bool bHad = false;
232 : SCSIZE nArrY;
233 0 : for (nArrY=1; nArrY+1<nArrCount; nArrY++)
234 : {
235 0 : RowInfo* pThisRowInfo = &pRowInfo[nArrY];
236 :
237 0 : if ( pThisRowInfo->bChanged )
238 : {
239 0 : if (!bHad)
240 : {
241 0 : bHad = sal_True;
242 : }
243 : }
244 0 : else if (bHad)
245 : {
246 0 : DrawSelectiveObjects( nLayer );
247 0 : bHad = false;
248 : }
249 : }
250 :
251 0 : if (bHad)
252 0 : DrawSelectiveObjects( nLayer );
253 15 : }
254 :
255 :
256 :
257 :
258 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|