void AP_Dialog_FormatTable::setCurCellProps(void)
{
    XAP_Frame *frame = XAP_App::getApp()->getLastFocussedFrame();
    if (frame) {
        FV_View * pView = static_cast<FV_View *>(frame->getCurrentView());

        if (m_bSettingsChanged ||
                m_iOldPos == pView->getPoint()) // comparing the actual cell pos would be even better; but who cares :)
            return;

        m_iOldPos = pView->getPoint();

        /*
         * update the border colors
         */

        gchar * color = NULL;

        if (pView->getCellProperty("left-color", color))
            m_vecProps.addOrReplaceProp("left-color", color);
        else
            m_vecProps.removeProp("left-color");

        if (pView->getCellProperty("right-color", color))
            m_vecProps.addOrReplaceProp("right-color", color);
        else
            m_vecProps.removeProp("right-color");

        if (pView->getCellProperty("top-color", color))
            m_vecProps.addOrReplaceProp("top-color", color);
        else
            m_vecProps.removeProp("top-color");

        if (pView->getCellProperty("bot-color", color))
            m_vecProps.addOrReplaceProp("bot-color", color);
        else
            m_vecProps.removeProp("bot-color");

        /*
         * update the background color
         */

        UT_RGBColor clr;
        gchar * bgColor = NULL;
        if (pView->getCellProperty("background-color", bgColor))
        {
            m_vecProps.addOrReplaceProp("background-color", bgColor);
            clr.setColor(bgColor);
            setBackgroundColorInGUI(clr);
        }
        else
        {
            m_vecProps.removeProp("background-color");
            setBackgroundColorInGUI(UT_RGBColor(255,255,255)); // No color == white for now - MARCM
        }


        if(pView->isImageAtStrux(m_iOldPos,PTX_SectionCell))
        {
            if(pView->isInTable())
            {
                fl_BlockLayout * pBL = pView->getCurrentBlock();
                fl_CellLayout * pCell = static_cast<fl_CellLayout *>(pBL->myContainingLayout());
                if(pCell->getContainerType() != FL_CONTAINER_CELL)
                {
                    UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
                    DELETEP(m_pGraphic);
                    DELETEP(m_pImage);
                    m_sImagePath.clear();
                }
                else
                {
                    FG_Graphic * pFG = FG_GraphicRaster::createFromStrux(pCell);
                    if(pFG)
                    {
                        DELETEP(m_pGraphic);
                        DELETEP(m_pImage);
                        m_sImagePath.clear();
                        m_pGraphic = pFG;
                        m_sImagePath = pFG->getDataId();
                        GR_Graphics * pG = m_pFormatTablePreview->getGraphics();
                        const UT_ByteBuf * pBB = pFG->getBuffer();
                        if(m_pGraphic->getType() == FGT_Raster)
                        {
                            m_pImage = static_cast<GR_Image *>(
                                           pG->createNewImage( m_sImagePath.c_str(),
                                                               pBB, pFG->getMimeType(),
                                                               pFG->getWidth(),
                                                               pFG->getHeight(),
                                                               GR_Image::GRT_Raster));
                        }
                        else
                        {
                            m_pImage = static_cast<GR_Image *>(
                                           pG->createNewImage( m_sImagePath.c_str(),
                                                               pBB, pFG->getMimeType(),
                                                               m_pFormatTablePreview->getWindowWidth()-2,
                                                               m_pFormatTablePreview->getWindowHeight()-2,
                                                               GR_Image::GRT_Vector));
                        }
                    }
                }
            }
            else
            {
                DELETEP(m_pGraphic);
                DELETEP(m_pImage);
                m_sImagePath.clear();
            }
        }
        else
        {
            DELETEP(m_pGraphic);
            DELETEP(m_pImage);
            m_sImagePath.clear();
        }

        UT_String bstmp = UT_String_sprintf("%d", FS_FILL);
        m_vecProps.addOrReplaceProp("bg-style", bstmp.c_str());

        // draw the preview with the changed properties
        if(m_pFormatTablePreview)
            m_pFormatTablePreview->queueDraw();
    }
}
/*!
 * Import graphic for cell background.
 */
void AP_Dialog_FormatTable::askForGraphicPathName(void)
{
    XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame();

    UT_return_if_fail(pFrame);
    XAP_DialogFactory * pDialogFactory
        = static_cast<XAP_DialogFactory *>(pFrame->getDialogFactory());

    UT_return_if_fail(pDialogFactory);
    XAP_Dialog_FileOpenSaveAs * pDialog
        = static_cast<XAP_Dialog_FileOpenSaveAs *>(pDialogFactory->requestDialog(XAP_DIALOG_ID_INSERT_PICTURE));
    UT_return_if_fail (pDialog);

    pDialog->setCurrentPathname(NULL);
    pDialog->setSuggestFilename(false);

    // to fill the file types popup list, we need to convert AP-level
    // ImpGraphic descriptions, suffixes, and types into strings.

    UT_uint32 filterCount = IE_ImpGraphic::getImporterCount();

    const char ** szDescList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *)));
    const char ** szSuffixList = static_cast<const char **>(UT_calloc(filterCount + 1, sizeof(char *)));
    IEGraphicFileType * nTypeList = (IEGraphicFileType *)
                                    UT_calloc(filterCount + 1,	sizeof(IEGraphicFileType));
    UT_uint32 k = 0;

    while (IE_ImpGraphic::enumerateDlgLabels(k, &szDescList[k], &szSuffixList[k], &nTypeList[k]))
        k++;

    pDialog->setFileTypeList(szDescList, szSuffixList, static_cast<const UT_sint32 *>(nTypeList));
    pDialog->runModal(pFrame);

    XAP_Dialog_FileOpenSaveAs::tAnswer ans = pDialog->getAnswer();
    bool bOK = (ans == XAP_Dialog_FileOpenSaveAs::a_OK);

    if (bOK)
    {
        m_sImagePath = pDialog->getPathname();
        UT_sint32 type = pDialog->getFileType();

        // If the number is negative, it's a special type.
        // Some operating systems which depend solely on filename
        // suffixes to identify type (like Windows) will always
        // want auto-detection.
        if (type < 0)
            switch (type)
            {
            case XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO:
                // do some automagical detecting
                m_iGraphicType = IEGFT_Unknown;
                break;
            default:
                // it returned a type we don't know how to handle
                UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
            }
        else
            m_iGraphicType = static_cast<IEGraphicFileType>(pDialog->getFileType());
    }

    FREEP(szDescList);
    FREEP(szSuffixList);
    FREEP(nTypeList);

    pDialogFactory->releaseDialog(pDialog);
    if(m_sImagePath.size() == 0)
    {
        return;
    }

    FG_Graphic* pFG = NULL;

    UT_Error errorCode;

    errorCode = IE_ImpGraphic::loadGraphic(m_sImagePath.c_str(), m_iGraphicType, &pFG);
    if(errorCode != UT_OK || !pFG)
    {
        ShowErrorBox(m_sImagePath, errorCode);
        return;
    }

    DELETEP(m_pGraphic);
    DELETEP(m_pImage);
    m_pGraphic = pFG->clone();
    GR_Graphics * pG = m_pFormatTablePreview->getGraphics();

    FV_View * pView = static_cast<FV_View *>(pFrame->getCurrentView());
    UT_return_if_fail(pView && pView->getDocument());

    UT_uint32 uid = pView->getDocument()->getUID(UT_UniqueId::Image); //see Bug 10852
    m_sImagePath.clear();
    UT_String_sprintf(m_sImagePath,"%d",uid);

    const UT_ByteBuf * pBB = m_pGraphic->getBuffer();
    if(m_pGraphic->getType() == FGT_Raster)
    {
        m_pImage = static_cast<GR_Image *>(
                       pG->createNewImage( m_sImagePath.c_str(),
                                           pBB, pFG->getMimeType(),
                                           pFG->getWidth(),
                                           pFG->getHeight(),
                                           GR_Image::GRT_Raster));
    }
    else
    {
        m_pImage = static_cast<GR_Image *>(
                       pG->createNewImage( m_sImagePath.c_str(),
                                           pBB, pFG->getMimeType(),
                                           m_pFormatTablePreview->getWindowWidth()-2,
                                           m_pFormatTablePreview->getWindowHeight()-2,
                                           GR_Image::GRT_Vector));
    }

    // draw the preview with the changed properties
    if(m_pFormatTablePreview)
        m_pFormatTablePreview->queueDraw();

}