xref: /aoo42x/main/sw/source/ui/shells/drawdlg.cxx (revision 64b14621)
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 
ExecDrawDlg(SfxRequest & rReq)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(
105                 NULL,
106                 &aNewAttr,
107                 pDoc,
108                 true);
109             DBG_ASSERT(pDlg, "Dialogdiet fail!");
110 			// const SvxColorTableItem* pColorItem = (const SvxColorTableItem*)
111 									GetView().GetDocShell()->GetItem(SID_COLOR_TABLE);
112 
113             if (pDlg->Execute() == RET_OK)
114 			{
115                 pSh->StartAction();
116                 if (bHasMarked)
117 					pView->SetAttributes(*pDlg->GetOutputItemSet());
118 				else
119 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
120                 pSh->EndAction();
121 
122 				static sal_uInt16 __READONLY_DATA aInval[] =
123 				{
124 					SID_ATTR_FILL_STYLE,
125                     SID_ATTR_FILL_COLOR,
126                     SID_ATTR_FILL_TRANSPARENCE,
127                     SID_ATTR_FILL_FLOATTRANSPARENCE,
128                     0
129 				};
130 				SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
131 				rBnd.Invalidate(aInval);
132 				rBnd.Update(SID_ATTR_FILL_STYLE);
133 				rBnd.Update(SID_ATTR_FILL_COLOR);
134 				rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
135 				rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
136 			}
137 			delete pDlg;
138 		}
139 		break;
140 
141 		case SID_ATTRIBUTES_LINE:
142 		{
143 			sal_Bool bHasMarked = pView->AreObjectsMarked();
144 
145 			const SdrObject* pObj = NULL;
146 			const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
147 			if( rMarkList.GetMarkCount() == 1 )
148 				pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
149 
150 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
151             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
152 			SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
153 					&aNewAttr,
154 				pDoc,
155 				pObj,
156 				bHasMarked);
157             DBG_ASSERT(pDlg, "Dialogdiet fail!");
158 			if (pDlg->Execute() == RET_OK)
159 			{
160                 pSh->StartAction();
161                 if(bHasMarked)
162 					pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
163 				else
164 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
165                 pSh->EndAction();
166 
167 				static sal_uInt16 __READONLY_DATA aInval[] =
168 				{
169                     SID_ATTR_LINE_STYLE,                // ( SID_SVX_START + 169 )
170                     SID_ATTR_LINE_DASH,                 // ( SID_SVX_START + 170 )
171                     SID_ATTR_LINE_WIDTH,                // ( SID_SVX_START + 171 )
172                     SID_ATTR_LINE_COLOR,                // ( SID_SVX_START + 172 )
173                     SID_ATTR_LINE_START,                // ( SID_SVX_START + 173 )
174                     SID_ATTR_LINE_END,                  // ( SID_SVX_START + 174 )
175                     SID_ATTR_LINE_TRANSPARENCE,         // (SID_SVX_START+1107)
176                     SID_ATTR_LINE_JOINT,                // (SID_SVX_START+1110)
177                     SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
178                     0
179 				};
180 
181 				GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
182 			}
183 			delete pDlg;
184 		}
185 		break;
186 
187 		default:
188 			break;
189 	}
190 
191 
192 	if (pDoc->IsChanged())
193 		GetShell().SetModified();
194 	else
195 		if (bChanged)
196 			pDoc->SetChanged(sal_True);
197 }
198 
199 /*--------------------------------------------------------------------
200 	Beschreibung:
201  --------------------------------------------------------------------*/
202 
203 
ExecDrawAttrArgs(SfxRequest & rReq)204 void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
205 {
206 	SwWrtShell* pSh   = &GetShell();
207 	SdrView*	pView = pSh->GetDrawView();
208 	const SfxItemSet* pArgs = rReq.GetArgs();
209 	sal_Bool 		bChanged = pView->GetModel()->IsChanged();
210 	pView->GetModel()->SetChanged(sal_False);
211 
212 	GetView().NoRotate();
213 
214 	if (pArgs)
215 	{
216 		if(pView->AreObjectsMarked())
217 			pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
218 		else
219 			pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
220 	}
221 	else
222 	{
223 		SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
224 		switch (rReq.GetSlot())
225 		{
226 			case SID_ATTR_FILL_STYLE:
227 			case SID_ATTR_FILL_COLOR:
228 			case SID_ATTR_FILL_GRADIENT:
229 			case SID_ATTR_FILL_HATCH:
230 			case SID_ATTR_FILL_BITMAP:
231 			case SID_ATTR_FILL_TRANSPARENCE:
232 			case SID_ATTR_FILL_FLOATTRANSPARENCE:
233 				pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
234 				break;
235 			case SID_ATTR_LINE_STYLE:
236 			case SID_ATTR_LINE_DASH:
237 			case SID_ATTR_LINE_WIDTH:
238 			case SID_ATTR_LINE_COLOR:
239             case SID_ATTR_LINE_TRANSPARENCE:
240             case SID_ATTR_LINE_JOINT:
241             case SID_ATTR_LINE_CAP:
242 				pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
243 				break;
244 		}
245 	}
246 	if (pView->GetModel()->IsChanged())
247 		GetShell().SetModified();
248 	else
249 		if (bChanged)
250 			pView->GetModel()->SetChanged(sal_True);
251 }
252 
253 /*--------------------------------------------------------------------
254 	Beschreibung:
255  --------------------------------------------------------------------*/
256 
257 
GetDrawAttrState(SfxItemSet & rSet)258 void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
259 {
260 	SdrView* pSdrView = GetShell().GetDrawView();
261 
262 	if (pSdrView->AreObjectsMarked())
263 	{
264 		sal_Bool bDisable = Disable( rSet );
265 
266 		if( !bDisable )
267 			pSdrView->GetAttributes( rSet );
268 	}
269 	else
270 		rSet.Put(pSdrView->GetDefaultAttr());
271 }
272 
273 
274 
275