1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <GeneralUndo.hxx>
22 #include <strings.hrc>
23 #include "SelectionBrowseBox.hxx"
24 #include <osl/diagnose.h>
28 // OQueryDesignFieldUndoAct - Basisclass for undo's in the fieldlist of a query design
30 class OQueryDesignFieldUndoAct
: public OCommentUndoAction
33 VclPtr
<OSelectionBrowseBox
> pOwner
;
34 sal_uInt16 m_nColumnPosition
;
36 virtual void Undo() override
= 0;
37 virtual void Redo() override
= 0;
40 OQueryDesignFieldUndoAct(OSelectionBrowseBox
* pSelBrwBox
, TranslateId pCommentID
);
41 virtual ~OQueryDesignFieldUndoAct() override
;
43 void SetColumnPosition(sal_uInt16 _nColumnPosition
)
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!");
51 // OTabFieldCellModifiedUndoAct - undo class to change a line of the column description
53 class OTabFieldCellModifiedUndoAct final
: public OQueryDesignFieldUndoAct
55 OUString m_strNextCellContents
;
56 sal_Int32 m_nCellIndex
;
59 explicit OTabFieldCellModifiedUndoAct(OSelectionBrowseBox
* pSelBrwBox
)
60 : OQueryDesignFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_MODIFY_CELL
)
61 ,m_nCellIndex(BROWSER_INVALIDID
){ }
63 void SetCellContents(const OUString
& str
) { m_strNextCellContents
= str
; }
64 void SetCellIndex(sal_Int32 nIndex
) { m_nCellIndex
= nIndex
; }
66 virtual void Undo() override
;
67 virtual void Redo() override
{ Undo(); }
70 // OTabFieldSizedUndoAct - undo class to change the column width
72 class OTabFieldSizedUndoAct final
: public OQueryDesignFieldUndoAct
74 tools::Long m_nNextWidth
;
77 explicit OTabFieldSizedUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OQueryDesignFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_SIZE_COLUMN
), m_nNextWidth(0) { }
79 void SetOriginalWidth(tools::Long nWidth
) { m_nNextWidth
= nWidth
; }
81 virtual void Undo() override
;
82 virtual void Redo() override
{ Undo(); }
85 // OTabFieldUndoAct - base class for undos in the fieldlist of a query design, which are used to change complete field descriptions
87 class OTabFieldUndoAct
: public OQueryDesignFieldUndoAct
90 OTableFieldDescRef pDescr
; // the deleted column description
93 OTabFieldUndoAct(OSelectionBrowseBox
* pSelBrwBox
, TranslateId pCommentID
) : OQueryDesignFieldUndoAct(pSelBrwBox
, pCommentID
) { }
95 void SetTabFieldDescr(OTableFieldDescRef
const & pDescription
) { pDescr
= pDescription
; }
98 // OTabFieldDelUndoAct - undo class to delete a field
100 class OTabFieldDelUndoAct
: public OTabFieldUndoAct
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(); }
107 explicit OTabFieldDelUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDDELETE
) { }
110 // OTabFieldCreateUndoAct - undo class for creating a field
112 class OTabFieldCreateUndoAct
: public OTabFieldUndoAct
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();}
119 explicit OTabFieldCreateUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDCREATE
) { }
122 // OTabFieldMovedUndoAct - Undo class when a field was moved inside the selection
124 class OTabFieldMovedUndoAct
: public OTabFieldUndoAct
127 virtual void Undo() override
;
128 virtual void Redo() override
134 explicit OTabFieldMovedUndoAct(OSelectionBrowseBox
* pSelBrwBox
) : OTabFieldUndoAct(pSelBrwBox
, STR_QUERY_UNDO_TABFIELDMOVED
) { }
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */