Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <svl/aeitem.hxx>
21 :
22 : #include <svx/dialmgr.hxx>
23 : #include <svx/dialogs.hrc>
24 :
25 : #include "svx/tbxalign.hxx"
26 : #include <sfx2/imagemgr.hxx>
27 : #include <vcl/svapp.hxx>
28 : #include <osl/mutex.hxx>
29 :
30 : #include <sfx2/app.hxx>
31 : #include <vcl/toolbox.hxx>
32 :
33 111 : SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlAlign, SfxAllEnumItem);
34 :
35 : /*
36 : * Klasse fuer SwToolbox
37 : */
38 0 : SvxTbxCtlAlign::SvxTbxCtlAlign( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
39 : SfxToolBoxControl( nSlotId, nId, rTbx )
40 : , m_aSubTbName( "alignmentbar" )
41 0 : , m_aSubTbResName( "private:resource/toolbar/alignmentbar" )
42 : {
43 0 : rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
44 0 : rTbx.Invalidate();
45 :
46 0 : m_aCommand = m_aCommandURL;
47 0 : }
48 :
49 : /*
50 : * Wenn man ein PopupWindow erzeugen will
51 : */
52 :
53 0 : SfxPopupWindowType SvxTbxCtlAlign::GetPopupWindowType() const
54 : {
55 0 : return SfxPopupWindowType::ONCLICK;
56 : }
57 :
58 : /*
59 : * Hier wird das Fenster erzeugt
60 : * Lage der Toolbox mit GetToolBox() abfragbar
61 : * rItemRect sind die Screen-Koordinaten
62 : */
63 :
64 0 : VclPtr<SfxPopupWindow> SvxTbxCtlAlign::CreatePopupWindow()
65 : {
66 0 : SolarMutexGuard aGuard;
67 0 : if ( GetSlotId() == SID_OBJECT_ALIGN )
68 0 : createAndPositionSubToolBar( m_aSubTbResName );
69 0 : return NULL;
70 : }
71 :
72 :
73 : // XSubToolbarController
74 :
75 :
76 0 : sal_Bool SAL_CALL SvxTbxCtlAlign::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException, std::exception)
77 : {
78 : // We control a sub-toolbar therefore, we have to return true.
79 0 : return sal_True;
80 : }
81 :
82 0 : OUString SAL_CALL SvxTbxCtlAlign::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException, std::exception)
83 : {
84 : // Provide the controlled sub-toolbar name, so we are notified whenever
85 : // this toolbar executes a function.
86 0 : SolarMutexGuard aGuard;
87 0 : return m_aSubTbName;
88 : }
89 :
90 0 : void SAL_CALL SvxTbxCtlAlign::functionSelected( const OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException, std::exception)
91 : {
92 : // remember the new command
93 0 : m_aCommand = aCommand;
94 :
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.
97 0 : updateImage();
98 0 : }
99 :
100 0 : void SAL_CALL SvxTbxCtlAlign::updateImage() throw (::com::sun::star::uno::RuntimeException, std::exception)
101 : {
102 : // We should update the button image of our parent (toolbar). Use the stored
103 : // command to set the correct current image.
104 0 : SolarMutexGuard aGuard;
105 0 : if ( !m_aCommand.isEmpty() )
106 : {
107 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
108 0 : Image aImage = GetImage( xFrame, m_aCommand, hasBigImages() );
109 0 : if ( !!aImage )
110 0 : GetToolBox().SetItemImage( GetId(), aImage );
111 0 : }
112 390 : }
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|