Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
21 :
22 : #include "GeneralUndo.hxx"
23 : #include "dbu_qry.hrc"
24 : #include "SelectionBrowseBox.hxx"
25 :
26 : namespace dbaui
27 : {
28 : // OQueryDesignFieldUndoAct - Basisclass for undo's in the fieldlist of a query design
29 :
30 : class OQueryDesignFieldUndoAct : public OCommentUndoAction
31 : {
32 : protected:
33 : OSelectionBrowseBox* pOwner;
34 : sal_uInt16 m_nColumnPostion;
35 :
36 : virtual void Undo() SAL_OVERRIDE = 0;
37 : virtual void Redo() SAL_OVERRIDE = 0;
38 :
39 : public:
40 : OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID);
41 : virtual ~OQueryDesignFieldUndoAct();
42 :
43 0 : inline void SetColumnPosition(sal_uInt16 _nColumnPostion)
44 : {
45 0 : m_nColumnPostion = _nColumnPostion;
46 : OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
47 : OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
48 0 : }
49 : };
50 :
51 : // OTabFieldCellModifiedUndoAct - undo class to change a line of the column description
52 :
53 0 : class OTabFieldCellModifiedUndoAct : public OQueryDesignFieldUndoAct
54 : {
55 : protected:
56 : OUString m_strNextCellContents;
57 : sal_Int32 m_nCellIndex;
58 :
59 : public:
60 0 : OTabFieldCellModifiedUndoAct(OSelectionBrowseBox* pSelBrwBox)
61 : : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_MODIFY_CELL)
62 0 : ,m_nCellIndex(BROWSER_INVALIDID){ }
63 :
64 0 : inline void SetCellContents(const OUString& str) { m_strNextCellContents = str; }
65 0 : inline void SetCellIndex(sal_Int32 nIndex) { m_nCellIndex = nIndex; }
66 :
67 : virtual void Undo() SAL_OVERRIDE;
68 0 : virtual void Redo() SAL_OVERRIDE { Undo(); }
69 : };
70 :
71 : // OTabFieldSizedUndoAct - undo class to change the column width
72 :
73 0 : class OTabFieldSizedUndoAct : public OQueryDesignFieldUndoAct
74 : {
75 : protected:
76 : long m_nNextWidth;
77 :
78 : public:
79 0 : OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { }
80 :
81 0 : inline void SetOriginalWidth(long nWidth) { m_nNextWidth = nWidth; }
82 :
83 : virtual void Undo() SAL_OVERRIDE;
84 0 : virtual void Redo() SAL_OVERRIDE { Undo(); }
85 : };
86 :
87 : // OTabFieldUndoAct - base class for undos in the fieldlist of a query design, which are used to change complete field descriptions
88 :
89 0 : class OTabFieldUndoAct : public OQueryDesignFieldUndoAct
90 : {
91 : protected:
92 : OTableFieldDescRef pDescr; // geloeschte Spaltenbeschreibung
93 :
94 : public:
95 0 : OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, nCommentID) { }
96 :
97 0 : void SetTabFieldDescr(OTableFieldDescRef pDescription) { pDescr = pDescription; }
98 : };
99 :
100 : // OTabFieldDelUndoAct - undo class to delete a field
101 :
102 0 : class OTabFieldDelUndoAct : public OTabFieldUndoAct
103 : {
104 : protected:
105 0 : virtual void Undo() SAL_OVERRIDE { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode(); }
106 0 : virtual void Redo() SAL_OVERRIDE { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode(); }
107 :
108 : public:
109 0 : OTabFieldDelUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDDELETE) { }
110 : };
111 :
112 : // OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes
113 : // OTabFieldDelUndoAct - undo class to create a field
114 :
115 0 : class OTabFieldCreateUndoAct : public OTabFieldUndoAct
116 : {
117 : protected:
118 0 : virtual void Undo() SAL_OVERRIDE { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode();}
119 0 : virtual void Redo() SAL_OVERRIDE { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode();}
120 :
121 : public:
122 0 : OTabFieldCreateUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDCREATE) { }
123 : };
124 :
125 : // OTabFieldMovedUndoAct - Undo class when a field was moved inside the selection
126 :
127 0 : class OTabFieldMovedUndoAct : public OTabFieldUndoAct
128 : {
129 : protected:
130 : virtual void Undo() SAL_OVERRIDE;
131 0 : virtual void Redo() SAL_OVERRIDE
132 : {
133 0 : Undo();
134 0 : }
135 :
136 : public:
137 0 : OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { }
138 : };
139 : }
140 : #endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|