summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 15:22:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 17:14:14 +0100
commit489bce598626390d9c0aa5e5b8514e26070add61 (patch)
tree170ec95dcb393dbe4f7178bc08e6d96b6b76954b /filter
parentf19599c929ac6ae2708b19b9eff62ff70b44ee75 (diff)
loplugin:flatten in filter..framework
Change-Id: I15a577b3c6da03001bbbf2c2b43b29b41c4007c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127234 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/escherex.cxx102
-rw-r--r--filter/source/msfilter/msdffimp.cxx73
-rw-r--r--filter/source/msfilter/rtfutil.cxx82
-rw-r--r--filter/source/svg/svgexport.cxx60
-rw-r--r--filter/source/svg/svgfilter.cxx45
-rw-r--r--filter/source/svg/svgwriter.cxx422
6 files changed, 388 insertions, 396 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index c85c51e41c95..b7ffd449cb22 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -1997,47 +1997,45 @@ bool EscherPropertyContainer::CreatePolygonProperties(
}
}
- if(0 != nTotalPoints && aSegments.size() >= 6 && aVertices.size() >= 6)
- {
- // Little endian
- aVertices[0] = static_cast<sal_uInt8>(nTotalPoints);
- aVertices[1] = static_cast<sal_uInt8>(nTotalPoints >> 8);
- aVertices[2] = static_cast<sal_uInt8>(nTotalPoints);
- aVertices[3] = static_cast<sal_uInt8>(nTotalPoints >> 8);
-
- aSegments.push_back(static_cast<sal_uInt8>(0));
- aSegments.push_back(static_cast<sal_uInt8>(0x80));
-
- const sal_uInt32 nSegmentBufSize(aSegments.size() - 6);
- aSegments[0] = static_cast<sal_uInt8>(nSegmentBufSize >> 1);
- aSegments[1] = static_cast<sal_uInt8>(nSegmentBufSize >> 9);
- aSegments[2] = static_cast<sal_uInt8>(nSegmentBufSize >> 1);
- aSegments[3] = static_cast<sal_uInt8>(nSegmentBufSize >> 9);
-
- AddOpt(
- ESCHER_Prop_geoRight,
- rGeoRect.Width);
- AddOpt(
- ESCHER_Prop_geoBottom,
- rGeoRect.Height);
- AddOpt(
- ESCHER_Prop_shapePath,
- ESCHER_ShapeComplex);
- AddOpt(
- ESCHER_Prop_pVertices,
- true,
- aVertices.size() - 6,
- aVertices);
- AddOpt(
- ESCHER_Prop_pSegmentInfo,
- true,
- aSegments.size(),
- aSegments);
+ if(0 == nTotalPoints || aSegments.size() < 6 || aVertices.size() < 6)
+ return false;
- return true;
- }
+ // Little endian
+ aVertices[0] = static_cast<sal_uInt8>(nTotalPoints);
+ aVertices[1] = static_cast<sal_uInt8>(nTotalPoints >> 8);
+ aVertices[2] = static_cast<sal_uInt8>(nTotalPoints);
+ aVertices[3] = static_cast<sal_uInt8>(nTotalPoints >> 8);
+
+ aSegments.push_back(static_cast<sal_uInt8>(0));
+ aSegments.push_back(static_cast<sal_uInt8>(0x80));
+
+ const sal_uInt32 nSegmentBufSize(aSegments.size() - 6);
+ aSegments[0] = static_cast<sal_uInt8>(nSegmentBufSize >> 1);
+ aSegments[1] = static_cast<sal_uInt8>(nSegmentBufSize >> 9);
+ aSegments[2] = static_cast<sal_uInt8>(nSegmentBufSize >> 1);
+ aSegments[3] = static_cast<sal_uInt8>(nSegmentBufSize >> 9);
+
+ AddOpt(
+ ESCHER_Prop_geoRight,
+ rGeoRect.Width);
+ AddOpt(
+ ESCHER_Prop_geoBottom,
+ rGeoRect.Height);
+ AddOpt(
+ ESCHER_Prop_shapePath,
+ ESCHER_ShapeComplex);
+ AddOpt(
+ ESCHER_Prop_pVertices,
+ true,
+ aVertices.size() - 6,
+ aVertices);
+ AddOpt(
+ ESCHER_Prop_pSegmentInfo,
+ true,
+ aSegments.size(),
+ aSegments);
- return false;
+ return true;
}
@@ -3751,22 +3749,22 @@ bool EscherPropertyContainer::CreateBlipPropertiesforOLEControl(const uno::Refer
const uno::Reference<drawing::XShape> & rXShape)
{
SdrObject* pShape = SdrObject::getSdrObjectFromXShape(rXShape);
- if ( pShape )
- {
- const Graphic aGraphic(SdrExchangeView::GetObjGraphic(*pShape));
- const GraphicObject aGraphicObject(aGraphic);
+ if ( !pShape )
+ return false;
- if (!aGraphicObject.GetUniqueID().isEmpty())
+ const Graphic aGraphic(SdrExchangeView::GetObjGraphic(*pShape));
+ const GraphicObject aGraphicObject(aGraphic);
+
+ if (!aGraphicObject.GetUniqueID().isEmpty())
+ {
+ if ( pGraphicProvider && pPicOutStrm && pShapeBoundRect )
{
- if ( pGraphicProvider && pPicOutStrm && pShapeBoundRect )
+ sal_uInt32 nBlibId = pGraphicProvider->GetBlibID(*pPicOutStrm, aGraphicObject);
+ if ( nBlibId )
{
- sal_uInt32 nBlibId = pGraphicProvider->GetBlibID(*pPicOutStrm, aGraphicObject);
- if ( nBlibId )
- {
- AddOpt( ESCHER_Prop_pib, nBlibId, true );
- ImplCreateGraphicAttributes( rXPropSet, nBlibId, false );
- return true;
- }
+ AddOpt( ESCHER_Prop_pib, nBlibId, true );
+ ImplCreateGraphicAttributes( rXPropSet, nBlibId, false );
+ return true;
}
}
}
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 44c9f10402e3..823868ae2dfe 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -422,23 +422,23 @@ SvStream& ReadSvxMSDffSolverContainer( SvStream& rIn, SvxMSDffSolverContainer& r
{
DffRecordHeader aHd;
bool bOk = ReadDffRecordHeader( rIn, aHd );
- if (bOk && aHd.nRecType == DFF_msofbtSolverContainer)
+ if (!bOk || aHd.nRecType != DFF_msofbtSolverContainer)
+ return rIn;
+
+ DffRecordHeader aCRule;
+ auto nEndPos = DffPropSet::SanitizeEndPos(rIn, aHd.GetRecEndFilePos());
+ while ( rIn.good() && ( rIn.Tell() < nEndPos ) )
{
- DffRecordHeader aCRule;
- auto nEndPos = DffPropSet::SanitizeEndPos(rIn, aHd.GetRecEndFilePos());
- while ( rIn.good() && ( rIn.Tell() < nEndPos ) )
+ if (!ReadDffRecordHeader(rIn, aCRule))
+ break;
+ if ( aCRule.nRecType == DFF_msofbtConnectorRule )
{
- if (!ReadDffRecordHeader(rIn, aCRule))
- break;
- if ( aCRule.nRecType == DFF_msofbtConnectorRule )
- {
- std::unique_ptr<SvxMSDffConnectorRule> pRule(new SvxMSDffConnectorRule);
- rIn >> *pRule;
- rContainer.aCList.push_back( std::move(pRule) );
- }
- if (!aCRule.SeekToEndOfRecord(rIn))
- break;
+ std::unique_ptr<SvxMSDffConnectorRule> pRule(new SvxMSDffConnectorRule);
+ rIn >> *pRule;
+ rContainer.aCList.push_back( std::move(pRule) );
}
+ if (!aCRule.SeekToEndOfRecord(rIn))
+ break;
}
return rIn;
}
@@ -6312,31 +6312,30 @@ bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*& rpShape,
SvxMSDffShapeInfos_ById::const_iterator const it =
m_xShapeInfosById->find(pTmpRec);
- if (it != m_xShapeInfosById->end())
- {
- // Possibly delete old error flag.
- if( rStCtrl.GetError() )
- rStCtrl.ResetError();
- // store FilePos of the stream(s)
- sal_uInt64 nOldPosCtrl = rStCtrl.Tell();
- sal_uInt64 nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
- // jump to the shape in the control stream
- sal_uInt64 const nFilePos((*it)->nFilePos);
- bool bSeeked = (nFilePos == rStCtrl.Seek(nFilePos));
+ if (it == m_xShapeInfosById->end())
+ return false;
- // if it failed, reset error statusF
- if (!bSeeked || rStCtrl.GetError())
- rStCtrl.ResetError();
- else
- rpShape = ImportObj( rStCtrl, rData, rData.aParentRect, rData.aParentRect, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
+ // Possibly delete old error flag.
+ if( rStCtrl.GetError() )
+ rStCtrl.ResetError();
+ // store FilePos of the stream(s)
+ sal_uInt64 nOldPosCtrl = rStCtrl.Tell();
+ sal_uInt64 nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
+ // jump to the shape in the control stream
+ sal_uInt64 const nFilePos((*it)->nFilePos);
+ bool bSeeked = (nFilePos == rStCtrl.Seek(nFilePos));
- // restore old FilePos of the stream(s)
- rStCtrl.Seek( nOldPosCtrl );
- if( &rStCtrl != pStData && pStData )
- pStData->Seek( nOldPosData );
- return ( nullptr != rpShape );
- }
- return false;
+ // if it failed, reset error statusF
+ if (!bSeeked || rStCtrl.GetError())
+ rStCtrl.ResetError();
+ else
+ rpShape = ImportObj( rStCtrl, rData, rData.aParentRect, rData.aParentRect, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
+
+ // restore old FilePos of the stream(s)
+ rStCtrl.Seek( nOldPosCtrl );
+ if( &rStCtrl != pStData && pStData )
+ pStData->Seek( nOldPosData );
+ return ( nullptr != rpShape );
}
diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx
index ac2dcdec8a10..e20a146c42d6 100644
--- a/filter/source/msfilter/rtfutil.cxx
+++ b/filter/source/msfilter/rtfutil.cxx
@@ -333,50 +333,50 @@ bool ExtractOLE2FromObjdata(const OString& rObjdata, SvStream& rOle2)
}
// Skip ObjectHeader, see [MS-OLEDS] 2.2.4.
- if (aStream.Tell())
+ if (!aStream.Tell())
+ return true;
+
+ aStream.Seek(0);
+ sal_uInt32 nData;
+ aStream.ReadUInt32(nData); // OLEVersion
+ aStream.ReadUInt32(nData); // FormatID
+ aStream.ReadUInt32(nData); // ClassName
+ OString aClassName;
+ if (nData)
{
- aStream.Seek(0);
- sal_uInt32 nData;
- aStream.ReadUInt32(nData); // OLEVersion
- aStream.ReadUInt32(nData); // FormatID
- aStream.ReadUInt32(nData); // ClassName
- OString aClassName;
- if (nData)
- {
- // -1 because it is null-terminated.
- aClassName = read_uInt8s_ToOString(aStream, nData - 1);
- // Skip null-termination.
- aStream.SeekRel(1);
- }
- aStream.ReadUInt32(nData); // TopicName
- aStream.SeekRel(nData);
- aStream.ReadUInt32(nData); // ItemName
- aStream.SeekRel(nData);
- aStream.ReadUInt32(nData); // NativeDataSize
+ // -1 because it is null-terminated.
+ aClassName = read_uInt8s_ToOString(aStream, nData - 1);
+ // Skip null-termination.
+ aStream.SeekRel(1);
+ }
+ aStream.ReadUInt32(nData); // TopicName
+ aStream.SeekRel(nData);
+ aStream.ReadUInt32(nData); // ItemName
+ aStream.SeekRel(nData);
+ aStream.ReadUInt32(nData); // NativeDataSize
- if (nData)
- {
- sal_uInt64 nPos = aStream.Tell();
- sal_uInt8 aSignature[8];
- aStream.ReadBytes(aSignature, SAL_N_ELEMENTS(aSignature));
- aStream.Seek(nPos);
- const sal_uInt8 aOle2Signature[8] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 };
- // Don't use Storage::IsStorageFile() here, that would seek to the start of the stream,
- // where the magic will always mismatch.
- if (std::memcmp(aSignature, aOle2Signature, SAL_N_ELEMENTS(aSignature)) == 0)
- {
- // NativeData
- rOle2.WriteStream(aStream, nData);
- }
- else
- {
- SvMemoryStream aStorage;
- WrapOle1InOle2(aStream, nData, aStorage, aClassName);
- rOle2.WriteStream(aStorage);
- }
- rOle2.Seek(0);
- }
+ if (!nData)
+ return true;
+
+ sal_uInt64 nPos = aStream.Tell();
+ sal_uInt8 aSignature[8];
+ aStream.ReadBytes(aSignature, SAL_N_ELEMENTS(aSignature));
+ aStream.Seek(nPos);
+ const sal_uInt8 aOle2Signature[8] = { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 };
+ // Don't use Storage::IsStorageFile() here, that would seek to the start of the stream,
+ // where the magic will always mismatch.
+ if (std::memcmp(aSignature, aOle2Signature, SAL_N_ELEMENTS(aSignature)) == 0)
+ {
+ // NativeData
+ rOle2.WriteStream(aStream, nData);
}
+ else
+ {
+ SvMemoryStream aStorage;
+ WrapOle1InOle2(aStream, nData, aStorage, aClassName);
+ rOle2.WriteStream(aStorage);
+ }
+ rOle2.Seek(0);
return true;
}
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index a9d02b3142ca..e0168d954c05 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -789,42 +789,42 @@ bool SVGFilter::implExportWriterTextGraphic( const Reference< view::XSelectionSu
Any selection = xSelectionSupplier->getSelection();
uno::Reference<lang::XServiceInfo> xSelection;
selection >>= xSelection;
- if (xSelection.is() && xSelection->supportsService("com.sun.star.text.TextGraphicObject"))
- {
- uno::Reference<beans::XPropertySet> xPropertySet(xSelection, uno::UNO_QUERY);
-
- uno::Reference<graphic::XGraphic> xOriginalGraphic;
- xPropertySet->getPropertyValue("Graphic") >>= xOriginalGraphic;
- const Graphic aOriginalGraphic(xOriginalGraphic);
+ if (!xSelection || !xSelection->supportsService("com.sun.star.text.TextGraphicObject"))
+ return true;
- uno::Reference<graphic::XGraphic> xTransformedGraphic;
- xPropertySet->getPropertyValue("TransformedGraphic") >>= xTransformedGraphic;
+ uno::Reference<beans::XPropertySet> xPropertySet(xSelection, uno::UNO_QUERY);
- if (!xTransformedGraphic.is())
- return false;
- const Graphic aTransformedGraphic(xTransformedGraphic);
- bool bSameGraphic = aTransformedGraphic == aOriginalGraphic ||
- aOriginalGraphic.GetChecksum() == aTransformedGraphic.GetChecksum();
- const Graphic aGraphic = bSameGraphic ? aOriginalGraphic : aTransformedGraphic;
- uno::Reference<graphic::XGraphic> xGraphic = bSameGraphic ? xOriginalGraphic : xTransformedGraphic;
+ uno::Reference<graphic::XGraphic> xOriginalGraphic;
+ xPropertySet->getPropertyValue("Graphic") >>= xOriginalGraphic;
+ const Graphic aOriginalGraphic(xOriginalGraphic);
- // Calculate size from Graphic
- Point aPos( OutputDevice::LogicToLogic(aGraphic.GetPrefMapMode().GetOrigin(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) );
- Size aSize( OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) );
+ uno::Reference<graphic::XGraphic> xTransformedGraphic;
+ xPropertySet->getPropertyValue("TransformedGraphic") >>= xTransformedGraphic;
- assert(mSelectedPages.size() == 1);
- SvxDrawPage* pSvxDrawPage(comphelper::getFromUnoTunnel<SvxDrawPage>(mSelectedPages[0]));
- if(pSvxDrawPage == nullptr || pSvxDrawPage->GetSdrPage() == nullptr)
- return false;
+ if (!xTransformedGraphic.is())
+ return false;
+ const Graphic aTransformedGraphic(xTransformedGraphic);
+ bool bSameGraphic = aTransformedGraphic == aOriginalGraphic ||
+ aOriginalGraphic.GetChecksum() == aTransformedGraphic.GetChecksum();
+ const Graphic aGraphic = bSameGraphic ? aOriginalGraphic : aTransformedGraphic;
+ uno::Reference<graphic::XGraphic> xGraphic = bSameGraphic ? xOriginalGraphic : xTransformedGraphic;
+
+ // Calculate size from Graphic
+ Point aPos( OutputDevice::LogicToLogic(aGraphic.GetPrefMapMode().GetOrigin(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) );
+ Size aSize( OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) );
+
+ assert(mSelectedPages.size() == 1);
+ SvxDrawPage* pSvxDrawPage(comphelper::getFromUnoTunnel<SvxDrawPage>(mSelectedPages[0]));
+ if(pSvxDrawPage == nullptr || pSvxDrawPage->GetSdrPage() == nullptr)
+ return false;
- SdrGrafObj* pGraphicObj = new SdrGrafObj(pSvxDrawPage->GetSdrPage()->getSdrModelFromSdrPage(), aGraphic, tools::Rectangle( aPos, aSize ));
- uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject(pGraphicObj);
- uno::Reference< XPropertySet > xShapePropSet(xShape, uno::UNO_QUERY);
- xShapePropSet->setPropertyValue("Graphic", uno::Any(xGraphic));
+ SdrGrafObj* pGraphicObj = new SdrGrafObj(pSvxDrawPage->GetSdrPage()->getSdrModelFromSdrPage(), aGraphic, tools::Rectangle( aPos, aSize ));
+ uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject(pGraphicObj);
+ uno::Reference< XPropertySet > xShapePropSet(xShape, uno::UNO_QUERY);
+ xShapePropSet->setPropertyValue("Graphic", uno::Any(xGraphic));
- maShapeSelection = drawing::ShapeCollection::create(comphelper::getProcessComponentContext());
- maShapeSelection->add(xShape);
- }
+ maShapeSelection = drawing::ShapeCollection::create(comphelper::getProcessComponentContext());
+ maShapeSelection->add(xShape);
return true;
}
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 359bd34e3dd8..174c3bbb35b0 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -102,35 +102,34 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
if(mxDstDoc.is()) // Import works for Impress / draw only
return filterImpressOrDraw(rDescriptor);
- if(mxSrcDoc.is())
+ if(!mxSrcDoc)
+ return false;
+
+ for (const PropertyValue& rProp : rDescriptor)
{
- for (const PropertyValue& rProp : rDescriptor)
+ if (rProp.Name == "FilterName")
{
- if (rProp.Name == "FilterName")
+ OUString sFilterName;
+ rProp.Value >>= sFilterName;
+ if(sFilterName == "impress_svg_Export")
{
- OUString sFilterName;
- rProp.Value >>= sFilterName;
- if(sFilterName == "impress_svg_Export")
- {
- mbImpressFilter = true;
- return filterImpressOrDraw(rDescriptor);
- }
- else if(sFilterName == "writer_svg_Export")
- {
- mbWriterFilter = true;
- return filterWriterOrCalc(rDescriptor);
- }
- else if(sFilterName == "calc_svg_Export")
- {
- mbCalcFilter = true;
- return filterWriterOrCalc(rDescriptor);
- }
- break;
+ mbImpressFilter = true;
+ return filterImpressOrDraw(rDescriptor);
+ }
+ else if(sFilterName == "writer_svg_Export")
+ {
+ mbWriterFilter = true;
+ return filterWriterOrCalc(rDescriptor);
}
+ else if(sFilterName == "calc_svg_Export")
+ {
+ mbCalcFilter = true;
+ return filterWriterOrCalc(rDescriptor);
+ }
+ break;
}
- return filterImpressOrDraw(rDescriptor);
}
- return false;
+ return filterImpressOrDraw(rDescriptor);
}
bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescriptor )
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 07afb5f440a1..014de0a808b0 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -961,149 +961,147 @@ bool SVGTextWriter::nextParagraph()
mbIsNewListItem = false;
mbIsListLevelStyleImage = false;
- if( mrParagraphEnumeration.is() && mrParagraphEnumeration->hasMoreElements() )
+ if( !mrParagraphEnumeration || !mrParagraphEnumeration->hasMoreElements() )
+ return false;
+
+ Reference < XTextContent > xTextContent( mrParagraphEnumeration->nextElement(), UNO_QUERY_THROW );
+ if( xTextContent.is() )
{
- Reference < XTextContent > xTextContent( mrParagraphEnumeration->nextElement(), UNO_QUERY_THROW );
- if( xTextContent.is() )
- {
- Reference< XServiceInfo > xServiceInfo( xTextContent, UNO_QUERY_THROW );
+ Reference< XServiceInfo > xServiceInfo( xTextContent, UNO_QUERY_THROW );
#if OSL_DEBUG_LEVEL > 0
- OUString sInfo;
+ OUString sInfo;
#endif
- if( xServiceInfo->supportsService( "com.sun.star.text.Paragraph" ) )
+ if( xServiceInfo->supportsService( "com.sun.star.text.Paragraph" ) )
+ {
+ mrCurrentTextParagraph.set( xTextContent );
+ Reference< XPropertySet > xPropSet( xTextContent, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ if( xPropSetInfo->hasPropertyByName( "NumberingLevel" ) )
{
- mrCurrentTextParagraph.set( xTextContent );
- Reference< XPropertySet > xPropSet( xTextContent, UNO_QUERY_THROW );
- Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
- if( xPropSetInfo->hasPropertyByName( "NumberingLevel" ) )
+ sal_Int16 nListLevel = 0;
+ if( xPropSet->getPropertyValue( "NumberingLevel" ) >>= nListLevel )
{
- sal_Int16 nListLevel = 0;
- if( xPropSet->getPropertyValue( "NumberingLevel" ) >>= nListLevel )
- {
- mbIsNewListItem = true;
+ mbIsNewListItem = true;
#if OSL_DEBUG_LEVEL > 0
- sInfo = "NumberingLevel: " + OUString::number( nListLevel );
- mrExport.AddAttribute( XML_NAMESPACE_NONE, "style", sInfo );
+ sInfo = "NumberingLevel: " + OUString::number( nListLevel );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, "style", sInfo );
#endif
- Reference< XIndexReplace > xNumRules;
- if( xPropSetInfo->hasPropertyByName( "NumberingRules" ) )
- {
- xPropSet->getPropertyValue( "NumberingRules" ) >>= xNumRules;
- }
- if( xNumRules.is() && ( nListLevel < xNumRules->getCount() ) )
+ Reference< XIndexReplace > xNumRules;
+ if( xPropSetInfo->hasPropertyByName( "NumberingRules" ) )
+ {
+ xPropSet->getPropertyValue( "NumberingRules" ) >>= xNumRules;
+ }
+ if( xNumRules.is() && ( nListLevel < xNumRules->getCount() ) )
+ {
+ bool bIsNumbered = true;
+ OUString sNumberingIsNumber("NumberingIsNumber");
+ if( xPropSetInfo->hasPropertyByName( sNumberingIsNumber ) )
{
- bool bIsNumbered = true;
- OUString sNumberingIsNumber("NumberingIsNumber");
- if( xPropSetInfo->hasPropertyByName( sNumberingIsNumber ) )
+ if( !(xPropSet->getPropertyValue( sNumberingIsNumber ) >>= bIsNumbered ) )
{
- if( !(xPropSet->getPropertyValue( sNumberingIsNumber ) >>= bIsNumbered ) )
- {
- OSL_FAIL( "numbered paragraph without number info" );
- bIsNumbered = false;
- }
+ OSL_FAIL( "numbered paragraph without number info" );
+ bIsNumbered = false;
+ }
#if OSL_DEBUG_LEVEL > 0
- if( bIsNumbered )
- {
- sInfo = "true";
- mrExport.AddAttribute( XML_NAMESPACE_NONE, "is-numbered", sInfo );
- }
-#endif
+ if( bIsNumbered )
+ {
+ sInfo = "true";
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, "is-numbered", sInfo );
}
- mbIsNewListItem = bIsNumbered;
+#endif
+ }
+ mbIsNewListItem = bIsNumbered;
- if( bIsNumbered )
+ if( bIsNumbered )
+ {
+ Sequence<PropertyValue> aProps;
+ if( xNumRules->getByIndex( nListLevel ) >>= aProps )
{
- Sequence<PropertyValue> aProps;
- if( xNumRules->getByIndex( nListLevel ) >>= aProps )
+ sal_Int16 eType = NumberingType::CHAR_SPECIAL;
+ sal_Unicode cBullet = 0xf095;
+ const sal_Int32 nCount = aProps.getLength();
+ const PropertyValue* pPropArray = aProps.getConstArray();
+ for( sal_Int32 i = 0; i < nCount; ++i )
{
- sal_Int16 eType = NumberingType::CHAR_SPECIAL;
- sal_Unicode cBullet = 0xf095;
- const sal_Int32 nCount = aProps.getLength();
- const PropertyValue* pPropArray = aProps.getConstArray();
- for( sal_Int32 i = 0; i < nCount; ++i )
+ const PropertyValue& rProp = pPropArray[i];
+ if( rProp.Name == "NumberingType" )
{
- const PropertyValue& rProp = pPropArray[i];
- if( rProp.Name == "NumberingType" )
- {
- rProp.Value >>= eType;
- }
- else if( rProp.Name == "BulletChar" )
+ rProp.Value >>= eType;
+ }
+ else if( rProp.Name == "BulletChar" )
+ {
+ OUString sValue;
+ rProp.Value >>= sValue;
+ if( !sValue.isEmpty() )
{
- OUString sValue;
- rProp.Value >>= sValue;
- if( !sValue.isEmpty() )
- {
- cBullet = sValue[0];
- }
+ cBullet = sValue[0];
}
}
- meNumberingType = eType;
- mbIsListLevelStyleImage = ( NumberingType::BITMAP == meNumberingType );
- if( NumberingType::CHAR_SPECIAL == meNumberingType )
+ }
+ meNumberingType = eType;
+ mbIsListLevelStyleImage = ( NumberingType::BITMAP == meNumberingType );
+ if( NumberingType::CHAR_SPECIAL == meNumberingType )
+ {
+ if( cBullet )
{
- if( cBullet )
+ if( cBullet < ' ' )
{
- if( cBullet < ' ' )
- {
- cBullet = 0xF000 + 149;
- }
- mcBulletChar = cBullet;
+ cBullet = 0xF000 + 149;
+ }
+ mcBulletChar = cBullet;
#if OSL_DEBUG_LEVEL > 0
- sInfo = OUString::number( static_cast<sal_Int32>(cBullet) );
- mrExport.AddAttribute( XML_NAMESPACE_NONE, "bullet-char", sInfo );
+ sInfo = OUString::number( static_cast<sal_Int32>(cBullet) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, "bullet-char", sInfo );
#endif
- }
-
}
+
}
}
}
-
}
- }
- Reference< XEnumerationAccess > xEnumerationAccess( xTextContent, UNO_QUERY_THROW );
- Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_SET_THROW );
- if( xEnumeration.is() && xEnumeration->hasMoreElements() )
- {
- mrTextPortionEnumeration.set( xEnumeration );
}
-#if OSL_DEBUG_LEVEL > 0
- sInfo = "Paragraph";
-#endif
}
- else if( xServiceInfo->supportsService( "com.sun.star.text.Table" ) )
+
+ Reference< XEnumerationAccess > xEnumerationAccess( xTextContent, UNO_QUERY_THROW );
+ Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_SET_THROW );
+ if( xEnumeration.is() && xEnumeration->hasMoreElements() )
{
- OSL_FAIL( "SVGTextWriter::nextParagraph: text tables are not handled." );
+ mrTextPortionEnumeration.set( xEnumeration );
+ }
#if OSL_DEBUG_LEVEL > 0
- sInfo = "Table";
+ sInfo = "Paragraph";
#endif
- }
- else
- {
- OSL_FAIL( "SVGTextWriter::nextParagraph: Unknown text content." );
- return false;
- }
+ }
+ else if( xServiceInfo->supportsService( "com.sun.star.text.Table" ) )
+ {
+ OSL_FAIL( "SVGTextWriter::nextParagraph: text tables are not handled." );
#if OSL_DEBUG_LEVEL > 0
- mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", sInfo );
- SvXMLElementExport aParaElem( mrExport, XML_NAMESPACE_NONE, "desc", mbIWS, mbIWS );
+ sInfo = "Table";
#endif
}
else
{
- OSL_FAIL( "SVGTextWriter::nextParagraph: no XServiceInfo interface available for text content." );
+ OSL_FAIL( "SVGTextWriter::nextParagraph: Unknown text content." );
return false;
}
-
- const OUString& rParagraphId = implGetValidIDFromInterface( Reference<XInterface>(xTextContent, UNO_QUERY) );
- if( !rParagraphId.isEmpty() )
- {
- mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId );
- }
- return true;
+#if OSL_DEBUG_LEVEL > 0
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", sInfo );
+ SvXMLElementExport aParaElem( mrExport, XML_NAMESPACE_NONE, "desc", mbIWS, mbIWS );
+#endif
+ }
+ else
+ {
+ OSL_FAIL( "SVGTextWriter::nextParagraph: no XServiceInfo interface available for text content." );
+ return false;
}
- return false;
+ const OUString& rParagraphId = implGetValidIDFromInterface( Reference<XInterface>(xTextContent, UNO_QUERY) );
+ if( !rParagraphId.isEmpty() )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId );
+ }
+ return true;
}
@@ -1111,134 +1109,134 @@ bool SVGTextWriter::nextTextPortion()
{
mrCurrentTextPortion.clear();
mbIsURLField = false;
- if( mrTextPortionEnumeration.is() && mrTextPortionEnumeration->hasMoreElements() )
- {
- mbIsPlaceholderShape = false;
- Reference< XPropertySet > xPortionPropSet( mrTextPortionEnumeration->nextElement(), UNO_QUERY );
- Reference< XPropertySetInfo > xPortionPropInfo( xPortionPropSet->getPropertySetInfo() );
- Reference < XTextRange > xPortionTextRange( xPortionPropSet, UNO_QUERY);
- if( xPortionPropSet.is() && xPortionPropInfo.is()
- && xPortionPropInfo->hasPropertyByName( "TextPortionType" ) )
- {
+ if( !mrTextPortionEnumeration || !mrTextPortionEnumeration->hasMoreElements() )
+ return false;
+
+ mbIsPlaceholderShape = false;
+ Reference< XPropertySet > xPortionPropSet( mrTextPortionEnumeration->nextElement(), UNO_QUERY );
+ Reference< XPropertySetInfo > xPortionPropInfo( xPortionPropSet->getPropertySetInfo() );
+ Reference < XTextRange > xPortionTextRange( xPortionPropSet, UNO_QUERY);
+ if( !xPortionPropSet || !xPortionPropInfo
+ || !xPortionPropInfo->hasPropertyByName( "TextPortionType" ) )
+ return true;
+
#if OSL_DEBUG_LEVEL > 0
- OUString sInfo;
- OUString sPortionType;
- if( xPortionPropSet->getPropertyValue( "TextPortionType" ) >>= sPortionType )
- {
- sInfo = "type: " + sPortionType + "; ";
- }
+ OUString sInfo;
+ OUString sPortionType;
+ if( xPortionPropSet->getPropertyValue( "TextPortionType" ) >>= sPortionType )
+ {
+ sInfo = "type: " + sPortionType + "; ";
+ }
#endif
- msPageCount = "";
- msDateTimeType = "";
- msTextFieldType = "";
- if( xPortionTextRange.is() )
- {
+ msPageCount = "";
+ msDateTimeType = "";
+ msTextFieldType = "";
+ if( xPortionTextRange.is() )
+ {
#if OSL_DEBUG_LEVEL > 0
- sInfo += "content: " + xPortionTextRange->getString() + "; ";
+ sInfo += "content: " + xPortionTextRange->getString() + "; ";
#endif
- mrCurrentTextPortion.set( xPortionTextRange );
+ mrCurrentTextPortion.set( xPortionTextRange );
- Reference < XPropertySet > xRangePropSet( xPortionTextRange, UNO_QUERY );
- if( xRangePropSet.is() && xRangePropSet->getPropertySetInfo()->hasPropertyByName( "TextField" ) )
- {
- Reference < XTextField > xTextField( xRangePropSet->getPropertyValue( "TextField" ), UNO_QUERY );
- if( xTextField.is() )
- {
- static const OUStringLiteral sServicePrefix(u"com.sun.star.text.textfield.");
- static const OUStringLiteral sPresentationServicePrefix(u"com.sun.star.presentation.TextField.");
+ Reference < XPropertySet > xRangePropSet( xPortionTextRange, UNO_QUERY );
+ if( xRangePropSet.is() && xRangePropSet->getPropertySetInfo()->hasPropertyByName( "TextField" ) )
+ {
+ Reference < XTextField > xTextField( xRangePropSet->getPropertyValue( "TextField" ), UNO_QUERY );
+ if( xTextField.is() )
+ {
+ static const OUStringLiteral sServicePrefix(u"com.sun.star.text.textfield.");
+ static const OUStringLiteral sPresentationServicePrefix(u"com.sun.star.presentation.TextField.");
- Reference< XServiceInfo > xService( xTextField, UNO_QUERY );
- const Sequence< OUString > aServices = xService->getSupportedServiceNames();
+ Reference< XServiceInfo > xService( xTextField, UNO_QUERY );
+ const Sequence< OUString > aServices = xService->getSupportedServiceNames();
- const OUString* pNames = aServices.getConstArray();
- sal_Int32 nCount = aServices.getLength();
+ const OUString* pNames = aServices.getConstArray();
+ sal_Int32 nCount = aServices.getLength();
- OUString sFieldName; // service name postfix of current field
+ OUString sFieldName; // service name postfix of current field
- // search for TextField service name
- while( nCount-- )
- {
- if ( pNames->matchIgnoreAsciiCase( sServicePrefix ) )
- {
- // TextField found => postfix is field type!
- sFieldName = pNames->copy( sServicePrefix.getLength() );
- break;
- }
- else if( pNames->startsWith( sPresentationServicePrefix ) )
- {
- // TextField found => postfix is field type!
- sFieldName = pNames->copy( sPresentationServicePrefix.getLength() );
- break;
- }
+ // search for TextField service name
+ while( nCount-- )
+ {
+ if ( pNames->matchIgnoreAsciiCase( sServicePrefix ) )
+ {
+ // TextField found => postfix is field type!
+ sFieldName = pNames->copy( sServicePrefix.getLength() );
+ break;
+ }
+ else if( pNames->startsWith( sPresentationServicePrefix ) )
+ {
+ // TextField found => postfix is field type!
+ sFieldName = pNames->copy( sPresentationServicePrefix.getLength() );
+ break;
+ }
- ++pNames;
- }
+ ++pNames;
+ }
- msTextFieldType = sFieldName;
+ msTextFieldType = sFieldName;
#if OSL_DEBUG_LEVEL > 0
- sInfo += "text field type: " + sFieldName + "; content: " + xTextField->getPresentation( /* show command: */ false ) + "; ";
+ sInfo += "text field type: " + sFieldName + "; content: " + xTextField->getPresentation( /* show command: */ false ) + "; ";
#endif
- // This case handle Date or Time text field inserted by the user
- // on both page/master page. It doesn't handle the standard Date/Time field.
- if( sFieldName == "DateTime" )
+ // This case handle Date or Time text field inserted by the user
+ // on both page/master page. It doesn't handle the standard Date/Time field.
+ if( sFieldName == "DateTime" )
+ {
+ Reference<XPropertySet> xTextFieldPropSet(xTextField, UNO_QUERY);
+ if( xTextFieldPropSet.is() )
+ {
+ Reference<XPropertySetInfo> xPropSetInfo = xTextFieldPropSet->getPropertySetInfo();
+ if( xPropSetInfo.is() )
{
- Reference<XPropertySet> xTextFieldPropSet(xTextField, UNO_QUERY);
- if( xTextFieldPropSet.is() )
+ // The standard Date/Time field has no property.
+ // Trying to get a property value on such field would cause a runtime exception.
+ // So the hasPropertyByName check is needed.
+ bool bIsFixed = true;
+ if( xPropSetInfo->hasPropertyByName("IsFixed") && ( ( xTextFieldPropSet->getPropertyValue( "IsFixed" ) ) >>= bIsFixed ) && !bIsFixed )
{
- Reference<XPropertySetInfo> xPropSetInfo = xTextFieldPropSet->getPropertySetInfo();
- if( xPropSetInfo.is() )
+ bool bIsDate = true;
+ if( xPropSetInfo->hasPropertyByName("IsDate") && ( ( xTextFieldPropSet->getPropertyValue( "IsDate" ) ) >>= bIsDate ) )
{
- // The standard Date/Time field has no property.
- // Trying to get a property value on such field would cause a runtime exception.
- // So the hasPropertyByName check is needed.
- bool bIsFixed = true;
- if( xPropSetInfo->hasPropertyByName("IsFixed") && ( ( xTextFieldPropSet->getPropertyValue( "IsFixed" ) ) >>= bIsFixed ) && !bIsFixed )
- {
- bool bIsDate = true;
- if( xPropSetInfo->hasPropertyByName("IsDate") && ( ( xTextFieldPropSet->getPropertyValue( "IsDate" ) ) >>= bIsDate ) )
- {
- msDateTimeType = OUString::createFromAscii( bIsDate ? "<date>" : "<time>" );
- }
- }
+ msDateTimeType = OUString::createFromAscii( bIsDate ? "<date>" : "<time>" );
}
}
}
- if( sFieldName == "DateTime" || sFieldName == "Header"
- || sFieldName == "Footer" || sFieldName == "PageNumber"
- || sFieldName == "PageName" )
- {
- mbIsPlaceholderShape = true;
- }
- else if (sFieldName == "PageCount")
- {
- msPageCount = xTextField->getPresentation( /* show command: */ false );
- }
- else
- {
- mbIsURLField = sFieldName == "URL";
+ }
+ }
+ if( sFieldName == "DateTime" || sFieldName == "Header"
+ || sFieldName == "Footer" || sFieldName == "PageNumber"
+ || sFieldName == "PageName" )
+ {
+ mbIsPlaceholderShape = true;
+ }
+ else if (sFieldName == "PageCount")
+ {
+ msPageCount = xTextField->getPresentation( /* show command: */ false );
+ }
+ else
+ {
+ mbIsURLField = sFieldName == "URL";
- if( mbIsURLField )
+ if( mbIsURLField )
+ {
+ Reference<XPropertySet> xTextFieldPropSet(xTextField, UNO_QUERY);
+ if( xTextFieldPropSet.is() )
+ {
+ OUString sURL;
+ if( ( xTextFieldPropSet->getPropertyValue( sFieldName ) ) >>= sURL )
{
- Reference<XPropertySet> xTextFieldPropSet(xTextField, UNO_QUERY);
- if( xTextFieldPropSet.is() )
- {
- OUString sURL;
- if( ( xTextFieldPropSet->getPropertyValue( sFieldName ) ) >>= sURL )
- {
#if OSL_DEBUG_LEVEL > 0
- sInfo += "url: " + mrExport.GetRelativeReference( sURL );
+ sInfo += "url: " + mrExport.GetRelativeReference( sURL );
#endif
- msUrl = mrExport.GetRelativeReference( sURL );
- if( !msUrl.isEmpty() )
- {
- implRegisterInterface( xPortionTextRange );
+ msUrl = mrExport.GetRelativeReference( sURL );
+ if( !msUrl.isEmpty() )
+ {
+ implRegisterInterface( xPortionTextRange );
- const OUString& rTextPortionId = implGetValidIDFromInterface( Reference<XInterface>(xPortionTextRange, UNO_QUERY) );
- if( !rTextPortionId.isEmpty() )
- {
- msHyperlinkIdList += rTextPortionId + " ";
- }
- }
+ const OUString& rTextPortionId = implGetValidIDFromInterface( Reference<XInterface>(xPortionTextRange, UNO_QUERY) );
+ if( !rTextPortionId.isEmpty() )
+ {
+ msHyperlinkIdList += rTextPortionId + " ";
}
}
}
@@ -1246,16 +1244,14 @@ bool SVGTextWriter::nextTextPortion()
}
}
}
-#if OSL_DEBUG_LEVEL > 0
- mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", "TextPortion" );
- SvXMLElementExport aPortionElem( mrExport, XML_NAMESPACE_NONE, "desc", mbIWS, mbIWS );
- mrExport.GetDocHandler()->characters( sInfo );
-#endif
- return true;
}
}
-
- return false;
+#if OSL_DEBUG_LEVEL > 0
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", "TextPortion" );
+ SvXMLElementExport aPortionElem( mrExport, XML_NAMESPACE_NONE, "desc", mbIWS, mbIWS );
+ mrExport.GetDocHandler()->characters( sInfo );
+#endif
+ return true;
}