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 0 : Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
40 : {
41 0 : Rectangle aRect;
42 : SCCOL nCol;
43 0 : Point aOffset;
44 0 : long nLayoutSign(bLayoutRTL ? -1 : 1);
45 :
46 0 : for (nCol=0; nCol<nX1; nCol++)
47 0 : aOffset.X() -= mpDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
48 0 : aOffset.Y() -= mpDoc->GetRowHeight( 0, nY1-1, nTab );
49 :
50 0 : long nDataWidth = 0;
51 0 : for (nCol=nX1; nCol<=nX2; nCol++)
52 0 : nDataWidth += mpDoc->GetColWidth( nCol, nTab );
53 :
54 0 : if ( bLayoutRTL )
55 0 : aOffset.X() += nDataWidth;
56 :
57 0 : aRect.Left() = aRect.Right() = -aOffset.X();
58 0 : aRect.Top() = aRect.Bottom() = -aOffset.Y();
59 :
60 0 : Point aMMOffset( aOffset );
61 0 : aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
62 0 : aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
63 :
64 0 : if (!bMetaFile)
65 0 : aMMOffset += Point( nLogStX, nLogStY );
66 :
67 0 : for (nCol=nX1; nCol<=nX2; nCol++)
68 0 : aRect.Right() += mpDoc->GetColWidth( nCol, nTab );
69 0 : aRect.Bottom() += mpDoc->GetRowHeight( nY1, nY2, nTab );
70 :
71 0 : aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS);
72 0 : aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS);
73 0 : aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS);
74 0 : aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
75 :
76 0 : if(pViewShell || pDrawView)
77 : {
78 0 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
79 :
80 0 : if(pLocalDrawView)
81 : {
82 : // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
83 0 : MapMode aOldMode = mpDev->GetMapMode();
84 0 : if (!bMetaFile)
85 0 : 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 0 : Region aRectRegion(aRect);
91 0 : mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(mpDev, aRectRegion, true);
92 : OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
93 :
94 0 : if (!bMetaFile)
95 0 : mpDev->SetMapMode( aOldMode );
96 : }
97 : }
98 :
99 0 : return aMMOffset;
100 : }
101 :
102 : // #i72502#
103 0 : 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 0 : MapMode aOldMode = mpDev->GetMapMode();
108 :
109 0 : if (!bMetaFile)
110 : {
111 0 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
112 : }
113 :
114 0 : if(pViewShell || pDrawView)
115 : {
116 0 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
117 :
118 0 : if(pLocalDrawView)
119 : {
120 : // #i74769# work with SdrPaintWindow directly
121 0 : pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
122 0 : mpTargetPaintWindow = 0;
123 : }
124 : }
125 :
126 : // #i74768#
127 0 : if (!bMetaFile)
128 : {
129 0 : mpDev->SetMapMode( aOldMode );
130 0 : }
131 0 : }
132 :
133 : // #i72502#
134 0 : void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
135 : {
136 0 : bool bHideAllDrawingLayer(false);
137 :
138 0 : if(pViewShell || pDrawView)
139 : {
140 0 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
141 :
142 0 : if(pLocalDrawView)
143 : {
144 0 : bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
145 0 : && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
146 : }
147 : }
148 :
149 : // #109985#
150 0 : if(bHideAllDrawingLayer || (!mpDoc->GetDrawLayer()))
151 : {
152 0 : return;
153 : }
154 :
155 0 : MapMode aOldMode = mpDev->GetMapMode();
156 :
157 0 : if (!bMetaFile)
158 : {
159 0 : mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
160 : }
161 :
162 : // #109985#
163 0 : DrawSelectiveObjects( nLayer );
164 :
165 0 : if (!bMetaFile)
166 : {
167 0 : mpDev->SetMapMode( aOldMode );
168 0 : }
169 : }
170 :
171 : // #109985#
172 0 : void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
173 : {
174 0 : ScDrawLayer* pModel = mpDoc->GetDrawLayer();
175 0 : 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 0 : SdrOutliner& rOutl = pModel->GetDrawOutliner();
182 0 : rOutl.EnableAutoColor( mbUseStyleColor );
183 : rOutl.SetDefaultHorizontalTextDirection(
184 0 : (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 0 : pModel->UseHyphenator();
191 :
192 0 : sal_uLong nOldDrawMode = mpDev->GetDrawMode();
193 0 : 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 0 : if(pViewShell || pDrawView)
201 : {
202 0 : SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
203 :
204 0 : if(pLocalDrawView)
205 : {
206 0 : SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
207 :
208 0 : if(pPageView)
209 : {
210 0 : pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), mpDev);
211 : }
212 : }
213 : }
214 :
215 0 : mpDev->SetDrawMode(nOldDrawMode);
216 :
217 : // #109985#
218 0 : return;
219 : }
220 :
221 : // Teile nur fuer Bildschirm
222 :
223 : // #109985#
224 0 : void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
225 : {
226 0 : sal_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 = sal_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 0 : }
249 :
250 :
251 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|