Esempio n. 1
0
void ofxLayout::applyStyles(ofxLayoutElement* element){
    ofxOSS* styleObject;
    if(element == NULL){
        element = &contextTreeRoot;
        styleObject = &contextTreeRoot.styles;
    }
    else{
        styleObject = &element->styles;
    }
    // Order is important! Styling override order is [ CLASS, ID, INLINE ]
    vector<string> classes = ofSplitString(element->getClasses(), " ");
    for(int i = 0; i < classes.size(); i++){
        if(contextTreeRoot.styles.classMap.count(classes[i])){
            element->overrideStyles(&contextTreeRoot.styles.classMap[classes[i]]);
        }
    }
    string id = element->getID();
    if(contextTreeRoot.styles.idMap.count(id)){
        element->overrideStyles(&contextTreeRoot.styles.idMap[id]);
    }
    
    ofxOSS inlineStyles = element->getInlineStyles();
    element->overrideStyles(&inlineStyles);
    
    updateAssets(element);
    for(ofxLayoutElement* child : element->children()){
        // RESET CHILD ELEMENT STYLES AND RETURN STATE TO "DEFAULT"
        applyStyles(child);
        child->setState("default");
    }
}
Esempio n. 2
0
/*!  
 * Translate a psiconv Word file representation into an AbiWord document
 */
