Ejemplo n.º 1
0
BOOL COleClientItem::ActivateAs(LPCTSTR lpszUserType,
                                REFCLSID clsidOld, REFCLSID clsidNew)
{
    ASSERT_VALID(this);
    ASSERT(lpszUserType == NULL || AfxIsValidString(lpszUserType));
    ASSERT(m_lpObject != NULL);

    // enable activate as
    m_scLast = _AfxOleDoTreatAsClass(lpszUserType, clsidOld, clsidNew);
    if (FAILED(m_scLast))
        return FALSE;

    // reload all items in this doucment
    COleDocument* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    POSITION pos = pDoc->GetStartPosition();
    COleClientItem* pItem;
    while ((pItem = pDoc->GetNextClientItem(pos)) != NULL)
    {
        // reload it, so activate as works as appropriate
        pItem->Reload();
    }

    ASSERT_VALID(this);
    return TRUE;
}
Ejemplo n.º 2
0
//****************************************************************************
COleClientItem*	CBCGPFrameWnd::GetInPlaceActiveItem ()
{
    CFrameWnd* pActiveFrame = GetActiveFrame ();
    if (pActiveFrame == NULL)
    {
        return NULL;
    }

    ASSERT_VALID (pActiveFrame);

    CView* pView = pActiveFrame->GetActiveView ();
    if (pView == NULL || pView->IsKindOf (RUNTIME_CLASS (CBCGPPrintPreviewView)))
    {
        return NULL;
    }

    ASSERT_VALID (pView);

    COleDocument* pDoc = DYNAMIC_DOWNCAST (COleDocument, pView->GetDocument ());
    if (pDoc == NULL)
    {
        return NULL;
    }

    ASSERT_VALID (pDoc);
    return pDoc->GetInPlaceActiveItem (pView);
}
Ejemplo n.º 3
0
BOOL COleFrameHook::NotifyAllInPlace(
	BOOL bParam, BOOL (COleFrameHook::*pNotifyFunc)(BOOL bParam))
{
	ASSERT_VALID(this);
	HWND hWndFrame = m_hWnd;
	CWinApp* pApp = AfxGetApp();

	// no doc manager - no templates
	if (pApp->m_pDocManager == NULL)
		return TRUE;

	// walk all templates in the application
	CDocTemplate* pTemplate;
	POSITION pos = pApp->m_pDocManager->GetFirstDocTemplatePosition();
	while (pos != NULL)
	{
		pTemplate = pApp->m_pDocManager->GetNextDocTemplate(pos);
		ASSERT_VALID(pTemplate);
		ASSERT_KINDOF(CDocTemplate, pTemplate);

		// walk all documents in the template
		POSITION pos2 = pTemplate->GetFirstDocPosition();
		while (pos2)
		{
			COleDocument* pDoc = (COleDocument*)pTemplate->GetNextDoc(pos2);
			ASSERT_VALID(pDoc);
			if (pDoc->IsKindOf(RUNTIME_CLASS(COleDocument)))
			{
				// walk all COleClientItem objects in the document
				COleClientItem* pItem;
				POSITION pos3 = pDoc->GetStartPosition();
				while ((pItem = pDoc->GetNextClientItem(pos3)) != NULL)
				{
					if (pItem->m_pInPlaceFrame != NULL &&
						pItem->m_pInPlaceFrame->m_lpActiveObject != NULL &&
						pItem->m_pView != NULL &&
						AfxIsDescendant(hWndFrame, pItem->m_pView->m_hWnd))
					{
						// Whew!  Found an in-place active item that is
						//  part of this frame window hierarchy.
						COleFrameHook* pNotifyHook = pItem->m_pInPlaceFrame;
						if (!(pNotifyHook->*pNotifyFunc)(bParam))
							return FALSE;
					}
				}
			}
		}
	}
	return TRUE;
}
Ejemplo n.º 4
0
void COleServerItem::OnUpdateItems()
{
	COleDocument* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// update all of the embedded objects
	POSITION pos = pDoc->GetStartPosition();
	COleClientItem* pItem;
	while ((pItem = pDoc->GetNextClientItem(pos)) != NULL)
	{
		// update any out-of-date item
		if (pItem->m_lpObject->IsUpToDate() != NULL)
			pItem->m_lpObject->Update();
	}
}
Ejemplo n.º 5
0
BOOL COleServerItem::OnQueryUpdateItems()
{
	COleDocument* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// update all of the embedded objects
	POSITION pos = pDoc->GetStartPosition();
	COleClientItem* pItem;
	while ((pItem = pDoc->GetNextClientItem(pos)) != NULL)
	{
		// if any item is out-of-date, then this item is out-of-date
		if (pItem->m_lpObject->IsUpToDate() != NULL)
			return TRUE;    // update needed
	}
	return FALSE;   // update not needed
}
Ejemplo n.º 6
0
BOOL COleClientItem::CanActivate()
{
	// don't allow in-place activations with iconic aspect items
	if (m_nDrawAspect == DVASPECT_ICON)
		return FALSE;

	// if no view has been set, attempt to find suitable one.
	//  (necessary to get links to embeddings to work correctly)
	if (m_pView == NULL)
	{
		// only use pActivateView if this item is in same document
		_AFX_OLE_STATE* pOleState = _afxOleState;
		if (pOleState->m_pActivateView != NULL &&
			pOleState->m_pActivateView->GetDocument() != GetDocument())
		{
			pOleState->m_pActivateView = NULL;   // not in same document
		}

		CView* pView = pOleState->m_pActivateView;
		if (pView == NULL)
		{
			// no routing view available - try to use the one with focus
			CWnd* pWnd = CWnd::GetFocus();
			while (pWnd != NULL && !pWnd->IsKindOf(RUNTIME_CLASS(CView)))
				pWnd = pWnd->GetParent();
			pView = STATIC_DOWNCAST(CView, pWnd);

			if (pView == NULL)
			{
				// still no routing view available - just use first one
				COleDocument* pDoc = GetDocument();
				POSITION pos = pDoc->GetFirstViewPosition();
				pView = pDoc->GetNextView(pos);
			}
		}
		m_pView = pView;
	}

	return m_pView->GetSafeHwnd() != NULL;
}
Ejemplo n.º 7
0
void CDocItem::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		ASSERT_VALID(m_pDocument);
		// nothing to do, there is no data
	}
	else
	{
		// if no document connected yet, attach it from the archive
		if (m_pDocument == NULL)
		{
			COleDocument* pContainerDoc = (COleDocument*)ar.m_pDocument;
			ASSERT_VALID(pContainerDoc);
			ASSERT_KINDOF(COleDocument, pContainerDoc);
			pContainerDoc->AddItem(this);
			ASSERT(pContainerDoc == m_pDocument);
		}
	}
	// perform ASSERT_VALID at the end because COleServerItem::AssertValid
	// checks the validity of the m_pDocument pointer
	ASSERT_VALID(this);
}