Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <sfx2/bindings.hxx>
30 : : #include <svx/htmlmode.hxx>
31 : : #include <svx/sdtacitm.hxx>
32 : : #include <svx/svdobj.hxx>
33 : : #include <svx/sdtagitm.hxx>
34 : : #include <svx/sdtakitm.hxx>
35 : : #include <svx/sdtaditm.hxx>
36 : : #include <svx/sdtaaitm.hxx>
37 : : #include <svx/svdview.hxx>
38 : : #include <svx/svdocapt.hxx>
39 : : #include <editeng/outlobj.hxx>
40 : : #include <cmdid.h>
41 : : #include <view.hxx>
42 : : #include <edtwin.hxx>
43 : : #include <wrtsh.hxx>
44 : : #include <viewopt.hxx>
45 : : #include <drawbase.hxx>
46 : : #include <concustomshape.hxx>
47 : : #include <svx/gallery.hxx>
48 : : #include <sfx2/request.hxx>
49 : : #include <svx/fmmodel.hxx>
50 : : #include <svl/itempool.hxx>
51 : : #include <svx/svdpage.hxx>
52 : : #include <svx/svdoashp.hxx>
53 : : #include <editeng/adjitem.hxx>
54 : :
55 : : #include <math.h>
56 : :
57 : : /*************************************************************************
58 : : |*
59 : : |* C'Tor
60 : : |*
61 : : \************************************************************************/
62 : 0 : ConstCustomShape::ConstCustomShape( SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView, SfxRequest& rReq )
63 : 0 : : SwDrawBase( pWrtShell, pEditWin, pSwView )
64 : : {
65 [ # # ]: 0 : aCustomShape = ConstCustomShape::GetShapeTypeFromRequest( rReq );
66 : 0 : }
67 : :
68 : 0 : rtl::OUString ConstCustomShape::GetShapeType() const
69 : : {
70 : 0 : return aCustomShape;
71 : : }
72 : :
73 : : //static
74 : 0 : rtl::OUString ConstCustomShape::GetShapeTypeFromRequest( SfxRequest& rReq )
75 : : {
76 : 0 : rtl::OUString aRet;
77 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
78 [ # # ]: 0 : if ( pArgs )
79 : : {
80 [ # # ]: 0 : const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
81 [ # # ]: 0 : aRet = rItm.GetValue();
82 : : }
83 : 0 : return aRet;
84 : : }
85 : :
86 : : /*************************************************************************
87 : : |*
88 : : |* MouseButtonDown-event
89 : : |*
90 : : \************************************************************************/
91 : :
92 : 0 : sal_Bool ConstCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
93 : : {
94 : 0 : sal_Bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
95 [ # # ]: 0 : if ( bReturn )
96 : : {
97 : 0 : SdrView *pSdrView = m_pSh->GetDrawView();
98 [ # # ]: 0 : if ( pSdrView )
99 : : {
100 : 0 : SdrObject* pObj = pSdrView->GetCreateObj();
101 [ # # ]: 0 : if ( pObj )
102 : : {
103 [ # # ]: 0 : SetAttributes( pObj );
104 : 0 : sal_Bool bForceNoFillStyle = sal_False;
105 [ # # ][ # # ]: 0 : if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
106 : 0 : bForceNoFillStyle = sal_True;
107 : :
108 [ # # ]: 0 : SfxItemSet aAttr( m_pView->GetPool() );
109 [ # # ]: 0 : if ( bForceNoFillStyle )
110 [ # # ][ # # ]: 0 : aAttr.Put( XFillStyleItem( XFILL_NONE ) );
[ # # ]
111 [ # # ][ # # ]: 0 : pObj->SetMergedItemSet(aAttr);
112 : : }
113 : : }
114 : : }
115 : 0 : return bReturn;
116 : : }
117 : :
118 : : /*************************************************************************
119 : : |*
120 : : |* MouseButtonUp-event
121 : : |*
122 : : \************************************************************************/
123 : :
124 : 0 : sal_Bool ConstCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
125 : : {
126 : 0 : return SwDrawBase::MouseButtonUp(rMEvt);
127 : : }
128 : :
129 : : /*************************************************************************
130 : : |*
131 : : |* activate function
132 : : |*
133 : : \************************************************************************/
134 : :
135 : 0 : void ConstCustomShape::Activate(const sal_uInt16 nSlotId)
136 : : {
137 : 0 : m_pWin->SetSdrDrawMode( OBJ_CUSTOMSHAPE );
138 : :
139 : 0 : SwDrawBase::Activate(nSlotId);
140 : 0 : }
141 : :
142 : : /*************************************************************************
143 : : |*
144 : : |* applying attributes
145 : : |*
146 : : \************************************************************************/
147 : :
148 : 0 : void ConstCustomShape::SetAttributes( SdrObject* pObj )
149 : : {
150 : 0 : sal_Bool bAttributesAppliedFromGallery = sal_False;
151 : :
152 [ # # ]: 0 : if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
153 : : {
154 [ # # ]: 0 : std::vector< rtl::OUString > aObjList;
155 [ # # ][ # # ]: 0 : if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
156 : : {
157 : : sal_uInt16 i;
158 [ # # ]: 0 : for ( i = 0; i < aObjList.size(); i++ )
159 : : {
160 [ # # ]: 0 : if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
161 : : {
162 [ # # ]: 0 : FmFormModel aFormModel;
163 : 0 : SfxItemPool& rPool = aFormModel.GetItemPool();
164 [ # # ]: 0 : rPool.FreezeIdRanges();
165 [ # # ][ # # ]: 0 : if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
166 : : {
167 [ # # ][ # # ]: 0 : const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
168 [ # # ]: 0 : if( pSourceObj )
169 : : {
170 [ # # ]: 0 : const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
171 [ # # ]: 0 : SfxItemSet aDest( pObj->GetModel()->GetItemPool(), // ranges from SdrAttrObj
172 : : SDRATTR_START, SDRATTR_SHADOW_LAST,
173 : : SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
174 : : SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
175 : : // Graphic Attributes
176 : : SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
177 : : // 3d Properties
178 : : SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
179 : : // CustomShape properties
180 : : SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
181 : : // range from SdrTextObj
182 : : EE_ITEMS_START, EE_ITEMS_END,
183 : : // end
184 [ # # ]: 0 : 0, 0);
185 [ # # ]: 0 : aDest.Set( rSource );
186 [ # # ]: 0 : pObj->SetMergedItemSet( aDest );
187 [ # # ]: 0 : sal_Int32 nAngle = pSourceObj->GetRotateAngle();
188 [ # # ]: 0 : if ( nAngle )
189 : : {
190 : 0 : double a = nAngle * F_PI18000;
191 [ # # ][ # # ]: 0 : pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
[ # # ]
192 : : }
193 [ # # ]: 0 : bAttributesAppliedFromGallery = sal_True;
194 : : }
195 : : }
196 [ # # ]: 0 : break;
197 : : }
198 : : }
199 : 0 : }
200 : : }
201 [ # # ]: 0 : if ( !bAttributesAppliedFromGallery )
202 : : {
203 [ # # ]: 0 : pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
204 [ # # ]: 0 : pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
205 [ # # ]: 0 : pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
206 [ # # ]: 0 : pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
207 : 0 : ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
208 : : }
209 : 0 : }
210 : :
211 : 0 : void ConstCustomShape::CreateDefaultObject()
212 : : {
213 : 0 : SwDrawBase::CreateDefaultObject();
214 : 0 : SdrView *pSdrView = m_pSh->GetDrawView();
215 [ # # ]: 0 : if ( pSdrView )
216 : : {
217 : 0 : const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
218 [ # # ]: 0 : if ( rMarkList.GetMarkCount() == 1 )
219 : : {
220 : 0 : SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
221 [ # # ][ # # ]: 0 : if ( pObj && pObj->ISA( SdrObjCustomShape ) )
[ # # ]
222 : 0 : SetAttributes( pObj );
223 : : }
224 : : }
225 : 0 : }
226 : :
227 : : // #i33136#
228 : 0 : bool ConstCustomShape::doConstructOrthogonal() const
229 : : {
230 : 0 : return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
231 : : }
232 : :
233 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|