diff -rup abiword-2.8.6/src/af/xap/gtk/xap_UnixDlg_Image.cpp abiword-2.8.6_imagepatch/src/af/xap/gtk/xap_UnixDlg_Image.cpp --- abiword-2.8.6/src/af/xap/gtk/xap_UnixDlg_Image.cpp 2009-06-06 21:36:47.000000000 -0400 +++ abiword-2.8.6_imagepatch/src/af/xap/gtk/xap_UnixDlg_Image.cpp 2011-06-21 15:47:38.642365463 -0400 @@ -56,6 +56,28 @@ void XAP_UnixDialog_Image::s_HeightEntry dlg->doHeightEntry(); } +gboolean XAP_UnixDialog_Image::s_HeightEntry_FocusOut(GtkWidget * widget, GdkEvent *event, XAP_UnixDialog_Image *dlg) +{ + if(!(widget && dlg)) + { + UT_ASSERT(cond); + return(TRUE); + } + dlg->doHeightEntry(); + return(FALSE); +} + +gboolean XAP_UnixDialog_Image::s_WidthEntry_FocusOut(GtkWidget * widget, GdkEvent *event, XAP_UnixDialog_Image *dlg) +{ + if(!(widget && dlg)) + { + UT_ASSERT(cond); + return(TRUE); + } + dlg->doWidthEntry(); + return(FALSE); +} + void XAP_UnixDialog_Image::s_WidthEntry_changed(GtkWidget * widget, XAP_UnixDialog_Image *dlg) { UT_return_if_fail(widget && dlg); @@ -202,6 +224,10 @@ void XAP_UnixDialog_Image::doHeightEntry gtk_editable_set_position(GTK_EDITABLE(m_wHeightEntry), pos); g_signal_handler_unblock(G_OBJECT(m_wHeightEntry), m_iHeightID); } + else + { + gtk_entry_set_text( GTK_ENTRY(m_wHeightEntry),getHeightString() ); + } adjustWidthForAspect(); } @@ -236,6 +262,10 @@ void XAP_UnixDialog_Image::doWidthEntry( gtk_editable_set_position(GTK_EDITABLE(m_wWidthEntry), pos); g_signal_handler_unblock(G_OBJECT(m_wWidthEntry), m_iWidthID); } + else + { + gtk_entry_set_text( GTK_ENTRY(m_wWidthEntry),getWidthString() ); + } adjustHeightForAspect(); } @@ -393,10 +423,22 @@ void XAP_UnixDialog_Image::_connectSigna static_cast(this)); m_iHeightID = g_signal_connect(G_OBJECT(m_wHeightEntry), - "changed", + "activate", G_CALLBACK(s_HeightEntry_changed), static_cast(this)); + g_signal_connect_after(G_OBJECT(m_wHeightEntry), + "focus_out_event", + G_CALLBACK(s_HeightEntry_FocusOut), + static_cast(this)); + + g_signal_connect_after(G_OBJECT(m_wWidthEntry), + "focus_out_event", + G_CALLBACK(s_WidthEntry_FocusOut), + static_cast(this)); + + + g_signal_connect(G_OBJECT(m_wWidthSpin), "changed", G_CALLBACK(s_WidthSpin_changed), @@ -442,10 +484,10 @@ void XAP_UnixDialog_Image::_connectSigna static_cast(this)); m_iWidthID = g_signal_connect(G_OBJECT(m_wWidthEntry), - "changed", - G_CALLBACK(s_WidthEntry_changed), - static_cast(this)); - + "activate", + G_CALLBACK(s_WidthEntry_changed), + static_cast(this)); + g_signal_connect(G_OBJECT(m_wAspectCheck), "clicked", G_CALLBACK(s_aspect_clicked), diff -rup abiword-2.8.6/src/af/xap/gtk/xap_UnixDlg_Image.h abiword-2.8.6_imagepatch/src/af/xap/gtk/xap_UnixDlg_Image.h --- abiword-2.8.6/src/af/xap/gtk/xap_UnixDlg_Image.h 2007-01-16 18:17:27.000000000 -0500 +++ abiword-2.8.6_imagepatch/src/af/xap/gtk/xap_UnixDlg_Image.h 2011-06-21 15:18:01.906345180 -0400 @@ -69,6 +69,8 @@ class XAP_UnixDialog_Image: public XAP_D static void s_WidthSpin_changed(GtkWidget * widget, XAP_UnixDialog_Image *dlg) ; static void s_HeightEntry_changed(GtkWidget * widget, XAP_UnixDialog_Image *dlg) ; + static gboolean s_HeightEntry_FocusOut(GtkWidget * widget, GdkEvent *event, XAP_UnixDialog_Image *dlg); + static gboolean s_WidthEntry_FocusOut(GtkWidget * widget, GdkEvent *event, XAP_UnixDialog_Image *dlg); static void s_WidthEntry_changed(GtkWidget * widget, XAP_UnixDialog_Image *dlg) ; diff -rup abiword-2.8.6/src/af/xap/xp/xap_Dlg_Image.cpp abiword-2.8.6_imagepatch/src/af/xap/xp/xap_Dlg_Image.cpp --- abiword-2.8.6/src/af/xap/xp/xap_Dlg_Image.cpp 2007-01-19 10:35:52.000000000 -0500 +++ abiword-2.8.6_imagepatch/src/af/xap/xp/xap_Dlg_Image.cpp 2011-06-21 20:19:42.222360855 -0400 @@ -162,7 +162,10 @@ void XAP_Dialog_Image::setHeight(const c */ void XAP_Dialog_Image::setHeight(double dHeight, bool checkaspect) { - double orig_height = m_height; + if(checkaspect && m_bAspect && m_height!=0.0) + setWidthAndHeight(dHeight, false); + else + { m_height = dHeight*72.0; if(m_height < 0.0) { @@ -174,13 +177,9 @@ void XAP_Dialog_Image::setHeight(double m_height = m_maxHeight; dHeight = (m_maxHeight - 1)/72.0; } - m_HeightString = UT_convertInchesToDimensionString(getPreferedUnits(),dHeight); - // Update For Aspect Ratio - if( checkaspect && m_bAspect && orig_height!=0.0 ) - { - setWidth(m_width*m_height/orig_height/72.0, false); - } + m_HeightString = UT_convertInchesToDimensionString(getPreferedUnits(),dHeight); + } } /*! @@ -206,7 +205,10 @@ void XAP_Dialog_Image::setWidth(const ch */ void XAP_Dialog_Image::setWidth(double dWidth, bool checkaspect) { - double orig_width = m_width; + if(checkaspect && m_bAspect && m_width!=0.0) + setWidthAndHeight(dWidth, true); + else + { m_width = dWidth*72.0; if(m_width < 0.0) { @@ -220,13 +222,51 @@ void XAP_Dialog_Image::setWidth(double } m_WidthString = UT_convertInchesToDimensionString(getPreferedUnits(),dWidth); - // Update For Aspect Ratio - if( checkaspect && m_bAspect && orig_width!=0.0 ) - { - setHeight(m_height*m_width/orig_width/72.0, false); - } + } +} + + +void XAP_Dialog_Image::setWidthAndHeight(double wh, bool iswidth) +{ + double orig_width,orig_height; + + orig_width = m_width; + orig_height = m_height; + + if (wh < 0.1) wh=0.1; + if (orig_width < 1.) orig_width = 1.; + if (orig_height < 1.) orig_height = 1.; + + if (iswidth) + { + m_width = wh*72.0; + m_height = m_width*orig_height/orig_width; + } + else + { + m_height = wh*72.0; + m_width = m_height*orig_width/orig_height; + } + + if (m_width > m_maxWidth) + { + m_width = m_maxWidth; + m_height = m_width*orig_height/orig_width; + } + + if (m_height > m_maxHeight) + { + m_height = m_maxHeight; + m_width = m_height*orig_width/orig_height; + } + + + m_WidthString = UT_convertInchesToDimensionString(getPreferedUnits(),m_width/72.0); + m_HeightString = UT_convertInchesToDimensionString(getPreferedUnits(),m_height/72.0); + } + /*! * Set the member string variable m_WidthString from the pixel value of * the image. This is to set the initial value if it's not defined. diff -rup abiword-2.8.6/src/af/xap/xp/xap_Dlg_Image.h abiword-2.8.6_imagepatch/src/af/xap/xp/xap_Dlg_Image.h --- abiword-2.8.6/src/af/xap/xp/xap_Dlg_Image.h 2008-05-14 08:33:34.000000000 -0400 +++ abiword-2.8.6_imagepatch/src/af/xap/xp/xap_Dlg_Image.h 2011-06-19 15:18:37.160689462 -0400 @@ -147,6 +147,7 @@ public: void setWidth (double w, bool checkaspect); void setHeight (double h, bool checkaspect); + void setWidthAndHeight (double wh, bool iswidth); WRAPPING_TYPE m_iWrappingType; POSITION_TO m_iPositionTo; diff -rup abiword-2.8.6/src/text/fmt/xp/fp_Run.cpp abiword-2.8.6_imagepatch/src/text/fmt/xp/fp_Run.cpp --- abiword-2.8.6/src/text/fmt/xp/fp_Run.cpp 2009-12-13 15:25:06.000000000 -0500 +++ abiword-2.8.6_imagepatch/src/text/fmt/xp/fp_Run.cpp 2011-06-22 19:55:29.637424864 -0400 @@ -3511,8 +3511,8 @@ void fp_ImageRun::_lookupProperties(cons { p = pDSL->getDocLayout()->getNthPage(0); } - UT_sint32 maxW = static_cast(static_cast(pDSL->getActualColumnWidth())*0.95); - UT_sint32 maxH = static_cast(static_cast(pDSL->getActualColumnHeight())*0.95); + UT_sint32 maxW = static_cast(static_cast(pDSL->getActualColumnWidth())); + UT_sint32 maxH = static_cast(static_cast(pDSL->getActualColumnHeight())); fl_ContainerLayout * pCL = getBlock()->myContainingLayout(); if(pCL && pCL->getContainerType() == FL_CONTAINER_FRAME) { @@ -3531,8 +3531,8 @@ void fp_ImageRun::_lookupProperties(cons // This is a compromize that makes tables sane for insanely large // images. The user will have to adjust images size manually // - maxW = static_cast(static_cast(maxW)*0.95); - maxH = static_cast(static_cast(maxH)*0.95); + maxW = static_cast(static_cast(maxW)); + maxH = static_cast(static_cast(maxH)); } if(pG->tdu(maxW) < 3) { @@ -3565,7 +3565,7 @@ void fp_ImageRun::_lookupProperties(cons UT_DEBUGMSG(("Change Image Height to %d \n",maxH)); } m_pImage = m_pFGraphic->generateImage(pG, pSpanAP, maxW, maxH); - if(bNoSize && m_pImage) + if(m_pImage) { iW = pG->tlu(m_pImage->getDisplayWidth()); iH = pG->tlu(m_pImage->getDisplayHeight()); diff -rup abiword-2.8.6/src/wp/ap/xp/ap_EditMethods.cpp abiword-2.8.6_imagepatch/src/wp/ap/xp/ap_EditMethods.cpp --- abiword-2.8.6/src/wp/ap/xp/ap_EditMethods.cpp 2010-05-12 17:30:47.000000000 -0400 +++ abiword-2.8.6_imagepatch/src/wp/ap/xp/ap_EditMethods.cpp 2011-06-22 14:48:20.425422441 -0400 @@ -10996,8 +10996,8 @@ Defun1(dlgFmtPosImage) fl_DocSectionLayout * pDSL = pBL->getDocSectionLayout(); UT_sint32 iColWidth = pDSL->getActualColumnWidth(); UT_sint32 iColHeight = pDSL->getActualColumnHeight(); - double max_width = 0.95*iColWidth*72.0/UT_LAYOUT_RESOLUTION; // units are 1/72 of an inch - double max_height = 0.95*iColHeight*72.0/UT_LAYOUT_RESOLUTION; + double max_width = iColWidth*72.0/UT_LAYOUT_RESOLUTION; // units are 1/72 of an inch + double max_height = iColHeight*72.0/UT_LAYOUT_RESOLUTION; pDialog->setMaxWidth (max_width); pDialog->setMaxHeight (max_height); @@ -11022,12 +11022,13 @@ Defun1(dlgFmtPosImage) { pszWidth = "1.0in"; } - pDialog->setWidth(pszWidth); if(!pAP || !pAP->getProperty("frame-height",pszHeight)) { pszHeight = "1.0in"; } - pDialog->setHeight(pszHeight); + pDialog->setWidth( UT_reformatDimensionString(dim,pszWidth)); + pDialog->setHeight( UT_reformatDimensionString(dim,pszHeight)); + UT_DEBUGMSG(("Width %s Height %s \n",pszWidth,pszHeight)); WRAPPING_TYPE iWrap = WRAP_NONE; if(pPosObj->getFrameWrapMode() == FL_FRAME_WRAPPED_TO_LEFT ) @@ -11076,15 +11077,32 @@ Defun1(dlgFmtPosImage) { return true; } + + + UT_String sWidth; + UT_String sHeight; + + sWidth = pDialog->getWidthString(); + sHeight = pDialog->getHeightString(); + UT_DEBUGMSG(("Width %s Height %s \n",sWidth.c_str(),sHeight.c_str())); + const gchar * attribs[] = {"title", NULL, "alt", NULL, 0}; + attribs[1] = pDialog->getTitle().utf8_str(); + attribs[3] = pDialog->getDescription().utf8_str(); + + if(pDialog->getWrapping() == WRAP_INLINE) { - pView->convertPositionedToInLine(pPosObj); - return true; + const gchar * properties[] = {"width", NULL, "height", NULL, 0}; + properties[1] = sWidth.c_str(); + properties[3] = sHeight.c_str(); + + pView->convertPositionedToInLine(pPosObj); + pView->setCharFormat(properties, attribs); + pView->updateScreen(); + return true; } else { - UT_String sWidth; - UT_String sHeight; POSITION_TO newFormatMode = pDialog->getPositionTo(); WRAPPING_TYPE newWrapMode = pDialog->getWrapping(); const gchar * properties[] = {"frame-width", NULL, @@ -11093,9 +11111,6 @@ Defun1(dlgFmtPosImage) "position-to",NULL, "tight-wrap",NULL,NULL}; - sWidth = pDialog->getWidthString(); - sHeight = pDialog->getHeightString(); - UT_DEBUGMSG(("Width %s Height %s \n",sWidth.c_str(),sHeight.c_str())); properties[1] = sWidth.c_str(); properties[3] = sHeight.c_str(); if(newWrapMode == WRAP_TEXTRIGHT) @@ -11129,16 +11144,13 @@ Defun1(dlgFmtPosImage) } if(pDialog->isTightWrap()) { - properties[9] = "1"; + properties[9] = "1"; } else { properties[9] = "0"; } - const gchar * attribs[] = {"title", NULL, "alt", NULL, 0}; - attribs[1] = pDialog->getTitle().utf8_str(); - attribs[3] = pDialog->getDescription().utf8_str(); // // Change the frame! // @@ -11177,7 +11189,7 @@ Defun(dlgFmtImage) XAP_Dialog_Image * pDialog = static_cast(pDialogFactory->requestDialog(XAP_DIALOG_ID_IMAGE)); -UT_return_val_if_fail(pDialog, false); + UT_return_val_if_fail(pDialog, false); double max_width = 0., max_height = 0.; UT_sint32 x1,x2,y1,y2,iHeight,iWidth; bool bEOL = false; @@ -11199,11 +11211,11 @@ UT_return_val_if_fail(pDialog, false); fl_DocSectionLayout * pDSL = pBL->getDocSectionLayout(); UT_sint32 iColWidth = pDSL->getActualColumnWidth(); UT_sint32 iColHeight = pDSL->getActualColumnHeight(); - max_width = 0.95*iColWidth/UT_LAYOUT_RESOLUTION; - max_height = 0.95*iColHeight/UT_LAYOUT_RESOLUTION; + max_width = iColWidth*72.0/UT_LAYOUT_RESOLUTION; + max_height = iColHeight*72.0/UT_LAYOUT_RESOLUTION; - pDialog->setMaxWidth (max_width*72.0); - pDialog->setMaxHeight (max_height*72.0); // units are 1/72 of an inch + pDialog->setMaxWidth (max_width); + pDialog->setMaxHeight (max_height); // units are 1/72 of an inch UT_DEBUGMSG(("formatting image: %d\n", pCallData->m_xPos)); PT_DocPosition pos = pView->getDocPositionFromLastXY(); @@ -11575,10 +11587,14 @@ UT_return_val_if_fail(pDialog, false); // // Now define the Frame attributes strux // - const gchar * attributes[5] = {PT_STRUX_IMAGE_DATAID, - NULL,"props",NULL,NULL}; + const gchar * attributes[9] = {PT_STRUX_IMAGE_DATAID, + NULL,"props",NULL,"title",NULL,"alt",NULL,NULL}; + attributes[1] = dataID; attributes[3] = sFrameProps.c_str(); + attributes[5] = pDialog->getTitle().utf8_str(); + attributes[7] = pDialog->getDescription().utf8_str(); + // // This deletes the inline image and places a positioned image in it's place // It deals with the undo/general update issues.