summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-07-18 11:55:50 +0200
committerCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-07-18 13:52:01 +0200
commit6fff90e38c7b030ea55a17f354aa41aafad34254 (patch)
treeb705099a541e524fce609c5c6196f7fdfcf1ba6e
parent2507e671554cc9ec058c0fdb6082898eca4d4bc4 (diff)
CMIS properties: Add type to the UNO API
Change-Id: Ie4f32bc840cdfab1d5f600991cd6ac8aabcb1f87
-rw-r--r--include/sfx2/dinfdlg.hxx11
-rw-r--r--offapi/com/sun/star/document/CmisProperty.idl4
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx101
-rw-r--r--sfx2/source/dialog/dinfdlg.hrc6
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx33
-rw-r--r--ucb/source/ucp/cmis/cmis_strings.hxx23
6 files changed, 114 insertions, 64 deletions
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index a344bdcf13ab..5528aaa8c1ee 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -578,6 +578,7 @@ public:
struct CmisPropertyLine
{
OUString m_sId;
+ OUString m_sType;
bool m_bUpdatable;
bool m_bRequired;
bool m_bMultiValued;
@@ -632,8 +633,9 @@ public:
sal_uInt16 GetLineCount() const;
inline sal_Int32 GetLineHeight() const { return m_nLineHeight; }
void AddLine( const OUString& sId, const OUString& sName,
- const bool bUpdatable, const bool bRequired,
- const bool bMultiValued, const bool bOpenChoice,
+ const OUString& sType, const bool bUpdatable,
+ const bool bRequired, const bool bMultiValued,
+ const bool bOpenChoice,
com::sun::star::uno::Any& aChoices,
com::sun::star::uno::Any& rAny );
bool AreAllLinesValid() const;
@@ -663,8 +665,9 @@ public:
~CmisPropertiesControl();
void AddLine( const OUString& sId, const OUString& sName,
- const bool bUpdatable, const bool bRequired,
- const bool bMultiValude, const bool bOpenChoice,
+ const OUString& sType, const bool bUpdatable,
+ const bool bRequired, const bool bMultiValude,
+ const bool bOpenChoice,
com::sun::star::uno::Any& aChoices,
com::sun::star::uno::Any& rAny, bool bInteractive );
diff --git a/offapi/com/sun/star/document/CmisProperty.idl b/offapi/com/sun/star/document/CmisProperty.idl
index 65caab11ead1..b06b84a0ed7f 100644
--- a/offapi/com/sun/star/document/CmisProperty.idl
+++ b/offapi/com/sun/star/document/CmisProperty.idl
@@ -33,6 +33,10 @@ struct CmisProperty
*/
string Name;
+ /** type of the property
+ */
+ string Type;
+
/** specifies if the property is updatable.
*/
boolean Updatable;
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index ba9b364e0998..3b50945afa71 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -2161,6 +2161,7 @@ void CmisPropertiesYesNoButton::Resize()
// struct CmisPropertyLine ---------------------------------------------
CmisPropertyLine::CmisPropertyLine( Window* pParent ) :
m_sId ( ),
+ m_sType ( CMIS_TYPE_STRING ),
m_aName ( pParent, SfxResId( SFX_CMIS_PROPERTY_NAME ) ),
m_aType ( pParent, SfxResId( SFX_CMIS_PROPERTY_TYPE ) ),
m_aValueEdit ( pParent, SfxResId( SFX_CMIS_ED_PROPERTY_VALUE ), this ),
@@ -2223,16 +2224,16 @@ bool CmisPropertiesWindow::IsLineValid( CmisPropertyLine* pLine ) const
{
bool bIsValid = true;
pLine->m_bTypeLostFocus = false;
- OUString sType = pLine->m_aType.GetText( );
String sValue = pLine->m_aValueEdit.GetText();
if ( sValue.Len() == 0 )
return true;
sal_uInt32 nIndex = 0xFFFFFFFF;
- if ( CMIS_TYPE_NUMBER == sType )
+ if ( CMIS_TYPE_INTEGER == pLine->m_sType ||
+ CMIS_TYPE_DECIMAL == pLine->m_sType )
nIndex = const_cast< SvNumberFormatter& >(
m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM );
- else if ( CMIS_TYPE_DATETIME == sType )
+ else if ( CMIS_TYPE_DATETIME == pLine->m_sType )
nIndex = const_cast< SvNumberFormatter& >(
m_aNumberFormatter).GetFormatIndex( NF_DATE_SYS_DDMMYYYY );
@@ -2360,13 +2361,14 @@ void CmisPropertiesWindow::updateLineWidth()
}
void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName,
- const bool bUpdatable, const bool bRequired,
- const bool bMultiValued, const bool bOpenChoice,
- Any& /*aChoices*/, Any& rAny )
+ const OUString& sType, const bool bUpdatable,
+ const bool bRequired, const bool bMultiValued,
+ const bool bOpenChoice, Any& /*aChoices*/, Any& rAny )
{
CmisPropertyLine* pNewLine = new CmisPropertyLine( this );
pNewLine->m_sId = sId;
+ pNewLine->m_sType = sType;
pNewLine->m_bUpdatable = bUpdatable;
pNewLine->m_bRequired = bRequired;
pNewLine->m_bMultiValued = bMultiValued;
@@ -2374,9 +2376,6 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName,
pNewLine->m_aValueEdit.SetLoseFocusHdl( LINK( this, CmisPropertiesWindow, EditLoseFocusHdl ) );
- pNewLine->m_aName.SetAccessibleName(m_aName.GetAccessibleName());
- pNewLine->m_aType.SetAccessibleName(m_aType.GetAccessibleName());
- pNewLine->m_aValueEdit.SetAccessibleName(m_aValueEdit.GetAccessibleName());
pNewLine->m_aValueEdit.SetReadOnly( !bUpdatable );
pNewLine->m_aDateField.SetReadOnly( !bUpdatable );
pNewLine->m_aTimeField.SetReadOnly( !bUpdatable );
@@ -2411,72 +2410,59 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName,
pNewLine->m_aDatePos = pNewLine->m_aDateField.GetPosPixel();
pNewLine->m_aTimePos = pNewLine->m_aTimeField.GetPosPixel();
pNewLine->m_aDateTimeSize = pNewLine->m_aDateField.GetSizePixel();
+ pNewLine->m_aName.SetText( sName );
- sal_Int64 nTmpValue = 0;
- double dTmpValue = 0.0;
- bool bTmpValue = false;
- OUString sTmpValue;
- util::DateTime aTmpDateTime;
SvtSysLocale aSysLocale;
const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData();
- pNewLine->m_aName.SetText( sName );
- OUString sType = CMIS_TYPE_STRING;
OUString sValue;
-
- if ( rAny >>= nTmpValue )
+ if ( sType == CMIS_TYPE_INTEGER )
{
+ sal_Int64 nTmpValue = 0;
+ rAny >>= nTmpValue;
sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM );
m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue );
- pNewLine->m_aValueEdit.SetText( sValue );
- sType = CMIS_TYPE_NUMBER;
}
- else if ( rAny >>= dTmpValue )
+ else if ( sType == CMIS_TYPE_DECIMAL )
{
+ double dTmpValue = 0.0;
+ rAny >>= dTmpValue;
sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM );
m_aNumberFormatter.GetInputLineString( dTmpValue, nIndex, sValue );
- pNewLine->m_aValueEdit.SetText( sValue );
- sType = CMIS_TYPE_NUMBER;
}
- else if ( rAny >>= bTmpValue )
+ else if ( sType == CMIS_TYPE_BOOL )
{
+ bool bTmpValue = false;
+ rAny >>= bTmpValue;
sValue = ( bTmpValue ? rLocaleWrapper.getTrueWord() : rLocaleWrapper.getFalseWord() );
- sType = CMIS_TYPE_BOOLEAN;
+ if ( bTmpValue )
+ pNewLine->m_aYesNoButton.CheckYes();
+ else
+ pNewLine->m_aYesNoButton.CheckNo();
}
- else if ( rAny >>= sTmpValue )
+ else if ( sType == CMIS_TYPE_STRING )
{
- pNewLine->m_aValueEdit.SetText( sTmpValue );
- sType = CMIS_TYPE_STRING;
+ rAny >>= sValue;
}
- else if ( rAny >>= aTmpDateTime )
+ else if ( sType == CMIS_TYPE_DATETIME )
{
+ 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.SetPosSizePixel(pNewLine->m_aDatePos, pNewLine->m_aDateTimeSize );
+ pNewLine->m_aTimeField.SetPosSizePixel(pNewLine->m_aTimePos, pNewLine->m_aDateTimeSize );
- sType = CMIS_TYPE_DATETIME;
- }
-
- if ( sType != CMIS_TYPE_ANY )
- {
- if ( CMIS_TYPE_BOOLEAN == sType )
- {
- if ( bTmpValue )
- pNewLine->m_aYesNoButton.CheckYes();
- else
- pNewLine->m_aYesNoButton.CheckNo();
- }
}
+ pNewLine->m_aValueEdit.SetText( sValue );
pNewLine->m_aType.SetText( sType );
- pNewLine->m_aValueEdit.Show(( CMIS_TYPE_STRING == sType ) || ( CMIS_TYPE_NUMBER == sType ) );
+ pNewLine->m_aValueEdit.Show( CMIS_TYPE_STRING == sType ||
+ CMIS_TYPE_INTEGER == sType ||
+ CMIS_TYPE_DECIMAL == sType );
pNewLine->m_aDateField.Show( CMIS_TYPE_DATETIME == sType );
pNewLine->m_aTimeField.Show( CMIS_TYPE_DATETIME == sType );
- pNewLine->m_aYesNoButton.Show( CMIS_TYPE_BOOLEAN == sType );
+ pNewLine->m_aYesNoButton.Show( CMIS_TYPE_BOOL == sType );
- if ( sType == CMIS_TYPE_DATETIME )
- {
- pNewLine->m_aDateField.SetPosSizePixel(pNewLine->m_aDatePos, pNewLine->m_aDateTimeSize );
- pNewLine->m_aTimeField.SetPosSizePixel(pNewLine->m_aTimePos, pNewLine->m_aDateTimeSize );
- }
pNewLine->m_aName.GrabFocus();
}
@@ -2544,6 +2530,7 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
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;
@@ -2554,7 +2541,8 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
{
aPropertiesSeq[i].Name = sPropertyName;
OUString sType = pLine->m_aType.GetText( );
- if ( CMIS_TYPE_NUMBER == sType )
+ if ( CMIS_TYPE_INTEGER == sType ||
+ CMIS_TYPE_DECIMAL == sType )
{
double nValue = 0;
sal_uInt32 nIndex = const_cast< SvNumberFormatter& >(
@@ -2564,7 +2552,7 @@ Sequence< document::CmisProperty > CmisPropertiesWindow::GetCmisProperties() con
if ( bIsNum )
aPropertiesSeq[i].Value <<= makeAny( nValue );
}
- else if ( CMIS_TYPE_BOOLEAN == sType )
+ else if ( CMIS_TYPE_BOOL == sType )
{
bool bValue = pLine->m_aYesNoButton.IsYesChecked();
aPropertiesSeq[i].Value <<= makeAny( bValue );
@@ -2679,11 +2667,12 @@ IMPL_LINK( CmisPropertiesControl, ScrollHdl, ScrollBar*, pScrollBar )
}
void CmisPropertiesControl::AddLine( const OUString& sId, const OUString& sName,
- const bool bUpdatable, const bool bRequired,
- const bool bMultiValued, const bool bOpenChoice,
- Any& aChoices, Any& rAny, bool bInteractive )
+ const OUString& sType, const bool bUpdatable,
+ const bool bRequired, const bool bMultiValued,
+ const bool bOpenChoice, Any& aChoices, Any& rAny,
+ bool bInteractive )
{
- m_pPropertiesWin->AddLine( sId, sName, bUpdatable, bRequired, bMultiValued,
+ m_pPropertiesWin->AddLine( sId, sName, sType, bUpdatable, bRequired, bMultiValued,
bOpenChoice, aChoices, rAny );
m_pVertScroll->SetRangeMax( m_pPropertiesWin->GetLineCount() + 1 );
if ( bInteractive && m_pPropertiesWin->GetOutputSizePixel().Height() <
@@ -2759,10 +2748,11 @@ void SfxCmisPropertiesPage::Reset( const SfxItemSet& rItemSet )
m_pPropertiesCtrl->ClearAllLines();
const SfxDocumentInfoItem* m_pInfoItem = &(const SfxDocumentInfoItem &)rItemSet.Get(SID_DOCINFO);
uno::Sequence< document::CmisProperty > aCmisProps = m_pInfoItem->GetCmisProperties();
- for ( sal_uInt32 i = 0; i < aCmisProps.getLength(); i++ )
+ for ( sal_Int32 i = 0; i < aCmisProps.getLength(); i++ )
{
m_pPropertiesCtrl->AddLine( aCmisProps[i].Id,
aCmisProps[i].Name,
+ aCmisProps[i].Type,
aCmisProps[i].Updatable,
aCmisProps[i].Required,
aCmisProps[i].MultiValued,
@@ -2785,5 +2775,4 @@ SfxTabPage* SfxCmisPropertiesPage::Create( Window* pParent, const SfxItemSet& rI
return new SfxCmisPropertiesPage( pParent, rItemSet );
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/dinfdlg.hrc b/sfx2/source/dialog/dinfdlg.hrc
index 2f73690094e9..a2b7e5df4557 100644
--- a/sfx2/source/dialog/dinfdlg.hrc
+++ b/sfx2/source/dialog/dinfdlg.hrc
@@ -31,11 +31,11 @@
#define CUSTOM_TYPE_DURATION 5
#define CUSTOM_TYPE_DATETIME 6
-#define CMIS_TYPE_ANY "Any"
#define CMIS_TYPE_STRING "String"
-#define CMIS_TYPE_NUMBER "Number"
+#define CMIS_TYPE_INTEGER "Integer"
+#define CMIS_TYPE_DECIMAL "Decimal"
#define CMIS_TYPE_DATETIME "Datetime"
-#define CMIS_TYPE_BOOLEAN "Boolean"
+#define CMIS_TYPE_BOOL "Bool"
// defines ---------------------------------------------------------------
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index 9ec04f7b7e47..812bb1a5d1a4 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -50,6 +50,7 @@
#include "cmis_provider.hxx"
#include "cmis_resultset.hxx"
#include "cmis_oauth2_providers.hxx"
+#include "cmis_strings.hxx"
#define OUSTR_TO_STDSTR(s) string( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ).getStr() )
#define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), RTL_TEXTENCODING_UTF8 )
@@ -208,7 +209,17 @@ namespace
bool bMultiValued = prop.MultiValued;
bool bOpenChoice = prop.OpenChoice;
uno::Any value = prop.Value;
- libcmis::PropertyType::Type type = libcmis::PropertyType::String;
+ libcmis::PropertyType::Type type;
+ if ( prop.Type == CMIS_TYPE_STRING )
+ type = libcmis::PropertyType::String;
+ else if ( prop.Type == CMIS_TYPE_BOOL )
+ type = libcmis::PropertyType::Bool;
+ else if ( prop.Type == CMIS_TYPE_INTEGER )
+ type = libcmis::PropertyType::Integer;
+ else if ( prop.Type == CMIS_TYPE_DECIMAL )
+ type = libcmis::PropertyType::Decimal;
+ else if ( prop.Type == CMIS_TYPE_DATETIME )
+ type = libcmis::PropertyType::DateTime;
propertyType->setId( OUSTR_TO_STDSTR( id ));
propertyType->setDisplayName( OUSTR_TO_STDSTR( name ) );
@@ -685,6 +696,26 @@ namespace cmis
pCmisProps[i].MultiValued = bMultiValued;
pCmisProps[i].OpenChoice = bOpenChoice;
pCmisProps[i].Value = lcl_cmisPropertyToUno( it->second );
+ switch ( it->second->getPropertyType( )->getType( ) )
+ {
+ default:
+ case libcmis::PropertyType::String:
+ pCmisProps[i].Type = CMIS_TYPE_STRING;
+ break;
+ case libcmis::PropertyType::Integer:
+ pCmisProps[i].Type = CMIS_TYPE_INTEGER;
+ break;
+ case libcmis::PropertyType::Decimal:
+ pCmisProps[i].Type = CMIS_TYPE_DECIMAL;
+ break;
+ case libcmis::PropertyType::Bool:
+ pCmisProps[i].Type = CMIS_TYPE_BOOL;
+ break;
+ case libcmis::PropertyType::DateTime:
+ pCmisProps[i].Type = CMIS_TYPE_DATETIME;
+ break;
+ }
+
}
xRow->appendObject( rProp.Name, uno::makeAny( aCmisProperties ) );
}
diff --git a/ucb/source/ucp/cmis/cmis_strings.hxx b/ucb/source/ucp/cmis/cmis_strings.hxx
new file mode 100644
index 000000000000..f478548c8269
--- /dev/null
+++ b/ucb/source/ucp/cmis/cmis_strings.hxx
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ */
+
+#ifndef CMIS_STRINGS_HXX
+#define CMIS_STRINGS_HXX
+
+#define CMIS_TYPE_STRING "String"
+#define CMIS_TYPE_INTEGER "Integer"
+#define CMIS_TYPE_DECIMAL "Decimal"
+#define CMIS_TYPE_DATETIME "Datetime"
+#define CMIS_TYPE_BOOL "Bool"
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */