diff options
author | Gulsah Kose <gulsah.1004@gmail.com> | 2016-04-20 18:29:07 +0300 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-05-20 10:20:34 +0000 |
commit | b12354a2de297f05dcdf4602290b56d64675006a (patch) | |
tree | 926969bea08f00ff7ffb06c7438973680ee2d88f | |
parent | 824cf015683383b553c744a746ac8e8ea65495cf (diff) |
tdf#87668 Add control to show or hide "Original Size" option.
Change-Id: I022ff86af2e480b061023aac50ff9f79fc6dbf9e
Signed-off-by: Gulsah Kose <gulsah.1004@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/24263
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | include/svx/svdograf.hxx | 1 | ||||
-rw-r--r-- | sd/source/ui/view/drviews7.cxx | 11 | ||||
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 14 | ||||
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 17 |
4 files changed, 31 insertions, 12 deletions
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 9e7bf069300c..90027f4429ad 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -143,6 +143,7 @@ public: void SetGrafStreamURL( const OUString& rGraphicStreamURL ); OUString GetGrafStreamURL() const; + Size getOriginalSize() const; private: void ForceSwapIn() const; diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 85e7ddb78c23..cd3162ec40e2 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1328,6 +1328,17 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) { bSingleGraphicSelected = nMarkCount == 1; const SdrGrafObj* pSdrGrafObj = static_cast< const SdrGrafObj* >(pObj); + + // Current size of the OBJ_GRAF + const Rectangle aRect = static_cast<SdrObject*>(pObj)->GetLogicRect(); + const Size aCurrentSizeofObj = aRect.GetSize(); + + // Original size of the OBJ_GRAF + const Size aOriginalSizeofObj = pSdrGrafObj->getOriginalSize(); + + if(aCurrentSizeofObj == aOriginalSizeofObj ) + rSet.DisableItem(SID_ORIGINAL_SIZE); + switch(pSdrGrafObj->GetGraphicType()) { case GRAPHIC_BITMAP : diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index c6e44d353d80..c7d803119a99 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -886,18 +886,8 @@ void View::SetMarkedOriginalSize() } else if( pObj->GetObjIdentifier() == OBJ_GRAF ) { - const MapMode aMap100( MAP_100TH_MM ); - Size aSize; - - if ( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL ) - aSize = Application::GetDefaultDevice()->PixelToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), aMap100 ); - else - { - aSize = OutputDevice::LogicToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), - static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode(), - aMap100 ); - } - + const SdrGrafObj* pSdrGrafObj = static_cast< const SdrGrafObj* >(pObj); + const Size aSize = pSdrGrafObj->getOriginalSize( ); pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) ); Rectangle aRect( pObj->GetLogicRect() ); aRect.SetSize( aSize ); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 0f2b64279e70..c67599d3a8a3 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -559,6 +559,23 @@ OUString SdrGrafObj::GetGrafStreamURL() const return pGraphic->GetUserData(); } +Size SdrGrafObj::getOriginalSize() const +{ + Size aSize; + + if ( GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL ) + aSize = Application::GetDefaultDevice()->PixelToLogic( GetGrafPrefSize(), + GetModel()->GetScaleUnit() ); + else + { + aSize = OutputDevice::LogicToLogic( GetGrafPrefSize(), + GetGrafPrefMapMode(), + GetModel()->GetScaleUnit() ); + } + + return aSize; +} + void SdrGrafObj::ForceSwapIn() const { if( mbIsPreview && pGraphic->HasUserData() ) |