summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-08-25 16:40:47 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-08-26 13:34:04 +0200
commitf6c0803e9984e716f5ba86a0271ecad7e0ed61d8 (patch)
treee4c35bf3bc70f7a818bb1ca179978c70ef3c1c68 /sfx2
parented4142f19a277cd982fd4f9ea19d64282f4d105e (diff)
itemdel.[ch]xx is only used in sfx2
Change-Id: I240f15f87e27ba8a52bab244f8c784d527bff179
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk1
-rw-r--r--sfx2/source/control/bindings.cxx2
-rw-r--r--sfx2/source/control/itemdel.cxx85
-rw-r--r--sfx2/source/control/querystatus.cxx2
-rw-r--r--sfx2/source/control/request.cxx2
-rw-r--r--sfx2/source/control/sfxstatuslistener.cxx2
-rw-r--r--sfx2/source/control/shell.cxx2
-rw-r--r--sfx2/source/inc/itemdel.hxx28
8 files changed, 119 insertions, 5 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 249cdd832596..8ce0196f782e 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -133,6 +133,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/config/evntconf \
sfx2/source/control/bindings \
sfx2/source/control/ctrlitem \
+ sfx2/source/control/itemdel \
sfx2/source/control/minfitem \
sfx2/source/control/msg \
sfx2/source/control/msgpool \
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index afa3d1cd7a84..ad43c5b924d8 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -42,7 +42,7 @@
#include <com/sun/star/frame/DispatchDescriptor.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <comphelper/processfactory.hxx>
-#include <svtools/itemdel.hxx>
+#include "itemdel.hxx"
//Includes below due to nInReschedule
#include "appdata.hxx"
diff --git a/sfx2/source/control/itemdel.cxx b/sfx2/source/control/itemdel.cxx
new file mode 100644
index 000000000000..7ff4d38e237f
--- /dev/null
+++ b/sfx2/source/control/itemdel.cxx
@@ -0,0 +1,85 @@
+/* -*- 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 .
+ */
+
+#include <sal/config.h>
+
+#include <boost/noncopyable.hpp>
+#include "itemdel.hxx"
+#include <vcl/svapp.hxx>
+#include <tools/errcode.hxx>
+#include <limits.h>
+#include <vector>
+
+#include <svl/itempool.hxx>
+
+class SfxItemDisruptor_Impl: private boost::noncopyable
+{
+ SfxPoolItem *pItem;
+ Link aLink;
+
+private:
+ DECL_LINK( Delete, void* );
+
+public:
+ SfxItemDisruptor_Impl( SfxPoolItem *pItemToDesrupt );
+ void LaunchDeleteOnIdle();
+ ~SfxItemDisruptor_Impl();
+};
+
+SfxItemDisruptor_Impl::SfxItemDisruptor_Impl( SfxPoolItem *pItemToDesrupt ):
+ pItem(pItemToDesrupt),
+ aLink( LINK(this, SfxItemDisruptor_Impl, Delete) )
+{
+
+ DBG_ASSERT( 0 == pItem->GetRefCount(), "disrupting pooled item" );
+ pItem->SetKind( SFX_ITEMS_DELETEONIDLE );
+}
+
+void SfxItemDisruptor_Impl::LaunchDeleteOnIdle()
+{
+ // process in Idle
+ Application::InsertIdleHdl( aLink, 1 );
+}
+
+SfxItemDisruptor_Impl::~SfxItemDisruptor_Impl()
+{
+
+ // remove from Idle-Handler
+ Application::RemoveIdleHdl( aLink );
+
+ // reset RefCount (was set to SFX_ITEMS_SPECIAL before!)
+ pItem->SetRefCount( 0 );
+
+ delete pItem;
+}
+
+IMPL_LINK_NOARG(SfxItemDisruptor_Impl, Delete)
+{
+ delete this;
+ return 0;
+}
+
+void DeleteItemOnIdle(SfxPoolItem* pItem)
+{
+ DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" );
+ SfxItemDisruptor_Impl *pDesruptor = new SfxItemDisruptor_Impl(pItem);
+ pDesruptor->LaunchDeleteOnIdle();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/querystatus.cxx b/sfx2/source/control/querystatus.cxx
index 64c1c0e2cdd0..ba455387bac3 100644
--- a/sfx2/source/control/querystatus.cxx
+++ b/sfx2/source/control/querystatus.cxx
@@ -26,7 +26,7 @@
#include <svl/stritem.hxx>
#include <svl/intitem.hxx>
#include <svl/itemset.hxx>
-#include <svtools/itemdel.hxx>
+#include "itemdel.hxx"
#include <svl/visitem.hxx>
#include <cppuhelper/implbase1.hxx>
#include <comphelper/processfactory.hxx>
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index 083d5ea2e055..a98302b79fcc 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -28,7 +28,7 @@
#include <svl/itemiter.hxx>
#include <svl/itempool.hxx>
-#include <svtools/itemdel.hxx>
+#include "itemdel.hxx"
#include <comphelper/processfactory.hxx>
diff --git a/sfx2/source/control/sfxstatuslistener.cxx b/sfx2/source/control/sfxstatuslistener.cxx
index 703ad903d3e6..543bf3d35e7b 100644
--- a/sfx2/source/control/sfxstatuslistener.cxx
+++ b/sfx2/source/control/sfxstatuslistener.cxx
@@ -23,7 +23,7 @@
#include <svl/stritem.hxx>
#include <svl/intitem.hxx>
#include <svl/itemset.hxx>
-#include <svtools/itemdel.hxx>
+#include "itemdel.hxx"
#include <svl/visitem.hxx>
#include <cppuhelper/weak.hxx>
#include <comphelper/processfactory.hxx>
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 594363e9cf2a..fbe76d206a17 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -25,7 +25,7 @@
#include <sal/log.hxx>
#include <svl/itempool.hxx>
#include <svl/undo.hxx>
-#include <svtools/itemdel.hxx>
+#include "itemdel.hxx"
#include <svtools/asynclink.hxx>
#include <basic/sbx.hxx>
diff --git a/sfx2/source/inc/itemdel.hxx b/sfx2/source/inc/itemdel.hxx
new file mode 100644
index 000000000000..cd5d14de170e
--- /dev/null
+++ b/sfx2/source/inc/itemdel.hxx
@@ -0,0 +1,28 @@
+/* -*- 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 .
+ */
+#ifndef INCLUDED_SFX2_ITEMDEL_HXX
+#define INCLUDED_SFX2_ITEMDEL_HXX
+
+class SfxPoolItem;
+
+void DeleteItemOnIdle( SfxPoolItem* pItem );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */