21#include <svx/strings.hrc>
22#include <bitmaps.hlst>
36#include <com/sun/star/util/URL.hpp>
37#include <com/sun/star/util/XURLTransformer.hpp>
38#include <com/sun/star/frame/theAutoRecovery.hpp>
39#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
40#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
41#include <com/sun/star/util/URLTransformer.hpp>
42#include <osl/file.hxx>
50#define COLUMN_STANDARDIMAGE -1
51#define COLUMN_DISPLAYNAME 0
52#define COLUMN_STATUSIMAGE 1
53#define COLUMN_STATUSTEXT 2
58 , m_pListener ( nullptr )
59 , m_bListenForSaving(bUsedForSaving)
110 css::uno::Sequence< css::beans::PropertyValue > lCopyArgs(3);
111 auto plCopyArgs = lCopyArgs.getArray();
113 plCopyArgs[0].Value <<=
false;
115 plCopyArgs[1].Value <<= rPath;
129 plCopyArgs[2].Value <<= rInfo.ID;
145 css::uno::Sequence< css::beans::PropertyValue > lCopyArgs(3);
146 auto plCopyArgs = lCopyArgs.getArray();
148 plCopyArgs[0].Value <<=
false;
150 plCopyArgs[1].Value <<= rPath;
161 if (rInfo.TempURL.isEmpty())
164 plCopyArgs[2].Value <<= rInfo.ID;
176 css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
177 auto plRemoveArgs = lRemoveArgs.getArray();
179 plRemoveArgs[0].Value <<=
false;
193 plRemoveArgs[1].Value <<= rInfo.ID;
205 css::uno::Sequence<css::beans::PropertyValue> lRemoveArgs(2);
206 auto plRemoveArgs = lRemoveArgs.getArray();
208 plRemoveArgs[0].Value <<=
false;
218 if (!rInfo.ShouldDiscard)
221 plRemoveArgs[1].Value <<= rInfo.ID;
232 css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
233 auto plRemoveArgs = lRemoveArgs.getArray();
235 plRemoveArgs[0].Value <<=
false;
246 plRemoveArgs[1].Value <<= rInfo.ID;
258 css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
259 auto plRemoveArgs = lRemoveArgs.getArray();
261 plRemoveArgs[0].Value <<=
false;
275 plRemoveArgs[1].Value <<= rInfo.ID;
314 css::uno::Sequence< css::beans::PropertyValue > lArgs{
332 css::uno::Sequence< css::beans::PropertyValue > lArgs{
407 if (aNew.
OrgURL.isEmpty()) {
423 if (aOld.ID == aNew.
ID)
439 OUString sURL = aNew.
OrgURL;
480 css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(
m_xContext));
481 xParser->parseStrict(
aURL);
485 m_xRealCore->addStatusListener(
static_cast< css::frame::XStatusListener*
>(
this),
aURL);
500 css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(
m_xContext));
501 xParser->parseStrict(
aURL);
503 m_xRealCore->removeStatusListener(
static_cast< css::frame::XStatusListener*
>(
this),
aURL);
511 aURL.Complete = sURL;
513 css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(
m_xContext));
514 xParser->parseStrict(
aURL);
520 : m_pProgressBar(pProgressBar)
574 : GenericDialogController(pParent,
"svx/ui/docrecoverysavedialog.ui",
"DocRecoverySaveDialog")
576 , m_xFileListLB(m_xBuilder->weld_tree_view(
"filelist"))
577 , m_xOkBtn(m_xBuilder->weld_button(
"ok"))
594 m_xFileListLB->append(
"", rInfo.DisplayName, rInfo.StandardImageId);
606 short nResult = xProgress->run();
618 : GenericDialogController(pParent,
"svx/ui/docrecoveryprogressdialog.ui",
"DocRecoveryProgressDialog")
620 , m_xProgressBar(m_xBuilder->weld_progress_bar(
"progress"))
628 css::uno::Reference<css::lang::XComponent> xComp(
m_xProgress, css::uno::UNO_QUERY);
640 short nRet = DialogController::run();
667 VclMessageType::Question, VclButtonsType::YesNo,
SvxResId(pRes)));
675 : GenericDialogController(pParent,
"svx/ui/docrecoveryrecoverdialog.ui",
"DocRecoveryRecoverDialog")
676 , m_aTitleRecoveryInProgress(
SvxResId(RID_SVXSTR_RECOVERY_INPROGRESS))
677 , m_aRecoveryOnlyFinish (
SvxResId(RID_SVXSTR_RECOVERYONLY_FINISH))
678 , m_aRecoveryOnlyFinishDescr(
SvxResId(RID_SVXSTR_RECOVERYONLY_FINISH_DESCR))
681 , m_bWaitForCore(false)
682 , m_bWasRecoveryStarted(false)
685 , m_aSuccessRecovStr(
SvxResId(RID_SVXSTR_SUCCESSRECOV))
686 , m_aOrigDocRecovStr(
SvxResId(RID_SVXSTR_ORIGDOCRECOV))
687 , m_aRecovFailedStr(
SvxResId(RID_SVXSTR_RECOVFAILED))
688 , m_aRecovInProgrStr(
SvxResId(RID_SVXSTR_RECOVINPROGR))
689 , m_aNotRecovYetStr(
SvxResId(RID_SVXSTR_NOTRECOVYET))
690 , m_aWillBeDiscStr(
SvxResId(RID_SVXSTR_WILLDISCARD))
691 , m_xDescrFT(m_xBuilder->weld_label(
"desc"))
692 , m_xProgressBar(m_xBuilder->weld_progress_bar(
"progress"))
693 , m_xFileListLB(m_xBuilder->weld_tree_view(
"filelist"))
694 , m_xNextBtn(m_xBuilder->weld_button(
"next"))
695 , m_xCancelBtn(m_xBuilder->weld_button(
"cancel"))
697 const auto nWidth =
m_xFileListLB->get_approximate_digit_width() * 80;
702 std::vector<int> aWidths;
703 aWidths.push_back(60 * nWidth / 100);
704 aWidths.push_back(5 * nWidth / 100);
735 css::uno::Reference<css::lang::XComponent> xComp(
m_xProgress, css::uno::UNO_QUERY);
791 nRet = aBrokenRecoveryDialog.
run();
862 nRet = aBrokenRecoveryDialog.
run();
904 OSL_FAIL(
"Should never be reached!");
911 for (
int i = 0;
i < c; ++
i)
919 if (!sStatus.isEmpty())
927 for (
int i=0;
i < c; ++
i)
930 if (pInfo->
ID != pItem->
ID)
946 switch (m_eRecoveryState)
966 switch (m_eRecoveryState)
989 int aIndex = m_xFileListLB->get_selected_index();
992 if (m_bWasRecoveryStarted)
1009 m_xFileListLB->set_toggle(
aIndex, eState);
1013 impl_updateItemDescription(
aIndex, eState);
1029 m_xNextBtn->set_sensitive(m_aToggleCount != 0);
1068 sStatus = RID_SVXBMP_GREENCHECK;
1071 sStatus = RID_SVXBMP_YELLOWCHECK;
1074 sStatus = RID_SVXBMP_REDCROSS;
1105 if (!sStatus.isEmpty())
1111 bool bBeforeRecovery)
1112 : GenericDialogController(pParent,
"svx/ui/docrecoverybrokendialog.ui",
"DocRecoveryBrokenDialog")
1114 , m_bBeforeRecovery(bBeforeRecovery)
1115 , m_bExecutionNeeded(false)
1116 , m_xFileListLB(m_xBuilder->weld_tree_view(
"filelist"))
1117 , m_xSaveDirED(m_xBuilder->weld_entry(
"savedir"))
1118 , m_xSaveDirBtn(m_xBuilder->weld_button(
"change"))
1119 , m_xOkBtn(m_xBuilder->weld_button(
"ok"))
1120 , m_xCancelBtn(m_xBuilder->weld_button(
"cancel"))
1143 for (
const TURLInfo& rInfo : rURLList)
1149 if (rInfo.TempURL.isEmpty())
1182 osl::FileBase::getFileURLFromSystemPath( sPhysicalPath, sURL );
1184 while (m_sSavePath.isEmpty())
1185 impl_askForSavePath();
1197 impl_askForSavePath();
1202 css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker =
1207 short nRet = xFolderPicker->execute();
1208 if (nRet == css::ui::dialogs::ExecutableDialogResults::OK)
1212 osl::FileBase::getSystemPathFromFileURL(
m_sSavePath, sPath);
Reference< XComponentContext > m_xContext
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const OUString & GetWorkPath() const
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
virtual ~BrokenRecoveryDialog() override
const OUString & getSaveDirURL() const
TODO.
void impl_askForSavePath()
TODO.
BrokenRecoveryDialog(weld::Window *pParent, RecoveryCore *pCore, bool bBeforeRecovery)
TODO.
std::unique_ptr< weld::Button > m_xSaveDirBtn
std::unique_ptr< weld::Button > m_xCancelBtn
bool isExecutionNeeded() const
TODO.
std::unique_ptr< weld::Entry > m_xSaveDirED
std::unique_ptr< weld::Button > m_xOkBtn
bool const m_bBeforeRecovery
std::unique_ptr< weld::TreeView > m_xFileListLB
virtual void updateItems()=0
virtual void stepNext(TURLInfo *pItem)=0
PluginProgress(weld::ProgressBar *pProgressBar)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual void SAL_CALL setValue(sal_Int32 nValue) override
virtual void SAL_CALL setText(const OUString &sText) override
virtual void SAL_CALL start(const OUString &sText, sal_Int32 nRange) override
virtual void SAL_CALL reset() override
weld::ProgressBar * m_pProgressBar
virtual void SAL_CALL dispose() override
virtual ~PluginProgress() override
virtual void SAL_CALL end() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
IRecoveryUpdateListener * m_pListener
TODO.
css::uno::Reference< css::task::XStatusIndicator > m_xProgress
TODO.
TURLList & getURLListAccess()
TODO.
css::uno::Reference< css::uno::XComponentContext > m_xContext
TODO.
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
void saveBrokenTempEntries(const OUString &sSaveDir)
virtual ~RecoveryCore() override
TODO.
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &aEvent) override
void setUpdateListener(IRecoveryUpdateListener *pListener)
TODO.
void impl_stopListening()
stop listening on the internal EmergencySave/AutoRecovery core.
static ERecoveryState mapDocState2RecoverState(EDocStates eDocState)
TODO.
void forgetAllRecoveryEntriesMarkedForDiscard()
void impl_startListening()
starts listening on the internal EmergencySave/AutoRecovery core.
const css::uno::Reference< css::uno::XComponentContext > & getComponentContext() const
TODO.
void forgetAllRecoveryEntries()
void doEmergencySavePrepare()
TODO.
bool m_bListenForSaving
knows the reason, why we listen on our internal m_xRealCore member.
css::util::URL impl_getParsedURL(const OUString &sURL)
TODO.
void forgetBrokenRecoveryEntries()
void setProgressHandler(const css::uno::Reference< css::task::XStatusIndicator > &xProgress)
TODO.
void saveAllTempEntries(const OUString &sSaveDir)
static bool isBrokenTempEntry(const TURLInfo &rInfo)
TODO.
void forgetBrokenTempEntries()
RecoveryCore(css::uno::Reference< css::uno::XComponentContext > xContext, bool bUsedForSaving)
TODO.
css::uno::Reference< css::frame::XDispatch > m_xRealCore
TODO.
std::unique_ptr< weld::Button > m_xCancelBtn
OUString m_aWillBeDiscStr
std::unique_ptr< weld::TreeView > m_xFileListLB
virtual void stepNext(TURLInfo *pItem) override
OUString m_aTitleRecoveryInProgress
virtual ~RecoveryDialog() override
RecoveryDialog(weld::Window *pParent, RecoveryCore *pCore)
TODO.
OUString impl_getStatusString(const TURLInfo &rInfo) const
@ E_RECOVERY_CANCELED_BEFORE
@ E_RECOVERY_CANCELED_AFTERWARDS
OUString m_aRecovFailedStr
OUString m_aRecovInProgrStr
OUString m_aSuccessRecovStr
virtual void updateItems() override
std::unique_ptr< weld::Button > m_xNextBtn
OUString m_aOrigDocRecovStr
static OUString impl_getStatusImage(const TURLInfo &rInfo)
bool m_bWasRecoveryStarted
std::unique_ptr< weld::ProgressBar > m_xProgressBar
OUString m_aNotRecovYetStr
OUString m_aRecoveryOnlyFinishDescr
css::uno::Reference< css::task::XStatusIndicator > m_xProgress
std::unique_ptr< weld::Label > m_xDescrFT
virtual void end() override
sal_Int32 m_eRecoveryState
OUString m_aRecoveryOnlyFinish
void impl_updateItemDescription(int row, const TriState &rState)
SaveDialog(weld::Window *pParent, RecoveryCore *pCore)
create all child controls of this dialog.
std::unique_ptr< weld::Button > m_xOkBtn
virtual ~SaveDialog() override
std::unique_ptr< weld::TreeView > m_xFileListLB
virtual void updateItems() override
css::uno::Reference< css::task::XStatusIndicator > m_xProgress
virtual void end() override
std::unique_ptr< weld::ProgressBar > m_xProgressBar
SaveProgressDialog(weld::Window *pParent, RecoveryCore *pCore)
create all child controls of this dialog.
virtual short run() override
start the emergency save operation.
virtual ~SaveProgressDialog() override
virtual void stepNext(TURLInfo *pItem) override
std::shared_ptr< weld::Dialog > m_xDialog
virtual void set_text(const OUString &rText)=0
virtual void set_percentage(int value)=0
std::pair< const TreeIter &, int > iter_col
OUString SvxResId(TranslateId aId)
#define COLUMN_DISPLAYNAME
#define COLUMN_STATUSTEXT
#define COLUMN_STATUSIMAGE
#define COLUMN_STANDARDIMAGE
constexpr OUStringLiteral RECOVERY_CMD_DO_PREPARE_EMERGENCY_SAVE
constexpr OUStringLiteral RECOVERY_CMD_DO_EMERGENCY_SAVE
constexpr OUStringLiteral STATEPROP_ORGURL
constexpr OUStringLiteral STATEPROP_TEMPURL
constexpr OUStringLiteral STATEPROP_TITLE
constexpr OUStringLiteral RECOVERY_CMD_DO_ENTRY_BACKUP
constexpr OUStringLiteral STATEPROP_MODULE
constexpr OUStringLiteral STATEPROP_STATE
constexpr OUStringLiteral RECOVERY_CMD_DO_RECOVERY
constexpr OUStringLiteral STATEPROP_ID
constexpr OUStringLiteral RECOVERY_CMD_DO_ENTRY_CLEANUP
#define DLG_RET_OK_AUTOLUNCH
constexpr OUStringLiteral PROP_DISPATCHASYNCHRON
#define RECOVERY_OPERATIONSTATE_UPDATE
#define RECOVERY_OPERATIONSTATE_START
constexpr OUStringLiteral PROP_SAVEPATH
constexpr OUStringLiteral PROP_STATUSINDICATOR
constexpr OUStringLiteral STATEPROP_TEMPLATEURL
constexpr OUStringLiteral STATEPROP_FACTORYURL
constexpr OUStringLiteral PROP_ENTRYID
#define RECOVERY_OPERATIONSTATE_STOP
@ Incomplete
the Auto/Emergency saved document is not really up-to-date (some changes can be missing)
@ Succeeded
the Auto/Emergency saved document was processed successfully
@ TryLoadBackup
an action was started (saving/loading) ... Can be interesting later if the process may be was interru...
@ Damaged
the Auto/Emergency saved document isn't usable any longer
std::deque< AttacherIndex_Impl > aIndex
#define LINK(Instance, Class, Member)
OString strip(const OString &rIn, char c)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
::std::vector< TURLInfo > TURLList
static short impl_askUserForWizardCancel(weld::Widget *pParent, TranslateId pRes)
IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, weld::Button &, void)
@ E_SUCCESSFULLY_RECOVERED
@ E_RECOVERY_IS_IN_PROGRESS
@ E_ORIGINAL_DOCUMENT_RECOVERED
OUString toId(const void *pValue)
bool ShouldDiscard
user choice to discard
OUString TemplateURL
may be the document base on a template file !?
ERecoveryState RecoveryState
ui representation for DocState!
OUString FactoryURL
a may be existing factory URL (e.g. for untitled documents)
OUString DisplayName
the pure file name, without path, disc etcpp.
OUString TempURL
the full qualified URL of the temp. file (if it's exists)
EDocStates DocState
state info as e.g. VALID, CORRUPTED, NON EXISTING ...
OUString StandardImageId
standard icon
OUString OrgURL
the full qualified document URL
OUString Module
the application module, where this document was loaded
sal_Int32 ID
unique ID, which is specified by the underlying autorecovery core!