ut_misc.h File Reference

#include <string>
#include "ut_types.h"
#include "ut_vector.h"

Go to the source code of this file.

Classes

class  UT_RGBColor
class  UT_HashColor
class  UT_Rect
struct  UT_Point
class  UT_UniqueId
class  UT_VersionInfo

Defines

#define UT_RGBCOLOR_PROXIMITY   45
#define UT_MAX(A, B)   (((A) > (B)) ? (A) : (B))
#define UT_MIN(A, B)   (((A) < (B)) ? (A) : (B))
#define UT_ABS(A)   ( ((A) < 0) ? (-(A)) : (A) )
#define UT_UID_INVALID   0xffffffff

Typedefs

typedef unsigned char UT_EthernetAddress [6]
typedef void AbiNativeWidget

Functions

void UT_setColor (UT_RGBColor &col, unsigned char r, unsigned char g, unsigned char b, bool bTransparent=false)
ABI_EXPORT void UT_parseColor (const char *, UT_RGBColor &)
ABI_EXPORT std::string UT_colorToHex (const char *, bool bPrefix=false)
const char * UT_pathSuffix (const char *path)
bool UT_isWordDelimiter (UT_UCSChar currentChar, UT_UCSChar followChar, UT_UCSChar prevChar)
ABI_EXPORT const gchar * UT_getAttribute (const gchar *name, const gchar **atts)
ABI_EXPORT gchar ** UT_cloneAndDecodeAttributes (const gchar **attrs)
UT_sint32 signedHiWord (UT_uint32 dw)
UT_sint32 signedLoWord (UT_uint32 dw)
UT_GenericVector< UT_String * > * simpleSplit (const UT_String &str, char separator= ' ', size_t max=0)
void warpString (UT_String &str, size_t col_max=75)
 It warps the string str in various lines, taking care that no line goes beyond the column col.
UT_uint32 UT_HeadingDepth (const char *szHeadName)
ABI_EXPORT bool UT_parseBool (const char *param, bool dfl)
 UT_parseBool.
void UT_gettimeofday (struct timeval *tv)
bool UT_getEthernetAddress (UT_EthernetAddress &a)
const gchar ** UT_setPropsToNothing (const gchar **props)
const gchar ** UT_setPropsToValue (const gchar **props, const gchar *value)
const gchar ** UT_splitPropsToArray (gchar *props)
UT_uint64 UT_hash64 (const char *p, UT_uint32 bytelen=0)
UT_uint32 UT_hash32 (const char *p, UT_uint32 bytelen=0)


Define Documentation

#define UT_ABS (  )     ( ((A) < 0) ? (-(A)) : (A) )

#define UT_MAX ( A,
 )     (((A) > (B)) ? (A) : (B))

