summaryrefslogtreecommitdiff
path: root/sd/source/ui/annotations
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/annotations')
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx128
-rw-r--r--sd/source/ui/annotations/annotationmanagerimpl.hxx26
-rw-r--r--sd/source/ui/annotations/annotationtag.cxx54
-rw-r--r--sd/source/ui/annotations/annotationtag.hxx10
-rw-r--r--sd/source/ui/annotations/annotationwindow.cxx32
-rw-r--r--sd/source/ui/annotations/annotationwindow.hxx3
6 files changed, 134 insertions, 119 deletions
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 95e7bfb4b901..8a844e8dc118 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -26,7 +26,6 @@
#include <comphelper/lok.hxx>
#include <svx/svxids.hrc>
-#include <vcl/commandinfoprovider.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
@@ -41,7 +40,7 @@
#include <tools/datetime.hxx>
#include <tools/UnitConversion.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
@@ -54,9 +53,6 @@
#include <editeng/fhgtitem.hxx>
#include <editeng/outlobj.hxx>
#include <editeng/postitem.hxx>
-#include <editeng/wghtitem.hxx>
-#include <editeng/udlnitem.hxx>
-#include <editeng/crossedoutitem.hxx>
#include <svx/postattr.hxx>
@@ -84,15 +80,9 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::geometry;
-using namespace ::com::sun::star::container;
-using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::text;
-using namespace ::com::sun::star::view;
-using namespace ::com::sun::star::style;
-using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::ui;
-using namespace ::com::sun::star::task;
using namespace ::com::sun::star::office;
namespace sd {
@@ -103,10 +93,10 @@ SfxItemPool* GetAnnotationPool()
if( !s_pAnnotationPool )
{
s_pAnnotationPool = EditEngine::CreatePool();
- s_pAnnotationPool->SetPoolDefaultItem(SvxFontHeightItem(423,100,EE_CHAR_FONTHEIGHT));
+ s_pAnnotationPool->SetUserDefaultItem(SvxFontHeightItem(423,100,EE_CHAR_FONTHEIGHT));
vcl::Font aAppFont( Application::GetSettings().GetStyleSettings().GetAppFont() );
- s_pAnnotationPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(),aAppFont.GetFamilyName(),"",PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
+ s_pAnnotationPool->SetUserDefaultItem(SvxFontItem(aAppFont.GetFamilyType(),aAppFont.GetFamilyName(),"",PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO));
}
return s_pAnnotationPool.get();
@@ -164,8 +154,7 @@ OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotatio
}
AnnotationManagerImpl::AnnotationManagerImpl( ViewShellBase& rViewShellBase )
-: AnnotationManagerImplBase( m_aMutex )
-, mrBase( rViewShellBase )
+: mrBase( rViewShellBase )
, mpDoc( rViewShellBase.GetDocument() )
, mbShowAnnotations( true )
, mnUpdateTagsEvent( nullptr )
@@ -200,7 +189,7 @@ void AnnotationManagerImpl::init()
}
// WeakComponentImplHelper
-void SAL_CALL AnnotationManagerImpl::disposing ()
+void AnnotationManagerImpl::disposing (std::unique_lock<std::mutex>&)
{
try
{
@@ -240,9 +229,9 @@ void SAL_CALL AnnotationManagerImpl::notifyEvent( const css::document::EventObje
if ( aEvent.EventName == "OnAnnotationRemoved" )
{
Reference< XAnnotation > xAnnotation( aEvent.Source, uno::UNO_QUERY );
- if ( xAnnotation.is() )
+ if ( auto pAnnotation = dynamic_cast<sd::Annotation*>(xAnnotation.get()) )
{
- LOKCommentNotify(CommentNotificationType::Remove, &mrBase, xAnnotation);
+ LOKCommentNotify(CommentNotificationType::Remove, &mrBase, pAnnotation);
}
}
@@ -253,7 +242,7 @@ void SAL_CALL AnnotationManagerImpl::disposing( const css::lang::EventObject& /*
{
}
-Reference<XAnnotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnnotationId)
+rtl::Reference<Annotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnnotationId)
{
SdPage* pPage = nullptr;
do
@@ -263,15 +252,15 @@ Reference<XAnnotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnno
{
AnnotationVector aAnnotations(pPage->getAnnotations());
auto iter = std::find_if(aAnnotations.begin(), aAnnotations.end(),
- [nAnnotationId](const Reference<XAnnotation>& xAnnotation) {
- return sd::getAnnotationId(xAnnotation) == nAnnotationId;
+ [nAnnotationId](const rtl::Reference<sd::Annotation>& xAnnotation) {
+ return xAnnotation->GetId() == nAnnotationId;
});
if (iter != aAnnotations.end())
return *iter;
}
} while( pPage );
- Reference<XAnnotation> xAnnotationEmpty;
+ rtl::Reference<Annotation> xAnnotationEmpty;
return xAnnotationEmpty;
}
@@ -327,10 +316,9 @@ void AnnotationManagerImpl::ExecuteInsertAnnotation(SfxRequest const & rReq)
OUString sText;
if (pArgs)
{
- const SfxPoolItem* pPoolItem = nullptr;
- if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_TEXT, true, &pPoolItem))
+ if (const SfxStringItem* pPoolItem = pArgs->GetItemIfSet(SID_ATTR_POSTIT_TEXT))
{
- sText = static_cast<const SfxStringItem*>(pPoolItem)->GetValue();
+ sText = pPoolItem->GetValue();
}
}
@@ -361,13 +349,20 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest const & rReq)
break;
case SID_DELETE_POSTIT:
{
- Reference< XAnnotation > xAnnotation;
+ rtl::Reference< Annotation > xAnnotation;
sal_uInt32 nId = 0;
if( pArgs )
{
const SfxPoolItem* pPoolItem = nullptr;
if( SfxItemState::SET == pArgs->GetItemState( SID_DELETE_POSTIT, true, &pPoolItem ) )
- static_cast<const SfxUnoAnyItem*>(pPoolItem)->GetValue() >>= xAnnotation;
+ {
+ uno::Reference<XAnnotation> xTmpAnnotation;
+ if (static_cast<const SfxUnoAnyItem*>(pPoolItem)->GetValue() >>= xTmpAnnotation)
+ {
+ xAnnotation = dynamic_cast<Annotation*>(xTmpAnnotation.get());
+ assert(bool(xAnnotation) == bool(xTmpAnnotation) && "must be of concrete type sd::Annotation");
+ }
+ }
if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_POSTIT_ID, true, &pPoolItem ) )
nId = static_cast<const SvxPostItIdItem*>(pPoolItem)->GetValue().toUInt32();
}
@@ -388,7 +383,7 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest const & rReq)
void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest const & rReq)
{
const SfxItemSet* pArgs = rReq.GetArgs();
- Reference< XAnnotation > xAnnotation;
+ rtl::Reference< Annotation > xAnnotation;
OUString sText;
sal_Int32 nPositionX = -1;
sal_Int32 nPositionY = -1;
@@ -399,24 +394,23 @@ void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest const & rReq)
if (mpDoc->IsUndoEnabled())
mpDoc->BegUndo(SdResId(STR_ANNOTATION_UNDO_EDIT));
- const SfxPoolItem* pPoolItem = nullptr;
- if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_ID, true, &pPoolItem))
+ if (const SvxPostItIdItem* pPoolItem = pArgs->GetItemIfSet(SID_ATTR_POSTIT_ID))
{
- sal_uInt32 nId = static_cast<const SvxPostItIdItem*>(pPoolItem)->GetValue().toUInt32();
+ sal_uInt32 nId = pPoolItem->GetValue().toUInt32();
xAnnotation = GetAnnotationById(nId);
}
- if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_TEXT, true, &pPoolItem))
- sText = static_cast<const SfxStringItem*>(pPoolItem)->GetValue();
+ if (const SfxStringItem* pPoolItem = pArgs->GetItemIfSet(SID_ATTR_POSTIT_TEXT))
+ sText = pPoolItem->GetValue();
- if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_POSITION_X, true, &pPoolItem))
- nPositionX = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+ if (const SfxInt32Item* pPoolItem = pArgs->GetItemIfSet(SID_ATTR_POSTIT_POSITION_X))
+ nPositionX = pPoolItem->GetValue();
- if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_POSITION_Y, true, &pPoolItem))
- nPositionY = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+ if (const SfxInt32Item* pPoolItem = pArgs->GetItemIfSet(SID_ATTR_POSTIT_POSITION_Y))
+ nPositionY = pPoolItem->GetValue();
if (xAnnotation.is())
{
- CreateChangeUndo(xAnnotation);
+ xAnnotation->createChangeUndo();
if (nPositionX >= 0 && nPositionY >= 0)
{
@@ -474,7 +468,7 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText)
aTagRect.SetRight( aTagRect.Left() + width - 1 );
aTagRect.SetBottom( aTagRect.Top() + height - 1 );
- if( aNewRect.IsOver( aTagRect ) )
+ if( aNewRect.Overlaps( aTagRect ) )
{
bFree = false;
break;
@@ -497,7 +491,7 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText)
}
}
- Reference< XAnnotation > xAnnotation;
+ rtl::Reference< Annotation > xAnnotation;
pPage->createAnnotation( xAnnotation );
OUString sAuthor;
@@ -537,7 +531,7 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText)
void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
{
- Reference< XAnnotation > xAnnotation;
+ rtl::Reference< Annotation > xAnnotation;
const SfxItemSet* pArgs = rReq.GetArgs();
OUString sReplyText;
if( pArgs )
@@ -550,7 +544,14 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
xAnnotation = GetAnnotationById(nReplyId);
}
else if( SfxItemState::SET == pArgs->GetItemState( rReq.GetSlot(), true, &pPoolItem ) )
- static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue() >>= xAnnotation;
+ {
+ uno::Reference<XAnnotation> xTmpAnnotation;
+ if (static_cast<const SfxUnoAnyItem*>(pPoolItem)->GetValue() >>= xTmpAnnotation)
+ {
+ xAnnotation = dynamic_cast<Annotation*>(xTmpAnnotation.get());
+ assert(bool(xAnnotation) == bool(xTmpAnnotation) && "must be of concrete type sd::Annotation");
+ }
+ }
if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_POSTIT_TEXT, true, &pPoolItem ) )
sReplyText = static_cast<const SvxPostItTextItem*>( pPoolItem )->GetValue();
@@ -560,10 +561,15 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
if( !pTextApi )
return;
+ if (mpDoc->IsUndoEnabled())
+ mpDoc->BegUndo(SdResId(STR_ANNOTATION_REPLY));
+
+ if (xAnnotation)
+ xAnnotation->createChangeUndo();
::Outliner aOutliner( GetAnnotationPool(),OutlinerMode::TextObject );
SdDrawDocument::SetCalcFieldValueHdl( &aOutliner );
- aOutliner.SetUpdateMode( true );
+ aOutliner.SetUpdateLayout( true );
OUString aStr(SdResId(STR_ANNOTATION_REPLY));
OUString sAuthor( xAnnotation->getAuthor() );
@@ -597,7 +603,7 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
if (!sReplyText.isEmpty())
aOutliner.Insert(sReplyText);
- std::unique_ptr< OutlinerParaObject > pOPO( aOutliner.CreateParaObject() );
+ std::optional< OutlinerParaObject > pOPO( aOutliner.CreateParaObject() );
pTextApi->SetText(*pOPO);
OUString sReplyAuthor;
@@ -617,11 +623,14 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
// Tell our LOK clients about this (comment modification)
LOKCommentNotifyAll(CommentNotificationType::Modify, xAnnotation);
+ if( mpDoc->IsUndoEnabled() )
+ mpDoc->EndUndo();
+
UpdateTags(true);
SelectAnnotation( xAnnotation, true );
}
-void AnnotationManagerImpl::DeleteAnnotation( const Reference< XAnnotation >& xAnnotation )
+void AnnotationManagerImpl::DeleteAnnotation( const rtl::Reference< Annotation >& xAnnotation )
{
SdPage* pPage = GetCurrentPage();
@@ -649,10 +658,9 @@ void AnnotationManagerImpl::DeleteAnnotationsByAuthor( std::u16string_view sAuth
{
pPage = GetNextPage( pPage, true );
- if( pPage && !pPage->getAnnotations().empty() )
+ if( pPage )
{
- AnnotationVector aAnnotations( pPage->getAnnotations() );
- for( Reference< XAnnotation >& xAnnotation : aAnnotations )
+ for( const rtl::Reference< Annotation >& xAnnotation : pPage->getAnnotations() )
{
if( xAnnotation->getAuthor() == sAuthor )
{
@@ -703,14 +711,14 @@ void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet)
const bool bReadOnly = mrBase.GetDocShell()->IsReadOnly();
const bool bWrongPageKind = (pCurrentPage == nullptr) || (pCurrentPage->GetPageKind() != PageKind::Standard);
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFSaneDefaultVersion() );
+ const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( GetODFSaneDefaultVersion() );
if (bReadOnly || bWrongPageKind || (nCurrentODFVersion <= SvtSaveOptions::ODFSVER_012))
rSet.DisableItem( SID_INSERT_POSTIT );
rSet.Put(SfxBoolItem(SID_TOGGLE_NOTES, mbShowAnnotations));
- Reference< XAnnotation > xAnnotation;
+ rtl::Reference< Annotation > xAnnotation;
GetSelectedAnnotation( xAnnotation );
// Don't disable these slot in case of LOK, as postit doesn't need to
@@ -749,7 +757,7 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForward)
{
ShowAnnotations( true );
- Reference< XAnnotation > xCurrent;
+ rtl::Reference< Annotation > xCurrent;
GetSelectedAnnotation( xCurrent );
SdPage* pPage = GetCurrentPage();
if( !pPage )
@@ -826,7 +834,7 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForward)
// The question text depends on the search direction.
bool bImpress = mpDoc->GetDocumentType() == DocumentType::Impress;
- const char* pStringId;
+ TranslateId pStringId;
if(bForward)
pStringId = bImpress ? STR_ANNOTATION_WRAP_FORWARD : STR_ANNOTATION_WRAP_FORWARD_DRAW;
else
@@ -859,7 +867,7 @@ void AnnotationManagerImpl::onTagDeselected( AnnotationTag const & rTag )
}
}
-void AnnotationManagerImpl::SelectAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bEdit /* = sal_False */ )
+void AnnotationManagerImpl::SelectAnnotation( const rtl::Reference< Annotation >& xAnnotation, bool bEdit /* = sal_False */ )
{
mxSelectedAnnotation = xAnnotation;
@@ -873,7 +881,7 @@ void AnnotationManagerImpl::SelectAnnotation( const css::uno::Reference< css::of
}
}
-void AnnotationManagerImpl::GetSelectedAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation )
+void AnnotationManagerImpl::GetSelectedAnnotation( rtl::Reference< Annotation >& xAnnotation )
{
xAnnotation = mxSelectedAnnotation;
}
@@ -900,7 +908,7 @@ void AnnotationManagerImpl::onSelectionChanged()
try
{
- Reference< XAnnotationAccess > xPage( mxView->getCurrentPage(), UNO_QUERY );
+ rtl::Reference< SdPage > xPage = mrBase.GetMainViewShell()->getCurrentPage();
if( xPage != mxCurrentPage )
{
@@ -961,10 +969,8 @@ void AnnotationManagerImpl::CreateTags()
rtl::Reference< AnnotationTag > xSelectedTag;
- Reference< XAnnotationEnumeration > xEnum( mxCurrentPage->createAnnotationEnumeration() );
- while( xEnum->hasMoreElements() )
+ for (const rtl::Reference< Annotation > & xAnnotation : mxCurrentPage->getAnnotations() )
{
- Reference< XAnnotation > xAnnotation( xEnum->nextElement() );
Color aColor( GetColorLight( mpDoc->GetAnnotationAuthorIndex( xAnnotation->getAuthor() ) ) );
rtl::Reference< AnnotationTag > xTag( new AnnotationTag( *this, *xViewShell->GetView(), xAnnotation, aColor, nIndex++, maFont ) );
maTagVector.push_back(xTag);
@@ -1038,7 +1044,7 @@ IMPL_LINK(AnnotationManagerImpl,EventMultiplexerListener,
}
}
-void AnnotationManagerImpl::ExecuteAnnotationTagContextMenu(const Reference<XAnnotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect)
+void AnnotationManagerImpl::ExecuteAnnotationTagContextMenu(const rtl::Reference<Annotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect)
{
SfxDispatcher* pDispatcher( getDispatcher( mrBase ) );
if( !pDispatcher )
@@ -1072,13 +1078,13 @@ void AnnotationManagerImpl::ExecuteAnnotationTagContextMenu(const Reference<XAnn
if (sId == ".uno:ReplyToAnnotation")
{
- const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( xAnnotation ) );
+ const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( css::uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get())) ) );
pDispatcher->ExecuteList(SID_REPLYTO_POSTIT,
SfxCallMode::ASYNCHRON, { &aItem });
}
else if (sId == ".uno:DeleteAnnotation")
{
- const SfxUnoAnyItem aItem( SID_DELETE_POSTIT, Any( xAnnotation ) );
+ const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( css::uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get())) ) );
pDispatcher->ExecuteList(SID_DELETE_POSTIT, SfxCallMode::ASYNCHRON,
{ &aItem });
}
diff --git a/sd/source/ui/annotations/annotationmanagerimpl.hxx b/sd/source/ui/annotations/annotationmanagerimpl.hxx
index 63e6ead48fd3..bbcd5a852199 100644
--- a/sd/source/ui/annotations/annotationmanagerimpl.hxx
+++ b/sd/source/ui/annotations/annotationmanagerimpl.hxx
@@ -23,8 +23,7 @@
#include <rtl/ustring.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/compbase.hxx>
#include "annotationtag.hxx"
@@ -35,21 +34,22 @@ namespace com::sun::star::office { class XAnnotation; }
class SfxRequest;
class SdPage;
class SdDrawDocument;
+struct ImplSVEvent;
namespace sd
{
-
+class Annotation;
class ViewShellBase;
namespace tools {
class EventMultiplexerEvent;
}
-typedef ::cppu::WeakComponentImplHelper <
+typedef comphelper::WeakComponentImplHelper <
css::document::XEventListener
> AnnotationManagerImplBase;
-class AnnotationManagerImpl : private ::cppu::BaseMutex, public AnnotationManagerImplBase
+class AnnotationManagerImpl : public AnnotationManagerImplBase
{
public:
explicit AnnotationManagerImpl( ViewShellBase& rViewShellBase );
@@ -57,7 +57,7 @@ public:
void init();
// WeakComponentImplHelper
- virtual void SAL_CALL disposing () override;
+ virtual void disposing (std::unique_lock<std::mutex>&) override;
// XEventListener
virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) override;
@@ -73,15 +73,15 @@ public:
void SelectNextAnnotation(bool bForward);
- void SelectAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bEdit = false );
- void GetSelectedAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation );
+ void SelectAnnotation( const rtl::Reference< Annotation >& xAnnotation, bool bEdit = false );
+ void GetSelectedAnnotation( rtl::Reference< Annotation >& xAnnotation );
void InsertAnnotation(const OUString& rText);
- void DeleteAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation );
+ void DeleteAnnotation( const rtl::Reference< Annotation >& xAnnotation );
void DeleteAnnotationsByAuthor( std::u16string_view sAuthor );
void DeleteAllAnnotations();
- void ExecuteAnnotationTagContextMenu(const css::uno::Reference<css::office::XAnnotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect);
+ void ExecuteAnnotationTagContextMenu(const rtl::Reference<Annotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect);
static Color GetColorDark(sal_uInt16 aAuthorIndex);
static Color GetColorLight(sal_uInt16 aAuthorIndex);
@@ -120,14 +120,14 @@ private:
std::vector< rtl::Reference< AnnotationTag > > maTagVector;
css::uno::Reference< css::drawing::XDrawView > mxView;
- css::uno::Reference< css::office::XAnnotationAccess > mxCurrentPage;
- css::uno::Reference< css::office::XAnnotation > mxSelectedAnnotation;
+ rtl::Reference< SdPage > mxCurrentPage;
+ rtl::Reference< Annotation > mxSelectedAnnotation;
bool mbShowAnnotations;
ImplSVEvent * mnUpdateTagsEvent;
vcl::Font maFont;
- css::uno::Reference<css::office::XAnnotation> GetAnnotationById(sal_uInt32 nAnnotationId);
+ rtl::Reference<Annotation> GetAnnotationById(sal_uInt32 nAnnotationId);
};
OUString getAnnotationDateTimeString( const css::uno::Reference< css::office::XAnnotation >& xAnnotation );
diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx
index cfd632dcc2bd..8147cedef374 100644
--- a/sd/source/ui/annotations/annotationtag.cxx
+++ b/sd/source/ui/annotations/annotationtag.cxx
@@ -22,6 +22,7 @@
#include <rtl/ustrbuf.hxx>
+#include <utility>
#include <vcl/commandevent.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
@@ -48,9 +49,6 @@
#include <drawdoc.hxx>
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::drawing;
-using namespace ::com::sun::star::office;
using namespace ::com::sun::star::geometry;
namespace sd
@@ -96,7 +94,7 @@ namespace {
class AnnotationDragMove : public SdrDragMove
{
public:
- AnnotationDragMove(SdrDragView& rNewView, const rtl::Reference <AnnotationTag >& xTag);
+ AnnotationDragMove(SdrDragView& rNewView, rtl::Reference <AnnotationTag > xTag);
virtual bool BeginSdrDrag() override;
virtual bool EndSdrDrag(bool bCopy) override;
virtual void MoveSdrDrag(const Point& rNoSnapPnt) override;
@@ -109,9 +107,9 @@ private:
}
-AnnotationDragMove::AnnotationDragMove(SdrDragView& rNewView, const rtl::Reference <AnnotationTag >& xTag)
+AnnotationDragMove::AnnotationDragMove(SdrDragView& rNewView, rtl::Reference <AnnotationTag > xTag)
: SdrDragMove(rNewView)
-, mxTag( xTag )
+, mxTag(std::move( xTag ))
{
}
@@ -161,19 +159,19 @@ namespace {
class AnnotationHdl : public SmartHdl
{
public:
- AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt );
+ AnnotationHdl( const SmartTagReference& xTag, const rtl::Reference< Annotation >& xAnnotation, const Point& rPnt );
virtual void CreateB2dIAObject() override;
virtual bool IsFocusHdl() const override;
private:
- Reference< XAnnotation > mxAnnotation;
+ rtl::Reference< sd::Annotation > mxAnnotation;
rtl::Reference< AnnotationTag > mxTag;
};
}
-AnnotationHdl::AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt )
+AnnotationHdl::AnnotationHdl( const SmartTagReference& xTag, const rtl::Reference< Annotation >& xAnnotation, const Point& rPnt )
: SmartHdl( xTag, rPnt, SdrHdlKind::SmartTag )
, mxAnnotation( xAnnotation )
, mxTag( dynamic_cast< AnnotationTag* >( xTag.get() ) )
@@ -193,17 +191,17 @@ void AnnotationHdl::CreateB2dIAObject()
const Point aTagPos( GetPos() );
basegfx::B2DPoint aPosition( aTagPos.X(), aTagPos.Y() );
- const bool bFocused = IsFocusHdl() && pHdlList && (pHdlList->GetFocusHdl() == this);
+ const bool bFocused = IsFocusHdl() && m_pHdlList && (m_pHdlList->GetFocusHdl() == this);
BitmapEx aBitmapEx( mxTag->CreateAnnotationBitmap(mxTag->isSelected()) );
BitmapEx aBitmapEx2;
if( bFocused )
aBitmapEx2 = mxTag->CreateAnnotationBitmap(!mxTag->isSelected() );
- if(!pHdlList)
+ if(!m_pHdlList)
return;
- SdrMarkView* pView = pHdlList->GetView();
+ SdrMarkView* pView = m_pHdlList->GetView();
if(!pView || pView->areMarkHandlesHidden())
return;
@@ -224,11 +222,9 @@ void AnnotationHdl::CreateB2dIAObject()
{
std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject;
- auto* pAnnotation = dynamic_cast<sd::Annotation*>(mxAnnotation.get());
-
- if (pAnnotation && pAnnotation->hasCustomAnnotationMarker())
+ if (mxAnnotation && mxAnnotation->hasCustomAnnotationMarker())
{
- CustomAnnotationMarker& rCustomAnnotationMarker = pAnnotation->getCustomAnnotationMarker();
+ CustomAnnotationMarker& rCustomAnnotationMarker = mxAnnotation->getCustomAnnotationMarker();
auto& rPolygons = rCustomAnnotationMarker.maPolygons;
if (!rPolygons.empty())
@@ -238,7 +234,7 @@ void AnnotationHdl::CreateB2dIAObject()
aPolyPolygon.append(rPolygon);
pOverlayObject.reset(new sdr::overlay::OverlayPolyPolygon(
- aPolyPolygon,
+ std::move(aPolyPolygon),
rCustomAnnotationMarker.maLineColor,
rCustomAnnotationMarker.mnLineWidth,
rCustomAnnotationMarker.maFillColor));
@@ -273,7 +269,7 @@ bool AnnotationHdl::IsFocusHdl() const
return true;
}
-AnnotationTag::AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const Reference< XAnnotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont )
+AnnotationTag::AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const rtl::Reference< Annotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont )
: SmartTag( rView )
, mrManager( rManager )
, mxAnnotation( xAnnotation )
@@ -523,18 +519,28 @@ BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected )
{
ScopedVclPtrInstance< VirtualDevice > pVDev;
- OUString sInitials(mxAnnotation->getInitials());
- if (sInitials.isEmpty())
- sInitials = getInitials(mxAnnotation->getAuthor());
+ OUString sText;
+ if (mxAnnotation && mxAnnotation->isFreeText())
+ {
+ sText = mxAnnotation->getTextRange()->getString();
+ }
+ else
+ {
+ OUString sInitials(mxAnnotation->getInitials());
+ if (sInitials.isEmpty())
+ {
+ sInitials = getInitials(mxAnnotation->getAuthor());
+ }
- OUString sAuthor(sInitials + " " + OUString::number(mnIndex));
+ sText = sInitials + " " + OUString::number(mnIndex);
+ }
pVDev->SetFont( mrFont );
const int BORDER_X = 4; // pixels
const int BORDER_Y = 4; // pixels
- maSize = Size( pVDev->GetTextWidth( sAuthor ) + 2*BORDER_X, pVDev->GetTextHeight() + 2*BORDER_Y );
+ maSize = Size(pVDev->GetTextWidth(sText) + 2 * BORDER_X, pVDev->GetTextHeight() + 2 * BORDER_Y);
pVDev->SetOutputSizePixel( maSize, false );
Color aBorderColor( maColor );
@@ -562,7 +568,7 @@ BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected )
pVDev->DrawRect( aBorderRect );
pVDev->SetTextColor( maColor.IsDark() ? COL_WHITE : COL_BLACK );
- pVDev->DrawText( Point( BORDER_X, BORDER_Y ), sAuthor );
+ pVDev->DrawText(Point(BORDER_X, BORDER_Y), sText);
return pVDev->GetBitmapEx( aPos, maSize );
}
diff --git a/sd/source/ui/annotations/annotationtag.hxx b/sd/source/ui/annotations/annotationtag.hxx
index 1c10a2db3c97..b5807a4b08d7 100644
--- a/sd/source/ui/annotations/annotationtag.hxx
+++ b/sd/source/ui/annotations/annotationtag.hxx
@@ -19,20 +19,22 @@
#pragma once
+#include <vcl/vclevent.hxx>
+
#include <smarttag.hxx>
#include "annotationwindow.hxx"
namespace com::sun::star::office { class XAnnotation; }
namespace sd {
-
+class Annotation;
class View;
class AnnotationManagerImpl;
class AnnotationTag final : public SmartTag
{
public:
- AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const css::uno::Reference< css::office::XAnnotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont );
+ AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const rtl::Reference< Annotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont );
virtual ~AnnotationTag() override;
/// @return true if the SmartTag handled the event.
@@ -56,7 +58,7 @@ public:
BitmapEx CreateAnnotationBitmap(bool);
- const css::uno::Reference< css::office::XAnnotation >& GetAnnotation() const { return mxAnnotation; }
+ const rtl::Reference< Annotation >& GetAnnotation() const { return mxAnnotation; }
void OpenPopup( bool bEdit );
void ClosePopup();
@@ -72,7 +74,7 @@ private:
DECL_LINK(PopupModeEndHdl, weld::Popover&, void);
AnnotationManagerImpl& mrManager;
- css::uno::Reference< css::office::XAnnotation > mxAnnotation;
+ rtl::Reference< Annotation > mxAnnotation;
std::unique_ptr<AnnotationWindow> mpAnnotationWindow;
Color maColor;
int mnIndex;
diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx
index 0022b84c9625..fffaf70ee863 100644
--- a/sd/source/ui/annotations/annotationwindow.cxx
+++ b/sd/source/ui/annotations/annotationwindow.cxx
@@ -28,6 +28,8 @@
#include <editeng/postitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/crossedoutitem.hxx>
+#include <editeng/editund2.hxx>
+#include <officecfg/Office/Common.hxx>
#include <svx/svxids.hrc>
#include <unotools/useroptions.hxx>
@@ -77,7 +79,7 @@ void AnnotationTextWindow::Paint(vcl::RenderContext& rRenderContext, const ::too
if (!bHighContrast)
{
rRenderContext.DrawGradient(::tools::Rectangle(Point(0,0), rRenderContext.PixelToLogic(aSize)),
- Gradient(GradientStyle::Linear, mrContents.maColorLight, mrContents.maColor));
+ Gradient(css::awt::GradientStyle_LINEAR, mrContents.maColorLight, mrContents.maColor));
}
DoPaint(rRenderContext, rRect);
@@ -165,7 +167,7 @@ EditEngine* AnnotationTextWindow::GetEditEngine() const
OutlinerView* pOutlinerView = mrContents.GetOutlinerView();
if (!pOutlinerView)
return nullptr;
- return pOutlinerView->GetEditView().GetEditEngine();
+ return &pOutlinerView->GetEditView().getEditEngine();
}
void AnnotationTextWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
@@ -188,14 +190,12 @@ void AnnotationTextWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
rDevice.SetBackground(aBgColor);
Size aOutputSize(rDevice.PixelToLogic(aSize));
- aSize = aOutputSize;
- aSize.setHeight(aSize.Height());
EditView* pEditView = GetEditView();
pEditView->setEditViewCallbacks(this);
EditEngine* pEditEngine = GetEditEngine();
- pEditEngine->SetPaperSize(aSize);
+ pEditEngine->SetPaperSize(aOutputSize);
pEditEngine->SetRefDevice(&rDevice);
pEditView->SetOutputArea(::tools::Rectangle(Point(0, 0), aOutputSize));
@@ -249,7 +249,7 @@ void AnnotationWindow::InitControls()
mpOutliner.reset( new ::Outliner(GetAnnotationPool(),OutlinerMode::TextObject) );
SdDrawDocument::SetCalcFieldValueHdl( mpOutliner.get() );
- mpOutliner->SetUpdateMode( true );
+ mpOutliner->SetUpdateLayout( true );
if (OutputDevice* pDev = mpDoc->GetRefDevice())
mpOutliner->SetRefDevice( pDev );
@@ -299,7 +299,7 @@ void AnnotationWindow::InitControls()
mxTextControl->GrabFocus();
}
-IMPL_LINK(AnnotationWindow, MenuItemSelectedHdl, const OString&, rIdent, void)
+IMPL_LINK(AnnotationWindow, MenuItemSelectedHdl, const OUString&, rIdent, void)
{
SfxDispatcher* pDispatcher = mpDocShell->GetViewShell()->GetViewFrame()->GetDispatcher();
if (!pDispatcher)
@@ -390,8 +390,13 @@ void AnnotationWindow::DoResize()
if( aTextHeight > aHeight )
{
- // we need vertical scrollbars and have to reduce the width
- aWidth -= mxVScrollbar->get_scroll_thickness();
+ const int nThickness = mxVScrollbar->get_scroll_thickness();
+ if (nThickness)
+ {
+ // we need vertical scrollbars and have to reduce the width
+ aWidth -= nThickness;
+ mpOutliner->SetPaperSize(rDevice.PixelToLogic(Size(aWidth, aHeight)));
+ }
mxVScrollbar->set_vpolicy(VclPolicyType::ALWAYS);
}
else
@@ -506,7 +511,7 @@ void AnnotationWindow::setAnnotation( const Reference< XAnnotation >& xAnnotatio
if( pTextApi )
{
- std::unique_ptr< OutlinerParaObject > pOPO( pTextApi->CreateText() );
+ std::optional< OutlinerParaObject > pOPO( pTextApi->CreateText() );
mpOutliner->SetText(*pOPO);
}
@@ -547,10 +552,7 @@ void AnnotationWindow::SetColor()
maColorLight = AnnotationManagerImpl::GetColorLight( nAuthorIdx );
}
- {
- SvtAccessibilityOptions aOptions;
- mpOutliner->ForceAutoColor( bHighContrast || aOptions.GetIsAutomaticFontColor() );
- }
+ mpOutliner->ForceAutoColor( bHighContrast || officecfg::Office::Common::Accessibility::IsAutomaticFontColor::get() );
mxPopover->set_background(maColor);
mxMenuButton->set_background(maColor);
@@ -574,7 +576,7 @@ void AnnotationWindow::SaveToDocument()
if( pTextApi )
{
- std::unique_ptr<OutlinerParaObject> pOPO = mpOutliner->CreateParaObject();
+ std::optional<OutlinerParaObject> pOPO = mpOutliner->CreateParaObject();
if( pOPO )
{
if( mpDoc->IsUndoEnabled() )
diff --git a/sd/source/ui/annotations/annotationwindow.hxx b/sd/source/ui/annotations/annotationwindow.hxx
index fe5023413ed4..a150ebf1c8cd 100644
--- a/sd/source/ui/annotations/annotationwindow.hxx
+++ b/sd/source/ui/annotations/annotationwindow.hxx
@@ -21,7 +21,6 @@
#include <vcl/weld.hxx>
#include <tools/long.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
#include <svx/weldeditview.hxx>
namespace com::sun::star::office { class XAnnotation; }
@@ -93,7 +92,7 @@ private:
std::unique_ptr<weld::MenuButton> mxMenuButton;
DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);
- DECL_LINK(MenuItemSelectedHdl, const OString&, void);
+ DECL_LINK(MenuItemSelectedHdl, const OUString&, void);
void FillMenuButton();
void InitControls();