Commit fe8d9105 authored by Thomas Zander's avatar Thomas Zander

SVN_SILENT whitespace adjustment to coding style

svn path=/trunk/koffice/; revision=851638
parent cfc2b625
......@@ -29,7 +29,8 @@
#include <KSharedPtr>
#include <KSharedConfig>
class KoCanvasBase::Private {
class KoCanvasBase::Private
{
public:
Private() : shapeController(0), resourceProvider(0), controller(0) {}
~Private() {
......@@ -60,7 +61,8 @@ KoCanvasBase::~KoCanvasBase()
}
KoShapeController * KoCanvasBase::shapeController() const {
KoShapeController * KoCanvasBase::shapeController() const
{
return d->shapeController;
}
......@@ -69,12 +71,14 @@ KoCanvasResourceProvider * KoCanvasBase::resourceProvider() const
return d->resourceProvider;
}
void KoCanvasBase::ensureVisible(const QRectF &rect) {
if(d->controller)
void KoCanvasBase::ensureVisible(const QRectF &rect)
{
if (d->controller)
d->controller->ensureVisible(rect);
}
void KoCanvasBase::setCanvasController(KoCanvasController *controller) {
void KoCanvasBase::setCanvasController(KoCanvasController *controller)
{
d->controller = controller;
}
......@@ -83,7 +87,8 @@ KoCanvasController * KoCanvasBase::canvasController() const
return d->controller;
}
void KoCanvasBase::clipToDocument(const KoShape *, QPointF &) const {
void KoCanvasBase::clipToDocument(const KoShape *, QPointF &) const
{
}
bool KoCanvasBase::isAntialiased() const
......
This diff is collapsed.
......@@ -99,7 +99,7 @@ void Viewport::handleDragEnterEvent(QDragEnterEvent *event)
{
// if not a canvas set then ignore this, makes it possible to assume
// we have a canvas in all the support methods.
if(! (m_parent->canvas() && m_parent->canvas()->canvasWidget()))
if (! (m_parent->canvas() && m_parent->canvas()->canvasWidget()))
return;
if (event->mimeData()->hasFormat(SHAPETEMPLATE_MIMETYPE) ||
event->mimeData()->hasFormat(SHAPEID_MIMETYPE)) {
......@@ -116,7 +116,7 @@ void Viewport::handleDragEnterEvent(QDragEnterEvent *event)
QString id;
dataStream >> id;
QString properties;
if(isTemplate)
if (isTemplate)
dataStream >> properties;
// and finally, there is a point.
......@@ -126,7 +126,7 @@ void Viewport::handleDragEnterEvent(QDragEnterEvent *event)
// The rest of this method is mostly a copy paste from the KoCreateShapeStrategy
// So, lets remove this again when Zagge adds his new class that does this kind of thing. (KoLoadSave)
KoShapeFactory *factory = KoShapeRegistry::instance()->value(id);
if(! factory) {
if (! factory) {
kWarning(30006) << "Application requested a shape that is not registered '" <<
id << "', Ignoring" << endl;
event->ignore();
......@@ -135,7 +135,7 @@ void Viewport::handleDragEnterEvent(QDragEnterEvent *event)
event->setDropAction(Qt::CopyAction);
event->accept();
if(isTemplate) {
if (isTemplate) {
KoProperties props;
props.load(properties);
m_draggedShape = factory->createShapeAndInit( &props, m_parent->canvas()->shapeController()->shapeControllerBase() );
......@@ -146,7 +146,7 @@ void Viewport::handleDragEnterEvent(QDragEnterEvent *event)
Q_ASSERT(m_draggedShape);
if (!m_draggedShape) return;
if( m_draggedShape->shapeId().isEmpty() )
if ( m_draggedShape->shapeId().isEmpty() )
m_draggedShape->setShapeId(factory->id());
m_draggedShape->setZIndex(INT_MAX);
......@@ -154,7 +154,8 @@ void Viewport::handleDragEnterEvent(QDragEnterEvent *event)
}
}
void Viewport::handleDropEvent(QDropEvent *event) {
void Viewport::handleDropEvent(QDropEvent *event)
{
if ( !m_draggedShape ) return;
repaint(m_draggedShape);
......@@ -165,7 +166,7 @@ void Viewport::handleDropEvent(QDropEvent *event) {
m_parent->canvas()->clipToDocument(m_draggedShape, newPos); // ensure the shape is dropped inside the document.
m_draggedShape->setAbsolutePosition( newPos );
QUndoCommand * cmd = m_parent->canvas()->shapeController()->addShape( m_draggedShape );
if(cmd) {
if (cmd) {
m_parent->canvas()->addCommand(cmd);
KoSelection *selection = m_parent->canvas()->shapeManager()->selection();
......@@ -182,7 +183,8 @@ void Viewport::handleDropEvent(QDropEvent *event) {
m_draggedShape = 0;
}
QPointF Viewport::correctPosition(const QPoint &point) const {
QPointF Viewport::correctPosition(const QPoint &point) const
{
QWidget *canvasWidget = m_parent->canvas()->canvasWidget();
Q_ASSERT(canvasWidget); // since we should not allow drag if there is not.
QPoint correctedPos(point.x() - canvasWidget->x(), point.y() - canvasWidget->y());
......@@ -192,8 +194,9 @@ QPointF Viewport::correctPosition(const QPoint &point) const {
return m_parent->canvas()->viewConverter()->viewToDocument(correctedPos);
}
void Viewport::handleDragMoveEvent (QDragMoveEvent *event) {
if(m_draggedShape == 0)
void Viewport::handleDragMoveEvent (QDragMoveEvent *event)
{
if (m_draggedShape == 0)
return;
m_draggedShape->update();
repaint(m_draggedShape);
......@@ -202,7 +205,8 @@ void Viewport::handleDragMoveEvent (QDragMoveEvent *event) {
repaint(m_draggedShape);
}
void Viewport::repaint(KoShape *shape) {
void Viewport::repaint(KoShape *shape)
{
QRect rect = m_parent->canvas()->viewConverter()->documentToView(shape->boundingRect()).toRect();
QWidget *canvasWidget = m_parent->canvas()->canvasWidget();
Q_ASSERT(canvasWidget); // since we should not allow drag if there is not.
......@@ -212,8 +216,9 @@ void Viewport::repaint(KoShape *shape) {
update(rect);
}
void Viewport::handleDragLeaveEvent(QDragLeaveEvent *) {
if(m_draggedShape) {
void Viewport::handleDragLeaveEvent(QDragLeaveEvent *)
{
if (m_draggedShape) {
repaint(m_draggedShape);
m_parent->canvas()->shapeManager()->remove(m_draggedShape);
delete m_draggedShape;
......@@ -225,7 +230,7 @@ void Viewport::handlePaintEvent(QPainter & painter, QPaintEvent *event)
{
Q_UNUSED(event);
// Draw the shadow around the canvas.
if(m_parent->canvas() && m_parent->canvas()->canvasWidget() && m_drawShadow ) {
if (m_parent->canvas() && m_parent->canvas()->canvasWidget() && m_drawShadow ) {
QWidget *canvas = m_parent->canvas()->canvasWidget();
painter.setPen(Qt::black);
QRect rect(canvas->x(), canvas->y(), canvas->width(), canvas->height());
......@@ -234,7 +239,7 @@ void Viewport::handlePaintEvent(QPainter & painter, QPaintEvent *event)
painter.drawLine(rect.right()+2, rect.top()+2, rect.right()+2, rect.bottom()+2);
painter.drawLine(rect.left()+2, rect.bottom()+2, rect.right()+2, rect.bottom()+2);
}
if(m_draggedShape) {
if (m_draggedShape) {
const KoViewConverter *vc = m_parent->canvas()->viewConverter();
painter.save();
......@@ -328,11 +333,11 @@ void Viewport::resetLayout()
if ( marginBottom > 0 ) resizeH = viewH - marginBottom;
}
if( m_parent->canvasMode() == KoCanvasController::AlignTop ) {
if ( m_parent->canvasMode() == KoCanvasController::AlignTop ) {
moveY = 0;
}
if (m_canvas) {
if( m_parent->canvasMode() == KoCanvasController::Infinite )
if ( m_parent->canvasMode() == KoCanvasController::Infinite )
m_canvas->setGeometry( 0, 0, viewW, viewH );
else
m_canvas->setGeometry( moveX, moveY, resizeW, resizeH );
......
......@@ -19,8 +19,10 @@
#include "KoCanvasObserver.h"
KoCanvasObserver::KoCanvasObserver() {
KoCanvasObserver::KoCanvasObserver()
{
}
KoCanvasObserver::~KoCanvasObserver() {
KoCanvasObserver::~KoCanvasObserver()
{
}
......@@ -23,7 +23,8 @@
#include <KoColor.h> // Zut, do we want this? It's convenient, but
// also makes flake dependent on pigment. (BSAR)
class KoCanvasResourceProvider::Private {
class KoCanvasResourceProvider::Private
{
public:
QHash<int, QVariant> resources;
};
......@@ -78,7 +79,7 @@ void KoCanvasResourceProvider::setResource( int key, const KoID & id )
KoColor KoCanvasResourceProvider::koColorResource( int key )
{
if(! d->resources.contains(key)) {
if (! d->resources.contains(key)) {
KoColor empty;
return empty;
}
......@@ -118,7 +119,7 @@ KoID KoCanvasResourceProvider::koIDResource(int key)
void KoCanvasResourceProvider::setHandleRadius( int handleRadius )
{
// do not allow arbitrary small handles
if( handleRadius < 3 )
if ( handleRadius < 3 )
handleRadius = 3;
setResource( KoCanvasResource::HandleRadius, QVariant( handleRadius) );
}
......@@ -133,47 +134,53 @@ void KoCanvasResourceProvider::setUnitChanged()
setResource( KoCanvasResource::Unit, true );
}
bool KoCanvasResourceProvider::boolResource(int key) const {
if(! d->resources.contains(key))
bool KoCanvasResourceProvider::boolResource(int key) const
{
if (! d->resources.contains(key))
return false;
return d->resources[key].toBool();
}
int KoCanvasResourceProvider::intResource(int key) const {
if(! d->resources.contains(key))
int KoCanvasResourceProvider::intResource(int key) const
{
if (! d->resources.contains(key))
return 0;
return d->resources[key].toInt();
}
bool KoCanvasResourceProvider::doubleResource(int key) const {
if(! d->resources.contains(key))
bool KoCanvasResourceProvider::doubleResource(int key) const
{
if (! d->resources.contains(key))
return 0.;
return d->resources[key].toDouble();
}
QString KoCanvasResourceProvider::stringResource(int key)
{
if(! d->resources.contains(key)) {
if (! d->resources.contains(key)) {
QString empty;
return empty;
}
return qvariant_cast<QString>(resource(key));
}
QSizeF KoCanvasResourceProvider::sizeResource(int key) {
if(! d->resources.contains(key)) {
QSizeF KoCanvasResourceProvider::sizeResource(int key)
{
if (! d->resources.contains(key)) {
QSizeF empty;
return empty;
}
return qvariant_cast<QSizeF>(resource(key));
}
bool KoCanvasResourceProvider::hasResource(int key) {
bool KoCanvasResourceProvider::hasResource(int key)
{
return d->resources.contains(key);
}
void KoCanvasResourceProvider::clearResource(int key) {
if(! d->resources.contains(key))
void KoCanvasResourceProvider::clearResource(int key)
{
if (! d->resources.contains(key))
return;
d->resources.remove(key);
QVariant empty;
......
......@@ -46,7 +46,7 @@ KoColorBackground::KoColorBackground()
KoColorBackground::KoColorBackground( const QColor &color, Qt::BrushStyle style )
: d( new Private() )
{
if( style < Qt::SolidPattern || style >= Qt::LinearGradientPattern )
if ( style < Qt::SolidPattern || style >= Qt::LinearGradientPattern )
style = Qt::SolidPattern;
d->style = style;
d->color = color;
......@@ -81,11 +81,11 @@ void KoColorBackground::fillStyle( KoGenStyle &style, KoShapeSavingContext &cont
bool KoColorBackground::loadStyle( KoOdfLoadingContext & context, const QSizeF & )
{
KoStyleStack &styleStack = context.styleStack();
if( ! styleStack.hasProperty( KoXmlNS::draw, "fill" ) )
if ( ! styleStack.hasProperty( KoXmlNS::draw, "fill" ) )
return false;
QString fillStyle = styleStack.property( KoXmlNS::draw, "fill" );
if( fillStyle == "solid" || fillStyle == "hatch" )
if ( fillStyle == "solid" || fillStyle == "hatch" )
{
QBrush brush = KoOdfGraphicStyles::loadOasisFillStyle( styleStack, fillStyle, context.stylesReader() );
d->color = brush.color();
......
This diff is collapsed.
......@@ -37,7 +37,7 @@ KoConnectionShapeConfigWidget::KoConnectionShapeConfigWidget()
void KoConnectionShapeConfigWidget::open(KoShape *shape)
{
m_connection = dynamic_cast<KoConnectionShape*>( shape );
if( ! m_connection )
if ( ! m_connection )
return;
widget.connectionType->blockSignals( true );
......@@ -49,7 +49,7 @@ void KoConnectionShapeConfigWidget::open(KoShape *shape)
void KoConnectionShapeConfigWidget::save()
{
if( ! m_connection )
if ( ! m_connection )
return;
m_connection->setConnectionType( static_cast<KoConnectionShape::Type>( widget.connectionType->currentIndex() ) );
......@@ -57,7 +57,7 @@ void KoConnectionShapeConfigWidget::save()
QUndoCommand * KoConnectionShapeConfigWidget::createCommand()
{
if( ! m_connection )
if ( ! m_connection )
return 0;
else
{
......
......@@ -22,10 +22,12 @@
#include <KoPluginLoader.h>
KoDeviceRegistry::KoDeviceRegistry() {
KoDeviceRegistry::KoDeviceRegistry()
{
}
void KoDeviceRegistry::init() {
void KoDeviceRegistry::init()
{
KoPluginLoader::PluginsConfig config;
config.whiteList = "DevicePlugins";
config.blacklist = "DevicePluginsDisabled";
......@@ -36,7 +38,7 @@ void KoDeviceRegistry::init() {
foreach( QString id, keys() )
{
KoDevice * d = value(id);
if( d )
if ( d )
d->start();
}
}
......@@ -46,7 +48,7 @@ KoDeviceRegistry::~KoDeviceRegistry()
foreach( QString id, keys() )
{
KoDevice * d = value(id);
if( d )
if ( d )
d->stop();
}
}
......@@ -57,7 +59,7 @@ static K3StaticDeleter<KoDeviceRegistry> staticToolRegistryDeleter;
KoDeviceRegistry* KoDeviceRegistry::instance()
{
if(KoDeviceRegistry::s_instance == 0) {
if (KoDeviceRegistry::s_instance == 0) {
staticToolRegistryDeleter.setObject(s_instance, new KoDeviceRegistry());
KoDeviceRegistry::s_instance->init();
}
......
......@@ -39,7 +39,7 @@ public:
}
QGradient * cloneGradient( const QGradient * gradient ) const
{
if( ! gradient )
if ( ! gradient )
return 0;
QGradient * clone = 0;
......@@ -111,7 +111,7 @@ QMatrix KoGradientBackground::matrix() const
void KoGradientBackground::setGradient( QGradient * gradient )
{
if( d->gradient )
if ( d->gradient )
delete d->gradient;
d->gradient = gradient;
......@@ -120,7 +120,7 @@ void KoGradientBackground::setGradient( QGradient * gradient )
void KoGradientBackground::setGradient( const QGradient & gradient )
{
if( d->gradient )
if ( d->gradient )
delete d->gradient;
d->gradient = d->cloneGradient( &gradient );
......@@ -134,7 +134,7 @@ const QGradient * KoGradientBackground::gradient() const
KoGradientBackground& KoGradientBackground::operator = ( const KoGradientBackground &rhs )
{
if( this == &rhs )
if ( this == &rhs )
return *this;
d->matrix = rhs.d->matrix;
......@@ -164,7 +164,7 @@ void KoGradientBackground::fillStyle( KoGenStyle &style, KoShapeSavingContext &c
bool KoGradientBackground::loadStyle( KoOdfLoadingContext & context, const QSizeF &shapeSize )
{
KoStyleStack &styleStack = context.styleStack();
if( ! styleStack.hasProperty( KoXmlNS::draw, "fill" ) )
if ( ! styleStack.hasProperty( KoXmlNS::draw, "fill" ) )
return false;
QString fillStyle = styleStack.property( KoXmlNS::draw, "fill" );
......
......@@ -26,7 +26,8 @@
#include <KDebug>
#include <kmimetype.h>
class KoImageCollection::Private {
class KoImageCollection::Private
{
public:
QList<KoImageData*> images;
};
......@@ -36,32 +37,36 @@ KoImageCollection::KoImageCollection()
{
}
KoImageCollection::~KoImageCollection() {
KoImageCollection::~KoImageCollection()
{
delete d;
}
void KoImageCollection::addImage(KoImageData *image) {
void KoImageCollection::addImage(KoImageData *image)
{
d->images.append(new KoImageData(*image));
}
void KoImageCollection::removeImage(KoImageData *image) {
void KoImageCollection::removeImage(KoImageData *image)
{
foreach(KoImageData *data, d->images) {
if(data->operator==(*image)) {
if (data->operator==(*image)) {
d->images.removeAll(data);
delete data;
}
}
}
bool KoImageCollection::completeLoading(KoStore *store) {
bool KoImageCollection::completeLoading(KoStore *store)
{
foreach(KoImageData *image, d->images) {
if(! store->open(image->storeHref())) {
if (! store->open(image->storeHref())) {
kWarning(30006) << "open image " << image->storeHref() << "failed";
return false;
}
bool ok = image->loadFromFile(new KoStoreDevice(store));
store->close();
if(! ok) {
if (! ok) {
kWarning(30006) << "load image " << image->storeHref() << "failed";
return false;
}
......@@ -69,15 +74,16 @@ bool KoImageCollection::completeLoading(KoStore *store) {
return true;
}
bool KoImageCollection::completeSaving(KoStore *store, KoXmlWriter * manifestWriter ) {
bool KoImageCollection::completeSaving(KoStore *store, KoXmlWriter * manifestWriter )
{
foreach(KoImageData *image, d->images) {
if(image->isTaggedForSaving())
if (image->isTaggedForSaving())
{
if(! store->open(image->storeHref()))
if (! store->open(image->storeHref()))
return false;
bool ok = image->saveToFile(new KoStoreDevice(store));
store->close();
if(! ok)
if (! ok)
return false;
const QString mimetype( KMimeType::findByPath( image->storeHref(), 0 ,true )->name() );
manifestWriter->addManifestEntry( image->storeHref(), mimetype );
......
......@@ -31,7 +31,8 @@
#include <QIODevice>
#include <QPainter>
class KoImageData::Private {
class KoImageData::Private
{
public:
Private(KoImageCollection *c)
: refCount(0)
......@@ -74,30 +75,34 @@ KoImageData::KoImageData(const KoImageData &imageData)
d->refCount++;
}
KoImageData::~KoImageData() {
if(--d->refCount == 0) {
KoImageData::~KoImageData()
{
if (--d->refCount == 0) {
d->collection->removeImage(this);
delete d;
}
}
void KoImageData::setImageQuality(KoImageData::ImageQuality quality) {
if(d->quality == quality) return;
void KoImageData::setImageQuality(KoImageData::ImageQuality quality)
{
if (d->quality == quality) return;
d->pixmap = QPixmap(); // remove data
d->quality = quality;
}
KoImageData::ImageQuality KoImageData::imageQuality() const {
KoImageData::ImageQuality KoImageData::imageQuality() const
{
return d->quality;
}
QPixmap KoImageData::pixmap() {
if(d->pixmap.isNull()) {
QPixmap KoImageData::pixmap()
{
if (d->pixmap.isNull()) {
image(); // force loading if only present in a tmp file
if(! d->image.isNull()) {
if (! d->image.isNull()) {
int multiplier = 150; // max 150 ppi
if(d->quality == NoPreviewImage) {
if (d->quality == NoPreviewImage) {
d->pixmap = QPixmap(1,1);
QPainter p(&d->pixmap);
p.setPen(QPen(Qt::gray));
......@@ -105,16 +110,16 @@ QPixmap KoImageData::pixmap() {
p.end();
return d->pixmap;
}
if(d->quality == LowQuality)
if (d->quality == LowQuality)
multiplier = 50;
else if(d->quality == MediumQuality)
else if (d->quality == MediumQuality)
multiplier = 100;
int width = qMin(d->image.width(), qRound(imageSize().width() * multiplier / 72.));
int height = qMin(d->image.height(), qRound(imageSize().height() * multiplier / 72.));
// kDebug(30004)() <<" image:" << width <<"x" << height;
QImage scaled = d->image.scaled(width, height);
if(d->tempImageFile) // free memory
if (d->tempImageFile) // free memory
d->image = QImage();
d->pixmap = QPixmap::fromImage(scaled);
......@@ -123,15 +128,17 @@ QPixmap KoImageData::pixmap() {
return d->pixmap;
}
KUrl KoImageData::imageLocation() const {
KUrl KoImageData::imageLocation() const
{
return d->url;
}
QString KoImageData::tagForSaving() {
QString KoImageData::tagForSaving()
{
static int counter=0;
d->taggedForSaving=true;
d->storeHref = QString("Pictures/image%1").arg(counter++);
if(d->tempImageFile) {
if (d->tempImageFile) {
// we should set a suffix, unfortunately the tmp file don'thave a correct one set
//d->storeHref +=
}
......@@ -143,34 +150,35 @@ QString KoImageData::tagForSaving() {
return d->storeHref;
}
QString KoImageData::storeHref() const {
QString KoImageData::storeHref() const
{
return d->storeHref;
}
bool KoImageData::saveToFile(QIODevice *device)
{
if(d->tempImageFile) {
if(! d->tempImageFile->open())
if (d->tempImageFile) {
if (! d->tempImageFile->open())
return false;
char * data = new char[32 * 1024];
while(true) {
bool failed = false;
qint64 bytes = d->tempImageFile->read(data, 32*1024);
if(bytes == 0)
if (bytes == 0)
break;
else if(bytes == -1) {
else if (bytes == -1) {
kWarning() << "Failed to read data from the tmpfile\n";
failed = true;
}
while(! failed && bytes > 0) {
qint64 written = device->write(data, bytes);
if(written < 0) {// error!
if (written < 0) {// error!
kWarning() << "Failed to copy the image from the temp to the store\n";
failed = true;
}
bytes -= written;
}
if(failed) { // read or write failed; so lets cleanly abort.
if (failed) { // read or write failed; so lets cleanly abort.
delete[] data;
return false;
}
......@@ -189,7 +197,8 @@ bool KoImageData::isTaggedForSaving()
}
bool KoImageData::loadFromFile(QIODevice *device) {
bool KoImageData::loadFromFile(QIODevice *device)
{
struct Finally {
Finally(QIODevice *d) : device (d), bytes(0) {}
~Finally() {
......@@ -206,30 +215,30 @@ bool KoImageData::loadFromFile(QIODevice *device) {
d->tempImageFile = 0;
d->image = QImage();
if(true) { // right now we tmp file everything device->size() > 25E4) { // larger than 250Kb, save to tmp file.
if (true) { // right now we tmp file everything device->size() > 25E4) { // larger than 250Kb, save to tmp file.
d->tempImageFile = new KTemporaryFile();
if(! d->tempImageFile->open())
if (! d->tempImageFile->open())
return false;
char * data = new char[32 * 1024];
finally.bytes = data;
while(true) {
bool failed = false;
qint64 bytes = device->read(data, 32*1024);
if(bytes == 0)
if (bytes == 0)
break;
else if(bytes == -1) {
else if (bytes == -1) {
kWarning() << "Failed to read data from the store\n";
failed = true;
}
while(! failed && bytes > 0) {
qint64 written = d->tempImageFile->write(data, bytes);
if(written < 0) {// error!
if (written < 0) {// error!
kWarning() << "Failed to copy the image from the store to temp\n";
failed = true;
}
bytes -= written;
}
if(failed) { // read or write failed; so lets cleanly abort.
if (failed) { // read or write failed; so lets cleanly abort.
delete d->tempImageFile;
d->tempImageFile = 0;