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();
352 DropTargetHelper( this ),
353 DragSourceHelper( this ),
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)
952 mpAutoFilterPopup->addMember(aStringVal, aDoubleVal, bSelected, it->IsHiddenByFilter());
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 = !rEntry.IsHiddenByFilter();
964 if (!aSelectedValue.empty() || !aSelectedString.empty())
968 if (aDoubleVal == aRDoubleVal)
969 bSelected = aSelectedValue.count(aDoubleVal) > 0
970 || aSelectedString.count(aStringVal) > 0;
972 bSelected = aSelectedValue.count(aDoubleVal) > 0
973 || aSelectedValue.count(aRDoubleVal) > 0
974 || aSelectedString.count(aStringVal) > 0;
977 bSelected = aSelectedString.count(aStringVal) > 0;
980 if ( rEntry.IsDate() )
981 mpAutoFilterPopup->addDateMember( aStringVal, rEntry.GetValue(), bSelected, rEntry.IsHiddenByFilter());
983 mpAutoFilterPopup->addMember( aStringVal, aRDoubleVal, bSelected, rEntry.IsHiddenByFilter(),
996 pSubMenu->setPopupStartAction(
new AutoFilterColorPopupStartAction(
this, pSubMenu));
999 pSubMenu->addMenuItem(
1001 pSubMenu->addMenuItem(
1003 pSubMenu->addMenuItem(
1005 pSubMenu->addMenuItem(
1007 pSubMenu->addSeparator();
1008 pSubMenu->addMenuItem(
1010 pSubMenu->resizeToFitMenuItems();
1029 collectUIInformation(OUString::number(nRow), OUString::number(nCol),
"AUTOFILTER");
1050 const AutoFilterData*
pData =
1071 if (nCol < aSortParam.nCol1 || nCol > aSortParam.
nCol2)
1078 aSortParam.
bByRow =
true;
1119 SAL_INFO(
"sc.ui",
"Apply autofilter to data when entries are the same");
1176 std::for_each(aResult.begin(), aResult.end(), AddItemToEntry(rItems, rPool));
1197 assert(
false &&
"should be handled by AutoFilterColorAction::execute");
1215 rScrPos = rViewData.
GetScrPos(nCol, nRow, eWhich);
1220 rScrSize =
Size(nSizeX-1, nSizeY-1);
1259 auto nSizeX = rCellRect.
GetWidth();
1265 if (nSizeX < nMinLOKWinWidth)
1266 nSizeX = nMinLOKWinWidth;
1276 auto nMaxToExpandTo = std::min(nSizeX,
static_cast<decltype(nSizeX)
>(300));
1277 if (aSize.
Width() < nMaxToExpandTo)
1287 if (!bLayoutRTL && aSize.
Width() > nSizeX)
1306 bool bMenuAtTop =
true;
1315 nRow = rScenRange.
aEnd.
Row() + 1;
1330 aPos.AdjustX( -nSizeX );
1361 aCurrent = aTabName;
1370 sal_Int32
nPos = -1;
1371 if (!aCurrent.isEmpty())
1410 aPos.setX(aPos.getX() / fZoomX);
1411 aPos.setY(aPos.getY() / fZoomY);
1412 nSizeX = nSizeX / fZoomX;
1413 nSizeY = nSizeY / fZoomY;
1417 aPos.AdjustX( -nSizeX );
1431 bool bEmpty =
false;
1432 std::vector<ScTypedStrData> aStrings;
1439 auto lambda = [](
const ScTypedStrData& rStr) {
return rStr.GetString().isEmpty(); };
1440 aStrings.erase(std::remove_if(aStrings.begin(), aStrings.end(), lambda), aStrings.end());
1443 if (aStrings.empty())
1451 bool bWait = aStrings.size() > 100;
1456 for (
const auto& rString : aStrings)
1458 const OUString& rFilterString = rString.GetString();
1470 sal_Int32 nSelPos = -1;
1476 std::unique_ptr<ScTypedStrData> pNew;
1477 OUString aDocStr = rDoc.
GetString(nCol, nRow, nTab);
1486 if (
pData->GetListType() == css::sheet::TableValidationVisibility::SORTEDASCENDING)
1490 nSelPos =
static_cast<sal_Int32
>(std::distance(aStrings.begin(), it));
1494 auto it = std::find_if(aStrings.begin(), aStrings.end(),
FindTypedStrData(*pNew,
true));
1495 if (it != aStrings.end())
1496 nSelPos =
static_cast<sal_Int32
>(std::distance(aStrings.begin(), it));
1520 rFilterBox.
select(nSelPos);
1526 collectUIInformation(OUString::number(nRow), OUString::number(nCol),
"SELECTMENU");
1532 OUString aString = rFilterBox.
get_text(
static_cast<sal_Int32
>(nSel));
1562 pView->
EnterData( nCol, nRow, nTab, rStr );
1605 if ( bAction && !rMEvt.
IsLeft() )
1608 bool bNewPointer =
false;
1664 aStartPos.AdjustX(2 );
1665 aEndPos.AdjustX(2 );
1667 bool bTop = ( aMousePos.X() >= aStartPos.X()-3 && aMousePos.X() <= aStartPos.X()+1 &&
1668 aMousePos.Y() >= aStartPos.Y()-3 && aMousePos.Y() <= aStartPos.Y()+1 );
1669 bool bBottom = ( aMousePos.X() >= aEndPos.X()-3 && aMousePos.X() <= aEndPos.X()+1 &&
1670 aMousePos.Y() >= aEndPos.Y()-3 && aMousePos.Y() <= aEndPos.Y()+1 );
1671 if ( bTop || bBottom )
1687 if (!bNewPointer && bAction)
1764 SAL_WARN_IF(bWasMouseCaptured,
"sc.ui",
"Is there a scenario where the mouse is captured before mouse down?");
1773 bool bDouble = (rMEvt.
GetClicks() == 2);
1809 SfxCallMode::SLOT | SfxCallMode::RECORD,
1810 { &aPosXItem, &aPosYItem });
1845 if ( nPosX >= nEditCol && nPosX <= nEndCol &&
1846 nPosY >= nEditRow && nPosY <= nEndRow )
1886 bool bCrossPointer =
TestMouse( rMEvt,
true );
1887 if ( bCrossPointer )
1895 if ( !bCrossPointer )
1910 if (((!bFormulaMode && !bEditMode) || bIsTiledRendering) && rMEvt.
IsLeft())
1940 if ( !bDouble && !bFormulaMode && rMEvt.
IsLeft() )
1950 SC_MOD()->InputEnterHandler();
1977 if ( aButtonRect.
Contains( aPos ) )
2019 if ( bDouble && !bCrossPointer )
2030 bool bAlt = rMEvt.
IsMod2();
2118 GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection )
2127 rBindings.
Invalidate( SID_HYPERLINK_GETLINK );
2168 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_WIDTH);
2169 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_HEIGHT);
2170 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_X);
2171 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_Y);
2172 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ANGLE);
2173 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ROT_X);
2174 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_ROT_Y);
2175 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_AUTOWIDTH);
2176 rFrmBindings.
Invalidate(SID_ATTR_TRANSFORM_AUTOHEIGHT);
2206 ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2207 if ( aBlockRange != aDelRange )
2209 if ( aDelRange.
aStart.
Row() == nStartRow )
2227 ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
2230 ScAddress aEndPos( nFillCol, nFillRow, nTab );
2237 if ( aEndPos != aBlockRange.
aEnd )
2264 GetStyleSheetPool();
2276 case SfxStyleFamily::Para:
2281 case SfxStyleFamily::Page:
2289 rBindings.
Invalidate( SID_STATUS_PAGESTYLE );
2330 sheet::DataPilotTableHeaderData
aData;
2333 if ( (
aData.Flags & sheet::MemberResultFlags::HASMEMBER ) &&
2334 ! (
aData.Flags & sheet::MemberResultFlags::SUBTOTAL ) )
2336 css::sheet::DataPilotFieldOrientation nDummy;
2356 Sequence<sheet::DataPilotFieldFilter> aFilters;
2366 bool bEditAllowed =
true;
2373 if ( bSkipProtected && bSkipUnprotected )
2374 bEditAllowed =
false;
2375 else if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) )
2376 bEditAllowed =
false;
2405 bool bAlt = rMEvt.
IsMod2();
2410 OUString
aName, aUrl, aTarget;
2419 if (aUrl.startsWith(
"#")) {
2426 if (isTiledRendering && pViewShell &&
2433 int mouseX = aPos.X() / fPPTX;
2434 OString aMsg(aUrl.toUtf8() +
" coordinates: " + aCursor +
", " + OString::number(mouseX));
2451 OUStringBuffer
aBuf;
2464 aBuf.append(aRefCalcA1);
2472 aBuf.append(aUrlCalcA1);
2479 if( xVbaEvents.is() )
try
2488 ScAddress aCellPos( nPosX, nPosY, nTab );
2490 uno::Sequence< uno::Any > aArgs{
uno::Any(xCell) };
2491 xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs );
2494 catch( uno::Exception& )
2514 OSL_ENSURE( pDisp || bFormulaMode,
"Cursor moved on inactive View ?" );
2530 aAddr +=
":" + aAddr;
2546 SfxBoolItem aAlignCursorItem( FN_PARAM_2,
false );
2548 SfxCallMode::SLOT | SfxCallMode::RECORD,
2549 { &aPosItem, &aAlignCursorItem });
2649 if ( nPosX >= nEditCol && nPosX <= nEndCol &&
2650 nPosY >= nEditRow && nPosY <= nEndRow )
2662 pFld = pEditView->
GetField( aLogicClick );
2669 bool bAlt = rMEvt.
IsMod2();
2686 bool bCross =
false;
2693 if (rCorner !=
NONE)
2705 if (nBreakType != 0 )
2708 switch ( nBreakType )
2713 eNew = PointerStyle::ESize;
2718 eNew = PointerStyle::SSize;
2722 eNew = PointerStyle::SESize;
2726 eNew = PointerStyle::NESize;
2749 bool bAlt = rMEvt.
IsMod2();
2767 if (!bSkipSelectionUpdate)
2773 rEvent.Modifiers = 0;
2775 rEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
2777 rEvent.Modifiers |= css::awt::KeyModifier::MOD1;
2779 rEvent.Modifiers |= css::awt::KeyModifier::MOD2;
2781 rEvent.Modifiers |= css::awt::KeyModifier::MOD3;
2785 rEvent.Buttons |= css::awt::MouseButton::LEFT;
2787 rEvent.Buttons |= css::awt::MouseButton::RIGHT;
2794 rEvent.PopupTrigger =
false;
2801 if (
nType == NotifyEventType::MOUSEBUTTONUP ||
nType == NotifyEventType::MOUSEBUTTONDOWN )
2804 if (pWindow ==
this)
2813 css::awt::MouseEvent
aEvent;
2817 if (
nType == NotifyEventType::MOUSEBUTTONDOWN)
2827 if (
nType == NotifyEventType::MOUSEBUTTONDOWN )
2841 return Window::PreNotify( rNEvt );
2880 SC_MOD()->EndReference();
2905 CommandEvent aDragEvent( rPosPixel, CommandEventId::StartDrag,
true );
2918 pEditView->
Command( aDragEvent );
2961 nCmd == CommandEventId::ContextMenu )
2968 OSL_ENSURE( nCmd != CommandEventId::StartDrag,
"ScGridWindow::Command called with CommandEventId::StartDrag" );
2970 if (nCmd == CommandEventId::ModKeyChange)
2972 Window::Command(rCEvt);
2976 if ( nCmd == CommandEventId::StartExtTextInput ||
2977 nCmd == CommandEventId::EndExtTextInput ||
2978 nCmd == CommandEventId::ExtTextInput ||
2979 nCmd == CommandEventId::CursorPos ||
2980 nCmd == CommandEventId::QueryCharPosition )
2990 if ( pOlView && pOlView->
GetWindow() ==
this )
2998 if ( nCmd == CommandEventId::CursorPos && !bEditView )
3016 Window::Command( rCEvt );
3020 if ( nCmd == CommandEventId::PasteSelection )
3034 if ( nCmd == CommandEventId::InputLanguageChange )
3041 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
3045 if ( nCmd == CommandEventId::Wheel || nCmd == CommandEventId::StartAutoScroll || nCmd == CommandEventId::AutoScroll )
3049 Window::Command(rCEvt);
3053 if (nCmd == CommandEventId::GestureZoom)
3057 Window::Command(rCEvt);
3067 if (nCmd != CommandEventId::ContextMenu ||
SC_MOD()->GetIsWaterCan())
3083 Point aMenuPos = aPosPixel;
3091 if (bPosIsInEditView)
3096 bPosIsInEditView =
false;
3101 bPosIsInEditView =
false;
3103 if (!bPosIsInEditView)
3113 bool bSpellError =
false;
3114 SCCOL nColSpellError = nCellX;
3121 bool bSelectAllowed =
true;
3130 bSelectAllowed = bSelProtected;
3132 bSelectAllowed = bSelUnprotected;
3134 if (!bSelectAllowed)
3150 aSpellCheckCell.
assign(rDoc, aPos);
3154 nColSpellError = aPos.
Col();
3158 bSpellError = (
mpSpellCheckCxt->isMisspelled(nColSpellError, nCellY));
3179 if (bMouse && bSpellError)
3186 OSL_ENSURE( bEdit,
"Can not be switched in edit mode" );
3201 aLogicPos.AdjustX(pCur->
GetWidth() );
3202 aLogicPos.AdjustY(pCur->
GetHeight() / 2 );
3222 const OUString sOldText = pHdl ? pHdl->
GetEditString() :
"";
3232 || (!bDone && !bPosIsInEditView)))
3237 if (!bDone && nColSpellError != nCellX)
3258 aMenuPos.AdjustX(bLayoutIsRTL ? -nSizeXPix : nSizeXPix );
3259 aMenuPos.AdjustY(nSizeYPix );
3271 aMenuPos = aSelectRect.
Center();
3285 if (!bShouldDisableEditHyperlink)
3315 if ( nCellX >= nEditStartCol && nCellX <= nEditEndCol &&
3316 nCellY >= nEditStartRow && nCellY <= nEditEndRow )
3328 aTextPos -= aOutputArea.
TopRight();
3330 aTextPos.setX( aTextPos.Y() );
3331 aTextPos.setY( nTemp );
3334 aTextPos -= aOutputArea.
TopLeft();
3335 aTextPos += aVisArea.
TopLeft();
3341 if ( aCompare < aSelection || aCompare > aSelection )
3366 if ( aOutputArea.
Contains( aLogicPos ) )
3374 Point aTextPos = aLogicPos;
3377 aTextPos -= aOutputArea.
TopRight();
3379 aTextPos.setX( aTextPos.Y() );
3380 aTextPos.setY( nTemp );
3383 aTextPos -= aOutputArea.
TopLeft();
3384 aTextPos += aVisArea.
TopLeft();
3390 if ( aCompare < aSelection || aCompare > aSelection )
3412 bool bHitSelected =
false;
3416 bHitSelected =
true;
3421 bHitSelected =
true;
3430 bool bHitDraw =
false;
3437 bHitDraw = pDrawView->
MarkObj( aLogicPos );
3482 for (
auto& itr : rMapper.getDataSources())
3492 if(
SC_MOD()->IsRefDialogOpen() )
3496 SC_MOD()->EndReference();
3509 &&
SC_MOD()->GetInputOptions().GetEnterPasteMode() )
3515 uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard =
3517 if (xSystemClipboard.is())
3519 xSystemClipboard->setContents(
3520 uno::Reference<datatransfer::XTransferable>(),
3521 uno::Reference<datatransfer::clipboard::XClipboardOwner>());
3557 rBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_X);
3558 rBindings.
Invalidate(SID_ATTR_TRANSFORM_POS_Y);
3569 if (pViewSh->SfxViewShell::KeyInput(rKEvt))
3575 if ( bHadKeyMarker )
3586 if ( bHadKeyMarker )
3605 Window::KeyInput(rKEvt);
3621 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3622 if (pOlView && pOlView->
GetWindow() ==
this)
3626 return Window::GetSurroundingText();
3642 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3643 if (pOlView && pOlView->
GetWindow() ==
this)
3647 return Window::GetSurroundingTextSelection();
3663 OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
3664 if (pOlView && pOlView->
GetWindow() ==
this)
3668 return Window::DeleteSurroundingText(rSelection);
3696#define SCROLL_SENSITIVE 20
3722 if ( nDx != 0 || nDy != 0 )
3734 bool bReturn =
false;
3761 SCCOL nCol1 = nPosX;
3763 if ( nCol2 > rDoc.
MaxCol() )
3765 nCol1 -= nCol2 - rDoc.
MaxCol();
3768 SCROW nRow1 = nPosY;
3770 if ( nRow2 > rDoc.
MaxRow() )
3772 nRow1 -= nRow2 - rDoc.
MaxRow();
3776 return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
3805 if (pSourceDoc == &rThisDoc)
3838 SCCOL nSizeX = nSourceEndX - nSourceStartX + 1;
3839 SCROW nSizeY = nSourceEndY - nSourceStartY + 1;
3845 if (nNewDragX<0) nNewDragX=0;
3846 if (nNewDragX+(nSizeX-1) > rThisDoc.
MaxCol())
3847 nNewDragX = rThisDoc.
MaxCol()-(nSizeX-1);
3849 if (nNewDragY<0) nNewDragY=0;
3850 if (nNewDragY+(nSizeY-1) > rThisDoc.
MaxRow())
3851 nNewDragY = rThisDoc.
MaxRow()-(nSizeY-1);
3873 if ( &rThisDoc == pSourceDoc && ( pDPObj = rThisDoc.
GetDPAtCursor( nNewDragX, nNewDragY, nTab ) ) !=
nullptr )
3877 bool bDPSort =
false;
3880 sheet::DataPilotTableHeaderData aDestData;
3882 bool bValid = ( aDestData.Dimension >= 0 );
3888 sheet::DataPilotTableHeaderData aSourceData;
3890 if ( aSourceData.Dimension != aDestData.Dimension || aSourceData.MemberName.isEmpty() )
3897 OUString aDimName = pDPObj->
GetDimName( aDestData.Dimension, bIsDataLayout );
3903 sheet::DataPilotFieldOrientation nOrient = pDim->
GetOrientation();
3904 if ( nOrient == sheet::DataPilotFieldOrientation_COLUMN )
3907 nSizeY = aOutRange.
aEnd.
Row() - nNewDragY + 1;
3910 else if ( nOrient == sheet::DataPilotFieldOrientation_ROW )
3913 nSizeX = aOutRange.
aEnd.
Col() - nNewDragX + 1;
3931 else if ( aState.mnState &
KEY_MOD2 )
3933 if ( &rThisDoc == pSourceDoc && nTab == aSourceRange.
aStart.
Tab() )
3937 if ( nDeltaX <= nDeltaY )
3946 if ( ( eDragInsertMode ==
INS_CELLSDOWN && nNewDragY <= nSourceEndY &&
3947 ( nNewDragX + nSizeX - 1 ) >= nSourceStartX && nNewDragX <= nSourceEndX &&
3948 ( nNewDragX != nSourceStartX || nNewDragY >= nSourceStartY ) ) ||
3949 ( eDragInsertMode ==
INS_CELLSRIGHT && nNewDragX <= nSourceEndX &&
3950 ( nNewDragY + nSizeY - 1 ) >= nSourceStartY && nNewDragY <= nSourceEndY &&
3951 ( nNewDragY != nSourceStartY || nNewDragX >= nSourceStartX ) ) )
4026 if (pDocSh && pDocSh->
HasName())
4048 nMyAction &= ~DND_ACTION_LINK;
4060 if ( IsDropFormatSupported(SotClipboardFormatId::SVXB)
4061 || IsDropFormatSupported(SotClipboardFormatId::GDIMETAFILE)
4062 || IsDropFormatSupported(SotClipboardFormatId::PNG)
4063 || IsDropFormatSupported(SotClipboardFormatId::BITMAP) )
4074 switch ( nMyAction )
4081 if ( IsDropFormatSupported( SotClipboardFormatId::EMBED_SOURCE ) ||
4082 IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE ) ||
4083 IsDropFormatSupported( SotClipboardFormatId::EMBED_SOURCE_OLE ) ||
4084 IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE_OLE ) ||
4085 IsDropFormatSupported( SotClipboardFormatId::EMBEDDED_OBJ_OLE ) ||
4086 IsDropFormatSupported( SotClipboardFormatId::STRING ) ||
4087 IsDropFormatSupported( SotClipboardFormatId::STRING_TSVC ) ||
4088 IsDropFormatSupported( SotClipboardFormatId::SYLK ) ||
4089 IsDropFormatSupported( SotClipboardFormatId::LINK ) ||
4090 IsDropFormatSupported( SotClipboardFormatId::HTML ) ||
4091 IsDropFormatSupported( SotClipboardFormatId::HTML_SIMPLE ) ||
4092 IsDropFormatSupported( SotClipboardFormatId::DIF ) ||
4093 IsDropFormatSupported( SotClipboardFormatId::DRAWING ) ||
4094 IsDropFormatSupported( SotClipboardFormatId::SVXB ) ||
4095 IsDropFormatSupported( SotClipboardFormatId::RTF ) ||
4096 IsDropFormatSupported( SotClipboardFormatId::RICHTEXT ) ||
4097 IsDropFormatSupported( SotClipboardFormatId::GDIMETAFILE ) ||
4098 IsDropFormatSupported( SotClipboardFormatId::PNG ) ||
4099 IsDropFormatSupported( SotClipboardFormatId::BITMAP ) ||
4100 IsDropFormatSupported( SotClipboardFormatId::SBA_DATAEXCHANGE ) ||
4101 IsDropFormatSupported( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE ) ||
4103 IsDropFormatSupported( SotClipboardFormatId::FILE_LIST ) ||
4104 IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
4105 IsDropFormatSupported( SotClipboardFormatId::SOLK ) ||
4106 IsDropFormatSupported( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) ||
4107 IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK ) ||
4108 IsDropFormatSupported( SotClipboardFormatId::FILEGRPDESCRIPTOR ) ) ) )
4115 if ( IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE ) ||
4116 IsDropFormatSupported( SotClipboardFormatId::LINK_SOURCE_OLE ) ||
4117 IsDropFormatSupported( SotClipboardFormatId::LINK ) ||
4118 IsDropFormatSupported( SotClipboardFormatId::FILE_LIST ) ||
4119 IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
4120 IsDropFormatSupported( SotClipboardFormatId::SOLK ) ||
4121 IsDropFormatSupported( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) ||
4122 IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK ) ||
4123 IsDropFormatSupported( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4164 if ( !aDataHelper.
HasFormat( SotClipboardFormatId::SBA_DATAEXCHANGE ) )
4168 if ( aDataHelper.
HasFormat( SotClipboardFormatId::SOLK ) )
4169 return SotClipboardFormatId::SOLK;
4170 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) )
4171 return SotClipboardFormatId::UNIFORMRESOURCELOCATOR;
4172 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) )
4173 return SotClipboardFormatId::NETSCAPE_BOOKMARK;
4174 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4175 return SotClipboardFormatId::FILEGRPDESCRIPTOR;
4179 if ( aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ) )
4180 nFormatId = SotClipboardFormatId::DRAWING;
4181 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ) )
4182 nFormatId = SotClipboardFormatId::SVXB;
4183 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE ) )
4187 bool bDoRtf =
false;
4195 && ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) ) );
4198 nFormatId = aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
4200 nFormatId = SotClipboardFormatId::EMBED_SOURCE;
4202 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ) )
4203 nFormatId = SotClipboardFormatId::LINK_SOURCE;
4204 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SBA_DATAEXCHANGE ) )
4205 nFormatId = SotClipboardFormatId::SBA_DATAEXCHANGE;
4206 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE ) )
4207 nFormatId = SotClipboardFormatId::SBA_FIELDDATAEXCHANGE;
4208 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BIFF_8 ) )
4209 nFormatId = SotClipboardFormatId::BIFF_8;
4210 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BIFF_5 ) )
4211 nFormatId = SotClipboardFormatId::BIFF_5;
4212 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBED_SOURCE_OLE ) )
4213 nFormatId = SotClipboardFormatId::EMBED_SOURCE_OLE;
4214 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::EMBEDDED_OBJ_OLE ) )
4215 nFormatId = SotClipboardFormatId::EMBEDDED_OBJ_OLE;
4216 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ) )
4217 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
4218 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) )
4219 nFormatId = SotClipboardFormatId::RTF;
4220 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) )
4221 nFormatId = SotClipboardFormatId::RICHTEXT;
4222 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::HTML ) )
4223 nFormatId = SotClipboardFormatId::HTML;
4224 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::HTML_SIMPLE ) )
4225 nFormatId = SotClipboardFormatId::HTML_SIMPLE;
4226 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SYLK ) )
4227 nFormatId = SotClipboardFormatId::SYLK;
4228 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK ) )
4229 nFormatId = SotClipboardFormatId::LINK;
4230 else if ( bPreferText && aDataHelper.
HasFormat( SotClipboardFormatId::STRING ) )
4231 nFormatId = SotClipboardFormatId::STRING;
4232 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILE_LIST ) )
4233 nFormatId = SotClipboardFormatId::FILE_LIST;
4234 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
4235 nFormatId = SotClipboardFormatId::SIMPLE_FILE;
4236 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::STRING_TSVC ) )
4237 nFormatId = SotClipboardFormatId::STRING_TSVC;
4238 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::STRING ) )
4239 nFormatId = SotClipboardFormatId::STRING;
4240 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
4241 nFormatId = SotClipboardFormatId::GDIMETAFILE;
4242 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::PNG ) )
4243 nFormatId = SotClipboardFormatId::PNG;
4244 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::BITMAP ) )
4245 nFormatId = SotClipboardFormatId::BITMAP;
4255 if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE ) )
4256 nFormatId = SotClipboardFormatId::LINK_SOURCE;
4257 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK_SOURCE_OLE ) )
4258 nFormatId = SotClipboardFormatId::LINK_SOURCE_OLE;
4259 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::LINK ) )
4260 nFormatId = SotClipboardFormatId::LINK;
4261 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILE_LIST ) )
4262 nFormatId = SotClipboardFormatId::FILE_LIST;
4263 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
4264 nFormatId = SotClipboardFormatId::SIMPLE_FILE;
4265 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SOLK ) )
4266 nFormatId = SotClipboardFormatId::SOLK;
4267 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) )
4268 nFormatId = SotClipboardFormatId::UNIFORMRESOURCELOCATOR;
4269 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) )
4270 nFormatId = SotClipboardFormatId::NETSCAPE_BOOKMARK;
4271 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) )
4272 nFormatId = SotClipboardFormatId::FILEGRPDESCRIPTOR;
4288 const Point& rLogicPos,
sal_Int8 nDndAction )
4324 ScRange aDest( nDestPosX, nDestPosY, nThisTab,
4325 nDestPosX + nSizeX - 1, nDestPosY + nSizeY - 1, nThisTab );
4353 if (!bFiltered && pSourceDoc == &rThisDoc)
4367 OUString aChartName;
4374 sal_uInt16
nId = bIsMove ? SID_CHART_SOURCE : SID_CHART_ADDSOURCE;
4376 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
4377 { &aRangeItem, &aNameItem });
4380 else if ( rThisDoc.
GetDPAtCursor( nDestPosX, nDestPosY, nThisTab ) )
4384 ScAddress aDestPos( nDestPosX, nDestPosY, nThisTab );
4385 if ( aDestPos != aSource.
aStart )
4391 nSourceTab != nThisTab )
4393 OUString aUndo =
ScResId( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
4396 SCCOL nCorrectCursorPosCol = 0;
4397 SCROW nCorrectCursorPosRow = 0;
4406 if ( nThisTab == nSourceTab )
4412 bDone = aSource.
Move( 0, nSizeY, 0, aErrorRange, *pSourceDoc );
4413 nCorrectCursorPosRow = nSizeY;
4419 bDone = aSource.
Move( nSizeX, 0, 0, aErrorRange, *pSourceDoc );
4420 nCorrectCursorPosCol = nSizeX;
4462 bDone = aDest.
Move( 0, -nSizeY, 0, aErrorRange, rThisDoc );
4467 bDone = aDest.
Move( -nSizeX, 0, 0, aErrorRange, rThisDoc );
4504 else if ( !bFiltered && pSourceDoc )
4512 std::vector<SCTAB> nTabs;
4522 for(
SCTAB j=
i+1;j<nTabCount;j++)
4526 nTabs.push_back( j );
4534 pView->
ImportTables( pSrcShell,
static_cast<SCTAB>(nTabs.size()), nTabs.data(), bIsLink, nThisTab );
4544 OSL_ENSURE(pSourceSh,
"drag document has no shell");
4547 OUString aUndo =
ScResId( STR_UNDO_COPY );
4569 const OUString aQuote(
'"');
4591 nDestPosY + nSizeY - 1, nThisTab );
4607 OUString aUndo =
ScResId( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
4625 pView->
SetCursor( nDestPosX, nDestPosY );
4663 if (pDocSh && pDocSh->
HasName())
4686 OSL_FAIL(
"drop with link: no sheet nor area");
4735 if ( pHitObj && bIsLink )
4748 if ( nFormatId != SotClipboardFormatId::NONE )
4752 nFormatId, rEvt.
maDropEvent.Transferable, nPosX, nPosY, &aLogicPos, bIsLink );
4786 if ( pOwnSelection )
4792 if ( pCellTransfer )
4800 if ( pDrawTransfer )
4805 aLogicPos, pDrawTransfer->GetModel(),
false,
4814 const uno::Reference<datatransfer::XTransferable>& xTransferable = aDataHelper.
GetTransferable();
4815 if ( xTransferable.is() )
4818 if ( nFormatId != SotClipboardFormatId::NONE )
4839 if (
SC_MOD()->IsFormulaMode() )