Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
425c2c64
Commit
425c2c64
authored
Jul 18, 2007
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
Aug 22, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wordpad: Handle different formats on open/save.
parent
07d60bc7
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
144 additions
and
27 deletions
+144
-27
De.rc
programs/wordpad/De.rc
+4
-0
En.rc
programs/wordpad/En.rc
+5
-1
Fr.rc
programs/wordpad/Fr.rc
+5
-1
Hu.rc
programs/wordpad/Hu.rc
+5
-1
Ko.rc
programs/wordpad/Ko.rc
+4
-0
Nl.rc
programs/wordpad/Nl.rc
+5
-1
No.rc
programs/wordpad/No.rc
+5
-1
Pl.rc
programs/wordpad/Pl.rc
+4
-0
Ru.rc
programs/wordpad/Ru.rc
+5
-1
Tr.rc
programs/wordpad/Tr.rc
+5
-1
resource.h
programs/wordpad/resource.h
+8
-6
wordpad.c
programs/wordpad/wordpad.c
+89
-14
No files found.
programs/wordpad/De.rc
View file @
425c2c64
...
...
@@ -97,6 +97,7 @@ STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rich-Text-Format (*.rtf)"
STRING_TEXT_FILES_TXT, "Textdateien (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "Alle Dokumente (*.*)"
END
...
...
@@ -106,4 +107,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/En.rc
View file @
425c2c64
...
...
@@ -96,7 +96,8 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
STRING_TEXT_FILES_TXT, "Text files (*.txt)"
STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "All documents (*.*)"
END
...
...
@@ -106,4 +107,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/Fr.rc
View file @
425c2c64
...
...
@@ -96,7 +96,8 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
STRING_TEXT_FILES_TXT, "Text files (*.txt)"
STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "All documents (*.*)"
END
...
...
@@ -106,4 +107,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/Hu.rc
View file @
425c2c64
...
...
@@ -96,7 +96,8 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
STRING_TEXT_FILES_TXT, "Text files (*.txt)"
STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "All documents (*.*)"
END
...
...
@@ -106,4 +107,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/Ko.rc
View file @
425c2c64
...
...
@@ -98,6 +98,7 @@ STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "리치 텍스트 파일형식 (*.rtf)"
STRING_TEXT_FILES_TXT, "텍스트 파일 (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "모든 문서 (*.*)"
END
...
...
@@ -107,4 +108,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "'%s'의 바뀐 것을 저장하겠습니까?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/Nl.rc
View file @
425c2c64
...
...
@@ -96,7 +96,8 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
STRING_TEXT_FILES_TXT, "Text files (*.txt)"
STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "All documents (*.*)"
END
...
...
@@ -106,4 +107,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/No.rc
View file @
425c2c64
...
...
@@ -96,7 +96,8 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rikt tekstformat (*.rtf)"
STRING_TEXT_FILES_TXT, "Tekstfiler (*.txt)"
STRING_TEXT_FILES_TXT, "Tekstdokument (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode-tekstdokument (*.txt)"
STRING_ALL_FILES, "Alle filer (*.*)"
END
...
...
@@ -106,4 +107,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Lagre endringer i %s?"
STRING_SEARCH_FINISHED, "Ferdig med ske i dokumentet."
STRING_LOAD_RICHED_FAILED, "Klarte ikke laste RichEdit-biblioteket."
STRING_SAVE_LOSEFORMATTING, "Du har valgt lagre i rent tekstformat, noe som " \
"vil fre til at all formatering gr tapt. Er du " \
"sikker p at du vil fortsette?"
END
programs/wordpad/Pl.rc
View file @
425c2c64
...
...
@@ -98,6 +98,7 @@ STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Tekst sformatowany - RTF (*.rtf)"
STRING_TEXT_FILES_TXT, "Dokument tekstowy (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "Wszystkie dokumenty (*.*)"
END
...
...
@@ -107,4 +108,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/Ru.rc
View file @
425c2c64
...
...
@@ -94,7 +94,8 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
STRING_TEXT_FILES_TXT, "Text files (*.txt)"
STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "All documents (*.*)"
END
...
...
@@ -104,4 +105,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/Tr.rc
View file @
425c2c64
...
...
@@ -98,7 +98,8 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
STRING_TEXT_FILES_TXT, "Text files (*.txt)"
STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
STRING_ALL_FILES, "All documents (*.*)"
END
...
...
@@ -108,4 +109,7 @@ BEGIN
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
STRING_SEARCH_FINISHED, "Finished searching the document."
STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
END
programs/wordpad/resource.h
View file @
425c2c64
...
...
@@ -90,9 +90,11 @@
#define STRING_ALL_FILES 1400
#define STRING_TEXT_FILES_TXT 1401
#define STRING_RICHTEXT_FILES_RTF 1402
#define STRING_DEFAULT_FILENAME 1403
#define STRING_PROMPT_SAVE_CHANGES 1404
#define STRING_SEARCH_FINISHED 1405
#define STRING_LOAD_RICHED_FAILED 1406
#define STRING_TEXT_FILES_UNICODE_TXT 1402
#define STRING_RICHTEXT_FILES_RTF 1403
#define STRING_DEFAULT_FILENAME 1700
#define STRING_PROMPT_SAVE_CHANGES 1701
#define STRING_SEARCH_FINISHED 1702
#define STRING_LOAD_RICHED_FAILED 1703
#define STRING_SAVE_LOSEFORMATTING 1704
programs/wordpad/wordpad.c
View file @
425c2c64
...
...
@@ -55,7 +55,7 @@ static HWND hFindWnd;
static
UINT
ID_FINDMSGSTRING
;
static
WCHAR
wszFilter
[
MAX_STRING_LEN
];
static
WCHAR
wszFilter
[
MAX_STRING_LEN
*
4
+
6
*
3
+
5
];
static
WCHAR
wszDefaultFileName
[
MAX_STRING_LEN
];
static
WCHAR
wszSaveChanges
[
MAX_STRING_LEN
];
...
...
@@ -78,6 +78,10 @@ static void DoLoadStrings(void)
p
+=
lstrlenW
(
p
)
+
1
;
lstrcpyW
(
p
,
files_txt
);
p
+=
lstrlenW
(
p
)
+
1
;
LoadStringW
(
hInstance
,
STRING_TEXT_FILES_UNICODE_TXT
,
p
,
MAX_STRING_LEN
);
p
+=
lstrlenW
(
p
)
+
1
;
lstrcpyW
(
p
,
files_txt
);
p
+=
lstrlenW
(
p
)
+
1
;
LoadStringW
(
hInstance
,
STRING_ALL_FILES
,
p
,
MAX_STRING_LEN
);
p
+=
lstrlenW
(
p
)
+
1
;
lstrcpyW
(
p
,
files_all
);
...
...
@@ -165,6 +169,7 @@ static LPWSTR file_basename(LPWSTR path)
}
static
WCHAR
wszFileName
[
MAX_PATH
];
static
WPARAM
fileFormat
=
SF_RTF
;
static
void
set_caption
(
LPCWSTR
wszNewFileName
)
{
...
...
@@ -424,21 +429,63 @@ static void registry_set_filelist(LPCWSTR newFile)
registry_read_filelist
(
hMainWnd
);
}
static
int
fileformat_number
(
WPARAM
format
)
{
int
number
=
0
;
if
(
format
==
SF_TEXT
)
{
number
=
1
;
}
else
if
(
format
==
(
SF_TEXT
|
SF_UNICODE
))
{
number
=
2
;
}
return
number
;
}
static
WPARAM
fileformat_flags
(
int
format
)
{
WPARAM
flags
[]
=
{
SF_RTF
,
SF_TEXT
,
SF_TEXT
|
SF_UNICODE
};
return
flags
[
format
];
}
static
void
set_fileformat
(
WPARAM
format
)
{
fileFormat
=
format
;
}
static
void
DoOpenFile
(
LPCWSTR
szOpenFileName
)
{
HANDLE
hFile
;
EDITSTREAM
es
;
char
fileStart
[
5
];
DWORD
readOut
;
WPARAM
format
=
SF_TEXT
;
hFile
=
CreateFileW
(
szOpenFileName
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
;
ReadFile
(
hFile
,
fileStart
,
5
,
&
readOut
,
NULL
);
SetFilePointer
(
hFile
,
0
,
NULL
,
FILE_BEGIN
);
if
(
readOut
>=
2
&&
(
BYTE
)
fileStart
[
0
]
==
0xff
&&
(
BYTE
)
fileStart
[
1
]
==
0xfe
)
{
format
=
SF_TEXT
|
SF_UNICODE
;
SetFilePointer
(
hFile
,
2
,
NULL
,
FILE_BEGIN
);
}
else
if
(
readOut
>=
5
)
{
static
const
char
header
[]
=
"{
\\
rtf"
;
if
(
!
memcmp
(
header
,
fileStart
,
5
))
format
=
SF_RTF
;
}
es
.
dwCookie
=
(
DWORD_PTR
)
hFile
;
es
.
pfnCallback
=
stream_in
;
/* FIXME: Handle different file formats */
SendMessageW
(
hEditorWnd
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
SendMessageW
(
hEditorWnd
,
EM_STREAMIN
,
format
,
(
LPARAM
)
&
es
);
CloseHandle
(
hFile
);
...
...
@@ -449,9 +496,10 @@ static void DoOpenFile(LPCWSTR szOpenFileName)
lstrcpyW
(
wszFileName
,
szOpenFileName
);
SendMessageW
(
hEditorWnd
,
EM_SETMODIFY
,
FALSE
,
0
);
registry_set_filelist
(
szOpenFileName
);
set_fileformat
(
format
);
}
static
void
DoSaveFile
(
LPCWSTR
wszSaveFileName
)
static
void
DoSaveFile
(
LPCWSTR
wszSaveFileName
,
WPARAM
format
)
{
HANDLE
hFile
;
EDITSTREAM
stream
;
...
...
@@ -463,11 +511,20 @@ static void DoSaveFile(LPCWSTR wszSaveFileName)
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
;
if
(
format
==
(
SF_TEXT
|
SF_UNICODE
))
{
static
const
BYTE
unicode
[]
=
{
0xff
,
0xfe
};
DWORD
writeOut
;
WriteFile
(
hFile
,
&
unicode
,
sizeof
(
unicode
),
&
writeOut
,
0
);
if
(
writeOut
!=
sizeof
(
unicode
))
return
;
}
stream
.
dwCookie
=
(
DWORD_PTR
)
hFile
;
stream
.
pfnCallback
=
stream_out
;
/* FIXME: Handle different formats */
ret
=
SendMessageW
(
hEditorWnd
,
EM_STREAMOUT
,
SF_RTF
,
(
LPARAM
)
&
stream
);
ret
=
SendMessageW
(
hEditorWnd
,
EM_STREAMOUT
,
format
,
(
LPARAM
)
&
stream
);
CloseHandle
(
hFile
);
...
...
@@ -486,6 +543,7 @@ static void DoSaveFile(LPCWSTR wszSaveFileName)
lstrcpyW
(
wszFileName
,
wszSaveFileName
);
set_caption
(
wszFileName
);
SendMessageW
(
hEditorWnd
,
EM_SETMODIFY
,
FALSE
,
0
);
set_fileformat
(
format
);
}
static
void
DialogSaveFile
(
void
)
...
...
@@ -498,17 +556,33 @@ static void DialogSaveFile(void)
ZeroMemory
(
&
sfn
,
sizeof
(
sfn
));
sfn
.
lStructSize
=
sizeof
(
sfn
);
sfn
.
Flags
=
OFN_HIDEREADONLY
|
OFN_PATHMUSTEXIST
;
sfn
.
Flags
=
OFN_HIDEREADONLY
|
OFN_PATHMUSTEXIST
|
OFN_OVERWRITEPROMPT
;
sfn
.
hwndOwner
=
hMainWnd
;
sfn
.
lpstrFilter
=
wszFilter
;
sfn
.
lpstrFile
=
wszFile
;
sfn
.
nMaxFile
=
MAX_PATH
;
sfn
.
lpstrDefExt
=
wszDefExt
;
sfn
.
nFilterIndex
=
fileformat_number
(
fileFormat
)
+
1
;
if
(
!
GetSaveFileNameW
(
&
sfn
))
return
;
DoSaveFile
(
sfn
.
lpstrFile
);
while
(
GetSaveFileNameW
(
&
sfn
))
{
if
(
fileformat_flags
(
sfn
.
nFilterIndex
-
1
)
!=
SF_RTF
)
{
if
(
MessageBoxW
(
hMainWnd
,
MAKEINTRESOURCEW
(
STRING_SAVE_LOSEFORMATTING
),
wszAppTitle
,
MB_YESNO
|
MB_ICONEXCLAMATION
)
!=
IDYES
)
{
continue
;
}
else
{
DoSaveFile
(
sfn
.
lpstrFile
,
fileformat_flags
(
sfn
.
nFilterIndex
-
1
));
break
;
}
}
else
{
DoSaveFile
(
sfn
.
lpstrFile
,
fileformat_flags
(
sfn
.
nFilterIndex
-
1
));
break
;
}
}
}
static
BOOL
prompt_save_changes
(
void
)
...
...
@@ -555,7 +629,7 @@ static BOOL prompt_save_changes(void)
case
IDYES
:
if
(
wszFileName
[
0
])
DoSaveFile
(
wszFileName
);
DoSaveFile
(
wszFileName
,
fileFormat
);
else
DialogSaveFile
();
return
TRUE
;
...
...
@@ -582,6 +656,7 @@ static void DialogOpenFile(void)
ofn
.
lpstrFile
=
wszFile
;
ofn
.
nMaxFile
=
MAX_PATH
;
ofn
.
lpstrDefExt
=
wszDefExt
;
ofn
.
nFilterIndex
=
fileformat_number
(
fileFormat
)
+
1
;
if
(
GetOpenFileNameW
(
&
ofn
))
{
...
...
@@ -1068,7 +1143,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
wszFileName
[
0
]
=
'\0'
;
SetWindowTextW
(
hwndEditor
,
wszFileName
);
SendMessageW
(
hEditorWnd
,
EM_SETMODIFY
,
FALSE
,
0
);
/* FIXME: set default format too */
fileFormat
=
SF_RTF
;
}
break
;
...
...
@@ -1079,7 +1154,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
case
ID_FILE_SAVE
:
if
(
wszFileName
[
0
])
{
DoSaveFile
(
wszFileName
);
DoSaveFile
(
wszFileName
,
fileFormat
);
break
;
}
/* Fall through */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment