1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
20 #define DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
22 #include "GeneralUndo.hxx"
23 #include "dbu_qry.hrc"
24 #include "SelectionBrowseBox.hxx"
29 // ================================================================================================
30 // OQueryDesignFieldUndoAct - Basisclass for undo's in the fieldlist of a query design
33 class OQueryDesignFieldUndoAct
: public OCommentUndoAction
36 OSelectionBrowseBox
* pOwner
;
37 sal_uInt16 m_nColumnPostion
;
39 virtual void Undo() = 0;
40 virtual void Redo() = 0;
43 OQueryDesignFieldUndoAct(OSelectionBrowseBox
* pSelBrwBox
, sal_uInt16 nCommentID
);
44 virtual ~OQueryDesignFieldUndoAct();
46 inline void SetColumnPosition(sal_uInt16 _nColumnPostion
)
48 m_nColumnPostion
= _nColumnPostion
;
49 OSL_ENSURE(m_nColumnPostion
!= BROWSER_INVALIDID
,"Column position was not set add the undo action!");
50 OSL_ENSURE(m_nColumnPostion
< pOwner
->GetColumnCount(),"Position outside the column count!");
54 // ================================================================================================
55 // OTabFieldCellModifiedUndoAct - undo class to change a line of the column description
57 class OTabFieldCellModifiedUndoAct
: public OQueryDesignFieldUndoAct
60 String m_strNextCellContents
;
61 sal_Int32 m_nCellIndex
;
64 OTabFieldCellModifiedUndoAct(OSelectionBrowseBox
* pSelBrwBox
)
65 : OQueryDesignFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_MODIFY_CELL
)
66 ,m_nCellIndex(BROWSER_INVALIDID
){ }
68 inline void SetCellContents(const String
& str
) { m_strNextCellContents
= str
; }
69 inline void SetCellIndex(sal_Int32 nIndex
) { m_nCellIndex
= nIndex
; }
72 virtual void Redo() { Undo(); }
75 // ================================================================================================
76 // OTabFieldSizedUndoAct - undo class to change the column width
78 class OTabFieldSizedUndoAct
: public OQueryDesignFieldUndoAct
84 OTabFieldSizedUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OQueryDesignFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_SIZE_COLUMN
), m_nNextWidth(0) { }
86 inline void SetOriginalWidth(long nWidth
) { m_nNextWidth
= nWidth
; }
89 virtual void Redo() { Undo(); }
92 // ================================================================================================
93 // OTabFieldUndoAct - base class for undos in the fieldlist of a query design, which are used to change complete field descriptions
95 class OTabFieldUndoAct
: public OQueryDesignFieldUndoAct
98 OTableFieldDescRef pDescr
; // geloeschte Spaltenbeschreibung
101 OTabFieldUndoAct(OSelectionBrowseBox
* pSelBrwBox
, sal_uInt16 nCommentID
) : OQueryDesignFieldUndoAct(pSelBrwBox
, nCommentID
) { }
103 void SetTabFieldDescr(OTableFieldDescRef pDescription
) { pDescr
= pDescription
; }
106 // ================================================================================================
107 // OTabFieldDelUndoAct - undo class to delete a field
109 class OTabFieldDelUndoAct
: public OTabFieldUndoAct
112 virtual void Undo() { pOwner
->EnterUndoMode();pOwner
->InsertColumn(pDescr
, m_nColumnPostion
);pOwner
->LeaveUndoMode(); }
113 virtual void Redo() { pOwner
->EnterUndoMode();pOwner
->RemoveColumn(pDescr
->GetColumnId());pOwner
->LeaveUndoMode(); }
116 OTabFieldDelUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDDELETE
) { }
119 // ================================================================================================
120 // OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes
121 // OTabFieldDelUndoAct - undo class to create a field
123 class OTabFieldCreateUndoAct
: public OTabFieldUndoAct
126 virtual void Undo() { pOwner
->EnterUndoMode();pOwner
->RemoveColumn(pDescr
->GetColumnId());pOwner
->LeaveUndoMode();}
127 virtual void Redo() { pOwner
->EnterUndoMode();pOwner
->InsertColumn(pDescr
, m_nColumnPostion
);pOwner
->LeaveUndoMode();}
130 OTabFieldCreateUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDCREATE
) { }
133 // ================================================================================================
134 // OTabFieldMovedUndoAct - Undo class when a field was moved inside the selection
136 class OTabFieldMovedUndoAct
: public OTabFieldUndoAct
146 OTabFieldMovedUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDMOVED
) { }
149 #endif // DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */