Пример #1
0
 public OdtTemplate(DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceResolver,
                    IXDocumentParserService xDocumentParserService)
     : base(documentInformation, xmlNamespaceResolver, xDocumentParserService)
 {
     ScriptSectionFormatting();
     ReplaceFields();
 }
Пример #2
0
        public OdtTemplate( DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceResolver,
		                    IXDocumentParserService xDocumentParserService )
            : base(documentInformation, xmlNamespaceResolver, xDocumentParserService)
        {
            ScriptSectionFormatting();
            ReplaceFields();
        }
Пример #3
0
 public OdsTemplate(DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceResolver,
                    IXDocumentParserService xDocumentParserService)
     : base(documentInformation, xmlNamespaceResolver, xDocumentParserService)
 {
     HandleConditionals();
     ReplaceComments();
 }
Пример #4
0
        public OdsTemplate( DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceResolver,
		                    IXDocumentParserService xDocumentParserService )
            : base(documentInformation, xmlNamespaceResolver, xDocumentParserService)
        {
            HandleConditionals();
            ReplaceComments();
        }
Пример #5
0
        protected Template( DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceResolver,
		                    IXDocumentParserService xDocumentParserService )
        {
            OriginalDocument = documentInformation.Document;
            Meta = documentInformation.Metadata;
            Manager = xmlNamespaceResolver;
            _xDocumentParserService = xDocumentParserService;
            ConvertDocument( documentInformation.Content );
        }
Пример #6
0
 protected Template(DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceResolver,
                    IXDocumentParserService xDocumentParserService)
 {
     OriginalDocument        = documentInformation.Document;
     Meta                    = documentInformation.Metadata;
     Manager                 = xmlNamespaceResolver;
     _xDocumentParserService = xDocumentParserService;
     ConvertDocument(documentInformation.Content);
 }
Пример #7
0
        public Template GenerateTemplate(DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceService,
                                         IXDocumentParserService xDocumentParserService)
        {
            switch (documentInformation.FileType)
            {
            case OdfHandlerService.FileType.Ods:
                return(new OdsTemplate(documentInformation, xmlNamespaceService, xDocumentParserService));

            case OdfHandlerService.FileType.Odt:
                return(new OdtTemplate(documentInformation, xmlNamespaceService, xDocumentParserService));
            }

            throw new NotSupportedException(
                      "Only ods and odt files are supported at this time, and this error should have been caught on pattern initialization.");
        }
Пример #8
0
        public Template GenerateTemplate( DocumentInformation documentInformation, IXmlNamespaceResolver xmlNamespaceService,
		                                  IXDocumentParserService xDocumentParserService )
        {
            switch( documentInformation.FileType )
            {
                case OdfHandlerService.FileType.Ods:
                    return new OdsTemplate( documentInformation, xmlNamespaceService, xDocumentParserService );

                case OdfHandlerService.FileType.Odt:
                    return new OdtTemplate( documentInformation, xmlNamespaceService, xDocumentParserService );
            }

            throw new NotSupportedException(
                "Only ods and odt files are supported at this time, and this error should have been caught on pattern initialization." );
        }
Пример #9
0
        public virtual DocumentInformation BuildDocumentInformation( byte[] document )
        {
            var informationDocument = new byte[document.Length];
            document.CopyTo( informationDocument, 0 );

            using( var archive = _zipFactory.ZipArchiveFromDocument( document ) )
            {
                var fileType = _zipHandlerService.GetFileType( archive );
                var content = _zipHandlerService.GetEntryAsString( archive, "content.xml" );
                var metaXml = _zipHandlerService.GetEntryAsString( archive, "meta.xml" );

                var metadata = _buildOdfMetadataService.BuildOdfMetadata( metaXml, _manager, _ixDocumentParserService );

                var information = new DocumentInformation( fileType, informationDocument, content, metadata );

                return information;
            }
        }
Пример #10
0
        public virtual DocumentInformation BuildDocumentInformation(byte[] document)
        {
            var informationDocument = new byte[document.Length];

            document.CopyTo(informationDocument, 0);

            using (var archive = _zipFactory.ZipArchiveFromDocument(document))
            {
                var fileType = _zipHandlerService.GetFileType(archive);
                var content  = _zipHandlerService.GetEntryAsString(archive, "content.xml");
                var metaXml  = _zipHandlerService.GetEntryAsString(archive, "meta.xml");

                var metadata = _buildOdfMetadataService.BuildOdfMetadata(metaXml, _manager, _ixDocumentParserService);

                var information = new DocumentInformation(fileType, informationDocument, content, metadata);

                return(information);
            }
        }
Пример #11
0
        public void GeneratesOdtTemplate()
        {
            var asm = Assembly.GetExecutingAssembly();
            using( var stream = asm.GetManifestResourceStream( "TestProject.OdtContent.xml" ) )
            {
                if( stream == null ) return;
                var reader = new StreamReader( stream );
                _content = reader.ReadToEnd();
            }

            _odtDocumentInformation = new DocumentInformation(
                OdfHandlerService.FileType.Odt,
                new byte[0], _content,
                new OdfMetadata( typeof( object ) ) );

            _xDocumentParserService.Setup( x => x.Parse( It.IsAny<string>() ) ).Returns( XDocument.Parse( _content ) );

            _sut.GenerateTemplate( _odtDocumentInformation, _xmlNamespaceService, _xDocumentParserService.Object );

            _xDocumentParserService.Verify( x => x.Parse( It.IsAny<string>() ) );
        }