1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbui.hxx"
26 #ifndef DBAUI_OQueryTabWinUndoAct_HXX
27 #include "QueryTabWinUndoAct.hxx"
28 #endif
29 #ifndef _OSL_DIAGNOSE_H_
30 #include <osl/diagnose.h>
31 #endif
32 #ifndef DBAUI_QUERY_TABLEWINDOW_HXX
33 #include "QTableWindow.hxx"
34 #endif
35 #ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
36 #include "QTableWindowData.hxx"
37 #endif
38 #ifndef DBAUI_TABLECONNECTION_HXX
39 #include "TableConnection.hxx"
40 #endif
41 #ifndef DBAUI_TABLECONNECTIONDATA_HXX
42 #include "TableConnectionData.hxx"
43 #endif
44 #ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
45 #include "QueryDesignFieldUndoAct.hxx"
46 #endif
47 #ifndef DBAUI_QUERYTABLEVIEW_HXX
48 #include "QueryTableView.hxx"
49 #endif
50 
51 
52 using namespace dbaui;
DBG_NAME(OQueryDesignFieldUndoAct)53 DBG_NAME(OQueryDesignFieldUndoAct)
54 OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID)
55 	: OCommentUndoAction(nCommentID)
56 	, pOwner(pSelBrwBox)
57 	, m_nColumnPostion(BROWSER_INVALIDID)
58 {
59 	DBG_CTOR(OQueryDesignFieldUndoAct,NULL);
60 }
61 // -----------------------------------------------------------------------------
~OQueryDesignFieldUndoAct()62 OQueryDesignFieldUndoAct::~OQueryDesignFieldUndoAct()
63 {
64 	DBG_DTOR(OQueryDesignFieldUndoAct,NULL);
65 	pOwner = NULL;
66 }
67 // -----------------------------------------------------------------------------
68 
DBG_NAME(OQueryTabWinUndoAct)69 DBG_NAME(OQueryTabWinUndoAct )
70 // ------------------------------------------------------------------------------------------------
71 OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, sal_uInt16 nCommentID)
72 	:OQueryDesignUndoAction(pOwner, nCommentID)
73 	,m_pTabWin(NULL)
74 {
75 	DBG_CTOR(OQueryTabWinUndoAct ,NULL);
76 }
77 //==============================================================================
~OQueryTabWinUndoAct()78 OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
79 {
80 	DBG_DTOR(OQueryTabWinUndoAct ,NULL);
81 	if (m_bOwnerOfObjects)
82 	{	// wenn ich der alleinige Owner des Fenster bin, muss ich dafuer sorgen, dass es geloescht wird
83 		OSL_ENSURE(m_pTabWin != NULL, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin sollte nicht NULL sein");
84 		OSL_ENSURE(!m_pTabWin->IsVisible(), "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : *m_pTabWin sollte nicht sichtbar sein");
85 
86 		if ( m_pTabWin )
87 			m_pTabWin->clearListBox();
88 		delete m_pTabWin;
89 
90 		// und natuerlich auch die entsprechenden Connections
91 		::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
92         ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
93 		for(;aIter != aEnd;++aIter)
94 		{
95 			m_pOwner->DeselectConn(*aIter);
96 			delete (*aIter);
97 		}
98 		m_vTableConnection.clear();
99 	}
100 }
101 //------------------------------------------------------------------------------
Undo()102 void OTabFieldCellModifiedUndoAct::Undo()
103 {
104 	pOwner->EnterUndoMode();
105 	OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
106 	OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
107 	if ( m_nColumnPostion != BROWSER_INVALIDID )
108 	{
109 		sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
110 		String strNext = pOwner->GetCellContents(m_nCellIndex, nColumnId);
111 		pOwner->SetCellContents(m_nCellIndex, nColumnId, m_strNextCellContents);
112 		m_strNextCellContents = strNext;
113 	}
114 	pOwner->LeaveUndoMode();
115 }
116 
117 //------------------------------------------------------------------------------
Undo()118 void OTabFieldSizedUndoAct::Undo()
119 {
120 	pOwner->EnterUndoMode();
121 	OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
122 	if ( m_nColumnPostion != BROWSER_INVALIDID )
123 	{
124 		sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
125 		long nNextWidth = pOwner->GetColumnWidth(nColumnId);
126 		pOwner->SetColWidth(nColumnId, m_nNextWidth);
127 		m_nNextWidth = nNextWidth;
128 	}
129 	pOwner->LeaveUndoMode();
130 }
131 // -----------------------------------------------------------------------------
Undo()132 void OTabFieldMovedUndoAct::Undo()
133 {
134 	pOwner->EnterUndoMode();
135 	OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
136 	if ( m_nColumnPostion != BROWSER_INVALIDID )
137 	{
138 		sal_uInt16 nId = pDescr->GetColumnId();
139 		sal_uInt16 nOldPos = pOwner->GetColumnPos(nId);
140 		pOwner->SetColumnPos(nId,m_nColumnPostion);
141 		pOwner->ColumnMoved(nId,sal_False);
142 		m_nColumnPostion = nOldPos;
143 	}
144 	pOwner->LeaveUndoMode();
145 }
146 // -----------------------------------------------------------------------------
147 
148 
149 
150 
151 
152