143 static const crn::String k(U
"nimrod::Illustration");
148 static const crn::String k(U
"nimrod::GraphicalElement");
153 static const crn::String k(U
"nimrod::ComposedBlock");
171 doc(std::make_shared<crn::
Document>()),
172 throws(throw_exceptions)
174 doc->SetUserData(
AltoPathKey(), std::make_shared<crn::Map>());
197 std::unique_ptr<AltoWrapper> wrapper(
new AltoWrapper(throw_exceptions));
199 const Path xpath(directory);
201 const Path ipath = imagedirectory.
IsEmpty() ? directory : imagedirectory;
206 std::vector<Path> xfiles(xdir.
GetFiles());
207 xfiles.erase(std::remove_if(xfiles.begin(), xfiles.end(),
keepXML()), xfiles.end());
208 std::sort(xfiles.begin(), xfiles.end());
213 for (
const Path &altofile : xfiles)
218 Alto xml(altofile, throw_exceptions);
220 Path imgfile(desc.GetFilename().Get());
221 if (imgfile.IsRelative())
222 imgfile = ipath / imgfile;
223 wrapper->
AddView(imgfile, altofile);
225 catch (std::exception &e)
227 CRNdout << altofile.CStr() <<
" : " << e.what() << std::endl;
234 wrapper->doc->Save(documentname);
239 return std::move(wrapper);
258 std::unique_ptr<AltoWrapper> wrapper(
new AltoWrapper(throw_exceptions));
262 std::vector<Path> ifiles(idir.
GetFiles());
263 std::sort(ifiles.begin(), ifiles.end());
268 for (
const Path &imgfile : ifiles)
272 Path altofile(xml_directory);
285 wrapper->
AddView(imgfile, altofile);
287 catch (std::exception &e)
296 wrapper->doc->Save(documentname);
301 return std::move(wrapper);
313 if (!document->IsUserData(
AltoPathKey()) && !create_altos)
316 UAltoWrapper wrapper(
new AltoWrapper(throw_exceptions));
317 wrapper->doc = document;
320 wrapper->createAltos();
322 return std::move(wrapper);
338 UAltoWrapper wrapper(
new AltoWrapper(throw_exceptions));
339 wrapper->doc->Load(documentname);
341 if (!wrapper->doc->IsUserData(
AltoPathKey()) && !create_altos)
345 wrapper->createAltos();
347 return std::move(wrapper);
362 std::unique_ptr<AltoWrapper> AltoWrapper::newFromList(
const std::vector<std::pair<crn::Path, crn::Path> > &filelist,
const crn::Path &documentname,
crn::Progress *prog,
bool throw_exceptions)
365 UAltoWrapper wrapper(
new AltoWrapper(throw_exceptions));
368 wrapper->doc->Save(documentname);
373 for (
const std::pair<crn::Path, crn::Path> &p : filelist)
375 wrapper->AddView(p.first, p.second);
381 wrapper->Synchronize(
false);
384 wrapper->doc->Save();
386 return std::move(wrapper);
409 String vid = doc->AddView(imagename);
416 SMap altomap(std::static_pointer_cast<Map>(doc->GetUserData(
AltoPathKey())));
417 altomap->Set(vid,
Clone(altoname));
419 if (doc->GetFilename().IsNotEmpty())
429 SMap altomap(std::static_pointer_cast<Map>(doc->GetUserData(
AltoPathKey())));
430 const std::vector<String> vids(doc->GetViewIds());
431 for(
const String &
id : vids)
433 SBlock block(doc->GetView(
id));
444 Alto alto(*std::static_pointer_cast<Path>((*altomap)[
id]));
447 std::vector<std::weak_ptr<Alto::Layout::Page> > pages(alto.
GetLayout().
GetPages());
449 for (
const std::weak_ptr<Alto::Layout::Page> &page : pages)
451 const std::shared_ptr<Alto::Layout::Page> spage(page.lock());
452 try { spage->GetId(); }
catch (...) { alto.
AddId(*spage); }
455 int pagew = spage->GetWidth() ? spage->GetWidth().
Get() : block->GetAbsoluteBBox().GetWidth() / int(pages.size());
456 int pageh = spage->GetHeight() ? spage->GetHeight().Get() : block->GetAbsoluteBBox().GetHeight();
459 if (*pos == Alto::Layout::Page::Position::Right)
461 pagearea =
crn::Rect(block->GetAbsoluteBBox().GetRight() - pagew, 0, block->GetAbsoluteBBox().GetRight(), pageh);
465 pagearea =
crn::Rect(refx, 0, refx + pagew, pageh);
471 pagearea =
crn::Rect(refx, 0, refx + pagew, pageh);
474 SBlock pageblock(block->AddChildAbsolute(
PageKey(), pagearea, spage->GetId()));
476 std::vector<std::weak_ptr<Alto::Layout::Page::Space> > spaces(spage->GetSpaces());
477 for (
const std::weak_ptr<Alto::Layout::Page::Space> space : spaces)
479 const std::shared_ptr<Alto::Layout::Page::Space> sspace(space.lock());
480 try { sspace->GetId(); }
catch (...) { alto.
AddId(*sspace); }
481 int spacev = int(sspace->GetVPos());
482 int spaceh = int(sspace->GetHPos());
483 crn::Rect spacearea(spaceh, spacev, spaceh +
int(sspace->GetWidth()), spacev +
int(sspace->GetHeight()));
484 String sname(sspace->GetName());
486 SBlock spaceblock(pageblock->AddChildAbsolute(
SpaceKey(), spacearea, sname));
488 std::vector<std::weak_ptr<Alto::Layout::Page::Space::TextBlock> > textblocks(sspace->GetTextBlocks());
489 for (
const std::weak_ptr<Alto::Layout::Page::Space::TextBlock> &tb : textblocks)
491 const std::shared_ptr<Alto::Layout::Page::Space::TextBlock> stb(tb.lock());
492 try { stb->GetId(); }
catch (...) { alto.
AddId(*stb); }
493 int tbv = int(stb->GetVPos());
494 int tbh = int(stb->GetHPos());
495 crn::Rect tbarea(tbh, tbv, tbh +
int(stb->GetWidth()), tbv +
int(stb->GetHeight()));
496 SBlock tbblock(spaceblock->AddChildAbsolute(
TextBlockKey(), tbarea, stb->GetId()));
498 std::vector<std::weak_ptr<Alto::Layout::Page::Space::TextBlock::TextLine> > textlines(stb->GetTextLines());
499 for (
const std::weak_ptr<Alto::Layout::Page::Space::TextBlock::TextLine> &tl : textlines)
501 const std::shared_ptr<Alto::Layout::Page::Space::TextBlock::TextLine> stl(tl.lock());
502 try { stl->GetId(); }
catch (...) { alto.
AddId(*stl); }
503 int tlv = int(stl->GetVPos());
504 int tlh = int(stl->GetHPos());
505 crn::Rect tlarea(tlh, tlv, tlh +
int(stl->GetWidth()), tlv +
int(stl->GetHeight()));
506 SBlock tlblock(tbblock->AddChildAbsolute(
TextLineKey(), tlarea, stl->GetId()));
508 std::vector<std::weak_ptr<Alto::Layout::Page::Space::TextBlock::TextLine::Word> > words(stl->GetWords());
509 for (
const std::weak_ptr<Alto::Layout::Page::Space::TextBlock::TextLine::Word> &word : words)
511 const std::shared_ptr<Alto::Layout::Page::Space::TextBlock::TextLine::Word> sword(word.lock());
512 try { sword->GetId(); }
catch (...) { alto.
AddId(*sword); }
513 if (sword->GetVPos() && sword->GetHPos() && sword->GetWidth())
515 int wx = int(sword->GetHPos().Get());
516 int wy = int(sword->GetVPos().Get());
517 int ww = int(sword->GetWidth().Get());
518 int wh = sword->GetHeight() ? int(sword->GetHeight().Get()) : tlarea.GetHeight();
519 crn::Rect wordarea(wx, wy, wx + ww, wy + wh);
520 tlblock->AddChildAbsolute(
WordKey(), wordarea, sword->GetId().Get());
526 std::vector<std::weak_ptr<Alto::Layout::Page::Space::Illustration> > illustrations(sspace->GetIllustrations());
527 for (
const std::weak_ptr<Alto::Layout::Page::Space::Illustration> &illus : illustrations)
529 const std::shared_ptr<Alto::Layout::Page::Space::Illustration> sillus(illus.lock());
530 try { sillus->GetId(); }
catch (...) { alto.
AddId(*sillus); }
531 int ilv = int(sillus->GetVPos());
532 int ilh = int(sillus->GetHPos());
533 crn::Rect ilarea(ilh, ilv, ilh +
int(sillus->GetWidth()), ilv +
int(sillus->GetHeight()));
537 std::vector<std::weak_ptr<Alto::Layout::Page::Space::GraphicalElement> > graphelems(sspace->GetGraphicalElements());
538 for (
const std::weak_ptr<Alto::Layout::Page::Space::GraphicalElement> &gel : graphelems)
540 const std::shared_ptr<Alto::Layout::Page::Space::GraphicalElement> sgel(gel.lock());
541 try { sgel->GetId(); }
catch (...) { alto.
AddId(*sgel); }
542 int gev = int(sgel->GetVPos());
543 int geh = int(sgel->GetHPos());
544 crn::Rect gearea(geh, gev, geh +
int(sgel->GetWidth()), gev +
int(sgel->GetHeight()));
557 void AltoWrapper::createAltos()
562 altomap = std::make_shared<crn::Map>();
566 altomap = std::static_pointer_cast<
Map>(doc->GetUserData(
AltoPathKey()));
567 const std::vector<String> vids(doc->GetViewIds());
568 for (
const String &
id : vids)
570 if (altomap->Find(
id) == altomap->end())
573 Path altoname(doc->GetBasename() /
id.CStr() +
"_alto.xml");
575 altomap->Set(
id,
Clone(altoname));
593 return View(getLock(view_id), view_id);
609 String id(doc->GetViewId(index));
610 return View(getLock(
id),
id);
623 std::shared_ptr<AltoWrapper::ViewLock> AltoWrapper::getLock(
const String &view_id)
const
625 std::map<String, std::weak_ptr<ViewLock> >::iterator it(viewLocks.find(view_id));
626 if (it == viewLocks.end())
628 SCMap altomap(std::static_pointer_cast<const Map>(doc->GetUserData(
AltoPathKey())));
629 std::shared_ptr<ViewLock> vl(
new ViewLock(doc->GetView(view_id), std::make_shared<Alto>(*std::static_pointer_cast<
const Path>(altomap->Get(view_id)),
throws)));
631 viewLocks[view_id] = vl;
636 if (it->second.expired())
638 SCMap altomap(std::static_pointer_cast<const Map>(doc->GetUserData(
AltoPathKey())));
639 std::shared_ptr<ViewLock> vl(
new ViewLock(doc->GetView(view_id), std::make_shared<Alto>(*std::static_pointer_cast<
const Path>(altomap->Get(view_id)),
throws)));
641 viewLocks[view_id] = vl;
646 return it->second.lock();
785 const std::vector<std::weak_ptr<AltoPage> > &pages(lock->GetAlto()->GetLayout().GetPages());
786 for (
const std::weak_ptr<AltoPage> &p : pages)
787 ids.push_back(p.lock()->GetId());
798 SBlock b(lock->GetBlock()->GetChild(
PageKey(), pageId));
799 AltoPage &p(lock->GetAlto()->GetLayout().GetPage(pageId));
813 Id pageId(lock->GetAlto()->CreateId());
814 AltoPage &page(lock->GetAlto()->GetLayout().AddPage(pageId, image_number, w, h, pos));
816 int pagew = page.GetWidth() ? page.GetWidth().Get() : lock->GetBlock()->GetAbsoluteBBox().GetWidth() / int(lock->GetAlto()->GetLayout().GetPages().size());
817 int pageh = page.GetHeight() ? page.GetHeight().Get() : lock->GetBlock()->GetAbsoluteBBox().GetHeight();
818 auto pagearea =
crn::Rect(0, 0, pagew, pageh);
821 if (*pos == Alto::Layout::Page::Position::Right)
823 pagearea =
crn::Rect(lock->GetBlock()->GetAbsoluteBBox().GetRight() - pagew, 0, lock->GetBlock()->GetAbsoluteBBox().GetRight(), pageh);
827 auto b = lock->GetBlock()->AddChildAbsolute(
PageKey(), pagearea, pageId);
829 return Page(b, page, lock,
id);
844 Id pageId(lock->GetAlto()->CreateId());
845 AltoPage &page(lock->GetAlto()->GetLayout().AddPageAfter(pred, pageId, image_number, w, h, pos));
847 int pagew = page.GetWidth() ? page.GetWidth().Get() : lock->GetBlock()->GetAbsoluteBBox().GetWidth() / int(lock->GetAlto()->GetLayout().GetPages().size());
848 int pageh = page.GetHeight() ? page.GetHeight().Get() : lock->GetBlock()->GetAbsoluteBBox().GetHeight();
849 auto pagearea =
crn::Rect(0, 0, pagew, pageh);
852 if (*pos == Alto::Layout::Page::Position::Right)
854 pagearea =
crn::Rect(lock->GetBlock()->GetAbsoluteBBox().GetRight() - pagew, 0, lock->GetBlock()->GetAbsoluteBBox().GetRight(), pageh);
858 auto b = lock->GetBlock()->AddChildAbsolute(
PageKey(), pagearea, pageId);
860 return Page(b, page, lock,
id);
875 Id pageId(lock->GetAlto()->CreateId());
876 AltoPage &page(lock->GetAlto()->GetLayout().AddPageBefore(next, pageId, image_number, w, h, pos));
878 int pagew = page.GetWidth() ? page.GetWidth().Get() : lock->GetBlock()->GetAbsoluteBBox().GetWidth() / int(lock->GetAlto()->GetLayout().GetPages().size());
879 int pageh = page.GetHeight() ? page.GetHeight().Get() : lock->GetBlock()->GetAbsoluteBBox().GetHeight();
880 auto pagearea =
crn::Rect(0, 0, pagew, pageh);
883 if (*pos == Alto::Layout::Page::Position::Right)
885 pagearea =
crn::Rect(lock->GetBlock()->GetAbsoluteBBox().GetRight() - pagew, 0, lock->GetBlock()->GetAbsoluteBBox().GetRight(), pageh);
889 auto b = lock->GetBlock()->AddChildAbsolute(
PageKey(), pagearea, pageId);
891 return Page(b, page, lock,
id);
900 lock->GetAlto()->GetLayout().RemovePage(pageId);
901 lock->GetBlock()->RemoveChild(
PageKey(), pageId);
922 box = space.GetBBox() | r;
923 if (box != space.GetBBox())
924 space.SetBBox(box,
false);
926 box = tb.GetBBox() | r;
927 if (box != tb.GetBBox())
928 tb.SetBBox(box,
false);
930 box = tl.GetBBox() | r;
931 if (box != tl.GetBBox())
932 tl.SetBBox(box,
false);
956 box = space.GetBBox() | r;
957 if (box != space.GetBBox())
958 space.SetBBox(box,
false);
960 box = tb.GetBBox() | r;
961 if (box != tb.GetBBox())
962 tb.SetBBox(box,
false);
964 tl.SetBBox(r, erase_oob);
985 box = space.GetBBox() | r;
986 if (box != space.GetBBox())
987 space.SetBBox(box,
false);
989 tb.SetBBox(r, erase_oob);
1009 space.SetBBox(r, erase_oob);
1026 const std::vector<Id> spaces(GetSpaces());
1027 for (
const Id &sid : spaces)
1030 if ((s.
GetBBox() & r).GetArea() == 0)
1040 for (
const Id &bid : blocks)
1043 if ((tb.GetBBox() & r).GetArea() == 0)
1045 const std::vector<Id> lines(tb.GetTextLines());
1046 for (
const Id &lid : lines)
1049 if ((tl.GetBBox() & r).GetArea() == 0)
1051 const std::vector<Id> words(tl.GetWords());
1052 for (
const Id &wid : words)
1054 Word w(tl.GetWord(wid));
1055 if ((w.GetBBox() & r).GetArea() == 0)
1062 block->SetAbsoluteBBox(r);
1063 const crn::Rect crop(block->GetAbsoluteBBox());
1067 page->SetHeight(crop.GetHeight());
1068 for (
const Id &sid : spaces)
1078 std::vector<Alto::Styles::Text> sty;
1079 const std::vector<Id> &sids(GetStyles());
1080 for (
const Id &sid : sids)
1082 try { sty.push_back(lock->GetAlto()->GetStyles().GetTextStyle(sid)); }
catch (...) { }
1090 std::vector<Alto::Styles::Paragraph> sty;
1091 const std::vector<Id> &sids(GetStyles());
1092 for (
const Id &sid : sids)
1094 try { sty.push_back(lock->GetAlto()->GetStyles().GetParagraphStyle(sid)); }
catch (...) { }
1102 const std::vector<std::weak_ptr<AltoSpace> > spaces(page->GetSpaces());
1103 std::vector<Id> ids(spaces.size());
1104 for (
size_t tmp = 0; tmp < spaces.size(); ++tmp)
1105 ids[tmp] = spaces[tmp].lock()->GetId().Get();
1119 SBlock b(block->GetChild(
SpaceKey(), n));
1129 std::weak_ptr<AltoSpace> sp(page->GetTopMargin());
1132 SBlock b(block->GetChild(
SpaceKey(), U
"topmargin"));
1144 SBlock b(block->AddChildAbsolute(
SpaceKey(), bbox, U
"topmargin"));
1154 std::weak_ptr<AltoSpace> sp(page->GetLeftMargin());
1157 SBlock b(block->GetChild(
SpaceKey(), U
"leftmargin"));
1169 SBlock b(block->AddChildAbsolute(
SpaceKey(), bbox, U
"leftmargin"));
1179 std::weak_ptr<AltoSpace> sp(page->GetBottomMargin());
1182 SBlock b(block->GetChild(
SpaceKey(), U
"bottommargin"));
1194 SBlock b(block->AddChildAbsolute(
SpaceKey(), bbox, U
"bottommargin"));
1204 std::weak_ptr<AltoSpace> sp(page->GetRightMargin());
1207 SBlock b(block->GetChild(
SpaceKey(), U
"rightmargin"));
1219 SBlock b(block->AddChildAbsolute(
SpaceKey(), bbox, U
"rightmargin"));
1229 std::weak_ptr<AltoSpace> sp(page->GetPrintSpace());
1232 SBlock b(block->GetChild(
SpaceKey(), U
"printspace"));
1244 SBlock b(block->AddChildAbsolute(
SpaceKey(), bbox, U
"printspace"));
1254 page->RemoveSpace(sid);
1255 block->RemoveChild(
SpaceKey(), sid);
1295 const std::vector<Id> blocks(GetTextBlocks());
1296 for (
const Id &bid : blocks)
1299 if ((tb.
GetBBox() & r).GetArea() == 0)
1309 for (
const Id &lid : lines)
1312 if ((tl.GetBBox() & r).GetArea() == 0)
1314 const std::vector<Id> words(tl.GetWords());
1315 for (
const Id &wid : words)
1317 Word w(tl.GetWord(wid));
1318 if ((w.GetBBox() & r).GetArea() == 0)
1324 block->SetAbsoluteBBox(r);
1325 const crn::Rect crop(block->GetAbsoluteBBox());
1326 space->SetHPos(crop.GetLeft());
1327 space->SetVPos(crop.GetTop());
1329 space->SetHeight(crop.GetHeight());
1330 for (
const Id &bid : blocks)
1340 std::vector<Alto::Styles::Text> sty;
1341 const std::vector<Id> &sids(GetStyles());
1342 for (
const Id &sid : sids)
1344 try { sty.push_back(lock->GetAlto()->GetStyles().GetTextStyle(sid)); }
catch (...) { }
1352 std::vector<Alto::Styles::Paragraph> sty;
1353 const std::vector<Id> &sids(GetStyles());
1354 for (
const Id &sid : sids)
1356 try { sty.push_back(lock->GetAlto()->GetStyles().GetParagraphStyle(sid)); }
catch (...) { }
1364 const std::vector<std::weak_ptr<AltoTextBlock> > tbs(space->GetTextBlocks());
1365 std::vector<Id> ids(tbs.size());
1366 for (
size_t tmp = 0; tmp < tbs.size(); ++tmp)
1367 ids[tmp] = tbs[tmp].lock()->GetId();
1390 SBlock b(block->AddChildAbsolute(
TextBlockKey(), bbox, tb.GetId()));
1403 SBlock b(block->AddChildAbsolute(
TextBlockKey(), bbox, tb.GetId()));
1416 SBlock b(block->AddChildAbsolute(
TextBlockKey(), bbox, tb.GetId()));
1426 space->RemoveBlock(bid);
1444 const std::vector<Id> lines(GetTextLines());
1445 for (
const Id &lid : lines)
1448 if ((tl.
GetBBox() & r).GetArea() == 0)
1451 RemoveTextLine(lid);
1457 const std::vector<Id> words(tl.
GetWords());
1458 for (
const Id &wid : words)
1461 if ((w.GetBBox() & r).GetArea() == 0)
1466 block->SetAbsoluteBBox(r);
1467 const crn::Rect crop(block->GetAbsoluteBBox());
1468 textblock->SetHPos(crop.GetLeft());
1469 textblock->SetVPos(crop.GetTop());
1470 textblock->
SetWidth(crop.GetWidth());
1471 textblock->SetHeight(crop.GetHeight());
1472 for (
const Id &lid : lines)
1482 std::vector<Alto::Styles::Text> sty;
1483 const std::vector<Id> &sids(GetStyles());
1484 for (
const Id &sid : sids)
1486 try { sty.push_back(lock->GetAlto()->GetStyles().GetTextStyle(sid)); }
catch (...) { }
1494 std::vector<Alto::Styles::Paragraph> sty;
1495 const std::vector<Id> &sids(GetStyles());
1496 for (
const Id &sid : sids)
1498 try { sty.push_back(lock->GetAlto()->GetStyles().GetParagraphStyle(sid)); }
catch (...) { }
1506 const std::vector<std::weak_ptr<AltoTextLine> > tls(textblock->GetTextLines());
1507 std::vector<Id> ids(tls.size());
1508 for (
size_t tmp = 0; tmp < tls.size(); ++tmp)
1509 ids[tmp] = tls[tmp].lock()->GetId();
1532 SBlock b(block->AddChildAbsolute(
TextLineKey(), bbox, tl.GetId()));
1545 SBlock b(block->AddChildAbsolute(
TextLineKey(), bbox, tl.GetId()));
1558 SBlock b(block->AddChildAbsolute(
TextLineKey(), bbox, tl.GetId()));
1568 textblock->RemoveTextLine(tid);
1579 std::vector<Alto::Styles::Text> sty;
1580 const std::vector<Id> &sids(GetStyles());
1581 for (
const Id &sid : sids)
1583 try { sty.push_back(lock->GetAlto()->GetStyles().GetTextStyle(sid)); }
catch (...) { }
1591 std::vector<Alto::Styles::Paragraph> sty;
1592 const std::vector<Id> &sids(GetStyles());
1593 for (
const Id &sid : sids)
1595 try { sty.push_back(lock->GetAlto()->GetStyles().GetParagraphStyle(sid)); }
catch (...) { }
1610 const std::vector<Id> words(GetWords());
1611 for (
const Id &wid : words)
1614 if ((w.
GetBBox() & r).GetArea() == 0)
1622 block->SetAbsoluteBBox(r);
1623 const crn::Rect crop(block->GetAbsoluteBBox());
1624 textline->SetHPos(crop.GetLeft());
1625 textline->SetVPos(crop.GetTop());
1626 textline->
SetWidth(crop.GetWidth());
1627 textline->SetHeight(crop.GetHeight());
1628 for (
const Id &wid : words)
1638 const std::vector<std::weak_ptr<AltoWord> > words(textline->GetWords());
1639 std::vector<Id> ids(words.size());
1640 for (
size_t tmp = 0; tmp < words.size(); ++tmp)
1641 ids[tmp] = words[tmp].lock()->GetId().Get();
1652 AltoWord &word(textline->GetWord(
id));
1653 SBlock b(block->GetChild(
WordKey(),
id));
1664 SBlock b(block->AddChildAbsolute(
WordKey(), bbox, w.GetId().Get()));
1677 SBlock b(block->AddChildAbsolute(
WordKey(), bbox, w.GetId().Get()));
1690 SBlock b(block->AddChildAbsolute(
WordKey(), bbox, w.GetId().Get()));
1700 textline->RemoveWord(wid);
1701 block->RemoveChild(
WordKey(), wid);
1711 std::vector<Alto::Styles::Text> sty;
1712 const std::vector<Id> &sids(GetStyles());
1713 for (
const Id &sid : sids)
1715 try { sty.push_back(lock->GetAlto()->GetStyles().GetTextStyle(sid)); }
catch (...) { }
1723 std::vector<Alto::Styles::Paragraph> sty;
1724 const std::vector<Id> &sids(GetStyles());
1725 for (
const Id &sid : sids)
1727 try { sty.push_back(lock->GetAlto()->GetStyles().GetParagraphStyle(sid)); }
catch (...) { }
1739 block->SetAbsoluteBBox(r);
1740 const crn::Rect crop(block->GetAbsoluteBBox());
1741 word->SetHPos(crop.GetLeft());
1742 word->SetVPos(crop.GetTop());
1744 word->SetHeight(crop.GetHeight());
static const String & GraphicalElementKey()
const Rect & GetBBox() const
Gets the coordinates of the text block.
TextBlock AddTextBlockAfter(const Id &pred, const crn::Rect &bbox)
Adds a text block to the space.
void RemovePage(const Id &pageId)
Removes a page.
TextLine GetTextLine(const TextLinePath &p)
Gets a TextLine by path.
Space AddPrintSpace(const crn::Rect &bbox)
Adds the print space.
StringUTF8 & ToLower()
Converts the string to lowercase.
AltoWrapper(const AltoWrapper &)=delete
Page AddPageAfter(const Id &pred, int image_number, int w, int h, Option< AltoPage::Position > pos=Option< AltoPage::Position >())
Adds a page.
const Rect & GetBBox() const
Gets the coordinates of the word.
void ResizeTextLine(const TextLinePath &p, const crn::Rect &r, bool erase_oob)
Changes the size of a line and all its parents if needed.
std::vector< Alto::Styles::Paragraph > GetParagraphStyles()
Returns the paragraph styles.
TextBlock AddTextBlockBefore(const Id &next, const crn::Rect &bbox)
Adds a text block to the space.
std::vector< String > Split(const String &sep) const
Splits the string in multiple strings delimited by a set of separators.
static std::unique_ptr< AltoWrapper > NewFromDir(const crn::Path &directory, const crn::Path &documentname, const crn::Path &imagedirectory="", crn::Progress *prog=nullptr, bool throw_exceptions=true)
Creates a wrapper from a directory containing Altos.
std::vector< Alto::Styles::Text > GetTextStyles()
Returns the text styles.
Base class for a progress display.
Page GetPage(const PagePath &p)
Gets a Page by path.
TextLine AddTextLineBefore(const Id &next, const crn::Rect &bbox)
Adds a text line to the block.
void ResizeTextLine(const TextLinePath &p, const crn::Rect &r, bool erase_oob)
Changes the size of a line and all its parents if needed.
Space AddBottomMargin(const crn::Rect &bbox)
Adds a bottom margin.
std::vector< Alto::Styles::Paragraph > GetParagraphStyles()
Returns the paragraph styles.
Page GetPage(const Id &pageId)
Gets a page.
Space GetRightMargin()
Gets the space proxy on the right margin.
Word AddWordAfter(const Id &pred, const StringUTF8 &text, const crn::Rect &bbox)
Adds a word to the line.
Word AddWordBefore(const Id &next, const StringUTF8 &text, const crn::Rect &bbox)
Adds a word to the line.
void SetBBox(const crn::Rect &r, bool erase_oob)
Sets the coordinates of the space.
void ResizeSpace(const SpacePath &p, const crn::Rect &r, bool erase_oob)
Changes the size of a space and all its parents if needed.
std::vector< Id > GetWords() const
Returns the ids of the words in the line.
static const String & TextBlockKey()
std::vector< Alto::Styles::Paragraph > GetParagraphStyles()
Returns the paragraph styles.
void RemoveSpace(const Id &sid)
Removes a space.
Page AddPageBefore(const Id &next, int image_number, int w, int h, Option< AltoPage::Position > pos=Option< AltoPage::Position >())
Adds a page.
static const String & ComposedBlockKey()
bool IsNotEmpty() const noexcept
Checks if the string is not empty.
static const String & WordKey()
void RemoveWord(const Id &wid)
Removes a line element.
static char Separator() noexcept
Local directory separator.
Space GetLeftMargin()
Gets the space proxy on the left margin.
int GetTop() const
Returns the topmost coordinate.
int GetLeft() const
Returns the leftmost coordinate.
void Synchronize(bool reset=false)
Creates CRNBlocks and ids where there is none.
static const String & IllustrationKey()
View GetView(const String &view_id)
Gets a view by id.
A handler to the content of a directory.
Alto::Layout::Page AltoPage
void Advance()
Progresses of one step.
A UTF32 character string class.
const String AddView(const Path &imagename, const Path &altoname="")
Adds a view to the document.
void ResizeWord(const WordPath &p, const crn::Rect &r)
Changes the size of a word and all its parents if needed.
TextBlock GetTextBlock(const Id &id)
Gets a text block proxy.
Space GetBottomMargin()
Gets the space proxy on the bottom margin.
T & Get() noexcept
Value access (undefined behaviour if the value is not set)
std::vector< Alto::Styles::Text > GetTextStyles()
Returns the text styles.
Alto::Layout::Page::Space::TextBlock AltoTextBlock
TextBlock AddTextBlock(const crn::Rect &bbox)
Adds a text block to the space.
std::vector< Id > GetTextBlocks() const
Returns the ids of the text blocks in the page space.
int SetWidth(int wid)
Changes the width of the rectangle.
const char * CStr() const noexcept
Conversion to UTF8 cstring.
static const crn::String & Separator()
Space GetSpace(const SpacePath &p)
Gets a Space by path.
Word AddWord(const StringUTF8 &text, const crn::Rect &bbox)
Adds a word to the line.
bool IsEmpty() const noexcept
Checks if the string is empty.
static const TextLinePath & NullPath()
A convenience class for file paths.
void ResizeWord(const WordPath &p, const crn::Rect &r)
Changes the size of a word and all its parents if needed.
std::vector< Alto::Styles::Text > GetTextStyles()
Returns the text styles.
Id AddId(Element &el)
Adds an id to an element.
std::vector< Alto::Styles::Paragraph > GetParagraphStyles()
Returns the paragraph styles.
void SetBBox(const crn::Rect &r, bool erase_oob)
Sets the coordinates of the text line.
const Rect & GetBBox() const
Gets the coordinates of the page.
std::vector< PagePtr > GetPages() const
Returns the list of all pages.
static const BlockPath & NullPath()
static const WordPath & NullPath()
Layout & GetLayout()
Gets the layout description part of the Alto.
void Save(const Path &fname)
Saves to file.
bool operator()(const Path &p)
const Rect & GetBBox() const
Gets the coordinates of the space.
void SetBBox(const crn::Rect &r, bool erase_oob)
Sets the coordinates of the page.
Word GetWord(const Id &id)
Gets a word proxy.
void ResizeTextBlock(const BlockPath &p, const crn::Rect &r, bool erase_oob)
Changes the size of a text block and all its parents if needed.
static const String & TextLineKey()
Space GetTopMargin()
Gets the space proxy on the top margin.
static std::unique_ptr< AltoWrapper > NewFromDocument(const crn::SDocument &document, bool create_altos=false, bool throw_exceptions=true)
Creates a wrapper from a crn::Document that was created by Nimrod.
Alto::Layout::Page::Space::TextBlock::TextLine::Word AltoWord
std::vector< Id > GetTextLines() const
Returns the ids of the text lines in the page space.
Space AddRightMargin(const crn::Rect &bbox)
Adds a right margin.
static std::unique_ptr< AltoWrapper > NewFromDirs(const crn::Path &image_directory, const crn::Path &xml_directory, const crn::Path &documentname, crn::Progress *prog=nullptr, bool throw_exceptions=true)
Creates a wrapper from two directories containing images and Altos with the same base names...
void SetBBox(const crn::Rect &r, bool erase_oob)
Sets the coordinates of the text block.
Alto::Layout::Page::Space AltoSpace
void SetMaxCount(size_t maxcount, bool reset=true)
Sets the total number of steps.
int GetHeight() const
Returns the height of the rectangle.
static const String & PageKey()
std::vector< Alto::Styles::Text > GetTextStyles()
Returns the text styles.
TextLine GetTextLine(const Id &id)
Gets a text line proxy.
Path GetBase() const
Returns the base of the filename.
String & ToLower()
Converts the string to lowercase.
UImage NewImageFromFile(const Path &fname)
Loads an image from a file.
Space AddTopMargin(const crn::Rect &bbox)
Adds a top margin.
static const String & AltoPathKey()
Space AddLeftMargin(const crn::Rect &bbox)
Adds a left margin.
int GetWidth() const
Returns the width of the rectangle.
Word GetWord(const WordPath &p)
Gets a Word by path.
Space GetPrintSpace()
Gets the space proxy on the print space.
Page AddPage(int image_number, int w, int h, Option< AltoPage::Position > pos=Option< AltoPage::Position >())
Adds a page.
TextLine AddTextLineAfter(const Id &pred, const crn::Rect &bbox)
Adds a text line to the block.
const std::vector< Path > & GetFiles() const
Returns the list of files.
std::vector< Alto::Styles::Paragraph > GetParagraphStyles()
Returns the paragraph styles.
TextLine AddTextLine(const crn::Rect &bbox)
Adds a text line to the block.
static bool Access(const Path &name, int mode)
Checks rights on a file.
void ResizeTextBlock(const BlockPath &p, const crn::Rect &r, bool erase_oob)
Changes the size of a text block and all its parents if needed.
TextBlock GetTextBlock(const BlockPath &p)
Gets a TextBlock by path.
A character string class.
void SetBBox(const crn::Rect &r)
Sets the coordinates of the word.
UObject Clone(const Object &obj)
Clones an object if possible.
void RemoveBlock(const Id &bid)
Removes a block.
std::vector< Id > GetSpaces() const
Returns the ids of the spaces in the page.
A class to store an optional value.
static const String & SpaceKey()
std::vector< Id > GetPages()
Gets the list of page ids.
int GetRight() const
Returns the rightmost coordinate.
Path GetExtension() const
Returns the extension.
void ResizeSpace(const SpacePath &p, const crn::Rect &r, bool erase_oob)
Changes the size of a space and all its parents if needed.
Alto::Layout::Page::Space::TextBlock::TextLine AltoTextLine
Space GetSpace(const Id &spaceid)
Gets a space proxy.
const Rect & GetBBox() const
Gets the coordinates of the text line.
void RemoveTextLine(const Id &tid)
Removes a text line.
static const PagePath & NullPath()
static const SpacePath & NullPath()
Invalid argument error (e.g.: nullptr pointer)
Description & GetDescription()
Gets the global description part of the Alto (may be null)
std::vector< Alto::Styles::Text > GetTextStyles()
Returns the text styles.
An item was not found in a container.