summaryrefslogtreecommitdiff
path: root/editeng/source/outliner/outlvw.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'editeng/source/outliner/outlvw.cxx')
-rw-r--r--editeng/source/outliner/outlvw.cxx115
1 files changed, 87 insertions, 28 deletions
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index e607698d5efe..cd01503731eb 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -30,7 +30,7 @@
#include <i18nlangtag/languagetag.hxx>
#include <editeng/outliner.hxx>
-#include "outleeng.hxx"
+#include <outleeng.hxx>
#include "paralist.hxx"
#include "outlundo.hxx"
#include <editeng/outlobj.hxx>
@@ -189,6 +189,13 @@ bool OutlinerView::PostKeyEvent( const KeyEvent& rKEvt, vcl::Window const * pFra
if( !aKeyCode.IsShift() )
{
+ // Don't let insert empty paragraph with numbering. Instead end numbering.
+ if (pPara->GetDepth() > -1 &&
+ pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) == 0)
+ {
+ ToggleBullets();
+ return true;
+ }
// ImpGetCursor again???
if( !bSelection &&
aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
@@ -284,7 +291,7 @@ sal_Int32 OutlinerView::ImpCheckMousePos(const Point& rPosPix, MouseTarget& reTa
bool OutlinerView::MouseMove( const MouseEvent& rMEvt )
{
- if( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode())
+ if( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->getEditEngine().IsInSelectionMode())
return pEditView->MouseMove( rMEvt );
Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) );
@@ -299,7 +306,7 @@ bool OutlinerView::MouseMove( const MouseEvent& rMEvt )
bool OutlinerView::MouseButtonDown( const MouseEvent& rMEvt )
{
- if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode() )
+ if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->getEditEngine().IsInSelectionMode() )
return pEditView->MouseButtonDown( rMEvt );
Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) );
@@ -347,7 +354,7 @@ bool OutlinerView::MouseButtonDown( const MouseEvent& rMEvt )
bool OutlinerView::MouseButtonUp( const MouseEvent& rMEvt )
{
- if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode() )
+ if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->getEditEngine().IsInSelectionMode() )
return pEditView->MouseButtonUp( rMEvt );
Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) );
@@ -384,6 +391,24 @@ void OutlinerView::Select( Paragraph const * pParagraph, bool bSelect )
pEditView->SetSelection( aSel );
}
+void OutlinerView::SetDepth(sal_Int32 nParagraph, sal_Int16 nDepth)
+{
+ Paragraph* pParagraph = pOwner->GetParagraph(nParagraph);
+ pOwner->SetDepth(pParagraph, nDepth);
+}
+
+sal_Int16 OutlinerView::GetDepth() const
+{
+ ESelection aESelection = GetSelection();
+ aESelection.Adjust();
+ sal_Int16 nDepth = pOwner->GetDepth(aESelection.nStartPara);
+ for (sal_Int32 nPara = aESelection.nStartPara + 1; nPara <= aESelection.nEndPara; ++nPara)
+ {
+ if (nDepth != pOwner->GetDepth(nPara))
+ return -2;
+ }
+ return nDepth;
+}
void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
{
@@ -667,12 +692,12 @@ void OutlinerView::Cut()
}
}
-void OutlinerView::PasteSpecial()
+void OutlinerView::PasteSpecial(SotClipboardFormatId format)
{
- Paste( true );
+ Paste( true, format );
}
-void OutlinerView::Paste( bool bUseSpecial )
+void OutlinerView::Paste( bool bUseSpecial, SotClipboardFormatId format)
{
if ( ImpCalcSelectedPages( false ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
return;
@@ -683,7 +708,7 @@ void OutlinerView::Paste( bool bUseSpecial )
pOwner->bPasting = true;
if ( bUseSpecial )
- pEditView->PasteSpecial();
+ pEditView->PasteSpecial(format);
else
pEditView->Paste();
@@ -715,6 +740,18 @@ void OutlinerView::CreateSelectionList (std::vector<Paragraph*> &aSelList)
}
}
+void OutlinerView::SetStyleSheet(const OUString& rStyleName)
+{
+ ParaRange aParas = ImpGetSelectedParagraphs(false);
+
+ auto pStyle = pOwner->GetStyleSheetPool()->Find(rStyleName, SfxStyleFamily::Para);
+ if (!pStyle)
+ return;
+
+ for (sal_Int32 nPara = aParas.nStartPara; nPara <= aParas.nEndPara; nPara++)
+ pOwner->SetStyleSheet(nPara, static_cast<SfxStyleSheet*>(pStyle));
+}
+
const SfxStyleSheet* OutlinerView::GetStyleSheet() const
{
return pEditView->GetStyleSheet();
@@ -845,7 +882,7 @@ void OutlinerView::ToggleBullets()
// determine default numbering rule for bullets
const ESelection aSelection(nPara, 0);
const SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection));
- const SfxPoolItem& rPoolItem = aTmpSet.GetPool()->GetDefaultItem( EE_PARA_NUMBULLET );
+ const SfxPoolItem& rPoolItem = aTmpSet.GetPool()->GetUserOrPoolDefaultItem( EE_PARA_NUMBULLET );
const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(&rPoolItem);
pDefaultBulletNumRule = pNumBulletItem ? &pNumBulletItem->GetNumRule() : nullptr;
}
@@ -930,6 +967,35 @@ void OutlinerView::ToggleBulletsNumbering(
}
}
+void OutlinerView::EnsureNumberingIsOn()
+{
+ pOwner->UndoActionStart(OLUNDO_DEPTH);
+
+ ESelection aSel(pEditView->GetSelection());
+ aSel.Adjust();
+
+ const bool bUpdate = pOwner->pEditEngine->IsUpdateLayout();
+ pOwner->pEditEngine->SetUpdateLayout(false);
+
+ for (sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++)
+ {
+ Paragraph* pPara = pOwner->pParaList->GetParagraph(nPara);
+ DBG_ASSERT(pPara, "OutlinerView::EnableBullets(), illegal selection?");
+
+ if (pPara && pOwner->GetDepth(nPara) == -1)
+ pOwner->SetDepth(pPara, 0);
+ }
+
+ sal_Int32 nParaCount = pOwner->pParaList->GetParagraphCount();
+ pOwner->ImplCheckParagraphs(aSel.nStartPara, nParaCount);
+
+ const sal_Int32 nEndPara = (nParaCount > 0) ? nParaCount-1 : nParaCount;
+ pOwner->pEditEngine->QuickMarkInvalid(ESelection(aSel.nStartPara, 0, nEndPara, 0));
+
+ pOwner->pEditEngine->SetUpdateLayout(bUpdate);
+
+ pOwner->UndoActionEnd();
+}
void OutlinerView::ApplyBulletsNumbering(
const bool bHandleBullets,
@@ -1016,17 +1082,15 @@ void OutlinerView::ApplyBulletsNumbering(
// Get old bullet space.
{
- const SfxPoolItem* pPoolItem=nullptr;
- SfxItemState eState = rAttrs.GetItemState(EE_PARA_NUMBULLET, false, &pPoolItem);
- if (eState != SfxItemState::SET)
+ const SvxNumBulletItem* pNumBulletItem = rAttrs.GetItemIfSet(EE_PARA_NUMBULLET, false);
+ if (pNumBulletItem)
{
// Use default value when has not contain bullet item.
ESelection aSelection(nPara, 0);
SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection));
- pPoolItem = aTmpSet.GetItem(EE_PARA_NUMBULLET);
+ pNumBulletItem = aTmpSet.GetItem(EE_PARA_NUMBULLET);
}
- const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(pPoolItem);
if (pNumBulletItem)
{
const sal_uInt16 nLevelCnt = std::min(pNumBulletItem->GetNumRule().GetLevelCount(), aNewRule.GetLevelCount());
@@ -1301,14 +1365,9 @@ const SvxFieldItem* OutlinerView::GetFieldUnderMousePointer() const
return pEditView->GetFieldUnderMousePointer();
}
-const SvxFieldItem* OutlinerView::GetFieldAtSelection() const
-{
- return pEditView->GetFieldAtSelection();
-}
-
-const SvxFieldData* OutlinerView::GetFieldAtCursor() const
+const SvxFieldItem* OutlinerView::GetFieldAtSelection(bool bAlsoCheckBeforeCursor) const
{
- return pEditView->GetFieldAtCursor();
+ return pEditView->GetFieldAtSelection(bAlsoCheckBeforeCursor);
}
void OutlinerView::SelectFieldAtCursor()
@@ -1346,13 +1405,13 @@ void OutlinerView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCal
void OutlinerView::Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs )
{
- sal_Int32 nOldParaCount = pEditView->GetEditEngine()->GetParagraphCount();
+ sal_Int32 nOldParaCount = pEditView->getEditEngine().GetParagraphCount();
ESelection aOldSel = pEditView->GetSelection();
aOldSel.Adjust();
pEditView->Read( rInput, eFormat, pHTTPHeaderAttrs );
- tools::Long nParaDiff = pEditView->GetEditEngine()->GetParagraphCount() - nOldParaCount;
+ tools::Long nParaDiff = pEditView->getEditEngine().GetParagraphCount() - nOldParaCount;
sal_Int32 nChangesStart = aOldSel.nStartPara;
sal_Int32 nChangesEnd = nChangesStart + nParaDiff + (aOldSel.nEndPara-aOldSel.nStartPara);
@@ -1434,17 +1493,17 @@ bool GetStatusValueForThesaurusFromContext(
{
// get text and locale for thesaurus look up
OUString aText;
- EditEngine *pEditEngine = rEditView.GetEditEngine();
+ EditEngine& rEditEngine = rEditView.getEditEngine();
ESelection aTextSel( rEditView.GetSelection() );
if (!aTextSel.HasRange())
- aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD );
- aText = pEditEngine->GetText( aTextSel );
+ aTextSel = rEditEngine.GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD );
+ aText = rEditEngine.GetText( aTextSel );
aTextSel.Adjust();
- if (!isSingleScriptType(pEditEngine->GetScriptType(aTextSel)))
+ if (!isSingleScriptType(rEditEngine.GetScriptType(aTextSel)))
return false;
- LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos );
+ LanguageType nLang = rEditEngine.GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos ).nLang;
OUString aLangText( LanguageTag::convertToBcp47( nLang ) );
// set word and locale to look up as status value