Referenced by GR_Caret::_blink(), fp_FieldRun::_defaultDraw(), FV_View::_deleteSelection(), fp_TextRun::_draw(), fp_ImageRun::_draw(), fp_EndOfParagraphRun::_draw(), fp_BookmarkRun::_draw(), fp_ForcedLineBreakRun::_draw(), fp_TabRun::_draw(), fp_MathRun::_draw(), fp_EmbedRun::_draw(), fp_DirectionMarkerRun::_draw(), fp_AnnotationRun::_draw(), fp_TabRun::_drawArrow(), AP_TopRuler::_drawBar(), AP_TopRuler::_drawCellProperties(), fp_TextRun::_drawInvisibleSpaces(), FV_View::_drawSelection(), AP_TopRuler::_drawTabProperties(), AP_TopRuler::_drawTicks(), FV_View::_findNext(), AP_TopRuler::_getFirstPixelInColumn(), FV_View::_getMouseContext(), AP_TopRuler::_getTabToggleRect(), AP_TopRuler::_getUnitsFromRulerLeft(), FV_View::_MergeCells(), fp_Page::_reformatColumns(), fp_TableContainer::_size_allocate_pass1(), fp_TableContainer::_size_allocate_pass2(), fp_TableContainer::_size_request_pass1(), fp_TableContainer::_size_request_pass2(), AP_TopRuler::_xorGuide(), PD_Document::acceptRejectRevision(), AD_Document::areDocumentHistoriesEqual(), fp_Page::breakPage(), Defun1(), FV_View::doesSelectionContainRevision(), XAP_Preview_FontPreview::draw(), fp_CellContainer::draw(), fp_FrameContainer::draw(), fp_FootnoteContainer::draw(), fp_VerticalContainer::draw(), AP_Preview_Annotation::draw(), fp_CellContainer::drawBroken(), fp_Run::drawDecors(), fp_Page::getAvailableHeightForColumn(), fp_Page::getFilledHeight(), AD_Document::getHighestRevisionId(), FV_View::getInsertionPointContext(), fp_Line::getMarginAfter(), fp_Line::getMarginBefore(), fl_BlockLayout::getMaxNonBreakableRun(), AP_TopRuler::getTabToggleAreaWidth(), AP_TopRuler::mouseMotion(), AP_TopRuler::mouseRelease(), AP_TopRuler::notify(), GR_Graphics::polygon(), fp_Line::recalcHeight(), fp_TableContainer::resize(), AP_TopRuler::scrollRuler(), AP_TopRuler::setTableLineDrag(), AP_LeftRuler::setTableLineDrag(), and UT_Rect::unionRect().

#define UT_MIN ( A,
 )     (((A) < (B)) ? (A) : (B))

Referenced by FV_View::_adjustDeletePosition(), GR_Caret::_blink(), s_RTF_ListenerGetProps::_check_revs_for_color(), s_RTF_ListenerGetProps::_check_revs_for_font(), XAP_CocoaFrameImpl::_createTopLevelWindow(), fp_FieldRun::_defaultDraw(), pt_PieceTable::_deleteComplexSpan(), pt_PieceTable::_deleteComplexSpan_norec(), FV_View::_deleteSelection(), fl_BlockLayout::_doInsertTextSpan(), pt_PieceTable::_doTheDo(), fp_TextRun::_draw(), fp_ImageRun::_draw(), fp_EndOfParagraphRun::_draw(), fp_BookmarkRun::_draw(), fp_ForcedLineBreakRun::_draw(), fp_TabRun::_draw(), fp_MathRun::_draw(), fp_EmbedRun::_draw(), fp_DirectionMarkerRun::_draw(), fp_AnnotationRun::_draw(), fp_TabRun::_drawArrow(), fp_Page::_drawCropMarks(), FV_View::_drawSelection(), FV_View::_findPrev(), FV_View::_getMouseContext(), s_AbiWord_1_Listener::_handleDataItems(), IE_Imp_MsWord_97::_insertTOC(), IE_Imp_RTF::_isBidiDocument(), pf_Frag_Text::_isContentEqual(), ODi_Abi_Data::_loadStream(), FV_View::_MergeCells(), AP_Win32App::_pasteFormatFromClipboard(), XAP_Win32Dialog_FileOpenSaveAs::_previewPicture(), pt_PieceTable::_realChangeSpanFmt(), IE_Imp_Text::_recognizeEncoding(), GR_Win32USPGraphics::_scriptBreak(), fp_FieldRun::_setValue(), PD_Document::acceptRejectRevision(), PD_Document::areDocumentContentsEqual(), PD_Document::areDocumentFormatsEqual(), AD_Document::areDocumentHistoriesEqual(), XAP_Dialog_Modeless::BuildWindowName(), fp_FieldListLabelRun::calculateValue(), FV_View::calculateZoomPercentForWholePage(), pt_PieceTable::changeSpanFmt(), IE_MailMerge::constructMerger(), Defun1(), pt_PieceTable::deleteSpan(), FV_View::doesSelectionContainRevision(), fp_FrameContainer::draw(), AP_Lists_preview::draw(), fp_Run::drawDecors(), PD_Document::explodeRevisions(), PD_Document::findFirstDifferenceInContent(), fp_TextRun::findPointCoords(), FV_View::getInsertionPointContext(), AP_Dialog_Lists::getListLabel(), FV_View::getTextBetweenPos(), FV_View::getVisibleDocumentPagesAndRectangles(), loadStream(), fp_VerticalContainer::mapXYToPosition(), GR_UnixPangoGraphics::measureString(), AP_TopRuler::mouseMotion(), AP_CocoaApp::pasteFromClipboard(), GR_Graphics::polygon(), AP_Dialog_Lists::PopulateDialogData(), XAP_UnixDialog_FileOpenSaveAs::previewPicture(), IE_ImpGraphicSniffer::recognizeContents(), IE_Imp_OpenWriter_Sniffer::recognizeContents(), IE_ImpSniffer::recognizeContents(), FV_View::toggleCase(), UT_Rect::unionRect(), fp_TextRun::updateOnDelete(), and fp_Run::updateOnDelete().

#define UT_RGBCOLOR_PROXIMITY   45

Referenced by UT_RGBColor::operator%=().

#define UT_UID_INVALID   0xffffffff


Typedef Documentation

typedef void AbiNativeWidget

typedef unsigned char UT_EthernetAddress[6]


Function Documentation

UT_sint32 signedHiWord ( UT_uint32  dw  ) 

UT_sint32 signedLoWord ( UT_uint32  dw  ) 

UT_GenericVector<UT_String*>* simpleSplit ( const UT_String str,
char  separator,
size_t  max 
)

simplesplit splits the referring string along the character 'separator', removing the separator character, and placing the resulting strings in a UT_Vector. If 'max' is specified, this is done max times - the max + 1 string in the vector will contain the remainder of the original string (str).

References UT_GenericVector< T >::addItem(), and UT_String::size().

Referenced by EV_Menu::addMenuItem().

ABI_EXPORT gchar** UT_cloneAndDecodeAttributes ( const gchar **  attrs  ) 

ABI_EXPORT std::string UT_colorToHex ( const char *  szColor,
bool  bPrefix 
)

This function takes in a color string of any form (e.g. "red", "CMYK()", "#000000", "000000", etc.) and returns an RGB hexadecimal string.

Parameters:
szColor The incoming string to parse
bPrefix The return string will be prefixed with a '#' if bPrefix is true. Defaults to false.
Returns:
An RGB hexadecimal string or an empty string if szColor is empty
WARNING: Will return 000000 or #000000 if an invalid color is passed in

References UT_RGBColor::m_blu, UT_RGBColor::m_grn, UT_RGBColor::m_red, UT_HashColor::setColor(), UT_parseColor(), and UT_return_val_if_fail.

Referenced by s_HTML_Listener::_openSpan(), s_HTML_Listener::_outputStyles(), ODe_Style_Style::GraphicProps::fetchAttributesFromAbiProps(), ODe_Style_Style::CellProps::fetchAttributesFromAbiProps(), ODe_Style_Style::TableProps::fetchAttributesFromAbiProps(), ODe_Style_Style::TextProps::fetchAttributesFromAbiProps(), ODe_Style_Style::ParagraphProps::fetchAttributesFromAbiProps(), ODe_Style_PageLayout::fetchAttributesFromAbiSection(), and s_StyleTree::s_StyleTree().

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

References gchar, and UT_return_val_if_fail.

