[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - desktop/source include/LibreOfficeKit libreofficekit/source sc/inc sc/source
Szymon Kłos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 25 15:54:30 UTC 2019
desktop/source/lib/init.cxx | 3
include/LibreOfficeKit/LibreOfficeKitEnums.h | 16 ++
libreofficekit/source/gtk/lokdocview.cxx | 45 +++++++
sc/inc/scmod.hxx | 7 -
sc/source/ui/app/inputhdl.cxx | 157 ++++++++++++++++++++++++++-
sc/source/ui/app/inputwin.cxx | 12 +-
sc/source/ui/app/scmod.cxx | 34 +----
sc/source/ui/formdlg/formula.cxx | 75 ++++++------
sc/source/ui/inc/formula.hxx | 1
sc/source/ui/inc/inputhdl.hxx | 6 +
sc/source/ui/inc/output.hxx | 49 +++++++-
sc/source/ui/inc/tabvwsh.hxx | 7 +
sc/source/ui/miscdlgs/anyrefdg.cxx | 9 +
sc/source/ui/view/cellsh3.cxx | 4
sc/source/ui/view/gridwin.cxx | 2
sc/source/ui/view/gridwin4.cxx | 7 -
sc/source/ui/view/output.cxx | 114 ++++++++++++++++++-
sc/source/ui/view/tabview3.cxx | 3
sc/source/ui/view/tabview4.cxx | 13 ++
sc/source/ui/view/tabvwsh4.cxx | 2
sc/source/ui/view/tabvwsha.cxx | 2
sc/source/ui/view/tabvwshc.cxx | 11 +
22 files changed, 490 insertions(+), 89 deletions(-)
New commits:
commit d2727d1084a5b3f6dab2e4fc076f8054044f3b5e
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Sep 13 15:26:31 2018 +0200
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Sep 25 17:53:51 2019 +0200
Add reference marks callback
Change-Id: Ic749e138356392b0c327a30cff28055f06e23e2e
Reviewed-on: https://gerrit.libreoffice.org/79464
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/79529
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7208a536441d..1f4e24862d0d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1073,7 +1073,8 @@ void CallbackFlushHandler::queue(const int type, const char* data)
type != LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
type != LOK_CALLBACK_CURSOR_VISIBLE &&
type != LOK_CALLBACK_VIEW_CURSOR_VISIBLE &&
- type != LOK_CALLBACK_TEXT_SELECTION)
+ type != LOK_CALLBACK_TEXT_SELECTION &&
+ type != LOK_CALLBACK_REFERENCE_MARKS)
{
SAL_INFO("lok", "Skipping while painting [" << type << "]: [" << payload << "].");
return;
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index c34ed86e8f59..b28b51b0f19a 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -685,6 +685,20 @@ typedef enum
* cell.
*/
LOK_CALLBACK_TABLE_SELECTED = 44,
+
+ /*
+ * Show reference marks from payload.
+ *
+ * Example payload:
+ * {
+ * "marks": [
+ * { "rectangle": "3825, 3315, 1245, 2010", "color": "0000ff", "part": "0" },
+ * { "rectangle": "8925, 4335, 2520, 735", "color": "ff0000", "part": "0" },
+ * ...
+ * ]
+ * }
+ */
+ LOK_CALLBACK_REFERENCE_MARKS = 45,
}
LibreOfficeKitCallbackType;
@@ -803,6 +817,8 @@ static inline const char* lokCallbackTypeToString(int nType)
return "LOK_CALLBACK_CELL_AUTO_FILL_AREA";
case LOK_CALLBACK_TABLE_SELECTED:
return "LOK_CALLBACK_TABLE_SELECTED";
+ case LOK_CALLBACK_REFERENCE_MARKS:
+ return "LOK_CALLBACK_REFERENCE_MARKS";
}
assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index f48916298dbe..c3167b8222d9 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -139,6 +139,9 @@ struct LOKDocViewPrivateImpl
/// see them, can't modify them. Key is the view id.
std::map<int, ViewRectangle> m_aCellViewCursors;
gboolean m_bInDragGraphicSelection;
+ /// Position, size and color of the reference marks. The current view can only
+ /// see them, can't modify them. Key is the view id.
+ std::vector<std::pair<ViewRectangle, sal_uInt32>> m_aReferenceMarks;
/// @name Start/middle/end handle.
///@{
@@ -1363,6 +1366,27 @@ callback (gpointer pData)
case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
case LOK_CALLBACK_TABLE_SELECTED:
break; // TODO
+ case LOK_CALLBACK_REFERENCE_MARKS:
+ {
+ std::stringstream aStream(pCallback->m_aPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+
+ priv->m_aReferenceMarks.clear();
+
+ for(auto& rMark : aTree.get_child("marks"))
+ {
+ sal_uInt32 nColor = std::stoi(rMark.second.get<std::string>("color"), nullptr, 16);
+ std::string sRect = rMark.second.get<std::string>("rectangle");
+ sal_uInt32 nPart = std::stoi(rMark.second.get<std::string>("part"));
+
+ GdkRectangle aRect = payloadToRectangle(pDocView, sRect.c_str());
+ priv->m_aReferenceMarks.push_back(std::pair<ViewRectangle, sal_uInt32>(ViewRectangle(nPart, aRect), nColor));
+ }
+
+ gtk_widget_queue_draw(GTK_WIDGET(pDocView));
+ break;
+ }
default:
g_assert(false);
break;
@@ -1819,6 +1843,27 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
cairo_stroke(pCairo);
}
+ // Draw reference marks.
+ for (auto& rPair : priv->m_aReferenceMarks)
+ {
+ const ViewRectangle& rMark = rPair.first;
+ if (rMark.m_nPart != priv->m_nPartId)
+ continue;
+
+ sal_uInt32 nColor = rPair.second;
+ sal_uInt8 nRed = (nColor >> 16) & 0xff;
+ sal_uInt8 nGreen = (nColor >> 8) & 0xff;
+ sal_uInt8 nBlue = nColor & 0xff;
+ cairo_set_source_rgb(pCairo, nRed, nGreen, nBlue);
+ cairo_rectangle(pCairo,
+ twipToPixel(rMark.m_aRectangle.x, priv->m_fZoom),
+ twipToPixel(rMark.m_aRectangle.y, priv->m_fZoom),
+ twipToPixel(rMark.m_aRectangle.width, priv->m_fZoom),
+ twipToPixel(rMark.m_aRectangle.height, priv->m_fZoom));
+ cairo_set_line_width(pCairo, 2.0);
+ cairo_stroke(pCairo);
+ }
+
// View locks: they are colored.
for (auto& rPair : priv->m_aViewLockRectangles)
{
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index bbdadfd3fffd..f602fc50a808 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -86,6 +86,8 @@
#include <markdata.hxx>
#include <tokenarray.hxx>
#include <gridwin.hxx>
+#include <output.hxx>
+#include <fillinfo.hxx>
// Maximum Ranges in RangeFinder
#define RANGEFIND_MAX 64
@@ -281,6 +283,44 @@ ScTypedCaseStrSet::const_iterator findTextAll(
}
+void ScInputHandler::SendReferenceMarks( const SfxViewShell* pViewShell,
+ const std::vector<ReferenceMark>& rReferenceMarks )
+{
+ if ( !pViewShell )
+ return;
+
+ bool bSend = false;
+
+ std::stringstream ss;
+
+ ss << "{ \"marks\": [ ";
+
+ for ( size_t i = 0; i < rReferenceMarks.size(); i++ )
+ {
+ if ( rReferenceMarks[i].Is() )
+ {
+ if ( bSend )
+ ss << ", ";
+
+ ss << "{ \"rectangle\": \""
+ << rReferenceMarks[i].nX << ", "
+ << rReferenceMarks[i].nY << ", "
+ << rReferenceMarks[i].nWidth << ", "
+ << rReferenceMarks[i].nHeight << "\", "
+ "\"color\": \"" << rReferenceMarks[i].aColor.AsRGBHexString() << "\", "
+ "\"part\": \"" << rReferenceMarks[i].nTab << "\" } ";
+
+ bSend = true;
+ }
+ }
+
+ ss << " ] }";
+
+ OString aPayload = ss.str().c_str();
+ pViewShell->libreOfficeKitViewCallback(
+ LOK_CALLBACK_REFERENCE_MARKS, aPayload.getStr() );
+}
+
void ScInputHandler::InitRangeFinder( const OUString& rFormula )
{
DeleteRangeFinder();
@@ -380,6 +420,8 @@ handle_r1c1:
// Do not skip last separator; could be a quote (?)
}
+ UpdateLokReferenceMarks();
+
if (nCount)
{
mpEditEngine->SetUpdateMode( true );
@@ -388,6 +430,109 @@ handle_r1c1:
}
}
+static ReferenceMark lcl_GetReferenceMark( ScViewData& rViewData, ScDocShell* pDocSh,
+ long nX1, long nX2, long nY1, long nY2,
+ long nTab, const Color& rColor )
+{
+ ScSplitPos eWhich = rViewData.GetActivePart();
+
+ Point aScrPos = rViewData.GetScrPos( nX1, nY1, eWhich );
+ long nScrX = aScrPos.X();
+ long nScrY = aScrPos.Y();
+
+ double nPPTX = rViewData.GetPPTX();
+ double nPPTY = rViewData.GetPPTY();
+
+ Fraction aZoomX = rViewData.GetZoomX();
+ Fraction aZoomY = rViewData.GetZoomY();
+
+ ScTableInfo aTabInfo;
+ pDocSh->GetDocument().FillInfo( aTabInfo, nX1, nY1, nX2, nY2,
+ nTab, nPPTX, nPPTY, false, false );
+
+ ScOutputData aOutputData( nullptr, OUTTYPE_WINDOW, aTabInfo,
+ &( pDocSh->GetDocument() ), nTab,
+ nScrX, nScrY,
+ nX1, nY1, nX2, nY2,
+ nPPTX, nPPTY,
+ &aZoomX, &aZoomY );
+
+ return aOutputData.FillReferenceMark( nX1, nY1, nX2, nY2,
+ rColor );
+}
+
+void ScInputHandler::UpdateLokReferenceMarks()
+{
+ if ( !comphelper::LibreOfficeKit::isActive() || !pActiveViewSh )
+ return;
+
+ ScViewData& rViewData = pActiveViewSh->GetViewData();
+ ScDocShell* pDocSh = rViewData.GetDocShell();
+ ScRangeFindList* pRangeFinder = GetRangeFindList();
+
+ if ( !pRangeFinder && !rViewData.IsRefMode() )
+ return;
+
+ sal_uInt16 nAdditionalMarks = 0;
+ std::vector<ReferenceMark> aReferenceMarks( 1 );
+
+ if ( rViewData.IsRefMode() )
+ {
+ nAdditionalMarks = 1;
+
+ const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
+ Color aRefColor( rColorCfg.GetColorValue( svtools::CALCREFERENCE ).nColor );
+ long nX1 = rViewData.GetRefStartX();
+ long nX2 = rViewData.GetRefEndX();
+ long nY1 = rViewData.GetRefStartY();
+ long nY2 = rViewData.GetRefEndY();
+ long nTab = rViewData.GetRefTabNo();
+
+ PutInOrder(nX1, nX2);
+ PutInOrder(nY1, nY2);
+
+ aReferenceMarks[0] = lcl_GetReferenceMark( rViewData, pDocSh,
+ nX1, nX2, nY1, nY2,
+ nTab, aRefColor );
+ }
+
+ sal_uInt16 nCount = pRangeFinder ?
+ ( static_cast<sal_uInt16>( pRangeFinder->Count() ) + nAdditionalMarks ) : nAdditionalMarks;
+ aReferenceMarks.resize( nCount );
+
+ if ( nCount && pRangeFinder && !pRangeFinder->IsHidden() &&
+ pRangeFinder->GetDocName() == pDocSh->GetTitle() )
+ {
+ for (sal_uInt16 i = 0; i < nCount - nAdditionalMarks; i++)
+ {
+ ScRangeFindData& rData = pRangeFinder->GetObject( i );
+ ScRange aRef = rData.aRef;
+ aRef.PutInOrder();
+
+ long nX1 = aRef.aStart.Col();
+ long nX2 = aRef.aEnd.Col();
+ long nY1 = aRef.aStart.Row();
+ long nY2 = aRef.aEnd.Row();
+ long nTab = aRef.aStart.Tab();
+
+ aReferenceMarks[i + nAdditionalMarks] = lcl_GetReferenceMark(
+ rViewData, pDocSh, nX1, nX2, nY1, nY2, nTab, rData.nColor );
+
+ ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+ }
+ }
+ else if ( nCount )
+ {
+ ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+ }
+ else
+ {
+ // Clear
+ aReferenceMarks.clear();
+ ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+ }
+}
+
void ScInputHandler::SetDocumentDisposing( bool b )
{
mbDocumentDisposing = b;
@@ -3010,6 +3155,13 @@ void ScInputHandler::CancelHandler()
aFormText.clear();
bInOwnChange = false;
+
+ if ( comphelper::LibreOfficeKit::isActive() && pExecuteSh )
+ {
+ // Clear
+ std::vector<ReferenceMark> aReferenceMarks;
+ ScInputHandler::SendReferenceMarks( pActiveViewSh, aReferenceMarks );
+ }
}
bool ScInputHandler::IsModalMode( const SfxObjectShell* pDocSh )
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 0857f0156528..fa3c105117cd 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -78,6 +78,7 @@
#include <comphelper/string.hxx>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <helpids.h>
+#include <output.hxx>
#define THESIZE 1000000 // Should be more than enough!
#define TBX_WINDOW_HEIGHT 22 // in pixel - TODO: The same on all systems?
@@ -1590,6 +1591,13 @@ void ScTextWnd::StopEditEngine( bool bAll )
if (bSelection)
Invalidate(); // So that the Selection is not left there
}
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ // Clear
+ std::vector<ReferenceMark> aReferenceMarks;
+ ScInputHandler::SendReferenceMarks( mpViewShell, aReferenceMarks );
+ }
}
static sal_Int32 findFirstNonMatchingChar(const OUString& rStr1, const OUString& rStr2)
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index a03461784783..ecb394b5f809 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -49,6 +49,8 @@ class KeyEvent;
class CommandEvent;
class VclWindowEvent;
namespace vcl { class Window; }
+struct ReferenceMark;
+struct ESelection;
// ScInputHandler
@@ -273,6 +275,10 @@ public:
// actually private, public for SID_INPUT_SUM
void InitRangeFinder(const OUString& rFormula);
+ void UpdateLokReferenceMarks();
+ static void SendReferenceMarks( const SfxViewShell* pViewShell,
+ const std::vector<ReferenceMark>& rReferenceMarks );
+
void SetDocumentDisposing( bool b );
static void SetAutoComplete(bool bSet) { bAutoComplete = bSet; }
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 6150dd78f8d8..fed50cb1916d 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -58,6 +58,39 @@ enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER };
class ClearableClipRegion;
typedef std::unique_ptr<ClearableClipRegion, o3tl::default_delete<ClearableClipRegion>> ClearableClipRegionPtr;
+/// Describes reference mark to be drawn, position & size in TWIPs
+struct ReferenceMark {
+ long nX;
+ long nY;
+ long nWidth;
+ long nHeight;
+ long nTab;
+ Color aColor;
+
+ ReferenceMark()
+ : nX( 0 )
+ , nY( 0 )
+ , nWidth( 0 )
+ , nHeight( 0 )
+ , nTab( 0 )
+ , aColor( COL_AUTO ) {}
+
+ ReferenceMark( long aX,
+ long aY,
+ long aWidth,
+ long aHeight,
+ long aTab,
+ const Color& rColor )
+ : nX( aX )
+ , nY( aY )
+ , nWidth( aWidth )
+ , nHeight( aHeight )
+ , nTab( aTab )
+ , aColor( rColor ) {}
+
+ bool Is() const { return ( nWidth > 0 && nHeight > 0 ); }
+};
+
class ScOutputData
{
friend class ScDrawStringsVars;
@@ -152,8 +185,10 @@ private:
long nScrW; // Output size (Pixel)
long nScrH;
long nMirrorW; // Visible output width for mirroring (default: nScrW)
- SCCOL const nX1; // Start-/End coordinates
- SCROW const nY1; // ( incl. hidden )
+ long nTilePosX; // Current tile X offset (twips)
+ long nTilePosY; // Current tile Y offset (twips)
+ SCCOL const nX1; // Start-/End coordinates
+ SCROW const nY1; // ( incl. hidden )
SCCOL const nX2;
SCROW const nY2;
SCCOL nVisX1; // Start-/End coordinates
@@ -259,6 +294,7 @@ private:
void SetCellRotations();
public:
+
/**
* @param nNewScrX: X-Offset in the output device for the table
* @param nNewScrY: Y-Offset in the output device for the table
@@ -270,7 +306,8 @@ public:
SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
double nPixelPerTwipsX, double nPixelPerTwipsY,
const Fraction* pZoomX = nullptr,
- const Fraction* pZoomY = nullptr );
+ const Fraction* pZoomY = nullptr,
+ long nNewTilePosX = 0, long nNewTilePosY = 0 );
~ScOutputData();
@@ -331,9 +368,13 @@ public:
void FindChanged();
void SetPagebreakMode( ScPageBreakData* pPageData );
- void DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
+ /// Draws reference mark and returns its properties
+ ReferenceMark DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
SCCOL nRefEndX, SCROW nRefEndY,
const Color& rColor, bool bHandle );
+ ReferenceMark FillReferenceMark( SCCOL nRefStartX, SCROW nRefStartY,
+ SCCOL nRefEndX, SCROW nRefEndY,
+ const Color& rColor );
void DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
SCCOL nRefEndX, SCROW nRefEndY,
const Color& rColor, sal_uInt16 nType );
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 54a0be8869b8..e58a7ed6a080 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -40,6 +40,8 @@
#include <inputopt.hxx>
#include <rangeutl.hxx>
#include <tokenarray.hxx>
+#include <comphelper/lok.hxx>
+#include <output.hxx>
#include <memory>
@@ -259,6 +261,13 @@ void ScFormulaReferenceHelper::HideReference( bool bDoneRefMode )
if ( bDoneRefMode )
pTabViewShell->DoneRefMode();
pTabViewShell->ClearHighlightRanges();
+
+ if( comphelper::LibreOfficeKit::isActive() )
+ {
+ // Clear
+ std::vector<ReferenceMark> aReferenceMarks;
+ ScInputHandler::SendReferenceMarks( pTabViewShell, aReferenceMarks );
+ }
}
m_bHighlightRef=false;
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0830a65e6152..c8486ab80dd8 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5082,6 +5082,8 @@ void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, bool bUp )
ScDocShell* pDocSh = pViewData->GetDocShell();
+ pHdl->UpdateLokReferenceMarks();
+
// only redrawing what has been changed...
lcl_PaintRefChanged( pDocSh, aOld, aNew );
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 4d89d32dc755..3271139cdbb7 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -830,8 +830,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
{
Color aRefColor( rColorCfg.GetColorValue(svtools::CALCREFERENCE).nColor );
aOutputData.DrawRefMark( pViewData->GetRefStartX(), pViewData->GetRefStartY(),
- pViewData->GetRefEndX(), pViewData->GetRefEndY(),
- aRefColor, false );
+ pViewData->GetRefEndX(), pViewData->GetRefEndY(),
+ aRefColor, false );
}
// range finder
@@ -1214,7 +1214,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
-nTopLeftTileRowOffset,
nTopLeftTileCol, nTopLeftTileRow,
nBottomRightTileCol, nBottomRightTileRow,
- fPPTX, fPPTY);
+ fPPTX, fPPTY, nullptr, nullptr,
+ nTilePosX, nTilePosY);
// setup the SdrPage so that drawinglayer works correctly
ScDrawLayer* pModel = pDoc->GetDrawLayer();
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 1cf2a1620d06..536be2f2c2c1 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -42,6 +42,8 @@
#include <vcl/settings.hxx>
#include <svx/unoapi.hxx>
#include <sal/log.hxx>
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <output.hxx>
#include <document.hxx>
@@ -145,7 +147,8 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
SCTAB nNewTab, long nNewScrX, long nNewScrY,
SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
double nPixelPerTwipsX, double nPixelPerTwipsY,
- const Fraction* pZoomX, const Fraction* pZoomY ) :
+ const Fraction* pZoomX, const Fraction* pZoomY,
+ long nNewTilePosX, long nNewTilePosY ) :
mpDev( pNewDev ),
mpRefDevice( pNewDev ), // default is output device
pFmtDevice( pNewDev ), // default is output device
@@ -156,6 +159,8 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
nTab( nNewTab ),
nScrX( nNewScrX ),
nScrY( nNewScrY ),
+ nTilePosX( nNewTilePosX ),
+ nTilePosY( nNewTilePosY ),
nX1( nNewX1 ),
nY1( nNewY1 ),
nX2( nNewX2 ),
@@ -1847,10 +1852,103 @@ void ScOutputData::FindChanged()
mpDoc->EnableIdle(bWasIdleEnabled);
}
-void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
+ReferenceMark ScOutputData::FillReferenceMark( SCCOL nRefStartX, SCROW nRefStartY,
+ SCCOL nRefEndX, SCROW nRefEndY, const Color& rColor)
+{
+ ReferenceMark aResult;
+
+ PutInOrder( nRefStartX, nRefEndX );
+ PutInOrder( nRefStartY, nRefEndY );
+
+ if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY )
+ mpDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab );
+
+ if ( nRefStartX <= nVisX2 && nRefEndX >= nVisX1 &&
+ nRefStartY <= nVisY2 && nRefEndY >= nVisY1 )
+ {
+ long nMinX = nScrX;
+ long nMinY = nScrY;
+ long nMaxX = nScrX + nScrW - 1;
+ long nMaxY = nScrY + nScrH - 1;
+ if ( bLayoutRTL )
+ {
+ long nTemp = nMinX;
+ nMinX = nMaxX;
+ nMaxX = nTemp;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ bool bTop = false;
+ bool bBottom = false;
+ bool bLeft = false;
+ bool bRight = false;
+
+ long nPosY = nScrY;
+ bool bNoStartY = ( nY1 < nRefStartY );
+ bool bNoEndY = false;
+ for (SCSIZE nArrY=1; nArrY<nArrCount; nArrY++) // loop to end for bNoEndY check
+ {
+ SCROW nY = pRowInfo[nArrY].nRowNo;
+
+ if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) )
+ {
+ nMinY = nPosY;
+ bTop = true;
+ }
+ if ( nY==nRefEndY )
+ {
+ nMaxY = nPosY + pRowInfo[nArrY].nHeight - 2;
+ bBottom = true;
+ }
+ if ( nY>nRefEndY && bNoEndY )
+ {
+ nMaxY = nPosY-2;
+ bBottom = true;
+ }
+ bNoStartY = ( nY < nRefStartY );
+ bNoEndY = ( nY < nRefEndY );
+ nPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ long nPosX = nScrX;
+ if ( bLayoutRTL )
+ nPosX += nMirrorW - 1; // always in pixels
+
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ if ( nX==nRefStartX )
+ {
+ nMinX = nPosX;
+ bLeft = true;
+ }
+ if ( nX==nRefEndX )
+ {
+ nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 2 ) * nLayoutSign;
+ bRight = true;
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+
+ if (bTop && bBottom && bLeft && bRight)
+ {
+ aResult = ReferenceMark( nMinX / mnPPTX * double( aZoomX ),
+ nMinY / mnPPTY * double( aZoomY ),
+ ( nMaxX - nMinX ) / mnPPTX * double( aZoomX ),
+ ( nMaxY - nMinY ) / mnPPTY * double( aZoomY ),
+ nTab,
+ rColor );
+ }
+ }
+
+ return aResult;
+}
+
+ReferenceMark ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
SCCOL nRefEndX, SCROW nRefEndY,
const Color& rColor, bool bHandle )
{
+ ReferenceMark aResult;
+
PutInOrder( nRefStartX, nRefEndX );
PutInOrder( nRefStartY, nRefEndY );
@@ -1927,12 +2025,12 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
nMaxY >= nMinY )
{
mpDev->SetLineColor( rColor );
- if (bTop && bBottom && bLeft && bRight)
+ if (bTop && bBottom && bLeft && bRight && !comphelper::LibreOfficeKit::isActive() )
{
- mpDev->SetFillColor();
- mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) );
+ mpDev->SetFillColor();
+ mpDev->DrawRect( tools::Rectangle( nMinX, nMinY, nMaxX, nMaxY ) );
}
- else
+ else if ( !comphelper::LibreOfficeKit::isActive() )
{
if (bTop)
mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMaxX, nMinY ) );
@@ -1943,7 +2041,7 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
if (bRight)
mpDev->DrawLine( Point( nMaxX, nMinY ), Point( nMaxX, nMaxY ) );
}
- if ( bHandle && bRight && bBottom )
+ if ( bHandle && bRight && bBottom && !comphelper::LibreOfficeKit::isActive() )
{
mpDev->SetLineColor( rColor );
mpDev->SetFillColor( rColor );
@@ -1973,6 +2071,8 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
}
}
}
+
+ return aResult;
}
void ScOutputData::DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index d003f32d6aa8..b1e7df6ccce2 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2045,6 +2045,9 @@ void ScTabView::OnLibreOfficeKitTabChanged()
SfxLokHelper::forEachOtherView(pThisViewShell, lTabSwitch);
pThisViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, "all");
+
+ if (pThisViewShell->GetInputHandler())
+ pThisViewShell->GetInputHandler()->UpdateLokReferenceMarks();
}
}
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 250f71b32b3a..2efc0ef197ca 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -30,6 +30,7 @@
#include <scresid.hxx>
#include <formulacell.hxx>
#include <dociter.hxx>
+#include <inputhdl.hxx>
// --- Referenz-Eingabe / Fill-Cursor
@@ -250,6 +251,12 @@ void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ )
SCROW nPaintEndY;
if (aRect.GetDiff( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY ))
PaintArea( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY, ScUpdateMode::Marks );
+
+ ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl();
+ if (pInputHandler)
+ {
+ pInputHandler->UpdateLokReferenceMarks();
+ }
}
// autocomplete for Auto-Fill
@@ -327,6 +334,12 @@ void ScTabView::InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eT
ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ );
SC_MOD()->SetReference( aRef, pDoc, &rMark );
}
+
+ ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl();
+ if (pInputHandler)
+ {
+ pInputHandler->UpdateLokReferenceMarks();
+ }
}
}
commit d888916b80d34bfdf5a414df4c2ae973806e9f56
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Sep 5 21:12:23 2018 +0200
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Sep 25 17:53:36 2019 +0200
Allow to use multiple Formula dialog instances
Change-Id: Ia24556f40dd06e3acb40f24334ab972e2dada26a
Reviewed-on: https://gerrit.libreoffice.org/79463
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/79528
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 3a389ecc2d45..351d6d3bb95f 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -98,7 +98,6 @@ class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationL
std::unique_ptr<SvtCTLOptions> m_pCTLOptions;
std::unique_ptr<SvtUserOptions> m_pUserOptions;
std::unique_ptr<SfxErrorHandler> m_pErrorHdl;
- std::unique_ptr<ScFormEditData> m_pFormEditData;
sal_uInt16 m_nCurRefDlgId;
bool m_bIsWaterCan:1;
bool m_bIsInEditCommand:1;
@@ -203,7 +202,6 @@ public:
void InputSelection( const EditView* pView );
void InputChanged( const EditView* pView );
ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true );
-
void SetRefInputHdl( ScInputHandler* pNew );
ScInputHandler* GetRefInputHdl() { return m_pRefInputHandler;}
@@ -214,14 +212,9 @@ public:
void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
void InputReplaceSelection( const OUString& rStr );
void InputTurnOffWinEngine();
- OUString InputGetFormulaStr();
void ActivateInputWindow( const OUString* pStr = nullptr,
bool bMatrix = false );
- void InitFormEditData();
- void ClearFormEditData();
- ScFormEditData* GetFormEditData() { return m_pFormEditData.get(); }
-
// input of reference:
SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr );
bool IsModalMode(SfxObjectShell* pDocSh = nullptr);
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 3d7029d3aa30..bbdadfd3fffd 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3633,9 +3633,12 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
{
ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pScTabViewShell = pScMod ? dynamic_cast<ScTabViewShell*>(pScMod->GetViewShell()) : nullptr;
+
// Also take foreign reference input into account here (e.g. FunctionsAutoPilot),
// FormEditData, if we're switching from Help to Calc:
- if ( !bFormulaMode && !pScMod->IsFormulaMode() && !pScMod->GetFormEditData() )
+ if ( !bFormulaMode && !pScMod->IsFormulaMode() &&
+ ( !pScTabViewShell || !pScTabViewShell->GetFormEditData() ) )
{
bool bIgnore = false;
if ( bModified )
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 29c7a2d5b42e..0857f0156528 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -74,10 +74,10 @@
#include <AccessibleEditObject.hxx>
#include <AccessibleText.hxx>
#include <svtools/miscopt.hxx>
+#include <comphelper/lok.hxx>
#include <comphelper/string.hxx>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <helpids.h>
-#include <comphelper/lok.hxx>
#define THESIZE 1000000 // Should be more than enough!
#define TBX_WINDOW_HEIGHT 22 // in pixel - TODO: The same on all systems?
@@ -318,7 +318,7 @@ void ScInputWindow::Select()
{
//! new method at ScModule to query if function autopilot is open
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
- if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
+ if ( pViewFrm && ( comphelper::LibreOfficeKit::isActive() || !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ) )
{
pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION,
SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 954ac316c50e..3324b0225fb0 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -188,8 +188,6 @@ ScModule::~ScModule()
SfxItemPool::Free(m_pMessagePool);
- m_pFormEditData.reset();
-
m_pDragData.reset();
m_pErrorHdl.reset();
@@ -676,16 +674,6 @@ void ScModule::SetSelectionTransfer( ScSelectionTransferObj* pNew )
m_pSelTransfer = pNew;
}
-void ScModule::InitFormEditData()
-{
- m_pFormEditData.reset( new ScFormEditData );
-}
-
-void ScModule::ClearFormEditData()
-{
- m_pFormEditData.reset();
-}
-
void ScModule::SetViewOptions( const ScViewOptions& rOpt )
{
if ( !m_pViewCfg )
@@ -1339,7 +1327,7 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
*/
ScInputHandler* ScModule::GetInputHdl( ScTabViewShell* pViewSh, bool bUseRef )
{
- if ( m_pRefInputHandler && bUseRef )
+ if ( !comphelper::LibreOfficeKit::isActive() && m_pRefInputHandler && bUseRef )
return m_pRefInputHandler;
ScInputHandler* pHdl = nullptr;
@@ -1464,15 +1452,6 @@ void ScModule::InputTurnOffWinEngine()
pHdl->InputTurnOffWinEngine();
}
-OUString ScModule::InputGetFormulaStr()
-{
- ScInputHandler* pHdl = GetInputHdl();
- OUString aStr;
- if ( pHdl )
- aStr = pHdl->GetFormString();
- return aStr;
-}
-
void ScModule::ActivateInputWindow( const OUString* pStrFormula, bool bMatrix )
{
ScInputHandler* pHdl = GetInputHdl();
@@ -1514,7 +1493,8 @@ void ScModule::SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm )
{
//TODO: Move reference dialog handling to view
// Just keep function autopilot here for references to other documents
- if(m_nCurRefDlgId==0 || (nId==m_nCurRefDlgId && !bVis))
+ if ( m_nCurRefDlgId == 0 || ( nId == m_nCurRefDlgId && !bVis )
+ || ( comphelper::LibreOfficeKit::isActive() && m_nCurRefDlgId == SID_OPENDLG_FUNCTION ) )
{
if ( !pViewFrm )
pViewFrm = SfxViewFrame::Current();
@@ -1661,7 +1641,13 @@ bool ScModule::IsFormulaMode()
if ( m_nCurRefDlgId )
{
- SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId );
+ SfxChildWindow* pChildWnd = nullptr;
+
+ if ( comphelper::LibreOfficeKit::isActive() )
+ pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId );
+ else
+ pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId );
+
if ( pChildWnd )
{
IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index df788d2101d1..34cf78b7731b 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -64,11 +64,12 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
vcl::Window* pParent, const ScViewData* pViewData, const formula::IFunctionManager* _pFunctionMgr )
: formula::FormulaDlg( pB, pCW, pParent, _pFunctionMgr,this)
, m_aHelper(this,pB)
+ , m_pViewShell( nullptr )
{
m_aHelper.SetWindow(this);
ScModule* pScMod = SC_MOD();
pScMod->InputEnterHandler();
- ScTabViewShell* pScViewShell = nullptr;
+ m_pViewShell = nullptr;
// title has to be from the view that opened the dialog,
// even if it's not the current view
@@ -81,9 +82,9 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
if (pMyViewFrm)
{
- pScViewShell = dynamic_cast<ScTabViewShell*>( pMyViewFrm->GetViewShell() );
- if( pScViewShell )
- pScViewShell->UpdateInputHandler(true);
+ m_pViewShell = dynamic_cast<ScTabViewShell*>( pMyViewFrm->GetViewShell() );
+ if( m_pViewShell )
+ m_pViewShell->UpdateInputHandler(true);
}
}
}
@@ -97,7 +98,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
m_xOpCodeMapper.set(ScServiceProvider::MakeInstance(ScServiceProvider::Type::OPCODEMAPPER,
static_cast<ScDocShell*>(m_pDoc->GetDocumentShell())),uno::UNO_QUERY);
- ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell);
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(m_pViewShell);
OSL_ENSURE( pInputHdl, "Missing input handler :-/" );
@@ -112,10 +113,10 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
notifyChange();
fill();
- ScFormEditData* pData = pScMod->GetFormEditData();
+ ScFormEditData* pData = m_pViewShell->GetFormEditData();
if (!pData)
{
- pScMod->SetRefInputHdl(pScMod->GetInputHdl());
+ pScMod->SetRefInputHdl(pInputHdl);
m_pDoc = pViewData->GetDocument();
SCCOL nCol = pViewData->GetCurX();
@@ -123,9 +124,9 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
SCTAB nTab = pViewData->GetTabNo();
m_CursorPos = ScAddress( nCol, nRow, nTab );
- pScMod->InitFormEditData(); // create new
- pData = pScMod->GetFormEditData();
- pData->SetInputHandler(pScMod->GetInputHdl());
+ m_pViewShell->InitFormEditData(); // create new
+ pData = m_pViewShell->GetFormEditData();
+ pData->SetInputHandler(pInputHdl);
pData->SetDocShell(pViewData->GetDocShell());
OSL_ENSURE(pData,"FormEditData not available");
@@ -146,12 +147,12 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
sal_Int32 nFEnd = 0;
if ( GetFormulaHelper().GetNextFunc( aFormula, false, nFStart, &nFEnd) )
{
- pScMod->InputReplaceSelection( aFormula );
- pScMod->InputSetSelection( nFStart, nFEnd );
+ pInputHdl->InputReplaceSelection( aFormula );
+ pInputHdl->InputSetSelection( nFStart, nFEnd );
sal_Int32 PrivStart, PrivEnd;
- pScMod->InputGetSelection( PrivStart, PrivEnd);
+ pInputHdl->InputGetSelection( PrivStart, PrivEnd);
- eMode = SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd, bMatrix, true, true);
+ eMode = SetMeText(pInputHdl->GetFormString(),PrivStart, PrivEnd, bMatrix, true, true);
pData->SetFStart( nFStart );
}
else
@@ -164,11 +165,11 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
if ( aFormula.startsWith("=") )
aNewFormula = aFormula;
- pScMod->InputReplaceSelection( aNewFormula );
- pScMod->InputSetSelection( 1, aNewFormula.getLength()+1 );
+ pInputHdl->InputReplaceSelection( aNewFormula );
+ pInputHdl->InputSetSelection( 1, aNewFormula.getLength()+1 );
sal_Int32 PrivStart, PrivEnd;
- pScMod->InputGetSelection( PrivStart, PrivEnd);
- SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,false,false);
+ pInputHdl->InputGetSelection( PrivStart, PrivEnd);
+ SetMeText(pInputHdl->GetFormString(),PrivStart, PrivEnd,bMatrix,false,false);
pData->SetFStart( 1 ); // after "="
}
@@ -183,9 +184,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
void ScFormulaDlg::notifyChange()
{
- ScModule* pScMod = SC_MOD();
-
- ScInputHandler* pInputHdl = pScMod->GetInputHdl();
+ ScInputHandler* pInputHdl = m_pViewShell->GetInputHandler();
if ( pInputHdl )
pInputHdl->NotifyChange( nullptr );
}
@@ -193,7 +192,7 @@ void ScFormulaDlg::notifyChange()
void ScFormulaDlg::fill()
{
ScModule* pScMod = SC_MOD();
- ScFormEditData* pData = pScMod->GetFormEditData();
+ ScFormEditData* pData = static_cast<ScFormEditData*>(getFormEditData());
notifyChange();
OUString rStrExp;
if (pData)
@@ -223,11 +222,11 @@ void ScFormulaDlg::fill()
pData->SetInputHandler(pInputHdl);
}
- OUString aOldFormulaTmp(pScMod->InputGetFormulaStr());
- pScMod->InputSetSelection( 0, aOldFormulaTmp.getLength());
+ OUString aOldFormulaTmp(pData->GetInputHandler()->GetFormString());
+ pData->GetInputHandler()->InputSetSelection( 0, aOldFormulaTmp.getLength());
rStrExp=pData->GetUndoStr();
- pScMod->InputReplaceSelection(rStrExp);
+ pData->GetInputHandler()->InputReplaceSelection(rStrExp);
SetMeText(rStrExp);
@@ -244,16 +243,17 @@ ScFormulaDlg::~ScFormulaDlg()
void ScFormulaDlg::dispose()
{
- ScModule* pScMod = SC_MOD();
- ScFormEditData* pData = pScMod->GetFormEditData();
+ ScFormEditData* pData = m_pViewShell->GetFormEditData();
+
m_aHelper.dispose();
if (pData) // close doesn't destroy;
{
//set back reference input handler
- pScMod->SetRefInputHdl(nullptr);
+ SC_MOD()->SetRefInputHdl(nullptr);
StoreFormEditData(pData);
}
+ m_pViewShell->ClearFormEditData();
formula::FormulaDlg::dispose();
}
@@ -564,8 +564,8 @@ void ScFormulaDlg::setDispatcherLock( bool bLock )
}
void ScFormulaDlg::deleteFormData()
{
- ScModule* pScMod = SC_MOD();
- pScMod->ClearFormEditData(); // pData is invalid!
+ if (m_pViewShell)
+ m_pViewShell->ClearFormEditData(); // pData is invalid!
}
void ScFormulaDlg::clear()
{
@@ -582,10 +582,9 @@ void ScFormulaDlg::clear()
}
void ScFormulaDlg::switchBack()
{
- ScModule* pScMod = SC_MOD();
// back to the document
// (foreign doc could be above - #34222#)
- ScInputHandler* pHdl = pScMod->GetInputHdl();
+ ScInputHandler* pHdl = m_pViewShell->GetInputHandler();
if ( pHdl )
{
pHdl->ViewShellGone(nullptr); // -> get active view
@@ -610,8 +609,10 @@ void ScFormulaDlg::switchBack()
}
formula::FormEditData* ScFormulaDlg::getFormEditData() const
{
- ScModule* pScMod = SC_MOD();
- return pScMod->GetFormEditData();
+ ScTabViewShell* pViewShell = m_pViewShell;
+ if (pViewShell)
+ return pViewShell->GetFormEditData();
+ return nullptr;
}
void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
{
@@ -647,8 +648,10 @@ void ScFormulaDlg::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
}
OUString ScFormulaDlg::getCurrentFormula() const
{
- ScModule* pScMod = SC_MOD();
- return pScMod->InputGetFormulaStr();
+ ScFormEditData* pData = m_pViewShell->GetFormEditData();
+ if (pData && pData->GetInputHandler())
+ return pData->GetInputHandler()->GetFormString();
+ return "";
}
formula::IFunctionManager* ScFormulaDlg::getFunctionManager()
{
diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx
index a40b55ecb9e1..c276fa49dccf 100644
--- a/sc/source/ui/inc/formula.hxx
+++ b/sc/source/ui/inc/formula.hxx
@@ -41,6 +41,7 @@ class ScFormulaDlg final : public formula::FormulaDlg,
ScDocument* m_pDoc;
ScAddress m_CursorPos;
+ ScTabViewShell* m_pViewShell;
mutable std::shared_ptr<ScCompiler> m_xCompiler;
public:
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index d35f1f67e1b6..2f17319efeaf 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -89,6 +89,7 @@ enum ObjectSelectionType
OST_Media
};
+class ScFormEditData;
class SC_DLLPUBLIC ScTabViewShell: public SfxViewShell, public ScDBFunc
{
private:
@@ -113,6 +114,7 @@ private:
std::unique_ptr<FmFormShell> pFormShell;
+ std::unique_ptr<ScFormEditData> mpFormEditData;
std::unique_ptr<ScInputHandler, o3tl::default_delete<ScInputHandler>> mpInputHandler; // for OLE input cell
std::unique_ptr<::editeng::SvxBorderLine> pCurFrameLine;
@@ -163,7 +165,6 @@ private:
bool mbInSwitch;
OUString maName;
OUString maScope;
-
private:
void Construct( TriState nForceDesignMode );
@@ -391,6 +392,10 @@ public:
static bool isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd);
css::uno::Reference<css::drawing::XShapes> getSelectedXShapes();
static css::uno::Reference<css::datatransfer::XTransferable2> GetClipData(vcl::Window* pWin);
+
+ void InitFormEditData();
+ void ClearFormEditData();
+ ScFormEditData* GetFormEditData() { return mpFormEditData.get(); }
};
#endif
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 11db51e467c1..2125ebcf0d05 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -319,8 +319,8 @@ void ScCellShell::Execute( SfxRequest& rReq )
sal_uInt16 nId = SID_OPENDLG_FUNCTION;
SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
-
- pScMod->SetRefDialog( nId, pWnd == nullptr );
+ bool bVis = comphelper::LibreOfficeKit::isActive() || pWnd == nullptr;
+ pScMod->SetRefDialog( nId, bVis );
rReq.Ignore();
}
break;
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 696ca8babcf1..30e9def2e4a2 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -21,6 +21,7 @@
#include <scitems.hxx>
#include <editeng/eeitem.hxx>
+#include <formdata.hxx>
#include <sfx2/app.hxx>
#include <svx/dialogs.hrc>
@@ -1777,6 +1778,7 @@ ScTabViewShell::~ScTabViewShell()
pPivotShell.reset();
pAuditingShell.reset();
pCurFrameLine.reset();
+ mpFormEditData.reset();
mpInputHandler.reset();
pPivotSource.reset();
pDialogDPObject.reset();
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index d8d8c22a6615..815ae6745a80 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -737,7 +737,7 @@ void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
// we will save the doc immediately afterwards, the modified state event
// is clobbered. To avoid that, we notify all views immediately of the
// modified state, apply the modification, then save the document.
- ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+ ScInputHandler* pHdl = GetInputHandler();
if (pHdl != nullptr && pHdl->GetModified())
SfxLokHelper::notifyAllViews(LOK_CALLBACK_STATE_CHANGED, ".uno:ModifiedStatus=true");
}
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 85f7dba8d8ca..12d57de75962 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -59,6 +59,7 @@
#include <condformatdlg.hxx>
#include <xmlsourcedlg.hxx>
#include <condformatdlgitem.hxx>
+#include <formdata.hxx>
#include <RandomNumberGeneratorDialog.hxx>
#include <SamplingDialog.hxx>
@@ -740,4 +741,14 @@ const OUString ScTabViewShell::DoAutoSum(bool& rRangeFinder, bool& rSubTotal)
return aFormula;
}
+void ScTabViewShell::InitFormEditData()
+{
+ mpFormEditData.reset(new ScFormEditData);
+}
+
+void ScTabViewShell::ClearFormEditData()
+{
+ mpFormEditData.reset();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list