LibreOffice Module sw (master)  1
drawdlg.cxx
Go to the documentation of this file.
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 <sfx2/request.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/viewfrm.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 #include <memory>
37 
39 {
40  SwWrtShell* pSh = &GetShell();
41  SdrView* pView = pSh->GetDrawView();
42  SdrModel* pDoc = pView->GetModel();
43  bool bChanged = pDoc->IsChanged();
44  pDoc->SetChanged(false);
45 
46  SfxItemSet aNewAttr( pDoc->GetItemPool() );
47  pView->GetAttributes( aNewAttr );
48 
49  GetView().NoRotate();
50 
51  switch (rReq.GetSlot())
52  {
54  {
56  ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog(rReq.GetFrameWeld(), &aNewAttr, pView));
57  sal_uInt16 nResult = pDlg->Execute();
58 
59  if (nResult == RET_OK)
60  {
61  if (pView->AreObjectsMarked())
62  {
63  pSh->StartAction();
64  pView->SetAttributes(*pDlg->GetOutputItemSet());
65  rReq.Done(*(pDlg->GetOutputItemSet()));
66  pSh->EndAction();
67  }
68  }
69  }
70  break;
71 
72  case SID_MEASURE_DLG:
73  {
74  bool bHasMarked = pView->AreObjectsMarked();
75 
78  aNewAttr, pView, RID_SVXPAGE_MEASURE));
79  if (pDlg->Execute() == RET_OK)
80  {
81  pSh->StartAction();
82  if (bHasMarked)
83  pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), false);
84  else
85  pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), false);
86  pSh->EndAction();
87  }
88  }
89  break;
90 
91  case SID_ATTRIBUTES_AREA:
92  {
93  bool bHasMarked = pView->AreObjectsMarked();
94 
97  &aNewAttr,
98  pDoc,
99  true));
100 
101  pDlg->StartExecuteAsync([bChanged, bHasMarked, pDoc, pDlg, pSh, pView, this](
102  sal_Int32 nResult){
103  if (nResult == RET_OK)
104  {
105  pSh->StartAction();
106  if (bHasMarked)
107  pView->SetAttributes(*pDlg->GetOutputItemSet());
108  else
109  pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), false);
110  pSh->EndAction();
111 
112  static sal_uInt16 aInval[] =
113  {
114  SID_ATTR_FILL_STYLE,
115  SID_ATTR_FILL_COLOR,
116  SID_ATTR_FILL_TRANSPARENCE,
117  SID_ATTR_FILL_FLOATTRANSPARENCE,
118  0
119  };
121  rBnd.Invalidate(aInval);
122  rBnd.Update(SID_ATTR_FILL_STYLE);
123  rBnd.Update(SID_ATTR_FILL_COLOR);
124  rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
125  rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
126  }
127 
128  if (pDoc->IsChanged())
129  GetShell().SetModified();
130  else if (bChanged)
131  pDoc->SetChanged();
132 
133  pDlg->disposeOnce();
134  });
135  }
136  break;
137 
138  case SID_ATTRIBUTES_LINE:
139  {
140  bool bHasMarked = pView->AreObjectsMarked();
141 
142  const SdrObject* pObj = nullptr;
143  const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
144  if( rMarkList.GetMarkCount() == 1 )
145  pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
146 
149  &aNewAttr,
150  pDoc,
151  pObj,
152  bHasMarked));
153 
154  pDlg->StartExecuteAsync([bChanged, bHasMarked, pDoc, pDlg, pSh, pView, this](
155  sal_Int32 nResult){
156  if (nResult == RET_OK)
157  {
158  pSh->StartAction();
159  if(bHasMarked)
160  pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), false);
161  else
162  pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), false);
163  pSh->EndAction();
164 
165  static sal_uInt16 aInval[] =
166  {
167  SID_ATTR_LINE_STYLE, // ( SID_SVX_START + 169 )
168  SID_ATTR_LINE_DASH, // ( SID_SVX_START + 170 )
169  SID_ATTR_LINE_WIDTH, // ( SID_SVX_START + 171 )
170  SID_ATTR_LINE_COLOR, // ( SID_SVX_START + 172 )
171  SID_ATTR_LINE_START, // ( SID_SVX_START + 173 )
172  SID_ATTR_LINE_END, // ( SID_SVX_START + 174 )
173  SID_ATTR_LINE_TRANSPARENCE, // (SID_SVX_START+1107)
174  SID_ATTR_LINE_JOINT, // (SID_SVX_START+1110)
175  SID_ATTR_LINE_CAP, // (SID_SVX_START+1111)
176  0
177  };
178 
180  }
181 
182  if (pDoc->IsChanged())
183  GetShell().SetModified();
184  else if (bChanged)
185  pDoc->SetChanged();
186 
187  pDlg->disposeOnce();
188  });
189  }
190  break;
191 
192  default:
193  break;
194  }
195 
196  if (pDoc->IsChanged())
197  GetShell().SetModified();
198  else
199  if (bChanged)
200  pDoc->SetChanged();
201 }
202 
204 {
205  SwWrtShell* pSh = &GetShell();
206  SdrView* pView = pSh->GetDrawView();
207  const SfxItemSet* pArgs = rReq.GetArgs();
208  bool bChanged = pView->GetModel()->IsChanged();
209  pView->GetModel()->SetChanged(false);
210 
211  GetView().NoRotate();
212 
213  if (pArgs)
214  {
215  if(pView->AreObjectsMarked())
216  pView->SetAttrToMarked(*rReq.GetArgs(), false);
217  else
218  pView->SetDefaultAttr(*rReq.GetArgs(), false);
219  }
220  else
221  {
222  SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
223  switch (rReq.GetSlot())
224  {
225  case SID_ATTR_FILL_STYLE:
226  case SID_ATTR_FILL_COLOR:
227  case SID_ATTR_FILL_GRADIENT:
228  case SID_ATTR_FILL_HATCH:
229  case SID_ATTR_FILL_BITMAP:
230  case SID_ATTR_FILL_TRANSPARENCE:
231  case SID_ATTR_FILL_FLOATTRANSPARENCE:
232  pDis->Execute(SID_ATTRIBUTES_AREA);
233  break;
234  case SID_ATTR_LINE_STYLE:
235  case SID_ATTR_LINE_DASH:
236  case SID_ATTR_LINE_WIDTH:
237  case SID_ATTR_LINE_COLOR:
238  case SID_ATTR_LINE_TRANSPARENCE:
239  case SID_ATTR_LINE_JOINT:
240  case SID_ATTR_LINE_CAP:
241  pDis->Execute(SID_ATTRIBUTES_LINE);
242  break;
243  }
244  }
245  if (pView->GetModel()->IsChanged())
246  GetShell().SetModified();
247  else
248  if (bChanged)
249  pView->GetModel()->SetChanged();
250 }
251 
253 {
254  SdrView* pSdrView = GetShell().GetDrawView();
255 
256  if (pSdrView->AreObjectsMarked())
257  {
258  bool bDisable = Disable( rSet );
259 
260  if( !bDisable )
261  pSdrView->GetAttributes( rSet );
262  }
263  else
264  rSet.Put(pSdrView->GetDefaultAttr());
265 }
266 
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
size_t GetMarkCount() const
SwView & GetView()
Definition: basesh.hxx:57
SdrView * GetDrawView()
Definition: vnew.cxx:376
virtual const SfxItemSet * GetOutputItemSet() const =0
SfxDispatcher * GetDispatcher()
bool AreObjectsMarked() const
SwWrtShell & GetShell()
Definition: basesh.cxx:2622
static SvxAbstractDialogFactory * Create()
void GetDrawAttrState(SfxItemSet &rSet)
Definition: drawdlg.cxx:252
void Done(bool bRemove=false)
SdrMark * GetMark(size_t nNum) const
void ExecDrawAttrArgs(SfxRequest const &rReq)
Definition: drawdlg.cxx:203
void SetModified()
Definition: edws.cxx:69
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
void SetAttrToMarked(const SfxItemSet &rAttr, bool bReplaceAll)
const SwView & GetView() const
Definition: wrtsh.hxx:426
virtual VclPtr< SfxAbstractDialog > CreateSfxDialog(weld::Window *pParent, const SfxItemSet &rAttr, const SdrView *pView, sal_uInt32 nResId)=0
const SfxItemSet & GetDefaultAttr() const
virtual void SetChanged(bool bFlg=true)
SdrObject * GetMarkedSdrObj() const
void NoRotate()
Definition: viewdraw.cxx:440
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:232
SfxBindings & GetBindings()
const SdrMarkList & GetMarkedObjectList() const
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
#define FN_DRAWTEXT_ATTR_DLG
Definition: cmdid.h:230
void SetDefaultAttr(const SfxItemSet &rAttr, bool bReplaceAll)
bool Disable(SfxItemSet &rSet, sal_uInt16 nWhich=0)
Definition: drwbassh.cxx:755
bool IsChanged() const
void StartAction()
Definition: crsrsh.cxx:215
virtual VclPtr< SfxAbstractTabDialog > CreateTextTabDialog(weld::Window *pParent, const SfxItemSet *pAttrSet, SdrView *pView)=0
weld::Window * GetFrameWeld() const
void Update(sal_uInt16 nId)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void ExecDrawDlg(SfxRequest &rReq)
Definition: drawdlg.cxx:38
virtual VclPtr< AbstractSvxAreaTabDialog > CreateSvxAreaTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, SdrModel *pModel, bool bShadow)=0
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
RET_OK
const SfxItemPool & GetItemPool() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SdrModel * GetModel() const
virtual VclPtr< SfxAbstractTabDialog > CreateSvxLineTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, SdrModel *pModel, const SdrObject *pObj, bool bHasObj)=0