#include "camtypes.h"
#include "ngcore.h"
#include "ngitem.h"
#include "ngprop.h"
#include "ngscan.h"
#include "ngsentry.h"
#include "extender.h"
#include <algorithm>
#include "objchge.h"
#include "layer.h"
#include "keypress.h"
#include "nodebmp.h"
#include "nodershp.h"
#include "ophist.h"
Go to the source code of this file.
Functions | |
DECLARE_SOURCE ("$Revision: 1282 $") | |
static BOOL | ApplyNameToNode (const StringBase &strName, Node *pNode, UndoableOperation *pOp, INT32 BarNo) |
Helper function to create a new Wix object name attribute and attach it to the given node in an undoable way. | |
static NodeSetProperty * | ApplyPropToNode (const StringBase &strName, Node *pNode, NodeSetProperty *pCopyPropNode, UndoableOperation *pOp) |
Helper function to create a new NodeSetProperty, with default properties, and attach it to the given node in an undoable way. | |
Variables | |
static char BASED_CODE | THIS_FILE [] = __FILE__ |
|
Helper function to create a new Wix object name attribute and attach it to the given node in an undoable way.
Definition at line 665 of file ngscan.cpp. 00666 { 00667 // Try to create a new object name attribute to apply to the target node. 00668 TemplateAttribute* pta; 00669 String_256 BarName = ""; 00670 00671 if (BarNo >= 0) 00672 { 00673 BarName.MakeMsg(_R(IDS_BARNAME), BarNo+1); 00674 } 00675 00676 ALLOC_WITH_FAIL(pta, (new TemplateAttribute(TA_NAME, BarNo >= 0 ? BarName : _T("") , strName)), pOp); 00677 ERRORIF(pta == 0, _R(IDE_NOMORE_MEMORY), FALSE); 00678 00679 // If the target node is an object, check that the attribute type is required by it, 00680 // and make a note for the attribute manager of the object being applied to. 00681 if (pNode->IsAnObject()) 00682 { 00683 NodeRenderableInk* pObj = (NodeRenderableInk*) pNode; 00684 if (!pObj->RequiresAttrib(pta)) 00685 { 00686 // (No objects reject Wix attributes, AFAIK) 00687 TRACEUSER( "JustinF", _T("ApplyNameToNode: %s failed RequireAttrib at 0x%p\n"), 00688 pObj->GetRuntimeClass()->m_lpszClassName, pObj); 00689 delete pta; 00690 return FALSE; 00691 } 00692 00693 AttributeManager::pLastNodeAppliedTo = pObj; 00694 } 00695 00696 // Attach the new attribute and make a note for the AttributeManager. 00697 pta->AttachNode(pNode, FIRSTCHILD); 00698 00699 /* *** DUBIOUS TEXT BODGE *** 00700 // If we are applying the attribute to a node which discards its attribute children 00701 // (like the caret) then we should not generate any undo for the operation. 00702 if (m_pNode->DiscardsAttributeChildren()) SucceedAndDiscard(); 00703 00704 // JCF: this is a bodge for the text tool, copied from 00705 // OpApplyAttribToSelected::ApplyToSelection:- 00706 // 00707 // "EOL nodes can now have attributes, but the last EOL cannot 00708 // be selected by the user, causing the text tool to show <multiple> 00709 // when it shouldn't really. So if the last node in the range is 00710 // the node before the last EOL in a text story then we apply the 00711 // attribute to the EOL too." 00712 Node* pLastNode = selRange.FindLast(); 00713 if (pLastNode != 0 && pLastNode->IsAVisibleTextNode()) 00714 { 00715 // "Alternative approach to fix other EOLNode problems that have appeared, ie. 00716 // (Bugs 5371 & 5372). If the AbstractTextChar following the last selected node 00717 // is an EOLNode then apply to it too." 00718 AbstractTextChar* pNextChr = 00719 (AbstractTextChar*) pLastNode->FindNext(CC_RUNTIME_CLASS(AbstractTextChar)); 00720 if (pNextChr != 0 && pNextChr->IsAnEOLNode() && !DoApply(pNextChr, pAttrib, pSets)) 00721 { 00722 delete pAttrib; 00723 FailAndExecute(); 00724 End(); 00725 return; 00726 } 00727 } 00728 */ 00729 // Create an action to hide the new attribute when we Undo. 00730 HideNodeAction* pHideAct; 00731 if (AC_FAIL == HideNodeAction::Init(pOp, pOp->GetUndoActions(), 00732 pta, TRUE, (Action**) &pHideAct)) 00733 { 00734 pta->CascadeDelete(); 00735 delete pta; 00736 return FALSE; 00737 } 00738 00739 // Success. 00740 return TRUE; 00741 }
|
|
Helper function to create a new NodeSetProperty, with default properties, and attach it to the given node in an undoable way.
Definition at line 885 of file ngscan.cpp. 00888 { 00889 // If the set sentinel already has a NodeSetProperty for the given name then 00890 // do nothing. 00891 NodeSetProperty* psp = 00892 Document::GetSelected()->GetSetSentinel()->FindPropertyNode(strName); 00893 if (psp != 0) return psp; 00894 00895 // Try to create a new property node to 'apply' to the sentinel. 00896 ALLOC_WITH_FAIL(psp, (new NodeSetProperty(strName)), pOp); 00897 ERRORIF(psp == 0, _R(IDE_NOMORE_MEMORY), 0); 00898 00899 // Try to make a bunch of default or copied properties for it. 00900 NodeSetProperty * fOK=psp; // we use this as a boolean flag 00901 ALLOC_WITH_FAIL(psp, 00902 ((pCopyPropNode != 0 ? psp->CopyProperties(pCopyPropNode) 00903 : psp->CreateDefaults())?psp:NULL), 00904 pOp); 00905 if (!fOK) 00906 { 00907 delete psp; 00908 ERROR1RAW(_R(IDE_NOMORE_MEMORY)); 00909 return 0; 00910 } 00911 00912 // Attach the new property and create an action to hide it when we Undo. 00913 HideNodeAction* pHideAct; 00914 psp->AttachNode(pNode, LASTCHILD); 00915 if (AC_FAIL == HideNodeAction::Init(pOp, pOp->GetUndoActions(), 00916 psp, TRUE, (Action**) &pHideAct)) 00917 { 00918 psp->CascadeDelete(); 00919 delete psp; 00920 return 0; 00921 } 00922 00923 // Success. 00924 return psp; 00925 }
|
|
|
|
Definition at line 144 of file ngscan.cpp. |