include/svx/annotation/AnnotationObject.hxx | 2 include/svx/svdmodel.hxx | 7 +++ sd/source/filter/pdf/sdpdffilter.cxx | 5 +- sd/source/ui/annotations/annotationmanager.cxx | 2 svx/source/annotation/AnnotationObject.cxx | 58 +++++++++++++++---------- svx/source/svdraw/svdmodel.cxx | 1 6 files changed, 49 insertions(+), 26 deletions(-)
New commits: commit afaefb06e186fd79304333e4b7ee641186311a81 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Jun 27 21:11:50 2024 +0900 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Jul 22 11:35:49 2024 +0200 annot: AnnotationObject should be the size as the text content This makes the AnnotationObject to resize the frame to the size of the text content, or else the text that is too big will be shown outside the object's frame (rectangle). For some reason we need to set the object as a "text frame" (mbTextFrame = true) or else it will not allow to automatically adjust the frame to the text content. Change-Id: Ib2b9a7c07626fe8b0a2286cfd67c3bf37cf9af03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169642 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170331 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 11d59f7aa530..6ed81042805b 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -1118,7 +1118,7 @@ void AnnotationManagerImpl::SyncAnnotationObjects() applyAnnotationProperties(*pNewObject, rInfo); } - pNewObject->SetLogicRect(aRectangle); + pNewObject->SetRelativePos(aRectangle.TopLeft()); pView->InsertObjectAtView(pNewObject.get(), *pView->GetSdrPageView()); diff --git a/svx/source/annotation/AnnotationObject.cxx b/svx/source/annotation/AnnotationObject.cxx index 6cebb91925d9..d69f9be6e9fa 100644 --- a/svx/source/annotation/AnnotationObject.cxx +++ b/svx/source/annotation/AnnotationObject.cxx @@ -133,17 +133,18 @@ void AnnotationObject::ApplyAnnotationName() OUString sInitials(mpAnnotationData->mxAnnotation->getInitials()); if (sInitials.isEmpty()) sInitials = createInitials(mpAnnotationData->mxAnnotation->getAuthor()); - SetText(sInitials + " " + OUString::number(maViewData.nIndex)); + SetText(sInitials + u" "_ustr + OUString::number(maViewData.nIndex)); } else { - SetText(u"Empty"_ustr); + SetText(u"🗅"_ustr); } Color aColor(getColorLight(maViewData.nAuthorIndex)); - SetMergedItem(XFillStyleItem(drawing::FillStyle_SOLID)); - SetMergedItem(XFillColorItem(OUString(), aColor)); + SfxItemSet aItemSet = GetMergedItemSet(); + aItemSet.Put(XFillStyleItem(drawing::FillStyle_SOLID)); + aItemSet.Put(XFillColorItem(OUString(), aColor)); Color aBorderColor(aColor); if (aColor.IsDark()) @@ -151,20 +152,22 @@ void AnnotationObject::ApplyAnnotationName() else aBorderColor.DecreaseLuminance(32); - SetMergedItem(XLineStyleItem(drawing::LineStyle_SOLID)); - SetMergedItem(XLineColorItem(OUString(), aBorderColor)); - SetMergedItem(XLineWidthItem(o3tl::convert(0, o3tl::Length::pt, o3tl::Length::mm100))); + aItemSet.Put(XLineStyleItem(drawing::LineStyle_SOLID)); + aItemSet.Put(XLineColorItem(OUString(), aBorderColor)); + aItemSet.Put(XLineWidthItem(o3tl::convert(0, o3tl::Length::pt, o3tl::Length::mm100))); - SetMergedItem(SvxFontHeightItem(o3tl::convert(10, o3tl::Length::pt, o3tl::Length::mm100), 100, - EE_CHAR_FONTHEIGHT)); + aItemSet.Put(SvxFontHeightItem(o3tl::convert(10, o3tl::Length::pt, o3tl::Length::mm100), 100, + EE_CHAR_FONTHEIGHT)); - SetMergedItem(SvxColorItem(aColor.IsDark() ? COL_WHITE : COL_BLACK, EE_CHAR_COLOR)); + aItemSet.Put(SvxColorItem(aColor.IsDark() ? COL_WHITE : COL_BLACK, EE_CHAR_COLOR)); - SetMergedItem(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_NONE)); + aItemSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_NONE)); - SetMergedItem(makeSdrTextWordWrapItem(false)); - SetMergedItem(makeSdrTextAutoGrowWidthItem(true)); - SetMergedItem(makeSdrTextAutoGrowHeightItem(true)); + aItemSet.Put(makeSdrTextWordWrapItem(false)); + aItemSet.Put(makeSdrTextAutoGrowWidthItem(true)); + aItemSet.Put(makeSdrTextAutoGrowHeightItem(true)); + + SetMergedItemSet(aItemSet); } AnnotationObject::~AnnotationObject() {} @@ -195,13 +198,13 @@ SdrObjKind AnnotationObject::GetObjIdentifier() const { return SdrObjKind::Annot OUString AnnotationObject::TakeObjNameSingul() const { - OUString sName(u"Annotation"_ustr); + OUString sOutName(u"Annotation"_ustr); OUString aName(GetName()); if (!aName.isEmpty()) - sName += " '" + aName + "'"; + sOutName += u" '"_ustr + aName + u"'"_ustr; - return sName; + return sOutName; } OUString AnnotationObject::TakeObjNamePlural() const { return u"Annotations"_ustr; } commit 6f35891442f76b3025b8a808331692eefe507131 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Jul 4 12:38:42 2024 +0900 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Jul 22 11:35:39 2024 +0200 annot: don't show the annot. object if LOK and not PDF document Change-Id: I50ffd1b6d81d2fcf6ef9f821e783ae228e39e4e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170330 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/svx/annotation/AnnotationObject.hxx b/include/svx/annotation/AnnotationObject.hxx index e372fec1f56a..674d1290b9af 100644 --- a/include/svx/annotation/AnnotationObject.hxx +++ b/include/svx/annotation/AnnotationObject.hxx @@ -37,6 +37,8 @@ public: AnnotationObject(SdrModel& rSdrModel, tools::Rectangle const& rRectangle, sdr::annotation::AnnotationViewData const& aAnnotationViewData); + void setup(); + rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override; SdrObjKind GetObjIdentifier() const override; diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index f029d928aa8a..5f0175b57d7e 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -213,6 +213,7 @@ protected: bool m_bStarDrawPreviewMode:1; bool mbDisableTextEditUsesCommonUndoManager:1; bool mbVOCInvalidationIsReliable:1; // does the app reliably invalidate the VOC, or do we need to rebuild the primitives on every render? + bool m_bIsPDFDocument:1; sal_uInt16 m_nDefaultTabulator; sal_uInt32 m_nMaxUndoCount; @@ -581,6 +582,12 @@ public: bool IsWriter() const { return m_bIsWriter; } + bool IsPDFDocument() const { return m_bIsPDFDocument; } + void setPDFDocument(bool bIsPDFDocument) + { + m_bIsPDFDocument = bIsPDFDocument; + } + // Used as a fallback in *::ReadUserDataSequence() to process common properties void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue); void WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues); diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index 58e2dfead82f..22229e6597ce 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -59,6 +59,9 @@ bool SdPdfFilter::Import() mrDocument.setLock(true); const bool bSavedUndoEnabled = mrDocument.IsUndoEnabled(); mrDocument.EnableUndo(false); + mrDocument.setPDFDocument(true); + + SdrModel& rModel = mrDocument; // Add as many pages as we need up-front. mrDocument.CreateFirstPages(); @@ -83,8 +86,6 @@ bool SdPdfFilter::Import() // Make the page size match the rendered image. pPage->SetSize(aSizeHMM); - SdrModel& rModel = pPage->getSdrModelFromSdrPage(); - rtl::Reference<SdrGrafObj> pSdrGrafObj = new SdrGrafObj(rModel, rGraphic, tools::Rectangle(Point(), aSizeHMM)); diff --git a/svx/source/annotation/AnnotationObject.cxx b/svx/source/annotation/AnnotationObject.cxx index 35dc4807e1b8..6cebb91925d9 100644 --- a/svx/source/annotation/AnnotationObject.cxx +++ b/svx/source/annotation/AnnotationObject.cxx @@ -11,15 +11,13 @@ #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> +#include <comphelper/lok.hxx> + #include <sal/log.hxx> #include <svx/svdmodel.hxx> - #include <svx/annotation/AnnotationObject.hxx> #include <svx/annotation/ObjectAnnotationData.hxx> #include <sdr/properties/rectangleproperties.hxx> -#include <vcl/settings.hxx> -#include <vcl/svapp.hxx> - #include <svx/xfillit0.hxx> #include <svx/xflclit.hxx> #include <svx/xlineit0.hxx> @@ -29,6 +27,9 @@ #include <svx/sdooitm.hxx> #include <svx/sdtagitm.hxx> #include <svx/sdasitm.hxx> + +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> #include <editeng/fhgtitem.hxx> #include <editeng/colritem.hxx> #include <o3tl/unit_conversion.hxx> @@ -92,13 +93,13 @@ Color getColorLight(sal_uInt16 aAuthorIndex) AnnotationObject::AnnotationObject(SdrModel& rSdrModel) : SdrRectObj(rSdrModel) { - setAsAnnotationObject(true); + setup(); } AnnotationObject::AnnotationObject(SdrModel& rSdrModel, AnnotationObject const& rSource) : SdrRectObj(rSdrModel, rSource) { - setAsAnnotationObject(true); + setup(); } AnnotationObject::AnnotationObject(SdrModel& rSdrModel, tools::Rectangle const& rRectangle, @@ -114,7 +115,15 @@ AnnotationObject::AnnotationObject(SdrModel& rSdrModel, tools::Rectangle const& rSdrModel.EnableUndo(bUndo); osl_atomic_decrement(&m_refCount); + setup(); +} + +void AnnotationObject::setup() +{ setAsAnnotationObject(true); + mbTextFrame = true; // need this so the frame can be adjusted to the text + bool bLOK = comphelper::LibreOfficeKit::isActive(); + SetVisible(getSdrModelFromSdrObject().IsPDFDocument() || !bLOK); } void AnnotationObject::ApplyAnnotationName() diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index a86dffc3246f..46497f398944 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -143,6 +143,7 @@ SdrModel::SdrModel(SfxItemPool* pPool, comphelper::IEmbeddedHelper* pEmbeddedHel , m_bStarDrawPreviewMode(false) , mbDisableTextEditUsesCommonUndoManager(false) , mbVOCInvalidationIsReliable(false) + , m_bIsPDFDocument(false) , m_nDefaultTabulator(0) , m_nMaxUndoCount(16) , m_pTextChain(new TextChain)