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 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_basctl.hxx" 26 27 28 #include "dlgedfac.hxx" 29 #include "dlgedobj.hxx" 30 #include <dlgeddef.hxx> 31 #include <com/sun/star/container/XNameContainer.hpp> 32 #include <com/sun/star/beans/PropertyValue.hpp> 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 #include <com/sun/star/awt/ScrollBarOrientation.hpp> 35 36 using namespace ::com::sun::star; 37 38 //---------------------------------------------------------------------------- 39 40 DlgEdFactory::DlgEdFactory() 41 { 42 SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) ); 43 } 44 45 //---------------------------------------------------------------------------- 46 47 DlgEdFactory::~DlgEdFactory() 48 { 49 SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) ); 50 } 51 52 //---------------------------------------------------------------------------- 53 54 IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory ) 55 { 56 static sal_Bool bNeedsInit = sal_True; 57 static uno::Reference< lang::XMultiServiceFactory > xDialogSFact; 58 59 if( bNeedsInit ) 60 { 61 uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); 62 uno::Reference< container::XNameContainer > xC( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), uno::UNO_QUERY ); 63 if( xC.is() ) 64 { 65 uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY ); 66 xDialogSFact = xModFact; 67 } 68 bNeedsInit = sal_False; 69 } 70 71 if( (pObjFactory->nInventor == DlgInventor) && 72 (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) && 73 (pObjFactory->nIdentifier <= OBJ_DLG_TREECONTROL) ) 74 { 75 switch( pObjFactory->nIdentifier ) 76 { 77 case OBJ_DLG_PUSHBUTTON: 78 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlButtonModel") , xDialogSFact ); 79 break; 80 case OBJ_DLG_RADIOBUTTON: 81 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlRadioButtonModel") , xDialogSFact ); 82 break; 83 case OBJ_DLG_CHECKBOX: 84 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlCheckBoxModel") , xDialogSFact ); 85 break; 86 case OBJ_DLG_LISTBOX: 87 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlListBoxModel") , xDialogSFact ); 88 break; 89 case OBJ_DLG_COMBOBOX: 90 { 91 DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlComboBoxModel") , xDialogSFact ); 92 pObjFactory->pNewObj = pNew; 93 try 94 { 95 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY); 96 if (xPSet.is()) 97 { 98 sal_Bool bB = sal_True; 99 xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(&bB,::getBooleanCppuType())); 100 } 101 } 102 catch(...) 103 { 104 } 105 } break; 106 case OBJ_DLG_GROUPBOX: 107 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlGroupBoxModel") , xDialogSFact ); 108 break; 109 case OBJ_DLG_EDIT: 110 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlEditModel") , xDialogSFact ); 111 break; 112 case OBJ_DLG_FIXEDTEXT: 113 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedTextModel") , xDialogSFact ); 114 break; 115 case OBJ_DLG_IMAGECONTROL: 116 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlImageControlModel") , xDialogSFact ); 117 break; 118 case OBJ_DLG_PROGRESSBAR: 119 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlProgressBarModel") , xDialogSFact ); 120 break; 121 case OBJ_DLG_HSCROLLBAR: 122 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlScrollBarModel") , xDialogSFact ); 123 break; 124 case OBJ_DLG_VSCROLLBAR: 125 { 126 DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlScrollBarModel") , xDialogSFact ); 127 pObjFactory->pNewObj = pNew; 128 // set vertical orientation 129 try 130 { 131 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY); 132 if (xPSet.is()) 133 { 134 uno::Any aValue; 135 aValue <<= (sal_Int32) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL; 136 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue ); 137 } 138 } 139 catch(...) 140 { 141 } 142 } break; 143 case OBJ_DLG_HFIXEDLINE: 144 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedLineModel") , xDialogSFact ); 145 break; 146 case OBJ_DLG_VFIXEDLINE: 147 { 148 DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedLineModel") , xDialogSFact ); 149 pObjFactory->pNewObj = pNew; 150 // set vertical orientation 151 try 152 { 153 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY); 154 if (xPSet.is()) 155 { 156 uno::Any aValue; 157 aValue <<= (sal_Int32) 1; 158 xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue ); 159 } 160 } 161 catch(...) 162 { 163 } 164 } break; 165 case OBJ_DLG_DATEFIELD: 166 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlDateFieldModel") , xDialogSFact ); 167 break; 168 case OBJ_DLG_TIMEFIELD: 169 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlTimeFieldModel") , xDialogSFact ); 170 break; 171 case OBJ_DLG_NUMERICFIELD: 172 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlNumericFieldModel") , xDialogSFact ); 173 break; 174 case OBJ_DLG_CURRENCYFIELD: 175 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlCurrencyFieldModel") , xDialogSFact ); 176 break; 177 case OBJ_DLG_FORMATTEDFIELD: 178 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFormattedFieldModel") , xDialogSFact ); 179 break; 180 case OBJ_DLG_PATTERNFIELD: 181 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlPatternFieldModel") , xDialogSFact ); 182 break; 183 case OBJ_DLG_FILECONTROL: 184 pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFileControlModel") , xDialogSFact ); 185 break; 186 case OBJ_DLG_TREECONTROL: 187 DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString::createFromAscii("com.sun.star.awt.tree.TreeControlModel") , xDialogSFact ); 188 pObjFactory->pNewObj = pNew; 189 /* 190 try 191 { 192 uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY); 193 if (xPSet.is()) 194 { 195 // first create a data model for our tree control 196 Reference< XComponentContext > xComponentContext; 197 198 Reference< XPropertySet > xPropSet( xInterface, UNO_QUERY ); 199 xPropSet->getPropertyValue( OUString::createFromAscii("DefaultContext") ) >>= xComponentContext; 200 201 // gets the service manager from the office 202 Reference< XMultiComponentFactory > xMultiComponentFactoryServer( xComponentContext->getServiceManager() ); 203 204 205 // gets the TreeDataModel 206 Reference< XMutableTreeDataModel > xTreeDataModel; 207 208 xTreeDataModel = Reference< XMutableTreeDataModel >( 209 xMultiComponentFactoryServer->createInstanceWithContext( 210 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.tree.MutableTreeDataModel" ) ), xComponentContext ), UNO_QUERY_THROW ); 211 212 // now fill it with some sample data 213 const OUString sRoot( RTL_CONSTASCII_USTRINGPARAM( "Root" ) ); 214 215 Reference< XMutableTreeNode > xNode( mxTreeDataModel->createNode( sRoot, false ), UNO_QUERY_THROW ); 216 xNode->setDataValue( sRoot ); 217 xNode->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) ); 218 xNode->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) ); 219 220 const OUString sNode_1( RTL_CONSTASCII_USTRINGPARAM( "Node_1" ) ); 221 222 Reference< XMutableTreeNode > xChildNode_1( mxTreeDataModel->createNode( sNode_1, true ), UNO_QUERY_THROW ); 223 xChildNode_1->setDataValue( sNode_1 ); 224 xChildNode_1->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) ); 225 xChildNode_1->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) ); 226 227 xNode->appendChild( xChildNode_1 ); 228 229 const OUString sNode_1_1( RTL_CONSTASCII_USTRINGPARAM( "Node_1_1" ) ); 230 231 Reference< XMutableTreeNode > xChildNode_1_1( mxTreeDataModel->createNode( sNode_1_1, false ), UNO_QUERY_THROW ); 232 xChildNode_1_1->setDataValue( sNode_1_1 ); 233 xChildNode_1_1->setExpandedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_down.png" ) ) ); 234 xChildNode_1_1->setCollapsedGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/sd/res/triangle_right.png" ) ) ); 235 236 xChildNode_1->appendChild( xChildNode_1_1 ); 237 238 const OUString sNode_1_1( RTL_CONSTASCII_USTRINGPARAM( "Node_2" ) ); 239 240 Reference< XMutableTreeNode > xChildNode_2( mxTreeDataModel->createNode( sNode_2, false ), UNO_QUERY_THROW ); 241 xChildNode_2->setDataValue( sNode_2 ); 242 xChildNode_2->setNodeGraphicURL( OUString( RTL_CONSTASCII_USTRINGPARAM("private:graphicrepository/sw/imglst/nc20010.png") ) ); 243 xNode->appendChild( xChildNode_2 ); 244 245 xTreeDataModel->setRoot( xNode ); 246 247 248 const OUString sDataModel( RTL_CONSTASCII_USTRINGPARAM( "DataModel" ) ); 249 250 xPSet->setPropertyValue( sDataModel, xTreeDataModel ); 251 } 252 } 253 catch(...) 254 { 255 }*/ 256 break; 257 } 258 } 259 260 return 0; 261 } 262 263 //---------------------------------------------------------------------------- 264 265