xref: /trunk/main/sw/source/ui/shells/drawdlg.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC //autogen
32cdf0e10cSrcweir #include <svx/svxids.hrc>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
35cdf0e10cSrcweir #include <vcl/msgbox.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <sfx2/request.hxx>
38cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
39cdf0e10cSrcweir #include <svx/svdview.hxx>
40cdf0e10cSrcweir #include <svx/tabarea.hxx>
41cdf0e10cSrcweir #include <svx/tabline.hxx>
42cdf0e10cSrcweir #include <svx/drawitem.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <svx/xtable.hxx>
45cdf0e10cSrcweir #include "view.hxx"
46cdf0e10cSrcweir #include "wrtsh.hxx"
47cdf0e10cSrcweir #include "docsh.hxx"
48cdf0e10cSrcweir #include "cmdid.h"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include "drawsh.hxx"
51cdf0e10cSrcweir #include <svx/svxdlg.hxx>
52cdf0e10cSrcweir #include <svx/dialogs.hrc>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /*--------------------------------------------------------------------
55cdf0e10cSrcweir     Beschreibung:
56cdf0e10cSrcweir  --------------------------------------------------------------------*/
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
ExecDrawDlg(SfxRequest & rReq)59cdf0e10cSrcweir void SwDrawShell::ExecDrawDlg(SfxRequest& rReq)
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     SwWrtShell*     pSh     = &GetShell();
62cdf0e10cSrcweir     SdrView*        pView   = pSh->GetDrawView();
63cdf0e10cSrcweir     SdrModel*       pDoc    = pView->GetModel();
64cdf0e10cSrcweir     sal_Bool            bChanged = pDoc->IsChanged();
65cdf0e10cSrcweir     pDoc->SetChanged(sal_False);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     SfxItemSet aNewAttr( pDoc->GetItemPool() );
68cdf0e10cSrcweir     pView->GetAttributes( aNewAttr );
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     GetView().NoRotate();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     switch (rReq.GetSlot())
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         case FN_DRAWTEXT_ATTR_DLG:
75cdf0e10cSrcweir         {
76cdf0e10cSrcweir             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
77cdf0e10cSrcweir             if ( pFact )
78cdf0e10cSrcweir             {
79cdf0e10cSrcweir                 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView );
80cdf0e10cSrcweir                 sal_uInt16 nResult = pDlg->Execute();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir                 if (nResult == RET_OK)
83cdf0e10cSrcweir                 {
84cdf0e10cSrcweir                     if (pView->AreObjectsMarked())
85cdf0e10cSrcweir                     {
86cdf0e10cSrcweir                         pSh->StartAction();
87cdf0e10cSrcweir                         pView->SetAttributes(*pDlg->GetOutputItemSet());
88cdf0e10cSrcweir                         rReq.Done(*(pDlg->GetOutputItemSet()));
89cdf0e10cSrcweir                         pSh->EndAction();
90cdf0e10cSrcweir                     }
91cdf0e10cSrcweir                 }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir                 delete( pDlg );
94cdf0e10cSrcweir             }
95cdf0e10cSrcweir         }
96cdf0e10cSrcweir         break;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         case SID_ATTRIBUTES_AREA:
99cdf0e10cSrcweir         {
100cdf0e10cSrcweir             sal_Bool bHasMarked = pView->AreObjectsMarked();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
103cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
104*64b14621SArmin Le Grand             AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog(
105*64b14621SArmin Le Grand                 NULL,
106cdf0e10cSrcweir                 &aNewAttr,
107cdf0e10cSrcweir                 pDoc,
108*64b14621SArmin Le Grand                 true);
109cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
110c3467423SPavel Janík             // const SvxColorTableItem* pColorItem = (const SvxColorTableItem*)
111cdf0e10cSrcweir                                     GetView().GetDocShell()->GetItem(SID_COLOR_TABLE);
112c7be74b1SArmin Le Grand 
113cdf0e10cSrcweir             if (pDlg->Execute() == RET_OK)
114cdf0e10cSrcweir             {
115cdf0e10cSrcweir                 pSh->StartAction();
116cdf0e10cSrcweir                 if (bHasMarked)
117cdf0e10cSrcweir                     pView->SetAttributes(*pDlg->GetOutputItemSet());
118cdf0e10cSrcweir                 else
119cdf0e10cSrcweir                     pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
120cdf0e10cSrcweir                 pSh->EndAction();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir                 static sal_uInt16 __READONLY_DATA aInval[] =
123cdf0e10cSrcweir                 {
124d5370dc8SArmin Le Grand                     SID_ATTR_FILL_STYLE,
125d5370dc8SArmin Le Grand                     SID_ATTR_FILL_COLOR,
126d5370dc8SArmin Le Grand                     SID_ATTR_FILL_TRANSPARENCE,
127d5370dc8SArmin Le Grand                     SID_ATTR_FILL_FLOATTRANSPARENCE,
128d5370dc8SArmin Le Grand                     0
129cdf0e10cSrcweir                 };
130cdf0e10cSrcweir                 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
131cdf0e10cSrcweir                 rBnd.Invalidate(aInval);
132cdf0e10cSrcweir                 rBnd.Update(SID_ATTR_FILL_STYLE);
133cdf0e10cSrcweir                 rBnd.Update(SID_ATTR_FILL_COLOR);
134d5370dc8SArmin Le Grand                 rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
135d5370dc8SArmin Le Grand                 rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
136cdf0e10cSrcweir             }
137cdf0e10cSrcweir             delete pDlg;
138cdf0e10cSrcweir         }
139cdf0e10cSrcweir         break;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         case SID_ATTRIBUTES_LINE:
142cdf0e10cSrcweir         {
143cdf0e10cSrcweir             sal_Bool bHasMarked = pView->AreObjectsMarked();
144cdf0e10cSrcweir 
145cdf0e10cSrcweir             const SdrObject* pObj = NULL;
146cdf0e10cSrcweir             const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
147cdf0e10cSrcweir             if( rMarkList.GetMarkCount() == 1 )
148cdf0e10cSrcweir                 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
149cdf0e10cSrcweir 
150cdf0e10cSrcweir             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
151cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
152cdf0e10cSrcweir             SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL,
153cdf0e10cSrcweir                     &aNewAttr,
154cdf0e10cSrcweir                 pDoc,
155cdf0e10cSrcweir                 pObj,
156cdf0e10cSrcweir                 bHasMarked);
157cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
158cdf0e10cSrcweir             if (pDlg->Execute() == RET_OK)
159cdf0e10cSrcweir             {
160cdf0e10cSrcweir                 pSh->StartAction();
161cdf0e10cSrcweir                 if(bHasMarked)
162cdf0e10cSrcweir                     pView->SetAttrToMarked(*pDlg->GetOutputItemSet(), sal_False);
163cdf0e10cSrcweir                 else
164cdf0e10cSrcweir                     pView->SetDefaultAttr(*pDlg->GetOutputItemSet(), sal_False);
165cdf0e10cSrcweir                 pSh->EndAction();
166cdf0e10cSrcweir 
167cdf0e10cSrcweir                 static sal_uInt16 __READONLY_DATA aInval[] =
168cdf0e10cSrcweir                 {
169d5370dc8SArmin Le Grand                     SID_ATTR_LINE_STYLE,                // ( SID_SVX_START + 169 )
170d5370dc8SArmin Le Grand                     SID_ATTR_LINE_DASH,                 // ( SID_SVX_START + 170 )
171d5370dc8SArmin Le Grand                     SID_ATTR_LINE_WIDTH,                // ( SID_SVX_START + 171 )
172d5370dc8SArmin Le Grand                     SID_ATTR_LINE_COLOR,                // ( SID_SVX_START + 172 )
173d5370dc8SArmin Le Grand                     SID_ATTR_LINE_START,                // ( SID_SVX_START + 173 )
174d5370dc8SArmin Le Grand                     SID_ATTR_LINE_END,                  // ( SID_SVX_START + 174 )
175d5370dc8SArmin Le Grand                     SID_ATTR_LINE_TRANSPARENCE,         // (SID_SVX_START+1107)
176d5370dc8SArmin Le Grand                     SID_ATTR_LINE_JOINT,                // (SID_SVX_START+1110)
177d5370dc8SArmin Le Grand                     SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
178d5370dc8SArmin Le Grand                     0
179cdf0e10cSrcweir                 };
180cdf0e10cSrcweir 
181cdf0e10cSrcweir                 GetView().GetViewFrame()->GetBindings().Invalidate(aInval);
182cdf0e10cSrcweir             }
183cdf0e10cSrcweir             delete pDlg;
184cdf0e10cSrcweir         }
185cdf0e10cSrcweir         break;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         default:
188cdf0e10cSrcweir             break;
189cdf0e10cSrcweir     }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     if (pDoc->IsChanged())
193cdf0e10cSrcweir         GetShell().SetModified();
194cdf0e10cSrcweir     else
195cdf0e10cSrcweir         if (bChanged)
196cdf0e10cSrcweir             pDoc->SetChanged(sal_True);
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir /*--------------------------------------------------------------------
200cdf0e10cSrcweir     Beschreibung:
201cdf0e10cSrcweir  --------------------------------------------------------------------*/
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 
ExecDrawAttrArgs(SfxRequest & rReq)204cdf0e10cSrcweir void SwDrawShell::ExecDrawAttrArgs(SfxRequest& rReq)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     SwWrtShell* pSh   = &GetShell();
207cdf0e10cSrcweir     SdrView*    pView = pSh->GetDrawView();
208cdf0e10cSrcweir     const SfxItemSet* pArgs = rReq.GetArgs();
209cdf0e10cSrcweir     sal_Bool        bChanged = pView->GetModel()->IsChanged();
210cdf0e10cSrcweir     pView->GetModel()->SetChanged(sal_False);
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     GetView().NoRotate();
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     if (pArgs)
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         if(pView->AreObjectsMarked())
217cdf0e10cSrcweir             pView->SetAttrToMarked(*rReq.GetArgs(), sal_False);
218cdf0e10cSrcweir         else
219cdf0e10cSrcweir             pView->SetDefaultAttr(*rReq.GetArgs(), sal_False);
220cdf0e10cSrcweir     }
221cdf0e10cSrcweir     else
222cdf0e10cSrcweir     {
223cdf0e10cSrcweir         SfxDispatcher* pDis = pSh->GetView().GetViewFrame()->GetDispatcher();
224cdf0e10cSrcweir         switch (rReq.GetSlot())
225cdf0e10cSrcweir         {
226cdf0e10cSrcweir             case SID_ATTR_FILL_STYLE:
227cdf0e10cSrcweir             case SID_ATTR_FILL_COLOR:
228cdf0e10cSrcweir             case SID_ATTR_FILL_GRADIENT:
229cdf0e10cSrcweir             case SID_ATTR_FILL_HATCH:
230cdf0e10cSrcweir             case SID_ATTR_FILL_BITMAP:
231d5370dc8SArmin Le Grand             case SID_ATTR_FILL_TRANSPARENCE:
232d5370dc8SArmin Le Grand             case SID_ATTR_FILL_FLOATTRANSPARENCE:
233cdf0e10cSrcweir                 pDis->Execute(SID_ATTRIBUTES_AREA, sal_False);
234cdf0e10cSrcweir                 break;
235cdf0e10cSrcweir             case SID_ATTR_LINE_STYLE:
236cdf0e10cSrcweir             case SID_ATTR_LINE_DASH:
237cdf0e10cSrcweir             case SID_ATTR_LINE_WIDTH:
238cdf0e10cSrcweir             case SID_ATTR_LINE_COLOR:
239d5370dc8SArmin Le Grand             case SID_ATTR_LINE_TRANSPARENCE:
240d5370dc8SArmin Le Grand             case SID_ATTR_LINE_JOINT:
241d5370dc8SArmin Le Grand             case SID_ATTR_LINE_CAP:
242cdf0e10cSrcweir                 pDis->Execute(SID_ATTRIBUTES_LINE, sal_False);
243cdf0e10cSrcweir                 break;
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir     }
246cdf0e10cSrcweir     if (pView->GetModel()->IsChanged())
247cdf0e10cSrcweir         GetShell().SetModified();
248cdf0e10cSrcweir     else
249cdf0e10cSrcweir         if (bChanged)
250cdf0e10cSrcweir             pView->GetModel()->SetChanged(sal_True);
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir /*--------------------------------------------------------------------
254cdf0e10cSrcweir     Beschreibung:
255cdf0e10cSrcweir  --------------------------------------------------------------------*/
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
GetDrawAttrState(SfxItemSet & rSet)258cdf0e10cSrcweir void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir     SdrView* pSdrView = GetShell().GetDrawView();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     if (pSdrView->AreObjectsMarked())
263cdf0e10cSrcweir     {
264cdf0e10cSrcweir         sal_Bool bDisable = Disable( rSet );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir         if( !bDisable )
267cdf0e10cSrcweir             pSdrView->GetAttributes( rSet );
268cdf0e10cSrcweir     }
269cdf0e10cSrcweir     else
270cdf0e10cSrcweir         rSet.Put(pSdrView->GetDefaultAttr());
271cdf0e10cSrcweir }
272