[Libreoffice-commits] core.git: sw/source

Bjoern Michaelsen (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 26 19:57:23 UTC 2020


 sw/source/core/text/EnhancedPDFExportHelper.cxx |   89 ++++++++++--------------
 1 file changed, 39 insertions(+), 50 deletions(-)

New commits:
commit bbecc4813b4d88541a5e343e9bab8e2ed4de800f
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Tue Feb 25 22:42:20 2020 +0100
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Wed Feb 26 20:56:42 2020 +0100

    use GatherFields
    
    Change-Id: Ia60061ae35c1822ebd52f109f128510eb2454140
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89488
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 264e7db82580..823bde78b662 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1551,60 +1551,49 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
 
         if ( pPDFExtOutDevData->GetIsExportNotes() )
         {
-            SwFieldType* pType = mrSh.GetFieldType( SwFieldIds::Postit, OUString() );
-            SwIterator<SwFormatField,SwFieldType> aIter( *pType );
-            for( SwFormatField* pFirst = aIter.First(); pFirst; )
+            std::vector<SwFormatField*> vpFields;
+            mrSh.GetFieldType(SwFieldIds::Postit, OUString())->GatherFields(vpFields);
+            for(auto pFormatField : vpFields)
             {
-                if( pFirst->GetTextField() && pFirst->IsFieldInDoc() )
+                const SwTextNode* pTNd = pFormatField->GetTextField()->GetpTextNode();
+                OSL_ENSURE(nullptr != pTNd, "Enhanced pdf export - text node is missing");
+
+                // 1. Check if the whole paragraph is hidden
+                // 2. Move to the field
+                // 3. Check for hidden text attribute
+                if(pTNd->IsHidden() || !mrSh.GotoFormatField(*pFormatField) || mrSh.SelectHiddenRange())
                 {
-                    const SwTextNode* pTNd = pFirst->GetTextField()->GetpTextNode();
-                    OSL_ENSURE( nullptr != pTNd, "Enhanced pdf export - text node is missing" );
-
-                    // 1. Check if the whole paragraph is hidden
-                    // 2. Move to the field
-                    // 3. Check for hidden text attribute
-                    if ( !pTNd->IsHidden() &&
-                          mrSh.GotoFormatField( *pFirst ) &&
-                         !mrSh.SelectHiddenRange() )
-                    {
-                        // Link Rectangle
-                        const SwRect& rNoteRect = mrSh.GetCharRect();
-                        const SwPageFrame* pCurrPage =
-                            static_cast<const SwPageFrame*>( mrSh.GetLayout()->Lower() );
+                    mrSh.SwCursorShell::ClearMark();
+                    continue;
+                }
+                // Link Rectangle
+                const SwRect& rNoteRect = mrSh.GetCharRect();
+                const SwPageFrame* pCurrPage = static_cast<const SwPageFrame*>(mrSh.GetLayout()->Lower());
 
-                        // Link PageNums
-                        std::vector<sal_Int32> aNotePageNums = CalcOutputPageNums( rNoteRect );
-                        for (sal_Int32 aNotePageNum : aNotePageNums)
-                        {
-                            // Link Note
-                            vcl::PDFNote aNote;
-
-                            // Use the NumberFormatter to get the date string:
-                            const SwPostItField* pField = static_cast<SwPostItField*>(pFirst->GetField());
-                            SvNumberFormatter* pNumFormatter = pDoc->GetNumberFormatter();
-                            const Date aDateDiff( pField->GetDate() -
-                                                 pNumFormatter->GetNullDate() );
-                            const sal_uLong nFormat =
-                                pNumFormatter->GetStandardFormat( SvNumFormatType::DATE, pField->GetLanguage() );
-                            OUString sDate;
-                            Color* pColor;
-                            pNumFormatter->GetOutputString( aDateDiff.GetDate(), nFormat, sDate, &pColor );
-
-                            // The title should consist of the author and the date:
-                            if(pField->GetResolved())
-                                aNote.Title = pField->GetPar1() + ", " + sDate + ", " + SwResId(STR_RESOLVED);
-                            else
-                                aNote.Title = pField->GetPar1() + ", " + sDate;
-                            // Guess what the contents contains...
-                            aNote.Contents = pField->GetText();
-
-                            // Link Export
-                            tools::Rectangle aRect(SwRectToPDFRect(pCurrPage, rNoteRect.SVRect()));
-                            pPDFExtOutDevData->CreateNote(aRect, aNote, aNotePageNum);
-                        }
-                    }
+                // Link PageNums
+                std::vector<sal_Int32> aNotePageNums = CalcOutputPageNums(rNoteRect);
+                for (sal_Int32 aNotePageNum : aNotePageNums)
+                {
+
+                    // Use the NumberFormatter to get the date string:
+                    const SwPostItField* pField = static_cast<SwPostItField*>(pFormatField->GetField());
+                    SvNumberFormatter* pNumFormatter = pDoc->GetNumberFormatter();
+                    const Date aDateDiff(pField->GetDate() - pNumFormatter->GetNullDate());
+                    const sal_uLong nFormat = pNumFormatter->GetStandardFormat(SvNumFormatType::DATE, pField->GetLanguage());
+                    OUString sDate;
+                    Color* pColor;
+                    pNumFormatter->GetOutputString(aDateDiff.GetDate(), nFormat, sDate, &pColor);
+
+                    vcl::PDFNote aNote;
+                    // The title should consist of the author and the date:
+                    aNote.Title = pField->GetPar1() + ", " + sDate + ", " + (pField->GetResolved() ? SwResId(STR_RESOLVED) : "");
+                    // Guess what the contents contains...
+                    aNote.Contents = pField->GetText();
+
+                    // Link Export
+                    tools::Rectangle aRect(SwRectToPDFRect(pCurrPage, rNoteRect.SVRect()));
+                    pPDFExtOutDevData->CreateNote(aRect, aNote, aNotePageNum);
                 }
-                pFirst = aIter.Next();
                 mrSh.SwCursorShell::ClearMark();
             }
         }


More information about the Libreoffice-commits mailing list