1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
28
29 #include "DrawViewShell.hxx"
30 #include <vcl/msgbox.hxx>
31 #include <svl/urlbmk.hxx>
32 #include <svx/svdpagv.hxx>
33 #include <svx/svdundo.hxx>
34 #include <svx/fmglob.hxx>
35 #include <editeng/eeitem.hxx>
36 #ifndef _FLDITEM_HXX
37 #include <editeng/flditem.hxx>
38 #endif
39 #ifndef _SVXIDS_HRC
40 #include <svx/svxids.hrc>
41 #endif
42 #include <svx/ruler.hxx>
43 #ifndef _GLOBL3D_HXX
44 #include <svx/globl3d.hxx>
45 #endif
46 #include <editeng/outliner.hxx>
47 #ifndef _SFX_CLIENTSH_HXX
48 #include <sfx2/ipclient.hxx>
49 #endif
50 #include <sfx2/request.hxx>
51 #include <sfx2/dispatch.hxx>
52 #include <svx/svdopath.hxx>
53 #include <sfx2/viewfrm.hxx>
54 #include <editeng/editview.hxx>
55 #include <vcl/cursor.hxx>
56
57
58 #include "app.hrc"
59 #include "glob.hrc"
60 #include "strings.hrc"
61 #include "res_bmp.hrc"
62 #include "DrawDocShell.hxx"
63 #include "drawdoc.hxx"
64 #include "Window.hxx"
65 #include "fupoor.hxx"
66 #include "fusnapln.hxx"
67 #include "app.hxx"
68 #include "Ruler.hxx"
69 #include "sdresid.hxx"
70 #include "GraphicViewShell.hxx"
71 #include "sdpage.hxx"
72 #include "slideshow.hxx"
73 #include "anminfo.hxx"
74 #include "sdpopup.hxx"
75 #include "drawview.hxx"
76 #include <svx/bmpmask.hxx>
77 #include "LayerTabBar.hxx"
78
79 // #97016# IV
80 #include <svx/svditer.hxx>
81
82 #include <navigatr.hxx>
83 namespace sd {
84
85 #define PIPETTE_RANGE 0
86
87 #ifdef _MSC_VER
88 #pragma optimize ( "", off )
89 #endif
90
91 using namespace ::com::sun::star::uno;
92 using namespace ::com::sun::star::drawing;
93
94 /*************************************************************************
95 |*
96 |* aktuelle Seite loeschen
97 |*
98 \************************************************************************/
99
DeleteActualPage()100 void DrawViewShell::DeleteActualPage()
101 {
102 sal_uInt16 nPage = maTabControl.GetCurPageId() - 1;
103
104 mpDrawView->SdrEndTextEdit();
105
106 try
107 {
108 Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
109 Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
110 Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
111 xPages->remove( xPage );
112 }
113 catch( Exception& )
114 {
115 DBG_ERROR("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
116 }
117 }
118
119 /*************************************************************************
120 |*
121 |* aktuelle Ebene loeschen
122 |*
123 \************************************************************************/
124
DeleteActualLayer()125 void DrawViewShell::DeleteActualLayer()
126 {
127 if(!GetLayerTabControl()) // #87182#
128 {
129 OSL_ENSURE(false, "No LayerTabBar (!)");
130 return;
131 }
132
133 SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
134 const String& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId());
135 String aString(SdResId(STR_ASK_DELETE_LAYER));
136
137 // Platzhalter ersetzen
138 sal_uInt16 nPos = aString.Search(sal_Unicode('$'));
139 aString.Erase(nPos, 1);
140 aString.Insert(rName, nPos);
141
142 if (QueryBox(GetActiveWindow(), WB_YES_NO, aString).Execute() == RET_YES)
143 {
144 const SdrLayer* pLayer = rAdmin.GetLayer(rName, sal_False);
145 mpDrawView->DeleteLayer( pLayer->GetName() );
146
147 // damit TabBar und Window neu gezeichnet werden;
148 // sollte spaeter wie beim Aendern der Layerfolge durch einen
149 // Hint von Joe angestossen werden
150 // ( View::Notify() --> ViewShell::ResetActualLayer() )
151
152 mbIsLayerModeActive = false; // damit ChangeEditMode() ueberhaupt was tut
153 ChangeEditMode(GetEditMode(), true);
154 }
155 }
156
157
158 /*************************************************************************
159 |*
160 |* Keyboard event
161 |*
162 \************************************************************************/
163
KeyInput(const KeyEvent & rKEvt,::sd::Window * pWin)164 sal_Bool DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin)
165 {
166 sal_Bool bRet = sal_False;
167
168 if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) )
169 {
170 // #97016# IV
171 if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
172 && rKEvt.GetKeyCode().IsMod1()
173 && GetView()->IsTextEdit())
174 {
175 // this should be used for cursor travelling.
176 SdPage* pActualPage = GetActualPage();
177 const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
178 SdrTextObj* pCandidate = 0L;
179
180 if(pActualPage && 1 == rMarkList.GetMarkCount())
181 {
182 SdrMark* pMark = rMarkList.GetMark(0);
183
184 // remember which object was the text in edit mode
185 SdrObject* pOldObj = pMark->GetMarkedSdrObj();
186
187 // end text edit now
188 GetView()->SdrEndTextEdit();
189
190 // look for a new candidate, a successor of pOldObj
191 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
192 sal_Bool bDidVisitOldObject(sal_False);
193
194 while(aIter.IsMore() && !pCandidate)
195 {
196 SdrObject* pObj = aIter.Next();
197
198 if(pObj && pObj->ISA(SdrTextObj))
199 {
200 sal_uInt32 nInv(pObj->GetObjInventor());
201 sal_uInt16 nKnd(pObj->GetObjIdentifier());
202
203 if(SdrInventor == nInv &&
204 (OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd)
205 && bDidVisitOldObject)
206 {
207 pCandidate = (SdrTextObj*)pObj;
208 }
209
210 if(pObj == pOldObj)
211 {
212 bDidVisitOldObject = sal_True;
213 }
214 }
215 }
216 }
217
218 if(pCandidate)
219 {
220 // set the new candidate to text edit mode
221 GetView()->UnMarkAll();
222 GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView());
223
224 GetViewFrame()->GetDispatcher()->Execute(
225 SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON);
226 }
227 else
228 {
229 // insert a new page with the same page layout
230 GetViewFrame()->GetDispatcher()->Execute(
231 SID_INSERTPAGE_QUICK, SFX_CALLMODE_ASYNCHRON);
232 }
233 }
234 else
235 {
236 bRet = ViewShell::KeyInput(rKEvt, pWin);
237 //Solution: If object is marked , the corresponding entry is set true ,
238 //else the corresponding entry is set false .
239 if(KEY_TAB == rKEvt.GetKeyCode().GetCode())
240 {
241 FreshNavigatrTree();
242 }
243 }
244 }
245
246 return bRet;
247 }
248
249 /*************************************************************************
250 |*
251 |* Vom Lineal ausgehenden Drag (Hilflinien, Ursprung) beginnen
252 |*
253 \************************************************************************/
254
StartRulerDrag(const Ruler & rRuler,const MouseEvent & rMEvt)255 void DrawViewShell::StartRulerDrag (
256 const Ruler& rRuler,
257 const MouseEvent& rMEvt)
258 {
259 GetActiveWindow()->CaptureMouse();
260
261 Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel());
262
263 if ( rRuler.GetExtraRect().IsInside(rMEvt.GetPosPixel()) )
264 {
265 mpDrawView->BegSetPageOrg(aWPos);
266 mbIsRulerDrag = sal_True;
267 }
268 else
269 {
270 // #i34536# if no guide-lines are visible yet, that show them
271 if( ! mpDrawView->IsHlplVisible())
272 mpDrawView->SetHlplVisible( sal_True );
273
274 SdrHelpLineKind eKind;
275
276 if ( rMEvt.IsMod1() )
277 eKind = SDRHELPLINE_POINT;
278 else if ( rRuler.IsHorizontal() )
279 eKind = SDRHELPLINE_HORIZONTAL;
280 else
281 eKind = SDRHELPLINE_VERTICAL;
282
283 mpDrawView->BegDragHelpLine(aWPos, eKind);
284 mbIsRulerDrag = sal_True;
285 }
286 }
287 //Solution: If object is marked , the corresponding entry is set true ,
288 //else the corresponding entry is set false .
FreshNavigatrEntry()289 void DrawViewShell::FreshNavigatrEntry()
290 {
291 sal_uInt16 nId = SID_NAVIGATOR;
292 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
293 if( pWindow )
294 {
295 SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
296 if( pNavWin )
297 pNavWin->FreshEntry();
298 }
299 }
300
FreshNavigatrTree()301 void DrawViewShell::FreshNavigatrTree()
302 {
303 sal_uInt16 nId = SID_NAVIGATOR;
304 SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
305 if( pWindow )
306 {
307 SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
308 if( pNavWin )
309 pNavWin->FreshTree( GetDoc() );
310 }
311 }
312 /*************************************************************************
313 |*
314 |* MouseButtonDown event
315 |*
316 \************************************************************************/
317
MouseButtonDown(const MouseEvent & rMEvt,::sd::Window * pWin)318 void DrawViewShell::MouseButtonDown(const MouseEvent& rMEvt,
319 ::sd::Window* pWin)
320 {
321 // We have to check if a context menu is shown and we have an UI
322 // active inplace client. In that case we have to ignore the mouse
323 // button down event. Otherwise we would crash (context menu has been
324 // opened by inplace client and we would deactivate the inplace client,
325 // the context menu is closed by VCL asynchronously which in the end
326 // would work on deleted objects or the context menu has no parent anymore)
327 // See #126086# and #128122#
328 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
329 sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
330
331 if ( bIsOleActive && PopupMenu::IsInExecute() )
332 return;
333
334 if ( !IsInputLocked() )
335 {
336 ViewShell::MouseButtonDown(rMEvt, pWin);
337
338 //Solution: If object is marked , the corresponding entry is set true ,
339 //else the corresponding entry is set false .
340 FreshNavigatrTree();
341 if ( mbPipette )
342 ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->PipetteClicked();
343 }
344 }
345
346 /*************************************************************************
347 |*
348 |* MouseMove event
349 |*
350 \************************************************************************/
351
352
MouseMove(const MouseEvent & rMEvt,::sd::Window * pWin)353 void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
354 {
355 if ( !IsInputLocked() )
356 {
357 if ( mpDrawView->IsAction() )
358 {
359 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
360
361 if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
362 {
363 sal_Bool bInsideOtherWindow = sal_False;
364
365 if (mpContentWindow.get() != NULL)
366 {
367 aOutputArea = Rectangle(Point(0,0),
368 mpContentWindow->GetOutputSizePixel());
369
370 Point aPos = mpContentWindow->GetPointerPosPixel();
371 if ( aOutputArea.IsInside(aPos) )
372 bInsideOtherWindow = sal_True;
373 }
374
375 if (! GetActiveWindow()->HasFocus ())
376 {
377 GetActiveWindow()->ReleaseMouse ();
378 mpDrawView->BrkAction ();
379 return;
380 }
381 else if ( bInsideOtherWindow )
382 {
383 GetActiveWindow()->ReleaseMouse();
384 pWin->CaptureMouse ();
385 }
386 }
387 else if ( pWin != GetActiveWindow() )
388 pWin->CaptureMouse();
389 }
390
391 // #109585#
392 // Since the next MouseMove may execute a IsSolidDraggingNow() in
393 // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
394 // is needed it is necessary to set it here.
395 if(mpDrawView!=NULL && GetDoc()!=NULL)
396 {
397 svtools::ColorConfig aColorConfig;
398 Color aFillColor;
399
400 if(DOCUMENT_TYPE_IMPRESS == GetDoc()->GetDocumentType())
401 {
402 aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
403 }
404 else
405 {
406 aFillColor = Color( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
407 }
408
409 mpDrawView->SetApplicationBackgroundColor(aFillColor);
410 }
411
412 ViewShell::MouseMove(rMEvt, pWin);
413
414 if( !mbMousePosFreezed )
415 maMousePos = rMEvt.GetPosPixel();
416
417 Rectangle aRect;
418
419 if ( mbIsRulerDrag )
420 {
421 Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos);
422 mpDrawView->MovAction(aLogPos);
423 }
424
425 if ( mpDrawView->IsAction() )
426 {
427 mpDrawView->TakeActionRect(aRect);
428 aRect = GetActiveWindow()->LogicToPixel(aRect);
429 }
430 else
431 {
432 aRect = Rectangle(maMousePos, maMousePos);
433 }
434
435 ShowMousePosInfo(aRect, pWin);
436
437 if ( mbPipette && GetViewFrame()->HasChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ) )
438 {
439 const long nStartX = maMousePos.X() - PIPETTE_RANGE;
440 const long nEndX = maMousePos.X() + PIPETTE_RANGE;
441 const long nStartY = maMousePos.Y() - PIPETTE_RANGE;
442 const long nEndY = maMousePos.Y() + PIPETTE_RANGE;
443 long nRed = 0;
444 long nGreen = 0;
445 long nBlue = 0;
446 const double fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
447
448 for ( long nY = nStartY; nY <= nEndY; nY++ )
449 {
450 for( long nX = nStartX; nX <= nEndX; nX++ )
451 {
452 const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
453
454 nRed += aCol.GetRed();
455 nGreen += aCol.GetGreen();
456 nBlue += aCol.GetBlue();
457 }
458 }
459
460 ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
461 SetColor( Color( (sal_uInt8) ( nRed / fDiv + .5 ),
462 (sal_uInt8) ( nGreen / fDiv + .5 ),
463 (sal_uInt8) ( nBlue / fDiv + .5 ) ) );
464 }
465 }
466 }
467
468
469 /*************************************************************************
470 |*
471 |* MouseButtonUp event
472 |*
473 \************************************************************************/
474
MouseButtonUp(const MouseEvent & rMEvt,::sd::Window * pWin)475 void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
476 {
477 if ( !IsInputLocked() )
478 {
479 FASTBOOL bIsSetPageOrg = mpDrawView->IsSetPageOrg();
480
481 if (mbIsRulerDrag)
482 {
483 Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
484
485 if (aOutputArea.IsInside(rMEvt.GetPosPixel()))
486 {
487 mpDrawView->EndAction();
488
489 if (bIsSetPageOrg)
490 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
491 }
492 else if (rMEvt.IsLeft() && bIsSetPageOrg)
493 {
494 mpDrawView->BrkAction();
495 SdPage* pPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
496 Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder());
497 mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
498 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
499 }
500 else
501 {
502 mpDrawView->BrkAction();
503 }
504
505 GetActiveWindow()->ReleaseMouse();
506 mbIsRulerDrag = sal_False;
507 }
508 else
509 ViewShell::MouseButtonUp(rMEvt, pWin);
510 //Solution: If object is marked , the corresponding entry is set true ,
511 //else the corresponding entry is set false .
512 FreshNavigatrTree();
513 }
514 }
515
516 /*************************************************************************
517 |*
518 |* Command event
519 |*
520 \************************************************************************/
521
Command(const CommandEvent & rCEvt,::sd::Window * pWin)522 void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
523 {
524 // The command event is send to the window after a possible context
525 // menu from an inplace client is closed. Now we have the chance to
526 // deactivate the inplace client without any problem regarding parent
527 // windows and code on the stack.
528 // For more information, see #126086# and #128122#
529 SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
530 sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
531 if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
532 {
533 // Deactivate OLE object
534 mpDrawView->UnmarkAll();
535 SelectionHasChanged();
536 return;
537 }
538
539 if ( !IsInputLocked() )
540 {
541 if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
542 return;
543
544 const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
545
546 if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow )
547 {
548 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
549
550 if( aDataHelper.GetTransferable().is() )
551 {
552 Point aPos;
553 sal_Int8 nDnDAction = DND_ACTION_COPY;
554
555 if( GetActiveWindow() )
556 aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
557
558 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, sal_False ) )
559 {
560 INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
561
562 if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
563 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
564 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
565 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
566 ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
567 aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
568 {
569 InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
570 }
571 }
572 }
573 }
574 else if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bNativeShow &&
575 pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
576 {
577 sal_uInt16 nSdResId = 0; // ResourceID fuer Popup-Menue
578 sal_Bool bGraphicShell = this->ISA(GraphicViewShell);
579
580 // Ist ein Fangobjekt unter dem Mauszeiger?
581 SdrPageView* pPV;
582 Point aMPos = pWin->PixelToLogic( maMousePos );
583 sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
584 Size(FuPoor::HITPIX, 0 ) ).Width();
585 sal_uInt16 nHelpLine;
586 // fuer Klebepunkt
587 SdrObject* pObj = NULL;
588 sal_uInt16 nPickId = 0;
589 // fuer Feldbefehl
590 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
591 const SvxFieldItem* pFldItem = NULL;
592 if( pOLV )
593 pFldItem = pOLV->GetFieldAtSelection();
594 //pFldItem = pOLV->GetFieldUnderMousePointer();
595
596 // Hilfslinie
597 if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
598 {
599 nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
600 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
601 return;
602 }
603 // Klebepunkt unter dem Mauszeiger markiert?
604 else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
605 mpDrawView->IsGluePointMarked( pObj, nPickId ) )
606 {
607 nSdResId = RID_DRAW_GLUEPOINT_POPUP;
608 }
609 // Feldbefehl ?
610 else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
611 pFldItem->GetField()->ISA( SvxExtTimeField ) ||
612 pFldItem->GetField()->ISA( SvxExtFileField ) ||
613 pFldItem->GetField()->ISA( SvxAuthorField ) ) )
614 {
615 LanguageType eLanguage( LANGUAGE_SYSTEM );
616
617 // #101743# Format popup with outliner language, if possible
618 if( pOLV->GetOutliner() )
619 {
620 ESelection aSelection( pOLV->GetSelection() );
621 eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
622 }
623
624 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
625
626 if ( rCEvt.IsMouseEvent() )
627 aMPos = rCEvt.GetMousePosPixel();
628 else
629 aMPos = Point( 20, 20 );
630 aFieldPopup.Execute( pWin, aMPos );
631
632 SvxFieldData* pField = aFieldPopup.GetField();
633 if( pField )
634 {
635 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
636 //pOLV->DeleteSelected(); <-- fehlt leider !
637 // Feld selektieren, so dass es beim Insert geloescht wird
638 ESelection aSel = pOLV->GetSelection();
639 sal_Bool bSel = sal_True;
640 if( aSel.nStartPos == aSel.nEndPos )
641 {
642 bSel = sal_False;
643 aSel.nEndPos++;
644 }
645 pOLV->SetSelection( aSel );
646
647 pOLV->InsertField( aFieldItem );
648
649 // Selektion wird wieder in den Ursprungszustand gebracht
650 if( !bSel )
651 aSel.nEndPos--;
652 pOLV->SetSelection( aSel );
653
654 delete pField;
655 }
656 }
657 else
658 {
659 // ist etwas selektiert?
660 if (mpDrawView->AreObjectsMarked() &&
661 mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
662 {
663 pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
664 if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
665 {
666 nSdResId = RID_BEZIER_POPUP;
667 }
668 else
669 {
670 if( mpDrawView->GetTextEditObject() )
671 {
672 OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
673 Point aPos(rCEvt.GetMousePosPixel());
674
675 if ( pOutlinerView )
676 {
677 if( ( rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
678 ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
679 {
680 // #91457# Popup for Online-Spelling now handled by DrawDocShell
681 // Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback);
682 Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
683
684 if( !rCEvt.IsMouseEvent() )
685 {
686 aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
687 }
688 // While showing the spell context menu
689 // we lock the input so that another
690 // context menu can not be opened during
691 // that time (crash #i43235#). In order
692 // to not lock the UI completely we
693 // first release the mouse.
694 GetActiveWindow()->ReleaseMouse();
695 LockInput();
696 pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
697 UnlockInput();
698 }
699 else
700 {
701 if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
702 {
703 nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
704 }
705 else
706 {
707 nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
708 }
709 }
710 }
711 }
712 else
713 {
714 sal_uInt32 nInv = pObj->GetObjInventor();
715 sal_uInt16 nId = pObj->GetObjIdentifier();
716
717 if (nInv == SdrInventor)
718 {
719 switch ( nId )
720 {
721 case OBJ_CAPTION:
722 case OBJ_TITLETEXT:
723 case OBJ_OUTLINETEXT:
724 case OBJ_TEXT:
725 nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
726 RID_DRAW_TEXTOBJ_POPUP;
727 break;
728
729 case OBJ_PATHLINE:
730 case OBJ_PLIN:
731 nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
732 RID_DRAW_POLYLINEOBJ_POPUP;
733 break;
734
735 case OBJ_FREELINE:
736 case OBJ_EDGE: // Connector
737 nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
738 RID_DRAW_EDGEOBJ_POPUP;
739 break;
740
741 case OBJ_LINE:
742 nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
743 RID_DRAW_LINEOBJ_POPUP;
744 break;
745
746 case OBJ_MEASURE:
747 nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
748 RID_DRAW_MEASUREOBJ_POPUP;
749 break;
750
751 case OBJ_RECT:
752 case OBJ_CIRC:
753 case OBJ_FREEFILL:
754 case OBJ_PATHFILL:
755 case OBJ_POLY:
756 case OBJ_SECT:
757 case OBJ_CARC:
758 case OBJ_CCUT:
759 nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
760 RID_DRAW_GEOMOBJ_POPUP;
761 break;
762
763 case OBJ_CUSTOMSHAPE:
764 nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
765 RID_DRAW_CUSTOMSHAPE_POPUP;
766 break;
767
768 case OBJ_GRUP:
769 nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
770 RID_DRAW_GROUPOBJ_POPUP;
771 break;
772
773 case OBJ_GRAF:
774 nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
775 RID_DRAW_GRAPHIC_POPUP;
776 break;
777
778 case OBJ_OLE2:
779 nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
780 RID_DRAW_OLE2_POPUP;
781 break;
782 case OBJ_MEDIA:
783 nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
784 RID_DRAW_MEDIA_POPUP;
785 break;
786 case OBJ_TABLE:
787 nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
788 RID_DRAW_TABLE_POPUP;
789 break;
790 }
791 }
792 else if( nInv == E3dInventor /*&& nId == E3D_POLYSCENE_ID*/)
793 {
794 if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
795 {
796 if( !mpDrawView->IsGroupEntered() )
797 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
798 RID_DRAW_3DSCENE_POPUP;
799 else
800 nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
801 RID_DRAW_3DSCENE2_POPUP;
802 }
803 else
804 nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
805 RID_DRAW_3DOBJ_POPUP;
806 }
807 else if( nInv == FmFormInventor )
808 {
809 nSdResId = RID_FORM_CONTROL_POPUP;
810 }
811 }
812 }
813 }
814
815 // Mehrfachselektion
816 else if (mpDrawView->AreObjectsMarked() &&
817 mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
818 {
819 nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
820 RID_DRAW_MULTISELECTION_POPUP;
821 }
822
823 // nichts selektiert
824 else
825 {
826 nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
827 RID_DRAW_NOSEL_POPUP;
828 }
829 }
830 // Popup-Menue anzeigen
831 if (nSdResId)
832 {
833 GetActiveWindow()->ReleaseMouse();
834
835 if(rCEvt.IsMouseEvent())
836 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
837 else
838 {
839 //#106326# don't open contextmenu at mouse position if not opened via mouse
840
841 //middle of the window if nothing is marked
842 Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
843 ,GetActiveWindow()->GetSizePixel().Height()/2);
844
845 //middle of the bounding rect if something is marked
846 if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
847 {
848 Rectangle aMarkRect;
849 mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
850 aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
851
852 //move the point into the visible window area
853 if( aMenuPos.X() < 0 )
854 aMenuPos.X() = 0;
855 if( aMenuPos.Y() < 0 )
856 aMenuPos.Y() = 0;
857 if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
858 aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
859 if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
860 aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
861 }
862
863 //open context menu at that point
864 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
865 }
866 mbMousePosFreezed = sal_False;
867 }
868 }
869 else
870 {
871 ViewShell::Command(rCEvt, pWin);
872 }
873 }
874 }
875
876 /*************************************************************************
877 |*
878 |* Linealmarkierungen anzeigen
879 |*
880 \************************************************************************/
881
ShowMousePosInfo(const Rectangle & rRect,::sd::Window * pWin)882 void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
883 ::sd::Window* pWin)
884 {
885 if (mbHasRulers && pWin )
886 {
887 RulerLine pHLines[2];
888 RulerLine pVLines[2];
889 long nHOffs = 0L;
890 long nVOffs = 0L;
891 sal_uInt16 nCnt;
892
893 if (mpHorizontalRuler.get() != NULL)
894 mpHorizontalRuler->SetLines();
895
896 if (mpVerticalRuler.get() != NULL)
897 mpVerticalRuler->SetLines();
898
899 if (mpHorizontalRuler.get() != NULL)
900 {
901 nHOffs = mpHorizontalRuler->GetNullOffset() +
902 mpHorizontalRuler->GetPageOffset();
903 }
904
905 if (mpVerticalRuler.get() != NULL)
906 {
907 nVOffs = mpVerticalRuler->GetNullOffset() +
908 mpVerticalRuler->GetPageOffset();
909 }
910
911 nCnt = 1;
912 pHLines[0].nPos = rRect.Left() - nHOffs;
913 pVLines[0].nPos = rRect.Top() - nVOffs;
914 pHLines[0].nStyle = 0;
915 pVLines[0].nStyle = 0;
916
917 if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
918 {
919 pHLines[1].nPos = rRect.Right() - nHOffs;
920 pVLines[1].nPos = rRect.Bottom() - nVOffs;
921 pHLines[1].nStyle = 0;
922 pVLines[1].nStyle = 0;
923 nCnt++;
924 }
925
926 if (mpHorizontalRuler.get() != NULL)
927 mpHorizontalRuler->SetLines(nCnt, pHLines);
928 if (mpVerticalRuler.get() != NULL)
929 mpVerticalRuler->SetLines(nCnt, pVLines);
930 }
931
932 // StatusBar Koordinatenanzeige
933 OSL_ASSERT (GetViewShell()!=NULL);
934 if ( !GetViewShell()->GetUIActiveClient() )
935 {
936 SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
937 SID_ATTR_POSITION, SID_ATTR_POSITION,
938 SID_ATTR_SIZE, SID_ATTR_SIZE,
939 0L);
940
941 // GetStatusBarState(aSet); nicht performant bei gedrueckter Modifiertaste!!
942
943 aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
944
945 SfxBindings& rBindings = GetViewFrame()->GetBindings();
946 rBindings.SetState(aSet);
947 rBindings.Invalidate(SID_CONTEXT);
948 rBindings.Invalidate(SID_ATTR_POSITION);
949 rBindings.Invalidate(SID_ATTR_SIZE);
950 }
951 }
952
953 /*************************************************************************
954 |*
955 |*
956 |*
957 \************************************************************************/
958
LockInput()959 void DrawViewShell::LockInput()
960 {
961 mnLockCount++;
962 }
963
964 /*************************************************************************
965 |*
966 |*
967 |*
968 \************************************************************************/
969
UnlockInput()970 void DrawViewShell::UnlockInput()
971 {
972 DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
973 if ( mnLockCount )
974 mnLockCount--;
975 }
976
977
978
979
ShowSnapLineContextMenu(SdrPageView & rPageView,const sal_uInt16 nSnapLineIndex,const Point & rMouseLocation)980 void DrawViewShell::ShowSnapLineContextMenu (
981 SdrPageView& rPageView,
982 const sal_uInt16 nSnapLineIndex,
983 const Point& rMouseLocation)
984 {
985 const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
986 ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
987
988 if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
989 {
990 pMenu->InsertItem(
991 SID_SET_SNAPITEM,
992 String(SdResId(STR_POPUP_EDIT_SNAPPOINT)));
993 pMenu->InsertSeparator();
994 pMenu->InsertItem(
995 SID_DELETE_SNAPITEM,
996 String(SdResId(STR_POPUP_DELETE_SNAPPOINT)));
997 }
998 else
999 {
1000 pMenu->InsertItem(
1001 SID_SET_SNAPITEM,
1002 String(SdResId(STR_POPUP_EDIT_SNAPLINE)));
1003 pMenu->InsertSeparator();
1004 pMenu->InsertItem(
1005 SID_DELETE_SNAPITEM,
1006 String(SdResId(STR_POPUP_DELETE_SNAPLINE)));
1007 }
1008
1009 pMenu->RemoveDisabledEntries(sal_False, sal_False);
1010
1011 const sal_uInt16 nResult = pMenu->Execute(
1012 GetActiveWindow(),
1013 Rectangle(rMouseLocation, Size(10,10)),
1014 POPUPMENU_EXECUTE_DOWN);
1015 switch (nResult)
1016 {
1017 case SID_SET_SNAPITEM:
1018 {
1019 SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
1020 const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
1021 GetViewFrame()->GetDispatcher()->Execute(
1022 SID_SET_SNAPITEM,
1023 SFX_CALLMODE_SLOT,
1024 aArguments);
1025 }
1026 break;
1027
1028 case SID_DELETE_SNAPITEM:
1029 {
1030 rPageView.DeleteHelpLine(nSnapLineIndex);
1031 }
1032 break;
1033
1034 default:
1035 break;
1036 }
1037 }
1038
1039
1040
1041
1042 #ifdef _MSC_VER
1043 #pragma optimize ( "", on )
1044 #endif
1045
1046 } // end of namespace sd
1047