예제 #1
0
/********************************************************************************************

>	void OpMakeNodesShapes::DoWithParam(OpDescriptor* pOp, OpParam* pParam)

	Author:		Karim_MacDonald (Xara Group Ltd) <*****@*****.**>
	Created:	23/11/1999
	Inputs:		pOp			unused pointer to an OpDescriptor.
				pParam		pointer to an OpParamMakeNodesShapes data information structure.

	Outputs:	The list of nodes, passed in through the OpParam, is converted in place
				into paths.
	Purpose:	This undoable operation converts a given list of nodes to editable shapes
				(paths), each new node retaining the selection status of the original.
	See also:	OpParamMakeNodesShapes

********************************************************************************************/
void OpMakeNodesShapes::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
{
	std::list<Node*>* plpNodes = ((OpParamMakeNodesShapes*)pParam)->m_plpNodes;

	Node* pNode;
	BOOL bFirst = FALSE;
	BOOL ok = TRUE;
	for (	std::list<Node*>::iterator iterNode = plpNodes->begin();
			iterNode != plpNodes->end() && ok;
			iterNode++ )
	{
		pNode = *iterNode;
		BecomeA baInfo(BECOMEA_REPLACE, CC_RUNTIME_CLASS(NodePath), this,
											pNode->IsSelected(), bFirst);
		baInfo.SetResultsStayInPlace(TRUE);
		ok = pNode->DoBecomeA(&baInfo);

#ifdef _DEBUG
		if (ok)
			TRACEUSER( "Karim", _T("converted %s to editable shapes\n"), pNode->Name());
#endif

		bFirst = TRUE;
	}

	if (!ok)
	{
		InformError();
		FailAndExecute();
	}

	End();
	return;
}
예제 #2
0
void OpDragBox::DragFinished(DocCoord dcMousePos, ClickModifiers cmods,
							 Spread* pSpread, BOOL fOK, BOOL bSolidDrag)
{
	// Remove the last drag box.
	RenderDragBlobs(m_drLastDragBox, m_pStartSpread, bSolidDrag);

	// It's possible that the mouse is in a different position to where it was on the last
	// call to DragPointerMove, so recalculate the drag box (but don't draw it, of course).
	// Here, check for a change in the spread containing the mouse.
	if (pSpread != m_pStartSpread && pSpread != NULL)
	{
		dcMousePos = MakeRelativeToSpread(m_pStartSpread, pSpread, dcMousePos);
	}

	// Recalculate the drag box.
	m_drLastDragBox = CalcDragBox(m_dcStartPos, dcMousePos);

	// Call the derived class handler, passing the drag box and the success code.
	if (!OnDragEnded(m_pStartSpread, m_drLastDragBox, cmods, EndDrag() && fOK))
	{
		FailAndExecute();
	}

	// Finally, end the operation.
	End();
}
예제 #3
0
void OpChangeLayerColour::DoWithParam(OpDescriptor* pOpDesc,OpParam* pOpParam)
{
	OpChangeLayerColourParam* pParam = (OpChangeLayerColourParam*)pOpParam;

	ActionCode Ac = LayerColourAction::Init(this,&UndoActions,*pParam);

	if (Ac == AC_FAIL)
		FailAndExecute();

	End();
}
예제 #4
0
BOOL OpRetroFit::BuildUndo(NodePath* pPreviousNode, NodePath* pNewNode)
{
	// A few quick error checks
	ENSURE(pPreviousNode!=NULL, "Previous Node was NULL in RetroFit::BuildUndo()");
	ENSURE(pPreviousNode->IsKindOf(CC_RUNTIME_CLASS(NodePath)), "Previous Node not a path");

	ENSURE(pNewNode!=NULL, "New Node was NULL in RetroFit::BuildUndo()");
	ENSURE(pNewNode->IsKindOf(CC_RUNTIME_CLASS(NodePath)), "New Node not a path");

	// Falg to see if it has worked
	BOOL IsOperationOk = TRUE;

	// Start the undo of the selected item
	IsOperationOk = DoStartSelOp(FALSE);

	// Will the node allow this op to take place?
	ObjChangeFlags cFlags;
	cFlags.ReplaceNode = TRUE;
	ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,pPreviousNode,this);
	if (IsOperationOk)
		IsOperationOk = pPreviousNode->AllowOp(&ObjChange);
	
	// insert our new object
	if (IsOperationOk)
	{
		// Insert the new node into the tree
		IsOperationOk = DoInsertNewNode(pNewNode, pPreviousNode, NEXT, TRUE);
	}

	// Invalidate the region covered by the old node
	if (IsOperationOk)
		IsOperationOk = DoInvalidateNodeRegion(pPreviousNode, TRUE);

	// Make sure everything has worked
	if (IsOperationOk)
	{
		// Remove the old node
		IsOperationOk = DoHideNode(pPreviousNode, TRUE);
	}

	ObjChange.Define(OBJCHANGE_FINISHED,cFlags,pPreviousNode,this);
	IsOperationOk = UpdateChangedNodes(&ObjChange);

	// If something went wrong then fail
	if (!IsOperationOk)
		FailAndExecute();
	
	// End the operation properly
	End();

	// return a value back to the caller
	return IsOperationOk;
}
예제 #5
0
파일: nativeop.cpp 프로젝트: vata/xarino
void OpMenuLoad::DoWithParam(OpDescriptor*, OpParam* pOpParam)
{
	// Extract the parameters.
	NativeFileOpParams* ppm = (NativeFileOpParams*)(void *)(pOpParam->Param1);

	// Try to load the file.
	ERROR3IF(!ppm->pFile, "Null CCLexFile* in OpMenuLoad::DoWithParam");
	ppm->fStatus = ppm->pFile && LoadFile(ppm->pFile, ppm->nPrefFilter);
	if (!ppm->fStatus) FailAndExecute();

	// Before we call End() we must ensure that CurrentDoc == SelectedDoc
	Document::GetSelected()->SetCurrent();
	End();
}
예제 #6
0
/********************************************************************************************
>	void OpMakeStroke::Do(OpDescriptor*)

	Author:		Richard_Millican (Xara Group Ltd) <*****@*****.**>
	Created:	04/03/97
	Inputs:		OpDescriptor (unused)
	Outputs:	-
	Returns:	-
	Purpose:	Performs the MakeShapes operation. 
********************************************************************************************/
void OpMakeStroke::Do(OpDescriptor*)
{   
	// Obtain the current selections 
	Range Selection = *GetApplication()->FindSelection();
	Node* CurrentNode = Selection.FindFirst(); 
	BOOL Success = TRUE;		
	
	ERROR3IF(CurrentNode == NULL, "Make shapes called with no nodes selected"); 
	
	if (CurrentNode != NULL) // No nodes selected so End
	{                    
		// Try to record the selection state, don't render the blobs though 
		if (Success)
			Success = DoStartSelOp(FALSE,FALSE);								   

		// First, Make Shapes on everything so they're all simple paths
		String_256 Desc("Building new stroke brush...");
		Progress::Start(FALSE, &Desc);
		OpDescriptor *pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_MAKE_SHAPES);
		if (pOp != NULL)
			pOp->Invoke();

		// Second, Group everything
		pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_GROUP);
		if (pOp != NULL)
			pOp->Invoke();

		pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_GROUP);
		if (pOp != NULL)
			pOp->Invoke();

		// Finally, create a new brush
		PathStrokerVector::BodgeRipSelection(/*(CommandIndex == 0) ? FALSE :*/ TRUE);
		Progress::Stop();

	}                   

	if (!Success)
	{
		InformError();
		FailAndExecute();
	}

 	End(); 
}			
예제 #7
0
void OpPush::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL Success, BOOL bSolidDrag)
{
	// Put up the hourglass as we have to
	BeginSlowJob();

	// End the Drag
	EndDrag();
	
	// If the drag failed, then fail the operation
	if (!Success) FailAndExecute();

	// End the operation
	End();

	// Send a message saying that the screen has changed, so that the brush tool can update
	BROADCAST_TO_ALL(ScreenChangeMsg());

}
예제 #8
0
파일: nativeop.cpp 프로젝트: vata/xarino
BOOL OpMenuSave::Save ( Filter *pFilter, CCLexFile *pFile )
{
	// Check that the extension is ok according to this filter
	// But only if the operation requires it
	if (FixFileType())
	{
		PathName pth = pFile->GetPathName();
		if (pth.IsValid()) EnsureFileTypeCorrectId(pFilter, pth);
	}

	// open the file and export into it
	if (!SaveSpecificFile(pFilter, pFile))
	{
		FailAndExecute();
		return FALSE;
	}

	// Success.
	return TRUE;
}
예제 #9
0
파일: nativeop.cpp 프로젝트: vata/xarino
Filter* OpMenuSave::FindFilter ( UINT32 nPrefFilter )
{
	UINT32 SearchFilterId = ( nPrefFilter != FILTERID_USERCHOICE ) ? nPrefFilter
																 : GetSearchFilterId ();
	Filter* pFilter = Filter::GetFirst ();

	while ( pFilter != NULL && pFilter->FilterID != SearchFilterId )
	{
		// Try the next filter
		pFilter = Filter::GetNext ( pFilter );
	}

	// Make sure that we found the Native Filter
	if ( pFilter == NULL )
	{
		InformError ( _R(IDT_CANT_FIND_FILTER) );
		FailAndExecute (); 
	}

	return pFilter;
}
예제 #10
0
파일: gendwnd.cpp 프로젝트: vata/xarino
BOOL OpGenericDownload::OnDocChangingMsg(Document* pChangingDoc, DocChangingMsg::DocState State)
{
	GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam;
	Document* pCurDoc = pGenericParam->pDoc;

	if (pParam != NULL)
	{
		if (State == DocChangingMsg::ABOUTTODIE && pChangingDoc == pCurDoc)
		{
//			Document::SetSelectedViewAndSpread(pCurDoc);
//			SelOperation* Op = pGenericParam->m_Op;
//			((OpMenuImport*)Op)->EndImport();

			// end of the download op
			FailAndExecute(); 
			End();
		}
	}

	return TRUE;
}
예제 #11
0
/********************************************************************************************

>	virtual void OpApplyClipView::Do(OpDescriptor* pOpDesc, OpParam* pOpParam)

	Author:		Karim_MacDonald (Xara Group Ltd) <*****@*****.**>
	Created:	01 February 2000
	Inputs:		
	Outputs:	
	Returns:	
	Purpose:	
	Errors:		
	See also:	

********************************************************************************************/
void OpApplyClipView::Do(OpDescriptor* pOpDesc)
{
	// obtain the current selection.
	Range Sel(*(GetApplication()->FindSelection()));
	RangeControl rc = Sel.GetRangeControlFlags();
	rc.PromoteToParent = TRUE;
	Sel.Range::SetRangeControl(rc);

	// check that at least two nodes are selected.
	Node* pNode = NULL;
	Node* pFirstNode = Sel.FindFirst();
	if (pFirstNode != NULL)
		pNode = Sel.FindNext(pFirstNode);
		
	if (pFirstNode == NULL || pNode == NULL)
	{
		ERROR3("OpApplyClipView invoked with less than two selected nodes. This should never occur.");
		End();
		return;
	}

	// render blobs off for tools which don't automatically redraw their blobs.
	Tool* pTool = Tool::GetCurrent();
	Spread* pSpread = Document::GetSelectedSpread();
	if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
		pTool->RenderToolBlobs(pSpread, NULL);

	// record the current selection state and if required, render off any selection blobs.
	if (!DoStartSelOp(FALSE, FALSE))
	{
		End();
		return;
	}

	// invalidate the region bounding the selection.
	// the commented code doesn't do the job properly (doesn't tackle undo)
	// though it should - I get the feeling I'm not using it correctly.
	// so we'll just have to invalidate the selection node by node.
//	if (!DoInvalidateNodesRegions(Sel, TRUE, FALSE, FALSE))
//	{
//		End();
//		return;
//	}
	Node* pSelNode = Sel.FindFirst();
	while (pSelNode != NULL)
	{
		if (pSelNode->IsAnObject())
		{
			if (!DoInvalidateNodeRegion((NodeRenderableInk*)pSelNode, TRUE))
			{
				End();
				return;
			}
		}
		pSelNode = Sel.FindNext(pSelNode);
	}

	// we need to insert the controller node at the position of the highest
	// selected node in the z-order, ie last in the selection, so find it.
	Node* pLastNode = NULL;
	while (pNode != NULL)
	{
		pLastNode = pNode;
		pNode = Sel.FindNext(pLastNode);
	}	// loop terminates with pNode == NULL, pLastNode == last-node-in-sel.

	// create a new NodeClipViewController, which we will shortly insert into the tree;
	// note that ALLOC_WITH_FAIL automatically calls FailAndExecute() if things go wrong.
	NodeClipViewController* pClipViewController = NULL;
	ALLOC_WITH_FAIL(pClipViewController, new NodeClipViewController, this);
	BOOL ok = (pClipViewController != NULL);

	// put an action to hide the NodeClipViewController onto the undo action-list,
	// so that if the user presses undo then it will be hidden.
	if (ok)
	{
		HideNodeAction* pUndoHideNodeAction = NULL;
		ActionCode ac = HideNodeAction::Init(this,
											&UndoActions,
											pClipViewController,
											FALSE,		// don't include subtree size
											(Action**)&pUndoHideNodeAction,
											FALSE);		// don't tell subtree when undone
		if (ac == AC_FAIL)
		{
			delete pClipViewController;
			End();
			return;
		}
		else
		{
			// right! we've got our node, we've got our action - lets stick it in the tree
			// (at a position just next to the last node which will go in the group).
			pClipViewController->AttachNode(pLastNode, NEXT);
		}
	}

	// move each item from the selection into our ClipView group,
	// remembering to deselect them as we go.
	// TODO:
	//	sneaky suspicion I should be putting this in a Do fn in UndoableOperation...
	if (ok)
	{
		pNode = Sel.FindNext(pFirstNode);				// the node we're moving now.
		ok = DoMoveNode(pFirstNode, pClipViewController, FIRSTCHILD);
		if (ok)
			((NodeRenderable*)pFirstNode)->DeSelect(FALSE);
	}

	Node* pNextNode		= NULL;							// the next node to move.
	Node* pAnchorNode	= pFirstNode;					// the node we've just moved.
	while (ok && pNode != NULL)
	{
		// get the next node to move.
		pNextNode = Sel.FindNext(pNode);

		// now move the current node next to the anchor and deselect it.
		ok = DoMoveNode(pNode, pAnchorNode, NEXT);
		if (ok)
			((NodeRenderable*)pNode)->DeSelect(FALSE);

		// get the new anchor node and the next node to move.
		pAnchorNode = pNode;
		pNode = pNextNode;
	}

	// try and locate a suitable candidate for a keyhole node.
	Node* pKeyhole = NULL;
	if (ok)
	{
		// now get the keyhole node, which is the first object-node child of the NCVC.
		pKeyhole = pClipViewController->FindFirstChild();
		while (pKeyhole != NULL && !pKeyhole->IsAnObject())
		{
			pKeyhole = pKeyhole->FindNext();
		}

		// doh! can't find _one_ NodeRenderableInk child! I don't know...
		if (pKeyhole == NULL)
		{
			ok = FALSE;
			ERROR2RAW("ClipViewController has no object children");
		}
	}

	// now attach a new NodeClipView, as the immediate NEXT-sibling of the keyhole node.
	NodeClipView* pClipView = NULL;
	if (ok)
	{
		ALLOC_WITH_FAIL(pClipView, new NodeClipView(pKeyhole, NEXT), this);
		ok = (pClipView != NULL);
	}

	// wow - succeeded! now all we need to do is some house-keeping.
	if (ok)
	{
		// tell the new NodeClipViewController that its current keyhole path is now invalid.
		pClipViewController->MarkKeyholeInvalid();

		// invalidate ours and our parent's bounding rects. our bounding rect is almost
		// certainly already invalid, as we haven't done anything to make it valid yet.
		// this is why we invalidate *both* rects - just to cover all cases.
		pClipViewController->InvalidateBoundingRect();
		Node* pParent = pClipViewController->FindParent();
		if (pParent != NULL && pParent->IsBounded())
			((NodeRenderableBounded*)pParent)->InvalidateBoundingRect();

		// select the new NodeClipViewController, but don't draw any blobs yet.
		pClipViewController->Select(FALSE);

		// invalidate the region bounding the selection.
		if (!DoInvalidateNodesRegions(*(GetApplication()->FindSelection()), TRUE, FALSE, FALSE))
		{
			End();
			return;
		}

		// factor out any common attributes.
		if (!DoFactorOutCommonChildAttributes(pClipViewController))
		{
			End();
			return;
		}
		
		// render blobs back on if the current tool doesn't automatically redraw its blobs.
		if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
			pTool->RenderToolBlobs(pSpread, NULL);
	}
	else
	{
		FailAndExecute();
	}

	// end the operation.
 	End();
}
예제 #12
0
void OpFillNudge::Do(OpDescriptor* pOpDesc)
{

	//	Get scaled pixel size 
	FIXED16 ScaledPixelWidth, ScaledPixelHeight;
	GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight) ;
	PixelNudge=ScaledPixelWidth.MakeDouble() ;

	// Determine the nudge factors based on the OpDescriptor used to invoke the nudge operation
	String OpToken = pOpDesc->Token; 

	if		(OpToken == String(OPTOKEN_NUDGEUPPIXEL1))		{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUPPIXEL10))		{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGEDOWNPIXEL1))	{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWNPIXEL10))	{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGELEFTPIXEL1))	{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFTPIXEL10))	{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGERIGHTPIXEL1))	{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHTPIXEL10))	{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGEUP1))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUP5))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUP10))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUPFIFTH))		{ IsPixelNudgeClass = FALSE; }

	else if	(OpToken == String(OPTOKEN_NUDGEDOWN1))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWN5))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWN10))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWNFIFTH))		{ IsPixelNudgeClass = FALSE; }

	else if	(OpToken == String(OPTOKEN_NUDGELEFT1))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFT5))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFT10))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFTFIFTH))		{ IsPixelNudgeClass = FALSE; }

	else if	(OpToken == String(OPTOKEN_NUDGERIGHT1))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHT5))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHT10))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHTFIFTH))	{ IsPixelNudgeClass = FALSE; }

	// Setup the Offset DocCoord to contain the X and Y translation values	
	DocCoord Offset;

	if (IsPixelNudgeClass)
	{
		Offset.x=(INT32)GetXPixelDisplacement();
		Offset.y=(INT32)GetYPixelDisplacement();
	}
	else if (!IsPixelNudgeClass)
	{
		//TypeCast from double to INT32
		Offset.x=(INT32) GetXNudgeDisplacement();
		Offset.y=(INT32) GetYNudgeDisplacement();
	}

	if (AttrFillGeometry::SelectionCount == 0)
	{
			// Nothing to Nudge !!
		FailAndExecute();
		End();
		return;
	}

	FillGeometryNudger* FillNudger = new FillGeometryNudger();

	if (FillNudger == NULL)
	{
		FailAndExecute();
		End();
		return;
	}

	FillNudger->MutateColourFills(NudgeCols);
	FillNudger->SetNudgeDistance(Offset.x, Offset.y);

	AttributeManager::AttributeSelected(NULL, FillNudger);

	LastNudgeType 	= NULL;
	LastNudgeStart 	= DocCoord(0,0);
	LastNudgeEnd 	= DocCoord(0,0);
	LastNudgeEnd2 	= DocCoord(0,0);
	
	End();
}
예제 #13
0
파일: opnudge.cpp 프로젝트: vata/xarino
/********************************************************************************************

>	void OpNudge::Do(OpDescriptor* pOpDesc)

	Author:		Mark_Neves (Xara Group Ltd) <*****@*****.**>
	Created:	7/9/94
	Inputs:		pOpDesc = ptr to the op descriptor
	Outputs:	-
	Returns:	-
	Purpose:	The nudge op's Do() function.
	Errors:		-
	SeeAlso:	-

********************************************************************************************/
void OpNudge::Do(OpDescriptor* pOpDesc)
{
// Determine the nudge factors based on the OpDescriptor used to invoke the nudge operation
    String OpToken = pOpDesc->Token;

//Get scaled pixel size
    FIXED16 ScaledPixelWidth, ScaledPixelHeight;
    GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight) ;
    PixelNudge=ScaledPixelWidth.MakeDouble() ;


    if		(OpToken == String(OPTOKEN_NUDGEUP1))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 1;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUP5))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 5;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUP10))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 10;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUPFIFTH))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 0.2;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN1))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -1;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN5))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -5;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN10))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -10;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNFIFTH))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -0.2;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT1))				{
        X_NudgeFactor = -1;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT5))				{
        X_NudgeFactor = -5;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT10))			{
        X_NudgeFactor = -10;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTFIFTH))			{
        X_NudgeFactor = -0.2;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT1))			{
        X_NudgeFactor = 1;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT5))	 		{
        X_NudgeFactor = 5;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT10))			{
        X_NudgeFactor = 10;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTFIFTH))		{
        X_NudgeFactor = 0.2;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }

    else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL1)) 			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 1;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL10))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 10;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL1))		{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -1;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL10))		{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -10;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL1))		{
        X_NudgeFactor = -1;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL10))		{
        X_NudgeFactor = -10;
        Y_NudgeFactor =	0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL1))		{
        X_NudgeFactor = 1;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL10))		{
        X_NudgeFactor = 10;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }

    else
    {
        ERROR3("Unknown type of nudge");
    }



    Range* Selection = GetApplication()->FindSelection();
    RangeControl TransFlags = Selection->GetRangeControlFlags();
    TransFlags.IgnoreNoneRenderable=TRUE;
    TransFlags.IgnoreInvisibleLayers = TRUE;
    Selection->SetRangeControl(TransFlags);
    SliceHelper::ModifySelectionToContainWholeButtonElements();



// Setup the Offset DocCoord to contain the X and Y translation values
    DocCoord Offset;

    if	(flag)
    {
        (Offset.x) = (INT32) GetXNudgeDisplacement();
        (Offset.y) = (INT32) GetYNudgeDisplacement();
    }
    else if	(!flag)
    {
        (Offset.x) = (INT32)GetXPixelDisplacement();
        (Offset.y) = (INT32)GetYPixelDisplacement();
    }

    // Will the nudge send the selection beyond the spread bounds?
    // If so, fail and return now
    if (!IsNudgeOK(Offset.x,Offset.y))
    {
        SliceHelper::RestoreSelection();
        InformWarning(_R(IDS_NUDGE_OUTOFBOUNDS));
        FailAndExecute();
        End();
        return;
    }

    TransformData 	TransData;

    // Set up the transform data
    TransData.CentreOfTrans.x 	= 0;
    TransData.CentreOfTrans.y 	= 0;
    TransData.StartBlob 	  	= 0;
    TransData.LockAspect 		= TRUE;
    TransData.LeaveCopy  		= FALSE;
    TransData.ScaleLines 		= FALSE;
    TransData.TransFills 		= TRUE;
    TransData.pRange = 0;

    // Call OpTranslateTrans::DoWithParams() with a ptr to the transform data and a ptr to a DocCoord
    // that specs the X and Y offsets of the translation
    OpParam param( &TransData, &Offset );
    DoWithParam( pOpDesc, &param );

    SliceHelper::RestoreSelection();
}
예제 #14
0
/********************************************************************************************

>	void OpMovePathPoint::DoWithParam(OpDescriptor*, OpParam* Params)

	Author:		Peter_Arnold (Xara Group Ltd) <*****@*****.**>
	Created:	1/11/94
	Inputs:		OpDescriptor (unused)
				Params - pointer to the OpParam block (should be a MovePointsParams object)
	Purpose:	An operation to position elements in a path (in an undoable kind of way).
	Errors:		if Params contains a NULL pointer to a path.
				if Params contains a NULL pointer to the changes data.

********************************************************************************************/
void OpMovePathPoint::DoWithParam(OpDescriptor* Fred, OpParam* Params)
{
	// Cast parameter block to our type
	MovePointsParams*	MyParams = (MovePointsParams*)Params;

	ERROR3IF(MyParams == NULL, "Parameter block pointer was NULL");
	ERROR3IF(MyParams->ChangesCount == 0, "No elements to alter!");
	ERROR3IF(MyParams->PathChanges == NULL, "No changes data supplied (NULL pointer passed)");
	ERROR3IF(MyParams->PathToEdit == NULL, "No changes path supplied (NULL pointer passed)");

	// Do the above tests again for the retail build
	if ( (MyParams == NULL) || (MyParams->ChangesCount == 0) || (MyParams->PathChanges == NULL)
																|| (MyParams->PathToEdit == NULL) )
	{
		End();
		return;
	}

	// Get pointers to the path data.
	PathFlags*	Flags = MyParams->PathToEdit->InkPath.GetFlagArray();
	PathVerb*	Verbs = MyParams->PathToEdit->InkPath.GetVerbArray();
	DocCoord*	Coords= MyParams->PathToEdit->InkPath.GetCoordArray();
	INT32		NumElements = MyParams->PathToEdit->InkPath.GetNumCoords();
	BOOL		NotFailed = TRUE;

	// Tell the operation system to start.
	if (!DoStartTransOp(FALSE,MyParams->PathToEdit))
	{
		FailAndExecute();
		End();								
		return;
	}

	for (INT32 Loop = 0; (Loop < MyParams->ChangesCount) && NotFailed; Loop++)
	{
		// Get the index of the point to edit
		INT32 Index = MyParams->PathChanges[Loop].Element;
		DocCoord NewCoord = MyParams->PathChanges[Loop].Coordinate;

		ERROR3IF(((Index >= NumElements) || (Index < 0)), "Invalid index into path (either -ve or off end of path)");
		if ((Index >= NumElements) || (Index < 0))
		{
			FailAndExecute();
			End();								
			return;
		}

		// Find the start and end of the subpath containing index
		INT32 EndOfSubPathIndex = Index;
		MyParams->PathToEdit->InkPath.FindEndElOfSubPath(&EndOfSubPathIndex);
		INT32 StartOfSubPathIndex = EndOfSubPathIndex;
		while ((Verbs[StartOfSubPathIndex] != PT_MOVETO) && (StartOfSubPathIndex > 0))
			StartOfSubPathIndex--;
		BOOL IsSubPathClosed = (Verbs[EndOfSubPathIndex] & PT_CLOSEFIGURE);

		// Move the point to the required coordinate
		NotFailed = DoAlterPathElement(MyParams->PathToEdit, Index, NewCoord, Flags[Index], Verbs[Index]);
	
		// If we have just moved one endpoint of a closed path we will have to move the
		// other point too!
		if ( NotFailed && IsSubPathClosed )
		{
			if (Index == EndOfSubPathIndex)
			{
				NotFailed = DoAlterPathElement(MyParams->PathToEdit, StartOfSubPathIndex, NewCoord,
												Flags[StartOfSubPathIndex], Verbs[StartOfSubPathIndex]);
			}
			if (Index == StartOfSubPathIndex)
			{
				NotFailed = DoAlterPathElement(MyParams->PathToEdit, EndOfSubPathIndex, NewCoord,
													Flags[EndOfSubPathIndex], Verbs[EndOfSubPathIndex]);
			}
		}

		// Now if we have just moved a Bezier control point then we need to clear the
		// smooth and rotate flags from the associated endpoint.  We are lucky in that a 
		// control point's endpoint is at either +1 or -1 elements away from the control point.
		if (NotFailed && ( (Verbs[Index] == PT_BEZIERTO) && !Flags[Index].IsEndPoint) )
		{
			INT32 BezEndpoint = -1;

			if ((Verbs[Index+1] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
				BezEndpoint = Index + 1;
			else
			{
				ERROR3IF(((Verbs[Index-1] & ~PT_CLOSEFIGURE) != PT_BEZIERTO),"Invalid path detected");
				if ((Verbs[Index-1] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
					BezEndpoint = Index - 1;
				else
					NotFailed = FALSE;
			}

			// Having found the endpoint attack its flags.
			if (NotFailed)
			{
				NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,BezEndpoint);
			}

			// And the other control point if this is a closed path
			if (NotFailed && IsSubPathClosed)
			{
			 	if ( (Index == EndOfSubPathIndex-1) || (Index == EndOfSubPathIndex+1) )
					NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,StartOfSubPathIndex);
			 	if ( (Index == StartOfSubPathIndex-1) || (Index == StartOfSubPathIndex+1) )
					NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,EndOfSubPathIndex);
			}

			// Clear them from the moved control point
			if (NotFailed)
			{
				NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,Index);
			}

			// Also clear the flags from the opposite control point
			if (NotFailed)
			{
				INT32 OtherControlPoint = MyParams->PathToEdit->InkPath.FindOppositeControlPoint(Index);
				if (OtherControlPoint != -1)
				{
					NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,OtherControlPoint);
				}
			}
		}
	}

	// Now run along the path and smooth it.
	if (NotFailed)
	{
		DocCoord NewCoord;
		for (INT32 i = 0; (i < NumElements) && NotFailed; i++)
		{
			if (Verbs[i] == PT_BEZIERTO && !(Flags[i].IsEndPoint) && Flags[i].IsSmooth)
			{
				NewCoord = MyParams->PathToEdit->InkPath.SmoothControlPoint(i);
				if (NewCoord != Coords[i])
					NotFailed = DoAlterPathElement(MyParams->PathToEdit, i, NewCoord, Flags[i], Verbs[i]);
			}
		}
	}

	if (NotFailed)
		GetApplication()->FindSelection()->UpdateBounds();

	if (!NotFailed)
	{
		InformError();
		FailAndExecute();
	}

	End();
}
예제 #15
0
/********************************************************************************************
>	void OpBaseConvertPathSegment::Do(OpDescriptor*)

	Author:		Peter_Arnold (Xara Group Ltd) <*****@*****.**>
	Created:	16/8/95
	Inputs:		OpDescriptor (unused)
	Purpose:	Performs the common SelRange scanning part of converting path segments.  Calls
				the ProcessSegment function in derived classes to do the actual processing
	Errors:		-
	SeeAlso:	-
********************************************************************************************/
void OpBaseConvertPathSegment::Do(OpDescriptor*)
{   
#ifndef STANDALONE

	// Obtain the current selections and the first node in the selection
	SelRange* Selected = GetApplication()->FindSelection();
	BOOL ok = (Selected != NULL);

	// Start the op
	BeginSlowJob();
	if (ok)
		ok = DoStartSelOp(TRUE,TRUE);

	// Check with the selrange it is ok to run this op
	ObjChangeFlags cFlags;
	ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
	if (ok)
	{
		if (!Selected->AllowOp(&ObjChange))
		{
			EndSlowJob();
			FailAndExecute();
			End();
			return;
		}
	}

	Node* pNode = Selected->FindFirst();
	NodePath* ThisPath = NULL;

	while (ok && (pNode != NULL))
	{	// we're only interested in NodePaths which have selected points
		BOOL DoThisNode = pNode->IsNodePath();
		if (DoThisNode)
			DoThisNode = (((NodePath*)pNode)->InkPath.IsSubSelection());
		if (DoThisNode)
			DoThisNode = (((NodePath*)pNode)->IsPathAllowable());

		if 	( DoThisNode )
		{
			// for convenience, cast the pointer to a pointer to a NodePath
			ThisPath = (NodePath*)pNode;

			// First get pointers to the arrays
			PathVerb* Verbs = NULL;
			PathFlags* Flags = NULL;
			DocCoord* Coords = NULL;
			ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
			INT32 NumCoords = ThisPath->InkPath.GetNumCoords();
			BOOL PrevSelected = FALSE;
			INT32 PrevPos = 0;

			// Set the NeedToRender flags
			INT32		loop;
			for (loop = 0; loop < NumCoords; loop++)
			{
				if (Flags[loop].IsEndPoint && Flags[loop].IsSelected)
					Flags[loop].NeedToRender = TRUE;
				else
					Flags[loop].NeedToRender = FALSE;
			}

			// Force a re-draw of the place where the path used to be
			if (ok)
				ok = (RecalcBoundsAction::DoRecalc(this, &UndoActions, ThisPath, TRUE) != AC_FAIL);

			// loop through the points
			for (loop = 0; loop<NumCoords; loop++)
			{
				if (Flags[loop].IsEndPoint)
				{	// its an endpoint
					if (Flags[loop].IsSelected)
					{	// which is selected
						if (PrevSelected && ((Verbs[loop] & ~PT_CLOSEFIGURE) == GetProcessPathType()) )
						{	//  and the previous was selected and it's a processable segment
							if (ok)
								ok = ProcessSegment(ThisPath, &loop, PrevPos);
							// Recache array pointers
							ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
							NumCoords = ThisPath->InkPath.GetNumCoords();
							Flags[loop].NeedToRender = TRUE;
						}
						PrevSelected = TRUE;
						PrevPos = loop;
					}
					else
						PrevSelected = FALSE;
				}
			}

			// Having finished processing this path go round and smooth it.
			DocCoord NewCoord;
			for (loop = 0; (ok && (loop < NumCoords)); loop++)
			{
				if (Verbs[loop] == PT_BEZIERTO && !(Flags[loop].IsEndPoint) && Flags[loop].IsSmooth)
				{
					NewCoord = ThisPath->InkPath.SmoothControlPoint(loop);
					if (ok && (NewCoord != Coords[loop]))
					{
						ok = DoAlterPathElement(ThisPath, loop, NewCoord, Flags[loop], Verbs[loop], FALSE);
						ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
					}
				}
			}

			ThisPath->InvalidateBoundingRect();

			// Force a redraw of the place where the path is now.
			if (ok)
				ok = (RecordBoundsAction::DoRecord(this, &UndoActions, ThisPath, TRUE) != AC_FAIL);
		}
		pNode = Selected->FindNext(pNode);
	}

	if (ok)
	{
		ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
		if (!UpdateChangedNodes(&ObjChange))
		{
			FailAndExecute();
			End();
			return;
		}
	}

	EndSlowJob();

	if (!ok)
	{	
		FailAndExecute();
		InformError();
	}

#endif

	End();
}
예제 #16
0
/********************************************************************************************

>	virtual void OpRemoveClipView::Do(OpDescriptor* pOpDesc, OpParam* pOpParam)

	Author:		Karim_MacDonald (Xara Group Ltd) <*****@*****.**>
	Created:	01 February 2000
	Inputs:		
	Outputs:	
	Returns:	
	Purpose:	
	Errors:		
	See also:	

********************************************************************************************/
void OpRemoveClipView::Do(OpDescriptor* pOpDesc)
{
	// try to record the selection state.
	if (DoStartSelOp(FALSE, FALSE))
	{
		// obtain the current selection.
		Range Sel(*(GetApplication()->FindSelection()));
		RangeControl rc = Sel.GetRangeControlFlags();
		rc.PromoteToParent = TRUE;
		Sel.Range::SetRangeControl(rc);

		// check that the selection is one lone NodeClipViewController.
		BOOL ok = FALSE;
		Node* pFirstNode = Sel.FindFirst();
		if (pFirstNode != NULL && pFirstNode->IsANodeClipViewController())
			if (Sel.FindNext(pFirstNode) == NULL)
				ok = TRUE;

		// remove tool blobs and localise any common attributes.
		Tool* pTool = NULL;
		Spread* pSpread = NULL;
		if (ok)
		{
			// render blobs off for tools which don't automatically redraw their blobs.
			pTool = Tool::GetCurrent();
			pSpread = Document::GetSelectedSpread();
			if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
				pTool->RenderToolBlobs(pSpread, NULL);

			// invalidate the region of screen covering the selection.
			DoInvalidateNodesRegions(*(GetApplication()->FindSelection()), TRUE, FALSE, FALSE);

			// localise any common attributes.
			ok = DoLocaliseCommonAttributes((NodeGroup*)pFirstNode);
		}

		// deselect and hide the NCVC.
		NodeHidden* pHiddenNode = NULL;
		if (ok)
		{
			// deselect the NCVC, but don't ask for its blobs to be redrawn.
			((NodeRenderable*)pFirstNode)->DeSelect(FALSE);
			ERROR3IF(pFirstNode->IsSelected(), "Deselect failed to deselect current node");

			// hide the NodeClipViewController.
			ok = DoHideNode(pFirstNode, FALSE, &pHiddenNode, FALSE);
			ERROR3IF(!ok, "Unable to hide NodeClipViewController!");
		}

		// hide the NCVC's NodeClipView node.
		if (ok)
		{
			NodeHidden* pDummy;
			NodeClipView* pClipView = ((NodeClipViewController*)pFirstNode)->GetClipView();
			ok = DoHideNode(pClipView, FALSE, &pDummy, FALSE);
			ERROR3IF(!ok, "Unable to hide NodeClipView!");
		}

		// show and select the NCVC's children.
		// a straight loop-over should do, as it should skip the now-hidden NodeClipView.
		if (ok)
		{
			// get the first child node (the NCVC's keyhole node).
			Node* pChildNode = pFirstNode->FindFirstChild();
			if (pChildNode == NULL)
				TRACEUSER( "Karim", _T("OpRemoveClipView::Do(); Found an empty NodeClipViewController!\n"));

			// move and select the child nodes in turn.
			Node* pAnchorNode = pHiddenNode;
			Node* pNextChildNode = NULL;
			while (pChildNode != NULL)
			{
				// get the next child-node.
				pNextChildNode = pChildNode->FindNext();

				// if the node is not a NodeHidden then move the node to its new location in 
				// the tree - there is no need to render the node.
				if (!pChildNode->IsAnAttribute() && !pChildNode->IsNodeHidden())
				{
					// move pChildNode to be the next-sibling of the anchor node.
					ok = DoMoveNode(pChildNode, pAnchorNode, NEXT);
					if (!ok)
						break;

					pAnchorNode = pChildNode;
				}

				// select the child node and invalidate its bounding rect,
				// but don't bother redrawing its blobs yet.
				if (pChildNode->IsAnObject())
				{
					((NodeRenderableInk*)pChildNode)->Select(FALSE);
					((NodeRenderableInk*)pChildNode)->InvalidateBoundingRect();
					ok = this->DoInvalidateNodeRegion(((NodeRenderableInk*)pChildNode), TRUE);
					if (!ok)
						break;
				}

				pChildNode = pNextChildNode;
			}
		}

		// render blobs back on for tools which don't automatically redraw their blobs.
		if (ok)
		{
			if (pSpread != NULL && pTool != NULL && !pTool->AreToolBlobsRenderedOnSelection())
				pTool->RenderToolBlobs(pSpread, NULL);
		}

		// fail gracefully if things went pear-shaped.
		else
			FailAndExecute();
	}

	End();
}			
예제 #17
0
/********************************************************************************************

>	void OpMoveToLayer::Do(OpDescriptor*)

	Author:		Simon_Knight (Xara Group Ltd) <*****@*****.**> 
	Created:	3/5/00
	Purpose:	This takes the selection and moves it to the active layer. This is a more
				powerful operation than the move forward/backward a layer

********************************************************************************************/
void OpMoveToLayer::Do(OpDescriptor*)
{
	if (DoStartSelOp(FALSE,TRUE))
	{
		// get the selection
		Range Sel(*(GetApplication()->FindSelection()));

		// set the range flags so it includes shadow and bevel manager nodes
		RangeControl rg = Sel.GetRangeControlFlags();
		rg.PromoteToParent = TRUE;
		Sel.Range::SetRangeControl(rg);

		// Prepare an ObjChangeParam so we can mark which nodes will allow this op to happen to them
		ObjChangeFlags cFlags;
		cFlags.MoveNode = TRUE;
		ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);

		// add items directly after the layer node as its first child
		Node * pTail = (Node *) (Document::GetCurrent()->GetInsertionPosition());
		AttachNodeDirection TailAttachDirection = PREV;
		Spread* pSpread = Document::GetSelectedSpread();

		if (!pTail)
		{
			if (pSpread)
			{
				pTail = pSpread->FindActiveLayer();
				// AttachNodeDirection TailAttachDirection = LASTCHILD; <--- AMB removed this and inserted the next line 2006-04-10 presuming bug
				TailAttachDirection = LASTCHILD;
			}
			else
			{
				FailAndExecute();
				End();
				return; // nowhere to put the nodes
			}
		}


		// Mark nodes that will allow this to happen, and error if no nodes will let it happen
		if (!Sel.AllowOp(&ObjChange))
		{
			FailAndExecute();
			End();
			return; // op not allowed
		}

		// get a list from which to move the nodes (fixes job #10781 - the re-selection of 
		// moved nodes caused an infinite loop)

		List* pNodeList = Sel.MakeListOfNodes(FALSE);
		NodeListItem* CurItem = (NodeListItem*)(pNodeList->GetHead());
		while (CurItem)
		{
			Node* pNode = CurItem->pNode;

			// Make sure the current owner Layer is told about the changes
			// and given the chance to release any cached info it may be
			// holding about the selected object
			// (I know that the original position coincides with the destination position
			//  but this is hte simplest way to get the original parent layer uncached
			//  and to get a record in the undo history so that the layer cacheing will
			//  be dealt with properly during gundo/redo)
			DoInvalidateNodeRegion((NodeRenderableBounded*) pNode, TRUE, FALSE);

			// localise attribs for this node
			DoLocaliseForAttrChange((NodeRenderableInk*) pNode, (AttrTypeSet *)NULL, (ObjectSet*) NULL);
			DoMoveNode(pNode, pTail, TailAttachDirection);
			// factor out common attribs
			if (pNode->IsCompound())
				DoFactorOutCommonChildAttributes((NodeRenderableInk*) pNode);
			else
				DoFactorOutAfterAttrChange((NodeRenderableInk*) pNode, (AttrTypeSet *)NULL);

			// make the nodes region be redrawn
			DoInvalidateNodeRegion((NodeRenderableBounded*) pNode, TRUE, FALSE);

			CurItem = (NodeListItem*)(pNodeList->GetNext(CurItem));
		}
		// delete the the list objects 
		pNodeList->DeleteAll();
		delete pNodeList;

		// the selection will have changed - after all we just deleted it
		BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED));
		GetApplication()->UpdateSelection();

		ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
		UpdateChangedNodes(&ObjChange);
		// end the op
		End();

		// update the bars
		DialogBarOp::SetSystemStateChanged();
		DialogBarOp::UpdateStateOfAllBars(); 
	}
	else
	{
		// give up and go home
		FailAndExecute();
		End();
	}
}
예제 #18
0
파일: makebmp.cpp 프로젝트: vata/xarino
/********************************************************************************************

>	void OpConvertToBitmap::Do(OpDescriptor*)

	Author:		Will_Cowling (Xara Group Ltd) <*****@*****.**>
	Created:	11/6/96
	Inputs:		-
	Purpose:	Convert the selection into a bitmap
	Errors:		-
	SeeAlso:	-

********************************************************************************************/
void OpConvertToBitmap::Do(OpDescriptor*)
{   
	// We want to include bevel/contour/shadow controller nodes in our bitmap-copy
	// deliberations, so set PromoteToParent on a copy of the app's SelRange.
	SelRange Sel(*(GetApplication()->FindSelection()));
	RangeControl rg = Sel.GetRangeControlFlags();
	rg.PromoteToParent = TRUE;
	Sel.Range::SetRangeControl(rg);

	// Find the first node which is selected 
	Node* CurrentNode = Sel.FindFirst(); 
	
	ERROR3IF(CurrentNode == NULL, "Called ConvertToBitmap with no nodes selected"); 
	
	// In the retail build it is best to do nothing if we find there are no selected nodes 
	if (CurrentNode != NULL) // No nodes selected so End
	{   
		// We need to invalidate the region
		if (!DoInvalidateNodesRegions(Sel, TRUE))
			goto EndOperation; 

		if (!DoStartSelOp(FALSE,FALSE))  // Try to record the selection state , don't
			goto EndOperation;  		 // render the blobs though 
             
        // Create a special Bitmap filter, that creates a bitmap
        // and puts it in the tree   
		MakeBitmapFilter* pBitmapFilter = new MakeBitmapFilter();
		if (pBitmapFilter == NULL)
		{
			FailAndExecute();
			goto EndOperation;  
		}

		KernelBitmap* pBitmapToCreate = NULL;

		if (!pBitmapFilter->DoCreateBitmap(this, Document::GetSelected(), &pBitmapToCreate))
		{
			delete pBitmapFilter;
			FailAndExecute();
			goto EndOperation;  
		}

		if (!pBitmapFilter->InsertBitmapIntoDocument(this, pBitmapToCreate, Document::GetSelected()))
		{
			delete pBitmapToCreate;
			delete pBitmapFilter;
			FailAndExecute();
			goto EndOperation;  
		}

		delete pBitmapFilter;

		if (!DoInvalidateNodesRegions(*(GetApplication()->FindSelection()), TRUE))
		{
			// We need to invalidate the region
			FailAndExecute();
			goto EndOperation; 
		} 
	}                   

 	EndOperation:

	SelRange* pRng = GetApplication()->FindSelection();

	End();
}			
예제 #19
0
void OpAlign::DoWithParam(OpDescriptor* pOp, OpParam* pAlignParam)
{
	// DMc alterations so that this works with compound nodes	
	SelRange   Selection(*(GetApplication()->FindSelection()));

	RangeControl rg = Selection.GetRangeControlFlags();
	rg.PromoteToParent = TRUE;
	Selection.Range::SetRangeControl(rg);

	DocRect		SelRect   = Selection.GetBoundingRect();
	DocRect		TargetRect;
	TargetRect.MakeEmpty();
	INT32        NumObjs   = Selection.Count();
	AlignParam* pAlign    =(AlignParam*)pAlignParam;

	BOOL moved=FALSE;					// set to TRUE if any object is moved
	BeginSlowJob(-1,FALSE);
	BOOL OK=DoStartTransOp(FALSE);

	// find parent spread of first object in selection
	Node*   pFirstNode=NULL;
	Spread* pSpread   =NULL;
	if (OK)
	{
		pFirstNode=Selection.FindFirst();
		if (pFirstNode!=NULL)
			pSpread=pFirstNode->FindParentSpread();
		OK=(pSpread!=NULL);
		if (!OK)
			ERROR2RAW("OpAlign::DoWithParam() - could not find parent spread");
	}

	// Find the size of the target rectangle
	if (pAlign->target==ToSelection)
		TargetRect=SelRect;
	else
	{
		Page* pPage=pSpread->FindFirstPageInSpread();
		while (pPage)
		{
			DocRect PageRect=pPage->GetPageRect();
			if (pAlign->target==ToSpread || SelRect.IsIntersectedWith(PageRect))
				TargetRect=TargetRect.Union(PageRect);
			pPage=pPage->FindNextPage();
		}
	}

	// allocate all dynamic memory required
	Node**	 pObj=NULL;
	ObjInfo* x   =NULL;
	ObjInfo* y   =NULL;
	INT32*    dx  =NULL;
	INT32*    dy  =NULL;
	if (OK)			ALLOC_WITH_FAIL(pObj,(Node**)  CCMalloc(NumObjs*sizeof(Node*)),  this);
	if (pObj!=NULL)	ALLOC_WITH_FAIL(x,   (ObjInfo*)CCMalloc(NumObjs*sizeof(ObjInfo)),this);
	if (   x!=NULL) ALLOC_WITH_FAIL(y,   (ObjInfo*)CCMalloc(NumObjs*sizeof(ObjInfo)),this);
	if (   y!=NULL) ALLOC_WITH_FAIL(dx,  (INT32*)   CCMalloc(NumObjs*sizeof(INT32)),   this);
	if (  dx!=NULL) ALLOC_WITH_FAIL(dy,  (INT32*)   CCMalloc(NumObjs*sizeof(INT32)),   this);
	OK=(dy!=NULL);

	// if memory claimed OK and target rect not empty proceed with op
	// (ie. do nothing if 'within page(s)' when no object on a page)
	DocRect EmptyRect;
	if (OK && TargetRect!=EmptyRect)
	{
		// create an array of pointers to objects (nodes) to be affected
		Node* pNode=Selection.FindFirst();
		INT32  i=0;
		while (pNode!=NULL)
		{
			if (pNode->IsBounded() && !((NodeRenderableBounded*)pNode)->GetBoundingRect(TRUE).IsEmpty())
				pObj[i++]=pNode;
			pNode=Selection.FindNext(pNode);
		}
		NumObjs=i;

		// cache x & y info in separate arrays so they can be sorted separately
		XLONG SumObjWidths =0;
		XLONG SumObjHeights=0;
		for (i=0; i<NumObjs; i++)
		{
			DocRect ObjRect=((NodeRenderableBounded*)pObj[i])->GetBoundingRect();
			x[i].i=i;
			x[i].lo=ObjRect.lo.x;
			x[i].hi=ObjRect.hi.x;
			SumObjWidths+=ObjRect.hi.x-ObjRect.lo.x;
			y[i].i=i;
			y[i].lo=ObjRect.lo.y;
			y[i].hi=ObjRect.hi.y;
			SumObjHeights+=ObjRect.hi.y-ObjRect.lo.y;
		}

		// for each object, calculate the x and y displacements independently
		AlignOneAxis(pAlign->h,NumObjs,SumObjWidths, TargetRect.lo.x,TargetRect.hi.x,x,dx);
		AlignOneAxis(pAlign->v,NumObjs,SumObjHeights,TargetRect.lo.y,TargetRect.hi.y,y,dy);

		// apply the x and y displacements simultaneously to each object
		for (i=0; i<NumObjs; i++)
			if (dx[i]!=0 || dy[i]!=0)
			{
				moved=TRUE;
				Trans2DMatrix* pMatrix=new Trans2DMatrix(dx[i],dy[i]);
				DoTransformNode((NodeRenderableInk*)pObj[i],pMatrix);
			}
	}

	// free up any memory which was allocated
	CCFree(dx);
	CCFree(dy);
	CCFree(x);
	CCFree(y);
	CCFree(pObj);

	if (moved)
	{
		Document::GetSelected()->ForceRedraw(pSpread, TargetRect);
		GetApplication()->UpdateSelection();
	}
	else
		FailAndExecute();
	End();
	EndSlowJob();
}
예제 #20
0
void OpReversePath::Do (OpDescriptor*)
{
	// Obtain the current selections and the first node in the selection
	SelRange* Selected = GetApplication()->FindSelection();
	BOOL ok = (Selected != NULL);

	// Start the op
	BeginSlowJob();
	if (ok)
		ok = DoStartSelOp(TRUE,TRUE);

	// Check with the selrange it is ok to run this op
	ObjChangeFlags cFlags;
	ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
	if (ok)
	{
		if (!Selected->AllowOp(&ObjChange))
		{
			EndSlowJob();
			FailAndExecute();
			End();
			return;
		}
	}

	Node* pNode = Selected->FindFirst();
	NodePath* ThisPath = NULL;

	//Document* pDocument = GetWorkingDoc();

	while (ok && (pNode != NULL))
	{	// we're only interested in NodePaths which have selected points
		BOOL DoThisNode = pNode->IsNodePath();
		//if (DoThisNode)
		//	DoThisNode = (((NodePath*)pNode)->InkPath.IsSubSelection());
		if (DoThisNode)
			DoThisNode = (((NodePath*)pNode)->IsPathAllowable());

		if 	( DoThisNode )
		{
			// for convenience, cast the pointer to a pointer to a NodePath
			ThisPath = (NodePath*)pNode;

			// First get pointers to the arrays
			PathVerb* Verbs = NULL;
			PathFlags* Flags = NULL;
			DocCoord* Coords = NULL;
			ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
			INT32 NumCoords = ThisPath->InkPath.GetNumCoords();
//			BOOL PrevSelected = FALSE;
//			INT32 PrevPos = 0;

			ObjChangeFlags cFlags;
			cFlags.TransformNode = TRUE;
			ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,ThisPath,this);
			if (!ThisPath->AllowOp(&ObjChange, TRUE))
			{
				return;
			}

			// Set the NeedToRender flags
			for (INT32 loop = 0; loop < NumCoords; loop++)
			{
				if (Flags[loop].IsEndPoint && Flags[loop].IsSelected)
					Flags[loop].NeedToRender = TRUE;
				else
					Flags[loop].NeedToRender = FALSE;
			}

			// Force a re-draw of the place where the path used to be
			if (ok)
				ok = (RecalcBoundsAction::DoRecalc(this, &UndoActions, ThisPath, TRUE) != AC_FAIL);

			DoReversePath (ThisPath);

			// Force a redraw of the place where the path is now.
			if (ok)
				ok = (RecordBoundsAction::DoRecord(this, &UndoActions, ThisPath, TRUE) != AC_FAIL);
		}
		pNode = Selected->FindNext(pNode);
	}

	if (ok)
	{
		ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
		if (!UpdateChangedNodes(&ObjChange))
		{
			FailAndExecute();
			End();
			return;
		}
	}

	EndSlowJob();

	if (!ok)
	{	
		FailAndExecute();
		InformError();
	}

	End();
}
예제 #21
0
/********************************************************************************************
>	void OpMakeShapes::Do(OpDescriptor*)

	Author:		Simon_Maneggio (Xara Group Ltd) <*****@*****.**>
	Created:	29/04/94
	Inputs:		OpDescriptor (unused)
	Outputs:	-
	Returns:	-
	Purpose:	Performs the MakeShapes operation. 
********************************************************************************************/
void OpMakeShapes::Do(OpDescriptor*)
{   
	// Obtain the current selections 
	Range Selection(*GetApplication()->FindSelection());
	RangeControl rg = Selection.GetRangeControlFlags();
	rg.PromoteToParent = TRUE;
	Selection.Range::SetRangeControl(rg);

	// change the selection flags

	Node* CurrentNode = Selection.FindFirst(); 
	BOOL Success = TRUE;		
	
	ERROR3IF(CurrentNode == NULL, "Make shapes called with no nodes selected"); 
	
	if (CurrentNode != NULL) // No nodes selected so End
	{   
		// We need to invalidate the region
		if (Success)
			Success = DoInvalidateNodesRegions(Selection, TRUE, FALSE, FALSE, FALSE);	// Don't recache
                    
		// Try to record the selection state, don't render the blobs though 
		if (Success)
			Success = DoStartSelOp(FALSE,FALSE);								   

		// The DoMakeShapes function does all the work
		while (Success && CurrentNode!=NULL)
		{
			Node* Next = Selection.FindNext(CurrentNode);

// BODGE - since the group is selected and won't be replaced by anything else, no need to reselect it
// this fixes a bug where make shapes on grouped text stories/molds/blends don't leave the parent group
// selected but selects the objects inside!
			BOOL reselect = !IS_A(CurrentNode,NodeGroup) && !IS_A(CurrentNode,NodeBlend);
//			BOOL ok = TRUE;
		

			ObjChangeFlags cFlags(TRUE);
			ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,NULL);
			if (CurrentNode->AllowOp(&ObjChange))
			{
				BecomeA BecomeAPath(BECOMEA_REPLACE,CC_RUNTIME_CLASS(NodePath), this, reselect);
				BecomeAPath.SetResultsStayInPlace(TRUE);
				Success = CurrentNode->DoBecomeA(&BecomeAPath);
			}
	
			CurrentNode = Next;
		}

		// We need to invalidate the region again for the new positions
		GetApplication()->FindSelection()->Update();
		if (Success)
			Success = DoInvalidateNodesRegions(*GetApplication()->FindSelection(), TRUE);
	}                   

	if (!Success)
	{
		InformError();
		FailAndExecute();
	}

 	End(); 
}