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