void CMainFrame::Sort(VARIANT* vArray)
{
   COleSafeArray sa;
   BSTR *pbstr;
   TCHAR buf[1024];
   LONG cElements, lLBound, lUBound;
  
   //needed for OLE2T macro below, include afxpriv.h
   USES_CONVERSION;

   // Type check VARIANT parameter. It should contain a BSTR array
   // passed by reference. The array must be passed by reference it is
   // an in-out-parameter.
   if (V_VT(vArray) != (VT_ARRAY | VT_BSTR))
   {
      AfxThrowOleDispatchException(1001, 
         _T("Type Mismatch in Parameter. Pass a string array by reference"));
   }

   // clears data in sa and copies the variant data into sa
   sa.Attach(*vArray);

   // Check that array is 1 dimensional
   if (sa.GetDim() != 1)
   {
      AfxThrowOleDispatchException(1002, 
         _T("Type Mismatch in Parameter. Pass a one-dimensional array"));
   }

   try 
   {
      // Get array bounds.
      sa.GetLBound(1, &lLBound);
      sa.GetUBound(1, &lUBound);

      // Get a pointer to the elements of the array
      // and increments the lock count on the array
      sa.AccessData((LPVOID*)&pbstr);

      //get no. of elements in array
      cElements = lUBound - lLBound + 1;
      for (int i = 0; i < cElements; i++)
      {
         //output the elements of the array
         _stprintf_s(buf, 1024, _T("[%s]\n"), OLE2T(pbstr[i]));
         OutputDebugString(buf);
      }
      
      //decrement lock count
      sa.UnaccessData();
   }
   catch (COleException *pEx)
   {
      AfxThrowOleDispatchException(1003, 
         _T("Unexpected Failure in FastSort method"));
      pEx->Delete();
   }
}
Ejemplo n.º 2
0
IComparison* Comparisons::NewEx(LPCTSTR originalDocId, LPCTSTR modifiedDocId, VARIANT &renderingSet, LONG comparisonMode, VARIANT_BOOL showSelectorDialog, BSTR originalDescription, BSTR modifiedDescription)
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());
	AutomationInteractionSuppressor ais;

	CDeltaViewCommandLineInfo cmdInfo;
	cmdInfo.m_sOriginal = EnsureDocId(originalDocId);
	cmdInfo.m_sModified = EnsureDocId(modifiedDocId);
	cmdInfo.m_sOriginalDisplayName = originalDescription;
	cmdInfo.m_sModifiedDisplayName = modifiedDescription;
	cmdInfo.m_bShowSelector = showSelectorDialog != VARIANT_FALSE;
	CStdString selectedRenderingSet = RenderingSet::GetCurrentRenderingSet();
	_variant_t vrenderSet = renderingSet;
	if (vrenderSet.vt == VT_BSTR)
	{
		selectedRenderingSet = _bstr_t(vrenderSet);
	}
	RenderingSetOverride rso(selectedRenderingSet);

	cmdInfo.m_comparisonOption = comparisonMode;
	cmdInfo.m_bSilentMode = showSelectorDialog == VARIANT_FALSE;

	COptionsDlgSelector optSelector;
	if(optSelector.SetDlgInformation(cmdInfo) == S_FALSE)
		return FALSE;

	if( cmdInfo.ShouldShowDocumentSelectorDlg() )
	{		
		if( !optSelector.ShowDialog() )
		{
			// Dialog might have returned false because it was cancelled during a right-click op.
			// If so, don't display a 'unable to compare' error.  ST2085
			if( !optSelector.Cancelled() )
			{
				AfxThrowOleDispatchException(1105, L"Comparison failed.");
			}
			AfxThrowOleDispatchException(1106, L"Cancelled.");
		}
	}
	else
	{
		if (!optSelector.StartComparisons())
		{
			AfxThrowOleDispatchException(1105, L"Comparison failed.");
		}
	}

