xref: /AOO41X/main/sw/source/ui/ribbar/conrect.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 <sfx2/bindings.hxx>
29 #include <svx/htmlmode.hxx>
30 #include <svx/sdtacitm.hxx>
31 #include <svx/svdobj.hxx>
32 #include <svx/sdtagitm.hxx>
33 #include <svx/sdtakitm.hxx>
34 #include <svx/sdtaditm.hxx>
35 #include <svx/sdtaaitm.hxx>
36 #include <svx/svdview.hxx>
37 #include <svx/svdocapt.hxx>
38 #include <editeng/outlobj.hxx>
39 #include <cmdid.h>
40 #include <view.hxx>
41 #include <edtwin.hxx>
42 #include <wrtsh.hxx>
43 #include <viewopt.hxx>
44 #include <drawbase.hxx>
45 #include <conrect.hxx>
46 
47 
48 /*************************************************************************
49 |*
50 |* Konstruktor
51 |*
52 \************************************************************************/
53 
ConstRectangle(SwWrtShell * pWrtShell,SwEditWin * pEditWin,SwView * pSwView)54 ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
55                                 SwView* pSwView )
56     : SwDrawBase( pWrtShell, pEditWin, pSwView ),
57     bMarquee(sal_False),
58     // #93382#
59     mbVertical(sal_False)
60 {
61 }
62 
63 /*************************************************************************
64 |*
65 |* MouseButtonDown-event
66 |*
67 \************************************************************************/
68 
MouseButtonDown(const MouseEvent & rMEvt)69 sal_Bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
70 {
71     sal_Bool bReturn;
72 
73     if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True
74                                     && m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
75     {
76         m_pView->NoRotate();
77         if (m_pView->IsDrawSelMode())
78         {
79             m_pView->FlipDrawSelMode();
80             m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
81         }
82     }
83     return (bReturn);
84 }
85 
86 /*************************************************************************
87 |*
88 |* MouseButtonUp-event
89 |*
90 \************************************************************************/
91 
MouseButtonUp(const MouseEvent & rMEvt)92 sal_Bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
93 {
94     Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
95 
96     sal_Bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
97     if( bRet )
98     {
99         SdrView *pSdrView = m_pSh->GetDrawView();
100         const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
101         SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
102                                                : 0;
103         switch( m_pWin->GetSdrDrawMode() )
104         {
105         case OBJ_TEXT:
106             if( bMarquee )
107             {
108                 m_pSh->ChgAnchor(FLY_AS_CHAR);
109 
110                 if( pObj )
111                 {
112                     // die fuer das Scrollen benoetigten Attribute setzen
113                     SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
114                                         SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
115 
116                     aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
117                     aItemSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
118                     aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
119                     aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
120                     aItemSet.Put( SdrTextAniCountItem( 0 ) );
121                     aItemSet.Put( SdrTextAniAmountItem(
122                             (sal_Int16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
123 
124                     pObj->SetMergedItemSetAndBroadcast(aItemSet);
125                 }
126             }
127             else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
128             {
129                 // #93382#
130                 SdrTextObj* pText = (SdrTextObj*)pObj;
131                 SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
132 
133                 pText->SetVerticalWriting(sal_True);
134 
135                 aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
136                 aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
137                 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
138                 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
139 
140                 pText->SetMergedItemSet(aSet);
141             }
142             if( pObj )
143             {
144                 SdrPageView* pPV = pSdrView->GetSdrPageView();
145                 m_pView->BeginTextEdit( pObj, pPV, m_pWin, sal_True );
146             }
147             m_pView->LeaveDrawCreate();  // In Selektionsmode wechseln
148             m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
149             break;
150 
151         case OBJ_CAPTION:
152         {
153             SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
154             if( bCapVertical && pCaptObj )
155             {
156                 pCaptObj->ForceOutlinerParaObject();
157                 OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
158                 if( pOPO && !pOPO->IsVertical() )
159                     pOPO->SetVertical( sal_True );
160             }
161         }
162         break;
163         default:; //prevent warning
164         }
165     }
166     return bRet;
167 }
168 
169 /*************************************************************************
170 |*
171 |* Function aktivieren
172 |*
173 \************************************************************************/
174 
Activate(const sal_uInt16 nSlotId)175 void ConstRectangle::Activate(const sal_uInt16 nSlotId)
176 {
177     bMarquee = bCapVertical = sal_False;
178     mbVertical = sal_False;
179 
180     switch (nSlotId)
181     {
182     case SID_DRAW_LINE:
183         m_pWin->SetSdrDrawMode(OBJ_LINE);
184         break;
185 
186     case SID_DRAW_RECT:
187         m_pWin->SetSdrDrawMode(OBJ_RECT);
188         break;
189 
190     case SID_DRAW_ELLIPSE:
191         m_pWin->SetSdrDrawMode(OBJ_CIRC);
192         break;
193 
194     case SID_DRAW_TEXT_MARQUEE:
195         bMarquee = sal_True;
196         m_pWin->SetSdrDrawMode(OBJ_TEXT);
197         break;
198 
199     case SID_DRAW_TEXT_VERTICAL:
200         // #93382#
201         mbVertical = sal_True;
202         m_pWin->SetSdrDrawMode(OBJ_TEXT);
203         break;
204 
205     case SID_DRAW_TEXT:
206         m_pWin->SetSdrDrawMode(OBJ_TEXT);
207         break;
208 
209     case SID_DRAW_CAPTION_VERTICAL:
210         bCapVertical = sal_True;
211         // no break
212     case SID_DRAW_CAPTION:
213         m_pWin->SetSdrDrawMode(OBJ_CAPTION);
214         break;
215 
216     default:
217         m_pWin->SetSdrDrawMode(OBJ_NONE);
218         break;
219     }
220 
221     SwDrawBase::Activate(nSlotId);
222 }
223 
224 
225 
226