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 "sidebar/PanelFactory.hxx" 23 24 #include "text/TextPropertyPanel.hxx" 25 #include "area/AreaPropertyPanel.hxx" 26 #include "graphic/GraphicPropertyPanel.hxx" 27 #include "line/LinePropertyPanel.hxx" 28 #include "possize/PosSizePropertyPanel.hxx" 29 #include "GalleryControl.hxx" 30 #include "debug/ColorPanel.hxx" 31 #include "debug/ContextPanel.hxx" 32 #include "debug/NotYetImplementedPanel.hxx" 33 #include "EmptyPanel.hxx" 34 #include <sfx2/sidebar/SidebarPanelBase.hxx> 35 #include <sfx2/sfxbasecontroller.hxx> 36 #include <toolkit/helper/vclunohelper.hxx> 37 #include <vcl/window.hxx> 38 #include <rtl/ref.hxx> 39 #include <comphelper/namedvaluecollection.hxx> 40 41 42 #include <boost/bind.hpp> 43 44 45 using namespace css; 46 using namespace cssu; 47 using ::rtl::OUString; 48 49 50 namespace svx { namespace sidebar { 51 52 #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 53 #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.svx.sidebar.PanelFactory" 54 #define SERVICE_NAME "com.sun.star.ui.UIElementFactory" 55 56 57 ::rtl::OUString SAL_CALL PanelFactory::getImplementationName (void) 58 { 59 return A2S(IMPLEMENTATION_NAME); 60 } 61 62 63 64 65 cssu::Reference<cssu::XInterface> SAL_CALL PanelFactory::createInstance ( 66 const uno::Reference<lang::XMultiServiceFactory>& rxFactory) 67 { 68 (void)rxFactory; 69 70 ::rtl::Reference<PanelFactory> pPanelFactory (new PanelFactory()); 71 cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY); 72 return xService; 73 } 74 75 76 77 78 cssu::Sequence<OUString> SAL_CALL PanelFactory::getSupportedServiceNames (void) 79 { 80 cssu::Sequence<OUString> aServiceNames (1); 81 aServiceNames[0] = A2S(SERVICE_NAME); 82 return aServiceNames; 83 84 } 85 86 87 88 89 PanelFactory::PanelFactory (void) 90 : PanelFactoryInterfaceBase(m_aMutex) 91 { 92 } 93 94 95 96 97 PanelFactory::~PanelFactory (void) 98 { 99 } 100 101 102 103 104 Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement ( 105 const ::rtl::OUString& rsResourceURL, 106 const ::cssu::Sequence<css::beans::PropertyValue>& rArguments) 107 throw( 108 container::NoSuchElementException, 109 lang::IllegalArgumentException, 110 RuntimeException) 111 { 112 Reference<ui::XUIElement> xElement; 113 114 const ::comphelper::NamedValueCollection aArguments (rArguments); 115 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>())); 116 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>())); 117 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); 118 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); 119 120 ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); 121 if ( ! xParentWindow.is() || pParentWindow==NULL) 122 throw RuntimeException( 123 A2S("PanelFactory::createUIElement called without ParentWindow"), 124 NULL); 125 if ( ! xFrame.is()) 126 throw RuntimeException( 127 A2S("PanelFactory::createUIElement called without Frame"), 128 NULL); 129 if (pBindings == NULL) 130 throw RuntimeException( 131 A2S("PanelFactory::createUIElement called without SfxBindings"), 132 NULL); 133 134 #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s)) 135 if (DoesResourceEndWith("/TextPropertyPanel")) 136 { 137 TextPropertyPanel* pPanel = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings); 138 xElement = sfx2::sidebar::SidebarPanelBase::Create( 139 rsResourceURL, 140 xFrame, 141 pPanel, 142 ui::LayoutSize(-1,-1,-1)); 143 } 144 else if (DoesResourceEndWith("/AreaPropertyPanel")) 145 { 146 AreaPropertyPanel* pPanel = AreaPropertyPanel::Create(pParentWindow, xFrame, pBindings); 147 xElement = sfx2::sidebar::SidebarPanelBase::Create( 148 rsResourceURL, 149 xFrame, 150 pPanel, 151 ui::LayoutSize(-1,-1,-1)); 152 } 153 else if (DoesResourceEndWith("/GraphicPropertyPanel")) 154 { 155 GraphicPropertyPanel* pPanel = GraphicPropertyPanel::Create(pParentWindow, xFrame, pBindings); 156 xElement = sfx2::sidebar::SidebarPanelBase::Create( 157 rsResourceURL, 158 xFrame, 159 pPanel, 160 ui::LayoutSize(-1,-1,-1)); 161 } 162 else if (DoesResourceEndWith("/LinePropertyPanel")) 163 { 164 LinePropertyPanel* pPanel = LinePropertyPanel::Create(pParentWindow, xFrame, pBindings); 165 xElement = sfx2::sidebar::SidebarPanelBase::Create( 166 rsResourceURL, 167 xFrame, 168 pPanel, 169 ui::LayoutSize(-1,-1,-1)); 170 } 171 else if (DoesResourceEndWith("/PosSizePropertyPanel")) 172 { 173 PosSizePropertyPanel* pPanel = PosSizePropertyPanel::Create(pParentWindow, xFrame, pBindings); 174 xElement = sfx2::sidebar::SidebarPanelBase::Create( 175 rsResourceURL, 176 xFrame, 177 pPanel, 178 ui::LayoutSize(-1,-1,-1)); 179 } 180 else if (DoesResourceEndWith("/GalleryPanel")) 181 { 182 GalleryControl* pGalleryControl = new GalleryControl( 183 pBindings, 184 pParentWindow); 185 xElement = sfx2::sidebar::SidebarPanelBase::Create( 186 rsResourceURL, 187 xFrame, 188 pGalleryControl, 189 ui::LayoutSize(300,-1,400)); 190 } 191 else if (DoesResourceEndWith("/Debug_ColorPanel")) 192 { 193 ColorPanel* pPanel = new ColorPanel(pParentWindow); 194 xElement = sfx2::sidebar::SidebarPanelBase::Create( 195 rsResourceURL, 196 xFrame, 197 pPanel, 198 ui::LayoutSize(300,-1,400)); 199 } 200 else if (DoesResourceEndWith("/Debug_ContextPanel")) 201 { 202 ContextPanel* pPanel = new ContextPanel(pParentWindow); 203 xElement = sfx2::sidebar::SidebarPanelBase::Create( 204 rsResourceURL, 205 xFrame, 206 pPanel, 207 ui::LayoutSize(45,45,45)); 208 } 209 else if (DoesResourceEndWith("/Debug_NotYetImplementedPanel")) 210 { 211 NotYetImplementedPanel* pPanel = new NotYetImplementedPanel(pParentWindow); 212 xElement = sfx2::sidebar::SidebarPanelBase::Create( 213 rsResourceURL, 214 xFrame, 215 pPanel, 216 ui::LayoutSize(20,25,25)); 217 } 218 else if (DoesResourceEndWith("/EmptyPanel")) 219 { 220 EmptyPanel* pPanel = new EmptyPanel(pParentWindow); 221 xElement = sfx2::sidebar::SidebarPanelBase::Create( 222 rsResourceURL, 223 xFrame, 224 pPanel, 225 ui::LayoutSize(20,-1, 50)); 226 } 227 #undef DoesResourceEndWith 228 229 return xElement; 230 } 231 232 } } // end of namespace svx::sidebar 233 234 // eof 235