25#include <osl/diagnose.h>
60#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
61#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
62#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
63#include <com/sun/star/sheet/MemberResultFlags.hpp>
64#include <com/sun/star/sheet/TableValidationVisibility.hpp>
65#include <com/sun/star/awt/KeyModifier.hpp>
66#include <com/sun/star/awt/MouseButton.hpp>
67#include <com/sun/star/awt/XVclWindowPeer.hpp>
68#include <com/sun/star/script/vba/VBAEventId.hpp>
69#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
70#include <com/sun/star/text/textfield/Type.hpp>
79#include <document.hxx>
108#include <compiler.hxx>
119#include <overlayobject.hxx>
121#include <drawview.hxx>
128#include <uiobject.hxx>
135#include <officecfg/Office/Common.hxx>
147#include <LibreOfficeKit/LibreOfficeKitEnums.h>
150#include <boost/property_tree/json_parser.hpp>
155using namespace css::uno;
166#define SC_FILTERLISTBOX_LINES 12
170 , mnCol2(rDoc.MaxCol())
172 , mnRow2(rDoc.MaxRow())
178 return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2;
183 bool bChanged = mnCol1 != nCol1 || mnRow1 != nRow1 || mnCol2 != nCol2 || mnRow2 != nRow2;
196 : xBuilder(
Application::CreateBuilder(pParent,
"modules/scalc/ui/filterlist.ui"))
197 , xPopover(xBuilder->weld_popover(
"FilterList"))
198 , xTreeView(xBuilder->weld_tree_view(
"list"))
207 , nAsyncSelectHdl(nullptr)
241 pGridWin->ClickExtern();
254 if (!bInit && !bCancelled && !nAsyncSelectHdl)
256 int nPos = xTreeView->get_selected_index();
269 nAsyncSelectHdl =
nullptr;
272 auto xThis(shared_from_this());
273 pGridWin->FilterSelect(nSel);
274 if (xThis.use_count() == 1)
279 pGridWin->ClickExtern();
358 rPoint.
setX(nMirrorPX - rPoint.
X());
359 rRect.
SetLeft(nMirrorMM - nRight);
366 DropTargetHelper( this ),
367 DragSourceHelper( this ),
368 maVisibleRange(rData.GetDocument()),
371 nCursorHideCount( 0 ),
376 pDragDPObj( nullptr ),
381 nPagebreakBreak( 0 ),
389 aComboButton( GetOutDev() ),
392 aRFSelectedCorned(
NONE ),
393 maShowPageBreaksTimer(
"ScGridWindow maShowPageBreaksTimer"),
398 bPagebreakDrawn( false ),
401 bNeedsRepaint( false ),
402 bAutoMarkVisible( false ),
403 bListValButton( false )
425 OSL_FAIL(
"GridWindow: wrong position");
491 bool bMouseWasCaptured = mpFilterBox->MouseWasCaptured();
492 mpFilterBox->SetCancelled();
495 SAL_WARN_IF(bMouseWasCaptured,
"sc.ui",
"Is there a scenario where the mouse was captured before mouse down?");
496 if (bMouseWasCaptured)
504 if( rInfo.nCommand == SpellCallbackCommand::STARTSPELLDLG )
505 mrViewData.GetDispatcher().Execute( SID_SPELL_DIALOG, SfxCallMode::ASYNCHRON );
506 else if (rInfo.nCommand == SpellCallbackCommand::AUTOCORRECT_OPTIONS)
507 mrViewData.GetDispatcher().Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
533 virtual bool execute()
override
535 mpWindow->UpdateAutoFilterFromMenu(meMode);
549 virtual bool execute()
override
551 mpWindow->RefreshAutoFilterButton(maPos);
557class AutoFilterSubMenuAction :
public AutoFilterAction
564 : AutoFilterAction(
p,
eMode)
565 , m_pSubMenu(pSubMenu)
570class AutoFilterColorAction :
public AutoFilterSubMenuAction
577 : AutoFilterSubMenuAction(
p, pSubMenu,
eMode)
582 virtual bool execute()
override
584 const AutoFilterData*
pData =
585 static_cast<const AutoFilterData*
>(m_pSubMenu->getExtendedData());
596 ScViewData& rViewData = m_pSubMenu->GetViewData();
621 bool bActive =
false;
623 if (aItem.maColor == m_aColor
659class AutoFilterSortColorAction :
public AutoFilterSubMenuAction
667 : AutoFilterSubMenuAction(
p, pSubMenu,
eMode)
669 , m_rViewData(rViewData)
673 virtual bool execute()
override
675 const AutoFilterData*
pData =
676 static_cast<const AutoFilterData*
>(m_pSubMenu->getExtendedData());
689 if (nCol < aSortParam.nCol1 || nCol > aSortParam.
nCol2)
720class AutoFilterColorPopupStartAction :
public AutoFilterSubMenuAction
727 mbIsFilter(bIsFilter)
731 virtual bool execute()
override
733 const AutoFilterData*
pData =
734 static_cast<const AutoFilterData*
>(m_pSubMenu->getExtendedData());
743 ScViewData& rViewData = m_pSubMenu->GetViewData();
750 m_pSubMenu->clearMenuItems();
754 OUString aPaletteName(officecfg::Office::Common::UserColors::PaletteName::get());
756 std::vector<OUString> aPaletteNames = aPaletteManager.
GetPaletteList();
757 for (
size_t i = 0, nLen = aPaletteNames.size(); i < nLen; ++i)
759 if (aPaletteName == aPaletteNames[i])
765 if (!xUserColorList->Load())
766 xUserColorList =
nullptr;
782 for (
auto& rColor : aColors)
784 bool bActive =
false;
789 if (aItem.maColor == rColor
799 const bool bAutoColor = rColor ==
COL_AUTO;
805 xDev->SetOutputSize(aImageSize);
810 const Color aW(COL_WHITE);
811 const Color aG(0xef, 0xef, 0xef);
812 int nMinDim = std::min(aImageSize.Width(), aImageSize.Height()) + 1;
813 int nCheckSize = nMinDim / 3;
814 xDev->DrawCheckered(aRect.TopLeft(), aRect.GetSize(), std::min(nCheckSize, 8), aW, aG);
815 xDev->SetFillColor();
818 xDev->SetFillColor(rColor);
821 xDev->DrawRect(aRect);
826 ?
ScResId(SCSTR_FILTER_AUTOMATIC_COLOR)
827 :
ScResId(SCSTR_FILTER_NO_FILL);
830 m_pSubMenu->addMenuColorItem(
831 sText, bActive, *xDev, nMenu,
832 new AutoFilterColorAction(mpWindow, m_pSubMenu, eMode, rColor));
836 m_pSubMenu->addMenuColorItem(
837 sText, bActive, *xDev, nMenu,
838 new AutoFilterSortColorAction(mpWindow, m_pSubMenu, eMode, rColor, rViewData));
845 bool bFoundColorName =
false;
848 sal_Int32
nPos = xUserColorList->GetIndexOfColor(rColor);
851 XColorEntry* pColorEntry = xUserColorList->GetColor(nPos);
853 bFoundColorName =
true;
856 if (!bFoundColorName)
857 sName =
"#" + rColor.AsRGBHexString().toAsciiUpperCase();
861 m_pSubMenu->addMenuColorItem(
862 sName, bActive, *xDev, nMenu,
863 new AutoFilterColorAction(mpWindow, m_pSubMenu, eMode, rColor));
867 m_pSubMenu->addMenuColorItem(
868 sName, bActive, *xDev, nMenu,
869 new AutoFilterSortColorAction(mpWindow, m_pSubMenu, eMode, rColor,
878 m_pSubMenu->resizeToFitMenuItems();
890 mrItems(rItems), mrPool(rPool) {}
900 mrItems.push_back(aNew);
905class AddSelectedItemString
907 std::unordered_set<OUString>& mrSetString;
908 std::unordered_set<double>& mrSetValue;
910 explicit AddSelectedItemString(std::unordered_set<OUString>& rString, std::unordered_set<double>& rValue) :
911 mrSetString(rString), mrSetValue(rValue) {}
915 if( rItem.
meType == ScQueryEntry::QueryType::ByValue )
916 mrSetValue.insert(rItem.
mfVal);
922void collectUIInformation(
const OUString& aRow,
const OUString& aCol ,
const OUString& aevent)
925 aDescription.
aAction =
"LAUNCH";
926 aDescription.
aID =
"grid_window";
928 {
"ROW", aRow}, {
"COL", aCol}};
929 aDescription.
aParent =
"MainWindow";
930 aDescription.
aKeyWord =
"ScGridWinUIObject";
954 int nMaxTextWidth = 0;
955 if (aFilterEntries.
size() <= 10)
958 for (
const auto& rEntry : aFilterEntries)
960 const OUString& aText = rEntry.GetString();
961 nMaxTextWidth = std::max<int>(nMaxTextWidth,
mpAutoFilterPopup->GetTextWidth(aText) + aText.getLength() * 2);
968 auto itMax = aFilterEntries.
begin();
969 for (
auto it = itMax; it != aFilterEntries.
end(); ++it)
971 int nTextWidth = it->GetString().getLength();
972 if (nMaxTextWidth < nTextWidth)
974 nMaxTextWidth = nTextWidth;
978 nMaxTextWidth =
mpAutoFilterPopup->GetTextWidth(itMax->GetString()) + nMaxTextWidth * 2;
983 int nWindowWidth = std::min<int>(1024, nMaxTextWidth + 70);
985 nMaxTextWidth = std::max<int>(nMaxTextWidth, nWindowWidth - 70);
989 new AutoFilterPopupEndAction(
this,
ScAddress(nCol, nRow, nTab)));
990 std::unique_ptr<AutoFilterData>
pData(
new AutoFilterData);
1006 nSizeX = nSizeX / fZoomX;
1007 nSizeY = nSizeY / fZoomY;
1015 pData->mpData = pDBData;
1021 std::unordered_set<OUString> aSelectedString;
1022 std::unordered_set<double> aSelectedValue;
1023 bool bQueryByNonEmpty =
aEntries.size() == 1 &&
aEntries[0]->IsQueryByNonEmpty();
1025 if (!bQueryByNonEmpty)
1032 std::for_each(rItems.begin(), rItems.end(), AddSelectedItemString(aSelectedString, aSelectedValue));
1039 for (
auto it = aFilterEntries.
begin(); it != aFilterEntries.
end(); ++it)
1042 if (it->GetString().isEmpty())
1044 const OUString& aStringVal = it->GetString();
1045 const double aDoubleVal = it->GetValue();
1046 bool bSelected =
true;
1047 if (!aSelectedValue.empty() || !aSelectedString.empty())
1048 bSelected = aSelectedString.count(aStringVal) > 0;
1049 else if (bQueryByNonEmpty)
1051 mpAutoFilterPopup->addMember(aStringVal, aDoubleVal, bSelected, it->IsHiddenByFilter());
1056 for (
const auto& rEntry : aFilterEntries)
1058 const OUString& aStringVal = rEntry.GetString();
1059 const double aDoubleVal = rEntry.GetValue();
1060 const double aRDoubleVal = rEntry.GetRoundedValue();
1061 bool bSelected = !rEntry.IsHiddenByFilter();
1063 if (!aSelectedValue.empty() || !aSelectedString.empty())
1067 if (aDoubleVal == aRDoubleVal)
1068 bSelected = aSelectedValue.count(aDoubleVal) > 0
1069 || aSelectedString.count(aStringVal) > 0;
1071 bSelected = aSelectedValue.count(aDoubleVal) > 0
1072 || aSelectedValue.count(aRDoubleVal) > 0
1073 || aSelectedString.count(aStringVal) > 0;
1076 bSelected = aSelectedString.count(aStringVal) > 0;
1079 if ( rEntry.IsDate() )
1080 mpAutoFilterPopup->addDateMember( aStringVal, rEntry.GetValue(), bSelected, rEntry.IsHiddenByFilter());
1082 mpAutoFilterPopup->addMember( aStringVal, aRDoubleVal, bSelected, rEntry.IsHiddenByFilter(),
1094 pSubMenu->setPopupStartAction(
new AutoFilterColorPopupStartAction(
this, pSubMenu,
false));
1097 pSubMenu->setPopupStartAction(
new AutoFilterColorPopupStartAction(
this, pSubMenu,
true));
1100 pSubMenu->addMenuItem(
1102 pSubMenu->addMenuItem(
1104 pSubMenu->addMenuItem(
1106 pSubMenu->addMenuItem(
1108 pSubMenu->addSeparator();
1109 pSubMenu->addMenuItem(
1111 pSubMenu->resizeToFitMenuItems();
1130 collectUIInformation(OUString::number(nRow), OUString::number(nCol),
"AUTOFILTER");
1151 const AutoFilterData*
pData =
1172 if (nCol < aSortParam.nCol1 || nCol > aSortParam.
nCol2)
1179 aSortParam.
bByRow =
true;
1221 SAL_INFO(
"sc.ui",
"Apply autofilter to data when entries are the same");
1278 std::for_each(aResult.begin(), aResult.end(), AddItemToEntry(rItems, rPool));
1299 assert(
false &&
"should be handled by AutoFilterColorAction::execute");
1317 rScrPos = rViewData.
GetScrPos(nCol, nRow, eWhich);
1322 rScrSize =
Size(nSizeX-1, nSizeY-1);
1361 auto nSizeX = rCellRect.
GetWidth();
1367 if (nSizeX < nMinLOKWinWidth)
1368 nSizeX = nMinLOKWinWidth;
1378 auto nMaxToExpandTo = std::min(nSizeX,
static_cast<decltype(nSizeX)
>(300));
1379 if (aSize.
Width() < nMaxToExpandTo)
1389 if (!bLayoutRTL && aSize.
Width() > nSizeX)
1408 bool bMenuAtTop =
true;
1417 nRow = rScenRange.
aEnd.
Row() + 1;
1463 aCurrent = aTabName;
1472 sal_Int32
nPos = -1;
1473 if (!aCurrent.isEmpty())
1514 nSizeX = nSizeX / fZoomX;
1515 nSizeY = nSizeY / fZoomY;
1533 bool bEmpty =
false;
1534 std::vector<ScTypedStrData> aStrings;
1541 auto lambda = [](
const ScTypedStrData& rStr) {
return rStr.GetString().isEmpty(); };
1542 aStrings.erase(std::remove_if(aStrings.begin(), aStrings.end(), lambda), aStrings.end());
1545 if (aStrings.empty())
1553 bool bWait = aStrings.size() > 100;
1558 for (
const auto& rString : aStrings)
1560 const OUString& rFilterString = rString.GetString();
1572 sal_Int32 nSelPos = -1;
1578 std::unique_ptr<ScTypedStrData> pNew;
1579 OUString aDocStr = rDoc.
GetString(nCol, nRow, nTab);
1588 if (
pData->GetListType() == css::sheet::TableValidationVisibility::SORTEDASCENDING)
1592 nSelPos =
static_cast<sal_Int32
>(std::distance(aStrings.begin(), it));
1596 auto it = std::find_if(aStrings.begin(), aStrings.end(),
FindTypedStrData(*pNew,
true));
1597 if (it != aStrings.end())
1598 nSelPos =
static_cast<sal_Int32
>(std::distance(aStrings.begin(), it));
1622 rFilterBox.
select(nSelPos);
1628 collectUIInformation(OUString::number(nRow), OUString::number(nCol),
"SELECTMENU");
1634 OUString aString = rFilterBox.
get_text(
static_cast<sal_Int32
>(nSel));
1664 pView->
EnterData( nCol, nRow, nTab, rStr );
1707 if ( bAction && !rMEvt.
IsLeft() )
1710 bool bNewPointer =
false;
1769 bool bTop = ( aMousePos.
X() >= aStartPos.
X()-3 && aMousePos.
X() <= aStartPos.
X()+1 &&
1770 aMousePos.
Y() >= aStartPos.
Y()-3 && aMousePos.
Y() <= aStartPos.
Y()+1 );
1771 bool bBottom = ( aMousePos.
X() >= aEndPos.
X()-3 && aMousePos.
X() <= aEndPos.
X()+1 &&
1772 aMousePos.
Y() >= aEndPos.
Y()-3 && aMousePos.
Y() <= aEndPos.
Y()+1 );
1773 if ( bTop || bBottom )
1789 if (!bNewPointer && bAction)
1866 SAL_WARN_IF(bWasMouseCaptured,
"sc.ui",
"Is there a scenario where the mouse is captured before mouse down?");
1875 bool bDouble = (rMEvt.
GetClicks() == 2);
1911 SfxCallMode::SLOT | SfxCallMode::RECORD,
1912 { &aPosXItem, &aPosYItem });
1947 if ( nPosX >= nEditCol && nPosX <= nEndCol &&
1948 nPosY >= nEditRow && nPosY <= nEndRow )
1962 [pEditView, aOutputArea] {
2006 bool bCrossPointer =
TestMouse( rMEvt,
true );
2007 if ( bCrossPointer )
2015 if ( !bCrossPointer )
2030 if (((!bFormulaMode && !bEditMode) || bIsTiledRendering) && rMEvt.
IsLeft())
2060 if ( !bDouble && !bFormulaMode && rMEvt.
IsLeft() )
2070 SC_MOD()->InputEnterHandler();
2104 if ( aButtonRect.
Contains( aPos ) )
2146 if ( bDouble && !bCrossPointer )
2157 bool bAlt = rMEvt.
IsMod2();
2248 [pEditView, aOutputArea] {
2263 GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection )
2272 rBindings.
Invalidate( SID_HYPERLINK_GETLINK );
2313 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_WIDTH);
2314 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_HEIGHT);
2315 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_X);
2316 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_Y);
2317 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ANGLE);
2318 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ROT_X);
2319 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ROT_Y);
2320 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_AUTOWIDTH);
2321 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_AUTOHEIGHT);
2351 ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2352 if ( aBlockRange != aDelRange )
2354 if ( aDelRange.
aStart.
Row() == nStartRow )
2372 ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2375 ScAddress aEndPos( nFillCol, nFillRow, nTab );
2382 if ( aEndPos != aBlockRange.
aEnd )
2409 GetStyleSheetPool();
2421 case SfxStyleFamily::Para:
2426 case SfxStyleFamily::Page:
2434 rBindings.
Invalidate( SID_STATUS_PAGESTYLE );
2475 sheet::DataPilotTableHeaderData
aData;
2478 if ( (
aData.Flags & sheet::MemberResultFlags::HASMEMBER ) &&
2479 ! (
aData.Flags & sheet::MemberResultFlags::SUBTOTAL ) )
2481 css::sheet::DataPilotFieldOrientation nDummy;
2501 Sequence<sheet::DataPilotFieldFilter> aFilters;
2511 bool bEditAllowed =
true;
2518 if ( bSkipProtected && bSkipUnprotected )
2519 bEditAllowed =
false;
2520 else if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) )
2521 bEditAllowed =
false;
2550 bool bAlt = rMEvt.
IsMod2();
2555 OUString
aName, aUrl, aTarget;
2564 if (aUrl.startsWith(
"#")) {
2571 if (isTiledRendering && pViewShell &&
2578 int mouseX = aPos.
X() / fPPTX;
2579 OString aMsg(aUrl.toUtf8() +
" coordinates: " + aCursor +
", " + OString::number(mouseX));
2596 OUStringBuffer
aBuf;
2613 aBuf.append(
"#" + aUrlCalcA1);
2620 if( xVbaEvents.is() )
try
2629 ScAddress aCellPos( nPosX, nPosY, nTab );
2631 uno::Sequence< uno::Any > aArgs{
uno::Any(xCell) };
2632 xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs );
2635 catch( uno::Exception& )
2655 OSL_ENSURE( pDisp || bFormulaMode,
"Cursor moved on inactive View ?" );
2671 aAddr +=
":" + aAddr;
2687 SfxBoolItem aAlignCursorItem( FN_PARAM_2,
false );
2689 SfxCallMode::SLOT | SfxCallMode::RECORD,
2690 { &aPosItem, &aAlignCursorItem });
2755 [pEditView, aOutputArea] {
2809 if ( nPosX >= nEditCol && nPosX <= nEndCol &&
2810 nPosY >= nEditRow && nPosY <= nEndRow )
2822 pFld = pEditView->
GetField( aLogicClick );
2829 bool bAlt = rMEvt.
IsMod2();
2846 bool bCross =
false;
2853 if (rCorner !=
NONE)
2865 if (nBreakType != 0 )
2868 switch ( nBreakType )
2873 eNew = PointerStyle::ESize;
2878 eNew = PointerStyle::SSize;
2882 eNew = PointerStyle::SESize;
2886 eNew = PointerStyle::NESize;
2909 bool bAlt = rMEvt.
IsMod2();
2927 if (!bSkipSelectionUpdate)
2933 rEvent.Modifiers = 0;
2935 rEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
2937 rEvent.Modifiers |= css::awt::KeyModifier::MOD1;
2939 rEvent.Modifiers |= css::awt::KeyModifier::MOD2;
2941 rEvent.Modifiers |= css::awt::KeyModifier::MOD3;
2945 rEvent.Buttons |= css::awt::MouseButton::LEFT;
2947 rEvent.Buttons |= css::awt::MouseButton::RIGHT;
2954 rEvent.PopupTrigger =
false;
2961 if (
nType == NotifyEventType::MOUSEBUTTONUP ||
nType == NotifyEventType::MOUSEBUTTONDOWN )
2964 if (pWindow ==
this)
2973 css::awt::MouseEvent
aEvent;
2977 if (
nType == NotifyEventType::MOUSEBUTTONDOWN)
2987 if (
nType == NotifyEventType::MOUSEBUTTONDOWN )
3001 return Window::PreNotify( rNEvt );
3040 SC_MOD()->EndReference();
3065 CommandEvent aDragEvent( rPosPixel, CommandEventId::StartDrag,
true );
3078 pEditView->
Command( aDragEvent );
3121 nCmd == CommandEventId::ContextMenu )
3128 OSL_ENSURE( nCmd != CommandEventId::StartDrag,
"ScGridWindow::Command called with CommandEventId::StartDrag" );
3130 if (nCmd == CommandEventId::ModKeyChange)
3132 Window::Command(rCEvt);
3136 if ( nCmd == CommandEventId::StartExtTextInput ||
3137 nCmd == CommandEventId::EndExtTextInput ||
3138 nCmd == CommandEventId::ExtTextInput ||
3139 nCmd == CommandEventId::CursorPos ||
3140 nCmd == CommandEventId::QueryCharPosition )
3150 if ( pOlView && pOlView->
GetWindow() ==
this )
3158 if ( nCmd == CommandEventId::CursorPos && !bEditView )
3176 Window::Command( rCEvt );
3180 if ( nCmd == CommandEventId::PasteSelection )
3194 if ( nCmd == CommandEventId::InputLanguageChange )
3201 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
3205 if ( nCmd == CommandEventId::Wheel || nCmd == CommandEventId::StartAutoScroll || nCmd == CommandEventId::AutoScroll )
3209 Window::Command(rCEvt);
3213 if (nCmd == CommandEventId::GestureZoom)
3217 Window::Command(rCEvt);
3227 if (nCmd != CommandEventId::ContextMenu ||
SC_MOD()->GetIsWaterCan())
3243 Point aMenuPos = aPosPixel;
3251 if (bPosIsInEditView)
3256 bPosIsInEditView =
false;
3261 bPosIsInEditView =
false;
3263 if (!bPosIsInEditView)
3273 bool bSpellError =
false;
3274 SCCOL nColSpellError = nCellX;
3281 bool bSelectAllowed =
true;
3290 bSelectAllowed = bSelProtected;
3292 bSelectAllowed = bSelUnprotected;
3294 if (!bSelectAllowed)
3310 aSpellCheckCell.
assign(rDoc, aPos);
3314 nColSpellError = aPos.
Col();
3318 bSpellError = (
mpSpellCheckCxt->isMisspelled(nColSpellError, nCellY));
3339 if (bMouse && bSpellError)
3346 OSL_ENSURE( bEdit,
"Can not be switched in edit mode" );
3382 const OUString sOldText = pHdl ? pHdl->
GetEditString() :
"";
3392 || (!bDone && !bPosIsInEditView)))
3397 if (!bDone && nColSpellError != nCellX)
3418 aMenuPos.
AdjustX(bLayoutIsRTL ? -nSizeXPix : nSizeXPix );
3431 aMenuPos = aSelectRect.
Center();
3445 if (!bShouldDisableEditHyperlink)
3475 if ( nCellX >= nEditStartCol && nCellX <= nEditEndCol &&
3476 nCellY >= nEditStartRow && nCellY <= nEditEndRow )
3488 aTextPos -= aOutputArea.
TopRight();
3490 aTextPos.
setX( aTextPos.
Y() );
3491 aTextPos.
setY( nTemp );
3494 aTextPos -= aOutputArea.
TopLeft();
3495 aTextPos += aVisArea.
TopLeft();
3501 if ( aCompare < aSelection || aCompare > aSelection )
3526 if ( aOutputArea.
Contains( aLogicPos ) )
3534 Point aTextPos = aLogicPos;
3537 aTextPos -= aOutputArea.
TopRight();
3539 aTextPos.
setX( aTextPos.
Y() );
3540 aTextPos.
setY( nTemp );
3543 aTextPos -= aOutputArea.
TopLeft();
3544 aTextPos += aVisArea.
TopLeft();
3550 if ( aCompare < aSelection || aCompare > aSelection )
3572 bool bHitSelected =
false;
3576 bHitSelected =
true;
3581 bHitSelected =
true;
3590 bool bHitDraw =
false;
3597 bHitDraw = pDrawView->
MarkObj( aLogicPos );
3642 for (
auto& itr : rMapper.getDataSources())
3652 if(
SC_MOD()->IsRefDialogOpen() )
3656 SC_MOD()->EndReference();
3669 &&
SC_MOD()->GetInputOptions().GetEnterPasteMode() )
3675 uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard =
3677 if (xSystemClipboard.is())
3679 xSystemClipboard->setContents(
3680 uno::Reference<datatransfer::XTransferable>(),
3681 uno::Reference<datatransfer::clipboard::XClipboardOwner>());
3717 rBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_X);
3718 rBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_Y);
3729 if (pViewSh->SfxViewShell::KeyInput(rKEvt))
3735 if ( bHadKeyMarker )
3746 if ( bHadKeyMarker )
3765 Window::KeyInput(rKEvt);
3781 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3782 if (pOlView && pOlView->
GetWindow() ==
this)
3786 return Window::GetSurroundingText();
3802 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3803 if (pOlView && pOlView->
GetWindow() ==
this)
3807 return Window::GetSurroundingTextSelection();
3823 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3824 if (pOlView && pOlView->
GetWindow() ==
this)
3828 return Window::DeleteSurroundingText(rSelection);
3856#define SCROLL_SENSITIVE 20
3882 if ( nDx != 0 || nDy != 0 )
3894 bool bReturn =
false;
3921 SCCOL nCol1 = nPosX;
3923 if ( nCol2 > rDoc.
MaxCol() )
3925 nCol1 -= nCol2 - rDoc.
MaxCol();
3928 SCROW nRow1 = nPosY;
3930 if ( nRow2 > rDoc.
MaxRow() )
3932 nRow1 -= nRow2 - rDoc.
MaxRow();
3936 return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
3965 if (pSourceDoc == &rThisDoc)
3998 SCCOL nSizeX = nSourceEndX - nSourceStartX + 1;
3999 SCROW nSizeY = nSourceEndY - nSourceStartY + 1;
4005 if (nNewDragX<0) nNewDragX=0;
4006 if (nNewDragX+(nSizeX-1) > rThisDoc.
MaxCol())
4007 nNewDragX = rThisDoc.
MaxCol()-(nSizeX-1);
4009 if (nNewDragY<0) nNewDragY=0;
4010 if (nNewDragY+(nSizeY-1) > rThisDoc.
MaxRow())
4011 nNewDragY = rThisDoc.
MaxRow()-(nSizeY-1);
4033 if ( &rThisDoc == pSourceDoc && ( pDPObj = rThisDoc.
GetDPAtCursor( nNewDragX, nNewDragY, nTab ) ) !=
nullptr )
4037 bool bDPSort =
false;
4040 sheet::DataPilotTableHeaderData aDestData;
4042 bool bValid = ( aDestData.Dimension >= 0 );
4048 sheet::DataPilotTableHeaderData aSourceData;
4050 if ( aSourceData.Dimension != aDestData.Dimension || aSourceData.MemberName.isEmpty() )
4057 OUString aDimName = pDPObj->
GetDimName( aDestData.Dimension, bIsDataLayout );
4063 sheet::DataPilotFieldOrientation nOrient = pDim->
GetOrientation();
4064 if ( nOrient == sheet::DataPilotFieldOrientation_COLUMN )
4067 nSizeY = aOutRange.
aEnd.
Row() - nNewDragY + 1;
4070 else if ( nOrient == sheet::DataPilotFieldOrientation_ROW )
4073 nSizeX = aOutRange.
aEnd.
Col() - nNewDragX + 1;
4091 else if ( aState.mnState &
KEY_MOD2 )
4093 if ( &rThisDoc == pSourceDoc && nTab == aSourceRange.
aStart.
Tab() )
4097 if ( nDeltaX <= nDeltaY )
4106 if ( ( eDragInsertMode ==
INS_CELLSDOWN && nNewDragY <= nSourceEndY &&
4107 ( nNewDragX + nSizeX - 1 ) >= nSourceStartX && nNewDragX <= nSourceEndX &&
4108 ( nNewDragX != nSourceStartX || nNewDragY >= nSourceStartY ) ) ||
4109 ( eDragInsertMode ==
INS_CELLSRIGHT && nNewDragX <= nSourceEndX &&
4110 ( nNewDragY + nSizeY - 1 ) >= nSourceStartY && nNewDragY <= nSourceEndY &&
4111 ( nNewDragY != nSourceStartY || nNewDragX >= nSourceStartX ) ) )
4186 if (pDocSh && pDocSh->
HasName())
4208 nMyAction &= ~DND_ACTION_LINK;
4220 if ( IsDropFormatSupported(SotClipboardFormatId::SVXB)
4221 || IsDropFormatSupported(SotClipboardFormatId::GDIMETAFILE)
4222 || IsDropFormatSupported(SotClipboardFormatId::PNG)
4223 || IsDropFormatSupported(SotClipboardFormatId::BITMAP) )
4234 switch ( nMyAction )
4241 if ( IsDropFormatSupported( SotClipboardFormatId::EMBED_SOURCE ) ||
4242 IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE ) ||
4243 IsDropFormatSupported( SotClipboardFormatId::EMBED_SOURCE_OLE ) ||
4244 IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE_OLE ) ||
4245 IsDropFormatSupported( SotClipboardFormatId::EMBEDDED_OBJ_OLE ) ||
4246 IsDropFormatSupported( SotClipboardFormatId::STRING ) ||
4247 IsDropFormatSupported( SotClipboardFormatId::STRING_TSVC ) ||
4248 IsDropFormatSupported( SotClipboardFormatId::SYLK ) ||
4249 IsDropFormatSupported( SotClipboardFormatId::LINK ) ||
4250 IsDropFormatSupported( SotClipboardFormatId::HTML ) ||
4251 IsDropFormatSupported( SotClipboardFormatId::HTML_SIMPLE ) ||
4252 IsDropFormatSupported( SotClipboardFormatId::DIF ) ||
4253 IsDropFormatSupported( SotClipboardFormatId::DRAWING ) ||
4254 IsDropFormatSupported( SotClipboardFormatId::SVXB ) ||
4255 IsDropFormatSupported( SotClipboardFormatId::RTF ) ||
4256 IsDropFormatSupported( SotClipboardFormatId::RICHTEXT ) ||
4257 IsDropFormatSupported( SotClipboardFormatId::GDIMETAFILE ) ||
4258 IsDropFormatSupported( SotClipboardFormatId::PNG ) ||
4259 IsDropFormatSupported( SotClipboardFormatId::BITMAP ) ||
4260 IsDropFormatSupported( SotClipboardFormatId::SBA_DATAEXCHANGE ) ||
4261 IsDropFormatSupported( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE ) ||
4263 IsDropFormatSupported( SotClipboardFormatId::FILE_LIST ) ||
4264 IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
4265 IsDropFormatSupported( SotClipboardFormatId::SOLK ) ||
4266 IsDropFormatSupported( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) ||
4267 IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK ) ||
4268 IsDropFormatSupported( SotClipboardFormatId::FILEGRPDESCRIPTOR ) ) ) )
4275 if ( IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE ) ||
4276 IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE_OLE ) ||
4277 IsDropFormatSupported( SotClipboardFormatId::LINK ) ||
4278 IsDropFormatSupported( SotClipboardFormatId::FILE_LIST ) ||
4279 IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
4280 IsDropFormatSupported( SotClipboardFormatId::SOLK ) ||
4281 IsDropFormatSupported( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) ||
4282 IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK ) ||
4283 IsDropFormatSupported( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4324 if ( !aDataHelper.
HasFormat( SotClipboardFormatId::SBA_DATAEXCHANGE ) )
4328 if ( aDataHelper.
HasFormat( SotClipboardFormatId::SOLK ) )
4329 return SotClipboardFormatId::SOLK;
4330 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) )
4331 return SotClipboardFormatId::UNIFORMRESOURCELOCATOR;
4332 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) )
4333 return SotClipboardFormatId::NETSCAPE_BOOKMARK;
4334 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4335 return SotClipboardFormatId::FILEGRPDESCRIPTOR;
4339 if ( aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ) )
4340 nFormatId = SotClipboardFormatId::DRAWING;
4341 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ) )
4342 nFormatId = SotClipboardFormatId::SVXB;
4343 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE ) )
4347 bool bDoRtf =
false;
4355 && ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) ) );
4358 nFormatId = aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
4360 nFormatId = SotClipboardFormatId::EMBED_SOURCE;
4362 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ) )
4363 nFormatId = SotClipboardFormatId::LINK_SOURCE;
4364 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SBA_DATAEXCHANGE ) )
4365 nFormatId = SotClipboardFormatId::SBA_DATAEXCHANGE;
4366 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE ) )
4367 nFormatId = SotClipboardFormatId::SBA_FIELDDATAEXCHANGE;
4368 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BIFF_8 ) )
4369 nFormatId = SotClipboardFormatId::BIFF_8;
4370 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BIFF_5 ) )
4371 nFormatId = SotClipboardFormatId::BIFF_5;
4372 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ) )
4373 nFormatId = SotClipboardFormatId::EMBED_SOURCE_OLE;
4374 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ) )
4375 nFormatId = SotClipboardFormatId::EMBEDDED_OBJ_OLE;
4376 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ) )
4377 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
4378 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) )
4379 nFormatId = SotClipboardFormatId::RTF;
4380 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) )
4381 nFormatId = SotClipboardFormatId::RICHTEXT;
4382 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::HTML ) )
4383 nFormatId = SotClipboardFormatId::HTML;
4384 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::HTML_SIMPLE ) )
4385 nFormatId = SotClipboardFormatId::HTML_SIMPLE;
4386 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SYLK ) )
4387 nFormatId = SotClipboardFormatId::SYLK;
4388 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK ) )
4389 nFormatId = SotClipboardFormatId::LINK;
4390 else if ( bPreferText && aDataHelper.
HasFormat( SotClipboardFormatId::STRING ) )
4391 nFormatId = SotClipboardFormatId::STRING;
4392 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILE_LIST ) )
4393 nFormatId = SotClipboardFormatId::FILE_LIST;
4394 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
4395 nFormatId = SotClipboardFormatId::SIMPLE_FILE;
4396 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::STRING_TSVC ) )
4397 nFormatId = SotClipboardFormatId::STRING_TSVC;
4398 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::STRING ) )
4399 nFormatId = SotClipboardFormatId::STRING;
4400 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
4401 nFormatId = SotClipboardFormatId::GDIMETAFILE;
4402 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::PNG ) )
4403 nFormatId = SotClipboardFormatId::PNG;
4404 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BITMAP ) )
4405 nFormatId = SotClipboardFormatId::BITMAP;
4415 if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ) )
4416 nFormatId = SotClipboardFormatId::LINK_SOURCE;
4417 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ) )
4418 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
4419 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK ) )
4420 nFormatId = SotClipboardFormatId::LINK;
4421 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILE_LIST ) )
4422 nFormatId = SotClipboardFormatId::FILE_LIST;
4423 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
4424 nFormatId = SotClipboardFormatId::SIMPLE_FILE;
4425 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SOLK ) )
4426 nFormatId = SotClipboardFormatId::SOLK;
4427 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) )
4428 nFormatId = SotClipboardFormatId::UNIFORMRESOURCELOCATOR;
4429 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) )
4430 nFormatId = SotClipboardFormatId::NETSCAPE_BOOKMARK;
4431 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4432 nFormatId = SotClipboardFormatId::FILEGRPDESCRIPTOR;
4484 ScRange aDest( nDestPosX, nDestPosY, nThisTab,
4485 nDestPosX + nSizeX - 1, nDestPosY + nSizeY - 1, nThisTab );
4513 if (!bFiltered && pSourceDoc == &rThisDoc)
4527 OUString aChartName;
4534 sal_uInt16
nId = bIsMove ? SID_CHART_SOURCE : SID_CHART_ADDSOURCE;
4536 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
4537 { &aRangeItem, &aNameItem });
4540 else if ( rThisDoc.
GetDPAtCursor( nDestPosX, nDestPosY, nThisTab ) )
4544 ScAddress aDestPos( nDestPosX, nDestPosY, nThisTab );
4545 if ( aDestPos != aSource.
aStart )
4551 nSourceTab != nThisTab )
4553 OUString aUndo =
ScResId( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
4556 SCCOL nCorrectCursorPosCol = 0;
4557 SCROW nCorrectCursorPosRow = 0;
4566 if ( nThisTab == nSourceTab )
4572 bDone = aSource.
Move( 0, nSizeY, 0, aErrorRange, *pSourceDoc );
4573 nCorrectCursorPosRow = nSizeY;
4579 bDone = aSource.
Move( nSizeX, 0, 0, aErrorRange, *pSourceDoc );
4580 nCorrectCursorPosCol = nSizeX;
4622 bDone = aDest.
Move( 0, -nSizeY, 0, aErrorRange, rThisDoc );
4627 bDone = aDest.
Move( -nSizeX, 0, 0, aErrorRange, rThisDoc );
4664 else if ( !bFiltered && pSourceDoc )
4672 std::vector<SCTAB> nTabs;
4682 for(
SCTAB j=
i+1;j<nTabCount;j++)
4686 nTabs.push_back( j );
4694 pView->
ImportTables( pSrcShell,
static_cast<SCTAB>(nTabs.size()), nTabs.data(), bIsLink, nThisTab );
4704 OSL_ENSURE(pSourceSh,
"drag document has no shell");
4707 OUString aUndo =
ScResId( STR_UNDO_COPY );
4729 const OUString aQuote(
'"');
4751 nDestPosY + nSizeY - 1, nThisTab );
4767 OUString aUndo =
ScResId( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
4785 pView->
SetCursor( nDestPosX, nDestPosY );