include/vcl/print.hxx                               |    4 ---
 sc/source/ui/unoobj/docuno.cxx                      |   19 +++++++++++++-----
 sw/source/writerfilter/dmapper/DomainMapper.cxx     |    4 +--
 sw/source/writerfilter/dmapper/NumberingManager.cxx |   21 ++++++++------------
 sw/source/writerfilter/dmapper/SettingsTable.cxx    |   11 +++++-----
 sw/source/writerfilter/dmapper/TableManager.cxx     |    4 +--
 vcl/source/gdi/print.cxx                            |    1 
 vcl/source/gdi/print3.cxx                           |   12 -----------
 8 files changed, 33 insertions(+), 43 deletions(-)

New commits:
commit 1707b9359a69f70c0fff294aaaf742d0f3a250c7
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Apr 16 12:27:42 2025 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Thu Apr 24 20:24:06 2025 +0200

    crashtesting: check getValue()
    
    According to sw/source/writerfilter/inc/dmapper/resourcemodel.hxx:384
    Returns value of the SPRM. Returns nullptr if the internal value is nullptr.
    
    Seen in https://shorturl.at/KVBYr
    
    Change-Id: Icfe015c8f39a3dc26ee1cd38c61c1956d562ee68
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184263
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit eedda19d84dde8f284b4e296bda5208503bf2a7c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184278
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index ef9aaca77f5e..1cc90c61e9a4 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -1543,8 +1543,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
     //needed for page properties
     SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext();
     const Value* pValue = rSprm.getValue();
