Update ooo320-m1
[ooovba.git] / sc / source / ui / view / output3.cxx
blob8efba39e565e1f9ef28b97d911cfc3d861253459
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: output3.cxx,v $
10 * $Revision: 1.28 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <svx/eeitem.hxx>
39 #include <svx/svdograf.hxx>
40 #include <svx/svdoole2.hxx>
41 #include <svx/svdoutl.hxx>
42 #include <svx/svdpage.hxx>
43 #include <svx/svdpagv.hxx>
44 #include <svx/svdview.hxx>
45 #include <vcl/svapp.hxx>
47 #include "output.hxx"
48 #include "drwlayer.hxx"
49 #include "document.hxx"
50 #include "tabvwsh.hxx"
51 #include "fillinfo.hxx"
54 #ifdef IRIX
55 #include <basic/sbx.hxx>
56 #endif
57 #include <svx/fmview.hxx>
59 // STATIC DATA -----------------------------------------------------------
61 SdrObject* pSkipPaintObj = NULL;
63 //==================================================================
65 // #i72502#
66 Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
68 Rectangle aRect;
69 SCCOL nCol;
70 Point aOffset;
71 long nLayoutSign(bLayoutRTL ? -1 : 1);
73 for (nCol=0; nCol<nX1; nCol++)
74 aOffset.X() -= pDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
75 aOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nTab );
77 long nDataWidth = 0;
78 long nDataHeight = 0;
79 for (nCol=nX1; nCol<=nX2; nCol++)
80 nDataWidth += pDoc->GetColWidth( nCol, nTab );
81 nDataHeight += pDoc->GetRowHeight( nY1, nY2, nTab );
83 if ( bLayoutRTL )
84 aOffset.X() += nDataWidth;
86 aRect.Left() = aRect.Right() = -aOffset.X();
87 aRect.Top() = aRect.Bottom() = -aOffset.Y();
89 Point aMMOffset( aOffset );
90 aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
91 aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
93 if (!bMetaFile)
94 aMMOffset += Point( nLogStX, nLogStY );
96 for (nCol=nX1; nCol<=nX2; nCol++)
97 aRect.Right() += pDoc->GetColWidth( nCol, nTab );
98 aRect.Bottom() += pDoc->GetRowHeight( nY1, nY2, nTab );
100 aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS);
101 aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS);
102 aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS);
103 aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
105 if(pViewShell || pDrawView)
107 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
109 if(pLocalDrawView)
111 // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
112 MapMode aOldMode = pDev->GetMapMode();
113 if (!bMetaFile)
114 pDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
116 // #i74769# work with SdrPaintWindow directly
117 // #i76114# pass bDisableIntersect = true, because the intersection of the table area
118 // with the Window's paint region can be empty
119 Region aRectRegion(aRect);
120 mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(pDev, aRectRegion, true);
121 OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
123 if (!bMetaFile)
124 pDev->SetMapMode( aOldMode );
128 return aMMOffset;
131 // #i72502#
132 void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
134 // #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
135 // painted with offset
136 MapMode aOldMode = pDev->GetMapMode();
138 if (!bMetaFile)
140 pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
143 if(pViewShell || pDrawView)
145 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
147 if(pLocalDrawView)
149 // #i74769# work with SdrPaintWindow directly
150 pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
151 mpTargetPaintWindow = 0;
155 // #i74768#
156 if (!bMetaFile)
158 pDev->SetMapMode( aOldMode );
162 // #i72502#
163 void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
165 bool bHideAllDrawingLayer(false);
167 if(pViewShell || pDrawView)
169 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
171 if(pLocalDrawView)
173 bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart() && pLocalDrawView->getHideDraw();
177 // #109985#
178 if(bHideAllDrawingLayer || (!pDoc->GetDrawLayer()))
180 return;
183 MapMode aOldMode = pDev->GetMapMode();
185 if (!bMetaFile)
187 pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
190 // #109985#
191 DrawSelectiveObjects( nLayer );
193 if (!bMetaFile)
195 pDev->SetMapMode( aOldMode );
199 // #109985#
200 void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
202 ScDrawLayer* pModel = pDoc->GetDrawLayer();
203 if (!pModel)
204 return;
206 // #i46362# high contrast mode (and default text direction) must be handled
207 // by the application, so it's still needed when using DrawLayer().
209 SdrOutliner& rOutl = pModel->GetDrawOutliner();
210 rOutl.EnableAutoColor( bUseStyleColor );
211 rOutl.SetDefaultHorizontalTextDirection(
212 (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
214 // #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
215 // LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
216 // so it's not a performance problem to call UseHyphenator even when it's not needed.
218 pModel->UseHyphenator();
220 ULONG nOldDrawMode = pDev->GetDrawMode();
221 if ( bUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
223 pDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
224 DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
227 // #109985#
228 if(pViewShell || pDrawView)
230 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
232 if(pLocalDrawView)
234 SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
236 if(pPageView)
238 pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), pDev);
243 pDev->SetDrawMode(nOldDrawMode);
245 // #109985#
246 return;
249 // Teile nur fuer Bildschirm
251 // #109985#
252 void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
254 BOOL bHad = FALSE;
255 long nPosY = nScrY;
256 SCSIZE nArrY;
257 for (nArrY=1; nArrY+1<nArrCount; nArrY++)
259 RowInfo* pThisRowInfo = &pRowInfo[nArrY];
261 if ( pThisRowInfo->bChanged )
263 if (!bHad)
265 bHad = TRUE;
268 else if (bHad)
270 DrawSelectiveObjects( nLayer );
271 bHad = FALSE;
273 nPosY += pRowInfo[nArrY].nHeight;
276 if (bHad)
277 DrawSelectiveObjects( nLayer );