LibreOffice Module dbaccess (master) 1
QueryTabWinUndoAct.cxx
Go to the documentation of this file.
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
21#include <osl/diagnose.h>
22#include "QTableWindow.hxx"
24#include <QueryTableView.hxx>
25
26using namespace dbaui;
27OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, TranslateId pCommentID)
28 : OCommentUndoAction(pCommentID)
29 , pOwner(pSelBrwBox)
30 , m_nColumnPosition(BROWSER_INVALIDID)
31{
32}
33
35{
36 pOwner = nullptr;
37}
38
40 : OQueryDesignUndoAction(pOwner, pCommentID)
41 , m_pTabWin(nullptr)
42 , m_bOwnerOfObjects(false)
43{
44}
45
47{
49 return;
50
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");
54
55 if ( m_pTabWin )
56 m_pTabWin->clearListBox();
57 m_pTabWin.disposeAndClear();
58
59 // and of course the corresponding connections
60 for (auto & connection : m_vTableConnection)
61 {
62 m_pOwner->DeselectConn(connection);
63 connection.disposeAndClear();
64 }
65 m_vTableConnection.clear();
66}
67
69{
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!");
74 {
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;
79 }
80 pOwner->LeaveUndoMode();
81}
82
84{
85 pOwner->EnterUndoMode();
86 OSL_ENSURE(m_nColumnPosition != BROWSER_INVALIDID,"Column position was not set add the undo action!");
88 {
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;
93 }
94 pOwner->LeaveUndoMode();
95}
96
98{
99 pOwner->EnterUndoMode();
100 OSL_ENSURE(m_nColumnPosition != BROWSER_INVALIDID,"Column position was not set add the undo action!");
102 {
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;
108 }
109 pOwner->LeaveUndoMode();
110}
111
112/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BROWSER_INVALIDID
VclPtr< OSelectionBrowseBox > pOwner
virtual ~OQueryDesignFieldUndoAct() override
VclPtr< OJoinTableView > m_pOwner
OQueryTabWinUndoAct(OQueryTableView *pOwner, TranslateId pCommentID)
VclPtr< OQueryTableWindow > m_pTabWin
std::vector< VclPtr< OTableConnection > > m_vTableConnection
virtual ~OQueryTabWinUndoAct() override
virtual void Undo() override
virtual void Undo() override
SvLinkSource * pOwner
long Long
sal_Int16 nId