void CNetscapeCntrItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam) { COleClientItem::OnChange(nCode, dwParam); // this is a hack to test if we need to ask user to save the file or not. // since I can not get lpPersistStorage->IsDirty() to give me the correct // answer. if (nCode == OLE_CLOSED) m_isDirty = FALSE; if (nCode == OLE_CHANGED && dwParam == DVASPECT_CONTENT) m_isDirty = TRUE; // Update all references to the item manually. MWContext *pContext = GetDocument()->GetContext()->GetContext(); POSITION rIndex = m_cplElements.GetHeadPosition(); LO_EmbedStruct *pLayoutData; while(rIndex != NULL) { pLayoutData = (LO_EmbedStruct *)m_cplElements.GetNext(rIndex); if (pContext->compositor) { XP_Rect rect; CL_GetLayerBbox(pLayoutData->layer, &rect); CL_UpdateLayerRect(CL_GetLayerCompositor(pLayoutData->layer), pLayoutData->layer, &rect, PR_FALSE); } else pContext->funcs->DisplayEmbed(pContext, FE_VIEW, pLayoutData); } }
/* * BUGBUG LAYERS: Since we know that lo_DisplaySubtext is only done * for selection, we generate a synchronous composite. This might * not be the right thing to do: maybe we should have an additional * argument to the LO_Display routines */ void lo_DisplaySubtext(MWContext *context, LO_TextStruct *text, int32 start_pos, int32 end_pos, Bool need_bg, CL_Layer *sel_layer) { lo_NormalizeStartAndEndOfSelection(text, &start_pos, &end_pos); /* If we have to draw, go through the compositor */ if (context->compositor) { XP_Rect rect; CL_Layer *layer; int32 x_offset, y_offset; if (!sel_layer) layer = CL_FindLayer(context->compositor, LO_BODY_LAYER_NAME); else layer = sel_layer; FE_GetTextFrame(context, text, start_pos, end_pos, &rect); lo_GetLayerXYShift(layer, &x_offset, &y_offset); XP_OffsetRect(&rect, -x_offset, -y_offset); CL_UpdateLayerRect(context->compositor, layer, &rect, PR_FALSE); return; } else /* For layers, we don't ever need to clear the background */ FE_DisplaySubtext(context, FE_VIEW, text, start_pos, end_pos, FALSE); }
void EmbedUrlExit(URL_Struct *pUrl, int iStatus, MWContext *pContext) { // The embedded item is finished downloading, and possibly has an error and stuff. NPEmbeddedApp* pEmbeddedApp = (NPEmbeddedApp*)pUrl->fe_data; if (!pEmbeddedApp) { NET_FreeURLStruct(pUrl); return; } CNetscapeCntrItem *pItem = (CNetscapeCntrItem *)pEmbeddedApp->fe_data; // if an EMBED tag's SRC attribute is a LOCAL file which does not exist, // pItem is NULL. Bandaid against GPF for 2.0, but later we must fix the // FE_GetEmbedSize() and NP_EmbedCreate() combo that cause this problem. if(pItem != NULL) { if(wfe_IsTypePlugin(pEmbeddedApp)) { pItem->m_bLoading = FALSE; NET_FreeURLStruct(pUrl); return; } #ifdef MOCHA { /* only wait on applets if onload flag */ lo_TopState *top_state = lo_FetchTopState(XP_DOCID(pContext)); if (top_state != NULL && top_state->mocha_loading_embeds_count) { top_state->mocha_loading_embeds_count--; ET_SendLoadEvent(pContext, EVENT_XFER_DONE, NULL, NULL, LO_DOCUMENT_LAYER_ID, FALSE); } } #endif /* MOCHA */ // else must be an OLE stream exit if(iStatus != MK_DATA_LOADED) { // Load error. pItem->m_bBroken = TRUE; } else if(pUrl->server_status != 0 && pUrl->server_status / 100 != 2 && pUrl->server_status / 100 != 3 && iStatus == MK_DATA_LOADED) { // Server error. pItem->m_bBroken = TRUE; } // If the item isn't broken, we can load it up. if(pItem->m_bBroken == FALSE) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); if(FALSE == pItem->CreateFromFile(pItem->m_csFileName)) { // Couldn't create for some reason! pItem->m_bBroken = TRUE; } SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } pItem->m_bLoading = FALSE; // Get the width and height out of our newly created item, if it isn't broken. // We need to do this two different ways, depending on what type of context we // are in. CSize csExtents; // New way. CDCCX *pCX = VOID2CX(pContext->fe.cx, CDCCX); if(pItem->m_bBroken == FALSE) { pItem->GetExtent(&csExtents); csExtents.cx = CASTINT(pCX->Metric2TwipsX(csExtents.cx)); csExtents.cy = CASTINT(pCX->Metric2TwipsY(csExtents.cy)); } else { LTRB Rect; int32 x, y; // pCX->DisplayIcon(Rect.left, Rect.right, IL_IMAGE_BAD_DATA, &x, &y); pCX->GetIconDimensions(&x, &y, IL_IMAGE_BAD_DATA); csExtents.cx = CASTINT(x); csExtents.cy = CASTINT(y); } // Need to flush all delayed display, and blocked layout. // Do all blocks. POSITION rIndex = pItem->m_cplUnblock.GetHeadPosition(); LO_EmbedStruct *pLayoutData = NULL; while(rIndex != NULL && iStatus != MK_INTERRUPTED) { pLayoutData = (LO_EmbedStruct *)pItem->m_cplUnblock.GetNext(rIndex); if ((pEmbeddedApp->type == NP_OLE) && pItem->m_lpObject) { if ( pLayoutData->width) csExtents.cx = pLayoutData->width; if ( pLayoutData->height) csExtents.cy = pLayoutData->height; pLayoutData->width = csExtents.cx; pLayoutData->height = csExtents.cy; } LO_ClearEmbedBlock(ABSTRACTCX(pContext)->GetDocumentContext(), pLayoutData); } pItem->m_cplUnblock.RemoveAll(); #ifdef LAYERS rIndex = pItem->m_cplElements.GetHeadPosition(); while (rIndex != NULL) { pLayoutData = (LO_EmbedStruct *)pItem->m_cplElements.GetNext(rIndex); // An OLE container is windowless until it is activated. LO_SetEmbedType(pLayoutData, PR_FALSE); } #endif // LAYERS // Do all needed display. rIndex = pItem->m_cplDisplay.GetHeadPosition(); while(rIndex != NULL) { pLayoutData = (LO_EmbedStruct *)pItem->m_cplDisplay.GetNext(rIndex); if ((pEmbeddedApp->type == NP_OLE) && pItem->m_lpObject) { if ( pLayoutData->width ) csExtents.cx = pLayoutData->width; if ( pLayoutData->height) csExtents.cy = pLayoutData->height; pLayoutData->width = csExtents.cx; pLayoutData->height = csExtents.cy; } #ifdef LAYERS if (pContext->compositor) { XP_Rect rect; CL_GetLayerBbox(pLayoutData->layer, &rect); CL_UpdateLayerRect(CL_GetLayerCompositor(pLayoutData->layer), pLayoutData->layer, &rect, PR_FALSE); } else #endif /* LAYERS */ pContext->funcs->DisplayEmbed(pContext, FE_VIEW, pLayoutData); } pItem->m_cplDisplay.RemoveAll(); } // And well, hey, get rid of the url. NET_FreeURLStruct(pUrl); }