2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 18:57:46 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:57:46 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:57:46 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:57:46 +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 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:57:46 +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 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:57:46 +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 23:16:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-07-21 10:38:55 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sc.hxx"
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#include "printopt.hxx"
|
2001-05-29 18:46:58 +00:00
|
|
|
#include "miscuno.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
using namespace utl;
|
|
|
|
using namespace com::sun::star::uno;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-02-24 15:22:42 +01:00
|
|
|
using ::rtl::OUString;
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
TYPEINIT1(ScTpPrintItem, SfxPoolItem);
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
ScPrintOptions::ScPrintOptions()
|
|
|
|
{
|
|
|
|
SetDefaults();
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
ScPrintOptions::ScPrintOptions( const ScPrintOptions& rCpy ) :
|
|
|
|
bSkipEmpty( rCpy.bSkipEmpty ),
|
|
|
|
bAllSheets( rCpy.bAllSheets )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
ScPrintOptions::~ScPrintOptions()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
void ScPrintOptions::SetDefaults()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
bSkipEmpty = sal_True;
|
2011-03-10 16:55:21 -05:00
|
|
|
bAllSheets = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
const ScPrintOptions& ScPrintOptions::operator=( const ScPrintOptions& rCpy )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-05-29 18:46:58 +00:00
|
|
|
bSkipEmpty = rCpy.bSkipEmpty;
|
|
|
|
bAllSheets = rCpy.bAllSheets;
|
|
|
|
return *this;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2009-05-11 14:05:52 +00:00
|
|
|
int ScPrintOptions::operator==( const ScPrintOptions& rOpt ) const
|
2001-05-29 18:46:58 +00:00
|
|
|
{
|
|
|
|
return bSkipEmpty == rOpt.bSkipEmpty
|
|
|
|
&& bAllSheets == rOpt.bAllSheets;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2009-05-11 14:05:52 +00:00
|
|
|
int ScPrintOptions::operator!=( const ScPrintOptions& rOpt ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-05-29 18:46:58 +00:00
|
|
|
return !(operator==(rOpt));
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
ScTpPrintItem::ScTpPrintItem( sal_uInt16 nWhichP, const ScPrintOptions& rOpt ) :
|
2007-02-27 11:17:50 +00:00
|
|
|
SfxPoolItem ( nWhichP ),
|
2001-05-29 18:46:58 +00:00
|
|
|
theOptions ( rOpt )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
ScTpPrintItem::ScTpPrintItem( const ScTpPrintItem& rItem ) :
|
|
|
|
SfxPoolItem ( rItem ),
|
|
|
|
theOptions ( rItem.theOptions )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
ScTpPrintItem::~ScTpPrintItem()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
String ScTpPrintItem::GetValueText() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-05-29 18:46:58 +00:00
|
|
|
return String::CreateFromAscii( "ScTpPrintItem" );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
int ScTpPrintItem::operator==( const SfxPoolItem& rItem ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
|
|
|
|
|
|
|
|
const ScTpPrintItem& rPItem = (const ScTpPrintItem&)rItem;
|
|
|
|
return ( theOptions == rPItem.theOptions );
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
SfxPoolItem* ScTpPrintItem::Clone( SfxItemPool * ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return new ScTpPrintItem( *this );
|
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
#define CFGPATH_PRINT "Office.Calc/Print"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
#define SCPRINTOPT_EMPTYPAGES 0
|
|
|
|
#define SCPRINTOPT_ALLSHEETS 1
|
|
|
|
#define SCPRINTOPT_COUNT 2
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
Sequence<OUString> ScPrintCfg::GetPropertyNames()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-05-29 18:46:58 +00:00
|
|
|
static const char* aPropNames[] =
|
|
|
|
{
|
|
|
|
"Page/EmptyPages", // SCPRINTOPT_EMPTYPAGES
|
|
|
|
"Other/AllSheets" // SCPRINTOPT_ALLSHEETS
|
|
|
|
};
|
|
|
|
Sequence<OUString> aNames(SCPRINTOPT_COUNT);
|
|
|
|
OUString* pNames = aNames.getArray();
|
|
|
|
for(int i = 0; i < SCPRINTOPT_COUNT; i++)
|
|
|
|
pNames[i] = OUString::createFromAscii(aPropNames[i]);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
return aNames;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
ScPrintCfg::ScPrintCfg() :
|
2010-11-11 10:10:14 +00:00
|
|
|
ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_PRINT )) )
|
2001-05-29 18:46:58 +00:00
|
|
|
{
|
|
|
|
Sequence<OUString> aNames = GetPropertyNames();
|
|
|
|
Sequence<Any> aValues = GetProperties(aNames);
|
|
|
|
const Any* pValues = aValues.getConstArray();
|
2008-11-10 15:06:12 +00:00
|
|
|
DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
|
2001-05-29 18:46:58 +00:00
|
|
|
if(aValues.getLength() == aNames.getLength())
|
|
|
|
{
|
|
|
|
for(int nProp = 0; nProp < aNames.getLength(); nProp++)
|
|
|
|
{
|
2008-11-10 15:06:12 +00:00
|
|
|
DBG_ASSERT(pValues[nProp].hasValue(), "property value missing");
|
2001-05-29 18:46:58 +00:00
|
|
|
if(pValues[nProp].hasValue())
|
|
|
|
{
|
|
|
|
switch(nProp)
|
|
|
|
{
|
|
|
|
case SCPRINTOPT_EMPTYPAGES:
|
|
|
|
// reversed
|
|
|
|
SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
|
|
|
|
break;
|
|
|
|
case SCPRINTOPT_ALLSHEETS:
|
|
|
|
SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
void ScPrintCfg::Commit()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-05-29 18:46:58 +00:00
|
|
|
Sequence<OUString> aNames = GetPropertyNames();
|
|
|
|
Sequence<Any> aValues(aNames.getLength());
|
|
|
|
Any* pValues = aValues.getArray();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
for(int nProp = 0; nProp < aNames.getLength(); nProp++)
|
|
|
|
{
|
|
|
|
switch(nProp)
|
|
|
|
{
|
|
|
|
case SCPRINTOPT_EMPTYPAGES:
|
|
|
|
// reversed
|
|
|
|
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], !GetSkipEmpty() );
|
|
|
|
break;
|
|
|
|
case SCPRINTOPT_ALLSHEETS:
|
|
|
|
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAllSheets() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PutProperties(aNames, aValues);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2001-05-29 18:46:58 +00:00
|
|
|
void ScPrintCfg::SetOptions( const ScPrintOptions& rNew )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-05-29 18:46:58 +00:00
|
|
|
*(ScPrintOptions*)this = rNew;
|
|
|
|
SetModified();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 15:22:42 +01:00
|
|
|
void ScPrintCfg::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|