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 .
20 #undef SC_DLLIMPLEMENTATION
22 #include <svx/dlgutil.hxx>
23 #include <svx/drawitem.hxx>
24 #include <svx/xtable.hxx>
26 #include "appoptio.hxx"
28 #include "scitems.hxx"
31 #include "viewopti.hxx"
32 #include "tabvwsh.hxx"
33 #include "uiitems.hxx"
34 #include "scresid.hxx"
37 #include "globstr.hrc"
39 #include "opredlin.hxx"
41 ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( vcl::Window
* pParent
,
42 const SfxItemSet
& rSet
)
43 : SfxTabPage(pParent
,"OptChangesPage", "modules/scalc/ui/optchangespage.ui", &rSet
),
44 aAuthorStr (ScResId(SCSTR_AUTHOR
))
46 get(m_pContentColorLB
, "changes");
47 get(m_pRemoveColorLB
, "deletions");
48 get(m_pInsertColorLB
, "entries");
49 get(m_pMoveColorLB
, "insertions");
51 Link
<> aLk
= LINK(this, ScRedlineOptionsTabPage
, ColorHdl
);
52 m_pContentColorLB
->SetSelectHdl( aLk
);
53 m_pMoveColorLB
->SetSelectHdl( aLk
);
54 m_pInsertColorLB
->SetSelectHdl( aLk
);
55 m_pRemoveColorLB
->SetSelectHdl( aLk
);
58 ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
63 void ScRedlineOptionsTabPage::dispose()
65 m_pContentColorLB
.clear();
66 m_pRemoveColorLB
.clear();
67 m_pInsertColorLB
.clear();
68 m_pMoveColorLB
.clear();
69 SfxTabPage::dispose();
72 VclPtr
<SfxTabPage
> ScRedlineOptionsTabPage::Create( vcl::Window
* pParent
, const SfxItemSet
* rSet
)
74 return VclPtr
<ScRedlineOptionsTabPage
>::Create( pParent
, *rSet
);
77 bool ScRedlineOptionsTabPage::FillItemSet( SfxItemSet
* /* rSet */ )
79 ScAppOptions aAppOptions
=SC_MOD()->GetAppOptions();
84 nPos
= m_pContentColorLB
->GetSelectEntryPos();
85 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
88 nNew
= m_pContentColorLB
->GetEntryColor(nPos
).GetColor();
90 nNew
= COL_TRANSPARENT
;
92 aAppOptions
.SetTrackContentColor(nNew
);
95 nPos
= m_pMoveColorLB
->GetSelectEntryPos();
96 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
99 nNew
= m_pMoveColorLB
->GetEntryColor(nPos
).GetColor();
101 nNew
= COL_TRANSPARENT
;
103 aAppOptions
.SetTrackMoveColor(nNew
);
106 nPos
= m_pInsertColorLB
->GetSelectEntryPos();
107 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
110 nNew
= m_pInsertColorLB
->GetEntryColor(nPos
).GetColor();
112 nNew
= COL_TRANSPARENT
;
114 aAppOptions
.SetTrackInsertColor(nNew
);
117 nPos
= m_pRemoveColorLB
->GetSelectEntryPos();
118 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
121 nNew
= m_pRemoveColorLB
->GetEntryColor(nPos
).GetColor();
123 nNew
= COL_TRANSPARENT
;
125 aAppOptions
.SetTrackDeleteColor(nNew
);
129 SC_MOD()->SetAppOptions(aAppOptions
);
131 // Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert,
132 // waere das nicht noetig...)
133 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
135 pDocSh
->PostPaintGridAll();
140 void ScRedlineOptionsTabPage::Reset( const SfxItemSet
* /* rSet */ )
142 m_pContentColorLB
->InsertEntry(aAuthorStr
);
143 m_pMoveColorLB
->InsertEntry(aAuthorStr
);
144 m_pInsertColorLB
->InsertEntry(aAuthorStr
);
145 m_pRemoveColorLB
->InsertEntry(aAuthorStr
);
147 m_pContentColorLB
->SetUpdateMode( false);
148 m_pMoveColorLB
->SetUpdateMode( false);
149 m_pInsertColorLB
->SetUpdateMode( false);
150 m_pRemoveColorLB
->SetUpdateMode( false);
152 XColorListRef xColorLst
= XColorList::GetStdColorList();
153 for( sal_uInt16 i
= 0; i
< xColorLst
->Count(); ++i
)
155 XColorEntry
* pEntry
= xColorLst
->GetColor( i
);
156 Color aColor
= pEntry
->GetColor();
157 OUString sName
= pEntry
->GetName();
159 m_pContentColorLB
->InsertEntry( aColor
, sName
);
160 m_pMoveColorLB
->InsertEntry( aColor
, sName
);
161 m_pInsertColorLB
->InsertEntry( aColor
, sName
);
162 m_pRemoveColorLB
->InsertEntry( aColor
, sName
);
164 m_pContentColorLB
->SetUpdateMode( true );
165 m_pMoveColorLB
->SetUpdateMode( true );
166 m_pInsertColorLB
->SetUpdateMode( true );
167 m_pRemoveColorLB
->SetUpdateMode( true );
169 ScAppOptions aAppOptions
=SC_MOD()->GetAppOptions();
171 sal_uLong nColor
= aAppOptions
.GetTrackContentColor();
172 if (nColor
== COL_TRANSPARENT
)
173 m_pContentColorLB
->SelectEntryPos(0);
175 m_pContentColorLB
->SelectEntry(Color(nColor
));
177 nColor
= aAppOptions
.GetTrackMoveColor();
178 if (nColor
== COL_TRANSPARENT
)
179 m_pMoveColorLB
->SelectEntryPos(0);
181 m_pMoveColorLB
->SelectEntry(Color(nColor
));
183 nColor
= aAppOptions
.GetTrackInsertColor();
184 if (nColor
== COL_TRANSPARENT
)
185 m_pInsertColorLB
->SelectEntryPos(0);
187 m_pInsertColorLB
->SelectEntry(Color(nColor
));
189 nColor
= aAppOptions
.GetTrackDeleteColor();
190 if (nColor
== COL_TRANSPARENT
)
191 m_pRemoveColorLB
->SelectEntryPos(0);
193 m_pRemoveColorLB
->SelectEntry(Color(nColor
));
197 IMPL_STATIC_LINK_NOARG(ScRedlineOptionsTabPage
, ColorHdl
)
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */