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
Hide 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,81 +162,82 @@ CDocument.prototype.Is_DefaultStyleChanged = function(sName)
...
@@ -162,81 +162,82 @@ 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
);
if
(
null
!==
sStyleId
)
{
var
oStyle
=
this
.
Style
[
sStyleId
];
var
BasedOnId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_BasedOn
(),
false
);
var
NewStyleParaPr
=
oAscStyle
.
get_ParaPr
();
oStyle
.
Set_BasedOn
(
BasedOnId
);
var
NewStyleTextPr
=
oAscStyle
.
get_TextPr
();
oStyle
.
Set_Next
(
this
.
Get_StyleIdByName
(
oAscStyle
.
get_Next
(),
false
));
oStyle
.
Set_Type
(
oAscStyle
.
get_Type
());
var
NewStyleParaPr
=
oAscStyle
.
get_ParaPr
(
);
var
BasedOnId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_BasedOn
(),
false
);
var
NewStyleTextPr
=
oAscStyle
.
get_TextPr
(
);
var
NextId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_Next
(),
false
);
// Если у нас есть стиль с данным именем, тогда мы старый стиль удаляем, а новый добавляем со старым Id,
oStyle
.
Set_Type
(
oAscStyle
.
get_Type
());
// чтобы если были ссылки на старый стиль - теперь они стали на новый.
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_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
===
OldId
||
OldId
===
this
.
Default
.
Paragraph
)
{
oStyle
.
Set_BasedOn
(
null
);
var
OldStyleParaPr
=
oOldStyle
.
ParaPr
.
Copy
();
var
OldStyleTextPr
=
oOldStyle
.
TextPr
.
Copy
();
OldStyleParaPr
.
Merge
(
NewStyleParaPr
);
OldStyleTextPr
.
Merge
(
NewStyleTextPr
);
NewStyleParaPr
=
OldStyleParaPr
;
NewStyleTextPr
=
OldStyleTextPr
;
}
if
(
oStyle
.
Get_Next
()
===
OldId
)
if
(
BasedOnId
===
sStyleId
||
sStyleId
===
this
.
Default
.
Paragraph
)
oStyle
.
Set_Next
(
null
);
{
oStyle
.
Set_BasedOn
(
null
);
if
(
null
!=
oOldStyle
.
Get_Next
()
&&
null
==
oStyle
.
Get_Next
())
var
OldStyleParaPr
=
oStyle
.
ParaPr
.
Copy
();
oStyle
.
Set_Next
(
oOldStyle
.
Get_Next
());
var
OldStyleTextPr
=
oStyle
.
TextPr
.
Copy
();
OldStyleParaPr
.
Merge
(
NewStyleParaPr
);
OldStyleTextPr
.
Merge
(
NewStyleTextPr
);
NewStyleParaPr
=
OldStyleParaPr
;
NewStyleTextPr
=
OldStyleTextPr
;
}
else
{
oStyle
.
Set_BasedOn
(
BasedOnId
);
}
this
.
Remove
(
OldId
);
if
(
null
===
oStyle
.
Get_Next
()
||
(
null
!==
NextId
&&
NextId
!==
sStyleId
))
this
.
RemapIdReferences
(
OldId
,
oStyle
.
GetId
());
{
if
(
NextId
===
sStyleId
)
oStyle
.
Set_Next
(
null
);
else
oStyle
.
Set_Next
(
NextId
);
}
var
o
LogicDocument
=
editor
.
WordControl
.
m_oLogicDocument
;
var
o
AscLink
=
oAscStyle
.
get_Link
()
;
if
(
oLogicDocument
)
if
(
false
!=
bCheckLink
&&
null
!=
oAscLink
&&
undefined
!==
oAscLink
)
{
{
var
arrParagraphs
=
oLogicDocument
.
Get_AllParagraphsByStyle
([
OldId
]);
var
oLinkedStyle
=
this
.
Create_StyleFromInterface
(
oAscLink
,
false
);
for
(
var
nIndex
=
0
,
nCount
=
arrParagraphs
.
length
;
nIndex
<
nCount
;
++
nIndex
)
oStyle
.
Set_Link
(
oLinkedStyle
.
Get_Id
());
{
oLinkedStyle
.
Set_Link
(
oStyle
.
Get_Id
());
arrParagraphs
[
nIndex
].
Style_Add
(
oStyle
.
GetId
(),
true
);
}
}
}
}
oStyle
.
Set_Name
(
sStyleName
);
oStyle
.
Set_TextPr
(
NewStyleTextPr
);
oStyle
.
Set_ParaPr
(
NewStyleParaPr
);
if
(
styletype_Paragraph
===
oStyle
.
Get_Type
())
return
oStyle
;
oStyle
.
Set_QFormat
(
true
);
}
else
{
var
oStyle
=
new
CStyle
();
var
oAscLink
=
oAscStyle
.
get_Link
();
var
BasedOnId
=
this
.
Get_StyleIdByName
(
oAscStyle
.
get_BasedOn
(),
false
);
if
(
false
!=
bCheckLink
&&
null
!=
oAscLink
&&
undefined
!==
oAscLink
)
oStyle
.
Set_BasedOn
(
BasedOnId
);
{
oStyle
.
Set_Next
(
this
.
Get_StyleIdByName
(
oAscStyle
.
get_Next
(),
false
));
var
oLinkedStyle
=
this
.
Create_StyleFromInterface
(
oAscLink
,
false
);
oStyle
.
Set_Type
(
oAscStyle
.
get_Type
());
oStyle
.
Set_Link
(
oLinkedStyle
.
Get_Id
());
oStyle
.
Set_TextPr
(
oAscStyle
.
get_TextPr
());
oLinkedStyle
.
Set_Link
(
oStyle
.
Get_Id
());
oStyle
.
Set_ParaPr
(
oAscStyle
.
get_ParaPr
());
}
oStyle
.
Set_Name
(
sStyleName
);
if
(
styletype_Paragraph
===
oStyle
.
Get_Type
())
oStyle
.
Set_QFormat
(
true
);
oStyle
.
Set_TextPr
(
NewStyleTextPr
);
var
oAscLink
=
oAscStyle
.
get_Link
();
oStyle
.
Set_ParaPr
(
NewStyleParaPr
);
if
(
false
!=
bCheckLink
&&
null
!=
oAscLink
&&
undefined
!==
oAscLink
)
{
var
oLinkedStyle
=
this
.
Create_StyleFromInterface
(
oAscLink
,
false
);
oStyle
.
Set_Link
(
oLinkedStyle
.
Get_Id
());
oLinkedStyle
.
Set_Link
(
oStyle
.
Get_Id
());
}
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