Graphic state operator (gs)

This commit is contained in:
Jakub Melka
2019-02-23 15:44:14 +01:00
parent 959ed6599b
commit ffc56d38e1
6 changed files with 194 additions and 10 deletions

View File

@ -273,7 +273,7 @@ PDFInteger PDFDocumentDataLoaderDecorator::readInteger(const PDFObject& object,
return defaultValue;
}
PDFReal PDFDocumentDataLoaderDecorator::readNumber(const PDFObject& object, PDFInteger defaultValue) const
PDFReal PDFDocumentDataLoaderDecorator::readNumber(const PDFObject& object, PDFReal defaultValue) const
{
const PDFObject& dereferencedObject = m_document->getObject(object);
@ -357,4 +357,32 @@ PDFInteger PDFDocumentDataLoaderDecorator::readIntegerFromDictionary(const PDFDi
return defaultValue;
}
std::vector<PDFReal> PDFDocumentDataLoaderDecorator::readNumberArray(const PDFObject& object) const
{
const PDFObject& dereferencedObject = m_document->getObject(object);
if (dereferencedObject.isArray())
{
const PDFArray* array = dereferencedObject.getArray();
std::vector<PDFReal> result;
const size_t count = array->getCount();
result.reserve(count);
for (size_t i = 0; i < count; ++i)
{
const PDFReal number = readNumber(array->getItem(i), std::numeric_limits<PDFReal>::quiet_NaN());
if (std::isnan(number))
{
return std::vector<PDFReal>();
}
result.push_back(number);
}
// We assume, that RVO (return value optimization) will not work for this function
// (multiple return points).
return std::move(result);
}
return std::vector<PDFReal>();
}
} // namespace pdf