Referenced by _fontSizeChange(), ODi_Frame_ListenerState::_getFrameProperties(), _getTranslationCode(), IE_Imp_XML::_getXMLPropValue(), OpenWriter_ContentStream_Listener::_insertImage(), pt_PieceTable::_makeStrux(), 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_textProperties(), ODi_Style_PageLayout::_parseBackgroundImage(), ODi_Table_ListenerState::_parseCellStart(), ODi_Table_ListenerState::_parseColumnStart(), ODi_Style_PageLayout::_parseHeaderFooterProperties(), ODi_Style_PageLayout::_parsePageLayoutProperties(), 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(), FL_DocLayout::considerSmartQuoteCandidateAt(), Defun(), Defun_EV_GetMenuItemState_Fn(), Defun_EV_GetToolbarItemState_Fn(), AP_Dialog_Lists::fillUncustomizedValues(), 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_doLangDlg(), s_doPageSetupDlg(), s_getPageMargins(), PD_Document::setAttrProp(), FV_View::setCharFormat(), AP_Dialog_Paragraph::setDialogData(), AP_Dialog_Columns::setViewAndDoc(), UT_XML_Decoder::startElement(), OXMLi_ListenerState_Theme::startElement(), OXMLi_ListenerState_Styles::startElement(), OXMLi_ListenerState_DocSettings::startElement(), OXMLi_ListenerState_Common::startElement(), ODi_TextContent_ListenerState::startElement(), ODi_TableOfContent_ListenerState::startElement(), ODi_Table_ListenerState::startElement(), ODi_Style_Style::startElement(), ODi_Style_PageLayout::startElement(), ODi_Style_MasterPage::startElement(), ODi_Style_List::startElement(), ODi_NotesConfiguration::startElement(), ODi_Numbered_ListLevelStyle::startElement(), ODi_Bullet_ListLevelStyle::startElement(), ODi_ListLevelStyle::startElement(), ODi_FontFaceDecls::startElement(), IE_MailMerge_XML_Listener::startElement(), OpenWriter_ContentStream_Listener::startElement(), OpenWriter_StylesStream_Listener::startElement(), OpenWriter_MetaStream_Listener::startElement(), IE_Imp_AbiWord_1::startElement(), and BarbarismChecker::startElement().

bool UT_getEthernetAddress ( UT_EthernetAddress A  ) 

retrieve the 6-byte address of the network card; returns true on success

retrieve the 6-byte address of the network card; returns true on success This implementation is from libuuid; it has not been debugged or even compiled

References _ASTAT::adapt, name, UT_ASSERT, UT_DEBUGMSG, UT_NOT_IMPLEMENTED, UT_return_val_if_fail, and UT_UNUSED.

Referenced by UT_UUID::_makeUUID().

void UT_gettimeofday ( struct timeval *  tv  ) 

UT_gettimeofday() fills in the timeval structure with current time; the platform implementation needs to be as accurate as possible since this function is used in the UT_UUID class.

UT_gettimeofday() fills in the timeval structure with current time; the platform implementation needs to be as accurate as possible since this function is used in the UT_UUID class.

this implementation is from: http://bugzilla.vovida.org/bugzilla/show_bug.cgi?id=751

Referenced by UT_UUID::_getClock().

UT_uint32 UT_hash32 ( const char *  p,
UT_uint32  bytelen = 0 
)

UT_uint64 UT_hash64 ( const char *  p,
UT_uint32  bytelen = 0 
)

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.

References UT_String::c_str().

Referenced by FV_View::setStyleAtPos().

bool UT_isWordDelimiter ( UT_UCSChar  currentChar,
UT_UCSChar  followChar,
UT_UCSChar  prevChar 
)

ABI_EXPORT 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().

ABI_EXPORT void UT_parseColor ( const char *  ,
UT_RGBColor  
)

const char* UT_pathSuffix ( const char *  path  ) 

void UT_setColor ( UT_RGBColor col,
unsigned char  r,
unsigned char  g,
unsigned char  b,
bool  bTransparent = false 
)

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 pt_PieceTable::appendLastStruxFmt(), and pt_PieceTable::changeLastStruxFmtNoUndo().

void warpString ( UT_String str,
size_t  col_max 
)

It warps the string str in various lines, taking care that no line goes beyond the column col.

Parameters:
str is the string to warp.
col_max is the column that no character in any line should pass (except if we can not cut this line anywhere).

References find_next_space(), and UT_String::size().


Generated on Sat Aug 30 00:06:40 2008 for AbiWord by  doxygen 1.5.5