- return (wxDocument *) NULL;
- }
-
- // Existing document
- wxDocTemplate *temp = (wxDocTemplate *) NULL;
-
- wxString path2("");
- if (path != "")
- path2 = path;
-
- if (flags & wxDOC_SILENT)
- temp = FindTemplateForPath(path2);
- else
- temp = SelectDocumentPath(templates, n, path2, flags);
-
- delete[] templates;
-
- if (temp)
- {
- wxDocument *newDoc = temp->CreateDocument(path2, flags);
- if (newDoc)
- {
- newDoc->SetDocumentName(temp->GetDocumentName());
- newDoc->SetDocumentTemplate(temp);
- if (!newDoc->OnOpenDocument(path2))
- {
- delete newDoc;
- return (wxDocument *) NULL;
- }
- AddFileToHistory(path2);
- }
- return newDoc;
- }
- else
- return (wxDocument *) NULL;
-}
-
-wxView *wxDocManager::CreateView(wxDocument *doc, long flags)
-{
- wxDocTemplate **templates = new wxDocTemplate *[m_templates.Number()];
- int n =0;
- int i;
- for (i = 0; i < m_templates.Number(); i++)
- {
- wxDocTemplate *temp = (wxDocTemplate *)(m_templates.Nth(i)->Data());
- if (temp->IsVisible())
- {
- if (temp->GetDocumentName() == doc->GetDocumentName())
- {
- templates[n] = temp;
- n ++;
- }
- }
- }
- if (n == 0)
- {
- delete[] templates;
- return (wxView *) NULL;
- }
- if (n == 1)
- {
- wxDocTemplate *temp = templates[0];
- delete[] templates;
- wxView *view = temp->CreateView(doc, flags);
- if (view)
- view->SetViewName(temp->GetViewName());
- return view;
- }
-
- wxDocTemplate *temp = SelectViewType(templates, n);
- delete[] templates;
- if (temp)
- {
- wxView *view = temp->CreateView(doc, flags);
- if (view)
- view->SetViewName(temp->GetViewName());
- return view;
- }
- else
- return (wxView *) NULL;