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