1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_UIVWIMP_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_UIVWIMP_HXX
21 
22 #include <view.hxx>
23 
24 #include <sfx2/objsh.hxx>
25 #include <com/sun/star/view/XSelectionSupplier.hpp>
26 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <cppuhelper/weakref.hxx>
29 
30 class SwXTextView;
31 class SfxRequest;
32 class SwTransferable;
33 class SfxRequest;
34 
35 namespace sfx2 { class DocumentInserter; }
36 namespace com::sun::star {
37     namespace frame {
38         class XDispatchProviderInterceptor;
39     }
40     namespace lang {
41         class XUnoTunnel;
42     }
43 }
44 
45 class SwScannerEventListener : public ::cppu::WeakImplHelper<
46     css::lang::XEventListener >
47 {
48     SwView* pView;
49 
50 public:
51 
SwScannerEventListener(SwView & rView)52     SwScannerEventListener( SwView& rView ) : pView( &rView )  {}
53     virtual ~SwScannerEventListener() override;
54 
55     // XEventListener
56     virtual void SAL_CALL disposing(
57                     const css::lang::EventObject& rEventObject ) override;
58 
ViewDestroyed()59     void ViewDestroyed() { pView = nullptr; }
60 };
61 
62 // Clipboard EventListener
63 class SwClipboardChangeListener : public ::cppu::WeakImplHelper<
64     css::datatransfer::clipboard::XClipboardListener >
65 {
66     SwView* pView;
67 
68     // XEventListener
69     virtual void SAL_CALL disposing( const css::lang::EventObject& rEventObject ) override;
70 
71     // XClipboardListener
72     virtual void SAL_CALL changedContents( const css::datatransfer::clipboard::ClipboardEvent& rEventObject ) override;
73 
74 public:
SwClipboardChangeListener(SwView & rView)75     SwClipboardChangeListener( SwView& rView ) : pView( &rView ) {}
76     virtual ~SwClipboardChangeListener() override;
77 
ViewDestroyed()78     void ViewDestroyed() { pView = nullptr; }
79 
80     void AddRemoveListener( bool bAdd );
81 };
82 
83 class SwMailMergeConfigItem;
84 
85 class SwView_Impl
86 {
87     css::uno::Reference< css::frame::XDispatchProviderInterceptor >   xDisProvInterceptor;
88     css::uno::Reference< css::view::XSelectionSupplier >              mxXTextView;       // UNO object
89     std::vector< css::uno::WeakReference< css::lang::XUnoTunnel > > mxTransferables;
90 
91     // temporary document for printing text of selection / multi selection
92     // in PDF export.
93     SfxObjectShellLock          xTmpSelDocSh;
94 
95     SwView*                     pView;
96     rtl::Reference<SwScannerEventListener>
97                                 mxScanEvtLstnr;
98     rtl::Reference<SwClipboardChangeListener>
99                                 mxClipEvtLstnr;
100     ShellMode                   eShellMode;
101 
102     std::shared_ptr<SwMailMergeConfigItem>
103                                 xConfigItem;
104 
105     std::unique_ptr<sfx2::DocumentInserter> m_pDocInserter;
106     std::unique_ptr<SfxRequest>             m_pRequest;
107     sal_Int16                   m_nParam;
108 
109     Point                       m_aEditingPosition;
110     bool                        m_bSelectObject;
111     bool                        m_bEditingPositionSet;
112 
113 public:
114     /// Redline author that's specific to this view.
115     OUString m_sRedlineAuthor;
116 
117     SwView_Impl(SwView* pShell);
118     ~SwView_Impl();
119 
120     void                            SetShellMode(ShellMode eSet);
121 
122     css::view::XSelectionSupplier* GetUNOObject();
123     SwXTextView*                    GetUNOObject_Impl();
124     void                            Invalidate();
125 
GetShellMode() const126     ShellMode                       GetShellMode() const {return eShellMode;}
127 
128     void                            ExecuteScan(SfxRequest& rReq);
129     SwScannerEventListener&         GetScannerEventListener();
130 
131     void                            AddClipboardListener();
132 
133     void                            AddTransferable(SwTransferable& rTransferable);
134 
SetMailMergeConfigItem(std::shared_ptr<SwMailMergeConfigItem> const & rItem)135     void SetMailMergeConfigItem(std::shared_ptr<SwMailMergeConfigItem> const & rItem)
136     {
137         xConfigItem = rItem;
138     }
GetMailMergeConfigItem() const139     std::shared_ptr<SwMailMergeConfigItem> const & GetMailMergeConfigItem() const {return xConfigItem;}
140 
141     //#i33307# restore editing position
SetRestorePosition(const Point & rCursorPos,bool bSelectObj)142     void                    SetRestorePosition(const Point& rCursorPos, bool bSelectObj)
143                             {
144                                 m_aEditingPosition = rCursorPos;
145                                 m_bSelectObject = bSelectObj;
146                                 m_bEditingPositionSet = true;
147                             }
GetRestorePosition(Point & rCursorPos,bool & rbSelectObj)148     bool                    GetRestorePosition(Point& rCursorPos, bool& rbSelectObj)
149                             {
150                                 rCursorPos = m_aEditingPosition;
151                                 rbSelectObj = m_bSelectObject;
152                                 return m_bEditingPositionSet;
153                             }
154 
155     void                    StartDocumentInserter(
156                                 const OUString& rFactory,
157                                 const Link<sfx2::FileDialogHelper*,void>& rEndDialogHdl,
158                                 const sal_uInt16 nSlotId
159                             );
160     std::unique_ptr<SfxMedium> CreateMedium();
161     void                    InitRequest( const SfxRequest& rRequest );
162 
GetRequest() const163     SfxRequest*      GetRequest() const { return m_pRequest.get(); }
GetParam() const164     sal_Int16        GetParam() const { return m_nParam; }
SetParam(sal_Int16 nParam)165     void             SetParam( sal_Int16 nParam ) { m_nParam = nParam; }
166 };
167 #endif
168 
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
170