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
8efed345
Commit
8efed345
authored
Jul 24, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug #35412
parent
f5dcb1be
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
33 deletions
+54
-33
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.cpp
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.cpp
+10
-13
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp
+44
-13
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp
+0
-7
No files found.
ASCOfficeTxtFile/TxtFormatTest/TxtFormatTest.cpp
View file @
8efed345
...
@@ -47,23 +47,20 @@
...
@@ -47,23 +47,20 @@
int
_tmain
(
int
argc
,
_TCHAR
*
argv
[])
int
_tmain
(
int
argc
,
_TCHAR
*
argv
[])
{
{
if
(
argc
<
3
)
return
0
;
if
(
argc
<
2
)
return
0
;
std
::
wstring
sXMLOptions
=
_T
(
"<Options><TXTOptions><Encoding>
100
0</Encoding></TXTOptions></Options>"
);
std
::
wstring
sXMLOptions
=
_T
(
"<Options><TXTOptions><Encoding>
5
0</Encoding></TXTOptions></Options>"
);
std
::
wstring
srcFileName
=
argv
[
1
];
std
::
wstring
srcFileName
=
argv
[
1
];
std
::
wstring
dstFileName
=
argv
[
2
];
int
n1
=
srcFileName
.
rfind
(
_T
(
'.'
));
std
::
wstring
outputDir
=
NSDirectory
::
GetFolderPath
(
dstFileName
);
std
::
wstring
ext_1
=
n1
>=
0
?
srcFileName
.
substr
(
n1
+
1
,
srcFileName
.
length
()
-
n1
)
:
_T
(
""
);
std
::
wstring
dstTempPath
=
NSDirectory
::
CreateDirectoryWithUniqueName
(
outputDir
);
int
n1
=
srcFileName
.
rfind
(
L"."
);
std
::
transform
(
ext_1
.
begin
(),
ext_1
.
end
(),
ext_1
.
begin
(),
::
tolower
);
int
n2
=
dstFileName
.
rfind
(
L"."
);
std
::
wstring
ext_1
=
n1
>=
0
?
srcFileName
.
substr
(
n1
+
1
,
srcFileName
.
length
()
-
n1
)
:
L""
;
//ext_1.MakeLower();
std
::
wstring
dstFileName
=
argc
>
2
?
argv
[
2
]
:
srcFileName
+
L"_my."
+
(
ext_1
==
L"txt"
?
L"docx"
:
L"txt"
);
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
);
std
::
wstring
outputDir
=
NSDirectory
::
GetFolderPath
(
dstFileName
);
std
::
wstring
dstTempPath
=
NSDirectory
::
CreateDirectoryWithUniqueName
(
outputDir
);
CTxtXmlFile
txtFile
;
CTxtXmlFile
txtFile
;
...
@@ -77,7 +74,7 @@ int _tmain(int argc, _TCHAR* argv[])
...
@@ -77,7 +74,7 @@ int _tmain(int argc, _TCHAR* argv[])
if
(
S_OK
!=
oCOfficeUtils
.
CompressFileOrDirectory
(
dstTempPath
.
c_str
(),
dstFileName
.
c_str
(),
-
1
))
if
(
S_OK
!=
oCOfficeUtils
.
CompressFileOrDirectory
(
dstTempPath
.
c_str
(),
dstFileName
.
c_str
(),
-
1
))
return
S_FALSE
;
return
S_FALSE
;
}
}
if
(
ext_2
==
L"txt"
)
else
{
{
// docx->txt
// docx->txt
if
(
S_OK
!=
oCOfficeUtils
.
ExtractToDirectory
(
srcFileName
.
c_str
(),
dstTempPath
.
c_str
(),
NULL
,
0
))
if
(
S_OK
!=
oCOfficeUtils
.
ExtractToDirectory
(
srcFileName
.
c_str
(),
dstTempPath
.
c_str
(),
NULL
,
0
))
...
...
ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp
View file @
8efed345
...
@@ -85,7 +85,7 @@ namespace Docx2Txt
...
@@ -85,7 +85,7 @@ namespace Docx2Txt
OOX
::
CDocument
*
pDocument
,
OOX
::
CNumbering
*
pNumbering
,
OOX
::
CStyles
*
pStyles
);
OOX
::
CDocument
*
pDocument
,
OOX
::
CNumbering
*
pNumbering
,
OOX
::
CStyles
*
pStyles
);
size_t
NoteCount
;
size_t
NoteCount
;
std
::
list
<
std
::
wstring
>
Notes
;
std
::
map
<
std
::
wstring
,
std
::
list
<
std
::
wstring
>
>
Notes
;
static
std
::
wstring
IntToLowerLetter
(
int
number
);
static
std
::
wstring
IntToLowerLetter
(
int
number
);
static
std
::
wstring
IntToUpperLetter
(
int
number
);
static
std
::
wstring
IntToUpperLetter
(
int
number
);
...
@@ -198,10 +198,20 @@ namespace Docx2Txt
...
@@ -198,10 +198,20 @@ namespace Docx2Txt
if
(
NoteCount
!=
0
)
if
(
NoteCount
!=
0
)
{
{
m_outputFile
.
m_listContent
.
push_back
(
_T
(
"---------------------------"
));
m_outputFile
.
m_listContent
.
push_back
(
L""
);
for
(
std
::
list
<
std
::
wstring
>::
const_iterator
iter
=
Notes
.
begin
();
iter
!=
Notes
.
end
();
iter
++
)
m_outputFile
.
m_listContent
.
push_back
(
L"---------------------------"
);
for
(
std
::
map
<
std
::
wstring
,
std
::
list
<
std
::
wstring
>>::
const_iterator
iter_map
=
Notes
.
begin
();
iter_map
!=
Notes
.
end
();
iter_map
++
)
{
bool
bFirst
=
true
;
for
(
std
::
list
<
std
::
wstring
>::
const_iterator
iter
=
iter_map
->
second
.
begin
();
iter
!=
iter_map
->
second
.
end
();
iter
++
)
{
{
m_outputFile
.
m_listContent
.
push_back
(
*
iter
);
if
(
bFirst
)
m_outputFile
.
m_listContent
.
push_back
(
iter_map
->
first
+
L" "
+
*
iter
);
else
m_outputFile
.
m_listContent
.
push_back
(
*
iter
);
bFirst
=
false
;
}
}
}
}
}
}
}
...
@@ -491,31 +501,52 @@ namespace Docx2Txt
...
@@ -491,31 +501,52 @@ namespace Docx2Txt
if
(
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_footnoteReference
||
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_endnoteReference
)
if
(
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_footnoteReference
||
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_endnoteReference
)
{
// todooo Ref ????
{
// todooo Ref ????
std
::
list
<
std
::
wstring
>
notes_content
;
OOX
::
Logic
::
CFootnoteReference
*
footnote_ref
=
dynamic_cast
<
OOX
::
Logic
::
CFootnoteReference
*>
(
run
->
m_arrItems
[
j
]);
OOX
::
Logic
::
CEndnoteReference
*
endnote_ref
=
dynamic_cast
<
OOX
::
Logic
::
CEndnoteReference
*>
(
run
->
m_arrItems
[
j
]);
NoteCount
++
;
NoteCount
++
;
std
::
wstring
s
=
_T
(
"["
)
+
ToWString
(
NoteCount
)
+
_T
(
"]"
);
Notes
.
push_back
(
s
);
if
(
footnote_ref
)
if
(
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_footnoteReference
)
{
{
smart_ptr
<
OOX
::
File
>
pFile
=
pDocument
->
Find
(
OOX
::
FileTypes
::
FootNote
);
smart_ptr
<
OOX
::
File
>
pFile
=
pDocument
->
Find
(
OOX
::
FileTypes
::
FootNote
);
if
(
pFile
.
IsInit
())
if
(
pFile
.
IsInit
())
{
{
OOX
::
CFootnotes
*
pFootnotes
=
(
OOX
::
CFootnotes
*
)
pFile
.
operator
->
();
OOX
::
CFootnotes
*
pFootnotes
=
(
OOX
::
CFootnotes
*
)
pFile
.
operator
->
();
for
(
long
r
=
0
;
r
<
pFootnotes
->
m_arrFootnote
.
size
();
r
++
)
for
(
size_t
r
=
0
;
r
<
pFootnotes
->
m_arrFootnote
.
size
();
r
++
)
convert
(
pFootnotes
->
m_arrFootnote
[
r
]
->
m_arrItems
,
Notes
,
Event
,
false
,
pDocument
,
pNumbering
,
pStyles
);
{
OOX
::
CFtnEdn
*
note
=
dynamic_cast
<
OOX
::
CFtnEdn
*>
(
pFootnotes
->
m_arrFootnote
[
r
]);
if
(
note
&&
note
->
m_oId
==
footnote_ref
->
m_oId
)
{
convert
(
pFootnotes
->
m_arrFootnote
[
r
]
->
m_arrItems
,
notes_content
,
Event
,
false
,
pDocument
,
pNumbering
,
pStyles
);
}
}
}
}
Notes
.
insert
(
std
::
make_pair
(
ToWString
(
NoteCount
),
notes_content
));
}
}
else
if
(
run
->
m_arrItems
[
j
]
->
getType
()
==
OOX
::
et_w_endnoteReference
)
if
(
endnote_ref
)
{
{
smart_ptr
<
OOX
::
File
>
pFile
=
pDocument
->
Find
(
OOX
::
FileTypes
::
EndNote
);
smart_ptr
<
OOX
::
File
>
pFile
=
pDocument
->
Find
(
OOX
::
FileTypes
::
EndNote
);
if
(
pFile
.
IsInit
())
if
(
pFile
.
IsInit
())
{
{
OOX
::
CEndnotes
*
pEndnotes
=
(
OOX
::
CEndnotes
*
)
pFile
.
operator
->
();
OOX
::
CEndnotes
*
pEndnotes
=
(
OOX
::
CEndnotes
*
)
pFile
.
operator
->
();
for
(
long
r
=
0
;
r
<
pEndnotes
->
m_arrEndnote
.
size
();
r
++
)
convert
(
pEndnotes
->
m_arrEndnote
[
r
]
->
m_arrItems
,
Notes
,
Event
,
false
,
pDocument
,
pNumbering
,
pStyles
);
for
(
size_t
r
=
0
;
r
<
pEndnotes
->
m_arrEndnote
.
size
();
r
++
)
{
OOX
::
CFtnEdn
*
note
=
dynamic_cast
<
OOX
::
CFtnEdn
*>
(
pEndnotes
->
m_arrEndnote
[
r
]);
if
(
note
&&
note
->
m_oId
==
endnote_ref
->
m_oId
)
{
convert
(
pEndnotes
->
m_arrEndnote
[
r
]
->
m_arrItems
,
notes_content
,
Event
,
false
,
pDocument
,
pNumbering
,
pStyles
);
}
}
}
}
Notes
.
insert
(
std
::
make_pair
(
ToWString
(
NoteCount
),
notes_content
));
}
}
wstr
.
replace
(
wstr
.
find
(
_T
(
"_"
)),
1
,
ToWString
(
NoteCount
))
;
wstr
+=
L"["
+
ToWString
(
NoteCount
)
+
L"]"
;
;
}
}
line
+=
wstr
;
line
+=
wstr
;
}
}
...
...
ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp
View file @
8efed345
...
@@ -104,13 +104,6 @@ static int ParseTxtOptions(const std::wstring & sXmlOptions)
...
@@ -104,13 +104,6 @@ static int ParseTxtOptions(const std::wstring & sXmlOptions)
HRESULT
CTxtXmlFile
::
txt_LoadFromFile
(
const
std
::
wstring
&
sSrcFileName
,
const
std
::
wstring
&
sDstPath
,
const
std
::
wstring
&
sXMLOptions
)
HRESULT
CTxtXmlFile
::
txt_LoadFromFile
(
const
std
::
wstring
&
sSrcFileName
,
const
std
::
wstring
&
sDstPath
,
const
std
::
wstring
&
sXMLOptions
)
{
{
//проверка на структуру xml - если что не так выкинет быстро
//HRESULT hr = xml_LoadFromFile(sSrcFileName, sDstPath, sXMLOptions);
//if(hr == S_OK)
// return S_OK;
//As Text
Writers
::
FileWriter
*
pDocxWriter
=
new
Writers
::
FileWriter
(
sDstPath
,
L""
,
true
,
1
,
false
,
NULL
,
L""
);
Writers
::
FileWriter
*
pDocxWriter
=
new
Writers
::
FileWriter
(
sDstPath
,
L""
,
true
,
1
,
false
,
NULL
,
L""
);
if
(
pDocxWriter
==
NULL
)
return
S_FALSE
;
if
(
pDocxWriter
==
NULL
)
return
S_FALSE
;
...
...
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