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 .
21 #include "reffact.hxx"
22 #include "document.hxx"
24 #include "scresid.hxx"
25 #include "globstr.hrc"
26 #include "highred.hrc"
28 #include "highred.hxx"
29 #include <vcl/msgbox.hxx>
30 #include <sfx2/app.hxx>
32 // defines -------------------------------------------------------------------
34 #define ABS_SREF SCA_VALID \
35 | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
36 #define ABS_DREF ABS_SREF \
37 | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
38 #define ABS_DREF3D ABS_DREF | SCA_TAB_3D
40 //============================================================================
41 // class ScHighlightChgDlg
43 //----------------------------------------------------------------------------
44 ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings
* pB
, SfxChildWindow
* pCW
, Window
* pParent
,
45 ScViewData
* ptrViewData
)
47 : ScAnyRefDlg ( pB
, pCW
, pParent
, RID_SCDLG_HIGHLIGHT_CHANGES
),
49 aHighlightBox ( this, ScResId( CB_HIGHLIGHT
)),
50 aFlFilter ( this, ScResId( FL_FILTER
)),
52 aCbAccept ( this, ScResId( CB_HIGHLIGHT_ACCEPT
)),
53 aCbReject ( this, ScResId( CB_HIGHLIGHT_REJECT
)),
54 aOkButton ( this, ScResId( BTN_OK
) ),
55 aCancelButton ( this, ScResId( BTN_CANCEL
) ),
56 aHelpButton ( this, ScResId( BTN_HELP
) ),
57 aEdAssign ( this, this, NULL
, ScResId( ED_ASSIGN
) ),
58 aRbAssign ( this, ScResId( RB_ASSIGN
), &aEdAssign
, this ),
60 pViewData ( ptrViewData
),
61 pDoc ( ptrViewData
->GetDocument() ),
62 aLocalRangeName ( *(pDoc
->GetRangeName()) )
66 Point
aFlFilterPt( aFlFilter
.GetPosPixel() );
67 aFlFilterPt
.Y() += aFlFilter
.GetSizePixel().Height();
68 aFilterCtr
.SetPosPixel( aFlFilterPt
);
69 MinSize
=aFilterCtr
.GetSizePixel();
72 aOkButton
.SetClickHdl(LINK( this, ScHighlightChgDlg
, OKBtnHdl
));
73 aHighlightBox
.SetClickHdl(LINK( this, ScHighlightChgDlg
, HighlightHandle
));
74 aFilterCtr
.SetRefHdl(LINK( this, ScHighlightChgDlg
, RefHandle
));
75 aFilterCtr
.HideRange(false);
77 SetDispatcherLock( true );
83 ScHighlightChgDlg::~ScHighlightChgDlg()
85 SetDispatcherLock( false );
88 void ScHighlightChgDlg::Init()
92 OSL_ENSURE( pViewData
&& pDoc
, "ViewData oder Document nicht gefunden!" );
94 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
97 aChangeViewSet
.SetTheAuthorToShow(pChanges
->GetUser());
98 aFilterCtr
.ClearAuthors();
99 const std::set
<OUString
>& rUserColl
= pChanges
->GetUserCollection();
100 std::set
<OUString
>::const_iterator it
= rUserColl
.begin(), itEnd
= rUserColl
.end();
101 for (; it
!= itEnd
; ++it
)
102 aFilterCtr
.InsertAuthor(*it
);
106 ScChangeViewSettings
* pViewSettings
=pDoc
->GetChangeViewSettings();
108 if(pViewSettings
!=NULL
)
109 aChangeViewSet
=*pViewSettings
;
110 aHighlightBox
.Check(aChangeViewSet
.ShowChanges());
111 aFilterCtr
.CheckDate(aChangeViewSet
.HasDate());
112 aFilterCtr
.SetFirstDate(aChangeViewSet
.GetTheFirstDateTime());
113 aFilterCtr
.SetFirstTime(aChangeViewSet
.GetTheFirstDateTime());
114 aFilterCtr
.SetLastDate(aChangeViewSet
.GetTheLastDateTime());
115 aFilterCtr
.SetLastTime(aChangeViewSet
.GetTheLastDateTime());
116 aFilterCtr
.SetDateMode((sal_uInt16
)aChangeViewSet
.GetTheDateMode());
117 aFilterCtr
.CheckAuthor(aChangeViewSet
.HasAuthor());
118 aFilterCtr
.CheckComment(aChangeViewSet
.HasComment());
119 aFilterCtr
.SetComment(aChangeViewSet
.GetTheComment());
121 aCbAccept
.Check(aChangeViewSet
.IsShowAccepted());
122 aCbReject
.Check(aChangeViewSet
.IsShowRejected());
124 OUString aString
=aChangeViewSet
.GetTheAuthorToShow();
125 if(!aString
.isEmpty())
127 aFilterCtr
.SelectAuthor(aString
);
131 aFilterCtr
.SelectedAuthorPos(0);
134 aFilterCtr
.CheckRange(aChangeViewSet
.HasRange());
136 if ( !aChangeViewSet
.GetTheRangeList().empty() )
138 const ScRange
* pRangeEntry
= aChangeViewSet
.GetTheRangeList().front();
139 OUString
aRefStr(pRangeEntry
->Format(ABS_DREF3D
, pDoc
));
140 aFilterCtr
.SetRange(aRefStr
);
142 aFilterCtr
.Enable(sal_True
,sal_True
);
143 HighlightHandle(&aHighlightBox
);
146 //----------------------------------------------------------------------------
147 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
148 // neue Selektion im Referenz-Edit angezeigt wird.
150 void ScHighlightChgDlg::SetReference( const ScRange
& rRef
, ScDocument
* pDocP
)
152 if ( aEdAssign
.IsVisible() )
154 if ( rRef
.aStart
!= rRef
.aEnd
)
155 RefInputStart(&aEdAssign
);
156 OUString
aRefStr(rRef
.Format(ABS_DREF3D
, pDocP
, pDocP
->GetAddressConvention()));
157 aEdAssign
.SetRefString( aRefStr
);
158 aFilterCtr
.SetRange(aRefStr
);
162 //----------------------------------------------------------------------------
163 sal_Bool
ScHighlightChgDlg::Close()
165 return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
168 void ScHighlightChgDlg::RefInputDone( sal_Bool bForced
)
170 ScAnyRefDlg::RefInputDone(bForced
);
171 if(bForced
|| !aRbAssign
.IsVisible())
173 aFilterCtr
.SetRange(aEdAssign
.GetText());
174 aFilterCtr
.SetFocusToRange();
180 void ScHighlightChgDlg::SetActive()
184 sal_Bool
ScHighlightChgDlg::IsRefInputMode() const
186 return aEdAssign
.IsVisible();
189 IMPL_LINK( ScHighlightChgDlg
, HighlightHandle
, CheckBox
*, pCb
)
193 if(aHighlightBox
.IsChecked())
195 aFilterCtr
.Enable(sal_True
,sal_True
);
201 aFilterCtr
.Disable(sal_True
);
209 IMPL_LINK( ScHighlightChgDlg
, RefHandle
, SvxTPFilter
*, pRef
)
213 SetDispatcherLock( true );
216 aEdAssign
.SetText(aFilterCtr
.GetRange());
217 ScAnyRefDlg::RefInputStart(&aEdAssign
,&aRbAssign
);
222 IMPL_LINK( ScHighlightChgDlg
, OKBtnHdl
, PushButton
*, pOKBtn
)
224 if ( pOKBtn
== &aOkButton
)
226 aChangeViewSet
.SetShowChanges(aHighlightBox
.IsChecked());
227 aChangeViewSet
.SetHasDate(aFilterCtr
.IsDate());
228 ScChgsDateMode eMode
= (ScChgsDateMode
) aFilterCtr
.GetDateMode();
229 aChangeViewSet
.SetTheDateMode( eMode
);
230 Date
aFirstDate( aFilterCtr
.GetFirstDate() );
231 Time
aFirstTime( aFilterCtr
.GetFirstTime() );
232 Date
aLastDate( aFilterCtr
.GetLastDate() );
233 Time
aLastTime( aFilterCtr
.GetLastTime() );
234 aChangeViewSet
.SetTheFirstDateTime( DateTime( aFirstDate
, aFirstTime
) );
235 aChangeViewSet
.SetTheLastDateTime( DateTime( aLastDate
, aLastTime
) );
236 aChangeViewSet
.SetHasAuthor(aFilterCtr
.IsAuthor());
237 aChangeViewSet
.SetTheAuthorToShow(aFilterCtr
.GetSelectedAuthor());
238 aChangeViewSet
.SetHasRange(aFilterCtr
.IsRange());
239 aChangeViewSet
.SetShowAccepted(aCbAccept
.IsChecked());
240 aChangeViewSet
.SetShowRejected(aCbReject
.IsChecked());
241 aChangeViewSet
.SetHasComment(aFilterCtr
.IsComment());
242 aChangeViewSet
.SetTheComment(aFilterCtr
.GetComment());
243 ScRangeList aLocalRangeList
;
244 aLocalRangeList
.Parse(aFilterCtr
.GetRange(), pDoc
);
245 aChangeViewSet
.SetTheRangeList(aLocalRangeList
);
246 aChangeViewSet
.AdjustDateMode( *pDoc
);
247 pDoc
->SetChangeViewSettings(aChangeViewSet
);
248 pViewData
->GetDocShell()->PostPaintGridAll();
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */