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
7d321f25
Commit
7d321f25
authored
Apr 20, 2016
by
ElenaSubbotina
Committed by
Alexander Trofimov
May 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TxtFile - bug #32257, конвертация табов (в обе стороны), возвращена конвертация через локаль.
parent
303a13a9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
66 deletions
+86
-66
ASCOfficeTxtFile/TxtXmlFormatLib/Source/Common/Encoding.cpp
ASCOfficeTxtFile/TxtXmlFormatLib/Source/Common/Encoding.cpp
+26
-8
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp
+5
-1
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertTxt2Docx.cpp
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertTxt2Docx.cpp
+41
-49
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/File.cpp
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/File.cpp
+4
-2
ASCOfficeTxtFile/Win32/TxtFormatTest/TxtFormatTest.cpp
ASCOfficeTxtFile/Win32/TxtFormatTest/TxtFormatTest.cpp
+2
-2
Common/DocxFormat/Source/DocxFormat/Logic/Paragraph.cpp
Common/DocxFormat/Source/DocxFormat/Logic/Paragraph.cpp
+3
-0
Common/OfficeDefines.h
Common/OfficeDefines.h
+5
-4
No files found.
ASCOfficeTxtFile/TxtXmlFormatLib/Source/Common/Encoding.cpp
View file @
7d321f25
...
...
@@ -4,20 +4,28 @@
#include "Encoding.h"
#include "Utility.h"
#if defined (_WIN32) || defined (_WIN64)
#include <windows.h>
#else
#include <iconv.h>
#endif
#include "../../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../../UnicodeConverter/UnicodeConverter.h"
#include "../../../UnicodeConverter/UnicodeConverter_Encodings.h"
//#include <boost/locale.hpp>
//#include <boost/locale/conversion.hpp>
#include <locale>
const
std
::
wstring
Encoding
::
ansi2unicode
(
const
std
::
string
&
line
)
{
return
std
::
wstring
(
line
.
begin
(),
line
.
end
());
//cp2unicode(line, CP_ACP);
if
(
line
.
empty
())
return
std
::
wstring
();
std
::
locale
loc
(
""
);
std
::
ctype
<
wchar_t
>
const
&
facet
=
std
::
use_facet
<
std
::
ctype
<
wchar_t
>
>
(
loc
);
std
::
wstring
result
;
result
.
resize
(
line
.
size
());
facet
.
widen
(
line
.
c_str
(),
line
.
c_str
()
+
line
.
size
(),
&
result
[
0
]);
return
result
;
}
const
std
::
wstring
Encoding
::
cp2unicode
(
const
std
::
string
&
sline
,
const
unsigned
int
nCodepage
)
...
...
@@ -89,7 +97,17 @@ const std::wstring Encoding::utf82unicode(const std::string& line)
const
std
::
string
Encoding
::
unicode2ansi
(
const
std
::
wstring
&
line
)
{
return
std
::
string
(
line
.
begin
(),
line
.
end
());
if
(
line
.
empty
())
return
std
::
string
();
std
::
locale
loc
(
""
);
std
::
ctype
<
wchar_t
>
const
&
facet
=
std
::
use_facet
<
std
::
ctype
<
wchar_t
>
>
(
loc
);
std
::
string
result
;
result
.
resize
(
line
.
size
());
facet
.
narrow
(
line
.
c_str
(),
line
.
c_str
()
+
line
.
size
(),
'?'
,
&
result
[
0
]);
return
result
;
}
const
std
::
string
Encoding
::
unicode2utf8
(
const
std
::
wstring
&
line
)
...
...
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp
View file @
7d321f25
...
...
@@ -443,7 +443,11 @@ namespace Docx2Txt
if
((
run
->
m_oRunProperty
)
&&
(
run
->
m_oRunProperty
->
m_oCaps
.
Init
())
&&
(
run
->
m_oRunProperty
->
m_oCaps
->
m_oVal
.
ToBool
()))
caps
=
true
;
std
::
wstring
wstr
;
if
(
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_t
)
if
(
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_tab
)
{
wstr
=
L"
\x09
"
;
}
else
if
(
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_t
)
{
OOX
::
Logic
::
CText
*
text
=
dynamic_cast
<
OOX
::
Logic
::
CText
*>
(
run
->
m_arrItems
[
j
]);
wstr
=
string2std_string
(
text
->
m_sText
);
...
...
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertTxt2Docx.cpp
View file @
7d321f25
...
...
@@ -73,71 +73,63 @@ namespace Txt2Docx
if
(
!
m_inputFile
.
m_listContent
.
empty
()
/*&& pFile.IsInit() && OOX::FileTypes::Document == pFile->type()*/
)
{
//pDocument = (OOX::CDocument*)pFile.operator->();
//pDocument->ClearItems();
int
percent
=
100000
;
int
step
=
800000
/
m_inputFile
.
m_listContentSize
;
// !!!!!
bool
cancel
=
Event
.
Progress
(
0
,
100000
);
if
(
cancel
)
return
;
/*
OOX::Logic::ParagraphProperty pPr;
OOX::Logic::Spacing space;
space.After = 0;
space.Line = 240;
space.LineRule = "auto";
pPr.Spacing = space;
OOX::Logic::RFonts rFont;
rFont.Ascii = "Courier New";
rFont.HAnsi = "Courier New";
rFont.Cs = "Courier New";
OOX::Logic::RunProperty rPr;
rPr.RFonts = rFont;
pPr.RunProperty = rPr;
OOX::Logic::Paragraph paragraph;
paragraph.Property = pPr;
*/
for
(
std
::
list
<
std
::
wstring
>::
iterator
line
=
m_inputFile
.
m_listContent
.
begin
();
line
!=
m_inputFile
.
m_listContent
.
end
();
line
++
)
{
//OOX::Logic::ParagraphProperty pPr;
//OOX::Logic::Spacing space;
//space.After = 0;
//space.Line = 240;
//space.LineRule = "auto";
//pPr.Spacing = space;
//OOX::Logic::RFonts rFont;
//rFont.Ascii = "Courier New";
//rFont.HAnsi = "Courier New";
//rFont.Cs = "Courier New";
ComplexTypes
::
Word
::
CSpacing
space
;
ComplexTypes
::
Word
::
CFonts
font
;
space
.
m_oAfter
.
Init
();
space
.
m_oAfter
->
FromString
(
L"0"
);
space
.
m_oLine
.
Init
();
space
.
m_oLine
->
FromString
(
L"240"
);
space
.
m_oLineRule
.
Init
();
space
.
m_oLineRule
->
SetValue
(
SimpleTypes
::
linespacingruleAuto
);
font
.
m_sAscii
.
Init
();
*
font
.
m_sAscii
=
"Courier New"
;
font
.
m_sHAnsi
.
Init
();
*
font
.
m_sHAnsi
=
"Courier New"
;
font
.
m_sCs
.
Init
();
*
font
.
m_sCs
=
"Courier New"
;
//OOX::Logic::RunProperty rPr;
//rPr.RFonts = rFont;
//pPr.RunProperty = rPr;
for
(
std
::
list
<
std
::
wstring
>::
iterator
line
=
m_inputFile
.
m_listContent
.
begin
();
line
!=
m_inputFile
.
m_listContent
.
end
();
line
++
)
{
OOX
::
Logic
::
CParagraph
*
paragraph
=
new
OOX
::
Logic
::
CParagraph
();
OOX
::
Logic
::
CParagraphProperty
*
pPr
=
new
OOX
::
Logic
::
CParagraphProperty
();
OOX
::
Logic
::
CRunProperty
*
rPr
=
new
OOX
::
Logic
::
CRunProperty
();
//OOX::Logic::Paragraph paragraph;
//paragraph.Property = pPr;
rPr
->
m_oRFonts
=
font
;
pPr
->
m_oSpacing
=
space
;
pPr
->
m_oRPr
=
*
rPr
;
OOX
::
Logic
::
CParagraph
*
temp
=
new
OOX
::
Logic
::
CParagraph
();
paragraph
->
m_arrItems
.
push_back
(
pPr
);
paragraph
->
m_oParagraphProperty
=
pPr
;
//
while
(
line
->
find
(
_T
(
"
\x08
"
))
!=
line
->
npos
)
{
line
->
erase
(
line
->
find
(
_T
(
"
\x08
"
)),
1
);
//, "");
}
if
(
line
->
length
()
>
0
)
while
(
line
->
find
(
_T
(
"
\x09
"
))
!=
line
->
npos
)
{
CString
s
=
PrepareToXML
(
*
line
);
temp
->
AddText
(
s
);
//, rPr);
int
pos
=
line
->
find
(
_T
(
"
\x09
"
));
if
(
pos
>
0
)
{
std
::
wstring
s
=
line
->
substr
(
0
,
pos
-
1
);
if
(
!
s
.
empty
())
{
OOX
::
Logic
::
CRunProperty
*
rPr_
=
new
OOX
::
Logic
::
CRunProperty
();
rPr_
->
m_oRFonts
=
font
;
paragraph
->
AddText
(
PrepareToXML
(
s
),
rPr_
);
}
}
paragraph
->
AddTab
();
line
->
erase
(
0
,
pos
+
1
);
}
pDocument
->
m_arrItems
.
push_back
(
temp
);
if
(
!
line
->
empty
())
{
paragraph
->
AddText
(
PrepareToXML
(
*
line
),
rPr
);
}
pDocument
->
m_arrItems
.
push_back
(
paragraph
);
percent
+=
step
;
cancel
=
Event
.
Progress
(
0
,
percent
);
...
...
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/File.cpp
View file @
7d321f25
...
...
@@ -63,9 +63,11 @@ namespace Txt
// listContentUnicode = file.readUnicodeWithOutBOM();
else
{
if
(
-
1
==
m_nEncoding
)
if
(
-
1
==
m_nEncoding
)
m_listContent
=
_transform
(
file
.
readAnsiOrCodePage
(),
Encoding
::
utf82unicode
);
else
else
if
(
1000
==
m_nEncoding
)
m_listContent
=
_transform
(
file
.
readAnsiOrCodePage
(),
Encoding
::
ansi2unicode
);
else
m_listContent
=
_transform2
(
file
.
readAnsiOrCodePage
(),
m_nEncoding
,
Encoding
::
cp2unicode
);
}
...
...
ASCOfficeTxtFile/Win32/TxtFormatTest/TxtFormatTest.cpp
View file @
7d321f25
...
...
@@ -17,7 +17,7 @@ int _tmain(int argc, _TCHAR* argv[])
{
if
(
argc
<
3
)
return
0
;
std
::
wstring
sXMLOptions
=
_T
(
"<Options><TXTOptions><Encoding>
2
</Encoding></TXTOptions></Options>"
);
std
::
wstring
sXMLOptions
=
_T
(
"<Options><TXTOptions><Encoding>
1000
</Encoding></TXTOptions></Options>"
);
std
::
wstring
srcFileName
=
argv
[
1
];
std
::
wstring
dstFileName
=
argv
[
2
];
...
...
@@ -39,7 +39,7 @@ int _tmain(int argc, _TCHAR* argv[])
if
(
ext_1
==
_T
(
"txt"
))
{
// txt->docx
if
(
S_OK
!=
txtFile
.
txt_LoadFromFile
(
srcFileName
,
dstTempPath
,
L""
/*sXMLOptions*/
))
if
(
S_OK
!=
txtFile
.
txt_LoadFromFile
(
srcFileName
,
dstTempPath
,
sXMLOptions
))
return
2
;
if
(
S_OK
!=
oCOfficeUtils
.
CompressFileOrDirectory
(
dstTempPath
.
c_str
(),
dstFileName
.
c_str
(),
-
1
))
...
...
Common/DocxFormat/Source/DocxFormat/Logic/Paragraph.cpp
View file @
7d321f25
...
...
@@ -313,7 +313,10 @@ namespace OOX
pText
->
m_oSpace
->
SetValue
(
SimpleTypes
::
xmlspacePreserve
);
if
(
pProperty
)
{
((
CRun
*
)
pR
)
->
m_arrItems
.
push_back
(
(
WritingElement
*
)
pProperty
);
((
CRun
*
)
pR
)
->
m_oRunProperty
=
pProperty
;
//
}
((
CRun
*
)
pR
)
->
m_arrItems
.
push_back
(
pT
);
...
...
Common/OfficeDefines.h
View file @
7d321f25
...
...
@@ -16,10 +16,11 @@ namespace TiffCompression
namespace
EncodingType
{
const
int
Utf8
=
0
;
const
int
Unicode
=
1
;
const
int
Ansi
=
2
;
const
int
BigEndian
=
3
;
//from unicodeconverter_encodings.h
const
int
Utf8
=
46
;
const
int
Unicode
=
50
;
const
int
Ansi
=
1000
;
const
int
BigEndian
=
51
;
}
#define PERMISSION_PRINT ( 1 << 2 ) //
...
...
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