From 41f6595dd78fe26cd6b5585c9e93951cc49f6e04 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 20 Jul 2010 18:01:48 +0200 Subject: sw34bf01: #i77438#: xmloff: apply patch by cyhawk --- xmloff/source/core/xmlehelp.cxx | 2 +- xmloff/source/core/xmluconv.cxx | 4 +- xmloff/source/draw/sdxmlexp.cxx | 12 +++--- xmloff/source/draw/shapeexport3.cxx | 4 +- xmloff/source/draw/xexptran.cxx | 48 +++++++++++------------ xmloff/source/style/MarkerStyle.cxx | 6 +-- xmloff/source/style/fonthdl.cxx | 6 +-- xmloff/source/style/xmlnumi.cxx | 10 ++--- xmloff/source/text/txtparae.cxx | 2 +- xmloff/source/transform/FormPropOASISTContext.cxx | 2 +- xmloff/source/transform/TransformerBase.cxx | 10 ++--- 11 files changed, 53 insertions(+), 53 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/core/xmlehelp.cxx b/xmloff/source/core/xmlehelp.cxx index e50e180b089a..2a2b1c2257b8 100644 --- a/xmloff/source/core/xmlehelp.cxx +++ b/xmloff/source/core/xmlehelp.cxx @@ -416,7 +416,7 @@ double SvXMLExportHelper::GetConversionFactor(::rtl::OUStringBuffer& rUnit, MapUnit SvXMLExportHelper::GetUnitFromString(const ::rtl::OUString& rString, MapUnit eDefaultUnit) { - sal_Int32 nPos = 0L; + sal_Int32 nPos = 0; sal_Int32 nLen = rString.getLength(); MapUnit eRetUnit = eDefaultUnit; diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 28abf2edbcbd..efd0a8127d87 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -200,7 +200,7 @@ sal_Bool SvXMLUnitConverter::convertMeasure( sal_Int32& rValue, sal_Bool bNeg = sal_False; double nVal = 0; - sal_Int32 nPos = 0L; + sal_Int32 nPos = 0; const sal_Int32 nLen = rString.getLength(); // skip white space @@ -679,7 +679,7 @@ sal_Bool SvXMLUnitConverter::convertNumber64( sal_Int64& rValue, sal_Bool bNeg = sal_False; rValue = 0; - sal_Int32 nPos = 0L; + sal_Int32 nPos = 0; const sal_Int32 nLen = rString.getLength(); // skip white space diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 862326495a70..815e2b92ef8c 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -853,7 +853,7 @@ void SdXMLExport::ImpPrepAutoLayoutInfos() } // prepare name creation - for(sal_Int32 nCnt = 0L; nCnt < mnDocDrawPageCount; nCnt++) + for (sal_Int32 nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++) { Any aAny(mxDocDrawPages->getByIndex(nCnt)); Reference xDrawPage; @@ -1207,11 +1207,11 @@ void SdXMLExport::ImpWriteAutoLayoutInfos() Point aTmpPos(aPartPos); - for(sal_Int32 a = 0L; a < nRowCnt; a++) + for (sal_Int32 a = 0; a < nRowCnt; a++) { aTmpPos.X() = aPartPos.X(); - for(sal_Int32 b = 0L; b < nColCnt; b++) + for (sal_Int32 b = 0; b < nColCnt; b++) { Rectangle aTmpRect(aTmpPos, aPartSize); @@ -1416,7 +1416,7 @@ void SdXMLExport::ImpPrepPageMasterInfos() if(mnDocMasterPageCount) { // look for needed page-masters, create these - for(sal_Int32 nMPageId = 0L; nMPageId < mnDocMasterPageCount; nMPageId++) + for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++) { Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY ); ImpXMLEXPPageMasterInfo* pNewInfo = 0L; @@ -1841,7 +1841,7 @@ void SdXMLExport::ImpWritePresentationStyles() { if(IsImpress()) { - for(sal_Int32 nCnt = 0L; nCnt < mnDocMasterPageCount; nCnt++) + for (sal_Int32 nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++) { Any aAny(mxDocMasterPages->getByIndex(nCnt)); Reference xNamed; @@ -2552,7 +2552,7 @@ void SdXMLExport::_ExportMasterStyles() } // export MasterPages in master-styles section - for(sal_Int32 nMPageId = 0L; nMPageId < mnDocMasterPageCount; nMPageId++) + for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++) { Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY ); if(xMasterPage.is()) diff --git a/xmloff/source/draw/shapeexport3.cxx b/xmloff/source/draw/shapeexport3.cxx index 559f94f6d51f..f51302b64156 100644 --- a/xmloff/source/draw/shapeexport3.cxx +++ b/xmloff/source/draw/shapeexport3.cxx @@ -218,7 +218,7 @@ void XMLShapeExport::ImpExport3DShape( drawing::DoubleSequence* pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); sal_Int32 a; - for( a= 0L; a < nOuterSequenceCount; a++) + for (a = 0; a < nOuterSequenceCount; a++) { sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength()); double* pArrayX = pInnerSequenceX->getArray(); @@ -268,7 +268,7 @@ void XMLShapeExport::ImpExport3DShape( pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray(); pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray(); - for(a = 0L; a < nOuterSequenceCount; a++) + for (a = 0; a < nOuterSequenceCount; a++) { sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength()); double* pArrayX = pInnerSequenceX->getArray(); diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx index e486394988db..969e3a0d5f8f 100644 --- a/xmloff/source/draw/xexptran.cxx +++ b/xmloff/source/draw/xexptran.cxx @@ -1455,8 +1455,8 @@ SdXMLImExPointsElement::SdXMLImExPointsElement(const OUString& rNew, // second loop if(nNumPoints) { - nPos = 0L; - maPoly.realloc(1L); + nPos = 0; + maPoly.realloc(1); drawing::PointSequence* pOuterSequence = maPoly.getArray(); pOuterSequence->realloc(nNumPoints); awt::Point* pInnerSequence = pOuterSequence->getArray(); @@ -2651,8 +2651,8 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, while(nPos < nLen && Imp_IsOnNumberChar(aStr, nPos)) { - sal_Int32 nX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); if(bRelative) { @@ -2682,8 +2682,8 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, while(nPos < nLen && Imp_IsOnNumberChar(aStr, nPos)) { - sal_Int32 nX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); if(bRelative) { @@ -2713,7 +2713,7 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, while(nPos < nLen && Imp_IsOnNumberChar(aStr, nPos)) { - sal_Int32 nX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); sal_Int32 nY(mnLastY); if(bRelative) @@ -2741,7 +2741,7 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, while(nPos < nLen && Imp_IsOnNumberChar(aStr, nPos)) { sal_Int32 nX(mnLastX); - sal_Int32 nY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); if(bRelative) nY += mnLastY; @@ -2769,10 +2769,10 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, { sal_Int32 nX1; sal_Int32 nY1; - sal_Int32 nX2(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY2(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nX2(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY2(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); if(bRelative) { @@ -2830,12 +2830,12 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, while(nPos < nLen && Imp_IsOnNumberChar(aStr, nPos)) { - sal_Int32 nX1(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY1(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nX2(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY2(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nX1(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY1(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nX2(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY2(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); if(bRelative) { @@ -2879,10 +2879,10 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, while(nPos < nLen && Imp_IsOnNumberChar(aStr, nPos)) { - sal_Int32 nXX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nYY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nXX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nYY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); if(bRelative) { @@ -2932,8 +2932,8 @@ SdXMLImExSvgDElement::SdXMLImExSvgDElement(const OUString& rNew, { sal_Int32 nXX; sal_Int32 nYY; - sal_Int32 nX(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); - sal_Int32 nY(Imp_ImportNumberAndSpaces(0L, aStr, nPos, nLen, rConv)); + sal_Int32 nX(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); + sal_Int32 nY(Imp_ImportNumberAndSpaces(0, aStr, nPos, nLen, rConv)); if(bRelative) { diff --git a/xmloff/source/style/MarkerStyle.cxx b/xmloff/source/style/MarkerStyle.cxx index 4835691b5909..7f134bd65176 100644 --- a/xmloff/source/style/MarkerStyle.cxx +++ b/xmloff/source/style/MarkerStyle.cxx @@ -212,7 +212,7 @@ sal_Bool XMLMarkerStyleExport::exportXML( sal_Int32 a, b; sal_Bool bClosed(sal_False); - for(a = 0L; a < nOuterCnt; a++) + for (a = 0; a < nOuterCnt; a++) { drawing::PointSequence* pSequence = pOuterSequence++; const awt::Point *pPoints = pSequence->getConstArray(); @@ -229,7 +229,7 @@ sal_Bool XMLMarkerStyleExport::exportXML( } } - for(b = 0L; b < nPointCount; b++) + for (b = 0; b < nPointCount; b++) { const awt::Point aPoint = pPoints[b]; @@ -259,7 +259,7 @@ sal_Bool XMLMarkerStyleExport::exportXML( drawing::FlagSequence* pOuterFlags = aBezier.Flags.getArray(); SdXMLImExSvgDElement aSvgDElement(aViewBox); - for(a = 0L; a < nOuterCnt; a++) + for (a = 0; a < nOuterCnt; a++) { drawing::PointSequence* pSequence = pOuterSequence++; drawing::FlagSequence* pFlags = pOuterFlags++; diff --git a/xmloff/source/style/fonthdl.cxx b/xmloff/source/style/fonthdl.cxx index 89ad6e9db8b8..c91a7edcfc03 100644 --- a/xmloff/source/style/fonthdl.cxx +++ b/xmloff/source/style/fonthdl.cxx @@ -136,12 +136,12 @@ sal_Bool XMLFontFamilyNamePropHdl::exportXML( OUString& rStrExpValue, const uno: if( rValue >>= aStrFamilyName ) { OUStringBuffer sValue( aStrFamilyName.getLength() + 2L ); - sal_Int32 nPos = 0L; + sal_Int32 nPos = 0; do { sal_Int32 nFirst = nPos; nPos = aStrFamilyName.indexOf( sal_Unicode(';'), nPos ); - sal_Int32 nLast = (-1L == nPos ? aStrFamilyName.getLength() : nPos); + sal_Int32 nLast = (-1 == nPos ? aStrFamilyName.getLength() : nPos); // Set position to the character behind the ';', so we won't // forget this. @@ -173,7 +173,7 @@ sal_Bool XMLFontFamilyNamePropHdl::exportXML( OUString& rStrExpValue, const uno: sValue.append( sal_Unicode( ',' ) ); sValue.append( sal_Unicode( ' ' )); } - sal_Int32 nLen = nLast-nFirst+1L; + sal_Int32 nLen = nLast-nFirst+1; OUString sFamily( aStrFamilyName.copy( nFirst, nLen ) ); sal_Bool bQuote = sal_False; for( sal_Int32 i=0; i < nLen; i++ ) diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx index 7306c7d5f0de..72efeabaaca4 100644 --- a/xmloff/source/style/xmlnumi.cxx +++ b/xmloff/source/style/xmlnumi.cxx @@ -374,7 +374,7 @@ SvxXMLListLevelStyleContext_Impl::SvxXMLListLevelStyleContext_Impl( if( nLevel >= 1L ) nLevel--; else - nLevel = 0L; + nLevel = 0; break; case XML_TOK_TEXT_LEVEL_ATTR_STYLE_NAME: sTextStyleName = rValue; @@ -471,7 +471,7 @@ Sequence SvxXMLListLevelStyleContext_Impl::GetProperties( { sal_Int16 eType; - sal_Int32 nCount = 0L; + sal_Int32 nCount = 0; if( bBullet ) { eType = NumberingType::CHAR_SPECIAL; @@ -480,7 +480,7 @@ Sequence SvxXMLListLevelStyleContext_Impl::GetProperties( if( bImage ) { eType = NumberingType::BITMAP; - nCount = 15L; + nCount = 15; if( (sImageURL.getLength() > 0L) || xBase64Stream.is() ) nCount++; @@ -490,7 +490,7 @@ Sequence SvxXMLListLevelStyleContext_Impl::GetProperties( eType = NumberingType::ARABIC; GetImport().GetMM100UnitConverter().convertNumFormat( eType, sNumFormat, sNumLetterSync, sal_True ); - nCount = 15L; + nCount = 15; } if( ( bBullet || bNum ) && nRelSize ) @@ -505,7 +505,7 @@ Sequence SvxXMLListLevelStyleContext_Impl::GetProperties( if( nCount > 0 ) { beans::PropertyValue *pProps = aPropSeq.getArray(); - sal_Int32 nPos = 0L; + sal_Int32 nPos = 0; pProps[nPos].Name = OUString::createFromAscii( XML_UNO_NAME_NRULE_NUMBERINGTYPE ); pProps[nPos++].Value <<= (sal_Int16)eType ; diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 140656fd4298..4b6eba9a5f43 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3423,7 +3423,7 @@ void XMLTextParagraphExport::exportTextRange( void XMLTextParagraphExport::exportText( const OUString& rText, sal_Bool& rPrevCharIsSpace ) { - sal_Int32 nExpStartPos = 0L; + sal_Int32 nExpStartPos = 0; sal_Int32 nEndPos = rText.getLength(); sal_Int32 nSpaceChars = 0; for( sal_Int32 nPos = 0; nPos < nEndPos; nPos++ ) diff --git a/xmloff/source/transform/FormPropOASISTContext.cxx b/xmloff/source/transform/FormPropOASISTContext.cxx index 91452183e13e..57ec2b33cf20 100644 --- a/xmloff/source/transform/FormPropOASISTContext.cxx +++ b/xmloff/source/transform/FormPropOASISTContext.cxx @@ -53,7 +53,7 @@ XMLTokenEnum XMLFormPropOASISTransformerContext::GetValueType( sal_Bool bNeg = sal_False; sal_uInt32 nVal = 0; - sal_Int32 nPos = 0L; + sal_Int32 nPos = 0; sal_Int32 nLen = rValue.getLength(); // skip white space diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx index 9df6ed0c461e..d8b6a51ebc00 100644 --- a/xmloff/source/transform/TransformerBase.cxx +++ b/xmloff/source/transform/TransformerBase.cxx @@ -616,8 +616,8 @@ XMLMutableAttributeList *XMLTransformerBase::ProcessAttrList( // --> OD 2004-10-29 #i13778#,#i36248# // apply correct twip-to-1/100mm nMeasure = (sal_Int32)( nMeasure >= 0 - ? ((nMeasure*127L+36L)/72L) - : ((nMeasure*127L-36L)/72L) ); + ? ((nMeasure*127+36)/72) + : ((nMeasure*127-36)/72) ); // <-- rtl::OUStringBuffer aBuffer; @@ -778,8 +778,8 @@ XMLMutableAttributeList *XMLTransformerBase::ProcessAttrList( // --> OD 2004-10-29 #i13778#,#i36248# // apply correct 1/100mm-to-twip conversion nMeasure = (sal_Int32)( nMeasure >= 0 - ? ((nMeasure*72L+63L)/127L) - : ((nMeasure*72L-63L)/127L) ); + ? ((nMeasure*72+63)/127) + : ((nMeasure*72-63)/127) ); // <-- OUStringBuffer aBuffer; @@ -1201,7 +1201,7 @@ sal_Bool XMLTransformerBase::NegPercent( OUString& rValue ) sal_Bool bNeg = sal_False; double nVal = 0; - sal_Int32 nPos = 0L; + sal_Int32 nPos = 0; sal_Int32 nLen = rValue.getLength(); // skip white space -- cgit From be14de675d69009d540394fa1f503d800a2cf85a Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 30 Jul 2010 15:16:05 +0200 Subject: sw34bf01: #i113056#: xmlexp.cxx: apply patch by cmc --- xmloff/source/core/xmlexp.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmloff/source') diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index b1ba8520c1db..ac46c740ee97 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -752,7 +752,7 @@ void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XCompo sal_Int32 nIndex; OUString aURL; - for( nIndex = 0; nIndex < nCount; nIndex++, *pPrefix++ ) + for( nIndex = 0; nIndex < nCount; ++nIndex, ++pPrefix ) { if( xNamespaceMap->getByName( *pPrefix ) >>= aURL ) _GetNamespaceMap().Add( *pPrefix, aURL, XML_NAMESPACE_UNKNOWN ); -- cgit From d623b4e513183aa9f6ea8f13a2c3a8626c124b0d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 4 Aug 2010 14:36:46 +0200 Subject: sw34bf01: #i113645#: PropertyActionsOOo.cxx: add TEXT_OVERLINE_{STYLE,COLOR} to aTextPropertyOOoAttrActionTable. --- xmloff/source/transform/PropertyActionsOOo.cxx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'xmloff/source') diff --git a/xmloff/source/transform/PropertyActionsOOo.cxx b/xmloff/source/transform/PropertyActionsOOo.cxx index 34b5ef85560b..bb3e66ff13b6 100644 --- a/xmloff/source/transform/PropertyActionsOOo.cxx +++ b/xmloff/source/transform/PropertyActionsOOo.cxx @@ -645,6 +645,10 @@ XMLTransformerActionInit aTextPropertyOOoAttrActionTable[] = NO_PARAMS }, /* generated entry */ { XML_NAMESPACE_FO, XML_HYPHENATION_PUSH_CHAR_COUNT, XML_ATACTION_COPY, NO_PARAMS }, /* generated entry */ + { XML_NAMESPACE_STYLE, XML_TEXT_OVERLINE_STYLE, XML_ATACTION_REMOVE, + NO_PARAMS }, /* #i113645# */ + { XML_NAMESPACE_STYLE, XML_TEXT_OVERLINE_COLOR, XML_ATACTION_REMOVE, + NO_PARAMS }, /* #i113645# */ { XML_NAMESPACE_OFFICE, XML_TOKEN_INVALID, XML_ATACTION_EOT, NO_PARAMS } }; -- cgit From f0c824936cfcc6b684898f7c909390a9b5799303 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 9 Sep 2010 11:25:11 +0200 Subject: sw34bf01: #i114162#: xmloff: do not write invalid config-items of type "byte". --- xmloff/source/core/SettingsExportHelper.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'xmloff/source') diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx index 48e3dc92b61d..90e1ba583dd5 100644 --- a/xmloff/source/core/SettingsExportHelper.cxx +++ b/xmloff/source/core/SettingsExportHelper.cxx @@ -203,6 +203,7 @@ void XMLSettingsExportHelper::exportBool(const sal_Bool bValue, const rtl::OUStr void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue, const rtl::OUString& rName) const { +#if 0 DBG_ASSERT(rName.getLength(), "no name"); m_rContext.AddAttribute( XML_NAME, rName ); m_rContext.AddAttribute( XML_TYPE, XML_BYTE ); @@ -211,6 +212,13 @@ void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue, const rtl::OUStr SvXMLUnitConverter::convertNumber(sBuffer, sal_Int32(nValue)); m_rContext.Characters( sBuffer.makeStringAndClear() ); m_rContext.EndElement( sal_False ); +#else + (void) nValue; (void) rName; + OSL_ENSURE(false, "XMLSettingsExportHelper::exportByte(): #i114162#:\n" + "config-items of type \"byte\" are not valid ODF, " + "so storing them is disabled!\n" + "Use a different type instead (e.g. \"short\")."); +#endif } void XMLSettingsExportHelper::exportShort(const sal_Int16 nValue, const rtl::OUString& rName) const { -- cgit From d09dd8986436f17717443823ef18bd8552fdf408 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 15 Sep 2010 13:55:34 +0200 Subject: dba34a: export/import min-/max-/default-/value for date/time as XML-Schema conformant strings --- xmloff/source/core/xmltoken.cxx | 3 + xmloff/source/forms/controlelement.cxx | 2 + xmloff/source/forms/controlelement.hxx | 2 + xmloff/source/forms/elementexport.cxx | 125 ++++++- xmloff/source/forms/elementexport.hxx | 7 + xmloff/source/forms/elementimport.cxx | 402 +++++++++++++++------ xmloff/source/forms/elementimport.hxx | 33 +- xmloff/source/forms/form_handler_factory.hxx | 50 +++ .../source/forms/handler/form_handler_factory.cxx | 90 +++++ xmloff/source/forms/handler/makefile.mk | 55 +++ .../source/forms/handler/property_handler_base.cxx | 61 ++++ .../source/forms/handler/property_handler_base.hxx | 64 ++++ xmloff/source/forms/handler/vcl_date_handler.cxx | 114 ++++++ xmloff/source/forms/handler/vcl_date_handler.hxx | 55 +++ xmloff/source/forms/handler/vcl_time_handler.cxx | 115 ++++++ xmloff/source/forms/handler/vcl_time_handler.hxx | 55 +++ xmloff/source/forms/makefile.mk | 2 + xmloff/source/forms/property_description.hxx | 140 +++++++ xmloff/source/forms/property_group.hxx | 47 +++ xmloff/source/forms/property_handler.hxx | 84 +++++ xmloff/source/forms/property_ids.hxx | 56 +++ xmloff/source/forms/property_meta_data.cxx | 264 ++++++++++++++ xmloff/source/forms/property_meta_data.hxx | 65 ++++ xmloff/source/forms/propertyexport.cxx | 27 +- xmloff/source/forms/propertyexport.hxx | 19 +- xmloff/source/forms/propertyimport.cxx | 7 +- xmloff/source/forms/propertyimport.hxx | 2 +- xmloff/source/forms/valueproperties.cxx | 36 +- 28 files changed, 1802 insertions(+), 180 deletions(-) create mode 100755 xmloff/source/forms/form_handler_factory.hxx create mode 100755 xmloff/source/forms/handler/form_handler_factory.cxx create mode 100755 xmloff/source/forms/handler/makefile.mk create mode 100755 xmloff/source/forms/handler/property_handler_base.cxx create mode 100755 xmloff/source/forms/handler/property_handler_base.hxx create mode 100755 xmloff/source/forms/handler/vcl_date_handler.cxx create mode 100755 xmloff/source/forms/handler/vcl_date_handler.hxx create mode 100755 xmloff/source/forms/handler/vcl_time_handler.cxx create mode 100755 xmloff/source/forms/handler/vcl_time_handler.hxx create mode 100755 xmloff/source/forms/property_description.hxx create mode 100755 xmloff/source/forms/property_group.hxx create mode 100755 xmloff/source/forms/property_handler.hxx create mode 100755 xmloff/source/forms/property_ids.hxx create mode 100755 xmloff/source/forms/property_meta_data.cxx create mode 100755 xmloff/source/forms/property_meta_data.hxx (limited to 'xmloff/source') diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index a3d4a0c48d02..b9b4cc8737b0 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3110,6 +3110,9 @@ namespace xmloff { namespace token { TOKEN( "diagonal-bl-tr-widths", XML_DIAGONAL_BL_TR_WIDTHS ), TOKEN( "diagonal-tl-br-widths", XML_DIAGONAL_TL_BR_WIDTHS ), + TOKEN( "min-value", XML_MIN_VALUE ), + TOKEN( "max-value", XML_MAX_VALUE ), + #if OSL_DEBUG_LEVEL > 0 { 0, NULL, NULL, XML_TOKEN_END } #else diff --git a/xmloff/source/forms/controlelement.cxx b/xmloff/source/forms/controlelement.cxx index 84a74fe44a8b..748cf68c23ed 100644 --- a/xmloff/source/forms/controlelement.cxx +++ b/xmloff/source/forms/controlelement.cxx @@ -59,6 +59,8 @@ namespace xmloff case HIDDEN: return "hidden"; case GRID: return "grid"; case VALUERANGE: return "value-range"; + case TIME: return "time"; + case DATE: return "date"; default: return "generic-control"; } diff --git a/xmloff/source/forms/controlelement.hxx b/xmloff/source/forms/controlelement.hxx index 1816710fb4dc..d226f218f426 100644 --- a/xmloff/source/forms/controlelement.hxx +++ b/xmloff/source/forms/controlelement.hxx @@ -63,6 +63,8 @@ namespace xmloff GRID, VALUERANGE, GENERIC_CONTROL, + TIME, + DATE, UNKNOWN // must be the last element }; diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 115b06c4c2ad..a4cbaa61edec 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -36,6 +36,7 @@ #include "formcellbinding.hxx" #include "formcellbinding.hxx" #include "xformsexport.hxx" +#include "property_meta_data.hxx" /** === begin UNO includes === **/ #include @@ -321,6 +322,9 @@ namespace xmloff #endif } + // "new-style" properties ... + exportGenericHandlerAttributes(); + // common control attributes exportCommonControlAttributes(); @@ -473,6 +477,84 @@ namespace xmloff } } + //--------------------------------------------------------------------- + void OControlExport::exportGenericHandlerAttributes() + { + const Sequence< Property > aProperties = m_xPropertyInfo->getProperties(); + for ( const Property* prop = aProperties.getConstArray(); + prop != aProperties.getConstArray() + aProperties.getLength(); + ++prop + ) + { + try + { + // see if this property can already be handled with an IPropertyHandler (which, on the long + // term, should be the case for most, if not all, properties) + const PropertyDescription* propDescription = metadata::getPropertyDescription( prop->Name ); + if ( propDescription == NULL ) + continue; + + // let the factory provide the concrete handler. Note that caching, if desired, is the task + // of the factory + PPropertyHandler handler = (*propDescription->factory)( propDescription->propertyId ); + ENSURE_OR_CONTINUE( handler.get() != NULL, + "OControlExport::exportGenericHandlerAttributes: invalid property handler provided by the factory!" ); + + ::rtl::OUString attributeValue; + if ( propDescription->propertyGroup == NO_GROUP ) + { + // that's a property which has a direct mapping to an attribute + if ( !shouldExportProperty( prop->Name ) ) + // TODO: in the future, we surely need a more sophisticated approach to this, involving the property + // handler, or the property description + { + exportedProperty( prop->Name ); + continue; + } + + const Any propValue = m_xProps->getPropertyValue( prop->Name ); + attributeValue = handler->getAttributeValue( propValue ); + } + else + { + // that's a property which is part of a group of properties, whose values, in their entity, comprise + // a single attribute value + + // retrieve the descriptions of all other properties which add to the attribute value + PropertyDescriptionList descriptions; + metadata::getPropertyGroup( propDescription->propertyGroup, descriptions ); + + // retrieve the values for all those properties + PropertyValues aValues; + for ( PropertyDescriptionList::iterator prop = descriptions.begin(); + prop != descriptions.end(); + ++prop + ) + { + // TODO: XMultiPropertySet? + const Any propValue = m_xProps->getPropertyValue( (*prop)->propertyName ); + aValues[ (*prop)->propertyId ] = propValue; + } + + // let the handler translate into an XML attribute value + attributeValue = handler->getAttributeValue( aValues ); + } + + AddAttribute( + propDescription->attribute.namespacePrefix, + token::GetXMLToken( propDescription->attribute.attributeToken ), + attributeValue + ); + + exportedProperty( prop->Name ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + //--------------------------------------------------------------------- void OControlExport::exportCommonControlAttributes() { @@ -1380,21 +1462,35 @@ namespace xmloff m_nClassId = FormComponentType::CONTROL; DBG_CHECK_PROPERTY( PROPERTY_CLASSID, sal_Int16 ); m_xProps->getPropertyValue(PROPERTY_CLASSID) >>= m_nClassId; + bool knownType = false; switch (m_nClassId) { case FormComponentType::DATEFIELD: + m_eType = DATE; + knownType = true; + // NO BREAK case FormComponentType::TIMEFIELD: + if ( !knownType ) + { + m_eType = TIME; + knownType = true; + } + m_nIncludeSpecial |= SCA_VALIDATION; + // NO BREAK case FormComponentType::NUMERICFIELD: case FormComponentType::CURRENCYFIELD: case FormComponentType::PATTERNFIELD: - m_eType = FORMATTED_TEXT; + if ( !knownType ) + { + m_eType = FORMATTED_TEXT; + knownType = true; + } // NO BREAK case FormComponentType::TEXTFIELD: { // it's some kind of edit. To know which type we need further investigation - if (FORMATTED_TEXT != m_eType) - { // not coming from the previous cases which had a class id .ne. TEXTFIELD - + if ( !knownType ) + { // check if it's a formatted field if (m_xPropertyInfo->hasPropertyByName(PROPERTY_FORMATKEY)) { @@ -1430,14 +1526,21 @@ namespace xmloff m_eType = TEXT; } } + knownType = true; } - // attributes which are common to all the four types: + // attributes which are common to all the types: // common attributes m_nIncludeCommon = - CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_VALUE | + CCA_NAME | CCA_SERVICE_NAME | CCA_DISABLED | CCA_PRINTABLE | CCA_TAB_INDEX | CCA_TAB_STOP | CCA_TITLE; + if ( ( m_nClassId != FormComponentType::DATEFIELD ) + && ( m_nClassId != FormComponentType::TIMEFIELD ) + ) + // date and time field values are handled differently nowadays + m_nIncludeCommon |= CCA_VALUE; + // database attributes m_nIncludeDatabase = DA_DATA_FIELD | DA_INPUT_REQUIRED; @@ -1461,8 +1564,7 @@ namespace xmloff // max and min values and validation: if (FORMATTED_TEXT == m_eType) { // in general all controls represented as formatted-text have these props - if (FormComponentType::PATTERNFIELD != m_nClassId) - // but the PatternField does not have value limits + if ( FormComponentType::PATTERNFIELD != m_nClassId ) // except the PatternField m_nIncludeSpecial |= SCA_MAX_VALUE | SCA_MIN_VALUE; if (FormComponentType::TEXTFIELD != m_nClassId) @@ -1471,8 +1573,13 @@ namespace xmloff } // if it's not a password field or rich text control, the CurrentValue needs to be stored, too - if ( PASSWORD != m_eType ) + if ( ( PASSWORD != m_eType ) + && ( DATE != m_eType ) + && ( TIME != m_eType ) + ) + { m_nIncludeCommon |= CCA_CURRENT_VALUE; + } } break; diff --git a/xmloff/source/forms/elementexport.hxx b/xmloff/source/forms/elementexport.hxx index d9504271ac04..a8981f0a1fea 100644 --- a/xmloff/source/forms/elementexport.hxx +++ b/xmloff/source/forms/elementexport.hxx @@ -161,6 +161,13 @@ namespace xmloff */ void exportSubTags() throw (::com::sun::star::uno::Exception); + /** adds the attributes which are handled via generic IPropertyHandlers + +

In the future, this really should be *all* attribiutes, instead of this shitload of + hand-crafted code we have currently ...

+ */ + void exportGenericHandlerAttributes(); + /** adds common control attributes to the XMLExport context given

The attribute list of the context is not cleared initially, this is the responsibility of the caller.

diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index b946c4a20941..3eb5be233f9a 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -28,22 +28,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include #include "elementimport.hxx" -#include -#include -#include +#include "xmloff/xmlimp.hxx" +#include "xmloff/nmspmap.hxx" +#include "xmloff/xmluconv.hxx" #include "strings.hxx" #include "callbacks.hxx" #include "attriblistmerge.hxx" #include "xmlnmspe.hxx" #include "eventimport.hxx" -#include +#include "xmloff/txtstyli.hxx" #include "formenums.hxx" -#include +#include "xmloff/xmltoken.hxx" #include "gridcolumnproptranslator.hxx" -#include -#include +#include "property_description.hxx" +#include "property_meta_data.hxx" /** === begin UNO includes === **/ #include @@ -54,9 +53,13 @@ #include #include /** === end UNO includes === **/ + #include +#include #include #include +#include +#include #include #include @@ -166,18 +169,42 @@ namespace xmloff { } + //--------------------------------------------------------------------- + ::rtl::OUString OElementImport::determineDefaultServiceName() const + { + return ::rtl::OUString(); + } + //--------------------------------------------------------------------- void OElementImport::StartElement(const Reference< sax::XAttributeList >& _rxAttrList) { ENTER_LOG_CONTEXT( "xmloff::OElementImport - importing one element" ); - // call the base class. This should give us enough information (especially the service name) - // to create our UNO element - OPropertyImport::StartElement(_rxAttrList); - // create the element + const SvXMLNamespaceMap& rMap = m_rContext.getGlobalContext().GetNamespaceMap(); + const ::rtl::OUString sImplNameAttribute = rMap.GetQNameByKey( XML_NAMESPACE_FORM, GetXMLToken( XML_CONTROL_IMPLEMENTATION ) ); + const ::rtl::OUString sControlImplementation = _rxAttrList->getValueByName( sImplNameAttribute ); + + // retrieve the service name + if ( sControlImplementation.getLength() > 0 ) + { + ::rtl::OUString sOOoImplementationName; + const sal_uInt16 nImplPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sControlImplementation, &sOOoImplementationName ); + m_sServiceName = ( nImplPrefix == XML_NAMESPACE_OOO ) ? sOOoImplementationName : sControlImplementation; + } + + if ( !m_sServiceName.getLength() ) + determineDefaultServiceName(); + + // create the object *now*. This allows setting properties in the various handleAttribute methods. + // (Though currently not all code is migrated to this pattern, most attributes are still handled + // by remembering the value (via implPushBackPropertyValue), and setting the correct property value + // later (in OControlImport::StartElement).) m_xElement = createElement(); - if ( !m_xInfo.is() && m_xElement.is() ) + if ( m_xElement.is() ) m_xInfo = m_xElement->getPropertySetInfo(); + + // call the base class + OPropertyImport::StartElement( _rxAttrList ); } //--------------------------------------------------------------------- @@ -352,7 +379,7 @@ namespace xmloff m_xInfo = m_xElement->getPropertySetInfo(); } - // determine the type of the value (source forthe following conversion) + // determine the type of the value (source for the following conversion) TypeClass eValueTypeClass = aPropValues->Value.getValueTypeClass(); const sal_Bool bValueIsSequence = TypeClass_SEQUENCE == eValueTypeClass; if ( bValueIsSequence ) @@ -361,7 +388,7 @@ namespace xmloff eValueTypeClass = aSimpleType.getTypeClass(); } - // determine the type of the property (target forthe following conversion) + // determine the type of the property (target for the following conversion) const Property aProperty( m_xInfo->getPropertyByName( aPropValues->Name ) ); TypeClass ePropTypeClass = aProperty.Type.getTypeClass(); const sal_Bool bPropIsSequence = TypeClass_SEQUENCE == ePropTypeClass; @@ -484,38 +511,109 @@ namespace xmloff } //--------------------------------------------------------------------- - void OElementImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + PropertyGroups::const_iterator OElementImport::impl_matchPropertyGroup( const PropertyGroups& i_propertyGroups ) const { - if (!m_sServiceName.getLength() && - token::IsXMLToken( _rLocalName, token::XML_CONTROL_IMPLEMENTATION)) - { // it's the service name + ENSURE_OR_RETURN( m_xInfo.is(), "OElementImport::impl_matchPropertyGroup: no property set info!", i_propertyGroups.end() ); + + for ( PropertyGroups::const_iterator group = i_propertyGroups.begin(); + group != i_propertyGroups.end(); + ++group + ) + { + bool missingProp = false; + for ( PropertyDescriptionList::const_iterator prop = group->begin(); + prop != group->end(); + ++prop + ) + { + if ( !m_xInfo->hasPropertyByName( (*prop)->propertyName ) ) + { + missingProp = true; + break; + } + } - ::rtl::OUString sImplName; - const sal_uInt16 nImplPrefix = - GetImport().GetNamespaceMap().GetKeyByAttrName( _rValue, - &sImplName ); - m_sServiceName = XML_NAMESPACE_OOO==nImplPrefix ? sImplName - :_rValue; + if ( missingProp ) + // try next group + continue; + + return group; } - else + + OSL_ENSURE( false, "OElementImport::impl_matchPropertyGroup: no group matched!" ); + return i_propertyGroups.end(); + } + + //--------------------------------------------------------------------- + bool OElementImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + { + if ( token::IsXMLToken( _rLocalName, token::XML_CONTROL_IMPLEMENTATION ) ) + // ignore this, it has already been handled in OElementImport::StartElement + return true; + + if ( token::IsXMLToken( _rLocalName, token::XML_NAME ) ) { - if (!m_sName.getLength() && - token::IsXMLToken( _rLocalName, token::XML_NAME)) + if ( !m_sName.getLength() ) // remember the name for later use in EndElement m_sName = _rValue; + return true; + } + + // maybe it's the style attribute? + if ( token::IsXMLToken( _rLocalName, token::XML_TEXT_STYLE_NAME ) ) + { + const SvXMLStyleContext* pStyleContext = m_rContext.getStyleElement( _rValue ); + OSL_ENSURE( pStyleContext, "OElementImport::handleAttribute: do not know the style!" ); + // remember the element for later usage. + m_pStyleElement = PTR_CAST( XMLTextStyleContext, pStyleContext ); + return true; + } + + // the generic approach (which I hope all props will be migrated to, on the medium term): property handlers + const AttributeDescription attribute( metadata::getAttributeDescription( _nNamespaceKey, _rLocalName ) ); + if ( attribute.attributeToken != XML_TOKEN_INVALID ) + { + PropertyGroups propertyGroups; + metadata::getPropertyGroupList( attribute, propertyGroups ); + const PropertyGroups::const_iterator pos = impl_matchPropertyGroup( propertyGroups ); + if ( pos == propertyGroups.end() ) + return OPropertyImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); - // maybe it's the style attribute? - if ( token::IsXMLToken( _rLocalName, token::XML_TEXT_STYLE_NAME ) ) + do { - const SvXMLStyleContext* pStyleContext = m_rContext.getStyleElement( _rValue ); - OSL_ENSURE( pStyleContext, "OPropertyImport::handleAttribute: do not know the style!" ); - // remember the element for later usage. - m_pStyleElement = PTR_CAST( XMLTextStyleContext, pStyleContext ); + const PropertyDescriptionList& rProperties( *pos ); + const PropertyDescription* first = *rProperties.begin(); + ENSURE_OR_BREAK( first != NULL, "OElementImport::handleAttribute: invalid property description!" ); + const PPropertyHandler handler = (*first->factory)( first->propertyId ); + ENSURE_OR_BREAK( handler.get() != NULL, "OElementImport::handleAttribute: invalid property handler!" ); + + PropertyValues aValues; + for ( PropertyDescriptionList::const_iterator propDesc = rProperties.begin(); + propDesc != rProperties.end(); + ++propDesc + ) + { + aValues[ (*propDesc)->propertyId ] = Any(); + } + if ( handler->getPropertyValues( _rValue, aValues ) ) + { + for ( PropertyDescriptionList::const_iterator propDesc = rProperties.begin(); + propDesc != rProperties.end(); + ++propDesc + ) + { + implPushBackPropertyValue( (*propDesc)->propertyName, aValues[ (*propDesc)->propertyId ] ); + } + } } - else - // let the base class handle it - OPropertyImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); + while ( false ); + + // handled + return true; } + + // let the base class handle it + return OPropertyImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); } //--------------------------------------------------------------------- @@ -553,7 +651,7 @@ namespace xmloff { ::rtl::OUString sLocalAttrName = ::rtl::OUString::createFromAscii(_pAttributeName); if ( !encounteredAttribute( sLocalAttrName ) ) - handleAttribute( XML_NAMESPACE_FORM, sLocalAttrName, ::rtl::OUString::createFromAscii( _pAttributeDefault ) ); + OSL_VERIFY( handleAttribute( XML_NAMESPACE_FORM, sLocalAttrName, ::rtl::OUString::createFromAscii( _pAttributeDefault ) ) ); } } @@ -576,6 +674,36 @@ namespace xmloff { } + //--------------------------------------------------------------------- + ::rtl::OUString OControlImport::determineDefaultServiceName() const + { + const sal_Char* pServiceName = NULL; + switch ( m_eElementType ) + { + case OControlElement::TEXT: + case OControlElement::TEXT_AREA: + case OControlElement::PASSWORD: pServiceName = "com.sun.star.form.component.TextField"; break; + case OControlElement::FILE: pServiceName = "com.sun.star.form.component.FileControl"; break; + case OControlElement::FORMATTED_TEXT: pServiceName = "com.sun.star.form.component.FormattedField"; break; + case OControlElement::FIXED_TEXT: pServiceName = "com.sun.star.form.component.FixedText"; break; + case OControlElement::COMBOBOX: pServiceName = "com.sun.star.form.component.ComboBox"; break; + case OControlElement::LISTBOX: pServiceName = "com.sun.star.form.component.ListBox"; break; + case OControlElement::BUTTON: pServiceName = "com.sun.star.form.component.CommandButton"; break; + case OControlElement::IMAGE: pServiceName = "com.sun.star.form.component.ImageButton"; break; + case OControlElement::CHECKBOX: pServiceName = "com.sun.star.form.component.CheckBox"; break; + case OControlElement::RADIO: pServiceName = "com.sun.star.form.component.RadioButton"; break; + case OControlElement::FRAME: pServiceName = "com.sun.star.form.component.GroupBox"; break; + case OControlElement::IMAGE_FRAME: pServiceName = "com.sun.star.form.component.DatabaseImageControl"; break; + case OControlElement::HIDDEN: pServiceName = "com.sun.star.form.component.HiddenControl"; break; + case OControlElement::GRID: pServiceName = "com.sun.star.form.component.GridControl"; break; + case OControlElement::TIME: pServiceName = "com.sun.star.form.component.DateField"; break; + case OControlElement::DATE: pServiceName = "com.sun.star.form.component.TimeField"; break; + } + if ( pServiceName != NULL ) + return ::rtl::OUString::createFromAscii( pServiceName ); + return ::rtl::OUString(); + } + //--------------------------------------------------------------------- void OControlImport::addOuterAttributes(const Reference< sax::XAttributeList >& _rxOuterAttribs) { @@ -584,7 +712,7 @@ namespace xmloff } //--------------------------------------------------------------------- - void OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + bool OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { static const sal_Char* pLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeName(BA_LINKED_CELL); @@ -601,66 +729,84 @@ namespace xmloff m_sControlId = _rValue; } } + return true; } - else if ( _rLocalName.equalsAscii( pLinkedCellAttributeName ) ) + + if ( _rLocalName.equalsAscii( pLinkedCellAttributeName ) ) { // it's the address of a spreadsheet cell m_sBoundCellAddress = _rValue; + return true; } - else if ( _nNamespaceKey == XML_NAMESPACE_XFORMS && IsXMLToken( _rLocalName, XML_BIND ) ) + + if ( _nNamespaceKey == XML_NAMESPACE_XFORMS && IsXMLToken( _rLocalName, XML_BIND ) ) { m_sBindingID = _rValue; + return true; } - else if ( _nNamespaceKey == XML_NAMESPACE_FORM && IsXMLToken( _rLocalName, XML_XFORMS_LIST_SOURCE ) ) + + if ( _nNamespaceKey == XML_NAMESPACE_FORM && IsXMLToken( _rLocalName, XML_XFORMS_LIST_SOURCE ) ) { m_sListBindingID = _rValue; + return true; } - else if ( (_nNamespaceKey == XML_NAMESPACE_FORM && IsXMLToken( _rLocalName, XML_XFORMS_SUBMISSION ) ) || - ( _nNamespaceKey == XML_NAMESPACE_XFORMS && IsXMLToken( _rLocalName, XML_SUBMISSION ) ) ) + + if ( ( ( _nNamespaceKey == XML_NAMESPACE_FORM ) + && IsXMLToken( _rLocalName, XML_XFORMS_SUBMISSION ) + ) + || ( ( _nNamespaceKey == XML_NAMESPACE_XFORMS ) + && IsXMLToken( _rLocalName, XML_SUBMISSION ) + ) + ) { m_sSubmissionID = _rValue; + return true; } - else + + if ( OElementImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ) ) + return true; + + static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE); + static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE); + static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE); + static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE); + static const sal_Char* pRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY ); + + sal_Int32 nHandle = -1; + if ( _rLocalName.equalsAscii( pValueAttributeName ) ) + nHandle = PROPID_VALUE; + else if ( _rLocalName.equalsAscii( pCurrentValueAttributeName ) ) + nHandle = PROPID_CURRENT_VALUE; + else if ( _rLocalName.equalsAscii( pMinValueAttributeName ) ) + nHandle = PROPID_MIN_VALUE; + else if ( _rLocalName.equalsAscii( pMaxValueAttributeName ) ) + nHandle = PROPID_MAX_VALUE; + if ( nHandle != -1 ) + { + // for the moment, simply remember the name and the value + PropertyValue aProp; + aProp.Name = _rLocalName; + aProp.Handle = nHandle; + aProp.Value <<= _rValue; + m_aValueProperties.push_back(aProp); + return true; + } + + if ( _rLocalName.equalsAscii( pRepeatDelayAttributeName ) ) { - static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE); - static const sal_Char* pCurrentValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CURRENT_VALUE); - static const sal_Char* pMinValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MIN_VALUE); - static const sal_Char* pMaxValueAttributeName = OAttributeMetaData::getSpecialAttributeName(SCA_MAX_VALUE); - static const sal_Char* pRepeatDelayAttributeName = OAttributeMetaData::getSpecialAttributeName( SCA_REPEAT_DELAY ); - - sal_Int32 nHandle = -1; - if ( _rLocalName.equalsAscii( pValueAttributeName ) ) - nHandle = PROPID_VALUE; - else if ( _rLocalName.equalsAscii( pCurrentValueAttributeName ) ) - nHandle = PROPID_CURRENT_VALUE; - else if ( _rLocalName.equalsAscii( pMinValueAttributeName ) ) - nHandle = PROPID_MIN_VALUE; - else if ( _rLocalName.equalsAscii( pMaxValueAttributeName ) ) - nHandle = PROPID_MAX_VALUE; - if ( nHandle != -1 ) + ::Time aTime; + sal_Int32 nFractions = 0; + if ( SvXMLUnitConverter::convertTimeDuration( _rValue, aTime, &nFractions ) ) { - // for the moment, simply remember the name and the value PropertyValue aProp; - aProp.Name = _rLocalName; - aProp.Handle = nHandle; - aProp.Value <<= _rValue; - m_aValueProperties.push_back(aProp); - } - else if ( _rLocalName.equalsAscii( pRepeatDelayAttributeName ) ) - { - ::Time aTime; - sal_Int32 nFractions = 0; - if ( SvXMLUnitConverter::convertTimeDuration( _rValue, aTime, &nFractions ) ) - { - PropertyValue aProp; - aProp.Name = PROPERTY_REPEAT_DELAY; - aProp.Value <<= (sal_Int32)( ( ( aTime.GetMSFromTime() / 1000 ) * 1000 ) + nFractions ); + aProp.Name = PROPERTY_REPEAT_DELAY; + aProp.Value <<= (sal_Int32)( ( ( aTime.GetMSFromTime() / 1000 ) * 1000 ) + nFractions ); - implPushBackPropertyValue(aProp); - } + implPushBackPropertyValue(aProp); } - else - OElementImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); + return true; } + + return false; } //--------------------------------------------------------------------- @@ -980,7 +1126,7 @@ namespace xmloff } //--------------------------------------------------------------------- - void OImagePositionImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, + bool OImagePositionImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ) { if ( _rLocalName == GetXMLToken( XML_IMAGE_POSITION ) ) @@ -990,16 +1136,19 @@ namespace xmloff _rValue, OEnumMapper::getEnumMap( OEnumMapper::epImagePosition ) ) >>= m_nImagePosition ); m_bHaveImagePosition = sal_True; + return true; } - else if ( _rLocalName == GetXMLToken( XML_IMAGE_ALIGN ) ) + + if ( _rLocalName == GetXMLToken( XML_IMAGE_ALIGN ) ) { OSL_VERIFY( PropertyConversion::convertString( m_rContext.getGlobalContext(), ::getCppuType( &m_nImageAlign ), _rValue, OEnumMapper::getEnumMap( OEnumMapper::epImageAlign ) ) >>= m_nImageAlign ); + return true; } - else - OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); + + return OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); } //--------------------------------------------------------------------- @@ -1047,14 +1196,16 @@ namespace xmloff } //--------------------------------------------------------------------- - void OReferredControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, + bool OReferredControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { static const ::rtl::OUString s_sReferenceAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getCommonControlAttributeName(CCA_FOR)); if (_rLocalName == s_sReferenceAttributeName) + { m_sReferringControls = _rValue; - else - OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); + return true; + } + return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); } //===================================================================== @@ -1068,7 +1219,7 @@ namespace xmloff } //--------------------------------------------------------------------- - void OPasswordImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + bool OPasswordImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { static const ::rtl::OUString s_sEchoCharAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getSpecialAttributeName(SCA_ECHO_CHAR)); if (_rLocalName == s_sEchoCharAttributeName) @@ -1083,9 +1234,9 @@ namespace xmloff else aEchoChar.Value <<= (sal_Int16)0; implPushBackPropertyValue(aEchoChar); + return true; } - else - OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); + return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); } //===================================================================== @@ -1099,7 +1250,7 @@ namespace xmloff } //--------------------------------------------------------------------- - void ORadioImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + bool ORadioImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { // need special handling for the State & CurrentState properties: // they're stored as booleans, but expected to be int16 properties @@ -1122,9 +1273,9 @@ namespace xmloff implPushBackPropertyValue(aNewValue); } + return true; } - else - OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); + return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); } //===================================================================== @@ -1138,7 +1289,7 @@ namespace xmloff } //--------------------------------------------------------------------- - void OURLReferenceImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + bool OURLReferenceImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { static const sal_Char* s_pTargetLocationAttributeName = OAttributeMetaData::getCommonControlAttributeName( CCA_TARGET_LOCATION ); static const sal_Char* s_pImageDataAttributeName = OAttributeMetaData::getCommonControlAttributeName( CCA_IMAGE_DATA ); @@ -1157,18 +1308,18 @@ namespace xmloff if ( bMakeAbsolute && ( _rValue.getLength() > 0 ) ) { // make a global URL out of the local one - ::rtl::OUString sAdjustedValue; - // only resolve image related url - // we don't want say form url targets to be resolved - // using ResolveGraphicObjectURL - if ( 0 == _rLocalName.compareToAscii( s_pImageDataAttributeName ) ) - sAdjustedValue = m_rContext.getGlobalContext().ResolveGraphicObjectURL( _rValue, FALSE ); - else - sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue ); - OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, sAdjustedValue ); + ::rtl::OUString sAdjustedValue; + // only resolve image related url + // we don't want say form url targets to be resolved + // using ResolveGraphicObjectURL + if ( 0 == _rLocalName.compareToAscii( s_pImageDataAttributeName ) ) + sAdjustedValue = m_rContext.getGlobalContext().ResolveGraphicObjectURL( _rValue, FALSE ); + else + sAdjustedValue = m_rContext.getGlobalContext().GetAbsoluteReference( _rValue ); + return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, sAdjustedValue ); } - else - OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); + + return OImagePositionImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); } //===================================================================== @@ -1205,14 +1356,14 @@ namespace xmloff } //--------------------------------------------------------------------- - void OValueRangeImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ) + bool OValueRangeImport::handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ) { if ( _rLocalName.equalsAscii( OAttributeMetaData::getSpecialAttributeName( SCA_STEP_SIZE ) ) ) { GetImport().GetMM100UnitConverter().convertNumber( m_nStepSizeValue, _rValue ); + return true; } - else - OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); + return OControlImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); } //--------------------------------------------------------------------- @@ -1535,7 +1686,7 @@ namespace xmloff } //--------------------------------------------------------------------- - void OListAndComboImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + bool OListAndComboImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { static const sal_Char* pListSourceAttributeName = OAttributeMetaData::getDatabaseAttributeName(DA_LIST_SOURCE); if ( _rLocalName.equalsAscii(pListSourceAttributeName) ) @@ -1560,12 +1711,16 @@ namespace xmloff } implPushBackPropertyValue( aListSource ); + return true; } - else if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ) ) ) + + if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_CELL_RANGE ) ) ) { m_sCellListSource = _rValue; + return true; } - else if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ) ) ) + + if ( _rLocalName.equalsAscii( OAttributeMetaData::getBindingAttributeName( BA_LIST_LINKING_TYPE ) ) ) { sal_Int16 nLinkageType = 0; PropertyConversion::convertString( @@ -1576,9 +1731,10 @@ namespace xmloff ) >>= nLinkageType; m_bLinkWithIndexes = ( nLinkageType != 0 ); + return true; } - else - OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); + + return OControlImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); } //--------------------------------------------------------------------- @@ -1776,7 +1932,9 @@ namespace xmloff || (OControlElement::FORMATTED_TEXT == _eType) || (OControlElement::CHECKBOX == _eType) || (OControlElement::LISTBOX == _eType) - || (OControlElement::COMBOBOX == _eType), + || (OControlElement::COMBOBOX == _eType) + || (OControlElement::TIME == _eType) + || (OControlElement::DATE == _eType), "OColumnWrapperImport::implCreateChildContext: invalid or unrecognized sub element!"); switch (_eType) @@ -1871,19 +2029,25 @@ namespace xmloff } //--------------------------------------------------------------------- - void OFormImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + bool OFormImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { // handle the master/details field attributes (they're way too special to let the OPropertyImport handle them) static const ::rtl::OUString s_sMasterFieldsAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getFormAttributeName(faMasterFields)); static const ::rtl::OUString s_sDetailFieldsAttributeName = ::rtl::OUString::createFromAscii(OAttributeMetaData::getFormAttributeName(faDetailFiels)); - if (s_sMasterFieldsAttributeName == _rLocalName) + if ( s_sMasterFieldsAttributeName == _rLocalName ) + { implTranslateStringListProperty(PROPERTY_MASTERFIELDS, _rValue); - else if (s_sDetailFieldsAttributeName == _rLocalName) + return true; + } + + if ( s_sDetailFieldsAttributeName == _rLocalName ) + { implTranslateStringListProperty(PROPERTY_DETAILFIELDS, _rValue); + return true; + } - else - OFormImport_Base::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); + return OFormImport_Base::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); } //--------------------------------------------------------------------- diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx index 97eb2ec950d3..f48f031854de 100644 --- a/xmloff/source/forms/elementimport.hxx +++ b/xmloff/source/forms/elementimport.hxx @@ -31,6 +31,9 @@ #include "propertyimport.hxx" #include "controlelement.hxx" #include "valueproperties.hxx" +#include "eventimport.hxx" +#include "logging.hxx" +#include "property_description.hxx" /** === begin UNO includes === **/ #include @@ -39,9 +42,8 @@ #include #include /** === end UNO includes === **/ + #include -#include "eventimport.hxx" -#include "logging.hxx" class XMLTextStyleContext; //......................................................................... @@ -132,7 +134,7 @@ namespace xmloff virtual void EndElement(); // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); @@ -165,6 +167,10 @@ namespace xmloff /** sets the style properties which have been read for the element (if any) */ void implSetStyleProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ); + + PropertyGroups::const_iterator impl_matchPropertyGroup( const PropertyGroups& i_propertyGroups ) const; + + virtual ::rtl::OUString determineDefaultServiceName() const; }; //===================================================================== @@ -225,7 +231,7 @@ namespace xmloff virtual void EndElement(); // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); @@ -239,6 +245,8 @@ namespace xmloff const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >& _rxPropInfo, ::com::sun::star::beans::PropertyValue& /* [in/out] */ _rPropValue); + virtual ::rtl::OUString determineDefaultServiceName() const; + /** registers the given cell address as value binding address for our element

