Defines | Functions

ut_misc.cpp File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <glib.h>
#include "ut_string_class.h"
#include "ut_types.h"
#include "ut_misc.h"
#include "ut_assert.h"
#include "ut_string.h"
#include "ut_std_string.h"
#include "ut_go_file.h"
#include "ut_debugmsg.h"
#include <limits.h>

Defines

#define AUTO_LIST_RESERVED   1000
#define R_RIGHT(pr)   (((pr)->left)+((pr)->width))
#define R_BOTTOM(pr)   (((pr)->top)+((pr)->height))
#define MYZERO   0LL

Functions

std::string UT_pathSuffix (std::string path)
bool UT_addOrReplacePathSuffix (std::string &sPath, const char *sSuffix)
bool UT_isWordDelimiter (UT_UCSChar currentChar, UT_UCSChar followChar, UT_UCSChar prevChar)
gchar ** UT_cloneAndDecodeAttributes (const gchar **attrs)
const gchar * UT_getAttribute (const gchar *name, const gchar **atts, const gchar *def)
 Like UT_getAttribute(name,atts) but return the def value if there is no attibute name in atts.
const gchar * UT_getAttribute (const gchar *name, const gchar **atts)
 Get the attribute "name" from atts or NULL if no such attribute is in atts.
bool isTrue (const char *s)
 s is not null and is not a string that is "0" or false or something sane that indicates "false".
UT_sint32 signedLoWord (UT_uint32 dw)
UT_sint32 signedHiWord (UT_uint32 dw)
std::vector< std::string > * simpleSplit (const std::string &str, char separator)
UT_uint32 UT_HeadingDepth (const char *szHeadingName)
void * UT_calloc (UT_uint32 nmemb, UT_uint32 size)
bool UT_parseBool (const char *param, bool dfl)
 UT_parseBool.
const gchar ** UT_setPropsToNothing (const gchar **props)
const gchar ** UT_setPropsToValue (const gchar **props, const gchar *value)
const gchar ** UT_splitPropsToArray (gchar *pProps)
UT_uint64 UT_hash64 (const char *p, UT_uint32 bytelen)
UT_uint32 UT_hash32 (const char *p, UT_uint32 bytelen)

Define Documentation

#define AUTO_LIST_RESERVED   1000
#define MYZERO   0LL

Referenced by UT_hash64().

#define R_BOTTOM (   pr  )     (((pr)->top)+((pr)->height))

Referenced by UT_Rect::intersectsRect().

#define R_RIGHT (   pr  )     (((pr)->left)+((pr)->width))

Referenced by UT_Rect::intersectsRect().


Function Documentation

bool isTrue ( const char *  s  ) 

s is not null and is not a string that is "0" or false or something sane that indicates "false".

Referenced by AbiCommand::parseTokens().

UT_sint32 signedHiWord ( UT_uint32  dw  ) 
UT_sint32 signedLoWord ( UT_uint32  dw  ) 
std::vector<std::string>* simpleSplit ( const std::string &  str,
char  separator 
)

simplesplit splits the referring string along the character 'separator', removing the separator character, and placing the resulting strings in a vector.

Referenced by EV_Menu::addMenuItem(), and TFTEST_MAIN().

bool UT_addOrReplacePathSuffix ( std::string &  sPath,
const char *  sSuffix 
)

Take a path name and search for the suffix. replace it the supplied suffix.

References s.

Referenced by XAP_UnixDialog_Print::setupPrint().

void* UT_calloc ( UT_uint32  nmemb,
UT_uint32  size 
)

Referenced by IE_Imp_RTF::_appendField(), AP_Preview_Paragraph::_appendLine(), UT_ByteBuf::_byteBuf(), FV_View::_computeFindPrefix(), AP_Win32Dialog_New::_doChoose(), FV_View::_findGetNextBlockBuffer(), FV_View::_findGetPrevBlockBuffer(), FV_View::_findNext(), FV_View::_findPrev(), XAP_Dialog_Print::_getPrintToFilePathname(), UT_GrowBuf::_growBuf(), XAP_UnixDialog_FileOpenSaveAs::_loadXPM(), IE_ImpGraphic_GdkPixbuf::_loadXPM(), AP_Dialog_Styles::_populateAbiPreview(), AP_CocoaDialog_Replace::_populateWindowData, pt_PieceTable::_realChangeSpanFmt(), pt_PieceTable::_realChangeStruxFmt(), _toggleSpanOrBlock(), AP_Dialog_Spell::addChangeAll(), XAP_Dictionary::addWord(), AP_Dialog_Styles::applyModifiedStyleToDoc(), AP_Dialog_FormatTable::askForGraphicPathName(), AP_Dialog_FormatFrame::askForGraphicPathName(), FV_View::changeListStyle(), AP_Dialog_Styles::createNewStyle(), Defun(), Defun1(), AP_Win32App::doesStringSetExist(), EV_Toolbar_ActionSet::EV_Toolbar_ActionSet(), EV_Toolbar_LabelSet::EV_Toolbar_LabelSet(), EV_Toolbar_Layout::EV_Toolbar_Layout(), XAP_Win32Dialog_PluginManager::event_Load(), XAP_UnixDialog_PluginManager::event_Load(), AP_UnixDialog_New::event_ToggleOpenExisting(), AP_CocoaDialog_New::event_ToggleOpenExisting, AP_Dialog_MailMerge::eventOpen(), FileTypeArray::FileTypeArray(), fv_PropCache::fillProps(), FV_View::getBlockFormat(), FV_View::getCharFormat(), AP_Dialog_MarkRevisions::getComment1(), XAP_Win32DialogBase::getControlText(), fv_PropCache::getCopyOfProps(), AP_Dialog_Paragraph::getDialogData(), GR_Win32Graphics::getDocInfo(), AP_Dialog_ListRevisions::getNthItemText(), GR_Win32Graphics::getPrinterGraphics(), AP_Dialog_MarkRevisions::getRadio1Label(), FV_View::getSectionFormat(), FV_View::getSelectionText(), FV_View::gotoTarget(), AP_Dialog_Spell::inChangeAll(), AP_Win32App::initialize(), AbiCommand::insertText(), XAP_Dictionary::isWord(), AP_Dialog_Styles::ModifyParagraph(), IE_Imp_WordPerfect::openEndnote(), IE_Imp_WordPerfect::openFootnote(), AbiCommand::parseTokens(), GR_Win32Graphics::polyLine(), fl_BlockLayout::prependList(), XAP_Win32Slurp::processCommand(), fl_BlockLayout::remItemFromList(), AbiCommand::replaceAll(), AbiCommand::replaceNext(), fl_BlockLayout::resumeList(), XAP_Win32Dialog_FileOpenSaveAs::runModal(), s_AskForGOComponentPathname(), s_AskForGraphicPathname(), s_AskForPathname(), s_AskForScriptName(), AP_CocoaPlugin_Document::selectMailMergeSource, fl_BlockLayout::StartList(), fl_BlockLayout::StopListInBlock(), XAP_Dictionary::suggestWord(), AP_Dialog_Styles::updateCurrentStyle(), UT_cloneAndDecodeAttributes(), UT_GetDefaultPrinterName(), UT_UCS4_cloneString(), UT_UCS4_cloneString_char(), UT_XML_cloneConvAmpersands(), UT_XML_cloneNoAmpersands(), UT_XML_transNoAmpersands(), UT_Xpm2Bmp(), XAP_Args::XAP_Args(), and XAP_Win32Dialog_Print::XAP_Win32Dialog_Print().

gchar** UT_cloneAndDecodeAttributes ( const gchar **  attrs  ) 
const gchar* UT_getAttribute ( const gchar *  name,
const gchar **  atts,
const gchar *  def 
)

Like UT_getAttribute(name,atts) but return the def value if there is no attibute name in atts.

References gchar, and UT_getAttribute().

