void ConsoleBatch::setupFixOrientation(std::set<PageId> allPages) { IntrusivePtr<fix_orientation::Filter> fix_orientation = m_ptrStages->fixOrientationFilter(); CommandLine const& cli = CommandLine::get(); for (std::set<PageId>::iterator i=allPages.begin(); i!=allPages.end(); i++) { PageId page = *i; OrthogonalRotation rotation; // FIX ORIENTATION FILTER if (cli.hasOrientation()) { switch(cli.getOrientation()) { case CommandLine::LEFT: rotation.prevClockwiseDirection(); break; case CommandLine::RIGHT: rotation.nextClockwiseDirection(); break; case CommandLine::UPSIDEDOWN: rotation.nextClockwiseDirection(); rotation.nextClockwiseDirection(); break; default: break; } fix_orientation->getSettings()->applyRotation(page.imageId(), rotation); } } }
PageIdIterator(const std::vector<Extent>& extents, PageId target) : extent(0), pageID(kInvalidPageId), extents(&extents) { for(;extent<extents.size(); extent++) if(extents[extent].begin().toInteger() <= target.toInteger() && target.toInteger() < extents[extent].end().toInteger()) { pageID = target; return; } }
void Filter::loadSettings(ProjectReader const& reader, QDomElement const& filters_el) { m_ptrSettings->clear(); QDomElement const filter_el( filters_el.namedItem("output").toElement() ); QString const page_tag_name("page"); QDomNode node(filter_el.firstChild()); for (; !node.isNull(); node = node.nextSibling()) { if (!node.isElement()) { continue; } if (node.nodeName() != page_tag_name) { continue; } QDomElement const el(node.toElement()); bool ok = true; int const id = el.attribute("id").toInt(&ok); if (!ok) { continue; } PageId const page_id(reader.pageId(id)); if (page_id.isNull()) { continue; } ZoneSet const picture_zones(el.namedItem("zones").toElement(), m_pictureZonePropFactory); if (!picture_zones.empty()) { m_ptrSettings->setPictureZones(page_id, picture_zones); } ZoneSet const fill_zones(el.namedItem("fill-zones").toElement(), m_fillZonePropFactory); if (!fill_zones.empty()) { m_ptrSettings->setFillZones(page_id, fill_zones); } QDomElement const params_el(el.namedItem("params").toElement()); if (!params_el.isNull()) { Params const params(params_el); m_ptrSettings->setParams(page_id, params); } QDomElement const output_params_el(el.namedItem("output-params").toElement()); if (!output_params_el.isNull()) { OutputParams const output_params(output_params_el); m_ptrSettings->setOutputParams(page_id, output_params); } } }
bool OrderBySplitTypeProvider::precedes( PageId const& lhs_page, bool const lhs_incomplete, PageId const& rhs_page, bool const rhs_incomplete) const { if (lhs_incomplete != rhs_incomplete) { // Pages with question mark go to the bottom. return rhs_incomplete; } else if (lhs_incomplete) { assert(rhs_incomplete); // Two pages with question marks are ordered naturally. return lhs_page < rhs_page; } assert(lhs_incomplete == false); assert(rhs_incomplete == false); Settings::Record const lhs_record(m_ptrSettings->getPageRecord(lhs_page.imageId())); Settings::Record const rhs_record(m_ptrSettings->getPageRecord(rhs_page.imageId())); Params const* lhs_params = lhs_record.params(); Params const* rhs_params = rhs_record.params(); int lhs_layout_type = lhs_record.combinedLayoutType(); if (lhs_params) { lhs_layout_type = lhs_params->pageLayout().toLayoutType(); } if (lhs_layout_type == AUTO_LAYOUT_TYPE) { lhs_layout_type = 100; // To force it below pages with known layout. } int rhs_layout_type = rhs_record.combinedLayoutType(); if (rhs_params) { rhs_layout_type = rhs_params->pageLayout().toLayoutType(); } if (rhs_layout_type == AUTO_LAYOUT_TYPE) { rhs_layout_type = 100; // To force it below pages with known layout. } if (lhs_layout_type == rhs_layout_type) { return lhs_page < rhs_page; } else { return lhs_layout_type < rhs_layout_type; } }
void Filter::preUpdateUI(FilterUiInterface* ui, PageId const& page_id) { if (m_ptrOptionsWidget.get()) { OrthogonalRotation const rotation( m_ptrSettings->getRotationFor(page_id.imageId()) ); m_ptrOptionsWidget->preUpdateUI(page_id, rotation); ui->setOptionsWidget(m_ptrOptionsWidget.get(), ui->KEEP_OWNERSHIP); } }
IntrusivePtr<Task> Filter::createTask( PageId const& page_id, IntrusivePtr<page_split::Task> const& next_task, bool const batch_processing) { return IntrusivePtr<Task>( new Task( page_id.imageId(), IntrusivePtr<Filter>(this), m_ptrSettings, next_task, batch_processing ) ); }
void Filter::loadSettings(ProjectReader const& reader, QDomElement const& filters_el) { m_ptrSettings->clear(); QDomElement const filter_el(filters_el.namedItem("deskew").toElement()); QString const page_tag_name("page"); QDomNode node(filter_el.firstChild()); for (; !node.isNull(); node = node.nextSibling()) { if (!node.isElement()) { continue; } if (node.nodeName() != page_tag_name) { continue; } QDomElement const el(node.toElement()); bool ok = true; int const id = el.attribute("id").toInt(&ok); if (!ok) { continue; } PageId const page_id(reader.pageId(id)); if (page_id.isNull()) { continue; } QDomElement const params_el(el.namedItem("params").toElement()); if (params_el.isNull()) { continue; } Params const params(params_el); m_ptrSettings->setPageParams(page_id, params); } }
void inc(uint64_t count) { assert(pageID != kInvalidPageId); while(count!=0 && pageID!=kInvalidPageId) { // Next extent if(pageID == (*extents)[extent].end()) { extent++; if(extent >= extents->size()) pageID = kInvalidPageId; else pageID = (*extents)[extent].begin(); } // uint64_t leftInThisExtent = (*extents)[extent].end().toInteger() - pageID.toInteger(); if(leftInThisExtent > count) { pageID = PageId(pageID.toInteger() + count); count = 0; } else { count -= leftInThisExtent; pageID = (*extents)[extent].end(); } } }
DataPage::AddedValueRef::AddedValueRef(size_type valueSize, const PageId& firstLargeValuePage) : valueSizeOrTag_(0xffff) , valueReference_(reinterpret_cast<const char*>(&largeValueRef_), sizeof(largeValueRef_)) , largeValueRef_(valueSize | static_cast<uint64_t>(firstLargeValuePage.pageNumber()) << 32) { }
void OpenFiles::read(Page& page, const PageId& pageId) { file(pageId.fileType())->read(page, pageId); }