예제 #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>() ) );
        }