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
Show 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:
...
@@ -698,6 +698,21 @@ public:
oDocument
.
m_oProperty
.
m_nAnsiCodePage
=
nKeepGlobalCodepage
;
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
)
void
ExecuteText
(
RtfDocument
&
oDocument
,
RtfReader
&
oReader
,
CString
sText
)
{
{
if
(
is_panose
==
m_eInternalState
)
if
(
is_panose
==
m_eInternalState
)
...
@@ -709,14 +724,20 @@ public:
...
@@ -709,14 +724,20 @@ public:
if
(
sText
.
Find
(
';'
)
!=
-
1
)
if
(
sText
.
Find
(
';'
)
!=
-
1
)
{
{
sText
.
Remove
(
';'
);
sText
.
Remove
(
';'
);
m_oFont
.
m_sName
+=
sText
;
if
(
sText
.
Find
(
'&'
)
!=
0
)
//todooo выясниснить что значит &;
{
//sText.Remove('&'); //
m_oFont
.
m_sName
+=
RemoveLastUnchar
(
sText
);
}
//todooo при добавлении могут быть повторы - убрать нннадо - goldwingSetting.rtf
//todooo при добавлении могут быть повторы - убрать нннадо - goldwingSetting.rtf
oDocument
.
m_oFontTable
.
DirectAddItem
(
m_oFont
);
oDocument
.
m_oFontTable
.
DirectAddItem
(
m_oFont
);
m_oFont
.
SetDefaultRtf
();
m_oFont
.
SetDefaultRtf
();
}
}
else
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)
...
@@ -111,7 +111,11 @@ CString RtfFootnote::RenderToOOX(RenderParameter oRenderParameter)
sResult
.
Append
(
_T
(
"<w:r>"
)
);
sResult
.
Append
(
_T
(
"<w:r>"
)
);
CString
srPr
=
m_oCharProp
.
RenderToOOX
(
oRenderParameter
);
CString
srPr
=
m_oCharProp
.
RenderToOOX
(
oRenderParameter
);
if
(
false
==
srPr
.
IsEmpty
()
)
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
.
AppendFormat
(
_T
(
"<w:endnoteReference w:id=
\"
%d
\"
/>"
),
nID
);
sResult
.
Append
(
_T
(
"</w:r>"
)
);
sResult
.
Append
(
_T
(
"</w:r>"
)
);
}
}
...
@@ -126,7 +130,11 @@ CString RtfFootnote::RenderToOOX(RenderParameter oRenderParameter)
...
@@ -126,7 +130,11 @@ CString RtfFootnote::RenderToOOX(RenderParameter oRenderParameter)
sResult
.
Append
(
_T
(
"<w:r>"
)
);
sResult
.
Append
(
_T
(
"<w:r>"
)
);
CString
srPr
=
m_oCharProp
.
RenderToOOX
(
oRenderParameter
);
CString
srPr
=
m_oCharProp
.
RenderToOOX
(
oRenderParameter
);
if
(
false
==
srPr
.
IsEmpty
()
)
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
.
AppendFormat
(
_T
(
"<w:footnoteReference w:id=
\"
%d
\"
/>"
),
nID
);
sResult
.
Append
(
_T
(
"</w:r>"
)
);
sResult
.
Append
(
_T
(
"</w:r>"
)
);
}
}
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.cpp
View file @
e81517ca
...
@@ -23,8 +23,10 @@ CString RtfFontTable::RenderToRtf(RenderParameter oRenderParameter)
...
@@ -23,8 +23,10 @@ CString RtfFontTable::RenderToRtf(RenderParameter oRenderParameter)
RenderParameter
oNewParameter
=
oRenderParameter
;
RenderParameter
oNewParameter
=
oRenderParameter
;
oNewParameter
.
nType
=
RENDER_TO_RTF_PARAM_FONT_TBL
;
oNewParameter
.
nType
=
RENDER_TO_RTF_PARAM_FONT_TBL
;
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
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
;
return
sResult
;
}
}
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.h
View file @
e81517ca
...
@@ -115,8 +115,7 @@ public:
...
@@ -115,8 +115,7 @@ public:
oNewParameter
.
nType
=
RENDER_TO_RTF_PARAM_COLOR_TBL
;
oNewParameter
.
nType
=
RENDER_TO_RTF_PARAM_COLOR_TBL
;
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
{
{
CString
str
=
m_aArray
[
i
].
RenderToRtf
(
oNewParameter
);
sResult
+=
m_aArray
[
i
].
RenderToRtf
(
oNewParameter
);
sResult
.
AppendFormat
(
_T
(
"%ls"
),
str
.
GetBuffer
());
}
}
sResult
.
Append
(
_T
(
"}"
));
sResult
.
Append
(
_T
(
"}"
));
}
}
...
@@ -352,8 +351,9 @@ public:
...
@@ -352,8 +351,9 @@ public:
}
}
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
{
{
CString
str
=
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
);
sResult
.
Append
(
_T
(
"{"
));
sResult
.
AppendFormat
(
_T
(
"{%ls}"
),
str
.
GetBuffer
()
);
sResult
.
Append
(
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
));
sResult
.
Append
(
_T
(
"}"
));
}
}
sResult
.
Append
(
_T
(
"}"
));
sResult
.
Append
(
_T
(
"}"
));
}
}
...
@@ -382,8 +382,9 @@ public:
...
@@ -382,8 +382,9 @@ public:
sResult
.
Append
(
_T
(
"{
\\
*
\\
listoverridetable"
));
sResult
.
Append
(
_T
(
"{
\\
*
\\
listoverridetable"
));
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
{
{
CString
str
=
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
);
sResult
.
Append
(
_T
(
"{"
));
sResult
.
AppendFormat
(
_T
(
"{%ls}"
),
str
.
GetBuffer
()
);
sResult
.
Append
(
m_aArray
[
i
].
RenderToRtf
(
oRenderParameter
));
sResult
.
Append
(
_T
(
"}"
));
}
}
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 @@
...
@@ -28,35 +28,66 @@
#define RENDER_OOX_BOOL( prop, sResult, sName)\
#define RENDER_OOX_BOOL( prop, sResult, sName)\
if
(
0
==
prop
)
\
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
)
\
else
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
"<%ls w:val=
\"
true
\"
/>"
),
sName
);
{
\
sResult
.
Append
(
_T
(
"<"
)
);
\
#define RENDER_OOX_BOOL_ATTRIBUTE( prop, sResult, sName)\
sResult
.
Append
(
sName
);
\
if
(
0
==
prop
)
\
sResult
.
AppendFormat
(
_T
(
" w:val=
\"
true
\"
/>"
));
\
sResult
.
AppendFormat
(
_T
(
" %ls=
\"
0
\"
"
),
sName
);
\
}
else
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
" %ls=
\"
1
\"
"
),
sName
);
#define RENDER_OOX_INT( prop, sResult, sName)\
#define RENDER_OOX_INT( prop, sResult, sName)\
if
(
PROP_DEF
!=
prop
)
\
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)\
#define RENDER_OOX_INT_ATTRIBUTE( prop, sResult, sName)\
if
(
PROP_DEF
!=
prop
)
\
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)\
#define RENDER_RTF_BOOL( prop, sResult, sName)\
if
(
0
==
prop
)
\
if
(
0
==
prop
)
\
sResult
.
AppendFormat
(
_T
(
"
\\
%ls0"
),
sName
);
\
{
\
sResult
.
Append
(
_T
(
"
\\
"
)
);
\
sResult
.
Append
(
sName
);
\
sResult
.
Append
(
_T
(
"0"
)
);
\
}
\
else
if
(
PROP_DEF
!=
prop
)
\
else
if
(
PROP_DEF
!=
prop
)
\
sResult
.
AppendFormat
(
_T
(
"
\\
%ls"
),
sName
);
{
\
sResult
.
Append
(
_T
(
"
\\
"
)
);
\
sResult
.
Append
(
sName
);
\
}
#define RENDER_RTF_INT( prop, sResult, sName)\
#define RENDER_RTF_INT( prop, sResult, sName)\
if
(
PROP_DEF
!=
prop
)
\
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
class
RtfFont
:
public
IRenderableProperty
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp
View file @
e81517ca
...
@@ -746,7 +746,7 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
...
@@ -746,7 +746,7 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
return
sResult
;
return
sResult
;
}
}
CString
RtfSectionProperty
::
SaveFile
(
TextItemContainerPtr
oTarget
,
RenderParameter
oRenderParameter
,
bool
bHeader
)
CString
RtfSectionProperty
::
SaveFile
(
TextItemContainerPtr
oTarget
,
RenderParameter
oRenderParameter
,
bool
bHeader
)
{
{
OOXWriter
*
poOOXWriter
=
static_cast
<
OOXWriter
*>
(
oRenderParameter
.
poWriter
);
OOXWriter
*
poOOXWriter
=
static_cast
<
OOXWriter
*>
(
oRenderParameter
.
poWriter
);
RtfDocument
*
poRtfDocument
=
static_cast
<
RtfDocument
*>
(
oRenderParameter
.
poDocument
);
RtfDocument
*
poRtfDocument
=
static_cast
<
RtfDocument
*>
(
oRenderParameter
.
poDocument
);
...
@@ -799,4 +799,4 @@ CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParame
...
@@ -799,4 +799,4 @@ CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParame
srID
=
poOOXWriter
->
m_oDocRels
.
AddRelationship
(
_T
(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
),
sFilename
);
srID
=
poOOXWriter
->
m_oDocRels
.
AddRelationship
(
_T
(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
),
sFilename
);
}
}
return
srID
;
return
srID
;
}
}
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXFootnoteWriter.h
View file @
e81517ca
...
@@ -16,7 +16,12 @@ public:
...
@@ -16,7 +16,12 @@ public:
CString
sFootnote
;
CString
sFootnote
;
sFootnote
.
Append
(
_T
(
"<w:footnote"
)
);
sFootnote
.
Append
(
_T
(
"<w:footnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
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
)
if
(
PROP_DEF
!=
nID
)
sFootnote
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
sFootnote
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
sFootnote
.
Append
(
_T
(
">"
)
);
sFootnote
.
Append
(
_T
(
">"
)
);
...
@@ -29,9 +34,15 @@ public:
...
@@ -29,9 +34,15 @@ public:
{
{
m_sFootnotes
.
Append
(
_T
(
"<w:footnote"
)
);
m_sFootnotes
.
Append
(
_T
(
"<w:footnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
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
)
if
(
PROP_DEF
!=
nID
)
{
m_sFootnotes
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
m_sFootnotes
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
}
m_sFootnotes
.
Append
(
_T
(
">"
)
);
m_sFootnotes
.
Append
(
_T
(
">"
)
);
m_sFootnotes
.
Append
(
sText
);
m_sFootnotes
.
Append
(
sText
);
m_sFootnotes
.
Append
(
_T
(
"</w:footnote>"
));
m_sFootnotes
.
Append
(
_T
(
"</w:footnote>"
));
...
@@ -87,7 +98,11 @@ public:
...
@@ -87,7 +98,11 @@ public:
CString
sEndnote
;
CString
sEndnote
;
sEndnote
.
Append
(
_T
(
"<w:endnote"
)
);
sEndnote
.
Append
(
_T
(
"<w:endnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
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
)
if
(
-
2
!=
nID
)
sEndnote
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
sEndnote
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
sEndnote
.
Append
(
_T
(
">"
)
);
sEndnote
.
Append
(
_T
(
">"
)
);
...
@@ -100,7 +115,12 @@ public:
...
@@ -100,7 +115,12 @@ public:
{
{
m_sEndnotes
.
Append
(
_T
(
"<w:endnote"
)
);
m_sEndnotes
.
Append
(
_T
(
"<w:endnote"
)
);
if
(
false
==
sType
.
IsEmpty
()
)
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
)
if
(
-
2
!=
nID
)
m_sEndnotes
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
m_sEndnotes
.
AppendFormat
(
_T
(
" w:id=
\"
%d
\"
"
),
nID
);
m_sEndnotes
.
Append
(
_T
(
">"
)
);
m_sEndnotes
.
Append
(
_T
(
">"
)
);
...
...
ASCOfficeRtfFile/RtfFormatTest/RtfFormatTest.cpp
View file @
e81517ca
...
@@ -3,36 +3,52 @@
...
@@ -3,36 +3,52 @@
#include <tchar.h>
#include <tchar.h>
#include "../RtfFormatLib/source/ConvertationManager.h"
#include "../RtfFormatLib/source/ConvertationManager.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include <algorithm>
#include <algorithm>
#include <string>
#include <string>
int
_tmain
(
int
argc
,
_TCHAR
*
argv
[])
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
dstTempPath
=
FileSystem
::
Directory
::
CreateDirectoryWithUniqueName
(
outputDir
);
std
::
wstring
sArg_2
=
argv
[
2
];
int
n1
=
s
Arg_1
.
rfind
(
_T
(
'.'
));
int
n1
=
s
rcFileName
.
rfind
(
_T
(
'.'
));
int
n2
=
sArg_2
.
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_1
=
n1
>=
0
?
s
rcFileName
.
substr
(
n1
+
1
,
srcFileName
.
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_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
);
std
::
transform
(
ext_1
.
begin
(),
ext_1
.
end
(),
ext_1
.
begin
(),
::
tolower
);
RtfConvertationManager
rtfConvert
;
RtfConvertationManager
rtfConvert
;
rtfConvert
.
m_sTempFolder
=
sTemp
;
rtfConvert
.
m_sTempFolder
=
dstTempPath
;
COfficeUtils
oCOfficeUtils
(
NULL
);
if
(
ext_1
==
_T
(
"rtf"
))
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"
))
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
;
return
0
;
}
}
Common/DocxFormat/Source/DocxFormat/Document.h
View file @
e81517ca
...
@@ -187,40 +187,13 @@ namespace OOX
...
@@ -187,40 +187,13 @@ namespace OOX
CPath
oRootPath
;
CPath
oRootPath
;
read
(
oRootPath
,
oPath
);
read
(
oRootPath
,
oPath
);
}
}
virtual
void
read
(
const
CPath
&
oRootPath
,
const
CPath
&
oPath
)
{
m_oReadPath
=
oPath
;
IFileContainer
::
Read
(
oRootPath
,
oPath
);
#ifdef USE_LITE_READER
Common
::
readAllShapeTypes
(
oPath
,
m_arrShapeTypes
);
XmlUtils
::
CXmlLiteReader
oReader
;
if
(
!
oReader
.
FromFile
(
oPath
.
GetPath
()
)
)
void
CreateElements
(
XmlUtils
::
CXmlLiteReader
&
oReader
,
int
Depth
)
return
;
if
(
!
oReader
.
ReadNextNode
()
)
return
;
CWCharWrapper
sName
=
oReader
.
GetName
();
if
(
_T
(
"w:document"
)
==
sName
)
{
{
ReadAttributes
(
oReader
);
while
(
oReader
.
ReadNextSiblingNode
(
Depth
)
)
if
(
!
oReader
.
IsEmptyNode
()
)
{
int
nDocumentDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nDocumentDepth
)
)
{
{
sName
=
oReader
.
GetName
();
CWCharWrapper
sName
=
oReader
.
GetName
();
if
(
_T
(
"w:body"
)
==
sName
&&
!
oReader
.
IsEmptyNode
()
)
{
int
nBodyDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nBodyDepth
)
)
{
sName
=
oReader
.
GetName
();
WritingElement
*
pItem
=
NULL
;
WritingElement
*
pItem
=
NULL
;
/*if ( _T("w:altChunk") == sName )
/*if ( _T("w:altChunk") == sName )
...
@@ -285,11 +258,56 @@ namespace OOX
...
@@ -285,11 +258,56 @@ namespace OOX
m_oSectPr
=
oReader
;
m_oSectPr
=
oReader
;
else
if
(
_T
(
"w:tbl"
)
==
sName
)
else
if
(
_T
(
"w:tbl"
)
==
sName
)
pItem
=
new
Logic
::
CTbl
(
oReader
);
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
)
if
(
pItem
)
m_arrItems
.
push_back
(
pItem
);
m_arrItems
.
push_back
(
pItem
);
}
}
}
}
virtual
void
read
(
const
CPath
&
oRootPath
,
const
CPath
&
oPath
)
{
m_oReadPath
=
oPath
;
IFileContainer
::
Read
(
oRootPath
,
oPath
);
#ifdef USE_LITE_READER
Common
::
readAllShapeTypes
(
oPath
,
m_arrShapeTypes
);
XmlUtils
::
CXmlLiteReader
oReader
;
if
(
!
oReader
.
FromFile
(
oPath
.
GetPath
()
)
)
return
;
if
(
!
oReader
.
ReadNextNode
()
)
return
;
CWCharWrapper
sName
=
oReader
.
GetName
();
if
(
_T
(
"w:document"
)
==
sName
||
_T
(
"w:wordDocument"
)
==
sName
)
{
ReadAttributes
(
oReader
);
if
(
!
oReader
.
IsEmptyNode
()
)
{
int
nDocumentDepth
=
oReader
.
GetDepth
();
while
(
oReader
.
ReadNextSiblingNode
(
nDocumentDepth
)
)
{
sName
=
oReader
.
GetName
();
if
(
_T
(
"w:body"
)
==
sName
&&
!
oReader
.
IsEmptyNode
()
)
{
int
nBodyDepth
=
oReader
.
GetDepth
();
CreateElements
(
oReader
,
nBodyDepth
);
}
else
if
(
_T
(
"w:background"
)
==
sName
)
else
if
(
_T
(
"w:background"
)
==
sName
)
m_oBackground
=
oReader
;
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