summaryrefslogtreecommitdiff
path: root/sw/source/uibase/docvw/AnnotationWin.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-04-10 14:12:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-04-11 10:20:58 +0200
commitbf6449230ad2b4dfb427a062663e5ff2b9ddf3b6 (patch)
tree75c9947c10b4685cb9caaaaf1b59ca3f679bcd4e /sw/source/uibase/docvw/AnnotationWin.cxx
parent9fa75f677a7b48a2177fe11cca0d00f5a2deb7da (diff)
loplugin:mergeclasses merge SwAnnotationWin and SwSidebarWin
Change-Id: Idaf7d7e8e4da37e0ba423dca3e22dc6711ba806a Reviewed-on: https://gerrit.libreoffice.org/36380 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase/docvw/AnnotationWin.cxx')
-rw-r--r--sw/source/uibase/docvw/AnnotationWin.cxx126
1 files changed, 121 insertions, 5 deletions
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx
index 7809c3bc18b3..9f70393f637e 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -51,6 +51,11 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <SwUndoField.hxx>
+#include <edtwin.hxx>
+#include <ShadowOverlayObject.hxx>
+#include <AnchorOverlayObject.hxx>
+#include <OverlayRanges.hxx>
+#include <SidebarTxtControl.hxx>
#include <memory>
@@ -61,11 +66,49 @@ SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
SwPostItMgr& aMgr,
SwSidebarItem& rSidebarItem,
SwFormatField* aField )
- : SwSidebarWin( rEditWin, nBits, aMgr, rSidebarItem )
+ : Window(&rEditWin, nBits)
+ , mrMgr(aMgr)
+ , mrView(rEditWin.GetView())
+ , mnEventId(nullptr)
+ , mpOutlinerView(nullptr)
+ , mpOutliner(nullptr)
+ , mpSidebarTextControl(nullptr)
+ , mpVScrollbar(nullptr)
+ , mpMetadataAuthor(nullptr)
+ , mpMetadataDate(nullptr)
+ , mpMenuButton(nullptr)
+ , mpAnchor(nullptr)
+ , mpShadow(nullptr)
+ , mpTextRangeOverlay(nullptr)
+ , mColorAnchor()
+ , mColorDark()
+ , mColorLight()
+ , mChangeColor()
+ , meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE)
+ , mPosSize()
+ , mAnchorRect()
+ , mPageBorder(0)
+ , mbAnchorRectChanged(false)
+ , mbMouseOver(false)
+ , mLayoutStatus(SwPostItHelper::INVISIBLE)
+ , mbReadonly(false)
+ , mbIsFollow(false)
+ , mrSidebarItem(rSidebarItem)
+ , mpAnchorFrame(rSidebarItem.maLayoutInfo.mpAnchorFrame)
, mpFormatField(aField)
, mpField( static_cast<SwPostItField*>(aField->GetField()))
, mpButtonPopup(nullptr)
{
+ mpShadow = sidebarwindows::ShadowOverlayObject::CreateShadowOverlayObject( mrView );
+ if ( mpShadow )
+ {
+ mpShadow->setVisible(false);
+ }
+
+ mrMgr.ConnectSidebarWinToFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame),
+ mrSidebarItem.GetFormatField(),
+ *this );
+
if (SupportsDoubleBuffering())
// When double-buffering, allow parents to paint on our area. That's
// necessary when parents paint the complete buffer.
@@ -80,7 +123,71 @@ SwAnnotationWin::~SwAnnotationWin()
void SwAnnotationWin::dispose()
{
mpButtonPopup.disposeAndClear();
- sw::sidebarwindows::SwSidebarWin::dispose();
+
+ if (IsDisposed())
+ return;
+
+ mrMgr.DisconnectSidebarWinFromFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame),
+ *this );
+
+ Disable();
+
+ if ( mpSidebarTextControl )
+ {
+ if ( mpOutlinerView )
+ {
+ mpOutlinerView->SetWindow( nullptr );
+ }
+ }
+ mpSidebarTextControl.disposeAndClear();
+
+ if ( mpOutlinerView )
+ {
+ delete mpOutlinerView;
+ mpOutlinerView = nullptr;
+ }
+
+ if (mpOutliner)
+ {
+ delete mpOutliner;
+ mpOutliner = nullptr;
+ }
+
+ if (mpMetadataAuthor)
+ {
+ mpMetadataAuthor->RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) );
+ }
+ mpMetadataAuthor.disposeAndClear();
+
+ if (mpMetadataDate)
+ {
+ mpMetadataDate->RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) );
+ }
+ mpMetadataDate.disposeAndClear();
+
+ if (mpVScrollbar)
+ {
+ mpVScrollbar->RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) );
+ }
+ mpVScrollbar.disposeAndClear();
+
+ RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) );
+
+ sidebarwindows::AnchorOverlayObject::DestroyAnchorOverlayObject( mpAnchor );
+ mpAnchor = nullptr;
+
+ sidebarwindows::ShadowOverlayObject::DestroyShadowOverlayObject( mpShadow );
+ mpShadow = nullptr;
+
+ delete mpTextRangeOverlay;
+ mpTextRangeOverlay = nullptr;
+
+ mpMenuButton.disposeAndClear();
+
+ if (mnEventId)
+ Application::RemoveUserEvent( mnEventId );
+
+ vcl::Window::dispose();
}
void SwAnnotationWin::SetPostItText()
@@ -155,7 +262,16 @@ void SwAnnotationWin::Delete()
{
if (DocView().GetWrtShellPtr()->GotoField(*mpFormatField))
{
- SwSidebarWin::Delete();
+ if ( mrMgr.GetActiveSidebarWin() == this)
+ {
+ mrMgr.SetActiveSidebarWin(nullptr);
+ // if the note is empty, the previous line will send a delete event, but we are already there
+ if (mnEventId)
+ {
+ Application::RemoveUserEvent( mnEventId );
+ mnEventId = nullptr;
+ }
+ }
// we delete the field directly, the Mgr cleans up the PostIt by listening
GrabFocusToDocument();
DocView().GetWrtShellPtr()->ClearMark();
@@ -245,7 +361,7 @@ void SwAnnotationWin::InitAnswer(OutlinerParaObject* pText)
return;
//collect our old meta data
- SwSidebarWin* pWin = Mgr().GetNextPostIt(KEY_PAGEUP, this);
+ SwAnnotationWin* pWin = Mgr().GetNextPostIt(KEY_PAGEUP, this);
const SvtSysLocale aSysLocale;
const LocaleDataWrapper& rLocalData = aSysLocale.GetLocaleData();
SwRewriter aRewriter;
@@ -323,7 +439,7 @@ SvxLanguageItem SwAnnotationWin::GetLanguage()
bool SwAnnotationWin::IsProtected()
{
- return SwSidebarWin::IsProtected() ||
+ return mbReadonly ||
GetLayoutStatus() == SwPostItHelper::DELETED ||
( mpFormatField && mpFormatField->IsProtect() );
}