xref: /trunk/main/reportdesign/source/ui/dlg/GroupsSorting.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
19e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39e0e4191SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49e0e4191SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59e0e4191SAndrew Rist  * distributed with this work for additional information
69e0e4191SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79e0e4191SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89e0e4191SAndrew Rist  * "License"); you may not use this file except in compliance
99e0e4191SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139e0e4191SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149e0e4191SAndrew Rist  * software distributed under the License is distributed on an
159e0e4191SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169e0e4191SAndrew Rist  * KIND, either express or implied.  See the License for the
179e0e4191SAndrew Rist  * specific language governing permissions and limitations
189e0e4191SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209e0e4191SAndrew Rist  *************************************************************/
219e0e4191SAndrew Rist 
229e0e4191SAndrew Rist 
23b63233d8Sdamjan #include "precompiled_rptui.hxx"
24cdf0e10cSrcweir #include "GroupsSorting.hxx"
25cdf0e10cSrcweir #include "GroupsSorting.hrc"
26cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
27cdf0e10cSrcweir #include <svtools/editbrowsebox.hxx>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
29cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp>
30cdf0e10cSrcweir #include <com/sun/star/report/GroupOn.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <tools/debug.hxx>
34cdf0e10cSrcweir #include "RptResId.hrc"
35cdf0e10cSrcweir #include "rptui_slotid.hrc"
36cdf0e10cSrcweir #include "ModuleHelper.hxx"
37cdf0e10cSrcweir #include "helpids.hrc"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <svx/globlmn.hrc>
40cdf0e10cSrcweir #include <svx/svxids.hrc>
41cdf0e10cSrcweir #include <svtools/imgdef.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "GroupExchange.hxx"
44cdf0e10cSrcweir #include "UITools.hxx"
45cdf0e10cSrcweir #include "UndoActions.hxx"
46cdf0e10cSrcweir #include "uistrings.hrc"
47cdf0e10cSrcweir #include "ReportController.hxx"
48cdf0e10cSrcweir #include "ColumnInfo.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
51cdf0e10cSrcweir #include <comphelper/property.hxx>
52cdf0e10cSrcweir #include <vcl/mnemonic.hxx>
53cdf0e10cSrcweir #include <vcl/msgbox.hxx>
54cdf0e10cSrcweir #include <algorithm>
55cdf0e10cSrcweir #include <boost/bind.hpp>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define HANDLE_ID           0
60cdf0e10cSrcweir #define FIELD_EXPRESSION    1
61cdf0e10cSrcweir #define GROUPS_START_LEN    5
62cdf0e10cSrcweir #define NO_GROUP            -1
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace rptui
65cdf0e10cSrcweir {
66cdf0e10cSrcweir using namespace ::com::sun::star;
67cdf0e10cSrcweir using namespace svt;
68cdf0e10cSrcweir using namespace ::comphelper;
69cdf0e10cSrcweir 
lcl_addToList_throw(ComboBoxControl & _rListBox,::std::vector<ColumnInfo> & o_aColumnList,const uno::Reference<container::XNameAccess> & i_xColumns)70cdf0e10cSrcweir     void lcl_addToList_throw( ComboBoxControl& _rListBox, ::std::vector<ColumnInfo>& o_aColumnList,const uno::Reference< container::XNameAccess>& i_xColumns )
71cdf0e10cSrcweir     {
72cdf0e10cSrcweir         uno::Sequence< ::rtl::OUString > aEntries = i_xColumns->getElementNames();
73cdf0e10cSrcweir         const ::rtl::OUString* pEntries = aEntries.getConstArray();
74cdf0e10cSrcweir         sal_Int32 nEntries = aEntries.getLength();
75cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
76cdf0e10cSrcweir         {
77cdf0e10cSrcweir             uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),uno::UNO_QUERY_THROW);
78cdf0e10cSrcweir             ::rtl::OUString sLabel;
79cdf0e10cSrcweir             if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
80cdf0e10cSrcweir                 xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
81cdf0e10cSrcweir             o_aColumnList.push_back( ColumnInfo(*pEntries,sLabel) );
82cdf0e10cSrcweir             if ( sLabel.getLength() )
83cdf0e10cSrcweir                 _rListBox.InsertEntry( sLabel );
84cdf0e10cSrcweir             else
85cdf0e10cSrcweir                 _rListBox.InsertEntry( *pEntries );
86cdf0e10cSrcweir         }
87cdf0e10cSrcweir     }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir typedef ::svt::EditBrowseBox OFieldExpressionControl_Base;
90cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1< container::XContainerListener > TContainerListenerBase;
91cdf0e10cSrcweir class OFieldExpressionControl : public TContainerListenerBase
92cdf0e10cSrcweir                                ,public OFieldExpressionControl_Base
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     ::osl::Mutex                    m_aMutex;
95cdf0e10cSrcweir     ::std::vector<sal_Int32>        m_aGroupPositions;
96cdf0e10cSrcweir     ::std::vector<ColumnInfo>       m_aColumnInfo;
97cdf0e10cSrcweir     ::svt::ComboBoxControl*         m_pComboCell;
98cdf0e10cSrcweir     sal_Int32                       m_nDataPos;
99cdf0e10cSrcweir     sal_Int32                       m_nCurrentPos;
100cdf0e10cSrcweir     sal_uLong                           m_nPasteEvent;
101cdf0e10cSrcweir     sal_uLong                           m_nDeleteEvent;
102cdf0e10cSrcweir     OGroupsSortingDialog*           m_pParent;
103cdf0e10cSrcweir     bool                            m_bIgnoreEvent;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     void fillListBox(const uno::Reference< beans::XPropertySet>& _xDest,long nRow,sal_uInt16 nColumnId);
107cdf0e10cSrcweir     sal_Bool SaveModified(bool _bAppend);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     OFieldExpressionControl(const OFieldExpressionControl&); // NO COPY
110cdf0e10cSrcweir     void operator =(const OFieldExpressionControl&);         // NO ASSIGN
111cdf0e10cSrcweir public:
112cdf0e10cSrcweir     OFieldExpressionControl( OGroupsSortingDialog* _pParent,const ResId& _rResId);
113cdf0e10cSrcweir     virtual ~OFieldExpressionControl();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     // XEventListener
116cdf0e10cSrcweir     virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
117cdf0e10cSrcweir     // XContainerListener
118cdf0e10cSrcweir     virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir     virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir     virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     void        fillColumns(const uno::Reference< container::XNameAccess>& _xColumns);
123cdf0e10cSrcweir     void        lateInit();
124cdf0e10cSrcweir     sal_Bool    IsDeleteAllowed( );
125cdf0e10cSrcweir     void        DeleteRows();
126cdf0e10cSrcweir     void        cut();
127cdf0e10cSrcweir     void        copy();
128cdf0e10cSrcweir     void        paste();
129cdf0e10cSrcweir 
getGroupPosition(sal_Int32 _nRow) const130cdf0e10cSrcweir     inline sal_Int32   getGroupPosition(sal_Int32 _nRow) const { return _nRow != BROWSER_ENDOFSELECTION ? m_aGroupPositions[_nRow] : sal_Int32(NO_GROUP); }
131cdf0e10cSrcweir 
getExpressionControl() const132cdf0e10cSrcweir     inline ::svt::ComboBoxControl*  getExpressionControl() const { return m_pComboCell; }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     /** returns the sequence with the selected groups
136cdf0e10cSrcweir     */
137cdf0e10cSrcweir     uno::Sequence<uno::Any> fillSelectedGroups();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     /** move groups given by _aGroups
140cdf0e10cSrcweir     */
141cdf0e10cSrcweir     void moveGroups(const uno::Sequence<uno::Any>& _aGroups,sal_Int32 _nRow,sal_Bool _bSelect = sal_True);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol);
144cdf0e10cSrcweir     using OFieldExpressionControl_Base::GetRowCount;
145cdf0e10cSrcweir protected:
146cdf0e10cSrcweir     virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol );
150cdf0e10cSrcweir     virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol );
151cdf0e10cSrcweir     virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const;
152cdf0e10cSrcweir     virtual sal_Bool SeekRow( long nRow );
153cdf0e10cSrcweir     virtual sal_Bool SaveModified();
154cdf0e10cSrcweir     virtual String GetCellText( long nRow, sal_uInt16 nColId ) const;
155cdf0e10cSrcweir     virtual RowStatus GetRowStatus(long nRow) const;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     virtual void KeyInput(const KeyEvent& rEvt);
158cdf0e10cSrcweir     virtual void Command( const CommandEvent& rEvt );
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     // D&D
161cdf0e10cSrcweir     virtual void     StartDrag( sal_Int8 nAction, const Point& rPosPixel );
162cdf0e10cSrcweir     virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt );
163cdf0e10cSrcweir     virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     using BrowseBox::AcceptDrop;
166cdf0e10cSrcweir     using BrowseBox::ExecuteDrop;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir private:
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     DECL_LINK( AsynchActivate, void* );
171cdf0e10cSrcweir     DECL_LINK( AsynchDeactivate, void* );
172cdf0e10cSrcweir     DECL_LINK( DelayedPaste, void* );
173cdf0e10cSrcweir     DECL_LINK( CBChangeHdl,ComboBox*);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     void InsertRows( long nRow );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir public:
178cdf0e10cSrcweir     DECL_LINK( DelayedDelete, void* );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir };
181cdf0e10cSrcweir //========================================================================
182cdf0e10cSrcweir // class OFieldExpressionControl
183cdf0e10cSrcweir //========================================================================
DBG_NAME(rpt_OFieldExpressionControl)184cdf0e10cSrcweir DBG_NAME( rpt_OFieldExpressionControl )
185cdf0e10cSrcweir //------------------------------------------------------------------------
186cdf0e10cSrcweir OFieldExpressionControl::OFieldExpressionControl( OGroupsSortingDialog* _pParent,const ResId& _rResId )
187cdf0e10cSrcweir     :EditBrowseBox( _pParent, _rResId,EBBF_NONE, WB_TABSTOP | BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_AUTOSIZE_LASTCOL |
188cdf0e10cSrcweir                                   BROWSER_KEEPSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL)
189cdf0e10cSrcweir     ,m_aGroupPositions(GROUPS_START_LEN,-1)
190cdf0e10cSrcweir     ,m_pComboCell(NULL)
191cdf0e10cSrcweir     ,m_nDataPos(-1)
192cdf0e10cSrcweir     ,m_nCurrentPos(-1)
193cdf0e10cSrcweir     ,m_nPasteEvent(0)
194cdf0e10cSrcweir     ,m_nDeleteEvent(0)
195cdf0e10cSrcweir     ,m_pParent(_pParent)
196cdf0e10cSrcweir     ,m_bIgnoreEvent(false)
197cdf0e10cSrcweir {
198cdf0e10cSrcweir     DBG_CTOR( rpt_OFieldExpressionControl,NULL);
199cdf0e10cSrcweir     SetBorderStyle(WINDOW_BORDER_MONO);
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir //------------------------------------------------------------------------
~OFieldExpressionControl()203cdf0e10cSrcweir OFieldExpressionControl::~OFieldExpressionControl()
204cdf0e10cSrcweir {
205cdf0e10cSrcweir     acquire();
206cdf0e10cSrcweir     uno::Reference< report::XGroups > xGroups = m_pParent->getGroups();
207cdf0e10cSrcweir     xGroups->removeContainerListener(this);
208cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
209cdf0e10cSrcweir     // delete events from queue
210cdf0e10cSrcweir     if( m_nPasteEvent )
211cdf0e10cSrcweir         Application::RemoveUserEvent( m_nPasteEvent );
212cdf0e10cSrcweir     if( m_nDeleteEvent )
213cdf0e10cSrcweir         Application::RemoveUserEvent( m_nDeleteEvent );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     delete m_pComboCell;
216cdf0e10cSrcweir     DBG_DTOR( rpt_OFieldExpressionControl,NULL);
217cdf0e10cSrcweir }
218cdf0e10cSrcweir //------------------------------------------------------------------------------
fillSelectedGroups()219cdf0e10cSrcweir uno::Sequence<uno::Any> OFieldExpressionControl::fillSelectedGroups()
220cdf0e10cSrcweir {
221cdf0e10cSrcweir     uno::Sequence<uno::Any> aList;
222cdf0e10cSrcweir     ::std::vector<uno::Any> vClipboardList;
223cdf0e10cSrcweir     vClipboardList.reserve(GetSelectRowCount());
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     uno::Reference<report::XGroups> xGroups = m_pParent->getGroups();
226cdf0e10cSrcweir     sal_Int32 nCount = xGroups->getCount();
227cdf0e10cSrcweir     if ( nCount >= 1 )
228cdf0e10cSrcweir     {
229cdf0e10cSrcweir         for( long nIndex=FirstSelectedRow(); nIndex >= 0 ; nIndex=NextSelectedRow() )
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir             try
232cdf0e10cSrcweir             {
233cdf0e10cSrcweir                 if ( m_aGroupPositions[nIndex] != NO_GROUP )
234cdf0e10cSrcweir                 {
235cdf0e10cSrcweir                     uno::Reference< report::XGroup> xOrgGroup(xGroups->getByIndex(m_aGroupPositions[nIndex]),uno::UNO_QUERY);
236cdf0e10cSrcweir                     /*uno::Reference< report::XGroup> xCopy = xGroups->createGroup();
237cdf0e10cSrcweir                     ::comphelper::copyProperties(xOrgGroup.get(),xCopy.get());*/
238cdf0e10cSrcweir                     vClipboardList.push_back( uno::makeAny(xOrgGroup) );
239cdf0e10cSrcweir                 }
240cdf0e10cSrcweir             }
241cdf0e10cSrcweir             catch(uno::Exception&)
242cdf0e10cSrcweir             {
243cdf0e10cSrcweir                 OSL_ENSURE(0,"Can not access group!");
244cdf0e10cSrcweir             }
245cdf0e10cSrcweir         }
246cdf0e10cSrcweir         if ( !vClipboardList.empty() )
247cdf0e10cSrcweir             aList = uno::Sequence< uno::Any >(&vClipboardList[0], vClipboardList.size());
248cdf0e10cSrcweir     } // if ( nCount > 1 )
249cdf0e10cSrcweir     return aList;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir //------------------------------------------------------------------------------
StartDrag(sal_Int8,const Point &)252cdf0e10cSrcweir void OFieldExpressionControl::StartDrag( sal_Int8 /*_nAction*/ , const Point& /*_rPosPixel*/ )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
255cdf0e10cSrcweir     if ( m_pParent && !m_pParent->isReadOnly( ) )
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         uno::Sequence<uno::Any> aClipboardList = fillSelectedGroups();
258cdf0e10cSrcweir 
259cdf0e10cSrcweir         if( aClipboardList.getLength() )
260cdf0e10cSrcweir         {
261cdf0e10cSrcweir             OGroupExchange* pData = new OGroupExchange(aClipboardList);
262cdf0e10cSrcweir             uno::Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
263cdf0e10cSrcweir             pData->StartDrag(this, DND_ACTION_MOVE );
264cdf0e10cSrcweir         } // if(!vClipboardList.empty())
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir }
267cdf0e10cSrcweir //------------------------------------------------------------------------------
AcceptDrop(const BrowserAcceptDropEvent & rEvt)268cdf0e10cSrcweir sal_Int8 OFieldExpressionControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
271cdf0e10cSrcweir     sal_Int8 nAction = DND_ACTION_NONE;
272cdf0e10cSrcweir     if ( IsEditing() )
273cdf0e10cSrcweir     {
274cdf0e10cSrcweir         sal_uInt16 nPos = m_pComboCell->GetSelectEntryPos();
275cdf0e10cSrcweir         if ( COMBOBOX_ENTRY_NOTFOUND != nPos || m_pComboCell->GetText().Len() )
276cdf0e10cSrcweir             SaveModified();
277cdf0e10cSrcweir         DeactivateCell();
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir     if ( IsDropFormatSupported( OGroupExchange::getReportGroupId() ) && m_pParent->getGroups()->getCount() > 1 && rEvt.GetWindow() == &GetDataWindow() )
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         nAction = DND_ACTION_MOVE;
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir     return nAction;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir //------------------------------------------------------------------------------
ExecuteDrop(const BrowserExecuteDropEvent & rEvt)286cdf0e10cSrcweir sal_Int8 OFieldExpressionControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
289cdf0e10cSrcweir     sal_Int8 nAction = DND_ACTION_NONE;
290cdf0e10cSrcweir     if ( IsDropFormatSupported( OGroupExchange::getReportGroupId() ) )
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         sal_Int32   nRow = GetRowAtYPosPixel(rEvt.maPosPixel.Y(), sal_False);
293cdf0e10cSrcweir         SetNoSelection();
294cdf0e10cSrcweir 
295cdf0e10cSrcweir         TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable );
296cdf0e10cSrcweir         uno::Any aDrop = aDropped.GetAny(OGroupExchange::getReportGroupId());
297cdf0e10cSrcweir         uno::Sequence< uno::Any > aGroups;
298cdf0e10cSrcweir         aDrop >>= aGroups;
299cdf0e10cSrcweir         if ( aGroups.getLength() )
300cdf0e10cSrcweir         {
301cdf0e10cSrcweir             moveGroups(aGroups,nRow);
302cdf0e10cSrcweir             nAction = DND_ACTION_MOVE;
303cdf0e10cSrcweir         }
304cdf0e10cSrcweir     }
305cdf0e10cSrcweir     return nAction;
306cdf0e10cSrcweir }
307cdf0e10cSrcweir //------------------------------------------------------------------------------
moveGroups(const uno::Sequence<uno::Any> & _aGroups,sal_Int32 _nRow,sal_Bool _bSelect)308cdf0e10cSrcweir void OFieldExpressionControl::moveGroups(const uno::Sequence<uno::Any>& _aGroups,sal_Int32 _nRow,sal_Bool _bSelect)
309cdf0e10cSrcweir {
310cdf0e10cSrcweir     if ( _aGroups.getLength() )
311cdf0e10cSrcweir     {
312cdf0e10cSrcweir         m_bIgnoreEvent = true;
313cdf0e10cSrcweir         {
314cdf0e10cSrcweir             sal_Int32 nRow = _nRow;
315cdf0e10cSrcweir             const String sUndoAction(ModuleRes(RID_STR_UNDO_MOVE_GROUP));
316cdf0e10cSrcweir             const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir             uno::Reference< report::XGroups> xGroups = m_pParent->getGroups();
319cdf0e10cSrcweir             const uno::Any* pIter = _aGroups.getConstArray();
320cdf0e10cSrcweir             const uno::Any* pEnd  = pIter + _aGroups.getLength();
321cdf0e10cSrcweir             for(;pIter != pEnd;++pIter)
322cdf0e10cSrcweir             {
323cdf0e10cSrcweir                 uno::Reference< report::XGroup> xGroup(*pIter,uno::UNO_QUERY);
324cdf0e10cSrcweir                 if ( xGroup.is() )
325cdf0e10cSrcweir                 {
326cdf0e10cSrcweir                     uno::Sequence< beans::PropertyValue > aArgs(1);
327cdf0e10cSrcweir                     aArgs[0].Name = PROPERTY_GROUP;
328cdf0e10cSrcweir                     aArgs[0].Value <<= xGroup;
329cdf0e10cSrcweir                     // we use this way to create undo actions
330cdf0e10cSrcweir                     m_pParent->m_pController->executeChecked(SID_GROUP_REMOVE,aArgs);
331cdf0e10cSrcweir                     aArgs.realloc(2);
332cdf0e10cSrcweir                     if ( nRow > xGroups->getCount() )
333cdf0e10cSrcweir                         nRow = xGroups->getCount();
334cdf0e10cSrcweir                     if ( _bSelect )
335cdf0e10cSrcweir                         SelectRow(nRow);
336cdf0e10cSrcweir                     aArgs[1].Name = PROPERTY_POSITIONY;
337cdf0e10cSrcweir                     aArgs[1].Value <<= nRow;
338cdf0e10cSrcweir                     m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs);
339cdf0e10cSrcweir                     ++nRow;
340cdf0e10cSrcweir                 }
341cdf0e10cSrcweir             } // for(;pIter != pEnd;++pIter)
342cdf0e10cSrcweir         }
343cdf0e10cSrcweir         m_bIgnoreEvent = false;
344cdf0e10cSrcweir         Invalidate();
345cdf0e10cSrcweir     } // if ( _aGroups.getLength() )
346cdf0e10cSrcweir }
347cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillColumns(const uno::Reference<container::XNameAccess> & _xColumns)348cdf0e10cSrcweir void OFieldExpressionControl::fillColumns(const uno::Reference< container::XNameAccess>& _xColumns)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir     m_pComboCell->Clear();
351cdf0e10cSrcweir     if ( _xColumns.is() )
352cdf0e10cSrcweir         lcl_addToList_throw(*m_pComboCell,m_aColumnInfo,_xColumns);
353cdf0e10cSrcweir }
354cdf0e10cSrcweir //------------------------------------------------------------------------------
lateInit()355cdf0e10cSrcweir void OFieldExpressionControl::lateInit()
356cdf0e10cSrcweir {
357cdf0e10cSrcweir     uno::Reference< report::XGroups > xGroups = m_pParent->getGroups();
358cdf0e10cSrcweir     sal_Int32 nGroupsCount = xGroups->getCount();
359cdf0e10cSrcweir     m_aGroupPositions.resize(::std::max<sal_Int32>(nGroupsCount,sal_Int32(GROUPS_START_LEN)),NO_GROUP);
360cdf0e10cSrcweir     ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin();
361cdf0e10cSrcweir     for (sal_Int32 i = 0; i < nGroupsCount; ++i,++aIter)
362cdf0e10cSrcweir         *aIter = i;
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     if ( ColCount() == 0 )
365cdf0e10cSrcweir     {
366cdf0e10cSrcweir         Font aFont( GetDataWindow().GetFont() );
367cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_NORMAL );
368cdf0e10cSrcweir         GetDataWindow().SetFont( aFont );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir         // Font fuer die Ueberschriften auf Light setzen
371cdf0e10cSrcweir         aFont = GetFont();
372cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_LIGHT );
373cdf0e10cSrcweir         SetFont(aFont);
374cdf0e10cSrcweir 
375cdf0e10cSrcweir         InsertHandleColumn(static_cast<sal_uInt16>(GetTextWidth('0') * 4)/*, sal_True */);
376cdf0e10cSrcweir         InsertDataColumn( FIELD_EXPRESSION, String(ModuleRes(STR_RPT_EXPRESSION)), 100);
377cdf0e10cSrcweir 
378cdf0e10cSrcweir         m_pComboCell = new ComboBoxControl( &GetDataWindow() );
379cdf0e10cSrcweir         m_pComboCell->SetSelectHdl(LINK(this,OFieldExpressionControl,CBChangeHdl));
380cdf0e10cSrcweir         m_pComboCell->SetHelpId(HID_RPT_FIELDEXPRESSION);
381cdf0e10cSrcweir 
382cdf0e10cSrcweir         Control* pControls[] = {m_pComboCell};
383cdf0e10cSrcweir         for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
384cdf0e10cSrcweir         {
385cdf0e10cSrcweir             pControls[i]->SetGetFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));
386cdf0e10cSrcweir             pControls[i]->SetLoseFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusLost));
387cdf0e10cSrcweir         }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir         //////////////////////////////////////////////////////////////////////
390cdf0e10cSrcweir         // set browse mode
391cdf0e10cSrcweir         BrowserMode nMode(BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION  | BROWSER_KEEPSELECTION |
392cdf0e10cSrcweir                           BROWSER_HLINESFULL | BROWSER_VLINESFULL       | BROWSER_AUTOSIZE_LASTCOL | BROWSER_AUTO_VSCROLL | BROWSER_AUTO_HSCROLL);
393cdf0e10cSrcweir         if( m_pParent->isReadOnly() )
394cdf0e10cSrcweir             nMode |= BROWSER_HIDECURSOR;
395cdf0e10cSrcweir         SetMode(nMode);
396cdf0e10cSrcweir         xGroups->addContainerListener(this);
397cdf0e10cSrcweir     }
398cdf0e10cSrcweir     else
399cdf0e10cSrcweir         // not the first call
400cdf0e10cSrcweir         RowRemoved(0, GetRowCount());
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     RowInserted(0, m_aGroupPositions.size(), sal_True);
403cdf0e10cSrcweir }
404cdf0e10cSrcweir // -----------------------------------------------------------------------------
405cdf0e10cSrcweir // -----------------------------------------------------------------------------
406cdf0e10cSrcweir IMPL_LINK( OFieldExpressionControl, CBChangeHdl, ComboBox*, /*pComboBox*/ )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     SaveModified();
411cdf0e10cSrcweir     return 0L;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OFieldExpressionControl,AsynchActivate,void *,EMPTYARG)414cdf0e10cSrcweir IMPL_LINK(OFieldExpressionControl, AsynchActivate, void*, EMPTYARG)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir     ActivateCell();
417cdf0e10cSrcweir     return 0L;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OFieldExpressionControl,AsynchDeactivate,void *,EMPTYARG)421cdf0e10cSrcweir IMPL_LINK(OFieldExpressionControl, AsynchDeactivate, void*, EMPTYARG)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     DeactivateCell();
424cdf0e10cSrcweir     return 0L;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir //------------------------------------------------------------------------------
IsTabAllowed(sal_Bool) const428cdf0e10cSrcweir sal_Bool OFieldExpressionControl::IsTabAllowed(sal_Bool /*bForward*/) const
429cdf0e10cSrcweir {
430cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
431cdf0e10cSrcweir     return sal_False;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir 
434cdf0e10cSrcweir //------------------------------------------------------------------------------
SaveModified()435cdf0e10cSrcweir sal_Bool OFieldExpressionControl::SaveModified()
436cdf0e10cSrcweir {
437cdf0e10cSrcweir     return SaveModified(true);
438cdf0e10cSrcweir }
439cdf0e10cSrcweir //------------------------------------------------------------------------------
SaveModified(bool _bAppendRow)440cdf0e10cSrcweir sal_Bool OFieldExpressionControl::SaveModified(bool _bAppendRow)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
443cdf0e10cSrcweir     sal_Int32 nRow = GetCurRow();
444cdf0e10cSrcweir     if ( nRow != BROWSER_ENDOFSELECTION )
445cdf0e10cSrcweir     {
446cdf0e10cSrcweir         sal_Bool bAppend = sal_False;
447cdf0e10cSrcweir         try
448cdf0e10cSrcweir         {
449cdf0e10cSrcweir             uno::Reference< report::XGroup> xGroup;
450cdf0e10cSrcweir             if ( m_aGroupPositions[nRow] == NO_GROUP )
451cdf0e10cSrcweir             {
452cdf0e10cSrcweir                 bAppend = sal_True;
453cdf0e10cSrcweir                 String sUndoAction(ModuleRes(RID_STR_UNDO_APPEND_GROUP));
454cdf0e10cSrcweir                 m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, String() );
455cdf0e10cSrcweir                 xGroup = m_pParent->getGroups()->createGroup();
456cdf0e10cSrcweir                 xGroup->setHeaderOn(sal_True);
457cdf0e10cSrcweir 
458cdf0e10cSrcweir                 uno::Sequence< beans::PropertyValue > aArgs(2);
459cdf0e10cSrcweir                 aArgs[0].Name = PROPERTY_GROUP;
460cdf0e10cSrcweir                 aArgs[0].Value <<= xGroup;
461cdf0e10cSrcweir                 // find position where to insert the new group
462cdf0e10cSrcweir                 sal_Int32 nGroupPos = 0;
463cdf0e10cSrcweir                 ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin();
464cdf0e10cSrcweir                 ::std::vector<sal_Int32>::iterator aEnd  = m_aGroupPositions.begin() + nRow;
465cdf0e10cSrcweir                 for(;aIter != aEnd;++aIter)
466cdf0e10cSrcweir                     if ( *aIter != NO_GROUP )
467cdf0e10cSrcweir                         nGroupPos = *aIter + 1;
468cdf0e10cSrcweir                 aArgs[1].Name = PROPERTY_POSITIONY;
469cdf0e10cSrcweir                 aArgs[1].Value <<= nGroupPos;
470cdf0e10cSrcweir                 m_bIgnoreEvent = true;
471cdf0e10cSrcweir                 m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs);
472cdf0e10cSrcweir                 m_bIgnoreEvent = false;
473cdf0e10cSrcweir                 OSL_ENSURE(*aIter == NO_GROUP ,"Illegal iterator!");
474cdf0e10cSrcweir                 *aIter++ = nGroupPos;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir                 aEnd  = m_aGroupPositions.end();
477cdf0e10cSrcweir                 for(;aIter != aEnd;++aIter)
478cdf0e10cSrcweir                     if ( *aIter != NO_GROUP )
479cdf0e10cSrcweir                         ++*aIter;
480cdf0e10cSrcweir             }
481cdf0e10cSrcweir             else
482cdf0e10cSrcweir                 xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
483cdf0e10cSrcweir             if ( xGroup.is() )
484cdf0e10cSrcweir             {
485cdf0e10cSrcweir                 sal_uInt16 nPos = m_pComboCell->GetSelectEntryPos();
486cdf0e10cSrcweir                 ::rtl::OUString sExpression;
487cdf0e10cSrcweir                 if ( COMBOBOX_ENTRY_NOTFOUND == nPos )
488cdf0e10cSrcweir                     sExpression = m_pComboCell->GetText();
489cdf0e10cSrcweir                 else
490cdf0e10cSrcweir                 {
491cdf0e10cSrcweir                     sExpression = m_aColumnInfo[nPos].sColumnName;
492cdf0e10cSrcweir                 }
493cdf0e10cSrcweir                 xGroup->setExpression( sExpression );
494cdf0e10cSrcweir 
495cdf0e10cSrcweir                 ::rptui::adjustSectionName(xGroup,nPos);
496cdf0e10cSrcweir 
497cdf0e10cSrcweir                 if ( bAppend )
498cdf0e10cSrcweir                     m_pParent->m_pController->getUndoManager().LeaveListAction();
499cdf0e10cSrcweir             }
500cdf0e10cSrcweir 
501cdf0e10cSrcweir             if ( Controller() )
502cdf0e10cSrcweir                 Controller()->ClearModified();
503cdf0e10cSrcweir             if ( _bAppendRow && GetRowCount() == m_pParent->getGroups()->getCount() )
504cdf0e10cSrcweir             {
505cdf0e10cSrcweir                 RowInserted( GetRowCount()-1);
506cdf0e10cSrcweir                 m_aGroupPositions.push_back(NO_GROUP);
507cdf0e10cSrcweir             }
508cdf0e10cSrcweir 
509cdf0e10cSrcweir             GoToRow(nRow);
510cdf0e10cSrcweir             m_pParent->DisplayData(nRow);
511cdf0e10cSrcweir         }
512cdf0e10cSrcweir         catch(uno::Exception&)
513cdf0e10cSrcweir         {
514cdf0e10cSrcweir             OSL_ENSURE(0,"OFieldExpressionControl::SaveModified: Exception caught!");
515cdf0e10cSrcweir         }
516cdf0e10cSrcweir     }
517cdf0e10cSrcweir 
518cdf0e10cSrcweir     return sal_True;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir //------------------------------------------------------------------------------
GetCellText(long nRow,sal_uInt16) const521cdf0e10cSrcweir String OFieldExpressionControl::GetCellText( long nRow, sal_uInt16 /*nColId*/ ) const
522cdf0e10cSrcweir {
523cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
524cdf0e10cSrcweir     String sText;
525cdf0e10cSrcweir     if ( nRow != BROWSER_ENDOFSELECTION && m_aGroupPositions[nRow] != NO_GROUP )
526cdf0e10cSrcweir     {
527cdf0e10cSrcweir         try
528cdf0e10cSrcweir         {
529cdf0e10cSrcweir             uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
530cdf0e10cSrcweir             ::rtl::OUString sExpression = xGroup->getExpression();
531cdf0e10cSrcweir 
532cdf0e10cSrcweir             for(::std::vector<ColumnInfo>::const_iterator aIter = m_aColumnInfo.begin(); aIter != m_aColumnInfo.end();++aIter)
533cdf0e10cSrcweir             {
534cdf0e10cSrcweir                 if ( aIter->sColumnName == sExpression )
535cdf0e10cSrcweir                 {
536cdf0e10cSrcweir                     if ( aIter->sLabel.getLength() )
537cdf0e10cSrcweir                         sExpression = aIter->sLabel;
538cdf0e10cSrcweir                     break;
539cdf0e10cSrcweir                 }
540cdf0e10cSrcweir             }
541cdf0e10cSrcweir             sText  = sExpression;
542cdf0e10cSrcweir         }
543cdf0e10cSrcweir         catch(uno::Exception&)
544cdf0e10cSrcweir         {
545cdf0e10cSrcweir             OSL_ENSURE(0,"Exception caught while getting expression value from the group");
546cdf0e10cSrcweir         }
547cdf0e10cSrcweir     } // if ( nRow != BROWSER_ENDOFSELECTION && nRow < m_pParent->getGroups()->getCount() )
548cdf0e10cSrcweir     return sText;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir //------------------------------------------------------------------------------
InitController(CellControllerRef &,long nRow,sal_uInt16 nColumnId)552cdf0e10cSrcweir void OFieldExpressionControl::InitController( CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColumnId )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
555cdf0e10cSrcweir 
556cdf0e10cSrcweir     m_pComboCell->SetText( GetCellText( nRow, nColumnId ) );
557cdf0e10cSrcweir }
558cdf0e10cSrcweir //------------------------------------------------------------------------------
CursorMoving(long nNewRow,sal_uInt16 nNewCol)559cdf0e10cSrcweir sal_Bool OFieldExpressionControl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     if (!EditBrowseBox::CursorMoving(nNewRow, nNewCol))
564cdf0e10cSrcweir         return sal_False;
565cdf0e10cSrcweir     m_nDataPos = nNewRow;
566cdf0e10cSrcweir     long nOldDataPos = GetCurRow();
567cdf0e10cSrcweir     InvalidateStatusCell( m_nDataPos );
568cdf0e10cSrcweir     InvalidateStatusCell( nOldDataPos );
569cdf0e10cSrcweir 
570cdf0e10cSrcweir     m_pParent->SaveData( nOldDataPos );
571cdf0e10cSrcweir     m_pParent->DisplayData( m_nDataPos );
572cdf0e10cSrcweir     return sal_True;
573cdf0e10cSrcweir }
574cdf0e10cSrcweir //------------------------------------------------------------------------------
GetController(long,sal_uInt16)575cdf0e10cSrcweir CellController* OFieldExpressionControl::GetController( long /*nRow*/, sal_uInt16 /*nColumnId*/ )
576cdf0e10cSrcweir {
577cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
578cdf0e10cSrcweir     ComboBoxCellController* pCellController = new ComboBoxCellController( m_pComboCell );
579cdf0e10cSrcweir     pCellController->GetComboBox().SetReadOnly(!m_pParent->m_pController->isEditable());
580cdf0e10cSrcweir     return pCellController;
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir //------------------------------------------------------------------------------
SeekRow(long _nRow)584cdf0e10cSrcweir sal_Bool OFieldExpressionControl::SeekRow( long _nRow )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
587cdf0e10cSrcweir     // die Basisklasse braucht den Aufruf, da sie sich dort merkt, welche Zeile gepainted wird
588cdf0e10cSrcweir     EditBrowseBox::SeekRow(_nRow);
589cdf0e10cSrcweir     m_nCurrentPos = _nRow;
590cdf0e10cSrcweir     return sal_True;
591cdf0e10cSrcweir }
592cdf0e10cSrcweir 
593cdf0e10cSrcweir //------------------------------------------------------------------------------
PaintCell(OutputDevice & rDev,const Rectangle & rRect,sal_uInt16 nColumnId) const594cdf0e10cSrcweir void OFieldExpressionControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
595cdf0e10cSrcweir {
596cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
597cdf0e10cSrcweir     String aText  =const_cast< OFieldExpressionControl*>(this)->GetCellText( m_nCurrentPos, nColumnId );
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     Point aPos( rRect.TopLeft() );
600cdf0e10cSrcweir     Size aTextSize( GetDataWindow().GetTextHeight(),GetDataWindow().GetTextWidth( aText ));
601cdf0e10cSrcweir 
602cdf0e10cSrcweir     if( aPos.X() < rRect.Right() || aPos.X() + aTextSize.Width() > rRect.Right() ||
603cdf0e10cSrcweir         aPos.Y() < rRect.Top() || aPos.Y() + aTextSize.Height() > rRect.Bottom() )
604cdf0e10cSrcweir         rDev.SetClipRegion( rRect );
605cdf0e10cSrcweir 
606cdf0e10cSrcweir     rDev.DrawText( aPos, aText );
607cdf0e10cSrcweir 
608cdf0e10cSrcweir     if( rDev.IsClipRegion() )
609cdf0e10cSrcweir         rDev.SetClipRegion();
610cdf0e10cSrcweir }
611cdf0e10cSrcweir //------------------------------------------------------------------------------
GetRowStatus(long nRow) const612cdf0e10cSrcweir EditBrowseBox::RowStatus OFieldExpressionControl::GetRowStatus(long nRow) const
613cdf0e10cSrcweir {
614cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
615cdf0e10cSrcweir     if (nRow >= 0 && nRow == m_nDataPos)
616cdf0e10cSrcweir         return EditBrowseBox::CURRENT;
617cdf0e10cSrcweir     if ( nRow != BROWSER_ENDOFSELECTION && nRow < static_cast<long>(m_aGroupPositions.size()) && m_aGroupPositions[nRow] != NO_GROUP )
618cdf0e10cSrcweir     {
619cdf0e10cSrcweir         try
620cdf0e10cSrcweir         {
621cdf0e10cSrcweir             uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
622cdf0e10cSrcweir             return (xGroup->getHeaderOn() || xGroup->getFooterOn())? EditBrowseBox::HEADERFOOTER : EditBrowseBox::CLEAN;
623cdf0e10cSrcweir         }
624cdf0e10cSrcweir         catch(uno::Exception&)
625cdf0e10cSrcweir         {
626cdf0e10cSrcweir             OSL_ENSURE(0,"Exception cathced while try to get a group!");
627cdf0e10cSrcweir         }
628cdf0e10cSrcweir     }
629cdf0e10cSrcweir     return EditBrowseBox::CLEAN;
630cdf0e10cSrcweir }
631cdf0e10cSrcweir //  XEventListener
632cdf0e10cSrcweir //------------------------------------------------------------------------------
disposing(const lang::EventObject &)633cdf0e10cSrcweir void SAL_CALL OFieldExpressionControl::disposing(const lang::EventObject& /*e*/) throw( uno::RuntimeException )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir }
636cdf0e10cSrcweir //------------------------------------------------------------------------------
637cdf0e10cSrcweir // XContainerListener
638cdf0e10cSrcweir //------------------------------------------------------------------------------
elementInserted(const container::ContainerEvent & evt)639cdf0e10cSrcweir void SAL_CALL OFieldExpressionControl::elementInserted(const container::ContainerEvent& evt) throw(uno::RuntimeException)
640cdf0e10cSrcweir {
641cdf0e10cSrcweir     if ( m_bIgnoreEvent )
642cdf0e10cSrcweir         return;
643cdf0e10cSrcweir     ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() );
644cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
645cdf0e10cSrcweir     sal_Int32 nGroupPos = 0;
646cdf0e10cSrcweir     if ( evt.Accessor >>= nGroupPos )
647cdf0e10cSrcweir     {
648cdf0e10cSrcweir         if ( nGroupPos >= GetRowCount() )
649cdf0e10cSrcweir         {
650cdf0e10cSrcweir             sal_Int32 nAddedRows = nGroupPos - GetRowCount();
651cdf0e10cSrcweir             RowInserted(nAddedRows);
652cdf0e10cSrcweir             for (sal_Int32 i = 0; i < nAddedRows; ++i)
653cdf0e10cSrcweir                 m_aGroupPositions.push_back(NO_GROUP);
654cdf0e10cSrcweir             m_aGroupPositions[nGroupPos] = nGroupPos;
655cdf0e10cSrcweir         }
656cdf0e10cSrcweir         else
657cdf0e10cSrcweir         {
658cdf0e10cSrcweir             ::std::vector<sal_Int32>::iterator aFind = m_aGroupPositions.begin()+ nGroupPos;
659cdf0e10cSrcweir             if ( aFind == m_aGroupPositions.end() )
660cdf0e10cSrcweir                 aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),NO_GROUP);
661cdf0e10cSrcweir 
662cdf0e10cSrcweir             if ( aFind != m_aGroupPositions.end() )
663cdf0e10cSrcweir             {
664cdf0e10cSrcweir                 if ( *aFind != NO_GROUP )
665cdf0e10cSrcweir                     aFind = m_aGroupPositions.insert(aFind,nGroupPos);
666cdf0e10cSrcweir                 else
667cdf0e10cSrcweir                     *aFind = nGroupPos;
668cdf0e10cSrcweir 
669cdf0e10cSrcweir                 ::std::vector<sal_Int32>::iterator aEnd  = m_aGroupPositions.end();
670cdf0e10cSrcweir                 for(++aFind;aFind != aEnd;++aFind)
671cdf0e10cSrcweir                     if ( *aFind != NO_GROUP )
672cdf0e10cSrcweir                         ++*aFind;
673cdf0e10cSrcweir 
674cdf0e10cSrcweir                 //::std::vector<sal_Int32>::reverse_iterator aRIter = m_aGroupPositions.rbegin();
675cdf0e10cSrcweir                 //::std::vector<sal_Int32>::reverse_iterator aREnd = m_aGroupPositions.rend();
676cdf0e10cSrcweir                 //for (; aRIter != aREnd && *aRIter != NO_GROUP; ++aRIter)
677cdf0e10cSrcweir                 //    continue;
678cdf0e10cSrcweir                 //if ( aRIter != aREnd )
679cdf0e10cSrcweir                 //    m_aGroupPositions.erase(m_aGroupPositions.begin() + (m_aGroupPositions.size() - 1 - (aRIter - m_aGroupPositions.rbegin())));
680cdf0e10cSrcweir             }
681cdf0e10cSrcweir         }
682cdf0e10cSrcweir         Invalidate();
683cdf0e10cSrcweir     }
684cdf0e10cSrcweir }
685cdf0e10cSrcweir //------------------------------------------------------------------------------
elementReplaced(const container::ContainerEvent &)686cdf0e10cSrcweir void SAL_CALL OFieldExpressionControl::elementReplaced(const container::ContainerEvent& /*evt*/) throw(uno::RuntimeException)
687cdf0e10cSrcweir {
688cdf0e10cSrcweir }
689cdf0e10cSrcweir //------------------------------------------------------------------------------
elementRemoved(const container::ContainerEvent & evt)690cdf0e10cSrcweir void SAL_CALL OFieldExpressionControl::elementRemoved(const container::ContainerEvent& evt) throw(uno::RuntimeException)
691cdf0e10cSrcweir {
692cdf0e10cSrcweir     ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() );
693cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
694cdf0e10cSrcweir 
695cdf0e10cSrcweir     if ( m_bIgnoreEvent )
696cdf0e10cSrcweir         return;
697cdf0e10cSrcweir 
698cdf0e10cSrcweir     sal_Int32 nGroupPos = 0;
699cdf0e10cSrcweir     if ( evt.Accessor >>= nGroupPos )
700cdf0e10cSrcweir     {
701cdf0e10cSrcweir         ::std::vector<sal_Int32>::iterator aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),nGroupPos);
702cdf0e10cSrcweir         if ( aFind != m_aGroupPositions.end() )
703cdf0e10cSrcweir         {
704cdf0e10cSrcweir             *aFind = NO_GROUP;
705cdf0e10cSrcweir             ::std::vector<sal_Int32>::iterator aEnd  = m_aGroupPositions.end();
706cdf0e10cSrcweir             for(++aFind;aFind != aEnd;++aFind)
707cdf0e10cSrcweir                 if ( *aFind != NO_GROUP )
708cdf0e10cSrcweir                     --*aFind;
709cdf0e10cSrcweir             //PaintCell(*this,GetFieldRect(FIELD_EXPRESSION),FIELD_EXPRESSION);
710cdf0e10cSrcweir             Invalidate();
711cdf0e10cSrcweir         }
712cdf0e10cSrcweir     }
713cdf0e10cSrcweir }
714cdf0e10cSrcweir //------------------------------------------------------------------------------
IsDeleteAllowed()715cdf0e10cSrcweir sal_Bool OFieldExpressionControl::IsDeleteAllowed( )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir     return !m_pParent->isReadOnly() && GetSelectRowCount() > 0;
718cdf0e10cSrcweir }
719cdf0e10cSrcweir //------------------------------------------------------------------------
KeyInput(const KeyEvent & rEvt)720cdf0e10cSrcweir void OFieldExpressionControl::KeyInput( const KeyEvent& rEvt )
721cdf0e10cSrcweir {
722cdf0e10cSrcweir     if (IsDeleteAllowed())
723cdf0e10cSrcweir     {
724cdf0e10cSrcweir         if (rEvt.GetKeyCode().GetCode() == KEY_DELETE &&    // Delete rows
725cdf0e10cSrcweir             !rEvt.GetKeyCode().IsShift() &&
726cdf0e10cSrcweir             !rEvt.GetKeyCode().IsMod1())
727cdf0e10cSrcweir         {
728cdf0e10cSrcweir             DeleteRows();
729cdf0e10cSrcweir             return;
730cdf0e10cSrcweir         }
731cdf0e10cSrcweir     }
732cdf0e10cSrcweir     EditBrowseBox::KeyInput(rEvt);
733cdf0e10cSrcweir }
734cdf0e10cSrcweir //------------------------------------------------------------------------
Command(const CommandEvent & rEvt)735cdf0e10cSrcweir void OFieldExpressionControl::Command(const CommandEvent& rEvt)
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     switch (rEvt.GetCommand())
738cdf0e10cSrcweir     {
739cdf0e10cSrcweir         case COMMAND_CONTEXTMENU:
740cdf0e10cSrcweir         {
741cdf0e10cSrcweir             if (!rEvt.IsMouseEvent())
742cdf0e10cSrcweir             {
743cdf0e10cSrcweir                 EditBrowseBox::Command(rEvt);
744cdf0e10cSrcweir                 return;
745cdf0e10cSrcweir             }
746cdf0e10cSrcweir 
747cdf0e10cSrcweir             sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
748cdf0e10cSrcweir 
749cdf0e10cSrcweir             if ( nColId == HANDLE_ID )
750cdf0e10cSrcweir             {
751cdf0e10cSrcweir                 //long   nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
752cdf0e10cSrcweir                 PopupMenu aContextMenu(ModuleRes(RID_GROUPSROWPOPUPMENU));
753cdf0e10cSrcweir                 sal_Bool bEnable = sal_False;
754cdf0e10cSrcweir                 long nIndex = FirstSelectedRow();
755cdf0e10cSrcweir                 while( nIndex >= 0 && !bEnable )
756cdf0e10cSrcweir                 {
757cdf0e10cSrcweir                     if ( m_aGroupPositions[nIndex] != NO_GROUP )
758cdf0e10cSrcweir                         bEnable = sal_True;
759cdf0e10cSrcweir                     nIndex = NextSelectedRow();
760cdf0e10cSrcweir                 }
761cdf0e10cSrcweir                 //aContextMenu.EnableItem( SID_CUT, IsDeleteAllowed() && bEnable);
762cdf0e10cSrcweir                 //aContextMenu.EnableItem( SID_COPY, bEnable);
763cdf0e10cSrcweir                 //TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
764cdf0e10cSrcweir                 //aContextMenu.EnableItem( SID_PASTE, aTransferData.HasFormat(SOT_FORMATSTR_ID_RPT_GRPED) );
765cdf0e10cSrcweir                 aContextMenu.EnableItem( SID_DELETE, IsDeleteAllowed() && bEnable );
766cdf0e10cSrcweir                 switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
767cdf0e10cSrcweir                 {
768cdf0e10cSrcweir                     case SID_CUT:
769cdf0e10cSrcweir                         cut();
770cdf0e10cSrcweir                         break;
771cdf0e10cSrcweir                     case SID_COPY:
772cdf0e10cSrcweir                         copy();
773cdf0e10cSrcweir                         break;
774cdf0e10cSrcweir                     case SID_PASTE:
775cdf0e10cSrcweir                         paste();
776cdf0e10cSrcweir                         break;
777cdf0e10cSrcweir 
778cdf0e10cSrcweir                     case SID_DELETE:
779cdf0e10cSrcweir                         if( m_nDeleteEvent )
780cdf0e10cSrcweir                             Application::RemoveUserEvent( m_nDeleteEvent );
781cdf0e10cSrcweir                         m_nDeleteEvent = Application::PostUserEvent( LINK(this, OFieldExpressionControl, DelayedDelete) );
782cdf0e10cSrcweir                         break;
783cdf0e10cSrcweir                     default:
784cdf0e10cSrcweir                         break;
785cdf0e10cSrcweir                 }
786cdf0e10cSrcweir             } // if ( nColId == HANDLE_ID )
787cdf0e10cSrcweir             // run through
788cdf0e10cSrcweir         }
789cdf0e10cSrcweir         default:
790cdf0e10cSrcweir             EditBrowseBox::Command(rEvt);
791cdf0e10cSrcweir     }
792cdf0e10cSrcweir 
793cdf0e10cSrcweir }
794cdf0e10cSrcweir //------------------------------------------------------------------------------
DeleteRows()795cdf0e10cSrcweir void OFieldExpressionControl::DeleteRows()
796cdf0e10cSrcweir {
797cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     sal_Bool bIsEditing = IsEditing();
800cdf0e10cSrcweir     if (bIsEditing)
801cdf0e10cSrcweir     {
802cdf0e10cSrcweir         DeactivateCell();
803cdf0e10cSrcweir     }
804cdf0e10cSrcweir     long nIndex = FirstSelectedRow();
805cdf0e10cSrcweir     if (nIndex == -1)
806cdf0e10cSrcweir     {
807cdf0e10cSrcweir         nIndex = GetCurRow();
808cdf0e10cSrcweir     }
809cdf0e10cSrcweir     bool bFirstTime = true;
810cdf0e10cSrcweir 
811cdf0e10cSrcweir     long nOldDataPos = nIndex;
812cdf0e10cSrcweir     uno::Sequence< beans::PropertyValue > aArgs(1);
813cdf0e10cSrcweir     aArgs[0].Name = PROPERTY_GROUP;
814cdf0e10cSrcweir     m_bIgnoreEvent = true;
815cdf0e10cSrcweir     while( nIndex >= 0 )
816cdf0e10cSrcweir     {
817cdf0e10cSrcweir         if ( m_aGroupPositions[nIndex] != NO_GROUP )
818cdf0e10cSrcweir         {
819cdf0e10cSrcweir             if ( bFirstTime )
820cdf0e10cSrcweir             {
821cdf0e10cSrcweir                 bFirstTime = false;
822cdf0e10cSrcweir                 String sUndoAction(ModuleRes(RID_STR_UNDO_REMOVE_SELECTION));
823cdf0e10cSrcweir                 m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, String() );
824cdf0e10cSrcweir             }
825cdf0e10cSrcweir 
826cdf0e10cSrcweir             sal_Int32 nGroupPos = m_aGroupPositions[nIndex];
827cdf0e10cSrcweir             uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(nGroupPos);
828cdf0e10cSrcweir             aArgs[0].Value <<= xGroup;
829cdf0e10cSrcweir             // we use this way to create undo actions
830cdf0e10cSrcweir             m_pParent->m_pController->executeChecked(SID_GROUP_REMOVE,aArgs);
831cdf0e10cSrcweir 
832cdf0e10cSrcweir             ::std::vector<sal_Int32>::iterator aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),nGroupPos);
833cdf0e10cSrcweir             *aFind = NO_GROUP;
834cdf0e10cSrcweir             ::std::vector<sal_Int32>::iterator aEnd  = m_aGroupPositions.end();
835cdf0e10cSrcweir             for(++aFind;aFind != aEnd;++aFind)
836cdf0e10cSrcweir                 if ( *aFind != NO_GROUP )
837cdf0e10cSrcweir                     --*aFind;
838cdf0e10cSrcweir         }
839cdf0e10cSrcweir         nIndex = NextSelectedRow();
840cdf0e10cSrcweir     } // while( nIndex >= 0 )
841cdf0e10cSrcweir 
842cdf0e10cSrcweir     if ( !bFirstTime )
843cdf0e10cSrcweir         m_pParent->m_pController->getUndoManager().LeaveListAction();
844cdf0e10cSrcweir 
845cdf0e10cSrcweir     m_nDataPos = GetCurRow();
846cdf0e10cSrcweir     InvalidateStatusCell( nOldDataPos );
847cdf0e10cSrcweir     InvalidateStatusCell( m_nDataPos );
848cdf0e10cSrcweir     ActivateCell();
849cdf0e10cSrcweir     m_pParent->DisplayData( m_nDataPos );
850cdf0e10cSrcweir     m_bIgnoreEvent = false;
851cdf0e10cSrcweir     Invalidate();
852cdf0e10cSrcweir }
853cdf0e10cSrcweir //------------------------------------------------------------------------------
854cdf0e10cSrcweir //------------------------------------------------------------------------------
cut()855cdf0e10cSrcweir void OFieldExpressionControl::cut()
856cdf0e10cSrcweir {
857cdf0e10cSrcweir     copy();
858cdf0e10cSrcweir     DeleteRows();
859cdf0e10cSrcweir }
860cdf0e10cSrcweir 
861cdf0e10cSrcweir //------------------------------------------------------------------------------
copy()862cdf0e10cSrcweir void OFieldExpressionControl::copy()
863cdf0e10cSrcweir {
864cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
865cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
866cdf0e10cSrcweir     // set to the right row and save it
867cdf0e10cSrcweir     m_pParent->SaveData( m_nDataPos );
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     uno::Sequence<uno::Any> aClipboardList = fillSelectedGroups();
870cdf0e10cSrcweir 
871cdf0e10cSrcweir     if( aClipboardList.getLength() )
872cdf0e10cSrcweir     {
873cdf0e10cSrcweir         OGroupExchange* pData = new OGroupExchange(aClipboardList);
874cdf0e10cSrcweir         uno::Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
875cdf0e10cSrcweir         pData->CopyToClipboard(GetParent());
876cdf0e10cSrcweir     }
877cdf0e10cSrcweir }
878cdf0e10cSrcweir 
879cdf0e10cSrcweir //------------------------------------------------------------------------------
paste()880cdf0e10cSrcweir void OFieldExpressionControl::paste()
881cdf0e10cSrcweir {
882cdf0e10cSrcweir     TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
883cdf0e10cSrcweir     if(aTransferData.HasFormat(OGroupExchange::getReportGroupId()))
884cdf0e10cSrcweir     {
885cdf0e10cSrcweir         if( m_nPasteEvent )
886cdf0e10cSrcweir             Application::RemoveUserEvent( m_nPasteEvent );
887cdf0e10cSrcweir         m_nPasteEvent = Application::PostUserEvent( LINK(this, OFieldExpressionControl, DelayedPaste) );
888cdf0e10cSrcweir     }
889cdf0e10cSrcweir }
890cdf0e10cSrcweir //------------------------------------------------------------------------------
891cdf0e10cSrcweir IMPL_LINK( OFieldExpressionControl, DelayedPaste, void*,  )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir     m_nPasteEvent = 0;
894cdf0e10cSrcweir 
895cdf0e10cSrcweir     sal_Int32 nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : GetCurRow();
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     InsertRows( nPastePosition );
898cdf0e10cSrcweir     SetNoSelection();
899cdf0e10cSrcweir     GoToRow( nPastePosition );
900cdf0e10cSrcweir 
901cdf0e10cSrcweir     return 0;
902cdf0e10cSrcweir }
903cdf0e10cSrcweir //------------------------------------------------------------------------------
904cdf0e10cSrcweir IMPL_LINK( OFieldExpressionControl, DelayedDelete, void*,  )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir     m_nDeleteEvent = 0;
907cdf0e10cSrcweir     DeleteRows();
908cdf0e10cSrcweir     return 0;
909cdf0e10cSrcweir }
910cdf0e10cSrcweir //------------------------------------------------------------------------------
InsertRows(long nRow)911cdf0e10cSrcweir void OFieldExpressionControl::InsertRows( long nRow )
912cdf0e10cSrcweir {
913cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
914cdf0e10cSrcweir 
915cdf0e10cSrcweir     sal_Int32 nSize = 0;
916cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////
917cdf0e10cSrcweir     // get rows from clipboard
918cdf0e10cSrcweir     TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
919cdf0e10cSrcweir     if(aTransferData.HasFormat(OGroupExchange::getReportGroupId()))
920cdf0e10cSrcweir     {
921cdf0e10cSrcweir         datatransfer::DataFlavor aFlavor;
922cdf0e10cSrcweir         SotExchange::GetFormatDataFlavor(OGroupExchange::getReportGroupId(), aFlavor);
923cdf0e10cSrcweir         uno::Sequence< uno::Any > aGroups;
924cdf0e10cSrcweir 
925cdf0e10cSrcweir         if( (aTransferData.GetAny(aFlavor) >>= aGroups) && aGroups.getLength() )
926cdf0e10cSrcweir         {
927cdf0e10cSrcweir             m_bIgnoreEvent = false;
928cdf0e10cSrcweir             {
929cdf0e10cSrcweir                 const String sUndoAction(ModuleRes(RID_STR_UNDO_APPEND_GROUP));
930cdf0e10cSrcweir                 const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction );
931cdf0e10cSrcweir 
932cdf0e10cSrcweir                 uno::Reference<report::XGroups> xGroups = m_pParent->getGroups();
933cdf0e10cSrcweir                 sal_Int32 nGroupPos = 0;
934cdf0e10cSrcweir                 ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin();
935cdf0e10cSrcweir                 ::std::vector<sal_Int32>::size_type nRowPos = static_cast< ::std::vector<sal_Int32>::size_type >(nRow);
936cdf0e10cSrcweir                 if ( nRowPos < m_aGroupPositions.size() )
937cdf0e10cSrcweir                 {
938cdf0e10cSrcweir                     ::std::vector<sal_Int32>::iterator aEnd  = m_aGroupPositions.begin() + nRowPos;
939cdf0e10cSrcweir                     for(;aIter != aEnd;++aIter)
940cdf0e10cSrcweir                     {
941cdf0e10cSrcweir                         if ( *aIter != NO_GROUP )
942cdf0e10cSrcweir                             nGroupPos = *aIter;
943cdf0e10cSrcweir                     }
944cdf0e10cSrcweir                 }
945cdf0e10cSrcweir                 for(sal_Int32 i=0;i < aGroups.getLength();++i,++nSize)
946cdf0e10cSrcweir                 {
947cdf0e10cSrcweir                     uno::Sequence< beans::PropertyValue > aArgs(2);
948cdf0e10cSrcweir                     aArgs[0].Name = PROPERTY_GROUP;
949cdf0e10cSrcweir                     aArgs[0].Value = aGroups[i];
950cdf0e10cSrcweir                     aArgs[1].Name = PROPERTY_POSITIONY;
951cdf0e10cSrcweir                     aArgs[1].Value <<= nGroupPos;
952cdf0e10cSrcweir                     m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs);
953cdf0e10cSrcweir 
954cdf0e10cSrcweir                     ::std::vector<sal_Int32>::iterator aInsertPos = m_aGroupPositions.insert(aIter,nGroupPos);
955cdf0e10cSrcweir                     ++aInsertPos;
956cdf0e10cSrcweir                     aIter = aInsertPos;
957cdf0e10cSrcweir                     ::std::vector<sal_Int32>::iterator aEnd  = m_aGroupPositions.end();
958cdf0e10cSrcweir                     for(;aInsertPos != aEnd;++aInsertPos)
959cdf0e10cSrcweir                         if ( *aInsertPos != NO_GROUP )
960cdf0e10cSrcweir                             ++*aInsertPos;
961cdf0e10cSrcweir                 }
962cdf0e10cSrcweir             }
963cdf0e10cSrcweir             m_bIgnoreEvent = true;
964cdf0e10cSrcweir         }
965cdf0e10cSrcweir     }
966cdf0e10cSrcweir 
967cdf0e10cSrcweir     RowInserted( nRow,nSize,sal_True );
968cdf0e10cSrcweir }
969cdf0e10cSrcweir //------------------------------------------------------------------------------
970cdf0e10cSrcweir 
DBG_NAME(rpt_OGroupsSortingDialog)971cdf0e10cSrcweir DBG_NAME( rpt_OGroupsSortingDialog )
972cdf0e10cSrcweir //========================================================================
973cdf0e10cSrcweir // class OGroupsSortingDialog
974cdf0e10cSrcweir //========================================================================
975cdf0e10cSrcweir OGroupsSortingDialog::OGroupsSortingDialog( Window* _pParent
976cdf0e10cSrcweir                                            ,sal_Bool _bReadOnly
977cdf0e10cSrcweir                                            ,OReportController* _pController)
978cdf0e10cSrcweir     : FloatingWindow( _pParent, ModuleRes(RID_GROUPS_SORTING) )
979cdf0e10cSrcweir     ,OPropertyChangeListener(m_aMutex)
980cdf0e10cSrcweir     ,m_aFL2(this, ModuleRes(FL_SEPARATOR2) )
981cdf0e10cSrcweir     ,m_aMove(this, ModuleRes(FT_MOVELABEL) )
982cdf0e10cSrcweir /*
983cdf0e10cSrcweir     ,m_aPB_Up(this, ModuleRes(PB_UP) )
984cdf0e10cSrcweir     ,m_aPB_Down(this, ModuleRes(PB_DOWN) )
985cdf0e10cSrcweir     ,m_aPB_Delete(this, ModuleRes(PB_DELETE) )
986cdf0e10cSrcweir */
987cdf0e10cSrcweir     ,m_aToolBox(this, ModuleRes(TB_TOOLBOX) )
988cdf0e10cSrcweir 
989cdf0e10cSrcweir     ,m_aFL3(this, ModuleRes(FL_SEPARATOR3) )
990cdf0e10cSrcweir     ,m_aOrder(this, ModuleRes(FT_ORDER) )
991cdf0e10cSrcweir     ,m_aOrderLst(this, ModuleRes(LST_ORDER) )
992cdf0e10cSrcweir     ,m_aHeader(this, ModuleRes(FT_HEADER) )
993cdf0e10cSrcweir     ,m_aHeaderLst(this, ModuleRes(LST_HEADERLST) )
994cdf0e10cSrcweir     ,m_aFooter(this, ModuleRes(FT_FOOTER) )
995cdf0e10cSrcweir     ,m_aFooterLst(this, ModuleRes(LST_FOOTERLST) )
996cdf0e10cSrcweir     ,m_aGroupOn(this, ModuleRes(FT_GROUPON) )
997cdf0e10cSrcweir     ,m_aGroupOnLst(this, ModuleRes(LST_GROUPONLST) )
998cdf0e10cSrcweir     ,m_aGroupInterval(this, ModuleRes(FT_GROUPINTERVAL) )
999cdf0e10cSrcweir     ,m_aGroupIntervalEd(this, ModuleRes(ED_GROUPINTERVALLST) )
1000cdf0e10cSrcweir     ,m_aKeepTogether(this, ModuleRes(FT_KEEPTOGETHER) )
1001cdf0e10cSrcweir     ,m_aKeepTogetherLst(this, ModuleRes(LST_KEEPTOGETHERLST) )
1002cdf0e10cSrcweir     ,m_aFL(this, ModuleRes(FL_SEPARATOR1) )
1003cdf0e10cSrcweir     ,m_aHelpWindow(this, ModuleRes(HELP_FIELD) )
1004cdf0e10cSrcweir     ,m_pFieldExpression( new OFieldExpressionControl(this,ModuleRes(WND_CONTROL)))
1005cdf0e10cSrcweir     ,m_pController(_pController)
1006cdf0e10cSrcweir     ,m_pCurrentGroupListener(NULL)
1007cdf0e10cSrcweir     ,m_xGroups(m_pController->getReportDefinition()->getGroups())
1008cdf0e10cSrcweir     ,m_bReadOnly(_bReadOnly)
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir     DBG_CTOR( rpt_OGroupsSortingDialog,NULL);
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir     Control* pControlsLst[] = { &m_aHeaderLst, &m_aFooterLst, &m_aGroupOnLst, &m_aKeepTogetherLst, &m_aOrderLst, &m_aGroupIntervalEd};
1014cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControlsLst)/sizeof(pControlsLst[0]); ++i)
1015cdf0e10cSrcweir     {
1016cdf0e10cSrcweir         pControlsLst[i]->SetGetFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusGot));
1017cdf0e10cSrcweir         pControlsLst[i]->SetLoseFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusLost));
1018cdf0e10cSrcweir         pControlsLst[i]->Show(sal_True);
1019cdf0e10cSrcweir     } // for (int i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir     for (size_t i = 0; i < (sizeof(pControlsLst)/sizeof(pControlsLst[0]))-1; ++i)
1022cdf0e10cSrcweir         static_cast<ListBox*>(pControlsLst[i])->SetSelectHdl(LINK(this,OGroupsSortingDialog,LBChangeHdl));
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir     Control* pControls[]    = { &m_aHeader, &m_aFooter, &m_aGroupOn, &m_aGroupInterval, &m_aKeepTogether, &m_aOrder
1025cdf0e10cSrcweir                                 , &m_aMove,&m_aFL2};
1026cdf0e10cSrcweir     sal_Int32 nMaxTextWidth = 0;
1027cdf0e10cSrcweir     MnemonicGenerator aMnemonicGenerator;
1028cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1029cdf0e10cSrcweir         aMnemonicGenerator.RegisterMnemonic( pControls[i]->GetText() );
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1032cdf0e10cSrcweir     {
1033cdf0e10cSrcweir         pControls[i]->Show(sal_True);
1034cdf0e10cSrcweir         String sText = pControls[i]->GetText();
1035cdf0e10cSrcweir         if ( aMnemonicGenerator.CreateMnemonic(sText) )
1036cdf0e10cSrcweir             pControls[i]->SetText(sText);
1037cdf0e10cSrcweir         sal_Int32 nTextWidth = GetTextWidth(sText);
1038cdf0e10cSrcweir         nMaxTextWidth = ::std::max<sal_Int32>(nTextWidth,nMaxTextWidth);
1039cdf0e10cSrcweir     }
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir     Size aSize(UNRELATED_CONTROLS, PAGE_HEIGHT);
1042cdf0e10cSrcweir     Size aSpace = LogicToPixel( aSize, MAP_APPFONT );
1043cdf0e10cSrcweir     Size aOutSize(nMaxTextWidth + m_aHeader.GetSizePixel().Width() + 3*aSpace.Width(),aSpace.Height());
1044cdf0e10cSrcweir     SetMinOutputSizePixel(aOutSize);
1045cdf0e10cSrcweir     SetOutputSizePixel(aOutSize);
1046cdf0e10cSrcweir //  Resize();
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir     m_pReportListener = new OPropertyChangeMultiplexer(this,m_pController->getReportDefinition().get());
1049cdf0e10cSrcweir     m_pReportListener->addProperty(PROPERTY_COMMAND);
1050cdf0e10cSrcweir     m_pReportListener->addProperty(PROPERTY_COMMANDTYPE);
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir     m_pFieldExpression->lateInit();
1053cdf0e10cSrcweir     fillColumns();
1054cdf0e10cSrcweir     m_pFieldExpression->Show();
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir     //m_aHelpWindow.SetReadOnly();
1057cdf0e10cSrcweir     m_aHelpWindow.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
1058cdf0e10cSrcweir     //BTN m_aPB_Up.SetClickHdl(LINK(this,OGroupsSortingDialog,ClickHdl));
1059cdf0e10cSrcweir     //BTN m_aPB_Down.SetClickHdl(LINK(this,OGroupsSortingDialog,ClickHdl));
1060cdf0e10cSrcweir     //BTN m_aPB_Delete.SetClickHdl(LINK(this,OGroupsSortingDialog,ClickHdl));
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir     m_pFieldExpression->SetZOrder(&m_aFL2, WINDOW_ZORDER_BEHIND);
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir     m_aMove.SetZOrder(m_pFieldExpression, WINDOW_ZORDER_BEHIND);
1065cdf0e10cSrcweir     //BTN m_aPB_Up.SetZOrder(&m_aMove, WINDOW_ZORDER_BEHIND);
1066cdf0e10cSrcweir     //BTN m_aPB_Down.SetZOrder(&m_aPB_Up, WINDOW_ZORDER_BEHIND);
1067cdf0e10cSrcweir     // set Hi contrast bitmaps
1068cdf0e10cSrcweir     //BTN m_aPB_Up.SetModeImage(        ModuleRes(IMG_UP_H),BMP_COLOR_HIGHCONTRAST);
1069cdf0e10cSrcweir     //BTN m_aPB_Down.SetModeImage(  ModuleRes(IMG_DOWN_H),BMP_COLOR_HIGHCONTRAST);
1070cdf0e10cSrcweir     m_aToolBox.SetStyle(m_aToolBox.GetStyle()|WB_LINESPACING);
1071cdf0e10cSrcweir     m_aToolBox.SetSelectHdl(LINK(this, OGroupsSortingDialog, OnFormatAction));
1072cdf0e10cSrcweir     m_aToolBox.SetImageListProvider(this);
1073cdf0e10cSrcweir     setToolBox(&m_aToolBox);
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir     checkButtons(0);
1076cdf0e10cSrcweir     Resize();
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir     FreeResource();
1079cdf0e10cSrcweir }
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir //------------------------------------------------------------------------
~OGroupsSortingDialog()1082cdf0e10cSrcweir OGroupsSortingDialog::~OGroupsSortingDialog()
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir     DBG_DTOR( rpt_OGroupsSortingDialog,NULL);
1085cdf0e10cSrcweir     delete m_pFieldExpression;
1086cdf0e10cSrcweir     m_xColumns.clear();
1087cdf0e10cSrcweir     m_pReportListener->dispose();
1088cdf0e10cSrcweir     if ( m_pCurrentGroupListener.is() )
1089cdf0e10cSrcweir         m_pCurrentGroupListener->dispose();
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir // -----------------------------------------------------------------------------
isReadOnly() const1092cdf0e10cSrcweir sal_Bool OGroupsSortingDialog::isReadOnly( ) const
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir     return m_bReadOnly;
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir //------------------------------------------------------------------------------
UpdateData()1097cdf0e10cSrcweir void OGroupsSortingDialog::UpdateData( )
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir     m_pFieldExpression->Invalidate();
1100cdf0e10cSrcweir     long nCurRow = m_pFieldExpression->GetCurRow();
1101cdf0e10cSrcweir     m_pFieldExpression->DeactivateCell();
1102cdf0e10cSrcweir     m_pFieldExpression->ActivateCell(nCurRow, m_pFieldExpression->GetCurColumnId());
1103cdf0e10cSrcweir     DisplayData(nCurRow);
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir //------------------------------------------------------------------------------
DisplayData(sal_Int32 _nRow)1106cdf0e10cSrcweir void OGroupsSortingDialog::DisplayData( sal_Int32 _nRow )
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1109cdf0e10cSrcweir     sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
1110cdf0e10cSrcweir     sal_Bool bEmpty = nGroupPos == NO_GROUP;
1111cdf0e10cSrcweir     m_aHeaderLst.Enable(!bEmpty);
1112cdf0e10cSrcweir     m_aFooterLst.Enable(!bEmpty);
1113cdf0e10cSrcweir     m_aGroupOnLst.Enable(!bEmpty);
1114cdf0e10cSrcweir     m_aGroupIntervalEd.Enable(!bEmpty);
1115cdf0e10cSrcweir     m_aKeepTogetherLst.Enable(!bEmpty);
1116cdf0e10cSrcweir     m_aOrderLst.Enable(!bEmpty);
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir     m_aFL3.Enable(!bEmpty);
1119cdf0e10cSrcweir     m_aHeader.Enable(!bEmpty);
1120cdf0e10cSrcweir     m_aFooter.Enable(!bEmpty);
1121cdf0e10cSrcweir     m_aGroupOn.Enable(!bEmpty);
1122cdf0e10cSrcweir     m_aGroupInterval.Enable(!bEmpty);
1123cdf0e10cSrcweir     m_aKeepTogether.Enable(!bEmpty);
1124cdf0e10cSrcweir     m_aOrder.Enable(!bEmpty);
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir     checkButtons(_nRow);
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir     if ( m_pCurrentGroupListener.is() )
1129cdf0e10cSrcweir         m_pCurrentGroupListener->dispose();
1130cdf0e10cSrcweir     m_pCurrentGroupListener = NULL;
1131cdf0e10cSrcweir     if ( !bEmpty && nGroupPos != NO_GROUP )
1132cdf0e10cSrcweir     {
1133cdf0e10cSrcweir         uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir         m_pCurrentGroupListener = new OPropertyChangeMultiplexer(this,xGroup.get());
1136cdf0e10cSrcweir         m_pCurrentGroupListener->addProperty(PROPERTY_HEADERON);
1137cdf0e10cSrcweir         m_pCurrentGroupListener->addProperty(PROPERTY_FOOTERON);
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir         displayGroup(xGroup);
1140cdf0e10cSrcweir     }
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir //------------------------------------------------------------------------------
SaveData(sal_Int32 _nRow)1143cdf0e10cSrcweir void OGroupsSortingDialog::SaveData( sal_Int32 _nRow)
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1146cdf0e10cSrcweir     sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
1147cdf0e10cSrcweir     if ( nGroupPos == NO_GROUP )
1148cdf0e10cSrcweir         return;
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir     uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
1151cdf0e10cSrcweir     if ( m_aHeaderLst.GetSavedValue() != m_aHeaderLst.GetSelectEntryPos() )
1152cdf0e10cSrcweir         xGroup->setHeaderOn( m_aHeaderLst.GetSelectEntryPos() == 0 );
1153cdf0e10cSrcweir     if ( m_aFooterLst.GetSavedValue() != m_aFooterLst.GetSelectEntryPos() )
1154cdf0e10cSrcweir         xGroup->setFooterOn( m_aFooterLst.GetSelectEntryPos() == 0 );
1155cdf0e10cSrcweir     if ( m_aKeepTogetherLst.GetSavedValue() != m_aKeepTogetherLst.GetSelectEntryPos() )
1156cdf0e10cSrcweir         xGroup->setKeepTogether( m_aKeepTogetherLst.GetSelectEntryPos() );
1157cdf0e10cSrcweir     if ( m_aGroupOnLst.GetSavedValue() != m_aGroupOnLst.GetSelectEntryPos() )
1158cdf0e10cSrcweir     {
1159cdf0e10cSrcweir         sal_Int16 nGroupOn = static_cast<sal_Int16>(reinterpret_cast<sal_IntPtr>(m_aGroupOnLst.GetEntryData(m_aGroupOnLst.GetSelectEntryPos())));
1160cdf0e10cSrcweir         xGroup->setGroupOn( nGroupOn );
1161cdf0e10cSrcweir     }
1162cdf0e10cSrcweir     if ( m_aGroupIntervalEd.GetSavedValue().ToInt32() != m_aGroupIntervalEd.GetValue() )
1163cdf0e10cSrcweir     {
1164cdf0e10cSrcweir         xGroup->setGroupInterval( static_cast<sal_Int32>(m_aGroupIntervalEd.GetValue()) );
1165cdf0e10cSrcweir         m_aGroupIntervalEd.SaveValue();
1166cdf0e10cSrcweir     }
1167cdf0e10cSrcweir     if ( m_aOrderLst.GetSavedValue() != m_aOrderLst.GetSelectEntryPos() )
1168cdf0e10cSrcweir         xGroup->setSortAscending( m_aOrderLst.GetSelectEntryPos() == 0 );
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir     ListBox* pControls[] = { &m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aKeepTogetherLst,&m_aOrderLst};
1171cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1172cdf0e10cSrcweir         pControls[i]->SaveValue();
1173cdf0e10cSrcweir }
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir // -----------------------------------------------------------------------------
getColumnDataType(const::rtl::OUString & _sColumnName)1176cdf0e10cSrcweir sal_Int32 OGroupsSortingDialog::getColumnDataType(const ::rtl::OUString& _sColumnName)
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir     sal_Int32 nDataType = sdbc::DataType::VARCHAR;
1179cdf0e10cSrcweir     try
1180cdf0e10cSrcweir     {
1181cdf0e10cSrcweir         if ( !m_xColumns.is() )
1182cdf0e10cSrcweir             fillColumns();
1183cdf0e10cSrcweir         if ( m_xColumns.is() && m_xColumns->hasByName(_sColumnName) )
1184cdf0e10cSrcweir         {
1185cdf0e10cSrcweir             uno::Reference< beans::XPropertySet> xColumn(m_xColumns->getByName(_sColumnName),uno::UNO_QUERY);
1186cdf0e10cSrcweir             if ( xColumn.is() )
1187cdf0e10cSrcweir                 xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
1188cdf0e10cSrcweir         }
1189cdf0e10cSrcweir     }
1190cdf0e10cSrcweir     catch(uno::Exception&)
1191cdf0e10cSrcweir     {
1192*a8d869c0SJohn Bampton         OSL_ENSURE(0,"Exception caught while getting the type of a column");
1193cdf0e10cSrcweir     }
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir     return nDataType;
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OGroupsSortingDialog,OnControlFocusGot,Control *,pControl)1198cdf0e10cSrcweir IMPL_LINK(OGroupsSortingDialog, OnControlFocusGot, Control*, pControl )
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir     if ( m_pFieldExpression && m_pFieldExpression->getExpressionControl() )
1201cdf0e10cSrcweir     {
1202cdf0e10cSrcweir         Control* pControls[] = { m_pFieldExpression->getExpressionControl(),&m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aGroupIntervalEd,&m_aKeepTogetherLst,&m_aOrderLst};
1203cdf0e10cSrcweir         for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1204cdf0e10cSrcweir         {
1205cdf0e10cSrcweir             if ( pControl == pControls[i] )
1206cdf0e10cSrcweir             {
1207cdf0e10cSrcweir                 ListBox* pListBox = dynamic_cast< ListBox* >( pControl );
1208cdf0e10cSrcweir                 if ( pListBox )
1209cdf0e10cSrcweir                     pListBox->SaveValue();
1210cdf0e10cSrcweir                 NumericField* pNumericField = dynamic_cast< NumericField* >( pControl );
1211cdf0e10cSrcweir                 if ( pNumericField )
1212cdf0e10cSrcweir                     pNumericField->SaveValue();
1213cdf0e10cSrcweir                 showHelpText(static_cast<sal_uInt16>(i+STR_RPT_HELP_FIELD));
1214cdf0e10cSrcweir                 break;
1215cdf0e10cSrcweir             }
1216cdf0e10cSrcweir         }
1217cdf0e10cSrcweir     }
1218cdf0e10cSrcweir     return 0L;
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OGroupsSortingDialog,OnControlFocusLost,Control *,pControl)1221cdf0e10cSrcweir IMPL_LINK(OGroupsSortingDialog, OnControlFocusLost, Control*, pControl )
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir     if ( m_pFieldExpression && pControl == &m_aGroupIntervalEd )
1224cdf0e10cSrcweir     {
1225cdf0e10cSrcweir         if ( m_aGroupIntervalEd.IsModified() )
1226cdf0e10cSrcweir             SaveData(m_pFieldExpression->GetCurRow());
1227cdf0e10cSrcweir     }
1228cdf0e10cSrcweir     return 0L;
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir // -----------------------------------------------------------------------------
1231cdf0e10cSrcweir IMPL_LINK( OGroupsSortingDialog, OnFormatAction, ToolBox*, /*NOTINTERESTEDIN*/ )
1232cdf0e10cSrcweir // IMPL_LINK( OGroupsSortingDialog, ClickHdl, ImageButton*, _pButton )
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir     sal_uInt16 nCommand = m_aToolBox.GetCurItemId();
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir     if ( m_pFieldExpression )
1239cdf0e10cSrcweir     {
1240cdf0e10cSrcweir         long nIndex = m_pFieldExpression->GetCurrRow();
1241cdf0e10cSrcweir         sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(nIndex);
1242cdf0e10cSrcweir         uno::Sequence<uno::Any> aClipboardList;
1243cdf0e10cSrcweir         if ( nIndex >= 0 && nGroupPos != NO_GROUP )
1244cdf0e10cSrcweir         {
1245cdf0e10cSrcweir             aClipboardList.realloc(1);
1246cdf0e10cSrcweir             aClipboardList[0] = m_xGroups->getByIndex(nGroupPos);
1247cdf0e10cSrcweir         }
1248cdf0e10cSrcweir         //BTN if ( _pButton == &m_aPB_Up )
1249cdf0e10cSrcweir         if ( nCommand == SID_RPT_GROUPSORT_MOVE_UP )
1250cdf0e10cSrcweir         {
1251cdf0e10cSrcweir             --nIndex;
1252cdf0e10cSrcweir         }
1253cdf0e10cSrcweir         //BTN if ( _pButton == &m_aPB_Down )
1254cdf0e10cSrcweir         if ( nCommand == SID_RPT_GROUPSORT_MOVE_DOWN )
1255cdf0e10cSrcweir         {
1256cdf0e10cSrcweir             ++nIndex;
1257cdf0e10cSrcweir         }
1258cdf0e10cSrcweir         //BTN if ( _pButton == &m_aPB_Delete )
1259cdf0e10cSrcweir         if ( nCommand == SID_RPT_GROUPSORT_DELETE )
1260cdf0e10cSrcweir         {
1261cdf0e10cSrcweir             // m_pFieldExpression->DeleteCurrentRow();
1262cdf0e10cSrcweir             Application::PostUserEvent( LINK(m_pFieldExpression, OFieldExpressionControl, DelayedDelete) );
1263cdf0e10cSrcweir             // UpdateData( );
1264cdf0e10cSrcweir         }
1265cdf0e10cSrcweir         else
1266cdf0e10cSrcweir         {
1267cdf0e10cSrcweir             if ( nIndex >= 0 && aClipboardList.getLength() )
1268cdf0e10cSrcweir             {
1269cdf0e10cSrcweir                 m_pFieldExpression->SetNoSelection();
1270cdf0e10cSrcweir                 m_pFieldExpression->moveGroups(aClipboardList,nIndex,sal_False);
1271cdf0e10cSrcweir                 m_pFieldExpression->DeactivateCell();
1272cdf0e10cSrcweir                 m_pFieldExpression->GoToRow(nIndex);
1273cdf0e10cSrcweir                 //long nCurRow = m_pFieldExpression->GetCurRow();
1274cdf0e10cSrcweir                 m_pFieldExpression->ActivateCell(nIndex, m_pFieldExpression->GetCurColumnId());
1275cdf0e10cSrcweir                 DisplayData(nIndex);
1276cdf0e10cSrcweir             }
1277cdf0e10cSrcweir         }
1278cdf0e10cSrcweir     }
1279cdf0e10cSrcweir     return 1L;
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPL_LINK(OGroupsSortingDialog,LBChangeHdl,ListBox *,pListBox)1282cdf0e10cSrcweir IMPL_LINK( OGroupsSortingDialog, LBChangeHdl, ListBox*, pListBox )
1283cdf0e10cSrcweir {
1284cdf0e10cSrcweir     DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1285cdf0e10cSrcweir     if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() )
1286cdf0e10cSrcweir     {
1287cdf0e10cSrcweir         sal_Int32 nRow = m_pFieldExpression->GetCurRow();
1288cdf0e10cSrcweir         sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(nRow);
1289cdf0e10cSrcweir         if ( pListBox != &m_aHeaderLst && pListBox != &m_aFooterLst)
1290cdf0e10cSrcweir         {
1291cdf0e10cSrcweir             if ( pListBox && pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() )
1292cdf0e10cSrcweir                 SaveData(nRow);
1293cdf0e10cSrcweir             if ( pListBox == &m_aGroupOnLst )
1294cdf0e10cSrcweir                 m_aGroupIntervalEd.Enable( pListBox->GetSelectEntryPos() != 0 );
1295cdf0e10cSrcweir         }
1296cdf0e10cSrcweir         else if ( nGroupPos != NO_GROUP )
1297cdf0e10cSrcweir         {
1298cdf0e10cSrcweir             uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
1299cdf0e10cSrcweir             uno::Sequence< beans::PropertyValue > aArgs(2);
1300cdf0e10cSrcweir             aArgs[1].Name = PROPERTY_GROUP;
1301cdf0e10cSrcweir             aArgs[1].Value <<= xGroup;
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir             if ( &m_aHeaderLst  == pListBox )
1304cdf0e10cSrcweir                 aArgs[0].Name = PROPERTY_HEADERON;
1305cdf0e10cSrcweir             else
1306cdf0e10cSrcweir                 aArgs[0].Name = PROPERTY_FOOTERON;
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir             aArgs[0].Value <<= pListBox->GetSelectEntryPos() == 0;
1309cdf0e10cSrcweir             m_pController->executeChecked(&m_aHeaderLst  == pListBox ? SID_GROUPHEADER : SID_GROUPFOOTER,aArgs);
1310cdf0e10cSrcweir             if ( m_pFieldExpression )
1311cdf0e10cSrcweir                 m_pFieldExpression->InvalidateHandleColumn();
1312cdf0e10cSrcweir         }
1313cdf0e10cSrcweir     }
1314cdf0e10cSrcweir     return 1L;
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir // -----------------------------------------------------------------------------
showHelpText(sal_uInt16 _nResId)1317cdf0e10cSrcweir void OGroupsSortingDialog::showHelpText(sal_uInt16 _nResId)
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir     m_aHelpWindow.SetText(String(ModuleRes(_nResId)));
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir // -----------------------------------------------------------------------------
_propertyChanged(const beans::PropertyChangeEvent & _rEvent)1322cdf0e10cSrcweir void OGroupsSortingDialog::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException)
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir     uno::Reference< report::XGroup > xGroup(_rEvent.Source,uno::UNO_QUERY);
1325cdf0e10cSrcweir     if ( xGroup.is() )
1326cdf0e10cSrcweir         displayGroup(xGroup);
1327cdf0e10cSrcweir     else
1328cdf0e10cSrcweir         fillColumns();
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillColumns()1331cdf0e10cSrcweir void OGroupsSortingDialog::fillColumns()
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir     m_xColumns = m_pController->getColumns();
1334cdf0e10cSrcweir     m_pFieldExpression->fillColumns(m_xColumns);
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir // -----------------------------------------------------------------------------
displayGroup(const uno::Reference<report::XGroup> & _xGroup)1337cdf0e10cSrcweir void OGroupsSortingDialog::displayGroup(const uno::Reference<report::XGroup>& _xGroup)
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir     m_aHeaderLst.SelectEntryPos(_xGroup->getHeaderOn() ? 0 : 1 );
1340cdf0e10cSrcweir     m_aFooterLst.SelectEntryPos(_xGroup->getFooterOn() ? 0 : 1 );
1341cdf0e10cSrcweir     sal_Int32 nDataType = getColumnDataType(_xGroup->getExpression());
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir     // first clear whole group on list
1344cdf0e10cSrcweir     while(m_aGroupOnLst.GetEntryCount() > 1 )
1345cdf0e10cSrcweir     {
1346cdf0e10cSrcweir         m_aGroupOnLst.RemoveEntry(1);
1347cdf0e10cSrcweir     }
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir     switch(nDataType)
1350cdf0e10cSrcweir     {
1351cdf0e10cSrcweir         case sdbc::DataType::LONGVARCHAR:
1352cdf0e10cSrcweir         case sdbc::DataType::VARCHAR:
1353cdf0e10cSrcweir         case sdbc::DataType::CHAR:
1354cdf0e10cSrcweir             m_aGroupOnLst.InsertEntry(String(ModuleRes(STR_RPT_PREFIXCHARS)));
1355cdf0e10cSrcweir             m_aGroupOnLst.SetEntryData(1,reinterpret_cast<void*>(report::GroupOn::PREFIX_CHARACTERS));
1356cdf0e10cSrcweir             break;
1357cdf0e10cSrcweir         case sdbc::DataType::DATE:
1358cdf0e10cSrcweir         case sdbc::DataType::TIME:
1359cdf0e10cSrcweir         case sdbc::DataType::TIMESTAMP:
1360cdf0e10cSrcweir             {
1361cdf0e10cSrcweir                 sal_uInt16 nIds[] = { STR_RPT_YEAR, STR_RPT_QUARTER,STR_RPT_MONTH,STR_RPT_WEEK,STR_RPT_DAY,STR_RPT_HOUR,STR_RPT_MINUTE };
1362cdf0e10cSrcweir                 for (sal_uInt16 i = 0; i < sizeof(nIds)/sizeof(nIds[0]); ++i)
1363cdf0e10cSrcweir                 {
1364cdf0e10cSrcweir                     m_aGroupOnLst.InsertEntry(String(ModuleRes(nIds[i])));
1365cdf0e10cSrcweir                     m_aGroupOnLst.SetEntryData(i+1,reinterpret_cast<void*>(i+2));
1366cdf0e10cSrcweir                 }
1367cdf0e10cSrcweir             }
1368cdf0e10cSrcweir             break;
1369cdf0e10cSrcweir         default:
1370cdf0e10cSrcweir             m_aGroupOnLst.InsertEntry(String(ModuleRes(STR_RPT_INTERVAL)));
1371cdf0e10cSrcweir             m_aGroupOnLst.SetEntryData(1,reinterpret_cast<void*>(report::GroupOn::INTERVAL));
1372cdf0e10cSrcweir             break;
1373cdf0e10cSrcweir     } // switch(nDataType)
1374cdf0e10cSrcweir     sal_uInt16 nPos = 0;
1375cdf0e10cSrcweir     switch(_xGroup->getGroupOn())
1376cdf0e10cSrcweir     {
1377cdf0e10cSrcweir         case report::GroupOn::DEFAULT:
1378cdf0e10cSrcweir             nPos = 0;
1379cdf0e10cSrcweir             break;
1380cdf0e10cSrcweir         case report::GroupOn::PREFIX_CHARACTERS:
1381cdf0e10cSrcweir             nPos = 1;
1382cdf0e10cSrcweir             break;
1383cdf0e10cSrcweir         case report::GroupOn::YEAR:
1384cdf0e10cSrcweir             nPos = 1;
1385cdf0e10cSrcweir             break;
1386cdf0e10cSrcweir         case report::GroupOn::QUARTAL:
1387cdf0e10cSrcweir             nPos = 2;
1388cdf0e10cSrcweir             break;
1389cdf0e10cSrcweir         case report::GroupOn::MONTH:
1390cdf0e10cSrcweir             nPos = 3;
1391cdf0e10cSrcweir             break;
1392cdf0e10cSrcweir         case report::GroupOn::WEEK:
1393cdf0e10cSrcweir             nPos = 4;
1394cdf0e10cSrcweir             break;
1395cdf0e10cSrcweir         case report::GroupOn::DAY:
1396cdf0e10cSrcweir             nPos = 5;
1397cdf0e10cSrcweir             break;
1398cdf0e10cSrcweir         case report::GroupOn::HOUR:
1399cdf0e10cSrcweir             nPos = 6;
1400cdf0e10cSrcweir             break;
1401cdf0e10cSrcweir         case report::GroupOn::MINUTE:
1402cdf0e10cSrcweir             nPos = 7;
1403cdf0e10cSrcweir             break;
1404cdf0e10cSrcweir         case report::GroupOn::INTERVAL:
1405cdf0e10cSrcweir             nPos = 1;
1406cdf0e10cSrcweir             break;
1407cdf0e10cSrcweir         default:
1408cdf0e10cSrcweir             nPos = 0;
1409cdf0e10cSrcweir     }
1410cdf0e10cSrcweir     m_aGroupOnLst.SelectEntryPos(nPos);
1411cdf0e10cSrcweir     m_aGroupIntervalEd.SetText(String::CreateFromInt32(_xGroup->getGroupInterval()));
1412cdf0e10cSrcweir     m_aGroupIntervalEd.SaveValue();
1413cdf0e10cSrcweir     m_aGroupIntervalEd.Enable( nPos != 0 );
1414cdf0e10cSrcweir     m_aKeepTogetherLst.SelectEntryPos(_xGroup->getKeepTogether());
1415cdf0e10cSrcweir     m_aOrderLst.SelectEntryPos(_xGroup->getSortAscending() ? 0 : 1);
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir     ListBox* pControls[] = { &m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aKeepTogetherLst,&m_aOrderLst};
1418cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1419cdf0e10cSrcweir         pControls[i]->SaveValue();
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir     ListBox* pControlsLst2[] = { &m_aHeaderLst, &m_aFooterLst,  &m_aGroupOnLst, &m_aKeepTogetherLst,&m_aOrderLst};
1422cdf0e10cSrcweir     sal_Bool bReadOnly = !m_pController->isEditable();
1423cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControlsLst2)/sizeof(pControlsLst2[0]); ++i)
1424cdf0e10cSrcweir         pControlsLst2[i]->SetReadOnly(bReadOnly);
1425cdf0e10cSrcweir     m_aGroupIntervalEd.SetReadOnly(bReadOnly);
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir //------------------------------------------------------------------------------
Resize()1428cdf0e10cSrcweir void OGroupsSortingDialog::Resize()
1429cdf0e10cSrcweir {
1430cdf0e10cSrcweir     Window::Resize();
1431cdf0e10cSrcweir     Size aTotalOutputSize = GetOutputSizePixel();
1432cdf0e10cSrcweir     Size aSpace = LogicToPixel( Size( UNRELATED_CONTROLS, UNRELATED_CONTROLS ), MAP_APPFONT );
1433cdf0e10cSrcweir     m_pFieldExpression->SetSizePixel(Size(aTotalOutputSize.Width() - 2*aSpace.Width(),m_pFieldExpression->GetSizePixel().Height()));
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir     Control* pControlsLst[] = { &m_aHeaderLst,  &m_aFooterLst,  &m_aGroupOnLst, &m_aGroupIntervalEd,&m_aKeepTogetherLst,&m_aOrderLst};
1436cdf0e10cSrcweir     Control* pControls[]    = { &m_aHeader,     &m_aFooter,     &m_aGroupOn,    &m_aGroupInterval,  &m_aKeepTogether,   &m_aOrder};
1437cdf0e10cSrcweir     sal_Int32 nMaxTextWidth = 0;
1438cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1439cdf0e10cSrcweir     {
1440cdf0e10cSrcweir         nMaxTextWidth = ::std::max<sal_Int32>(static_cast<sal_Int32>(GetTextWidth(pControls[i]->GetText())),nMaxTextWidth);
1441cdf0e10cSrcweir     } // for (int i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir     // aTotalOutputSize.Width() - m_aHeaderLst.GetSizePixel().Width() - 3*aSpace.Width()
1444cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1445cdf0e10cSrcweir     {
1446cdf0e10cSrcweir         pControls[i]->SetSizePixel(Size(nMaxTextWidth,pControls[i]->GetSizePixel().Height()));
1447cdf0e10cSrcweir         Point aPos = pControls[i]->GetPosPixel();
1448cdf0e10cSrcweir         aPos.X() += nMaxTextWidth + aSpace.Width();
1449cdf0e10cSrcweir         aPos.Y() = pControlsLst[i]->GetPosPixel().Y();
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir         pControlsLst[i]->SetPosSizePixel(aPos,Size(aTotalOutputSize.Width() - aPos.X() - aSpace.Width(),pControlsLst[i]->GetSizePixel().Height()));
1452cdf0e10cSrcweir     } // for (int i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir     m_aFL.SetSizePixel(Size(aTotalOutputSize.Width() - aSpace.Width(),m_aFL.GetSizePixel().Height()));
1455cdf0e10cSrcweir     m_aFL2.SetSizePixel(Size(aTotalOutputSize.Width() - aSpace.Width(),m_aFL2.GetSizePixel().Height()));
1456cdf0e10cSrcweir     m_aFL3.SetSizePixel(Size(aTotalOutputSize.Width() - aSpace.Width(),m_aFL3.GetSizePixel().Height()));
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir //BTN   sal_Int32 nPos = aTotalOutputSize.Width() - aSpace.Width() - m_aPB_Up.GetSizePixel().Width();
1459cdf0e10cSrcweir //BTN   m_aPB_Delete.SetPosPixel(Point(nPos,m_aPB_Delete.GetPosPixel().Y()));
1460cdf0e10cSrcweir //BTN
1461cdf0e10cSrcweir //BTN   nPos -= (m_aPB_Up.GetSizePixel().Width() + LogicToPixel( Size( UNRELATED_CONTROLS, 0 ), MAP_APPFONT ).Width());
1462cdf0e10cSrcweir //BTN   m_aPB_Down.SetPosPixel(Point(nPos,m_aPB_Down.GetPosPixel().Y()));
1463cdf0e10cSrcweir //BTN
1464cdf0e10cSrcweir //BTN   nPos -= (m_aPB_Up.GetSizePixel().Width() + LogicToPixel( Size( RELATED_CONTROLS, 0 ), MAP_APPFONT ).Width());
1465cdf0e10cSrcweir //BTN   m_aPB_Up.SetPosPixel(Point(nPos,m_aPB_Up.GetPosPixel().Y()));
1466cdf0e10cSrcweir     sal_Int32 nPos = aTotalOutputSize.Width() - aSpace.Width() - m_aToolBox.GetSizePixel().Width();
1467cdf0e10cSrcweir     m_aToolBox.SetPosPixel(Point(nPos,m_aToolBox.GetPosPixel().Y()));
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir     Point aHelpPos = m_aHelpWindow.GetPosPixel();
1470cdf0e10cSrcweir     m_aHelpWindow.SetSizePixel(Size(aTotalOutputSize.Width() - aHelpPos.X(),aTotalOutputSize.Height() - aHelpPos.Y()));
1471cdf0e10cSrcweir }
1472cdf0e10cSrcweir //------------------------------------------------------------------------------
checkButtons(sal_Int32 _nRow)1473cdf0e10cSrcweir void OGroupsSortingDialog::checkButtons(sal_Int32 _nRow)
1474cdf0e10cSrcweir {
1475cdf0e10cSrcweir     sal_Int32 nGroupCount = m_xGroups->getCount();
1476cdf0e10cSrcweir     sal_Int32 nRowCount = m_pFieldExpression->GetRowCount();
1477cdf0e10cSrcweir     sal_Bool bEnabled = nGroupCount > 1;
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir     if (bEnabled && _nRow > 0 /* && _nRow < nGroupCount */ )
1480cdf0e10cSrcweir     {
1481cdf0e10cSrcweir         m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_UP, sal_True);
1482cdf0e10cSrcweir     }
1483cdf0e10cSrcweir     else
1484cdf0e10cSrcweir     {
1485cdf0e10cSrcweir         m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_UP, sal_False);
1486cdf0e10cSrcweir     }
1487cdf0e10cSrcweir     if (bEnabled && _nRow < (nRowCount - 1) /* && _nRow < (nGroupCount - 1) */ )
1488cdf0e10cSrcweir     {
1489cdf0e10cSrcweir         m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_DOWN, sal_True);
1490cdf0e10cSrcweir     }
1491cdf0e10cSrcweir     else
1492cdf0e10cSrcweir     {
1493cdf0e10cSrcweir         m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_DOWN, sal_False);
1494cdf0e10cSrcweir     }
1495cdf0e10cSrcweir     //BTN m_aPB_Up.Enable(bEnable && _nRow > 0 );
1496cdf0e10cSrcweir     //BTN m_aPB_Down.Enable(bEnable && _nRow < (m_pFieldExpression->GetRowCount()-1) );
1497cdf0e10cSrcweir     // m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_DOWN, bEnable && _nRow < (-1) );
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir     sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
1500cdf0e10cSrcweir     if ( nGroupPos != NO_GROUP )
1501cdf0e10cSrcweir     {
1502cdf0e10cSrcweir         sal_Bool bEnableDelete = nGroupCount > 0;
1503cdf0e10cSrcweir         //BTN m_aPB_Delete.Enable(bEnableDelete );
1504cdf0e10cSrcweir         m_aToolBox.EnableItem(SID_RPT_GROUPSORT_DELETE, bEnableDelete);
1505cdf0e10cSrcweir     }
1506cdf0e10cSrcweir     else
1507cdf0e10cSrcweir     {
1508cdf0e10cSrcweir         //BTN m_aPB_Delete.Enable( sal_False );
1509cdf0e10cSrcweir         m_aToolBox.EnableItem(SID_RPT_GROUPSORT_DELETE, sal_False);
1510cdf0e10cSrcweir     }
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir 
getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const1513cdf0e10cSrcweir ImageList OGroupsSortingDialog::getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir     sal_Int16 nN = IMG_CONDFORMAT_DLG_SC;
1516cdf0e10cSrcweir     sal_Int16 nH = IMG_CONDFORMAT_DLG_SCH;
1517cdf0e10cSrcweir     if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE )
1518cdf0e10cSrcweir     {
1519cdf0e10cSrcweir         nN = IMG_CONDFORMAT_DLG_LC;
1520cdf0e10cSrcweir         nH = IMG_CONDFORMAT_DLG_LCH;
1521cdf0e10cSrcweir     }
1522cdf0e10cSrcweir     return ImageList(ModuleRes( _bHiContast ? nH : nN ));
1523cdf0e10cSrcweir }
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir //------------------------------------------------------------------
resizeControls(const Size & _rDiff)1526cdf0e10cSrcweir void OGroupsSortingDialog::resizeControls(const Size& _rDiff)
1527cdf0e10cSrcweir {
1528cdf0e10cSrcweir     // we use large images so we must change them
1529cdf0e10cSrcweir     if ( _rDiff.Width() || _rDiff.Height() )
1530cdf0e10cSrcweir     {
1531cdf0e10cSrcweir         Point aPos = LogicToPixel( Point( 2*RELATED_CONTROLS , 0), MAP_APPFONT );
1532cdf0e10cSrcweir         Invalidate();
1533cdf0e10cSrcweir     }
1534cdf0e10cSrcweir }
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir //------------------------------------------------------------------
1537cdf0e10cSrcweir // load the images
getImageList(vcl::ImageListType _eType)1538cdf0e10cSrcweir ImageList OGroupsSortingDialog::getImageList(vcl::ImageListType _eType) SAL_THROW (( com::sun::star::lang::IllegalArgumentException ))
1539cdf0e10cSrcweir {
1540cdf0e10cSrcweir     if (_eType == vcl::HIGHCONTRAST_NO)
1541cdf0e10cSrcweir     {
1542cdf0e10cSrcweir         return ImageList(ModuleRes(IMGLST_GROUPSORT_DLG_SC));
1543cdf0e10cSrcweir     }
1544cdf0e10cSrcweir     else if (_eType == vcl::HIGHCONTRAST_YES)
1545cdf0e10cSrcweir     {
1546cdf0e10cSrcweir         return ImageList(ModuleRes(IMGLST_GROUPSORT_DLG_SCH));
1547cdf0e10cSrcweir     }
1548cdf0e10cSrcweir     else
1549cdf0e10cSrcweir     {
1550cdf0e10cSrcweir         throw com::sun::star::lang::IllegalArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("High contrast parameter is wrong.")), NULL, 0);
1551cdf0e10cSrcweir     }
1552cdf0e10cSrcweir }
1553cdf0e10cSrcweir 
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir 
1556cdf0e10cSrcweir // =============================================================================
1557cdf0e10cSrcweir } // rptui
1558cdf0e10cSrcweir // =============================================================================
1559