xref: /aoo41x/main/sd/source/ui/func/fuvect.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 
32 #include "fuvect.hxx"
33 #include <tools/poly.hxx>
34 #ifndef _SVDOPATH_HXX //autogen
35 #include <svx/svdograf.hxx>
36 #endif
37 #include <vcl/msgbox.hxx>
38 #ifndef _SVX_SVDOGRAF_HXX //autogen
39 #include <svx/svdograf.hxx>
40 #endif
41 #ifndef _SVX_SVDEDTV_HXX //autogen
42 #include <svx/svdedtv.hxx>
43 #endif
44 
45 
46 #include "View.hxx"
47 #include "ViewShell.hxx"
48 #include "Window.hxx"
49 #include "strings.hrc"
50 #include "sdresid.hxx"
51 #include "sdabstdlg.hxx"
52 
53 namespace sd
54 {
55 
56 TYPEINIT1( FuVectorize, FuPoor );
57 
58 /*************************************************************************
59 |*
60 |* Konstruktor
61 |*
62 \************************************************************************/
63 
64 FuVectorize::FuVectorize (
65     ViewShell* pViewSh,
66     ::sd::Window* pWin,
67     ::sd::View* pView,
68     SdDrawDocument* pDoc,
69     SfxRequest& rReq)
70     : FuPoor (pViewSh, pWin, pView, pDoc, rReq)
71 {
72 }
73 
74 FunctionReference FuVectorize::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
75 {
76 	FunctionReference xFunc( new FuVectorize( pViewSh, pWin, pView, pDoc, rReq ) );
77 	xFunc->DoExecute(rReq);
78 	return xFunc;
79 }
80 
81 void FuVectorize::DoExecute( SfxRequest& )
82 {
83 	const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
84 
85 	if( rMarkList.GetMarkCount() == 1 )
86 	{
87 		SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
88 
89 		if( pObj && pObj->ISA( SdrGrafObj ) )
90 		{
91 			SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
92 			AbstractSdVectorizeDlg* pDlg = pFact ? pFact->CreateSdVectorizeDlg( mpWindow, ( (SdrGrafObj*) pObj )->GetGraphic().GetBitmap(), mpDocSh ) : 0;
93 			if( pDlg && pDlg->Execute() == RET_OK )
94 			{
95 				const GDIMetaFile&	rMtf = pDlg->GetGDIMetaFile();
96 				SdrPageView*		pPageView = mpView->GetSdrPageView();
97 
98 				if( pPageView && rMtf.GetActionCount() )
99 				{
100 					SdrGrafObj*	pVectObj = (SdrGrafObj*) pObj->Clone();
101 					String		aStr( mpView->GetDescriptionOfMarkedObjects() );
102 
103 					aStr.Append( sal_Unicode(' ') );
104 					aStr.Append( String( SdResId( STR_UNDO_VECTORIZE ) ) );
105 					mpView->BegUndo( aStr );
106 					pVectObj->SetGraphic( rMtf );
107 					mpView->ReplaceObjectAtView( pObj, *pPageView, pVectObj );
108 					mpView->EndUndo();
109 				}
110 			}
111 			delete pDlg;
112 		}
113 	}
114 }
115 
116 } // end of namespace sd
117