The default implementation simply calls registerCellValueBinding at our import @@ -265,7 +273,6 @@ namespace xmloff // OElementImport overridables virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createElement(); - }; // TODO: @@ -295,7 +302,7 @@ namespace xmloff const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList); // OPropertyImport overridables - virtual void handleAttribute( sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ); @@ -321,7 +328,7 @@ namespace xmloff const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList); // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); }; @@ -339,7 +346,7 @@ namespace xmloff ); // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); }; @@ -358,7 +365,7 @@ namespace xmloff protected: // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); }; @@ -380,7 +387,7 @@ namespace xmloff protected: // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); }; @@ -430,7 +437,7 @@ namespace xmloff const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList ); // OPropertyImport overridables - virtual void handleAttribute( sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ); }; @@ -516,7 +523,7 @@ namespace xmloff virtual void EndElement(); // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); @@ -715,7 +722,7 @@ namespace xmloff sal_uInt16 _nPrefix, const ::rtl::OUString& _rLocalName); // OPropertyImport overridables - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); diff --git a/xmloff/source/forms/form_handler_factory.hxx b/xmloff/source/forms/form_handler_factory.hxx new file mode 100755 index 000000000000..62bf94f74aa8 --- /dev/null +++ b/xmloff/source/forms/form_handler_factory.hxx @@ -0,0 +1,50 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_FORM_HANDLER_FACTORY_HXX +#define XMLOFF_FORM_HANDLER_FACTORY_HXX + +#include "property_handler.hxx" + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= FormHandlerFactory + //================================================================================================================== + class FormHandlerFactory + { + public: + static PPropertyHandler getFormPropertyHandler( const PropertyId i_propertyId ); + }; + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_FORM_HANDLER_FACTORY_HXX diff --git a/xmloff/source/forms/handler/form_handler_factory.cxx b/xmloff/source/forms/handler/form_handler_factory.cxx new file mode 100755 index 000000000000..ccf829d4201f --- /dev/null +++ b/xmloff/source/forms/handler/form_handler_factory.cxx @@ -0,0 +1,90 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_xmloff.hxx" + +#include "form_handler_factory.hxx" +#include "vcl_date_handler.hxx" +#include "vcl_time_handler.hxx" + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + namespace + { + static PPropertyHandler s_pVCLDateHandler = NULL; + static PPropertyHandler s_pVCLTimeHandler = NULL; + } + + //================================================================================================================== + //= FormHandlerFactory + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + PPropertyHandler FormHandlerFactory::getFormPropertyHandler( const PropertyId i_propertyId ) + { + PPropertyHandler pHandler( NULL ); + + switch ( i_propertyId ) + { + case PID_DATE_MIN: + case PID_DATE_MAX: + case PID_DEFAULT_DATE: + case PID_DATE: + if ( s_pVCLDateHandler.get() == NULL ) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if ( s_pVCLDateHandler == NULL ) + s_pVCLDateHandler = new VCLDateHandler(); + } + pHandler = s_pVCLDateHandler; + break; + + case PID_TIME_MIN: + case PID_TIME_MAX: + case PID_DEFAULT_TIME: + case PID_TIME: + if ( s_pVCLTimeHandler.get() == NULL ) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if ( s_pVCLTimeHandler == NULL ) + s_pVCLTimeHandler = new VCLTimeHandler(); + } + pHandler = s_pVCLTimeHandler; + break; + + default: + OSL_ENSURE( false, "FormHandlerFactory::getFormPropertyHandler: unknown property ID!" ); + break; + } + + return pHandler; + } + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... diff --git a/xmloff/source/forms/handler/makefile.mk b/xmloff/source/forms/handler/makefile.mk new file mode 100755 index 000000000000..574537ffd474 --- /dev/null +++ b/xmloff/source/forms/handler/makefile.mk @@ -0,0 +1,55 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=../../.. + +PRJNAME=xmloff +TARGET=form_handlers + +INCEXT=.. + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE: $(PRJ)/util/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)/form_handler_factory.obj \ + $(SLO)/property_handler_base.obj \ + $(SLO)/vcl_date_handler.obj \ + $(SLO)/vcl_time_handler.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + +test: + echo $(INCLUDE) \ No newline at end of file diff --git a/xmloff/source/forms/handler/property_handler_base.cxx b/xmloff/source/forms/handler/property_handler_base.cxx new file mode 100755 index 000000000000..d599e0e259fe --- /dev/null +++ b/xmloff/source/forms/handler/property_handler_base.cxx @@ -0,0 +1,61 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_xmloff.hxx" + +#include "property_handler_base.hxx" + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= PropertyHandlerBase + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + PropertyHandlerBase::~PropertyHandlerBase() + { + } + + //------------------------------------------------------------------------------------------------------------------ + oslInterlockedCount SAL_CALL PropertyHandlerBase::acquire() + { + return osl_incrementInterlockedCount( &m_refCount ); + } + + //------------------------------------------------------------------------------------------------------------------ + oslInterlockedCount SAL_CALL PropertyHandlerBase::release() + { + oslInterlockedCount decremented = osl_decrementInterlockedCount( &m_refCount ); + if ( 0 == decremented ) + delete this; + return decremented; + } + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... diff --git a/xmloff/source/forms/handler/property_handler_base.hxx b/xmloff/source/forms/handler/property_handler_base.hxx new file mode 100755 index 000000000000..10adceaa52aa --- /dev/null +++ b/xmloff/source/forms/handler/property_handler_base.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_PROPERTY_HANDLER_BASE_HXX +#define XMLOFF_PROPERTY_HANDLER_BASE_HXX + +#include "property_handler.hxx" + +#include + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= PropertyHandlerBase + //================================================================================================================== + class PropertyHandlerBase : public IPropertyHandler + { + protected: + PropertyHandlerBase() + :m_refCount( 0 ) + { + } + + virtual ~PropertyHandlerBase(); + + // IReference + virtual oslInterlockedCount SAL_CALL acquire(); + virtual oslInterlockedCount SAL_CALL release(); + + private: + oslInterlockedCount m_refCount; + }; + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_PROPERTY_HANDLER_BASE_HXX diff --git a/xmloff/source/forms/handler/vcl_date_handler.cxx b/xmloff/source/forms/handler/vcl_date_handler.cxx new file mode 100755 index 000000000000..a8404ed04e05 --- /dev/null +++ b/xmloff/source/forms/handler/vcl_date_handler.cxx @@ -0,0 +1,114 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_xmloff.hxx" + +#include "vcl_date_handler.hxx" +#include "xmloff/xmluconv.hxx" + +#include + +#include +#include + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::util::DateTime; + + //================================================================================================================== + //= VCLDateHandler + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + VCLDateHandler::VCLDateHandler() + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString VCLDateHandler::getAttributeValue( const PropertyValues& /*i_propertyValues*/ ) const + { + OSL_ENSURE( false, "VCLDateHandler::getAttributeValue: unexpected call!" ); + return ::rtl::OUString(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString VCLDateHandler::getAttributeValue( const Any& i_propertyValue ) const + { + sal_Int32 nVCLDate(0); + OSL_VERIFY( i_propertyValue >>= nVCLDate ); + ::Date aVCLDate( nVCLDate ); + + DateTime aDateTime; // default-inited to 0 + aDateTime.Day = aVCLDate.GetDay(); + aDateTime.Month = aVCLDate.GetMonth(); + aDateTime.Year = aVCLDate.GetYear(); + + ::rtl::OUStringBuffer aBuffer; + SvXMLUnitConverter::convertDateTime( aBuffer, aDateTime, sal_False ); + return aBuffer.makeStringAndClear(); + } + + //------------------------------------------------------------------------------------------------------------------ + bool VCLDateHandler::getPropertyValues( const ::rtl::OUString i_attributeValue, PropertyValues& o_propertyValues ) const + { + sal_Int32 nVCLDate(0); + + DateTime aDateTime; + if ( SvXMLUnitConverter::convertDateTime( aDateTime, i_attributeValue ) ) + { + ::Date aVCLDate( aDateTime.Day, aDateTime.Month, aDateTime.Year ); + nVCLDate = aVCLDate.GetDate(); + } + else + { + // compatibility format, before we wrote those values in XML-schema compatible form + if ( !SvXMLUnitConverter::convertNumber( nVCLDate, i_attributeValue ) ) + { + OSL_ENSURE( false, "VCLDateHandler::getPropertyValues: unknown date format (no XML-schema date, no legacy integer)!" ); + return false; + } + } + + const Any aPropertyValue( makeAny( nVCLDate ) ); + + OSL_ENSURE( o_propertyValues.size() == 1, "VCLDateHandler::getPropertyValues: date strings represent exactly one property - not more, not less!" ); + for ( PropertyValues::iterator prop = o_propertyValues.begin(); + prop != o_propertyValues.end(); + ++prop + ) + { + prop->second = aPropertyValue; + } + return true; + } + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... diff --git a/xmloff/source/forms/handler/vcl_date_handler.hxx b/xmloff/source/forms/handler/vcl_date_handler.hxx new file mode 100755 index 000000000000..44a7f7395ceb --- /dev/null +++ b/xmloff/source/forms/handler/vcl_date_handler.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_VCL_DATE_HANDLER_HXX +#define XMLOFF_VCL_DATE_HANDLER_HXX + +#include "property_handler_base.hxx" + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= VCLDateHandler + //================================================================================================================== + class VCLDateHandler : public PropertyHandlerBase + { + public: + VCLDateHandler(); + + // IPropertyHandler + virtual ::rtl::OUString getAttributeValue( const PropertyValues& i_propertyValues ) const; + virtual ::rtl::OUString getAttributeValue( const ::com::sun::star::uno::Any& i_propertyValue ) const; + virtual bool getPropertyValues( const ::rtl::OUString i_attributeValue, PropertyValues& o_propertyValues ) const; + }; + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_VCL_DATE_HANDLER_HXX diff --git a/xmloff/source/forms/handler/vcl_time_handler.cxx b/xmloff/source/forms/handler/vcl_time_handler.cxx new file mode 100755 index 000000000000..98ea739d04a4 --- /dev/null +++ b/xmloff/source/forms/handler/vcl_time_handler.cxx @@ -0,0 +1,115 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_xmloff.hxx" + +#include "vcl_time_handler.hxx" +#include "xmloff/xmluconv.hxx" + +#include + +#include +#include + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::util::DateTime; + + //================================================================================================================== + //= VCLTimeHandler + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + VCLTimeHandler::VCLTimeHandler() + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString VCLTimeHandler::getAttributeValue( const PropertyValues& /*i_propertyValues*/ ) const + { + OSL_ENSURE( false, "VCLTimeHandler::getAttributeValue: unexpected call!" ); + return ::rtl::OUString(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString VCLTimeHandler::getAttributeValue( const Any& i_propertyValue ) const + { + sal_Int32 nVCLTime(0); + OSL_VERIFY( i_propertyValue >>= nVCLTime ); + ::Time aVCLTime( nVCLTime ); + + DateTime aDateTime; // default-inited to 0 + aDateTime.Hours = aVCLTime.GetHour(); + aDateTime.Minutes = aVCLTime.GetMin(); + aDateTime.Seconds = aVCLTime.GetSec(); + aDateTime.HundredthSeconds = aVCLTime.Get100Sec(); + + ::rtl::OUStringBuffer aBuffer; + SvXMLUnitConverter::convertTime( aBuffer, aDateTime ); + return aBuffer.makeStringAndClear(); + } + + //------------------------------------------------------------------------------------------------------------------ + bool VCLTimeHandler::getPropertyValues( const ::rtl::OUString i_attributeValue, PropertyValues& o_propertyValues ) const + { + sal_Int32 nVCLTime(0); + + DateTime aDateTime; + if ( SvXMLUnitConverter::convertTime( aDateTime, i_attributeValue ) ) + { + ::Time aVCLTime( aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds ); + nVCLTime = aVCLTime.GetTime(); + } + else + { + // compatibility format, before we wrote those values in XML-schema compatible form + if ( !SvXMLUnitConverter::convertNumber( nVCLTime, i_attributeValue ) ) + { + OSL_ENSURE( false, "VCLTimeHandler::getPropertyValues: unknown time format (no XML-schema time, no legacy integer)!" ); + return false; + } + } + + const Any aPropertyValue( makeAny( nVCLTime ) ); + + OSL_ENSURE( o_propertyValues.size() == 1, "VCLTimeHandler::getPropertyValues: time strings represent exactly one property - not more, not less!" ); + for ( PropertyValues::iterator prop = o_propertyValues.begin(); + prop != o_propertyValues.end(); + ++prop + ) + { + prop->second = aPropertyValue; + } + return true; + } + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... diff --git a/xmloff/source/forms/handler/vcl_time_handler.hxx b/xmloff/source/forms/handler/vcl_time_handler.hxx new file mode 100755 index 000000000000..7ed6f0aa5730 --- /dev/null +++ b/xmloff/source/forms/handler/vcl_time_handler.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_VCL_TIME_HANDLER_HXX +#define XMLOFF_VCL_TIME_HANDLER_HXX + +#include "property_handler_base.hxx" + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= VCLTimeHandler + //================================================================================================================== + class VCLTimeHandler : public PropertyHandlerBase + { + public: + VCLTimeHandler(); + + // IPropertyHandler + virtual ::rtl::OUString getAttributeValue( const PropertyValues& i_propertyValues ) const; + virtual ::rtl::OUString getAttributeValue( const ::com::sun::star::uno::Any& i_propertyValue ) const; + virtual bool getPropertyValues( const ::rtl::OUString i_attributeValue, PropertyValues& o_propertyValues ) const; + }; + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_VCL_TIME_HANDLER_HXX diff --git a/xmloff/source/forms/makefile.mk b/xmloff/source/forms/makefile.mk index 8c46a4fbf3c9..fa2a6ea7d235 100644 --- a/xmloff/source/forms/makefile.mk +++ b/xmloff/source/forms/makefile.mk @@ -64,6 +64,8 @@ SLOFILES = \ $(SLO)$/logging.obj \ $(SLO)$/formcellbinding.obj \ $(SLO)$/gridcolumnproptranslator.obj \ + \ + $(SLO)/property_meta_data.obj # --- Tagets ------------------------------------------------------- diff --git a/xmloff/source/forms/property_description.hxx b/xmloff/source/forms/property_description.hxx new file mode 100755 index 000000000000..8e9aa9cb616e --- /dev/null +++ b/xmloff/source/forms/property_description.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_PROPERTY_DESCRIPTION_HXX +#define XMLOFF_PROPERTY_DESCRIPTION_HXX + +#include "property_handler.hxx" +#include "property_group.hxx" + +#include "xmloff/xmltoken.hxx" + +#include +#include + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= PropertyDescription + //================================================================================================================== + struct AttributeDescription + { + sal_uInt16 namespacePrefix; // usually XML_NAMESPACE_FORM + ::xmloff::token::XMLTokenEnum attributeToken; + + AttributeDescription() + :namespacePrefix( 0 ) + ,attributeToken( ::xmloff::token::XML_TOKEN_INVALID ) + { + } + + AttributeDescription( + const sal_uInt16 i_namespacePrefix, + const ::xmloff::token::XMLTokenEnum i_attributeToken + ) + :namespacePrefix( i_namespacePrefix ) + ,attributeToken( i_attributeToken ) + { + } + }; + + //.................................................................................................................. + inline bool operator==( const AttributeDescription& i_lhs, const AttributeDescription& i_rhs ) + { + return ( i_lhs.namespacePrefix == i_rhs.namespacePrefix ) + && ( i_lhs.attributeToken == i_rhs.attributeToken ); + } + + //================================================================================================================== + //= PropertyDescription + //================================================================================================================== + struct PropertyDescription + { + /// is the name of the property + const ::rtl::OUString propertyName; + /** denotes the attribute which represents the property. Note that multiple properties might comprise a single + attribute value. + */ + const AttributeDescription attribute; + /// is the factory for creating a handler for reading and writing the property + const PropertyHandlerFactory factory; + /// the unique ID of the property. The property meta data table must not contain two entries with the same property ID + const PropertyId propertyId; + /** the group which the property belongs to. Multiple properties belonging to the same group will, all together, + define the attribute value to be written into the ODF file. + + Consequently, properties which have the same |propertyGroup| value must also have the same |attribute| + and the same |factory| value, with the only exception being NO_GROUP properties. + + Note that the other direction is not given: It is perfectly legitimate to map the same attribute to different + (disjunct) property groups. + */ + const PropertyGroup propertyGroup; + + PropertyDescription() + :propertyName() + ,attribute() + ,factory( NULL ) + ,propertyId( PID_INVALID ) + ,propertyGroup( NO_GROUP ) + { + } + + PropertyDescription( + const ::rtl::OUString& i_propertyName, + const sal_uInt16 i_namespacePrefix, + const ::xmloff::token::XMLTokenEnum i_attributeToken, + const PropertyHandlerFactory i_factory, + const PropertyId i_propertyId, + const PropertyGroup i_propertyGroup + ) + :propertyName( i_propertyName ) + ,attribute( i_namespacePrefix, i_attributeToken ) + ,factory( i_factory ) + ,propertyId( i_propertyId ) + ,propertyGroup( i_propertyGroup ) + { + } + }; + + //================================================================================================================== + //= PropertyDescriptionList + //================================================================================================================== + typedef ::std::vector< const PropertyDescription* > PropertyDescriptionList; + + //================================================================================================================== + //= PropertyGroups + //================================================================================================================== + typedef ::std::list< PropertyDescriptionList > PropertyGroups; + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_PROPERTY_DESCRIPTION_HXX diff --git a/xmloff/source/forms/property_group.hxx b/xmloff/source/forms/property_group.hxx new file mode 100755 index 000000000000..bca354f14e92 --- /dev/null +++ b/xmloff/source/forms/property_group.hxx @@ -0,0 +1,47 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_PROPERTY_GROUP_HXX +#define XMLOFF_PROPERTY_GROUP_HXX + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= PropertyGroup + //================================================================================================================== + enum PropertyGroup + { + NO_GROUP + }; + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_PROPERTY_GROUP_HXX diff --git a/xmloff/source/forms/property_handler.hxx b/xmloff/source/forms/property_handler.hxx new file mode 100755 index 000000000000..247b4f17f798 --- /dev/null +++ b/xmloff/source/forms/property_handler.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_PROPERTY_HANDLER_HXX +#define XMLOFF_PROPERTY_HANDLER_HXX + +#include "property_ids.hxx" + +#include + +#include + +#include +#include + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + typedef ::std::map< PropertyId, ::com::sun::star::uno::Any > PropertyValues; + + //================================================================================================================== + //= IPropertyHandler + //================================================================================================================== + class IPropertyHandler : public ::rtl::IReference + { + public: + /** retrieves the XML attribute value for the given property values + */ + virtual ::rtl::OUString + getAttributeValue( const PropertyValues& i_propertyValues ) const = 0; + + /** is a convenience method for XML attributes whose value comprises of only one UNO API property + */ + virtual ::rtl::OUString + getAttributeValue( const ::com::sun::star::uno::Any& i_propertyValue ) const = 0; + + /** retrieves the values of the properties controlled by an XML attributed, described by a given attribute value + */ + virtual bool + getPropertyValues( const ::rtl::OUString i_attributeValue, PropertyValues& o_propertyValues ) const = 0; + + virtual ~IPropertyHandler() { } + }; + + //================================================================================================================== + //= PPropertyHandler + //================================================================================================================== + typedef ::rtl::Reference< IPropertyHandler > PPropertyHandler; + + //================================================================================================================== + //= PropertyHandlerFactory + //================================================================================================================== + typedef PPropertyHandler (*PropertyHandlerFactory)( const PropertyId i_propertyId ); + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_PROPERTY_HANDLER_HXX diff --git a/xmloff/source/forms/property_ids.hxx b/xmloff/source/forms/property_ids.hxx new file mode 100755 index 000000000000..31004f2d9ff2 --- /dev/null +++ b/xmloff/source/forms/property_ids.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_PROPERTY_IDS_HXX +#define XMLOFF_PROPERTY_IDS_HXX + +//...................................................................................................................... +namespace xmloff +{ +//...................................................................................................................... + + //================================================================================================================== + //= PropertyId + //================================================================================================================== + enum PropertyId + { + PID_DATE_MIN, + PID_DATE_MAX, + PID_DEFAULT_DATE, + PID_DATE, + PID_TIME_MIN, + PID_TIME_MAX, + PID_DEFAULT_TIME, + PID_TIME, + + PID_INVALID + }; + +//...................................................................................................................... +} // namespace xmloff +//...................................................................................................................... + +#endif // XMLOFF_PROPERTY_IDS_HXX diff --git a/xmloff/source/forms/property_meta_data.cxx b/xmloff/source/forms/property_meta_data.cxx new file mode 100755 index 000000000000..a907112dbe58 --- /dev/null +++ b/xmloff/source/forms/property_meta_data.cxx @@ -0,0 +1,264 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_xmloff.hxx" + +#include "property_description.hxx" +#include "form_handler_factory.hxx" +#include "strings.hxx" +#include "xmloff/xmltoken.hxx" +#include "xmlnmspe.hxx" + +#include +#include + +#include + +//...................................................................................................................... +namespace xmloff { namespace metadata +{ +//...................................................................................................................... + + using namespace ::xmloff::token; + +#define FORM_SINGLE_PROPERTY( id, att ) \ + PropertyDescription( PROPERTY_##id, XML_NAMESPACE_FORM, att, &FormHandlerFactory::getFormPropertyHandler, PID_##id, NO_GROUP ) + + //================================================================================================================== + //= property meta data + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + static const PropertyDescription s_propertyMetaData[] = + { + FORM_SINGLE_PROPERTY( DATE_MIN, XML_MIN_VALUE ), + FORM_SINGLE_PROPERTY( DATE_MAX, XML_MAX_VALUE ), + FORM_SINGLE_PROPERTY( DEFAULT_DATE, XML_VALUE ), + FORM_SINGLE_PROPERTY( DATE, XML_CURRENT_VALUE ), + FORM_SINGLE_PROPERTY( TIME_MIN, XML_MIN_VALUE ), + FORM_SINGLE_PROPERTY( TIME_MAX, XML_MAX_VALUE ), + FORM_SINGLE_PROPERTY( DEFAULT_TIME, XML_VALUE ), + FORM_SINGLE_PROPERTY( TIME, XML_CURRENT_VALUE ), + + PropertyDescription() + }; + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + // TODO: instead of having all of the below static, it should be some per-instance data. This way, the + // approach used here would scale much better. + // That is, if you have multiple "meta data instances", which manage a small, but closed set of properties, + // then looking looking through those multiple instances would probably be faster than searching within + // one big instance, since in this case, every instance can quickly decide whether it is responsible + // for some attribute or property, and otherwise delegate to the next instance. + + //.............................................................................................................. + typedef ::std::hash_map< ::rtl::OUString, const PropertyDescription*, ::rtl::OUStringHash > DescriptionsByName; + + //.............................................................................................................. + const DescriptionsByName& lcl_getPropertyDescriptions() + { + DBG_TESTSOLARMUTEX(); + static DescriptionsByName s_propertyDescriptionsByName; + if ( s_propertyDescriptionsByName.empty() ) + { + const PropertyDescription* desc = s_propertyMetaData; + while ( desc->propertyName.getLength() != 0 ) + { + s_propertyDescriptionsByName[ desc->propertyName ] = desc; + ++desc; + } + } + return s_propertyDescriptionsByName; + } + + //.............................................................................................................. + typedef ::std::map< PropertyGroup, PropertyDescriptionList > IndexedPropertyGroups; + + //.............................................................................................................. + const IndexedPropertyGroups& lcl_getIndexedPropertyGroups() + { + DBG_TESTSOLARMUTEX(); + static IndexedPropertyGroups s_indexedPropertyGroups; + if ( s_indexedPropertyGroups.empty() ) + { + const PropertyDescription* desc = s_propertyMetaData; + while ( desc->propertyName.getLength() != 0 ) + { + if ( desc->propertyGroup != NO_GROUP ) + s_indexedPropertyGroups[ desc->propertyGroup ].push_back( desc ); + ++desc; + } + } + return s_indexedPropertyGroups; + } + + //.............................................................................................................. + typedef ::std::hash_map< ::rtl::OUString, XMLTokenEnum, ::rtl::OUStringHash > ReverseTokenLookup; + + //.............................................................................................................. + const ReverseTokenLookup& getReverseTokenLookup() + { + DBG_TESTSOLARMUTEX(); + static ReverseTokenLookup s_reverseTokenLookup; + if ( s_reverseTokenLookup.empty() ) + { + const PropertyDescription* desc = s_propertyMetaData; + while ( desc->propertyName.getLength() != 0 ) + { + s_reverseTokenLookup[ token::GetXMLToken( desc->attribute.attributeToken ) ] = desc->attribute.attributeToken; + ++desc; + } + } + return s_reverseTokenLookup; + } + + //.............................................................................................................. + struct AttributeHash : public ::std::unary_function< AttributeDescription, size_t > + { + size_t operator()( const AttributeDescription& i_attribute ) const + { + return size_t( i_attribute.attributeToken * 100 ) + size_t( i_attribute.namespacePrefix ); + } + }; + + //.............................................................................................................. + typedef ::std::hash_multimap< AttributeDescription, PropertyGroup, AttributeHash > AttributeGroups; + + //.............................................................................................................. + const AttributeGroups& lcl_getAttributeGroups() + { + DBG_TESTSOLARMUTEX(); + static AttributeGroups s_attributeGroups; + if ( s_attributeGroups.empty() ) + { + const PropertyDescription* desc = s_propertyMetaData; + while ( desc->propertyName.getLength() != 0 ) + { + if ( desc->propertyGroup != NO_GROUP ) + s_attributeGroups.insert( AttributeGroups::value_type( desc->attribute, desc->propertyGroup ) ); + ++desc; + } + } + return s_attributeGroups; + } + + //.............................................................................................................. + typedef ::std::hash_map< AttributeDescription, PropertyGroups, AttributeHash > AttributesWithoutGroup; + + //.............................................................................................................. + const AttributesWithoutGroup& lcl_getAttributesWithoutGroups() + { + DBG_TESTSOLARMUTEX(); + static AttributesWithoutGroup s_attributesWithoutGroup; + if ( s_attributesWithoutGroup.empty() ) + { + const PropertyDescription* desc = s_propertyMetaData; + while ( desc->propertyName.getLength() != 0 ) + { + if ( desc->propertyGroup == NO_GROUP ) + { + PropertyDescriptionList singleElementList; + singleElementList.push_back( desc ); + + s_attributesWithoutGroup[ desc->attribute ].push_back( singleElementList ); + } + ++desc; + } + } + return s_attributesWithoutGroup; + } + } + + //------------------------------------------------------------------------------------------------------------------ + const PropertyDescription* getPropertyDescription( const ::rtl::OUString& i_propertyName ) + { + const DescriptionsByName& rAllDescriptions( lcl_getPropertyDescriptions() ); + DescriptionsByName::const_iterator pos = rAllDescriptions.find( i_propertyName ); + if ( pos != rAllDescriptions.end() ) + return pos->second; + return NULL; + } + + //------------------------------------------------------------------------------------------------------------------ + void getPropertyGroup( const PropertyGroup i_propertyGroup, PropertyDescriptionList& o_propertyDescriptions ) + { + OSL_ENSURE( i_propertyGroup != NO_GROUP, "xmloff::metadata::getPropertyGroup: illegal group!" ); + + const IndexedPropertyGroups& rPropertyGroups( lcl_getIndexedPropertyGroups() ); + const IndexedPropertyGroups::const_iterator pos = rPropertyGroups.find( i_propertyGroup ); + if ( pos != rPropertyGroups.end() ) + o_propertyDescriptions = pos->second; + } + + //------------------------------------------------------------------------------------------------------------------ + void getPropertyGroupList( const AttributeDescription& i_attribute, PropertyGroups& o_propertyGroups ) + { + const AttributeGroups& rAttributeGroups = lcl_getAttributeGroups(); + + ::std::pair< AttributeGroups::const_iterator, AttributeGroups::const_iterator > + range = rAttributeGroups.equal_range( i_attribute ); + + if ( range.first == range.second ) + { + // the attribute is not used for any non-trivial group, which means it is mapped directly to + // a single property + const AttributesWithoutGroup& attributesWithoutGroups( lcl_getAttributesWithoutGroups() ); + const AttributesWithoutGroup::const_iterator pos = attributesWithoutGroups.find( i_attribute ); + if ( pos != attributesWithoutGroups.end() ) + o_propertyGroups = pos->second; + } + else + { + const IndexedPropertyGroups& rPropertyGroups = lcl_getIndexedPropertyGroups(); + for ( AttributeGroups::const_iterator group = range.first; group != range.second; ++group ) + { + const PropertyGroup propGroup = group->second; + const IndexedPropertyGroups::const_iterator groupPos = rPropertyGroups.find( propGroup ); + ENSURE_OR_CONTINUE( groupPos != rPropertyGroups.end(), "getPropertyGroupList: inconsistency!" ); + o_propertyGroups.push_back( groupPos->second ); + } + } + } + + //------------------------------------------------------------------------------------------------------------------ + AttributeDescription getAttributeDescription( const sal_uInt16 i_namespacePrefix, const ::rtl::OUString& i_attributeName ) + { + AttributeDescription attribute; + + const ReverseTokenLookup& rTokenLookup( getReverseTokenLookup() ); + const ReverseTokenLookup::const_iterator pos = rTokenLookup.find( i_attributeName ); + if ( pos != rTokenLookup.end() ) + { + attribute.namespacePrefix = i_namespacePrefix; + attribute.attributeToken = pos->second; + } + return attribute; + } + +//...................................................................................................................... +} } // namespace xmloff::metadata +//...................................................................................................................... diff --git a/xmloff/source/forms/property_meta_data.hxx b/xmloff/source/forms/property_meta_data.hxx new file mode 100755 index 000000000000..f246a7bfd745 --- /dev/null +++ b/xmloff/source/forms/property_meta_data.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef XMLOFF_PROPERTY_META_DATA_HXX +#define XMLOFF_PROPERTY_META_DATA_HXX + +#include "property_description.hxx" + +//...................................................................................................................... +namespace xmloff { namespace metadata +{ +//...................................................................................................................... + + const PropertyDescription* getPropertyDescription( const ::rtl::OUString& i_propertyName ); + + /** retries the descriptions of all properties which add to the given XML attribute + +

Effectively, the complete property map is search for all entries which have the given + namespace/attribute values.

+ */ + void getPropertyGroup( + const PropertyGroup i_propertyGroup, + PropertyDescriptionList& o_propertyDescriptions + ); + + /** retrieves all known property groups which are mapped to the given attribute + */ + void getPropertyGroupList( + const AttributeDescription& i_attribute, + PropertyGroups& o_propertyGroups + ); + + /** retrieves the attribute descriptor for the attribute given by namespace prefix and attribute name + */ + AttributeDescription + getAttributeDescription( const sal_uInt16 i_namespacePrefix, const ::rtl::OUString& i_attributeName ); + +//...................................................................................................................... +} } // namespace xmloff::metadata +//...................................................................................................................... + +#endif // XMLOFF_PROPERTY_META_DATA_HXX diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index 2a485566cf9d..7d84e5a60a1f 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -72,6 +71,8 @@ namespace xmloff OPropertyExport::OPropertyExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps) :m_rContext(_rContext) ,m_xProps(_rxProps) + ,m_xPropertyInfo( m_xProps->getPropertySetInfo() ) + ,m_xPropertyState( _rxProps, UNO_QUERY ) { // caching ::rtl::OUStringBuffer aBuffer; @@ -80,13 +81,24 @@ namespace xmloff m_rContext.getGlobalContext().GetMM100UnitConverter().convertBool(aBuffer, sal_False); m_sValueFalse = aBuffer.makeStringAndClear(); - m_xPropertyInfo = m_xProps->getPropertySetInfo(); OSL_ENSURE(m_xPropertyInfo.is(), "OPropertyExport::OPropertyExport: need an XPropertySetInfo!"); // collect the properties which need to be exported examinePersistence(); } + //--------------------------------------------------------------------- + bool OPropertyExport::shouldExportProperty( const ::rtl::OUString& i_propertyName ) const + { + // if the property state is DEFAULT, it does not need to be written - at least + // if it's a built-in property, and not a dynamically-added one. + bool bIsDefaultValue = m_xPropertyState.is() + && ( PropertyState_DEFAULT_VALUE == m_xPropertyState->getPropertyState( i_propertyName ) ); + bool bIsDynamicProperty = m_xPropertyInfo.is() + && ( ( m_xPropertyInfo->getPropertyByName( i_propertyName ).Attributes & PropertyAttribute::REMOVEABLE ) != 0 ); + return ( !bIsDefaultValue || bIsDynamicProperty ); + } + //--------------------------------------------------------------------- void OPropertyExport::exportRemainingProperties() { @@ -95,9 +107,6 @@ namespace xmloff try { - Reference< XPropertyState > xPropertyState( m_xProps, UNO_QUERY ); - Reference< XPropertySetInfo > xPSI( m_xProps->getPropertySetInfo() ); - Any aValue; ::rtl::OUString sValue; @@ -112,13 +121,7 @@ namespace xmloff #if OSL_DEBUG_LEVEL > 0 const ::rtl::OUString sPropertyName = *aProperty; (void)sPropertyName; #endif - // if the property state is DEFAULT, it does not need to be written - at least - // if it's a built-in property, and not a dynamically-added one. - bool bIsDefaultValue = xPropertyState.is() - && ( PropertyState_DEFAULT_VALUE == xPropertyState->getPropertyState( *aProperty ) ); - bool bIsDynamicProperty = xPSI.is() - && ( ( xPSI->getPropertyByName( *aProperty ).Attributes & PropertyAttribute::REMOVEABLE ) != 0 ); - if ( bIsDefaultValue && !bIsDynamicProperty ) + if ( !shouldExportProperty( *aProperty ) ) continue; // now that we have the first sub-tag we need the form:properties element diff --git a/xmloff/source/forms/propertyexport.hxx b/xmloff/source/forms/propertyexport.hxx index ab17912e4df4..3ddfd8d4cabd 100644 --- a/xmloff/source/forms/propertyexport.hxx +++ b/xmloff/source/forms/propertyexport.hxx @@ -31,6 +31,7 @@ #include "formattributes.hxx" #include #include +#include #include #include #include "callbacks.hxx" @@ -74,10 +75,12 @@ namespace xmloff protected: IFormsExportContext& m_rContext; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > - m_xProps; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > - m_xPropertyInfo; + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + m_xProps; + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > + m_xPropertyInfo; + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > + m_xPropertyState; // caching ::rtl::OUString m_sValueTrue; @@ -308,6 +311,14 @@ namespace xmloff const sal_Unicode _aQuoteCharacter = '"', const sal_Unicode _aListSeparator = ','); + /** determines whether the given property is to be exported + +

