1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/svxids.hrc>
21 #include <vcl/msgbox.hxx>
22 #include <sfx2/request.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/drawitem.hxx>
27 #include <svx/xtable.hxx>
34 #include <svx/svxdlg.hxx>
35 #include <svx/dialogs.hrc>
37 void SwDrawShell::ExecDrawDlg(SfxRequest
& rReq
)
39 SwWrtShell
* pSh
= &GetShell();
40 SdrView
* pView
= pSh
->GetDrawView();
41 SdrModel
* pDoc
= pView
->GetModel();
42 sal_Bool bChanged
= pDoc
->IsChanged();
43 pDoc
->SetChanged(sal_False
);
45 SfxItemSet
aNewAttr( pDoc
->GetItemPool() );
46 pView
->GetAttributes( aNewAttr
);
50 switch (rReq
.GetSlot())
52 case FN_DRAWTEXT_ATTR_DLG
:
54 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
57 SfxAbstractTabDialog
*pDlg
= pFact
->CreateTextTabDialog( NULL
, &aNewAttr
, pView
);
58 sal_uInt16 nResult
= pDlg
->Execute();
60 if (nResult
== RET_OK
)
62 if (pView
->AreObjectsMarked())
65 pView
->SetAttributes(*pDlg
->GetOutputItemSet());
66 rReq
.Done(*(pDlg
->GetOutputItemSet()));
76 case SID_ATTRIBUTES_AREA
:
78 sal_Bool bHasMarked
= pView
->AreObjectsMarked();
80 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
81 AbstractSvxAreaTabDialog
* pDlg
= pFact
->CreateSvxAreaTabDialog( NULL
,
85 if (pDlg
->Execute() == RET_OK
)
89 pView
->SetAttributes(*pDlg
->GetOutputItemSet());
91 pView
->SetDefaultAttr(*pDlg
->GetOutputItemSet(), sal_False
);
94 static sal_uInt16 aInval
[] =
98 SID_ATTR_FILL_TRANSPARENCE
,
99 SID_ATTR_FILL_FLOATTRANSPARENCE
,
102 SfxBindings
&rBnd
= GetView().GetViewFrame()->GetBindings();
103 rBnd
.Invalidate(aInval
);
104 rBnd
.Update(SID_ATTR_FILL_STYLE
);
105 rBnd
.Update(SID_ATTR_FILL_COLOR
);
106 rBnd
.Update(SID_ATTR_FILL_TRANSPARENCE
);
107 rBnd
.Update(SID_ATTR_FILL_FLOATTRANSPARENCE
);
113 case SID_ATTRIBUTES_LINE
:
115 sal_Bool bHasMarked
= pView
->AreObjectsMarked();
117 const SdrObject
* pObj
= NULL
;
118 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
119 if( rMarkList
.GetMarkCount() == 1 )
120 pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
122 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
123 OSL_ENSURE(pFact
, "Dialogdiet Factory fail!");
124 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSvxLineTabDialog( NULL
,
129 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
130 if (pDlg
->Execute() == RET_OK
)
134 pView
->SetAttrToMarked(*pDlg
->GetOutputItemSet(), sal_False
);
136 pView
->SetDefaultAttr(*pDlg
->GetOutputItemSet(), sal_False
);
139 static sal_uInt16 aInval
[] =
141 SID_ATTR_LINE_STYLE
, // ( SID_SVX_START + 169 )
142 SID_ATTR_LINE_DASH
, // ( SID_SVX_START + 170 )
143 SID_ATTR_LINE_WIDTH
, // ( SID_SVX_START + 171 )
144 SID_ATTR_LINE_COLOR
, // ( SID_SVX_START + 172 )
145 SID_ATTR_LINE_START
, // ( SID_SVX_START + 173 )
146 SID_ATTR_LINE_END
, // ( SID_SVX_START + 174 )
147 SID_ATTR_LINE_TRANSPARENCE
, // (SID_SVX_START+1107)
148 SID_ATTR_LINE_JOINT
, // (SID_SVX_START+1110)
149 SID_ATTR_LINE_CAP
, // (SID_SVX_START+1111)
153 GetView().GetViewFrame()->GetBindings().Invalidate(aInval
);
164 if (pDoc
->IsChanged())
165 GetShell().SetModified();
168 pDoc
->SetChanged(sal_True
);
171 void SwDrawShell::ExecDrawAttrArgs(SfxRequest
& rReq
)
173 SwWrtShell
* pSh
= &GetShell();
174 SdrView
* pView
= pSh
->GetDrawView();
175 const SfxItemSet
* pArgs
= rReq
.GetArgs();
176 sal_Bool bChanged
= pView
->GetModel()->IsChanged();
177 pView
->GetModel()->SetChanged(sal_False
);
179 GetView().NoRotate();
183 if(pView
->AreObjectsMarked())
184 pView
->SetAttrToMarked(*rReq
.GetArgs(), sal_False
);
186 pView
->SetDefaultAttr(*rReq
.GetArgs(), sal_False
);
190 SfxDispatcher
* pDis
= pSh
->GetView().GetViewFrame()->GetDispatcher();
191 switch (rReq
.GetSlot())
193 case SID_ATTR_FILL_STYLE
:
194 case SID_ATTR_FILL_COLOR
:
195 case SID_ATTR_FILL_GRADIENT
:
196 case SID_ATTR_FILL_HATCH
:
197 case SID_ATTR_FILL_BITMAP
:
198 case SID_ATTR_FILL_TRANSPARENCE
:
199 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
200 pDis
->Execute(SID_ATTRIBUTES_AREA
, sal_False
);
202 case SID_ATTR_LINE_STYLE
:
203 case SID_ATTR_LINE_DASH
:
204 case SID_ATTR_LINE_WIDTH
:
205 case SID_ATTR_LINE_COLOR
:
206 case SID_ATTR_LINE_TRANSPARENCE
:
207 case SID_ATTR_LINE_JOINT
:
208 case SID_ATTR_LINE_CAP
:
209 pDis
->Execute(SID_ATTRIBUTES_LINE
, sal_False
);
213 if (pView
->GetModel()->IsChanged())
214 GetShell().SetModified();
217 pView
->GetModel()->SetChanged(sal_True
);
220 void SwDrawShell::GetDrawAttrState(SfxItemSet
& rSet
)
222 SdrView
* pSdrView
= GetShell().GetDrawView();
224 if (pSdrView
->AreObjectsMarked())
226 sal_Bool bDisable
= Disable( rSet
);
229 pSdrView
->GetAttributes( rSet
);
232 rSet
.Put(pSdrView
->GetDefaultAttr());
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */