1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 32 33 // INCLUDE --------------------------------------------------------------- 34 35 #include <editeng/eeitem.hxx> 36 #include <svx/svdograf.hxx> 37 #include <svx/svdoole2.hxx> 38 #include <svx/svdoutl.hxx> 39 #include <svx/svdpage.hxx> 40 #include <svx/svdpagv.hxx> 41 #include <svx/svdview.hxx> 42 #include <vcl/svapp.hxx> 43 44 #include "output.hxx" 45 #include "drwlayer.hxx" 46 #include "document.hxx" 47 #include "tabvwsh.hxx" 48 #include "fillinfo.hxx" 49 50 #include <svx/fmview.hxx> 51 52 // STATIC DATA ----------------------------------------------------------- 53 54 SdrObject* pSkipPaintObj = NULL; 55 56 //================================================================== 57 58 // #i72502# 59 Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY ) 60 { 61 Rectangle aRect; 62 SCCOL nCol; 63 Point aOffset; 64 long nLayoutSign(bLayoutRTL ? -1 : 1); 65 66 for (nCol=0; nCol<nX1; nCol++) 67 aOffset.X() -= pDoc->GetColWidth( nCol, nTab ) * nLayoutSign; 68 aOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nTab ); 69 70 long nDataWidth = 0; 71 long nDataHeight = 0; 72 for (nCol=nX1; nCol<=nX2; nCol++) 73 nDataWidth += pDoc->GetColWidth( nCol, nTab ); 74 nDataHeight += pDoc->GetRowHeight( nY1, nY2, nTab ); 75 76 if ( bLayoutRTL ) 77 aOffset.X() += nDataWidth; 78 79 aRect.Left() = aRect.Right() = -aOffset.X(); 80 aRect.Top() = aRect.Bottom() = -aOffset.Y(); 81 82 Point aMMOffset( aOffset ); 83 aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS); 84 aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS); 85 86 if (!bMetaFile) 87 aMMOffset += Point( nLogStX, nLogStY ); 88 89 for (nCol=nX1; nCol<=nX2; nCol++) 90 aRect.Right() += pDoc->GetColWidth( nCol, nTab ); 91 aRect.Bottom() += pDoc->GetRowHeight( nY1, nY2, nTab ); 92 93 aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS); 94 aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS); 95 aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS); 96 aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS); 97 98 if(pViewShell || pDrawView) 99 { 100 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView(); 101 102 if(pLocalDrawView) 103 { 104 // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion 105 MapMode aOldMode = pDev->GetMapMode(); 106 if (!bMetaFile) 107 pDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) ); 108 109 // #i74769# work with SdrPaintWindow directly 110 // #i76114# pass bDisableIntersect = true, because the intersection of the table area 111 // with the Window's paint region can be empty 112 Region aRectRegion(aRect); 113 mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(pDev, aRectRegion, true); 114 OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)"); 115 116 if (!bMetaFile) 117 pDev->SetMapMode( aOldMode ); 118 } 119 } 120 121 return aMMOffset; 122 } 123 124 // #i72502# 125 void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768# 126 { 127 // #i74768# just use offset as in PrintDrawingLayer() to also get the form controls 128 // painted with offset 129 MapMode aOldMode = pDev->GetMapMode(); 130 131 if (!bMetaFile) 132 { 133 pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) ); 134 } 135 136 if(pViewShell || pDrawView) 137 { 138 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView(); 139 140 if(pLocalDrawView) 141 { 142 // #i74769# work with SdrPaintWindow directly 143 pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true); 144 mpTargetPaintWindow = 0; 145 } 146 } 147 148 // #i74768# 149 if (!bMetaFile) 150 { 151 pDev->SetMapMode( aOldMode ); 152 } 153 } 154 155 // #i72502# 156 void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset) 157 { 158 bool bHideAllDrawingLayer(false); 159 160 if(pViewShell || pDrawView) 161 { 162 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView(); 163 164 if(pLocalDrawView) 165 { 166 bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart() 167 && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl(); 168 } 169 } 170 171 // #109985# 172 if(bHideAllDrawingLayer || (!pDoc->GetDrawLayer())) 173 { 174 return; 175 } 176 177 MapMode aOldMode = pDev->GetMapMode(); 178 179 if (!bMetaFile) 180 { 181 pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) ); 182 } 183 184 // #109985# 185 DrawSelectiveObjects( nLayer ); 186 187 if (!bMetaFile) 188 { 189 pDev->SetMapMode( aOldMode ); 190 } 191 } 192 193 // #109985# 194 void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer) 195 { 196 ScDrawLayer* pModel = pDoc->GetDrawLayer(); 197 if (!pModel) 198 return; 199 200 // #i46362# high contrast mode (and default text direction) must be handled 201 // by the application, so it's still needed when using DrawLayer(). 202 203 SdrOutliner& rOutl = pModel->GetDrawOutliner(); 204 rOutl.EnableAutoColor( bUseStyleColor ); 205 rOutl.SetDefaultHorizontalTextDirection( 206 (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) ); 207 208 // #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation). 209 // LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand, 210 // so it's not a performance problem to call UseHyphenator even when it's not needed. 211 212 pModel->UseHyphenator(); 213 214 sal_uLong nOldDrawMode = pDev->GetDrawMode(); 215 if ( bUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) 216 { 217 pDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | 218 DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT ); 219 } 220 221 // #109985# 222 if(pViewShell || pDrawView) 223 { 224 SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView(); 225 226 if(pLocalDrawView) 227 { 228 SdrPageView* pPageView = pLocalDrawView->GetSdrPageView(); 229 230 if(pPageView) 231 { 232 pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), pDev); 233 } 234 } 235 } 236 237 pDev->SetDrawMode(nOldDrawMode); 238 239 // #109985# 240 return; 241 } 242 243 // Teile nur fuer Bildschirm 244 245 // #109985# 246 void ScOutputData::DrawingSingle(const sal_uInt16 nLayer) 247 { 248 sal_Bool bHad = sal_False; 249 long nPosY = nScrY; 250 SCSIZE nArrY; 251 for (nArrY=1; nArrY+1<nArrCount; nArrY++) 252 { 253 RowInfo* pThisRowInfo = &pRowInfo[nArrY]; 254 255 if ( pThisRowInfo->bChanged ) 256 { 257 if (!bHad) 258 { 259 bHad = sal_True; 260 } 261 } 262 else if (bHad) 263 { 264 DrawSelectiveObjects( nLayer ); 265 bHad = sal_False; 266 } 267 nPosY += pRowInfo[nArrY].nHeight; 268 } 269 270 if (bHad) 271 DrawSelectiveObjects( nLayer ); 272 } 273 274 275 276 277