LibreOffice Module sc (master) 1
output3.cxx
Go to the documentation of this file.
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 <sal/config.h>
21
23#include <svx/svdoutl.hxx>
24#include <svx/svdpagv.hxx>
25#include <svx/svdview.hxx>
26#include <vcl/svapp.hxx>
27#include <vcl/settings.hxx>
28#include <osl/diagnose.h>
29
30#include <output.hxx>
31#include <drwlayer.hxx>
32#include <document.hxx>
33#include <tabvwsh.hxx>
34
35#include <svx/fmview.hxx>
36
37// #i72502#
39{
40 tools::Rectangle aRect;
41 SCCOL nCol;
42 Point aOffset;
43 tools::Long nLayoutSign(bLayoutRTL ? -1 : 1);
44
45 for (nCol=0; nCol<nX1; nCol++)
46 aOffset.AdjustX( -(mpDoc->GetColWidth( nCol, nTab ) * nLayoutSign) );
47 aOffset.AdjustY( -sal_Int32(mpDoc->GetRowHeight( 0, nY1-1, nTab )) );
48
49 tools::Long nDataWidth = 0;
50 for (nCol=nX1; nCol<=nX2; nCol++)
51 nDataWidth += mpDoc->GetColWidth( nCol, nTab );
52
53 if ( bLayoutRTL )
54 aOffset.AdjustX(nDataWidth );
55
56 aRect.SetLeft( -aOffset.X() );
57 aRect.SetRight( -aOffset.X() );
58 aRect.SetTop( -aOffset.Y() );
59 aRect.SetBottom( -aOffset.Y() );
60
61 Point aMMOffset( aOffset );
64
65 if (!bMetaFile)
66 aMMOffset += Point( nLogStX, nLogStY );
67
68 for (nCol=nX1; nCol<=nX2; nCol++)
69 aRect.AdjustRight(mpDoc->GetColWidth( nCol, nTab ) );
71
76
78 {
79 SdrView* pLocalDrawView = pDrawView ? pDrawView : pViewShell->GetScDrawView();
80
81 if(pLocalDrawView)
82 {
83 // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
84 MapMode aOldMode = mpDev->GetMapMode();
85 if (!bMetaFile)
86 mpDev->SetMapMode( MapMode( MapUnit::Map100thMM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
87
88 // #i74769# work with SdrPaintWindow directly
89 // #i76114# pass bDisableIntersect = true, because the intersection of the table area
90 // with the Window's paint region can be empty
91 vcl::Region aRectRegion(aRect);
92 mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(mpDev, aRectRegion, true);
93 OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
94
95 if (!bMetaFile)
96 mpDev->SetMapMode( aOldMode );
97 }
98 }
99
100 return aMMOffset;
101}
102
103// #i72502#
104void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
105{
106 // #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
107 // painted with offset
108 MapMode aOldMode = mpDev->GetMapMode();
109
110 if (!bMetaFile)
111 {
112 mpDev->SetMapMode( MapMode( MapUnit::Map100thMM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
113 }
114
115 if(pViewShell || pDrawView)
116 {
117 SdrView* pLocalDrawView = pDrawView ? pDrawView : pViewShell->GetScDrawView();
118
119 if(pLocalDrawView)
120 {
121 // #i74769# work with SdrPaintWindow directly
122 pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
123 mpTargetPaintWindow = nullptr;
124 }
125 }
126
127 // #i74768#
128 if (!bMetaFile)
129 {
130 mpDev->SetMapMode( aOldMode );
131 }
132}
133
134// #i72502#
136{
137 bool bHideAllDrawingLayer(false);
138
139 if(pViewShell || pDrawView)
140 {
141 SdrView* pLocalDrawView = pDrawView ? pDrawView : pViewShell->GetScDrawView();
142
143 if(pLocalDrawView)
144 {
145 bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
146 && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
147 }
148 }
149
150 if(bHideAllDrawingLayer || (!mpDoc->GetDrawLayer()))
151 {
152 return;
153 }
154
155 MapMode aOldMode = mpDev->GetMapMode();
156
157 if (!bMetaFile)
158 {
159 mpDev->SetMapMode( MapMode( MapUnit::Map100thMM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
160 }
161
162 DrawSelectiveObjects( nLayer );
163
164 if (!bMetaFile)
165 {
166 mpDev->SetMapMode( aOldMode );
167 }
168}
169
171{
172 ScDrawLayer* pModel = mpDoc->GetDrawLayer();
173 if (!pModel)
174 return;
175
176 // #i46362# high contrast mode (and default text direction) must be handled
177 // by the application, so it's still needed when using DrawLayer().
178
179 SdrOutliner& rOutl = pModel->GetDrawOutliner();
180 rOutl.EnableAutoColor( mbUseStyleColor );
181 rOutl.SetDefaultHorizontalTextDirection(
183
184 // #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
185 // LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
186 // so it's not a performance problem to call UseHyphenator even when it's not needed.
187
188 pModel->UseHyphenator();
189
190 DrawModeFlags nOldDrawMode = mpDev->GetDrawMode();
191 if ( mbUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
192 {
193 mpDev->SetDrawMode( nOldDrawMode | DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill |
194 DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient );
195 }
196
197 if(pViewShell || pDrawView)
198 {
199 SdrView* pLocalDrawView = pDrawView ? pDrawView : pViewShell->GetScDrawView();
200
201 if(pLocalDrawView)
202 {
203 SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
204
205 if(pPageView)
206 {
207 pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), mpDev);
208 }
209 }
210 }
211
212 mpDev->SetDrawMode(nOldDrawMode);
213}
214
215/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawModeFlags
static const AllSettings & GetSettings()
const Fraction & GetScaleX() const
const Fraction & GetScaleY() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4161
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4122
EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const
Definition: documen8.cxx:355
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
void UseHyphenator()
Definition: drwlayer.cxx:411
SCROW nY2
Definition: output.hxx:194
SdrPaintWindow * mpTargetPaintWindow
Definition: output.hxx:241
SCTAB nTab
Definition: output.hxx:185
void PostPrintDrawingLayer(const Point &rMMOffset)
Definition: output3.cxx:104
VclPtr< OutputDevice > mpDev
Definition: output.hxx:178
bool bMetaFile
Definition: output.hxx:213
SCCOL nX1
Definition: output.hxx:191
void PrintDrawingLayer(SdrLayerID nLayer, const Point &rMMOffset)
Definition: output3.cxx:135
SCCOL nX2
Definition: output.hxx:193
ScDocument * mpDoc
Definition: output.hxx:184
FmFormView * pDrawView
Definition: output.hxx:207
SCROW nY1
Definition: output.hxx:192
bool bLayoutRTL
Definition: output.hxx:238
bool mbUseStyleColor
Definition: output.hxx:218
void DrawSelectiveObjects(SdrLayerID nLayer)
Definition: output3.cxx:170
Point PrePrintDrawingLayer(tools::Long nLogStX, tools::Long nLogStY)
Definition: output3.cxx:38
ScTabViewShell * pViewShell
Definition: output.hxx:205
ScDrawView * GetScDrawView()
Definition: tabview.hxx:352
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
void DrawLayer(SdrLayerID nID, OutputDevice *pGivenTarget, sdr::contact::ViewObjectContactRedirector *pRedirector=nullptr, const tools::Rectangle &rRect=tools::Rectangle(), basegfx::B2IRectangle const *pPageFrame=nullptr)
void EndDrawLayers(SdrPaintWindow &rPaintWindow, bool bPaintFormLayer)
bool getHideFormControl() const
bool getHideDraw() const
SdrPageView * GetSdrPageView() const
bool getHideOle() const
bool getHideChart() const
SdrPaintWindow * BeginDrawLayers(OutputDevice *pOut, const vcl::Region &rReg, bool bDisableIntersect=false)
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr void SetRight(tools::Long v)
constexpr tools::Long Right() const
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
long Long
sal_Int16 SCCOL
Definition: types.hxx:21