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
6778027d
Commit
6778027d
authored
Aug 28, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RtfFormat - small refactoring
parent
daf44553
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
108 additions
and
114 deletions
+108
-114
ASCOfficeRtfFile/RtfFormatLib/source/RtfField.h
ASCOfficeRtfFile/RtfFormatLib/source/RtfField.h
+0
-27
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.h
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.h
+1
-1
ASCOfficeRtfFile/RtfFormatLib/source/RtfPicture.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfPicture.cpp
+9
-13
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp
+60
-51
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.h
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.h
+9
-3
ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp
+20
-16
ASCOfficeRtfFile/RtfFormatLib/source/RtfWriter.cpp
ASCOfficeRtfFile/RtfFormatLib/source/RtfWriter.cpp
+2
-2
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXRelsWriter.h
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXRelsWriter.h
+7
-1
No files found.
ASCOfficeRtfFile/RtfFormatLib/source/RtfField.h
View file @
6778027d
...
...
@@ -310,33 +310,6 @@ public: CString RenderToOOX(RenderParameter oRenderParameter)
//заканчиваем Field
sResult
+=
_T
(
"<w:p>"
);
sResult
+=
_T
(
"<w:r><w:fldChar w:fldCharType=
\"
end
\"
/></w:r>"
);
////пишем параграфы содержания
//RenderParameter oNewParametr = oRenderParameter;
//oNewParametr.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
//sResult += m_oResult->RenderToOOX(oNewParametr));
//CString sFieldBegin;
//sFieldBegin += _T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>");
//sFieldBegin.AppendFormat(_T("<w:r><w:instrText xml:space=\"preserve\">%ls</w:instrText></w:r>"), Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) ));
//sFieldBegin += _T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>");
////пишем после первого w:pPr
//CString sFindStr = _T("</w:pPr>");
//int nIndex = sResult.Find( sFindStr );
//if( nIndex >= 0 && nIndex < sResult.GetLength() )
// sResult.Inset( sFieldBegin, nIndex + sFindStr.GetLength() );
//else//пишем после первого w:p
//{
// sFindStr = _T("<w:p>");
// nIndex = sResult.Find( sFindStr );
// if( nIndex >= 0 && nIndex < sResult.GetLength() )
// sResult.Inset( sFieldBegin, nIndex + sFindStr.GetLength() );
//}
//CString sFieldEnd;
//sFieldEnd += _T("<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>");
//sFieldEnd.AppendFormat(_T("<w:r><w:instrText xml:space=\"preserve\">%ls</w:instrText></w:r>"), Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) ));
//sFieldEnd += _T("<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>");
////пишем после последнего w:pPr
}
}
}
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfGlobalTables.h
View file @
6778027d
...
...
@@ -250,7 +250,7 @@ public:
for
(
int
i
=
0
;
i
<
(
int
)
m_aArray
.
size
();
i
++
)
{
CString
str
=
m_aArray
[
i
]
->
RenderToRtf
(
oRenderParameter
);
sResult
.
AppendFormat
(
_T
(
"%ls
\n\n
"
),
str
.
GetBuffer
()
);
sResult
+=
str
+
_T
(
"
\n\n
"
);
}
sResult
+=
_T
(
"}"
);
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfPicture.cpp
View file @
6778027d
...
...
@@ -37,16 +37,10 @@ CString RtfPicture::GenerateWMF(RenderParameter oRenderParameter)
{
CString
sResult
;
sResult
+=
_T
(
"{
\\
pict"
);
//if(-1 != m_nShapeId)
// sResult.AppendFormat(_T("{\\*\\picprop\\shplid%d%ls}"), m_nShapeId, m_oShapeProp.RenderToRtf( oRenderParameter ) );
//else
// sResult.AppendFormat(_T("{\\*\\picprop%ls}"), m_oShapeProp.RenderToRtf( oRenderParameter ) );
////"наши" wmf не растягиваются
RENDER_RTF_INT
(
100
,
sResult
,
_T
(
"picscalex"
)
)
RENDER_RTF_INT
(
100
,
sResult
,
_T
(
"picscaley"
)
)
//RENDER_RTF_INT( (int)m_dScaleX, sResult, _T("picscalex") )
//RENDER_RTF_INT( (int)m_dScaleY, sResult, _T("picscaley") )
RENDER_RTF_INT
(
m_nCropL
,
sResult
,
_T
(
"piccropl"
)
)
RENDER_RTF_INT
(
m_nCropT
,
sResult
,
_T
(
"piccropt"
)
)
RENDER_RTF_INT
(
m_nCropR
,
sResult
,
_T
(
"piccropr"
)
)
...
...
@@ -87,9 +81,12 @@ CString RtfPicture::RenderToRtf(RenderParameter oRenderParameter)
CString
sResult
=
_T
(
"{
\\
pict"
);
//if(-1 != m_nShapeId)
// sResult.AppendFormat(_T("{\\*\\picprop\\shplid%d%ls}"), m_nShapeId, m_oShapeProp.RenderToRtf( oRenderParameter ) );
//{
// sResult.AppendFormat(_T("{\\*\\picprop\\shplid%d"), m_nShapeId);
// sResult += m_oShapeProp.RenderToRtf( oRenderParameter ) + _T("}");
//}
//else
// sResult.AppendFormat(_T("{\\*\\picprop
%ls}"), m_oShapeProp.RenderToRtf( oRenderParameter )
);
// sResult.AppendFormat(_T("{\\*\\picprop
") + m_oShapeProp.RenderToRtf( oRenderParameter ) + _T("}"
);
RENDER_RTF_INT
(
(
int
)
m_dScaleX
,
sResult
,
_T
(
"picscalex"
)
)
RENDER_RTF_INT
(
(
int
)
m_dScaleY
,
sResult
,
_T
(
"picscaley"
)
)
RENDER_RTF_INT
(
m_nCropL
,
sResult
,
_T
(
"piccropl"
)
)
...
...
@@ -137,7 +134,9 @@ CString RtfPicture::RenderToOOX(RenderParameter oRenderParameter)
}
CString
sFilenameRels
;
sFilenameRels
.
AppendFormat
(
_T
(
"Image%d.%ls"
),
poRtfDocument
->
m_oIdGenerator
.
Generate_ImageIndex
(),
sExtension
.
GetBuffer
());
sFilenameRels
.
AppendFormat
(
_T
(
"Image%d."
),
poRtfDocument
->
m_oIdGenerator
.
Generate_ImageIndex
());
sFilenameRels
+=
sExtension
;
CString
sFilenameFull
=
poOOXWriter
->
m_sTargetFolder
+
FILE_SEPARATOR_STR
+
_T
(
"word"
)
+
FILE_SEPARATOR_STR
+
_T
(
"media"
);
FileSystem
::
Directory
::
CreateDirectory
(
sFilenameFull
);
...
...
@@ -154,8 +153,5 @@ CString RtfPicture::RenderToOOX(RenderParameter oRenderParameter)
CString
srId
=
poRelsWriter
->
AddRelationship
(
_T
(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
),
sFilenameRels
);
//CString sResult;
//sResult.AppendFormat( _T("<v:imagedata r:id=\"%ls\""), srId );
return
srId
;
}
\ No newline at end of file
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp
View file @
6778027d
This diff is collapsed.
Click to expand it.
ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.h
View file @
6778027d
...
...
@@ -714,8 +714,14 @@ private:
CString
sTheme
;
if
(
true
==
GetStringByTheme
(
sTheme
,
m_eTheme
)
)
{
sResult
.
AppendFormat
(
_T
(
"theme%lsColor =
\"
%ls
\"
theme%lsShade =
\"
%d
\"
theme%lsTint =
\"
%d
\"
"
),
sParam
.
GetBuffer
(),
sTheme
.
GetBuffer
(),
sParam
.
GetBuffer
(),
m_byteShade
,
sParam
.
GetBuffer
(),
m_byteTint
);
sResult
+=
_T
(
"theme"
)
+
sParam
+
_T
(
"Color"
);
sResult
+=
_T
(
"=
\"
"
)
+
sTheme
+
_T
(
"
\"
"
);
sResult
+=
_T
(
" theme"
)
+
sParam
+
_T
(
"Shade"
);
sResult
.
AppendFormat
(
_T
(
"=
\"
%d
\"
"
),
m_byteShade
);
sResult
+=
_T
(
" theme"
)
+
sParam
+
_T
(
"Tint"
);
sResult
.
AppendFormat
(
_T
(
"=
\"
%d
\"
"
),
m_byteTint
);
}
}
return
sResult
;
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfSection.cpp
View file @
6778027d
...
...
@@ -516,8 +516,10 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
sPaperSource
.
AppendFormat
(
_T
(
" w:first=
\"
%d
\"
"
),
m_nPaperSourceFirst
);
if
(
PROP_DEF
!=
m_nPaperSourceFirst
)
sPaperSource
.
AppendFormat
(
_T
(
" w:other=
\"
%d
\"
"
),
m_nPaperSourceOther
);
if
(
false
==
sPaperSource
.
IsEmpty
()
)
sResult
.
AppendFormat
(
_T
(
"<w:paperSrc %ls/>"
),
sPaperSource
.
GetBuffer
()
);
if
(
!
sPaperSource
.
IsEmpty
()
)
sResult
+=
_T
(
"<w:paperSrc "
)
+
sPaperSource
+
_T
(
"/>"
);
if
(
1
==
m_bRtlGutter
)
sResult
+=
_T
(
"<w:rtlGutter/>"
);
...
...
@@ -661,7 +663,7 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
case
lnr_linecont
:
sLineNumbering
+=
_T
(
" w:restart=
\"
continuous
\"
"
);
break
;
}
if
(
false
==
sLineNumbering
.
IsEmpty
()
)
sResult
.
AppendFormat
(
_T
(
"<w:lnNumType %ls/>"
),
sLineNumbering
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:lnNumType "
)
+
sLineNumbering
+
_T
(
"/>"
);
//Page Information
CString
sPageSize
;
...
...
@@ -672,7 +674,7 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
if
(
1
==
m_bLandscapeFormat
)
sPageSize
.
Append
(
_T
(
" w:orient=
\"
landscape
\"
"
));
if
(
false
==
sPageSize
.
IsEmpty
()
)
sResult
.
AppendFormat
(
_T
(
"<w:pgSz %ls/>"
),
sPageSize
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:pgSz "
)
+
sPageSize
+
_T
(
"/>"
);
CString
sMargin
;
if
(
PROP_DEF
!=
m_nMarginLeft
)
...
...
@@ -690,16 +692,16 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
if
(
PROP_DEF
!=
m_nFooterBottom
)
sMargin
.
AppendFormat
(
_T
(
" w:footer=
\"
%d
\"
"
),
m_nFooterBottom
);
if
(
false
==
sMargin
.
IsEmpty
()
)
sResult
.
AppendFormat
(
_T
(
"<w:pgMar %ls/>"
),
sMargin
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:pgMar "
)
+
sMargin
+
_T
(
"/>"
);
if
(
1
==
m_bTitlePage
)
sResult
.
Append
(
_T
(
"<w:titlePg/>"
)
);
sResult
+=
_T
(
"<w:titlePg/>"
);
//Page Numbers
CString
sPageNumber
;
if
(
PROP_DEF
!=
m_nPageNumberStart
)
sPageNumber
.
AppendFormat
(
_T
(
" w:start=
\"
%d
\"
"
),
m_nPageNumberStart
);
if
(
false
==
sPageNumber
.
IsEmpty
()
)
sResult
.
AppendFormat
(
_T
(
"<w:pgNumType %ls/>"
),
sPageNumber
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:pgNumType "
)
+
sPageNumber
+
_T
(
"/>"
);
//Vertical Alignment
switch
(
m_eVerticalAlignment
)
{
...
...
@@ -769,32 +771,32 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
if
(
0
!=
m_oHeaderLeft
)
{
CString
sId
=
SaveFile
(
m_oHeaderLeft
,
oRenderParameter
,
true
);
sResult
.
AppendFormat
(
_T
(
"<w:headerReference w:type=
\"
even
\"
r:id=
\"
%ls
\"
/>"
),
sId
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:headerReference w:type=
\"
even
\"
r:id=
\"
"
)
+
sId
+
_T
(
"
\"
/>"
);
}
if
(
0
!=
m_oHeaderFirst
)
{
CString
sId
=
SaveFile
(
m_oHeaderFirst
,
oRenderParameter
,
true
);
sResult
.
AppendFormat
(
_T
(
"<w:headerReference w:type=
\"
first
\"
r:id=
\"
%ls
\"
/>"
),
sId
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:headerReference w:type=
\"
first
\"
r:id=
\"
"
)
+
sId
+
_T
(
"
\"
/>"
);
}
if
(
0
!=
m_oHeaderRight
)
{
CString
sId
=
SaveFile
(
m_oHeaderRight
,
oRenderParameter
,
true
);
sResult
.
AppendFormat
(
_T
(
"<w:headerReference w:type=
\"
default
\"
r:id=
\"
%ls
\"
/>"
),
sId
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:headerReference w:type=
\"
default
\"
r:id=
\"
"
)
+
sId
+
_T
(
"
\"
/>"
);
}
if
(
0
!=
m_oFooterLeft
)
{
CString
sId
=
SaveFile
(
m_oFooterLeft
,
oRenderParameter
,
false
);
sResult
.
AppendFormat
(
_T
(
"<w:footerReference w:type=
\"
even
\"
r:id=
\"
%ls
\"
/>"
),
sId
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:footerReference w:type=
\"
even
\"
r:id=
\"
"
)
+
sId
+
_T
(
"
\"
/>"
);
}
if
(
0
!=
m_oFooterFirst
)
{
CString
sId
=
SaveFile
(
m_oFooterFirst
,
oRenderParameter
,
false
);
sResult
.
AppendFormat
(
_T
(
"<w:footerReference w:type=
\"
first
\"
r:id=
\"
%ls
\"
/>"
),
sId
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:footerReference w:type=
\"
first
\"
r:id=
\"
"
)
+
sId
+
_T
(
"
\"
/>"
);
}
if
(
0
!=
m_oFooterRight
)
{
CString
sId
=
SaveFile
(
m_oFooterRight
,
oRenderParameter
,
false
);
sResult
.
AppendFormat
(
_T
(
"<w:footerReference w:type=
\"
default
\"
r:id=
\"
%ls
\"
/>"
),
sId
.
GetBuffer
()
);
sResult
+=
_T
(
"<w:footerReference w:type=
\"
default
\"
r:id=
\"
"
)
+
sId
+
_T
(
"
\"
/>"
);
}
sResult
.
Append
(
_T
(
"</w:sectPr>"
));
return
sResult
;
...
...
@@ -816,8 +818,10 @@ CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParame
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
()
);
sContent
+=
_T
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
yes
\"
?>
\n
"
);
sContent
+=
_T
(
"<"
);
sContent
+=
sRootName
;
sContent
+=
_T
(
"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
\"
>"
);
RenderParameter
oNewParameter
=
oRenderParameter
;
OOXRelsWriterPtr
oNewRelsWr
=
OOXRelsWriterPtr
(
new
OOXRelsWriter
(
sFilename
,
*
poRtfDocument
)
);
...
...
@@ -825,7 +829,7 @@ CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParame
oNewParameter
.
poRels
=
oNewRelsWr
.
get
();
sContent
+=
oTarget
->
RenderToOOX
(
oNewParameter
);
sContent
.
AppendFormat
(
_T
(
"</%ls>"
),
sRootName
.
GetBuffer
()
);
sContent
+=
_T
(
"</"
)
+
sRootName
+
_T
(
">"
);
std
::
string
sXmlUTF
=
NSFile
::
CUtf8Converter
::
GetUtf8StringFromUnicode
(
sContent
.
GetBuffer
());
...
...
ASCOfficeRtfFile/RtfFormatLib/source/RtfWriter.cpp
View file @
6778027d
...
...
@@ -283,10 +283,10 @@ CString RtfWriter::CreateRtfStart()
//CString sDefCharProp = m_oDocument.m_oDefaultCharProp.RenderToRtf( oRenderParameter );
//if( false == sDefCharProp.IsEmpty() )
// sResult
.AppendFormat( _T("{\\*\\defchp %ls}"), sDefCharProp
);
// sResult
+= _T("{\\*\\defchp ") + sDefCharProp + _T("}"
);
//CString sDefParProp = m_oDocument.m_oDefaultParagraphProp.RenderToRtf( oRenderParameter );
//if( false == sDefParProp.IsEmpty() )
// sResult
.AppendFormat( _T("{\\*\\defpap %ls}"),sDefParProp
);
// sResult
+= _T("{\\*\\defpap ") + sDefParProp+ _T("}"
);
//sResult += m_oDocument.m_oStyleTable.RenderToRtf( oRenderParameter ) );
sResult
+=
m_oDocument
.
m_oListTabel
.
RenderToRtf
(
oRenderParameter
);
...
...
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXRelsWriter.h
View file @
6778027d
...
...
@@ -70,7 +70,13 @@ public:
for
(
int
i
=
0
;
i
<
(
int
)
m_aTargets
.
size
();
i
++
)
{
sResult
.
AppendFormat
(
_T
(
"<Relationship Id=
\"
%ls
\"
Type=
\"
%ls
\"
Target=
\"
%ls
\"
"
),
m_aIDs
[
i
].
GetBuffer
(),
m_aTypes
[
i
].
GetBuffer
(),
m_aTargets
[
i
].
GetBuffer
());
sResult
+=
_T
(
"<Relationship Id=
\"
"
);
sResult
+=
m_aIDs
[
i
];
sResult
+=
_T
(
"
\"
Type=
\"
"
);
sResult
+=
m_aTypes
[
i
];
sResult
+=
_T
(
"
\"
Target=
\"
"
);
sResult
+=
m_aTargets
[
i
];
sResult
+=
_T
(
"
\"
"
);
if
(
false
==
m_aModes
[
i
]
)
sResult
+=
_T
(
" TargetMode=
\"
External
\"
"
);
sResult
+=
_T
(
"/>"
);
...
...
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