~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kspread/interfaces/ViewAdaptor.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include "part/Doc.h"
32
32
#include "Map.h"
33
 
#include "Selection.h"
 
33
#include "ui/Selection.h"
34
34
#include "Sheet.h"
35
35
#include "part/View.h"
36
36
#include "part/Canvas.h"
37
37
#include "MapAdaptor.h"
38
38
 
 
39
// commands
 
40
#include "commands/BorderColorCommand.h"
 
41
#include "commands/CommentCommand.h"
 
42
#include "commands/StyleCommand.h"
 
43
 
39
44
#include <KoShapeManager.h>
40
45
#include <KoSelection.h>
41
46
 
148
153
 
149
154
bool ViewAdaptor::showSheet(const QString& sheetName)
150
155
{
151
 
    return m_view->showSheet(sheetName);
 
156
    Sheet *const sheet = m_view->doc()->map()->findSheet(sheetName);
 
157
    if (!sheet) {
 
158
        kDebug(36001) << "Unknown sheet" << sheetName;
 
159
        return false;
 
160
    }
 
161
    m_view->selection()->emitCloseEditor(true); // save changes
 
162
    m_view->setActiveSheet(sheet);
 
163
    return true;
152
164
}
153
165
 
154
166
void ViewAdaptor::previousSheet()
352
364
 
353
365
void ViewAdaptor::setSelectionComment(const QString& comment)
354
366
{
355
 
    m_view->setSelectionComment(comment);
 
367
    CommentCommand* command = new CommentCommand();
 
368
    command->setSheet(m_view->activeSheet());
 
369
    command->setText(i18n("Add Comment"));
 
370
    command->setComment(comment.trimmed());
 
371
    command->add(*m_view->selection());
 
372
    command->execute();
356
373
}
357
374
 
358
375
#if 0 // -> cell tool
364
381
 
365
382
void ViewAdaptor::setSelectionTextColor(const QColor& txtColor)
366
383
{
367
 
    m_view->setSelectionTextColor(txtColor);
 
384
    StyleCommand* command = new StyleCommand();
 
385
    command->setSheet(m_view->activeSheet());
 
386
    command->setText(i18n("Change Text Color"));
 
387
    command->setFontColor(txtColor);
 
388
    command->add(*m_view->selection());
 
389
    command->execute();
368
390
}
369
391
 
370
392
void ViewAdaptor::setSelectionBgColor(const QColor& bgColor)
371
393
{
372
 
    m_view->setSelectionBackgroundColor(bgColor);
 
394
    StyleCommand* command = new StyleCommand();
 
395
    command->setSheet(m_view->activeSheet());
 
396
    command->setText(i18n("Change Background Color"));
 
397
    command->setBackgroundColor(bgColor);
 
398
    command->add(*m_view->selection());
 
399
    command->execute();
373
400
}
374
401
 
375
 
void ViewAdaptor::setSelectionBorderColor(const QColor& bdColor)
 
402
void ViewAdaptor::setSelectionBorderColor(const QColor& bgColor)
376
403
{
377
 
    m_view->setSelectionBorderColor(bdColor);
 
404
    StyleCommand* command = new StyleCommand();
 
405
    command->setSheet(m_view->activeSheet());
 
406
    command->setText(i18n("Change Background Color"));
 
407
    command->setBackgroundColor(bgColor);
 
408
    command->add(*m_view->selection());
 
409
    command->execute();
378
410
}
379
411
 
380
412
#if 0 // -> cell tool
396
428
 
397
429
void ViewAdaptor::setLeftBorderColor(const QColor& color)
398
430
{
399
 
    m_view->setSelectionLeftBorderColor(color);
 
431
    StyleCommand* command = new StyleCommand();
 
432
    command->setSheet(m_view->activeSheet());
 
433
    command->setText(i18n("Change Border"));
 
434
    if (m_view->activeSheet()->layoutDirection() == Qt::RightToLeft)
 
435
        command->setRightBorderPen(QPen(color, 1, Qt::SolidLine));
 
436
    else
 
437
        command->setLeftBorderPen(QPen(color, 1, Qt::SolidLine));
 
438
    command->add(*m_view->selection());
 
439
    command->execute();
400
440
}
401
441
 
402
442
void ViewAdaptor::setTopBorderColor(const QColor& color)
403
443
{
404
 
    m_view->setSelectionTopBorderColor(color);
 
444
    StyleCommand* command = new StyleCommand();
 
445
    command->setSheet(m_view->activeSheet());
 
446
    command->setText(i18n("Change Border"));
 
447
    command->setTopBorderPen(QPen(color, 1, Qt::SolidLine));
 
448
    command->add(*m_view->selection());
 
449
    command->execute();
405
450
}
406
451
 
407
452
void ViewAdaptor::setRightBorderColor(const QColor& color)
408
453
{
409
 
    m_view->setSelectionRightBorderColor(color);
 
454
    StyleCommand* command = new StyleCommand();
 
455
    command->setSheet(m_view->activeSheet());
 
456
    command->setText(i18n("Change Border"));
 
457
    if (m_view->activeSheet()->layoutDirection() == Qt::RightToLeft)
 
458
        command->setLeftBorderPen(QPen(color, 1, Qt::SolidLine));
 
459
    else
 
460
        command->setRightBorderPen(QPen(color, 1, Qt::SolidLine));
 
461
    command->add(*m_view->selection());
 
462
    command->execute();
410
463
}
411
464
 
412
465
void ViewAdaptor::setBottomBorderColor(const QColor& color)
413
466
{
414
 
    m_view->setSelectionBottomBorderColor(color);
 
467
    StyleCommand* command = new StyleCommand();
 
468
    command->setSheet(m_view->activeSheet());
 
469
    command->setText(i18n("Change Border"));
 
470
    command->setBottomBorderPen(QPen(color, 1, Qt::SolidLine));
 
471
    command->add(*m_view->selection());
 
472
    command->execute();
415
473
}
416
474
 
417
475
void ViewAdaptor::setAllBorderColor(const QColor& color)
418
476
{
419
 
    m_view->setSelectionAllBorderColor(color);
 
477
    StyleCommand* command = new StyleCommand();
 
478
    command->setSheet(m_view->activeSheet());
 
479
    command->setText(i18n("Change Border"));
 
480
    command->setTopBorderPen(QPen(color, 1, Qt::SolidLine));
 
481
    command->setBottomBorderPen(QPen(color, 1, Qt::SolidLine));
 
482
    command->setLeftBorderPen(QPen(color, 1, Qt::SolidLine));
 
483
    command->setRightBorderPen(QPen(color, 1, Qt::SolidLine));
 
484
    command->setHorizontalPen(QPen(color, 1, Qt::SolidLine));
 
485
    command->setVerticalPen(QPen(color, 1, Qt::SolidLine));
 
486
    command->add(*m_view->selection());
 
487
    command->execute();
420
488
}
421
489
 
422
490
void ViewAdaptor::setOutlineBorderColor(const QColor& color)
423
491
{
424
 
    m_view->setSelectionOutlineBorderColor(color);
 
492
    StyleCommand* command = new StyleCommand();
 
493
    command->setSheet(m_view->activeSheet());
 
494
    command->setText(i18n("Change Border"));
 
495
    command->setTopBorderPen(QPen(color, 1, Qt::SolidLine));
 
496
    command->setBottomBorderPen(QPen(color, 1, Qt::SolidLine));
 
497
    command->setLeftBorderPen(QPen(color, 1, Qt::SolidLine));
 
498
    command->setRightBorderPen(QPen(color, 1, Qt::SolidLine));
 
499
    command->add(*m_view->selection());
 
500
    command->execute();
425
501
}
426
502
 
427
503
#if 0 // -> cell tool