Tag: cws_src680_reportdesign01
User: oj      
Date: 2007-10-16 11:55:21+0000
Modified:
   dba/reportdesign/source/ui/dlg/DateTime.cxx
   dba/reportdesign/source/ui/inc/DateTime.hxx
   dba/reportdesign/source/ui/report/ReportController.cxx

Log:
 #i78403# set width for date time control

File Changes:

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.3.20.1&r2=1.3.20.2
Delta lines:  +57 -82
---------------------
--- DateTime.cxx        2007-10-15 12:50:04+0000        1.3.20.1
+++ DateTime.cxx        2007-10-16 11:55:18+0000        1.3.20.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: DateTime.cxx,v $
  *
- *  $Revision: 1.3.20.1 $
+ *  $Revision: 1.3.20.2 $
  *
- *  last change: $Author: lla $ $Date: 2007/10/15 12:50:04 $
+ *  last change: $Author: oj $ $Date: 2007/10/16 11:55:18 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -97,9 +97,7 @@
 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATPREVIEWER_HPP_
 #include <com/sun/star/util/XNumberFormatPreviewer.hpp>
 #endif
-#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
 #include <com/sun/star/util/XNumberFormatTypes.hpp>
-#endif
 #ifndef _COM_SUN_STAR_I18N_NUMBERFORMATINDEX_HPP_
 #include <com/sun/star/i18n/NumberFormatIndex.hpp>
 #endif
@@ -134,8 +132,6 @@
        ,m_aPB_Help(this,       ModuleRes(PB_HELP))
        ,m_pController(_pController)
        ,m_xHoldAlive(_xHoldAlive)
-      ,m_nDateEntryCount(0)
-      ,m_nTimeEntryCount(0)
          ,m_aDateControlling()
          ,m_aTimeControlling()
 {
@@ -145,43 +141,17 @@
        {
                SvtSysLocale aSysLocale;
                m_nLocale = aSysLocale.GetLocaleData().getLocale();
+           // Fill listbox with all well known date types
+        InsertEntry(util::NumberFormat::DATE);
+        InsertEntry(util::NumberFormat::TIME);
        }
        catch(uno::Exception&)
        {
        }
-       // Fill listbox with all well known date types
-       InsertDateEntry(i18n::NumberFormatIndex::DATE_SYSTEM_LONG);
-       InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_DMMMYYYY);
-       InsertDateEntry(i18n::NumberFormatIndex::DATE_SYSTEM_SHORT);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_DDMMYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_DIN_DMMMYYYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_DMMMMYYYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_DIN_DMMMMYYYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_NNDMMMYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_DEF_NNDDMMMYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_NNDMMMMYYYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_NNNNDMMMMYYYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_DIN_MMDD);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_DIN_YYMMDD);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_DIN_YYYYMMDD);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_MMYY);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_SYS_DDMMM);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_MMMM);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_QQJJ);
-    InsertDateEntry(i18n::NumberFormatIndex::DATE_WW);
 
        m_aDateListBox.SetDropDownLineCount(20);
        m_aDateListBox.SelectEntryPos(0);
 
-       // Fill listbox with all well known time types
-       
-    InsertTimeEntry(i18n::NumberFormatIndex::TIME_HHMMSS);
-    InsertTimeEntry(i18n::NumberFormatIndex::TIME_HHMMSSAMPM);
-    InsertTimeEntry(i18n::NumberFormatIndex::TIME_HHMM);
-    InsertTimeEntry(i18n::NumberFormatIndex::TIME_HH_MMSS);
-    InsertTimeEntry(i18n::NumberFormatIndex::TIME_MMSS00);
-    InsertTimeEntry(i18n::NumberFormatIndex::TIME_HH_MMSS00);
-
        m_aTimeListBox.SetDropDownLineCount(20);
     m_aTimeListBox.SelectEntryPos(0);
 
@@ -196,19 +166,24 @@
        FreeResource();
 }
 // 
-----------------------------------------------------------------------------
-    void ODateTimeDialog::InsertDateEntry(sal_Int16 _nNumberFormatId)
+    void ODateTimeDialog::InsertEntry(sal_Int16 _nNumberFormatId)
     {
-        sal_Int16 nPos = m_aDateListBox.InsertEntry( 
getFormatString(_nNumberFormatId) );
-        // m_aDateListBox.SetEntryFlags(m_nDateEntryCount, _nNumberFormatId);
-        m_aDateListBox.SetEntryData(nPos, 
reinterpret_cast<void*>(_nNumberFormatId));
-    }
-    void ODateTimeDialog::InsertTimeEntry(sal_Int16 _nNumberFormatId)
+        const bool bTime = util::NumberFormat::TIME == _nNumberFormatId;
+        ListBox* pListBox = &m_aDateListBox;
+        if ( bTime )
+            pListBox = &m_aTimeListBox;
+        
+        const uno::Reference< util::XNumberFormatter> xNumberFormatter = 
m_pController->getReportNumberFormatter();
+           const uno::Reference< util::XNumberFormats> xFormats = 
xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats();
+        const uno::Sequence<sal_Int32> aFormatKeys = 
xFormats->queryKeys(_nNumberFormatId,m_nLocale,sal_True);
+        const sal_Int32* pIter = aFormatKeys.getConstArray();
+        const sal_Int32* pEnd  = pIter + aFormatKeys.getLength();
+        for(;pIter != pEnd;++pIter)
     {
-        sal_Int16 nPos = m_aTimeListBox.InsertEntry( 
getFormatString(_nNumberFormatId) );
-        // m_aTimeListBox.SetEntryFlags(m_nTimeEntryCount, _nNumberFormatId);
-        m_aTimeListBox.SetEntryData(nPos, 
reinterpret_cast<void*>(_nNumberFormatId));
+            const sal_Int16 nPos = 
pListBox->InsertEntry(getFormatStringByKey(*pIter,xFormats,bTime));
+            pListBox->SetEntryData(nPos, reinterpret_cast<void*>(*pIter));
+        }
     }
-
 //------------------------------------------------------------------------
 ODateTimeDialog::~ODateTimeDialog()
 {
@@ -224,7 +199,7 @@
                try
                {
             sal_Int32 nLength = 0;
-            uno::Sequence<beans::PropertyValue> aValues( 5 );
+            uno::Sequence<beans::PropertyValue> aValues( 6 );
             aValues[nLength].Name = PROPERTY_SECTION;
             aValues[nLength++].Value <<= m_xHoldAlive;
 
@@ -235,10 +210,28 @@
             aValues[nLength++].Value <<= m_aDate.IsChecked();
 
             aValues[nLength].Name = PROPERTY_FORMATKEYDATE;
-            aValues[nLength++].Value <<= 
getFormatKey(getFormatIndex(sal_True));
+            aValues[nLength++].Value <<= getFormatKey(sal_True);
 
             aValues[nLength].Name = PROPERTY_FORMATKEYTIME;
-            aValues[nLength++].Value <<= 
getFormatKey(getFormatIndex(sal_False));
+            aValues[nLength++].Value <<= getFormatKey(sal_False);
+
+            sal_Int32 nWidth = 0;
+            if ( m_aDate.IsChecked() )
+            {
+                String sDateFormat = m_aDateListBox.GetEntry( 
m_aDateListBox.GetSelectEntryPos() );
+                nWidth = 
LogicToLogic(PixelToLogic(Size(GetCtrlTextWidth(sDateFormat),0)).Width(),GetMapMode().GetMapUnit(),MAP_100TH_MM);
+            }
+            if ( m_aTime.IsChecked() )
+            {
+                String sDateFormat = m_aTimeListBox.GetEntry( 
m_aTimeListBox.GetSelectEntryPos() );
+                nWidth = 
::std::max<sal_Int32>(LogicToLogic(PixelToLogic(Size(GetCtrlTextWidth(sDateFormat),0)).Width(),GetMapMode().GetMapUnit(),MAP_100TH_MM),nWidth);
+            }
+
+            if ( nWidth > 4000 )
+            {
+                aValues[nLength].Name = PROPERTY_WIDTH;
+                aValues[nLength++].Value <<= nWidth;
+            }
 
             m_pController->executeChecked(SID_DATETIME,aValues);
                }
@@ -250,24 +243,15 @@
        return nRet;
 }
 // 
