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_sd.hxx" 30 31 #include "fuconcs.hxx" 32 #include <svx/svdpagv.hxx> 33 34 35 #include <svx/svxids.hrc> 36 #include <svx/dialogs.hrc> 37 #include <svx/dialmgr.hxx> 38 39 #include "app.hrc" 40 #include <svl/aeitem.hxx> 41 #include <svx/xlnstwit.hxx> 42 #include <svx/xlnedwit.hxx> 43 #include <svx/xlnedit.hxx> 44 #include <svx/xlnstit.hxx> 45 #include <svx/xlnwtit.hxx> 46 #include <sfx2/viewfrm.hxx> 47 #include <svx/sdtmfitm.hxx> 48 #include <svx/sxekitm.hxx> 49 #include <svx/sderitm.hxx> 50 #include <sfx2/dispatch.hxx> 51 #include <svx/svdopath.hxx> 52 #include <svx/svdocirc.hxx> 53 #include <svl/intitem.hxx> 54 #include <sfx2/request.hxx> 55 #include <editeng/adjitem.hxx> 56 #include <svx/xtable.hxx> 57 #include <svx/sdasitm.hxx> 58 #include <svx/tbxcustomshapes.hxx> 59 #include <svx/svdoashp.hxx> 60 #include <svx/sdtagitm.hxx> 61 62 // #88751# 63 #include <svx/svdocapt.hxx> 64 65 // #97016# 66 #include <svx/svdomeas.hxx> 67 #include "ViewShell.hxx" 68 #include "ViewShellBase.hxx" 69 #include "ToolBarManager.hxx" 70 // #109583# 71 #include <editeng/writingmodeitem.hxx> 72 #include <svx/gallery.hxx> 73 #include <svl/itempool.hxx> 74 #include <com/sun/star/uno/Any.hxx> 75 76 #include "sdresid.hxx" 77 #include "View.hxx" 78 #include "sdpage.hxx" 79 #include "Window.hxx" 80 #include "stlpool.hxx" 81 #include "drawdoc.hxx" 82 #include "res_bmp.hrc" 83 #include "glob.hrc" 84 85 namespace sd { 86 87 TYPEINIT1( FuConstructCustomShape, FuConstruct ); 88 89 /************************************************************************* 90 |* 91 |* Konstruktor 92 |* 93 \************************************************************************/ 94 95 FuConstructCustomShape::FuConstructCustomShape ( 96 ViewShell* pViewSh, 97 ::sd::Window* pWin, 98 ::sd::View* pView, 99 SdDrawDocument* pDoc, 100 SfxRequest& rReq ) : 101 FuConstruct(pViewSh, pWin, pView, pDoc, rReq) 102 { 103 } 104 105 FunctionReference FuConstructCustomShape::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent ) 106 { 107 FuConstructCustomShape* pFunc; 108 FunctionReference xFunc( pFunc = new FuConstructCustomShape( pViewSh, pWin, pView, pDoc, rReq ) ); 109 xFunc->DoExecute(rReq); 110 pFunc->SetPermanent( bPermanent ); 111 return xFunc; 112 } 113 114 void FuConstructCustomShape::DoExecute( SfxRequest& rReq ) 115 { 116 FuConstruct::DoExecute( rReq ); 117 118 const SfxItemSet* pArgs = rReq.GetArgs(); 119 if ( pArgs ) 120 { 121 const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() ); 122 aCustomShape = rItm.GetValue(); 123 } 124 125 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar( 126 ToolBarManager::TBG_FUNCTION, 127 ToolBarManager::msDrawingObjectToolBar); 128 } 129 130 /************************************************************************* 131 |* 132 |* MouseButtonDown-event 133 |* 134 \************************************************************************/ 135 136 sal_Bool FuConstructCustomShape::MouseButtonDown(const MouseEvent& rMEvt) 137 { 138 sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt); 139 140 if ( rMEvt.IsLeft() && !mpView->IsAction() ) 141 { 142 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 143 144 mpWindow->CaptureMouse(); 145 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() ); 146 147 mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog); 148 149 SdrObject* pObj = mpView->GetCreateObj(); 150 if ( pObj ) 151 { 152 SetAttributes( pObj ); 153 sal_Bool bForceFillStyle = sal_True; 154 sal_Bool bForceNoFillStyle = sal_False; 155 if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() ) 156 { 157 bForceFillStyle = sal_False; 158 bForceNoFillStyle = sal_True; 159 } 160 SfxItemSet aAttr(mpDoc->GetPool()); 161 SetStyleSheet( aAttr, pObj, bForceFillStyle, bForceNoFillStyle ); 162 pObj->SetMergedItemSet(aAttr); 163 } 164 } 165 166 return bReturn; 167 } 168 169 /************************************************************************* 170 |* 171 |* MouseMove-event 172 |* 173 \************************************************************************/ 174 175 sal_Bool FuConstructCustomShape::MouseMove(const MouseEvent& rMEvt) 176 { 177 return FuConstruct::MouseMove(rMEvt); 178 } 179 180 /************************************************************************* 181 |* 182 |* MouseButtonUp-event 183 |* 184 \************************************************************************/ 185 186 sal_Bool FuConstructCustomShape::MouseButtonUp(const MouseEvent& rMEvt) 187 { 188 sal_Bool bReturn(sal_False); 189 190 if(mpView->IsCreateObj() && rMEvt.IsLeft()) 191 { 192 SdrObject* pObj = mpView->GetCreateObj(); 193 if( pObj && mpView->EndCreateObj( SDRCREATE_FORCEEND ) ) 194 { 195 bReturn = sal_True; 196 } 197 } 198 bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn; 199 200 if (!bPermanent) 201 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON); 202 203 return bReturn; 204 } 205 206 /************************************************************************* 207 |* 208 |* Tastaturereignisse bearbeiten 209 |* 210 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 211 |* sal_False. 212 |* 213 \************************************************************************/ 214 215 sal_Bool FuConstructCustomShape::KeyInput(const KeyEvent& rKEvt) 216 { 217 sal_Bool bReturn = FuConstruct::KeyInput(rKEvt); 218 return(bReturn); 219 } 220 221 /************************************************************************* 222 |* 223 |* Function aktivieren 224 |* 225 \************************************************************************/ 226 227 void FuConstructCustomShape::Activate() 228 { 229 mpView->SetCurrentObj( OBJ_CUSTOMSHAPE ); 230 FuConstruct::Activate(); 231 } 232 233 /************************************************************************* 234 |* 235 |* Attribute fuer das zu erzeugende Objekt setzen 236 |* 237 \************************************************************************/ 238 239 void FuConstructCustomShape::SetAttributes( SdrObject* pObj ) 240 { 241 sal_Bool bAttributesAppliedFromGallery = sal_False; 242 243 if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) 244 { 245 std::vector< rtl::OUString > aObjList; 246 if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) 247 { 248 sal_uInt16 i; 249 for ( i = 0; i < aObjList.size(); i++ ) 250 { 251 if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) ) 252 { 253 FmFormModel aFormModel; 254 SfxItemPool& rPool = aFormModel.GetItemPool(); 255 rPool.FreezeIdRanges(); 256 if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) ) 257 { 258 const SdrPage* pPage = aFormModel.GetPage( 0 ); 259 if ( pPage ) 260 { 261 const SdrObject* pSourceObj = pPage->GetObj( 0 ); 262 if( pSourceObj ) 263 { 264 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); 265 SfxItemSet aDest( pObj->GetModel()->GetItemPool(), // ranges from SdrAttrObj 266 SDRATTR_START, SDRATTR_SHADOW_LAST, 267 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, 268 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 269 // Graphic Attributes 270 SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, 271 // 3d Properties 272 SDRATTR_3D_FIRST, SDRATTR_3D_LAST, 273 // CustomShape properties 274 SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST, 275 // range from SdrTextObj 276 EE_ITEMS_START, EE_ITEMS_END, 277 // end 278 0, 0); 279 aDest.Set( rSource ); 280 pObj->SetMergedItemSet( aDest ); 281 sal_Int32 nAngle = pSourceObj->GetRotateAngle(); 282 if ( nAngle ) 283 { 284 double a = nAngle * F_PI18000; 285 pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); 286 } 287 bAttributesAppliedFromGallery = sal_True; 288 289 290 /* 291 com::sun::star::uno::Any aAny; 292 if ( ((SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )).QueryValue( aAny ) ) 293 { 294 aGeometryItem.PutValue( aAny ); 295 pObj->SetMergedItem( aGeometryItem ); 296 bAttributesAppliedFromGallery = sal_True; 297 } 298 */ 299 } 300 } 301 } 302 break; 303 } 304 } 305 } 306 } 307 if ( !bAttributesAppliedFromGallery ) 308 { 309 pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) ); 310 pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); 311 pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) ); 312 pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) ); 313 ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape ); 314 } 315 } 316 317 // #97016# 318 SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle) 319 { 320 SdrObject* pObj = SdrObjFactory::MakeNewObject( 321 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(), 322 0L, mpDoc); 323 324 if( pObj ) 325 { 326 Rectangle aRect( rRectangle ); 327 if ( doConstructOrthogonal() ) 328 ImpForceQuadratic( aRect ); 329 pObj->SetLogicRect( aRect ); 330 SetAttributes( pObj ); 331 SfxItemSet aAttr(mpDoc->GetPool()); 332 SetStyleSheet(aAttr, pObj); 333 pObj->SetMergedItemSet(aAttr); 334 } 335 return pObj; 336 } 337 338 // #i33136# 339 bool FuConstructCustomShape::doConstructOrthogonal() const 340 { 341 return SdrObjCustomShape::doConstructOrthogonal(aCustomShape); 342 } 343 344 } // end of namespace sd 345