Example #1
0
Layer* OpBackground::DoCreateBackgroundLayer(UndoableOperation * pOp, Spread * pSpread)
{
	ERROR2IF(pOp == NULL || pSpread == NULL,FALSE,"OpBackground::DoCreateBackgroundLayer Bad params error!");

	// Search for our special page background layer
	Layer* pFoundLayer = pSpread->FindFirstPageBackgroundLayer();
	// If we have found it then return this to the caller as we don't want
	// more than one present!
	if (pFoundLayer != NULL)
		return pFoundLayer;

	// We didn't find a page background layer so go and create a new one
	Layer* pNewLayer = CreateBackgroundLayer();
	if (pNewLayer != NULL)
	{
		// If we insert the new layer as the FIRSTCHILD then this will be like the guidelayer
		// and behind the page. If we insert as the last child then we will be at the front of
		// the stacking order. We need to insert ourselves as the node after the last page node
		Page *pLastPage = pSpread->FindLastPageInSpread();

		// Insert the new layer as the next node after the last page.
		if (pLastPage && pOp->DoInsertNewNode(pNewLayer, pLastPage, NEXT, FALSE,FALSE,FALSE,FALSE))
		{
			pNewLayer->EnsureUniqueLayerID();
			BROADCAST_TO_ALL(SpreadMsg(pSpread, SpreadMsg::LAYERCHANGES));
		}
		else
		{
			delete pNewLayer;
			pNewLayer = NULL;
		}
	}

	return pNewLayer;
}
Example #2
0
void OpShowGuides::Do(OpDescriptor*)
{
	DocView *pDocView = DocView::GetSelected();

	if (pDocView != NULL)
	{
		pDocView->SetShowGuidesState(!pDocView->GetShowGuidesState());

		Spread* pSpread = Document::GetSelectedSpread();
		Document* pDoc  = Document::GetSelected();
		if (pSpread != NULL && pDoc != NULL)
		{
			Layer* pLayer = pSpread->FindFirstGuideLayer();
			if (pLayer != NULL)
				LayerSGallery::ForceRedrawLayer(pDoc,pLayer);
		}

		BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
	}

	End();
}