25#include <osl/diagnose.h>
59#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
60#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
61#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
62#include <com/sun/star/sheet/MemberResultFlags.hpp>
63#include <com/sun/star/sheet/TableValidationVisibility.hpp>
64#include <com/sun/star/awt/KeyModifier.hpp>
65#include <com/sun/star/awt/MouseButton.hpp>
66#include <com/sun/star/script/vba/VBAEventId.hpp>
67#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
68#include <com/sun/star/text/textfield/Type.hpp>
77#include <document.hxx>
106#include <compiler.hxx>
117#include <overlayobject.hxx>
119#include <drawview.hxx>
126#include <uiobject.hxx>
133#include <officecfg/Office/Common.hxx>
145#include <LibreOfficeKit/LibreOfficeKitEnums.h>
148#include <boost/property_tree/json_parser.hpp>
153using namespace css::uno;
164#define SC_FILTERLISTBOX_LINES 12
168 , mnCol2(rDoc.MaxCol())
170 , mnRow2(rDoc.MaxRow())
176 return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2;
181 bool bChanged = mnCol1 != nCol1 || mnRow1 != nRow1 || mnCol2 != nCol2 || mnRow2 != nRow2;
194 : xBuilder(
Application::CreateBuilder(pParent,
"modules/scalc/ui/filterlist.ui"))
195 , xPopover(xBuilder->weld_popover(
"FilterList"))
196 , xTreeView(xBuilder->weld_tree_view(
"list"))
205 , nAsyncSelectHdl(nullptr)
239 pGridWin->ClickExtern();
252 if (!bInit && !bCancelled && !nAsyncSelectHdl)
254 int nPos = xTreeView->get_selected_index();
267 nAsyncSelectHdl =
nullptr;
270 auto xThis(shared_from_this());
271 pGridWin->FilterSelect(nSel);
272 if (xThis.use_count() == 1)
277 pGridWin->ClickExtern();
354 maVisibleRange(
rData.GetDocument()),
357 nCursorHideCount( 0 ),
362 pDragDPObj( nullptr ),
367 nPagebreakBreak( 0 ),
375 aComboButton( GetOutDev() ),
378 aRFSelectedCorned(
NONE ),
379 maShowPageBreaksTimer(
"ScGridWindow maShowPageBreaksTimer"),
384 bPagebreakDrawn( false ),
387 bNeedsRepaint( false ),
388 bAutoMarkVisible( false ),
389 bListValButton( false )
411 OSL_FAIL(
"GridWindow: wrong position");
477 bool bMouseWasCaptured = mpFilterBox->MouseWasCaptured();
478 mpFilterBox->SetCancelled();
481 SAL_WARN_IF(bMouseWasCaptured,
"sc.ui",
"Is there a scenario where the mouse was captured before mouse down?");
482 if (bMouseWasCaptured)
490 if( rInfo.nCommand == SpellCallbackCommand::STARTSPELLDLG )
491 mrViewData.GetDispatcher().Execute( SID_SPELL_DIALOG, SfxCallMode::ASYNCHRON );
492 else if (rInfo.nCommand == SpellCallbackCommand::AUTOCORRECT_OPTIONS)
493 mrViewData.GetDispatcher().Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
519 virtual bool execute()
override
521 mpWindow->UpdateAutoFilterFromMenu(meMode);
535 virtual bool execute()
override
537 mpWindow->RefreshAutoFilterButton(maPos);
543class AutoFilterSubMenuAction :
public AutoFilterAction
550 : AutoFilterAction(
p,
eMode)
551 , m_pSubMenu(pSubMenu)
556class AutoFilterColorAction :
public AutoFilterSubMenuAction
563 : AutoFilterSubMenuAction(
p, pSubMenu,
eMode)
568 virtual bool execute()
override
570 const AutoFilterData*
pData =
571 static_cast<const AutoFilterData*
>(m_pSubMenu->getExtendedData());
582 ScViewData& rViewData = m_pSubMenu->GetViewData();
607 bool bActive =
false;
609 if (aItem.maColor == m_aColor
645class AutoFilterColorPopupStartAction :
public AutoFilterSubMenuAction
653 virtual bool execute()
override
655 const AutoFilterData*
pData =
656 static_cast<const AutoFilterData*
>(m_pSubMenu->getExtendedData());
665 ScViewData& rViewData = m_pSubMenu->GetViewData();
672 m_pSubMenu->clearMenuItems();
676 OUString aPaletteName(officecfg::Office::Common::UserColors::PaletteName::get());
678 std::vector<OUString> aPaletteNames = aPaletteManager.
GetPaletteList();
679 for (
size_t i = 0, nLen = aPaletteNames.size(); i < nLen; ++i)
681 if (aPaletteName == aPaletteNames[i])
687 if (!xUserColorList->Load())
688 xUserColorList =
nullptr;
704 for (
auto& rColor : aColors)
706 bool bActive =
false;
711 if (aItem.maColor == rColor
721 const bool bAutoColor = rColor ==
COL_AUTO;
727 xDev->SetOutputSize(aImageSize);
732 const Color aW(COL_WHITE);
733 const Color aG(0xef, 0xef, 0xef);
734 int nMinDim = std::min(aImageSize.Width(), aImageSize.Height()) + 1;
735 int nCheckSize = nMinDim / 3;
736 xDev->DrawCheckered(aRect.TopLeft(), aRect.GetSize(), std::min(nCheckSize, 8), aW, aG);
737 xDev->SetFillColor();
740 xDev->SetFillColor(rColor);
743 xDev->DrawRect(aRect);
748 ?
ScResId(SCSTR_FILTER_AUTOMATIC_COLOR)
749 :
ScResId(SCSTR_FILTER_NO_FILL);
750 m_pSubMenu->addMenuColorItem(sText, bActive, *xDev, nMenu,
751 new AutoFilterColorAction(mpWindow, m_pSubMenu, eMode, rColor));
757 bool bFoundColorName =
false;
760 sal_Int32
nPos = xUserColorList->GetIndexOfColor(rColor);
763 XColorEntry* pColorEntry = xUserColorList->GetColor(nPos);
765 bFoundColorName =
true;
768 if (!bFoundColorName)
769 sName =
"#" + rColor.AsRGBHexString().toAsciiUpperCase();
771 m_pSubMenu->addMenuColorItem(sName, bActive, *xDev, nMenu,
772 new AutoFilterColorAction(mpWindow, m_pSubMenu, eMode, rColor));
779 m_pSubMenu->resizeToFitMenuItems();
791 mrItems(rItems), mrPool(rPool) {}
801 mrItems.push_back(aNew);
806class AddSelectedItemString
808 std::unordered_set<OUString>& mrSetString;
809 std::unordered_set<double>& mrSetValue;
811 explicit AddSelectedItemString(std::unordered_set<OUString>& rString, std::unordered_set<double>& rValue) :
812 mrSetString(rString), mrSetValue(rValue) {}
816 if( rItem.
meType == ScQueryEntry::QueryType::ByValue )
817 mrSetValue.insert(rItem.
mfVal);
823void collectUIInformation(
const OUString& aRow,
const OUString& aCol ,
const OUString& aevent)
826 aDescription.
aAction =
"LAUNCH";
827 aDescription.
aID =
"grid_window";
829 {
"ROW", aRow}, {
"COL", aCol}};
830 aDescription.
aParent =
"MainWindow";
831 aDescription.
aKeyWord =
"ScGridWinUIObject";
855 int nMaxTextWidth = 0;
856 if (aFilterEntries.
size() <= 10)
859 for (
const auto& rEntry : aFilterEntries)
861 const OUString& aText = rEntry.GetString();
862 nMaxTextWidth = std::max<int>(nMaxTextWidth,
mpAutoFilterPopup->GetTextWidth(aText) + aText.getLength() * 2);
869 auto itMax = aFilterEntries.
begin();
870 for (
auto it = itMax; it != aFilterEntries.
end(); ++it)
872 int nTextWidth = it->GetString().getLength();
873 if (nMaxTextWidth < nTextWidth)
875 nMaxTextWidth = nTextWidth;
879 nMaxTextWidth =
mpAutoFilterPopup->GetTextWidth(itMax->GetString()) + nMaxTextWidth * 2;
884 int nWindowWidth = std::min<int>(1024, nMaxTextWidth + 70);
886 nMaxTextWidth = std::max<int>(nMaxTextWidth, nWindowWidth - 70);
890 new AutoFilterPopupEndAction(
this,
ScAddress(nCol, nRow, nTab)));
891 std::unique_ptr<AutoFilterData>
pData(
new AutoFilterData);
905 aPos.setX(aPos.getX() / fZoomX);
906 aPos.setY(aPos.getY() / fZoomY);
907 nSizeX = nSizeX / fZoomX;
908 nSizeY = nSizeY / fZoomY;
916 pData->mpData = pDBData;
922 std::unordered_set<OUString> aSelectedString;
923 std::unordered_set<double> aSelectedValue;
924 bool bQueryByNonEmpty =
aEntries.size() == 1 &&
aEntries[0]->IsQueryByNonEmpty();
926 if (!bQueryByNonEmpty)
933 std::for_each(rItems.begin(), rItems.end(), AddSelectedItemString(aSelectedString, aSelectedValue));
940 for (
auto it = aFilterEntries.
begin(); it != aFilterEntries.
end(); ++it)
943 if (it->GetString().isEmpty())
945 const OUString& aStringVal = it->GetString();
946 const double aDoubleVal = it->GetValue();
947 bool bSelected =
true;
948 if (!aSelectedValue.empty() || !aSelectedString.empty())
949 bSelected = aSelectedString.count(aStringVal) > 0;
950 else if (bQueryByNonEmpty)
957 for (
const auto& rEntry : aFilterEntries)
959 const OUString& aStringVal = rEntry.GetString();
960 const double aDoubleVal = rEntry.GetValue();
961 const double aRDoubleVal = rEntry.GetRoundedValue();
962 bool bSelected =
true;
964 if (!aSelectedValue.empty() || !aSelectedString.empty())
966 if (aDoubleVal == aRDoubleVal)
967 bSelected = aSelectedValue.count(aDoubleVal) > 0 || aSelectedString.count(aStringVal) > 0;
969 bSelected = aSelectedValue.count(aDoubleVal) > 0 || aSelectedValue.count(aRDoubleVal) > 0 || aSelectedString.count(aStringVal) > 0;
972 if ( rEntry.IsDate() )
987 pSubMenu->setPopupStartAction(
new AutoFilterColorPopupStartAction(
this, pSubMenu));
990 pSubMenu->addMenuItem(
992 pSubMenu->addMenuItem(
994 pSubMenu->addMenuItem(
996 pSubMenu->addMenuItem(
998 pSubMenu->addSeparator();
999 pSubMenu->addMenuItem(
1001 pSubMenu->resizeToFitMenuItems();
1020 collectUIInformation(OUString::number(nRow), OUString::number(nCol),
"AUTOFILTER");
1041 const AutoFilterData*
pData =
1062 if (nCol < aSortParam.nCol1 || nCol > aSortParam.
nCol2)
1069 aSortParam.
bByRow =
true;
1110 SAL_INFO(
"sc.ui",
"Apply autofilter to data when entries are the same");
1167 std::for_each(aResult.begin(), aResult.end(), AddItemToEntry(rItems, rPool));
1188 assert(
false &&
"should be handled by AutoFilterColorAction::execute");
1206 rScrPos = rViewData.
GetScrPos(nCol, nRow, eWhich);
1211 rScrSize =
Size(nSizeX-1, nSizeY-1);
1250 auto nSizeX = rCellRect.
GetWidth();
1256 if (nSizeX < nMinLOKWinWidth)
1257 nSizeX = nMinLOKWinWidth;
1267 auto nMaxToExpandTo = std::min(nSizeX,
static_cast<decltype(nSizeX)
>(300));
1268 if (aSize.
Width() < nMaxToExpandTo)
1278 if (!bLayoutRTL && aSize.
Width() > nSizeX)
1297 bool bMenuAtTop =
true;
1306 nRow = rScenRange.
aEnd.
Row() + 1;
1321 aPos.AdjustX( -nSizeX );
1352 aCurrent = aTabName;
1361 sal_Int32
nPos = -1;
1362 if (!aCurrent.isEmpty())
1401 aPos.setX(aPos.getX() / fZoomX);
1402 aPos.setY(aPos.getY() / fZoomY);
1403 nSizeX = nSizeX / fZoomX;
1404 nSizeY = nSizeY / fZoomY;
1408 aPos.AdjustX( -nSizeX );
1419 bool bEmpty =
false;
1420 std::vector<ScTypedStrData> aStrings;
1423 if (aStrings.empty())
1431 bool bWait = aStrings.size() > 100;
1436 for (
const auto& rString : aStrings)
1447 sal_Int32 nSelPos = -1;
1455 std::unique_ptr<ScTypedStrData> pNew;
1456 OUString aDocStr = rDoc.
GetString(nCol, nRow, nTab);
1465 if (
pData->GetListType() == css::sheet::TableValidationVisibility::SORTEDASCENDING)
1469 nSelPos =
static_cast<sal_Int32
>(std::distance(aStrings.begin(), it));
1473 auto it = std::find_if(aStrings.begin(), aStrings.end(),
FindTypedStrData(*pNew,
true));
1474 if (it != aStrings.end())
1475 nSelPos =
static_cast<sal_Int32
>(std::distance(aStrings.begin(), it));
1499 rFilterBox.
select(nSelPos);
1505 collectUIInformation(OUString::number(nRow), OUString::number(nCol),
"SELECTMENU");
1511 OUString aString = rFilterBox.
get_text(
static_cast<sal_Int32
>(nSel));
1540 pView->
EnterData( nCol, nRow, nTab, rStr );
1583 if ( bAction && !rMEvt.
IsLeft() )
1586 bool bNewPointer =
false;
1642 aStartPos.AdjustX(2 );
1643 aEndPos.AdjustX(2 );
1645 bool bTop = ( aMousePos.X() >= aStartPos.X()-3 && aMousePos.X() <= aStartPos.X()+1 &&
1646 aMousePos.Y() >= aStartPos.Y()-3 && aMousePos.Y() <= aStartPos.Y()+1 );
1647 bool bBottom = ( aMousePos.X() >= aEndPos.X()-3 && aMousePos.X() <= aEndPos.X()+1 &&
1648 aMousePos.Y() >= aEndPos.Y()-3 && aMousePos.Y() <= aEndPos.Y()+1 );
1649 if ( bTop || bBottom )
1665 if (!bNewPointer && bAction)
1732 SCCOL nNonEmptyX = nPosX;
1733 for (; nNonEmptyX >= 0; --nNonEmptyX)
1741 if (nNonEmptyX == nPosX)
1743 rTextStartPosX = nNonEmptyX;
1783 if (nTextEndX >= nPosX)
1785 rTextStartPosX = nNonEmptyX;
1822 SAL_WARN_IF(bWasMouseCaptured,
"sc.ui",
"Is there a scenario where the mouse is captured before mouse down?");
1831 bool bDouble = (rMEvt.
GetClicks() == 2);
1844 if (bIsTiledRendering)
1847 SCCOL nPosX, nNonEmptyX(0);
1853 bool bIsEmpty = aCell.
isEmpty();
1856 if (bIsCoveredByText)
1877 else if (bIsEmpty && bEditMode && bDouble)
1910 SfxCallMode::SLOT | SfxCallMode::RECORD,
1911 { &aPosXItem, &aPosYItem });
1946 if ( nPosX >= nEditCol && nPosX <= nEndCol &&
1947 nPosY >= nEditRow && nPosY <= nEndRow )
1987 bool bCrossPointer =
TestMouse( rMEvt,
true );
1988 if ( bCrossPointer )
1996 if ( !bCrossPointer )
2011 if (((!bFormulaMode && !bEditMode) || bIsTiledRendering) && rMEvt.
IsLeft())
2041 if ( !bDouble && !bFormulaMode && rMEvt.
IsLeft() )
2051 SC_MOD()->InputEnterHandler();
2078 if ( aButtonRect.
Contains( aPos ) )
2120 if ( bDouble && !bCrossPointer )
2131 bool bAlt = rMEvt.
IsMod2();
2219 GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection )
2228 rBindings.
Invalidate( SID_HYPERLINK_GETLINK );
2269 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_WIDTH);
2270 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_HEIGHT);
2271 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_X);
2272 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_Y);
2273 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ANGLE);
2274 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ROT_X);
2275 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ROT_Y);
2276 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_AUTOWIDTH);
2277 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_AUTOHEIGHT);
2307 ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2308 if ( aBlockRange != aDelRange )
2310 if ( aDelRange.
aStart.
Row() == nStartRow )
2328 ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2331 ScAddress aEndPos( nFillCol, nFillRow, nTab );
2338 if ( aEndPos != aBlockRange.
aEnd )
2365 GetStyleSheetPool();
2377 case SfxStyleFamily::Para:
2382 case SfxStyleFamily::Page:
2390 rBindings.
Invalidate( SID_STATUS_PAGESTYLE );
2416 bool bInDataPilotTable = (pDPObj !=
nullptr);
2423 if ((bDouble || (bIsTiledRendering && !bInDataPilotTable))
2434 sheet::DataPilotTableHeaderData
aData;
2437 if ( (
aData.Flags & sheet::MemberResultFlags::HASMEMBER ) &&
2438 ! (
aData.Flags & sheet::MemberResultFlags::SUBTOTAL ) )
2440 css::sheet::DataPilotFieldOrientation nDummy;
2460 Sequence<sheet::DataPilotFieldFilter> aFilters;
2470 bool bEditAllowed =
true;
2477 if ( bSkipProtected && bSkipUnprotected )
2478 bEditAllowed =
false;
2479 else if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) )
2480 bEditAllowed =
false;
2485 if ( bEditAllowed && (!bIsTiledRendering || bDouble) )
2489 if (bIsTiledRendering && bDouble)
2520 bool bAlt = rMEvt.
IsMod2();
2525 OUString
aName, aUrl, aTarget;
2534 if (aUrl.startsWith(
"#")) {
2541 if (isTiledRendering && pViewShell &&
2548 int mouseX = aPos.X() / fPPTX;
2549 OString aMsg(aUrl.toUtf8() +
" coordinates: " + aCursor +
", " + OString::number(mouseX));
2566 OUStringBuffer
aBuf;
2579 aBuf.append(aRefCalcA1);
2587 aBuf.append(aUrlCalcA1);
2594 if( xVbaEvents.is() )
try
2603 ScAddress aCellPos( nPosX, nPosY, nTab );
2605 uno::Sequence< uno::Any > aArgs{
uno::Any(xCell) };
2606 xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs );
2609 catch( uno::Exception& )
2629 OSL_ENSURE( pDisp || bFormulaMode,
"Cursor moved on inactive View ?" );
2645 aAddr +=
":" + aAddr;
2661 SfxBoolItem aAlignCursorItem( FN_PARAM_2,
false );
2663 SfxCallMode::SLOT | SfxCallMode::RECORD,
2664 { &aPosItem, &aAlignCursorItem });
2764 if ( nPosX >= nEditCol && nPosX <= nEndCol &&
2765 nPosY >= nEditRow && nPosY <= nEndRow )
2777 pFld = pEditView->
GetField( aLogicClick );
2784 bool bAlt = rMEvt.
IsMod2();
2801 bool bCross =
false;
2808 if (rCorner !=
NONE)
2820 if (nBreakType != 0 )
2823 switch ( nBreakType )
2828 eNew = PointerStyle::ESize;
2833 eNew = PointerStyle::SSize;
2837 eNew = PointerStyle::SESize;
2841 eNew = PointerStyle::NESize;
2864 bool bAlt = rMEvt.
IsMod2();
2882 if (!bSkipSelectionUpdate)
2888 rEvent.Modifiers = 0;
2890 rEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
2892 rEvent.Modifiers |= css::awt::KeyModifier::MOD1;
2894 rEvent.Modifiers |= css::awt::KeyModifier::MOD2;
2896 rEvent.Modifiers |= css::awt::KeyModifier::MOD3;
2900 rEvent.Buttons |= css::awt::MouseButton::LEFT;
2902 rEvent.Buttons |= css::awt::MouseButton::RIGHT;
2909 rEvent.PopupTrigger =
false;
2916 if (
nType == MouseNotifyEvent::MOUSEBUTTONUP ||
nType == MouseNotifyEvent::MOUSEBUTTONDOWN )
2919 if (pWindow ==
this)
2930 css::awt::MouseEvent
aEvent;
2934 if (
nType == MouseNotifyEvent::MOUSEBUTTONDOWN)
2945 if (
nType == MouseNotifyEvent::MOUSEBUTTONDOWN )
2959 return Window::PreNotify( rNEvt );
2998 SC_MOD()->EndReference();
3020 CommandEvent aDragEvent( rPosPixel, CommandEventId::StartDrag,
true );
3033 pEditView->
Command( aDragEvent );
3076 nCmd == CommandEventId::ContextMenu )
3083 OSL_ENSURE( nCmd != CommandEventId::StartDrag,
"ScGridWindow::Command called with CommandEventId::StartDrag" );
3085 if (nCmd == CommandEventId::ModKeyChange)
3087 Window::Command(rCEvt);
3091 if ( nCmd == CommandEventId::StartExtTextInput ||
3092 nCmd == CommandEventId::EndExtTextInput ||
3093 nCmd == CommandEventId::ExtTextInput ||
3094 nCmd == CommandEventId::CursorPos ||
3095 nCmd == CommandEventId::QueryCharPosition )
3105 if ( pOlView && pOlView->
GetWindow() ==
this )
3113 if ( nCmd == CommandEventId::CursorPos && !bEditView )
3131 Window::Command( rCEvt );
3135 if ( nCmd == CommandEventId::PasteSelection )
3149 if ( nCmd == CommandEventId::InputLanguageChange )
3156 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
3160 if ( nCmd == CommandEventId::Wheel || nCmd == CommandEventId::StartAutoScroll || nCmd == CommandEventId::AutoScroll )
3164 Window::Command(rCEvt);
3173 if (nCmd != CommandEventId::ContextMenu ||
SC_MOD()->GetIsWaterCan())
3189 Point aMenuPos = aPosPixel;
3197 if (bPosIsInEditView)
3202 bPosIsInEditView =
false;
3207 bPosIsInEditView =
false;
3209 if (!bPosIsInEditView)
3219 bool bSpellError =
false;
3220 SCCOL nColSpellError = nCellX;
3227 bool bSelectAllowed =
true;
3236 bSelectAllowed = bSelProtected;
3238 bSelectAllowed = bSelUnprotected;
3240 if (!bSelectAllowed)
3256 aSpellCheckCell.
assign(rDoc, aPos);
3260 nColSpellError = aPos.
Col();
3264 bSpellError = (
mpSpellCheckCxt->isMisspelled(nColSpellError, nCellY));
3285 if (bMouse && bSpellError)
3292 OSL_ENSURE( bEdit,
"Can not be switched in edit mode" );
3307 aLogicPos.AdjustX(pCur->
GetWidth() );
3308 aLogicPos.AdjustY(pCur->
GetHeight() / 2 );
3328 const OUString sOldText = pHdl ? pHdl->
GetEditString() :
"";
3338 || (!bDone && !bPosIsInEditView)))
3343 if (!bDone && nColSpellError != nCellX)
3364 aMenuPos.AdjustX(bLayoutIsRTL ? -nSizeXPix : nSizeXPix );
3365 aMenuPos.AdjustY(nSizeYPix );
3377 aMenuPos = aSelectRect.
Center();
3391 if (!bShouldDisableEditHyperlink)
3421 if ( nCellX >= nEditStartCol && nCellX <= nEditEndCol &&
3422 nCellY >= nEditStartRow && nCellY <= nEditEndRow )
3434 aTextPos -= aOutputArea.
TopRight();
3436 aTextPos.setX( aTextPos.Y() );
3437 aTextPos.setY( nTemp );
3440 aTextPos -= aOutputArea.
TopLeft();
3441 aTextPos += aVisArea.
TopLeft();
3447 if ( aCompare < aSelection || aCompare > aSelection )
3472 if ( aOutputArea.
Contains( aLogicPos ) )
3480 Point aTextPos = aLogicPos;
3483 aTextPos -= aOutputArea.
TopRight();
3485 aTextPos.setX( aTextPos.Y() );
3486 aTextPos.setY( nTemp );
3489 aTextPos -= aOutputArea.
TopLeft();
3490 aTextPos += aVisArea.
TopLeft();
3496 if ( aCompare < aSelection || aCompare > aSelection )
3518 bool bHitSelected =
false;
3522 bHitSelected =
true;
3527 bHitSelected =
true;
3536 bool bHitDraw =
false;
3543 bHitDraw = pDrawView->
MarkObj( aLogicPos );
3588 for (
auto& itr : rMapper.getDataSources())
3598 if(
SC_MOD()->IsRefDialogOpen() )
3602 SC_MOD()->EndReference();
3615 &&
SC_MOD()->GetInputOptions().GetEnterPasteMode() )
3621 uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard =
3623 if (xSystemClipboard.is())
3625 xSystemClipboard->setContents(
3626 uno::Reference<datatransfer::XTransferable>(),
3627 uno::Reference<datatransfer::clipboard::XClipboardOwner>());
3663 rBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_X);
3664 rBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_Y);
3675 if (pViewSh->SfxViewShell::KeyInput(rKEvt))
3681 if ( bHadKeyMarker )
3692 if ( bHadKeyMarker )
3711 Window::KeyInput(rKEvt);
3727 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3728 if (pOlView && pOlView->
GetWindow() ==
this)
3732 return Window::GetSurroundingText();
3748 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3749 if (pOlView && pOlView->
GetWindow() ==
this)
3753 return Window::GetSurroundingTextSelection();
3769 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3770 if (pOlView && pOlView->
GetWindow() ==
this)
3774 return Window::DeleteSurroundingText(rSelection);
3802#define SCROLL_SENSITIVE 20
3828 if ( nDx != 0 || nDy != 0 )
3840 bool bReturn =
false;
3867 SCCOL nCol1 = nPosX;
3869 if ( nCol2 > rDoc.
MaxCol() )
3871 nCol1 -= nCol2 - rDoc.
MaxCol();
3874 SCROW nRow1 = nPosY;
3876 if ( nRow2 > rDoc.
MaxRow() )
3878 nRow1 -= nRow2 - rDoc.
MaxRow();
3882 return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
3894 if (
rData.pCellTransfer )
3911 if (pSourceDoc == &rThisDoc)
3939 ScRange aSourceRange =
rData.pCellTransfer->GetRange();
3944 SCCOL nSizeX = nSourceEndX - nSourceStartX + 1;
3945 SCROW nSizeY = nSourceEndY - nSourceStartY + 1;
3948 nSizeY =
rData.pCellTransfer->GetNonFilteredRows();
3950 SCCOL nNewDragX = nPosX -
rData.pCellTransfer->GetDragHandleX();
3951 if (nNewDragX<0) nNewDragX=0;
3952 if (nNewDragX+(nSizeX-1) > rThisDoc.
MaxCol())
3953 nNewDragX = rThisDoc.
MaxCol()-(nSizeX-1);
3954 SCROW nNewDragY = nPosY -
rData.pCellTransfer->GetDragHandleY();
3955 if (nNewDragY<0) nNewDragY=0;
3956 if (nNewDragY+(nSizeY-1) > rThisDoc.
MaxRow())
3957 nNewDragY = rThisDoc.
MaxRow()-(nSizeY-1);
3979 if ( &rThisDoc == pSourceDoc && ( pDPObj = rThisDoc.
GetDPAtCursor( nNewDragX, nNewDragY, nTab ) ) !=
nullptr )
3983 bool bDPSort =
false;
3986 sheet::DataPilotTableHeaderData aDestData;
3988 bool bValid = ( aDestData.Dimension >= 0 );
3994 sheet::DataPilotTableHeaderData aSourceData;
3996 if ( aSourceData.Dimension != aDestData.Dimension || aSourceData.MemberName.isEmpty() )
4003 OUString aDimName = pDPObj->
GetDimName( aDestData.Dimension, bIsDataLayout );
4009 sheet::DataPilotFieldOrientation nOrient = pDim->
GetOrientation();
4010 if ( nOrient == sheet::DataPilotFieldOrientation_COLUMN )
4013 nSizeY = aOutRange.
aEnd.
Row() - nNewDragY + 1;
4016 else if ( nOrient == sheet::DataPilotFieldOrientation_ROW )
4019 nSizeX = aOutRange.
aEnd.
Col() - nNewDragX + 1;
4037 else if ( aState.mnState &
KEY_MOD2 )
4039 if ( &rThisDoc == pSourceDoc && nTab == aSourceRange.
aStart.
Tab() )
4043 if ( nDeltaX <= nDeltaY )
4052 if ( ( eDragInsertMode ==
INS_CELLSDOWN && nNewDragY <= nSourceEndY &&
4053 ( nNewDragX + nSizeX - 1 ) >= nSourceStartX && nNewDragX <= nSourceEndX &&
4054 ( nNewDragX != nSourceStartX || nNewDragY >= nSourceStartY ) ) ||
4055 ( eDragInsertMode ==
INS_CELLSRIGHT && nNewDragX <= nSourceEndX &&
4056 ( nNewDragY + nSizeY - 1 ) >= nSourceStartY && nNewDragY <= nSourceEndY &&
4057 ( nNewDragY != nSourceStartY || nNewDragX >= nSourceStartX ) ) )
4105 if (
rData.pCellTransfer )
4117 if (
rData.pCellTransfer)
4128 if ( !
rData.aLinkDoc.isEmpty() )
4132 if (pDocSh && pDocSh->
HasName())
4135 if (
rData.aLinkDoc != aThisName )
4138 else if (!
rData.aJumpTarget.isEmpty())
4154 nMyAction &= ~DND_ACTION_LINK;
4157 if ( !
rData.pDrawTransfer ||
4180 switch ( nMyAction )
4270 if ( !aDataHelper.
HasFormat( SotClipboardFormatId::SBA_DATAEXCHANGE ) )
4274 if ( aDataHelper.
HasFormat( SotClipboardFormatId::SOLK ) )
4275 return SotClipboardFormatId::SOLK;
4276 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) )
4277 return SotClipboardFormatId::UNIFORMRESOURCELOCATOR;
4278 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) )
4279 return SotClipboardFormatId::NETSCAPE_BOOKMARK;
4280 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4281 return SotClipboardFormatId::FILEGRPDESCRIPTOR;
4285 if ( aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ) )
4286 nFormatId = SotClipboardFormatId::DRAWING;
4287 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ) )
4288 nFormatId = SotClipboardFormatId::SVXB;
4289 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE ) )
4293 bool bDoRtf =
false;
4301 && ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) ) );
4304 nFormatId = aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
4306 nFormatId = SotClipboardFormatId::EMBED_SOURCE;
4308 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ) )
4309 nFormatId = SotClipboardFormatId::LINK_SOURCE;
4310 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SBA_DATAEXCHANGE ) )
4311 nFormatId = SotClipboardFormatId::SBA_DATAEXCHANGE;
4312 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE ) )
4313 nFormatId = SotClipboardFormatId::SBA_FIELDDATAEXCHANGE;
4314 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BIFF_8 ) )
4315 nFormatId = SotClipboardFormatId::BIFF_8;
4316 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BIFF_5 ) )
4317 nFormatId = SotClipboardFormatId::BIFF_5;
4318 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ) )
4319 nFormatId = SotClipboardFormatId::EMBED_SOURCE_OLE;
4320 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ) )
4321 nFormatId = SotClipboardFormatId::EMBEDDED_OBJ_OLE;
4322 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ) )
4323 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
4324 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) )
4325 nFormatId = SotClipboardFormatId::RTF;
4326 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) )
4327 nFormatId = SotClipboardFormatId::RICHTEXT;
4328 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::HTML ) )
4329 nFormatId = SotClipboardFormatId::HTML;
4330 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::HTML_SIMPLE ) )
4331 nFormatId = SotClipboardFormatId::HTML_SIMPLE;
4332 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SYLK ) )
4333 nFormatId = SotClipboardFormatId::SYLK;
4334 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK ) )
4335 nFormatId = SotClipboardFormatId::LINK;
4336 else if ( bPreferText && aDataHelper.
HasFormat( SotClipboardFormatId::STRING ) )
4337 nFormatId = SotClipboardFormatId::STRING;
4338 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILE_LIST ) )
4339 nFormatId = SotClipboardFormatId::FILE_LIST;
4340 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
4341 nFormatId = SotClipboardFormatId::SIMPLE_FILE;
4342 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::STRING_TSVC ) )
4343 nFormatId = SotClipboardFormatId::STRING_TSVC;
4344 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::STRING ) )
4345 nFormatId = SotClipboardFormatId::STRING;
4346 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
4347 nFormatId = SotClipboardFormatId::GDIMETAFILE;
4348 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::PNG ) )
4349 nFormatId = SotClipboardFormatId::PNG;
4350 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BITMAP ) )
4351 nFormatId = SotClipboardFormatId::BITMAP;
4361 if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ) )
4362 nFormatId = SotClipboardFormatId::LINK_SOURCE;
4363 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ) )
4364 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
4365 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK ) )
4366 nFormatId = SotClipboardFormatId::LINK;
4367 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILE_LIST ) )
4368 nFormatId = SotClipboardFormatId::FILE_LIST;
4369 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
4370 nFormatId = SotClipboardFormatId::SIMPLE_FILE;
4371 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SOLK ) )
4372 nFormatId = SotClipboardFormatId::SOLK;
4373 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) )
4374 nFormatId = SotClipboardFormatId::UNIFORMRESOURCELOCATOR;
4375 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) )
4376 nFormatId = SotClipboardFormatId::NETSCAPE_BOOKMARK;
4377 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4378 nFormatId = SotClipboardFormatId::FILEGRPDESCRIPTOR;
4394 const Point& rLogicPos,
sal_Int8 nDndAction )
4430 ScRange aDest( nDestPosX, nDestPosY, nThisTab,
4431 nDestPosX + nSizeX - 1, nDestPosY + nSizeY - 1, nThisTab );
4459 if (!bFiltered && pSourceDoc == &rThisDoc)
4473 OUString aChartName;
4480 sal_uInt16
nId = bIsMove ? SID_CHART_SOURCE : SID_CHART_ADDSOURCE;
4482 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
4483 { &aRangeItem, &aNameItem });
4486 else if ( rThisDoc.
GetDPAtCursor( nDestPosX, nDestPosY, nThisTab ) )
4490 ScAddress aDestPos( nDestPosX, nDestPosY, nThisTab );
4491 if ( aDestPos != aSource.
aStart )
4497 nSourceTab != nThisTab )
4499 OUString aUndo =
ScResId( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
4502 SCCOL nCorrectCursorPosCol = 0;
4503 SCROW nCorrectCursorPosRow = 0;
4512 if ( nThisTab == nSourceTab )
4518 bDone = aSource.
Move( 0, nSizeY, 0, aErrorRange, *pSourceDoc );
4519 nCorrectCursorPosRow = nSizeY;
4525 bDone = aSource.
Move( nSizeX, 0, 0, aErrorRange, *pSourceDoc );
4526 nCorrectCursorPosCol = nSizeX;
4568 bDone = aDest.
Move( 0, -nSizeY, 0, aErrorRange, rThisDoc );
4573 bDone = aDest.
Move( -nSizeX, 0, 0, aErrorRange, rThisDoc );
4610 else if ( !bFiltered && pSourceDoc )
4618 std::vector<SCTAB> nTabs;
4628 for(
SCTAB j=
i+1;j<nTabCount;j++)
4632 nTabs.push_back( j );
4640 pView->
ImportTables( pSrcShell,
static_cast<SCTAB>(nTabs.size()), nTabs.data(), bIsLink, nThisTab );
4650 OSL_ENSURE(pSourceSh,
"drag document has no shell");
4653 OUString aUndo =
ScResId( STR_UNDO_COPY );
4675 const OUString aQuote(
'"');
4697 nDestPosY + nSizeY - 1, nThisTab );
4713 OUString aUndo =
ScResId( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
4731 pView->
SetCursor( nDestPosX, nDestPosY );
4757 if (
rData.pCellTransfer)
4762 if ( !
rData.aLinkDoc.isEmpty() )
4769 if (pDocSh && pDocSh->
HasName())
4772 if (
rData.aLinkDoc == aThisName )
4777 if ( !
rData.aLinkTable.isEmpty() )
4780 else if ( !
rData.aLinkArea.isEmpty() )
4792 OSL_FAIL(
"drop with link: no sheet nor area");
4803 if (!bIsLink &&
rData.pDrawTransfer)
4813 aLogicPos,
rData.pDrawTransfer->GetModel(),
false,
u"A",
u"B");
4816 rData.pDrawTransfer->SetDragWasInternal();
4826 if (!
rData.aJumpTarget.isEmpty())