Esempio n. 1
0
void
PropPageFormats::OnEdit ()
{
  try
    {
      int idx = GetSelectedItem();
      CString formatKey = listControl.GetItemText(idx, 0);
      FormatDefinitionDialog dlg (this, TU_(formatKey));
      if (dlg.DoModal() != IDOK)
	{
	  return;
	}
      FormatInfo formatInfo = dlg.GetFormatInfo();
      if (PathName::Compare(formatInfo.key.c_str(), TU_(formatKey)) != 0)
	{
	  // rename key: delete old, create new
	  SessionWrapper(true)->DeleteFormatInfo (TU_(formatKey));
	  formatKey = formatInfo.key.c_str();
	}
      SessionWrapper(true)->SetFormatInfo (formatInfo);
      Refresh ();
      MakeAlias (formatInfo);
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }
}
Esempio n. 2
0
void
PropPageFormats::OnRemove ()
{
  try
    {
      int n = listControl.GetSelectedCount();
      for (int i = 0; i < n; ++i)
	{
	  int idx = GetSelectedItem();
	  CString formatKey = listControl.GetItemText(idx, 0);
	  SessionWrapper(true)->DeleteFormatInfo (TU_(formatKey));
	  if (! listControl.DeleteItem(idx))
	    {
	      FATAL_WINDOWS_ERROR ("CListCtrl::DeleteItem", 0);
	    }
	}
      EnableButtons ();
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }
}
Esempio n. 3
0
void
DviView::OnFileDvips ()
{
  try
    {
      DviDoc * pDoc = GetDocument();
      ASSERT_VALID (pDoc);
      DvipsDialog dlg (this);
      dlg.m_iFirstPage = pDoc->GetPageNum(0);
      dlg.m_iLastPage = pDoc->GetPageNum(pDoc->GetPageCount() - 1);
      dlg.m_nPageRange = 0;
      if (dlg.DoModal() != IDOK)
	{
	  return;
	}
      PrintRange pr;
      switch (dlg.m_nPageRange)
	{
	case 0:			// all
	  pr.nRange = PrintRange::All;
	  break;
	case 1:			// current
	  pr.nRange = PrintRange::Range;
	  pr.nFirst = pr.nLast = GetCurrentPageIdx() + 1;
	  break;
	case 2:			// range
	  pr.nRange = PrintRange::Range;
	  pr.nFirst = dlg.m_iFirstPage;
	  pr.nLast = dlg.m_iLastPage;
	  break;
	}
      switch (dlg.m_nEvenOdd)
	{
	case 0:
	  pr.nEvenOdd = PrintRange::EvenOdd;
	  break;
	case 1:
	  pr.nEvenOdd = PrintRange::EvenOnly;
	  break;
	case 2:
	  pr.nEvenOdd = PrintRange::OddOnly;
	  break;
	}
      PrintPostScript (TU_(pDoc->GetPathName()),
		       dlg.GetPrinterName(),
		       pr);
      g_pYapConfig->Save ();
    }
  
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }

  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }
}
Esempio n. 4
0
void
SplitUrl (/*[in]*/ const string &	url,
	  /*[out]*/ string &		protocol,
	  /*[out]*/ string &		host)
{
  _TCHAR szProtocol[200];
  _TCHAR szHost[200];
  URL_COMPONENTS url_comp = { 0 };
  url_comp.dwStructSize = sizeof(url_comp);
  url_comp.lpszScheme = szProtocol;
  url_comp.dwSchemeLength = 200;
  url_comp.lpszHostName = szHost;
  url_comp.dwHostNameLength = 200;
  if (! InternetCrackUrl(UT_(url.c_str()), 0, 0, &url_comp))
    {
      FATAL_WINDOWS_ERROR ("InternetCrackUrl", 0);
    }
  protocol = TU_(szProtocol);
  host = TU_(szHost);
}
Esempio n. 5
0
void
DviDoc::Reread ()
{
  MIKTEX_ASSERT (! isPrintContext);
  Dvi * pDvi = this->pDvi;
  this->pDvi = 0;
  fileStatus = DVIFILE_NOT_LOADED;
  if (pDvi != 0)
    {
      delete pDvi;
    }
  CreateDocument (TU_(GetPathName()));
}
Esempio n. 6
0
void
PropPageFormats::OnMake ()
{
  try
    {
      PropSheet * pSheet =
	reinterpret_cast<PropSheet*>(GetParent());
      auto_ptr<ProgressDialog> ppd (ProgressDialog::Create());
      ppd->StartProgressDialog (GetParent()->GetSafeHwnd());
      if (listControl.GetSelectedCount() > 1)
	{
	  ppd->SetTitle (T_("Making Format Files"));
	}
      else
	{
	  ppd->SetTitle (T_("Making Format File"));
	}
      ppd->SetLine (1, T_("Creating format file:"));
      POSITION pos = listControl.GetFirstSelectedItemPosition();
      while (pos != 0)
	{
	  int idx = listControl.GetNextSelectedItem(pos);
	  CString formatKey = listControl.GetItemText(idx, 0);
	  FormatInfo formatInfo =
	    SessionWrapper(true)->GetFormatInfo(TU_(formatKey));
	  CommandLineBuilder cmdLine;
	  cmdLine.AppendOption ("--dump=", formatInfo.key);
	  if (! pSheet->RunIniTeXMF(formatInfo.description.c_str(),
				    cmdLine,
				    ppd.get()))
	    {
	      // <todo/>
	    }
	}
      ppd->StopProgressDialog ();
      ppd.reset ();
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }
}
Esempio n. 7
0
BOOL SecurityOptionsPage::OnApply()
{
  try
  {
    g_pYapConfig->enableShellCommands = enableShellCommands;
    g_pYapConfig->secureCommands = TU_(secureCommands);
    return CPropertyPage::OnApply();
  }
  catch (const MiKTeXException& e)
  {
    ErrorDialog::DoModal(this, e);
    return FALSE;
  }
  catch (const exception& e)
  {
    ErrorDialog::DoModal(this, e);
    return FALSE;
  }
}
Esempio n. 8
0
void
DviDoc::BeginDviPrinting (/*[in]*/ const CDC * pPrinterDC)
{
  UNUSED_ALWAYS (pPrinterDC);
  MIKTEX_ASSERT (! isPrintContext);
  MIKTEX_ASSERT (pDviSave == 0);
  MIKTEX_ASSERT (pDvi != 0);
  isPrintContext = true;
  pDviSave = pDvi;
  pDvi = 0;
  try
    {
      CreateDocument (TU_(GetPathName()));
    }
  catch (const exception &)
    {
      this->pDvi = pDviSave;
      pDviSave = 0;
      isPrintContext = false;
      throw;
    }
}
Esempio n. 9
0
BOOL
DviDoc::OnOpenDocument (/*[in]*/ LPCTSTR lpszPathName) 
{
  try
    {
      MIKTEX_ASSERT (pDvi == 0);
      MIKTEX_ASSERT (pDviSave == 0);
      MIKTEX_ASSERT (! isPrintContext);
      CreateDocument (TU_(lpszPathName));
      return (TRUE);
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (0, e);
      return (FALSE);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (0, e);
      return (FALSE);
    }
}
Esempio n. 10
0
DviDoc::DviFileStatus
DviDoc::GetDviFileStatus ()
{
  if (fileStatus == DVIFILE_LOADED)
    {
      if (! File::Exists(PathName(GetPathName())))
	{
	  fileStatus = DVIFILE_LOST;
	}
      else
	{
	  time_t timeMod = modificationTime;
	  modificationTime = File::GetLastWriteTime(PathName(GetPathName()));
	  if (timeMod != modificationTime)
	    {
	      YapLog (T_("%s has been modified"), Q_(TU_(GetPathName())));
	      modificationTime = timeMod;
	      fileStatus = DVIFILE_MODIFIED;
	    }
	}
    }
  return (fileStatus);
}
Esempio n. 11
0
BOOL SettingsPage::OnKillActive()
{
  SetupOptions options = SetupApp::Instance->Service->GetOptions();
  BOOL ret = CPropertyPage::OnKillActive();
  options.PaperSize = TU_(paperSize);
  switch (installOnTheFly)
  {
  case 0:
    options.IsInstallOnTheFlyEnabled = TriState::True;
    break;
  case 1:
    options.IsInstallOnTheFlyEnabled = TriState::False;
    break;
  case 2:
    options.IsInstallOnTheFlyEnabled = TriState::Undetermined;
    break;
  default:
    ASSERT(false);
    __assume (false);
    break;
  }
  SetupApp::Instance->Service->SetOptions(options);
  return ret;
}
Esempio n. 12
0
BOOL
WelcomePage::OnKillActive ()
{
  BOOL ret = CPropertyPage::OnKillActive();
  if (ret)
    { 
      try
	{
	  pSheet->SetThoroughlyFlag (thoroughly != FALSE);
	  pSheet->SetNextText (TU_(oldNextText));
	}
      catch (const MiKTeXException & e)
	{
	  pSheet->ReportError (e);
	  ret = FALSE;
	}
      catch (const exception & e)
	{
	  pSheet->ReportError (e);
	  ret = FALSE;
	}
    }
  return (ret);
}
Esempio n. 13
0
LRESULT
SiteWizRemote::FillList (/*[in]*/ WPARAM	wParam,
			 /*[in]*/ LPARAM	lParam)
{
  UNUSED_ALWAYS (wParam);
  UNUSED_ALWAYS (lParam);

  CPropertySheet * pSheet = reinterpret_cast<CPropertySheet*>(GetParent());
  ASSERT_KINDOF (CPropertySheet, pSheet);

  try
    {
      if (! listControl.DeleteAllItems())
	{
	  FATAL_WINDOWS_ERROR ("CListCtrl::DeleteAllItems", 0);
	}
      
      bool selected = false;
      
      string url;

      if (! pManager->TryGetRemotePackageRepository(url))
	{
	  url = "";
	}

      int idx = 0;
      
      for (vector<RepositoryInfo>::const_iterator it = repositories.begin();
	   it != repositories.end();
	   ++ it, ++ idx)
	{
#if MIKTEX_RELEASE_STATE < 4
	  if (it->packageLevel == PackageLevel::None)
	    {
	      continue;
	    }
#endif
	  
	  LV_ITEM lvitem;
	  
	  lvitem.iItem = idx;
	  lvitem.mask = LVIF_PARAM;
	  lvitem.lParam = idx;
	  lvitem.iSubItem = 0;
      
	  if (listControl.InsertItem(&lvitem) < 0)
	    {
	      FATAL_WINDOWS_ERROR ("CListCtrl::InsertItem", 0);
	    }

	  string protocol;
	  string host;

	  SplitUrl (it->url, protocol, host);

	  SetItemText (idx, 0, it->country.c_str());
	  CString protUC (protocol.c_str());
	  protUC.MakeUpper ();
	  SetItemText (idx, 1, TU_(protUC));
	  SetItemText (idx, 2, host.c_str());
      	  SetItemText (idx, 3, TU_(CTime(it->timeDate).Format(_T("%d-%b-%y"))));
	  SetItemText (idx, 4, it->description.c_str());

	  if (it->url == url)
	    {
	      if (! listControl.SetItemState(idx,
					     LVIS_SELECTED,
					     LVIS_SELECTED))
		{
		  FATAL_WINDOWS_ERROR ("CListCtrl::SetItemState", 0);
		}
	      selected = true;
	    }
	}

      pSheet->SetWizardButtons (PSWIZB_BACK
				| (selected ? PSWIZB_FINISH : 0));
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }

  return (0);
}
Esempio n. 14
0
LRESULT
RemoteRepositoryPage::OnFillList (/*[in]*/ WPARAM		wParam,
				  /*[in]*/ LPARAM		lParam)
{
  UNUSED_ALWAYS (wParam);
  UNUSED_ALWAYS (lParam);

  try
    {
      if (pSheet->GetCancelFlag() || pSheet->GetErrorFlag())
	{
	  SetProgressText (pSheet->GetCancelFlag()
			   ? T_("Cancelled")
			   : T_("Unsuccessful"));
	  pSheet->EnableCloseButton ();
	  return (0);
	}

      if (! listControl.DeleteAllItems())
	{
	  FATAL_WINDOWS_ERROR ("CListCtrl::DeleteAllItems", 0);
	}
      
      bool selected = false;

      int idx = 0;

      for (vector<RepositoryInfo>::const_iterator it = repositories.begin();
	   it != repositories.end();
	   ++ it, ++ idx)
	{
#if MIKTEX_RELEASE_STATE < 4
	  if (it->packageLevel < theApp.GetPackageLevel())
	    {
	      continue;
	    }
#endif

	  LV_ITEM lvitem;
	  
	  lvitem.iItem = idx;
	  lvitem.mask = LVIF_PARAM;
	  lvitem.lParam = idx;
	  lvitem.iSubItem = 0;
	  
	  if (listControl.InsertItem(&lvitem) < 0)
	    {
	      FATAL_WINDOWS_ERROR ("CListCtrl::InsertItem", 0);
	    }

	  string protocol;
	  string host;

	  SplitUrl (it->url, protocol, host);

	  SetItemText (idx, 0, it->country.c_str());
	  CStringW protUC = UW_(protocol.c_str());
	  protUC.MakeUpper ();
	  SetItemText (idx, 1, WU_(protUC));
	  SetItemText (idx, 2, host.c_str());
      	  SetItemText (idx, 3, TU_(CTime(it->timeDate).Format(_T("%d-%b-%y"))));
#if SHOW_DESCRIPTION
	  SetItemText (idx, 4, it->description.c_str());
#endif

	  if (it->url == theApp.GetRemotePackageRepository())
	    {
	      if (! listControl.SetItemState(idx,
					     LVIS_SELECTED,
					     LVIS_SELECTED))
		{
		  FATAL_WINDOWS_ERROR ("CListCtrl::SetItemState", 0);
		}
	      selected = true;
	    }
	}

      pSheet->SetWizardButtons (PSWIZB_BACK
				| (selected ? PSWIZB_NEXT : 0));
    }
  catch (const MiKTeXException & e)
    {
      pSheet->ReportError (e);
    }
  catch (const exception & e)
    {
      pSheet->ReportError (e);
    }
  
  return (0);
}