diff options
Diffstat (limited to 'editeng/source/outliner')
-rw-r--r-- | editeng/source/outliner/outleeng.cxx | 21 | ||||
-rw-r--r-- | editeng/source/outliner/outleeng.hxx | 84 | ||||
-rw-r--r-- | editeng/source/outliner/outlin2.cxx | 26 | ||||
-rw-r--r-- | editeng/source/outliner/outliner.cxx | 91 | ||||
-rw-r--r-- | editeng/source/outliner/outlvw.cxx | 86 | ||||
-rw-r--r-- | editeng/source/outliner/overflowingtxt.cxx | 9 |
6 files changed, 129 insertions, 188 deletions
diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx index e4fc414ad8e3..1136ef37b9e2 100644 --- a/editeng/source/outliner/outleeng.cxx +++ b/editeng/source/outliner/outleeng.cxx @@ -21,9 +21,10 @@ #include <editeng/eerdll.hxx> #include <editeng/outliner.hxx> -#include "outleeng.hxx" +#include <outleeng.hxx> #include "paralist.hxx" #include <editeng/editrids.hrc> +#include <optional> #include <svl/itemset.hxx> #include <editeng/editstat.hxx> #include "outlundo.hxx" @@ -69,6 +70,15 @@ tools::Rectangle OutlinerEditEng::GetBulletArea( sal_Int32 nPara ) return aBulletArea; } +std::optional<bool> OutlinerEditEng::GetCompatFlag(SdrCompatibilityFlag eFlag) const +{ + if(pOwner) + { + return pOwner->GetCompatFlag(eFlag); + } + return {}; +} + void OutlinerEditEng::ParagraphInserted( sal_Int32 nNewParagraph ) { pOwner->ParagraphInserted( nNewParagraph ); @@ -141,7 +151,8 @@ OUString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const } void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen, - o3tl::span<const sal_Int32> pDXArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, + std::span<const sal_Int32> pDXArray, std::span<const sal_Bool> pKashidaArray, + const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, const EEngineData::WrongSpellVector* pWrongSpellVector, const SvxFieldData* pFieldData, bool bEndOfLine, @@ -150,7 +161,7 @@ void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText const Color& rOverlineColor, const Color& rTextLineColor) { - pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nRightToLeft, + pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,pKashidaArray,rFont,nPara,nRightToLeft, pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, false/*bEndOfBullet*/, pLocale, rOverlineColor, rTextLineColor); } @@ -163,9 +174,9 @@ void OutlinerEditEng::DrawingTab( const Point& rStartPos, tools::Long nWidth, co bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor ); } -OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor ) +OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor, std::optional<FontLineStyle>& rpFldLineStyle ) { - return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor ); + return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor, rpFldLineStyle ); } void OutlinerEditEng::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) diff --git a/editeng/source/outliner/outleeng.hxx b/editeng/source/outliner/outleeng.hxx deleted file mode 100644 index 963e74582ec0..000000000000 --- a/editeng/source/outliner/outleeng.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include <editeng/outliner.hxx> -#include <editeng/editeng.hxx> - -typedef std::vector<EENotify> NotifyList; - -class OutlinerEditEng : public EditEngine -{ - Outliner* pOwner; - -protected: - - // derived from EditEngine. Allows Outliner objects to provide - // bullet access to the EditEngine. - virtual const SvxNumberFormat* GetNumberFormat( sal_Int32 nPara ) const override; - -public: - OutlinerEditEng( Outliner* pOwner, SfxItemPool* pPool ); - virtual ~OutlinerEditEng() override; - - virtual void PaintingFirstLine(sal_Int32 nPara, const Point& rStartPos, const Point& rOrigin, Degree10 nOrientation, OutputDevice& rOutDev) override; - - virtual void ParagraphInserted( sal_Int32 nNewParagraph ) override; - virtual void ParagraphDeleted( sal_Int32 nDeletedParagraph ) override; - virtual void ParagraphConnected( sal_Int32 nLeftParagraph, sal_Int32 nRightParagraph ) override; - - virtual void DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, - sal_Int32 nTextLen, o3tl::span<const sal_Int32> pDXArray, const SvxFont& rFont, - sal_Int32 nPara, sal_uInt8 nRightToLeft, - const EEngineData::WrongSpellVector* pWrongSpellVector, - const SvxFieldData* pFieldData, - bool bEndOfLine, - bool bEndOfParagraph, - const css::lang::Locale* pLocale, - const Color& rOverlineColor, - const Color& rTextLineColor) override; - - virtual void DrawingTab( - const Point& rStartPos, tools::Long nWidth, const OUString& rChar, - const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, - bool bEndOfLine, - bool bEndOfParagraph, - const Color& rOverlineColor, - const Color& rTextLineColor) override; - - virtual void StyleSheetChanged( SfxStyleSheet* pStyle ) override; - virtual void ParaAttribsChanged( sal_Int32 nPara ) override; - virtual bool SpellNextDocument() override; - virtual OUString GetUndoComment( sal_uInt16 nUndoId ) const override; - - // for text conversion - virtual bool ConvertNextDocument() override; - - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override; - - virtual tools::Rectangle GetBulletArea( sal_Int32 nPara ) override; - - virtual void SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) override; - - // belongs into class Outliner, move there before incompatible update! - Link<EENotify&,void> aOutlinerNotifyHdl; - NotifyList aNotifyCache; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx index 3d4061a82cde..ccd07199a60f 100644 --- a/editeng/source/outliner/outlin2.cxx +++ b/editeng/source/outliner/outlin2.cxx @@ -30,7 +30,7 @@ #include <editeng/outliner.hxx> #include "paralist.hxx" -#include "outleeng.hxx" +#include <outleeng.hxx> #include <editeng/editstat.hxx> @@ -108,11 +108,6 @@ void Outliner::SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) pEditEngine->SetModifyHdl( rLink ); } -Link<LinkParamNone*,void> const & Outliner::GetModifyHdl() const -{ - return pEditEngine->GetModifyHdl(); -} - void Outliner::SetNotifyHdl( const Link<EENotify&,void>& rLink ) { pEditEngine->aOutlinerNotifyHdl = rLink; @@ -248,11 +243,6 @@ Size Outliner::CalcTextSize() return Size(pEditEngine->CalcTextWidth(),pEditEngine->GetTextHeight()); } -Size Outliner::CalcTextSizeNTP() -{ - return Size(pEditEngine->CalcTextWidth(),pEditEngine->GetTextHeightNTP()); -} - void Outliner::SetStyleSheetPool( SfxStyleSheetPool* pSPool ) { pEditEngine->SetStyleSheetPool( pSPool ); @@ -482,9 +472,13 @@ void Outliner::QuickFormatDoc() pEditEngine->QuickFormatDoc(); } -void Outliner::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY ) +ScalingParameters Outliner::getScalingParameters() const { + return pEditEngine->getScalingParameters(); +} +void Outliner::setScalingParameters(ScalingParameters const& rScalingParameters) +{ // reset bullet size sal_Int32 nParagraphs = pParaList->GetParagraphCount(); for ( sal_Int32 nPara = 0; nPara < nParagraphs; nPara++ ) @@ -494,12 +488,12 @@ void Outliner::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY ) pPara->aBulSize.setWidth( -1 ); } - pEditEngine->SetGlobalCharStretching( nX, nY ); + pEditEngine->setScalingParameters(rScalingParameters); } -void Outliner::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const +void Outliner::setRoundFontSizeToPt(bool bRound) const { - pEditEngine->GetGlobalCharStretching( rX, rY ); + pEditEngine->setRoundFontSizeToPt(bRound); } void Outliner::EraseVirtualDevice() @@ -559,7 +553,7 @@ EEHorizontalTextDirection Outliner::GetDefaultHorizontalTextDirection() const LanguageType Outliner::GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const { - return pEditEngine->GetLanguage( nPara, nPos ); + return pEditEngine->GetLanguage( nPara, nPos ).nLang; } void Outliner::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich ) diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index d5e6630cefe4..671ecd017cfd 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -30,7 +30,7 @@ #include <editeng/outliner.hxx> #include "paralist.hxx" #include <editeng/outlobj.hxx> -#include "outleeng.hxx" +#include <outleeng.hxx> #include "outlundo.hxx" #include <editeng/eeitem.hxx> #include <editeng/editstat.hxx> @@ -47,6 +47,8 @@ #include <libxml/xmlwriter.h> #include <sal/log.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> +#include <o3tl/temporary.hxx> #include <osl/diagnose.h> #include <memory> @@ -122,7 +124,6 @@ void Outliner::ParagraphInserted( sal_Int32 nPara ) pParaList->Insert( std::unique_ptr<Paragraph>(pPara), nPara ); if( pEditEngine->IsInUndo() ) { - pPara->nFlags = ParaFlag::SETBULLETTEXT; pPara->bVisible = true; const SfxInt16Item& rLevel = pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ); pPara->SetDepth( rLevel.GetValue() ); @@ -359,7 +360,7 @@ sal_Int32 Outliner::GetBulletsNumberingStatus() const std::optional<OutlinerParaObject> Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const { - if ( static_cast<sal_uLong>(nStartPara) + nCount > + if ( static_cast<sal_uInt64>(nStartPara) + nCount > o3tl::make_unsigned(pParaList->GetParagraphCount()) ) nCount = pParaList->GetParagraphCount() - nStartPara; @@ -381,6 +382,7 @@ std::optional<OutlinerParaObject> Outliner::CreateParaObject( sal_Int32 nStartPa aParagraphDataVector[nPara-nStartPara] = *GetParagraph(nPara); } + xText->ClearPortionInfo(); // tdf#147166 the PortionInfo is unwanted here OutlinerParaObject aPObj(std::move(xText), std::move(aParagraphDataVector), bIsEditDoc); aPObj.SetOutlinerMode(GetOutlinerMode()); @@ -426,7 +428,7 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara ) // handle empty strings. while( nIdx>=0 && nIdx<aText.getLength() ) { - OUString aStr = aText.getToken( 0, '\x0A', nIdx ); + std::u16string_view aStr = o3tl::getToken(aText, 0, '\x0A', nIdx ); sal_Int16 nCurDepth; if( nPos ) @@ -443,11 +445,11 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara ) ( GetOutlinerMode() == OutlinerMode::OutlineView ) ) { // Extract Tabs - sal_Int32 nTabs = 0; - while ( ( nTabs < aStr.getLength() ) && ( aStr[nTabs] == '\t' ) ) + size_t nTabs = 0; + while ( ( nTabs < aStr.size() ) && ( aStr[nTabs] == '\t' ) ) nTabs++; if ( nTabs ) - aStr = aStr.copy(nTabs); + aStr = aStr.substr(nTabs); // Keep depth? (see Outliner::Insert) if( !(pPara->nFlags & ParaFlag::HOLDDEPTH) ) @@ -455,19 +457,18 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara ) nCurDepth = nTabs-1; //TODO: sal_Int32 -> sal_Int16! ImplCheckDepth( nCurDepth ); pPara->SetDepth( nCurDepth ); - pPara->nFlags &= ~ParaFlag::HOLDDEPTH; } } if( nPos ) // not with the first paragraph { pParaList->Insert( std::unique_ptr<Paragraph>(pPara), nInsPos ); - pEditEngine->InsertParagraph( nInsPos, aStr ); + pEditEngine->InsertParagraph( nInsPos, OUString(aStr) ); ParagraphInsertedHdl(pPara); } else { nInsPos--; - pEditEngine->SetText( nInsPos, aStr ); + pEditEngine->SetText( nInsPos, OUString(aStr) ); } ImplInitDepth( nInsPos, nCurDepth, false ); nInsPos++; @@ -522,8 +523,8 @@ bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara ) } sal_Int32 nPos = nHeadingNumberStart ? nHeadingNumberStart : nNumberingNumberStart; - OUString aLevel = comphelper::string::stripStart(aName.subView(nPos), ' '); - nTabs = aLevel.toInt32(); + std::u16string_view aLevel = comphelper::string::stripStart(aName.subView(nPos), ' '); + nTabs = o3tl::toInt32(aLevel); if( nTabs ) nTabs--; // Level 0 = "heading 1" bConverted = true; @@ -633,7 +634,7 @@ void Outliner::AddText( const OutlinerParaObject& rPObj, bool bAppend ) pEditEngine->SetUpdateLayout( bUpdate ); } -OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor ) +OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor, std::optional<FontLineStyle>& rpFldLineStyle ) { if ( !aCalcFieldValueHdl.IsSet() ) return OUString( ' ' ); @@ -649,6 +650,11 @@ OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, rpTxtColor = *aFldInfo.GetTextColor(); } + if ( aFldInfo.GetFontLineStyle() ) + { + rpFldLineStyle = *aFldInfo.GetFontLineStyle(); + } + if (aFldInfo.GetFieldColor()) rpFldColor = *aFldInfo.GetFieldColor(); else @@ -663,7 +669,6 @@ void Outliner::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle ) if (pPara) { pEditEngine->SetStyleSheet( nPara, pStyle ); - pPara->nFlags |= ParaFlag::SETBULLETTEXT; ImplCheckNumBulletItem( nPara ); } } @@ -802,7 +807,6 @@ bool Outliner::Collapse( Paragraph const * pPara ) return true; } - vcl::Font Outliner::ImpCalcBulletFont( sal_Int32 nPara ) const { const SvxNumberFormat* pFmt = GetNumberFormat( nPara ); @@ -841,16 +845,12 @@ vcl::Font Outliner::ImpCalcBulletFont( sal_Int32 nPara ) const } // Use original scale... - sal_uInt16 nStretchX, nStretchY; - GetGlobalCharStretching(nStretchX, nStretchY); - sal_uInt16 nScale = pFmt->GetBulletRelSize() * nStretchY / 100; - sal_uLong nScaledLineHeight = aStdFont.GetFontSize().Height(); - nScaledLineHeight *= nScale*10; - nScaledLineHeight /= 1000; + double fFontScaleY = pFmt->GetBulletRelSize() / 100.0 * getScalingParameters().fFontY; + double fScaledLineHeight = aStdFont.GetFontSize().Height() * fFontScaleY; aBulletFont.SetAlignment( ALIGN_BOTTOM ); - aBulletFont.SetFontSize( Size( 0, nScaledLineHeight ) ); + aBulletFont.SetFontSize(Size(0, basegfx::fround(fScaledLineHeight))); bool bVertical = IsVertical(); aBulletFont.SetVertical( bVertical ); aBulletFont.SetOrientation( Degree10(bVertical ? (IsTopToBottom() ? 2700 : 900) : 0) ); @@ -888,12 +888,13 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& bool bRightToLeftPara = pEditEngine->IsRightToLeft( nPara ); tools::Rectangle aBulletArea( ImpCalcBulletArea( nPara, true, false ) ); - sal_uInt16 nStretchX, nStretchY; - GetGlobalCharStretching(nStretchX, nStretchY); - aBulletArea = tools::Rectangle( Point(aBulletArea.Left()*nStretchX/100, - aBulletArea.Top()), - Size(aBulletArea.GetWidth()*nStretchX/100, - aBulletArea.GetHeight()) ); + + double fSpacingFactorX = getScalingParameters().fSpacingX; + + tools::Long nStretchBulletX = basegfx::fround<tools::Long>(double(aBulletArea.Left()) * fSpacingFactorX); + tools::Long nStretchBulletWidth = basegfx::fround<tools::Long>(double(aBulletArea.GetWidth()) * fSpacingFactorX); + aBulletArea = tools::Rectangle(Point(nStretchBulletX, aBulletArea.Top()), + Size(nStretchBulletWidth, aBulletArea.GetHeight()) ); Paragraph* pPara = pParaList->GetParagraph( nPara ); const SvxNumberFormat* pFmt = GetNumberFormat( nPara ); @@ -938,18 +939,8 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& { // Both TopLeft and bottom left is not quite correct, // since in EditEngine baseline ... - double nRealOrientation = toRadians(nOrientation); - double nCos = cos( nRealOrientation ); - double nSin = sin( nRealOrientation ); - Point aRotatedPos; - // Translation... - aTextPos -= rOrigin; - // Rotation... - aRotatedPos.setX(static_cast<tools::Long>(nCos*aTextPos.X() + nSin*aTextPos.Y()) ); - aRotatedPos.setY(static_cast<tools::Long>(- (nSin*aTextPos.X() - nCos*aTextPos.Y())) ); - aTextPos = aRotatedPos; - // Translation... - aTextPos += rOrigin; + rOrigin.RotateAround(aTextPos, nOrientation); + vcl::Font aRotatedFont( aBulletFont ); aRotatedFont.SetOrientation( nOrientation ); rOutDev.SetFont( aRotatedFont ); @@ -965,7 +956,7 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& if(bStrippingPortions) { const vcl::Font& aSvxFont(rOutDev.GetFont()); - std::vector<sal_Int32> aBuf; + KernArray aBuf; rOutDev.GetTextArray( pPara->GetText(), &aBuf ); if(bSymbol) @@ -975,7 +966,8 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point& aTextPos.AdjustY( -(aMetric.GetDescent()) ); } - DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf, + assert(aBuf.get_factor() == 1); + DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf.get_subunit_array(), {}, aSvxFont, nPara, bRightToLeftPara ? 1 : 0, nullptr, nullptr, false, false, true, nullptr, Color(), Color()); } else @@ -1144,12 +1136,12 @@ void Outliner::ImpFilterIndents( sal_Int32 nFirstPara, sal_Int32 nLastPara ) pEditEngine->SetUpdateLayout( bUpdate ); } -SfxUndoManager& Outliner::GetUndoManager() +EditUndoManager& Outliner::GetUndoManager() { return pEditEngine->GetUndoManager(); } -SfxUndoManager* Outliner::SetUndoManager(SfxUndoManager* pNew) +EditUndoManager* Outliner::SetUndoManager(EditUndoManager* pNew) { return pEditEngine->SetUndoManager(pNew); } @@ -1651,7 +1643,8 @@ void Outliner::StripPortions() } void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, - sal_Int32 nTextLen, o3tl::span<const sal_Int32> pDXArray,const SvxFont& rFont, + sal_Int32 nTextLen, std::span<const sal_Int32> pDXArray, + std::span<const sal_Bool> pKashidaArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, const EEngineData::WrongSpellVector* pWrongSpellVector, const SvxFieldData* pFieldData, @@ -1664,7 +1657,7 @@ void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_I { if(aDrawPortionHdl.IsSet()) { - DrawPortionInfo aInfo( rStartPos, rText, nTextStart, nTextLen, rFont, nPara, pDXArray, pWrongSpellVector, + DrawPortionInfo aInfo( rStartPos, rText, nTextStart, nTextLen, rFont, nPara, pDXArray, pKashidaArray, pWrongSpellVector, pFieldData, pLocale, rOverlineColor, rTextLineColor, nRightToLeft, false, 0, bEndOfLine, bEndOfParagraph, bEndOfBullet); aDrawPortionHdl.Call( &aInfo ); @@ -1677,7 +1670,7 @@ void Outliner::DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUS { if(aDrawPortionHdl.IsSet()) { - DrawPortionInfo aInfo( rStartPos, rChar, 0, rChar.getLength(), rFont, nPara, {}, nullptr, + DrawPortionInfo aInfo( rStartPos, rChar, 0, rChar.getLength(), rFont, nPara, {}, {}, nullptr, nullptr, nullptr, rOverlineColor, rTextLineColor, nRightToLeft, true, nWidth, bEndOfLine, bEndOfParagraph, false); aDrawPortionHdl.Call( &aInfo ); @@ -1835,8 +1828,6 @@ void Outliner::ImplCalcBulletText( sal_Int32 nPara, bool bRecalcLevel, bool bRec if (pPara->GetText() != aBulletText) pPara->SetText( aBulletText ); - pPara->nFlags &= ~ParaFlag::SETBULLETTEXT; - if ( bRecalcLevel ) { sal_Int16 nDepth = pPara->GetDepth(); @@ -1895,8 +1886,6 @@ OUString Outliner::ImplGetBulletText( sal_Int32 nPara ) Paragraph* pPara = pParaList->GetParagraph( nPara ); if (pPara) { - // Enable optimization again ... -// if( pPara->nFlags & ParaFlag::SETBULLETTEXT ) ImplCalcBulletText( nPara, false, false ); aRes = pPara->GetText(); } diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index bf11c742dfea..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; } @@ -1045,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()); @@ -1330,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() @@ -1375,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); @@ -1463,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 diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx index ca7f363010d1..0a17cd609100 100644 --- a/editeng/source/outliner/overflowingtxt.cxx +++ b/editeng/source/outliner/overflowingtxt.cxx @@ -28,6 +28,7 @@ #include <editeng/editdata.hxx> #include <editdoc.hxx> +#include <utility> std::optional<OutlinerParaObject> TextChainingUtils::JuxtaposeParaObject( @@ -44,7 +45,7 @@ std::optional<OutlinerParaObject> TextChainingUtils::JuxtaposeParaObject( // Special case: if only empty text remove it at the end bool bOnlyOneEmptyPara = !pNextPObj || (pOutl->GetParagraphCount() == 1 && - pNextPObj->GetTextObject().GetText(0).isEmpty()); + !pNextPObj->GetTextObject().HasText(0)); EditEngine &rEditEngine = const_cast<EditEngine &>(pOutl->GetEditEngine()); @@ -93,7 +94,7 @@ std::optional<OutlinerParaObject> TextChainingUtils::DeeplyMergeParaObject( css::uno::Reference< css::datatransfer::XTransferable > TextChainingUtils::CreateTransferableFromText(Outliner const *pOutl) { - const EditEngine &rEditEngine = pOutl->GetEditEngine(); + EditEngine& rEditEngine = const_cast<EditEngine &>(pOutl->GetEditEngine()); sal_Int32 nLastPara = pOutl->GetParagraphCount()-1; ESelection aWholeTextSel(0, 0, nLastPara, rEditEngine.GetTextLen(nLastPara)); @@ -102,8 +103,8 @@ css::uno::Reference< css::datatransfer::XTransferable > TextChainingUtils::Creat -OverflowingText::OverflowingText(css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent) : - mxOverflowingContent(xOverflowingContent) +OverflowingText::OverflowingText(css::uno::Reference< css::datatransfer::XTransferable > xOverflowingContent) : + mxOverflowingContent(std::move(xOverflowingContent)) { } |