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