Esempio n. 1
0
 static void table_text(WordMacros& macros, bool secondTable, int row, int col, string_t text) { 
   if (secondTable)
     macros.CellCell(2, 2, 7, row, col, "Select");
   else
     macros.CellCell(2, 3, 2, row, col, "Select");
   macros.SelectionText(text); 
 }
Esempio n. 2
0
//-------------------------------------------------------------------------
void ReportDiplom::Run(int grpId, int studentId)
{
  r::PrivateData privData;
  r::GetPrivateData(privData, studentId);
  DirectData dirData;
  GetDirectData(dirData, privData);
  std::vector<Discip> cursDiscip;
  std::vector<Discip> commonDiscip;
  std::vector<Discip> specDiscip;
  bool useZe = privData.specOrProfilTag.startsWith("бак") || privData.specOrProfilTag == "маг";    // так же для расчета объема программы
  bool anotherEnd = privData.specOrProfilTag.empty() || privData.specOrProfilTag == "бак1";
  GetDiscipInfo(studentId, cursDiscip, commonDiscip, specDiscip, privData.lang, privData.vkrTitle, useZe, anotherEnd);

  WordMacros macros;
  macros.BeginMacros();

  // ФИО
  macros.Cell(1, 3, 7, "Range.Select");
  macros.SelectionText(privData.secondName);
  macros.Cell(1, 4, 7, "Range.Select");
  macros.SelectionText(privData.firstName);
  macros.Cell(1, 5, 7, "Range.Select");
  macros.SelectionText(privData.thirdName);

  // дата рождения
  macros.Cell(1, 6, 8, "Range.Select");
  macros.SelectionText(r::to_str_date(privData.bornDate, "года"));

  // аттестат
  macros.Cell(1, 8, 6, "Range.Select");
  macros.SelectionText(privData.prevDoc.toUpperFirst() + " " + privData.prevDocYear + " год");

  // номер регистрации
  macros.Cell(1, 13, 5, "Range.Select");
  macros.SelectionText(privData.regNum);

  // дата выдачи
  macros.Cell(1, 15, 7, "Range.Select");
  macros.SelectionText(r::to_str_date(privData.dataVidachi, "года"));  

  // специалиста (специалиста с отличием, бакалавра, бакалавра с отличием)
  macros.Cell(1, 9, 4, "Range.Select");
  macros.SelectionText(dirData.title1);

  // по специальности, по направлению
  macros.Cell(1, 11, 9, "Range.Select");
  macros.SelectionText(dirData.title2);

  // сколько обучался
  macros.Cell(1, 15, 9, "Range.Select");
  macros.SelectionText(dirData.title3);

  // дополнительная информация
  macros.Cell(1, 12, 3, "Range.Select");
  macros.SelectionText(dirData.bottomInfo);

  // курсовые работы
  for (int i = 0; i < (int)cursDiscip.size(); ++i)
  {
     macros.CellCell(1, 3, 2, i + 1, 1, "Select");
     macros.SelectionText(toQuate(cursDiscip[i].title));
     macros.CellCell(1, 3, 2, i + 1, 2, "Select");
     macros.SelectionText(cursDiscip[i].ocenka);
  }
  
  struct local
  {
    static void table_text(WordMacros& macros, bool secondTable, int row, int col, string_t text) { 
      if (secondTable)
        macros.CellCell(2, 2, 7, row, col, "Select");
      else
        macros.CellCell(2, 3, 2, row, col, "Select");
      macros.SelectionText(text); 
    }
  };

  // обычные дисциплины на первой таблице
  int table1RowCount = 56;  // всего осталось строк в первой таблице
  int usedDiscip = 0;       // сколько на самом деле добавили дисциплин в первую таблицу
  for (int i = 0; i < (int)commonDiscip.size() && table1RowCount > 0; ++i)
  {
    table1RowCount -= PrepareDiscipTitle(commonDiscip[i].title, 63);
    if (table1RowCount < 0) // если строка не уберется в конце таблицы, то сразу нечего продолжать
      break;

    usedDiscip++;
    local::table_text(macros, false, i+1, 1, toQuate(commonDiscip[i].title));
    local::table_text(macros, false, i+1, 2, commonDiscip[i].period);
    local::table_text(macros, false, i+1, 3, commonDiscip[i].ocenka);
  }
  
  int table2CurRow = 1;
  bool need_second_table = usedDiscip < (int)commonDiscip.size();
  // обычные дисциплины во второй таблице если не хватило места на первой
  if (need_second_table)
    for (int i = usedDiscip; i < (int)commonDiscip.size(); ++i)
    {
      local::table_text(macros, true, table2CurRow, 1, toQuate(commonDiscip[i].title));
      local::table_text(macros, true, table2CurRow, 2, commonDiscip[i].period);
      local::table_text(macros, true, table2CurRow, 3, commonDiscip[i].ocenka);
      ++table2CurRow;
    }
  
  // остальные данные могут или убраться на первой таблице или надо перенести на вторую
  if (!need_second_table)
    if (table1RowCount <= (int)specDiscip.size())
      need_second_table = true;

  int rowPos = need_second_table ? table2CurRow : usedDiscip + 1;
  for (int i = 0; i < (int)specDiscip.size(); ++i)
  {
    local::table_text(macros, need_second_table, rowPos+i, 1, toQuate(specDiscip[i].title));
    local::table_text(macros, need_second_table, rowPos+i, 2, specDiscip[i].period);
    local::table_text(macros, need_second_table, rowPos+i, 3, specDiscip[i].ocenka);
  }

  macros.EndMacros();
  macros.RunMacros(theApp.GetModuleDir() + "diplom-2014.dot");
}