Referenced by _fontSizeChange(), ODi_Frame_ListenerState::_getFrameProperties(), _getTranslationCode(), IE_Imp_XML::_getXMLPropValue(), OpenWriter_ContentStream_Listener::_insertImage(), ODi_TextContent_ListenerState::_insureInSection(), pt_PieceTable::_makeStrux(), ODi_Style_Style::_parse_style_background_image(), ODi_Style_Style::_parse_style_graphicProperties(), ODi_Style_Style::_parse_style_paragraphProperties(), ODi_Style_Style::_parse_style_sectionProperties(), ODi_Style_Style::_parse_style_style(), ODi_Style_Style::_parse_style_tableCellProperties(), ODi_Style_Style::_parse_style_tableColumnProperties(), ODi_Style_Style::_parse_style_tableProperties(), ODi_Style_Style::_parse_style_tableRowProperties(), ODi_Style_Style::_parse_style_tabStopProperties(), ODi_Style_Style::_parse_style_textProperties(), ODi_Style_PageLayout::_parseBackgroundImage(), ODi_Table_ListenerState::_parseCellStart(), ODi_Table_ListenerState::_parseColumnStart(), ODi_Style_PageLayout::_parseHeaderFooterProperties(), ODi_Style_PageLayout::_parsePageLayoutProperties(), ODi_Table_ListenerState::_parseRowStart(), ODi_Table_ListenerState::_parseTableStart(), AP_Dialog_Styles::_populateAbiPreview(), AP_Dialog_Styles::_populatePreviews(), AP_Dialog_Tab::_populateWindowData(), pt_PieceTable::_realChangeSpanFmt(), pt_PieceTable::_realChangeStruxFmt(), AP_Win32Dialog_Lists::_selectFont(), ODi_TextContent_ListenerState::_startParagraphElement(), _toggleSpanOrBlock(), ODi_Office_Styles::addDefaultStyle(), ODi_Abi_Data::addImageDataItem(), ODi_Office_Styles::addList(), ODi_Office_Styles::addMasterPage(), ODi_Office_Styles::addNotesConfiguration(), ODi_Abi_Data::addObjectDataItem(), ODi_Office_Styles::addPageLayout(), ODi_Style_Style_Family::addStyle(), ODi_Office_Styles::addStyle(), pt_PieceTable::appendObject(), pt_PieceTable::appendStrux(), pt_PieceTable::appendStyle(), FV_View::cmdCharDelete(), FV_View::cmdInsertTable(), FL_DocLayout::considerSmartQuoteCandidateAt(), Defun(), Defun1(), Defun_EV_GetMenuItemState_Fn(), Defun_EV_GetToolbarItemState_Fn(), AP_Dialog_Lists::fillUncustomizedValues(), PP_RevisionAttr::getHighestRevisionNumberWithAttribute(), pt_PieceTable::insertObjectBeforeFrag(), pt_PieceTable::insertStruxBeforeFrag(), FV_View::insertSymbol(), pt_VarSet::mergeAP(), AP_Dialog_Styles::ModifyLang(), AP_Dialog_Styles::ModifyParagraph(), ap_sbf_Language::notify(), OO_Style::parse(), OO_PageStyle::parse(), s_doFontDlg(), s_doFormatImageDlg(), s_doLangDlg(), s_getPageMargins(), PD_Document::setAttrProp(), AP_Dialog_Paragraph::setDialogData(), AP_Dialog_Columns::setViewAndDoc(), UT_XML_Decoder::startElement(), ODi_TextContent_ListenerState::startElement(), ODi_TableOfContent_ListenerState::startElement(), ODi_Style_Style::startElement(), ODi_Style_PageLayout::startElement(), ODi_Style_MasterPage::startElement(), ODi_Style_List::startElement(), ODi_NotesConfiguration::startElement(), ODi_ManifestStream_ListenerState::startElement(), ODi_Numbered_ListLevelStyle::startElement(), ODi_Bullet_ListLevelStyle::startElement(), ODi_ListLevelStyle::startElement(), ODi_FontFaceDecls::startElement(), ODi_ContentStreamAnnotationMatcher_ListenerState::startElement(), IE_MailMerge_XML_Listener::startElement(), OpenWriter_ContentStream_Listener::startElement(), OpenWriter_StylesStream_Listener::startElement(), OpenWriter_MetaStream_Listener::startElement(), OpfListener::startElement(), ContainerListener::startElement(), IE_Imp_AbiWord_1::startElement(), BarbarismChecker::startElement(), UT_getAttribute(), and UT_getLatestAttribute().

const gchar* UT_getAttribute ( const gchar *  name,
const gchar **  atts 
)

Get the attribute "name" from atts or NULL if no such attribute is in atts.

References gchar, and UT_return_val_if_fail.

UT_uint32 UT_hash32 ( const char *  p,
UT_uint32  bytelen 
)
UT_uint64 UT_hash64 ( const char *  p,
UT_uint32  bytelen 
)

References MYZERO, and UT_return_val_if_fail.

UT_uint32 UT_HeadingDepth ( const char *  szHeadingName  ) 

Strips off the first numeric part of string and returns it as a uint32. ie. "Numbered Heading 5" would return 5.

Referenced by FV_View::setStyleAtPos(), and TFTEST_MAIN().

bool UT_isWordDelimiter ( UT_UCSChar  currentChar,
UT_UCSChar  followChar,
UT_UCSChar  prevChar 
)
bool UT_parseBool ( const char *  param,
bool  dfl 
)

UT_parseBool.

Returns true if param is [true, 1, yes, allow, enable, on] Returns false if param is [false, 0, no, disallow, disable, off] Returns dfl otherwise, including if param is null

References UT_return_val_if_fail.

Referenced by IE_Exp_OpenDocument::_openFile(), IE_Exp_AbiWord_1::_setupFile(), IE_Exp_OpenDocument::_writeDocument(), IE_Exp_HTML::_writeDocument(), IE_Exp_S5::_writeHeader(), and AP_Convert::print().

std::string UT_pathSuffix ( std::string  path  ) 
const gchar** UT_setPropsToNothing ( const gchar **  props  ) 

References gchar.

Referenced by pt_PieceTable::changeSpanFmt().

const gchar** UT_setPropsToValue ( const gchar **  props,
const gchar *  value 
)

References gchar.

Referenced by pt_PieceTable::changeStruxFmt().

const gchar** UT_splitPropsToArray ( gchar *  pProps  ) 

splits the xml property string (font-size:24pt;font-face:Arial') into names and values and stores them in an array

the caller has to delete[] the array; the process is destructive to props

References gchar, and UT_return_val_if_fail.

Referenced by ODi_TextContent_ListenerState::_insureInSection(), pt_PieceTable::appendLastStruxFmt(), and pt_PieceTable::changeLastStruxFmtNoUndo().