LibreOffice Module sw (master)  1
UndoSort.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 
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX
22 
23 #include <undobj.hxx>
24 
25 #include <rtl/ustring.hxx>
26 #include <tools/solar.h>
27 
28 #include <memory>
29 #include <vector>
30 
31 struct SwSortOptions;
32 class SwTableNode;
33 class SwUndoAttrTable;
34 
36 {
37  union {
38  struct {
40  // we cannot store these as SwNodeOffset (even though they are)
41  // because SwNodeOffset has no default constructor
42  sal_Int32 nSource, nTarget;
43  } TXT;
44  struct {
45  OUString *pSource, *pTarget;
46  } TBL;
47  } SORT_TXT_TBL;
48 
49  SwSortUndoElement( const OUString& aS, const OUString& aT )
50  {
51  SORT_TXT_TBL.TBL.pSource = new OUString( aS );
52  SORT_TXT_TBL.TBL.pTarget = new OUString( aT );
53  }
55  {
56  SORT_TXT_TBL.TXT.nSource = sal_Int32(nS);
57  SORT_TXT_TBL.TXT.nTarget = sal_Int32(nT);
58  SORT_TXT_TBL.TXT.nID = 0xffffffff;
59  }
61 };
62 
63 class SwUndoSort final : public SwUndo, private SwUndRng
64 {
65  std::unique_ptr<SwSortOptions> m_pSortOptions;
66  std::vector<std::unique_ptr<SwSortUndoElement>> m_SortList;
67  std::unique_ptr<SwUndoAttrTable> m_pUndoAttrTable;
69 
70 public:
71  SwUndoSort( const SwPaM&, const SwSortOptions& );
72  SwUndoSort( SwNodeOffset nStt, SwNodeOffset nEnd, const SwTableNode&,
73  const SwSortOptions&, bool bSaveTable );
74 
75  virtual ~SwUndoSort() override;
76 
77  virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
78  virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
79  virtual void RepeatImpl( ::sw::RepeatContext & ) override;
80 
81  void Insert( const OUString& rOrgPos, const OUString& rNewPos );
82  void Insert( SwNodeOffset nOrgPos, SwNodeOffset nNewPos );
83 };
84 
85 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOSORT_HXX
86 
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwUndoSort(const SwPaM &, const SwSortOptions &)
Definition: unsort.cxx:44
struct SwSortUndoElement::@9::@10 TXT
sal_uLong nID
Definition: UndoSort.hxx:39
union SwSortUndoElement::@9 SORT_TXT_TBL
sal_uIntPtr sal_uLong
virtual ~SwUndoSort() override
Definition: unsort.cxx:65
virtual void RepeatImpl(::sw::RepeatContext &) override
Definition: unsort.cxx:230
sal_Int32 nSource
Definition: UndoSort.hxx:42
SwSortUndoElement(SwNodeOffset nS, SwNodeOffset nT)
Definition: UndoSort.hxx:54
virtual void UndoImpl(::sw::UndoRedoContext &) override
Definition: unsort.cxx:71
virtual void RedoImpl(::sw::UndoRedoContext &) override
Definition: unsort.cxx:152
void Insert(const OUString &rOrgPos, const OUString &rNewPos)
Definition: unsort.cxx:243
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
SwSortUndoElement(const OUString &aS, const OUString &aT)
Definition: UndoSort.hxx:49
std::vector< std::unique_ptr< SwSortUndoElement > > m_SortList
Definition: UndoSort.hxx:66
OUString * pTarget
Definition: UndoSort.hxx:45
struct SwSortUndoElement::@9::@11 TBL
SwNodeOffset m_nTableNode
Definition: UndoSort.hxx:68
OUString * pSource
Definition: UndoSort.hxx:45
sal_Int32 nTarget
Definition: UndoSort.hxx:42
std::unique_ptr< SwSortOptions > m_pSortOptions
Definition: UndoSort.hxx:65
std::unique_ptr< SwUndoAttrTable > m_pUndoAttrTable
Definition: UndoSort.hxx:67