// TODO - can we get the frame in a better way
	CMDIFrameWnd* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWnd, AfxGetMainWnd());
	CChildFrame *pFrame = DYNAMIC_DOWNCAST( CChildFrame, pMainFrame->MDIGetActive() );
	CDeltaVwDoc* pDoc = pFrame->GetDocument();
	UpdateOpenList();
	return FindComObject(pDoc);

}
Ejemplo n.º 3
0
LONG Changes::GetCount(void)
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());

	if (m_pDocument == NULL || m_pDocument->GetDVController() == NULL || m_pDocument->GetDVController()->GetChildFrame() == NULL || m_pDocument->GetDVController()->GetChildFrame()->GetSummaryWnd() == NULL )
	{
		AfxThrowOleDispatchException(1100, L"The object has been deleted.");
	}

	return m_pDocument->GetDVController()->GetChildFrame()->GetSummaryWnd()->GetSummaryItemCount();
}
Ejemplo n.º 4
0
IChange* Changes::Item(LONG Index)
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());

	if (m_pDocument == NULL)
	{
		AfxThrowOleDispatchException(1100, L"The object has been deleted.");
	}

	if (Index <= 0 || Index > GetCount())
		AfxThrowOleDispatchException(1103, L"Index out of range.");

	if (m_vChanges[Index-1] == NULL)
	{
		Change* pChange = new Change(m_pDocument, Index-1);
		pChange->InternalAddRef();
		m_vChanges[Index - 1] = pChange;
	}

	return m_vChanges[Index-1]->GetComObject();
}
Ejemplo n.º 5
0
IComparison* Comparisons::Item(LONG Index)
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());
	AutomationInteractionSuppressor ais;
	UpdateOpenList();

	if (Index <= 0 || Index > (int) m_openList.size())
		AfxThrowOleDispatchException(1103, L"Index out of range.");

	return m_openList[Index-1].second->GetComObject();

}
Ejemplo n.º 6
0
IComparison* Comparisons::Open(LPCTSTR wdfDocId)
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());
	AutomationInteractionSuppressor ais;


	CMDIFrameWnd* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWnd, AfxGetMainWnd());
	GetApp()->RealFileNew();
// TODO - can we get the frame in a better way
	CChildFrame *pFrame = DYNAMIC_DOWNCAST( CChildFrame, pMainFrame->MDIGetActive() );

	if (pFrame)
	{
	// TODO - do we need this
		GetDVController(pFrame)->CloseDocument(true);
		GetDVController(pFrame)->CloseDocument(false);

		GetDVController(pFrame)->CloseCompositeDocument();
		GetDVController(pFrame)->GetComparisonDocController().CloseComparisonDocument();

		if( pFrame->GetCompositeBar() )
			pFrame->GetCompositeBar()->OnInitialUpdate();

		pFrame->ShowWindow(SW_SHOW);
		pFrame->BringWindowToTop();

		if (!GetDVController(pFrame)->LoadWDF(wdfDocId))
		{
			AfxThrowOleDispatchException(1102, L"File not found : " + CString(wdfDocId));
		}


		pFrame->GetDocument()->UpdateAllViews(NULL);
		UpdateOpenList();
		return FindComObject(pFrame->GetDocument());
	}
	AfxThrowOleDispatchException(1101, L"Internal Error");
	return NULL;
}
Ejemplo n.º 7
0
void CCmdTarget::SetNotSupported()
{
	AfxThrowOleDispatchException(
		AFX_IDP_SET_NOT_SUPPORTED, AFX_IDP_SET_NOT_SUPPORTED);
}
Ejemplo n.º 8
0
void CBoxHttpResponse::put_ContentEncoding(LPCTSTR pstrContentEncoding)
{
	if(_tcsicmp(pstrContentEncoding, _T("gzip")) && _tcsicmp(pstrContentEncoding, _T("deflate")))
		AfxThrowOleDispatchException(0x4005, _T("Not Support"), 0);
	m_pAccept->SetEncoding(pstrContentEncoding);
}