Hi all!
I'm working on Bug 34423 (more of a feature request).
There's this extension called OpenOffice Toolbox on the bug's page. It implements image rotation. I
want to port that to C++.
I added a menu item to the right click menu of the image (Rotate... <- will call a dialog), now it
just rotates the image with a hard coded value (90 degrees).
To be precise it should rotate the image, but I don't really know this UNO thing, so I'm not sure
what I'm doing (wrong) :)
My goal is to somehow get the selected image (XShape ?) and change its 'RotateAngle' property (this
was used in the extension code (basic)).
I hope someone can help me with this.
Szabolcs
From 2b65880c462367c71b2eb07b0787404260a193b1 Mon Sep 17 00:00:00 2001
From: Szabolcs Dezsi <dezsiszabi@hotmail.com>
Date: Mon, 2 Apr 2012 19:15:17 +0200
Subject: [PATCH] Rotate help
---
sw/inc/cmdid.h | 2 ++
sw/inc/swcommands.h | 1 +
sw/sdi/_grfsh.sdi | 6 ++++++
sw/sdi/swriter.sdi | 23 +++++++++++++++++++++++
sw/source/ui/app/mn.src | 6 ++++++
sw/source/ui/shells/grfsh.cxx | 23 +++++++++++++++++++++++
6 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 7802db7..d888c05 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -619,6 +619,8 @@ included in c-context files, so c++ style stuff will cause problems.
#define FN_TABLE_AUTOSUM (FN_FORMAT + 195) /* */
#define FN_SET_CONTROL_HANDLER (FN_FORMAT + 199) /* set macro */
+#define FN_ROTATE (FN_FORMAT + 196) /* rotate picture */
+
#define FN_IS_IMAGE (FN_FORMAT2 + 6) /* numbering: with graphic? */
#define FN_GOTO_NEXT_REGION (FN_FORMAT2 + 9) /* */
diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h
index 411ec5c..e211ef5 100644
--- a/sw/inc/swcommands.h
+++ b/sw/inc/swcommands.h
@@ -439,6 +439,7 @@
#define CMD_FN_HEADERFOOTER_BORDERBACK ".uno:HeaderFooterBorderBackground"
#define CMD_FN_PAGEBREAK_EDIT ".uno:PageBreakEdit"
#define CMD_FN_PAGEBREAK_DELETE ".uno:PageBreakDelete"
+#define CMD_FN_ROTATE ".uno:RotatePicture"
#endif
diff --git a/sw/sdi/_grfsh.sdi b/sw/sdi/_grfsh.sdi
index d60dc39..942b990 100644
--- a/sw/sdi/_grfsh.sdi
+++ b/sw/sdi/_grfsh.sdi
@@ -70,6 +70,12 @@ interface BaseTextGraphic
DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
]
+ FN_ROTATE
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetAttrState ;
+ ]
+
SID_TWAIN_TRANSFER
[
ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index d7cb8b3..ee307f7 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -3536,6 +3536,29 @@ SfxVoidItem ExternalEdit FN_EXTERNAL_EDIT
]
//------------------------------------------------------------------------
+SfxVoidItem RotatePicture FN_ROTATE
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_GRAPHIC;
+]
//--------------------------------------------------------------------------
SfxVoidItem Grow FN_GROW_FONT_SIZE
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index e1f2aa1..1933fec 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -1262,6 +1262,12 @@ Menu MN_GRF_POPUPMENU
{
MN_ALIGN_FRAME
MN_MOUSE_FRAME_WITH_CONTOUR
+ MenuItem
+ {
+ Identifier = FN_ROTATE ;
+ HelpId = CMD_FN_ROTATE ;
+ Text [ en-US ] = "Rotate..." ;
+ };
SEPARATOR ;
MN_TITLE_DESCRIPTION_SHAPE
SEPARATOR ;
diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx
index 7b537e4..e1dcb25 100644
--- a/sw/source/ui/shells/grfsh.cxx
+++ b/sw/source/ui/shells/grfsh.cxx
@@ -81,8 +81,15 @@
#include "swabstdlg.hxx"
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
#define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) )
+using namespace ::com::sun::star;
+
SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC))
{
SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU));
@@ -125,6 +132,22 @@ void SwGrfShell::Execute(SfxRequest &rReq)
}
break;
+ case FN_ROTATE:
+ {
+ uno::Reference< frame::XModel > xModel = GetView().GetDocShell() ?
GetView().GetDocShell()->GetModel() : NULL;
+ if ( xModel.is() )
+ {
+ uno::Reference< frame::XController > xController = xModel->getCurrentController();
+ uno::Reference< view::XSelectionSupplier > xDocView(
xModel->getCurrentController(), uno::UNO_QUERY );
+ uno::Any xShape = xDocView->getSelection();
+ uno::Reference< beans::XPropertySet > rShapeProps( xShape, uno::UNO_QUERY );
+ uno::Any Angle;
+ Angle <<= (long)9000;
+ rShapeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
"RotateAngle" )), Angle );
+ }
+ }
+ break;
+
case SID_INSERT_GRAPHIC:
case FN_FORMAT_GRAFIC_DLG:
{
--
1.7.7
Context
- Need help in UNO · Dézsi Szabolcs
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.