1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/svxdlg.hxx>
22 #include <svx/dialogs.hrc>
24 #include "scitems.hxx"
26 #include <editeng/eeitem.hxx>
27 #include <svx/fontwork.hxx>
28 #include <svl/srchitem.hxx>
29 #include <svx/svdpage.hxx>
30 #include <sfx2/app.hxx>
31 #include <sfx2/objface.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <sfx2/request.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <svl/whiter.hxx>
36 #include <vcl/msgbox.hxx>
39 #include "drwlayer.hxx"
41 #include "viewdata.hxx"
42 #include "document.hxx"
43 #include "docpool.hxx"
44 #include "drawview.hxx"
45 #include "scresid.hxx"
46 #include <svx/svdobj.hxx>
47 #include <svx/drawitem.hxx>
48 #include <svx/xtable.hxx>
49 #include "tabvwsh.hxx"
50 #include <sfx2/bindings.hxx>
53 #include "scslots.hxx"
55 #include "userdat.hxx"
56 #include <svl/macitem.hxx>
57 #include <sfx2/evntconf.hxx>
58 #include <sfx2/viewsh.hxx>
59 #include <com/sun/star/util/XModifiable.hpp>
60 #include <com/sun/star/frame/XFrame.hpp>
62 //------------------------------------------------------------------
64 TYPEINIT1( ScDrawShell
, SfxShell
);
66 SFX_IMPL_INTERFACE(ScDrawShell
, SfxShell
, ScResId(SCSTR_DRAWSHELL
) )
68 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_SERVER
,
69 ScResId(RID_DRAW_OBJECTBAR
) );
70 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAW
) );
71 SFX_CHILDWINDOW_REGISTRATION( SvxFontWorkChildWindow::GetChildWindowId() );
75 // abschalten der nicht erwuenschten Acceleratoren:
77 void ScDrawShell::StateDisableItems( SfxItemSet
&rSet
)
79 SfxWhichIter
aIter(rSet
);
80 sal_uInt16 nWhich
= aIter
.FirstWhich();
84 rSet
.DisableItem( nWhich
);
85 nWhich
= aIter
.NextWhich();
89 static void lcl_setModified( SfxObjectShell
* pShell
)
93 com::sun::star::uno::Reference
< com::sun::star::util::XModifiable
> xModif( pShell
->GetModel(), com::sun::star::uno::UNO_QUERY
);
95 xModif
->setModified( sal_True
);
99 void ScDrawShell::ExecDrawAttr( SfxRequest
& rReq
)
101 sal_uInt16 nSlot
= rReq
.GetSlot();
102 Window
* pWin
= pViewData
->GetActiveWin();
103 ScDrawView
* pView
= pViewData
->GetScDrawView();
104 SdrModel
* pDoc
= pViewData
->GetDocument()->GetDrawLayer();
106 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
107 sal_uLong nMarkCount
= rMarkList
.GetMarkCount();
108 SdrObject
* pSingleSelectedObj
= NULL
;
109 if ( nMarkCount
> 0 )
110 pSingleSelectedObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
114 case SID_ASSIGNMACRO
:
116 if ( pSingleSelectedObj
)
117 ExecuteMacroAssign( pSingleSelectedObj
, pWin
);
121 case SID_TEXT_STANDARD
: // Harte Textattributierung loeschen
123 SfxItemSet
aEmptyAttr(GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
124 pView
->SetAttributes(aEmptyAttr
, sal_True
);
128 case SID_ATTR_LINE_STYLE
:
129 case SID_ATTR_LINEEND_STYLE
:
130 case SID_ATTR_LINE_START
:
131 case SID_ATTR_LINE_END
:
132 case SID_ATTR_LINE_DASH
:
133 case SID_ATTR_LINE_WIDTH
:
134 case SID_ATTR_LINE_COLOR
:
135 case SID_ATTR_LINE_TRANSPARENCE
:
136 case SID_ATTR_LINE_JOINT
:
137 case SID_ATTR_LINE_CAP
:
138 case SID_ATTR_FILL_STYLE
:
139 case SID_ATTR_FILL_COLOR
:
140 case SID_ATTR_FILL_GRADIENT
:
141 case SID_ATTR_FILL_HATCH
:
142 case SID_ATTR_FILL_BITMAP
:
143 case SID_ATTR_FILL_TRANSPARENCE
:
144 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
147 case SID_ATTR_FILL_SHADOW
:
149 // Wenn ToolBar vertikal :
150 if ( !rReq
.GetArgs() )
154 case SID_ATTR_LINE_STYLE
:
155 case SID_ATTR_LINE_DASH
:
156 case SID_ATTR_LINE_WIDTH
:
157 case SID_ATTR_LINE_COLOR
:
158 case SID_ATTR_LINE_TRANSPARENCE
:
159 case SID_ATTR_LINE_JOINT
:
160 case SID_ATTR_LINE_CAP
:
161 ExecuteLineDlg( rReq
);
164 case SID_ATTR_FILL_STYLE
:
165 case SID_ATTR_FILL_COLOR
:
166 case SID_ATTR_FILL_GRADIENT
:
167 case SID_ATTR_FILL_HATCH
:
168 case SID_ATTR_FILL_BITMAP
:
169 case SID_ATTR_FILL_TRANSPARENCE
:
170 case SID_ATTR_FILL_FLOATTRANSPARENCE
:
173 case SID_ATTR_FILL_SHADOW
:
175 ExecuteAreaDlg( rReq
);
187 if( pView
->AreObjectsMarked() )
188 pView
->SetAttrToMarked( *rReq
.GetArgs(), false );
190 pView
->SetDefaultAttr( *rReq
.GetArgs(), false);
191 pView
->InvalidateAttribs();
195 case SID_ATTRIBUTES_LINE
:
196 ExecuteLineDlg( rReq
);
199 case SID_ATTRIBUTES_AREA
:
200 ExecuteAreaDlg( rReq
);
203 case SID_DRAWTEXT_ATTR_DLG
:
204 ExecuteTextAttrDlg( rReq
);
207 case SID_DRAW_HLINK_EDIT
:
208 if ( pSingleSelectedObj
)
209 pViewData
->GetDispatcher().Execute( SID_HYPERLINK_DIALOG
);
212 case SID_DRAW_HLINK_DELETE
:
213 if ( pSingleSelectedObj
)
214 SetHlinkForObject( pSingleSelectedObj
, OUString() );
217 case SID_OPEN_HYPERLINK
:
218 if ( nMarkCount
== 1 )
220 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
221 if ( pObj
->IsGroupObject() )
223 SdrPageView
* pPV
= 0;
225 if ( pView
->PickObj( pWin
->PixelToLogic( pViewData
->GetMousePosPixel() ), pView
->getHitTolLog(), pHit
, pPV
, SDRSEARCH_DEEP
) )
229 ScMacroInfo
* pInfo
= ScDrawLayer::GetMacroInfo( pObj
);
230 if ( pInfo
&& !pInfo
->GetHlink().isEmpty() )
231 ScGlobal::OpenURL( pInfo
->GetHlink(), OUString() );
235 case SID_ATTR_TRANSFORM
:
238 if ( pView
->AreObjectsMarked() )
240 const SfxItemSet
* pArgs
= rReq
.GetArgs();
244 if( rMarkList
.GetMark(0) != 0 )
246 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
247 if( pObj
->GetObjIdentifier() == OBJ_CAPTION
)
249 // --------- Itemset fuer Caption --------
250 SfxItemSet
aNewAttr(pDoc
->GetItemPool());
251 pView
->GetAttributes(aNewAttr
);
252 // --------- Itemset fuer Groesse und Position --------
253 SfxItemSet
aNewGeoAttr(pView
->GetGeoAttrFromMarked());
255 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
258 SfxAbstractTabDialog
*pDlg
= pFact
->CreateCaptionDialog( pWin
, pView
);
260 const sal_uInt16
* pRange
= pDlg
->GetInputRanges( *aNewAttr
.GetPool() );
261 SfxItemSet
aCombSet( *aNewAttr
.GetPool(), pRange
);
262 aCombSet
.Put( aNewAttr
);
263 aCombSet
.Put( aNewGeoAttr
);
264 pDlg
->SetInputSet( &aCombSet
);
266 if (pDlg
->Execute() == RET_OK
)
268 rReq
.Done(*(pDlg
->GetOutputItemSet()));
269 pView
->SetAttributes(*pDlg
->GetOutputItemSet());
270 pView
->SetGeoAttrToMarked(*pDlg
->GetOutputItemSet());
278 SfxItemSet
aNewAttr(pView
->GetGeoAttrFromMarked());
279 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
282 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSvxTransformTabDialog( pWin
, &aNewAttr
,pView
);
283 OSL_ENSURE(pDlg
, "Dialog creation failed!");
284 if (pDlg
->Execute() == RET_OK
)
286 rReq
.Done(*(pDlg
->GetOutputItemSet()));
287 pView
->SetGeoAttrToMarked(*pDlg
->GetOutputItemSet());
297 pView
->SetGeoAttrToMarked( *pArgs
);
301 ScTabViewShell
* pViewShell
= pViewData
->GetViewShell();
302 SfxBindings
& rBindings
=pViewShell
->GetViewFrame()->GetBindings();
303 rBindings
.Invalidate(SID_ATTR_TRANSFORM_WIDTH
);
304 rBindings
.Invalidate(SID_ATTR_TRANSFORM_HEIGHT
);
305 rBindings
.Invalidate(SID_ATTR_TRANSFORM_POS_X
);
306 rBindings
.Invalidate(SID_ATTR_TRANSFORM_POS_Y
);
307 rBindings
.Invalidate(SID_ATTR_TRANSFORM_ANGLE
);
308 rBindings
.Invalidate(SID_ATTR_TRANSFORM_ROT_X
);
309 rBindings
.Invalidate(SID_ATTR_TRANSFORM_ROT_Y
);
310 rBindings
.Invalidate(SID_ATTR_TRANSFORM_AUTOWIDTH
);
311 rBindings
.Invalidate(SID_ATTR_TRANSFORM_AUTOHEIGHT
);
320 void ScDrawShell::ExecuteMacroAssign( SdrObject
* pObj
, Window
* pWin
)
322 SvxMacroItem
aItem ( SFX_APP()->GetPool().GetWhich( SID_ATTR_MACROITEM
) );
323 ScMacroInfo
* pInfo
= ScDrawLayer::GetMacroInfo( pObj
, sal_True
);
324 if ( !pInfo
->GetMacro().isEmpty() )
326 SvxMacroTableDtor aTab
;
327 OUString sMacro
= pInfo
->GetMacro();
328 aTab
.Insert(SFX_EVENT_MOUSECLICK_OBJECT
, SvxMacro(sMacro
, OUString()));
329 aItem
.SetMacroTable( aTab
);
332 // create empty itemset for macro-dlg
333 SfxItemSet
* pItemSet
= new SfxItemSet(SFX_APP()->GetPool(), SID_ATTR_MACROITEM
, SID_ATTR_MACROITEM
, SID_EVENTCONFIG
, SID_EVENTCONFIG
, 0 );
334 pItemSet
->Put ( aItem
, SID_ATTR_MACROITEM
);
336 SfxEventNamesItem
aNamesItem(SID_EVENTCONFIG
);
337 aNamesItem
.AddEvent( ScResId(RID_SCSTR_ONCLICK
), OUString(), SFX_EVENT_MOUSECLICK_OBJECT
);
338 pItemSet
->Put( aNamesItem
, SID_EVENTCONFIG
);
340 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
> xFrame
;
342 xFrame
= GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
344 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
345 SfxAbstractDialog
* pMacroDlg
= pFact
->CreateSfxDialog( pWin
, *pItemSet
, xFrame
, SID_EVENTCONFIG
);
346 if ( pMacroDlg
&& pMacroDlg
->Execute() == RET_OK
)
348 const SfxItemSet
* pOutSet
= pMacroDlg
->GetOutputItemSet();
349 const SfxPoolItem
* pItem
;
350 if( SFX_ITEM_SET
== pOutSet
->GetItemState( SID_ATTR_MACROITEM
, false, &pItem
))
353 const SvxMacro
* pMacro
= ((SvxMacroItem
*)pItem
)->GetMacroTable().Get( SFX_EVENT_MOUSECLICK_OBJECT
);
355 sMacro
= pMacro
->GetMacName();
357 if ( pObj
->IsGroupObject() )
359 SdrObjList
* pOL
= pObj
->GetSubList();
360 sal_uLong nObj
= pOL
->GetObjCount();
361 for ( sal_uLong index
=0; index
<nObj
; ++index
)
363 pInfo
= ScDrawLayer::GetMacroInfo( pOL
->GetObj(index
), sal_True
);
364 pInfo
->SetMacro( sMacro
);
368 pInfo
->SetMacro( sMacro
);
369 lcl_setModified( GetObjectShell() );
377 void ScDrawShell::ExecuteLineDlg( SfxRequest
& rReq
, sal_uInt16 nTabPage
)
379 ScDrawView
* pView
= pViewData
->GetScDrawView();
380 sal_Bool bHasMarked
= pView
->AreObjectsMarked();
381 const SdrObject
* pObj
= NULL
;
382 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
384 if( rMarkList
.GetMarkCount() == 1 )
385 pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
387 SfxItemSet
aNewAttr( pView
->GetDefaultAttr() );
389 pView
->MergeAttrFromMarked( aNewAttr
, false );
391 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
392 OSL_ENSURE(pFact
, "Dialogdiet Factory fail!");
393 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSvxLineTabDialog( pViewData
->GetDialogParent(),
395 pViewData
->GetDocument()->GetDrawLayer(),
398 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
399 if ( nTabPage
!= 0xffff )
400 pDlg
->SetCurPageId( nTabPage
);
402 if ( pDlg
->Execute() == RET_OK
)
405 pView
->SetAttrToMarked( *pDlg
->GetOutputItemSet(), false );
407 pView
->SetDefaultAttr( *pDlg
->GetOutputItemSet(), false );
409 pView
->InvalidateAttribs();
416 void ScDrawShell::ExecuteAreaDlg( SfxRequest
& rReq
, sal_uInt16 nTabPage
)
418 ScDrawView
* pView
= pViewData
->GetScDrawView();
419 sal_Bool bHasMarked
= pView
->AreObjectsMarked();
421 SfxItemSet
aNewAttr( pView
->GetDefaultAttr() );
423 pView
->MergeAttrFromMarked( aNewAttr
, false );
426 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
427 AbstractSvxAreaTabDialog
* pDlg
= pFact
->CreateSvxAreaTabDialog(
428 pViewData
->GetDialogParent(), &aNewAttr
,
429 pViewData
->GetDocument()->GetDrawLayer(), pView
);
431 if ( nTabPage
!= 0xffff )
432 pDlg
->SetCurPageId( nTabPage
);
434 if ( pDlg
->Execute() == RET_OK
)
437 pView
->SetAttrToMarked( *pDlg
->GetOutputItemSet(), false );
439 pView
->SetDefaultAttr( *pDlg
->GetOutputItemSet(), false );
441 pView
->InvalidateAttribs();
448 void ScDrawShell::ExecuteTextAttrDlg( SfxRequest
& rReq
, sal_uInt16
/* nTabPage */ )
450 ScDrawView
* pView
= pViewData
->GetScDrawView();
451 sal_Bool bHasMarked
= pView
->AreObjectsMarked();
452 SfxItemSet
aNewAttr ( pView
->GetDefaultAttr() );
455 pView
->MergeAttrFromMarked( aNewAttr
, false );
457 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
458 SfxAbstractTabDialog
*pDlg
= pFact
->CreateTextTabDialog( pViewData
->GetDialogParent(), &aNewAttr
, pView
);
460 sal_uInt16 nResult
= pDlg
->Execute();
462 if ( RET_OK
== nResult
)
465 pView
->SetAttributes( *pDlg
->GetOutputItemSet() );
467 pView
->SetDefaultAttr( *pDlg
->GetOutputItemSet(), false );
469 pView
->InvalidateAttribs();
475 void ScDrawShell::SetHlinkForObject( SdrObject
* pObj
, const OUString
& rHlnk
)
479 ScMacroInfo
* pInfo
= ScDrawLayer::GetMacroInfo( pObj
, sal_True
);
480 pInfo
->SetHlink( rHlnk
);
481 lcl_setModified( GetObjectShell() );
485 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */