bool fp_FieldTOCHeadingRun::calculateValue(void)
{
    UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1];
//
// First get owning TOC.
//
    UT_ASSERT(getLength() == 0);
    fl_TOCLayout * pTOCL = static_cast<fl_TOCLayout *>(getBlock()->myContainingLayout());
    UT_ASSERT(pTOCL->getContainerType() == FL_CONTAINER_TOC);
    UT_UCS4String str = pTOCL->getTOCHeading().ucs4_str();
    if(str.size() == 0)
    {
        sz_ucs_FieldValue[0] = 0;
        return _setValue(sz_ucs_FieldValue);
    }
    UT_sint32 i = 0;
    bool bStop = false;

    for(i=0; (i<FPFIELD_MAX_LENGTH) && !bStop; i++)
    {
        sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(str[i]);
        if(str[i] == 0)
        {
            bStop = true;
        }
    }
    return _setValue(sz_ucs_FieldValue);
}
bool ev_UnixKeyboard::charDataEvent(AV_View* pView, EV_EditBits state, const char * text, size_t len)
{
    EV_EditEventMapperResult result;
    EV_EditMethod * pEM;

    /*
    do some sanity checking, since:
    - delete_surrounding commits a 0 length string in some IMs
    - some IMs state a length of 1, while the text being "" (for example the
    Amharic IM for keystrokes that have no secondary character (eg. shift-R)
    */
    if (!text || *text == '\0' || !len)
        return true;

    UT_UCS4String ucs (text, len);

    UT_uint32 charData = static_cast<UT_uint32>(ucs[0]);

    xxx_UT_DEBUGMSG(("DOM: charData: %d | length: %d | string: '%s'\n", charData, len, text));
    if (charData == 32)
        charData = 'a'; // HACK!!! for space bar not working. investigate more....

    if(charData>0xff || charData == 0)
        result = m_pEEM->Keystroke(EV_EKP_PRESS|state|'a',&pEM);
    else
        result = m_pEEM->Keystroke(EV_EKP_PRESS|state|charData,&pEM);

    switch (result)
    {
    case EV_EEMR_BOGUS_START:
        // If it is a bogus key and we don't have a sequence in
        // progress, we should let the system handle it
        // (this lets things like ALT-F4 work).
        return false;

    case EV_EEMR_BOGUS_CONT:
        // If it is a bogus key but in the middle of a sequence,
        // we should silently eat it (this is to prevent things
        // like Control-X ALT-F4 from killing us -- if they want
        // to kill us, fine, but they shouldn't be in the middle
        // of a sequence).
        return true;

    case EV_EEMR_COMPLETE:
    {
        UT_ASSERT(pEM);

        invokeKeyboardMethod(pView,pEM,
                             ucs.ucs4_str(), static_cast<UT_uint32>(ucs.size()));
        return true;
    }
    case EV_EEMR_INCOMPLETE:
        return true;

    default:
        UT_ASSERT(0);
        return true;
    }

    return false;
}
Exemple #3
0
bool ev_EditMethod_invoke (const EV_EditMethod * pEM, const UT_UCS4String & data)
{
  EV_EditMethodCallData callData ( data.ucs4_str(), static_cast<UT_uint32>(data.size()) ) ;
  return ev_EditMethod_invoke ( pEM, &callData ) ;
}
UT_UTF8String::UT_UTF8String (const UT_UCS4String & rhs) :
	pimpl(new UT_UTF8Stringbuf)
{
	if (rhs.size ()) appendUCS4 (rhs.ucs4_str (), rhs.size ());
}
bool operator==(const UT_UCS4String& s1, const UT_UCS4String& s2)
{
        if (s1.size() != s2.size()) return false;
	return UT_UCS4_strcmp(s1.ucs4_str(), s2.ucs4_str()) == 0;
}