xref: /trunk/main/sw/source/ui/shells/drawdlg.cxx (revision c7be74b1)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC //autogen
32cdf0e10cSrcweir #include <svx/svxids.hrc>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
35cdf0e10cSrcweir #include <vcl/msgbox.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <sfx2/request.hxx>
38cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
39cdf0e10cSrcweir #include <svx/svdview.hxx>
40cdf0e10cSrcweir #include <svx/tabarea.hxx>
41cdf0e10cSrcweir #include <svx/tabline.hxx>
42cdf0e10cSrcweir #include <svx/drawitem.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <svx/xtable.hxx>
45cdf0e10cSrcweir #include "view.hxx"
46cdf0e10cSrcweir #include "wrtsh.hxx"
47cdf0e10cSrcweir #include "docsh.hxx"
48cdf0e10cSrcweir #include "cmdid.h"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include "drawsh.hxx"
51cdf0e10cSrcweir #include <svx/svxdlg.hxx>
52cdf0e10cSrcweir #include <svx/dialogs.hrc>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /*--------------------------------------------------------------------
55cdf0e10cSrcweir 	Beschreibung:
56cdf0e10cSrcweir  --------------------------------------------------------------------*/
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	SwWrtShell* 	pSh 	= &GetShell();
62cdf0e10cSrcweir 	SdrView*		pView	= pSh->GetDrawView();
63cdf0e10cSrcweir 	SdrModel*		pDoc	= pView->GetModel();
64cdf0e10cSrcweir 	sal_Bool			bChanged = pDoc->IsChanged();
65cdf0e10cSrcweir 	pDoc->SetChanged(sal_False);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	SfxItemSet aNewAttr( pDoc->GetItemPool() );
68cdf0e10cSrcweir 	pView->GetAttributes( aNewAttr );
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	GetView().NoRotate();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	switch (rReq.GetSlot())
73cdf0e10cSrcweir 	{
74cdf0e10cSrcweir 		case FN_DRAWTEXT_ATTR_DLG:
75cdf0e10cSrcweir 		{
76cdf0e10cSrcweir 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
77cdf0e10cSrcweir 			if ( pFact )
78cdf0e10cSrcweir 			{
79cdf0e10cSrcweir 				SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView );
80cdf0e10cSrcweir 				sal_uInt16 nResult = pDlg->Execute();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 				if (nResult == RET_OK)
83cdf0e10cSrcweir 				{
84cdf0e10cSrcweir 	                if (pView->AreObjectsMarked())
85cdf0e10cSrcweir 	                {
86cdf0e10cSrcweir 	                    pSh->StartAction();
87cdf0e10cSrcweir 	                    pView->SetAttributes(*pDlg->GetOutputItemSet());
88cdf0e10cSrcweir 	                    rReq.Done(*(pDlg->GetOutputItemSet()));
89cdf0e10cSrcweir 	                    pSh->EndAction();
90cdf0e10cSrcweir 	                }
91cdf0e10cSrcweir 	            }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 				delete( pDlg );
94cdf0e10cSrcweir 			}
95cdf0e10cSrcweir 		}
96cdf0e10cSrcweir 		break;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		case SID_ATTRIBUTES_AREA:
99cdf0e10cSrcweir 		{
100cdf0e10cSrcweir 			sal_Bool bHasMarked = pView->AreObjectsMarked();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
103cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
104cdf0e10cSrcweir 			AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL,
105cdf0e10cSrcweir 																			&aNewAttr,
106cdf0e10cSrcweir 																			pDoc,
107cdf0e10cSrcweir 																			pView);
108cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
109cdf0e10cSrcweir 			const SvxColorTableItem* pColorItem = (const SvxColorTableItem*)
110cdf0e10cSrcweir 									GetView().GetDocShell()->GetItem(SID_COLOR_TABLE);
111*c7be74b1SArmin Le Grand 
112*c7be74b1SArmin Le Grand             if (pDlg->Execute() == RET_OK)
113cdf0e10cSrcweir 			{
114cdf0e10cSrcweir                 pSh->StartAction();
115cdf0e10cSrcweir                 if (bHasMarked)
116cdf0e10cSrcweir 					pView->SetAttributes(*pDlg->GetOutputItemSet());
117cdf0e10cSrcweir 				else
118cdf0e10cSrcweir 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
119cdf0e10cSrcweir                 pSh->EndAction();
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 				static sal_uInt16 __READONLY_DATA aInval[] =
122cdf0e10cSrcweir 				{
123d5370dc8SArmin Le Grand 					SID_ATTR_FILL_STYLE,
124d5370dc8SArmin Le Grand                     SID_ATTR_FILL_COLOR,
125d5370dc8SArmin Le Grand                     SID_ATTR_FILL_TRANSPARENCE,
126d5370dc8SArmin Le Grand                     SID_ATTR_FILL_FLOATTRANSPARENCE,
127d5370dc8SArmin Le Grand                     0
128cdf0e10cSrcweir 				};
129cdf0e10cSrcweir 				SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
130cdf0e10cSrcweir 				rBnd.Invalidate(aInval);
131cdf0e10cSrcweir 				rBnd.Update(SID_ATTR_FILL_STYLE);
132cdf0e10cSrcweir 				rBnd.Update(SID_ATTR_FILL_COLOR);
133d5370dc8SArmin Le Grand 				rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
134d5370dc8SArmin Le Grand 				rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
135cdf0e10cSrcweir 			}
136cdf0e10cSrcweir 			delete pDlg;
137cdf0e10cSrcweir 		}
138cdf0e10cSrcweir 		break;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 		case SID_ATTRIBUTES_LINE:
141cdf0e10cSrcweir 		{
142cdf0e10cSrcweir 			sal_Bool bHasMarked = pView->AreObjectsMarked();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 			const SdrObject* pObj = NULL;
145cdf0e10cSrcweir 			const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
146cdf0e10cSrcweir 			if( rMarkList.GetMarkCount() == 1 )
147cdf0e10cSrcweir 				pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
150cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
151cdf0e10cSrcweir 			SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
152cdf0e10cSrcweir 					&aNewAttr,
153cdf0e10cSrcweir 				pDoc,
154cdf0e10cSrcweir 				pObj,
155cdf0e10cSrcweir 				bHasMarked);
156cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
157cdf0e10cSrcweir 			if (pDlg->Execute() == RET_OK)
158cdf0e10cSrcweir 			{
159cdf0e10cSrcweir                 pSh->StartAction();
160cdf0e10cSrcweir                 if(bHasMarked)
161cdf0e10cSrcweir 					pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
162cdf0e10cSrcweir 				else
163cdf0e10cSrcweir 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
164cdf0e10cSrcweir                 pSh->EndAction();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 				static sal_uInt16 __READONLY_DATA aInval[] =
167cdf0e10cSrcweir 				{
168d5370dc8SArmin Le Grand                     SID_ATTR_LINE_STYLE,                // ( SID_SVX_START + 169 )
169d5370dc8SArmin Le Grand                     SID_ATTR_LINE_DASH,                 // ( SID_SVX_START + 170 )
170d5370dc8SArmin Le Grand                     SID_ATTR_LINE_WIDTH,                // ( SID_SVX_START + 171 )
171d5370dc8SArmin Le Grand                     SID_ATTR_LINE_COLOR,                // ( SID_SVX_START + 172 )
172d5370dc8SArmin Le Grand                     SID_ATTR_LINE_START,                // ( SID_SVX_START + 173 )
173d5370dc8SArmin Le Grand                     SID_ATTR_LINE_END,                  // ( SID_SVX_START + 174 )
174d5370dc8SArmin Le Grand                     SID_ATTR_LINE_TRANSPARENCE,         // (SID_SVX_START+1107)
175d5370dc8SArmin Le Grand                     SID_ATTR_LINE_JOINT,                // (SID_SVX_START+1110)
176d5370dc8SArmin Le Grand                     SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
177d5370dc8SArmin Le Grand                     0
178cdf0e10cSrcweir 				};
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 				GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
181cdf0e10cSrcweir 			}
182cdf0e10cSrcweir 			delete pDlg;
183cdf0e10cSrcweir 		}
184cdf0e10cSrcweir 		break;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 		default:
187cdf0e10cSrcweir 			break;
188cdf0e10cSrcweir 	}
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	if (pDoc->IsChanged())
192cdf0e10cSrcweir 		GetShell().SetModified();
193cdf0e10cSrcweir 	else
194cdf0e10cSrcweir 		if (bChanged)
195cdf0e10cSrcweir 			pDoc->SetChanged(sal_True);
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir /*--------------------------------------------------------------------
199cdf0e10cSrcweir 	Beschreibung:
200cdf0e10cSrcweir  --------------------------------------------------------------------*/
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
203cdf0e10cSrcweir void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	SwWrtShell* pSh   = &GetShell();
206cdf0e10cSrcweir 	SdrView*	pView = pSh->GetDrawView();
207cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
208cdf0e10cSrcweir 	sal_Bool 		bChanged = pView->GetModel()->IsChanged();
209cdf0e10cSrcweir 	pView->GetModel()->SetChanged(sal_False);
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	GetView().NoRotate();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	if (pArgs)
214cdf0e10cSrcweir 	{
215cdf0e10cSrcweir 		if(pView->AreObjectsMarked())
216cdf0e10cSrcweir 			pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
217cdf0e10cSrcweir 		else
218cdf0e10cSrcweir 			pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
219cdf0e10cSrcweir 	}
220cdf0e10cSrcweir 	else
221cdf0e10cSrcweir 	{
222cdf0e10cSrcweir 		SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
223cdf0e10cSrcweir 		switch (rReq.GetSlot())
224cdf0e10cSrcweir 		{
225cdf0e10cSrcweir 			case SID_ATTR_FILL_STYLE:
226cdf0e10cSrcweir 			case SID_ATTR_FILL_COLOR:
227cdf0e10cSrcweir 			case SID_ATTR_FILL_GRADIENT:
228cdf0e10cSrcweir 			case SID_ATTR_FILL_HATCH:
229cdf0e10cSrcweir 			case SID_ATTR_FILL_BITMAP:
230d5370dc8SArmin Le Grand 			case SID_ATTR_FILL_TRANSPARENCE:
231d5370dc8SArmin Le Grand 			case SID_ATTR_FILL_FLOATTRANSPARENCE:
232cdf0e10cSrcweir 				pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
233cdf0e10cSrcweir 				break;
234cdf0e10cSrcweir 			case SID_ATTR_LINE_STYLE:
235cdf0e10cSrcweir 			case SID_ATTR_LINE_DASH:
236cdf0e10cSrcweir 			case SID_ATTR_LINE_WIDTH:
237cdf0e10cSrcweir 			case SID_ATTR_LINE_COLOR:
238d5370dc8SArmin Le Grand             case SID_ATTR_LINE_TRANSPARENCE:
239d5370dc8SArmin Le Grand             case SID_ATTR_LINE_JOINT:
240d5370dc8SArmin Le Grand             case SID_ATTR_LINE_CAP:
241cdf0e10cSrcweir 				pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
242cdf0e10cSrcweir 				break;
243cdf0e10cSrcweir 		}
244cdf0e10cSrcweir 	}
245cdf0e10cSrcweir 	if (pView->GetModel()->IsChanged())
246cdf0e10cSrcweir 		GetShell().SetModified();
247cdf0e10cSrcweir 	else
248cdf0e10cSrcweir 		if (bChanged)
249cdf0e10cSrcweir 			pView->GetModel()->SetChanged(sal_True);
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir /*--------------------------------------------------------------------
253cdf0e10cSrcweir 	Beschreibung:
254cdf0e10cSrcweir  --------------------------------------------------------------------*/
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 
257cdf0e10cSrcweir void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
258cdf0e10cSrcweir {
259cdf0e10cSrcweir 	SdrView* pSdrView = GetShell().GetDrawView();
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	if (pSdrView->AreObjectsMarked())
262cdf0e10cSrcweir 	{
263cdf0e10cSrcweir 		sal_Bool bDisable = Disable( rSet );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 		if( !bDisable )
266cdf0e10cSrcweir 			pSdrView->GetAttributes( rSet );
267cdf0e10cSrcweir 	}
268cdf0e10cSrcweir 	else
269cdf0e10cSrcweir 		rSet.Put(pSdrView->GetDefaultAttr());
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 
274