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