Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "QueryTabWinUndoAct.hxx"
21 : #include <osl/diagnose.h>
22 : #include "QTableWindow.hxx"
23 : #include "QTableWindowData.hxx"
24 : #include "TableConnection.hxx"
25 : #include "TableConnectionData.hxx"
26 : #include "QueryDesignFieldUndoAct.hxx"
27 : #include "QueryTableView.hxx"
28 :
29 :
30 : using namespace dbaui;
31 : DBG_NAME(OQueryDesignFieldUndoAct)
32 0 : OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID)
33 : : OCommentUndoAction(nCommentID)
34 : , pOwner(pSelBrwBox)
35 0 : , m_nColumnPostion(BROWSER_INVALIDID)
36 : {
37 : DBG_CTOR(OQueryDesignFieldUndoAct,NULL);
38 0 : }
39 : // -----------------------------------------------------------------------------
40 0 : OQueryDesignFieldUndoAct::~OQueryDesignFieldUndoAct()
41 : {
42 : DBG_DTOR(OQueryDesignFieldUndoAct,NULL);
43 0 : pOwner = NULL;
44 0 : }
45 : // -----------------------------------------------------------------------------
46 :
47 : DBG_NAME(OQueryTabWinUndoAct )
48 : // ------------------------------------------------------------------------------------------------
49 0 : OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, sal_uInt16 nCommentID)
50 : :OQueryDesignUndoAction(pOwner, nCommentID)
51 0 : ,m_pTabWin(NULL)
52 : {
53 : DBG_CTOR(OQueryTabWinUndoAct ,NULL);
54 0 : }
55 : //==============================================================================
56 0 : OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
57 : {
58 : DBG_DTOR(OQueryTabWinUndoAct ,NULL);
59 0 : if (m_bOwnerOfObjects)
60 : {
61 : // I should take care to delete the window if I am the only owner
62 : OSL_ENSURE(m_pTabWin != NULL, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin sollte nicht NULL sein");
63 : OSL_ENSURE(!m_pTabWin->IsVisible(), "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : *m_pTabWin sollte nicht sichtbar sein");
64 :
65 0 : if ( m_pTabWin )
66 0 : m_pTabWin->clearListBox();
67 0 : delete m_pTabWin;
68 :
69 : // and of course the corresponding connections
70 0 : ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
71 0 : ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
72 0 : for(;aIter != aEnd;++aIter)
73 : {
74 0 : m_pOwner->DeselectConn(*aIter);
75 0 : delete (*aIter);
76 : }
77 0 : m_vTableConnection.clear();
78 : }
79 0 : }
80 : //------------------------------------------------------------------------------
81 0 : void OTabFieldCellModifiedUndoAct::Undo()
82 : {
83 0 : pOwner->EnterUndoMode();
84 : OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
85 : OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
86 0 : if ( m_nColumnPostion != BROWSER_INVALIDID )
87 : {
88 0 : sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
89 0 : String strNext = pOwner->GetCellContents(m_nCellIndex, nColumnId);
90 0 : pOwner->SetCellContents(m_nCellIndex, nColumnId, m_strNextCellContents);
91 0 : m_strNextCellContents = strNext;
92 : }
93 0 : pOwner->LeaveUndoMode();
94 0 : }
95 :
96 : //------------------------------------------------------------------------------
97 0 : void OTabFieldSizedUndoAct::Undo()
98 : {
99 0 : pOwner->EnterUndoMode();
100 : OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
101 0 : if ( m_nColumnPostion != BROWSER_INVALIDID )
102 : {
103 0 : sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
104 0 : long nNextWidth = pOwner->GetColumnWidth(nColumnId);
105 0 : pOwner->SetColWidth(nColumnId, m_nNextWidth);
106 0 : m_nNextWidth = nNextWidth;
107 : }
108 0 : pOwner->LeaveUndoMode();
109 0 : }
110 : // -----------------------------------------------------------------------------
111 0 : void OTabFieldMovedUndoAct::Undo()
112 : {
113 0 : pOwner->EnterUndoMode();
114 : OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
115 0 : if ( m_nColumnPostion != BROWSER_INVALIDID )
116 : {
117 0 : sal_uInt16 nId = pDescr->GetColumnId();
118 0 : sal_uInt16 nOldPos = pOwner->GetColumnPos(nId);
119 0 : pOwner->SetColumnPos(nId,m_nColumnPostion);
120 0 : pOwner->ColumnMoved(nId,sal_False);
121 0 : m_nColumnPostion = nOldPos;
122 : }
123 0 : pOwner->LeaveUndoMode();
124 12 : }
125 : // -----------------------------------------------------------------------------
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|