//---------------------------------------------------------------------------
#include <math.h>

#pragma hdrstop

#include "ReportSelectSteel.h"
#include "Word_Automation.h"
#include "StandartProfil.h"
#include "SelectProfilSect.h"
#include "ProcExt.h"
#include "ListConst.h"
#include "RichReport.h"
#include "CheckExecuteU.h"
#include "AboutProg.h"
#include "DrawRSU.h"



static    Variant vTabl;
static    Variant my_tables;
static    Variant my_table;
static TStandartProfil StandartProfil;
static     DATA_SELECT *Ds;

extern TCheckExecute CheckExecute;

void Report_sect_param(int form_profil);
void Report_Rect_sect_param();
void Report_Circ_sect_param();
void Report_centr_tension();
//void Report_Rect_centr_tension();
//void Report_Circ_centr_tension();
void Report_centr_compress();
//void Report_Rect_centr_compress();
//void Report_Circ_centr_compress();
void Report_comp_bending();
void Report_bending();
void Report_tension_bending();

extern bool flag_image;
extern int  Page_Height;
extern int  Page_Width;
extern TMetafile * GrapMeta;
extern TFont     * TheFont;
extern TMetafileCanvas *pCanvas;

//------------------------------------------------------------------
int Report_Checking(TObject *Sender) {
  int i, j, k, rc;
  char stroka[1200];

  AnsiString type_section[7] = {"Прокатной двутавр", "Квадратная труба", "Прямоугольная труба", "Круглая труба","Сварной двутавр",
								"Сквозной двутавр","Тавр" };

  Ds = &(SelectProfilSectForm->Data_select);

  // Создание объекта Word
  Word_Automation.GetActiveWord();
  // Создание документа
  rc = Word_Automation.CreateDocument("ProfilSteelSelect.dot");
  if (rc>0)
	 return rc;

  // Выделить весь документ
  Word_Automation.this_doc.OleProcedure("Select");
  // получить ссылку на объект выделения
  Word_Automation.my_selection = Word_Automation.my_word.OlePropertyGet("Selection");

  if (GrapMeta!=NULL)
	delete GrapMeta;
  GrapMeta = new TMetafile;

  Page_Height = 300; //StrToInt(Edit_h->Text);
  Page_Width = 500; //StrToInt(Edit_w->Text);

  GrapMeta->Height = Page_Height;
  GrapMeta->Width = Page_Width;
  flag_image = false;  // рисовать на pCanvas

  // Оформление рисунков
  FormalPict();

  // Общий вид с системой координат
  bool Checked_buf[6];
  Checked_buf[0] = SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[0];
  Checked_buf[1] = SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[1];
  Checked_buf[2] = SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[2];
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[0] = false;
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[1] = false;
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[2] = true;

  SelectProfilSectForm->Draw_prof_ax(SelectProfilSectForm->N_profil);

  delete pCanvas;

  Word_Automation.PastePictures(GrapMeta, "%PICTURE_0");

  //
  // Напечатать версию программы
  AboutProgForm->GetVersion(stroka);
  Word_Automation.PasteTextPattern((AnsiString)stroka, "%VERS");
  // Отображение расчетной модели балки или стойки
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[0] = true;
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[1] = true;
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[2] = true;

  AnsiString Astr, ind;

  switch (Ds->index_loads) {
	  case 0:
		Word_Automation.PasteTextPattern(" ", "%BALKA_OR_RACK");
	  break;
	  case 1:
		Word_Automation.PasteFilePattern("Model_zagrugh.doc", "%BALKA_OR_RACK");

		for (i=0; i<SelectProfilSectForm->BalkaLoadFrame1->n_beam; i++) {
		  FormalPict();
		  SelectProfilSectForm->BalkaLoadFrame1->ComboBox_num_zagr->ItemIndex = i;
		  SelectProfilSectForm->BalkaLoadFrame1->ComboBox_num_zagrChange(Sender);
		  SelectProfilSectForm->Draw_prof_ax(SelectProfilSectForm->N_profil);

		  delete pCanvas;
		  Word_Automation.PastePictures(GrapMeta, "%ZAGRUGH");
		  Astr = (AnsiString)"Коэффициент надежности по нагрузке "+
				  FloatToStr(SelectProfilSectForm->BalkaLoadFrame1->Koeff_gamma_f[i]);
		  Word_Automation.PasteTextPattern(Astr, "%KOEFF_F");
		  Astr = (AnsiString)"Понижающий коэффициент "+
				  FloatToStr(SelectProfilSectForm->BalkaLoadFrame1->Koeff_low[i]);
		  Word_Automation.PasteTextPattern(Astr, "%KOEFF_LOW");
		  if (i<SelectProfilSectForm->BalkaLoadFrame1->n_beam - 1)
			Word_Automation.PasteTextPattern("%ZAGRUGH\n%KOEFF_F\n%KOEFF_LOW\n%NEXT_ZAGRUGH", "%NEXT_ZAGRUGH");
		  else
			Word_Automation.PasteTextPattern(" ", "%NEXT_ZAGRUGH");
		}
		if (SelectProfilSectForm->BalkaLoadFrame1->n_comb > 0) {   // Есть заданные комбинации
			RichReportForm->RichEditOut->Lines->Add("*-");
			Astr = "№ комб.";
			for (j=0; j<SelectProfilSectForm->BalkaLoadFrame1->n_beam; j++) {
			 if (SelectProfilSectForm->BalkaLoadFrame1->type_zagr[j]==zagrCONSTANT)
			   ind = " C";
			 if (SelectProfilSectForm->BalkaLoadFrame1->type_zagr[j]==zagrTEMPORAR)
			   ind = " L";
			 if (SelectProfilSectForm->BalkaLoadFrame1->type_zagr[j]==zagrTRANSIST)
			   ind = " S";
			 Astr += "|"+ IntToStr(j+1) + ind;
			}
			RichReportForm->RichEditOut->Lines->Add(Astr);
			for (i=0; i<SelectProfilSectForm->BalkaLoadFrame1->n_comb; i++) {
			  Astr = IntToStr(i+1);
			  for (j=0; j<SelectProfilSectForm->BalkaLoadFrame1->n_beam; j++) {
				 Astr += "|"+ FloatToStr(SelectProfilSectForm->BalkaLoadFrame1->Combin_zagr[i][j]);
			  }
			  RichReportForm->RichEditOut->Lines->Add(Astr);
			}
		   RichReportForm->RichEditOut->Lines->Add("*-");
		   Word_Automation.PasteTable(RichReportForm->RichEditOut, "%TABL_COMBIN");

		   my_tables = Word_Automation.my_range.OlePropertyGet("Tables");
		// Получить ссылку на таблицу
		   my_table=my_tables.OleFunction("Item", 1);

		// установка стиля таблицы
		   my_table.OleFunction("AutoFormat", 23, true, false,
										 true, true,
										 true, false,
										 true, false, true);
		}
		else {
			Word_Automation.PasteTextPattern("Комбинации не заданы. ", "%TABL_COMBIN");
		}
	  break;
	  case 2:
		Word_Automation.PasteFilePattern("Model_zagrugh.doc", "%BALKA_OR_RACK");

		for (i=0; i<SelectProfilSectForm->RackLoadFrame1->n_beam; i++) {
		  FormalPict();
		  SelectProfilSectForm->RackLoadFrame1->ComboBox_num_zagr->ItemIndex = i;
		  SelectProfilSectForm->RackLoadFrame1->ComboBox_num_zagrChange(Sender);
		  SelectProfilSectForm->Draw_prof_ax(SelectProfilSectForm->N_profil);

		  delete pCanvas;
		  Word_Automation.PastePictures(GrapMeta, "%ZAGRUGH");
		  Astr = (AnsiString)"Коэффициент надежности по нагрузке "+
				  FloatToStr(SelectProfilSectForm->RackLoadFrame1->Koeff_gamma_f[i]);
		  Word_Automation.PasteTextPattern(Astr, "%KOEFF_F");
		  Astr = (AnsiString)"Понижающий коэффициент "+
				  FloatToStr(SelectProfilSectForm->RackLoadFrame1->Koeff_low[i]);
		  Word_Automation.PasteTextPattern(Astr, "%KOEFF_LOW");
		  if (i<SelectProfilSectForm->RackLoadFrame1->n_beam - 1)
			Word_Automation.PasteTextPattern("%ZAGRUGH\n%KOEFF_F\n%KOEFF_LOW\n%NEXT_ZAGRUGH", "%NEXT_ZAGRUGH");
		  else
			Word_Automation.PasteTextPattern(" ", "%NEXT_ZAGRUGH");
		}
		if (SelectProfilSectForm->RackLoadFrame1->n_comb > 0) {   // Есть заданные комбинации
			RichReportForm->RichEditOut->Lines->Add("*-");
			Astr = "№ комб.";
			for (j=0; j<SelectProfilSectForm->RackLoadFrame1->n_beam; j++) {
			 if (SelectProfilSectForm->RackLoadFrame1->type_zagr[j]==zagrCONSTANT)
			   ind = " C";
			 if (SelectProfilSectForm->RackLoadFrame1->type_zagr[j]==zagrTEMPORAR)
			   ind = " L";
			 if (SelectProfilSectForm->RackLoadFrame1->type_zagr[j]==zagrTRANSIST)
			   ind = " S";
			 Astr += "|"+ IntToStr(j+1) + ind;
			}
			RichReportForm->RichEditOut->Lines->Add(Astr);
			for (i=0; i<SelectProfilSectForm->RackLoadFrame1->n_comb; i++) {
			  Astr = IntToStr(i+1);
			  for (j=0; j<SelectProfilSectForm->RackLoadFrame1->n_beam; j++) {
				 Astr += "|"+ FloatToStr(SelectProfilSectForm->RackLoadFrame1->Combin_zagr[i][j]);
			  }
			  RichReportForm->RichEditOut->Lines->Add(Astr);
			}
		   RichReportForm->RichEditOut->Lines->Add("*-");
		   Word_Automation.PasteTable(RichReportForm->RichEditOut, "%TABL_COMBIN");

		   my_tables = Word_Automation.my_range.OlePropertyGet("Tables");
		// Получить ссылку на таблицу
		   my_table=my_tables.OleFunction("Item", 1);

		// установка стиля таблицы
		   my_table.OleFunction("AutoFormat", 23, true, false,
										 true, true,
										 true, false,
										 true, false, true);
		}
		else {
			Word_Automation.PasteTextPattern("Комбинации не заданы. ", "%TABL_COMBIN");
		}
	  break;
  }
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[0] = Checked_buf[0];
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[1] = Checked_buf[1];
  SelectProfilSectForm->Draw_RSU_Frame1->CheckListBox_Show->Checked[2] = Checked_buf[2];

  switch (Ds->form_profil) {
  case DVUTAVR_STAND:  // Двутавр
  case PERFOR_BEAM:  // Сквозной двутавр
	Word_Automation.PasteFilePattern("Select_Ibeam_sect_param.doc", "%FILE_SECT_PARAM");
  break;
  case TRUBA:
	if (Ds->type_profil != typeCIRC) {
	   Word_Automation.PasteFilePattern("Select_Rect_sect_param.doc", "%FILE_SECT_PARAM");
	}
	else {
	   Word_Automation.PasteFilePattern("Select_Circ_sect_param.doc", "%FILE_SECT_PARAM");
	}
  break;
  case DVUTAVR_WELD:  // Сварной двутавр
	Word_Automation.PasteFilePattern("Select_Ibeam_sect_param.doc", "%FILE_SECT_PARAM");
  break;
  case COMPOSED_BEAM:  // Сварной двутавр
	Word_Automation.PasteFilePattern("Select_Comp_sect_param.doc", "%FILE_SECT_PARAM");
  break;
  }
  // Вывести таблицу основных параметров
  Report_sect_param(Ds->form_profil);
  int num_tabl = 2;
  //-----------------------------------------------------------------
  // Центрально-растянутые
  if (SelectProfilSectForm->TabSheet_KI_CT->TabVisible) {
	switch (Ds->form_profil) {
	case DVUTAVR_STAND:  // Двутавр
	case DVUTAVR_WELD:   // Сварной двутавр
	case PERFOR_BEAM:    // Сквозной двутавр
		//Word_Automation.PasteFilePattern("Select_Ibeam_centr_tension.doc", "%FILE_CENTR_TENS");
		Word_Automation.PasteFilePattern("Report_Ibeam_centr_tension.doc", "%FILE_CENTR_TENS");
		//Report_centr_tension();
	break;
	case TRUBA:
	  if (Ds->type_profil != typeCIRC) {
		 Word_Automation.PasteFilePattern("Report_rect_centr_tension.doc", "%FILE_CENTR_TENS");
		 //Report_Rect_centr_tension();
	  }
	  else {
		 Word_Automation.PasteFilePattern("Report_circ_centr_tension.doc", "%FILE_CENTR_TENS");
		 //Report_Circ_centr_tension();
	  }
	break;
	}
	Report_centr_tension();
	num_tabl ++;
	Word_Automation.PasteTextPattern(IntToStr(num_tabl), "%NUM_TABL_CT");
  }
  else {
	Word_Automation.PasteTextPattern(" ", "%FILE_CENTR_TENS");
  }

  //-----------------------------------------------------------------
  // Центрально-сжатые
  if (SelectProfilSectForm->TabSheet_KI_CC->TabVisible) {
	 switch (Ds->form_profil) {
	 case DVUTAVR_STAND:  // Двутавр
	 case DVUTAVR_WELD:   // Сварной двутавр
	 case PERFOR_BEAM:    // Сквозной двутавр
		//Word_Automation.PasteFilePattern("Select_Ibeam_centr_compress.doc", "%FILE_CENTR_COMP");
		Word_Automation.PasteFilePattern("Report_Ibeam_centr_compress.doc", "%FILE_CENTR_COMP");
		//Report_centr_compress();
	 break;
	 case TRUBA:
	  if (Ds->type_profil != typeCIRC) {
		 Word_Automation.PasteFilePattern("Report_rect_centr_compress.doc", "%FILE_CENTR_COMP");
		 //Report_Rect_centr_compress();
	  }
	  else {
		 Word_Automation.PasteFilePattern("Report_circ_centr_compress.doc", "%FILE_CENTR_COMP");
		 //Report_Circ_centr_compress();
	  }
	 break;
	 }
	 Report_centr_compress();
	 num_tabl ++;
	 Word_Automation.PasteTextPattern(IntToStr(num_tabl), "%NUM_TABL_CC");
  }
  else {
   Word_Automation.PasteTextPattern(" ", "%FILE_CENTR_COMP");
  }

  //-----------------------------------------------------------------
  // Сжато-изгибаемые
  //-----------------------------------------------------------------
  if (SelectProfilSectForm->TabSheet_KI_CB->TabVisible) {
	switch (Ds->form_profil) {
	case DVUTAVR_STAND:  // Двутавр
	  //Word_Automation.PasteFilePattern("Select_Ibeam_compress_bending.doc", "%FILE_COMP_BEND");
	  Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending.doc", "%FILE_COMP_BEND");
	break;
	case DVUTAVR_WELD:   // Сварной двутавр
	  Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending.doc", "%FILE_COMP_BEND");
	break;
	case PERFOR_BEAM:    // Сквозной двутавр
	  Word_Automation.PasteFilePattern("Select_Ibeam_compress_bending.doc", "%FILE_COMP_BEND");
	break;
	case TRUBA:
	  if (Ds->type_profil != typeCIRC) {
		 Word_Automation.PasteFilePattern("Report_rect_compress_bending.doc", "%FILE_COMP_BEND");
	  }
	  else {
		 Word_Automation.PasteFilePattern("Report_circ_compress_bending.doc", "%FILE_COMP_BEND");
	  }
	break;
	}
	Report_comp_bending();
	num_tabl ++;
	Word_Automation.PasteTextPattern(IntToStr(num_tabl), "%NUM_TABL_CB");
  }
  else {
   Word_Automation.PasteTextPattern(" ", "%FILE_COMP_BEND");
  }
  //-----------------------------------------------------------------
  // Растянуто-изгибаемые
  //-----------------------------------------------------------------
  if (SelectProfilSectForm->TabSheet_KI_TB->TabVisible) {
	switch (Ds->form_profil) {
	case DVUTAVR_STAND:  // Двутавр
	  //Word_Automation.PasteFilePattern("Select_Ibeam_compress_bending.doc", "%FILE_COMP_BEND");
	  Word_Automation.PasteFilePattern("Report_Ibeam_tension_bending.doc", "%FILE_TENSION_BEND");
	break;
	case DVUTAVR_WELD:   // Сварной двутавр
	  Word_Automation.PasteFilePattern("Report_Ibeam_tension_bending.doc", "%FILE_TENSION_BEND");
	break;
	case PERFOR_BEAM:    // Сквозной двутавр
	  Word_Automation.PasteFilePattern("Select_Ibeam_tension_bending.doc", "%FILE_TENSION_BEND");
	break;
	case TRUBA:
	  if (Ds->type_profil != typeCIRC) {
		 Word_Automation.PasteFilePattern("Report_rect_tension_bending.doc", "%FILE_TENSION_BEND");
	  }
	  else {
		 Word_Automation.PasteFilePattern("Report_circ_tension_bending.doc", "%FILE_TENSION_BEND");
	  }
	break;
	}
	Report_tension_bending();
	num_tabl ++;
	Word_Automation.PasteTextPattern(IntToStr(num_tabl), "%NUM_TABL_TB");
  }
  else {
   Word_Automation.PasteTextPattern(" ", "%FILE_TENSION_BEND");
  }
  //-----------------------------------------------------------------
  // Изгибаемые
  //-----------------------------------------------------------------
  if (SelectProfilSectForm->TabSheet_KI_B->TabVisible) {
	switch (Ds->form_profil) {
	case DVUTAVR_STAND:  // Двутавр
	  //Word_Automation.PasteFilePattern("Select_Ibeam_bending.doc", "%FILE_BEND");
	  Word_Automation.PasteFilePattern("Report_Ibeam_bending.doc", "%FILE_BEND");
	  Word_Automation.PasteTextPattern(" ", "%FILE_CHECK_WELD");
	break;
	case DVUTAVR_WELD:   // Сварной двутавр
	  //Word_Automation.PasteFilePattern("Select_Ibeam_bending_weld.doc", "%FILE_BEND");
	  Word_Automation.PasteFilePattern("Report_Ibeam_bending.doc", "%FILE_BEND");
	  Word_Automation.PasteFilePattern("Report_CheckWeld_Ibeam.doc", "%FILE_CHECK_WELD");
	  Report_welding();
	break;
	case PERFOR_BEAM:    // Сквозной двутавр
	  Word_Automation.PasteFilePattern("Report_Ibeam_bending_perfor.doc", "%FILE_BEND");
	  Word_Automation.PasteTextPattern(" ", "%FILE_CHECK_WELD");
	break;
	case TRUBA:
	  if (Ds->type_profil != typeCIRC) {
		 Word_Automation.PasteFilePattern("Report_Rect_bending.doc", "%FILE_BEND");
	  }
	  else {
		 Word_Automation.PasteFilePattern("Report_Circ_bending.doc", "%FILE_BEND");
	  }
	  Word_Automation.PasteTextPattern(" ", "%FILE_CHECK_WELD");
	break;
	case COMPOSED_BEAM:
	  Word_Automation.PasteFilePattern("Report_Ibeam_bending.doc", "%FILE_BEND");
	  switch (Ds->index_composed) {
	  case TAVR_DOWN:
		Word_Automation.PasteFilePattern("Report_CheckWeld_CompTavr.doc", "%FILE_CHECK_WELD");
	  break;
	  case TAVR_PLATE_UP:
		Word_Automation.PasteFilePattern("Report_CheckWeld_CompTavr.doc", "%FILE_CHECK_WELD");
	  break;
	  case DVUTAVR_PLATE_DOWN:
		Word_Automation.PasteFilePattern("Report_CheckWeld_CompDvutavr.doc", "%FILE_CHECK_WELD");
	  break;
	  }
	  Report_welding();
	break;

	}
	//-----------------------------------------------------
	// Вывод отчета для изгибаемых элементов
	//-----------------------------------------------------
	Report_bending();
	num_tabl ++;
	Word_Automation.PasteTextPattern(IntToStr(num_tabl), "%NUM_TABL_B");
  }
  else {
   Word_Automation.PasteTextPattern(" ", "%FILE_BEND");
  }

  // Растянуто-изгибаемые
  if (SelectProfilSectForm->TabSheet_KI_TB->TabVisible) {
	switch (Ds->form_profil) {
	case DVUTAVR_STAND:  // Двутавр
	case PERFOR_BEAM:    // Сквозной двутавр
	  Word_Automation.PasteFilePattern("Select_Ibeam_tension_bending.doc", "%FILE_TENSION_BEND");
	  Word_Automation.PasteTextPattern(" ", "%FILE_CHECK_WELD");
	break;
	case DVUTAVR_WELD:   // Сварной двутавр
	case COMPOSED_BEAM:    // Составная балка
	  Word_Automation.PasteFilePattern("Select_Ibeam_tension_bending.doc", "%FILE_TENSION_BEND");
	  Word_Automation.PasteFilePattern("Report_CheckWeld.doc", "%FILE_CHECK_WELD");
	  Report_welding();
	break;
	case TRUBA:
	  if (Ds->type_profil != typeCIRC) {
		 Word_Automation.PasteFilePattern("Select_Rect_tension_bending.doc", "%FILE_TENSION_BEND");
	  }
	  else {
		 Word_Automation.PasteFilePattern("Select_Circ_tension_bending.doc", "%FILE_TENSION_BEND");
	  }
	  Word_Automation.PasteTextPattern(" ", "%FILE_CHECK_WELD");
	break;

	}
	Report_tension_bending();
	num_tabl ++;
	Word_Automation.PasteTextPattern(IntToStr(num_tabl), "%NUM_TABL_TB");
  }
  else {
   Word_Automation.PasteTextPattern(" ", "%FILE_TENSION_BEND");
  }

  Word_Automation.PasteTextPattern(IntToStr(Ds->N_plane), "%NUM_PART");
  Word_Automation.PasteTextPattern(IntToStr(Ds->index_class), "%CLASS");

  Word_Automation.PasteTextPattern(AnsiString(Ds->title_material), "%MATERIAL");
  Word_Automation.PasteTextPattern(FloatToStr(Ds->gamma_m), "%GAMMA_M");

  Word_Automation.PasteTextPattern(FloatToStrF(Ds->gamma_c, ffFixed, 15, 2), "%GAMMA_C");
  Word_Automation.PasteTextPattern(FloatToStrF(Ds->gamma_n, ffFixed, 15, 2), "%GAMMA_N");
  //------------------------------------------------------------
  switch (Ds->form_profil) {
  case DVUTAVR_STAND:
	Word_Automation.PasteTextPattern(type_section[0], "%TYPE_SECT");
  break;
  case TRUBA:
	if (Ds->type_profil==typeSQUARE)
		Word_Automation.PasteTextPattern(type_section[1], "%TYPE_SECT");
	if (Ds->type_profil==typeRECT)
		Word_Automation.PasteTextPattern(type_section[2], "%TYPE_SECT");
	if (Ds->type_profil==typeCIRC)
		Word_Automation.PasteTextPattern(type_section[3], "%TYPE_SECT");
  break;
  case DVUTAVR_WELD:
	Word_Automation.PasteTextPattern(type_section[4], "%TYPE_SECT");
  break;
  case PERFOR_BEAM:
	Word_Automation.PasteTextPattern(type_section[5], "%TYPE_SECT");
  break;
  case COMPOSED_BEAM:
	switch (Ds->index_composed) {
	case TAVR_PLATE_DOWN:
	case TAVR_PLATE_UP:
	   Word_Automation.PasteTextPattern(type_section[6], "%TYPE_SECT");
	break;
	case DVUTAVR_PLATE_DOWN:
	  Word_Automation.PasteTextPattern(type_section[0], "%TYPE_SECT");
	break;
	}
  break;
  }
  if (!Ds->flag_add_limit || Ds->max_height==0 ) {
	Word_Automation.PasteTextPattern("нет", "%MAX_HEIGHT");
  }
  else
	Word_Automation.PasteTextPattern(FloatToStr(Ds->max_height), "%MAX_HEIGHT");

  if (Ds->form_profil != TRUBA)
	Word_Automation.PasteTextPattern("полки", "%POLKI");
  else
	Word_Automation.PasteTextPattern("сечения", "%POLKI");

  if (!Ds->flag_add_limit || Ds->max_width==0 ) {
	Word_Automation.PasteTextPattern("нет", "%MAX_WIDTH");
  }
  else
	Word_Automation.PasteTextPattern(FloatToStr(Ds->max_width), "%MAX_WIDTH");

  Word_Automation.PasteTextPattern(FloatToStr(Ds->Limit_lambda1), "%LAM1");
  Word_Automation.PasteTextPattern(FloatToStr(Ds->Limit_lambda2), "%LAM2");
  Word_Automation.PasteTextPattern(FloatToStr(Ds->Limit_lambda_plus), "%LAM_TENS");

  Word_Automation.PasteTextPattern(" ", "%FILE_CHECK_WELD");

  //-------------------------------------------------------------
  // Вставка таблицы параметров РСУ
  RichReportForm->RichEditOut->Clear();
  char strpl[36];
  char s_length[1200];
  char strk1[1200];
  char strk2[1200];
  char str_step[1200];
  char strN[1200];
  char strMx[1200];
  char strMy[1200];
  char strq[1200];
  double N_, Mx, My, Qy, Qx, q_bal;

  RichReportForm->RichEditOut->Lines->Add("*-");
  strcpy(stroka, "");
  strcpy(s_length, "");
  strcpy(strk1, "");
  strcpy(strk2, "");
  strcpy(str_step, "");
  for (i=0; i<Ds->N_plane; i++) {
	sprintf(strpl," |Элемент %d", i+1);
	strcpy(stroka+strlen(stroka), strpl);
	sprintf(strpl," |%10.0f", Ds->Length[i]);
	strcpy(s_length+strlen(s_length), strpl);
	sprintf(strpl," |%10.0f", Ds->length_XZ[i]);
	strcpy(strk1+strlen(strk1), strpl);
	sprintf(strpl," |%10.0f", Ds->length_XY[i]);
	strcpy(strk2+strlen(strk2), strpl);
	if (Ds->step_comp[i] > 0) {
	  sprintf(strpl," |%10.0f", Ds->step_comp[i]);
	  strcpy(str_step+strlen(str_step), strpl);
	}
	else {
	  sprintf(strpl," |%10.0f", Ds->length_XY[i]);
	  strcpy(str_step+strlen(str_step), strpl);
	}
  }
  RichReportForm->RichEditOut->Lines->Add(AnsiString(stroka));
  RichReportForm->RichEditOut->Lines->Add(" Длина, мм"+AnsiString(s_length));  //Коэффициент расчетной длины \u03BC в пл. XZ";
  if (Ds->form_profil==DVUTAVR_STAND || Ds->form_profil==DVUTAVR_WELD || Ds->form_profil==PERFOR_BEAM) {
	RichReportForm->RichEditOut->Lines->Add(L"Расчетная длина в пл. стенки (XZ), мм" + String(strk1));
	RichReportForm->RichEditOut->Lines->Add(L"Расчетная длина в пл. поясов (XY), мм" + String(strk2));
	RichReportForm->RichEditOut->Lines->Add(L"Шаг раскреплений сжатого пояса, мм" + String(str_step));
  }
  else {
	RichReportForm->RichEditOut->Lines->Add(L"Расчетная длина в пл. XZ, мм" + String(strk1));
	RichReportForm->RichEditOut->Lines->Add(L"Расчетная длина в пл. XY, мм" + String(strk2));
  }

  RichReportForm->RichEditOut->Lines->Add("*-");
  Word_Automation.PasteTable(RichReportForm->RichEditOut, "%TABL_PARAM");

  my_tables = Word_Automation.my_range.OlePropertyGet("Tables");
  // Получить ссылку на таблицу
  my_table=my_tables.OleFunction("Item", 1);

  // Выровнять таблицу по центру
  // wdAlignRowLeft = 0;
  // wdAlignRowCentr = 1;
  // wdAlignRowRight = 2;
  // my_table.OlePropertyGet("Rows").OlePropertySet("Alignment", 1);

  // установка стиля таблицы
  my_table.OleFunction("AutoFormat", 23, true, false,
										 true, true,
										 true, false,
										 true, false, true);

  // Таблицы РСУ
  RichReportForm->RichEditOut->Lines->Add("*-");
  sprintf(stroka,"|N кН|My кН*м|Qz кН|Mz кН*м|Qy кН|qy кН/м");
  RichReportForm->RichEditOut->Lines->Add(AnsiString(stroka));
  for (i=0; i<Ds->N_plane; i++) {
	sprintf(strpl,"№ РСУ| Элемент %d", i+1);
	RichReportForm->RichEditOut->Lines->Add(AnsiString(strpl));
	for (k=0; k<Ds->N_RSU[i]; k++) {
	  sprintf(stroka,"%d|%10.1f|%10.1f|%10.1f|%10.1f|%10.1f|%10.1f",
			  //k+1, Ds->RSU[i][k][0], Ds->RSU[i][k][1], Ds->RSU[i][k][2],
			  //	   Ds->RSU[i][k][3], Ds->RSU[i][k][4], Ds->q_bal[i][k]);
			  k+1, Ds->RSU[i][k][0]*Ds->gamma_n, Ds->RSU[i][k][1]*Ds->gamma_n, Ds->RSU[i][k][2]*Ds->gamma_n,
				   Ds->RSU[i][k][3]*Ds->gamma_n, Ds->RSU[i][k][4]*Ds->gamma_n, Ds->q_bal[i][k]*Ds->gamma_n);
	  RichReportForm->RichEditOut->Lines->Add(AnsiString(stroka));
	}
  }
  RichReportForm->RichEditOut->Lines->Add("*-");
  Word_Automation.PasteTable(RichReportForm->RichEditOut, "%TABL_RSU");

  my_tables = Word_Automation.my_range.OlePropertyGet("Tables");
  // Получить ссылку на таблицу
  my_table=my_tables.OleFunction("Item", 1);

  // Выровнять таблицу по центру
  // wdAlignRowLeft = 0;
  // wdAlignRowCentr = 1;
  // wdAlignRowRight = 2;
  // my_table.OlePropertyGet("Rows").OlePropertySet("Alignment", 1);

  // установка стиля таблицы
  my_table.OleFunction("AutoFormat", 23, true, false,
										 true, true,
										 true, false,
										 true, false, true);
  // Рисунки РСУ
   DrawRSUForm->form_profil = Ds->form_profil;
   DrawRSUForm->index_profil = SelectProfilSectForm->Data_select.index_profil;
   DrawRSUForm->type_profil = SelectProfilSectForm->Data_select.type_profil;
   DrawRSUForm->attit = SelectProfilSectForm->Data_select.perfor_attit;
   DrawRSUForm->alfa = SelectProfilSectForm->Data_select.perfor_alfa;
   DrawRSUForm->plate_thick = SelectProfilSectForm->Data_select.plate_thick;
   DrawRSUForm->plate_width = SelectProfilSectForm->Data_select.plate_width;
   DrawRSUForm->index_GOST_or_TU = SelectProfilSectForm->Data_select.index_GOST_or_TU;
   DrawRSUForm->index_TAVR_GOST_or_TU = SelectProfilSectForm->Data_select.index_TAVR_GOST_or_TU;
   DrawRSUForm->index_composed = SelectProfilSectForm->Data_select.index_composed;
   DrawRSUForm->n_profil = SelectProfilSectForm->N_profil;
   DrawRSUForm->index_draw = 0;
  for (i=0; i<Ds->N_plane; i++) {
	DrawRSUForm->L_beam = Ds->Length[i];
	for (j=0; j<Ds->N_RSU[i]; j++) {
	  for (k=0; k<5; k++) {
		DrawRSUForm->loads[k] = Ds->RSU[i][j][k];
	  }
	  DrawRSUForm->loads[k] = Ds->q_bal[i][j];
	  // Оформление рисунков
	  FormalPict();
	  DrawRSUForm->Draw_All(Sender);
	  delete pCanvas;

	  Word_Automation.PastePictures(GrapMeta, "%PICTURE_RSU");
	  Astr = "Элемент "+IntToStr(i+1)+"; РСУ №"+IntToStr(j+1)+"\n%PICTURE_RSU\n%NEXT_RSU";
	  Word_Automation.PasteTextPattern(Astr, "%NEXT_RSU");
	}
  }
  Word_Automation.PasteTextPattern(" ", "%PICTURE_RSU");
  Word_Automation.PasteTextPattern(" ", "%NEXT_RSU");


  Screen->Cursor = crDefault;
  // Восстановить флаг
  flag_image = true;  // рисовать на форме




  return 0;
}
//-------------------------------------------------------------------------------
// Вывод основных расчетных параметров сечения (для двутавров и труб)
//-------------------------------------------------------------------------------
void Report_sect_param(int form_profil) {

  int in, i, k;
  CHECK_ELEM_PARAM_U *Cp;
  DATA_CHECK_U *Dt;

  Dt = &(CheckExecute.Data_check_U);
  Cp = &(CheckExecute.Check_param);

  Word_Automation.PasteTextPattern(SelectProfilSectForm->Name_prof, "%NUM_SECT");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->hw, ffFixed, 15, 0), "%HW_");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->hef, ffFixed, 15, 0), "%HEF_");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->bef, ffFixed, 15, 0), "%BEF");

  double Nmin;

  in = -1;
  for (i=0; i<Cp->n_RSU; i++) {
	if (Nmin > Cp->RSU[i][0]) {
	  Nmin = Cp->RSU[i][0];
	  in= i;
	}
  }
  in = SelectProfilSectForm->nnel_max;
  Word_Automation.PasteTextPattern((AnsiString)Cp->Steel, "%STEEL");
  Word_Automation.PasteTextPattern(IntToStr(in+1), "%NUMEL");
  Word_Automation.PasteTextPattern(FloatToStr(Cp->hsect), "%HSECT");
  Word_Automation.PasteTextPattern(FloatToStr(Ds->plate_width), "%WP_");
  Word_Automation.PasteTextPattern(FloatToStr(Ds->plate_thick), "%TP_");
	//Word_Automation.PasteTextPattern(FloatToStr(Cp->Sect_Elem.com_sect.dvutavr.h +
	//								 2*Cp->Sect_Elem.com_sect.dvutavr.h1), "%HSECT");
  Word_Automation.PasteTextPattern(FloatToStr(Cp->bsect), "%BSECT");
	//Word_Automation.PasteTextPattern(FloatToStr(Cp->Sect_Elem.com_sect.dvutavr.b1), "%BSECT");
  Word_Automation.PasteTextPattern(FloatToStr(Cp->Sect_Elem.com_sect.dvutavr.b), "%TW");
  Word_Automation.PasteTextPattern(FloatToStr(Cp->Sect_Elem.com_sect.dvutavr.h1), "%TB");

  Word_Automation.PasteTextPattern(FloatToStrF(Dt->length_XZ[in], ffFixed, 15, 0), "%LEN_XZ");
  Word_Automation.PasteTextPattern(FloatToStrF(Dt->length_YZ[in], ffFixed, 15, 0), "%LEN_YZ");
  //------------------------------------------------------------------------------------------
  if (Ds->t1==1000)
	 Word_Automation.PasteTextPattern("свыше "+ FloatToStr(Ds->t0), "%THICK%");
  else
	 Word_Automation.PasteTextPattern("от "+ FloatToStr(Ds->t0) + " до " + FloatToStr(Ds->t1), "%THICK%");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Ryn, ffFixed, 15, 0), "%RYN%");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Ry, ffFixed, 15, 0), "%RY%");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Rs, ffFixed, 15, 0), "%RS%");
  //
  Word_Automation.PasteTextPattern(IntToStr(Cp->nelem), "%NELEM");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->param_sect.Ar*1e-2, ffFixed, 15, 1), "%AN_");
  Word_Automation.PasteTextPattern(Round(Cp->Iy*1e-4, 0), "%I4Y");
  Word_Automation.PasteTextPattern(Round(Cp->Ix*1e-4, 0), "%I4X");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Ad*1e-2, ffFixed, 15, 1), "%AD_");

  Word_Automation.PasteTextPattern(FloatToStrF(Cp->param_sect.Itor*1e-4, ffFixed, 15, 0), "%IT");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->alfa_f, ffFixed, 15, 2), "%AF_");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->alfa_f, ffFixed, 15, 2), "%AlFA_F");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->r_stab, ffFixed, 15, 2), "%R_STAB");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->alfa_stab, ffFixed, 15, 2), "%AlFA_STAB");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_uw, ffFixed, 15, 2), "%LAMB_UW");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_w, ffFixed, 15, 2), "%LAMB_W");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_uf, ffFixed, 15, 2), "%LAMB_UF");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_f, ffFixed, 15, 2), "%LAMB_F");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_f1, ffFixed, 15, 2), "%LAMB_F1");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_f2, ffFixed, 15, 2), "%LAMB_F2");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambdaX, ffFixed, 15, 2), "%LAMBX");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_x, ffFixed, 15, 2), "%LAMB_X");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambdaY, ffFixed, 15, 2), "%LAMBY");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->lambda_y, ffFixed, 15, 2), "%LAMB_Y");

  Word_Automation.PasteTextPattern(FloatToStrF(Cp->fi_x, ffFixed, 15, 2), "%_FI_X");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->fi_y, ffFixed, 15, 2), "%_FI_Y");
  //Word_Automation.PasteTextPattern(FloatToStrF(Cp->cfi_y, ffFixed, 15, 2), "%CFI_Y");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->fi_e, ffFixed, 15, 2), "%_FI_E%");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->fi_ey, ffFixed, 15, 2), "%_FI_EY");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->fi_exy, ffFixed, 15, 2), "%_FI_EXY");
}
//-------------------------------------------------------------------------------
// Вывод отчета для центрально-растянутых элементов (двутавров)
//-------------------------------------------------------------------------------
void Report_centr_tension() {

  int in, i, k;
  CHECK_ELEM_PARAM_U *Cp;
  DATA_CHECK_U *Dt;

  Dt = &(CheckExecute.Data_check_U);
  Cp = &(CheckExecute.Check_param);


  AnsiString Text_coeff;
  for (i=0, k=0; i<SelectProfilSectForm->Data_select.N_check[0]; i++) {
		if (SelectProfilSectForm->Num_prov[0][i]==1) {
		  if (k<9)
			Text_coeff = "%Coeff_0"+IntToStr(k+1);
		  else
			Text_coeff = "%Coeff_"+IntToStr(k+1);
		  if (SelectProfilSectForm->Krit[0][i]>=0) {
			  Word_Automation.PasteTextPattern(FloatToStrF(SelectProfilSectForm->Krit[0][i], ffFixed, 15, 2),
			  Text_coeff);
		  }
		  else {
			Word_Automation.PasteTextPattern("-", Text_coeff);
		  }

		  k++;
		}
  }
  Word_Automation.PasteTextPattern(Round(Cp->NT_, -3), "%NT%");
  Word_Automation.PasteTextPattern(Round(Cp->A_netto, 0), "%ANET");
  Word_Automation.PasteTextPattern(Ds->gamma_c, "%GAMMA_C");
  Word_Automation.PasteTextPattern(Cp->Ry, "%RY%");
  Word_Automation.PasteTextPattern(Round(Cp->k_, 2), "%K%");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaX, 2), "%LAMBDAX");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_ux, 2), "%LAMBDAUX");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaY, 2), "%LAMBDAY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uy, 2), "%LAMBDAUY");

}
//-------------------------------------------------------------------------------
// Вывод отчета для центрально-сжатых элементов (двутавров)
//-------------------------------------------------------------------------------
void Report_centr_compress() {

  int in, i, k;
  CHECK_ELEM_PARAM_U *Cp;
  DATA_CHECK_U *Dt;

  Dt = &(CheckExecute.Data_check_U);
  Cp = &(CheckExecute.Check_param);


  AnsiString Text_coeff;
  if (Dt->flag_step_edge) {
	 Word_Automation.PasteTextPattern("Проверка шага ребер жесткости", "%CHECK_EDGE");
  }
  else {
	 Word_Automation.PasteTextPattern("Проверка необходимости ребер жесткости", "%CHECK_EDGE");
  }

  for (i=0, k=0; i<SelectProfilSectForm->Data_select.N_check[1]; i++) {
		if (SelectProfilSectForm->Num_prov[1][i]==1) {
		  if (k<9)
			Text_coeff = "%Coeff_0"+IntToStr(k+1);
		  else
			Text_coeff = "%Coeff_"+IntToStr(k+1);
		  if (SelectProfilSectForm->Krit[1][i]>=0) {
			switch (k+1) {
			case 5:
			  if (Dt->flag_step_edge) {
				Word_Automation.PasteFilePattern("Report_Ibeam_centr_compression%check05.doc", "%CENTR_COMP_CHECK05");
			  }
			  else {
				Word_Automation.PasteTextPattern(("Требуется установка ребер с шагом не более " + FloatToStr(Dt->edge_step)+ " мм.").c_str(), "%CENTR_COMP_CHECK05");
			  }
			break;
			}
			Word_Automation.PasteTextPattern(FloatToStrF(SelectProfilSectForm->Krit[1][i], ffFixed, 15, 2),
			Text_coeff);
		  }
		  else {
			switch (k+1) {
			case 5:
			  if (Dt->flag_step_edge) {
				Word_Automation.PasteTextPattern("Ребра не требуются, т.к. условная гибкость стенки менее 2.3", "%CENTR_COMP_CHECK05");
			  }
			  else {
				Word_Automation.PasteTextPattern("Ребра не требуются, т.к. стенка не теряет устойчивость.", "%CENTR_COMP_CHECK05");
			  }
			break;
			}
			Word_Automation.PasteTextPattern("-", Text_coeff);
		  }

		  k++;
		}
  }
 //-------------------------------------------------------------------------------------
  // Подстановка параметров
  Word_Automation.PasteTextPattern(Round(Cp->N_, -3), "%N%");
  Word_Automation.PasteTextPattern(Round(Cp->A_netto, 0), "%ANET");
  Word_Automation.PasteTextPattern(Round(Cp->Ar, 0), "%AR%");
  Word_Automation.PasteTextPattern(Round(Cp->fi_e, 3), "%FI_E%");
  Word_Automation.PasteTextPattern(Ds->gamma_c, "%GAMMA_C");
  Word_Automation.PasteTextPattern(Cp->Ry, "%RY%");
  Word_Automation.PasteTextPattern(Round(Cp->k_, 2), "%K%");
  Word_Automation.PasteTextPattern(Round(Cp->k_x, 2), "%KX%");
  Word_Automation.PasteTextPattern(Round(Cp->k_y, 2), "%KY%");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_w, 2), "%LAMBDAW");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uw, 2), "%LAMBDAUW");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaX, 2), "%LAMBDAX");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_ux, 2), "%LAMBDAUX");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaY, 2), "%LAMBDAY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uy, 2), "%LAMBDAUY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_f, 2), "%LAMBDAF");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uf, 2), "%LAMBDAUF");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaX, 2), "%LAMBDAX");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaY, 2), "%LAMBDAY");
  Word_Automation.PasteTextPattern(Round(Cp->fi_e, 2), "%FI_E%");
  Word_Automation.PasteTextPattern(Round(Cp->fi_y, 2), "%FI_Y");
  Word_Automation.PasteTextPattern(Round(Cp->fi_x, 2), "%FI_X");
  Word_Automation.PasteTextPattern(Round(Cp->a_step, 0), "%ASTEP");
  Word_Automation.PasteTextPattern(Round(Cp->hef, 0), "%HEF");



}
//-------------------------------------------------------------------------------
// Вывод отчета для сжато-изгибаемых элементов (двутавров и труб)
//-------------------------------------------------------------------------------
void Report_comp_bending() {

  int in, i, k;
  CHECK_ELEM_PARAM_U *Cp;
  DATA_CHECK_U *Dt;

  Dt = &(CheckExecute.Data_check_U);
  Cp = &(CheckExecute.Check_param);

  AnsiString Text_coeff;

  if (Dt->flag_step_edge) {
	 Word_Automation.PasteTextPattern("Проверка шага ребер жесткости", "%CHECK_EDGE");
  }
  else {
	 Word_Automation.PasteTextPattern("Проверка необходимости ребер жесткости", "%CHECK_EDGE");
  }

  if (Cp->index_105==1) {
	 Word_Automation.PasteTextPattern("п. 8.2.3 с учетом п. 9.1.1 ф. (105)", "%PP_NUM");
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Form105.doc", "%FORM_106OR106");
	 if ((ABS(Cp->N_105))<0.001)
	   Word_Automation.PasteTextPattern("0", "%N%");
	 else
	   Word_Automation.PasteTextPattern(Round(Cp->N_105, 0), "%N%");
	 Word_Automation.PasteTextPattern(Round(Cp->beta, 2), "%BETA");
	 Word_Automation.PasteTextPattern(Cp->n_pow, "%N_POW");
	 Word_Automation.PasteTextPattern(Round(Cp->cx, 2), "%CX");
	 Word_Automation.PasteTextPattern(Round(Cp->cy, 2), "%CY");
	 Word_Automation.PasteTextPattern(Round(Cp->Wx_min, 0), "%W_XN");
	 Word_Automation.PasteTextPattern(Round(Cp->Wy_min, 0), "%W_YN");
  }
  else {
	 Word_Automation.PasteTextPattern("п. 8.2.1 с учетом ф. (106)", "%PP_NUM");
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Form106.doc", "%FORM_106OR106");
	 if ((ABS(Cp->N_))<0.001)
	   Word_Automation.PasteTextPattern("0", "%N%");
	 else
	   Word_Automation.PasteTextPattern(Round(Cp->N_, 0), "%N%");
	 Word_Automation.PasteTextPattern(Round(Cp->y_106, 2), "%Y%");
	 Word_Automation.PasteTextPattern(Round(Cp->x_106, 2), "%X%");
  }

  for (i=0, k=0; i<SelectProfilSectForm->Data_select.N_check[2]; i++) {
		if (SelectProfilSectForm->Num_prov[2][i]==1) {
		  if (k<9)
			Text_coeff = "%Coeff_0"+IntToStr(k+1);
		  else
			Text_coeff = "%Coeff_"+IntToStr(k+1);
		  if (SelectProfilSectForm->Krit[2][i]>=0) {
			switch (k+1) {
			case 4:
			  Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending%check04.doc", "%COMP_BEND_CHECK04");
			break;
			case 7:
			  Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending%check07.doc", "%COMP_BEND_CHECK07");
			break;
			case 8:
			  if (Dt->flag_step_edge) {
				Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending%check08.doc", "%COMP_BEND_CHECK08");
			  }
			  else {
				Word_Automation.PasteTextPattern(("Требуется установка ребер с шагом не более " + FloatToStr(Dt->edge_step)+ " мм.").c_str(), "%COMP_BEND_CHECK08");
			  }
			break;
			case 9:
			  Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending%check09.doc", "%COMP_BEND_CHECK09");
			break;
			case 10:
			  Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending%check10.doc", "%COMP_BEND_CHECK10");
			break;
			}
			Word_Automation.PasteTextPattern(FloatToStrF(SelectProfilSectForm->Krit[2][i], ffFixed, 15, 2),
			Text_coeff);
		  }
		  else {
			switch (k+1) {
			case 4:
			  Word_Automation.PasteTextPattern("Проверка не выполняется, т.к. Ryn<=440 МПа", "%COMP_BEND_CHECK04");
			break;
			case 7:
			  Word_Automation.PasteTextPattern("Проверка не выполняется, т.к. My=0", "%COMP_BEND_CHECK07");
			break;
			case 8:
			  if (Dt->flag_step_edge) {
				Word_Automation.PasteTextPattern("Ребра не требуются, т.к. условная гибкость стенки менее 2.3", "%COMP_BEND_CHECK08");
			  }
			  else {
				Word_Automation.PasteTextPattern("Ребра не требуются, т.к. стенка не теряет устойчивость.", "%COMP_BEND_CHECK08");
			  }
			break;
			case 9:
			  Word_Automation.PasteTextPattern("Проверка не выполняется, т.к. не выполняется неравенство ", "%COMP_BEND_CHECK09");
			break;
			case 10:
			  Word_Automation.PasteTextPattern("Проверка не выполняется, т.к. одно или оба неравенства не выполняются ", "%COMP_BEND_CHECK10");
			break;
			}
			Word_Automation.PasteTextPattern("-", Text_coeff);
		  }

		  k++;
		}
  }

  //-------------------------------------------------------------------------------------
  // Подстановка параметров
  Word_Automation.PasteTextPattern(Round(Cp->A_netto, 0), "%ANET");
  Word_Automation.PasteTextPattern(Round(Cp->Ar, 0), "%AR%");
  Word_Automation.PasteTextPattern(Round(Cp->fi_e, 3), "%FI_E%");
  Word_Automation.PasteTextPattern(Round(Cp->Qy, 0), "%QY");
  Word_Automation.PasteTextPattern(Round(Cp->Qx, 0), "%QX");
  Word_Automation.PasteTextPattern(Round(Cp->Sy, 0), "%SY%");
  Word_Automation.PasteTextPattern(Round(Cp->Sx, 0), "%SX%");
  Word_Automation.PasteTextPattern(Round(Cp->Iy, 0), "%IY");
  Word_Automation.PasteTextPattern(Round(Cp->Ix, 0), "%IX");
  Word_Automation.PasteTextPattern(Cp->tw, "%TW");
  Word_Automation.PasteTextPattern(Cp->tf, "%TF");
  Word_Automation.PasteTextPattern(Ds->gamma_c, "%GAMMA_C");
  Word_Automation.PasteTextPattern(Round(Cp->Aw, 0), "%AW%");
  Word_Automation.PasteTextPattern(Round(Cp->Af, 0), "%AF%");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_xw)), "%SIGXW");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_yw)), "%SIGYW");
  Word_Automation.PasteTextPattern((ABS(Cp->tau_w)), "%TAUW");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_xf)), "%SIGXF");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_yf)), "%SIGYF");
  Word_Automation.PasteTextPattern((ABS(Cp->tau_f)), "%TAUF");
  Word_Automation.PasteTextPattern(Cp->gamma_u, "%GAMMA_U");
  Word_Automation.PasteTextPattern(Cp->delta4, "%DELTA4");
  Word_Automation.PasteTextPattern(Cp->Wtn, "%WTN");
  Word_Automation.PasteTextPattern(Cp->Ru, "%RU");
  Word_Automation.PasteTextPattern(Cp->Rs, "%RS");
  Word_Automation.PasteTextPattern(Cp->Ry, "%RY%");
  Word_Automation.PasteTextPattern(Cp->Ryw, "%RYW");
  Word_Automation.PasteTextPattern(Round(Cp->N_, 0), "%N%");
  Word_Automation.PasteTextPattern(Round(Cp->Mx, 0), "%MX");
  Word_Automation.PasteTextPattern(Round(Cp->My, 0), "%MY");
  Word_Automation.PasteTextPattern(Round(Cp->fi_b, 2), "%FI_B");
  Word_Automation.PasteTextPattern(Round(Cp->fi_y, 2), "%FI_Y");
  Word_Automation.PasteTextPattern(Round(Cp->fi_ey, 2), "%FI_EY");
  Word_Automation.PasteTextPattern(Round(Cp->fi_exy, 2), "%FI_EXY");
  Word_Automation.PasteTextPattern(Round(Cp->c_, 2), "%C%");
  Word_Automation.PasteTextPattern(Round(Cp->c_*Cp->fi_y, 2), "%CFI_Y");
  Word_Automation.PasteTextPattern(Round(Cp->a_step, 0), "%ASTEP");
  Word_Automation.PasteTextPattern(Round(Cp->hef, 0), "%HEF");
  Word_Automation.PasteTextPattern(Round(Cp->k_, 2), "%K%");
  Word_Automation.PasteTextPattern(Round(Cp->k_x, 2), "%KX%");
  Word_Automation.PasteTextPattern(Round(Cp->k_y, 2), "%KY%");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uw_m, 2), "%LAMBDA_UW_M");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uw, 2), "%LAMBDA_UW%");

  Word_Automation.PasteTextPattern(Round(Cp->lambda_uf, 2), "%LAMBDA_UF%");
  Word_Automation.PasteTextPattern(Round(Cp->Wcx, 0), "%WCX");
  Word_Automation.PasteTextPattern(Round(Cp->Wy, 0), "%WY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_w, 2), "%LAMBDAW");
  Word_Automation.PasteTextPattern(Round(Cp->krit_lambdaw, 2), "%KRIT_LAMBDAW");
  if (Cp->lambda_w <= Cp->krit_lambdaw ) {
	  Word_Automation.PasteTextPattern("<", "%LESS_OR_MOOR_ 9");
  }
  else
	  Word_Automation.PasteTextPattern(">", "%LESS_OR_MOOR_ 9");

  Word_Automation.PasteTextPattern(Round(Cp->sigma1w, 0), "%SIGMA1W");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_f, 2), "%LAMBDAF");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uf, 2), "%LAMBDAUF");
  Word_Automation.PasteTextPattern(Round(Cp->delta_b, 1), "%DELTAB");
  Word_Automation.PasteTextPattern(Round(Cp->delta_ub, 1), "%DELTAUB");
  Word_Automation.PasteTextPattern(Round(Cp->fi_1, 2), "%FI_1");
  Word_Automation.PasteTextPattern(Round(Cp->psi, 2), "%PSI");
  Word_Automation.PasteTextPattern(Round(Cp->h_fi_b, 1), "%H%");
  Word_Automation.PasteTextPattern(Round(Cp->l_ef, 0), "%LEF");
  Word_Automation.PasteTextPattern(Round(Cp->Ey, 0), "%E%");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaX, 2), "%LAMBDAX");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaY, 2), "%LAMBDAY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_ux, 2), "%LAMBDAUX");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uy, 2), "%LAMBDAUY");

  Word_Automation.PasteTextPattern(Round(Cp->fi_rect_ez, 2), "%FI_RECT_EZ%");
  Word_Automation.PasteTextPattern(Round(Cp->fi_rect_ey, 2), "%FI_RECT_EY%");
  Word_Automation.PasteTextPattern(Round(Cp->Wm_XZ, 2), "%W_ZMIN");
  Word_Automation.PasteTextPattern(Round(Cp->Wm_XY, 2), "%W_YMIN");
  Word_Automation.PasteTextPattern(Round(Cp->c_y, 2), "%C_Y%");
  Word_Automation.PasteTextPattern(Round(Cp->c_z, 2), "%C_Z%");
  Word_Automation.PasteTextPattern(Round(Cp->delta_x, 2), "%DEL_Y");
  Word_Automation.PasteTextPattern(Round(Cp->delta_y, 2), "%DEL_Z");

  if (Cp->flag_check_step) {
	  if (Cp->index_105==1) {
		 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_step_12_105.doc", "%CALC_STEP_12");
		 Word_Automation.PasteTextPattern(Round(Cp->lambda_b, 0), "%LAMBDA_B");
		 Word_Automation.PasteTextPattern(Round(Cp->lambda_ub, 0), "%LAMBDA_UB");
	  }
	  else {
		 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_step_12_106.doc", "%CALC_STEP_12");
	  }
	  Word_Automation.PasteTextPattern(Round(Cp->step_max, 0), "%STEP_EDGE");
  }
  else {
	Word_Automation.PasteTextPattern("Проверка шага ребер не выполняется", "%CALC_STEP_12");
  }
  if (Cp->N_< -10.0) {
	Word_Automation.PasteTextPattern("<0", "%VALUE_N");
  }
  else
	Word_Automation.PasteTextPattern("=0", "%VALUE_N");

  if (Cp->index_105==0) {
	Word_Automation.PasteTextPattern("пластика не допускается", "%IND_PLAST");
  }
  else
	Word_Automation.PasteTextPattern("пластика допускается", "%IND_PLAST");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_w, 2), "%LAMBDA_W");
  Word_Automation.PasteTextPattern(Round(Cp->del_lamb, 2), "%DEL_LAMB");
  if (Dt->fi_b_type_constr==0)
	 Word_Automation.PasteTextPattern("Балка", "%SCHEMA_CONSTR");
  else
	 Word_Automation.PasteTextPattern("Консоль", "%SCHEMA_CONSTR");
	 // количество закреплений в пролете 0 - без закреплений, 1 - два в середине 2 - одно в середине
  switch (Dt->fi_b_num_constr) {
  case 0:
	 Word_Automation.PasteTextPattern("Без закреплений", "%SCHEMA_COUNT");
	 if (Dt->fi_b_type_load==0)
	   Word_Automation.PasteTextPattern("Сосредоточенная", "%SCHEMA_LOAD");
	 else
	   Word_Automation.PasteTextPattern("Равномерно распределенная", "%SCHEMA_LOAD");
  break;
  case 1:
	 Word_Automation.PasteTextPattern("Два и более", "%SCHEMA_COUNT");
	 Word_Automation.PasteTextPattern("Любая", "%SCHEMA_LOAD");
 break;
  case 2:
	 Word_Automation.PasteTextPattern("Одно в середине", "%SCHEMA_COUNT");
	 switch (Dt->fi_b_type_load) {
	   case 0:
		 Word_Automation.PasteTextPattern("Сосредоточенная в середине", "%SCHEMA_LOAD");
	   break;
	   case 1:
		 Word_Automation.PasteTextPattern("Сосредоточенная в четверти", "%SCHEMA_LOAD");
	   break;
	   case 2:
		 Word_Automation.PasteTextPattern("Равномерно распределенная", "%SCHEMA_LOAD");
	   break;
	 }
  break;
  }
  switch (Dt->fi_b_index_poyas) {
  case 0:
	 Word_Automation.PasteTextPattern("К сжатому (верхнему) поясу ", "%SCHEMA_UP_DOWN");
  break;
  case 1:
	 Word_Automation.PasteTextPattern("К растянутому (нижнему) поясу ", "%SCHEMA_UP_DOWN");
  break;
  case 2:
	 Word_Automation.PasteTextPattern("Ко всему сечению", "%SCHEMA_UP_DOWN");
  break;

  }


}
//-------------------------------------------------------------------------------
// Вывод отчета для изгибаемых элементов (двутавров)
//-------------------------------------------------------------------------------
void Report_bending() {

  int in, i, k;
  CHECK_ELEM_PARAM_U *Cp;
  DATA_CHECK_U *Dt;

  Dt = &(CheckExecute.Data_check_U);
  Cp = &(CheckExecute.Check_param);


  AnsiString Text_coeff;
  if (Dt->flag_step_edge) {
	 Word_Automation.PasteTextPattern("Проверка шага ребер жесткости", "%CHECK_EDGE");
  }
  else {
	 Word_Automation.PasteTextPattern("Проверка необходимости ребер жесткости", "%CHECK_EDGE");
  }
  //-------------------------------------------------------------------------------------
  // Подстановка параметров
  if (Cp->index_105==1) {
	 Word_Automation.PasteTextPattern("п. 8.2.3 с учетом п. 9.1.1 ф. (105)", "%PP_NUM");
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Form105.doc", "%FORM_106OR106");
	 Word_Automation.PasteFilePattern("Report_rect_bending%check_04_105.doc", "%RECT_BEND_04");
	 if ((ABS(Cp->N_105))<0.001)
	   Word_Automation.PasteTextPattern("0", "%N%");
	 else
	   Word_Automation.PasteTextPattern(Round(Cp->N_105, 0), "%N%");
	 Word_Automation.PasteTextPattern(Round(Cp->beta, 2), "%BETA");
	 Word_Automation.PasteTextPattern(Cp->n_pow, "%N_POW");
	 Word_Automation.PasteTextPattern(Round(Cp->cx, 2), "%CX");
	 Word_Automation.PasteTextPattern(Round(Cp->cy, 2), "%CY");
	 Word_Automation.PasteTextPattern(Round(Cp->Wx_min, 0), "%W_XN");
	 Word_Automation.PasteTextPattern(Round(Cp->Wy_min, 0), "%W_YN");
  }
  else {
	 Word_Automation.PasteTextPattern("п. 8.2.1 с учетом ф. (106)", "%PP_NUM");
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Form106.doc", "%FORM_106OR106");
	 Word_Automation.PasteFilePattern("Report_rect_bending%check_04_106.doc", "%RECT_BEND_04");
	 if ((ABS(Cp->N_))<0.001)
	   Word_Automation.PasteTextPattern("0", "%N%");
	 else
	   Word_Automation.PasteTextPattern(Round(Cp->N_, 0), "%N%");
	 Word_Automation.PasteTextPattern(Round(Cp->y_106, 2), "%Y%");
	 Word_Automation.PasteTextPattern(Round(Cp->x_106, 2), "%X%");
  }
  if (Cp->fi_b <=0.85) {
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_fi_b_less.doc", "%CALC_FI_B");
  }
  else {
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_fi_b_more.doc", "%CALC_FI_B");
  }
  switch (Cp->index_stab_w) {
  case 0:
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_stab_10_1.doc", "%CALC_STAB_10");
	 Word_Automation.PasteTextPattern(Round(Cp->k12, 2), "%KW");
  break;
  case 1:
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_stab_10_2.doc", "%CALC_STAB_10");
	 Word_Automation.PasteTextPattern(Round(Cp->sigma_stab_max, 1), "%SIG_STAB");
	 Word_Automation.PasteTextPattern(Round(Cp->sigma_stab_cr, 1), "%SIG_CR");
	 Word_Automation.PasteTextPattern(Round(Cp->tau_stab_max, 1), "%TAU_STAB");
	 Word_Automation.PasteTextPattern(Round(Cp->tau_stab_cr, 1), "%TAU_CR");
	 Word_Automation.PasteTextPattern(Round(Cp->sigma_loc, 1), "%SIG_LOC%");
	 Word_Automation.PasteTextPattern(Round(Cp->sigma_loc_cr, 1), "%SIG_LOC_CR");
  break;
  case 2:
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_stab_10_3.doc", "%CALC_STAB_10");
  break;
  case 3:
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_stab_10_4.doc", "%CALC_STAB_10");
  break;
  }

    for (i=0, k=0; i<SelectProfilSectForm->Data_select.N_check[3]; i++) {
		if (SelectProfilSectForm->Num_prov[3][i]==1) {
		  if (k<9)
			Text_coeff = "%Coeff_0"+IntToStr(k+1);
		  else
			Text_coeff = "%Coeff_"+IntToStr(k+1);
		  if (SelectProfilSectForm->Krit[3][i] >= 0) {
			switch (k+1) {
			case 11:
			  if (Dt->flag_step_edge) {
				if (Cp->index_105==1) {
				  Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_step_11_105.doc", "%CALC_CHECK_11");
				  Word_Automation.PasteTextPattern(Round(Cp->lambda_b, 0), "%LAMBDA_B");
				  Word_Automation.PasteTextPattern(Round(Cp->lambda_ub, 0), "%LAMBDA_UB");
				}
				else {
				  Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_step_11_106.doc", "%CALC_CHECK_11");
				}
				Word_Automation.PasteTextPattern(Round(Dt->edge_step, 0), "%STEP_EDGE");
				Word_Automation.PasteTextPattern(Round(Cp->step_max, 0), "%DEL_A");
			  }
			  else {
				if (SelectProfilSectForm->Krit[3][i] == 2.0) {
				  Word_Automation.PasteTextPattern("Ребра необходимы, т.к. учитываются пластические деформации", "%CALC_CHECK_11");
				}
				else {
				  Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_edge_11.doc", "%CALC_CHECK_11");
				  Word_Automation.PasteTextPattern(FloatToStrF(SelectProfilSectForm->Krit[3][i], ffFixed, 15, 2),	Text_coeff);
				  if (SelectProfilSectForm->Krit[3][i] > 1.0)
					 Word_Automation.PasteTextPattern("Ребра необходимы",	"%Concl_11");
				  else
					 Word_Automation.PasteTextPattern("Ребра не требуются", "%Concl_11");
				}
			  }
			break;
			}
			Word_Automation.PasteTextPattern(FloatToStrF(SelectProfilSectForm->Krit[3][i], ffFixed, 15, 2),	Text_coeff);
		  }
		  else {
		    switch (k+1) {
			case 11:
			  if (Dt->flag_step_edge) {
				Word_Automation.PasteTextPattern("Ребра не требуются, т.к. условная гибкость стенки менее 2.3", "%COMP_BEND_CHECK11");
			  }
			  else {
				Word_Automation.PasteFilePattern("Report_Ibeam_bending%Calc_edge_11.doc", "%CALC_CHECK_11");
				Word_Automation.PasteTextPattern(FloatToStrF(SelectProfilSectForm->Krit[3][i], ffFixed, 15, 2),	Text_coeff);
			  }
			break;
			}
		  }
		  k++;
		}
  }

  Word_Automation.PasteTextPattern(Round(Cp->A_netto, 0), "%ANET");
  Word_Automation.PasteTextPattern(Round(Cp->Qy, 0), "%QY");
  Word_Automation.PasteTextPattern(Round(Cp->Qx, 0), "%QX");
  Word_Automation.PasteTextPattern(Round(Cp->Sy, 0), "%SY%");
  Word_Automation.PasteTextPattern(Round(Cp->Sx, 0), "%SX%");
  Word_Automation.PasteTextPattern(Round(Cp->Iy, 0), "%IY");
  Word_Automation.PasteTextPattern(Round(Cp->Ix, 0), "%IX");
  Word_Automation.PasteTextPattern(Cp->tw, "%TW");
  Word_Automation.PasteTextPattern(Cp->tf, "%TF");
  Word_Automation.PasteTextPattern(Ds->gamma_c, "%GAMMA_C");
  Word_Automation.PasteTextPattern(Round(Cp->Aw, 0), "%AW%");
  Word_Automation.PasteTextPattern(Round(Cp->Af, 0), "%AF%");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_xw)), "%SIGXW");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_yw)), "%SIGYW");
  Word_Automation.PasteTextPattern((ABS(Cp->tau_w)), "%TAUW");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_xf)), "%SIGXF");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_yf)), "%SIGYF");
  Word_Automation.PasteTextPattern((ABS(Cp->tau_f)), "%TAUF");
  Word_Automation.PasteTextPattern(Cp->Rs, "%RS");
  Word_Automation.PasteTextPattern(Cp->Ry, "%RY%");

  Word_Automation.PasteTextPattern(Cp->Ryw, "%RYW");
  Word_Automation.PasteTextPattern(Round(Cp->N_, 0), "%N%");
  Word_Automation.PasteTextPattern(Round(Cp->Mx, 0), "%MX");
  Word_Automation.PasteTextPattern(Round(Cp->My, 0), "%MY");
  Word_Automation.PasteTextPattern(Round(Cp->fi_b, 2), "%FI_B");
  Word_Automation.PasteTextPattern(Round(Cp->Wcx, 0), "%WCX");
  Word_Automation.PasteTextPattern(Round(Cp->Wy, 0), "%WY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_w, 2), "%LAMBDAW");
  Word_Automation.PasteTextPattern(Round(Cp->krit_lambdaw, 2), "%KRIT_LAMBDAW");
  if (Cp->lambda_w <= Cp->krit_lambdaw ) {
	  Word_Automation.PasteTextPattern("<", "%LESS_OR_MOOR_ 9");
  }
  else
	  Word_Automation.PasteTextPattern(">", "%LESS_OR_MOOR_ 9");

  Word_Automation.PasteTextPattern(Round(Cp->sigma1w, 0), "%SIGMA1W");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_f, 2), "%LAMBDAF");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uf, 2), "%LAMBDAUF");
  Word_Automation.PasteTextPattern(Round(Cp->delta_b, 1), "%DELTAB");
  Word_Automation.PasteTextPattern(Round(Cp->delta_ub, 1), "%DELTAUB");
  Word_Automation.PasteTextPattern(Round(Cp->fi_1, 2), "%FI_1");
  Word_Automation.PasteTextPattern(Round(Cp->psi, 2), "%PSI");
  Word_Automation.PasteTextPattern(Round(Cp->h_fi_b, 1), "%H%");
  Word_Automation.PasteTextPattern(Round(Cp->l_ef, 0), "%LEF");
  Word_Automation.PasteTextPattern(Round(Cp->Ey, 0), "%E%");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->alfa_f, ffFixed, 15, 2), "%AlFA_F");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->r_stab, ffFixed, 15, 2), "%R_STAB");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->alfa_stab, ffFixed, 15, 2), "%AlFA_STAB");
  if (Cp->N_<-10) {
	Word_Automation.PasteTextPattern("<0", "%VALUE_N");
  }
  else
	Word_Automation.PasteTextPattern("=0", "%VALUE_N");

  if (Cp->index_105==0) {
	Word_Automation.PasteTextPattern("пластика не допускается", "%IND_PLAST");
  }
  else
	Word_Automation.PasteTextPattern("пластика допускается", "%IND_PLAST");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_w, 2), "%LAMBDA_W");
  Word_Automation.PasteTextPattern(Round(Cp->del_lamb, 2), "%DEL_LAMB");
  if (Dt->fi_b_type_constr==0)
	 Word_Automation.PasteTextPattern("Балка", "%SCHEMA_CONSTR");
  else
	 Word_Automation.PasteTextPattern("Консоль", "%SCHEMA_CONSTR");
	 // количество закреплений в пролете 0 - без закреплений, 1 - два в середине 2 - одно в середине
  // Для перфорированного двутавра
  Word_Automation.PasteTextPattern(FloatToStr(Round(Cp->M13, 0)), "%M13");
  Word_Automation.PasteTextPattern(FloatToStr(Round(Cp->M24, 0)), "%M24");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Q13, ffFixed, 9,0), "%Q13");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Q24, ffFixed, 9,0), "%Q24");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Qperf, ffFixed, 9,0), "%QPERF");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Wx_perf, ffFixed, 9,0), "%WX%");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Wmax_tavr, ffFixed, 9,0), "%WMAX");
  Word_Automation.PasteTextPattern(FloatToStrF(Cp->Wmin_tavr, ffFixed, 9,0), "%WMIN");
  Word_Automation.PasteTextPattern(Cp->hef, "%HEF");
  Word_Automation.PasteTextPattern(Dt->perfor_a, "%A_PERF");
  Word_Automation.PasteTextPattern(Cp->s_perf, "%S_PERF");
  Word_Automation.PasteTextPattern(Cp->Ru, "%RU");
  Word_Automation.PasteTextPattern("1.3", "%GAMMA_U");

  switch (Dt->fi_b_num_constr) {
  case 0:
	 Word_Automation.PasteTextPattern("Без закреплений", "%SCHEMA_COUNT");
	 if (Dt->fi_b_type_load==0)
	   Word_Automation.PasteTextPattern("Сосредоточенная", "%SCHEMA_LOAD");
	 else
	   Word_Automation.PasteTextPattern("Равномерно распределенная", "%SCHEMA_LOAD");
  break;
  case 1:
	 Word_Automation.PasteTextPattern("Два и более", "%SCHEMA_COUNT");
	 Word_Automation.PasteTextPattern("Любая", "%SCHEMA_LOAD");
 break;
  case 2:
	 Word_Automation.PasteTextPattern("Одно в середине", "%SCHEMA_COUNT");
	 switch (Dt->fi_b_type_load) {
	   case 0:
		 Word_Automation.PasteTextPattern("Сосредоточенная в середине", "%SCHEMA_LOAD");
	   break;
	   case 1:
		 Word_Automation.PasteTextPattern("Сосредоточенная в четверти", "%SCHEMA_LOAD");
	   break;
	   case 2:
		 Word_Automation.PasteTextPattern("Равномерно распределенная", "%SCHEMA_LOAD");
	   break;
	 }
  break;
  }
  switch (Dt->fi_b_index_poyas) {
  case 0:
	 Word_Automation.PasteTextPattern("К сжатому (верхнему) поясу ", "%SCHEMA_UP_DOWN");
  break;
  case 1:
	 Word_Automation.PasteTextPattern("К растянутому (нижнему) поясу ", "%SCHEMA_UP_DOWN");
  break;
  case 2:
	 Word_Automation.PasteTextPattern("Ко всему сечению", "%SCHEMA_UP_DOWN");
  break;

  }

}
//-------------------------------------------------------------------------------
// Вывод отчета по проверке сварных швов
void Report_welding() {

  int in, i, k;
  CHECK_ELEM_PARAM_U *Cp;
  DATA_CHECK_U *Dt;
  AnsiString Text_coeff;
  CHECK_WELD_U *Cw;
  Dt = &(CheckExecute.Data_check_U);
  Cp = &(CheckExecute.Check_param);
  Cw = &(CheckExecute.Check_Weld_U);

   Word_Automation.PasteTextPattern(Round(Cw->WQ, 0), "%WQ");
   Word_Automation.PasteTextPattern(Round(Cw->WTEXT, 2), "%WTEXT");
   Word_Automation.PasteTextPattern(Round(Cw->WTINT, 2), "%WTINT");
   Word_Automation.PasteTextPattern(Round(Cw->WSEXT, 0), "%WSEXT");
   Word_Automation.PasteTextPattern(Round(Cw->WSINT, 0), "%WSINT");
   Word_Automation.PasteTextPattern(Round(Cw->WI, 0), "%WI");
   Word_Automation.PasteTextPattern(Round(Cw->VDOWN, 2), "%VDOWN");
   Word_Automation.PasteTextPattern(Round(Cw->WRTV, 2), "%WRTV");
   Word_Automation.PasteTextPattern(Cw->WN, "%WN");
   Word_Automation.PasteTextPattern(Cw->BETAF, "%BETAF");
   Word_Automation.PasteTextPattern(Cw->BETAZ, "%BETAZ");
   Word_Automation.PasteTextPattern(Cw->KF, "%KF");
   Word_Automation.PasteTextPattern(Cw->RWZ, "%RWZ");
   Word_Automation.PasteTextPattern(Cw->RWF, "%RWF");
   Word_Automation.PasteTextPattern(Cw->T_W, "%T_W");
   Word_Automation.PasteTextPattern(Cw->T_F1, "%T_F1");
   Word_Automation.PasteTextPattern(Cw->T_F2, "%T_F2");
   Word_Automation.PasteTextPattern(Cw->T_P, "%T_P");
   Word_Automation.PasteTextPattern(Cw->KUFFW, "%KUFFW");
   Word_Automation.PasteTextPattern(Cw->KUFF1, "%KUFF1");
   Word_Automation.PasteTextPattern(Cw->KUFF2, "%KUFF2");
   Word_Automation.PasteTextPattern(Cw->KUFFP, "%KUFFP");

  switch (Ds->form_profil) {
  case DVUTAVR_WELD:
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[0], 2), "%WCHECK_01");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[1], 2), "%WCHECK_02");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[2], 2), "%WCHECK_03");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[3], 2), "%WCHECK_04");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[4], 2), "%WCHECK_05");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[5], 2), "%WCHECK_06");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[6], 2), "%WCHECK_07");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[7], 2), "%WCHECK_08");

	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[16], 2), "%WCHECK_09");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[17], 2), "%WCHECK_10");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[18], 2), "%WCHECK_11");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[19], 2), "%WCHECK_12");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[20], 2), "%WCHECK_13");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[21], 2), "%WCHECK_14");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[22], 2), "%WCHECK_15");
	 Word_Automation.PasteTextPattern(Round(Cw->WCHECK[23], 2), "%WCHECK_16");
  break;
  case COMPOSED_BEAM:
	switch (Ds->index_composed) {
	case TAVR_PLATE_DOWN:
	case TAVR_PLATE_UP:
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[4], 2), "%WCHECK_01");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[5], 2), "%WCHECK_02");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[6], 2), "%WCHECK_03");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[7], 2), "%WCHECK_04");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[18], 2), "%WCHECK_05");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[19], 2), "%WCHECK_06");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[22], 2), "%WCHECK_07");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[23], 2), "%WCHECK_08");
	break;
	case DVUTAVR_PLATE_DOWN:
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[4], 2), "%WCHECK_01");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[5], 2), "%WCHECK_02");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[6], 2), "%WCHECK_03");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[7], 2), "%WCHECK_04");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[18], 2), "%WCHECK_05");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[19], 2), "%WCHECK_06");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[22], 2), "%WCHECK_07");
		Word_Automation.PasteTextPattern(Round(Cw->WCHECK[23], 2), "%WCHECK_08");
	break;
	}
  break;
  }
}
//-------------------------------------------------------------------------------
// Вывод отчета для растянуто-изгибаемых элементов (двутавров и труб)
void Report_tension_bending() {

  int in, i, k;
  CHECK_ELEM_PARAM_U *Cp;
  DATA_CHECK_U *Dt;

  Dt = &(CheckExecute.Data_check_U);
  Cp = &(CheckExecute.Check_param);

  AnsiString Text_coeff;


	if (Cp->index_105==1) {
	 Word_Automation.PasteTextPattern("п. 8.2.3 с учетом п. 9.1.1 ф. (105)", "%PP_NUM");
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Form105.doc", "%FORM_106OR106");
	 if ((ABS(Cp->N_105))<0.001)
	   Word_Automation.PasteTextPattern("0", "%N%");
	 else
	   Word_Automation.PasteTextPattern(Round(Cp->N_105, 0), "%N%");
	 Word_Automation.PasteTextPattern(Round(Cp->beta, 2), "%BETA");
	 Word_Automation.PasteTextPattern(Cp->n_pow, "%N_POW");
	 Word_Automation.PasteTextPattern(Round(Cp->cx, 2), "%CX");
	 Word_Automation.PasteTextPattern(Round(Cp->cy, 2), "%CY");
	 Word_Automation.PasteTextPattern(Round(Cp->Wx_min, 0), "%W_XN");
	 Word_Automation.PasteTextPattern(Round(Cp->Wy_min, 0), "%W_YN");
	}
	else {
	 Word_Automation.PasteTextPattern("п. 8.2.1 с учетом ф. (106)", "%PP_NUM");
	 Word_Automation.PasteFilePattern("Report_Ibeam_bending%Form106.doc", "%FORM_106OR106");
	 if ((ABS(Cp->N_))<0.001)
	   Word_Automation.PasteTextPattern("0", "%N%");
	 else
	   Word_Automation.PasteTextPattern(Round(Cp->N_, 0), "%N%");
	 Word_Automation.PasteTextPattern(Round(Cp->y_106, 2), "%Y%");
	 Word_Automation.PasteTextPattern(Round(Cp->x_106, 2), "%X%");
	}

	for (i=0, k=0; i<SelectProfilSectForm->Data_select.N_check[4]; i++) {
		if (SelectProfilSectForm->Num_prov[4][i]==1) {
		  if (k<9)
			Text_coeff = "%Coeff_0"+IntToStr(k+1);
		  else
			Text_coeff = "%Coeff_"+IntToStr(k+1);
		  if (SelectProfilSectForm->Krit[4][i]>=0) {
			switch (k+1) {
			case 4:
			  Word_Automation.PasteFilePattern("Report_Ibeam_compress_bending%check04.doc", "%TENS_BEND_CHECK04");
			break;
			}
			Word_Automation.PasteTextPattern(FloatToStrF(SelectProfilSectForm->Krit[4][i], ffFixed, 15, 2),
											 Text_coeff);
		  }
		  else {
			switch (k+1) {
			case 4:
			  Word_Automation.PasteTextPattern("Проверка не выполняется, т.к. Ryn<=440 МПа", "%TENS_BEND_CHECK04");
			break;
			Word_Automation.PasteTextPattern("-", Text_coeff);
			}
		  }
		  k++;
		}
	}



  //-------------------------------------------------------------------------------------
  // Подстановка параметров
  Word_Automation.PasteTextPattern(Round(Cp->A_netto, 0), "%ANET");
  Word_Automation.PasteTextPattern(Round(Cp->Ar, 0), "%AR%");
  Word_Automation.PasteTextPattern(Round(Cp->fi_e, 3), "%FI_E%");
  Word_Automation.PasteTextPattern(Round(Cp->Qy, 0), "%QY");
  Word_Automation.PasteTextPattern(Round(Cp->Qx, 0), "%QX");
  Word_Automation.PasteTextPattern(Round(Cp->Sy, 0), "%SY%");
  Word_Automation.PasteTextPattern(Round(Cp->Sx, 0), "%SX%");
  Word_Automation.PasteTextPattern(Round(Cp->Iy, 0), "%IY");
  Word_Automation.PasteTextPattern(Round(Cp->Ix, 0), "%IX");
  Word_Automation.PasteTextPattern(Cp->tw, "%TW");
  Word_Automation.PasteTextPattern(Cp->tf, "%TF");
  Word_Automation.PasteTextPattern(Ds->gamma_c, "%GAMMA_C");
  Word_Automation.PasteTextPattern(Round(Cp->Aw, 0), "%AW%");
  Word_Automation.PasteTextPattern(Round(Cp->Af, 0), "%AF%");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_xw)), "%SIGXW");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_yw)), "%SIGYW");
  Word_Automation.PasteTextPattern((ABS(Cp->tau_w)), "%TAUW");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_xf)), "%SIGXF");
  Word_Automation.PasteTextPattern((ABS(Cp->sig_yf)), "%SIGYF");
  Word_Automation.PasteTextPattern((ABS(Cp->tau_f)), "%TAUF");
  Word_Automation.PasteTextPattern(Cp->gamma_u, "%GAMMA_U");
  Word_Automation.PasteTextPattern(Cp->delta4, "%DELTA4");
  Word_Automation.PasteTextPattern(Cp->Wtn, "%WTN");
  Word_Automation.PasteTextPattern(Cp->Ru, "%RU");
  Word_Automation.PasteTextPattern(Cp->Rs, "%RS");
  Word_Automation.PasteTextPattern(Cp->Ry, "%RY%");
  Word_Automation.PasteTextPattern(Cp->Ryw, "%RYW");
  Word_Automation.PasteTextPattern(Round(Cp->N_, 0), "%N%");
  Word_Automation.PasteTextPattern(Round(Cp->Mx, 0), "%MX");
  Word_Automation.PasteTextPattern(Round(Cp->My, 0), "%MY");
  Word_Automation.PasteTextPattern(Round(Cp->fi_b, 2), "%FI_B");
  Word_Automation.PasteTextPattern(Round(Cp->fi_y, 2), "%FI_Y");
  Word_Automation.PasteTextPattern(Round(Cp->fi_ey, 2), "%FI_EY");
  Word_Automation.PasteTextPattern(Round(Cp->fi_exy, 2), "%FI_EXY");
  Word_Automation.PasteTextPattern(Round(Cp->c_, 2), "%C%");
  Word_Automation.PasteTextPattern(Round(Cp->c_*Cp->fi_y, 2), "%CFI_Y");
  Word_Automation.PasteTextPattern(Round(Cp->a_step, 0), "%ASTEP");
  Word_Automation.PasteTextPattern(Round(Cp->hef, 0), "%HEF");
  Word_Automation.PasteTextPattern(Round(Cp->k_, 2), "%K%");
  Word_Automation.PasteTextPattern(Round(Cp->k_x, 2), "%KX%");
  Word_Automation.PasteTextPattern(Round(Cp->k_y, 2), "%KY%");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uw_m, 2), "%LAMBDA_UW_M");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uw, 2), "%LAMBDA_UW%");

  Word_Automation.PasteTextPattern(Round(Cp->lambda_uf, 2), "%LAMBDA_UF%");
  Word_Automation.PasteTextPattern(Round(Cp->Wcx, 0), "%WCX");
  Word_Automation.PasteTextPattern(Round(Cp->Wy, 0), "%WY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_w, 2), "%LAMBDAW");
  Word_Automation.PasteTextPattern(Round(Cp->krit_lambdaw, 2), "%KRIT_LAMBDAW");
  if (Cp->lambda_w <= Cp->krit_lambdaw ) {
	  Word_Automation.PasteTextPattern("<", "%LESS_OR_MOOR_ 9");
  }
  else
	  Word_Automation.PasteTextPattern(">", "%LESS_OR_MOOR_ 9");

  Word_Automation.PasteTextPattern(Round(Cp->sigma1w, 0), "%SIGMA1W");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_f, 2), "%LAMBDAF");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uf, 2), "%LAMBDAUF");
  Word_Automation.PasteTextPattern(Round(Cp->delta_b, 1), "%DELTAB");
  Word_Automation.PasteTextPattern(Round(Cp->delta_ub, 1), "%DELTAUB");
  Word_Automation.PasteTextPattern(Round(Cp->fi_1, 2), "%FI_1");
  Word_Automation.PasteTextPattern(Round(Cp->psi, 2), "%PSI");
  Word_Automation.PasteTextPattern(Round(Cp->h_fi_b, 1), "%H%");
  Word_Automation.PasteTextPattern(Round(Cp->l_ef, 0), "%LEF");
  Word_Automation.PasteTextPattern(Round(Cp->Ey, 0), "%E%");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaX, 2), "%LAMBDAX");
  Word_Automation.PasteTextPattern(Round(Cp->lambdaY, 2), "%LAMBDAY");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_ux, 2), "%LAMBDAUX");
  Word_Automation.PasteTextPattern(Round(Cp->lambda_uy, 2), "%LAMBDAUY");

  Word_Automation.PasteTextPattern(Round(Cp->fi_rect_ez, 2), "%FI_RECT_EZ%");
  Word_Automation.PasteTextPattern(Round(Cp->fi_rect_ey, 2), "%FI_RECT_EY%");
  Word_Automation.PasteTextPattern(Round(Cp->Wm_XZ, 2), "%W_ZMIN");
  Word_Automation.PasteTextPattern(Round(Cp->Wm_XY, 2), "%W_YMIN");
  Word_Automation.PasteTextPattern(Round(Cp->c_y, 2), "%C_Y%");
  Word_Automation.PasteTextPattern(Round(Cp->c_z, 2), "%C_Z%");
  Word_Automation.PasteTextPattern(Round(Cp->delta_x, 2), "%DEL_Y");
  Word_Automation.PasteTextPattern(Round(Cp->delta_y, 2), "%DEL_Z");


  if (Cp->index_105==0) {
	Word_Automation.PasteTextPattern("пластика не допускается", "%IND_PLAST");
  }
  else
	Word_Automation.PasteTextPattern("пластика допускается", "%IND_PLAST");

  Word_Automation.PasteTextPattern(Round(Cp->lambda_w, 2), "%LAMBDA_W");
  Word_Automation.PasteTextPattern(Round(Cp->del_lamb, 2), "%DEL_LAMB");



}
//----------------------------------------------------------------------------
// Оформление рисунков
void FormalPict() {

  pCanvas = new TMetafileCanvas(GrapMeta, 0);
  int Font_size = 8;

  if (TheFont!=NULL)
  delete TheFont;
  TheFont = new TFont();
  TheFont->Size = Font_size;
  pCanvas->Font = TheFont;
}



