summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2011-10-29 00:12:25 +0200
committerAndras Timar <atimar@suse.com>2011-10-29 00:21:18 +0200
commitadb8868edaebb372a54140f84bf85ac9eef37918 (patch)
treecb65d747f8a01e4fd40c190083e3e167798549fe
parentd87d2aa40853d6119322698b26d701a4936b52a5 (diff)
Display original resolution in PPI in Writer's Picture/Crop tab
-rw-r--r--cui/source/inc/grfpage.hxx1
-rw-r--r--cui/source/tabpages/grfpage.cxx32
-rw-r--r--cui/source/tabpages/grfpage.hrc3
-rw-r--r--cui/source/tabpages/grfpage.src42
4 files changed, 36 insertions, 42 deletions
diff --git a/cui/source/inc/grfpage.hxx b/cui/source/inc/grfpage.hxx
index 9d53f2cc29db..4840442ccb83 100644
--- a/cui/source/inc/grfpage.hxx
+++ b/cui/source/inc/grfpage.hxx
@@ -97,6 +97,7 @@ class SvxGrfCropPage : public SfxTabPage
Timer aTimer;
String aGraphicName;
Size aOrigSize;
+ Size aOrigPixelSize;
Size aPageSize;
const MetricField* pLastCropField;
long nOldWidth;
diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx
index 435345baeda2..af27a6cde508 100644
--- a/cui/source/tabpages/grfpage.cxx
+++ b/cui/source/tabpages/grfpage.cxx
@@ -42,6 +42,7 @@
#include <svx/dialogs.hrc> // for RID_SVXPAGE_GRFCROP
#define CM_1_TO_TWIP 567
+#define TWIP_TO_INCH 1440
inline long lcl_GetValue( MetricField& rMetric, FieldUnit eUnit )
@@ -214,8 +215,13 @@ void SvxGrfCropPage::Reset( const SfxItemSet &rSet )
if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, sal_False, &pItem ) )
{
const Graphic* pGrf = ((SvxBrushItem*)pItem)->GetGraphic();
- if( pGrf )
+ if( 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() )
{
@@ -360,6 +366,10 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet)
{
aExampleWN.SetGraphic( *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);
GraphicHasChanged( aOrigSize.Width() && aOrigSize.Height() );
CalcMinMaxBorder();
@@ -664,9 +674,25 @@ void SvxGrfCropPage::GraphicHasChanged( sal_Bool bFound )
aFld.SetValue( aFld.Normalize( aOrigSize.Width() ), eUnit );
String sTemp = aFld.GetText();
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();
- 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);
aLeftMF .Enable(bFound);
diff --git a/cui/source/tabpages/grfpage.hrc b/cui/source/tabpages/grfpage.hrc
index 438e67a8010f..67c7f0e9719a 100644
--- a/cui/source/tabpages/grfpage.hrc
+++ b/cui/source/tabpages/grfpage.hrc
@@ -49,5 +49,4 @@
#define RB_SIZECONST 23
#define RB_ZOOMCONST 24
#define WN_BSP 25
-
-
+#define STR_PPI 2600
diff --git a/cui/source/tabpages/grfpage.src b/cui/source/tabpages/grfpage.src
index 085e92f2d0c0..6e1b5af9618a 100644
--- a/cui/source/tabpages/grfpage.src
+++ b/cui/source/tabpages/grfpage.src
@@ -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)" ;
+};