User: kz Date: 2008-03-05 18:13:07+0000 Modified: dba/reportdesign/source/ui/report/ReportController.cxx
Log: INTEGRATION: CWS rptchart01_DEV300 (1.6.16); FILE MERGED 2008/02/20 11:49:56 oj 1.6.16.8: #i85225# execute report is now always enabled, but with error message 2008/02/20 11:25:56 oj 1.6.16.7: #i85225# execute report is now always enabled, but with error message 2008/02/20 11:19:37 oj 1.6.16.6: #i85225# execute report is now always enabled, but with error message 2008/02/20 07:37:25 oj 1.6.16.5: check if chart is enabled 2008/02/19 17:09:52 oj 1.6.16.4: missing eol 2008/02/19 09:23:02 oj 1.6.16.3: RESYNC: (1.6-1.10); FILE MERGED 2008/02/19 06:42:52 oj 1.6.16.2: #i85225# ongoing work 2008/01/24 12:39:33 oj 1.6.16.1: #i85225# changes for chart File Changes: Directory: /dba/reportdesign/source/ui/report/ ============================================== File [changed]: ReportController.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/report/ReportController.cxx?r1=1.10&r2=1.11 Delta lines: +147 -66 ---------------------- --- ReportController.cxx 2008-02-12 13:19:31+0000 1.10 +++ ReportController.cxx 2008-03-05 18:13:04+0000 1.11 @@ -278,6 +278,7 @@ #include <toolkit/helper/vclunohelper.hxx> #endif #include "UndoEnv.hxx" +#include "InsertFunctions.hxx" #include <svx/svdpagv.hxx> #include <boost/mem_fn.hpp> #include <boost/bind.hpp> @@ -287,6 +288,7 @@ #include <com/sun/star/sdbc/SQLWarning.hpp> #include <cppuhelper/exc_hlp.hxx> +#include <unotools/confignode.hxx> #include <helpids.hrc> using namespace ::com::sun::star; @@ -386,6 +388,8 @@ ,m_bShowProperties(sal_True) ,m_bGroupFloaterWasVisible(sal_False) ,m_bHelplinesMove(sal_True) +,m_bChartEnabled(false) +,m_bChartEnabledAsked(false) { DBG_CTOR( rpt_OReportController,NULL); } @@ -609,18 +613,7 @@ aReturn.bEnabled = sal_True; break; case SID_EXECUTE_REPORT: - aReturn.bEnabled = isConnected() && isEditable() && m_xReportDefinition.is() - && m_xReportDefinition->getCommand().getLength(); - if ( aReturn.bEnabled ) - { - aReturn.bEnabled = sal_False; - const sal_uInt16 nCount = m_aReportModel->GetPageCount(); - for (sal_uInt16 i = 0; i < nCount && !aReturn.bEnabled ; ++i) - { - const SdrPage* pPage = m_aReportModel->GetPage(i); - aReturn.bEnabled = pPage->GetObjCount() != 0; - } - } + aReturn.bEnabled = isConnected() && m_xReportDefinition.is(); break; case SID_DELETE: aReturn.bEnabled = isEditable() && m_pMyOwnView->HasSelection() && !m_pMyOwnView->isHandleEvent(_nId); @@ -649,6 +642,11 @@ aReturn.bEnabled = sal_True; aReturn.bChecked = m_pMyOwnView->GetMode() == RPTUI_SELECT; break; + case SID_INSERT_DIAGRAM: + aReturn.bEnabled = isEditable(); + aReturn.bInvisible = optional< bool >(!m_bChartEnabled); + aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_OLE2; + break; case SID_FM_FIXEDTEXT: aReturn.bEnabled = isEditable(); aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_DLG_FIXEDTEXT; @@ -1006,9 +1004,6 @@ case SID_DATETIME: aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && m_pMyOwnView->getCurrentSection().is(); break; - case SID_INSERT_DIAGRAM: - aReturn.bEnabled = isEditable(); - break; case SID_EXPORTDOC: case SID_EXPORTDOCASPDF: aReturn.bEnabled = m_xReportDefinition.is(); @@ -1257,6 +1252,20 @@ m_pMyOwnView->SetMode(RPTUI_SELECT); InvalidateAll(); break; + case SID_INSERT_DIAGRAM: + /*{ + OSectionView* pView = getCurrentSectionView(); + if ( pView ) + { + Reference< awt::XWindow> xWindow = VCLUnoHelper::GetInterface(getView()->Window::GetParent()); + InsertChart(m_xContext,m_xReportDefinition.get(),xWindow,pView,getSdrModel().get()); + } + }*/ + m_pMyOwnView->SetMode( RPTUI_INSERT ); + m_pMyOwnView->SetInsertObj( OBJ_OLE2); + createDefaultControl(aArgs); + InvalidateAll(); + break; case SID_FM_FIXEDTEXT: m_pMyOwnView->SetMode( RPTUI_INSERT ); m_pMyOwnView->SetInsertObj( OBJ_DLG_FIXEDTEXT ); @@ -1666,7 +1675,6 @@ createPageNumber(aArgs); } // if ( m_xReportDefinition.is() ) break; - case SID_INSERT_DIAGRAM: case SID_EXPORTDOC: case SID_EXPORTDOCASPDF: break; @@ -1779,6 +1787,8 @@ } // if ( m_xReportDefinition.is() ) + // check if chart is supported by the engine + checkChartEnabled(); // restore the view data m_pMyOwnView->toggleGrid(m_bGridVisible); m_pMyOwnView->showRuler(m_bShowRuler); @@ -1910,11 +1920,6 @@ implDescribeSupportedFeature( ".uno:ReportHeaderFooter", SID_REPORTHEADERFOOTER, CommandGroup::VIEW ); //implDescribeSupportedFeature( ".uno:SwitchControlDesignMode", SID_FM_DESIGN_MODE, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:InsertPageNumberField", SID_INSERT_FLD_PGNUMBER, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:InsertDateTimeField", SID_DATETIME, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:InsertObjectChart", SID_INSERT_DIAGRAM, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:InsertGraphic", SID_INSERT_GRAPHIC, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:ConditionalFormatting", SID_CONDITIONALFORMATTING, CommandGroup::FORMAT ); implDescribeSupportedFeature( ".uno:PageDialog", SID_PAGEDIALOG, CommandGroup::FORMAT ); implDescribeSupportedFeature( ".uno:ResetAttributes", SID_SETCONTROLDEFAULTS, CommandGroup::FORMAT ); @@ -1973,6 +1978,10 @@ implDescribeSupportedFeature( ".uno:Save", SID_SAVEDOC, CommandGroup::DOCUMENT ); implDescribeSupportedFeature( ".uno:SaveAs", SID_SAVEASDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( ".uno:InsertPageNumberField", SID_INSERT_FLD_PGNUMBER, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:InsertDateTimeField", SID_DATETIME, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:InsertObjectChart", SID_INSERT_DIAGRAM, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:InsertGraphic", SID_INSERT_GRAPHIC, CommandGroup::INSERT ); // controls implDescribeSupportedFeature( ".uno:SelectObject", SID_OBJECT_SELECT, CommandGroup::INSERT ); implDescribeSupportedFeature( ".uno:Label", SID_FM_FIXEDTEXT, CommandGroup::INSERT ); @@ -2909,10 +2918,59 @@ // ----------------------------------------------------------------------------- uno::Reference<frame::XModel> OReportController::executeReport() { + OSL_ENSURE(m_xReportDefinition.is(),"Where is my report?"); + uno::Reference<frame::XModel> xModel; if ( m_xReportDefinition.is() ) { + sal_uInt16 nErrorId = RID_ERR_NO_COMMAND; + bool bEnabled = m_xReportDefinition->getCommand().getLength() != 0; + if ( bEnabled ) + { + bEnabled = false; + const sal_uInt16 nCount = m_aReportModel->GetPageCount(); + sal_uInt16 i = 0; + for (; i < nCount && !bEnabled ; ++i) + { + const SdrPage* pPage = m_aReportModel->GetPage(i); + bEnabled = pPage->GetObjCount() != 0; + } + if ( !bEnabled ) + nErrorId = RID_ERR_NO_OBJECTS; + } + dbtools::SQLExceptionInfo aInfo; + if ( !bEnabled ) + { + sdb::SQLContext aFirstMessage; + String sInfo = String( ModuleRes( nErrorId ) ); + aFirstMessage.Message = sInfo; + aInfo = aFirstMessage; + if ( isEditable() ) + { + sal_uInt16 nCommand = 0; + if ( nErrorId == RID_ERR_NO_COMMAND ) + { + if ( !m_bShowProperties ) + executeUnChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue>()); + + m_sLastActivePage = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data")); + m_pMyOwnView->setCurrentPage(m_sLastActivePage); + nCommand = SID_SELECT_REPORT; + } + else if ( m_pMyOwnView && !m_pMyOwnView->isAddFieldVisible() ) + { + nCommand = SID_FM_ADD_FIELD; + } + if ( nCommand ) + { + uno::Sequence< beans::PropertyValue> aArgs; + executeUnChecked(nCommand,aArgs); + } + } + } + else + { try { WaitObject aWait(getView()); // cursor @@ -2920,11 +2978,6 @@ m_xReportEngine.set(getORB()->createInstance(SERVICE_REPORTENGINE),uno::UNO_QUERY_THROW); m_xReportEngine->setReportDefinition(m_xReportDefinition); m_xReportEngine->setActiveConnection(getConnection()); - // if ( !m_xFrameLoader.is() ) - // m_xFrameLoader.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))),uno::UNO_QUERY_THROW); - // const sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE; - // const ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank")); - // Reference<XFrame> xFrame = Reference<XFrame>(m_xFrameLoader,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag); Reference<XFrame> xFrame = getXFrame(); xModel = m_xReportEngine->createDocumentAlive(xFrame); } @@ -2962,11 +3015,15 @@ aInfo = aFirstMessage; } - if (aInfo.isValid()) { const String suSQLContext = String( ModuleRes( RID_STR_COULD_NOT_CREATE_REPORT ) ); aInfo.prepend(suSQLContext); + } + } + + if (aInfo.isValid()) + { showError(aInfo); } } @@ -3929,3 +3986,27 @@ return m_xFormatter; } // ----------------------------------------------------------------------------- +void OReportController::checkChartEnabled() +{ + if ( !m_bChartEnabledAsked ) + { + m_bChartEnabledAsked = true; + const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign" ) ); + const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "UserData/Chart" ) ); + + try + { + ::utl::OConfigurationTreeRoot aConfiguration( + ::utl::OConfigurationTreeRoot::createWithServiceFactory( m_xServiceFactory, sConfigName ) ); + + sal_Bool bChartEnabled = sal_False; + if ( aConfiguration.hasByHierarchicalName(sPropertyName) ) + aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled; + m_bChartEnabled = bChartEnabled; + } + catch(const Exception&) + { + } + } +} + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
