2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 00:57:28 +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:57:28 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:57:28 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:57:28 +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:57:28 +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:57:28 +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-09-17 04:22:10 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
2010-01-06 19:26:54 +01:00
|
|
|
#include "precompiled_editeng.hxx"
|
2006-09-17 04:22:10 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// include ---------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include <tools/shl.hxx>
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/editrids.hrc>
|
|
|
|
#include <editeng/paperinf.hxx>
|
|
|
|
#include <editeng/eerdll.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
2011-02-16 16:34:02 -05:00
|
|
|
Description: Is the printer valid
|
2000-09-18 16:07:07 +00:00
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
inline sal_Bool IsValidPrinter( const Printer* pPtr )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-13 14:12:48 +01:00
|
|
|
return pPtr->GetName().Len() ? sal_True : sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
//------------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
Size SvxPaperInfo::GetPaperSize( Paper ePaper, MapUnit eUnit )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-06-12 09:36:34 +00:00
|
|
|
PaperInfo aInfo(ePaper);
|
|
|
|
Size aRet(aInfo.getWidth(), aInfo.getHeight()); // in 100thMM
|
|
|
|
return eUnit == MAP_100TH_MM ? aRet : OutputDevice::LogicToLogic(aRet, MAP_100TH_MM, eUnit);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------
|
2011-02-16 16:34:02 -05:00
|
|
|
Description: Return the paper size of the printer, aligned to our
|
|
|
|
own sizes. If no Printer is set in the system, A4 portrait
|
|
|
|
will be delivered as the default paper size.
|
2000-09-18 16:07:07 +00:00
|
|
|
------------------------------------------------------------------------*/
|
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
//Is this method may be confused about the units it returns ?
|
|
|
|
//Always returns TWIPS for known paper sizes or on failure.
|
|
|
|
//But in the case of PAPER_USER paper and with a Printer with a mapmode set
|
|
|
|
//will return in those printer units ?
|
2000-09-18 16:07:07 +00:00
|
|
|
Size SvxPaperInfo::GetPaperSize( const Printer* pPrinter )
|
|
|
|
{
|
|
|
|
if ( !IsValidPrinter(pPrinter) )
|
2009-06-12 09:36:34 +00:00
|
|
|
return GetPaperSize( PAPER_A4 );
|
|
|
|
const Paper ePaper = pPrinter->GetPaper();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
if ( ePaper == PAPER_USER )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-16 16:34:02 -05:00
|
|
|
// Orientation not take into account, as the right size has
|
|
|
|
// been already set by SV
|
2000-09-18 16:07:07 +00:00
|
|
|
Size aPaperSize = pPrinter->GetPaperSize();
|
|
|
|
const Size aInvalidSize;
|
|
|
|
|
|
|
|
if ( aPaperSize == aInvalidSize )
|
2009-06-12 09:36:34 +00:00
|
|
|
return GetPaperSize(PAPER_A4);
|
2000-09-18 16:07:07 +00:00
|
|
|
MapMode aMap1 = pPrinter->GetMapMode();
|
|
|
|
MapMode aMap2;
|
|
|
|
|
|
|
|
if ( aMap1 == aMap2 )
|
|
|
|
aPaperSize =
|
|
|
|
pPrinter->PixelToLogic( aPaperSize, MapMode( MAP_TWIP ) );
|
|
|
|
return aPaperSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Orientation eOrient = pPrinter->GetOrientation();
|
|
|
|
Size aSize( GetPaperSize( ePaper ) );
|
2011-02-16 16:34:02 -05:00
|
|
|
// for Landscape exchange the pages, has already been done by SV
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( eOrient == ORIENTATION_LANDSCAPE )
|
|
|
|
Swap( aSize );
|
|
|
|
return aSize;
|
|
|
|
}
|
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
Paper SvxPaperInfo::GetSvxPaper( const Size &rSize, MapUnit eUnit, bool bSloppy )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-06-12 09:36:34 +00:00
|
|
|
Size aSize(eUnit == MAP_100TH_MM ? rSize : OutputDevice::LogicToLogic(rSize, eUnit, MAP_100TH_MM));
|
|
|
|
PaperInfo aInfo(aSize.Width(), aSize.Height());
|
|
|
|
if (bSloppy)
|
|
|
|
aInfo.doSloppyFit();
|
|
|
|
return aInfo.getPaper();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
long SvxPaperInfo::GetSloppyPaperDimension( long nSize, MapUnit eUnit )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-06-12 09:36:34 +00:00
|
|
|
nSize = eUnit == MAP_100TH_MM ? nSize : OutputDevice::LogicToLogic(nSize, eUnit, MAP_100TH_MM);
|
|
|
|
nSize = PaperInfo::sloppyFitPageDimension(nSize);
|
|
|
|
return eUnit == MAP_100TH_MM ? nSize : OutputDevice::LogicToLogic(nSize, MAP_100TH_MM, eUnit);
|
2006-05-04 14:08:58 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
Size SvxPaperInfo::GetDefaultPaperSize( MapUnit eUnit )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-06-12 09:36:34 +00:00
|
|
|
PaperInfo aInfo(PaperInfo::getSystemDefaultPaper());
|
|
|
|
Size aRet(aInfo.getWidth(), aInfo.getHeight());
|
|
|
|
return eUnit == MAP_100TH_MM ? aRet : OutputDevice::LogicToLogic(aRet, MAP_100TH_MM, eUnit);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------
|
2011-02-16 16:34:02 -05:00
|
|
|
Description: String representation for the SV-defines of paper size
|
2000-09-18 16:07:07 +00:00
|
|
|
------------------------------------------------------------------------*/
|
|
|
|
|
2009-06-12 09:36:34 +00:00
|
|
|
String SvxPaperInfo::GetName( Paper ePaper )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-19 16:33:54 +01:00
|
|
|
return String( Printer::GetPaperName( ePaper ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|