Tag: cws_src680_oj14 User: oj Date: 2007-05-11 12:05:28+0000 Modified: dba/reportdesign/source/inc/uistrings.hrc dba/reportdesign/source/shared/uistrings.cxx dba/reportdesign/source/ui/dlg/DateTime.cxx dba/reportdesign/source/ui/inc/ReportController.hxx dba/reportdesign/source/ui/report/ReportController.cxx
Log: #i77039# insert correct date time functions File Changes: Directory: /dba/reportdesign/source/inc/ ======================================== File [changed]: uistrings.hrc Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/inc/uistrings.hrc?r1=1.1.2.1&r2=1.1.2.2 Delta lines: +4 -2 ------------------- --- uistrings.hrc 2007-05-09 13:55:50+0000 1.1.2.1 +++ uistrings.hrc 2007-05-11 12:05:24+0000 1.1.2.2 @@ -4,9 +4,9 @@ * * $RCSfile: uistrings.hrc,v $ * - * $Revision: 1.1.2.1 $ + * $Revision: 1.1.2.2 $ * - * last change: $Author: oj $ $Date: 2007/05/09 13:55:50 $ + * last change: $Author: oj $ $Date: 2007/05/11 12:05:24 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -62,6 +62,8 @@ DECLARE_CONSTASCII_USTRING(PROPERTY_EMPTY_IS_NULL ); DECLARE_CONSTASCII_USTRING(PROPERTY_FILTERPROPOSAL ); DECLARE_CONSTASCII_USTRING(PROPERTY_POSITION ); +DECLARE_CONSTASCII_USTRING(PROPERTY_FORMATKEYDATE ); +DECLARE_CONSTASCII_USTRING(PROPERTY_FORMATKEYTIME ); } Directory: /dba/reportdesign/source/shared/ =========================================== File [changed]: uistrings.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/shared/uistrings.cxx?r1=1.1.2.1&r2=1.1.2.2 Delta lines: +4 -2 ------------------- --- uistrings.cxx 2007-05-09 13:49:21+0000 1.1.2.1 +++ uistrings.cxx 2007-05-11 12:05:25+0000 1.1.2.2 @@ -4,9 +4,9 @@ * * $RCSfile: uistrings.cxx,v $ * - * $Revision: 1.1.2.1 $ + * $Revision: 1.1.2.2 $ * - * last change: $Author: oj $ $Date: 2007/05/09 13:49:21 $ + * last change: $Author: oj $ $Date: 2007/05/11 12:05:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -56,5 +56,7 @@ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_EMPTY_IS_NULL , "ConvertEmptyToNull"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILTERPROPOSAL , "UseFilterValueProposal"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_POSITION , "Position"); + IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FORMATKEYDATE , "FormatKeyDate"); + IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FORMATKEYTIME , "FormatKeyTime"); } Directory: /dba/reportdesign/source/ui/dlg/ =========================================== File [changed]: DateTime.cxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/dlg/DateTime.cxx?r1=1.1.2.1&r2=1.1.2.2 Delta lines: +17 -43 --------------------- --- DateTime.cxx 2007-05-09 13:50:29+0000 1.1.2.1 +++ DateTime.cxx 2007-05-11 12:05:25+0000 1.1.2.2 @@ -4,9 +4,9 @@ * * $RCSfile: DateTime.cxx,v $ * - * $Revision: 1.1.2.1 $ + * $Revision: 1.1.2.2 $ * - * last change: $Author: oj $ $Date: 2007/05/09 13:50:29 $ + * last change: $Author: oj $ $Date: 2007/05/11 12:05:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -177,47 +177,21 @@ { try { - struct THelper - { - ::rtl::OUString sElementName; - USHORT nStringResId; - ::rtl::OUString sDataField; - sal_Int32 nWidth; - sal_uInt32 nHeight; - sal_Int32 nFormat; - }; - sal_Int32 nF1 = getFormatKey(getFormatIndex(sal_True)); - sal_Int32 nF2 = getFormatKey(getFormatIndex(sal_False)); - - THelper pHelper[] = { - {SERVICE_FORMATTEDFIELD,0,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=TODAY()")),6000,397,nF1}, - {SERVICE_FORMATTEDFIELD,0,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=NOW()")),6000,397,nF2}, - }; + sal_Int32 nLength = 0; + uno::Sequence<beans::PropertyValue> aValues( 4 ); + aValues[nLength].Name = PROPERTY_SECTION; + aValues[nLength++].Value <<= m_xHoldAlive; - int nCount = sizeof(pHelper)/sizeof(pHelper[0]); - int i = 0; - if ( !m_aDate.IsChecked() ) - i = 1; - if ( !m_aTime.IsChecked() ) - --nCount; - - uno::Reference< report::XReportDefinition > xReport = m_xHoldAlive->getReportDefinition(); - uno::Reference< lang::XMultiServiceFactory > xFac(xReport,uno::UNO_QUERY); - sal_Int32 nPosY = 0; - for (; i < nCount; ++i) - { - uno::Reference< report::XFormattedField > xElem(xFac->createInstance(pHelper[i].sElementName),uno::UNO_QUERY); - if ( m_xHoldAlive->getHeight() < sal_uInt32(nPosY + pHelper[i].nHeight) ) - m_xHoldAlive->setHeight(sal_uInt32(nPosY + pHelper[i].nHeight)); - xElem->setPositionX(lcl_getStyleProperty<sal_Int32>(xReport,PROPERTY_LEFTMARGIN)); - xElem->setPositionY(nPosY); - xElem->setDataField(pHelper[i].sDataField); - xElem->setFormatKey(pHelper[i].nFormat); - xElem->setHeight(pHelper[i].nHeight); - xElem->setWidth(pHelper[i].nWidth); - m_xHoldAlive->add(xElem.get()); - nPosY += pHelper[i].nHeight; - } + aValues[nLength].Name = PROPERTY_STATE; + aValues[nLength++].Value <<= m_aTime.IsChecked(); + + aValues[nLength].Name = PROPERTY_FORMATKEYDATE; + aValues[nLength++].Value <<= getFormatKey(getFormatIndex(sal_True)); + + aValues[nLength].Name = PROPERTY_FORMATKEYTIME; + aValues[nLength++].Value <<= getFormatKey(getFormatIndex(sal_False)); + + m_pController->executeChecked(SID_DATETIME,aValues); } catch(uno::Exception&) { Directory: /dba/reportdesign/source/ui/inc/ =========================================== File [changed]: ReportController.hxx Url: http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inc/ReportController.hxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +15 -2 -------------------- --- ReportController.hxx 2007-05-11 09:24:19+0000 1.1.2.2 +++ ReportController.hxx 2007-05-11 12:05:25+0000 1.1.2.3 @@ -6,9 +6,9 @@ * * $RCSfile: ReportController.hxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: oj $ $Date: 2007/05/11 09:24:19 $ + * last change: $Author: oj $ $Date: 2007/05/11 12:05:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -163,6 +163,13 @@ sal_Bool m_bHelplinesMove; + /** creates a formatted field in the given section with the given formula as data field + * + * \param _aArgs + * \param _xSection the section where to create the formatted field + * \param _sFunction the function which will be set at the data field. + */ + void createControls(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _aArgs,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection,const ::rtl::OUString& _sFunction ); /** switch the report header/footer sectionon off with undo or without depending on the given id. * * \param _nId Can either be SID_REPORTHEADER_WITHOUT_UNDO or SID_REPORTFOOTER_WITHOUT_UNDO or SID_REPORTHEADERFOOTER. @@ -261,6 +268,12 @@ */ void createPageNumber(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _aArgs); + /** creates a formatted filed with TODAY() function and if set also an NOW() function + * + * \param _aArgs + */ + void createDateTime(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _aArgs); + /** gets the current section (SdrView) * * \return the currently selected section or <NULL/> if noone is selected 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.1.2.2&r2=1.1.2.3 Delta lines: +72 -35 --------------------- --- ReportController.cxx 2007-05-11 09:24:19+0000 1.1.2.2 +++ ReportController.cxx 2007-05-11 12:05:25+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: ReportController.cxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: oj $ $Date: 2007/05/11 09:24:19 $ + * last change: $Author: oj $ $Date: 2007/05/11 12:05:25 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -1543,8 +1543,13 @@ case SID_DATETIME: if ( m_xReportDefinition.is() ) { + if ( !aArgs.getLength() ) + { ODateTimeDialog aDlg(getView(),m_pMyOwnView->getCurrentSection(),this); aDlg.Execute(); + } + else + createDateTime(aArgs); } // if ( m_xReportDefinition.is() ) break; case SID_INSERT_FLD_PGNUMBER: @@ -3043,24 +3048,13 @@ return 0L; } // ----------------------------------------------------------------------------- -void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs) +void OReportController::createControls(const Sequence< PropertyValue >& _aArgs,const uno::Reference< report::XSection>& _xSection,const ::rtl::OUString& _sFunction ) { - m_pMyOwnView->unmarkAllObjects(NULL); - - const String sUndoAction(String(ModuleRes(RID_STR_UNDO_INSERT_CONTROL))); - getUndoMgr()->EnterListAction( sUndoAction, String() ); - - if ( !m_xReportDefinition->getPageHeaderOn() ) - { - uno::Sequence< beans::PropertyValue > aArgs; - executeChecked(SID_PAGEHEADERFOOTER,aArgs); - } // if ( !m_xHoldAlive->getPageHeaderOn() ) - SequenceAsHashMap aMap(_aArgs); - sal_Bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON,sal_True); - sal_Bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE,sal_False); - m_pMyOwnView->setMarked(bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter() ,sal_True); + m_pMyOwnView->setMarked(_xSection ,sal_True); ::boost::shared_ptr<OReportSection> pReportSection = m_pMyOwnView->getMarkedSection(); + if ( !pReportSection ) + return; sal_Int32 nLeftMargin = lcl_getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN); const sal_Int32 nRightMargin = lcl_getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN); @@ -3090,24 +3084,12 @@ xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER)); if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) ) { - //::rtl::OUString sName; - //xUnoProp->getPropertyValue(PROPERTY_DATAFIELD) >>= sName; - //sDefaultName = sName; - //xUnoProp->setPropertyValue(PROPERTY_NAME,uno::makeAny(sDefaultName)); - String sFunction = String(ModuleRes(STR_RPT_PN_PAGE)); - ::rtl::OUString sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()")); - sFunction.SearchAndReplace(String::CreateFromAscii("#PAGENUMBER#"),sPageNumber); - - if ( bStateOfPage ) - { - ::rtl::OUString sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()")); - sFunction += String(ModuleRes(STR_RPT_PN_PAGE_OF)); - sFunction.SearchAndReplace(String::CreateFromAscii("#PAGECOUNT#"),sPageCount); - } - - ReportFormula aFunctionFormula( ReportFormula::Expression, sFunction ); + ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction ); xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) ); } + sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0)); + if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) ) + xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) ); pObj->CreateMediator(sal_True); const sal_Int32 nShapeWidth = xShapeProp->getWidth(); @@ -3117,6 +3099,61 @@ xShapeProp->setPosition(aPos); lcl_correctOverlapping(pControl,pReportSection); +} +// ----------------------------------------------------------------------------- +void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs) +{ + m_pMyOwnView->unmarkAllObjects(NULL); + + const String sUndoAction(String(ModuleRes(RID_STR_UNDO_INSERT_CONTROL))); + getUndoMgr()->EnterListAction( sUndoAction, String() ); + + SequenceAsHashMap aMap(_aArgs); + aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0))); + + uno::Reference< report::XSection> xSection = aMap.getUnpackedValueOrDefault(PROPERTY_SECTION,uno::Reference< report::XSection>()); + ::rtl::OUString sFunction(RTL_CONSTASCII_USTRINGPARAM("TODAY()")); + createControls(aMap.getAsConstPropertyValueList(),xSection,sFunction); + sal_Bool bTime = aMap.getUnpackedValueOrDefault(PROPERTY_STATE,sal_False); + if ( bTime ) + { + sFunction = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("NOW()")); + aMap[PROPERTY_FORMATKEY] <<= aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYTIME,sal_Int32(0)); + createControls(aMap.getAsConstPropertyValueList(),xSection,sFunction); + } + + getUndoMgr()->LeaveListAction(); +} +// ----------------------------------------------------------------------------- +void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs) +{ + m_pMyOwnView->unmarkAllObjects(NULL); + + const String sUndoAction(String(ModuleRes(RID_STR_UNDO_INSERT_CONTROL))); + getUndoMgr()->EnterListAction( sUndoAction, String() ); + + if ( !m_xReportDefinition->getPageHeaderOn() ) + { + uno::Sequence< beans::PropertyValue > aArgs; + executeChecked(SID_PAGEHEADERFOOTER,aArgs); + } // if ( !m_xHoldAlive->getPageHeaderOn() ) + + SequenceAsHashMap aMap(_aArgs); + sal_Bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE,sal_False); + + String sFunction = String(ModuleRes(STR_RPT_PN_PAGE)); + ::rtl::OUString sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()")); + sFunction.SearchAndReplace(String::CreateFromAscii("#PAGENUMBER#"),sPageNumber); + + if ( bStateOfPage ) + { + ::rtl::OUString sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()")); + sFunction += String(ModuleRes(STR_RPT_PN_PAGE_OF)); + sFunction.SearchAndReplace(String::CreateFromAscii("#PAGECOUNT#"),sPageCount); + } + + sal_Bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON,sal_True); + createControls(_aArgs,bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter(),sFunction); getUndoMgr()->LeaveListAction(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
