Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
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
sdkjs
Commits
8630fe5f
Commit
8630fe5f
authored
Mar 17, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug #34371. Reworked function for replacing a style.
parent
1c20b87f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
62 deletions
+63
-62
word/Private/StyleManager.js
word/Private/StyleManager.js
+63
-62
No files found.
word/Private/StyleManager.js
View file @
8630fe5f
...
@@ -162,63 +162,66 @@ CDocument.prototype.Is_DefaultStyleChanged = function(sName)
...
@@ -162,63 +162,66 @@ CDocument.prototype.Is_DefaultStyleChanged = function(sName)
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
CStyles
.
prototype
.
Create_StyleFromInterface
=
function
(
oAscStyle
,
bCheckLink
)
CStyles
.
prototype
.
Create_StyleFromInterface
=
function
(
oAscStyle
,
bCheckLink
)
{
{
var
oStyle
=
new
CStyle
();
var
sStyleName
=
oAscStyle
.
get_Name
();
var
sStyleId
=
this
.
Get_StyleIdByName
(
sStyleName
,
false
);
var
BasedOnId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_BasedOn
(),
false
);
if
(
null
!==
sStyleId
)
oStyle
.
Set_BasedOn
(
BasedOnId
);
{
oStyle
.
Set_Next
(
this
.
Get_StyleIdByName
(
oAscStyle
.
get_Next
(),
false
));
var
oStyle
=
this
.
Style
[
sStyleId
];
oStyle
.
Set_Type
(
oAscStyle
.
get_Type
());
var
NewStyleParaPr
=
oAscStyle
.
get_ParaPr
();
var
NewStyleParaPr
=
oAscStyle
.
get_ParaPr
();
var
NewStyleTextPr
=
oAscStyle
.
get_TextPr
();
var
NewStyleTextPr
=
oAscStyle
.
get_TextPr
();
// Если у нас есть стиль с данным именем, тогда мы старый стиль удаляем, а новый добавляем со старым Id,
var
BasedOnId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_BasedOn
(),
false
);
// чтобы если были ссылки на старый стиль - теперь они стали на новый.
var
NextId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_Next
(),
false
);
var
sStyleName
=
oAscStyle
.
get_Name
();
var
OldId
=
this
.
Get_StyleIdByName
(
sStyleName
,
false
);
if
(
null
!=
OldId
)
{
var
oOldStyle
=
this
.
Style
[
OldId
];
oStyle
.
Set_QFormat
(
oOldStyle
.
Get_QFormat
());
oStyle
.
Set_Type
(
oAscStyle
.
get_Type
());
oStyle
.
Set_UiPriority
(
oOldStyle
.
Get_UiPriority
());
oStyle
.
Set_Hidden
(
oOldStyle
.
Get_Hidden
());
oStyle
.
Set_SemiHidden
(
oOldStyle
.
Get_SemiHidden
());
oStyle
.
Set_UnhideWhenUsed
(
oOldStyle
.
Get_UnhideWhenUsed
());
// Если удаляемый стиль - стиль, который стоит в BasedOn, либо это вообще дефолтовый стиль, тогда мы должны
if
(
BasedOnId
===
sStyleId
||
sStyleId
===
this
.
Default
.
Paragraph
)
// его смержить с заданным.
if
(
BasedOnId
===
OldId
||
OldId
===
this
.
Default
.
Paragraph
)
{
{
oStyle
.
Set_BasedOn
(
null
);
oStyle
.
Set_BasedOn
(
null
);
var
OldStyleParaPr
=
oOld
Style
.
ParaPr
.
Copy
();
var
OldStyleParaPr
=
o
Style
.
ParaPr
.
Copy
();
var
OldStyleTextPr
=
oOld
Style
.
TextPr
.
Copy
();
var
OldStyleTextPr
=
o
Style
.
TextPr
.
Copy
();
OldStyleParaPr
.
Merge
(
NewStyleParaPr
);
OldStyleParaPr
.
Merge
(
NewStyleParaPr
);
OldStyleTextPr
.
Merge
(
NewStyleTextPr
);
OldStyleTextPr
.
Merge
(
NewStyleTextPr
);
NewStyleParaPr
=
OldStyleParaPr
;
NewStyleParaPr
=
OldStyleParaPr
;
NewStyleTextPr
=
OldStyleTextPr
;
NewStyleTextPr
=
OldStyleTextPr
;
}
}
else
{
oStyle
.
Set_BasedOn
(
BasedOnId
);
}
if
(
oStyle
.
Get_Next
()
===
OldId
)
if
(
null
===
oStyle
.
Get_Next
()
||
(
null
!==
NextId
&&
NextId
!==
sStyleId
))
{
if
(
NextId
===
sStyleId
)
oStyle
.
Set_Next
(
null
);
oStyle
.
Set_Next
(
null
);
else
oStyle
.
Set_Next
(
NextId
);
}
if
(
null
!=
oOldStyle
.
Get_Next
()
&&
null
==
oStyle
.
Get_Next
())
var
oAscLink
=
oAscStyle
.
get_Link
();
oStyle
.
Set_Next
(
oOldStyle
.
Get_Next
());
if
(
false
!=
bCheckLink
&&
null
!=
oAscLink
&&
undefined
!==
oAscLink
)
this
.
Remove
(
OldId
);
this
.
RemapIdReferences
(
OldId
,
oStyle
.
GetId
());
var
oLogicDocument
=
editor
.
WordControl
.
m_oLogicDocument
;
if
(
oLogicDocument
)
{
var
arrParagraphs
=
oLogicDocument
.
Get_AllParagraphsByStyle
([
OldId
]);
for
(
var
nIndex
=
0
,
nCount
=
arrParagraphs
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
{
arrParagraphs
[
nIndex
].
Style_Add
(
oStyle
.
GetId
(),
true
);
var
oLinkedStyle
=
this
.
Create_StyleFromInterface
(
oAscLink
,
false
);
}
oStyle
.
Set_Link
(
oLinkedStyle
.
Get_Id
());
oLinkedStyle
.
Set_Link
(
oStyle
.
Get_Id
());
}
}
oStyle
.
Set_TextPr
(
NewStyleTextPr
);
oStyle
.
Set_ParaPr
(
NewStyleParaPr
);
return
oStyle
;
}
}
else
{
var
oStyle
=
new
CStyle
();
var
BasedOnId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_BasedOn
(),
false
);
oStyle
.
Set_BasedOn
(
BasedOnId
);
oStyle
.
Set_Next
(
this
.
Get_StyleIdByName
(
oAscStyle
.
get_Next
(),
false
));
oStyle
.
Set_Type
(
oAscStyle
.
get_Type
());
oStyle
.
Set_TextPr
(
oAscStyle
.
get_TextPr
());
oStyle
.
Set_ParaPr
(
oAscStyle
.
get_ParaPr
());
oStyle
.
Set_Name
(
sStyleName
);
oStyle
.
Set_Name
(
sStyleName
);
if
(
styletype_Paragraph
===
oStyle
.
Get_Type
())
if
(
styletype_Paragraph
===
oStyle
.
Get_Type
())
...
@@ -232,11 +235,9 @@ CStyles.prototype.Create_StyleFromInterface = function(oAscStyle, bCheckLink)
...
@@ -232,11 +235,9 @@ CStyles.prototype.Create_StyleFromInterface = function(oAscStyle, bCheckLink)
oLinkedStyle
.
Set_Link
(
oStyle
.
Get_Id
());
oLinkedStyle
.
Set_Link
(
oStyle
.
Get_Id
());
}
}
oStyle
.
Set_TextPr
(
NewStyleTextPr
);
oStyle
.
Set_ParaPr
(
NewStyleParaPr
);
this
.
Add
(
oStyle
);
this
.
Add
(
oStyle
);
return
oStyle
;
return
oStyle
;
}
};
};
CStyles
.
prototype
.
Remove_StyleFromInterface
=
function
(
StyleId
)
CStyles
.
prototype
.
Remove_StyleFromInterface
=
function
(
StyleId
)
{
{
...
...
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