Exemplo n.º 1
0
void ODe_Style_List::setLevelStyle(UT_uint8 level, const PP_AttrProp& rBlockAP) {
    
    UT_UTF8String levelString;
    ODe_ListLevelStyle* pLevelStyle;
    const gchar* pValue = NULL;
    bool ok;
    
    UT_UTF8String_sprintf(levelString, "%u", level);
    
    pLevelStyle = m_levelStyles.pick(levelString.utf8_str());
    
    if (pLevelStyle != NULL) {
        // This level style aws already set. There's nothing to be done.
        return;
    }
    
    ok = rBlockAP.getProperty("list-style", pValue);
    UT_return_if_fail(ok && pValue);
    
    if (!strcmp(pValue, "Numbered List") ||
        !strcmp(pValue, "Lower Case List") ||
        !strcmp(pValue, "Upper Case List") ||
        !strcmp(pValue, "Lower Roman List") ||
        !strcmp(pValue, "Upper Roman List") ||
        !strcmp(pValue, "Hebrew List") ||
        !strcmp(pValue, "Arabic List")) {
            
        pLevelStyle = new ODe_Numbered_ListLevelStyle();

    } else if (!strcmp(pValue, "Bullet List") ||
               !strcmp(pValue, "Dashed List") ||
               !strcmp(pValue, "Square List") ||
               !strcmp(pValue, "Triangle List") ||
               !strcmp(pValue, "Diamond List") ||
               !strcmp(pValue, "Star List") ||
               !strcmp(pValue, "Tick List") ||
               !strcmp(pValue, "Box List") ||
               !strcmp(pValue, "Hand List") ||
               !strcmp(pValue, "Heart List") ||
               !strcmp(pValue, "Implies List")) {
                
        pLevelStyle = new ODe_Bullet_ListLevelStyle();
        
        
    } else {
        UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
        return;
    }


    m_levelStyles.insert(levelString.utf8_str(), pLevelStyle);
    pLevelStyle->fetchAttributesFromAbiBlock(rBlockAP);
}
Exemplo n.º 2
0
/*! Create a new AttrProp based upon the given one, adding or replacing the items given.
	 \return NULL on failure, the newly-created PP_AttrProp clone otherwise.
*/
PP_AttrProp * PP_AttrProp::cloneWithReplacements(const gchar ** attributes,
												 const gchar ** properties,
												 bool bClearProps) const
{
	bool bIgnoreProps = false; // see below

	// first, create a new AttrProp using just the values given.

	PP_AttrProp * papNew = new PP_AttrProp();
	if (!papNew)
		goto Failed;
	if (!papNew->setAttributes(attributes) || !papNew->setProperties(properties))
		goto Failed;

	// next, add any items that we have that are not present
	// (have not been overridden) in the new one.

	UT_uint32 k;
	const gchar * n;
	const gchar * v;
	const gchar * vNew;

	k = 0;
	while (getNthAttribute(k++,n,v))
	{
		// TODO decide if/whether to allow PT_PROPS_ATTRIBUTE_NAME here.
		// TODO The issue is: we use it to store the CSS properties and
		// TODO when we see it, we expand the value into one or more
		// TODO properties.  if we allow it to be given here, should
		// TODO we blowaway all of the existing properties and create
		// TODO them from this?  or should we expand it and override
		// TODO individual properties?
		// TODO for now, we just barf on it.
		UT_return_val_if_fail (strcmp(n,PT_PROPS_ATTRIBUTE_NAME)!=0, false); // cannot handle PROPS here
		if (!papNew->getAttribute(n,vNew))
			if (!papNew->setAttribute(n,v))
				goto Failed;
	}

	// we want to be able to remove all properties by setting the
	// props attribute to ""; in order for that to work, we need to
	// skip the following loop if props is set to ""
	const gchar * szValue;

	if(papNew->getAttribute("props", szValue) && !*szValue)
		bIgnoreProps = true;

	if (!bClearProps && !bIgnoreProps)
	{
		k = 0;
		while (getNthProperty(k++,n,v))
		{
			if (!papNew->getProperty(n,vNew))
				if (!papNew->setProperty(n,v))
					goto Failed;
		}
	}

	// the following will remove all properties set to ""; this allows us
	// to remove properties by setting them to ""
	papNew->_clearEmptyProperties();
	papNew->_clearEmptyAttributes();

	return papNew;

Failed:
	DELETEP(papNew);
	return NULL;
}
Exemplo n.º 3
0
void ODe_Frame_Listener::_openODTextbox(const PP_AttrProp& rAP,
                                        ODe_ListenerAction& /*rAction*/) 
{
    UT_UTF8String output;
    UT_UTF8String str;
    bool ok;
    const gchar* pValue = NULL;
    ODe_Style_Style* pStyle;
    
    pStyle = new ODe_Style_Style();
    pStyle->setFamily("graphic");
    pStyle->fetchAttributesFromAbiFrame(rAP);
    
    // Abi frames have no padding
    // (no margin between frame borders and its content)
    pStyle->setPadding("0cm");
    
    // Abi frames are aways positioned from its top-left corner.
    pStyle->setHorizontalPos("from-left");
    pStyle->setVerticalPos("from-top");
    
    // For OOo to recognize a textbox as being a textbox, it will
    // need to have the parent style name "Frame". I can't find it
    // in the ODF spec, but without it OOo considers the textbox to
    // be a generic drawing object (check the Navigator window in OOo).
    pStyle->setParentStyleName("Frame");
    // Make sure an (empty) Frame style exists, for completeness sake
	// (OOo doesn't seem to care if it exists or not).
    if (!m_rStyles.getGraphicsStyle("Frame")) {
        ODe_Style_Style* pFrameStyle = new ODe_Style_Style();
		pFrameStyle->setStyleName("Frame");
		pFrameStyle->setFamily("graphic");
        m_rStyles.addGraphicsStyle(pFrameStyle);
    }

	m_rAutomatiStyles.storeGraphicStyle(pStyle);

    ////
    // Write <draw:frame>
    
    _printSpacesOffset(output);
    output += "<draw:frame";

    UT_UTF8String_sprintf(str, "Frame%u", m_rAuxiliaryData.m_frameCount+1);
    ODe_writeAttribute(output, "draw:name", str);
    m_rAuxiliaryData.m_frameCount++;
    
    ODe_writeAttribute(output, "draw:style-name", pStyle->getName());

    UT_UTF8String_sprintf(str, "%u", m_zIndex);
    ODe_writeAttribute(output, "draw:z-index", str);


    ok = rAP.getProperty("position-to", pValue);

    if (pValue && !strcmp(pValue, "block-above-text")) {

        ODe_writeAttribute(output, "text:anchor-type", "paragraph");

        ok = rAP.getProperty("xpos", pValue);
        UT_ASSERT(ok && pValue != NULL);
        ODe_writeAttribute(output, "svg:x", pValue);

        ok = rAP.getProperty("ypos", pValue);
        UT_ASSERT(ok && pValue != NULL);
        ODe_writeAttribute(output, "svg:y", pValue);
    } else {
        // Everything else (column and page) will be treated as page
        // anchored.
        
        ODe_writeAttribute(output, "text:anchor-type", "page");

	if(pValue && !strcmp(pValue, "column-above-text"))
	{
	  //
	  // Get the most recent page style so we can do the arithmetic
	  // Won't work for x in multi-columned docs
	  //
	    UT_uint32 numPStyles =  m_rAutomatiStyles.getSectionStylesCount();
	    UT_UTF8String stylePName;
	    UT_UTF8String_sprintf(stylePName, "PLayout%d", numPStyles + 1);
	    ODe_Style_PageLayout * pPageL = m_rAutomatiStyles.getPageLayout(stylePName.utf8_str());

	    ok = rAP.getProperty("frame-col-xpos", pValue);
	    UT_ASSERT(ok && pValue != NULL);
	    double xCol =  UT_convertToInches(pValue);
	    const gchar* pSVal= pPageL->getPageMarginLeft();
	    double xPageL = UT_convertToInches(pSVal);
	    double xTot = xPageL + xCol;
	    pValue = UT_convertInchesToDimensionString(DIM_IN,xTot,"4");
	    ODe_writeAttribute(output, "svg:x", pValue);
        
	    ok = rAP.getProperty("frame-col-ypos", pValue);
	    UT_ASSERT(ok && pValue != NULL);
	    double yCol =  UT_convertToInches(pValue);
	    pSVal= pPageL->getPageMarginTop();
	    double yPageL = UT_convertToInches(pSVal);
	    double yTot = yPageL + yCol;
	    pValue = UT_convertInchesToDimensionString(DIM_IN,yTot,"4");
	    ODe_writeAttribute(output, "svg:y", pValue);	  
	}
	else
	{
	    ok = rAP.getProperty("frame-page-xpos", pValue);
	    UT_ASSERT(ok && pValue != NULL);
	    ODe_writeAttribute(output, "svg:x", pValue);
        
	    ok = rAP.getProperty("frame-page-ypos", pValue);
	    UT_ASSERT(ok && pValue != NULL);
	    ODe_writeAttribute(output, "svg:y", pValue);
	}
    }
    
    
    ok = rAP.getProperty("frame-width", pValue);
    if (ok && pValue != NULL) {
        ODe_writeAttribute(output, "svg:width", pValue);
    }
    
    output += ">\n";
    
    ODe_writeUTF8String(m_pTextOutput, output);
    m_spacesOffset++;
    
    ////
    // Write <draw:text-box>
    
    output.clear();
    _printSpacesOffset(output);
    output += "<draw:text-box";
    
    ok = rAP.getProperty("frame-height", pValue);
    if (ok && pValue != NULL) {
        ODe_writeAttribute(output, "fo:min-height", pValue);
    }
    
    output += ">\n";
    
    ODe_writeUTF8String(m_pTextOutput, output);
    m_spacesOffset++;
}