Commit 3a8c1b36 authored by Ilya Kirillov's avatar Ilya Kirillov

Fix bug #32699. Fixed bug with adjusting image size to column width.

parent e4bcecae
...@@ -10968,6 +10968,13 @@ CDocument.prototype.DecreaseIndent = function() ...@@ -10968,6 +10968,13 @@ CDocument.prototype.DecreaseIndent = function()
this.Recalculate(); this.Recalculate();
} }
}; };
/**
* Получаем размеры текущей колонки (используется при вставке изображения).
*/
CDocument.prototype.GetColumnSize = function()
{
return this.Controller.GetColumnSize();
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Settings // Settings
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
...@@ -15920,6 +15927,34 @@ CDocument.prototype.controller_RestoreDocumentStateAfterLoadChanges = function(S ...@@ -15920,6 +15927,34 @@ CDocument.prototype.controller_RestoreDocumentStateAfterLoadChanges = function(S
this.NeedUpdateTarget = true; this.NeedUpdateTarget = true;
} }
}; };
CDocument.prototype.controller_GetColumnSize = function()
{
var ContentPos = true === this.Selection.Use ? ( this.Selection.StartPos < this.Selection.EndPos ? this.Selection.StartPos : this.Selection.EndPos ) : this.CurPos.ContentPos;
var PagePos = this.Get_DocumentPagePositionByContentPosition(this.Get_ContentPosition(this.Selection.Use, false));
var ColumnAbs = PagePos ? PagePos.Column : 0;
var SectPr = this.Get_SectPr(ContentPos);
var Y = SectPr.Get_PageMargin_Top();
var YLimit = SectPr.Get_PageHeight() - SectPr.Get_PageMargin_Bottom();
var X = SectPr.Get_PageMargin_Left();
var XLimit = SectPr.Get_PageWidth() - SectPr.Get_PageMargin_Right();
var ColumnsCount = SectPr.Get_ColumnsCount();
for (var ColumnIndex = 0; ColumnIndex < ColumnAbs; ++ColumnIndex)
{
X += SectPr.Get_ColumnWidth(ColumnIndex);
X += SectPr.Get_ColumnSpace(ColumnIndex);
}
if (ColumnsCount - 1 !== ColumnAbs)
XLimit = X + SectPr.Get_ColumnWidth(ColumnAbs);
return {
W : XLimit - X,
H : YLimit - Y
};
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// //
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -717,3 +717,8 @@ CDocumentControllerBase.prototype.SaveDocumentStateBeforeLoadChanges = function( ...@@ -717,3 +717,8 @@ CDocumentControllerBase.prototype.SaveDocumentStateBeforeLoadChanges = function(
* @param State * @param State
*/ */
CDocumentControllerBase.prototype.RestoreDocumentStateAfterLoadChanges = function(State){}; CDocumentControllerBase.prototype.RestoreDocumentStateAfterLoadChanges = function(State){};
/**
* Получаем размеры текущей колонки.
* @returns {{W: number, H: number}}
*/
CDocumentControllerBase.prototype.GetColumnSize = function(){return {W : 0, H : 0};};
...@@ -497,5 +497,16 @@ CDrawingsController.prototype.RestoreDocumentStateAfterLoadChanges = function(St ...@@ -497,5 +497,16 @@ CDrawingsController.prototype.RestoreDocumentStateAfterLoadChanges = function(St
LogicDocument.Content[ContentPos].Cursor_MoveToStartPos(false); LogicDocument.Content[ContentPos].Cursor_MoveToStartPos(false);
} }
}; };
CDrawingsController.prototype.GetColumnSize = function()
{
// TODO: Переделать
var _w = Math.max(1, AscCommon.Page_Width - (AscCommon.X_Left_Margin + AscCommon.X_Right_Margin));
var _h = Math.max(1, AscCommon.Page_Height - (AscCommon.Y_Top_Margin + AscCommon.Y_Bottom_Margin));
return {
W : AscCommon.Page_Width - (AscCommon.X_Left_Margin + AscCommon.X_Right_Margin),
H : AscCommon.Page_Height - (AscCommon.Y_Top_Margin + AscCommon.Y_Bottom_Margin)
};
};
...@@ -2614,6 +2614,17 @@ CFootnotesController.prototype.RestoreDocumentStateAfterLoadChanges = function(S ...@@ -2614,6 +2614,17 @@ CFootnotesController.prototype.RestoreDocumentStateAfterLoadChanges = function(S
} }
} }
}; };
CFootnotesController.prototype.GetColumnSize = function()
{
// TODO: Переделать
var _w = Math.max(1, AscCommon.Page_Width - (AscCommon.X_Left_Margin + AscCommon.X_Right_Margin));
var _h = Math.max(1, AscCommon.Page_Height - (AscCommon.Y_Top_Margin + AscCommon.Y_Bottom_Margin));
return {
W : AscCommon.Page_Width - (AscCommon.X_Left_Margin + AscCommon.X_Right_Margin),
H : AscCommon.Page_Height - (AscCommon.Y_Top_Margin + AscCommon.Y_Bottom_Margin)
};
};
function CFootEndnotePage() function CFootEndnotePage()
......
...@@ -449,4 +449,25 @@ CHdrFtrController.prototype.RestoreDocumentStateAfterLoadChanges = function(Stat ...@@ -449,4 +449,25 @@ CHdrFtrController.prototype.RestoreDocumentStateAfterLoadChanges = function(Stat
{ {
this.LogicDocument.Document_End_HdrFtrEditing(); this.LogicDocument.Document_End_HdrFtrEditing();
} }
};
CHdrFtrController.prototype.GetColumnSize = function()
{
var CurHdrFtr = this.HdrFtr.CurHdrFtr;
if (null !== CurHdrFtr && -1 !== CurHdrFtr.RecalcInfo.CurPage)
{
var Page = this.LogicDocument.Pages[CurHdrFtr.RecalcInfo.CurPage];
var SectPr = this.LogicDocument.Get_SectPr(Page.Pos);
var Y = SectPr.Get_PageMargin_Top();
var YLimit = SectPr.Get_PageHeight() - SectPr.Get_PageMargin_Bottom();
var X = SectPr.Get_PageMargin_Left();
var XLimit = SectPr.Get_PageWidth() - SectPr.Get_PageMargin_Right();
return {
W : XLimit - X,
H : YLimit - Y
};
}
return {W : 0, H : 0};
}; };
\ No newline at end of file
...@@ -365,3 +365,7 @@ CLogicDocumentController.prototype.RestoreDocumentStateAfterLoadChanges = functi ...@@ -365,3 +365,7 @@ CLogicDocumentController.prototype.RestoreDocumentStateAfterLoadChanges = functi
{ {
this.LogicDocument.controller_RestoreDocumentStateAfterLoadChanges(State); this.LogicDocument.controller_RestoreDocumentStateAfterLoadChanges(State);
}; };
CLogicDocumentController.prototype.GetColumnSize = function()
{
return this.LogicDocument.controller_GetColumnSize();
};
...@@ -5017,8 +5017,10 @@ background-repeat: no-repeat;\ ...@@ -5017,8 +5017,10 @@ background-repeat: no-repeat;\
var _image = this.ImageLoader.LoadImage(url, 1); var _image = this.ImageLoader.LoadImage(url, 1);
if (null != _image) if (null != _image)
{ {
var _w = Math.max(1, AscCommon.Page_Width - (AscCommon.X_Left_Margin + AscCommon.X_Right_Margin)); var ColumnSize = this.WordControl.m_oLogicDocument.GetColumnSize();
var _h = Math.max(1, AscCommon.Page_Height - (AscCommon.Y_Top_Margin + AscCommon.Y_Bottom_Margin));
var _w = Math.max(1, ColumnSize.W);
var _h = Math.max(1, ColumnSize.H);
if (_image.Image != null) if (_image.Image != null)
{ {
var __w = Math.max(parseInt(_image.Image.width * AscCommon.g_dKoef_pix_to_mm), 1); var __w = Math.max(parseInt(_image.Image.width * AscCommon.g_dKoef_pix_to_mm), 1);
...@@ -5068,8 +5070,10 @@ background-repeat: no-repeat;\ ...@@ -5068,8 +5070,10 @@ background-repeat: no-repeat;\
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
this.asyncImageEndLoaded2 = function(_image) this.asyncImageEndLoaded2 = function(_image)
{ {
var _w = Math.max(1, AscCommon.Page_Width - (AscCommon.X_Left_Margin + AscCommon.X_Right_Margin)); var ColumnSize = this.WordControl.m_oLogicDocument.GetColumnSize();
var _h = Math.max(1, AscCommon.Page_Height - (AscCommon.Y_Top_Margin + AscCommon.Y_Bottom_Margin));
var _w = Math.max(1, ColumnSize.W);
var _h = Math.max(1, ColumnSize.H);
if (_image.Image != null) if (_image.Image != null)
{ {
var __w = Math.max(parseInt(_image.Image.width * AscCommon.g_dKoef_pix_to_mm), 1); var __w = Math.max(parseInt(_image.Image.width * AscCommon.g_dKoef_pix_to_mm), 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment