xref: /aoo41x/main/sd/source/ui/func/fuconcs.cxx (revision 79aad27f)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5b190011SAndrew Rist  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19*5b190011SAndrew Rist  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "fuconcs.hxx"
28cdf0e10cSrcweir #include <svx/svdpagv.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <svx/svxids.hrc>
32cdf0e10cSrcweir #include <svx/dialogs.hrc>
33cdf0e10cSrcweir #include <svx/dialmgr.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "app.hrc"
36cdf0e10cSrcweir #include <svl/aeitem.hxx>
37cdf0e10cSrcweir #include <svx/xlnstwit.hxx>
38cdf0e10cSrcweir #include <svx/xlnedwit.hxx>
39cdf0e10cSrcweir #include <svx/xlnedit.hxx>
40cdf0e10cSrcweir #include <svx/xlnstit.hxx>
41cdf0e10cSrcweir #include <svx/xlnwtit.hxx>
42cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
43cdf0e10cSrcweir #include <svx/sdtmfitm.hxx>
44cdf0e10cSrcweir #include <svx/sxekitm.hxx>
45cdf0e10cSrcweir #include <svx/sderitm.hxx>
46cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
47cdf0e10cSrcweir #include <svx/svdopath.hxx>
48cdf0e10cSrcweir #include <svx/svdocirc.hxx>
49cdf0e10cSrcweir #include <svl/intitem.hxx>
50cdf0e10cSrcweir #include <sfx2/request.hxx>
51cdf0e10cSrcweir #include <editeng/adjitem.hxx>
52cdf0e10cSrcweir #include <svx/xtable.hxx>
53cdf0e10cSrcweir #include <svx/sdasitm.hxx>
54cdf0e10cSrcweir #include <svx/tbxcustomshapes.hxx>
55cdf0e10cSrcweir #include <svx/svdoashp.hxx>
56cdf0e10cSrcweir #include <svx/sdtagitm.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir // #88751#
59cdf0e10cSrcweir #include <svx/svdocapt.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // #97016#
62cdf0e10cSrcweir #include <svx/svdomeas.hxx>
63cdf0e10cSrcweir #include "ViewShell.hxx"
64cdf0e10cSrcweir #include "ViewShellBase.hxx"
65cdf0e10cSrcweir #include "ToolBarManager.hxx"
66cdf0e10cSrcweir // #109583#
67cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx>
68cdf0e10cSrcweir #include <svx/gallery.hxx>
69cdf0e10cSrcweir #include <svl/itempool.hxx>
70cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
71cdf0e10cSrcweir 
72cdf0e10cSrcweir #include "sdresid.hxx"
73cdf0e10cSrcweir #include "View.hxx"
74cdf0e10cSrcweir #include "sdpage.hxx"
75cdf0e10cSrcweir #include "Window.hxx"
76cdf0e10cSrcweir #include "stlpool.hxx"
77cdf0e10cSrcweir #include "drawdoc.hxx"
78cdf0e10cSrcweir #include "res_bmp.hrc"
79cdf0e10cSrcweir #include "glob.hrc"
80cdf0e10cSrcweir 
81cdf0e10cSrcweir namespace sd {
82cdf0e10cSrcweir 
83cdf0e10cSrcweir TYPEINIT1( FuConstructCustomShape, FuConstruct );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir /*************************************************************************
86cdf0e10cSrcweir |*
87cdf0e10cSrcweir |* Konstruktor
88cdf0e10cSrcweir |*
89cdf0e10cSrcweir \************************************************************************/
90cdf0e10cSrcweir 
FuConstructCustomShape(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)91cdf0e10cSrcweir FuConstructCustomShape::FuConstructCustomShape (
92cdf0e10cSrcweir 		ViewShell* 			pViewSh,
93cdf0e10cSrcweir 		::sd::Window*		pWin,
94cdf0e10cSrcweir 		::sd::View*			pView,
95cdf0e10cSrcweir 		SdDrawDocument*		pDoc,
96cdf0e10cSrcweir 		SfxRequest&			rReq ) :
97cdf0e10cSrcweir 	FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq,bool bPermanent)101cdf0e10cSrcweir FunctionReference FuConstructCustomShape::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	FuConstructCustomShape* pFunc;
104cdf0e10cSrcweir 	FunctionReference xFunc( pFunc = new FuConstructCustomShape( pViewSh, pWin, pView, pDoc, rReq ) );
105cdf0e10cSrcweir 	xFunc->DoExecute(rReq);
106cdf0e10cSrcweir 	pFunc->SetPermanent( bPermanent );
107cdf0e10cSrcweir 	return xFunc;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
DoExecute(SfxRequest & rReq)110cdf0e10cSrcweir void FuConstructCustomShape::DoExecute( SfxRequest& rReq )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	FuConstruct::DoExecute( rReq );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
115cdf0e10cSrcweir 	if ( pArgs )
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
118cdf0e10cSrcweir 		aCustomShape = rItm.GetValue();
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
122cdf0e10cSrcweir         ToolBarManager::TBG_FUNCTION,
123cdf0e10cSrcweir         ToolBarManager::msDrawingObjectToolBar);
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir /*************************************************************************
127cdf0e10cSrcweir |*
128cdf0e10cSrcweir |* MouseButtonDown-event
129cdf0e10cSrcweir |*
130cdf0e10cSrcweir \************************************************************************/
131cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)132cdf0e10cSrcweir sal_Bool FuConstructCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	if ( rMEvt.IsLeft() && !mpView->IsAction() )
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 		mpWindow->CaptureMouse();
141cdf0e10cSrcweir 		sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 		mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		SdrObject* pObj = mpView->GetCreateObj();
146cdf0e10cSrcweir 		if ( pObj )
147cdf0e10cSrcweir 		{
148cdf0e10cSrcweir 			SetAttributes( pObj );
149cdf0e10cSrcweir 			sal_Bool bForceFillStyle = sal_True;
150cdf0e10cSrcweir 			sal_Bool bForceNoFillStyle = sal_False;
151cdf0e10cSrcweir 			if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
152cdf0e10cSrcweir 			{
153cdf0e10cSrcweir 				bForceFillStyle = sal_False;
154cdf0e10cSrcweir 				bForceNoFillStyle = sal_True;
155cdf0e10cSrcweir 			}
156cdf0e10cSrcweir 			SfxItemSet aAttr(mpDoc->GetPool());
157cdf0e10cSrcweir 			SetStyleSheet( aAttr, pObj, bForceFillStyle, bForceNoFillStyle );
158cdf0e10cSrcweir 			pObj->SetMergedItemSet(aAttr);
159cdf0e10cSrcweir 		}
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	return bReturn;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir /*************************************************************************
166cdf0e10cSrcweir |*
167cdf0e10cSrcweir |* MouseMove-event
168cdf0e10cSrcweir |*
169cdf0e10cSrcweir \************************************************************************/
170cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)171cdf0e10cSrcweir sal_Bool FuConstructCustomShape::MouseMove(const MouseEvent& rMEvt)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	return FuConstruct::MouseMove(rMEvt);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir /*************************************************************************
177cdf0e10cSrcweir |*
178cdf0e10cSrcweir |* MouseButtonUp-event
179cdf0e10cSrcweir |*
180cdf0e10cSrcweir \************************************************************************/
181cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)182cdf0e10cSrcweir sal_Bool FuConstructCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	sal_Bool bReturn(sal_False);
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	if(mpView->IsCreateObj() && rMEvt.IsLeft())
187cdf0e10cSrcweir 	{
188cdf0e10cSrcweir 		SdrObject* pObj = mpView->GetCreateObj();
189cdf0e10cSrcweir 		if( pObj && mpView->EndCreateObj( SDRCREATE_FORCEEND ) )
190cdf0e10cSrcweir 		{
191cdf0e10cSrcweir 			bReturn = sal_True;
192cdf0e10cSrcweir 		}
193cdf0e10cSrcweir 	}
194cdf0e10cSrcweir 	bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	if (!bPermanent)
197cdf0e10cSrcweir 		mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	return bReturn;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir /*************************************************************************
203cdf0e10cSrcweir |*
204cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
205cdf0e10cSrcweir |*
206cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
207cdf0e10cSrcweir |* sal_False.
208cdf0e10cSrcweir |*
209cdf0e10cSrcweir \************************************************************************/
210cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)211cdf0e10cSrcweir sal_Bool FuConstructCustomShape::KeyInput(const KeyEvent& rKEvt)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
214cdf0e10cSrcweir 	return(bReturn);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir /*************************************************************************
218cdf0e10cSrcweir |*
219cdf0e10cSrcweir |* Function aktivieren
220cdf0e10cSrcweir |*
221cdf0e10cSrcweir \************************************************************************/
222cdf0e10cSrcweir 
Activate()223cdf0e10cSrcweir void FuConstructCustomShape::Activate()
224cdf0e10cSrcweir {
225cdf0e10cSrcweir 	mpView->SetCurrentObj( OBJ_CUSTOMSHAPE );
226cdf0e10cSrcweir 	FuConstruct::Activate();
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir /*************************************************************************
230cdf0e10cSrcweir |*
231cdf0e10cSrcweir |* Attribute fuer das zu erzeugende Objekt setzen
232cdf0e10cSrcweir |*
233cdf0e10cSrcweir \************************************************************************/
234cdf0e10cSrcweir 
SetAttributes(SdrObject * pObj)235cdf0e10cSrcweir void FuConstructCustomShape::SetAttributes( SdrObject* pObj )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	sal_Bool bAttributesAppliedFromGallery = sal_False;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
240cdf0e10cSrcweir 	{
241cdf0e10cSrcweir 		std::vector< rtl::OUString > aObjList;
242cdf0e10cSrcweir 		if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
243cdf0e10cSrcweir 		{
244cdf0e10cSrcweir 			sal_uInt16 i;
245cdf0e10cSrcweir 			for ( i = 0; i < aObjList.size(); i++ )
246cdf0e10cSrcweir 			{
247cdf0e10cSrcweir 				if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
248cdf0e10cSrcweir 				{
249cdf0e10cSrcweir 					FmFormModel aFormModel;
250cdf0e10cSrcweir 					SfxItemPool& rPool = aFormModel.GetItemPool();
251cdf0e10cSrcweir 					rPool.FreezeIdRanges();
252cdf0e10cSrcweir 					if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
253cdf0e10cSrcweir 					{
254cdf0e10cSrcweir 						const SdrPage* pPage = aFormModel.GetPage( 0 );
255cdf0e10cSrcweir 						if ( pPage )
256cdf0e10cSrcweir 						{
257cdf0e10cSrcweir 							const SdrObject* pSourceObj = pPage->GetObj( 0 );
258cdf0e10cSrcweir 							if( pSourceObj )
259cdf0e10cSrcweir 							{
260cdf0e10cSrcweir 								const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
261cdf0e10cSrcweir 								SfxItemSet aDest( pObj->GetModel()->GetItemPool(), 				// ranges from SdrAttrObj
262cdf0e10cSrcweir 								SDRATTR_START, SDRATTR_SHADOW_LAST,
263cdf0e10cSrcweir 								SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
264cdf0e10cSrcweir 								SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
265cdf0e10cSrcweir 								// Graphic Attributes
266cdf0e10cSrcweir 								SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
267cdf0e10cSrcweir 								// 3d Properties
268cdf0e10cSrcweir 								SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
269cdf0e10cSrcweir 								// CustomShape properties
270cdf0e10cSrcweir 								SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
271cdf0e10cSrcweir 								// range from SdrTextObj
272cdf0e10cSrcweir 								EE_ITEMS_START, EE_ITEMS_END,
273cdf0e10cSrcweir 								// end
274cdf0e10cSrcweir 								0, 0);
275cdf0e10cSrcweir 								aDest.Set( rSource );
276cdf0e10cSrcweir 								pObj->SetMergedItemSet( aDest );
277cdf0e10cSrcweir 								sal_Int32 nAngle = pSourceObj->GetRotateAngle();
278cdf0e10cSrcweir 								if ( nAngle )
279cdf0e10cSrcweir 								{
280cdf0e10cSrcweir 									double a = nAngle * F_PI18000;
281cdf0e10cSrcweir 									pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
282cdf0e10cSrcweir 								}
283cdf0e10cSrcweir 								bAttributesAppliedFromGallery = sal_True;
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	/*
287cdf0e10cSrcweir 								com::sun::star::uno::Any aAny;
288cdf0e10cSrcweir 								if ( ((SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )).QueryValue( aAny ) )
289cdf0e10cSrcweir 								{
290cdf0e10cSrcweir 									aGeometryItem.PutValue( aAny );
291cdf0e10cSrcweir 									pObj->SetMergedItem( aGeometryItem );
292cdf0e10cSrcweir 									bAttributesAppliedFromGallery = sal_True;
293cdf0e10cSrcweir 								}
294cdf0e10cSrcweir 	*/
295cdf0e10cSrcweir 							}
296cdf0e10cSrcweir 						}
297cdf0e10cSrcweir 					}
298cdf0e10cSrcweir 					break;
299cdf0e10cSrcweir 				}
300cdf0e10cSrcweir 			}
301cdf0e10cSrcweir 		}
302cdf0e10cSrcweir 	}
303cdf0e10cSrcweir 	if ( !bAttributesAppliedFromGallery )
304cdf0e10cSrcweir 	{
305cdf0e10cSrcweir         pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
306cdf0e10cSrcweir 		pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
307cdf0e10cSrcweir 		pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
308cdf0e10cSrcweir 		pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
309cdf0e10cSrcweir 		((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
310cdf0e10cSrcweir 	}
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir // #97016#
CreateDefaultObject(const sal_uInt16,const Rectangle & rRectangle)314cdf0e10cSrcweir SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir 	SdrObject* pObj = SdrObjFactory::MakeNewObject(
317cdf0e10cSrcweir 		mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
318cdf0e10cSrcweir 		0L, mpDoc);
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 	if( pObj )
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		Rectangle aRect( rRectangle );
323cdf0e10cSrcweir 		if ( doConstructOrthogonal() )
324cdf0e10cSrcweir 			ImpForceQuadratic( aRect );
325cdf0e10cSrcweir 		pObj->SetLogicRect( aRect );
326cdf0e10cSrcweir 		SetAttributes( pObj );
327cdf0e10cSrcweir 		SfxItemSet aAttr(mpDoc->GetPool());
328cdf0e10cSrcweir 		SetStyleSheet(aAttr, pObj);
329cdf0e10cSrcweir 		pObj->SetMergedItemSet(aAttr);
330cdf0e10cSrcweir 	}
331cdf0e10cSrcweir 	return pObj;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir // #i33136#
doConstructOrthogonal() const335cdf0e10cSrcweir bool FuConstructCustomShape::doConstructOrthogonal() const
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir } // end of namespace sd
341