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 #undef SC_DLLIMPLEMENTATION
21 
22 #include <svx/colorbox.hxx>
23 
24 #include <appoptio.hxx>
25 #include <scmod.hxx>
26 #include <docsh.hxx>
27 #include <svx/svxids.hrc>
28 
29 #include <opredlin.hxx>
30 
ScRedlineOptionsTabPage(weld::Container * pPage,weld::DialogController * pController,const SfxItemSet & rSet)31 ScRedlineOptionsTabPage::ScRedlineOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
32     : SfxTabPage(pPage, pController, "modules/scalc/ui/optchangespage.ui", "OptChangesPage", &rSet)
33     , m_xContentColorLB(new ColorListBox(m_xBuilder->weld_menu_button("changes"), pController->getDialog()))
34     , m_xRemoveColorLB(new ColorListBox(m_xBuilder->weld_menu_button("deletions"), pController->getDialog()))
35     , m_xInsertColorLB(new ColorListBox(m_xBuilder->weld_menu_button("entries"), pController->getDialog()))
36     , m_xMoveColorLB(new ColorListBox(m_xBuilder->weld_menu_button("insertions"), pController->getDialog()))
37 {
38     m_xContentColorLB->SetSlotId(SID_AUTHOR_COLOR);
39     m_xRemoveColorLB->SetSlotId(SID_AUTHOR_COLOR);
40     m_xInsertColorLB->SetSlotId(SID_AUTHOR_COLOR);
41     m_xMoveColorLB->SetSlotId(SID_AUTHOR_COLOR);
42 }
43 
~ScRedlineOptionsTabPage()44 ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
45 {
46     m_xContentColorLB.reset();
47     m_xRemoveColorLB.reset();
48     m_xInsertColorLB.reset();
49     m_xMoveColorLB.reset();
50 }
51 
Create(weld::Container * pPage,weld::DialogController * pController,const SfxItemSet * rSet)52 std::unique_ptr<SfxTabPage> ScRedlineOptionsTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
53 {
54     return std::make_unique<ScRedlineOptionsTabPage>( pPage, pController, *rSet );
55 }
56 
FillItemSet(SfxItemSet *)57 bool ScRedlineOptionsTabPage::FillItemSet( SfxItemSet* /* rSet */ )
58 {
59     ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
60 
61     Color nNew = m_xContentColorLB->GetSelectEntryColor();
62     aAppOptions.SetTrackContentColor(nNew);
63 
64     nNew = m_xMoveColorLB->GetSelectEntryColor();
65     aAppOptions.SetTrackMoveColor(nNew);
66 
67     nNew = m_xInsertColorLB->GetSelectEntryColor();
68     aAppOptions.SetTrackInsertColor(nNew);
69 
70     nNew = m_xRemoveColorLB->GetSelectEntryColor();
71     aAppOptions.SetTrackDeleteColor(nNew);
72 
73     SC_MOD()->SetAppOptions(aAppOptions);
74 
75     //  repaint (if everything would be done by Items (how it should be),
76     //  this wouldn't be necessary)
77     ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
78     if (pDocSh)
79         pDocSh->PostPaintGridAll();
80 
81     return false;
82 }
83 
Reset(const SfxItemSet *)84 void ScRedlineOptionsTabPage::Reset( const SfxItemSet* /* rSet */ )
85 {
86     ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
87 
88     Color nColor = aAppOptions.GetTrackContentColor();
89     m_xContentColorLB->SelectEntry(nColor);
90 
91     nColor = aAppOptions.GetTrackMoveColor();
92     m_xMoveColorLB->SelectEntry(nColor);
93 
94     nColor = aAppOptions.GetTrackInsertColor();
95     m_xInsertColorLB->SelectEntry(nColor);
96 
97     nColor = aAppOptions.GetTrackDeleteColor();
98     m_xRemoveColorLB->SelectEntry(nColor);
99 }
100 
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
102