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