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
27bc6e74
Commit
27bc6e74
authored
8 years ago
by
Alexey.Musinov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/ONLYOFFICE/sdkjs
into HEAD
parents
d8e6c66c
1fa15bbc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
21 deletions
+66
-21
common/Drawings/CommonController.js
common/Drawings/CommonController.js
+6
-5
word/Editor/Table/TableRecalculate.js
word/Editor/Table/TableRecalculate.js
+60
-16
No files found.
common/Drawings/CommonController.js
View file @
27bc6e74
...
...
@@ -368,14 +368,15 @@ DrawingObjectsController.prototype =
//for mobile spreadsheet editor
startEditTextCurrentShape
:
function
()
{
if
(
this
.
selectedObjects
.
length
===
1
&&
this
.
selectedObjects
[
0
].
getObjectType
()
===
historyitem_type_Shape
)
var
oSelector
=
this
.
selection
.
groupSelection
?
this
.
selection
.
groupSelection
:
this
;
if
(
oSelector
.
selectedObjects
.
length
===
1
&&
oSelector
.
selectedObjects
[
0
].
getObjectType
()
===
historyitem_type_Shape
)
{
var
oShape
=
this
.
selectedObjects
[
0
];
var
oContent
=
oShape
.
getDocContent
();
if
(
oContent
)
{
this
.
resetInternalSelection
();
this
.
selection
.
textSelection
=
oShape
;
oSelector
.
resetInternalSelection
();
oSelector
.
selection
.
textSelection
=
oShape
;
oContent
.
Cursor_MoveToEndPos
(
false
);
this
.
updateSelectionState
();
this
.
updateOverlay
();
...
...
@@ -386,8 +387,8 @@ DrawingObjectsController.prototype =
this
.
checkSelectedObjectsAndCallback
(
function
(){
oShape
.
createTextBody
();
var
oContent
=
oShape
.
getDocContent
();
o
This
.
resetInternalSelection
();
o
This
.
selection
.
textSelection
=
oShape
;
o
Selector
.
resetInternalSelection
();
o
Selector
.
selection
.
textSelection
=
oShape
;
oContent
.
Cursor_MoveToEndPos
(
false
);
oThis
.
updateSelectionState
();
},
[],
false
,
historydescription_Spreadsheet_AddNewParagraph
);
...
...
This diff is collapsed.
Click to expand it.
word/Editor/Table/TableRecalculate.js
View file @
27bc6e74
...
...
@@ -634,6 +634,7 @@ CTable.prototype.private_RecalculateGrid = function()
MaxTableW
+=
2
*
TableSpacing
;
// 4. Рассчитаем желаемую ширину таблицы таблицы
// Цифра 2 означает добавочная разница
var
MaxContent2
=
[];
var
SumMin
=
0
,
SumMinMargin
=
0
,
SumMinContent
=
0
,
SumMax
=
0
,
SumMaxContent2
=
0
;
var
TableGrid2
=
[];
...
...
@@ -665,9 +666,30 @@ CTable.prototype.private_RecalculateGrid = function()
if
(
SumMin
<
MaxTableW
)
{
// SumMin < MaxTableW, значит у нас есть свободное пространство для распределения
// Если SumMax < MaxTableW, тогда все колонки делаем по ширине MaxContent[CurCol] + MinMargin[CurCol],
// в противном случаем значение (MaxTableW - SumMin) распределяем между колонками в отношении
// MaxContent[CurCol] / SumMaxContent
// У нас есть три типа ширины: Min < Preffered < Max
var
SumMin
=
0
,
SumPreffered
=
0
,
SumMax
=
0
;
var
PreffOverMin
=
[],
MaxOverPreff
=
[];
var
SumPreffOverMin
=
0
,
SumMaxOverPreff
=
0
;
var
PreffContent
=
[];
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
++
CurCol
)
{
var
MinW
=
MinMargin
[
CurCol
]
+
MinContent
[
CurCol
];
var
MaxW
=
MinMargin
[
CurCol
]
+
MaxContent
[
CurCol
];
var
PreffW
=
(
true
===
MaxFlags
[
CurCol
]
?
MaxW
:
MinW
);
SumMin
+=
MinW
;
SumPreffered
+=
PreffW
;
SumMax
+=
MaxW
;
PreffContent
[
CurCol
]
=
PreffW
-
MinMargin
[
CurCol
];
PreffOverMin
[
CurCol
]
=
Math
.
max
(
0
,
PreffW
-
MinW
);
MaxOverPreff
[
CurCol
]
=
Math
.
max
(
0
,
MaxW
-
PreffW
);
SumPreffOverMin
+=
PreffOverMin
[
CurCol
];
SumMaxOverPreff
+=
MaxOverPreff
[
CurCol
];
}
if
(
SumMax
<=
MaxTableW
||
SumMaxContent2
<
0.001
)
{
...
...
@@ -688,28 +710,50 @@ CTable.prototype.private_RecalculateGrid = function()
// максимальным значениям.
if
(
tblwidth_Mm
===
TablePr
.
TableW
.
Type
||
tblwidth_Pct
===
TablePr
.
TableW
.
Type
)
{
if
(
SumMin
<
TableW
)
if
(
SumMin
>=
TableW
)
{
if
(
SumMax
<
TableW
)
// Выставляем минимальные значения
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
++
CurCol
)
{
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
CurCol
++
)
this
.
TableGridCalc
[
CurCol
]
=
MinMargin
[
CurCol
]
+
MinContent
[
CurCol
];
}
}
else
if
(
SumPreffered
>=
TableW
&&
SumPreffOverMin
>
0.001
)
{
this
.
TableGridCalc
[
CurCol
]
=
MinMargin
[
CurCol
]
+
MaxContent
[
CurCol
]
+
(
TableW
-
SumMax
)
*
(
MinMargin
[
CurCol
]
+
MaxContent
[
CurCol
])
/
SumMax
;
// Растягиваем только те колонки, в которых заданы предпочитаемые ширины
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
++
CurCol
)
{
this
.
TableGridCalc
[
CurCol
]
=
MinMargin
[
CurCol
]
+
MinContent
[
CurCol
]
+
(
TableW
-
SumMin
)
*
PreffOverMin
[
CurCol
]
/
SumPreffOverMin
;
}
}
else
{
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
CurCol
++
)
// Если данное условие выполняется, значит у нас все ячейки с предпочитаемыми значениями, тогда
// мы растягиваем все ячейки равномерно. Если не выполняется, значит есть ячейки, в которых
// предпочитаемое значение не задано, и тогда растягиваем только такие ячейки.
if
(
Math
.
abs
(
SumMax
-
SumPreffered
)
<
0.001
)
{
if
(
SumMax
>=
TableW
)
{
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
++
CurCol
)
{
this
.
TableGridCalc
[
CurCol
]
=
MinMargin
[
CurCol
]
+
MinContent
[
CurCol
]
+
(
TableW
-
SumMin
)
*
MaxContent2
[
CurCol
]
/
SumMaxContent2
;
}
}
else
{
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
CurCol
++
)
{
this
.
TableGridCalc
[
CurCol
]
=
MinMargin
[
CurCol
]
+
MaxContent
[
CurCol
]
+
(
TableW
-
SumMax
)
*
(
MinMargin
[
CurCol
]
+
MaxContent
[
CurCol
])
/
SumMax
;
}
}
}
else
{
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
CurCol
++
)
for
(
var
CurCol
=
0
;
CurCol
<
GridCount
;
++
CurCol
)
{
this
.
TableGridCalc
[
CurCol
]
=
MinMargin
[
CurCol
]
+
MinContent
[
CurCol
];
this
.
TableGridCalc
[
CurCol
]
=
MinMargin
[
CurCol
]
+
PreffContent
[
CurCol
]
+
(
TableW
-
SumPreffered
)
*
MaxOverPreff
[
CurCol
]
/
SumMaxOverPreff
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
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