LibreOffice Module dbaccess (master) 1
QueryDesignFieldUndoAct.hxx
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#pragma once
20
21#include <GeneralUndo.hxx>
22#include <strings.hrc>
24#include <osl/diagnose.h>
25
26namespace dbaui
27{
28 // OQueryDesignFieldUndoAct - Basisclass for undo's in the fieldlist of a query design
29
31 {
32 protected:
35
36 virtual void Undo() override = 0;
37 virtual void Redo() override = 0;
38
39 public:
41 virtual ~OQueryDesignFieldUndoAct() override;
42
43 void SetColumnPosition(sal_uInt16 _nColumnPosition)
44 {
45 m_nColumnPosition = _nColumnPosition;
46 OSL_ENSURE(m_nColumnPosition != BROWSER_INVALIDID,"Column position was not set add the undo action!");
47 OSL_ENSURE(m_nColumnPosition < pOwner->GetColumnCount(),"Position outside the column count!");
48 }
49 };
50
51 // OTabFieldCellModifiedUndoAct - undo class to change a line of the column description
52
54 {
56 sal_Int32 m_nCellIndex;
57
58 public:
60 : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_MODIFY_CELL)
62
63 void SetCellContents(const OUString& str) { m_strNextCellContents = str; }
64 void SetCellIndex(sal_Int32 nIndex) { m_nCellIndex = nIndex; }
65
66 virtual void Undo() override;
67 virtual void Redo() override { Undo(); }
68 };
69
70 // OTabFieldSizedUndoAct - undo class to change the column width
71
73 {
75
76 public:
77 explicit OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { }
78
79 void SetOriginalWidth(tools::Long nWidth) { m_nNextWidth = nWidth; }
80
81 virtual void Undo() override;
82 virtual void Redo() override { Undo(); }
83 };
84
85 // OTabFieldUndoAct - base class for undos in the fieldlist of a query design, which are used to change complete field descriptions
86
88 {
89 protected:
90 OTableFieldDescRef pDescr; // the deleted column description
91
92 public:
93 OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, TranslateId pCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, pCommentID) { }
94
95 void SetTabFieldDescr(OTableFieldDescRef const & pDescription) { pDescr = pDescription; }
96 };
97
98 // OTabFieldDelUndoAct - undo class to delete a field
99
101 {
102 protected:
103 virtual void Undo() override { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPosition);pOwner->LeaveUndoMode(); }
104 virtual void Redo() override { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode(); }
105
106 public:
107 explicit OTabFieldDelUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDDELETE) { }
108 };
109
110 // OTabFieldCreateUndoAct - undo class for creating a field
111
113 {
114 protected:
115 virtual void Undo() override { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode();}
116 virtual void Redo() override { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPosition);pOwner->LeaveUndoMode();}
117
118 public:
119 explicit OTabFieldCreateUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDCREATE) { }
120 };
121
122 // OTabFieldMovedUndoAct - Undo class when a field was moved inside the selection
123
125 {
126 protected:
127 virtual void Undo() override;
128 virtual void Redo() override
129 {
130 Undo();
131 }
132
133 public:
134 explicit OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { }
135 };
136}
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define BROWSER_INVALIDID
VclPtr< OSelectionBrowseBox > pOwner
virtual ~OQueryDesignFieldUndoAct() override
void SetColumnPosition(sal_uInt16 _nColumnPosition)
virtual void Redo() override=0
OQueryDesignFieldUndoAct(OSelectionBrowseBox *pSelBrwBox, TranslateId pCommentID)
virtual void Undo() override=0
OTabFieldCellModifiedUndoAct(OSelectionBrowseBox *pSelBrwBox)
OTabFieldCreateUndoAct(OSelectionBrowseBox *pSelBrwBox)
OTabFieldDelUndoAct(OSelectionBrowseBox *pSelBrwBox)
virtual void Undo() override
OTabFieldMovedUndoAct(OSelectionBrowseBox *pSelBrwBox)
OTabFieldSizedUndoAct(OSelectionBrowseBox *pSelBrwBox)
virtual void Undo() override
void SetOriginalWidth(tools::Long nWidth)
OTabFieldUndoAct(OSelectionBrowseBox *pSelBrwBox, TranslateId pCommentID)
void SetTabFieldDescr(OTableFieldDescRef const &pDescription)
sal_Int32 nIndex
long Long