19e0e4191SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file 59e0e4191SAndrew Rist * distributed with this work for additional information 69e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the 89e0e4191SAndrew Rist * "License"); you may not use this file except in compliance 99e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at 109e0e4191SAndrew Rist * 119e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 129e0e4191SAndrew Rist * 139e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing, 149e0e4191SAndrew Rist * software distributed under the License is distributed on an 159e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169e0e4191SAndrew Rist * KIND, either express or implied. See the License for the 179e0e4191SAndrew Rist * specific language governing permissions and limitations 189e0e4191SAndrew Rist * under the License. 199e0e4191SAndrew Rist * 209e0e4191SAndrew Rist *************************************************************/ 219e0e4191SAndrew Rist 229e0e4191SAndrew Rist 23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx" 24cdf0e10cSrcweir #include "propbrw.hxx" 25cdf0e10cSrcweir #include "RptObject.hxx" 26cdf0e10cSrcweir #include "ReportController.hxx" 27cdf0e10cSrcweir #include <cppuhelper/component_context.hxx> 28cdf0e10cSrcweir #ifndef _REPORT_DLGRESID_HRC 29cdf0e10cSrcweir #include <RptResId.hrc> 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #ifndef _RPTUI_SLOTID_HRC_ 32cdf0e10cSrcweir #include "rptui_slotid.hrc" 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #include <tools/debug.hxx> 35cdf0e10cSrcweir #include <com/sun/star/awt/XLayoutConstrains.hpp> 36cdf0e10cSrcweir #include <com/sun/star/inspection/ObjectInspector.hpp> 37cdf0e10cSrcweir #include <com/sun/star/inspection/DefaultHelpProvider.hpp> 38cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC 39cdf0e10cSrcweir #include <svx/svxids.hrc> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #include <vcl/stdtext.hxx> 42cdf0e10cSrcweir #include <svx/svdview.hxx> 43cdf0e10cSrcweir #include <svx/svdogrp.hxx> 44cdf0e10cSrcweir #include <svx/svdpage.hxx> 45cdf0e10cSrcweir #include <svx/svditer.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 48cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #include <comphelper/property.hxx> 51cdf0e10cSrcweir #include <comphelper/namecontainer.hxx> 52cdf0e10cSrcweir #include <comphelper/composedprops.hxx> 53cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 54cdf0e10cSrcweir #include <comphelper/types.hxx> 55cdf0e10cSrcweir #include <comphelper/sequence.hxx> 56cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 57cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 58cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 59cdf0e10cSrcweir #include <com/sun/star/report/inspection/DefaultComponentInspectorModel.hpp> 60cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 61cdf0e10cSrcweir #include "SectionView.hxx" 62cdf0e10cSrcweir #include "ReportSection.hxx" 63cdf0e10cSrcweir #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC 64cdf0e10cSrcweir #include "uistrings.hrc" 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #include "DesignView.hxx" 67cdf0e10cSrcweir #include "ViewsWindow.hxx" 68cdf0e10cSrcweir #include "UITools.hxx" 69cdf0e10cSrcweir #include <unotools/confignode.hxx> 70cdf0e10cSrcweir 71cdf0e10cSrcweir namespace rptui 72cdf0e10cSrcweir { 73cdf0e10cSrcweir #define STD_WIN_SIZE_X 300 74cdf0e10cSrcweir #define STD_WIN_SIZE_Y 350 75cdf0e10cSrcweir 76cdf0e10cSrcweir using namespace ::com::sun::star; 77cdf0e10cSrcweir using namespace uno; 78cdf0e10cSrcweir using namespace lang; 79cdf0e10cSrcweir using namespace frame; 80cdf0e10cSrcweir using namespace beans; 81cdf0e10cSrcweir using namespace container; 82cdf0e10cSrcweir using namespace ::comphelper; 83cdf0e10cSrcweir 84cdf0e10cSrcweir //---------------------------------------------------------------------------- 85cdf0e10cSrcweir //----------------------------------------------------------------------- 86cdf0e10cSrcweir namespace 87cdf0e10cSrcweir { 88cdf0e10cSrcweir static bool lcl_shouldEnableHelpSection( const Reference< XMultiServiceFactory >& _rxFactory ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign/PropertyBrowser/" ) ); 91cdf0e10cSrcweir const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DirectHelp" ) ); 92cdf0e10cSrcweir 93cdf0e10cSrcweir ::utl::OConfigurationTreeRoot aConfiguration( 94cdf0e10cSrcweir ::utl::OConfigurationTreeRoot::createWithServiceFactory( _rxFactory, sConfigName ) ); 95cdf0e10cSrcweir 96cdf0e10cSrcweir bool bEnabled = false; 97cdf0e10cSrcweir OSL_VERIFY( aConfiguration.getNodeValue( sPropertyName ) >>= bEnabled ); 98cdf0e10cSrcweir return bEnabled; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir } 101cdf0e10cSrcweir //----------------------------------------------------------------------- 102cdf0e10cSrcweir //============================================================================ 103cdf0e10cSrcweir // PropBrw 104cdf0e10cSrcweir //============================================================================ 105cdf0e10cSrcweir 106cdf0e10cSrcweir DBG_NAME( rpt_PropBrw ) 107cdf0e10cSrcweir 108cdf0e10cSrcweir //---------------------------------------------------------------------------- 109cdf0e10cSrcweir 110cdf0e10cSrcweir PropBrw::PropBrw(const Reference< XMultiServiceFactory >& _xORB,Window* pParent,ODesignView* _pDesignView) 111cdf0e10cSrcweir :DockingWindow(pParent,WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE)) 112cdf0e10cSrcweir ,m_xORB(_xORB) 113cdf0e10cSrcweir ,m_pDesignView(_pDesignView) 114cdf0e10cSrcweir ,m_pView( NULL ) 115cdf0e10cSrcweir ,m_bInitialStateChange(sal_True) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir DBG_CTOR( rpt_PropBrw,NULL); 118cdf0e10cSrcweir 119cdf0e10cSrcweir Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y); 120cdf0e10cSrcweir SetOutputSizePixel(aPropWinSize); 121cdf0e10cSrcweir 122cdf0e10cSrcweir try 123cdf0e10cSrcweir { 124cdf0e10cSrcweir // create a frame wrapper for myself 125cdf0e10cSrcweir m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame"))), UNO_QUERY); 126cdf0e10cSrcweir if (m_xMeAsFrame.is()) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir m_xMeAsFrame->initialize( VCLUnoHelper::GetInterface ( this ) ); 129cdf0e10cSrcweir m_xMeAsFrame->setName(::rtl::OUString::createFromAscii("report property browser")); // change name! 130cdf0e10cSrcweir } 131cdf0e10cSrcweir } 132cdf0e10cSrcweir catch (Exception&) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir DBG_ERROR("PropBrw::PropBrw: could not create/initialize my frame!"); 135cdf0e10cSrcweir m_xMeAsFrame.clear(); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir if (m_xMeAsFrame.is()) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir Reference< XComponentContext > xOwnContext; 141cdf0e10cSrcweir try 142cdf0e10cSrcweir { 143cdf0e10cSrcweir // our own component context 144cdf0e10cSrcweir Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW ); 145cdf0e10cSrcweir xOwnContext.set( 146cdf0e10cSrcweir xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), 147cdf0e10cSrcweir UNO_QUERY_THROW ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir /*uno::Reference< XComponent> xModel = new OContextHelper(m_xORB,uno::Reference< XComponent>(m_pDesignView->getController().getModel(),uno::UNO_QUERY) ); 150cdf0e10cSrcweir uno::Reference< XComponent> xDialogParentWindow = new OContextHelper(m_xORB,uno::Reference< XComponent>(VCLUnoHelper::GetInterface ( this ),uno::UNO_QUERY) ); 151cdf0e10cSrcweir uno::Reference< XComponent> xConnection = new OContextHelper(m_xORB,uno::Reference< XComponent>(m_pDesignView->getController().getConnection(),uno::UNO_QUERY) );*/ 152cdf0e10cSrcweir // a ComponentContext for the 153cdf0e10cSrcweir ::cppu::ContextEntry_Init aHandlerContextInfo[] = 154cdf0e10cSrcweir { 155cdf0e10cSrcweir ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( m_pDesignView->getController().getModel() )), 156cdf0e10cSrcweir ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface ( this ) )), 157cdf0e10cSrcweir ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ), makeAny( m_pDesignView->getController().getConnection() ) ), 158cdf0e10cSrcweir }; 159cdf0e10cSrcweir m_xInspectorContext.set( 160cdf0e10cSrcweir ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), 161cdf0e10cSrcweir xOwnContext ) ); 162cdf0e10cSrcweir // create a property browser controller 163cdf0e10cSrcweir bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB ); 164cdf0e10cSrcweir Reference< inspection::XObjectInspectorModel> xInspectorModel( bEnableHelpSection 165cdf0e10cSrcweir ? report::inspection::DefaultComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 8 ) 166cdf0e10cSrcweir : report::inspection::DefaultComponentInspectorModel::createDefault( m_xInspectorContext ) ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir m_xBrowserController = inspection::ObjectInspector::createWithModel(m_xInspectorContext, xInspectorModel); 169cdf0e10cSrcweir if ( !m_xBrowserController.is() ) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) ); 172cdf0e10cSrcweir ShowServiceNotAvailableError(pParent, sServiceName, sal_True); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir else 175cdf0e10cSrcweir { 176cdf0e10cSrcweir m_xBrowserController->attachFrame(m_xMeAsFrame); 177cdf0e10cSrcweir m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow(); 178cdf0e10cSrcweir OSL_ENSURE(m_xBrowserComponentWindow.is(), "PropBrw::PropBrw: attached the controller, but have no component window!"); 179cdf0e10cSrcweir if ( bEnableHelpSection ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir uno::Reference< inspection::XObjectInspector > xInspector( m_xBrowserController, uno::UNO_QUERY_THROW ); 182cdf0e10cSrcweir uno::Reference< inspection::XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() ); 183cdf0e10cSrcweir uno::Reference< uno::XInterface > xDefaultHelpProvider( inspection::DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI ) ); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir } 186cdf0e10cSrcweir xFactoryProperties->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ,makeAny(xOwnContext)); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir catch (Exception&) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir DBG_ERROR("PropBrw::PropBrw: could not create/initialize the browser controller!"); 191cdf0e10cSrcweir try 192cdf0e10cSrcweir { 193cdf0e10cSrcweir ::comphelper::disposeComponent(m_xBrowserController); 194cdf0e10cSrcweir ::comphelper::disposeComponent(m_xBrowserComponentWindow); 195cdf0e10cSrcweir Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW ); 196cdf0e10cSrcweir if ( xOwnContext.is() ) 197cdf0e10cSrcweir xFactoryProperties->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ,makeAny(xOwnContext)); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir catch(Exception&) { } 200cdf0e10cSrcweir m_xBrowserController.clear(); 201cdf0e10cSrcweir m_xBrowserComponentWindow.clear(); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir if (m_xBrowserComponentWindow.is()) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir 208cdf0e10cSrcweir m_xBrowserComponentWindow->setPosSize(0, 0, aPropWinSize.Width(), aPropWinSize.Height(), 209cdf0e10cSrcweir awt::PosSize::WIDTH | awt::PosSize::HEIGHT | awt::PosSize::X | awt::PosSize::Y); 210cdf0e10cSrcweir Resize(); 211cdf0e10cSrcweir m_xBrowserComponentWindow->setVisible(sal_True); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir ::rptui::notifySystemWindow(pParent,this,::comphelper::mem_fun(&TaskPaneList::AddWindow)); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir //---------------------------------------------------------------------------- 217cdf0e10cSrcweir 218cdf0e10cSrcweir PropBrw::~PropBrw() 219cdf0e10cSrcweir { 220cdf0e10cSrcweir if (m_xBrowserController.is()) 221cdf0e10cSrcweir implDetachController(); 222cdf0e10cSrcweir 223cdf0e10cSrcweir try 224cdf0e10cSrcweir { 225cdf0e10cSrcweir uno::Reference<container::XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY); 226cdf0e10cSrcweir if ( xName.is() ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir const ::rtl::OUString pProps[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ) 229cdf0e10cSrcweir , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ) 230cdf0e10cSrcweir , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) )}; 231cdf0e10cSrcweir for (size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i) 232cdf0e10cSrcweir xName->removeByName(pProps[i]); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir catch(Exception&) 236cdf0e10cSrcweir {} 237cdf0e10cSrcweir 238cdf0e10cSrcweir ::rptui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); 239cdf0e10cSrcweir 240cdf0e10cSrcweir DBG_DTOR( rpt_PropBrw,NULL); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir // ----------------------------------------------------------------------------- 243cdf0e10cSrcweir void PropBrw::setCurrentPage(const ::rtl::OUString& _sLastActivePage) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir m_sLastActivePage = _sLastActivePage; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir //---------------------------------------------------------------------------- 248cdf0e10cSrcweir 249cdf0e10cSrcweir void PropBrw::implDetachController() 250cdf0e10cSrcweir { 251cdf0e10cSrcweir m_sLastActivePage = getCurrentPage(); 252cdf0e10cSrcweir implSetNewObject( ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir if ( m_xMeAsFrame.is() ) 255cdf0e10cSrcweir m_xMeAsFrame->setComponent( NULL, NULL ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir if ( m_xBrowserController.is() ) 258cdf0e10cSrcweir m_xBrowserController->attachFrame( NULL ); 259cdf0e10cSrcweir 260cdf0e10cSrcweir m_xMeAsFrame.clear(); 261cdf0e10cSrcweir m_xBrowserController.clear(); 262cdf0e10cSrcweir m_xBrowserComponentWindow.clear(); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir //----------------------------------------------------------------------- 265cdf0e10cSrcweir ::rtl::OUString PropBrw::getCurrentPage() const 266cdf0e10cSrcweir { 267cdf0e10cSrcweir ::rtl::OUString sCurrentPage; 268cdf0e10cSrcweir try 269cdf0e10cSrcweir { 270cdf0e10cSrcweir if ( m_xBrowserController.is() ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage ); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir if ( !sCurrentPage.getLength() ) 276cdf0e10cSrcweir sCurrentPage = m_sLastActivePage; 277cdf0e10cSrcweir } 278cdf0e10cSrcweir catch( const Exception& ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir OSL_ENSURE( sal_False, "PropBrw::getCurrentPage: caught an exception while retrieving the current page!" ); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir return sCurrentPage; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir //---------------------------------------------------------------------------- 285cdf0e10cSrcweir 286cdf0e10cSrcweir sal_Bool PropBrw::Close() 287cdf0e10cSrcweir { 288cdf0e10cSrcweir m_xLastSection.clear(); 289cdf0e10cSrcweir // suspend the controller (it is allowed to veto) 290cdf0e10cSrcweir if ( m_xMeAsFrame.is() ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir try 293cdf0e10cSrcweir { 294cdf0e10cSrcweir Reference< XController > xController( m_xMeAsFrame->getController() ); 295cdf0e10cSrcweir if ( xController.is() && !xController->suspend( sal_True ) ) 296cdf0e10cSrcweir return sal_False; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir catch( const Exception& ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::Close: caught an exception while asking the controller!" ); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir implDetachController(); 304cdf0e10cSrcweir 305cdf0e10cSrcweir if( IsRollUp() ) 306cdf0e10cSrcweir RollDown(); 307cdf0e10cSrcweir 308cdf0e10cSrcweir m_pDesignView->getController().executeUnChecked(SID_PROPERTYBROWSER_LAST_PAGE,uno::Sequence< beans::PropertyValue>()); 309cdf0e10cSrcweir 310cdf0e10cSrcweir return sal_True; 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313cdf0e10cSrcweir //---------------------------------------------------------------------------- 314cdf0e10cSrcweir 315cdf0e10cSrcweir uno::Sequence< Reference<uno::XInterface> > PropBrw::CreateCompPropSet(const SdrMarkList& _rMarkList) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir sal_uInt32 nMarkCount = _rMarkList.GetMarkCount(); 318cdf0e10cSrcweir ::std::vector< uno::Reference< uno::XInterface> > aSets; 319cdf0e10cSrcweir aSets.reserve(nMarkCount); 320cdf0e10cSrcweir 321cdf0e10cSrcweir for(sal_uInt32 i=0;i<nMarkCount;++i) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj(); 324cdf0e10cSrcweir 325cdf0e10cSrcweir ::std::auto_ptr<SdrObjListIter> pGroupIterator; 326cdf0e10cSrcweir if (pCurrent->IsGroupObject()) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir pGroupIterator.reset(new SdrObjListIter(*pCurrent->GetSubList())); 329cdf0e10cSrcweir pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL; 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir while (pCurrent) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir OObjectBase* pObj = dynamic_cast<OObjectBase*>(pCurrent); 335cdf0e10cSrcweir if ( pObj ) 336cdf0e10cSrcweir aSets.push_back(CreateComponentPair(pObj)); 337cdf0e10cSrcweir 338cdf0e10cSrcweir // next element 339cdf0e10cSrcweir pCurrent = pGroupIterator.get() && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir } 342cdf0e10cSrcweir Reference<uno::XInterface> *pSets = aSets.empty() ? NULL : &aSets[0]; 343cdf0e10cSrcweir return uno::Sequence< Reference<uno::XInterface> >(pSets, aSets.size()); 344cdf0e10cSrcweir } 345cdf0e10cSrcweir //---------------------------------------------------------------------------- 346cdf0e10cSrcweir void PropBrw::implSetNewObject( const uno::Sequence< Reference<uno::XInterface> >& _aObjects ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir if ( m_xBrowserController.is() ) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir try 351cdf0e10cSrcweir { 352cdf0e10cSrcweir m_xBrowserController->inspect(uno::Sequence< Reference<uno::XInterface> >()); 353cdf0e10cSrcweir m_xBrowserController->inspect(_aObjects); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir catch( const Exception& ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::StateChanged: caught an exception while setting the initial page!" ); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir //Resize(); 361cdf0e10cSrcweir } 362cdf0e10cSrcweir SetText( GetHeadlineName(_aObjects) ); 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir //---------------------------------------------------------------------------- 366cdf0e10cSrcweir 367cdf0e10cSrcweir ::rtl::OUString PropBrw::GetHeadlineName( const uno::Sequence< Reference<uno::XInterface> >& _aObjects ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir ::rtl::OUString aName; 370cdf0e10cSrcweir if ( !_aObjects.getLength() ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir aName = String(ModuleRes(RID_STR_BRWTITLE_NO_PROPERTIES)); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir else if ( _aObjects.getLength() == 1 ) // single selection 375cdf0e10cSrcweir { 376cdf0e10cSrcweir sal_uInt16 nResId = 0; 377cdf0e10cSrcweir aName = String(ModuleRes(RID_STR_BRWTITLE_PROPERTIES)); 378cdf0e10cSrcweir 379cdf0e10cSrcweir uno::Reference< container::XNameContainer > xNameCont(_aObjects[0],uno::UNO_QUERY); 380cdf0e10cSrcweir Reference< lang::XServiceInfo > xServiceInfo( xNameCont->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent"))), UNO_QUERY ); 381cdf0e10cSrcweir if ( xServiceInfo.is() ) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT ) ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_FIXEDTEXT; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL ) ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_IMAGECONTROL; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD ) ) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_FORMATTED; 394cdf0e10cSrcweir } 395cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_SHAPE ) ) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_SHAPE; 398cdf0e10cSrcweir } 399cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_REPORT; 402cdf0e10cSrcweir } 403cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_SECTION ) ) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_SECTION; 406cdf0e10cSrcweir } 407cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_FUNCTION ) ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_FUNCTION; 410cdf0e10cSrcweir } 411cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_GROUP ) ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_GROUP; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir else if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE ) ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir nResId = RID_STR_PROPTITLE_FIXEDLINE; 418cdf0e10cSrcweir } 419cdf0e10cSrcweir else 420cdf0e10cSrcweir { 421cdf0e10cSrcweir OSL_ENSURE(0,"Unknown service name!"); 422cdf0e10cSrcweir nResId = RID_STR_CLASS_FORMATTEDFIELD; 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425cdf0e10cSrcweir if (nResId) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir aName += String(ModuleRes(nResId)); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir } 430cdf0e10cSrcweir } 431cdf0e10cSrcweir else // multiselection 432cdf0e10cSrcweir { 433cdf0e10cSrcweir aName = String(ModuleRes(RID_STR_BRWTITLE_PROPERTIES)); 434cdf0e10cSrcweir aName += String(ModuleRes(RID_STR_BRWTITLE_MULTISELECT)); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir return aName; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir // ----------------------------------------------------------------------------- 440cdf0e10cSrcweir uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(OObjectBase* _pObj) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir _pObj->initializeOle(); 443cdf0e10cSrcweir return CreateComponentPair(_pObj->getAwtComponent(),_pObj->getReportComponent()); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir //---------------------------------------------------------------------------- 446cdf0e10cSrcweir uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(const uno::Reference< uno::XInterface>& _xFormComponent 447cdf0e10cSrcweir ,const uno::Reference< uno::XInterface>& _xReportComponent) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir uno::Reference< container::XNameContainer > xNameCont = ::comphelper::NameContainer_createInstance(::getCppuType(static_cast<Reference<XInterface> * >(NULL))); 450cdf0e10cSrcweir xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormComponent")),uno::makeAny(_xFormComponent)); 451cdf0e10cSrcweir xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent")),uno::makeAny(_xReportComponent)); 452cdf0e10cSrcweir xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RowSet")) 453cdf0e10cSrcweir ,uno::makeAny(uno::Reference< uno::XInterface>(m_pDesignView->getController().getRowSet()))); 454cdf0e10cSrcweir 455cdf0e10cSrcweir return xNameCont.get(); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir // ----------------------------------------------------------------------------- 458cdf0e10cSrcweir ::Size PropBrw::getMinimumSize() const 459cdf0e10cSrcweir { 460cdf0e10cSrcweir ::Size aSize; 461cdf0e10cSrcweir Reference< awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY ); 462cdf0e10cSrcweir if( xLayoutConstrains.is() ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir awt::Size aMinSize = xLayoutConstrains->getMinimumSize(); 465cdf0e10cSrcweir aMinSize.Height += 4; 466cdf0e10cSrcweir aMinSize.Width += 4; 467cdf0e10cSrcweir aSize.setHeight( aMinSize.Height ); 468cdf0e10cSrcweir aSize.setWidth( aMinSize.Width ); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir return aSize; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir //---------------------------------------------------------------------------- 473cdf0e10cSrcweir void PropBrw::Resize() 474cdf0e10cSrcweir { 475cdf0e10cSrcweir Window::Resize(); 476cdf0e10cSrcweir 477cdf0e10cSrcweir Reference< awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY ); 478cdf0e10cSrcweir if( xLayoutConstrains.is() ) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir ::Size aMinSize = getMinimumSize(); 481cdf0e10cSrcweir SetMinOutputSizePixel( aMinSize ); 482cdf0e10cSrcweir ::Size aSize = GetOutputSizePixel(); 483cdf0e10cSrcweir sal_Bool bResize = sal_False; 484cdf0e10cSrcweir if( aSize.Width() < aMinSize.Width() ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir aSize.setWidth( aMinSize.Width() ); 487cdf0e10cSrcweir bResize = sal_True; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir if( aSize.Height() < aMinSize.Height() ) 490cdf0e10cSrcweir { 491cdf0e10cSrcweir aSize.setHeight( aMinSize.Height() ); 492cdf0e10cSrcweir bResize = sal_True; 493cdf0e10cSrcweir } 494cdf0e10cSrcweir if( bResize ) 495cdf0e10cSrcweir SetOutputSizePixel( aSize ); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir // adjust size 498cdf0e10cSrcweir if (m_xBrowserComponentWindow.is()) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 501cdf0e10cSrcweir m_xBrowserComponentWindow->setPosSize(0, 0, aSize.Width(), aSize.Height(), 502cdf0e10cSrcweir awt::PosSize::WIDTH | awt::PosSize::HEIGHT); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir } 505cdf0e10cSrcweir //---------------------------------------------------------------------------- 506cdf0e10cSrcweir void PropBrw::Update( OSectionView* pNewView ) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir try 509cdf0e10cSrcweir { 510cdf0e10cSrcweir if ( m_pView ) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir EndListening( *(m_pView->GetModel()) ); 513cdf0e10cSrcweir m_pView = NULL; 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir // set focus on initialization 517cdf0e10cSrcweir if ( m_bInitialStateChange ) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir // if we're just newly created, we want to have the focus 520cdf0e10cSrcweir PostUserEvent( LINK( this, PropBrw, OnAsyncGetFocus ) ); 521cdf0e10cSrcweir m_bInitialStateChange = sal_False; 522cdf0e10cSrcweir // and additionally, we want to show the page which was active during 523cdf0e10cSrcweir // our previous incarnation 524cdf0e10cSrcweir if ( m_sLastActivePage.getLength() && m_xBrowserController.is() ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir try 527cdf0e10cSrcweir { 528cdf0e10cSrcweir m_xBrowserController->restoreViewData( makeAny( m_sLastActivePage ) ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir catch( const Exception& ) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::StateChanged: caught an exception while setting the initial page!" ); 533cdf0e10cSrcweir } 534cdf0e10cSrcweir } 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir if ( !pNewView ) 538cdf0e10cSrcweir return; 539cdf0e10cSrcweir else 540cdf0e10cSrcweir m_pView = pNewView; 541cdf0e10cSrcweir 542cdf0e10cSrcweir uno::Sequence< Reference<uno::XInterface> > aMarkedObjects; 543cdf0e10cSrcweir OViewsWindow* pViews = m_pView->getReportSection()->getSectionWindow()->getViewsWindow(); 544cdf0e10cSrcweir const sal_uInt16 nSectionCount = pViews->getSectionCount(); 545cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nSectionCount; ++i) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pSectionWindow = pViews->getSectionWindow(i); 548cdf0e10cSrcweir if ( pSectionWindow ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir const SdrMarkList& rMarkList = pSectionWindow->getReportSection().getSectionView().GetMarkedObjectList(); 551cdf0e10cSrcweir aMarkedObjects = ::comphelper::concatSequences(aMarkedObjects,CreateCompPropSet( rMarkList )); 552cdf0e10cSrcweir } 553cdf0e10cSrcweir } 554cdf0e10cSrcweir 555cdf0e10cSrcweir if ( aMarkedObjects.getLength() ) // multiple selection 556cdf0e10cSrcweir { 557cdf0e10cSrcweir m_xLastSection.clear(); 558cdf0e10cSrcweir implSetNewObject( aMarkedObjects ); 559cdf0e10cSrcweir } 560cdf0e10cSrcweir else if ( m_xLastSection != m_pView->getReportSection()->getSection() ) 561cdf0e10cSrcweir { 562cdf0e10cSrcweir uno::Reference< uno::XInterface> xTemp(m_pView->getReportSection()->getSection()); 563cdf0e10cSrcweir m_xLastSection = xTemp; 564cdf0e10cSrcweir uno::Reference< container::XNameContainer > xNameCont = ::comphelper::NameContainer_createInstance(::getCppuType(static_cast<Reference<XInterface> * >(NULL))); 565cdf0e10cSrcweir xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent")),uno::makeAny(xTemp)); 566cdf0e10cSrcweir xTemp = xNameCont; 567cdf0e10cSrcweir 568cdf0e10cSrcweir implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) ); 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571cdf0e10cSrcweir StartListening( *(m_pView->GetModel()) ); 572cdf0e10cSrcweir } 573cdf0e10cSrcweir catch ( Exception& ) 574cdf0e10cSrcweir { 575*30acf5e8Spfg DBG_ERROR( "PropBrw::Update: Exception occurred!" ); 576cdf0e10cSrcweir } 577cdf0e10cSrcweir } 578cdf0e10cSrcweir //---------------------------------------------------------------------------- 579cdf0e10cSrcweir void PropBrw::Update( const uno::Reference< uno::XInterface>& _xReportComponent) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir if ( m_xLastSection != _xReportComponent ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir m_xLastSection = _xReportComponent; 584cdf0e10cSrcweir try 585cdf0e10cSrcweir { 586cdf0e10cSrcweir if ( m_pView ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir EndListening( *(m_pView->GetModel()) ); 589cdf0e10cSrcweir m_pView = NULL; 590cdf0e10cSrcweir } // if ( m_pView ) 591cdf0e10cSrcweir 592cdf0e10cSrcweir uno::Reference< uno::XInterface> xTemp(CreateComponentPair(_xReportComponent,_xReportComponent)); 593cdf0e10cSrcweir implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) ); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir catch ( Exception& ) 596cdf0e10cSrcweir { 597*30acf5e8Spfg DBG_ERROR( "PropBrw::Update: Exception occurred!" ); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir } 600cdf0e10cSrcweir } 601cdf0e10cSrcweir //----------------------------------------------------------------------- 602cdf0e10cSrcweir IMPL_LINK( PropBrw, OnAsyncGetFocus, void*, ) 603cdf0e10cSrcweir { 604cdf0e10cSrcweir if (m_xBrowserComponentWindow.is()) 605cdf0e10cSrcweir m_xBrowserComponentWindow->setFocus(); 606cdf0e10cSrcweir return 0L; 607cdf0e10cSrcweir } 608cdf0e10cSrcweir //---------------------------------------------------------------------------- 609cdf0e10cSrcweir void PropBrw::LoseFocus() 610cdf0e10cSrcweir { 611cdf0e10cSrcweir DockingWindow::LoseFocus(); 612cdf0e10cSrcweir m_pDesignView->getController().InvalidateAll(); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir //---------------------------------------------------------------------------- 615cdf0e10cSrcweir } 616