1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawdlg.cxx,v $
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>
41 #ifndef _MSGBOX_HXX //autogen
42 #include <vcl/msgbox.hxx>
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>
58 #include <svx/svxdlg.hxx>
59 #include <svx/dialogs.hrc>
61 /*--------------------------------------------------------------------
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
);
79 switch (rReq
.GetSlot())
81 case FN_DRAWTEXT_ATTR_DLG
:
83 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
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())
94 pView
->SetAttributes(*pDlg
->GetOutputItemSet());
95 rReq
.Done(*(pDlg
->GetOutputItemSet()));
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
,
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
)
125 pView
->SetAttributes(*pDlg
->GetOutputItemSet());
127 pView
->SetDefaultAttr(*pDlg
->GetOutputItemSet(), FALSE
);
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
);
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
,
160 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
161 if (pDlg
->Execute() == RET_OK
)
165 pView
->SetAttrToMarked(*pDlg
->GetOutputItemSet(), FALSE
);
167 pView
->SetDefaultAttr(*pDlg
->GetOutputItemSet(), FALSE
);
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
);
187 if (pDoc
->IsChanged())
188 GetShell().SetModified();
191 pDoc
->SetChanged(TRUE
);
194 /*--------------------------------------------------------------------
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();
211 if(pView
->AreObjectsMarked())
212 pView
->SetAttrToMarked(*rReq
.GetArgs(), FALSE
);
214 pView
->SetDefaultAttr(*rReq
.GetArgs(), FALSE
);
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
);
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
);
236 if (pView
->GetModel()->IsChanged())
237 GetShell().SetModified();
240 pView
->GetModel()->SetChanged(TRUE
);
243 /*--------------------------------------------------------------------
245 --------------------------------------------------------------------*/
248 void SwDrawShell::GetDrawAttrState(SfxItemSet
& rSet
)
250 SdrView
* pSdrView
= GetShell().GetDrawView();
252 if (pSdrView
->AreObjectsMarked())
254 BOOL bDisable
= Disable( rSet
);
257 pSdrView
->GetAttributes( rSet
);
260 rSet
.Put(pSdrView
->GetDefaultAttr());