1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conrect.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <sfx2/bindings.hxx>
36 #include <svx/htmlmode.hxx>
37 #include <svx/sdtacitm.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/sdtagitm.hxx>
40 #include <svx/sdtakitm.hxx>
41 #include <svx/sdtaditm.hxx>
42 #include <svx/sdtaaitm.hxx>
43 #include <svx/svdview.hxx>
44 #include <svx/svdocapt.hxx>
45 #include <svx/outlobj.hxx>
54 #include <viewopt.hxx>
56 #include <drawbase.hxx>
59 #include <conrect.hxx>
62 /*************************************************************************
66 \************************************************************************/
68 ConstRectangle::ConstRectangle( SwWrtShell
* pWrtShell
, SwEditWin
* pEditWin
,
70 : SwDrawBase( pWrtShell
, pEditWin
, pSwView
),
77 /*************************************************************************
79 |* MouseButtonDown-event
81 \************************************************************************/
83 BOOL
ConstRectangle::MouseButtonDown(const MouseEvent
& rMEvt
)
87 if ((bReturn
= SwDrawBase::MouseButtonDown(rMEvt
)) == TRUE
88 && m_pWin
->GetSdrDrawMode() == OBJ_CAPTION
)
91 if (m_pView
->IsDrawSelMode())
93 m_pView
->FlipDrawSelMode();
94 m_pSh
->GetDrawView()->SetFrameDragSingles(m_pView
->IsDrawSelMode());
100 /*************************************************************************
102 |* MouseButtonUp-event
104 \************************************************************************/
106 BOOL
ConstRectangle::MouseButtonUp(const MouseEvent
& rMEvt
)
108 Point
aPnt(m_pWin
->PixelToLogic(rMEvt
.GetPosPixel()));
110 BOOL bRet
= SwDrawBase::MouseButtonUp(rMEvt
);
113 SdrView
*pSdrView
= m_pSh
->GetDrawView();
114 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
115 SdrObject
* pObj
= rMarkList
.GetMark(0) ? rMarkList
.GetMark(0)->GetMarkedSdrObj()
117 switch( m_pWin
->GetSdrDrawMode() )
122 m_pSh
->ChgAnchor(FLY_IN_CNTNT
);
126 // die fuer das Scrollen benoetigten Attribute setzen
127 SfxItemSet
aItemSet( pSdrView
->GetModel()->GetItemPool(),
128 SDRATTR_MISC_FIRST
, SDRATTR_MISC_LAST
);
130 aItemSet
.Put( SdrTextAutoGrowWidthItem( FALSE
) );
131 aItemSet
.Put( SdrTextAutoGrowHeightItem( FALSE
) );
132 aItemSet
.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL
) );
133 aItemSet
.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT
) );
134 aItemSet
.Put( SdrTextAniCountItem( 0 ) );
135 aItemSet
.Put( SdrTextAniAmountItem(
136 (INT16
)m_pWin
->PixelToLogic(Size(2,1)).Width()) );
138 pObj
->SetMergedItemSetAndBroadcast(aItemSet
);
141 else if(mbVertical
&& pObj
&& pObj
->ISA(SdrTextObj
))
144 SdrTextObj
* pText
= (SdrTextObj
*)pObj
;
145 SfxItemSet
aSet(pSdrView
->GetModel()->GetItemPool());
147 pText
->SetVerticalWriting(TRUE
);
149 aSet
.Put(SdrTextAutoGrowWidthItem(TRUE
));
150 aSet
.Put(SdrTextAutoGrowHeightItem(FALSE
));
151 aSet
.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP
));
152 aSet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT
));
154 pText
->SetMergedItemSet(aSet
);
158 SdrPageView
* pPV
= pSdrView
->GetSdrPageView();
159 m_pView
->BeginTextEdit( pObj
, pPV
, m_pWin
, sal_True
);
161 m_pView
->LeaveDrawCreate(); // In Selektionsmode wechseln
162 m_pSh
->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW
);
167 SdrCaptionObj
* pCaptObj
= dynamic_cast<SdrCaptionObj
*>(pObj
);
168 if( bCapVertical
&& pCaptObj
)
170 pCaptObj
->ForceOutlinerParaObject();
171 OutlinerParaObject
* pOPO
= pCaptObj
->GetOutlinerParaObject();
172 if( pOPO
&& !pOPO
->IsVertical() )
173 pOPO
->SetVertical( TRUE
);
177 default:; //prevent warning
183 /*************************************************************************
185 |* Function aktivieren
187 \************************************************************************/
189 void ConstRectangle::Activate(const USHORT nSlotId
)
191 bMarquee
= bCapVertical
= FALSE
;
192 mbVertical
= sal_False
;
197 m_pWin
->SetSdrDrawMode(OBJ_LINE
);
201 m_pWin
->SetSdrDrawMode(OBJ_RECT
);
204 case SID_DRAW_ELLIPSE
:
205 m_pWin
->SetSdrDrawMode(OBJ_CIRC
);
208 case SID_DRAW_TEXT_MARQUEE
:
210 m_pWin
->SetSdrDrawMode(OBJ_TEXT
);
213 case SID_DRAW_TEXT_VERTICAL
:
215 mbVertical
= sal_True
;
216 m_pWin
->SetSdrDrawMode(OBJ_TEXT
);
220 m_pWin
->SetSdrDrawMode(OBJ_TEXT
);
223 case SID_DRAW_CAPTION_VERTICAL
:
226 case SID_DRAW_CAPTION
:
227 m_pWin
->SetSdrDrawMode(OBJ_CAPTION
);
231 m_pWin
->SetSdrDrawMode(OBJ_NONE
);
235 SwDrawBase::Activate(nSlotId
);