sw/inc/unochart.hxx                 |    3 ++-
 sw/source/core/doc/docchart.cxx     |   23 ++++++++++++++++++++++-
 sw/source/core/unocore/unochart.cxx |    6 +++++-
 3 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit d769e75de28a1afbb1df31b48840626cb35ed7ba
Author:     Armin Le Grand (Allotropia) <armin.le.gr...@me.com>
AuthorDate: Tue Jan 18 17:43:16 2022 +0100
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Fri Jan 21 09:46:18 2022 +0100

    tdf#122995 Trigger Chart refresh directly in UpdateCharts for SW
    
    For OLE/Charts in SW we do not (yet) have a refresh
    mechanism or embedding of the primitive represetation, so this
    needs to be done locally here (simple solution).
    To have the Chart already invalidated at the next repaint,
    I needed to add a 'immediate' mode to InvalidateTable.
    
    Note: The text there claiming that the framework should do this
    is correct, but as long as the mechanism is incomplete (VC/VOC/OC
    in SW) direct refresh is needed.
    
    Change-Id: I3c845b3ec46fbb494e7bce163cfe105145421450
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128572
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx
index 2df27f9dbda2..ff4e24e764d6 100644
--- a/sw/inc/unochart.hxx
+++ b/sw/inc/unochart.hxx
@@ -175,7 +175,8 @@ public:
     void        RemoveDataSequence( const SwTable &rTable, 
css::uno::Reference< css::chart2::data::XDataSequence > const &rxDataSequence );
 
     // will send modified events for all data-sequences of the table
-    void        InvalidateTable( const SwTable *pTable );
+    // tdf#122995 added Immediate-Mode to allow non-timer-delayed Chart 
invalidation
+    void        InvalidateTable( const SwTable *pTable, bool bImmediate = 
false );
     void        DeleteBox( const SwTable *pTable, const SwTableBox &rBox );
     void        DisposeAllDataSequences( const SwTable *pTable );
 
diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx
index 693f16886468..27d94c09a242 100644
--- a/sw/source/core/doc/docchart.cxx
+++ b/sw/source/core/doc/docchart.cxx
@@ -107,9 +107,30 @@ void SwDoc::UpdateCharts_( const SwTable& rTable, 
SwViewShell const & rVSh ) con
             aName == pONd->GetChartTableName() &&
             pONd->getLayoutFrame( rVSh.GetLayout() ) )
         {
+            // tdf#122995 for OLE/Charts in SW we do not (yet) have a refresh
+            // mechanism or embedding of the primitive representation, so this
+            // needs to be done locally here (simplest solution).
+            bool bImmediateMode(false);
+
+            if(pONd->IsChart())
+            {
+                // refresh to trigger repaint
+                const SwRect aChartRect(pONd->FindLayoutRect());
+                if(!aChartRect.IsEmpty())
+                    const_cast<SwViewShell 
&>(rVSh).InvalidateWindows(aChartRect);
+
+                // forced refresh of the chart's primitive representation
+                pONd->GetOLEObj().resetBufferedData();
+
+                // InvalidateTable using the Immediate-Mode, else the chart 
will
+                // not yet know that it is invalidated at the next repaint and 
create
+                // the same graphical representation again
+                bImmediateMode = true;
+            }
+
             SwChartDataProvider *pPCD = 
getIDocumentChartDataProviderAccess().GetChartDataProvider();
             if (pPCD)
-                pPCD->InvalidateTable( &rTable );
+                pPCD->InvalidateTable( &rTable, bImmediateMode );
             // following this the framework will now take care of repainting
             // the chart or it's replacement image...
         }
diff --git a/sw/source/core/unocore/unochart.cxx 
b/sw/source/core/unocore/unochart.cxx
index b32a0dc35b80..02984b804866 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1420,7 +1420,7 @@ void SwChartDataProvider::RemoveDataSequence( const 
SwTable &rTable, uno::Refere
     m_aDataSequences[ &rTable ].erase( rxDataSequence );
 }
 
-void SwChartDataProvider::InvalidateTable( const SwTable *pTable )
+void SwChartDataProvider::InvalidateTable( const SwTable *pTable, bool 
bImmediate )
 {
     OSL_ENSURE( pTable, "table pointer is NULL" );
     if (!pTable)
@@ -1440,6 +1440,10 @@ void SwChartDataProvider::InvalidateTable( const SwTable 
*pTable )
             xRef->setModified( true );
         }
     }
+
+    // tdf#122995 added Immediate-mode to allow non-timer-delayed Chart 
invalidation
+    if (bImmediate && !m_bDisposed)
+       
pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().Disconnect();
 }
 
 void SwChartDataProvider::DeleteBox( const SwTable *pTable, const SwTableBox 
&rBox )

Reply via email to