diff options
Diffstat (limited to 'cui/source/tabpages/grfpage.cxx')
-rw-r--r-- | cui/source/tabpages/grfpage.cxx | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx index 091ef70faddf..cf0f13e42350 100644 --- a/cui/source/tabpages/grfpage.cxx +++ b/cui/source/tabpages/grfpage.cxx @@ -57,6 +57,7 @@ SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* p , nOldWidth(0) , nOldHeight(0) , bSetOrigSize(false) + , m_aPreferredDPI(0) , m_xCropFrame(m_xBuilder->weld_widget("cropframe")) , m_xZoomConstRB(m_xBuilder->weld_radio_button("keepscale")) , m_xSizeConstRB(m_xBuilder->weld_radio_button("keepsize")) @@ -287,6 +288,10 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) DBG_ASSERT( pPool, "Where is the pool?" ); #endif + auto& aProperties = getAdditionalProperties(); + if (aProperties.find("PreferredDPI") != aProperties.end()) + m_aPreferredDPI = aProperties.at("PreferredDPI").get<sal_Int32>(); + bSetOrigSize = false; // Size @@ -652,6 +657,7 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) } sTemp = sTemp.replaceAll("%1", sPPI); } + sTemp += "\n" + OUString::number(aOrigPixelSize.Width()) + u"\u00D7" + OUString::number(aOrigPixelSize.Height()) + " px"; m_xOrigSizeFT->set_label(sTemp); } @@ -664,13 +670,27 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) Size SvxGrfCropPage::GetGrfOrigSize(const Graphic& rGrf) { - const MapMode aMapTwip( MapUnit::MapTwip ); - Size aSize( rGrf.GetPrefSize() ); - if( MapUnit::MapPixel == rGrf.GetPrefMapMode().GetMapUnit() ) - aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMapTwip); + Size aSize; + + if (m_aPreferredDPI > 0) + { + Size aPixelSize = rGrf.GetSizePixel(); + double fWidth = aPixelSize.Width() / double(m_aPreferredDPI); + double fHeight = aPixelSize.Height() / double(m_aPreferredDPI); + fWidth = fWidth * 1440.0; + fHeight = fHeight * 1440.0; + aSize = Size(fWidth, fHeight); + } else - aSize = OutputDevice::LogicToLogic( aSize, - rGrf.GetPrefMapMode(), aMapTwip ); + { + const MapMode aMapTwip( MapUnit::MapTwip ); + aSize = rGrf.GetPrefSize(); + if( MapUnit::MapPixel == rGrf.GetPrefMapMode().GetMapUnit() ) + aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMapTwip); + else + aSize = OutputDevice::LogicToLogic( aSize, + rGrf.GetPrefMapMode(), aMapTwip ); + } return aSize; } |