Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <sal/macros.h>
31 : :
32 : : #include <svx/dialmgr.hxx>
33 : : #include <svx/dialogs.hrc>
34 : : #include "docrecovery.hxx"
35 : : #include "docrecovery.hrc"
36 : :
37 : : #include <comphelper/componentcontext.hxx>
38 : : #include <comphelper/configurationhelper.hxx>
39 : : #include <comphelper/processfactory.hxx>
40 : : #include <comphelper/sequenceashashmap.hxx>
41 : : #include <comphelper/string.hxx>
42 : : #include <svtools/imagemgr.hxx>
43 : : #include <vcl/xtextedt.hxx>
44 : : #include <tools/urlobj.hxx>
45 : : #include <vcl/msgbox.hxx>
46 : : #include <vcl/svapp.hxx>
47 : : #include <rtl/ustrbuf.hxx>
48 : : #include <vcl/scrbar.hxx>
49 : :
50 : : #include <toolkit/unohlp.hxx>
51 : :
52 : : #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
53 : : #include <com/sun/star/lang/XInitialization.hpp>
54 : : #include <com/sun/star/beans/NamedValue.hpp>
55 : : #include <com/sun/star/util/URL.hpp>
56 : : #include <com/sun/star/util/XURLTransformer.hpp>
57 : : #include <com/sun/star/frame/XDispatch.hpp>
58 : : #include <com/sun/star/awt/XWindow.hpp>
59 : : #include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
60 : : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
61 : : #include <com/sun/star/util/URLTransformer.hpp>
62 : : #include <osl/file.hxx>
63 : : #include <osl/security.hxx>
64 : : #include <rtl/bootstrap.hxx>
65 : : #include <unotools/pathoptions.hxx>
66 : : #include <unotools/localfilehelper.hxx>
67 : :
68 : : namespace svx{
69 : : namespace DocRecovery{
70 : :
71 : : namespace css = ::com::sun::star;
72 : :
73 : : using namespace ::rtl;
74 : : using namespace ::osl;
75 : :
76 : : //===============================================
77 : 0 : TabDialog4Recovery::TabDialog4Recovery(Window* pParent)
78 : 0 : : TabDialog (pParent, SVX_RES( RID_SVX_TABDLG_DOCRECOVERY ))
79 [ # # ][ # # ]: 0 : , m_pActualPage(m_lTabPages.begin() )
80 : : {
81 : 0 : }
82 : :
83 : : //===============================================
84 : 0 : TabDialog4Recovery::~TabDialog4Recovery()
85 : : {
86 : 0 : m_lTabPages.clear();
87 [ # # ]: 0 : }
88 : :
89 : : //===============================================
90 : 0 : void TabDialog4Recovery::addTabPage(IExtendedTabPage* pPage)
91 : : {
92 [ # # ]: 0 : if (pPage)
93 : 0 : m_lTabPages.push_back(pPage);
94 : 0 : }
95 : :
96 : : //===============================================
97 : 0 : short TabDialog4Recovery::Execute()
98 : : {
99 [ # # ]: 0 : ::SolarMutexGuard aLock;
100 : :
101 [ # # ]: 0 : Show();
102 : 0 : m_pActualPage = m_lTabPages.begin();
103 : 0 : while(sal_True)
104 : : {
105 : 0 : IExtendedTabPage* pPage = *m_pActualPage;
106 : 0 : SetViewWindow(pPage);
107 [ # # ]: 0 : pPage->Show();
108 [ # # ]: 0 : pPage->setDefButton();
109 [ # # ]: 0 : short nRet = pPage->execute();
110 [ # # ]: 0 : pPage->Hide();
111 : :
112 [ # # # # ]: 0 : switch(nRet)
113 : : {
114 : : case DLG_RET_OK :
115 : : {
116 : 0 : ++m_pActualPage;
117 [ # # ][ # # ]: 0 : if (m_pActualPage == m_lTabPages.end())
118 : 0 : return nRet;
119 : : }
120 : 0 : break;
121 : :
122 : : case DLG_RET_BACK :
123 : : {
124 [ # # ][ # # ]: 0 : if (m_pActualPage != m_lTabPages.begin())
125 : 0 : --m_pActualPage;
126 : : }
127 : 0 : break;
128 : :
129 : : case DLG_RET_UNKNOWN :
130 : : case DLG_RET_CANCEL :
131 : : case DLG_RET_OK_AUTOLUNCH :
132 : 0 : return nRet;
133 : : }
134 [ # # ]: 0 : }
135 : : }
136 : :
137 : : //===============================================
138 : 0 : RecoveryCore::RecoveryCore(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
139 : : sal_Bool bUsedForSaving)
140 : : : m_xSMGR ( xSMGR )
141 : : , m_pListener ( 0 )
142 [ # # ]: 0 : , m_bListenForSaving(bUsedForSaving)
143 : : {
144 [ # # ]: 0 : impl_startListening();
145 : 0 : }
146 : :
147 : : //===============================================
148 : 0 : RecoveryCore::~RecoveryCore()
149 : : {
150 [ # # ]: 0 : impl_stopListening();
151 [ # # ]: 0 : }
152 : :
153 : : //===============================================
154 : 0 : css::uno::Reference< css::lang::XMultiServiceFactory > RecoveryCore::getSMGR()
155 : : {
156 : 0 : return m_xSMGR;
157 : : }
158 : :
159 : : //===============================================
160 : 0 : TURLList* RecoveryCore::getURLListAccess()
161 : : {
162 : 0 : return &m_lURLs;
163 : : }
164 : :
165 : : //===============================================
166 : 0 : sal_Bool RecoveryCore::existsBrokenTempEntries()
167 : : {
168 : 0 : TURLList::const_iterator pIt;
169 [ # # ][ # # ]: 0 : for ( pIt = m_lURLs.begin();
[ # # ]
170 : 0 : pIt != m_lURLs.end() ;
171 : : ++pIt )
172 : : {
173 : 0 : const TURLInfo& rInfo = *pIt;
174 [ # # ]: 0 : if (RecoveryCore::isBrokenTempEntry(rInfo))
175 : 0 : return sal_True;
176 : : }
177 : :
178 : 0 : return sal_False;
179 : : }
180 : :
181 : : //===============================================
182 : 0 : sal_Bool RecoveryCore::existsNonRecoveredEntries()
183 : : {
184 : 0 : TURLList::const_iterator pIt;
185 [ # # ][ # # ]: 0 : for ( pIt = m_lURLs.begin();
[ # # ]
186 : 0 : pIt != m_lURLs.end() ;
187 : : ++pIt )
188 : : {
189 : 0 : const TURLInfo& rInfo = *pIt;
190 [ # # ]: 0 : if (rInfo.RecoveryState == E_NOT_RECOVERED_YET)
191 : 0 : return sal_True;
192 : : }
193 : :
194 : 0 : return sal_False;
195 : : }
196 : :
197 : : //===============================================
198 : 0 : sal_Bool RecoveryCore::isBrokenTempEntry(const TURLInfo& rInfo)
199 : : {
200 [ # # ]: 0 : if (rInfo.TempURL.isEmpty())
201 : 0 : return sal_False;
202 : :
203 : : // Note: If the original files was recovery ... but a temp file
204 : : // exists ... an error inside the temp file exists!
205 [ # # ][ # # ]: 0 : if (
206 : 0 : !(rInfo.RecoveryState == E_RECOVERY_FAILED ) &&
207 : 0 : !(rInfo.RecoveryState == E_ORIGINAL_DOCUMENT_RECOVERED)
208 : : )
209 : 0 : return sal_False;
210 : :
211 : 0 : return sal_True;
212 : : }
213 : :
214 : : //===============================================
215 : 0 : void RecoveryCore::saveBrokenTempEntries(const ::rtl::OUString& sPath)
216 : : {
217 [ # # ]: 0 : if (sPath.isEmpty())
218 : : return;
219 : :
220 [ # # ]: 0 : if (!m_xRealCore.is())
221 : : return;
222 : :
223 : : // prepare all needed parameters for the following dispatch() request.
224 [ # # ][ # # ]: 0 : css::util::URL aCopyURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_BACKUP);
225 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lCopyArgs(3);
226 [ # # ][ # # ]: 0 : lCopyArgs[0].Name = PROP_DISPATCHASYNCHRON;
227 [ # # ][ # # ]: 0 : lCopyArgs[0].Value <<= sal_False;
228 [ # # ][ # # ]: 0 : lCopyArgs[1].Name = PROP_SAVEPATH;
229 [ # # ][ # # ]: 0 : lCopyArgs[1].Value <<= sPath;
230 [ # # ][ # # ]: 0 : lCopyArgs[2].Name = PROP_ENTRYID;
231 : : // lCopyArgs[2].Value will be changed during next loop ...
232 : :
233 : : // work on a copied list only ...
234 : : // Reason: We will get notifications from the core for every
235 : : // changed or removed element. And that will change our m_lURLs list.
236 : : // That's not a good idea, if we use a stl iterator inbetween .-)
237 [ # # ]: 0 : TURLList lURLs = m_lURLs;
238 : 0 : TURLList::const_iterator pIt;
239 [ # # ][ # # ]: 0 : for ( pIt = lURLs.begin();
[ # # ]
240 : 0 : pIt != lURLs.end() ;
241 : : ++pIt )
242 : : {
243 : 0 : const TURLInfo& rInfo = *pIt;
244 [ # # ]: 0 : if (!RecoveryCore::isBrokenTempEntry(rInfo))
245 : 0 : continue;
246 : :
247 [ # # ][ # # ]: 0 : lCopyArgs[2].Value <<= rInfo.ID;
248 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aCopyURL, lCopyArgs);
249 [ # # ]: 0 : }
250 : : }
251 : :
252 : : //===============================================
253 : 0 : void RecoveryCore::saveAllTempEntries(const ::rtl::OUString& sPath)
254 : : {
255 [ # # ]: 0 : if (sPath.isEmpty())
256 : : return;
257 : :
258 [ # # ]: 0 : if (!m_xRealCore.is())
259 : : return;
260 : :
261 : : // prepare all needed parameters for the following dispatch() request.
262 [ # # ][ # # ]: 0 : css::util::URL aCopyURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_BACKUP);
263 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lCopyArgs(3);
264 [ # # ][ # # ]: 0 : lCopyArgs[0].Name = PROP_DISPATCHASYNCHRON;
265 [ # # ][ # # ]: 0 : lCopyArgs[0].Value <<= sal_False;
266 [ # # ][ # # ]: 0 : lCopyArgs[1].Name = PROP_SAVEPATH;
267 [ # # ][ # # ]: 0 : lCopyArgs[1].Value <<= sPath;
268 [ # # ][ # # ]: 0 : lCopyArgs[2].Name = PROP_ENTRYID;
269 : : // lCopyArgs[2].Value will be changed during next loop ...
270 : :
271 : : // work on a copied list only ...
272 : : // Reason: We will get notifications from the core for every
273 : : // changed or removed element. And that will change our m_lURLs list.
274 : : // That's not a good idea, if we use a stl iterator inbetween .-)
275 [ # # ]: 0 : TURLList lURLs = m_lURLs;
276 : 0 : TURLList::const_iterator pIt;
277 [ # # ][ # # ]: 0 : for ( pIt = lURLs.begin();
[ # # ]
278 : 0 : pIt != lURLs.end() ;
279 : : ++pIt )
280 : : {
281 : 0 : const TURLInfo& rInfo = *pIt;
282 [ # # ]: 0 : if (rInfo.TempURL.isEmpty())
283 : 0 : continue;
284 : :
285 [ # # ][ # # ]: 0 : lCopyArgs[2].Value <<= rInfo.ID;
286 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aCopyURL, lCopyArgs);
287 [ # # ]: 0 : }
288 : : }
289 : :
290 : : //===============================================
291 : 0 : void RecoveryCore::forgetBrokenTempEntries()
292 : : {
293 [ # # ]: 0 : if (!m_xRealCore.is())
294 : 0 : return;
295 : :
296 [ # # ][ # # ]: 0 : css::util::URL aRemoveURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_CLEANUP);
297 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
298 [ # # ][ # # ]: 0 : lRemoveArgs[0].Name = PROP_DISPATCHASYNCHRON;
299 [ # # ][ # # ]: 0 : lRemoveArgs[0].Value <<= sal_False;
300 [ # # ][ # # ]: 0 : lRemoveArgs[1].Name = PROP_ENTRYID;
301 : : // lRemoveArgs[1].Value will be changed during next loop ...
302 : :
303 : : // work on a copied list only ...
304 : : // Reason: We will get notifications from the core for every
305 : : // changed or removed element. And that will change our m_lURLs list.
306 : : // That's not a good idea, if we use a stl iterator inbetween .-)
307 [ # # ]: 0 : TURLList lURLs = m_lURLs;
308 : 0 : TURLList::const_iterator pIt;
309 [ # # ][ # # ]: 0 : for ( pIt = lURLs.begin();
[ # # ]
310 : 0 : pIt != lURLs.end() ;
311 : : ++pIt )
312 : : {
313 : 0 : const TURLInfo& rInfo = *pIt;
314 [ # # ]: 0 : if (!RecoveryCore::isBrokenTempEntry(rInfo))
315 : 0 : continue;
316 : :
317 [ # # ][ # # ]: 0 : lRemoveArgs[1].Value <<= rInfo.ID;
318 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aRemoveURL, lRemoveArgs);
319 [ # # ]: 0 : }
320 : : }
321 : :
322 : : //===============================================
323 : 0 : void RecoveryCore::forgetAllRecoveryEntries()
324 : : {
325 [ # # ]: 0 : if (!m_xRealCore.is())
326 : 0 : return;
327 : :
328 [ # # ][ # # ]: 0 : css::util::URL aRemoveURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_CLEANUP);
329 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
330 [ # # ][ # # ]: 0 : lRemoveArgs[0].Name = PROP_DISPATCHASYNCHRON;
331 [ # # ][ # # ]: 0 : lRemoveArgs[0].Value <<= sal_False;
332 [ # # ][ # # ]: 0 : lRemoveArgs[1].Name = PROP_ENTRYID;
333 : : // lRemoveArgs[1].Value will be changed during next loop ...
334 : :
335 : : // work on a copied list only ...
336 : : // Reason: We will get notifications from the core for every
337 : : // changed or removed element. And that will change our m_lURLs list.
338 : : // That's not a good idea, if we use a stl iterator inbetween .-)
339 [ # # ]: 0 : TURLList lURLs = m_lURLs;
340 : 0 : TURLList::const_iterator pIt;
341 [ # # ][ # # ]: 0 : for ( pIt = lURLs.begin();
[ # # ]
342 : 0 : pIt != lURLs.end() ;
343 : : ++pIt )
344 : : {
345 : 0 : const TURLInfo& rInfo = *pIt;
346 [ # # ][ # # ]: 0 : lRemoveArgs[1].Value <<= rInfo.ID;
347 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aRemoveURL, lRemoveArgs);
348 [ # # ]: 0 : }
349 : : }
350 : :
351 : : //===============================================
352 : 0 : void RecoveryCore::forgetBrokenRecoveryEntries()
353 : : {
354 [ # # ]: 0 : if (!m_xRealCore.is())
355 : 0 : return;
356 : :
357 [ # # ][ # # ]: 0 : css::util::URL aRemoveURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_CLEANUP);
358 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
359 [ # # ][ # # ]: 0 : lRemoveArgs[0].Name = PROP_DISPATCHASYNCHRON;
360 [ # # ][ # # ]: 0 : lRemoveArgs[0].Value <<= sal_False;
361 [ # # ][ # # ]: 0 : lRemoveArgs[1].Name = PROP_ENTRYID;
362 : : // lRemoveArgs[1].Value will be changed during next loop ...
363 : :
364 : : // work on a copied list only ...
365 : : // Reason: We will get notifications from the core for every
366 : : // changed or removed element. And that will change our m_lURLs list.
367 : : // That's not a good idea, if we use a stl iterator inbetween .-)
368 [ # # ]: 0 : TURLList lURLs = m_lURLs;
369 : 0 : TURLList::const_iterator pIt;
370 [ # # ][ # # ]: 0 : for ( pIt = lURLs.begin();
[ # # ]
371 : 0 : pIt != lURLs.end() ;
372 : : ++pIt )
373 : : {
374 : 0 : const TURLInfo& rInfo = *pIt;
375 [ # # ]: 0 : if (!RecoveryCore::isBrokenTempEntry(rInfo))
376 : 0 : continue;
377 : :
378 [ # # ][ # # ]: 0 : lRemoveArgs[1].Value <<= rInfo.ID;
379 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aRemoveURL, lRemoveArgs);
380 [ # # ]: 0 : }
381 : : }
382 : :
383 : : //===============================================
384 : 0 : void RecoveryCore::setProgressHandler(const css::uno::Reference< css::task::XStatusIndicator >& xProgress)
385 : : {
386 : 0 : m_xProgress = xProgress;
387 : 0 : }
388 : :
389 : : //===============================================
390 : 0 : void RecoveryCore::setUpdateListener(IRecoveryUpdateListener* pListener)
391 : : {
392 : 0 : m_pListener = pListener;
393 : 0 : }
394 : :
395 : : //===============================================
396 : 0 : void RecoveryCore::doEmergencySavePrepare()
397 : : {
398 [ # # ]: 0 : if (!m_xRealCore.is())
399 : 0 : return;
400 : :
401 [ # # ][ # # ]: 0 : css::util::URL aURL = impl_getParsedURL(RECOVERY_CMD_DO_PREPARE_EMERGENCY_SAVE);
402 : :
403 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lArgs(1);
404 [ # # ][ # # ]: 0 : lArgs[0].Name = PROP_DISPATCHASYNCHRON;
405 [ # # ][ # # ]: 0 : lArgs[0].Value <<= sal_False;
406 : :
407 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aURL, lArgs);
[ # # ]
408 : : }
409 : :
410 : : //===============================================
411 : 0 : void RecoveryCore::doEmergencySave()
412 : : {
413 [ # # ]: 0 : if (!m_xRealCore.is())
414 : 0 : return;
415 : :
416 [ # # ][ # # ]: 0 : css::util::URL aURL = impl_getParsedURL(RECOVERY_CMD_DO_EMERGENCY_SAVE);
417 : :
418 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
419 [ # # ][ # # ]: 0 : lArgs[0].Name = PROP_STATUSINDICATOR;
420 [ # # ][ # # ]: 0 : lArgs[0].Value <<= m_xProgress;
421 [ # # ][ # # ]: 0 : lArgs[1].Name = PROP_DISPATCHASYNCHRON;
422 [ # # ][ # # ]: 0 : lArgs[1].Value <<= sal_True;
423 : :
424 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aURL, lArgs);
[ # # ]
425 : : }
426 : :
427 : : //===============================================
428 : 0 : void RecoveryCore::doRecovery()
429 : : {
430 [ # # ]: 0 : if (!m_xRealCore.is())
431 : 0 : return;
432 : :
433 [ # # ][ # # ]: 0 : css::util::URL aURL = impl_getParsedURL(RECOVERY_CMD_DO_RECOVERY);
434 : :
435 [ # # ]: 0 : css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
436 [ # # ][ # # ]: 0 : lArgs[0].Name = PROP_STATUSINDICATOR;
437 [ # # ][ # # ]: 0 : lArgs[0].Value <<= m_xProgress;
438 [ # # ][ # # ]: 0 : lArgs[1].Name = PROP_DISPATCHASYNCHRON;
439 [ # # ][ # # ]: 0 : lArgs[1].Value <<= sal_True;
440 : :
441 [ # # ][ # # ]: 0 : m_xRealCore->dispatch(aURL, lArgs);
[ # # ]
442 : : }
443 : :
444 : : //===============================================
445 : 0 : ERecoveryState RecoveryCore::mapDocState2RecoverState(sal_Int32 eDocState)
446 : : {
447 : : // ???
448 : 0 : ERecoveryState eRecState = E_NOT_RECOVERED_YET;
449 : :
450 : : /* Attention:
451 : : Some of the following states can occure at the
452 : : same time. So we have to check for the "worst case" first!
453 : :
454 : : DAMAGED -> INCOMPLETE -> HANDLED
455 : : */
456 : :
457 : : // running ...
458 [ # # ][ # # ]: 0 : if (
459 : : ((eDocState & E_TRY_LOAD_BACKUP ) == E_TRY_LOAD_BACKUP ) ||
460 : : ((eDocState & E_TRY_LOAD_ORIGINAL) == E_TRY_LOAD_ORIGINAL)
461 : : )
462 : 0 : eRecState = E_RECOVERY_IS_IN_PROGRESS;
463 : : // red
464 : : else
465 [ # # ]: 0 : if ((eDocState & E_DAMAGED) == E_DAMAGED)
466 : 0 : eRecState = E_RECOVERY_FAILED;
467 : : // yellow
468 : : else
469 [ # # ]: 0 : if ((eDocState & E_INCOMPLETE) == E_INCOMPLETE)
470 : 0 : eRecState = E_ORIGINAL_DOCUMENT_RECOVERED;
471 : : // green
472 : : else
473 [ # # ]: 0 : if ((eDocState & E_SUCCEDED) == E_SUCCEDED)
474 : 0 : eRecState = E_SUCCESSFULLY_RECOVERED;
475 : :
476 : 0 : return eRecState;
477 : : }
478 : :
479 : : //===============================================
480 : 0 : void SAL_CALL RecoveryCore::statusChanged(const css::frame::FeatureStateEvent& aEvent)
481 : : throw(css::uno::RuntimeException)
482 : : {
483 : : // a) special notification about start/stop async dispatch!
484 : : // FeatureDescriptor = "start" || "stop"
485 [ # # ][ # # ]: 0 : if (aEvent.FeatureDescriptor.equals(RECOVERY_OPERATIONSTATE_START))
486 : : {
487 [ # # ]: 0 : if (m_pListener)
488 [ # # ]: 0 : m_pListener->start();
489 : : return;
490 : : }
491 : :
492 [ # # ][ # # ]: 0 : if (aEvent.FeatureDescriptor.equals(RECOVERY_OPERATIONSTATE_STOP))
493 : : {
494 [ # # ]: 0 : if (m_pListener)
495 [ # # ]: 0 : m_pListener->end();
496 : : return;
497 : : }
498 : :
499 : : // b) normal notification about changed items
500 : : // FeatureDescriptor = "Update"
501 : : // State = Lits of informations [seq< NamedValue >]
502 [ # # ][ # # ]: 0 : if (! aEvent.FeatureDescriptor.equals(RECOVERY_OPERATIONSTATE_UPDATE))
503 : : return;
504 : :
505 [ # # ]: 0 : ::comphelper::SequenceAsHashMap lInfo(aEvent.State);
506 [ # # ]: 0 : TURLInfo aNew;
507 : :
508 [ # # ][ # # ]: 0 : aNew.ID = lInfo.getUnpackedValueOrDefault(STATEPROP_ID , (sal_Int32)0 );
509 [ # # ][ # # ]: 0 : aNew.DocState = lInfo.getUnpackedValueOrDefault(STATEPROP_STATE , (sal_Int32)0 );
510 [ # # ][ # # ]: 0 : aNew.OrgURL = lInfo.getUnpackedValueOrDefault(STATEPROP_ORGURL , ::rtl::OUString());
511 [ # # ][ # # ]: 0 : aNew.TempURL = lInfo.getUnpackedValueOrDefault(STATEPROP_TEMPURL , ::rtl::OUString());
512 [ # # ][ # # ]: 0 : aNew.FactoryURL = lInfo.getUnpackedValueOrDefault(STATEPROP_FACTORYURL , ::rtl::OUString());
513 [ # # ][ # # ]: 0 : aNew.TemplateURL = lInfo.getUnpackedValueOrDefault(STATEPROP_TEMPLATEURL, ::rtl::OUString());
514 [ # # ][ # # ]: 0 : aNew.DisplayName = lInfo.getUnpackedValueOrDefault(STATEPROP_TITLE , ::rtl::OUString());
515 [ # # ][ # # ]: 0 : aNew.Module = lInfo.getUnpackedValueOrDefault(STATEPROP_MODULE , ::rtl::OUString());
516 : :
517 : : // search for already existing items and update her nState value ...
518 : 0 : TURLList::iterator pIt;
519 [ # # ][ # # ]: 0 : for ( pIt = m_lURLs.begin();
520 : 0 : pIt != m_lURLs.end() ;
521 : : ++pIt )
522 : : {
523 : 0 : TURLInfo& aOld = *pIt;
524 [ # # ]: 0 : if (aOld.ID == aNew.ID)
525 : : {
526 : : // change existing
527 : 0 : aOld.DocState = aNew.DocState;
528 : 0 : aOld.RecoveryState = RecoveryCore::mapDocState2RecoverState(aOld.DocState);
529 [ # # ]: 0 : if (m_pListener)
530 : : {
531 [ # # ]: 0 : m_pListener->updateItems();
532 [ # # ]: 0 : m_pListener->stepNext(&aOld);
533 : : }
534 : : return;
535 : : }
536 : : }
537 : :
538 : : // append as new one
539 : : // TODO think about mmatching Module name to a corresponding icon
540 [ # # ]: 0 : String sURL = aNew.OrgURL;
541 [ # # ]: 0 : if (!sURL.Len())
542 [ # # ]: 0 : sURL = aNew.FactoryURL;
543 [ # # ]: 0 : if (!sURL.Len())
544 [ # # ]: 0 : sURL = aNew.TempURL;
545 [ # # ]: 0 : if (!sURL.Len())
546 [ # # ]: 0 : sURL = aNew.TemplateURL;
547 [ # # ][ # # ]: 0 : INetURLObject aURL(sURL);
548 [ # # ][ # # ]: 0 : aNew.StandardImage = SvFileInformationManager::GetFileImage(aURL, false);
[ # # ]
549 : :
550 : : /* set the right UI state for this item to NOT_RECOVERED_YET ... because nDocState shows the state of
551 : : the last emergency save operation before and is interessting for the used recovery core service only ...
552 : : for now! But if there is a further notification for this item (see lines above!) we must
553 : : map the doc state to an UI state. */
554 : 0 : aNew.RecoveryState = E_NOT_RECOVERED_YET;
555 : :
556 : : // patch DisplayName! Because the document title contain more then the file name ...
557 : 0 : sal_Int32 i = aNew.DisplayName.indexOf(" - ");
558 [ # # ]: 0 : if (i > 0)
559 : 0 : aNew.DisplayName = aNew.DisplayName.copy(0, i);
560 : :
561 [ # # ]: 0 : m_lURLs.push_back(aNew);
562 : :
563 [ # # ]: 0 : if (m_pListener)
564 [ # # ][ # # ]: 0 : m_pListener->updateItems();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
565 : : }
566 : :
567 : : //===============================================
568 : 0 : void SAL_CALL RecoveryCore::disposing(const css::lang::EventObject& /*aEvent*/)
569 : : throw(css::uno::RuntimeException)
570 : : {
571 : 0 : m_xRealCore.clear();
572 : 0 : }
573 : :
574 : : //===============================================
575 : 0 : void RecoveryCore::impl_startListening()
576 : : {
577 : : // listening already initialized ?
578 [ # # ]: 0 : if (m_xRealCore.is())
579 : 0 : return;
580 [ # # ][ # # ]: 0 : m_xRealCore = css::uno::Reference< css::frame::XDispatch >(m_xSMGR->createInstance(SERVICENAME_RECOVERYCORE), css::uno::UNO_QUERY_THROW);
[ # # ][ # # ]
[ # # ]
581 : :
582 : 0 : css::util::URL aURL;
583 [ # # ]: 0 : if (m_bListenForSaving)
584 [ # # ]: 0 : aURL.Complete = RECOVERY_CMD_DO_EMERGENCY_SAVE;
585 : : else
586 [ # # ]: 0 : aURL.Complete = RECOVERY_CMD_DO_RECOVERY;
587 [ # # ][ # # ]: 0 : css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(::comphelper::ComponentContext(m_xSMGR).getUNOContext()));
[ # # ][ # # ]
588 [ # # ][ # # ]: 0 : xParser->parseStrict(aURL);
589 : :
590 : : /* Note: addStatusListener() call us synchronous back ... so we
591 : : will get the complete list of currently open documents! */
592 [ # # ][ # # ]: 0 : m_xRealCore->addStatusListener(static_cast< css::frame::XStatusListener* >(this), aURL);
[ # # ]
593 : : }
594 : :
595 : : //===============================================
596 : 0 : void RecoveryCore::impl_stopListening()
597 : : {
598 : : // Ignore it, if this instance doesnt listen currently
599 [ # # ]: 0 : if (!m_xRealCore.is())
600 : 0 : return;
601 : :
602 : 0 : css::util::URL aURL;
603 [ # # ]: 0 : if (m_bListenForSaving)
604 [ # # ]: 0 : aURL.Complete = RECOVERY_CMD_DO_EMERGENCY_SAVE;
605 : : else
606 [ # # ]: 0 : aURL.Complete = RECOVERY_CMD_DO_RECOVERY;
607 [ # # ][ # # ]: 0 : css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(::comphelper::ComponentContext(m_xSMGR).getUNOContext()));
[ # # ][ # # ]
608 [ # # ][ # # ]: 0 : xParser->parseStrict(aURL);
609 : :
610 [ # # ][ # # ]: 0 : m_xRealCore->removeStatusListener(static_cast< css::frame::XStatusListener* >(this), aURL);
[ # # ]
611 : 0 : m_xRealCore.clear();
612 : : }
613 : :
614 : : //===============================================
615 : 0 : css::util::URL RecoveryCore::impl_getParsedURL(const ::rtl::OUString& sURL)
616 : : {
617 : 0 : css::util::URL aURL;
618 : 0 : aURL.Complete = sURL;
619 : :
620 [ # # ][ # # ]: 0 : css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(::comphelper::ComponentContext(m_xSMGR).getUNOContext()));
[ # # ][ # # ]
621 [ # # ][ # # ]: 0 : xParser->parseStrict(aURL);
622 : :
623 : 0 : return aURL;
624 : : }
625 : :
626 : : //===============================================
627 : 0 : PluginProgressWindow::PluginProgressWindow( Window* pParent ,
628 : : const css::uno::Reference< css::lang::XComponent >& xProgress)
629 : : : Window (pParent )
630 : 0 : , m_xProgress(xProgress)
631 : : {
632 [ # # ]: 0 : Show();
633 [ # # ]: 0 : Size aParentSize = pParent->GetSizePixel();
634 : : // align the progressbar to its parent
635 [ # # ]: 0 : SetPosSizePixel( -9, 0, aParentSize.Width() + 15, aParentSize.Height() - 4 );
636 : 0 : }
637 : :
638 : : //===============================================
639 : 0 : PluginProgressWindow::~PluginProgressWindow()
640 : : {
641 [ # # ]: 0 : if (m_xProgress.is())
642 [ # # ][ # # ]: 0 : m_xProgress->dispose();
643 [ # # ]: 0 : }
644 : :
645 : : //===============================================
646 : 0 : PluginProgress::PluginProgress( Window* pParent,
647 : 0 : const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
648 : : {
649 [ # # ][ # # ]: 0 : m_pPlugProgressWindow = new PluginProgressWindow(pParent, static_cast< css::lang::XComponent* >(this));
[ # # ]
650 [ # # ]: 0 : css::uno::Reference< css::awt::XWindow > xProgressWindow = VCLUnoHelper::GetInterface(m_pPlugProgressWindow);
651 [ # # ][ # # ]: 0 : m_xProgressFactory = css::uno::Reference< css::task::XStatusIndicatorFactory >(xSMGR->createInstance(SERVICENAME_PROGRESSFACTORY), css::uno::UNO_QUERY_THROW);
[ # # ][ # # ]
[ # # ]
652 [ # # ]: 0 : css::uno::Reference< css::lang::XInitialization > xInit(m_xProgressFactory, css::uno::UNO_QUERY_THROW);
653 : :
654 [ # # ]: 0 : css::uno::Sequence< css::uno::Any > lArgs(2);
655 : 0 : css::beans::NamedValue aProp;
656 [ # # ]: 0 : aProp.Name = PROP_PARENTWINDOW;
657 [ # # ]: 0 : aProp.Value <<= xProgressWindow;
658 [ # # ][ # # ]: 0 : lArgs[0] <<= aProp;
659 [ # # ]: 0 : aProp.Name = PROP_ALLOWPARENTSHOW;
660 [ # # ]: 0 : aProp.Value <<= sal_True;
661 [ # # ][ # # ]: 0 : lArgs[1] <<= aProp;
662 : :
663 [ # # ][ # # ]: 0 : xInit->initialize(lArgs);
664 : :
665 [ # # ][ # # ]: 0 : m_xProgress = m_xProgressFactory->createStatusIndicator();
[ # # ][ # # ]
666 : 0 : }
667 : :
668 : : //===============================================
669 : 0 : PluginProgress::~PluginProgress()
670 : : {
671 [ # # ]: 0 : }
672 : :
673 : : //===============================================
674 : 0 : void SAL_CALL PluginProgress::dispose()
675 : : throw(css::uno::RuntimeException)
676 : : {
677 : : // m_pPluginProgressWindow was deleted ...
678 : : // So the internal pointer of this progress
679 : : // weill be dead!
680 : 0 : m_xProgress.clear();
681 : 0 : }
682 : :
683 : : //===============================================
684 : 0 : void SAL_CALL PluginProgress::addEventListener(const css::uno::Reference< css::lang::XEventListener >& )
685 : : throw(css::uno::RuntimeException)
686 : : {
687 : 0 : }
688 : :
689 : : //===============================================
690 : 0 : void SAL_CALL PluginProgress::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& )
691 : : throw(css::uno::RuntimeException)
692 : : {
693 : 0 : }
694 : :
695 : : //===============================================
696 : 0 : void SAL_CALL PluginProgress::start(const ::rtl::OUString&,
697 : : sal_Int32 nRange)
698 : : throw(css::uno::RuntimeException)
699 : : {
700 [ # # ]: 0 : if (m_xProgress.is())
701 [ # # ]: 0 : m_xProgress->start(::rtl::OUString(), nRange);
702 : 0 : }
703 : :
704 : : //===============================================
705 : 0 : void SAL_CALL PluginProgress::end()
706 : : throw(css::uno::RuntimeException)
707 : : {
708 [ # # ]: 0 : if (m_xProgress.is())
709 : 0 : m_xProgress->end();
710 : 0 : }
711 : :
712 : : //===============================================
713 : 0 : void SAL_CALL PluginProgress::setText(const ::rtl::OUString& sText)
714 : : throw(css::uno::RuntimeException)
715 : : {
716 [ # # ]: 0 : if (m_xProgress.is())
717 : 0 : m_xProgress->setText(sText);
718 : 0 : }
719 : :
720 : : //===============================================
721 : 0 : void SAL_CALL PluginProgress::setValue(sal_Int32 nValue)
722 : : throw(css::uno::RuntimeException)
723 : : {
724 [ # # ]: 0 : if (m_xProgress.is())
725 : 0 : m_xProgress->setValue(nValue);
726 : 0 : }
727 : :
728 : : //===============================================
729 : 0 : void SAL_CALL PluginProgress::reset()
730 : : throw(css::uno::RuntimeException)
731 : : {
732 [ # # ]: 0 : if (m_xProgress.is())
733 : 0 : m_xProgress->reset();
734 : 0 : }
735 : :
736 : : //===============================================
737 : 0 : SaveDialog::SaveDialog(Window* pParent,
738 : : RecoveryCore* pCore )
739 : 0 : : IExtendedTabPage( pParent, SVX_RES( RID_SVXPAGE_DOCRECOVERY_SAVE ) )
740 [ # # ]: 0 : , m_aTitleWin ( this , SVX_RES ( WIN_SAVE_TITLE ) )
741 [ # # ]: 0 : , m_aTitleFT ( this , SVX_RES ( FT_SAVE_TITLE ) )
742 [ # # ]: 0 : , m_aTitleFL ( this , SVX_RES ( FL_SAVE_TITLE ) )
743 [ # # ]: 0 : , m_aDescrFT ( this , SVX_RES ( FT_SAVE_DESCR ) )
744 [ # # ]: 0 : , m_aFileListFT ( this , SVX_RES ( FT_SAVE_FILELIST ) )
745 [ # # ]: 0 : , m_aFileListLB ( this , SVX_RES ( LB_SAVE_FILELIST ) )
746 [ # # ]: 0 : , m_aBottomFL ( this , SVX_RES ( FL_SAVE_BOTTOM ) )
747 [ # # ]: 0 : , m_aOkBtn ( this , SVX_RES ( BT_SAVE_OK ) )
748 [ # # ][ # # ]: 0 : , m_pCore ( pCore )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
749 : : {
750 [ # # ]: 0 : FreeResource();
751 : :
752 : : // Prepare the office for the following crash save step.
753 : : // E.g. hide all open widows so the user cant influence our
754 : : // operation .-)
755 [ # # ]: 0 : m_pCore->doEmergencySavePrepare();
756 : :
757 : 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
758 [ # # ]: 0 : Wallpaper aBackground(rStyleSettings.GetWindowColor());
759 [ # # ]: 0 : m_aTitleWin.SetBackground(aBackground);
760 [ # # ]: 0 : m_aTitleFT.SetBackground (aBackground);
761 : :
762 [ # # ]: 0 : Font aFont(m_aTitleFT.GetFont());
763 [ # # ]: 0 : aFont.SetWeight(WEIGHT_BOLD);
764 [ # # ]: 0 : m_aTitleFT.SetFont(aFont);
765 : :
766 [ # # ]: 0 : m_aOkBtn.SetClickHdl( LINK( this, SaveDialog, OKButtonHdl ) );
767 [ # # ]: 0 : m_aFileListLB.SetControlBackground( rStyleSettings.GetDialogColor() );
768 : :
769 : : // fill listbox with current open documents
770 [ # # ]: 0 : m_aFileListLB.Clear();
771 : :
772 [ # # ]: 0 : TURLList* pURLs = m_pCore->getURLListAccess();
773 : 0 : TURLList::const_iterator pIt;
774 : :
775 [ # # ][ # # ]: 0 : for ( pIt = pURLs->begin();
[ # # ]
776 : 0 : pIt != pURLs->end() ;
777 : : ++pIt )
778 : : {
779 : 0 : const TURLInfo& rInfo = *pIt;
780 [ # # ][ # # ]: 0 : m_aFileListLB.InsertEntry( rInfo.DisplayName, rInfo.StandardImage );
[ # # ]
781 [ # # ][ # # ]: 0 : }
782 : 0 : }
783 : :
784 : : //===============================================
785 [ # # ][ # # ]: 0 : SaveDialog::~SaveDialog()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
786 : : {
787 [ # # ]: 0 : }
788 : :
789 : : //===============================================
790 : 0 : IMPL_LINK_NOARG(SaveDialog, OKButtonHdl)
791 : : {
792 : 0 : m_nResult = DLG_RET_OK;
793 : 0 : return 0;
794 : : }
795 : :
796 : : //===============================================
797 : 0 : short SaveDialog::execute()
798 : : {
799 [ # # ]: 0 : ::SolarMutexGuard aLock;
800 : :
801 : : // wait for user input "OK"
802 : 0 : m_nResult = DLG_RET_UNKNOWN;
803 [ # # ]: 0 : while(m_nResult == DLG_RET_UNKNOWN)
804 [ # # ]: 0 : Application::Yield();
805 : :
806 : : // start crash-save with progress
807 [ # # ]: 0 : if (m_nResult == DLG_RET_OK)
808 : : {
809 [ # # ][ # # ]: 0 : SaveProgressDialog* pProgress = new SaveProgressDialog(this, m_pCore);
810 [ # # ]: 0 : m_nResult = pProgress->Execute();
811 [ # # ][ # # ]: 0 : delete pProgress;
812 : : }
813 : : // if "CANCEL" => return "CANCEL"
814 : : // if "OK" => "AUTOLUNCH" always !
815 [ # # ]: 0 : if (m_nResult == DLG_RET_OK)
816 : 0 : m_nResult = DLG_RET_OK_AUTOLUNCH;
817 : :
818 [ # # ]: 0 : return m_nResult;
819 : : }
820 : :
821 : : //===============================================
822 : 0 : void SaveDialog::setDefButton()
823 : : {
824 : 0 : m_aOkBtn.GrabFocus();
825 : 0 : }
826 : :
827 : : //===============================================
828 : 0 : SaveProgressDialog::SaveProgressDialog(Window* pParent,
829 : : RecoveryCore* pCore )
830 : 0 : : ModalDialog ( pParent , SVX_RES( RID_SVX_MDLG_DOCRECOVERY_PROGR ) )
831 [ # # ]: 0 : , m_aHintFT ( this , SVX_RES ( FT_SAVEPROGR_HINT ) )
832 [ # # ]: 0 : , m_aProgrFT ( this , SVX_RES ( FT_SAVEPROGR_PROGR ) )
833 [ # # ]: 0 : , m_aProgrParent( this , SVX_RES ( WIN_SAVEPROGR_PROGR ) )
834 [ # # ][ # # ]: 0 : , m_pCore ( pCore )
[ # # ][ # # ]
[ # # ]
835 : : {
836 [ # # ]: 0 : FreeResource();
837 [ # # ][ # # ]: 0 : PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, pCore->getSMGR() );
838 [ # # ][ # # ]: 0 : m_xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW);
[ # # ]
839 : 0 : }
840 : :
841 : : //===============================================
842 [ # # ][ # # ]: 0 : SaveProgressDialog::~SaveProgressDialog()
[ # # ][ # # ]
843 : : {
844 [ # # ]: 0 : }
845 : :
846 : : //===============================================
847 : 0 : short SaveProgressDialog::Execute()
848 : : {
849 [ # # ]: 0 : ::SolarMutexGuard aLock;
850 : :
851 [ # # ]: 0 : m_pCore->setProgressHandler(m_xProgress);
852 [ # # ]: 0 : m_pCore->setUpdateListener(this);
853 [ # # ]: 0 : m_pCore->doEmergencySave();
854 [ # # ]: 0 : short nRet = ModalDialog::Execute();
855 [ # # ]: 0 : m_pCore->setUpdateListener(0);
856 [ # # ]: 0 : return nRet;
857 : : }
858 : :
859 : : //===============================================
860 : 0 : void SaveProgressDialog::updateItems()
861 : : {
862 : 0 : }
863 : :
864 : : //===============================================
865 : 0 : void SaveProgressDialog::stepNext(TURLInfo* )
866 : : {
867 : : /* TODO
868 : :
869 : : wenn die m_pCore noch ein Member m_nCurrentItem haette
870 : : koennte man dort erkennen, wer gerade drann war, wer demnaechst
871 : : dran ist ... Diese Info kann man dann in unserem Progress FixText anzeigen ...
872 : : */
873 : 0 : }
874 : :
875 : : //===============================================
876 : 0 : void SaveProgressDialog::start()
877 : : {
878 : 0 : }
879 : :
880 : : //===============================================
881 : 0 : void SaveProgressDialog::end()
882 : : {
883 : 0 : EndDialog(DLG_RET_OK);
884 : 0 : }
885 : :
886 : : //===============================================
887 : 0 : RecovDocListEntry::RecovDocListEntry( SvLBoxEntry* pEntry,
888 : : sal_uInt16 nFlags,
889 : : const String& sText )
890 [ # # ]: 0 : : SvLBoxString( pEntry, nFlags, sText )
891 : : {
892 : 0 : }
893 : :
894 : : //===============================================
895 : 0 : void RecovDocListEntry::Paint(const Point& aPos ,
896 : : SvLBox& aDevice,
897 : : sal_uInt16 /*nFlags */,
898 : : SvLBoxEntry* pEntry )
899 : : {
900 : 0 : const Image* pImg = 0;
901 : 0 : const String* pTxt = 0;
902 : 0 : RecovDocList* pList = static_cast< RecovDocList* >(&aDevice);
903 : :
904 : 0 : TURLInfo* pInfo = (TURLInfo*)pEntry->GetUserData();
905 [ # # # # : 0 : switch(pInfo->RecoveryState)
# # ]
906 : : {
907 : : case E_SUCCESSFULLY_RECOVERED :
908 : : {
909 : 0 : pImg = &pList->m_aGreenCheckImg;
910 : 0 : pTxt = &pList->m_aSuccessRecovStr;
911 : : }
912 : 0 : break;
913 : :
914 : : case E_ORIGINAL_DOCUMENT_RECOVERED : // TODO must be renamed into ORIGINAL DOCUMENT recovered! Because its marked as yellow
915 : : {
916 : 0 : pImg = &pList->m_aYellowCheckImg;
917 : 0 : pTxt = &pList->m_aOrigDocRecovStr;
918 : : }
919 : 0 : break;
920 : :
921 : : case E_RECOVERY_FAILED :
922 : : {
923 : 0 : pImg = &pList->m_aRedCrossImg;
924 : 0 : pTxt = &pList->m_aRecovFailedStr;
925 : : }
926 : 0 : break;
927 : :
928 : : case E_RECOVERY_IS_IN_PROGRESS :
929 : : {
930 : 0 : pImg = 0;
931 : 0 : pTxt = &pList->m_aRecovInProgrStr;
932 : : }
933 : 0 : break;
934 : :
935 : : case E_NOT_RECOVERED_YET :
936 : : {
937 : 0 : pImg = 0;
938 : 0 : pTxt = &pList->m_aNotRecovYetStr;
939 : : }
940 : 0 : break;
941 : : }
942 : :
943 [ # # ]: 0 : if (pImg)
944 : 0 : aDevice.DrawImage(aPos, *pImg);
945 : :
946 [ # # ]: 0 : if (pTxt)
947 : : {
948 : 0 : Point aPnt(aPos);
949 [ # # ]: 0 : aPnt.X() += pList->m_aGreenCheckImg.GetSizePixel().Width();
950 : 0 : aPnt.X() += 10;
951 [ # # ]: 0 : aDevice.DrawText(aPnt, *pTxt);
952 : : }
953 : 0 : }
954 : : //===============================================
955 : 0 : RecovDocList::RecovDocList(SvxSimpleTableContainer& rParent, ResMgr &rResMgr)
956 : : : SvxSimpleTable ( rParent )
957 : : , m_aGreenCheckImg ( ResId(IMG_GREENCHECK, rResMgr ) )
958 : : , m_aYellowCheckImg ( ResId(IMG_YELLOWCHECK, rResMgr ) )
959 : : , m_aRedCrossImg ( ResId(IMG_REDCROSS, rResMgr ) )
960 : : , m_aSuccessRecovStr ( ResId(STR_SUCCESSRECOV, rResMgr ) )
961 : : , m_aOrigDocRecovStr ( ResId(STR_ORIGDOCRECOV, rResMgr ) )
962 : : , m_aRecovFailedStr ( ResId(STR_RECOVFAILED, rResMgr ) )
963 : : , m_aRecovInProgrStr ( ResId(STR_RECOVINPROGR, rResMgr ) )
964 [ # # ][ # # ]: 0 : , m_aNotRecovYetStr ( ResId(STR_NOTRECOVYET, rResMgr ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
965 : : {
966 : 0 : }
967 : :
968 : : //===============================================
969 [ # # ][ # # ]: 0 : RecovDocList::~RecovDocList()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
970 : : {
971 [ # # ]: 0 : }
972 : :
973 : : //===============================================
974 : 0 : void RecovDocList::InitEntry( SvLBoxEntry* pEntry ,
975 : : const XubString& sText ,
976 : : const Image& aImage1,
977 : : const Image& aImage2,
978 : : SvLBoxButtonKind eButtonKind)
979 : : {
980 : 0 : SvTabListBox::InitEntry(pEntry, sText, aImage1, aImage2, eButtonKind);
981 : : DBG_ASSERT( TabCount() == 2, "*RecovDocList::InitEntry(): structure missmatch" );
982 : :
983 : 0 : SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem(2);
984 [ # # ][ # # ]: 0 : RecovDocListEntry* p = new RecovDocListEntry(pEntry, 0, pCol->GetText());
[ # # ][ # # ]
985 : 0 : pEntry->ReplaceItem(p, 2);
986 : 0 : }
987 : :
988 : : //===============================================
989 : 0 : short impl_askUserForWizardCancel(Window* pParent, sal_Int16 nRes)
990 : : {
991 [ # # ][ # # ]: 0 : QueryBox aQuery(pParent, SVX_RES(nRes));
992 [ # # ][ # # ]: 0 : if (aQuery.Execute() == RET_YES)
993 : 0 : return DLG_RET_OK;
994 : : else
995 [ # # ]: 0 : return DLG_RET_CANCEL;
996 : : }
997 : :
998 : : //===============================================
999 : 0 : RecoveryDialog::RecoveryDialog(Window* pParent,
1000 : : RecoveryCore* pCore )
1001 : 0 : : IExtendedTabPage( pParent , SVX_RES( RID_SVXPAGE_DOCRECOVERY_RECOVER ) )
1002 [ # # ]: 0 : , m_aTitleWin ( this , SVX_RES ( WIN_RECOV_TITLE ) )
1003 [ # # ]: 0 : , m_aTitleFT ( this , SVX_RES ( FT_RECOV_TITLE ) )
1004 [ # # ]: 0 : , m_aTitleFL ( this , SVX_RES ( FL_RECOV_TITLE ) )
1005 [ # # ]: 0 : , m_aDescrFT ( this , SVX_RES ( FT_RECOV_DESCR ) )
1006 [ # # ]: 0 : , m_aProgressFT ( this , SVX_RES ( FT_RECOV_PROGR ) )
1007 [ # # ]: 0 : , m_aProgrParent ( this , SVX_RES ( WIN_RECOV_PROGR ) )
1008 [ # # ]: 0 : , m_aFileListFT ( this , SVX_RES ( FT_RECOV_FILELIST ) )
1009 [ # # ]: 0 : , m_aFileListLBContainer( this , SVX_RES ( LB_RECOV_FILELIST ) )
1010 [ # # ]: 0 : , m_aFileListLB (m_aFileListLBContainer, DIALOG_MGR())
1011 [ # # ]: 0 : , m_aBottomFL ( this , SVX_RES ( FL_RECOV_BOTTOM ) )
1012 [ # # ]: 0 : , m_aNextBtn ( this , SVX_RES ( BTN_RECOV_NEXT ) )
1013 [ # # ]: 0 : , m_aCancelBtn ( this , SVX_RES ( BTN_RECOV_CANCEL ) )
1014 [ # # ]: 0 : , m_aNextStr ( SVX_RES ( STR_RECOVERY_NEXT ) )
1015 [ # # ]: 0 : , m_aTitleRecoveryInProgress( SVX_RES ( STR_RECOVERY_INPROGRESS ) )
1016 [ # # ]: 0 : , m_aTitleRecoveryReport( SVX_RES ( STR_RECOVERY_REPORT ) )
1017 [ # # ]: 0 : , m_aRecoveryOnlyFinish ( SVX_RES ( STR_RECOVERYONLY_FINISH ) )
1018 [ # # ]: 0 : , m_aRecoveryOnlyFinishDescr( SVX_RES ( STR_RECOVERYONLY_FINISH_DESCR ) )
1019 : : , m_pDefButton ( NULL )
1020 : : , m_pCore ( pCore )
1021 : : , m_eRecoveryState (RecoveryDialog::E_RECOVERY_PREPARED)
1022 : : , m_bWaitForUser (sal_False)
1023 : : , m_bWaitForCore (sal_False)
1024 : : , m_bUserDecideNext (sal_False)
1025 : : , m_bWasRecoveryStarted (sal_False)
1026 [ # # ][ # # ]: 0 : , m_bRecoveryOnly (sal_False)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1027 : : {
1028 : : static long nTabs[] = { 2, 0, 40*RECOV_CONTROLWIDTH/100 };
1029 [ # # ]: 0 : m_aFileListLB.SetTabs( &nTabs[0] );
1030 [ # # ][ # # ]: 0 : m_aFileListLB.InsertHeaderEntry( String( SVX_RES( STR_HEADERBAR ) ) );
[ # # ][ # # ]
[ # # ]
1031 : :
1032 [ # # ]: 0 : FreeResource();
1033 : :
1034 : 0 : ::rtl::OUString CFG_PACKAGE_RECOVERY( "org.openoffice.Office.Recovery/" );
1035 : 0 : ::rtl::OUString CFG_PATH_CRASHREPORTER( "CrashReporter" );
1036 : 0 : ::rtl::OUString CFG_ENTRY_ENABLED( "Enabled" );
1037 : :
1038 : 0 : sal_Bool bCrashRepEnabled( sal_False );
1039 : : css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey(
1040 : 0 : pCore->getSMGR(),
1041 : : CFG_PACKAGE_RECOVERY,
1042 : : CFG_PATH_CRASHREPORTER,
1043 : : CFG_ENTRY_ENABLED,
1044 [ # # ][ # # ]: 0 : ::comphelper::ConfigurationHelper::E_READONLY);
1045 : 0 : aVal >>= bCrashRepEnabled;
1046 : 0 : m_bRecoveryOnly = !bCrashRepEnabled;
1047 : :
1048 [ # # ][ # # ]: 0 : PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, pCore->getSMGR() );
1049 [ # # ][ # # ]: 0 : m_xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW);
[ # # ]
1050 : :
1051 : 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1052 [ # # ]: 0 : Wallpaper aBackground( rStyleSettings.GetWindowColor() );
1053 [ # # ]: 0 : m_aTitleWin.SetBackground(aBackground);
1054 [ # # ]: 0 : m_aTitleFT.SetBackground (aBackground);
1055 : :
1056 [ # # ]: 0 : Font aFont(m_aTitleFT.GetFont());
1057 [ # # ]: 0 : aFont.SetWeight(WEIGHT_BOLD);
1058 [ # # ]: 0 : m_aTitleFT.SetFont(aFont);
1059 : :
1060 [ # # ][ # # ]: 0 : m_aFileListLB.SetBackground( rStyleSettings.GetDialogColor() );
[ # # ]
1061 : :
1062 [ # # ]: 0 : m_aNextBtn.Enable(sal_True);
1063 [ # # ]: 0 : m_aNextBtn.SetClickHdl( LINK( this, RecoveryDialog, NextButtonHdl ) );
1064 [ # # ]: 0 : m_aCancelBtn.SetClickHdl( LINK( this, RecoveryDialog, CancelButtonHdl ) );
1065 : :
1066 : : // fill list box first time
1067 [ # # ]: 0 : TURLList* pURLList = m_pCore->getURLListAccess();
1068 : 0 : TURLList::const_iterator pIt;
1069 [ # # ][ # # ]: 0 : for ( pIt = pURLList->begin();
[ # # ]
1070 : 0 : pIt != pURLList->end() ;
1071 : : ++pIt )
1072 : : {
1073 : 0 : const TURLInfo& rInfo = *pIt;
1074 : :
1075 [ # # ]: 0 : String sName( rInfo.DisplayName );
1076 [ # # ]: 0 : sName += '\t';
1077 [ # # ][ # # ]: 0 : sName += impl_getStatusString( rInfo );
[ # # ]
1078 [ # # ]: 0 : SvLBoxEntry* pEntry = m_aFileListLB.InsertEntry(sName, rInfo.StandardImage, rInfo.StandardImage);
1079 : 0 : pEntry->SetUserData((void*)&rInfo);
1080 [ # # ]: 0 : }
1081 : :
1082 : : // mark first item
1083 [ # # ]: 0 : SvLBoxEntry* pFirst = m_aFileListLB.First();
1084 [ # # ]: 0 : if (pFirst)
1085 [ # # ][ # # ]: 0 : m_aFileListLB.SetCursor(pFirst, sal_True);
[ # # ]
1086 : 0 : }
1087 : :
1088 : : //===============================================
1089 [ # # ][ # # ]: 0 : RecoveryDialog::~RecoveryDialog()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1090 : : {
1091 [ # # ]: 0 : }
1092 : :
1093 : : //===============================================
1094 : 0 : short RecoveryDialog::execute()
1095 : : {
1096 [ # # ]: 0 : ::SolarMutexGuard aSolarLock;
1097 : :
1098 [ # # # # : 0 : switch(m_eRecoveryState)
# # # # ]
1099 : : {
1100 : : case RecoveryDialog::E_RECOVERY_PREPARED :
1101 : : {
1102 : : // Dialog was started first time ...
1103 : : // wait for user decision ("start" or "cancel" recovery)
1104 : : // This decision will be made inside the NextBtn handler.
1105 [ # # ]: 0 : m_aNextBtn.Enable(sal_True);
1106 [ # # ]: 0 : m_aCancelBtn.Enable(sal_True);
1107 : 0 : m_bWaitForUser = sal_True;
1108 [ # # ]: 0 : while(m_bWaitForUser)
1109 [ # # ]: 0 : Application::Yield();
1110 [ # # ]: 0 : if (m_bUserDecideNext)
1111 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_IN_PROGRESS;
1112 : : else
1113 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED;
1114 [ # # ]: 0 : return execute();
1115 : : }
1116 : :
1117 : : case RecoveryDialog::E_RECOVERY_IN_PROGRESS :
1118 : : {
1119 : : // user decided to start recovery ...
1120 : 0 : m_bWasRecoveryStarted = sal_True;
1121 : : // do it asynchronous (to allow repaints)
1122 : : // and wait for this asynchronous operation.
1123 [ # # ]: 0 : m_aDescrFT.SetText( m_aTitleRecoveryInProgress );
1124 [ # # ]: 0 : m_aNextBtn.Enable(sal_False);
1125 [ # # ]: 0 : m_aCancelBtn.Enable(sal_False);
1126 [ # # ]: 0 : m_pCore->setProgressHandler(m_xProgress);
1127 [ # # ]: 0 : m_pCore->setUpdateListener(this);
1128 [ # # ]: 0 : m_pCore->doRecovery();
1129 : :
1130 : 0 : m_bWaitForCore = sal_True;
1131 [ # # ]: 0 : while(m_bWaitForCore)
1132 [ # # ]: 0 : Application::Yield();
1133 : :
1134 [ # # ]: 0 : m_pCore->setUpdateListener(0);
1135 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_CORE_DONE;
1136 [ # # ]: 0 : return execute();
1137 : : }
1138 : :
1139 : : case RecoveryDialog::E_RECOVERY_CORE_DONE :
1140 : : {
1141 : : // the core finished it's task.
1142 : : // let the user decide the next step.
1143 [ # # ]: 0 : if ( m_bRecoveryOnly )
1144 : : {
1145 [ # # ]: 0 : m_aDescrFT.SetText(m_aRecoveryOnlyFinishDescr);
1146 [ # # ]: 0 : m_aNextBtn.SetText(m_aRecoveryOnlyFinish);
1147 [ # # ]: 0 : m_aNextBtn.Enable(sal_True);
1148 [ # # ]: 0 : m_aCancelBtn.Enable(sal_False);
1149 : : }
1150 : : else
1151 : : {
1152 [ # # ]: 0 : m_aDescrFT.SetText(m_aTitleRecoveryReport);
1153 [ # # ]: 0 : m_aNextBtn.SetText(m_aNextStr);
1154 [ # # ]: 0 : m_aNextBtn.Enable(sal_True);
1155 [ # # ]: 0 : m_aCancelBtn.Enable(sal_True);
1156 : : }
1157 : :
1158 : 0 : m_bWaitForUser = sal_True;
1159 [ # # ]: 0 : while(m_bWaitForUser)
1160 [ # # ]: 0 : Application::Yield();
1161 : :
1162 [ # # ]: 0 : if (m_bUserDecideNext)
1163 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_DONE;
1164 : : else
1165 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED;
1166 [ # # ]: 0 : return execute();
1167 : : }
1168 : :
1169 : : case RecoveryDialog::E_RECOVERY_DONE :
1170 : : {
1171 : : // All documents was reovered.
1172 : : // User decided to step to the "next" wizard page.
1173 : : // Do it ... but check first, if there exist some
1174 : : // failed recovery documents. They must be saved to
1175 : : // a user selected directrory.
1176 : 0 : short nRet = DLG_RET_UNKNOWN;
1177 [ # # ][ # # ]: 0 : BrokenRecoveryDialog* pBrokenRecoveryDialog = new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
1178 [ # # ][ # # ]: 0 : String sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); // get the default dir
1179 [ # # ][ # # ]: 0 : if (pBrokenRecoveryDialog->isExecutionNeeded())
1180 : : {
1181 [ # # ]: 0 : nRet = pBrokenRecoveryDialog->Execute();
1182 [ # # ][ # # ]: 0 : sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
1183 : : }
1184 [ # # ][ # # ]: 0 : delete pBrokenRecoveryDialog;
1185 : :
1186 [ # # # # ]: 0 : switch(nRet)
1187 : : {
1188 : : // no broken temp files exists
1189 : : // step to the next wizard page
1190 : : case DLG_RET_UNKNOWN :
1191 : : {
1192 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
1193 : 0 : return DLG_RET_OK;
1194 : : }
1195 : :
1196 : : // user decided to save the broken temp files
1197 : : // do and forget it
1198 : : // step to the next wizard page
1199 : : case DLG_RET_OK :
1200 : : {
1201 [ # # ][ # # ]: 0 : m_pCore->saveBrokenTempEntries(sSaveDir);
1202 [ # # ]: 0 : m_pCore->forgetBrokenTempEntries();
1203 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
1204 : 0 : return DLG_RET_OK;
1205 : : }
1206 : :
1207 : : // user decided to ignore broken temp files.
1208 : : // Ask it again ... may be this decision was wrong.
1209 : : // Results:
1210 : : // IGNORE => remove broken temp files
1211 : : // => step to the next wizard page
1212 : : // CANCEL => step back to the recovery page
1213 : : case DLG_RET_CANCEL :
1214 : : {
1215 : : // TODO ask user ...
1216 [ # # ]: 0 : m_pCore->forgetBrokenTempEntries();
1217 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
1218 : 0 : return DLG_RET_OK;
1219 : : }
1220 : : }
1221 : :
1222 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
1223 [ # # ]: 0 : return DLG_RET_OK;
1224 : : }
1225 : :
1226 : : case RecoveryDialog::E_RECOVERY_CANCELED :
1227 : : {
1228 : : // "YES" => break recovery
1229 : : // But there exist different states, where "cancel" can be called.
1230 : : // Handle it different.
1231 [ # # ]: 0 : if (m_bWasRecoveryStarted)
1232 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED_AFTERWARDS;
1233 : : else
1234 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED_BEFORE;
1235 [ # # ]: 0 : return execute();
1236 : : }
1237 : :
1238 : : case RecoveryDialog::E_RECOVERY_CANCELED_BEFORE :
1239 : : case RecoveryDialog::E_RECOVERY_CANCELED_AFTERWARDS :
1240 : : {
1241 : : // We have to check if there exists some temp. files.
1242 : : // They should be saved to a user defined location.
1243 : : // If no temp files exists or user decided to ignore it ...
1244 : : // we have to remove all recovery/session data anyway!
1245 : 0 : short nRet = DLG_RET_UNKNOWN;
1246 [ # # ][ # # ]: 0 : BrokenRecoveryDialog* pBrokenRecoveryDialog = new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
1247 [ # # ][ # # ]: 0 : String sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); // get the default save location
1248 : :
1249 : : // dialog itself checks if there is a need to copy files for this mode.
1250 : : // It uses the information m_bWasRecoveryStarted doing so.
1251 [ # # ][ # # ]: 0 : if (pBrokenRecoveryDialog->isExecutionNeeded())
1252 : : {
1253 [ # # ]: 0 : nRet = pBrokenRecoveryDialog->Execute();
1254 [ # # ][ # # ]: 0 : sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
1255 : : }
1256 [ # # ][ # # ]: 0 : delete pBrokenRecoveryDialog;
1257 : :
1258 : : // Possible states:
1259 : : // a) nRet == DLG_RET_UNKNOWN
1260 : : // dialog was not shown ...
1261 : : // because there exists no temp file for copy.
1262 : : // => remove all recovery data
1263 : : // b) nRet == DLG_RET_OK
1264 : : // dialog was shown ...
1265 : : // user decided to save temp files
1266 : : // => save all OR broken temp files (depends from the time, where cancel was called)
1267 : : // => remove all recovery data
1268 : : // c) nRet == DLG_RET_CANCEL
1269 : : // dialog was shown ...
1270 : : // user decided to ignore temp files
1271 : : // => remove all recovery data
1272 : : // => a)/c) are the same ... b) has one additional operation
1273 : :
1274 : : // b)
1275 [ # # ]: 0 : if (nRet == DLG_RET_OK)
1276 : : {
1277 [ # # ]: 0 : if (m_bWasRecoveryStarted)
1278 [ # # ][ # # ]: 0 : m_pCore->saveBrokenTempEntries(sSaveDir);
1279 : : else
1280 [ # # ][ # # ]: 0 : m_pCore->saveAllTempEntries(sSaveDir);
1281 : : }
1282 : :
1283 : : // a,b,c)
1284 [ # # ]: 0 : if (m_bWasRecoveryStarted)
1285 [ # # ]: 0 : m_pCore->forgetBrokenRecoveryEntries();
1286 : : else
1287 [ # # ]: 0 : m_pCore->forgetAllRecoveryEntries();
1288 : 0 : m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
1289 : :
1290 : : // THERE IS NO WAY BACK. see impl_askUserForWizardCancel()!
1291 [ # # ]: 0 : return DLG_RET_CANCEL;
1292 : : }
1293 : :
1294 : : case RecoveryDialog::E_RECOVERY_HANDLED :
1295 : : {
1296 : 0 : m_bWaitForUser = sal_True;
1297 [ # # ]: 0 : while(m_bWaitForUser)
1298 [ # # ]: 0 : Application::Yield();
1299 : :
1300 : : // TODO: show BrokenRecoveryDialog again, ift he user
1301 : : // doesnt accepted it last time.
1302 : :
1303 [ # # ]: 0 : if (m_bUserDecideNext)
1304 : 0 : return DLG_RET_OK;
1305 : : else
1306 : 0 : return DLG_RET_CANCEL;
1307 : : }
1308 : : }
1309 : :
1310 : : // should never be reached .-)
1311 : : OSL_FAIL("Should never be reached!");
1312 [ # # ]: 0 : return DLG_RET_OK;
1313 : : }
1314 : :
1315 : : //===============================================
1316 : 0 : void RecoveryDialog::setDefButton()
1317 : : {
1318 [ # # ]: 0 : if ( m_aNextBtn.IsEnabled() )
1319 : 0 : m_aNextBtn.GrabFocus();
1320 : : else
1321 : 0 : m_pDefButton = &m_aNextBtn;
1322 : 0 : }
1323 : :
1324 : : //===============================================
1325 : 0 : void RecoveryDialog::start()
1326 : : {
1327 : 0 : }
1328 : :
1329 : : //===============================================
1330 : 0 : void RecoveryDialog::updateItems()
1331 : : {
1332 : 0 : sal_uIntPtr c = m_aFileListLB.GetEntryCount();
1333 : 0 : sal_uIntPtr i = 0;
1334 [ # # ]: 0 : for ( i=0; i<c; ++i )
1335 : : {
1336 [ # # ]: 0 : SvLBoxEntry* pEntry = m_aFileListLB.GetEntry(i);
1337 [ # # ]: 0 : if ( !pEntry )
1338 : 0 : continue;
1339 : :
1340 : 0 : TURLInfo* pInfo = (TURLInfo*)pEntry->GetUserData();
1341 [ # # ]: 0 : if ( !pInfo )
1342 : 0 : continue;
1343 : :
1344 [ # # ]: 0 : String sStatus = impl_getStatusString( *pInfo );
1345 [ # # ]: 0 : if ( sStatus.Len() > 0 )
1346 [ # # ]: 0 : m_aFileListLB.SetEntryText( sStatus, pEntry, 1 );
1347 [ # # ]: 0 : }
1348 : :
1349 : 0 : m_aFileListLB.Invalidate();
1350 : 0 : m_aFileListLB.Update();
1351 : 0 : }
1352 : :
1353 : : //===============================================
1354 : 0 : void RecoveryDialog::stepNext(TURLInfo* pItem)
1355 : : {
1356 : 0 : sal_uIntPtr c = m_aFileListLB.GetEntryCount();
1357 : 0 : sal_uIntPtr i = 0;
1358 [ # # ]: 0 : for (i=0; i<c; ++i)
1359 : : {
1360 : 0 : SvLBoxEntry* pEntry = m_aFileListLB.GetEntry(i);
1361 [ # # ]: 0 : if (!pEntry)
1362 : 0 : continue;
1363 : :
1364 : 0 : TURLInfo* pInfo = (TURLInfo*)pEntry->GetUserData();
1365 [ # # ]: 0 : if (pInfo->ID != pItem->ID)
1366 : 0 : continue;
1367 : :
1368 : 0 : m_aFileListLB.SetCursor(pEntry, sal_True);
1369 : 0 : m_aFileListLB.MakeVisible(pEntry);
1370 : 0 : m_aFileListLB.Invalidate();
1371 : 0 : m_aFileListLB.Update();
1372 : 0 : break;
1373 : : }
1374 : 0 : }
1375 : :
1376 : : //===============================================
1377 : 0 : void RecoveryDialog::end()
1378 : : {
1379 [ # # ]: 0 : if ( m_pDefButton )
1380 : : {
1381 : 0 : m_pDefButton->GrabFocus();
1382 : 0 : m_pDefButton = NULL;
1383 : : }
1384 : 0 : m_bWaitForCore = sal_False;
1385 : 0 : }
1386 : :
1387 : : //===============================================
1388 : 0 : IMPL_LINK_NOARG(RecoveryDialog, NextButtonHdl)
1389 : : {
1390 : 0 : m_bUserDecideNext = sal_True;
1391 : 0 : m_bWaitForUser = sal_False;
1392 : 0 : return 0;
1393 : : }
1394 : :
1395 : : //===============================================
1396 : 0 : IMPL_LINK_NOARG(RecoveryDialog, CancelButtonHdl)
1397 : : {
1398 [ # # ]: 0 : if (m_eRecoveryState == RecoveryDialog::E_RECOVERY_PREPARED)
1399 : : {
1400 [ # # ]: 0 : if (impl_askUserForWizardCancel(this, RID_SVXQB_EXIT_RECOVERY) == DLG_RET_CANCEL)
1401 : 0 : return 0;
1402 : : }
1403 : 0 : m_bUserDecideNext = sal_False;
1404 : 0 : m_bWaitForUser = sal_False;
1405 : 0 : return 0;
1406 : : }
1407 : :
1408 : : //===============================================
1409 : 0 : String RecoveryDialog::impl_getStatusString( const TURLInfo& rInfo ) const
1410 : : {
1411 : 0 : String sStatus;
1412 [ # # # # : 0 : switch ( rInfo.RecoveryState )
# # ]
1413 : : {
1414 : : case E_SUCCESSFULLY_RECOVERED :
1415 [ # # ]: 0 : sStatus = m_aFileListLB.m_aSuccessRecovStr;
1416 : 0 : break;
1417 : : case E_ORIGINAL_DOCUMENT_RECOVERED :
1418 [ # # ]: 0 : sStatus = m_aFileListLB.m_aOrigDocRecovStr;
1419 : 0 : break;
1420 : : case E_RECOVERY_FAILED :
1421 [ # # ]: 0 : sStatus = m_aFileListLB.m_aRecovFailedStr;
1422 : 0 : break;
1423 : : case E_RECOVERY_IS_IN_PROGRESS :
1424 [ # # ]: 0 : sStatus = m_aFileListLB.m_aRecovInProgrStr;
1425 : 0 : break;
1426 : : case E_NOT_RECOVERED_YET :
1427 [ # # ]: 0 : sStatus = m_aFileListLB.m_aNotRecovYetStr;
1428 : 0 : break;
1429 : : default:
1430 : 0 : break;
1431 : : }
1432 : 0 : return sStatus;
1433 : : }
1434 : :
1435 : : //===============================================
1436 : 0 : BrokenRecoveryDialog::BrokenRecoveryDialog(Window* pParent ,
1437 : : RecoveryCore* pCore ,
1438 : : sal_Bool bBeforeRecovery)
1439 : 0 : : ModalDialog ( pParent, SVX_RES( RID_SVX_MDLG_DOCRECOVERY_BROKEN ) )
1440 [ # # ]: 0 : , m_aDescrFT ( this , SVX_RES( FT_BROKEN_DESCR ) )
1441 [ # # ]: 0 : , m_aFileListFT ( this , SVX_RES( FT_BROKEN_FILELIST ) )
1442 [ # # ]: 0 : , m_aFileListLB ( this , SVX_RES( LB_BROKEN_FILELIST ) )
1443 [ # # ]: 0 : , m_aSaveDirFT ( this , SVX_RES( FT_BROKEN_SAVEDIR ) )
1444 [ # # ]: 0 : , m_aSaveDirED ( this , SVX_RES( ED_BROKEN_SAVEDIR ) )
1445 [ # # ]: 0 : , m_aSaveDirBtn ( this , SVX_RES( BTN_BROKEN_SAVEDIR ) )
1446 [ # # ]: 0 : , m_aBottomFL ( this , SVX_RES( FL_BROKEN_BOTTOM ) )
1447 [ # # ]: 0 : , m_aOkBtn ( this , SVX_RES( BTN_BROKEN_OK ) )
1448 [ # # ]: 0 : , m_aCancelBtn ( this , SVX_RES( BTN_BROKEN_CANCEL ) )
1449 : : , m_pCore ( pCore )
1450 : : , m_bBeforeRecovery (bBeforeRecovery)
1451 [ # # ][ # # ]: 0 : , m_bExecutionNeeded(sal_False)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1452 : : {
1453 [ # # ]: 0 : FreeResource();
1454 : :
1455 [ # # ]: 0 : m_aSaveDirBtn.SetClickHdl( LINK( this, BrokenRecoveryDialog, SaveButtonHdl ) );
1456 [ # # ]: 0 : m_aOkBtn.SetClickHdl( LINK( this, BrokenRecoveryDialog, OkButtonHdl ) );
1457 [ # # ]: 0 : m_aCancelBtn.SetClickHdl( LINK( this, BrokenRecoveryDialog, CancelButtonHdl ) );
1458 : :
1459 [ # # ][ # # ]: 0 : m_sSavePath = SvtPathOptions().GetWorkPath();
[ # # ][ # # ]
1460 [ # # ]: 0 : INetURLObject aObj( m_sSavePath );
1461 [ # # ]: 0 : String sPath;
1462 [ # # ][ # # ]: 0 : ::utl::LocalFileHelper::ConvertURLToSystemPath( aObj.GetMainURL( INetURLObject::NO_DECODE ), sPath );
[ # # ][ # # ]
1463 [ # # ]: 0 : m_aSaveDirED.SetText( sPath );
1464 : :
1465 [ # # ][ # # ]: 0 : impl_refresh();
[ # # ]
1466 : 0 : }
1467 : :
1468 : : //===============================================
1469 [ # # ][ # # ]: 0 : BrokenRecoveryDialog::~BrokenRecoveryDialog()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1470 : : {
1471 [ # # ]: 0 : }
1472 : :
1473 : : //===============================================
1474 : 0 : void BrokenRecoveryDialog::impl_refresh()
1475 : : {
1476 : 0 : m_bExecutionNeeded = sal_False;
1477 [ # # ]: 0 : TURLList* pURLList = m_pCore->getURLListAccess();
1478 : 0 : TURLList::const_iterator pIt;
1479 [ # # ][ # # ]: 0 : for ( pIt = pURLList->begin();
[ # # ]
1480 : 0 : pIt != pURLList->end() ;
1481 : : ++pIt )
1482 : : {
1483 : 0 : const TURLInfo& rInfo = *pIt;
1484 : :
1485 [ # # ]: 0 : if (m_bBeforeRecovery)
1486 : : {
1487 : : // "Cancel" before recovery ->
1488 : : // search for any temp files!
1489 [ # # ]: 0 : if (rInfo.TempURL.isEmpty())
1490 : 0 : continue;
1491 : : }
1492 : : else
1493 : : {
1494 : : // "Cancel" after recovery ->
1495 : : // search for broken temp files
1496 [ # # ]: 0 : if (!RecoveryCore::isBrokenTempEntry(rInfo))
1497 : 0 : continue;
1498 : : }
1499 : :
1500 : 0 : m_bExecutionNeeded = sal_True;
1501 : :
1502 [ # # ][ # # ]: 0 : sal_uInt16 nPos = m_aFileListLB.InsertEntry(rInfo.DisplayName, rInfo.StandardImage );
[ # # ]
1503 [ # # ]: 0 : m_aFileListLB.SetEntryData( nPos, (void*)&rInfo );
1504 : : }
1505 : 0 : m_sSavePath = ::rtl::OUString();
1506 [ # # ]: 0 : m_aOkBtn.GrabFocus();
1507 : 0 : }
1508 : :
1509 : : //===============================================
1510 : 0 : sal_Bool BrokenRecoveryDialog::isExecutionNeeded()
1511 : : {
1512 : 0 : return m_bExecutionNeeded;
1513 : : }
1514 : :
1515 : : //===============================================
1516 : 0 : ::rtl::OUString BrokenRecoveryDialog::getSaveDirURL()
1517 : : {
1518 : 0 : return m_sSavePath;
1519 : : }
1520 : :
1521 : : //===============================================
1522 : 0 : IMPL_LINK_NOARG(BrokenRecoveryDialog, OkButtonHdl)
1523 : : {
1524 [ # # ][ # # ]: 0 : String sPhysicalPath = comphelper::string::strip(m_aSaveDirED.GetText(), ' ');
[ # # ][ # # ]
[ # # ]
1525 : 0 : rtl::OUString sURL;
1526 [ # # ][ # # ]: 0 : ::utl::LocalFileHelper::ConvertPhysicalNameToURL( sPhysicalPath, sURL );
1527 : 0 : m_sSavePath = sURL;
1528 [ # # ]: 0 : while (m_sSavePath.isEmpty())
1529 [ # # ]: 0 : impl_askForSavePath();
1530 : :
1531 [ # # ]: 0 : EndDialog(DLG_RET_OK);
1532 [ # # ]: 0 : return 0;
1533 : : }
1534 : :
1535 : : //===============================================
1536 : 0 : IMPL_LINK_NOARG(BrokenRecoveryDialog, CancelButtonHdl)
1537 : : {
1538 : 0 : EndDialog(DLG_RET_CANCEL);
1539 : 0 : return 0;
1540 : : }
1541 : :
1542 : : //===============================================
1543 : 0 : IMPL_LINK_NOARG(BrokenRecoveryDialog, SaveButtonHdl)
1544 : : {
1545 : 0 : impl_askForSavePath();
1546 : 0 : return 0;
1547 : : }
1548 : :
1549 : : //===============================================
1550 : 0 : void BrokenRecoveryDialog::impl_askForSavePath()
1551 : : {
1552 : : css::uno::Reference< css::ui::dialogs::XFolderPicker > xFolderPicker(
1553 [ # # ][ # # ]: 0 : m_pCore->getSMGR()->createInstance(SERVICENAME_FOLDERPICKER), css::uno::UNO_QUERY_THROW);
[ # # ][ # # ]
[ # # ]
1554 : :
1555 [ # # ]: 0 : INetURLObject aURL(m_sSavePath, INET_PROT_FILE);
1556 [ # # ][ # # ]: 0 : xFolderPicker->setDisplayDirectory(aURL.GetMainURL(INetURLObject::NO_DECODE));
[ # # ]
1557 [ # # ][ # # ]: 0 : short nRet = xFolderPicker->execute();
1558 [ # # ]: 0 : if (nRet == css::ui::dialogs::ExecutableDialogResults::OK)
1559 : : {
1560 [ # # ][ # # ]: 0 : m_sSavePath = xFolderPicker->getDirectory();
1561 [ # # ]: 0 : String sPath;
1562 [ # # ][ # # ]: 0 : ::utl::LocalFileHelper::ConvertURLToSystemPath( m_sSavePath, sPath );
[ # # ]
1563 [ # # ][ # # ]: 0 : m_aSaveDirED.SetText( sPath );
1564 [ # # ]: 0 : }
1565 : 0 : }
1566 : :
1567 : : //===============================================
1568 : : ///////////////////////////////////////////////////////////////////////
1569 : : // Error Report Welcome Dialog
1570 : : ///////////////////////////////////////////////////////////////////////
1571 : :
1572 : 0 : ErrorRepWelcomeDialog::ErrorRepWelcomeDialog( Window* _pParent, sal_Bool _bAllowBack )
1573 : 0 : :IExtendedTabPage ( _pParent, SVX_RES( RID_SVXPAGE_ERR_REP_WELCOME ) )
1574 [ # # ]: 0 : ,maTitleWin ( this, SVX_RES( WIN_RECOV_TITLE ) )
1575 [ # # ]: 0 : ,maTitleFT ( this, SVX_RES( FT_RECOV_TITLE ) )
1576 [ # # ]: 0 : ,maTitleFL ( this, SVX_RES( FL_RECOV_TITLE ) )
1577 [ # # ]: 0 : ,maDescrFT ( this, SVX_RES( FT_RECOV_DESCR ) )
1578 [ # # ]: 0 : ,maBottomFL ( this, SVX_RES( FL_RECOV_BOTTOM ) )
1579 [ # # ]: 0 : ,maPrevBtn ( this, SVX_RES( BTN_RECOV_PREV ) )
1580 [ # # ]: 0 : ,maNextBtn ( this, SVX_RES( BTN_RECOV_NEXT ) )
1581 [ # # ][ # # ]: 0 : ,maCancelBtn ( this, SVX_RES( BTN_RECOV_CANCEL ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1582 : : {
1583 [ # # ]: 0 : FreeResource();
1584 : :
1585 [ # # ]: 0 : Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() );
1586 [ # # ]: 0 : maTitleWin.SetBackground( aBack );
1587 [ # # ]: 0 : maTitleFT.SetBackground( aBack );
1588 : :
1589 [ # # ]: 0 : Font aFnt( maTitleFT.GetFont() );
1590 [ # # ]: 0 : aFnt.SetWeight( WEIGHT_BOLD );
1591 [ # # ]: 0 : maTitleFT.SetFont( aFnt );
1592 : :
1593 [ # # ]: 0 : maPrevBtn.SetClickHdl( LINK( this, ErrorRepWelcomeDialog, PrevBtnHdl ) );
1594 [ # # ]: 0 : maPrevBtn.Enable( _bAllowBack );
1595 : :
1596 [ # # ]: 0 : maNextBtn.SetClickHdl( LINK( this, ErrorRepWelcomeDialog, NextBtnHdl ) );
1597 [ # # ]: 0 : maNextBtn.Enable( sal_True );
1598 : :
1599 [ # # ]: 0 : maCancelBtn.SetClickHdl( LINK( this, ErrorRepWelcomeDialog, CancelBtnHdl ) );
1600 [ # # ][ # # ]: 0 : maCancelBtn.Enable( sal_True );
[ # # ]
1601 : 0 : }
1602 : :
1603 [ # # ][ # # ]: 0 : ErrorRepWelcomeDialog::~ErrorRepWelcomeDialog()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1604 : : {
1605 [ # # ]: 0 : }
1606 : :
1607 : 0 : IMPL_LINK_NOARG(ErrorRepWelcomeDialog, PrevBtnHdl)
1608 : : {
1609 : 0 : m_nResult = DLG_RET_BACK;
1610 : 0 : return 0;
1611 : : }
1612 : :
1613 : 0 : IMPL_LINK_NOARG(ErrorRepWelcomeDialog, NextBtnHdl)
1614 : : {
1615 : 0 : m_nResult = DLG_RET_OK;
1616 : 0 : return 0;
1617 : : }
1618 : :
1619 : 0 : IMPL_LINK_NOARG(ErrorRepWelcomeDialog, CancelBtnHdl)
1620 : : {
1621 : 0 : m_nResult = DLG_RET_CANCEL;
1622 : 0 : return 0;
1623 : : }
1624 : :
1625 : 0 : short ErrorRepWelcomeDialog::execute()
1626 : : {
1627 [ # # ]: 0 : ::SolarMutexGuard aLock;
1628 [ # # ]: 0 : Show();
1629 : 0 : m_nResult = DLG_RET_UNKNOWN;
1630 [ # # ]: 0 : while(m_nResult == DLG_RET_UNKNOWN)
1631 [ # # ]: 0 : Application::Yield();
1632 [ # # ]: 0 : return m_nResult;
1633 : : }
1634 : :
1635 : 0 : void ErrorRepWelcomeDialog::setDefButton()
1636 : : {
1637 : 0 : maNextBtn.GrabFocus();
1638 : 0 : }
1639 : :
1640 : : ///////////////////////////////////////////////////////////////////////
1641 : : // Error Report Send Dialog and its MultiLineEdit
1642 : : ///////////////////////////////////////////////////////////////////////
1643 : :
1644 : 0 : ErrorDescriptionEdit::ErrorDescriptionEdit( Window* pParent, const ResId& rResId ) :
1645 : :
1646 : 0 : MultiLineEdit( pParent, rResId )
1647 : :
1648 : : {
1649 [ # # ]: 0 : SetModifyHdl( LINK( this, ErrorDescriptionEdit, ModifyHdl ) );
1650 [ # # ][ # # ]: 0 : if ( GetVScrollBar() )
1651 [ # # ][ # # ]: 0 : GetVScrollBar()->Hide();
1652 : 0 : }
1653 : :
1654 : 0 : ErrorDescriptionEdit::~ErrorDescriptionEdit()
1655 : : {
1656 [ # # ]: 0 : }
1657 : :
1658 : 0 : IMPL_LINK_NOARG(ErrorDescriptionEdit, ModifyHdl)
1659 : : {
1660 [ # # ][ # # ]: 0 : if ( !GetVScrollBar() )
1661 : 0 : return 0;
1662 : :
1663 [ # # ]: 0 : ExtTextEngine* pTextEngine = GetTextEngine();
1664 : : DBG_ASSERT( pTextEngine, "no text engine" );
1665 : :
1666 [ # # ]: 0 : sal_uIntPtr i, nParaCount = pTextEngine->GetParagraphCount();
1667 : 0 : sal_uInt16 nLineCount = 0;
1668 : :
1669 [ # # ]: 0 : for ( i = 0; i < nParaCount; ++i )
1670 [ # # ]: 0 : nLineCount = nLineCount + pTextEngine->GetLineCount(i);
1671 : :
1672 : 0 : sal_uInt16 nVisCols = 0, nVisLines = 0;
1673 [ # # ]: 0 : GetMaxVisColumnsAndLines( nVisCols, nVisLines );
1674 [ # # ][ # # ]: 0 : GetVScrollBar()->Show( nLineCount > nVisLines );
1675 : :
1676 : 0 : return 0;
1677 : : }
1678 : :
1679 : 0 : ErrorRepSendDialog::ErrorRepSendDialog( Window* _pParent )
1680 : 0 : :IExtendedTabPage ( _pParent, SVX_RES( RID_SVXPAGE_ERR_REP_SEND ) )
1681 [ # # ]: 0 : ,maTitleWin ( this, SVX_RES( WIN_RECOV_TITLE ) )
1682 [ # # ]: 0 : ,maTitleFT ( this, SVX_RES( FT_RECOV_TITLE ) )
1683 [ # # ]: 0 : ,maTitleFL ( this, SVX_RES( FL_RECOV_TITLE ) )
1684 [ # # ]: 0 : ,maDescrFT ( this, SVX_RES( FT_RECOV_DESCR ) )
1685 : :
1686 [ # # ]: 0 : ,maDocTypeFT ( this, SVX_RES( FT_ERRSEND_DOCTYPE ) )
1687 [ # # ]: 0 : ,maDocTypeED ( this, SVX_RES( ED_ERRSEND_DOCTYPE ) )
1688 [ # # ]: 0 : ,maUsingFT ( this, SVX_RES( FT_ERRSEND_USING ) )
1689 [ # # ]: 0 : ,maUsingML ( this, SVX_RES( ML_ERRSEND_USING ) )
1690 [ # # ]: 0 : ,maShowRepBtn ( this, SVX_RES( BTN_ERRSEND_SHOWREP ) )
1691 [ # # ]: 0 : ,maOptBtn ( this, SVX_RES( BTN_ERRSEND_OPT ) )
1692 [ # # ]: 0 : ,maContactCB ( this, SVX_RES( CB_ERRSEND_CONTACT ) )
1693 [ # # ]: 0 : ,maEMailAddrFT ( this, SVX_RES( FT_ERRSEND_EMAILADDR ) )
1694 [ # # ]: 0 : ,maEMailAddrED ( this, SVX_RES( ED_ERRSEND_EMAILADDR ) )
1695 : :
1696 [ # # ]: 0 : ,maBottomFL ( this, SVX_RES( FL_RECOV_BOTTOM ) )
1697 [ # # ]: 0 : ,maPrevBtn ( this, SVX_RES( BTN_RECOV_PREV ) )
1698 [ # # ]: 0 : ,maNextBtn ( this, SVX_RES( BTN_RECOV_NEXT ) )
1699 [ # # ][ # # ]: 0 : ,maCancelBtn ( this, SVX_RES( BTN_RECOV_CANCEL ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1700 : : {
1701 [ # # ]: 0 : FreeResource();
1702 : :
1703 [ # # ]: 0 : initControls();
1704 : :
1705 [ # # ]: 0 : Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() );
1706 [ # # ]: 0 : maTitleWin.SetBackground( aBack );
1707 [ # # ]: 0 : maTitleFT.SetBackground( aBack );
1708 : :
1709 [ # # ]: 0 : Font aFnt( maTitleFT.GetFont() );
1710 [ # # ]: 0 : aFnt.SetWeight( WEIGHT_BOLD );
1711 [ # # ]: 0 : maTitleFT.SetFont( aFnt );
1712 : :
1713 [ # # ]: 0 : maShowRepBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, ShowRepBtnHdl ) );
1714 [ # # ]: 0 : maOptBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, OptBtnHdl ) );
1715 [ # # ]: 0 : maContactCB.SetClickHdl( LINK( this, ErrorRepSendDialog, ContactCBHdl ) );
1716 [ # # ]: 0 : maPrevBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, PrevBtnHdl ) );
1717 [ # # ]: 0 : maNextBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, SendBtnHdl ) );
1718 [ # # ]: 0 : maCancelBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, CancelBtnHdl ) );
1719 : :
1720 [ # # ]: 0 : ReadParams();
1721 : :
1722 [ # # ][ # # ]: 0 : ContactCBHdl( 0 );
[ # # ]
1723 : 0 : }
1724 : :
1725 [ # # ][ # # ]: 0 : ErrorRepSendDialog::~ErrorRepSendDialog()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1726 : : {
1727 [ # # ]: 0 : }
1728 : :
1729 : 0 : short ErrorRepSendDialog::execute()
1730 : : {
1731 [ # # ]: 0 : ::SolarMutexGuard aLock;
1732 [ # # ]: 0 : Show();
1733 : 0 : m_nResult = DLG_RET_UNKNOWN;
1734 [ # # ]: 0 : while(m_nResult == DLG_RET_UNKNOWN)
1735 [ # # ]: 0 : Application::Yield();
1736 [ # # ]: 0 : return m_nResult;
1737 : : }
1738 : :
1739 : 0 : void ErrorRepSendDialog::setDefButton()
1740 : : {
1741 : : // set first focus
1742 : 0 : maDocTypeED.GrabFocus();
1743 : 0 : }
1744 : :
1745 : 0 : IMPL_LINK_NOARG(ErrorRepSendDialog, PrevBtnHdl)
1746 : : {
1747 : 0 : m_nResult = DLG_RET_BACK;
1748 : 0 : return 0;
1749 : : }
1750 : :
1751 : 0 : IMPL_LINK_NOARG(ErrorRepSendDialog, CancelBtnHdl)
1752 : : {
1753 : 0 : m_nResult = DLG_RET_CANCEL;
1754 : 0 : return 0;
1755 : : }
1756 : :
1757 : 0 : IMPL_LINK_NOARG(ErrorRepSendDialog, SendBtnHdl)
1758 : : {
1759 : :
1760 : 0 : SaveParams();
1761 : 0 : SendReport();
1762 : :
1763 : 0 : m_nResult = DLG_RET_OK;
1764 : 0 : return 0;
1765 : : }
1766 : :
1767 : 0 : IMPL_LINK_NOARG(ErrorRepSendDialog, ShowRepBtnHdl)
1768 : : {
1769 [ # # ]: 0 : ErrorRepPreviewDialog aDlg( this );
1770 [ # # ]: 0 : aDlg.Execute();
1771 [ # # ]: 0 : return 0;
1772 : : }
1773 : :
1774 : 0 : IMPL_LINK_NOARG(ErrorRepSendDialog, OptBtnHdl)
1775 : : {
1776 [ # # ]: 0 : ErrorRepOptionsDialog aDlg( this, maParams );
1777 [ # # ]: 0 : aDlg.Execute();
1778 [ # # ]: 0 : return 0;
1779 : : }
1780 : :
1781 : 0 : IMPL_LINK_NOARG(ErrorRepSendDialog, ContactCBHdl)
1782 : : {
1783 : 0 : bool bCheck = maContactCB.IsChecked();
1784 : 0 : maEMailAddrFT.Enable( bCheck );
1785 : 0 : maEMailAddrED.Enable( bCheck );
1786 : 0 : return 0;
1787 : : }
1788 : :
1789 : 0 : void ErrorRepSendDialog::initControls()
1790 : : {
1791 : : // if the text is too short for two lines, insert a newline
1792 [ # # ]: 0 : String sText = maDocTypeFT.GetText();
1793 [ # # ][ # # ]: 0 : if ( maDocTypeFT.GetCtrlTextWidth( sText ) <= maDocTypeFT.GetSizePixel().Width() )
[ # # ]
1794 : : {
1795 [ # # ]: 0 : sText.Insert( '\n', 0 );
1796 [ # # ]: 0 : maDocTypeFT.SetText( sText );
1797 : : }
1798 : :
1799 : : // if the button text is too wide, then broaden the button
1800 [ # # ][ # # ]: 0 : sText = maShowRepBtn.GetText();
[ # # ]
1801 [ # # ]: 0 : long nTxtW = maShowRepBtn.GetCtrlTextWidth( sText );
1802 [ # # ]: 0 : long nBtnW = maShowRepBtn.GetSizePixel().Width();
1803 [ # # ]: 0 : if ( nTxtW >= nBtnW )
1804 : : {
1805 : 0 : const long nMinDelta = 10;
1806 : 0 : long nDelta = Max( nTxtW - nBtnW, nMinDelta );
1807 : 0 : sal_uInt32 i = 0;
1808 : : Window* pWins[] =
1809 : : {
1810 : : &maShowRepBtn, &maOptBtn,
1811 : : &maDescrFT, &maDocTypeFT, &maDocTypeED, &maUsingFT,
1812 : : &maUsingML, &maContactCB, &maEMailAddrFT, &maEMailAddrED
1813 : 0 : };
1814 : : // the first two buttons need a new size (wider) and position (more left)
1815 : 0 : Window** pCurrent = pWins;
1816 : 0 : const sal_uInt32 nBtnCount = 2;
1817 [ # # ]: 0 : for ( ; i < nBtnCount; ++i, ++pCurrent )
1818 : : {
1819 [ # # ]: 0 : Size aNewSize = (*pCurrent)->GetSizePixel();
1820 : 0 : aNewSize.Width() += nDelta;
1821 [ # # ]: 0 : (*pCurrent)->SetSizePixel( aNewSize );
1822 [ # # ]: 0 : Point aNewPos = (*pCurrent)->GetPosPixel();
1823 : 0 : aNewPos.X() -= nDelta;
1824 [ # # ]: 0 : (*pCurrent)->SetPosPixel( aNewPos );
1825 : : }
1826 : :
1827 : : // loop through all the other windows and adjust their size
1828 [ # # ]: 0 : for ( ; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent )
1829 : : {
1830 [ # # ]: 0 : Size aSize = (*pCurrent)->GetSizePixel();
1831 : 0 : aSize.Width() -= nDelta;
1832 [ # # ]: 0 : (*pCurrent)->SetSizePixel( aSize );
1833 : : }
1834 [ # # ]: 0 : }
1835 : 0 : }
1836 : :
1837 : 0 : String ErrorRepSendDialog::GetDocType( void ) const
1838 : : {
1839 : 0 : return maDocTypeED.GetText();
1840 : : }
1841 : :
1842 : 0 : String ErrorRepSendDialog::GetUsing( void ) const
1843 : : {
1844 : 0 : return maUsingML.GetText();
1845 : : }
1846 : :
1847 : 0 : bool ErrorRepSendDialog::IsContactAllowed( void ) const
1848 : : {
1849 : 0 : return maContactCB.IsChecked();
1850 : : }
1851 : :
1852 : 0 : String ErrorRepSendDialog::GetEMailAddress( void ) const
1853 : : {
1854 : 0 : return maEMailAddrED.GetText();
1855 : : }
1856 : :
1857 : :
1858 : : ///////////////////////////////////////////////////////////////////////
1859 : : // Error Report Options Dialog
1860 : : ///////////////////////////////////////////////////////////////////////
1861 : :
1862 : 0 : ErrorRepOptionsDialog::ErrorRepOptionsDialog( Window* _pParent, ErrorRepParams& _rParams )
1863 : 0 : :ModalDialog ( _pParent, SVX_RES( RID_SVX_MDLG_ERR_REP_OPTIONS ) )
1864 [ # # ]: 0 : ,maProxyFL( this, SVX_RES( FL_ERROPT_PROXY ) )
1865 [ # # ]: 0 : ,maSystemBtn( this, SVX_RES( BTN_ERROPT_SYSTEM ) )
1866 [ # # ]: 0 : ,maDirectBtn( this, SVX_RES( BTN_ERROPT_DIRECT ) )
1867 [ # # ]: 0 : ,maManualBtn( this, SVX_RES( BTN_ERROPT_MANUAL ) )
1868 [ # # ]: 0 : ,maProxyServerFT( this, SVX_RES( FT_ERROPT_PROXYSERVER ) )
1869 [ # # ]: 0 : ,maProxyServerEd( this, SVX_RES( ED_ERROPT_PROXYSERVER ) )
1870 [ # # ]: 0 : ,maProxyPortFT( this, SVX_RES( FT_ERROPT_PROXYPORT ) )
1871 [ # # ]: 0 : ,maProxyPortEd( this, SVX_RES( ED_ERROPT_PROXYPORT ) )
1872 [ # # ]: 0 : ,maDescriptionFT( this, SVX_RES( FT_ERROPT_DESCRIPTION ) )
1873 [ # # ]: 0 : ,maButtonsFL( this, SVX_RES( FL_ERROPT_BUTTONS ) )
1874 [ # # ]: 0 : ,maOKBtn( this, SVX_RES( BTN_ERROPT_OK ) )
1875 [ # # ]: 0 : ,maCancelBtn( this, SVX_RES( BTN_ERROPT_CANCEL ) )
1876 [ # # ][ # # ]: 0 : ,mrParams( _rParams )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1877 : : {
1878 [ # # ]: 0 : FreeResource();
1879 : :
1880 [ # # ]: 0 : maManualBtn.SetToggleHdl( LINK( this, ErrorRepOptionsDialog, ManualBtnHdl ) );
1881 [ # # ]: 0 : maCancelBtn.SetClickHdl( LINK( this, ErrorRepOptionsDialog, CancelBtnHdl ) );
1882 [ # # ]: 0 : maOKBtn.SetClickHdl( LINK( this, ErrorRepOptionsDialog, OKBtnHdl ) );
1883 : :
1884 [ # # ]: 0 : maProxyServerEd.SetText( mrParams.maHTTPProxyServer );
1885 [ # # ]: 0 : maProxyPortEd.SetText( mrParams.maHTTPProxyPort );
1886 : :
1887 : : #ifndef WNT
1888 : : // no "Use system settings" button on non windows systems
1889 : : // so hide this button
1890 [ # # ]: 0 : maSystemBtn.Hide();
1891 [ # # ][ # # ]: 0 : long nDelta = maDirectBtn.GetPosPixel().Y() - maSystemBtn.GetPosPixel().Y();
1892 : : // and loop through all these controls and adjust their position
1893 : : Window* pWins[] =
1894 : : {
1895 : : &maDirectBtn, &maManualBtn, &maProxyServerFT,
1896 : : &maProxyServerEd, &maProxyPortFT, &maProxyPortEd, &maDescriptionFT
1897 : 0 : };
1898 : 0 : Window** pCurrent = pWins;
1899 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < sizeof( pWins ) / sizeof( pWins[ 0 ] ); ++i, ++pCurrent )
1900 : : {
1901 [ # # ]: 0 : Point aPos = (*pCurrent)->GetPosPixel();
1902 : 0 : aPos.Y() -= nDelta;
1903 [ # # ]: 0 : (*pCurrent)->SetPosPixel( aPos );
1904 : : }
1905 : : #endif
1906 : :
1907 : :
1908 [ # # ]: 0 : switch ( mrParams.miHTTPConnectionType )
1909 : : {
1910 : : default:
1911 : : #ifdef WNT
1912 : : case 0:
1913 : : maSystemBtn.Check( sal_True );
1914 : : break;
1915 : : #endif
1916 : : case 1:
1917 [ # # ]: 0 : maDirectBtn.Check( sal_True );
1918 : 0 : break;
1919 : : case 2:
1920 [ # # ]: 0 : maManualBtn.Check( sal_True );
1921 : 0 : break;
1922 : : }
1923 : :
1924 [ # # ]: 0 : ManualBtnHdl( 0 );
1925 : 0 : }
1926 : :
1927 [ # # ][ # # ]: 0 : ErrorRepOptionsDialog::~ErrorRepOptionsDialog()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1928 : : {
1929 [ # # ]: 0 : }
1930 : :
1931 : 0 : IMPL_LINK_NOARG(ErrorRepOptionsDialog, ManualBtnHdl)
1932 : : {
1933 : 0 : bool bCheck = maManualBtn.IsChecked();
1934 : 0 : maProxyServerFT.Enable( bCheck );
1935 : 0 : maProxyServerEd.Enable( bCheck );
1936 : 0 : maProxyPortFT.Enable( bCheck );
1937 : 0 : maProxyPortEd.Enable( bCheck );
1938 : 0 : return 0;
1939 : : }
1940 : :
1941 : 0 : IMPL_LINK_NOARG(ErrorRepOptionsDialog, OKBtnHdl)
1942 : : {
1943 [ # # ]: 0 : if ( maManualBtn.IsChecked() )
1944 : 0 : mrParams.miHTTPConnectionType = 2;
1945 [ # # ]: 0 : else if ( maDirectBtn.IsChecked() )
1946 : 0 : mrParams.miHTTPConnectionType = 1;
1947 [ # # ]: 0 : else if ( maSystemBtn.IsChecked() )
1948 : 0 : mrParams.miHTTPConnectionType = 0;
1949 : :
1950 [ # # ]: 0 : mrParams.maHTTPProxyServer = maProxyServerEd.GetText();
1951 [ # # ]: 0 : mrParams.maHTTPProxyPort = maProxyPortEd.GetText();
1952 : :
1953 : 0 : EndDialog(DLG_RET_OK);
1954 : 0 : return 0;
1955 : : }
1956 : :
1957 : 0 : IMPL_LINK_NOARG(ErrorRepOptionsDialog, CancelBtnHdl)
1958 : : {
1959 : 0 : EndDialog(DLG_RET_CANCEL);
1960 : 0 : return 0;
1961 : : }
1962 : :
1963 : : ///////////////////////////////////////////////////////////////////////
1964 : : // Error Report Edit (MultiLineEdit with fixed font)
1965 : : ///////////////////////////////////////////////////////////////////////
1966 : :
1967 : 0 : ErrorRepEdit::ErrorRepEdit( Window* pParent, const ResId& rResId ) :
1968 : 0 : ExtMultiLineEdit( pParent, rResId )
1969 : : {
1970 : : // fixed font for error report
1971 : 0 : Color aColor = GetTextColor();
1972 : :
1973 : : Font aFont = OutputDevice::GetDefaultFont(
1974 [ # # ]: 0 : DEFAULTFONT_FIXED, LANGUAGE_SYSTEM, DEFAULTFONT_FLAGS_ONLYONE );
1975 : :
1976 : : // Set font color because the default font color is transparent !!!
1977 [ # # ]: 0 : aFont.SetColor( aColor );
1978 : :
1979 [ # # ][ # # ]: 0 : GetTextEngine()->SetFont( aFont );
1980 : :
1981 : : // no blinking cursor and a little left margin
1982 [ # # ]: 0 : EnableCursor( sal_False );
1983 [ # # ][ # # ]: 0 : SetLeftMargin( 4 );
1984 : 0 : }
1985 : :
1986 : 0 : ErrorRepEdit::~ErrorRepEdit()
1987 : : {
1988 [ # # ]: 0 : }
1989 : :
1990 : : ///////////////////////////////////////////////////////////////////////
1991 : : // Error Report Preview Dialog
1992 : : ///////////////////////////////////////////////////////////////////////
1993 : :
1994 : :
1995 : 0 : static ::rtl::OUString GetCrashConfigDir()
1996 : : {
1997 : :
1998 : : #if defined(WNT)
1999 : : OUString ustrValue = OUString("${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}");
2000 : : #elif defined( MACOSX )
2001 : : OUString ustrValue = OUString("~");
2002 : : #else
2003 : 0 : OUString ustrValue = OUString("$SYSUSERCONFIG");
2004 : : #endif
2005 : 0 : Bootstrap::expandMacros( ustrValue );
2006 : :
2007 : : #if defined(WNT)
2008 : : ustrValue += OUString("/user/crashdata");
2009 : : #endif
2010 : 0 : return ustrValue;
2011 : : }
2012 : :
2013 : : #if defined(WNT)
2014 : : #define PRVFILE "crashdat.prv"
2015 : : #else
2016 : : #define PRVFILE ".crash_report_preview"
2017 : : #endif
2018 : :
2019 : 0 : static ::rtl::OUString GetPreviewURL()
2020 : : {
2021 : 0 : ::rtl::OUString aURL = GetCrashConfigDir();
2022 : :
2023 : 0 : aURL += ::rtl::OUString( "/" );
2024 : 0 : aURL += ::rtl::OUString( PRVFILE );
2025 : :
2026 : 0 : return aURL;
2027 : : }
2028 : :
2029 : 0 : static String LoadCrashFile( const ::rtl::OUString &rURL )
2030 : : {
2031 [ # # ]: 0 : String aFileContent;
2032 : 0 : ::osl::File aFile( rURL );
2033 : :
2034 [ # # ][ # # ]: 0 : printf( "Loading %s:", OString( rURL.getStr(), rURL.getLength(), osl_getThreadTextEncoding() ).getStr() );
[ # # ]
2035 [ # # ][ # # ]: 0 : if ( ::osl::FileBase::E_None == aFile.open( osl_File_OpenFlag_Read ) )
2036 : : {
2037 : 0 : ::rtl::OString aContent;
2038 : : ::osl::FileBase::RC result;
2039 : : sal_uInt64 aBytesRead;
2040 : :
2041 [ # # ][ # # ]: 0 : do
[ # # ]
2042 : : {
2043 : : sal_Char aBuffer[256];
2044 : :
2045 [ # # ]: 0 : result = aFile.read( aBuffer, sizeof(aBuffer), aBytesRead );
2046 : :
2047 [ # # ]: 0 : if ( ::osl::FileBase::E_None == result )
2048 : : {
2049 : 0 : ::rtl::OString aTemp( aBuffer, static_cast< xub_StrLen >( aBytesRead ) );
2050 : 0 : aContent += aTemp;
2051 : : }
2052 : : } while ( ::osl::FileBase::E_None == result && aBytesRead );
2053 : :
2054 [ # # ]: 0 : ::rtl::OUString ustrContent( aContent.getStr(), aContent.getLength(), RTL_TEXTENCODING_UTF8 );
2055 [ # # ]: 0 : aFileContent = ustrContent;
2056 : :
2057 [ # # ]: 0 : aFile.close();
2058 : :
2059 [ # # ]: 0 : printf( "SUCCEEDED\n" );
2060 : : }
2061 : : else
2062 [ # # ]: 0 : printf( "FAILED\n" );
2063 : :
2064 [ # # ]: 0 : return aFileContent;
2065 : : }
2066 : :
2067 : :
2068 : :
2069 : 0 : ErrorRepPreviewDialog::ErrorRepPreviewDialog( Window* _pParent )
2070 : 0 : :ModalDialog ( _pParent, SVX_RES( RID_SVX_MDLG_ERR_REP_PREVIEW ) )
2071 [ # # ]: 0 : ,maContentML( this, SVX_RES( ML_ERRPREVIEW_CONTENT ) )
2072 [ # # ][ # # ]: 0 : ,maOKBtn( this, SVX_RES( BTN_ERRPREVIEW_OK ) )
[ # # ][ # # ]
2073 : :
2074 : : {
2075 [ # # ]: 0 : FreeResource();
2076 : :
2077 [ # # ]: 0 : mnMinHeight = ( maContentML.GetSizePixel().Height() / 2 );
2078 : :
2079 [ # # ][ # # ]: 0 : String aPreview = LoadCrashFile( GetPreviewURL() );
2080 : 0 : ErrorRepSendDialog *pMainDlg = (ErrorRepSendDialog *)_pParent;
2081 : :
2082 [ # # ]: 0 : String aSeperator = ::rtl::OUString( "\r\n\r\n================\r\n\r\n" );
2083 : :
2084 [ # # ]: 0 : String aContent = pMainDlg->GetDocType();
2085 [ # # ]: 0 : if ( aContent.Len() > 0 )
2086 [ # # ]: 0 : aContent += aSeperator;
2087 [ # # ][ # # ]: 0 : aContent += pMainDlg->GetUsing();
[ # # ]
2088 [ # # ]: 0 : if ( aContent.Len() > 0 )
2089 [ # # ]: 0 : aContent += aSeperator;
2090 [ # # ]: 0 : aContent += aPreview;
2091 : :
2092 [ # # ][ # # ]: 0 : maContentML.SetText( aContent );
[ # # ][ # # ]
2093 : 0 : }
2094 : :
2095 [ # # ][ # # ]: 0 : ErrorRepPreviewDialog::~ErrorRepPreviewDialog()
2096 : : {
2097 [ # # ]: 0 : }
2098 : :
2099 : 0 : void ErrorRepPreviewDialog::Resize()
2100 : : {
2101 [ # # ][ # # ]: 0 : Size a3Sz = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
[ # # ]
2102 [ # # ]: 0 : Size aWinSz = GetSizePixel();
2103 [ # # ]: 0 : Size aBtnSz = maOKBtn.GetSizePixel();
2104 [ # # ]: 0 : Point aEditPnt = maContentML.GetPosPixel();
2105 : :
2106 : 0 : long nNewHeight = Max( aWinSz.Height() - aEditPnt.Y() - 3 * a3Sz.Height() - aBtnSz.Height(), mnMinHeight );
2107 : 0 : long nNewWidth = aWinSz.Width() - 4 * a3Sz.Width();
2108 : :
2109 : 0 : Size aNewSize( nNewWidth, nNewHeight );
2110 [ # # ]: 0 : maContentML.SetSizePixel( aNewSize );
2111 : 0 : Point aNewPoint( Max( aEditPnt.X() + aNewSize.Width() - aBtnSz.Width(), aEditPnt.X() ),
2112 : 0 : aEditPnt.Y() + aNewSize.Height() + a3Sz.Height() );
2113 [ # # ]: 0 : maOKBtn.SetPosPixel( aNewPoint );
2114 : 0 : }
2115 : : } // namespace DocRecovery
2116 : : } // namespace svx
2117 : :
2118 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|