void AXRController::add(HSSContainer::p & newContainer) { if(!this->root){ this->root = newContainer; } else { if(this->currentContext.size() != 0){ HSSContainer::p theCurrent = this->currentContext.top(); theCurrent->add(newContainer); } else { throw "tried to add a container to nonexistent current"; } } }
void AXRController::add(HSSDisplayObject::p newElement) { newElement->setController(this); if(!this->root){ HSSContainer::p cont = HSSContainer::asContainer(newElement); if (cont){ this->setRoot(cont); } else { std_log1("############## HSSController: cannot add non-controller as root"); } } else { if(this->currentContext.size() != 0){ HSSContainer::p theCurrent = this->currentContext.top(); theCurrent->add(newElement); } else { std_log1("############## HSSController: tried to add a container to nonexistent current"); } } }
void HSSRequest::fire() { AXRDocument* document = this->getController()->document(); //if there is no target if (this->target->empty()) { document->loadXMLFile(this->src); } else { switch (this->mode) { default: { AXRController::p controller = AXRController::p(new AXRController(document)); XMLParser::p xmlParser(new XMLParser(controller.data())); HSSParser::p hssParser(new HSSParser(controller.data())); AXRBuffer::p baseFile = document->getFile(); AXRBuffer::p newFile; try { newFile = document->getFile(this->src); } catch (const AXRError &e) { e.raise(); } if (newFile) { bool loadingSuccess = xmlParser->loadFile(newFile); if (!loadingSuccess) { AXRError("AXRDocument", "Could not load the XML file").raise(); } else { HSSContainer::p root = qSharedPointerCast<HSSContainer > (controller->getRoot()); if (root) { std::vector<QUrl> loadSheets = controller->loadSheetsGet(); for (std::vector<QUrl>::iterator sheetsIt = loadSheets.begin(); sheetsIt != loadSheets.end(); ++sheetsIt) { AXRBuffer::p hssfile; try { hssfile = document->getFile(*sheetsIt); } catch (const AXRError &e) { e.raise(); continue; } if (!hssParser->loadFile(hssfile)) { AXRError("AXRDocument", "Could not load the HSS file").raise(); } } controller->matchRulesToContentTree(); HSSSimpleSelection::const_iterator targetIt, childIt; for (targetIt = this->target->begin(); targetIt != this->target->end(); ++targetIt) { const HSSDisplayObject::p & theDO = *targetIt; HSSContainer::p theContainer = HSSContainer::asContainer(theDO); if (theContainer) { theContainer->clear(); for (childIt = root->getChildren()->begin(); childIt != root->getChildren()->end(); ++childIt) { const HSSDisplayObject::p & theChild = *childIt; theContainer->add(theChild); } } } root->setNeedsRereadRules(true); root->recursiveReadDefinitionObjects(); root->handleEvent(HSSEventTypeLoad, NULL); document->setNeedsDisplay(true); } } } // AXRDocument::tp document = AXRDocument::getInstance(); // AXRWrapper * document = document->getWrapper(); // AXRBuffer::p baseFile = document->getFile(); // // bool loadingSuccess = document->loadFile(baseFile->basePath+this->src, this->src); // if(loadingSuccess){ // unsigned i, size; // for (i=0, size=this->target.size(); i<size; ++i) { // std_log1("Adding loaded file to target"); // // if(this->target[i]->isA(HSSObjectTypeContainer)){ // const HSSContainer::p & theCont = qSharedPointerCast<HSSContainer>(this->target[i]); // const HSSContainer::p & loadedRoot = fileController.getRoot(); // theCont->add(loadedRoot); // // unsigned j, k, size2, size3; // HSSSimpleSelection::p scope = theCont->getChildren(); // for (j=0, size2=fileController.rulesSize(); j<size2; ++j) { // HSSRule::p & theRule = fileController.rulesGet(j); // theRule->childrenAdd(theRule); // } // for (j=0, size2=theCont->rulesSize(); j<size2; ++j) { // HSSRule::p theRule = theCont->rulesGet(j); // for (k=0, size3=theRule->childrenSize(); k<size3; ++k) { // HSSRule::p childRule = theRule->childrenGet(k); // this->getController()->recursiveMatchRulesToDisplayObjects(childRule, scope, theCont); // } // } // // theCont->recursiveReadDefinitionObjects(); // theCont->setNeedsLayout(true); // } // } // } break; } } } }