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