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
9115edbd
Commit
9115edbd
authored
Jul 13, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug #35382.
parent
3f18f961
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
24 deletions
+129
-24
ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h
ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h
+2
-2
ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp
ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp
+98
-18
ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h
ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h
+6
-1
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
+17
-2
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
+6
-1
No files found.
ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h
View file @
9115edbd
...
...
@@ -68,12 +68,12 @@ namespace DocFileFormat
int
cp
=
m_document
->
FIB
->
m_RgLw97
.
ccpText
+
m_document
->
FIB
->
m_RgLw97
.
ccpFtn
+
m_document
->
FIB
->
m_RgLw97
.
ccpHdr
;
size_t
count
=
m_document
->
AnnotationsReferencePlex
->
Elements
.
size
();
for
(
unsigned
in
t
i
=
0
;
i
<
count
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
count
;
++
i
)
{
AnnotationReferenceDescriptor
*
atrdPre10
=
static_cast
<
AnnotationReferenceDescriptor
*>
(
m_document
->
AnnotationsReferencePlex
->
Elements
[
index
]);
m_pXmlWriter
->
WriteNodeBegin
(
L"w:comment"
,
TRUE
);
m_pXmlWriter
->
WriteAttribute
(
L"w:id"
,
FormatUtils
::
IntToWideString
(
index
));
m_pXmlWriter
->
WriteAttribute
(
L"w:id"
,
FormatUtils
::
IntToWideString
(
index
+
1
));
m_pXmlWriter
->
WriteAttribute
(
L"w:author"
,
FormatUtils
::
XmlEncode
(
m_document
->
AnnotationOwners
->
at
(
atrdPre10
->
GetAuthorIndex
()
)
));
m_pXmlWriter
->
WriteAttribute
(
L"w:initials"
,
atrdPre10
->
GetUserInitials
());
...
...
ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp
View file @
9115edbd
...
...
@@ -290,17 +290,15 @@ namespace DocFileFormat
std
::
vector
<
wchar_t
>*
chpxChars
=
m_document
->
GetChars
(
fcChpxStart
,
fcChpxEnd
,
cp
);
//search for bookmarks in the chars
std
::
vector
<
int
>
bookmarks
=
searchBookmarks
(
chpxChars
,
cp
);
//if there are bookmarks in this run, split the run into several runs
if
(
!
bookmarks
.
empty
())
std
::
vector
<
int
>
annot
=
searchAnnot
(
chpxChars
,
cp
);
if
(
!
annot
.
empty
())
{
std
::
list
<
std
::
vector
<
wchar_t
>>*
runs
=
splitCharList
(
chpxChars
,
&
bookmarks
);
std
::
list
<
std
::
vector
<
wchar_t
>>*
runs
=
splitCharList
(
chpxChars
,
&
annot
);
if
(
runs
)
{
for
(
std
::
list
<
std
::
vector
<
wchar_t
>
>::
iterator
iter
=
runs
->
begin
();
iter
!=
runs
->
end
();
++
iter
)
{
if
(
write
Bookmark
s
(
cp
))
if
(
write
Annotation
s
(
cp
))
{
cp
=
writeRun
(
&
(
*
iter
),
*
cpeIter
,
cp
);
}
...
...
@@ -311,7 +309,30 @@ namespace DocFileFormat
}
else
{
cp
=
writeRun
(
chpxChars
,
*
cpeIter
,
cp
);
//search for bookmarks in the chars
std
::
vector
<
int
>
bookmarks
=
searchBookmarks
(
chpxChars
,
cp
);
//if there are bookmarks in this run, split the run into several runs
if
(
!
bookmarks
.
empty
())
{
std
::
list
<
std
::
vector
<
wchar_t
>>*
runs
=
splitCharList
(
chpxChars
,
&
bookmarks
);
if
(
runs
)
{
for
(
std
::
list
<
std
::
vector
<
wchar_t
>
>::
iterator
iter
=
runs
->
begin
();
iter
!=
runs
->
end
();
++
iter
)
{
if
(
writeBookmarks
(
cp
))
{
cp
=
writeRun
(
&
(
*
iter
),
*
cpeIter
,
cp
);
}
}
RELEASEOBJECT
(
runs
);
}
}
else
{
cp
=
writeRun
(
chpxChars
,
*
cpeIter
,
cp
);
}
}
RELEASEOBJECT
(
chpxChars
);
...
...
@@ -948,19 +969,17 @@ namespace DocFileFormat
}
else
if
(
TextMark
::
AnnotationReference
==
code
)
{
if
(
typeid
(
*
this
)
!
=
typeid
(
CommentsMapping
))
if
(
typeid
(
*
this
)
=
=
typeid
(
CommentsMapping
))
{
m_pXmlWriter
->
WriteNodeBegin
(
L"w:commentReference"
,
true
);
m_pXmlWriter
->
WriteAttribute
(
L"w:id"
,
FormatUtils
::
IntToWideString
(
_commentNr
));
m_pXmlWriter
->
WriteNodeBegin
(
L"w:annotationRef"
,
true
);
m_pXmlWriter
->
WriteNodeEnd
(
L""
,
true
);
}
}
else
{
m_pXmlWriter
->
WriteNodeBegin
(
L"w:annotationRef"
,
true
);
m_pXmlWriter
->
WriteNodeEnd
(
L""
,
true
);
m_pXmlWriter
->
WriteNodeBegin
(
L"w:commentReference"
,
true
);
m_pXmlWriter
->
WriteAttribute
(
L"w:id"
,
FormatUtils
::
IntToWideString
(
_commentNr
));
m_pXmlWriter
->
WriteNodeEnd
(
L""
,
true
);
}
_commentNr
++
;
}
else
if
(
!
FormatUtils
::
IsControlSymbol
(
c
)
&&
((
int
)
c
!=
0xFFFF
))
{
...
...
@@ -1042,6 +1061,30 @@ namespace DocFileFormat
return
ret
;
}
// Searches for bookmarks in the list of characters.
std
::
vector
<
int
>
DocumentMapping
::
searchAnnot
(
std
::
vector
<
wchar_t
>*
chars
,
int
initialCp
)
{
std
::
vector
<
int
>
ret
;
if
(
m_document
->
AnnotStartPlex
->
IsValid
())
{
int
cp
=
initialCp
;
size_t
count
=
chars
->
size
();
for
(
size_t
i
=
0
;
i
<
count
;
++
i
)
{
if
((
m_document
->
AnnotStartPlex
->
IsCpExists
(
cp
))
||
(
m_document
->
AnnotEndPlex
->
IsCpExists
(
cp
)))
{
ret
.
push_back
(
i
);
}
++
cp
;
}
}
return
ret
;
}
ParagraphPropertyExceptions
*
DocumentMapping
::
findValidPapx
(
int
fc
)
{
...
...
@@ -1540,7 +1583,6 @@ namespace DocFileFormat
return
cpCellEnd
;
}
//
bool
DocumentMapping
::
writeBookmarks
(
int
cp
)
{
bool
result
=
true
;
...
...
@@ -1561,7 +1603,27 @@ namespace DocFileFormat
return
result
;
}
bool
DocumentMapping
::
writeAnnotations
(
int
cp
)
{
bool
result
=
true
;
for
(
size_t
i
=
0
;
i
<
m_document
->
AnnotStartEndCPs
.
size
();
i
++
)
{
if
(
m_document
->
AnnotStartEndCPs
[
i
].
first
==
cp
)
{
result
=
writeAnnotationStart
(
i
+
1
);
_commentNr
=
i
+
1
;
}
if
(
m_document
->
AnnotStartEndCPs
[
i
].
second
==
cp
)
{
result
=
writeAnnotationEnd
(
i
+
1
);
_commentNr
=
i
+
1
;
}
}
return
result
;
}
bool
DocumentMapping
::
writeBookmarkStart
(
short
id
)
{
// write bookmark start
...
...
@@ -1585,8 +1647,6 @@ namespace DocFileFormat
bool
DocumentMapping
::
writeBookmarkEnd
(
short
id
)
{
// write bookmark end
WideString
*
bookmarkName
=
static_cast
<
WideString
*>
(
m_document
->
BookmarkNames
->
operator
[]
(
id
)
);
if
(
(
bookmarkName
!=
NULL
)
&&
(
*
bookmarkName
!=
L"_PictureBullets"
)
)
...
...
@@ -1602,7 +1662,27 @@ namespace DocFileFormat
return
false
;
}
bool
DocumentMapping
::
writeAnnotationStart
(
short
id
)
{
XMLTools
::
XMLElement
bookmarkElem
(
L"w:commentRangeStart"
);
bookmarkElem
.
AppendAttribute
(
L"w:id"
,
FormatUtils
::
IntToWideString
(
id
));
m_pXmlWriter
->
WriteString
(
bookmarkElem
.
GetXMLString
());
return
true
;
}
bool
DocumentMapping
::
writeAnnotationEnd
(
short
id
)
{
XMLTools
::
XMLElement
bookmarkElem
(
L"w:commentRangeEnd"
);
bookmarkElem
.
AppendAttribute
(
L"w:id"
,
FormatUtils
::
IntToWideString
(
id
));
m_pXmlWriter
->
WriteString
(
bookmarkElem
.
GetXMLString
());
return
true
;
}
// Checks if the CHPX is special
bool
DocumentMapping
::
isSpecial
(
CharacterPropertyExceptions
*
chpx
)
{
...
...
ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h
View file @
9115edbd
...
...
@@ -99,8 +99,9 @@ namespace DocFileFormat
void
writeTextStart
(
const
std
::
wstring
&
textType
,
bool
preserve_space
);
void
writeTextEnd
(
const
std
::
wstring
&
textType
);
// Searches for bookmarks in the list of characters.
std
::
vector
<
int
>
searchBookmarks
(
std
::
vector
<
wchar_t
>*
chars
,
int
initialCp
);
std
::
vector
<
int
>
searchAnnot
(
std
::
vector
<
wchar_t
>*
chars
,
int
initialCp
);
ParagraphPropertyExceptions
*
findValidPapx
(
int
fc
);
// Splits a list of characters into several lists
std
::
list
<
std
::
vector
<
wchar_t
>
>*
splitCharList
(
std
::
vector
<
wchar_t
>*
chars
,
std
::
vector
<
int
>*
splitIndices
);
...
...
@@ -121,6 +122,10 @@ namespace DocFileFormat
bool
writeBookmarks
(
int
cp
);
bool
writeBookmarkStart
(
short
id
);
bool
writeBookmarkEnd
(
short
id
);
bool
writeAnnotations
(
int
cp
);
bool
writeAnnotationStart
(
short
id
);
bool
writeAnnotationEnd
(
short
id
);
// Checks if the CHPX is special
bool
isSpecial
(
CharacterPropertyExceptions
*
chpx
);
// Finds the SEPX that is valid for the given CP.
...
...
ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp
View file @
9115edbd
...
...
@@ -52,7 +52,8 @@ namespace DocFileFormat
TextboxIndividualPlex
(
NULL
),
AssocNames
(
NULL
),
BookmarkAnnotNames
(
NULL
),
Captions
(
NULL
),
AutoCaptions
(
NULL
),
ListPlex
(
NULL
),
OfficeDrawingPlex
(
NULL
),
OfficeDrawingPlexHeader
(
NULL
),
SectionPlex
(
NULL
),
BookmarkStartPlex
(
NULL
),
BookmarkEndPlex
(
NULL
),
AutoTextPlex
(
NULL
),
AllPapxFkps
(
NULL
),
AllChpxFkps
(
NULL
),
AllPapx
(
NULL
),
AllPapxVector
(
NULL
),
AllSepx
(
NULL
),
Styles
(
NULL
),
listTable
(
NULL
),
AnnotationOwners
(
NULL
),
DocProperties
(
NULL
),
listFormatOverrideTable
(
NULL
),
headerAndFooterTable
(
NULL
),
encryptionHeader
(
NULL
)
AnnotationOwners
(
NULL
),
DocProperties
(
NULL
),
listFormatOverrideTable
(
NULL
),
headerAndFooterTable
(
NULL
),
AnnotStartPlex
(
NULL
),
AnnotEndPlex
(
NULL
),
encryptionHeader
(
NULL
)
{
m_pCallFunc
=
pCallFunc
;
m_sTempFolder
=
sTempFolder
;
...
...
@@ -275,12 +276,17 @@ namespace DocFileFormat
TextboxIndividualPlex
=
new
Plex
<
FTXBXS
>
(
FTXBXS
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcftxbxTxt
,
FIB
->
m_FibWord97
.
lcbPlcftxbxTxt
,
bOlderVersion
);
SectionPlex
=
new
Plex
<
SectionDescriptor
>
(
SectionDescriptor
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfSed
,
FIB
->
m_FibWord97
.
lcbPlcfSed
,
bOlderVersion
);
BookmarkStartPlex
=
new
Plex
<
BookmarkFirst
>
(
BookmarkFirst
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfBkf
,
FIB
->
m_FibWord97
.
lcbPlcfBkf
,
bOlderVersion
);
BookmarkEndPlex
=
new
Plex
<
EmptyStructure
>
(
EmptyStructure
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfBkl
,
FIB
->
m_FibWord97
.
lcbPlcfBkl
,
bOlderVersion
);
TextboxBreakPlex
=
new
Plex
<
Tbkd
>
(
Tbkd
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfTxbxBkd
,
FIB
->
m_FibWord97
.
lcbPlcfTxbxBkd
,
bOlderVersion
);
TextboxBreakPlexHeader
=
new
Plex
<
Tbkd
>
(
Tbkd
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfTxbxHdrBkd
,
FIB
->
m_FibWord97
.
lcbPlcfTxbxHdrBkd
,
bOlderVersion
);
AnnotStartPlex
=
new
Plex
<
BookmarkFirst
>
(
BookmarkFirst
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfAtnBkf
,
FIB
->
m_FibWord97
.
lcbPlcfAtnBkf
,
bOlderVersion
);
AnnotEndPlex
=
new
Plex
<
EmptyStructure
>
(
EmptyStructure
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfAtnBkl
,
FIB
->
m_FibWord97
.
lcbPlcfAtnBkl
,
bOlderVersion
);
for
(
size_t
i
=
0
;
i
<
BookmarkStartPlex
->
Elements
.
size
();
++
i
)
{
BookmarkFirst
*
pBookmark
=
static_cast
<
BookmarkFirst
*>
(
BookmarkStartPlex
->
Elements
[
i
]);
...
...
@@ -289,7 +295,14 @@ namespace DocFileFormat
BookmarkStartEndCPs
.
push_back
(
std
::
make_pair
(
BookmarkStartPlex
->
CharacterPositions
[
i
],
BookmarkEndPlex
->
CharacterPositions
[
pBookmark
->
GetIndex
()]));
}
}
for
(
size_t
i
=
0
;
i
<
AnnotStartPlex
->
Elements
.
size
();
++
i
)
{
BookmarkFirst
*
pBookmark
=
static_cast
<
BookmarkFirst
*>
(
AnnotStartPlex
->
Elements
[
i
]);
if
(
pBookmark
)
{
AnnotStartEndCPs
.
push_back
(
std
::
make_pair
(
AnnotStartPlex
->
CharacterPositions
[
i
],
AnnotEndPlex
->
CharacterPositions
[
pBookmark
->
GetIndex
()]));
}
}
AutoTextPlex
=
new
Plex
<
EmptyStructure
>
(
EmptyStructure
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfGlsy
,
FIB
->
m_FibWord97
.
lcbPlcfGlsy
,
bOlderVersion
);
FieldsPlex
=
new
Plex
<
FieldCharacter
>
(
FieldCharacter
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfFldMom
,
FIB
->
m_FibWord97
.
lcbPlcfFldMom
,
bOlderVersion
);
FootnoteDocumentFieldsPlex
=
new
Plex
<
FieldCharacter
>
(
FieldCharacter
::
STRUCTURE_SIZE
,
TableStream
,
FIB
->
m_FibWord97
.
fcPlcfFldFtn
,
FIB
->
m_FibWord97
.
lcbPlcfFldFtn
,
bOlderVersion
);
...
...
@@ -659,6 +672,8 @@ namespace DocFileFormat
RELEASEOBJECT
(
SectionPlex
);
RELEASEOBJECT
(
BookmarkStartPlex
);
RELEASEOBJECT
(
BookmarkEndPlex
);
RELEASEOBJECT
(
AnnotStartPlex
);
RELEASEOBJECT
(
AnnotEndPlex
);
RELEASEOBJECT
(
AutoTextPlex
);
RELEASEOBJECT
(
ListPlex
);
RELEASEOBJECT
(
Styles
);
...
...
ASCOfficeDocFile/DocDocxConverter/WordDocument.h
View file @
9115edbd
...
...
@@ -162,7 +162,9 @@ namespace DocFileFormat
std
::
vector
<
int
>
*
AllPapxVector
;
// A vector to quick find in AllPapx
std
::
map
<
int
,
int
>
PictureBulletsCPsMap
;
std
::
vector
<
std
::
pair
<
int
,
int
>>
BookmarkStartEndCPs
;
std
::
vector
<
std
::
pair
<
int
,
int
>>
AnnotStartEndCPs
;
FileInformationBlock
*
FIB
;
StyleSheet
*
Styles
;
// The style sheet of the document
...
...
@@ -204,7 +206,10 @@ namespace DocFileFormat
Plex
<
SectionDescriptor
>
*
SectionPlex
;
// A Plex containing all section descriptors
Plex
<
BookmarkFirst
>
*
BookmarkStartPlex
;
Plex
<
EmptyStructure
>
*
BookmarkEndPlex
;
Plex
<
EmptyStructure
>
*
BookmarkEndPlex
;
Plex
<
BookmarkFirst
>
*
AnnotStartPlex
;
Plex
<
EmptyStructure
>
*
AnnotEndPlex
;
Plex
<
ListNumCache
>
*
ListPlex
;
Plex
<
FieldCharacter
>
*
FieldsPlex
;
...
...
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