xref: /AOO41X/main/sd/source/ui/framework/factories/Pane.cxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "framework/Pane.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <rtl/uuid.h>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <vos/mutex.hxx>
31cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
32cdf0e10cSrcweir #include <vcl/window.hxx>
33cdf0e10cSrcweir #include <cppcanvas/vclfactory.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using namespace ::com::sun::star;
36cdf0e10cSrcweir using namespace ::com::sun::star::uno;
37cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using ::rtl::OUString;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace sd { namespace framework {
42cdf0e10cSrcweir 
Pane(const Reference<XResourceId> & rxPaneId,::Window * pWindow)43cdf0e10cSrcweir Pane::Pane (
44cdf0e10cSrcweir     const Reference<XResourceId>& rxPaneId,
45cdf0e10cSrcweir     ::Window* pWindow)
46cdf0e10cSrcweir     throw ()
47cdf0e10cSrcweir     : PaneInterfaceBase(MutexOwner::maMutex),
48cdf0e10cSrcweir       mxPaneId(rxPaneId),
49cdf0e10cSrcweir       mpWindow(pWindow),
50cdf0e10cSrcweir       mxWindow(VCLUnoHelper::GetInterface(pWindow))
51cdf0e10cSrcweir {
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 
~Pane(void)57cdf0e10cSrcweir Pane::~Pane (void) throw()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
disposing(void)64cdf0e10cSrcweir void Pane::disposing (void)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     mxWindow = NULL;
67cdf0e10cSrcweir     mpWindow = NULL;
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
GetWindow(void)73cdf0e10cSrcweir ::Window* Pane::GetWindow (void)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     if (mxWindow.is())
76cdf0e10cSrcweir         return mpWindow;
77cdf0e10cSrcweir     else
78cdf0e10cSrcweir         return NULL;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
SetWindow(::Window * pWindow)84*7a32b0c8SAndre Fischer void Pane::SetWindow (::Window* pWindow)
85*7a32b0c8SAndre Fischer {
86*7a32b0c8SAndre Fischer     OSL_TRACE("setting Pane::mpWindow to %x", pWindow);
87*7a32b0c8SAndre Fischer     mpWindow = pWindow;
88*7a32b0c8SAndre Fischer     mxWindow = VCLUnoHelper::GetInterface(mpWindow);
89*7a32b0c8SAndre Fischer }
90*7a32b0c8SAndre Fischer 
91*7a32b0c8SAndre Fischer 
92*7a32b0c8SAndre Fischer 
93*7a32b0c8SAndre Fischer 
94cdf0e10cSrcweir //----- XPane -----------------------------------------------------------------
95cdf0e10cSrcweir 
getWindow(void)96cdf0e10cSrcweir Reference<awt::XWindow> SAL_CALL Pane::getWindow (void)
97cdf0e10cSrcweir     throw (RuntimeException)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     ThrowIfDisposed();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     return mxWindow;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
getCanvas(void)107cdf0e10cSrcweir Reference<rendering::XCanvas> SAL_CALL Pane::getCanvas (void)
108cdf0e10cSrcweir     throw (RuntimeException)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
111cdf0e10cSrcweir     ThrowIfDisposed();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     if ( ! mxCanvas.is())
114cdf0e10cSrcweir         mxCanvas = CreateCanvas();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     return mxCanvas;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir //----- XPane2 ----------------------------------------------------------------
123cdf0e10cSrcweir 
isVisible(void)124cdf0e10cSrcweir sal_Bool SAL_CALL Pane::isVisible (void)
125cdf0e10cSrcweir     throw (RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     ThrowIfDisposed();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     const ::Window* pWindow = GetWindow();
130cdf0e10cSrcweir     if (pWindow != NULL)
131cdf0e10cSrcweir         return pWindow->IsVisible();
132cdf0e10cSrcweir     else
133cdf0e10cSrcweir         return false;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 
setVisible(sal_Bool bIsVisible)139cdf0e10cSrcweir void SAL_CALL Pane::setVisible (sal_Bool bIsVisible)
140cdf0e10cSrcweir     throw (RuntimeException)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     ThrowIfDisposed();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     ::Window* pWindow = GetWindow();
145cdf0e10cSrcweir     if (pWindow != NULL)
146cdf0e10cSrcweir         pWindow->Show(bIsVisible);
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 
getAccessible(void)152cdf0e10cSrcweir Reference<accessibility::XAccessible> SAL_CALL Pane::getAccessible (void)
153cdf0e10cSrcweir     throw (RuntimeException)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     ThrowIfDisposed();
156cdf0e10cSrcweir     ::Window* pWindow = GetWindow();
157cdf0e10cSrcweir     if (pWindow != NULL)
158cdf0e10cSrcweir         return pWindow->GetAccessible(sal_False);
159cdf0e10cSrcweir     else
160cdf0e10cSrcweir         return NULL;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 
setAccessible(const Reference<accessibility::XAccessible> & rxAccessible)166cdf0e10cSrcweir void SAL_CALL Pane::setAccessible (
167cdf0e10cSrcweir     const Reference<accessibility::XAccessible>& rxAccessible)
168cdf0e10cSrcweir     throw (RuntimeException)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir     ThrowIfDisposed();
171cdf0e10cSrcweir     ::Window* pWindow = GetWindow();
172cdf0e10cSrcweir     if (pWindow != NULL)
173cdf0e10cSrcweir         pWindow->SetAccessible(rxAccessible);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir //----- XResource -------------------------------------------------------------
180cdf0e10cSrcweir 
getResourceId(void)181cdf0e10cSrcweir Reference<XResourceId> SAL_CALL Pane::getResourceId (void)
182cdf0e10cSrcweir     throw (RuntimeException)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir     ThrowIfDisposed();
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     return mxPaneId;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
isAnchorOnly(void)192cdf0e10cSrcweir sal_Bool SAL_CALL Pane::isAnchorOnly (void)
193cdf0e10cSrcweir     throw (RuntimeException)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     return true;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 
201cdf0e10cSrcweir //----- XUnoTunnel ------------------------------------------------------------
202cdf0e10cSrcweir 
getUnoTunnelId(void)203cdf0e10cSrcweir const Sequence<sal_Int8>& Pane::getUnoTunnelId (void)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	static Sequence<sal_Int8>* pSequence = NULL;
206cdf0e10cSrcweir 	if (pSequence == NULL)
207cdf0e10cSrcweir 	{
208cdf0e10cSrcweir         const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
209cdf0e10cSrcweir 		if (pSequence == NULL)
210cdf0e10cSrcweir 		{
211cdf0e10cSrcweir 			static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
212cdf0e10cSrcweir 			rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
213cdf0e10cSrcweir 			pSequence = &aSequence;
214cdf0e10cSrcweir 		}
215cdf0e10cSrcweir 	}
216cdf0e10cSrcweir 	return *pSequence;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
getSomething(const Sequence<sal_Int8> & rId)222cdf0e10cSrcweir sal_Int64 SAL_CALL Pane::getSomething (const Sequence<sal_Int8>& rId)
223cdf0e10cSrcweir     throw (RuntimeException)
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     sal_Int64 nResult = 0;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     if (rId.getLength() == 16
228cdf0e10cSrcweir         && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
229cdf0e10cSrcweir 	{
230cdf0e10cSrcweir 		nResult = reinterpret_cast<sal_Int64>(this);
231cdf0e10cSrcweir 	}
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     return nResult;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
239cdf0e10cSrcweir //-----------------------------------------------------------------------------
240cdf0e10cSrcweir 
CreateCanvas(void)241cdf0e10cSrcweir Reference<rendering::XCanvas> Pane::CreateCanvas (void)
242cdf0e10cSrcweir     throw (RuntimeException)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     Reference<rendering::XCanvas> xCanvas;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     if (mpWindow != NULL)
247cdf0e10cSrcweir     {
248cdf0e10cSrcweir         ::cppcanvas::SpriteCanvasSharedPtr pCanvas (
249cdf0e10cSrcweir             ::cppcanvas::VCLFactory::getInstance().createSpriteCanvas(*mpWindow));
250cdf0e10cSrcweir         if (pCanvas.get() != NULL)
251cdf0e10cSrcweir             xCanvas = Reference<rendering::XCanvas>(pCanvas->getUNOSpriteCanvas(), UNO_QUERY);
252cdf0e10cSrcweir     }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     return xCanvas;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 
ThrowIfDisposed(void) const260cdf0e10cSrcweir void Pane::ThrowIfDisposed (void) const
261cdf0e10cSrcweir     throw (lang::DisposedException)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
264cdf0e10cSrcweir 	{
265cdf0e10cSrcweir         throw lang::DisposedException (
266cdf0e10cSrcweir             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
267cdf0e10cSrcweir                 "Pane object has already been disposed")),
268cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 
273cdf0e10cSrcweir } } // end of namespace sd::framework
274