2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 00:28:35 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:28:35 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:28:35 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:28:35 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:28:35 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:28:35 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-07-21 13:53:11 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sc.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
// INCLUDE ---------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <vcl/outdev.hxx>
|
|
|
|
|
|
|
|
#include "drawutil.hxx"
|
|
|
|
#include "document.hxx"
|
|
|
|
#include "global.hxx"
|
2001-04-18 09:42:15 +00:00
|
|
|
#include "viewdata.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// STATIC DATA -----------------------------------------------------------
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
inline Fraction MakeFraction( long nA, long nB )
|
|
|
|
{
|
|
|
|
return ( nA && nB ) ? Fraction(nA,nB) : Fraction(1,1);
|
|
|
|
}
|
|
|
|
|
2004-06-04 10:59:44 +00:00
|
|
|
void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab,
|
|
|
|
SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
|
2000-09-18 16:07:07 +00:00
|
|
|
OutputDevice* pDev,
|
|
|
|
const Fraction& rZoomX, const Fraction& rZoomY,
|
|
|
|
double nPPTX, double nPPTY,
|
|
|
|
Fraction& rScaleX, Fraction& rScaleY )
|
|
|
|
{
|
|
|
|
long nPixelX = 0;
|
|
|
|
long nTwipsX = 0;
|
|
|
|
long nPixelY = 0;
|
|
|
|
long nTwipsY = 0;
|
2004-06-04 10:59:44 +00:00
|
|
|
for (SCCOL i=nStartCol; i<nEndCol; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-04-18 09:42:15 +00:00
|
|
|
USHORT nWidth = pDoc->GetColWidth(i,nTab);
|
|
|
|
nTwipsX += (long) nWidth;
|
|
|
|
nPixelX += ScViewData::ToPixel( nWidth, nPPTX );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2010-06-23 13:38:34 +02:00
|
|
|
|
|
|
|
for (SCROW nRow = nStartRow; nRow <= nEndRow-1; ++nRow)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-06-23 13:38:34 +02:00
|
|
|
SCROW nLastRow = nRow;
|
|
|
|
if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
|
|
|
|
{
|
|
|
|
nRow = nLastRow;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT nHeight = pDoc->GetRowHeight(nRow, nTab);
|
|
|
|
nTwipsY += static_cast<long>(nHeight);
|
|
|
|
nPixelY += ScViewData::ToPixel(nHeight, nPPTY);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY );
|
|
|
|
Point aPixelLog = pDev->PixelToLogic( Point( nPixelX,nPixelY ), aHMMMode );
|
|
|
|
|
2001-10-16 13:43:14 +00:00
|
|
|
// Fraction(double) ctor can be used here (and avoid overflows of PixelLog * Zoom)
|
|
|
|
// because ReduceInaccurate is called later anyway.
|
|
|
|
|
|
|
|
if ( aPixelLog.X() && nTwipsX )
|
|
|
|
rScaleX = Fraction( ((double)aPixelLog.X()) *
|
|
|
|
((double)rZoomX.GetNumerator()) /
|
|
|
|
((double)nTwipsX) /
|
|
|
|
((double)HMM_PER_TWIPS) /
|
|
|
|
((double)rZoomX.GetDenominator()) );
|
|
|
|
else
|
|
|
|
rScaleX = Fraction( 1, 1 );
|
|
|
|
|
|
|
|
if ( aPixelLog.Y() && nTwipsY )
|
|
|
|
rScaleY = Fraction( ((double)aPixelLog.Y()) *
|
|
|
|
((double)rZoomY.GetNumerator()) /
|
|
|
|
((double)nTwipsY) /
|
|
|
|
((double)HMM_PER_TWIPS) /
|
|
|
|
((double)rZoomY.GetDenominator()) );
|
|
|
|
else
|
|
|
|
rScaleY = Fraction( 1, 1 );
|
|
|
|
|
2010-06-23 13:38:34 +02:00
|
|
|
// 25 bits of accuracy are needed to always hit the right part of
|
|
|
|
// cells in the last rows (was 17 before 1M rows).
|
|
|
|
rScaleX.ReduceInaccurate( 25 );
|
|
|
|
rScaleY.ReduceInaccurate( 25 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|