Commit 657dab84 authored by GoshaZotov's avatar GoshaZotov Committed by GitHub

Merge pull request #103 from ONLYOFFICE/Feature/special_paste

Feature/special paste
parents 79213b13 524ee66a
...@@ -372,6 +372,16 @@ var editor; ...@@ -372,6 +372,16 @@ var editor;
return false; return false;
}; };
spreadsheet_api.prototype.asc_SpecialPaste = function(props) {
return AscCommon.g_clipboardBase.Special_Paste(props);
};
spreadsheet_api.prototype.asc_SpecialPasteData = function(props) {
if (!this.getViewMode()) {
this.wb.specialPasteData(props);
}
};
spreadsheet_api.prototype.asc_Cut = function() { spreadsheet_api.prototype.asc_Cut = function() {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
......
...@@ -367,6 +367,27 @@ var c_oAscPopUpSelectorType = { ...@@ -367,6 +367,27 @@ var c_oAscPopUpSelectorType = {
Custom: 2 Custom: 2
}; };
var c_oSpecialPasteProps = {
paste: 0,
pasteOnlyFormula: 1,
formulaNumberFormat: 2,
formulaAllFormatting: 3,
formulaWithoutBorders: 4,
formulaColumnWidth: 5,
mergeConditionalFormating: 6,
pasteOnlyValues: 7,
valueNumberFormat: 8,
valueAllFormating: 9,
pasteOnlyFormating: 10,
transpose: 11,
link: 12,
picture: 13,
linkedPicture: 14,
sourceformatting: 15,
destinationFormatting: 16
};
var c_kMaxPrintPages = 1500; var c_kMaxPrintPages = 1500;
//----------------------------------------------------------export---------------------------------------------------- //----------------------------------------------------------export----------------------------------------------------
...@@ -557,4 +578,23 @@ var c_oAscPopUpSelectorType = { ...@@ -557,4 +578,23 @@ var c_oAscPopUpSelectorType = {
prot['Individual'] = prot.Individual; prot['Individual'] = prot.Individual;
prot['Group'] = prot.Group; prot['Group'] = prot.Group;
prot['Custom'] = prot.Custom; prot['Custom'] = prot.Custom;
window['Asc']['c_oSpecialPasteProps'] = window['Asc'].c_oSpecialPasteProps = c_oSpecialPasteProps;
prot = c_oSpecialPasteProps;
prot['paste'] = prot.paste;
prot['pasteOnlyFormula'] = prot.pasteOnlyFormula;
prot['formulaNumberFormat'] = prot.formulaNumberFormat;
prot['formulaAllFormatting'] = prot.formulaAllFormatting;
prot['formulaWithoutBorders'] = prot.formulaWithoutBorders;
prot['formulaColumnWidth'] = prot.formulaColumnWidth;
prot['mergeConditionalFormating'] = prot.mergeConditionalFormating;
prot['pasteOnlyValues'] = prot.pasteOnlyValues;
prot['valueNumberFormat'] = prot.valueNumberFormat;
prot['valueAllFormating'] = prot.valueAllFormating;
prot['pasteOnlyFormating'] = prot.pasteOnlyFormating;
prot['transpose'] = prot.transpose;
prot['link'] = prot.link;
prot['picture'] = prot.picture;
prot['linkedPicture'] = prot.linkedPicture;
prot['sourceformatting'] = prot.sourceformatting;
prot['destinationFormatting'] = prot.destinationFormatting;
})(window); })(window);
...@@ -483,6 +483,11 @@ CHistory.prototype.UndoRedoEnd = function (Point, oRedoObjectParam, bUndo) { ...@@ -483,6 +483,11 @@ CHistory.prototype.UndoRedoEnd = function (Point, oRedoObjectParam, bUndo) {
if (oRedoObjectParam.bIsOn) if (oRedoObjectParam.bIsOn)
this.TurnOn(); this.TurnOn();
if(!window["Asc"]["editor"].wb.clipboard.pasteStart)
{
this.workbook.handlers.trigger("hideSpecialPasteOptions");
}
}; };
CHistory.prototype.Redo = function() CHistory.prototype.Redo = function()
{ {
...@@ -734,6 +739,12 @@ CHistory.prototype._sendCanUndoRedo = function() ...@@ -734,6 +739,12 @@ CHistory.prototype._sendCanUndoRedo = function()
this.workbook.handlers.trigger("setCanUndo", this.Can_Undo()); this.workbook.handlers.trigger("setCanUndo", this.Can_Undo());
this.workbook.handlers.trigger("setCanRedo", this.Can_Redo()); this.workbook.handlers.trigger("setCanRedo", this.Can_Redo());
this.workbook.handlers.trigger("setDocumentModified", this.Have_Changes()); this.workbook.handlers.trigger("setDocumentModified", this.Have_Changes());
//скрываю кнопку специальной вставки при каждом действии/undoredo
//при выполнении специальной вставки и при сохранении(-1 !== this.Index) не скрываю кнопку
if(!window["Asc"]["editor"].wb.clipboard.pasteStart && -1 !== this.Index && !(this.workbook.bUndoChanges || this.workbook.bRedoChanges))
{
this.workbook.handlers.trigger("hideSpecialPasteOptions");
}
}; };
CHistory.prototype.SetSelection = function(range) CHistory.prototype.SetSelection = function(range)
{ {
......
This diff is collapsed.
...@@ -789,6 +789,7 @@ ...@@ -789,6 +789,7 @@
case 27: // Esc case 27: // Esc
t.handlers.trigger("stopFormatPainter"); t.handlers.trigger("stopFormatPainter");
t.handlers.trigger("stopAddShape"); t.handlers.trigger("stopAddShape");
t.handlers.trigger("hideSpecialPasteOptions");
return result; return result;
case 144: //Num Lock case 144: //Num Lock
......
...@@ -463,6 +463,11 @@ ...@@ -463,6 +463,11 @@
} else { } else {
self.model.recalcWB(false); self.model.recalcWB(false);
} }
},
//special paste
"hideSpecialPasteOptions": function () {
self.handlers.trigger("hideSpecialPasteOptions");
} }
}); });
...@@ -709,6 +714,13 @@ ...@@ -709,6 +714,13 @@
if (_canvas) if (_canvas)
self.MobileTouchManager.CheckSelect(_canvas.trackOverlay, color); self.MobileTouchManager.CheckSelect(_canvas.trackOverlay, color);
} }
},
"showSpecialPasteOptions": function(val) {
self.handlers.trigger("asc_onShowSpecialPasteOptions", val);
if(!window['AscCommon'].g_clipboardBase.showSpecialPasteButton)
{
window['AscCommon'].g_clipboardBase.showSpecialPasteButton = true;
}
} }
}); });
...@@ -822,6 +834,13 @@ ...@@ -822,6 +834,13 @@
this.handlers.add('hiddenComments', function () { this.handlers.add('hiddenComments', function () {
return !self.isShowComments; return !self.isShowComments;
}); });
this.model.handlers.add("hideSpecialPasteOptions", function() {
if(window['AscCommon'].g_clipboardBase.showSpecialPasteButton)
{
self.handlers.trigger("asc_onHideSpecialPasteOptions");
window['AscCommon'].g_clipboardBase.showSpecialPasteButton = false;
}
});
this.cellCommentator = new AscCommonExcel.CCellCommentator({ this.cellCommentator = new AscCommonExcel.CCellCommentator({
model: new WorkbookCommentsModel(this.handlers, this.model.aComments), model: new WorkbookCommentsModel(this.handlers, this.model.aComments),
...@@ -1167,6 +1186,7 @@ ...@@ -1167,6 +1186,7 @@
} }
ws.cellCommentator.updateCommentPosition(); ws.cellCommentator.updateCommentPosition();
ws.updateSpecialPasteOptionsPosition();
this._onDocumentPlaceChanged(); this._onDocumentPlaceChanged();
} }
ws.draw(); ws.draw();
...@@ -1665,6 +1685,7 @@ ...@@ -1665,6 +1685,7 @@
// Нужно очистить поиск // Нужно очистить поиск
this._cleanFindResults(); this._cleanFindResults();
this.handlers.trigger("hideSpecialPasteOptions");
return this; return this;
}; };
...@@ -2062,6 +2083,12 @@ ...@@ -2062,6 +2083,12 @@
t.clipboard.pasteData(ws, _format, data1, data2, text_data); t.clipboard.pasteData(ws, _format, data1, data2, text_data);
}; };
WorkbookView.prototype.specialPasteData = function(props) {
if (!this.getCellEditMode()) {
this.getWorksheet().specialPaste(props);
}
};
WorkbookView.prototype.selectionCut = function() { WorkbookView.prototype.selectionCut = function() {
if (this.getCellEditMode()) { if (this.getCellEditMode()) {
this.cellEditor.cutSelection(); this.cellEditor.cutSelection();
......
This diff is collapsed.
...@@ -93,6 +93,16 @@ ...@@ -93,6 +93,16 @@
this.PasteImagesCount = 0; this.PasteImagesCount = 0;
this.PasteImagesCounter = 0; this.PasteImagesCounter = 0;
this.PasteImagesBody = ""; this.PasteImagesBody = "";
//special paste
this.specialPasteData = {};//данные последней вставки перед специальной вставкой
this.specialPasteUndoData = {};//для того, чтобы сделать повторную вставку с помощью special paste нужно сначала откатиться до того состояния, которое было до первой вставки
//параметры специальной вставки из меню.используется класс для EXCEL СSpecialPasteProps. чтобы не протаскивать через все вызываемые функции, добавил это свойство
this.specialPasteProps = null;
this.showSpecialPasteButton = false;//нужно показывать или нет кнопку специальной вставки
this.specialPasteButtonProps = {};//параметры кнопки специальной вставки - позиция. нужно при прокрутке документа, изменения масштаба и тп
} }
CClipboardBase.prototype = CClipboardBase.prototype =
...@@ -921,6 +931,18 @@ ...@@ -921,6 +931,18 @@
this.Api.asc_PasteData(this.LastCopyBinary[0].type, this.LastCopyBinary[0].data); this.Api.asc_PasteData(this.LastCopyBinary[0].type, this.LastCopyBinary[0].data);
} }
return _ret; return _ret;
},
Special_Paste : function(props)
{
this.Api.asc_SpecialPasteData(props);
return true;
},
Clean_SpecialPasteObj : function()
{
this.specialPasteData = {};
this.specialPasteUndoData = {};
} }
}; };
......
...@@ -1776,10 +1776,17 @@ function CopyPasteCorrectString(str) ...@@ -1776,10 +1776,17 @@ function CopyPasteCorrectString(str)
return res; return res;
} }
function Editor_Paste_Exec(api, pastebin, nodeDisplay, onlyBinary) function Editor_Paste_Exec(api, pastebin, nodeDisplay, onlyBinary, specialPasteProps)
{ {
var oPasteProcessor = new PasteProcessor(api, true, true, false); var oPasteProcessor = new PasteProcessor(api, true, true, false);
if(!specialPasteProps)
{
oPasteProcessor.Start(pastebin, nodeDisplay, null, onlyBinary); oPasteProcessor.Start(pastebin, nodeDisplay, null, onlyBinary);
}
else
{
}
} }
function trimString( str ){ function trimString( str ){
return str.replace(/^\s+|\s+$/g, '') ; return str.replace(/^\s+|\s+$/g, '') ;
......
...@@ -1781,6 +1781,17 @@ background-repeat: no-repeat;\ ...@@ -1781,6 +1781,17 @@ background-repeat: no-repeat;\
} }
}; };
asc_docs_api.prototype.asc_SpecialPaste = function(props)
{
return AscCommon.g_clipboardBase.Special_Paste(props);
};
asc_docs_api.prototype.asc_SpecialPasteData = function(props)
{
AscCommon.Editor_Paste_Exec(this, null, null, null, props);
//this.wb.specialPasteData(props);
};
asc_docs_api.prototype.onSaveCallback = function(e, isUndoRequest) asc_docs_api.prototype.onSaveCallback = function(e, isUndoRequest)
{ {
var t = this; var t = this;
......
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