/src/libreoffice/sc/source/ui/drawfunc/fuconarc.cxx
Line | Count | Source |
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 <fuconarc.hxx> |
21 | | #include <tabvwsh.hxx> |
22 | | #include <drawview.hxx> |
23 | | |
24 | | // Create default drawing objects via keyboard |
25 | | #include <svx/svdocirc.hxx> |
26 | | #include <svx/svxids.hrc> |
27 | | #include <svx/sxciaitm.hxx> |
28 | | #include <osl/diagnose.h> |
29 | | #include <vcl/ptrstyle.hxx> |
30 | | |
31 | | FuConstArc::FuConstArc(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawView* pViewP, |
32 | | SdrModel& rDoc, const SfxRequest& rReq) |
33 | 0 | : FuConstruct(rViewSh, pWin, pViewP, rDoc, rReq) |
34 | 0 | { |
35 | 0 | } |
36 | | |
37 | | FuConstArc::~FuConstArc() |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | bool FuConstArc::MouseButtonDown( const MouseEvent& rMEvt ) |
42 | 0 | { |
43 | | // remember button state for creation of own MouseEvents |
44 | 0 | SetMouseButtonCode(rMEvt.GetButtons()); |
45 | |
|
46 | 0 | bool bReturn = FuConstruct::MouseButtonDown( rMEvt ); |
47 | |
|
48 | 0 | if ( rMEvt.IsLeft() && !pView->IsAction() ) |
49 | 0 | { |
50 | 0 | Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); |
51 | 0 | pWindow->CaptureMouse(); |
52 | 0 | pView->BegCreateObj( aPnt ); |
53 | 0 | bReturn = true; |
54 | 0 | } |
55 | 0 | return bReturn; |
56 | 0 | } |
57 | | |
58 | | bool FuConstArc::MouseButtonUp( const MouseEvent& rMEvt ) |
59 | 0 | { |
60 | | // remember button state for creation of own MouseEvents |
61 | 0 | SetMouseButtonCode(rMEvt.GetButtons()); |
62 | |
|
63 | 0 | bool bReturn = false; |
64 | |
|
65 | 0 | if ( pView->IsCreateObj() && rMEvt.IsLeft() ) |
66 | 0 | { |
67 | 0 | pView->EndCreateObj( SdrCreateCmd::NextPoint ); |
68 | 0 | bReturn = true; |
69 | 0 | } |
70 | 0 | return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); |
71 | 0 | } |
72 | | |
73 | | void FuConstArc::Activate() |
74 | 0 | { |
75 | 0 | SdrObjKind aObjKind; |
76 | |
|
77 | 0 | switch (aSfxRequest.GetSlot() ) |
78 | 0 | { |
79 | 0 | case SID_DRAW_ARC: |
80 | 0 | aNewPointer = PointerStyle::DrawArc; |
81 | 0 | aObjKind = SdrObjKind::CircleArc; |
82 | 0 | break; |
83 | | |
84 | 0 | case SID_DRAW_PIE: |
85 | 0 | aNewPointer = PointerStyle::DrawPie; |
86 | 0 | aObjKind = SdrObjKind::CircleSection; |
87 | 0 | break; |
88 | | |
89 | 0 | case SID_DRAW_CIRCLECUT: |
90 | 0 | aNewPointer = PointerStyle::DrawCircleCut; |
91 | 0 | aObjKind = SdrObjKind::CircleCut; |
92 | 0 | break; |
93 | | |
94 | 0 | default: |
95 | 0 | aNewPointer = PointerStyle::Cross; |
96 | 0 | aObjKind = SdrObjKind::CircleArc; |
97 | 0 | break; |
98 | 0 | } |
99 | | |
100 | 0 | pView->SetCurrentObj(aObjKind); |
101 | |
|
102 | 0 | aOldPointer = pWindow->GetPointer(); |
103 | 0 | rViewShell.SetActivePointer( aNewPointer ); |
104 | |
|
105 | 0 | FuDraw::Activate(); |
106 | 0 | } |
107 | | |
108 | | void FuConstArc::Deactivate() |
109 | 0 | { |
110 | 0 | FuDraw::Deactivate(); |
111 | 0 | rViewShell.SetActivePointer( aOldPointer ); |
112 | 0 | } |
113 | | |
114 | | // Create default drawing objects via keyboard |
115 | | rtl::Reference<SdrObject> FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) |
116 | 0 | { |
117 | | // case SID_DRAW_ARC: |
118 | | // case SID_DRAW_PIE: |
119 | | // case SID_DRAW_CIRCLECUT: |
120 | |
|
121 | 0 | rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject( |
122 | 0 | rDrDoc, |
123 | 0 | pView->GetCurrentObjInventor(), |
124 | 0 | pView->GetCurrentObjIdentifier())); |
125 | |
|
126 | 0 | if(pObj) |
127 | 0 | { |
128 | 0 | if(dynamic_cast<const SdrCircObj*>( pObj.get() ) != nullptr) |
129 | 0 | { |
130 | 0 | tools::Rectangle aRect(rRectangle); |
131 | |
|
132 | 0 | if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID) |
133 | 0 | { |
134 | | // force quadratic |
135 | 0 | ImpForceQuadratic(aRect); |
136 | 0 | } |
137 | |
|
138 | 0 | pObj->SetLogicRect(aRect); |
139 | |
|
140 | 0 | SfxItemSet aAttr(rDrDoc.GetItemPool()); |
141 | 0 | aAttr.Put(makeSdrCircStartAngleItem(9000_deg100)); |
142 | 0 | aAttr.Put(makeSdrCircEndAngleItem(0_deg100)); |
143 | |
|
144 | 0 | pObj->SetMergedItemSet(aAttr); |
145 | 0 | } |
146 | 0 | else |
147 | 0 | { |
148 | 0 | OSL_FAIL("Object is NO circle object"); |
149 | 0 | } |
150 | 0 | } |
151 | |
|
152 | 0 | return pObj; |
153 | 0 | } |
154 | | |
155 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |