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