xref: /AOO41X/main/sw/source/ui/shells/drawdlg.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew 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);
111cdf0e10cSrcweir 			if(pColorItem->GetColorTable() == XColorTable::GetStdColorTable())
112cdf0e10cSrcweir 				pDlg->DontDeleteColorTable();
113cdf0e10cSrcweir 			if (pDlg->Execute() == RET_OK)
114cdf0e10cSrcweir 			{
115cdf0e10cSrcweir                 pSh->StartAction();
116cdf0e10cSrcweir                 if (bHasMarked)
117cdf0e10cSrcweir 					pView->SetAttributes(*pDlg->GetOutputItemSet());
118cdf0e10cSrcweir 				else
119cdf0e10cSrcweir 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
120cdf0e10cSrcweir                 pSh->EndAction();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 				static sal_uInt16 __READONLY_DATA aInval[] =
123cdf0e10cSrcweir 				{
124cdf0e10cSrcweir 					SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, 0
125cdf0e10cSrcweir 				};
126cdf0e10cSrcweir 				SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
127cdf0e10cSrcweir 				rBnd.Invalidate(aInval);
128cdf0e10cSrcweir 				rBnd.Update(SID_ATTR_FILL_STYLE);
129cdf0e10cSrcweir 				rBnd.Update(SID_ATTR_FILL_COLOR);
130cdf0e10cSrcweir 			}
131cdf0e10cSrcweir 			delete pDlg;
132cdf0e10cSrcweir 		}
133cdf0e10cSrcweir 		break;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		case SID_ATTRIBUTES_LINE:
136cdf0e10cSrcweir 		{
137cdf0e10cSrcweir 			sal_Bool bHasMarked = pView->AreObjectsMarked();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 			const SdrObject* pObj = NULL;
140cdf0e10cSrcweir 			const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
141cdf0e10cSrcweir 			if( rMarkList.GetMarkCount() == 1 )
142cdf0e10cSrcweir 				pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 			SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
145cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
146cdf0e10cSrcweir 			SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
147cdf0e10cSrcweir 					&aNewAttr,
148cdf0e10cSrcweir 				pDoc,
149cdf0e10cSrcweir 				pObj,
150cdf0e10cSrcweir 				bHasMarked);
151cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
152cdf0e10cSrcweir 			if (pDlg->Execute() == RET_OK)
153cdf0e10cSrcweir 			{
154cdf0e10cSrcweir                 pSh->StartAction();
155cdf0e10cSrcweir                 if(bHasMarked)
156cdf0e10cSrcweir 					pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
157cdf0e10cSrcweir 				else
158cdf0e10cSrcweir 					pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
159cdf0e10cSrcweir                 pSh->EndAction();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 				static sal_uInt16 __READONLY_DATA aInval[] =
162cdf0e10cSrcweir 				{
163cdf0e10cSrcweir 					SID_ATTR_LINE_STYLE, SID_ATTR_LINE_WIDTH,
164cdf0e10cSrcweir 					SID_ATTR_LINE_COLOR, 0
165cdf0e10cSrcweir 				};
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 				GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
168cdf0e10cSrcweir 			}
169cdf0e10cSrcweir 			delete pDlg;
170cdf0e10cSrcweir 		}
171cdf0e10cSrcweir 		break;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 		default:
174cdf0e10cSrcweir 			break;
175cdf0e10cSrcweir 	}
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	if (pDoc->IsChanged())
179cdf0e10cSrcweir 		GetShell().SetModified();
180cdf0e10cSrcweir 	else
181cdf0e10cSrcweir 		if (bChanged)
182cdf0e10cSrcweir 			pDoc->SetChanged(sal_True);
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir /*--------------------------------------------------------------------
186cdf0e10cSrcweir 	Beschreibung:
187cdf0e10cSrcweir  --------------------------------------------------------------------*/
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 
190cdf0e10cSrcweir void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	SwWrtShell* pSh   = &GetShell();
193cdf0e10cSrcweir 	SdrView*	pView = pSh->GetDrawView();
194cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
195cdf0e10cSrcweir 	sal_Bool 		bChanged = pView->GetModel()->IsChanged();
196cdf0e10cSrcweir 	pView->GetModel()->SetChanged(sal_False);
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	GetView().NoRotate();
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	if (pArgs)
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir 		if(pView->AreObjectsMarked())
203cdf0e10cSrcweir 			pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
204cdf0e10cSrcweir 		else
205cdf0e10cSrcweir 			pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
206cdf0e10cSrcweir 	}
207cdf0e10cSrcweir 	else
208cdf0e10cSrcweir 	{
209cdf0e10cSrcweir 		SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
210cdf0e10cSrcweir 		switch (rReq.GetSlot())
211cdf0e10cSrcweir 		{
212cdf0e10cSrcweir 			case SID_ATTR_FILL_STYLE:
213cdf0e10cSrcweir 			case SID_ATTR_FILL_COLOR:
214cdf0e10cSrcweir 			case SID_ATTR_FILL_GRADIENT:
215cdf0e10cSrcweir 			case SID_ATTR_FILL_HATCH:
216cdf0e10cSrcweir 			case SID_ATTR_FILL_BITMAP:
217cdf0e10cSrcweir 				pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
218cdf0e10cSrcweir 				break;
219cdf0e10cSrcweir 			case SID_ATTR_LINE_STYLE:
220cdf0e10cSrcweir 			case SID_ATTR_LINE_DASH:
221cdf0e10cSrcweir 			case SID_ATTR_LINE_WIDTH:
222cdf0e10cSrcweir 			case SID_ATTR_LINE_COLOR:
223cdf0e10cSrcweir 				pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
224cdf0e10cSrcweir 				break;
225cdf0e10cSrcweir 		}
226cdf0e10cSrcweir 	}
227cdf0e10cSrcweir 	if (pView->GetModel()->IsChanged())
228cdf0e10cSrcweir 		GetShell().SetModified();
229cdf0e10cSrcweir 	else
230cdf0e10cSrcweir 		if (bChanged)
231cdf0e10cSrcweir 			pView->GetModel()->SetChanged(sal_True);
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir /*--------------------------------------------------------------------
235cdf0e10cSrcweir 	Beschreibung:
236cdf0e10cSrcweir  --------------------------------------------------------------------*/
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
239cdf0e10cSrcweir void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	SdrView* pSdrView = GetShell().GetDrawView();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	if (pSdrView->AreObjectsMarked())
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		sal_Bool bDisable = Disable( rSet );
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 		if( !bDisable )
248cdf0e10cSrcweir 			pSdrView->GetAttributes( rSet );
249cdf0e10cSrcweir 	}
250cdf0e10cSrcweir 	else
251cdf0e10cSrcweir 		rSet.Put(pSdrView->GetDefaultAttr());
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 
256