Line data Source code
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 <sfx2/bindings.hxx>
21 : #include <sfx2/htmlmode.hxx>
22 : #include <svx/sdtacitm.hxx>
23 : #include <svx/svdobj.hxx>
24 : #include <svx/sdtagitm.hxx>
25 : #include <svx/sdtakitm.hxx>
26 : #include <svx/sdtaditm.hxx>
27 : #include <svx/sdtaaitm.hxx>
28 : #include <svx/svdview.hxx>
29 : #include <svx/svdocapt.hxx>
30 : #include <editeng/outlobj.hxx>
31 : #include <cmdid.h>
32 : #include <view.hxx>
33 : #include <edtwin.hxx>
34 : #include <wrtsh.hxx>
35 : #include <viewopt.hxx>
36 : #include <drawbase.hxx>
37 : #include <conrect.hxx>
38 :
39 0 : ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
40 : SwView* pSwView )
41 : : SwDrawBase( pWrtShell, pEditWin, pSwView ),
42 : bMarquee(false),
43 : // #93382#
44 0 : mbVertical(false)
45 : {
46 0 : }
47 :
48 0 : sal_Bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
49 : {
50 : sal_Bool bReturn;
51 :
52 0 : if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True
53 0 : && m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
54 : {
55 0 : m_pView->NoRotate();
56 0 : if (m_pView->IsDrawSelMode())
57 : {
58 0 : m_pView->FlipDrawSelMode();
59 0 : m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
60 : }
61 : }
62 0 : return (bReturn);
63 : }
64 :
65 0 : sal_Bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
66 : {
67 0 : sal_Bool bRet = SwDrawBase::MouseButtonUp(rMEvt);
68 0 : if( bRet )
69 : {
70 0 : SdrView *pSdrView = m_pSh->GetDrawView();
71 0 : const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
72 0 : SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
73 0 : : 0;
74 0 : switch( m_pWin->GetSdrDrawMode() )
75 : {
76 : case OBJ_TEXT:
77 0 : if( bMarquee )
78 : {
79 0 : m_pSh->ChgAnchor(FLY_AS_CHAR);
80 :
81 0 : if( pObj )
82 : {
83 : // Set the attributes needed for scrolling
84 0 : SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
85 0 : SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
86 :
87 0 : aItemSet.Put( SdrTextAutoGrowWidthItem( false ) );
88 0 : aItemSet.Put( SdrTextAutoGrowHeightItem( false ) );
89 0 : aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
90 0 : aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
91 0 : aItemSet.Put( SdrTextAniCountItem( 0 ) );
92 : aItemSet.Put( SdrTextAniAmountItem(
93 0 : (sal_Int16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
94 :
95 0 : pObj->SetMergedItemSetAndBroadcast(aItemSet);
96 : }
97 : }
98 0 : else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
99 : {
100 0 : SdrTextObj* pText = (SdrTextObj*)pObj;
101 0 : SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
102 :
103 0 : pText->SetVerticalWriting(true);
104 :
105 0 : aSet.Put(SdrTextAutoGrowWidthItem(true));
106 0 : aSet.Put(SdrTextAutoGrowHeightItem(false));
107 0 : aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
108 0 : aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
109 :
110 0 : pText->SetMergedItemSet(aSet);
111 : }
112 0 : if( pObj )
113 : {
114 0 : SdrPageView* pPV = pSdrView->GetSdrPageView();
115 0 : m_pView->BeginTextEdit( pObj, pPV, m_pWin, true );
116 : }
117 0 : m_pView->LeaveDrawCreate(); // Switch to selection mode
118 0 : m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
119 0 : break;
120 :
121 : case OBJ_CAPTION:
122 : {
123 0 : SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj);
124 0 : if( bCapVertical && pCaptObj )
125 : {
126 0 : pCaptObj->ForceOutlinerParaObject();
127 0 : OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
128 0 : if( pOPO && !pOPO->IsVertical() )
129 0 : pOPO->SetVertical( true );
130 : }
131 : }
132 0 : break;
133 : default:; //prevent warning
134 : }
135 : }
136 0 : return bRet;
137 : }
138 :
139 0 : void ConstRectangle::Activate(const sal_uInt16 nSlotId)
140 : {
141 0 : bMarquee = bCapVertical = false;
142 0 : mbVertical = false;
143 :
144 0 : switch (nSlotId)
145 : {
146 : case SID_DRAW_LINE:
147 0 : m_pWin->SetSdrDrawMode(OBJ_LINE);
148 0 : break;
149 :
150 : case SID_DRAW_RECT:
151 0 : m_pWin->SetSdrDrawMode(OBJ_RECT);
152 0 : break;
153 :
154 : case SID_DRAW_ELLIPSE:
155 0 : m_pWin->SetSdrDrawMode(OBJ_CIRC);
156 0 : break;
157 :
158 : case SID_DRAW_TEXT_MARQUEE:
159 0 : bMarquee = true;
160 0 : m_pWin->SetSdrDrawMode(OBJ_TEXT);
161 0 : break;
162 :
163 : case SID_DRAW_TEXT_VERTICAL:
164 0 : mbVertical = true;
165 0 : m_pWin->SetSdrDrawMode(OBJ_TEXT);
166 0 : break;
167 :
168 : case SID_DRAW_TEXT:
169 0 : m_pWin->SetSdrDrawMode(OBJ_TEXT);
170 0 : break;
171 :
172 : case SID_DRAW_CAPTION_VERTICAL:
173 0 : bCapVertical = true;
174 : // no break
175 : case SID_DRAW_CAPTION:
176 0 : m_pWin->SetSdrDrawMode(OBJ_CAPTION);
177 0 : break;
178 :
179 : default:
180 0 : m_pWin->SetSdrDrawMode(OBJ_NONE);
181 0 : break;
182 : }
183 :
184 0 : SwDrawBase::Activate(nSlotId);
185 0 : }
186 :
187 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|