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 .
20 #include <svl/aeitem.hxx>
22 #include <svx/dialmgr.hxx>
23 #include <svx/dialogs.hrc>
25 #include "svx/tbxalign.hxx"
26 #include <sfx2/imagemgr.hxx>
27 #include <vcl/svapp.hxx>
28 #include <osl/mutex.hxx>
30 #include <sfx2/app.hxx>
31 #include <vcl/toolbox.hxx>
33 SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlAlign
, SfxAllEnumItem
);
36 * Klasse fuer SwToolbox
38 SvxTbxCtlAlign::SvxTbxCtlAlign( sal_uInt16 nSlotId
, sal_uInt16 nId
, ToolBox
& rTbx
) :
39 SfxToolBoxControl( nSlotId
, nId
, rTbx
)
40 , m_aSubTbName( "alignmentbar" )
41 , m_aSubTbResName( "private:resource/toolbar/alignmentbar" )
43 rTbx
.SetItemBits( nId
, ToolBoxItemBits::DROPDOWN
| rTbx
.GetItemBits( nId
) );
46 m_aCommand
= m_aCommandURL
;
50 * Wenn man ein PopupWindow erzeugen will
53 SfxPopupWindowType
SvxTbxCtlAlign::GetPopupWindowType() const
55 return SfxPopupWindowType::ONCLICK
;
59 * Hier wird das Fenster erzeugt
60 * Lage der Toolbox mit GetToolBox() abfragbar
61 * rItemRect sind die Screen-Koordinaten
64 VclPtr
<SfxPopupWindow
> SvxTbxCtlAlign::CreatePopupWindow()
66 SolarMutexGuard aGuard
;
67 if ( GetSlotId() == SID_OBJECT_ALIGN
)
68 createAndPositionSubToolBar( m_aSubTbResName
);
73 // XSubToolbarController
76 sal_Bool SAL_CALL
SvxTbxCtlAlign::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException
, std::exception
)
78 // We control a sub-toolbar therefore, we have to return true.
82 OUString SAL_CALL
SvxTbxCtlAlign::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException
, std::exception
)
84 // Provide the controlled sub-toolbar name, so we are notified whenever
85 // this toolbar executes a function.
86 SolarMutexGuard aGuard
;
90 void SAL_CALL
SvxTbxCtlAlign::functionSelected( const OUString
& aCommand
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
92 // remember the new command
93 m_aCommand
= aCommand
;
95 // Our sub-toolbar wants to execute a function.
96 // We have to change the image of our toolbar button to reflect the new function.
100 void SAL_CALL
SvxTbxCtlAlign::updateImage() throw (::com::sun::star::uno::RuntimeException
, std::exception
)
102 // We should update the button image of our parent (toolbar). Use the stored
103 // command to set the correct current image.
104 SolarMutexGuard aGuard
;
105 if ( !m_aCommand
.isEmpty() )
107 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> xFrame( getFrameInterface());
108 Image aImage
= GetImage( xFrame
, m_aCommand
, hasBigImages() );
110 GetToolBox().SetItemImage( GetId(), aImage
);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */