1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
24cdf0e10cSrcweir #define DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef DBAUI_GENERALUNDO_HXX
27cdf0e10cSrcweir #include "GeneralUndo.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _DBU_QRY_HRC_
30cdf0e10cSrcweir #include "dbu_qry.hrc"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
33cdf0e10cSrcweir #include "SelectionBrowseBox.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace dbaui
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	// ================================================================================================
40cdf0e10cSrcweir 	// OQueryDesignFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 	class OQueryDesignFieldUndoAct : public OCommentUndoAction
44cdf0e10cSrcweir 	{
45cdf0e10cSrcweir 	protected:
46cdf0e10cSrcweir 		OSelectionBrowseBox*	pOwner;
47cdf0e10cSrcweir 		sal_uInt16					m_nColumnPostion;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 		virtual void	Undo() = 0;
50cdf0e10cSrcweir 		virtual void	Redo() = 0;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	public:
53cdf0e10cSrcweir 		OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID);
54cdf0e10cSrcweir 		virtual ~OQueryDesignFieldUndoAct();
55cdf0e10cSrcweir 
SetColumnPosition(sal_uInt16 _nColumnPostion)56cdf0e10cSrcweir 		inline void SetColumnPosition(sal_uInt16 _nColumnPostion)
57cdf0e10cSrcweir 		{
58cdf0e10cSrcweir 			m_nColumnPostion = _nColumnPostion;
59cdf0e10cSrcweir 			OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
60cdf0e10cSrcweir 			OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
61cdf0e10cSrcweir 		}
62cdf0e10cSrcweir 	};
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	// ================================================================================================
65cdf0e10cSrcweir 	// OTabFieldCellModifiedUndoAct - Undo-Klasse fuer Aendern einer Zelle einer Spaltenbeschreibung
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	class OTabFieldCellModifiedUndoAct : public OQueryDesignFieldUndoAct
68cdf0e10cSrcweir 	{
69cdf0e10cSrcweir 	protected:
70cdf0e10cSrcweir 		String		m_strNextCellContents;
71cdf0e10cSrcweir 		sal_Int32	m_nCellIndex;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	public:
OTabFieldCellModifiedUndoAct(OSelectionBrowseBox * pSelBrwBox)74cdf0e10cSrcweir 		OTabFieldCellModifiedUndoAct(OSelectionBrowseBox* pSelBrwBox)
75cdf0e10cSrcweir 			: OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_MODIFY_CELL)
76cdf0e10cSrcweir 			,m_nCellIndex(BROWSER_INVALIDID){ }
77cdf0e10cSrcweir 
SetCellContents(const String & str)78cdf0e10cSrcweir 		inline void SetCellContents(const String& str)	{ m_strNextCellContents = str; }
SetCellIndex(sal_Int32 nIndex)79cdf0e10cSrcweir 		inline void SetCellIndex(sal_Int32 nIndex)		{ m_nCellIndex = nIndex; }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 		virtual void Undo();
Redo()82cdf0e10cSrcweir 		virtual void Redo() { Undo(); }
83cdf0e10cSrcweir 	};
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	// ================================================================================================
86cdf0e10cSrcweir 	// OTabFieldSizedUndoAct - Undo-Klasse fuer Aendern einer Spaltenbreite
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	class OTabFieldSizedUndoAct : public OQueryDesignFieldUndoAct
89cdf0e10cSrcweir 	{
90cdf0e10cSrcweir 	protected:
91cdf0e10cSrcweir 		long		m_nNextWidth;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	public:
OTabFieldSizedUndoAct(OSelectionBrowseBox * pSelBrwBox)94cdf0e10cSrcweir 		OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { }
95cdf0e10cSrcweir 
SetOriginalWidth(long nWidth)96cdf0e10cSrcweir 		inline void SetOriginalWidth(long nWidth) { m_nNextWidth = nWidth; }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		virtual void Undo();
Redo()99cdf0e10cSrcweir 		virtual void Redo() { Undo(); }
100cdf0e10cSrcweir 	};
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	// ================================================================================================
103cdf0e10cSrcweir 	// OTabFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf, die mit Veraendern einer kompletten Feldbeschreibung zu tun haben
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	class OTabFieldUndoAct : public OQueryDesignFieldUndoAct
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 	protected:
108cdf0e10cSrcweir 		OTableFieldDescRef		pDescr;		// geloeschte Spaltenbeschreibung
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	public:
OTabFieldUndoAct(OSelectionBrowseBox * pSelBrwBox,sal_uInt16 nCommentID)111cdf0e10cSrcweir 		OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, nCommentID) { }
112cdf0e10cSrcweir 
SetTabFieldDescr(OTableFieldDescRef pDescription)113cdf0e10cSrcweir 		void SetTabFieldDescr(OTableFieldDescRef pDescription) { pDescr = pDescription; }
114cdf0e10cSrcweir 	};
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	// ================================================================================================
117cdf0e10cSrcweir 	// OTabFieldDelUndoAct - Undo-Klasse fuer Loeschen eines Feldes
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	class OTabFieldDelUndoAct : public OTabFieldUndoAct
120cdf0e10cSrcweir 	{
121cdf0e10cSrcweir 	protected:
Undo()122cdf0e10cSrcweir 		virtual void Undo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode(); }
Redo()123cdf0e10cSrcweir 		virtual void Redo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode(); }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	public:
OTabFieldDelUndoAct(OSelectionBrowseBox * pSelBrwBox)126cdf0e10cSrcweir 		OTabFieldDelUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDDELETE) { }
127cdf0e10cSrcweir 	};
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	// ================================================================================================
130cdf0e10cSrcweir 	// OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	class OTabFieldCreateUndoAct : public OTabFieldUndoAct
133cdf0e10cSrcweir 	{
134cdf0e10cSrcweir 	protected:
Undo()135cdf0e10cSrcweir 		virtual void Undo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode();}
Redo()136cdf0e10cSrcweir 		virtual void Redo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode();}
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	public:
OTabFieldCreateUndoAct(OSelectionBrowseBox * pSelBrwBox)139cdf0e10cSrcweir 		OTabFieldCreateUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDCREATE) { }
140cdf0e10cSrcweir 	};
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	// ================================================================================================
143cdf0e10cSrcweir 	// OTabFieldMovedUndoAct - Undo-class when a field was moved inside the selection
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	class OTabFieldMovedUndoAct : public OTabFieldUndoAct
146cdf0e10cSrcweir 	{
147cdf0e10cSrcweir 	protected:
148cdf0e10cSrcweir 		virtual void Undo();
Redo()149cdf0e10cSrcweir 		virtual void Redo()
150cdf0e10cSrcweir 		{
151cdf0e10cSrcweir 			Undo();
152cdf0e10cSrcweir 		}
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	public:
OTabFieldMovedUndoAct(OSelectionBrowseBox * pSelBrwBox)155cdf0e10cSrcweir 		OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { }
156cdf0e10cSrcweir 	};
157cdf0e10cSrcweir }
158cdf0e10cSrcweir #endif // DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 
162