bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / shells / drawdlg.cxx
blob8373278cbc06994d6e975388366098743ae2a23d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include "view.hxx"
29 #include "wrtsh.hxx"
30 #include "docsh.hxx"
31 #include "cmdid.h"
33 #include "drawsh.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 );
48 GetView().NoRotate();
50 switch (rReq.GetSlot())
52 case FN_DRAWTEXT_ATTR_DLG:
54 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
55 if ( pFact )
57 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView );
58 sal_uInt16 nResult = pDlg->Execute();
60 if (nResult == RET_OK)
62 if (pView->AreObjectsMarked())
64 pSh->StartAction();
65 pView->SetAttributes(*pDlg->GetOutputItemSet());
66 rReq.Done(*(pDlg->GetOutputItemSet()));
67 pSh->EndAction();
71 delete( pDlg );
74 break;
76 case SID_ATTRIBUTES_AREA:
78 sal_Bool bHasMarked = pView->AreObjectsMarked();
80 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
81 AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL,
82 &aNewAttr,
83 pDoc,
84 pView);
85 if (pDlg->Execute() == RET_OK)
87 pSh->StartAction();
88 if (bHasMarked)
89 pView->SetAttributes(*pDlg->GetOutputItemSet());
90 else
91 pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
92 pSh->EndAction();
94 static sal_uInt16 aInval[] =
96 SID_ATTR_FILL_STYLE,
97 SID_ATTR_FILL_COLOR,
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);
109 delete pDlg;
111 break;
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,
125 &aNewAttr,
126 pDoc,
127 pObj,
128 bHasMarked);
129 OSL_ENSURE(pDlg, "Dialogdiet fail!");
130 if (pDlg->Execute() == RET_OK)
132 pSh->StartAction();
133 if(bHasMarked)
134 pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
135 else
136 pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
137 pSh->EndAction();
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);
155 delete pDlg;
157 break;
159 default:
160 break;
164 if (pDoc->IsChanged())
165 GetShell().SetModified();
166 else
167 if (bChanged)
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();
181 if (pArgs)
183 if(pView->AreObjectsMarked())
184 pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
185 else
186 pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
188 else
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);
201 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 pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
210 break;
213 if (pView->GetModel()->IsChanged())
214 GetShell().SetModified();
215 else
216 if (bChanged)
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 );
228 if( !bDisable )
229 pSdrView->GetAttributes( rSet );
231 else
232 rSet.Put(pSdrView->GetDefaultAttr());
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */