2007-01-05 23:12:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
// local includes
|
|
|
|
#include "pagesize.h"
|
|
|
|
|
|
|
|
using namespace Okular;
|
|
|
|
|
2007-04-17 21:20:35 +00:00
|
|
|
class Okular::PageSizePrivate : public QSharedData
|
2007-01-05 23:12:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-04-17 21:20:35 +00:00
|
|
|
PageSizePrivate()
|
2007-01-05 23:12:06 +00:00
|
|
|
: m_width(0)
|
|
|
|
, m_height(0)
|
|
|
|
{
|
|
|
|
}
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-04-17 21:20:35 +00:00
|
|
|
bool operator==(const PageSizePrivate &rhs) const
|
|
|
|
{
|
|
|
|
return m_width == rhs.m_width && m_height == rhs.m_height && m_name == rhs.m_name;
|
|
|
|
}
|
2020-07-10 22:15:05 +00:00
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
double m_width;
|
|
|
|
double m_height;
|
|
|
|
QString m_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
PageSize::PageSize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PageSize::PageSize(double width, double height, const QString &name)
|
2007-04-17 21:20:35 +00:00
|
|
|
: d(new PageSizePrivate)
|
2007-01-05 23:12:06 +00:00
|
|
|
{
|
|
|
|
d->m_width = width;
|
|
|
|
d->m_height = height;
|
|
|
|
d->m_name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
PageSize::PageSize(const PageSize &pageSize)
|
2007-04-17 21:20:35 +00:00
|
|
|
: d(pageSize.d)
|
2007-01-05 23:12:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PageSize::~PageSize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
double PageSize::width() const
|
|
|
|
{
|
2007-04-17 21:20:35 +00:00
|
|
|
if (!d)
|
|
|
|
return 0;
|
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
return d->m_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
double PageSize::height() const
|
|
|
|
{
|
2007-04-17 21:20:35 +00:00
|
|
|
if (!d)
|
|
|
|
return 0;
|
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
return d->m_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString PageSize::name() const
|
|
|
|
{
|
2007-04-17 21:20:35 +00:00
|
|
|
if (!d)
|
|
|
|
return QString();
|
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
return d->m_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PageSize::isNull() const
|
|
|
|
{
|
2007-04-17 21:20:35 +00:00
|
|
|
if (!d)
|
|
|
|
return true;
|
|
|
|
|
2007-01-05 23:12:06 +00:00
|
|
|
return d->m_width == 0 && d->m_height == 0 && d->m_name.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PageSize::operator==(const PageSize &pageSize) const
|
|
|
|
{
|
2007-04-17 21:20:35 +00:00
|
|
|
// 1st: we're null: check if the other is null too
|
|
|
|
if (!d)
|
|
|
|
return !pageSize.d;
|
|
|
|
// 2nd: we're not null, return if the other is null
|
|
|
|
if (!pageSize.d)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// 3rd: normal == check
|
|
|
|
return *d == *pageSize.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PageSize::operator!=(const PageSize &pageSize) const
|
|
|
|
{
|
|
|
|
return !operator==(pageSize);
|
2007-01-05 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PageSize &PageSize::operator=(const PageSize &pageSize)
|
|
|
|
{
|
|
|
|
if (this == &pageSize)
|
|
|
|
return *this;
|
|
|
|
|
2007-04-17 21:20:35 +00:00
|
|
|
d = pageSize.d;
|
2007-01-05 23:12:06 +00:00
|
|
|
return *this;
|
|
|
|
}
|