[Libreoffice-commits] core.git: include/svx sd/source svx/source

Gulsah Kose gulsah.1004 at gmail.com
Fri May 20 10:20:56 UTC 2016


 include/svx/svdograf.hxx       |    1 +
 sd/source/ui/view/drviews7.cxx |   11 +++++++++++
 sd/source/ui/view/sdview.cxx   |   14 ++------------
 svx/source/svdraw/svdograf.cxx |   17 +++++++++++++++++
 4 files changed, 31 insertions(+), 12 deletions(-)

New commits:
commit b12354a2de297f05dcdf4602290b56d64675006a
Author: Gulsah Kose <gulsah.1004 at gmail.com>
Date:   Wed Apr 20 18:29:07 2016 +0300

    tdf#87668 Add control to show or hide "Original Size" option.
    
    Change-Id: I022ff86af2e480b061023aac50ff9f79fc6dbf9e
    Signed-off-by: Gulsah Kose <gulsah.1004 at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/24263
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 9e7bf06..90027f4 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 85e7ddb..cd3162e 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 c6e44d3..c7d8031 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 0f2b642..c67599d 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() )


More information about the Libreoffice-commits mailing list