core.git: sc/source
sc/source/ui/view/viewdata.cxx |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) New commits: commit e1abdcef4404c2a1b8d6d87ae295451a457aeae4 Author: Tomaž Vajngerl AuthorDate: Fri Jan 5 21:05:50 2024 +0900 Commit: Caolán McNamara CommitDate: Tue Jan 9 14:25:43 2024 +0100 sc: LOK work-around for mouse click selecting the wrong cell Don't increase the cell selection if we detect the mouse click was out of the screen (grid window) area. Only do this when LOK is enabled. Change-Id: I97922e9d02500d7cedeaa5fa29d4ca344950ff47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161662 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161816 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 25e602669e80..d09c0a9e0aec 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2851,15 +2851,19 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, tools::Long nClickY, ScSp } } +bool bLOK = comphelper::LibreOfficeKit::isActive(); // cells too big? -if ( rPosX == nStartPosX && nClickX > 0 ) +// Work-around this for LOK, because the screen size is in not set correctly +// for all views and we will geturn the wrong position in case we send a click +// that is outside the set screen grid area +if (rPosX == nStartPosX && nClickX > 0 && !bLOK) { if (pView) aScrSize.setWidth( pView->GetGridWidth(eHWhich) ); if ( nClickX > aScrSize.Width() ) ++rPosX; } -if ( rPosY == nStartPosY && nClickY > 0 ) +if (rPosY == nStartPosY && nClickY > 0 && !bLOK) { if (pView) aScrSize.setHeight( pView->GetGridHeight(eVWhich) );
core.git: Branch 'distro/collabora/co-23.05' - sc/source
sc/source/ui/view/viewdata.cxx |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) New commits: commit 1380a8290b799f44ef767e2fb6813e3cd387ff6c Author: Tomaž Vajngerl AuthorDate: Fri Jan 5 21:05:50 2024 +0900 Commit: Miklos Vajna CommitDate: Mon Jan 8 11:05:12 2024 +0100 sc: LOK work-around for mouse click selecting the wrong cell Don't increase the cell selection if we detect the mouse click was out of the screen (grid window) area. Only do this when LOK is enabled. Change-Id: I97922e9d02500d7cedeaa5fa29d4ca344950ff47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161662 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 57ef3e5487d0..8fc254aa8fce 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2849,15 +2849,19 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, tools::Long nClickY, ScSp } } +bool bLOK = comphelper::LibreOfficeKit::isActive(); // cells too big? -if ( rPosX == nStartPosX && nClickX > 0 ) +// Work-around this for LOK, because the screen size is in not set correctly +// for all views and we will geturn the wrong position in case we send a click +// that is outside the set screen grid area +if (rPosX == nStartPosX && nClickX > 0 && !bLOK) { if (pView) aScrSize.setWidth( pView->GetGridWidth(eHWhich) ); if ( nClickX > aScrSize.Width() ) ++rPosX; } -if ( rPosY == nStartPosY && nClickY > 0 ) +if (rPosY == nStartPosY && nClickY > 0 && !bLOK) { if (pView) aScrSize.setHeight( pView->GetGridHeight(eVWhich) );
core.git: editeng/source
editeng/source/editeng/impedit2.cxx | 38 1 file changed, 22 insertions(+), 16 deletions(-) New commits: commit 548f0b1883e18ff2870a40bccf047864ff35c18b Author: Tomaž Vajngerl AuthorDate: Tue Jan 2 15:29:52 2024 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 2 09:56:55 2024 +0100 editeng: preserve ContentNode in a unique_ptr when moving paras When we move the paragraphs, we can just take the unique_ptr of ContetNodes out of the EditDoc and move it to new position inside EditDoc, like it is done for ParaPortions in ParaPortionList. No need to muck with the raw pointers and releasing the ContentNode from a unique_ptr and later moving it back again. Also just use a std::vector for ParaPortions instead of a new instance of ParaPortionList. Change-Id: I8634ccc83121c1ee683be4c2cfb0cedbd469c05d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161531 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 78a56dc926bc..6e9351a7c80e 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -2199,36 +2199,42 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_Int32 n // do not lose sight of the Position ! ParaPortion* pDestPortion = GetParaPortions().SafeGetObject( nNewPos ); -ParaPortionList aTmpPortionList; +// Temporary containers used for moving the paragraph portions and content nodes to a new location +std::vector> aParagraphPortionVector; +std::vector> aContentNodeVector; + +// Take the paragraph portions and content nodes out of its containers for (tools::Long i = aOldPositions.Min(); i <= aOldPositions.Max(); i++ ) { -// always aOldPositions.Min(), since Remove(). -std::unique_ptr pTmpPortion = GetParaPortions().Release(aOldPositions.Min()); -auto pContentNode = maEditDoc.Release(aOldPositions.Min()); -pContentNode.release(); -aTmpPortionList.Append(std::move(pTmpPortion)); +// always aOldPositions.Min() as the index, since we remove and the elements from the containers and the +// other elements shift to the left. +std::unique_ptr pPortion = GetParaPortions().Release(aOldPositions.Min()); +aParagraphPortionVector.push_back(std::move(pPortion)); + +std::unique_ptr pContentNode = maEditDoc.Release(aOldPositions.Min()); +aContentNodeVector.push_back(std::move(pContentNode)); } +// Determine the new location for paragraphs sal_Int32 nRealNewPos = pDestPortion ? GetParaPortions().GetPos( pDestPortion ) : GetParaPortions().Count(); assert( nRealNewPos != EE_PARA_NOT_FOUND && "ImpMoveParagraphs: Invalid Position!" ); +// Add the paragraph portions and content nodes to a new position sal_Int32 i = 0; -while( aTmpPortionList.Count() > 0 ) +for (auto& pPortion : aParagraphPortionVector) { -std::unique_ptr pTmpPortion = aTmpPortionList.Release(0); -if ( i == 0 ) -aSelection.Min().SetNode( pTmpPortion->GetNode() ); - -aSelection.Max().SetNode( pTmpPortion->GetNode() ); -aSelection.Max().SetIndex( pTmpPortion->GetNode()->Len() ); +if (i == 0) +aSelection.Min().SetNode(pPortion->GetNode()); +aSelection.Max().SetNode(pPortion->GetNode()); +aSelection.Max().SetIndex(pPortion->GetNode()->Len()); -ContentNode* pNode = pTmpPortion->GetNode(); -maEditDoc.Insert(nRealNewPos+i, std::unique_ptr(pNode)); +maEditDoc.Insert(nRealNewPos + i, std::move(aContentNodeVector[i])); +GetParaPortions().Insert(nRealNewPos + i, std::move(pPortion)); -GetParaPortions().Insert(nRealNewPos+i, std::move(pTmpPortion)); ++i; } +// Signal end of paragraph moving maEndMovingParagraphsHdl.Call( aMoveParagraphsInfo ); if ( GetNotifyHdl().IsSet() )
core.git: editeng/inc editeng/source
editeng/inc/ParagraphPortionList.hxx | 14 +- editeng/source/editeng/impedit3.cxx |3 +-- 2 files changed, 14 insertions(+), 3 deletions(-) New commits: commit e7e7449729fe2b750506b4b165c4be993834fd16 Author: Tomaž Vajngerl AuthorDate: Mon Jan 1 14:34:04 2024 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 2 04:12:51 2024 +0100 editeng: add begin, end, MarkAllSelectionsInvalid to ParaPortionList begin, end to make iteration work with range for Change-Id: Ia64d4f8102485b257e190fc702e4aa734a81d866 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161530 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/ParagraphPortionList.hxx b/editeng/inc/ParagraphPortionList.hxx index 23654adc5e43..aa7862afa8d7 100644 --- a/editeng/inc/ParagraphPortionList.hxx +++ b/editeng/inc/ParagraphPortionList.hxx @@ -28,7 +28,8 @@ class EditDoc; class ParaPortionList { mutable sal_Int32 nLastCache = 0; -std::vector> maPortions; +typedef std::vector> ParaPortionContainerType; +ParaPortionContainerType maPortions; public: ParaPortionList() = default; @@ -50,6 +51,17 @@ public: void Append(std::unique_ptr p); sal_Int32 Count() const; +ParaPortionContainerType::iterator begin() { return maPortions.begin(); } +ParaPortionContainerType::iterator end() { return maPortions.end(); } +ParaPortionContainerType::const_iterator cbegin() const { return maPortions.cbegin(); } +ParaPortionContainerType::const_iterator cend() const { return maPortions.cend(); } + +void MarkAllSelectionsInvalid(sal_Int32 nStart) +{ +for (auto& pParaPortion : maPortions) +pParaPortion->MarkSelectionInvalid(nStart); +} + #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG // temporary: static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index a4e0a54aaa0d..d50c2eb1338e 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -393,8 +393,7 @@ bool ImpEditEngine::IsPageOverflow( ) const void ImpEditEngine::FormatFullDoc() { -for ( sal_Int32 nPortion = 0; nPortion < GetParaPortions().Count(); nPortion++ ) -GetParaPortions()[nPortion]->MarkSelectionInvalid( 0 ); +GetParaPortions().MarkAllSelectionsInvalid(0); FormatDoc(); }
core.git: editeng/source
editeng/source/editeng/editeng.cxx | 84 +++ editeng/source/editeng/impedit.hxx | 153 +-- editeng/source/editeng/impedit2.cxx | 182 editeng/source/editeng/impedit3.cxx | 114 ++-- editeng/source/editeng/impedit4.cxx | 199 +--- editeng/source/editeng/impedit5.cxx | 20 +-- 6 files changed, 374 insertions(+), 378 deletions(-) New commits: commit de385412949e2ca52c999546677744ed070d189c Author: Tomaž Vajngerl AuthorDate: Mon Jan 1 14:31:13 2024 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 2 04:12:32 2024 +0100 editeng: prefix members of ImpEditEngine Change-Id: I05a738be8956ebaa2912c6c8a20a05002d67b789 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161529 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index c5db1b5ca9ab..7af59f499e12 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -393,7 +393,7 @@ void EditEngine::SetPaperSize( const Size& rNewSize ) if ( !(bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() )) ) return; -for (EditView* pView : pImpEditEngine->aEditViews) +for (EditView* pView : pImpEditEngine->maEditViews) { if ( bAutoPageSize ) pView->pImpEditView->RecalcOutputArea(); @@ -414,7 +414,7 @@ void EditEngine::SetPaperSize( const Size& rNewSize ) pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() ); if ( pImpEditEngine->IsUpdateLayout() && pImpEditEngine->GetActiveView() ) -pImpEditEngine->pActiveView->ShowCursor( false, false ); +pImpEditEngine->mpActiveView->ShowCursor( false, false ); } } @@ -685,7 +685,7 @@ void EditEngine::CheckIdleFormatter() bool EditEngine::IsIdleFormatterActive() const { -return pImpEditEngine->aIdleFormatter.IsActive(); +return pImpEditEngine->maIdleFormatter.IsActive(); } ParaPortion* EditEngine::FindParaPortion(ContentNode const * pNode) @@ -725,7 +725,7 @@ bool EditEngine::IsCallParaInsertedOrDeleted() const void EditEngine::AppendDeletedNodeInfo(DeletedNodeInfo* pInfo) { - pImpEditEngine->aDeletedNodes.push_back(std::unique_ptr(pInfo)); + pImpEditEngine->maDeletedNodes.push_back(std::unique_ptr(pInfo)); } void EditEngine::UpdateSelections() @@ -969,12 +969,12 @@ EditPaM EditEngine::DeleteSelected(const EditSelection& rSel) void EditEngine::HandleBeginPasteOrDrop(PasteOrDropInfos& rInfos) { -pImpEditEngine->aBeginPasteOrDropHdl.Call(rInfos); +pImpEditEngine->maBeginPasteOrDropHdl.Call(rInfos); } void EditEngine::HandleEndPasteOrDrop(PasteOrDropInfos& rInfos) { -pImpEditEngine->aEndPasteOrDropHdl.Call(rInfos); +pImpEditEngine->maEndPasteOrDropHdl.Call(rInfos); } bool EditEngine::HasText() const @@ -984,7 +984,7 @@ bool EditEngine::HasText() const const EditSelectionEngine& EditEngine::GetSelectionEngine() const { -return pImpEditEngine->aSelEngine; +return pImpEditEngine->maSelEngine; } void EditEngine::SetInSelectionMode(bool b) @@ -1049,7 +1049,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v sal_Int32 nParas = GetParagraphCount(); Point aPos; Point aViewStart( pEditView->GetOutputArea().TopLeft() ); -tools::Long n20 = 40 * pImpEditEngine->nOnePixelInRef; +tools::Long n20 = 40 * pImpEditEngine->mnOnePixelInRef; for ( sal_Int32 n = 0; n < nParas; n++ ) { tools::Long nH = GetTextHeight( n ); @@ -1316,7 +1316,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v // Only at end of word... sal_Int32 nIndex = aCurSel.Max().GetIndex(); if ( ( nIndex >= aCurSel.Max().GetNode()->Len() ) || - ( pImpEditEngine->aWordDelimiters.indexOf( aCurSel.Max().GetNode()->GetChar( nIndex ) ) != -1 ) ) + ( pImpEditEngine->maWordDelimiters.indexOf( aCurSel.Max().GetNode()->GetChar( nIndex ) ) != -1 ) ) { EditPaM aStart( pImpEditEngine->WordLeft( aCurSel.Max() ) ); OUString aWord = pImpEditEngine->GetSelected( EditSelection( aStart, aCurSel.Max() ) ); @@ -1327,18 +1327,18 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v LanguageType eLang = pImpEditEngine->GetLanguage( EditPaM( aStart.GetNode(), aStart.GetIndex()+1)).nLang; LanguageTag aLanguageTag( eLang); -if
core.git: editeng/inc editeng/source
editeng/inc/editdoc.hxx |2 -- editeng/source/editeng/editdoc.cxx | 10 -- editeng/source/editeng/edtspell.cxx |6 +++--- editeng/source/editeng/impedit.hxx |8 editeng/source/editeng/impedit2.cxx | 10 +- 5 files changed, 12 insertions(+), 24 deletions(-) New commits: commit 92a9fa82f412daa4e5ccb5889076a1267648e0c1 Author: Tomaž Vajngerl AuthorDate: Sun Dec 31 19:15:38 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 2 04:11:16 2024 +0100 editeng: remove operator[] for EditDoc (use GetObject instead) Change-Id: Ie41d2baf84d230b9ee280859d390e24b9da70be7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161482 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 974447bd806c..0c2bcd28fa97 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -205,8 +205,6 @@ public: const ContentNode* GetObject(sal_Int32 nPos) const; ContentNode* GetObject(sal_Int32 nPos); sal_Int32 Count() const; -const ContentNode* operator[](sal_Int32 nPos) const; -ContentNode* operator[](sal_Int32 nPos); void Insert(sal_Int32 nPos, std::unique_ptr p); /// deletes void Remove(sal_Int32 nPos); diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 07d61802c773..efc95b944833 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -933,16 +933,6 @@ ContentNode* EditDoc::GetObject(sal_Int32 nPos) return 0 <= nPos && o3tl::make_unsigned(nPos) < maContents.size() ? maContents[nPos].get() : nullptr; } -const ContentNode* EditDoc::operator[](sal_Int32 nPos) const -{ -return GetObject(nPos); -} - -ContentNode* EditDoc::operator[](sal_Int32 nPos) -{ -return GetObject(nPos); -} - void EditDoc::Insert(sal_Int32 nPos, std::unique_ptr pNode) { if (nPos < 0 || nPos == SAL_MAX_INT32) diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx index c07361bd196b..36e9f5fd84ae 100644 --- a/editeng/source/editeng/edtspell.cxx +++ b/editeng/source/editeng/edtspell.cxx @@ -613,8 +613,8 @@ OUString const* EdtAutoCorrDoc::GetPrevPara(bool const) bAllowUndoAction = false; // Not anymore ... -EditDoc& rNodes = mpEditEngine->GetEditDoc(); -sal_Int32 nPos = rNodes.GetPos( pCurNode ); +EditDoc& rEditDoc = mpEditEngine->GetEditDoc(); +sal_Int32 nPos = rEditDoc.GetPos( pCurNode ); // Special case: Bullet => Paragraph start => simply return NULL... const SfxBoolItem& rBulletState = mpEditEngine->GetParaAttrib( nPos, EE_PARA_BULLETSTATE ); @@ -632,7 +632,7 @@ OUString const* EdtAutoCorrDoc::GetPrevPara(bool const) for ( sal_Int32 n = nPos; n; ) { n--; -ContentNode* pNode = rNodes[n]; +ContentNode* pNode = rEditDoc.GetObject(n); if ( pNode->Len() ) return & pNode->GetString(); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 7269c0e0b614..ef699b0b28ad 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -1090,8 +1090,8 @@ public: EditPaM CreateEditPaM( const EPaM& rEPaM ) { DBG_ASSERT( rEPaM.nPara < maEditDoc.Count(), "CreateEditPaM: invalid paragraph" ); -DBG_ASSERT( maEditDoc[ rEPaM.nPara ]->Len() >= rEPaM.nIndex, "CreateEditPaM: invalid Index" ); -return EditPaM( maEditDoc[ rEPaM.nPara], rEPaM.nIndex ); +DBG_ASSERT(maEditDoc.GetObject(rEPaM.nPara)->Len() >= rEPaM.nIndex, "CreateEditPaM: invalid Index"); +return EditPaM(maEditDoc.GetObject(rEPaM.nPara), rEPaM.nIndex); } ESelection CreateESel(const EditSelection& rSel) const @@ -,9 +,9 @@ public: DBG_ASSERT( rSel.nStartPara < maEditDoc.Count(), "CreateSel: invalid start paragraph" ); DBG_ASSERT( rSel.nEndPara < maEditDoc.Count(), "CreateSel: invalid end paragraph" ); EditSelection aSel; -aSel.Min().SetNode( maEditDoc[ rSel.nStartPara ] ); +aSel.Min().SetNode(maEditDoc.GetObject(rSel.nStartPara)); aSel.Min().SetIndex( rSel.nStartPos ); -aSel.Max().SetNode( maEditDoc[ rSel.nEndPara ] ); +aSel.Max().SetNode(maEditDoc.GetObject(rSel.nEndPara)); aSel.Max().SetIndex( rSel.nEndPos ); DBG_ASSERT( !aSel.DbgIsBuggy( maEditDoc ), "CreateSel: incorrect selection!" ); return aSel; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 488873edd266..2b8263cc62cd 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -236,8 +236,8 @@ void ImpEditEngine::InitDoc(bool bKeepParaAttribs) sal_Int32 nParas = maEditDoc.Count(); for ( sal_Int32 n = bKeepParaAttribs ? 1 : 0; n < nParas; n++ ) { -if ( maEditDoc[n]->GetStyleSheet() ) -
core.git: 2 commits - editeng/inc editeng/qa editeng/source include/editeng
editeng/inc/editdoc.hxx |2 editeng/qa/unit/core-test.cxx | 93 +++- editeng/source/editeng/editdoc.cxx |9 +-- editeng/source/editeng/editeng.cxx |4 - editeng/source/editeng/editundo.cxx | 45 - editeng/source/editeng/editundo.hxx |9 +-- editeng/source/editeng/impedit.hxx |2 editeng/source/editeng/impedit2.cxx | 31 ++-- editeng/source/editeng/impedit3.cxx |8 +-- include/editeng/editeng.hxx |2 10 files changed, 149 insertions(+), 56 deletions(-) New commits: commit e71934471442a8bbba7e661d3ebe5f708627c5d6 Author: Tomaž Vajngerl AuthorDate: Sun Dec 31 11:26:04 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 2 01:21:00 2024 +0100 editeng: add max paper size constant Change-Id: Ib51f5c5bbcf68fd156b02e04e8e99408aa97abf1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161481 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 94f4c6ccfa8f..488873edd266 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -88,11 +88,13 @@ static sal_uInt16 lcl_CalcExtraSpace( const SvxLineSpacingItem& rLSItem ) return nExtra; } +constexpr tools::Long constMaxPaperSize = 0x7FFF; + ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : pSharedVCL(EditDLL::Get().GetSharedVclResources()), -maPaperSize( 0x7FFF, 0x7FFF ), -maMinAutoPaperSize( 0x0, 0x0 ), -maMaxAutoPaperSize( 0x7FFF, 0x7FFF ), +maPaperSize(constMaxPaperSize, constMaxPaperSize), +maMinAutoPaperSize(0, 0), +maMaxAutoPaperSize(constMaxPaperSize, constMaxPaperSize), maEditDoc( pItemPool ), pEditEngine(pEE), pActiveView(nullptr), commit 3461a0027cf5c54ae164462d177ea222ccc76f39 Author: Tomaž Vajngerl AuthorDate: Sat Dec 30 22:27:42 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Jan 2 01:20:53 2024 +0100 editeng: better lifecycle control for ContentNode in EditDoc Don't use raw pointers, when it is possible to move the unique_ptr around into another object that is responsible for the object's ownership. The ContentNode is either in a vector in the EditDoc class or it is moved to the EditUndoDelContent class for the undo/redo action. Those 2 classes are responsible for freeing the ContentNode. Change-Id: I977d8e418947bb48781f23575d62420260025e57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161480 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index e9016989e840..974447bd806c 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -211,7 +211,7 @@ public: /// deletes void Remove(sal_Int32 nPos); /// does not delete -void Release(sal_Int32 nPos); +std::unique_ptr Release(sal_Int32 nPos); static OUString GetSepStr( LineEnd eEnd ); }; diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index b5320f90e448..c17fccf1caef 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -113,6 +113,7 @@ public: void testTdf148148(); void testSingleLine(); +void testMoveParagraph(); DECL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, void ); @@ -139,6 +140,7 @@ public: CPPUNIT_TEST(testTdf147196); CPPUNIT_TEST(testTdf148148); CPPUNIT_TEST(testSingleLine); +CPPUNIT_TEST(testMoveParagraph); CPPUNIT_TEST_SUITE_END(); private: @@ -555,8 +557,7 @@ IMPL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, pInfo, void ) void Test::testHyperlinkCopyPaste() { // Create Outliner instance -Outliner aOutliner(mpItemPool.get(), OutlinerMode -::TextObject); +Outliner aOutliner(mpItemPool.get(), OutlinerMode::TextObject); aOutliner.SetCalcFieldValueHdl( LINK( nullptr, Test, CalcFieldValueHdl ) ); // Create EditEngine's instance @@ -1984,6 +1985,94 @@ void Test::testSingleLine() CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aEditEngine.GetLineCount(0)); } +void Test::testMoveParagraph() +{ +EditEngine aEditEngine(mpItemPool.get()); +aEditEngine.SetPaperSize(Size(5000, 5000)); +aEditEngine.SetText("Paragraph 1 Paragraph 2 Paragraph 3 Paragraph 4 Paragraph 5"); + +CPPUNIT_ASSERT_EQUAL(true, aEditEngine.IsFormatted()); + +CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aEditEngine.GetParagraphCount()); +CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 1"), aEditEngine.GetText(0)); +CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 2"), aEditEngine.GetText(1)); +CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 3"), aEditEngine.GetText(2)); +CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 4"), aEditEngine.GetText(3)); +CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 5"), aEditEngine.GetText(4)); + +
core.git: editeng/inc editeng/source
editeng/inc/editdoc.hxx |7 +-- editeng/source/editeng/editdoc.cxx | 18 +- editeng/source/editeng/impedit2.cxx |6 +++--- editeng/source/editeng/impedit3.cxx |2 +- 4 files changed, 18 insertions(+), 15 deletions(-) New commits: commit 417d1d56b39453b5ae8396a8286d8291061f049b Author: Tomaž Vajngerl AuthorDate: Sat Dec 30 11:25:34 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Mon Jan 1 09:21:14 2024 +0100 editeng: make it clear EditDoc is responsible for ContentNodes Change-Id: I38b9b1a5ba48d73438865f5a040f2483f6814c40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161479 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 7fc29556957c..e9016989e840 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -100,7 +100,10 @@ public: }; - +/** Edit document + * + * Holder, responsible for the content nodes and the manipulation of those. + */ class EditDoc { private: @@ -204,7 +207,7 @@ public: sal_Int32 Count() const; const ContentNode* operator[](sal_Int32 nPos) const; ContentNode* operator[](sal_Int32 nPos); -void Insert(sal_Int32 nPos, ContentNode* p); +void Insert(sal_Int32 nPos, std::unique_ptr p); /// deletes void Remove(sal_Int32 nPos); /// does not delete diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 0afcc9cdd81c..c44c0b5a123c 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -943,14 +943,14 @@ ContentNode* EditDoc::operator[](sal_Int32 nPos) return GetObject(nPos); } -void EditDoc::Insert(sal_Int32 nPos, ContentNode* p) +void EditDoc::Insert(sal_Int32 nPos, std::unique_ptr pNode) { if (nPos < 0 || nPos == SAL_MAX_INT32) { SAL_WARN( "editeng", "EditDoc::Insert - overflow pos " << nPos); return; } -maContents.insert(maContents.begin()+nPos, std::unique_ptr(p)); +maContents.insert(maContents.begin()+nPos, std::move(pNode)); } void EditDoc::Remove(sal_Int32 nPos) @@ -1057,8 +1057,8 @@ EditPaM EditDoc::Clear() { maContents.clear(); -ContentNode* pNode = new ContentNode( GetItemPool() ); -Insert(0, pNode); +ContentNode* pNode = new ContentNode(GetItemPool()); +Insert(0, std::unique_ptr(pNode)); CreateDefFont(false); @@ -1100,8 +1100,8 @@ EditPaM EditDoc::RemoveText() maContents.clear(); -ContentNode* pNode = new ContentNode( GetItemPool() ); -Insert(0, pNode); +ContentNode* pNode = new ContentNode(GetItemPool()); +Insert(0, std::unique_ptr(pNode)); pNode->SetStyleSheet(pPrevStyle, false); pNode->GetContentAttribs().GetItems().Set( aPrevSet ); @@ -1109,7 +1109,7 @@ EditPaM EditDoc::RemoveText() SetModified(true); -return EditPaM( pNode, 0 ); +return EditPaM(pNode, 0); } EditPaM EditDoc::InsertText( EditPaM aPaM, std::u16string_view rStr ) @@ -1143,7 +1143,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs ) aContentAttribs.GetItems().Put( SfxBoolItem( EE_PARA_BULLETSTATE, true) ); // ContentNode constructor copies also the paragraph attributes -ContentNode* pNode = new ContentNode( aStr, std::move(aContentAttribs) ); +ContentNode* pNode = new ContentNode(aStr, std::move(aContentAttribs)); // Copy the Default Font pNode->GetCharAttribs().GetDefFont() = aPaM.GetNode()->GetCharAttribs().GetDefFont(); @@ -1161,7 +1161,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs ) // Character attributes may need to be copied or trimmed: pNode->CopyAndCutAttribs( aPaM.GetNode(), GetItemPool(), bKeepEndingAttribs ); -Insert(nPos+1, pNode); +Insert(nPos+1, std::unique_ptr(pNode)); SetModified(true); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index d3a62cb2b9de..b7a1aca97e2f 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -2218,8 +2218,8 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_Int32 n aSelection.Max().SetNode( pTmpPortion->GetNode() ); aSelection.Max().SetIndex( pTmpPortion->GetNode()->Len() ); -ContentNode* pN = pTmpPortion->GetNode(); -maEditDoc.Insert(nRealNewPos+i, pN); +ContentNode* pNode = pTmpPortion->GetNode(); +maEditDoc.Insert(nRealNewPos+i, std::unique_ptr(pNode)); GetParaPortions().Insert(nRealNewPos+i, std::move(pTmpPortion)); ++i; @@ -2998,7 +2998,7 @@ EditPaM ImpEditEngine::ImpFastInsertParagraph( sal_Int32 nPara ) if ( GetStatus().DoOnlineSpelling() ) pNode->CreateWrongList(); -maEditDoc.Insert(nPara, pNode); +maEditDoc.Insert(nPara, std::unique_ptr(pNode)); GetParaPortions().Insert(nPara, std::make_unique( pNode )); if
core.git: 2 commits - editeng/inc editeng/source
editeng/inc/ParagraphPortion.hxx | 26 +++--- editeng/inc/ParagraphPortionList.hxx |5 +- editeng/inc/editdoc.hxx | 60 ++-- editeng/source/editeng/editdoc.cxx | 64 +-- 4 files changed, 75 insertions(+), 80 deletions(-) New commits: commit 252c0316c3be09079e08afc9fa512ca5a60ea957 Author: Tomaž Vajngerl AuthorDate: Fri Dec 29 21:55:54 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Mon Jan 1 09:21:06 2024 +0100 editeng: prefix members of EditDoc Change-Id: I403db061b6e3e184e97c5ec3ce5746d2fdff0749 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161478 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 738c0b2d5772..7fc29556957c 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -104,20 +104,20 @@ public: class EditDoc { private: -mutable sal_Int32 nLastCache; -std::vector > maContents; +mutable sal_Int32 mnLastCache; +std::vector> maContents; -rtl::Reference pItemPool; -Link aModifyHdl; +rtl::Reference mpItemPool; +Link maModifyHdl; SvxFont maDefFont; //faster than ever from the pool!! -sal_uInt16 nDefTab; -boolbIsVertical:1; +sal_uInt16 mnDefTab; +boolmbIsVertical:1; TextRotationmnRotation; -boolbIsFixedCellHeight:1; +boolmbIsFixedCellHeight:1; -boolbModified:1; -boolbDisableAttributeExpanding:1; +boolmbModified:1; +boolmbDisableAttributeExpanding:1; public: EditDoc( SfxItemPool* pItemPool ); @@ -126,28 +126,44 @@ public: voiddumpAsXml(xmlTextWriterPtr pWriter) const; voidClearSpellErrors(); -boolIsModified() const { return bModified; } +boolIsModified() const { return mbModified; } voidSetModified( bool b ); -voidDisableAttributeExpanding() { bDisableAttributeExpanding = true; } +voidDisableAttributeExpanding() { mbDisableAttributeExpanding = true; } -voidSetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; } +voidSetModifyHdl(const Link& rLink) +{ +maModifyHdl = rLink; +} voidCreateDefFont( bool bUseStyles ); const SvxFont& GetDefFont() const { return maDefFont; } -voidSetDefTab( sal_uInt16 nTab ){ nDefTab = nTab ? nTab : DEFTAB; } -sal_uInt16 GetDefTab() const { return nDefTab; } +voidSetDefTab(sal_uInt16 nTab) +{ +mnDefTab = nTab ? nTab : DEFTAB; +} -voidSetVertical( bool bVertical ) { bIsVertical = bVertical; } +sal_uInt16 GetDefTab() const +{ +return mnDefTab; +} + +voidSetVertical( bool bVertical ) { mbIsVertical = bVertical; } boolIsEffectivelyVertical() const; boolIsTopToBottom() const; boolGetVertical() const; voidSetRotation( TextRotation nRotation ) { mnRotation = nRotation; } TextRotationGetRotation() const { return mnRotation; } -voidSetFixedCellHeight( bool bUseFixedCellHeight ) { bIsFixedCellHeight = bUseFixedCellHeight; } -boolIsFixedCellHeight() const { return bIsFixedCellHeight; } +voidSetFixedCellHeight( bool bUseFixedCellHeight ) +{ +mbIsFixedCellHeight = bUseFixedCellHeight; +} +boolIsFixedCellHeight() const +{ +return mbIsFixedCellHeight; +} EditPaM Clear(); EditPaM RemoveText(); @@ -166,8 +182,14 @@ public: EditPaM GetStartPaM() const; EditPaM GetEndPaM() const; -SfxItemPool&GetItemPool() { return *pItemPool; } -const SfxItemPool& GetItemPool() const { return *pItemPool; } +SfxItemPool&GetItemPool() +{ +return *mpItemPool; +} +const SfxItemPool& GetItemPool() const +{ +return *mpItemPool; +} voidInsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd ); voidInsertAttrib( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem ); diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index fdfd74edb09a..0afcc9cdd81c 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -790,14 +790,14 @@ void EditSelection::Adjust( const EditDoc& rNodes ) } EditDoc::EditDoc( SfxItemPool* pPool ) : -nLastCache(0), -pItemPool(pPool ? pPool : new EditEngineItemPool()), -
core.git: editeng/inc
editeng/inc/ParagraphPortionList.hxx | 60 +++ editeng/inc/editdoc.hxx | 33 --- 2 files changed, 61 insertions(+), 32 deletions(-) New commits: commit 275860e607c172825bc47f70eba5562e5a9208f4 Author: Tomaž Vajngerl AuthorDate: Fri Dec 29 20:58:40 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Mon Jan 1 04:34:28 2024 +0100 editeng: move ParaPortionList into its own header file Change-Id: Ibb1c9feb989a7dc3127e21c5a4dcda41b64fc84b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161476 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/ParagraphPortionList.hxx b/editeng/inc/ParagraphPortionList.hxx new file mode 100644 index ..8964c9767ba7 --- /dev/null +++ b/editeng/inc/ParagraphPortionList.hxx @@ -0,0 +1,60 @@ +/* -*- 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 "ParagraphPortion.hxx" + +#include + +class EditDoc; + +class ParaPortionList +{ +mutable sal_Int32 nLastCache; +std::vector> maPortions; + +public: +ParaPortionList(); +~ParaPortionList(); + +void Reset(); +tools::Long GetYOffset(const ParaPortion* pPPortion) const; +sal_Int32 FindParagraph(tools::Long nYOffset) const; + +const ParaPortion* SafeGetObject(sal_Int32 nPos) const; +ParaPortion* SafeGetObject(sal_Int32 nPos); + +sal_Int32 GetPos(const ParaPortion* p) const; +ParaPortion* operator[](sal_Int32 nPos); +const ParaPortion* operator[](sal_Int32 nPos) const; + +std::unique_ptr Release(sal_Int32 nPos); +void Remove(sal_Int32 nPos); +void Insert(sal_Int32 nPos, std::unique_ptr p); +void Append(std::unique_ptr p); +sal_Int32 Count() const; + +#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG +// temporary: +static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc); +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 1b93d52a6a88..738c0b2d5772 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -19,6 +19,7 @@ #pragma once +#include "ParagraphPortionList.hxx" #include "editattr.hxx" #include "edtspell.hxx" #include "eerdll2.hxx" @@ -37,7 +38,6 @@ #include "EditLineList.hxx" #include "EditPaM.hxx" #include "EditSelection.hxx" -#include "ParagraphPortion.hxx" #include #include @@ -82,37 +82,6 @@ enum class DeleteMode { Simple, RestOfWord, RestOfContent }; -class ParaPortionList -{ -mutable sal_Int32 nLastCache; -std::vector> maPortions; -public: -ParaPortionList(); -~ParaPortionList(); - -voidReset(); -tools::Long GetYOffset(const ParaPortion* pPPortion) const; -sal_Int32 FindParagraph(tools::Long nYOffset) const; - -const ParaPortion* SafeGetObject(sal_Int32 nPos) const; -ParaPortion* SafeGetObject(sal_Int32 nPos); - -sal_Int32 GetPos(const ParaPortion* p) const; -ParaPortion* operator[](sal_Int32 nPos); -const ParaPortion* operator[](sal_Int32 nPos) const; - -std::unique_ptr Release(sal_Int32 nPos); -void Remove(sal_Int32 nPos); -void Insert(sal_Int32 nPos, std::unique_ptr p); -void Append(std::unique_ptr p); -sal_Int32 Count() const; - -#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG -// temporary: -static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc); -#endif -}; - class DeletedNodeInfo { private:
core.git: 2 commits - editeng/inc editeng/Library_editeng.mk editeng/source solenv/clang-format
editeng/Library_editeng.mk |1 editeng/inc/ParagraphPortion.hxx | 133 + editeng/inc/TextPortionList.hxx| 32 +- editeng/inc/editdoc.hxx| 104 -- editeng/source/editeng/TextPortionList.cxx | 95 editeng/source/editeng/editdoc.cxx | 113 solenv/clang-format/excludelist|1 7 files changed, 254 insertions(+), 225 deletions(-) New commits: commit 916268c70a5673680c86eaac11c543fd45b90eb3 Author: Tomaž Vajngerl AuthorDate: Fri Dec 29 20:54:43 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Mon Jan 1 04:34:20 2024 +0100 editeng: move ParaPortion into its own header file Change-Id: I3fefe4a9fc5d391b1c3af335893a084eaeddba4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161475 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/ParagraphPortion.hxx b/editeng/inc/ParagraphPortion.hxx new file mode 100644 index ..93eb8356f611 --- /dev/null +++ b/editeng/inc/ParagraphPortion.hxx @@ -0,0 +1,133 @@ +/* -*- 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 "EditLineList.hxx" +#include "TextPortionList.hxx" + +struct ScriptTypePosInfo +{ +short nScriptType; +sal_Int32 nStartPos; +sal_Int32 nEndPos; + +ScriptTypePosInfo(short Type, sal_Int32 Start, sal_Int32 End) +: nScriptType(Type) +, nStartPos(Start) +, nEndPos(End) +{ +} +}; + +typedef std::vector ScriptTypePosInfos; + +struct WritingDirectionInfo +{ +sal_uInt8 nType; +sal_Int32 nStartPos; +sal_Int32 nEndPos; + +WritingDirectionInfo(sal_uInt8 Type, sal_Int32 Start, sal_Int32 End) +: nType(Type) +, nStartPos(Start) +, nEndPos(End) +{ +} +}; + +typedef std::vector WritingDirectionInfos; + +class ParaPortion +{ +friend class ImpEditEngine; // to adjust the height +private: +EditLineList aLineList; +TextPortionList aTextPortionList; +ContentNode* pNode; +tools::Long nHeight; + +ScriptTypePosInfos aScriptInfos; +WritingDirectionInfos aWritingDirectionInfos; + +sal_Int32 nInvalidPosStart; +sal_Int32 nFirstLineOffset; // For Writer-LineSpacing-Interpretation +sal_Int32 nBulletX; +sal_Int32 nInvalidDiff; + +bool bInvalid : 1; +bool bSimple : 1; // only linear Tap +bool bVisible : 1; // Belongs to the node! +bool bForceRepaint : 1; + +ParaPortion(const ParaPortion&) = delete; + +public: +ParaPortion(ContentNode* pNode); +~ParaPortion(); + +sal_Int32 GetLineNumber(sal_Int32 nIndex) const; + +EditLineList& GetLines() { return aLineList; } +const EditLineList& GetLines() const { return aLineList; } + +bool IsInvalid() const { return bInvalid; } +bool IsSimpleInvalid() const { return bSimple; } +void SetValid() +{ +bInvalid = false; +bSimple = true; +} + +bool MustRepaint() const { return bForceRepaint; } +void SetMustRepaint(bool bRP) { bForceRepaint = bRP; } + +sal_Int32 GetBulletX() const { return nBulletX; } +void SetBulletX(sal_Int32 n) { nBulletX = n; } + +void MarkInvalid(sal_Int32 nStart, sal_Int32 nDiff); +void MarkSelectionInvalid(sal_Int32 nStart); + +void SetVisible(bool bVisible); +bool IsVisible() const { return bVisible; } + +bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0].GetLen() == 0; } + +tools::Long GetHeight() const { return (bVisible ? nHeight : 0); } +sal_Int32 GetFirstLineOffset() const { return (bVisible ? nFirstLineOffset : 0); } +void ResetHeight() +{ +nHeight = 0; +nFirstLineOffset = 0; +} + +ContentNode* GetNode() const { return pNode; } +TextPortionList& GetTextPortions() { return aTextPortionList; } +const TextPortionList& GetTextPortions() const { return aTextPortionList; } + +sal_Int32 GetInvalidPosStart() const { return nInvalidPosStart; } +short GetInvalidDiff() const {
core.git: editeng/inc
editeng/inc/TextPortionList.hxx | 48 editeng/inc/editdoc.hxx | 25 2 files changed, 49 insertions(+), 24 deletions(-) New commits: commit e3267cadcaa8cfc64705e24bd484815469b8814f Author: Tomaž Vajngerl AuthorDate: Fri Dec 29 16:47:30 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Mon Jan 1 03:06:57 2024 +0100 editeng: move TextPortionList into its own header file Change-Id: I366706138f88c7865a7f1315af64bb4ab5b07ce3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161473 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/TextPortionList.hxx b/editeng/inc/TextPortionList.hxx new file mode 100644 index ..3e2272f4de9c --- /dev/null +++ b/editeng/inc/TextPortionList.hxx @@ -0,0 +1,48 @@ +/* -*- 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 "TextPortion.hxx" +#include + +class TextPortionList +{ +typedef std::vector> PortionsType; +PortionsType maPortions; + +public: +TextPortionList(); +~TextPortionList(); + +void Reset(); +sal_Int32 FindPortion(sal_Int32 nCharPos, sal_Int32& rPortionStart, + bool bPreferStartingPortion = false) const; +sal_Int32 GetStartPos(sal_Int32 nPortion); +void DeleteFromPortion(sal_Int32 nDelFrom); +sal_Int32 Count() const; +const TextPortion& operator[](sal_Int32 nPos) const; +TextPortion& operator[](sal_Int32 nPos); + +void Append(TextPortion* p); +void Insert(sal_Int32 nPos, TextPortion* p); +void Remove(sal_Int32 nPos); +sal_Int32 GetPos(const TextPortion* p) const; +}; +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index ee4f4433c307..f81eac050b76 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -31,6 +31,7 @@ #include #include #include "TextPortion.hxx" +#include "TextPortionList.hxx" #include "ItemList.hxx" #include "ContentNode.hxx" #include "EditLineList.hxx" @@ -113,30 +114,6 @@ enum class DeleteMode { Simple, RestOfWord, RestOfContent }; -class TextPortionList -{ -typedef std::vector > PortionsType; -PortionsType maPortions; - -public: -TextPortionList(); -~TextPortionList(); - -voidReset(); -sal_Int32 FindPortion( -sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false) const; -sal_Int32 GetStartPos(sal_Int32 nPortion); -void DeleteFromPortion(sal_Int32 nDelFrom); -sal_Int32 Count() const; -const TextPortion& operator[](sal_Int32 nPos) const; -TextPortion& operator[](sal_Int32 nPos); - -void Append(TextPortion* p); -void Insert(sal_Int32 nPos, TextPortion* p); -void Remove(sal_Int32 nPos); -sal_Int32 GetPos(const TextPortion* p) const; -}; - class ParaPortion { friend class ImpEditEngine; // to adjust the height
core.git: editeng/CppunitTest_editeng_core.mk editeng/inc editeng/qa editeng/source
editeng/CppunitTest_editeng_core.mk |1 editeng/inc/EditSelection.hxx | 25 - editeng/qa/unit/EditSelectionTest.cxx | 143 ++ editeng/source/editeng/editdoc.cxx| 23 - 4 files changed, 162 insertions(+), 30 deletions(-) New commits: commit 5b4dfce8933b1a2c18b9fc00d2b8a9a8ce37b510 Author: Tomaž Vajngerl AuthorDate: Wed Dec 27 14:31:53 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sun Dec 31 10:32:00 2023 +0100 editeng: cleanup operators and constructors for EditSelection + test Move the constructors into class body, cleanup operators so they use more standard class based operators and use default for != as it will just be a neagtion of ==. Change-Id: I1b99db6c9a82468ab76091eb93a5f3641024c65b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161365 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/CppunitTest_editeng_core.mk b/editeng/CppunitTest_editeng_core.mk index 47be49fbcd96..3fc6d9bde688 100644 --- a/editeng/CppunitTest_editeng_core.mk +++ b/editeng/CppunitTest_editeng_core.mk @@ -17,6 +17,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,editeng_core, \ editeng/qa/unit/EPaMTest \ editeng/qa/unit/EditLineTest \ editeng/qa/unit/EditPaMTest \ +editeng/qa/unit/EditSelectionTest \ )) $(eval $(call gb_CppunitTest_use_library_objects,editeng_core,editeng)) diff --git a/editeng/inc/EditSelection.hxx b/editeng/inc/EditSelection.hxx index c94fce2c0881..9d11a9685c30 100644 --- a/editeng/inc/EditSelection.hxx +++ b/editeng/inc/EditSelection.hxx @@ -28,10 +28,19 @@ private: EditPaM aEndPaM; public: -EditSelection(); +EditSelection() = default; -EditSelection(const EditPaM& rStartAndAnd); -EditSelection(const EditPaM& rStart, const EditPaM& rEnd); +EditSelection(const EditPaM& rStartAndEnd) +: aStartPaM(rStartAndEnd) +, aEndPaM(rStartAndEnd) +{ +} + +EditSelection(const EditPaM& rStart, const EditPaM& rEnd) +: aStartPaM(rStart) +, aEndPaM(rEnd) +{ +} EditPaM& Min() { return aStartPaM; } EditPaM& Max() { return aEndPaM; } @@ -45,12 +54,14 @@ public: void Adjust(const EditDoc& rNodes); -EditSelection& operator=(const EditPaM& r); -bool operator==(const EditSelection& r) const +EditSelection& operator=(const EditPaM& rPaM) { -return (aStartPaM == r.aStartPaM) && (aEndPaM == r.aEndPaM); +aStartPaM = rPaM; +aEndPaM = rPaM; +return *this; } -bool operator!=(const EditSelection& r) const { return !(r == *this); } + +bool operator==(const EditSelection& rOther) const = default; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/qa/unit/EditSelectionTest.cxx b/editeng/qa/unit/EditSelectionTest.cxx new file mode 100644 index ..b3308fbc2fa9 --- /dev/null +++ b/editeng/qa/unit/EditSelectionTest.cxx @@ -0,0 +1,143 @@ +/* -*- 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/. + */ + +#include +#include +#include + +namespace +{ +class EditSelectionTest : public test::BootstrapFixture +{ +protected: +rtl::Reference mpItemPool; + +public: +void setUp() override +{ +test::BootstrapFixture::setUp(); +mpItemPool = new EditEngineItemPool(); +} + +void tearDown() override +{ +mpItemPool.clear(); +test::BootstrapFixture::tearDown(); +} +}; + +CPPUNIT_TEST_FIXTURE(EditSelectionTest, testConstruction) +{ +// Check empty selections +EditSelection aEmpty; +CPPUNIT_ASSERT(aEmpty.Min().GetNode() == nullptr); +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aEmpty.Min().GetIndex()); + +CPPUNIT_ASSERT(aEmpty.Max().GetNode() == nullptr); +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aEmpty.Max().GetIndex()); + +// Create content nodes +ContentNode aContentNode1(*mpItemPool); +ContentNode* pContentNode1 = +ContentNode aContentNode2(*mpItemPool); +ContentNode* pContentNode2 = + +// Check selection with (node1 10, node1 20) +{ +EditSelection aNew(EditPaM(, 10), EditPaM(, 20)); + +CPPUNIT_ASSERT_EQUAL(true, aNew.Min().GetNode() == pContentNode1); +CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNew.Min().GetIndex()); + +CPPUNIT_ASSERT_EQUAL(true, aNew.Max().GetNode() == pContentNode1); +CPPUNIT_ASSERT_EQUAL(sal_Int32(20), aNew.Max().GetIndex()); +} + +// Check selection with (node1 10, node2 10) +{ +EditSelection aNew(EditPaM(, 10), EditPaM(, 10)); + +CPPUNIT_ASSERT_EQUAL(true, aNew.Min().GetNode() == pContentNode1); +
core.git: editeng/CppunitTest_editeng_core.mk editeng/inc editeng/qa editeng/source
editeng/CppunitTest_editeng_core.mk |1 editeng/inc/EditPaM.hxx | 18 +--- editeng/qa/unit/EditPaMTest.cxx | 74 editeng/source/editeng/editdoc.cxx | 20 - 4 files changed, 86 insertions(+), 27 deletions(-) New commits: commit ac481d5df48c9db1f662903af52a5dd50bbe66df Author: Tomaž Vajngerl AuthorDate: Mon Dec 25 00:41:53 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sun Dec 31 07:49:39 2023 +0100 editeng: cleanup operators and constructors for EditPaM + test Move the constructors into class body, cleanup operators so they use more standard class based operators and use default for != as it will just be a neagtion of ==. Change-Id: I6534db60dcb23cb3daefb91d5f27579a690a9637 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161364 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/CppunitTest_editeng_core.mk b/editeng/CppunitTest_editeng_core.mk index d28c7fcb4365..47be49fbcd96 100644 --- a/editeng/CppunitTest_editeng_core.mk +++ b/editeng/CppunitTest_editeng_core.mk @@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,editeng_core, \ editeng/qa/unit/ESelectionTest \ editeng/qa/unit/EPaMTest \ editeng/qa/unit/EditLineTest \ +editeng/qa/unit/EditPaMTest \ )) $(eval $(call gb_CppunitTest_use_library_objects,editeng_core,editeng)) diff --git a/editeng/inc/EditPaM.hxx b/editeng/inc/EditPaM.hxx index 2aa733f5ea74..9a33ad5a0990 100644 --- a/editeng/inc/EditPaM.hxx +++ b/editeng/inc/EditPaM.hxx @@ -26,24 +26,28 @@ class EditDoc; class EditPaM { private: -ContentNode* pNode; -sal_Int32 nIndex; +ContentNode* pNode = nullptr; +sal_Int32 nIndex = 0; public: -EditPaM(); -EditPaM(ContentNode* p, sal_Int32 n); +EditPaM() = default; +EditPaM(ContentNode* p, sal_Int32 n) +: pNode(p) +, nIndex(n) +{ +} const ContentNode* GetNode() const { return pNode; } ContentNode* GetNode() { return pNode; } -void SetNode(ContentNode* p); +void SetNode(ContentNode* p) { pNode = p; } sal_Int32 GetIndex() const { return nIndex; } void SetIndex(sal_Int32 n) { nIndex = n; } bool DbgIsBuggy(EditDoc const& rDoc) const; -friend bool operator==(const EditPaM& r1, const EditPaM& r2); -friend bool operator!=(const EditPaM& r1, const EditPaM& r2); +bool operator==(const EditPaM& rOther) const = default; + bool operator!() const { return !pNode && !nIndex; } }; diff --git a/editeng/qa/unit/EditPaMTest.cxx b/editeng/qa/unit/EditPaMTest.cxx new file mode 100644 index ..12f0fa9741c9 --- /dev/null +++ b/editeng/qa/unit/EditPaMTest.cxx @@ -0,0 +1,74 @@ +/* -*- 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/. + */ + +#include +#include +#include + +namespace +{ +class EditPaMTest : public test::BootstrapFixture +{ +protected: +rtl::Reference mpItemPool; + +public: +void setUp() override +{ +test::BootstrapFixture::setUp(); +mpItemPool = new EditEngineItemPool(); +} + +void tearDown() override +{ +mpItemPool.clear(); +test::BootstrapFixture::tearDown(); +} +}; + +CPPUNIT_TEST_FIXTURE(EditPaMTest, testConstruction) +{ +EditPaM aEmpty; +CPPUNIT_ASSERT(aEmpty.GetNode() == nullptr); +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aEmpty.GetIndex()); + +ContentNode aContentNode(*mpItemPool); +EditPaM aNew(, 10); + +CPPUNIT_ASSERT(aNew.GetNode() != nullptr); +CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNew.GetIndex()); +} + +CPPUNIT_TEST_FIXTURE(EditPaMTest, testEquals) +{ +ContentNode aContentNode(*mpItemPool); + +EditPaM aEditPaMEmpty1; +EditPaM aEditPaMEmpty2; + +CPPUNIT_ASSERT_EQUAL(true, aEditPaMEmpty1 == aEditPaMEmpty2); +CPPUNIT_ASSERT_EQUAL(false, aEditPaMEmpty1 != aEditPaMEmpty2); + +EditPaM aEditPaM1(, 10); + +CPPUNIT_ASSERT_EQUAL(false, aEditPaMEmpty1 == aEditPaM1); +CPPUNIT_ASSERT_EQUAL(true, aEditPaMEmpty1 != aEditPaM1); + +EditPaM aEditPaM2(, 15); +CPPUNIT_ASSERT_EQUAL(false, aEditPaM2 == aEditPaM1); +CPPUNIT_ASSERT_EQUAL(true, aEditPaM2 != aEditPaM1); + +EditPaM aEditPaM3(, 10); +CPPUNIT_ASSERT_EQUAL(true, aEditPaM3 == aEditPaM1); +CPPUNIT_ASSERT_EQUAL(false, aEditPaM3 != aEditPaM1); +} + +} // end anonymous namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 153cc25dfc1f..d61683619a84 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -890,15 +890,6 @@ void
core.git: 2 commits - editeng/inc
editeng/inc/EditPaM.hxx | 50 +++ editeng/inc/EditSelection.hxx | 56 +++ editeng/inc/editdoc.hxx | 60 +- 3 files changed, 108 insertions(+), 58 deletions(-) New commits: commit 5c1f9ec049a724071bd47bca2d76553c0dfb1718 Author: Tomaž Vajngerl AuthorDate: Mon Dec 25 00:16:25 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sun Dec 31 02:34:59 2023 +0100 editeng: move EditSelection into its own header file Change-Id: Ib56a0d308de700097470d26ebed3dc90d583b616 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161363 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/EditSelection.hxx b/editeng/inc/EditSelection.hxx new file mode 100644 index ..c94fce2c0881 --- /dev/null +++ b/editeng/inc/EditSelection.hxx @@ -0,0 +1,56 @@ +/* -*- 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 "EditPaM.hxx" + +class EditSelection +{ +private: +EditPaM aStartPaM; +EditPaM aEndPaM; + +public: +EditSelection(); + +EditSelection(const EditPaM& rStartAndAnd); +EditSelection(const EditPaM& rStart, const EditPaM& rEnd); + +EditPaM& Min() { return aStartPaM; } +EditPaM& Max() { return aEndPaM; } + +const EditPaM& Min() const { return aStartPaM; } +const EditPaM& Max() const { return aEndPaM; } + +bool HasRange() const { return aStartPaM != aEndPaM; } +bool IsInvalid() const { return !aStartPaM || !aEndPaM; } +bool DbgIsBuggy(EditDoc const& rDoc) const; + +void Adjust(const EditDoc& rNodes); + +EditSelection& operator=(const EditPaM& r); +bool operator==(const EditSelection& r) const +{ +return (aStartPaM == r.aStartPaM) && (aEndPaM == r.aEndPaM); +} +bool operator!=(const EditSelection& r) const { return !(r == *this); } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 6bba498440f6..ee4f4433c307 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -35,6 +35,7 @@ #include "ContentNode.hxx" #include "EditLineList.hxx" #include "EditPaM.hxx" +#include "EditSelection.hxx" #include #include @@ -237,40 +238,6 @@ public: #endif }; - - -class EditSelection -{ -private: -EditPaM aStartPaM; -EditPaM aEndPaM; - -public: -EditSelection();// No constructor and destructor -// are automatically executed correctly! -EditSelection( const EditPaM& rStartAndAnd ); -EditSelection( const EditPaM& rStart, const EditPaM& rEnd ); - -EditPaM&Min() { return aStartPaM; } -EditPaM&Max() { return aEndPaM; } - -const EditPaM& Min() const { return aStartPaM; } -const EditPaM& Max() const { return aEndPaM; } - -boolHasRange() const{ return aStartPaM != aEndPaM; } -boolIsInvalid() const { return !aStartPaM || !aEndPaM; } -boolDbgIsBuggy( EditDoc const & rDoc ) const; - -voidAdjust( const EditDoc& rNodes ); - -EditSelection& operator = ( const EditPaM& r ); -booloperator == ( const EditSelection& r ) const -{ return ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ); } -booloperator != ( const EditSelection& r ) const { return !( r == *this ); } -}; - - - class DeletedNodeInfo { private: commit 291fe245284806538d74b40d45dfa20b3fbab172 Author: Tomaž Vajngerl AuthorDate: Mon Dec 25 00:14:00 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sun Dec 31 02:34:52 2023 +0100 editeng: move EditPaM into its own header file Change-Id: I13c5d4f2ea0bd7ef942ac0cacb9dce4b58909b19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161362 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/EditPaM.hxx b/editeng/inc/EditPaM.hxx new
core.git: editeng/inc editeng/source
editeng/inc/EditLineList.hxx | 53 +++--- editeng/inc/editdoc.hxx|1 editeng/source/editeng/editdoc.cxx | 64 - 3 files changed, 41 insertions(+), 77 deletions(-) New commits: commit 020444ed98d7a31403787238cd753e112a6a56fb Author: Tomaž Vajngerl AuthorDate: Mon Dec 25 00:06:07 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Dec 30 14:17:16 2023 +0100 editeng: move EditLineList methods definition into header Class is simple enough and more or less just wraps the vector anyway. Change-Id: I65a2980e8dd3c70b87e617920db623782d43b1b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161361 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/EditLineList.hxx b/editeng/inc/EditLineList.hxx index 2b3874913cad..a3a547d7ce24 100644 --- a/editeng/inc/EditLineList.hxx +++ b/editeng/inc/EditLineList.hxx @@ -19,8 +19,12 @@ #pragma once +#include "EditLine.hxx" + +#include #include #include +#include class EditLineList { @@ -28,18 +32,43 @@ class EditLineList LinesType maLines; public: -EditLineList(); -~EditLineList(); - -void Reset(); -void DeleteFromLine(sal_Int32 nDelFrom); -sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd); -sal_Int32 Count() const; -const EditLine& operator[](sal_Int32 nPos) const; -EditLine& operator[](sal_Int32 nPos); - -void Append(EditLine* p); -void Insert(sal_Int32 nPos, EditLine* p); +EditLineList() = default; + +void Reset() { maLines.clear(); } + +void DeleteFromLine(sal_Int32 nDelFrom) +{ +assert(nDelFrom <= (static_cast(maLines.size()) - 1)); +LinesType::iterator it = maLines.begin(); +std::advance(it, nDelFrom); +maLines.erase(it, maLines.end()); +} + +sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd) +{ +sal_Int32 n = maLines.size(); +for (sal_Int32 i = 0; i < n; ++i) +{ +const EditLine& rLine = *maLines[i]; +if ((bInclEnd && (rLine.GetEnd() >= nChar)) || (rLine.GetEnd() > nChar)) +{ +return i; +} +} + +DBG_ASSERT(!bInclEnd, "Line not found: FindLine"); +return n - 1; +} + +sal_Int32 Count() const { return maLines.size(); } +const EditLine& operator[](sal_Int32 nPos) const { return *maLines[nPos]; } +EditLine& operator[](sal_Int32 nPos) { return *maLines[nPos]; } + +void Append(EditLine* p) { maLines.push_back(std::unique_ptr(p)); } +void Insert(sal_Int32 nPos, EditLine* p) +{ +maLines.insert(maLines.begin() + nPos, std::unique_ptr(p)); +} }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 3db8a8a64a63..e400a3b42e4a 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -33,7 +33,6 @@ #include "TextPortion.hxx" #include "ItemList.hxx" #include "ContentNode.hxx" -#include "EditLine.hxx" #include "EditLineList.hxx" #include diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index e37bc47a7fa3..153cc25dfc1f 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -890,70 +890,6 @@ void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const Map } } -EditLineList::EditLineList() -{ -} - -EditLineList::~EditLineList() -{ -Reset(); -} - -void EditLineList::Reset() -{ -maLines.clear(); -} - -void EditLineList::DeleteFromLine(sal_Int32 nDelFrom) -{ -assert(nDelFrom <= (static_cast(maLines.size()) - 1)); -LinesType::iterator it = maLines.begin(); -std::advance(it, nDelFrom); -maLines.erase(it, maLines.end()); -} - -sal_Int32 EditLineList::FindLine(sal_Int32 nChar, bool bInclEnd) -{ -sal_Int32 n = maLines.size(); -for (sal_Int32 i = 0; i < n; ++i) -{ -const EditLine& rLine = *maLines[i]; -if ( (bInclEnd && (rLine.GetEnd() >= nChar)) || - (rLine.GetEnd() > nChar) ) -{ -return i; -} -} - -DBG_ASSERT( !bInclEnd, "Line not found: FindLine" ); -return n - 1; -} - -sal_Int32 EditLineList::Count() const -{ -return maLines.size(); -} - -const EditLine& EditLineList::operator[](sal_Int32 nPos) const -{ -return *maLines[nPos]; -} - -EditLine& EditLineList::operator[](sal_Int32 nPos) -{ -return *maLines[nPos]; -} - -void EditLineList::Append(EditLine* p) -{ -maLines.push_back(std::unique_ptr(p)); -} - -void EditLineList::Insert(sal_Int32 nPos, EditLine* p) -{ -maLines.insert(maLines.begin()+nPos, std::unique_ptr(p)); -} - EditPaM::EditPaM() : pNode(nullptr), nIndex(0) {} EditPaM::EditPaM(ContentNode* p, sal_Int32 n) : pNode(p), nIndex(n) {}
core.git: 2 commits - editeng/inc editeng/Library_editeng.mk editeng/source solenv/clang-format
editeng/Library_editeng.mk |1 editeng/inc/EditLine.hxx|4 + editeng/inc/EditLineList.hxx| 45 ++ editeng/inc/editdoc.hxx | 23 - editeng/source/editeng/EditLine.cxx | 90 editeng/source/editeng/editdoc.cxx | 66 -- solenv/clang-format/excludelist |1 7 files changed, 142 insertions(+), 88 deletions(-) New commits: commit 4acb0979b10bf35cf929078e53ea249e1416 Author: Tomaž Vajngerl AuthorDate: Sun Dec 24 23:55:58 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Dec 30 14:17:08 2023 +0100 editeng: move EditLineList to its own header file Change-Id: Ic19aa0826050a768e9976d8d3db9eadb108607f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161360 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/EditLineList.hxx b/editeng/inc/EditLineList.hxx new file mode 100644 index ..2b3874913cad --- /dev/null +++ b/editeng/inc/EditLineList.hxx @@ -0,0 +1,45 @@ +/* -*- 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 +#include + +class EditLineList +{ +typedef std::vector> LinesType; +LinesType maLines; + +public: +EditLineList(); +~EditLineList(); + +void Reset(); +void DeleteFromLine(sal_Int32 nDelFrom); +sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd); +sal_Int32 Count() const; +const EditLine& operator[](sal_Int32 nPos) const; +EditLine& operator[](sal_Int32 nPos); + +void Append(EditLine* p); +void Insert(sal_Int32 nPos, EditLine* p); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index c53abc62949c..3db8a8a64a63 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -34,6 +34,7 @@ #include "ItemList.hxx" #include "ContentNode.hxx" #include "EditLine.hxx" +#include "EditLineList.hxx" #include #include @@ -159,28 +160,6 @@ public: sal_Int32 GetPos(const TextPortion* p) const; }; -class EditLineList -{ -typedef std::vector > LinesType; -LinesType maLines; - -public: -EditLineList(); -~EditLineList(); - -void Reset(); -void DeleteFromLine(sal_Int32 nDelFrom); -sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd); -sal_Int32 Count() const; -const EditLine& operator[](sal_Int32 nPos) const; -EditLine& operator[](sal_Int32 nPos); - -void Append(EditLine* p); -void Insert(sal_Int32 nPos, EditLine* p); -}; - - - class ParaPortion { friend class ImpEditEngine; // to adjust the height commit 9a62dcf59af3513a82fb5640314021d064d8b9b7 Author: Tomaž Vajngerl AuthorDate: Sun Dec 24 22:45:54 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Dec 30 14:16:59 2023 +0100 editeng: move impl. of EditLine methods to own cxx sourcefile Change-Id: I9856302967de59368dc60b3e01f4a36fdb97e00e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161359 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk index e0834b96f983..49225b910d14 100644 --- a/editeng/Library_editeng.mk +++ b/editeng/Library_editeng.mk @@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\ editeng/source/editeng/editdbg \ editeng/source/editeng/editdoc \ editeng/source/editeng/editeng \ +editeng/source/editeng/EditLine \ editeng/source/editeng/editobj \ editeng/source/editeng/editsel \ editeng/source/editeng/editundo \ diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx index df1dec9f0ae2..165f3fcf0a59 100644 --- a/editeng/inc/EditLine.hxx +++ b/editeng/inc/EditLine.hxx @@ -19,6 +19,10 @@ #pragma once +#include +#include +#include + class ParaPortion; class EditLine diff --git a/editeng/source/editeng/EditLine.cxx b/editeng/source/editeng/EditLine.cxx new file mode 100644 index ..7724f8f12a79 --- /dev/null +++ b/editeng/source/editeng/EditLine.cxx @@
core.git: editeng/CppunitTest_editeng_core.mk editeng/inc editeng/qa editeng/source
editeng/CppunitTest_editeng_core.mk |1 editeng/inc/EditLine.hxx| 58 +- editeng/qa/unit/EditLineTest.cxx| 111 editeng/source/editeng/editdoc.cxx | 63 4 files changed, 154 insertions(+), 79 deletions(-) New commits: commit 72fde57386eb7b53f4b1a0954a1595e36cf17e5f Author: Tomaž Vajngerl AuthorDate: Sun Dec 24 22:34:40 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Dec 30 14:16:43 2023 +0100 editeng: EditLine test and refactor constructors, operators Change-Id: Ia60ce07073725bf66bf299edaf7b3cd24cfe59c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161358 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/CppunitTest_editeng_core.mk b/editeng/CppunitTest_editeng_core.mk index 43df48cbe38a..d28c7fcb4365 100644 --- a/editeng/CppunitTest_editeng_core.mk +++ b/editeng/CppunitTest_editeng_core.mk @@ -15,6 +15,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,editeng_core, \ editeng/qa/unit/core-test \ editeng/qa/unit/ESelectionTest \ editeng/qa/unit/EPaMTest \ +editeng/qa/unit/EditLineTest \ )) $(eval $(call gb_CppunitTest_use_library_objects,editeng_core,editeng)) diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx index 2b6bc2a71efb..df1dec9f0ae2 100644 --- a/editeng/inc/EditLine.hxx +++ b/editeng/inc/EditLine.hxx @@ -29,22 +29,29 @@ public: private: CharPosArrayType aPositions; std::vector aKashidaPositions; -sal_Int32 nTxtWidth; -sal_Int32 nStartPosX; -sal_Int32 nStart; // could be replaced by nStartPortion -sal_Int32 nEnd; // could be replaced by nEndPortion -sal_Int32 nStartPortion; -sal_Int32 nEndPortion; -sal_uInt16 nHeight; // Total height of the line -sal_uInt16 nTxtHeight; // Pure Text height -sal_uInt16 nMaxAscent; -bool bHangingPunctuation : 1; -bool bInvalid : 1; // for skillful formatting +sal_Int32 nTxtWidth = 0; +sal_Int32 nStartPosX = 0; +sal_Int32 nStart = 0; // could be replaced by nStartPortion +sal_Int32 nEnd = 0; // could be replaced by nEndPortion +sal_Int32 nStartPortion = 0; +sal_Int32 nEndPortion = 0; +sal_uInt16 nHeight = 0; // Total height of the line +sal_uInt16 nTxtHeight = 0; // Pure Text height +sal_uInt16 nMaxAscent = 0; +bool bHangingPunctuation : 1 = false; +bool bInvalid : 1 = true; // for skillful formatting public: -EditLine(); -EditLine(const EditLine&); -~EditLine(); +EditLine() = default; +EditLine(const EditLine& rEditLine) +: nStart(rEditLine.nStart) +, nEnd(rEditLine.nEnd) +, nStartPortion(rEditLine.nStartPortion) +, nEndPortion(rEditLine.nEndPortion) +, bHangingPunctuation(rEditLine.bHangingPunctuation) +, bInvalid(true) +{ +} bool IsIn(sal_Int32 nIndex) const { return ((nIndex >= nStart) && (nIndex < nEnd)); } @@ -103,8 +110,27 @@ public: EditLine* Clone() const; -EditLine& operator=(const EditLine& rLine); -friend bool operator==(const EditLine& r1, const EditLine& r2); +EditLine& operator=(const EditLine& rLine) +{ +nEnd = rLine.nEnd; +nStart = rLine.nStart; +nEndPortion = rLine.nEndPortion; +nStartPortion = rLine.nStartPortion; +return *this; +} + +bool operator==(const EditLine& rLine) const +{ +return nStart == rLine.nStart && nEnd == rLine.nEnd && nStartPortion == rLine.nStartPortion + && nEndPortion == rLine.nEndPortion; +} }; +template +inline std::basic_ostream& operator<<(std::basic_ostream& stream, + EditLine const& rLine) +{ +return stream << "EditLine(" << rLine.GetStart() << ", " << rLine.GetEnd() << ")"; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/qa/unit/EditLineTest.cxx b/editeng/qa/unit/EditLineTest.cxx new file mode 100644 index ..6991ba67755c --- /dev/null +++ b/editeng/qa/unit/EditLineTest.cxx @@ -0,0 +1,111 @@ +/* -*- 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/. + */ + +#include +#include + +namespace +{ +class EditLineTest : public test::BootstrapFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(EditLineTest, testConstruction) +{ +EditLine aNew; +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetStart()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetEnd()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetStartPortion()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetEndPortion()); +CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), aNew.GetMaxAscent()); +
core.git: editeng/inc
editeng/inc/EditLine.hxx | 110 +++ editeng/inc/editdoc.hxx | 92 --- 2 files changed, 111 insertions(+), 91 deletions(-) New commits: commit 2ffe4a6580a17d178794fabeba6916c1ff4c744c Author: Tomaž Vajngerl AuthorDate: Sun Dec 24 16:46:16 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Dec 30 03:09:49 2023 +0100 editeng: move EditLine in its own header file Change-Id: I21cac4a8899f96da420428c4eb110078c740615a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161357 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx new file mode 100644 index ..2b6bc2a71efb --- /dev/null +++ b/editeng/inc/EditLine.hxx @@ -0,0 +1,110 @@ +/* -*- 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 + +class ParaPortion; + +class EditLine +{ +public: +typedef std::vector CharPosArrayType; + +private: +CharPosArrayType aPositions; +std::vector aKashidaPositions; +sal_Int32 nTxtWidth; +sal_Int32 nStartPosX; +sal_Int32 nStart; // could be replaced by nStartPortion +sal_Int32 nEnd; // could be replaced by nEndPortion +sal_Int32 nStartPortion; +sal_Int32 nEndPortion; +sal_uInt16 nHeight; // Total height of the line +sal_uInt16 nTxtHeight; // Pure Text height +sal_uInt16 nMaxAscent; +bool bHangingPunctuation : 1; +bool bInvalid : 1; // for skillful formatting + +public: +EditLine(); +EditLine(const EditLine&); +~EditLine(); + +bool IsIn(sal_Int32 nIndex) const { return ((nIndex >= nStart) && (nIndex < nEnd)); } + +bool IsIn(sal_Int32 nIndex, bool bInclEnd) const +{ +return ((nIndex >= nStart) && (bInclEnd ? (nIndex <= nEnd) : (nIndex < nEnd))); +} + +void SetStart(sal_Int32 n) { nStart = n; } +sal_Int32 GetStart() const { return nStart; } +sal_Int32& GetStart() { return nStart; } + +void SetEnd(sal_Int32 n) { nEnd = n; } +sal_Int32 GetEnd() const { return nEnd; } +sal_Int32& GetEnd() { return nEnd; } + +void SetStartPortion(sal_Int32 n) { nStartPortion = n; } +sal_Int32 GetStartPortion() const { return nStartPortion; } +sal_Int32& GetStartPortion() { return nStartPortion; } + +void SetEndPortion(sal_Int32 n) { nEndPortion = n; } +sal_Int32 GetEndPortion() const { return nEndPortion; } +sal_Int32& GetEndPortion() { return nEndPortion; } + +void SetHeight(sal_uInt16 nH, sal_uInt16 nTxtH = 0); +sal_uInt16 GetHeight() const { return nHeight; } +sal_uInt16 GetTxtHeight() const { return nTxtHeight; } + +void SetTextWidth(sal_Int32 n) { nTxtWidth = n; } +sal_Int32 GetTextWidth() const { return nTxtWidth; } + +void SetMaxAscent(sal_uInt16 n) { nMaxAscent = n; } +sal_uInt16 GetMaxAscent() const { return nMaxAscent; } + +void SetHangingPunctuation(bool b) { bHangingPunctuation = b; } +bool IsHangingPunctuation() const { return bHangingPunctuation; } + +sal_Int32 GetLen() const { return nEnd - nStart; } + +sal_Int32 GetStartPosX() const { return nStartPosX; } +void SetStartPosX(sal_Int32 start); +Size CalcTextSize(ParaPortion& rParaPortion); + +bool IsInvalid() const { return bInvalid; } +bool IsValid() const { return !bInvalid; } +void SetInvalid() { bInvalid = true; } +void SetValid() { bInvalid = false; } + +bool IsEmpty() const { return nEnd <= nStart; } + +CharPosArrayType& GetCharPosArray() { return aPositions; } +const CharPosArrayType& GetCharPosArray() const { return aPositions; } + +std::vector& GetKashidaArray() { return aKashidaPositions; } +const std::vector& GetKashidaArray() const { return aKashidaPositions; } + +EditLine* Clone() const; + +EditLine& operator=(const EditLine& rLine); +friend bool operator==(const EditLine& r1, const EditLine& r2); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 9840d1ff8337..c53abc62949c 100644 --- a/editeng/inc/editdoc.hxx +++
core.git: 2 commits - editeng/inc editeng/Library_editeng.mk editeng/source solenv/clang-format
editeng/Library_editeng.mk |1 editeng/inc/ContentNode.hxx|9 editeng/source/editeng/ContentNode.cxx | 1000 + editeng/source/editeng/editdoc.cxx | 984 solenv/clang-format/excludelist|1 5 files changed, 1005 insertions(+), 990 deletions(-) New commits: commit 5c198a8d1345a5f658a46085de9cdd76d49a959e Author: Tomaž Vajngerl AuthorDate: Sun Dec 24 16:37:58 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 29 12:38:11 2023 +0100 editeng: simplify and remove unneded const. of ContentNode & co ContentNode, CharAttribList, ContentAttribs constructors and destructors can be simplified and in some cases removed (if they are empty). Change-Id: Id5b1d4c1934a9b0b6e0ed8a7fe2af0d41ce4b4fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161356 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/ContentNode.hxx b/editeng/inc/ContentNode.hxx index d89612ddeac8..391953d7f4ae 100644 --- a/editeng/inc/ContentNode.hxx +++ b/editeng/inc/ContentNode.hxx @@ -37,7 +37,7 @@ class SvxTabStop; class ContentAttribs { private: -SfxStyleSheet* mpStyle; +SfxStyleSheet* mpStyle = nullptr; SfxItemSetFixed maAttribSet; public: @@ -68,12 +68,9 @@ public: private: AttribsType maAttribs; SvxFont maDefFont; // faster than ever from the pool! -bool mbHasEmptyAttribs; +bool mbHasEmptyAttribs = false; public: -CharAttribList(); -~CharAttribList(); - void dumpAsXml(xmlTextWriterPtr pWriter) const; void DeleteEmptyAttribs(); @@ -122,7 +119,7 @@ private: public: ContentNode(SfxItemPool& rItemPool); ContentNode(const OUString& rStr, const ContentAttribs& rContentAttribs); -~ContentNode(); + ContentNode(const ContentNode&) = delete; ContentNode& operator=(const ContentNode&) = delete; diff --git a/editeng/source/editeng/ContentNode.cxx b/editeng/source/editeng/ContentNode.cxx index 16d6a1ed808b..0cc3a72da65c 100644 --- a/editeng/source/editeng/ContentNode.cxx +++ b/editeng/source/editeng/ContentNode.cxx @@ -40,10 +40,6 @@ ContentNode::ContentNode( const OUString& rStr, const ContentAttribs& rContentAt { } -ContentNode::~ContentNode() -{ -} - void ContentNode::ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNew ) { if ( !nNew ) @@ -653,12 +649,10 @@ void ContentNode::checkAndDeleteEmptyAttribs() const } ContentAttribs::ContentAttribs( SfxItemPool& rPool ) -: mpStyle(nullptr) -, maAttribSet( rPool ) +: maAttribSet(rPool) { } - SvxTabStop ContentAttribs::FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab ) { const SvxTabStopItem& rTabs = GetItem( EE_PARA_TABS ); @@ -741,15 +735,6 @@ struct LessByStart } -CharAttribList::CharAttribList() -: mbHasEmptyAttribs(false) -{ -} - -CharAttribList::~CharAttribList() -{ -} - void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib ) { // ! commit 62aee46df1f8e4b863e2927e0b9d3b6bcd270008 Author: Tomaž Vajngerl AuthorDate: Sun Dec 24 16:33:46 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 29 12:38:04 2023 +0100 editeng: move source of ContentNode & co. to own sourcefile Move ContentNode, CharAttribList, ContentAttribs methods to own source class. Change-Id: Idd1371430ecaf36431de763dc4e3e3978ba60641 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161355 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk index 7f7f3581b62f..e0834b96f983 100644 --- a/editeng/Library_editeng.mk +++ b/editeng/Library_editeng.mk @@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\ endif $(eval $(call gb_Library_add_exception_objects,editeng,\ +editeng/source/editeng/ContentNode \ editeng/source/editeng/editattr \ editeng/source/editeng/editdata \ editeng/source/editeng/editdbg \ diff --git a/editeng/source/editeng/ContentNode.cxx b/editeng/source/editeng/ContentNode.cxx new file mode 100644 index ..16d6a1ed808b --- /dev/null +++ b/editeng/source/editeng/ContentNode.cxx @@ -0,0 +1,1015 @@ +/* -*- 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
core.git: 2 commits - editeng/inc editeng/source
editeng/inc/ContentNode.hxx| 179 + editeng/inc/editdoc.hxx| 152 --- editeng/source/editeng/editdoc.cxx | 172 +-- 3 files changed, 267 insertions(+), 236 deletions(-) New commits: commit beb2b1d6b1b23e941d1a6a34dc68a16ec7167c1b Author: Tomaž Vajngerl AuthorDate: Sat Dec 23 20:09:42 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 29 07:29:42 2023 +0100 editeng: prefix members of ContentNode, CharAttribList, ContentAttribs Change-Id: I2af96b6525ee0d4410200775ce4daf71bcc80db4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161354 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/ContentNode.hxx b/editeng/inc/ContentNode.hxx index 1d44e3469a36..d89612ddeac8 100644 --- a/editeng/inc/ContentNode.hxx +++ b/editeng/inc/ContentNode.hxx @@ -37,8 +37,8 @@ class SvxTabStop; class ContentAttribs { private: -SfxStyleSheet* pStyle; -SfxItemSetFixed aAttribSet; +SfxStyleSheet* mpStyle; +SfxItemSetFixed maAttribSet; public: ContentAttribs(SfxItemPool& rItemPool); @@ -46,10 +46,10 @@ public: void dumpAsXml(xmlTextWriterPtr pWriter) const; SvxTabStop FindTabStop(sal_Int32 nCurPos, sal_uInt16 nDefTab); -SfxItemSet& GetItems() { return aAttribSet; } -const SfxItemSet& GetItems() const { return aAttribSet; } -const SfxStyleSheet* GetStyleSheet() const { return pStyle; } -SfxStyleSheet* GetStyleSheet() { return pStyle; } +SfxItemSet& GetItems() { return maAttribSet; } +const SfxItemSet& GetItems() const { return maAttribSet; } +const SfxStyleSheet* GetStyleSheet() const { return mpStyle; } +SfxStyleSheet* GetStyleSheet() { return mpStyle; } void SetStyleSheet(SfxStyleSheet* pS); const SfxPoolItem& GetItem(sal_uInt16 nWhich) const; @@ -66,9 +66,9 @@ public: typedef std::vector> AttribsType; private: -AttribsType aAttribs; -SvxFont aDefFont; // faster than ever from the pool! -bool bHasEmptyAttribs; +AttribsType maAttribs; +SvxFont maDefFont; // faster than ever from the pool! +bool mbHasEmptyAttribs; public: CharAttribList(); @@ -91,15 +91,15 @@ public: void InsertAttrib(EditCharAttrib* pAttrib); -SvxFont& GetDefFont() { return aDefFont; } +SvxFont& GetDefFont() { return maDefFont; } -bool HasEmptyAttribs() const { return bHasEmptyAttribs; } +bool HasEmptyAttribs() const { return mbHasEmptyAttribs; } void SetHasEmptyAttribs(bool b); bool HasBoundingAttrib(sal_Int32 nBound) const; bool HasAttrib(sal_Int32 nStartPos, sal_Int32 nEndPos) const; -AttribsType& GetAttribs() { return aAttribs; } -const AttribsType& GetAttribs() const { return aAttribs; } +AttribsType& GetAttribs() { return maAttribs; } +const AttribsType& GetAttribs() const { return maAttribs; } void Remove(const EditCharAttrib* p); void Remove(sal_Int32 nPos); @@ -113,8 +113,8 @@ class ContentNode { private: OUString maString; -ContentAttribs aContentAttribs; -CharAttribList aCharAttribList; +ContentAttribs maContentAttribs; +CharAttribList maCharAttribList; std::unique_ptr mpWrongList; void UnExpandPosition(sal_Int32& rStartPos, bool bBiasStart); @@ -128,10 +128,10 @@ public: void dumpAsXml(xmlTextWriterPtr pWriter) const; -ContentAttribs& GetContentAttribs() { return aContentAttribs; } -const ContentAttribs& GetContentAttribs() const { return aContentAttribs; } -CharAttribList& GetCharAttribs() { return aCharAttribList; } -const CharAttribList& GetCharAttribs() const { return aCharAttribList; } +ContentAttribs& GetContentAttribs() { return maContentAttribs; } +const ContentAttribs& GetContentAttribs() const { return maContentAttribs; } +CharAttribList& GetCharAttribs() { return maCharAttribList; } +const CharAttribList& GetCharAttribs() const { return maCharAttribList; } void ExpandAttribs(sal_Int32 nIndex, sal_Int32 nNewChars); void CollapseAttribs(sal_Int32 nIndex, sal_Int32 nDelChars); @@ -140,7 +140,7 @@ public: void SetStyleSheet(SfxStyleSheet* pS, bool bRecalcFont = true); void SetStyleSheet(SfxStyleSheet* pS, const SvxFont& rFontFromStyle); -SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); } +SfxStyleSheet* GetStyleSheet() { return maContentAttribs.GetStyleSheet(); } void CreateDefFont(); diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index b28773e71977..8bac8f2cf67b 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1164,12 +1164,14 @@ bool operator != ( const EditPaM& r1, const EditPaM& r2 ) return !( r1 == r2 ); } -ContentNode::ContentNode( SfxItemPool& rPool ) : aContentAttribs( rPool ) +ContentNode::ContentNode( SfxItemPool& rPool ) +:
core.git: editeng/inc editeng/source
editeng/inc/ItemList.hxx | 53 - editeng/source/editeng/editdoc.cxx | 28 --- 2 files changed, 29 insertions(+), 52 deletions(-) New commits: commit 985b6c4a7fd00d1859ce3a32ab141d94526e989c Author: Tomaž Vajngerl AuthorDate: Fri Dec 22 20:24:37 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 29 07:29:12 2023 +0100 editeng: ItemList - prefix members, move methods in class - Move methods into class def. as the class is simple enough. - Prefix member variables. - Remove unneeded includes. Change-Id: Ide567c64dad3606f1a9faf837571ae2a5c3d69ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161352 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/ItemList.hxx b/editeng/inc/ItemList.hxx index 29c2b0dcddd2..a060fc6e29e7 100644 --- a/editeng/inc/ItemList.hxx +++ b/editeng/inc/ItemList.hxx @@ -19,38 +19,43 @@ #pragma once -#include "editattr.hxx" -#include "edtspell.hxx" -#include "eerdll2.hxx" -#include -#include -#include -#include #include -#include -#include -#include -#include "TextPortion.hxx" - -#include -#include -#include #include class ItemList { private: -typedef std::vector DummyItemList; -DummyItemList aItemPool; -sal_Int32 CurrentItem; +std::vector maItemPool; +sal_Int32 maCurrentItem = 0; public: -ItemList(); -const SfxPoolItem* First(); -const SfxPoolItem* Next(); -sal_Int32 Count() const { return aItemPool.size(); }; -void Insert(const SfxPoolItem* pItem); -void Clear() { aItemPool.clear(); }; +ItemList() = default; + +const SfxPoolItem* First() +{ +maCurrentItem = 0; +return maItemPool.empty() ? nullptr : maItemPool[0]; +} + +const SfxPoolItem* Next() +{ +if (maCurrentItem + 1 < sal_Int32(maItemPool.size())) +{ +++maCurrentItem; +return maItemPool[maCurrentItem]; +} +return nullptr; +} + +sal_Int32 Count() const { return maItemPool.size(); } + +void Insert(const SfxPoolItem* pItem) +{ +maItemPool.push_back(pItem); +maCurrentItem = maItemPool.size() - 1; +} + +void Clear() { maItemPool.clear(); } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 0856a594f7ae..b28773e71977 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1862,34 +1862,6 @@ void ContentAttribs::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterEndElement(pWriter); } - -ItemList::ItemList() : CurrentItem( 0 ) -{ -} - -const SfxPoolItem* ItemList::First() -{ -CurrentItem = 0; -return aItemPool.empty() ? nullptr : aItemPool[ 0 ]; -} - -const SfxPoolItem* ItemList::Next() -{ -if ( CurrentItem + 1 < static_cast(aItemPool.size()) ) -{ -++CurrentItem; -return aItemPool[ CurrentItem ]; -} -return nullptr; -} - -void ItemList::Insert( const SfxPoolItem* pItem ) -{ -aItemPool.push_back( pItem ); -CurrentItem = aItemPool.size() - 1; -} - - EditDoc::EditDoc( SfxItemPool* pPool ) : nLastCache(0), pItemPool(pPool ? pPool : new EditEngineItemPool()),
core.git: editeng/inc
editeng/inc/ItemList.hxx | 56 +++ editeng/inc/editdoc.hxx | 24 2 files changed, 57 insertions(+), 23 deletions(-) New commits: commit 27afa3fa1321bc55d6063115c4ad3558d68eb76e Author: Tomaž Vajngerl AuthorDate: Fri Dec 22 20:16:14 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 29 07:28:31 2023 +0100 editeng: move ItemList in its own header file Change-Id: I52f3f2a557db7058aa584ca7c1cee08eae58d726 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161351 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/ItemList.hxx b/editeng/inc/ItemList.hxx new file mode 100644 index ..29c2b0dcddd2 --- /dev/null +++ b/editeng/inc/ItemList.hxx @@ -0,0 +1,56 @@ +/* -*- 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 "editattr.hxx" +#include "edtspell.hxx" +#include "eerdll2.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include "TextPortion.hxx" + +#include +#include +#include +#include + +class ItemList +{ +private: +typedef std::vector DummyItemList; +DummyItemList aItemPool; +sal_Int32 CurrentItem; + +public: +ItemList(); +const SfxPoolItem* First(); +const SfxPoolItem* Next(); +sal_Int32 Count() const { return aItemPool.size(); }; +void Insert(const SfxPoolItem* pItem); +void Clear() { aItemPool.clear(); }; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 240bcbfc9e37..aa6232c1f486 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -31,6 +31,7 @@ #include #include #include "TextPortion.hxx" +#include "ItemList.hxx" #include #include @@ -103,31 +104,8 @@ public: void AppendCharAttrib(EditCharAttrib* pNew); }; - - typedef std::vector SvxColorList; - - - -class ItemList -{ -private: -typedef std::vector DummyItemList; -DummyItemList aItemPool; -sal_Int32 CurrentItem; - -public: -ItemList(); -const SfxPoolItem* First(); -const SfxPoolItem* Next(); -sal_Int32 Count() const { return aItemPool.size(); }; -voidInsert( const SfxPoolItem* pItem ); -voidClear() { aItemPool.clear(); }; -}; - - - class ContentAttribs { private:
core.git: 2 commits - editeng/inc editeng/source
editeng/inc/TextPortion.hxx | 147 editeng/inc/editdoc.hxx | 124 -- editeng/source/editeng/editdoc.cxx | 26 -- editeng/source/editeng/impedit.hxx | 10 +- editeng/source/editeng/impedit3.cxx |1 5 files changed, 155 insertions(+), 153 deletions(-) New commits: commit 629f55de24aca6eed7cb3bb8ad2bd8f4a6593d46 Author: Tomaž Vajngerl AuthorDate: Fri Dec 22 20:04:01 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 29 02:42:21 2023 +0100 editeng: simplify FormatterFontMetric We don't really need a custom constructor and default values can now be set directly. Change-Id: I7e8aabf2c60d3b63abf1764bbff512685803f71e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161349 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 89339b11dc3e..4b283106 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -181,11 +181,13 @@ struct ConvInfo struct FormatterFontMetric { -sal_uInt16 nMaxAscent; -sal_uInt16 nMaxDescent; +sal_uInt16 nMaxAscent = 0; +sal_uInt16 nMaxDescent = 0; -FormatterFontMetric() : nMaxAscent(0), nMaxDescent(0) { /* nMinLeading = 0x; */ } -sal_uInt16 GetHeight() const { return nMaxAscent+nMaxDescent; } +sal_uInt16 GetHeight() const +{ +return nMaxAscent + nMaxDescent; +} }; class IdleFormattter : public Idle commit 1958805f61612a7b23f1c5c2d532be4d5dc24a2a Author: Tomaž Vajngerl AuthorDate: Sat Dec 9 15:26:34 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 29 02:42:14 2023 +0100 editeng: move TextPortion to own header file Change-Id: I54d0bbad4ef142705191672319774f26abf3e735 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161348 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/TextPortion.hxx b/editeng/inc/TextPortion.hxx new file mode 100644 index ..e5560f260326 --- /dev/null +++ b/editeng/inc/TextPortion.hxx @@ -0,0 +1,147 @@ +/* -*- 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 "editattr.hxx" +#include "edtspell.hxx" +#include "eerdll2.hxx" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +enum class PortionKind +{ +TEXT = 0, +TAB = 1, +LINEBREAK = 2, +FIELD = 3, +HYPHENATOR = 4 +}; + +enum class AsianCompressionFlags +{ +Normal = 0x00, +Kana = 0x01, +PunctuationLeft = 0x02, +PunctuationRight = 0x04, +}; +namespace o3tl +{ +template <> struct typed_flags : is_typed_flags +{ +}; +} + +struct ExtraPortionInfo +{ +ExtraPortionInfo() {} + +tools::Long nOrgWidth = 0; +tools::Long nWidthFullCompression = 0; + +tools::Long nPortionOffsetX = 0; + +sal_uInt16 nMaxCompression100thPercent = 0; + +AsianCompressionFlags nAsianCompressionTypes = AsianCompressionFlags::Normal; +bool bFirstCharIsRightPunktuation = false; +bool bCompressed = false; + +std::unique_ptr pOrgDXArray; +std::vector lineBreaksList; + +void SaveOrgDXArray(const sal_Int32* pDXArray, sal_Int32 nLen) +{ +if (pDXArray) +{ +pOrgDXArray.reset(new sal_Int32[nLen]); +memcpy(pOrgDXArray.get(), pDXArray, nLen * sizeof(sal_Int32)); +} +else +pOrgDXArray.reset(); +} +}; + +class TextPortion +{ +private: +std::unique_ptr xExtraInfos; +sal_Int32 nLen; +Size aOutSz = Size(-1, -1); +PortionKind nKind = PortionKind::TEXT; +sal_uInt8 nRightToLeftLevel = 0; +sal_Unicode nExtraValue = 0; + +public: +TextPortion(sal_Int32 nL) +: nLen(nL) +{ +} + +TextPortion(const TextPortion& r) +: nLen(r.nLen) +, aOutSz(r.aOutSz) +, nKind(r.nKind) +, nRightToLeftLevel(r.nRightToLeftLevel) +, nExtraValue(r.nExtraValue) +{ +} + +sal_Int32 GetLen() const { return nLen; } +
core.git: editeng/source
editeng/source/editeng/impedit.cxx | 36 +--- 1 file changed, 17 insertions(+), 19 deletions(-) New commits: commit feb035b265210379ed81511d1694466b28695ff3 Author: Tomaž Vajngerl AuthorDate: Fri Dec 8 16:54:13 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:08:42 2023 +0100 editeng: ImpEditView - clean-up UNO types use com::sun::star namespace as the base for UNO types Change-Id: I5ce71f21a914f4653d908162f5ec6f773023165e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161347 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 92fb5affa6c3..abf3c5337255 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -46,9 +46,7 @@ #include #include -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::linguistic2; +using namespace css; #define SCRLRANGE 20 // Scroll 1/20 of the width/height, when in QueryDrop @@ -1416,7 +1414,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) else { // is cursor at a misspelled word ? -Reference< linguistic2::XSpellChecker1 > xSpeller( pEditEngine->pImpEditEngine->GetSpeller() ); +uno::Reference xSpeller( pEditEngine->pImpEditEngine->GetSpeller() ); bool bIsWrong = xSpeller.is() && IsWrongSpelledWord(aPaM, /*bMarkIfWrong*/ false); EditView* pActiveView = GetEditViewPtr(); @@ -1648,7 +1646,7 @@ Pair ImpEditView::Scroll( tools::Long ndX, tools::Long ndY, ScrollRangeCheck nRa return Pair( nRealDiffX, nRealDiffY ); } -Reference ImpEditView::GetClipboard() const +uno::Reference ImpEditView::GetClipboard() const { if (EditViewCallbacks* pCallbacks = getEditViewCallbacks()) return pCallbacks->GetClipboard(); @@ -1671,7 +1669,7 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p { if ( !bReadOnly ) { -Reference aClipBoard(GetClipboard()); +uno::Reference aClipBoard(GetClipboard()); CutCopy( aClipBoard, true ); bDone = true; } @@ -1679,7 +1677,7 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p break; case KeyFuncType::COPY: { -Reference aClipBoard(GetClipboard()); +uno::Reference aClipBoard(GetClipboard()); CutCopy( aClipBoard, false ); bDone = true; } @@ -1689,7 +1687,7 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p if ( !bReadOnly && IsPasteEnabled() ) { pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_PASTE ); -Reference aClipBoard(GetClipboard()); +uno::Reference aClipBoard(GetClipboard()); Paste( aClipBoard, pEditEngine->pImpEditEngine->GetStatus().AllowPasteSpecial() ); pEditEngine->pImpEditEngine->UndoActionEnd(); bDone = true; @@ -1717,12 +1715,12 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent ) if ( rMouseEvent.IsMiddle() && !bReadOnly && Application::GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) { -Reference aClipBoard(GetSystemPrimarySelection()); +uno::Reference aClipBoard(GetSystemPrimarySelection()); Paste( aClipBoard ); } else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() ) { -Reference aClipBoard(GetSystemPrimarySelection()); +uno::Reference aClipBoard(GetSystemPrimarySelection()); CutCopy( aClipBoard, false ); } @@ -1807,7 +1805,7 @@ OUString ImpEditView::SpellIgnoreWord() if ( !aWord.isEmpty() ) { -Reference< XDictionary > xDic = LinguMgr::GetIgnoreAllList(); +uno::Reference xDic = LinguMgr::GetIgnoreAllList(); if (xDic.is()) xDic->add( aWord, false, OUString() ); EditDoc& rDoc = pEditEngine->GetEditDoc(); @@ -1913,7 +1911,7 @@ bool ImpEditView::IsBulletArea( const Point& rPos, sal_Int32* pPara ) return false; } -void ImpEditView::CutCopy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard, bool bCut ) +void ImpEditView::CutCopy(uno::Reference const & rxClipboard, bool bCut ) { if ( !(rxClipboard.is() && HasSelection()) ) return; @@ -1946,12 +1944,12 @@ void ImpEditView::CutCopy( css::uno::Reference< css::datatransfer::clipboard::XC } } -void
core.git: editeng/source
editeng/source/editeng/editdbg.cxx |2 +- editeng/source/editeng/impedit.hxx | 34 +- editeng/source/editeng/impedit2.cxx | 20 ++-- editeng/source/editeng/impedit3.cxx | 18 +- editeng/source/editeng/impedit4.cxx |2 +- 5 files changed, 38 insertions(+), 38 deletions(-) New commits: commit 8530c6a25a9ce258e58eb657a9cdd200ba1a30d2 Author: Tomaž Vajngerl AuthorDate: Fri Dec 8 16:48:18 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:08:16 2023 +0100 editeng: prefix ImpEditEngine pVirtDev, pRefDev Change-Id: I4e215b374178314a836cfddb0107b8cdbe6c1f82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161346 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 31ec9d09306d..74cd266d8bb8 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -464,7 +464,7 @@ void EditEngine::DumpData(const EditEngine* pEE, bool bInfoBox) fprintf( fp, " == EditEngine & Views ==" ); fprintf( fp, " " ); fprintf( fp, " Control: %x", unsigned( pEE->GetControlWord() ) ); -fprintf( fp, " RefMapMode: %i", int( pEE->pImpEditEngine->pRefDev->GetMapMode().GetMapUnit() ) ); +fprintf( fp, " RefMapMode: %i", int( pEE->pImpEditEngine->mpRefDev->GetMapMode().GetMapUnit() ) ); fprintf( fp, " PaperSize: %" SAL_PRIdINT64 " x %" SAL_PRIdINT64, sal_Int64(pEE->GetPaperSize().Width()), sal_Int64(pEE->GetPaperSize().Height()) ); fprintf( fp, " MaxAutoPaperSize: %" SAL_PRIdINT64 " x %" SAL_PRIdINT64, sal_Int64(pEE->GetMaxAutoPaperSize().Width()), sal_Int64(pEE->GetMaxAutoPaperSize().Height()) ); fprintf( fp, " MinAutoPaperSize: %" SAL_PRIdINT64 " x %" SAL_PRIdINT64 , sal_Int64(pEE->GetMinAutoPaperSize().Width()), sal_Int64(pEE->GetMinAutoPaperSize().Height()) ); diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 57fe8ca0c7eb..89339b11dc3e 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -534,8 +534,8 @@ private: SfxStyleSheetPool* pStylePool; SfxItemPool*pTextObjectPool; -VclPtr< VirtualDevice> pVirtDev; -VclPtr< OutputDevice > pRefDev; +VclPtr mpVirtDev; +VclPtr mpRefDev; VclPtr mpOwnDev; svtools::ColorConfig maColorConfig; @@ -814,24 +814,24 @@ private: VirtualDevice* GetVirtualDevice(const MapMode& rMapMode, DrawModeFlags nDrawMode) { -if ( !pVirtDev ) -pVirtDev = VclPtr::Create(); +if (!mpVirtDev) +mpVirtDev = VclPtr::Create(); -if ( ( pVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit() ) || - ( pVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX() ) || - ( pVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY() ) ) +if ((mpVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit()) || +(mpVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX()) || +(mpVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY()) ) { -MapMode aMapMode( rMapMode ); -aMapMode.SetOrigin( Point( 0, 0 ) ); -pVirtDev->SetMapMode( aMapMode ); +MapMode aMapMode(rMapMode); +aMapMode.SetOrigin(Point(0, 0)); +mpVirtDev->SetMapMode(aMapMode); } -pVirtDev->SetDrawMode( nDrawMode ); +mpVirtDev->SetDrawMode(nDrawMode); -return pVirtDev; +return mpVirtDev; } -void EraseVirtualDevice() { pVirtDev.disposeAndClear(); } +void EraseVirtualDevice() { mpVirtDev.disposeAndClear(); } DECL_LINK( StatusTimerHdl, Timer *, void); DECL_LINK( IdleFormatHdl, Timer *, void); @@ -1131,11 +1131,11 @@ public: bool isUsedByModel() const override { return true; } -OutputDevice* GetRefDevice() const { return pRefDev.get(); } -voidSetRefDevice( OutputDevice* pRefDef ); +OutputDevice* GetRefDevice() const { return mpRefDev.get(); } +voidSetRefDevice(OutputDevice* mpRefDef); -const MapMode& GetRefMapMode() const { return pRefDev->GetMapMode(); } -voidSetRefMapMode( const MapMode& rMapMode ); +const MapMode& GetRefMapMode() const { return mpRefDev->GetMapMode(); } +voidSetRefMapMode(const MapMode& rMapMode); InternalEditStatus& GetStatus() { return maStatus; } voidCallStatusHdl(); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 4b8f0a63799a..1f481259cafd 100644 --- a/editeng/source/editeng/impedit2.cxx +++
core.git: editeng/inc
editeng/inc/editdoc.hxx |1 - 1 file changed, 1 deletion(-) New commits: commit a26ff6a061ca2ec8fb51123b732288d44a536bf5 Author: Tomaž Vajngerl AuthorDate: Fri Dec 22 20:09:06 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:06:55 2023 +0100 editeng: unneeded forward declaration Change-Id: Icd97c2d382fd9495c67071e08362de0bd4985bbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161350 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 1450cc560833..565012ad97cc 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -50,7 +50,6 @@ bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType ); EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_Int32 nS, sal_Int32 nE ); -class ContentNode; class EditDoc; struct ScriptTypePosInfo
core.git: editeng/source
editeng/source/editeng/impedit.hxx | 262 + 1 file changed, 124 insertions(+), 138 deletions(-) New commits: commit 357ab973db8d33290bde1558af52d4f8d5e065c4 Author: Tomaž Vajngerl AuthorDate: Fri Dec 8 15:42:54 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:06:36 2023 +0100 editeng: move inline methods into ImpEditEngine class Change-Id: Id9e6e1a4308b7f7d0384a1b28c7279aaa3c716f8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161345 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index e4352f298fd8..57fe8ca0c7eb 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -404,9 +404,32 @@ public: voidSetSelectionMode( EESelectionMode eMode ); -inline PointerStyle GetPointer(); +PointerStyle GetPointer() +{ +if ( !mxPointer ) +{ +mxPointer = IsVertical() ? PointerStyle::TextVertical : PointerStyle::Text; +return *mxPointer; +} + +if(PointerStyle::Text == *mxPointer && IsVertical()) +{ +mxPointer = PointerStyle::TextVertical; +} +else if(PointerStyle::TextVertical == *mxPointer && !IsVertical()) +{ +mxPointer = PointerStyle::Text; +} + +return *mxPointer; +} -inline vcl::Cursor* GetCursor(); +vcl::Cursor* GetCursor() +{ +if ( !pCursor ) +pCursor.reset( new vcl::Cursor ); +return pCursor.get(); +} voidAddDragAndDropListeners(); voidRemoveDragAndDropListeners(); @@ -789,7 +812,25 @@ private: void ForceAutoColor( bool b ) { mbForceAutoColor = b; } bool IsForceAutoColor() const { return mbForceAutoColor; } -inline VirtualDevice* GetVirtualDevice( const MapMode& rMapMode, DrawModeFlags nDrawMode ); +VirtualDevice* GetVirtualDevice(const MapMode& rMapMode, DrawModeFlags nDrawMode) +{ +if ( !pVirtDev ) +pVirtDev = VclPtr::Create(); + +if ( ( pVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit() ) || + ( pVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX() ) || + ( pVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY() ) ) +{ +MapMode aMapMode( rMapMode ); +aMapMode.SetOrigin( Point( 0, 0 ) ); +pVirtDev->SetMapMode( aMapMode ); +} + +pVirtDev->SetDrawMode( nDrawMode ); + +return pVirtDev; +} + void EraseVirtualDevice() { pVirtDev.disposeAndClear(); } DECL_LINK( StatusTimerHdl, Timer *, void); @@ -799,8 +840,19 @@ private: voidCheckIdleFormatter(); -inline const ParaPortion* FindParaPortion( const ContentNode* pNode ) const; -inline ParaPortion* FindParaPortion( ContentNode const * pNode ); +const ParaPortion* FindParaPortion(const ContentNode* pNode) const +{ +sal_Int32 nPos = maEditDoc.GetPos( pNode ); +DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" ); +return GetParaPortions()[ nPos ]; +} + +ParaPortion* FindParaPortion(ContentNode const * pNode) +{ +sal_Int32 nPos = maEditDoc.GetPos( pNode ); +DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" ); +return GetParaPortions()[ nPos ]; +} css::uno::Reference< css::datatransfer::XTransferable > CreateTransferable( const EditSelection& rSelection ); @@ -836,8 +888,34 @@ public: ImpEditEngine(const ImpEditEngine&) = delete; ImpEditEngine& operator=(const ImpEditEngine&) = delete; -inline EditUndoManager& GetUndoManager(); -inline EditUndoManager* SetUndoManager(EditUndoManager* pNew); +EditUndoManager& GetUndoManager() +{ +if ( !pUndoManager ) +{ +pUndoManager = new EditUndoManager(); +pUndoManager->SetEditEngine(pEditEngine); +} +return *pUndoManager; +} + +EditUndoManager* SetUndoManager(EditUndoManager* pNew) +{ +EditUndoManager* pRetval = pUndoManager; + +if(pUndoManager) +{ +pUndoManager->SetEditEngine(nullptr); +} + +pUndoManager = pNew; + +if(pUndoManager) +{ +pUndoManager->SetEditEngine(pEditEngine); +} + +return pRetval; +} // @return the previous bUpdateLayout state boolSetUpdateLayout( bool bUpdate, EditView* pCurView = nullptr, bool bForceUpdate = false ); @@ -1000,10 +1078,45 @@ public: static bool DoVisualCursorTraveling(); EditSelection ConvertSelection( sal_Int32 nStartPara, sal_Int32 nStartPos, sal_Int32 nEndPara, sal_Int32 nEndPos ); -inline EPaM
core.git: 2 commits - include/editeng
include/editeng/EPaM.hxx | 44 - include/editeng/EPosition.hxx | 49 ++ include/editeng/editdata.hxx | 26 -- 3 files changed, 65 insertions(+), 54 deletions(-) New commits: commit ecc154cd2a4574a8b9754c0ee7c89afc56e7 Author: Tomaž Vajngerl AuthorDate: Fri Dec 8 15:42:01 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:06:04 2023 +0100 editeng: move EPosition in its own header file Change-Id: I6362bfdde31e276c006be3799839e9c1ff4f82f6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161344 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/editeng/EPosition.hxx b/include/editeng/EPosition.hxx new file mode 100644 index ..ca6a3e13bee0 --- /dev/null +++ b/include/editeng/EPosition.hxx @@ -0,0 +1,49 @@ +/* -*- 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 + +#define EE_INDEX_NOT_FOUND SAL_MAX_INT32 +#define EE_PARA_NOT_FOUND SAL_MAX_INT32 + +struct EPosition +{ +sal_Int32 nPara; +sal_Int32 nIndex; + +EPosition() +: nPara(EE_PARA_NOT_FOUND) +, nIndex(EE_INDEX_NOT_FOUND) +{ +} + +EPosition(sal_Int32 nPara_, sal_Int32 nPos_) +: nPara(nPara_) +, nIndex(nPos_) +{ +} +}; + +template +inline std::basic_ostream& operator<<(std::basic_ostream& stream, + EPosition const& pos) +{ +return stream << "EPosition(" << pos.nPara << ',' << pos.nIndex << ")"; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx index c31fc7eb7bd1..da789675d1b6 100644 --- a/include/editeng/editdata.hxx +++ b/include/editeng/editdata.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -46,12 +47,10 @@ enum class EEAnchorMode { enum class EERemoveParaAttribsMode { RemoveAll, RemoveCharItems, RemoveNone }; -#define EE_PARA_NOT_FOUND SAL_MAX_INT32 #define EE_PARA_APPEND SAL_MAX_INT32 #define EE_PARA_ALL SAL_MAX_INT32 #define EE_PARA_MAX_COUNT SAL_MAX_INT32 -#define EE_INDEX_NOT_FOUND SAL_MAX_INT32 #define EE_TEXTPOS_ALL SAL_MAX_INT32 #define EE_TEXTPOS_MAX_COUNTSAL_MAX_INT32 @@ -86,29 +85,6 @@ EDITENG_DLLPUBLIC extern const size_t EE_APPEND; #define EDITUNDO_USER 200 -struct EPosition -{ -sal_Int32 nPara; -sal_Int32 nIndex; - -EPosition() -: nPara( EE_PARA_NOT_FOUND ) -, nIndex( EE_INDEX_NOT_FOUND ) -{ } - -EPosition( sal_Int32 nPara_, sal_Int32 nPos_ ) -: nPara( nPara_ ) -, nIndex( nPos_ ) -{ } -}; - -template -inline std::basic_ostream & operator <<( -std::basic_ostream & stream, EPosition const& pos) -{ -return stream << "EPosition(" << pos.nPara << ',' << pos.nIndex << ")"; -} - struct EDITENG_DLLPUBLIC EFieldInfo { std::unique_ptr pFieldItem; commit aa2376eb12b02ae88399412495b035f1ddce3b72 Author: Tomaž Vajngerl AuthorDate: Tue Dec 5 23:18:38 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:05:55 2023 +0100 editeng: simplify and clean-up EPaM Remove copy/assign operator as they are not needed because they are the same as default. Change-Id: I1a71e5de8024680307a65e8b5540b250178f0a97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161343 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/editeng/EPaM.hxx b/include/editeng/EPaM.hxx index 85ad4bd2b6ee..d474dfe18235 100644 --- a/include/editeng/EPaM.hxx +++ b/include/editeng/EPaM.hxx @@ -21,44 +21,30 @@ struct EPaM { -sal_Int32 nPara; -sal_Int32 nIndex; +sal_Int32 nPara = 0; +sal_Int32 nIndex = 0; -EPaM() -: nPara(0) -, nIndex(0) -{ -} -EPaM(sal_Int32 nP, sal_Int32 nI) -: nPara(nP) -, nIndex(nI) +EPaM() = default; + +EPaM(sal_Int32 _nParagraph, sal_Int32 _nIndex) +:
core.git: 2 commits - editeng/CppunitTest_editeng_core.mk editeng/inc editeng/qa include/editeng
editeng/CppunitTest_editeng_core.mk |1 editeng/inc/editdoc.hxx | 24 editeng/qa/unit/EPaMTest.cxx| 103 include/editeng/EPaM.hxx| 69 4 files changed, 174 insertions(+), 23 deletions(-) New commits: commit ff0a9cb65ae5d862575b091c44e114c117e9f3b5 Author: Tomaž Vajngerl AuthorDate: Tue Dec 5 23:13:42 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:05:43 2023 +0100 editeng: add EPaM unit tests Change-Id: Icc15746bf2712bae446f16fd378f94f8be5ec61e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161342 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/CppunitTest_editeng_core.mk b/editeng/CppunitTest_editeng_core.mk index 67a3c949555b..43df48cbe38a 100644 --- a/editeng/CppunitTest_editeng_core.mk +++ b/editeng/CppunitTest_editeng_core.mk @@ -14,6 +14,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,editeng_core)) $(eval $(call gb_CppunitTest_add_exception_objects,editeng_core, \ editeng/qa/unit/core-test \ editeng/qa/unit/ESelectionTest \ +editeng/qa/unit/EPaMTest \ )) $(eval $(call gb_CppunitTest_use_library_objects,editeng_core,editeng)) diff --git a/editeng/qa/unit/EPaMTest.cxx b/editeng/qa/unit/EPaMTest.cxx new file mode 100644 index ..509f08720aa0 --- /dev/null +++ b/editeng/qa/unit/EPaMTest.cxx @@ -0,0 +1,103 @@ +/* -*- 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/. + */ + +#include +#include + +namespace +{ +class EPaMTest : public test::BootstrapFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(EPaMTest, testConstruction) +{ +{ +EPaM aNew; +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.nPara); +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.nIndex); +} + +{ +EPaM aNew(1, 2); +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNew.nPara); +CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNew.nIndex); +} + +{ +EPaM aNew = { 1, 2 }; +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNew.nPara); +CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNew.nIndex); +} + +{ +EPaM aNew{ 1, 2 }; +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNew.nPara); +CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNew.nIndex); +} +} + +CPPUNIT_TEST_FIXTURE(EPaMTest, testAssign) +{ +EPaM aPaM1; +EPaM aPaM2; + +// set PaM 2 +aPaM2 = EPaM{ 2, 1 }; + +// selections are not equal +CPPUNIT_ASSERT(aPaM2 != aPaM1); + +// assign PaM 1 with PaM 2 content +aPaM1 = aPaM2; + +// expect selections to be equal +CPPUNIT_ASSERT_EQUAL(aPaM2, aPaM1); +} + +CPPUNIT_TEST_FIXTURE(EPaMTest, testEquals) +{ +EPaM aPaM1; +EPaM aPaM2; + +// both empty = equal +CPPUNIT_ASSERT_EQUAL(aPaM1, aPaM2); + +// set PaM 1 +aPaM1 = { 1, 2 }; + +// expect them to be not equal +CPPUNIT_ASSERT(aPaM1 != aPaM2); + +// set PaM 2 to the same value +aPaM2 = { 1, 2 }; + +// equal again +CPPUNIT_ASSERT_EQUAL(aPaM1, aPaM2); +} + +CPPUNIT_TEST_FIXTURE(EPaMTest, testLess) +{ +// Both equal +CPPUNIT_ASSERT_EQUAL(false, EPaM(0, 0) < EPaM(0, 0)); + +// Obviously not less +CPPUNIT_ASSERT_EQUAL(false, EPaM(0, 2) < EPaM(0, 1)); + +// Strictly "<" +CPPUNIT_ASSERT_EQUAL(true, EPaM(0, 0) < EPaM(0, 1)); + +// Check if paragraph taken into account +CPPUNIT_ASSERT_EQUAL(false, EPaM(1, 0) < EPaM(0, 1)); +CPPUNIT_ASSERT_EQUAL(true, EPaM(1, 0) < EPaM(2, 0)); +} + +} // end anonymous namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/EPaM.hxx b/include/editeng/EPaM.hxx index c61d77577cbf..85ad4bd2b6ee 100644 --- a/include/editeng/EPaM.hxx +++ b/include/editeng/EPaM.hxx @@ -59,4 +59,11 @@ inline bool EPaM::operator==(const EPaM& r) const return (nPara == r.nPara) && (nIndex == r.nIndex); } +template +inline std::basic_ostream& operator<<(std::basic_ostream& stream, + EPaM const& aPaM) +{ +return stream << "EPaM(" << aPaM.nPara << ',' << aPaM.nIndex << ")"; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 9c40b820280843450cab4287d7cfbdc0988064e4 Author: Tomaž Vajngerl AuthorDate: Tue Dec 5 23:12:09 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 08:05:35 2023 +0100 editeng: move EPaM in its own header file Change-Id: Ib3682dd5df09162748aad4402108b2b3cec3a853 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161341 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 16eaf157a91f..1450cc560833 100644 ---
core.git: 2 commits - editeng/CppunitTest_editeng_core.mk editeng/qa include/editeng
editeng/CppunitTest_editeng_core.mk |1 editeng/qa/unit/ESelectionTest.cxx | 185 include/editeng/ESelection.hxx | 126 ++-- 3 files changed, 238 insertions(+), 74 deletions(-) New commits: commit 5d579ddc04d2862861a9b948ebc12ace74fc122c Author: Tomaž Vajngerl AuthorDate: Tue Dec 5 23:08:25 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 04:21:25 2023 +0100 editeng: simplify and clean-up ESelection Change-Id: I8c0ee3f6b0f4e20277e006c15fddbda6ba9c05e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161340 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/editeng/ESelection.hxx b/include/editeng/ESelection.hxx index 2ddc90c997d8..7f5aa8e81cf6 100644 --- a/include/editeng/ESelection.hxx +++ b/include/editeng/ESelection.hxx @@ -21,24 +21,18 @@ struct ESelection { -sal_Int32 nStartPara; -sal_Int32 nStartPos; -sal_Int32 nEndPara; -sal_Int32 nEndPos; +sal_Int32 nStartPara = 0; +sal_Int32 nStartPos = 0; +sal_Int32 nEndPara = 0; +sal_Int32 nEndPos = 0; -ESelection() -: nStartPara(0) -, nStartPos(0) -, nEndPara(0) -, nEndPos(0) -{ -} +ESelection() = default; -ESelection(sal_Int32 nStPara, sal_Int32 nStPos, sal_Int32 nEPara, sal_Int32 nEPos) -: nStartPara(nStPara) -, nStartPos(nStPos) -, nEndPara(nEPara) -, nEndPos(nEPos) +ESelection(sal_Int32 _nStartPara, sal_Int32 _nStartPos, sal_Int32 _nEndPara, sal_Int32 _nEndPos) +: nStartPara(_nStartPara) +, nStartPos(_nStartPos) +, nEndPara(_nEndPara) +, nEndPos(_nEndPos) { } @@ -50,71 +44,55 @@ struct ESelection { } -void Adjust(); -bool operator==(const ESelection& rS) const; -bool operator!=(const ESelection& rS) const { return !operator==(rS); } -bool operator<(const ESelection& rS) const; -bool operator>(const ESelection& rS) const; -bool IsZero() const; -bool HasRange() const; -}; +void Adjust() +{ +if (nStartPara > nEndPara || (nStartPara == nEndPara && nStartPos > nEndPos)) +{ +std::swap(nStartPara, nEndPara); +std::swap(nStartPos, nEndPos); +} +} -template -inline std::basic_ostream& operator<<(std::basic_ostream& stream, - ESelection const& sel) -{ -return stream << "ESelection(" << sel.nStartPara << ',' << sel.nStartPos << "," << sel.nEndPara - << "," << sel.nEndPos << ")"; -} +bool operator==(const ESelection& rSelection) const +{ +return nStartPara == rSelection.nStartPara && nStartPos == rSelection.nStartPos + && nEndPara == rSelection.nEndPara && nEndPos == rSelection.nEndPos; +} -inline bool ESelection::HasRange() const -{ -return (nStartPara != nEndPara) || (nStartPos != nEndPos); -} +bool operator!=(const ESelection& rSelection) const = default; -inline bool ESelection::IsZero() const -{ -return ((nStartPara == 0) && (nStartPos == 0) && (nEndPara == 0) && (nEndPos == 0)); -} +bool operator<(const ESelection& rSelection) const +{ +// The selection must be adjusted. +// => Only check if end of 'this' < Start of rS +return nEndPara < rSelection.nStartPara + || (nEndPara == rSelection.nStartPara && nEndPos < rSelection.nStartPos + && operator!=(rSelection)); +} -inline bool ESelection::operator==(const ESelection& rS) const -{ -return ((nStartPara == rS.nStartPara) && (nStartPos == rS.nStartPos) -&& (nEndPara == rS.nEndPara) && (nEndPos == rS.nEndPos)); -} +bool operator>(const ESelection& rSelection) const +{ +// The selection must be adjusted. +// => Only check if end of 'this' < Start of rS +return nStartPara > rSelection.nEndPara + || (nStartPara == rSelection.nEndPara && nStartPos > rSelection.nEndPos + && operator!=(rSelection)); +} -inline bool ESelection::operator<(const ESelection& rS) const -{ -// The selection must be adjusted. -// => Only check if end of 'this' < Start of rS -return (nEndPara < rS.nStartPara) - || ((nEndPara == rS.nStartPara) && (nEndPos < rS.nStartPos) && !operator==(rS)); -} +bool IsZero() const +{ +return nStartPara == 0 && nStartPos == 0 && nEndPara == 0 && nEndPos == 0; +} -inline bool ESelection::operator>(const ESelection& rS) const -{ -// The selection must be adjusted. -// => Only check if end of 'this' < Start of rS -return (nStartPara > rS.nEndPara) - || ((nStartPara == rS.nEndPara) && (nStartPos > rS.nEndPos) && !operator==(rS)); -} +bool HasRange() const { return nStartPara != nEndPara || nStartPos != nEndPos; } +}; -inline void ESelection::Adjust()
core.git: include/editeng
include/editeng/ESelection.hxx | 120 + include/editeng/editdata.hxx | 90 -- 2 files changed, 121 insertions(+), 89 deletions(-) New commits: commit 29097009b1f8c0dcb050367d3f2acfcaf2074a56 Author: Tomaž Vajngerl AuthorDate: Mon Dec 4 10:12:54 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Dec 28 02:36:29 2023 +0100 editeng: move ESelection in its own header file Change-Id: I46fbaf9fea8308169f2ada19787684c87b0c3c5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161338 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/editeng/ESelection.hxx b/include/editeng/ESelection.hxx new file mode 100644 index ..2ddc90c997d8 --- /dev/null +++ b/include/editeng/ESelection.hxx @@ -0,0 +1,120 @@ +/* -*- 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 + +struct ESelection +{ +sal_Int32 nStartPara; +sal_Int32 nStartPos; +sal_Int32 nEndPara; +sal_Int32 nEndPos; + +ESelection() +: nStartPara(0) +, nStartPos(0) +, nEndPara(0) +, nEndPos(0) +{ +} + +ESelection(sal_Int32 nStPara, sal_Int32 nStPos, sal_Int32 nEPara, sal_Int32 nEPos) +: nStartPara(nStPara) +, nStartPos(nStPos) +, nEndPara(nEPara) +, nEndPos(nEPos) +{ +} + +ESelection(sal_Int32 nPara, sal_Int32 nPos) +: nStartPara(nPara) +, nStartPos(nPos) +, nEndPara(nPara) +, nEndPos(nPos) +{ +} + +void Adjust(); +bool operator==(const ESelection& rS) const; +bool operator!=(const ESelection& rS) const { return !operator==(rS); } +bool operator<(const ESelection& rS) const; +bool operator>(const ESelection& rS) const; +bool IsZero() const; +bool HasRange() const; +}; + +template +inline std::basic_ostream& operator<<(std::basic_ostream& stream, + ESelection const& sel) +{ +return stream << "ESelection(" << sel.nStartPara << ',' << sel.nStartPos << "," << sel.nEndPara + << "," << sel.nEndPos << ")"; +} + +inline bool ESelection::HasRange() const +{ +return (nStartPara != nEndPara) || (nStartPos != nEndPos); +} + +inline bool ESelection::IsZero() const +{ +return ((nStartPara == 0) && (nStartPos == 0) && (nEndPara == 0) && (nEndPos == 0)); +} + +inline bool ESelection::operator==(const ESelection& rS) const +{ +return ((nStartPara == rS.nStartPara) && (nStartPos == rS.nStartPos) +&& (nEndPara == rS.nEndPara) && (nEndPos == rS.nEndPos)); +} + +inline bool ESelection::operator<(const ESelection& rS) const +{ +// The selection must be adjusted. +// => Only check if end of 'this' < Start of rS +return (nEndPara < rS.nStartPara) + || ((nEndPara == rS.nStartPara) && (nEndPos < rS.nStartPos) && !operator==(rS)); +} + +inline bool ESelection::operator>(const ESelection& rS) const +{ +// The selection must be adjusted. +// => Only check if end of 'this' < Start of rS +return (nStartPara > rS.nEndPara) + || ((nStartPara == rS.nEndPara) && (nStartPos > rS.nEndPos) && !operator==(rS)); +} + +inline void ESelection::Adjust() +{ +bool bSwap = false; +if (nStartPara > nEndPara) +bSwap = true; +else if ((nStartPara == nEndPara) && (nStartPos > nEndPos)) +bSwap = true; + +if (bSwap) +{ +sal_Int32 nSPar = nStartPara; +sal_Int32 nSPos = nStartPos; +nStartPara = nEndPara; +nStartPos = nEndPos; +nEndPara = nSPar; +nEndPos = nSPos; +} +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx index 1762fd86e837..c31fc7eb7bd1 100644 --- a/include/editeng/editdata.hxx +++ b/include/editeng/editdata.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -108,95 +109,6 @@ inline std::basic_ostream & operator <<( return stream << "EPosition(" << pos.nPara << ',' << pos.nIndex << ")";
core.git: Branch 'distro/collabora/co-23.05' - 2 commits - chart2/export_setup.mk include/oox oox/inc oox/source sd/qa sw/qa sw/source test/source
chart2/export_setup.mk | 60 - include/oox/export/drawingml.hxx| 14 ++- oox/inc/drawingml/misccontexts.hxx |4 oox/source/core/xmlfilterbase.cxx |1 oox/source/drawingml/misccontexts.cxx | 41 +++-- oox/source/export/drawingml.cxx | 103 ++-- oox/source/token/namespaces-strict.txt |1 oox/source/token/namespaces.txt |1 oox/source/token/tokens.txt |2 sd/qa/unit/data/odp/SvgImageTest.odp|binary sd/qa/unit/export-tests.cxx | 44 ++ sw/qa/extras/globalfilter/data/SvgImageTest.odt |binary sw/qa/extras/globalfilter/globalfilter.cxx | 51 +++ sw/qa/extras/ooxmlexport/data/SvgImageTest.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 27 ++ sw/source/filter/ww8/docxattributeoutput.cxx| 16 +++ test/source/xmltesttools.cxx|2 17 files changed, 287 insertions(+), 80 deletions(-) New commits: commit 1e7cd7da0b216557f836e3cb031bca47c2364b1e Author: Tomaž Vajngerl AuthorDate: Mon Sep 25 09:03:54 2023 +0200 Commit: Andras Timar CommitDate: Sun Dec 10 12:37:35 2023 +0100 tdf#126084 import svg image from ooxml document that use svgBlip elem. In an OOXML document the svg image is defined in an svgBlip, which is an OOXML extension. This change checks for the svgBlip element and imports that instead the normal "blip" element that is still provided as a fallback (PNG image). Add roundtrip SVG image test for ODF and OOXML, Impress and Writer. testGraphicBlipXLSX test failed after this change, because some component was missing. Changed to enable use_rdb for all chart2 export tests, so issues like this won't happen anymore. Change-Id: Idf0e754775254d7dcfd0321dfca2ed6d00c42c09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157238 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 1db193c6c744289139b1df2af0b8defcf974b238) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160384 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar diff --git a/chart2/export_setup.mk b/chart2/export_setup.mk index b2bcf75e..723df9897c4a 100644 --- a/chart2/export_setup.mk +++ b/chart2/export_setup.mk @@ -71,65 +71,7 @@ $(eval $(call gb_CppunitTest_use_sdk_api,chart2_export$(1))) $(eval $(call gb_CppunitTest_use_ure,chart2_export$(1))) $(eval $(call gb_CppunitTest_use_vcl,chart2_export$(1))) - -$(eval $(call gb_CppunitTest_use_components,chart2_export$(1),\ -basic/util/sb \ -animations/source/animcore/animcore \ -chart2/source/controller/chartcontroller \ -chart2/source/chartcore \ -comphelper/util/comphelp \ -configmgr/source/configmgr \ -dbaccess/util/dba \ -embeddedobj/util/embobj \ -emfio/emfio \ -eventattacher/source/evtatt \ -filter/source/config/cache/filterconfig1 \ -filter/source/odfflatxml/odfflatxml \ -filter/source/storagefilterdetect/storagefd \ -filter/source/xmlfilteradaptor/xmlfa \ -filter/source/xmlfilterdetect/xmlfd \ -forms/util/frm \ -framework/util/fwk \ -i18npool/util/i18npool \ -linguistic/source/lng \ -oox/util/oox \ -package/source/xstor/xstor \ -package/util/package2 \ -sax/source/expatwrap/expwrap \ -sc/util/sc \ -sc/util/scd \ -sc/util/scfilt \ -sw/util/sw \ -sw/util/swd \ -sw/util/msword \ -sd/util/sd \ -sd/util/sdd \ -$(call gb_Helper_optional,SCRIPTING, \ - sc/util/vbaobj) \ -scaddins/source/analysis/analysis \ -scaddins/source/datefunc/date \ -scripting/source/basprov/basprov \ -scripting/util/scriptframe \ -sfx2/util/sfx \ -sot/util/sot \ -svl/source/fsstor/fsstorage \ -svl/util/svl \ - svtools/util/svt \ -svx/util/svx \ -svx/util/svxcore \ -toolkit/util/tk \ -vcl/vcl.common \ -ucb/source/core/ucb1 \ -ucb/source/ucp/file/ucpfile1 \ -ucb/source/ucp/tdoc/ucptdoc1 \ -unotools/util/utl \ -unoxml/source/rdf/unordf \ -unoxml/source/service/unoxml \ -uui/util/uui \ -writerfilter/util/writerfilter \ -xmloff/util/xo \ -xmlscript/util/xmlscript \ -)) +$(eval $(call gb_CppunitTest_use_rdb,chart2_export$(1),services)) $(eval $(call gb_CppunitTest_use_uiconfigs,chart2_export$(1), \ modules/swriter \ diff --git a/oox/inc/drawingml/misccontexts.hxx b/oox/inc/drawingml/misccontexts.hxx index c79816282ae7..1b7f05444ac7 100644 --- a/oox/inc/drawingml/misccontexts.hxx +++ b/oox/inc/drawingml/misccontexts.hxx @@ -102,7 +102,8 @@ class BlipExtensionContext final : public ::oox::core::ContextHandler2 public: explicitBlipExtensionContext( ::oox::core::ContextHandler2Helper const & rParent,
core.git: Branch 'distro/collabora/co-23.05' - 2 commits - include/oox oox/source sc/source sw/source
include/oox/export/drawingml.hxx | 33 +-- oox/source/export/drawingml.cxx | 279 --- oox/source/export/shapes.cxx | 10 oox/source/export/vmlexport.cxx |4 sc/source/filter/excel/xeescher.cxx |2 sw/source/filter/ww8/docxattributeoutput.cxx |6 6 files changed, 162 insertions(+), 172 deletions(-) New commits: commit c86a81192e6a39ca82850156fccb78b2a4ccc3c6 Author: Tomaž Vajngerl AuthorDate: Sun Dec 3 12:53:58 2023 +0900 Commit: Andras Timar CommitDate: Sun Dec 10 12:37:11 2023 +0100 oox: Refactor and simplify writing to storage with GraphicExport Change-Id: I743dc99e0228b59050fb4926c8ef56bed8e82060 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160252 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 1be8b2752d30d3c024e46526e9d31c1e7066799c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160382 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index fd293c28b5d2..70827d256b8d 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -140,28 +140,28 @@ protected: virtual ~DMLTextExport() {} }; -constexpr const char* getComponentDir(DocumentType eDocumentType) +constexpr std::u16string_view getComponentDir(DocumentType eDocumentType) { switch (eDocumentType) { -case DOCUMENT_DOCX: return "word"; -case DOCUMENT_PPTX: return "ppt"; -case DOCUMENT_XLSX: return "xl"; +case DOCUMENT_DOCX: return u"word"; +case DOCUMENT_PPTX: return u"ppt"; +case DOCUMENT_XLSX: return u"xl"; } -return ""; +return u""; } -constexpr const char* getRelationCompPrefix(DocumentType eDocumentType) +constexpr std::u16string_view getRelationCompPrefix(DocumentType eDocumentType) { switch (eDocumentType) { -case DOCUMENT_DOCX: return ""; +case DOCUMENT_DOCX: return u""; case DOCUMENT_PPTX: -case DOCUMENT_XLSX: return "../"; +case DOCUMENT_XLSX: return u"../"; } -return ""; +return u""; } class OOX_DLLPUBLIC GraphicExportCache @@ -251,12 +251,15 @@ public: } }; -class GraphicExport +class OOX_DLLPUBLIC GraphicExport { +private: sax_fastparser::FSHelperPtr mpFS; oox::core::XmlFilterBase* mpFilterBase; DocumentType meDocumentType; +OUString writeNewEntryToStorage(const Graphic& rGraphic, bool bRelPathToMedia); + public: GraphicExport(sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFilterBase, DocumentType eDocumentType) : mpFS(pFS) @@ -319,8 +322,8 @@ protected: void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties ); -const char* GetComponentDir() const; -const char* GetRelationCompPrefix() const; +OUString GetComponentDir() const; +OUString GetRelationCompPrefix() const; static bool EqualGradients( const css::awt::Gradient2& rGradient1, const css::awt::Gradient2& rGradient2 ); bool IsFontworkShape(const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet); @@ -349,7 +352,7 @@ public: void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; } /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship -OUString writeGraphicToStorage( const Graphic , bool bRelPathToMedia = false ); +OUString writeGraphicToStorage(const Graphic , bool bRelPathToMedia = false); void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT ); void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index b44ab8b21f47..0bb2272d6ecf 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1256,14 +1256,14 @@ void DrawingML::WriteOutline( const Reference& rXPropSet, Referenc mpFS->endElementNS( XML_a, XML_ln ); } -const char* DrawingML::GetComponentDir() const +OUString DrawingML::GetComponentDir() const { -return getComponentDir(meDocumentType); +return OUString(getComponentDir(meDocumentType)); } -const char* DrawingML::GetRelationCompPrefix() const +OUString DrawingML::GetRelationCompPrefix() const { -return getRelationCompPrefix(meDocumentType); +return OUString(getRelationCompPrefix(meDocumentType)); } void GraphicExport::writeBlip(Graphic const& rGraphic, std::vector const& rEffects, bool bRelPathToMedia) @@ -1384,136 +1384,135 @@ void GraphicExport::writeBlip(Graphic const& rGraphic, std::vectorendElementNS(XML_a, XML_blip); } -OUString GraphicExport::writeToStorage(const Graphic&
core.git: oox/source sd/qa sw/qa
oox/source/drawingml/misccontexts.cxx |6 +- sd/qa/unit/export-tests.cxx| 15 +-- sw/qa/extras/globalfilter/globalfilter.cxx | 17 + 3 files changed, 31 insertions(+), 7 deletions(-) New commits: commit a010567c2cdb8ea0fe059b0b64fd5d1f2fd99a03 Author: Tomaž Vajngerl AuthorDate: Wed Dec 6 16:55:01 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 8 03:55:42 2023 +0100 tdf#126084 document OOXML SVG tests and import Change-Id: Ief29d04f2f0693a4cdfa44c7c100ac6164da38f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160378 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/oox/source/drawingml/misccontexts.cxx b/oox/source/drawingml/misccontexts.cxx index 244d17d9fc62..93d2c8ee411b 100644 --- a/oox/source/drawingml/misccontexts.cxx +++ b/oox/source/drawingml/misccontexts.cxx @@ -619,20 +619,24 @@ ContextHandlerRef BlipExtensionContext::onCreateContext(sal_Int32 nElement, cons case OOX_TOKEN(a14, imgProps): return new ArtisticEffectContext(*this, mrBlipProps.maEffect); +// Import the SVG Blip case OOX_TOKEN(asvg, svgBlip): { if (rAttribs.hasAttribute(R_TOKEN(embed))) { -// internal picture URL OUString aFragmentPath = getFragmentPathFromRelId(rAttribs.getStringDefaulted(R_TOKEN(embed))); if (!aFragmentPath.isEmpty()) { +// Read the graphic from the fragment path auto xGraphic = getFilter().getGraphicHelper().importEmbeddedGraphic(aFragmentPath); + +// Overwrite the fill graphic with the one contining SVG mrBlipProps.mxFillGraphic = xGraphic; if (mpBlipFill) mpBlipFill->mxGraphic = xGraphic; } } +// TODO - link } break; } diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 92b36ecacce7..428b09e983a1 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -1933,10 +1933,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport) { // Load the original file createSdImpressDoc("odp/SvgImageTest.odp"); -const OString sFailedMessage = "Failed on filter: " + rFormat.toUtf8(); +// Save into the target format saveAndReload(rFormat); -// Check whether graphic was exported well +const OString sFailedMessage = "Failed on filter: " + rFormat.toUtf8(); + +// Check whether SVG graphic was exported as expected uno::Reference xDrawPagesSupplier(mxComponent, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(1), @@ -1944,15 +1946,24 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport) uno::Reference xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDrawPage.is()); + +// Get the image uno::Reference xImage(xDrawPage->getByIndex(0), uno::UNO_QUERY); uno::Reference xPropertySet(xImage, uno::UNO_QUERY_THROW); +// Convert to a XGraphic uno::Reference xGraphic; xPropertySet->getPropertyValue("Graphic") >>= xGraphic; CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + +// Access the Graphic Graphic aGraphic(xGraphic); + +// Check if it contian a VectorGraphicData struct auto pVectorGraphic = aGraphic.getVectorGraphicData(); CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pVectorGraphic); + +// Which should be of type SVG, which means we have a SVG file CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), VectorGraphicDataType::Svg, pVectorGraphic->getType()); } diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 3eda6b6354e8..9d7c28b83ff8 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -2225,28 +2225,37 @@ void Test::testSvgImageSupport() for (OUString const & rFilterName : aFilterNames) { -// Check whether the export code swaps in the image which was swapped out before by auto mechanism +// Use case to import a document containing a SVG image, export in target format, import and check if the +// SVG image is present and as expected in the document +// Import ODT file createSwDoc("SvgImageTest.odt"); -// Export the document and import again for a check +// Export the document in target format and import again saveAndReload(rFilterName); -
[Libreoffice-commits] core.git: chart2/export_setup.mk oox/inc oox/source sd/qa sw/qa
chart2/export_setup.mk | 60 oox/inc/drawingml/misccontexts.hxx |4 + oox/source/core/xmlfilterbase.cxx |1 oox/source/drawingml/misccontexts.cxx | 37 ++ sd/qa/unit/data/odp/SvgImageTest.odp|binary sd/qa/unit/export-tests.cxx | 31 sw/qa/extras/globalfilter/data/SvgImageTest.odt |binary sw/qa/extras/globalfilter/globalfilter.cxx | 37 ++ 8 files changed, 100 insertions(+), 70 deletions(-) New commits: commit 1db193c6c744289139b1df2af0b8defcf974b238 Author: Tomaž Vajngerl AuthorDate: Mon Sep 25 09:03:54 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 6 08:23:34 2023 +0100 tdf#126084 import svg image from ooxml document that use svgBlip elem. In an OOXML document the svg image is defined in an svgBlip, which is an OOXML extension. This change checks for the svgBlip element and imports that instead the normal "blip" element that is still provided as a fallback (PNG image). Add roundtrip SVG image test for ODF and OOXML, Impress and Writer. testGraphicBlipXLSX test failed after this change, because some component was missing. Changed to enable use_rdb for all chart2 export tests, so issues like this won't happen anymore. Change-Id: Idf0e754775254d7dcfd0321dfca2ed6d00c42c09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157238 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/chart2/export_setup.mk b/chart2/export_setup.mk index b2bcf75e..723df9897c4a 100644 --- a/chart2/export_setup.mk +++ b/chart2/export_setup.mk @@ -71,65 +71,7 @@ $(eval $(call gb_CppunitTest_use_sdk_api,chart2_export$(1))) $(eval $(call gb_CppunitTest_use_ure,chart2_export$(1))) $(eval $(call gb_CppunitTest_use_vcl,chart2_export$(1))) - -$(eval $(call gb_CppunitTest_use_components,chart2_export$(1),\ -basic/util/sb \ -animations/source/animcore/animcore \ -chart2/source/controller/chartcontroller \ -chart2/source/chartcore \ -comphelper/util/comphelp \ -configmgr/source/configmgr \ -dbaccess/util/dba \ -embeddedobj/util/embobj \ -emfio/emfio \ -eventattacher/source/evtatt \ -filter/source/config/cache/filterconfig1 \ -filter/source/odfflatxml/odfflatxml \ -filter/source/storagefilterdetect/storagefd \ -filter/source/xmlfilteradaptor/xmlfa \ -filter/source/xmlfilterdetect/xmlfd \ -forms/util/frm \ -framework/util/fwk \ -i18npool/util/i18npool \ -linguistic/source/lng \ -oox/util/oox \ -package/source/xstor/xstor \ -package/util/package2 \ -sax/source/expatwrap/expwrap \ -sc/util/sc \ -sc/util/scd \ -sc/util/scfilt \ -sw/util/sw \ -sw/util/swd \ -sw/util/msword \ -sd/util/sd \ -sd/util/sdd \ -$(call gb_Helper_optional,SCRIPTING, \ - sc/util/vbaobj) \ -scaddins/source/analysis/analysis \ -scaddins/source/datefunc/date \ -scripting/source/basprov/basprov \ -scripting/util/scriptframe \ -sfx2/util/sfx \ -sot/util/sot \ -svl/source/fsstor/fsstorage \ -svl/util/svl \ - svtools/util/svt \ -svx/util/svx \ -svx/util/svxcore \ -toolkit/util/tk \ -vcl/vcl.common \ -ucb/source/core/ucb1 \ -ucb/source/ucp/file/ucpfile1 \ -ucb/source/ucp/tdoc/ucptdoc1 \ -unotools/util/utl \ -unoxml/source/rdf/unordf \ -unoxml/source/service/unoxml \ -uui/util/uui \ -writerfilter/util/writerfilter \ -xmloff/util/xo \ -xmlscript/util/xmlscript \ -)) +$(eval $(call gb_CppunitTest_use_rdb,chart2_export$(1),services)) $(eval $(call gb_CppunitTest_use_uiconfigs,chart2_export$(1), \ modules/swriter \ diff --git a/oox/inc/drawingml/misccontexts.hxx b/oox/inc/drawingml/misccontexts.hxx index c79816282ae7..1b7f05444ac7 100644 --- a/oox/inc/drawingml/misccontexts.hxx +++ b/oox/inc/drawingml/misccontexts.hxx @@ -102,7 +102,8 @@ class BlipExtensionContext final : public ::oox::core::ContextHandler2 public: explicitBlipExtensionContext( ::oox::core::ContextHandler2Helper const & rParent, -BlipFillProperties& rBlipProps ); +BlipFillProperties& rBlipProps, +model::BlipFill* pBlipFill); virtual ~BlipExtensionContext() override; virtual ::oox::core::ContextHandlerRef @@ -112,6 +113,7 @@ public: private: BlipFillProperties& mrBlipProps; +model::BlipFill* mpBlipFill; }; diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index d197440133da..93b5816812a1 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -149,6 +149,7 @@ const Sequence< beans::Pair< OUString, sal_Int32 > >& NamespaceIds()
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sw/qa xmloff/inc xmloff/source
sw/qa/extras/fodfexport/data/SvgImageTest.fodt | 321 + sw/qa/extras/fodfexport/fodfexport.cxx | 25 + xmloff/inc/xmlmultiimagehelper.hxx |1 xmloff/source/core/xmlmultiimagehelper.cxx | 28 +- xmloff/source/draw/ximpshap.cxx| 24 + xmloff/source/draw/ximpshap.hxx|3 xmloff/source/text/XMLTextFrameContext.cxx | 11 xmloff/source/text/XMLTextFrameContext.hxx |1 8 files changed, 399 insertions(+), 15 deletions(-) New commits: commit d6ca6718a3514f383b2b4b678bbcca7188493c86 Author: Tomaž Vajngerl AuthorDate: Sat Dec 2 16:57:30 2023 +0900 Commit: Miklos Vajna CommitDate: Wed Dec 6 08:20:46 2023 +0100 tdf#123396 actually use the mimetype set in the from document In the document we set the mime type for the images stored, but at import we never actually used the mime types. We always did mime type detection from the filename extension. The problem with this is that files stored as base64 streams don't have a filename so it is also not possible to determine the mime type from the file name. The consequence of this is that we can't know which image to take if we have multiple images (fallback images) so we always take the last one, which could be the wrong one. This happend in the test document. This changes the behavior so that we always first use the document set mime type as there is no reason to not trust that. Only if the mime type isn't provided by the document we use other mime type detection methods. Change-Id: I175c509ce5f11eab2c0454d4d9901ca1fe975272 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160237 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit f5cf0c10eb7050feff19190b06b4597aab2d400a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160338 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/fodfexport/data/SvgImageTest.fodt b/sw/qa/extras/fodfexport/data/SvgImageTest.fodt new file mode 100644 index ..4246a7cb5e5e --- /dev/null +++ b/sw/qa/extras/fodfexport/data/SvgImageTest.fodt @@ -0,0 +1,321 @@ + + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + 2023-12-01T21:40:25.0108966092023-12-02T14:20:24.763250978PT2M41S2LibreOffice/7.6.3.1$Linux_X86_64 LibreOffice_project/60$Build-1 + + + 0 + 0 + 58104 + 33657 + true + false + + + view2 + 20551 + 17866 + 0 + 0 + 58103 + 33655 + 0 + 1 + false + 100 + false + false + false + false + false + false + + + + + true + false + true + false + true + false + false + 0 + true + false + true + false + false + false + false +
[Libreoffice-commits] core.git: include/oox oox/source sw/qa sw/source test/source
include/oox/export/drawingml.hxx | 14 ++- oox/source/export/drawingml.cxx| 103 +++-- oox/source/token/namespaces-strict.txt |1 oox/source/token/namespaces.txt|1 oox/source/token/tokens.txt|2 sw/qa/extras/ooxmlexport/data/SvgImageTest.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport20.cxx | 27 ++ sw/source/filter/ww8/docxattributeoutput.cxx | 16 +++ test/source/xmltesttools.cxx |2 9 files changed, 157 insertions(+), 9 deletions(-) New commits: commit bfbbf06bcea4d58117c14fd3f3b8743a3714f97e Author: Tomaž Vajngerl AuthorDate: Sun Dec 3 13:21:35 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Mon Dec 4 10:33:34 2023 +0100 tdf#126084 support writing SVG images into OOXML using the MS OOXML extension SVG files aren't supported in OOXML, but we can write it using the MS OOXML extension, which is supported in the latest MSO versions. For now this only implements the support in the exporter. Change-Id: I688180fb5772f3999c2ee3020bc234f90d57cc2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157237 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 9028cfdc0f9f..dcbb1b544390 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -259,16 +259,25 @@ private: DocumentType meDocumentType; OUString writeNewEntryToStorage(const Graphic& rGraphic, bool bRelPathToMedia); +OUString writeNewSvgEntryToStorage(const Graphic& rGraphic, bool bRelPathToMedia); public: +enum class TypeHint +{ +Detect, +SVG +}; + GraphicExport(sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFilterBase, DocumentType eDocumentType) : mpFS(pFS) , mpFilterBase(pFilterBase) , meDocumentType(eDocumentType) {} -OUString writeToStorage(Graphic const& rGraphic, bool bRelPathToMedia = false); +OUString writeToStorage(Graphic const& rGraphic, bool bRelPathToMedia = false, TypeHint eHint = TypeHint::Detect); + void writeBlip(Graphic const& rGraphic, std::vector const& rEffects, bool bRelPathToMedia = false); +void writeSvgExtension(OUString const& rSvgRelId); }; class OOX_DLLPUBLIC DrawingML @@ -353,7 +362,7 @@ public: void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; } /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship -OUString writeGraphicToStorage(const Graphic , bool bRelPathToMedia = false); +OUString writeGraphicToStorage(const Graphic , bool bRelPathToMedia = false, GraphicExport::TypeHint eHint = GraphicExport::TypeHint::Detect); void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT ); void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT ); @@ -516,6 +525,7 @@ public: const OUString& sRelationshipType, OUString* pRelationshipId ); +std::shared_ptr createGraphicExport(); }; } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 228aa2326cc0..05c96c9ad798 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1283,12 +1283,34 @@ OUString DrawingML::GetRelationCompPrefix() const return OUString(getRelationCompPrefix(meDocumentType)); } +void GraphicExport::writeSvgExtension(OUString const& rSvgRelId) +{ +if (rSvgRelId.isEmpty()) +return; + +mpFS->startElementNS(XML_a, XML_extLst); +mpFS->startElementNS(XML_a, XML_ext, XML_uri, "{96DAC541-7B7A-43D3-8B79-37D633B846F1}"); +mpFS->singleElementNS(XML_asvg, XML_svgBlip, +FSNS(XML_xmlns, XML_asvg), mpFilterBase->getNamespaceURL(OOX_NS(asvg)), +FSNS(XML_r, XML_embed), rSvgRelId); +mpFS->endElementNS(XML_a, XML_ext); +mpFS->endElementNS( XML_a, XML_extLst); +} + void GraphicExport::writeBlip(Graphic const& rGraphic, std::vector const& rEffects, bool bRelPathToMedia) { OUString sRelId = writeToStorage(rGraphic, bRelPathToMedia); mpFS->startElementNS(XML_a, XML_blip, FSNS(XML_r, XML_embed), sRelId); +auto const& rVectorGraphicDataPtr = rGraphic.getVectorGraphicData(); + +if (rVectorGraphicDataPtr && rVectorGraphicDataPtr->getType() == VectorGraphicDataType::Svg) +{ +OUString sSvgRelId = writeToStorage(rGraphic, bRelPathToMedia, TypeHint::SVG); +writeSvgExtension(sSvgRelId); +} + for (auto const& rEffect : rEffects) { switch (rEffect.meType) @@ -1514,19 +1536,72 @@ OUString GraphicExport::writeNewEntryToStorage(const Graphic& rGraphic, bool bRe return
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sw/qa sw/source writerfilter/qa writerfilter/source
sw/qa/core/header_footer/HeaderFooterTest.cxx | 75 - sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |3 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 13 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |4 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx |9 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |4 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |3 sw/qa/extras/rtfexport/rtfexport.cxx |3 sw/qa/extras/rtfexport/rtfexport2.cxx |6 sw/qa/extras/rtfexport/rtfexport3.cxx | 35 sw/qa/extras/rtfexport/rtfexport5.cxx |2 sw/qa/extras/rtfimport/rtfimport.cxx | 19 sw/source/core/doc/docfmt.cxx | 17 sw/source/filter/ww8/rtfexport.cxx |8 writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx |1 writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx |3 writerfilter/source/dmapper/DomainMapper_Impl.cxx | 214 +++- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 60 - writerfilter/source/dmapper/PropertyIds.cxx|3 writerfilter/source/dmapper/PropertyIds.hxx|3 writerfilter/source/dmapper/PropertyMap.cxx| 663 ++--- writerfilter/source/dmapper/PropertyMap.hxx| 83 + 22 files changed, 713 insertions(+), 518 deletions(-) New commits: commit 2cc3e16f8e3f50d0fa53f15f78bba3afe29977bd Author: Tomaž Vajngerl AuthorDate: Tue Nov 28 13:46:21 2023 +0900 Commit: Miklos Vajna CommitDate: Mon Dec 4 09:10:00 2023 +0100 tdf#136472 adjust ooxml import to handle first header/footer Previously the ooxml import added a new page style when the first header or footer was detected. Since then we gained support to add first page header/footer in an existing page style so we don't need to import it like that anymore. This changes the import code so that the old complication to add "First Page" page style is removed and it always just uses the "Standard" page style for all 3 cases: first, left and right headers and footers. This also adjusts the existing tests to align with this change. Change-Id: Ibf69597e6990499ac520ea9e323a5f73f429800b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157860 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 4b0fa253a4540f5461397815d290586f9ddabe61) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160193 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx b/sw/qa/core/header_footer/HeaderFooterTest.cxx index 23e91a2db4b1..58411ee03b2b 100644 --- a/sw/qa/core/header_footer/HeaderFooterTest.cxx +++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx @@ -97,8 +97,11 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testNonFirstHeaderIsDisabled) createSwDoc("tdf127778.docx"); -xmlDocUniquePtr pLayout = parseLayoutDump(); -assertXPath(pLayout, "//page[2]/header", 0); +// TODO + +// Header can only be enabled or disabled, but can't be disbaled just for first, left or right page. +// If a header is enabled but empty, the header still takes space in LO, but not in MSO, where it acts the same as +// if it is disabled. } // Check for correct header/footer with special first page with TOC inside @@ -114,8 +117,10 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testHeaderFooterWithSpecialFirstPage_OOXM { xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // check first page -assertXPath(pXmlDoc, "/root/page[1]/header", 0); -assertXPath(pXmlDoc, "/root/page[1]/footer", 0); +assertXPath(pXmlDoc, "/root/page[1]/header"); +assertXPath(pXmlDoc, "/root/page[1]/footer"); +assertXPath(pXmlDoc, "/root/page[1]/header/txt/text()", 0); +assertXPath(pXmlDoc, "/root/page[1]/footer/txt/text()", 0); // check second page in the same way assertXPath(pXmlDoc, "/root/page[2]/header"); assertXPath(pXmlDoc, "/root/page[2]/footer"); @@ -448,7 +453,9 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf112694) uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard"); // Header was on when header for file was for explicit first pages only // (marked via ). -CPPUNIT_ASSERT(!getProperty(aPageStyle, "HeaderIsOn")); +//CPPUNIT_ASSERT(!getProperty(aPageStyle, "HeaderIsOn")); +// TODO - can't disable headers/footers selectively (only fo first page) +CPPUNIT_ASSERT(getProperty(aPageStyle, "HeaderIsOn")); }; createSwDoc("tdf112694.docx"); @@ -649,7 +656,11 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest,
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sw/inc sw/qa sw/source
sw/inc/pagedesc.hxx |2 - sw/qa/core/header_footer/HeaderFooterTest.cxx | 40 ++ sw/source/core/doc/docfmt.cxx | 33 - sw/source/core/layout/pagedesc.cxx|2 - 4 files changed, 73 insertions(+), 4 deletions(-) New commits: commit af20a7544531d074cd3e40f736e9c1e6a4e0 Author: Tomaž Vajngerl AuthorDate: Thu Nov 30 16:42:26 2023 +0900 Commit: Miklos Vajna CommitDate: Mon Dec 4 09:00:16 2023 +0100 sw: fix issue with copying stashed frame format When the PageDesc is copied from one document to another, we don't make sure the stashed FrameFormat(s) are also properly copied to the new document (which can happen at copy/paste). This can cause a crash if the stashed FrameFormats are accessed or destructed after the original document is destroyed. This fixes the issue so that when we detect the PageDesc belong to different documents, the stashed FrameFormats are copied just like the non-stashed FrameFormats (used for headers and footers). Change-Id: I948068dba4d39bb47c3725dfa8491c53c5833c7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160065 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 963de9feb37105560fde14b44d992e47f341bb5b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160192 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 382bbb5f00cd..11bb347aa1fb 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -223,7 +223,7 @@ public: const SwFrameFormat* GetStashedFrameFormat(bool bHeader, bool bLeft, bool bFirst) const; /// Checks if the pagedescriptor has a stashed format according to the parameters or not. -bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst); +bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst) const; /// Gives the feature of removing the stashed format by hand if it is necessary. void RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst); diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx b/sw/qa/core/header_footer/HeaderFooterTest.cxx index 1f1dd5c2db70..23e91a2db4b1 100644 --- a/sw/qa/core/header_footer/HeaderFooterTest.cxx +++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx @@ -49,6 +49,46 @@ public: } }; +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testStashedHeaderFooter) +{ +createSwDoc(); +SwDoc* pSourceDocument = getSwDoc(); +uno::Reference xSourceDocument = mxComponent; +mxComponent.clear(); + +createSwDoc(); +SwDoc* pTargetDocument = getSwDoc(); +uno::Reference xTargetDocument = mxComponent; +mxComponent.clear(); + +// Source +SwPageDesc* pSourcePageDesc = pSourceDocument->MakePageDesc("SourceStyle"); +pSourcePageDesc->ChgFirstShare(false); +CPPUNIT_ASSERT(!pSourcePageDesc->IsFirstShared()); +pSourcePageDesc->StashFrameFormat(pSourcePageDesc->GetFirstMaster(), true, false, true); +pSourceDocument->ChgPageDesc("SourceStyle", *pSourcePageDesc); +CPPUNIT_ASSERT(pSourcePageDesc->HasStashedFormat(true, false, true)); + +// Target +SwPageDesc* pTargetPageDesc = pTargetDocument->MakePageDesc("TargetStyle"); + +// Copy source to target +pTargetDocument->CopyPageDesc(*pSourcePageDesc, *pTargetPageDesc); + +// Check the stashed frame format is copied +CPPUNIT_ASSERT(pTargetPageDesc->HasStashedFormat(true, false, true)); + +// Check document instance +auto pSourceStashedFormat = pSourcePageDesc->GetStashedFrameFormat(true, false, true); +CPPUNIT_ASSERT_EQUAL(true, pSourceStashedFormat->GetDoc() == pSourceDocument); + +auto pTargetStashedFormat = pTargetPageDesc->GetStashedFrameFormat(true, false, true); +CPPUNIT_ASSERT_EQUAL(true, pTargetStashedFormat->GetDoc() == pTargetDocument); + +xSourceDocument->dispose(); +xTargetDocument->dispose(); +} + CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testNonFirstHeaderIsDisabled) { // related to tdf#127778 diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 9e8df615959a..97fddbdbc87d 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1542,14 +1542,43 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc, // Copy the stashed formats as well between the page descriptors... for (bool bFirst : { true, false }) +{ for (bool bLeft : { true, false }) +{ for (bool bHeader : { true, false }) { if (!bLeft && !bFirst) continue; -if (auto pStashedFormat = rSrcDesc.GetStashedFrameFormat(bHeader, bLeft, bFirst)) -rDstDesc.StashFrameFormat(*pStashedFormat, bHeader, bLeft, bFirst); + +// Copy format only if it exists +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sw/CppunitTest_sw_core_header_footer.mk sw/Module_sw.mk sw/qa
dev/null |binary sw/CppunitTest_sw_core_header_footer.mk| 73 sw/Module_sw.mk|1 sw/qa/core/header_footer/HeaderFooterTest.cxx | 1253 + sw/qa/core/header_footer/data/DoubleFirstLeftRight.docx|binary sw/qa/core/header_footer/data/DoubleFirstLeftRight.odt |binary sw/qa/core/header_footer/data/FirstPageHeaderShape.docx|binary sw/qa/core/header_footer/data/FirstPageHeaderShape.odt |binary sw/qa/core/header_footer/data/SimpleFirstLeftRight.docx|binary sw/qa/core/header_footer/data/SimpleFirstLeftRight.odt |binary sw/qa/core/header_footer/data/TestFirstFooterDisabled.docx |binary sw/qa/core/header_footer/data/TestPageStyleOnlyLeft.docx |binary sw/qa/core/header_footer/data/tdf135216_evenOddFooter.docx |binary sw/qa/extras/odfexport/odfexport.cxx | 67 sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 135 - sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 26 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 26 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 43 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 45 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 17 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 67 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 14 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 18 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 127 - sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 226 -- sw/qa/extras/ww8export/ww8export.cxx | 20 26 files changed, 1327 insertions(+), 831 deletions(-) New commits: commit e3fbf91e934d172d16fa5e820b22aa0f5af57c59 Author: Tomaž Vajngerl AuthorDate: Fri Nov 24 12:55:25 2023 +0900 Commit: Miklos Vajna CommitDate: Mon Dec 4 08:57:02 2023 +0100 sw: move header/footer tests to own class in core tests In addition add some more basic header/footer tests. This makes refactoring of header and footer OOXML import much easier. Change-Id: I5b3b3714656ba2f7b1dda8d8f067c3bfe68857a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159946 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl (cherry picked from commit 9e876c164a1d9e552c08be3112ada09712a20eb3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160136 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/CppunitTest_sw_core_header_footer.mk b/sw/CppunitTest_sw_core_header_footer.mk new file mode 100644 index ..5f1668c3fb49 --- /dev/null +++ b/sw/CppunitTest_sw_core_header_footer.mk @@ -0,0 +1,73 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#* +# +# 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/. +# +#* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_header_footer, \ +sw/qa/core/header_footer/HeaderFooterTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_core_header_footer, \ +comphelper \ +cppu \ +cppuhelper \ +sal \ +sfx \ +subsequenttest \ +sw \ +swqahelper \ +test \ +unotest \ +utl \ +vcl \ +svt \ +tl \ +svl \ +svxcore \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_core_header_footer,\ +boost_headers \ +libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_core_header_footer,\ +-I$(SRCDIR)/sw/inc \ +-I$(SRCDIR)/sw/source/core/inc \ +-I$(SRCDIR)/sw/source/uibase/inc \ +-I$(SRCDIR)/sw/qa/inc \ +$$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_core_header_footer,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_core_header_footer)) +$(eval $(call gb_CppunitTest_use_vcl,sw_core_header_footer)) +$(eval $(call gb_CppunitTest_use_rdb,sw_core_header_footer,services)) +$(eval $(call gb_CppunitTest_use_configuration,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_header_footer,\ +officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_header_footer, \ +modules/swriter \ +svt \ +svx \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 33ff9de9081f..6d4d1f816c40 100644
[Libreoffice-commits] core.git: include/oox oox/source
include/oox/export/drawingml.hxx | 29 ++-- oox/source/export/drawingml.cxx | 253 +++ oox/source/export/shapes.cxx | 10 - 3 files changed, 145 insertions(+), 147 deletions(-) New commits: commit 1be8b2752d30d3c024e46526e9d31c1e7066799c Author: Tomaž Vajngerl AuthorDate: Sun Dec 3 12:53:58 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sun Dec 3 11:09:25 2023 +0100 oox: Refactor and simplify writing to storage with GraphicExport Change-Id: I743dc99e0228b59050fb4926c8ef56bed8e82060 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160252 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index d50023be1c17..9028cfdc0f9f 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -140,28 +140,28 @@ protected: virtual ~DMLTextExport() {} }; -constexpr const char* getComponentDir(DocumentType eDocumentType) +constexpr std::u16string_view getComponentDir(DocumentType eDocumentType) { switch (eDocumentType) { -case DOCUMENT_DOCX: return "word"; -case DOCUMENT_PPTX: return "ppt"; -case DOCUMENT_XLSX: return "xl"; +case DOCUMENT_DOCX: return u"word"; +case DOCUMENT_PPTX: return u"ppt"; +case DOCUMENT_XLSX: return u"xl"; } -return ""; +return u""; } -constexpr const char* getRelationCompPrefix(DocumentType eDocumentType) +constexpr std::u16string_view getRelationCompPrefix(DocumentType eDocumentType) { switch (eDocumentType) { -case DOCUMENT_DOCX: return ""; +case DOCUMENT_DOCX: return u""; case DOCUMENT_PPTX: -case DOCUMENT_XLSX: return "../"; +case DOCUMENT_XLSX: return u"../"; } -return ""; +return u""; } class OOX_DLLPUBLIC GraphicExportCache @@ -251,12 +251,15 @@ public: } }; -class GraphicExport +class OOX_DLLPUBLIC GraphicExport { +private: sax_fastparser::FSHelperPtr mpFS; oox::core::XmlFilterBase* mpFilterBase; DocumentType meDocumentType; +OUString writeNewEntryToStorage(const Graphic& rGraphic, bool bRelPathToMedia); + public: GraphicExport(sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFilterBase, DocumentType eDocumentType) : mpFS(pFS) @@ -320,8 +323,8 @@ protected: void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties ); -const char* GetComponentDir() const; -const char* GetRelationCompPrefix() const; +OUString GetComponentDir() const; +OUString GetRelationCompPrefix() const; static bool EqualGradients( const css::awt::Gradient2& rGradient1, const css::awt::Gradient2& rGradient2 ); bool IsFontworkShape(const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet); @@ -350,7 +353,7 @@ public: void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; } /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship -OUString writeGraphicToStorage( const Graphic , bool bRelPathToMedia = false ); +OUString writeGraphicToStorage(const Graphic , bool bRelPathToMedia = false); void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT ); void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 8c2abb6b07cc..87c693a9cd75 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1273,14 +1273,14 @@ void DrawingML::WriteOutline( const Reference& rXPropSet, Referenc mpFS->endElementNS( XML_a, XML_ln ); } -const char* DrawingML::GetComponentDir() const +OUString DrawingML::GetComponentDir() const { -return getComponentDir(meDocumentType); +return OUString(getComponentDir(meDocumentType)); } -const char* DrawingML::GetRelationCompPrefix() const +OUString DrawingML::GetRelationCompPrefix() const { -return getRelationCompPrefix(meDocumentType); +return OUString(getRelationCompPrefix(meDocumentType)); } void GraphicExport::writeBlip(Graphic const& rGraphic, std::vector const& rEffects, bool bRelPathToMedia) @@ -1401,134 +1401,135 @@ void GraphicExport::writeBlip(Graphic const& rGraphic, std::vectorendElementNS(XML_a, XML_blip); } -OUString GraphicExport::writeToStorage(const Graphic& rGraphic , bool bRelPathToMedia) +OUString GraphicExport::writeNewEntryToStorage(const Graphic& rGraphic, bool bRelPathToMedia) { -GfxLink aLink = rGraphic.GetGfxLink (); -BitmapChecksum aChecksum = rGraphic.GetChecksum(); +GfxLink const& rLink = rGraphic.GetGfxLink(); + OUString sMediaType; -const char* pExtension = ""; -OUString sRelId; -OUString sPath; +
[Libreoffice-commits] core.git: xmloff/source
xmloff/source/text/XMLTextFrameContext.cxx |1 - 1 file changed, 1 deletion(-) New commits: commit 91b39a9dad0563726ea2100557e3c88c24be2e61 Author: Tomaž Vajngerl AuthorDate: Sat Dec 2 21:42:25 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Dec 2 13:44:38 2023 +0100 remove printf Change-Id: Ib83b5c3b0f80310cd11f7cd8cd83e82d11e12eb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160241 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 723a168a52b9..b00b2b84d90e 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -1082,7 +1082,6 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( case XML_ELEMENT(DRAW, XML_MIME_TYPE): case XML_ELEMENT(LO_EXT, XML_MIME_TYPE): sMimeType = aIter.toString(); -printf ("MIME %s\n", sMimeType.toUtf8().getStr()); break; case XML_ELEMENT(DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES): case XML_ELEMENT(DRAW, XML_NOTIFY_ON_UPDATE_OF_TABLE):
[Libreoffice-commits] core.git: sw/qa xmloff/inc xmloff/source
sw/qa/extras/fodfexport/data/SvgImageTest.fodt | 321 + sw/qa/extras/fodfexport/fodfexport.cxx | 25 + xmloff/inc/xmlmultiimagehelper.hxx |1 xmloff/source/core/xmlmultiimagehelper.cxx | 28 +- xmloff/source/draw/ximpshap.cxx| 24 + xmloff/source/draw/ximpshap.hxx|3 xmloff/source/text/XMLTextFrameContext.cxx | 12 xmloff/source/text/XMLTextFrameContext.hxx |1 8 files changed, 400 insertions(+), 15 deletions(-) New commits: commit f5cf0c10eb7050feff19190b06b4597aab2d400a Author: Tomaž Vajngerl AuthorDate: Sat Dec 2 16:57:30 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Dec 2 11:10:34 2023 +0100 tdf#123396 actually use the mimetype set in the from document In the document we set the mime type for the images stored, but at import we never actually used the mime types. We always did mime type detection from the filename extension. The problem with this is that files stored as base64 streams don't have a filename so it is also not possible to determine the mime type from the file name. The consequence of this is that we can't know which image to take if we have multiple images (fallback images) so we always take the last one, which could be the wrong one. This happend in the test document. This changes the behavior so that we always first use the document set mime type as there is no reason to not trust that. Only if the mime type isn't provided by the document we use other mime type detection methods. Change-Id: I175c509ce5f11eab2c0454d4d9901ca1fe975272 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160237 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/qa/extras/fodfexport/data/SvgImageTest.fodt b/sw/qa/extras/fodfexport/data/SvgImageTest.fodt new file mode 100644 index ..4246a7cb5e5e --- /dev/null +++ b/sw/qa/extras/fodfexport/data/SvgImageTest.fodt @@ -0,0 +1,321 @@ + + +http://www.w3.org/TR/css3-text/; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer; xmlns:xlink="http://www.w3.org/1999/xlink; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table; xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report; xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office; xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + 2023-12-01T21:40:25.0108966092023-12-02T14:20:24.763250978PT2M41S2LibreOffice/7.6.3.1$Linux_X86_64 LibreOffice_project/60$Build-1 + + + 0 + 0 + 58104 + 33657 + true + false + + + view2 + 20551 + 17866 + 0 + 0 + 58103 + 33655 + 0 + 1 + false + 100 + false + false + false + false + false + false + + + + + true + false + true + false + true + false + false + 0 + true + false + true + false + false + false + false + true + false + false + + false + false + true + false + false + true + true + false + false + false + false + false + false + true + false + false + 925541 +
[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/qa writerfilter/source
sw/qa/core/header_footer/HeaderFooterTest.cxx | 74 - sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |3 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 13 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |4 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx |9 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |4 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |3 sw/qa/extras/rtfexport/rtfexport.cxx |3 sw/qa/extras/rtfexport/rtfexport2.cxx |6 sw/qa/extras/rtfexport/rtfexport3.cxx | 35 sw/qa/extras/rtfexport/rtfexport5.cxx |2 sw/qa/extras/rtfimport/rtfimport.cxx | 18 sw/source/filter/ww8/rtfexport.cxx |9 writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx |1 writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx |3 writerfilter/source/dmapper/DomainMapper_Impl.cxx | 214 +++- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 60 - writerfilter/source/dmapper/PropertyIds.cxx|3 writerfilter/source/dmapper/PropertyIds.hxx|3 writerfilter/source/dmapper/PropertyMap.cxx| 663 ++--- writerfilter/source/dmapper/PropertyMap.hxx| 83 + 21 files changed, 711 insertions(+), 502 deletions(-) New commits: commit 4b0fa253a4540f5461397815d290586f9ddabe61 Author: Tomaž Vajngerl AuthorDate: Tue Nov 28 13:46:21 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 1 08:26:38 2023 +0100 tdf#136472 adjust ooxml import to handle first header/footer Previously the ooxml import added a new page style when the first header or footer was detected. Since then we gained support to add first page header/footer in an existing page style so we don't need to import it like that anymore. This changes the import code so that the old complication to add "First Page" page style is removed and it always just uses the "Standard" page style for all 3 cases: first, left and right headers and footers. This also adjusts the existing tests to align with this change. Change-Id: Ibf69597e6990499ac520ea9e323a5f73f429800b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157860 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx b/sw/qa/core/header_footer/HeaderFooterTest.cxx index b411632884e1..d67e874df0ec 100644 --- a/sw/qa/core/header_footer/HeaderFooterTest.cxx +++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx @@ -96,8 +96,11 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testNonFirstHeaderIsDisabled) createSwDoc("tdf127778.docx"); -xmlDocUniquePtr pLayout = parseLayoutDump(); -assertXPath(pLayout, "//page[2]/header"_ostr, 0); +// TODO + +// Header can only be enabled or disabled, but can't be disbaled just for first, left or right page. +// If a header is enabled but empty, the header still takes space in LO, but not in MSO, where it acts the same as +// if it is disabled. } // Check for correct header/footer with special first page with TOC inside @@ -113,8 +116,10 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testHeaderFooterWithSpecialFirstPage_OOXM { xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // check first page -assertXPath(pXmlDoc, "/root/page[1]/header"_ostr, 0); -assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr, 0); +assertXPath(pXmlDoc, "/root/page[1]/header"_ostr); +assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr); +assertXPath(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr, 0); +assertXPath(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr, 0); // check second page in the same way assertXPath(pXmlDoc, "/root/page[2]/header"_ostr); assertXPath(pXmlDoc, "/root/page[2]/footer"_ostr); @@ -463,7 +468,9 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf112694) uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard"); // Header was on when header for file was for explicit first pages only // (marked via ). -CPPUNIT_ASSERT(!getProperty(aPageStyle, "HeaderIsOn")); +//CPPUNIT_ASSERT(!getProperty(aPageStyle, "HeaderIsOn")); +// TODO - can't disable headers/footers selectively (only fo first page) +CPPUNIT_ASSERT(getProperty(aPageStyle, "HeaderIsOn")); }; createSwDoc("tdf112694.docx"); @@ -664,7 +671,10 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testFirstPageFooterEnabled) // Footer shouldn't be enabled on first page, but then on the other pages auto verify = [this]() { xmlDocUniquePtr pXmlDoc = parseLayoutDump(); -assertXPath(pXmlDoc, "/root/page[1]/footer/txt"_ostr,
[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
sw/inc/pagedesc.hxx |2 - sw/qa/core/header_footer/HeaderFooterTest.cxx | 40 ++ sw/source/core/doc/docfmt.cxx | 33 - sw/source/core/layout/pagedesc.cxx|2 - 4 files changed, 73 insertions(+), 4 deletions(-) New commits: commit 963de9feb37105560fde14b44d992e47f341bb5b Author: Tomaž Vajngerl AuthorDate: Thu Nov 30 16:42:26 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Fri Dec 1 05:07:42 2023 +0100 sw: fix issue with copying stashed frame format When the PageDesc is copied from one document to another, we don't make sure the stashed FrameFormat(s) are also properly copied to the new document (which can happen at copy/paste). This can cause a crash if the stashed FrameFormats are accessed or destructed after the original document is destroyed. This fixes the issue so that when we detect the PageDesc belong to different documents, the stashed FrameFormats are copied just like the non-stashed FrameFormats (used for headers and footers). Change-Id: I948068dba4d39bb47c3725dfa8491c53c5833c7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160065 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 382bbb5f00cd..11bb347aa1fb 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -223,7 +223,7 @@ public: const SwFrameFormat* GetStashedFrameFormat(bool bHeader, bool bLeft, bool bFirst) const; /// Checks if the pagedescriptor has a stashed format according to the parameters or not. -bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst); +bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst) const; /// Gives the feature of removing the stashed format by hand if it is necessary. void RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst); diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx b/sw/qa/core/header_footer/HeaderFooterTest.cxx index 8b78363a0c1b..b411632884e1 100644 --- a/sw/qa/core/header_footer/HeaderFooterTest.cxx +++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx @@ -48,6 +48,46 @@ public: } }; +CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testStashedHeaderFooter) +{ +createSwDoc(); +SwDoc* pSourceDocument = getSwDoc(); +uno::Reference xSourceDocument = mxComponent; +mxComponent.clear(); + +createSwDoc(); +SwDoc* pTargetDocument = getSwDoc(); +uno::Reference xTargetDocument = mxComponent; +mxComponent.clear(); + +// Source +SwPageDesc* pSourcePageDesc = pSourceDocument->MakePageDesc("SourceStyle"); +pSourcePageDesc->ChgFirstShare(false); +CPPUNIT_ASSERT(!pSourcePageDesc->IsFirstShared()); +pSourcePageDesc->StashFrameFormat(pSourcePageDesc->GetFirstMaster(), true, false, true); +pSourceDocument->ChgPageDesc("SourceStyle", *pSourcePageDesc); +CPPUNIT_ASSERT(pSourcePageDesc->HasStashedFormat(true, false, true)); + +// Target +SwPageDesc* pTargetPageDesc = pTargetDocument->MakePageDesc("TargetStyle"); + +// Copy source to target +pTargetDocument->CopyPageDesc(*pSourcePageDesc, *pTargetPageDesc); + +// Check the stashed frame format is copied +CPPUNIT_ASSERT(pTargetPageDesc->HasStashedFormat(true, false, true)); + +// Check document instance +auto pSourceStashedFormat = pSourcePageDesc->GetStashedFrameFormat(true, false, true); +CPPUNIT_ASSERT_EQUAL(true, pSourceStashedFormat->GetDoc() == pSourceDocument); + +auto pTargetStashedFormat = pTargetPageDesc->GetStashedFrameFormat(true, false, true); +CPPUNIT_ASSERT_EQUAL(true, pTargetStashedFormat->GetDoc() == pTargetDocument); + +xSourceDocument->dispose(); +xTargetDocument->dispose(); +} + CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testNonFirstHeaderIsDisabled) { // related to tdf#127778 diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index d5854b3633e6..57c42c529eb1 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1540,14 +1540,43 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc, // Copy the stashed formats as well between the page descriptors... for (bool bFirst : { true, false }) +{ for (bool bLeft : { true, false }) +{ for (bool bHeader : { true, false }) { if (!bLeft && !bFirst) continue; -if (auto pStashedFormat = rSrcDesc.GetStashedFrameFormat(bHeader, bLeft, bFirst)) -rDstDesc.StashFrameFormat(*pStashedFormat, bHeader, bLeft, bFirst); + +// Copy format only if it exists +if (auto pStashedFormatSrc = rSrcDesc.GetStashedFrameFormat(bHeader, bLeft, bFirst)) +{ +if (pStashedFormatSrc->GetDoc() != this) +{ +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - writerfilter/source
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 80 -- writerfilter/source/dmapper/DomainMapper_Impl.hxx |6 - 2 files changed, 32 insertions(+), 54 deletions(-) New commits: commit ed8daf521b59361efc7c6bc716a9d2cc83724b88 Author: Tomaž Vajngerl AuthorDate: Wed Oct 11 23:09:00 2023 +0900 Commit: Miklos Vajna CommitDate: Thu Nov 30 11:20:24 2023 +0100 writerfilter: clean-up PushPageHeaderFooter method impl. in addition change m_aHeaderFooterTextAppendStack to use enum PagePartType for the "second" value in pair, instead of a bool to denote if it is an entry for header or footer. No change in functionality. Change-Id: I2aa75494c9b3337dd51bf79e282291cdca9d8547 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157839 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 7bd401fa4e458c4ca16f7eb88289d50059e1d32e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160135 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index ae02cd20d5ca..6b86f8af5557 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3279,10 +3279,10 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b { while (!m_aHeaderFooterTextAppendStack.empty()) { -auto aFooterHeader = m_aHeaderFooterTextAppendStack.top(); -if ((aFooterHeader.second && !bDynamicHeightTop) || (!aFooterHeader.second && !bDynamicHeightBottom)) +auto& [aTextAppendContext, ePagePartType] = m_aHeaderFooterTextAppendStack.top(); +if ((ePagePartType == PagePartType::Header && !bDynamicHeightTop) || (ePagePartType == PagePartType::Footer && !bDynamicHeightBottom)) { -uno::Reference< text::XTextAppend > xTextAppend = aFooterHeader.first.xTextAppend; +uno::Reference< text::XTextAppend > xTextAppend = aTextAppendContext.xTextAppend; uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor(); uno::Reference< text::XTextRange > xRangeStart, xRangeEnd; @@ -3308,13 +3308,12 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b fillEmptyFrameProperties(aFrameProperties, false); // If it is a footer, then orient the frame to the bottom -if (!aFooterHeader.second) +if (ePagePartType == PagePartType::Footer) +{ aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_VERT_ORIENT), text::VertOrientation::BOTTOM)); - -uno::Reference xBodyText( -xRangeStart->getText(), uno::UNO_QUERY); -xBodyText->convertToTextFrame(xTextAppend, xRangeEnd, -comphelper::containerToSequence(aFrameProperties)); +} +uno::Reference xBodyText(xRangeStart->getText(), uno::UNO_QUERY); +xBodyText->convertToTextFrame(xTextAppend, xRangeEnd, comphelper::containerToSequence(aFrameProperties)); } m_aHeaderFooterTextAppendStack.pop(); } @@ -3332,7 +3331,7 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageTyp const PropertyIds ePropIsOn = bHeader ? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; const PropertyIds ePropShared = bHeader ? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; const PropertyIds ePropTextLeft = bHeader ? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; -const PropertyIds ePropText = bHeader ? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; +const PropertyIds ePropTextRight = bHeader ? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; m_bDiscardHeaderFooter = true; m_eInHeaderFooterImport = bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer; @@ -3340,8 +3339,8 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageTyp //get the section context PropertyMapPtr pContext = DomainMapper_Impl::GetTopContextOfType(CONTEXT_SECTION); //ask for the header/footer name of the given type -SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() ); -if(!pSectionContext) +SectionPropertyMap* pSectionContext = dynamic_cast(pContext.get()); +if (!pSectionContext) return; // clear the "Link To Previous" flag so that the header/footer @@ -3358,31 +3357,24 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageTyp return; try { -bool bLeft = eType == PageType::LEFT; -bool bFirst = eType == PageType::FIRST; -if (!bLeft || GetSettingsTable()->GetEvenAndOddHeaders()) +const PropertyIds ePropText = eType == PageType::LEFT ? ePropTextLeft :
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sw/qa
sw/qa/extras/ooxmlimport/data/SimpleFirst.docx |binary sw/qa/extras/ooxmlimport/data/SimpleFirst.odt |binary sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx |binary sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt |binary sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx |binary sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt |binary sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 214 7 files changed, 214 insertions(+) New commits: commit b82a2a6b7694d07cb12b46f70312e142a107631e Author: Tomaž Vajngerl AuthorDate: Wed Oct 11 22:46:03 2023 +0900 Commit: Miklos Vajna CommitDate: Thu Nov 30 10:58:42 2023 +0100 sw: prepare tests cases for first, left, right headers and variants This prepares the test case for first, left, right headers, only first and non-first headers, only left and right (no first) headers and make them run for ODF, where they should work as expected. In a follow up commit, the OOXML implementation should be fixed so that the same tests pass for OOXML documents. Change-Id: I1e7f610324c14dd9eb285ff9d46829610de5b1b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157838 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 955ca0eba5c9ec22fbae0fc3e6220914ec3d69be) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160134 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx b/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx new file mode 100644 index ..1641a2d084ed Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt b/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt new file mode 100644 index ..fc165e966f85 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx new file mode 100644 index ..2b530a5e324f Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt new file mode 100644 index ..d5035ac8f581 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx new file mode 100644 index ..80dbda0420d7 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt new file mode 100644 index ..61302944da30 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index dfda91089b40..5c050982a0d6 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -48,6 +48,10 @@ class Test : public SwModelTestBase { public: +void checkFirstLeftRightHeaderPageStyles(); +void checkFirstRestHeaderPageStyles(); +void checkLeftRightHeaderPageStyles(); + Test() : SwModelTestBase("/sw/qa/extras/ooxmlimport/data/", "Office Open XML Text") { @@ -1197,6 +1201,216 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141969) CPPUNIT_ASSERT_EQUAL(8.0f, getProperty(xRun, "CharHeight")); } +void Test::checkFirstLeftRightHeaderPageStyles() +{ +// Page 1 +{ +OUString pageStyle; +uno::Reference xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY); + +uno::Reference xTextRange(xPropertySet, uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Para 1"), xTextRange->getString()); + +xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; +CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); +} + +// Page 2 +{ +OUString pageStyle; +uno::Reference xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY); + +uno::Reference xTextRange(xPropertySet, uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Para 2"), xTextRange->getString()); + +xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; +CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); +} + +// Page 3 +{ +OUString pageStyle; +uno::Reference xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY); + +uno::Reference xTextRange(xPropertySet, uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Para 3"), xTextRange->getString()); + +xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - writerfilter/source
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 31 +- writerfilter/source/dmapper/DomainMapper_Impl.hxx |6 ++-- writerfilter/source/dmapper/PropertyMap.cxx | 12 writerfilter/source/dmapper/PropertyMap.hxx | 14 - 4 files changed, 29 insertions(+), 34 deletions(-) New commits: commit 5888287530d41304e29dd39453b62003829b89b3 Author: Tomaž Vajngerl AuthorDate: Mon Oct 2 08:15:06 2023 +0200 Commit: Miklos Vajna CommitDate: Thu Nov 30 10:57:57 2023 +0100 change PageType (first, left, right) enum to enum class Change-Id: I45bb7947266de1e18028c7ed460149c609e430b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157834 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit e3d09d2e525ef6d5b93c6646e3cadc3f01297ea0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160133 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 5b27c8c889af..ae02cd20d5ca 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3320,7 +3320,7 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b } } -void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageType eType) { m_bSaveParaHadField = m_bParaHadField; m_aHeaderFooterStack.push(HeaderFooterContext(m_bTextInserted, m_nTableDepth)); @@ -3353,22 +3353,17 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, Section return; // TODO sw cannot Undo insert header/footer without crashing } -uno::Reference< beans::XPropertySet > xPageStyle = -pSectionContext->GetPageStyle( -*this, -eType == SectionPropertyMap::PAGE_FIRST ); +uno::Reference xPageStyle = pSectionContext->GetPageStyle(*this, eType == PageType::FIRST); if (!xPageStyle.is()) return; try { -bool bLeft = eType == SectionPropertyMap::PAGE_LEFT; -bool bFirst = eType == SectionPropertyMap::PAGE_FIRST; +bool bLeft = eType == PageType::LEFT; +bool bFirst = eType == PageType::FIRST; if (!bLeft || GetSettingsTable()->GetEvenAndOddHeaders()) { //switch on header/footer use -xPageStyle->setPropertyValue( -getPropertyName(ePropIsOn), -uno::Any(true)); +xPageStyle->setPropertyValue(getPropertyName(ePropIsOn), uno::Any(true)); // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it // Even if the 'Even' header/footer is blank - the flag should be imported (so it would look in LO like in Word) @@ -3419,12 +3414,12 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, Section } } -void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageHeader(PageType eType) { PushPageHeaderFooter(PagePartType::Header, eType); } -void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageFooter(PageType eType) { PushPageHeaderFooter(PagePartType::Footer, eType); } @@ -9220,22 +9215,22 @@ void DomainMapper_Impl::substream(Id rName, switch( rName ) { case NS_ooxml::LN_headerl: -PushPageHeader(SectionPropertyMap::PAGE_LEFT); +PushPageHeader(PageType::LEFT); break; case NS_ooxml::LN_headerr: -PushPageHeader(SectionPropertyMap::PAGE_RIGHT); +PushPageHeader(PageType::RIGHT); break; case NS_ooxml::LN_headerf: -PushPageHeader(SectionPropertyMap::PAGE_FIRST); +PushPageHeader(PageType::FIRST); break; case NS_ooxml::LN_footerl: -PushPageFooter(SectionPropertyMap::PAGE_LEFT); +PushPageFooter(PageType::LEFT); break; case NS_ooxml::LN_footerr: -PushPageFooter(SectionPropertyMap::PAGE_RIGHT); +PushPageFooter(PageType::RIGHT); break; case NS_ooxml::LN_footerf: -PushPageFooter(SectionPropertyMap::PAGE_FIRST); +PushPageFooter(PageType::FIRST); break; case NS_ooxml::LN_footnote: case NS_ooxml::LN_endnote: diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 7f39d99aed37..fc6518fd7d7e 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -876,8 +876,8 @@ public: /// Get the first pending shape, if there are any. css::uno::Reference PopPendingShape();
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - writerfilter/source
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 19 ++- writerfilter/source/dmapper/DomainMapper_Impl.hxx |8 +++- 2 files changed, 17 insertions(+), 10 deletions(-) New commits: commit 836eb425bb000acdb05125e64e3f8ecdb166f875 Author: Tomaž Vajngerl AuthorDate: Wed Sep 20 21:22:54 2023 +0200 Commit: Miklos Vajna CommitDate: Thu Nov 30 10:56:03 2023 +0100 change bool header or footer parameter to use enum type instead Is much more readable. Change-Id: Ie81aaf344758182915796b18efbe25d3f45df4b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157236 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit c90de36ede6d35e2cf1ebea195e0ff28f618f319) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160132 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 722b616ac4d2..5b27c8c889af 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3320,21 +3320,22 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b } } -void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, SectionPropertyMap::PageType eType) { m_bSaveParaHadField = m_bParaHadField; m_aHeaderFooterStack.push(HeaderFooterContext(m_bTextInserted, m_nTableDepth)); m_bTextInserted = false; m_nTableDepth = 0; -const PropertyIds ePropIsOn = bHeader? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; -const PropertyIds ePropShared = bHeader? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; -const PropertyIds ePropTextLeft = bHeader? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; -const PropertyIds ePropText = bHeader? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; +bool bHeader = ePagePartType == PagePartType::Header; + +const PropertyIds ePropIsOn = bHeader ? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; +const PropertyIds ePropShared = bHeader ? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; +const PropertyIds ePropTextLeft = bHeader ? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; +const PropertyIds ePropText = bHeader ? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; m_bDiscardHeaderFooter = true; -m_eInHeaderFooterImport -= bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer; +m_eInHeaderFooterImport = bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer; //get the section context PropertyMapPtr pContext = DomainMapper_Impl::GetTopContextOfType(CONTEXT_SECTION); @@ -3420,12 +3421,12 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType) { -PushPageHeaderFooter(/* bHeader = */ true, eType); +PushPageHeaderFooter(PagePartType::Header, eType); } void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType) { -PushPageHeaderFooter(/* bHeader = */ false, eType); +PushPageHeaderFooter(PagePartType::Footer, eType); } void DomainMapper_Impl::PopPageHeaderFooter() diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 5c2a128a2b11..7f39d99aed37 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -447,6 +447,12 @@ struct SymbolData { } }; +enum class PagePartType +{ +Header, +Footer +}; + class DomainMapper; class DomainMapper_Impl final { @@ -1214,7 +1220,7 @@ public: OUString ConvertTOCStyleName(OUString const&); private: -void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType); +void PushPageHeaderFooter(PagePartType ePagePartType, SectionPropertyMap::PageType eType); // Start a new index section; if needed, finish current paragraph css::uno::Reference StartIndexSectionChecked(const OUString& sServiceName); std::vector > m_vTextFramesForChaining ;
[Libreoffice-commits] core.git: sw/CppunitTest_sw_core_header_footer.mk sw/Module_sw.mk sw/qa
dev/null |binary sw/CppunitTest_sw_core_header_footer.mk| 73 sw/Module_sw.mk|1 sw/qa/core/header_footer/HeaderFooterTest.cxx | 1274 + sw/qa/core/header_footer/data/DoubleFirstLeftRight.docx|binary sw/qa/core/header_footer/data/DoubleFirstLeftRight.odt |binary sw/qa/core/header_footer/data/FirstPageHeaderShape.docx|binary sw/qa/core/header_footer/data/FirstPageHeaderShape.odt |binary sw/qa/core/header_footer/data/SimpleFirstLeftRight.docx|binary sw/qa/core/header_footer/data/SimpleFirstLeftRight.odt |binary sw/qa/core/header_footer/data/TestFirstFooterDisabled.docx |binary sw/qa/core/header_footer/data/TestPageStyleOnlyLeft.docx |binary sw/qa/core/header_footer/data/tdf135216_evenOddFooter.docx |binary sw/qa/extras/odfexport/odfexport.cxx | 61 sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 129 - sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 26 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 26 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 43 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 45 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 17 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 67 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 14 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 18 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 127 - sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 226 -- sw/qa/extras/ww8export/ww8export.cxx | 20 26 files changed, 1348 insertions(+), 819 deletions(-) New commits: commit 9e876c164a1d9e552c08be3112ada09712a20eb3 Author: Tomaž Vajngerl AuthorDate: Fri Nov 24 12:55:25 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Tue Nov 28 04:02:22 2023 +0100 sw: move header/footer tests to own class in core tests In addition add some more basic header/footer tests. This makes refactoring of header and footer OOXML import much easier. Change-Id: I5b3b3714656ba2f7b1dda8d8f067c3bfe68857a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159946 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/sw/CppunitTest_sw_core_header_footer.mk b/sw/CppunitTest_sw_core_header_footer.mk new file mode 100644 index ..5f1668c3fb49 --- /dev/null +++ b/sw/CppunitTest_sw_core_header_footer.mk @@ -0,0 +1,73 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#* +# +# 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/. +# +#* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_header_footer, \ +sw/qa/core/header_footer/HeaderFooterTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sw_core_header_footer, \ +comphelper \ +cppu \ +cppuhelper \ +sal \ +sfx \ +subsequenttest \ +sw \ +swqahelper \ +test \ +unotest \ +utl \ +vcl \ +svt \ +tl \ +svl \ +svxcore \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sw_core_header_footer,\ +boost_headers \ +libxml2 \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_core_header_footer,\ +-I$(SRCDIR)/sw/inc \ +-I$(SRCDIR)/sw/source/core/inc \ +-I$(SRCDIR)/sw/source/uibase/inc \ +-I$(SRCDIR)/sw/qa/inc \ +$$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sw_core_header_footer,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sw_core_header_footer)) +$(eval $(call gb_CppunitTest_use_vcl,sw_core_header_footer)) +$(eval $(call gb_CppunitTest_use_rdb,sw_core_header_footer,services)) +$(eval $(call gb_CppunitTest_use_configuration,sw_core_header_footer)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_header_footer,\ +officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_header_footer, \ +modules/swriter \ +svt \ +svx \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 22cea818178a..0123a56468de 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -158,6 +158,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_uibase_fldui \ CppunitTest_sw_core_view \
[Libreoffice-commits] core.git: sw/qa
sw/qa/unit/swmodeltestbase.cxx |8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) New commits: commit 6ef1728944b3e0ad0679a11cb17044b8d4401491 Author: Tomaž Vajngerl AuthorDate: Fri Nov 24 12:26:08 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Nov 25 06:22:15 2023 +0100 sw: prevent crash with assert in test base class Change-Id: I4450d38bfc8146828f0ea447d713ff746c33f101 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159945 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index 206f8dd53660..5029421a631a 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -210,8 +210,9 @@ OUString SwModelTestBase::parseDump(const OString& aXPath, const OString& aAttri if (pXmlXpathObj->type == XPATH_NODESET) { xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval; -CPPUNIT_ASSERT_EQUAL_MESSAGE("xpath should match exactly 1 node", 1, - xmlXPathNodeSetGetLength(pXmlNodes)); +int nNodes = xmlXPathNodeSetGetLength(pXmlNodes); +OString aMessage("xpath ('" + aXPath + "') should match exactly 1 node"); +CPPUNIT_ASSERT_EQUAL_MESSAGE(aMessage.getStr(), 1, nNodes); xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; if (aAttribute.getLength()) pXpathStrResult = xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr())); @@ -343,7 +344,8 @@ SwModelTestBase::getParagraphOfText(int number, uno::Reference cons const OUString& content) const { uno::Reference const xParagraph(getParagraphOrTable(number, xText), - uno::UNO_QUERY_THROW); + uno::UNO_QUERY); +CPPUNIT_ASSERT(xParagraph.is()); if (!content.isEmpty()) CPPUNIT_ASSERT_EQUAL_MESSAGE("paragraph does not contain expected content", content, xParagraph->getString());
[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 0 commits -
Rebased ref, commits from common ancestor:
[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 2923 commits - accessibility/inc accessibility/source android/source animations/source avmedia/inc avmedia/Library_avmedia.mk avmed
Rebased ref, commits from common ancestor: commit 97c00895af73a71825a402c3604d5e34e9dbef59 Author: Tomaž Vajngerl AuthorDate: Tue Jul 18 18:02:28 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Sat Oct 28 19:10:35 2023 +0900 basegfx: BColorStops shouldn't derive from std::vector Change-Id: I9f246c0d9a5ddc7f8cf428bf7fc8c8957e8584b6 diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index 86e1812d21ac..73767f3cc958 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -72,8 +72,8 @@ namespace basegfx // BColorStops for a single StartColor @0.0 & EndColor @1.0 BColorStops::BColorStops(const BColor& rStart, const BColor& rEnd) { -emplace_back(0.0, rStart); -emplace_back(1.0, rEnd); +maStops.emplace_back(0.0, rStart); +maStops.emplace_back(1.0, rEnd); } /* Helper to grep the correct ColorStop out of @@ -85,30 +85,30 @@ BColor BColorStops::getInterpolatedBColor(double fPosition, sal_uInt32 nRequeste BColorStopRange& rLastColorStopRange) const { // no color at all, done -if (empty()) +if (maStops.empty()) return BColor(); // outside range -> at start -const double fMin(front().getStopOffset()); +const double fMin(maStops.front().getStopOffset()); if (fPosition < fMin) -return front().getStopColor(); +return maStops.front().getStopColor(); // outside range -> at end -const double fMax(back().getStopOffset()); +const double fMax(maStops.back().getStopOffset()); if (fPosition > fMax) -return back().getStopColor(); +return maStops.back().getStopColor(); // special case for the 'classic' case with just two colors: // we can optimize that and keep the speed/resources low // by avoiding some calculations and an O(log(N)) array access -if (2 == size()) +if (2 == maStops.size()) { // if same StopOffset use front color if (fTools::equal(fMin, fMax)) -return front().getStopColor(); +return maStops.front().getStopColor(); -const basegfx::BColor aCStart(front().getStopColor()); -const basegfx::BColor aCEnd(back().getStopColor()); +const basegfx::BColor aCStart(maStops.front().getStopColor()); +const basegfx::BColor aCEnd(maStops.back().getStopColor()); // if colors are equal just return one if (aCStart == aCEnd) @@ -145,21 +145,22 @@ BColor BColorStops::getInterpolatedBColor(double fPosition, sal_uInt32 nRequeste // looping/accessing, but that's just due to the extensive // debug test code created by the stl. In a pro version, // all is good/fast as expected -const auto upperBound(std::upper_bound(begin(), end(), BColorStop(fPosition), +const auto upperBound(std::upper_bound(maStops.begin(), maStops.end(), + BColorStop(fPosition), [](const BColorStop& x, const BColorStop& y) { return x.getStopOffset() < y.getStopOffset(); })); // no upper bound, done -if (end() == upperBound) -return back().getStopColor(); +if (maStops.end() == upperBound) +return maStops.back().getStopColor(); // lower bound is one entry back, access that const auto lowerBound(upperBound - 1); // no lower bound, done -if (end() == lowerBound) -return back().getStopColor(); +if (maStops.end() == lowerBound) +return maStops.back().getStopColor(); // we have lower and upper bound, get colors and offsets rLastColorStopRange.maColorStart = lowerBound->getStopColor(); @@ -196,24 +197,24 @@ BColor BColorStops::getInterpolatedBColor(double fPosition, sal_uInt32 nRequeste */ void BColorStops::replaceStartColor(const BColor& rStart) { -BColorStops::iterator a1stNonStartColor(begin()); +auto a1stNonStartColor(maStops.begin()); // search for highest existing non-StartColor - CAUTION, // there might be none, one or multiple with StopOffset 0.0 -while (a1stNonStartColor != end() +while (a1stNonStartColor != maStops.end() && basegfx::fTools::lessOrEqual(a1stNonStartColor->getStopOffset(), 0.0)) a1stNonStartColor++; // create new ColorStops by 1st adding new one and then all // non-StartColor entries -BColorStops aNewColorStops; +std::vector aNewColorStops; -aNewColorStops.reserve(size() + 1); +aNewColorStops.reserve(maStops.size() + 1); aNewColorStops.emplace_back(0.0, rStart); -aNewColorStops.insert(aNewColorStops.end(), a1stNonStartColor, end()); +aNewColorStops.insert(aNewColorStops.end(),
[Libreoffice-commits] core.git: writerfilter/source
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 80 -- writerfilter/source/dmapper/DomainMapper_Impl.hxx |6 - 2 files changed, 32 insertions(+), 54 deletions(-) New commits: commit 7bd401fa4e458c4ca16f7eb88289d50059e1d32e Author: Tomaž Vajngerl AuthorDate: Wed Oct 11 23:09:00 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Oct 12 09:31:09 2023 +0200 writerfilter: clean-up PushPageHeaderFooter method impl. in addition change m_aHeaderFooterTextAppendStack to use enum PagePartType for the "second" value in pair, instead of a bool to denote if it is an entry for header or footer. No change in functionality. Change-Id: I2aa75494c9b3337dd51bf79e282291cdca9d8547 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157839 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index f9f6dbd52d65..1c4925b290d8 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3415,10 +3415,10 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b { while (!m_aHeaderFooterTextAppendStack.empty()) { -auto aFooterHeader = m_aHeaderFooterTextAppendStack.top(); -if ((aFooterHeader.second && !bDynamicHeightTop) || (!aFooterHeader.second && !bDynamicHeightBottom)) +auto& [aTextAppendContext, ePagePartType] = m_aHeaderFooterTextAppendStack.top(); +if ((ePagePartType == PagePartType::Header && !bDynamicHeightTop) || (ePagePartType == PagePartType::Footer && !bDynamicHeightBottom)) { -uno::Reference< text::XTextAppend > xTextAppend = aFooterHeader.first.xTextAppend; +uno::Reference< text::XTextAppend > xTextAppend = aTextAppendContext.xTextAppend; uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor(); uno::Reference< text::XTextRange > xRangeStart, xRangeEnd; @@ -3444,13 +3444,12 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b fillEmptyFrameProperties(aFrameProperties, false); // If it is a footer, then orient the frame to the bottom -if (!aFooterHeader.second) +if (ePagePartType == PagePartType::Footer) +{ aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_VERT_ORIENT), text::VertOrientation::BOTTOM)); - -uno::Reference xBodyText( -xRangeStart->getText(), uno::UNO_QUERY); -xBodyText->convertToTextFrame(xTextAppend, xRangeEnd, -comphelper::containerToSequence(aFrameProperties)); +} +uno::Reference xBodyText(xRangeStart->getText(), uno::UNO_QUERY); +xBodyText->convertToTextFrame(xTextAppend, xRangeEnd, comphelper::containerToSequence(aFrameProperties)); } m_aHeaderFooterTextAppendStack.pop(); } @@ -3468,7 +3467,7 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageTyp const PropertyIds ePropIsOn = bHeader ? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; const PropertyIds ePropShared = bHeader ? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; const PropertyIds ePropTextLeft = bHeader ? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; -const PropertyIds ePropText = bHeader ? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; +const PropertyIds ePropTextRight = bHeader ? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; m_bDiscardHeaderFooter = true; m_eInHeaderFooterImport = bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer; @@ -3476,8 +3475,8 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageTyp //get the section context PropertyMapPtr pContext = DomainMapper_Impl::GetTopContextOfType(CONTEXT_SECTION); //ask for the header/footer name of the given type -SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() ); -if(!pSectionContext) +SectionPropertyMap* pSectionContext = dynamic_cast(pContext.get()); +if (!pSectionContext) return; // clear the "Link To Previous" flag so that the header/footer @@ -3494,31 +3493,24 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageTyp return; try { -bool bLeft = eType == PageType::LEFT; -bool bFirst = eType == PageType::FIRST; -if (!bLeft || GetSettingsTable()->GetEvenAndOddHeaders()) +const PropertyIds ePropText = eType == PageType::LEFT ? ePropTextLeft : ePropTextRight; +if (eType != PageType::LEFT || GetSettingsTable()->GetEvenAndOddHeaders()) { //switch on header/footer use
[Libreoffice-commits] core.git: sw/qa
sw/qa/extras/ooxmlimport/data/SimpleFirst.docx |binary sw/qa/extras/ooxmlimport/data/SimpleFirst.odt |binary sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx |binary sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt |binary sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx |binary sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt |binary sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 214 7 files changed, 214 insertions(+) New commits: commit 955ca0eba5c9ec22fbae0fc3e6220914ec3d69be Author: Tomaž Vajngerl AuthorDate: Wed Oct 11 22:46:03 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Oct 12 06:44:26 2023 +0200 sw: prepare tests cases for first, left, right headers and variants This prepares the test case for first, left, right headers, only first and non-first headers, only left and right (no first) headers and make them run for ODF, where they should work as expected. In a follow up commit, the OOXML implementation should be fixed so that the same tests pass for OOXML documents. Change-Id: I1e7f610324c14dd9eb285ff9d46829610de5b1b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157838 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx b/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx new file mode 100644 index ..1641a2d084ed Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirst.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt b/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt new file mode 100644 index ..fc165e966f85 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirst.odt differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx new file mode 100644 index ..2b530a5e324f Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt new file mode 100644 index ..d5035ac8f581 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleFirstLeftRight.odt differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx new file mode 100644 index ..80dbda0420d7 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.docx differ diff --git a/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt new file mode 100644 index ..61302944da30 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/SimpleLeftRight.odt differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 76210cd2ef20..6b4054c4e38f 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -48,6 +48,10 @@ class Test : public SwModelTestBase { public: +void checkFirstLeftRightHeaderPageStyles(); +void checkFirstRestHeaderPageStyles(); +void checkLeftRightHeaderPageStyles(); + Test() : SwModelTestBase("/sw/qa/extras/ooxmlimport/data/", "Office Open XML Text") { @@ -1194,6 +1198,216 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141969) CPPUNIT_ASSERT_EQUAL(8.0f, getProperty(xRun, "CharHeight")); } +void Test::checkFirstLeftRightHeaderPageStyles() +{ +// Page 1 +{ +OUString pageStyle; +uno::Reference xPropertySet(getParagraphOrTable(1), uno::UNO_QUERY); + +uno::Reference xTextRange(xPropertySet, uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Para 1"), xTextRange->getString()); + +xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; +CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); +} + +// Page 2 +{ +OUString pageStyle; +uno::Reference xPropertySet(getParagraphOrTable(2), uno::UNO_QUERY); + +uno::Reference xTextRange(xPropertySet, uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Para 2"), xTextRange->getString()); + +xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; +CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); +} + +// Page 3 +{ +OUString pageStyle; +uno::Reference xPropertySet(getParagraphOrTable(3), uno::UNO_QUERY); + +uno::Reference xTextRange(xPropertySet, uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Para 3"), xTextRange->getString()); + +xPropertySet->getPropertyValue("PageStyleName") >>= pageStyle; +CPPUNIT_ASSERT_EQUAL(OUString("Standard"), pageStyle); +} +} + +void Test::checkFirstRestHeaderPageStyles() +{ +// Page 1 +{ +OUString pageStyle; +uno::Reference
[Libreoffice-commits] core.git: editeng/qa
editeng/qa/unit/core-test.cxx | 33 + 1 file changed, 13 insertions(+), 20 deletions(-) New commits: commit 4fd6b125751897923428523336a768310a58b36e Author: Tomaž Vajngerl AuthorDate: Wed Oct 11 22:41:02 2023 +0900 Commit: Tomaž Vajngerl CommitDate: Thu Oct 12 05:08:27 2023 +0200 editeng: move the methods into Test class definition This makes makes all the Test class methods contined in the class definition body, so more readable and less noise for the actual test definitions. Change-Id: I3ea177f27aa868a396e537b1682ce91d93c1208e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157837 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index d3f92ce60c2c..12099ea0a719 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -45,10 +45,20 @@ namespace { class Test : public test::BootstrapFixture { public: -Test(); +Test() {} -virtual void setUp() override; -virtual void tearDown() override; +void setUp() override +{ +test::BootstrapFixture::setUp(); +mpItemPool = new EditEngineItemPool(); +SfxApplication::GetOrCreate(); +} + +void tearDown() override +{ +mpItemPool.clear(); +test::BootstrapFixture::tearDown(); +} #if HAVE_MORE_FONTS /// Test text portions position when percentage line spacing is set @@ -135,23 +145,6 @@ private: rtl::Reference mpItemPool; }; -Test::Test() {} - -void Test::setUp() -{ -test::BootstrapFixture::setUp(); - -mpItemPool = new EditEngineItemPool(); - -SfxApplication::GetOrCreate(); -} - -void Test::tearDown() -{ -mpItemPool.clear(); -test::BootstrapFixture::tearDown(); -} - #if HAVE_MORE_FONTS void Test::testLineSpacing() {
[Libreoffice-commits] core.git: writerfilter/source
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 31 +- writerfilter/source/dmapper/DomainMapper_Impl.hxx |6 ++-- writerfilter/source/dmapper/PropertyMap.cxx | 12 writerfilter/source/dmapper/PropertyMap.hxx | 14 - 4 files changed, 29 insertions(+), 34 deletions(-) New commits: commit e3d09d2e525ef6d5b93c6646e3cadc3f01297ea0 Author: Tomaž Vajngerl AuthorDate: Mon Oct 2 08:15:06 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Oct 12 03:33:53 2023 +0200 change PageType (first, left, right) enum to enum class Change-Id: I45bb7947266de1e18028c7ed460149c609e430b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157834 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index cddf8c6f6127..f9f6dbd52d65 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3456,7 +3456,7 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b } } -void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, PageType eType) { m_bSaveParaHadField = m_bParaHadField; m_aHeaderFooterStack.push(HeaderFooterContext(m_bTextInserted, m_nTableDepth)); @@ -3489,22 +3489,17 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, Section return; // TODO sw cannot Undo insert header/footer without crashing } -uno::Reference< beans::XPropertySet > xPageStyle = -pSectionContext->GetPageStyle( -*this, -eType == SectionPropertyMap::PAGE_FIRST ); +uno::Reference xPageStyle = pSectionContext->GetPageStyle(*this, eType == PageType::FIRST); if (!xPageStyle.is()) return; try { -bool bLeft = eType == SectionPropertyMap::PAGE_LEFT; -bool bFirst = eType == SectionPropertyMap::PAGE_FIRST; +bool bLeft = eType == PageType::LEFT; +bool bFirst = eType == PageType::FIRST; if (!bLeft || GetSettingsTable()->GetEvenAndOddHeaders()) { //switch on header/footer use -xPageStyle->setPropertyValue( -getPropertyName(ePropIsOn), -uno::Any(true)); +xPageStyle->setPropertyValue(getPropertyName(ePropIsOn), uno::Any(true)); // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it // Even if the 'Even' header/footer is blank - the flag should be imported (so it would look in LO like in Word) @@ -3555,12 +3550,12 @@ void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, Section } } -void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageHeader(PageType eType) { PushPageHeaderFooter(PagePartType::Header, eType); } -void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageFooter(PageType eType) { PushPageHeaderFooter(PagePartType::Footer, eType); } @@ -9291,22 +9286,22 @@ void DomainMapper_Impl::substream(Id rName, switch( rName ) { case NS_ooxml::LN_headerl: -PushPageHeader(SectionPropertyMap::PAGE_LEFT); +PushPageHeader(PageType::LEFT); break; case NS_ooxml::LN_headerr: -PushPageHeader(SectionPropertyMap::PAGE_RIGHT); +PushPageHeader(PageType::RIGHT); break; case NS_ooxml::LN_headerf: -PushPageHeader(SectionPropertyMap::PAGE_FIRST); +PushPageHeader(PageType::FIRST); break; case NS_ooxml::LN_footerl: -PushPageFooter(SectionPropertyMap::PAGE_LEFT); +PushPageFooter(PageType::LEFT); break; case NS_ooxml::LN_footerr: -PushPageFooter(SectionPropertyMap::PAGE_RIGHT); +PushPageFooter(PageType::RIGHT); break; case NS_ooxml::LN_footerf: -PushPageFooter(SectionPropertyMap::PAGE_FIRST); +PushPageFooter(PageType::FIRST); break; case NS_ooxml::LN_footnote: case NS_ooxml::LN_endnote: diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 82d7ca06824e..83a804cf618d 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -853,8 +853,8 @@ public: /// Get the first pending shape, if there are any. css::uno::Reference PopPendingShape(); -void PushPageHeader(SectionPropertyMap::PageType eType); -void PushPageFooter(SectionPropertyMap::PageType eType); +void PushPageHeader(PageType eType); +void PushPageFooter(PageType
[Libreoffice-commits] core.git: editeng/source
editeng/source/editeng/editeng.cxx | 22 +-- editeng/source/editeng/impedit.hxx | 166 +++ editeng/source/editeng/impedit2.cxx | 252 ++-- editeng/source/editeng/impedit3.cxx | 156 +++--- editeng/source/editeng/impedit4.cxx | 158 +++--- editeng/source/editeng/impedit5.cxx | 114 6 files changed, 432 insertions(+), 436 deletions(-) New commits: commit b63f768941ca870f0930ff400e3bc6ff829bea4a Author: Tomaž Vajngerl AuthorDate: Sat Sep 30 22:56:27 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Oct 12 01:28:05 2023 +0200 prefix some members of ImpEditEngine Change-Id: I9975bed2af853374a10b87c468840ff22b230157 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157833 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 0dd24c941069..6cb28954aedc 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -588,7 +588,7 @@ sal_Int32 EditEngine::GetTextLen() const sal_Int32 EditEngine::GetParagraphCount() const { -return pImpEditEngine->aEditDoc.Count(); +return pImpEditEngine->maEditDoc.Count(); } sal_Int32 EditEngine::GetLineCount( sal_Int32 nParagraph ) const @@ -994,7 +994,7 @@ const EditSelectionEngine& EditEngine::GetSelectionEngine() const void EditEngine::SetInSelectionMode(bool b) { -pImpEditEngine->bInSelection = b; +pImpEditEngine->mbInSelection = b; } bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, vcl::Window const * pFrameWin ) @@ -1863,28 +1863,28 @@ void EditEngine::SetFlatMode( bool bFlat) bool EditEngine::IsFlatMode() const { -return !( pImpEditEngine->aStatus.UseCharAttribs() ); +return !( pImpEditEngine->GetStatus().UseCharAttribs() ); } void EditEngine::SetSingleLine(bool bValue) { -if (bValue == pImpEditEngine->aStatus.IsSingleLine()) +if (bValue == pImpEditEngine->GetStatus().IsSingleLine()) return; if (bValue) -pImpEditEngine->aStatus.TurnOnFlags(EEControlBits::SINGLELINE); +pImpEditEngine->GetStatus().TurnOnFlags(EEControlBits::SINGLELINE); else -pImpEditEngine->aStatus.TurnOffFlags(EEControlBits::SINGLELINE); +pImpEditEngine->GetStatus().TurnOffFlags(EEControlBits::SINGLELINE); } void EditEngine::SetControlWord( EEControlBits nWord ) { -if ( nWord == pImpEditEngine->aStatus.GetControlWord() ) +if ( nWord == pImpEditEngine->GetStatus().GetControlWord() ) return; -EEControlBits nPrev = pImpEditEngine->aStatus.GetControlWord(); -pImpEditEngine->aStatus.GetControlWord() = nWord; +EEControlBits nPrev = pImpEditEngine->GetStatus().GetControlWord(); +pImpEditEngine->GetStatus().GetControlWord() = nWord; EEControlBits nChanges = nPrev ^ nWord; if ( pImpEditEngine->IsFormatted() ) @@ -1952,7 +1952,7 @@ void EditEngine::SetControlWord( EEControlBits nWord ) EEControlBits EditEngine::GetControlWord() const { -return pImpEditEngine->aStatus.GetControlWord(); +return pImpEditEngine->GetStatus().GetControlWord(); } tools::Long EditEngine::GetFirstLineStartX( sal_Int32 nParagraph ) @@ -2437,7 +2437,7 @@ EPosition EditEngine::FindDocPosition( const Point& rDocPos ) const EditPaM aPaM = const_cast(this)->pImpEditEngine->GetPaM( rDocPos, false ); if ( aPaM.GetNode() ) { -aPos.nPara = pImpEditEngine->aEditDoc.GetPos( aPaM.GetNode() ); +aPos.nPara = pImpEditEngine->maEditDoc.GetPos( aPaM.GetNode() ); aPos.nIndex = aPaM.GetIndex(); } return aPos; diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 2fba7bd778f4..df7a11c97dcb 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -494,17 +494,13 @@ class ImpEditEngine : public SfxListener, public svl::StyleSheetUser private: std::shared_ptr pSharedVCL; - -// Data ... - - // Document Specific data ... -ParaPortionList aParaPortionList; // Formatting -SizeaPaperSize; // Layout -SizeaMinAutoPaperSize; // Layout ? -SizeaMaxAutoPaperSize; // Layout ? +ParaPortionList maParaPortionList; // Formatting +Size maPaperSize; // Layout +Size maMinAutoPaperSize; // Layout ? +Size maMaxAutoPaperSize; // Layout ? tools::Long mnMinColumnWrapHeight = 0; // Corresponds to graphic object height -EditDoc aEditDoc; // Document content +EditDoc maEditDoc; // Document content // Engine Specific data ... EditEngine* pEditEngine; @@ -540,11 +536,11 @@ private: double mfSpacingScaleY; bool mbRoundToNearestPt; -CharCompressTypenAsianCompressionMode; +CharCompressType
[Libreoffice-commits] core.git: 2 commits - sfx2/source sw/source vcl/jsdialog
sfx2/source/notebookbar/SfxNotebookBar.cxx |3 sw/source/ui/dialog/uiregionsw.cxx | 102 ++--- vcl/jsdialog/enabled.cxx |1 3 files changed, 56 insertions(+), 50 deletions(-) New commits: commit ba970cb1e267531affc90735ae2b66456a9eb8ed Author: Tomaž Vajngerl AuthorDate: Mon Jul 17 17:14:21 2023 +0900 Commit: Caolán McNamara CommitDate: Wed Oct 11 15:21:29 2023 +0200 disable add-ons for NotebookBar in LOKit - perf. issues Searching for add-ons to use in NotebookBar causes perf. issues, so disable them for now. This was discovered during a editing session and the flame-graph showed up the NotebookbarAddonValues method. See COOL GitHub ticket [1] for more details. [1] https://github.com/CollaboraOnline/online/issues/6896 Change-Id: I4b2ced2be966de1cd1282f801a4410bc1625f0f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154513 Reviewed-by: Michael Meeks Tested-by: Michael Meeks (cherry picked from commit 0cda4c31c6c7881ea7b5089b04ad5147b28117af) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157815 Tested-by: Jenkins diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 3b33ef7dd781..4937e278c73d 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -49,6 +49,9 @@ static void NotebookbarAddonValues( std::vector>>& aExtensionValues) { +if (comphelper::LibreOfficeKit::isActive()) +return; + framework::AddonsOptions aAddonsItems; for (int nIdx = 0; nIdx < aAddonsItems.GetAddonsNotebookBarCount(); nIdx++) commit ff568f6ec8292ad7e5b7001ce0d27430c23c2258 Author: Skyler Grey AuthorDate: Sun Feb 19 13:13:05 2023 + Commit: Caolán McNamara CommitDate: Wed Oct 11 15:21:21 2023 +0200 Make the format > sections > options dialog a jsdialog - This dialog was not properly tunneled so did not show on collabora online - Running asynchronously as a jsdialog both fixes this issue and is a general improvement (in that jsdialog conversion improves accessability, looks more consistent with the rest of COOL, etc.) Note- This commit was previously given the Change-Id Ie9a70da70bbb30de039ded82f738285b1b734421 however I have replaced it due to accidentally creating it against the wrong base branch. To see the old change go to https://gerrit.libreoffice.org/c/core/+/147295 Change-Id: I2715eb1d8e3e301e1519e2ef6b69c823e571d08c Signed-off-by: Skyler Grey Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151188 Reviewed-by: Szymon Kłos Tested-by: Jenkins CollaboraOffice (cherry picked from commit 6aff11f36ecd02613c0613c9e89883c81656d9f6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157814 Tested-by: Caolán McNamara diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index f55b2194bdc2..85bb57abba7c 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -1048,57 +1048,59 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl, weld::Button&, void) aSet.Put(SwFormatFrameSize(SwFrameSize::Variable, nWidth)); aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); -SwSectionPropertyTabDialog aTabDlg(m_xDialog.get(), aSet, m_rSh); -if (RET_OK != aTabDlg.run()) -return; - -const SfxItemSet* pOutSet = aTabDlg.GetOutputItemSet(); -if( !(pOutSet && pOutSet->Count()) ) -return; - -const SwFormatCol* pColItem = pOutSet->GetItemIfSet( -RES_COL, false ); -const SvxBrushItem* pBrushItem = pOutSet->GetItemIfSet( -RES_BACKGROUND, false ); -const SwFormatFootnoteAtTextEnd* pFootnoteItem = pOutSet->GetItemIfSet( -RES_FTN_AT_TXTEND, false ); -const SwFormatEndAtTextEnd* pEndItem = pOutSet->GetItemIfSet( -RES_END_AT_TXTEND, false ); -const SwFormatNoBalancedColumns* pBalanceItem = pOutSet->GetItemIfSet( -RES_COLUMNBALANCE, false ); -const SvxFrameDirectionItem* pFrameDirItem = pOutSet->GetItemIfSet( -RES_FRAMEDIR, false ); -const SvxLRSpaceItem* pLRSpaceItem = pOutSet->GetItemIfSet( -RES_LR_SPACE, false ); - -if( !(pColItem || - pBrushItem || - pFootnoteItem || - pEndItem || - pBalanceItem || - pFrameDirItem || - pLRSpaceItem) ) -return; - -m_xTree->selected_foreach([&](weld::TreeIter& rEntry) -{ -SectRepr* pRepr = weld::fromId(m_xTree->get_id(rEntry)); -if (pColItem) -pRepr->GetCol() = *pColItem; -if (pBrushItem) -
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - oox/source
oox/source/export/drawingml.cxx |4 1 file changed, 4 deletions(-) New commits: commit 97e7ea424021239b04924cde50ddc3474e31f8cd Author: Tomaž Vajngerl AuthorDate: Wed Oct 11 11:58:35 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Oct 11 12:31:28 2023 +0200 Revert "tdf#51510 Blurry QR code after save/reload (docx)" This reverts commit f8b547097dc043924f6df89a8c0e8bafd3f9873a. Reason for revert: This can cause compatibility issues with OOXML when they are saved like this because this is not the correct way how SVG should be saved to the OOXML document - it needs to use the OOXML SVG extension so that the image is still shown in old MSO versions. See more info in https://gerrit.libreoffice.org/c/core/+/157729. Change-Id: Ie8fbe8ac0dd7bd1bff5976a89e7d5e174e9d2fcc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157784 Reviewed-by: Xisco Fauli Tested-by: Xisco Fauli diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 822f5a5e601e..a80111ededab 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1342,10 +1342,6 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) sMediaType = "image/png"; pExtension = ".png"; break; -case GfxLinkType::NativeSvg: -sMediaType = "image/svg"; -pExtension = ".svg"; -break; case GfxLinkType::NativeTif: sMediaType = "image/tiff"; pExtension = ".tif";
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - oox/source
oox/source/export/drawingml.cxx |4 1 file changed, 4 deletions(-) New commits: commit 9dc2c25d1b1b732ed1bb1416fcc36558e795a882 Author: Tomaž Vajngerl AuthorDate: Wed Oct 11 11:59:16 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Oct 11 12:31:33 2023 +0200 Revert "tdf#51510 Blurry QR code after save/reload (docx)" This reverts commit a9dbc31fd3db37b2c6c5ca53ab712be76933b9ea. Reason for revert: This can cause compatibility issues with OOXML when they are saved like this because this is not the correct way how SVG should be saved to the OOXML document - it needs to use the OOXML SVG extension so that the image is still shown in old MSO versions. See more info in https://gerrit.libreoffice.org/c/core/+/157729. Change-Id: I32a5c1e10bacff03beacb9e825d3a243d5334983 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157785 Reviewed-by: Xisco Fauli Tested-by: Xisco Fauli diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index ad5a5cc42d4d..de7644ee4c54 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1446,10 +1446,6 @@ OUString GraphicExport::writeToStorage(const Graphic& rGraphic , bool bRelPathTo sMediaType = "image/png"; pExtension = ".png"; break; -case GfxLinkType::NativeSvg: -sMediaType = "image/svg"; -pExtension = ".svg"; -break; case GfxLinkType::NativeTif: sMediaType = "image/tiff"; pExtension = ".tif";
[Libreoffice-commits] core.git: 2 commits - include/oox oox/source sc/source sw/source writerfilter/source
include/oox/export/drawingml.hxx |6 ++--- oox/source/export/drawingml.cxx | 26 -- oox/source/export/vmlexport.cxx |4 +-- sc/source/filter/excel/xeescher.cxx |2 - sw/source/filter/ww8/docxattributeoutput.cxx |6 ++--- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 19 writerfilter/source/dmapper/DomainMapper_Impl.hxx |8 +- 7 files changed, 36 insertions(+), 35 deletions(-) New commits: commit c90de36ede6d35e2cf1ebea195e0ff28f618f319 Author: Tomaž Vajngerl AuthorDate: Wed Sep 20 21:22:54 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Mon Sep 25 20:26:31 2023 +0200 change bool header or footer parameter to use enum type instead Is much more readable. Change-Id: Ie81aaf344758182915796b18efbe25d3f45df4b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157236 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 72b35d7d544d..13836906c53e 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3460,21 +3460,22 @@ void DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b } } -void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType) +void DomainMapper_Impl::PushPageHeaderFooter(PagePartType ePagePartType, SectionPropertyMap::PageType eType) { m_bSaveParaHadField = m_bParaHadField; m_aHeaderFooterStack.push(HeaderFooterContext(m_bTextInserted, m_nTableDepth)); m_bTextInserted = false; m_nTableDepth = 0; -const PropertyIds ePropIsOn = bHeader? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; -const PropertyIds ePropShared = bHeader? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; -const PropertyIds ePropTextLeft = bHeader? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; -const PropertyIds ePropText = bHeader? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; +bool bHeader = ePagePartType == PagePartType::Header; + +const PropertyIds ePropIsOn = bHeader ? PROP_HEADER_IS_ON: PROP_FOOTER_IS_ON; +const PropertyIds ePropShared = bHeader ? PROP_HEADER_IS_SHARED: PROP_FOOTER_IS_SHARED; +const PropertyIds ePropTextLeft = bHeader ? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; +const PropertyIds ePropText = bHeader ? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; m_bDiscardHeaderFooter = true; -m_eInHeaderFooterImport -= bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer; +m_eInHeaderFooterImport = bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer; //get the section context PropertyMapPtr pContext = DomainMapper_Impl::GetTopContextOfType(CONTEXT_SECTION); @@ -3560,12 +3561,12 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType) { -PushPageHeaderFooter(/* bHeader = */ true, eType); +PushPageHeaderFooter(PagePartType::Header, eType); } void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType) { -PushPageHeaderFooter(/* bHeader = */ false, eType); +PushPageHeaderFooter(PagePartType::Footer, eType); } void DomainMapper_Impl::PopPageHeaderFooter() diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index c19de5a5c4b9..676a0d3196d9 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -426,6 +426,12 @@ struct SymbolData { } }; +enum class PagePartType +{ +Header, +Footer +}; + class DomainMapper; class DomainMapper_Impl final { @@ -1194,7 +1200,7 @@ public: OUString getFontNameForTheme(const Id id); private: -void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType); +void PushPageHeaderFooter(PagePartType ePagePartType, SectionPropertyMap::PageType eType); // Start a new index section; if needed, finish current paragraph css::uno::Reference StartIndexSectionChecked(const OUString& sServiceName); std::vector > m_vTextFramesForChaining ; commit 33c347fb3b0fbbae9c1005b1ca7a6105284a6d31 Author: Tomaž Vajngerl AuthorDate: Sun Sep 17 23:00:17 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Mon Sep 25 20:26:24 2023 +0200 oox: remove returning sRelId and rename WriteImage Rename WriteImage -> writeGraphicToStorage to make it more clear what the method does. Remove returning the rel ID string in some methods that write the graphic into the stream (or the call chain), as it is never used later on, so it is better to not return it if it is not used (it could be abused).
[Libreoffice-commits] core.git: oox/source
oox/source/export/shapes.cxx |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) New commits: commit 8a9c3e82386d700549cac30f2555952046e021cb Author: Tomaž Vajngerl AuthorDate: Mon Sep 18 14:51:59 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Tue Sep 19 14:02:41 2023 +0200 oox: change frozen::make_set to "conventional" frozen::set construction Fixes compile issue with bisect repo started with commit: b839c09760919d4f4a21ed1819885b5385f27e31 (https://gerrit.libreoffice.org/c/core/+/157003) Log: /home/tdf/lode/bibisect/core242/oox/source/export/shapes.cxx:622:2: error: no matching function for call to ‘make_set()’ }); ^ In file included from /home/tdf/lode/bibisect/core242/oox/source/export/shapes.cxx:90:0: /home/tdf/lode/bibisect/core242/workdir/UnpackedTarball/frozen/include/frozen/set.h:223:16: note: candidate: template constexpr auto frozen::make_set(frozen::bits::ignored_arg) constexpr auto make_set(bits::ignored_arg = {}/* for consistency with the initializer below for N = 0*/) { ^~~~ /home/tdf/lode/bibisect/core242/workdir/UnpackedTarball/frozen/include/frozen/set.h:223:16: note: template argument deduction/substitution failed: /home/tdf/lode/bibisect/core242/oox/source/export/shapes.cxx:622:2: note: cannot convert ‘{"b\000l\000o\000c\000k\000-\000a\000r\000c\000\000", "r\000e\000c\000t\000a\000n\000g\000l\000e\000\000", "e\000l\000l\000i\000p\000s\000e\000\000", "r\000i\000n\000g\000\000", "c\000a\000n\000\000", "c\000u\000b\000e\000\000", "p\000a\000p\000e\000r\000\000", "f\000r\000a\000m\000e\000\000", "f\000o\000r\000b\000i\000d\000d\000e\000n\000\000", "s\000m\000i\000l\000e\000y\000\000", "s\000u\000n\000\000", "f\000l\000o\000w\000e\000r\000\000", "b\000r\000a\000c\000k\000e\000t\000-\000p\000a\000i\000r\000\000", "b\000r\000a\000c\000e\000-\000p\000a\000i\000r\000\000", "q\000u\000a\000d\000-\000b\000e\000v\000e\000l\000\000", "r\000o\000u\000n\000d\000-\000r\000e\000c\000t\000a\000n\000g\000u\000l\000a\000r\000-\000c\000a\000l\000l\000o\000u\000t\000\000", "r\000e\000c\000t\000a\000n\000g\000u\000l\000a\000r\000-\000c\000a\000l\000l\000o\000u\000t\000\000", "r\000o\000u\000n\000d\000-\000c\ 000a\000l\000l\000o\000u\000t\000\000", "c\000l\000o\000u\000d\000-\000c\000a\000l\000l\000o\000u\000t\000\000", "l\000i\000n\000e\000-\000c\000a\000l\000l\000o\000u\000t\000-\0001\000\000", "l\000i\000n\000e\000-\000c\000a\000l\000l\000o\000u\000t\000-\0002\000\000", "l\000i\000n\000e\000-\000c\000a\000l\000l\000o\000u\000t\000-\0003\000\000", "p\000a\000p\000e\000r\000\000", "v\000e\000r\000t\000i\000c\000a\000l\000-\000s\000c\000r\000o\000l\000l\000\000", "h\000o\000r\000i\000z\000o\000n\000t\000a\000l\000-\000s\000c\000r\000o\000l\000l\000\000", "m\000s\000o\000-\000s\000p\000t\0003\0004\000\000", "m\000s\000o\000-\000s\000p\000t\0007\0005\000\000", "m\000s\000o\000-\000s\000p\000t\0001\0006\0004\000\000", "m\000s\000o\000-\000s\000p\000t\0001\0008\\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000p\000r\000o\000c\000e\000s\000s\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000a\000l\000t\000e\000r\000n\000a\000t\000e\000-\000p\000r\000o\000c\000e\000 s\000s\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000d\000e\000c\000i\000s\000i\000o\000n\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000d\000a\000t\000a\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000p\000r\000e\000d\000e\000f\000i\000n\000e\000d\000-\000p\000r\000o\000c\000e\000s\000s\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000i\000n\000t\000e\000r\000n\000a\000l\000-\000s\000t\000o\000r\000a\000g\000e\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000d\000o\000c\000u\000m\000e\000n\000t\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000m\000u\000l\000t\000i\000d\000o\000c\000u\000m\000e\000n\000t\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000t\000e\000r\000m\000i\000n\000a\000t\000o\000r\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000p\000r\000e\000p\000a\000r\000a\000t\000i\000o\000n\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000m\000a\000n\000u\000a\000 l\000-\000i\000n\000p\000u\000t\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000m\000a\000n\000u\000a\000l\000-\000o\000p\000e\000r\000a\000t\000i\000o\000n\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000c\000o\000n\000n\000e\000c\000t\000o\000r\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000o\000f\000f\000-\000p\000a\000g\000e\000-\000c\000o\000n\000n\000e\000c\000t\000o\000r\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000c\000a\000r\000d\000\000", "f\000l\000o\000w\000c\000h\000a\000r\000t\000-\000p\000u\000n\000c\000h\000e\000d\000-\000t\000a\000p\000e\000\000",
[Libreoffice-commits] core.git: oox/source
oox/source/export/chartexport.cxx | 72 ++- oox/source/export/shapes.cxx | 235 +++--- 2 files changed, 159 insertions(+), 148 deletions(-) New commits: commit b839c09760919d4f4a21ed1819885b5385f27e31 Author: Tomaž Vajngerl AuthorDate: Sun Sep 17 22:25:01 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Mon Sep 18 07:54:27 2023 +0200 oox: some more conversions to frozen map and set Change-Id: Ibe557006ee4393a2cfa2cb600744ca5ba7090ca7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157003 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index c9db6f8cc431..0265c2b7db8d 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -107,6 +107,10 @@ #include #include +#include +#include +#include + #include #include @@ -440,41 +444,41 @@ static ::std::vector< double > lcl_getAllValuesFromSequence( const Reference< ch return aResult; } -static sal_Int32 lcl_getChartType( std::u16string_view sChartType ) +namespace +{ + +constexpr auto constChartTypeMap = frozen::make_unordered_map( +{ +{ u"com.sun.star.chart.BarDiagram", chart::TYPEID_BAR }, +{ u"com.sun.star.chart2.ColumnChartType", chart::TYPEID_BAR }, +{ u"com.sun.star.chart.AreaDiagram", chart::TYPEID_AREA }, +{ u"com.sun.star.chart2.AreaChartType", chart::TYPEID_AREA }, +{ u"com.sun.star.chart.LineDiagram", chart::TYPEID_LINE }, +{ u"com.sun.star.chart2.LineChartType", chart::TYPEID_LINE }, +{ u"com.sun.star.chart.PieDiagram", chart::TYPEID_PIE }, +{ u"com.sun.star.chart2.PieChartType", chart::TYPEID_PIE }, +{ u"com.sun.star.chart.DonutDiagram", chart::TYPEID_DOUGHNUT }, +{ u"com.sun.star.chart2.DonutChartType", chart::TYPEID_DOUGHNUT }, +{ u"com.sun.star.chart.XYDiagram", chart::TYPEID_SCATTER }, +{ u"com.sun.star.chart2.ScatterChartType", chart::TYPEID_SCATTER }, +{ u"com.sun.star.chart.NetDiagram", chart::TYPEID_RADARLINE }, +{ u"com.sun.star.chart2.NetChartType", chart::TYPEID_RADARLINE }, +{ u"com.sun.star.chart.FilledNetDiagram", chart::TYPEID_RADARAREA }, +{ u"com.sun.star.chart2.FilledNetChartType", chart::TYPEID_RADARAREA }, +{ u"com.sun.star.chart.StockDiagram", chart::TYPEID_STOCK }, +{ u"com.sun.star.chart2.CandleStickChartType", chart::TYPEID_STOCK }, +{ u"com.sun.star.chart.BubbleDiagram", chart::TYPEID_BUBBLE }, +{ u"com.sun.star.chart2.BubbleChartType", chart::TYPEID_BUBBLE }, +}); + +} // end anonymous namespace + +static sal_Int32 lcl_getChartType(std::u16string_view sChartType) { -chart::TypeId eChartTypeId = chart::TYPEID_UNKNOWN; -if( sChartType == u"com.sun.star.chart.BarDiagram" -|| sChartType == u"com.sun.star.chart2.ColumnChartType" ) -eChartTypeId = chart::TYPEID_BAR; -else if( sChartType == u"com.sun.star.chart.AreaDiagram" - || sChartType == u"com.sun.star.chart2.AreaChartType" ) -eChartTypeId = chart::TYPEID_AREA; -else if( sChartType == u"com.sun.star.chart.LineDiagram" - || sChartType == u"com.sun.star.chart2.LineChartType" ) -eChartTypeId = chart::TYPEID_LINE; -else if( sChartType == u"com.sun.star.chart.PieDiagram" - || sChartType == u"com.sun.star.chart2.PieChartType" ) -eChartTypeId = chart::TYPEID_PIE; -else if( sChartType == u"com.sun.star.chart.DonutDiagram" - || sChartType == u"com.sun.star.chart2.DonutChartType" ) -eChartTypeId = chart::TYPEID_DOUGHNUT; -else if( sChartType == u"com.sun.star.chart.XYDiagram" - || sChartType == u"com.sun.star.chart2.ScatterChartType" ) -eChartTypeId = chart::TYPEID_SCATTER; -else if( sChartType == u"com.sun.star.chart.NetDiagram" - || sChartType == u"com.sun.star.chart2.NetChartType" ) -eChartTypeId = chart::TYPEID_RADARLINE; -else if( sChartType == u"com.sun.star.chart.FilledNetDiagram" - || sChartType == u"com.sun.star.chart2.FilledNetChartType" ) -eChartTypeId = chart::TYPEID_RADARAREA; -else if( sChartType == u"com.sun.star.chart.StockDiagram" - || sChartType == u"com.sun.star.chart2.CandleStickChartType" ) -eChartTypeId = chart::TYPEID_STOCK; -else if( sChartType == u"com.sun.star.chart.BubbleDiagram" - || sChartType == u"com.sun.star.chart2.BubbleChartType" ) -eChartTypeId = chart::TYPEID_BUBBLE; - -return eChartTypeId; +auto aIterator = constChartTypeMap.find(sChartType); +if (aIterator == constChartTypeMap.end()) +return chart::TYPEID_UNKNOWN; +return aIterator->second; } static sal_Int32 lcl_generateRandomValue() diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 78614b7efbcc..08c3c38e4446 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx
[Libreoffice-commits] core.git: oox/source
oox/source/drawingml/fillproperties.cxx | 150 1 file changed, 59 insertions(+), 91 deletions(-) New commits: commit 5fd0d769a2a0106b6b12faed28dc81d90153c16c Author: Tomaž Vajngerl AuthorDate: Sat Sep 16 12:59:17 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Sat Sep 16 18:41:12 2023 +0200 oox: use frozen unordered_map for mapping the name string to token Change-Id: Ib1f7d28509a1bc2680ad66b2cb1bf0ed35315f58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156975 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index ff78f3183831..dec9ab9672cc 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -49,6 +49,11 @@ #include #include +#include +#include +#include + + using namespace ::com::sun::star; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::graphic; @@ -992,101 +997,64 @@ OUString ArtisticEffectProperties::getEffectString( sal_Int32 nToken ) return OUString(); } -sal_Int32 ArtisticEffectProperties::getEffectToken( const OUString& sName ) +constexpr auto constEffectTokenForEffectNameMap = frozen::make_unordered_map( { // effects -if( sName == "artisticBlur" ) -return XML_artisticBlur; -else if( sName == "artisticCement" ) -return XML_artisticCement; -else if( sName == "artisticChalkSketch" ) -return XML_artisticChalkSketch; -else if( sName == "artisticCrisscrossEtching" ) -return XML_artisticCrisscrossEtching; -else if( sName == "artisticCutout" ) -return XML_artisticCutout; -else if( sName == "artisticFilmGrain" ) -return XML_artisticFilmGrain; -else if( sName == "artisticGlass" ) -return XML_artisticGlass; -else if( sName == "artisticGlowDiffused" ) -return XML_artisticGlowDiffused; -else if( sName == "artisticGlowEdges" ) -return XML_artisticGlowEdges; -else if( sName == "artisticLightScreen" ) -return XML_artisticLightScreen; -else if( sName == "artisticLineDrawing" ) -return XML_artisticLineDrawing; -else if( sName == "artisticMarker" ) -return XML_artisticMarker; -else if( sName == "artisticMosiaicBubbles" ) -return XML_artisticMosiaicBubbles; -else if( sName == "artisticPaintStrokes" ) -return XML_artisticPaintStrokes; -else if( sName == "artisticPaintBrush" ) -return XML_artisticPaintBrush; -else if( sName == "artisticPastelsSmooth" ) -return XML_artisticPastelsSmooth; -else if( sName == "artisticPencilGrayscale" ) -return XML_artisticPencilGrayscale; -else if( sName == "artisticPencilSketch" ) -return XML_artisticPencilSketch; -else if( sName == "artisticPhotocopy" ) -return XML_artisticPhotocopy; -else if( sName == "artisticPlasticWrap" ) -return XML_artisticPlasticWrap; -else if( sName == "artisticTexturizer" ) -return XML_artisticTexturizer; -else if( sName == "artisticWatercolorSponge" ) -return XML_artisticWatercolorSponge; -else if( sName == "brightnessContrast" ) -return XML_brightnessContrast; -else if( sName == "colorTemperature" ) -return XML_colorTemperature; -else if( sName == "saturation" ) -return XML_saturation; -else if( sName == "sharpenSoften" ) -return XML_sharpenSoften; +{ u"artisticBlur", XML_artisticBlur }, +{ u"artisticCement", XML_artisticCement }, +{ u"artisticChalkSketch", XML_artisticChalkSketch }, +{ u"artisticCrisscrossEtching", XML_artisticCrisscrossEtching }, +{ u"artisticCutout", XML_artisticCutout }, +{ u"artisticFilmGrain", XML_artisticFilmGrain }, +{ u"artisticGlass", XML_artisticGlass }, +{ u"artisticGlowDiffused", XML_artisticGlowDiffused }, +{ u"artisticGlowEdges", XML_artisticGlowEdges }, +{ u"artisticLightScreen", XML_artisticLightScreen }, +{ u"artisticLineDrawing", XML_artisticLineDrawing }, +{ u"artisticMarker", XML_artisticMarker }, +{ u"artisticMosiaicBubbles", XML_artisticMosiaicBubbles }, +{ u"artisticPaintStrokes", XML_artisticPaintStrokes }, +{ u"artisticPaintBrush", XML_artisticPaintBrush }, +{ u"artisticPastelsSmooth", XML_artisticPastelsSmooth }, +{ u"artisticPencilGrayscale", XML_artisticPencilGrayscale }, +{ u"artisticPencilSketch", XML_artisticPencilSketch }, +{ u"artisticPhotocopy", XML_artisticPhotocopy }, +{ u"artisticPlasticWrap", XML_artisticPlasticWrap }, +{ u"artisticTexturizer", XML_artisticTexturizer }, +{ u"artisticWatercolorSponge", XML_artisticWatercolorSponge }, +{ u"brightnessContrast", XML_brightnessContrast }, +{ u"colorTemperature", XML_colorTemperature }, +{ u"saturation", XML_saturation }, +{ u"sharpenSoften", XML_sharpenSoften }, //
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/qa sc/subsequent_setup.mk
sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx |binary sc/qa/unit/subsequent_filters_test2.cxx | 32 ++ sc/subsequent_setup.mk|1 3 files changed, 33 insertions(+) New commits: commit 2586213c1790bd419442f3376af661168bbe8508 Author: Tomaž Vajngerl AuthorDate: Wed Sep 13 22:18:43 2023 +0200 Commit: Miklos Vajna CommitDate: Fri Sep 15 12:49:39 2023 +0200 sc: add test for the row import default index issue Change-Id: I09f94977602122ac751cc64dc7c3cec1a954aea8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156901 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit bbd1cae866630e1545b603b2b31417713d63d226) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156914 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx b/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx new file mode 100644 index ..980cdd35a0d6 Binary files /dev/null and b/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx differ diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx index f2fd4196dfa1..75a7ae4059bd 100644 --- a/sc/qa/unit/subsequent_filters_test2.cxx +++ b/sc/qa/unit/subsequent_filters_test2.cxx @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include #include @@ -193,6 +195,7 @@ public: void testTdf82984_zip64XLSXImport(); void testSingleLine(); void testNamedTableRef(); +void testRowImportCellStyleIssue(); CPPUNIT_TEST_SUITE(ScFiltersTest2); @@ -316,6 +319,7 @@ public: CPPUNIT_TEST(testTdf82984_zip64XLSXImport); CPPUNIT_TEST(testSingleLine); CPPUNIT_TEST(testNamedTableRef); +CPPUNIT_TEST(testRowImportCellStyleIssue); CPPUNIT_TEST_SUITE_END(); }; @@ -3095,6 +3099,34 @@ void ScFiltersTest2::testNamedTableRef() } } +void ScFiltersTest2::testRowImportCellStyleIssue() +{ +// Test checks that the correct cell style is imported for the first 6 rows and then the rest of the rows. +// Row 1 to 6 have no background color, after that light2 (background2) theme color. + +createScDoc("xlsx/RowImportCellStyleIssue.xlsx"); +ScDocument* pDoc = getScDoc(); + +// Check cell A6 - should have no background color set +{ +const ScPatternAttr* pAttr = pDoc->GetPattern(0, 5, 0); // A6 +const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND); +const SvxBrushItem& rBackground = static_cast(rItem); +CPPUNIT_ASSERT_EQUAL(false, rBackground.isUsed()); +} + +// Check cell A7 - should have light2 (background2) theme color set +{ +const ScPatternAttr* pAttr = pDoc->GetPattern(0, 6, 0); // A7 +const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND); +const SvxBrushItem& rBackground = static_cast(rItem); +CPPUNIT_ASSERT_EQUAL(true, rBackground.isUsed()); +CPPUNIT_ASSERT_EQUAL(Color(0xe7e6e6), rBackground.GetColor()); +auto const& rComplexColor = rBackground.getComplexColor(); +CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Light2, rComplexColor.getThemeColorType()); +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/subsequent_setup.mk b/sc/subsequent_setup.mk index 6847aca1a775..4cf9b34f984e 100644 --- a/sc/subsequent_setup.mk +++ b/sc/subsequent_setup.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_subsequent_$(1), \ cppu \ cppuhelper \ drawinglayer \ +docmodel \ editeng \ for \ forui \
[Libreoffice-commits] core.git: sc/qa sc/subsequent_setup.mk
sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx |binary sc/qa/unit/subsequent_filters_test4.cxx | 49 -- sc/subsequent_setup.mk|1 3 files changed, 38 insertions(+), 12 deletions(-) New commits: commit bbd1cae866630e1545b603b2b31417713d63d226 Author: Tomaž Vajngerl AuthorDate: Wed Sep 13 22:18:43 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Thu Sep 14 12:10:49 2023 +0200 sc: add test for the row import default index issue Change-Id: I09f94977602122ac751cc64dc7c3cec1a954aea8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156901 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx b/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx new file mode 100644 index ..980cdd35a0d6 Binary files /dev/null and b/sc/qa/unit/data/xlsx/RowImportCellStyleIssue.xlsx differ diff --git a/sc/qa/unit/subsequent_filters_test4.cxx b/sc/qa/unit/subsequent_filters_test4.cxx index ae5c7ff7e4da..4439b3d9ba97 100644 --- a/sc/qa/unit/subsequent_filters_test4.cxx +++ b/sc/qa/unit/subsequent_filters_test4.cxx @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -69,20 +71,20 @@ using namespace ::com::sun::star::uno; class ScFiltersTest4 : public ScModelTestBase { public: -ScFiltersTest4(); +ScFiltersTest4() +: ScModelTestBase("sc/qa/unit/data") +{ +} protected: -void testImportCrash(const char* rFileName); +void testImportCrash(const char* rFileName) +{ +createScDoc(rFileName); +ScDocument* pDoc = getScDoc(); +pDoc->CalcAll(); // perform hard re-calculation. +} }; -void ScFiltersTest4::testImportCrash(const char* rFileName) -{ -createScDoc(rFileName); - -ScDocument* pDoc = getScDoc(); -pDoc->CalcAll(); // perform hard re-calculation. -} - CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testPasswordNew) { //tests opening a file with new password algorithm @@ -1944,9 +1946,32 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf142905) CPPUNIT_ASSERT_EQUAL(OUString(" 3M "), pDoc->GetString(2, 0, 0)); } -ScFiltersTest4::ScFiltersTest4() -: ScModelTestBase("sc/qa/unit/data") +CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testRowImportCellStyleIssue) { +// Test checks that the correct cell style is imported for the first 6 rows and then the rest of the rows. +// Row 1 to 6 have no background color, after that light2 (background2) theme color. + +createScDoc("xlsx/RowImportCellStyleIssue.xlsx"); +ScDocument* pDoc = getScDoc(); + +// Check cell A6 - should have no background color set +{ +const ScPatternAttr* pAttr = pDoc->GetPattern(0, 5, 0); // A6 +const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND); +const SvxBrushItem& rBackground = static_cast(rItem); +CPPUNIT_ASSERT_EQUAL(false, rBackground.isUsed()); +} + +// Check cell A7 - should have light2 (background2) theme color set +{ +const ScPatternAttr* pAttr = pDoc->GetPattern(0, 6, 0); // A7 +const SfxPoolItem& rItem = pAttr->GetItem(ATTR_BACKGROUND); +const SvxBrushItem& rBackground = static_cast(rItem); +CPPUNIT_ASSERT_EQUAL(true, rBackground.isUsed()); +CPPUNIT_ASSERT_EQUAL(Color(0xe7e6e6), rBackground.GetColor()); +auto const& rComplexColor = rBackground.getComplexColor(); +CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Light2, rComplexColor.getThemeColorType()); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/subsequent_setup.mk b/sc/subsequent_setup.mk index 6847aca1a775..4cf9b34f984e 100644 --- a/sc/subsequent_setup.mk +++ b/sc/subsequent_setup.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_subsequent_$(1), \ cppu \ cppuhelper \ drawinglayer \ +docmodel \ editeng \ for \ forui \
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - sc/source
sc/source/filter/oox/sheetdatacontext.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit b0ba18cadd830d3c1b91e501eef937da251fac58 Author: Tomaž Vajngerl AuthorDate: Tue Sep 12 14:34:03 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Sep 13 10:14:10 2023 +0200 sc: row import - default style index is 0 and not -1 When importing CT_Row structure, the style index is 0 by default and not -1. The effect of this is that the style is not applied for the rows, because the index is -1. With the change to 0, the style applied is the first style, which is the correct behaviour and this fixes the issue with the test document. Change-Id: If5ab571e8dd7ec1319e7cb4d26ba006ca827eca6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156845 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl (cherry picked from commit 0da88ee88255083ec9557ff25005a745dcdbef14) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156877 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx index bc5855e9f4b7..19ad0a2a3465 100644 --- a/sc/source/filter/oox/sheetdatacontext.cxx +++ b/sc/source/filter/oox/sheetdatacontext.cxx @@ -279,7 +279,7 @@ void SheetDataContext::importRow( const AttributeList& rAttribs ) mnCol = -1; aModel.mfHeight = rAttribs.getDouble( XML_ht, -1.0 ); -aModel.mnXfId = rAttribs.getInteger( XML_s, -1 ); +aModel.mnXfId = rAttribs.getInteger(XML_s, 0); // default style index is 0 aModel.mnLevel= rAttribs.getInteger( XML_outlineLevel, 0 ); aModel.mbCustomHeight = rAttribs.getBool( XML_customHeight, false ); aModel.mbCustomFormat = rAttribs.getBool( XML_customFormat, false );
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/source
sc/source/filter/oox/sheetdatacontext.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit c148e51c446855cc751e955652081578f57e63d3 Author: Tomaž Vajngerl AuthorDate: Tue Sep 12 14:34:03 2023 +0200 Commit: Miklos Vajna CommitDate: Wed Sep 13 08:09:57 2023 +0200 sc: row import - default style index is 0 and not -1 When importing CT_Row structure, the style index is 0 by default and not -1. The effect of this is that the style is not applied for the rows, because the index is -1. With the change to 0, the style applied is the first style, which is the correct behaviour and this fixes the issue with the test document. Change-Id: If5ab571e8dd7ec1319e7cb4d26ba006ca827eca6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156845 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl (cherry picked from commit 2412ae8d8854a96bd3dc423e199c6356355cde83) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156748 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx index bc5855e9f4b7..19ad0a2a3465 100644 --- a/sc/source/filter/oox/sheetdatacontext.cxx +++ b/sc/source/filter/oox/sheetdatacontext.cxx @@ -279,7 +279,7 @@ void SheetDataContext::importRow( const AttributeList& rAttribs ) mnCol = -1; aModel.mfHeight = rAttribs.getDouble( XML_ht, -1.0 ); -aModel.mnXfId = rAttribs.getInteger( XML_s, -1 ); +aModel.mnXfId = rAttribs.getInteger(XML_s, 0); // default style index is 0 aModel.mnLevel= rAttribs.getInteger( XML_outlineLevel, 0 ); aModel.mbCustomHeight = rAttribs.getBool( XML_customHeight, false ); aModel.mbCustomFormat = rAttribs.getBool( XML_customFormat, false );
[Libreoffice-commits] core.git: sc/source
sc/source/filter/oox/sheetdatacontext.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 0da88ee88255083ec9557ff25005a745dcdbef14 Author: Tomaž Vajngerl AuthorDate: Tue Sep 12 14:34:03 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Tue Sep 12 20:50:16 2023 +0200 sc: row import - default style index is 0 and not -1 When importing CT_Row structure, the style index is 0 by default and not -1. The effect of this is that the style is not applied for the rows, because the index is -1. With the change to 0, the style applied is the first style, which is the correct behaviour and this fixes the issue with the test document. Change-Id: If5ab571e8dd7ec1319e7cb4d26ba006ca827eca6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156845 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx index bc5855e9f4b7..19ad0a2a3465 100644 --- a/sc/source/filter/oox/sheetdatacontext.cxx +++ b/sc/source/filter/oox/sheetdatacontext.cxx @@ -279,7 +279,7 @@ void SheetDataContext::importRow( const AttributeList& rAttribs ) mnCol = -1; aModel.mfHeight = rAttribs.getDouble( XML_ht, -1.0 ); -aModel.mnXfId = rAttribs.getInteger( XML_s, -1 ); +aModel.mnXfId = rAttribs.getInteger(XML_s, 0); // default style index is 0 aModel.mnLevel= rAttribs.getInteger( XML_outlineLevel, 0 ); aModel.mbCustomHeight = rAttribs.getBool( XML_customHeight, false ); aModel.mbCustomFormat = rAttribs.getBool( XML_customFormat, false );
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - basegfx/source chart2/import_setup.mk chart2/Library_chartcontroller.mk chart2/qa chart2/source docmodel/Library_docmodel.mk docmodel/source
basegfx/source/tools/bgradient.cxx | 167 - chart2/Library_chartcontroller.mk |3 chart2/import_setup.mk |1 chart2/qa/extras/chart2import.cxx |5 chart2/source/controller/main/ChartController_Tools.cxx |4 docmodel/Library_docmodel.mk|1 docmodel/source/uno/UnoGradientTools.cxx| 200 include/basegfx/utils/bgradient.hxx | 22 - include/docmodel/uno/UnoGradientTools.hxx | 33 ++ oox/qa/unit/drawingml.cxx |4 oox/qa/unit/shape.cxx | 23 + oox/source/drawingml/fillproperties.cxx |5 oox/source/drawingml/fontworkhelpers.cxx|5 oox/source/export/chartexport.cxx | 13 - oox/source/export/drawingml.cxx | 12 sd/CppunitTest_sd_misc_tests.mk |1 sd/export_setup.mk |1 sd/qa/unit/export-tests-ooxml1.cxx |7 sd/qa/unit/export-tests-ooxml2.cxx |4 sd/qa/unit/export-tests-ooxml3.cxx |7 sd/qa/unit/import-tests.cxx |1 sd/qa/unit/import-tests2.cxx|1 sd/qa/unit/misc-tests.cxx |6 svx/source/unodraw/XPropertyTable.cxx | 24 - svx/source/xoutdev/xattr.cxx| 17 - sw/CppunitTest_sw_odfexport.mk |1 sw/qa/extras/odfexport/odfexport.cxx|5 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx |5 sw/qa/extras/rtfexport/rtfexport.cxx|5 sw/rtfexport_setup.mk |1 xmloff/source/style/GradientStyle.cxx |3 xmloff/source/style/TransGradientStyle.cxx |3 32 files changed, 328 insertions(+), 262 deletions(-) New commits: commit eee4b3f8e46b85b3bb4f7cbe83b8af552594be89 Author: Tomaž Vajngerl AuthorDate: Wed Aug 9 13:27:49 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Sep 6 16:56:27 2023 +0200 move BGradient to awt::Gradient2 UNO conversion into docmodel This is needed because the module dependencies are an issues if the conversion is done in basegfx. The bigger issue will come when the ComplexColor conversion will be done as basegfx can't depend on docmodel because of circular dependencies. The BGradient is also more suitable for docmodel anyway as the previously it was part of the model and is not a basic (gfx) type - however this doesn't move the whole BGradient into docmodel yet. Change-Id: Id91ce52232f89f00e09b451c13da36e2854ae14b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155674 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 242bb3fdda5be165bd00701518df47cc1276438f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156449 Reviewed-by: Xisco Fauli diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index cd6f5492a595..88b1094f2445 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -68,41 +68,6 @@ basegfx::BGradient lcl_buildGradientFromStringMap(StringMap& rMap) namespace basegfx { -void BColorStops::setColorStopSequence(const css::awt::ColorStopSequence& rColorStops) -{ -const sal_Int32 nLen(rColorStops.getLength()); - -if (0 != nLen) -{ -// we have ColorStops -reserve(nLen); -const css::awt::ColorStop* pSourceColorStop(rColorStops.getConstArray()); - -for (sal_Int32 a(0); a < nLen; a++, pSourceColorStop++) -{ -emplace_back(pSourceColorStop->StopOffset, - BColor(pSourceColorStop->StopColor.Red, pSourceColorStop->StopColor.Green, -pSourceColorStop->StopColor.Blue)); -} -} -} - -BColorStops::BColorStops(const css::awt::ColorStopSequence& rColorStops) -{ -setColorStopSequence(rColorStops); -} - -BColorStops::BColorStops(const css::uno::Any& rVal) -{ -if (rVal.has()) -{ -// we can use awt::ColorStopSequence -css::awt::ColorStopSequence aColorStopSequence; -rVal >>= aColorStopSequence; -setColorStopSequence(aColorStopSequence); -} -} - // constructor with two colors to explicitly create a // BColorStops for a single StartColor @0.0 & EndColor @1.0 BColorStops::BColorStops(const BColor& rStart, const BColor& rEnd) @@ -498,28 +463,6 @@ bool BColorStops::checkPenultimate() const return true; } -/* Tooling method to fill a awt::ColorStopSequence with -the data from the given
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6-1' - slideshow/source
slideshow/source/engine/shapes/drawshape.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit f73da4f9c2ecbd3d79923db9bdbd15501d12696f Author: Tomaž Vajngerl AuthorDate: Tue Sep 5 11:10:45 2023 +0200 Commit: Xisco Fauli CommitDate: Wed Sep 6 14:41:03 2023 +0200 tdf#154138 C/P regression - used setWidth instead of setHeight Change-Id: I2433b4d32e939cadf499b61dfa9033125eaa3c76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156540 Tested-by: Jenkins Reviewed-by: Xisco Fauli (cherry picked from commit 1c08f20af9034e4995932fa7f3d71dcdd9989355) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156542 Reviewed-by: Ilmari Lauhakangas Reviewed-by: Hossein Tested-by: Xisco Fauli diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 8993c8edbe77..cdda31da8a66 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -775,7 +775,7 @@ namespace slideshow::internal aAABorder.setWidth( ::std::max( rShapeBorder.getWidth(), aAABorder.getWidth() ) ); -aAABorder.setWidth( ::std::max( +aAABorder.setHeight( ::std::max( rShapeBorder.getHeight(), aAABorder.getHeight() ) ); }
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - slideshow/source
slideshow/source/engine/shapes/drawshape.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit c0ddff184da9b8a0f713fcc2abb526d7e6218c0f Author: Tomaž Vajngerl AuthorDate: Tue Sep 5 11:10:45 2023 +0200 Commit: Miklos Vajna CommitDate: Wed Sep 6 10:22:11 2023 +0200 tdf#154138 C/P regression - used setWidth instead of setHeight Change-Id: I2433b4d32e939cadf499b61dfa9033125eaa3c76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156557 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit a56bfd0cc01daebadd8b457f04baa42ccb2dec7b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156590 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 8993c8edbe77..cdda31da8a66 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -775,7 +775,7 @@ namespace slideshow::internal aAABorder.setWidth( ::std::max( rShapeBorder.getWidth(), aAABorder.getWidth() ) ); -aAABorder.setWidth( ::std::max( +aAABorder.setHeight( ::std::max( rShapeBorder.getHeight(), aAABorder.getHeight() ) ); }
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - xmloff/inc xmloff/source
xmloff/inc/XMLThemeContext.hxx |5 +++-- xmloff/source/style/XMLThemeContext.cxx | 11 ++- 2 files changed, 9 insertions(+), 7 deletions(-) New commits: commit 6629f794c9ac6a14ac1331608511af98f2b74f89 Author: Tomaž Vajngerl AuthorDate: Mon Sep 4 12:06:06 2023 +0200 Commit: Miklos Vajna CommitDate: Wed Sep 6 08:07:15 2023 +0200 xmloff: rename m_aObject in XMLThemeContext and clarify Clarify what m_aObject is in the theme import (XMLThemeContext) and rename to a better name. It is refering to an object that has the "Theme" property, which is usually found in on XPage (master page) or XModel, but technically could be any object that has the property (for getting and setting the XTheme type). Change-Id: If15a8c42a0c516cd0566f4ee9e81f7315ef1651e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156511 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit ca120667c3855fbfc1e3579d4cf4ed0e3b93770a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156545 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/xmloff/inc/XMLThemeContext.hxx b/xmloff/inc/XMLThemeContext.hxx index f8ee08d5d4e8..c3056fa74216 100644 --- a/xmloff/inc/XMLThemeContext.hxx +++ b/xmloff/inc/XMLThemeContext.hxx @@ -24,13 +24,14 @@ class Theme; /// Imports the theme class XMLThemeContext : public SvXMLImportContext { -css::uno::Reference m_xObject; +// Any UNO object that has the "Theme" property - usually XPage (master page) or XModel +css::uno::Reference m_xObjectWithThemeProperty; std::shared_ptr mpTheme; public: XMLThemeContext(SvXMLImport& rImport, css::uno::Reference const& xAttrList, -css::uno::Reference const& xObject); +css::uno::Reference const& xObjectWithThemeProperty); ~XMLThemeContext(); css::uno::Reference SAL_CALL createFastChildContext( diff --git a/xmloff/source/style/XMLThemeContext.cxx b/xmloff/source/style/XMLThemeContext.cxx index 5c210c7a48dc..564d934ff8fb 100644 --- a/xmloff/source/style/XMLThemeContext.cxx +++ b/xmloff/source/style/XMLThemeContext.cxx @@ -31,11 +31,11 @@ using namespace css; using namespace xmloff::token; -XMLThemeContext::XMLThemeContext(SvXMLImport& rImport, - const uno::Reference& xAttrList, - css::uno::Reference const& xObject) +XMLThemeContext::XMLThemeContext( +SvXMLImport& rImport, const uno::Reference& xAttrList, +css::uno::Reference const& xObjectWithThemeProperty) : SvXMLImportContext(rImport) -, m_xObject(xObject) +, m_xObjectWithThemeProperty(xObjectWithThemeProperty) , mpTheme(new model::Theme) { for (const auto& rAttribute : sax_fastparser::castToFastAttributeList(xAttrList)) @@ -56,7 +56,8 @@ XMLThemeContext::~XMLThemeContext() { if (mpTheme && mpTheme->getColorSet()) { -uno::Reference xPropertySet(m_xObject, uno::UNO_QUERY); +uno::Reference xPropertySet(m_xObjectWithThemeProperty, + uno::UNO_QUERY); auto xTheme = model::theme::createXTheme(mpTheme); xPropertySet->setPropertyValue("Theme", uno::Any(xTheme)); }
[Libreoffice-commits] core.git: slideshow/source
slideshow/source/engine/shapes/drawshape.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 15e0dfe709636b517bc1876caa3853606d9b499c Author: Tomaž Vajngerl AuthorDate: Tue Sep 5 11:10:45 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Tue Sep 5 20:06:02 2023 +0200 tdf#154138 C/P regression - used setWidth instead of setHeight Change-Id: I2433b4d32e939cadf499b61dfa9033125eaa3c76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156557 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 8993c8edbe77..cdda31da8a66 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -775,7 +775,7 @@ namespace slideshow::internal aAABorder.setWidth( ::std::max( rShapeBorder.getWidth(), aAABorder.getWidth() ) ); -aAABorder.setWidth( ::std::max( +aAABorder.setHeight( ::std::max( rShapeBorder.getHeight(), aAABorder.getHeight() ) ); }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - slideshow/source
slideshow/source/engine/shapes/drawshape.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit e233f4616d6a6b7ca54e3028f77bdee4061bbfab Author: Tomaž Vajngerl AuthorDate: Tue Sep 5 11:10:45 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Sep 5 13:36:09 2023 +0200 tdf#154138 C/P regression - used setWidth instead of setHeight Change-Id: I2433b4d32e939cadf499b61dfa9033125eaa3c76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156540 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index 8993c8edbe77..cdda31da8a66 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -775,7 +775,7 @@ namespace slideshow::internal aAABorder.setWidth( ::std::max( rShapeBorder.getWidth(), aAABorder.getWidth() ) ); -aAABorder.setWidth( ::std::max( +aAABorder.setHeight( ::std::max( rShapeBorder.getHeight(), aAABorder.getHeight() ) ); }
[Libreoffice-commits] core.git: xmloff/inc xmloff/source
xmloff/inc/XMLThemeContext.hxx |5 +++-- xmloff/source/style/XMLThemeContext.cxx | 11 ++- 2 files changed, 9 insertions(+), 7 deletions(-) New commits: commit ca120667c3855fbfc1e3579d4cf4ed0e3b93770a Author: Tomaž Vajngerl AuthorDate: Mon Sep 4 12:06:06 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Tue Sep 5 13:23:32 2023 +0200 xmloff: rename m_aObject in XMLThemeContext and clarify Clarify what m_aObject is in the theme import (XMLThemeContext) and rename to a better name. It is refering to an object that has the "Theme" property, which is usually found in on XPage (master page) or XModel, but technically could be any object that has the property (for getting and setting the XTheme type). Change-Id: If15a8c42a0c516cd0566f4ee9e81f7315ef1651e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156511 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/xmloff/inc/XMLThemeContext.hxx b/xmloff/inc/XMLThemeContext.hxx index f8ee08d5d4e8..c3056fa74216 100644 --- a/xmloff/inc/XMLThemeContext.hxx +++ b/xmloff/inc/XMLThemeContext.hxx @@ -24,13 +24,14 @@ class Theme; /// Imports the theme class XMLThemeContext : public SvXMLImportContext { -css::uno::Reference m_xObject; +// Any UNO object that has the "Theme" property - usually XPage (master page) or XModel +css::uno::Reference m_xObjectWithThemeProperty; std::shared_ptr mpTheme; public: XMLThemeContext(SvXMLImport& rImport, css::uno::Reference const& xAttrList, -css::uno::Reference const& xObject); +css::uno::Reference const& xObjectWithThemeProperty); ~XMLThemeContext(); css::uno::Reference SAL_CALL createFastChildContext( diff --git a/xmloff/source/style/XMLThemeContext.cxx b/xmloff/source/style/XMLThemeContext.cxx index 5c210c7a48dc..564d934ff8fb 100644 --- a/xmloff/source/style/XMLThemeContext.cxx +++ b/xmloff/source/style/XMLThemeContext.cxx @@ -31,11 +31,11 @@ using namespace css; using namespace xmloff::token; -XMLThemeContext::XMLThemeContext(SvXMLImport& rImport, - const uno::Reference& xAttrList, - css::uno::Reference const& xObject) +XMLThemeContext::XMLThemeContext( +SvXMLImport& rImport, const uno::Reference& xAttrList, +css::uno::Reference const& xObjectWithThemeProperty) : SvXMLImportContext(rImport) -, m_xObject(xObject) +, m_xObjectWithThemeProperty(xObjectWithThemeProperty) , mpTheme(new model::Theme) { for (const auto& rAttribute : sax_fastparser::castToFastAttributeList(xAttrList)) @@ -56,7 +56,8 @@ XMLThemeContext::~XMLThemeContext() { if (mpTheme && mpTheme->getColorSet()) { -uno::Reference xPropertySet(m_xObject, uno::UNO_QUERY); +uno::Reference xPropertySet(m_xObjectWithThemeProperty, + uno::UNO_QUERY); auto xTheme = model::theme::createXTheme(mpTheme); xPropertySet->setPropertyValue("Theme", uno::Any(xTheme)); }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 134 +--- 1 file changed, 64 insertions(+), 70 deletions(-) New commits: commit 1428eb1dc2f6540ec2261da6bdfd8ca2e79d7a58 Author: Tomaž Vajngerl AuthorDate: Fri Sep 1 21:20:05 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Sep 4 09:49:28 2023 +0200 tdf#147704 fix reading TIFF metadata (width and height) When we prepare (not read and load) the bitmap we need to read only the metadata - most importantly pixel width and height. This didn't work correctly for the TIFF files or more importantly the specific TIFF files in the document, and the result was that the size reported was 0,0 and somehow the crop factor wasn't applied correctly. This change fixes the metadata reading and makes it more robust. Change-Id: I60951e5d01afc311c400589496ae82377ccb4cf5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156457 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 9c636d76a9a7e167da39913ab60f5135f8e831a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156437 Reviewed-by: Xisco Fauli diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index fc43cdd963ab..1a216bb1db92 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -33,7 +33,6 @@ constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44; -constexpr sal_uInt32 DATA_SIZE = 640; namespace { @@ -716,6 +715,7 @@ bool GraphicFormatDetector::checkTIF() if (bDetectOk) { sal_uInt16 nTemp16 = 0; +sal_uInt32 nTemp32 = 0; mrStream.ReadUInt16(nTemp16); if (nTemp16 == 0x2a) @@ -725,90 +725,84 @@ bool GraphicFormatDetector::checkTIF() if (mbExtendedInfo) { -sal_uLong nCount; -sal_uLong nMax = DATA_SIZE - 48; -sal_uInt32 nTemp32 = 0; +sal_uInt32 nIfdOffset = 0; // Offset of the first IFD -mrStream.ReadUInt32(nTemp32); -nCount = nTemp32 + 2; -mrStream.SeekRel(nCount - 0x08); +mrStream.ReadUInt32(nIfdOffset); +mrStream.SeekRel(nIfdOffset - 8); // read 6 bytes until here + +sal_uInt16 nNumberOfTags = 0; +mrStream.ReadUInt16(nNumberOfTags); + +bool bOk = true; +sal_Int32 nCount = 0; -if (nCount < nMax) +// read tags till we find Tag256(Width) +mrStream.ReadUInt16(nTemp16); +while (nTemp16 != 256 && bOk) { -bool bOk = false; +mrStream.SeekRel(10); +mrStream.ReadUInt16(nTemp16); +nCount++; +if (nCount > nNumberOfTags) +bOk = false; +} -// read tags till we find Tag256 ( Width ) -// do not read more bytes than DATA_SIZE +if (bOk) +{ +// width mrStream.ReadUInt16(nTemp16); -while (nTemp16 != 256) +mrStream.SeekRel(4); +if (nTemp16 == 3) { -bOk = nCount < nMax; -if (!bOk) -{ -break; -} -mrStream.SeekRel(10); mrStream.ReadUInt16(nTemp16); -nCount += 12; +maMetadata.maPixSize.setWidth(nTemp16); +mrStream.SeekRel(2); +} +else +{ +mrStream.ReadUInt32(nTemp32); +maMetadata.maPixSize.setWidth(nTemp32); } -if (bOk) +// height +mrStream.SeekRel(2); +mrStream.ReadUInt16(nTemp16); +mrStream.SeekRel(4); +if (nTemp16 == 3) { -// width mrStream.ReadUInt16(nTemp16); -mrStream.SeekRel(4); -if (nTemp16 == 3) -{ -mrStream.ReadUInt16(nTemp16); -maMetadata.maPixSize.setWidth(nTemp16); -
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/docmodel include/oox oox/source sc/qa sc/source
include/docmodel/color/ComplexColor.hxx |2 - include/docmodel/theme/FormatScheme.hxx | 18 +-- include/oox/export/ColorExportUtils.hxx |3 - oox/source/export/ColorExportUtils.cxx |7 +++- sc/qa/unit/ucalc_DocumentThemes.cxx |1 sc/source/filter/excel/xestyle.cxx | 13 sc/source/ui/drawfunc/drawsh.cxx |6 +-- sc/source/ui/theme/ThemeColorChanger.cxx | 49 +-- 8 files changed, 53 insertions(+), 46 deletions(-) New commits: commit e6f42c8e43a0b10ff13d3b2c12717f8e0984f76d Author: Tomaž Vajngerl AuthorDate: Mon Aug 28 18:36:10 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Sep 4 09:16:28 2023 +0200 various theme and complex color related fixes Most of changes are a results of code reviews. Added comments and clarifications, removed unneeded methods, renamed variables to be more clear, protection against nullptr dereference,... Change-Id: Iae2b6abfa90b3bbd3f28328ca7fcf429765cbe9d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156203 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 03bc5199f92e70b6168e4f79600ac288aa7b26ec) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156458 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/include/docmodel/color/ComplexColor.hxx b/include/docmodel/color/ComplexColor.hxx index 92d39a28426b..01f1dac0e703 100644 --- a/include/docmodel/color/ComplexColor.hxx +++ b/include/docmodel/color/ComplexColor.hxx @@ -180,8 +180,6 @@ public: meType = ColorType::HSL; } -void setPlaceholder() { meType = ColorType::Placeholder; } - void setSystemColor(SystemColorType eSystemColorType, sal_Int32 nRGB) { maLastColor = ::Color(ColorTransparency, nRGB); diff --git a/include/docmodel/theme/FormatScheme.hxx b/include/docmodel/theme/FormatScheme.hxx index 96c8afc48214..d6812e749aba 100644 --- a/include/docmodel/theme/FormatScheme.hxx +++ b/include/docmodel/theme/FormatScheme.hxx @@ -474,19 +474,19 @@ public: { FillStyle* pFillStyle = pThis->addFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } } @@ -517,7 +517,7 @@ public: pLineStyle->maLineDash.mePresetType = PresetDashType::Solid; pLineStyle->maLineJoin.meType = LineJoinType::Miter; auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pLineStyle->maLineFillStyle.mpFill = pFill; } { @@ -529,7 +529,7 @@ public: pLineStyle->maLineDash.mePresetType = PresetDashType::Solid; pLineStyle->maLineJoin.meType = LineJoinType::Miter; auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pLineStyle->maLineFillStyle.mpFill = pFill; } { @@ -541,7 +541,7 @@ public: pLineStyle->maLineDash.mePresetType = PresetDashType::Solid; pLineStyle->maLineJoin.meType = LineJoinType::Miter; auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pLineStyle->maLineFillStyle.mpFill = pFill; } } @@ -591,19 +591,19 @@ public: { FillStyle* pFillStyle = pThis->addBackgroundFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addBackgroundFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addBackgroundFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } } diff --git
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/qa sc/source xmloff/inc xmloff/source
sc/inc/unonames.hxx |1 sc/qa/extras/scspreadsheetsettingsobj.cxx | 19 +- sc/qa/unit/ThemeImportExportTest.cxx | 85 +- sc/source/filter/xml/xmlexprt.cxx | 21 +++ sc/source/filter/xml/xmlexprt.hxx |2 sc/source/ui/unoobj/docuno.cxx| 23 xmloff/inc/XMLThemeContext.hxx|6 +- xmloff/source/style/XMLThemeContext.cxx |6 +- xmloff/source/style/xmlstyle.cxx | 22 --- 9 files changed, 154 insertions(+), 31 deletions(-) New commits: commit 72dc179044bafdfbc577fdd2a69f19bb8f08c958 Author: Tomaž Vajngerl AuthorDate: Thu Aug 31 22:29:46 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Sep 4 09:15:21 2023 +0200 sc: add ODF import/export of the Theme + tests One missing thing is the support in calc to save the Theme into the ODS document and read that back. The theme element is added as a child element to the office:styles - the same as it already is added in Writer. Also adds "Theme" property as a top level document property so it is possible to get and set the theme in xmloff. Also tests have been added to cover this usecases. Change-Id: Ic214ff5e945b77d50e6c881def9d49509560a0e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156363 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit b36f7769dd07a6b6f55cdf4ce76e2f39ed186e89) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156456 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index c644dc32391a..57f75c3d9293 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -47,6 +47,7 @@ inline constexpr OUStringLiteral SC_UNO_ROWLABELRNG = u"RowLabelRanges" inline constexpr OUStringLiteral SC_UNO_SHEETLINKS = u"SheetLinks"; inline constexpr OUStringLiteral SC_UNO_FORBIDDEN= u"ForbiddenCharacters"; inline constexpr OUStringLiteral SC_UNO_HASDRAWPAGES = u"HasDrawPages"; +inline constexpr OUStringLiteral SC_UNO_THEME= u"Theme"; // CharacterProperties inline constexpr OUStringLiteral SC_UNONAME_CCOLOR = u"CharColor"; diff --git a/sc/qa/extras/scspreadsheetsettingsobj.cxx b/sc/qa/extras/scspreadsheetsettingsobj.cxx index 117fc4d4a097..9173a80ba178 100644 --- a/sc/qa/extras/scspreadsheetsettingsobj.cxx +++ b/sc/qa/extras/scspreadsheetsettingsobj.cxx @@ -48,21 +48,10 @@ public: ScSpreadsheetSettingsObj::ScSpreadsheetSettingsObj() : UnoApiTest("/sc/qa/extras/testdocuments") -, XPropertySet({ - "AreaLinks", - "CharLocale", - "CharLocaleAsian", - "CharLocaleComplex", - "ColumnLabelRanges", - "DDELinks", - "DatabaseRanges", - "ExternalDocLinks", - "InteropGrabBag", - "NamedRanges", - "NullDate", - "RowLabelRanges", - "SheetLinks", - }) +, XPropertySet({ "AreaLinks", "CharLocale", "CharLocaleAsian", "CharLocaleComplex", + "ColumnLabelRanges", "DDELinks", "DatabaseRanges", "ExternalDocLinks", + "InteropGrabBag", "NamedRanges", "NullDate", "RowLabelRanges", "SheetLinks", + "Theme" }) { } diff --git a/sc/qa/unit/ThemeImportExportTest.cxx b/sc/qa/unit/ThemeImportExportTest.cxx index 7e054ce5fe92..7d0eb47ee2c9 100644 --- a/sc/qa/unit/ThemeImportExportTest.cxx +++ b/sc/qa/unit/ThemeImportExportTest.cxx @@ -15,6 +15,11 @@ #include #include +#include +#include +#include +#include + using namespace css; namespace @@ -28,7 +33,85 @@ public: } }; -CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testThemeExport) +CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testThemeExportAndImport) +{ +mxComponent = loadFromDesktop("private:factory/scalc"); +{ +uno::Reference xPropertySet(mxComponent, uno::UNO_QUERY_THROW); + +auto pTheme = std::make_shared("MyTheme"); +auto pColorSet = std::make_shared("MyColorSet"); +pColorSet->add(model::ThemeColorType::Dark1, 0x11); +pColorSet->add(model::ThemeColorType::Light1, 0x22); +pColorSet->add(model::ThemeColorType::Dark2, 0x33); +pColorSet->add(model::ThemeColorType::Light2, 0x44); +pColorSet->add(model::ThemeColorType::Accent1, 0x55); +pColorSet->add(model::ThemeColorType::Accent2, 0x66); +pColorSet->add(model::ThemeColorType::Accent3, 0x77); +pColorSet->add(model::ThemeColorType::Accent4, 0x88); +pColorSet->add(model::ThemeColorType::Accent5, 0x99); +pColorSet->add(model::ThemeColorType::Accent6, 0xaa); +pColorSet->add(model::ThemeColorType::Hyperlink, 0xbb); +pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xcc); +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/xmloff sw/source xmloff/source
include/xmloff/xmlexp.hxx|4 ++ sw/source/filter/xml/xmlexp.hxx |3 - sw/source/filter/xml/xmlfmte.cxx | 61 ++- xmloff/source/core/xmlexp.cxx| 48 +++ xmloff/source/draw/sdxmlexp.cxx | 44 + xmloff/source/draw/sdxmlexp_impl.hxx |2 - 6 files changed, 68 insertions(+), 94 deletions(-) New commits: commit 0d99720641f733372516fa579094dca13601efdd Author: Tomaž Vajngerl AuthorDate: Thu Aug 31 13:47:27 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Sep 4 09:12:54 2023 +0200 move theme element export to xmloff to remove code duplication Both Impress/Draw and Writer export the model::Theme in a similar way, but the code is duplicated. Remove duplication and move the code to a common place (on the SwXMLExport class) so it can be reused at both places. Change-Id: Id93acfafb0dd4ab0168b3228079f6ce6f64e6b55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156362 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit b53a03d1d55de7fd04efc47c4a57baa11d72dd85) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156455 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx index 37a9096a0b32..2fb4bb6c3062 100644 --- a/include/xmloff/xmlexp.hxx +++ b/include/xmloff/xmlexp.hxx @@ -88,6 +88,8 @@ namespace com::sun::star { } namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; } +namespace model { class Theme; } + enum class SvXMLExportFlags { NONE = 0, META = 0x0001, @@ -262,6 +264,8 @@ protected: void SetDocHandler( const css::uno::Reference< css::xml::sax::XDocumentHandler > ); +void ExportThemeElement(std::shared_ptr const& pTheme); + bool mbAutoStylesCollected; public: diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx index 3ba34a5cced4..b87051d0c8a5 100644 --- a/sw/source/filter/xml/xmlexp.hxx +++ b/sw/source/filter/xml/xmlexp.hxx @@ -90,8 +90,7 @@ class SwXMLExport : public SvXMLExport SwXMLTableInfo_Impl& rTableInfo, sal_uInt32 nHeaderRows = 0 ); -void ExportThemeElement(const css::uno::Reference& xDrawPage); - +void exportTheme(); virtual void ExportMeta_() override; virtual void ExportFontDecls_() override; diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx index 6da12046665b..74782536b1dd 100644 --- a/sw/source/filter/xml/xmlfmte.cxx +++ b/sw/source/filter/xml/xmlfmte.cxx @@ -41,9 +41,7 @@ #include #include #include -#include -#include #include #include #include @@ -184,22 +182,21 @@ void SwXMLExport::ExportStyles_( bool bUsed ) GetPageExport()->exportDefaultStyle(); // Theme -uno::Reference xDrawPageSupplier(GetModel(), UNO_QUERY); -if (xDrawPageSupplier.is()) -{ -uno::Reference xPage = xDrawPageSupplier->getDrawPage(); -if (xPage.is()) -ExportThemeElement(xPage); -} +exportTheme(); } -void SwXMLExport::ExportThemeElement(const uno::Reference& xDrawPage) +void SwXMLExport::exportTheme() { if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0) -{ -// Do not export in standard ODF 1.3 or older. return; -} + +uno::Reference xDrawPageSupplier(GetModel(), UNO_QUERY); +if (!xDrawPageSupplier.is()) +return; + +uno::Reference xDrawPage = xDrawPageSupplier->getDrawPage(); +if (!xDrawPage.is()) +return; SdrPage* pPage = GetSdrPageFromXDrawPage(xDrawPage); SAL_WARN_IF(!pPage, "oox", "Can't get SdrPage from XDrawPage"); @@ -211,43 +208,7 @@ void SwXMLExport::ExportThemeElement(const uno::Reference& x if (!pTheme) return; -if (!pTheme->GetName().isEmpty()) -AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, pTheme->GetName()); -SvXMLElementExport aTheme(*this, XML_NAMESPACE_LO_EXT, XML_THEME, true, true); - -auto pColorSet = pTheme->getColorSet(); -if (!pColorSet->getName().isEmpty()) -AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, pColorSet->getName()); -SvXMLElementExport aColorTable(*this, XML_NAMESPACE_LO_EXT, XML_THEME_COLORS, true, true); - -static const XMLTokenEnum aColorTokens[] = -{ -XML_DARK1, // Text 1 -XML_LIGHT1, // Background 1 -XML_DARK2, // Text 2 -XML_LIGHT2, // Background 2 -XML_ACCENT1, -XML_ACCENT2, -XML_ACCENT3, -XML_ACCENT4, -XML_ACCENT5, -XML_ACCENT6, -XML_HYPERLINK, // Hyperlink -XML_FOLLOWED_HYPERLINK, // Followed hyperlink -}; - -for (auto eThemeColorType : o3tl::enumrange()) -{ -if (eThemeColorType ==
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sd/source svx/source
sd/source/core/ThemeColorChanger.cxx | 42 ++- svx/source/theme/ThemeColorChangerCommon.cxx | 17 +- 2 files changed, 32 insertions(+), 27 deletions(-) New commits: commit e3a9b09ffdb6fd3bf9f1d14c11d87468c3fab92c Author: Tomaž Vajngerl AuthorDate: Thu Aug 31 08:11:18 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Sep 4 09:11:35 2023 +0200 sd: set the theme for all master pages It can be annoying for the user to set the theme one by one for each master page. The reason for this is that in MSO the master slide (which contains the theme) has multiple layouts, which are converted to master pages in LO. As LO doesn't group master pages together the theme is defined on each master page, so it is needed to change each master page one by one. Change-Id: I94d75246ca012005ab376446c0941b8f57ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156361 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 70663f464b24f223c4174681b9a469d9f554bcee) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156454 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index 573a5f085dd4..3a5c7804ae57 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -154,31 +154,35 @@ void ThemeColorChanger::apply(std::shared_ptr const& pColorSet) { SdrPage* pCurrentPage = rModel.GetPage(nPage); -// Skip pages that are usign a different master page -if (!pCurrentPage->TRG_HasMasterPage() -|| >TRG_GetMasterPage() != mpMasterPage) -continue; - -for (size_t nObject = 0; nObject < pCurrentPage->GetObjCount(); ++nObject) +// TODO - for now change all the objects regardless to which master page it belongs to. +// Currently we don't have a concept of master slide with a group of layouts as in MSO, but we always only +// have master pages, which aren't grouped together. In MSO the theme is defined per master slide, so when +// changing a theme, all the layouts get the new theme, as layouts are synonomus to master pages in LibreOffise, +// this is not possible to do and we would need to change the theme for each master page separately, which +// is just annoying for the user. + +// if (!pCurrentPage->TRG_HasMasterPage() || >TRG_GetMasterPage() != mpMasterPage) +// continue; + +SdrObjListIter aIter(pCurrentPage, SdrIterMode::DeepWithGroups); +while (aIter.IsMore()) { -SdrObject* pObject = pCurrentPage->GetObj(nObject); -svx::theme::updateSdrObject(*pColorSet, pObject, pView, pUndoManager); - -// update child objects -SdrObjList* pList = pObject->GetSubList(); -if (pList) -{ -SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups); -while (aIter.IsMore()) -{ -svx::theme::updateSdrObject(*pColorSet, aIter.Next(), pView, pUndoManager); -} -} +svx::theme::updateSdrObject(*pColorSet, aIter.Next(), pView, pUndoManager); } } changeThemeColors(mpDocShell, mpMasterPage, pColorSet); +// See the TODO comment a couple of line above for the explanation - need to change the ThemeColors for all master +// pages for now, but the following code will need to be changed in the future when we have the concept similar to +// master slide and layouts +for (sal_uInt16 nPage = 0; nPage < rModel.GetPageCount(); ++nPage) +{ +SdrPage* pCurrentPage = rModel.GetPage(nPage); +if (pCurrentPage->IsMasterPage() && pCurrentPage != mpMasterPage) +changeThemeColors(mpDocShell, pCurrentPage, pColorSet); +} + pUndoManager->LeaveListAction(); } diff --git a/svx/source/theme/ThemeColorChangerCommon.cxx b/svx/source/theme/ThemeColorChangerCommon.cxx index fab4835684a1..5ff1a0de8cd6 100644 --- a/svx/source/theme/ThemeColorChangerCommon.cxx +++ b/svx/source/theme/ThemeColorChangerCommon.cxx @@ -105,13 +105,8 @@ bool updateEditEngTextSections(model::ColorSet const& rColorSet, SdrObject* pObj bool updateObjectAttributes(model::ColorSet const& rColorSet, SdrObject& rObject, SfxUndoManager* pUndoManager) { -if (pUndoManager) -{ -pUndoManager->AddUndoAction( - rObject.getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoAttrObject( -rObject, true, true)); -} bool bChanged = false; + auto aItemSet = rObject.GetMergedItemSet(); if (const XFillColorItem* pItem = aItemSet.GetItemIfSet(XATTR_FILLCOLOR, false)) @@ -152,6 +147,13 @@ bool updateObjectAttributes(model::ColorSet const&
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 134 +--- 1 file changed, 64 insertions(+), 70 deletions(-) New commits: commit 232216c003781404c377f96cd9d45aa9e83da2e7 Author: Tomaž Vajngerl AuthorDate: Fri Sep 1 21:20:05 2023 +0200 Commit: Miklos Vajna CommitDate: Mon Sep 4 09:10:58 2023 +0200 tdf#147704 fix reading TIFF metadata (width and height) When we prepare (not read and load) the bitmap we need to read only the metadata - most importantly pixel width and height. This didn't work correctly for the TIFF files or more importantly the specific TIFF files in the document, and the result was that the size reported was 0,0 and somehow the crop factor wasn't applied correctly. This change fixes the metadata reading and makes it more robust. Change-Id: I60951e5d01afc311c400589496ae82377ccb4cf5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156457 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 9c636d76a9a7e167da39913ab60f5135f8e831a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156438 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index fc43cdd963ab..1a216bb1db92 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -33,7 +33,6 @@ constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44; -constexpr sal_uInt32 DATA_SIZE = 640; namespace { @@ -716,6 +715,7 @@ bool GraphicFormatDetector::checkTIF() if (bDetectOk) { sal_uInt16 nTemp16 = 0; +sal_uInt32 nTemp32 = 0; mrStream.ReadUInt16(nTemp16); if (nTemp16 == 0x2a) @@ -725,90 +725,84 @@ bool GraphicFormatDetector::checkTIF() if (mbExtendedInfo) { -sal_uLong nCount; -sal_uLong nMax = DATA_SIZE - 48; -sal_uInt32 nTemp32 = 0; +sal_uInt32 nIfdOffset = 0; // Offset of the first IFD -mrStream.ReadUInt32(nTemp32); -nCount = nTemp32 + 2; -mrStream.SeekRel(nCount - 0x08); +mrStream.ReadUInt32(nIfdOffset); +mrStream.SeekRel(nIfdOffset - 8); // read 6 bytes until here + +sal_uInt16 nNumberOfTags = 0; +mrStream.ReadUInt16(nNumberOfTags); + +bool bOk = true; +sal_Int32 nCount = 0; -if (nCount < nMax) +// read tags till we find Tag256(Width) +mrStream.ReadUInt16(nTemp16); +while (nTemp16 != 256 && bOk) { -bool bOk = false; +mrStream.SeekRel(10); +mrStream.ReadUInt16(nTemp16); +nCount++; +if (nCount > nNumberOfTags) +bOk = false; +} -// read tags till we find Tag256 ( Width ) -// do not read more bytes than DATA_SIZE +if (bOk) +{ +// width mrStream.ReadUInt16(nTemp16); -while (nTemp16 != 256) +mrStream.SeekRel(4); +if (nTemp16 == 3) { -bOk = nCount < nMax; -if (!bOk) -{ -break; -} -mrStream.SeekRel(10); mrStream.ReadUInt16(nTemp16); -nCount += 12; +maMetadata.maPixSize.setWidth(nTemp16); +mrStream.SeekRel(2); +} +else +{ +mrStream.ReadUInt32(nTemp32); +maMetadata.maPixSize.setWidth(nTemp32); } -if (bOk) +// height +mrStream.SeekRel(2); +mrStream.ReadUInt16(nTemp16); +mrStream.SeekRel(4); +if (nTemp16 == 3) { -// width mrStream.ReadUInt16(nTemp16); -mrStream.SeekRel(4); -if (nTemp16 == 3) -{ -mrStream.ReadUInt16(nTemp16); -
[Libreoffice-commits] core.git: vcl/source
vcl/source/filter/GraphicFormatDetector.cxx | 134 +--- 1 file changed, 64 insertions(+), 70 deletions(-) New commits: commit 9c636d76a9a7e167da39913ab60f5135f8e831a6 Author: Tomaž Vajngerl AuthorDate: Fri Sep 1 21:20:05 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Sat Sep 2 07:32:23 2023 +0200 tdf#147704 fix reading TIFF metadata (width and height) When we prepare (not read and load) the bitmap we need to read only the metadata - most importantly pixel width and height. This didn't work correctly for the TIFF files or more importantly the specific TIFF files in the document, and the result was that the size reported was 0,0 and somehow the crop factor wasn't applied correctly. This change fixes the metadata reading and makes it more robust. Change-Id: I60951e5d01afc311c400589496ae82377ccb4cf5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156457 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index d4a027d60ed3..2cf9e953003e 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -34,7 +34,6 @@ constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44; -constexpr sal_uInt32 DATA_SIZE = 640; namespace { @@ -727,6 +726,7 @@ bool GraphicFormatDetector::checkTIF() if (bDetectOk) { sal_uInt16 nTemp16 = 0; +sal_uInt32 nTemp32 = 0; mrStream.ReadUInt16(nTemp16); if (nTemp16 == 0x2a) @@ -736,90 +736,84 @@ bool GraphicFormatDetector::checkTIF() if (mbExtendedInfo) { -sal_uLong nCount; -sal_uLong nMax = DATA_SIZE - 48; -sal_uInt32 nTemp32 = 0; +sal_uInt32 nIfdOffset = 0; // Offset of the first IFD -mrStream.ReadUInt32(nTemp32); -nCount = nTemp32 + 2; -mrStream.SeekRel(nCount - 0x08); +mrStream.ReadUInt32(nIfdOffset); +mrStream.SeekRel(nIfdOffset - 8); // read 6 bytes until here + +sal_uInt16 nNumberOfTags = 0; +mrStream.ReadUInt16(nNumberOfTags); + +bool bOk = true; +sal_Int32 nCount = 0; -if (nCount < nMax) +// read tags till we find Tag256(Width) +mrStream.ReadUInt16(nTemp16); +while (nTemp16 != 256 && bOk) { -bool bOk = false; +mrStream.SeekRel(10); +mrStream.ReadUInt16(nTemp16); +nCount++; +if (nCount > nNumberOfTags) +bOk = false; +} -// read tags till we find Tag256 ( Width ) -// do not read more bytes than DATA_SIZE +if (bOk) +{ +// width mrStream.ReadUInt16(nTemp16); -while (nTemp16 != 256) +mrStream.SeekRel(4); +if (nTemp16 == 3) { -bOk = nCount < nMax; -if (!bOk) -{ -break; -} -mrStream.SeekRel(10); mrStream.ReadUInt16(nTemp16); -nCount += 12; +maMetadata.maPixSize.setWidth(nTemp16); +mrStream.SeekRel(2); +} +else +{ +mrStream.ReadUInt32(nTemp32); +maMetadata.maPixSize.setWidth(nTemp32); } -if (bOk) +// height +mrStream.SeekRel(2); +mrStream.ReadUInt16(nTemp16); +mrStream.SeekRel(4); +if (nTemp16 == 3) { -// width mrStream.ReadUInt16(nTemp16); -mrStream.SeekRel(4); -if (nTemp16 == 3) -{ -mrStream.ReadUInt16(nTemp16); -maMetadata.maPixSize.setWidth(nTemp16); -mrStream.SeekRel(2); -} -else -{ -
[Libreoffice-commits] core.git: include/docmodel include/oox oox/source sc/qa sc/source
include/docmodel/color/ComplexColor.hxx |2 - include/docmodel/theme/FormatScheme.hxx | 18 +-- include/oox/export/ColorExportUtils.hxx |3 - oox/source/export/ColorExportUtils.cxx |7 +++- sc/qa/unit/ucalc_DocumentThemes.cxx |1 sc/source/filter/excel/xestyle.cxx | 13 sc/source/ui/drawfunc/drawsh.cxx |6 +-- sc/source/ui/theme/ThemeColorChanger.cxx | 49 +-- 8 files changed, 53 insertions(+), 46 deletions(-) New commits: commit 03bc5199f92e70b6168e4f79600ac288aa7b26ec Author: Tomaž Vajngerl AuthorDate: Mon Aug 28 18:36:10 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Fri Sep 1 22:52:16 2023 +0200 various theme and complex color related fixes Most of changes are a results of code reviews. Added comments and clarifications, removed unneeded methods, renamed variables to be more clear, protection against nullptr dereference,... Change-Id: Iae2b6abfa90b3bbd3f28328ca7fcf429765cbe9d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156203 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/docmodel/color/ComplexColor.hxx b/include/docmodel/color/ComplexColor.hxx index 4cec9e972503..0fc99a12617b 100644 --- a/include/docmodel/color/ComplexColor.hxx +++ b/include/docmodel/color/ComplexColor.hxx @@ -180,8 +180,6 @@ public: meType = ColorType::HSL; } -void setPlaceholder() { meType = ColorType::Placeholder; } - void setSystemColor(SystemColorType eSystemColorType, sal_Int32 nRGB) { maLastColor = ::Color(ColorTransparency, nRGB); diff --git a/include/docmodel/theme/FormatScheme.hxx b/include/docmodel/theme/FormatScheme.hxx index 96c8afc48214..d6812e749aba 100644 --- a/include/docmodel/theme/FormatScheme.hxx +++ b/include/docmodel/theme/FormatScheme.hxx @@ -474,19 +474,19 @@ public: { FillStyle* pFillStyle = pThis->addFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } } @@ -517,7 +517,7 @@ public: pLineStyle->maLineDash.mePresetType = PresetDashType::Solid; pLineStyle->maLineJoin.meType = LineJoinType::Miter; auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pLineStyle->maLineFillStyle.mpFill = pFill; } { @@ -529,7 +529,7 @@ public: pLineStyle->maLineDash.mePresetType = PresetDashType::Solid; pLineStyle->maLineJoin.meType = LineJoinType::Miter; auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pLineStyle->maLineFillStyle.mpFill = pFill; } { @@ -541,7 +541,7 @@ public: pLineStyle->maLineDash.mePresetType = PresetDashType::Solid; pLineStyle->maLineJoin.meType = LineJoinType::Miter; auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pLineStyle->maLineFillStyle.mpFill = pFill; } } @@ -591,19 +591,19 @@ public: { FillStyle* pFillStyle = pThis->addBackgroundFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addBackgroundFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } { FillStyle* pFillStyle = pThis->addBackgroundFillStyle(); auto pFill = std::make_shared(); -pFill->maColor.setPlaceholder(); +pFill->maColor.setThemePlaceholder(); pFillStyle->mpFill = pFill; } } diff --git a/include/oox/export/ColorExportUtils.hxx b/include/oox/export/ColorExportUtils.hxx index f9dafe260b46..01b3503e00a3 100644 --- a/include/oox/export/ColorExportUtils.hxx +++ b/include/oox/export/ColorExportUtils.hxx @@ -14,9
[Libreoffice-commits] core.git: 2 commits - include/xmloff sc/inc sc/qa sc/source sw/source xmloff/inc xmloff/source
include/xmloff/xmlexp.hxx |4 + sc/inc/unonames.hxx |1 sc/qa/extras/scspreadsheetsettingsobj.cxx | 19 +- sc/qa/unit/ThemeImportExportTest.cxx | 85 +- sc/source/filter/xml/xmlexprt.cxx | 21 +++ sc/source/filter/xml/xmlexprt.hxx |2 sc/source/ui/unoobj/docuno.cxx| 23 sw/source/filter/xml/xmlexp.hxx |3 - sw/source/filter/xml/xmlfmte.cxx | 61 +++-- xmloff/inc/XMLThemeContext.hxx|6 +- xmloff/source/core/xmlexp.cxx | 48 xmloff/source/draw/sdxmlexp.cxx | 44 +-- xmloff/source/draw/sdxmlexp_impl.hxx |2 xmloff/source/style/XMLThemeContext.cxx |6 +- xmloff/source/style/xmlstyle.cxx | 22 --- 15 files changed, 222 insertions(+), 125 deletions(-) New commits: commit b36f7769dd07a6b6f55cdf4ce76e2f39ed186e89 Author: Tomaž Vajngerl AuthorDate: Thu Aug 31 22:29:46 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Fri Sep 1 10:12:11 2023 +0200 sc: add ODF import/export of the Theme + tests One missing thing is the support in calc to save the Theme into the ODS document and read that back. The theme element is added as a child element to the office:styles - the same as it already is added in Writer. Also adds "Theme" property as a top level document property so it is possible to get and set the theme in xmloff. Also tests have been added to cover this usecases. Change-Id: Ic214ff5e945b77d50e6c881def9d49509560a0e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156363 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 522582a36fb5..f88d89fdd2f0 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -47,6 +47,7 @@ inline constexpr OUStringLiteral SC_UNO_ROWLABELRNG = u"RowLabelRanges" inline constexpr OUStringLiteral SC_UNO_SHEETLINKS = u"SheetLinks"; inline constexpr OUStringLiteral SC_UNO_FORBIDDEN= u"ForbiddenCharacters"; inline constexpr OUStringLiteral SC_UNO_HASDRAWPAGES = u"HasDrawPages"; +inline constexpr OUStringLiteral SC_UNO_THEME= u"Theme"; // CharacterProperties inline constexpr OUStringLiteral SC_UNONAME_CCOLOR = u"CharColor"; diff --git a/sc/qa/extras/scspreadsheetsettingsobj.cxx b/sc/qa/extras/scspreadsheetsettingsobj.cxx index 117fc4d4a097..9173a80ba178 100644 --- a/sc/qa/extras/scspreadsheetsettingsobj.cxx +++ b/sc/qa/extras/scspreadsheetsettingsobj.cxx @@ -48,21 +48,10 @@ public: ScSpreadsheetSettingsObj::ScSpreadsheetSettingsObj() : UnoApiTest("/sc/qa/extras/testdocuments") -, XPropertySet({ - "AreaLinks", - "CharLocale", - "CharLocaleAsian", - "CharLocaleComplex", - "ColumnLabelRanges", - "DDELinks", - "DatabaseRanges", - "ExternalDocLinks", - "InteropGrabBag", - "NamedRanges", - "NullDate", - "RowLabelRanges", - "SheetLinks", - }) +, XPropertySet({ "AreaLinks", "CharLocale", "CharLocaleAsian", "CharLocaleComplex", + "ColumnLabelRanges", "DDELinks", "DatabaseRanges", "ExternalDocLinks", + "InteropGrabBag", "NamedRanges", "NullDate", "RowLabelRanges", "SheetLinks", + "Theme" }) { } diff --git a/sc/qa/unit/ThemeImportExportTest.cxx b/sc/qa/unit/ThemeImportExportTest.cxx index 9eac3762d6af..e8e1a31dbbff 100644 --- a/sc/qa/unit/ThemeImportExportTest.cxx +++ b/sc/qa/unit/ThemeImportExportTest.cxx @@ -15,6 +15,11 @@ #include #include +#include +#include +#include +#include + using namespace css; namespace @@ -28,7 +33,85 @@ public: } }; -CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testThemeExport) +CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testThemeExportAndImport) +{ +mxComponent = loadFromDesktop("private:factory/scalc"); +{ +uno::Reference xPropertySet(mxComponent, uno::UNO_QUERY_THROW); + +auto pTheme = std::make_shared("MyTheme"); +auto pColorSet = std::make_shared("MyColorSet"); +pColorSet->add(model::ThemeColorType::Dark1, 0x11); +pColorSet->add(model::ThemeColorType::Light1, 0x22); +pColorSet->add(model::ThemeColorType::Dark2, 0x33); +pColorSet->add(model::ThemeColorType::Light2, 0x44); +pColorSet->add(model::ThemeColorType::Accent1, 0x55); +pColorSet->add(model::ThemeColorType::Accent2, 0x66); +pColorSet->add(model::ThemeColorType::Accent3, 0x77); +pColorSet->add(model::ThemeColorType::Accent4, 0x88); +pColorSet->add(model::ThemeColorType::Accent5, 0x99); +pColorSet->add(model::ThemeColorType::Accent6, 0xaa); +
[Libreoffice-commits] core.git: sd/source svx/source
sd/source/core/ThemeColorChanger.cxx | 42 ++- svx/source/theme/ThemeColorChangerCommon.cxx | 17 +- 2 files changed, 32 insertions(+), 27 deletions(-) New commits: commit 70663f464b24f223c4174681b9a469d9f554bcee Author: Tomaž Vajngerl AuthorDate: Thu Aug 31 08:11:18 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Fri Sep 1 07:29:02 2023 +0200 sd: set the theme for all master pages It can be annoying for the user to set the theme one by one for each master page. The reason for this is that in MSO the master slide (which contains the theme) has multiple layouts, which are converted to master pages in LO. As LO doesn't group master pages together the theme is defined on each master page, so it is needed to change each master page one by one. Change-Id: I94d75246ca012005ab376446c0941b8f57ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156361 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index adfacb6a47ac..3a5c7804ae57 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -154,31 +154,35 @@ void ThemeColorChanger::apply(std::shared_ptr const& pColorSet) { SdrPage* pCurrentPage = rModel.GetPage(nPage); -// Skip pages that are using a different master page -if (!pCurrentPage->TRG_HasMasterPage() -|| >TRG_GetMasterPage() != mpMasterPage) -continue; - -for (size_t nObject = 0; nObject < pCurrentPage->GetObjCount(); ++nObject) +// TODO - for now change all the objects regardless to which master page it belongs to. +// Currently we don't have a concept of master slide with a group of layouts as in MSO, but we always only +// have master pages, which aren't grouped together. In MSO the theme is defined per master slide, so when +// changing a theme, all the layouts get the new theme, as layouts are synonomus to master pages in LibreOffise, +// this is not possible to do and we would need to change the theme for each master page separately, which +// is just annoying for the user. + +// if (!pCurrentPage->TRG_HasMasterPage() || >TRG_GetMasterPage() != mpMasterPage) +// continue; + +SdrObjListIter aIter(pCurrentPage, SdrIterMode::DeepWithGroups); +while (aIter.IsMore()) { -SdrObject* pObject = pCurrentPage->GetObj(nObject); -svx::theme::updateSdrObject(*pColorSet, pObject, pView, pUndoManager); - -// update child objects -SdrObjList* pList = pObject->GetSubList(); -if (pList) -{ -SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups); -while (aIter.IsMore()) -{ -svx::theme::updateSdrObject(*pColorSet, aIter.Next(), pView, pUndoManager); -} -} +svx::theme::updateSdrObject(*pColorSet, aIter.Next(), pView, pUndoManager); } } changeThemeColors(mpDocShell, mpMasterPage, pColorSet); +// See the TODO comment a couple of line above for the explanation - need to change the ThemeColors for all master +// pages for now, but the following code will need to be changed in the future when we have the concept similar to +// master slide and layouts +for (sal_uInt16 nPage = 0; nPage < rModel.GetPageCount(); ++nPage) +{ +SdrPage* pCurrentPage = rModel.GetPage(nPage); +if (pCurrentPage->IsMasterPage() && pCurrentPage != mpMasterPage) +changeThemeColors(mpDocShell, pCurrentPage, pColorSet); +} + pUndoManager->LeaveListAction(); } diff --git a/svx/source/theme/ThemeColorChangerCommon.cxx b/svx/source/theme/ThemeColorChangerCommon.cxx index 44f041f5f3b0..446943100101 100644 --- a/svx/source/theme/ThemeColorChangerCommon.cxx +++ b/svx/source/theme/ThemeColorChangerCommon.cxx @@ -104,13 +104,8 @@ bool updateEditEngTextSections(model::ColorSet const& rColorSet, SdrObject* pObj bool updateObjectAttributes(model::ColorSet const& rColorSet, SdrObject& rObject, SfxUndoManager* pUndoManager) { -if (pUndoManager) -{ -pUndoManager->AddUndoAction( - rObject.getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoAttrObject( -rObject, true, true)); -} bool bChanged = false; + auto aItemSet = rObject.GetMergedItemSet(); if (const XFillColorItem* pItem = aItemSet.GetItemIfSet(XATTR_FILLCOLOR, false)) @@ -151,6 +146,13 @@ bool updateObjectAttributes(model::ColorSet const& rColorSet, SdrObject& rObject } if (bChanged) { +const bool bUndo = pUndoManager && pUndoManager->IsInListAction(); +if (bUndo) +{ +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5-6' - sw/source
sw/source/core/access/AccessibilityCheck.cxx |2 ++ 1 file changed, 2 insertions(+) New commits: commit 83bdc4ad3c4e8e8e9df1b163f236e9b4cdc7e869 Author: Tomaž Vajngerl AuthorDate: Fri May 19 22:56:57 2023 +0900 Commit: Christian Lohmaier CommitDate: Wed Aug 30 12:26:05 2023 +0200 sw: prevent crash in TextContrastCheck Change-Id: Idc8740a275b9f49aca08d8a3add9a88f9d53a220 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152012 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit c53a8284cf1740af7035b952fbc040a785117319) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155789 Reviewed-by: Michael Stahl (cherry picked from commit 7f51cf11bca0b1712bf0877007c99cc0bfcee074) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155910 Reviewed-by: Xisco Fauli Tested-by: Christian Lohmaier Reviewed-by: Christian Lohmaier diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index ac558a44c69e..2121ed10519b 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -436,6 +436,8 @@ private: } const SwPageDesc* pPageDescription = pTextNode->FindPageDesc(); +if (!pPageDescription) +return; const SwFrameFormat& rPageFormat = pPageDescription->GetMaster(); const SwAttrSet& rPageSet = rPageFormat.GetAttrSet();
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sd/source
sd/source/ui/view/drviewsf.cxx | 15 --- 1 file changed, 15 deletions(-) New commits: commit 62804da3c0ab9443cf36f2e02387a2e9c272d5dc Author: Tomaž Vajngerl AuthorDate: Wed Aug 30 09:15:56 2023 +0200 Commit: Miklos Vajna CommitDate: Wed Aug 30 11:16:05 2023 +0200 sd: remove condition to only show ThemeDialog in master view Change-Id: I09ce07f7b520688aa54dd30107b5ab2218b12894 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156277 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index e25ebed52dd3..8f75b9f8081c 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -469,21 +469,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) } break; -case SID_THEME_DIALOG: -{ -bool bDisable = true; -SdrPageView* pPageView = mpDrawView->GetSdrPageView(); -if (pPageView) -{ -SdPage* pPage = dynamic_cast(pPageView->GetPage()); -if (pPage && pPage->IsMasterPage()) -bDisable = false; -} -if (bDisable) -rSet.DisableItem(nWhich); -} -break; - case SID_STYLE_FAMILY2: case SID_STYLE_FAMILY3: case SID_STYLE_FAMILY5:
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - 2 commits - include/svx oox/source sc/qa sc/source sd/Library_sd.mk sd/qa sd/source svx/source sw/qa sw/source
include/svx/svdmodel.hxx |5 ++ include/svx/svdpage.hxx|4 +- oox/source/drawingml/theme.cxx |2 - sc/qa/unit/ucalc_DocumentThemes.cxx|8 +--- sc/qa/unit/ucalc_sparkline.cxx |4 -- sc/source/filter/excel/excdoc.cxx | 26 + sc/source/filter/oox/workbookfragment.cxx |5 +- sc/source/ui/docshell/docsh.cxx| 14 +-- sc/source/ui/theme/ThemeColorChanger.cxx | 16 +--- sc/source/ui/undo/UndoThemeChange.cxx | 36 -- sc/source/ui/view/tabvwsh3.cxx |9 ++-- sd/Library_sd.mk |1 sd/qa/unit/ThemeTest.cxx |2 - sd/source/core/ThemeColorChanger.cxx | 23 +--- sd/source/filter/eppt/pptx-epptooxml.cxx |2 - sd/source/ui/dlg/UndoThemeChange.cxx | 55 + sd/source/ui/docshell/docshell.cxx |4 +- sd/source/ui/inc/UndoThemeChange.hxx | 39 sd/source/ui/unoidl/unopage.cxx|8 ++-- sd/source/ui/view/drviews2.cxx |2 - svx/source/form/fmmodel.cxx|8 +--- svx/source/svdraw/svdmodel.cxx |2 + svx/source/svdraw/svdpage.cxx | 36 +++--- sw/qa/core/theme/ThemeTest.cxx | 22 ++- sw/source/core/model/ThemeColorChanger.cxx |6 +-- sw/source/core/undo/UndoThemeChange.cxx|8 ++-- sw/source/core/unocore/unodraw.cxx |4 +- sw/source/filter/ww8/docxexport.cxx|6 ++- sw/source/filter/xml/xmlfmte.cxx |3 + sw/source/uibase/app/docst.cxx |6 +-- sw/source/uibase/shells/basesh.cxx | 10 ++--- 31 files changed, 240 insertions(+), 136 deletions(-) New commits: commit 54d9425bc3165ed2bbab67c4719e6a0146a2c663 Author: Tomaž Vajngerl AuthorDate: Sun Aug 27 22:34:13 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Mon Aug 28 18:10:50 2023 +0200 sd: add undo/redo action for changing the model::ColorSet And add the undo action when changing the theme colors in the ThemeColorChanger. Change-Id: Ibeee8aeff420b42fd961e0abd630569e74075585 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156178 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit d3b06d044fafec0b31ada9ecbaf60f396555fb12) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156189 Tested-by: Jenkins CollaboraOffice Reviewed-by: Ashod Nakashian diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 24e3c985a4ee..1d7333176c16 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -246,6 +246,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/dlg/sdtreelb \ sd/source/ui/dlg/titledockwin \ sd/source/ui/dlg/unchss \ + sd/source/ui/dlg/UndoThemeChange \ sd/source/ui/docshell/docshel2 \ sd/source/ui/docshell/docshel3 \ sd/source/ui/docshell/docshel4 \ diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index 8d2a80aec281..573a5f085dd4 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -24,6 +24,8 @@ #include #include #include +#include +#include using namespace css; @@ -39,7 +41,8 @@ ThemeColorChanger::~ThemeColorChanger() = default; namespace { -void changeTheTheme(SdrPage* pMasterPage, std::shared_ptr const& pColorSet) +void changeThemeColors(sd::DrawDocShell* pDocShell, SdrPage* pMasterPage, + std::shared_ptr const& pNewColorSet) { auto pTheme = pMasterPage->getSdrPageProperties().getTheme(); if (!pTheme) @@ -47,7 +50,17 @@ void changeTheTheme(SdrPage* pMasterPage, std::shared_ptr const pTheme = std::make_shared("Office"); pMasterPage->getSdrPageProperties().setTheme(pTheme); } -pTheme->setColorSet(pColorSet); + +std::shared_ptr const& pOldColorSet = pTheme->getColorSet(); + +auto* pUndoManager = pDocShell->GetUndoManager(); +if (pUndoManager) +{ +pUndoManager->AddUndoAction(std::make_unique( +pDocShell->GetDoc(), pMasterPage, pOldColorSet, pNewColorSet)); +} + +pTheme->setColorSet(pNewColorSet); } bool changeStyle(sd::DrawDocShell* pDocShell, SdStyleSheet* pStyle, @@ -164,7 +177,7 @@ void ThemeColorChanger::apply(std::shared_ptr const& pColorSet) } } -changeTheTheme(mpMasterPage, pColorSet); +changeThemeColors(mpDocShell, mpMasterPage, pColorSet); pUndoManager->LeaveListAction(); } diff --git a/sd/source/ui/dlg/UndoThemeChange.cxx b/sd/source/ui/dlg/UndoThemeChange.cxx new file mode 100644 index ..1270dc06cab7 --- /dev/null +++ b/sd/source/ui/dlg/UndoThemeChange.cxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - 2 commits - cui/Library_cui.mk cui/qa cui/source cui/uiconfig cui/UIConfig_cui.mk include/svx sd/inc sd/qa sd/source sd/uiconfig
cui/Library_cui.mk |1 cui/UIConfig_cui.mk|1 cui/qa/uitest/tabpages/themepage.py| 87 - cui/source/factory/dlgfact.cxx |5 cui/source/inc/themepage.hxx | 53 --- cui/source/tabpages/themepage.cxx | 176 -- cui/uiconfig/ui/themetabpage.ui| 557 - include/svx/dialogs.hrc|1 sd/inc/sdabstdlg.hxx |2 sd/qa/unit/dialogs-test.cxx|2 sd/source/ui/dlg/dlgpage.cxx |9 sd/source/ui/dlg/sddlgfact.cxx |4 sd/source/ui/dlg/sddlgfact.hxx |2 sd/source/ui/func/fupage.cxx | 29 - sd/source/ui/inc/dlgpage.hxx |2 sd/source/ui/view/drviewsf.cxx | 18 + sd/uiconfig/sdraw/ui/drawpagedialog.ui | 181 +- 17 files changed, 54 insertions(+), 1076 deletions(-) New commits: commit a66c077ed90bb1a80fdc678641da64ce58045f98 Author: Tomaž Vajngerl AuthorDate: Tue Aug 22 08:14:10 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Mon Aug 28 18:10:19 2023 +0200 sd: remove theme tab page Change-Id: Iffb3d0f6d6933891333da68fa4569a3638ba18f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156123 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit f4ed90bcad83ea24644c1cbf077b369ae05f004e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156174 Tested-by: Jenkins CollaboraOffice Reviewed-by: Ashod Nakashian diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk index 03a1577ee66b..43d13810d5c1 100644 --- a/cui/Library_cui.mk +++ b/cui/Library_cui.mk @@ -229,7 +229,6 @@ $(eval $(call gb_Library_add_exception_objects,cui,\ cui/source/tabpages/textanim \ cui/source/tabpages/textattr \ cui/source/tabpages/TextColumnsPage \ -cui/source/tabpages/themepage \ cui/source/tabpages/tparea \ cui/source/tabpages/tpbitmap \ cui/source/tabpages/tpcolor \ diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk index 6985163f6922..a863e155dd04 100644 --- a/cui/UIConfig_cui.mk +++ b/cui/UIConfig_cui.mk @@ -219,7 +219,6 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\ cui/uiconfig/ui/textcolumnstabpage \ cui/uiconfig/ui/textdialog \ cui/uiconfig/ui/textflowpage \ - cui/uiconfig/ui/themetabpage \ cui/uiconfig/ui/thesaurus \ cui/uiconfig/ui/toolbarmodedialog \ cui/uiconfig/ui/transparencytabpage \ diff --git a/cui/qa/uitest/tabpages/themepage.py b/cui/qa/uitest/tabpages/themepage.py deleted file mode 100644 index 0145f0345492.. --- a/cui/qa/uitest/tabpages/themepage.py +++ /dev/null @@ -1,87 +0,0 @@ -# -# 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/. -# - -from libreoffice.uno.propertyvalue import convert_property_values_to_dict -from libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.framework import UITestCase -from uitest.uihelper.common import get_state_as_dict -from uitest.uihelper.common import select_pos -from uitest.uihelper.common import select_by_text - -# Test for cui/source/tabpages/themepage.cxx. -class Test(UITestCase): - -def testThemePage(self): -# Given an Impress document with a master page that has a theme: -with self.ui_test.create_doc_in_start_center("impress") as component: -template = self.xUITest.getTopFocusWindow() - self.ui_test.close_dialog_through_button(template.getChild("close")) -doc = self.xUITest.getTopFocusWindow() -editWin = doc.getChild("impress_win") -drawPage = component.getDrawPages().getByIndex(0) -master = drawPage.MasterPage -theme = mkPropertyValues({ -"Name": "nameA", -"ColorSchemeName": "colorSetA", -"ColorScheme": tuple([ -0x00, # dk1 -0x00, # lt1 -0x00, # dk2 -0x00, # lt2 -0xff, # accent1 -0x00, # accent2 -0x00, # accent3 -0x00, # accent4 -0x00, # accent5 -0x00, # accent6 -0x00, # hlink -0x00, # folHlink -]) -}) -master.ThemeUnoRepresentation = theme - -# When changing the name of the theme: -self.xUITest.executeCommand(".uno:SlideMasterPage") -with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xDialog: -xTabs = xDialog.getChild("tabcontrol") -# Select RID_SVXPAGE_THEME. -select_pos(xTabs, "3") -
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/svx sd/qa sd/source svx/sdi
include/svx/svxids.hrc |6 ++-- sd/qa/unit/uiimpress.cxx | 54 - sd/source/ui/view/drtxtob1.cxx | 24 -- sd/source/ui/view/drviews2.cxx | 29 -- svx/sdi/svx.sdi|4 +-- 5 files changed, 42 insertions(+), 75 deletions(-) New commits: commit 43fe1db03512bccd0c36b7037172378c8965fda0 Author: Tomaž Vajngerl AuthorDate: Fri Aug 18 22:31:51 2023 +0200 Commit: Tomaž Vajngerl CommitDate: Mon Aug 28 18:09:50 2023 +0200 svx: remove theme related parameters for Color and FillColor For SvxColorItem, XFillColorItem, XLineColorItem,... we set the ComplexColor via the JSON additional UNO Command argument, so we don't need the parameters to set the theme color and LumOff and LumMod color modifiers for the UNO Command. Actually this has broken the setting the colors in certain situations, so we must remove this. Change-Id: Ic28aa1e43559d3627703d93c7c1bd9310a149986 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155864 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 6471181b66ebe634e9ffbdc2b55dbf1da17a3acf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156172 Tested-by: Jenkins CollaboraOffice Reviewed-by: Ashod Nakashian diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 90aae09d2c69..2f18af269fd1 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -450,9 +450,9 @@ class XFillGradientItem; #define SID_ATTR_TEXTCOLUMNS_SPACING( SID_SVX_START + 341 ) // FREE ( SID_SVX_START + 342 ) -#define SID_ATTR_COLOR_THEME_INDEX TypedWhichId( SID_SVX_START + 343 ) -#define SID_ATTR_COLOR_LUM_MOD TypedWhichId( SID_SVX_START + 344 ) -#define SID_ATTR_COLOR_LUM_OFF TypedWhichId( SID_SVX_START + 345 ) +// FREE ( SID_SVX_START + 343 ) +// FREE ( SID_SVX_START + 344 ) +// FREE ( SID_SVX_START + 345 ) #define SID_SB_CONNECTIONPOOLING( SID_SVX_START + 348 ) #define SID_SB_DBREGISTEROPTIONS( SID_SVX_START + 349 ) diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index fc75ec4727eb..7baaf08490e7 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -1012,14 +1013,23 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testCharColorTheme) Scheduler::ProcessEventsToIdle(); // When picking a theme color on the sidebar: -uno::Sequence aColorArgs = { -comphelper::makePropertyValue("Color", static_cast(0xdae3f3)), // 80% light blue -comphelper::makePropertyValue("ColorThemeIndex", static_cast(4)), // accent 1 -comphelper::makePropertyValue("ColorLumMod", static_cast(2000)), -comphelper::makePropertyValue("ColorLumOff", static_cast(8000)), -}; -dispatchCommand(mxComponent, ".uno:Color", aColorArgs); -Scheduler::ProcessEventsToIdle(); +{ +model::ComplexColor aComplexColor; +aComplexColor.setThemeColor(model::ThemeColorType::Accent1); +aComplexColor.addTransformation({ model::TransformationType::LumMod, 2000 }); +aComplexColor.addTransformation({ model::TransformationType::LumOff, 8000 }); + +OUString aJSON += OStringToOUString(model::color::convertToJSON(aComplexColor), RTL_TEXTENCODING_UTF8); + +// When setting the fill color of that shape, with theme metadata & effects: +uno::Sequence aColorArgs = { +comphelper::makePropertyValue("Color.Color", sal_Int32(0xdae3f3)), // 80% light blue +comphelper::makePropertyValue("Color.ComplexColorJSON", uno::Any(aJSON)), +}; +dispatchCommand(mxComponent, ".uno:Color", aColorArgs); +Scheduler::ProcessEventsToIdle(); +} // Then make sure the theme "metadata" is set in the document model: pView->EndTextEditCurrentView(); @@ -1057,15 +1067,25 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorTheme) uno::UNO_QUERY); xController->select(uno::Any(xShape)); -// When setting the fill color of that shape, with theme metadata & effects: -uno::Sequence aColorArgs = { -comphelper::makePropertyValue("FillColor", static_cast(0xed7d31)), // orange -comphelper::makePropertyValue("ColorThemeIndex", static_cast(4)), // accent 1 -comphelper::makePropertyValue("ColorLumMod", static_cast(4000)), -comphelper::makePropertyValue("ColorLumOff", static_cast(6000)), -}; -dispatchCommand(mxComponent,
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - cui/source
cui/source/tabpages/chardlg.cxx | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) New commits: commit 431f9322863d0002b67469741a967b408d301905 Author: Tomaž Vajngerl AuthorDate: Fri Aug 18 22:28:33 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Aug 28 12:44:46 2023 +0200 cui: use common menthod to get the complex color from a NamedColor NamedColor implements a getComplexColor method, which creates the ComplexColor from the NamedColor attributes. We don't need to do this ourselves. Change-Id: If2629d49b7b2e561b85b93314f56a95492cafd93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155863 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 3f7e9b2ea67a8de9ad9dd819ec2eb91e8180af95) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156166 Tested-by: Jenkins CollaboraOffice Reviewed-by: Mike Kaganski diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 325b7925fb66..716e193af45e 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -1594,18 +1594,7 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet ) if (bChanged) { -SvxColorItem aItem( aSelectedColor.m_aColor, nWhich ); - -// The color was picked from the theme palette, remember its index. -model::ThemeColorType eType = model::convertToThemeColorType(aSelectedColor.m_nThemeIndex); -if (eType != model::ThemeColorType::Unknown) -{ -auto aComplexColor = model::ComplexColor::Theme(eType); - aComplexColor.addTransformation({model::TransformationType::LumMod, aSelectedColor.m_nLumMod}); - aComplexColor.addTransformation({model::TransformationType::LumOff, aSelectedColor.m_nLumOff}); -aItem.setComplexColor(aComplexColor); -} - +SvxColorItem aItem(aSelectedColor.m_aColor, aSelectedColor.getComplexColor(), nWhich); rSet.Put(aItem); } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - 2 commits - include/svx sc/source sd/source svx/source sw/source
include/svx/theme/ThemeColorChangerCommon.hxx |5 sc/source/ui/theme/ThemeColorChanger.cxx | 21 +- sd/source/core/ThemeColorChanger.cxx | 29 +++ svx/source/theme/ThemeColorChangerCommon.cxx | 192 -- sw/source/core/model/ThemeColorChanger.cxx| 19 ++ 5 files changed, 175 insertions(+), 91 deletions(-) New commits: commit 151e55ba811a4fddcefe26601c26447f7085b359 Author: Tomaž Vajngerl AuthorDate: Thu Aug 17 22:35:26 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Aug 28 12:44:30 2023 +0200 svx: refactor text color theme changing and add undo support This refactors text theme color changing to use editeng directly and also makes it possible to add undo support. Some refactoring changes were also needed in Writer and Calc ThemeColorChanger implementations. Change-Id: I5cc21205aa3866f65f5b2132ecaa760292401263 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155819 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 32400a791522d90c3b9b731b73c751b7967f660c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156165 Tested-by: Jenkins CollaboraOffice Reviewed-by: Mike Kaganski diff --git a/include/svx/theme/ThemeColorChangerCommon.hxx b/include/svx/theme/ThemeColorChangerCommon.hxx index 235648df2cab..d60d9c1ba7fb 100644 --- a/include/svx/theme/ThemeColorChangerCommon.hxx +++ b/include/svx/theme/ThemeColorChangerCommon.hxx @@ -14,12 +14,15 @@ #include #include #include +#include +#include namespace svx { namespace theme { -SVXCORE_DLLPUBLIC void updateSdrObject(model::ColorSet const& rColorSet, SdrObject* pObject); +SVXCORE_DLLPUBLIC void updateSdrObject(model::ColorSet const& rColorSet, SdrObject* pObject, + SdrView* pView, SfxUndoManager* pUndoManager = nullptr); } } // end svx namespace diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx b/sc/source/ui/theme/ThemeColorChanger.cxx index acef84f89fa0..4b1b555ec647 100644 --- a/sc/source/ui/theme/ThemeColorChanger.cxx +++ b/sc/source/ui/theme/ThemeColorChanger.cxx @@ -151,7 +151,7 @@ bool changeStyles(ScDocShell& rDocShell, std::shared_ptr const& return bChanged; } -bool changeSheets(ScDocShell& rDocShell, ScDrawLayer* pModel, +bool changeSheets(ScDocShell& rDocShell, ScTabViewShell* pViewShell, ScDrawLayer* pModel, std::shared_ptr const& pColorSet) { ScDocument& rDocument = rDocShell.GetDocument(); @@ -209,14 +209,15 @@ bool changeSheets(ScDocShell& rDocShell, ScDrawLayer* pModel, // Change all SdrObjects { pModel->BeginCalcUndo(true); +SdrView* pView = nullptr; +if (pViewShell) +pView = pViewShell->GetScDrawView(); SdrPage* pPage = pModel->GetPage(static_cast(nTab)); SdrObjListIter aIter(pPage, SdrIterMode::DeepNoGroups); -SdrObject* pObject = aIter.Next(); -while (pObject) +for (SdrObject* pObject = aIter.Next(); pObject; pObject = aIter.Next()) { -svx::theme::updateSdrObject(*pColorSet, pObject); -pObject = aIter.Next(); +svx::theme::updateSdrObject(*pColorSet, pObject, pView, rDocShell.GetUndoManager()); } std::unique_ptr pUndo = pModel->GetCalcUndo(); @@ -224,7 +225,6 @@ bool changeSheets(ScDocShell& rDocShell, ScDrawLayer* pModel, if (pUndo) { bChanged = true; -pUndo->SetComment("Hi!"); auto pUndoDraw = std::make_unique(std::move(pUndo), ); rDocShell.GetUndoManager()->AddUndoAction(std::move(pUndoDraw)); } @@ -316,9 +316,11 @@ void ThemeColorChanger::apply(std::shared_ptr const& pColorSet) const bool bUndo(rDocument.IsUndoEnabled()); +ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + ViewShellId nViewShellId(-1); -if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell()) -nViewShellId = pViewSh->GetViewShellId(); +if (pViewShell) +nViewShellId = pViewShell->GetViewShellId(); if (bUndo) { @@ -328,7 +330,8 @@ void ThemeColorChanger::apply(std::shared_ptr const& pColorSet) bool bChanged = false; bChanged = changeStyles(m_rDocShell, pColorSet) || bChanged; -bChanged = changeSheets(m_rDocShell, rDocument.GetDrawLayer(), pColorSet) || bChanged; +bChanged += changeSheets(m_rDocShell, pViewShell, rDocument.GetDrawLayer(), pColorSet) || bChanged; changeSparklines(m_rDocShell, pColorSet); changeTheTheme(m_rDocShell, pColorSet); diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index 01215f789fc2..163e51e091f9 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -122,10
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - 2 commits - include/svx include/xmloff schema/libreoffice sd/source xmloff/inc xmloff/qa xmloff/source
include/svx/strings.hrc |1 include/xmloff/xmltoken.hxx |1 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng | 10 sd/source/core/ThemeColorChanger.cxx| 84 - xmloff/inc/xmlprop.hxx |1 xmloff/qa/unit/data/FillAndStrokeThemeColorTest.fodp| 783 xmloff/qa/unit/draw.cxx | 53 xmloff/source/core/xmltoken.cxx |1 xmloff/source/draw/sdpropls.cxx |1 xmloff/source/token/tokens.txt |1 10 files changed, 911 insertions(+), 25 deletions(-) New commits: commit 7e553b4ff3aa6ada06d3abc0fa473f11f94de8b0 Author: Tomaž Vajngerl AuthorDate: Tue Aug 15 17:25:15 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Aug 28 12:44:04 2023 +0200 sd: add undo/redo for line/fill styles theme change Change-Id: I780e261c013a44426ce1baa3b10ddcf497dd54c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155817 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl (cherry picked from commit 286bde4f083470490251c2f43ffb7ea9b236b4fd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156163 Tested-by: Jenkins CollaboraOffice Reviewed-by: Mike Kaganski diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index 86422a9a63a8..478c74480153 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -1135,6 +1135,7 @@ #define RID_SVXSTR_THEME_COLOR12 NC_("RID_SVXSTR_THEME_COLOR12", "Followed Hyperlink") #define RID_SVXSTR_THEME_EFFECT_LIGHTER NC_("RID_SVXSTR_THEME_EFFECT_LIGHTER", "$THEME_NAME, $PERCENTAGE% Lighter") #define RID_SVXSTR_THEME_EFFECT_DARKER NC_("RID_SVXSTR_THEME_EFFECT_DARKER", "$THEME_NAME, $PERCENTAGE% Darker") +#define RID_SVXSTR_UNDO_THEME_COLOR_CHANGE NC_("RID_SVXSTR_UNDO_THEME_COLOR_CHANGE", "Theme Color Change") #define RID_SVX_EXTRUSION_BAR NC_("RID_SVX_EXTRUSION_BAR", "Extrusion") #define RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF NC_("RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF", "Apply Extrusion On/Off") diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index d0a84c866495..84a00527069c 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -17,6 +17,13 @@ #include #include #include +#include +#include +#include + +#include +#include +#include using namespace css; @@ -43,46 +50,73 @@ void changeTheTheme(SdrPage* pMasterPage, std::shared_ptr const pTheme->setColorSet(pColorSet); } -bool changeStyles(sd::DrawDocShell* pDocShell, std::shared_ptr const& pColorSet) +bool changeStyle(sd::DrawDocShell* pDocShell, SdStyleSheet* pStyle, + std::shared_ptr const& pColorSet) { -SfxStyleSheetBasePool* pPool = pDocShell->GetStyleSheetPool(); +bool bChanged = false; -SdStyleSheet* pStyle = static_cast(pPool->First(SfxStyleFamily::Para)); -while (pStyle) +auto aItemSet = pStyle->GetItemSet(); +if (const XFillColorItem* pItem = aItemSet.GetItemIfSet(XATTR_FILLCOLOR, false)) { -auto& rItemSet = pStyle->GetItemSet(); -if (const XFillColorItem* pItem = rItemSet.GetItemIfSet(XATTR_FILLCOLOR, false)) +model::ComplexColor const& rComplexColor = pItem->getComplexColor(); +if (rComplexColor.isValidThemeType()) { -model::ComplexColor const& rComplexColor = pItem->getComplexColor(); -if (rComplexColor.isValidThemeType()) -{ -Color aNewColor = pColorSet->resolveColor(rComplexColor); -std::unique_ptr pNewItem(pItem->Clone()); -pNewItem->SetColorValue(aNewColor); -rItemSet.Put(*pNewItem); -} +Color aNewColor = pColorSet->resolveColor(rComplexColor); +std::unique_ptr pNewItem(pItem->Clone()); +pNewItem->SetColorValue(aNewColor); +aItemSet.Put(*pNewItem); +bChanged = true; } -if (const XLineColorItem* pItem = rItemSet.GetItemIfSet(XATTR_LINECOLOR, false)) +} +if (const XLineColorItem* pItem = aItemSet.GetItemIfSet(XATTR_LINECOLOR, false)) +{ +model::ComplexColor const& rComplexColor = pItem->getComplexColor(); +if (rComplexColor.isValidThemeType()) { -model::ComplexColor const& rComplexColor = pItem->getComplexColor(); -if (rComplexColor.isValidThemeType()) -{ -Color aNewColor = pColorSet->resolveColor(rComplexColor); -std::unique_ptr pNewItem(pItem->Clone()); -pNewItem->SetColorValue(aNewColor); -
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - 2 commits - cui/source sd/inc sd/qa sd/source
cui/source/tabpages/tpline.cxx | 12 ++--- sd/inc/theme/ThemeColorChanger.hxx |5 +++ sd/qa/unit/ThemeTest.cxx |6 +++- sd/source/core/ThemeColorChanger.cxx | 46 ++- sd/source/ui/view/drviews2.cxx |5 ++- 5 files changed, 65 insertions(+), 9 deletions(-) New commits: commit 593d97ff8b071a4966c6b083340e5a8144ff9a93 Author: Tomaž Vajngerl AuthorDate: Mon Aug 14 22:32:36 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Aug 28 12:43:45 2023 +0200 sd: change fill/line theme colors for graphic styles on theme change Change-Id: Ieeb425519e805160bf6726a64086508290f9d521 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155684 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit b5aaf194866c5e416167cb54d37f9f04dabc5375) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156161 Tested-by: Jenkins CollaboraOffice Reviewed-by: Mike Kaganski diff --git a/sd/inc/theme/ThemeColorChanger.hxx b/sd/inc/theme/ThemeColorChanger.hxx index 8c8179460dd8..72ae70a0ea3c 100644 --- a/sd/inc/theme/ThemeColorChanger.hxx +++ b/sd/inc/theme/ThemeColorChanger.hxx @@ -13,6 +13,8 @@ #include #include #include +#include +#include namespace sd { @@ -20,9 +22,10 @@ class SD_DLLPUBLIC ThemeColorChanger : public svx::IThemeColorChanger { private: SdrPage* mpMasterPage; +sd::DrawDocShell* mpDocShell; public: -ThemeColorChanger(SdrPage* pMasterPage); +ThemeColorChanger(SdrPage* pMasterPage, sd::DrawDocShell* pDocShell); virtual ~ThemeColorChanger() override; void apply(std::shared_ptr const& pColorSet) override; diff --git a/sd/qa/unit/ThemeTest.cxx b/sd/qa/unit/ThemeTest.cxx index 71313b48a7e6..9a663106c1c8 100644 --- a/sd/qa/unit/ThemeTest.cxx +++ b/sd/qa/unit/ThemeTest.cxx @@ -67,6 +67,10 @@ CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) // Given a document, with a first slide and blue shape text from theme: loadFromURL(u"theme.pptx"); +SdXImpressDocument* pXImpressDocument = dynamic_cast(mxComponent.get()); +CPPUNIT_ASSERT(pXImpressDocument); +auto* pDocShell = pXImpressDocument->GetDocShell(); + uno::Reference xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); // The draw page also contains a group shape to make sure we don't crash on group shapes. uno::Reference xDrawPage( @@ -131,7 +135,7 @@ CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) auto* pMasterPage = GetSdrPageFromXDrawPage(xDrawPageMaster); auto pTheme = pMasterPage->getSdrPageProperties().GetTheme(); -sd::ThemeColorChanger aChanger(pMasterPage); +sd::ThemeColorChanger aChanger(pMasterPage, pDocShell); aChanger.apply(pTheme->getColorSet()); // Then make sure the shape text color is now green: diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index 7ca2b6478232..d0a84c866495 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -12,13 +12,19 @@ #include #include #include +#include +#include +#include +#include +#include using namespace css; namespace sd { -ThemeColorChanger::ThemeColorChanger(SdrPage* pMasterPage) +ThemeColorChanger::ThemeColorChanger(SdrPage* pMasterPage, sd::DrawDocShell* pDocShell) : mpMasterPage(pMasterPage) +, mpDocShell(pDocShell) { } @@ -37,10 +43,48 @@ void changeTheTheme(SdrPage* pMasterPage, std::shared_ptr const pTheme->setColorSet(pColorSet); } +bool changeStyles(sd::DrawDocShell* pDocShell, std::shared_ptr const& pColorSet) +{ +SfxStyleSheetBasePool* pPool = pDocShell->GetStyleSheetPool(); + +SdStyleSheet* pStyle = static_cast(pPool->First(SfxStyleFamily::Para)); +while (pStyle) +{ +auto& rItemSet = pStyle->GetItemSet(); +if (const XFillColorItem* pItem = rItemSet.GetItemIfSet(XATTR_FILLCOLOR, false)) +{ +model::ComplexColor const& rComplexColor = pItem->getComplexColor(); +if (rComplexColor.isValidThemeType()) +{ +Color aNewColor = pColorSet->resolveColor(rComplexColor); +std::unique_ptr pNewItem(pItem->Clone()); +pNewItem->SetColorValue(aNewColor); +rItemSet.Put(*pNewItem); +} +} +if (const XLineColorItem* pItem = rItemSet.GetItemIfSet(XATTR_LINECOLOR, false)) +{ +model::ComplexColor const& rComplexColor = pItem->getComplexColor(); +if (rComplexColor.isValidThemeType()) +{ +Color aNewColor = pColorSet->resolveColor(rComplexColor); +std::unique_ptr pNewItem(pItem->Clone()); +pNewItem->SetColorValue(aNewColor); +rItemSet.Put(*pNewItem); +} +} +pStyle = static_cast(pPool->Next()); +} + +return true; +} + } // end anonymous ns void
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - 2 commits - include/svx sc/qa sc/source sd/CppunitTest_sd_theme_tests.mk sd/inc sd/Library_sd.mk sd/Module_sd.mk sd/qa sd/sdi sd/so
include/svx/theme/ThemeColorChangerCommon.hxx | 12 --- sc/qa/unit/ucalc_sparkline.cxx|1 sc/source/ui/inc/ThemeColorChanger.hxx|2 sc/source/ui/theme/ThemeColorChanger.cxx |1 sd/CppunitTest_sd_theme_tests.mk | 78 +++ sd/Library_sd.mk |1 sd/Module_sd.mk |1 sd/inc/theme/ThemeColorChanger.hxx| 33 + sd/qa/unit/ThemeTest.cxx | 88 ++ sd/sdi/_drvwsh.sdi|6 + sd/source/core/ThemeColorChanger.cxx | 75 ++ sd/source/ui/view/drviews2.cxx| 35 ++ sd/uiconfig/sdraw/menubar/menubar.xml |1 sd/uiconfig/simpress/menubar/menubar.xml |1 svx/CppunitTest_svx_styles.mk | 49 -- svx/Library_svxcore.mk|2 svx/Module_svx.mk |1 svx/source/svdraw/svdpage.cxx | 18 - svx/source/theme/ThemeColorChangerCommon.cxx | 39 --- sw/source/core/inc/ThemeColorChanger.hxx |2 sw/source/core/model/ThemeColorChanger.cxx|1 21 files changed, 289 insertions(+), 158 deletions(-) New commits: commit c0ba7ba97ce440eff77526e48e3dfbafacc1cdad Author: Tomaž Vajngerl AuthorDate: Sat Aug 12 04:03:57 2023 +0900 Commit: Mike Kaganski CommitDate: Mon Aug 28 12:43:11 2023 +0200 sd: add ThemeDialog to Impress/Draw, refactor ThemeColorChanger Add "Theme" menu action, which starts the common ThemeDialog. Add Impress/Draw specific ThemeColorChanger and remove the one in svx, so that only the interface and common function remain. Rename the svx ThemeColorChanger files to THemeColorChangerCommon. Change-Id: Ibf07a443cadf0452747ab6685f65df37b145c984 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155682 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl (cherry picked from commit ad873064b0135e4e00389cd38c7de688286c1fa1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156159 Tested-by: Jenkins CollaboraOffice Reviewed-by: Mike Kaganski diff --git a/include/svx/theme/ThemeColorChanger.hxx b/include/svx/theme/ThemeColorChangerCommon.hxx similarity index 72% rename from include/svx/theme/ThemeColorChanger.hxx rename to include/svx/theme/ThemeColorChangerCommon.hxx index 8e942ea975ad..235648df2cab 100644 --- a/include/svx/theme/ThemeColorChanger.hxx +++ b/include/svx/theme/ThemeColorChangerCommon.hxx @@ -22,18 +22,6 @@ namespace theme SVXCORE_DLLPUBLIC void updateSdrObject(model::ColorSet const& rColorSet, SdrObject* pObject); } -class SVXCORE_DLLPUBLIC ThemeColorChanger : public IThemeColorChanger -{ -private: -SdrPage* mpPage; - -public: -ThemeColorChanger(SdrPage* pPage); -virtual ~ThemeColorChanger() override; - -void apply(std::shared_ptr const& pColorSet) override; -}; - } // end svx namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/ucalc_sparkline.cxx b/sc/qa/unit/ucalc_sparkline.cxx index bd4ffe5c9772..459f1d651dca 100644 --- a/sc/qa/unit/ucalc_sparkline.cxx +++ b/sc/qa/unit/ucalc_sparkline.cxx @@ -20,6 +20,7 @@ #include #include #include +#include using namespace css; diff --git a/sc/source/ui/inc/ThemeColorChanger.hxx b/sc/source/ui/inc/ThemeColorChanger.hxx index f3f3b7379671..57ca91cdb83c 100644 --- a/sc/source/ui/inc/ThemeColorChanger.hxx +++ b/sc/source/ui/inc/ThemeColorChanger.hxx @@ -11,7 +11,7 @@ #pragma once #include -#include +#include #include "docsh.hxx" namespace sc diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx b/sc/source/ui/theme/ThemeColorChanger.cxx index 2c0933da5cd9..acef84f89fa0 100644 --- a/sc/source/ui/theme/ThemeColorChanger.cxx +++ b/sc/source/ui/theme/ThemeColorChanger.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 3c60a60b3a3d..24e3c985a4ee 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -154,6 +154,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/core/EffectMigration \ sd/source/core/PageListWatcher \ sd/source/core/TransitionPreset \ + sd/source/core/ThemeColorChanger \ sd/source/core/anminfo \ sd/source/core/annotations/Annotation \ sd/source/core/annotations/AnnotationEnumeration \ diff --git a/sd/inc/theme/ThemeColorChanger.hxx b/sd/inc/theme/ThemeColorChanger.hxx new file mode 100644 index ..8c8179460dd8 --- /dev/null +++ b/sd/inc/theme/ThemeColorChanger.hxx @@ -0,0 +1,33 @@ +/* -*- 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
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - basctl/inc chart2/inc cui/inc cui/source docmodel/Library_docmodel.mk docmodel/source editeng/source include/docmodel include/oox i
basctl/inc/pch/precompiled_basctl.hxx|4 chart2/inc/pch/precompiled_chartcontroller.hxx |4 cui/inc/pch/precompiled_cui.hxx |3 cui/source/tabpages/chardlg.cxx |3 docmodel/Library_docmodel.mk |2 docmodel/source/color/ComplexColorJSON.cxx |4 docmodel/source/theme/ColorSet.cxx |6 - docmodel/source/uno/UnoComplexColor.cxx |2 editeng/source/items/textitem.cxx|6 - editeng/source/uno/unotext.cxx |4 include/docmodel/color/ComplexColor.hxx | 75 ++--- include/docmodel/theme/ColorSet.hxx |1 include/docmodel/theme/FormatScheme.hxx | 19 ++-- include/docmodel/theme/Theme.hxx |1 include/docmodel/theme/ThemeColor.hxx| 101 --- include/docmodel/uno/UnoComplexColor.hxx |2 include/oox/export/ThemeExport.hxx |2 include/svx/Palette.hxx |6 - offapi/com/sun/star/util/XComplexColor.idl |5 - oox/inc/pch/precompiled_oox.hxx |3 oox/qa/unit/drawingml.cxx| 14 +-- oox/qa/unit/shape.cxx|2 oox/source/drawingml/color.cxx |7 - oox/source/drawingml/colorchoicecontext.cxx | 11 -- oox/source/drawingml/fillproperties.cxx |2 oox/source/drawingml/lineproperties.cxx |4 oox/source/export/ThemeExport.cxx| 36 oox/source/export/drawingml.cxx |4 reportdesign/inc/pch/precompiled_rptui.hxx |4 sc/qa/unit/SparklineImportExportTest.cxx | 15 +-- sc/qa/unit/ThemeImportExportTest.cxx | 24 ++--- sc/qa/unit/ucalc_DocumentThemes.cxx |4 sc/qa/unit/ucalc_sparkline.cxx |4 sc/source/filter/excel/export/ExportTools.cxx|6 - sc/source/filter/excel/xestream.cxx |4 sc/source/filter/excel/xestyle.cxx |4 sc/source/filter/xml/SparklineGroupsExport.cxx |2 sc/source/ui/theme/ThemeColorChanger.cxx | 52 --- sd/inc/pch/precompiled_sdui.hxx |4 sd/qa/unit/uiimpress.cxx |4 sd/source/core/stlsheet.cxx |2 sd/source/ui/view/drtxtob1.cxx |2 sd/source/ui/view/drviews2.cxx |2 svx/inc/pch/precompiled_svx.hxx |1 svx/qa/unit/styles.cxx |4 svx/qa/unit/xoutdev.cxx |4 svx/source/table/cell.cxx|3 svx/source/tbxctrls/PaletteManager.cxx |2 svx/source/theme/ThemeColorChanger.cxx |6 - svx/source/theme/ThemeColorPaletteManager.cxx|2 svx/source/unodraw/unoshape.cxx |3 svx/source/xoutdev/xattr.cxx |6 - sw/inc/pch/precompiled_msword.hxx|5 + sw/inc/pch/precompiled_swui.hxx |4 sw/qa/core/theme/ThemeTest.cxx | 92 ++-- sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx | 16 +-- sw/source/core/model/ThemeColorChanger.cxx | 97 +++--- sw/source/filter/ww8/docxattributeoutput.cxx | 17 +-- writerfilter/source/dmapper/BorderHandler.cxx|2 writerfilter/source/dmapper/CellColorHandler.cxx |4 writerfilter/source/dmapper/DomainMapper.cxx |6 - writerfilter/source/dmapper/TDefTableHandler.cxx |2 xmloff/qa/unit/draw.cxx | 14 +-- xmloff/source/text/XMLComplexColorContext.cxx|6 - xmloff/source/text/XMLComplexColorExport.cxx |5 - 65 files changed, 326 insertions(+), 441 deletions(-) New commits: commit e9e18abdc76368e2599dd7a5c4f2d9903a0b9cf6 Author: Tomaž Vajngerl AuthorDate: Thu Aug 3 10:14:40 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Aug 28 12:42:43 2023 +0200 ComplexColor various clean-up and (trivial) refactorings Don't allow access to member variables of ComplexColor and makes them private. Needs a lot of changes. Change "scheme" to "theme" to be more consistent. In LO we usually call the "theme color" what is usually refered to as "scheme color" in OOXML, where it is sometimes refered to as "scheme" and other times as theme color. Remove ThemeColor class which was replaced with CmplexColor some time ago. Remove un-needed includes and un-needed components. Use isValidThemeColor in many places where we check that the ComplexColor is of "Theme" type and that ThemeColorType is set to a valid value. Change-Id: I325595fa65b8e56a4707e9d22acc6330aac28961 Reviewed-on:
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/qa
sc/qa/unit/tiledrendering/tiledrendering.cxx |3 +++ 1 file changed, 3 insertions(+) New commits: commit 0cc5861d6adf60f44b0fa5d307ced948b817e20a Author: Tomaž Vajngerl AuthorDate: Tue Aug 8 23:15:59 2023 +0200 Commit: Mike Kaganski CommitDate: Mon Aug 28 12:42:20 2023 +0200 sc: fix tiledrendering test execution order issue with comment IDs ScPostIt::mnLastPostItId is a static variable, which is used for generated the comment ID. In the test we depend that the ID are consistent and start with 1, but as we have more tests that insert comments this can be a problem. testCommentCallback and testCommentCellCopyPaste, both add comments and the expected execution order is testCommentCallback and then testCommentCellCopyPaste, so the latter test resets the mnLastPostItId variable to 1, so the IDs are consistent. In a LO 7.6 build for Fedora, it happened that the testCommentCellCopyPaste was executed first and testCommentCallback afterwards, but in testCommentCallback we do not reset the mnLastPostItId and the build failed. This change resets the mnLastPostItId also in testCommentCallback. Change-Id: I123b2f47b0d6177b2f5bdefcf6d8e9c301a7413b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155498 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl (cherry picked from commit 3dcf2acadb847ec76d7e1dff3b4b730a64b52c41) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156129 Tested-by: Jenkins CollaboraOffice Reviewed-by: Mike Kaganski diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 81143b845b44..30eaaebf207a 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1232,6 +1232,9 @@ void ScTiledRenderingTest::testCommentCallback() // Comments callback are emitted only if tiled annotations are off comphelper::LibreOfficeKit::setTiledAnnotations(false); +// FIXME: Hack because previous tests do not destroy ScDocument(with annotations) on exit (?). +ScPostIt::mnLastPostItId = 1; + { ScModelObj* pModelObj = createDoc("small.ods"); ViewCallback aView1;