/// <summary> /// Create a blank new document. /// </summary> public void New() { this._xmldoc = new XmlDocument(); this._xmldoc.LoadXml(TextDocumentHelper.GetBlankDocument()); this.NamespaceManager = TextDocumentHelper.NameSpace(this._xmldoc.NameTable); this.DocumentConfigurations2 = new DocumentConfiguration2(); this.DocumentManifest = new DocumentManifest(); this.DocumentManifest.New(); this.DocumentMetadata = new DocumentMetadata(this); this.DocumentMetadata.New(); this.DocumentPictures = new DocumentPictureCollection(); this.DocumentSetting = new DocumentSetting(); this.DocumentSetting.New(); this.DocumentStyles = new DocumentStyles(); this.DocumentStyles.New(this); this.ReadCommonStyles(); this.DocumentThumbnails = new DocumentPictureCollection(); }
/// <summary> /// Loads the document by using the specified importer. /// </summary> /// <param name="file">The the file.</param> public void Load(string file) { this._isLoadedFile = true; this.Styles = new StyleCollection(); this._fields = new FieldsCollection(); this.Content = new ContentCollection(); this._xmldoc = new XmlDocument(); this._xmldoc.LoadXml(TextDocumentHelper.GetBlankDocument()); this.NamespaceManager = TextDocumentHelper.NameSpace(this._xmldoc.NameTable); ImportHandler importHandler = new ImportHandler(); m_importer = importHandler.GetFirstImporter(DocumentTypes.TextDocument, file); m_dirInfo = m_importer.DirInfo; if (m_importer != null) { if (m_importer.NeedNewOpenDocument) { this.New(); } m_importer.Import(this, file); if (m_importer.ImportError != null) { if (m_importer.ImportError.Count > 0) { foreach (object ob in m_importer.ImportError) { if (ob is AODLWarning) { if (((AODLWarning)ob).Message != null) { Console.WriteLine("Err: {0}", ((AODLWarning)ob).Message); } if (((AODLWarning)ob).Node != null) { XmlTextWriter writer = new XmlTextWriter(Console.Out); writer.Formatting = Formatting.Indented; ((AODLWarning)ob).Node.WriteContentTo(writer); } } } } } } this._formCollection.Clearing += FormsCollection_Clear; this._formCollection.Removed += FormsCollection_Removed; }
/// <summary> /// Loads the document by using the specified importer. /// </summary> /// <param name="file">The the file.</param> public void Load(string file) { try { this._isLoadedFile = true; this._xmldoc = new XmlDocument(); this._xmldoc.LoadXml(TextDocumentHelper.GetBlankDocument()); this.NamespaceManager = TextDocumentHelper.NameSpace(this._xmldoc.NameTable); ImportHandler importHandler = new ImportHandler(); IImporter importer = importHandler.GetFirstImporter(DocumentTypes.TextDocument, file); if (importer != null) { if (importer.NeedNewOpenDocument) { this.New(); } importer.Import(this, file); if (importer.ImportError != null) { if (importer.ImportError.Count > 0) { foreach (object ob in importer.ImportError) { if (ob is AODLWarning) { if (((AODLWarning)ob).Message != null) { Console.WriteLine("Err: {0}", ((AODLWarning)ob).Message); } if (((AODLWarning)ob).Node != null) { XmlTextWriter writer = new XmlTextWriter(Console.Out); writer.Formatting = Formatting.Indented; ((AODLWarning)ob).Node.WriteContentTo(writer); } } } } } } } catch (Exception ex) { throw; } }
/// <summary> /// Create a blank new document. /// </summary> public TextDocument New() { this._xmldoc = new XmlDocument(); this.Styles = new StyleCollection(); this._xmldoc.LoadXml(TextDocumentHelper.GetBlankDocument()); this.NamespaceManager = TextDocumentHelper.NameSpace(this._xmldoc.NameTable); this.DocumentConfigurations2 = new DocumentConfiguration2(); this.DocumentManifest = new DocumentManifest(); this.DocumentManifest.New(); this.DocumentMetadata = new DocumentMetadata(this); this.DocumentMetadata.New(); this.DocumentPictures = new DocumentPictureCollection(); this.DocumentSetting = new DocumentSetting(); this.DocumentSetting.New(); this.DocumentStyles = new DocumentStyles(); this.DocumentStyles.New(this); this.ReadCommonStyles(); this.Forms = new ODFFormCollection(); this._formCollection.Clearing += FormsCollection_Clear; this._formCollection.Removed += FormsCollection_Removed; this.Fields.Clear(); this.Content.Clear(); this.VariableDeclarations = new VariableDeclCollection(); this.DocumentThumbnails = new DocumentPictureCollection(); MasterPageFactory.RenameMasterStyles( this.DocumentStyles.Styles, this.XmlDoc, this.NamespaceManager); // Read the moved and renamed styles LocalStyleProcessor lsp = new LocalStyleProcessor(this, false); lsp.ReReadKnownAutomaticStyles(); new MasterPageFactory(m_dirInfo).FillFromXMLDocument(this); return(this); }
/// <summary> /// Loads the document by using the specified importer. /// </summary> /// <param name="file">The the file.</param> /// <param name="importer"></param> public void Load(string file, IImporter importer) { _importer = importer; _isLoadedFile = true; Styles = new StyleCollection(); _fields = new FieldsCollection(); Content = new ContentCollection(); _xmldoc = XDocument.Parse(TextDocumentHelper.GetBlankDocument()); if (_importer != null) { if (_importer.NeedNewOpenDocument) { New(); } _importer.Import(this, file); if (_importer.ImportError != null) { if (_importer.ImportError.Count > 0) { foreach (AODLWarning ob in _importer.ImportError) { if (ob.Message != null) { Console.WriteLine("Err: {0}", ob.Message); } if (ob.Node != null) { using (XmlWriter writer = XmlWriter.Create(Console.Out, new XmlWriterSettings { Indent = true })) { ob.Node.WriteTo(writer); } } } } } } _formCollection.Clearing += FormsCollection_Clear; _formCollection.Removed += FormsCollection_Removed; }
/// <summary> /// Create a blank new document. /// </summary> public TextDocument New() { _xmldoc = XDocument.Parse(TextDocumentHelper.GetBlankDocument()); Styles = new StyleCollection(); DocumentConfigurations2 = new DocumentConfiguration2(); DocumentManifest = new DocumentManifest(); DocumentManifest.New(); DocumentMetadata = new DocumentMetadata(this); DocumentMetadata.New(); DocumentPictures = new DocumentPictureCollection(); DocumentSetting = new DocumentSetting(); DocumentSetting.New(); DocumentStyles = new DocumentStyles(); DocumentStyles.New(this); ReadCommonStyles(); Forms = new ODFFormCollection(); _formCollection.Clearing += FormsCollection_Clear; _formCollection.Removed += FormsCollection_Removed; Fields.Clear(); Content.Clear(); VariableDeclarations = new VariableDeclCollection(); DocumentThumbnails = new DocumentPictureCollection(); MasterPageFactory.RenameMasterStyles( DocumentStyles.Styles, XmlDoc); // Read the moved and renamed styles LocalStyleProcessor lsp = new LocalStyleProcessor(this, false); lsp.ReReadKnownAutomaticStyles(); new MasterPageFactory().FillFromXMLDocument(this); return(this); }