コード例 #1
0
        /// <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);
        }
コード例 #2
0
		/// <summary>
		/// Reads the image resources.
		/// </summary>
		/// <param name="folder">The folder.</param>
		private DocumentPictureCollection ReadImageResources(string folder)
		{
			DocumentPictureCollection dpc	= new DocumentPictureCollection();
			//If folder not exists, return (folder will only unpacked if not empty)
			if (!Directory.Exists(folder))
				return dpc;
			//Only image files should be in this folder, if not -> Exception
			DirectoryInfo di				= new DirectoryInfo(folder);
			foreach(FileInfo fi in di.GetFiles())
			{
				DocumentPicture dp			= new DocumentPicture(fi.FullName);
				dpc.Add(dp);
			}

			return dpc;
		}
コード例 #3
0
 /// <summary>
 /// Saves the existing graphics.
 /// </summary>
 /// <param name="pictures">The pictures.</param>
 /// <param name="folder">The folder.</param>
 private void SaveExistingGraphics(DocumentPictureCollection pictures, string folder)
 {
     try
     {
         foreach(DocumentPicture dpic in pictures)
             if(!File.Exists(folder+dpic.ImageName))
                 dpic.Image.Save(folder+dpic.ImageName);
     }
     catch(Exception ex)
     {
         throw;
     }
 }