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