xref: /trunk/main/sw/source/ui/ribbar/conrect.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <sfx2/bindings.hxx>
33 #include <svx/htmlmode.hxx>
34 #include <svx/sdtacitm.hxx>
35 #include <svx/svdobj.hxx>
36 #include <svx/sdtagitm.hxx>
37 #include <svx/sdtakitm.hxx>
38 #include <svx/sdtaditm.hxx>
39 #include <svx/sdtaaitm.hxx>
40 #include <svx/svdview.hxx>
41 #include <svx/svdocapt.hxx>
42 #include <editeng/outlobj.hxx>
43 #include <cmdid.h>
44 #include <view.hxx>
45 #include <edtwin.hxx>
46 #include <wrtsh.hxx>
47 #include <viewopt.hxx>
48 #include <drawbase.hxx>
49 #include <conrect.hxx>
50 
51 
52 /*************************************************************************
53 |*
54 |* Konstruktor
55 |*
56 \************************************************************************/
57 
58 ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
59                                 SwView* pSwView )
60     : SwDrawBase( pWrtShell, pEditWin, pSwView ),
61     bMarquee(sal_False),
62     // #93382#
63     mbVertical(sal_False)
64 {
65 }
66 
67 /*************************************************************************
68 |*
69 |* MouseButtonDown-event
70 |*
71 \************************************************************************/
72 
73 sal_Bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
74 {
75     sal_Bool bReturn;
76 
77     if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True
78                                     && m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
79     {
80         m_pView->NoRotate();
81         if (m_pView->IsDrawSelMode())
82         {
83             m_pView->FlipDrawSelMode();
84             m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
85         }
86     }
87     return (bReturn);
88 }
89 
90 /*************************************************************************
91 |*
92 |* MouseButtonUp-event
93 |*
94 \************************************************************************/
95 
96 sal_Bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
97 {
98     Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
99 
100     sal_Bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
101     if( bRet )
102     {
103         SdrView *pSdrView = m_pSh->GetDrawView();
104         const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
105         SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
106                                                : 0;
107         switch( m_pWin->GetSdrDrawMode() )
108         {
109         case OBJ_TEXT:
110             if( bMarquee )
111             {
112                 m_pSh->ChgAnchor(FLY_AS_CHAR);
113 
114                 if( pObj )
115                 {
116                     // die fuer das Scrollen benoetigten Attribute setzen
117                     SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
118                                         SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
119 
120                     aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
121                     aItemSet.Put( SdrTextAutoGrowHeightItem( sal_False ) );
122                     aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
123                     aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
124                     aItemSet.Put( SdrTextAniCountItem( 0 ) );
125                     aItemSet.Put( SdrTextAniAmountItem(
126                             (sal_Int16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
127 
128                     pObj->SetMergedItemSetAndBroadcast(aItemSet);
129                 }
130             }
131             else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
132             {
133                 // #93382#
134                 SdrTextObj* pText = (SdrTextObj*)pObj;
135                 SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
136 
137                 pText->SetVerticalWriting(sal_True);
138 
139                 aSet.Put(SdrTextAutoGrowWidthItem(sal_True));
140                 aSet.Put(SdrTextAutoGrowHeightItem(sal_False));
141                 aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
142                 aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
143 
144                 pText->SetMergedItemSet(aSet);
145             }
146             if( pObj )
147             {
148                 SdrPageView* pPV = pSdrView->GetSdrPageView();
149                 m_pView->BeginTextEdit( pObj, pPV, m_pWin, sal_True );
150             }
151             m_pView->LeaveDrawCreate();  // In Selektionsmode wechseln
152             m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
153             break;
154 
155         case OBJ_CAPTION:
156         {
157             SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
158             if( bCapVertical && pCaptObj )
159             {
160                 pCaptObj->ForceOutlinerParaObject();
161                 OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
162                 if( pOPO && !pOPO->IsVertical() )
163                     pOPO->SetVertical( sal_True );
164             }
165         }
166         break;
167         default:; //prevent warning
168         }
169     }
170     return bRet;
171 }
172 
173 /*************************************************************************
174 |*
175 |* Function aktivieren
176 |*
177 \************************************************************************/
178 
179 void ConstRectangle::Activate(const sal_uInt16 nSlotId)
180 {
181     bMarquee = bCapVertical = sal_False;
182     mbVertical = sal_False;
183 
184     switch (nSlotId)
185     {
186     case SID_DRAW_LINE:
187         m_pWin->SetSdrDrawMode(OBJ_LINE);
188         break;
189 
190     case SID_DRAW_RECT:
191         m_pWin->SetSdrDrawMode(OBJ_RECT);
192         break;
193 
194     case SID_DRAW_ELLIPSE:
195         m_pWin->SetSdrDrawMode(OBJ_CIRC);
196         break;
197 
198     case SID_DRAW_TEXT_MARQUEE:
199         bMarquee = sal_True;
200         m_pWin->SetSdrDrawMode(OBJ_TEXT);
201         break;
202 
203     case SID_DRAW_TEXT_VERTICAL:
204         // #93382#
205         mbVertical = sal_True;
206         m_pWin->SetSdrDrawMode(OBJ_TEXT);
207         break;
208 
209     case SID_DRAW_TEXT:
210         m_pWin->SetSdrDrawMode(OBJ_TEXT);
211         break;
212 
213     case SID_DRAW_CAPTION_VERTICAL:
214         bCapVertical = sal_True;
215         // no break
216     case SID_DRAW_CAPTION:
217         m_pWin->SetSdrDrawMode(OBJ_CAPTION);
218         break;
219 
220     default:
221         m_pWin->SetSdrDrawMode(OBJ_NONE);
222         break;
223     }
224 
225     SwDrawBase::Activate(nSlotId);
226 }
227 
228 
229 
230