Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svl/aeitem.hxx>
30 : :
31 : : #include <svx/dialmgr.hxx>
32 : : #include <svx/dialogs.hrc>
33 : :
34 : : #include "svx/tbxalign.hxx"
35 : : #include "svx/tbxdraw.hxx"
36 : : #include <tools/shl.hxx>
37 : : #include <sfx2/imagemgr.hxx>
38 : : #include <vcl/svapp.hxx>
39 : : #include <osl/mutex.hxx>
40 : :
41 : : #include <sfx2/app.hxx>
42 : : #include <vcl/toolbox.hxx>
43 : :
44 [ # # ]: 124 : SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlAlign, SfxAllEnumItem);
45 : :
46 : : /*************************************************************************
47 : : |*
48 : : |* Klasse fuer SwToolbox
49 : : |*
50 : : \************************************************************************/
51 : :
52 : 0 : SvxTbxCtlAlign::SvxTbxCtlAlign( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
53 : : SfxToolBoxControl( nSlotId, nId, rTbx )
54 : : , m_aSubTbName( RTL_CONSTASCII_USTRINGPARAM( "alignmentbar" ))
55 [ # # ][ # # ]: 0 : , m_aSubTbResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/alignmentbar" ))
56 : : {
57 [ # # ][ # # ]: 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
58 [ # # ]: 0 : rTbx.Invalidate();
59 : :
60 : 0 : m_aCommand = m_aCommandURL;
61 : 0 : }
62 : :
63 : : /*************************************************************************
64 : : |*
65 : : |* Wenn man ein PopupWindow erzeugen will
66 : : |*
67 : : \************************************************************************/
68 : :
69 : 0 : SfxPopupWindowType SvxTbxCtlAlign::GetPopupWindowType() const
70 : : {
71 : 0 : return(SFX_POPUPWINDOW_ONCLICK);
72 : : }
73 : :
74 : : /*************************************************************************
75 : : |*
76 : : |* Hier wird das Fenster erzeugt
77 : : |* Lage der Toolbox mit GetToolBox() abfragbar
78 : : |* rItemRect sind die Screen-Koordinaten
79 : : |*
80 : : \************************************************************************/
81 : :
82 : 0 : SfxPopupWindow* SvxTbxCtlAlign::CreatePopupWindow()
83 : : {
84 [ # # ]: 0 : SolarMutexGuard aGuard;
85 [ # # ][ # # ]: 0 : if ( GetSlotId() == SID_OBJECT_ALIGN )
86 [ # # ]: 0 : createAndPositionSubToolBar( m_aSubTbResName );
87 [ # # ]: 0 : return NULL;
88 : : }
89 : :
90 : : //========================================================================
91 : : // XSubToolbarController
92 : : //========================================================================
93 : :
94 : 0 : ::sal_Bool SAL_CALL SvxTbxCtlAlign::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
95 : : {
96 : : // We control a sub-toolbar therefor, we have to return true.
97 : 0 : return sal_True;
98 : : }
99 : :
100 : 0 : ::rtl::OUString SAL_CALL SvxTbxCtlAlign::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
101 : : {
102 : : // Provide the controlled sub-toolbar name, so we are notified whenever
103 : : // this toolbar executes a function.
104 [ # # ]: 0 : SolarMutexGuard aGuard;
105 [ # # ]: 0 : return m_aSubTbName;
106 : : }
107 : :
108 : 0 : void SAL_CALL SvxTbxCtlAlign::functionSelected( const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException)
109 : : {
110 : : // Our sub-toolbar wants to executes a function. We have to change
111 : : // the image of our toolbar button to reflect the new function.
112 [ # # ]: 0 : SolarMutexGuard aGuard;
113 [ # # ]: 0 : if ( !m_bDisposed )
114 : : {
115 [ # # ]: 0 : if ( !aCommand.isEmpty() )
116 : : {
117 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
118 [ # # ][ # # ]: 0 : Image aImage = GetImage( xFrame, aCommand, hasBigImages() );
119 [ # # ]: 0 : if ( !!aImage )
120 [ # # ][ # # ]: 0 : GetToolBox().SetItemImage( GetId(), aImage );
[ # # ][ # # ]
121 : : }
122 [ # # ]: 0 : }
123 : 0 : }
124 : :
125 : 0 : void SAL_CALL SvxTbxCtlAlign::updateImage() throw (::com::sun::star::uno::RuntimeException)
126 : : {
127 : : // We should update the button image of our parent (toolbar). Use the stored
128 : : // command to set the correct current image.
129 [ # # ]: 0 : SolarMutexGuard aGuard;
130 [ # # ]: 0 : if ( !m_aCommand.isEmpty() )
131 : : {
132 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
133 [ # # ][ # # ]: 0 : Image aImage = GetImage( xFrame, m_aCommand, hasBigImages() );
134 [ # # ]: 0 : if ( !!aImage )
135 [ # # ][ # # ]: 0 : GetToolBox().SetItemImage( GetId(), aImage );
[ # # ][ # # ]
136 [ # # ]: 0 : }
137 : 0 : }
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|