[Libreoffice-commits] core.git: sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Sat Aug 1 11:14:44 UTC 2020
sw/source/core/attr/calbck.cxx | 58 ++---
sw/source/core/attr/cellatr.cxx | 102 +++++-----
sw/source/core/attr/format.cxx | 40 ++--
sw/source/core/bastyp/index.cxx | 22 +-
sw/source/core/crsr/bookmrk.cxx | 94 ++++-----
sw/source/core/crsr/callnk.cxx | 22 +-
sw/source/core/crsr/crsrsh.cxx | 393 +++++++++++++++++++---------------------
sw/source/core/crsr/swcrsr.cxx | 72 +++----
sw/source/core/crsr/trvlcol.cxx | 44 ++--
sw/source/core/crsr/viscrs.cxx | 262 +++++++++++++-------------
10 files changed, 554 insertions(+), 555 deletions(-)
New commits:
commit fb34aeb7842eaa852c82c3d73c722411c11885d7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 30 10:33:15 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Aug 1 13:14:05 2020 +0200
loplugin:flatten in sw/core/access..sc/core/crsr
Change-Id: I073545c11e2261703e5255abefaf82a2bbea5211
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99934
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index cef9b02b059f..4eb04a5ede98 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -219,41 +219,41 @@ void SwModify::Add( SwClient* pDepend )
DBG_TESTSOLARMUTEX();
OSL_ENSURE( !m_bLockClientList, "Client inserted while in Modify" );
- if(pDepend->m_pRegisteredIn != this )
- {
+ if(pDepend->m_pRegisteredIn == this )
+ return;
+
#if OSL_DEBUG_LEVEL > 0
- if(sw::ClientIteratorBase::s_pClientIters)
+ if(sw::ClientIteratorBase::s_pClientIters)
+ {
+ for(auto& rIter : sw::ClientIteratorBase::s_pClientIters->GetRingContainer())
{
- for(auto& rIter : sw::ClientIteratorBase::s_pClientIters->GetRingContainer())
- {
- SAL_WARN_IF(&rIter.m_rRoot == m_pWriterListeners, "sw.core", "a " << typeid(*pDepend).name() << " client added as listener to a " << typeid(*this).name() << " during client iteration.");
- }
+ SAL_WARN_IF(&rIter.m_rRoot == m_pWriterListeners, "sw.core", "a " << typeid(*pDepend).name() << " client added as listener to a " << typeid(*this).name() << " during client iteration.");
}
+ }
#endif
- // deregister new client in case it is already registered elsewhere
- if( pDepend->m_pRegisteredIn != nullptr )
- pDepend->m_pRegisteredIn->Remove( pDepend );
+ // deregister new client in case it is already registered elsewhere
+ if( pDepend->m_pRegisteredIn != nullptr )
+ pDepend->m_pRegisteredIn->Remove( pDepend );
- if( !m_pWriterListeners )
- {
- // first client added
- m_pWriterListeners = pDepend;
- m_pWriterListeners->m_pLeft = nullptr;
- m_pWriterListeners->m_pRight = nullptr;
- }
- else
- {
- // append client
- pDepend->m_pRight = m_pWriterListeners->m_pRight;
- m_pWriterListeners->m_pRight = pDepend;
- pDepend->m_pLeft = m_pWriterListeners;
- if( pDepend->m_pRight )
- pDepend->m_pRight->m_pLeft = pDepend;
- }
-
- // connect client to me
- pDepend->m_pRegisteredIn = this;
+ if( !m_pWriterListeners )
+ {
+ // first client added
+ m_pWriterListeners = pDepend;
+ m_pWriterListeners->m_pLeft = nullptr;
+ m_pWriterListeners->m_pRight = nullptr;
}
+ else
+ {
+ // append client
+ pDepend->m_pRight = m_pWriterListeners->m_pRight;
+ m_pWriterListeners->m_pRight = pDepend;
+ pDepend->m_pLeft = m_pWriterListeners;
+ if( pDepend->m_pRight )
+ pDepend->m_pRight->m_pLeft = pDepend;
+ }
+
+ // connect client to me
+ pDepend->m_pRegisteredIn = this;
}
SwClient* SwModify::Remove( SwClient* pDepend )
diff --git a/sw/source/core/attr/cellatr.cxx b/sw/source/core/attr/cellatr.cxx
index a0a459ed8596..b7e4f507f0c2 100644
--- a/sw/source/core/attr/cellatr.cxx
+++ b/sw/source/core/attr/cellatr.cxx
@@ -124,62 +124,62 @@ void SwTableBoxFormula::ChangeState( const SfxPoolItem* pItem )
if (!pNd || &pNd->GetNodes() != &pNd->GetDoc()->GetNodes())
return;
pTableNd = pNd->FindTableNode();
- if( pTableNd != nullptr )
+ if( pTableNd == nullptr )
+ return;
+
+ switch( pUpdateField->m_eFlags )
{
- switch( pUpdateField->m_eFlags )
+ case TBL_CALC:
+ // reset value flag
+ ChgValid( false );
+ break;
+ case TBL_BOXNAME:
+ if( &pTableNd->GetTable() == pUpdateField->m_pTable )
+ // use external rendering
+ PtrToBoxNm( pUpdateField->m_pTable );
+ break;
+ case TBL_BOXPTR:
+ // internal rendering
+ BoxNmToPtr( &pTableNd->GetTable() );
+ break;
+ case TBL_RELBOXNAME:
+ if( &pTableNd->GetTable() == pUpdateField->m_pTable )
+ // relative rendering
+ ToRelBoxNm( pUpdateField->m_pTable );
+ break;
+
+ case TBL_SPLITTBL:
+ if( &pTableNd->GetTable() == pUpdateField->m_pTable )
{
- case TBL_CALC:
- // reset value flag
- ChgValid( false );
- break;
- case TBL_BOXNAME:
- if( &pTableNd->GetTable() == pUpdateField->m_pTable )
- // use external rendering
- PtrToBoxNm( pUpdateField->m_pTable );
- break;
- case TBL_BOXPTR:
- // internal rendering
- BoxNmToPtr( &pTableNd->GetTable() );
- break;
- case TBL_RELBOXNAME:
- if( &pTableNd->GetTable() == pUpdateField->m_pTable )
- // relative rendering
- ToRelBoxNm( pUpdateField->m_pTable );
- break;
-
- case TBL_SPLITTBL:
- if( &pTableNd->GetTable() == pUpdateField->m_pTable )
- {
- sal_uInt16 nLnPos = SwTableFormula::GetLnPosInTable(
- pTableNd->GetTable(), GetTableBox() );
- pUpdateField->m_bBehindSplitLine = USHRT_MAX != nLnPos &&
- pUpdateField->m_nSplitLine <= nLnPos;
- }
- else
- pUpdateField->m_bBehindSplitLine = false;
- [[fallthrough]];
- case TBL_MERGETBL:
- if( pUpdateField->m_pHistory )
+ sal_uInt16 nLnPos = SwTableFormula::GetLnPosInTable(
+ pTableNd->GetTable(), GetTableBox() );
+ pUpdateField->m_bBehindSplitLine = USHRT_MAX != nLnPos &&
+ pUpdateField->m_nSplitLine <= nLnPos;
+ }
+ else
+ pUpdateField->m_bBehindSplitLine = false;
+ [[fallthrough]];
+ case TBL_MERGETBL:
+ if( pUpdateField->m_pHistory )
+ {
+ // for a history record the unchanged formula is needed
+ SwTableBoxFormula aCopy( *this );
+ pUpdateField->m_bModified = false;
+ ToSplitMergeBoxNm( *pUpdateField );
+
+ if( pUpdateField->m_bModified )
{
- // for a history record the unchanged formula is needed
- SwTableBoxFormula aCopy( *this );
- pUpdateField->m_bModified = false;
- ToSplitMergeBoxNm( *pUpdateField );
-
- if( pUpdateField->m_bModified )
- {
- // external rendering
- aCopy.PtrToBoxNm( &pTableNd->GetTable() );
- pUpdateField->m_pHistory->Add(
- &aCopy,
- &aCopy,
- pNd->FindTableBoxStartNode()->GetIndex());
- }
+ // external rendering
+ aCopy.PtrToBoxNm( &pTableNd->GetTable() );
+ pUpdateField->m_pHistory->Add(
+ &aCopy,
+ &aCopy,
+ pNd->FindTableBoxStartNode()->GetIndex());
}
- else
- ToSplitMergeBoxNm( *pUpdateField );
- break;
}
+ else
+ ToSplitMergeBoxNm( *pUpdateField );
+ break;
}
}
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index a69dbf12592f..e7bfedb0a0f5 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -215,28 +215,28 @@ SwFormat::~SwFormat()
{
// This happens at an ObjectDying message. Thus put all dependent
// ones on DerivedFrom.
- if( HasWriterListeners() )
- {
- m_bFormatInDTOR = true;
+ if( !HasWriterListeners() )
+ return;
- SwFormat* pParentFormat = DerivedFrom();
- if( !pParentFormat )
- {
- SAL_WARN(
- "sw.core",
- "~SwFormat: parent format missing from: " << GetName() );
- }
- else
+ m_bFormatInDTOR = true;
+
+ SwFormat* pParentFormat = DerivedFrom();
+ if( !pParentFormat )
+ {
+ SAL_WARN(
+ "sw.core",
+ "~SwFormat: parent format missing from: " << GetName() );
+ }
+ else
+ {
+ SwFormatChg aOldFormat( this );
+ SwFormatChg aNewFormat( pParentFormat );
+ SwIterator<SwClient,SwFormat> aIter(*this);
+ for(SwClient* pClient = aIter.First(); pClient && pParentFormat; pClient = aIter.Next())
{
- SwFormatChg aOldFormat( this );
- SwFormatChg aNewFormat( pParentFormat );
- SwIterator<SwClient,SwFormat> aIter(*this);
- for(SwClient* pClient = aIter.First(); pClient && pParentFormat; pClient = aIter.Next())
- {
- SAL_INFO("sw.core", "reparenting " << typeid(*pClient).name() << " at " << pClient << " from " << typeid(*this).name() << " at " << this << " to " << typeid(*pParentFormat).name() << " at " << pParentFormat);
- pParentFormat->Add( pClient );
- pClient->ModifyNotification( &aOldFormat, &aNewFormat );
- }
+ SAL_INFO("sw.core", "reparenting " << typeid(*pClient).name() << " at " << pClient << " from " << typeid(*this).name() << " at " << this << " to " << typeid(*pParentFormat).name() << " at " << pParentFormat);
+ pParentFormat->Add( pClient );
+ pClient->ModifyNotification( &aOldFormat, &aNewFormat );
}
}
}
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index 073b6656311d..7fe9b5571a43 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -286,19 +286,19 @@ void SwIndexReg::Update(
void SwIndexReg::MoveTo( SwIndexReg& rArr )
{
- if (this != &rArr && m_pFirst)
+ if (!(this != &rArr && m_pFirst))
+ return;
+
+ SwIndex * pIdx = const_cast<SwIndex*>(m_pFirst);
+ SwIndex * pNext;
+ while( pIdx )
{
- SwIndex * pIdx = const_cast<SwIndex*>(m_pFirst);
- SwIndex * pNext;
- while( pIdx )
- {
- pNext = pIdx->m_pNext;
- pIdx->Assign( &rArr, pIdx->GetIndex() );
- pIdx = pNext;
- }
- m_pFirst = nullptr;
- m_pLast = nullptr;
+ pNext = pIdx->m_pNext;
+ pIdx->Assign( &rArr, pIdx->GetIndex() );
+ pIdx = pNext;
}
+ m_pFirst = nullptr;
+ m_pLast = nullptr;
}
#ifdef DBG_UTIL
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 3e0755108cd6..b331270b592a 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -717,60 +717,60 @@ namespace sw::mark
return;
}
- if (comphelper::LibreOfficeKit::isActive())
- {
- if (!m_pButton)
- return;
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
- SwEditWin* pEditWin = dynamic_cast<SwEditWin*>(m_pButton->GetParent());
- if (!pEditWin)
- return;
+ if (!m_pButton)
+ return;
- OStringBuffer sPayload;
- if (sAction == "show")
- {
- if(m_aPortionPaintArea.IsEmpty())
- return;
-
- sPayload = OStringLiteral("{\"action\": \"show\","
- " \"type\": \"drop-down\", \"textArea\": \"") +
- m_aPortionPaintArea.SVRect().toString() + "\",";
- // Add field params to the message
- sPayload.append(" \"params\": { \"items\": [");
-
- // List items
- auto pParameters = this->GetParameters();
- auto pListEntriesIter = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
- css::uno::Sequence<OUString> vListEntries;
- if (pListEntriesIter != pParameters->end())
- {
- pListEntriesIter->second >>= vListEntries;
- for (const OUString& sItem : std::as_const(vListEntries))
- sPayload.append("\"" + OUStringToOString(sItem, RTL_TEXTENCODING_UTF8) + "\", ");
- sPayload.setLength(sPayload.getLength() - 2);
- }
- sPayload.append("], ");
+ SwEditWin* pEditWin = dynamic_cast<SwEditWin*>(m_pButton->GetParent());
+ if (!pEditWin)
+ return;
- // Selected item
- auto pSelectedItemIter = pParameters->find(ODF_FORMDROPDOWN_RESULT);
- sal_Int32 nSelection = -1;
- if (pSelectedItemIter != pParameters->end())
- {
- pSelectedItemIter->second >>= nSelection;
- }
- sPayload.append("\"selected\": \"" + OString::number(nSelection) + "\", ");
+ OStringBuffer sPayload;
+ if (sAction == "show")
+ {
+ if(m_aPortionPaintArea.IsEmpty())
+ return;
- // Placeholder text
- sPayload.append("\"placeholderText\": \"" + OUStringToOString(SwResId(STR_DROP_DOWN_EMPTY_LIST), RTL_TEXTENCODING_UTF8) + "\"}}");
- }
- else
+ sPayload = OStringLiteral("{\"action\": \"show\","
+ " \"type\": \"drop-down\", \"textArea\": \"") +
+ m_aPortionPaintArea.SVRect().toString() + "\",";
+ // Add field params to the message
+ sPayload.append(" \"params\": { \"items\": [");
+
+ // List items
+ auto pParameters = this->GetParameters();
+ auto pListEntriesIter = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
+ css::uno::Sequence<OUString> vListEntries;
+ if (pListEntriesIter != pParameters->end())
{
- sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
+ pListEntriesIter->second >>= vListEntries;
+ for (const OUString& sItem : std::as_const(vListEntries))
+ sPayload.append("\"" + OUStringToOString(sItem, RTL_TEXTENCODING_UTF8) + "\", ");
+ sPayload.setLength(sPayload.getLength() - 2);
}
- if (sPayload.toString() != m_sLastSentLOKMsg) {
- m_sLastSentLOKMsg = sPayload.toString();
- pEditWin->GetView().GetWrtShell().GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, m_sLastSentLOKMsg.getStr());
+ sPayload.append("], ");
+
+ // Selected item
+ auto pSelectedItemIter = pParameters->find(ODF_FORMDROPDOWN_RESULT);
+ sal_Int32 nSelection = -1;
+ if (pSelectedItemIter != pParameters->end())
+ {
+ pSelectedItemIter->second >>= nSelection;
}
+ sPayload.append("\"selected\": \"" + OString::number(nSelection) + "\", ");
+
+ // Placeholder text
+ sPayload.append("\"placeholderText\": \"" + OUStringToOString(SwResId(STR_DROP_DOWN_EMPTY_LIST), RTL_TEXTENCODING_UTF8) + "\"}}");
+ }
+ else
+ {
+ sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
+ }
+ if (sPayload.toString() != m_sLastSentLOKMsg) {
+ m_sLastSentLOKMsg = sPayload.toString();
+ pEditWin->GetView().GetWrtShell().GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, m_sLastSentLOKMsg.getStr());
}
}
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 90905da63b7a..292099c5e316 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -203,20 +203,20 @@ SwCallLink::~SwCallLink() COVERITY_NOEXCEPT_FALSE
if (!pFrame)
return;
pFlyFrame = pFrame->FindFlyFrame();
- if ( pFlyFrame && !m_rShell.IsTableMode() )
- {
- const SwNodeIndex* pIndex = pFlyFrame->GetFormat()->GetContent().GetContentIdx();
- OSL_ENSURE( pIndex, "Fly without Content" );
+ if ( !(pFlyFrame && !m_rShell.IsTableMode()) )
+ return;
- if (!pIndex)
- return;
+ const SwNodeIndex* pIndex = pFlyFrame->GetFormat()->GetContent().GetContentIdx();
+ OSL_ENSURE( pIndex, "Fly without Content" );
- const SwNode& rStNd = pIndex->GetNode();
+ if (!pIndex)
+ return;
- if( rStNd.EndOfSectionNode()->StartOfSectionIndex() > m_nNode ||
- m_nNode > rStNd.EndOfSectionIndex() )
- m_rShell.GetFlyMacroLnk().Call( pFlyFrame->GetFormat() );
- }
+ const SwNode& rStNd = pIndex->GetNode();
+
+ if( rStNd.EndOfSectionNode()->StartOfSectionIndex() > m_nNode ||
+ m_nNode > rStNd.EndOfSectionIndex() )
+ m_rShell.GetFlyMacroLnk().Call( pFlyFrame->GetFormat() );
}
long SwCallLink::getLayoutFrame(const SwRootFrame* pRoot,
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index ef3200a51a26..a2a169339bae 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -387,20 +387,19 @@ bool SwCursorShell::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
void SwCursorShell::MarkListLevel( const OUString& sListId,
const int nListLevel )
{
- if ( sListId != m_sMarkedListId ||
- nListLevel != m_nMarkedListLevel)
- {
- if ( !m_sMarkedListId.isEmpty() )
- mxDoc->MarkListLevel( m_sMarkedListId, m_nMarkedListLevel, false );
+ if (sListId == m_sMarkedListId && nListLevel == m_nMarkedListLevel)
+ return;
- if ( !sListId.isEmpty() )
- {
- mxDoc->MarkListLevel( sListId, nListLevel, true );
- }
+ if ( !m_sMarkedListId.isEmpty() )
+ mxDoc->MarkListLevel( m_sMarkedListId, m_nMarkedListLevel, false );
- m_sMarkedListId = sListId;
- m_nMarkedListLevel = nListLevel;
+ if ( !sListId.isEmpty() )
+ {
+ mxDoc->MarkListLevel( sListId, nListLevel, true );
}
+
+ m_sMarkedListId = sListId;
+ m_nMarkedListLevel = nListLevel;
}
void SwCursorShell::UpdateMarkedListLevel()
@@ -408,28 +407,28 @@ void SwCursorShell::UpdateMarkedListLevel()
SwTextNode const*const pTextNd = sw::GetParaPropsNode(*GetLayout(),
GetCursor_()->GetPoint()->nNode);
- if ( pTextNd )
+ if ( !pTextNd )
+ return;
+
+ if (!pTextNd->IsNumbered(GetLayout()))
{
- if (!pTextNd->IsNumbered(GetLayout()))
- {
- m_pCurrentCursor->SetInFrontOfLabel_( false );
- MarkListLevel( OUString(), 0 );
- }
- else if ( m_pCurrentCursor->IsInFrontOfLabel() )
- {
- if ( pTextNd->IsInList() )
- {
- assert(pTextNd->GetActualListLevel() >= 0 &&
- pTextNd->GetActualListLevel() < MAXLEVEL);
- MarkListLevel( pTextNd->GetListId(),
- pTextNd->GetActualListLevel() );
- }
- }
- else
+ m_pCurrentCursor->SetInFrontOfLabel_( false );
+ MarkListLevel( OUString(), 0 );
+ }
+ else if ( m_pCurrentCursor->IsInFrontOfLabel() )
+ {
+ if ( pTextNd->IsInList() )
{
- MarkListLevel( OUString(), 0 );
+ assert(pTextNd->GetActualListLevel() >= 0 &&
+ pTextNd->GetActualListLevel() < MAXLEVEL);
+ MarkListLevel( pTextNd->GetListId(),
+ pTextNd->GetActualListLevel() );
}
}
+ else
+ {
+ MarkListLevel( OUString(), 0 );
+ }
}
void SwCursorShell::FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage)
@@ -2150,76 +2149,58 @@ void SwCursorShell::RefreshBlockCursor()
aRect.Justify();
SwSelectionList aSelList( pFrame );
- if( GetLayout()->FillSelection( aSelList, aRect ) )
+ if( !GetLayout()->FillSelection( aSelList, aRect ) )
+ return;
+
+ SwCursor* pNxt = static_cast<SwCursor*>(m_pCurrentCursor->GetNext());
+ while( pNxt != m_pCurrentCursor )
{
- SwCursor* pNxt = static_cast<SwCursor*>(m_pCurrentCursor->GetNext());
- while( pNxt != m_pCurrentCursor )
- {
- delete pNxt;
- pNxt = static_cast<SwCursor*>(m_pCurrentCursor->GetNext());
- }
+ delete pNxt;
+ pNxt = static_cast<SwCursor*>(m_pCurrentCursor->GetNext());
+ }
- std::list<SwPaM*>::iterator pStart = aSelList.getStart();
- std::list<SwPaM*>::iterator pPam = aSelList.getEnd();
- OSL_ENSURE( pPam != pStart, "FillSelection should deliver at least one PaM" );
- m_pCurrentCursor->SetMark();
+ std::list<SwPaM*>::iterator pStart = aSelList.getStart();
+ std::list<SwPaM*>::iterator pPam = aSelList.getEnd();
+ OSL_ENSURE( pPam != pStart, "FillSelection should deliver at least one PaM" );
+ m_pCurrentCursor->SetMark();
+ --pPam;
+ // If there is only one text portion inside the rectangle, a simple
+ // selection is created
+ if( pPam == pStart )
+ {
+ *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint();
+ if( (*pPam)->HasMark() )
+ *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
+ else
+ m_pCurrentCursor->DeleteMark();
+ delete *pPam;
+ m_pCurrentCursor->SetColumnSelection( false );
+ }
+ else
+ {
+ // The order of the SwSelectionList has to be preserved but
+ // the order inside the ring created by CreateCursor() is not like
+ // expected => First create the selections before the last one
+ // downto the first selection.
+ // At least create the cursor for the last selection
--pPam;
- // If there is only one text portion inside the rectangle, a simple
- // selection is created
- if( pPam == pStart )
- {
- *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint();
- if( (*pPam)->HasMark() )
- *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
- else
- m_pCurrentCursor->DeleteMark();
- delete *pPam;
- m_pCurrentCursor->SetColumnSelection( false );
- }
+ *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n-1 (if n == number of selections)
+ if( (*pPam)->HasMark() )
+ *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
else
+ m_pCurrentCursor->DeleteMark();
+ delete *pPam;
+ m_pCurrentCursor->SetColumnSelection( true );
+ while( pPam != pStart )
{
- // The order of the SwSelectionList has to be preserved but
- // the order inside the ring created by CreateCursor() is not like
- // expected => First create the selections before the last one
- // downto the first selection.
- // At least create the cursor for the last selection
--pPam;
- *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n-1 (if n == number of selections)
- if( (*pPam)->HasMark() )
- *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
- else
- m_pCurrentCursor->DeleteMark();
- delete *pPam;
- m_pCurrentCursor->SetColumnSelection( true );
- while( pPam != pStart )
- {
- --pPam;
- SwShellCursor* pNew = new SwShellCursor( *m_pCurrentCursor );
- pNew->insert( pNew->begin(), m_pCurrentCursor->begin(), m_pCurrentCursor->end());
- m_pCurrentCursor->clear();
- m_pCurrentCursor->DeleteMark();
+ SwShellCursor* pNew = new SwShellCursor( *m_pCurrentCursor );
+ pNew->insert( pNew->begin(), m_pCurrentCursor->begin(), m_pCurrentCursor->end());
+ m_pCurrentCursor->clear();
+ m_pCurrentCursor->DeleteMark();
- *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n-2, n-3, .., 2, 1
- if( (*pPam)->HasMark() )
- {
- m_pCurrentCursor->SetMark();
- *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
- }
- else
- m_pCurrentCursor->DeleteMark();
- m_pCurrentCursor->SetColumnSelection( true );
- delete *pPam;
- }
- {
- SwShellCursor* pNew = new SwShellCursor( *m_pCurrentCursor );
- pNew->insert( pNew->begin(), m_pCurrentCursor->begin(), m_pCurrentCursor->end() );
- m_pCurrentCursor->clear();
- m_pCurrentCursor->DeleteMark();
- }
- pPam = aSelList.getEnd();
- --pPam;
- *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n, the last selection
+ *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n-2, n-3, .., 2, 1
if( (*pPam)->HasMark() )
{
m_pCurrentCursor->SetMark();
@@ -2230,6 +2211,24 @@ void SwCursorShell::RefreshBlockCursor()
m_pCurrentCursor->SetColumnSelection( true );
delete *pPam;
}
+ {
+ SwShellCursor* pNew = new SwShellCursor( *m_pCurrentCursor );
+ pNew->insert( pNew->begin(), m_pCurrentCursor->begin(), m_pCurrentCursor->end() );
+ m_pCurrentCursor->clear();
+ m_pCurrentCursor->DeleteMark();
+ }
+ pPam = aSelList.getEnd();
+ --pPam;
+ *m_pCurrentCursor->GetPoint() = *(*pPam)->GetPoint(); // n, the last selection
+ if( (*pPam)->HasMark() )
+ {
+ m_pCurrentCursor->SetMark();
+ *m_pCurrentCursor->GetMark() = *(*pPam)->GetMark();
+ }
+ else
+ m_pCurrentCursor->DeleteMark();
+ m_pCurrentCursor->SetColumnSelection( true );
+ delete *pPam;
}
}
@@ -2386,38 +2385,38 @@ void SwCursorShell::ShowCursors( bool bCursorVis )
void SwCursorShell::ShowCursor()
{
- if( !m_bBasicHideCursor )
- {
- m_bSVCursorVis = true;
- m_pCurrentCursor->SetShowTextInputFieldOverlay( true );
+ if( m_bBasicHideCursor )
+ return;
- if (comphelper::LibreOfficeKit::isActive())
- {
- OString aPayload = OString::boolean(m_bSVCursorVis);
- GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
- SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
- }
+ m_bSVCursorVis = true;
+ m_pCurrentCursor->SetShowTextInputFieldOverlay( true );
- UpdateCursor();
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ OString aPayload = OString::boolean(m_bSVCursorVis);
+ GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
+ SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
}
+
+ UpdateCursor();
}
void SwCursorShell::HideCursor()
{
- if( !m_bBasicHideCursor )
- {
- m_bSVCursorVis = false;
- // possibly reverse selected areas!!
- CurrShell aCurr( this );
- m_pCurrentCursor->SetShowTextInputFieldOverlay( false );
- m_pVisibleCursor->Hide();
+ if( m_bBasicHideCursor )
+ return;
- if (comphelper::LibreOfficeKit::isActive())
- {
- OString aPayload = OString::boolean(m_bSVCursorVis);
- GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
- SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
- }
+ m_bSVCursorVis = false;
+ // possibly reverse selected areas!!
+ CurrShell aCurr( this );
+ m_pCurrentCursor->SetShowTextInputFieldOverlay( false );
+ m_pVisibleCursor->Hide();
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ OString aPayload = OString::boolean(m_bSVCursorVis);
+ GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload.getStr());
+ SfxLokHelper::notifyOtherViews(GetSfxViewShell(), LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
}
}
@@ -3703,30 +3702,30 @@ void SwCursorShell::GetSmartTagTerm( std::vector< OUString >& rSmartTagTypes,
SwPaM* pCursor = GetCursor();
SwPosition aPos( *pCursor->GetPoint() );
SwTextNode *pNode = aPos.nNode.GetNode().GetTextNode();
- if ( pNode && !pNode->IsInProtectSect() )
- {
- const SwWrongList *pSmartTagList = pNode->GetSmartTags();
- if ( pSmartTagList )
- {
- sal_Int32 nCurrent = aPos.nContent.GetIndex();
- sal_Int32 nBegin = nCurrent;
- sal_Int32 nLen = 1;
+ if ( !(pNode && !pNode->IsInProtectSect()) )
+ return;
- if (pSmartTagList->InWrongWord(nBegin, nLen) && !pNode->IsSymbolAt(nBegin))
- {
- const sal_uInt16 nIndex = pSmartTagList->GetWrongPos( nBegin );
- const SwWrongList* pSubList = pSmartTagList->SubList( nIndex );
- if ( pSubList )
- {
- pSmartTagList = pSubList;
- nCurrent = 0;
- }
+ const SwWrongList *pSmartTagList = pNode->GetSmartTags();
+ if ( !pSmartTagList )
+ return;
- lcl_FillRecognizerData( rSmartTagTypes, rStringKeyMaps, *pSmartTagList, nCurrent );
- lcl_FillTextRange( rRange, *pNode, nBegin, nLen );
- }
- }
+ sal_Int32 nCurrent = aPos.nContent.GetIndex();
+ sal_Int32 nBegin = nCurrent;
+ sal_Int32 nLen = 1;
+
+ if (!(pSmartTagList->InWrongWord(nBegin, nLen) && !pNode->IsSymbolAt(nBegin)))
+ return;
+
+ const sal_uInt16 nIndex = pSmartTagList->GetWrongPos( nBegin );
+ const SwWrongList* pSubList = pSmartTagList->SubList( nIndex );
+ if ( pSubList )
+ {
+ pSmartTagList = pSubList;
+ nCurrent = 0;
}
+
+ lcl_FillRecognizerData( rSmartTagTypes, rStringKeyMaps, *pSmartTagList, nCurrent );
+ lcl_FillTextRange( rRange, *pNode, nBegin, nLen );
}
// see also SwEditShell::GetCorrection( const Point* pPt, SwRect& rSelectRect )
@@ -3749,67 +3748,67 @@ void SwCursorShell::GetSmartTagRect( const Point& rPt, SwRect& rSelectRect )
pSmartTagList = pNode->GetSmartTags();
if( !pSmartTagList )
return;
- if( !pNode->IsInProtectSect() )
- {
- sal_Int32 nBegin = aPos.nContent.GetIndex();
- sal_Int32 nLen = 1;
-
- if (pSmartTagList->InWrongWord(nBegin, nLen) && !pNode->IsSymbolAt(nBegin))
- {
- // get smarttag word
- OUString aText( pNode->GetText().copy(nBegin, nLen) );
-
- //save the start and end positions of the line and the starting point
- Push();
- LeftMargin();
- const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex();
- RightMargin();
- const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex();
- Pop(PopMode::DeleteCurrent);
-
- // make sure the selection build later from the data below does not
- // include "in word" character to the left and right in order to
- // preserve those. Therefore count those "in words" in order to
- // modify the selection accordingly.
- const sal_Unicode* pChar = aText.getStr();
- sal_Int32 nLeft = 0;
- while (*pChar++ == CH_TXTATR_INWORD)
- ++nLeft;
- pChar = aText.getLength() ? aText.getStr() + aText.getLength() - 1 : nullptr;
- sal_Int32 nRight = 0;
- while (pChar && *pChar-- == CH_TXTATR_INWORD)
- ++nRight;
-
- aPos.nContent = nBegin + nLeft;
- pCursor = GetCursor();
- *pCursor->GetPoint() = aPos;
- pCursor->SetMark();
- ExtendSelection( true, nLen - nLeft - nRight );
- // do not determine the rectangle in the current line
- const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
- // take one less than the line end - otherwise the next line would
- // be calculated
- const sal_Int32 nWordEnd = std::min(nBegin + nLen - nLeft - nRight, nLineEnd);
- Push();
- pCursor->DeleteMark();
- SwIndex& rContent = GetCursor()->GetPoint()->nContent;
- rContent = nWordStart;
- SwRect aStartRect;
- SwCursorMoveState aState;
- aState.m_bRealWidth = true;
- SwContentNode* pContentNode = pCursor->GetContentNode();
- std::pair<Point, bool> const tmp(rPt, false);
- SwContentFrame *pContentFrame = pContentNode->getLayoutFrame(
- GetLayout(), pCursor->GetPoint(), &tmp);
-
- pContentFrame->GetCharRect( aStartRect, *pCursor->GetPoint(), &aState );
- rContent = nWordEnd - 1;
- SwRect aEndRect;
- pContentFrame->GetCharRect( aEndRect, *pCursor->GetPoint(),&aState );
- rSelectRect = aStartRect.Union( aEndRect );
- Pop(PopMode::DeleteCurrent);
- }
- }
+ if( pNode->IsInProtectSect() )
+ return;
+
+ sal_Int32 nBegin = aPos.nContent.GetIndex();
+ sal_Int32 nLen = 1;
+
+ if (!(pSmartTagList->InWrongWord(nBegin, nLen) && !pNode->IsSymbolAt(nBegin)))
+ return;
+
+ // get smarttag word
+ OUString aText( pNode->GetText().copy(nBegin, nLen) );
+
+ //save the start and end positions of the line and the starting point
+ Push();
+ LeftMargin();
+ const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex();
+ RightMargin();
+ const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex();
+ Pop(PopMode::DeleteCurrent);
+
+ // make sure the selection build later from the data below does not
+ // include "in word" character to the left and right in order to
+ // preserve those. Therefore count those "in words" in order to
+ // modify the selection accordingly.
+ const sal_Unicode* pChar = aText.getStr();
+ sal_Int32 nLeft = 0;
+ while (*pChar++ == CH_TXTATR_INWORD)
+ ++nLeft;
+ pChar = aText.getLength() ? aText.getStr() + aText.getLength() - 1 : nullptr;
+ sal_Int32 nRight = 0;
+ while (pChar && *pChar-- == CH_TXTATR_INWORD)
+ ++nRight;
+
+ aPos.nContent = nBegin + nLeft;
+ pCursor = GetCursor();
+ *pCursor->GetPoint() = aPos;
+ pCursor->SetMark();
+ ExtendSelection( true, nLen - nLeft - nRight );
+ // do not determine the rectangle in the current line
+ const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
+ // take one less than the line end - otherwise the next line would
+ // be calculated
+ const sal_Int32 nWordEnd = std::min(nBegin + nLen - nLeft - nRight, nLineEnd);
+ Push();
+ pCursor->DeleteMark();
+ SwIndex& rContent = GetCursor()->GetPoint()->nContent;
+ rContent = nWordStart;
+ SwRect aStartRect;
+ SwCursorMoveState aState;
+ aState.m_bRealWidth = true;
+ SwContentNode* pContentNode = pCursor->GetContentNode();
+ std::pair<Point, bool> const tmp(rPt, false);
+ SwContentFrame *pContentFrame = pContentNode->getLayoutFrame(
+ GetLayout(), pCursor->GetPoint(), &tmp);
+
+ pContentFrame->GetCharRect( aStartRect, *pCursor->GetPoint(), &aState );
+ rContent = nWordEnd - 1;
+ SwRect aEndRect;
+ pContentFrame->GetCharRect( aEndRect, *pCursor->GetPoint(),&aState );
+ rSelectRect = aStartRect.Union( aEndRect );
+ Pop(PopMode::DeleteCurrent);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index 1e126da0b2b4..a4b1d6a54c50 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -1916,32 +1916,32 @@ bool SwCursor::LeftRight( bool bLeft, sal_uInt16 nCnt, sal_uInt16 nMode,
void SwCursor::DoSetBidiLevelUpDown()
{
SwNode& rNode = GetPoint()->nNode.GetNode();
- if ( rNode.IsTextNode() )
- {
- SwTextFrame const* pFrame;
- const SwScriptInfo* pSI =
- SwScriptInfo::GetScriptInfo( *rNode.GetTextNode(), &pFrame );
- if ( pSI )
- {
- SwIndex& rIdx = GetPoint()->nContent;
- const sal_Int32 nPos = rIdx.GetIndex();
+ if ( !rNode.IsTextNode() )
+ return;
- if (nPos && nPos < rNode.GetTextNode()->GetText().getLength())
- {
- TextFrameIndex const nIndex(pFrame->MapModelToView(rNode.GetTextNode(), nPos));
- const sal_uInt8 nCurrLevel = pSI->DirType( nIndex );
- const sal_uInt8 nPrevLevel = pSI->DirType( nIndex - TextFrameIndex(1) );
+ SwTextFrame const* pFrame;
+ const SwScriptInfo* pSI =
+ SwScriptInfo::GetScriptInfo( *rNode.GetTextNode(), &pFrame );
+ if ( !pSI )
+ return;
- if ( nCurrLevel % 2 != nPrevLevel % 2 )
- {
- // set cursor level to the lower of the two levels
- SetCursorBidiLevel( std::min( nCurrLevel, nPrevLevel ) );
- }
- else
- SetCursorBidiLevel( nCurrLevel );
- }
- }
+ SwIndex& rIdx = GetPoint()->nContent;
+ const sal_Int32 nPos = rIdx.GetIndex();
+
+ if (!(nPos && nPos < rNode.GetTextNode()->GetText().getLength()))
+ return;
+
+ TextFrameIndex const nIndex(pFrame->MapModelToView(rNode.GetTextNode(), nPos));
+ const sal_uInt8 nCurrLevel = pSI->DirType( nIndex );
+ const sal_uInt8 nPrevLevel = pSI->DirType( nIndex - TextFrameIndex(1) );
+
+ if ( nCurrLevel % 2 != nPrevLevel % 2 )
+ {
+ // set cursor level to the lower of the two levels
+ SetCursorBidiLevel( std::min( nCurrLevel, nPrevLevel ) );
}
+ else
+ SetCursorBidiLevel( nCurrLevel );
}
bool SwCursor::UpDown( bool bUp, sal_uInt16 nCnt,
@@ -2293,23 +2293,23 @@ void SwCursor::RestoreSavePos()
OSL_ENSURE(m_vSavePos.empty() || m_vSavePos.back().nNode < uNodeCount,
"SwCursor::RestoreSavePos: invalid node: "
"probably something was deleted; consider using SwUnoCursor instead");
- if (!m_vSavePos.empty() && m_vSavePos.back().nNode < uNodeCount)
- {
- GetPoint()->nNode = m_vSavePos.back().nNode;
+ if (m_vSavePos.empty() || m_vSavePos.back().nNode >= uNodeCount)
+ return;
+
+ GetPoint()->nNode = m_vSavePos.back().nNode;
- sal_Int32 nIdx = 0;
- if ( GetContentNode() )
+ sal_Int32 nIdx = 0;
+ if ( GetContentNode() )
+ {
+ if (m_vSavePos.back().nContent <= GetContentNode()->Len())
+ nIdx = m_vSavePos.back().nContent;
+ else
{
- if (m_vSavePos.back().nContent <= GetContentNode()->Len())
- nIdx = m_vSavePos.back().nContent;
- else
- {
- nIdx = GetContentNode()->Len();
- OSL_FAIL("SwCursor::RestoreSavePos: invalid content index");
- }
+ nIdx = GetContentNode()->Len();
+ OSL_FAIL("SwCursor::RestoreSavePos: invalid content index");
}
- GetPoint()->nContent.Assign( GetContentNode(), nIdx );
}
+ GetPoint()->nContent.Assign( GetContentNode(), nIdx );
}
SwTableCursor::SwTableCursor( const SwPosition &rPos )
diff --git a/sw/source/core/crsr/trvlcol.cxx b/sw/source/core/crsr/trvlcol.cxx
index f919851bb431..c680e5a87c3f 100644
--- a/sw/source/core/crsr/trvlcol.cxx
+++ b/sw/source/core/crsr/trvlcol.cxx
@@ -71,32 +71,32 @@ void SwCursorShell::MoveColumn( SwWhichColumn fnWhichCol, SwPosColumn fnPosCol )
if( !pLayFrame )
return;
pLayFrame = (*fnWhichCol)( pLayFrame );
- if( pLayFrame )
- {
- SwContentFrame* pCnt = (*fnPosCol)( pLayFrame );
- if( pCnt )
- {
- CurrShell aCurr( this );
- SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
- SwCursorSaveState aSaveState( *m_pCurrentCursor );
+ if( !pLayFrame )
+ return;
+
+ SwContentFrame* pCnt = (*fnPosCol)( pLayFrame );
+ if( !pCnt )
+ return;
- pCnt->Calc(GetOut());
+ CurrShell aCurr( this );
+ SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
+ SwCursorSaveState aSaveState( *m_pCurrentCursor );
- Point aPt( pCnt->getFrameArea().Pos() + pCnt->getFramePrintArea().Pos() );
- if( fnPosCol == GetColumnEnd )
- {
- aPt.setX(aPt.getX() + pCnt->getFramePrintArea().Width());
- aPt.setY(aPt.getY() + pCnt->getFramePrintArea().Height());
- }
+ pCnt->Calc(GetOut());
- pCnt->GetModelPositionForViewPoint( m_pCurrentCursor->GetPoint(), aPt );
+ Point aPt( pCnt->getFrameArea().Pos() + pCnt->getFramePrintArea().Pos() );
+ if( fnPosCol == GetColumnEnd )
+ {
+ aPt.setX(aPt.getX() + pCnt->getFramePrintArea().Width());
+ aPt.setY(aPt.getY() + pCnt->getFramePrintArea().Height());
+ }
- if( !m_pCurrentCursor->IsInProtectTable( true ) &&
- !m_pCurrentCursor->IsSelOvr() )
- {
- UpdateCursor();
- }
- }
+ pCnt->GetModelPositionForViewPoint( m_pCurrentCursor->GetPoint(), aPt );
+
+ if( !m_pCurrentCursor->IsInProtectTable( true ) &&
+ !m_pCurrentCursor->IsSelOvr() )
+ {
+ UpdateCursor();
}
}
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 6f3a1e3b633d..cf544c08a536 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -300,21 +300,21 @@ void SwVisibleCursor::SetPosAndShow(SfxViewShell const * pViewShell)
}
}
- if ( !m_pCursorShell->IsCursorReadonly() || m_pCursorShell->GetViewOptions()->IsSelectionInReadonly() )
- {
- if ( m_pCursorShell->GetDrawView() )
- const_cast<SwDrawView*>(static_cast<const SwDrawView*>(m_pCursorShell->GetDrawView()))->SetAnimationEnabled(
- !m_pCursorShell->IsSelection() );
+ if ( !(!m_pCursorShell->IsCursorReadonly() || m_pCursorShell->GetViewOptions()->IsSelectionInReadonly()) )
+ return;
- sal_uInt16 nStyle = m_bIsDragCursor ? CURSOR_SHADOW : 0;
- if( nStyle != m_aTextCursor.GetStyle() )
- {
- m_aTextCursor.SetStyle( nStyle );
- m_aTextCursor.SetWindow( m_bIsDragCursor ? m_pCursorShell->GetWin() : nullptr );
- }
+ if ( m_pCursorShell->GetDrawView() )
+ const_cast<SwDrawView*>(static_cast<const SwDrawView*>(m_pCursorShell->GetDrawView()))->SetAnimationEnabled(
+ !m_pCursorShell->IsSelection() );
- m_aTextCursor.Show();
+ sal_uInt16 nStyle = m_bIsDragCursor ? CURSOR_SHADOW : 0;
+ if( nStyle != m_aTextCursor.GetStyle() )
+ {
+ m_aTextCursor.SetStyle( nStyle );
+ m_aTextCursor.SetWindow( m_bIsDragCursor ? m_pCursorShell->GetWin() : nullptr );
}
+
+ m_aTextCursor.Show();
}
const vcl::Cursor& SwVisibleCursor::GetTextCursor() const
@@ -389,109 +389,109 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
{
SdrView *const pView = const_cast<SdrView*>(m_pCursorShell->GetDrawView());
- if(pView && pView->PaintWindowCount())
- {
- // reset rects
- SwRects::clear();
- FillRects();
+ if(!(pView && pView->PaintWindowCount()))
+ return;
+
+ // reset rects
+ SwRects::clear();
+ FillRects();
#if HAVE_FEATURE_DESKTOP
- // get new rects
- std::vector< basegfx::B2DRange > aNewRanges;
- aNewRanges.reserve(size());
- for(size_type a = 0; a < size(); ++a)
- {
- const SwRect aNextRect((*this)[a]);
- const tools::Rectangle aPntRect(aNextRect.SVRect());
+ // get new rects
+ std::vector< basegfx::B2DRange > aNewRanges;
+ aNewRanges.reserve(size());
+ for(size_type a = 0; a < size(); ++a)
+ {
+ const SwRect aNextRect((*this)[a]);
+ const tools::Rectangle aPntRect(aNextRect.SVRect());
- aNewRanges.emplace_back(
- aPntRect.Left(), aPntRect.Top(),
- aPntRect.Right() + 1, aPntRect.Bottom() + 1);
- }
+ aNewRanges.emplace_back(
+ aPntRect.Left(), aPntRect.Top(),
+ aPntRect.Right() + 1, aPntRect.Bottom() + 1);
+ }
- if (m_pCursorOverlay)
+ if (m_pCursorOverlay)
+ {
+ if(!aNewRanges.empty())
{
- if(!aNewRanges.empty())
- {
- static_cast<sdr::overlay::OverlaySelection*>(m_pCursorOverlay.get())->setRanges(aNewRanges);
- }
- else
- {
- m_pCursorOverlay.reset();
- }
+ static_cast<sdr::overlay::OverlaySelection*>(m_pCursorOverlay.get())->setRanges(aNewRanges);
}
- else if(!empty())
+ else
{
- SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
- const rtl::Reference< sdr::overlay::OverlayManager >& xTargetOverlay = pCandidate->GetOverlayManager();
-
- if (xTargetOverlay.is())
- {
- // get the system's highlight color
- const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
- const Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor());
-
- // create correct selection
- m_pCursorOverlay.reset( new sdr::overlay::OverlaySelection(
- sdr::overlay::OverlayType::Transparent,
- aHighlight,
- aNewRanges,
- true) );
+ m_pCursorOverlay.reset();
+ }
+ }
+ else if(!empty())
+ {
+ SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
+ const rtl::Reference< sdr::overlay::OverlayManager >& xTargetOverlay = pCandidate->GetOverlayManager();
- xTargetOverlay->add(*m_pCursorOverlay);
- }
+ if (xTargetOverlay.is())
+ {
+ // get the system's highlight color
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+ const Color aHighlight(aSvtOptionsDrawinglayer.getHilightColor());
+
+ // create correct selection
+ m_pCursorOverlay.reset( new sdr::overlay::OverlaySelection(
+ sdr::overlay::OverlayType::Transparent,
+ aHighlight,
+ aNewRanges,
+ true) );
+
+ xTargetOverlay->add(*m_pCursorOverlay);
}
+ }
- HighlightInputField();
+ HighlightInputField();
#endif
- // Tiled editing does not expose the draw and writer cursor, it just
- // talks about "the" cursor at the moment. As long as that's true,
- // don't say anything about the Writer cursor till a draw object is
- // being edited.
- if (comphelper::LibreOfficeKit::isActive() && !pView->GetTextEditObject())
- {
- // If pSelectionRectangles is set, we're just collecting the text selections -> don't emit start/end.
- if (!empty() && !pSelectionRectangles)
- {
- // The selection may be a complex polygon, emit the logical
- // start/end cursor rectangle of the selection as separate
- // events, if there is a real selection.
- // This can be used to easily show selection handles on the
- // client side.
- SwRect aStartRect;
- SwRect aEndRect;
- FillStartEnd(aStartRect, aEndRect);
-
- if (aStartRect.HasArea())
- {
- OString sRect = aStartRect.SVRect().toString();
- GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
- }
- if (aEndRect.HasArea())
- {
- OString sRect = aEndRect.SVRect().toString();
- GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
- }
- }
+ // Tiled editing does not expose the draw and writer cursor, it just
+ // talks about "the" cursor at the moment. As long as that's true,
+ // don't say anything about the Writer cursor till a draw object is
+ // being edited.
+ if (!(comphelper::LibreOfficeKit::isActive() && !pView->GetTextEditObject()))
+ return;
- std::vector<OString> aRect;
- aRect.reserve(size());
- for (size_type i = 0; i < size(); ++i)
- {
- const SwRect& rRect = (*this)[i];
- aRect.push_back(rRect.SVRect().toString());
- }
- OString sRect = comphelper::string::join("; ", aRect);
- if (!pSelectionRectangles)
- {
- GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
- SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
- }
- else
- pSelectionRectangles->push_back(sRect);
+ // If pSelectionRectangles is set, we're just collecting the text selections -> don't emit start/end.
+ if (!empty() && !pSelectionRectangles)
+ {
+ // The selection may be a complex polygon, emit the logical
+ // start/end cursor rectangle of the selection as separate
+ // events, if there is a real selection.
+ // This can be used to easily show selection handles on the
+ // client side.
+ SwRect aStartRect;
+ SwRect aEndRect;
+ FillStartEnd(aStartRect, aEndRect);
+
+ if (aStartRect.HasArea())
+ {
+ OString sRect = aStartRect.SVRect().toString();
+ GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, sRect.getStr());
+ }
+ if (aEndRect.HasArea())
+ {
+ OString sRect = aEndRect.SVRect().toString();
+ GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, sRect.getStr());
}
}
+
+ std::vector<OString> aRect;
+ aRect.reserve(size());
+ for (size_type i = 0; i < size(); ++i)
+ {
+ const SwRect& rRect = (*this)[i];
+ aRect.push_back(rRect.SVRect().toString());
+ }
+ OString sRect = comphelper::string::join("; ", aRect);
+ if (!pSelectionRectangles)
+ {
+ GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+ SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
+ }
+ else
+ pSelectionRectangles->push_back(sRect);
}
void SwSelPaintRects::HighlightInputField()
@@ -571,18 +571,18 @@ void SwSelPaintRects::Invalidate( const SwRect& rRect )
// visible area, it is never aligned on one pixel at the right/bottom.
// This has to be determined here and if that is the case the
// rectangle has to be expanded.
- if( GetShell()->m_bVisPortChgd && 0 != ( nSz = size()) )
+ if( !(GetShell()->m_bVisPortChgd && 0 != ( nSz = size())) )
+ return;
+
+ SwSelPaintRects::Get1PixelInLogic( *GetShell() );
+ iterator it = begin();
+ for( ; nSz--; ++it )
{
- SwSelPaintRects::Get1PixelInLogic( *GetShell() );
- iterator it = begin();
- for( ; nSz--; ++it )
- {
- SwRect& rRectIt = *it;
- if( rRectIt.Right() == GetShell()->m_aOldRBPos.X() )
- rRectIt.AddRight( s_nPixPtX );
- if( rRectIt.Bottom() == GetShell()->m_aOldRBPos.Y() )
- rRectIt.AddBottom( s_nPixPtY );
- }
+ SwRect& rRectIt = *it;
+ if( rRectIt.Right() == GetShell()->m_aOldRBPos.X() )
+ rRectIt.AddRight( s_nPixPtX );
+ if( rRectIt.Bottom() == GetShell()->m_aOldRBPos.Y() )
+ rRectIt.AddBottom( s_nPixPtY );
}
}
@@ -679,27 +679,27 @@ void SwShellCursor::Show(SfxViewShell const * pViewShell)
pShCursor->SwSelPaintRects::Show(&aSelectionRectangles);
}
- if (comphelper::LibreOfficeKit::isActive())
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+
+ std::vector<OString> aRect;
+ for (const OString & rSelectionRectangle : aSelectionRectangles)
{
- std::vector<OString> aRect;
- for (const OString & rSelectionRectangle : aSelectionRectangles)
- {
- if (rSelectionRectangle.isEmpty())
- continue;
- aRect.push_back(rSelectionRectangle);
- }
- OString sRect = comphelper::string::join("; ", aRect);
- if (pViewShell)
- {
- // Just notify pViewShell about our existing selection.
- if (pViewShell != GetShell()->GetSfxViewShell())
- SfxLokHelper::notifyOtherView(GetShell()->GetSfxViewShell(), pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
- }
- else
- {
- GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
- SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
- }
+ if (rSelectionRectangle.isEmpty())
+ continue;
+ aRect.push_back(rSelectionRectangle);
+ }
+ OString sRect = comphelper::string::join("; ", aRect);
+ if (pViewShell)
+ {
+ // Just notify pViewShell about our existing selection.
+ if (pViewShell != GetShell()->GetSfxViewShell())
+ SfxLokHelper::notifyOtherView(GetShell()->GetSfxViewShell(), pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
+ }
+ else
+ {
+ GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+ SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
}
}
More information about the Libreoffice-commits
mailing list