Example #1
0
        public static void AppendAttachList(Document docSource, Document docAttachList, MergeOption Options)
        {
            Section sc = new Section(docSource);

            sc.PageSetup.PaperSize    = PaperSize.A4;
            sc.PageSetup.TopMargin    = ConvertUtil.MillimeterToPoint(2.5 * 10);
            sc.PageSetup.BottomMargin = ConvertUtil.MillimeterToPoint(2.5 * 10);
            sc.PageSetup.LeftMargin   = ConvertUtil.MillimeterToPoint(2.3 * 10);
            sc.PageSetup.RightMargin  = ConvertUtil.MillimeterToPoint(2.3 * 10);

            sc.AppendContent(docAttachList.FirstSection);

            var ps = sc.GetChildNodes(NodeType.Paragraph, true);

            foreach (Paragraph p in ps)
            {
                if (p.ParentNode.NodeType != NodeType.Body)
                {
                    continue;
                }

                if (p.Range.Text == "附件\r")
                {
                    continue;
                }

                WordMerge.SetParaStyle(p, Options);
            }

            // 表格
            //if (Options.Table)
            //{
            //    var tables = sc.GetChildNodes(NodeType.Table, true);

            //    WordMerge.SetTable(tables, Options);
            //}

            // 图片
            if (Options.Picture)
            {
                var images = sc.GetChildNodes(NodeType.Shape, true);
                WordMerge.SetImage(images);
            }

            docSource.Sections.Insert(0, sc);
        }
Example #2
0
        public override VisitorAction VisitSectionEnd(Section section)
        {
            if (IsCompositeAcrossPage(section))
            {
                // If a TOC field spans across more than one page then the hyperlink formatting may show through.
                // Remove direct formatting to avoid this.
                foreach (FieldStart start in section.GetChildNodes(NodeType.FieldStart, true))
                {
                    if (start.FieldType == FieldType.FieldTOC)
                    {
                        Field field = start.GetField();
                        Node  node  = field.Separator;

                        while ((node = node.NextPreOrder(section)) != field.End)
                        {
                            if (node.NodeType == NodeType.Run)
                            {
                                ((Run)node).Font.ClearFormatting();
                            }
                        }
                    }
                }

                foreach (Section cloneSection in SplitComposite(section))
                {
                    cloneSection.PageSetup.SectionStart                   = SectionStart.NewPage;
                    cloneSection.PageSetup.RestartPageNumbering           = true;
                    cloneSection.PageSetup.PageStartingNumber             = section.PageSetup.PageStartingNumber + (section.Document.IndexOf(cloneSection) - section.Document.IndexOf(section));
                    cloneSection.PageSetup.DifferentFirstPageHeaderFooter = false;

                    RemovePageBreaksFromParagraph(cloneSection.Body.LastParagraph);
                }

                RemovePageBreaksFromParagraph(section.Body.LastParagraph);

                // Add new page numbering for the body of the section as well.
                mPageNumberFinder.AddPageNumbersForNode(section.Body, mPageNumberFinder.GetPage(section), mPageNumberFinder.GetPageEnd(section));
            }

            return(VisitorAction.Continue);
        }
        public void ExportarRolADocumentoWord(Document word, Section seccionActual, DocumentoInstanciaXbrlDto instancia, string rol, IDefinicionPlantillaXbrl plantillaDocumento, string claveIdioma)
        {
            //Buscar el la tabla   []
            Table tabla800005 = null;

            NodeCollection allTables = seccionActual.GetChildNodes(NodeType.Table, true);

            foreach (Table table in allTables)
            {
                if (table.Range.Text.Contains("Ingresos nacionales [miembro]") || table.Range.Text.Contains("National income [member]"))
                {
                    tabla800005 = table;
                    break;
                }
            }

            if (tabla800005 != null)
            {
                DateTime fechaInicio = DateTime.MinValue;
                DateTime fechaFin    = DateTime.MinValue;
                //Trimestre actual


                if (XmlUtil.ParsearUnionDateTime(plantillaDocumento.ObtenerVariablePorId("fecha_2015_09_30"), out fechaFin)
                    &&
                    XmlUtil.ParsearUnionDateTime(plantillaDocumento.ObtenerVariablePorId("fecha_2015_01_01"), out fechaInicio))
                {
                    var todasLasMarcas = new DimensionInfoDto()
                    {
                        Explicita   = false,
                        IdDimension = _idDimensionMarcas,
                        ElementoMiembroTipificado = String.Format(_templateTypedMemeberMarcas, _todasLasMarcas)
                    };
                    var todosLosProductos = new DimensionInfoDto()
                    {
                        Explicita   = false,
                        IdDimension = _idDimensionProductos,
                        ElementoMiembroTipificado = String.Format(_templateTypedMemeberProducto, _todosLosProductos)
                    };


                    var combinacionesMarcaProducto = ObtenerCombinacionesDimensionesMarcaProducto(instancia, fechaInicio, fechaFin);

                    var iRenglon            = _renglonWordInicioHechos;
                    var renglonInicioHechos = tabla800005.Rows[_renglonWordInicioHechos];

                    foreach (var combinacion in combinacionesMarcaProducto)
                    {
                        var renglonNuevo = (Row)renglonInicioHechos.Clone(true);

                        tabla800005.InsertBefore(renglonNuevo, renglonInicioHechos);

                        renglonNuevo.Cells[0].FirstParagraph.AppendChild(new Run(word, ObtenerNombreMarcaOProducto(combinacion[0])));
                        renglonNuevo.Cells[0].FirstParagraph.Runs[0].Font.Name = "Arial";
                        renglonNuevo.Cells[0].FirstParagraph.Runs[0].Font.Size = 6;
                        renglonNuevo.Cells[1].FirstParagraph.AppendChild(new Run(word, ObtenerNombreMarcaOProducto(combinacion[1])));
                        renglonNuevo.Cells[1].FirstParagraph.Runs[0].Font.Name = "Arial";
                        renglonNuevo.Cells[1].FirstParagraph.Runs[0].Font.Size = 6;

                        var dimensionTipoIngreso = new DimensionInfoDto()
                        {
                            Explicita = true,
                        };

                        var listaDimensiones = new List <DimensionInfoDto>
                        {
                            combinacion[0],
                            combinacion[1],
                            dimensionTipoIngreso
                        };

                        for (var iCol = _columnaInicioHechos; iCol <= _columnaFinHechos; iCol++)
                        {
                            dimensionTipoIngreso.IdDimension   = _idDimensionTipoIngresos;
                            dimensionTipoIngreso.IdItemMiembro = _elementosMiembroTipoIngreso[iCol - _columnaInicioHechos];

                            var hecho = instancia.BuscarHechos(_idElementoPrimarioIngresos, null, null, fechaInicio,
                                                               fechaFin, listaDimensiones);
                            if (hecho != null && hecho.Count > 0)
                            {
                                string valor = "$ ";

                                double valorDouble = 0;
                                if (Double.TryParse(hecho[0].Valor, NumberStyles.Any, CultureInfo.InvariantCulture,
                                                    out valorDouble))
                                {
                                    valor += valorDouble.ToString("#,##0.00");
                                }
                                else
                                {
                                    valor = hecho[0].Valor;
                                }
                                renglonNuevo.Cells[iCol].FirstParagraph.AppendChild(new Run(word, valor));
                                renglonNuevo.Cells[iCol].FirstParagraph.Runs[0].Font.Name = "Arial";
                                renglonNuevo.Cells[iCol].FirstParagraph.Runs[0].Font.Size = 6;
                            }
                        }
                        iRenglon++;
                    }
                    var renglonTotal = tabla800005.LastRow;
                    for (var iCol = _columnaInicioHechos; iCol <= _columnaFinHechos; iCol++)
                    {
                        var tipoIngreso = new DimensionInfoDto()
                        {
                            Explicita     = true,
                            IdDimension   = _idDimensionTipoIngresos,
                            IdItemMiembro = _elementosMiembroTipoIngreso[iCol - _columnaInicioHechos]
                        };

                        var hecho = instancia.BuscarHechos(_idElementoPrimarioIngresos, null, null, fechaInicio,
                                                           fechaFin, new List <DimensionInfoDto>()
                        {
                            todasLasMarcas, todosLosProductos, tipoIngreso
                        });
                        if (hecho != null && hecho.Count > 0)
                        {
                            string valor       = "$ ";
                            double valorDouble = 0;
                            if (Double.TryParse(hecho[0].Valor, NumberStyles.Any, CultureInfo.InvariantCulture,
                                                out valorDouble))
                            {
                                valor += valorDouble.ToString("#,##0.00");
                            }
                            else
                            {
                                valor = hecho[0].Valor;
                            }
                            renglonTotal.Cells[iCol].FirstParagraph.AppendChild(new Run(word, valor));
                            renglonTotal.Cells[iCol].FirstParagraph.Runs[0].Font.Name = "Arial";
                            renglonTotal.Cells[iCol].FirstParagraph.Runs[0].Font.Size = 6;
                        }
                    }
                }
            }
        }
Example #4
0
        public override VisitorAction VisitSectionEnd(Section section)
        {
            if (IsCompositeAcrossPage(section))
            {
                // If a TOC field spans across more than one page then the hyperlink formatting may show through.
                // Remove direct formatting to avoid this.
                foreach (FieldStart start in section.GetChildNodes(NodeType.FieldStart, true))
                {
                    if (start.FieldType == FieldType.FieldTOC)
                    {
                        Field field = start.GetField();
                        Node node = field.Separator;

                        while ((node = node.NextPreOrder(section)) != field.End)
                            if (node.NodeType == NodeType.Run)
                                ((Run)node).Font.ClearFormatting();
                    }
                }

                foreach (Section cloneSection in SplitComposite(section))
                {
                    cloneSection.PageSetup.SectionStart = SectionStart.NewPage;
                    cloneSection.PageSetup.RestartPageNumbering = true;
                    cloneSection.PageSetup.PageStartingNumber = section.PageSetup.PageStartingNumber + (section.Document.IndexOf(cloneSection) - section.Document.IndexOf(section));
                    cloneSection.PageSetup.DifferentFirstPageHeaderFooter = false;

                    RemovePageBreaksFromParagraph(cloneSection.Body.LastParagraph);
                }

                RemovePageBreaksFromParagraph(section.Body.LastParagraph);

                // Add new page numbering for the body of the section as well.
                mPageNumberFinder.AddPageNumbersForNode(section.Body, mPageNumberFinder.GetPage(section), mPageNumberFinder.GetPageEnd(section));
            }

            return VisitorAction.Continue;
        }
        public void ExportarRolADocumentoWord(Document word, Section section, DocumentoInstanciaXbrlDto instancia, string rol, IDefinicionPlantillaXbrl plantillaDocumento, string claveIdioma)
        {
            DateTime fechaInicio = DateTime.MinValue;
            DateTime fechaFin    = DateTime.MinValue;

            //Navegar por secciones

            for (var iAnio = 0; iAnio < _anios.Length; iAnio++)
            {
                var variableFechaFin    = _anios[iAnio].Equals("A") ? "fecha_2015_09_30" : "fecha_2014_09_30";
                var variableFechaInicio = _anios[iAnio].Equals("A") ? "fecha_2015_01_01" : "fecha_2014_01_01";
                var conAjustes          = false;

                if (XmlUtil.ParsearUnionDateTime(plantillaDocumento.ObtenerVariablePorId(variableFechaFin), out fechaFin)
                    &&
                    XmlUtil.ParsearUnionDateTime(plantillaDocumento.ObtenerVariablePorId(variableFechaInicio), out fechaInicio))
                {
                    for (var iAjustes = 0; iAjustes < _itemsAjustes.Length; iAjustes++)
                    {
                        for (var iPrimario = 0; iPrimario < _elementosPrimarios.Length; iPrimario++)
                        {
                            for (var iComponentesCapital = 0;
                                 iComponentesCapital < _itemComponentesCapital.Length;
                                 iComponentesCapital++)
                            {
                                //Si es capital contable al inicio se envía de fecha de fin = fecha de inicio - 1 día
                                //Si es capital contable al final se envía fecha de fin = fecha de fin
                                DateTime fechaFinFinal = fechaFin;
                                if (iPrimario == 0)
                                {
                                    fechaFinFinal = fechaInicio.AddDays(-1);
                                }
                                var listaDimensiones = new List <DimensionInfoDto>();

                                if (iAjustes != 0)
                                {
                                    listaDimensiones.Add(new DimensionInfoDto()
                                    {
                                        Explicita     = true,
                                        IdDimension   = "ifrs-full_RetrospectiveApplicationAndRetrospectiveRestatementAxis",
                                        IdItemMiembro = _itemsAjustes[iAjustes]
                                    });
                                }
                                if (iComponentesCapital != 24)
                                {
                                    listaDimensiones.Add(new DimensionInfoDto()
                                    {
                                        Explicita     = true,
                                        IdDimension   = "ifrs-full_ComponentsOfEquityAxis",
                                        IdItemMiembro = _itemComponentesCapital[iComponentesCapital]
                                    });
                                }

                                var hechos = instancia.BuscarHechos(_elementosPrimarios[iPrimario], null, null, fechaInicio, fechaFinFinal,
                                                                    listaDimensiones);
                                if (hechos != null && hechos.Count > 0)
                                {
                                    //conHechos = true;
                                    string valorFinal = "$ ";

                                    double valorDouble = 0;
                                    if (Double.TryParse(hechos[0].Valor, NumberStyles.Any, CultureInfo.InvariantCulture,
                                                        out valorDouble))
                                    {
                                        valorFinal = valorFinal + valorDouble.ToString("#,##0.00");
                                    }
                                    else
                                    {
                                        valorFinal = hechos[0].Valor;
                                    }

                                    section.Range.Replace("[" + _anios[iAnio] + "-" + iAjustes + "-" + iPrimario + "-" + iComponentesCapital + "]",
                                                          valorFinal, false, false);
                                    if (iAjustes > 0)
                                    {
                                        conAjustes = true;
                                    }
                                }
                                else
                                {
                                    section.Range.Replace("[" + _anios[iAnio] + "-" + iAjustes + "-" + iPrimario + "-" + iComponentesCapital + "]",
                                                          "", false, false);
                                }
                            }
                        }
                    }
                    //Si no existen datos para ajustes, eliminar renglón  5 a 11
                    if (!conAjustes)
                    {
                        //Buscar la tabla para eliminar renglones
                        NodeCollection allTables = section.GetChildNodes(NodeType.Table, true);
                        var            indiceInicioTablaBorrar = iAnio * TablasPorPeriodo;
                        for (int indiceTablaBorrar = 0; indiceTablaBorrar < TablasPorPeriodo; indiceTablaBorrar++)
                        {
                            for (int iBorrar = 11; iBorrar >= 5; iBorrar--)
                            {
                                ((Table)allTables[indiceTablaBorrar + indiceInicioTablaBorrar]).Rows.RemoveAt(iBorrar);
                            }
                        }
                    }
                }
            }
        }