Bump version to 5.0-14
[LibreOffice.git] / starmath / source / config.cxx
blob8b47ce51444a15b5a02ba5d644f51074f7cf7e35
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 .
20 #include <svl/itemset.hxx>
21 #include <svl/hint.hxx>
22 #include <svl/smplhint.hxx>
23 #include <unotools/pathoptions.hxx>
24 #include <sfx2/sfxsids.hrc>
25 #include <svl/eitem.hxx>
26 #include <svl/itempool.hxx>
27 #include <svl/stritem.hxx>
28 #include <svl/intitem.hxx>
29 #include <tools/stream.hxx>
32 #include "config.hxx"
33 #include "format.hxx"
34 #include "smmod.hxx"
35 #include "starmath.hrc"
39 SmConfig::SmConfig()
44 SmConfig::~SmConfig()
49 void SmConfig::ItemSetToConfig(const SfxItemSet &rSet)
51 const SfxPoolItem *pItem = NULL;
53 sal_uInt16 nU16;
54 bool bVal;
55 if (rSet.GetItemState(SID_PRINTSIZE, true, &pItem) == SfxItemState::SET)
56 { nU16 = static_cast<const SfxUInt16Item *>(pItem)->GetValue();
57 SetPrintSize( (SmPrintSize) nU16 );
59 if (rSet.GetItemState(SID_PRINTZOOM, true, &pItem) == SfxItemState::SET)
60 { nU16 = static_cast<const SfxUInt16Item *>(pItem)->GetValue();
61 SetPrintZoomFactor( nU16 );
63 if (rSet.GetItemState(SID_PRINTTITLE, true, &pItem) == SfxItemState::SET)
64 { bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
65 SetPrintTitle( bVal );
67 if (rSet.GetItemState(SID_PRINTTEXT, true, &pItem) == SfxItemState::SET)
68 { bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
69 SetPrintFormulaText( bVal );
71 if (rSet.GetItemState(SID_PRINTFRAME, true, &pItem) == SfxItemState::SET)
72 { bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
73 SetPrintFrame( bVal );
75 if (rSet.GetItemState(SID_AUTOREDRAW, true, &pItem) == SfxItemState::SET)
76 { bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
77 SetAutoRedraw( bVal );
79 if (rSet.GetItemState(SID_NO_RIGHT_SPACES, true, &pItem) == SfxItemState::SET)
80 { bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
81 if (IsIgnoreSpacesRight() != bVal)
83 SetIgnoreSpacesRight( bVal );
85 // reformat (displayed) formulas accordingly
86 Broadcast(SfxSimpleHint(HINT_FORMATCHANGED));
89 if (rSet.GetItemState(SID_SAVE_ONLY_USED_SYMBOLS, true, &pItem) == SfxItemState::SET)
90 { bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
91 SetSaveOnlyUsedSymbols( bVal );
94 SaveOther();
98 void SmConfig::ConfigToItemSet(SfxItemSet &rSet) const
100 const SfxItemPool *pPool = rSet.GetPool();
102 rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTSIZE),
103 (sal_uInt16) GetPrintSize()));
104 rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTZOOM),
105 (sal_uInt16) GetPrintZoomFactor()));
107 rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), IsPrintTitle()));
108 rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT), IsPrintFormulaText()));
109 rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), IsPrintFrame()));
110 rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw()));
111 rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight()));
112 rSet.Put(SfxBoolItem(pPool->GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols()));
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */