sc lok: Edit annotation by id
Change-Id: Iaea08b7a31fab1a8c9b8edc193754821c6608c53 Reviewed-on: https://gerrit.libreoffice.org/35249 Reviewed-by: pranavk <pranavk@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk>
This commit is contained in:
parent
2237f08812
commit
055d8821e6
@ -1082,8 +1082,14 @@ void ScTiledRenderingTest::testCommentCallback()
|
|||||||
CPPUNIT_ASSERT_EQUAL(std::string("0, 255, 1274, 254"), aView2.m_aCommentCallbackResult.get<std::string>("cellPos"));
|
CPPUNIT_ASSERT_EQUAL(std::string("0, 255, 1274, 254"), aView2.m_aCommentCallbackResult.get<std::string>("cellPos"));
|
||||||
|
|
||||||
// Edit a comment
|
// Edit a comment
|
||||||
|
// Select some random cell, we should be able to edit the cell note without
|
||||||
|
// selecting the cell
|
||||||
|
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
|
||||||
|
if (pTabViewShell)
|
||||||
|
pTabViewShell->SetCursor(3, 100);
|
||||||
aArgs = comphelper::InitPropertySequence(
|
aArgs = comphelper::InitPropertySequence(
|
||||||
{
|
{
|
||||||
|
{"Id", uno::makeAny(OUString("Sheet1.A2"))},
|
||||||
{"Text", uno::makeAny(OUString("Edited comment"))},
|
{"Text", uno::makeAny(OUString("Edited comment"))},
|
||||||
{"Author", uno::makeAny(OUString("LOK User2"))},
|
{"Author", uno::makeAny(OUString("LOK User2"))},
|
||||||
});
|
});
|
||||||
@ -1103,7 +1109,6 @@ void ScTiledRenderingTest::testCommentCallback()
|
|||||||
CPPUNIT_ASSERT_EQUAL(std::string("0, 255, 1274, 254"), aView2.m_aCommentCallbackResult.get<std::string>("cellPos"));
|
CPPUNIT_ASSERT_EQUAL(std::string("0, 255, 1274, 254"), aView2.m_aCommentCallbackResult.get<std::string>("cellPos"));
|
||||||
|
|
||||||
// Delete the comment
|
// Delete the comment
|
||||||
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
|
|
||||||
if (pTabViewShell)
|
if (pTabViewShell)
|
||||||
pTabViewShell->SetCursor(4, 43);
|
pTabViewShell->SetCursor(4, 43);
|
||||||
aArgs = comphelper::InitPropertySequence(
|
aArgs = comphelper::InitPropertySequence(
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "scitems.hxx"
|
#include "scitems.hxx"
|
||||||
|
|
||||||
|
#include <comphelper/lok.hxx>
|
||||||
#include <svl/slstitm.hxx>
|
#include <svl/slstitm.hxx>
|
||||||
#include <svl/stritem.hxx>
|
#include <svl/stritem.hxx>
|
||||||
#include <svl/whiter.hxx>
|
#include <svl/whiter.hxx>
|
||||||
@ -312,7 +313,7 @@ void ScCellShell::GetCellState( SfxItemSet& rSet )
|
|||||||
ScDocument& rDoc = GetViewData()->GetDocShell()->GetDocument();
|
ScDocument& rDoc = GetViewData()->GetDocShell()->GetDocument();
|
||||||
ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
|
ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
|
||||||
GetViewData()->GetTabNo() );
|
GetViewData()->GetTabNo() );
|
||||||
|
bool isLOKNoTiledAnnotations = comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations();
|
||||||
SfxWhichIter aIter(rSet);
|
SfxWhichIter aIter(rSet);
|
||||||
sal_uInt16 nWhich = aIter.FirstWhich();
|
sal_uInt16 nWhich = aIter.FirstWhich();
|
||||||
while ( nWhich )
|
while ( nWhich )
|
||||||
@ -371,7 +372,8 @@ void ScCellShell::GetCellState( SfxItemSet& rSet )
|
|||||||
case SID_EDIT_POSTIT:
|
case SID_EDIT_POSTIT:
|
||||||
{
|
{
|
||||||
ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
|
ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
|
||||||
if( rDoc.GetNote(aPos) )
|
// Allow editing annotation by Id (without selecting the cell) for LOK
|
||||||
|
if( isLOKNoTiledAnnotations || rDoc.GetNote(aPos) )
|
||||||
{
|
{
|
||||||
bDisable = false;
|
bDisable = false;
|
||||||
}
|
}
|
||||||
|
@ -2201,10 +2201,29 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
|
|||||||
const SfxPoolItem* pText;
|
const SfxPoolItem* pText;
|
||||||
if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
|
if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXT, &pText) )
|
||||||
{
|
{
|
||||||
|
const SfxPoolItem* pCellId;
|
||||||
|
OUString aCellId;
|
||||||
|
// SID_ATTR_POSTIT_ID only argument for SID_EDIT_POSTIT
|
||||||
|
if (pReqArgs->HasItem( SID_ATTR_POSTIT_ID, &pCellId ))
|
||||||
|
aCellId = static_cast<const SvxPostItIdItem*>(pCellId)->GetValue();
|
||||||
|
|
||||||
const SvxPostItTextItem* pTextItem = static_cast<const SvxPostItTextItem*>( pText );
|
const SvxPostItTextItem* pTextItem = static_cast<const SvxPostItTextItem*>( pText );
|
||||||
const SvxPostItAuthorItem* pAuthorItem = static_cast<const SvxPostItAuthorItem*>( pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHOR) );
|
const SvxPostItAuthorItem* pAuthorItem = static_cast<const SvxPostItAuthorItem*>( pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHOR ) );
|
||||||
const SvxPostItDateItem* pDateItem = static_cast<const SvxPostItDateItem*>( pReqArgs->GetItem( SID_ATTR_POSTIT_DATE ) );
|
const SvxPostItDateItem* pDateItem = static_cast<const SvxPostItDateItem*>( pReqArgs->GetItem( SID_ATTR_POSTIT_DATE ) );
|
||||||
|
|
||||||
|
if (!aCellId.isEmpty())
|
||||||
|
{
|
||||||
|
ScAddress aParsedPos;
|
||||||
|
ScRefFlags nRes = aParsedPos.Parse(aCellId,
|
||||||
|
GetViewData()->GetDocument(),
|
||||||
|
ScAddress::Details(formula::FormulaGrammar::AddressConvention::CONV_ODF));
|
||||||
|
if (nRes & ScRefFlags::VALID)
|
||||||
|
{
|
||||||
|
pTabViewShell->SetTabNo(aParsedPos.Tab());
|
||||||
|
pTabViewShell->SetCursor(aParsedPos.Col(), aParsedPos.Row());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
|
ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
|
||||||
pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(),
|
pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(),
|
||||||
pAuthorItem ? &pAuthorItem->GetValue() : nullptr,
|
pAuthorItem ? &pAuthorItem->GetValue() : nullptr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user