Currently, the method simply checks whether the property's state is not PropertyState.DEFAULT, + or whether the property is a dynamic property (i.e. added via an XPropertyContainer). + So, take care when using the method - the heuristics is not applicable for all properties.

+ */ + bool shouldExportProperty( const ::rtl::OUString& i_propertyName ) const; + /** tries to convert an arbitrary Any into an string

If the type contained in the Any is not supported, the returned string will be empty. In the diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index 45fa2f5b4744..9d8e7be994f3 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -349,7 +349,7 @@ _rChars } //--------------------------------------------------------------------- -void OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) +bool OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { const OAttribute2Property::AttributeAssignment* pProperty = m_rContext.getAttributeMap().getAttributeTranslation(_rLocalName); if (pProperty) @@ -361,9 +361,10 @@ void OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const ::rtl // convert the value string into the target type aNewValue.Value = PropertyConversion::convertString(m_rContext.getGlobalContext(), pProperty->aPropertyType, _rValue, pProperty->pEnumMap, pProperty->bInverseSemantics); implPushBackPropertyValue( aNewValue ); + return true; } #if OSL_DEBUG_LEVEL > 0 - else if (!token::IsXMLToken(_rLocalName, token::XML_TYPE)) // xlink:type is valid but ignored for + if (!token::IsXMLToken(_rLocalName, token::XML_TYPE)) // xlink:type is valid but ignored for { ::rtl::OString sMessage( "OPropertyImport::handleAttribute: Can't handle the following:\n" ); sMessage += ::rtl::OString( " Attribute name: " ); @@ -371,7 +372,9 @@ void OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const ::rtl sMessage += ::rtl::OString( "\n value: " ); sMessage += ::rtl::OString( _rValue.getStr(), _rValue.getLength(), osl_getThreadTextEncoding() ); OSL_ENSURE( sal_False, sMessage.getStr() ); + return false; } + return true; #endif } diff --git a/xmloff/source/forms/propertyimport.hxx b/xmloff/source/forms/propertyimport.hxx index 30bc8bb1d617..d46c0068f090 100644 --- a/xmloff/source/forms/propertyimport.hxx +++ b/xmloff/source/forms/propertyimport.hxx @@ -119,7 +119,7 @@ namespace xmloff @param _rValue attribute value */ - virtual void handleAttribute(sal_uInt16 _nNamespaceKey, + virtual bool handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue); diff --git a/xmloff/source/forms/valueproperties.cxx b/xmloff/source/forms/valueproperties.cxx index 1c44db963944..8bf9ae7bcd57 100644 --- a/xmloff/source/forms/valueproperties.cxx +++ b/xmloff/source/forms/valueproperties.cxx @@ -65,16 +65,6 @@ namespace xmloff } break; - case FormComponentType::DATEFIELD: - _rpCurrentValuePropertyName = PROPERTY_DATE; - _rpValuePropertyName = PROPERTY_DEFAULT_DATE; - break; - - case FormComponentType::TIMEFIELD: - _rpCurrentValuePropertyName = PROPERTY_TIME; - _rpValuePropertyName = PROPERTY_DEFAULT_TIME; - break; - case FormComponentType::NUMERICFIELD: case FormComponentType::CURRENCYFIELD: _rpCurrentValuePropertyName = PROPERTY_VALUE; @@ -108,6 +98,10 @@ namespace xmloff _rpCurrentValuePropertyName = PROPERTY_SPINVALUE; _rpValuePropertyName = PROPERTY_DEFAULT_SPINVALUE; break; + + default: + OSL_ENSURE( false, "OValuePropertiesMetaData::getValuePropertyNames: unsupported component type!" ); + break; } } @@ -119,16 +113,6 @@ namespace xmloff _rpMinValuePropertyName = _rpMaxValuePropertyName = NULL; switch (_nFormComponentType) { - case FormComponentType::DATEFIELD: - _rpMinValuePropertyName = PROPERTY_DATE_MIN; - _rpMaxValuePropertyName = PROPERTY_DATE_MAX; - break; - - case FormComponentType::TIMEFIELD: - _rpMinValuePropertyName = PROPERTY_TIME_MIN; - _rpMaxValuePropertyName = PROPERTY_TIME_MAX; - break; - case FormComponentType::NUMERICFIELD: case FormComponentType::CURRENCYFIELD: _rpMinValuePropertyName = PROPERTY_VALUE_MIN; @@ -149,6 +133,10 @@ namespace xmloff _rpMinValuePropertyName = PROPERTY_SPINVALUE_MIN; _rpMaxValuePropertyName = PROPERTY_SPINVALUE_MAX; break; + + default: + OSL_ENSURE( false, "OValuePropertiesMetaData::getValueLimitPropertyNames: unsupported component type!" ); + break; } } @@ -175,7 +163,15 @@ namespace xmloff break; case FormComponentType::DATEFIELD: + _rpValuePropertyName = PROPERTY_DATE; + _rpDefaultValuePropertyName = PROPERTY_DEFAULT_DATE; + break; + case FormComponentType::TIMEFIELD: + _rpValuePropertyName = PROPERTY_TIME; + _rpDefaultValuePropertyName = PROPERTY_DEFAULT_TIME; + break; + case FormComponentType::NUMERICFIELD: case FormComponentType::CURRENCYFIELD: case FormComponentType::PATTERNFIELD: -- cgit From 3810e697af86a7e044d5ae305a172bfec23ab166 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 15 Sep 2010 13:55:35 +0200 Subject: dba34a: #i110304# when converting a string to a css.util.DateTime, don't go the way via a float, as it causes rounding errors --- xmloff/source/core/xmluconv.cxx | 88 +++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 47 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 28abf2edbcbd..4a748f99ec54 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -874,32 +874,27 @@ void SvXMLUnitConverter::convertTime( ::rtl::OUStringBuffer& rBuffer, } /** convert ISO Time String to double; negative durations allowed */ -sal_Bool SvXMLUnitConverter::convertTime( double& fTime, - const ::rtl::OUString& rString) +static bool lcl_convertTime( const ::rtl::OUString& rString, sal_Int32& o_rDays, sal_Int32& o_rHours, sal_Int32& o_rMins, + sal_Int32& o_rSecs, sal_Bool& o_rIsNegativeTime, double& o_rFractionalSecs ) { rtl::OUString aTrimmed = rString.trim().toAsciiUpperCase(); const sal_Unicode* pStr = aTrimmed.getStr(); // negative time duration? - sal_Bool bIsNegativeDuration = sal_False; if ( sal_Unicode('-') == (*pStr) ) { - bIsNegativeDuration = sal_True; + o_rIsNegativeTime = sal_True; pStr++; } if ( *(pStr++) != sal_Unicode('P') ) // duration must start with "P" - return sal_False; + return false; - rtl::OUString sDoubleStr; - sal_Bool bSuccess = sal_True; + ::rtl::OUString sDoubleStr; + sal_Bool bSuccess = true; sal_Bool bDone = sal_False; sal_Bool bTimePart = sal_False; sal_Bool bIsFraction = sal_False; - sal_Int32 nDays = 0; - sal_Int32 nHours = 0; - sal_Int32 nMins = 0; - sal_Int32 nSecs = 0; sal_Int32 nTemp = 0; while ( bSuccess && !bDone ) @@ -910,7 +905,7 @@ sal_Bool SvXMLUnitConverter::convertTime( double& fTime, else if ( sal_Unicode('0') <= c && sal_Unicode('9') >= c ) { if ( nTemp >= SAL_MAX_INT32 / 10 ) - bSuccess = sal_False; + bSuccess = false; else { if ( !bIsFraction ) @@ -928,17 +923,17 @@ sal_Bool SvXMLUnitConverter::convertTime( double& fTime, { if ( c == sal_Unicode('H') ) { - nHours = nTemp; + o_rHours = nTemp; nTemp = 0; } else if ( c == sal_Unicode('M') ) { - nMins = nTemp; + o_rMins = nTemp; nTemp = 0; } else if ( (c == sal_Unicode(',')) || (c == sal_Unicode('.')) ) { - nSecs = nTemp; + o_rSecs = nTemp; nTemp = 0; bIsFraction = sal_True; sDoubleStr = OUString(RTL_CONSTASCII_USTRINGPARAM("0.")); @@ -947,13 +942,13 @@ sal_Bool SvXMLUnitConverter::convertTime( double& fTime, { if ( !bIsFraction ) { - nSecs = nTemp; + o_rSecs = nTemp; nTemp = 0; sDoubleStr = OUString(RTL_CONSTASCII_USTRINGPARAM("0.0")); } } else - bSuccess = sal_False; // invalid character + bSuccess = false; // invalid character } else { @@ -961,7 +956,7 @@ sal_Bool SvXMLUnitConverter::convertTime( double& fTime, bTimePart = sal_True; else if ( c == sal_Unicode('D') ) { - nDays = nTemp; + o_rDays = nTemp; nTemp = 0; } else if ( c == sal_Unicode('Y') || c == sal_Unicode('M') ) @@ -969,14 +964,28 @@ sal_Bool SvXMLUnitConverter::convertTime( double& fTime, //! how many days is a year or month? DBG_ERROR("years or months in duration: not implemented"); - bSuccess = sal_False; + bSuccess = false; } else - bSuccess = sal_False; // invalid character + bSuccess = false; // invalid character } } if ( bSuccess ) + o_rFractionalSecs = sDoubleStr.toDouble(); + return bSuccess; +} + +sal_Bool SvXMLUnitConverter::convertTime( double& fTime, + const ::rtl::OUString& rString) +{ + sal_Int32 nDays = 0; + sal_Int32 nHours = 0; + sal_Int32 nMins = 0; + sal_Int32 nSecs = 0; + sal_Bool bIsNegativeDuration = sal_False; + double fFractionalSecs = 0.0; + if ( lcl_convertTime( rString, nDays, nHours, nMins, nSecs, bIsNegativeDuration, fFractionalSecs ) ) { if ( nDays ) nHours += nDays * 24; // add the days to the hours part @@ -985,12 +994,11 @@ sal_Bool SvXMLUnitConverter::convertTime( double& fTime, double fMin = nMins; double fSec = nSecs; double fSec100 = 0.0; - double fFraction = sDoubleStr.toDouble(); fTempTime = fHour / 24; fTempTime += fMin / (24 * 60); fTempTime += fSec / (24 * 60 * 60); fTempTime += fSec100 / (24 * 60 * 60 * 60); - fTempTime += fFraction / (24 * 60 * 60); + fTempTime += fFractionalSecs / (24 * 60 * 60); // negative duration? if ( bIsNegativeDuration ) @@ -999,8 +1007,9 @@ sal_Bool SvXMLUnitConverter::convertTime( double& fTime, } fTime = fTempTime; + return sal_True; } - return bSuccess; + return sal_False; } /** convert util::DateTime to ISO Time String */ @@ -1022,33 +1031,18 @@ void SvXMLUnitConverter::convertTime( ::rtl::OUStringBuffer& rBuffer, sal_Bool SvXMLUnitConverter::convertTime( ::com::sun::star::util::DateTime& rDateTime, const ::rtl::OUString& rString ) { - double fCalculatedTime = 0.0; - if( convertTime( fCalculatedTime, rString ) ) - { - // #101357# declare as volatile to prevent optimization - // (gcc 3.0.1 Linux) - volatile double fTempTime = fCalculatedTime; - fTempTime *= 24; - double fHoursValue = ::rtl::math::approxFloor (fTempTime); - fTempTime -= fHoursValue; - fTempTime *= 60; - double fMinsValue = ::rtl::math::approxFloor (fTempTime); - fTempTime -= fMinsValue; - fTempTime *= 60; - double fSecsValue = ::rtl::math::approxFloor (fTempTime); - fTempTime -= fSecsValue; - double f100SecsValue = 0.0; - - if( fTempTime > 0.00001 ) - f100SecsValue = fTempTime; - + sal_Int32 nDays = 0, nHours = 0, nMins = 0, nSecs = 0; + sal_Bool bIsNegativeDuration = sal_False; + double fFractionalSecs = 0.0; + if ( lcl_convertTime( rString, nDays, nHours, nMins, nSecs, bIsNegativeDuration, fFractionalSecs ) ) + { rDateTime.Year = 0; rDateTime.Month = 0; rDateTime.Day = 0; - rDateTime.Hours = static_cast < sal_uInt16 > ( fHoursValue ); - rDateTime.Minutes = static_cast < sal_uInt16 > ( fMinsValue ); - rDateTime.Seconds = static_cast < sal_uInt16 > ( fSecsValue ); - rDateTime.HundredthSeconds = static_cast < sal_uInt16 > ( f100SecsValue * 100.0 ); + rDateTime.Hours = static_cast < sal_uInt16 > ( nHours ); + rDateTime.Minutes = static_cast < sal_uInt16 > ( nMins ); + rDateTime.Seconds = static_cast < sal_uInt16 > ( nSecs ); + rDateTime.HundredthSeconds = static_cast < sal_uInt16 > ( fFractionalSecs * 100.0 ); return sal_True; } -- cgit From 99181c8c15e0aae7e1f434e895cfcfc2285a6166 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 16 Sep 2010 09:02:54 +0200 Subject: dba34a: silence GCC warning --- xmloff/source/forms/elementimport.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'xmloff/source') diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 3eb5be233f9a..ed11b57d9c54 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -698,6 +698,7 @@ namespace xmloff case OControlElement::GRID: pServiceName = "com.sun.star.form.component.GridControl"; break; case OControlElement::TIME: pServiceName = "com.sun.star.form.component.DateField"; break; case OControlElement::DATE: pServiceName = "com.sun.star.form.component.TimeField"; break; + default: break; } if ( pServiceName != NULL ) return ::rtl::OUString::createFromAscii( pServiceName ); -- cgit From 6631aae54e580f52e745ac2ccc07c06c385606bb Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 16 Sep 2010 09:27:49 +0200 Subject: dba34a: yet another GCC warning silenced --- xmloff/source/forms/elementexport.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index a4cbaa61edec..149965631b27 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -526,14 +526,14 @@ namespace xmloff // retrieve the values for all those properties PropertyValues aValues; - for ( PropertyDescriptionList::iterator prop = descriptions.begin(); - prop != descriptions.end(); - ++prop + for ( PropertyDescriptionList::iterator desc = descriptions.begin(); + desc != descriptions.end(); + ++desc ) { // TODO: XMultiPropertySet? - const Any propValue = m_xProps->getPropertyValue( (*prop)->propertyName ); - aValues[ (*prop)->propertyId ] = propValue; + const Any propValue = m_xProps->getPropertyValue( (*desc)->propertyName ); + aValues[ (*desc)->propertyId ] = propValue; } // let the handler translate into an XML attribute value -- cgit From ca9d33a5ba1fcf98990aa61ac3f42287e2d2fec5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 21 Sep 2010 17:05:14 +0200 Subject: dba34a: WaE --- xmloff/source/forms/propertyimport.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index 9d8e7be994f3..de57eadb69ae 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -363,19 +363,19 @@ bool OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const ::rtl implPushBackPropertyValue( aNewValue ); return true; } -#if OSL_DEBUG_LEVEL > 0 if (!token::IsXMLToken(_rLocalName, token::XML_TYPE)) // xlink:type is valid but ignored for { +#if OSL_DEBUG_LEVEL > 0 ::rtl::OString sMessage( "OPropertyImport::handleAttribute: Can't handle the following:\n" ); sMessage += ::rtl::OString( " Attribute name: " ); sMessage += ::rtl::OString( _rLocalName.getStr(), _rLocalName.getLength(), osl_getThreadTextEncoding() ); sMessage += ::rtl::OString( "\n value: " ); sMessage += ::rtl::OString( _rValue.getStr(), _rValue.getLength(), osl_getThreadTextEncoding() ); OSL_ENSURE( sal_False, sMessage.getStr() ); +#endif return false; } return true; -#endif } //===================================================================== -- cgit From 7acf233d5c2dbb3bf996a9893a84c030e9a9e4c5 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 23 Sep 2010 13:38:12 +0200 Subject: dba34a: #i114671# --- xmloff/source/chart/SchXMLTableContext.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index d3f0670f672d..bc1b50a908a2 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -704,6 +704,7 @@ private: public: SchXMLRangeSomewhereContext( SvXMLImport& rImport, + USHORT nPrefix, const ::rtl::OUString& rLocalName, ::rtl::OUString& rRangeString ); virtual ~SchXMLRangeSomewhereContext(); @@ -818,7 +819,7 @@ SvXMLImportContext* SchXMLTableCellContext::CreateChildContext( { //#i113950# previously the range was exported to attribute text:id, but that attribute does not allow arbitrary strings anymore //so we need to find an alternative to save that range info for copy/paste scenario ... -> use description at an empty group element for now - pContext = new SchXMLRangeSomewhereContext( GetImport(), rLocalName, maRangeId ); + pContext = new SchXMLRangeSomewhereContext( GetImport(), nPrefix, rLocalName, maRangeId ); } else { @@ -1188,9 +1189,10 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( //--------------------------------------------------------------------------------------------------- SchXMLRangeSomewhereContext::SchXMLRangeSomewhereContext( SvXMLImport& rImport, + USHORT nPrefix, const OUString& rLocalName, OUString& rRangeString ) : - SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ), + SvXMLImportContext( rImport, nPrefix, rLocalName ), mrRangeString( rRangeString ) { } -- cgit From 47c0ac79eea410b8b110e2bf5abfc2d86ef9164a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 24 Sep 2010 15:57:20 +0200 Subject: dba34a: separate the handling of generic property/attributes into a dedicated method, which can be called at appropriate time by derived classes (if desired, otherwise OElementImport will call it automatically) --- xmloff/source/forms/elementimport.cxx | 64 +++++++++++++++++++++-------------- xmloff/source/forms/elementimport.hxx | 29 +++++++++++----- 2 files changed, 59 insertions(+), 34 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index ed11b57d9c54..cdaa36d7a5a6 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -160,6 +160,7 @@ namespace xmloff ,m_rEventManager(_rEventManager) ,m_pStyleElement( NULL ) ,m_xParentContainer(_rxParentContainer) + ,m_bImplicitGenericAttributeHandling( true ) { OSL_ENSURE(m_xParentContainer.is(), "OElementImport::OElementImport: invalid parent container!"); } @@ -545,30 +546,8 @@ namespace xmloff } //--------------------------------------------------------------------- - bool OElementImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + bool OElementImport::tryGenericAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ) { - if ( token::IsXMLToken( _rLocalName, token::XML_CONTROL_IMPLEMENTATION ) ) - // ignore this, it has already been handled in OElementImport::StartElement - return true; - - if ( token::IsXMLToken( _rLocalName, token::XML_NAME ) ) - { - if ( !m_sName.getLength() ) - // remember the name for later use in EndElement - m_sName = _rValue; - return true; - } - - // maybe it's the style attribute? - if ( token::IsXMLToken( _rLocalName, token::XML_TEXT_STYLE_NAME ) ) - { - const SvXMLStyleContext* pStyleContext = m_rContext.getStyleElement( _rValue ); - OSL_ENSURE( pStyleContext, "OElementImport::handleAttribute: do not know the style!" ); - // remember the element for later usage. - m_pStyleElement = PTR_CAST( XMLTextStyleContext, pStyleContext ); - return true; - } - // the generic approach (which I hope all props will be migrated to, on the medium term): property handlers const AttributeDescription attribute( metadata::getAttributeDescription( _nNamespaceKey, _rLocalName ) ); if ( attribute.attributeToken != XML_TOKEN_INVALID ) @@ -577,7 +556,7 @@ namespace xmloff metadata::getPropertyGroupList( attribute, propertyGroups ); const PropertyGroups::const_iterator pos = impl_matchPropertyGroup( propertyGroups ); if ( pos == propertyGroups.end() ) - return OPropertyImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); + return false; do { @@ -611,6 +590,37 @@ namespace xmloff // handled return true; } + return false; + } + + //--------------------------------------------------------------------- + bool OElementImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) + { + if ( token::IsXMLToken( _rLocalName, token::XML_CONTROL_IMPLEMENTATION ) ) + // ignore this, it has already been handled in OElementImport::StartElement + return true; + + if ( token::IsXMLToken( _rLocalName, token::XML_NAME ) ) + { + if ( !m_sName.getLength() ) + // remember the name for later use in EndElement + m_sName = _rValue; + return true; + } + + // maybe it's the style attribute? + if ( token::IsXMLToken( _rLocalName, token::XML_TEXT_STYLE_NAME ) ) + { + const SvXMLStyleContext* pStyleContext = m_rContext.getStyleElement( _rValue ); + OSL_ENSURE( pStyleContext, "OElementImport::handleAttribute: do not know the style!" ); + // remember the element for later usage. + m_pStyleElement = PTR_CAST( XMLTextStyleContext, pStyleContext ); + return true; + } + + if ( m_bImplicitGenericAttributeHandling ) + if ( tryGenericAttribute( _nNamespaceKey, _rLocalName, _rValue ) ) + return true; // let the base class handle it return OPropertyImport::handleAttribute(_nNamespaceKey, _rLocalName, _rValue); @@ -664,6 +674,7 @@ namespace xmloff :OElementImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer) ,m_eElementType(OControlElement::UNKNOWN) { + disableImplicitGenericAttributeHandling(); } //--------------------------------------------------------------------- @@ -672,6 +683,7 @@ namespace xmloff :OElementImport(_rImport, _rEventManager, _nPrefix, _rName, _rxParentContainer) ,m_eElementType(_eType) { + disableImplicitGenericAttributeHandling(); } //--------------------------------------------------------------------- @@ -763,7 +775,7 @@ namespace xmloff return true; } - if ( OElementImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ) ) + if ( OElementImport::tryGenericAttribute( _nNamespaceKey, _rLocalName, _rValue ) ) return true; static const sal_Char* pValueAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_VALUE); @@ -807,7 +819,7 @@ namespace xmloff return true; } - return false; + return OElementImport::handleAttribute( _nNamespaceKey, _rLocalName, _rValue ); } //--------------------------------------------------------------------- diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx index f48f031854de..0db43d7d58a7 100644 --- a/xmloff/source/forms/elementimport.hxx +++ b/xmloff/source/forms/elementimport.hxx @@ -85,22 +85,25 @@ namespace xmloff ,public OStackedLogging { protected: - ::rtl::OUString m_sServiceName; // the service name as extracted from the service-name attribute - ::rtl::OUString m_sName; // the name of the object (redundant, already contained in the base class' array) + ::rtl::OUString m_sServiceName; // the service name as extracted from the service-name attribute + ::rtl::OUString m_sName; // the name of the object (redundant, already contained in the base class' array) OFormLayerXMLImport_Impl& m_rFormImport; // the form import context - IEventAttacherManager& m_rEventManager; // the event attacher manager + IEventAttacherManager& m_rEventManager; // the event attacher manager const XMLTextStyleContext* m_pStyleElement; // the XML element which describes the style we encountered // while reading our element + /// the parent container to insert the new element into ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > - m_xParentContainer; - // the parent container to insert the new element into + m_xParentContainer; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > - m_xInfo; + /// the element we're creating. Valid after StartElement ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > - m_xElement; // the element we're creating. Valid after StartElement + m_xElement; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > + m_xInfo; + + bool m_bImplicitGenericAttributeHandling; public: /** ctor @@ -160,6 +163,16 @@ namespace xmloff */ void simulateDefaultedAttribute(const sal_Char* _pAttributeName, const ::rtl::OUString& _rPropertyName, const sal_Char* _pAttributeDefault); + /** to be called from within handleAttribute, checks whether the given attribute is covered by our generic + attribute handler mechanisms + */ + bool tryGenericAttribute( sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue ); + + /** controls whether |handleAttribute| implicitly calls |tryGenericAttribute|, or whether the derived class + must do this explicitly at a suitable place in its own |handleAttribute| + */ + void disableImplicitGenericAttributeHandling() { m_bImplicitGenericAttributeHandling = false; } + private: ::rtl::OUString implGetDefaultName() const; void implImportGenericProperties(); -- cgit From df76cd75dee1e539533b3c2b00b5d0330062fe88 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 24 Sep 2010 21:27:18 +0200 Subject: dba34a: OElementImport::EndElement: don't assert m_aValues being empty - this is legitimate, especially for grid controls --- xmloff/source/forms/elementimport.cxx | 85 +++++++++++++++++++---------------- xmloff/source/forms/elementimport.hxx | 3 +- 2 files changed, 49 insertions(+), 39 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index cdaa36d7a5a6..5cc9a8203054 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -225,26 +225,61 @@ namespace xmloff if (!m_xElement.is()) return; + // apply the non-generic properties + implApplySpecificProperties(); + + // set the generic properties + implApplyGenericProperties(); + + // set the style properties + if ( m_pStyleElement && m_xElement.is() ) + { + Reference< XPropertySet > xPropTranslation = + new OGridColumnPropertyTranslator( Reference< XMultiPropertySet >( m_xElement, UNO_QUERY ) ); + const_cast< XMLTextStyleContext* >( m_pStyleElement )->FillPropertySet( xPropTranslation ); + + const ::rtl::OUString sNumberStyleName = const_cast< XMLTextStyleContext* >( m_pStyleElement )->GetDataStyleName( ); + if ( sNumberStyleName.getLength() ) + // the style also has a number (sub) style + m_rContext.applyControlNumberStyle( m_xElement, sNumberStyleName ); + } + + // insert the element into the parent container + if (!m_sName.getLength()) + { + OSL_ENSURE(sal_False, "OElementImport::EndElement: did not find a name attribute!"); + m_sName = implGetDefaultName(); + } + + m_xParentContainer->insertByName(m_sName, makeAny(m_xElement)); + LEAVE_LOG_CONTEXT( ); + } + + //--------------------------------------------------------------------- + void OElementImport::implApplySpecificProperties() + { + if ( m_aValues.empty() ) + return; + // set all the properties we collected #if OSL_DEBUG_LEVEL > 0 // check if the object has all the properties // (We do this in the non-pro version only. Doing it all the time would be much to expensive) if ( m_xInfo.is() ) { - PropertyValueArray::iterator aEnd = m_aValues.end(); + PropertyValueArray::const_iterator aEnd = m_aValues.end(); for ( PropertyValueArray::iterator aCheck = m_aValues.begin(); aCheck != aEnd; ++aCheck ) { OSL_ENSURE(m_xInfo->hasPropertyByName(aCheck->Name), - ::rtl::OString("OElementImport::EndElement: read a property (") + ::rtl::OString("OElementImport::implApplySpecificProperties: read a property (") += ::rtl::OString(aCheck->Name.getStr(), aCheck->Name.getLength(), RTL_TEXTENCODING_ASCII_US) += ::rtl::OString(") which does not exist on the element!")); } } #endif - OSL_ENSURE(!m_aValues.empty(), "OElementImport::EndElement: no properties read!"); // set the properties const Reference< XMultiPropertySet > xMultiProps(m_xElement, UNO_QUERY); @@ -281,7 +316,7 @@ namespace xmloff } catch(Exception&) { - OSL_ENSURE(sal_False, "OElementImport::EndElement: could not set the properties (using the XMultiPropertySet)!"); + OSL_ENSURE(sal_False, "OElementImport::implApplySpecificProperties: could not set the properties (using the XMultiPropertySet)!"); } } @@ -302,42 +337,16 @@ namespace xmloff catch(Exception&) { OSL_ENSURE(sal_False, - ::rtl::OString("OElementImport::EndElement: could not set the property \"") + ::rtl::OString("OElementImport::implApplySpecificProperties: could not set the property \"") += ::rtl::OString(aPropValues->Name.getStr(), aPropValues->Name.getLength(), RTL_TEXTENCODING_ASCII_US) += ::rtl::OString("\"!")); } } } - - // set the generic properties - implImportGenericProperties(); - - // set the style properties - if ( m_pStyleElement && m_xElement.is() ) - { - Reference< XPropertySet > xPropTranslation = - new OGridColumnPropertyTranslator( Reference< XMultiPropertySet >( m_xElement, UNO_QUERY ) ); - const_cast< XMLTextStyleContext* >( m_pStyleElement )->FillPropertySet( xPropTranslation ); - - const ::rtl::OUString sNumberStyleName = const_cast< XMLTextStyleContext* >( m_pStyleElement )->GetDataStyleName( ); - if ( sNumberStyleName.getLength() ) - // the style also has a number (sub) style - m_rContext.applyControlNumberStyle( m_xElement, sNumberStyleName ); - } - - // insert the element into the parent container - if (!m_sName.getLength()) - { - OSL_ENSURE(sal_False, "OElementImport::EndElement: did not find a name attribute!"); - m_sName = implGetDefaultName(); - } - - m_xParentContainer->insertByName(m_sName, makeAny(m_xElement)); - LEAVE_LOG_CONTEXT( ); } //--------------------------------------------------------------------- - void OElementImport::implImportGenericProperties() + void OElementImport::implApplyGenericProperties() { if ( m_aGenericValues.empty() ) return; @@ -362,7 +371,7 @@ namespace xmloff if ( !xDynamicProperties.is() ) { #if OSL_DEBUG_LEVEL > 0 - ::rtl::OString aMessage( "OElementImport::implImportGenericProperties: encountered an unknown property (" ); + ::rtl::OString aMessage( "OElementImport::implApplyGenericProperties: encountered an unknown property (" ); aMessage += ::rtl::OUStringToOString( aPropValues->Name, RTL_TEXTENCODING_ASCII_US ); aMessage += "), but component is no PropertyBag!"; OSL_ENSURE( false, aMessage.getStr() ); @@ -401,18 +410,18 @@ namespace xmloff if ( bPropIsSequence != bValueIsSequence ) { - OSL_ENSURE( false, "OElementImport::implImportGenericProperties: either both value and property should be a sequence, or none of them!" ); + OSL_ENSURE( false, "OElementImport::implApplyGenericProperties: either both value and property should be a sequence, or none of them!" ); continue; } if ( bValueIsSequence ) { OSL_ENSURE( eValueTypeClass == TypeClass_ANY, - "OElementImport::implImportGenericProperties: only ANYs should have been imported as generic list property!" ); + "OElementImport::implApplyGenericProperties: only ANYs should have been imported as generic list property!" ); // (OPropertyImport should produce only Sequencer< Any >, since it cannot know the real type OSL_ENSURE( ePropTypeClass == TypeClass_SHORT, - "OElementImport::implImportGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" ); + "OElementImport::implApplyGenericProperties: conversion to sequences other than 'sequence< short >' not implemented, yet!" ); Sequence< Any > aXMLValueList; aPropValues->Value >>= aXMLValueList; @@ -455,13 +464,13 @@ namespace xmloff aPropValues->Value <<= static_cast< sal_Int64 >( nVal ); break; default: - OSL_ENSURE( false, "OElementImport::implImportGenericProperties: unsupported value type!" ); + OSL_ENSURE( false, "OElementImport::implApplyGenericProperties: unsupported value type!" ); break; } } break; default: - OSL_ENSURE( false, "OElementImport::implImportGenericProperties: non-double values not supported!" ); + OSL_ENSURE( false, "OElementImport::implApplyGenericProperties: non-double values not supported!" ); break; } } diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx index 0db43d7d58a7..3b604c752595 100644 --- a/xmloff/source/forms/elementimport.hxx +++ b/xmloff/source/forms/elementimport.hxx @@ -175,7 +175,8 @@ namespace xmloff private: ::rtl::OUString implGetDefaultName() const; - void implImportGenericProperties(); + void implApplyGenericProperties(); + void implApplySpecificProperties(); /** sets the style properties which have been read for the element (if any) */ -- cgit From f23b151efd588900c91bf36fd7ae211989c9fc60 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 28 Sep 2010 10:17:38 +0200 Subject: dba34a: removed assertion from impl_matchPropertyGroup - it is allowed that no group matches, as long as we did not migrate all properties to this new mechanism --- xmloff/source/forms/elementimport.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'xmloff/source') diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 5cc9a8203054..1f1c28d579cf 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -550,7 +550,6 @@ namespace xmloff return group; } - OSL_ENSURE( false, "OElementImport::impl_matchPropertyGroup: no group matched!" ); return i_propertyGroups.end(); } -- cgit From d82a205b967311ff8b2fd3a49eeefa5a9d2839cd Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 4 Oct 2010 16:58:48 +0200 Subject: sw34bf01: XMLTextMarkImportContext::EndElement(): catch exception --- xmloff/source/text/XMLTextMarkImportContext.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'xmloff/source') diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index 00cdce37f4d5..922777808734 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -287,7 +287,12 @@ void XMLTextMarkImportContext::EndElement() Reference xInsertionCursor = m_rHelper.GetText()->createTextCursorByRange( xEndRange); + try { xInsertionCursor->gotoRange(xStartRange, sal_True); + } catch (uno::Exception&) { + OSL_ENSURE(false, + "cannot go to end position of bookmark"); + } //DBG_ASSERT(! xInsertionCursor->isCollapsed(), // "we want no point mark"); -- cgit From 98a64d26435b2e9a40e158f17f22641423e10183 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 1 Nov 2010 11:34:47 +0100 Subject: dba34a: s_propertyMetaData should not be a global static, as it uses other global statics for initialization, which makes proper initialization dependent on module-load-order --- xmloff/source/forms/elementimport.cxx | 8 ++++++ xmloff/source/forms/property_meta_data.cxx | 40 +++++++++++++++++------------- 2 files changed, 31 insertions(+), 17 deletions(-) (limited to 'xmloff/source') diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 1f1c28d579cf..eb6dd0965e76 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -880,6 +880,7 @@ namespace xmloff ++aValueProps ) { + bool bSuccess = false; switch (aValueProps->Handle) { case PROPID_VALUE: @@ -889,6 +890,7 @@ namespace xmloff if (!bRetrievedValues) { getValuePropertyNames(m_eElementType, nClassId, pCurrentValueProperty, pValueProperty); + ENSURE_OR_BREAK( pCurrentValueProperty && pValueProperty, "OControlImport::StartElement: illegal value property names!" ); bRetrievedValues = sal_True; } OSL_ENSURE((PROPID_VALUE != aValueProps->Handle) || pValueProperty, @@ -901,6 +903,7 @@ namespace xmloff aValueProps->Name = ::rtl::OUString::createFromAscii(pValueProperty); else aValueProps->Name = ::rtl::OUString::createFromAscii(pCurrentValueProperty); + bSuccess = true; } break; case PROPID_MIN_VALUE: @@ -910,6 +913,7 @@ namespace xmloff if (!bRetrievedValueLimits) { getValueLimitPropertyNames(nClassId, pMinValueProperty, pMaxValueProperty); + ENSURE_OR_BREAK( pMinValueProperty && pMaxValueProperty, "OControlImport::StartElement: illegal value limit property names!" ); bRetrievedValueLimits = sal_True; } OSL_ENSURE((PROPID_MIN_VALUE != aValueProps->Handle) || pMinValueProperty, @@ -922,10 +926,14 @@ namespace xmloff aValueProps->Name = ::rtl::OUString::createFromAscii(pMinValueProperty); else aValueProps->Name = ::rtl::OUString::createFromAscii(pMaxValueProperty); + bSuccess = true; } break; } + if ( !bSuccess ) + continue; + // translate the value implTranslateValueProperty(m_xInfo, *aValueProps); // add the property to the base class' array diff --git a/xmloff/source/forms/property_meta_data.cxx b/xmloff/source/forms/property_meta_data.cxx index a907112dbe58..7f058d14b9b7 100755 --- a/xmloff/source/forms/property_meta_data.cxx +++ b/xmloff/source/forms/property_meta_data.cxx @@ -51,19 +51,26 @@ namespace xmloff { namespace metadata //= property meta data //================================================================================================================== //------------------------------------------------------------------------------------------------------------------ - static const PropertyDescription s_propertyMetaData[] = + namespace { - FORM_SINGLE_PROPERTY( DATE_MIN, XML_MIN_VALUE ), - FORM_SINGLE_PROPERTY( DATE_MAX, XML_MAX_VALUE ), - FORM_SINGLE_PROPERTY( DEFAULT_DATE, XML_VALUE ), - FORM_SINGLE_PROPERTY( DATE, XML_CURRENT_VALUE ), - FORM_SINGLE_PROPERTY( TIME_MIN, XML_MIN_VALUE ), - FORM_SINGLE_PROPERTY( TIME_MAX, XML_MAX_VALUE ), - FORM_SINGLE_PROPERTY( DEFAULT_TIME, XML_VALUE ), - FORM_SINGLE_PROPERTY( TIME, XML_CURRENT_VALUE ), + const PropertyDescription* lcl_getPropertyMetaData() + { + static const PropertyDescription s_propertyMetaData[] = + { + FORM_SINGLE_PROPERTY( DATE_MIN, XML_MIN_VALUE ), + FORM_SINGLE_PROPERTY( DATE_MAX, XML_MAX_VALUE ), + FORM_SINGLE_PROPERTY( DEFAULT_DATE, XML_VALUE ), + FORM_SINGLE_PROPERTY( DATE, XML_CURRENT_VALUE ), + FORM_SINGLE_PROPERTY( TIME_MIN, XML_MIN_VALUE ), + FORM_SINGLE_PROPERTY( TIME_MAX, XML_MAX_VALUE ), + FORM_SINGLE_PROPERTY( DEFAULT_TIME, XML_VALUE ), + FORM_SINGLE_PROPERTY( TIME, XML_CURRENT_VALUE ), - PropertyDescription() - }; + PropertyDescription() + }; + return s_propertyMetaData; + } + } //------------------------------------------------------------------------------------------------------------------ namespace @@ -85,7 +92,7 @@ namespace xmloff { namespace metadata static DescriptionsByName s_propertyDescriptionsByName; if ( s_propertyDescriptionsByName.empty() ) { - const PropertyDescription* desc = s_propertyMetaData; + const PropertyDescription* desc = lcl_getPropertyMetaData(); while ( desc->propertyName.getLength() != 0 ) { s_propertyDescriptionsByName[ desc->propertyName ] = desc; @@ -105,7 +112,7 @@ namespace xmloff { namespace metadata static IndexedPropertyGroups s_indexedPropertyGroups; if ( s_indexedPropertyGroups.empty() ) { - const PropertyDescription* desc = s_propertyMetaData; + const PropertyDescription* desc = lcl_getPropertyMetaData(); while ( desc->propertyName.getLength() != 0 ) { if ( desc->propertyGroup != NO_GROUP ) @@ -126,7 +133,7 @@ namespace xmloff { namespace metadata static ReverseTokenLookup s_reverseTokenLookup; if ( s_reverseTokenLookup.empty() ) { - const PropertyDescription* desc = s_propertyMetaData; + const PropertyDescription* desc = lcl_getPropertyMetaData(); while ( desc->propertyName.getLength() != 0 ) { s_reverseTokenLookup[ token::GetXMLToken( desc->attribute.attributeToken ) ] = desc->attribute.attributeToken; @@ -155,7 +162,7 @@ namespace xmloff { namespace metadata static AttributeGroups s_attributeGroups; if ( s_attributeGroups.empty() ) { - const PropertyDescription* desc = s_propertyMetaData; + const PropertyDescription* desc = lcl_getPropertyMetaData(); while ( desc->propertyName.getLength() != 0 ) { if ( desc->propertyGroup != NO_GROUP ) @@ -176,7 +183,7 @@ namespace xmloff { namespace metadata static AttributesWithoutGroup s_attributesWithoutGroup; if ( s_attributesWithoutGroup.empty() ) { - const PropertyDescription* desc = s_propertyMetaData; + const PropertyDescription* desc = lcl_getPropertyMetaData(); while ( desc->propertyName.getLength() != 0 ) { if ( desc->propertyGroup == NO_GROUP ) @@ -248,7 +255,6 @@ namespace xmloff { namespace metadata AttributeDescription getAttributeDescription( const sal_uInt16 i_namespacePrefix, const ::rtl::OUString& i_attributeName ) { AttributeDescription attribute; - const ReverseTokenLookup& rTokenLookup( getReverseTokenLookup() ); const ReverseTokenLookup::const_iterator pos = rTokenLookup.find( i_attributeName ); if ( pos != rTokenLookup.end() ) -- cgit From 750cd2ac9658ccccf379f2d20f2990bbf82e1d64 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Wed, 10 Nov 2010 14:08:20 +0100 Subject: sw33bf12: #i115492# method - ignore svg:d attribute for text documents from OOo version before OOo 3.3 --- xmloff/source/draw/ximpshap.cxx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'xmloff/source') diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index b073e1e28d40..a26806ce6c24 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -1926,7 +1926,35 @@ void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XA SetLayer(); if ( maPath.hasValue() ) - xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ), maPath ); + { + // --> OD #i115492# + // Ignore svg:d attribute for text documents created by OpenOffice.org + // versions before OOo 3.3, because these OOo versions are storing + // svg:d values not using the correct unit. + bool bApplySVGD( true ); + if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() ) + { + sal_Int32 nUPD( 0 ); + sal_Int32 nBuild( 0 ); + const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); + if ( GetImport().IsTextDocInOOoFileFormat() || + ( bBuildIdFound && + ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0 + ( nUPD == 680 ) || // OOo 2.x + ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1 + ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1 + ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1 + { + bApplySVGD = false; + } + } + + if ( bApplySVGD ) + { + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ), maPath ); + } + // <-- + } SdXMLShapeContext::StartElement(xAttrList); } -- cgit