xref: /trunk/main/sw/source/ui/shells/drawdlg.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC //autogen
36*cdf0e10cSrcweir #include <svx/svxids.hrc>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
39*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #include <sfx2/request.hxx>
42*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
43*cdf0e10cSrcweir #include <svx/svdview.hxx>
44*cdf0e10cSrcweir #include <svx/tabarea.hxx>
45*cdf0e10cSrcweir #include <svx/tabline.hxx>
46*cdf0e10cSrcweir #include <svx/drawitem.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <svx/xtable.hxx>
49*cdf0e10cSrcweir #include "view.hxx"
50*cdf0e10cSrcweir #include "wrtsh.hxx"
51*cdf0e10cSrcweir #include "docsh.hxx"
52*cdf0e10cSrcweir #include "cmdid.h"
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include "drawsh.hxx"
55*cdf0e10cSrcweir #include <svx/svxdlg.hxx>
56*cdf0e10cSrcweir #include <svx/dialogs.hrc>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir /*--------------------------------------------------------------------
59*cdf0e10cSrcweir 	Beschreibung:
60*cdf0e10cSrcweir  --------------------------------------------------------------------*/
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir 	SwWrtShell* 	pSh 	= &GetShell();
66*cdf0e10cSrcweir 	SdrView*		pView	= pSh->GetDrawView();
67*cdf0e10cSrcweir 	SdrModel*		pDoc	= pView->GetModel();
68*cdf0e10cSrcweir 	sal_Bool			bChanged = pDoc->IsChanged();
69*cdf0e10cSrcweir 	pDoc->SetChanged(sal_False);
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	SfxItemSet aNewAttr( pDoc->GetItemPool() );
72*cdf0e10cSrcweir 	pView->GetAttributes( aNewAttr );
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 	GetView().NoRotate();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	switch (rReq.GetSlot())
77*cdf0e10cSrcweir 	{
78*cdf0e10cSrcweir 		case FN_DRAWTEXT_ATTR_DLG:
79*cdf0e10cSrcweir 		{
80*cdf0e10cSrcweir 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
81*cdf0e10cSrcweir 			if ( pFact )
82*cdf0e10cSrcweir 			{
83*cdf0e10cSrcweir 				SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView );
84*cdf0e10cSrcweir 				sal_uInt16 nResult = pDlg->Execute();
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 				if (nResult == RET_OK)
87*cdf0e10cSrcweir 				{
88*cdf0e10cSrcweir 	                if (pView->AreObjectsMarked())
89*cdf0e10cSrcweir 	                {
90*cdf0e10cSrcweir 	                    pSh->StartAction();
91*cdf0e10cSrcweir 	                    pView->SetAttributes(*pDlg->GetOutputItemSet());
92*cdf0e10cSrcweir 	                    rReq.Done(*(pDlg->GetOutputItemSet()));
93*cdf0e10cSrcweir 	                    pSh->EndAction();
94*cdf0e10cSrcweir 	                }
95*cdf0e10cSrcweir 	            }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 				delete( pDlg );
98*cdf0e10cSrcweir 			}
99*cdf0e10cSrcweir 		}
100*cdf0e10cSrcweir 		break;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 		case SID_ATTRIBUTES_AREA:
103*cdf0e10cSrcweir 		{
104*cdf0e10cSrcweir 			sal_Bool bHasMarked = pView->AreObjectsMarked();
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
107*cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
108*cdf0e10cSrcweir 			AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL,
109*cdf0e10cSrcweir 																			&aNewAttr,
110*cdf0e10cSrcweir 																			pDoc,
111*cdf0e10cSrcweir 																			pView);
112*cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
113*cdf0e10cSrcweir 			const SvxColorTableItem* pColorItem = (const SvxColorTableItem*)
114*cdf0e10cSrcweir 									GetView().GetDocShell()->GetItem(SID_COLOR_TABLE);
115*cdf0e10cSrcweir 			if(pColorItem->GetColorTable() == XColorTable::GetStdColorTable())
116*cdf0e10cSrcweir 				pDlg->DontDeleteColorTable();
117*cdf0e10cSrcweir 			if (pDlg->Execute() == RET_OK)
118*cdf0e10cSrcweir 			{
119*cdf0e10cSrcweir                 pSh->StartAction();
120*cdf0e10cSrcweir                 if (bHasMarked)
121*cdf0e10cSrcweir 					pView->SetAttributes(*pDlg->GetOutputItemSet());
122*cdf0e10cSrcweir 				else
123*cdf0e10cSrcweir 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
124*cdf0e10cSrcweir                 pSh->EndAction();
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 				static sal_uInt16 __READONLY_DATA aInval[] =
127*cdf0e10cSrcweir 				{
128*cdf0e10cSrcweir 					SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, 0
129*cdf0e10cSrcweir 				};
130*cdf0e10cSrcweir 				SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
131*cdf0e10cSrcweir 				rBnd.Invalidate(aInval);
132*cdf0e10cSrcweir 				rBnd.Update(SID_ATTR_FILL_STYLE);
133*cdf0e10cSrcweir 				rBnd.Update(SID_ATTR_FILL_COLOR);
134*cdf0e10cSrcweir 			}
135*cdf0e10cSrcweir 			delete pDlg;
136*cdf0e10cSrcweir 		}
137*cdf0e10cSrcweir 		break;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		case SID_ATTRIBUTES_LINE:
140*cdf0e10cSrcweir 		{
141*cdf0e10cSrcweir 			sal_Bool bHasMarked = pView->AreObjectsMarked();
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 			const SdrObject* pObj = NULL;
144*cdf0e10cSrcweir 			const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
145*cdf0e10cSrcweir 			if( rMarkList.GetMarkCount() == 1 )
146*cdf0e10cSrcweir 				pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
149*cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
150*cdf0e10cSrcweir 			SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
151*cdf0e10cSrcweir 					&aNewAttr,
152*cdf0e10cSrcweir 				pDoc,
153*cdf0e10cSrcweir 				pObj,
154*cdf0e10cSrcweir 				bHasMarked);
155*cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
156*cdf0e10cSrcweir 			if (pDlg->Execute() == RET_OK)
157*cdf0e10cSrcweir 			{
158*cdf0e10cSrcweir                 pSh->StartAction();
159*cdf0e10cSrcweir                 if(bHasMarked)
160*cdf0e10cSrcweir 					pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
161*cdf0e10cSrcweir 				else
162*cdf0e10cSrcweir 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
163*cdf0e10cSrcweir                 pSh->EndAction();
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 				static sal_uInt16 __READONLY_DATA aInval[] =
166*cdf0e10cSrcweir 				{
167*cdf0e10cSrcweir 					SID_ATTR_LINE_STYLE, SID_ATTR_LINE_WIDTH,
168*cdf0e10cSrcweir 					SID_ATTR_LINE_COLOR, 0
169*cdf0e10cSrcweir 				};
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 				GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
172*cdf0e10cSrcweir 			}
173*cdf0e10cSrcweir 			delete pDlg;
174*cdf0e10cSrcweir 		}
175*cdf0e10cSrcweir 		break;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 		default:
178*cdf0e10cSrcweir 			break;
179*cdf0e10cSrcweir 	}
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	if (pDoc->IsChanged())
183*cdf0e10cSrcweir 		GetShell().SetModified();
184*cdf0e10cSrcweir 	else
185*cdf0e10cSrcweir 		if (bChanged)
186*cdf0e10cSrcweir 			pDoc->SetChanged(sal_True);
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir /*--------------------------------------------------------------------
190*cdf0e10cSrcweir 	Beschreibung:
191*cdf0e10cSrcweir  --------------------------------------------------------------------*/
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
195*cdf0e10cSrcweir {
196*cdf0e10cSrcweir 	SwWrtShell* pSh   = &GetShell();
197*cdf0e10cSrcweir 	SdrView*	pView = pSh->GetDrawView();
198*cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
199*cdf0e10cSrcweir 	sal_Bool 		bChanged = pView->GetModel()->IsChanged();
200*cdf0e10cSrcweir 	pView->GetModel()->SetChanged(sal_False);
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	GetView().NoRotate();
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	if (pArgs)
205*cdf0e10cSrcweir 	{
206*cdf0e10cSrcweir 		if(pView->AreObjectsMarked())
207*cdf0e10cSrcweir 			pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
208*cdf0e10cSrcweir 		else
209*cdf0e10cSrcweir 			pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
210*cdf0e10cSrcweir 	}
211*cdf0e10cSrcweir 	else
212*cdf0e10cSrcweir 	{
213*cdf0e10cSrcweir 		SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
214*cdf0e10cSrcweir 		switch (rReq.GetSlot())
215*cdf0e10cSrcweir 		{
216*cdf0e10cSrcweir 			case SID_ATTR_FILL_STYLE:
217*cdf0e10cSrcweir 			case SID_ATTR_FILL_COLOR:
218*cdf0e10cSrcweir 			case SID_ATTR_FILL_GRADIENT:
219*cdf0e10cSrcweir 			case SID_ATTR_FILL_HATCH:
220*cdf0e10cSrcweir 			case SID_ATTR_FILL_BITMAP:
221*cdf0e10cSrcweir 				pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
222*cdf0e10cSrcweir 				break;
223*cdf0e10cSrcweir 			case SID_ATTR_LINE_STYLE:
224*cdf0e10cSrcweir 			case SID_ATTR_LINE_DASH:
225*cdf0e10cSrcweir 			case SID_ATTR_LINE_WIDTH:
226*cdf0e10cSrcweir 			case SID_ATTR_LINE_COLOR:
227*cdf0e10cSrcweir 				pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
228*cdf0e10cSrcweir 				break;
229*cdf0e10cSrcweir 		}
230*cdf0e10cSrcweir 	}
231*cdf0e10cSrcweir 	if (pView->GetModel()->IsChanged())
232*cdf0e10cSrcweir 		GetShell().SetModified();
233*cdf0e10cSrcweir 	else
234*cdf0e10cSrcweir 		if (bChanged)
235*cdf0e10cSrcweir 			pView->GetModel()->SetChanged(sal_True);
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir /*--------------------------------------------------------------------
239*cdf0e10cSrcweir 	Beschreibung:
240*cdf0e10cSrcweir  --------------------------------------------------------------------*/
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	SdrView* pSdrView = GetShell().GetDrawView();
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 	if (pSdrView->AreObjectsMarked())
248*cdf0e10cSrcweir 	{
249*cdf0e10cSrcweir 		sal_Bool bDisable = Disable( rSet );
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 		if( !bDisable )
252*cdf0e10cSrcweir 			pSdrView->GetAttributes( rSet );
253*cdf0e10cSrcweir 	}
254*cdf0e10cSrcweir 	else
255*cdf0e10cSrcweir 		rSet.Put(pSdrView->GetDefaultAttr());
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 
260