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 : #include <vcl/settings.hxx>
29 :
30 : #include "output.hxx"
31 : #include "drwlayer.hxx"
32 : #include "document.hxx"
33 : #include "tabvwsh.hxx"
34 : #include "fillinfo.hxx"
35 :
36 : #include <svx/fmview.hxx>
37 :
38 : // #i72502#
39 78 : Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
40 : {
41 78 : Rectangle aRect;
42 : SCCOL nCol;
43 78 : Point aOffset;
44 78 : long nLayoutSign(bLayoutRTL ? -1 : 1);
45 :
46 78 : for (nCol=0; nCol<nX1; nCol++)
47 0 : aOffset.X() -= mpDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
48 78 : aOffset.Y() -= mpDoc->GetRowHeight( 0, nY1-1, nTab );
49 :
50 78 : long nDataWidth = 0;
51 202 : for (nCol=nX1; nCol<=nX2; nCol++)
52 124 : nDataWidth += mpDoc->GetColWidth( nCol, nTab );
53 :
54 78 : if ( bLayoutRTL )
55 0 : aOffset.X() += nDataWidth;
56 :
57 78 : aRect.Left() = aRect.Right() = -aOffset.X();
58 78 : aRect.Top() = aRect.Bottom() = -aOffset.Y();
59 :
60 78 : Point aMMOffset( aOffset );
61 78 : aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
62 78 : aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
63 :
64 78 : if (!bMetaFile)
65 66 : aMMOffset += Point( nLogStX, nLogStY );
66 :
67 202 : for (nCol=nX1; nCol<=nX2; nCol++)
68 124 : aRect.Right() += mpDoc->GetColWidth( nCol, nTab );
69 78 : aRect.Bottom() += mpDoc->GetRowHeight( nY1, nY2, nTab );
70 :
71 78 : aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS);
72 78 : aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS);
73 78 : aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS);
74 78 : aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
75 :
76 78 : if(pViewShell || pDrawView)
77 : {
78 78 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
79 :
80 78 : if(pLocalDrawView)
81 : {
82 : // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
83 78 : MapMode aOldMode = mpDev->GetMapMode();
84 78 : if (!bMetaFile)
85 66 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
86 :
87 : // #i74769# work with SdrPaintWindow directly
88 : // #i76114# pass bDisableIntersect = true, because the intersection of the table area
89 : // with the Window's paint region can be empty
90 156 : vcl::Region aRectRegion(aRect);
91 78 : mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(mpDev, aRectRegion, true);
92 : OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
93 :
94 78 : if (!bMetaFile)
95 144 : mpDev->SetMapMode( aOldMode );
96 : }
97 : }
98 :
99 78 : return aMMOffset;
100 : }
101 :
102 : // #i72502#
103 78 : void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
104 : {
105 : // #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
106 : // painted with offset
107 78 : MapMode aOldMode = mpDev->GetMapMode();
108 :
109 78 : if (!bMetaFile)
110 : {
111 66 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
112 : }
113 :
114 78 : if(pViewShell || pDrawView)
115 : {
116 78 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
117 :
118 78 : if(pLocalDrawView)
119 : {
120 : // #i74769# work with SdrPaintWindow directly
121 78 : pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
122 78 : mpTargetPaintWindow = 0;
123 : }
124 : }
125 :
126 : // #i74768#
127 78 : if (!bMetaFile)
128 : {
129 66 : mpDev->SetMapMode( aOldMode );
130 78 : }
131 78 : }
132 :
133 : // #i72502#
134 234 : void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
135 : {
136 234 : bool bHideAllDrawingLayer(false);
137 :
138 234 : if(pViewShell || pDrawView)
139 : {
140 234 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
141 :
142 234 : if(pLocalDrawView)
143 : {
144 234 : bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
145 234 : && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
146 : }
147 : }
148 :
149 : // #109985#
150 234 : if(bHideAllDrawingLayer || (!mpDoc->GetDrawLayer()))
151 : {
152 234 : return;
153 : }
154 :
155 234 : MapMode aOldMode = mpDev->GetMapMode();
156 :
157 234 : if (!bMetaFile)
158 : {
159 198 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
160 : }
161 :
162 : // #109985#
163 234 : DrawSelectiveObjects( nLayer );
164 :
165 234 : if (!bMetaFile)
166 : {
167 198 : mpDev->SetMapMode( aOldMode );
168 234 : }
169 : }
170 :
171 : // #109985#
172 3182 : void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
173 : {
174 3182 : ScDrawLayer* pModel = mpDoc->GetDrawLayer();
175 3182 : if (!pModel)
176 0 : return;
177 :
178 : // #i46362# high contrast mode (and default text direction) must be handled
179 : // by the application, so it's still needed when using DrawLayer().
180 :
181 3182 : SdrOutliner& rOutl = pModel->GetDrawOutliner();
182 3182 : rOutl.EnableAutoColor( mbUseStyleColor );
183 : rOutl.SetDefaultHorizontalTextDirection(
184 3182 : (EEHorizontalTextDirection)mpDoc->GetEditTextDirection( nTab ) );
185 :
186 : // #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
187 : // LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
188 : // so it's not a performance problem to call UseHyphenator even when it's not needed.
189 :
190 3182 : pModel->UseHyphenator();
191 :
192 3182 : sal_uLong nOldDrawMode = mpDev->GetDrawMode();
193 3182 : if ( mbUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
194 : {
195 : mpDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
196 0 : DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
197 : }
198 :
199 : // #109985#
200 3182 : if(pViewShell || pDrawView)
201 : {
202 3182 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
203 :
204 3182 : if(pLocalDrawView)
205 : {
206 3182 : SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
207 :
208 3182 : if(pPageView)
209 : {
210 3182 : pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), mpDev);
211 : }
212 : }
213 : }
214 :
215 3182 : mpDev->SetDrawMode(nOldDrawMode);
216 :
217 : // #109985#
218 3182 : return;
219 : }
220 :
221 : // Teile nur fuer Bildschirm
222 :
223 : // #109985#
224 0 : void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
225 : {
226 0 : bool bHad = false;
227 : SCSIZE nArrY;
228 0 : for (nArrY=1; nArrY+1<nArrCount; nArrY++)
229 : {
230 0 : RowInfo* pThisRowInfo = &pRowInfo[nArrY];
231 :
232 0 : if ( pThisRowInfo->bChanged )
233 : {
234 0 : if (!bHad)
235 : {
236 0 : bHad = true;
237 : }
238 : }
239 0 : else if (bHad)
240 : {
241 0 : DrawSelectiveObjects( nLayer );
242 0 : bHad = false;
243 : }
244 : }
245 :
246 0 : if (bHad)
247 0 : DrawSelectiveObjects( nLayer );
248 228 : }
249 :
250 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|