sd/source/ui/func/futext.cxx | 104 +++++++++---------------------------------- sd/source/ui/inc/futext.hxx | 1 2 files changed, 22 insertions(+), 83 deletions(-)
New commits: commit 059f99991e8f291404addeba9341d2c4989976af Author: Bayram Çiçek <[email protected]> AuthorDate: Fri Apr 14 00:34:52 2023 +0300 Commit: Maxim Monastirsky <[email protected]> CommitDate: Tue Apr 18 01:18:57 2023 +0200 tdf#90253: Impress: make TextBox retain its height - [Impress] drawing a new Text Box and Vertical Text minimize itself to the height of one line. - This behavior has changed and inserting a new TextBox/VerticalText does not shrink itself to height of one line. - Unified some common Draw and Impress codes - removed unnecessary ImpSetAttributesFitCommon(pText) function, as ImpSetAttributesForNewTextObject(pText) takes care of the Text Box creations. - SID_ATTR_CHAR (.uno:Text) - SID_ATTR_CHAR_VERTICAL (.uno:VerticalText) Change-Id: Ia944c2b64d5b1fa6970f6afabf41d36bf1643efa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150377 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <[email protected]> diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index 60e36e2674b3..f01851668f76 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -509,59 +509,34 @@ bool FuText::MouseMove(const MouseEvent& rMEvt) void FuText::ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj) { - if(mpDoc->GetDocumentType() == DocumentType::Impress) + if( nSlotId == SID_ATTR_CHAR ) { - if( nSlotId == SID_ATTR_CHAR ) - { - /* Create Impress text object (rescales to line height) - We get the correct height during the subsequent creation of the - object, otherwise we draw too much */ - SfxItemSet aSet(mpViewShell->GetPool()); - aSet.Put(makeSdrTextMinFrameHeightItem(0)); - aSet.Put(makeSdrTextAutoGrowWidthItem(false)); - aSet.Put(makeSdrTextAutoGrowHeightItem(true)); - pTxtObj->SetMergedItemSet(aSet); - pTxtObj->AdjustTextFrameWidthAndHeight(); - aSet.Put(makeSdrTextMaxFrameHeightItem(pTxtObj->GetLogicRect().GetSize().Height())); - pTxtObj->SetMergedItemSet(aSet); - const SfxViewShell* pCurrentViewShell = SfxViewShell::Current(); - if (pCurrentViewShell && (pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKTablet())) - pTxtObj->SetText(SdResId(STR_PRESOBJ_TEXT_EDIT_MOBILE)); - } - else if( nSlotId == SID_ATTR_CHAR_VERTICAL ) - { - SfxItemSet aSet(mpViewShell->GetPool()); - aSet.Put(makeSdrTextMinFrameWidthItem(0)); - aSet.Put(makeSdrTextAutoGrowWidthItem(true)); - aSet.Put(makeSdrTextAutoGrowHeightItem(false)); - - // Needs to be set since default is SDRTEXTHORZADJUST_BLOCK - aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); - pTxtObj->SetMergedItemSet(aSet); - pTxtObj->AdjustTextFrameWidthAndHeight(); - aSet.Put(makeSdrTextMaxFrameWidthItem(pTxtObj->GetLogicRect().GetSize().Width())); - pTxtObj->SetMergedItemSet(aSet); - } + SfxItemSet aSet(mpViewShell->GetPool()); + aSet.Put(makeSdrTextAutoGrowWidthItem(false)); + aSet.Put(makeSdrTextAutoGrowHeightItem(true)); + pTxtObj->SetMergedItemSet(aSet); + pTxtObj->AdjustTextFrameWidthAndHeight(); + const SfxViewShell* pCurrentViewShell = SfxViewShell::Current(); + if (pCurrentViewShell && (pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKTablet())) + pTxtObj->SetText(SdResId(STR_PRESOBJ_TEXT_EDIT_MOBILE)); } - else + else if( nSlotId == SID_ATTR_CHAR_VERTICAL ) { - if( nSlotId == SID_ATTR_CHAR_VERTICAL ) - { - // draw text object, needs to be initialized when vertical text is used - SfxItemSet aSet(mpViewShell->GetPool()); + // draw text object, needs to be initialized when vertical text is used + SfxItemSet aSet(mpViewShell->GetPool()); - aSet.Put(makeSdrTextAutoGrowWidthItem(true)); - aSet.Put(makeSdrTextAutoGrowHeightItem(false)); + aSet.Put(makeSdrTextAutoGrowWidthItem(true)); + aSet.Put(makeSdrTextAutoGrowHeightItem(false)); - // Set defaults for vertical click-n'drag text object, pool defaults are: - // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP - // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK - // Analog to that: - aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); - aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); + // Set defaults for vertical click-n'drag text object, pool defaults are: + // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP + // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK + // Analog to that: + aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); + aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); - pTxtObj->SetMergedItemSet(aSet); - } + pTxtObj->SetMergedItemSet(aSet); + pTxtObj->AdjustTextFrameWidthAndHeight(); } } @@ -586,35 +561,6 @@ void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj) pTxtObj->AdjustTextFrameWidthAndHeight(); } -void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj) -{ - // Normal Textobject - if (mpDoc->GetDocumentType() != DocumentType::Impress) - return; - - if( nSlotId == SID_ATTR_CHAR ) - { - // Impress text object (rescales to line height) - SfxItemSet aSet(mpViewShell->GetPool()); - aSet.Put(makeSdrTextMinFrameHeightItem(0)); - aSet.Put(makeSdrTextMaxFrameHeightItem(0)); - aSet.Put(makeSdrTextAutoGrowHeightItem(true)); - aSet.Put(makeSdrTextAutoGrowWidthItem(false)); - pTxtObj->SetMergedItemSet(aSet); - } - else if( nSlotId == SID_ATTR_CHAR_VERTICAL ) - { - SfxItemSet aSet(mpViewShell->GetPool()); - aSet.Put(makeSdrTextMinFrameWidthItem(0)); - aSet.Put(makeSdrTextMaxFrameWidthItem(0)); - aSet.Put(makeSdrTextAutoGrowWidthItem(true)); - aSet.Put(makeSdrTextAutoGrowHeightItem(false)); - pTxtObj->SetMergedItemSet(aSet); - } - - pTxtObj->AdjustTextFrameWidthAndHeight(); -} - bool FuText::MouseButtonUp(const MouseEvent& rMEvt) { bool bReturn = false; @@ -758,8 +704,6 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt) } else { - ImpSetAttributesFitCommon(GetTextObj()); - // thereby the handles and the gray frame are correct mpView->AdjustMarkHdl(); mpView->PickHandle(aPnt); @@ -1356,10 +1300,6 @@ rtl::Reference<SdrObject> FuText::CreateDefaultObject(const sal_uInt16 nID, cons { ImpSetAttributesFitToSizeVertical(pText); } - else - { - ImpSetAttributesFitCommon(pText); - } // Put text object into edit mode. SdrPageView* pPV = mpView->GetSdrPageView(); diff --git a/sd/source/ui/inc/futext.hxx b/sd/source/ui/inc/futext.hxx index 681597b4cd6d..4ef6cc75df9a 100644 --- a/sd/source/ui/inc/futext.hxx +++ b/sd/source/ui/inc/futext.hxx @@ -89,7 +89,6 @@ private: void ImpSetAttributesForNewTextObject(SdrTextObj* pTxtObj); void ImpSetAttributesFitToSize(SdrTextObj* pTxtObj); void ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj); - void ImpSetAttributesFitCommon(SdrTextObj* pTxtObj); }; } // end of namespace sd
