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 INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
22 #include "GeneralUndo.hxx"
23 #include "dbu_qry.hrc"
24 #include "SelectionBrowseBox.hxx"
28 // OQueryDesignFieldUndoAct - Basisclass for undo's in the fieldlist of a query design
30 class OQueryDesignFieldUndoAct
: public OCommentUndoAction
33 VclPtr
<OSelectionBrowseBox
> pOwner
;
34 sal_uInt16 m_nColumnPostion
;
36 virtual void Undo() SAL_OVERRIDE
= 0;
37 virtual void Redo() SAL_OVERRIDE
= 0;
40 OQueryDesignFieldUndoAct(OSelectionBrowseBox
* pSelBrwBox
, sal_uInt16 nCommentID
);
41 virtual ~OQueryDesignFieldUndoAct();
43 inline void SetColumnPosition(sal_uInt16 _nColumnPostion
)
45 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!");
51 // OTabFieldCellModifiedUndoAct - undo class to change a line of the column description
53 class OTabFieldCellModifiedUndoAct
: public OQueryDesignFieldUndoAct
56 OUString m_strNextCellContents
;
57 sal_Int32 m_nCellIndex
;
60 OTabFieldCellModifiedUndoAct(OSelectionBrowseBox
* pSelBrwBox
)
61 : OQueryDesignFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_MODIFY_CELL
)
62 ,m_nCellIndex(BROWSER_INVALIDID
){ }
64 inline void SetCellContents(const OUString
& str
) { m_strNextCellContents
= str
; }
65 inline void SetCellIndex(sal_Int32 nIndex
) { m_nCellIndex
= nIndex
; }
67 virtual void Undo() SAL_OVERRIDE
;
68 virtual void Redo() SAL_OVERRIDE
{ Undo(); }
71 // OTabFieldSizedUndoAct - undo class to change the column width
73 class OTabFieldSizedUndoAct
: public OQueryDesignFieldUndoAct
79 OTabFieldSizedUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OQueryDesignFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_SIZE_COLUMN
), m_nNextWidth(0) { }
81 inline void SetOriginalWidth(long nWidth
) { m_nNextWidth
= nWidth
; }
83 virtual void Undo() SAL_OVERRIDE
;
84 virtual void Redo() SAL_OVERRIDE
{ Undo(); }
87 // OTabFieldUndoAct - base class for undos in the fieldlist of a query design, which are used to change complete field descriptions
89 class OTabFieldUndoAct
: public OQueryDesignFieldUndoAct
92 OTableFieldDescRef pDescr
; // geloeschte Spaltenbeschreibung
95 OTabFieldUndoAct(OSelectionBrowseBox
* pSelBrwBox
, sal_uInt16 nCommentID
) : OQueryDesignFieldUndoAct(pSelBrwBox
, nCommentID
) { }
97 void SetTabFieldDescr(OTableFieldDescRef pDescription
) { pDescr
= pDescription
; }
100 // OTabFieldDelUndoAct - undo class to delete a field
102 class OTabFieldDelUndoAct
: public OTabFieldUndoAct
105 virtual void Undo() SAL_OVERRIDE
{ pOwner
->EnterUndoMode();pOwner
->InsertColumn(pDescr
, m_nColumnPostion
);pOwner
->LeaveUndoMode(); }
106 virtual void Redo() SAL_OVERRIDE
{ pOwner
->EnterUndoMode();pOwner
->RemoveColumn(pDescr
->GetColumnId());pOwner
->LeaveUndoMode(); }
109 OTabFieldDelUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDDELETE
) { }
112 // OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes
113 // OTabFieldDelUndoAct - undo class to create a field
115 class OTabFieldCreateUndoAct
: public OTabFieldUndoAct
118 virtual void Undo() SAL_OVERRIDE
{ pOwner
->EnterUndoMode();pOwner
->RemoveColumn(pDescr
->GetColumnId());pOwner
->LeaveUndoMode();}
119 virtual void Redo() SAL_OVERRIDE
{ pOwner
->EnterUndoMode();pOwner
->InsertColumn(pDescr
, m_nColumnPostion
);pOwner
->LeaveUndoMode();}
122 OTabFieldCreateUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDCREATE
) { }
125 // OTabFieldMovedUndoAct - Undo class when a field was moved inside the selection
127 class OTabFieldMovedUndoAct
: public OTabFieldUndoAct
130 virtual void Undo() SAL_OVERRIDE
;
131 virtual void Redo() SAL_OVERRIDE
137 OTabFieldMovedUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDMOVED
) { }
140 #endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */