Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
26 :
27 : #include <svx/xtable.hxx>
28 : #include "view.hxx"
29 : #include "wrtsh.hxx"
30 : #include "docsh.hxx"
31 : #include "cmdid.h"
32 :
33 : #include "drawsh.hxx"
34 : #include <svx/svxdlg.hxx>
35 : #include <svx/dialogs.hrc>
36 :
37 0 : void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
38 : {
39 0 : SwWrtShell* pSh = &GetShell();
40 0 : SdrView* pView = pSh->GetDrawView();
41 0 : SdrModel* pDoc = pView->GetModel();
42 0 : sal_Bool bChanged = pDoc->IsChanged();
43 0 : pDoc->SetChanged(sal_False);
44 :
45 0 : SfxItemSet aNewAttr( pDoc->GetItemPool() );
46 0 : pView->GetAttributes( aNewAttr );
47 :
48 0 : GetView().NoRotate();
49 :
50 0 : switch (rReq.GetSlot())
51 : {
52 : case FN_DRAWTEXT_ATTR_DLG:
53 : {
54 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
55 0 : if ( pFact )
56 : {
57 0 : SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView );
58 0 : sal_uInt16 nResult = pDlg->Execute();
59 :
60 0 : if (nResult == RET_OK)
61 : {
62 0 : if (pView->AreObjectsMarked())
63 : {
64 0 : pSh->StartAction();
65 0 : pView->SetAttributes(*pDlg->GetOutputItemSet());
66 0 : rReq.Done(*(pDlg->GetOutputItemSet()));
67 0 : pSh->EndAction();
68 : }
69 : }
70 :
71 0 : delete( pDlg );
72 : }
73 : }
74 0 : break;
75 :
76 : case SID_ATTRIBUTES_AREA:
77 : {
78 0 : sal_Bool bHasMarked = pView->AreObjectsMarked();
79 :
80 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
81 : AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL,
82 : &aNewAttr,
83 : pDoc,
84 0 : pView);
85 0 : if (pDlg->Execute() == RET_OK)
86 : {
87 0 : pSh->StartAction();
88 0 : if (bHasMarked)
89 0 : pView->SetAttributes(*pDlg->GetOutputItemSet());
90 : else
91 0 : pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
92 0 : pSh->EndAction();
93 :
94 : static sal_uInt16 aInval[] =
95 : {
96 : SID_ATTR_FILL_STYLE,
97 : SID_ATTR_FILL_COLOR,
98 : SID_ATTR_FILL_TRANSPARENCE,
99 : SID_ATTR_FILL_FLOATTRANSPARENCE,
100 : 0
101 : };
102 0 : SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
103 0 : rBnd.Invalidate(aInval);
104 0 : rBnd.Update(SID_ATTR_FILL_STYLE);
105 0 : rBnd.Update(SID_ATTR_FILL_COLOR);
106 0 : rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
107 0 : rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
108 : }
109 0 : delete pDlg;
110 : }
111 0 : break;
112 :
113 : case SID_ATTRIBUTES_LINE:
114 : {
115 0 : sal_Bool bHasMarked = pView->AreObjectsMarked();
116 :
117 0 : const SdrObject* pObj = NULL;
118 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
119 0 : if( rMarkList.GetMarkCount() == 1 )
120 0 : pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
121 :
122 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
123 : OSL_ENSURE(pFact, "Dialogdiet Factory fail!");
124 : SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
125 : &aNewAttr,
126 : pDoc,
127 : pObj,
128 0 : bHasMarked);
129 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
130 0 : if (pDlg->Execute() == RET_OK)
131 : {
132 0 : pSh->StartAction();
133 0 : if(bHasMarked)
134 0 : pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
135 : else
136 0 : pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
137 0 : pSh->EndAction();
138 :
139 : static sal_uInt16 aInval[] =
140 : {
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)
150 : 0
151 : };
152 :
153 0 : GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
154 : }
155 0 : delete pDlg;
156 : }
157 0 : break;
158 :
159 : default:
160 0 : break;
161 : }
162 :
163 :
164 0 : if (pDoc->IsChanged())
165 0 : GetShell().SetModified();
166 : else
167 0 : if (bChanged)
168 0 : pDoc->SetChanged(sal_True);
169 0 : }
170 :
171 0 : void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
172 : {
173 0 : SwWrtShell* pSh = &GetShell();
174 0 : SdrView* pView = pSh->GetDrawView();
175 0 : const SfxItemSet* pArgs = rReq.GetArgs();
176 0 : sal_Bool bChanged = pView->GetModel()->IsChanged();
177 0 : pView->GetModel()->SetChanged(sal_False);
178 :
179 0 : GetView().NoRotate();
180 :
181 0 : if (pArgs)
182 : {
183 0 : if(pView->AreObjectsMarked())
184 0 : pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
185 : else
186 0 : pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
187 : }
188 : else
189 : {
190 0 : SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
191 0 : switch (rReq.GetSlot())
192 : {
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 0 : pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
201 0 : break;
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 0 : pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
210 0 : break;
211 : }
212 : }
213 0 : if (pView->GetModel()->IsChanged())
214 0 : GetShell().SetModified();
215 : else
216 0 : if (bChanged)
217 0 : pView->GetModel()->SetChanged(sal_True);
218 0 : }
219 :
220 0 : void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
221 : {
222 0 : SdrView* pSdrView = GetShell().GetDrawView();
223 :
224 0 : if (pSdrView->AreObjectsMarked())
225 : {
226 0 : sal_Bool bDisable = Disable( rSet );
227 :
228 0 : if( !bDisable )
229 0 : pSdrView->GetAttributes( rSet );
230 : }
231 : else
232 0 : rSet.Put(pSdrView->GetDefaultAttr());
233 99 : }
234 :
235 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|