include/sfx2/dinfdlg.hxx | 6 - sfx2/source/dialog/dinfdlg.cxx | 179 ++++++++++++++++++++++++----------- ucb/source/ucp/cmis/cmis_content.cxx | 136 ++++++++------------------ 3 files changed, 170 insertions(+), 151 deletions(-)
New commits: commit 25363f597a1452e4d1497758c3c80101b5aa8e3f Author: Cao Cuong Ngo <cao.cuong....@gmail.com> Date: Fri Aug 23 16:36:11 2013 +0200 CMIS properties: fix update issue Change-Id: Ia04c588c7491cf9a4a5430b364b52ac89adf2f90 diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx index 08d3808..e9fd2a2 100644 --- a/include/sfx2/dinfdlg.hxx +++ b/include/sfx2/dinfdlg.hxx @@ -531,7 +531,6 @@ struct CmisPropertyLine : public VclBuilderContainer CmisPropertyLine( Window* pParent ); }; -typedef boost::ptr_vector<CmisPropertyLine> CmisPropertiesLines; // class CmisPropertiesWindow ------------------------------------------ class CmisPropertiesWindow @@ -539,11 +538,8 @@ class CmisPropertiesWindow private: VclBox* m_pBox; sal_Int32 m_nItemHeight; - SvtSysLocale m_aSysLocale; SvNumberFormatter m_aNumberFormatter; - Timer m_aEditLoseFocusTimer; - Timer m_aBoxLoseFocusTimer; - CmisPropertiesLines m_aCmisPropertiesLines; + std::vector< CmisPropertyLine* > m_aCmisPropertiesLines; public: CmisPropertiesWindow(SfxTabPage* pParent); ~CmisPropertiesWindow(); diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 682278c..1c1b3d0 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -2136,13 +2136,8 @@ CmisPropertiesWindow::CmisPropertiesWindow(SfxTabPage* pParent): { pParent->get(m_pBox, "CmisWindow"); - if ( !m_aCmisPropertiesLines.empty()) - m_nItemHeight = m_aCmisPropertiesLines.front().getItemHeight(); - else - { - CmisPropertyLine aTemp( m_pBox ); - m_nItemHeight = aTemp.getItemHeight(); - } + CmisPropertyLine aTemp( m_pBox ); + m_nItemHeight = aTemp.getItemHeight(); }; CmisPropertiesWindow::~CmisPropertiesWindow() @@ -2152,6 +2147,13 @@ CmisPropertiesWindow::~CmisPropertiesWindow() void CmisPropertiesWindow::ClearAllLines() { + std::vector< CmisPropertyLine* >::iterator pIter; + for ( pIter = m_aCmisPropertiesLines.begin(); + pIter != m_aCmisPropertiesLines.end(); ++pIter ) + { + CmisPropertyLine* pLine = *pIter; + delete pLine; + } m_aCmisPropertiesLines.clear(); } @@ -2243,24 +2245,24 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con { Sequence< document::CmisProperty > aPropertiesSeq( m_aCmisPropertiesLines.size() ); sal_Int32 i = 0; - boost::ptr_vector< CmisPropertyLine >::const_iterator pIter; + std::vector< CmisPropertyLine* >::const_iterator pIter; for ( pIter = m_aCmisPropertiesLines.begin(); pIter != m_aCmisPropertiesLines.end(); ++pIter, ++i ) { - CmisPropertyLine pLine = *pIter; + CmisPropertyLine* pLine = *pIter; - aPropertiesSeq[i].Id = pLine.m_sId; - aPropertiesSeq[i].Type = pLine.m_sType; - aPropertiesSeq[i].Updatable = pLine.m_bUpdatable; - aPropertiesSeq[i].Required = pLine.m_bRequired; - aPropertiesSeq[i].OpenChoice = pLine.m_bOpenChoice; - aPropertiesSeq[i].MultiValued = pLine.m_bMultiValued; + aPropertiesSeq[i].Id = pLine->m_sId; + aPropertiesSeq[i].Type = pLine->m_sType; + aPropertiesSeq[i].Updatable = pLine->m_bUpdatable; + aPropertiesSeq[i].Required = pLine->m_bRequired; + aPropertiesSeq[i].OpenChoice = pLine->m_bOpenChoice; + aPropertiesSeq[i].MultiValued = pLine->m_bMultiValued; - String sPropertyName = pLine.m_aName->GetText(); + String sPropertyName = pLine->m_aName->GetText(); if ( sPropertyName.Len() > 0 ) { aPropertiesSeq[i].Name = sPropertyName; - OUString sType = pLine.m_aType->GetText( ); + OUString sType = pLine->m_aType->GetText( ); if ( CMIS_TYPE_INTEGER == sType || CMIS_TYPE_DECIMAL == sType ) { @@ -2268,27 +2270,35 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con sal_uInt32 nIndex = const_cast< SvNumberFormatter& >( m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM ); sal_Bool bIsNum = const_cast< SvNumberFormatter& >( m_aNumberFormatter ). - IsNumberFormat( pLine.m_aValueEdit->GetText(), nIndex, nValue ); + IsNumberFormat( pLine->m_aValueEdit->GetText(), nIndex, nValue ); + Sequence< double > seqValue( 1 ); + seqValue[0] = nValue; if ( bIsNum ) - aPropertiesSeq[i].Value <<= makeAny( nValue ); + aPropertiesSeq[i].Value <<= makeAny( seqValue ); } else if ( CMIS_TYPE_BOOL == sType ) { - bool bValue = pLine.m_aYesButton->IsChecked(); - aPropertiesSeq[i].Value <<= makeAny( bValue ); + bool bValue = pLine->m_aYesButton->IsChecked(); + Sequence< bool > seqValue( 1 ); + seqValue[0] = bValue; + aPropertiesSeq[i].Value <<= makeAny( seqValue ); } else if ( CMIS_TYPE_DATETIME == sType ) { - Date aTmpDate = pLine.m_aDateField->GetDate(); - Time aTmpTime = pLine.m_aTimeField->GetTime(); + Date aTmpDate = pLine->m_aDateField->GetDate(); + Time aTmpTime = pLine->m_aTimeField->GetTime(); util::DateTime aDateTime(aTmpTime.GetNanoSec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(), aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear() ); - aPropertiesSeq[i].Value <<= aDateTime; + Sequence< util::DateTime > seqValue( 1 ); + seqValue[0] = aDateTime; + aPropertiesSeq[i].Value <<= seqValue; } else { - OUString sValue( pLine.m_aValueEdit->GetText() ); - aPropertiesSeq[i].Value <<= makeAny( sValue ); + OUString sValue( pLine->m_aValueEdit->GetText() ); + Sequence< OUString > seqValue( 1 ); + seqValue[0] = sValue; + aPropertiesSeq[i].Value <<= makeAny( seqValue ); } } } @@ -2392,26 +2402,83 @@ sal_Bool SfxCmisPropertiesPage::FillItemSet( SfxItemSet& rSet ) Sequence< document::CmisProperty > aOldProps = pInfo->GetCmisProperties( ); Sequence< document::CmisProperty > aNewProps = m_pPropertiesCtrl.GetCmisProperties(); - for ( sal_Int32 i = 0; i< aNewProps.getLength( ); i++ ) + std::vector< document::CmisProperty > changedProps; + for ( sal_Int32 i = 0; i< aNewProps.getLength( ); ++i ) + if ( aOldProps[i].Updatable ) { - OUString oldValue; - aOldProps[i].Value >>= oldValue; - OUString newValue; - aNewProps[i].Value >>= newValue; - if ( !aNewProps[i].Id.isEmpty() && aNewProps[i].Updatable && oldValue != newValue ) - modifiedNum++; + if ( aOldProps[i].Type == CMIS_TYPE_STRING ) + { + Sequence< OUString > oldValue; + aOldProps[i].Value >>= oldValue; + Sequence< OUString > newValue; + aNewProps[i].Value >>= newValue; + if ( !aNewProps[i].Id.isEmpty() && aNewProps[i].Updatable && oldValue != newValue ) + { + modifiedNum++; + changedProps.push_back( aNewProps[i] ); + } + } + else if ( aOldProps[i].Type == CMIS_TYPE_BOOL ) + { + Sequence< bool > oldValue; + aOldProps[i].Value >>= oldValue; + Sequence< bool > newValue; + aNewProps[i].Value >>= newValue; + if ( !aNewProps[i].Id.isEmpty() && aNewProps[i].Updatable && oldValue != newValue ) + { + modifiedNum++; + changedProps.push_back( aNewProps[i] ); + } + } + else if ( aOldProps[i].Type == CMIS_TYPE_DATETIME ) + { + Sequence< util::DateTime > oldValue; + aOldProps[i].Value >>= oldValue; + // We only edit hours and minutes + // don't compare NanoSeconds and Seconds + for ( sal_Int32 ii = 0; ii < oldValue.getLength( ); ++ii ) + { + oldValue[ii].NanoSeconds = 0; + oldValue[ii].Seconds = 0; + } + Sequence< util::DateTime > newValue; + aNewProps[i].Value >>= newValue; + if ( !aNewProps[i].Id.isEmpty() && aNewProps[i].Updatable && oldValue != newValue ) + { + modifiedNum++; + changedProps.push_back( aNewProps[i] ); + } + } + else if ( aOldProps[i].Type == CMIS_TYPE_INTEGER ) + { + Sequence< sal_Int64 > oldValue; + aOldProps[i].Value >>= oldValue; + Sequence< sal_Int64 > newValue; + aNewProps[i].Value >>= newValue; + if ( !aNewProps[i].Id.isEmpty() && aNewProps[i].Updatable && oldValue != newValue ) + { + modifiedNum++; + changedProps.push_back( aNewProps[i] ); + } + } + else if ( aOldProps[i].Type == CMIS_TYPE_DECIMAL ) + { + Sequence< double > oldValue; + aOldProps[i].Value >>= oldValue; + Sequence< double > newValue; + aNewProps[i].Value >>= newValue; + if ( !aNewProps[i].Id.isEmpty() && aNewProps[i].Updatable && oldValue != newValue ) + { + modifiedNum++; + changedProps.push_back( aNewProps[i] ); + } + } } Sequence< document::CmisProperty> aModifiedProps( modifiedNum ); sal_Int32 nCount = 0; - for ( sal_Int32 i = 0; i< aNewProps.getLength( ); i++ ) - { - OUString oldValue; - aOldProps[i].Value >>= oldValue; - OUString newValue; - aNewProps[i].Value >>= newValue; - if ( !aNewProps[i].Id.isEmpty() && aNewProps[i].Updatable && oldValue != newValue ) - aModifiedProps[ nCount++ ] = aNewProps[i]; - } + for( std::vector< document::CmisProperty>::const_iterator pIter = changedProps.begin(); + pIter != changedProps.end( ); ++pIter ) + aModifiedProps[ nCount++ ] = *pIter; pInfo->SetCmisProperties( aModifiedProps ); } commit 90565319e35b11366f97c09d382ec7e7ce8b2580 Author: Cao Cuong Ngo <cao.cuong....@gmail.com> Date: Fri Aug 23 15:43:03 2013 +0200 CMIS properties dialog: get multiple values Change-Id: Ife7562d52cc3070c8d409f2da68d4e2aa5faea69 diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index f73024d..682278c 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -2182,43 +2182,42 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, pNewLine->m_aName->SetText( sName ); - SvtSysLocale aSysLocale; - const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData(); OUString sValue; if ( sType == CMIS_TYPE_INTEGER ) { - sal_Int64 nTmpValue = 0; + Sequence< sal_Int64 > nTmpValue; rAny >>= nTmpValue; sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); - m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue ); + m_aNumberFormatter.GetInputLineString( nTmpValue[0], nIndex, sValue ); } else if ( sType == CMIS_TYPE_DECIMAL ) { - double dTmpValue = 0.0; + Sequence< double > dTmpValue; rAny >>= dTmpValue; sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); - m_aNumberFormatter.GetInputLineString( dTmpValue, nIndex, sValue ); + m_aNumberFormatter.GetInputLineString( dTmpValue[0], nIndex, sValue ); } else if ( sType == CMIS_TYPE_BOOL ) { - bool bTmpValue = false; + Sequence< bool > bTmpValue; rAny >>= bTmpValue; - sValue = ( bTmpValue ? rLocaleWrapper.getTrueWord() : rLocaleWrapper.getFalseWord() ); - if ( bTmpValue ) + if ( bTmpValue[0] ) pNewLine->m_aYesButton->Check(); else pNewLine->m_aNoButton->Check(); } else if ( sType == CMIS_TYPE_STRING ) { - rAny >>= sValue; + Sequence< OUString > seqValue; + rAny >>= seqValue; + sValue = seqValue[0]; } else if ( sType == CMIS_TYPE_DATETIME ) { - util::DateTime aTmpDateTime; + Sequence< util::DateTime > aTmpDateTime; 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 ) ); + pNewLine->m_aDateField->SetDate( Date( aTmpDateTime[0].Day, aTmpDateTime[0].Month, aTmpDateTime[0].Year ) ); + pNewLine->m_aTimeField->SetTime( Time( aTmpDateTime[0].Hours, aTmpDateTime[0].Minutes, aTmpDateTime[0].Seconds, aTmpDateTime[0].NanoSeconds ) ); } diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 6ac4106..5b8451c 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -85,114 +85,78 @@ namespace uno::Any lcl_cmisPropertyToUno( libcmis::PropertyPtr pProperty ) { uno::Any aValue; - bool bMultiValued = pProperty->getPropertyType( )->isMultiValued( ); switch ( pProperty->getPropertyType( )->getType( ) ) { default: case libcmis::PropertyType::String: { vector< string > aCmisStrings = pProperty->getStrings( ); - if ( bMultiValued ) + uno::Sequence< OUString > aStrings( aCmisStrings.size( ) ); + OUString* aStringsArr = aStrings.getArray( ); + sal_Int32 i = 0; + for ( vector< string >::iterator it = aCmisStrings.begin( ); + it != aCmisStrings.end( ); ++it, ++i ) { - uno::Sequence< OUString > aStrings( aCmisStrings.size( ) ); - OUString* aStringsArr = aStrings.getArray( ); - sal_Int32 i = 0; - for ( vector< string >::iterator it = aCmisStrings.begin( ); - it != aCmisStrings.end( ); ++it, ++i ) - { - string str = *it; - aStringsArr[i] = STD_TO_OUSTR( str ); - } - aValue <<= aStrings; - } - else if ( !aCmisStrings.empty( ) ) - { - aValue <<= STD_TO_OUSTR( aCmisStrings.front( ) ); + string str = *it; + aStringsArr[i] = STD_TO_OUSTR( str ); } + aValue <<= aStrings; } break; case libcmis::PropertyType::Integer: { vector< long > aCmisLongs = pProperty->getLongs( ); - if ( bMultiValued ) + uno::Sequence< sal_Int64 > aLongs( aCmisLongs.size( ) ); + sal_Int64* aLongsArr = aLongs.getArray( ); + sal_Int32 i = 0; + for ( vector< long >::iterator it = aCmisLongs.begin( ); + it != aCmisLongs.end( ); ++it, ++i ) { - uno::Sequence< sal_Int64 > aLongs( aCmisLongs.size( ) ); - sal_Int64* aLongsArr = aLongs.getArray( ); - sal_Int32 i = 0; - for ( vector< long >::iterator it = aCmisLongs.begin( ); - it != aCmisLongs.end( ); ++it, ++i ) - { - aLongsArr[i] = *it; - } - aValue <<= aLongs; - } - else if ( !aCmisLongs.empty( ) ) - { - aValue <<= aCmisLongs.front( ); + aLongsArr[i] = *it; } + aValue <<= aLongs; } break; case libcmis::PropertyType::Decimal: { vector< double > aCmisDoubles = pProperty->getDoubles( ); - if ( bMultiValued ) - { - uno::Sequence< double > aDoubles( aCmisDoubles.size( ) ); - double* aDoublesArr = aDoubles.getArray( ); - sal_Int32 i = 0; - for ( vector< double >::iterator it = aCmisDoubles.begin( ); - it != aCmisDoubles.end( ); ++it, ++i ) - { - aDoublesArr[i] = *it; - } - aValue <<= aDoubles; - } - else if ( !aCmisDoubles.empty( ) ) + uno::Sequence< double > aDoubles( aCmisDoubles.size( ) ); + double* aDoublesArr = aDoubles.getArray( ); + sal_Int32 i = 0; + for ( vector< double >::iterator it = aCmisDoubles.begin( ); + it != aCmisDoubles.end( ); ++it, ++i ) { - aValue <<= aCmisDoubles.front( ); + aDoublesArr[i] = *it; } + aValue <<= aDoubles; } break; case libcmis::PropertyType::Bool: { vector< bool > aCmisBools = pProperty->getBools( ); - if ( bMultiValued ) + uno::Sequence< sal_Bool > aBools( aCmisBools.size( ) ); + sal_Bool* aBoolsArr = aBools.getArray( ); + sal_Int32 i = 0; + for ( vector< bool >::iterator it = aCmisBools.begin( ); + it != aCmisBools.end( ); ++it, ++i ) { - uno::Sequence< sal_Bool > aBools( aCmisBools.size( ) ); - sal_Bool* aBoolsArr = aBools.getArray( ); - sal_Int32 i = 0; - for ( vector< bool >::iterator it = aCmisBools.begin( ); - it != aCmisBools.end( ); ++it, ++i ) - { - aBoolsArr[i] = *it; - } - aValue <<= aBools; - } - else if ( !aCmisBools.empty( ) ) - { - aValue <<= sal_Bool( aCmisBools.front( ) ); + aBoolsArr[i] = *it; } + aValue <<= aBools; } break; case libcmis::PropertyType::DateTime: { vector< boost::posix_time::ptime > aCmisTimes = pProperty->getDateTimes( ); - if ( bMultiValued ) + uno::Sequence< util::DateTime > aTimes( aCmisTimes.size( ) ); + util::DateTime* aTimesArr = aTimes.getArray( ); + sal_Int32 i = 0; + for ( vector< boost::posix_time::ptime >::iterator it = aCmisTimes.begin( ); + it != aCmisTimes.end( ); ++it, ++i ) { - uno::Sequence< util::DateTime > aTimes( aCmisTimes.size( ) ); - util::DateTime* aTimesArr = aTimes.getArray( ); - sal_Int32 i = 0; - for ( vector< boost::posix_time::ptime >::iterator it = aCmisTimes.begin( ); - it != aCmisTimes.end( ); ++it, ++i ) - { - aTimesArr[i] = lcl_boostToUnoTime( *it ); - } - aValue <<= aTimes; - } - else if ( !aCmisTimes.empty( ) ) - { - aValue <<= lcl_boostToUnoTime( aCmisTimes.front( ) ); + aTimesArr[i] = lcl_boostToUnoTime( *it ); } + aValue <<= aTimes; } break; } @@ -215,11 +179,11 @@ namespace type = libcmis::PropertyType::String; else if ( prop.Type == CMIS_TYPE_BOOL ) type = libcmis::PropertyType::Bool; - else if ( prop.Type == CMIS_TYPE_INTEGER ) + else if ( prop.Type == CMIS_TYPE_INTEGER ) type = libcmis::PropertyType::Integer; - else if ( prop.Type == CMIS_TYPE_DECIMAL ) + else if ( prop.Type == CMIS_TYPE_DECIMAL ) type = libcmis::PropertyType::Decimal; - else if ( prop.Type == CMIS_TYPE_DATETIME ) + else if ( prop.Type == CMIS_TYPE_DATETIME ) type = libcmis::PropertyType::DateTime; propertyType->setId( OUSTR_TO_STDSTR( id )); @@ -233,23 +197,13 @@ namespace std::vector< std::string > values; // convert UNO value to string vector - if ( bMultiValued ) - { - uno::Sequence< OUString > aStrings; - value >>= aStrings; - sal_Int32 len = aStrings.getLength( ); - for ( sal_Int32 i = 0; i < len; i++ ) - { - string str = OUSTR_TO_STDSTR( aStrings[i] ); - values.push_back( str ); - } - } - else + uno::Sequence< OUString > aStrings; + value >>= aStrings; + sal_Int32 len = aStrings.getLength( ); + for ( sal_Int32 i = 0; i < len; i++ ) { - OUString val; - value >>= val; - std::string str = OUSTR_TO_STDSTR( val ); - values.push_back( str); + string str = OUSTR_TO_STDSTR( aStrings[i] ); + values.push_back( str ); } libcmis::PropertyPtr property( new libcmis::Property( propertyType, values ) ); commit 3e3008d518f09f5ce95cc00aa7d739f8a6eb6989 Author: Cao Cuong Ngo <cao.cuong....@gmail.com> Date: Fri Aug 23 15:25:06 2013 +0200 CMIS properties dialog: fix scroll Change-Id: I4f65adea63267dcafa448001fed7693f55378751 diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index d662f39..f73024d 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -2341,6 +2341,8 @@ void CmisPropertiesControl::setScrollRange() { sal_Int32 nScrollOffset = m_pPropertiesWin.GetItemHeight(); sal_Int32 nVisibleItems = m_rScrolledWindow.getVisibleChildSize().Height() / nScrollOffset; + if ( !nVisibleItems ) + nVisibleItems = m_pPropertiesWin.GetLineCount() / 2; m_rVertScroll.SetPageSize( nVisibleItems - 1 ); m_rVertScroll.SetVisibleSize( nVisibleItems ); m_rVertScroll.Scroll(); @@ -2437,6 +2439,7 @@ void SfxCmisPropertiesPage::Reset( const SfxItemSet& rItemSet ) aCmisProps[i].Choices, aCmisProps[i].Value ); } + m_pPropertiesCtrl.setScrollRange(); } int SfxCmisPropertiesPage::DeactivatePage( SfxItemSet* /*pSet*/ ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits