Example #1
0
void
PropPageGeneral::OnRefreshFndb ()
{
  try
    {
      auto_ptr<ProgressDialog> pProgressDialog (ProgressDialog::Create());
      pProgressDialog->StartProgressDialog (GetParent()->GetSafeHwnd());
      pProgressDialog->SetTitle (T_("MiKTeX Maintenance"));
      pProgressDialog->SetLine (1, T_("Collecting file information..."));
      this->pProgressDialog = pProgressDialog.get();
      Fndb::Refresh (this);
      if (! pProgressDialog->HasUserCancelled())
	{
	  pProgressDialog->SetLine
	    (1,
	     T_("Scanning package definitions"));
	  pProgressDialog->SetLine
	    (2,
	     T_("create the MPM file name database..."));
	  pManager->CreateMpmFndb ();
	}
      pProgressDialog->StopProgressDialog ();
      pProgressDialog.reset ();
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }
  this->pProgressDialog = 0;
}
Example #2
0
void ProjectorBase::setCameraParams(const Mat &K, const Mat &R, const Mat &T)
{
    CV_Assert(K.size() == Size(3, 3) && K.type() == CV_32F);
    CV_Assert(R.size() == Size(3, 3) && R.type() == CV_32F);
    CV_Assert((T.size() == Size(1, 3) || T.size() == Size(3, 1)) && T.type() == CV_32F);

    Mat_<float> K_(K);
    k[0] = K_(0,0); k[1] = K_(0,1); k[2] = K_(0,2);
    k[3] = K_(1,0); k[4] = K_(1,1); k[5] = K_(1,2);
    k[6] = K_(2,0); k[7] = K_(2,1); k[8] = K_(2,2);

    Mat_<float> Rinv = R.t();
    rinv[0] = Rinv(0,0); rinv[1] = Rinv(0,1); rinv[2] = Rinv(0,2);
    rinv[3] = Rinv(1,0); rinv[4] = Rinv(1,1); rinv[5] = Rinv(1,2);
    rinv[6] = Rinv(2,0); rinv[7] = Rinv(2,1); rinv[8] = Rinv(2,2);

    Mat_<float> R_Kinv = R * K.inv();
    r_kinv[0] = R_Kinv(0,0); r_kinv[1] = R_Kinv(0,1); r_kinv[2] = R_Kinv(0,2);
    r_kinv[3] = R_Kinv(1,0); r_kinv[4] = R_Kinv(1,1); r_kinv[5] = R_Kinv(1,2);
    r_kinv[6] = R_Kinv(2,0); r_kinv[7] = R_Kinv(2,1); r_kinv[8] = R_Kinv(2,2);

    Mat_<float> K_Rinv = K * Rinv;
    k_rinv[0] = K_Rinv(0,0); k_rinv[1] = K_Rinv(0,1); k_rinv[2] = K_Rinv(0,2);
    k_rinv[3] = K_Rinv(1,0); k_rinv[4] = K_Rinv(1,1); k_rinv[5] = K_Rinv(1,2);
    k_rinv[6] = K_Rinv(2,0); k_rinv[7] = K_Rinv(2,1); k_rinv[8] = K_Rinv(2,2);

    Mat_<float> T_(T.reshape(0, 3));
    t[0] = T_(0,0); t[1] = T_(1,0); t[2] = T_(2,0);
}
Example #3
0
void
VFont::Read ()
{
  if (! characterTable.empty() || dviInfo.notLoadable)
    {
      return;
    }

  dviInfo.notLoadable = true;

  InputStream stream (dviInfo.fileName.c_str());

  trace_vfont->WriteFormattedLine
    ("libdvi",
     T_("reading vf file %s"),
     Q_(dviInfo.fileName));

  if (stream.ReadByte() != pre)
    {
      FATAL_DVI_ERROR ("VFont::Read",
		       T_("Not a VF file."),
		       dviInfo.fileName.c_str());
    }

  ReadPreamble (stream);
  ReadFontDefsAndCharPackets (stream);
  ReadPostamble (stream);
  
  dviInfo.notLoadable = false;
}
Example #4
0
BOOL
MainFrame::PreCreateWindow (/*[in,out]*/ CREATESTRUCT & cs)
{
  try
    {
      if (! CFrameWnd::PreCreateWindow(cs))
	{
	  FATAL_MIKTEX_ERROR ("MainFrame::PreCreateWindow",
			      T_("The main window could not be initialized."),
			      0);
	}
      cs.style &= ~FWS_ADDTOTITLE;
      if (SessionWrapper(true)->IsAdminMode())
      {
	SetTitle (T_(_T("MiKTeX Package Manager (Admin)")));
      }
      else
      {
	SetTitle (T_(_T("MiKTeX Package Manager")));
      }
      return (TRUE);
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
      return (FALSE);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
      return (FALSE);
    }
}
Example #5
0
DviSpecialType
HyperTeXSpecialImpl::Parse ()
{
  name = state.nameOrHref;
  llx = state.llx;
  lly = state.lly;
  urx = state.urx;
  ury = state.ury;
  isName = state.isName;
  if (state.isName)
    {
      trace_hypertex->WriteFormattedLine
	("libdvi",
	 T_("new hypertex target \"%s\" (%d, %d, %d, %d)"),
	 name.c_str(),
	 state.llx,
	 state.lly,
	 state.urx,
	 state.ury);
    }
  else
    {
      trace_hypertex->WriteFormattedLine
	("libdvi",
	 T_("new hypertex reference \"%s\" (%d, %d, %d, %d)"),
	 name.c_str(), state.llx, state.lly, state.urx, state.ury);
    }
  return (DviSpecialType::Hypertex);
}
Example #6
0
void ProjectorBase::setCameraParams(InputArray _K, InputArray _R, InputArray _T)
{
    Mat K = _K.getMat(), R = _R.getMat(), T = _T.getMat();

    CV_Assert(K.size() == Size(3, 3) && K.type() == CV_32F);
    CV_Assert(R.size() == Size(3, 3) && R.type() == CV_32F);
    CV_Assert((T.size() == Size(1, 3) || T.size() == Size(3, 1)) && T.type() == CV_32F);

    Mat_<float> K_(K);
    k[0] = K_(0,0); k[1] = K_(0,1); k[2] = K_(0,2);
    k[3] = K_(1,0); k[4] = K_(1,1); k[5] = K_(1,2);
    k[6] = K_(2,0); k[7] = K_(2,1); k[8] = K_(2,2);

    Mat_<float> Rinv = R.t();
    rinv[0] = Rinv(0,0); rinv[1] = Rinv(0,1); rinv[2] = Rinv(0,2);
    rinv[3] = Rinv(1,0); rinv[4] = Rinv(1,1); rinv[5] = Rinv(1,2);
    rinv[6] = Rinv(2,0); rinv[7] = Rinv(2,1); rinv[8] = Rinv(2,2);

    Mat_<float> R_Kinv = R * K.inv();
    r_kinv[0] = R_Kinv(0,0); r_kinv[1] = R_Kinv(0,1); r_kinv[2] = R_Kinv(0,2);
    r_kinv[3] = R_Kinv(1,0); r_kinv[4] = R_Kinv(1,1); r_kinv[5] = R_Kinv(1,2);
    r_kinv[6] = R_Kinv(2,0); r_kinv[7] = R_Kinv(2,1); r_kinv[8] = R_Kinv(2,2);

    Mat_<float> K_Rinv = K * Rinv;
    k_rinv[0] = K_Rinv(0,0); k_rinv[1] = K_Rinv(0,1); k_rinv[2] = K_Rinv(0,2);
    k_rinv[3] = K_Rinv(1,0); k_rinv[4] = K_Rinv(1,1); k_rinv[5] = K_Rinv(1,2);
    k_rinv[6] = K_Rinv(2,0); k_rinv[7] = K_Rinv(2,1); k_rinv[8] = K_Rinv(2,2);

    Mat_<float> T_(T.reshape(0, 3));
    t[0] = T_(0,0); t[1] = T_(1,0); t[2] = T_(2,0);
}
Example #7
0
void eqnsys<nr_type_t>::substitute_qr_householder_ls (void) {
  int c, r;
  nr_type_t f;

  // forward substitution in order to solve R'X = B
  for (r = 0; r < N; r++) {
    for (f = B_(r), c = 0; c < r; c++) f -= A_(c, r) * B_(c);
    if (abs (A_(r, r)) > std::numeric_limits<nr_double_t>::epsilon())
      B_(r) = f / A_(r, r);
    else
      B_(r) = 0;
  }

  // compute the least square solution QX
  for (c = N - 1; c >= 0; c--) {
    if (T_(c) != 0) {
      // scalar product u' * B
      for (f = B_(c), r = c + 1; r < N; r++) f += cond_conj (A_(r, c)) * B_(r);
      // z - T * f * u_k
      f *= T_(c); B_(c) -= f;
      for (r = c + 1; r < N; r++) B_(r) -= f * A_(r, c);
    }
  }

  // permute solution vector
  for (r = 0; r < N; r++) X_(cMap[r]) = B_(r);
}
Example #8
0
bool
File::Exists (/*[in]*/ const PathName & path)
{
  struct stat statbuf;
  if (stat(path.Get(), &statbuf) == 0)
    {
      if (S_ISDIR(statbuf.st_mode) != 0)
	{
	  SessionImpl::theSession->trace_access->WriteFormattedLine
	    ("core",
	     T_("%s is a directory"),
	     Q_(path));
	  return (false);
	}
      SessionImpl::theSession->trace_access->WriteFormattedLine
	("core",
	 T_("accessing file %s: OK"),
	 Q_(path));
      return (true);
    }
  int error = errno;
  if (error != ENOENT)
    {
      FATAL_CRT_ERROR ("stat", path.Get());
    }
  SessionImpl::theSession->trace_access->WriteFormattedLine
    ("core",
     T_("accessing file %s: NOK"),
     Q_(path));
  return (false);
}
Example #9
0
void
PropPageFormats::MakeAlias (/*[in]*/ const FormatInfo & formatInfo)
{
  if (SessionWrapper(true)->IsMiKTeXDirect())
    {
      FATAL_MIKTEX_ERROR ("PropPageFormats::MakeAlias",
			  T_("Operation not supported."),
			  formatInfo.compiler.c_str());
    }
  PathName compilerPath;
  if (! SessionWrapper(true)->FindFile(formatInfo.compiler.c_str(),
				       FileType::EXE,
				       compilerPath))
    {
      FATAL_MIKTEX_ERROR ("PropPageFormats::MakeAlias",
			  T_("The compiler could not be found."),
			  formatInfo.compiler.c_str());
    }
  PathName pathBinDir =
    SessionWrapper(true)->GetSpecialPath(SpecialPath::BinDirectory);
  PathName pathAlias (pathBinDir, formatInfo.name, ".exe");
  if (compilerPath != pathAlias && ! File::Exists(pathAlias))
    {
      Directory::Create (pathBinDir);
      File::Copy (compilerPath, pathAlias);
      if (! Fndb::FileExists(pathAlias))
	{
	  Fndb::Add (pathAlias);
	}
    }
}
Example #10
0
bool
SessionImpl::MakePkFileName (/*[out]*/ PathName &	pkFileName,
			     /*[in]*/ const char *	lpszFontName,
			     /*[in]*/ int		dpi)
{
  string nameTemplate;

  if (! GetSessionValue(MIKTEX_REGKEY_CORE,
			MIKTEX_REGVAL_PK_FN_TEMPLATE,
			nameTemplate,
			DEFAULT_PK_NAME_TEMPLATE))
    {
      UNEXPECTED_CONDITION ("SessionImpl::MakePkFileName ");
    }

  string str;

  str.reserve (BufferSizes::MaxPath);

  for (const char * p = nameTemplate.c_str(); *p != 0; ++ p)
    {
      if (p[0] == '%')
	{
	  ++ p;
	  if (*p == 0)
	    {
	      FATAL_MIKTEX_ERROR ("SessionImpl::MakePkFileName",
				  T_("Invalid file name template."),
				  nameTemplate.c_str());
	    }
	  switch (*p)
	    {
	    case '%':
	      str += '%';
	      break;
	    case 'd':
	      str += NUMTOSTR(dpi);
	      break;
	    case 'f':
	      str += lpszFontName;
	      break;
	    default:
	      FATAL_MIKTEX_ERROR ("SessionImpl::MakePkFileName",
				  T_("Invalid file name template."),
				  nameTemplate.c_str());
	    }
	}
      else
	{
	  str += *p;
	}
    }

  pkFileName = str.c_str();

  return (true);
}
Example #11
0
DviSpecialType
TpicPolySpecialImpl::Parse ()
{
  m_outline = OutlineStyle::Solid;
  m_length = 0;
  m_bSpline = false;
  if (strncmp(GetXXX(), "ip", 2) == 0)
    {
      m_outline = OutlineStyle::None;
    }
  else if (strncmp(GetXXX(), "da", 2) == 0)
    {
      if (sscanf_s(GetXXX(), "da %f", &m_length) != 1)
	{
	  trace_error->WriteLine
	    ("libdvi",
	     T_("bad da special"));
	}
      else
	{
	  m_outline = OutlineStyle::Dashes;
	}
    }
  else if (strncmp(GetXXX(), "dt", 2) == 0)
    {
      if (sscanf_s(GetXXX(), "dt %f", &m_length) != 1)
	{
	  trace_error->WriteLine
	    ("libdvi",
	     T_("bad dt special"));
	}
      else
	{
	  m_outline = OutlineStyle::Dots;
	}
    }
  else if (strncmp(GetXXX(), "sp", 2) == 0)
    {
      m_bSpline = true;
      if (sscanf_s(GetXXX(), "sp %f", &m_length) == 1)
	{
	  if (m_length > 0)
	    {
	      m_outline = OutlineStyle::Dashes;
	    }
	  else if (m_length < 0)
	    {
	      m_length *= -1;
	      m_outline = OutlineStyle::Dots;
	    }
	}
    }

  return (DviSpecialType::Tpic);
}
Example #12
0
void
PostScript::SendHeader (/*[in]*/ const char * lpszHeaderName)
{
  PathName fileName;
  if (! SessionWrapper(true)->FindFile(lpszHeaderName, FileType::PSHEADER, fileName))
  {
    FATAL_MIKTEX_ERROR (T_("PostScript::SendHeader"),
      T_("Cannot find PostScript header file."), lpszHeaderName);
  }
  tracePS->WriteFormattedLine ("libdvi", T_("Sending %s..."), Q_(fileName));
  ExecuteBatch (fileName.Get());
}
BOOL
InverseSearchOptionsPage::OnApply ()
{
  try
    {
      PathName pathEditorsIni
	(SessionWrapper(true)->GetSpecialPath(SpecialPath::ConfigRoot),
	 MIKTEX_PATH_EDITORS_INI);
      if (mustWrite)
	{
	  SmartPointer<Cfg> pCfg (Cfg::Create());
	  for (int idx = firstCustomIdx;
	       idx < static_cast<int>(editors.size());
	       ++ idx)
	    {
	      pCfg->PutValue (editors[idx].name.c_str(),
			      T_("program"),
			      editors[idx].program.c_str());
	      pCfg->PutValue (editors[idx].name.c_str(),
			      T_("arguments"),
			      editors[idx].arguments.c_str());
	    }
	  Directory::Create (PathName(pathEditorsIni).RemoveFileSpec());
	  pCfg->Write (pathEditorsIni);
	  mustWrite = false;
	  pCfg.Release ();
	  if (! Fndb::FileExists(pathEditorsIni))
	    {
	      Fndb::Add (pathEditorsIni);
	    }
	}
      if (commandLineIdx >= 0)
	{
	  g_pYapConfig->inverseSearchCommandLine =
	    editors[commandLineIdx].GetCommandLine().c_str();
	}
      else
	{
	  g_pYapConfig->inverseSearchCommandLine = "";
	}
      return (CPropertyPage::OnApply());
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
      return (FALSE);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
      return (FALSE);
    }
}
Example #14
0
BOOL
SiteWizRemote::OnInitDialog ()
{
  BOOL ret = CPropertyPage::OnInitDialog();

  try
    {
      listControl.SetExtendedStyle (listControl.GetExtendedStyle()
				    | LVS_EX_FULLROWSELECT);
      
      int colIdx = 0;
      
      InsertColumn (colIdx,
		    T_("Country"),
		    "xxxx Australia");
      
      ++ colIdx;
      
      InsertColumn (colIdx,
		    T_("Protocol"),
		    "xxxx HTTP");

      ++ colIdx;

      InsertColumn (colIdx,
		    T_("Host"),
		    "xxxx scratchy.emate.ucr.ac.cr");
      
      ++ colIdx;
      
      InsertColumn (colIdx,
		    T_("Version"),
		    "xxxx 30-Aug-04");
      
      ++ colIdx;
      
      InsertColumn (colIdx,
		    T_("Description"),
		    "xxxx Primary Package Repository");
      
      ++ colIdx;
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }

  return (ret);
}
Example #15
0
void eqnsys<nr_type_t>::factorize_svd (void) {
  int i, j, l;
  nr_type_t t;

  // allocate space for vectors and matrices
  delete R; R = new tvector<nr_type_t> (N);
  delete T; T = new tvector<nr_type_t> (N);
  delete V; V = new tmatrix<nr_type_t> (N);
  delete S; S = new tvector<nr_double_t> (N);
  delete E; E = new tvector<nr_double_t> (N);

  // bidiagonalization through householder transformations
  for (i = 0; i < N; i++) {
    T_(i) = householder_left (i);
    if (i < N - 1) R_(i) = householder_right (i);
  }

  // copy over the real valued bidiagonal values
  for (i = 0; i < N; i++) S_(i) = real (A_(i, i));
  for (E_(0) = 0, i = 1; i < N; i++) E_(i) = real (A_(i - 1, i));

  // backward accumulation of right-hand householder transformations
  // yields the V' matrix
  for (l = N, i = N - 1; i >= 0; l = i--) {
    if (i < N - 1) {
      if ((t = R_(i)) != 0.0) {
	householder_apply_right_extern (i, cond_conj (t));
      }
      else for (j = l; j < N; j++) // cleanup this row
	V_(i, j) = V_(j, i) = 0.0;
    }
    V_(i, i) = 1.0;
  }

  // backward accumulation of left-hand householder transformations
  // yields the U matrix in place of the A matrix
  for (l = N, i = N - 1; i >= 0; l = i--) {
    for (j = l; j < N; j++) // cleanup upper row
      A_(i, j) = 0.0;
    if ((t = T_(i)) != 0.0) {
      householder_apply_left (i, cond_conj (t));
      for (j = l; j < N; j++) A_(j, i) *= -t;
    }
    else for (j = l; j < N; j++) // cleanup this column
      A_(j, i) = 0.0;
    A_(i, i) = 1.0 - t;
  }

  // S and E contain diagonal and super-diagonal, A contains U, V'
  // calculated; now diagonalization can begin
  diagonalize_svd ();
}
Example #16
0
SpyFrame::SpyFrame(dwt::TabView* mdiParent) :
	BaseType(mdiParent, T_("Search Spy"), IDH_SEARCH_SPY, IDR_SPY),
	searches(0),
	ignoreTTH(0),
	bIgnoreTTH(BOOLSETTING(SPY_FRAME_IGNORE_TTH_SEARCHES)),
	total(0),
	cur(0)
{
	memset(perSecond, 0, sizeof(perSecond));

	{
		Table::Seed cs = WinUtil::Seeds::Table;
		cs.style |= LVS_SINGLESEL;
		searches = addChild(cs);
		addWidget(searches);

		searches->createColumns(WinUtil::getStrings(columnNames));
		searches->setColumnOrder(WinUtil::splitTokens(SETTING(SPYFRAME_ORDER), columnIndexes));
		searches->setColumnWidths(WinUtil::splitTokens(SETTING(SPYFRAME_WIDTHS), columnSizes));
		searches->setSort(COLUMN_COUNT, dwt::Table::SORT_INT, false);
		searches->onColumnClick(std::tr1::bind(&SpyFrame::handleColumnClick, this, _1));
		searches->onContextMenu(std::tr1::bind(&SpyFrame::handleContextMenu, this, _1));
	}

	{
		CheckBox::Seed cs(T_("Ignore TTH searches"));
		ignoreTTH = addChild(cs);
		ignoreTTH->setHelpId(IDH_SPY_IGNORE_TTH);
		ignoreTTH->setChecked(bIgnoreTTH);
		ignoreTTH->onClicked(std::tr1::bind(&SpyFrame::handleIgnoreTTHClicked, this));
	}

	initStatus();
	statusSizes[STATUS_IGNORE_TTH] = 150; ///@todo get real checkbox + text width

	setStatusHelpId(STATUS_TOTAL, IDH_SPY_TOTAL);
	setStatusHelpId(STATUS_AVG_PER_SECOND, IDH_SPY_AVG_PER_SECOND);
	setStatusHelpId(STATUS_HITS, IDH_SPY_HITS);
	setStatusHelpId(STATUS_HIT_RATIO, IDH_SPY_HIT_RATIO);

	layout();

	onSpeaker(std::tr1::bind(&SpyFrame::handleSpeaker, this, _1, _2)) ;

	ShareManager::getInstance()->setHits(0);

	ClientManager::getInstance()->addListener(this);

	initSecond();
}
Example #17
0
void
VFont::ReadPreamble (/*[in]*/ InputStream & inputStream)
{
  if (inputStream.ReadByte() != id_byte)
    {
      FATAL_DVI_ERROR ("VFont::ReadPreamble",
		       T_("Bad VF file."),
		       dviInfo.fileName.c_str());
    }

  unsigned long commentSize = inputStream.ReadByte();

  char tmp[256];
  inputStream.Read (tmp, commentSize);
  tmp[commentSize] = 0;
  dviInfo.comment = tmp;

  int my_checkSum = inputStream.ReadSignedQuad();
  int my_designSize = inputStream.ReadSignedQuad();

  trace_vfont->WriteFormattedLine
    ("libdvi",
     "comment: %s",
     dviInfo.comment.c_str());
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "checkSum: 0%o",
     my_checkSum);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "designSize: %d",
     my_designSize);

  if (my_designSize * tfmConv != designSize)
    {
      trace_error->WriteFormattedLine
	("libdvi",
	 T_("%s: designSize mismatch"),
	 dviInfo.name.c_str());
    }

  if (my_checkSum != checkSum)
    {
      trace_error->WriteFormattedLine
	("libdvi",
	 T_("%s: checkSum mismatch"),
	 dviInfo.name.c_str());
    }
}
Example #18
0
OpenFontFile (/*[in,out]*/ bytefile *	pByteFile,
	      /*[in]*/ const char *	lpszFontName,
	      /*[in]*/ FileType		filetype,
	      /*[in]*/ const char *	lpszMakeFontCommand)
{
  PathName pathFont;
  if (! SessionWrapper(true)->FindFile(lpszFontName,
				       filetype,
				       pathFont))
    {
      if (lpszMakeFontCommand == 0
	  || ! SessionWrapper(true)->GetMakeFontsFlag())
	{
	  return (false);
	}
      PathName exe;
      if (! SessionWrapper(true)->FindFile(lpszMakeFontCommand,
					   FileType::EXE,
					   exe))
	{
	  FATAL_MIKTEX_ERROR ("OpenFontFile",
			      T_("\
The font creation utility could not be found."),
			      lpszMakeFontCommand);
	}
      char szBaseName[BufferSizes::MaxPath];
      PathName::Split (lpszFontName,
		       0, 0,
		       szBaseName, BufferSizes::MaxPath,
		       0, 0);
      string arguments;
      arguments = " -v \"";
      arguments += szBaseName;
      arguments += "\"";
      int exitCode;
      if (! (Process::Run(exe, arguments.c_str(), 0, &exitCode, 0)
	     && exitCode == 0))
	{
	  return (false);
	}
      if (! SessionWrapper(true)->FindFile(lpszFontName,
					   filetype,
					   pathFont))
	{
	  FATAL_MIKTEX_ERROR ("OpenFontFile",
			      T_("The font file could not be found."),
			      lpszFontName);
	}
    }
Example #19
0
void
PostScript::ExecuteEncapsulatedPostScript (/*[in]*/ const char * lpszFileName)
{
  FileStream epsStream;

  unsigned start = 0;
  unsigned length = 0;

#if 0
  // TODO
  if (bmeps_can_handle(PathName(lpszFileName).GetBuffer()) != 0)
  {
    tracePS->WriteFormattedLine ("libdvi", T_("Converting %s to EPS..."), Q_(lpszFileName));
    epsStream.Attach (ConvertToEPS(lpszFileName));
  }
  else
#endif
  {
    epsStream.Attach (File::Open(lpszFileName, FileMode::Open, FileAccess::Read, false));
    struct
    {
      unsigned char magic[4];
      unsigned char start[4];
      unsigned char length[4];
    } epsfheader;
    if (epsStream.Read(&epsfheader, sizeof(epsfheader)) == sizeof(epsfheader)
      && epsfheader.magic[0] == 'E' + 0x80
      && epsfheader.magic[1] == 'P' + 0x80
      && epsfheader.magic[2] == 'S' + 0x80
      && epsfheader.magic[3] == 'F' + 0x80)
    {
      start = epsfheader.start[0];
      start += epsfheader.start[1] * 256;
      start += epsfheader.start[2] * 256 * 256;
      start += epsfheader.start[3] * 256 * 256 * 256;
      length = epsfheader.length[0];
      length += epsfheader.length[1] * 256;
      length += epsfheader.length[2] * 256 * 256;
      length += epsfheader.length[3] * 256 * 256 * 256;
      tracePS->WriteFormattedLine ("libdvi", T_("EPS has a binary header"));
      tracePS->WriteFormattedLine ("libdvi", T_("start: %u"), static_cast<unsigned>(start));
      tracePS->WriteFormattedLine ("libdvi", T_("length: %u"), static_cast<unsigned>(length));
    }
  }

  epsStream.Seek (start, SeekOrigin::Begin);

  CopyFile (epsStream, length);
}
void FavoriteDirsPage::handleRenameClicked() {
	int i = -1;
	while((i = directories->getNext(i, LVNI_SELECTED)) != -1) {
		tstring old = directories->getText(i, 0);
		LineDlg dlg(this, T_("Favorite name"), T_("Under what name you see the directory"), old);
		if(dlg.run() == IDOK) {
			tstring line = dlg.getLine();
			if (FavoriteManager::getInstance()->renameFavoriteDir(Text::fromT(old), Text::fromT(line))) {
				directories->setText(i, 0, line);
			} else {
				createMessageBox().show(T_("Directory or directory name already exists"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), MessageBox::BOX_OK, MessageBox::BOX_ICONSTOP);
			}
		}
	}
}
Example #21
0
MIKTEXCALLBACK
GZipReaderThread (/*[in]*/ void * pv)
{
    try
    {
        auto_ptr<GZipReaderThreadArg>
        pArg (reinterpret_cast<GZipReaderThreadArg*>(pv));
        MIKTEX_ASSERT (pArg->gzin != 0);
        MIKTEX_ASSERT (pArg->fileout != 0);
        AutoGZ autoCloseGZip2Stream (pArg->gzin);
        FileStream autoCloseOutput (pArg->fileout);
        char buf[PIPE_SIZE];
        int len = 0;
        while (! ferror(pArg->fileout)
                && (len = gzread(pArg->gzin, buf, ARRAY_SIZE(buf))) > 0)
        {
            fwrite (buf, 1, len, pArg->fileout);
        }
        if (len < 0)
        {
            FATAL_MIKTEX_ERROR ("GZipReaderThread",
                                T_("gzread() failed for some reason."),
                                0);
        }
        if (ferror(pArg->fileout))
        {
            FATAL_CRT_ERROR ("fwrite", 0);
        }
    }
    catch (const exception &)
    {
    }
}
Example #22
0
bool
ProgressDialogImpl::HasUserCancelled ()
{
  if (hWindow == 0)
    {
      return (false);
    }

  DWORD_PTR res;

  if (! SendMessageTimeout(hWindow,
			   HASUSERCANCELLED,
			   0,
			   0,
			   0,
			   1000,
			   &res))
    {
      CHECK_WINDOWS_ERROR ("SendMessageTimeout", 0);
      FATAL_MIKTEX_ERROR ("ProgressDialogImpl::HasUserCancelled",
			  T_("The progress window does not respond."),
			  0);
    }

  return (res ? true : false);
}
Example #23
0
void UsersFrame::UserInfo::update(const FavoriteUser& u) {
	columns[COLUMN_NICK] = Text::toT(u.getNick());
	columns[COLUMN_HUB] = user->isOnline() ? WinUtil::getHubNames(u.getUser()).first : Text::toT(u.getUrl());
	columns[COLUMN_SEEN] = user->isOnline() ? T_("Online") : Text::toT(Util::formatTime("%Y-%m-%d %H:%M", u.getLastSeen()));
	columns[COLUMN_DESCRIPTION] = Text::toT(u.getDescription());
	columns[COLUMN_CID] = Text::toT(u.getUser()->getCID().toBase32());
}
Example #24
0
bool
SiteWizLocal::validatePage ()
{
  try
    {
      if (! QWizardPage::validatePage())
	{
	  return (false);
	}
      PathName directory (leDirectory->text().toLocal8Bit().data());
      if (! Directory::Exists(directory))
	{
	  QMessageBox::critical (this,
				 QString(),
				 T_("\
The specified directory does not exist."));
	  return (false);
	}
      if (! pManager->IsLocalPackageRepository(directory))
	{
	  PathName mpmIni (directory);
	  mpmIni += "texmf";
	  mpmIni += MIKTEX_PATH_MPM_INI;
	  if (! File::Exists(mpmIni))
	    {
	      QMessageBox::critical (this,
				     QString(),
				     T_("Not a local package repository."));
	      return (false);
	    }
	}
      pManager->SetDefaultPackageRepository (RepositoryType::Local,
					     directory.Get());
      return (true);
    }
Example #25
0
FILE *
SessionImpl::InitiateProcessPipe (/*[in]*/ const char *		lpszCommand,
        /*[in]*/ FileAccess		access,
        /*[in,out]*/ FileMode &	mode)
{
    Argv argv;
    argv.Build ("", lpszCommand);
    int argc = argv.GetArgc();
    if (argc == 0)
    {
        FATAL_MIKTEX_ERROR ("SessionImpl::InitiateProcessPipe",
                            T_("Invalid command."),
                            lpszCommand);
    }
    string verb = argv[1];
    if (verb == "zcat"
            && argc == 3
            && access.Get() == FileAccess::Read)
    {
        mode = FileMode::Open;
        return (OpenGZipFile(argv[2]));
    }
    else if (verb == "bzcat"
             && argc == 3 &&
             access.Get() == FileAccess::Read)
    {
        mode = FileMode::Open;
        return (OpenBZip2File(argv[2]));
    }
    else
    {
        return (POpen(lpszCommand,
                      access.Get() == FileAccess::Read ? "r" : "w"));
    }
}
Example #26
0
void
MainFrame::OnUpdateNumPackages (/*[in]*/ CCmdUI * pCmdUI)
{
  try
    {
      CView * pView = GetActiveView();
      pCmdUI->Enable (pView != 0);
      if (pView == 0)
	{
	  pCmdUI->SetText (_T(""));
	  return;
	}
      if (! pView->IsKindOf(RUNTIME_CLASS(MpmView)))
	{
	  pCmdUI->SetText (_T(""));
	  return;
	}
      MpmView * pMpmView = reinterpret_cast<MpmView*>(pView);
      CString str;
      str.Format (T_(_T("Total: %d")), pMpmView->GetNumberOfPackages());
      pCmdUI->SetText (str); 
    }

  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (this, e);
    }

  catch (const exception & e)
    {
      ErrorDialog::DoModal (this, e);
    }
}
Example #27
0
FILE *
SessionImpl::OpenBZip2File (/*[in]*/ const PathName & path)
{
    AutoBZ2 autoBz2 (BZ2_bzopen(path.Get(), "rb"));
    if (autoBz2.Get() == 0)
    {
        FATAL_MIKTEX_ERROR ("OpenBZip2File",
                            T_("BZ2_bzopen() failed for some."),
                            path.Get());
    }
    FILE * pFiles[2];
    Pipe (pFiles, PIPE_SIZE);
    try
    {
        auto_ptr<BZip2ReaderThreadArg> pArg (new BZip2ReaderThreadArg);
        pArg->bzin = autoBz2.Get();
        pArg->fileout = pFiles[1];
        auto_ptr<Thread> pThread (Thread::Start(BZip2ReaderThread, pArg.get()));
        pArg.release ();
        autoBz2.Detach ();
        return (pFiles[0]);
    }
    catch (const exception &)
    {
        if (pFiles[0] != 0)
        {
            fclose (pFiles[0]);
        }
        if (pFiles[1] != 0)
        {
            fclose (pFiles[1]);
        }
        throw;
    }
}
Example #28
0
void CommandDlg::handleOKClicked() {
	name = nameBox->getText();
	if((type != 0) && (name.empty() || commandBox->getText().empty())) {
		createMessageBox().show(T_("Name and command must not be empty"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), MessageBox::BOX_OK, MessageBox::BOX_ICONEXCLAMATION);
		return;
	}

	ctx = 0;
	if(hubMenu->getChecked())
		ctx |= UserCommand::CONTEXT_HUB;
	if(userMenu->getChecked())
		ctx |= UserCommand::CONTEXT_CHAT;
	if(searchMenu->getChecked())
		ctx |= UserCommand::CONTEXT_SEARCH;
	if(fileListMenu->getChecked())
		ctx |= UserCommand::CONTEXT_FILELIST;

	hub = hubBox->getText();

	if(type != 0)
		type = once->getChecked() ? 2 : 1;

	SettingsManager::getInstance()->set(SettingsManager::OPEN_USER_CMD_HELP, openHelp->getChecked());

	endDialog(IDOK);
}
Example #29
0
Tfm::Tfm (/*[in]*/ DviImpl *	pDvi,
	  /*[in]*/ int		checkSum,
	  /*[in]*/ int		scaledSize,
	  /*[in]*/ int		designSize,
	  /*[in]*/ const char *	lpszAreaName,
	  /*[in]*/ const char *	lpszFontName,
	  /*[in]*/ const char *	lpszFileName,
	  /*[in]*/ double	tfmConv,
	  /*[in]*/ double	conv)

  : DviFont (pDvi,
	     checkSum,
	     scaledSize,
	     designSize,
	     lpszAreaName,
	     lpszFontName,
	     lpszFileName,
	     tfmConv,
	     conv),
    trace_error (TraceStream::Open(MIKTEX_TRACE_ERROR)),
    trace_tfm (TraceStream::Open(MIKTEX_TRACE_DVITFM))

{
  trace_tfm->WriteFormattedLine
    ("libdvi",
     T_("creating TFM object '%s'"),
     dviInfo.name.c_str());
  dviInfo.isVirtualFont = false;
}
Example #30
0
MIKTEXCALLBACK
BZip2ReaderThread (/*[in]*/ void * pv)
{
    try
    {
        auto_ptr<BZip2ReaderThreadArg>
        pArg (reinterpret_cast<BZip2ReaderThreadArg*>(pv));
        MIKTEX_ASSERT (pArg->bzin != 0);
        MIKTEX_ASSERT (pArg->fileout != 0);
        AutoBZ2 autoCloseBZip2Stream (pArg->bzin);
        FileStream autoCloseOutput (pArg->fileout);
        char buf[PIPE_SIZE];
        int len;
        while (! ferror(pArg->fileout)
                && (len = BZ2_bzread(pArg->bzin, buf, ARRAY_SIZE(buf))) > 0)
        {
            fwrite (buf, 1, len, pArg->fileout);
        }
        int bzerr;
        BZ2_bzerror (pArg->bzin, &bzerr);
        if (bzerr != BZ_OK)
        {
            FATAL_MIKTEX_ERROR ("BZip2ReaderThread",
                                T_("BZ2_bzread() failed for some reason."),
                                0);
        }
        if (ferror(pArg->fileout))
        {
            FATAL_CRT_ERROR ("fwrite", 0);
        }
    }
    catch (const exception &)
    {
    }
}