-----------------------------------------------------------------------------
-::rtl::OUString ODateTimeDialog::getFormatString(::sal_Int16 
_nNumberFormatIndex)
+::rtl::OUString ODateTimeDialog::getFormatStringByKey(::sal_Int32 
_nNumberFormatKey,const uno::Reference< util::XNumberFormats>& _xFormats,bool 
_bTime)
 {
-       DBG_CHKTHIS( rpt_ODateTimeDialog,NULL);
-       uno::Reference< util::XNumberFormatter> xNumberFormatter = 
m_pController->getReportNumberFormatter();
-       uno::Reference< util::XNumberFormats> xFormats = 
xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats();
-       uno::Reference< util::XNumberFormatTypes> 
xNumType(xFormats,uno::UNO_QUERY);
-       sal_Int32 nFormatKey = 
xNumType->getFormatIndex(_nNumberFormatIndex,m_nLocale);
-
-       uno::Reference< beans::XPropertySet> xFormSet = 
xFormats->getByKey(nFormatKey);
+       uno::Reference< beans::XPropertySet> xFormSet = 
_xFormats->getByKey(_nNumberFormatKey);
        OSL_ENSURE(xFormSet.is(),"XPropertySet is null!");
        ::rtl::OUString sFormat;
        
xFormSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormatString")))
 >>= sFormat;
 
-       lang::Locale aLocale;
-       
::comphelper::getNumberFormatProperty(xNumberFormatter,nFormatKey,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale")))
 >>= aLocale;
-
        double nValue = 0;
-       if ( _nNumberFormatIndex >= i18n::NumberFormatIndex::TIME_START )
+       if ( _bTime )
        {
                Time aCurrentTime;
                nValue = 
::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime()));
@@ -275,13 +259,13 @@
        else
        {
                Date aCurrentDate;
-               static ::com::sun::star::util::Date 
STANDARD_DB_DATE(31,12,1899);
+               static ::com::sun::star::util::Date 
STANDARD_DB_DATE(30,12,1899);
                nValue = 
::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE);
        }
 
-       uno::Reference< util::XNumberFormatPreviewer> 
xPreViewer(xNumberFormatter,uno::UNO_QUERY);
+       uno::Reference< util::XNumberFormatPreviewer> 
xPreViewer(m_pController->getReportNumberFormatter(),uno::UNO_QUERY);
        OSL_ENSURE(xPreViewer.is(),"XNumberFormatPreviewer is null!");
-       return 
xPreViewer->convertNumberToPreviewString(sFormat,nValue,aLocale,sal_True);
+       return 
xPreViewer->convertNumberToPreviewString(sFormat,nValue,m_nLocale,sal_True);
 }
 // 
-----------------------------------------------------------------------------
 IMPL_LINK( ODateTimeDialog, CBClickHdl, CheckBox*, _pBox )
@@ -305,30 +289,21 @@
        return 1L;
 }
 // 
-----------------------------------------------------------------------------
-sal_Int16 ODateTimeDialog::getFormatIndex(sal_Bool _bDate)
+sal_Int32 ODateTimeDialog::getFormatKey(sal_Bool _bDate) const
 {
        DBG_CHKTHIS( rpt_ODateTimeDialog,NULL);
-    (void)_bDate;
-       sal_Int16 nFormat;
+       sal_Int32 nFormatKey;
        if ( _bDate )
     {
          //    nFormat = m_aDateF1.IsChecked() ? 
i18n::NumberFormatIndex::DATE_SYSTEM_LONG : (m_aDateF2.IsChecked() ? 
i18n::NumberFormatIndex::DATE_SYS_DMMMYYYY : 
i18n::NumberFormatIndex::DATE_SYSTEM_SHORT);
-         nFormat = 
static_cast<sal_Int16>(reinterpret_cast<sal_IntPtr>(m_aDateListBox.GetEntryData(
 m_aDateListBox.GetSelectEntryPos() )));
+         nFormatKey = 
static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(m_aDateListBox.GetEntryData(
 m_aDateListBox.GetSelectEntryPos() )));
     }
        else
        {
         //     nFormat = m_aTimeF1.IsChecked() ? 
i18n::NumberFormatIndex::TIME_HHMMSS : (m_aTimeF2.IsChecked() ? 
i18n::NumberFormatIndex::TIME_HHMMSSAMPM : i18n::NumberFormatIndex::TIME_HHMM);
-         nFormat = 
static_cast<sal_Int16>(reinterpret_cast<sal_IntPtr>(m_aTimeListBox.GetEntryData(
 m_aTimeListBox.GetSelectEntryPos() )));
+         nFormatKey = 
static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(m_aTimeListBox.GetEntryData(
 m_aTimeListBox.GetSelectEntryPos() )));
     }
-       return nFormat;
-}
-// 
-----------------------------------------------------------------------------
-sal_Int32 ODateTimeDialog::getFormatKey(::sal_Int16 _nNumberFormatIndex)
-{
-       uno::Reference< util::XNumberFormatter> xNumberFormatter = 
m_pController->getReportNumberFormatter();
-       uno::Reference< util::XNumberFormats> xFormats = 
xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats();
-       uno::Reference< util::XNumberFormatTypes> 
xNumType(xFormats,uno::UNO_QUERY);
-       return xNumType->getFormatIndex(_nNumberFormatIndex,m_nLocale);
+       return nFormatKey;
 }
 // 
=============================================================================
 } // rptui

Directory: /dba/reportdesign/source/ui/inc/
===========================================

File [changed]: DateTime.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inc/DateTime.hxx?r1=1.2.28.1&r2=1.2.28.2
Delta lines:  +18 -26
---------------------
--- DateTime.hxx        2007-10-15 12:50:17+0000        1.2.28.1
+++ DateTime.hxx        2007-10-16 11:55:18+0000        1.2.28.2
@@ -6,9 +6,9 @@
  *
  *  $RCSfile: DateTime.hxx,v $
  *
- *  $Revision: 1.2.28.1 $
+ *  $Revision: 1.2.28.2 $
  *
- *  last change: $Author: lla $ $Date: 2007/10/15 12:50:17 $
+ *  last change: $Author: oj $ $Date: 2007/10/16 11:55:18 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -53,6 +53,7 @@
 #ifndef _COM_SUN_STAR_REPORT_XREPORTDEFINITION_HPP_
 #include <com/sun/star/report/XReportDefinition.hpp>
 #endif
+#include <com/sun/star/util/XNumberFormats.hpp>
 #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
 #include <com/sun/star/lang/Locale.hpp>
 #endif
@@ -73,16 +74,10 @@
        CheckBox                                                                
m_aDate;
  FixedText m_aFTDateFormat;
     ListBox                                 m_aDateListBox;
-       // RadioButton                                                          
m_aDateF1;
-       // RadioButton                                                          
m_aDateF2;
-       // RadioButton                                                          
m_aDateF3;
        FixedLine                                                               
m_aFL0;
        CheckBox                                                                
m_aTime;
     FixedText m_aFTTimeFormat;
     ListBox                                 m_aTimeListBox;
-       // RadioButton                                                          
m_aTimeF1;
-       // RadioButton                                                          
m_aTimeF2;
-       // RadioButton                                                          
m_aTimeF3;
        FixedLine                                                               
m_aFL1;
        OKButton                                                                
m_aPB_OK;
        CancelButton                                                    
m_aPB_CANCEL;
@@ -97,29 +92,26 @@
                                                                                
        m_xHoldAlive;
        ::com::sun::star::lang::Locale                  m_nLocale;
 
-       /** returns the format string.
-       */
-       ::rtl::OUString getFormatString(::sal_Int16 _nNumberFormatIndex);
-
-       /** returns the format
-               @param  _bDate  <TRUE/> when the date format should be returned 
otherwise the time format will be returned.
+    /** returns the frmat string
+    *
+    * \param _nNumberFormatKey the number format key
+    * \param _xFormats 
+    * \param _bTime 
+    * \return 
        */
-       sal_Int16 getFormatIndex(sal_Bool _bDate);
+    ::rtl::OUString getFormatStringByKey(::sal_Int32 _nNumberFormatKey,const 
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats>& 
_xFormats,bool _bTime);
 
        /** returns the number format key
                @param  _nNumberFormatIndex the number format index @see 
com::sun::star::i18n::NumberFormatIndex
        */
-       sal_Int32 getFormatKey(::sal_Int16 _nNumberFormatIndex);
+       sal_Int32 getFormatKey(sal_Bool _bDate) const;
 
        DECL_LINK( CBClickHdl, CheckBox* );
     ODateTimeDialog(const ODateTimeDialog&);
     void operator =(const ODateTimeDialog&);
 
     // fill methods
-    sal_Int16 m_nDateEntryCount;
-    void InsertDateEntry(sal_Int16 _nNumberFormatId);
-    sal_Int16 m_nTimeEntryCount;
-    void InsertTimeEntry(sal_Int16 _nNumberFormatId);
+    void InsertEntry(sal_Int16 _nNumberFormatId);
 public:
        ODateTimeDialog( Window* pParent
                                                ,const 
::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& 
_xHoldAlive

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.4.20.4&r2=1.4.20.5
Delta lines:  +6 -3
-------------------
--- ReportController.cxx        2007-10-16 09:11:55+0000        1.4.20.4
+++ ReportController.cxx        2007-10-16 11:55:19+0000        1.4.20.5
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: ReportController.cxx,v $
  *
- *  $Revision: 1.4.20.4 $
+ *  $Revision: 1.4.20.5 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/16 09:11:55 $
+ *  last change: $Author: oj $ $Date: 2007/10/16 11:55:19 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -3336,7 +3336,10 @@
         }
     }
 
-    const sal_Int32 nShapeWidth = xShapeProp->getWidth();
+    const sal_Int32 nShapeWidth = 
aMap.getUnpackedValueOrDefault(PROPERTY_WIDTH,xShapeProp->getWidth());
+    if ( nShapeWidth != xShapeProp->getWidth() )
+        xShapeProp->setWidth( nShapeWidth );
+
     const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
     if ( bChangedPos )
         aPos.X = nPaperWidth - nShapeWidth;




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to