tdf#164803 sw: Fix SwTextSizeInfo applying grid metrics without grid
[LibreOffice.git] / sc / qa / unit / helper / sorthelper.hxx
blobdc337953fb9741d0cd1538a4a4c1df0e5ec96361
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/.
8 */
10 #pragma once
12 // Unfortunately requires linkage to sc/ internals so
13 // can't live in qahelper itself.
14 #include <inputopt.hxx>
15 #include <scmod.hxx>
17 /**
18 * Temporarily set the sorting type.
20 class SortTypeSetter {
21 bool mbSortRefUpdate;
22 public:
23 explicit SortTypeSetter(bool bSortRefUpdate)
25 mbSortRefUpdate = changeTo(bSortRefUpdate);
27 static bool changeTo(bool bSortRefUpdate)
29 ScModule* mod = ScModule::get();
30 ScInputOptions aInputOptions = mod->GetInputOptions();
31 bool bRet = aInputOptions.GetSortRefUpdate();
32 aInputOptions.SetSortRefUpdate(bSortRefUpdate);
33 mod->SetInputOptions(aInputOptions);
34 return bRet;
36 virtual ~SortTypeSetter() COVERITY_NOEXCEPT_FALSE
38 changeTo(mbSortRefUpdate);
42 class SortRefNoUpdateSetter : private SortTypeSetter
44 public:
45 SortRefNoUpdateSetter() : SortTypeSetter(false) {}
48 class SortRefUpdateSetter : private SortTypeSetter
50 public:
51 SortRefUpdateSetter() : SortTypeSetter(true) {}
54 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */