LibreOffice Module sc (master) 1
highred.cxx
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#include <reffact.hxx>
21#include <document.hxx>
22#include <docsh.hxx>
23#include <chgtrack.hxx>
24
25#include <highred.hxx>
26
27
29 ScViewData& rViewData)
30 : ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/showchangesdialog.ui", "ShowChangesDialog")
31 , m_rViewData(rViewData)
32 , rDoc(rViewData.GetDocument())
33 , m_xHighlightBox(m_xBuilder->weld_check_button("showchanges"))
34 , m_xCbAccept(m_xBuilder->weld_check_button("showaccepted"))
35 , m_xCbReject(m_xBuilder->weld_check_button("showrejected"))
36 , m_xOkButton(m_xBuilder->weld_button("ok"))
37 , m_xEdAssign(new formula::RefEdit(m_xBuilder->weld_entry("range")))
38 , m_xRbAssign(new formula::RefButton(m_xBuilder->weld_button("rangeref")))
39 , m_xBox(m_xBuilder->weld_container("box"))
40 , m_xFilterCtr(new SvxTPFilter(m_xBox.get()))
41{
42 m_xEdAssign->SetReferences(this, nullptr);
43 m_xRbAssign->SetReferences(this, m_xEdAssign.get());
44
45 m_xOkButton->connect_clicked(LINK( this, ScHighlightChgDlg, OKBtnHdl));
46 m_xHighlightBox->connect_toggled(LINK( this, ScHighlightChgDlg, HighlightHandle ));
47 m_xFilterCtr->SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle ));
48 m_xFilterCtr->HideRange(false);
49 m_xFilterCtr->Show();
50 SetDispatcherLock( true );
51
52 Init();
53}
54
56{
57 SetDispatcherLock( false );
58}
59
61{
62 ScChangeTrack* pChanges = rDoc.GetChangeTrack();
63 if(pChanges!=nullptr)
64 {
66 m_xFilterCtr->ClearAuthors();
67 const std::set<OUString>& rUserColl = pChanges->GetUserCollection();
68 for (const auto& rItem : rUserColl)
69 m_xFilterCtr->InsertAuthor(rItem);
70 }
71
73
74 if(pViewSettings!=nullptr)
75 aChangeViewSet=*pViewSettings;
78
80
82 if (aDateTime != aEmpty)
83 {
84 m_xFilterCtr->SetFirstDate(aDateTime);
85 m_xFilterCtr->SetFirstTime(aDateTime);
86 }
88 if (aDateTime != aEmpty)
89 {
90 m_xFilterCtr->SetLastDate(aDateTime);
91 m_xFilterCtr->SetLastTime(aDateTime);
92 }
93
94 m_xFilterCtr->SetDateMode(static_cast<sal_uInt16>(aChangeViewSet.GetTheDateMode()));
96 m_xFilterCtr->CheckComment(aChangeViewSet.HasComment());
98
101
102 OUString aString=aChangeViewSet.GetTheAuthorToShow();
103 if(!aString.isEmpty())
104 {
105 m_xFilterCtr->SelectAuthor(aString);
106 }
107 else
108 {
109 m_xFilterCtr->SelectedAuthorPos(0);
110 }
111
112 m_xFilterCtr->CheckRange(aChangeViewSet.HasRange());
113
115 {
116 const ScRange & rRangeEntry = aChangeViewSet.GetTheRangeList().front();
117 OUString aRefStr(rRangeEntry.Format(rDoc, ScRefFlags::RANGE_ABS_3D));
118 m_xFilterCtr->SetRange(aRefStr);
119 }
120 m_xFilterCtr->Enable(true);
121 HighlightHandle(*m_xHighlightBox);
122}
123
124// Set the reference to a cell range selected with the mouse. This is then
125// shown as the new selection in the reference field.
127{
128 if (m_xEdAssign->GetWidget()->get_visible())
129 {
130 if ( rRef.aStart != rRef.aEnd )
132 OUString aRefStr(rRef.Format(rDocP, ScRefFlags::RANGE_ABS_3D, rDocP.GetAddressConvention()));
133 m_xEdAssign->SetRefString( aRefStr );
134 m_xFilterCtr->SetRange(aRefStr);
135 }
136}
137
139{
140 DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
141}
142
144{
146 if (bForced || !m_xRbAssign->GetWidget()->get_visible())
147 {
148 m_xFilterCtr->SetRange(m_xEdAssign->GetText());
149 m_xFilterCtr->SetFocusToRange();
150 m_xEdAssign->GetWidget()->hide();
151 m_xRbAssign->GetWidget()->hide();
152 }
153}
154
156{
157}
158
160{
161 return m_xEdAssign->GetWidget()->get_visible();
162}
163
165{
166 if (m_xHighlightBox->get_active())
167 {
168 m_xFilterCtr->Enable(true);
169 m_xCbAccept->set_sensitive(true);
170 m_xCbReject->set_sensitive(true);
171 }
172 else
173 {
174 m_xFilterCtr->Enable(false);
175 m_xCbAccept->set_sensitive(false);
176 m_xCbReject->set_sensitive(false);
177 }
178}
179
180IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef, void )
181{
182 if(pRef!=nullptr)
183 {
184 SetDispatcherLock( true );
185 m_xEdAssign->GetWidget()->show();
186 m_xRbAssign->GetWidget()->show();
187 m_xEdAssign->SetText(m_xFilterCtr->GetRange());
188 m_xEdAssign->GrabFocus();
189 ScAnyRefDlgController::RefInputStart(m_xEdAssign.get(), m_xRbAssign.get());
190 }
191}
192
194{
195 aChangeViewSet.SetShowChanges(m_xHighlightBox->get_active());
196 aChangeViewSet.SetHasDate(m_xFilterCtr->IsDate());
197 SvxRedlinDateMode eMode = m_xFilterCtr->GetDateMode();
198 aChangeViewSet.SetTheDateMode( eMode );
199 Date aFirstDate( m_xFilterCtr->GetFirstDate() );
200 tools::Time aFirstTime( m_xFilterCtr->GetFirstTime() );
201 Date aLastDate( m_xFilterCtr->GetLastDate() );
202 tools::Time aLastTime( m_xFilterCtr->GetLastTime() );
203 aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) );
204 aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) );
205 aChangeViewSet.SetHasAuthor(m_xFilterCtr->IsAuthor());
206 aChangeViewSet.SetTheAuthorToShow(m_xFilterCtr->GetSelectedAuthor());
207 aChangeViewSet.SetHasRange(m_xFilterCtr->IsRange());
208 aChangeViewSet.SetShowAccepted(m_xCbAccept->get_active());
209 aChangeViewSet.SetShowRejected(m_xCbReject->get_active());
210 aChangeViewSet.SetHasComment(m_xFilterCtr->IsComment());
211 aChangeViewSet.SetTheComment(m_xFilterCtr->GetComment());
212 ScRangeList aLocalRangeList;
213 aLocalRangeList.Parse(m_xFilterCtr->GetRange(), rDoc);
214 aChangeViewSet.SetTheRangeList(aLocalRangeList);
215 aChangeViewSet.AdjustDateMode( rDoc );
216 rDoc.SetChangeViewSettings(aChangeViewSet);
217 m_rViewData.GetDocShell()->PostPaintGridAll();
218 response(RET_OK);
219}
220
221/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const std::set< OUString > & GetUserCollection() const
Definition: chgtrack.hxx:972
const OUString & GetUser() const
Definition: chgtrack.hxx:971
const ScRangeList & GetTheRangeList() const
Definition: chgviset.hxx:109
bool HasAuthor() const
Definition: chgviset.hxx:92
const OUString & GetTheComment() const
Definition: chgviset.hxx:101
const DateTime & GetTheFirstDateTime() const
Definition: chgviset.hxx:87
SvxRedlinDateMode GetTheDateMode() const
Definition: chgviset.hxx:84
bool IsShowRejected() const
Definition: chgviset.hxx:115
bool HasComment() const
Definition: chgviset.hxx:98
bool HasDate() const
Definition: chgviset.hxx:80
bool HasRange() const
Definition: chgviset.hxx:106
bool ShowChanges() const
Definition: chgviset.hxx:77
void SetTheAuthorToShow(const OUString &aString)
Definition: chgviset.hxx:96
const DateTime & GetTheLastDateTime() const
Definition: chgviset.hxx:90
bool IsShowAccepted() const
Definition: chgviset.hxx:112
const OUString & GetTheAuthorToShow() const
Definition: chgviset.hxx:95
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:492
ScChangeViewSettings * GetChangeViewSettings() const
Definition: document.hxx:2243
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
ScDocument & rDoc
Definition: highred.hxx:35
std::unique_ptr< weld::Button > m_xOkButton
Definition: highred.hxx:41
std::unique_ptr< formula::RefEdit > m_xEdAssign
Definition: highred.hxx:43
std::unique_ptr< formula::RefButton > m_xRbAssign
Definition: highred.hxx:44
std::unique_ptr< weld::CheckButton > m_xCbReject
Definition: highred.hxx:40
virtual bool IsRefInputMode() const override
Definition: highred.cxx:159
virtual void SetActive() override
Definition: highred.cxx:155
std::unique_ptr< SvxTPFilter > m_xFilterCtr
Definition: highred.hxx:48
std::unique_ptr< weld::CheckButton > m_xCbAccept
Definition: highred.hxx:39
virtual void RefInputDone(bool bForced=false) override
Definition: highred.cxx:143
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
Definition: highred.cxx:126
ScChangeViewSettings aChangeViewSet
Definition: highred.hxx:36
std::unique_ptr< weld::CheckButton > m_xHighlightBox
Definition: highred.hxx:38
virtual void Close() override
Definition: highred.cxx:138
virtual ~ScHighlightChgDlg() override
Definition: highred.cxx:55
ScHighlightChgDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, ScViewData &rViewData)
Definition: highred.cxx:28
ScRange & front()
Definition: rangelst.hxx:92
bool empty() const
Definition: rangelst.hxx:88
ScRefFlags Parse(std::u16string_view, const ScDocument &, formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO, SCTAB nDefaultTab=0, sal_Unicode cDelimiter=0)
Definition: rangelst.cxx:92
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
Definition: address.cxx:2170
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: anyrefdg.cxx:745
virtual void RefInputDone(bool bForced=false) override
Definition: anyrefdg.cxx:775
bool DoClose(sal_uInt16 nId)
Definition: anyrefdg.cxx:714
void SetDispatcherLock(bool bLock)
Definition: anyrefdg.cxx:720
SvxRedlinDateMode
IMPL_LINK_NOARG(ScHighlightChgDlg, HighlightHandle, weld::Toggleable &, void)
Definition: highred.cxx:164
IMPL_LINK(ScHighlightChgDlg, RefHandle, SvxTPFilter *, pRef, void)
Definition: highred.cxx:180
Mode eMode
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
RET_OK