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
e81517ca
Commit
e81517ca
authored
Apr 11, 2016
by
ElenaSubbotina
Committed by
Alexander Trofimov
May 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RtfFormat - правка багов по результатам тестирования
parent
33c1e271
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
505 additions
and
339 deletions
+505
-339
ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.h
ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.h
+25
-4
ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp
+10
-2
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.cpp
+4
-2
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.h
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.h
+8
-7
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp
+219
-170
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.h
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.h
+47
-16
ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp
+50
-50
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXFootnoteWriter.h
...iceRtfFile/RtfFormatLib/source/Writer/OOXFootnoteWriter.h
+24
-4
ASCOfficeRtfFile/RtfFormatTest/RtfFormatTest.cpp
ASCOfficeRtfFile/RtfFormatTest/RtfFormatTest.cpp
+28
-12
Common/DocxFormat/Source/DocxFormat/Document.h
Common/DocxFormat/Source/DocxFormat/Document.h
+90
-72
No files found.
ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.h
View file @
e81517ca
...
...
@@ -698,6 +698,21 @@ public:
oDocument
.
m_oProperty
.
m_nAnsiCodePage
=
nKeepGlobalCodepage
;
}
CString
RemoveLastUnchar
(
CString
str
)
{
int
i
=
1
;
while
(
true
)
{
if
(
i
>
str
.
GetLength
())
break
;
if
(
str
.
GetAt
(
str
.
GetLength
()
-
i
)
<=
0x20
)
str
.
Delete
(
str
.
GetLength
()
-
i
,
1
);
else
break
;
}
return
str
;
}
void
ExecuteText
(
RtfDocument
&
oDocument
,
RtfReader
&
oReader
,
CString
sText
)
{
if
(
is_panose
==
m_eInternalState
)
...
...
@@ -709,14 +724,20 @@ public:
if
(
sText
.
Find
(
';'
)
!=
-
1
)
{
sText
.
Remove
(
';'
);
m_oFont
.
m_sName
+=
sText
;
//todooo при добавлении могут быть повторы - убрать нннадо - goldwingSetting.rtf
oDocument
.
m_oFontTable
.
DirectAddItem
(
m_oFont
);
if
(
sText
.
Find
(
'&'
)
!=
0
)
//todooo выясниснить что значит &;
{
//sText.Remove('&'); //
m_oFont
.
m_sName
+=
RemoveLastUnchar
(
sText
);
}
//todooo при добавлении могут быть повторы - убрать нннадо - goldwingSetting.rtf
oDocument
.
m_oFontTable
.
DirectAddItem
(
m_oFont
);
m_oFont
.
SetDefaultRtf
();
}
else
{
m_oFont
.
m_sName
+=
sText
;
m_oFont
.
m_sName
+=
sText
.
Trim
()
;
}
}
}
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp
View file @
e81517ca
...
...
@@ -111,7 +111,11 @@ CString RtfFootnote::RenderToOOX(RenderParameter oRenderParameter)
sResult
.
Append
(
_T
(
"<w:r>"
)
);
CString
srPr
=
m_oCharProp
.
RenderToOOX
(
oRenderParameter
);
if
(
false
==
srPr
.
IsEmpty
()
)
sResult
.
AppendFormat
(
_T
(
"<w:rPr>%ls</w:rPr>"
),
srPr
.
GetBuffer
()
);
{
sResult
.
Append
(
_T
(
"<w:rPr>"
)
);
sResult
+=
srPr
;
sResult
.
Append
(
_T
(
"/w:rPr>"
)
);
}
sResult
.
AppendFormat
(
_T
(
"<w:endnoteReference w:id=
\"
%d
\"
/>"
),
nID
);
sResult
.
Append
(
_T
(
"</w:r>"
)
);
}
...
...
@@ -126,7 +130,11 @@ CString RtfFootnote::RenderToOOX(RenderParameter oRenderParameter)
sResult
.
Append
(
_T
(
"<w:r>"
)
);
CString
srPr
=
m_oCharProp
.
RenderToOOX
(
oRenderParameter
);
if
(
false
==
srPr
.
IsEmpty
()
)
sResult
.
AppendFormat
(
_T
(
"<w:rPr>%ls</w:rPr>"
),
srPr
.
GetBuffer
()
);
{
sResult
.
Append
(
_T
(
"<w:rPr>"
)
);
sResult
+=
srPr
;
sResult
.
Append
(
_T
(
"/w:rPr>"
)
);
}
sResult
.
AppendFormat
(
_T
(
"<w:footnoteReference w:id=
\"
%d
\"
/>"
),
nID
);
sResult
.
Append
(
_T
(
"</w:r>"
)
);
}
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.cpp
View file @
e81517ca
...
...
@@ -23,8 +23,10 @@ CString RtfFontTable::RenderToRtf(RenderParameter oRenderParameter)
RenderParameter
oNewParameter
=
oRenderParameter
;
oNewParameter
.
nType
=
RENDER_TO_RTF_PARAM_FONT_TBL
;
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
sResult
.
AppendFormat
(
_T
(
"%ls"
),
m_aArray
[
i
].
RenderToRtf
(
oNewParameter
).
GetBuffer
());
sResult
.
Append
(
_T
(
"}"
));
{
sResult
+=
m_aArray
[
i
].
RenderToRtf
(
oNewParameter
);
}
sResult
+=
_T
(
"}"
);
}
return
sResult
;
}
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.h
View file @
e81517ca
...
...
@@ -115,8 +115,7 @@ public:
oNewParameter
.
nType
=
RENDER_TO_RTF_PARAM_COLOR_TBL
;
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
{
CString
str
=
m_aArray
[
i
].
RenderToRtf
(
oNewParameter
);
sResult
.
AppendFormat
(
_T
(
"%ls"
),
str
.
GetBuffer
());
sResult
+=
m_aArray
[
i
].
RenderToRtf
(
oNewParameter
);
}
sResult
.
Append
(
_T
(
"}"
));
}
...
...
@@ -352,9 +351,10 @@ public:
}
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
{
CString
str
=
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
);
sResult
.
AppendFormat
(
_T
(
"{%ls}"
),
str
.
GetBuffer
()
);
}
sResult
.
Append
(
_T
(
"{"
));
sResult
.
Append
(
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
));
sResult
.
Append
(
_T
(
"}"
));
}
sResult
.
Append
(
_T
(
"}"
));
}
return
sResult
;
...
...
@@ -382,8 +382,9 @@ public:
sResult
.
Append
(
_T
(
"{
\\
*
\\
listoverridetable"
));
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
{
CString
str
=
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
);
sResult
.
AppendFormat
(
_T
(
"{%ls}"
),
str
.
GetBuffer
()
);
sResult
.
Append
(
_T
(
"{"
));
sResult
.
Append
(
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
));
sResult
.
Append
(
_T
(
"}"
));
}
sResult
.
Append
(
_T
(
"}"
));
}
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp
View file @
e81517ca
This diff is collapsed.
Click to expand it.
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.h
View file @
e81517ca
...
...
@@ -28,35 +28,66 @@
#define RENDER_OOX_BOOL( prop, sResult, sName)\
if
(
0
==
prop
)
\
sResult
.
AppendFormat
(
_T
(
"<%ls w:val=
\"
false
\"
/>"
),
sName
);
\
{
\
sResult
.
Append
(
_T
(
"<"
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
AppendFormat
(
_T
(
" w:val=
\"
false
\"
/>"
));
\
}
\
else
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
"<%ls w:val=
\"
true
\"
/>"
),
sName
);
#define RENDER_OOX_BOOL_ATTRIBUTE( prop, sResult, sName)\
if
(
0
==
prop
)
\
sResult
.
AppendFormat
(
_T
(
" %ls=
\"
0
\"
"
),
sName
);
\
else
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
" %ls=
\"
1
\"
"
),
sName
);
{
\
sResult
.
Append
(
_T
(
"<"
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
AppendFormat
(
_T
(
" w:val=
\"
true
\"
/>"
));
\
}
#define RENDER_OOX_INT( prop, sResult, sName)\
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
"<%ls w:val=
\"
%d
\"
/>"
),
sName
,
prop
);
{
\
sResult
.
Append
(
_T
(
"<"
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
AppendFormat
(
_T
(
" w:val=
\"
%d
\"
/>"
),
prop
);
\
}
#define RENDER_OOX_INT_ATTRIBUTE( prop, sResult, sName)\
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
" %ls=
\"
%d
\"
"
),
sName
,
prop
);
{
\
sResult
.
Append
(
_T
(
" "
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
AppendFormat
(
_T
(
"=
\"
%d
\"
"
),
prop
);
\
}
#define RENDER_OOX_BOOL_ATTRIBUTE( prop, sResult, sName)\
if
(
0
==
prop
)
\
{
\
sResult
.
Append
(
_T
(
" "
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
AppendFormat
(
_T
(
"=
\"
0
\"
"
));
\
}
\
else
if
(
PROP_DEF
!=
prop
)
\
{
\
sResult
.
Append
(
_T
(
" "
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
AppendFormat
(
_T
(
"=
\"
1
\"
"
));
\
}
#define RENDER_RTF_BOOL( prop, sResult, sName)\
if
(
0
==
prop
)
\
sResult
.
AppendFormat
(
_T
(
"
\\
%ls0"
),
sName
);
\
{
\
sResult
.
Append
(
_T
(
"
\\
"
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
Append
(
_T
(
"0"
)
);
\
}
\
else
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
"
\\
%ls"
),
sName
);
{
\
sResult
.
Append
(
_T
(
"
\\
"
)
);
\
sResult
.
Append
(
sName
);
\
}
#define RENDER_RTF_INT( prop, sResult, sName)\
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
"
\\
%ls%d"
),
sName
,
prop
);
{
\
sResult
.
Append
(
_T
(
"
\\
"
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
AppendFormat
(
_T
(
"%d"
),
prop
);
\
}
class
RtfFont
:
public
IRenderableProperty
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp
View file @
e81517ca
...
...
@@ -746,57 +746,57 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
return
sResult
;
}
CString
RtfSectionProperty
::
SaveFile
(
TextItemContainerPtr
oTarget
,
RenderParameter
oRenderParameter
,
bool
bHeader
)
{
OOXWriter
*
poOOXWriter
=
static_cast
<
OOXWriter
*>
(
oRenderParameter
.
poWriter
);
RtfDocument
*
poRtfDocument
=
static_cast
<
RtfDocument
*>
(
oRenderParameter
.
poDocument
);
CString
sFilename
;
if
(
true
==
bHeader
)
sFilename
.
AppendFormat
(
_T
(
"header%d.xml"
),
poRtfDocument
->
m_oIdGenerator
.
Generate_HeaderNumber
()
);
else
sFilename
.
AppendFormat
(
_T
(
"footer%d.xml"
),
poRtfDocument
->
m_oIdGenerator
.
Generate_FooterNumber
()
);
CString
sContent
;
CString
sRootName
;
if
(
true
==
bHeader
)
sRootName
=
_T
(
"w:hdr"
);
else
sRootName
=
_T
(
"w:ftr"
);
sContent
.
AppendFormat
(
_T
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
yes
\"
?>
\n
"
)
);
sContent
.
AppendFormat
(
_T
(
"<%ls xmlns:ve=
\"
http://schemas.openxmlformats.org/markup-compatibility/2006
\"
xmlns:o=
\"
urn:schemas-microsoft-com:office:office
\"
xmlns:r=
\"
http://schemas.openxmlformats.org/officeDocument/2006/relationships
\"
xmlns:m=
\"
http://schemas.openxmlformats.org/officeDocument/2006/math
\"
xmlns:v=
\"
urn:schemas-microsoft-com:vml
\"
xmlns:wp=
\"
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing
\"
xmlns:w10=
\"
urn:schemas-microsoft-com:office:word
\"
xmlns:w=
\"
http://schemas.openxmlformats.org/wordprocessingml/2006/main
\"
xmlns:wne=
\"
http://schemas.microsoft.com/office/word/2006/wordml
\"
>"
),
sRootName
.
GetBuffer
()
);
RenderParameter
oNewParameter
=
oRenderParameter
;
OOXRelsWriterPtr
oNewRelsWr
=
OOXRelsWriterPtr
(
new
OOXRelsWriter
(
sFilename
,
*
poRtfDocument
)
);
poOOXWriter
->
m_oCustomRelsWriter
.
push_back
(
oNewRelsWr
);
oNewParameter
.
poRels
=
oNewRelsWr
.
get
();
sContent
.
Append
(
oTarget
->
RenderToOOX
(
oNewParameter
)
);
sContent
.
AppendFormat
(
_T
(
"</%ls>"
),
sRootName
.
GetBuffer
()
);
{
OOXWriter
*
poOOXWriter
=
static_cast
<
OOXWriter
*>
(
oRenderParameter
.
poWriter
);
RtfDocument
*
poRtfDocument
=
static_cast
<
RtfDocument
*>
(
oRenderParameter
.
poDocument
);
CString
sFilename
;
if
(
true
==
bHeader
)
sFilename
.
AppendFormat
(
_T
(
"header%d.xml"
),
poRtfDocument
->
m_oIdGenerator
.
Generate_HeaderNumber
()
);
else
sFilename
.
AppendFormat
(
_T
(
"footer%d.xml"
),
poRtfDocument
->
m_oIdGenerator
.
Generate_FooterNumber
()
);
CString
sContent
;
CString
sRootName
;
if
(
true
==
bHeader
)
sRootName
=
_T
(
"w:hdr"
);
else
sRootName
=
_T
(
"w:ftr"
);
sContent
.
AppendFormat
(
_T
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
yes
\"
?>
\n
"
)
);
sContent
.
AppendFormat
(
_T
(
"<%ls xmlns:ve=
\"
http://schemas.openxmlformats.org/markup-compatibility/2006
\"
xmlns:o=
\"
urn:schemas-microsoft-com:office:office
\"
xmlns:r=
\"
http://schemas.openxmlformats.org/officeDocument/2006/relationships
\"
xmlns:m=
\"
http://schemas.openxmlformats.org/officeDocument/2006/math
\"
xmlns:v=
\"
urn:schemas-microsoft-com:vml
\"
xmlns:wp=
\"
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing
\"
xmlns:w10=
\"
urn:schemas-microsoft-com:office:word
\"
xmlns:w=
\"
http://schemas.openxmlformats.org/wordprocessingml/2006/main
\"
xmlns:wne=
\"
http://schemas.microsoft.com/office/word/2006/wordml
\"
>"
),
sRootName
.
GetBuffer
()
);
RenderParameter
oNewParameter
=
oRenderParameter
;
OOXRelsWriterPtr
oNewRelsWr
=
OOXRelsWriterPtr
(
new
OOXRelsWriter
(
sFilename
,
*
poRtfDocument
)
);
poOOXWriter
->
m_oCustomRelsWriter
.
push_back
(
oNewRelsWr
);
oNewParameter
.
poRels
=
oNewRelsWr
.
get
();
sContent
.
Append
(
oTarget
->
RenderToOOX
(
oNewParameter
)
);
sContent
.
AppendFormat
(
_T
(
"</%ls>"
),
sRootName
.
GetBuffer
()
);
std
::
string
sXmlUTF
=
NSFile
::
CUtf8Converter
::
GetUtf8StringFromUnicode
(
sContent
.
GetBuffer
());
CString
sFilePath
=
poOOXWriter
->
m_sTargetFolder
+
FILE_SEPARATOR_STR
+
_T
(
"word"
)
+
FILE_SEPARATOR_STR
+
sFilename
;
CFile
file
;
if
(
file
.
CreateFile
(
sFilePath
)
==
S_OK
)
{
file
.
WriteFile
((
void
*
)
sXmlUTF
.
c_str
(),
sXmlUTF
.
length
());
file
.
CloseFile
();
}
std
::
string
sXmlUTF
=
NSFile
::
CUtf8Converter
::
GetUtf8StringFromUnicode
(
sContent
.
GetBuffer
());
CString
sFilePath
=
poOOXWriter
->
m_sTargetFolder
+
FILE_SEPARATOR_STR
+
_T
(
"word"
)
+
FILE_SEPARATOR_STR
+
sFilename
;
CFile
file
;
if
(
file
.
CreateFile
(
sFilePath
)
==
S_OK
)
{
file
.
WriteFile
((
void
*
)
sXmlUTF
.
c_str
(),
sXmlUTF
.
length
());
file
.
CloseFile
();
}
CString
sContentTarget
=
_T
(
"/word/"
)
+
sFilename
;
CString
srID
;
if
(
true
==
bHeader
)
{
poOOXWriter
->
m_oContentTypes
.
AddContent
(
_T
(
"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"
),
sContentTarget
);
srID
=
poOOXWriter
->
m_oDocRels
.
AddRelationship
(
_T
(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
),
sFilename
);
}
else
{
poOOXWriter
->
m_oContentTypes
.
AddContent
(
_T
(
"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"
),
sContentTarget
);
srID
=
poOOXWriter
->
m_oDocRels
.
AddRelationship
(
_T
(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
),
sFilename
);
}
return
srID
;
CString
sContentTarget
=
_T
(
"/word/"
)
+
sFilename
;
CString
srID
;
if
(
true
==
bHeader
)
{
poOOXWriter
->
m_oContentTypes
.
AddContent
(
_T
(
"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"
),
sContentTarget
);
srID
=
poOOXWriter
->
m_oDocRels
.
AddRelationship
(
_T
(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
),
sFilename
);
}
else
{
poOOXWriter
->
m_oContentTypes
.
AddContent
(
_T
(
"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"
),
sContentTarget
);
srID
=
poOOXWriter
->
m_oDocRels
.
AddRelationship
(
_T
(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
),
sFilename
);
}
return
srID
;
}
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXFootnoteWriter.h
View file @
e81517ca
...
...
@@ -16,7 +16,12 @@ public:
CString
sFootnote
;
sFootnote
.
Append
(
_T
(
"<w:footnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
sFootnote
.
AppendFormat
(
_T
(
" w:type=
\"
%ls
\"
"
),
sType
.
GetBuffer
()
);
{
sFootnote
.
Append
(
_T
(
" w:type=
\"
"
)
);
sFootnote
+=
sType
;
sFootnote
.
Append
(
_T
(
"
\"
"
));
}
if
(
PROP_DEF
!=
nID
)
sFootnote
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
sFootnote
.
Append
(
_T
(
">"
)
);
...
...
@@ -29,9 +34,15 @@ public:
{
m_sFootnotes
.
Append
(
_T
(
"<w:footnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
m_sFootnotes
.
AppendFormat
(
_T
(
" w:type=
\"
%ls
\"
"
),
sType
.
GetBuffer
()
);
{
m_sFootnotes
.
Append
(
_T
(
" w:type=
\"
"
)
);
m_sFootnotes
+=
sType
;
m_sFootnotes
.
Append
(
_T
(
"
\"
"
));
}
if
(
PROP_DEF
!=
nID
)
{
m_sFootnotes
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
}
m_sFootnotes
.
Append
(
_T
(
">"
)
);
m_sFootnotes
.
Append
(
sText
);
m_sFootnotes
.
Append
(
_T
(
"</w:footnote>"
));
...
...
@@ -87,7 +98,11 @@ public:
CString
sEndnote
;
sEndnote
.
Append
(
_T
(
"<w:endnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
sEndnote
.
AppendFormat
(
_T
(
" w:type=
\"
%ls
\"
"
),
sType
.
GetBuffer
()
);
{
sEndnote
.
Append
(
_T
(
" w:type=
\"
"
)
);
sEndnote
+=
sType
;
sEndnote
.
Append
(
_T
(
"
\"
"
));
}
if
(
-
2
!=
nID
)
sEndnote
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
sEndnote
.
Append
(
_T
(
">"
)
);
...
...
@@ -100,7 +115,12 @@ public:
{
m_sEndnotes
.
Append
(
_T
(
"<w:endnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
m_sEndnotes
.
AppendFormat
(
_T
(
" w:type=
\"
%ls
\"
"
),
sType
.
GetBuffer
()
);
{
m_sEndnotes
.
Append
(
_T
(
" w:type=
\"
"
)
);
m_sEndnotes
+=
sType
;
m_sEndnotes
.
Append
(
_T
(
"
\"
"
));
}
if
(
-
2
!=
nID
)
m_sEndnotes
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
m_sEndnotes
.
Append
(
_T
(
">"
)
);
...
...
ASCOfficeRtfFile/RtfFormatTest/RtfFormatTest.cpp
View file @
e81517ca
...
...
@@ -3,36 +3,52 @@
#include <tchar.h>
#include "../RtfFormatLib/source/ConvertationManager.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include <algorithm>
#include <string>
int
_tmain
(
int
argc
,
_TCHAR
*
argv
[])
{
std
::
wstring
sTemp
=
_T
(
"D:
\\
test
\\
Temp"
);
std
::
wstring
srcFileName
=
argv
[
1
];
std
::
wstring
dstFileName
=
argv
[
2
];
std
::
wstring
outputDir
=
FileSystem
::
Directory
::
GetFolderPath
(
dstFileName
);
std
::
wstring
sArg_1
=
argv
[
1
];
std
::
wstring
sArg_2
=
argv
[
2
];
std
::
wstring
dstTempPath
=
FileSystem
::
Directory
::
CreateDirectoryWithUniqueName
(
outputDir
);
int
n1
=
s
Arg_1
.
rfind
(
_T
(
'.'
));
int
n2
=
sArg_2
.
rfind
(
_T
(
'.'
));
int
n1
=
s
rcFileName
.
rfind
(
_T
(
'.'
));
int
n2
=
dstFileName
.
rfind
(
_T
(
'.'
));
std
::
wstring
ext_1
=
n1
>=
0
?
s
Arg_1
.
substr
(
n1
+
1
,
sArg_1
.
length
()
-
n1
)
:
_T
(
""
);
//ext_1.MakeLower();
std
::
wstring
ext_2
=
n2
>=
0
?
sArg_2
.
substr
(
n2
+
1
,
sArg_2
.
length
()
-
n2
)
:
_T
(
""
);
//ext_2.MakeLower();
std
::
wstring
ext_1
=
n1
>=
0
?
s
rcFileName
.
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
::
transform
(
ext_1
.
begin
(),
ext_1
.
end
(),
ext_1
.
begin
(),
::
tolower
);
RtfConvertationManager
rtfConvert
;
rtfConvert
.
m_sTempFolder
=
sTemp
;
rtfConvert
.
m_sTempFolder
=
dstTempPath
;
COfficeUtils
oCOfficeUtils
(
NULL
);
if
(
ext_1
==
_T
(
"rtf"
))
{
// rtf->docx
rtfConvert
.
ConvertRtfToOOX
(
sArg_1
,
sArg_2
);
{
// rtf->docx
rtfConvert
.
ConvertRtfToOOX
(
srcFileName
,
dstTempPath
);
if
(
S_OK
!=
oCOfficeUtils
.
CompressFileOrDirectory
(
dstTempPath
.
c_str
(),
dstFileName
.
c_str
(),
-
1
))
return
S_FALSE
;
}
if
(
ext_2
==
_T
(
"rtf"
))
{
// docx->rtf
rtfConvert
.
ConvertOOXToRtf
(
sArg_2
,
sArg_1
);
{
// docx->rtf
if
(
S_OK
!=
oCOfficeUtils
.
ExtractToDirectory
(
srcFileName
.
c_str
(),
dstTempPath
.
c_str
(),
NULL
,
0
))
return
S_FALSE
;
rtfConvert
.
ConvertOOXToRtf
(
dstTempPath
,
srcFileName
);
}
FileSystem
::
Directory
::
DeleteDirectory
(
dstTempPath
);
return
0
;
}
Common/DocxFormat/Source/DocxFormat/Document.h
View file @
e81517ca
...
...
@@ -187,6 +187,93 @@ namespace OOX
CPath
oRootPath
;
read
(
oRootPath
,
oPath
);
}
void
CreateElements
(
XmlUtils
::
CXmlLiteReader
&
oReader
,
int
Depth
)
{
while
(
oReader
.
ReadNextSiblingNode
(
Depth
)
)
{
CWCharWrapper
sName
=
oReader
.
GetName
();
WritingElement
*
pItem
=
NULL
;
/*if ( _T("w:altChunk") == sName )
pItem = new Logic::CAltChunk( oReader );
else*/
if
(
_T
(
"w:bookmarkEnd"
)
==
sName
)
pItem
=
new
Logic
::
CBookmarkEnd
(
oReader
);
else
if
(
_T
(
"w:bookmarkStart"
)
==
sName
)
pItem
=
new
Logic
::
CBookmarkStart
(
oReader
);
else
if
(
_T
(
"w:commentRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCommentRangeEnd
(
oReader
);
else
if
(
_T
(
"w:commentRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCommentRangeStart
(
oReader
);
//else if ( _T("w:customXml") == sName )
// pItem = new Logic::CCustomXml( oReader );
else
if
(
_T
(
"w:customXmlDelRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlDelRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlDelRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlDelRangeStart
(
oReader
);
else
if
(
_T
(
"w:customXmlInsRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlInsRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlInsRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlInsRangeStart
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveFromRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveFromRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveFromRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveFromRangeStart
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveToRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveToRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveToRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveToRangeStart
(
oReader
);
else
if
(
_T
(
"w:del"
)
==
sName
)
pItem
=
new
Logic
::
CDel
(
oReader
);
else
if
(
_T
(
"w:ins"
)
==
sName
)
pItem
=
new
Logic
::
CIns
(
oReader
);
//else if ( _T("w:moveFrom") == sName )
// pItem = new Logic::CMoveFrom( oReader );
else
if
(
_T
(
"w:moveFromRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeEnd
(
oReader
);
else
if
(
_T
(
"w:moveFromRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeStart
(
oReader
);
//else if ( _T("w:moveTo") == sName )
// pItem = new Logic::CMoveTo( oReader );
else
if
(
_T
(
"w:moveToRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeEnd
(
oReader
);
else
if
(
_T
(
"w:moveToRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeStart
(
oReader
);
else
if
(
_T
(
"m:oMath"
)
==
sName
)
pItem
=
new
Logic
::
COMath
(
oReader
);
else
if
(
_T
(
"m:oMathPara"
)
==
sName
)
pItem
=
new
Logic
::
COMathPara
(
oReader
);
else
if
(
_T
(
"w:p"
)
==
sName
)
pItem
=
new
Logic
::
CParagraph
(
oReader
);
else
if
(
_T
(
"w:permEnd"
)
==
sName
)
pItem
=
new
Logic
::
CPermEnd
(
oReader
);
else
if
(
_T
(
"w:permStart"
)
==
sName
)
pItem
=
new
Logic
::
CPermStart
(
oReader
);
else
if
(
_T
(
"w:proofErr"
)
==
sName
)
pItem
=
new
Logic
::
CProofErr
(
oReader
);
else
if
(
_T
(
"w:sdt"
)
==
sName
)
pItem
=
new
Logic
::
CSdt
(
oReader
);
else
if
(
_T
(
"w:sectPr"
)
==
sName
)
m_oSectPr
=
oReader
;
else
if
(
_T
(
"w:tbl"
)
==
sName
)
pItem
=
new
Logic
::
CTbl
(
oReader
);
else
if
(
_T
(
"wx:sect"
)
==
sName
&&
!
oReader
.
IsEmptyNode
())
{
int
nWxSectDepth
=
oReader
.
GetDepth
();
CreateElements
(
oReader
,
nWxSectDepth
);
}
else
if
(
_T
(
"wx:pBdrGroup"
)
==
sName
&&
!
oReader
.
IsEmptyNode
())
{
int
nWxBdrGroupDepth
=
oReader
.
GetDepth
();
CreateElements
(
oReader
,
nWxBdrGroupDepth
);
}
if
(
pItem
)
m_arrItems
.
push_back
(
pItem
);
}
}
virtual
void
read
(
const
CPath
&
oRootPath
,
const
CPath
&
oPath
)
{
m_oReadPath
=
oPath
;
...
...
@@ -204,7 +291,7 @@ namespace OOX
return
;
CWCharWrapper
sName
=
oReader
.
GetName
();
if
(
_T
(
"w:document"
)
==
sName
)
if
(
_T
(
"w:document"
)
==
sName
||
_T
(
"w:wordDocument"
)
==
sName
)
{
ReadAttributes
(
oReader
);
...
...
@@ -218,77 +305,8 @@ namespace OOX
if
(
_T
(
"w:body"
)
==
sName
&&
!
oReader
.
IsEmptyNode
()
)
{
int
nBodyDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nBodyDepth
)
)
{
sName
=
oReader
.
GetName
();
WritingElement
*
pItem
=
NULL
;
/*if ( _T("w:altChunk") == sName )
pItem = new Logic::CAltChunk( oReader );
else*/
if
(
_T
(
"w:bookmarkEnd"
)
==
sName
)
pItem
=
new
Logic
::
CBookmarkEnd
(
oReader
);
else
if
(
_T
(
"w:bookmarkStart"
)
==
sName
)
pItem
=
new
Logic
::
CBookmarkStart
(
oReader
);
else
if
(
_T
(
"w:commentRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCommentRangeEnd
(
oReader
);
else
if
(
_T
(
"w:commentRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCommentRangeStart
(
oReader
);
//else if ( _T("w:customXml") == sName )
// pItem = new Logic::CCustomXml( oReader );
else
if
(
_T
(
"w:customXmlDelRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlDelRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlDelRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlDelRangeStart
(
oReader
);
else
if
(
_T
(
"w:customXmlInsRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlInsRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlInsRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlInsRangeStart
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveFromRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveFromRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveFromRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveFromRangeStart
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveToRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveToRangeEnd
(
oReader
);
else
if
(
_T
(
"w:customXmlMoveToRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CCustomXmlMoveToRangeStart
(
oReader
);
else
if
(
_T
(
"w:del"
)
==
sName
)
pItem
=
new
Logic
::
CDel
(
oReader
);
else
if
(
_T
(
"w:ins"
)
==
sName
)
pItem
=
new
Logic
::
CIns
(
oReader
);
//else if ( _T("w:moveFrom") == sName )
// pItem = new Logic::CMoveFrom( oReader );
else
if
(
_T
(
"w:moveFromRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeEnd
(
oReader
);
else
if
(
_T
(
"w:moveFromRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeStart
(
oReader
);
//else if ( _T("w:moveTo") == sName )
// pItem = new Logic::CMoveTo( oReader );
else
if
(
_T
(
"w:moveToRangeEnd"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeEnd
(
oReader
);
else
if
(
_T
(
"w:moveToRangeStart"
)
==
sName
)
pItem
=
new
Logic
::
CMoveToRangeStart
(
oReader
);
else
if
(
_T
(
"m:oMath"
)
==
sName
)
pItem
=
new
Logic
::
COMath
(
oReader
);
else
if
(
_T
(
"m:oMathPara"
)
==
sName
)
pItem
=
new
Logic
::
COMathPara
(
oReader
);
else
if
(
_T
(
"w:p"
)
==
sName
)
pItem
=
new
Logic
::
CParagraph
(
oReader
);
else
if
(
_T
(
"w:permEnd"
)
==
sName
)
pItem
=
new
Logic
::
CPermEnd
(
oReader
);
else
if
(
_T
(
"w:permStart"
)
==
sName
)
pItem
=
new
Logic
::
CPermStart
(
oReader
);
else
if
(
_T
(
"w:proofErr"
)
==
sName
)
pItem
=
new
Logic
::
CProofErr
(
oReader
);
else
if
(
_T
(
"w:sdt"
)
==
sName
)
pItem
=
new
Logic
::
CSdt
(
oReader
);
else
if
(
_T
(
"w:sectPr"
)
==
sName
)
m_oSectPr
=
oReader
;
else
if
(
_T
(
"w:tbl"
)
==
sName
)
pItem
=
new
Logic
::
CTbl
(
oReader
);
if
(
pItem
)
m_arrItems
.
push_back
(
pItem
);
}
CreateElements
(
oReader
,
nBodyDepth
);
}
else
if
(
_T
(
"w:background"
)
==
sName
)
m_oBackground
=
oReader
;
...
...
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