xref: /aoo42x/main/sc/source/ui/miscdlgs/highred.cxx (revision 4d7c9de0)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // System - Includes ---------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir // INCLUDE -------------------------------------------------------------------
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "global.hxx"
34cdf0e10cSrcweir #include "reffact.hxx"
35cdf0e10cSrcweir #include "document.hxx"
36cdf0e10cSrcweir #include "docsh.hxx"
37cdf0e10cSrcweir #include "scresid.hxx"
38cdf0e10cSrcweir #include "globstr.hrc"
39cdf0e10cSrcweir #include "highred.hrc"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "highred.hxx"
42cdf0e10cSrcweir #include <vcl/msgbox.hxx>
43cdf0e10cSrcweir #include <sfx2/app.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir // defines -------------------------------------------------------------------
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #define ABS_SREF		  SCA_VALID \
48cdf0e10cSrcweir 						| SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
49cdf0e10cSrcweir #define ABS_DREF		  ABS_SREF \
50cdf0e10cSrcweir 						| SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
51cdf0e10cSrcweir #define ABS_SREF3D		ABS_SREF | SCA_TAB_3D
52cdf0e10cSrcweir #define ABS_DREF3D		ABS_DREF | SCA_TAB_3D
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
57cdf0e10cSrcweir 
EnableDisable(Window & rWin,sal_Bool bEnable)58cdf0e10cSrcweir inline void EnableDisable( Window& rWin, sal_Bool bEnable )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir 	if (bEnable)
61cdf0e10cSrcweir 		rWin.Enable();
62cdf0e10cSrcweir 	else
63cdf0e10cSrcweir 		rWin.Disable();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir //============================================================================
67cdf0e10cSrcweir //	class ScHighlightChgDlg
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //----------------------------------------------------------------------------
ScHighlightChgDlg(SfxBindings * pB,SfxChildWindow * pCW,Window * pParent,ScViewData * ptrViewData)70cdf0e10cSrcweir ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
71cdf0e10cSrcweir 					  ScViewData*		ptrViewData)
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	:	ScAnyRefDlg	( pB, pCW, pParent, RID_SCDLG_HIGHLIGHT_CHANGES ),
74cdf0e10cSrcweir 		//
75cdf0e10cSrcweir 		aHighlightBox	( this, ScResId( CB_HIGHLIGHT)),
76cdf0e10cSrcweir         aFlFilter       ( this, ScResId( FL_FILTER)),
77cdf0e10cSrcweir 		aFilterCtr		( this),
78cdf0e10cSrcweir 		aCbAccept		( this, ScResId( CB_HIGHLIGHT_ACCEPT)),
79cdf0e10cSrcweir 		aCbReject		( this, ScResId( CB_HIGHLIGHT_REJECT)),
80cdf0e10cSrcweir 		aOkButton		( this, ScResId( BTN_OK ) ),
81cdf0e10cSrcweir 		aCancelButton	( this, ScResId( BTN_CANCEL ) ),
82cdf0e10cSrcweir 		aHelpButton		( this, ScResId( BTN_HELP ) ),
83cdf0e10cSrcweir         aEdAssign       ( this, this, ScResId( ED_ASSIGN ) ),
84cdf0e10cSrcweir 		aRbAssign		( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
85cdf0e10cSrcweir 		//
86cdf0e10cSrcweir 		pViewData		( ptrViewData ),
87cdf0e10cSrcweir 		pDoc			( ptrViewData->GetDocument() ),
88cdf0e10cSrcweir 		aLocalRangeName ( *(pDoc->GetRangeName()) )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	FreeResource();
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     Point aFlFilterPt( aFlFilter.GetPosPixel() );
93cdf0e10cSrcweir     aFlFilterPt.Y() += aFlFilter.GetSizePixel().Height();
94cdf0e10cSrcweir     aFilterCtr.SetPosPixel( aFlFilterPt );
95cdf0e10cSrcweir 	MinSize=aFilterCtr.GetSizePixel();
96cdf0e10cSrcweir 	MinSize.Height()+=2;
97cdf0e10cSrcweir 	MinSize.Width()+=2;
98cdf0e10cSrcweir 	aOkButton.SetClickHdl(LINK( this, ScHighlightChgDlg, OKBtnHdl));
99cdf0e10cSrcweir 	aHighlightBox.SetClickHdl(LINK( this, ScHighlightChgDlg, HighLightHandle ));
100cdf0e10cSrcweir 	aFilterCtr.SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle ));
101cdf0e10cSrcweir 	aFilterCtr.HideRange(sal_False);
102cdf0e10cSrcweir 	aFilterCtr.Show();
103cdf0e10cSrcweir 	SetDispatcherLock( sal_True );
104cdf0e10cSrcweir 	//SFX_APPWINDOW->Disable(sal_False);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	Init();
107cdf0e10cSrcweir 
108*0deba7fbSSteve Yin 	aFilterCtr.SetAccessibleRelationMemberOf(&aFlFilter);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
~ScHighlightChgDlg()111cdf0e10cSrcweir ScHighlightChgDlg::~ScHighlightChgDlg()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	SetDispatcherLock( sal_False );
114cdf0e10cSrcweir 	//SFX_APPWINDOW->Enable();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
Init()117cdf0e10cSrcweir void __EXPORT ScHighlightChgDlg::Init()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	String	aAreaStr;
120cdf0e10cSrcweir 	ScRange aRange;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	ScChangeTrack* pChanges=pDoc->GetChangeTrack();
125cdf0e10cSrcweir 	if(pChanges!=NULL)
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir 		aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
128cdf0e10cSrcweir 		aFilterCtr.ClearAuthors();
129cdf0e10cSrcweir 		ScStrCollection aUserColl=pChanges->GetUserCollection();
130cdf0e10cSrcweir 		for(sal_uInt16	i=0;i<aUserColl.GetCount();i++)
131cdf0e10cSrcweir 			aFilterCtr.InsertAuthor(aUserColl[i]->GetString());
132cdf0e10cSrcweir 	}
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	if(pViewSettings!=NULL)
138cdf0e10cSrcweir 		aChangeViewSet=*pViewSettings;
139cdf0e10cSrcweir 	aHighlightBox.Check(aChangeViewSet.ShowChanges());
140cdf0e10cSrcweir 	aFilterCtr.CheckDate(aChangeViewSet.HasDate());
141cdf0e10cSrcweir 	aFilterCtr.SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
142cdf0e10cSrcweir 	aFilterCtr.SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
143cdf0e10cSrcweir 	aFilterCtr.SetLastDate(aChangeViewSet.GetTheLastDateTime());
144cdf0e10cSrcweir 	aFilterCtr.SetLastTime(aChangeViewSet.GetTheLastDateTime());
145cdf0e10cSrcweir 	aFilterCtr.SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode());
146cdf0e10cSrcweir 	aFilterCtr.CheckAuthor(aChangeViewSet.HasAuthor());
147cdf0e10cSrcweir 	aFilterCtr.CheckComment(aChangeViewSet.HasComment());
148cdf0e10cSrcweir 	aFilterCtr.SetComment(aChangeViewSet.GetTheComment());
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	aCbAccept.Check(aChangeViewSet.IsShowAccepted());
151cdf0e10cSrcweir 	aCbReject.Check(aChangeViewSet.IsShowRejected());
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	String aString=aChangeViewSet.GetTheAuthorToShow();
154cdf0e10cSrcweir 	if(aString.Len()!=0)
155cdf0e10cSrcweir 	{
156cdf0e10cSrcweir 		aFilterCtr.SelectAuthor(aString);
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir 	else
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir 		aFilterCtr.SelectedAuthorPos(0);
161cdf0e10cSrcweir 	}
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	aFilterCtr.CheckRange(aChangeViewSet.HasRange());
164cdf0e10cSrcweir 	ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	if(pRangeEntry!=NULL)
168cdf0e10cSrcweir 	{
169cdf0e10cSrcweir 		String aRefStr;
170cdf0e10cSrcweir 		pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
171cdf0e10cSrcweir 		aFilterCtr.SetRange(aRefStr);
172cdf0e10cSrcweir 	}
173cdf0e10cSrcweir 	aFilterCtr.Enable(sal_True,sal_True);
174cdf0e10cSrcweir 	HighLightHandle(&aHighlightBox);
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir //----------------------------------------------------------------------------
178cdf0e10cSrcweir // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
179cdf0e10cSrcweir // neue Selektion im Referenz-Edit angezeigt wird.
180cdf0e10cSrcweir 
SetReference(const ScRange & rRef,ScDocument * pDocP)181cdf0e10cSrcweir void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	if ( aEdAssign.IsVisible() )
184cdf0e10cSrcweir 	{
185cdf0e10cSrcweir 		if ( rRef.aStart != rRef.aEnd )
186cdf0e10cSrcweir 			RefInputStart(&aEdAssign);
187cdf0e10cSrcweir 		String aRefStr;
188cdf0e10cSrcweir         rRef.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() );
189cdf0e10cSrcweir 		aEdAssign.SetRefString( aRefStr );
190cdf0e10cSrcweir 		aFilterCtr.SetRange(aRefStr);
191cdf0e10cSrcweir 	}
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir //----------------------------------------------------------------------------
Close()195cdf0e10cSrcweir sal_Bool __EXPORT ScHighlightChgDlg::Close()
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
RefInputDone(sal_Bool bForced)200cdf0e10cSrcweir void ScHighlightChgDlg::RefInputDone( sal_Bool bForced)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	ScAnyRefDlg::RefInputDone(bForced);
203cdf0e10cSrcweir 	if(bForced || !aRbAssign.IsVisible())
204cdf0e10cSrcweir 	{
205cdf0e10cSrcweir 		aFilterCtr.SetRange(aEdAssign.GetText());
206cdf0e10cSrcweir 		aFilterCtr.SetFocusToRange();
207cdf0e10cSrcweir 		aEdAssign.Hide();
208cdf0e10cSrcweir 		aRbAssign.Hide();
209cdf0e10cSrcweir 	}
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
SetActive()212cdf0e10cSrcweir void ScHighlightChgDlg::SetActive()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir 	/*
215cdf0e10cSrcweir 	if(pTPFilter!=NULL)
216cdf0e10cSrcweir 	{
217cdf0e10cSrcweir 		aAcceptChgCtr.GetFilterPage()->SetFocusToRange();
218cdf0e10cSrcweir 		aEdAssign.Hide();
219cdf0e10cSrcweir 		aRbAssign.Hide();
220cdf0e10cSrcweir 		SFX_APPWINDOW->Enable();
221cdf0e10cSrcweir 		SetDispatcherLock( sal_False );
222cdf0e10cSrcweir 	}
223cdf0e10cSrcweir 	//RefInputDone();
224cdf0e10cSrcweir 	*/
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
IsRefInputMode() const227cdf0e10cSrcweir sal_Bool ScHighlightChgDlg::IsRefInputMode() const
228cdf0e10cSrcweir {
229cdf0e10cSrcweir 	return aEdAssign.IsVisible();
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
IMPL_LINK(ScHighlightChgDlg,HighLightHandle,CheckBox *,pCb)232cdf0e10cSrcweir IMPL_LINK( ScHighlightChgDlg, HighLightHandle, CheckBox*, pCb )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir 	if(pCb!=NULL)
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		if(aHighlightBox.IsChecked())
237cdf0e10cSrcweir 		{
238cdf0e10cSrcweir 			aFilterCtr.Enable(sal_True,sal_True);
239cdf0e10cSrcweir 			aCbAccept.Enable();
240cdf0e10cSrcweir 			aCbReject.Enable();
241cdf0e10cSrcweir 		}
242cdf0e10cSrcweir 		else
243cdf0e10cSrcweir 		{
244cdf0e10cSrcweir 			aFilterCtr.Disable(sal_True);
245cdf0e10cSrcweir 			aCbAccept.Disable();
246cdf0e10cSrcweir 			aCbReject.Disable();
247cdf0e10cSrcweir 		}
248cdf0e10cSrcweir 	}
249cdf0e10cSrcweir 	return 0;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
IMPL_LINK(ScHighlightChgDlg,RefHandle,SvxTPFilter *,pRef)252cdf0e10cSrcweir IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir 	if(pRef!=NULL)
255cdf0e10cSrcweir 	{
256cdf0e10cSrcweir 		SetDispatcherLock( sal_True );
257cdf0e10cSrcweir 		//SFX_APPWINDOW->Disable(sal_False);
258cdf0e10cSrcweir 		aEdAssign.Show();
259cdf0e10cSrcweir 		aRbAssign.Show();
260cdf0e10cSrcweir 		aEdAssign.SetText(aFilterCtr.GetRange());
261*0deba7fbSSteve Yin 		aEdAssign.GrabFocus();
262cdf0e10cSrcweir 		ScAnyRefDlg::RefInputStart(&aEdAssign,&aRbAssign);
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 	return 0;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir 
IMPL_LINK(ScHighlightChgDlg,OKBtnHdl,PushButton *,pOKBtn)267cdf0e10cSrcweir IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir 	if ( pOKBtn == &aOkButton)
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 		aChangeViewSet.SetShowChanges(aHighlightBox.IsChecked());
272cdf0e10cSrcweir 		aChangeViewSet.SetHasDate(aFilterCtr.IsDate());
273cdf0e10cSrcweir 		ScChgsDateMode eMode = (ScChgsDateMode) aFilterCtr.GetDateMode();
274cdf0e10cSrcweir 		aChangeViewSet.SetTheDateMode( eMode );
275cdf0e10cSrcweir 		Date aFirstDate( aFilterCtr.GetFirstDate() );
276cdf0e10cSrcweir 		Time aFirstTime( aFilterCtr.GetFirstTime() );
277cdf0e10cSrcweir 		Date aLastDate( aFilterCtr.GetLastDate() );
278cdf0e10cSrcweir 		Time aLastTime( aFilterCtr.GetLastTime() );
279cdf0e10cSrcweir 		aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) );
280cdf0e10cSrcweir 		aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) );
281cdf0e10cSrcweir 		aChangeViewSet.SetHasAuthor(aFilterCtr.IsAuthor());
282cdf0e10cSrcweir 		aChangeViewSet.SetTheAuthorToShow(aFilterCtr.GetSelectedAuthor());
283cdf0e10cSrcweir 		aChangeViewSet.SetHasRange(aFilterCtr.IsRange());
284cdf0e10cSrcweir 		aChangeViewSet.SetShowAccepted(aCbAccept.IsChecked());
285cdf0e10cSrcweir 		aChangeViewSet.SetShowRejected(aCbReject.IsChecked());
286cdf0e10cSrcweir 		aChangeViewSet.SetHasComment(aFilterCtr.IsComment());
287cdf0e10cSrcweir 		aChangeViewSet.SetTheComment(aFilterCtr.GetComment());
288cdf0e10cSrcweir         ScRangeList aLocalRangeList;
289cdf0e10cSrcweir         aLocalRangeList.Parse(aFilterCtr.GetRange(), pDoc);
290cdf0e10cSrcweir         aChangeViewSet.SetTheRangeList(aLocalRangeList);
291cdf0e10cSrcweir         aChangeViewSet.AdjustDateMode( *pDoc );
292cdf0e10cSrcweir 		pDoc->SetChangeViewSettings(aChangeViewSet);
293cdf0e10cSrcweir 		pViewData->GetDocShell()->PostPaintGridAll();
294cdf0e10cSrcweir 		Close();
295cdf0e10cSrcweir 	}
296cdf0e10cSrcweir 	return 0;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 
301