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 aFilterCtr.SetAccessibleRelationMemberOf(&aFlFilter); 109 } 110 111 ScHighlightChgDlg::~ScHighlightChgDlg() 112 { 113 SetDispatcherLock( sal_False ); 114 //SFX_APPWINDOW->Enable(); 115 } 116 117 void __EXPORT ScHighlightChgDlg::Init() 118 { 119 String aAreaStr; 120 ScRange aRange; 121 122 DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" ); 123 124 ScChangeTrack* pChanges=pDoc->GetChangeTrack(); 125 if(pChanges!=NULL) 126 { 127 aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser()); 128 aFilterCtr.ClearAuthors(); 129 ScStrCollection aUserColl=pChanges->GetUserCollection(); 130 for(sal_uInt16 i=0;i<aUserColl.GetCount();i++) 131 aFilterCtr.InsertAuthor(aUserColl[i]->GetString()); 132 } 133 134 135 ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings(); 136 137 if(pViewSettings!=NULL) 138 aChangeViewSet=*pViewSettings; 139 aHighlightBox.Check(aChangeViewSet.ShowChanges()); 140 aFilterCtr.CheckDate(aChangeViewSet.HasDate()); 141 aFilterCtr.SetFirstDate(aChangeViewSet.GetTheFirstDateTime()); 142 aFilterCtr.SetFirstTime(aChangeViewSet.GetTheFirstDateTime()); 143 aFilterCtr.SetLastDate(aChangeViewSet.GetTheLastDateTime()); 144 aFilterCtr.SetLastTime(aChangeViewSet.GetTheLastDateTime()); 145 aFilterCtr.SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode()); 146 aFilterCtr.CheckAuthor(aChangeViewSet.HasAuthor()); 147 aFilterCtr.CheckComment(aChangeViewSet.HasComment()); 148 aFilterCtr.SetComment(aChangeViewSet.GetTheComment()); 149 150 aCbAccept.Check(aChangeViewSet.IsShowAccepted()); 151 aCbReject.Check(aChangeViewSet.IsShowRejected()); 152 153 String aString=aChangeViewSet.GetTheAuthorToShow(); 154 if(aString.Len()!=0) 155 { 156 aFilterCtr.SelectAuthor(aString); 157 } 158 else 159 { 160 aFilterCtr.SelectedAuthorPos(0); 161 } 162 163 aFilterCtr.CheckRange(aChangeViewSet.HasRange()); 164 ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0); 165 166 167 if(pRangeEntry!=NULL) 168 { 169 String aRefStr; 170 pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc ); 171 aFilterCtr.SetRange(aRefStr); 172 } 173 aFilterCtr.Enable(sal_True,sal_True); 174 HighLightHandle(&aHighlightBox); 175 } 176 177 //---------------------------------------------------------------------------- 178 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als 179 // neue Selektion im Referenz-Edit angezeigt wird. 180 181 void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP ) 182 { 183 if ( aEdAssign.IsVisible() ) 184 { 185 if ( rRef.aStart != rRef.aEnd ) 186 RefInputStart(&aEdAssign); 187 String aRefStr; 188 rRef.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() ); 189 aEdAssign.SetRefString( aRefStr ); 190 aFilterCtr.SetRange(aRefStr); 191 } 192 } 193 194 //---------------------------------------------------------------------------- 195 sal_Bool __EXPORT ScHighlightChgDlg::Close() 196 { 197 return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() ); 198 } 199 200 void ScHighlightChgDlg::RefInputDone( sal_Bool bForced) 201 { 202 ScAnyRefDlg::RefInputDone(bForced); 203 if(bForced || !aRbAssign.IsVisible()) 204 { 205 aFilterCtr.SetRange(aEdAssign.GetText()); 206 aFilterCtr.SetFocusToRange(); 207 aEdAssign.Hide(); 208 aRbAssign.Hide(); 209 } 210 } 211 212 void ScHighlightChgDlg::SetActive() 213 { 214 /* 215 if(pTPFilter!=NULL) 216 { 217 aAcceptChgCtr.GetFilterPage()->SetFocusToRange(); 218 aEdAssign.Hide(); 219 aRbAssign.Hide(); 220 SFX_APPWINDOW->Enable(); 221 SetDispatcherLock( sal_False ); 222 } 223 //RefInputDone(); 224 */ 225 } 226 227 sal_Bool ScHighlightChgDlg::IsRefInputMode() const 228 { 229 return aEdAssign.IsVisible(); 230 } 231 232 IMPL_LINK( ScHighlightChgDlg, HighLightHandle, CheckBox*, pCb ) 233 { 234 if(pCb!=NULL) 235 { 236 if(aHighlightBox.IsChecked()) 237 { 238 aFilterCtr.Enable(sal_True,sal_True); 239 aCbAccept.Enable(); 240 aCbReject.Enable(); 241 } 242 else 243 { 244 aFilterCtr.Disable(sal_True); 245 aCbAccept.Disable(); 246 aCbReject.Disable(); 247 } 248 } 249 return 0; 250 } 251 252 IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef ) 253 { 254 if(pRef!=NULL) 255 { 256 SetDispatcherLock( sal_True ); 257 //SFX_APPWINDOW->Disable(sal_False); 258 aEdAssign.Show(); 259 aRbAssign.Show(); 260 aEdAssign.SetText(aFilterCtr.GetRange()); 261 //IAccessibility2 Implementation 2009----- 262 aEdAssign.GrabFocus(); 263 //-----IAccessibility2 Implementation 2009 264 ScAnyRefDlg::RefInputStart(&aEdAssign,&aRbAssign); 265 } 266 return 0; 267 } 268 269 IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn ) 270 { 271 if ( pOKBtn == &aOkButton) 272 { 273 aChangeViewSet.SetShowChanges(aHighlightBox.IsChecked()); 274 aChangeViewSet.SetHasDate(aFilterCtr.IsDate()); 275 ScChgsDateMode eMode = (ScChgsDateMode) aFilterCtr.GetDateMode(); 276 aChangeViewSet.SetTheDateMode( eMode ); 277 Date aFirstDate( aFilterCtr.GetFirstDate() ); 278 Time aFirstTime( aFilterCtr.GetFirstTime() ); 279 Date aLastDate( aFilterCtr.GetLastDate() ); 280 Time aLastTime( aFilterCtr.GetLastTime() ); 281 aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) ); 282 aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) ); 283 aChangeViewSet.SetHasAuthor(aFilterCtr.IsAuthor()); 284 aChangeViewSet.SetTheAuthorToShow(aFilterCtr.GetSelectedAuthor()); 285 aChangeViewSet.SetHasRange(aFilterCtr.IsRange()); 286 aChangeViewSet.SetShowAccepted(aCbAccept.IsChecked()); 287 aChangeViewSet.SetShowRejected(aCbReject.IsChecked()); 288 aChangeViewSet.SetHasComment(aFilterCtr.IsComment()); 289 aChangeViewSet.SetTheComment(aFilterCtr.GetComment()); 290 ScRangeList aLocalRangeList; 291 aLocalRangeList.Parse(aFilterCtr.GetRange(), pDoc); 292 aChangeViewSet.SetTheRangeList(aLocalRangeList); 293 aChangeViewSet.AdjustDateMode( *pDoc ); 294 pDoc->SetChangeViewSettings(aChangeViewSet); 295 pViewData->GetDocShell()->PostPaintGridAll(); 296 Close(); 297 } 298 return 0; 299 } 300 301 302 303