From df155415d8f46d884ba18e370e8028d020ba6f3b Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 21 Apr 2013 14:07:20 +0200 Subject: Menu "Manage Graphic" and Rotate 90 degree menu items added to Writer. Change-Id: Ic5ced4a743c6d5465462a7d88e63150741d1f920 --- svx/inc/svx/svxids.hrc | 4 +- sw/sdi/_grfsh.sdi | 4 +- sw/source/ui/app/mn.src | 30 ++++++++++----- sw/source/ui/inc/grfsh.hxx | 10 +++-- sw/source/ui/shells/grfsh.cxx | 85 +++++++++++++++++++++++++++++++++++-------- 5 files changed, 101 insertions(+), 32 deletions(-) diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc index da669b8fd8a6..54540424eeaf 100644 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -931,10 +931,10 @@ #define SID_CHANGE_PICTURE (SID_SVX_START+1125) #define SID_ROTATE_GRAPHIC_LEFT (SID_SVX_START+1126) #define SID_ROTATE_GRAPHIC_RIGHT (SID_SVX_START+1127) - +#define SID_MENU_MANAGE_GRAPHIC (SID_SVX_START+1128) // IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id -#define SID_SVX_FIRSTFREE (SID_ROTATE_GRAPHIC_RIGHT + 1) +#define SID_SVX_FIRSTFREE (SID_MENU_MANAGE_GRAPHIC + 1) // -------------------------------------------------------------------------- // Overflow check for slot IDs diff --git a/sw/sdi/_grfsh.sdi b/sw/sdi/_grfsh.sdi index f91eba916c6e..491d01a83258 100644 --- a/sw/sdi/_grfsh.sdi +++ b/sw/sdi/_grfsh.sdi @@ -62,13 +62,13 @@ interface BaseTextGraphic SID_ROTATE_GRAPHIC_LEFT [ - ExecMethod = Execute ; + ExecMethod = ExecuteRotation ; StateMethod = GetAttrState ; ] SID_ROTATE_GRAPHIC_RIGHT [ - ExecMethod = Execute ; + ExecMethod = ExecuteRotation ; StateMethod = GetAttrState ; ] diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index a9871d49ff7f..3c230f9d02ff 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -1292,15 +1292,27 @@ Menu MN_GRF_POPUPMENU MenuItem { - Identifier = SID_ROTATE_GRAPHIC_LEFT ; - Command = ".uno:RotateGraphicLeft" ; - Text [ en-US ] = "Rotate Graphic Left" ; - }; - MenuItem - { - Identifier = SID_ROTATE_GRAPHIC_RIGHT ; - Command = ".uno:RotateGraphicRight" ; - Text [ en-US ] = "Rotate Graphic Right" ; + Identifier = SID_MENU_MANAGE_GRAPHIC ; + Command = ".uno:ManageGraphicMenu" ; + Text [ en-US ] = "~Manage Graphic" ; + SubMenu = Menu + { + ItemList = + { + MenuItem + { + Identifier = SID_ROTATE_GRAPHIC_LEFT ; + Command = ".uno:RotateGraphicLeft" ; + Text [ en-US ] = "Rotate 90° Left" ; + }; + MenuItem + { + Identifier = SID_ROTATE_GRAPHIC_RIGHT ; + Command = ".uno:RotateGraphicRight" ; + Text [ en-US ] = "Rotate 90° Right" ; + }; + }; + }; }; SEPARATOR; diff --git a/sw/source/ui/inc/grfsh.hxx b/sw/source/ui/inc/grfsh.hxx index a0665141e13b..b9567860c330 100644 --- a/sw/source/ui/inc/grfsh.hxx +++ b/sw/source/ui/inc/grfsh.hxx @@ -26,11 +26,13 @@ class SwGrfShell: public SwBaseShell public: SFX_DECL_INTERFACE(SW_GRFSHELL) - void Execute(SfxRequest &); - void ExecAttr(SfxRequest &); - void GetAttrState(SfxItemSet &); + void Execute(SfxRequest& rRequest); + void ExecuteRotation(SfxRequest &rRequest); + void ExecAttr(SfxRequest& rRequest); - SwGrfShell(SwView &rView); + void GetAttrState(SfxItemSet& rRequest); + + SwGrfShell(SwView &rView); }; #endif diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index ea883279d227..17c441c501bc 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -72,20 +73,24 @@ #define TOOLBOX_NAME "colorbar" -class SwExternalToolEdit : public ExternalToolEdit +namespace { - SwWrtShell* m_pShell; + class SwExternalToolEdit : public ExternalToolEdit + { + SwWrtShell* m_pShell; -public: - SwExternalToolEdit ( SwWrtShell* pShell ) : - m_pShell (pShell) - {} + public: + SwExternalToolEdit ( SwWrtShell* pShell ) : + m_pShell (pShell) + {} + + virtual void Update( Graphic& aGraphic ) + { + m_pShell->ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &aGraphic); + } + }; +} - virtual void Update( Graphic& aGraphic ) - { - m_pShell->ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &aGraphic); - } -}; SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC)) { @@ -162,9 +167,8 @@ void SwGrfShell::Execute(SfxRequest &rReq) break; case SID_EXTERNAL_EDIT: { - /* When the graphic is selected to be opened via some external tool - * for advanced editing - */ + // When the graphic is selected to be opened via some external tool + // for advanced editing GraphicObject *pGraphicObject = (GraphicObject *) rSh.GetGraphicObj(); if(0 != pGraphicObject) { @@ -173,7 +177,6 @@ void SwGrfShell::Execute(SfxRequest &rReq) } } break; - case SID_INSERT_GRAPHIC: case FN_FORMAT_GRAFIC_DLG: { @@ -592,6 +595,22 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet) if( rSh.GetGraphicType() == GRAPHIC_NONE ) bDisable = true; break; + case SID_ROTATE_GRAPHIC_LEFT: + case SID_ROTATE_GRAPHIC_RIGHT: + if( rSh.GetGraphicType() == GRAPHIC_NONE ) + { + bDisable = true; + } + else + { + Graphic aGraphic = *rSh.GetGraphic(); + GraphicNativeTransform aTransform(aGraphic); + if (!aTransform.canBeRotated()) + { + bDisable = true; + } + } + break; case SID_COLOR_SETTINGS: { if ( bParentCntProt || !bIsGrfCntnt ) @@ -732,6 +751,42 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet) SetGetStateSet( 0 ); } +void SwGrfShell::ExecuteRotation(SfxRequest &rReq) +{ + sal_uInt16 aRotation; + + SwWrtShell& rShell = GetShell(); + + if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_LEFT) + { + aRotation = 900; + } + else if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RIGHT) + { + aRotation = 2700; + } + else + { + return; + } + + rShell.StartAllAction(); + rShell.StartUndo(UNDO_START); + + Graphic aGraphic = *rShell.GetGraphic(); + GraphicNativeTransform aTransform(aGraphic); + aTransform.rotate(aRotation); + rShell.ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &aGraphic); + + SwFlyFrmAttrMgr aManager( false, &rShell, rShell.IsFrmSelected() ? FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF); + Size aSize(aManager.GetSize().Height(), aManager.GetSize().Width()); + aManager.SetSize(aSize); + aManager.UpdateFlyFrm(); + + rShell.EndUndo(UNDO_END); + rShell.EndAllAction(); +} + SwGrfShell::SwGrfShell(SwView &_rView) : SwBaseShell(_rView) -- cgit