Commit 731929c3 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

Поиск в презентациях

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58587 954022d7-b5bf-4e40-9824-e11837661b57
parent eecf969b
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
"../../Word/Editor/Table.js", "../../Word/Editor/Table.js",
"../../Word/Editor/Math.js", "../../Word/Editor/Math.js",
"../../Word/Editor/Spelling.js", "../../Word/Editor/Spelling.js",
"../../Word/Editor/Search.js",
"../../Word/Editor/FontClassification.js", "../../Word/Editor/FontClassification.js",
"../../PowerPoint/Editor/Format/ShapePrototype.js", "../../PowerPoint/Editor/Format/ShapePrototype.js",
"../../PowerPoint/Editor/Format/ImagePrototype.js", "../../PowerPoint/Editor/Format/ImagePrototype.js",
......
...@@ -247,24 +247,6 @@ CGroupShape.prototype = ...@@ -247,24 +247,6 @@ CGroupShape.prototype =
} }
}, },
getSearchResults : function(str, num)
{
var commonSearchResults = [];
for(var i = 0; i< this.arrGraphicObjects.length; ++i)
{
var searchResults;
if((searchResults = this.arrGraphicObjects[i].getSearchResults(str, i))!=null)
{
for(var j = 0; j < searchResults.length; ++j)
{
searchResults[j].shapeIndex = i;
}
commonSearchResults = commonSearchResults.concat(searchResults)
}
}
return commonSearchResults.length > 0 ? commonSearchResults : null;
},
getBoundsInGroup: function() getBoundsInGroup: function()
{ {
return getBoundsInGroup(this); return getBoundsInGroup(this);
......
...@@ -121,10 +121,6 @@ CImageShape.prototype = ...@@ -121,10 +121,6 @@ CImageShape.prototype =
return this.blipFill.RasterImageId; return this.blipFill.RasterImageId;
return null; return null;
}, },
getSearchResults: function()
{
return null;
},
isSimpleObject: function() isSimpleObject: function()
{ {
return true; return true;
......
...@@ -526,12 +526,24 @@ CShape.prototype = ...@@ -526,12 +526,24 @@ CShape.prototype =
this.textBoxContent.Search(Str, Props, SearchEngine, Type); this.textBoxContent.Search(Str, Props, SearchEngine, Type);
dd.EndSearchTransform(); dd.EndSearchTransform();
} }
else if(this.txBody && this.txBody.content)
{
//var dd = this.getDrawingDocument();
//dd.StartSearchTransform(this.transformText);
this.txBody.content.Search(Str, Props, SearchEngine, Type);
//dd.EndSearchTransform();
}
}, },
Search_GetId : function(bNext, bCurrent) Search_GetId : function(bNext, bCurrent)
{ {
if(this.textBoxContent) if(this.textBoxContent)
return this.textBoxContent.Search_GetId(bNext, bCurrent); return this.textBoxContent.Search_GetId(bNext, bCurrent);
else if(this.txBody && this.txBody.content)
{
return this.txBody.content.Search_GetId(bNext, bCurrent);
}
return null; return null;
}, },
......
...@@ -117,11 +117,6 @@ function CTextBody() ...@@ -117,11 +117,6 @@ function CTextBody()
CTextBody.prototype = CTextBody.prototype =
{ {
getSearchResults : function(str)
{
return this.content != null ? this.content.getSearchResults(str) : [];
},
createDuplicate: function() createDuplicate: function()
{ {
var ret = new CTextBody(); var ret = new CTextBody();
......
...@@ -154,6 +154,24 @@ CGraphicFrame.prototype = ...@@ -154,6 +154,24 @@ CGraphicFrame.prototype =
return historyitem_type_GraphicFrame; return historyitem_type_GraphicFrame;
}, },
Search : function(Str, Props, SearchEngine, Type)
{
if(this.graphicObject)
{
this.graphicObject.Search(Str, Props, SearchEngine, Type);
}
},
Search_GetId : function(bNext, bCurrent)
{
if(this.graphicObject)
{
return this.graphicObject.Search_GetId(bNext, bCurrent);
}
return null;
},
copy: function() copy: function()
{ {
var ret = new CGraphicFrame(); var ret = new CGraphicFrame();
...@@ -227,67 +245,6 @@ CGraphicFrame.prototype = ...@@ -227,67 +245,6 @@ CGraphicFrame.prototype =
} }
}, },
getSearchResults: function(str)
{
if(this.graphicObject instanceof CTable)
{
var ret = [];
var rows = this.graphicObject.Content;
for(var i = 0; i < rows.length; ++i)
{
var cells = rows[i].Content;
for(var j = 0; j < cells.length; ++j)
{
var cell = cells[j];
var s_arr = cell.Content.getSearchResults(str);
if(Array.isArray(s_arr) && s_arr.length > 0)
{
for(var t = 0; t < s_arr.length; ++t)
{
var s = {};
s.id = STATES_ID_TEXT_ADD;
s.textObject = this;
var TableState = {};
TableState.Selection =
{
Start : true,
Use : true,
StartPos :
{
Pos : { Row : i, Cell : j },
X : this.graphicObject.Selection.StartPos.X,
Y : this.graphicObject.Selection.StartPos.Y
},
EndPos :
{
Pos : { Row : i, Cell : j },
X : this.graphicObject.Selection.EndPos.X,
Y : this.graphicObject.Selection.EndPos.Y
},
Type : table_Selection_Text,
Data : null,
Type2 : table_Selection_Common,
Data2 : null
};
TableState.Selection.Data = [];
TableState.CurCell = { Row : i, Cell : j};
s_arr[t].push( TableState );
s.textSelectionState = s_arr[t];
ret.push(s);
}
}
}
}
return ret;
}
return [];
},
hitInPath: function() hitInPath: function()
{ {
return false; return false;
...@@ -771,15 +728,17 @@ CGraphicFrame.prototype = ...@@ -771,15 +728,17 @@ CGraphicFrame.prototype =
if(this.group) if(this.group)
{ {
var main_group = this.group.getMainGroup(); var main_group = this.group.getMainGroup();
this.parent.graphicObjects.selectObject(main_group, this.parent.num); this.parent.graphicObjects.selectObject(main_group, 0);
main_group.selectObject(this, this.parent.num); main_group.selectObject(this, this.parent.num);
main_group.selection.textSelection = this; main_group.selection.textSelection = this;
} }
else else
{ {
this.parent.graphicObjects.selectObject(this, this.parent.num); this.parent.graphicObjects.selectObject(this, 0);
this.parent.graphicObjects.selection.textSelection = this; this.parent.graphicObjects.selection.textSelection = this;
} }
editor.WordControl.m_oLogicDocument.Set_CurPage(this.parent.num);
editor.WordControl.GoToPage(this.parent.num);
} }
}, },
......
...@@ -44,6 +44,8 @@ CImageShape.prototype.recalcBrush = function() ...@@ -44,6 +44,8 @@ CImageShape.prototype.recalcBrush = function()
this.recalcInfo.recalculateBrush = true; this.recalcInfo.recalculateBrush = true;
}; };
CImageShape.prototype.recalcPen = function() CImageShape.prototype.recalcPen = function()
{ {
this.recalcInfo.recalculatePen = true; this.recalcInfo.recalculatePen = true;
......
...@@ -214,6 +214,8 @@ function CPresentation(DrawingDocument) ...@@ -214,6 +214,8 @@ function CPresentation(DrawingDocument)
this.DrawingDocument = DrawingDocument; this.DrawingDocument = DrawingDocument;
this.SearchEngine = new CDocumentSearch();
this.NeedUpdateTarget = false; this.NeedUpdateTarget = false;
this.viewMode = false; this.viewMode = false;
...@@ -253,6 +255,7 @@ function CPresentation(DrawingDocument) ...@@ -253,6 +255,7 @@ function CPresentation(DrawingDocument)
this.updateSlideIndex = false; this.updateSlideIndex = false;
this.recalcMap = {}; this.recalcMap = {};
this.bClearSearch = true;
this.forwardChangeThemeTimeOutId = null; this.forwardChangeThemeTimeOutId = null;
this.backChangeThemeTimeOutId = null; this.backChangeThemeTimeOutId = null;
...@@ -339,6 +342,11 @@ CPresentation.prototype = ...@@ -339,6 +342,11 @@ CPresentation.prototype =
Recalculate : function(RecalcData) Recalculate : function(RecalcData)
{ {
if(this.bClearSearch)
{
this.SearchEngine.Clear();
this.bClearSearch = false;
}
var _RecalcData = RecalcData ? RecalcData : History.Get_RecalcData(), key, recalcMap, bSync = true; var _RecalcData = RecalcData ? RecalcData : History.Get_RecalcData(), key, recalcMap, bSync = true;
if(_RecalcData.Drawings.All || _RecalcData.Drawings.ThemeInfo) if(_RecalcData.Drawings.All || _RecalcData.Drawings.ThemeInfo)
{ {
...@@ -517,6 +525,249 @@ CPresentation.prototype = ...@@ -517,6 +525,249 @@ CPresentation.prototype =
this.Slides[this.CurPage] && this.Slides[this.CurPage].graphicObjects.checkSelectedObjectsAndCallback(this.Slides[this.CurPage].graphicObjects.addNewParagraph, []); this.Slides[this.CurPage] && this.Slides[this.CurPage].graphicObjects.checkSelectedObjectsAndCallback(this.Slides[this.CurPage].graphicObjects.addNewParagraph, []);
}, },
Search : function(Str, Props)
{
if ( true === this.SearchEngine.Compare( Str, Props ) )
return this.SearchEngine;
this.SearchEngine.Clear();
this.SearchEngine.Set( Str, Props );
for(var i = 0; i < this.Slides.length; ++i)
{
this.Slides[i].Search( Str, Props, this.SearchEngine, search_Common );
}
this.DrawingDocument.ClearCachePages();
this.DrawingDocument.FirePaint();
this.bClearSearch = true;
return this.SearchEngine;
},
Search_GetId : function(isNext)
{
if(this.Slides.length > 0)
{
var i, Id, content, start_index;
var target_text_object = getTargetTextObject(this.Slides[this.CurPage].graphicObjects);
if(target_text_object)
{
if(target_text_object.getObjectType() === historyitem_type_GraphicFrame)
{
Id = target_text_object.graphicObject.Search_GetId(isNext, true);
if(Id !== null)
{
return Id;
}
}
else
{
content = target_text_object.getDocContent();
if(content)
{
Id = content.Search_GetId(isNext, true);
if(Id !== null)
{
return Id;
}
}
}
}
var sp_tree = this.Slides[this.CurPage].cSld.spTree, group_shapes, group_start_index;
if(isNext)
{
if(this.Slides[this.CurPage].graphicObjects.selection.groupSelection)
{
group_shapes = this.Slides[this.CurPage].graphicObjects.selection.groupSelection.arrGraphicObjects;
for(i = 0; i < group_shapes.length; ++i)
{
if(group_shapes[i].selected && group_shapes[i].getObjectType() === historyitem_type_Shape)
{
content = group_shapes[i].getDocContent();
if(content)
{
Id = content.Search_GetId(isNext, isRealObject(target_text_object));
if(Id !== null)
{
return Id;
}
}
group_start_index = i + 1;
}
}
for(i = group_start_index; i < group_shapes.length; ++i)
{
if(group_shapes[i].getObjectType() === historyitem_type_Shape)
{
content = group_shapes[i].getDocContent();
if(content)
{
Id = content.Search_GetId(isNext, false);
if(Id !== null)
{
return Id;
}
}
}
}
for(i = 0; i < sp_tree.length; ++i)
{
if(sp_tree[i] === this.Slides[this.CurPage].graphicObjects.selection.groupSelection)
{
start_index = i + 1;
break;
}
}
if(i === sp_tree.length)
{
start_index = sp_tree.length;
}
}
else if(this.Slides[this.CurPage].graphicObjects.selectedObjects.length === 0)
{
start_index = 0;
}
else
{
for(i = 0; i < sp_tree.length; ++i)
{
if(sp_tree[i].selected)
{
start_index = target_text_object ? i + 1 : i;
break;
}
}
if(i === sp_tree.length)
{
start_index = sp_tree.length;
}
}
Id = this.Slides[this.CurPage].Search_GetId(isNext, start_index);
if(Id !== null)
{
return Id;
}
for(i = this.CurPage + 1; i < this.Slides.length; ++i)
{
Id = this.Slides[i].Search_GetId(isNext, 0);
if(Id !== null)
{
return Id;
}
}
for(i = 0; i < this.CurPage; ++i)
{
Id = this.Slides[i].Search_GetId(isNext, 0);
if(Id !== null)
{
return Id;
}
}
}
else
{
if(this.Slides[this.CurPage].graphicObjects.selection.groupSelection)
{
group_shapes = this.Slides[this.CurPage].graphicObjects.selection.groupSelection.arrGraphicObjects;
for(i = group_shapes.length - 1; i > -1; --i)
{
if(group_shapes[i].selected && group_shapes[i].getObjectType() === historyitem_type_Shape)
{
content = group_shapes[i].getDocContent();
if(content)
{
Id = content.Search_GetId(isNext, isRealObject(target_text_object));
if(Id !== null)
{
return Id;
}
}
group_start_index = i - 1;
}
}
for(i = group_start_index; i > -1; --i)
{
if(group_shapes[i].getObjectType() === historyitem_type_Shape)
{
content = group_shapes[i].getDocContent();
if(content)
{
Id = content.Search_GetId(isNext, false);
if(Id !== null)
{
return Id;
}
}
}
}
for(i = 0; i < sp_tree.length; ++i)
{
if(sp_tree[i] === this.Slides[this.CurPage].graphicObjects.selection.groupSelection)
{
start_index = i - 1;
break;
}
}
if(i === sp_tree.length)
{
start_index = sp_tree.length;
}
}
else if(this.Slides[this.CurPage].graphicObjects.selectedObjects.length === 0)
{
start_index = sp_tree.length - 1;
}
else
{
for(i = sp_tree.length - 1; i > -1; --i)
{
if(sp_tree[i].selected)
{
start_index = target_text_object ? i - 1 : i;
break;
}
}
if(i === sp_tree.length)
{
start_index = -1;
}
}
Id = this.Slides[this.CurPage].Search_GetId(isNext, start_index);
if(Id !== null)
{
return Id;
}
for(i = this.CurPage - 1; i > -1; --i)
{
Id = this.Slides[i].Search_GetId(isNext, this.Slides[i].cSld.spTree.length - 1);
if(Id !== null)
{
return Id;
}
}
for(i = this.Slides.length - 1; i > this.CurPage; --i)
{
Id = this.Slides[i].Search_GetId(isNext, this.Slides[i].cSld.spTree.length - 1);
if(Id !== null)
{
return Id;
}
}
}
}
return null;
},
Search_Select : function(Id)
{
this.SearchEngine.Select(Id);
this.Document_UpdateInterfaceState();
this.Document_UpdateSelectionState();
this.Document_UpdateRulersState();
editor.WordControl.OnUpdateOverlay();
},
findText: function(text, scanForward) findText: function(text, scanForward)
{ {
if(typeof(text) != "string") if(typeof(text) != "string")
...@@ -2493,8 +2744,6 @@ CPresentation.prototype = ...@@ -2493,8 +2744,6 @@ CPresentation.prototype =
this.History.Create_NewPoint(); this.History.Create_NewPoint();
}, },
Document_Undo : function() Document_Undo : function()
{ {
if ( true === CollaborativeEditing.Get_GlobalLock() ) if ( true === CollaborativeEditing.Get_GlobalLock() )
......
...@@ -742,6 +742,32 @@ CShape.prototype.getIsSingleBody = function(x, y) ...@@ -742,6 +742,32 @@ CShape.prototype.getIsSingleBody = function(x, y)
return true; return true;
}; };
CShape.prototype.Set_CurrentElement = function(bUpdate, pageIndex)
{
if(this.parent)
{
var drawing_objects = this.parent.graphicObjects;
drawing_objects.resetSelection();
if(this.group)
{
var main_group = this.group.getMainGroup();
drawing_objects.selectObject(main_group, 0);
main_group.selectObject(this, 0);
main_group.selection.textSelection = this;
drawing_objects.selection.groupSelection = main_group;
}
else
{
drawing_objects.selectObject(this, 0);
drawing_objects.selection.textSelection = this;
}
//var content = this.getDocContent();
//content && content.Set_StartPage(this.parent.num);
editor.WordControl.m_oLogicDocument.Set_CurPage(this.parent.num);
editor.WordControl.GoToPage(this.parent.num);
}
};
CTextBody.prototype.Get_Worksheet = function() CTextBody.prototype.Get_Worksheet = function()
{ {
return this.parent && this.parent.Get_Worksheet && this.parent.Get_Worksheet(); return this.parent && this.parent.Get_Worksheet && this.parent.Get_Worksheet();
......
...@@ -121,6 +121,49 @@ Slide.prototype = ...@@ -121,6 +121,49 @@ Slide.prototype =
}, },
Search: function( Str, Props, Engine, Type )
{
var sp_tree = this.cSld.spTree;
for(var i = 0; i < sp_tree.length; ++i)
{
sp_tree[i].Search(Str, Props, Engine, Type);
}
},
Search_GetId: function(isNext, StartPos)
{
var sp_tree = this.cSld.spTree, i, Id;
if(isNext)
{
for(i = StartPos; i < sp_tree.length; ++i)
{
if(sp_tree[i].Search_GetId)
{
Id = sp_tree[i].Search_GetId(isNext, false);
if(Id !== null)
{
return Id;
}
}
}
}
else
{
for(i = StartPos; i > -1; --i)
{
if(sp_tree[i].Search_GetId)
{
Id = sp_tree[i].Search_GetId(isNext, false);
if(Id !== null)
{
return Id;
}
}
}
}
return null;
},
getMatchingShape: function(type, idx, bSingleBody) getMatchingShape: function(type, idx, bSingleBody)
{ {
var _input_reduced_type; var _input_reduced_type;
......
...@@ -1660,8 +1660,18 @@ asc_docs_api.prototype.stopSearchText = function(){ ...@@ -1660,8 +1660,18 @@ asc_docs_api.prototype.stopSearchText = function(){
this.WordControl.m_oLogicDocument.Search_Stop(); this.WordControl.m_oLogicDocument.Search_Stop();
} }
asc_docs_api.prototype.findText = function(text, scanForward){ asc_docs_api.prototype.findText = function(text, isNext){
return this.WordControl.m_oLogicDocument.findText(text, scanForward);
var SearchEngine = editor.WordControl.m_oLogicDocument.Search(text, {MatchCase: false});
var Id = this.WordControl.m_oLogicDocument.Search_GetId( isNext );
if ( null != Id )
this.WordControl.m_oLogicDocument.Search_Select( Id );
return SearchEngine.Count;
//return this.WordControl.m_oLogicDocument.findText(text, scanForward);
} }
asc_docs_api.prototype.asc_searchEnabled = function(bIsEnabled) asc_docs_api.prototype.asc_searchEnabled = function(bIsEnabled)
......
...@@ -219,6 +219,7 @@ ...@@ -219,6 +219,7 @@
<script src="../../../../OfficeWeb/Word/Editor/Table.js"></script> <script src="../../../../OfficeWeb/Word/Editor/Table.js"></script>
<script src="../../../../OfficeWeb/Word/Editor/Math.js"></script> <script src="../../../../OfficeWeb/Word/Editor/Math.js"></script>
<script src="../../../../OfficeWeb/Word/Editor/Spelling.js"></script> <script src="../../../../OfficeWeb/Word/Editor/Spelling.js"></script>
<script src="../../../../OfficeWeb/Word/Editor/Search.js"></script>
<script src="../../../../OfficeWeb/Word/Editor/FontClassification.js"></script> <script src="../../../../OfficeWeb/Word/Editor/FontClassification.js"></script>
......
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