-    sal_Int32 nIntValue = pValue->getInt();
-    const OUString sStringValue = pValue->getString();
+    sal_Int32 nIntValue = (pValue ? pValue->getInt() : 0);
+    OUString sStringValue = pValue ? pValue->getString() : OUString();
 
     switch(nSprmId)
     {
diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx 
b/sw/source/writerfilter/dmapper/SettingsTable.cxx
index cba9292e93d3..be728474b577 100644
--- a/sw/source/writerfilter/dmapper/SettingsTable.cxx
+++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx
@@ -257,7 +257,8 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
     sal_uInt32 nSprmId = rSprm.getId();
 
     const Value* pValue = rSprm.getValue();
-    sal_Int32 nIntValue = pValue->getInt();
+    sal_Int32 nIntValue = (pValue ? pValue->getInt() : 0);
+    OUString sStringValue = pValue ? pValue->getString() : OUString();
 
     switch(nSprmId)
     {
@@ -295,10 +296,10 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
     case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: //  92554; // Do 
Not Include Content in Text Boxes, Footnotes, and Endnotes in Document 
Statistics)
     break;
     case NS_ooxml::LN_CT_Settings_decimalSymbol: //  92562;
-        m_pImpl->m_sDecimalSymbol = pValue->getString();
+        m_pImpl->m_sDecimalSymbol = sStringValue;
     break;
     case NS_ooxml::LN_CT_Settings_listSeparator: //  92563;
-        m_pImpl->m_sListSeparator = pValue->getString();
+        m_pImpl->m_sListSeparator = sStringValue;
     break;
     case NS_ooxml::LN_CT_Settings_rsids: //  92549; revision save Ids - 
probably not necessary
     break;
@@ -353,7 +354,7 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
     case NS_ooxml::LN_CT_MailMerge_query:
     {
         // try to get the "database.table" name from the query saved previously
-        OUString sVal = pValue->getString();
+        OUString sVal = sStringValue;
         if ( sVal.endsWith("$") && sVal.indexOf(".dbo.") > 0 )
         {
             sal_Int32 nSpace = sVal.lastIndexOf(' ');
diff --git a/sw/source/writerfilter/dmapper/TableManager.cxx 
b/sw/source/writerfilter/dmapper/TableManager.cxx
index f73d61b145ac..6f16d9e0c01e 100644
--- a/sw/source/writerfilter/dmapper/TableManager.cxx
+++ b/sw/source/writerfilter/dmapper/TableManager.cxx
@@ -261,8 +261,8 @@ bool TableManager::sprm(Sprm& rSprm)
         case NS_ooxml::LN_tblDepth:
         {
             const Value* pValue = rSprm.getValue();
-
-            cellDepth(pValue->getInt());
+            sal_Int32 nIntValue = pValue ? pValue->getInt() : 0;
+            cellDepth(nIntValue);
         }
         break;
         case NS_ooxml::LN_inTbl:
commit 4a3764b0c284824b085e423d8a734825ffd029b3
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Apr 9 22:44:11 2025 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Thu Apr 24 20:23:49 2025 +0200

    tdf#166107: remove unnecessary resetPrintArea()
    
    In the mentioned regression, resetPrintArea() was responsible for reverting 
the print area in Calc, which was set by the Print Dialog,
    back to the one defined by the Page Styles.
    It was implemented in the print-related part that is used by all modules 
but this is a Calc-specific issue.
    Therefore, in this commit, resetPrintArea() was removed and it made
    more sense to fix the print area issue in the Calc modul.
    
    from
    commit 364f0bb1cac0e12f5f926857f61c2f329a353ec7
    Author: Tibor Nagy <tibor.nagy.ext...@allotropia.de>
    Date:   Wed Feb 28 11:13:10 2024 +0100
    
        tdf#155218 sc: fix regression page orientation in print dialog
    
    Change-Id: I3767c0685addefb9b2fb16bfc7cf967a0f332272
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183948
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit eccf4cd57a1970b296e12296bf0f5a0f52e917a7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184292
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 962308e327dc..f6107f414566 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -93,7 +93,6 @@ private:
     bool                        mbNewJobSetup;
     bool                        mbSinglePrintJobs;
     bool                        mbUsePrintSetting;
-    bool                        mbResetPrintArea;
 
     SAL_DLLPRIVATE void         ImplInitData();
     SAL_DLLPRIVATE void         ImplInit( SalPrinterQueueInfo* pInfo );
@@ -223,8 +222,6 @@ public:
     SAL_DLLPRIVATE void         SetPrinterOptions( const 
vcl::printer::Options& rOptions );
     const vcl::printer::Options& GetPrinterOptions() const { return( 
*mpPrinterOptions ); }
 
-    void                        ResetPrintArea(bool bReset) { mbResetPrintArea 
= bReset; }
-    bool                        IsPrintAreaReset() { return mbResetPrintArea; }
     void                        SetUsePrintDialogSetting(bool bUsed) { 
mbUsePrintSetting = bUsed; }
     bool                        IsUsePrintDialogSetting() { return 
mbUsePrintSetting; }
     void                        SetPrintPageSize(Size aPrintPageSize) { 
maPrintPageSize = aPrintPageSize; }
@@ -489,7 +486,6 @@ public:
     SAL_DLLPRIVATE    bool              getPrinterModified() const;
     SAL_DLLPRIVATE    void              pushPropertiesToPrinter();
     SAL_DLLPRIVATE    void              resetPaperToLastConfigured();
-    SAL_DLLPRIVATE    void              resetPrintArea();
                       void              setJobState( css::view::PrintableState 
);
     SAL_DLLPRIVATE    void              setupPrinter( weld::Window* 
i_pDlgParent );
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 19ef534be1e6..ee5ba4be9941 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1862,7 +1862,6 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const 
uno::Any& aSelection,
         return 0;
 
     Size aPrintPageSize;
-    bool bPrintAreaReset = false;
     bool bPrintPageLandscape = false;
     bool bUsePrintDialogSetting = false;
     Printer* pPrinter = lcl_GetPrinter(rOptions);
@@ -1874,16 +1873,13 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const 
uno::Any& aSelection,
             bPrintPageLandscape = (pPrinter->GetOrientation() == 
Orientation::Landscape);
             aPrintPageSize = 
lcl_GetPrintPageSize(pPrinter->GetPrintPageSize());
         }
-        else // reset the print area created by the Print Dialog to the page 
style's print area.
-            bPrintAreaReset = pPrinter->IsPrintAreaReset();
     }
 
     //  The same ScPrintFuncCache object in pPrintFuncCache is used as long as
     //  the same selection is used (aStatus) and the document isn't changed
     //  (pPrintFuncCache is cleared in Notify handler)
 
-    if (!pPrintFuncCache || !pPrintFuncCache->IsSameSelection(aStatus) || 
bUsePrintDialogSetting
-        || bPrintAreaReset)
+    if (!pPrintFuncCache || !pPrintFuncCache->IsSameSelection(aStatus) || 
bUsePrintDialogSetting)
     {
         pPrintFuncCache.reset(new ScPrintFuncCache(pDocShell, aMark, 
std::move(aStatus), aPrintPageSize,
                                                    bPrintPageLandscape, 
bUsePrintDialogSetting));
@@ -2783,6 +2779,19 @@ void SAL_CALL ScModelObj::render( sal_Int32 
nSelRenderer, const uno::Any& aSelec
 
     (void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart, true, nullptr 
);
 
+    if (pPrinter)
+    {
+        // reset the print area created by the Print Dialog to the page 
style's print area
+        if (pPrinter->IsUsePrintDialogSetting())
+        {
+            bUsePrintDialogSetting = false;
+            if (m_pPrintState && m_pPrintState->nPrintTab == nTab && 
!pSelRange)
+                pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, 
*m_pPrintState,
+                                                 &aStatus.GetOptions(), 
aPrintPageSize,
+                                                 bPrintPageLandscape, 
bUsePrintDialogSetting));
+        }
+    }
+
     vcl::PDFExtOutDevData* pPDFData = 
dynamic_cast<vcl::PDFExtOutDevData*>(pDev->GetExtOutDevData());
     if (pPDFData && pPDFData->GetIsExportTaggedPDF() && bIsLastPage)
     {
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 8cc67e7d5e68..8b6a9f89ce56 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -455,7 +455,6 @@ void Printer::ImplInitData()
     mbNewJobSetup       = false;
     mbSinglePrintJobs   = false;
     mbUsePrintSetting   = false;
-    mbResetPrintArea    = false;
     mpInfoPrinter       = nullptr;
     mpPrinter           = nullptr;
     mpDisplayDev        = nullptr;
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 0cef1d915af2..75d28ca69688 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -588,7 +588,6 @@ bool Printer::ExecutePrintJob(const 
std::shared_ptr<PrinterController>& xControl
 
 void Printer::FinishPrintJob(const std::shared_ptr<PrinterController>& 
xController)
 {
-    xController->resetPrintArea();
     xController->resetPaperToLastConfigured();
     xController->jobFinished( xController->getJobState() );
 }
@@ -1048,17 +1047,6 @@ void 
vcl::ImplPrinterControllerData::resetPaperToLastConfigured()
     mxPrinter->Pop();
 }
 
-// reset the print area created by the Print Dialog to the page style's print 
area.
-void PrinterController::resetPrintArea()
-{
-    if (mpImplData->mxPrinter->IsUsePrintDialogSetting())
-    {
-        mpImplData->mxPrinter->ResetPrintArea(true);
-        mpImplData->mxPrinter->SetUsePrintDialogSetting(false);
-        getPageCount();
-    }
-}
-
 int PrinterController::getPageCountProtected() const
 {
     const MapMode aMapMode( MapUnit::Map100thMM );
commit 32aa024f8aa2cb9602653c3e829f64870c4ee5da
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Apr 17 01:27:53 2025 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Thu Apr 24 20:23:29 2025 +0200

    sw: fix warning C6011: Dereferencing NULL pointer 'rSprm.getValue()'
    
    Change-Id: I4ebd78319b0d47b34ab311a2f57a921bc8369aac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184302
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 6c8f4322ac2dad1d8ba4f4a8ad83edfcd00d0d63)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184312
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>

diff --git a/sw/source/writerfilter/dmapper/NumberingManager.cxx 
b/sw/source/writerfilter/dmapper/NumberingManager.cxx
index 7f5a415a425b..f7ce330816cf 100644
--- a/sw/source/writerfilter/dmapper/NumberingManager.cxx
+++ b/sw/source/writerfilter/dmapper/NumberingManager.cxx
@@ -826,6 +826,7 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
     static bool bIsStartVisited = false;
     const Value* pValue = rSprm.getValue();
     sal_Int32 nIntValue = pValue ? pValue->getInt() : 0;
+    OUString sStringValue = pValue ? pValue->getString() : OUString();
     switch( nSprmId )
     {
         case NS_ooxml::LN_CT_Numbering_abstractNum:
@@ -934,13 +935,12 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
         break;
         case NS_ooxml::LN_CT_Num_abstractNumId:
         {
-            sal_Int32 nAbstractNumId = rSprm.getValue()->getInt();
             ListDef* pListDef = dynamic_cast< ListDef* >( 
m_pCurrentDefinition.get( ) );
             if ( pListDef != nullptr )
             {
                 // The current def should be a ListDef
                 pListDef->SetAbstractDefinition(
-                       GetAbstractList( nAbstractNumId ) );
+                       GetAbstractList( nIntValue ) );
             }
         }
         break;
@@ -990,15 +990,15 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
             if (ListLevel::Pointer pCurrentLevel = 
m_pCurrentDefinition->GetCurrentLevel())
             {
                 SvxNumberFormat::LabelFollowedBy value = 
SvxNumberFormat::LISTTAB;
-                if( rSprm.getValue()->getString() == "tab" )
+                if( sStringValue == "tab" )
                     value = SvxNumberFormat::LISTTAB;
-                else if( rSprm.getValue()->getString() == "space" )
+                else if( sStringValue == "space" )
                     value = SvxNumberFormat::SPACE;
-                else if( rSprm.getValue()->getString() == "nothing" )
+                else if( sStringValue == "nothing" )
                     value = SvxNumberFormat::NOTHING;
                 else
                     SAL_WARN( "writerfilter", "Unknown ST_LevelSuffix value "
-                        << rSprm.getValue()->getString());
+                        << sStringValue);
                 pCurrentLevel->SetValue( nSprmId, value );
             }
         }
@@ -1066,11 +1066,10 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
         break;
         case NS_ooxml::LN_CT_Lvl_pStyle:
         {
-            OUString sStyleName = rSprm.getValue( )->getString( );
             if (ListLevel::Pointer pLevel = 
m_pCurrentDefinition->GetCurrentLevel())
             {
                 StyleSheetTablePtr pStylesTable = 
m_rDMapper.GetStyleSheetTable( );
-                const StyleSheetEntryPtr pStyle = 
pStylesTable->FindStyleSheetByISTD( sStyleName );
+                const StyleSheetEntryPtr pStyle = 
pStylesTable->FindStyleSheetByISTD( sStringValue );
                 pLevel->SetParaStyle( pStyle );
             }
         }
@@ -1095,14 +1094,12 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
         break;
         case NS_ooxml::LN_CT_AbstractNum_numStyleLink:
         {
-            OUString sStyleName = rSprm.getValue( )->getString( );
-            m_pCurrentDefinition->SetNumStyleLink(sStyleName);
+            m_pCurrentDefinition->SetNumStyleLink(sStringValue);
         }
         break;
         case NS_ooxml::LN_CT_AbstractNum_styleLink:
         {
-            OUString sStyleName = rSprm.getValue()->getString();
-            m_pCurrentDefinition->SetStyleLink(sStyleName);
+            m_pCurrentDefinition->SetStyleLink(sStringValue);
         }
         break;
         case NS_ooxml::LN_EG_RPrBase_rFonts: //contains font properties
diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx 
b/sw/source/writerfilter/dmapper/SettingsTable.cxx
index 7ec07453d4f6..cba9292e93d3 100644
--- a/sw/source/writerfilter/dmapper/SettingsTable.cxx
+++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx
@@ -313,7 +313,7 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
     break;
     case NS_ooxml::LN_CT_Settings_trackRevisions:
     {
-        m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
+        m_pImpl->m_bRecordChanges = bool(nIntValue);
     }
     break;
     case NS_ooxml::LN_CT_Settings_revisionView:

Reply via email to