void IWORKCollector::fillMetadata(librevenge::RVNGPropertyList &props) { if (!m_metadata.m_title.empty()) props.insert("dc:subject", m_metadata.m_title.c_str()); if (!m_metadata.m_author.empty()) props.insert("meta:intial-creator", m_metadata.m_author.c_str()); if (!m_metadata.m_keywords.empty()) props.insert("meta:keyword", m_metadata.m_keywords.c_str()); if (!m_metadata.m_comment.empty()) props.insert("librevenge:comments", m_metadata.m_comment.c_str()); }
void WPSList::Level::addTo(librevenge::RVNGPropertyList &propList, int startVal) const { propList.insert("text:min-label-width", m_labelWidth); propList.insert("text:space-before", m_labelIndent); switch (m_type) { case libwps::BULLET: if (m_bullet.len()) propList.insert("text:bullet-char", m_bullet.cstr()); else { WPS_DEBUG_MSG(("WPSList::Level::addTo: the bullet char is not defined\n")); propList.insert("text:bullet-char", "*"); } break; case libwps::ARABIC: case libwps::LOWERCASE: case libwps::UPPERCASE: case libwps::LOWERCASE_ROMAN: case libwps::UPPERCASE_ROMAN: if (m_prefix.len()) propList.insert("style:num-prefix",m_prefix); if (m_suffix.len()) propList.insert("style:num-suffix", m_suffix); propList.insert("style:num-format", libwps::numberingTypeToString(m_type).c_str()); propList.insert("text:start-value", startVal); break; case libwps::NONE: break; default: WPS_DEBUG_MSG(("WPSList::Level::addTo: the level type is not set\n")); } m_sendToInterface = true; }
void WPSPageSpan::getPageProperty(librevenge::RVNGPropertyList &propList) const { propList.insert("librevenge:num-pages", getPageSpan()); propList.insert("fo:page-height", getFormLength()); propList.insert("fo:page-width", getFormWidth()); if (getFormOrientation() == WPSPageSpan::LANDSCAPE) propList.insert("style:print-orientation", "landscape"); else propList.insert("style:print-orientation", "portrait"); propList.insert("fo:margin-left", getMarginLeft()); propList.insert("fo:margin-right", getMarginRight()); propList.insert("fo:margin-top", getMarginTop()); propList.insert("fo:margin-bottom", getMarginBottom()); }
void WPSList::addLevelTo(int level, librevenge::RVNGPropertyList &propList) const { if (level <= 0 || level > int(m_levels.size()) || m_levels[size_t(level-1)].isDefault()) { WPS_DEBUG_MSG(("WPSList::addLevelTo: level %d is not defined\n",level)); return; } if (m_id==-1) { WPS_DEBUG_MSG(("WPSList::addLevelTo: the list id is not set\n")); static int falseId = 1000; m_id = falseId++; } propList.insert("librevenge:list-id", m_id); propList.insert("librevenge:level", level); m_levels[size_t(level-1)].addTo(propList,m_actualIndices[size_t(level-1)]); }
void IWORKLanguageManager::writeProperties(const std::string &tag, librevenge::RVNGPropertyList &props) const { #ifdef WITH_LIBLANGTAG const unordered_map<string, RVNGPropertyList>::const_iterator it = m_propsMap.find(tag); if (it == m_propsMap.end()) { ETONYEK_DEBUG_MSG(("IWORKLanguageManager::writeProperties: unknown tag %s\n", tag.c_str())); return; } for (RVNGPropertyList::Iter iter(it->second); !iter.last(); iter.next()) props.insert(iter.key(), iter()->getStr()); #else (void) tag; (void) props; #endif }
void WPSFont::addTo(librevenge::RVNGPropertyList &propList) const { double fontSizeChange = 1.0; switch (m_attributes& 0x0000001f) { case 0x01: // Extra large fontSizeChange = 2.0; break; case 0x02: // Very large fontSizeChange = 1.5; break; case 0x04: // Large fontSizeChange = 1.2; break; case 0x08: // Small print fontSizeChange = 0.8; break; case 0x10: // Fine print fontSizeChange = 0.6; break; default: // Normal fontSizeChange = 1.0; break; } if (m_attributes & WPS_SUPERSCRIPT_BIT) propList.insert("style:text-position", "super 58%"); else if (m_attributes & WPS_SUBSCRIPT_BIT) propList.insert("style:text-position", "sub 58%"); if (m_attributes & WPS_ITALICS_BIT) propList.insert("fo:font-style", "italic"); if (m_attributes & WPS_BOLD_BIT) propList.insert("fo:font-weight", "bold"); if (m_attributes & WPS_STRIKEOUT_BIT) propList.insert("style:text-line-through-type", "single"); if (m_attributes & WPS_DOUBLE_UNDERLINE_BIT) propList.insert("style:text-underline-type", "double"); else if (m_attributes & WPS_UNDERLINE_BIT) propList.insert("style:text-underline-type", "single"); if (m_attributes & WPS_OVERLINE_BIT) propList.insert("style:text-overline-type", "single"); if (m_attributes & WPS_OUTLINE_BIT) propList.insert("style:text-outline", "true"); if (m_attributes & WPS_SMALL_CAPS_BIT) propList.insert("fo:font-variant", "small-caps"); if (m_attributes & WPS_BLINK_BIT) propList.insert("style:text-blinking", "true"); if (m_attributes & WPS_SHADOW_BIT) propList.insert("fo:text-shadow", "1pt 1pt"); if (m_attributes & WPS_HIDDEN_BIT) propList.insert("text:display", "none"); if (m_attributes & WPS_ALL_CAPS_BIT) propList.insert("fo:text-transform", "uppercase"); if (m_attributes & WPS_EMBOSS_BIT) propList.insert("style:font-relief", "embossed"); else if (m_attributes & WPS_ENGRAVE_BIT) propList.insert("style:font-relief", "engraved"); if (!m_name.empty()) propList.insert("style:font-name", m_name); if (m_size>0) propList.insert("fo:font-size", fontSizeChange*m_size, librevenge::RVNG_POINT); if (m_spacing < 0 || m_spacing > 0) propList.insert("fo:letter-spacing", m_spacing, librevenge::RVNG_POINT); propList.insert("fo:color", m_color.str().c_str()); if (m_languageId < 0) libwps_tools_win::Language::addLocaleName(0x409, propList); if (m_languageId > 0) libwps_tools_win::Language::addLocaleName(m_languageId, propList); }
void libcdr::CDRContentCollector::_lineProperties(librevenge::RVNGPropertyList &propList) { if (m_currentLineStyle.lineType == (unsigned short)-1) { propList.insert("draw:stroke", "solid"); propList.insert("svg:stroke-width", 0.0); propList.insert("svg:stroke-color", "#000000"); } else { if (m_currentLineStyle.lineType & 0x1) propList.insert("draw:stroke", "none"); else if (m_currentLineStyle.lineType & 0x6) { if (m_currentLineStyle.dashArray.size() && (m_currentLineStyle.lineType & 0x4)) propList.insert("draw:stroke", "dash"); else propList.insert("draw:stroke", "solid"); double scale = 1.0; if (m_currentLineStyle.lineType & 0x20) // scale line with image { scale = m_currentTransforms.getScaleX(); double scaleY = m_currentTransforms.getScaleY(); if (scaleY > scale) scale = scaleY; } scale *= m_currentLineStyle.stretch; propList.insert("svg:stroke-width", m_currentLineStyle.lineWidth * scale); propList.insert("svg:stroke-color", m_ps.getRGBColorString(m_currentLineStyle.color)); switch (m_currentLineStyle.capsType) { case 1: propList.insert("svg:stroke-linecap", "round"); break; case 2: propList.insert("svg:stroke-linecap", "square"); break; default: propList.insert("svg:stroke-linecap", "butt"); } switch (m_currentLineStyle.joinType) { case 1: propList.insert("svg:stroke-linejoin", "round"); break; case 2: propList.insert("svg:stroke-linejoin", "bevel"); break; default: propList.insert("svg:stroke-linejoin", "miter"); } if (m_currentLineStyle.dashArray.size()) { int dots1 = 0; int dots2 = 0; unsigned dots1len = 0; unsigned dots2len = 0; unsigned gap = 0; if (m_currentLineStyle.dashArray.size() >= 2) { dots1len = m_currentLineStyle.dashArray[0]; gap = m_currentLineStyle.dashArray[1]; } unsigned long count = m_currentLineStyle.dashArray.size() / 2; unsigned i = 0; for (; i < count;) { if (dots1len == m_currentLineStyle.dashArray[2*i]) dots1++; else break; gap = gap < m_currentLineStyle.dashArray[2*i+1] ? m_currentLineStyle.dashArray[2*i+1] : gap; i++; } if (i < count) { dots2len = m_currentLineStyle.dashArray[2*i]; gap = gap < m_currentLineStyle.dashArray[2*i+1] ? m_currentLineStyle.dashArray[2*i+1] : gap; } for (; i < count;) { if (dots2len == m_currentLineStyle.dashArray[2*i]) dots2++; else break; gap = gap < m_currentLineStyle.dashArray[2*i+1] ? m_currentLineStyle.dashArray[2*i+1] : gap; i++; } if (!dots2) { dots2 = dots1; dots2len = dots1len; } propList.insert("draw:dots1", dots1); propList.insert("draw:dots1-length", 72.0*(m_currentLineStyle.lineWidth * scale)*dots1len, librevenge::RVNG_POINT); propList.insert("draw:dots2", dots2); propList.insert("draw:dots2-length", 72.0*(m_currentLineStyle.lineWidth * scale)*dots2len, librevenge::RVNG_POINT); propList.insert("draw:distance", 72.0*(m_currentLineStyle.lineWidth * scale)*gap, librevenge::RVNG_POINT); } } else { propList.insert("draw:stroke", "solid"); propList.insert("svg:stroke-width", 0.0); propList.insert("svg:stroke-color", "#000000"); } } // Deal with line markers (arrows, etc.) if (!m_currentLineStyle.startMarker.empty()) { CDRPath startMarker(m_currentLineStyle.startMarker); startMarker.transform(m_currentTransforms); if (!m_groupTransforms.empty()) startMarker.transform(m_groupTransforms.top()); CDRTransform tmpTrafo = CDRTransform(1.0, 0.0, 0.0, 0.0, -1.0, 0); startMarker.transform(tmpTrafo); librevenge::RVNGString path, viewBox; double width; startMarker.writeOut(path, viewBox, width); propList.insert("draw:marker-start-viewbox", viewBox); propList.insert("draw:marker-start-path", path); // propList.insert("draw:marker-start-width", width); } if (!m_currentLineStyle.endMarker.empty()) { CDRPath endMarker(m_currentLineStyle.endMarker); endMarker.transform(m_currentTransforms); if (!m_groupTransforms.empty()) endMarker.transform(m_groupTransforms.top()); CDRTransform tmpTrafo = CDRTransform(-1.0, 0.0, 0.0, 0.0, -1.0, 0); endMarker.transform(tmpTrafo); librevenge::RVNGString path, viewBox; double width; endMarker.writeOut(path, viewBox, width); propList.insert("draw:marker-end-viewbox", viewBox); propList.insert("draw:marker-end-path", path); // propList.insert("draw:marker-end-width", width); } }
void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &propList) { if (m_fillOpacity < 1.0) propList.insert("draw:opacity", m_fillOpacity, librevenge::RVNG_PERCENT); if (m_currentFillStyle.fillType == 0) propList.insert("draw:fill", "none"); else { if (m_currentFillStyle.fillType == (unsigned short)-1) propList.insert("draw:fill", "none"); else { switch (m_currentFillStyle.fillType) { case 1: // Solid propList.insert("draw:fill", "solid"); propList.insert("draw:fill-color", m_ps.getRGBColorString(m_currentFillStyle.color1)); propList.insert("svg:fill-rule", "evenodd"); break; case 2: // Gradient if (m_currentFillStyle.gradient.m_stops.empty()) propList.insert("draw:fill", "none"); else if (m_currentFillStyle.gradient.m_stops.size() == 1) { propList.insert("draw:fill", "solid"); propList.insert("draw:fill-color", m_ps.getRGBColorString(m_currentFillStyle.gradient.m_stops[0].m_color)); propList.insert("svg:fill-rule", "evenodd"); } else if (m_currentFillStyle.gradient.m_stops.size() == 2) { double angle = m_currentFillStyle.gradient.m_angle * 180 / M_PI; while (angle < 0.0) angle += 360.0; while (angle > 360.0) angle -= 360.0; propList.insert("draw:fill", "gradient"); propList.insert("draw:start-color", m_ps.getRGBColorString(m_currentFillStyle.gradient.m_stops[0].m_color)); propList.insert("draw:end-color", m_ps.getRGBColorString(m_currentFillStyle.gradient.m_stops[1].m_color)); propList.insert("draw:angle", (int)angle); switch (m_currentFillStyle.gradient.m_type) { case 1: // linear case 3: // conical propList.insert("draw:style", "linear"); angle += 90.0; while (angle < 0.0) angle += 360.0; while (angle > 360.0) angle -= 360.0; propList.insert("draw:angle", (int)angle); propList.insert("draw:border", (double)(m_currentFillStyle.gradient.m_edgeOffset)/100.0, librevenge::RVNG_PERCENT); break; case 2: // radial propList.insert("draw:border", (2.0 * (double)(m_currentFillStyle.gradient.m_edgeOffset)/100.0), librevenge::RVNG_PERCENT); propList.insert("draw:style", "radial"); propList.insert("svg:cx", (double)(0.5 + m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT); propList.insert("svg:cy", (double)(0.5 + m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT); break; case 4: // square propList.insert("draw:border", (2.0 * (double)(m_currentFillStyle.gradient.m_edgeOffset)/100.0), librevenge::RVNG_PERCENT); propList.insert("draw:style", "square"); propList.insert("svg:cx", (double)(0.5 + m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT); propList.insert("svg:cy", (double)(0.5 + m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT); break; default: propList.insert("draw:style", "linear"); angle += 90.0; while (angle < 0.0) angle += 360.0; while (angle > 360.0) angle -= 360.0; propList.insert("draw:angle", (int)angle); librevenge::RVNGPropertyListVector vec; for (unsigned i = 0; i < m_currentFillStyle.gradient.m_stops.size(); i++) { libcdr::CDRGradientStop &gradStop = m_currentFillStyle.gradient.m_stops[i]; librevenge::RVNGPropertyList stopElement; stopElement.insert("svg:offset", gradStop.m_offset, librevenge::RVNG_PERCENT); stopElement.insert("svg:stop-color", m_ps.getRGBColorString(gradStop.m_color)); stopElement.insert("svg:stop-opacity", m_fillOpacity, librevenge::RVNG_PERCENT); vec.append(stopElement); } propList.insert("svg:linearGradient", vec); break; } } else // output svg gradient as a hail mary pass towards ODG that does not really support it { propList.insert("draw:fill", "gradient"); propList.insert("draw:style", "linear"); double angle = m_currentFillStyle.gradient.m_angle * 180 / M_PI; angle += 90.0; while (angle < 0.0) angle += 360.0; while (angle > 360.0) angle -= 360.0; propList.insert("draw:angle", (int)angle); librevenge::RVNGPropertyListVector vec; for (unsigned i = 0; i < m_currentFillStyle.gradient.m_stops.size(); i++) { libcdr::CDRGradientStop &gradStop = m_currentFillStyle.gradient.m_stops[i]; librevenge::RVNGPropertyList stopElement; stopElement.insert("svg:offset", gradStop.m_offset, librevenge::RVNG_PERCENT); stopElement.insert("svg:stop-color", m_ps.getRGBColorString(gradStop.m_color)); stopElement.insert("svg:stop-opacity", m_fillOpacity, librevenge::RVNG_PERCENT); vec.append(stopElement); } propList.insert("svg:linearGradient", vec); } break; case 7: // Pattern { std::map<unsigned, CDRPattern>::iterator iterPattern = m_ps.m_patterns.find(m_currentFillStyle.imageFill.id); if (iterPattern != m_ps.m_patterns.end()) { propList.insert("draw:fill", "bitmap"); librevenge::RVNGBinaryData image; _generateBitmapFromPattern(image, iterPattern->second, m_currentFillStyle.color1, m_currentFillStyle.color2); #if DUMP_PATTERN librevenge::RVNGString filename; filename.sprintf("pattern%.8x.bmp", m_currentFillStyle.imageFill.id); FILE *f = fopen(filename.cstr(), "wb"); if (f) { const unsigned char *tmpBuffer = image.getDataBuffer(); for (unsigned long k = 0; k < image.size(); k++) fprintf(f, "%c",tmpBuffer[k]); fclose(f); } #endif propList.insert("draw:fill-image", image); propList.insert("librevenge:mime-type", "image/bmp"); propList.insert("style:repeat", "repeat"); if (m_currentFillStyle.imageFill.isRelative) { propList.insert("svg:width", m_currentFillStyle.imageFill.width, librevenge::RVNG_PERCENT); propList.insert("svg:height", m_currentFillStyle.imageFill.height, librevenge::RVNG_PERCENT); } else { double scaleX = 1.0; double scaleY = 1.0; if (m_currentFillStyle.imageFill.flags & 0x04) // scale fill with image { scaleX = m_currentTransforms.getScaleX(); scaleY = m_currentTransforms.getScaleY(); } propList.insert("svg:width", m_currentFillStyle.imageFill.width * scaleX); propList.insert("svg:height", m_currentFillStyle.imageFill.height * scaleY); } propList.insert("draw:fill-image-ref-point", "bottom-left"); if (m_currentFillStyle.imageFill.isRelative) { if (m_currentFillStyle.imageFill.xOffset != 0.0 && m_currentFillStyle.imageFill.xOffset != 1.0) propList.insert("draw:fill-image-ref-point-x", m_currentFillStyle.imageFill.xOffset, librevenge::RVNG_PERCENT); if (m_currentFillStyle.imageFill.yOffset != 0.0 && m_currentFillStyle.imageFill.yOffset != 1.0) propList.insert("draw:fill-image-ref-point-y", m_currentFillStyle.imageFill.yOffset, librevenge::RVNG_PERCENT); } else { if (m_fillTransforms.getTranslateX() != 0.0) { double xOffset = m_fillTransforms.getTranslateX() / m_currentFillStyle.imageFill.width; normalize(xOffset); propList.insert("draw:fill-image-ref-point-x", xOffset, librevenge::RVNG_PERCENT); } if (m_fillTransforms.getTranslateY() != 0.0) { double yOffset = m_fillTransforms.getTranslateY() / m_currentFillStyle.imageFill.width; normalize(yOffset); propList.insert("draw:fill-image-ref-point-y", 1.0 - yOffset, librevenge::RVNG_PERCENT); } } } else { // We did not find the pattern, so fill solid with the background colour propList.insert("draw:fill", "solid"); propList.insert("draw:fill-color", m_ps.getRGBColorString(m_currentFillStyle.color2)); propList.insert("svg:fill-rule", "evenodd"); } } break; case 9: // Bitmap case 11: // Texture { std::map<unsigned, librevenge::RVNGBinaryData>::iterator iterBmp = m_ps.m_bmps.find(m_currentFillStyle.imageFill.id); if (iterBmp != m_ps.m_bmps.end()) { propList.insert("librevenge:mime-type", "image/bmp"); propList.insert("draw:fill", "bitmap"); propList.insert("draw:fill-image", iterBmp->second); propList.insert("style:repeat", "repeat"); if (m_currentFillStyle.imageFill.isRelative) { propList.insert("svg:width", m_currentFillStyle.imageFill.width, librevenge::RVNG_PERCENT); propList.insert("svg:height", m_currentFillStyle.imageFill.height, librevenge::RVNG_PERCENT); } else { double scaleX = 1.0; double scaleY = 1.0; if (m_currentFillStyle.imageFill.flags & 0x04) // scale fill with image { scaleX = m_currentTransforms.getScaleX(); scaleY = m_currentTransforms.getScaleY(); } propList.insert("svg:width", m_currentFillStyle.imageFill.width * scaleX); propList.insert("svg:height", m_currentFillStyle.imageFill.height * scaleY); } propList.insert("draw:fill-image-ref-point", "bottom-left"); if (m_currentFillStyle.imageFill.isRelative) { if (m_currentFillStyle.imageFill.xOffset != 0.0 && m_currentFillStyle.imageFill.xOffset != 1.0) propList.insert("draw:fill-image-ref-point-x", m_currentFillStyle.imageFill.xOffset, librevenge::RVNG_PERCENT); if (m_currentFillStyle.imageFill.yOffset != 0.0 && m_currentFillStyle.imageFill.yOffset != 1.0) propList.insert("draw:fill-image-ref-point-y", m_currentFillStyle.imageFill.yOffset, librevenge::RVNG_PERCENT); } else { if (m_fillTransforms.getTranslateX() != 0.0) { double xOffset = m_fillTransforms.getTranslateX() / m_currentFillStyle.imageFill.width; while (xOffset < 0.0) xOffset += 1.0; while (xOffset > 1.0) xOffset -= 1.0; propList.insert("draw:fill-image-ref-point-x", xOffset, librevenge::RVNG_PERCENT); } if (m_fillTransforms.getTranslateY() != 0.0) { double yOffset = m_fillTransforms.getTranslateY() / m_currentFillStyle.imageFill.width; while (yOffset < 0.0) yOffset += 1.0; while (yOffset > 1.0) yOffset -= 1.0; propList.insert("draw:fill-image-ref-point-y", 1.0 - yOffset, librevenge::RVNG_PERCENT); } } } else propList.insert("draw:fill", "none"); } break; case 10: // Full color { std::map<unsigned, librevenge::RVNGBinaryData>::iterator iterVect = m_ps.m_vects.find(m_currentFillStyle.imageFill.id); if (iterVect != m_ps.m_vects.end()) { propList.insert("draw:fill", "bitmap"); propList.insert("librevenge:mime-type", "image/svg+xml"); propList.insert("draw:fill-image", iterVect->second); propList.insert("style:repeat", "repeat"); if (m_currentFillStyle.imageFill.isRelative) { propList.insert("svg:width", m_currentFillStyle.imageFill.width, librevenge::RVNG_PERCENT); propList.insert("svg:height", m_currentFillStyle.imageFill.height, librevenge::RVNG_PERCENT); } else { double scaleX = 1.0; double scaleY = 1.0; if (m_currentFillStyle.imageFill.flags & 0x04) // scale fill with image { scaleX = m_currentTransforms.getScaleX(); scaleY = m_currentTransforms.getScaleY(); } propList.insert("svg:width", m_currentFillStyle.imageFill.width * scaleX); propList.insert("svg:height", m_currentFillStyle.imageFill.height * scaleY); } propList.insert("draw:fill-image-ref-point", "bottom-left"); if (m_currentFillStyle.imageFill.isRelative) { if (m_currentFillStyle.imageFill.xOffset != 0.0 && m_currentFillStyle.imageFill.xOffset != 1.0) propList.insert("draw:fill-image-ref-point-x", m_currentFillStyle.imageFill.xOffset, librevenge::RVNG_PERCENT); if (m_currentFillStyle.imageFill.yOffset != 0.0 && m_currentFillStyle.imageFill.yOffset != 1.0) propList.insert("draw:fill-image-ref-point-y", m_currentFillStyle.imageFill.yOffset, librevenge::RVNG_PERCENT); } else { if (m_fillTransforms.getTranslateX() != 0.0) { double xOffset = m_fillTransforms.getTranslateX() / m_currentFillStyle.imageFill.width; while (xOffset < 0.0) xOffset += 1.0; while (xOffset > 1.0) xOffset -= 1.0; propList.insert("draw:fill-image-ref-point-x", xOffset, librevenge::RVNG_PERCENT); } if (m_fillTransforms.getTranslateY() != 0.0) { double yOffset = m_fillTransforms.getTranslateY() / m_currentFillStyle.imageFill.width; while (yOffset < 0.0) yOffset += 1.0; while (yOffset > 1.0) yOffset -= 1.0; propList.insert("draw:fill-image-ref-point-y", 1.0 - yOffset, librevenge::RVNG_PERCENT); } } } else propList.insert("draw:fill", "none"); } break; default: propList.insert("draw:fill", "none"); break; } } } }