merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / querydesign / QueryTabWinUndoAct.cxx
blobe034d08492bf3ed4b2c94639c933bbbb543e3626
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: QueryTabWinUndoAct.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBAUI_OQueryTabWinUndoAct_HXX
34 #include "QueryTabWinUndoAct.hxx"
35 #endif
36 #ifndef _OSL_DIAGNOSE_H_
37 #include <osl/diagnose.h>
38 #endif
39 #ifndef DBAUI_QUERY_TABLEWINDOW_HXX
40 #include "QTableWindow.hxx"
41 #endif
42 #ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
43 #include "QTableWindowData.hxx"
44 #endif
45 #ifndef DBAUI_TABLECONNECTION_HXX
46 #include "TableConnection.hxx"
47 #endif
48 #ifndef DBAUI_TABLECONNECTIONDATA_HXX
49 #include "TableConnectionData.hxx"
50 #endif
51 #ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
52 #include "QueryDesignFieldUndoAct.hxx"
53 #endif
54 #ifndef DBAUI_QUERYTABLEVIEW_HXX
55 #include "QueryTableView.hxx"
56 #endif
59 using namespace dbaui;
60 DBG_NAME(OQueryDesignFieldUndoAct)
61 OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, USHORT nCommentID)
62 : OCommentUndoAction(nCommentID)
63 , pOwner(pSelBrwBox)
64 , m_nColumnPostion(BROWSER_INVALIDID)
66 DBG_CTOR(OQueryDesignFieldUndoAct,NULL);
68 // -----------------------------------------------------------------------------
69 OQueryDesignFieldUndoAct::~OQueryDesignFieldUndoAct()
71 DBG_DTOR(OQueryDesignFieldUndoAct,NULL);
72 pOwner = NULL;
74 // -----------------------------------------------------------------------------
76 DBG_NAME(OQueryTabWinUndoAct )
77 // ------------------------------------------------------------------------------------------------
78 OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, USHORT nCommentID)
79 :OQueryDesignUndoAction(pOwner, nCommentID)
80 ,m_pTabWin(NULL)
82 DBG_CTOR(OQueryTabWinUndoAct ,NULL);
84 //==============================================================================
85 OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
87 DBG_DTOR(OQueryTabWinUndoAct ,NULL);
88 if (m_bOwnerOfObjects)
89 { // wenn ich der alleinige Owner des Fenster bin, muss ich dafuer sorgen, dass es geloescht wird
90 OSL_ENSURE(m_pTabWin != NULL, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin sollte nicht NULL sein");
91 OSL_ENSURE(!m_pTabWin->IsVisible(), "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : *m_pTabWin sollte nicht sichtbar sein");
93 if ( m_pTabWin )
94 m_pTabWin->clearListBox();
95 delete m_pTabWin;
97 // und natuerlich auch die entsprechenden Connections
98 ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
99 ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
100 for(;aIter != aEnd;++aIter)
102 m_pOwner->DeselectConn(*aIter);
103 delete (*aIter);
105 m_vTableConnection.clear();
108 //------------------------------------------------------------------------------
109 void OTabFieldCellModifiedUndoAct::Undo()
111 pOwner->EnterUndoMode();
112 OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
113 OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
114 if ( m_nColumnPostion != BROWSER_INVALIDID )
116 USHORT nColumnId = pOwner->GetColumnId(m_nColumnPostion);
117 String strNext = pOwner->GetCellContents(m_nCellIndex, nColumnId);
118 pOwner->SetCellContents(m_nCellIndex, nColumnId, m_strNextCellContents);
119 m_strNextCellContents = strNext;
121 pOwner->LeaveUndoMode();
124 //------------------------------------------------------------------------------
125 void OTabFieldSizedUndoAct::Undo()
127 pOwner->EnterUndoMode();
128 OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
129 if ( m_nColumnPostion != BROWSER_INVALIDID )
131 USHORT nColumnId = pOwner->GetColumnId(m_nColumnPostion);
132 long nNextWidth = pOwner->GetColumnWidth(nColumnId);
133 pOwner->SetColWidth(nColumnId, m_nNextWidth);
134 m_nNextWidth = nNextWidth;
136 pOwner->LeaveUndoMode();
138 // -----------------------------------------------------------------------------
139 void OTabFieldMovedUndoAct::Undo()
141 pOwner->EnterUndoMode();
142 OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
143 if ( m_nColumnPostion != BROWSER_INVALIDID )
145 sal_uInt16 nId = pDescr->GetColumnId();
146 USHORT nOldPos = pOwner->GetColumnPos(nId);
147 pOwner->SetColumnPos(nId,m_nColumnPostion);
148 pOwner->ColumnMoved(nId,FALSE);
149 m_nColumnPostion = nOldPos;
151 pOwner->LeaveUndoMode();
153 // -----------------------------------------------------------------------------