/////////////////////////////////////////////////////////////////////////////
// CBCGPOleServerDoc commands
void CBCGPOleServerDoc::OnResizeBorder( LPCRECT lpRectBorder, LPOLEINPLACEUIWINDOW lpUIWindow, BOOL bFrame )
{
	ASSERT_VALID (this);
	ASSERT (lpUIWindow != NULL);
	
	if (!bFrame)
	{
		COleServerDoc::OnResizeBorder (lpRectBorder, lpUIWindow, bFrame);
		return;
	}

	CBCGPOleCntrFrameWnd* pMainFrame = NULL;

	CBCGPOleDocIPFrameWnd* p_IpDocFrame = 
						DYNAMIC_DOWNCAST(CBCGPOleDocIPFrameWnd, m_pInPlaceFrame);

	if (p_IpDocFrame != NULL)
	{
		pMainFrame =  p_IpDocFrame->GetContainerFrameWindow ();
	}
	else
	{
		CBCGPOleIPFrameWnd* p_IpFrame = 
						DYNAMIC_DOWNCAST (CBCGPOleIPFrameWnd, m_pInPlaceFrame);

		if (p_IpFrame != NULL)
		{
			pMainFrame = p_IpFrame->GetContainerFrameWindow ();
		}
		else
		{
			return;
		}
	}

	if (pMainFrame == NULL)
	{
		return;
	}

	CBCGPDockManager* pDockManager = pMainFrame->GetDockManager ();
	ASSERT_VALID (pDockManager);

	CRect rcCurBorders;

	if (lpRectBorder == NULL)
	{
		if (lpUIWindow->GetBorder(&rcCurBorders) != S_OK)
		{
			lpUIWindow->SetBorderSpace (NULL);
			return;
		}
	}
	else
	{
		rcCurBorders = *lpRectBorder;
	}

	if (AfxGetThread()->m_pActiveWnd == m_pInPlaceFrame)
		OnShowControlBars(pMainFrame, TRUE);


	pDockManager->m_rectInPlace = rcCurBorders; 
	pDockManager->AdjustDockingLayout ();

	CRect rectClient = pDockManager->GetClientAreaBounds ();

	CRect rectRequest (
		abs (rectClient.left - rcCurBorders.left),
		abs (rectClient.top - rcCurBorders.top),
		abs (rectClient.right - rcCurBorders.right),
		abs (rectClient.bottom  - rcCurBorders.bottom)); // v.8.6 removed -1 to make it work in Excel

	CRect rectTemp;
	rectTemp = rectRequest;
	
	if (!rectRequest.IsRectNull() ||
		lpUIWindow->RequestBorderSpace(&rectTemp) == S_OK)
	{
		lpUIWindow->SetBorderSpace (&rectRequest);
		pDockManager->AdjustDockingLayout ();
	}
	else
	{
		OnShowControlBars (pMainFrame, FALSE);
		CRect rect (0,0,0,0);
		lpUIWindow->SetBorderSpace(&rect);
	}
}