xref: /AOO41X/main/sw/source/ui/ribbar/conpoly.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <svx/svdmark.hxx>
29 #include <svx/svdview.hxx>
30 #include <svx/svdopath.hxx>
31 
32 #include "view.hxx"
33 #include "edtwin.hxx"
34 #include "wrtsh.hxx"
35 #include "drawbase.hxx"
36 #include "conpoly.hxx"
37 #include <basegfx/polygon/b2dpolygon.hxx>
38 
39 /*************************************************************************
40 |*
41 |* Konstruktor
42 |*
43 \************************************************************************/
44 
45 
46 
ConstPolygon(SwWrtShell * pWrtShell,SwEditWin * pEditWin,SwView * pSwView)47 ConstPolygon::ConstPolygon(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
48                 SwDrawBase(pWrtShell, pEditWin, pSwView)
49 {
50 }
51 
52 /*************************************************************************
53 |*
54 |* MouseButtonDown-event
55 |*
56 \************************************************************************/
57 
58 
59 
MouseButtonDown(const MouseEvent & rMEvt)60 sal_Bool ConstPolygon::MouseButtonDown(const MouseEvent& rMEvt)
61 {
62     sal_Bool bReturn;
63 
64     if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
65         aLastPos = rMEvt.GetPosPixel();
66 
67     return (bReturn);
68 }
69 
70 /*************************************************************************
71 |*
72 |* MouseMove-event
73 |*
74 \************************************************************************/
75 
76 
77 
MouseMove(const MouseEvent & rMEvt)78 sal_Bool ConstPolygon::MouseMove(const MouseEvent& rMEvt)
79 {
80     sal_Bool bReturn = sal_False;
81 
82     bReturn = SwDrawBase::MouseMove(rMEvt);
83 
84     return bReturn;
85 }
86 
87 /*************************************************************************
88 |*
89 |* MouseButtonUp-event
90 |*
91 \************************************************************************/
92 
93 
94 
MouseButtonUp(const MouseEvent & rMEvt)95 sal_Bool ConstPolygon::MouseButtonUp(const MouseEvent& rMEvt)
96 {
97     sal_Bool bReturn = sal_False;
98 
99     if (m_pSh->IsDrawCreate())
100     {
101         if (rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
102                                         m_pWin->GetSdrDrawMode() != OBJ_FREELINE)
103         {
104             if (!m_pSh->EndCreate(SDRCREATE_NEXTPOINT))
105             {
106                 m_pSh->BreakCreate();
107                 EnterSelectMode(rMEvt);
108                 return sal_True;
109             }
110         }
111         else
112         {
113             Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
114             bReturn = SwDrawBase::MouseButtonUp(rMEvt);
115 
116             // #i85045# removed double mechanism to check for AutoClose polygon
117             // after construction; the method here did not check for already closed and
118             // also worked only for a single polygon. Removing.
119         }
120     }
121     else
122         bReturn = SwDrawBase::MouseButtonUp(rMEvt);
123 
124     return (bReturn);
125 }
126 
127 /*************************************************************************
128 |*
129 |* Function aktivieren
130 |*
131 \************************************************************************/
132 
133 
134 
Activate(const sal_uInt16 nSlotId)135 void ConstPolygon::Activate(const sal_uInt16 nSlotId)
136 {
137     switch (nSlotId)
138     {
139         case SID_DRAW_POLYGON_NOFILL:
140             m_pWin->SetSdrDrawMode(OBJ_PLIN);
141             break;
142 
143         case SID_DRAW_BEZIER_NOFILL:
144             m_pWin->SetSdrDrawMode(OBJ_PATHLINE);
145             break;
146 
147         case SID_DRAW_FREELINE_NOFILL:
148             m_pWin->SetSdrDrawMode(OBJ_FREELINE);
149             break;
150 
151         default:
152             break;
153     }
154 
155     SwDrawBase::Activate(nSlotId);
156 }
157 
158 
159 
160