void touchmind::print::XPSGeometryBuilder::CreatePathGeometryFromPoints( IXpsOMObjectFactory *pXpsFactory, const std::vector<D2D1_POINT_2F> &points, OUT IXpsOMGeometryFigure** ppXpsFigure) { XPS_POINT startPoint = {points[0].x, points[0].y}; std::vector<XPS_SEGMENT_TYPE> segmentTypes(points.size()); std::vector<FLOAT> segmentData(segmentTypes.size() * 2); std::vector<BOOL> segmentStrokes(segmentTypes.size()); for (size_t i = 1; i < points.size(); ++i) { size_t j = i - 1; segmentTypes[j] = XPS_SEGMENT_TYPE_LINE; segmentData[j * 2] = points[i].x; segmentData[j * 2 + 1] = points[i].y; segmentStrokes[j] = TRUE; } size_t i = 0; size_t j = points.size() - 1; segmentTypes[j] = XPS_SEGMENT_TYPE_LINE; segmentData[j * 2] = points[i].x; segmentData[j * 2 + 1] = points[i].y; segmentStrokes[j] = TRUE; CHK_RES(*ppXpsFigure, pXpsFactory->CreateGeometryFigure(&startPoint, ppXpsFigure)); // one of the pdf converter software have a problem when set SetISClosed to TRUE CHK_HR((*ppXpsFigure)->SetIsClosed(FALSE)); CHK_HR((*ppXpsFigure)->SetIsFilled(TRUE)); CHK_HR((*ppXpsFigure)->SetSegments( static_cast<UINT32>(segmentTypes.size()), static_cast<UINT32>(segmentData.size()), &segmentTypes.front(), &segmentData.front(), &segmentStrokes.front())); }
/** * Panic is raised, if the header with other header and terminating * ' ' is > 159 characters. Then 1 byte is left for payload ! * what will be the array element type ? */ void TWapTextMessage::EncodeSegmentsL(CArrayPtr<HBufC8>& aSegmentArray) { TBuf8<KMaxSmsChars> header; // buffer for a modifiable header TInt headerLength = 0; TInt segmentNumberIndex = 0; // index of segment number field in the header TBuf8<2> hexSegmentNumber; TInt dataSegmented = 0; OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, TWAPTEXTMESSAGE_ENCODESEGMENTSL_1, "TWapTextMessage::EncodeSegmentsL()"); iSegmentNumber = 0; do { // // Create the segment and add it to the array... // HBufC8* segment = HBufC8::NewL(KMaxSmsChars); // 160 characters CleanupStack::PushL(segment); TPtr8 ptr(segment->Des()); aSegmentArray.AppendL(segment); CleanupStack::Pop(); // segment // // Calculate length of header and copy it... // if (iSegmentNumber==0) { headerLength = CreateHeader(header, segmentNumberIndex); } ptr.Copy(header); if (iTotalSegments>255) { User::Leave(KErrOverflow); } // // Set segment number... // if (segmentNumberIndex != 0) { hexSegmentNumber.NumFixedWidthUC(iSegmentNumber+1, EHex, 2); // two bytes wide ptr.Insert(segmentNumberIndex, hexSegmentNumber); } // // Count any escaped characters we can be sure that the converted data // size fits inside the remaining length (e.g. so that non-7bit characters // when converted by the SMS Stack will still fit). // TInt segmentSize = iRefData.Length() - dataSegmented; if (segmentSize > KMaxSmsChars - headerLength) { segmentSize = KMaxSmsChars - headerLength; } while (segmentSize > 1) { TPtrC8 segmentData(iRefData.Mid(dataSegmented, segmentSize)); TInt non7bitCharEscapes = 0; // // Count all non-7bit characters that will be escaped (many non-7bit // characters are not escaped, but converted to "?"). The ones // that are known to be escaped are list below: // // 12 [Form Feed]. // 91 "[" // 92 "\" // 93 "]" // 94 "^" // 123 "{" // 124 "|" // 125 "}" // 126 "~" // for (TInt ch = 0; ch < segmentSize; ch++) { if (segmentData[ch] == 12 || (segmentData[ch] >= 91 && segmentData[ch] <= 94) || (segmentData[ch] >= 123 && segmentData[ch] <= 126)) { non7bitCharEscapes++; } } // // Can it fit? If so store it, otherwise reduce the size... // if (segmentData.Length() + non7bitCharEscapes <= KMaxSmsChars - headerLength) { ptr.Append(segmentData); break; } segmentSize--; } dataSegmented += segmentSize; iSegmentNumber++; } while (dataSegmented < iRefData.Length()); __ASSERT_DEBUG(iTotalSegments == aSegmentArray.Count(), Panic(KPanicEncodingError)); } // TWapTextMessage::EncodeSegmentsL
/** * Calculates count of segments to send a used data (based on iRefData) * The values is assigned to iTotalSegments * The affect of terminating ' ' is taken into inside the method */ TInt TWapTextMessage::CalculateTotalSegments(TInt aFixedLength) { OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, TWAPTEXTMESSAGE_CALCULATETOTALSEGMENTS_1, "TWapTextMessage::CalculateTotalSegments [aFixedLength=%d]", aFixedLength); // '+1': length of terminating ' ' TInt length = aFixedLength + iRefOtherHeader.Length() + 1; TInt remain = KMaxSmsChars - length; TInt dataSegmented = 0; __ASSERT_DEBUG(remain > 0, Panic(KPanicTextHeaderTooLong)); iTotalSegments = 0; do { iTotalSegments++; // // Count any escaped characters we can be sure that the converted data // size fits inside the remaining length (e.g. so that non-7bit characters // when converted by the SMS Stack will still fit). // TInt segmentSize = iRefData.Length() - dataSegmented; if (segmentSize > remain) { segmentSize = remain; } while (segmentSize > 1) { TPtrC8 segmentData(iRefData.Mid(dataSegmented, segmentSize)); TInt non7bitCharEscapes = 0; // // Count all non-7bit characters that will be escaped (many non-7bit // characters are not escaped, but converted to "?"). The ones // that are known to be escaped are list below: // // 12 [Form Feed]. // 91 "[" // 92 "\" // 93 "]" // 94 "^" // 123 "{" // 124 "|" // 125 "}" // 126 "~" // for (TInt ch = 0; ch < segmentSize; ch++) { if (segmentData[ch] == 12 || (segmentData[ch] >= 91 && segmentData[ch] <= 94) || (segmentData[ch] >= 123 && segmentData[ch] <= 126)) { non7bitCharEscapes++; } } // // Can it fit? If so store it, otherwise reduce the size... // if (segmentData.Length() + non7bitCharEscapes <= remain) { break; } segmentSize--; } dataSegmented += segmentSize; } while (dataSegmented < iRefData.Length()); // // At least one fragment is needed... // if (iTotalSegments == 0) { iTotalSegments = 1; } return iTotalSegments; } // TWapTextMessage::CalculateTotalSegments