Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / dbaccess / source / ui / querydesign / QueryDesignFieldUndoAct.hxx
blobcbd54cc5d2e60d385c2b3e1a4f03e9a8f56da0a1
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
22 #include "GeneralUndo.hxx"
23 #include "dbu_qry.hrc"
24 #include "SelectionBrowseBox.hxx"
26 namespace dbaui
28 // OQueryDesignFieldUndoAct - Basisclass for undo's in the fieldlist of a query design
30 class OQueryDesignFieldUndoAct : public OCommentUndoAction
32 protected:
33 VclPtr<OSelectionBrowseBox> pOwner;
34 sal_uInt16 m_nColumnPostion;
36 virtual void Undo() override = 0;
37 virtual void Redo() override = 0;
39 public:
40 OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID);
41 virtual ~OQueryDesignFieldUndoAct();
43 inline void SetColumnPosition(sal_uInt16 _nColumnPostion)
45 m_nColumnPostion = _nColumnPostion;
46 OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
47 OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
51 // OTabFieldCellModifiedUndoAct - undo class to change a line of the column description
53 class OTabFieldCellModifiedUndoAct : public OQueryDesignFieldUndoAct
55 protected:
56 OUString m_strNextCellContents;
57 sal_Int32 m_nCellIndex;
59 public:
60 explicit OTabFieldCellModifiedUndoAct(OSelectionBrowseBox* pSelBrwBox)
61 : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_MODIFY_CELL)
62 ,m_nCellIndex(BROWSER_INVALIDID){ }
64 void SetCellContents(const OUString& str) { m_strNextCellContents = str; }
65 void SetCellIndex(sal_Int32 nIndex) { m_nCellIndex = nIndex; }
67 virtual void Undo() override;
68 virtual void Redo() override { Undo(); }
71 // OTabFieldSizedUndoAct - undo class to change the column width
73 class OTabFieldSizedUndoAct : public OQueryDesignFieldUndoAct
75 protected:
76 long m_nNextWidth;
78 public:
79 explicit OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { }
81 inline void SetOriginalWidth(long nWidth) { m_nNextWidth = nWidth; }
83 virtual void Undo() override;
84 virtual void Redo() override { Undo(); }
87 // OTabFieldUndoAct - base class for undos in the fieldlist of a query design, which are used to change complete field descriptions
89 class OTabFieldUndoAct : public OQueryDesignFieldUndoAct
91 protected:
92 OTableFieldDescRef pDescr; // geloeschte Spaltenbeschreibung
94 public:
95 OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, nCommentID) { }
97 void SetTabFieldDescr(OTableFieldDescRef pDescription) { pDescr = pDescription; }
100 // OTabFieldDelUndoAct - undo class to delete a field
102 class OTabFieldDelUndoAct : public OTabFieldUndoAct
104 protected:
105 virtual void Undo() override { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode(); }
106 virtual void Redo() override { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode(); }
108 public:
109 explicit OTabFieldDelUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDDELETE) { }
112 // OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes
113 // OTabFieldDelUndoAct - undo class to create a field
115 class OTabFieldCreateUndoAct : public OTabFieldUndoAct
117 protected:
118 virtual void Undo() override { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode();}
119 virtual void Redo() override { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode();}
121 public:
122 explicit OTabFieldCreateUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDCREATE) { }
125 // OTabFieldMovedUndoAct - Undo class when a field was moved inside the selection
127 class OTabFieldMovedUndoAct : public OTabFieldUndoAct
129 protected:
130 virtual void Undo() override;
131 virtual void Redo() override
133 Undo();
136 public:
137 explicit OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { }
140 #endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */