1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "ColumnControl.hxx"
30 #include "ColumnPeer.hxx"
31 #include "dbustrings.hrc"
32 #include "apitools.hxx"
33 #include <com/sun/star/awt/PosSize.hpp>
34 #include "dbu_reghelper.hxx"
36 extern "C" void SAL_CALL
createRegistryInfo_OColumnControl()
38 static ::dbaui::OMultiInstanceAutoRegistration
< ::dbaui::OColumnControl
> aAutoRegistration
;
40 //.........................................................................
43 //.........................................................................
44 using namespace ::com::sun::star::uno
;
45 using namespace ::com::sun::star::awt
;
46 using namespace ::com::sun::star::beans
;
47 using namespace ::com::sun::star::lang
;
48 using namespace ::com::sun::star::sdbc
;
50 OColumnControl::OColumnControl(const Reference
<XMultiServiceFactory
>& _rxFactory
)
51 :UnoControl( _rxFactory
)
54 // -----------------------------------------------------------------------------
55 IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControl
,SERVICE_CONTROLDEFAULT
.ascii
,"com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl")
56 // -----------------------------------------------------------------------------
57 ::rtl::OUString
OColumnControl::GetComponentServiceName()
59 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ColumnDescriptorControl"));
61 // -----------------------------------------------------------------------------
62 void SAL_CALL
OColumnControl::createPeer(const Reference
< XToolkit
>& /*rToolkit*/, const Reference
< XWindowPeer
>& rParentPeer
) throw( RuntimeException
)
64 ::osl::ClearableMutexGuard
aGuard( GetMutex() );
65 if ( !getPeer().is() )
67 mbCreatingPeer
= sal_True
;
69 Window
* pParentWin
= NULL
;
72 VCLXWindow
* pParent
= VCLXWindow::GetImplementation(rParentPeer
);
74 pParentWin
= pParent
->GetWindow();
77 OColumnPeer
* pPeer
= new OColumnPeer( pParentWin
, maContext
.getLegacyServiceFactory() );
78 OSL_ENSURE(pPeer
!= NULL
, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
81 UnoControlComponentInfos
aComponentInfos(maComponentInfos
);
82 Reference
< XGraphics
> xGraphics( mxGraphics
);
83 Reference
< XView
> xV(getPeer(), UNO_QUERY
);
84 Reference
< XWindow
> xW(getPeer(), UNO_QUERY
);
90 xV
->setZoom( aComponentInfos
.nZoomX
, aComponentInfos
.nZoomY
);
91 setPosSize( aComponentInfos
.nX
, aComponentInfos
.nY
, aComponentInfos
.nWidth
, aComponentInfos
.nHeight
, ::com::sun::star::awt::PosSize::POSSIZE
);
93 Reference
<XPropertySet
> xProp(getModel(), UNO_QUERY
);
96 Reference
<XConnection
> xCon(xProp
->getPropertyValue(PROPERTY_ACTIVE_CONNECTION
),UNO_QUERY
);
97 pPeer
->setConnection(xCon
);
98 Reference
<XPropertySet
> xColumn(xProp
->getPropertyValue(PROPERTY_COLUMN
),UNO_QUERY
);
99 pPeer
->setColumn(xColumn
);
100 sal_Int32 nWidth
= 50;
101 xProp
->getPropertyValue(PROPERTY_EDIT_WIDTH
) >>= nWidth
;
102 pPeer
->setEditWidth(nWidth
);
105 if (aComponentInfos
.bVisible
)
106 xW
->setVisible(sal_True
);
108 if (!aComponentInfos
.bEnable
)
109 xW
->setEnable(sal_False
);
111 if (maWindowListeners
.getLength())
112 xW
->addWindowListener( &maWindowListeners
);
114 if (maFocusListeners
.getLength())
115 xW
->addFocusListener( &maFocusListeners
);
117 if (maKeyListeners
.getLength())
118 xW
->addKeyListener( &maKeyListeners
);
120 if (maMouseListeners
.getLength())
121 xW
->addMouseListener( &maMouseListeners
);
123 if (maMouseMotionListeners
.getLength())
124 xW
->addMouseMotionListener( &maMouseMotionListeners
);
126 if (maPaintListeners
.getLength())
127 xW
->addPaintListener( &maPaintListeners
);
129 Reference
< ::com::sun::star::awt::XView
> xPeerView(getPeer(), UNO_QUERY
);
130 xPeerView
->setZoom( maComponentInfos
.nZoomX
, maComponentInfos
.nZoomY
);
131 xPeerView
->setGraphics( xGraphics
);
133 mbCreatingPeer
= sal_False
;
136 //.........................................................................
138 //.........................................................................
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */