23#define TIMER_INTERVAL 100
25#define RESIZE_WINDOW(hwnd, extrax, extray) \
28 GetWindowRect(hwnd, &windowSize); \
29 SetWindowPos(hwnd, 0, 0, 0, windowSize.right - windowSize.left + extrax, \
30 windowSize.bottom - windowSize.top + extray, \
31 SWP_NOMOVE | SWP_NOZORDER); \
34#define MOVE_WINDOW(hwnd, dx, dy) \
38 GetWindowRect(hwnd, &rc); \
41 ScreenToClient(GetParent(hwnd), &pt); \
42 SetWindowPos(hwnd, 0, pt.x + dx, pt.y + dy, 0, 0, \
43 SWP_NOSIZE | SWP_NOZORDER); \
46static float sProgress;
52GetStringsFile(WCHAR filename[MAX_PATH])
54 if (!GetModuleFileNameW(
nullptr, filename, MAX_PATH))
57 WCHAR *dot = wcsrchr(filename,
'.');
58 if (!dot || wcsicmp(dot + 1, L
"exe"))
61 wcscpy(dot + 1, L
"ini");
68 int pos =
int(sProgress + 0.5f);
70 SendMessage(hWndPro, PBM_SETPOS, pos, 0);
76CenterDialog(HWND hDlg)
78 RECT rc, rcOwner, rcDlg;
81 HWND
desktop = GetDesktopWindow();
83 GetWindowRect(
desktop, &rcOwner);
84 GetWindowRect(hDlg, &rcDlg);
85 CopyRect(&rc, &rcOwner);
92 OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
93 OffsetRect(&rc, -rc.left, -rc.top);
94 OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
101 rcOwner.left + (rc.right / 2),
102 rcOwner.top + (rc.bottom / 2),
113 MultiByteToWideChar(CP_UTF8, 0, sUIStrings.
title, -1, szwTitle,
114 sizeof(szwTitle)/
sizeof(szwTitle[0]));
115 MultiByteToWideChar(CP_UTF8, 0, sUIStrings.
info, -1, szwInfo,
116 sizeof(szwInfo)/
sizeof(szwInfo[0]));
118 SetWindowTextW(hDlg, szwTitle);
119 SetWindowTextW(GetDlgItem(hDlg,
IDC_INFO), szwInfo);
122 HICON hIcon = LoadIcon(GetModuleHandle(
nullptr),
125 SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
128 SendMessage(hWndPro, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
131 LONG_PTR val = GetWindowLongPtr(hWndPro, GWL_STYLE);
132 SetWindowLongPtr(hWndPro, GWL_STYLE, val|PBS_MARQUEE);
133 SendMessage(hWndPro,(UINT) PBM_SETMARQUEE,(WPARAM) TRUE,(LPARAM)50 );
137 RECT infoSize, textSize;
138 HWND hWndInfo = GetDlgItem(hDlg,
IDC_INFO);
141 HDC hDCInfo =
GetDC(hWndInfo);
144 hInfoFont = (HFONT)SendMessage(hWndInfo, WM_GETFONT, 0, 0);
147 hOldFont = (HFONT)SelectObject(hDCInfo, hInfoFont);
151 if (
DrawText(hDCInfo, szwInfo, -1, &textSize,
152 DT_CALCRECT | DT_NOCLIP | DT_SINGLELINE))
154 GetClientRect(hWndInfo, &infoSize);
159 extra.cx = (textSize.right - textSize.left) - \
160 (infoSize.right - infoSize.left);
161 extra.cy = (textSize.bottom - textSize.top) - \
162 (infoSize.bottom - infoSize.top);
167 if ((extra.cx > 0) || (extra.cy > 0))
169 RESIZE_WINDOW(hDlg, extra.cx, extra.cy);
170 RESIZE_WINDOW(hWndInfo, extra.cx, extra.cy);
171 RESIZE_WINDOW(hWndPro, extra.cx, 0);
172 MOVE_WINDOW(hWndPro, 0, extra.cy);
177 SelectObject(hDCInfo, hOldFont);
179 ReleaseDC(hWndInfo, hDCInfo);
188DialogProc(HWND hDlg, UINT message, WPARAM , LPARAM )
225InitProgressUIStrings()
229 if (!GetStringsFile(filename))
231 strcpy(sUIStrings.
title,
"LibreOffice Update");
232 strcpy(sUIStrings.
info,
"Please wait while we update your installation.");
236 if (_waccess(filename, 04))
238 strcpy(sUIStrings.
title,
"LibreOffice Update");
239 strcpy(sUIStrings.
info,
"Please wait while we update your installation.");
247 strcpy(sUIStrings.
title,
"LibreOffice Update");
248 strcpy(sUIStrings.
info,
"Please wait while we update your installation.");
265 if (
sQuit || sProgress > 70.0f)
270 WCHAR appPath[
MAX_PATH + 1] = { L
'\0' };
271 if (!GetModuleFileNameW(
nullptr, appPath, MAX_PATH))
276 if (wcslen(appPath) + wcslen(L
".Local") >= MAX_PATH)
281 wcscat(appPath, L
".Local");
283 if (!_waccess(appPath, 04))
289 if (initUIStrings && InitProgressUIStrings() == -1)
294 if (!GetModuleFileNameW(
nullptr, appPath, MAX_PATH))
301 actx.cbSize =
sizeof(ACTCTXW);
302 actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID;
303 actx.hModule = GetModuleHandle(NULL);
306 actx.lpSource = appPath;
309 HANDLE hactx = CreateActCtxW(&actx);
310 ULONG_PTR actxCookie =
NULL;
311 if (hactx != INVALID_HANDLE_VALUE)
314 ActivateActCtx(hactx, &actxCookie);
317 INITCOMMONCONTROLSEX icc =
319 sizeof(INITCOMMONCONTROLSEX),
322 InitCommonControlsEx(&icc);
324 DialogBox(GetModuleHandle(
nullptr),
326 (DLGPROC) DialogProc);
328 if (hactx != INVALID_HANDLE_VALUE)
331 DeactivateActCtx(0, actxCookie);
346 sProgress = progress;
virtual void EndDialog(sal_Int32 nResult) override
constexpr tools::Long SIZE
int InitProgressUI(int *argc, char ***argv)
void UpdateProgressUI(float progress)
static gboolean UpdateDialog(gpointer)
int ReadStrings(const NS_tchar *path, const char *keyList, unsigned int numStrings, char results[][MAX_TEXT_LEN], const char *section)
A very basic parser for updater.ini taken mostly from nsINIParser.cpp that can be used by standalone ...
const wchar_t *typedef BOOL
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
#define IDR_COMCTL32_MANIFEST