const char * GR_Graphics::invertDimension(UT_Dimension dim, double dValue) const { // return pointer to static buffer -- use it quickly. double dInches = dValue / UT_LAYOUT_RESOLUTION; return UT_convertInchesToDimensionString( dim, dInches); }
void AP_Dialog_Paragraph::_syncControls(tControl changed, bool /*bAll = false */) { if(changed == id_SPIN_LEFT_INDENT) { // need to check the limits // cannot go past left page margin. // TODO : is there a minimum text width? double leftPageMargin = UT_convertToDimension(m_pageLeftMargin, m_dim); double rightIndent = UT_convertToDimension(_getSpinItemValue(id_SPIN_RIGHT_INDENT), m_dim); if(-UT_convertToDimension(_getSpinItemValue(id_SPIN_LEFT_INDENT), m_dim) > leftPageMargin) { _setSpinItemValue(id_SPIN_LEFT_INDENT, (const gchar *)UT_formatDimensionString(m_dim, -leftPageMargin), op_SYNC); } // nor past pagesize - rightIndent on right. if(UT_convertDimensionless(_getSpinItemValue(id_SPIN_LEFT_INDENT)) > UT_convertInchesToDimension(m_iMaxWidth, m_dim) - rightIndent) { _setSpinItemValue(id_SPIN_LEFT_INDENT, (const gchar *)UT_convertInchesToDimensionString(m_dim, m_iMaxWidth - rightIndent), op_SYNC); } } if(changed == id_SPIN_RIGHT_INDENT) { // need to check the limits // cannot go past right page margin. double rightPageMargin = UT_convertToDimension(m_pageRightMargin, m_dim); double leftIndent = UT_convertToDimension(_getSpinItemValue(id_SPIN_LEFT_INDENT), m_dim); if(-UT_convertToDimension(_getSpinItemValue(id_SPIN_RIGHT_INDENT), m_dim) > rightPageMargin) { _setSpinItemValue(id_SPIN_RIGHT_INDENT, (const gchar *)UT_formatDimensionString(m_dim, -rightPageMargin), op_SYNC); } // nor can we force text left past pagesize, minus left margin if(UT_convertDimensionless(_getSpinItemValue(id_SPIN_RIGHT_INDENT)) > UT_convertInchesToDimension(m_iMaxWidth, m_dim) - leftIndent) { _setSpinItemValue(id_SPIN_RIGHT_INDENT, (const gchar *)UT_convertInchesToDimensionString(m_dim, m_iMaxWidth - leftIndent), op_SYNC); } } if (changed == id_MENU_SPECIAL_INDENT || changed == id_SPIN_SPECIAL_INDENT) { double dDefault = 0.0; bool bDefault = true; double sign = -1.0; if (_getMenuItemValue(id_MENU_SPECIAL_INDENT) == indent_FIRSTLINE) sign = +1.0; if (changed == id_MENU_SPECIAL_INDENT) { switch(_getMenuItemValue(id_MENU_SPECIAL_INDENT)) { case indent_NONE: dDefault = 0.0; break; case indent_FIRSTLINE: case indent_HANGING: // only change to default if existing value is zero dDefault = UT_convertDimensionless(_getSpinItemValue(id_SPIN_SPECIAL_INDENT)); if (dDefault == 0) { bDefault = false; } else { dDefault = 0.5; } break; default: UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); break; } if (bDefault) { if (m_dim != DIM_IN) dDefault = UT_convertInchesToDimension(dDefault, m_dim); const gchar* szNew = UT_convertInchesToDimensionString(m_dim, dDefault, ".1"); _setSpinItemValue(id_SPIN_SPECIAL_INDENT, szNew, op_SYNC); } } else /* (changed == id_SPIN_SPECIAL_INDENT) */ { switch(_getMenuItemValue(id_MENU_SPECIAL_INDENT)) { case indent_NONE: _setMenuItemValue(id_MENU_SPECIAL_INDENT, indent_FIRSTLINE, op_SYNC); break; default: break; } } // if spin contains a negative number, we flip the direction of the indent. double val = UT_convertDimensionless(_getSpinItemValue(id_SPIN_SPECIAL_INDENT)); if (val < 0) { sign = -sign; // sometimes this appears to have no effect. why? if (_getMenuItemValue(id_MENU_SPECIAL_INDENT) == indent_FIRSTLINE) _setMenuItemValue(id_MENU_SPECIAL_INDENT, indent_HANGING, op_SYNC); else if (_getMenuItemValue(id_MENU_SPECIAL_INDENT) == indent_HANGING) _setMenuItemValue(id_MENU_SPECIAL_INDENT, indent_FIRSTLINE, op_SYNC); const gchar* szNew = UT_convertInchesToDimensionString(m_dim, -val, ".1"); _setSpinItemValue(id_SPIN_SPECIAL_INDENT, szNew, op_SYNC); } // sanity check. double leftIndent = UT_convertToDimension(_getSpinItemValue(id_SPIN_LEFT_INDENT), m_dim); double effectiveLeftMargin = leftIndent + (UT_convertToDimension (_getSpinItemValue(id_SPIN_SPECIAL_INDENT), m_dim) * sign); double leftPageMargin = UT_convertToDimension(m_pageLeftMargin, m_dim); double rightIndent = UT_convertToDimension(_getSpinItemValue(id_SPIN_RIGHT_INDENT), m_dim); if(-effectiveLeftMargin > leftPageMargin) { _setSpinItemValue(id_SPIN_SPECIAL_INDENT, (const gchar *)UT_formatDimensionString(m_dim, -leftPageMargin), op_SYNC); } if(effectiveLeftMargin > UT_convertInchesToDimension(m_iMaxWidth, m_dim) - rightIndent) { _setSpinItemValue(id_SPIN_SPECIAL_INDENT, (const gchar *)UT_convertInchesToDimensionString(m_dim, m_iMaxWidth - rightIndent), op_SYNC); } } if (changed == id_SPIN_SPECIAL_SPACING) { switch(_getMenuItemValue(id_MENU_SPECIAL_SPACING)) { case spacing_SINGLE: case spacing_ONEANDHALF: case spacing_DOUBLE: _setMenuItemValue(id_MENU_SPECIAL_SPACING, spacing_MULTIPLE, op_SYNC); break; default: break; } } if (changed == id_MENU_SPECIAL_SPACING) { UT_Dimension dimOld = UT_determineDimension(_getSpinItemValue(id_SPIN_SPECIAL_SPACING), DIM_none); switch(_getMenuItemValue(id_MENU_SPECIAL_SPACING)) { case spacing_SINGLE: _setSpinItemValue(id_SPIN_SPECIAL_SPACING, "1.0", op_SYNC); break; case spacing_ONEANDHALF: _setSpinItemValue(id_SPIN_SPECIAL_SPACING, "1.5", op_SYNC); break; case spacing_DOUBLE: _setSpinItemValue(id_SPIN_SPECIAL_SPACING, "2.0", op_SYNC); break; case spacing_ATLEAST: case spacing_EXACTLY: // only change to default if not dimensioned if (dimOld == DIM_none) _setSpinItemValue(id_SPIN_SPECIAL_SPACING, "12pt", op_SYNC); break; case spacing_MULTIPLE: // only change to default if dimensioned if (dimOld != DIM_none) _setSpinItemValue(id_SPIN_SPECIAL_SPACING, "1.0", op_SYNC); break; default: UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); break; } } // the preview needs to suck in the changed data (to cache it // for subsequent draws) UT_BidiCharType iDir; if(_getCheckItemValue(id_CHECK_DOMDIRECTION) == check_TRUE) iDir = UT_BIDI_RTL; else if(_getCheckItemValue(id_CHECK_DOMDIRECTION) == check_FALSE) iDir = UT_BIDI_LTR; else { // nothing given -- default to LTR UT_DEBUGMSG(("AP_Dialog_Paragraph::_syncControls: no value of dom-dir," " defaulting to LTR\n")); iDir = UT_BIDI_LTR; } m_paragraphPreview->setFormat(m_pageLeftMargin, m_pageRightMargin, (AP_Dialog_Paragraph::tAlignState) _getMenuItemValue(id_MENU_ALIGNMENT), _getSpinItemValue(id_SPIN_SPECIAL_INDENT), (AP_Dialog_Paragraph::tIndentState) _getMenuItemValue(id_MENU_SPECIAL_INDENT), _getSpinItemValue(id_SPIN_LEFT_INDENT), _getSpinItemValue(id_SPIN_RIGHT_INDENT), _getSpinItemValue(id_SPIN_BEFORE_SPACING), _getSpinItemValue(id_SPIN_AFTER_SPACING), _getSpinItemValue(id_SPIN_SPECIAL_SPACING), (AP_Dialog_Paragraph::tSpacingState) _getMenuItemValue(id_MENU_SPECIAL_SPACING), iDir); m_paragraphPreview->queueDraw(); }
bool AP_Dialog_Paragraph::getDialogData(const gchar **& pProps) { UT_Vector v; struct propPair { gchar * prop; gchar * val; }; propPair * p; // only do this if the control has a proper value if (_wasChanged(id_MENU_ALIGNMENT) && _getMenuItemValue(id_MENU_ALIGNMENT)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("text-align"); switch (_getMenuItemValue(id_MENU_ALIGNMENT)) { case align_LEFT: p->val = g_strdup("left"); break; case align_CENTERED: p->val = g_strdup("center"); break; case align_RIGHT: p->val = g_strdup("right"); break; case align_JUSTIFIED: p->val = g_strdup("justify"); break; default: UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } v.addItem(p); } if (_wasChanged(id_CHECK_DOMDIRECTION)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("dom-dir"); if (_getCheckItemValue(id_CHECK_DOMDIRECTION) == check_TRUE) p->val = g_strdup("rtl"); else p->val = g_strdup("ltr"); v.addItem(p); } if (_wasChanged(id_SPIN_LEFT_INDENT)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("margin-left"); p->val = g_strdup(_getSpinItemValue(id_SPIN_LEFT_INDENT)); v.addItem(p); } if (_wasChanged(id_SPIN_RIGHT_INDENT)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("margin-right"); p->val = g_strdup(_getSpinItemValue(id_SPIN_RIGHT_INDENT)); v.addItem(p); } // TODO : The logic here might not be bulletproof. If the user triggers // TODO : a change in the TYPE of special indent (hanging, first line, // TODO : none), we will always save what's in the box as a property. // TODO : One could make it smarter with a stronger contract with // TODO : the platform interfaces. if (_getMenuItemValue(id_MENU_SPECIAL_INDENT) && (_wasChanged(id_MENU_SPECIAL_INDENT) || _wasChanged(id_SPIN_SPECIAL_INDENT))) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("text-indent"); tIndentState i = (tIndentState) _getMenuItemValue(id_MENU_SPECIAL_INDENT); if (i == indent_NONE) p->val = g_strdup(UT_convertInchesToDimensionString(m_dim, 0)); else if (i == indent_FIRSTLINE) p->val = g_strdup(_getSpinItemValue(id_SPIN_SPECIAL_INDENT)); else if (i == indent_HANGING) { // we have to flip the sign for "hanging" indents to a negative quantity for // storage in the document as a text-indent // get with no dimension UT_Dimension dim = UT_determineDimension(_getSpinItemValue(id_SPIN_SPECIAL_INDENT)); double val = UT_convertDimensionless(_getSpinItemValue(id_SPIN_SPECIAL_INDENT)); // Convert to inches val = UT_convertDimToInches(val, dim); // flip sign val = val * (double) -1; // store the reconstructed p->val = g_strdup(UT_convertInchesToDimensionString(dim, val)); } v.addItem(p); } if (_wasChanged(id_SPIN_BEFORE_SPACING)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("margin-top"); p->val = g_strdup(_getSpinItemValue(id_SPIN_BEFORE_SPACING)); v.addItem(p); } if (_wasChanged(id_SPIN_AFTER_SPACING)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("margin-bottom"); p->val = g_strdup(_getSpinItemValue(id_SPIN_AFTER_SPACING)); v.addItem(p); } // TODO : The logic here might not be bulletproof. If the user triggers // TODO : a change in the TYPE of special indent (single, double, etc.) // TODO : we will always save what's in the box as a property. // TODO : One could make it smarter with a stronger contract with // TODO : the platform interfaces. if(_getMenuItemValue(id_MENU_SPECIAL_SPACING) && (_wasChanged(id_MENU_SPECIAL_SPACING) || _wasChanged(id_SPIN_SPECIAL_SPACING))) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("line-height"); // normal spacings (single, 1.5, double) are just simple numbers. // "at least" needs a "+" at the end of the number (no units). // "exactly" simply has units. // "multiple" has no units. gchar * pTmp = NULL; const gchar * pString = _getSpinItemValue(id_SPIN_SPECIAL_SPACING); UT_uint32 nSize = 0; switch(_getMenuItemValue(id_MENU_SPECIAL_SPACING)) { case spacing_SINGLE: p->val = g_strdup("1.0"); break; case spacing_ONEANDHALF: p->val = g_strdup("1.5"); break; case spacing_DOUBLE: p->val = g_strdup("2.0"); break; case spacing_ATLEAST: nSize = strlen(pString); pTmp = (gchar *) UT_calloc(nSize + 2, sizeof(gchar)); UT_return_val_if_fail (pTmp, false); strncpy(pTmp, pString, nSize); // stick a '+' at the end pTmp[nSize] = '+'; p->val = g_strdup(pTmp); FREEP(pTmp); break; case spacing_EXACTLY: // fallthrough case spacing_MULTIPLE: // both these cases either do or don't have units associated with them. // the platform dialog code takes care of that. p->val = g_strdup(pString); break; default: UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } v.addItem(p); } // NOTE : "orphans" and "widows" hold a number specifying the number // NOTE : of lines to consider an orphaned or widowed piece of text. // NOTE : If they're both 0 they're off. If either is greater than // NOTE : 0, then some form of control is in effect. If the property // NOTE : is not set, they're indeterminate. if (_wasChanged(id_CHECK_WIDOW_ORPHAN)) { // TODO : fix this! we stomp on both properties (setting them // TODO : to "2"s or "0"s) if the one check box was ever // TODO : changed { ALLOC_PROP_PAIR(p); p->prop = g_strdup("orphans"); if (_getCheckItemValue(id_CHECK_WIDOW_ORPHAN) == check_TRUE) p->val = g_strdup("2"); else p->val = g_strdup("0"); v.addItem(p); } { ALLOC_PROP_PAIR(p); p->prop = g_strdup("widows"); if (_getCheckItemValue(id_CHECK_WIDOW_ORPHAN) == check_TRUE) p->val = g_strdup("2"); else p->val = g_strdup("0"); v.addItem(p); } } if (_wasChanged(id_CHECK_KEEP_LINES)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("keep-together"); if (_getCheckItemValue(id_CHECK_KEEP_LINES) == check_TRUE) p->val = g_strdup("yes"); else p->val = g_strdup("no"); v.addItem(p); } if (_wasChanged(id_CHECK_KEEP_NEXT)) { ALLOC_PROP_PAIR(p); p->prop = g_strdup("keep-with-next"); if (_getCheckItemValue(id_CHECK_KEEP_NEXT) == check_TRUE) p->val = g_strdup("yes"); else p->val = g_strdup("no"); v.addItem(p); } // TODO : add these to PP_Property (pp_Property.cpp) !!! /* m_pageBreakBefore; m_suppressLineNumbers; m_noHyphenate; */ // export everything in the array UT_uint32 count = v.getItemCount()*2 + 1; const gchar ** newprops = (const gchar **) UT_calloc(count, sizeof(gchar *)); if (!newprops) return false; const gchar ** newitem = newprops; UT_uint32 i = v.getItemCount(); while (i > 0) { p = (propPair *) v.getNthItem(i-1); i--; newitem[0] = p->prop; newitem[1] = p->val; newitem += 2; } // DO purge the vector's CONTENTS, which are just propPair structs UT_VECTOR_FREEALL(propPair *, v); // DO NOT purge the propPair's CONTENTS, because they will be pointed to // by the pointers we just copied into memory typed (gchar **) pProps = newprops; return true; }
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++; }
/*! * This method Does the stuff requested on the "action" button, "Apply" in the * Modeless dialog and "OK" in the Modal dialog. * Read comments with for all the stuff that can happen. */ void AP_Dialog_Lists::Apply(void) { gchar szStart[20]; if(!isModal() && (!isPageLists() || m_bFoldingLevelChanged)) { // // OK fold up the text according the level specified. // m_bFoldingLevelChanged = false; fl_AutoNum * pAuto = getBlock()->getAutoNum(); const gchar * props[5] = {"text-folded",NULL,"text-folded-id",NULL,NULL}; UT_UTF8String sStr = UT_UTF8String_sprintf("%d",getCurrentFold()); props[1] = sStr.utf8_str(); UT_uint32 ID = 0; if(!pAuto) { ID = getView()->getDocument()->getUID(UT_UniqueId::List); } else { ID = pAuto->getID(); } UT_UTF8String sID = UT_UTF8String_sprintf("%d",ID); props[3] = sID.utf8_str(); PT_DocPosition posLow = 0; PT_DocPosition posHigh = 0; if(getView()->isSelectionEmpty() && pAuto) { PL_StruxDocHandle sdhLow = pAuto->getFirstItem(); PL_StruxDocHandle sdhHigh = pAuto->getLastItemInHeiracy(); posLow = getView()->getDocument()->getStruxPosition(sdhLow)+1; posHigh = getView()->getDocument()->getStruxPosition(sdhHigh)+1; } else { posLow = getView()->getPoint(); posHigh = getView()->getSelectionAnchor(); if(posLow > posHigh) { PT_DocPosition posTemp = posLow; posLow = posHigh; posHigh = posTemp; } } getView()->setCollapsedRange(posLow,posHigh,props); return; } /*! * * OK this is failsafe code incase the user has changed the font but wants a * bullet list anyway. We don't let then! */ if(m_NewListType == BULLETED_LIST || m_NewListType == IMPLIES_LIST) { m_pszFont = "Symbol"; } else if(m_NewListType > DASHED_LIST && m_NewListType < OTHER_NUMBERED_LISTS) { m_pszFont = _getDingbatsFontName(); } /*! * Just to make things even more confusing this method is also used in a Modal * mannor by the styles dialog. This method is called when the users clicks "OK" * on the modal dialog. When that happens we fill an output vector with all the * properties currently defined. */ if(isModal()) { // // Fill out output vector with gchar * strings to be accessed via the calling // function. // if(m_OutProps.getItemCount() > 0) m_OutProps.clear(); sprintf(szStart,"%d",m_iStartValue); m_OutProps.addItem((void *) "start-value"); m_Output[0] = (gchar *) szStart; m_OutProps.addItem((void *) m_Output[0].c_str()); m_OutProps.addItem((void *) "list-style"); m_Output[1] = getBlock()->getListStyleString(m_NewListType); m_OutProps.addItem((void *) m_Output[1].c_str()); m_OutProps.addItem((void *) "list-delim"); m_OutProps.addItem((void *) m_pszDelim.c_str()); m_OutProps.addItem((void *) "list-decimal"); m_OutProps.addItem((void *) m_pszDecimal.c_str()); m_OutProps.addItem((void *) "field-font"); m_OutProps.addItem((void *) m_pszFont.c_str()); m_OutProps.addItem((void *) "margin-left"); m_Output[2] = UT_convertInchesToDimensionString(DIM_IN, m_fAlign, 0); m_OutProps.addItem((void *) m_Output[2].c_str()); m_OutProps.addItem((void *) "text-indent"); m_Output[3] = UT_convertInchesToDimensionString(DIM_IN, m_fIndent, 0); m_OutProps.addItem((void *) m_Output[3].c_str()); m_Answer = a_OK; return; } /*! * If the "Apply to current" radio buton is chosen we have two options. * 1. If "No list" is chosen we stop the current list at on this block. * 2. Otherwise we change the current list to the type requested here. * This piece of code changes the list style at the current point to the * Style requested by the user. */ UT_GenericVector<fl_BlockLayout*> vBlock; UT_uint32 i = 0; getView()->getBlocksInSelection(&vBlock); UT_uint32 count = vBlock.getItemCount(); getView()->cmdUnselectSelection(); if(m_bApplyToCurrent == true && m_isListAtPoint == true && m_NewListType != NOT_A_LIST) { getView()->getDocument()->beginUserAtomicGlob(); getView()->changeListStyle(getAutoNum(),m_NewListType,m_iStartValue, m_pszDelim.c_str(), m_pszDecimal.c_str(), m_pszFont.c_str(),m_fAlign,m_fIndent); if(getAutoNum() != NULL) { getAutoNum()->update(0); } getView()->getDocument()->endUserAtomicGlob(); clearDirty(); getView()->updateLayout(); getView()->setPoint(getView()->getPoint()); getView()->ensureInsertionPointOnScreen(); return; } /*! * This code stops the list at the current point. */ if ( m_isListAtPoint == true && m_NewListType == NOT_A_LIST) { getView()->getDocument()->beginUserAtomicGlob(); for(i=0;i < count; i++) { fl_BlockLayout * pBlock = (fl_BlockLayout *) vBlock.getNthItem(i); if(pBlock->isListItem() == true) { getView()->getDocument()->StopList(pBlock->getStruxDocHandle()); } } getView()->getDocument()->endUserAtomicGlob(); clearDirty(); getView()->updateLayout(); getView()->setPoint(getView()->getPoint()); getView()->ensureInsertionPointOnScreen(); return; } /*! * Start new list. 4 Possibilities. * 1. If there is a list at the current point and the user choose no list, stop * the list the current point. * * 2. start a new list with the properties given if there is not a * list at the current point. * * 3. Start a sublist at the current point if a list already exists there and * contains two or more items. * * 4. Change the list to the requested value if a list already eists but only * has one item in it. */ if(m_bStartNewList == true) { getView()->getDocument()->beginUserAtomicGlob(); for(i=0;i < count; i++) { fl_BlockLayout * pBlock2 = (fl_BlockLayout *) vBlock.getNthItem(i); if(pBlock2->isListItem() == true && m_NewListType == NOT_A_LIST) { // // This stops the current list. // if(pBlock2->isListItem() == true) { getView()->getDocument()->StopList(pBlock2->getStruxDocHandle()); } } else if ( pBlock2->isListItem() == false && m_NewListType != NOT_A_LIST ) { // // This starts the new list // pBlock2->getDocument()->disableListUpdates(); if(i == 0) { pBlock2->StartList(m_NewListType,m_iStartValue, m_pszDelim.c_str(), m_pszDecimal.c_str(), m_pszFont.c_str(), m_fAlign, m_fIndent, 0, 1); pBlock2->getDocument()->enableListUpdates(); pBlock2->getDocument()->updateDirtyLists(); } else { fl_BlockLayout * pBlock = (fl_BlockLayout *) vBlock.getNthItem(i); fl_BlockLayout * rBlock = (fl_BlockLayout *) pBlock->getPrev(); if(rBlock != NULL) { pBlock->resumeList(rBlock); pBlock->getDocument()->enableListUpdates(); } } } else if( pBlock2->getAutoNum() && (pBlock2->getAutoNum()->getNumLabels() > 1) && m_NewListType != NOT_A_LIST ) { // // This starts a sublist. // UT_uint32 curlevel = pBlock2->getLevel(); UT_uint32 currID = pBlock2->getAutoNum()->getID(); curlevel++; pBlock2->getDocument()->disableListUpdates(); // // Need to update m_fAlign and m_fIndent to reflect the higher level of indentation. // if(i == 0) { m_fAlign = m_fAlign + (float) LIST_DEFAULT_INDENT; pBlock2->StartList(m_NewListType,m_iStartValue, m_pszDelim.c_str(), m_pszDecimal.c_str(), m_pszFont.c_str(), m_fAlign, m_fIndent, currID,curlevel); pBlock2->getDocument()->enableListUpdates(); pBlock2->getDocument()->updateDirtyLists(); } else { fl_BlockLayout * pBlock = (fl_BlockLayout *) vBlock.getNthItem(i); fl_BlockLayout * rBlock = (fl_BlockLayout *) pBlock->getPrev(); if(rBlock != NULL) { pBlock->resumeList(rBlock); pBlock->getDocument()->enableListUpdates(); pBlock->getDocument()->updateDirtyLists(); } } } else if( pBlock2->getAutoNum() && (pBlock2->getAutoNum()->getNumLabels() <= 1) && m_NewListType != NOT_A_LIST ) { // // The list at the current point only has one item which is the current paragraph. // We can't share an sdh amongst two autonum's so we can't start a sublist. // We'll change the list style instead. // getView()->changeListStyle(pBlock2->getAutoNum(), m_NewListType, m_iStartValue, m_pszDelim.c_str(), m_pszDecimal.c_str(), m_pszFont.c_str(), m_fAlign, m_fIndent); if(pBlock2->getAutoNum() != NULL) { pBlock2->getAutoNum()->update(0); } } } clearDirty(); getView()->updateLayout(); getView()->setPoint(getView()->getPoint()); getView()->updateScreen(true); getView()->notifyListeners(AV_CHG_MOTION | AV_CHG_HDRFTR); getView()->getDocument()->endUserAtomicGlob(); getView()->ensureInsertionPointOnScreen(); return; } /*! * OK Attach the block at this point to the previous list of the same margin. */ if(m_bResumeList == true && m_isListAtPoint != true ) { getView()->getDocument()->beginUserAtomicGlob(); for(i=0;i < count; i++) { fl_BlockLayout * pBlock = (fl_BlockLayout *) vBlock.getNthItem(i); fl_BlockLayout * rBlock = pBlock->getPreviousListOfSameMargin(); if(rBlock != NULL) { pBlock->resumeList(rBlock); pBlock->getDocument()->enableListUpdates(); pBlock->getDocument()->updateDirtyLists(); } } getView()->getDocument()->endUserAtomicGlob(); } getView()->updateLayout(); getView()->setPoint(getView()->getPoint()); getView()->updateScreen(true); getView()->notifyListeners(AV_CHG_MOTION | AV_CHG_HDRFTR); getView()->ensureInsertionPointOnScreen(); clearDirty(); }