1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10*b3f79822SAndrew Rist * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b3f79822SAndrew Rist * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19*b3f79822SAndrew Rist * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew 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 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 //---------------------------------------------------------------------------- 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 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir ScHighlightChgDlg::~ScHighlightChgDlg() 111cdf0e10cSrcweir { 112cdf0e10cSrcweir SetDispatcherLock( sal_False ); 113cdf0e10cSrcweir //SFX_APPWINDOW->Enable(); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir void __EXPORT ScHighlightChgDlg::Init() 117cdf0e10cSrcweir { 118cdf0e10cSrcweir String aAreaStr; 119cdf0e10cSrcweir ScRange aRange; 120cdf0e10cSrcweir 121cdf0e10cSrcweir DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" ); 122cdf0e10cSrcweir 123cdf0e10cSrcweir ScChangeTrack* pChanges=pDoc->GetChangeTrack(); 124cdf0e10cSrcweir if(pChanges!=NULL) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser()); 127cdf0e10cSrcweir aFilterCtr.ClearAuthors(); 128cdf0e10cSrcweir ScStrCollection aUserColl=pChanges->GetUserCollection(); 129cdf0e10cSrcweir for(sal_uInt16 i=0;i<aUserColl.GetCount();i++) 130cdf0e10cSrcweir aFilterCtr.InsertAuthor(aUserColl[i]->GetString()); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir 134cdf0e10cSrcweir ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings(); 135cdf0e10cSrcweir 136cdf0e10cSrcweir if(pViewSettings!=NULL) 137cdf0e10cSrcweir aChangeViewSet=*pViewSettings; 138cdf0e10cSrcweir aHighlightBox.Check(aChangeViewSet.ShowChanges()); 139cdf0e10cSrcweir aFilterCtr.CheckDate(aChangeViewSet.HasDate()); 140cdf0e10cSrcweir aFilterCtr.SetFirstDate(aChangeViewSet.GetTheFirstDateTime()); 141cdf0e10cSrcweir aFilterCtr.SetFirstTime(aChangeViewSet.GetTheFirstDateTime()); 142cdf0e10cSrcweir aFilterCtr.SetLastDate(aChangeViewSet.GetTheLastDateTime()); 143cdf0e10cSrcweir aFilterCtr.SetLastTime(aChangeViewSet.GetTheLastDateTime()); 144cdf0e10cSrcweir aFilterCtr.SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode()); 145cdf0e10cSrcweir aFilterCtr.CheckAuthor(aChangeViewSet.HasAuthor()); 146cdf0e10cSrcweir aFilterCtr.CheckComment(aChangeViewSet.HasComment()); 147cdf0e10cSrcweir aFilterCtr.SetComment(aChangeViewSet.GetTheComment()); 148cdf0e10cSrcweir 149cdf0e10cSrcweir aCbAccept.Check(aChangeViewSet.IsShowAccepted()); 150cdf0e10cSrcweir aCbReject.Check(aChangeViewSet.IsShowRejected()); 151cdf0e10cSrcweir 152cdf0e10cSrcweir String aString=aChangeViewSet.GetTheAuthorToShow(); 153cdf0e10cSrcweir if(aString.Len()!=0) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir aFilterCtr.SelectAuthor(aString); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir else 158cdf0e10cSrcweir { 159cdf0e10cSrcweir aFilterCtr.SelectedAuthorPos(0); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir aFilterCtr.CheckRange(aChangeViewSet.HasRange()); 163cdf0e10cSrcweir ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0); 164cdf0e10cSrcweir 165cdf0e10cSrcweir 166cdf0e10cSrcweir if(pRangeEntry!=NULL) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir String aRefStr; 169cdf0e10cSrcweir pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc ); 170cdf0e10cSrcweir aFilterCtr.SetRange(aRefStr); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir aFilterCtr.Enable(sal_True,sal_True); 173cdf0e10cSrcweir HighLightHandle(&aHighlightBox); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir //---------------------------------------------------------------------------- 177cdf0e10cSrcweir // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als 178cdf0e10cSrcweir // neue Selektion im Referenz-Edit angezeigt wird. 179cdf0e10cSrcweir 180cdf0e10cSrcweir void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir if ( aEdAssign.IsVisible() ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir if ( rRef.aStart != rRef.aEnd ) 185cdf0e10cSrcweir RefInputStart(&aEdAssign); 186cdf0e10cSrcweir String aRefStr; 187cdf0e10cSrcweir rRef.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() ); 188cdf0e10cSrcweir aEdAssign.SetRefString( aRefStr ); 189cdf0e10cSrcweir aFilterCtr.SetRange(aRefStr); 190cdf0e10cSrcweir } 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir //---------------------------------------------------------------------------- 194cdf0e10cSrcweir sal_Bool __EXPORT ScHighlightChgDlg::Close() 195cdf0e10cSrcweir { 196cdf0e10cSrcweir return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() ); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir void ScHighlightChgDlg::RefInputDone( sal_Bool bForced) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir ScAnyRefDlg::RefInputDone(bForced); 202cdf0e10cSrcweir if(bForced || !aRbAssign.IsVisible()) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir aFilterCtr.SetRange(aEdAssign.GetText()); 205cdf0e10cSrcweir aFilterCtr.SetFocusToRange(); 206cdf0e10cSrcweir aEdAssign.Hide(); 207cdf0e10cSrcweir aRbAssign.Hide(); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir void ScHighlightChgDlg::SetActive() 212cdf0e10cSrcweir { 213cdf0e10cSrcweir /* 214cdf0e10cSrcweir if(pTPFilter!=NULL) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir aAcceptChgCtr.GetFilterPage()->SetFocusToRange(); 217cdf0e10cSrcweir aEdAssign.Hide(); 218cdf0e10cSrcweir aRbAssign.Hide(); 219cdf0e10cSrcweir SFX_APPWINDOW->Enable(); 220cdf0e10cSrcweir SetDispatcherLock( sal_False ); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir //RefInputDone(); 223cdf0e10cSrcweir */ 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir sal_Bool ScHighlightChgDlg::IsRefInputMode() const 227cdf0e10cSrcweir { 228cdf0e10cSrcweir return aEdAssign.IsVisible(); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir IMPL_LINK( ScHighlightChgDlg, HighLightHandle, CheckBox*, pCb ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir if(pCb!=NULL) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir if(aHighlightBox.IsChecked()) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir aFilterCtr.Enable(sal_True,sal_True); 238cdf0e10cSrcweir aCbAccept.Enable(); 239cdf0e10cSrcweir aCbReject.Enable(); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir else 242cdf0e10cSrcweir { 243cdf0e10cSrcweir aFilterCtr.Disable(sal_True); 244cdf0e10cSrcweir aCbAccept.Disable(); 245cdf0e10cSrcweir aCbReject.Disable(); 246cdf0e10cSrcweir } 247cdf0e10cSrcweir } 248cdf0e10cSrcweir return 0; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir if(pRef!=NULL) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir SetDispatcherLock( sal_True ); 256cdf0e10cSrcweir //SFX_APPWINDOW->Disable(sal_False); 257cdf0e10cSrcweir aEdAssign.Show(); 258cdf0e10cSrcweir aRbAssign.Show(); 259cdf0e10cSrcweir aEdAssign.SetText(aFilterCtr.GetRange()); 260cdf0e10cSrcweir ScAnyRefDlg::RefInputStart(&aEdAssign,&aRbAssign); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir return 0; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn ) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir if ( pOKBtn == &aOkButton) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir aChangeViewSet.SetShowChanges(aHighlightBox.IsChecked()); 270cdf0e10cSrcweir aChangeViewSet.SetHasDate(aFilterCtr.IsDate()); 271cdf0e10cSrcweir ScChgsDateMode eMode = (ScChgsDateMode) aFilterCtr.GetDateMode(); 272cdf0e10cSrcweir aChangeViewSet.SetTheDateMode( eMode ); 273cdf0e10cSrcweir Date aFirstDate( aFilterCtr.GetFirstDate() ); 274cdf0e10cSrcweir Time aFirstTime( aFilterCtr.GetFirstTime() ); 275cdf0e10cSrcweir Date aLastDate( aFilterCtr.GetLastDate() ); 276cdf0e10cSrcweir Time aLastTime( aFilterCtr.GetLastTime() ); 277cdf0e10cSrcweir aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) ); 278cdf0e10cSrcweir aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) ); 279cdf0e10cSrcweir aChangeViewSet.SetHasAuthor(aFilterCtr.IsAuthor()); 280cdf0e10cSrcweir aChangeViewSet.SetTheAuthorToShow(aFilterCtr.GetSelectedAuthor()); 281cdf0e10cSrcweir aChangeViewSet.SetHasRange(aFilterCtr.IsRange()); 282cdf0e10cSrcweir aChangeViewSet.SetShowAccepted(aCbAccept.IsChecked()); 283cdf0e10cSrcweir aChangeViewSet.SetShowRejected(aCbReject.IsChecked()); 284cdf0e10cSrcweir aChangeViewSet.SetHasComment(aFilterCtr.IsComment()); 285cdf0e10cSrcweir aChangeViewSet.SetTheComment(aFilterCtr.GetComment()); 286cdf0e10cSrcweir ScRangeList aLocalRangeList; 287cdf0e10cSrcweir aLocalRangeList.Parse(aFilterCtr.GetRange(), pDoc); 288cdf0e10cSrcweir aChangeViewSet.SetTheRangeList(aLocalRangeList); 289cdf0e10cSrcweir aChangeViewSet.AdjustDateMode( *pDoc ); 290cdf0e10cSrcweir pDoc->SetChangeViewSettings(aChangeViewSet); 291cdf0e10cSrcweir pViewData->GetDocShell()->PostPaintGridAll(); 292cdf0e10cSrcweir Close(); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir return 0; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir 298cdf0e10cSrcweir 299