Update ooo320-m1
[ooovba.git] / sd / source / ui / func / futransf.cxx
blob15c13e62c44da55dfc7a3ccda0802ceec7a2c14e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: futransf.cxx,v $
10 * $Revision: 1.12.114.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include "futransf.hxx"
37 #include <svx/dialogs.hrc>
38 #include <svx/polysc3d.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <sfx2/request.hxx>
42 #include "strings.hrc"
43 #include "ViewShell.hxx"
44 #include "View.hxx"
45 #include "sdresid.hxx"
46 #include "drawdoc.hxx"
47 #include <svx/svxdlg.hxx>
48 #include <svx/dialogs.hrc>
50 namespace sd {
52 TYPEINIT1( FuTransform, FuPoor );
54 /*************************************************************************
56 |* Konstruktor
58 \************************************************************************/
60 FuTransform::FuTransform(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
61 SdDrawDocument* pDoc, SfxRequest& rReq)
62 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
66 FunctionReference FuTransform::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
68 FunctionReference xFunc( new FuTransform( pViewSh, pWin, pView, pDoc, rReq ) );
69 xFunc->DoExecute(rReq);
70 return xFunc;
73 void FuTransform::DoExecute( SfxRequest& rReq )
75 if( mpView->AreObjectsMarked() )
77 const SfxItemSet* pArgs = rReq.GetArgs();
79 if( !pArgs )
81 // --------- itemset for size and position --------
82 SfxItemSet aSet( mpView->GetGeoAttrFromMarked() );
84 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
85 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
86 if( rMarkList.GetMarkCount() == 1 &&
87 pObj->GetObjInventor() == SdrInventor &&
88 pObj->GetObjIdentifier() == OBJ_CAPTION )
90 // --------- itemset for caption --------
91 SfxItemSet aNewAttr( mpDoc->GetPool() );
92 mpView->GetAttributes( aNewAttr );
94 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
95 if ( pFact )
97 std::auto_ptr< SfxAbstractTabDialog > pDlg( pFact->CreateCaptionDialog( NULL, mpView, RID_SVXDLG_CAPTION ) );
99 const USHORT* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
100 SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
101 aCombSet.Put( aNewAttr );
102 aCombSet.Put( aSet );
103 pDlg->SetInputSet( &aCombSet );
105 if( pDlg.get() && (pDlg->Execute() == RET_OK) )
107 rReq.Done( *( pDlg->GetOutputItemSet() ) );
108 pArgs = rReq.GetArgs();
112 else
114 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
115 if(pFact)
117 std::auto_ptr< SfxAbstractTabDialog > pDlg( pFact->CreateSvxTransformTabDialog( NULL, &aSet,mpView, RID_SVXDLG_TRANSFORM) );
118 if( pDlg.get() && (pDlg->Execute() == RET_OK) )
120 rReq.Done( *( pDlg->GetOutputItemSet() ) );
121 pArgs = rReq.GetArgs();
127 if( pArgs )
129 // Undo
130 String aString( mpView->GetDescriptionOfMarkedObjects() );
131 aString.Append( sal_Unicode(' ') );
132 aString.Append( String( SdResId( STR_TRANSFORM ) ) );
133 mpView->BegUndo( aString );
135 mpView->SetGeoAttrToMarked( *pArgs );
136 mpView->SetAttributes( *pArgs );
137 mpView->EndUndo();
142 /*************************************************************************
144 |* Function ResizeObject
146 \************************************************************************/
148 Point FuTransform::GetPoint( Rectangle aRect, RECT_POINT eRP )
151 switch( eRP )
153 case RP_LT: return( Point( aRect.Left(), aRect.Top() ) );
154 case RP_MT: return( Point( aRect.Center().X(), aRect.Top() ) );
155 case RP_RT: return( Point( aRect.Right(), aRect.Top() ) );
156 case RP_LM: return( Point( aRect.Left(), aRect.Center().Y() ) );
157 case RP_MM: return( Point( aRect.Center().X(), aRect.Center().Y() ) );
158 case RP_RM: return( Point( aRect.Right(), aRect.Center().Y() ) );
159 case RP_LB: return( Point( aRect.Left(), aRect.Bottom() ) );
160 case RP_MB: return( Point( aRect.Center().X(), aRect.Bottom() ) );
161 case RP_RB: return( Point( aRect.Right(), aRect.Bottom() ) );
163 return( Point ( 0, 0 ) ); // Sollte nicht vorkommen !
167 } // end of namespace sd