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
f50dda7c
Commit
f50dda7c
authored
Apr 11, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug #34736
parent
f78a805f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
449 additions
and
37 deletions
+449
-37
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.cpp
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.cpp
+18
-17
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.sln
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.sln
+337
-2
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.vcproj
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.vcproj
+84
-11
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/TxtFile.cpp
...fficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/TxtFile.cpp
+10
-7
No files found.
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.cpp
View file @
f50dda7c
...
...
@@ -30,19 +30,20 @@
*
*/
#include "../
../
TxtXmlFormatLib/source/TxtXmlFile.h"
#include "../TxtXmlFormatLib/source/TxtXmlFile.h"
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../DesktopEditor/common/Directory.h"
#include <algorithm>
#include <string>
#include <tchar.h>
namespace
BinDocxRW
{
int
g_nCurFormatVersion
=
0
;
//extern from ...DocxSerializer
}
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
int
_tmain
(
int
argc
,
_TCHAR
*
argv
[])
{
...
...
@@ -52,22 +53,22 @@ int _tmain(int argc, _TCHAR* argv[])
std
::
wstring
srcFileName
=
argv
[
1
];
std
::
wstring
dstFileName
=
argv
[
2
];
std
::
wstring
outputDir
=
FileSystem
::
Directory
::
GetFolderPath
(
dstFileName
);
std
::
wstring
outputDir
=
NS
Directory
::
GetFolderPath
(
dstFileName
);
std
::
wstring
dstTempPath
=
FileSystem
::
Directory
::
CreateDirectoryWithUniqueName
(
outputDir
);
std
::
wstring
dstTempPath
=
NS
Directory
::
CreateDirectoryWithUniqueName
(
outputDir
);
int
n1
=
srcFileName
.
rfind
(
_T
(
'.'
)
);
int
n2
=
dstFileName
.
rfind
(
_T
(
'.'
)
);
int
n1
=
srcFileName
.
rfind
(
L"."
);
int
n2
=
dstFileName
.
rfind
(
L"."
);
std
::
wstring
ext_1
=
n1
>=
0
?
srcFileName
.
substr
(
n1
+
1
,
srcFileName
.
length
()
-
n1
)
:
_T
(
""
)
;
//ext_1.MakeLower();
std
::
wstring
ext_2
=
n2
>=
0
?
dstFileName
.
substr
(
n2
+
1
,
dstFileName
.
length
()
-
n2
)
:
_T
(
""
)
;
//ext_2.MakeLower();
std
::
wstring
ext_1
=
n1
>=
0
?
srcFileName
.
substr
(
n1
+
1
,
srcFileName
.
length
()
-
n1
)
:
L""
;
//ext_1.MakeLower();
std
::
wstring
ext_2
=
n2
>=
0
?
dstFileName
.
substr
(
n2
+
1
,
dstFileName
.
length
()
-
n2
)
:
L""
;
//ext_2.MakeLower();
std
::
transform
(
ext_1
.
begin
(),
ext_1
.
end
(),
ext_1
.
begin
(),
::
tolower
);
CTxtXmlFile
txtFile
;
COfficeUtils
oCOfficeUtils
(
NULL
);
if
(
ext_1
==
_T
(
"txt"
)
)
if
(
ext_1
==
L"txt"
)
{
// txt->docx
if
(
S_OK
!=
txtFile
.
txt_LoadFromFile
(
srcFileName
,
dstTempPath
,
sXMLOptions
))
...
...
@@ -76,7 +77,7 @@ int _tmain(int argc, _TCHAR* argv[])
if
(
S_OK
!=
oCOfficeUtils
.
CompressFileOrDirectory
(
dstTempPath
.
c_str
(),
dstFileName
.
c_str
(),
-
1
))
return
S_FALSE
;
}
if
(
ext_2
==
_T
(
"txt"
)
)
if
(
ext_2
==
L"txt"
)
{
// docx->txt
if
(
S_OK
!=
oCOfficeUtils
.
ExtractToDirectory
(
srcFileName
.
c_str
(),
dstTempPath
.
c_str
(),
NULL
,
0
))
...
...
@@ -86,7 +87,7 @@ int _tmain(int argc, _TCHAR* argv[])
return
3
;
}
FileSystem
::
Directory
::
DeleteDirectory
(
dstTempPath
);
NS
Directory
::
DeleteDirectory
(
dstTempPath
);
return
0
;
}
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.sln
View file @
f50dda7c
This diff is collapsed.
Click to expand it.
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.vcproj
View file @
f50dda7c
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType=
"Visual C++"
Version=
"8
,
00"
Version=
"8
.
00"
Name=
"TxtFormatTest"
ProjectGUID=
"{0F49D5D1-A8D3-4F97-8BC1-E2F65BB00C10}"
RootNamespace=
"TxtFormatTest"
...
...
@@ -23,6 +23,7 @@
OutputDirectory=
"$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory=
"$(ConfigurationName)"
ConfigurationType=
"1"
UseOfMFC=
"0"
UseOfATL=
"0"
CharacterSet=
"1"
>
...
...
@@ -44,8 +45,8 @@
<Tool
Name=
"VCCLCompilerTool"
Optimization=
"0"
AdditionalIncludeDirectories=
""
PreprocessorDefinitions=
"WIN32;_DEBUG;_CONSOLE;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_"
AdditionalIncludeDirectories=
"
"D:\_Work\core\DesktopEditor\agg-2.4\include";"D:\_Work\core\DesktopEditor\freetype-2.5.2\include"
"
PreprocessorDefinitions=
"WIN32;_DEBUG;_CONSOLE;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_
;DONT_WRITE_EMBEDDED_FONTS
"
MinimalRebuild=
"false"
BasicRuntimeChecks=
"3"
RuntimeLibrary=
"2"
...
...
@@ -338,22 +339,94 @@
<References>
</References>
<Files>
<Fil
e
RelativePath=
"..\..\..\build\bin\icu\win_32\icuuc.lib
"
<Fil
ter
Name=
"Common
"
>
</File>
<File
RelativePath=
"..\..\HtmlRenderer\src\ASCSVGWriter.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficePPTXFile\Editor\BinaryFileReaderWriter.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficeDocxFile2\BinWriter\BinWriters.cpp"
>
</File>
<File
RelativePath=
"..\..\XlsxSerializerCom\Reader\ChartFromToBinary.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficeDocxFile2\DocWrapper\ChartWriter.cpp"
>
</File>
<File
RelativePath=
"..\..\XlsxSerializerCom\Common\Common.cpp"
>
</File>
<File
RelativePath=
"..\..\XlsxSerializerCom\Reader\CommonWriter.cpp"
>
</File>
<File
RelativePath=
"..\..\XlsxSerializerCom\Reader\CSVReader.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficeDocxFile2\DocWrapper\DocxSerializer.cpp"
>
</File>
<File
RelativePath=
"..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficePPTXFile\Editor\FontPicker.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficeDocxFile2\DocWrapper\FontProcessor.cpp"
>
</File>
<File
RelativePath=
"..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath=
"..\..\Common\3dParty\pole\pole.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficeDocxFile2\BinReader\Readers.cpp"
>
</File>
<File
RelativePath=
"..\..\UnicodeConverter\UnicodeConverter.cpp"
>
</File>
<File
RelativePath=
"..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
>
</File>
<File
RelativePath=
"..\..\DesktopEditor\xml\src\xmldom.cpp"
>
</File>
<File
RelativePath=
"..\..\DesktopEditor\xml\src\xmllight.cpp"
>
</File>
</Filter>
<File
RelativePath=
"..\..\
..\Common\DocxFormat\Source\XML\libxml2\libxml2
.cpp"
RelativePath=
"..\..\
XlsxSerializerCom\Writer\CSVWriter
.cpp"
>
</File>
<File
RelativePath=
".\TxtFormatTest.cpp"
>
</File>
<File
RelativePath=
"..\..\..\UnicodeConverter\UnicodeConverter.cpp"
>
</File>
</Files>
<Globals>
</Globals>
...
...
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/TxtFile.cpp
View file @
f50dda7c
...
...
@@ -198,7 +198,7 @@ const std::list<std::string> TxtFile::readUtf8()
void
TxtFile
::
writeAnsiOrCodePage
(
const
std
::
list
<
std
::
string
>&
content
)
// === writeUtf8withoutPref также
{
NSFile
::
CFileBinary
file
;
if
(
file
.
CreateFileW
(
m_path
)
==
S_OK
)
if
(
file
.
CreateFileW
(
m_path
))
{
BYTE
endLine
[
2
]
=
{
0x0d
,
0x0a
};
for
(
std
::
list
<
std
::
string
>::
const_iterator
iter
=
content
.
begin
();
iter
!=
content
.
end
();
++
iter
)
...
...
@@ -214,7 +214,7 @@ void TxtFile::writeAnsiOrCodePage(const std::list<std::string>& content) // ===
void
TxtFile
::
writeUnicode
(
const
std
::
list
<
std
::
wstring
>&
content
)
{
NSFile
::
CFileBinary
file
;
if
(
file
.
CreateFileW
(
m_path
)
==
S_OK
)
if
(
file
.
CreateFileW
(
m_path
))
{
BYTE
Header
[
2
]
=
{
0xff
,
0xfe
};
BYTE
EndLine
[
4
]
=
{
0x0d
,
0x00
,
0x0a
,
0x00
};
...
...
@@ -238,13 +238,14 @@ void TxtFile::writeUnicode(const std::list<std::wstring>& content)
file
.
WriteFile
(
EndLine
,
4
);
m_linesCount
++
;
}
file
.
CloseFile
();
}
}
void
TxtFile
::
writeBigEndian
(
const
std
::
list
<
std
::
wstring
>&
content
)
{
NSFile
::
CFileBinary
file
;
if
(
file
.
CreateFileW
(
m_path
)
==
S_OK
)
if
(
file
.
CreateFileW
(
m_path
))
{
BYTE
Header
[
2
]
=
{
0xfe
,
0xff
};
BYTE
EndLine
[
4
]
=
{
0x00
,
0x0d
,
0x00
,
0x0a
};
...
...
@@ -274,13 +275,14 @@ void TxtFile::writeBigEndian(const std::list<std::wstring>& content)
file
.
WriteFile
(
EndLine
,
4
);
m_linesCount
++
;
}
file
.
CloseFile
();
}
}
void
TxtFile
::
writeUtf8
(
const
std
::
list
<
std
::
string
>&
content
)
{
NSFile
::
CFileBinary
file
;
if
(
file
.
CreateFileW
(
m_path
)
==
S_OK
)
if
(
file
.
CreateFileW
(
m_path
))
{
BYTE
Header
[
3
]
=
{
0xef
,
0xbb
,
0xbf
};
BYTE
EndLine
[
2
]
=
{
0x0d
,
0x0a
};
...
...
@@ -294,6 +296,7 @@ void TxtFile::writeUtf8(const std::list<std::string>& content)
m_linesCount
++
;
}
file
.
CloseFile
();
}
}
...
...
@@ -301,7 +304,7 @@ const bool TxtFile::isUnicode()
{
NSFile
::
CFileBinary
file
;
if
(
file
.
OpenFile
(
m_path
)
!=
S_OK
)
return
false
;
if
(
file
.
OpenFile
(
m_path
)
==
false
)
return
false
;
DWORD
dwRead
;
BYTE
data
[
2
];
...
...
@@ -318,7 +321,7 @@ const bool TxtFile::isBigEndian()
{
NSFile
::
CFileBinary
file
;
if
(
file
.
OpenFile
(
m_path
)
!=
S_OK
)
return
false
;
if
(
file
.
OpenFile
(
m_path
)
==
false
)
return
false
;
DWORD
dwRead
;
BYTE
data
[
2
];
...
...
@@ -335,7 +338,7 @@ const bool TxtFile::isUtf8()
{
NSFile
::
CFileBinary
file
;
if
(
file
.
OpenFile
(
m_path
)
!=
S_OK
)
return
false
;
if
(
file
.
OpenFile
(
m_path
)
==
false
)
return
false
;
DWORD
dwRead
;
BYTE
data
[
3
];
...
...
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