Set the original size in crop dialog to preferred DPI calc. size
If we have the document setting preferred image size set, then use that as the default DPI and recalcualte the logical image size using the DPI and the size in pixels. This is useful so we have the preferred DPI size as 100% in the crop dialog, so we can adjust the size in relation to that value. Change-Id: I50806f194032e228ee2cf56a39e5735a57358d46 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127096 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
046e6cfa54
commit
e34067483e
@@ -56,6 +56,7 @@ class SvxGrfCropPage : public SfxTabPage
|
||||
tools::Long nOldWidth;
|
||||
tools::Long nOldHeight;
|
||||
bool bSetOrigSize;
|
||||
sal_Int32 m_aPreferredDPI;
|
||||
|
||||
SvxCropExample m_aExampleWN;
|
||||
|
||||
@@ -92,7 +93,7 @@ class SvxGrfCropPage : public SfxTabPage
|
||||
void GraphicHasChanged(bool bFound);
|
||||
virtual void ActivatePage(const SfxItemSet& rSet) override;
|
||||
|
||||
static Size GetGrfOrigSize(const Graphic&);
|
||||
Size GetGrfOrigSize(const Graphic& rGraphic);
|
||||
public:
|
||||
SvxGrfCropPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
|
||||
static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet );
|
||||
|
||||
@@ -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,11 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet)
|
||||
DBG_ASSERT( pPool, "Where is the pool?" );
|
||||
#endif
|
||||
|
||||
if (!GetUserData().isEmpty())
|
||||
{
|
||||
m_aPreferredDPI = GetUserData().toInt32();
|
||||
}
|
||||
|
||||
bSetOrigSize = false;
|
||||
|
||||
// Size
|
||||
@@ -670,13 +676,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 = o3tl::convert(fWidth, o3tl::Length::in, o3tl::Length::twip);
|
||||
fHeight = o3tl::convert(fHeight, o3tl::Length::in, o3tl::Length::twip);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -609,6 +609,8 @@ public:
|
||||
bool DoesMakePageObjectsNamesUnique() const { return mbMakePageObjectsNamesUnique; }
|
||||
void DoMakePageObjectsNamesUnique(bool bDo) { mbMakePageObjectsNamesUnique = bDo; }
|
||||
|
||||
virtual sal_Int32 getImagePreferredDPI() const { return 0; }
|
||||
|
||||
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -616,7 +616,7 @@ public:
|
||||
SAL_DLLPRIVATE void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
|
||||
SAL_DLLPRIVATE void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
|
||||
|
||||
sal_Int32 getImagePreferredDPI() { return mnImagePreferredDPI; }
|
||||
sal_Int32 getImagePreferredDPI() const override { return mnImagePreferredDPI; }
|
||||
void setImagePreferredDPI(sal_Int32 nValue) { mnImagePreferredDPI = nValue; }
|
||||
|
||||
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
|
||||
|
||||
@@ -654,6 +654,8 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
|
||||
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
|
||||
::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_GRFCROP );
|
||||
std::unique_ptr<SfxTabPage> xTabPage = (*fnCreatePage)(aCropDialog.get_content_area(), &aCropDialog, &aCropDlgAttr);
|
||||
OUString sPreferredDPI = OUString::number(rView.getSdrModelFromSdrView().getImagePreferredDPI());
|
||||
xTabPage->SetUserData(sPreferredDPI);
|
||||
xTabPage->SetPageTitle(aCropStr);
|
||||
aCropDialog.SetTabPage(std::move(xTabPage));
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <wrap.hxx>
|
||||
#include <column.hxx>
|
||||
#include <macassgn.hxx>
|
||||
#include <IDocumentSettingAccess.hxx>
|
||||
|
||||
#include <strings.hrc>
|
||||
#include <svl/eitem.hxx>
|
||||
@@ -189,6 +190,12 @@ void SwFrameDlg::PageCreated(const OString& rId, SfxTabPage &rPage)
|
||||
{
|
||||
rPage.PageCreated(m_rSet);
|
||||
}
|
||||
else if (rId == "crop")
|
||||
{
|
||||
sal_Int32 nDPI = m_pWrtShell->GetDoc()->getIDocumentSettingAccess().getImagePreferredDPI();
|
||||
if (nDPI)
|
||||
rPage.SetUserData(OUString::number(nDPI));
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user