BOOL PrintMarksComponent::ExportPrintMark(BaseCamelotFilter *pFilter, PrintMarkItem *pMarkItem) { BOOL ok = TRUE; PORTNOTETRACE("print","PrintMarksComponent::ExportPrintMark - do nothing"); #ifndef EXCLUDE_FROM_XARALX ERROR3IF(pFilter == NULL || pMarkItem == NULL, "Illegal NULL params"); PrintMark *pMarkInfo = pMarkItem->GetPrintMark(); if (pMarkInfo == NULL) { ERROR3("PrintMarkItem with no PrintMark"); return(FALSE); } if (pMarkInfo->IsCustom()) { // A custom mark consists of a PrintMarkCustom record, defining where the // mark goes, what it's called, etc, followed records for the clipart subtree CXaraFileRecord Rec(TAG_PRINTMARKCUSTOM, TAG_PRINTMARKCUSTOM_SIZE); if (ok) ok = Rec.Init(); // Write out the print mark info // Type (bitmap ID), menu text string, orientation, positions if (ok) ok = Rec.WriteBYTE((BYTE) pMarkInfo->GetType()); if (ok) ok = Rec.WriteBYTE((BYTE) pMarkInfo->GetOrientation()); if (ok) { MarkPosition *Pos = pMarkInfo->GetFirstPosition(); while (ok && Pos != NULL) { ok = Rec.WriteBYTE((BYTE) Pos->GetRegion()); // Write the region if (ok) ok = Rec.WriteBYTE(Pos->GetFormat().GetAsFlagByte()); // Write the format Pos = pMarkInfo->GetNextPosition(Pos); } if (ok) ok = Rec.WriteBYTE(MarkRegion_FileFormatTerminator); // Terminate the list } if (ok) ok = Rec.WriteUnicode(pMarkInfo->GetMarkMenuText()); // Write the mark name // Finish off this record if (ok) pFilter->Write(&Rec); // OK, now write the print mark "clipart" subtree to the file... if (ok) ok = pFilter->WriteZeroSizedRecord(TAG_DOWN); // BLOCK { // Find the Glyph subtree. We could strip off the default attributes // that Mike keeps around, but they only add a tiny amount (100 bytes // or so) to the file, and save a lot of problems getting attribute-completeness // when reloading the mark. Node *GlyphRoot = pMarkItem->GetMarkGlyph(); if (GlyphRoot == NULL) { ERROR3("Custom printers mark with no glyph"); ok = FALSE; } if (ok) ok = pFilter->WriteNodes(GlyphRoot); } if (ok) ok = pFilter->WriteZeroSizedRecord(TAG_UP); } else { // --- Write the record CXaraFileRecord Rec(TAG_PRINTMARKDEFAULT, TAG_PRINTMARKDEFAULT_SIZE); if (ok) ok = Rec.Init(); if (ok) ok = Rec.WriteBYTE(pMarkInfo->GetIDByte()); // --- Finally, output the record if (ok) pFilter->Write(&Rec); } #endif return(ok); }
BOOL DragTarget::IsAKernelObject(void) { ERROR3("Somebody is using 'abstract' base class DragTarget!!!"); return(TRUE); }
BOOL OILPanose::GetPanoseNumber(ENUMLOGFONT *pEnumLogFont, CCPanose *pPanose) { ERROR2IF(pEnumLogFont==NULL, FALSE, "Parameter pEnumLogFont == NULL."); ERROR2IF(pPanose==NULL, FALSE, "Parameter pPanose == NULL."); ERROR2IF(IsInitialised==FALSE, FALSE, "Class OILPanose not initialised."); BOOL ok = FALSE; // watch closely - it gets fairly involved down here CFont *pNewCFont; pNewCFont = new CFont; if (pNewCFont->CreateFontIndirect(&(pEnumLogFont->elfLogFont)) != NULL) { // success, managed to get create a new font. now select it into the CDC we have CFont *pOldCFont; pOldCFont = pMyCDC->SelectObject(pNewCFont); if (pOldCFont!=NULL) { // success, managed to select the font into the DC TEXTMETRIC MyTextMetric; if (pMyCDC->GetTextMetrics(&MyTextMetric) != 0) { // great, we've got the TextMetric structure. now check to see if its // a TrueType font or not - only TrueType fonts have Panose information if ((MyTextMetric.tmPitchAndFamily & TMPF_TRUETYPE) == TMPF_TRUETYPE) { // its a TrueType font, so get the Panose number and run INT32 Value; OUTLINETEXTMETRIC *pOutlineTextMetric; // find out how much space we need for the information Value = pMyCDC->GetOutlineTextMetrics(NULL, NULL); // claim a block of memory at least this size pOutlineTextMetric = (OUTLINETEXTMETRIC *) malloc(Value); ERROR2IF(pOutlineTextMetric==NULL, FALSE, "Out of memory."); // now get the OutlineTextMetric structure Value = pMyCDC->GetOutlineTextMetrics(Value, pOutlineTextMetric); ERROR3IF(Value==FALSE, "Unable to retrieve OUTLINETEXTMETRIC information"); // hurray, we've finally found what we were looking for - celebrate! ;) // now copy the information into the CCPanose strucure pPanose->SetFamilyType(pOutlineTextMetric->otmPanoseNumber.bFamilyType); pPanose->SetSerifStyle(pOutlineTextMetric->otmPanoseNumber.bSerifStyle); pPanose->SetWeight(pOutlineTextMetric->otmPanoseNumber.bWeight); pPanose->SetProportion(pOutlineTextMetric->otmPanoseNumber.bProportion); pPanose->SetContrast(pOutlineTextMetric->otmPanoseNumber.bContrast); pPanose->SetStrokeVariation(pOutlineTextMetric->otmPanoseNumber.bStrokeVariation); pPanose->SetArmStyle(pOutlineTextMetric->otmPanoseNumber.bArmStyle); pPanose->SetLetterform(pOutlineTextMetric->otmPanoseNumber.bLetterform); pPanose->SetMidline(pOutlineTextMetric->otmPanoseNumber.bMidline); pPanose->SetXHeight(pOutlineTextMetric->otmPanoseNumber.bXHeight); // finally free the memory we had claimed free((void *) pOutlineTextMetric); } else { // its not a TrueType font, so set the Panose number to some safe value pPanose->SetAllToAny(); } } else { ERROR3("Unable to retrieve TEXTMETRIC structure from CDC."); ok = FALSE; } pMyCDC->SelectObject(pOldCFont); } else { ERROR3("Unable to select CFont object into the CDC."); ok = FALSE; } } else { ERROR3("Unable to create font."); ok = FALSE; } delete pNewCFont; return ok; }
EditableText::EditableText(const EditableText& Other) : m_Watcher(this) { ERROR3("EditableText - copy constructor unimplemented\n"); }
BOOL RegularShapeRecordHandler::ReadShapeInvalid(CXaraFileRecord *pCXaraFileRecord) { ERROR3("Attempt to read an invalid shape."); return FALSE; }
BOOL TrapEdgeList::ProcessEdgeNormals(ProcessPathToTrapezoids *pProcessor) { if (Used < 2) // Sanity check { ERROR3("Not enough coordinates in trapezoid list!"); return(FALSE); } TrapEdge *pPrevEdge = NULL; TrapEdge *pEdge = NULL; NormCoord PrevNormal(1.0, 0.0); BOOL CompletingAMitre = FALSE; // --- First, scan the trapezoid list, and calculate the normal of each edge for (UINT32 Index = 0; Index < Used; Index++) { // Start by finding a pointer to the edge record and previous record (if any) pPrevEdge = pEdge; pEdge = &(pEdges[Index]); // Calculate the path normal for this trapezoid edge. if (pPrevEdge == NULL) { // It's the very first point. The normal is just the normal to the first segment TrapEdge *pNextEdge = &(pEdges[Index+1]); pEdge->Normal.SetNormalToLine(pEdge->Centre, pNextEdge->Centre); PrevNormal = pEdge->Normal; // Remember this edge's normal for the next pass } else if (pEdge->Centre == pPrevEdge->Centre) { // Two points are coincident. That means a joint (or a degenerate source path element). // // The following cases can apply: // if (the next point is ALSO coincident) // * We have a mitred join. The normal is the average of the previous and next normals // with some jiggery-pokery to make the normal also have a length which will get the // outline out to the mitre intersection point (rather than being normalised) // else // * We have the last 2 points of the 3-point mitred join, or // * We have a simple bevelled or rounded join // (both of which are treated in the same manner) // Find the "next" edge. Care must be taken for the last join to make sure // that the first edge is treated as "next". Note that we don't use point 0 // in this case, as that is coincident! We use point 1 which is the point // at the end of that first line. TrapEdge *pNextEdge = &pEdges[1]; if (Index < Used-1) pNextEdge = &pEdges[Index+1]; if (pNextEdge->Centre == pEdge->Centre) { // We have found 3 coincident points, so we've hit a mitred join. // The middle Edge of the mitred join has a normal which is in the direction // of the average of the preceeding/next edge normals (i.e. points towards the // mitre intersection), but it has a non-unit-length, so as to stretch the // outline out to the mitre point. // In this case, we don't bother to do anything yet, as we'll calculate // the next normal on the next pass, so we just flag the case and let // the next pass come back and fix up our normal once it has all the facts. CompletingAMitre = TRUE; // NOTE that we leave PrevNormal containing the previous normal - we'll need it // on the next pass. } else { // The completing trap of any join simply uses the normal of the "next" edge, // so we simply calculate this for all cases. if (Index >= Used-1) { // At the end of the curve - we can just copy the normal from the first point pEdge->Normal = pEdges[0].Normal; } else { // Inside the path - just use the next edge to generate a normal pEdge->Normal.SetNormalToLine(pEdge->Centre, pNextEdge->Centre); } // However, now we must check if we've just completed a mitred join, in // which case we have to go back to fill in the previous edge normal if (CompletingAMitre) { // Find the vector pointing towards the mitre point pPrevEdge->Normal.Average(PrevNormal, pEdge->Normal); // We now know the direction the mitre intersection (pointy bit) lies in. // Now, we will "stretch" that normal by the ratio of the distance to // the intersection over the stroke width. // We pass in the point before the join, the join centre, and the point // after the join. (Note that the join centre point occupies 3 edge entries) double MitreChordRatio = 1.0; pProcessor->CalculateMitreIntersection( &pEdges[Index-3].Centre, &pEdge->Centre, &pNextEdge->Centre, /*TO*/ &MitreChordRatio); pPrevEdge->Normal.x *= MitreChordRatio; pPrevEdge->Normal.y *= MitreChordRatio; } CompletingAMitre = FALSE; // Clear the mitre flag PrevNormal = pEdge->Normal; // Remember this edge's normal for the next pass } } else { // This isn't the first point. It also is not "inside" a joint (although it could be // the last edge preceeding a join) if (Index >= Used-1) { // Last point - the normal is merely at right-angles to last line, so = (lineY,-lineX) // NOTE that this is not true if this is a closed path, but we will fix that after // the loop if it needs fixing pEdge->Normal = PrevNormal; } else { // Find normal to next line NormCoord NextNormal(pEdge->Centre.y - pEdges[Index+1].Centre.y, -(pEdge->Centre.x - pEdges[Index+1].Centre.x)); if (NextNormal.x == 0.0 && NextNormal.y == 0.0) { // This point and the next point are coincident, so we must have hit a cusp join // (or rampant discontinuity) The normal is simply perpendicular to the last line pEdge->Normal = PrevNormal; } else { // This point lies between 2 flattened source path segments, so we simply average // their normals to get the path normal at the point. NextNormal.Normalise(); pEdge->Normal.Average(PrevNormal, NextNormal); PrevNormal = NextNormal; // Remember this normal for the next pass } } } } return(TRUE); }
/******************************************************************************************* > VisibleListIterator::VisibleListIterator(const VisibleListIterator& Other) const VisibleListIterator& VisibleListIterator::operator=(const VisibleListIterator& Other) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 09/06/97 Purpose: Warns that these have not been implemented (but a destructor has) *******************************************************************************************/ VisibleListIterator::VisibleListIterator(const VisibleListIterator& Other) : m_Container(Other.m_Container) { ERROR3("VisibleListIterator - copy constructor unimplemented\n"); }
INT32 LibraryFile::Init(SuperGallery *ParentGal, PathName *APath, SGLibType Type, BOOL Updated, BOOL DoScroll) { #ifndef EXCLUDE_GALS if(ParentGal == NULL || APath == NULL || !Libraries.IsEmpty()) { ERROR3("LibraryFile::Init - NULL parameters are illegal OR Init called > 1 times"); if(!Libraries.IsEmpty()) return(Libraries.GetCount()); else return 0; } BOOL ok = TRUE; // Tidy up Path a bit String_256 OurPath(APath->GetPath()); LibraryFile::TidyUpSubPath(&OurPath); // Now point Path to the new pathname PathName ModifiedPath(OurPath); PathName *Path = &ModifiedPath; if(!ModifiedPath.IsValid()) { ERROR3("LibraryFile::Init -> Modified library path is invalid"); return 0; } // Remember the pathname and type MyPath = *Path; MyType = Type; ParentGallery = ParentGal; if(ParentGallery->IsKindOf(CC_RUNTIME_CLASS(LibraryGallery))) ParentLibraryGallery = (LibraryGallery *)ParentGal; else { ERROR3("LibraryFile::Init passed a non-library gallery - yikes..."); return 0; } // Need to reset the Quiet status before a stream of Library::Init calls ParentLibraryGallery->SetQuietStatus(FALSE); BOOL Retry = TRUE; while(Retry) { Retry = FALSE; // Would be nice to have a way of adding a file to a path in PathName... Is there one ? if(!SGLibOil::FileExists(Path)) { // We're opening the font gallery, but can't find the font library path - don't warn if(Type == SGLib_Font) return 0; // tell the user that the directory doesn't exist String_256 WarnMsg; String_256 DefaultIndex; String_256 IndexDesc; BOOL CanGenerate; ok = LibraryFile::GetSubIndexDetails(ParentLibraryGallery, &DefaultIndex, &IndexDesc, &CanGenerate); String_256 TmpPath(Path->GetLocation(FALSE)); LibraryFile::TidyUpSubPath(&TmpPath); // Taken out by Graham 30/10/97: If the gallery had no directory specified, //we used to throw a warning which said "do you want to specify another folder?" //We don't do this any more, because the default is to open all galleries empty and //then download stuff from the Xara web site #if 0 WarnMsg.MakeMsg(_R(IDS_BROWSE_OR_SCAN), (TCHAR *)IndexDesc, (TCHAR *)TmpPath); Error::SetError(0, WarnMsg, 0); INT32 ButtonPressed = InformWarning(0, _R(IDS_BROWSE), _R(IDS_RETRY), _R(IDS_CANCEL)/*, _R(IDS_HELP)*/); #else // WEBSTER INT32 ButtonPressed = 3; #endif // WEBSTER TRACEUSER( "Richard", _T("ButtonPressed: %d\n"), ButtonPressed); Error::ClearError(); switch(ButtonPressed) { case 1: { // Open the Browse dialog (or the Add.. dialog as it seems to be called now) PathName ThePath(*Path); // This returns FALSE if Cancel was hit, or an error occurred. if(!SGLibOil::GetLibPath(ParentLibraryGallery, &ThePath, CanGenerate, Type)) { ERROR3("GetLibPath returned FALSE in LF::Init"); return 0; } else { ModifiedPath = ThePath; if(!ModifiedPath.IsValid()) { ERROR3("LibraryFile::Init -> scanned library path is invalid"); return 0; } // Remember the pathname MyPath = ThePath; switch(Type) { case SGLib_ClipArt: case SGLib_Bitmap: LibClipartSGallery::DefaultLibraryPath = MyPath.GetPath(); LibClipartSGallery::ClipartPath = LibClipartSGallery::DefaultLibraryPath; break; case SGLib_ClipArt_WebThemes: LibClipartSGallery::DefaultLibraryPath = MyPath.GetPath(); LibClipartSGallery::WebThemePath = LibClipartSGallery::DefaultLibraryPath; break; #ifndef STANDALONE case SGLib_Texture: case SGLib_Fractal: LibFillsSGallery::DefaultLibraryPath = MyPath.GetPath(); break; case SGLib_Font: // WEBSTER-Martin-09/01/97 - Put back by Ranbir. //#ifndef WEBSTER FontsSGallery::DefaultLibraryPath = MyPath.GetPath(); break; // Not in webster so we get the error below //#endif // WEBSTER #endif default: ERROR2(FALSE,"Library::ScanForLocation Type not present!"); break; } } break; } case 2: Retry = TRUE; #if 0 { // Scan String_256 Result; if(!Library::ScanForLocation(Type, &Result)) { ERROR3("No libraries found..."); return 0; } if(!ModifiedPath.SetPathName(Result)) { ERROR3("LibraryFile::Init -> scanned library path is invalid"); return 0; } // Remember the pathname and type MyPath = *Path; } #endif break; case 3: // Cancel return 0; } } } // Wipe libraries added to gallery for scroll / redraw purposes... InitScrollRedrawSystem(); // Check the actual path exists if(SGLibOil::FileExists(Path)) { // Would be nice to have a way of adding a file to a path in PathName... Is there one ? String_256 IndexFile((const TCHAR *)Path->GetPath(TRUE)); // "%s\\XaraInfo\\index.txt" IndexFile += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME)); IndexFile += TEXT("\\") + String_16(_R(IDS_LIBRARIES_INDEX_FILENAME)); PathName IndexFilePath(IndexFile); if(!IndexFilePath.IsValid()) { ERROR3("LibraryFile::Init indexfilepath is invalid"); return 0; } CCDiskFile MainIndex; if (!MainIndex.InitLexer(FALSE)) { // SetError! ERROR3("LibraryFile::LibraryFile InitLexer failed"); return(0); } if(SGLibOil::FileExists(&IndexFilePath)) { // Count lines in index file INT32 Count = CountLines(&IndexFilePath); TRACEUSER( "Richard", _T("%d lines in index file\n"), Count); // Used for the percentage display INT32 CurrentGroupNumber = 0; // Just in case there's a slow job already going on... SmashSlowJob(); String_64 SlowJob(_R(IDS_LIBRARY_SCANNING)); BeginSlowJob(Count, FALSE, &SlowJob); // Now use the index file to create each group in turn if (MainIndex.open(IndexFilePath, ios::in)) { MainIndex.SetWhitespace(""); // Setting this to blank lets us read non-"'d strings MainIndex.SetDelimiters(","); // ,s delimit our fields MainIndex.SetCommentMarker('#'); // #'d lines are commented out MainIndex.SetStringDelimiters(""); // No string delimiters String_64 Directory; String_64 Description; String_64 SubIndex; String_64 Kind; LexTokenType TT; BOOL EscapePressed = FALSE; while(ok && !EscapePressed) { if(!MainIndex.GetToken()) break; // Get SubLib directory name // Keep reading tokens until we hit a normal one... (skips line ends and // comments for us TT = MainIndex.GetTokenType(); while (TT != TOKEN_NORMAL && ok) { ok = MainIndex.GetToken(); if(!ok) break; TT = MainIndex.GetTokenType(); ok = (TT != TOKEN_EOF); if(!ok) break; } if(!ok) break; Directory = MainIndex.GetTokenBuf(); KillLeadingSpaces(&Directory); if(!MainIndex.GetToken()) break; // Get ',' if(!MainIndex.GetToken()) break; // Get Description String_256 Description256; Description256 = MainIndex.GetTokenBuf(); KillLeadingSpaces(&Description256); Description256.Left(&Description, 60); if(!MainIndex.GetToken()) break; // Get ',' if(!MainIndex.GetToken()) break; // Get Sub Library Index name SubIndex = MainIndex.GetTokenBuf(); KillLeadingSpaces(&SubIndex); if(!MainIndex.GetToken()) break; // Get ',' if(!MainIndex.GetToken()) break; // Get type of files in sublib Kind = MainIndex.GetTokenBuf(); KillLeadingSpaces(&Kind); BOOL Match = FALSE; Match = ParentLibraryGallery->CheckForIndexMatch(&Kind); if(Match) { // Show status of additions EscapePressed = !ContinueSlowJob(CurrentGroupNumber++); // Sort pathname of sublib directory out String_256 SubP(Path->GetPath(TRUE)); SubP += Directory; PathName SubPath(SubP); if(!SubPath.IsValid()) { ERROR3("LibraryFile::Init - invalid subpath"); if(MainIndex.isOpen()) MainIndex.close(); EndSlowJob(); return 0; } // Go ahead and add the new group if(ok) { // Create the sub lib Library *NewSubLib = new Library; if (NewSubLib != NULL) { // Create the new group in the gallery (note the TRUE for create a virtualised one if // we can to save time / memory) if(NewSubLib->Init(ParentGal, &SubPath, &Description, &SubIndex, Type, Updated, TRUE)) { Libraries.AddTail(NewSubLib); // Keep track of libraries added for redraw purposes... AddNewFolderToScrollRedrawSystem(NewSubLib); } else { // This check is new, should be ok... delete NewSubLib; NewSubLib = NULL; ERROR3("Library::Init failed in LibraryFile::Init"); ok = FALSE; } } } } } } else { // Failed to open the index file... // SetError?! ERROR3("LibraryFile::LibraryFile couldn't open index file"); ok = FALSE; } EndSlowJob(); } else { // The directory given had no XaraInfo\index.txt file, maybe it's a sublib, check // For defaults... ok = CheckForSubIndexes(ParentGal, Path, Type, Updated); } // reclaim lexer-buffer memory MainIndex.DeinitLexer(); // And close the file if(MainIndex.isOpen()) MainIndex.close(); // Scroll / redraw the newly added groups... if(DoScroll) DoScrollRedraw(); } else { TRACEUSER( "Richard", _T("Path doesn't exist\n")); } // And return the number of items created return(Libraries.GetCount()); #endif return 0; }
BOOL LibraryFile::CheckForSubIndexes(SuperGallery *ParentGal, PathName *Path, SGLibType Type, BOOL Updated) { // The directory given had no XaraInfo\index.txt file, maybe it's a sublib, check // For defaults... String_256 DefaultIndex; String_256 IndexDesc; BOOL CanGenerate; BOOL ok = TRUE; // Need to reset the Quiet status before a stream of Library::Init calls ParentLibraryGallery->SetQuietStatus(FALSE); if(GetSubIndexDetails(ParentLibraryGallery, &DefaultIndex, &IndexDesc, &CanGenerate)) { String_256 SubP(Path->GetPath(TRUE)); // "%s\\XaraInfo\\%s" SubP += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME)); SubP += TEXT("\\") + DefaultIndex; PathName SubPath(SubP); if(!SubPath.IsValid()) { ERROR3("LibraryFile::CheckForSubIndexes invalid subpath"); return FALSE; } BOOL Generate = FALSE; BOOL Found = FALSE; // Is there a default sub index ? Found = SGLibOil::FileExists(&SubPath); if(!Found && CanGenerate) { if(Library::RemoteIndexes && GenerateIndexFile::IsDirectoryReadOnly(Path)) { // Check whether there's a 'temporary' index for this directory, and // possibly use that instead of the read only directory... String_256 RemoteLocationOfIndex; BOOL Existing = GenerateIndexFile::CheckForRemote(Path, &RemoteLocationOfIndex); if(Existing) { String_256 SubP(RemoteLocationOfIndex); // %s\\XaraInfo\\%s SGLibOil::AppendSlashIfNotPresent(&SubP); SubP += String_16(_R(IDS_LIBRARIES_XARAINFO_DIRNAME)); SubP += TEXT("\\") + DefaultIndex; PathName TmpSubPath(SubP); Found = SGLibOil::FileExists(&TmpSubPath); // OK, so there's a remote index sitting pretty in the user's temporary // location... Use that and don't bother generating a new one... if(Found) { SubPath.SetPathName(SubP); Path->SetPathName(RemoteLocationOfIndex); } } } if(!Found) { // tell the user that there is no index file, and ask if they want one generating String_256 WarnMsg; String_256 TmpPath(SubPath.GetLocation(FALSE)); LibraryFile::TidyUpSubPath(&TmpPath); WarnMsg.MakeMsg(_R(IDS_LIBRARY_NO_INDEX_FILE_GEN), (TCHAR *)IndexDesc, (TCHAR *)TmpPath); Error::SetError(0, WarnMsg, 0); //INT32 ButtonPressed = InformMessage(0, _R(IDS_NOTHUMBNAILS), _R(IDS_THUMBNAILS), _R(IDS_CANCEL)/*, _R(IDS_HELP)*/); INT32 ButtonPressed = InformMessage(0, _R(IDS_CREATE), _R(IDS_CANCEL)); Error::ClearError(); if(ButtonPressed < 2) { // Generate an index... String_64 Author(PRODUCT_NAME); Generate = GenerateDefaultIndex(&SubPath, Path, &Author, Type, TRUE); ok = TRUE; } else { // Cancel or help clicked ok = FALSE; } } } if(!Found && !CanGenerate) { // tell the user that there is no index file, and give them a cancel... String_256 WarnMsg; String_256 TmpPath(SubPath.GetLocation(FALSE)); LibraryFile::TidyUpSubPath(&TmpPath); WarnMsg.MakeMsg(_R(IDS_LIBRARY_NO_INDEX_FILE), (TCHAR *)IndexDesc, (TCHAR *)TmpPath); Error::SetError(0, WarnMsg, 0); INT32 ButtonPressed = InformWarning(0, _R(IDS_CANCEL), NULL); Error::ClearError(); ok = FALSE; } // Check again... Found = SGLibOil::FileExists(&SubPath); if((Found && ok) || (!Found && Generate && ok)) { String_256 Description256 = Path->GetPath(); AbbreviateName(Description256, 60, TRUE); String_64 Description(Description256); BOOL DoAgain = TRUE; while (DoAgain) { DoAgain = FALSE; // Create the sub lib Library *NewSubLib = new Library; if (NewSubLib != NULL) { String_64 DefIndex64(DefaultIndex); String_256 PathToAdd256 = SubPath.GetLocation(FALSE); TidyUpSubPath(&PathToAdd256); PathName PathToAdd(PathToAdd256); Error::ClearError(); // Create the actual group itself if(NewSubLib->Init(ParentGal, &PathToAdd, &Description, &DefIndex64, Type, Updated)) { Libraries.AddTail(NewSubLib); ok = TRUE; // Keep track of libraries added for redraw purposes... AddNewFolderToScrollRedrawSystem(NewSubLib); } else { delete NewSubLib; NewSubLib = NULL; String_256 WarnMsg; String_256 SmallPath; PathToAdd256.Left(&SmallPath, 150); // "The index for '%s' seems to be invalid and requires updating." WarnMsg.MakeMsg(_R(IDS_LIBRARY_DODGY_INDEX), (TCHAR *)SmallPath); Error::SetError(0, WarnMsg, 0); INT32 Button = InformWarning(0, _R(IDS_GENERATE), _R(IDS_CANCEL)); Error::ClearError(); String_256 IPathToAdd256(PathToAdd256); SGLibOil::AppendSlashIfNotPresent(&IPathToAdd256); IPathToAdd256 += TEXT("indexfle.txt"); // This is just to check we can write ok... PathName IPathToAdd(IPathToAdd256); if(Button == 1) DoAgain = SGLibOil::GenerateClicked(ParentLibraryGallery, &IPathToAdd); if(!DoAgain) ok = FALSE; Error::ClearError(); } } } } } return ok; }
BOOL StringToBitmap::TTFAddString(String_256 *text, UINT32 Xsize, UINT32 Ysize, UINT32 DPI, PLOGFONT pLogFont, INT32 IntLeading, KernelBitmap **BM, UINT32 ForeColour) { KernelBitmap *Bitmap = *BM; /* HDC ScreenDC = CreateCompatibleDC(NULL); if (ScreenDC == NULL) { ERROR3("StringToBitmap::AddString: Unable to create screen DC"); return FALSE; }*/ CDC SysDisplay; BOOL ok=SysDisplay.CreateCompatibleDC(NULL); if(!ok) { //DeleteDC(ScreenDC); ERROR3("StringToBitmap::TTF AddString: Unable to create CDC"); return FALSE; } HDC ScreenDC = SysDisplay.m_hDC; // bodge to get things working with GetBezierFromChar INT32 OldlfHeight = pLogFont->lfHeight; pLogFont->lfHeight = -(pLogFont->lfHeight - IntLeading); UINT32 CurrentPathSizeAlloc = 0; Trans2DMatrix *pTransform = NULL; DocCoord *pPathCoords = NULL; Path *pPath = NULL; //pPath = new Path(); DocCoord *pPolyCordBuffer = NULL; PathVerb *pPolyVerbBuffer = NULL; UINT32 TextLength = (UINT32)text->Length(); SIZE StringSize= {0,0}; // Get handle of font // HFONT hNewFont = CreateFontIndirect(pLogFont); // HGDIOBJ hOldFont = SelectObject(ScreenDC, hNewFont); CFont UnHintedCFont; if(!UnHintedCFont.CreateFontIndirect(pLogFont)) { SysDisplay.DeleteDC(); pLogFont->lfHeight = OldlfHeight; return FALSE; } CFont* pOldCFont=SysDisplay.SelectObject(&UnHintedCFont); // Get the default character to use if a charater is not present in the font. WCHAR FontDefaultCharacter = (unsigned char)'?'; TEXTMETRIC FontTextData; #ifdef _UNCCODE if (SysDisplay.GetTextMetrics(&FontTextData)) FontDefaultCharacter = FontTextData.tmDefaultChar; #else if (SysDisplay.GetTextMetrics(&FontTextData)) FontDefaultCharacter = (unsigned char)FontTextData.tmDefaultChar; #endif // Work out a nice scaling factor so the font fits in the bitmap ok... // Not 32 ? GetTextExtentPoint(ScreenDC, *text, TextLength, &StringSize); if(StringSize.cy == 0) { SysDisplay.SelectObject(pOldCFont); SysDisplay.DeleteDC(); pLogFont->lfHeight = OldlfHeight; return FALSE; } //ERROR3IF(!ok, "Initial GetTextExtentPoint32() failed"); double YScale = ((double)Ysize / (double)StringSize.cy) / (double)2; double XScale = YScale; // Shift thumbnail upwards, and scale down a bit - to get the g's looking right // One or two fonts require this reducing (their tops are clipped), 72000/100 is // about right for most of them though... // Note the external previews were done with 72000/220 for Matrix and 72000/140 for // the capital only fonts. double YShift = 72000/100;//72000/80; YScale = (YScale * 78) / 100; XScale = (XScale * 78) / 100; if(!text->IsEmpty()) { const TCHAR* pCurrentChar = (const TCHAR*)(*text); while (ok && *pCurrentChar!=0) { // Get the current character as Unicode. #ifdef _UNICODE WCHAR wchr = *pCurrentChar; // pCurrentChar is a pointer to WCHAR in _UNICODE builds #else UINT32 CharToConvert = 0; if (UnicodeManager::IsDBCSLeadByte(*pCurrentChar)) CharToConvert = UnicodeManager::ComposeMultiBytes(*pCurrentChar, *(pCurrentChar+1)); else CharToConvert = (unsigned char)(*pCurrentChar); WCHAR wchr = UnicodeManager::MultiByteToUnicode(CharToConvert); #endif // Get positioning information for this character ok = GetTextExtentPoint(ScreenDC, *text, (pCurrentChar-(TCHAR*)(*text)), &StringSize); ERROR3IF(!ok, "GetTextExtentPoint32() failed"); if (!ok) break; // Get the characters path DWORD PathSize = 0; ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)NULL, (BYTE *)NULL); if (!ok) { wchr = FontDefaultCharacter; ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)NULL, (BYTE *)NULL); } ERROR3IF(!ok, "GetBezierFromChar returned false"); if (!ok) break; // Pointer to an array of path coordinates if(pPolyCordBuffer == NULL) { TRY { pPolyCordBuffer = new DocCoord[PathSize]; } CATCH (CMemoryException, e) { pPolyCordBuffer = NULL; /*ERROR(_R(IDS_OUT_OF_MEMORY), FALSE);*/ } END_CATCH } // Pointer to an array of path verbs if(pPolyVerbBuffer == NULL) { TRY { pPolyVerbBuffer = new PathVerb[PathSize]; } CATCH (CMemoryException, e) { pPolyVerbBuffer = NULL; /*ERROR(_R(IDS_OUT_OF_MEMORY), FALSE);*/ } END_CATCH } if (pPolyCordBuffer == NULL || pPolyVerbBuffer == NULL) { ok = FALSE; break; } CurrentPathSizeAlloc = PathSize; // Fill up the buffers until they're bursting with fontyness ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)pPolyCordBuffer, (BYTE *)pPolyVerbBuffer); if(!ok) TRACEUSER( "Richard", _T("GetBezierFromChar returned false in second phase...\n")); if(!ok) break; // Spaces set PathSize to zero if((PathSize > 0)/* && (pPath != NULL)*/) { pPath = new Path(); pPath->Initialise(PathSize, 12); pPath->CopyPathDataFrom(pPolyCordBuffer, pPolyVerbBuffer, PathSize, TRUE); // Major bodge at present with the x spacing... Matrix scale(XScale, 0, 0, YScale, (INT32)((XScale*StringSize.cx*72000)/(double)DPI), (INT32)YShift); pTransform = new Trans2DMatrix(scale); pPathCoords = pPath->GetCoordArray(); pTransform->Transform( pPathCoords, pPath->GetNumCoords() ); delete pTransform; pPath->InitialiseFlags(); ok = ALU->GradFillPath(pPath, ForeColour, ForeColour, 0, 0, 0,/*Xsize/2,*/ Ysize, S2BMP_ANTIALIAS); ERROR3IF(!ok, "Gradfillpath returned false"); if(!ok) break; delete pPath; } // S2BMP_MAGIC is the worderfully fabby constant that mark's getbezierfromchar returns // Theory goes that he's going to sort this out sometime... if(CurrentPathSizeAlloc != S2BMP_MAGIC) { delete []pPolyCordBuffer; delete []pPolyVerbBuffer; pPolyCordBuffer = NULL; pPolyVerbBuffer = NULL; CurrentPathSizeAlloc = 0; } pPath = NULL; pTransform = NULL; pCurrentChar = camStrinc(pCurrentChar); }
BOOL StringToBitmap::SaveBitmap(KernelBitmap *Bitmap, PathName *Path) { BOOL ok = TRUE; // if(Bitmap->GetBPP() != 32) // { // TRACEUSER( "Richard", _T("Can only save converted 32bpp thumbnails")); // return FALSE; // } // Get the file ready for outputting CCDiskFile OutputFile; PathName TmpPath(*Path); ok = OutputFile.open(TmpPath, ios::out | ios::binary); if(!ok) ERROR3("s2bmp OutputFile.open returned false"); if(!ok) return FALSE; // Always output at 8bpp or 32bpp const UINT32 OutputDepth = Bitmap->GetBPP(); if(OutputDepth != 8 && OutputDepth != 32) { ERROR3("Wrong bpp for saving bmp in fontpgen"); return FALSE; } // Extract the header info and write it to the file first BitmapInfo Info; BitmapInfo *lpInfo = &Info; ok = Bitmap->ActualBitmap->GetInfo(lpInfo); if(!ok) ERROR3("s2bmp Bitmap->ActualBitmap->GetInfo(lpInfo) returned false"); if(!ok) return FALSE; LPBITMAPINFOHEADER pBMI =&(((WinBitmap *)(Bitmap->ActualBitmap))->BMInfo->bmiHeader); ok = (pBMI!=NULL); if(!ok) ERROR3("s2bmp pBMI!=NULL returned false"); if(!ok) return FALSE; UINT32 Ysize = pBMI->biHeight; // Sort the palette out LPLOGPALETTE lpPalette = NULL; DWORD space[258]; // bodge (256 entries + 2 DWORDS) if(OutputDepth<=8) { //DWORD *space = malloc(sizeof(DWORD) * (2<<OutputDepth)+4); // bodge! lpPalette = (LPLOGPALETTE)(void *)(space); memcpy(lpPalette->palPalEntry /*dest*/, (pBMI+1/*ptr arith*/)/*src*/, (pBMI->biClrUsed)*sizeof(DWORD)); lpPalette->palVersion = 0x300; lpPalette->palNumEntries = (unsigned short)(pBMI->biClrUsed); } // Set up the compression flag only if the output depth is correct UINT32 Compress = BI_RGB; // if (OutputDepth==4) Compress = BI_RLE4; // if (OutputDepth==8) Compress = BI_RLE8; // Write header to output file OutputDIB DestDIB; BeginSlowJob(100, TRUE, &(String_64)"Creating thumbnail"); ok = DestDIB.StartFile( &OutputFile, pBMI, lpPalette, OutputDepth, // actual file depth Compress, // compression (BI_RGB = none) (UINT32) Ysize, // all of it 100); // size of progress bar if(!ok) ERROR3("DestDIB.StartFile returned false"); if(!ok) EndSlowJob(); if(!ok) return FALSE; // write main data to the output file ok = DestDIB.WriteBlock(0, Ysize, ((WinBitmap *)(Bitmap->ActualBitmap))->BMBytes, (UINT32) Bitmap->GetBPP()); if(!ok) ERROR3("DestDIB.WriteBlock returned false"); if(!ok) EndSlowJob(); if(!ok) return FALSE; // Tidy up the file before killing the object ok = DestDIB.TidyUp(); EndSlowJob(); if(!ok) ERROR3("DestDIB.TidyUp returned false"); if(!ok) return FALSE; return TRUE; }
BOOL UnitListComponent::ImportUserUnitDefinition(CXaraFileRecord* pCXaraFileRecord, Document * pDoc, INT32 Tag) { ERROR2IF(pCXaraFileRecord == NULL,FALSE,"UnitListComponent::ImportUserUnitDefinition called with no pCXaraFileRecord pointer"); ERROR2IF(pDoc == NULL,FALSE,"UnitListComponent::ImportUserUnitDefinition called with no doc pointer"); ERROR2IF(pDocUnitList == NULL,FALSE,"UnitListComponent::ImportUserUnitDefinition called with no doc unit list pointer"); Unit* pUnit = NULL; BOOL ok = TRUE; ok = pDocUnitList->MakeNewUnit(&pUnit); if (ok && pUnit) { BOOL Prefix = TRUE; switch (Tag) { case TAG_DEFINE_PREFIXUSERUNIT: Prefix = TRUE; break; case TAG_DEFINE_SUFFIXUSERUNIT: Prefix = FALSE; break; default: ERROR3("Bad tag in ImportUserUnitDefinition"); } pUnit->SetPrefixState(Prefix); // Read in the main full name of the unit String_32 Name; if (ok) ok = pCXaraFileRecord->ReadUnicode(&Name);//Name, Name.MaxLength()); if (ok) ok = pUnit->SetToken(Name); // And the abbreviation String_32 Abbrev; if (ok) ok = pCXaraFileRecord->ReadUnicode(&Abbrev);//Abbrev, Abbrev.MaxLength()); if (ok) ok = pUnit->SetSpecifier(Abbrev); // Read in the size of this unit, 0 means based on double UnitSize = 0.0; if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&UnitSize); if (ok) ok = pUnit->SetMillipoints(UnitSize); // Read in the exported base unit type INT32 ExportBaseUnit = 0L; if (ok) ok = pCXaraFileRecord->ReadINT32(&ExportBaseUnit); UnitType BasedOn = NOTYPE; // Convert this based on unit into the required forms Unit* pBasedOnUnit = GetReadUnitReference(ExportBaseUnit); if (pBasedOnUnit != NULL) { //BasedOn = GetUnitType(ExportBaseUnit); BasedOn = pBasedOnUnit->GetUnitType(); if (ok) ok = pUnit->SetBaseUnitType(BasedOn); } else { ERROR3("UserUnit has a bad unit on which it is based"); } // Read in the multipliers for this unit double BaseNumerator = 0.0; double BaseDenominator = 0.0; if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&BaseNumerator); if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&BaseDenominator); if (ok) ok = pUnit->SetBaseNumerator(BaseNumerator); if (ok) ok = pUnit->SetBaseDenominator(BaseDenominator); // Add the unit to the user units map so we can remember the references of the // imported units // Reference for this unit is the record number INT32 RecordNumber = pCXaraFileRecord->GetRecordNumber(); TRACEUSER( "Neville", _T("Imported user unit reference %d\n"), RecordNumber); (*pImpUserUnitMap)[ RecordNumber ] = pUnit; } // We will ignore any errors as we shouldn't not load a document because there is an // error in the units definition. We will just warn the user about a problem // If we have a pFilter then ask the default warning handle to append our message if (!ok && pCamFilter) { if (!WarnedBefore) { pCamFilter->AppendWarning(_R(IDS_NATIVE_UNITSWARNING)); WarnedBefore = TRUE; } } return TRUE; }
int main(int argc, char **argv) { PHASH freq = NewHash(); int freqfid, codefid; int nrSource, delta; double clk; int count = 0; INDATA srcFile, compFile; /* Must be passed the name of a file to compress */ if(argc < 2) { printf("Must give a file to compress\n"); exit(1); } TIMESTART(clk); initLFIOFile(&srcFile, argv[1]); /* Read the file, 2 bytes at a time and create the frequency table */ nrSource = 0; while(canFetch(&srcFile, 2)) { U16 wrd = fetchWordLE(&srcFile); nrSource += 2; bumpFrequency(freq, wrd); } finishIOFile(&srcFile); printf("Read %d bytes\n", nrSource); /* Open the code and frequency files */ freqfid = CREAT("huffman.freq"); codefid = CREAT("huffman.code"); compressfid = CREAT("huffman.compressed"); if(freqfid < 0 || codefid < 0 || compressfid < 0) { ERROR0(1, "Cannot create frequency and code files\n"); } createCompressTables(freq, freqfid, codefid); close(freqfid); close(codefid); FreeHash(freq); /* Now read again and compress */ initCompressor("huffman.code"); initLFIOFile(&srcFile, argv[1]); outPoint = 0; written = 0; startCompress(&writeByte); /* Read the file, 2 bytes at a time and compress */ while(canFetch(&srcFile, 2)) { U16 wrd = fetchWordLE(&srcFile); writeCompressedSymbol(wrd); } endCompress(); flushOut(); close(compressfid); finishIOFile(&srcFile); /* Now decompress and compare */ for(count=0;count<30;count++) { initLFIOFile(&compFile, "huffman.compressed"); initLFIOFile(&srcFile, argv[1]); startDecompress(); delta = nrSource; while(delta > 0) { int comp = fetchCompressedSymbol(&compFile); int src = fetchWordLE(&srcFile); if(src != comp) { ERROR3(-1, "Src(%04x) != Comp(%04x) (at offset %d)\n", src, comp, nrSource - delta); } delta -= 2; } endDecompress(&compFile); finishIOFile(&srcFile); finishIOFile(&compFile); } finalizeCompressor(); TIMESTOP(clk); // sm: according to my man pages, the 'l' flag doesn't apply // to the 'f' format, which is always a double argument printf("Source %d bytes. Compressed %d bytes. Ratio: %5.2f\n", nrSource, written, (double)nrSource / (double)written); printf("Run hufftest in %8.3fms\n", clk / 1000.0); exit (0); return 0; }
ColourDragInformation::ColourDragInformation() { ERROR3("Default ColourDragInformation constructor called"); InitObject(); }
BOOL BfxPixelOp::IsPixelReallyInRegion(INT32 x, INT32 y) { ERROR3("How come base class BfxPixelOp::IsPixelReallyInRegion has got called?"); return DefaultValue; }
BOOL LibraryFile::AddSpecificIndex(SuperGallery *ParentGal, PathName *Path, SGLibType Type, StringBase *Description, UINT32 bModified, BOOL bIsWebLib) { if(ParentGal == NULL || Path == NULL || !Libraries.IsEmpty() || !Path->IsValid()) { ERROR3("LibraryFile::AddSpecificIndex - Problems on entry"); return FALSE; } // Check the path for the library exists // if(!SGLibOil::FileExists(Path)) // return FALSE; // Remember the pathname and type MyPath = *Path; MyType = Type; ParentGallery = ParentGal; // Create the sub lib Library *NewSubLib = new Library; if (NewSubLib != NULL) { // Path = "C:\testlib\animals\xarainfo\animals.txt" // Path of files themselves... FilesPath = "C:\testlib\animals" NewSubLib->m_bIsWebLib = bIsWebLib; PathName TmpPath(Path->GetLocation(FALSE)); NewSubLib->SetModified(bModified); // If it's a root directory we need the slash... PathName FilesPath; String_256 TmpRootCheck(TmpPath.GetLocation(TRUE)); if(SGLibOil::IsRootDirectory(&TmpRootCheck)) FilesPath.SetPathName(TmpPath.GetLocation(TRUE)); else FilesPath.SetPathName(TmpPath.GetLocation(FALSE)); // Default title for the new group String_256 Desc256; String_64 Desc64; if(Description == NULL) Desc256 = Path->GetTruncatedPath(60); else Desc256 = *Description; Desc256.Left(&Desc64, 64); // The filename of the index String_64 IndexFilename(Path->GetFileName(TRUE)); // Add this new index to the library file and scan it in... if(NewSubLib->Init(ParentGal, &FilesPath, &Desc64, &IndexFilename, Type, FALSE, (Description != NULL))) { Libraries.AddTail(NewSubLib); // Keep track of libraries added for redraw purposes... AddNewFolderToScrollRedrawSystem(NewSubLib); return TRUE; } else { // if there was a problem, don't go round leaving memory everywhere... delete NewSubLib; NewSubLib = NULL; } } // Nothing added return FALSE; }
BOOL ProcessPathToTrapezoids::NewPoint(PathVerb Verb, DocCoord *pCoord) { // Process any join we've just gone past. We have to delay processing of joins // until we know which way the curve headed off after the join, which is why // we are processing it now. If the new point is a MOVETO, then there is no join if (PointFollowsJoin && Verb == PT_LINETO) { // Find the last edge in the current edge list. If we can't find one, there is // nothing to "join to" TrapEdgeList *pEdgeList = pTraps->GetLastTrapEdgeList(); TrapEdge *pEdge = NULL; if (pEdgeList != NULL) pEdge = pEdgeList->GetLastTrapEdge(); if (pEdge != NULL) { switch(JoinType) { case MitreJoin: // A mitred join involves extending the previous and next segments of the outline // to their intersection. If there is no intersection, or if the intersection // is beyond the "MitreLimit", then we revert to a simple Bevelled join. // Otherwise, we need to add 2 line segments (3 trapezoid edges) joining the // end of the last segment to the intersection, and then from the intersection // to the start of this new segment. // These new segments are marked as being part of a join so that they will be // stroked as straight line segments rather than interpolating normals to make // a smoothed/curved join. { ERROR3IF(pEdgeList->GetNumEdges() < 2, "Not enough traps for mitred join"); TrapEdge *pPrevEdge = pEdgeList->GetTrapEdge(pEdgeList->GetNumEdges() - 2); BOOL Mitred; if (pCoord != NULL) { Mitred = CalculateMitreIntersection(&pPrevEdge->Centre, &pEdge->Centre, pCoord); } else { // No pCoord passed in, so this is the join at the end. Use the 1st point // in the subpath as the "next point". (Well, the 2nd in the array, because point // 1 is coincident! We use point 2 which is the end of the 1st line) DocCoord NextCoord = pEdgeList->GetTrapEdge(1)->Centre; Mitred = CalculateMitreIntersection(&pPrevEdge->Centre, &pEdge->Centre, &NextCoord); } //BLOCK { // Nasty bodge - Because AddEdge can re-alloc the array, we CANNOT keep pointers // to array entries around over calls to AddEdge. We thus copy the edge point // into a temporary variable which we can safely use over the 2 calls the AddEdge DocCoord Temp = pEdge->Centre; // Add a single point for this join - by default this gives a Bevelled join pEdgeList->AddEdge(&Temp, TrapJoin_MitredOrBevelled); // And if it's Mitred, then add another point for this join if (Mitred) pEdgeList->AddEdge(&Temp, TrapJoin_MitredOrBevelled); } } break; case RoundJoin: // To make a rounded join, you might think we need to output a number of trapezoids, // but in fact the recursive flattened-mapping algorithm employed by the path // stroker will "smooth" a single trapezoid into a proper round join! // Thus, we simply insert another trapezoid on the join point (but do NOT mark // it as "part of a join") so that it will be mapped as a round join. pEdgeList->AddEdge(&pEdge->Centre, TrapJoin_Round); break; case BevelledJoin: // To make a bevelled join, we simply add another TrapEdge on the join point for // the start of the next segment, which will be joined with a straight line. // However, the stroking mechanism will actually output that "line" as a round // join (due to its recursive flattened-mapping algorithm), so we have to // mark this point as "part of a join" so that it simply plonks down the // straight segment we want! (Hence the TRUE) pEdgeList->AddEdge(&pEdge->Centre, TrapJoin_MitredOrBevelled); break; default: ERROR3("Unsupported join type in ProcessPathToTrapezoids"); break; } } } // Clear the join flag, as any pending join has been processed PointFollowsJoin = FALSE; // If the provided coordinate was NULL, then they only wanted to add the join // information, so we exit now if (pCoord == NULL) return(TRUE); // Add the new point to the current trapezoid list switch(Verb) { case PT_MOVETO: { // A MoveTo signifies the start of a new (sub)path, so we start a new TrapList TrapEdgeList *pEdgeList = pTraps->AddEdgeList(); if (pEdgeList == NULL) return(FALSE); pEdgeList->AddEdge(pCoord); LastPoint = *pCoord; } break; case PT_LINETO: { // Append each new point as a new trapezoid edge in the current TrapList // Find the last TrapEdgeList TrapEdgeList *pEdgeList = pTraps->GetLastTrapEdgeList(); if (pEdgeList == NULL) { // We have started a path with a LineTo! // Create a new Trapezoid List (imply that this point is really a MOVETO) ERROR3("LINETO added to traplist with no preceding MOVETO"); LastPoint = DocCoord(0,0); pEdgeList = pTraps->AddEdgeList(); if (pEdgeList == NULL) return(FALSE); } // Append the new point to the current trap list. Check first to eliminate // coincident points (places where the source path has coincident points), // as we only want coincident points to occur in the special case of joins. if (pEdgeList->GetNumEdges() < 1 || LastPoint != *pCoord) { pEdgeList->AddEdge(pCoord); LastPoint = *pCoord; } } break; default: ERROR3("ProcessPathToTrapezoids only handles MOVETO and LINETO!"); break; } return(TRUE); }
/* Actually open the connection and do some http parsing, handle any 302 * responses within here. */ static int open_relay_connection (client_t *client, relay_server *relay, relay_server_master *master) { int redirects = 0; http_parser_t *parser = NULL; connection_t *con = &client->connection; char *server = strdup (master->ip); char *mount = strdup (master->mount); int port = master->port, timeout = master->timeout, ask_for_metadata = relay->mp3metadata; char *auth_header = NULL; if (relay->username && relay->password) { char *esc_authorisation; unsigned len = strlen(relay->username) + strlen(relay->password) + 2; DEBUG2 ("using username %s for %s", relay->username, relay->localmount); auth_header = malloc (len); snprintf (auth_header, len, "%s:%s", relay->username, relay->password); esc_authorisation = util_base64_encode(auth_header); free(auth_header); len = strlen (esc_authorisation) + 24; auth_header = malloc (len); snprintf (auth_header, len, "Authorization: Basic %s\r\n", esc_authorisation); free(esc_authorisation); } while (redirects < 10) { sock_t streamsock; char *bind = NULL; /* policy decision, we assume a source bind even after redirect, possible option */ if (master->bind) bind = strdup (master->bind); if (bind) INFO4 ("connecting to %s:%d for %s, bound to %s", server, port, relay->localmount, bind); else INFO3 ("connecting to %s:%d for %s", server, port, relay->localmount); con->con_time = time (NULL); relay->in_use = master; streamsock = sock_connect_wto_bind (server, port, bind, timeout); free (bind); if (connection_init (con, streamsock, server) < 0) { WARN2 ("Failed to connect to %s:%d", server, port); break; } parser = get_relay_response (con, mount, server, ask_for_metadata, auth_header); if (parser == NULL) { ERROR4 ("Problem trying to start relay on %s (%s:%d%s)", relay->localmount, server, port, mount); break; } if (strcmp (httpp_getvar (parser, HTTPP_VAR_ERROR_CODE), "302") == 0) { /* better retry the connection again but with different details */ const char *uri, *mountpoint; int len; uri = httpp_getvar (parser, "location"); INFO1 ("redirect received %s", uri); if (strncmp (uri, "http://", 7) != 0) break; uri += 7; mountpoint = strchr (uri, '/'); free (mount); if (mountpoint) mount = strdup (mountpoint); else mount = strdup ("/"); len = strcspn (uri, ":/"); port = 80; if (uri [len] == ':') port = atoi (uri+len+1); free (server); server = calloc (1, len+1); strncpy (server, uri, len); connection_close (con); httpp_destroy (parser); parser = NULL; } else { if (httpp_getvar (parser, HTTPP_VAR_ERROR_MESSAGE)) { ERROR3 ("Error from relay request on %s (%s %s)", relay->localmount, master->mount, httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE)); client->parser = NULL; break; } sock_set_blocking (streamsock, 0); thread_rwlock_wlock (&relay->source->lock); client->parser = parser; // old parser will be free in the format clear thread_rwlock_unlock (&relay->source->lock); client->connection.discon_time = 0; client->connection.con_time = time (NULL); client_set_queue (client, NULL); free (server); free (mount); free (auth_header); return 0; } redirects++; } /* failed, better clean up */ free (server); free (mount); free (auth_header); if (parser) httpp_destroy (parser); connection_close (con); con->con_time = time (NULL); // sources count needs to drop in such cases if (relay->in_use) relay->in_use->skip = 1; return -1; }
/******************************************************************************************** > 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, ¶m ); SliceHelper::RestoreSelection(); }
int auth_htpasswd_deleteuser(auth_t *auth, char *username) { FILE *passwdfile; FILE *tmp_passwdfile; htpasswd_auth_state *state; char line[MAX_LINE_LEN]; char *sep; char *tmpfile = NULL; int tmpfile_len = 0; state = auth->state; passwdfile = fopen(state->filename, "rb"); if(passwdfile == NULL) { WARN2("Failed to open authentication database \"%s\": %s", state->filename, strerror(errno)); return AUTH_FAILED; } tmpfile_len = strlen(state->filename) + 6; tmpfile = calloc(1, tmpfile_len); sprintf(tmpfile, ".%s.tmp", state->filename); tmp_passwdfile = fopen(tmpfile, "wb"); if(tmp_passwdfile == NULL) { WARN2("Failed to open temporary authentication database \"%s\": %s", tmpfile, strerror(errno)); fclose(passwdfile); free(tmpfile); return AUTH_FAILED; } while(get_line(passwdfile, line, MAX_LINE_LEN)) { if(!line[0] || line[0] == '#') continue; sep = strchr(line, ':'); if(sep == NULL) { DEBUG0("No seperator in line"); continue; } *sep = 0; if (strcmp(username, line)) { /* We did not match on the user, so copy it to the temp file */ /* and put the : back in */ *sep = ':'; fprintf(tmp_passwdfile, "%s\n", line); } } fclose(tmp_passwdfile); fclose(passwdfile); /* Now move the contents of the tmp file to the original */ #ifdef _WIN32 /* Windows won't let us rename a file if the destination file exists...so, lets remove the original first */ if (remove(state->filename) != 0) { ERROR3("Problem moving temp authentication file to original \"%s\" - \"%s\": %s", tmpfile, state->filename, strerror(errno)); } else { #endif if (rename(tmpfile, state->filename) != 0) { ERROR3("Problem moving temp authentication file to original \"%s\" - \"%s\": %s", tmpfile, state->filename, strerror(errno)); } #ifdef _WIN32 } #endif free(tmpfile); return AUTH_USERDELETED; }
const VisibleListIterator& VisibleListIterator::operator=(const VisibleListIterator& Other) { ERROR3("VisibleListIterator - assignment operator not implemented\n"); return *this; }
PrintComponent::PrintComponent() { ERROR3("PrintComponent constructed with default constructor!?\n"); pPrCtrl = NULL; pExportDC = NULL; }
const EditableText& EditableText::operator=(const EditableText& Other) { ERROR3("EditableText - assignment operator not implemented\n"); return *this; }
/******************************************************************************************* > BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions) Author: Stefan_Stoykov (Xara Group Ltd) <*****@*****.**> Created: 24/6/97 Inputs: BrowserOptions - the options for generating the html page Purpose: Generate a html file which includes our bitmap, together with some other optional stuff. Used for browser preview. *******************************************************************************************/ BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions) { PORTNOTE("other","Removed _R(IDD_TIMAPOPTIONS) - isn't wanted yet") #ifndef EXCLUDE_FROM_XARALX // sanity checks // check for export options ERROR3IF(m_pOptions == NULL, "BitmapPreviewData::GenerateHTMLStub - need export options"); if (m_pOptions == NULL) // we need export options return FALSE; // get the path for the exported bitmap from the options PathName TempPath = m_pOptions->GetPathName(); // check for exported bitmap ERROR3IF((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE), "BitmapPreviewData::GenerateHTMLStub - need exported bitmap"); if ((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE)) return FALSE; // delete the previous temp file, if any if (m_pTempHTMLPath != NULL) FileUtil::DeleteFile(m_pTempHTMLPath); else m_pTempHTMLPath = new PathName; // safety check if (m_pTempHTMLPath == NULL) return FALSE; // create a new temp file if (FileUtil::GetTemporaryPathName( _T("htm"),m_pTempHTMLPath) == FALSE) { delete m_pTempHTMLPath; m_pTempHTMLPath = NULL; return FALSE; } // start creating the html page // create a disk file CCDiskFile TempDiskFile(1024, FALSE, TRUE); // get path name to server, so we can find the logo bitmaps CString str; AfxGetModuleShortFileName(AfxGetInstanceHandle(), str); String_256 strPathName(str.GetBuffer(0)); // create a path name object from the program name PathName ProgramPath(strPathName); try { // open it for reading if (!TempDiskFile.open(*m_pTempHTMLPath, ios::out)) return FALSE; // output header String_256 s(_R(IDS_HTML_HEAD)); TempDiskFile.write(s); // set the background attributes switch (BrowserOptions.m_Background) { case BROWSER_BGR_DOC: { // set the background from the document page if (!SetBackgroundFromPage(TempDiskFile, BrowserOptions.m_pSpread)) ERROR3("Setting the html background from the document page failed\n"); } break; case BROWSER_BGR_CHECKER: { // display the checkered bitmap as background // get the checkered bitmap name String_256 Checker(_R(IDS_HTML_CHECKER)); // set it in the path ProgramPath.SetFileNameAndType(Checker); // set the checkered bitmap as background image s.MakeMsg(_R(IDS_CHECK_BACK), (TCHAR *)ProgramPath.GetWebAddress()); TempDiskFile.write(s); } break; case BROWSER_BGR_BITMAP: { // set our bitmap as background image s.MakeMsg(_R(IDS_BITMAPED_BACKGROUND), (TCHAR *)TempPath.GetWebAddress()); TempDiskFile.write(s); } break; case BROWSER_BGR_NONE: { String_256 background(_R(IDS_PLAIN_BACKGROUND)); TempDiskFile.write(background); } break; default: ERROR3("Unknown type of BrowserOptions.m_Background"); break; } // end of switch(BrowserOptions.m_Background) block // Get a pointer to the actual bitmap so that we can get some details from it. // OILBitmap *pOilBitmap = m_pBitmap->ActualBitmap; // ERROR3IF(pOilBitmap == NULL,"BitmapPreviewData::GenerateBitmapInfoStrings NULL oil bitmap pointer"); // Get the details from the specified bitmap // BitmapInfo BmInfo; // pOilBitmap->GetInfo(&BmInfo); // output our bitmap, but only if it wasn't already set as background String_256 s2(_R(IDS_PAGE_TITLE)); TempDiskFile.write(s2); if (BrowserOptions.m_Background != BROWSER_BGR_BITMAP) { // output the bitmap if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) { // GIF animation s.MakeMsg(_R(IDS_DISPLAY_PIC), (const TCHAR *)TempPath.GetFileName()); } else { if( m_pOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) || m_pOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME) || m_pOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP) ) { s.MakeMsg(_R(IDS_DISPLAY_BMP), (const TCHAR *)TempPath.GetFileName()); } else if( m_pOptions->GetFilterNameStrID() == _R(IDS_FILTERNAME_PNG) ) s.MakeMsg(_R(IDS_DISPLAY_PNG), (const TCHAR *)TempPath.GetFileName()); } TempDiskFile.write(s); } else { s.MakeMsg(_R(IDS_EMPTY_BOX)); TempDiskFile.write(s); } switch (m_pOptions->GetFilterNameStrID()) { case _R(IDT_FILTERNAME_BMP): s2.MakeMsg(_R(IDS_BMP_MESSAGE)); s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2); TempDiskFile.write(s); break; case _R(IDS_FILTERNAME_PNG): s2.MakeMsg(_R(IDS_PNG_MESSAGE)); s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2); TempDiskFile.write(s); break; } // end of switch(m_pOptions->GetFilterNameStrID()) s.MakeMsg(_R(IDS_DETAILS_BUILD)); TempDiskFile.write(s); // output the bitmap info, if requested if (BrowserOptions.m_bInfo != FALSE) { String_64 ImageSize; String_64 FileSize; BOOL m_bTransparent = FALSE; INT32 count; count=0; // generate the info strings if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) { // This is actually the export animated GIF using the frame gallery system MakeBitmapExportOptions* pMkBOptions = (MakeBitmapExportOptions*)m_pOptions; ERROR3IF(!pMkBOptions->IS_KIND_OF(MakeBitmapExportOptions), "pMkBOptions isn't"); PALETTE Palette = PAL_OPTIMISED; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); // Palette = pMkBOptions->GetPalette(); DitherType = pMkBOptions->GetDither(); colDepth = pMkBOptions->GetDepth(); s2.MakeMsg(_R(IDS_ANIMATED_GIF)); if (pMkBOptions->WantTransparent()) { s2.MakeMsg(_R(IDS_TRANSPARENT),"animated GIF"); } s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } switch (colDepth) { case 32: case 24: s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); break; case 8: { // Include the transparent colour in the colour depth check UINT32 RealNumberOfColours = NoOfColours; if (colDepth <= 8 && pMkBOptions->WantTransparent()) { UINT32 MaxColours = UINT32(pow(2,colDepth)); RealNumberOfColours++; if (RealNumberOfColours > MaxColours) RealNumberOfColours = MaxColours; } // We say 8 but we really mean the number of colours deep // We cannot say 2 colours = 2bpp as we save it as 10 colours due // to having 1 transparent colour and the usual lets pick 10 as the // transparent colour. Cannot allow the user to choose 1 as the code // then outputs 8bpp as GRenderOptPalette::GetOptimisedPalette has the // test if (ReservedColours < NumColours), which fails. /* if (RealNumberOfColours <= 2) s2.MakeMsg(_R(IDS_PALETTEINFO),2,NoOfColours,(const TCHAR*)sPalette); else */ if (RealNumberOfColours <= 16) s2.MakeMsg(_R(IDS_PALETTEINFO),4,NoOfColours,(const TCHAR*)sPalette); else s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); break; } case 1: s2.MakeMsg(_R(IDS_MONO),colDepth); break; case 4: default: s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); break; } TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) block ends else { switch (m_pOptions->GetFilterNameStrID()) { case _R(IDN_FILTERNAME_GIF): { GIFExportOptions* pGIFOptions = (GIFExportOptions*)m_pOptions; ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't"); PALETTE Palette = PAL_OPTIMISED; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); // Palette = pGIFOptions->GetPalette(); DitherType = pGIFOptions->GetDither(); colDepth = pGIFOptions->GetDepth(); if (pGIFOptions->WantTransparent()) count=count+1; if (pGIFOptions->WantInterlaced()) count=count+2; s.MakeMsg(_R(IDS_GIF)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); switch (count) { case 1: s2.MakeMsg(_R(IDS_TRANSPARENT),"GIF"); break; case 2: s2.MakeMsg(_R(IDS_INTERLACED),"GIF"); break; case 3: s2.MakeMsg(_R(IDS_INTER_TRANS),"GIF"); break; case 0: break; } s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 8) s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 1) s2.MakeMsg(_R(IDS_MONO),colDepth); if (colDepth > 8) s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // end case _R(IDN_FILTERNAME_GIF) break; case _R(IDS_JPG_EXP_FILTERNAME): { JPEGExportOptions* pJPEGOptions = (JPEGExportOptions *)m_pOptions; ERROR3IF(!pJPEGOptions->IS_KIND_OF(JPEGExportOptions), "pJPEGOptions isn't"); INT32 Quality = pJPEGOptions->GetQuality(); // Default Quality BOOL Progressive = pJPEGOptions->DoAsProgressive(); if (Quality > 100) Quality = 100; s.MakeMsg(_R(IDS_JPEG)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); if (Progressive) s2.MakeMsg(_R(IDS_PROGRESSIVE)); s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); s.MakeMsg(_R(IDS_JCOMPRESSION),Quality); TempDiskFile.write(s); } // end case _R(IDS_JPG_EXP_FILTERNAME) break; case _R(IDT_FILTERNAME_BMP): { BMPExportOptions* pBMPOptions = (BMPExportOptions*)m_pOptions; ERROR3IF(!pBMPOptions->IS_KIND_OF(BMPExportOptions), "pBMPOptions isn't"); PALETTE Palette; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); Palette = pBMPOptions->GetPalette(); DitherType = pBMPOptions->GetDither(); colDepth = pBMPOptions->GetDepth(); s.MakeMsg(_R(IDS_BMP)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } if (colDepth == 8 && NoOfColours > 256) NoOfColours = 256; s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 8) s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 1) s2.MakeMsg(_R(IDS_MONO),colDepth); if (colDepth > 8) s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // end case _R(IDT_FILTERNAME_BMP) break; case _R(IDS_FILTERNAME_PNG): { PNGExportOptions* pPNGOptions = (PNGExportOptions*)m_pOptions; ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't"); PALETTE Palette = PAL_OPTIMISED; DITHER DitherType; UINT32 colDepth; String_64 sPalette; String_64 Dither; UINT32 NoOfColours; NoOfColours=m_pOptions->GetNumColsInPalette(); // Palette = pPNGOptions->GetPalette(); DitherType = pPNGOptions->GetDither(); colDepth = pPNGOptions->GetDepth(); if (pPNGOptions->WantTransparent()) count=count+1; if (pPNGOptions->WantInterlaced()) count=count+2; s.MakeMsg(_R(IDS_PNG)); s2.MakeMsg(_R(IDS_A), (const TCHAR*)s); switch (count) { case 1: s2.MakeMsg(_R(IDS_TRANSPARENT),"PNG"); break; case 2: s2.MakeMsg(_R(IDS_INTERLACED),"PNG"); break; case 3: s2.MakeMsg(_R(IDS_INTER_TRANS),"PNG"); break; case 0: break; } s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2); TempDiskFile.write(s); switch (Palette) { case PAL_OPTIMISED: sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL)); break; case PAL_BROWSER: case PAL_STANDARD: sPalette.MakeMsg(_R(IDS_BROWSER_PAL)); break; case PAL_GLOBALOPTIMISED: sPalette.MakeMsg(_R(IDS_GLOBAL_OPT)); break; } if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) ) { NoOfColours = 216; } s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 8) s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette); if (colDepth == 1) s2.MakeMsg(_R(IDS_MONO),colDepth); if (colDepth > 8) s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth); TempDiskFile.write(s2); s.MakeMsg(_R(IDS_NODITHER)); switch (DitherType) { case XARADITHER_ORDERED: case XARADITHER_ORDERED_GREY: Dither.MakeMsg(_R(IDS_DITH_ORDER)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_ERROR_DIFFUSION: case XARADITHER_SIMPLE: Dither.MakeMsg(_R(IDS_DITH_ERROR)); s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither); break; case XARADITHER_NONE: s.MakeMsg(_R(IDS_NODITHER)); break; } TempDiskFile.write(s); } // end case _R(IDS_FILTERNAME_PNG) break; } // end switch (m_pOptions->GetFilterNameStrID()) } // end else block GenerateBitmapInfoStrings(ImageSize, FileSize); // output the bitmap info s.MakeMsg(_R(IDS_HTML_INFO1), (TCHAR *)ImageSize); TempDiskFile.write(s); // output the bitmap file size info s.MakeMsg(_R(IDS_HTML_INFO2), (TCHAR *)FileSize); TempDiskFile.write(s); s.MakeMsg(_R(IDS_CLOSE_CENTER)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TDTR_CLOSE)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_BANNER_BOX)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_SPEED_BUILD)); TempDiskFile.write(s); // s.MakeMsg(_R(IDS_SPEED_BUILD2)); // TempDiskFile.write(s); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); String_64 times; s.MakeMsg(_R(IDS_TIME_ENTRY),"14.4k"); TempDiskFile.write(s); CalculateTime(times,14400.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"28.8k"); TempDiskFile.write(s); CalculateTime(times,28800.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"33.6k"); TempDiskFile.write(s); CalculateTime(times,33600.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"57.6k"); TempDiskFile.write(s); CalculateTime(times,57600.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"64k"); TempDiskFile.write(s); CalculateTime(times,65536.0); TempDiskFile.write(times); s.MakeMsg(_R(IDS_ES_TR)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_TIME_ENTRY),"128k"); TempDiskFile.write(s); CalculateTime(times,131072.0); TempDiskFile.write(times); // s.MakeMsg(_R(IDS_ES_TR)); // TempDiskFile.write(s); s.MakeMsg(_R(IDS_SPEED_END)); TempDiskFile.write(s); TRACE( _T("m_FileSize = %d"), m_FileSize); } // end of if (BrowserOptions.m_bInfo != FALSE) String_64 webaddy(_R(IDS_HTML_URL_PROGRAM)); //Mark Howitt, 29/10/97. Setup the _R(IDS_HTML_URL_VISITMSG) To be a TCHAR* Also. It likes it that way! String_64 webvmess(_R(IDS_HTML_URL_VISITMSG)); s.MakeMsg(_R(IDS_LINK_BOX),(TCHAR *)webaddy,(TCHAR *)webvmess); TempDiskFile.write(s); //end of my stuff s.MakeMsg(_R(IDS_END_TABLE)); TempDiskFile.write(s); s.MakeMsg(_R(IDS_CLOSE_CENTER)); TempDiskFile.write(s); // output the "Exported from" string // get the xara logo file name String_256 Logo(_R(IDS_HTML_XARALOGO)); // set it in the path ProgramPath.SetFileNameAndType(Logo); // get the xara link String_256 URL(_R(IDS_HTML_URL_XARA)); // output the xara link and the xara logo s.MakeMsg(_R(IDS_HTML_XARA), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress()); TempDiskFile.write(s); // Do not display the Xara X logo bottom right... /* // get the program logo file name Logo.Load(_R(IDS_HTML_PROGRAMLOGO)); // set it in the path ProgramPath.SetFileNameAndType(Logo); // output the program link URL.Load(_R(IDS_HTML_URL_PROGRAM)); s.MakeMsg(_R(IDS_HTML_PROGRAM), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress()); TempDiskFile.write(s); */ // output the end of the file s.Load(_R(IDS_HTML_END)); TempDiskFile.write(s); // close the file TempDiskFile.close(); // now export the image map, if the option for that is set if (BrowserOptions.m_bImagemap != FALSE) { // export the image map ExportImagemap( TempDiskFile, m_pTempHTMLPath, m_pOptions->GetSelectionType(), m_pOptions->GetDPI(), BrowserOptions.m_ifoImagemapOptions); } TCHAR *FileWebAddress = m_pTempHTMLPath->GetWebAddress(); //Graham 17/9/97 ProgramPath.SetFileNameAndType(PRODUCT_WEBLINKEXENAME); const TCHAR *PathToWebLink = (const TCHAR *)ProgramPath.GetPath(); String_256 CmdLine = PathToWebLink + String_256(" -f ") + FileWebAddress; //TCHAR *CommandLine = (TCHAR *)CmdLine; if (!InvokeWeblink(CmdLine)) return FALSE; } // end of TRY block catch( CFileException ) { // any disk problems - come here // not much we can do really - just close the file and return FALSE if (TempDiskFile.isOpen()) TempDiskFile.close(); return FALSE; } #endif return TRUE; }
/******************************************************************************************** > 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(); }
SGDisplayDATATYPE::SGDisplayDATATYPE() { ERROR3("Illegal call on default SGDisplayDATATYPE constructor - call the other one!"); TheDATATYPE = NULL; }
BOOL DragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo, OilCoord *pMousePos, KeyPress* pKeyPress) { ERROR3("Illegal call to DragTarget::ProcessEvent - I'm not a KERNEL Target!"); return(FALSE); // We do not claim the event }
BOOL Octree::Insert(INT32 r, INT32 g, INT32 b) { //CheckIntegrity(); OctreeElement * pEl = GetElement(r, g, b); if (!pEl) return FALSE; // Insert any necessary intermediates while (pEl->Depth !=8) { OctreeElement * pNewEl = new OctreeElement; if (!pNewEl) return FALSE; pNewEl->Depth=pEl->Depth+1; INT32 halfwidth=(1<<(8 - pEl->Depth))>>1; INT32 R=pEl->R+halfwidth; INT32 G=pEl->G+halfwidth; INT32 B=pEl->B+halfwidth; pNewEl->R=(r>=R)?R:(pEl->R); pNewEl->G=(g>=G)?G:(pEl->G); pNewEl->B=(b>=B)?B:(pEl->B); INT32 child=((r>=R)?1:0)+((g>=G)?2:0)+((b>=B)?4:0); ERROR2IF(pEl->pChildren[child], FALSE, "Blurk! Octree element already has a child"); pEl->pChildren[child]=pNewEl; pNewEl->pParent=pEl; Unlink(pEl); pEl->NumChildren++; Link(pEl); pEl=pNewEl; Link(pEl); //CheckIntegrity(); } if (!pEl->Pixels) CurrentLeaves++; pEl->Pixels++; while (CurrentLeaves>MaxLeaves) { pEl=NULL; // Seatch deepest in the tree first ... for (INT32 d=8; (d>=0) && !pEl; d--) { // ... for an element with no children ... OctreeElement * plEl=ListHead[d][0]; while (plEl && !pEl) { // ... which has a parent ... pEl=plEl->pParent; // ... whose children have no children themselves for (INT32 c=0; (c<8) && pEl; c++) if (pEl->pChildren[c] && pEl->pChildren[c]->NumChildren) pEl=NULL; plEl=plEl->pListNext; } } if (pEl) { Unlink(pEl); if (!pEl->Pixels) CurrentLeaves++; for (INT32 c=0; c<8; c++) if (pEl->pChildren[c]) { pEl->Pixels+=pEl->pChildren[c]->Pixels; Unlink (pEl->pChildren[c]); pEl->NumChildren--; ERROR3IF(pEl->pChildren[c]->NumChildren, "OK, why have I been given an octree element with children?"); delete pEl->pChildren[c]; pEl->pChildren[c]=NULL; CurrentLeaves--; } Link(pEl); //CheckIntegrity(); } else { ERROR3("Can't find a candidate for combining octree"); break; } } return TRUE; }
GalleryLineDragInfo::GalleryLineDragInfo() { ERROR3("Default GalleryLineDragInfo constructor called"); }
/* For source (playback) line: * (a) if (fromPlayCursor == false), returns number of bytes available * for writing: bufferSize - (info->writePos - writeCursor); * (b) if (fromPlayCursor == true), playCursor is used instead writeCursor * and returned value can be used for play position calculation (see also * note about bufferSize) * For destination (capture) line: * (c) if (fromPlayCursor == false), returns number of bytes available * for reading from the buffer: readCursor - info->writePos; * (d) if (fromPlayCursor == true), captureCursor is used instead readCursor * and returned value can be used for capture position calculation (see * note about bufferSize) * bufferSize parameter are filled by "actual" buffer size: * if (fromPlayCursor == false), bufferSize = info->bufferSizeInBytes * otherwise it increase by number of bytes currently processed by DirectSound * (writeCursor - playCursor) or (captureCursor - readCursor) */ int DS_GetAvailable(DS_Info* info, DWORD* playCursor, DWORD* writeCursor, int* bufferSize, bool fromPlayCursor) { int available; int newReadPos; //TRACE2("DS_GetAvailable: fromPlayCursor=%d, deviceID=%d\n", fromPlayCursor, info->deviceID); if (!info->playBuffer && !info->captureBuffer) { ERROR0("DS_GetAvailable: ERROR: buffer not yet created"); return 0; } if (info->isSource) { if (FAILED(info->playBuffer->GetCurrentPosition(playCursor, writeCursor))) { ERROR0("DS_GetAvailable: ERROR: Failed to get current position.\n"); return 0; } int processing = DS_getDistance(info, (int)*playCursor, (int)*writeCursor); // workaround: sometimes DirectSound report writeCursor is less (for several bytes) then playCursor if (processing > info->dsBufferSizeInBytes / 2) { *writeCursor = *playCursor; processing = 0; } //TRACE3(" playCursor=%d, writeCursor=%d, info->writePos=%d\n", //*playCursor, *writeCursor, info->writePos); *bufferSize = info->bufferSizeInBytes; if (fromPlayCursor) { *bufferSize += processing; } DS_CheckUnderrun(info, *playCursor, *writeCursor); if (info->writePos == -1 || (info->underrun && !fromPlayCursor)) { /* always full buffer if at beginning */ available = *bufferSize; } else { int currWriteAhead = DS_getDistance(info, fromPlayCursor ? (int)*playCursor : (int)*writeCursor, info->writePos); if (currWriteAhead > *bufferSize) { if (info->underrun) { // playCursor surpassed writePos - no valid data, whole buffer available available = *bufferSize; } else { // the case may occur after stop(), when writeCursor jumps back to playCursor // so "actual" buffer size has grown *bufferSize = currWriteAhead; available = 0; } } else { available = *bufferSize - currWriteAhead; } } } else { if (FAILED(info->captureBuffer->GetCurrentPosition(playCursor, writeCursor))) { ERROR0("DS_GetAvailable: ERROR: Failed to get current position.\n"); return 0; } *bufferSize = info->bufferSizeInBytes; if (fromPlayCursor) { *bufferSize += DS_getDistance(info, (int)*playCursor, (int)*writeCursor); } //TRACE4(" captureCursor=%d, readCursor=%d, info->readPos=%d refBufferSize=%d\n", //*playCursor, *writeCursor, info->writePos, *bufferSize); if (info->writePos == -1) { /* always empty buffer if at beginning */ info->writePos = (int) (*writeCursor); } if (fromPlayCursor) { available = ((int) (*playCursor) - info->writePos); } else { available = ((int) (*writeCursor) - info->writePos); } if (available < 0) { available += info->dsBufferSizeInBytes; } if (!fromPlayCursor && available > info->bufferSizeInBytes) { /* overflow */ ERROR2("DS_GetAvailable: ERROR: overflow detected: " "DirectSoundBufferSize=%d, bufferSize=%d, ", info->dsBufferSizeInBytes, info->bufferSizeInBytes); ERROR3("captureCursor=%d, readCursor=%d, info->readPos=%d\n", *playCursor, *writeCursor, info->writePos); /* advance read position, to allow exactly one buffer worth of data */ newReadPos = (int) (*writeCursor) - info->bufferSizeInBytes; if (newReadPos < 0) { newReadPos += info->dsBufferSizeInBytes; } info->writePos = newReadPos; available = info->bufferSizeInBytes; } } available = (available / info->frameSize) * info->frameSize; //TRACE1("DS_available: Returning %d available bytes\n", (int) available); return available; }