#include <ngsetop.h>
Inheritance diagram for OpRenameAll:
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpRenameAll) | |
virtual void | DoWithParam (OpDescriptor *, OpParam *) |
Performs the OPTOKEN_RENAME_ALL operation. | |
virtual BOOL | MayChangeNodeBounds () const |
Definition at line 300 of file ngsetop.h.
|
|
|
Performs the OPTOKEN_RENAME_ALL operation.
Reimplemented from Operation. Definition at line 547 of file ngsetop.cpp. 00548 { 00549 ERROR3IF(pParam->Param1 == 0, "OpRenameAll::DoWithParam: null argument"); 00550 const StringBase& strNewName = *((const StringBase*) (void *) pParam->Param1); 00551 Spread * pSpread = Document::GetSelectedSpread(); 00552 if (pSpread == NULL) 00553 { 00554 FailAndExecute(); 00555 End(); 00556 return; 00557 } 00558 00559 // If we are only renaming one item then preserve it's properties, otherwise 00560 // if we are renaming lots to be the same name then make default properties. 00561 NodeSetProperty* pCopyPropNode = 0; 00562 NamedExportProp* pNewExport = 0; 00563 // Node * pNodeSetSentinel = GetWorkingDoc()->GetSetSentinel(); // the sentinel 00564 00565 INT32 nNames; 00566 NameGallery::Instance()->GetHighlightCount(0, &nNames); 00567 if (nNames == 1) 00568 { 00569 // Find the NodeSetProperty associated with the first highlighted item 00570 // in the 'Used Names' display group. 00571 String_256 str; 00572 NameGallery::Instance()->GetUsedNames()->FindNextSelectedItem()->GetNameText(&str); 00573 pCopyPropNode = GetWorkingDoc()->GetSetSentinel()->FindPropertyNode(str); 00574 if (pCopyPropNode != 0) 00575 { 00576 // Try to create an export property for the new name now so we can compare 00577 // it with that of the old name and work out what can be preserved. 00578 ALLOC_WITH_FAIL(pNewExport, 00579 (NamedExportProp*) SGNameProp::CreateDefault(strNewName, 00580 NamedExportProp::nIndex), 00581 this); 00582 if (pNewExport == 0) 00583 { 00584 FailAndExecute(); 00585 End(); 00586 return; 00587 } 00588 00589 // Look up the old properties. 00590 NamedExportProp* pOldExport = 00591 (NamedExportProp*) pCopyPropNode->GetProperty(NamedExportProp::nIndex); 00592 ERROR3IF(pOldExport == 0, "OpRenameAll::DoWithParam: no export property"); 00593 00594 // Preserve the filter, options and location of the old property. 00595 pNewExport->SetFilter(pOldExport->GetFilter()); 00596 pNewExport->SetOptions(pOldExport->GetOptions()); 00597 00598 String_256 strPath(pOldExport->GetPath().GetLocation(TRUE)); 00599 strPath += pNewExport->GetPath().GetFileName(TRUE); 00600 pNewExport->SetPath(PathName(strPath)); 00601 } 00602 } 00603 00604 SGNameItem* pNameGalleryItem = (SGNameItem*) NameGallery::Instance()->GetUsedNames()->GetChild(); 00605 // SGNameItem* pRenameMe = NULL; 00606 while (pNameGalleryItem) 00607 { 00608 if (pNameGalleryItem->IsSelected()) 00609 { 00610 String_256 str; 00611 pNameGalleryItem->GetNameText(&str); 00612 // remove any references to str (the old set name) 00613 // and replace them (undoably of corse) with strNewName (sjk) 00614 RenameSetInstance(str, *((const String_256 *) (void *) pParam->Param1), this, pSpread); 00615 } 00616 00617 pNameGalleryItem = (SGNameItem *) pNameGalleryItem->GetNext(); 00618 } 00619 00620 00621 // Now perform the actual renaming. 00622 AllowOpScan aosDoc(this, &theSelectedDocument); 00623 00624 BOOL ok = aosDoc.Scan(); 00625 00626 if (ok) 00627 ok = ApplyPropScan(this, strNewName, pCopyPropNode).Scan(); 00628 00629 if (ok) 00630 ok = HidePropScan(this).Scan(); 00631 00632 // if (ok) 00633 // ok = HideScan(this, &theSelectedDocument).Scan(); 00634 00635 // update the locations of everything now as we dont want any extends going on 00636 NameGallery * pNameGallery = NameGallery::Instance(); 00637 pNameGallery->FastUpdateNamedSetSizes(); // make sure we are using the most up-to-date data 00638 00639 if (ok) 00640 ok = aosDoc.Update(); 00641 00642 if (!ok) 00643 { 00644 FailAndExecute(); 00645 End(); 00646 return; 00647 } 00648 00649 // If we preserved an export property then reset it to the default for its new name. 00650 if (pNewExport != 0) 00651 { 00652 // Change to the new property (without undo) and deallocate the old. 00653 pCopyPropNode = GetWorkingDoc()->GetSetSentinel()->FindPropertyNode(strNewName); 00654 if (pCopyPropNode != 0) delete pCopyPropNode->SetProperty(pNewExport); 00655 } 00656 00657 End(); 00658 }
|
|
Reimplemented from UndoableOperation. Definition at line 307 of file ngsetop.h. 00307 { return TRUE; }
|