UT_Error IE_Imp_Psion_Word::parseFile(const psiconv_file psionfile)
{
	UT_Error res;
	bool header,footer;
	UT_DEBUGMSG(("PSION: Parsing Psion Word file\n"));

	// It really should be a Word file!
	if (psionfile->type != psiconv_word_file)
		return UT_IE_BOGUSDOCUMENT;
	psiconv_word_f file = (psiconv_word_f) (psionfile->file);
	
	// Handle all styles
	if ((res = applyStyles(file->styles_sec)))
		return res;

	// Handle the page settings (they always apply to the whole document
	if ((res = applyPageAttributes(file->page_sec,header,footer)))
		return res;

	// Handle all paragraphs with text and layout
	if ((res = readParagraphs(file->paragraphs,file->styles_sec)))
		return res;
	
	// Handle the headers and footers
	if ((res = processHeaderFooter(file->page_sec,header,footer)))
		return res;
	
	return UT_OK;
}
Esempio n. 3
0
void XHTMLReader::startElementHandler(const char *tag, const char **attributes) {
	static const std::string HASH = "#";
	const char *id = attributeValue(attributes, "id");
	const char *inlineStyle = attributeValue(attributes, "style");
	const char *klass = attributeValue(attributes, "class");
	if (id != 0) {
		myModelReader.addHyperlinkLabel(myReferenceName + HASH + id);
	}

	const std::string sTag = ZLUnicodeUtil::toLower(tag);
	myElementStack.push_back(StyleSheetTable::Element(sTag, klass, id));

	myStyleStack.resize(myStyleStack.size() + 1);
	StyleSheetTable::Style *style = &myStyleStack.back();
	if (myStyleStack.size() > 1) {
		style->inherit(myStyleStack.at(myStyleStack.size()-2));
	}

	myStyleSheetTable.applyStyles(myElementStack, *style);
	if (inlineStyle) {
		style->apply(myStyleParser.parseString(inlineStyle));
	}

	myParseStack.resize(myParseStack.size() + 1);
	ParseContext &prev(myParseStack.at(myParseStack.size()-2));
	ParseContext &context(myParseStack.back());
	if (style->TextStyle.opacitySupported()) {
		int opacity = prev.opacity;
		opacity *= style->TextStyle.opacity();
		opacity /= 255;
		context.opacity = opacity;
	} else {
		context.opacity = prev.opacity;
	}

	// Don't collect empty styles
	if (style->empty()) {
		myStyleStack.resize(myStyleStack.size()-1);
		style = NULL;
	} else {
		context.styleIndex = myStyleStack.size() - 1;
		if (style->PageBreakBefore == B3_TRUE) {
			addPageBreak();
		}
	}

	XHTMLTagAction *action = ourTagActions[sTag];
	if (action != 0) {
		action->doAtStart(*this, attributes);
	}

	if (context.kind >= 0) {
		context.decoration = ZLTextStyleCollection::Instance().decoration(context.kind);
	}

	if (myModelReader.paragraphIsOpen()) {
		applyStyles(myParseStack.back());
	}
}
Esempio n. 4
0
void XHTMLReader::beginParagraph() {
	if (!myModelReader.paragraphIsOpen()) {
		myModelReader.beginParagraph();
		for (std::vector<ParseContext>::iterator it = myParseStack.begin(); it != myParseStack.end(); ++it) {
			applyStyles(*it);
		}
	}
}
Esempio n. 5
0
void ofxLayout::applyChanges(){
    applyStyles();
    if(x || y){
        getBody()->setPosition(ofPoint(x,y));
    }
}
Esempio n. 6
0
void interpretCommands(void)
{
  short i, num, den, nbars;
  Char STR2[256];
  short FORLIM;

  strcpy(title_line, cline[(long)title]);
  strcpy(part_line, cline[(long)part]);
  if (*cline[(long)poet] != '\0' || *cline[(long)composer] != '\0')
    sprintf(composer_line, "\\mtxComposerLine{%s}{%s}",
	    cline[(long)poet], cline[(long)composer]);
  else
    *composer_line = '\0';
  strcpy(pmx_line, cline[(long)pmx]);
  GetNextWord(options_line, cline[(long)options], blank_, dummy);
  FORLIM = known_styles;
  for (i = 0; i <= FORLIM - 1; i++)
    style_used[i] = false;
  applyStyles();
  setVoices(voices);
  FORLIM = known_styles;
  for (i = old_known_styles; i <= FORLIM - 1; i++) {
    if (!style_used[i]) {
      warning("The following style was supplied but not used", !print);
      puts(known_style[i]);
    }
  }
  setClefs(clefs);
  if (!redefined[(long)meter]) {
    sprintf(STR2, "You have not defined Meter, assuming \"%s\" ",
	    cline[(long)meter]);
    warning(STR2, !print);
  }
  getMeter(cline[(long)meter], &meternum, &meterdenom, &pmnum, &pmdenom);
  setDefaultDuration(meterdenom);
  if (meternum == 0 &&
      !(redefined[(long)pages] || redefined[(long)systems] ||
	redefined[(long)bars])) {
    strcpy(cline[(long)bars], "1");
    redefined[(long)bars] = true;
  }
  if (redefined[(long)pages] || redefined[(long)systems]) {
    if (redefined[(long)bars])
      warning("BARS/LINE ignored since you specified PAGES or SYSTEMS", print);
    if (redefined[(long)systems])
      getNum(cline[(long)systems], &n_systems);
    else
      warning("PAGES specified but not SYSTEMS", !print);
    if (redefined[(long)pages])
      getNum(cline[(long)pages], &n_pages);
    else
      warning("SYSTEMS specified but not PAGES", !print);
  } else if (redefined[(long)bars]) {
    getNum(cline[(long)bars], &nbars);
    if (nbars > 0) {
      n_pages = 0;
      n_systems = nbars;
    }
  }
  getNum(cline[(long)sharps], &n_sharps);
  setSpace(cline[(long)space]);
  setSize(cline[(long)msize]);
  getTwoNums(cline[(long)shortnote], &num, &den);
  if (den == 0)
    den = 1;
  short_note = num * 64 / den;
  if (*cline[(long)flats] != '\0') {
    getNum(cline[(long)flats], &n_sharps);
    n_sharps = -n_sharps;
  }
  setName();
  setIndent();
  setInitOctave();
  setOnly(cline[(long)only]);
  setRange(cline[(long)range]);
  setDimension(cline[(long)width], width);
  setDimension(cline[(long)height], height);
  if (*options_line != '\0') {
    warning("\"Options\" is cryptic and obsolescent.", !print);
    printf("  Use \"Enable\" and \"Disable\" instead.\n");
  }
  FORLIM = strlen(options_line);
  for (i = 0; i <= FORLIM - 1; i++)
    processOption(options_line[i]);
}