Line data Source code
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 :
20 : #ifndef INCLUDED_BASCTL_SOURCE_INC_DLGEDOBJ_HXX
21 : #define INCLUDED_BASCTL_SOURCE_INC_DLGEDOBJ_HXX
22 :
23 : #include <com/sun/star/frame/XModel.hpp>
24 : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
25 : #include <com/sun/star/container/XContainerListener.hpp>
26 : #include <comphelper/processfactory.hxx>
27 : #include <svx/svdouno.hxx>
28 :
29 : #include <boost/optional.hpp>
30 :
31 : namespace basctl
32 : {
33 :
34 : typedef ::std::multimap< sal_Int16, OUString, ::std::less< sal_Int16 > > IndexToNameMap;
35 :
36 :
37 : class DlgEdForm;
38 : class DlgEditor;
39 :
40 :
41 : // DlgEdObj
42 :
43 :
44 0 : class DlgEdObj: public SdrUnoObj
45 : {
46 : friend class DlgEditor;
47 : friend class DlgEdFactory;
48 : friend class DlgEdPropListenerImpl;
49 : friend class DlgEdForm;
50 :
51 : private:
52 : bool bIsListening;
53 : DlgEdForm* pDlgEdForm;
54 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
55 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener> m_xContainerListener;
56 :
57 : private:
58 : DlgEditor& GetDialogEditor ();
59 :
60 : protected:
61 : DlgEdObj();
62 : DlgEdObj(const OUString& rModelName,
63 : const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac);
64 :
65 : virtual void NbcMove( const Size& rSize ) SAL_OVERRIDE;
66 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
67 : virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
68 :
69 : using SfxListener::StartListening;
70 : void StartListening();
71 : using SfxListener::EndListening;
72 : void EndListening(bool bRemoveListener = true);
73 0 : bool isListening() const { return bIsListening; }
74 :
75 : bool TransformSdrToControlCoordinates(
76 : sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
77 : sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
78 : bool TransformSdrToFormCoordinates(
79 : sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
80 : sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
81 : bool TransformControlToSdrCoordinates(
82 : sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
83 : sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
84 : bool TransformFormToSdrCoordinates(
85 : sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
86 : sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut );
87 :
88 : public:
89 : TYPEINFO_OVERRIDE();
90 :
91 : virtual ~DlgEdObj();
92 : virtual void SetPage(SdrPage* pNewPage) SAL_OVERRIDE;
93 :
94 0 : void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
95 0 : DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
96 :
97 : virtual sal_uInt32 GetObjInventor() const SAL_OVERRIDE;
98 : virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
99 :
100 : virtual DlgEdObj* Clone() const SAL_OVERRIDE; // not working yet
101 : void clonedFrom(const DlgEdObj* _pSource); // not working yet
102 :
103 : // FullDrag support
104 : virtual SdrObject* getFullDragClone() const SAL_OVERRIDE;
105 :
106 : bool supportsService( OUString const & serviceName ) const;
107 : OUString GetDefaultName() const;
108 : OUString GetUniqueName() const;
109 :
110 : sal_Int32 GetStep() const;
111 : virtual void UpdateStep();
112 :
113 : void SetDefaults();
114 : virtual void SetRectFromProps();
115 : virtual void SetPropsFromRect();
116 :
117 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > GetControl() const;
118 :
119 : virtual void PositionAndSizeChange( const ::com::sun::star::beans::PropertyChangeEvent& evt );
120 : void SAL_CALL NameChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(css::container::NoSuchElementException, css::uno::RuntimeException);
121 : void SAL_CALL TabIndexChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
122 :
123 : // PropertyChangeListener
124 : void SAL_CALL _propertyChange(const css::beans::PropertyChangeEvent& evt) throw (css::uno::RuntimeException, std::exception);
125 :
126 : // ContainerListener
127 : void SAL_CALL _elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
128 : void SAL_CALL _elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
129 : void SAL_CALL _elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
130 :
131 : virtual void SetLayer(SdrLayerID nLayer) SAL_OVERRIDE;
132 : bool MakeDataAware( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel );
133 : };
134 :
135 :
136 :
137 : // DlgEdForm
138 :
139 :
140 : class DlgEdForm: public DlgEdObj
141 : {
142 : friend class DlgEditor;
143 : friend class DlgEdFactory;
144 :
145 : private:
146 : DlgEditor& rDlgEditor;
147 : ::std::vector<DlgEdObj*> pChildren;
148 :
149 : mutable ::boost::optional< ::com::sun::star::awt::DeviceInfo > mpDeviceInfo;
150 :
151 : private:
152 : explicit DlgEdForm (DlgEditor&);
153 :
154 : protected:
155 : virtual void NbcMove( const Size& rSize ) SAL_OVERRIDE;
156 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
157 : virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
158 :
159 : public:
160 : TYPEINFO_OVERRIDE();
161 :
162 : virtual ~DlgEdForm();
163 :
164 0 : DlgEditor& GetDlgEditor () const { return rDlgEditor; }
165 :
166 : void AddChild( DlgEdObj* pDlgEdObj );
167 : void RemoveChild( DlgEdObj* pDlgEdObj );
168 0 : std::vector<DlgEdObj*> const& GetChildren() const { return pChildren; }
169 :
170 : virtual void UpdateStep() SAL_OVERRIDE;
171 :
172 : virtual void SetRectFromProps() SAL_OVERRIDE;
173 : virtual void SetPropsFromRect() SAL_OVERRIDE;
174 :
175 : virtual void PositionAndSizeChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) SAL_OVERRIDE;
176 :
177 : void UpdateTabIndices();
178 : void UpdateTabOrder();
179 : void UpdateGroups();
180 : void UpdateTabOrderAndGroups();
181 :
182 : ::com::sun::star::awt::DeviceInfo getDeviceInfo() const;
183 :
184 : private:
185 : void ImplInvalidateDeviceInfo();
186 : };
187 :
188 : } // namespace basctl
189 :
190 : #endif // INCLUDED_BASCTL_SOURCE_INC_DLGEDOBJ_HXX
191 :
192 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|