filter/source/msfilter/escherex.cxx | 102 +- filter/source/msfilter/msdffimp.cxx | 73 +- filter/source/msfilter/rtfutil.cxx | 82 +- filter/source/svg/svgexport.cxx | 60 - filter/source/svg/svgfilter.cxx | 45 - filter/source/svg/svgwriter.cxx | 422 +++++------- forms/source/component/CheckBox.cxx | 58 - forms/source/component/ComboBox.cxx | 40 - forms/source/component/DatabaseForm.cxx | 96 +- forms/source/component/Date.cxx | 52 - forms/source/component/Filter.cxx | 43 - forms/source/component/FormattedField.cxx | 48 - forms/source/component/Pattern.cxx | 44 - forms/source/component/Time.cxx | 58 - forms/source/misc/limitedformats.cxx | 106 +-- forms/source/runtime/formoperations.cxx | 37 - formula/source/core/api/token.cxx | 164 ++-- formula/source/ui/dlg/structpg.cxx | 28 fpicker/source/office/PlacesListBox.cxx | 35 fpicker/source/office/iodlg.cxx | 68 - framework/source/helper/dockingareadefaultacceptor.cxx | 48 - framework/source/layoutmanager/layoutmanager.cxx | 214 +++--- framework/source/layoutmanager/toolbarlayoutmanager.cxx | 250 +++---- framework/source/services/urltransformer.cxx | 52 - framework/source/uiconfiguration/globalsettings.cxx | 40 - framework/source/uiconfiguration/imagemanagerimpl.cxx | 128 +-- framework/source/uielement/imagebuttontoolbarcontroller.cxx | 34 framework/source/uielement/menubarmanager.cxx | 336 ++++----- framework/source/uifactory/factoryconfiguration.cxx | 32 framework/source/uifactory/uielementfactorymanager.cxx | 32 30 files changed, 1404 insertions(+), 1423 deletions(-)
New commits: commit 489bce598626390d9c0aa5e5b8514e26070add61 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Dec 21 15:22:06 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Dec 21 17:14:14 2021 +0100 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.gran...@collabora.co.uk> 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; } diff --git a/forms/source/component/CheckBox.cxx b/forms/source/component/CheckBox.cxx index 7718b7d74504..f82a49f7042c 100644 --- a/forms/source/component/CheckBox.cxx +++ b/forms/source/component/CheckBox.cxx @@ -236,39 +236,39 @@ Any OCheckBoxModel::translateDbColumnToControlValue() bool OCheckBoxModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { OSL_PRECOND( m_xColumnUpdate.is(), "OCheckBoxModel::commitControlValueToDbColumn: not bound!" ); - if ( m_xColumnUpdate.is() ) + if ( !m_xColumnUpdate ) + return true; + + Any aControlValue( m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) ); + try { - Any aControlValue( m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) ); - try - { - sal_Int16 nValue = TRISTATE_INDET; - aControlValue >>= nValue; - switch (nValue) - { - case TRISTATE_INDET: - m_xColumnUpdate->updateNull(); - break; - case TRISTATE_TRUE: - if (DbUseBool()) - m_xColumnUpdate->updateBoolean( true ); - else - m_xColumnUpdate->updateString( getReferenceValue() ); - break; - case TRISTATE_FALSE: - if (DbUseBool()) - m_xColumnUpdate->updateBoolean( false ); - else - m_xColumnUpdate->updateString( getNoCheckReferenceValue() ); - break; - default: - OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: invalid value !"); - } - } - catch(const Exception&) + sal_Int16 nValue = TRISTATE_INDET; + aControlValue >>= nValue; + switch (nValue) { - OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: could not commit !"); + case TRISTATE_INDET: + m_xColumnUpdate->updateNull(); + break; + case TRISTATE_TRUE: + if (DbUseBool()) + m_xColumnUpdate->updateBoolean( true ); + else + m_xColumnUpdate->updateString( getReferenceValue() ); + break; + case TRISTATE_FALSE: + if (DbUseBool()) + m_xColumnUpdate->updateBoolean( false ); + else + m_xColumnUpdate->updateString( getNoCheckReferenceValue() ); + break; + default: + OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: invalid value !"); } } + catch(const Exception&) + { + OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: could not commit !"); + } return true; } diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index d43903bfea35..c26b90f04778 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -755,29 +755,29 @@ bool OComboBoxModel::commitControlValueToDbColumn( bool _bPostReset ) bool bAddToList = bModified && !_bPostReset; // (only if this is not the "commit" triggered by a "reset") - if ( bAddToList ) + if ( !bAddToList ) + return true; + + css::uno::Sequence<OUString> aStringItemList; + if ( !(getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList) ) + return true; + + bool bFound = false; + for (const OUString& rStringItem : std::as_const(aStringItemList)) { - css::uno::Sequence<OUString> aStringItemList; - if ( getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList ) - { - bool bFound = false; - for (const OUString& rStringItem : std::as_const(aStringItemList)) - { - if ( (bFound = rStringItem == sNewValue) ) - break; - } + if ( (bFound = rStringItem == sNewValue) ) + break; + } - // not found -> add - if (!bFound) - { - sal_Int32 nOldLen = aStringItemList.getLength(); - aStringItemList.realloc( nOldLen + 1 ); - aStringItemList.getArray()[ nOldLen ] = sNewValue; + // not found -> add + if (!bFound) + { + sal_Int32 nOldLen = aStringItemList.getLength(); + aStringItemList.realloc( nOldLen + 1 ); + aStringItemList.getArray()[ nOldLen ] = sNewValue; - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( aStringItemList ) ); - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); - } - } + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( aStringItemList ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); } return true; diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 45ffd5e595f1..74fbaf77e6be 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -1033,32 +1033,31 @@ void ODatabaseForm::updateParameterInfo() bool ODatabaseForm::hasValidParent() const { // do we have to fill the parameters again? - if (m_bSubForm) + if (!m_bSubForm) + return true; + Reference<XResultSet> xResultSet(m_xParent, UNO_QUERY); + if (!xResultSet.is()) { - Reference<XResultSet> xResultSet(m_xParent, UNO_QUERY); - if (!xResultSet.is()) - { - OSL_FAIL("ODatabaseForm::hasValidParent() : no parent resultset !"); - return false; - } - try - { - Reference< XPropertySet > xSet( m_xParent, UNO_QUERY ); - Reference< XLoadable > xLoad( m_xParent, UNO_QUERY ); - if ( xLoad->isLoaded() - && ( xResultSet->isBeforeFirst() - || xResultSet->isAfterLast() - || getBOOL( xSet->getPropertyValue( PROPERTY_ISNEW ) ) - ) + OSL_FAIL("ODatabaseForm::hasValidParent() : no parent resultset !"); + return false; + } + try + { + Reference< XPropertySet > xSet( m_xParent, UNO_QUERY ); + Reference< XLoadable > xLoad( m_xParent, UNO_QUERY ); + if ( xLoad->isLoaded() + && ( xResultSet->isBeforeFirst() + || xResultSet->isAfterLast() + || getBOOL( xSet->getPropertyValue( PROPERTY_ISNEW ) ) ) - // the parent form is loaded and on a "virtual" row -> not valid - return false; - } - catch(const Exception&) - { - // parent could be forwardonly? + ) + // the parent form is loaded and on a "virtual" row -> not valid return false; - } + } + catch(const Exception&) + { + // parent could be forwardonly? + return false; } return true; } @@ -3110,35 +3109,34 @@ sal_Bool SAL_CALL ODatabaseForm::approveCursorMove(const EventObject& event) sal_Bool SAL_CALL ODatabaseForm::approveRowChange(const RowChangeEvent& event) { // is our aggregate calling? - if (event.Source == css::uno::Reference<css::uno::XInterface>(static_cast<XWeak*>(this))) + if (event.Source != css::uno::Reference<css::uno::XInterface>(static_cast<XWeak*>(this))) + return true; + + // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface + // for XRowSetApproveBroadcaster-interface. + // So we have to multiplex this approve request. + ::comphelper::OInterfaceIteratorHelper3 aIter( m_aRowSetApproveListeners ); + while ( aIter.hasMoreElements() ) { - // Our aggregate doesn't have any ApproveRowSetListeners (expect ourself), as we re-routed the queryInterface - // for XRowSetApproveBroadcaster-interface. - // So we have to multiplex this approve request. - ::comphelper::OInterfaceIteratorHelper3 aIter( m_aRowSetApproveListeners ); - while ( aIter.hasMoreElements() ) + Reference< XRowSetApproveListener > xListener( aIter.next() ); + try { - Reference< XRowSetApproveListener > xListener( aIter.next() ); - try - { - if ( !xListener->approveRowChange( event ) ) - return false; - } - catch (const DisposedException& e) - { - if ( e.Context == xListener ) - aIter.remove(); - } - catch (const RuntimeException&) - { - throw; - } - catch (const Exception&) - { - DBG_UNHANDLED_EXCEPTION("forms.component"); - } + if ( !xListener->approveRowChange( event ) ) + return false; + } + catch (const DisposedException& e) + { + if ( e.Context == xListener ) + aIter.remove(); + } + catch (const RuntimeException&) + { + throw; + } + catch (const Exception&) + { + DBG_UNHANDLED_EXCEPTION("forms.component"); } - return true; } return true; } diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx index cf3de99e1b24..35b2f3f7424b 100644 --- a/forms/source/component/Date.cxx +++ b/forms/source/component/Date.cxx @@ -219,40 +219,40 @@ void ODateModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm ) bool ODateModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aControlValue != m_aSaveValue ) + if ( aControlValue == m_aSaveValue ) + return true; + + if ( !aControlValue.hasValue() ) + m_xColumnUpdate->updateNull(); + else { - if ( !aControlValue.hasValue() ) - m_xColumnUpdate->updateNull(); - else + try { - try + util::Date aDate; + if ( !( aControlValue >>= aDate ) ) { - util::Date aDate; - if ( !( aControlValue >>= aDate ) ) - { - sal_Int32 nAsInt(0); - aControlValue >>= nAsInt; - aDate = DBTypeConversion::toDate(nAsInt); - } - - if ( !m_bDateTimeField ) - m_xColumnUpdate->updateDate( aDate ); - else - { - util::DateTime aDateTime = m_xColumn->getTimestamp(); - aDateTime.Day = aDate.Day; - aDateTime.Month = aDate.Month; - aDateTime.Year = aDate.Year; - m_xColumnUpdate->updateTimestamp( aDateTime ); - } + sal_Int32 nAsInt(0); + aControlValue >>= nAsInt; + aDate = DBTypeConversion::toDate(nAsInt); } - catch(const Exception&) + + if ( !m_bDateTimeField ) + m_xColumnUpdate->updateDate( aDate ); + else { - return false; + util::DateTime aDateTime = m_xColumn->getTimestamp(); + aDateTime.Day = aDate.Day; + aDateTime.Month = aDate.Month; + aDateTime.Year = aDate.Year; + m_xColumnUpdate->updateTimestamp( aDateTime ); } } - m_aSaveValue = aControlValue; + catch(const Exception&) + { + return false; + } } + m_aSaveValue = aControlValue; return true; } diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 38ed0b7ada01..9c6459a0dd04 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -510,32 +510,31 @@ namespace frm default: return true; } - if ( m_aText != aText ) + if ( m_aText == aText ) + return true; + // check the text with the SQL-Parser + OUString aNewText = aText.trim(); + if ( !aNewText.isEmpty() ) { - // check the text with the SQL-Parser - OUString aNewText = aText.trim(); - if ( !aNewText.isEmpty() ) + ::dbtools::OPredicateInputController aPredicateInput( m_xContext, m_xConnection, getParseContext() ); + OUString sErrorMessage; + if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) ) { - ::dbtools::OPredicateInputController aPredicateInput( m_xContext, m_xConnection, getParseContext() ); - OUString sErrorMessage; - if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) ) - { - // display the error and outta here - SQLContext aError; - aError.Message = ResourceManager::loadString(RID_STR_SYNTAXERROR); - aError.Details = sErrorMessage; - displayException( aError ); - return false; - } + // display the error and outta here + SQLContext aError; + aError.Message = ResourceManager::loadString(RID_STR_SYNTAXERROR); + aError.Details = sErrorMessage; + displayException( aError ); + return false; } - - setText(aNewText); - TextEvent aEvt; - aEvt.Source = *this; - ::comphelper::OInterfaceIteratorHelper3 aIt(m_aTextListeners); - while( aIt.hasMoreElements() ) - aIt.next()->textChanged(aEvt); } + + setText(aNewText); + TextEvent aEvt; + aEvt.Source = *this; + ::comphelper::OInterfaceIteratorHelper3 aIt(m_aTextListeners); + while( aIt.hasMoreElements() ) + aIt.next()->textChanged(aEvt); #endif return true; } diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx index 340ee79a8a0f..432456802c4c 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -809,38 +809,38 @@ sal_uInt16 OFormattedModel::getPersistenceFlags() const bool OFormattedModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aControlValue != m_aSaveValue ) - { - // empty string + EmptyIsNull = void - if ( !aControlValue.hasValue() - || ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING ) - && getString( aControlValue ).isEmpty() - && m_bEmptyIsNull - ) + if ( aControlValue == m_aSaveValue ) + return true; + + // empty string + EmptyIsNull = void + if ( !aControlValue.hasValue() + || ( ( aControlValue.getValueType().getTypeClass() == TypeClass_STRING ) + && getString( aControlValue ).isEmpty() + && m_bEmptyIsNull ) - m_xColumnUpdate->updateNull(); - else + ) + m_xColumnUpdate->updateNull(); + else + { + try { - try + double f = 0.0; + if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE || (aControlValue >>= f)) // #i110323 { - double f = 0.0; - if ( aControlValue.getValueType().getTypeClass() == TypeClass_DOUBLE || (aControlValue >>= f)) // #i110323 - { - DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType ); - } - else - { - DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalid value type!" ); - m_xColumnUpdate->updateString( getString( aControlValue ) ); - } + DBTypeConversion::setValue( m_xColumnUpdate, m_aNullDate, getDouble( aControlValue ), m_nKeyType ); } - catch(const Exception&) + else { - return false; + DBG_ASSERT( aControlValue.getValueType().getTypeClass() == TypeClass_STRING, "OFormattedModel::commitControlValueToDbColumn: invalid value type!" ); + m_xColumnUpdate->updateString( getString( aControlValue ) ); } } - m_aSaveValue = aControlValue; + catch(const Exception&) + { + return false; + } } + m_aSaveValue = aControlValue; return true; } diff --git a/forms/source/component/Pattern.cxx b/forms/source/component/Pattern.cxx index 434bf27f7cfc..24e9ac10585d 100644 --- a/forms/source/component/Pattern.cxx +++ b/forms/source/component/Pattern.cxx @@ -126,33 +126,33 @@ bool OPatternModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aNewValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aNewValue != m_aLastKnownValue ) - { - OUString sNewValue; - aNewValue >>= sNewValue; + if ( aNewValue == m_aLastKnownValue ) + return true; - if ( !aNewValue.hasValue() - || ( sNewValue.isEmpty() // an empty string - && m_bEmptyIsNull // which should be interpreted as NULL - ) - ) - { - m_xColumnUpdate->updateNull(); - } - else - { - OSL_ENSURE(m_pFormattedValue, - "OPatternModel::commitControlValueToDbColumn: no value helper!"); - if (!m_pFormattedValue) - return false; + OUString sNewValue; + aNewValue >>= sNewValue; - if ( !m_pFormattedValue->setFormattedValue( sNewValue ) ) - return false; - } + if ( !aNewValue.hasValue() + || ( sNewValue.isEmpty() // an empty string + && m_bEmptyIsNull // which should be interpreted as NULL + ) + ) + { + m_xColumnUpdate->updateNull(); + } + else + { + OSL_ENSURE(m_pFormattedValue, + "OPatternModel::commitControlValueToDbColumn: no value helper!"); + if (!m_pFormattedValue) + return false; - m_aLastKnownValue = aNewValue; + if ( !m_pFormattedValue->setFormattedValue( sNewValue ) ) + return false; } + m_aLastKnownValue = aNewValue; + return true; } diff --git a/forms/source/component/Time.cxx b/forms/source/component/Time.cxx index 24d4a0369a90..fffcbd5466ed 100644 --- a/forms/source/component/Time.cxx +++ b/forms/source/component/Time.cxx @@ -224,43 +224,43 @@ void OTimeModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm ) bool OTimeModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) { Any aControlValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) ); - if ( aControlValue != m_aSaveValue ) + if ( aControlValue == m_aSaveValue ) + return true; + + if ( !aControlValue.hasValue() ) + m_xColumnUpdate->updateNull(); + else { - if ( !aControlValue.hasValue() ) - m_xColumnUpdate->updateNull(); - else + try { - try + util::Time aTime; + if ( !( aControlValue >>= aTime ) ) { - util::Time aTime; - if ( !( aControlValue >>= aTime ) ) - { - sal_Int64 nAsInt(0); - aControlValue >>= nAsInt; - aTime = DBTypeConversion::toTime(nAsInt); - } - - if (!m_bDateTimeField) - m_xColumnUpdate->updateTime(aTime); - else - { - util::DateTime aDateTime = m_xColumn->getTimestamp(); - if (aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0) - aDateTime = ::com::sun::star::util::DateTime(0,0,0,0,30,12,1899, false); - aDateTime.NanoSeconds = aTime.NanoSeconds; - aDateTime.Seconds = aTime.Seconds; - aDateTime.Minutes = aTime.Minutes; - aDateTime.Hours = aTime.Hours; - m_xColumnUpdate->updateTimestamp(aDateTime); - } + sal_Int64 nAsInt(0); + aControlValue >>= nAsInt; + aTime = DBTypeConversion::toTime(nAsInt); } - catch(const Exception&) + + if (!m_bDateTimeField) + m_xColumnUpdate->updateTime(aTime); + else { - return false; + util::DateTime aDateTime = m_xColumn->getTimestamp(); + if (aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0) + aDateTime = ::com::sun::star::util::DateTime(0,0,0,0,30,12,1899, false); + aDateTime.NanoSeconds = aTime.NanoSeconds; + aDateTime.Seconds = aTime.Seconds; + aDateTime.Minutes = aTime.Minutes; + aDateTime.Hours = aTime.Hours; + m_xColumnUpdate->updateTimestamp(aDateTime); } } - m_aSaveValue = aControlValue; + catch(const Exception&) + { + return false; + } } + m_aSaveValue = aControlValue; return true; } diff --git a/forms/source/misc/limitedformats.cxx b/forms/source/misc/limitedformats.cxx index f49b8617ff2c..b7a0d5abcbd6 100644 --- a/forms/source/misc/limitedformats.cxx +++ b/forms/source/misc/limitedformats.cxx @@ -271,70 +271,68 @@ namespace frm { OSL_ENSURE(m_xAggregate.is() && (-1 != m_nFormatEnumPropertyHandle), "OLimitedFormats::convertFormatKeyPropertyValue: not initialized!"); - if (m_xAggregate.is()) + if (!m_xAggregate) + return false; + + // the new format key to set + sal_Int32 nNewFormat = 0; + if (!(_rNewValue >>= nNewFormat)) + throw IllegalArgumentException(); + + // get the old (enum) value from the aggregate + Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); + sal_Int32 nOldEnumValue = -1; + ::cppu::enum2int(nOldEnumValue, aEnumPropertyValue); + + // get the translation table + const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); + + _rOldValue.clear(); + _rConvertedValue.clear(); + + // look for the entry with the given format key + sal_Int32 nTablePosition = 0; + for ( ; + (nullptr != pFormats->pDescription) && (nNewFormat != pFormats->nKey); + ++pFormats, ++nTablePosition + ) { - // the new format key to set - sal_Int32 nNewFormat = 0; - if (!(_rNewValue >>= nNewFormat)) - throw IllegalArgumentException(); - - // get the old (enum) value from the aggregate - Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); - sal_Int32 nOldEnumValue = -1; - ::cppu::enum2int(nOldEnumValue, aEnumPropertyValue); - - // get the translation table - const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); - - _rOldValue.clear(); - _rConvertedValue.clear(); - - // look for the entry with the given format key - sal_Int32 nTablePosition = 0; - for ( ; - (nullptr != pFormats->pDescription) && (nNewFormat != pFormats->nKey); - ++pFormats, ++nTablePosition - ) - { - if (nTablePosition == nOldEnumValue) - _rOldValue <<= pFormats->nKey; - } + if (nTablePosition == nOldEnumValue) + _rOldValue <<= pFormats->nKey; + } - bool bFoundIt = (nullptr != pFormats->pDescription); - bool bModified = false; - if (bFoundIt) - { - _rConvertedValue <<= static_cast<sal_Int16>(nTablePosition); - bModified = nTablePosition != nOldEnumValue; - } + bool bFoundIt = (nullptr != pFormats->pDescription); + bool bModified = false; + if (bFoundIt) + { + _rConvertedValue <<= static_cast<sal_Int16>(nTablePosition); + bModified = nTablePosition != nOldEnumValue; + } - if (!_rOldValue.hasValue()) - { // did not reach the end of the table (means we found nNewFormat) - // -> go to the end to ensure that _rOldValue is set - while (pFormats->pDescription) + if (!_rOldValue.hasValue()) + { // did not reach the end of the table (means we found nNewFormat) + // -> go to the end to ensure that _rOldValue is set + while (pFormats->pDescription) + { + if (nTablePosition == nOldEnumValue) { - if (nTablePosition == nOldEnumValue) - { - _rOldValue <<= pFormats->nKey; - break; - } - - ++pFormats; - ++nTablePosition; + _rOldValue <<= pFormats->nKey; + break; } - } - OSL_ENSURE(_rOldValue.hasValue(), "OLimitedFormats::convertFormatKeyPropertyValue: did not find the old enum value in the table!"); - - if (!bFoundIt) - { // somebody gave us a format which we can't translate - throw IllegalArgumentException("This control supports only a very limited number of formats.", nullptr, 2); + ++pFormats; + ++nTablePosition; } + } + + OSL_ENSURE(_rOldValue.hasValue(), "OLimitedFormats::convertFormatKeyPropertyValue: did not find the old enum value in the table!"); - return bModified; + if (!bFoundIt) + { // somebody gave us a format which we can't translate + throw IllegalArgumentException("This control supports only a very limited number of formats.", nullptr, 2); } - return false; + return bModified; } diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index e7c7d135f61a..ae40c527b4d6 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -430,26 +430,25 @@ namespace frm // returns false if parent should *abort* (user pressed cancel) bool checkConfirmation(bool &needConfirmation, bool &shouldCommit) { - if(needConfirmation) + if(!needConfirmation) + return true; + // TODO: shouldn't this be done with an interaction handler? + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, + ResourceManager::loadString(RID_STR_QUERY_SAVE_MODIFIED_ROW))); + xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); + xQueryBox->set_default_response(RET_YES); + + switch (xQueryBox->run()) { - // TODO: shouldn't this be done with an interaction handler? - std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, - VclMessageType::Question, VclButtonsType::YesNo, - ResourceManager::loadString(RID_STR_QUERY_SAVE_MODIFIED_ROW))); - xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); - xQueryBox->set_default_response(RET_YES); - - switch (xQueryBox->run()) - { - case RET_NO: - shouldCommit = false; - [[fallthrough]]; // don't ask again! - case RET_YES: - needConfirmation = false; - return true; - case RET_CANCEL: - return false; - } + case RET_NO: + shouldCommit = false; + [[fallthrough]]; // don't ask again! + case RET_YES: + needConfirmation = false; + return true; + case RET_CANCEL: + return false; } return true; } diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 89ae03162778..abda98f2f86d 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -942,68 +942,68 @@ void FormulaTokenArray::AddRecalcMode( ScRecalcMode nBits ) bool FormulaTokenArray::HasMatrixDoubleRefOps() const { - if ( pRPN && nRPN ) + if ( !pRPN || !nRPN ) + return false; + + // RPN-Interpreter simulation. + // Simply assumes a double as return value of each function. + std::unique_ptr<FormulaToken*[]> pStack(new FormulaToken* [nRPN]); + FormulaToken* pResult = new FormulaDoubleToken( 0.0 ); + short sp = 0; + for ( auto t: RPNTokens() ) { - // RPN-Interpreter simulation. - // Simply assumes a double as return value of each function. - std::unique_ptr<FormulaToken*[]> pStack(new FormulaToken* [nRPN]); - FormulaToken* pResult = new FormulaDoubleToken( 0.0 ); - short sp = 0; - for ( auto t: RPNTokens() ) + OpCode eOp = t->GetOpCode(); + sal_uInt8 nParams = t->GetParamCount(); + switch ( eOp ) { - OpCode eOp = t->GetOpCode(); - sal_uInt8 nParams = t->GetParamCount(); - switch ( eOp ) + case ocAdd : + case ocSub : + case ocMul : + case ocDiv : + case ocPow : + case ocPower : + case ocAmpersand : + case ocEqual : + case ocNotEqual : + case ocLess : + case ocGreater : + case ocLessEqual : + case ocGreaterEqual : { - case ocAdd : - case ocSub : - case ocMul : - case ocDiv : - case ocPow : - case ocPower : - case ocAmpersand : - case ocEqual : - case ocNotEqual : - case ocLess : - case ocGreater : - case ocLessEqual : - case ocGreaterEqual : + for ( sal_uInt8 k = nParams; k; k-- ) { - for ( sal_uInt8 k = nParams; k; k-- ) + if ( sp >= k && pStack[sp-k]->GetType() == svDoubleRef ) { - if ( sp >= k && pStack[sp-k]->GetType() == svDoubleRef ) - { - pResult->Delete(); - return true; - } + pResult->Delete(); + return true; } } - break; - default: - { - // added to avoid warnings - } } - if ( eOp == ocPush || lcl_IsReference( eOp, t->GetType() ) ) - pStack[sp++] = t; - else if (FormulaCompiler::IsOpCodeJumpCommand( eOp )) - { // ignore Jumps, pop previous Result (Condition) - if ( sp ) - --sp; + break; + default: + { + // added to avoid warnings } - else - { // pop parameters, push result - sp = sal::static_int_cast<short>( sp - nParams ); - if ( sp < 0 ) - { - SAL_WARN("formula.core", "FormulaTokenArray::HasMatrixDoubleRefOps: sp < 0" ); - sp = 0; - } - pStack[sp++] = pResult; + } + if ( eOp == ocPush || lcl_IsReference( eOp, t->GetType() ) ) + pStack[sp++] = t; + else if (FormulaCompiler::IsOpCodeJumpCommand( eOp )) + { // ignore Jumps, pop previous Result (Condition) + if ( sp ) + --sp; + } + else + { // pop parameters, push result + sp = sal::static_int_cast<short>( sp - nParams ); + if ( sp < 0 ) + { + SAL_WARN("formula.core", "FormulaTokenArray::HasMatrixDoubleRefOps: sp < 0" ); + sp = 0; } + pStack[sp++] = pResult; } - pResult->Delete(); } + pResult->Delete(); return false; } @@ -1530,23 +1530,23 @@ inline bool isWhitespace( OpCode eOp ) { return eOp == ocSpaces || eOp == ocWhit bool FormulaTokenArray::MayReferenceFollow() { - if ( pCode && nLen > 0 ) + if ( !pCode || nLen <= 0 ) + return false; + + // ignore trailing spaces + sal_uInt16 i = nLen - 1; + while (i > 0 && isWhitespace( pCode[i]->GetOpCode())) { - // ignore trailing spaces - sal_uInt16 i = nLen - 1; - while (i > 0 && isWhitespace( pCode[i]->GetOpCode())) - { - --i; - } - if (i > 0 || !isWhitespace( pCode[i]->GetOpCode())) + --i; + } + if (i > 0 || !isWhitespace( pCode[i]->GetOpCode())) + { + OpCode eOp = pCode[i]->GetOpCode(); + if ( (SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP ) || + (SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP ) || + eOp == SC_OPCODE_OPEN || eOp == SC_OPCODE_SEP ) { - OpCode eOp = pCode[i]->GetOpCode(); - if ( (SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP ) || - (SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP ) || - eOp == SC_OPCODE_OPEN || eOp == SC_OPCODE_SEP ) - { - return true; - } + return true; } } return false; @@ -1776,26 +1776,26 @@ FormulaToken* FormulaTokenArrayPlainIterator::GetNextReferenceRPN() FormulaToken* FormulaTokenArrayPlainIterator::GetNextReferenceOrName() { - if( mpFTA->GetArray() ) + if( !mpFTA->GetArray() ) + return nullptr; + + while ( mnIndex < mpFTA->GetLen() ) { - while ( mnIndex < mpFTA->GetLen() ) + FormulaToken* t = mpFTA->GetArray()[ mnIndex++ ]; + switch( t->GetType() ) { - FormulaToken* t = mpFTA->GetArray()[ mnIndex++ ]; - switch( t->GetType() ) + case svSingleRef: + case svDoubleRef: + case svIndex: + case svExternalSingleRef: + case svExternalDoubleRef: + case svExternalName: + return t; + default: { - case svSingleRef: - case svDoubleRef: - case svIndex: - case svExternalSingleRef: - case svExternalDoubleRef: - case svExternalName: - return t; - default: - { - // added to avoid warnings - } - } - } + // added to avoid warnings + } + } } return nullptr; } diff --git a/formula/source/ui/dlg/structpg.cxx b/formula/source/ui/dlg/structpg.cxx index 0eed0ff0dfaa..69a912206384 100644 --- a/formula/source/ui/dlg/structpg.cxx +++ b/formula/source/ui/dlg/structpg.cxx @@ -104,22 +104,22 @@ OUString StructPage::GetEntryText(const weld::TreeIter* pEntry) const const FormulaToken* StructPage::GetFunctionEntry(const weld::TreeIter* pEntry) { - if (pEntry) + if (!pEntry) + return nullptr; + + const FormulaToken * pToken = reinterpret_cast<const FormulaToken *>(m_xTlbStruct->get_id(*pEntry).toInt64()); + if (pToken) { - const FormulaToken * pToken = reinterpret_cast<const FormulaToken *>(m_xTlbStruct->get_id(*pEntry).toInt64()); - if (pToken) + if ( !(pToken->IsFunction() || pToken->GetParamCount() > 1 ) ) { - if ( !(pToken->IsFunction() || pToken->GetParamCount() > 1 ) ) - { - std::unique_ptr<weld::TreeIter> xParent(m_xTlbStruct->make_iterator(pEntry)); - if (!m_xTlbStruct->iter_parent(*xParent)) - return nullptr; - return GetFunctionEntry(xParent.get()); - } - else - { - return pToken; - } + std::unique_ptr<weld::TreeIter> xParent(m_xTlbStruct->make_iterator(pEntry)); + if (!m_xTlbStruct->iter_parent(*xParent)) + return nullptr; + return GetFunctionEntry(xParent.get()); + } + else + { + return pToken; } } return nullptr; diff --git a/fpicker/source/office/PlacesListBox.cxx b/fpicker/source/office/PlacesListBox.cxx index a7a90281bb11..050cee39c113 100644 --- a/fpicker/source/office/PlacesListBox.cxx +++ b/fpicker/source/office/PlacesListBox.cxx @@ -112,27 +112,26 @@ IMPL_LINK_NOARG( PlacesListBox, DoubleClick, weld::TreeView&, bool ) { sal_uInt16 nSelected = mxImpl->get_cursor_index(); PlacePtr pPlace = maPlaces[nSelected]; - if ( pPlace->IsEditable() && !pPlace->IsLocal( ) ) + if ( !pPlace->IsEditable() || pPlace->IsLocal( ) ) + return true; + PlaceEditDialog aDlg(mpDlg->getDialog(), pPlace); + short aRetCode = aDlg.run(); + switch (aRetCode) { - PlaceEditDialog aDlg(mpDlg->getDialog(), pPlace); - short aRetCode = aDlg.run(); - switch (aRetCode) + case RET_OK : + { + pPlace->SetName ( aDlg.GetServerName() ); + pPlace->SetUrl( aDlg.GetServerUrl() ); + mbUpdated = true; + break; + } + case RET_NO : { - case RET_OK : - { - pPlace->SetName ( aDlg.GetServerName() ); - pPlace->SetUrl( aDlg.GetServerUrl() ); - mbUpdated = true; - break; - } - case RET_NO : - { - RemovePlace(nSelected); - break; - } - default: - break; + RemovePlace(nSelected); + break; } + default: + break; } return true; } diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index 9f6a11da9ab1..33f42647e308 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -1831,51 +1831,51 @@ bool SvtFileDialog::IsolateFilterFromPath_Impl( OUString& rPath, OUString& rFilt rFilter.clear(); - if ( nWildCardPos != -1 ) - { - sal_Int32 nPathTokenPos = aReversePath.indexOf( '/' ); + if ( nWildCardPos == -1 ) + return true; - if ( nPathTokenPos == -1 ) - { - OUString aDelim( + sal_Int32 nPathTokenPos = aReversePath.indexOf( '/' ); + + if ( nPathTokenPos == -1 ) + { + OUString aDelim( #if defined(_WIN32) - '\\' + '\\' #else - '/' + '/' #endif - ); + ); - nPathTokenPos = aReversePath.indexOf( aDelim ); + nPathTokenPos = aReversePath.indexOf( aDelim ); #if !defined( UNX ) - if ( nPathTokenPos == -1 ) - { - nPathTokenPos = aReversePath.indexOf( ':' ); - } -#endif + if ( nPathTokenPos == -1 ) + { + nPathTokenPos = aReversePath.indexOf( ':' ); } +#endif + } - // check syntax - if ( nPathTokenPos != -1 ) + // check syntax + if ( nPathTokenPos != -1 ) + { + if ( nPathTokenPos < (rPath.getLength() - nWildCardPos - 1) ) { - if ( nPathTokenPos < (rPath.getLength() - nWildCardPos - 1) ) - { - ErrorHandler::HandleError( ERRCODE_SFX_INVALIDSYNTAX ); - return false; - } + ErrorHandler::HandleError( ERRCODE_SFX_INVALIDSYNTAX ); + return false; + } - // cut off filter - rFilter = aReversePath.copy( 0, nPathTokenPos ); - rFilter = comphelper::string::reverseString(rFilter); + // cut off filter + rFilter = aReversePath.copy( 0, nPathTokenPos ); + rFilter = comphelper::string::reverseString(rFilter); - // determine folder - rPath = aReversePath.copy( nPathTokenPos ); - rPath = comphelper::string::reverseString(rPath); - } - else - { - rFilter = rPath; - rPath.clear(); - } + // determine folder + rPath = aReversePath.copy( nPathTokenPos ); + rPath = comphelper::string::reverseString(rPath); + } + else + { + rFilter = rPath; + rPath.clear(); } return true; diff --git a/framework/source/helper/dockingareadefaultacceptor.cxx b/framework/source/helper/dockingareadefaultacceptor.cxx index d167bc11157f..59a43a1e321a 100644 --- a/framework/source/helper/dockingareadefaultacceptor.cxx +++ b/framework/source/helper/dockingareadefaultacceptor.cxx @@ -64,32 +64,30 @@ sal_Bool SAL_CALL DockingAreaDefaultAcceptor::requestDockingAreaSpace( const css // Try to "lock" the frame for access to taskscontainer. css::uno::Reference< XFrame > xFrame( m_xOwner ); - if ( xFrame.is() ) - { - css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() ); - css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() ); - - if ( xContainerWindow.is() && xComponentWindow.is() ) - { - css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY ); - // Convert relative size to output size. - css::awt::Rectangle aRectangle = xContainerWindow->getPosSize(); - css::awt::DeviceInfo aInfo = xDevice->getInfo(); - css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset , - aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); - - css::awt::Size aMinSize( 0, 0 ); // = xLayoutConstraints->getMinimumSize(); - - // Check if request border space would decrease component window size below minimum size - if ((( aSize.Width - RequestedSpace.X - RequestedSpace.Width ) < aMinSize.Width ) || - (( aSize.Height - RequestedSpace.Y - RequestedSpace.Height ) < aMinSize.Height ) ) - return false; - - return true; - } - } + if ( !xFrame.is() ) + return false; + + css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() ); + css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() ); + + if ( !xContainerWindow.is() || !xComponentWindow.is() ) + return false; + + css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY ); + // Convert relative size to output size. + css::awt::Rectangle aRectangle = xContainerWindow->getPosSize(); + css::awt::DeviceInfo aInfo = xDevice->getInfo(); + css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset , + aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); + + css::awt::Size aMinSize( 0, 0 ); // = xLayoutConstraints->getMinimumSize(); + + // Check if request border space would decrease component window size below minimum size + if ((( aSize.Width - RequestedSpace.X - RequestedSpace.Width ) < aMinSize.Width ) || + (( aSize.Height - RequestedSpace.Y - RequestedSpace.Height ) < aMinSize.Height ) ) + return false; - return false; + return true; } void SAL_CALL DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::Rectangle& BorderSpace ) diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index e02f57e4345e..0d1cc619da89 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -513,130 +513,130 @@ bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElem std::unique_ptr<GlobalSettings> &rGlobalSettings, bool &bInGlobalSettings, const Reference< XComponentContext > &rComponentContext ) { - if ( rPersistentWindowState.is() ) - { - bool bGetSettingsState( false ); + if ( !rPersistentWindowState.is() ) + return false; - SolarMutexClearableGuard aWriteLock; - bool bGlobalSettings( bInGlobalSettings ); - if ( rGlobalSettings == nullptr ) - { - rGlobalSettings.reset( new GlobalSettings( rComponentContext ) ); - bGetSettingsState = true; - } - GlobalSettings* pGlobalSettings = rGlobalSettings.get(); - aWriteLock.clear(); + bool bGetSettingsState( false ); - try + SolarMutexClearableGuard aWriteLock; + bool bGlobalSettings( bInGlobalSettings ); + if ( rGlobalSettings == nullptr ) + { + rGlobalSettings.reset( new GlobalSettings( rComponentContext ) ); + bGetSettingsState = true; + } + GlobalSettings* pGlobalSettings = rGlobalSettings.get(); + aWriteLock.clear(); + + try + { + Sequence< PropertyValue > aWindowState; + if ( rPersistentWindowState->hasByName( aName ) && (rPersistentWindowState->getByName( aName ) >>= aWindowState) ) { - Sequence< PropertyValue > aWindowState; - if ( rPersistentWindowState->hasByName( aName ) && (rPersistentWindowState->getByName( aName ) >>= aWindowState) ) + bool bValue( false ); + for ( PropertyValue const & rProp : std::as_const(aWindowState) ) { - bool bValue( false ); - for ( PropertyValue const & rProp : std::as_const(aWindowState) ) + if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKED ) { - if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKED ) - { - if ( rProp.Value >>= bValue ) - rElementData.m_bFloating = !bValue; - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_VISIBLE ) - { - if ( rProp.Value >>= bValue ) - rElementData.m_bVisible = bValue; - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKINGAREA ) - { - ui::DockingArea eDockingArea; - if ( rProp.Value >>= eDockingArea ) - rElementData.m_aDockedData.m_nDockedArea = eDockingArea; - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKPOS ) - { - awt::Point aPoint; - if (rProp.Value >>= aPoint) - { - //tdf#90256 repair these broken Docking positions - if (aPoint.X < 0) - aPoint.X = SAL_MAX_INT32; - if (aPoint.Y < 0) - aPoint.Y = SAL_MAX_INT32; - rElementData.m_aDockedData.m_aPos = aPoint; - } - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_POS ) - { - awt::Point aPoint; - if ( rProp.Value >>= aPoint ) - rElementData.m_aFloatingData.m_aPos = aPoint; - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_SIZE ) - { - awt::Size aSize; - if ( rProp.Value >>= aSize ) - rElementData.m_aFloatingData.m_aSize = aSize; - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_UINAME ) - rProp.Value >>= rElementData.m_aUIName; - else if ( rProp.Name == WINDOWSTATE_PROPERTY_STYLE ) - { - sal_Int32 nStyle = 0; - if ( rProp.Value >>= nStyle ) - rElementData.m_nStyle = static_cast<ButtonType>( nStyle ); - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_LOCKED ) - { - if ( rProp.Value >>= bValue ) - rElementData.m_aDockedData.m_bLocked = bValue; - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_CONTEXT ) - { - if ( rProp.Value >>= bValue ) - rElementData.m_bContextSensitive = bValue; - } - else if ( rProp.Name == WINDOWSTATE_PROPERTY_NOCLOSE ) + if ( rProp.Value >>= bValue ) + rElementData.m_bFloating = !bValue; + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_VISIBLE ) + { + if ( rProp.Value >>= bValue ) + rElementData.m_bVisible = bValue; + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKINGAREA ) + { + ui::DockingArea eDockingArea; + if ( rProp.Value >>= eDockingArea ) + rElementData.m_aDockedData.m_nDockedArea = eDockingArea; + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKPOS ) + { + awt::Point aPoint; + if (rProp.Value >>= aPoint) { - if ( rProp.Value >>= bValue ) - rElementData.m_bNoClose = bValue; + //tdf#90256 repair these broken Docking positions + if (aPoint.X < 0) + aPoint.X = SAL_MAX_INT32; + if (aPoint.Y < 0) + aPoint.Y = SAL_MAX_INT32; + rElementData.m_aDockedData.m_aPos = aPoint; } } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_POS ) + { + awt::Point aPoint; + if ( rProp.Value >>= aPoint ) + rElementData.m_aFloatingData.m_aPos = aPoint; + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_SIZE ) + { + awt::Size aSize; + if ( rProp.Value >>= aSize ) + rElementData.m_aFloatingData.m_aSize = aSize; + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_UINAME ) + rProp.Value >>= rElementData.m_aUIName; + else if ( rProp.Name == WINDOWSTATE_PROPERTY_STYLE ) + { + sal_Int32 nStyle = 0; + if ( rProp.Value >>= nStyle ) + rElementData.m_nStyle = static_cast<ButtonType>( nStyle ); + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_LOCKED ) + { + if ( rProp.Value >>= bValue ) + rElementData.m_aDockedData.m_bLocked = bValue; + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_CONTEXT ) + { + if ( rProp.Value >>= bValue ) + rElementData.m_bContextSensitive = bValue; + } + else if ( rProp.Name == WINDOWSTATE_PROPERTY_NOCLOSE ) + { ... etc. - the rest is truncated