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 #include "precompiled_sfx2.hxx" 23 24 #include "sfx2/sidebar/SidebarPanelBase.hxx" 25 #include "sfx2/sidebar/Theme.hxx" 26 #include "sfx2/imagemgr.hxx" 27 #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> 28 #include <com/sun/star/ui/UIElementType.hpp> 29 30 using namespace css; 31 using namespace cssu; 32 33 34 namespace sfx2 { namespace sidebar { 35 36 SidebarPanelBase::SidebarPanelBase ( 37 const ::rtl::OUString& rsResourceURL, 38 Window* pParentWindow, 39 const cssu::Reference<css::frame::XFrame>& rxFrame, 40 const ResId& rResId) 41 : SidebarPanelBaseInterfaceBase(m_aMutex), 42 msResourceURL(rsResourceURL), 43 Control(pParentWindow, rResId), 44 mxFrame(rxFrame), 45 meFontUnderline(UNDERLINE_SINGLE) 46 { 47 // Let the Pane draw the background. 48 SetBackground(Wallpaper()); 49 50 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 51 css::ui::ContextChangeEventMultiplexer::get( 52 ::comphelper::getProcessComponentContext())); 53 if (xMultiplexer.is()) 54 xMultiplexer->addContextChangeEventListener(this, mxFrame->getController()); 55 } 56 57 58 59 60 SidebarPanelBase::~SidebarPanelBase (void) 61 { 62 } 63 64 65 66 67 void SAL_CALL SidebarPanelBase::disposing (void) 68 throw (cssu::RuntimeException) 69 { 70 if (mxFrame.is()) 71 { 72 cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 73 css::ui::ContextChangeEventMultiplexer::get( 74 ::comphelper::getProcessComponentContext())); 75 if (xMultiplexer.is()) 76 xMultiplexer->removeAllContextChangeEventListeners(this); 77 mxFrame = NULL; 78 } 79 } 80 81 82 83 84 // XContextChangeEventListener 85 void SAL_CALL SidebarPanelBase::notifyContextChangeEvent ( 86 const ui::ContextChangeEventObject& rEvent) 87 { 88 HandleContextChange ( 89 EnumContext( 90 EnumContext::GetApplicationEnum(rEvent.ApplicationName), 91 EnumContext::GetContextEnum(rEvent.ContextName))); 92 } 93 94 95 96 97 void SAL_CALL SidebarPanelBase::disposing ( 98 const css::lang::EventObject& rEvent) 99 throw (cssu::RuntimeException) 100 { 101 } 102 103 104 105 106 cssu::Reference<css::frame::XFrame> SAL_CALL SidebarPanelBase::getFrame (void) 107 throw(cssu::RuntimeException) 108 { 109 return mxFrame; 110 } 111 112 113 114 115 ::rtl::OUString SAL_CALL SidebarPanelBase::getResourceURL (void) 116 throw(cssu::RuntimeException) 117 { 118 return msResourceURL; 119 } 120 121 122 123 124 sal_Int16 SAL_CALL SidebarPanelBase::getType (void) 125 throw(cssu::RuntimeException) 126 { 127 return ui::UIElementType::TOOLPANEL; 128 } 129 130 131 132 133 Reference<XInterface> SAL_CALL SidebarPanelBase::getRealInterface (void) 134 throw(cssu::RuntimeException) 135 { 136 return Reference<XInterface>(static_cast<XWeak*>(this)); 137 } 138 139 140 141 142 Reference<accessibility::XAccessible> SAL_CALL SidebarPanelBase::createAccessible ( 143 const Reference<accessibility::XAccessible>& rxParentAccessible) 144 throw(cssu::RuntimeException) 145 { 146 // Not yet implemented. 147 return NULL; 148 } 149 150 151 152 153 Reference<awt::XWindow> SAL_CALL SidebarPanelBase::getWindow (void) 154 throw(cssu::RuntimeException) 155 { 156 return Reference<awt::XWindow>( 157 Control::GetComponentInterface(), 158 UNO_QUERY); 159 } 160 161 162 163 164 FontUnderline SidebarPanelBase::GetDefaultUnderline (void) const 165 { 166 return meFontUnderline; 167 } 168 169 170 171 172 Image SidebarPanelBase::GetIcon (const ::rtl::OUString& rsURL) 173 { 174 return GetImage(mxFrame, rsURL, sal_False, Theme::IsHighContrastMode()); 175 } 176 177 178 179 180 void SidebarPanelBase::SetDefaultUnderline (const FontUnderline eFontUnderline) 181 { 182 meFontUnderline = eFontUnderline; 183 } 184 185 186 187 } } // end of namespace sfx2::sidebar 188