void TestErrorStuff() { test1(0); test1(1); test1(2); test1(3); test1(4); InformError(); test2(0); test2(1); test2(2); test2(3); test2(4); InformError(); ERROR3("simple"); ERROR3IF( TRUE, "simple" ); ERROR3_PF( ("doc is %lx", 0x123456) ); ERROR3IF_PF( TRUE, ("doc %s is %lx", "blobdoc", 0x123456) ); TRACEUSER( "Andy", _T("simple trace\n")); TRACEUSER( "Andy", "complex %d %s trace", 42, _T("blobby\n") ); }
BOOL OpBackground::ApplyDefaultAttributes(NodeRegularShape * pShape) { ERROR2IF(pShape == NULL,FALSE,"OpBackground::ApplyDefaultAttributes Bar params!"); // ***** // Set up a no colour line colour AttrStrokeColour * pLineColAttr = new AttrStrokeColour(); if (pLineColAttr == NULL) { InformError(); return(FALSE); } DocColour ColNone(COLOUR_NONE); ((AttrFillGeometry*)pLineColAttr)->SetStartColour(&ColNone); // And now insert it as a child of the regular shape // Factoring should be ok as the Regular Shape is assumed to be the child of // layer pLineColAttr->AttachNode(pShape, LASTCHILD); // ***** // Set up a line width attribute AttrLineWidth *pLineWidthAttr = new AttrLineWidth(); if (pLineWidthAttr == NULL) { InformError(); return(FALSE); } ((AttrLineWidth*)pLineWidthAttr)->Value.LineWidth = 0; // And now insert it as a child of the regular shape // Factoring should be ok as the Regular Shape is assumed to be the child of // layer pLineWidthAttr->AttachNode(pShape, LASTCHILD); // ***** // Set up a join type attribute AttrJoinType * pJoinTypeAttr = new AttrJoinType(); if (pLineWidthAttr == NULL) { InformError(); return(FALSE); } // We will use a default constructed one as this should be vaguely correct // ((AttrLineWidth*)pJoinTypeAttr)->Value.LineWidth = 0; // And now insert it as a child of the regular shape // Factoring should be ok as the Regular Shape is assumed to be the child of // layer pJoinTypeAttr->AttachNode(pShape, LASTCHILD); return TRUE; }
BOOL OpMenuSave::SaveSpecificFile(Filter* pFilter, CCLexFile* pFile) { ERROR2IF(pFilter == NULL,FALSE,"OpMenuSave::SaveSpecificFile null filter specified"); // First off, we have to try and open the file BOOL AllOK = TRUE; // TRY { // Tell the filter we would like a Preview Bitmap please if (pFilter->CanIncludePreviewBmp()) pFilter->IncludePreviewBmp(TRUE); // Try and export the file PathName pth = pFile->GetPathName(); if (!pFilter->DoExport(this, pFile, &pth, Document::GetCurrent(), FALSE)) { // Something went a bit wrong - tell the user what it was. // Supress the error if it was the 'user has cancelled one' if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) { // Clean up after ourselves InformError(); } else Error::ClearError(); // otherwise remove the error so it won't get reported // Set the error AllOK = FALSE; } } #if 0 // See if there was a file io error CATCH(CFileException, e) { // Report the error if no one else did if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) { InformError(); } else Error::ClearError(); // and fail return FALSE; } END_CATCH #endif // Tell the filter we would NOT like a Preview Bitmap ready for next time if (pFilter->CanIncludePreviewBmp()) pFilter->IncludePreviewBmp(FALSE); // return return AllOK; }
// ** RALPH XSetError() ** void CDECL Error::XSetError( const TCHAR *fmt, ...) { TCHAR buf[256]; TRACEUSER( "Chris", _T("oOoOo Ralph Set Error \n")); #ifdef _DEBUG #if 0 != wxUSE_UNICODE TCHAR fmt2[MAXERRORFORMATLENGTH]; FixFormat(fmt, fmt2); #else const TCHAR * fmt2=fmt; #endif va_list marker; va_start( marker, fmt ); camVsnprintf( buf, 256, fmt2, marker ); va_end( marker ); // in debug builds we put up an ensure box EnsureFailedLine( buf, LastErrorFile, LastErrorLine ); // put up box #else XSetErrorC(); InformError(); #endif return; }
BOOL EditTab::HandleMsg(DialogMsg* Msg) { TRACEUSER( "Neville", _T("HandleEditMsg\n")); ERROR2IF(Msg == NULL,FALSE,"EditTab::Message null message received"); ERROR2IF(pPrefsDlg == NULL,FALSE,"EditTab::HandleMsg called with no dialog pointer"); BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_EDIT)); // The edit page identifier if (!ok) return TRUE; // no page present = handled message switch(Msg->DlgMsg) { case DIM_CREATE: // Initialise controls GreyStatus = FALSE; // we are ungreyed by default ok = InitSection(); if (!ok) InformError(); break; case DIM_SELECTION_CHANGED: case DIM_LFT_BN_CLICKED: case DIM_TEXT_CHANGED: OptionsTabs::SetApplyNowState(TRUE); break; default: break; } return TRUE; }
BOOL LayerManager::ReadSpreadLayerDetails() { ENSURE(CurrentSpread != NULL, "Trying to read the details of a NULL current spread"); ENSURE(LyrDetList.IsEmpty(), "Layer details list not empty"); LyrDetails* LayerDet; Layer* Current = CurrentSpread->FindFirstLayer(); while (Current != NULL) { // Found a layer so record the details LayerDet = new LyrDetails(); if (LayerDet == NULL) { // Inform an error - The error will already be set by new InformError(); return FALSE; } LayerDet->Status = (Current)->GetLayerStatus(); // record the layer status LayerDet->m_pLayer = Current; LayerDet->New = FALSE; LayerDet->Deleted = FALSE; LyrDetList.AddTail(LayerDet); // Add the layers details to the tail of the layer // detail list, so preserving the correct z-order. Current = Current->FindNextLayer(); } ENSURE(!LyrDetList.IsEmpty(), "No layers found on the current spread"); return TRUE; }
/******************************************************************************************** > 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; }
void OpChangeLineAttribOpDesc::SetGadgetText(const String& strGadgetText) { // Create a list for the dialogue manager to put gadget ID's on. List* pGadgetList = new List; if (pGadgetList == NULL) { InformError(_R(IDE_NOMORE_MEMORY)); return; } // Obtain a list of all the combo controls. if (BuildGadgetList(pGadgetList)) { // Iterate over each control in the list. for (GadgetListItem* pGadgetItem = (GadgetListItem*) pGadgetList->GetHead(); pGadgetItem != NULL; pGadgetItem = (GadgetListItem*) pGadgetList->GetNext(pGadgetItem)) { // Set each control to display the text. pGadgetItem->pDialogOp->SetStringGadgetValue(pGadgetItem->gidGadgetID, ((String&) strGadgetText), FALSE, -1); } // Tidy up. pGadgetList->DeleteAll(); } // Deallocate gadget list. delete pGadgetList; }
/******************************************************************************************** > void OpDeSelectAllPathPoints::Do(OpDescriptor*) Author: Peter_Arnold (Xara Group Ltd) <*****@*****.**> Created: 30/04/95 Inputs: Unused Outputs: - Returns: - Purpose: Deselects all the points on the selected paths SeeAlso: - ********************************************************************************************/ void OpDeSelectAllPathPoints::Do(OpDescriptor*) { if (!DoAction(FALSE)) InformError(); End(); }
void InformLastError(UINT32) { if (ErrStatus != ERRORSTAT_NONE) { InformError(); ErrStatus = ERRORSTAT_NONE; } }
void PushTool::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread* pSpread ) { if (ClickMods.Menu) return; // Don't do anything if the user clicked the Menu button // Make sure this click is one that we want if ( Click == CLICKTYPE_SINGLE ) { #ifdef RALPH //Graham 20/9/96: If we're in Ralph, clicking on a Hot Link activates it. //The one exception to this rule is if CTRL is pressed, in which case //the tool acts as normal. //So, is CTRL pressed? if (!(ClickMods.Constrain)) { //No. Are we on a Hot Link? Let's try and find one. //First, find a Hot Link Node* pHotLinkNode= DocView::FindHotLinkNode(PointerPos); //If we've found one, go to that Hot Link if (pHotLinkNode) { DocView::GoToHotLink((AttrUser*) pHotLinkNode); return; } } //If CTRL was pressed, or if we weren't over a Hot Link, we treat //the click as a normal Push drag. Read on... #endif //Ralph // Just what we wanted - Someone is dragging the mouse about // We need to make an operation to perform the drag with OpPush* pOpPush = new OpPush; if (pOpPush == NULL) { // Failed to get the memory to do the job // I guess we should just ignore the click, though the user is going to // wonder just what is happening! // TRACE( _T("The Push Operation could not start due to lack of memory\n") ); // Inform the person doing the clicking that life is not looking so good InformError( _R(IDS_OUT_OF_MEMORY), _R(IDS_OK) ); } else { // Start the drag operation and pass in the Anchor Point to the push operation pOpPush -> DoDrag( PointerPos ); } } }
void CBaseBrushNameDlg::Do(OpDescriptor*) { // Try to run this operation. if (!Create()) { InformError(0, _R(IDS_OK)); End(); } if (m_bModeless == TRUE) Open(); }
void ToolbarDlg::Do(OpDescriptor*) { if (Create()) { Open(); } else // Could not create { InformError(); End(); // End the operation } }
void CustomizeBarDlg::Do(OpDescriptor* pOpDesc) { if (Create()) { // pToolbarDlg = pDlg; Open(); } else // Could not create { InformError(); End(); // End the operation } }
BOOL OpBackground::ApplyBitmap(KernelBitmap * pBitmapToApply, NodeRegularShape * pShape) { ERROR2IF(pBitmapToApply == NULL || pShape == NULL,FALSE,"OpBackground::ApplyBitmap Bar params!"); // Set up a fill colour attribute AttrBitmapColourFill *pBitmapFillAttr = new AttrBitmapColourFill(); if (pBitmapFillAttr == NULL) { InformError(); return(FALSE); } // Set the coordinates of the fill end points // We want to start the fill at the top left of the regular shape // The bounding rect should be roughly what we want DocRect Rect = pShape->GetBoundingRect(TRUE, FALSE); // Get the size of the bitmap taking into account its DPI INT32 Width = pBitmapToApply->GetRecommendedWidth(); INT32 Height = pBitmapToApply->GetRecommendedHeight(); // You would think that the handles on the fill correspond to where you place them // but oh now the displayed handles are shown at different points. So instead of // positioning the start in the centre of the bitmap, you need to position it bottom left // The End should be centre and right but needs to be bottom right. // The End2 should be centre and top but needs to be top left. // We want the start point to be half the height of the bitmap below this //DocCoord Start(Rect.lo.x + Width/2, Rect.hi.y - Height/2); DocCoord Start(Rect.lo.x, Rect.hi.y - Height); // We want the other end point to be same height as the centre point // but on the far right of the rectangle i.e the full width across //DocCoord End(Rect.lo.x + Width, Rect.hi.y - Height/2); DocCoord End(Rect.lo.x + Width, Rect.hi.y - Height); // We want the end point to be middle and top of the rectangle //DocCoord End2(Rect.lo.x + Width/2, Rect.hi.y); DocCoord End2(Rect.lo.x, Rect.hi.y); ((AttrFillGeometry*)pBitmapFillAttr)->SetStartPoint(&Start); ((AttrFillGeometry*)pBitmapFillAttr)->SetEndPoint(&End); ((AttrFillGeometry*)pBitmapFillAttr)->SetEndPoint2(&End2); // Now attach the correct bitmap to the fill ((AttrFillGeometry*)pBitmapFillAttr)->AttachBitmap(pBitmapToApply); // And now insert it as a child of the regular shape // Factoring should be ok as the Regular Shape is assumed to be the child of // layer pBitmapFillAttr->AttachNode(pShape, FIRSTCHILD); return TRUE; }
void ImagemapDlg::Do(OpDescriptor*) { BOOL ok; // Force the dialog box to be created, as it is modal it will be opened via a message ok = Create(); if ( !ok ) { // Could not create the dialog box so call inform error InformError(); End(); } }
void URLImportDlg::DoWithParam(OpDescriptor*, OpParam* Param) { BOOL ok; // Force the dialog box to be created, as it is modal it will be opened via a message ok = Create(); if ( !ok ) { // Could not create the dialog box so call inform error InformError(); End(); // End the operation } }
/****************************************************************************************** > void PrintPrefsDlg::Do(OpDescriptor*) Author: Neville_Humphrys (Xara Group Ltd) <*****@*****.**> Created: 12/4/95 Inputs: - Outputs: - Returns: - Purpose: Creates then opens the dialog in response to a request from the user. Errors: - SeeAlso: - ******************************************************************************************/ void PrintPrefsDlg::Do(OpDescriptor*) { BOOL ok; if (OptionsTabs::pPrefsDlg != NULL) { ERROR3("PrintPrefsDlg::Do an options tabbed dialog box is already present"); return; } // Set up the name that the main dialog page is going to use String_256 Temp(_R(IDN_PRINTOPTS)); TitleString = Temp; SetName(&TitleString); // Make sure that our options tabs have a link to the dialog box class OptionsTabs::pPrefsDlg = this; OptionsTabs::SetApplyNowState(FALSE); // Make sure that we have set up our class variables so that the tabs know what // is the current document and spread to work on. Document *pDocument = Document::GetSelected(); OptionsTabs::SetCurrentDocAndSpread(pDocument); // Work out the document name so that it is ready for options tabs to display. OptionsTabs::SetDocumentName(pDocument); // Force the dialog box to be created, as it is non-modal it must be opened if the create // works ok. ok = Create(); // create the dialog box if ( ok ) { // // Modal at present so remove the Open() // Open(); // created ok so open the dialog box up // // // grey out the apply now button as this should only become enabled when we have // // made a change to the dialog box. // OptionsTabs::SetInitMessageState(FALSE); // OptionsTabs::SetApplyNowState(FALSE); // OptionsTabs::GreyApplyNow(); } else { // Could not create the dialog box so call inform error InformError(); // Show user the error End(); // End the operation } }
BOOL ScaleTab::HandleMsg(DialogMsg* Msg) { TRACEUSER( "Neville", _T("HandleScaleMsg\n")); ERROR2IF(Msg == NULL,FALSE,"ScaleTab::Message null message received"); ERROR2IF(pPrefsDlg == NULL,FALSE,"ScaleTab::HandleMsg called with no dialog pointer"); BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The Scale tab identifier if (!ok) return TRUE; // page not present switch(Msg->DlgMsg) { case DIM_CREATE: // Initialise controls GreyStatus = FALSE; // we are ungreyed by default ok = InitSection(); if (!ok) InformError(); break; case DIM_LFT_BN_CLICKED: OptionsTabs::SetApplyNowState(TRUE); if (Msg->GadgetID == _R(IDC_OPTS_USESCALEFACTOR)) { BOOL Valid; BOOL Active = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_USESCALEFACTOR),0,1,0,&Valid); // Grey/ungrey the editable fields accordingly pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWINGSCALE), Active); pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALSCALE), Active); // Grey/ungrey the static text fields accordingly pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEEG), Active); pPrefsDlg->EnableGadget(_R(IDC_OPTS_REALWORLD), Active); pPrefsDlg->EnableGadget(_R(IDC_OPTS_DRAWING), Active); pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO), Active); pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALETO2), Active); pPrefsDlg->EnableGadget(_R(IDC_OPTS_SCALEGROUP), Active); } break; case DIM_SELECTION_CHANGED: case DIM_TEXT_CHANGED: OptionsTabs::SetApplyNowState(TRUE); break; default: break; } return TRUE; }
/******************************************************************************************** > 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(); }
BOOL OpBackground::ApplyDocColour(DocColour * pColourToApply, NodeRegularShape * pShape) { ERROR2IF(pColourToApply == NULL || pShape == NULL,FALSE,"OpBackground::ApplyDocColour Bar params!"); // Set up a fill colour attribute AttrFlatColourFill *pFillColAttr = new AttrFlatColourFill(); if (pFillColAttr == NULL) { InformError(); return(FALSE); } ((AttrFillGeometry*)pFillColAttr)->SetStartColour(pColourToApply); // And now insert it as a child of the regular shape // Factoring should be ok as the Regular Shape is assumed to be the child of // layer pFillColAttr->AttachNode(pShape, FIRSTCHILD); return TRUE; }
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; }
void OpGenericDownload::OnDownloadFail() { //First get a pointer to the parameters GenericDownloadParam* pGenParam = (GenericDownloadParam*) pParam; if (pGenParam==NULL) { ERROR2RAW("OpBitmapDownload::OnDownloadFail - no download parameters"); return; } //Get the URL which the user typed String_256 strURL=pGenParam->strURL; //And put it up as a message String_256 strMessage; strMessage.MakeMsg(_R(IDS_HTML_DOWNLOADFAILED), &strURL); Error::SetError(0, strMessage, 0); InformError(); }
BOOL PrintPrefsDlg::CommitDialogValues() { // Ok has been pressed so take the values from the dialog box BOOL ok = TRUE; BOOL ValuesOk = TRUE; // Go through all the tabs declared to the system in turn // and tell them to commit the values for their tab OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { // Only get the tab to commit if it is a print based option if ( pOptionsTabs->IsPrintingOption() ) { // Get the found page to commit its values. // Should return False if reported error and we should just fail. // 2 if set an error which we should report and then fail. ok = pOptionsTabs->CommitSection(); if ( ok != TRUE ) { if (ok == 2) InformError(); // If error required show it. // Carry on with other pages so that report all errors and have a chance // to correct mistakes in other pages but make note of error state. ValuesOk = FALSE; //return FALSE; } } // Get the next option's tab. pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } // Return whether we found bad values or not. return ValuesOk; }
BOOL LayerPropertiesTab::HandleMsg(DialogMsg* Msg) { TRACEUSER( "Neville", _T("LayerPropertiesTab::HandleMsg\n")); ERROR2IF(Msg == NULL,FALSE,"LayerPropertiesTab::Message null message received"); ERROR2IF(pPropertiesDlg == NULL,FALSE,"LayerPropertiesTab::HandleMsg called with no dialog pointer"); BOOL ok = pPropertiesDlg->TalkToPage(GetPageID()); if (!ok) return TRUE; // no page present = handled message switch(Msg->DlgMsg) { case DIM_CREATE: // Initialise controls GreyStatus = FALSE; // we are ungreyed by default ok = InitSection(); if (!ok) InformError(); break; case DIM_LFT_BN_CLICKED: { UpdateApplyState(); //switch (Msg->GadgetID) //{ //} } break; case DIM_SELECTION_CHANGED: case DIM_TEXT_CHANGED: UpdateApplyState(); break; default: break; } return TRUE; }
BOOL OpMenuLoad::LoadFile(CCLexFile* pFileToLoad, UINT32 nPrefFilter) { // Make sure we have a valid file to load. /* TRACEUSER( "JustinF", _T("In OpMenuLoad::LoadFile(%p, %u)\n"), (LPVOID) pFileToLoad, nPrefFilter); */ ERROR3IF(!pFileToLoad, "Null CCLexFile* in OpMenuLoad::LoadFile"); // Find out the position of the filter selected by the user in the open dialog INT32 SelectedPos = 0; #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) SelectedPos = BaseFileDialog::SelectedFilter; #endif // Go get the first filter in the list Filter* pFilter = Filter::GetFirst(); // Do we know which filter was used? (we know nothing about things in the recent file // list). If we don't, then use the preferred one, by default the generic filter. if (nPrefFilter != FILTERID_USERCHOICE || SelectedPos == 0) { // We know nothing. We will have to go and have a look at all the possibles // We will find the Filter Family and ask it to try and load the file. UINT32 nID = (nPrefFilter != FILTERID_USERCHOICE) ? nPrefFilter : FILTERID_GENERIC; while (pFilter != NULL && pFilter->FilterID != nID) { // Try the next filter pFilter = Filter::GetNext(pFilter); } } else { // We know which type of filter the user had selected in the file dialog // Find the filter that the user chose. while (pFilter != NULL) { // This is the filter? if (pFilter->GetFlags().CanImport && pFilter->pOILFilter->Position == SelectedPos) break; // Try the next filter pFilter = Filter::GetNext(pFilter); } } // Check that the Filter existed if (pFilter == NULL) { // It did not... InformError(_R(IDT_CANT_FIND_FILTER)); return FALSE; } // Get pointer to current doc 'cos we'll need it several times... Document* pCurDoc = Document::GetCurrent(); // If this is not a filter family, check for compatibility before asking // filter to load the file. // This means the user has chosen an explicit filter to handle the import PathName Path = pFileToLoad->GetPathName(); String_256 FilePath = Path.GetPath(); // FilePath will be null if a pathname is not valid if (!pFilter->IS_KIND_OF(FilterFamily) && !FilePath.IsEmpty()) { UINT32 Size = 1024; size_t FileSize; ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize); // If there has been a problem in the load initial segment then fail now. if (FilterBuf == NULL) { // Tell the user about the problem and get out now while the goings good InformError(); return FALSE; } // Inform any filters that we are about to do a HowCompatible call. // This would allow a set of filters which have common functionality hidden in a // filter that cannot import and cannot export handle this call and hence set // itself up. This would allow it to maybe cache a result which should only be // checked by the first filter in the group. pFilter->PreHowCompatible(); // Change this to be less than 8 as the filters like the Accusoft forms return // 8 and 9 to make sure that they are last in the chain. if (pFilter->HowCompatible(Path, FilterBuf, Size, UINT32(FileSize)) < 8) { // Not 100% happy with this file - ask for confirmation. ErrorInfo Question; Question.ErrorMsg = _R(IDW_OPENQUERY_NOTSURE); Question.Button[0] = _R(IDB_OPENQUERY_OPEN); Question.Button[1] = _R(IDB_OPENQUERY_DONTOPEN); if ((ResourceID)AskQuestion(&Question) != _R(IDB_OPENQUERY_OPEN)) { // User asked for this to be cancelled. TRACEUSER( "Tim", _T("Filter compatibility was less than 10\n")); // Close the file, report the abort and finish. CCFree(FilterBuf); //InformMessage(_R(IDT_IMP_USERABORT)); return FALSE; } } // Get rid of initial file header CCFree(FilterBuf); } // we have to try and open the file try { // Found the Filter, so ask it to import the file please if (!pFilter->DoImport(this, pFileToLoad, pCurDoc)) { // Something went a bit wrong - tell the user what it was. // Only tell them if not special user cancelled error message if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) { // Only supress the error if not the special user abort error // ***** For now use the native EPS filter if (pFilter->FilterID == FILTERID_NATIVE_EPS && Error::GetErrorNumber() != _R(IDT_IMPORT_USERABORT)) { Error::ClearError(); InformError(_R(IDS_ERRORINARTFILE)); } else { // Tell the user what the problem was InformError(); wxMessageDialog dlg( NULL, _T( "Xara LX failed to load the design.\n\n") _T( "This is an early demonstration version of the program which does ") _T( "not yet support all of the data types that can appear in XAR designs."), _T("Load failed"), wxOK ); dlg.ShowModal() ; } } else { // otherwise remove the error so it won't get reported Error::ClearError(); } // and fail return FALSE; } } // See if there was a file io errir catch( CFileException ) { // Report the error if no one else did, otherwise clear it. if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) InformError(); else Error::ClearError(); // and fail return FALSE; } // Success. return TRUE; }
BOOL ScaleTab::CommitSection() { TRACEUSER( "Neville", _T("commit Scale section\n")); ERROR3IF(pPrefsDlg == NULL, "ScaleTab::CommitSection called with no dialog pointer"); BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_SCALE)); // The Scale tab identifier if (!ok) return TRUE; // Talk to View failed to return now // Ok has been pressed so take the values from this section of the dialog box // Takes the values in the dialog and sets the DimScale object accordingly. BOOL Valid=TRUE; // Flag for validity of value // BOOL State=FALSE; // Flag for state of button/switch BOOL SetOk=TRUE; // Preference value set ok // Section = Scale settings // Now check that we have the selected view still, just in case it has switched // without us being told about it or even we have no current document/view. // This may be a valid state now, so do not complain about it. DocView* pCurrentView = DocView::GetSelected(); if (pCurrentView != NULL) { // Only if there is a current view do we read the values. String_256 DrawingStr; String_256 RealStr; //TCHAR* pDrawingStr = DrawingStr; //TCHAR* pRealStr = RealStr; BOOL Active; // Get the values from the dialog box Active = pPrefsDlg->GetLongGadgetValue(_R(IDC_OPTS_USESCALEFACTOR),0,1,0, &Valid); DrawingStr = pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_DRAWINGSCALE), &Valid); RealStr = pPrefsDlg->GetStringGadgetValue(_R(IDC_OPTS_REALSCALE), &Valid); Spread* pSpread = pCurrentView->GetFirstSelectedSpread(); // If no selected spread then use the visible spread if (pSpread == NULL) pSpread = pCurrentView->GetVisibleSpread(); // Only do the chnage if we have a valid spread pointer and we have changed something. if ( (pSpread != NULL) && ( (OldActiveState != Active) || (OldDrawingStr != DrawingStr) || (OldRealStr != RealStr) ) ) { pDimScale = pSpread->GetPtrDimScale(); if (pDimScale != NULL) { // Only if active is set do we need to try and set new strings // and hence a new drawing scale if (Active) { // Dim Scales can only be 32 characters long String_32 DrawingStr32 = _T(""); String_32 RealStr32 = _T(""); // Check if read in strings are longer than this if (DrawingStr.Length() > DrawingStr32.MaxLength()) { InformError(_R(IDE_OPTS_INVALIDDRAWSCALE)); return FALSE; } if (RealStr.Length() > RealStr32.MaxLength()) { InformError(_R(IDE_OPTS_INVALIDREALSCALE)); return FALSE; } RealStr32 = RealStr; DrawingStr32 = DrawingStr; // Try and set these strings as new drawing and real scales strings SetOk = pDimScale->SetDrawingScaleStr(DrawingStr32); if (!SetOk) { InformError(_R(IDE_OPTS_INVALIDDRAWSCALE)); return FALSE; } SetOk = SetOk && pDimScale->SetRealScaleStr(RealStr32); if (!SetOk) { InformError(_R(IDE_OPTS_INVALIDREALSCALE)); return FALSE; } // Now try to convert these into a new scaling factor if (SetOk) SetOk = SetOk && pDimScale->SetScaleFactor(); // If we failed in any of the conversions then warn the user and fail if (!SetOk) { InformError(_R(IDE_OPTS_INVALIDSCALING)); return FALSE; } } // Set up a possibly new active state pDimScale->SetActiveState(Active); } // Now tell other users of units/scaling factors that there they are likely // to need to update any currently displayed units. Document *pCurrentDoc = (Document *)pSpread->FindOwnerDoc(); BROADCAST_TO_ALL(OptionsChangingMsg(pCurrentDoc, OptionsChangingMsg::NEWUNITS)); // unfortunately pScopeDoc is NULL!, and since pCurrentDoc is calulated I thought it ought to use! - Ed 17/10/95 // BROADCAST_TO_ALL(OptionsChangingMsg(pScopeDocument, OptionsChangingMsg::OptionsState::NEWUNITS)); // Make sure the document is marked as modified. pCurrentDoc->SetModified(TRUE); // And note the new states OldActiveState = Active; OldDrawingStr = DrawingStr; OldRealStr = RealStr; } } // else // ERROR2(FALSE,_R(IDE_OPTS_READPREF_SCALE)); return TRUE; }
void OpBreakAtPoints::Do(OpDescriptor*) { // Obtain the current selections SelRange* Selected = GetApplication()->FindSelection(); NodePath* pSplitNode; // Now, because we're going to be doing mad things to the selection, we have to make a list // of all the selected nodes, so that adding nodes into the tree won't confuse us List* NodeList = Selected->MakeListOfNodes(); NodeListItem* CurItem = (NodeListItem*)(NodeList->GetHead()); if (!CurItem) goto FailAndDeleteList; if (!DoStartSelOp(TRUE,TRUE)) goto FailAndDeleteList; while (CurItem) { // get a pointer to the NodePath NodePath* pThisNode = (NodePath*)(CurItem->pNode); // Only interested in NodePaths that have a sub selection, and that will allow the op to happen if ((IS_A(pThisNode,NodePath) || IS_A(pThisNode,NodeBlendPath)) && pThisNode->InkPath.IsSubSelection()) { // Find out how many nodes this op will reproduce INT32 NumSplinters = pThisNode->InkPath.NumSplinters(); BOOL DoThisNode = FALSE; if (NumSplinters > 0) { // We need to ask the effected nodes if they (and their parents) can handle this node being replaced ObjChangeFlags cFlags; if (NumSplinters > 1) cFlags.MultiReplaceNode = TRUE; // Node will be replaced with more than one node. else cFlags.ReplaceNode = TRUE; // Node will be replaced with one node only. ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this); DoThisNode = pThisNode->AllowOp(&ObjChange); } if (DoThisNode) { BOOL ok; Node* pnode; // Copy the nodepath and all its children, without placing the copy in the tree CALL_WITH_FAIL(pThisNode->NodeCopy(&pnode), this, ok); if (!ok) goto DeleteList; pSplitNode = (NodePath*)pnode; // remove the fill from this path as we're about to open it pSplitNode->InkPath.IsFilled = FALSE; // Now stick the new path into the tree CALL_WITH_FAIL ( DoInsertNewNode(pSplitNode, pThisNode, NEXT, TRUE, FALSE), this,ok ); if (!ok) goto DeleteListAndPath; // Now breakup this copy of the path where necessary Path* pChildPath; INT32 split; do { // Create a new path, ready for split ALLOC_WITH_FAIL(pChildPath, new Path, this); if (!pChildPath) goto DeleteList; // Now split the path, possibly into two pieces. split = pSplitNode->InkPath.BreakInTwo(pChildPath); if (split==-1) { InformError(_R(IDS_OUT_OF_MEMORY), _R(IDS_OK)); delete pChildPath; goto FailAndDeleteList; } /* Karim 05/12/2000 No longer required - see code addition at the bottom of this loop. if (split==1) { delete pChildPath; continue; } */ if (split>1) { // update the split paths bounding rectangle pSplitNode->InvalidateBoundingRect(); // Create a new nodepath. NodePath* pChildNode; ALLOC_WITH_FAIL(pChildNode, new NodePath(), this); if (!pChildNode) { delete pChildPath; goto DeleteList; } // make room for the new path in the node path. CALL_WITH_FAIL ( pChildNode->SetUpPath(pChildPath->GetNumCoords(),12), this,ok ); if (!ok) { delete pChildNode; delete pChildPath; goto DeleteList; } // now copy the path data in there. pChildNode->InkPath.CopyPathDataFrom(pChildPath); delete pChildPath; // Clear the selection flag from the first element in both the split // and child paths. All others apart from the last will be unselected // by definition. Also select the last element in the child (pSplitNode->InkPath.GetFlagArray())[0].IsSelected = FALSE; (pChildNode->InkPath.GetFlagArray())[0].IsSelected = FALSE; (pChildNode->InkPath.GetFlagArray())[(pChildNode->InkPath.GetNumCoords()-1)].IsSelected = TRUE; pChildNode->InkPath.IsFilled = FALSE; // now, copy all attributes from the parent split to the child split Node* pAttr = pSplitNode->FindFirstChild(); while (pAttr != NULL) { if (pAttr->IsKindOf(CC_RUNTIME_CLASS(NodeAttribute))) { Node* pAttrCopy; CALL_WITH_FAIL(pAttr->NodeCopy(&pAttrCopy), this,ok); if (!ok) { pChildNode->CascadeDelete(); delete pChildNode; goto DeleteList; } pAttrCopy->AttachNode(pChildNode, FIRSTCHILD); } pAttr = pAttr->FindNext(); } for (INT32 loop = 0; loop < pChildNode->InkPath.GetNumCoords(); loop ++) { pChildNode->InkPath.GetVerbArray()[loop] = pChildNode->InkPath.GetVerbArray()[loop] & ~PT_CLOSEFIGURE; } // Now stick the new path into the tree CALL_WITH_FAIL ( DoInsertNewNode(pChildNode, pSplitNode, NEXT, TRUE, FALSE), this,ok ); if (!ok) { pChildNode->CascadeDelete(); delete pChildNode; goto DeleteList; } pSplitNode = pChildNode; } // Karim 05/12/2000 // Fix for memory leak. else { delete pChildPath; } } while (split); // Clear out any remaining closefigures on the last bit of the path for (INT32 loop = 0; loop < pSplitNode->InkPath.GetNumCoords(); loop ++) { pSplitNode->InkPath.GetVerbArray()[loop] = pSplitNode->InkPath.GetVerbArray()[loop] & ~PT_CLOSEFIGURE; } // Now we've broken up this path, let's hide it CALL_WITH_FAIL(DoHideNode(pThisNode,TRUE), this, ok) if (!ok) goto DeleteList; } } CurItem = (NodeListItem*)(NodeList->GetNext(CurItem)); }
BOOL GuidesPropertiesTab::HandleMsg(DialogMsg* Msg) { TRACEUSER( "Neville", _T("GuidesPropertiesTab::HandleMsg\n")); ERROR2IF(Msg == NULL,FALSE,"GuidesPropertiesTab::Message null message received"); ERROR2IF(pPropertiesDlg == NULL,FALSE,"GuidesPropertiesTab::HandleMsg called with no dialog pointer"); BOOL ok = pPropertiesDlg->TalkToPage(GetPageID()); if (!ok) return TRUE; // no page present = handled message switch(Msg->DlgMsg) { case DIM_CREATE: // Initialise controls GreyStatus = FALSE; // we are ungreyed by default ok = InitSection(); if (!ok) InformError(); break; case DIM_LFT_BN_CLICKED: //LayerPropertyTabs::SetApplyNowState(TRUE); if (FALSE) {} else if (Msg->GadgetID == _R(IDC_GUIDETAB_HORZ)) { if (GuideType != GUIDELINE_HORZ) { GuideType = GUIDELINE_HORZ; ShowDetails(); } } else if (Msg->GadgetID == _R(IDC_GUIDETAB_VERT)) { if (GuideType != GUIDELINE_VERT) { GuideType = GUIDELINE_VERT; ShowDetails(); } } else if (Msg->GadgetID == _R(IDC_GUIDETAB_PROPERTIES)) { PropertiesClicked(); ShowDetails(); } else if (Msg->GadgetID == _R(IDC_GUIDETAB_NEW)) { NewClicked(); ShowDetails(); } else if (Msg->GadgetID == _R(IDC_GUIDETAB_DELETE)) { DeleteClicked(); ShowDetails(); } break; case DIM_SELECTION_CHANGED: case DIM_TEXT_CHANGED: //LayerPropertyTabs::SetApplyNowState(TRUE); if (FALSE) {} else if (Msg->GadgetID == _R(IDC_GUIDETAB_GUIDELINELIST)) { ChangeControlStatus(!GreyStatus); } else if (Msg->GadgetID == _R(IDC_GUIDETAB_COLOURLIST)) { ColourChanged(pPropertiesDlg->GetSelectedValueIndex(Msg->GadgetID)); ShowDetails(); } break; default: break; } return TRUE; }
/******************************************************************************************** > 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(); }