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