From: tiennou <tie...@gm...> - 2007-03-16 12:30:01
|
Here is the response I got from wx-users... Guess we'll have to cope with this by making our own wxDoc subclass... I'll look into this. Début du message réexpédié : > De : Klaas Holwerda <db...@nl...> > Date : 16 mars 2007 10:27:49 HNEC > À : wx-...@li... > Objet : Rép : Doc/View framework, and stopping LoadObject > Répondre à : wx-...@li... > > tiennou wrote: > >> I guess I should return something wrong somewhere in LoadObject, >> but I can't return NULL (compiler give me an error), so what is >> the correct way of telling the Document that I should use ? > > In wxArt2D derived doec/view framework i handled this problem by > having m_parsedWell flag in a2dDocument. > And i have several ways to find a handler for the document to load. > A handler is coupled to a document template. > Like in void a2dDocument::OnOpenDocument( a2dDocumentEvent& event ) > find a handler based on the document template. > > a2dIOHandlerStrIn* handler = m_documentTemplate- > >GetDocumentIOHandlerForLoad( store, this ); > > LoadObject( store, handler ); > if ( !m_parsedWell || (!store && !store.eof()) ) > { > a2dDocviewGlobals->ReportErrorF( a2dError_FileCouldNotOpen, > _("Sorry, could not Load file %s"), file.GetFullPath().c_str() ); > event.Veto(); > } > > Here GetDocumentIOHandlerForLoad normaly only returns the handler > of the document template. > But it also does test with the handler its CanLoad() method if at > least the file header is oke. > This makes it possible to load files without extensions too. > And the one down here searches a handler in all available templates. > > a2dIOHandlerStrIn* > a2dDocumentTemplateAuto::GetDocumentIOHandlerForLoad > ( a2dDocumentInputStream& stream, a2dDocument* document ) > { > // Find the template for this type of document. > const a2dDocumentTemplateList& allDocTemplates = > a2dDocviewGlobals->GetDocviewCommandProcessor()->GetDocTemplates(); > for( a2dDocumentTemplateList::const_iterator iter = > allDocTemplates.begin(); iter != allDocTemplates.end(); ++iter ) > { > a2dDocumentTemplateList::value_type temp = *iter; > if ( temp != this && temp->GetDocumentTypeName() == > GetDocumentTypeName() && temp->GetDocumentIOHandlerStrIn() && temp- > >GetDocumentIOHandlerStrIn()->CanLoad( stream, document ) ) > return temp->GetDocumentIOHandlerStrIn(); > } > return NULL; > } > > To bad for you, you can not do these things with the standard Doc/ > view framework. I found several other short comings, which made > certain things impossible. > So i think you best can take mine, our you modify the existing one > to suit your needs. > > Klaas > > > > > > -- > Unclassified > > --------------------------------------------------------------------- > To unsubscribe, e-mail: wx-...@li... > For additional commands, e-mail: wx-...@li... > tiennou |