Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / dbaccess / source / ui / querydesign / QueryTabWinUndoAct.cxx
blob2afe74db423272fc66dab58500d3d31ce787d7b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "QueryTabWinUndoAct.hxx"
21 #include <osl/diagnose.h>
22 #include "QTableWindow.hxx"
23 #include "QueryDesignFieldUndoAct.hxx"
24 #include <QueryTableView.hxx>
26 using namespace dbaui;
27 OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, TranslateId pCommentID)
28 : OCommentUndoAction(pCommentID)
29 , pOwner(pSelBrwBox)
30 , m_nColumnPosition(BROWSER_INVALIDID)
34 OQueryDesignFieldUndoAct::~OQueryDesignFieldUndoAct()
36 pOwner = nullptr;
39 OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, TranslateId pCommentID)
40 : OQueryDesignUndoAction(pOwner, pCommentID)
41 , m_pTabWin(nullptr)
42 , m_bOwnerOfObjects(false)
46 OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
48 if (!m_bOwnerOfObjects)
49 return;
51 // I should take care to delete the window if I am the only owner
52 OSL_ENSURE(m_pTabWin != nullptr, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin must not be NULL");
53 OSL_ENSURE(!m_pTabWin->IsVisible(), "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : *m_pTabWin must not be visible");
55 if ( m_pTabWin )
56 m_pTabWin->clearListBox();
57 m_pTabWin.disposeAndClear();
59 // and of course the corresponding connections
60 for (auto & connection : m_vTableConnection)
62 m_pOwner->DeselectConn(connection);
63 connection.disposeAndClear();
65 m_vTableConnection.clear();
68 void OTabFieldCellModifiedUndoAct::Undo()
70 pOwner->EnterUndoMode();
71 OSL_ENSURE(m_nColumnPosition != BROWSER_INVALIDID,"Column position was not set add the undo action!");
72 OSL_ENSURE(m_nColumnPosition < pOwner->GetColumnCount(),"Position outside the column count!");
73 if ( m_nColumnPosition != BROWSER_INVALIDID )
75 sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPosition);
76 OUString strNext = pOwner->GetCellContents(m_nCellIndex, nColumnId);
77 pOwner->SetCellContents(m_nCellIndex, nColumnId, m_strNextCellContents);
78 m_strNextCellContents = strNext;
80 pOwner->LeaveUndoMode();
83 void OTabFieldSizedUndoAct::Undo()
85 pOwner->EnterUndoMode();
86 OSL_ENSURE(m_nColumnPosition != BROWSER_INVALIDID,"Column position was not set add the undo action!");
87 if ( m_nColumnPosition != BROWSER_INVALIDID )
89 sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPosition);
90 tools::Long nNextWidth = pOwner->GetColumnWidth(nColumnId);
91 pOwner->SetColWidth(nColumnId, m_nNextWidth);
92 m_nNextWidth = nNextWidth;
94 pOwner->LeaveUndoMode();
97 void OTabFieldMovedUndoAct::Undo()
99 pOwner->EnterUndoMode();
100 OSL_ENSURE(m_nColumnPosition != BROWSER_INVALIDID,"Column position was not set add the undo action!");
101 if ( m_nColumnPosition != BROWSER_INVALIDID )
103 sal_uInt16 nId = pDescr->GetColumnId();
104 sal_uInt16 nOldPos = pOwner->GetColumnPos(nId);
105 pOwner->SetColumnPos(nId,m_nColumnPosition);
106 pOwner->ColumnMoved(nId,false);
107 m_nColumnPosition = nOldPos;
109 pOwner->LeaveUndoMode();
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */