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

« back to all changes in this revision

Viewing changes to kspread/commands/PasteCommand.h

  • 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:
 
1
/* This file is part of the KDE project
 
2
   Copyright 2009 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
 
3
 
 
4
   This library is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
 
 
9
   This library is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
   Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef KSPREAD_PASTE_COMMAND
 
21
#define KSPREAD_PASTE_COMMAND
 
22
 
 
23
#include "AbstractRegionCommand.h"
 
24
 
 
25
#include <KoXmlReader.h>
 
26
 
 
27
#include "Global.h"
 
28
 
 
29
class QMimeData;
 
30
class KoXmlDocument;
 
31
 
 
32
namespace KSpread
 
33
{
 
34
 
 
35
/**
 
36
 * \ingroup Commands
 
37
 * \brief Command to paste cell data.
 
38
 */
 
39
class PasteCommand : public AbstractRegionCommand
 
40
{
 
41
public:
 
42
    PasteCommand(QUndoCommand *parent = 0);
 
43
    virtual ~PasteCommand();
 
44
 
 
45
    /**
 
46
     * Modes used for paste with insertion.
 
47
     */
 
48
    enum InsertionMode {
 
49
        NoInsertion,     ///< No cell insertion.
 
50
        ShiftCells,      ///< Shift cells; determine the direction from the data.
 
51
        ShiftCellsRight, ///< Shift cells to the right.
 
52
        ShiftCellsDown   ///< Shift cells to the bottom.
 
53
    };
 
54
 
 
55
    bool setMimeData(const QMimeData *mimeData);
 
56
    void setInsertionMode(InsertionMode mode);
 
57
    void setMode(Paste::Mode mode);
 
58
    void setOperation(Paste::Operation operation);
 
59
    void setPasteFC(bool force);
 
60
 
 
61
    virtual bool isApproved() const;
 
62
 
 
63
    /**
 
64
     * \param mimeData the MIME data to check
 
65
     * \return \c true , if the MIME type is supported.
 
66
     */
 
67
    static bool supports(const QMimeData *mimeData);
 
68
 
 
69
    /**
 
70
     * Checks wether the clipboard data contains columns or rows.
 
71
     * Used to decide wether the paste with insertion dialog, where
 
72
     * you can choose between shifting cells down or to the right,
 
73
     * has to be shown.
 
74
     * \param mimeData the MIME data to check
 
75
     * \return \c true if the shifting direction is not defined
 
76
     * \return \c false if the clipboard data contains a column or a row
 
77
     */
 
78
    static bool unknownShiftDirection(const QMimeData *mimeData);
 
79
 
 
80
protected:
 
81
    virtual bool preProcessing();
 
82
    virtual bool mainProcessing();
 
83
    virtual bool postProcessing();
 
84
 
 
85
    /**
 
86
     * Creates sub-commands for the region \p element by parsing XML \p data.
 
87
     */
 
88
    bool processXmlData(Element *element, KoXmlDocument *data);
 
89
 
 
90
    /**
 
91
     * Creates sub-commands for the region \p element by parsing plain text.
 
92
     */
 
93
    bool processTextPlain(Element *element);
 
94
 
 
95
private:
 
96
    const QMimeData *   m_mimeData;
 
97
    KoXmlDocument *     m_xmlDocument;
 
98
    InsertionMode       m_insertMode;
 
99
    Paste::Mode         m_pasteMode;
 
100
    Paste::Operation    m_operation;
 
101
    bool                m_pasteFC;
 
102
};
 
103
 
 
104
} // namespace KSpread
 
105
 
 
106
#endif // KSPREAD_PASTE_COMMAND