bool PlainTextFileType::write(Document* const Doc, std::ostream &OutputStream, const std::string& FileNameOrExtension) { PlainDocumentRefPtr TheDocument = dynamic_cast<PlainDocument*>(Doc); std::vector<Element*> GenericRoots; GenericRoots = TheDocument->getRootElements(); for(UInt32 i=0;i<GenericRoots.size();i++) { PlainDocumentBranchElementRefPtr RootElement; RootElement = dynamic_cast<PlainDocumentBranchElement*>(GenericRoots[i]); for(UInt32 j=0;j<RootElement->getElementCount()-1;j++) { PlainDocumentLeafElementRefPtr LeafElement; LeafElement = dynamic_cast<PlainDocumentLeafElement*>(RootElement->getElement(j)); OutputStream<<LeafElement->getText(); } PlainDocumentLeafElementRefPtr LeafElement; LeafElement = dynamic_cast<PlainDocumentLeafElement*>(RootElement->getElement(RootElement->getElementCount()-1)); OutputStream<<LeafElement->getText().substr(0,LeafElement->getTextLength()-2); } return false; }
void FixedHeightLayoutManager::populateCache(void) { // cache exists only when the word wrap is enabled if(getParentTextDomArea()->getWrapStyleWord()) { linesToElements.clear(); if(getParentTextDomArea()->getDocumentModel()) { ElementRefPtr defaultRoot=getParentTextDomArea()->getDocumentModel()->getDefaultRootElement(); if(defaultRoot) { PlainDocumentBranchElementRefPtr rootElement = dynamic_pointer_cast<PlainDocumentBranchElement>(defaultRoot); Pnt2f init = getParentTextDomArea()->getPosition(); Vec2f dimensions = getParentTextDomArea()->getPreferredSize(); for(UInt32 i=0;i<rootElement->getElementCount();i++) { //GlyphViewRefPtr view = GlyphView::create(); PlainDocumentLeafElementRefPtr temp = dynamic_cast<PlainDocumentLeafElement*>(rootElement->getElement(i)); //view->setElement(ElementRefPtr(temp)); UInt32 noOfCharacters= temp->getTextLength(); /* to be edited............ Real32 totalLengthOfAllCharacters = noOfCharacters * widthOfCharacter; UInt32 noOfLines = UInt32(ceil(totalLengthOfAllCharacters / dimensions.x())); for(UInt32 j=0;j<noOfLines;j++) linesToElements.push_back(i); */ } } } } }