merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / shells / drawdlg.cxx
blob3d3b4e688aa44c7449fb980bca50df7eb3f43bcd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawdlg.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
38 #ifndef _SVX_SVXIDS_HRC //autogen
39 #include <svx/svxids.hrc>
40 #endif
41 #ifndef _MSGBOX_HXX //autogen
42 #include <vcl/msgbox.hxx>
43 #endif
44 #include <sfx2/request.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <svx/svdview.hxx>
47 #include <svx/tabarea.hxx>
48 #include <svx/tabline.hxx>
49 #include <svx/drawitem.hxx>
51 #include <svx/xtable.hxx>
52 #include "view.hxx"
53 #include "wrtsh.hxx"
54 #include "docsh.hxx"
55 #include "cmdid.h"
57 #include "drawsh.hxx"
58 #include <svx/svxdlg.hxx>
59 #include <svx/dialogs.hrc>
61 /*--------------------------------------------------------------------
62 Beschreibung:
63 --------------------------------------------------------------------*/
66 void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
68 SwWrtShell* pSh = &GetShell();
69 SdrView* pView = pSh->GetDrawView();
70 SdrModel* pDoc = pView->GetModel();
71 BOOL bChanged = pDoc->IsChanged();
72 pDoc->SetChanged(FALSE);
74 SfxItemSet aNewAttr( pDoc->GetItemPool() );
75 pView->GetAttributes( aNewAttr );
77 GetView().NoRotate();
79 switch (rReq.GetSlot())
81 case FN_DRAWTEXT_ATTR_DLG:
83 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
84 if ( pFact )
86 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, RID_SVXDLG_TEXT, pView );
87 USHORT nResult = pDlg->Execute();
89 if (nResult == RET_OK)
91 if (pView->AreObjectsMarked())
93 pSh->StartAction();
94 pView->SetAttributes(*pDlg->GetOutputItemSet());
95 rReq.Done(*(pDlg->GetOutputItemSet()));
96 pSh->EndAction();
100 delete( pDlg );
103 break;
105 case SID_ATTRIBUTES_AREA:
107 BOOL bHasMarked = pView->AreObjectsMarked();
109 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
110 DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
111 AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL,
112 &aNewAttr,
113 pDoc,
114 RID_SVXDLG_AREA,
115 pView);
116 DBG_ASSERT(pDlg, "Dialogdiet fail!");
117 const SvxColorTableItem* pColorItem = (const SvxColorTableItem*)
118 GetView().GetDocShell()->GetItem(SID_COLOR_TABLE);
119 if(pColorItem->GetColorTable() == XColorTable::GetStdColorTable())
120 pDlg->DontDeleteColorTable();
121 if (pDlg->Execute() == RET_OK)
123 pSh->StartAction();
124 if (bHasMarked)
125 pView->SetAttributes(*pDlg->GetOutputItemSet());
126 else
127 pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), FALSE);
128 pSh->EndAction();
130 static USHORT __READONLY_DATA aInval[] =
132 SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, 0
134 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
135 rBnd.Invalidate(aInval);
136 rBnd.Update(SID_ATTR_FILL_STYLE);
137 rBnd.Update(SID_ATTR_FILL_COLOR);
139 delete pDlg;
141 break;
143 case SID_ATTRIBUTES_LINE:
145 BOOL bHasMarked = pView->AreObjectsMarked();
147 const SdrObject* pObj = NULL;
148 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
149 if( rMarkList.GetMarkCount() == 1 )
150 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
152 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
153 DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
154 SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
155 &aNewAttr,
156 pDoc,
157 RID_SVXDLG_LINE,
158 pObj,
159 bHasMarked);
160 DBG_ASSERT(pDlg, "Dialogdiet fail!");
161 if (pDlg->Execute() == RET_OK)
163 pSh->StartAction();
164 if(bHasMarked)
165 pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), FALSE);
166 else
167 pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), FALSE);
168 pSh->EndAction();
170 static USHORT __READONLY_DATA aInval[] =
172 SID_ATTR_LINE_STYLE, SID_ATTR_LINE_WIDTH,
173 SID_ATTR_LINE_COLOR, 0
176 GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
178 delete pDlg;
180 break;
182 default:
183 break;
187 if (pDoc->IsChanged())
188 GetShell().SetModified();
189 else
190 if (bChanged)
191 pDoc->SetChanged(TRUE);
194 /*--------------------------------------------------------------------
195 Beschreibung:
196 --------------------------------------------------------------------*/
199 void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
201 SwWrtShell* pSh = &GetShell();
202 SdrView* pView = pSh->GetDrawView();
203 const SfxItemSet* pArgs = rReq.GetArgs();
204 BOOL bChanged = pView->GetModel()->IsChanged();
205 pView->GetModel()->SetChanged(FALSE);
207 GetView().NoRotate();
209 if (pArgs)
211 if(pView->AreObjectsMarked())
212 pView->SetAttrToMarked(*rReq.GetArgs(), FALSE);
213 else
214 pView->SetDefaultAttr(*rReq.GetArgs(), FALSE);
216 else
218 SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
219 switch (rReq.GetSlot())
221 case SID_ATTR_FILL_STYLE:
222 case SID_ATTR_FILL_COLOR:
223 case SID_ATTR_FILL_GRADIENT:
224 case SID_ATTR_FILL_HATCH:
225 case SID_ATTR_FILL_BITMAP:
226 pDis->Execute(SID_ATTRIBUTES_AREA, FALSE);
227 break;
228 case SID_ATTR_LINE_STYLE:
229 case SID_ATTR_LINE_DASH:
230 case SID_ATTR_LINE_WIDTH:
231 case SID_ATTR_LINE_COLOR:
232 pDis->Execute(SID_ATTRIBUTES_LINE, FALSE);
233 break;
236 if (pView->GetModel()->IsChanged())
237 GetShell().SetModified();
238 else
239 if (bChanged)
240 pView->GetModel()->SetChanged(TRUE);
243 /*--------------------------------------------------------------------
244 Beschreibung:
245 --------------------------------------------------------------------*/
248 void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
250 SdrView* pSdrView = GetShell().GetDrawView();
252 if (pSdrView->AreObjectsMarked())
254 BOOL bDisable = Disable( rSet );
256 if( !bDisable )
257 pSdrView->GetAttributes( rSet );
259 else
260 rSet.Put(pSdrView->GetDefaultAttr());