Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
597414ea
Commit
597414ea
authored
Dec 26, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DocFormatFile - fix users file (1995) without codepage
parent
7f06ce70
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
107 additions
and
49 deletions
+107
-49
ASCOfficeDocFile/DocDocxConverter/ConversionContext.h
ASCOfficeDocFile/DocDocxConverter/ConversionContext.h
+1
-14
ASCOfficeDocFile/DocDocxConverter/Converter.cpp
ASCOfficeDocFile/DocDocxConverter/Converter.cpp
+8
-8
ASCOfficeDocFile/DocDocxConverter/FontFamilyName.h
ASCOfficeDocFile/DocDocxConverter/FontFamilyName.h
+2
-1
ASCOfficeDocFile/DocDocxConverter/FontTableMapping.cpp
ASCOfficeDocFile/DocDocxConverter/FontTableMapping.cpp
+4
-6
ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp
ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp
+2
-2
ASCOfficeDocFile/DocDocxConverter/StringTable.h
ASCOfficeDocFile/DocDocxConverter/StringTable.h
+1
-0
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
+84
-12
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
+2
-2
ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj
ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj
+1
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Font.cpp
...ficeXlsFile2/source/XlsFormat/Logic/Biff_records/Font.cpp
+1
-1
ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.cpp
...mat/Logic/SummaryInformationStream/SummaryInformation.cpp
+1
-2
No files found.
ASCOfficeDocFile/DocDocxConverter/ConversionContext.h
View file @
597414ea
...
...
@@ -47,30 +47,17 @@ namespace DocFileFormat
virtual
~
ConversionContext
()
{
}
// Adds a new RSID to the set
inline
void
AddRsid
(
const
std
::
wstring
&
rsid
)
{
if
(
AllRsids
.
find
(
rsid
)
==
AllRsids
.
end
())
AllRsids
.
insert
(
rsid
);
}
inline
WordDocument
*
GetDocument
()
{
return
_doc
;
}
inline
WordprocessingDocument
*
GetXmlDocument
()
{
return
_docx
;
}
public:
WordprocessingDocument
*
_docx
;
WordDocument
*
_doc
;
/// A set thta contains all revision ids.
std
::
set
<
std
::
wstring
>
AllRsids
;
};
}
\ No newline at end of file
ASCOfficeDocFile/DocDocxConverter/Converter.cpp
View file @
597414ea
...
...
@@ -63,8 +63,16 @@ namespace DocFileFormat
{
long
Converter
::
Convert
(
WordDocument
*
doc
,
WordprocessingDocument
*
docx
,
const
ProgressCallback
*
progress
)
{
if
(
!
doc
||
!
docx
)
return
S_FALSE
;
ConversionContext
context
(
doc
,
docx
);
//Write fontTable.xml
if
(
doc
->
FontTable
)
{
FontTableMapping
fontTableMapping
(
&
context
);
doc
->
FontTable
->
Convert
(
&
fontTableMapping
);
}
//Write styles.xml
if
(
doc
->
Styles
)
{
...
...
@@ -107,14 +115,6 @@ namespace DocFileFormat
return
S_FALSE
;
}
}
//Write fontTable.xml
if
(
doc
->
FontTable
)
{
FontTableMapping
fontTableMapping
(
&
context
);
doc
->
FontTable
->
Convert
(
&
fontTableMapping
);
}
if
(
progress
!=
NULL
)
{
progress
->
OnProgress
(
progress
->
caller
,
DOC_ONPROGRESSEVENT_ID
,
875000
);
...
...
ASCOfficeDocFile/DocDocxConverter/FontFamilyName.h
View file @
597414ea
...
...
@@ -48,7 +48,8 @@ namespace DocFileFormat
class
FontFamilyName
:
public
ByteStructure
{
friend
class
CharacterPropertiesMapping
;
friend
class
WordDocument
;
friend
class
CharacterPropertiesMapping
;
friend
class
DocumentMapping
;
friend
class
FontTableMapping
;
friend
class
StyleSheetMapping
;
...
...
ASCOfficeDocFile/DocDocxConverter/FontTableMapping.cpp
View file @
597414ea
...
...
@@ -34,32 +34,30 @@
namespace
DocFileFormat
{
FontTableMapping
::
FontTableMapping
(
ConversionContext
*
ctx
)
:
AbstractOpenXmlMapping
(
new
XMLTools
::
CStringXmlWriter
()
)
FontTableMapping
::
FontTableMapping
(
ConversionContext
*
ctx
)
:
AbstractOpenXmlMapping
(
new
XMLTools
::
CStringXmlWriter
()
)
{
_ctx
=
ctx
;
}
/*========================================================================================================*/
FontTableMapping
::~
FontTableMapping
()
{
RELEASEOBJECT
(
m_pXmlWriter
);
}
/*========================================================================================================*/
void
FontTableMapping
::
Apply
(
IVisitable
*
visited
)
{
StringTable
<
FontFamilyName
>*
table
=
static_cast
<
StringTable
<
FontFamilyName
>*>
(
visited
);
this
->
_ctx
->
_docx
->
RegisterFontTable
();
_ctx
->
_docx
->
RegisterFontTable
();
m_pXmlWriter
->
WriteNodeBegin
(
L"?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?"
);
m_pXmlWriter
->
WriteNodeBegin
(
L"w:fonts"
,
TRUE
);
m_pXmlWriter
->
WriteAttribute
(
L"xmlns:w"
,
OpenXmlNamespaces
::
WordprocessingML
);
m_pXmlWriter
->
WriteNodeEnd
(
L""
,
TRUE
,
FALSE
);
int
sz_fonts
=
table
->
Data
.
size
();
int
sz_fonts
=
table
->
Data
.
size
();
int
users_fonts
=
0
;
for
(
std
::
vector
<
ByteStructure
*>::
iterator
iter
=
table
->
Data
.
begin
();
iter
!=
table
->
Data
.
end
();
iter
++
)
...
...
@@ -140,6 +138,6 @@ namespace DocFileFormat
m_pXmlWriter
->
WriteNodeEnd
(
L"w:fonts"
);
this
->
_ctx
->
_docx
->
FontTableXML
=
std
::
wstring
(
m_pXmlWriter
->
GetXmlString
()
)
;
_ctx
->
_docx
->
FontTableXML
=
m_pXmlWriter
->
GetXmlString
()
;
}
}
ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp
View file @
597414ea
...
...
@@ -38,8 +38,8 @@ namespace DocFileFormat
{
if
(
m_context
)
{
m_document
=
m_context
->
GetDocument
()
;
m_xmldocument
=
m_context
->
GetXmlDocument
()
;
m_document
=
m_context
->
_doc
;
m_xmldocument
=
m_context
->
_docx
;
}
}
...
...
ASCOfficeDocFile/DocDocxConverter/StringTable.h
View file @
597414ea
...
...
@@ -41,6 +41,7 @@ namespace DocFileFormat
{
template
<
class
T
>
class
StringTable
:
public
IVisitable
{
friend
class
WordDocument
;
friend
class
CharacterPropertiesMapping
;
friend
class
FontTableMapping
;
friend
class
StyleSheetMapping
;
...
...
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
View file @
597414ea
...
...
@@ -40,8 +40,45 @@
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/Directory.h"
#include <unordered_map>
namespace
DocFileFormat
{
static
const
int
aCodePages
[][
2
]
=
{
//charset codepage
0
,
1252
,
//ANSI
1
,
0
,
//Default
2
,
42
,
//Symbol
77
,
10000
,
//Mac Roman
78
,
10001
,
//Mac Shift Jis
79
,
10003
,
//Mac Hangul
80
,
10008
,
//Mac GB2312
81
,
10002
,
//Mac Big5
83
,
10005
,
//Mac Hebrew
84
,
10004
,
//Mac Arabic
85
,
10006
,
//Mac Greek
86
,
10081
,
//Mac Turkish
87
,
10021
,
//Mac Thai
88
,
10029
,
//Mac East Europe
89
,
10007
,
//Mac Russian
128
,
932
,
//Shift JIS
129
,
949
,
//Hangul
130
,
1361
,
//Johab
134
,
936
,
//GB2312
136
,
950
,
//Big5
238
,
1250
,
//Greek
161
,
1253
,
//Greek
162
,
1254
,
//Turkish
163
,
1258
,
//Vietnamese
177
,
1255
,
//Hebrew
178
,
1256
,
//Arabic
186
,
1257
,
//Baltic
204
,
1251
,
//Russian
222
,
874
,
//Thai
238
,
1250
,
//Eastern European
254
,
437
,
//PC 437
255
,
850
//OEM
};
WordDocument
::
WordDocument
(
const
ProgressCallback
*
pCallFunc
,
const
std
::
wstring
&
sTempFolder
)
:
m_PieceTable
(
NULL
),
WordDocumentStream
(
NULL
),
TableStream
(
NULL
),
DataStream
(
NULL
),
FIB
(
NULL
),
Text
(
NULL
),
RevisionAuthorTable
(
NULL
),
FontTable
(
NULL
),
BookmarkNames
(
NULL
),
AutoTextNames
(
NULL
),
...
...
@@ -55,12 +92,15 @@ namespace DocFileFormat
AnnotationOwners
(
NULL
),
DocProperties
(
NULL
),
listFormatOverrideTable
(
NULL
),
headerAndFooterTable
(
NULL
),
AnnotStartPlex
(
NULL
),
AnnotEndPlex
(
NULL
),
encryptionHeader
(
NULL
)
{
m_pCallFunc
=
pCallFunc
;
m_sTempFolder
=
sTempFolder
;
m_pCallFunc
=
pCallFunc
;
m_sTempFolder
=
sTempFolder
;
m_pStorage
=
NULL
;
officeArtContent
=
NULL
;
bOlderVersion
=
false
;
m_pStorage
=
NULL
;
officeArtContent
=
NULL
;
bOlderVersion
=
false
;
bDocumentCodePage
=
false
;
nDocumentCodePage
=
ENCODING_WINDOWS_1250
;
}
WordDocument
::~
WordDocument
()
...
...
@@ -178,8 +218,6 @@ namespace DocFileFormat
m_pStorage
->
GetStream
(
L"SummaryInformation"
,
&
Summary
);
m_pStorage
->
GetStream
(
L"DocumentSummaryInformation"
,
&
DocSummary
);
document_code_page
=
ENCODING_WINDOWS_1250
;
if
((
Summary
)
&&
(
Summary
->
size
()
>
0
))
{
...
...
@@ -188,7 +226,10 @@ namespace DocFileFormat
int
document_code_page1
=
summary_info
.
GetCodePage
();
//from software last open
if
(
document_code_page1
>
0
)
document_code_page
=
document_code_page1
;
{
nDocumentCodePage
=
document_code_page1
;
bDocumentCodePage
=
true
;
}
}
if
((
DocSummary
)
&&
(
DocSummary
->
size
()
>
0
))
{
...
...
@@ -197,12 +238,18 @@ namespace DocFileFormat
int
document_code_page2
=
doc_summary_info
.
GetCodePage
();
if
(
document_code_page2
>
0
)
document_code_page
=
document_code_page2
;
{
nDocumentCodePage
=
document_code_page2
;
bDocumentCodePage
=
true
;
}
}
if
(
!
bOlderVersion
)
document_code_page
=
ENCODING_UTF16
;
{
nDocumentCodePage
=
ENCODING_UTF16
;
bDocumentCodePage
=
true
;
}
FIB
->
m_CodePage
=
document_code_p
age
;
FIB
->
m_CodePage
=
nDocumentCodeP
age
;
//-------------------------------------------------------------------------------------------------
try
{
...
...
@@ -353,6 +400,31 @@ namespace DocFileFormat
return
AVS_ERROR_FILEFORMAT
;
}
}
if
(
!
bDocumentCodePage
&&
FontTable
)
{
std
::
unordered_map
<
int
,
int
>
fonts_charsets
;
for
(
std
::
vector
<
ByteStructure
*>::
iterator
iter
=
FontTable
->
Data
.
begin
();
!
bDocumentCodePage
&&
iter
!=
FontTable
->
Data
.
end
();
iter
++
)
{
FontFamilyName
*
font
=
dynamic_cast
<
FontFamilyName
*>
(
*
iter
);
if
(
!
font
)
continue
;
if
(
fonts_charsets
.
find
(
font
->
chs
)
==
fonts_charsets
.
end
())
{
fonts_charsets
.
insert
(
std
::
make_pair
(
font
->
chs
,
font
->
ff
));
for
(
int
i
=
0
;
i
<
sizeof
(
aCodePages
)
/
2
;
i
++
)
{
if
(
aCodePages
[
i
][
0
]
==
font
->
chs
&&
font
->
chs
!=
0
)
{
nDocumentCodePage
=
aCodePages
[
i
][
1
];
bDocumentCodePage
=
true
;
break
;
}
}
}
}
}
if
(
FIB
->
m_FibWord97
.
lcbClx
>
0
)
{
...
...
@@ -371,7 +443,7 @@ namespace DocFileFormat
WordDocumentStream
->
read
(
bytes
,
cb
);
Text
=
new
std
::
vector
<
wchar_t
>
();
FormatUtils
::
GetSTLCollectionFromBytes
<
std
::
vector
<
wchar_t
>
>
(
Text
,
bytes
,
cb
,
document_code_p
age
);
FormatUtils
::
GetSTLCollectionFromBytes
<
std
::
vector
<
wchar_t
>
>
(
Text
,
bytes
,
cb
,
nDocumentCodeP
age
);
RELEASEARRAYOBJECTS
(
bytes
);
}
...
...
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
View file @
597414ea
...
...
@@ -69,7 +69,6 @@ namespace DocFileFormat
{
class
WordDocument
:
public
IVisitable
{
/*Mapping classes with direct access to the Word Document.*/
friend
class
FootnotesMapping
;
friend
class
EndnotesMapping
;
friend
class
CommentsMapping
;
...
...
@@ -98,7 +97,8 @@ namespace DocFileFormat
long
LoadDocument
(
const
std
::
wstring
&
fileName
,
const
std
::
wstring
&
password
);
bool
bOlderVersion
;
int
document_code_page
;
int
nDocumentCodePage
;
bool
bDocumentCodePage
;
inline
StructuredStorageReader
*
GetStorage
()
const
{
...
...
ASCOfficeDocFile/DocFormatTest/DocFormatTest.vcproj
View file @
597414ea
...
...
@@ -67,7 +67,7 @@
Name=
"VCLinkerTool"
AdditionalDependencies=
"Urlmon.lib"
LinkIncremental=
"1"
IgnoreDefaultLibraryNames=
"LIBCMT.lib"
IgnoreDefaultLibraryNames=
"LIBCMT
D
.lib"
IgnoreEmbeddedIDL=
"true"
GenerateDebugInformation=
"true"
SubSystem=
"1"
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Font.cpp
View file @
597414ea
...
...
@@ -91,7 +91,7 @@ void Font::readFields(CFRecord& record)
if
(
global_info
->
fonts_charsets
.
find
(
bCharSet
)
==
global_info
->
fonts_charsets
.
end
())
{
global_info
->
fonts_charsets
.
insert
(
global_info
->
fonts_charsets
.
begin
(),
std
::
pair
<
int
,
int
>
(
bCharSet
,
bFamily
));
global_info
->
fonts_charsets
.
insert
(
std
::
make_pair
(
bCharSet
,
bFamily
));
}
}
...
...
ASCOfficeXlsFile2/source/XlsFormat/Logic/SummaryInformationStream/SummaryInformation.cpp
View file @
597414ea
...
...
@@ -38,8 +38,7 @@
namespace
OLEPS
{
SummaryInformation
::
SummaryInformation
(
XLS
::
CFStreamPtr
stream
)
:
property_set_stream
(
stream
)
SummaryInformation
::
SummaryInformation
(
XLS
::
CFStreamPtr
stream
)
:
property_set_stream
(
stream
)
{
}
...
...
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