[Libreoffice-commits] core.git: Branch 'feature/cmis' - include/sfx2 sfx2/source

Cao Cuong Ngo cao.cuong.ngo at gmail.com
Mon Jun 10 12:15:34 PDT 2013


 include/sfx2/dinfdlg.hxx       |    7 +--
 sfx2/source/dialog/dinfdlg.cxx |   79 +++++++++++++++--------------------------
 sfx2/source/dialog/dinfdlg.hrc |    6 +++
 sfx2/source/dialog/dinfdlg.src |   17 ++++++++
 sfx2/source/inc/sfxlocal.hrc   |    1 
 5 files changed, 56 insertions(+), 54 deletions(-)

New commits:
commit fca06947a4997482c3f061f368237dc0d91794ec
Author: Cao Cuong Ngo <cao.cuong.ngo at gmail.com>
Date:   Fri Jun 7 18:40:11 2013 +0200

    CMIS properties dialog
    
    Fix properties type editing
    
    Change-Id: Ic36f0351ec738e7444508f8326c23e89150c9603

diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index 72d1ed1..397a011 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -588,14 +588,12 @@ public:
 
 struct CmisPropertyLine
 {
-    ComboBox                      m_aNameBox;
+    SelectableFixedText           m_aNameBox;
     CmisPropertiesTypeBox         m_aTypeBox;
     CmisPropertiesEdit            m_aValueEdit;
     CmisPropertiesDateField       m_aDateField;
     CmisPropertiesTimeField       m_aTimeField;
-    CmisPropertiesEditButton      m_aEditButton;
     CmisPropertiesYesNoButton     m_aYesNoButton;
-
     Point                           m_aDatePos;
     Point                           m_aTimePos;
     Size                            m_aDateTimeSize;
@@ -611,12 +609,11 @@ struct CmisPropertyLine
 class CmisPropertiesWindow : public Window
 {
 private:
-    ComboBox                            m_aNameBox;
+    SelectableFixedText                 m_aNameBox;
     ListBox                             m_aTypeBox;
     Edit                                m_aValueEdit;
     DateField                           m_aDateField;
     TimeField                           m_aTimeField;
-    PushButton                          m_aEditButton;
     CmisPropertiesYesNoButton           m_aYesNoButton;
 
     sal_Int32                           m_nLineHeight;
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 7750f28..abd66d6 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -2173,12 +2173,11 @@ void CmisPropertiesYesNoButton::Resize()
 
 // struct CmisPropertyLine ---------------------------------------------
 CmisPropertyLine::CmisPropertyLine( Window* pParent ) :
-    m_aNameBox      ( pParent, SfxResId( SFX_CB_PROPERTY_NAME )  ),
-    m_aTypeBox      ( pParent, SfxResId( SFX_LB_PROPERTY_TYPE ), this ),
+    m_aNameBox      ( pParent ),
+    m_aTypeBox      ( pParent, SfxResId( SFX_LB_CMIS_PROPERTY_TYPE ), this ),
     m_aValueEdit    ( pParent, SfxResId( SFX_ED_PROPERTY_VALUE ), this ),
     m_aDateField    ( pParent, SfxResId( SFX_FLD_DATE), this),
     m_aTimeField    ( pParent, SfxResId( SFX_FLD_TIME), this),
-    m_aEditButton(    pParent, SfxResId( SFX_PB_EDIT ), this),
     m_aYesNoButton  ( pParent, SfxResId( SFX_WIN_PROPERTY_YESNO ) ),
     m_bTypeLostFocus( false )
 
@@ -2194,12 +2193,11 @@ CmisPropertiesWindow::CmisPropertiesWindow(Window* pParent,
     const OUString &rHeaderAccType,
     const OUString &rHeaderAccValue) :
     Window(pParent),
-    m_aNameBox      ( this, SfxResId( SFX_CB_PROPERTY_NAME ) ),
-    m_aTypeBox      ( this, SfxResId( SFX_LB_PROPERTY_TYPE ) ),
+    m_aNameBox      ( this ),
+    m_aTypeBox      ( this, SfxResId( SFX_LB_CMIS_PROPERTY_TYPE ) ),
     m_aValueEdit    ( this, SfxResId( SFX_ED_PROPERTY_VALUE ) ),
     m_aDateField    ( this, SfxResId( SFX_FLD_DATE) ),
     m_aTimeField    ( this, SfxResId( SFX_FLD_TIME) ),
-    m_aEditButton(    this, SfxResId( SFX_PB_EDIT )),
     m_aYesNoButton  ( this, SfxResId( SFX_WIN_PROPERTY_YESNO ) ),
     m_nScrollPos (0),
     m_aNumberFormatter( ::comphelper::getProcessComponentContext(),
@@ -2222,14 +2220,12 @@ IMPL_LINK( CmisPropertiesWindow, TypeHdl, CmisPropertiesTypeBox*, pBox )
 {
     sal_Int64 nType = sal_Int64( (long)pBox->GetEntryData( pBox->GetSelectEntryPos() ) );
     CmisPropertyLine* pLine = pBox->GetLine();
-    pLine->m_aValueEdit.Show( (CUSTOM_TYPE_TEXT == nType) || (CUSTOM_TYPE_NUMBER  == nType) );
-    pLine->m_aDateField.Show( (CUSTOM_TYPE_DATE == nType) || (CUSTOM_TYPE_DATETIME  == nType) );
-    pLine->m_aTimeField.Show( CUSTOM_TYPE_DATETIME  == nType );
-    pLine->m_aYesNoButton.Show( CUSTOM_TYPE_BOOLEAN == nType );
+    pLine->m_aValueEdit.Show(( CMIS_TYPE_STRING == nType ) || ( CMIS_TYPE_NUMBER == nType ) );
+    pLine->m_aDateField.Show( CMIS_TYPE_DATETIME  == nType );
+    pLine->m_aTimeField.Show( CMIS_TYPE_DATETIME  == nType );
+    pLine->m_aYesNoButton.Show( CMIS_TYPE_BOOLEAN == nType );
 
-    if ( nType == CUSTOM_TYPE_DATE )
-        pLine->m_aDateField.SetPosSizePixel(pLine->m_aValueEdit.GetPosPixel(), pLine->m_aValueEdit.GetSizePixel());
-    else if ( nType == CUSTOM_TYPE_DATETIME)
+    if ( nType == CMIS_TYPE_DATETIME )
     {
         pLine->m_aDateField.SetPosSizePixel( pLine->m_aDatePos, pLine->m_aDateTimeSize );
         pLine->m_aTimeField.SetPosSizePixel(pLine->m_aTimePos, pLine->m_aDateTimeSize );
@@ -2276,10 +2272,10 @@ bool CmisPropertiesWindow::IsLineValid( CmisPropertyLine* pLine ) const
         return true;
 
     sal_uInt32 nIndex = 0xFFFFFFFF;
-    if ( CUSTOM_TYPE_NUMBER == nType )
+    if ( CMIS_TYPE_NUMBER == nType )
         nIndex = const_cast< SvNumberFormatter& >(
             m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM );
-    else if ( CUSTOM_TYPE_DATE == nType )
+    else if ( CMIS_TYPE_DATETIME == nType )
         nIndex = const_cast< SvNumberFormatter& >(
             m_aNumberFormatter).GetFormatIndex( NF_DATE_SYS_DDMMYYYY );
 
@@ -2305,7 +2301,7 @@ void CmisPropertiesWindow::ValidateLine( CmisPropertyLine* pLine, bool bIsFromTy
             pLine->m_bTypeLostFocus = true;
         Window* pParent = GetParent()->GetParent();
         if ( QueryBox( pParent, SfxResId( SFX_QB_WRONG_TYPE ) ).Execute() == RET_OK )
-            pLine->m_aTypeBox.SelectEntryPos( m_aTypeBox.GetEntryPos( (void*)CUSTOM_TYPE_TEXT ) );
+            pLine->m_aTypeBox.SelectEntryPos( m_aTypeBox.GetEntryPos( (void*)CMIS_TYPE_STRING ) );
         else
             pLine->m_aValueEdit.GrabFocus();
     }
@@ -2321,11 +2317,8 @@ void CmisPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBar*
     m_aValueEdit.Hide();
     m_aDateField.Hide();
     m_aTimeField.Hide();
-    m_aEditButton.Hide();
     m_aYesNoButton.Hide();
 
-    m_nLineHeight = m_aTypeBox.GetSizePixel().Height();
-
     const long nOffset = 4;
     const long nScrollBarWidth = pScrollBar->GetSizePixel().Width();
     const long nButtonWidth = nScrollBarWidth + nOffset;
@@ -2368,6 +2361,8 @@ void CmisPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBar*
         pCurrent++;
     }
 
+    m_nLineHeight = m_aValueEdit.GetSizePixel().Height();
+
 }
 
 sal_uInt16 CmisPropertiesWindow::GetVisibleLineCount() const
@@ -2384,7 +2379,7 @@ void CmisPropertiesWindow::updateLineWidth()
 {
     Window* pWindows[] = {  &m_aNameBox, &m_aTypeBox, &m_aValueEdit,
                             &m_aDateField, &m_aTimeField,
-                            &m_aEditButton, &m_aYesNoButton, NULL };
+                            &m_aYesNoButton, NULL };
 
     for (std::vector< CmisPropertyLine* >::iterator aI =
         m_aCmisPropertiesLines.begin(), aEnd = m_aCmisPropertiesLines.end();
@@ -2394,7 +2389,7 @@ void CmisPropertiesWindow::updateLineWidth()
 
         Window* pNewWindows[] =
             {   &pNewLine->m_aNameBox, &pNewLine->m_aTypeBox, &pNewLine->m_aValueEdit,
-                &pNewLine->m_aDateField, &pNewLine->m_aTimeField, &pNewLine->m_aEditButton,
+                &pNewLine->m_aDateField, &pNewLine->m_aTimeField,
                 &pNewLine->m_aYesNoButton, NULL };
 
         Window** pCurrent = pWindows;
@@ -2423,16 +2418,16 @@ void CmisPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
     pNewLine->m_aTypeBox.SetAccessibleName(m_aTypeBox.GetAccessibleName());
     pNewLine->m_aValueEdit.SetAccessibleName(m_aValueEdit.GetAccessibleName());
 
-    m_nLineHeight = m_aTypeBox.GetSizePixel().Height();
+    m_nLineHeight = m_aValueEdit.GetSizePixel().Height() ;
 
     long nPos = GetVisibleLineCount() * GetLineHeight();
     m_aCmisPropertiesLines.push_back( pNewLine );
     Window* pWindows[] = {  &m_aNameBox, &m_aTypeBox, &m_aValueEdit,
-                            &m_aDateField, &m_aTimeField, &m_aEditButton,
+                            &m_aDateField, &m_aTimeField,
                             &m_aYesNoButton, NULL };
     Window* pNewWindows[] =
         {   &pNewLine->m_aNameBox, &pNewLine->m_aTypeBox, &pNewLine->m_aValueEdit,
-            &pNewLine->m_aDateField, &pNewLine->m_aTimeField, &pNewLine->m_aEditButton,
+            &pNewLine->m_aDateField, &pNewLine->m_aTimeField,
             &pNewLine->m_aYesNoButton, NULL };
     Window** pCurrent = pWindows;
     Window** pNewCurrent = pNewWindows;
@@ -2456,11 +2451,10 @@ void CmisPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
     bool bTmpValue = false;
     OUString sTmpValue;
     util::DateTime aTmpDateTime;
-    util::Date aTmpDate;
     SvtSysLocale aSysLocale;
     const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData();
     pNewLine->m_aNameBox.SetText( sName );
-    sal_IntPtr nType = CUSTOM_TYPE_UNKNOWN;
+    sal_IntPtr nType = CMIS_TYPE_ANY;
     String sValue;
 
     if ( rAny >>= nTmpValue )
@@ -2468,35 +2462,29 @@ void CmisPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
         sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM );
         m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue );
         pNewLine->m_aValueEdit.SetText( sValue );
-        nType = CUSTOM_TYPE_NUMBER;
+        nType = CMIS_TYPE_NUMBER;
     }
     else if ( rAny >>= bTmpValue )
     {
         sValue = ( bTmpValue ? rLocaleWrapper.getTrueWord() : rLocaleWrapper.getFalseWord() );
-        nType = CUSTOM_TYPE_BOOLEAN;
+        nType = CMIS_TYPE_BOOLEAN;
     }
     else if ( rAny >>= sTmpValue )
     {
         pNewLine->m_aValueEdit.SetText( sTmpValue );
-        nType = CUSTOM_TYPE_TEXT;
-    }
-    else if ( rAny >>= aTmpDate )
-    {
-        nType = CUSTOM_TYPE_DATE;
-        pNewLine->m_aDateField.SetDate( Date( aTmpDate.Day, aTmpDate.Month, aTmpDate.Year ) );
-
+        nType = CMIS_TYPE_STRING;
     }
     else if ( rAny >>= aTmpDateTime )
     {
         pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) );
         pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.NanoSeconds ) );
 
-        nType = CUSTOM_TYPE_DATETIME;
+        nType = CMIS_TYPE_DATETIME;
     }
 
-    if ( nType != CUSTOM_TYPE_UNKNOWN )
+    if ( nType != CMIS_TYPE_ANY )
     {
-        if ( CUSTOM_TYPE_BOOLEAN == nType )
+        if ( CMIS_TYPE_BOOLEAN == nType )
         {
             if ( bTmpValue )
                 pNewLine->m_aYesNoButton.CheckYes();
@@ -2551,7 +2539,7 @@ void CmisPropertiesWindow::DoScroll( sal_Int32 nNewPos )
         CmisPropertyLine* pLine = *pIter;
 
         Window* pWindows[] = {  &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit, &pLine->m_aDateField,
-                                &pLine->m_aTimeField, &pLine->m_aEditButton, &pLine->m_aYesNoButton, NULL };
+                                &pLine->m_aTimeField, &pLine->m_aYesNoButton, NULL };
         Window** pCurrent = pWindows;
         while ( *pCurrent )
         {
@@ -2579,7 +2567,7 @@ Sequence< beans::PropertyValue > CmisPropertiesWindow::GetCmisProperties() const
             aPropertiesSeq[i].Name = sPropertyName;
             sal_Int64 nType = sal_Int64(
                 (long)pLine->m_aTypeBox.GetEntryData( pLine->m_aTypeBox.GetSelectEntryPos() ) );
-            if ( CUSTOM_TYPE_NUMBER == nType )
+            if ( CMIS_TYPE_NUMBER == nType )
             {
                 double nValue = 0;
                 sal_uInt32 nIndex = const_cast< SvNumberFormatter& >(
@@ -2589,12 +2577,12 @@ Sequence< beans::PropertyValue > CmisPropertiesWindow::GetCmisProperties() const
                 if ( bIsNum )
                     aPropertiesSeq[i].Value <<= makeAny( nValue );
             }
-            else if ( CUSTOM_TYPE_BOOLEAN == nType )
+            else if ( CMIS_TYPE_BOOLEAN == nType )
             {
                 bool bValue = pLine->m_aYesNoButton.IsYesChecked();
                 aPropertiesSeq[i].Value <<= makeAny( bValue );
             }
-            else if ( CUSTOM_TYPE_DATETIME == nType )
+            else if ( CMIS_TYPE_DATETIME == nType )
             {
                 Date aTmpDate = pLine->m_aDateField.GetDate();
                 Time aTmpTime = pLine->m_aTimeField.GetTime();
@@ -2602,13 +2590,6 @@ Sequence< beans::PropertyValue > CmisPropertiesWindow::GetCmisProperties() const
                         aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear() );
                 aPropertiesSeq[i].Value <<= aDateTime;
             }
-            else if ( CUSTOM_TYPE_DATE == nType )
-            {
-                Date aTmpDate = pLine->m_aDateField.GetDate();
-                util::Date aDate(aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear());
-                aPropertiesSeq[i].Value <<= aDate;
-
-            }
             else
             {
                 OUString sValue( pLine->m_aValueEdit.GetText() );
diff --git a/sfx2/source/dialog/dinfdlg.hrc b/sfx2/source/dialog/dinfdlg.hrc
index 4dc96b1..f39c17d 100644
--- a/sfx2/source/dialog/dinfdlg.hrc
+++ b/sfx2/source/dialog/dinfdlg.hrc
@@ -31,6 +31,12 @@
 #define CUSTOM_TYPE_DURATION    5
 #define CUSTOM_TYPE_DATETIME    6
 
+#define CMIS_TYPE_ANY         0
+#define CMIS_TYPE_STRING      1
+#define CMIS_TYPE_NUMBER      2
+#define CMIS_TYPE_DATETIME    3
+#define CMIS_TYPE_BOOLEAN     4
+
 // defines ---------------------------------------------------------------
 
 #define RB_PROPERTY_YES     100
diff --git a/sfx2/source/dialog/dinfdlg.src b/sfx2/source/dialog/dinfdlg.src
index 9b6c6bf..f649cd0 100644
--- a/sfx2/source/dialog/dinfdlg.src
+++ b/sfx2/source/dialog/dinfdlg.src
@@ -90,6 +90,23 @@ ListBox SFX_LB_PROPERTY_TYPE
         < "Yes or no"   ; CUSTOM_TYPE_BOOLEAN ; > ;
     };
 };
+ListBox SFX_LB_CMIS_PROPERTY_TYPE
+{
+    Pos = MAP_APPFONT ( 63 , 2 ) ;
+    Size = MAP_APPFONT ( 60 , 80 ) ;
+    DropDown = TRUE;
+    Border = TRUE;
+    CurPos = 0;
+    StringList [ en-US ] =
+    {
+        < "Text"        ; CMIS_TYPE_STRING ; > ;
+        < "DateTime"    ; CMIS_TYPE_DATETIME ; > ;
+        < "Integer"     ; CMIS_TYPE_NUMBER ; > ;
+        < "Decimal"     ; CMIS_TYPE_NUMBER ; > ;
+        < "Boolean"     ; CMIS_TYPE_BOOLEAN ; > ;
+    };
+};
+
 Edit SFX_ED_PROPERTY_VALUE
 {
     Border = TRUE ;
diff --git a/sfx2/source/inc/sfxlocal.hrc b/sfx2/source/inc/sfxlocal.hrc
index 836ad2b..e78f645 100644
--- a/sfx2/source/inc/sfxlocal.hrc
+++ b/sfx2/source/inc/sfxlocal.hrc
@@ -49,6 +49,7 @@
 #define SFX_FLD_TIME                        (RID_SFX_SFXLOCAL_START +  11)
 #define SFX_FLD_DURATION                    (RID_SFX_SFXLOCAL_START +  12)
 #define SFX_ST_DURATION_FORMAT              (RID_SFX_SFXLOCAL_START +  13)
+#define SFX_LB_CMIS_PROPERTY_TYPE           (RID_SFX_SFXLOCAL_START +  14)
 
 // Images ----------------------------------------------------------------
 


More information about the Libreoffice-commits mailing list