summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-04-21 14:07:20 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-04-21 21:55:47 +0200
commitdf155415d8f46d884ba18e370e8028d020ba6f3b (patch)
treee9b6642af83a49fe0af3ee027c4a49f30b05726b /sw
parent06c25631e316fb3eebf88c2e8396ddb5b9aa9b21 (diff)
Menu "Manage Graphic" and Rotate 90 degree menu items added to Writer.
Change-Id: Ic5ced4a743c6d5465462a7d88e63150741d1f920
Diffstat (limited to 'sw')
-rw-r--r--sw/sdi/_grfsh.sdi4
-rw-r--r--sw/source/ui/app/mn.src30
-rw-r--r--sw/source/ui/inc/grfsh.hxx10
-rw-r--r--sw/source/ui/shells/grfsh.cxx85
4 files changed, 99 insertions, 30 deletions
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 <editeng/brushitem.hxx>
#include <svx/grfflt.hxx>
#include <svx/compressgraphicdialog.hxx>
+#include <vcl/GraphicNativeTransform.hxx>
#include <svx/tbxcolor.hxx>
#include <fmturl.hxx>
#include <view.hxx>
@@ -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)