Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / sc / source / ui / view / output3.cxx
blobeb4ff52e69a9c8775c781ad3175e9deb7de3a29c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 #include "output.hxx"
30 #include "drwlayer.hxx"
31 #include "document.hxx"
32 #include "tabvwsh.hxx"
33 #include "fillinfo.hxx"
35 #include <svx/fmview.hxx>
37 // STATIC DATA -----------------------------------------------------------
39 SdrObject* pSkipPaintObj = NULL;
41 //==================================================================
43 // #i72502#
44 Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
46 Rectangle aRect;
47 SCCOL nCol;
48 Point aOffset;
49 long nLayoutSign(bLayoutRTL ? -1 : 1);
51 for (nCol=0; nCol<nX1; nCol++)
52 aOffset.X() -= mpDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
53 aOffset.Y() -= mpDoc->GetRowHeight( 0, nY1-1, nTab );
55 long nDataWidth = 0;
56 for (nCol=nX1; nCol<=nX2; nCol++)
57 nDataWidth += mpDoc->GetColWidth( nCol, nTab );
59 if ( bLayoutRTL )
60 aOffset.X() += nDataWidth;
62 aRect.Left() = aRect.Right() = -aOffset.X();
63 aRect.Top() = aRect.Bottom() = -aOffset.Y();
65 Point aMMOffset( aOffset );
66 aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
67 aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
69 if (!bMetaFile)
70 aMMOffset += Point( nLogStX, nLogStY );
72 for (nCol=nX1; nCol<=nX2; nCol++)
73 aRect.Right() += mpDoc->GetColWidth( nCol, nTab );
74 aRect.Bottom() += mpDoc->GetRowHeight( nY1, nY2, nTab );
76 aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS);
77 aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS);
78 aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS);
79 aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
81 if(pViewShell || pDrawView)
83 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
85 if(pLocalDrawView)
87 // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
88 MapMode aOldMode = mpDev->GetMapMode();
89 if (!bMetaFile)
90 mpDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
92 // #i74769# work with SdrPaintWindow directly
93 // #i76114# pass bDisableIntersect = true, because the intersection of the table area
94 // with the Window's paint region can be empty
95 Region aRectRegion(aRect);
96 mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(mpDev, aRectRegion, true);
97 OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
99 if (!bMetaFile)
100 mpDev->SetMapMode( aOldMode );
104 return aMMOffset;
107 // #i72502#
108 void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
110 // #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
111 // painted with offset
112 MapMode aOldMode = mpDev->GetMapMode();
114 if (!bMetaFile)
116 mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
119 if(pViewShell || pDrawView)
121 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
123 if(pLocalDrawView)
125 // #i74769# work with SdrPaintWindow directly
126 pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
127 mpTargetPaintWindow = 0;
131 // #i74768#
132 if (!bMetaFile)
134 mpDev->SetMapMode( aOldMode );
138 // #i72502#
139 void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
141 bool bHideAllDrawingLayer(false);
143 if(pViewShell || pDrawView)
145 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
147 if(pLocalDrawView)
149 bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
150 && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
154 // #109985#
155 if(bHideAllDrawingLayer || (!mpDoc->GetDrawLayer()))
157 return;
160 MapMode aOldMode = mpDev->GetMapMode();
162 if (!bMetaFile)
164 mpDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
167 // #109985#
168 DrawSelectiveObjects( nLayer );
170 if (!bMetaFile)
172 mpDev->SetMapMode( aOldMode );
176 // #109985#
177 void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
179 ScDrawLayer* pModel = mpDoc->GetDrawLayer();
180 if (!pModel)
181 return;
183 // #i46362# high contrast mode (and default text direction) must be handled
184 // by the application, so it's still needed when using DrawLayer().
186 SdrOutliner& rOutl = pModel->GetDrawOutliner();
187 rOutl.EnableAutoColor( mbUseStyleColor );
188 rOutl.SetDefaultHorizontalTextDirection(
189 (EEHorizontalTextDirection)mpDoc->GetEditTextDirection( nTab ) );
191 // #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
192 // LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
193 // so it's not a performance problem to call UseHyphenator even when it's not needed.
195 pModel->UseHyphenator();
197 sal_uLong nOldDrawMode = mpDev->GetDrawMode();
198 if ( mbUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
200 mpDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
201 DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
204 // #109985#
205 if(pViewShell || pDrawView)
207 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
209 if(pLocalDrawView)
211 SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
213 if(pPageView)
215 pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), mpDev);
220 mpDev->SetDrawMode(nOldDrawMode);
222 // #109985#
223 return;
226 // Teile nur fuer Bildschirm
228 // #109985#
229 void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
231 sal_Bool bHad = false;
232 SCSIZE nArrY;
233 for (nArrY=1; nArrY+1<nArrCount; nArrY++)
235 RowInfo* pThisRowInfo = &pRowInfo[nArrY];
237 if ( pThisRowInfo->bChanged )
239 if (!bHad)
241 bHad = sal_True;
244 else if (bHad)
246 DrawSelectiveObjects( nLayer );
247 bHad = false;
251 if (bHad)
252 DrawSelectiveObjects( nLayer );
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */