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: drviews8.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_sd.hxx"
34 #include "DrawViewShell.hxx"
36 #include "ViewShellHint.hxx"
38 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
39 #include <toolkit/unohlp.hxx>
41 #include <sfx2/dispatch.hxx>
43 #include <svx/svxids.hrc>
45 #include <vcl/msgbox.hxx>
46 #include <svx/svddef.hxx>
47 #include <sfx2/bindings.hxx>
48 #include <sfx2/request.hxx>
49 #include <sfx2/viewfrm.hxx>
50 #include <svx/svdograf.hxx>
51 #include <svx/svdpagv.hxx>
54 #include "strings.hrc"
58 #include "fudspord.hxx"
59 #include "futransf.hxx"
63 #include "fuparagr.hxx"
64 #include "fubullet.hxx"
65 #include "futempl.hxx"
66 #include "fuinsert.hxx"
67 #include "fuprlout.hxx"
69 #ifndef SD_FU_OBJECT_ANIMATION_PARAMETERS_HXX
70 #include "fuoaprms.hxx"
73 #ifndef SD_FU_LINE_END_HXX
74 #include "fulinend.hxx"
76 #include "fusnapln.hxx"
77 #include "fuolbull.hxx"
78 #include "fuinsfil.hxx"
81 #include "futxtatt.hxx"
82 #include "fumeasur.hxx"
83 #include "fuconnct.hxx"
84 #include "fumorph.hxx"
86 #include "sdresid.hxx"
88 #include "drawview.hxx"
89 #include "zoomlist.hxx"
90 #include <vos/mutex.hxx>
91 #include <vcl/salbtype.hxx> // FRound
92 #include <vcl/svapp.hxx>
96 /*************************************************************************
98 |* SfxRequests fuer temporaere Funktionen
100 \************************************************************************/
102 void DrawViewShell::FuTemp01(SfxRequest
& rReq
)
104 switch(rReq
.GetSlot())
106 case SID_ATTRIBUTES_LINE
: // BASIC
108 SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
113 case SID_ATTRIBUTES_AREA
: // BASIC
115 SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
120 case SID_ATTR_TRANSFORM
:
122 SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
123 Invalidate(SID_RULER_OBJECT
);
128 case SID_CHAR_DLG
: // BASIC
130 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
137 SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
142 case SID_OUTLINE_BULLET
:
144 SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
149 case FN_INSERT_SOFT_HYPHEN
:
150 case FN_INSERT_HARDHYPHEN
:
151 case FN_INSERT_HARD_SPACE
:
152 case SID_INSERT_RLM
:
153 case SID_INSERT_LRM
:
154 case SID_INSERT_ZWNBSP
:
155 case SID_INSERT_ZWSP
:
158 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
163 case SID_PRESENTATION_LAYOUT
:
165 SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
170 case SID_PASTE_SPECIAL
:
172 SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
178 case SID_INSERT_GRAPHIC
:
180 SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
183 Invalidate(SID_DRAWTBX_INSERT
);
187 case SID_INSERT_AVMEDIA
:
189 SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
194 Invalidate(SID_DRAWTBX_INSERT
);
198 case SID_INSERT_OBJECT
:
199 case SID_INSERT_PLUGIN
:
200 case SID_INSERT_SOUND
:
201 case SID_INSERT_VIDEO
:
202 case SID_INSERT_APPLET
:
203 case SID_INSERT_FLOATINGFRAME
:
204 case SID_INSERT_MATH
:
205 case SID_INSERT_DIAGRAM
:
208 SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
213 Invalidate(SID_DRAWTBX_INSERT
);
217 case SID_COPYOBJECTS
:
219 if ( mpDrawView
->IsPresObjSelected(FALSE
, TRUE
) )
221 ::sd::Window
* pWindow
= GetActiveWindow();
222 InfoBox(pWindow
, String(SdResId(STR_ACTION_NOTPOSSIBLE
) ) ).Execute();
226 if ( mpDrawView
->IsTextEdit() )
228 mpDrawView
->SdrEndTextEdit();
231 SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
238 case SID_INSERTFILE
: // BASIC
240 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START
));
241 SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
242 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END
));
246 Invalidate(SID_DRAWTBX_INSERT
);
250 case SID_SELECT_BACKGROUND
:
251 case SID_PAGESETUP
: // BASIC ??
253 SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
255 rReq
.Ignore (); // es werden eigenstaendige macros generiert !!
260 case SID_ZOOM_PANNING
:
262 mbZoomOnPage
= FALSE
;
263 SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
264 // Beendet sich selbst, kein Cancel() notwendig!
265 Invalidate( SID_ZOOM_TOOLBOX
);
273 SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
274 Invalidate( SID_POSITION
);
276 // Beendet sich selbst, kein Cancel() notwendig!
280 case SID_REVERSE_ORDER
: // BASIC
282 mpDrawView
->ReverseOrderOfMarked();
283 Invalidate( SID_POSITION
);
289 case SID_ANIMATION_EFFECTS
:
291 SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
296 case SID_LINEEND_POLYGON
:
298 SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
303 case SID_CAPTUREPOINT
:
304 // negative Werte um Aufruf aus Menue zu signalisieren
305 maMousePos
= Point(-1,-1);
306 case SID_SET_SNAPITEM
:
308 SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
313 case SID_MANAGE_LINKS
:
315 SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
323 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
329 case SID_TEXTATTR_DLG
:
331 SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
337 case SID_MEASURE_DLG
:
339 SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
345 case SID_CONNECTION_DLG
:
347 SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
353 case SID_CONNECTION_NEW_ROUTING
:
355 SfxItemSet
aDefAttr( GetPool(), SDRATTR_EDGELINE1DELTA
, SDRATTR_EDGELINE3DELTA
);
356 GetView()->SetAttributes( aDefAttr
, TRUE
); // (ReplaceAll)
363 case SID_TWAIN_SELECT
:
367 if( mxScannerManager
.is() )
371 const ::com::sun::star::uno::Sequence
< ::com::sun::star::scanner::ScannerContext
>
372 aContexts( mxScannerManager
->getAvailableScanners() );
374 if( aContexts
.getLength() )
376 ::com::sun::star::scanner::ScannerContext
aContext( aContexts
.getConstArray()[ 0 ] );
377 bDone
= mxScannerManager
->configureScanner( aContext
);
390 case SID_TWAIN_TRANSFER
:
394 if( mxScannerManager
.is() )
398 const ::com::sun::star::uno::Sequence
< ::com::sun::star::scanner::ScannerContext
> aContexts( mxScannerManager
->getAvailableScanners() );
400 if( aContexts
.getLength() )
402 mxScannerManager
->startScan( aContexts
.getConstArray()[ 0 ], mxScannerListener
);
414 const USHORT nId
= STR_TWAIN_NO_SOURCE
;
416 const USHORT nId
= STR_TWAIN_NO_SOURCE_UNX
;
419 ::sd::Window
* pWindow
= GetActiveWindow();
420 InfoBox(pWindow
, String( SdResId( nId
) ) ).Execute();
424 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
425 rBindings
.Invalidate( SID_TWAIN_SELECT
);
426 rBindings
.Invalidate( SID_TWAIN_TRANSFER
);
434 case SID_POLYGON_MORPHING
:
436 SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
443 SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView
, GetDoc(), rReq
) );
450 // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
451 // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8),
452 // FuTemp02 (drviewsb) gewandert.
459 /*************************************************************************
463 \************************************************************************/
465 void DrawViewShell::ScannerEvent( const ::com::sun::star::lang::EventObject
& )
467 if( mxScannerManager
.is() )
469 const ::com::sun::star::scanner::ScannerContext
aContext( mxScannerManager
->getAvailableScanners().getConstArray()[ 0 ] );
470 const ::com::sun::star::scanner::ScanError eError
= mxScannerManager
->getError( aContext
);
472 if( ::com::sun::star::scanner::ScanError_ScanErrorNone
== eError
)
474 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XBitmap
> xBitmap( mxScannerManager
->getBitmap( aContext
) );
478 const BitmapEx
aScanBmp( VCLUnoHelper::GetBitmap( xBitmap
) );
482 const ::vos::OGuard
aGuard( Application::GetSolarMutex() );
483 SdrPage
* pPage
= mpDrawView
->GetSdrPageView()->GetPage();
484 Size
aBmpSize( aScanBmp
.GetPrefSize() ), aPageSize( pPage
->GetSize() );
485 const MapMode
aMap100( MAP_100TH_MM
);
487 if( !aBmpSize
.Width() || !aBmpSize
.Height() )
488 aBmpSize
= aScanBmp
.GetSizePixel();
490 if( aScanBmp
.GetPrefMapMode().GetMapUnit() == MAP_PIXEL
)
491 aBmpSize
= GetActiveWindow()->PixelToLogic( aBmpSize
, aMap100
);
493 aBmpSize
= OutputDevice::LogicToLogic( aBmpSize
, aScanBmp
.GetPrefMapMode(), aMap100
);
495 aPageSize
.Width() -= pPage
->GetLftBorder() + pPage
->GetRgtBorder();
496 aPageSize
.Height() -= pPage
->GetUppBorder() + pPage
->GetLwrBorder();
498 if( ( ( aBmpSize
.Height() > aPageSize
.Height() ) || ( aBmpSize
.Width() > aPageSize
.Width() ) ) && aBmpSize
.Height() && aPageSize
.Height() )
500 double fGrfWH
= (double) aBmpSize
.Width() / aBmpSize
.Height();
501 double fWinWH
= (double) aPageSize
.Width() / aPageSize
.Height();
503 if( fGrfWH
< fWinWH
)
505 aBmpSize
.Width() = FRound( aPageSize
.Height() * fGrfWH
);
506 aBmpSize
.Height()= aPageSize
.Height();
508 else if( fGrfWH
> 0.F
)
510 aBmpSize
.Width() = aPageSize
.Width();
511 aBmpSize
.Height()= FRound( aPageSize
.Width() / fGrfWH
);
515 Point
aPnt ( ( aPageSize
.Width() - aBmpSize
.Width() ) >> 1, ( aPageSize
.Height() - aBmpSize
.Height() ) >> 1 );
516 aPnt
+= Point( pPage
->GetLftBorder(), pPage
->GetUppBorder() );
517 Rectangle
aRect( aPnt
, aBmpSize
);
518 SdrGrafObj
* pGrafObj
= NULL
;
519 BOOL bInsertNewObject
= TRUE
;
521 if( GetView()->AreObjectsMarked() )
523 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
525 if( rMarkList
.GetMarkCount() == 1 )
527 SdrMark
* pMark
= rMarkList
.GetMark(0);
528 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
530 if( pObj
->ISA( SdrGrafObj
) )
532 pGrafObj
= static_cast< SdrGrafObj
* >( pObj
);
534 if( pGrafObj
->IsEmptyPresObj() )
536 bInsertNewObject
= FALSE
;
537 pGrafObj
->SetEmptyPresObj(FALSE
);
538 pGrafObj
->SetOutlinerParaObject(NULL
);
539 pGrafObj
->SetGraphic( Graphic( aScanBmp
) );
545 if( bInsertNewObject
)
547 pGrafObj
= new SdrGrafObj( Graphic( aScanBmp
), aRect
);
548 SdrPageView
* pPV
= GetView()->GetSdrPageView();
549 GetView()->InsertObjectAtView( pGrafObj
, *pPV
, SDRINSERT_SETDEFLAYER
);
556 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
557 rBindings
.Invalidate( SID_TWAIN_SELECT
);
558 rBindings
.Invalidate( SID_TWAIN_TRANSFER
);
561 } // end of namespace sd