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 <fuline.hxx>
21 
22 #include <svx/svxids.hrc>
23 #include <sfx2/request.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <ViewShell.hxx>
27 #include <View.hxx>
28 #include <drawdoc.hxx>
29 #include <svx/svxdlg.hxx>
30 #include <memory>
31 
32 namespace sd {
33 
34 
FuLine(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)35 FuLine::FuLine (
36     ViewShell* pViewSh,
37     ::sd::Window* pWin,
38     ::sd::View* pView,
39     SdDrawDocument* pDoc,
40     SfxRequest& rReq)
41     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
42 {
43 }
44 
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)45 rtl::Reference<FuPoor> FuLine::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
46 {
47     rtl::Reference<FuPoor> xFunc( new FuLine( pViewSh, pWin, pView, pDoc, rReq ) );
48     xFunc->DoExecute(rReq);
49     return xFunc;
50 }
51 
DoExecute(SfxRequest & rReq)52 void FuLine::DoExecute( SfxRequest& rReq )
53 {
54     rReq.Ignore();
55 
56     const SfxItemSet* pArgs = rReq.GetArgs();
57     if (pArgs)
58         return;
59 
60     const SdrObject* pObj = nullptr;
61     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
62     if( rMarkList.GetMarkCount() == 1 )
63         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
64 
65     std::unique_ptr<SfxItemSet> pNewAttr(new SfxItemSet( mpDoc->GetPool() ));
66     mpView->GetAttributes( *pNewAttr );
67 
68     bool bHasMarked = mpView->AreObjectsMarked();
69     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
70     VclPtr<SfxAbstractTabDialog> pDlg( pFact->CreateSvxLineTabDialog(mpViewShell->GetFrameWeld(), pNewAttr.get(), mpDoc, pObj, bHasMarked) );
71 
72     pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nResult){
73         if (nResult == RET_OK)
74         {
75             mpView->SetAttributes (*(pDlg->GetOutputItemSet ()));
76 
77             // some attributes are changed, we have to update the listboxes in the objectbars
78             static const sal_uInt16 SidArray[] = {
79                 SID_ATTR_LINE_STYLE,                // ( SID_SVX_START + 169 )
80                 SID_ATTR_LINE_DASH,                 // ( SID_SVX_START + 170 )
81                 SID_ATTR_LINE_WIDTH,                // ( SID_SVX_START + 171 )
82                 SID_ATTR_LINE_COLOR,                // ( SID_SVX_START + 172 )
83                 SID_ATTR_LINE_START,                // ( SID_SVX_START + 173 )
84                 SID_ATTR_LINE_END,                  // ( SID_SVX_START + 174 )
85                 SID_ATTR_LINE_TRANSPARENCE,         // (SID_SVX_START+1107)
86                 SID_ATTR_LINE_JOINT,                // (SID_SVX_START+1110)
87                 SID_ATTR_LINE_CAP,                  // (SID_SVX_START+1111)
88                 0 };
89 
90             mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
91         }
92 
93         // deferred until the dialog ends
94         mpViewShell->Cancel();
95 
96         pDlg->disposeOnce();
97     });
98 }
99 
Activate()100 void FuLine::Activate()
101 {
102 }
103 
Deactivate()104 void FuLine::Deactivate()
105 {
106 }
107 
108 } // end of namespace sd
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
111