~smartboyhw/ubuntu/raring/calligra/2.6.0-0ubuntu1

« back to all changes in this revision

Viewing changes to libs/kopageapp/KoPADocument.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-10-23 21:09:16 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20121023210916-m82w6zxnxhaxz7va
Tags: 1:2.5.90-0ubuntu1
* New upstream alpha release (LP: #1070436)
  - Add libkactivities-dev and libopenimageio-dev to build-depends
  - Add kubuntu_build_calligraactive.diff to build calligraactive by default
  - Add package for calligraauthor and move files that are shared between
    calligrawords and calligraauthor to calligrawords-common
* Document the patches
* Remove numbers from patches so they follow the same naming scheme as
  the rest of our patches.
* calligra-data breaks replaces krita-data (<< 1:2.5.3) (LP: #1071686)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "KoPADocument.h"
22
22
 
23
 
#include <QPainter>
 
23
#include "KoPACanvas.h"
 
24
#include "KoPAView.h"
 
25
#include "KoPAPage.h"
 
26
#include "KoPAMasterPage.h"
 
27
#include "KoPASavingContext.h"
 
28
#include "KoPALoadingContext.h"
 
29
#include "KoPAViewMode.h"
 
30
#include "KoPAPageProvider.h"
 
31
#include "commands/KoPAPageDeleteCommand.h"
24
32
 
25
33
#include <KoStore.h>
26
34
#include <KoDocumentResourceManager.h>
46
54
#include <KoUpdater.h>
47
55
#include <KoDocumentInfo.h>
48
56
#include <KoVariableManager.h>
49
 
 
50
 
#include "KoPACanvas.h"
51
 
#include "KoPAView.h"
52
 
#include "KoPAPage.h"
53
 
#include "KoPAMasterPage.h"
54
 
#include "KoPASavingContext.h"
55
 
#include "KoPALoadingContext.h"
56
 
#include "KoPAViewMode.h"
57
 
#include "KoPAPageProvider.h"
58
 
#include "commands/KoPAPageDeleteCommand.h"
 
57
#include <KoPart.h>
59
58
 
60
59
#include <kdebug.h>
 
60
#include <kglobal.h>
61
61
#include <kconfig.h>
62
62
#include <kconfiggroup.h>
63
63
 
 
64
#include <QPainter>
 
65
 
64
66
#include <typeinfo>
65
67
 
66
68
class KoPADocument::Private
76
78
    QPointer<KoUpdater> odfPageProgressUpdater;
77
79
};
78
80
 
79
 
KoPADocument::KoPADocument(QObject* parent)
80
 
    : KoDocument(parent),
 
81
KoPADocument::KoPADocument(KoPart *part)
 
82
    : KoDocument(part),
81
83
    d(new Private())
82
84
{
83
85
    d->inlineTextObjectManager = resourceManager()->resource(KoText::InlineTextObjectManager).value<KoInlineTextObjectManager*>();
145
147
    if (d->odfProgressUpdater) {
146
148
        d->odfProgressUpdater->setProgress(0);
147
149
    }
148
 
    KoOdfLoadingContext loadingContext( odfStore.styles(), odfStore.store(), componentData() );
 
150
    KoOdfLoadingContext loadingContext( odfStore.styles(), odfStore.store(), KGlobal::mainComponent());
149
151
    KoPALoadingContext paContext(loadingContext, resourceManager());
150
152
 
151
153
    KoXmlElement content = odfStore.contentDoc().documentElement();
194
196
    loadOdfDocumentStyles( paContext );
195
197
 
196
198
    if ( d->pages.size() > 1 ) {
197
 
        setActionEnabled( KoPAView::ActionDeletePage, false );
 
199
        emit actionsPossible(KoPAView::ActionDeletePage, false);
198
200
    }
199
201
 
200
202
    updatePageCount();
533
535
        return;
534
536
 
535
537
    // the KoShapeController sets the active layer as parent
536
 
    KoPAPageBase * page( pageByShape( shape ) );
537
 
 
538
 
    foreach( KoView *view, views() )
539
 
    {
540
 
        KoPAView * kopaView = static_cast<KoPAView*>( view );
541
 
        kopaView->viewMode()->addShape( shape );
542
 
    }
543
 
 
544
 
    emit shapeAdded( shape );
 
538
    KoPAPageBase *page(pageByShape(shape));
 
539
 
 
540
    emit shapeAdded(shape);
545
541
 
546
542
    // it can happen in kpresenter notes view that there is no page
547
543
    if ( page ) {
556
552
    Q_UNUSED( shape );
557
553
}
558
554
 
559
 
void KoPADocument::removeShape( KoShape *shape )
 
555
void KoPADocument::removeShape(KoShape *shape)
560
556
{
561
 
    if(!shape)
 
557
    if (!shape)
562
558
        return;
563
559
 
564
 
    KoPAPageBase * page( pageByShape( shape ) );
565
 
 
566
 
    foreach( KoView *view, views() )
567
 
    {
568
 
        KoPAView * kopaView = static_cast<KoPAView*>( view );
569
 
        kopaView->viewMode()->removeShape( shape );
570
 
    }
571
 
 
572
 
    emit shapeRemoved( shape );
573
 
 
574
 
    page->shapeRemoved( shape );
575
 
    postRemoveShape( page, shape );
 
560
    KoPAPageBase *page(pageByShape(shape));
 
561
 
 
562
    emit shapeRemoved(shape);
 
563
 
 
564
    page->shapeRemoved(shape);
 
565
    postRemoveShape(page, shape);
576
566
}
577
567
 
578
568
void KoPADocument::postRemoveShape( KoPAPageBase * page, KoShape * shape )
612
602
    return page;
613
603
}
614
604
 
 
605
//F)XME
 
606
/*
615
607
void KoPADocument::updateViews(KoPAPageBase *page)
616
608
{
617
609
    if (!page) return;
630
622
        }
631
623
    }
632
624
}
633
 
 
 
625
*/
634
626
KoPageApp::PageType KoPADocument::pageType() const
635
627
{
636
628
    return KoPageApp::Page;
661
653
    KoDocument::initEmpty();
662
654
}
663
655
 
664
 
void KoPADocument::setActionEnabled( int actions, bool enable )
665
 
{
666
 
    foreach( KoView *view, views() )
667
 
    {
668
 
        KoPAView * kopaView = static_cast<KoPAView*>( view );
669
 
        kopaView->setActionEnabled( actions, enable );
670
 
    }
671
 
}
672
 
 
673
656
void KoPADocument::insertPage( KoPAPageBase* page, int index )
674
657
{
675
658
    if ( !page )
685
668
    pages.insert( index, page );
686
669
    updatePageCount();
687
670
 
688
 
    setActionEnabled( KoPAView::ActionDeletePage, pages.size() > 1 );
 
671
    emit actionsPossible(KoPAView::ActionDeletePage, pages.size() > 1);
689
672
 
690
 
    emit pageAdded( page );
 
673
    emit pageAdded(page);
691
674
}
692
675
 
693
676
void KoPADocument::insertPage( KoPAPageBase* page, KoPAPageBase* after )
711
694
    pages.insert( index, page );
712
695
    updatePageCount();
713
696
 
714
 
    setActionEnabled( KoPAView::ActionDeletePage, pages.size() > 1 );
 
697
    emit actionsPossible(KoPAView::ActionDeletePage, pages.size() > 1);
715
698
 
716
699
    emit pageAdded( page );
717
700
}
733
716
        // change to previous page when the page is the active one if the first one is delete go to the next one
734
717
        int newIndex = index == 0 ? 0 : index - 1;
735
718
        KoPAPageBase * newActivePage = pages.at( newIndex );
736
 
        foreach( KoView *view, views() )
737
 
        {
738
 
            KoPAView * kopaView = static_cast<KoPAView*>( view );
739
 
            if ( page == kopaView->activePage() ) {
740
 
                kopaView->viewMode()->updateActivePage( newActivePage );
741
 
            }
742
 
        }
 
719
 
743
720
        updatePageCount();
 
721
 
 
722
        emit replaceActivePage(page, newActivePage);
 
723
        emit pageRemoved(page);
744
724
    }
745
725
 
746
726
    if ( pages.size() == 1 ) {
747
 
        setActionEnabled( KoPAView::ActionDeletePage, false );
 
727
        emit actionsPossible(KoPAView::ActionDeletePage, false);
748
728
    }
749
729
 
750
 
    emit pageRemoved( page );
751
730
 
752
731
    return index;
753
732
}
775
754
 
776
755
void KoPADocument::loadConfig()
777
756
{
778
 
    KSharedConfigPtr config = componentData().config();
 
757
    KSharedConfigPtr config = KGlobal::mainComponent().config();
779
758
 
780
759
    if( config->hasGroup( "Grid" ) )
781
760
    {
804
783
 
805
784
void KoPADocument::saveConfig()
806
785
{
807
 
    KSharedConfigPtr config = componentData().config();
 
786
    KSharedConfigPtr config = KGlobal::mainComponent().config();
808
787
    KConfigGroup configGroup = config->group( "Grid" );
809
788
    KoGridData defGrid;
810
789