Kaydet (Commit) adb8868e authored tarafından László Németh's avatar László Németh Kaydeden (comit) Andras Timar

Display original resolution in PPI in Writer's Picture/Crop tab

üst d87d2aa4
...@@ -97,6 +97,7 @@ class SvxGrfCropPage : public SfxTabPage ...@@ -97,6 +97,7 @@ class SvxGrfCropPage : public SfxTabPage
Timer aTimer; Timer aTimer;
String aGraphicName; String aGraphicName;
Size aOrigSize; Size aOrigSize;
Size aOrigPixelSize;
Size aPageSize; Size aPageSize;
const MetricField* pLastCropField; const MetricField* pLastCropField;
long nOldWidth; long nOldWidth;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <svx/dialogs.hrc> // for RID_SVXPAGE_GRFCROP #include <svx/dialogs.hrc> // for RID_SVXPAGE_GRFCROP
#define CM_1_TO_TWIP 567 #define CM_1_TO_TWIP 567
#define TWIP_TO_INCH 1440
inline long lcl_GetValue( MetricField& rMetric, FieldUnit eUnit ) inline long lcl_GetValue( MetricField& rMetric, FieldUnit eUnit )
...@@ -214,8 +215,13 @@ void SvxGrfCropPage::Reset( const SfxItemSet &rSet ) ...@@ -214,8 +215,13 @@ void SvxGrfCropPage::Reset( const SfxItemSet &rSet )
if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, sal_False, &pItem ) ) if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, sal_False, &pItem ) )
{ {
const Graphic* pGrf = ((SvxBrushItem*)pItem)->GetGraphic(); const Graphic* pGrf = ((SvxBrushItem*)pItem)->GetGraphic();
if( pGrf ) if( pGrf ) {
aOrigSize = GetGrfOrigSize( *pGrf ); aOrigSize = GetGrfOrigSize( *pGrf );
if (pGrf->GetType() == GRAPHIC_BITMAP && aOrigSize.Width() && aOrigSize.Height()) {
Bitmap aBitmap = pGrf->GetBitmap();
aOrigPixelSize = aBitmap.GetSizePixel();
}
}
if( aOrigSize.Width() && aOrigSize.Height() ) if( aOrigSize.Width() && aOrigSize.Height() )
{ {
...@@ -360,6 +366,10 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) ...@@ -360,6 +366,10 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet)
{ {
aExampleWN.SetGraphic( *pGrf ); aExampleWN.SetGraphic( *pGrf );
aOrigSize = GetGrfOrigSize( *pGrf ); aOrigSize = GetGrfOrigSize( *pGrf );
if (pGrf->GetType() == GRAPHIC_BITMAP && aOrigSize.Width() > 1 && aOrigSize.Height() > 1) {
Bitmap aBitmap = pGrf->GetBitmap();
aOrigPixelSize = aBitmap.GetSizePixel();
}
aExampleWN.SetFrameSize(aOrigSize); aExampleWN.SetFrameSize(aOrigSize);
GraphicHasChanged( aOrigSize.Width() && aOrigSize.Height() ); GraphicHasChanged( aOrigSize.Width() && aOrigSize.Height() );
CalcMinMaxBorder(); CalcMinMaxBorder();
...@@ -664,9 +674,25 @@ void SvxGrfCropPage::GraphicHasChanged( sal_Bool bFound ) ...@@ -664,9 +674,25 @@ void SvxGrfCropPage::GraphicHasChanged( sal_Bool bFound )
aFld.SetValue( aFld.Normalize( aOrigSize.Width() ), eUnit ); aFld.SetValue( aFld.Normalize( aOrigSize.Width() ), eUnit );
String sTemp = aFld.GetText(); String sTemp = aFld.GetText();
aFld.SetValue( aFld.Normalize( aOrigSize.Height() ), eUnit ); aFld.SetValue( aFld.Normalize( aOrigSize.Height() ), eUnit );
sTemp += UniString::CreateFromAscii(" x "); // multiplication sign (U+00D7)
sTemp += UniString("\xc3\x97", RTL_TEXTENCODING_UTF8);
sTemp += aFld.GetText(); sTemp += aFld.GetText();
aOrigSizeFT.SetText(sTemp);
if ( aOrigPixelSize.Width() && aOrigPixelSize.Height() ) {
int ax = int(floor((float)aOrigPixelSize.Width() /
((float)aOrigSize.Width()/TWIP_TO_INCH)+0.5));
int ay = int(floor((float)aOrigPixelSize.Height() /
((float)aOrigSize.Height()/TWIP_TO_INCH)+0.5));
sTemp += UniString::CreateFromAscii(" ");
sTemp += CUI_RESSTR( STR_PPI );
String sPPI = UniString::CreateFromInt32(ax);
if (abs(ax - ay) > 1) {
sPPI += UniString("\xc3\x97", RTL_TEXTENCODING_UTF8);
sPPI += UniString::CreateFromInt32(ay);
}
sTemp.SearchAndReplaceAscii("%1", sPPI);
}
aOrigSizeFT.SetText( sTemp );
} }
aLeftFT .Enable(bFound); aLeftFT .Enable(bFound);
aLeftMF .Enable(bFound); aLeftMF .Enable(bFound);
......
...@@ -49,5 +49,4 @@ ...@@ -49,5 +49,4 @@
#define RB_SIZECONST 23 #define RB_SIZECONST 23
#define RB_ZOOMCONST 24 #define RB_ZOOMCONST 24
#define WN_BSP 25 #define WN_BSP 25
#define STR_PPI 2600
...@@ -304,40 +304,8 @@ TabPage RID_SVXPAGE_GRFCROP ...@@ -304,40 +304,8 @@ TabPage RID_SVXPAGE_GRFCROP
}; };
}; };
String STR_PPI
{
Text [ x-comment ] = "PPI is pixel per inch, %1 is a number" ;
Text [ en-US ] = "(%1 PPI)" ;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment