reportdesign/source/core/api/ReportEngineJFree.cxx |   72 ++++++++++-----------
 reportdesign/source/filter/xml/xmlExport.cxx       |   10 +-
 2 files changed, 40 insertions(+), 42 deletions(-)

New commits:
commit 38c0897854f1e217f256535cc9acac221752d9a0
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue May 20 17:30:19 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed May 21 08:09:06 2025 +0200

    reportdesign: Switch OSL_ENSURE -> assert
    
    Change-Id: Id9613b3a1b7c3bcea8f4951db6c5057d89829fba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185570
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/reportdesign/source/filter/xml/xmlExport.cxx 
b/reportdesign/source/filter/xml/xmlExport.cxx
index 8d1080f8f945..14c416e2333d 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -385,7 +385,7 @@ void ORptExport::exportComponent(const 
Reference<XReportComponent>& _xReportComp
 
 void ORptExport::exportFormatConditions(const Reference<XReportControlModel>& 
_xReportElement)
 {
-    OSL_ENSURE(_xReportElement.is(),"_xReportElement is NULL -> GPF");
+    assert(_xReportElement.is() && "_xReportElement is NULL -> GPF");
     const sal_Int32 nCount = _xReportElement->getCount();
     try
     {
@@ -409,7 +409,7 @@ void ORptExport::exportFormatConditions(const 
Reference<XReportControlModel>& _x
 
 void ORptExport::exportReportElement(const Reference<XReportControlModel>& 
_xReportElement)
 {
-    OSL_ENSURE(_xReportElement.is(),"_xReportElement is NULL -> GPF");
+    assert(_xReportElement.is() && "_xReportElement is NULL -> GPF");
     if ( !_xReportElement->getPrintWhenGroupChange() )
         AddAttribute(XML_NAMESPACE_REPORT, XML_PRINT_WHEN_GROUP_CHANGE, 
XML_FALSE );
 
@@ -489,7 +489,7 @@ void ORptExport::collectStyleNames(XmlStyleFamily _nFamily, 
const ::std::vector<
 
 void ORptExport::exportSectionAutoStyle(const Reference<XSection>& _xProp)
 {
-    OSL_ENSURE(_xProp != nullptr,"Section is NULL -> GPF");
+    assert(_xProp && "Section is NULL -> GPF");
     exportAutoStyle(_xProp);
 
     Reference<XReportDefinition> xReport = _xProp->getReportDefinition();
@@ -689,7 +689,7 @@ void ORptExport::exportReportComponentAutoStyles(const 
Reference<XSection>& _xPr
 
 void ORptExport::exportSection(const Reference<XSection>& _xSection,bool 
bHeader)
 {
-    OSL_ENSURE(_xSection.is(),"Section is NULL -> GPF");
+    assert(_xSection.is() && "Section is NULL -> GPF");
     AddAttribute(XML_NAMESPACE_TABLE, XML_NAME,_xSection->getName());
 
     if ( !_xSection->getVisible() )
@@ -1019,7 +1019,7 @@ void ORptExport::exportGroup(const 
Reference<XReportDefinition>& _xReportDefinit
     if ( _nPos >= 0 && _nPos < nCount )
     {
         Reference<XGroup> xGroup(xGroups->getByIndex(_nPos),uno::UNO_QUERY);
-        OSL_ENSURE(xGroup.is(),"No Group prepare for GPF");
+        assert(xGroup.is() && "No Group prepare for GPF");
         if ( _bExportAutoStyle )
         {
             if ( xGroup->getHeaderOn() )
commit f2c843540a7c4b6228bebeedc61fe7c463e7c9f0
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue May 20 17:20:34 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed May 21 08:09:01 2025 +0200

    reportdesign: Flatten OReportEngineJFree::createDocumentAlive
    
    Add early returns to decrease nesting level.
    
    (`git show --ignore-space-change` helps see the
    "actual change" more easily.)
    
    Change-Id: Ib51b2665b8a680e310cc3f9927959838db4ef6e8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185569
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/reportdesign/source/core/api/ReportEngineJFree.cxx 
b/reportdesign/source/core/api/ReportEngineJFree.cxx
index 1d0ee4af1b40..d90bfd3430c9 100644
--- a/reportdesign/source/core/api/ReportEngineJFree.cxx
+++ b/reportdesign/source/core/api/ReportEngineJFree.cxx
@@ -246,47 +246,45 @@ uno::Reference< frame::XModel > SAL_CALL 
OReportEngineJFree::createDocumentAlive
 
 uno::Reference< frame::XModel > OReportEngineJFree::createDocumentAlive( const 
uno::Reference< frame::XFrame >& _frame,bool _bHidden )
 {
-    uno::Reference< frame::XModel > xModel;
     OUString sOutputName = getNewOutputName(); // starts implicitly the report 
generator
-    if ( !sOutputName.isEmpty() )
+    if (sOutputName.isEmpty())
+        return nullptr;
+
+    ::osl::MutexGuard aGuard(m_aMutex);
+    ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
+    uno::Reference<frame::XComponentLoader> xFrameLoad(_frame,uno::UNO_QUERY);
+    if ( !xFrameLoad.is() )
     {
-        ::osl::MutexGuard aGuard(m_aMutex);
-        ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
-        uno::Reference<frame::XComponentLoader> 
xFrameLoad(_frame,uno::UNO_QUERY);
-        if ( !xFrameLoad.is() )
-        {
-            // if there is no frame given, find the right
-            xFrameLoad = frame::Desktop::create(m_xContext);
-            sal_Int32 const nFrameSearchFlag = frame::FrameSearchFlag::TASKS | 
frame::FrameSearchFlag::CREATE;
-            uno::Reference< frame::XFrame> xFrame = uno::Reference< 
frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame(u"_blank"_ustr,nFrameSearchFlag);
-            xFrameLoad.set( xFrame,uno::UNO_QUERY);
-        }
+        // if there is no frame given, find the right
+        xFrameLoad = frame::Desktop::create(m_xContext);
+        sal_Int32 const nFrameSearchFlag = frame::FrameSearchFlag::TASKS | 
frame::FrameSearchFlag::CREATE;
+        uno::Reference< frame::XFrame> xFrame = uno::Reference< 
frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame(u"_blank"_ustr,nFrameSearchFlag);
+        xFrameLoad.set( xFrame,uno::UNO_QUERY);
+    }
 
-        if ( xFrameLoad.is() )
-        {
-            uno::Sequence < beans::PropertyValue > aArgs( _bHidden ? 3 : 2 );
-            auto pArgs = aArgs.getArray();
-            sal_Int32 nLen = 0;
-            pArgs[nLen].Name = "AsTemplate";
-            pArgs[nLen++].Value <<= false;
-
-            pArgs[nLen].Name = "ReadOnly";
-            pArgs[nLen++].Value <<= true;
-
-            if ( _bHidden )
-            {
-                pArgs[nLen].Name = "Hidden";
-                pArgs[nLen++].Value <<= true;
-            }
-
-            xModel.set( xFrameLoad->loadComponentFromURL(
-                sOutputName,
-                OUString(), // empty frame name
-                0,
-                aArgs
-                ),uno::UNO_QUERY);
-        }
+    if (!xFrameLoad.is())
+        return nullptr;
+
+    uno::Sequence < beans::PropertyValue > aArgs( _bHidden ? 3 : 2 );
+    auto pArgs = aArgs.getArray();
+    sal_Int32 nLen = 0;
+    pArgs[nLen].Name = "AsTemplate";
+    pArgs[nLen++].Value <<= false;
+
+    pArgs[nLen].Name = "ReadOnly";
+    pArgs[nLen++].Value <<= true;
+
+    if ( _bHidden )
+    {
+        pArgs[nLen].Name = "Hidden";
+        pArgs[nLen++].Value <<= true;
     }
+
+    uno::Reference<frame::XModel> xModel(
+        xFrameLoad->loadComponentFromURL(sOutputName,
+                                         OUString(), // empty frame name
+                                         0, aArgs),
+        uno::UNO_QUERY);
     return xModel;
 }
 

Reply via email to