diff options
Diffstat (limited to 'reportdesign/source/ui/report')
20 files changed, 13657 insertions, 0 deletions
diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx new file mode 100644 index 000000000000..37a67f99eb63 --- /dev/null +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -0,0 +1,787 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#include "DesignView.hxx" +#include <tools/debug.hxx> +#include "ReportController.hxx" +#include <comphelper/types.hxx> +#include <unotools/syslocale.hxx> +#include <unotools/viewoptions.hxx> +#include "RptDef.hxx" +#include "UITools.hxx" +#include "RptObject.hxx" +#include "propbrw.hxx" +#include <toolkit/helper/convert.hxx> +#include "helpids.hrc" +#include "SectionView.hxx" +#include "ReportSection.hxx" +#include "rptui_slotid.hrc" +#include <svx/svxids.hrc> +#include "AddField.hxx" +#include "ScrollHelper.hxx" +#include "Navigator.hxx" +#include "SectionWindow.hxx" +#include "RptResId.hrc" +#include <vcl/svapp.hxx> + +namespace rptui +{ +using namespace ::dbaui; +using namespace ::utl; +using namespace ::com::sun::star; +using namespace uno; +using namespace lang; +using namespace beans; +using namespace container; + +#define LINE_SIZE 50 +#define START_SIZE_TASKPANE 30 +#define COLSET_ID 1 +#define REPORT_ID 2 +#define TASKPANE_ID 3 + +class OTaskWindow : public Window +{ + PropBrw* m_pPropWin; +public: + OTaskWindow(Window* _pParent) : Window(_pParent),m_pPropWin(NULL){} + + inline void setPropertyBrowser(PropBrw* _pPropWin) + { + m_pPropWin = _pPropWin; + } + + virtual void Resize() + { + const Size aSize = GetOutputSizePixel(); + if ( m_pPropWin && aSize.Height() && aSize.Width() ) + m_pPropWin->SetSizePixel(aSize); + } + long getMinimumWidth() const + { + long nRet = 0; + if ( m_pPropWin ) + nRet = m_pPropWin->getMinimumSize().Width(); + return nRet; + } +}; +class OwnSplitWindow : public SplitWindow +{ +public: + OwnSplitWindow(Window* pParent) : SplitWindow(pParent,WB_DIALOGCONTROL){SetBackground( );} + + virtual void Split() + { + SplitWindow::Split(); + setItemSizes(); + } + void setItemSizes() + { + const long nOutWidth = GetOutputSizePixel().Width(); + long nTaskPaneMinSplitSize = static_cast<OTaskWindow*>(GetItemWindow(TASKPANE_ID))->getMinimumWidth(); + nTaskPaneMinSplitSize = static_cast<long>(nTaskPaneMinSplitSize*100/nOutWidth); + if ( !nTaskPaneMinSplitSize ) + nTaskPaneMinSplitSize = START_SIZE_TASKPANE; + + const long nReportMinSplitSize = static_cast<long>(12000/nOutWidth); + + long nReportSize = GetItemSize( REPORT_ID ); + long nTaskPaneSize = GetItemSize( TASKPANE_ID ); + + BOOL bMod = FALSE; + if( nReportSize < nReportMinSplitSize ) + { + nReportSize = nReportMinSplitSize; + nTaskPaneSize = 99 - nReportMinSplitSize; + + bMod = TRUE; + } + else if( nTaskPaneSize < nTaskPaneMinSplitSize ) + { + nTaskPaneSize = nTaskPaneMinSplitSize; + nReportSize = 99 - nTaskPaneMinSplitSize; + + bMod = TRUE; + } + + if( bMod ) + { + SetItemSize( REPORT_ID, nReportSize ); + SetItemSize( TASKPANE_ID, nTaskPaneSize ); + } + } +}; +//================================================================== +// class ODesignView +//================================================================== +DBG_NAME( rpt_ODesignView ) +//------------------------------------------------------------------------------ +ODesignView::ODesignView( Window* pParent, + const Reference< XMultiServiceFactory >& _rxOrb, + OReportController& _rController) : + ODataView( pParent, _rController, _rxOrb, WB_DIALOGCONTROL ) + ,m_aSplitWin(this) + ,m_rReportController( _rController ) + ,m_aScrollWindow(this) + ,m_pPropWin(NULL) + ,m_pAddField(NULL) + ,m_pCurrentView(NULL) + ,m_pReportExplorer(NULL) + ,m_eMode( RPTUI_SELECT ) + ,m_nCurrentPosition(USHRT_MAX) + ,m_eActObj( OBJ_NONE ) + ,m_bFirstDraw(FALSE) + ,m_aGridSizeCoarse( 1000, 1000 ) // #i93595# 100TH_MM changed to grid using coarse 1 cm grid + ,m_aGridSizeFine( 250, 250 ) // and a 0,25 cm subdivision for better visualisation + ,m_bGridVisible(TRUE) + ,m_bGridSnap(TRUE) + ,m_bDeleted( FALSE ) +{ + DBG_CTOR( rpt_ODesignView,NULL); + SetHelpId(UID_RPT_RPT_APP_VIEW); + ImplInitSettings(); + + SetMapMode( MapMode( MAP_100TH_MM ) ); + + // now create the task pane on the right side :-) + m_pTaskPane = new OTaskWindow(this); + //m_pTaskPane->Show(); + + m_aSplitWin.InsertItem( COLSET_ID,100,SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE | SWIB_COLSET ); + m_aSplitWin.InsertItem( REPORT_ID, &m_aScrollWindow, 100/*m_aScrollWindow.getMaxMarkerWidth(sal_False)*/, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE /*SWIB_COLSET*/); + //m_aSplitWin.InsertItem( TASKPANE_ID, m_pTaskPane, 50, SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE ); + + // Splitter einrichten + //m_aSplitter.SetSplitHdl(LINK(this, ODesignView,SplitHdl)); + m_aSplitWin.SetSplitHdl(LINK(this, ODesignView,SplitHdl)); + m_aSplitWin.ShowAutoHideButton(); + m_aSplitWin.SetAlign(WINDOWALIGN_LEFT); + m_aSplitWin.Show(); + + m_aMarkTimer.SetTimeout( 100 ); + m_aMarkTimer.SetTimeoutHdl( LINK( this, ODesignView, MarkTimeout ) ); +} + +//------------------------------------------------------------------------------ +ODesignView::~ODesignView() +{ + DBG_DTOR( rpt_ODesignView,NULL); + m_bDeleted = TRUE; + Hide(); + m_aScrollWindow.Hide(); + m_aMarkTimer.Stop(); + if ( m_pPropWin ) + { + notifySystemWindow(this,m_pPropWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); + ::std::auto_ptr<Window> aTemp2(m_pPropWin); + m_pPropWin = NULL; + } + if ( m_pAddField ) + { + SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( UID_RPT_RPT_APP_VIEW ) ); + aDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( m_pAddField->GetWindowState(WINDOWSTATE_MASK_ALL).GetBuffer() ) ); + notifySystemWindow(this,m_pAddField,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); + ::std::auto_ptr<Window> aTemp2(m_pAddField); + m_pAddField = NULL; + } + if ( m_pReportExplorer ) + { + SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_NAVIGATOR ) ); + aDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( m_pReportExplorer->GetWindowState(WINDOWSTATE_MASK_ALL).GetBuffer() ) ); + notifySystemWindow(this,m_pReportExplorer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); + ::std::auto_ptr<Window> aTemp2(m_pReportExplorer); + m_pReportExplorer = NULL; + } + { + ::std::auto_ptr<Window> aTemp2(m_pTaskPane); + m_pTaskPane = NULL; + } +} +// ----------------------------------------------------------------------------- +void ODesignView::initialize() +{ + SetMapMode( MapMode( MAP_100TH_MM ) ); + m_aScrollWindow.initialize(); + m_aScrollWindow.Show(); +} +//----------------------------------------------------------------------------- +void ODesignView::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ODataView::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + ImplInitSettings(); + Invalidate(); + } +} +//------------------------------------------------------------------------------ +long ODesignView::PreNotify( NotifyEvent& rNEvt ) +{ + long nRet = ODataView::PreNotify(rNEvt); // 1 := has to be handled here + switch(rNEvt.GetType()) + { + case EVENT_KEYINPUT: + //if ( nRet != 1L ) + { + const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); + if ( handleKeyEvent(*pKeyEvent) ) + nRet = 1L; + else if ( nRet == 1L && m_pAccel.get() ) + { + const KeyCode& rCode = pKeyEvent->GetKeyCode(); + util::URL aUrl; + aUrl.Complete = m_pAccel->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rCode)); + if ( !aUrl.Complete.getLength() || !m_rController.isCommandEnabled( aUrl.Complete ) ) + nRet = 0L; + } + } + break; + default: + break; + } + + return nRet; +} +//------------------------------------------------------------------------------ +void ODesignView::resizeDocumentView(Rectangle& _rPlayground) +{ + if ( !_rPlayground.IsEmpty() ) + { + const Size aPlaygroundSize( _rPlayground.GetSize() ); + + // calc the split pos, and forward it to the controller + sal_Int32 nSplitPos = getController().getSplitPos(); + if ( 0 != aPlaygroundSize.Width() ) + { + if ( ( -1 == nSplitPos ) + || ( nSplitPos >= aPlaygroundSize.Width() ) + ) + { + long nMinWidth = static_cast<long>(0.1*aPlaygroundSize.Width()); + if ( m_pPropWin && m_pPropWin->IsVisible() ) + nMinWidth = m_pPropWin->GetMinOutputSizePixel().Width(); + nSplitPos = static_cast<sal_Int32>(_rPlayground.Right() - nMinWidth); + getController().setSplitPos(nSplitPos); + } + } // if ( 0 != _rPlaygroundSize.Width() ) + + Size aReportWindowSize(aPlaygroundSize); + if ( m_aSplitWin.IsItemValid(TASKPANE_ID) ) + { + // normalize the split pos + const long nSplitterWidth = GetSettings().GetStyleSettings().GetSplitSize(); + Point aTaskPanePos(nSplitPos + nSplitterWidth, _rPlayground.Top()); + if ( m_pTaskPane && m_pTaskPane->IsVisible() ) + { + aTaskPanePos.X() = aPlaygroundSize.Width() - m_pTaskPane->GetSizePixel().Width(); + sal_Int32 nMinWidth = m_pPropWin->getMinimumSize().Width(); + if ( nMinWidth > (aPlaygroundSize.Width() - aTaskPanePos.X()) ) + { + aTaskPanePos.X() = aPlaygroundSize.Width() - nMinWidth; + } + nSplitPos = aTaskPanePos.X() - nSplitterWidth; + getController().setSplitPos(nSplitPos); + + const long nTaskPaneSize = static_cast<long>((aPlaygroundSize.Width() - aTaskPanePos.X())*100/aPlaygroundSize.Width()); + if ( m_aSplitWin.GetItemSize( TASKPANE_ID ) != nTaskPaneSize ) + { + m_aSplitWin.SetItemSize( REPORT_ID, 99 - nTaskPaneSize ); + m_aSplitWin.SetItemSize( TASKPANE_ID, nTaskPaneSize ); + } + } + } + // set the size of the report window + m_aSplitWin.SetPosSizePixel( _rPlayground.TopLeft(),aPlaygroundSize ); + } + // just for completeness: there is no space left, we occupied it all ... + _rPlayground.SetPos( _rPlayground.BottomRight() ); + _rPlayground.SetSize( Size( 0, 0 ) ); + +} +// ----------------------------------------------------------------------------- +// set the view readonly or not +void ODesignView::setReadOnly(sal_Bool /*_bReadOnly*/) +{ +} +//---------------------------------------------------------------------------- +IMPL_LINK( ODesignView, MarkTimeout, Timer *, EMPTYARG ) +{ + if ( m_pPropWin && m_pPropWin->IsVisible() ) + { + m_pPropWin->Update(m_pCurrentView); + uno::Reference<beans::XPropertySet> xProp(m_xReportComponent,uno::UNO_QUERY); + if ( xProp.is() ) + { + m_pPropWin->Update(xProp); + static_cast<OTaskWindow*>(m_pTaskPane)->Resize(); + } + Resize(); + } + + return 0; +} + +//---------------------------------------------------------------------------- +void ODesignView::SetMode( DlgEdMode _eNewMode ) +{ + m_eMode = _eNewMode; + if ( m_eMode == RPTUI_SELECT ) + m_eActObj = OBJ_NONE; + + m_aScrollWindow.SetMode(_eNewMode); +} +//---------------------------------------------------------------------------- +void ODesignView::SetInsertObj( USHORT eObj,const ::rtl::OUString& _sShapeType ) +{ + m_eActObj = eObj; + m_aScrollWindow.SetInsertObj( eObj,_sShapeType ); +} +//---------------------------------------------------------------------------- +rtl::OUString ODesignView::GetInsertObjString() const +{ + return m_aScrollWindow.GetInsertObjString(); +} +//---------------------------------------------------------------------------- + +USHORT ODesignView::GetInsertObj() const +{ + return m_eActObj; +} + +//---------------------------------------------------------------------------- +void ODesignView::Cut() +{ + Copy(); + Delete(); +} + +//---------------------------------------------------------------------------- + +void ODesignView::Copy() +{ + m_aScrollWindow.Copy(); +} + +//---------------------------------------------------------------------------- + +void ODesignView::Paste() +{ + m_aScrollWindow.Paste(); +} +//---------------------------------------------------------------------------- +void ODesignView::Delete() +{ + m_aScrollWindow.Delete(); +} +//---------------------------------------------------------------------------- +BOOL ODesignView::HasSelection() const +{ + return m_aScrollWindow.HasSelection(); +} +//---------------------------------------------------------------------------- + +BOOL ODesignView::IsPasteAllowed() const +{ + return m_aScrollWindow.IsPasteAllowed(); +} + +//---------------------------------------------------------------------------- +void ODesignView::UpdatePropertyBrowserDelayed(OSectionView& _rView) +{ + if ( m_pCurrentView != &_rView ) + { + if ( m_pCurrentView ) + m_aScrollWindow.setMarked(m_pCurrentView,sal_False); + m_pCurrentView = &_rView; + if ( m_pCurrentView ) + m_aScrollWindow.setMarked(m_pCurrentView,sal_True); + m_xReportComponent.clear(); + DlgEdHint aHint( RPTUI_HINT_SELECTIONCHANGED ); + Broadcast( aHint ); + } + m_aMarkTimer.Start(); +} + +//---------------------------------------------------------------------------- +void ODesignView::toggleGrid(sal_Bool _bGridVisible) +{ + m_aScrollWindow.toggleGrid(_bGridVisible); +} +//---------------------------------------------------------------------------- +USHORT ODesignView::getSectionCount() const +{ + return m_aScrollWindow.getSectionCount(); +} +//---------------------------------------------------------------------------- +void ODesignView::showRuler(sal_Bool _bShow) +{ + m_aScrollWindow.showRuler(_bShow); +} +//---------------------------------------------------------------------------- +void ODesignView::removeSection(USHORT _nPosition) +{ + m_aScrollWindow.removeSection(_nPosition); +} +//---------------------------------------------------------------------------- +void ODesignView::addSection(const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry,USHORT _nPosition) +{ + m_aScrollWindow.addSection(_xSection,_sColorEntry,_nPosition); +} +// ----------------------------------------------------------------------------- +void ODesignView::GetFocus() +{ + Window::GetFocus(); + + if ( !m_bDeleted ) + { + ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_aScrollWindow.getMarkedSection(); + if ( pSectionWindow ) + pSectionWindow->GrabFocus(); + } +} +// ----------------------------------------------------------------------------- +void ODesignView::ImplInitSettings() +{ +//#if OSL_DEBUG_LEVEL > 0 +// SetBackground( Wallpaper( COL_RED )); +//#else + SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() )); +//#endif + SetFillColor( Application::GetSettings().GetStyleSettings().GetFaceColor() ); + SetTextFillColor( Application::GetSettings().GetStyleSettings().GetFaceColor() ); +} +//----------------------------------------------------------------------------- +IMPL_LINK( ODesignView, SplitHdl, void*, ) +{ + const Size aOutputSize = GetOutputSizePixel(); + const long nTest = aOutputSize.Width() * m_aSplitWin.GetItemSize(TASKPANE_ID) / 100; + long nMinWidth = static_cast<long>(0.1*aOutputSize.Width()); + if ( m_pPropWin && m_pPropWin->IsVisible() ) + nMinWidth = m_pPropWin->GetMinOutputSizePixel().Width(); + + if ( (aOutputSize.Width() - nTest) >= nMinWidth && nTest > m_aScrollWindow.getMaxMarkerWidth(sal_False) ) + { + long nOldSplitPos = getController().getSplitPos(); + getController().setSplitPos(nTest); + if ( nOldSplitPos != -1 && nOldSplitPos <= nTest ) + { + Invalidate(/*INVALIDATE_NOCHILDREN*/); + } + } + + return 0L; +} +//----------------------------------------------------------------------------- +void ODesignView::SelectAll(const sal_uInt16 _nObjectType) +{ + m_aScrollWindow.SelectAll(_nObjectType); +} +//----------------------------------------------------------------------------- +void ODesignView::unmarkAllObjects(OSectionView* _pSectionView) +{ + m_aScrollWindow.unmarkAllObjects(_pSectionView); +} +//----------------------------------------------------------------------------- +void ODesignView::togglePropertyBrowser(sal_Bool _bToogleOn) +{ + if ( !m_pPropWin && _bToogleOn ) + { + m_pPropWin = new PropBrw(getController().getORB(),m_pTaskPane,this); + m_pPropWin->Invalidate(); + static_cast<OTaskWindow*>(m_pTaskPane)->setPropertyBrowser(m_pPropWin); + notifySystemWindow(this,m_pPropWin,::comphelper::mem_fun(&TaskPaneList::AddWindow)); + } + if ( m_pPropWin && _bToogleOn != m_pPropWin->IsVisible() ) + { + if ( !m_pCurrentView && !m_xReportComponent.is() ) + m_xReportComponent = getController().getReportDefinition(); + + const sal_Bool bWillBeVisible = _bToogleOn; + m_pPropWin->Show(bWillBeVisible); + m_pTaskPane->Show(bWillBeVisible); + m_pTaskPane->Invalidate(); + + if ( bWillBeVisible ) + m_aSplitWin.InsertItem( TASKPANE_ID, m_pTaskPane,START_SIZE_TASKPANE, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE/*|SWIB_COLSET */); + else + m_aSplitWin.RemoveItem(TASKPANE_ID); + + // TRY + // Invalidate(/*INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE*/); + if ( bWillBeVisible ) + m_aMarkTimer.Start(); + } +} +//----------------------------------------------------------------------------- +void ODesignView::showProperties(const uno::Reference< uno::XInterface>& _xReportComponent) +{ + if ( m_xReportComponent != _xReportComponent ) + { + m_xReportComponent = _xReportComponent; + if ( m_pCurrentView ) + m_aScrollWindow.setMarked(m_pCurrentView,sal_False); + m_pCurrentView = NULL; + m_aMarkTimer.Start(); + } +} +//----------------------------------------------------------------------------- +BOOL ODesignView::isReportExplorerVisible() const +{ + return m_pReportExplorer && m_pReportExplorer->IsVisible(); +} +//----------------------------------------------------------------------------- +void ODesignView::toggleReportExplorer() +{ + if ( !m_pReportExplorer ) + { + OReportController& rReportController = getController(); + m_pReportExplorer = new ONavigator(this,rReportController); + SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_NAVIGATOR ) ); + if ( aDlgOpt.Exists() ) + m_pReportExplorer->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); + m_pReportExplorer->AddEventListener(LINK(&rReportController,OReportController,EventLstHdl)); + notifySystemWindow(this,m_pReportExplorer,::comphelper::mem_fun(&TaskPaneList::AddWindow)); + } + else + m_pReportExplorer->Show(!m_pReportExplorer->IsVisible()); +} +//----------------------------------------------------------------------------- +BOOL ODesignView::isAddFieldVisible() const +{ + return m_pAddField && m_pAddField->IsVisible(); +} +//----------------------------------------------------------------------------- +void ODesignView::toggleAddField() +{ + if ( !m_pAddField ) + { + uno::Reference< report::XReportDefinition > xReport(m_xReportComponent,uno::UNO_QUERY); + uno::Reference< report::XReportComponent > xReportComponent(m_xReportComponent,uno::UNO_QUERY); + OReportController& rReportController = getController(); + if ( !m_pCurrentView && !xReport.is() ) + { + if ( xReportComponent.is() ) + xReport = xReportComponent->getSection()->getReportDefinition(); + else + xReport = rReportController.getReportDefinition().get(); + } + else if ( m_pCurrentView ) + { + uno::Reference< report::XSection > xSection = m_pCurrentView->getReportSection()->getSection(); + xReport = xSection->getReportDefinition(); + } + uno::Reference < beans::XPropertySet > xSet(rReportController.getRowSet(),uno::UNO_QUERY); + m_pAddField = new OAddFieldWindow(this,xSet); + m_pAddField->SetCreateHdl(LINK( &rReportController, OReportController, OnCreateHdl ) ); + SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( UID_RPT_RPT_APP_VIEW ) ); + if ( aDlgOpt.Exists() ) + m_pAddField->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); + m_pAddField->Update(); + m_pAddField->AddEventListener(LINK(&rReportController,OReportController,EventLstHdl)); + notifySystemWindow(this,m_pAddField,::comphelper::mem_fun(&TaskPaneList::AddWindow)); + m_pAddField->Show(); + } + else + m_pAddField->Show(!m_pAddField->IsVisible()); +} +// ------------------------------------------------------------------------- +uno::Reference< report::XSection > ODesignView::getCurrentSection() const +{ + uno::Reference< report::XSection > xSection; + if ( m_pCurrentView ) + xSection = m_pCurrentView->getReportSection()->getSection(); + + // why do we need the code below? + //else + // { + // OReportController& rReportController = getController(); + // xSection = rReportController.getReportDefinition()->getDetail(); + // } + return xSection; +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XReportComponent > ODesignView::getCurrentControlModel() const +{ + uno::Reference< report::XReportComponent > xModel; + if ( m_pCurrentView ) + { + xModel = m_pCurrentView->getReportSection()->getCurrentControlModel(); + } + return xModel; +} +// ------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> ODesignView::getMarkedSection(NearSectionAccess nsa) const +{ + return m_aScrollWindow.getMarkedSection(nsa); +} +//----------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> ODesignView::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const +{ + return m_aScrollWindow.getSectionWindow(_xSection); +} +// ------------------------------------------------------------------------- +void ODesignView::markSection(const sal_uInt16 _nPos) +{ + m_aScrollWindow.markSection(_nPos); +} +// ----------------------------------------------------------------------------- +void ODesignView::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const +{ + m_aScrollWindow.fillCollapsedSections(_rCollapsedPositions); +} +// ----------------------------------------------------------------------------- +void ODesignView::collapseSections(const uno::Sequence< beans::PropertyValue>& _aCollpasedSections) +{ + m_aScrollWindow.collapseSections(_aCollpasedSections); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ODesignView::getCurrentPage() const +{ + return m_pPropWin ? m_pPropWin->getCurrentPage() : ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +void ODesignView::setCurrentPage(const ::rtl::OUString& _sLastActivePage) +{ + if ( m_pPropWin ) + m_pPropWin->setCurrentPage(_sLastActivePage); +} +// ----------------------------------------------------------------------------- +void ODesignView::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool bBoundRects) +{ + m_aScrollWindow.alignMarkedObjects(_nControlModification, _bAlignAtSection,bBoundRects); +} +#if 0 +// ----------------------------------------------------------------------------- +sal_Bool ODesignView::isAlignPossible() const +{ + ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection(); + return pMarkedSection.get() && pMarkedSection->getReportSection().getSectionView().IsAlignPossible(); +} +#endif +//------------------------------------------------------------------------------ +sal_Bool ODesignView::handleKeyEvent(const KeyEvent& _rEvent) +{ + if ( (m_pPropWin && m_pPropWin->HasChildPathFocus()) ) + return sal_False; + if ( (m_pAddField && m_pAddField->HasChildPathFocus()) ) + return sal_False; + if ( (m_pReportExplorer && m_pReportExplorer->HasChildPathFocus()) ) + return sal_False; + return m_aScrollWindow.handleKeyEvent(_rEvent); +} +//------------------------------------------------------------------------ +void ODesignView::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark) +{ + m_aScrollWindow.setMarked(_xSection,_bMark); + if ( _bMark ) + UpdatePropertyBrowserDelayed(getMarkedSection()->getReportSection().getSectionView()); + else + m_pCurrentView = NULL; +} +//------------------------------------------------------------------------ +void ODesignView::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _aShapes,sal_Bool _bMark) +{ + m_aScrollWindow.setMarked(_aShapes,_bMark); + if ( _aShapes.hasElements() && _bMark ) + showProperties(_aShapes[0]); + else + m_xReportComponent.clear(); +} +//------------------------------------------------------------------------------ +void ODesignView::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( rMEvt.IsLeft() ) + { + const uno::Sequence< beans::PropertyValue> aArgs; + getController().executeChecked(SID_SELECT_REPORT,aArgs); + } + ODataView::MouseButtonDown(rMEvt); +} +// ----------------------------------------------------------------------------- +uno::Any ODesignView::getCurrentlyShownProperty() const +{ + uno::Any aRet; + ::boost::shared_ptr<OSectionWindow> pSectionWindow = getMarkedSection(); + if ( pSectionWindow ) + { + ::std::vector< uno::Reference< uno::XInterface > > aSelection; + pSectionWindow->getReportSection().fillControlModelSelection(aSelection); + if ( !aSelection.empty() ) + { + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin(); + uno::Sequence< uno::Reference< report::XReportComponent > > aSeq(aSelection.size()); + for(sal_Int32 i = 0; i < aSeq.getLength(); ++i,++aIter) + { + aSeq[i].set(*aIter,uno::UNO_QUERY); + } + aRet <<= aSeq; + } + } + return aRet; +} +// ----------------------------------------------------------------------------- +void ODesignView::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const +{ + m_aScrollWindow.fillControlModelSelection(_rSelection); +} +// ----------------------------------------------------------------------------- +void ODesignView::setGridSnap(BOOL bOn) +{ + m_aScrollWindow.setGridSnap(bOn); + +} +// ----------------------------------------------------------------------------- +void ODesignView::setDragStripes(BOOL bOn) +{ + m_aScrollWindow.setDragStripes(bOn); +} +// ----------------------------------------------------------------------------- +sal_Bool ODesignView::isHandleEvent(sal_uInt16 /*_nId*/) const +{ + return m_pPropWin && m_pPropWin->HasChildPathFocus(); +} +// ----------------------------------------------------------------------------- +sal_uInt32 ODesignView::getMarkedObjectCount() const +{ + return m_aScrollWindow.getMarkedObjectCount(); +} +// ----------------------------------------------------------------------------- +void ODesignView::zoom(const Fraction& _aZoom) +{ + m_aScrollWindow.zoom(_aZoom); +} +// ----------------------------------------------------------------------------- +sal_uInt16 ODesignView::getZoomFactor(SvxZoomType _eType) const +{ + return m_aScrollWindow.getZoomFactor(_eType); +} +//============================================================================ +} // rptui +//============================================================================ diff --git a/reportdesign/source/ui/report/EndMarker.cxx b/reportdesign/source/ui/report/EndMarker.cxx new file mode 100644 index 000000000000..c32a07d5fc76 --- /dev/null +++ b/reportdesign/source/ui/report/EndMarker.cxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "EndMarker.hxx" +#include "ColorChanger.hxx" +#include "SectionWindow.hxx" +#include "helpids.hrc" +#include <vcl/svapp.hxx> +#include <vcl/gradient.hxx> +#include <vcl/lineinfo.hxx> + + +#define CORNER_SPACE 5 +//===================================================================== +namespace rptui +{ +//===================================================================== + DBG_NAME( rpt_OEndMarker ) +OEndMarker::OEndMarker(Window* _pParent ,const ::rtl::OUString& _sColorEntry) +: OColorListener(_pParent,_sColorEntry) +{ + DBG_CTOR( rpt_OEndMarker,NULL); + SetUniqueId(HID_RPT_ENDMARKER); + ImplInitSettings(); + SetPaintTransparent(TRUE); +} +// ----------------------------------------------------------------------------- +OEndMarker::~OEndMarker() +{ + DBG_DTOR( rpt_OEndMarker,NULL); +} +// ----------------------------------------------------------------------------- +void OEndMarker::Paint( const Rectangle& /*rRect*/ ) +{ + Fraction aCornerSpace(long(CORNER_SPACE)); + aCornerSpace *= GetMapMode().GetScaleX(); + const long nCornerSpace = aCornerSpace; + + Size aSize = GetSizePixel(); + aSize.Width() += nCornerSpace; + Rectangle aWholeRect(Point(-nCornerSpace,0),aSize); + PolyPolygon aPoly; + aPoly.Insert(Polygon(aWholeRect,nCornerSpace,nCornerSpace)); + + Color aStartColor(m_nColor); + aStartColor.IncreaseLuminance(10); + USHORT nHue = 0; + USHORT nSat = 0; + USHORT nBri = 0; + aStartColor.RGBtoHSB(nHue, nSat, nBri); + nSat += 40; + Color aEndColor(Color::HSBtoRGB(nHue, nSat, nBri)); + Gradient aGradient(GRADIENT_LINEAR,aStartColor,aEndColor); + aGradient.SetSteps(static_cast<USHORT>(aSize.Height())); + + DrawGradient(PixelToLogic(aPoly) ,aGradient); + if ( m_bMarked ) + { + Rectangle aRect( Point(-nCornerSpace,nCornerSpace), + Size(aSize.Width()- nCornerSpace,aSize.Height() - nCornerSpace- nCornerSpace)); + ColorChanger aColors( this, COL_WHITE, COL_WHITE ); + DrawPolyLine(Polygon(PixelToLogic(aRect)),LineInfo(LINE_SOLID,2)); + } +} +// ----------------------------------------------------------------------- +void OEndMarker::ImplInitSettings() +{ + SetBackground( Wallpaper( svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor) ); + SetFillColor( Application::GetSettings().GetStyleSettings().GetShadowColor() ); +} +// ----------------------------------------------------------------------- +void OEndMarker::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( !rMEvt.IsLeft() && !rMEvt.IsRight()) + return; + static_cast<OSectionWindow*>(GetParent())->showProperties(); +} +// ======================================================================= +} +// ======================================================================= diff --git a/reportdesign/source/ui/report/FixedTextColor.cxx b/reportdesign/source/ui/report/FixedTextColor.cxx new file mode 100644 index 000000000000..9952d706a4b4 --- /dev/null +++ b/reportdesign/source/ui/report/FixedTextColor.cxx @@ -0,0 +1,283 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_reportdesign.hxx" + +#include <FixedTextColor.hxx> +#include <com/sun/star/report/XFixedText.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <com/sun/star/awt/InvalidateStyle.hpp> + +#include <RptObject.hxx> +#include <RptModel.hxx> +#include <RptPage.hxx> +#include <ViewsWindow.hxx> +#include <ReportSection.hxx> +#include <ReportController.hxx> +#include <uistrings.hrc> +#include <reportformula.hxx> +#include <toolkit/helper/property.hxx> + +#include <tools/color.hxx> // COL_TRANSPARENT +#include <svtools/extcolorcfg.hxx> +#include <unotools/confignode.hxx> + +// DBG_* +#include <tools/debug.hxx> +// DBG_UNHANDLED_EXCEPTION +#include <tools/diagnose_ex.h> + +#include <vcl/svapp.hxx> +#include <vcl/settings.hxx> + +namespace rptui +{ + using namespace ::com::sun::star; + + DBG_NAME(rpt_FixedTextColor) + + FixedTextColor::FixedTextColor(const OReportController& _aController) + :m_rReportController(_aController) + { + DBG_CTOR(rpt_FixedTextColor, NULL); + } + + //-------------------------------------------------------------------- + // sal_Int32 FixedTextColor::getTextColor() + // { + // const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings(); + // BOOL bHighContrast = aStyleSettings.GetHighContrastMode(); + // + // Color aGetFaceColor = aStyleSettings.GetFaceColor(); + // Color aGetCheckedColor = aStyleSettings.GetCheckedColor(); + // Color aGetLightColor = aStyleSettings.GetLightColor(); + // Color aGetLightBorderColor = aStyleSettings.GetLightBorderColor(); + // Color aGetShadowColor = aStyleSettings.GetShadowColor(); + // Color aGetDarkShadowColor = aStyleSettings.GetDarkShadowColor(); + // Color aGetButtonTextColor = aStyleSettings.GetButtonTextColor(); + // Color aGetButtonRolloverTextColor = aStyleSettings.GetButtonRolloverTextColor(); + // Color aGetRadioCheckTextColor = aStyleSettings.GetRadioCheckTextColor(); + // Color aGetGroupTextColor = aStyleSettings.GetGroupTextColor(); + // Color aGetLabelTextColor = aStyleSettings.GetLabelTextColor(); + // Color aGetInfoTextColor = aStyleSettings.GetInfoTextColor(); + // Color aGetWindowColor = aStyleSettings.GetWindowColor(); + // Color aGetWindowTextColor = aStyleSettings.GetWindowTextColor(); + // Color aGetDialogColor = aStyleSettings.GetDialogColor(); + // Color aGetDialogTextColor = aStyleSettings.GetDialogTextColor(); + // Color aGetWorkspaceColor = aStyleSettings.GetWorkspaceColor(); + // Color aGetFieldColor = aStyleSettings.GetFieldColor(); + // Color aGetFieldTextColor = aStyleSettings.GetFieldTextColor(); + // Color aGetFieldRolloverTextColor = aStyleSettings.GetFieldRolloverTextColor(); + // Color aGetActiveColor = aStyleSettings.GetActiveColor(); + // Color aGetActiveColor2 = aStyleSettings.GetActiveColor2(); + // Color aGetActiveTextColor = aStyleSettings.GetActiveTextColor(); + // Color aGetActiveBorderColor = aStyleSettings.GetActiveBorderColor(); + // Color aGetDeactiveColor = aStyleSettings.GetDeactiveColor(); + // Color aGetDeactiveColor2 = aStyleSettings.GetDeactiveColor2(); + // Color aGetDeactiveTextColor = aStyleSettings.GetDeactiveTextColor(); + // Color aGetDeactiveBorderColor = aStyleSettings.GetDeactiveBorderColor(); + // Color aGetHighlightColor = aStyleSettings.GetHighlightColor(); + // Color aGetHighlightTextColor = aStyleSettings.GetHighlightTextColor(); + // Color aGetDisableColor = aStyleSettings.GetDisableColor(); + // Color aGetHelpColor = aStyleSettings.GetHelpColor(); + // Color aGetHelpTextColor = aStyleSettings.GetHelpTextColor(); + // Color aGetMenuColor = aStyleSettings.GetMenuColor(); + // Color aGetMenuBarColor = aStyleSettings.GetMenuBarColor(); + // Color aGetMenuBorderColor = aStyleSettings.GetMenuBorderColor(); + // Color aGetMenuTextColor = aStyleSettings.GetMenuTextColor(); + // Color aGetMenuHighlightColor = aStyleSettings.GetMenuHighlightColor(); + // Color aGetMenuHighlightTextColor = aStyleSettings.GetMenuHighlightTextColor(); + // Color aGetLinkColor = aStyleSettings.GetLinkColor(); + // Color aGetVisitedLinkColor = aStyleSettings.GetVisitedLinkColor(); + // Color aGetHighlightLinkColor = aStyleSettings.GetHighlightLinkColor(); + // Color aGetMonoColor = aStyleSettings.GetMonoColor(); + // Color aGetActiveTabColor = aStyleSettings.GetActiveTabColor(); + // Color aGetInactiveTabColor = aStyleSettings.GetInactiveTabColor(); + // + // Color aWindowColor = aStyleSettings.GetWindowColor(); + // Color aLabelColor = aStyleSettings.GetLabelTextColor(); + // + // // if (m_nTextColor == -1) + // // { + // // svtools::ExtendedColorConfig aConfig; + // // m_nTextColor = aConfig.GetColorValue(CFG_REPORTDESIGNER, DBTEXTBOXBOUNDCONTENT).getColor(); + // // } + // return aLabelColor.GetColor(); + // } + + //-------------------------------------------------------------------- + FixedTextColor::~FixedTextColor() + { + DBG_DTOR(rpt_FixedTextColor,NULL); + } + // ----------------------------------------------------------------------------- + + void FixedTextColor::notifyPropertyChange( const beans::PropertyChangeEvent& _rEvent ) + { + // (void)_rEvent; + uno::Reference< report::XFixedText > xFixedText( _rEvent.Source, uno::UNO_QUERY ); + if ( ! xFixedText.is() ) + { + return; + } + + try + { + uno::Reference< lang::XComponent > xComponent( xFixedText, uno::UNO_QUERY_THROW ); + handle(xComponent); + // uno::Reference<awt::XVclWindowPeer> xVclWindowPeer = getVclWindowPeer(xComponent); + + // setPropertyTextColor(xVclWindowPeer, getTextColor()); + } + catch (uno::Exception e) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + // ----------------------------------------------------------------------------- + void FixedTextColor::setPropertyTextColor(const uno::Reference< awt::XVclWindowPeer >& _xVclWindowPeer, sal_Int32 _nTextColor) + { + _xVclWindowPeer->setProperty(PROPERTY_TEXTCOLOR, uno::makeAny(sal_Int32(_nTextColor))); + } + + // ----------------------------------------------------------------------------- + void FixedTextColor::notifyElementInserted( const uno::Reference< uno::XInterface >& _rxElement ) + { + handle(_rxElement); + } + +// ----------------------------------------------------------------------------- + void FixedTextColor::handle( const uno::Reference< uno::XInterface >& _rxElement ) + { + // (void) _rxElement; + uno::Reference< report::XFixedText > xFixedText( _rxElement, uno::UNO_QUERY ); + if ( ! xFixedText.is() ) + { + return; + } + + try + { + sal_Bool bIsDark = sal_False; + const sal_Int32 nBackColor( xFixedText->getControlBackground() ); + if ((sal_uInt32)nBackColor == COL_TRANSPARENT) + { + uno::Reference <report::XSection> xSection(xFixedText->getParent(), uno::UNO_QUERY_THROW); + + sal_Bool bSectionBackColorIsTransparent = xSection->getBackTransparent(); + if (bSectionBackColorIsTransparent) + { + // Label Transparent, Section Transparent set LabelTextColor + const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings(); + Color aWindowColor = aStyleSettings.GetWindowColor(); + bIsDark = aWindowColor.IsDark(); + } + else + { + com::sun::star::util::Color aColor2 = xSection->getBackColor(); + Color aBackColor(aColor2); + bIsDark = aBackColor.IsDark(); + } + } + else + { + Color aLabelBackColor(nBackColor); + bIsDark = aLabelBackColor.IsDark(); + } + + uno::Reference<awt::XVclWindowPeer> xVclWindowPeer = getVclWindowPeer(xFixedText); + if (bIsDark) + { + const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings(); + Color aLabelTextColor = aStyleSettings.GetLabelTextColor(); + setPropertyTextColor(xVclWindowPeer, aLabelTextColor.GetColor()); + } + else + { + util::Color aLabelColor = xFixedText->getCharColor(); + setPropertyTextColor(xVclWindowPeer, aLabelColor); + } + + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + +// ----------------------------------------------------------------------------- + // XPropertyChangeListener + uno::Reference<awt::XControl> FixedTextColor::getXControl(const uno::Reference< report::XFixedText >& _xFixedText) throw(uno::RuntimeException) + { + + uno::Reference<awt::XControl> xControl; + OReportController *pController = (OReportController *)&m_rReportController; + + ::boost::shared_ptr<OReportModel> pModel = pController->getSdrModel(); + + uno::Reference<report::XSection> xSection(_xFixedText->getSection()); + if ( xSection.is() ) + { + OReportPage *pPage = pModel->getPage(xSection); + ULONG nIndex = pPage->getIndexOf(_xFixedText.get()); + if (nIndex < pPage->GetObjCount() ) + { + SdrObject *pObject = pPage->GetObj(nIndex); + OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObject); + if ( pUnoObj ) // this doesn't need to be done for shapes + { + ::boost::shared_ptr<OSectionWindow> pSectionWindow = pController->getSectionWindow(xSection); + if (pSectionWindow != NULL) + { + OReportSection& aOutputDevice = pSectionWindow->getReportSection(); // OutputDevice + OSectionView& aSdrView = aOutputDevice.getSectionView(); // SdrView + xControl = pUnoObj->GetUnoControl(aSdrView, aOutputDevice); + } + } + } + } + return xControl; + } + +// ----------------------------------------------------------------------------- + uno::Reference<awt::XVclWindowPeer> FixedTextColor::getVclWindowPeer(const uno::Reference< report::XFixedText >& _xComponent) throw(uno::RuntimeException) + { + uno::Reference<awt::XVclWindowPeer> xVclWindowPeer; + uno::Reference<awt::XControl> xControl = getXControl(_xComponent); + + xVclWindowPeer = uno::Reference<awt::XVclWindowPeer>( xControl->getPeer(), uno::UNO_QUERY); + + return xVclWindowPeer; + } + + + + +} diff --git a/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx b/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx new file mode 100644 index 000000000000..fdfdad6cb55f --- /dev/null +++ b/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx @@ -0,0 +1,203 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_reportdesign.hxx" + +#include <FormattedFieldBeautifier.hxx> + +#include <com/sun/star/report/XFormattedField.hpp> +#include <com/sun/star/report/XImageControl.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <com/sun/star/awt/InvalidateStyle.hpp> + +#include <RptObject.hxx> +#include <RptModel.hxx> +#include <RptPage.hxx> +#include <ViewsWindow.hxx> +#include <ReportSection.hxx> +#include <ReportController.hxx> +#include <uistrings.hrc> +#include <reportformula.hxx> +#include <toolkit/helper/property.hxx> + +#include <svtools/extcolorcfg.hxx> +#include <unotools/confignode.hxx> + +// DBG_* +#include <tools/debug.hxx> +// DBG_UNHANDLED_EXCEPTION +#include <tools/diagnose_ex.h> + +namespace rptui +{ + using namespace ::com::sun::star; + + DBG_NAME(rpt_FormattedFieldBeautifier) + + //-------------------------------------------------------------------- + FormattedFieldBeautifier::FormattedFieldBeautifier(const OReportController& _aController) + :m_rReportController(_aController) + ,m_nTextColor(-1) + { + DBG_CTOR(rpt_FormattedFieldBeautifier, NULL); + } + + //-------------------------------------------------------------------- + sal_Int32 FormattedFieldBeautifier::getTextColor() + { + if (m_nTextColor == -1) + { + svtools::ExtendedColorConfig aConfig; + m_nTextColor = aConfig.GetColorValue(CFG_REPORTDESIGNER, DBTEXTBOXBOUNDCONTENT).getColor(); + } + return m_nTextColor; + } + + //-------------------------------------------------------------------- + FormattedFieldBeautifier::~FormattedFieldBeautifier() + { + DBG_DTOR(rpt_FormattedFieldBeautifier,NULL); + } + + // ----------------------------------------------------------------------------- + void FormattedFieldBeautifier::setPlaceholderText( const uno::Reference< uno::XInterface >& _rxComponent ) + { + ::rtl::OUString sDataField; + + try + { + uno::Reference< report::XFormattedField > xControlModel( _rxComponent, uno::UNO_QUERY ); + if ( xControlModel.is() ) + { + sDataField = xControlModel->getDataField(); + + if ( sDataField.getLength() ) + { + ReportFormula aFormula( sDataField ); + bool bSet = true; + if ( aFormula.getType() == ReportFormula::Field ) + { + const ::rtl::OUString sColumnName = aFormula.getFieldName(); + ::rtl::OUString sLabel = m_rReportController.getColumnLabel_throw(sColumnName); + if ( sLabel.getLength() ) + { + ::rtl::OUStringBuffer aBuffer; + aBuffer.appendAscii( "=" ); + aBuffer.append( sLabel ); + sDataField = aBuffer.makeStringAndClear(); + bSet = false; + } + } + if ( bSet ) + sDataField = aFormula.getEqualUndecoratedContent(); + } + } + + if ( xControlModel.is() ) + setPlaceholderText( getVclWindowPeer( xControlModel.get() ), sDataField ); + } + catch (uno::Exception) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + // ----------------------------------------------------------------------------- + void FormattedFieldBeautifier::setPlaceholderText( const uno::Reference< awt::XVclWindowPeer >& _xVclWindowPeer, const ::rtl::OUString& _rText ) + { + OSL_ENSURE( _xVclWindowPeer.is(), "FormattedFieldBeautifier::setPlaceholderText: invalid peer!" ); + if ( !_xVclWindowPeer.is() ) + throw uno::RuntimeException(); + + // the actual text + _xVclWindowPeer->setProperty(PROPERTY_TEXT, uno::makeAny(_rText)); + // the text color + _xVclWindowPeer->setProperty(PROPERTY_TEXTCOLOR, uno::makeAny(getTextColor())); + // font->italic + uno::Any aFontDescriptor = _xVclWindowPeer->getProperty(PROPERTY_FONTDESCRIPTOR); + awt::FontDescriptor aFontDescriptorStructure; + aFontDescriptor >>= aFontDescriptorStructure; + aFontDescriptorStructure.Slant = ::com::sun::star::awt::FontSlant_ITALIC; + _xVclWindowPeer->setProperty(PROPERTY_FONTDESCRIPTOR, uno::makeAny(aFontDescriptorStructure)); + } + + // ----------------------------------------------------------------------------- + void FormattedFieldBeautifier::notifyPropertyChange( const beans::PropertyChangeEvent& _rEvent ) + { + if ( !_rEvent.PropertyName.equalsAscii( "DataField" ) ) + // not interested in + return; + + setPlaceholderText( _rEvent.Source ); + } + + // ----------------------------------------------------------------------------- + void FormattedFieldBeautifier::handle( const uno::Reference< uno::XInterface >& _rxElement ) + { + setPlaceholderText( _rxElement ); + } + + // ----------------------------------------------------------------------------- + void FormattedFieldBeautifier::notifyElementInserted( const uno::Reference< uno::XInterface >& _rxElement ) + { + handle( _rxElement ); + } + + // ----------------------------------------------------------------------------- + uno::Reference<awt::XVclWindowPeer> FormattedFieldBeautifier::getVclWindowPeer(const uno::Reference< report::XReportComponent >& _xComponent) throw(uno::RuntimeException) + { + uno::Reference<awt::XVclWindowPeer> xVclWindowPeer; + + ::boost::shared_ptr<OReportModel> pModel = const_cast< OReportController& >( m_rReportController ).getSdrModel(); + + uno::Reference<report::XSection> xSection(_xComponent->getSection()); + if ( xSection.is() ) + { + OReportPage *pPage = pModel->getPage(xSection); + ULONG nIndex = pPage->getIndexOf(_xComponent); + if (nIndex < pPage->GetObjCount() ) + { + SdrObject *pObject = pPage->GetObj(nIndex); + OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObject); + if ( pUnoObj ) // this doesn't need to be done for shapes + { + // Rectangle aRect = pUnoObj->GetCurrentBoundRect(); + ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_rReportController.getSectionWindow(xSection); + if (pSectionWindow != NULL) + { + OReportSection& aOutputDevice = pSectionWindow->getReportSection(); // OutputDevice + OSectionView& aSdrView = aOutputDevice.getSectionView(); // SdrView + uno::Reference<awt::XControl> xControl = pUnoObj->GetUnoControl(aSdrView, aOutputDevice); + xVclWindowPeer = uno::Reference<awt::XVclWindowPeer>( xControl->getPeer(), uno::UNO_QUERY); + } + } + } + } + return xVclWindowPeer; + } +} diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx new file mode 100644 index 000000000000..6d13804fe7fa --- /dev/null +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -0,0 +1,4402 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#define RPTUI_ID_LRSPACE 1 +#define RPTUI_ID_ULSPACE 2 +#define RPTUI_ID_PAGE 3 +#define RPTUI_ID_SIZE 4 +#define RPTUI_ID_PAGE_MODE 5 +#define RPTUI_ID_START 6 +#define RPTUI_ID_END 7 +#define RPTUI_ID_BRUSH 8 +#define RPTUI_ID_METRIC 9 + +#define ITEMID_LRSPACE RPTUI_ID_LRSPACE +#define ITEMID_ULSPACE RPTUI_ID_ULSPACE +#define ITEMID_SIZE RPTUI_ID_SIZE +#define ITEMID_PAGE RPTUI_ID_PAGE +#define ITEMID_BRUSH RPTUI_ID_BRUSH + + +#include "ReportController.hxx" +#include "ReportDefinition.hxx" +#include "CondFormat.hxx" +#include "UITools.hxx" +#include "AddField.hxx" +#include <toolkit/helper/vclunohelper.hxx> +#include "DateTime.hxx" + +#include <sfx2/filedlghelper.hxx> +#include <tools/string.hxx> +#include <tools/diagnose_ex.h> +#include "rptui_slotid.hrc" +#include "reportformula.hxx" + +#include <comphelper/documentconstants.hxx> +#include <comphelper/mediadescriptor.hxx> +#include <comphelper/property.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <comphelper/types.hxx> + +#include <connectivity/dbtools.hxx> +#include <com/sun/star/view/PaperFormat.hpp> +#include <com/sun/star/style/GraphicLocation.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/style/PageStyleLayout.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/datatransfer/XTransferable.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/report/XImageControl.hpp> +#include <com/sun/star/report/XFixedLine.hpp> +#include <com/sun/star/report/Function.hpp> +#include <com/sun/star/report/XShape.hpp> +#include <com/sun/star/awt/FontDescriptor.hpp> +#include <com/sun/star/sdb/XDocumentDataSource.hpp> +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/EmbedMapUnits.hpp> +#include <comphelper/streamsection.hxx> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/TextAlign.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/frame/status/FontHeight.hpp> +#include <com/sun/star/report/XFormattedField.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdbc/SQLWarning.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +#include <vcl/svapp.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/waitobj.hxx> + +#include <svx/fmview.hxx> +#include <editeng/paperinf.hxx> +#include <svx/svxids.hrc> +#include <svx/svdobj.hxx> +#include <svx/dataaccessdescriptor.hxx> +#include <editeng/svxenum.hxx> +#include <svx/pageitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/ulspitem.hxx> +#include <editeng/sizeitem.hxx> +#include <svx/zoomitem.hxx> +#include <svx/zoomslideritem.hxx> +#include <editeng/brshitem.hxx> +#include <svx/flagsdef.hxx> //CHINA001 +#include <svx/svdpagv.hxx> +#include <svx/svxdlg.hxx> +#include <svx/zoom_def.hxx> +#include <svx/dialogs.hrc> + +#include "DesignView.hxx" +#include "ModuleHelper.hxx" +#include "RptObject.hxx" +#include "Undo.hxx" +#include "uistrings.hrc" +#include "RptDef.hxx" +#include "ReportSection.hxx" +#include "SectionView.hxx" +#include "UndoActions.hxx" +#include "dlgpage.hxx" +#include "RptResId.hrc" + +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include <svl/aeitem.hxx> //CHINA001 +#include <svtools/cliplistener.hxx> +#include <unotools/syslocale.hxx> +#include <unotools/viewoptions.hxx> + +#include <vos/mutex.hxx> +#include "PropertyForward.hxx" +#include "SectionWindow.hxx" + +#include <toolkit/helper/convert.hxx> +#include "GroupsSorting.hxx" +#include "PageNumber.hxx" +#include <toolkit/helper/vclunohelper.hxx> +#include "UndoEnv.hxx" +#include "InsertFunctions.hxx" + +#include <boost/mem_fn.hpp> +#include <boost/bind.hpp> +#include <boost/utility.hpp> + +#include <cppuhelper/exc_hlp.hxx> +#include <unotools/confignode.hxx> +#include <helpids.hrc> + +#include <ReportControllerObserver.hxx> + +#define MAX_ROWS_FOR_PREVIEW 50 + +using namespace ::com::sun::star; +using namespace uno; +using namespace io; +using namespace beans; +using namespace frame; +using namespace util; +using namespace lang; +using namespace container; +using namespace sdbcx; +using namespace sdbc; +using namespace sdb; +using namespace ui; +using namespace ui::dialogs; +using namespace util; +using namespace ::dbtools; +using namespace ::rptui; +using namespace ::dbaui; +using namespace ::comphelper; +using namespace ::cppu; + +// ----------------------------------------------------------------------------- +namespace +{ + // comparing two PropertyValue instances + struct PropertyValueCompare : public ::std::binary_function< beans::PropertyValue, ::rtl::OUString , bool > + { + bool operator() (const beans::PropertyValue& x, const ::rtl::OUString& y) const + { + return x.Name.equals(y);// ? true : false; + } + bool operator() (const ::rtl::OUString& x,const beans::PropertyValue& y) const + { + return x.equals(y.Name);// ? true : false; + } + }; + + void lcl_setFontWPU_nothrow(const uno::Reference< report::XReportControlFormat>& _xReportControlFormat,const sal_Int32 _nId) + { + if ( _xReportControlFormat.is() ) + { + try + { + awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor(); + switch(_nId) + { + case SID_ATTR_CHAR_WEIGHT: + aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight; + break; + case SID_ATTR_CHAR_POSTURE: + aFontDescriptor.Slant = static_cast<awt::FontSlant>(static_cast<sal_Int16>(awt::FontSlant_ITALIC) - static_cast<sal_Int16>(aFontDescriptor.Slant)); + break; + case SID_ATTR_CHAR_UNDERLINE: + aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline; + break; + default: + OSL_ENSURE(0,"Illegal value in default!"); + break; + } + + _xReportControlFormat->setFontDescriptor(aFontDescriptor); + } + catch(beans::UnknownPropertyException&) + { + } + } // if ( xReportControlFormat.is() ) + } +} + +// ----------------------------------------------------------------------------- +void lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs, + ODesignView* _pView, + uno::Reference< awt::XWindow>& _xWindow, + ::std::vector< uno::Reference< uno::XInterface > >& _rControlsFormats) +{ + uno::Reference< report::XReportControlFormat> xReportControlFormat; + if ( aArgs.getLength() ) + { + SequenceAsHashMap aMap(aArgs); + xReportControlFormat = aMap.getUnpackedValueOrDefault(REPORTCONTROLFORMAT,uno::Reference< report::XReportControlFormat>()); + _xWindow = aMap.getUnpackedValueOrDefault(CURRENT_WINDOW,uno::Reference< awt::XWindow>()); + } // if ( aArgs.getLength() ) + if ( !xReportControlFormat.is() ) + { + _pView->fillControlModelSelection(_rControlsFormats); + //xReportControlFormat.set( _pView->getCurrentControlModel(),uno::UNO_QUERY); + } // if ( !xReportControlFormat.is() ) + else + _rControlsFormats.push_back(xReportControlFormat); + + if ( !_xWindow.is() ) + _xWindow = VCLUnoHelper::GetInterface(_pView); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OReportController::getImplementationName() throw( RuntimeException ) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------------ +::rtl::OUString OReportController::getImplementationName_Static() throw( RuntimeException ) +{ + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.comp.ReportDesign")); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString> OReportController::getSupportedServiceNames_Static(void) throw( RuntimeException ) +{ + Sequence< ::rtl::OUString> aSupported(1); + aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ReportDesign")); + return aSupported; +} +//------------------------------------------------------------------------- +Sequence< ::rtl::OUString> SAL_CALL OReportController::getSupportedServiceNames() throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +// ------------------------------------------------------------------------- +Reference< XInterface > OReportController::create(Reference< XComponentContext > const & xContext) +{ + return *(new OReportController(xContext)); +} + +#define PROPERTY_ID_ZOOMVALUE 1 + +DBG_NAME( rpt_OReportController ) +// ----------------------------------------------------------------------------- +OReportController::OReportController(Reference< XComponentContext > const & xContext) + :OReportController_BASE(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY)) + ,OPropertyStateContainer(OGenericUnoController_Base::rBHelper) + ,m_aSelectionListeners( getMutex() ) + ,m_pClipbordNotifier(NULL) + ,m_pGroupsFloater(NULL) + ,m_xContext(xContext) + ,m_nSplitPos(-1) + ,m_nPageNum(-1) + ,m_nSelectionCount(0) + ,m_nZoomValue(100) + ,m_eZoomType(SVX_ZOOM_PERCENT) + ,m_bShowRuler(sal_True) + ,m_bGridVisible(sal_True) + ,m_bGridUse(sal_True) + ,m_bShowProperties(sal_True) + ,m_bGroupFloaterWasVisible(sal_False) + ,m_bHelplinesMove(sal_True) + ,m_bChartEnabled(false) + ,m_bChartEnabledAsked(false) + ,m_bInGeneratePreview(false) +{ + // new Observer + m_pReportControllerObserver = new OXReportControllerObserver(*this); + m_pReportControllerObserver->acquire(); + + m_sMode = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("normal")); + DBG_CTOR( rpt_OReportController,NULL); + registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZoomValue")),PROPERTY_ID_ZOOMVALUE,beans::PropertyAttribute::BOUND| beans::PropertyAttribute::TRANSIENT,&m_nZoomValue,::getCppuType(reinterpret_cast< sal_Int16*>(NULL))); + +} +// ----------------------------------------------------------------------------- +OReportController::~OReportController() +{ + DBG_DTOR( rpt_OReportController,NULL); +} +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XTYPEPROVIDER2(OReportController,OReportController_BASE,OReportController_Listener) +IMPLEMENT_FORWARD_XINTERFACE2(OReportController,OReportController_BASE,OReportController_Listener) +// ----------------------------------------------------------------------------- +void OReportController::disposing() +{ + + if ( m_pClipbordNotifier ) + { + m_pClipbordNotifier->ClearCallbackLink(); + m_pClipbordNotifier->AddRemoveListener( getView(), sal_False ); + m_pClipbordNotifier->release(); + m_pClipbordNotifier = NULL; + } // if ( getView() && m_pClipbordNotifier ) + if ( m_pGroupsFloater ) + { + SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_GROUPS_SORTING ) ); + aDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( m_pGroupsFloater->GetWindowState(WINDOWSTATE_MASK_ALL).GetBuffer() ) ); + ::std::auto_ptr<FloatingWindow> aTemp(m_pGroupsFloater); + m_pGroupsFloater = NULL; + } + + try + { + m_xHoldAlive.clear(); + m_xColumns.clear(); + ::comphelper::disposeComponent( m_xRowSet ); + ::comphelper::disposeComponent( m_xRowSetMediator ); + ::comphelper::disposeComponent( m_xFormatter ); + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"Exception caught while disposing row sets."); + } + m_xRowSet.clear(); + m_xRowSetMediator.clear(); + + if ( m_xReportDefinition.is() ) + { + try + { + ::boost::shared_ptr<OSectionWindow> pSectionWindow; + if ( getDesignView() ) + pSectionWindow = getDesignView()->getMarkedSection(); + if ( pSectionWindow ) + pSectionWindow->getReportSection().deactivateOle(); + getUndoMgr()->Clear(); // clear all undo redo things + if ( m_aReportModel ) + listen(false); + m_pReportControllerObserver->Clear(); + m_pReportControllerObserver->release(); + } + catch(uno::Exception&) + { + } + } + + { + EventObject aDisposingEvent( *this ); + m_aSelectionListeners.disposeAndClear( aDisposingEvent ); + } + + OReportController_BASE::disposing(); + + + // disconnect(); + try + { + m_xReportDefinition.clear(); + m_aReportModel.reset(); + m_xFrameLoader.clear(); + m_xReportEngine.clear(); + } + catch(uno::Exception&) + { + } + if ( getDesignView() ) + EndListening( *getDesignView() ); + clearView(); +} +// ----------------------------------------------------------------------------- +FeatureState OReportController::GetState(sal_uInt16 _nId) const +{ + FeatureState aReturn; + // (disabled automatically) + aReturn.bEnabled = sal_False; + // check this first + if ( !getView() ) + return aReturn; + + switch (_nId) + { + case SID_RPT_TEXTDOCUMENT: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_TEXT); + break; + case SID_RPT_SPREADSHEET: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET); + break; + case SID_REPORTHEADER_WITHOUT_UNDO: + case SID_REPORTFOOTER_WITHOUT_UNDO: + case SID_REPORTHEADERFOOTER: + { + aReturn.bEnabled = isEditable(); + ::rtl::OUString sText = String(ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT)); + aReturn.sTitle = sText; + } + break; + case SID_PAGEHEADER_WITHOUT_UNDO: + case SID_PAGEFOOTER_WITHOUT_UNDO: + case SID_PAGEHEADERFOOTER: + { + aReturn.bEnabled = isEditable(); + ::rtl::OUString sText = String(ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT)); + aReturn.sTitle = sText; + } + break; + case SID_GROUP_APPEND: + case SID_GROUP_REMOVE: + case SID_GROUPHEADER_WITHOUT_UNDO: + case SID_GROUPHEADER: + case SID_GROUPFOOTER_WITHOUT_UNDO: + case SID_GROUPFOOTER: + aReturn.bEnabled = isEditable(); + break; + case SID_ADD_CONTROL_PAIR: + aReturn.bEnabled = isEditable(); + break; + case SID_REDO: + case SID_UNDO: + aReturn = OReportController_BASE::GetState(_nId); + aReturn.bEnabled = aReturn.bEnabled; + break; + case SID_OBJECT_RESIZING: + case SID_OBJECT_SMALLESTWIDTH: + case SID_OBJECT_SMALLESTHEIGHT: + case SID_OBJECT_GREATESTWIDTH: + case SID_OBJECT_GREATESTHEIGHT: + aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();// && getDesignView()->isAlignPossible(); + if ( aReturn.bEnabled ) + aReturn.bEnabled = m_nSelectionCount > 1; + break; + + case SID_DISTRIBUTION: + aReturn.bEnabled = isEditable() && getDesignView()->HasSelection(); + if ( aReturn.bEnabled ) + { + OSectionView* pSectionView = getCurrentSectionView(); + aReturn.bEnabled = pSectionView && pSectionView->GetMarkedObjectCount() > 2; + } + break; + case SID_ARRANGEMENU: + case SID_FRAME_DOWN: + case SID_FRAME_UP: + case SID_FRAME_TO_TOP: + case SID_FRAME_TO_BOTTOM: + case SID_OBJECT_HEAVEN: + case SID_OBJECT_HELL: + aReturn.bEnabled = isEditable() && getDesignView()->HasSelection(); + if ( aReturn.bEnabled ) + { + OSectionView* pSectionView = getCurrentSectionView(); + aReturn.bEnabled = pSectionView && pSectionView->OnlyShapesMarked(); + if ( aReturn.bEnabled ) + { + if ( SID_OBJECT_HEAVEN == _nId ) + aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_FRONT; + else if ( SID_OBJECT_HELL == _nId ) + aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_BACK; + } + } + break; + + case SID_SECTION_SHRINK: + case SID_SECTION_SHRINK_TOP: + case SID_SECTION_SHRINK_BOTTOM: + { + sal_Int32 nCount = 0; + uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection(); + if ( xSection.is() ) + { + nCount = xSection->getCount(); + } + aReturn.bEnabled = isEditable() && nCount > 0; + } + break; + case SID_OBJECT_ALIGN: + case SID_OBJECT_ALIGN_LEFT: + case SID_OBJECT_ALIGN_CENTER: + case SID_OBJECT_ALIGN_RIGHT: + case SID_OBJECT_ALIGN_UP: + case SID_OBJECT_ALIGN_MIDDLE: + case SID_OBJECT_ALIGN_DOWN: + case SID_SECTION_ALIGN: + case SID_SECTION_ALIGN_LEFT: + case SID_SECTION_ALIGN_CENTER: + case SID_SECTION_ALIGN_RIGHT: + case SID_SECTION_ALIGN_UP: + case SID_SECTION_ALIGN_MIDDLE: + case SID_SECTION_ALIGN_DOWN: + aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();// && getDesignView()->isAlignPossible(); + break; + case SID_CUT: + aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId); + break; + case SID_COPY: + aReturn.bEnabled = getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId); + break; + case SID_PASTE: + aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent(_nId) && getDesignView()->IsPasteAllowed(); + break; + case SID_SELECTALL: + aReturn.bEnabled = !getDesignView()->isHandleEvent(_nId); + break; + case SID_SELECTALL_IN_SECTION: + aReturn.bEnabled = !getDesignView()->isHandleEvent(_nId); + if ( aReturn.bEnabled ) + aReturn.bEnabled = getCurrentSectionView() != NULL; + break; + case SID_ESCAPE: + aReturn.bEnabled = getDesignView()->GetMode() == RPTUI_INSERT; + break; + case SID_TERMINATE_INPLACEACTIVATION: + aReturn.bEnabled = sal_True; + break; + case SID_SELECT_ALL_EDITS: + case SID_SELECT_ALL_LABELS: + aReturn.bEnabled = sal_True; + break; + case SID_RPT_NEW_FUNCTION: + aReturn.bEnabled = isEditable(); + break; + case SID_COLLAPSE_SECTION: + case SID_EXPAND_SECTION: + case SID_NEXT_MARK: + case SID_PREV_MARK: + aReturn.bEnabled = isEditable(); + break; + case SID_SELECT: + case SID_SELECT_REPORT: + aReturn.bEnabled = sal_True; + break; + case SID_EXECUTE_REPORT: + aReturn.bEnabled = isConnected() && m_xReportDefinition.is(); + break; + case SID_DELETE: + aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId); + if ( aReturn.bEnabled ) + { + ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection(); + if ( pSectionWindow ) + aReturn.bEnabled = !pSectionWindow->getReportSection().isUiActive(); + } + { + ::rtl::OUString sText = String(ModuleRes(RID_STR_DELETE)); + aReturn.sTitle = sText; + } + break; + case SID_GRID_VISIBLE: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = m_bGridVisible; + break; + case SID_GRID_USE: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = m_bGridUse; + break; + case SID_HELPLINES_MOVE: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = m_bHelplinesMove; + break; + case SID_RULER: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = m_bShowRuler; + break; + case SID_OBJECT_SELECT: + aReturn.bEnabled = sal_True; + aReturn.bChecked = getDesignView()->GetMode() == RPTUI_SELECT; + break; + case SID_INSERT_DIAGRAM: + aReturn.bEnabled = isEditable(); + aReturn.bInvisible = optional< bool >(!m_bChartEnabled); + aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_OLE2; + break; + case SID_FM_FIXEDTEXT: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FIXEDTEXT; + break; + case SID_INSERT_HFIXEDLINE: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_HFIXEDLINE; + break; + case SID_INSERT_VFIXEDLINE: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_VFIXEDLINE; + break; + case SID_FM_EDIT: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FORMATTEDFIELD; + break; + case SID_FM_IMAGECONTROL: + aReturn.bEnabled = isEditable(); + aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_IMAGECONTROL; + break; + case SID_DRAWTBX_CS_BASIC: + case SID_DRAWTBX_CS_BASIC1: + case SID_DRAWTBX_CS_BASIC2: + case SID_DRAWTBX_CS_BASIC3: + case SID_DRAWTBX_CS_BASIC4: + case SID_DRAWTBX_CS_BASIC5: + case SID_DRAWTBX_CS_BASIC6: + case SID_DRAWTBX_CS_BASIC7: + case SID_DRAWTBX_CS_BASIC8: + case SID_DRAWTBX_CS_BASIC9: + case SID_DRAWTBX_CS_BASIC10: + case SID_DRAWTBX_CS_BASIC11: + case SID_DRAWTBX_CS_BASIC12: + case SID_DRAWTBX_CS_BASIC13: + case SID_DRAWTBX_CS_BASIC14: + case SID_DRAWTBX_CS_BASIC15: + case SID_DRAWTBX_CS_BASIC16: + case SID_DRAWTBX_CS_BASIC17: + case SID_DRAWTBX_CS_BASIC18: + case SID_DRAWTBX_CS_BASIC19: + case SID_DRAWTBX_CS_BASIC20: + case SID_DRAWTBX_CS_BASIC21: + case SID_DRAWTBX_CS_BASIC22: + impl_fillCustomShapeState_nothrow("diamond",aReturn); + break; + case SID_DRAWTBX_CS_SYMBOL: + case SID_DRAWTBX_CS_SYMBOL1: + case SID_DRAWTBX_CS_SYMBOL2: + case SID_DRAWTBX_CS_SYMBOL3: + case SID_DRAWTBX_CS_SYMBOL4: + case SID_DRAWTBX_CS_SYMBOL5: + case SID_DRAWTBX_CS_SYMBOL6: + case SID_DRAWTBX_CS_SYMBOL7: + case SID_DRAWTBX_CS_SYMBOL8: + case SID_DRAWTBX_CS_SYMBOL9: + case SID_DRAWTBX_CS_SYMBOL10: + case SID_DRAWTBX_CS_SYMBOL11: + case SID_DRAWTBX_CS_SYMBOL12: + case SID_DRAWTBX_CS_SYMBOL13: + case SID_DRAWTBX_CS_SYMBOL14: + case SID_DRAWTBX_CS_SYMBOL15: + case SID_DRAWTBX_CS_SYMBOL16: + case SID_DRAWTBX_CS_SYMBOL17: + case SID_DRAWTBX_CS_SYMBOL18: + impl_fillCustomShapeState_nothrow("smiley",aReturn); + break; + case SID_DRAWTBX_CS_ARROW: + case SID_DRAWTBX_CS_ARROW1: + case SID_DRAWTBX_CS_ARROW2: + case SID_DRAWTBX_CS_ARROW3: + case SID_DRAWTBX_CS_ARROW4: + case SID_DRAWTBX_CS_ARROW5: + case SID_DRAWTBX_CS_ARROW6: + case SID_DRAWTBX_CS_ARROW7: + case SID_DRAWTBX_CS_ARROW8: + case SID_DRAWTBX_CS_ARROW9: + case SID_DRAWTBX_CS_ARROW10: + case SID_DRAWTBX_CS_ARROW11: + case SID_DRAWTBX_CS_ARROW12: + case SID_DRAWTBX_CS_ARROW13: + case SID_DRAWTBX_CS_ARROW14: + case SID_DRAWTBX_CS_ARROW15: + case SID_DRAWTBX_CS_ARROW16: + case SID_DRAWTBX_CS_ARROW17: + case SID_DRAWTBX_CS_ARROW18: + case SID_DRAWTBX_CS_ARROW19: + case SID_DRAWTBX_CS_ARROW20: + case SID_DRAWTBX_CS_ARROW21: + case SID_DRAWTBX_CS_ARROW22: + case SID_DRAWTBX_CS_ARROW23: + case SID_DRAWTBX_CS_ARROW24: + case SID_DRAWTBX_CS_ARROW25: + case SID_DRAWTBX_CS_ARROW26: + impl_fillCustomShapeState_nothrow("left-right-arrow",aReturn); + break; + case SID_DRAWTBX_CS_STAR: + case SID_DRAWTBX_CS_STAR1: + case SID_DRAWTBX_CS_STAR2: + case SID_DRAWTBX_CS_STAR3: + case SID_DRAWTBX_CS_STAR4: + case SID_DRAWTBX_CS_STAR5: + case SID_DRAWTBX_CS_STAR6: + case SID_DRAWTBX_CS_STAR7: + case SID_DRAWTBX_CS_STAR8: + case SID_DRAWTBX_CS_STAR9: + case SID_DRAWTBX_CS_STAR10: + case SID_DRAWTBX_CS_STAR11: + case SID_DRAWTBX_CS_STAR12: + impl_fillCustomShapeState_nothrow("star5",aReturn); + break; + case SID_DRAWTBX_CS_FLOWCHART: + case SID_DRAWTBX_CS_FLOWCHART1: + case SID_DRAWTBX_CS_FLOWCHART2: + case SID_DRAWTBX_CS_FLOWCHART3: + case SID_DRAWTBX_CS_FLOWCHART4: + case SID_DRAWTBX_CS_FLOWCHART5: + case SID_DRAWTBX_CS_FLOWCHART6: + case SID_DRAWTBX_CS_FLOWCHART7: + case SID_DRAWTBX_CS_FLOWCHART8: + case SID_DRAWTBX_CS_FLOWCHART9: + case SID_DRAWTBX_CS_FLOWCHART10: + case SID_DRAWTBX_CS_FLOWCHART11: + case SID_DRAWTBX_CS_FLOWCHART12: + case SID_DRAWTBX_CS_FLOWCHART13: + case SID_DRAWTBX_CS_FLOWCHART14: + case SID_DRAWTBX_CS_FLOWCHART15: + case SID_DRAWTBX_CS_FLOWCHART16: + case SID_DRAWTBX_CS_FLOWCHART17: + case SID_DRAWTBX_CS_FLOWCHART18: + case SID_DRAWTBX_CS_FLOWCHART19: + case SID_DRAWTBX_CS_FLOWCHART20: + case SID_DRAWTBX_CS_FLOWCHART21: + case SID_DRAWTBX_CS_FLOWCHART22: + case SID_DRAWTBX_CS_FLOWCHART23: + case SID_DRAWTBX_CS_FLOWCHART24: + case SID_DRAWTBX_CS_FLOWCHART25: + case SID_DRAWTBX_CS_FLOWCHART26: + case SID_DRAWTBX_CS_FLOWCHART27: + case SID_DRAWTBX_CS_FLOWCHART28: + impl_fillCustomShapeState_nothrow("flowchart-internal-storage",aReturn); + break; + case SID_DRAWTBX_CS_CALLOUT: + case SID_DRAWTBX_CS_CALLOUT1: + case SID_DRAWTBX_CS_CALLOUT2: + case SID_DRAWTBX_CS_CALLOUT3: + case SID_DRAWTBX_CS_CALLOUT4: + case SID_DRAWTBX_CS_CALLOUT5: + case SID_DRAWTBX_CS_CALLOUT6: + case SID_DRAWTBX_CS_CALLOUT7: + impl_fillCustomShapeState_nothrow("round-rectangular-callout",aReturn); + break; + case SID_RPT_SHOWREPORTEXPLORER: + aReturn.bEnabled = m_xReportDefinition.is(); + aReturn.bChecked = getDesignView() && getDesignView()->isReportExplorerVisible(); + break; + case SID_FM_ADD_FIELD: + aReturn.bEnabled = isConnected() && isEditable() && m_xReportDefinition.is() + && m_xReportDefinition->getCommand().getLength(); + aReturn.bChecked = getDesignView() && getDesignView()->isAddFieldVisible(); + break; + case SID_SHOW_PROPERTYBROWSER: + aReturn.bEnabled = sal_True; + aReturn.bChecked = m_bShowProperties; + break; + case SID_PROPERTYBROWSER_LAST_PAGE: + aReturn.bEnabled = sal_True; + aReturn.aValue <<= m_sLastActivePage; + break; + case SID_SPLIT_POSITION: + aReturn.bEnabled = sal_True; + aReturn.aValue <<= getSplitPos(); + break; + case SID_SAVEDOC: + aReturn.bEnabled = impl_isModified() && isEditable(); + break; + case SID_SAVEASDOC: + aReturn.bEnabled = isConnected() && isEditable(); + break; + case SID_EDITDOC: + aReturn.bChecked = isEditable(); + break; + case SID_PAGEDIALOG: + aReturn.bEnabled = isEditable(); + break; + case SID_BACKGROUND_COLOR: + impl_fillState_nothrow(PROPERTY_CONTROLBACKGROUND,aReturn); + break; + case SID_ATTR_CHAR_COLOR_BACKGROUND: + aReturn.bEnabled = isEditable(); + { + uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection(); + if ( xSection.is() ) + try + { + aReturn.aValue <<= xSection->getBackColor(); + const uno::Reference< report::XReportControlModel> xControlModel(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY); + aReturn.bEnabled = !xControlModel.is(); + } + catch(beans::UnknownPropertyException&) + { + } + else + aReturn.bEnabled = sal_False; + } + break; + case SID_SORTINGANDGROUPING: + aReturn.bEnabled = sal_True; + aReturn.bChecked = m_pGroupsFloater && m_pGroupsFloater->IsVisible(); + break; + case SID_ATTR_CHAR_WEIGHT: + case SID_ATTR_CHAR_POSTURE: + case SID_ATTR_CHAR_UNDERLINE: + impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn); + if ( aReturn.bEnabled ) + { + awt::FontDescriptor aFontDescriptor; + aReturn.aValue >>= aFontDescriptor; + aReturn.aValue.clear(); + + switch(_nId) + { + case SID_ATTR_CHAR_WEIGHT: + aReturn.bChecked = awt::FontWeight::BOLD == aFontDescriptor.Weight; + break; + case SID_ATTR_CHAR_POSTURE: + aReturn.bChecked = awt::FontSlant_ITALIC == aFontDescriptor.Slant; + break; + case SID_ATTR_CHAR_UNDERLINE: + aReturn.bChecked = awt::FontUnderline::SINGLE == aFontDescriptor.Underline; + break; + default: + ; + } // switch(_nCommand) + } + break; + case SID_ATTR_CHAR_COLOR: + case SID_ATTR_CHAR_COLOR2: + impl_fillState_nothrow(PROPERTY_CHARCOLOR,aReturn); + break; + case SID_ATTR_CHAR_FONT: + impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn); + break; + case SID_ATTR_CHAR_FONTHEIGHT: + impl_fillState_nothrow(PROPERTY_CHARHEIGHT,aReturn); + if ( aReturn.aValue.hasValue() ) + { + frame::status::FontHeight aFontHeight; + aReturn.aValue >>= aFontHeight.Height; + aReturn.aValue <<= aFontHeight; // another type is needed here, so + } + break; + case SID_ATTR_PARA_ADJUST_LEFT: + case SID_ATTR_PARA_ADJUST_CENTER: + case SID_ATTR_PARA_ADJUST_RIGHT: + case SID_ATTR_PARA_ADJUST_BLOCK: + impl_fillState_nothrow(PROPERTY_PARAADJUST,aReturn); + if ( aReturn.bEnabled ) + { + ::sal_Int16 nParaAdjust = 0; + if ( aReturn.aValue >>= nParaAdjust ) + { + switch(nParaAdjust) + { + case style::ParagraphAdjust_LEFT: + aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_LEFT; + break; + case style::ParagraphAdjust_RIGHT: + aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_RIGHT; + break; + case style::ParagraphAdjust_BLOCK: + case style::ParagraphAdjust_STRETCH: + aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_BLOCK; + break; + case style::ParagraphAdjust_CENTER: + aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_CENTER; + break; + } + } // if ( aReturn.aValue >>= nParaAdjust ) + aReturn.aValue.clear(); + } + break; + + case SID_INSERT_GRAPHIC: + aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is(); + break; + case SID_CHAR_DLG: + case SID_SETCONTROLDEFAULTS: + aReturn.bEnabled = m_xReportDefinition.is() && isEditable();// && getDesignView()->getCurrentControlModel().is(); + if ( aReturn.bEnabled ) + { + ::std::vector< uno::Reference< uno::XInterface > > aSelection; + getDesignView()->fillControlModelSelection(aSelection); + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin(); + for(; aIter != aSelection.end() + && !uno::Reference< report::XFixedLine >(*aIter,uno::UNO_QUERY).is() + && !uno::Reference< report::XImageControl >(*aIter,uno::UNO_QUERY).is() + && uno::Reference< report::XReportControlFormat >(*aIter,uno::UNO_QUERY).is() ;++aIter) + ; + aReturn.bEnabled = !aSelection.empty() && aIter == aSelection.end(); + } + break; + case SID_CONDITIONALFORMATTING: + { + const uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY); + aReturn.bEnabled = xFormattedField.is(); + } + break; + case SID_INSERT_FLD_PGNUMBER: + case SID_DATETIME: + aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is(); + break; + case SID_EXPORTDOC: + case SID_EXPORTDOCASPDF: + aReturn.bEnabled = m_xReportDefinition.is(); + break; + case SID_PRINTPREVIEW: + aReturn.bEnabled = sal_False; + break; + case SID_ATTR_ZOOM: + aReturn.bEnabled = sal_True; + { + SvxZoomItem aZoom(m_eZoomType,m_nZoomValue); + aZoom.SetValueSet(SVX_ZOOM_ENABLE_50|SVX_ZOOM_ENABLE_75|SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_200); + aZoom.QueryValue(aReturn.aValue); + //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue); + } + break; + case SID_ATTR_ZOOMSLIDER: + aReturn.bEnabled = sal_True; + { + SvxZoomSliderItem aZoomSlider(m_nZoomValue,20,400); + aZoomSlider.AddSnappingPoint(50); + aZoomSlider.AddSnappingPoint(75); + aZoomSlider.AddSnappingPoint(100); + aZoomSlider.AddSnappingPoint(200); + aZoomSlider.QueryValue(aReturn.aValue); + //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue); + } + break; + default: + aReturn = OReportController_BASE::GetState(_nId); + } + return aReturn; +} + +// ----------------------------------------------------------------------------- +namespace +{ + /** extracts a background color from a dispatched SID_BACKGROUND_COLOR call + + The dispatch might originate from either the toolbar, or the conditional + formatting dialog. In both cases, argument formats are different. + */ + util::Color lcl_extractBackgroundColor( const Sequence< PropertyValue >& _rDispatchArgs ) + { + util::Color aColor( COL_TRANSPARENT ); + if ( _rDispatchArgs.getLength() == 1 ) + { + OSL_VERIFY( _rDispatchArgs[0].Value >>= aColor ); + } + else + { + SequenceAsHashMap aMap( _rDispatchArgs ); + aColor = aMap.getUnpackedValueOrDefault( PROPERTY_FONTCOLOR, aColor ); + } + return aColor; + } +} + +// ----------------------------------------------------------------------------- +void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( getMutex() ); + if ( !getView() ) + { + switch(_nId) + { + case SID_RULER: + OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!"); + aArgs[0].Value >>= m_bShowRuler; + break; + case SID_HELPLINES_MOVE: + OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!"); + aArgs[0].Value >>= m_bHelplinesMove; + break; + case SID_GRID_VISIBLE: + OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!"); + aArgs[0].Value >>= m_bGridVisible; + break; + case SID_SHOW_PROPERTYBROWSER: + OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!"); + aArgs[0].Value >>= m_bShowProperties; + break; + case SID_PROPERTYBROWSER_LAST_PAGE: + OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!"); + aArgs[0].Value >>= m_sLastActivePage; + break; + case SID_SPLIT_POSITION: + OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!"); + aArgs[0].Value >>= m_nSplitPos; + break; + } + return; // return without execution + } + sal_Bool bForceBroadcast = sal_False; + switch(_nId) + { + case SID_RPT_TEXTDOCUMENT: + if ( m_xReportDefinition.is() ) + m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_TEXT ); + break; + case SID_RPT_SPREADSHEET: + if (m_xReportDefinition.is() ) + m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET ); + break; + case SID_REPORTHEADER_WITHOUT_UNDO: + case SID_REPORTFOOTER_WITHOUT_UNDO: + case SID_REPORTHEADERFOOTER: + switchReportSection(_nId); + break; + case SID_PAGEHEADER_WITHOUT_UNDO: + case SID_PAGEFOOTER_WITHOUT_UNDO: + case SID_PAGEHEADERFOOTER: + switchPageSection(_nId); + break; + case SID_GROUP_APPEND: + case SID_GROUP_REMOVE: + modifyGroup(_nId == SID_GROUP_APPEND,aArgs); + break; + case SID_GROUPHEADER_WITHOUT_UNDO: + case SID_GROUPHEADER: + createGroupSection(SID_GROUPHEADER == _nId,true,aArgs); + break; + case SID_GROUPFOOTER_WITHOUT_UNDO: + case SID_GROUPFOOTER: + createGroupSection(SID_GROUPFOOTER == _nId,false,aArgs); + break; + case SID_ADD_CONTROL_PAIR: + addPairControls(aArgs); + break; + case SID_REDO: + case SID_UNDO: + { + // const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); + // We would like to know if we are in undo mode + const OXUndoEnvironment::OUndoMode aLock( m_aReportModel->GetUndoEnv() ); + OReportController_BASE::Execute( _nId, aArgs ); + InvalidateAll(); + updateFloater(); + } + break; + case SID_CUT: + executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Cut)); + break; + case SID_COPY: + getDesignView()->Copy(); + break; + case SID_PASTE: + executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fun(&ODesignView::Paste)); + break; + + case SID_FRAME_TO_TOP: + case SID_FRAME_DOWN: + case SID_FRAME_UP: + case SID_FRAME_TO_BOTTOM: + case SID_OBJECT_HEAVEN: + case SID_OBJECT_HELL: + changeZOrder(_nId); + break; + case SID_DISTRIBUTION: + { + OSectionView* pSectionView = getCurrentSectionView(); + if ( pSectionView ) + pSectionView->DistributeMarkedObjects(); + } + break; + case SID_OBJECT_SMALLESTWIDTH: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_SMALLEST); + break; + case SID_OBJECT_SMALLESTHEIGHT: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_SMALLEST); + break; + case SID_OBJECT_GREATESTWIDTH: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_GREATEST); + break; + case SID_OBJECT_GREATESTHEIGHT: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_GREATEST); + break; + case SID_SECTION_ALIGN_LEFT: + case SID_OBJECT_ALIGN_LEFT: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::LEFT,SID_SECTION_ALIGN_LEFT == _nId); + break; + case SID_SECTION_ALIGN_CENTER: + case SID_OBJECT_ALIGN_CENTER: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_HORIZONTAL,SID_SECTION_ALIGN_CENTER == _nId); + break; + case SID_SECTION_ALIGN_RIGHT: + case SID_OBJECT_ALIGN_RIGHT: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::RIGHT,SID_SECTION_ALIGN_RIGHT == _nId); + break; + case SID_SECTION_ALIGN_UP: + case SID_OBJECT_ALIGN_UP: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::TOP,SID_SECTION_ALIGN_UP == _nId); + break; + case SID_SECTION_ALIGN_MIDDLE: + case SID_OBJECT_ALIGN_MIDDLE: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_VERTICAL,SID_SECTION_ALIGN_MIDDLE == _nId); + break; + case SID_SECTION_ALIGN_DOWN: + case SID_OBJECT_ALIGN_DOWN: + alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::BOTTOM,SID_SECTION_ALIGN_DOWN == _nId); + break; + + case SID_SECTION_SHRINK_BOTTOM: + case SID_SECTION_SHRINK_TOP: + case SID_SECTION_SHRINK: + { + uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection(); + shrinkSection(RID_STR_UNDO_SHRINK, xSection, _nId); + } + break; + + case SID_SELECTALL: + getDesignView()->SelectAll(OBJ_NONE); + break; + case SID_SELECTALL_IN_SECTION: + { + OSectionView* pSectionView = getCurrentSectionView(); + if ( pSectionView ) + pSectionView->MarkAll(); + } + break; + case SID_ESCAPE: + getDesignView()->SetMode(RPTUI_SELECT); + InvalidateFeature( SID_OBJECT_SELECT ); + break; + case SID_SELECT_ALL_EDITS: + getDesignView()->SelectAll(OBJ_DLG_FORMATTEDFIELD); + break; + case SID_SELECT_ALL_LABELS: + getDesignView()->SelectAll(OBJ_DLG_FIXEDTEXT); + break; + case SID_TERMINATE_INPLACEACTIVATION: + { + ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection(); + if ( pSection ) + pSection->getReportSection().deactivateOle(); + } + break; + case SID_SELECT: + if ( aArgs.getLength() == 1 ) + select(aArgs[0].Value); + break; + case SID_SELECT_REPORT: + select(uno::makeAny(m_xReportDefinition)); + break; + case SID_EXECUTE_REPORT: + /*m_nExecuteReportEvent = */getView()->PostUserEvent(LINK(this, OReportController,OnExecuteReport)); + break; + case SID_RPT_NEW_FUNCTION: + createNewFunction(aArgs[0].Value); + break; + case SID_COLLAPSE_SECTION: + collapseSection(true); + break; + case SID_EXPAND_SECTION: + collapseSection(false); + break; + case SID_NEXT_MARK: + markSection(true); + break; + case SID_PREV_MARK: + markSection(false); + break; + case SID_DELETE: + if ( aArgs.getLength() == 1 ) + { + uno::Reference< report::XFunction> xFunction; + aArgs[0].Value >>= xFunction; + if ( xFunction.is() ) + { + uno::Reference< report::XFunctions> xFunctions(xFunction->getParent(),uno::UNO_QUERY_THROW); + sal_Int32 nIndex = getPositionInIndexAccess(xFunctions.get(),xFunction); + const String sUndoAction = String((ModuleRes(RID_STR_UNDO_REMOVE_FUNCTION))); + UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + xFunctions->removeByIndex(nIndex); + select(uno::makeAny(xFunctions->getParent())); + InvalidateFeature( SID_SAVEDOC ); + InvalidateFeature( SID_UNDO ); + } + } + else + executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Delete)); + break; + case SID_GRID_USE: + getDesignView()->setGridSnap(m_bGridUse = !m_bGridUse); + break; + case SID_HELPLINES_MOVE: + getDesignView()->setDragStripes(m_bHelplinesMove = !m_bHelplinesMove); + break; + case SID_GRID_VISIBLE: + getDesignView()->toggleGrid(m_bGridVisible = !m_bGridVisible); + break; + case SID_RULER: + getDesignView()->showRuler(m_bShowRuler = !m_bShowRuler); + break; + case SID_OBJECT_SELECT: + getDesignView()->SetMode(RPTUI_SELECT); + InvalidateAll(); + break; + case SID_INSERT_DIAGRAM: + /*{ + OSectionView* pView = getCurrentSectionView(); + if ( pView ) + { + Reference< awt::XWindow> xWindow = VCLUnoHelper::GetInterface(getView()->Window::GetParent()); + InsertChart(m_xContext,m_xReportDefinition.get(),xWindow,pView,getSdrModel().get()); + } + }*/ + getDesignView()->SetMode( RPTUI_INSERT ); + getDesignView()->SetInsertObj( OBJ_OLE2); + createDefaultControl(aArgs); + InvalidateAll(); + break; + case SID_FM_FIXEDTEXT: + getDesignView()->SetMode( RPTUI_INSERT ); + getDesignView()->SetInsertObj( OBJ_DLG_FIXEDTEXT ); + createDefaultControl(aArgs); + InvalidateAll(); + break; + case SID_INSERT_HFIXEDLINE: + getDesignView()->SetMode( RPTUI_INSERT ); + getDesignView()->SetInsertObj( OBJ_DLG_HFIXEDLINE ); + createDefaultControl(aArgs); + InvalidateAll(); + break; + case SID_INSERT_VFIXEDLINE: + getDesignView()->SetMode( RPTUI_INSERT ); + getDesignView()->SetInsertObj( OBJ_DLG_VFIXEDLINE ); + createDefaultControl(aArgs); + InvalidateAll(); + break; + case SID_FM_EDIT: + getDesignView()->SetMode( RPTUI_INSERT ); + getDesignView()->SetInsertObj( OBJ_DLG_FORMATTEDFIELD ); + createDefaultControl(aArgs); + InvalidateAll(); + break; + case SID_FM_IMAGECONTROL: + getDesignView()->SetMode( RPTUI_INSERT ); + getDesignView()->SetInsertObj( OBJ_DLG_IMAGECONTROL ); + createDefaultControl(aArgs); + InvalidateAll(); + break; + case SID_DRAWTBX_CS_BASIC: + case SID_DRAWTBX_CS_BASIC1: + case SID_DRAWTBX_CS_BASIC2: + case SID_DRAWTBX_CS_BASIC3: + case SID_DRAWTBX_CS_BASIC4: + case SID_DRAWTBX_CS_BASIC5: + case SID_DRAWTBX_CS_BASIC6: + case SID_DRAWTBX_CS_BASIC7: + case SID_DRAWTBX_CS_BASIC8: + case SID_DRAWTBX_CS_BASIC9: + case SID_DRAWTBX_CS_BASIC10: + case SID_DRAWTBX_CS_BASIC11: + case SID_DRAWTBX_CS_BASIC12: + case SID_DRAWTBX_CS_BASIC13: + case SID_DRAWTBX_CS_BASIC14: + case SID_DRAWTBX_CS_BASIC15: + case SID_DRAWTBX_CS_BASIC16: + case SID_DRAWTBX_CS_BASIC17: + case SID_DRAWTBX_CS_BASIC18: + case SID_DRAWTBX_CS_BASIC19: + case SID_DRAWTBX_CS_BASIC20: + case SID_DRAWTBX_CS_BASIC21: + case SID_DRAWTBX_CS_BASIC22: + case SID_DRAWTBX_CS_SYMBOL1: + case SID_DRAWTBX_CS_SYMBOL2: + case SID_DRAWTBX_CS_SYMBOL3: + case SID_DRAWTBX_CS_SYMBOL4: + case SID_DRAWTBX_CS_SYMBOL5: + case SID_DRAWTBX_CS_SYMBOL6: + case SID_DRAWTBX_CS_SYMBOL7: + case SID_DRAWTBX_CS_SYMBOL8: + case SID_DRAWTBX_CS_SYMBOL9: + case SID_DRAWTBX_CS_SYMBOL10: + case SID_DRAWTBX_CS_SYMBOL11: + case SID_DRAWTBX_CS_SYMBOL12: + case SID_DRAWTBX_CS_SYMBOL13: + case SID_DRAWTBX_CS_SYMBOL14: + case SID_DRAWTBX_CS_SYMBOL15: + case SID_DRAWTBX_CS_SYMBOL16: + case SID_DRAWTBX_CS_SYMBOL17: + case SID_DRAWTBX_CS_SYMBOL18: + case SID_DRAWTBX_CS_ARROW1: + case SID_DRAWTBX_CS_ARROW2: + case SID_DRAWTBX_CS_ARROW3: + case SID_DRAWTBX_CS_ARROW4: + case SID_DRAWTBX_CS_ARROW5: + case SID_DRAWTBX_CS_ARROW6: + case SID_DRAWTBX_CS_ARROW7: + case SID_DRAWTBX_CS_ARROW8: + case SID_DRAWTBX_CS_ARROW9: + case SID_DRAWTBX_CS_ARROW10: + case SID_DRAWTBX_CS_ARROW11: + case SID_DRAWTBX_CS_ARROW12: + case SID_DRAWTBX_CS_ARROW13: + case SID_DRAWTBX_CS_ARROW14: + case SID_DRAWTBX_CS_ARROW15: + case SID_DRAWTBX_CS_ARROW16: + case SID_DRAWTBX_CS_ARROW17: + case SID_DRAWTBX_CS_ARROW18: + case SID_DRAWTBX_CS_ARROW19: + case SID_DRAWTBX_CS_ARROW20: + case SID_DRAWTBX_CS_ARROW21: + case SID_DRAWTBX_CS_ARROW22: + case SID_DRAWTBX_CS_ARROW23: + case SID_DRAWTBX_CS_ARROW24: + case SID_DRAWTBX_CS_ARROW25: + case SID_DRAWTBX_CS_ARROW26: + case SID_DRAWTBX_CS_STAR1: + case SID_DRAWTBX_CS_STAR2: + case SID_DRAWTBX_CS_STAR3: + case SID_DRAWTBX_CS_STAR4: + case SID_DRAWTBX_CS_STAR5: + case SID_DRAWTBX_CS_STAR6: + case SID_DRAWTBX_CS_STAR7: + case SID_DRAWTBX_CS_STAR8: + case SID_DRAWTBX_CS_STAR9: + case SID_DRAWTBX_CS_STAR10: + case SID_DRAWTBX_CS_STAR11: + case SID_DRAWTBX_CS_STAR12: + case SID_DRAWTBX_CS_FLOWCHART1: + case SID_DRAWTBX_CS_FLOWCHART2: + case SID_DRAWTBX_CS_FLOWCHART3: + case SID_DRAWTBX_CS_FLOWCHART4: + case SID_DRAWTBX_CS_FLOWCHART5: + case SID_DRAWTBX_CS_FLOWCHART6: + case SID_DRAWTBX_CS_FLOWCHART7: + case SID_DRAWTBX_CS_FLOWCHART8: + case SID_DRAWTBX_CS_FLOWCHART9: + case SID_DRAWTBX_CS_FLOWCHART10: + case SID_DRAWTBX_CS_FLOWCHART11: + case SID_DRAWTBX_CS_FLOWCHART12: + case SID_DRAWTBX_CS_FLOWCHART13: + case SID_DRAWTBX_CS_FLOWCHART14: + case SID_DRAWTBX_CS_FLOWCHART15: + case SID_DRAWTBX_CS_FLOWCHART16: + case SID_DRAWTBX_CS_FLOWCHART17: + case SID_DRAWTBX_CS_FLOWCHART18: + case SID_DRAWTBX_CS_FLOWCHART19: + case SID_DRAWTBX_CS_FLOWCHART20: + case SID_DRAWTBX_CS_FLOWCHART21: + case SID_DRAWTBX_CS_FLOWCHART22: + case SID_DRAWTBX_CS_FLOWCHART23: + case SID_DRAWTBX_CS_FLOWCHART24: + case SID_DRAWTBX_CS_FLOWCHART25: + case SID_DRAWTBX_CS_FLOWCHART26: + case SID_DRAWTBX_CS_FLOWCHART27: + case SID_DRAWTBX_CS_FLOWCHART28: + case SID_DRAWTBX_CS_CALLOUT1: + case SID_DRAWTBX_CS_CALLOUT2: + case SID_DRAWTBX_CS_CALLOUT3: + case SID_DRAWTBX_CS_CALLOUT4: + case SID_DRAWTBX_CS_CALLOUT5: + case SID_DRAWTBX_CS_CALLOUT6: + case SID_DRAWTBX_CS_CALLOUT7: + case SID_DRAWTBX_CS_SYMBOL: + case SID_DRAWTBX_CS_ARROW: + case SID_DRAWTBX_CS_FLOWCHART: + case SID_DRAWTBX_CS_CALLOUT: + case SID_DRAWTBX_CS_STAR: + getDesignView()->SetMode( RPTUI_INSERT ); + { + URL aUrl = getURLForId(_nId); + sal_Int32 nIndex = 1; + ::rtl::OUString sType = aUrl.Complete.getToken(0,'.',nIndex); + if ( nIndex == -1 || !sType.getLength() ) + { + switch(_nId) + { + case SID_DRAWTBX_CS_SYMBOL: + sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("smiley")); + break; + case SID_DRAWTBX_CS_ARROW: + sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("left-right-arrow")); + break; + case SID_DRAWTBX_CS_FLOWCHART: + sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("flowchart-internal-storage")); + break; + case SID_DRAWTBX_CS_CALLOUT: + sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("round-rectangular-callout")); + break; + case SID_DRAWTBX_CS_STAR: + sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("star5")); + break; + case SID_DRAWTBX_CS_BASIC: + default: + sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diamond")); + } + } + else + sType = aUrl.Complete.getToken(0,'.',nIndex); + + getDesignView()->SetInsertObj( OBJ_CUSTOMSHAPE ,sType); + createDefaultControl(aArgs); + } + InvalidateAll(); + break; + case SID_RPT_SHOWREPORTEXPLORER: + if ( isUiVisible() ) + getDesignView()->toggleReportExplorer(); + break; + case SID_FM_ADD_FIELD: + if ( isUiVisible() ) + getDesignView()->toggleAddField(); + break; + case SID_SHOW_PROPERTYBROWSER: + if ( m_bShowProperties ) + m_sLastActivePage = getDesignView()->getCurrentPage(); + else + getDesignView()->setCurrentPage(m_sLastActivePage); + + if ( isUiVisible() ) + { + m_bShowProperties = !m_bShowProperties; + if ( aArgs.getLength() == 1 ) + aArgs[0].Value >>= m_bShowProperties; + + getDesignView()->togglePropertyBrowser(m_bShowProperties); + } + break; + case SID_PROPERTYBROWSER_LAST_PAGE: // nothing to do + m_sLastActivePage = getDesignView()->getCurrentPage(); + break; + case SID_SPLIT_POSITION: + getDesignView()->Resize(); + break; + case SID_PAGEDIALOG: + case SID_ATTR_CHAR_COLOR_BACKGROUND: + { + uno::Reference<report::XSection> xSection; + if (aArgs.getLength() == 1 ) + aArgs[0].Value >>= xSection; + openPageDialog(xSection); + bForceBroadcast = sal_True; + } + break; + case SID_SORTINGANDGROUPING: + openSortingAndGroupingDialog(); + m_bGroupFloaterWasVisible = m_pGroupsFloater && m_pGroupsFloater->IsVisible(); + break; + case SID_BACKGROUND_COLOR: + { + const util::Color aColor( lcl_extractBackgroundColor( aArgs ) ); + if ( !impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CONTROLBACKGROUND,uno::makeAny(aColor),aArgs) ) + { + uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection(); + if ( xSection.is() ) + { + xSection->setBackColor( aColor ); + } + } + bForceBroadcast = sal_True; + } + break; + case SID_ATTR_CHAR_WEIGHT: + case SID_ATTR_CHAR_POSTURE: + case SID_ATTR_CHAR_UNDERLINE: + { + ::std::auto_ptr<UndoManagerListAction> pListAction; + uno::Reference< awt::XWindow> xWindow; + ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats; + lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats ); + bool bMulti = aControlsFormats.size() > 1; + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin(); + for(; aIter != aControlsFormats.end();++aIter) + { + if ( !pListAction.get() && bMulti) + { + const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT)); + pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction)); + } // if ( !pListAction.get() ) + uno::Reference< report::XReportControlFormat> xReportControlFormat(*aIter,uno::UNO_QUERY); + lcl_setFontWPU_nothrow(xReportControlFormat,_nId); + } + } + break; + case SID_ATTR_CHAR_COLOR: + case SID_ATTR_CHAR_COLOR2: + { + const SequenceAsHashMap aMap(aArgs); + const util::Color aColor = aMap.getUnpackedValueOrDefault(PROPERTY_FONTCOLOR,util::Color()); + impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARCOLOR,uno::makeAny(aColor),aArgs); + bForceBroadcast = sal_True; + } + break; + case SID_ATTR_CHAR_FONT: + if ( aArgs.getLength() == 1 ) + { + awt::FontDescriptor aFont; + if ( aArgs[0].Value >>= aFont ) + { + impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARFONTNAME,uno::makeAny(aFont.Name),aArgs); + } // if ( aArgs[0].Value >>= aFont ) + } + break; + case SID_ATTR_CHAR_FONTHEIGHT: + if ( aArgs.getLength() == 1 ) + { + float fSelVal = 0.0; + if ( aArgs[0].Value >>= fSelVal ) + impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARHEIGHT,aArgs[0].Value,aArgs); + } + break; + case SID_ATTR_PARA_ADJUST_LEFT: + case SID_ATTR_PARA_ADJUST_CENTER: + case SID_ATTR_PARA_ADJUST_RIGHT: + case SID_ATTR_PARA_ADJUST_BLOCK: + { + sal_Int16 eParagraphAdjust = style::ParagraphAdjust_LEFT; + switch(_nId) + { + case SID_ATTR_PARA_ADJUST_LEFT: + eParagraphAdjust = style::ParagraphAdjust_LEFT; + break; + case SID_ATTR_PARA_ADJUST_CENTER: + eParagraphAdjust = style::ParagraphAdjust_CENTER; + break; + case SID_ATTR_PARA_ADJUST_RIGHT: + eParagraphAdjust = style::ParagraphAdjust_RIGHT; + break; + case SID_ATTR_PARA_ADJUST_BLOCK: + eParagraphAdjust = style::ParagraphAdjust_BLOCK; + break; + } // switch(_nId) + impl_setPropertyAtControls_throw(RID_STR_UNDO_ALIGNMENT,PROPERTY_PARAADJUST,uno::makeAny(eParagraphAdjust),aArgs); + + InvalidateFeature(SID_ATTR_PARA_ADJUST_LEFT); + InvalidateFeature(SID_ATTR_PARA_ADJUST_CENTER); + InvalidateFeature(SID_ATTR_PARA_ADJUST_RIGHT); + InvalidateFeature(SID_ATTR_PARA_ADJUST_BLOCK); + } + break; + case SID_CHAR_DLG: + { + ::std::auto_ptr<UndoManagerListAction> pListAction; + uno::Sequence< beans::NamedValue > aSettings; + uno::Reference< awt::XWindow> xWindow; + ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats; + lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats ); + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin(); + for(; aIter != aControlsFormats.end();++aIter) + { + uno::Reference< report::XReportControlFormat > xFormat(*aIter,uno::UNO_QUERY); + if ( xFormat.is() ) + { + if ( !pListAction.get() ) + { + const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT)); + pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction)); + rptui::openCharDialog(xFormat,xWindow,aSettings); + } // if ( !pListAction.get() ) + applyCharacterSettings( xFormat, aSettings ); + } + } // for(; aIter != aControlsFormats.end();++aIter) + if ( !aControlsFormats.empty() ) + InvalidateAll(); + } + break; + //case SID_FM_DESIGN_MODE: + // break; + case SID_INSERT_GRAPHIC: + insertGraphic(); + break; + case SID_SETCONTROLDEFAULTS: + break; + case SID_CONDITIONALFORMATTING: + { + uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY); + if ( xFormattedField.is() ) + { + ConditionalFormattingDialog aDlg( getView(), xFormattedField.get(), *this ); + aDlg.Execute(); + } + } + break; + case SID_DATETIME: + if ( m_xReportDefinition.is() ) + { + if ( !aArgs.getLength() ) + { + ODateTimeDialog aDlg(getView(),getDesignView()->getCurrentSection(),this); + aDlg.Execute(); + } + else + createDateTime(aArgs); + } // if ( m_xReportDefinition.is() ) + break; + case SID_INSERT_FLD_PGNUMBER: + if ( m_xReportDefinition.is() ) + { + if ( !aArgs.getLength() ) + { + OPageNumberDialog aDlg(getView(),m_xReportDefinition,this); + aDlg.Execute(); + } + else + createPageNumber(aArgs); + } // if ( m_xReportDefinition.is() ) + break; + case SID_EXPORTDOC: + case SID_EXPORTDOCASPDF: + break; + case SID_PRINTPREVIEW: + if ( m_xReportDefinition.is() ) + { + } + break; + case SID_EDITDOC: + if(isEditable()) + { // the state should be changed to not editable + switch (saveModified()) + { + case RET_CANCEL: + // don't change anything here so return + return; + case RET_NO: + setModified(sal_False); // and we are not modified yet + break; + default: + break; + } + } + setEditable(!isEditable()); + //getJoinView()->setReadOnly(!isEditable()); + InvalidateAll(); + return; + case SID_GROUP: + break; + case SID_ATTR_ZOOM: + if ( aArgs.getLength() == 0 ) + { + openZoomDialog(); + } + else if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") ) + { + SvxZoomItem aZoomItem; + aZoomItem.PutValue(aArgs[0].Value); + m_nZoomValue = aZoomItem.GetValue(); + m_eZoomType = aZoomItem.GetType(); + impl_zoom_nothrow(); + } // if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") ) + break; + case SID_ATTR_ZOOMSLIDER: + if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("ZoomSlider") ) + { + SvxZoomSliderItem aZoomSlider; + aZoomSlider.PutValue(aArgs[0].Value); + m_nZoomValue = aZoomSlider.GetValue(); + m_eZoomType = SVX_ZOOM_PERCENT; + impl_zoom_nothrow(); + } + break; + default: + OReportController_BASE::Execute(_nId,aArgs); + } + InvalidateFeature(_nId,Reference< XStatusListener >(),bForceBroadcast); +} +// ----------------------------------------------------------------------------- +short OReportController::saveModified() +{ + return RET_NO; +} +// ----------------------------------------------------------------------------- +void OReportController::impl_initialize( ) +{ + OReportController_BASE::impl_initialize(); + + const ::comphelper::NamedValueCollection& rArguments( getInitParams() ); + + rArguments.get_ensureType( (::rtl::OUString)PROPERTY_REPORTNAME, m_sName ); + if ( !m_sName.getLength() ) + rArguments.get_ensureType( "DocumentTitle", m_sName ); + + try + { + if ( m_xReportDefinition.is() ) + { + //m_sName = m_xReportDefinition->getName(); + getView()->initialize(); // show the windows and fill with our informations + getUndoMgr()->Clear(); // clear all undo redo things + getSdrModel(); + if ( !m_aReportModel ) + throw Exception(); + + ::comphelper::NamedValueCollection aArgs(getModel()->getArgs()); + setMode(aArgs.getOrDefault("Mode", rtl::OUString::createFromAscii("normal"))); + + listen(true); + setEditable( !m_aReportModel->IsReadOnly() ); + m_xFormatter.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY); + m_xFormatter->attachNumberFormatsSupplier(Reference< XNumberFormatsSupplier>(m_xReportDefinition,uno::UNO_QUERY)); + + ::comphelper::MediaDescriptor aDescriptor( m_xReportDefinition->getArgs() ); + ::rtl::OUString sHierarchicalDocumentName; + sHierarchicalDocumentName = aDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HierarchicalDocumentName")),sHierarchicalDocumentName); + + if ( !sHierarchicalDocumentName.getLength() && getConnection().is() ) + { + uno::Reference<sdbcx::XTablesSupplier> xTablesSup(getConnection(),uno::UNO_QUERY_THROW); + uno::Reference<container::XNameAccess> xTables = xTablesSup->getTables(); + const uno::Sequence< ::rtl::OUString > aNames( xTables->getElementNames() ); + + if ( aNames.hasElements() ) + { + m_xReportDefinition->setCommand(aNames[0]); + m_xReportDefinition->setCommandType(sdb::CommandType::TABLE); + } + } // if ( !sHierarchicalDocumentName.getLength() && getConnection().is() ) + + m_aVisualAreaSize = m_xReportDefinition->getVisualAreaSize(0); + + } // if ( m_xReportDefinition.is() ) + + // check if chart is supported by the engine + checkChartEnabled(); + // restore the view data + getDesignView()->toggleGrid(m_bGridVisible); + getDesignView()->showRuler(m_bShowRuler); + getDesignView()->togglePropertyBrowser(m_bShowProperties); + getDesignView()->setCurrentPage(m_sLastActivePage); + getDesignView()->unmarkAllObjects(NULL); + + if ( m_nPageNum != -1 ) + { + if ( m_nPageNum < m_aReportModel->GetPageCount() ) + { + const OReportPage* pPage = dynamic_cast<OReportPage*>(m_aReportModel->GetPage(static_cast<sal_uInt16>(m_nPageNum))); + if ( pPage ) + { + uno::Sequence< beans::PropertyValue> aArgs(1); + aArgs[0].Value <<= pPage->getSection(); + executeUnChecked(SID_SELECT,aArgs); + } + } + else + m_nPageNum = -1; + } + getDesignView()->collapseSections(m_aCollapsedSections); + impl_zoom_nothrow(); + getDesignView()->Resize(); + getDesignView()->Invalidate(); + InvalidateAll(); + + if ( m_bShowProperties && m_nPageNum == -1 ) + { + m_sLastActivePage = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data")); + getDesignView()->setCurrentPage(m_sLastActivePage); + uno::Sequence< beans::PropertyValue> aArgs; + executeUnChecked(SID_SELECT_REPORT,aArgs); + } // if ( m_bShowProperties && m_nPageNum == -1 ) + + setModified(sal_False); // and we are not modified yet + + // open the global help agent + // we need a Frame but at this time there is no frame, therefore we send a UserEvent + getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent)); + } + catch(const SQLException&) + { + OSL_ENSURE(sal_False, "OReportController::initialize: caught an exception!"); + } +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OReportController, OnOpenHelpAgent, void* ,/*_pMemfun*/) +{ + //m_nExecuteReportEvent = 0; + doOpenHelpAgent(); + return 0L; +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OReportController, OnCreateHdl, OAddFieldWindow* ,_pAddFieldDlg) +{ + WaitObject aObj( getDesignView() ); + uno::Sequence< beans::PropertyValue > aArgs = _pAddFieldDlg->getSelectedFieldDescriptors(); + // we use this way to create undo actions + if ( aArgs.getLength() ) + { + executeChecked(SID_ADD_CONTROL_PAIR,aArgs); + } + return 0L; +} +// ----------------------------------------------------------------------------- + +void OReportController::doOpenHelpAgent() +{ + if (getFrame().is()) + { + rtl::OUString suURL = rtl::OUString::createFromAscii("vnd.sun.star.help://shared/text/shared/explorer/database/rep_main.xhp?UseDB=no&DbPAR=swriter"); + openHelpAgent(suURL); + // openHelpAgent(68245 /* HID_REPORT_DESIGN... UNKNOWN */ ); + // HID_APP_REPORT_TREE + } + else + { + // as long as we don't get a Frame, we send the user event again. + getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent)); + } +} +// ----------------------------------------------------------------------------- +sal_Bool OReportController::Construct(Window* pParent) +{ + ODesignView* pMyOwnView = new ODesignView( pParent, getORB(), *this ); + StartListening( *pMyOwnView ); + setView( *pMyOwnView ); + + // now that we have a view we can create the clipboard listener + m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() ); + m_aSystemClipboard.StartClipboardListening( ); + m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OReportController, OnClipboardChanged ) ); + m_pClipbordNotifier->acquire(); + m_pClipbordNotifier->AddRemoveListener( getView(), sal_True ); + + OReportController_BASE::Construct(pParent); + //getView()->Show(); + return sal_True; +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException ) +{ + if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed ) + return sal_True; + + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( getMutex() ); + + if ( getView() && getView()->IsInModalMode() ) + return sal_False; + + // this suspend will be handled in the DBAccess interceptor implementation + return sal_True; +} +// ----------------------------------------------------------------------------- +void OReportController::describeSupportedFeatures() +{ + OSingleDocumentController::describeSupportedFeatures(); + + implDescribeSupportedFeature( ".uno:TextDocument", SID_RPT_TEXTDOCUMENT, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( ".uno:Spreadsheet", SID_RPT_SPREADSHEET, CommandGroup::APPLICATION ); + + implDescribeSupportedFeature( ".uno:Redo", SID_REDO, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:Undo", SID_UNDO, CommandGroup::EDIT ); + //implDescribeSupportedFeature( ".uno:PasteSpecial", SID_PASTE, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:SelectAllInSection", SID_SELECTALL_IN_SECTION, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:Delete", SID_DELETE, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:SelectReport", SID_SELECT_REPORT, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:ExecuteReport", SID_EXECUTE_REPORT, CommandGroup::EDIT ); + + implDescribeSupportedFeature( ".uno:GridVisible", SID_GRID_VISIBLE, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:GridUse", SID_GRID_USE, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:HelplinesMove", SID_HELPLINES_MOVE, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:ShowRuler", SID_RULER, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:AddField", SID_FM_ADD_FIELD, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:ReportNavigator", SID_RPT_SHOWREPORTEXPLORER, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:ControlProperties", SID_SHOW_PROPERTYBROWSER, CommandGroup::VIEW ); + //implDescribeSupportedFeature( ".uno:SwitchControlDesignMode", SID_FM_DESIGN_MODE, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:DbSortingAndGrouping", SID_SORTINGANDGROUPING, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:PageHeaderFooter", SID_PAGEHEADERFOOTER, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:ReportHeaderFooter", SID_REPORTHEADERFOOTER, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:ZoomSlider", SID_ATTR_ZOOMSLIDER, CommandGroup::VIEW ); + implDescribeSupportedFeature( ".uno:Zoom", SID_ATTR_ZOOM, CommandGroup::VIEW ); + //implDescribeSupportedFeature( ".uno:SwitchControlDesignMode", SID_FM_DESIGN_MODE, CommandGroup::VIEW ); + + implDescribeSupportedFeature( ".uno:ConditionalFormatting", SID_CONDITIONALFORMATTING, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:PageDialog", SID_PAGEDIALOG, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:ResetAttributes", SID_SETCONTROLDEFAULTS, CommandGroup::FORMAT ); + + implDescribeSupportedFeature( ".uno:Bold", SID_ATTR_CHAR_WEIGHT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:Italic", SID_ATTR_CHAR_POSTURE, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:Underline", SID_ATTR_CHAR_UNDERLINE, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:BackColor", SID_ATTR_CHAR_COLOR_BACKGROUND, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:BackgroundColor", SID_BACKGROUND_COLOR, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:Color", SID_ATTR_CHAR_COLOR); + implDescribeSupportedFeature( ".uno:FontColor", SID_ATTR_CHAR_COLOR2, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:FontDialog", SID_CHAR_DLG, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:LeftPara", SID_ATTR_PARA_ADJUST_LEFT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:CenterPara", SID_ATTR_PARA_ADJUST_CENTER, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:RightPara", SID_ATTR_PARA_ADJUST_RIGHT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:JustifyPara", SID_ATTR_PARA_ADJUST_BLOCK, CommandGroup::FORMAT ); + + implDescribeSupportedFeature( ".uno:FontHeight", SID_ATTR_CHAR_FONTHEIGHT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:CharFontName", SID_ATTR_CHAR_FONT, CommandGroup::FORMAT ); + + implDescribeSupportedFeature( ".uno:ArrangeMenu", SID_ARRANGEMENU, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:BringToFront", SID_FRAME_TO_TOP, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:ObjectBackOne", SID_FRAME_DOWN, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:ObjectForwardOne", SID_FRAME_UP, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SendToBack", SID_FRAME_TO_BOTTOM, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SetObjectToForeground", SID_OBJECT_HEAVEN, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SetObjectToBackground", SID_OBJECT_HELL, CommandGroup::FORMAT ); + + implDescribeSupportedFeature( ".uno:ObjectAlign", SID_OBJECT_ALIGN, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:ObjectAlignLeft", SID_OBJECT_ALIGN_LEFT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:AlignCenter", SID_OBJECT_ALIGN_CENTER, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:ObjectAlignRight", SID_OBJECT_ALIGN_RIGHT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:AlignUp", SID_OBJECT_ALIGN_UP, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:AlignMiddle", SID_OBJECT_ALIGN_MIDDLE, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:AlignDown", SID_OBJECT_ALIGN_DOWN, CommandGroup::FORMAT ); + + implDescribeSupportedFeature( ".uno:SectionAlign", SID_SECTION_ALIGN, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionAlignLeft", SID_SECTION_ALIGN_LEFT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionAlignCenter", SID_SECTION_ALIGN_CENTER, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionAlignRight", SID_SECTION_ALIGN_RIGHT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionAlignTop", SID_SECTION_ALIGN_UP, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionAlignMiddle", SID_SECTION_ALIGN_MIDDLE, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionAlignBottom", SID_SECTION_ALIGN_DOWN, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionShrink", SID_SECTION_SHRINK, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionShrinkTop", SID_SECTION_SHRINK_TOP, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SectionShrinkBottom", SID_SECTION_SHRINK_BOTTOM, CommandGroup::FORMAT ); + + implDescribeSupportedFeature( ".uno:ObjectResize", SID_OBJECT_RESIZING, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SmallestWidth", SID_OBJECT_SMALLESTWIDTH, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SmallestHeight", SID_OBJECT_SMALLESTHEIGHT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:GreatestWidth", SID_OBJECT_GREATESTWIDTH, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:GreatestHeight", SID_OBJECT_GREATESTHEIGHT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:Distribution", SID_DISTRIBUTION, CommandGroup::FORMAT ); + + implDescribeSupportedFeature( ".uno:HelpMenu", SID_HELPMENU, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( ".uno:ExportTo", SID_EXPORTDOC, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( ".uno:ExportToPDF", SID_EXPORTDOCASPDF, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( ".uno:PrintPreview", SID_PRINTPREVIEW, CommandGroup::APPLICATION ); + + implDescribeSupportedFeature( ".uno:NewDoc", SID_NEWDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( ".uno:Save", SID_SAVEDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( ".uno:SaveAs", SID_SAVEASDOC, CommandGroup::DOCUMENT ); + + implDescribeSupportedFeature( ".uno:InsertPageNumberField", SID_INSERT_FLD_PGNUMBER, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:InsertDateTimeField", SID_DATETIME, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:InsertObjectChart", SID_INSERT_DIAGRAM, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:InsertGraphic", SID_INSERT_GRAPHIC, CommandGroup::INSERT ); + // controls + implDescribeSupportedFeature( ".uno:SelectObject", SID_OBJECT_SELECT, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:Label", SID_FM_FIXEDTEXT, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:Edit", SID_FM_EDIT, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ImageControl", SID_FM_IMAGECONTROL, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:HFixedLine", SID_INSERT_HFIXEDLINE, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:VFixedLine", SID_INSERT_VFIXEDLINE, CommandGroup::INSERT ); + + // shapes + implDescribeSupportedFeature( ".uno:BasicShapes", SID_DRAWTBX_CS_BASIC, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.rectangle", SID_DRAWTBX_CS_BASIC1, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.round-rectangle",SID_DRAWTBX_CS_BASIC2, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.quadrat", SID_DRAWTBX_CS_BASIC3, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.round-quadrat", SID_DRAWTBX_CS_BASIC4, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.circle", SID_DRAWTBX_CS_BASIC5, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.ellipse", SID_DRAWTBX_CS_BASIC6, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.circle-pie", SID_DRAWTBX_CS_BASIC7, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.isosceles-triangle",SID_DRAWTBX_CS_BASIC8, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.right-triangle",SID_DRAWTBX_CS_BASIC9, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.trapezoid", SID_DRAWTBX_CS_BASIC10, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.diamond", SID_DRAWTBX_CS_BASIC11, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.parallelogram", SID_DRAWTBX_CS_BASIC12, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.pentagon", SID_DRAWTBX_CS_BASIC13, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.hexagon", SID_DRAWTBX_CS_BASIC14, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.octagon", SID_DRAWTBX_CS_BASIC15, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.cross", SID_DRAWTBX_CS_BASIC16, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.ring", SID_DRAWTBX_CS_BASIC17, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.block-arc", SID_DRAWTBX_CS_BASIC18, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.can", SID_DRAWTBX_CS_BASIC19, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.cube", SID_DRAWTBX_CS_BASIC20, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.paper", SID_DRAWTBX_CS_BASIC21, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes.frame", SID_DRAWTBX_CS_BASIC22, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:SymbolShapes", SID_DRAWTBX_CS_SYMBOL, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:SymbolShapes.smiley" , SID_DRAWTBX_CS_SYMBOL1, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.sun" , SID_DRAWTBX_CS_SYMBOL2, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.moon" , SID_DRAWTBX_CS_SYMBOL3, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.lightning" , SID_DRAWTBX_CS_SYMBOL4, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.heart" , SID_DRAWTBX_CS_SYMBOL5, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.flower" , SID_DRAWTBX_CS_SYMBOL6, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.cloud" , SID_DRAWTBX_CS_SYMBOL7, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.forbidden" , SID_DRAWTBX_CS_SYMBOL8, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.puzzle" , SID_DRAWTBX_CS_SYMBOL9, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.bracket-pair" ,SID_DRAWTBX_CS_SYMBOL10, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.left-bracket" ,SID_DRAWTBX_CS_SYMBOL11, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.right-bracket",SID_DRAWTBX_CS_SYMBOL12, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.brace-pair" , SID_DRAWTBX_CS_SYMBOL13, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.left-brace" , SID_DRAWTBX_CS_SYMBOL14, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.right-brace" , SID_DRAWTBX_CS_SYMBOL15, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.quad-bevel" , SID_DRAWTBX_CS_SYMBOL16, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.octagon-bevel",SID_DRAWTBX_CS_SYMBOL17, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes.diamond-bevel",SID_DRAWTBX_CS_SYMBOL18, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow" , SID_DRAWTBX_CS_ARROW1, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow" , SID_DRAWTBX_CS_ARROW2, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow" , SID_DRAWTBX_CS_ARROW3, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow" , SID_DRAWTBX_CS_ARROW4, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow" , SID_DRAWTBX_CS_ARROW5, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow" , SID_DRAWTBX_CS_ARROW6, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow" , SID_DRAWTBX_CS_ARROW7, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-down-arrow" , SID_DRAWTBX_CS_ARROW8, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow" , SID_DRAWTBX_CS_ARROW9, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.corner-right-arrow" , SID_DRAWTBX_CS_ARROW10, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.split-arrow" , SID_DRAWTBX_CS_ARROW11, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.striped-right-arrow" , SID_DRAWTBX_CS_ARROW12, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.notched-right-arrow" , SID_DRAWTBX_CS_ARROW13, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.pentagon-right" , SID_DRAWTBX_CS_ARROW14, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.chevron" , SID_DRAWTBX_CS_ARROW15, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow-callout" , SID_DRAWTBX_CS_ARROW16, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow-callout" , SID_DRAWTBX_CS_ARROW17, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow-callout" , SID_DRAWTBX_CS_ARROW18, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow-callout" , SID_DRAWTBX_CS_ARROW19, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow-callout",SID_DRAWTBX_CS_ARROW20, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow-callout" ,SID_DRAWTBX_CS_ARROW21, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow-callout",SID_DRAWTBX_CS_ARROW22, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow-callout" , SID_DRAWTBX_CS_ARROW23, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.circular-arrow" , SID_DRAWTBX_CS_ARROW24, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.split-round-arrow" , SID_DRAWTBX_CS_ARROW25, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes.s-sharped-arrow" , SID_DRAWTBX_CS_ARROW26, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:StarShapes.bang" , SID_DRAWTBX_CS_STAR1, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.star4" , SID_DRAWTBX_CS_STAR2, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.star5" , SID_DRAWTBX_CS_STAR3, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.star6" , SID_DRAWTBX_CS_STAR4, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.star8" , SID_DRAWTBX_CS_STAR5, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.star12" , SID_DRAWTBX_CS_STAR6, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.star24" , SID_DRAWTBX_CS_STAR7, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.concave-star6" , SID_DRAWTBX_CS_STAR8, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.vertical-scroll" , SID_DRAWTBX_CS_STAR9, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.horizontal-scroll" , SID_DRAWTBX_CS_STAR10, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.signet" , SID_DRAWTBX_CS_STAR11, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes.doorplate" , SID_DRAWTBX_CS_STAR12, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-process" , SID_DRAWTBX_CS_FLOWCHART1, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-alternate-process" , SID_DRAWTBX_CS_FLOWCHART2, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-decision" , SID_DRAWTBX_CS_FLOWCHART3, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-data" , SID_DRAWTBX_CS_FLOWCHART4, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-predefined-process" , SID_DRAWTBX_CS_FLOWCHART5, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-internal-storage" , SID_DRAWTBX_CS_FLOWCHART6, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-document" , SID_DRAWTBX_CS_FLOWCHART7, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-multidocument" , SID_DRAWTBX_CS_FLOWCHART8, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-terminator" , SID_DRAWTBX_CS_FLOWCHART9, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-preparation" , SID_DRAWTBX_CS_FLOWCHART10, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-input" , SID_DRAWTBX_CS_FLOWCHART11, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-operation" , SID_DRAWTBX_CS_FLOWCHART12, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-connector" , SID_DRAWTBX_CS_FLOWCHART13, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-off-page-connector" , SID_DRAWTBX_CS_FLOWCHART14, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-card" , SID_DRAWTBX_CS_FLOWCHART15, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-punched-tape" , SID_DRAWTBX_CS_FLOWCHART16, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-summing-junction" , SID_DRAWTBX_CS_FLOWCHART17, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-or" , SID_DRAWTBX_CS_FLOWCHART18, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-collate" , SID_DRAWTBX_CS_FLOWCHART19, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sort" , SID_DRAWTBX_CS_FLOWCHART20, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-extract" , SID_DRAWTBX_CS_FLOWCHART21, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-merge" , SID_DRAWTBX_CS_FLOWCHART22, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-stored-data" , SID_DRAWTBX_CS_FLOWCHART23, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-delay" , SID_DRAWTBX_CS_FLOWCHART24, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sequential-access" , SID_DRAWTBX_CS_FLOWCHART25, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-magnetic-disk" , SID_DRAWTBX_CS_FLOWCHART26, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-direct-access-storage",SID_DRAWTBX_CS_FLOWCHART27, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-display" , SID_DRAWTBX_CS_FLOWCHART28, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:CalloutShapes.rectangular-callout" , SID_DRAWTBX_CS_CALLOUT1, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes.round-rectangular-callout" , SID_DRAWTBX_CS_CALLOUT2, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes.round-callout" , SID_DRAWTBX_CS_CALLOUT3, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes.cloud-callout" , SID_DRAWTBX_CS_CALLOUT4, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-1" , SID_DRAWTBX_CS_CALLOUT5, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-2" , SID_DRAWTBX_CS_CALLOUT6, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-3" , SID_DRAWTBX_CS_CALLOUT7, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:ArrowShapes", SID_DRAWTBX_CS_ARROW, CommandGroup::INSERT ); + + implDescribeSupportedFeature( ".uno:FlowChartShapes", SID_DRAWTBX_CS_FLOWCHART, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes", SID_DRAWTBX_CS_CALLOUT, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes", SID_DRAWTBX_CS_STAR, CommandGroup::INSERT ); + + + // keys + implDescribeSupportedFeature( ".uno:Escape", SID_ESCAPE, CommandGroup::CONTROLS); + + // internal one + implDescribeSupportedFeature( ".uno:RPT_RPTHEADER_UNDO", SID_REPORTHEADER_WITHOUT_UNDO); + implDescribeSupportedFeature( ".uno:RPT_RPTFOOTER_UNDO", SID_REPORTFOOTER_WITHOUT_UNDO); + implDescribeSupportedFeature( ".uno:RPT_PGHEADER_UNDO", SID_PAGEHEADER_WITHOUT_UNDO); + implDescribeSupportedFeature( ".uno:RPT_PGFOOTER_UNDO", SID_PAGEFOOTER_WITHOUT_UNDO); + implDescribeSupportedFeature( ".uno:DBBackgroundColor", SID_ATTR_CHAR_COLOR_BACKGROUND); + implDescribeSupportedFeature( ".uno:SID_GROUPHEADER", SID_GROUPHEADER); + implDescribeSupportedFeature( ".uno:SID_GROUPHEADER_WITHOUT_UNDO", SID_GROUPHEADER_WITHOUT_UNDO); + implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER", SID_GROUPFOOTER); + implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER_WITHOUT_UNDO", SID_GROUPFOOTER_WITHOUT_UNDO); + implDescribeSupportedFeature( ".uno:SID_GROUP_REMOVE", SID_GROUP_REMOVE); + implDescribeSupportedFeature( ".uno:SID_GROUP_APPEND", SID_GROUP_APPEND); + implDescribeSupportedFeature( ".uno:SID_ADD_CONTROL_PAIR", SID_ADD_CONTROL_PAIR); + implDescribeSupportedFeature( ".uno:SplitPosition", SID_SPLIT_POSITION); + implDescribeSupportedFeature( ".uno:LastPropertyBrowserPage", SID_PROPERTYBROWSER_LAST_PAGE); + implDescribeSupportedFeature( ".uno:Select", SID_SELECT); + implDescribeSupportedFeature( ".uno:InsertFunction", SID_RPT_NEW_FUNCTION); + implDescribeSupportedFeature( ".uno:NextMark", SID_NEXT_MARK); + implDescribeSupportedFeature( ".uno:PrevMark", SID_PREV_MARK); + implDescribeSupportedFeature( ".uno:TerminateInplaceActivation", SID_TERMINATE_INPLACEACTIVATION); + implDescribeSupportedFeature( ".uno:SelectAllLabels", SID_SELECT_ALL_LABELS); + implDescribeSupportedFeature( ".uno:SelectAllEdits", SID_SELECT_ALL_EDITS); + implDescribeSupportedFeature( ".uno:CollapseSection", SID_COLLAPSE_SECTION); + implDescribeSupportedFeature( ".uno:ExpandSection", SID_EXPAND_SECTION); +} +// ----------------------------------------------------------------------------- +SfxUndoManager* OReportController::getUndoMgr() +{ + return &m_aUndoManager; +} +// ----------------------------------------------------------------------------- +void OReportController::impl_onModifyChanged() +{ + try + { + if ( m_xReportDefinition.is() ) + m_xReportDefinition->setModified( impl_isModified() ); + OSingleDocumentController::impl_onModifyChanged(); + } + catch(uno::Exception) + { + DBG_UNHANDLED_EXCEPTION(); + } +} +// ----------------------------------------------------------------------------- +void OReportController::losingConnection( ) +{ + // let the base class do it's reconnect + OReportController_BASE::losingConnection( ); + + InvalidateAll(); +} +// ----------------------------------------------------------------------------- +void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager) +{ + if ( _xLayoutManager.is() ) + { + static const ::rtl::OUString s_sMenu[] = { + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/statusbar/statusbar")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/reportcontrols")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/drawbar")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/Formatting")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/alignmentbar")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sectionalignmentbar")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/resizebar")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sectionshrinkbar")) + }; + for (size_t i = 0; i< sizeof(s_sMenu)/sizeof(s_sMenu[0]); ++i) + { + _xLayoutManager->createElement( s_sMenu[i] ); + _xLayoutManager->requestElement( s_sMenu[i] ); + } + } // if ( _xLayoutManager.is() ) +} +// ----------------------------------------------------------------------------- +void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _bShow) +{ + uno::Reference< report::XGroup> xGroup(_rEvent.Element,uno::UNO_QUERY); + if ( xGroup.is() ) + { + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( getMutex() ); + sal_Int32 nGroupPos = 0; + _rEvent.Accessor >>= nGroupPos; + + if ( _bShow ) + { + xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this)); + xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this)); + } + else + { + xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this)); + xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this)); + } + + if ( xGroup->getHeaderOn() ) + { + groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow); + if (_bShow) + { + m_pReportControllerObserver->AddSection(xGroup->getHeader()); + } + else + { + m_pReportControllerObserver->RemoveSection(xGroup->getHeader()); + } + } + if ( xGroup->getFooterOn() ) + { + groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow); + if (_bShow) + { + m_pReportControllerObserver->AddSection(xGroup->getFooter()); + } + else + { + m_pReportControllerObserver->RemoveSection(xGroup->getFooter()); + } + } + } +} +// ----------------------------------------------------------------------------- +// ::container::XContainerListener +void SAL_CALL OReportController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException) +{ + notifyGroupSections(_rEvent,true); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException) +{ + notifyGroupSections(_rEvent,false); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::elementReplaced( const ContainerEvent& /*_rEvent*/ ) throw(RuntimeException) +{ + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( getMutex() ); + OSL_ENSURE(0,"Not yet implemented!"); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( getMutex() ); + try + { + sal_Bool bShow = sal_False; + evt.NewValue >>= bShow; + if ( evt.Source == m_xReportDefinition ) + { + if ( evt.PropertyName.equals( PROPERTY_REPORTHEADERON ) ) + { + const USHORT nPosition = m_xReportDefinition->getPageHeaderOn() ? 1 : 0; + if ( bShow ) + { + getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER,nPosition); + m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportHeader()); + } + else + { + getDesignView()->removeSection(nPosition); + } + } + else if ( evt.PropertyName.equals( PROPERTY_REPORTFOOTERON ) ) + { + USHORT nPosition = getDesignView()->getSectionCount(); + if ( m_xReportDefinition->getPageFooterOn() ) + --nPosition; + if ( bShow ) + { + getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER,nPosition); + m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportFooter()); + } + else + { + getDesignView()->removeSection(nPosition - 1); + } + } + else if ( evt.PropertyName.equals( PROPERTY_PAGEHEADERON ) ) + { + if ( bShow ) + { + getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER,0); + m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageHeader()); + } + else + { + getDesignView()->removeSection(USHORT(0)); + } + } + else if ( evt.PropertyName.equals( PROPERTY_PAGEFOOTERON ) ) + { + if ( bShow ) + { + getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER); + m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageFooter()); + } + else + { + getDesignView()->removeSection(getDesignView()->getSectionCount() - 1); + } + } + else if ( evt.PropertyName.equals( PROPERTY_COMMAND ) + || evt.PropertyName.equals( PROPERTY_COMMANDTYPE ) + || evt.PropertyName.equals( PROPERTY_ESCAPEPROCESSING ) + || evt.PropertyName.equals( PROPERTY_FILTER ) + ) + { + m_xColumns.clear(); + m_xHoldAlive.clear(); + InvalidateFeature(SID_FM_ADD_FIELD); + if ( !getDesignView()->isAddFieldVisible() && isUiVisible() ) + getDesignView()->toggleAddField(); + } + /// TODO: check what we need to notify here TitleHelper + /*else if ( evt.PropertyName.equals( PROPERTY_CAPTION ) ) + updateTitle();*/ + } // if ( evt.Source == m_xReportDefinition ) + else + { + uno::Reference< report::XGroup> xGroup(evt.Source,uno::UNO_QUERY); + if ( xGroup.is() ) + { + sal_Int32 nGroupPos = getGroupPosition(xGroup); + + groupChange(xGroup,evt.PropertyName,nGroupPos,bShow); + } + } + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::disposing( const lang::EventObject& Source ) throw(uno::RuntimeException) +{ + OReportController_BASE::disposing(Source); +} + +// ----------------------------------------------------------------------------- +USHORT lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups + ,sal_Int32 _nGroupPos + ,::std::mem_fun_t<sal_Bool,OGroupHelper>&_pGroupMemberFunction) +{ + uno::Reference< report::XGroup> xGroup; + USHORT nNonVisibleGroups = 0; + sal_Int32 nCount = _xGroups->getCount(); + for( sal_Int32 i = 0; i < _nGroupPos && i < nCount; ++i) + { + xGroup.set(_xGroups->getByIndex(i),uno::UNO_QUERY); + OSL_ENSURE(xGroup.is(),"Group is NULL! -> GPF"); + OGroupHelper aGroupHelper(xGroup); + if ( !_pGroupMemberFunction(&aGroupHelper) ) + ++nNonVisibleGroups; + } + return nNonVisibleGroups; +} +// ----------------------------------------------------------------------------- +void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGroup,const ::rtl::OUString& _sPropName,sal_Int32 _nGroupPos,bool _bShow) +{ + //adjustSectionName(_xGroup,_nGroupPos); + ::std::mem_fun_t<sal_Bool,OGroupHelper> pMemFun = ::std::mem_fun(&OGroupHelper::getHeaderOn); + ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader); + ::rtl::OUString sColor(DBGROUPHEADER); + USHORT nPosition = 0; + bool bHandle = false; + if ( _sPropName.equals( PROPERTY_HEADERON ) ) + { + nPosition = m_xReportDefinition->getPageHeaderOn() ? (m_xReportDefinition->getReportHeaderOn() ? 2 : 1) : (m_xReportDefinition->getReportHeaderOn() ? 1 : 0); + nPosition += (static_cast<USHORT>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun)); + bHandle = true; + } + else if ( _sPropName.equals( PROPERTY_FOOTERON ) ) + { + pMemFun = ::std::mem_fun(&OGroupHelper::getFooterOn); + pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter); + nPosition = getDesignView()->getSectionCount(); + + if ( m_xReportDefinition->getPageFooterOn() ) + --nPosition; + if ( m_xReportDefinition->getReportFooterOn() ) + --nPosition; + sColor = DBGROUPFOOTER; + nPosition -= (static_cast<USHORT>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun)); + if ( !_bShow ) + --nPosition; + bHandle = true; + } + if ( bHandle ) + { + if ( _bShow ) + { + OGroupHelper aGroupHelper(_xGroup); + getDesignView()->addSection(pMemFunSection(&aGroupHelper),sColor,nPosition); + } + else + { + getDesignView()->removeSection(nPosition); + } + } +} +//------------------------------------------------------------------------------ +IMPL_LINK( OReportController, OnClipboardChanged, void*, EMPTYARG ) +{ + return OnInvalidateClipboard( NULL ); +} +//------------------------------------------------------------------------------ +IMPL_LINK( OReportController, NotifyUndoActionHdl, SfxUndoAction*, _pUndoAction ) +{ + OSL_ENSURE(_pUndoAction,"UndoAction is NULL!"); + addUndoActionAndInvalidate(_pUndoAction); + return 0L; +} +//------------------------------------------------------------------------------ +IMPL_LINK(OReportController, OnInvalidateClipboard, void*, EMPTYARG) +{ + InvalidateFeature(SID_CUT); + InvalidateFeature(SID_COPY); + InvalidateFeature(SID_PASTE); + return 0L; +} +// ----------------------------------------------------------------------------- +void OReportController::openPageDialog(const uno::Reference<report::XSection>& _xSection) +{ + if ( !m_xReportDefinition.is() ) + return; + // ------------ + // UNO->ItemSet + static SfxItemInfo aItemInfos[] = + { + { SID_ATTR_LRSPACE, SFX_ITEM_POOLABLE }, + { SID_ATTR_ULSPACE, SFX_ITEM_POOLABLE }, + { SID_ATTR_PAGE, SFX_ITEM_POOLABLE }, + { SID_ATTR_PAGE_SIZE, SFX_ITEM_POOLABLE }, + { SID_ENUM_PAGE_MODE, SFX_ITEM_POOLABLE }, + { SID_PAPER_START, SFX_ITEM_POOLABLE }, + { SID_PAPER_END, SFX_ITEM_POOLABLE }, + { SID_ATTR_BRUSH, SFX_ITEM_POOLABLE }, + { SID_FLAG_TYPE, SFX_ITEM_POOLABLE }, + { SID_ATTR_METRIC, SFX_ITEM_POOLABLE } + }; + + MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); + FieldUnit eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH; + SfxPoolItem* pDefaults[] = + { + new SvxLRSpaceItem(RPTUI_ID_LRSPACE), + new SvxULSpaceItem(RPTUI_ID_ULSPACE), + new SvxPageItem(RPTUI_ID_PAGE), + new SvxSizeItem(RPTUI_ID_SIZE), + new SfxAllEnumItem(RPTUI_ID_PAGE_MODE,SVX_PAGE_MODE_STANDARD), + new SfxAllEnumItem(RPTUI_ID_START,PAPER_A4), + new SfxAllEnumItem(RPTUI_ID_END,PAPER_E), + new SvxBrushItem(ITEMID_BRUSH), + new SfxUInt16Item(RPTUI_ID_METRIC,static_cast<UINT16>(eUserMetric)) + }; + + static USHORT pRanges[] = + { + RPTUI_ID_LRSPACE,RPTUI_ID_BRUSH, + SID_ATTR_METRIC,SID_ATTR_METRIC, + 0 + }; + SfxItemPool* pPool( new SfxItemPool(String::CreateFromAscii("ReportPageProperties"), RPTUI_ID_LRSPACE,RPTUI_ID_METRIC, aItemInfos, pDefaults) ); + pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why + pPool->FreezeIdRanges(); // the same + + try + { + ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges)); + // fill it + if ( _xSection.is() ) + pDescriptor->Put(SvxBrushItem(::Color(_xSection->getBackColor()),ITEMID_BRUSH)); + else + { + pDescriptor->Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE)))); + pDescriptor->Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN) + ,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE)); + pDescriptor->Put(SvxULSpaceItem(static_cast<USHORT>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN)) + ,static_cast<USHORT>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE)); + pDescriptor->Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<UINT16>(eUserMetric))); + + uno::Reference< style::XStyle> xPageStyle(getUsedStyle(m_xReportDefinition)); + if ( xPageStyle.is() ) + { + SvxPageItem aPageItem(RPTUI_ID_PAGE); + aPageItem.SetDescName(xPageStyle->getName()); + uno::Reference<beans::XPropertySet> xProp(xPageStyle,uno::UNO_QUERY_THROW); + aPageItem.PutValue(xProp->getPropertyValue(PROPERTY_PAGESTYLELAYOUT),MID_PAGE_LAYOUT); + aPageItem.SetLandscape(getStyleProperty<sal_Bool>(m_xReportDefinition,PROPERTY_ISLANDSCAPE)); + aPageItem.SetNumType((SvxNumType)getStyleProperty<sal_Int16>(m_xReportDefinition,PROPERTY_NUMBERINGTYPE)); + pDescriptor->Put(aPageItem); + pDescriptor->Put(SvxBrushItem(::Color(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH)); + } + } + + { // want the dialog to be destroyed before our set + ORptPageDialog aDlg(getView(), pDescriptor.get(),_xSection.is() ? RID_PAGEDIALOG_BACKGROUND : RID_PAGEDIALOG_PAGE); + if (RET_OK == aDlg.Execute()) + { + // ------------ + // ItemSet->UNO + // UNO-properties + const SfxItemSet* pSet = aDlg.GetOutputItemSet(); + if ( _xSection.is() ) + { + const SfxPoolItem* pItem; + if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,sal_True,&pItem)) + _xSection->setBackColor(static_cast<const SvxBrushItem*>(pItem)->GetColor().GetColor()); + } + else + { + uno::Reference< beans::XPropertySet> xProp(getUsedStyle(m_xReportDefinition),uno::UNO_QUERY_THROW); + const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEPAGE)); + UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + const SfxPoolItem* pItem = NULL; + if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_SIZE,sal_True,&pItem)) + { + const Size aPaperSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); + uno::Any aValue; + static_cast<const SvxSizeItem*>(pItem)->QueryValue(aValue,MID_SIZE_SIZE); + xProp->setPropertyValue(PROPERTY_PAPERSIZE,aValue); + resetZoomType(); + } + + if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_LRSPACE,sal_True,&pItem)) + { + xProp->setPropertyValue(PROPERTY_LEFTMARGIN,uno::makeAny(static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft())); + xProp->setPropertyValue(PROPERTY_RIGHTMARGIN,uno::makeAny(static_cast<const SvxLRSpaceItem*>(pItem)->GetRight())); + } + if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_ULSPACE,sal_True,&pItem)) + { + xProp->setPropertyValue(PROPERTY_TOPMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetUpper())); + xProp->setPropertyValue(PROPERTY_BOTTOMMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetLower())); + } + if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_PAGE,sal_True,&pItem)) + { + const SvxPageItem* pPageItem = static_cast<const SvxPageItem*>(pItem); + xProp->setPropertyValue(PROPERTY_ISLANDSCAPE,uno::makeAny(static_cast<sal_Bool>(pPageItem->IsLandscape()))); + xProp->setPropertyValue(PROPERTY_NUMBERINGTYPE,uno::makeAny(static_cast<sal_Int16>(pPageItem->GetNumType()))); + uno::Any aValue; + pPageItem->QueryValue(aValue,MID_PAGE_LAYOUT); + xProp->setPropertyValue(PROPERTY_PAGESTYLELAYOUT,aValue); + resetZoomType(); + } + if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,sal_True,&pItem)) + { + ::Color aBackColor = static_cast<const SvxBrushItem*>(pItem)->GetColor(); + xProp->setPropertyValue(PROPERTY_BACKTRANSPARENT,uno::makeAny(aBackColor == COL_TRANSPARENT)); + xProp->setPropertyValue(PROPERTY_BACKCOLOR,uno::makeAny(aBackColor.GetColor())); + } + } + } + } + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + SfxItemPool::Free(pPool); + + for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) + delete pDefaults[i]; + +} +// ----------------------------------------------------------------------------- +sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel) throw( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getMutex() ); + m_xReportDefinition.set(xModel,uno::UNO_QUERY); + return m_xReportDefinition.is(); +} +// ----------------------------------------------------------------------------- +void OReportController::openSortingAndGroupingDialog() +{ + if ( !m_xReportDefinition.is() ) + return; + if ( !m_pGroupsFloater ) + { + m_pGroupsFloater = new OGroupsSortingDialog(getView(),!isEditable(),this); + SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_GROUPS_SORTING ) ); + if ( aDlgOpt.Exists() ) + m_pGroupsFloater->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) ); + m_pGroupsFloater->AddEventListener(LINK(this,OReportController,EventLstHdl)); + } + else if ( isUiVisible() ) + m_pGroupsFloater->Show(!m_pGroupsFloater->IsVisible()); +} +// ----------------------------------------------------------------------------- +sal_Int32 OReportController::getGroupPosition(const uno::Reference< report::XGroup >& _xGroup) +{ + return rptui::getPositionInIndexAccess(m_xReportDefinition->getGroups().get(),_xGroup); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +IMPL_LINK( OReportController, EventLstHdl, VclWindowEvent*, _pEvent ) +{ + if ( _pEvent && _pEvent->GetId() == VCLEVENT_WINDOW_CLOSE ) + { + InvalidateFeature(SID_SORTINGANDGROUPING); + InvalidateFeature(SID_FM_ADD_FIELD); + InvalidateFeature(SID_RPT_SHOWREPORTEXPLORER); + } + return 1L; +} +// ----------------------------------------------------------------------------- +void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHint) +{ + if (_rHint.ISA(DlgEdHint) + && (static_cast< DlgEdHint const & >(_rHint).GetKind() + == RPTUI_HINT_SELECTIONCHANGED)) + { + const sal_Int32 nSelectionCount = getDesignView()->getMarkedObjectCount(); + if ( m_nSelectionCount != nSelectionCount ) + { + m_nSelectionCount = nSelectionCount; + InvalidateAll(); + } + lang::EventObject aEvent(*this); + m_aSelectionListeners.forEach<view::XSelectionChangeListener>( + ::boost::bind(&view::XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent))); + + } +} +// ----------------------------------------------------------------------------- +void OReportController::executeMethodWithUndo(USHORT _nUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun) +{ + const String sUndoAction = String((ModuleRes(_nUndoStrId))); + UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + _pMemfun( getDesignView() ); + InvalidateFeature( SID_SAVEDOC ); + InvalidateFeature( SID_UNDO ); +} +// ----------------------------------------------------------------------------- +void OReportController::alignControlsWithUndo(USHORT _nUndoStrId,sal_Int32 _nControlModification,bool _bAlignAtSection) +{ + const String sUndoAction = String((ModuleRes(_nUndoStrId))); + UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + getDesignView()->alignMarkedObjects(_nControlModification,_bAlignAtSection); + InvalidateFeature( SID_SAVEDOC ); + InvalidateFeature( SID_UNDO ); +} +// ----------------------------------------------------------------------------- +void OReportController::shrinkSectionBottom(uno::Reference<report::XSection> _xSection) +{ + const sal_Int32 nElements = _xSection->getCount(); + if (nElements == 0) + { + // there are no elements + return; + } + const sal_Int32 nSectionHeight = _xSection->getHeight(); + // sal_Int32 nMinPositionY = nSectionHeight; + sal_Int32 nMaxPositionY = 0; + uno::Reference< report::XReportComponent> xReportComponent; + + // for every component get it's Y-position and compare it to the current Y-position + for (int i=0;i<nElements;i++) + { + xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY); + const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY(); + const sal_Int32 nReportComponentHeight = xReportComponent->getHeight(); + const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight; + // nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY); + nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY); + } + // now we know the minimal Y-Position and maximal Y-Position + + if (nMaxPositionY > (nSectionHeight - 7) ) // Magic Number, we use a little bit less heights for right positioning + { + // the lowest position is already 0 + return; + } + _xSection->setHeight(nMaxPositionY); +} + +void OReportController::shrinkSectionTop(uno::Reference<report::XSection> _xSection) +{ + const sal_Int32 nElements = _xSection->getCount(); + if (nElements == 0) + { + // there are no elements + return; + } + + const sal_Int32 nSectionHeight = _xSection->getHeight(); + sal_Int32 nMinPositionY = nSectionHeight; + // sal_Int32 nMaxPositionY = 0; + uno::Reference< report::XReportComponent> xReportComponent; + + // for every component get it's Y-position and compare it to the current Y-position + for (int i=0;i<nElements;i++) + { + xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY); + const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY(); + // const sal_Int32 nReportComponentHeight = xReportComponent->getHeight(); + // const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight; + nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY); + // nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY); + } + // now we know the minimal Y-Position and maximal Y-Position + if (nMinPositionY == 0) + { + // the lowest position is already 0 + return; + } + for (int i=0;i<nElements;i++) + { + xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY); + const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY(); + const sal_Int32 nNewPositionY = nReportComponentPositionY - nMinPositionY; + xReportComponent->setPositionY(nNewPositionY); + } + const sal_Int32 nNewSectionHeight = nSectionHeight - nMinPositionY; + _xSection->setHeight(nNewSectionHeight); +} + +void OReportController::shrinkSection(USHORT _nUndoStrId, uno::Reference<report::XSection> _xSection, sal_Int32 _nSid) +{ + if ( _xSection.is() ) + { + const String sUndoAction = String((ModuleRes(_nUndoStrId))); + UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + + if (_nSid == SID_SECTION_SHRINK) + { + shrinkSectionTop(_xSection); + shrinkSectionBottom(_xSection); + } + else if (_nSid == SID_SECTION_SHRINK_TOP) + { + shrinkSectionTop(_xSection); + } + else if (_nSid == SID_SECTION_SHRINK_BOTTOM) + { + shrinkSectionBottom(_xSection); + } + } + + InvalidateFeature( SID_SAVEDOC ); + InvalidateFeature( SID_UNDO ); +} + +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL OReportController::getViewData(void) throw( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getMutex() ); + typedef ::std::pair< ::rtl::OUString,sal_uInt16> TStringIntPair; + const TStringIntPair pViewDataList[] = + { + TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GridVisible")), SID_GRID_VISIBLE) + ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GridUse")), SID_GRID_USE) + ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelplinesMove")), SID_HELPLINES_MOVE) + ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowRuler")), SID_RULER) + ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlProperties")), SID_SHOW_PROPERTYBROWSER) + ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LastPropertyBrowserPage")),SID_PROPERTYBROWSER_LAST_PAGE) + ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SplitPosition")), SID_SPLIT_POSITION) + }; + + uno::Sequence<beans::PropertyValue> aCommandProps(sizeof(pViewDataList)/sizeof(pViewDataList[0])); + beans::PropertyValue* pIter = aCommandProps.getArray(); + beans::PropertyValue* pEnd = pIter + aCommandProps.getLength(); + for (sal_Int32 i = 0; pIter != pEnd; ++pIter,++i) + { + FeatureState aFeatureState = GetState(pViewDataList[i].second); + pIter->Name = pViewDataList[i].first; + if ( !!aFeatureState.bChecked ) + pIter->Value <<= (*aFeatureState.bChecked) ? sal_True : sal_False; + else if ( aFeatureState.aValue.hasValue() ) + pIter->Value = aFeatureState.aValue; + + } // for (; pIter != pEnd; ++pIter) + + uno::Sequence<beans::PropertyValue> aProps(1); + aProps[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CommandProperties")); + aProps[0].Value <<= aCommandProps; + + if ( getDesignView() ) + { + ::std::vector<sal_uInt16> aCollapsedPositions; + getDesignView()->fillCollapsedSections(aCollapsedPositions); + if ( !aCollapsedPositions.empty() ) + { + uno::Sequence<beans::PropertyValue> aCollapsedSections(aCollapsedPositions.size()); + beans::PropertyValue* pCollapsedIter = aCollapsedSections.getArray(); + ::std::vector<sal_uInt16>::iterator aIter = aCollapsedPositions.begin(); + ::std::vector<sal_uInt16>::iterator aEnd = aCollapsedPositions.end(); + for (sal_Int32 i = 1; aIter != aEnd ; ++aIter,++pCollapsedIter,++i) + { + pCollapsedIter->Name = PROPERTY_SECTION + ::rtl::OUString::valueOf(i); + pCollapsedIter->Value <<= static_cast<sal_Int32>(*aIter); + } + const sal_Int32 nCount = aProps.getLength(); + aProps.realloc( nCount + 1 ); + aProps[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CollapsedSections")); + aProps[nCount].Value <<= aCollapsedSections; + } + + ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection(); + if ( pSectionWindow.get() ) + { + const sal_Int32 nCount = aProps.getLength(); + aProps.realloc( nCount + 1 ); + aProps[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MarkedSection")); + aProps[nCount].Value <<= (sal_Int32)pSectionWindow->getReportSection().getPage()->GetPageNum(); + } // if ( pSectionWindow.get() ) + } // if ( getDesignView() ) + const sal_Int32 nCount = aProps.getLength(); + aProps.realloc( nCount + 1 ); + aProps[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZoomFactor")); + aProps[nCount].Value <<= m_nZoomValue; + return uno::makeAny(aProps); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::restoreViewData(const uno::Any& Data) throw( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( getMutex() ); + uno::Sequence<beans::PropertyValue> aProps; + if ( Data >>= aProps ) + { + const beans::PropertyValue* pPropsIter = aProps.getConstArray(); + const beans::PropertyValue* pPropsEnd = pPropsIter + aProps.getLength(); + for (sal_Int32 i = 0; pPropsIter != pPropsEnd; ++pPropsIter,++i) + { + if ( pPropsIter->Name.equalsAscii("CommandProperties") ) + { + util::URL aCommand; + uno::Sequence< beans::PropertyValue> aArgs(1); + beans::PropertyValue* pArg = aArgs.getArray(); + pArg->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); + uno::Sequence< beans::PropertyValue> aCommandProps; + if ( pPropsIter->Value >>= aCommandProps ) + { + const beans::PropertyValue* pIter = aCommandProps.getConstArray(); + const beans::PropertyValue* pEnd = pIter + aCommandProps.getLength(); + for (; pIter != pEnd; ++pIter) + { + pArg->Value = pIter->Value; + if ( pArg->Value.hasValue() ) + { + aCommand.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:")) + pIter->Name; + executeUnChecked(aCommand,aArgs); + } + } + } + } + else if ( pPropsIter->Name.equalsAscii("CollapsedSections") ) + pPropsIter->Value >>= m_aCollapsedSections; + else if ( pPropsIter->Name.equalsAscii("MarkedSection") ) + pPropsIter->Value >>= m_nPageNum; + else if ( pPropsIter->Name.equalsAscii("ZoomFactor") ) + pPropsIter->Value >>= m_nZoomValue; + } + } +} +// ----------------------------------------------------------------------------- +void OReportController::updateFloater() +{ + if ( m_pGroupsFloater && m_pGroupsFloater->IsVisible() ) + m_pGroupsFloater->UpdateData(); +} + +// ----------------------------------------------------------------------------- +Reference<XFrame> OReportController::getXFrame() +{ + if ( !m_xFrameLoader.is() ) + { + m_xFrameLoader.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))),uno::UNO_QUERY_THROW); + } + const sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE; + const ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank")); + Reference<XFrame> xFrame = Reference<XFrame>(m_xFrameLoader,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag); + return xFrame; +} + +// ----------------------------------------------------------------------------- +uno::Reference<frame::XModel> OReportController::executeReport() +{ + OSL_ENSURE(m_xReportDefinition.is(),"Where is my report?"); + + uno::Reference<frame::XModel> xModel; + if ( m_xReportDefinition.is() ) + { + sal_uInt16 nErrorId = RID_ERR_NO_COMMAND; + bool bEnabled = m_xReportDefinition->getCommand().getLength() != 0; + if ( bEnabled ) + { + bEnabled = false; + const sal_uInt16 nCount = m_aReportModel->GetPageCount(); + sal_uInt16 i = 0; + for (; i < nCount && !bEnabled ; ++i) + { + const SdrPage* pPage = m_aReportModel->GetPage(i); + bEnabled = pPage->GetObjCount() != 0; + } + if ( !bEnabled ) + nErrorId = RID_ERR_NO_OBJECTS; + } + + dbtools::SQLExceptionInfo aInfo; + if ( !bEnabled ) + { + sdb::SQLContext aFirstMessage; + String sInfo = String( ModuleRes( nErrorId ) ); + aFirstMessage.Message = sInfo; + aInfo = aFirstMessage; + if ( isEditable() ) + { + sal_uInt16 nCommand = 0; + if ( nErrorId == RID_ERR_NO_COMMAND ) + { + if ( !m_bShowProperties ) + executeUnChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue>()); + + m_sLastActivePage = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data")); + getDesignView()->setCurrentPage(m_sLastActivePage); + nCommand = SID_SELECT_REPORT; + } + else if ( getDesignView() && !getDesignView()->isAddFieldVisible() ) + { + nCommand = SID_FM_ADD_FIELD; + } + if ( nCommand ) + { + uno::Sequence< beans::PropertyValue> aArgs; + executeUnChecked(nCommand,aArgs); + } + } + } + else + { + m_bInGeneratePreview = true; + try + { + WaitObject aWait(getView()); // cursor + if ( !m_xReportEngine.is() ) + m_xReportEngine.set(getORB()->createInstance(SERVICE_REPORTENGINE),uno::UNO_QUERY_THROW); + m_xReportEngine->setReportDefinition(m_xReportDefinition); + m_xReportEngine->setActiveConnection(getConnection()); + Reference<XFrame> xFrame = getXFrame(); + xModel = m_xReportEngine->createDocumentAlive(xFrame); + } + catch( const sdbc::SQLException& /*e*/ ) + { // SQLExceptions and derived exceptions must not be translated + aInfo = ::cppu::getCaughtException(); + } + catch(const uno::Exception& e) + { + uno::Any aCaughtException( ::cppu::getCaughtException() ); + + // our first message says: we caught an exception + sdb::SQLContext aFirstMessage; + String sInfo = String( ModuleRes( RID_STR_CAUGHT_FOREIGN_EXCEPTION ) ); + sInfo.SearchAndReplaceAllAscii( "$type$", aCaughtException.getValueTypeName() ); + aFirstMessage.Message = sInfo; + + // our second message: the message of the exception we caught + sdbc::SQLException aSecondMessage; + aSecondMessage.Message = e.Message; + aSecondMessage.Context = e.Context; + + // maybe our third message: the message which is wrapped in the exception we caught + sdbc::SQLException aThirdMessage; + lang::WrappedTargetException aWrapped; + if ( aCaughtException >>= aWrapped ) + { + aThirdMessage.Message = aWrapped.Message; + aThirdMessage.Context = aWrapped.Context; + } + + if ( aThirdMessage.Message.getLength() ) + aSecondMessage.NextException <<= aThirdMessage; + aFirstMessage.NextException <<= aSecondMessage; + + aInfo = aFirstMessage; + } + if (aInfo.isValid()) + { + const String suSQLContext = String( ModuleRes( RID_STR_COULD_NOT_CREATE_REPORT ) ); + aInfo.prepend(suSQLContext); + } // if (aInfo.isValid()) + m_bInGeneratePreview = false; + } + + if (aInfo.isValid()) + { + showError(aInfo); + } + } + return xModel; +} +// ----------------------------------------------------------------------------- +uno::Reference< frame::XModel > SAL_CALL OReportController::getModel(void) throw( uno::RuntimeException ) +{ + return m_xReportDefinition.get(); +} +// ----------------------------------------------------------------------------- +uno::Reference< sdbc::XRowSet > OReportController::getRowSet() +{ + OSL_PRECOND( m_xReportDefinition.is(), "OReportController::getRowSet: no report definition?!" ); + + if ( m_xRowSet.is() || !m_xReportDefinition.is() ) + return m_xRowSet; + + try + { + uno::Reference< sdbc::XRowSet > xRowSet( getORB()->createInstance( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.RowSet" ) ) ), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet> xRowSetProp( xRowSet, uno::UNO_QUERY_THROW ); + + xRowSetProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, uno::makeAny( getConnection() ) ); + xRowSetProp->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( sal_True ) ); + + ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter()); + TPropertyNamePair aPropertyMediation; + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMAND, TPropertyConverter(PROPERTY_COMMAND,aNoConverter) ) ); + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMANDTYPE, TPropertyConverter(PROPERTY_COMMANDTYPE,aNoConverter) ) ); + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_ESCAPEPROCESSING, TPropertyConverter(PROPERTY_ESCAPEPROCESSING,aNoConverter) ) ); + aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_FILTER, TPropertyConverter(PROPERTY_FILTER,aNoConverter) ) ); + + m_xRowSetMediator = new OPropertyMediator( m_xReportDefinition.get(), xRowSetProp, aPropertyMediation ); + m_xRowSet = xRowSet; + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return m_xRowSet; +} +// ----------------------------------------------------------------------------- +void OReportController::insertGraphic() +{ + const String sTitle(ModuleRes(RID_STR_IMPORT_GRAPHIC)); + // build some arguments for the upcoming dialog + try + { + uno::Reference< report::XSection> xSection = getDesignView()->getCurrentSection(); + ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, SFXWB_GRAPHIC ); + aDialog.SetTitle( sTitle ); + + uno::Reference< ui::dialogs::XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY_THROW); + xController->setValue(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True)); + xController->enableControl(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False/*sal_True*/); + sal_Bool bLink = sal_True; + xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, ::cppu::bool2any( bLink ) ); + + if ( ERRCODE_NONE == aDialog.Execute() ) + { + xController->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bLink; + uno::Sequence<beans::PropertyValue> aArgs(2); + aArgs[0].Name = PROPERTY_IMAGEURL; + aArgs[0].Value <<= ::rtl::OUString(aDialog.GetPath()); + aArgs[1].Name = PROPERTY_PRESERVEIRI; + aArgs[1].Value <<= bLink; + createControl(aArgs,xSection,::rtl::OUString(),OBJ_DLG_IMAGECONTROL); + } + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } +} +// ----------------------------------------------------------------------------- +::boost::shared_ptr<rptui::OReportModel> OReportController::getSdrModel() +{ + if ( !m_aReportModel ) + { + m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition); + if ( m_aReportModel ) + { + m_aReportModel->attachController( *this ); + m_aReportModel->SetNotifyUndoActionHdl(LINK( this, OReportController, NotifyUndoActionHdl )); + } + } + return m_aReportModel; +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL OReportController::select( const Any& aSelection ) throw (IllegalArgumentException, RuntimeException) +{ + ::osl::MutexGuard aGuard( getMutex() ); + ::sal_Bool bRet = sal_True; + if ( getDesignView() ) + { + getDesignView()->unmarkAllObjects(NULL); + getDesignView()->SetMode(RPTUI_SELECT); + + uno::Sequence< uno::Reference<report::XReportComponent> > aElements; + if ( aSelection >>= aElements ) + { + if ( aElements.getLength() > 0 ) + getDesignView()->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY)); + getDesignView()->setMarked(aElements,sal_True); + } + else + { + uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY); + uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY); + if ( xProp.is() ) + { + getDesignView()->showProperties(xObject); + aElements.realloc(1); + aElements[0] = xProp; + getDesignView()->setMarked(aElements,sal_True); + } + else + { + uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY); + if ( !xSection.is() && xObject.is() ) + getDesignView()->showProperties(xObject); + getDesignView()->setMarked(xSection,xSection.is()); + } + } + InvalidateAll(); + } + return bRet; +} +// ----------------------------------------------------------------------------- +Any SAL_CALL OReportController::getSelection( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( getMutex() ); + Any aRet; + if ( getDesignView() ) + { + aRet = getDesignView()->getCurrentlyShownProperty(); + if ( !aRet.hasValue() ) + aRet <<= getDesignView()->getCurrentSection(); + } + return aRet; +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException) +{ + m_aSelectionListeners.addInterface( _Listener ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException) +{ + m_aSelectionListeners.removeInterface( _Listener ); +} +// ----------------------------------------------------------------------------- +void OReportController::createNewFunction(const uno::Any& _aValue) +{ + uno::Reference< container::XIndexContainer> xFunctions(_aValue,uno::UNO_QUERY_THROW); + const ::rtl::OUString sNewName = String(ModuleRes(RID_STR_FUNCTION)); + uno::Reference< report::XFunction> xFunction(report::Function::create(m_xContext)); + xFunction->setName(sNewName); + // the call below will also create an undo action -> listener + xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(xFunction)); +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OReportController, OnExecuteReport, void* ,/*_pMemfun*/) +{ + //m_nExecuteReportEvent = 0; + executeReport(); + return 0L; +} +// ----------------------------------------------------------------------------- +void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,const uno::Reference< report::XSection>& _xSection,const ::rtl::OUString& _sFunction,sal_uInt16 _nObjectId) +{ + SequenceAsHashMap aMap(_aArgs); + getDesignView()->setMarked(_xSection ,sal_True); + ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection(); + if ( !pSectionWindow ) + return; + + OSL_ENSURE(pSectionWindow->getReportSection().getSection() == _xSection,"Invalid section after marking the corrct one."); + + sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN); + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin; + awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0)); + if ( aPos.X < nLeftMargin ) + aPos.X = nLeftMargin; + + SdrObject* pNewControl = NULL; + uno::Reference< report::XReportComponent> xShapeProp; + if ( _nObjectId == OBJ_CUSTOMSHAPE ) + { + pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() ); + xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY); + ::rtl::OUString sCustomShapeType = getDesignView()->GetInsertObjString(); + if ( !sCustomShapeType.getLength() ) + sCustomShapeType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diamond")); + pSectionWindow->getReportSection().createDefault(sCustomShapeType,pNewControl); + pNewControl->SetLogicRect(Rectangle(3000,500,6000,3500)); // switch height and width + } // if ( _nObjectId == OBJ_CUSTOMSHAPE ) + else if ( _nObjectId == OBJ_OLE2 || OBJ_DLG_SUBREPORT == _nObjectId ) + { + pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() ); + + pNewControl->SetLogicRect(Rectangle(3000,500,8000,5500)); // switch height and width + xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW); + OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl); + if ( pObj && !pObj->IsEmpty() ) + { + pObj->initializeChart(getModel()); + } + } + else + { + SdrUnoObj* pLabel( NULL ); + SdrUnoObj* pControl( NULL ); + FmFormView::createControlLabelPair( getDesignView() + ,nLeftMargin,0 + ,NULL,NULL,_nObjectId,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT, + NULL,pSectionWindow->getReportSection().getPage(),m_aReportModel.get(), + pLabel,pControl); + delete pLabel; + + pNewControl = pControl; + OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl); + uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY); + xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY); + uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo(); + uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo(); + + const ::rtl::OUString sProps[] = { PROPERTY_NAME + ,PROPERTY_FONTDESCRIPTOR + ,PROPERTY_FONTDESCRIPTORASIAN + ,PROPERTY_FONTDESCRIPTORCOMPLEX + ,PROPERTY_ORIENTATION + ,PROPERTY_BORDER + ,PROPERTY_FORMATSSUPPLIER + ,PROPERTY_BACKGROUNDCOLOR + }; + for(size_t i = 0; i < sizeof(sProps)/sizeof(sProps[0]);++i) + { + if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) ) + xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i])); + } // for(size_t i = 0; i < sizeof(sProps)/sizeof(sProps[0]);++i) + + if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) ) + xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER)); + + + if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && _sFunction.getLength() ) + { + ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction ); + xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) ); + } + + sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0)); + if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) ) + xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) ); + + ::rtl::OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,::rtl::OUString()); + if ( sUrl.getLength() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) ) + xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) ); + + pObj->CreateMediator(sal_True); + + if ( _nObjectId == OBJ_DLG_FIXEDTEXT ) // special case for fixed text + xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj))); + else if ( _nObjectId == OBJ_DLG_VFIXEDLINE ) + { + awt::Size aOlSize = xShapeProp->getSize(); + xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width + } + } + + const sal_Int32 nShapeWidth = aMap.getUnpackedValueOrDefault(PROPERTY_WIDTH,xShapeProp->getWidth()); + if ( nShapeWidth != xShapeProp->getWidth() ) + xShapeProp->setWidth( nShapeWidth ); + + const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth; + if ( bChangedPos ) + aPos.X = nPaperWidth - nShapeWidth; + xShapeProp->setPosition(aPos); + + correctOverlapping(pNewControl,pSectionWindow->getReportSection()); +} +// ----------------------------------------------------------------------------- +void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs) +{ + getDesignView()->unmarkAllObjects(NULL); + + const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL)); + UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + + SequenceAsHashMap aMap(_aArgs); + aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0))); + + uno::Reference< report::XSection> xSection = aMap.getUnpackedValueOrDefault(PROPERTY_SECTION,uno::Reference< report::XSection>()); + ::rtl::OUString sFunction; + + sal_Bool bDate = aMap.getUnpackedValueOrDefault(PROPERTY_DATE_STATE,sal_False); + if ( bDate ) + { + sFunction = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("TODAY()")); + createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction); + } + sal_Bool bTime = aMap.getUnpackedValueOrDefault(PROPERTY_TIME_STATE,sal_False); + if ( bTime ) + { + sFunction = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("TIMEVALUE(NOW())")); + aMap[PROPERTY_FORMATKEY] <<= aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYTIME,sal_Int32(0)); + createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction); + } +} +// ----------------------------------------------------------------------------- +void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs) +{ + getDesignView()->unmarkAllObjects(NULL); + + const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL)); + UndoManagerListAction aListAction(m_aUndoManager,sUndoAction); + + if ( !m_xReportDefinition->getPageHeaderOn() ) + { + uno::Sequence< beans::PropertyValue > aArgs; + executeChecked(SID_PAGEHEADERFOOTER,aArgs); + } // if ( !m_xHoldAlive->getPageHeaderOn() ) + + SequenceAsHashMap aMap(_aArgs); + sal_Bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE,sal_False); + + String sFunction = String(ModuleRes(STR_RPT_PN_PAGE)); + ::rtl::OUString sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()")); + sFunction.SearchAndReplace(String::CreateFromAscii("#PAGENUMBER#"),sPageNumber); + + if ( bStateOfPage ) + { + ::rtl::OUString sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()")); + sFunction += String(ModuleRes(STR_RPT_PN_PAGE_OF)); + sFunction.SearchAndReplace(String::CreateFromAscii("#PAGECOUNT#"),sPageCount); + } + + sal_Bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON,sal_True); + createControl(_aArgs,bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter(),sFunction); +} + +// ----------------------------------------------------------------------------- +void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) +{ + getDesignView()->unmarkAllObjects(NULL); + ////////////////////////////////////////////////////////////////////// + // Anhand des FormatKeys wird festgestellt, welches Feld benoetigt wird + ::boost::shared_ptr<OSectionWindow> pSectionWindow[2]; + pSectionWindow[0] = getDesignView()->getMarkedSection(); + + if ( !pSectionWindow[0] ) + { + select(uno::makeAny(m_xReportDefinition->getDetail())); + pSectionWindow[0] = getDesignView()->getMarkedSection(); + if ( !pSectionWindow[0] ) + return; + } + + uno::Reference<report::XSection> xCurrentSection = getDesignView()->getCurrentSection(); + UndoManagerListAction aUndo( *getUndoMgr(), String( ModuleRes( RID_STR_UNDO_INSERT_CONTROL ) ) ); + + try + { + bool bHandleOnlyOne = false; + const PropertyValue* pIter = aArgs.getConstArray(); + const PropertyValue* pEnd = pIter + aArgs.getLength(); + for(;pIter != pEnd && !bHandleOnlyOne;++pIter) + { + Sequence< PropertyValue > aValue; + if ( !(pIter->Value >>= aValue) ) + { // the sequence has only one element which already contains the descriptor + bHandleOnlyOne = true; + aValue = aArgs; + } + ::svx::ODataAccessDescriptor aDescriptor(aValue); + SequenceAsHashMap aMap(aValue); + uno::Reference<report::XSection> xSection = aMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Section")),xCurrentSection); + uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition(); + + getDesignView()->setMarked(xSection,sal_True); + pSectionWindow[0] = getDesignView()->getMarkedSection(); + + sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN); + awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0)); + if ( aPos.X < nLeftMargin ) + aPos.X = nLeftMargin; + + // LLA: new feature, add the Label in dependency of the given DND_ACTION one section up, normal or one section down + sal_Int8 nDNDAction = aMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DNDAction")), sal_Int8(0)); + pSectionWindow[1] = pSectionWindow[0]; + // ::boost::shared_ptr<OReportSection> pReportSectionPost; + sal_Bool bLabelAboveTextField = nDNDAction == DND_ACTION_COPY; + if ( bLabelAboveTextField || nDNDAction == DND_ACTION_LINK ) + { + // Add the Label one Section up + pSectionWindow[1] = getDesignView()->getMarkedSection(bLabelAboveTextField ? PREVIOUS : POST); + if (!pSectionWindow[1]) + { + // maybe out of bounds + pSectionWindow[1] = pSectionWindow[0]; + } + } + // clear all selections + getDesignView()->unmarkAllObjects(NULL); + + uno::Reference< beans::XPropertySet > xField( aDescriptor[ ::svx::daColumnObject ], uno::UNO_QUERY ); + uno::Reference< lang::XComponent > xHoldAlive; + if ( !xField.is() ) + { + ::rtl::OUString sCommand; + ::rtl::OUString sColumnName; + sal_Int32 nCommandType( -1 ); + OSL_VERIFY( aDescriptor[ ::svx::daCommand ] >>= sCommand ); + OSL_VERIFY( aDescriptor[ ::svx::daColumnName ] >>= sColumnName ); + OSL_VERIFY( aDescriptor[ ::svx::daCommandType ] >>= nCommandType ); + + uno::Reference< container::XNameAccess > xColumns; + uno::Reference< sdbc::XConnection > xConnection( getConnection() ); + if ( sCommand.getLength() && nCommandType != -1 && sColumnName.getLength() && xConnection.is() ) + { + if ( !xReportDefinition->getCommand().getLength() ) + { + xReportDefinition->setCommand(sCommand); + xReportDefinition->setCommandType(nCommandType); + } // if ( !xReportDefinition->getCommand().getLength() ) + + xColumns = dbtools::getFieldsByCommandDescriptor(xConnection,nCommandType,sCommand,xHoldAlive); + if ( xColumns.is() && xColumns->hasByName(sColumnName) ) + xField.set( xColumns->getByName( sColumnName ), uno::UNO_QUERY ); + } + + if ( !xField.is() ) + { + #if OSL_DEBUG_LEVEL > 0 + try + { + uno::Reference< beans::XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW ); + ::rtl::OUString sRowSetCommand; + sal_Int32 nRowSetCommandType( -1 ); + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sRowSetCommand ); + OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nRowSetCommandType ); + OSL_ENSURE( ( sRowSetCommand == sCommand ) && ( nCommandType == nRowSetCommandType ), + "OReportController::addPairControls: this only works for a data source which equals our current settings!" ); + // if this asserts, then either our row set and our report definition are not in sync, or somebody + // requested the creation of a control/pair for another data source than what our report + // definition is bound to - which is not supported for the parameters case, since we + // can retrieve parameters from the RowSet only. + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + #endif + + // no column name - perhaps a parameter name? + uno::Reference< sdb::XParametersSupplier > xSuppParam( getRowSet(), uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xParams( xSuppParam->getParameters(), uno::UNO_QUERY_THROW ); + sal_Int32 nParamCount( xParams->getCount() ); + for ( sal_Int32 i=0; i<nParamCount; ++i) + { + uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW ); + ::rtl::OUString sParamName; + OSL_VERIFY( xParamCol->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sParamName ); + if ( sParamName == sColumnName ) + { + xField = xParamCol; + break; + } + } + } + } + if ( !xField.is() ) + continue; + + sal_uInt16 nOBJID = 0; + sal_Int32 nDataType = sdbc::DataType::BINARY; + xField->getPropertyValue(PROPERTY_TYPE) >>= nDataType; + switch ( nDataType ) + { + case sdbc::DataType::BINARY: + case sdbc::DataType::VARBINARY: + case sdbc::DataType::LONGVARBINARY: + nOBJID = OBJ_DLG_IMAGECONTROL; + break; + default: + nOBJID = OBJ_DLG_FORMATTEDFIELD; + break; + } + + if ( !nOBJID ) + continue; + + Reference< util::XNumberFormatsSupplier > xSupplier = getReportNumberFormatter()->getNumberFormatsSupplier(); + if ( !xSupplier.is() ) + continue; + + Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats()); + SdrUnoObj* pControl[2]; + pControl[0] = NULL; + pControl[1] = NULL; + //getDesignView()->GetModel()->GetUndoEnv().Lock(); + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN); + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin; + OSectionView* pSectionViews[2]; + pSectionViews[0] = &pSectionWindow[1]->getReportSection().getSectionView(); + pSectionViews[1] = &pSectionWindow[0]->getReportSection().getSectionView(); + // find this in svx + FmFormView::createControlLabelPair( getDesignView() + ,nLeftMargin,0 + ,xField,xNumberFormats,nOBJID,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT, + pSectionWindow[1]->getReportSection().getPage(),pSectionWindow[0]->getReportSection().getPage(),m_aReportModel.get(), + pControl[0],pControl[1]); + //getDesignView()->GetModel()->GetUndoEnv().UnLock(); + if ( pControl[0] && pControl[1] ) + { + SdrPageView* pPgViews[2]; + pPgViews[0] = pSectionViews[0]->GetSdrPageView(); + pPgViews[1] = pSectionViews[1]->GetSdrPageView(); + if ( pPgViews[0] && pPgViews[1] ) + { + ::rtl::OUString sDefaultName; + size_t i = 0; + OUnoObject* pObjs[2]; + for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) + { + pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i]); + uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW); + uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW); + xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME)); + + uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo(); + uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo(); + const ::rtl::OUString sProps[] = { PROPERTY_FONTDESCRIPTOR + ,PROPERTY_FONTDESCRIPTORASIAN + ,PROPERTY_FONTDESCRIPTORCOMPLEX + ,PROPERTY_BORDER + ,PROPERTY_BACKGROUNDCOLOR + }; + for(size_t k = 0; k < sizeof(sProps)/sizeof(sProps[0]);++k) + { + if ( xInfo->hasPropertyByName(sProps[k]) && xShapeInfo->hasPropertyByName(sProps[k]) ) + xUnoProp->setPropertyValue(sProps[k],xShapeProp->getPropertyValue(sProps[k])); + } + if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) ) + { + ::rtl::OUString sName; + xUnoProp->getPropertyValue(PROPERTY_DATAFIELD) >>= sName; + sDefaultName = sName; + xUnoProp->setPropertyValue(PROPERTY_NAME,uno::makeAny(sDefaultName)); + + ReportFormula aFormula( ReportFormula::Field, sName ); + xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFormula.getCompleteFormula() ) ); + } // if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) ) + + if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) ) + xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER)); + + pObjs[i]->CreateMediator(sal_True); + // need SectionView from the above or follow Section + // (getMarkedSection) returns the current Section + //pSectionViews[i]->InsertObjectAtView(pControl[i],*pPgViews[i],SDRINSERT_ADDMARK); + + const sal_Int32 nShapeWidth = xShapeProp->getWidth(); + const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth; + if ( bChangedPos ) + aPos.X = nPaperWidth - nShapeWidth; + xShapeProp->setPosition(aPos); + if ( bChangedPos ) + aPos.Y += xShapeProp->getHeight(); + aPos.X += nShapeWidth; + } + ::rtl::OUString sLabel; + if ( xField->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) + xField->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + + if (pSectionViews[0] != pSectionViews[1] && + nOBJID == OBJ_DLG_FORMATTEDFIELD) // we want this nice feature only at FORMATTEDFIELD + { + // we have two different Views, so set the position x new. + // pSectionViews[1].position.x = pSectionViews[0].position.x + uno::Reference< report::XReportComponent> xShapePropLabel(pObjs[0]->getUnoShape(),uno::UNO_QUERY_THROW); + uno::Reference< report::XReportComponent> xShapePropTextField(pObjs[1]->getUnoShape(),uno::UNO_QUERY_THROW); + if ( sLabel.getLength() ) + xShapePropTextField->setName(sLabel); + awt::Point aPosLabel = xShapePropLabel->getPosition(); + awt::Point aPosTextField = xShapePropTextField->getPosition(); + aPosTextField.X = aPosLabel.X; + xShapePropTextField->setPosition(aPosTextField); + if (bLabelAboveTextField) + { + // move the label down near the splitter + const uno::Reference<report::XSection> xLabelSection = pSectionWindow[1]->getReportSection().getSection(); + aPosLabel.Y = xLabelSection->getHeight() - xShapePropLabel->getHeight(); + } + else + { + // move the label up to the splitter + aPosLabel.Y = 0; + } + xShapePropLabel->setPosition(aPosLabel); + } + OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0]); + uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW); + xShapeProp->setName(xShapeProp->getName() + sDefaultName ); + + for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) // insert controls + { + correctOverlapping(pControl[i],pSectionWindow[1-i]->getReportSection()); + } + + if (!bLabelAboveTextField ) + { + if ( pSectionViews[0] == pSectionViews[1] ) + { + Rectangle aLabel = getRectangleFromControl(pControl[0]); + Rectangle aTextfield = getRectangleFromControl(pControl[1]); + + // create a Union of the given Label and Textfield + Rectangle aLabelAndTextfield( aLabel ); + aLabelAndTextfield.Union(aTextfield); + + // check if there exists other fields and if yes, move down + bool bOverlapping = true; + bool bHasToMove = false; + while ( bOverlapping ) + { + const SdrObject* pOverlappedObj = isOver(aLabelAndTextfield, *pSectionWindow[0]->getReportSection().getPage(), *pSectionViews[0], true, pControl, 2); + bOverlapping = pOverlappedObj != NULL; + if ( bOverlapping ) + { + const Rectangle& aLogicRect = pOverlappedObj->GetLogicRect(); + aLabelAndTextfield.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aLabelAndTextfield.Top()); + bHasToMove = true; + } + } + + if (bHasToMove) + { + // There was a move down, we need to move the Label and the Textfield down + aLabel.Move(0, aLabelAndTextfield.Top() - aLabel.Top()); + aTextfield.Move(0, aLabelAndTextfield.Top() - aTextfield.Top()); + + uno::Reference< report::XReportComponent> xLabel(pControl[0]->getUnoShape(),uno::UNO_QUERY_THROW); + xLabel->setPositionY(aLabel.Top()); + + uno::Reference< report::XReportComponent> xTextfield(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW); + xTextfield->setPositionY(aTextfield.Top()); + } + } + // this should never happen. + // else + // { + // DBG_ERROR("unhandled case."); + // } + } + } + } + else + { + for(size_t i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) + delete pControl[i]; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +// ----------------------------------------------------------------------------- +OSectionView* OReportController::getCurrentSectionView() const +{ + OSectionView* pSectionView = NULL; + ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection(); + if ( pSectionWindow.get() ) + pSectionView = &pSectionWindow->getReportSection().getSectionView(); + return pSectionView; +} +// ----------------------------------------------------------------------------- +void OReportController::changeZOrder(sal_Int32 _nId) +{ + OSectionView* pSectionView = getCurrentSectionView(); + if ( pSectionView ) + { + switch(_nId) + { + case SID_FRAME_TO_BOTTOM: + pSectionView->PutMarkedToBtm(); + break; + case SID_FRAME_TO_TOP: + pSectionView->PutMarkedToTop(); + break; + case SID_FRAME_DOWN: + pSectionView->MovMarkedToBtm(); + break; + case SID_FRAME_UP: + pSectionView->MovMarkedToTop(); + break; + + case SID_OBJECT_HEAVEN: + pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT ); + break; + case SID_OBJECT_HELL: + pSectionView->SetMarkedToLayer( RPT_LAYER_BACK ); + break; + } + } +} +// ----------------------------------------------------------------------------- +void OReportController::listen(const bool _bAdd) +{ + const ::rtl::OUString aProps [] = { PROPERTY_REPORTHEADERON,PROPERTY_REPORTFOOTERON + ,PROPERTY_PAGEHEADERON,PROPERTY_PAGEFOOTERON + ,PROPERTY_COMMAND, PROPERTY_COMMANDTYPE,PROPERTY_CAPTION + }; + + void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const ::rtl::OUString&, const uno::Reference< XPropertyChangeListener >& ) = + _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener; + + for (size_t i = 0; i < sizeof(aProps)/sizeof(aProps[0]); ++i) + (m_xReportDefinition.get()->*pPropertyListenerAction)( aProps[i], static_cast< XPropertyChangeListener* >( this ) ); + + OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv(); + uno::Reference< XPropertyChangeListener > xUndo = &rUndoEnv; + uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties(); + const beans::Property* pIter = aSeq.getConstArray(); + const beans::Property* pEnd = pIter + aSeq.getLength(); + const ::rtl::OUString* pPropsBegin = &aProps[0]; + const ::rtl::OUString* pPropsEnd = pPropsBegin + (sizeof(aProps)/sizeof(aProps[0])) - 3; + for(;pIter != pEnd;++pIter) + { + if ( ::std::find(pPropsBegin,pPropsEnd,pIter->Name) == pPropsEnd ) + (m_xReportDefinition.get()->*pPropertyListenerAction)( pIter->Name, xUndo ); + } + + // Add Listeners to UndoEnvironment + void (OXUndoEnvironment::*pElementUndoFunction)( const uno::Reference< uno::XInterface >& ) = + _bAdd ? &OXUndoEnvironment::AddElement : &OXUndoEnvironment::RemoveElement; + + (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getStyleFamilies() ); + (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getFunctions() ); + + // Add Listeners to ReportControllerObserver + OXReportControllerObserver& rObserver = *m_pReportControllerObserver; + // void (OXReportControllerObserver::*pObserverFunction)( const uno::Reference< uno::XInterface >& ) = + // _bAdd ? &OXReportControllerObserver::AddElement : &OXReportControllerObserver::RemoveElement; + + // (rObserver.*pObserverFunction)( m_xReportDefinition->getStyleFamilies() ); + // (rObserver.*pObserverFunction)( m_xReportDefinition->getFunctions() ); + + if ( m_xReportDefinition->getPageHeaderOn() && _bAdd ) + { + getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER); + rObserver.AddSection(m_xReportDefinition->getPageHeader()); + } + if ( m_xReportDefinition->getReportHeaderOn() && _bAdd ) + { + getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER); + rObserver.AddSection(m_xReportDefinition->getReportHeader()); + } + + uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups(); + const sal_Int32 nCount = xGroups->getCount(); + _bAdd ? xGroups->addContainerListener(&rUndoEnv) : xGroups->removeContainerListener(&rUndoEnv); + _bAdd ? xGroups->addContainerListener(&rObserver) : xGroups->removeContainerListener(&rObserver); + + for (sal_Int32 i=0;i<nCount ; ++i) + { + uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY); + (xGroup.get()->*pPropertyListenerAction)( PROPERTY_HEADERON, static_cast< XPropertyChangeListener* >( this ) ); + (xGroup.get()->*pPropertyListenerAction)( PROPERTY_FOOTERON, static_cast< XPropertyChangeListener* >( this ) ); + + (rUndoEnv.*pElementUndoFunction)( xGroup ); + (rUndoEnv.*pElementUndoFunction)( xGroup->getFunctions() ); + if ( xGroup->getHeaderOn() && _bAdd ) + { + getDesignView()->addSection(xGroup->getHeader(),DBGROUPHEADER); + rObserver.AddSection(xGroup->getHeader()); + } + } // for (sal_Int32 i=0;i<nCount ; ++i) + + if ( _bAdd ) + { + getDesignView()->addSection(m_xReportDefinition->getDetail(),DBDETAIL); + rObserver.AddSection(m_xReportDefinition->getDetail()); + + for (sal_Int32 i=nCount;i > 0 ; --i) + { + uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i-1),uno::UNO_QUERY); + if ( xGroup->getFooterOn() ) + { + getDesignView()->addSection(xGroup->getFooter(),DBGROUPFOOTER); + rObserver.AddSection(xGroup->getFooter()); + } + } + if ( m_xReportDefinition->getReportFooterOn() ) + { + getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER); + rObserver.AddSection(m_xReportDefinition->getReportFooter()); + } + if ( m_xReportDefinition->getPageFooterOn()) + { + getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER); + rObserver.AddSection(m_xReportDefinition->getPageFooter()); + } + + xGroups->addContainerListener(static_cast<XContainerListener*>(this)); + m_xReportDefinition->addModifyListener(static_cast<XModifyListener*>(this)); + } + else /* ! _bAdd */ + { + rObserver.RemoveSection(m_xReportDefinition->getDetail()); + xGroups->removeContainerListener(static_cast<XContainerListener*>(this)); + m_xReportDefinition->removeModifyListener(static_cast<XModifyListener*>(this)); + m_aReportModel->detachController(); + } +} +// ----------------------------------------------------------------------------- +void OReportController::switchReportSection(const sal_Int16 _nId) +{ + OSL_ENSURE(_nId == SID_REPORTHEADER_WITHOUT_UNDO || _nId == SID_REPORTFOOTER_WITHOUT_UNDO || _nId == SID_REPORTHEADERFOOTER ,"Illegal id given!"); + + if ( m_xReportDefinition.is() ) + { + const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); + const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn(); + if ( SID_REPORTHEADERFOOTER == _nId ) + { + const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); + getUndoMgr()->EnterListAction( sUndoAction, String() ); + + addUndoActionAndInvalidate(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO + ,::std::mem_fun(&OReportHelper::getReportHeader) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + ,0 + )); + + addUndoActionAndInvalidate(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO + ,::std::mem_fun(&OReportHelper::getReportFooter) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + ,0 + )); + } + + switch( _nId ) + { + case SID_REPORTHEADER_WITHOUT_UNDO: + m_xReportDefinition->setReportHeaderOn( bSwitchOn ); + break; + case SID_REPORTFOOTER_WITHOUT_UNDO: + m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() ); + break; + case SID_REPORTHEADERFOOTER: + m_xReportDefinition->setReportHeaderOn( bSwitchOn ); + m_xReportDefinition->setReportFooterOn( bSwitchOn ); + break; + } + + if ( SID_REPORTHEADERFOOTER == _nId ) + getUndoMgr()->LeaveListAction(); + getView()->Resize(); + } +} +// ----------------------------------------------------------------------------- +void OReportController::switchPageSection(const sal_Int16 _nId) +{ + OSL_ENSURE(_nId == SID_PAGEHEADERFOOTER || _nId == SID_PAGEHEADER_WITHOUT_UNDO || _nId == SID_PAGEFOOTER_WITHOUT_UNDO ,"Illegal id given!"); + if ( m_xReportDefinition.is() ) + { + const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); + const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn(); + + if ( SID_PAGEHEADERFOOTER == _nId ) + { + const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER)); + getUndoMgr()->EnterListAction( sUndoAction, String() ); + + addUndoActionAndInvalidate(new OReportSectionUndo(*m_aReportModel + ,SID_PAGEHEADER_WITHOUT_UNDO + ,::std::mem_fun(&OReportHelper::getPageHeader) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + ,0 + )); + + addUndoActionAndInvalidate(new OReportSectionUndo(*m_aReportModel + ,SID_PAGEFOOTER_WITHOUT_UNDO + ,::std::mem_fun(&OReportHelper::getPageFooter) + ,m_xReportDefinition + ,bSwitchOn ? Inserted : Removed + ,0 + )); + } // if ( SID_PAGEHEADERFOOTER == _nId ) + switch( _nId ) + { + case SID_PAGEHEADER_WITHOUT_UNDO: + m_xReportDefinition->setPageHeaderOn( bSwitchOn ); + break; + case SID_PAGEFOOTER_WITHOUT_UNDO: + m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() ); + break; + case SID_PAGEHEADERFOOTER: + m_xReportDefinition->setPageHeaderOn( bSwitchOn ); + m_xReportDefinition->setPageFooterOn( bSwitchOn ); + break; + } + if ( SID_PAGEHEADERFOOTER == _nId ) + getUndoMgr()->LeaveListAction(); + getView()->Resize(); + } +} +// ----------------------------------------------------------------------------- +void OReportController::modifyGroup(const bool _bAppend, const Sequence< PropertyValue >& _aArgs) +{ + if ( !m_xReportDefinition.is() ) + return; + + try + { + const SequenceAsHashMap aMap( _aArgs ); + uno::Reference< report::XGroup > xGroup = aMap.getUnpackedValueOrDefault( PROPERTY_GROUP, uno::Reference< report::XGroup >() ); + if ( !xGroup.is() ) + return; + + OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv(); + uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups(); + if ( _bAppend ) + { + const sal_Int32 nPos = aMap.getUnpackedValueOrDefault( PROPERTY_POSITIONY, xGroups->getCount() ); + xGroups->insertByIndex( nPos, uno::makeAny( xGroup ) ); + rUndoEnv.AddElement( xGroup->getFunctions() ); + } + + addUndoActionAndInvalidate( new OGroupUndo( + *m_aReportModel, + _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP, + _bAppend ? Inserted : Removed, + xGroup, + m_xReportDefinition + ) ); + + if ( !_bAppend ) + { + rUndoEnv.RemoveElement( xGroup->getFunctions() ); + const sal_Int32 nPos = getGroupPosition( xGroup ); + const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() ); + xGroups->removeByIndex( nPos ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +// ----------------------------------------------------------------------------- +void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader, const Sequence< PropertyValue >& _aArgs) +{ + if ( m_xReportDefinition.is() ) + { + const SequenceAsHashMap aMap(_aArgs); + const sal_Bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? PROPERTY_HEADERON : PROPERTY_FOOTERON,sal_False); + uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>()); + if ( xGroup.is() ) + { + const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv()); + if ( _bUndo ) + addUndoActionAndInvalidate(new OGroupSectionUndo(*m_aReportModel + ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO + ,_bHeader ? ::std::mem_fun(&OGroupHelper::getHeader) : ::std::mem_fun(&OGroupHelper::getFooter) + ,xGroup + ,bSwitchOn ? Inserted : Removed + , ( _bHeader ? + (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER) + :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER) + ) + )); + + if ( _bHeader ) + xGroup->setHeaderOn( bSwitchOn ); + else + xGroup->setFooterOn( bSwitchOn ); + } + } +} +// ----------------------------------------------------------------------------- +void OReportController::collapseSection(const bool _bCollapse) +{ + ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection(); + if ( pSection ) + { + pSection->setCollapsed(_bCollapse); + } +} +// ----------------------------------------------------------------------------- +void OReportController::markSection(const bool _bNext) +{ + ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection(); + if ( pSection ) + { + ::boost::shared_ptr<OSectionWindow> pPrevSection = getDesignView()->getMarkedSection(_bNext ? POST : PREVIOUS); + if ( pPrevSection != pSection && pPrevSection ) + select(uno::makeAny(pPrevSection->getReportSection().getSection())); + else + select(uno::makeAny(m_xReportDefinition)); + } + else + { + getDesignView()->markSection(_bNext ? 0 : getDesignView()->getSectionCount() - 1); + pSection = getDesignView()->getMarkedSection(); + if ( pSection ) + select(uno::makeAny(pSection->getReportSection().getSection())); + } +} +// ----------------------------------------------------------------------------- +void OReportController::createDefaultControl(const uno::Sequence< beans::PropertyValue>& _aArgs) +{ + uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection(); + if ( !xSection.is() ) + xSection = m_xReportDefinition->getDetail(); + + if ( xSection.is() ) + { + const ::rtl::OUString sKeyModifier(RTL_CONSTASCII_USTRINGPARAM("KeyModifier")); + const beans::PropertyValue* pIter = _aArgs.getConstArray(); + const beans::PropertyValue* pEnd = pIter + _aArgs.getLength(); + const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyValueCompare(),boost::cref(sKeyModifier))); + sal_Int16 nKeyModifier = 0; + if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) ) + { + Sequence< PropertyValue > aCreateArgs; + getDesignView()->unmarkAllObjects(NULL); + createControl(aCreateArgs,xSection,::rtl::OUString(),getDesignView()->GetInsertObj()); + } + } +} +// ----------------------------------------------------------------------------- +uno::Reference< util::XNumberFormatter > OReportController::getReportNumberFormatter() const +{ + return m_xFormatter; +} +// ----------------------------------------------------------------------------- +void OReportController::checkChartEnabled() +{ + if ( !m_bChartEnabledAsked ) + { + m_bChartEnabledAsked = true; + const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign" ) ); + const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "UserData/Chart" ) ); + + try + { + ::utl::OConfigurationTreeRoot aConfiguration( + ::utl::OConfigurationTreeRoot::createWithServiceFactory( m_xServiceFactory, sConfigName ) ); + + sal_Bool bChartEnabled = sal_False; + if ( aConfiguration.hasByHierarchicalName(sPropertyName) ) + aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled; + m_bChartEnabled = bChartEnabled; + } + catch(const Exception&) + { + } + } +} +// ----------------------------------------------------------------------------- + +// css.frame.XTitle +::rtl::OUString SAL_CALL OReportController::getTitle() + throw (uno::RuntimeException) +{ + vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( getMutex() ); + + uno::Reference< frame::XTitle> xTitle(m_xReportDefinition,uno::UNO_QUERY_THROW); + + return xTitle->getTitle (); +} +// ----------------------------------------------------------------------------- +void OReportController::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const +{ + _rDefault <<= sal_Int16(100); +} +// ----------------------------------------------------------------------------- +// comphelper::OPropertyArrayUsageHelper +::cppu::IPropertyArrayHelper* OReportController::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- + +// cppu::OPropertySetHelper +::cppu::IPropertyArrayHelper& SAL_CALL OReportController::getInfoHelper() +{ + typedef ::comphelper::OPropertyArrayUsageHelper<OReportController_BASE> OReportController_PROP; + return *OReportController_PROP::getArrayHelper(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OReportController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any& _aValue) throw (Exception) +{ + if ( _nHandle == PROPERTY_ID_ZOOMVALUE ) + { + _aValue >>= m_nZoomValue; + impl_zoom_nothrow(); + } +} +void SAL_CALL OReportController::setMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( getMutex() ); + m_sMode = aMode; +} +::rtl::OUString SAL_CALL OReportController::getMode( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( getMutex() ); + return m_sMode; +} +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OReportController::getSupportedModes( ) throw (::com::sun::star::uno::RuntimeException) +{ + static ::rtl::OUString s_sModes[] = { ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("remote")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("normal")) }; + return uno::Sequence< ::rtl::OUString> (&s_sModes[0],sizeof(s_sModes)/sizeof(s_sModes[0])); +} +::sal_Bool SAL_CALL OReportController::supportsMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString> aModes = getSupportedModes(); + const ::rtl::OUString* pIter = aModes.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aModes.getLength(); + for(;pIter != pEnd;++pIter) + { + if ( pIter->equals(aMode ) ) + break; + } + return pIter != pEnd; +} +// ----------------------------------------------------------------------------- +bool OReportController::isUiVisible() const +{ + return !m_sMode.equalsAscii("remote"); +} +// ----------------------------------------------------------------------------- +void OReportController::impl_fillState_nothrow(const ::rtl::OUString& _sProperty,dbaui::FeatureState& _rState) const +{ + _rState.bEnabled = isEditable(); + if ( _rState.bEnabled ) + { + ::std::vector< uno::Reference< uno::XInterface > > aSelection; + getDesignView()->fillControlModelSelection(aSelection); + _rState.bEnabled = !aSelection.empty(); + if ( _rState.bEnabled ) + { + uno::Any aTemp; + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin(); + for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter) + { + uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY); + try + { + uno::Any aTemp2 = xProp->getPropertyValue(_sProperty); + if ( aIter == aSelection.begin() ) + { + aTemp = aTemp2; + } + else if ( !comphelper::compare(aTemp,aTemp2) ) + break; + } + catch(beans::UnknownPropertyException&) + { + _rState.bEnabled = sal_False; + } + } // for(; aIter != aSelection.end();++aIter) + if ( aIter == aSelection.end() ) + _rState.aValue = aTemp; + } + } // if ( _rState.bEnabled ) +} +// ----------------------------------------------------------------------------- +void OReportController::impl_zoom_nothrow() +{ + Fraction aZoom(m_nZoomValue,100); + setZoomFactor( aZoom,*getDesignView() ); + getDesignView()->zoom(aZoom); + // TRY + /*getDesignView()->Invalidate(INVALIDATE_NOCHILDREN);*/ + InvalidateFeature(SID_ATTR_ZOOM,Reference< XStatusListener >(),sal_True); + InvalidateFeature(SID_ATTR_ZOOMSLIDER,Reference< XStatusListener >(),sal_True); +} +// ----------------------------------------------------------------------------- +sal_Bool OReportController::isFormatCommandEnabled(sal_uInt16 _nCommand,const uno::Reference< report::XReportControlFormat>& _xReportControlFormat) const +{ + sal_Bool bRet = sal_False; + if ( _xReportControlFormat.is() && !uno::Reference< report::XFixedLine>(_xReportControlFormat,uno::UNO_QUERY).is() ) // this command is really often called so we nedd a short cut here + { + try + { + const awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor(); + + switch(_nCommand) + { + case SID_ATTR_CHAR_WEIGHT: + bRet = awt::FontWeight::BOLD == aFontDescriptor.Weight; + break; + case SID_ATTR_CHAR_POSTURE: + bRet = awt::FontSlant_ITALIC == aFontDescriptor.Slant; + break; + case SID_ATTR_CHAR_UNDERLINE: + bRet = awt::FontUnderline::SINGLE == aFontDescriptor.Underline; + break; + default: + ; + } // switch(_nCommand) + } + catch(uno::Exception&) + { + } + } + return bRet; +} +// ----------------------------------------------------------------------------- +bool OReportController::impl_setPropertyAtControls_throw(const sal_uInt16 _nUndoResId,const ::rtl::OUString& _sProperty,const uno::Any& _aValue,const Sequence< PropertyValue >& _aArgs) +{ + ::std::auto_ptr<UndoManagerListAction> pListAction; + ::std::vector< uno::Reference< uno::XInterface > > aSelection; + uno::Reference< awt::XWindow> xWindow; + lcl_getReportControlFormat( _aArgs, getDesignView(), xWindow, aSelection ); + const bool bMultiSet = aSelection.size() > 1; + ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin(); + for(; aIter != aSelection.end();++aIter) + { + if ( !pListAction.get() && _nUndoResId && bMultiSet ) + { + const String sUndoAction = String(ModuleRes(_nUndoResId)); + pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction)); + } // if ( !pListAction.get() ) + const uno::Reference< beans::XPropertySet > xControlModel(*aIter,uno::UNO_QUERY); + if ( xControlModel.is() ) + xControlModel->setPropertyValue(_sProperty,_aValue); + } // for(; aIter != aSelection.end();++aIter) + return !aSelection.empty(); +} +// ----------------------------------------------------------------------------- +void OReportController::impl_fillCustomShapeState_nothrow(const char* _pCustomShapeType,dbaui::FeatureState& _rState) const +{ + _rState.bEnabled = isEditable(); + _rState.bChecked = getDesignView()->GetInsertObj() == OBJ_CUSTOMSHAPE && getDesignView()->GetInsertObjString().compareToAscii(_pCustomShapeType) == 0; +} + +// ----------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OReportController::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const +{ + if ( getDesignView() ) + { + return getDesignView()->getSectionWindow(_xSection); + } + + // throw NullPointerException? + ::boost::shared_ptr<OSectionWindow> pEmpty; + return pEmpty; +} + + +// ----------------------------------------------------------------------------- +void OReportController::openZoomDialog() +{ + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + static SfxItemInfo aItemInfos[] = + { + { SID_ATTR_ZOOM, SFX_ITEM_POOLABLE } + }; + SfxPoolItem* pDefaults[] = + { + new SvxZoomItem() + }; + static USHORT pRanges[] = + { + SID_ATTR_ZOOM,SID_ATTR_ZOOM, + 0 + }; + SfxItemPool* pPool( new SfxItemPool(String::CreateFromAscii("ZoomProperties"), SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, pDefaults) ); + pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why + pPool->FreezeIdRanges(); // the same + try + { + ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges)); + // fill it + SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM ); + aZoomItem.SetValueSet(SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_WHOLEPAGE|SVX_ZOOM_ENABLE_PAGEWIDTH); + pDescriptor->Put(aZoomItem); + + ::std::auto_ptr<AbstractSvxZoomDialog> pDlg( pFact->CreateSvxZoomDialog(NULL, *pDescriptor.get()) ); + pDlg->SetLimits( 20, 400 ); + bool bCancel = ( RET_CANCEL == pDlg->Execute() ); + + if ( !bCancel ) + { + const SvxZoomItem& rZoomItem = (const SvxZoomItem&)pDlg->GetOutputItemSet()->Get( SID_ATTR_ZOOM ); + m_eZoomType = rZoomItem.GetType(); + m_nZoomValue = rZoomItem.GetValue(); + if ( m_eZoomType != SVX_ZOOM_PERCENT ) + m_nZoomValue = getDesignView()->getZoomFactor( m_eZoomType ); + + impl_zoom_nothrow(); + } // if ( !bCancel ) + } + catch(uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + SfxItemPool::Free(pPool); + + for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) + delete pDefaults[i]; + } // if(pFact) +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// XVisualObject +void SAL_CALL OReportController::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( getMutex() ); + //if( nAspect == embed::Aspects::MSOLE_CONTENT ) + { + bool bChanged = + (m_aVisualAreaSize.Width != _aSize.Width || + m_aVisualAreaSize.Height != _aSize.Height); + m_aVisualAreaSize = _aSize; + if( bChanged ) + setModified( sal_True ); + } + m_nAspect = _nAspect; +} +// ----------------------------------------------------------------------------- +awt::Size SAL_CALL OReportController::getVisualAreaSize( ::sal_Int64 /*nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( getMutex() ); + return m_aVisualAreaSize; +} +// ----------------------------------------------------------------------------- +embed::VisualRepresentation SAL_CALL OReportController::getPreferredVisualRepresentation( ::sal_Int64 _nAspect ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( getMutex() ); + embed::VisualRepresentation aResult; + if ( !m_bInGeneratePreview ) + { + m_bInGeneratePreview = true; + try + { + if ( !m_xReportEngine.is() ) + m_xReportEngine.set(getORB()->createInstance(SERVICE_REPORTENGINE),uno::UNO_QUERY_THROW); + const sal_Int32 nOldMaxRows = m_xReportEngine->getMaxRows(); + m_xReportEngine->setMaxRows(MAX_ROWS_FOR_PREVIEW); + m_xReportEngine->setReportDefinition(m_xReportDefinition); + m_xReportEngine->setActiveConnection(getConnection()); + try + { + Reference<embed::XVisualObject> xTransfer(m_xReportEngine->createDocumentModel(),UNO_QUERY); + if ( xTransfer.is() ) + { + xTransfer->setVisualAreaSize(m_nAspect,m_aVisualAreaSize); + aResult = xTransfer->getPreferredVisualRepresentation( _nAspect ); + } // if ( xTransfer.is() ) + } + catch( uno::Exception & ex ) + { + (void)ex; + } + m_xReportEngine->setMaxRows(nOldMaxRows); + } + catch( uno::Exception & ex ) + { + (void)ex; + } + m_bInGeneratePreview = false; + } + return aResult; +} +// ----------------------------------------------------------------------------- +::sal_Int32 SAL_CALL OReportController::getMapUnit( ::sal_Int64 /*nAspect*/ ) throw (uno::Exception, uno::RuntimeException) +{ + return embed::EmbedMapUnits::ONE_100TH_MM; +} +// ----------------------------------------------------------------------------- +uno::Reference< container::XNameAccess > OReportController::getColumns() const +{ + if ( !m_xColumns.is() && m_xReportDefinition.is() && m_xReportDefinition->getCommand().getLength() ) + { + m_xColumns = dbtools::getFieldsByCommandDescriptor(getConnection(),m_xReportDefinition->getCommandType(),m_xReportDefinition->getCommand(),m_xHoldAlive); + } + return m_xColumns; +} +// ----------------------------------------------------------------------------- +::rtl::OUString OReportController::getColumnLabel_throw(const ::rtl::OUString& i_sColumnName) const +{ + ::rtl::OUString sLabel; + uno::Reference< container::XNameAccess > xColumns = getColumns(); + if ( xColumns.is() && xColumns->hasByName(i_sColumnName) ) + { + uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(i_sColumnName),uno::UNO_QUERY_THROW); + if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + } + return sLabel; +} +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/ui/report/ReportControllerObserver.cxx b/reportdesign/source/ui/report/ReportControllerObserver.cxx new file mode 100644 index 000000000000..7c0f3a572be8 --- /dev/null +++ b/reportdesign/source/ui/report/ReportControllerObserver.cxx @@ -0,0 +1,462 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_reportdesign.hxx" + +#include <ReportControllerObserver.hxx> +#include <ReportController.hxx> +#include <svl/smplhint.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <com/sun/star/report/XFormattedField.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <FormattedFieldBeautifier.hxx> + +#include <svx/unopage.hxx> + +// DBG_* +#include <tools/debug.hxx> +// DBG_UNHANDLED_EXCEPTION +#include <tools/diagnose_ex.h> + +namespace rptui +{ + + using namespace ::com::sun::star; + + // const OReportController *& m_pReportController; + +DECLARE_STL_USTRINGACCESS_MAP(bool, AllProperties); +DECLARE_STL_STDKEY_MAP(uno::Reference< beans::XPropertySet >, AllProperties, PropertySetInfoCache); + +class OXReportControllerObserverImpl +{ + OXReportControllerObserverImpl(OXReportControllerObserverImpl&); + void operator =(OXReportControllerObserverImpl&); +public: + const OReportController& m_rReportController; + ::std::vector< uno::Reference< container::XChild> > m_aSections; + ::osl::Mutex m_aMutex; + oslInterlockedCount m_nLocks; + sal_Bool m_bReadOnly; + + OXReportControllerObserverImpl(const OReportController& _rController); + ~OXReportControllerObserverImpl(); +}; + +// ----------------------------------------------------------------------------- + + OXReportControllerObserverImpl::OXReportControllerObserverImpl(const OReportController& _rController) + :m_rReportController(_rController) + ,m_nLocks(0) + ,m_bReadOnly(sal_False) + { + } + + OXReportControllerObserverImpl::~OXReportControllerObserverImpl() + { + } + + // ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- + + DBG_NAME(rpt_OXReportControllerObserver) + + OXReportControllerObserver::OXReportControllerObserver(const OReportController& _rController) + :m_pImpl(new OXReportControllerObserverImpl(_rController) ) + ,m_aFormattedFieldBeautifier(_rController) + ,m_aFixedTextColor(_rController) + { + DBG_CTOR( rpt_OXReportControllerObserver,NULL); + + Application::AddEventListener(LINK( this, OXReportControllerObserver, SettingsChanged ) ); + } + + OXReportControllerObserver::~OXReportControllerObserver() + { + DBG_CTOR( rpt_OXReportControllerObserver,NULL); + Application::RemoveEventListener(LINK( this, OXReportControllerObserver, SettingsChanged ) ); + } + + // ----------------------------------------------------------------------------- + IMPL_LINK(OXReportControllerObserver, SettingsChanged, VclWindowEvent*, _pEvt) + { + if ( _pEvt ) + { + sal_Int32 nEvent = _pEvt->GetId(); + /* + // just for debug + if (nEvent == VCLEVENT_WINDOW_CHILDCREATED || + nEvent == VCLEVENT_WINDOW_PAINT || + nEvent == VCLEVENT_WINDOW_MOVE || + nEvent == VCLEVENT_WINDOW_RESIZE || + nEvent == VCLEVENT_WINDOW_SHOW || + nEvent == VCLEVENT_WINDOW_MOUSEMOVE || + nEvent == VCLEVENT_WINDOW_FRAMETITLECHANGED || + nEvent == VCLEVENT_WINDOW_HIDE || + nEvent == VCLEVENT_EDIT_MODIFY || + nEvent == VCLEVENT_SCROLLBAR_ENDSCROLL || + nEvent == VCLEVENT_EDIT_SELECTIONCHANGED || + nEvent == VCLEVENT_TABPAGE_INSERTED || + nEvent == VCLEVENT_TABPAGE_REMOVED || + nEvent == VCLEVENT_TOOLBOX_FORMATCHANGED || + nEvent == VCLEVENT_TOOLBOX_ITEMADDED || + nEvent == VCLEVENT_TOOLBOX_ALLITEMCHANGED || + nEvent == VCLEVENT_MENUBARADDED || + nEvent == 1 + ) + { + return 0L; + } + */ + + if (nEvent == VCLEVENT_APPLICATION_DATACHANGED ) + { + DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData()); + if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS ) || + ( pData->GetType() == DATACHANGED_DISPLAY )) && + ( pData->GetFlags() & SETTINGS_STYLE ))) + { + OEnvLock aLock(*this); + + // sal_uInt32 nCount = m_pImpl->m_aSections.size(); + + // send all Section Objects a 'tingle' + // maybe they need a change in format, color, etc + ::std::vector< uno::Reference< container::XChild > >::const_iterator aIter = m_pImpl->m_aSections.begin(); + ::std::vector< uno::Reference< container::XChild > >::const_iterator aEnd = m_pImpl->m_aSections.end(); + for (;aIter != aEnd; aIter++) + { + const uno::Reference<container::XChild> xChild (*aIter); + if (xChild.is()) + { + uno::Reference<report::XSection> xSection(xChild, uno::UNO_QUERY); + if (xSection.is()) + { + const sal_Int32 nCount = xSection->getCount(); + for (sal_Int32 i = 0; i < nCount; ++i) + { + const uno::Any aObj = xSection->getByIndex(i); + uno::Reference < report::XReportComponent > xReportComponent(aObj, uno::UNO_QUERY); + if (xReportComponent.is()) + { + m_aFormattedFieldBeautifier.handle(xReportComponent); + m_aFixedTextColor.handle(xReportComponent); + } + } + } + } + } + } + } + } + + return 0L; + } + + // XEventListener + void SAL_CALL OXReportControllerObserver::disposing(const lang::EventObject& e) throw( uno::RuntimeException ) + { + (void) e; + // check if it's an object we have cached informations about + uno::Reference< beans::XPropertySet > xSourceSet(e.Source, uno::UNO_QUERY); + if ( xSourceSet.is() ) + { + uno::Reference< report::XSection> xSection(xSourceSet,uno::UNO_QUERY); + if ( xSection.is() ) + RemoveSection(xSection); + else + RemoveElement(xSourceSet); + } + } + + void OXReportControllerObserver::Clear() + { + OEnvLock aLock(*this); + // sal_uInt32 nDebugValue = m_pImpl->m_aSections.size(); + m_pImpl->m_aSections.clear(); + } + + // XPropertyChangeListener + void SAL_CALL OXReportControllerObserver::propertyChange(const beans::PropertyChangeEvent& _rEvent) throw(uno::RuntimeException) + { + (void) _rEvent; + ::osl::ClearableMutexGuard aGuard( m_pImpl->m_aMutex ); + + if ( IsLocked() ) + return; + + m_aFormattedFieldBeautifier.notifyPropertyChange(_rEvent); + m_aFixedTextColor.notifyPropertyChange(_rEvent); + } + +// ----------------------------------------------------------------------------- +void OXReportControllerObserver::Lock() +{ + OSL_ENSURE(m_refCount,"Illegal call to dead object!"); + osl_incrementInterlockedCount( &m_pImpl->m_nLocks ); +} +void OXReportControllerObserver::UnLock() +{ + OSL_ENSURE(m_refCount,"Illegal call to dead object!"); + + osl_decrementInterlockedCount( &m_pImpl->m_nLocks ); +} +sal_Bool OXReportControllerObserver::IsLocked() const { return m_pImpl->m_nLocks != 0; } + +//------------------------------------------------------------------------------ +void OXReportControllerObserver::AddSection(const uno::Reference< report::XSection > & _xSection) +{ + OEnvLock aLock(*this); + try + { + uno::Reference<container::XChild> xChild = _xSection.get(); + m_pImpl->m_aSections.push_back(xChild); + uno::Reference< uno::XInterface > xInt(_xSection); + AddElement(xInt); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void OXReportControllerObserver::RemoveSection(const uno::Reference< report::XSection > & _xSection) +{ + OEnvLock aLock(*this); + try + { + uno::Reference<container::XChild> xChild(_xSection.get()); + m_pImpl->m_aSections.erase(::std::remove(m_pImpl->m_aSections.begin(),m_pImpl->m_aSections.end(), + xChild), m_pImpl->m_aSections.end()); + uno::Reference< uno::XInterface > xInt(_xSection); + RemoveElement(xInt); + } + catch(uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void OXReportControllerObserver::TogglePropertyListening(const uno::Reference< uno::XInterface > & Element) +{ + // listen at Container + uno::Reference< container::XIndexAccess > xContainer(Element, uno::UNO_QUERY); + if (xContainer.is()) + { + uno::Reference< uno::XInterface > xInterface; + sal_Int32 nCount = xContainer->getCount(); + for(sal_Int32 i = 0;i != nCount;++i) + { + xInterface.set(xContainer->getByIndex( i ),uno::UNO_QUERY); + TogglePropertyListening(xInterface); + } + } + + uno::Reference< beans::XPropertySet > xSet(Element, uno::UNO_QUERY); + if (xSet.is()) + { + if (!m_pImpl->m_bReadOnly) + xSet->addPropertyChangeListener( ::rtl::OUString(), this ); + else + xSet->removePropertyChangeListener( ::rtl::OUString(), this ); + } +} + + +//------------------------------------------------------------------------------ +void OXReportControllerObserver::switchListening( const uno::Reference< container::XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(()) +{ + OSL_PRECOND( _rxContainer.is(), "OXReportControllerObserver::switchListening: invalid container!" ); + if ( !_rxContainer.is() ) + return; + + try + { + // also handle all children of this element + uno::Reference< uno::XInterface > xInterface; + sal_Int32 nCount = _rxContainer->getCount(); + for(sal_Int32 i = 0;i != nCount;++i) + { + xInterface.set(_rxContainer->getByIndex( i ),uno::UNO_QUERY); + if ( _bStartListening ) + AddElement( xInterface ); + else + RemoveElement( xInterface ); + } + + // be notified of any changes in the container elements + uno::Reference< container::XContainer > xSimpleContainer( _rxContainer, uno::UNO_QUERY ); + // OSL_ENSURE( xSimpleContainer.is(), "OXReportControllerObserver::switchListening: how are we expected to be notified of changes in the container?" ); + if ( xSimpleContainer.is() ) + { + if ( _bStartListening ) + xSimpleContainer->addContainerListener( this ); + else + xSimpleContainer->removeContainerListener( this ); + } + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void OXReportControllerObserver::switchListening( const uno::Reference< uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(()) +{ + OSL_PRECOND( _rxObject.is(), "OXReportControllerObserver::switchListening: how should I listen at a NULL object?" ); + + try + { + if ( !m_pImpl->m_bReadOnly ) + { + uno::Reference< beans::XPropertySet > xProps( _rxObject, uno::UNO_QUERY ); + if ( xProps.is() ) + { + if ( _bStartListening ) + xProps->addPropertyChangeListener( ::rtl::OUString(), this ); + else + xProps->removePropertyChangeListener( ::rtl::OUString(), this ); + } + } + + uno::Reference< util::XModifyBroadcaster > xBroadcaster( _rxObject, uno::UNO_QUERY ); + if ( xBroadcaster.is() ) + { + if ( _bStartListening ) + xBroadcaster->addModifyListener( this ); + else + xBroadcaster->removeModifyListener( this ); + } + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//------------------------------------------------------------------------------ +void SAL_CALL OXReportControllerObserver::modified( const lang::EventObject& /*aEvent*/ ) throw (uno::RuntimeException) +{ + // implSetModified(); +} + +//------------------------------------------------------------------------------ +void OXReportControllerObserver::AddElement(const uno::Reference< uno::XInterface >& _rxElement ) +{ + // if ( !IsLocked() ) + // { + m_aFormattedFieldBeautifier.notifyElementInserted(_rxElement); + m_aFixedTextColor.notifyElementInserted(_rxElement); + // } + + // if it's a container, start listening at all elements + uno::Reference< container::XIndexAccess > xContainer( _rxElement, uno::UNO_QUERY ); + if ( xContainer.is() ) + switchListening( xContainer, true ); + + switchListening( _rxElement, true ); +} + +//------------------------------------------------------------------------------ +void OXReportControllerObserver::RemoveElement(const uno::Reference< uno::XInterface >& _rxElement) +{ + switchListening( _rxElement, false ); + + uno::Reference< container::XIndexAccess > xContainer( _rxElement, uno::UNO_QUERY ); + if ( xContainer.is() ) + switchListening( xContainer, false ); +} + +// ----------------------------------------------------------------------------- +::std::vector< uno::Reference< container::XChild> >::const_iterator OXReportControllerObserver::getSection(const uno::Reference<container::XChild>& _xContainer) const +{ + ::std::vector< uno::Reference< container::XChild> >::const_iterator aFind = m_pImpl->m_aSections.end(); + if ( _xContainer.is() ) + { + aFind = ::std::find(m_pImpl->m_aSections.begin(),m_pImpl->m_aSections.end(),_xContainer); + + if ( aFind == m_pImpl->m_aSections.end() ) + { + uno::Reference<container::XChild> xParent(_xContainer->getParent(),uno::UNO_QUERY); + aFind = getSection(xParent); + } + } + return aFind; +} +// XContainerListener +//------------------------------------------------------------------------------ +void SAL_CALL OXReportControllerObserver::elementInserted(const container::ContainerEvent& evt) throw(uno::RuntimeException) +{ + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( m_pImpl->m_aMutex ); + + // neues Object zum lauschen + uno::Reference< uno::XInterface > xIface( evt.Element, uno::UNO_QUERY ); + if ( xIface.is() ) + { + AddElement(xIface); + } +} + +//------------------------------------------------------------------------------ +void SAL_CALL OXReportControllerObserver::elementReplaced(const container::ContainerEvent& evt) throw(uno::RuntimeException) +{ + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( m_pImpl->m_aMutex ); + + uno::Reference< uno::XInterface > xIface(evt.ReplacedElement,uno::UNO_QUERY); + OSL_ENSURE(xIface.is(), "OXReportControllerObserver::elementReplaced: invalid container notification!"); + RemoveElement(xIface); + + xIface.set(evt.Element,uno::UNO_QUERY); + AddElement(xIface); +} + +//------------------------------------------------------------------------------ +void SAL_CALL OXReportControllerObserver::elementRemoved(const container::ContainerEvent& evt) throw(uno::RuntimeException) +{ + ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard( m_pImpl->m_aMutex ); + + uno::Reference< uno::XInterface > xIface( evt.Element, uno::UNO_QUERY ); + if ( xIface.is() ) + { + RemoveElement(xIface); + } +} + + +} // namespace rptui + + + diff --git a/reportdesign/source/ui/report/ReportRuler.cxx b/reportdesign/source/ui/report/ReportRuler.cxx new file mode 100644 index 000000000000..c2480f23b3e5 --- /dev/null +++ b/reportdesign/source/ui/report/ReportRuler.cxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "ReportRuler.hxx" +#include "ReportSection.hxx" +#include "ReportWindow.hxx" +namespace rptui +{ +using namespace ::com::sun::star; +DBG_NAME( rpt_OReportRuler ) +OReportRuler::OReportRuler(Window* _pParent,OReportWindow* _pReportWindow,const uno::Reference< report::XSection >& _xSection) +:Window(_pParent) +,m_pParent(_pReportWindow) +{ + DBG_CTOR( rpt_OReportRuler,NULL); + SetMapMode( MapMode( MAP_100TH_MM ) ); + + Show(); +} +//------------------------------------------------------------------------------ +OReportRuler::~OReportRuler() +{ + DBG_DTOR( rpt_OReportRuler,NULL); + delete m_pSection; +} +//------------------------------------------------------------------------------ +void OReportRuler::Resize() +{ + m_pSection->SetPosSizePixel(Point(0,0),GetOutputSize()); +} +//------------------------------------------------------------------------------ +void OReportRuler::SetGridVisible(BOOL _bVisible) +{ + m_pSection->SetGridVisible( _bVisible ); +} +//------------------------------------------------------------------------------ +//============================================================================== +} // rptui +//============================================================================== diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx new file mode 100644 index 000000000000..04222d6e2f1e --- /dev/null +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -0,0 +1,878 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "ReportSection.hxx" +#include "ReportWindow.hxx" +#include "DesignView.hxx" +#include "uistrings.hrc" +#include "RptObject.hxx" +#include "RptModel.hxx" +#include "SectionView.hxx" +#include "RptPage.hxx" +#include "ReportController.hxx" +#include "UITools.hxx" +#include "ViewsWindow.hxx" + +#include <svx/svdpagv.hxx> +#include <editeng/eeitemid.hxx> +#include <editeng/adjitem.hxx> +#include <svx/sdrpaintwindow.hxx> +#include <svx/unoshape.hxx> +#include <svx/gallery.hxx> +#include <svx/svxids.hrc> +#include <svx/svditer.hxx> +#include <svx/dbaexchange.hxx> + +#include <vcl/svapp.hxx> + +#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <toolkit/helper/convert.hxx> +#include "RptDef.hxx" +#include "SectionWindow.hxx" +#include "helpids.hrc" +#include "RptResId.hrc" +#include "dlgedclip.hxx" +#include "UndoActions.hxx" +#include "rptui_slotid.hrc" + +#include <connectivity/dbtools.hxx> + +#include <vcl/lineinfo.hxx> +#include "ColorChanger.hxx" + +#include <svl/itempool.hxx> +#include <svtools/extcolorcfg.hxx> +#include <unotools/confignode.hxx> +#include <framework/imageproducer.hxx> + +// ============================================================================= +namespace rptui +{ +// ============================================================================= +using namespace ::com::sun::star; +// ----------------------------------------------------------------------------- + +sal_Int32 lcl_getOverlappedControlColor(/*const uno::Reference <lang::XMultiServiceFactory> _rxFactory*/) +{ + svtools::ExtendedColorConfig aConfig; + sal_Int32 nColor = aConfig.GetColorValue(CFG_REPORTDESIGNER, DBOVERLAPPEDCONTROL).getColor(); + return nColor; +} +//------------------------------------------------------------------------------ +DBG_NAME( rpt_OReportSection ) +OReportSection::OReportSection(OSectionWindow* _pParent,const uno::Reference< report::XSection >& _xSection) +: Window(_pParent,WB_DIALOGCONTROL) +, ::comphelper::OPropertyChangeListener(m_aMutex) +, DropTargetHelper(this) +,m_pPage(NULL) +,m_pView(NULL) +,m_pParent(_pParent) +,m_pFunc(NULL) +,m_pMulti(NULL) +,m_pReportListener(NULL) +,m_xSection(_xSection) +,m_eMode(RPTUI_SELECT) +,m_bDialogModelChanged(FALSE) +,m_bInDrag(sal_False) +{ + DBG_CTOR( rpt_OReportSection,NULL); + EnableChildTransparentMode(); + SetHelpId(HID_REPORTSECTION); + SetMapMode( MapMode( MAP_100TH_MM ) ); + + try + { + fill(); + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"Exception catched!"); + } + + m_pFunc.reset(new DlgEdFuncSelect( this )); + m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( /* m_pParent->getViewsWindow()->getView()->getReportView()->getController().getORB() */ ) ); +} +//------------------------------------------------------------------------------ +OReportSection::~OReportSection() +{ + DBG_DTOR( rpt_OReportSection,NULL); + m_pPage = NULL; + //m_pModel->GetUndoEnv().RemoveSection(m_xSection.get()); + if ( m_pMulti.is() ) + m_pMulti->dispose(); + + if ( m_pReportListener.is() ) + m_pReportListener->dispose(); + m_pFunc = ::std::auto_ptr<DlgEdFunc>(); + + { + ::std::auto_ptr<OSectionView> aTemp( m_pView); + if ( m_pView ) + m_pView->EndListening( *m_pModel ); + m_pView = NULL; + } + /*m_pModel->DeletePage(m_pPage->GetPageNum());*/ +} +//------------------------------------------------------------------------------ +void OReportSection::Paint( const Rectangle& rRect ) +{ + Window::Paint(rRect); + + if ( m_pView ) + { + // repaint, get PageView and prepare Region + SdrPageView* pPgView = m_pView->GetSdrPageView(); + const Region aPaintRectRegion(rRect); + + // #i74769# + SdrPaintWindow* pTargetPaintWindow = 0; + + // mark repaint start + if(pPgView) + { + pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(this, aPaintRectRegion); + OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)"); + // draw background self using wallpaper + OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice(); + sal_Int32 nColor = m_xSection->getBackColor(); + if ( nColor == (sal_Int32)COL_TRANSPARENT ) + nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR); + rTargetOutDev.DrawWallpaper(rRect, Wallpaper(Color(nColor))); + } + + // do paint (unbuffered) and mark repaint end + if(pPgView) + { + pPgView->DrawLayer(0, this); + pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true); + } + + m_pView->CompleteRedraw(this,aPaintRectRegion); + } +} +//------------------------------------------------------------------------------ +void OReportSection::Resize() +{ + Window::Resize(); + if ( m_xSection.is() && m_pPage && m_pView ) + { + uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition(); + m_pPage->SetSize( Size( getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight()) ); + const Size aPageSize = m_pPage->GetSize(); + const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + m_pView->SetWorkArea( Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) ); + } +} +//------------------------------------------------------------------------------ +void OReportSection::fill() +{ + if ( !m_xSection.is() ) + return; + + m_pMulti = new comphelper::OPropertyChangeMultiplexer(this,m_xSection.get()); + m_pMulti->addProperty(PROPERTY_BACKCOLOR); + + m_pReportListener = addStyleListener(m_xSection->getReportDefinition(),this); + + m_pModel = m_pParent->getViewsWindow()->getView()->getReportView()->getController().getSdrModel(); + m_pPage = m_pModel->getPage(m_xSection); + + m_pView = new OSectionView( m_pModel.get(), this, m_pParent->getViewsWindow()->getView() ); + + // #i93597# tell SdrPage that only left and right page border is defined + // instead of the full rectangle definition + m_pPage->setPageBorderOnlyLeftRight(true); + + // without the following call, no grid is painted + m_pView->ShowSdrPage( m_pPage ); + + m_pView->SetMoveSnapOnlyTopLeft( TRUE ); + ODesignView* pDesignView = m_pParent->getViewsWindow()->getView()->getReportView(); + + // #i93595# Adapted grid to a more coarse grid and subdivisions for better visualisation. This + // is only for visualisation and has nothing to do with the actual snap + const Size aGridSizeCoarse(pDesignView->getGridSizeCoarse()); + const Size aGridSizeFine(pDesignView->getGridSizeFine()); + m_pView->SetGridCoarse(aGridSizeCoarse); + m_pView->SetGridFine(aGridSizeFine); + + // #i93595# set snap grid width to snap to all existing subdivisions + const Fraction aX(aGridSizeFine.A()); + const Fraction aY(aGridSizeFine.B()); + m_pView->SetSnapGridWidth(aX, aY); + + m_pView->SetGridSnap( pDesignView->isGridSnap() ); + m_pView->SetGridFront( FALSE ); + m_pView->SetDragStripes( TRUE ); + m_pView->SetPageVisible(); + sal_Int32 nColor = m_xSection->getBackColor(); + if ( nColor == (sal_Int32)COL_TRANSPARENT ) + nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR); + m_pView->SetApplicationDocumentColor(nColor); + + const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_LEFTMARGIN); + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_RIGHTMARGIN); + m_pPage->SetLftBorder(nLeftMargin); + m_pPage->SetRgtBorder(nRightMargin); + +// LLA: TODO +// m_pPage->SetUppBorder(-10000); + + m_pView->SetDesignMode( TRUE ); + + m_pView->StartListening( *m_pModel ); + /*Resize();*/ + if ( m_xSection.is() && m_pPage && m_pView ) + { + uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition(); + m_pPage->SetSize( Size( getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight()) ); + const Size aPageSize = m_pPage->GetSize(); + const sal_Int32 nWorkAreaLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nWorkAreaRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + m_pView->SetWorkArea( Rectangle( Point( nWorkAreaLeftMargin, 0), Size(aPageSize.Width() - nWorkAreaLeftMargin - nWorkAreaRightMargin,aPageSize.Height()) ) ); + } // if ( m_xSection.is() && m_pPage && m_pView ) + + //SetBackground( Wallpaper( COL_BLUE )); +} +// ----------------------------------------------------------------------------- +void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyCopiedObjects,bool _bForce) +{ + OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!"); + if ( m_xSection.is() && _aAllreadyCopiedObjects.getLength() ) + { + // stop all drawing actions + m_pView->BrkAction(); + + // unmark all objects + m_pView->UnmarkAll(); + const ::rtl::OUString sSectionName = m_xSection->getName(); + const sal_Int32 nLength = _aAllreadyCopiedObjects.getLength(); + const beans::NamedValue* pIter = _aAllreadyCopiedObjects.getConstArray(); + const beans::NamedValue* pEnd = pIter + nLength; + for(;pIter != pEnd;++pIter) + { + if ( _bForce || pIter->Name == sSectionName) + { + try + { + uno::Sequence< uno::Reference<report::XReportComponent> > aCopies; + pIter->Value >>= aCopies; + const uno::Reference<report::XReportComponent>* pCopiesIter = aCopies.getConstArray(); + const uno::Reference<report::XReportComponent>* pCopiesEnd = pCopiesIter + aCopies.getLength(); + for (;pCopiesIter != pCopiesEnd ; ++pCopiesIter) + { + SvxShape* pShape = SvxShape::getImplementation( *pCopiesIter ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL; + if ( pObject ) + { + SdrObject* pNeuObj = pObject->Clone(); + + pNeuObj->SetPage( m_pPage ); + pNeuObj->SetModel( m_pModel.get() ); + SdrInsertReason aReason(SDRREASON_VIEWCALL); + m_pPage->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason); + + Rectangle aRet(VCLPoint((*pCopiesIter)->getPosition()),VCLSize((*pCopiesIter)->getSize())); + aRet.setHeight(aRet.getHeight() + 1); + aRet.setWidth(aRet.getWidth() + 1); + bool bOverlapping = true; + while ( bOverlapping ) + { + bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNeuObj) != NULL; + if ( bOverlapping ) + { + aRet.Move(0,aRet.getHeight()+1); + pNeuObj->SetLogicRect(aRet); + //(*pCopiesIter)->setPositionY(aRet.Top()); + } + } + m_pView->AddUndo( m_pView->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNeuObj ) ); + m_pView->MarkObj( pNeuObj, m_pView->GetSdrPageView() ); + if ( m_xSection.is() && (static_cast<sal_uInt32>(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) ) + m_xSection->setHeight(aRet.getHeight() + aRet.Top()); + } + } + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"Exception caught while pasting a new object!"); + } + if ( !_bForce ) + break; + } + } + } +} +//---------------------------------------------------------------------------- +void OReportSection::Delete() +{ + if( !m_pView->AreObjectsMarked() ) + return; + + m_pView->BrkAction(); + m_pView->DeleteMarked(); +} +//---------------------------------------------------------------------------- +void OReportSection::SetMode( DlgEdMode eNewMode ) +{ + if ( eNewMode != m_eMode ) + { + if ( eNewMode == RPTUI_INSERT ) + { + m_pFunc.reset(new DlgEdFuncInsert( this )); + } + else + { + m_pFunc.reset(new DlgEdFuncSelect( this )); + } + m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( ) ); + m_pModel->SetReadOnly(eNewMode == RPTUI_READONLY); + m_eMode = eNewMode; + } +} +// ----------------------------------------------------------------------------- +void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects) +{ + Copy(_rAllreadyCopiedObjects,false); +} +//---------------------------------------------------------------------------- +void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects,bool _bEraseAnddNoClone) +{ + OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!"); + if( !m_pView->AreObjectsMarked() || !m_xSection.is() ) + return; + + // stop all drawing actions + //m_pView->BrkAction(); + + // insert control models of marked objects into clipboard dialog model + const SdrMarkList& rMarkedList = m_pView->GetMarkedObjectList(); + const ULONG nMark = rMarkedList.GetMarkCount(); + + ::std::vector< uno::Reference<report::XReportComponent> > aCopies; + aCopies.reserve(nMark); + + SdrUndoFactory& rUndo = m_pView->GetModel()->GetSdrUndoFactory(); + + for( ULONG i = nMark; i > 0; ) + { + --i; + SdrObject* pSdrObject = rMarkedList.GetMark(i)->GetMarkedSdrObj(); + OObjectBase* pObj = dynamic_cast<OObjectBase*>(pSdrObject); + if ( pObj ) + { + try + { + SdrObject* pNeuObj = pSdrObject->Clone(); + aCopies.push_back(uno::Reference<report::XReportComponent>(pNeuObj->getUnoShape(),uno::UNO_QUERY)); + if ( _bEraseAnddNoClone ) + { + m_pView->AddUndo( rUndo.CreateUndoDeleteObject( *pSdrObject ) ); + m_pPage->RemoveObject(pSdrObject->GetOrdNum()); + } + + } + catch(uno::Exception&) + { + OSL_ENSURE(0,"Can't copy report elements!"); + } + } + } // for( ULONG i = 0; i < nMark; i++ ) + + if ( !aCopies.empty() ) + { + ::std::reverse(aCopies.begin(),aCopies.end()); + const sal_Int32 nLength = _rAllreadyCopiedObjects.getLength(); + _rAllreadyCopiedObjects.realloc( nLength + 1); + beans::NamedValue* pNewValue = _rAllreadyCopiedObjects.getArray() + nLength; + pNewValue->Name = m_xSection->getName(); + pNewValue->Value <<= uno::Sequence< uno::Reference<report::XReportComponent> >(&(*aCopies.begin()),aCopies.size()); + } +} +//---------------------------------------------------------------------------- +void OReportSection::MouseButtonDown( const MouseEvent& rMEvt ) +{ + m_pParent->getViewsWindow()->getView()->setMarked(m_pView,sal_True); // mark the section in which is clicked + m_pFunc->MouseButtonDown( rMEvt ); + Window::MouseButtonDown(rMEvt); +} +//---------------------------------------------------------------------------- +void OReportSection::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( !m_pFunc->MouseButtonUp( rMEvt ) ) + m_pParent->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_OBJECT_SELECT,uno::Sequence< beans::PropertyValue>()); +} + +//---------------------------------------------------------------------------- + +void OReportSection::MouseMove( const MouseEvent& rMEvt ) +{ + m_pFunc->MouseMove( rMEvt ); + +} +//---------------------------------------------------------------------------- +void OReportSection::SetGridVisible(BOOL _bVisible) +{ + m_pView->SetGridVisible( _bVisible ); +} +//------------------------------------------------------------------------------ +void OReportSection::SelectAll(const sal_uInt16 _nObjectType) +{ + if ( m_pView ) + { + if ( _nObjectType == OBJ_NONE ) + m_pView->MarkAllObj(); + else + { + m_pView->UnmarkAll(); + SdrObjListIter aIter(*m_pPage,IM_DEEPNOGROUPS); + SdrObject* pObjIter = NULL; + while( (pObjIter = aIter.Next()) != NULL ) + { + if ( pObjIter->GetObjIdentifier() == _nObjectType ) + m_pView->MarkObj( pObjIter, m_pView->GetSdrPageView() ); + } + } + } +} +void lcl_insertMenuItemImages(PopupMenu& rContextMenu,OReportController& rController,const uno::Reference< report::XReportDefinition>& _xReportDefinition,uno::Reference<frame::XFrame>& _rFrame,BOOL _bHiContrast) +{ + const USHORT nCount = rContextMenu.GetItemCount(); + for (USHORT i = 0; i < nCount; ++i) + { + if ( MENUITEM_SEPARATOR != rContextMenu.GetItemType(i)) + { + const USHORT nId = rContextMenu.GetItemId(i); + PopupMenu* pPopupMenu = rContextMenu.GetPopupMenu( nId ); + if ( pPopupMenu ) + { + lcl_insertMenuItemImages(*pPopupMenu,rController,_xReportDefinition,_rFrame,_bHiContrast); + } + else + { + const ::rtl::OUString sCommand = rContextMenu.GetItemCommand(nId); + rContextMenu.SetItemImage(nId,framework::GetImageFromURL(_rFrame,sCommand,FALSE,_bHiContrast)); + if ( nId == SID_PAGEHEADERFOOTER ) + { + String sText = String(ModuleRes((_xReportDefinition.is() && _xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT)); + rContextMenu.SetItemText(nId,sText); + } + else if ( nId == SID_REPORTHEADERFOOTER ) + { + String sText = String(ModuleRes((_xReportDefinition.is() && _xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT)); + rContextMenu.SetItemText(nId,sText); + } + } + rContextMenu.CheckItem(nId,rController.isCommandChecked(nId)); + rContextMenu.EnableItem(nId,rController.isCommandEnabled(nId)); + } + } // for (USHORT i = 0; i < nCount; ++i) +} +//---------------------------------------------------------------------------- +void OReportSection::Command( const CommandEvent& _rCEvt ) +{ + Window::Command(_rCEvt); + switch (_rCEvt.GetCommand()) + { + case COMMAND_CONTEXTMENU: + { + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + BOOL bHiContrast = rSettings.GetHighContrastMode(); + OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController(); + uno::Reference<frame::XFrame> xFrame = rController.getFrame(); + PopupMenu aContextMenu( ModuleRes( RID_MENU_REPORT ) ); + uno::Reference< report::XReportDefinition> xReportDefinition = getSection()->getReportDefinition(); + + lcl_insertMenuItemImages(aContextMenu,rController,xReportDefinition,xFrame,bHiContrast); + + Point aPos = _rCEvt.GetMousePosPixel(); + m_pView->EndAction(); + const USHORT nId = aContextMenu.Execute(this, aPos); + if ( nId ) + { + uno::Sequence< beans::PropertyValue> aArgs; + if ( nId == SID_ATTR_CHAR_COLOR_BACKGROUND ) + { + aArgs.realloc(1); + aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Selection")); + aArgs[0].Value <<= m_xSection; + } + rController.executeChecked(nId,aArgs); + } + } + break; + } +} +// ----------------------------------------------------------------------------- +void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException) +{ + if ( m_xSection.is() ) + { + if ( _rEvent.Source == m_xSection || PROPERTY_BACKCOLOR == _rEvent.PropertyName ) + { + sal_Int32 nColor = m_xSection->getBackColor(); + if ( nColor == (sal_Int32)COL_TRANSPARENT ) + nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR); + m_pView->SetApplicationDocumentColor(nColor); + Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE); + } + else + { + uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition(); + if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN ) + { + const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + m_pPage->SetLftBorder(nLeftMargin); + } + else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN ) + { + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + m_pPage->SetRgtBorder(nRightMargin); + } + + try + { + const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width; + const sal_Int32 nCount = m_xSection->getCount(); + for (sal_Int32 i = 0; i < nCount; ++i) + { + bool bChanged = false; + uno::Reference< report::XReportComponent> xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW); + awt::Point aPos = xReportComponent->getPosition(); + awt::Size aSize = xReportComponent->getSize(); + SvxShape* pShape = SvxShape::getImplementation( xReportComponent ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL; + if ( pObject ) + { + OObjectBase* pBase = dynamic_cast<OObjectBase*>(pObject); + pBase->EndListening(sal_False); + if ( aPos.X < nLeftMargin ) + { + aPos.X = nLeftMargin; + bChanged = true; + } + if ( (aPos.X + aSize.Width) > (nPaperWidth - nRightMargin) ) + { + aPos.X = nPaperWidth - nRightMargin - aSize.Width; + if ( aPos.X < nLeftMargin ) + { + aSize.Width += aPos.X - nLeftMargin; + aPos.X = nLeftMargin; + // add listener around + pBase->StartListening(); + xReportComponent->setSize(aSize); + pBase->EndListening(sal_False); + } + bChanged = true; + } + if ( aPos.Y < 0 ) + aPos.Y = 0; + if ( bChanged ) + { + xReportComponent->setPosition(aPos); + correctOverlapping(pObject,*this,false); + Rectangle aRet(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize())); + aRet.setHeight(aRet.getHeight() + 1); + aRet.setWidth(aRet.getWidth() + 1); + if ( m_xSection.is() && (static_cast<sal_uInt32>(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) ) + m_xSection->setHeight(aRet.getHeight() + aRet.Top()); + } + pBase->StartListening(); + } + } // for (sal_Int32 i = 0; i < nCount; ++i) + } + catch(uno::Exception) + { + OSL_ENSURE(0,"Exception caught: OReportSection::_propertyChanged("); + } + + Resize(); + } + } +} +//------------------------------------------------------------------------------ +sal_Bool OReportSection::handleKeyEvent(const KeyEvent& _rEvent) +{ + return m_pFunc.get() ? m_pFunc->handleKeyEvent(_rEvent) : sal_False; +} +// ----------------------------------------------------------------------------- +void OReportSection::deactivateOle() +{ + if ( m_pFunc.get() ) + m_pFunc->deactivateOle(true); +} +// ----------------------------------------------------------------------------- +void OReportSection::createDefault(const ::rtl::OUString& _sType) +{ + SdrObject* pObj = m_pView->GetCreateObj();//rMarkList.GetMark(0)->GetObj(); + if ( !pObj ) + return; + createDefault(_sType,pObj); +} +// ----------------------------------------------------------------------------- +void OReportSection::createDefault(const ::rtl::OUString& _sType,SdrObject* _pObj) +{ + sal_Bool bAttributesAppliedFromGallery = sal_False; + + if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) + { + std::vector< rtl::OUString > aObjList; + if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) + { + std::vector< rtl::OUString >::iterator aIter = aObjList.begin(); + std::vector< rtl::OUString >::iterator aEnd = aObjList.end(); + for (sal_uInt32 i=0 ; aIter != aEnd; ++aIter,++i) + { + if ( aIter->equalsIgnoreAsciiCase( _sType ) ) + { + OReportModel aReportModel(NULL); + SfxItemPool& rPool = aReportModel.GetItemPool(); + rPool.FreezeIdRanges(); + if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aReportModel ) ) + { + const SdrObject* pSourceObj = aReportModel.GetPage( 0 )->GetObj( 0 ); + if( pSourceObj ) + { + const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); + SfxItemSet aDest( _pObj->GetModel()->GetItemPool(), // ranges from SdrAttrObj + SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + // Graphic Attributes + SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, + // 3d Properties + SDRATTR_3D_FIRST, SDRATTR_3D_LAST, + // CustomShape properties + SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST, + // range from SdrTextObj + EE_ITEMS_START, EE_ITEMS_END, + // end + 0, 0); + aDest.Set( rSource ); + _pObj->SetMergedItemSet( aDest ); + sal_Int32 nAngle = pSourceObj->GetRotateAngle(); + if ( nAngle ) + { + double a = nAngle * F_PI18000; + _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); + } + bAttributesAppliedFromGallery = sal_True; + } + } + break; + } + } + } + } + if ( !bAttributesAppliedFromGallery ) + { + _pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER ,ITEMID_ADJUST) ); + _pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); + _pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) ); + _pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) ); + ((SdrObjCustomShape*)_pObj)->MergeDefaultAttributes( &_sType ); + } +} +// ----------------------------------------------------------------------------- +uno::Reference< report::XReportComponent > OReportSection::getCurrentControlModel() const +{ + uno::Reference< report::XReportComponent > xModel; + if ( m_pView ) + { + const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList(); + sal_uInt32 nMarkCount = rMarkList.GetMarkCount(); + + if ( nMarkCount == 1 ) + { + SdrObject* pDlgEdObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + OObjectBase* pObj = dynamic_cast<OObjectBase*>(pDlgEdObj); + if ( pObj ) + xModel = pObj->getReportComponent().get(); + } + } + return xModel; +} +// ----------------------------------------------------------------------------- +void OReportSection::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const +{ + if ( m_pView ) + { + const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList(); + const sal_uInt32 nMarkCount = rMarkList.GetMarkCount(); + + for (sal_uInt32 i=0; i < nMarkCount; ++i) + { + const SdrObject* pDlgEdObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); + const OObjectBase* pObj = dynamic_cast<const OObjectBase*>(pDlgEdObj); + if ( pObj ) + _rSelection.push_back(pObj->getReportComponent()); + } + } +} +// ----------------------------------------------------------------------------- +sal_Int8 OReportSection::AcceptDrop( const AcceptDropEvent& _rEvt ) +{ + OSL_TRACE("AcceptDrop::DropEvent.Action %i\n", _rEvt.mnAction); + + ::Point aDropPos(_rEvt.maPosPixel); + const MouseEvent aMouseEvt(aDropPos); + if ( m_pFunc->isOverlapping(aMouseEvt) ) + return DND_ACTION_NONE; + + if ( _rEvt.mnAction == DND_ACTION_COPY || + _rEvt.mnAction == DND_ACTION_LINK + ) + { + if (!m_pParent) return DND_ACTION_NONE; + USHORT nCurrentPosition = 0; + nCurrentPosition = m_pParent->getViewsWindow()->getPosition(m_pParent); + if (_rEvt.mnAction == DND_ACTION_COPY ) + { + // we must assure, we can't drop in the top section + if (nCurrentPosition < 1) + { + return DND_ACTION_NONE; + } + return DND_ACTION_LINK; + } + if (_rEvt.mnAction == DND_ACTION_LINK) + { + // we must assure, we can't drop in the bottom section + if (m_pParent->getViewsWindow()->getSectionCount() > (nCurrentPosition + 1) ) + { + return DND_ACTION_COPY; + } + return DND_ACTION_NONE; + } + } + else + { + const DataFlavorExVector& rFlavors = GetDataFlavorExVector(); + if ( ::svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors) + || ::svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, CTF_FIELD_DESCRIPTOR | CTF_CONTROL_EXCHANGE | CTF_COLUMN_DESCRIPTOR) ) + return _rEvt.mnAction; + + const sal_Int8 nDropOption = ( OReportExchange::canExtract(rFlavors) ) ? DND_ACTION_COPYMOVE : DND_ACTION_NONE; + + return nDropOption; + } + return DND_ACTION_NONE; +} + +// ----------------------------------------------------------------------------- +sal_Int8 OReportSection::ExecuteDrop( const ExecuteDropEvent& _rEvt ) +{ + OSL_TRACE("ExecuteDrop::DropEvent.Action %i\n", _rEvt.mnAction); + ::Point aDropPos(PixelToLogic(_rEvt.maPosPixel)); + const MouseEvent aMouseEvt(aDropPos); + if ( m_pFunc->isOverlapping(aMouseEvt) ) + return DND_ACTION_NONE; + + sal_Int8 nDropOption = DND_ACTION_NONE; + const TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable); + DataFlavorExVector& rFlavors = aDropped.GetDataFlavorExVector(); + bool bMultipleFormat = ::svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors); + if ( OReportExchange::canExtract(rFlavors) ) + { + OReportExchange::TSectionElements aCopies = OReportExchange::extractCopies(aDropped); + Paste(aCopies,true); + nDropOption = DND_ACTION_COPYMOVE; + m_pParent->getViewsWindow()->BrkAction(); + m_pParent->getViewsWindow()->unmarkAllObjects(m_pView); + //m_pParent->getViewsWindow()->getView()->setMarked(m_pView,sal_True); + } // if ( OReportExchange::canExtract(rFlavors) ) + else if ( bMultipleFormat + || ::svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, CTF_FIELD_DESCRIPTOR | CTF_CONTROL_EXCHANGE | CTF_COLUMN_DESCRIPTOR) ) + { + m_pParent->getViewsWindow()->getView()->setMarked(m_pView,sal_True); + m_pView->UnmarkAll(); + const Rectangle& rRect = m_pView->GetWorkArea(); + if ( aDropPos.X() < rRect.Left() ) + aDropPos.X() = rRect.Left(); + else if ( aDropPos.X() > rRect.Right() ) + aDropPos.X() = rRect.Right(); + + if ( aDropPos.Y() > rRect.Bottom() ) + aDropPos.Y() = rRect.Bottom(); + + uno::Sequence<beans::PropertyValue> aValues; + if ( !bMultipleFormat ) + { + ::svx::ODataAccessDescriptor aDescriptor = ::svx::OColumnTransferable::extractColumnDescriptor(aDropped); + + aValues.realloc(1); + aValues[0].Value <<= aDescriptor.createPropertyValueSequence(); + } // if ( !bMultipleFormat ) + else + aValues = ::svx::OMultiColumnTransferable::extractDescriptor(aDropped); + + beans::PropertyValue* pIter = aValues.getArray(); + beans::PropertyValue* pEnd = pIter + aValues.getLength(); + for(;pIter != pEnd; ++pIter) + { + uno::Sequence<beans::PropertyValue> aCurrent; + pIter->Value >>= aCurrent; + sal_Int32 nLength = aCurrent.getLength(); + if ( nLength ) + { + aCurrent.realloc(nLength + 3); + aCurrent[nLength].Name = PROPERTY_POSITION; + aCurrent[nLength++].Value <<= AWTPoint(aDropPos); + // give also the DND Action (Shift|Ctrl) Key to really say what we want + aCurrent[nLength].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DNDAction")); + aCurrent[nLength++].Value <<= _rEvt.mnAction; + + aCurrent[nLength].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Section")); + aCurrent[nLength++].Value <<= getSection(); + pIter->Value <<= aCurrent; + } + } + + // we use this way to create undo actions + OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController(); + rController.executeChecked(SID_ADD_CONTROL_PAIR,aValues); + nDropOption = DND_ACTION_COPY; + } + return nDropOption; +} +// ----------------------------------------------------------------------------- +void OReportSection::stopScrollTimer() +{ + m_pFunc->stopScrollTimer(); +} +// ----------------------------------------------------------------------------- +bool OReportSection::isUiActive() const +{ + return m_pFunc->isUiActive(); +} +// ----------------------------------------------------------------------------- +// ============================================================================= +} +// ============================================================================= diff --git a/reportdesign/source/ui/report/ReportWindow.cxx b/reportdesign/source/ui/report/ReportWindow.cxx new file mode 100644 index 000000000000..3a2f4559b43a --- /dev/null +++ b/reportdesign/source/ui/report/ReportWindow.cxx @@ -0,0 +1,444 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "ReportWindow.hxx" +#include "ReportSection.hxx" +#include "SectionView.hxx" +#include "ViewsWindow.hxx" +#include "ReportRuler.hxx" +#include "DesignView.hxx" + +#include <tools/debug.hxx> +#include <svtools/colorcfg.hxx> +#include <svl/itempool.hxx> +#include <unotools/syslocale.hxx> + +#include "RptDef.hxx" +#include "dlgedfunc.hxx" +#include "RptModel.hxx" +#include "uistrings.hrc" +#include "RptPage.hxx" +#include "ReportController.hxx" +#include "EndMarker.hxx" +#include "ColorChanger.hxx" +#include "ScrollHelper.hxx" + +#include "helpids.hrc" +#include "dlgedfac.hxx" +#include <boost/bind.hpp> +#include <toolkit/helper/vclunohelper.hxx> + + +#define SECTION_OFFSET 3 +namespace rptui +{ +using namespace ::com::sun::star; +using namespace ::comphelper; +//================================================================== +// class OReportWindow +//================================================================== +DBG_NAME( rpt_OReportWindow ) +//------------------------------------------------------------------------------ +OReportWindow::OReportWindow(OScrollWindowHelper* _pParent,ODesignView* _pView) +: Window(_pParent,WB_DIALOGCONTROL) +,m_aHRuler(this) +,m_pView(_pView) +,m_pParent(_pParent) +,m_aViewsWindow(this) +,m_pObjFac( new DlgEdFactory() ) +{ + DBG_CTOR( rpt_OReportWindow,NULL); + SetHelpId(UID_RPT_REPORTWINDOW); + SetMapMode( MapMode( MAP_100TH_MM ) ); + + m_aViewsWindow.Show(); + + m_aHRuler.Show(); + m_aHRuler.Activate(); + m_aHRuler.SetPagePos(0); + m_aHRuler.SetBorders(); + m_aHRuler.SetIndents(); + m_aHRuler.SetMargin1(); + m_aHRuler.SetMargin2(); + const MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); + m_aHRuler.SetUnit(MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH); + + ImplInitSettings(); +} +//------------------------------------------------------------------------------ +OReportWindow::~OReportWindow() +{ + DBG_DTOR( rpt_OReportWindow,NULL); +} +// ----------------------------------------------------------------------------- +void OReportWindow::initialize() +{ + m_aViewsWindow.initialize(); +} +//---------------------------------------------------------------------------- +void OReportWindow::SetInsertObj( USHORT eObj,const ::rtl::OUString& _sShapeType ) +{ + m_aViewsWindow.SetInsertObj( eObj,_sShapeType); +} + +//---------------------------------------------------------------------------- +rtl::OUString OReportWindow::GetInsertObjString() const +{ + return m_aViewsWindow.GetInsertObjString(); +} +//------------------------------------------------------------------------------ +void OReportWindow::SetMode( DlgEdMode eNewMode ) +{ + m_aViewsWindow.SetMode(eNewMode); +} +//---------------------------------------------------------------------------- +void OReportWindow::removeSection(USHORT _nPosition) +{ + m_aViewsWindow.removeSection(_nPosition); + m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight()); + m_aViewsWindow.Invalidate(INVALIDATE_TRANSPARENT); + //Resize(); +} +//---------------------------------------------------------------------------- +void OReportWindow::addSection(const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry,USHORT _nPosition) +{ + if ( !_xSection.is() ) + return; + + m_aViewsWindow.addSection(_xSection,_sColorEntry,_nPosition); + + m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight()); +} +//------------------------------------------------------------------------------ +void OReportWindow::toggleGrid(sal_Bool _bVisible) +{ + m_aViewsWindow.toggleGrid(_bVisible); +} +//---------------------------------------------------------------------------- +void OReportWindow::showRuler(sal_Bool _bShow) +{ + m_aHRuler.Show(_bShow); + + m_aViewsWindow.showRuler(_bShow); +} +//------------------------------------------------------------------------------ +sal_Int32 OReportWindow::getMaxMarkerWidth(sal_Bool _bWithEnd) const +{ + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= m_aViewsWindow.GetMapMode().GetScaleX(); + if ( _bWithEnd ) + aStartWidth += Fraction(long(REPORT_ENDMARKER_WIDTH)); + return sal_Int32((long)aStartWidth); +} +//------------------------------------------------------------------------------ +sal_Int32 OReportWindow::GetTotalWidth() const +{ + sal_Int32 nWidth = 0; + if ( !m_aViewsWindow.empty() ) + { + Fraction aStartWidth(long(REPORT_ENDMARKER_WIDTH + REPORT_STARTMARKER_WIDTH )); + const Fraction aZoom(m_pView->getController().getZoomValue(),100); + aStartWidth *= aZoom; // m_aViewsWindow.GetMapMode().GetScaleX();; + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width; + Fraction aPaperWidth(nPaperWidth,1); + aPaperWidth *= aZoom; + const Size aPageSize = LogicToPixel(Size(aPaperWidth,0)); + nWidth = aPageSize.Width() + long(aStartWidth); + } + return nWidth; +} +//------------------------------------------------------------------------------ +void OReportWindow::Resize() +{ + Window::Resize(); + if ( !m_aViewsWindow.empty() ) + { + const Size aTotalOutputSize = GetOutputSizePixel(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)*m_pView->getController().getZoomValue(),100); + + const Point aOffset = LogicToPixel( Point( SECTION_OFFSET, 0 ), MAP_APPFONT ); + Point aStartPoint((long)aStartWidth + aOffset.X(),0); + uno::Reference<report::XReportDefinition> xReportDefinition = getReportView()->getController().getReportDefinition(); + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width; + sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + Size aPageSize = m_aViewsWindow.LogicToPixel(Size(nPaperWidth ,0)); + nLeftMargin = m_aViewsWindow.LogicToPixel(Size(nLeftMargin,0)).Width(); + nRightMargin = m_aViewsWindow.LogicToPixel(Size(nRightMargin,0)).Width(); + + aPageSize.Height() = m_aHRuler.GetSizePixel().Height(); + + const long nTermp(m_aViewsWindow.getTotalHeight() + aPageSize.Height()); + long nSectionsHeight = ::std::max<long>(nTermp,aTotalOutputSize.Height()); + + m_aHRuler.SetPosSizePixel(aStartPoint,aPageSize); + m_aHRuler.SetNullOffset(nLeftMargin); + m_aHRuler.SetMargin1(0); + m_aHRuler.SetMargin2(aPageSize.Width() - nLeftMargin - nRightMargin); + + aStartPoint.Y() += aPageSize.Height(); + nSectionsHeight -= aStartPoint.Y(); + + aStartPoint.X() = aOffset.X(); + + m_aViewsWindow.SetPosSizePixel(aStartPoint,Size(aTotalOutputSize.Width(),nSectionsHeight)); + } +} +//------------------------------------------------------------------------------ +Point OReportWindow::getThumbPos() const +{ + return m_pParent->getThumbPos(); +} +//------------------------------------------------------------------------------ +void OReportWindow::ImplInitSettings() +{ + SetBackground( ); +} +//----------------------------------------------------------------------------- +void OReportWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + ImplInitSettings(); + Invalidate(); + } +} +//------------------------------------------------------------------------------ +sal_Int32 OReportWindow::GetTotalHeight() const +{ + return m_aViewsWindow.getTotalHeight(); +} +//------------------------------------------------------------------------------ +void OReportWindow::ScrollChildren(const Point& _aThumbPos) +{ + MapMode aMap = m_aHRuler.GetMapMode(); + Point aOrg( aMap.GetOrigin() ); + if ( aOrg.X() != (-_aThumbPos.X()) ) + { + aMap.SetOrigin( Point(- _aThumbPos.X(), aOrg.Y())); + m_aHRuler.SetMapMode( aMap ); + m_aHRuler.Scroll(-(aOrg.X() + _aThumbPos.X()),0); + } + + /*const Point aPos(PixelToLogic(_aThumbPos));*/ + m_aViewsWindow.scrollChildren(_aThumbPos); +} +//---------------------------------------------------------------------------- +USHORT OReportWindow::getSectionCount() const +{ + return m_aViewsWindow.getSectionCount(); +} +//---------------------------------------------------------------------------- +void OReportWindow::notifySizeChanged() +{ + m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight()); +} +//---------------------------------------------------------------------------- +BOOL OReportWindow::HasSelection() const +{ + return m_aViewsWindow.HasSelection(); +} +//---------------------------------------------------------------------------- +void OReportWindow::Delete() +{ + + m_aViewsWindow.Delete(); +} +//---------------------------------------------------------------------------- +void OReportWindow::Copy() +{ + + m_aViewsWindow.Copy(); +} +//---------------------------------------------------------------------------- +void OReportWindow::Paste() +{ + + m_aViewsWindow.Paste(); +} +//---------------------------------------------------------------------------- +BOOL OReportWindow::IsPasteAllowed() const +{ + return m_aViewsWindow.IsPasteAllowed(); +} +//----------------------------------------------------------------------------- +void OReportWindow::SelectAll(const sal_uInt16 _nObjectType) +{ + + m_aViewsWindow.SelectAll(_nObjectType); +} +//----------------------------------------------------------------------------- +void OReportWindow::unmarkAllObjects(OSectionView* _pSectionView) +{ + + m_aViewsWindow.unmarkAllObjects(_pSectionView); +} +//----------------------------------------------------------------------------- +void OReportWindow::showProperties(const uno::Reference< report::XSection>& _xReportComponent) +{ + ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_aViewsWindow.getSectionWindow( _xReportComponent ); + m_pView->UpdatePropertyBrowserDelayed(pSectionWindow->getReportSection().getSectionView()); +} +//------------------------------------------------------------------------------ +sal_Bool OReportWindow::handleKeyEvent(const KeyEvent& _rEvent) +{ + return m_aViewsWindow.handleKeyEvent(_rEvent); +} +//------------------------------------------------------------------------ +void OReportWindow::setMarked(OSectionView* _pSectionView,sal_Bool _bMark) +{ + if ( _pSectionView ) + m_aViewsWindow.setMarked(_pSectionView,_bMark); +} +//------------------------------------------------------------------------ +void OReportWindow::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark) +{ + + m_aViewsWindow.setMarked(_xSection,_bMark); +} +//------------------------------------------------------------------------ +void OReportWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _xShape,sal_Bool _bMark) +{ + + m_aViewsWindow.setMarked(_xShape,_bMark); +} +//----------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OReportWindow::getMarkedSection(NearSectionAccess nsa) const +{ + return m_aViewsWindow.getMarkedSection(nsa); +} +//----------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OReportWindow::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const +{ + return m_aViewsWindow.getSectionWindow(_xSection); +} +// ------------------------------------------------------------------------- +void OReportWindow::markSection(const sal_uInt16 _nPos) +{ + + m_aViewsWindow.markSection(_nPos); +} +// ----------------------------------------------------------------------------- +void OReportWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const +{ + + m_aViewsWindow.fillCollapsedSections(_rCollapsedPositions); +} +// ----------------------------------------------------------------------------- +void OReportWindow::collapseSections(const uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections) +{ + + m_aViewsWindow.collapseSections(_aCollpasedSections); +} +// ----------------------------------------------------------------------------- +void OReportWindow::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool bBoundRects) +{ + + m_aViewsWindow.alignMarkedObjects(_nControlModification, _bAlignAtSection, bBoundRects); +} +// ----------------------------------------------------------------------------- +void OReportWindow::setGridSnap(BOOL bOn) +{ + + m_aViewsWindow.setGridSnap(bOn); +} +// ----------------------------------------------------------------------------- +void OReportWindow::setDragStripes(BOOL bOn) +{ + m_aViewsWindow.setDragStripes(bOn); +} +// ----------------------------------------------------------------------------- +sal_uInt32 OReportWindow::getMarkedObjectCount() const +{ + return m_aViewsWindow.getMarkedObjectCount(); +} +// ----------------------------------------------------------------------------- +void OReportWindow::zoom(const Fraction& _aZoom) +{ + m_aHRuler.SetZoom(_aZoom); + m_aHRuler.Invalidate(); + + //setZoomFactor(_aZoom,*this); // if this will be include the H - ruler has the wrong size + m_aViewsWindow.zoom(_aZoom); + + notifySizeChanged(); + const Point aNewThumbPos( m_pParent->getThumbPos() ); + + ScrollChildren( aNewThumbPos ); + Resize(); + + Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); +} +// ----------------------------------------------------------------------------- +void OReportWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const +{ + m_aViewsWindow.fillControlModelSelection(_rSelection); +} +// ----------------------------------------------------------------------------- +sal_Int32 OReportWindow::impl_getRealPixelWidth() const +{ + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width; + MapMode aMap( MAP_100TH_MM ); + const Size aPageSize = LogicToPixel(Size(nPaperWidth,0),aMap); + return aPageSize.Width() + REPORT_ENDMARKER_WIDTH + REPORT_STARTMARKER_WIDTH + SECTION_OFFSET; +} +// ----------------------------------------------------------------------------- +sal_uInt16 OReportWindow::getZoomFactor(SvxZoomType _eType) const +{ + sal_uInt16 nZoom(100); + const Size aSize( GetSizePixel() ); + switch( _eType) + { + case SVX_ZOOM_PERCENT: + nZoom = m_pView->getController().getZoomValue(); + break; + case SVX_ZOOM_OPTIMAL: + break; + case SVX_ZOOM_WHOLEPAGE: + { + nZoom = (USHORT)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth()); + MapMode aMap( MAP_100TH_MM ); + const Size aHeight = m_aViewsWindow.LogicToPixel(m_aViewsWindow.PixelToLogic(Size(0,GetTotalHeight() + m_aHRuler.GetSizePixel().Height())),aMap); + nZoom = ::std::min(nZoom,(USHORT)(long)Fraction(aSize.Height()*100,aHeight.Height())); + } + break; + case SVX_ZOOM_PAGEWIDTH: + nZoom = (USHORT)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth()); + break; + default: + break; + } + + return nZoom; +} +//================================================================== +} //rptui +//================================================================== + diff --git a/reportdesign/source/ui/report/ScrollHelper.cxx b/reportdesign/source/ui/report/ScrollHelper.cxx new file mode 100644 index 000000000000..b6ab83e24a64 --- /dev/null +++ b/reportdesign/source/ui/report/ScrollHelper.cxx @@ -0,0 +1,416 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "ScrollHelper.hxx" +#include "DesignView.hxx" +#include "ReportController.hxx" +#include "ReportWindow.hxx" +#include "UITools.hxx" +#include <tools/debug.hxx> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <toolkit/helper/convert.hxx> +#include <vcl/svapp.hxx> + +namespace rptui +{ +#define LINE_SIZE 50 +#define SECTION_OFFSET 3 +#define SCR_LINE_SIZE 10 +using namespace ::com::sun::star; + +// ----------------------------------------------------------------------------- +void lcl_setScrollBar(sal_Int32 _nNewValue,const Point& _aPos,const Size& _aSize,ScrollBar& _rScrollBar) +{ + _rScrollBar.SetPosSizePixel(_aPos,_aSize); + _rScrollBar.SetPageSize( _nNewValue ); + _rScrollBar.SetVisibleSize( _nNewValue ); +} + +// ----------------------------------------------------------------------------- +DBG_NAME( rpt_OScrollWindowHelper ); +OScrollWindowHelper::OScrollWindowHelper( ODesignView* _pDesignView) + : OScrollWindowHelper_BASE( _pDesignView,WB_DIALOGCONTROL) + ,OPropertyChangeListener(m_aMutex) + ,m_aHScroll( this, WB_HSCROLL|WB_REPEAT|WB_DRAG ) + ,m_aVScroll( this, WB_VSCROLL|WB_REPEAT|WB_DRAG ) + ,m_aCornerWin( this ) + ,m_pParent(_pDesignView) + ,m_aReportWindow(this,m_pParent) + ,m_pReportDefintionMultiPlexer(NULL) +{ + DBG_CTOR( rpt_OScrollWindowHelper,NULL); + SetMapMode( MapMode( MAP_100TH_MM ) ); + + impl_initScrollBar( m_aHScroll ); + impl_initScrollBar( m_aVScroll ); + + m_aReportWindow.SetMapMode( MapMode( MAP_100TH_MM ) ); + m_aReportWindow.Show(); + + // normally we should be SCROLL_PANE + SetAccessibleRole(accessibility::AccessibleRole::SCROLL_PANE); + ImplInitSettings(); +} + +// ----------------------------------------------------------------------------- +OScrollWindowHelper::~OScrollWindowHelper() +{ + DBG_DTOR( rpt_OScrollWindowHelper,NULL); + if ( m_pReportDefintionMultiPlexer.is() ) + m_pReportDefintionMultiPlexer->dispose(); +} + +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::impl_initScrollBar( ScrollBar& _rScrollBar ) const +{ + AllSettings aSettings( _rScrollBar.GetSettings() ); + StyleSettings aStyle( aSettings.GetStyleSettings() ); + aStyle.SetDragFullOptions( aStyle.GetDragFullOptions() | DRAGFULL_OPTION_SCROLL ); // live scrolling + aSettings.SetStyleSettings( aStyle ); + _rScrollBar.SetSettings( aSettings ); + //_rScrollBar.SetMapMode( MapMode( MAP_100TH_MM ) ); + + _rScrollBar.SetScrollHdl( LINK( this, OScrollWindowHelper, ScrollHdl ) ); + _rScrollBar.SetLineSize( SCR_LINE_SIZE ); +} + +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::initialize() +{ + uno::Reference<report::XReportDefinition> xReportDefinition = m_pParent->getController().getReportDefinition(); + m_pReportDefintionMultiPlexer = addStyleListener(xReportDefinition,this); + + m_aReportWindow.initialize(); +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::setTotalSize(sal_Int32 _nWidth ,sal_Int32 _nHeight) +{ + m_aTotalPixelSize.Width() = _nWidth; + m_aTotalPixelSize.Height() = _nHeight; + + // now set the ranges without start marker + Fraction aStartWidth(REPORT_STARTMARKER_WIDTH * m_pParent->getController().getZoomValue(),100); + long nWidth = long(_nWidth - (double)aStartWidth); + m_aHScroll.SetRangeMax( nWidth ); + m_aVScroll.SetRangeMax( m_aTotalPixelSize.Height() ); + + Resize(); +} +//------------------------------------------------------------------------------ +Size OScrollWindowHelper::ResizeScrollBars() +{ + // get the new output-size in pixel + Size aOutPixSz = GetOutputSizePixel(); + if ( aOutPixSz.Width() == 0 || aOutPixSz.Height() == 0 ) + return aOutPixSz; + + aOutPixSz.Height() -= m_aReportWindow.getRulerHeight(); + // determine the size of the output-area and if we need scrollbars + const long nScrSize = GetSettings().GetStyleSettings().GetScrollBarSize(); + bool bVVisible = false; // by default no vertical-ScrollBar + bool bHVisible = false; // by default no horizontal-ScrollBar + bool bChanged; // determines if a visiblility was changed + do + { + bChanged = false; + + // does we need a vertical ScrollBar + if ( aOutPixSz.Width() < m_aTotalPixelSize.Width() && !bHVisible ) + { + bHVisible = true; + aOutPixSz.Height() -= nScrSize; + bChanged = true; + } + + // does we need a horizontal ScrollBar + if ( aOutPixSz.Height() < m_aTotalPixelSize.Height() && !bVVisible ) + { + bVVisible = true; + aOutPixSz.Width() -= nScrSize; + bChanged = true; + } + + } + while ( bChanged ); // until no visibility has changed + + aOutPixSz.Height() += m_aReportWindow.getRulerHeight(); + + // show or hide scrollbars + m_aVScroll.Show( bVVisible ); + m_aHScroll.Show( bHVisible ); + + // disable painting in the corner between the scrollbars + if ( bVVisible && bHVisible ) + { + m_aCornerWin.SetPosSizePixel(Point(aOutPixSz.Width(), aOutPixSz.Height()), Size(nScrSize, nScrSize) ); + m_aCornerWin.Show(); + } + else + m_aCornerWin.Hide(); + + const Point aOffset = LogicToPixel( Point( SECTION_OFFSET, SECTION_OFFSET ), MAP_APPFONT ); + // resize scrollbars and set their ranges + { + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH*m_pParent->getController().getZoomValue()),100); + const sal_Int32 nNewWidth = aOutPixSz.Width() - aOffset.X() - (long)aStartWidth; + lcl_setScrollBar(nNewWidth,Point( (long)aStartWidth + aOffset.X(), aOutPixSz.Height() ),Size( nNewWidth, nScrSize ),m_aHScroll); + } + { + const sal_Int32 nNewHeight = aOutPixSz.Height() - m_aReportWindow.getRulerHeight(); + lcl_setScrollBar(nNewHeight,Point( aOutPixSz.Width(), m_aReportWindow.getRulerHeight() ),Size( nScrSize,nNewHeight),m_aVScroll); + } + + return aOutPixSz; +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::Resize() +{ + OScrollWindowHelper_BASE::Resize(); + const Size aTotalOutputSize = ResizeScrollBars(); + + m_aReportWindow.SetPosSizePixel(Point( 0, 0 ),aTotalOutputSize); +} +//------------------------------------------------------------------------------ +IMPL_LINK( OScrollWindowHelper, ScrollHdl, ScrollBar*, /*pScroll*/ ) +{ + m_aReportWindow.ScrollChildren( getThumbPos() ); + return 0; +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::addSection(const uno::Reference< report::XSection >& _xSection + ,const ::rtl::OUString& _sColorEntry + ,USHORT _nPosition) +{ + m_aReportWindow.addSection(_xSection,_sColorEntry,_nPosition); +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::removeSection(USHORT _nPosition) +{ + m_aReportWindow.removeSection(_nPosition); +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::toggleGrid(sal_Bool _bVisible) +{ + m_aReportWindow.toggleGrid(_bVisible); +} +//------------------------------------------------------------------------------ +USHORT OScrollWindowHelper::getSectionCount() const +{ + return m_aReportWindow.getSectionCount(); +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::SetInsertObj( USHORT eObj,const ::rtl::OUString& _sShapeType ) +{ + m_aReportWindow.SetInsertObj(eObj,_sShapeType); +} +//---------------------------------------------------------------------------- +rtl::OUString OScrollWindowHelper::GetInsertObjString() const +{ + return m_aReportWindow.GetInsertObjString(); +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::SetMode( DlgEdMode _eNewMode ) +{ + m_aReportWindow.SetMode(_eNewMode); +} +//------------------------------------------------------------------------------ +BOOL OScrollWindowHelper::HasSelection() const +{ + return m_aReportWindow.HasSelection(); +} +//---------------------------------------------------------------------------- +void OScrollWindowHelper::Delete() +{ + m_aReportWindow.Delete(); +} +//---------------------------------------------------------------------------- +void OScrollWindowHelper::Copy() +{ + m_aReportWindow.Copy(); +} +//---------------------------------------------------------------------------- +void OScrollWindowHelper::Paste() +{ + m_aReportWindow.Paste(); +} +//---------------------------------------------------------------------------- +BOOL OScrollWindowHelper::IsPasteAllowed() const +{ + return m_aReportWindow.IsPasteAllowed(); +} +//----------------------------------------------------------------------------- +void OScrollWindowHelper::SelectAll(const sal_uInt16 _nObjectType) +{ + m_aReportWindow.SelectAll(_nObjectType); +} +//---------------------------------------------------------------------------- +void OScrollWindowHelper::unmarkAllObjects(OSectionView* _pSectionView) +{ + m_aReportWindow.unmarkAllObjects(_pSectionView); +} +//------------------------------------------------------------------------------ +sal_Int32 OScrollWindowHelper::getMaxMarkerWidth(sal_Bool _bWithEnd) const +{ + return m_aReportWindow.getMaxMarkerWidth(_bWithEnd); +} +//---------------------------------------------------------------------------- +void OScrollWindowHelper::showRuler(sal_Bool _bShow) +{ + m_aReportWindow.showRuler(_bShow); +} +//------------------------------------------------------------------------------ +sal_Bool OScrollWindowHelper::handleKeyEvent(const KeyEvent& _rEvent) +{ + return m_aReportWindow.handleKeyEvent(_rEvent); +} +//------------------------------------------------------------------------ +void OScrollWindowHelper::setMarked(OSectionView* _pSectionView,sal_Bool _bMark) +{ + m_aReportWindow.setMarked(_pSectionView,_bMark); +} +//------------------------------------------------------------------------ +void OScrollWindowHelper::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark) +{ + m_aReportWindow.setMarked(_xSection,_bMark); +} +//------------------------------------------------------------------------ +void OScrollWindowHelper::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _xShape,sal_Bool _bMark) +{ + m_aReportWindow.setMarked(_xShape,_bMark); +} +// ------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OScrollWindowHelper::getMarkedSection(NearSectionAccess nsa) const +{ + return m_aReportWindow.getMarkedSection(nsa); +} +// ------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OScrollWindowHelper::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const +{ + return m_aReportWindow.getSectionWindow(_xSection); +} +// ------------------------------------------------------------------------- +void OScrollWindowHelper::markSection(const sal_uInt16 _nPos) +{ + m_aReportWindow.markSection(_nPos); +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const +{ + m_aReportWindow.fillCollapsedSections(_rCollapsedPositions); +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::collapseSections(const uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections) +{ + m_aReportWindow.collapseSections(_aCollpasedSections); +} +//------------------------------------------------------------------------------ +long OScrollWindowHelper::Notify( NotifyEvent& rNEvt ) +{ + const CommandEvent* pCommandEvent = rNEvt.GetCommandEvent(); + if ( pCommandEvent && + ( ((pCommandEvent->GetCommand() == COMMAND_WHEEL) || + (pCommandEvent->GetCommand() == COMMAND_STARTAUTOSCROLL) || + (pCommandEvent->GetCommand() == COMMAND_AUTOSCROLL))) ) + { + ScrollBar* pHScrBar = NULL; + ScrollBar* pVScrBar = NULL; + if ( m_aHScroll.IsVisible() ) + pHScrBar = &m_aHScroll; + + if ( m_aVScroll.IsVisible() ) + pVScrBar = &m_aVScroll; + + if ( HandleScrollCommand( *pCommandEvent, pHScrBar, pVScrBar ) ) + return 1L; + } + return OScrollWindowHelper_BASE::Notify(rNEvt); +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool bBoundRects) +{ + m_aReportWindow.alignMarkedObjects(_nControlModification, _bAlignAtSection, bBoundRects); +} +//------------------------------------------------------------------------------ +void OScrollWindowHelper::ImplInitSettings() +{ + SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() )); + // SetBackground( Wallpaper( COL_LIGHTRED )); + SetFillColor( Application::GetSettings().GetStyleSettings().GetFaceColor() ); + SetTextFillColor( Application::GetSettings().GetStyleSettings().GetFaceColor() ); +} +//----------------------------------------------------------------------------- +void OScrollWindowHelper::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + ImplInitSettings(); + Invalidate(); + } +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::_propertyChanged(const beans::PropertyChangeEvent& /*_rEvent*/) throw( uno::RuntimeException) +{ + m_aReportWindow.notifySizeChanged(); +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::setGridSnap(BOOL bOn) +{ + m_aReportWindow.setGridSnap(bOn); +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::setDragStripes(BOOL bOn) +{ + m_aReportWindow.setDragStripes(bOn); +} +// ----------------------------------------------------------------------------- +sal_uInt32 OScrollWindowHelper::getMarkedObjectCount() const +{ + return m_aReportWindow.getMarkedObjectCount(); +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::zoom(const Fraction& _aZoom) +{ + m_aReportWindow.zoom(_aZoom); + Resize(); + Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_TRANSPARENT); +} +// ----------------------------------------------------------------------------- +void OScrollWindowHelper::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const +{ + m_aReportWindow.fillControlModelSelection(_rSelection); +} +// ----------------------------------------------------------------------------- +sal_uInt16 OScrollWindowHelper::getZoomFactor(SvxZoomType _eType) const +{ + return m_aReportWindow.getZoomFactor(_eType); +} +//============================================================================== +} // rptui +//============================================================================== diff --git a/reportdesign/source/ui/report/SectionView.cxx b/reportdesign/source/ui/report/SectionView.cxx new file mode 100644 index 000000000000..e0d836a3d8c5 --- /dev/null +++ b/reportdesign/source/ui/report/SectionView.cxx @@ -0,0 +1,274 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "SectionView.hxx" +#include "DesignView.hxx" +#include <RptPage.hxx> +#include <RptObject.hxx> +#include <RptDef.hxx> +#include <svx/svxids.hrc> +#include <svx/svddrgmt.hxx> +#include <vcl/scrbar.hxx> +#include "ReportSection.hxx" +#include "ReportWindow.hxx" +#include "uistrings.hrc" +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> + +namespace rptui +{ + using namespace ::com::sun::star; +TYPEINIT1( OSectionView, SdrView ); + +//---------------------------------------------------------------------------- +DBG_NAME( rpt_OSectionView ) +OSectionView::OSectionView( SdrModel* pModel, OReportSection* _pSectionWindow, OReportWindow* pEditor ) + :SdrView( pModel, _pSectionWindow ) + ,m_pReportWindow( pEditor ) + ,m_pSectionWindow(_pSectionWindow) +{ + DBG_CTOR( rpt_OSectionView,NULL); + SetBufferedOutputAllowed(true); + SetBufferedOverlayAllowed(true); + SetPageBorderVisible(false); + SetBordVisible(); + SetQuickTextEditMode(FALSE); +} + +//---------------------------------------------------------------------------- + +OSectionView::~OSectionView() +{ + DBG_DTOR( rpt_OSectionView,NULL); +} + +//---------------------------------------------------------------------------- + +void OSectionView::MarkListHasChanged() +{ + DBG_CHKTHIS( rpt_OSectionView,NULL); + SdrView::MarkListHasChanged(); + + if ( m_pReportWindow && m_pSectionWindow && !m_pSectionWindow->getPage()->getSpecialMode() ) + { + //m_pReportWindow->unmarkAllObjects(this); // WHY + DlgEdHint aHint( RPTUI_HINT_SELECTIONCHANGED ); + m_pReportWindow->getReportView()->Broadcast( aHint ); + m_pReportWindow->getReportView()->UpdatePropertyBrowserDelayed(*this); + } +} + +//---------------------------------------------------------------------------- + +void OSectionView::MakeVisible( const Rectangle& rRect, Window& rWin ) +{ + DBG_CHKTHIS( rpt_OSectionView,NULL); + // visible area + MapMode aMap( rWin.GetMapMode() ); + const Point aOrg( aMap.GetOrigin() ); + const Size aVisSize( rWin.GetOutputSize() ); + const Rectangle aVisRect( Point(-aOrg.X(),-aOrg.Y()), aVisSize ); + + // check, if rectangle is inside visible area + if ( !aVisRect.IsInside( rRect ) ) + { + // calculate scroll distance; the rectangle must be inside the visible area + sal_Int32 nScrollX = 0, nScrollY = 0; + + const sal_Int32 nVisLeft = aVisRect.Left(); + const sal_Int32 nVisRight = aVisRect.Right(); + const sal_Int32 nVisTop = aVisRect.Top(); + const sal_Int32 nVisBottom = aVisRect.Bottom(); + + // don't scroll beyond the page size + Size aPageSize = m_pSectionWindow->getPage()->GetSize(); + const sal_Int32 nPageWidth = aPageSize.Width(); + const sal_Int32 nPageHeight = aPageSize.Height(); + + if ( nVisRight + nScrollX > nPageWidth ) + nScrollX = nPageWidth - nVisRight; + + if ( nVisLeft + nScrollX < 0 ) + nScrollX = -nVisLeft; + + if ( nVisBottom + nScrollY > nPageHeight ) + nScrollY = nPageHeight - nVisBottom; + + if ( nVisTop + nScrollY < 0 ) + nScrollY = -nVisTop; + + // scroll window + rWin.Update(); + rWin.Scroll( -nScrollX, -nScrollY ); + aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) ); + rWin.SetMapMode( aMap ); + rWin.Update(); + rWin.Invalidate(); + + if ( m_pReportWindow ) + { + const DlgEdHint aHint( RPTUI_HINT_WINDOWSCROLLED ); + m_pReportWindow->getReportView()->Broadcast( aHint ); + } + } + else + { + rWin.Invalidate(INVALIDATE_NOERASE); + } +} +//------------------------------------------------------------------------------ +void OSectionView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +{ + DBG_CHKTHIS( rpt_OSectionView,NULL); + SdrView::Notify(rBC,rHint); + if ( rHint.ISA(SdrHint) ) + { + const SdrObject* pObj = ((SdrHint&)rHint).GetObject(); + const SdrHintKind eKind = ((SdrHint&)rHint).GetKind(); + // check for change of selected object + if(HINT_OBJCHG == eKind && pObj && IsObjMarked(const_cast<SdrObject*>(pObj))) + AdjustMarkHdl(); + else if ( eKind == HINT_OBJREMOVED ) + ObjectRemovedInAliveMode(pObj); + } +} + +//------------------------------------------------------------------------------ +void OSectionView::ObjectRemovedInAliveMode( const SdrObject* _pObject ) +{ + DBG_CHKTHIS( rpt_OSectionView,NULL); + const SdrMarkList& rMarkedList = GetMarkedObjectList(); + const ULONG nMark = rMarkedList.GetMarkCount(); + + for( ULONG i = 0; i < nMark; i++ ) + { + SdrObject* pSdrObj = rMarkedList.GetMark(i)->GetMarkedSdrObj(); + if (_pObject == pSdrObj) + { + SdrPageView* pPgView = GetSdrPageView(); + BrkAction(); + MarkObj( pSdrObj, pPgView, TRUE ); + break; + } + } +} + +// ----------------------------------------------------------------------------- +void OSectionView::SetMarkedToLayer( SdrLayerID _nLayerNo ) +{ + if (AreObjectsMarked()) + { + // #i11702# use SdrUndoObjectLayerChange for undo + // STR_UNDO_SELATTR is "Attributes" - should use a different text later + BegUndo( ); + + const SdrMarkList& rMark = GetMarkedObjectList(); + ULONG nCount = rMark.GetMarkCount(); + for (ULONG i=0; i<nCount; i++) + { + SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); + if ( pObj->ISA(OCustomShape) ) + { + AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), _nLayerNo) ); + pObj->SetLayer( _nLayerNo ); + OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj); + try + { + pBaseObj->getReportComponent()->setPropertyValue(PROPERTY_OPAQUE,uno::makeAny(_nLayerNo == RPT_LAYER_FRONT)); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + EndUndo(); + + // #84073# check mark list now instead of later in a timer + CheckMarked(); + MarkListHasChanged(); + } +} +// ----------------------------------------------------------------------------- +bool OSectionView::OnlyShapesMarked() const +{ + const SdrMarkList& rMark = GetMarkedObjectList(); + const ULONG nCount = rMark.GetMarkCount(); + if ( !nCount ) + return false; + ULONG i=0; + for (; i<nCount; i++) + { + SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); + if ( !pObj->ISA(OCustomShape) ) + { + break; + } + } // for (ULONG i=0; i<nCount; i++) + return i == nCount; +} + +bool OSectionView::IsDragResize() const +{ + const SdrDragMethod* pDragMethod = GetDragMethod(); + if (pDragMethod) + { + bool bMoveOnly = pDragMethod->getMoveOnly(); + if (bMoveOnly == false) + { + // current marked components will be resized + return true; + } + } + return false; +} + +// ----------------------------------------------------------------------------- +short OSectionView::GetLayerIdOfMarkedObjects() const +{ + short nRet = SHRT_MAX; + const SdrMarkList &rMrkList = GetMarkedObjectList(); + for ( USHORT i = 0; i < rMrkList.GetMarkCount(); ++i ) + { + const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj(); + if ( nRet == SHRT_MAX ) + nRet = pObj->GetLayer(); + else if ( nRet != pObj->GetLayer() ) + { + nRet = -1; + break; + } + } + if ( nRet == SHRT_MAX ) + nRet = -1; + return nRet; +} + +//============================================================================ +} // rptui +//============================================================================ diff --git a/reportdesign/source/ui/report/SectionWindow.cxx b/reportdesign/source/ui/report/SectionWindow.cxx new file mode 100644 index 000000000000..26ce8c13c2a6 --- /dev/null +++ b/reportdesign/source/ui/report/SectionWindow.cxx @@ -0,0 +1,418 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "SectionWindow.hxx" +#include "ReportWindow.hxx" +#include "ReportRuler.hxx" +#include "rptui_slotid.hrc" +#include "ReportController.hxx" +#include "SectionView.hxx" +#include "RptDef.hxx" +#include "ReportSection.hxx" +#include "DesignView.hxx" +#include "uistrings.hrc" +#include "helpids.hrc" +#include "RptResId.hrc" +#include "StartMarker.hxx" +#include "EndMarker.hxx" +#include "ViewsWindow.hxx" + +#include <svtools/colorcfg.hxx> +#include <boost/bind.hpp> +#include <functional> +#include <algorithm> +#include <vcl/svapp.hxx> +#include <connectivity/dbtools.hxx> + +namespace rptui +{ +#define SECTION_OFFSET 3 + +using namespace ::com::sun::star; +using namespace ::comphelper; + +DBG_NAME( rpt_OSectionWindow ) +OSectionWindow::OSectionWindow( OViewsWindow* _pParent,const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry) +: Window( _pParent,WB_DIALOGCONTROL) +,OPropertyChangeListener(m_aMutex) +,m_pParent(_pParent) +,m_aStartMarker( this,_sColorEntry) +,m_aReportSection( this,_xSection) +,m_aSplitter(this) +,m_aEndMarker( this,_sColorEntry) +{ + DBG_CTOR( rpt_OSectionWindow,NULL); + SetUniqueId(UID_RPT_SECTIONSWINDOW); + const MapMode& rMapMode = _pParent->GetMapMode(); + SetMapMode( rMapMode ); + ImplInitSettings(); + // TRY + m_aSplitter.SetMapMode( MapMode( MAP_100TH_MM ) ); + m_aSplitter.SetStartSplitHdl(LINK(this, OSectionWindow,StartSplitHdl)); + m_aSplitter.SetSplitHdl(LINK(this, OSectionWindow,SplitHdl)); + m_aSplitter.SetEndSplitHdl(LINK(this, OSectionWindow,EndSplitHdl)); + m_aSplitter.SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() )); + m_aSplitter.SetSplitPosPixel(m_aSplitter.LogicToPixel(Size(0,_xSection->getHeight())).Height()); + + + m_aStartMarker.setCollapsedHdl(LINK(this,OSectionWindow,Collapsed)); + + m_aStartMarker.zoom(rMapMode.GetScaleX()); + setZoomFactor(rMapMode.GetScaleX(),m_aReportSection); + setZoomFactor(rMapMode.GetScaleX(),m_aSplitter); + setZoomFactor(rMapMode.GetScaleX(),m_aEndMarker); + + m_aSplitter.Show(); + m_aStartMarker.Show(); + m_aReportSection.Show(); + m_aEndMarker.Show(); + Show(); + + m_pSectionMulti = new OPropertyChangeMultiplexer(this,_xSection.get()); + m_pSectionMulti->addProperty(PROPERTY_NAME); + m_pSectionMulti->addProperty(PROPERTY_HEIGHT); + + beans::PropertyChangeEvent aEvent; + aEvent.Source = _xSection; + aEvent.PropertyName = PROPERTY_NAME; + uno::Reference< report::XGroup > xGroup(_xSection->getGroup()); + if ( xGroup.is() ) + { + m_pGroupMulti = new OPropertyChangeMultiplexer(this,xGroup.get()); + m_pGroupMulti->addProperty(PROPERTY_EXPRESSION); + aEvent.Source = xGroup; + aEvent.PropertyName = PROPERTY_EXPRESSION; + } + + _propertyChanged(aEvent); + SetPaintTransparent(TRUE); +} +// ----------------------------------------------------------------------------- +OSectionWindow::~OSectionWindow() +{ + DBG_DTOR( rpt_OSectionWindow,NULL); + try + { + if ( m_pSectionMulti.is() ) + m_pSectionMulti->dispose(); + if ( m_pGroupMulti.is() ) + m_pGroupMulti->dispose(); + } + catch (uno::Exception&) + { + } +} +// ----------------------------------------------------------------------------- +void OSectionWindow::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException) +{ + const uno::Reference< report::XSection > xSection(_rEvent.Source,uno::UNO_QUERY); + if ( xSection.is() ) + { + const uno::Reference< report::XSection> xCurrentSection = m_aReportSection.getSection(); + if ( _rEvent.PropertyName.equals(PROPERTY_HEIGHT) ) + { + m_pParent->getView()->SetUpdateMode(FALSE); + Resize(); + m_pParent->getView()->notifySizeChanged(); + m_pParent->resize(*this); + m_pParent->getView()->SetUpdateMode(TRUE); + m_aStartMarker.Invalidate(INVALIDATE_NOERASE); + m_aEndMarker.Invalidate(INVALIDATE_NOERASE); + m_aReportSection.Invalidate(/*INVALIDATE_NOERASE*/); + getViewsWindow()->getView()->getReportView()->getController().resetZoomType(); + // Invalidate(INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); + // m_pParent->Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE|INVALIDATE_TRANSPARENT); + // m_pParent->Invalidate(/*INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE |*/ INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); + } + else if ( _rEvent.PropertyName.equals(PROPERTY_NAME) && !xSection->getGroup().is() ) + { + uno::Reference< report::XReportDefinition > xReport = xSection->getReportDefinition(); + if ( setReportSectionTitle(xReport,RID_STR_REPORT_HEADER,::std::mem_fun(&OReportHelper::getReportHeader),::std::mem_fun(&OReportHelper::getReportHeaderOn)) + || setReportSectionTitle(xReport,RID_STR_REPORT_FOOTER,::std::mem_fun(&OReportHelper::getReportFooter),::std::mem_fun(&OReportHelper::getReportFooterOn)) + || setReportSectionTitle(xReport,RID_STR_PAGE_HEADER,::std::mem_fun(&OReportHelper::getPageHeader),::std::mem_fun(&OReportHelper::getPageHeaderOn)) + || setReportSectionTitle(xReport,RID_STR_PAGE_FOOTER,::std::mem_fun(&OReportHelper::getPageFooter),::std::mem_fun(&OReportHelper::getPageFooterOn)) ) + m_aStartMarker.Invalidate(INVALIDATE_NOERASE); + else + { + String sTitle = String(ModuleRes(RID_STR_DETAIL)); + m_aStartMarker.setTitle(sTitle); + m_aStartMarker.Invalidate(INVALIDATE_CHILDREN); + } + } + } // if ( xSection.is() ) + else if ( _rEvent.PropertyName.equals(PROPERTY_EXPRESSION) ) + { + uno::Reference< report::XGroup > xGroup(_rEvent.Source,uno::UNO_QUERY); + if ( xGroup.is() ) + { + if ( !setGroupSectionTitle(xGroup,RID_STR_HEADER,::std::mem_fun(&OGroupHelper::getHeader),::std::mem_fun(&OGroupHelper::getHeaderOn)) ) + setGroupSectionTitle(xGroup,RID_STR_FOOTER,::std::mem_fun(&OGroupHelper::getFooter),::std::mem_fun(&OGroupHelper::getFooterOn)); + } + } +} +// ----------------------------------------------------------------------------- +bool OSectionWindow::setReportSectionTitle(const uno::Reference< report::XReportDefinition>& _xReport,USHORT _nResId,::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> _pGetSection,::std::mem_fun_t<sal_Bool,OReportHelper> _pIsSectionOn) +{ + OReportHelper aReportHelper(_xReport); + const bool bRet = _pIsSectionOn(&aReportHelper) && _pGetSection(&aReportHelper) == m_aReportSection.getSection(); + if ( bRet ) + { + String sTitle = String(ModuleRes(_nResId)); + m_aStartMarker.setTitle(sTitle); + m_aStartMarker.Invalidate(INVALIDATE_CHILDREN); + } // if ( bRet ) + return bRet; +} +// ----------------------------------------------------------------------------- +bool OSectionWindow::setGroupSectionTitle(const uno::Reference< report::XGroup>& _xGroup,USHORT _nResId,::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> _pGetSection,::std::mem_fun_t<sal_Bool,OGroupHelper> _pIsSectionOn) +{ + OGroupHelper aGroupHelper(_xGroup); + const bool bRet = _pIsSectionOn(&aGroupHelper) && _pGetSection(&aGroupHelper) == m_aReportSection.getSection() ; + if ( bRet ) + { + ::rtl::OUString sExpression = _xGroup->getExpression(); + ::rtl::OUString sLabel = getViewsWindow()->getView()->getReportView()->getController().getColumnLabel_throw(sExpression); + if ( sLabel.getLength() ) + { + sExpression = sLabel; + } + + String sTitle = String(ModuleRes(_nResId)); + sTitle.SearchAndReplace('#',sExpression); + m_aStartMarker.setTitle(sTitle); + m_aStartMarker.Invalidate(INVALIDATE_CHILDREN); + } // if ( _pIsSectionOn(&aGroupHelper) ) + return bRet; +} +//------------------------------------------------------------------------------ +void OSectionWindow::ImplInitSettings() +{ + SetBackground( ); + //SetBackground( Wallpaper( COL_RED )); +} +//----------------------------------------------------------------------------- +void OSectionWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + ImplInitSettings(); + Invalidate(); + } +} +//------------------------------------------------------------------------------ +void OSectionWindow::Resize() +{ + Window::Resize(); + + Size aOutputSize = GetOutputSizePixel(); + Fraction aEndWidth(long(REPORT_ENDMARKER_WIDTH)); + aEndWidth *= GetMapMode().GetScaleX(); + + const Point aThumbPos = m_pParent->getView()->getThumbPos(); + aOutputSize.Width() -= aThumbPos.X(); + aOutputSize.Height() -= m_aSplitter.GetSizePixel().Height(); + + if ( m_aStartMarker.isCollapsed() ) + { + Point aPos(0,0); + m_aStartMarker.SetPosSizePixel(aPos,aOutputSize); + } + else + { + const bool bShowEndMarker = m_pParent->getView()->GetTotalWidth() <= (aThumbPos.X() + aOutputSize.Width() ); + + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= GetMapMode().GetScaleX(); + + // set start marker + m_aStartMarker.SetPosSizePixel(Point(0,0),Size(aStartWidth,aOutputSize.Height())); + + // set report section + const uno::Reference< report::XSection> xSection = m_aReportSection.getSection(); + Size aSectionSize = LogicToPixel( Size( 0,xSection->getHeight() ) ); + Point aReportPos(aStartWidth,0); + aSectionSize.Width() = aOutputSize.Width() - (long)aStartWidth; + if ( bShowEndMarker ) + aSectionSize.Width() -= (long)aEndWidth; + + m_aReportSection.SetPosSizePixel(aReportPos,aSectionSize); + + // set splitter + aReportPos.Y() += aSectionSize.Height(); + m_aSplitter.SetPosSizePixel(aReportPos,Size(aSectionSize.Width(),m_aSplitter.GetSizePixel().Height())); + aSectionSize.Height() = (long)(1000 * (double)GetMapMode().GetScaleY()); + m_aSplitter.SetDragRectPixel( Rectangle(Point(aStartWidth,0),aSectionSize)); + + // set end marker + aReportPos.X() += aSectionSize.Width(); + aReportPos.Y() = 0; + m_aEndMarker.Show(bShowEndMarker); + m_aEndMarker.SetPosSizePixel(aReportPos,Size(aEndWidth,aOutputSize.Height())); + } +} +// ----------------------------------------------------------------------------- +void OSectionWindow::setCollapsed(sal_Bool _bCollapsed) +{ + if ( m_aStartMarker.isCollapsed() != _bCollapsed ) + { + m_aStartMarker.setCollapsed(_bCollapsed); + } +} +//----------------------------------------------------------------------------- +void OSectionWindow::showProperties() +{ + m_pParent->getView()->showProperties( m_aReportSection.getSection().get() ); +} +//----------------------------------------------------------------------------- +void OSectionWindow::setMarked(sal_Bool _bMark) +{ + m_aStartMarker.setMarked(_bMark); + m_aEndMarker.setMarked(_bMark); +} +// ----------------------------------------------------------------------------- +IMPL_LINK( OSectionWindow, Collapsed, OColorListener *, _pMarker ) +{ + if ( _pMarker ) + { + sal_Bool bShow = !_pMarker->isCollapsed(); + m_aReportSection.Show(bShow); + m_aEndMarker.Show(bShow); + m_aSplitter.Show(bShow); + + m_pParent->resize(*this); + Resize(); + // TRY + // m_pParent->Invalidate(INVALIDATE_TRANSPARENT | INVALIDATE_NOCHILDREN); + Invalidate(); + } + return 0L; +} +// ----------------------------------------------------------------------------- +void OSectionWindow::zoom(const Fraction& _aZoom) +{ + setZoomFactor(_aZoom,*this); + m_aStartMarker.zoom(_aZoom); + + setZoomFactor(_aZoom,m_aReportSection); + setZoomFactor(_aZoom,m_aSplitter); + setZoomFactor(_aZoom,m_aEndMarker); + //Resize(); + Invalidate(/*INVALIDATE_UPDATE |*/ /* | INVALIDATE_TRANSPARENT *//*INVALIDATE_NOCHILDREN*/); +} +//----------------------------------------------------------------------------- +IMPL_LINK( OSectionWindow, StartSplitHdl, Splitter*, ) +{ + const String sEmpty(ModuleRes(RID_STR_UNDO_CHANGE_SIZE)); + getViewsWindow()->getView()->getReportView()->getController().getUndoMgr()->EnterListAction(sEmpty,String()); + return 0L; +} +//------------------------------------------------------------------------------ +IMPL_LINK( OSectionWindow, EndSplitHdl, Splitter*, ) +{ + getViewsWindow()->getView()->getReportView()->getController().getUndoMgr()->LeaveListAction(); + /*getViewsWindow()->Resize();*/ + return 0L; +} +//----------------------------------------------------------------------------- +IMPL_LINK( OSectionWindow, SplitHdl, Splitter*, _pSplitter ) +{ + if ( !getViewsWindow()->getView()->getReportView()->getController().isEditable() ) + { + return 0L; + } + + sal_Int32 nSplitPos = _pSplitter->GetSplitPosPixel(); + const Point aPos = _pSplitter->GetPosPixel(); + + + const uno::Reference< report::XSection> xSection = m_aReportSection.getSection(); + nSplitPos = m_aSplitter.PixelToLogic(Size(0,nSplitPos)).Height(); + // nSplitPos = xSection->getHeight() + m_aSplitter.PixelToLogic(Size(0,nSplitPos - aPos.Y() )).Height(); + + const sal_Int32 nCount = xSection->getCount(); + for (sal_Int32 i = 0; i < nCount; ++i) + { + uno::Reference<report::XReportComponent> xReportComponent(xSection->getByIndex(i),uno::UNO_QUERY); + if ( xReportComponent.is() /*&& nSplitPos < (xReportComponent->getPositionY() + xReportComponent->getHeight())*/ ) + { + nSplitPos = ::std::max(nSplitPos,xReportComponent->getPositionY() + xReportComponent->getHeight()); + } + } // for (sal_Int32 i = 0; i < nCount; ++i) + + if ( nSplitPos < 0 ) + nSplitPos = 0; + + xSection->setHeight(nSplitPos); + m_aSplitter.SetSplitPosPixel(m_aSplitter.LogicToPixel(Size(0,nSplitPos)).Height()); + + return 0L; +} +// ----------------------------------------------------------------------------- +void lcl_scroll(Window& _rWindow,const Point& _aDelta) +{ + _rWindow.Scroll(-_aDelta.X(),-_aDelta.Y()/*,SCROLL_CHILDREN*//*|SCROLL_CLIP*/); + _rWindow.Invalidate(INVALIDATE_TRANSPARENT); +} +// ----------------------------------------------------------------------------- +void lcl_setOrigin(Window& _rWindow,long _nX, long _nY) +{ + MapMode aMap = _rWindow.GetMapMode(); + aMap.SetOrigin( Point(- _nX, - _nY)); + _rWindow.SetMapMode( aMap ); +} +//---------------------------------------------------------------------------- +void OSectionWindow::scrollChildren(long _nX) +{ + const Point aDelta( _nX,0 ); + + MapMode aMapMode( m_aReportSection.GetMapMode() ); + const Point aOld = aMapMode.GetOrigin(); + lcl_setOrigin(m_aReportSection,aDelta.X(), 0); + + aMapMode = m_aReportSection.GetMapMode(); + const Point aNew = aMapMode.GetOrigin(); + const Point aDiff = aOld - aNew; + { + //OWindowPositionCorrector aCorrector(&m_aReportSection,-aDelta.Width(),0); + lcl_scroll(m_aReportSection,aDiff); + } + + //lcl_setOrigin(m_aEndMarker,_nDeltaX, 0); + lcl_scroll(m_aEndMarker,m_aEndMarker.PixelToLogic(Point(_nX,0))); + + lcl_setOrigin(m_aSplitter,_nX, 0); + lcl_scroll(m_aSplitter,aDiff); + + Resize(); +} +//============================================================================== +} // rptui +//============================================================================== + diff --git a/reportdesign/source/ui/report/StartMarker.cxx b/reportdesign/source/ui/report/StartMarker.cxx new file mode 100644 index 000000000000..c3fed866e534 --- /dev/null +++ b/reportdesign/source/ui/report/StartMarker.cxx @@ -0,0 +1,324 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "StartMarker.hxx" +#include <vcl/image.hxx> +#include <vcl/svapp.hxx> +#include "RptResId.hrc" +#include "ModuleHelper.hxx" +#include "ColorChanger.hxx" +#include "ReportDefines.hxx" +#include "SectionWindow.hxx" +#include "helpids.hrc" +#include <vcl/help.hxx> +#include <vcl/gradient.hxx> +#include <vcl/lineinfo.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <unotools/syslocale.hxx> +#include <svl/smplhint.hxx> + +#define CORNER_SPACE 5 + +//===================================================================== +namespace rptui +{ +//===================================================================== + +Image* OStartMarker::s_pDefCollapsed = NULL; +Image* OStartMarker::s_pDefExpanded = NULL; +Image* OStartMarker::s_pDefCollapsedHC = NULL; +Image* OStartMarker::s_pDefExpandedHC = NULL; +oslInterlockedCount OStartMarker::s_nImageRefCount = 0; + +DBG_NAME( rpt_OStartMarker ) +// ----------------------------------------------------------------------------- +OStartMarker::OStartMarker(OSectionWindow* _pParent,const ::rtl::OUString& _sColorEntry) +: OColorListener(_pParent,_sColorEntry) +,m_aVRuler(this,WB_VERT) +,m_aText(this,WB_HYPHENATION) +,m_aImage(this,WB_LEFT|WB_TOP|WB_SCALE) +,m_pParent(_pParent) +,m_bShowRuler(sal_True) +{ + DBG_CTOR( rpt_OStartMarker,NULL); + SetUniqueId(HID_RPT_STARTMARKER); + + osl_incrementInterlockedCount(&s_nImageRefCount); + initDefaultNodeImages(); + ImplInitSettings(); + m_aText.SetHelpId(HID_RPT_START_TITLE); + m_aImage.SetHelpId(HID_RPT_START_IMAGE); + m_aText.Show(); + m_aImage.Show(); + m_aVRuler.Show(); + m_aVRuler.Activate(); + m_aVRuler.SetPagePos(0); + m_aVRuler.SetBorders(); + m_aVRuler.SetIndents(); + m_aVRuler.SetMargin1(); + m_aVRuler.SetMargin2(); + const MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); + m_aVRuler.SetUnit(MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH); + SetPaintTransparent(TRUE); +} +// ----------------------------------------------------------------------------- +OStartMarker::~OStartMarker() +{ + DBG_DTOR( rpt_OStartMarker,NULL); + if ( osl_decrementInterlockedCount(&s_nImageRefCount) == 0 ) + { + DELETEZ(s_pDefCollapsed); + DELETEZ(s_pDefExpanded); + DELETEZ(s_pDefCollapsedHC); + DELETEZ(s_pDefExpandedHC); + } // if ( osl_decrementInterlockedCount(&s_nImageRefCount) == 0 ) +} +// ----------------------------------------------------------------------------- +sal_Int32 OStartMarker::getMinHeight() const +{ + Fraction aExtraWidth(long(2*REPORT_EXTRA_SPACE)); + aExtraWidth *= GetMapMode().GetScaleX(); + return LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() + (long)aExtraWidth; +} +// ----------------------------------------------------------------------------- +void OStartMarker::Paint( const Rectangle& rRect ) +{ + Window::Paint( rRect ); + //SetUpdateMode(FALSE); + Size aSize = GetOutputSizePixel(); + long nSize = aSize.Width(); + const long nCornerWidth = long(CORNER_SPACE * (double)GetMapMode().GetScaleX()); + + if ( !isCollapsed() ) + { + const long nVRulerWidth = m_aVRuler.GetSizePixel().Width(); + nSize = aSize.Width() - nVRulerWidth/* - m_nCornerSize*/; + SetClipRegion(Region(PixelToLogic(Rectangle(Point(),Size( nSize,aSize.Height()))))); + aSize.Width() += nCornerWidth; + } // if ( !isCollapsed() ) + else + SetClipRegion(); + + const Point aGcc3WorkaroundTemporary; + Rectangle aWholeRect(aGcc3WorkaroundTemporary,aSize); + { + const ColorChanger aColors( this, m_nTextBoundaries, m_nColor ); + PolyPolygon aPoly; + aPoly.Insert(Polygon(aWholeRect,nCornerWidth,nCornerWidth)); + + Color aStartColor(m_nColor); + aStartColor.IncreaseLuminance(10); + USHORT nHue = 0; + USHORT nSat = 0; + USHORT nBri = 0; + aStartColor.RGBtoHSB(nHue, nSat, nBri); + nSat += 40; + Color aEndColor(Color::HSBtoRGB(nHue, nSat, nBri)); + Gradient aGradient(GRADIENT_LINEAR,aStartColor,aEndColor); + aGradient.SetSteps(static_cast<USHORT>(aSize.Height())); + + DrawGradient(PixelToLogic(aPoly) ,aGradient); + } + if ( m_bMarked ) + { + const long nCornerHeight = long(CORNER_SPACE * (double)GetMapMode().GetScaleY()); + Rectangle aRect( Point(nCornerWidth,nCornerHeight), + Size(aSize.Width() - nCornerWidth - nCornerWidth,aSize.Height() - nCornerHeight - nCornerHeight)); + ColorChanger aColors( this, COL_WHITE, COL_WHITE ); + DrawPolyLine(Polygon(PixelToLogic(aRect)),LineInfo(LINE_SOLID,2 )); + } +} +// ----------------------------------------------------------------------------- +void OStartMarker::setColor() +{ + const Color aColor(m_nColor); + Color aTextColor = GetTextColor(); + if ( aColor.GetLuminance() < 128 ) + aTextColor = COL_WHITE; + m_aText.SetTextColor(aTextColor); + m_aText.SetLineColor(m_nColor); +} +// ----------------------------------------------------------------------- +void OStartMarker::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( !rMEvt.IsLeft() ) + return; + + Point aPos( rMEvt.GetPosPixel()); + + const Size aOutputSize = GetOutputSizePixel(); + if( aPos.X() > aOutputSize.Width() || aPos.Y() > aOutputSize.Height() ) + return; + Rectangle aRect(m_aImage.GetPosPixel(),m_aImage.GetSizePixel()); + if ( rMEvt.GetClicks() == 2 || aRect.IsInside( aPos ) ) + { + m_bCollapsed = !m_bCollapsed; + + changeImage(); + + m_aVRuler.Show(!m_bCollapsed && m_bShowRuler); + if ( m_aCollapsedLink.IsSet() ) + m_aCollapsedLink.Call(this); + } + + m_pParent->showProperties(); +} +// ----------------------------------------------------------------------------- +void OStartMarker::changeImage() +{ + Image* pImage = NULL; + if ( GetSettings().GetStyleSettings().GetHighContrastMode() ) + pImage = m_bCollapsed ? s_pDefCollapsedHC : s_pDefExpandedHC; + else + pImage = m_bCollapsed ? s_pDefCollapsed : s_pDefExpanded; + m_aImage.SetImage(*pImage); +} +// ----------------------------------------------------------------------- +void OStartMarker::initDefaultNodeImages() +{ + if ( !s_pDefCollapsed ) + { + s_pDefCollapsed = new Image( ModuleRes( RID_IMG_TREENODE_COLLAPSED ) ); + s_pDefCollapsedHC = new Image( ModuleRes( RID_IMG_TREENODE_COLLAPSED_HC ) ); + s_pDefExpanded = new Image( ModuleRes( RID_IMG_TREENODE_EXPANDED ) ); + s_pDefExpandedHC = new Image( ModuleRes( RID_IMG_TREENODE_EXPANDED_HC ) ); + } + + Image* pImage = NULL; + if ( GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + pImage = m_bCollapsed ? s_pDefCollapsedHC : s_pDefExpandedHC; + } + else + { + pImage = m_bCollapsed ? s_pDefCollapsed : s_pDefExpanded; + } + m_aImage.SetImage(*pImage); + m_aImage.SetMouseTransparent(TRUE); + m_aImage.SetBackground(); + m_aText.SetBackground(); + m_aText.SetMouseTransparent(TRUE); +} +// ----------------------------------------------------------------------- +void OStartMarker::ImplInitSettings() +{ + // SetBackground( Wallpaper( COL_YELLOW )); + SetBackground( ); + SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() ); + setColor(); +} +//------------------------------------------------------------------------------ +void OStartMarker::Resize() +{ + const Size aOutputSize( GetOutputSizePixel() ); + const long nOutputWidth = aOutputSize.Width(); + const long nOutputHeight = aOutputSize.Height(); + + const long nVRulerWidth = m_aVRuler.GetSizePixel().Width(); + const Point aRulerPos(nOutputWidth - nVRulerWidth,0); + m_aVRuler.SetPosSizePixel(aRulerPos,Size(nVRulerWidth,nOutputHeight)); + + Size aImageSize = m_aImage.GetImage().GetSizePixel(); + const MapMode& rMapMode = GetMapMode(); + aImageSize.Width() = long(aImageSize.Width() * (double)rMapMode.GetScaleX()); + aImageSize.Height() = long(aImageSize.Height() * (double)rMapMode.GetScaleY()); + + Fraction aExtraWidth(long(REPORT_EXTRA_SPACE)); + aExtraWidth *= rMapMode.GetScaleX(); + + Point aPos(aImageSize.Width() + (long)(aExtraWidth + aExtraWidth), aExtraWidth); + const long nHeight = ::std::max<sal_Int32>(nOutputHeight - 2*aPos.Y(),LogicToPixel(Size(0,m_aText.GetTextHeight())).Height()); + m_aText.SetPosSizePixel(aPos,Size(aRulerPos.X() - aPos.X(),nHeight)); + + aPos.X() = aExtraWidth; + aPos.Y() += static_cast<sal_Int32>((LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() - aImageSize.Height()) * 0.5) ; + m_aImage.SetPosSizePixel(aPos,aImageSize); +} +// ----------------------------------------------------------------------------- +void OStartMarker::setTitle(const String& _sTitle) +{ + m_aText.SetText(_sTitle); +} +// ----------------------------------------------------------------------------- +void OStartMarker::Notify(SfxBroadcaster & rBc, SfxHint const & rHint) +{ + OColorListener::Notify(rBc, rHint); + if (rHint.ISA(SfxSimpleHint) + && (static_cast< SfxSimpleHint const & >(rHint).GetId() + == SFX_HINT_COLORS_CHANGED)) + { + setColor(); + //m_aText.Invalidate(); + Invalidate(INVALIDATE_CHILDREN); + } +} +//---------------------------------------------------------------------------- +void OStartMarker::showRuler(sal_Bool _bShow) +{ + m_bShowRuler = _bShow; + m_aVRuler.Show(!m_bCollapsed && m_bShowRuler); +} +//------------------------------------------------------------------------------ +void OStartMarker::RequestHelp( const HelpEvent& rHEvt ) +{ + if( m_aText.GetText().Len()) + { + // Hilfe anzeigen + Rectangle aItemRect(rHEvt.GetMousePosPixel(),Size(GetSizePixel().Width(),getMinHeight())); + //aItemRect = LogicToPixel( aItemRect ); + Point aPt = OutputToScreenPixel( aItemRect.TopLeft() ); + aItemRect.Left() = aPt.X(); + aItemRect.Top() = aPt.Y(); + aPt = OutputToScreenPixel( aItemRect.BottomRight() ); + aItemRect.Right() = aPt.X(); + aItemRect.Bottom() = aPt.Y(); + if( rHEvt.GetMode() == HELPMODE_BALLOON ) + Help::ShowBalloon( this, aItemRect.Center(), aItemRect, m_aText.GetText()); + else + Help::ShowQuickHelp( this, aItemRect, m_aText.GetText() ); + } +} +// ----------------------------------------------------------------------------- +void OStartMarker::setCollapsed(sal_Bool _bCollapsed) +{ + OColorListener::setCollapsed(_bCollapsed); + showRuler(_bCollapsed); + changeImage(); +} +// ----------------------------------------------------------------------- +void OStartMarker::zoom(const Fraction& _aZoom) +{ + setZoomFactor(_aZoom,*this); + m_aVRuler.SetZoom(_aZoom); + setZoomFactor(_aZoom,m_aText); + Resize(); + Invalidate(); +} +// ----------------------------------------------------------------------- +// ======================================================================= +} +// ======================================================================= diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx new file mode 100644 index 000000000000..bcd50236aab3 --- /dev/null +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -0,0 +1,1869 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" + +#include "ViewsWindow.hxx" +#include "ScrollHelper.hxx" +#include "UndoActions.hxx" +#include "ReportWindow.hxx" +#include "DesignView.hxx" +#include <svtools/colorcfg.hxx> +#include "ReportController.hxx" +#include "UITools.hxx" +#include "RptDef.hxx" +#include "RptResId.hrc" +#include "SectionView.hxx" +#include "ReportSection.hxx" +#include "uistrings.hrc" +#include "rptui_slotid.hrc" +#include "dlgedclip.hxx" +#include "ColorChanger.hxx" +#include "RptObject.hxx" +#include "RptObject.hxx" +#include "ModuleHelper.hxx" +#include "EndMarker.hxx" +#include <svx/svdpagv.hxx> +#include <svx/unoshape.hxx> +#include <vcl/svapp.hxx> +#include <boost/bind.hpp> + +#include "helpids.hrc" +#include <svx/svdundo.hxx> +#include <toolkit/helper/convert.hxx> +#include <algorithm> +#include <numeric> + +namespace rptui +{ +#define DEFAUL_MOVE_SIZE 100 + +using namespace ::com::sun::star; +using namespace ::comphelper; +// ----------------------------------------------------------------------------- +bool lcl_getNewRectSize(const Rectangle& _aObjRect,long& _nXMov, long& _nYMov,SdrObject* _pObj,SdrView* _pView,sal_Int32 _nControlModification, bool _bBoundRects) +{ + bool bMoveAllowed = _nXMov != 0 || _nYMov != 0; + if ( bMoveAllowed ) + { + Rectangle aNewRect = _aObjRect; + SdrObject* pOverlappedObj = NULL; + do + { + aNewRect = _aObjRect; + switch(_nControlModification) + { + case ControlModification::HEIGHT_GREATEST: + case ControlModification::WIDTH_GREATEST: + aNewRect.setWidth(_nXMov); + aNewRect.setHeight(_nYMov); + break; + default: + aNewRect.Move(_nXMov,_nYMov); + break; + } + if ( dynamic_cast<OUnoObject*>(_pObj) ) + { + pOverlappedObj = isOver(aNewRect,*_pObj->GetPage(),*_pView,true,_pObj); + if ( pOverlappedObj && _pObj != pOverlappedObj ) + { + Rectangle aOverlappingRect = (_bBoundRects ? pOverlappedObj->GetCurrentBoundRect() : pOverlappedObj->GetSnapRect()); + sal_Int32 nXTemp = _nXMov; + sal_Int32 nYTemp = _nYMov; + switch(_nControlModification) + { + case ControlModification::LEFT: + nXTemp += aOverlappingRect.Right() - aNewRect.Left(); + bMoveAllowed = _nXMov != nXTemp; + break; + case ControlModification::RIGHT: + nXTemp += aOverlappingRect.Left() - aNewRect.Right(); + bMoveAllowed = _nXMov != nXTemp; + break; + case ControlModification::TOP: + nYTemp += aOverlappingRect.Bottom() - aNewRect.Top(); + bMoveAllowed = _nYMov != nYTemp; + break; + case ControlModification::BOTTOM: + nYTemp += aOverlappingRect.Top() - aNewRect.Bottom(); + bMoveAllowed = _nYMov != nYTemp; + break; + case ControlModification::CENTER_HORIZONTAL: + if ( _aObjRect.Left() < aOverlappingRect.Left() ) + nXTemp += aOverlappingRect.Left() - aNewRect.Left() - aNewRect.getWidth(); + else + nXTemp += aOverlappingRect.Right() - aNewRect.Left(); + bMoveAllowed = _nXMov != nXTemp; + break; + case ControlModification::CENTER_VERTICAL: + if ( _aObjRect.Top() < aOverlappingRect.Top() ) + nYTemp += aOverlappingRect.Top() - aNewRect.Top() - aNewRect.getHeight(); + else + nYTemp += aOverlappingRect.Bottom() - aNewRect.Top(); + bMoveAllowed = _nYMov != nYTemp; + break; + case ControlModification::HEIGHT_GREATEST: + case ControlModification::WIDTH_GREATEST: + { + Rectangle aIntersectionRect = aNewRect.GetIntersection(aOverlappingRect); + if ( !aIntersectionRect.IsEmpty() ) + { + if ( _nControlModification == ControlModification::WIDTH_GREATEST ) + { + if ( aNewRect.Left() < aIntersectionRect.Left() ) + { + aNewRect.Right() = aIntersectionRect.Left(); + } + else if ( aNewRect.Left() < aIntersectionRect.Right() ) + { + aNewRect.Left() = aIntersectionRect.Right(); + } + } + else if ( _nControlModification == ControlModification::HEIGHT_GREATEST ) + { + if ( aNewRect.Top() < aIntersectionRect.Top() ) + { + aNewRect.Bottom() = aIntersectionRect.Top(); + } + else if ( aNewRect.Top() < aIntersectionRect.Bottom() ) + { + aNewRect.Top() = aIntersectionRect.Bottom(); + } + } + nYTemp = aNewRect.getHeight(); + bMoveAllowed = _nYMov != nYTemp; + nXTemp = aNewRect.getWidth(); + bMoveAllowed = bMoveAllowed && _nXMov != nXTemp; + } + } + break; + default: + break; + } + + _nXMov = nXTemp; + _nYMov = nYTemp; + } + else + pOverlappedObj = NULL; + } + } + while ( pOverlappedObj && bMoveAllowed ); + } + return bMoveAllowed; +} +// ----------------------------------------------------------------------------- + +DBG_NAME( rpt_OViewsWindow ); +OViewsWindow::OViewsWindow( OReportWindow* _pReportWindow) +: Window( _pReportWindow,WB_DIALOGCONTROL) +,m_pParent(_pReportWindow) +,m_bInUnmark(sal_False) +{ + DBG_CTOR( rpt_OViewsWindow,NULL); + SetPaintTransparent(TRUE); + SetUniqueId(UID_RPT_VIEWSWINDOW); + SetMapMode( MapMode( MAP_100TH_MM ) ); + m_aColorConfig.AddListener(this); + ImplInitSettings(); +} +// ----------------------------------------------------------------------------- +OViewsWindow::~OViewsWindow() +{ + m_aColorConfig.RemoveListener(this); + m_aSections.clear(); + + DBG_DTOR( rpt_OViewsWindow,NULL); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::initialize() +{ + +} +// ----------------------------------------------------------------------------- +void OViewsWindow::impl_resizeSectionWindow(OSectionWindow& _rSectionWindow,Point& _rStartPoint,bool _bSet) +{ + const uno::Reference< report::XSection> xSection = _rSectionWindow.getReportSection().getSection(); + + Size aSectionSize = _rSectionWindow.LogicToPixel( Size( 0,xSection->getHeight() ) ); + aSectionSize.Width() = getView()->GetTotalWidth(); + + const sal_Int32 nMinHeight = _rSectionWindow.getStartMarker().getMinHeight(); + if ( _rSectionWindow.getStartMarker().isCollapsed() || nMinHeight > aSectionSize.Height() ) + { + aSectionSize.Height() = nMinHeight; + } + const StyleSettings& rSettings = GetSettings().GetStyleSettings(); + aSectionSize.Height() += (long)(rSettings.GetSplitSize() * (double)_rSectionWindow.GetMapMode().GetScaleY()); + + if ( _bSet ) + _rSectionWindow.SetPosSizePixel(_rStartPoint,aSectionSize); + + _rStartPoint.Y() += aSectionSize.Height(); +} + +// ----------------------------------------------------------------------------- +void OViewsWindow::resize(const OSectionWindow& _rSectionWindow) +{ + bool bSet = false; + Point aStartPoint; + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) + { + const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter); + if ( pSectionWindow.get() == &_rSectionWindow ) + { + aStartPoint = pSectionWindow->GetPosPixel(); + bSet = true; + } // if ( pSectionWindow.get() == &_rSectionWindow ) + + if ( bSet ) + { + impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,bSet); + pSectionWindow->Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); + pSectionWindow->getStartMarker().Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT ); + } + } // for (;aIter != aEnd ; ++aIter,++nPos) + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= GetMapMode().GetScaleX(); + Size aOut = GetOutputSizePixel(); + aOut.Width() = aStartWidth; + aOut = PixelToLogic(aOut); + m_pParent->notifySizeChanged(); + + Rectangle aRect(PixelToLogic(Point(0,0)),aOut); + Invalidate(aRect,INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); +} +//------------------------------------------------------------------------------ +void OViewsWindow::Resize() +{ + Window::Resize(); + if ( !m_aSections.empty() ) + { + const Point aOffset(m_pParent->getThumbPos()); + Point aStartPoint(0,-aOffset.Y()); + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (USHORT nPos=0;aIter != aEnd ; ++aIter,++nPos) + { + const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter); + impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,true); + } // for (;aIter != aEnd ; ++aIter) + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::Paint( const Rectangle& rRect ) +{ + Window::Paint( rRect ); + + Size aOut = GetOutputSizePixel(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= GetMapMode().GetScaleX(); + + aOut.Width() -= (long)aStartWidth; + aOut = PixelToLogic(aOut); + + Rectangle aRect(PixelToLogic(Point(aStartWidth,0)),aOut); + Wallpaper aWall( m_aColorConfig.GetColorValue(::svtools::APPBACKGROUND).nColor ); + DrawWallpaper(aRect,aWall); +} +//------------------------------------------------------------------------------ +void OViewsWindow::ImplInitSettings() +{ + // SetBackground( Wallpaper( COL_LIGHTBLUE )); + SetBackground( ); + SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() ); + SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() ); +} +//----------------------------------------------------------------------------- +void OViewsWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + ImplInitSettings(); + Invalidate(); + } +} +//---------------------------------------------------------------------------- +void OViewsWindow::addSection(const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry,USHORT _nPosition) +{ + ::boost::shared_ptr<OSectionWindow> pSectionWindow( new OSectionWindow(this,_xSection,_sColorEntry) ); + m_aSections.insert(getIteratorAtPos(_nPosition) , TSectionsMap::value_type(pSectionWindow)); + m_pParent->setMarked(&pSectionWindow->getReportSection().getSectionView(),m_aSections.size() == 1); + + Resize(); +} +//---------------------------------------------------------------------------- +void OViewsWindow::removeSection(USHORT _nPosition) +{ + if ( _nPosition < m_aSections.size() ) + { + TSectionsMap::iterator aPos = getIteratorAtPos(_nPosition); + TSectionsMap::iterator aNew = getIteratorAtPos(_nPosition == 0 ? _nPosition+1: _nPosition - 1); + + m_pParent->getReportView()->UpdatePropertyBrowserDelayed((*aNew)->getReportSection().getSectionView()); + + m_aSections.erase(aPos); + Resize(); + } // if ( _nPosition < m_aSections.size() ) +} +//------------------------------------------------------------------------------ +void OViewsWindow::toggleGrid(BOOL _bVisible) +{ + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(&OReportSection::SetGridVisible,_1,_bVisible),TReportPairHelper())); + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(&OReportSection::Window::Invalidate,_1,INVALIDATE_NOERASE),TReportPairHelper())); +} +//------------------------------------------------------------------------------ +sal_Int32 OViewsWindow::getTotalHeight() const +{ + sal_Int32 nHeight = 0; + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) + { + nHeight += (*aIter)->GetSizePixel().Height(); + } + return nHeight; +} +//---------------------------------------------------------------------------- +USHORT OViewsWindow::getSectionCount() const +{ + return static_cast<USHORT>(m_aSections.size()); +} +//---------------------------------------------------------------------------- +void OViewsWindow::SetInsertObj( USHORT eObj,const ::rtl::OUString& _sShapeType ) +{ + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) + (*aIter)->getReportSection().getSectionView().SetCurrentObj( eObj, ReportInventor ); + + m_sShapeType = _sShapeType; +} +//---------------------------------------------------------------------------- +rtl::OUString OViewsWindow::GetInsertObjString() const +{ + return m_sShapeType; +} + +//------------------------------------------------------------------------------ +void OViewsWindow::SetMode( DlgEdMode eNewMode ) +{ + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(&OReportSection::SetMode,_1,eNewMode),TReportPairHelper())); +} +//---------------------------------------------------------------------------- +BOOL OViewsWindow::HasSelection() const +{ + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (;aIter != aEnd && !(*aIter)->getReportSection().getSectionView().AreObjectsMarked(); ++aIter) + ; + return aIter != aEnd; +} +//---------------------------------------------------------------------------- +void OViewsWindow::Delete() +{ + m_bInUnmark = sal_True; + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::mem_fn(&OReportSection::Delete),TReportPairHelper())); + m_bInUnmark = sal_False; +} +//---------------------------------------------------------------------------- +void OViewsWindow::Copy() +{ + uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects; + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(&OReportSection::Copy,_1,::boost::ref(aAllreadyCopiedObjects)),TReportPairHelper())); + + //TSectionsMap::iterator aIter = m_aSections.begin(); + //TSectionsMap::iterator aEnd = m_aSections.end(); + //for (; aIter != aEnd; ++aIter) + // (*aIter)->getReportSection().Copy(aAllreadyCopiedObjects); + OReportExchange* pCopy = new OReportExchange(aAllreadyCopiedObjects); + uno::Reference< datatransfer::XTransferable> aEnsureDelete = pCopy; + pCopy->CopyToClipboard(this); +} +//---------------------------------------------------------------------------- +void OViewsWindow::Paste() +{ + TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(this)); + OReportExchange::TSectionElements aCopies = OReportExchange::extractCopies(aTransferData); + if ( aCopies.getLength() > 1 ) + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(&OReportSection::Paste,_1,aCopies,false),TReportPairHelper())); + else + { + ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection(); + if ( pMarkedSection ) + pMarkedSection->getReportSection().Paste(aCopies,true); + } +} +// --------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OViewsWindow::getSectionWindow(const uno::Reference< report::XSection>& _xSection) const +{ + OSL_ENSURE(_xSection.is(),"Section is NULL!"); + + ::boost::shared_ptr<OSectionWindow> pSectionWindow; + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (; aIter != aEnd ; ++aIter) + { + if ((*aIter)->getReportSection().getSection() == _xSection) + { + pSectionWindow = (*aIter); + break; + } + } + + return pSectionWindow; +} + +//---------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OViewsWindow::getMarkedSection(NearSectionAccess nsa) const +{ + ::boost::shared_ptr<OSectionWindow> pRet; + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + sal_uInt32 nCurrentPosition = 0; + for (; aIter != aEnd ; ++aIter) + { + if ( (*aIter)->getStartMarker().isMarked() ) + { + if (nsa == CURRENT) + { + pRet = (*aIter); + break; + } + else if ( nsa == PREVIOUS ) + { + if (nCurrentPosition > 0) + { + pRet = (*(--aIter)); + if (pRet == NULL) + { + pRet = (*m_aSections.begin()); + } + } + else + { + // if we are out of bounds return the first one + pRet = (*m_aSections.begin()); + } + break; + } + else if ( nsa == POST ) + { + sal_uInt32 nSize = m_aSections.size(); + if ((nCurrentPosition + 1) < nSize) + { + pRet = *(++aIter); + if (pRet == NULL) + { + pRet = (*(--aEnd)); + } + } + else + { + // if we are out of bounds return the last one + pRet = (*(--aEnd)); + } + break; + } + } // ( (*aIter).second->isMarked() ) + ++nCurrentPosition; + } // for (; aIter != aEnd ; ++aIter) + + return pRet; +} +// ------------------------------------------------------------------------- +void OViewsWindow::markSection(const sal_uInt16 _nPos) +{ + if ( _nPos < m_aSections.size() ) + m_pParent->setMarked(m_aSections[_nPos]->getReportSection().getSection(),sal_True); +} +//---------------------------------------------------------------------------- +BOOL OViewsWindow::IsPasteAllowed() const +{ + TransferableDataHelper aTransferData( TransferableDataHelper::CreateFromSystemClipboard( const_cast< OViewsWindow* >( this ) ) ); + return aTransferData.HasFormat(OReportExchange::getDescriptorFormatId()); +} +//----------------------------------------------------------------------------- +void OViewsWindow::SelectAll(const sal_uInt16 _nObjectType) +{ + m_bInUnmark = sal_True; + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(::boost::mem_fn(&OReportSection::SelectAll),_1,_nObjectType),TReportPairHelper())); + m_bInUnmark = sal_False; +} +//----------------------------------------------------------------------------- +void OViewsWindow::unmarkAllObjects(OSectionView* _pSectionView) +{ + if ( !m_bInUnmark ) + { + m_bInUnmark = sal_True; + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd ; ++aIter) + { + if ( &(*aIter)->getReportSection().getSectionView() != _pSectionView ) + { + (*aIter)->getReportSection().deactivateOle(); + (*aIter)->getReportSection().getSectionView().UnmarkAllObj(); + } + } // for (; aIter != aEnd ; ++aIter) + m_bInUnmark = sal_False; + } +} +//----------------------------------------------------------------------------- +/* +::boost::shared_ptr<OSectionWindow> OViewsWindow::getReportSection(const uno::Reference< report::XSection >& _xSection) +{ + OSL_ENSURE(_xSection.is(),"Section is NULL!"); + ::boost::shared_ptr<OSectionWindow> pRet; + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd ; ++aIter) + { + if ( (*aIter)->getReportSection().getSection() == _xSection ) + { + pRet = (*aIter); + break; + } // if ( (*aIter)->getSection() == _xSection ) + } // for (; aIter != aEnd ; ++aIter) + return pRet; +} +*/ +// ----------------------------------------------------------------------- +void OViewsWindow::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32) +{ + ImplInitSettings(); + Invalidate(); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( rMEvt.IsLeft() ) + { + GrabFocus(); + const uno::Sequence< beans::PropertyValue> aArgs; + getView()->getReportView()->getController().executeChecked(SID_SELECT_REPORT,aArgs); + } + Window::MouseButtonDown(rMEvt); +} +//---------------------------------------------------------------------------- +void OViewsWindow::showRuler(sal_Bool _bShow) +{ + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(&OStartMarker::showRuler,_1,_bShow),TStartMarkerHelper())); + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::bind(&OStartMarker::Window::Invalidate,_1,USHORT(INVALIDATE_NOERASE)),TStartMarkerHelper())); +} +//---------------------------------------------------------------------------- +void OViewsWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( rMEvt.IsLeft() ) + { + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) + { + if ( (*aIter)->getReportSection().getSectionView().AreObjectsMarked() ) + { + (*aIter)->getReportSection().MouseButtonUp(rMEvt); + break; + } + } + + // remove special insert mode + for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter) + { + (*aIter)->getReportSection().getPage()->resetSpecialMode(); + } + } +} +//------------------------------------------------------------------------------ +sal_Bool OViewsWindow::handleKeyEvent(const KeyEvent& _rEvent) +{ + sal_Bool bRet = sal_False; + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) + { + //if ( (*aIter).getReportSection().getSectionView().->AreObjectsMarked() ) + if ( (*aIter)->getStartMarker().isMarked() ) + { + bRet = (*aIter)->getReportSection().handleKeyEvent(_rEvent); + } + } + return bRet; +} +//---------------------------------------------------------------------------- +OViewsWindow::TSectionsMap::iterator OViewsWindow::getIteratorAtPos(USHORT _nPos) +{ + TSectionsMap::iterator aRet = m_aSections.end(); + if ( _nPos < m_aSections.size() ) + aRet = m_aSections.begin() + _nPos; + return aRet; +} +//------------------------------------------------------------------------ +void OViewsWindow::setMarked(OSectionView* _pSectionView,sal_Bool _bMark) +{ + OSL_ENSURE(_pSectionView != NULL,"SectionView is NULL!"); + if ( _pSectionView ) + setMarked(_pSectionView->getReportSection()->getSection(),_bMark); +} +//------------------------------------------------------------------------ +void OViewsWindow::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark) +{ + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd ; ++aIter) + { + if ( (*aIter)->getReportSection().getSection() != _xSection ) + { + (*aIter)->setMarked(sal_False); + } + else if ( (*aIter)->getStartMarker().isMarked() != _bMark ) + { + (*aIter)->setMarked(_bMark); + } + } +} +//------------------------------------------------------------------------ +void OViewsWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _aShapes,sal_Bool _bMark) +{ + bool bFirst = true; + const uno::Reference< report::XReportComponent>* pIter = _aShapes.getConstArray(); + const uno::Reference< report::XReportComponent>* pEnd = pIter + _aShapes.getLength(); + for(;pIter != pEnd;++pIter) + { + const uno::Reference< report::XSection> xSection = (*pIter)->getSection(); + if ( xSection.is() ) + { + if ( bFirst ) + { + bFirst = false; + m_pParent->setMarked(xSection,_bMark); + } + ::boost::shared_ptr<OSectionWindow> pSectionWindow = getSectionWindow(xSection); + if ( pSectionWindow ) + { + SvxShape* pShape = SvxShape::getImplementation( *pIter ); + SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL; + OSL_ENSURE( pObject, "OViewsWindow::setMarked: no SdrObject for the shape!" ); + if ( pObject ) + pSectionWindow->getReportSection().getSectionView().MarkObj( pObject, pSectionWindow->getReportSection().getSectionView().GetSdrPageView(), !_bMark ); + } + } + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::collectRectangles(TRectangleMap& _rSortRectangles, bool _bBoundRects) +{ + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter) + { + OSectionView& rView = (*aIter)->getReportSection().getSectionView(); + if ( rView.AreObjectsMarked() ) + { + rView.SortMarkedObjects(); + const sal_uInt32 nCount = rView.GetMarkedObjectCount(); + for (sal_uInt32 i=0; i < nCount; ++i) + { + const SdrMark* pM = rView.GetSdrMarkByIndex(i); + SdrObject* pObj = pM->GetMarkedSdrObj(); + Rectangle aObjRect(_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect()); + _rSortRectangles.insert(TRectangleMap::value_type(aObjRect,TRectangleMap::mapped_type(pObj,&rView))); + } + } + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles,sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects,Rectangle& _rBound,Rectangle& _rResize) +{ + bool bOnlyOnce = false; + TRectangleMap::const_iterator aRectIter = _rSortRectangles.begin(); + TRectangleMap::const_iterator aRectEnd = _rSortRectangles.end(); + for (;aRectIter != aRectEnd ; ++aRectIter) + { + Rectangle aObjRect = aRectIter->first; + if ( _rResize.IsEmpty() ) + _rResize = aObjRect; + switch(_nControlModification) + { + case ControlModification::WIDTH_SMALLEST: + if ( _rResize.getWidth() > aObjRect.getWidth() ) + _rResize = aObjRect; + break; + case ControlModification::HEIGHT_SMALLEST: + if ( _rResize.getHeight() > aObjRect.getHeight() ) + _rResize = aObjRect; + break; + case ControlModification::WIDTH_GREATEST: + if ( _rResize.getWidth() < aObjRect.getWidth() ) + _rResize = aObjRect; + break; + case ControlModification::HEIGHT_GREATEST: + if ( _rResize.getHeight() < aObjRect.getHeight() ) + _rResize = aObjRect; + break; + } + + SdrObjTransformInfoRec aInfo; + const SdrObject* pObj = aRectIter->second.first; + pObj->TakeObjInfo(aInfo); + BOOL bHasFixed = !aInfo.bMoveAllowed || pObj->IsMoveProtect(); + if ( bHasFixed ) + _rBound.Union(aObjRect); + else + { + if ( _bAlignAtSection || _rSortRectangles.size() == 1 ) + { // einzelnes Obj an der Seite ausrichten + if ( ! bOnlyOnce ) + { + bOnlyOnce = true; + OReportSection* pReportSection = aRectIter->second.second->getReportSection(); + const uno::Reference< report::XSection> xSection = pReportSection->getSection(); + try + { + uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition(); + _rBound.Union(Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0, + getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN), + xSection->getHeight())); + } + catch(uno::Exception){} + } + } + else + { + if (_bBoundRects) + _rBound.Union(aRectIter->second.second->GetMarkedObjBoundRect()); + else + _rBound.Union(aRectIter->second.second->GetMarkedObjRect()); + } + } + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects) +{ + if ( _nControlModification == ControlModification::NONE ) + return; + + Point aRefPoint; + RectangleLess::CompareMode eCompareMode = RectangleLess::POS_LEFT; + switch (_nControlModification) + { + case ControlModification::TOP : eCompareMode = RectangleLess::POS_UPPER; break; + case ControlModification::BOTTOM: eCompareMode = RectangleLess::POS_DOWN; break; + case ControlModification::LEFT : eCompareMode = RectangleLess::POS_LEFT; break; + case ControlModification::RIGHT : eCompareMode = RectangleLess::POS_RIGHT; break; + case ControlModification::CENTER_HORIZONTAL : + case ControlModification::CENTER_VERTICAL : + { + eCompareMode = (ControlModification::CENTER_VERTICAL == _nControlModification) ? RectangleLess::POS_CENTER_VERTICAL : RectangleLess::POS_CENTER_HORIZONTAL; + uno::Reference<report::XSection> xSection = (*m_aSections.begin())->getReportSection().getSection(); + uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition(); + aRefPoint = Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0, + getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN), + xSection->getHeight()).Center(); + } + break; + default: break; + } + RectangleLess aCompare(eCompareMode,aRefPoint); + TRectangleMap aSortRectangles(aCompare); + collectRectangles(aSortRectangles,_bBoundRects); + + Rectangle aBound; + Rectangle aResize; + collectBoundResizeRect(aSortRectangles,_nControlModification,_bAlignAtSection,_bBoundRects,aBound,aResize); + + bool bMove = true; + + ::std::mem_fun_t<long&,Rectangle> aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom); + ::std::mem_fun_t<long&,Rectangle> aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top); + TRectangleMap::iterator aRectIter = aSortRectangles.begin(); + TRectangleMap::iterator aRectEnd = aSortRectangles.end(); + for (;aRectIter != aRectEnd ; ++aRectIter) + { + Rectangle aObjRect = aRectIter->first; + SdrObject* pObj = aRectIter->second.first; + SdrView* pView = aRectIter->second.second; + Point aCenter(aBound.Center()); + SdrObjTransformInfoRec aInfo; + pObj->TakeObjInfo(aInfo); + if (aInfo.bMoveAllowed && !pObj->IsMoveProtect()) + { + long nXMov = 0; + long nYMov = 0; + long* pValue = &nXMov; + switch(_nControlModification) + { + case ControlModification::TOP : + aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top); + aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom); + pValue = &nYMov; + break; + case ControlModification::BOTTOM: + // defaults are already set + pValue = &nYMov; + break; + case ControlModification::CENTER_VERTICAL: + nYMov = aCenter.Y() - aObjRect.Center().Y(); + pValue = &nYMov; + bMove = false; + break; + case ControlModification::RIGHT : + aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right); + aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left); + break; + case ControlModification::CENTER_HORIZONTAL: + nXMov = aCenter.X() - aObjRect.Center().X(); + bMove = false; + break; + case ControlModification::LEFT : + aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left); + aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right); + break; + default: + bMove = false; + break; + } + if ( bMove ) + { + Rectangle aTest = aObjRect; + aGetFun(&aTest) = aGetFun(&aBound); + TRectangleMap::iterator aInterSectRectIter = aSortRectangles.begin(); + for (; aInterSectRectIter != aRectIter; ++aInterSectRectIter) + { + if ( pView == aInterSectRectIter->second.second && dynamic_cast<OUnoObject*>(aInterSectRectIter->second.first) ) + { + SdrObject* pPreviousObj = aInterSectRectIter->second.first; + Rectangle aIntersectRect = aTest.GetIntersection(_bBoundRects ? pPreviousObj->GetCurrentBoundRect() : pPreviousObj->GetSnapRect()); + if ( !aIntersectRect.IsEmpty() && (aIntersectRect.Left() != aIntersectRect.Right() && aIntersectRect.Top() != aIntersectRect.Bottom() ) ) + { + *pValue = aRefFun(&aIntersectRect) - aGetFun(&aObjRect); + break; + } + } + } + if ( aInterSectRectIter == aRectIter ) + *pValue = aGetFun(&aBound) - aGetFun(&aObjRect); + } + + if ( lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects) ) + { + const Size aSize(nXMov,nYMov); + pView->AddUndo(pView->GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,aSize)); + pObj->Move(aSize); + aObjRect = (_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect()); + } + + // resizing control + if ( !aResize.IsEmpty() && aObjRect != aResize ) + { + nXMov = aResize.getWidth(); + nYMov = aResize.getHeight(); + switch(_nControlModification) + { + case ControlModification::WIDTH_GREATEST: + case ControlModification::HEIGHT_GREATEST: + if ( _nControlModification == ControlModification::HEIGHT_GREATEST ) + nXMov = aObjRect.getWidth(); + else if ( _nControlModification == ControlModification::WIDTH_GREATEST ) + nYMov = aObjRect.getHeight(); + lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects); + // run through + case ControlModification::WIDTH_SMALLEST: + case ControlModification::HEIGHT_SMALLEST: + pView->AddUndo( pView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + { + OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj); + OSL_ENSURE(pObjBase,"Where comes this object from?"); + if ( pObjBase ) + { + if ( _nControlModification == ControlModification::WIDTH_SMALLEST || _nControlModification == ControlModification::WIDTH_GREATEST ) + pObjBase->getReportComponent()->setSize(awt::Size(nXMov,aObjRect.getHeight())); + //pObj->Resize(aObjRect.TopLeft(),Fraction(nXMov,aObjRect.getWidth()),Fraction(1,1)); + else if ( _nControlModification == ControlModification::HEIGHT_GREATEST || _nControlModification == ControlModification::HEIGHT_SMALLEST ) + pObjBase->getReportComponent()->setSize(awt::Size(aObjRect.getWidth(),nYMov)); + //pObj->Resize(aObjRect.TopLeft(),Fraction(1,1),Fraction(nYMov,aObjRect.getHeight())); + } + } + break; + default: + break; + } + } + } + pView->AdjustMarkHdl(); + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::createDefault() +{ + ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection(); + if ( pMarkedSection ) + pMarkedSection->getReportSection().createDefault(m_sShapeType); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::setGridSnap(BOOL bOn) +{ + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd ; ++aIter) + { + (*aIter)->getReportSection().getSectionView().SetGridSnap(bOn); + (*aIter)->getReportSection().Invalidate(); + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::setDragStripes(BOOL bOn) +{ + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd ; ++aIter) + (*aIter)->getReportSection().getSectionView().SetDragStripes(bOn); +} +// ----------------------------------------------------------------------------- +USHORT OViewsWindow::getPosition(const OSectionWindow* _pSectionWindow) const +{ + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + USHORT nPosition = 0; + for (; aIter != aEnd ; ++aIter) + { + if ( _pSectionWindow == (*aIter).get() ) + { + break; + } + ++nPosition; + } + return nPosition; +} +// ----------------------------------------------------------------------------- +::boost::shared_ptr<OSectionWindow> OViewsWindow::getSectionWindow(const USHORT _nPos) const +{ + ::boost::shared_ptr<OSectionWindow> aReturn; + + if ( _nPos < m_aSections.size() ) + aReturn = m_aSections[_nPos]; + + return aReturn; +} +// ----------------------------------------------------------------------------- +namespace +{ + enum SectionViewAction + { + eEndDragObj, + eEndAction, + eMoveAction, + eMarkAction, + eForceToAnotherPage, + eBreakAction + }; + class ApplySectionViewAction : public ::std::unary_function< OViewsWindow::TSectionsMap::value_type, void > + { + private: + SectionViewAction m_eAction; + sal_Bool m_bCopy; + Point m_aPoint; + + public: + ApplySectionViewAction( sal_Bool _bCopy ) : m_eAction( eEndDragObj ), m_bCopy( _bCopy ) { } + ApplySectionViewAction(SectionViewAction _eAction = eEndAction ) : m_eAction( _eAction ) { } + ApplySectionViewAction( const Point& _rPoint, SectionViewAction _eAction = eMoveAction ) : m_eAction( _eAction ), m_bCopy( sal_False ), m_aPoint( _rPoint ) { } + + void operator() ( const OViewsWindow::TSectionsMap::value_type& _rhs ) + { + OSectionView& rView( _rhs->getReportSection().getSectionView() ); + switch ( m_eAction ) + { + case eEndDragObj: + rView.EndDragObj( m_bCopy ); + break; + case eEndAction: + if ( rView.IsAction() ) + rView.EndAction ( ); + break; + case eMoveAction: + rView.MovAction ( m_aPoint ); + break; + case eMarkAction: + rView.BegMarkObj ( m_aPoint ); + break; + case eForceToAnotherPage: + rView.ForceMarkedToAnotherPage(); + break; + case eBreakAction: + if ( rView.IsAction() ) + rView.BrkAction ( ); + break; + // default: + + } + } + }; +} +// ----------------------------------------------------------------------------- +void OViewsWindow::BrkAction() +{ + EndDragObj_removeInvisibleObjects(); + ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eBreakAction) ); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const Rectangle& _aRect, const OSectionView& _rSection) +{ + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + Point aNewPos(0,0); + + for (; aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + rReportSection.getPage()->setSpecialMode(); + OSectionView& rView = rReportSection.getSectionView(); + + if ( &rView != &_rSection ) + { +// SdrRectObj *pNewObj = new SdrRectObj(OBJ_RECT, _aRect); +// SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Temp Label"))); + SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))); + if (pNewObj) + { + pNewObj->SetLogicRect(_aRect); + // pNewObj->SetSize(_aRect.GetSize()); + // pNewObj->Move(Size(_aRect.Left(), _aRect.Top())); + + pNewObj->Move(Size(0, aNewPos.Y())); + BOOL bChanged = rView.GetModel()->IsChanged(); + rReportSection.getPage()->InsertObject(pNewObj); + rView.GetModel()->SetChanged(bChanged); + m_aBegDragTempList.push_back(pNewObj); + Rectangle aRect = pNewObj->GetLogicRect(); + + // pNewObj->SetText(String::CreateFromAscii("Drag helper")); + rView.MarkObj( pNewObj, rView.GetSdrPageView() ); + } + } + const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + aNewPos.Y() -= nSectionHeight; +// aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); + } +} +// ----------------------------------------------------------------------------- +bool OViewsWindow::isObjectInMyTempList(SdrObject *_pObj) +{ + return ::std::find(m_aBegDragTempList.begin(),m_aBegDragTempList.end(),_pObj) != m_aBegDragTempList.end(); +} + +// ----------------------------------------------------------------------------- +void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionView* _pSection) +{ + OSL_TRACE("BegDragObj Clickpoint X:%d Y:%d\n", _aPnt.X(), _aPnt.Y() ); + + m_aBegDragTempList.clear(); + + // Calculate the absolute clickpoint in the views + Point aAbsolutePnt = _aPnt; + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + OSectionView* pView = &rReportSection.getSectionView(); + if (pView == _pSection) + break; + const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + aAbsolutePnt.Y() += nSectionHeight; + } + m_aDragDelta = Point(SAL_MAX_INT32, SAL_MAX_INT32); + OSL_TRACE("BegDragObj Absolute X:%d Y:%d\n", aAbsolutePnt.X(), aAbsolutePnt.Y() ); + + // Create drag lines over all viewable Views + // Therefore we need to identify the marked objects + // and create temporary objects on all other views at the same position + // relative to its occurance. + + OSL_TRACE("BegDragObj createInvisible Objects\n" ); + int nViewCount = 0; + Point aNewObjPos(0,0); + Point aLeftTop = Point(SAL_MAX_INT32, SAL_MAX_INT32); + for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + + OSectionView& rView = rReportSection.getSectionView(); + + if ( rView.AreObjectsMarked() ) + { + const sal_uInt32 nCount = rView.GetMarkedObjectCount(); + for (sal_uInt32 i=0; i < nCount; ++i) + { + const SdrMark* pM = rView.GetSdrMarkByIndex(i); + SdrObject* pObj = pM->GetMarkedSdrObj(); + if (!isObjectInMyTempList(pObj)) + { + Rectangle aRect( pObj->GetCurrentBoundRect() ); + aRect.Move(0, aNewObjPos.Y()); + + aLeftTop.X() = ::std::min( aRect.Left(), aLeftTop.X() ); + aLeftTop.Y() = ::std::min( aRect.Top(), aLeftTop.Y() ); + + OSL_TRACE("BegDragObj createInvisible X:%d Y:%d on View #%d\n", aRect.Left(), aRect.Top(), nViewCount ); + + BegDragObj_createInvisibleObjectAtPosition(aRect, rView); + + // calculate the clickpoint +// const sal_Int32 nDeltaX = abs(aRect.Left() - aAbsolutePnt.X()); +// const sal_Int32 nDeltaY = abs(aRect.Top() - aAbsolutePnt.Y()); +// if (m_aDragDelta.X() > nDeltaX) +// m_aDragDelta.X() = nDeltaX; +// if (m_aDragDelta.Y() > nDeltaY) +// m_aDragDelta.Y() = nDeltaY; + } + } + } + ++nViewCount; + Rectangle aClipRect = rView.GetWorkArea(); + aClipRect.Top() = -aNewObjPos.Y(); + rView.SetWorkArea( aClipRect ); + + const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + aNewObjPos.Y() += nSectionHeight; + + // don't subtract the height of the lines between the views + // aNewObjPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); + } + + const sal_Int32 nDeltaX = abs(aLeftTop.X() - aAbsolutePnt.X()); + const sal_Int32 nDeltaY = abs(aLeftTop.Y() - aAbsolutePnt.Y()); + m_aDragDelta.X() = nDeltaX; + m_aDragDelta.Y() = nDeltaY; + + Point aNewPos = aAbsolutePnt; + // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + // { + // OReportSection& rReportSection = (*aIter)->getReportSection(); + // if ( &rReportSection.getSectionView() == _pSection ) + // break; + // aNewPos.Y() += rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + // } + + const short nDrgLog = static_cast<short>(PixelToLogic(Size(3,0)).Width()); + // long nLastSectionHeight = 0; + // bool bAdd = true; + nViewCount = 0; + for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + + // if ( &rReportSection.getSectionView() == _pSection ) + // { + // bAdd = false; + // aNewPos = _aPnt; + // } + // else if ( bAdd ) + // { + // const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + // aNewPos.Y() += nSectionHeight; + // } + // else + // { + // aNewPos.Y() -= nLastSectionHeight; + // } + + //? + SdrHdl* pHdl = _pHdl; + if ( pHdl ) + { + if ( &rReportSection.getSectionView() != _pSection ) + { + const SdrHdlList& rHdlList = rReportSection.getSectionView().GetHdlList(); + pHdl = rHdlList.GetHdl(_pHdl->GetKind()); + } + } + OSL_TRACE("BegDragObj X:%d Y:%d on View#%d\n", aNewPos.X(), aNewPos.Y(), nViewCount++ ); + rReportSection.getSectionView().BegDragObj(aNewPos, (OutputDevice*)NULL, pHdl, nDrgLog, NULL); + + const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + aNewPos.Y() -= nSectionHeight; + // subtract the height between the views, because they are visible but not from interest here. + // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); + } +} + +// ----------------------------------------------------------------------------- +void OViewsWindow::ForceMarkedToAnotherPage() +{ + ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eForceToAnotherPage ) ); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::BegMarkObj(const Point& _aPnt,const OSectionView* _pSection) +{ + bool bAdd = true; + Point aNewPos = _aPnt; + + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + long nLastSectionHeight = 0; + for (; aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + if ( &rReportSection.getSectionView() == _pSection ) + { + bAdd = false; + aNewPos = _aPnt; // 2,2 + } + else if ( bAdd ) + { + const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + aNewPos.Y() += nSectionHeight; + } + else + { + aNewPos.Y() -= nLastSectionHeight; + } + rReportSection.getSectionView().BegMarkObj ( aNewPos ); + nLastSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + + // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); + } + //::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( _aPnt , eMarkAction) ); +} +// ----------------------------------------------------------------------------- +OSectionView* OViewsWindow::getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt) +{ + OSectionView* pSection = NULL; + sal_Int32 nCount = 0; + TSectionsMap::iterator aIter = m_aSections.begin(); + const TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd ; ++aIter,++nCount) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + if ( &rReportSection.getSectionView() == _pSection) + break; + } + OSL_ENSURE(aIter != aEnd,"This can never happen!"); + if ( _rPnt.Y() < 0 ) + { + if ( nCount ) + --aIter; + for (; nCount && (_rPnt.Y() < 0); --nCount) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + const sal_Int32 nHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + _rPnt.Y() += nHeight; + if ( (nCount -1) > 0 && (_rPnt.Y() < 0) ) + --aIter; + } + if ( nCount == 0 ) + pSection = &(*m_aSections.begin())->getReportSection().getSectionView(); + else + pSection = &(*aIter)->getReportSection().getSectionView(); + } + else + { + for (; aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + const long nHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + if ( (_rPnt.Y() - nHeight) < 0 ) + break; + _rPnt.Y() -= nHeight; + } + if ( aIter != aEnd ) + pSection = &(*aIter)->getReportSection().getSectionView(); + else + pSection = &(*(aEnd-1))->getReportSection().getSectionView(); + } + + return pSection; +} +// ----------------------------------------------------------------------------- +void OViewsWindow::EndDragObj_removeInvisibleObjects() +{ + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + + for (; aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + rReportSection.getPage()->resetSpecialMode(); + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::EndDragObj(BOOL _bControlKeyPressed, const OSectionView* _pSection,const Point& _aPnt) +{ + const String sUndoAction = String((ModuleRes(RID_STR_UNDO_CHANGEPOSITION))); + UndoManagerListAction aListAction(*getView()->getReportView()->getController().getUndoMgr(),sUndoAction); + + Point aNewPos = _aPnt; + OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aNewPos); + if (!_bControlKeyPressed && + (_pSection && ( _pSection->IsDragResize() == false ) ) && /* Not in resize mode */ + _pSection != pInSection) + { + EndDragObj_removeInvisibleObjects(); + + // we need to manipulate the current clickpoint, we substract the old delta from BeginDrag + // OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aPnt); + // aNewPos.X() -= m_aDragDelta.X(); + // aNewPos.Y() -= m_aDragDelta.Y(); + aNewPos -= m_aDragDelta; + + uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects; + TSectionsMap::iterator aIter = m_aSections.begin(); + const TSectionsMap::iterator aEnd = m_aSections.end(); + for (; aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + if ( pInSection != &rReportSection.getSectionView() ) + { + rReportSection.getSectionView().BrkAction(); + rReportSection.Copy(aAllreadyCopiedObjects,true); + } + else + pInSection->EndDragObj(FALSE); + } // for (; aIter != aEnd; ++aIter) + + if ( aAllreadyCopiedObjects.getLength() ) + { + beans::NamedValue* pIter = aAllreadyCopiedObjects.getArray(); + const beans::NamedValue* pEnd = pIter + aAllreadyCopiedObjects.getLength(); + try + { + uno::Reference<report::XReportDefinition> xReportDefinition = getView()->getReportView()->getController().getReportDefinition(); + const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width; + + if ( aNewPos.X() < nLeftMargin ) + aNewPos.X() = nLeftMargin; + if ( aNewPos.Y() < 0 ) + aNewPos.Y() = 0; + + Point aPrevious; + for (; pIter != pEnd; ++pIter) + { + uno::Sequence< uno::Reference<report::XReportComponent> > aClones; + pIter->Value >>= aClones; + uno::Reference<report::XReportComponent>* pColIter = aClones.getArray(); + const uno::Reference<report::XReportComponent>* pColEnd = pColIter + aClones.getLength(); + + // move the cloned Components to new positions + for (; pColIter != pColEnd; ++pColIter) + { + uno::Reference< report::XReportComponent> xRC(*pColIter); + aPrevious = VCLPoint(xRC->getPosition()); + awt::Size aSize = xRC->getSize(); + + if ( aNewPos.X() < nLeftMargin ) + { + aNewPos.X() = nLeftMargin; + } + else if ( (aNewPos.X() + aSize.Width) > (nPaperWidth - nRightMargin) ) + { + aNewPos.X() = nPaperWidth - nRightMargin - aSize.Width; + } + if ( aNewPos.Y() < 0 ) + { + aNewPos.Y() = 0; + } + if ( aNewPos.X() < 0 ) + { + aSize.Width += aNewPos.X(); + aNewPos.X()= 0; + xRC->setSize(aSize); + } + xRC->setPosition(AWTPoint(aNewPos)); + if ( (pColIter+1) != pColEnd ) + { + // bring aNewPos to the position of the next object + uno::Reference< report::XReportComponent> xRCNext(*(pColIter + 1),uno::UNO_QUERY); + Point aNextPosition = VCLPoint(xRCNext->getPosition()); + aNewPos += (aNextPosition - aPrevious); + } + } + } + } + catch(uno::Exception&) + { + } + pInSection->getReportSection()->Paste(aAllreadyCopiedObjects,true); + } + } + else + { + ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( FALSE ) ); + EndDragObj_removeInvisibleObjects(); + } + m_aDragDelta = Point(SAL_MAX_INT32, SAL_MAX_INT32); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::EndAction() +{ + ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction() ); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::MovAction(const Point& _aPnt,const OSectionView* _pSection,bool _bMove, bool _bControlKeySet) +{ + (void)_bMove; + + Point aRealMousePos = _aPnt; + Point aCurrentSectionPos; + OSL_TRACE("MovAction X:%d Y:%d\n", aRealMousePos.X(), aRealMousePos.Y() ); + + Point aHdlPos; + SdrHdl* pHdl = _pSection->GetDragHdl(); + if ( pHdl ) + { + aHdlPos = pHdl->GetPos(); + } + + TSectionsMap::iterator aIter/* = m_aSections.begin() */; + TSectionsMap::iterator aEnd = m_aSections.end(); + + //if ( _bMove ) + //{ + for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + if ( &rReportSection.getSectionView() == _pSection ) + break; + const long nSectionHeight = (*aIter)->PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); + aCurrentSectionPos.Y() += nSectionHeight; + } // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + //} + aRealMousePos += aCurrentSectionPos; + + // If control key is pressed the work area is limited to the section with the current selection. + Point aPosForWorkArea(0,0); + for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + OSectionView& rView = rReportSection.getSectionView(); + const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height(); + + if (_bControlKeySet) + { + Rectangle aClipRect = rView.GetWorkArea(); + aClipRect.Top() = aCurrentSectionPos.Y() - aPosForWorkArea.Y(); + // if (aClipRect.Top() < 0) aClipRect.Top() = 0; + aClipRect.Bottom() = aClipRect.Top() + nSectionHeight; + rView.SetWorkArea( aClipRect ); + } + else + { + Rectangle aClipRect = rView.GetWorkArea(); + aClipRect.Top() = -aPosForWorkArea.Y(); + rView.SetWorkArea( aClipRect ); + } + aPosForWorkArea.Y() += nSectionHeight; + // aNewPos.Y() += PixelToLogic(aIter->second.second->GetSizePixel()).Height(); + } + + + for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + SdrHdl* pCurrentHdl = rReportSection.getSectionView().GetDragHdl(); + if ( pCurrentHdl ) + { + if ( aRealMousePos.Y() > 0 ) + aRealMousePos = _aPnt + pCurrentHdl->GetPos() - aHdlPos; + } + rReportSection.getSectionView().MovAction ( aRealMousePos ); + const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height(); + aRealMousePos.Y() -= nSectionHeight; + } +#if 0 +#if OSL_DEBUG_LEVEL > 0 + // TEST TEST TEST TEST + // Ich versuche gerade rauszubekommen, ob ich ein Object bewege oder nur resize. + // TEST TEST TEST TEST + + for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + OSectionView& rView = rReportSection.getSectionView(); + if ( rView.AreObjectsMarked() ) + { + rView.SortMarkedObjects(); + const sal_uInt32 nCount = rView.GetMarkedObjectCount(); + for (sal_uInt32 i=0; i < nCount; ++i) + { + const SdrMark* pM = rView.GetSdrMarkByIndex(i); + SdrObject* pObj = pM->GetMarkedSdrObj(); + (void)pObj; + + int dummy = 0; + (void)dummy; + } + } + + /* + OReportSection& rReportSection = (*aIter)->getReportSection(); + OSectionView& rView = rReportSection.getSectionView(); + const SdrHdlList& rHdlList = rView.GetHdlList(); + SdrHdl* pHdl2 = rHdlList.GetFocusHdl(); + + if ( pHdl2 != 0 ) + { + SdrHdlKind eKind = pHdl->GetKind(); + int dummy = 0; + switch(eKind) + { + case HDL_UPLFT: // Oben links + case HDL_UPPER: // Oben + case HDL_UPRGT: // Oben rechts + case HDL_LEFT: // Links + case HDL_RIGHT: // Rechts + case HDL_LWLFT: // Unten links + case HDL_LOWER: // Unten + case HDL_LWRGT: // Unten rechts + dummy = 1; + break; + default: + dummy = 0; + } + } + */ + } + // TEST TEST TEST TEST +#endif +#endif +} +// ----------------------------------------------------------------------------- +BOOL OViewsWindow::IsAction() const +{ + BOOL bAction = FALSE; + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (; !bAction && aIter != aEnd; ++aIter) + bAction = (*aIter)->getReportSection().getSectionView().IsAction(); + return bAction; +} +// ----------------------------------------------------------------------------- +BOOL OViewsWindow::IsDragObj() const +{ + BOOL bAction = FALSE; + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (; !bAction && aIter != aEnd; ++aIter) + bAction = (*aIter)->getReportSection().getSectionView().IsAction(); + return bAction; +} +// ----------------------------------------------------------------------------- +sal_uInt32 OViewsWindow::getMarkedObjectCount() const +{ + sal_uInt32 nCount = 0; + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (; aIter != aEnd; ++aIter) + nCount += (*aIter)->getReportSection().getSectionView().GetMarkedObjectCount(); + return nCount; +} +// ----------------------------------------------------------------------------- +void OViewsWindow::handleKey(const KeyCode& _rCode) +{ + const USHORT nCode = _rCode.GetCode(); + if ( _rCode.IsMod1() ) + { + // scroll page + OScrollWindowHelper* pScrollWindow = getView()->getScrollWindow(); + ScrollBar* pScrollBar = ( nCode == KEY_LEFT || nCode == KEY_RIGHT ) ? pScrollWindow->GetHScroll() : pScrollWindow->GetVScroll(); + if ( pScrollBar && pScrollBar->IsVisible() ) + pScrollBar->DoScrollAction(( nCode == KEY_RIGHT || nCode == KEY_UP ) ? SCROLL_LINEUP : SCROLL_LINEDOWN ); + return; + } + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (; aIter != aEnd; ++aIter) + { + OReportSection& rReportSection = (*aIter)->getReportSection(); + long nX = 0; + long nY = 0; + + if ( nCode == KEY_UP ) + nY = -1; + else if ( nCode == KEY_DOWN ) + nY = 1; + else if ( nCode == KEY_LEFT ) + nX = -1; + else if ( nCode == KEY_RIGHT ) + nX = 1; + + if ( rReportSection.getSectionView().AreObjectsMarked() ) + { + if ( _rCode.IsMod2() ) + { + // move in 1 pixel distance + const Size aPixelSize = rReportSection.PixelToLogic( Size( 1, 1 ) ); + nX *= aPixelSize.Width(); + nY *= aPixelSize.Height(); + } + else + { + // move in 1 mm distance + nX *= DEFAUL_MOVE_SIZE; + nY *= DEFAUL_MOVE_SIZE; + } + + OSectionView& rView = rReportSection.getSectionView(); + const SdrHdlList& rHdlList = rView.GetHdlList(); + SdrHdl* pHdl = rHdlList.GetFocusHdl(); + + if ( pHdl == 0 ) + { + // no handle selected + if ( rView.IsMoveAllowed() ) + { + // restrict movement to work area + Rectangle rWorkArea = rView.GetWorkArea(); + + if ( !rWorkArea.IsEmpty() ) + { + if ( rWorkArea.Top() < 0 ) + rWorkArea.Top() = 0; + Rectangle aMarkRect( rView.GetMarkedObjRect() ); + aMarkRect.Move( nX, nY ); + + if ( !rWorkArea.IsInside( aMarkRect ) ) + { + if ( aMarkRect.Left() < rWorkArea.Left() ) + nX += rWorkArea.Left() - aMarkRect.Left(); + + if ( aMarkRect.Right() > rWorkArea.Right() ) + nX -= aMarkRect.Right() - rWorkArea.Right(); + + if ( aMarkRect.Top() < rWorkArea.Top() ) + nY += rWorkArea.Top() - aMarkRect.Top(); + + if ( aMarkRect.Bottom() > rWorkArea.Bottom() ) + nY -= aMarkRect.Bottom() - rWorkArea.Bottom(); + } + bool bCheck = false; + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i ) + { + SdrMark* pMark = rMarkList.GetMark(i); + bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL; + } + + if ( bCheck && isOver(aMarkRect,*rReportSection.getPage(),rView) ) + break; + } + + if ( nX != 0 || nY != 0 ) + { + rView.MoveAllMarked( Size( nX, nY ) ); + rView.MakeVisible( rView.GetAllMarkedRect(), rReportSection); + } + } + } + else + { + // move the handle + if ( pHdl && ( nX || nY ) ) + { + const Point aStartPoint( pHdl->GetPos() ); + const Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) ); + const SdrDragStat& rDragStat = rView.GetDragStat(); + + // start dragging + rView.BegDragObj( aStartPoint, 0, pHdl, 0 ); + + if ( rView.IsDragObj() ) + { + const FASTBOOL bWasNoSnap = rDragStat.IsNoSnap(); + const BOOL bWasSnapEnabled = rView.IsSnapEnabled(); + + // switch snapping off + if ( !bWasNoSnap ) + ((SdrDragStat&)rDragStat).SetNoSnap( TRUE ); + if ( bWasSnapEnabled ) + rView.SetSnapEnabled( FALSE ); + + Rectangle aNewRect; + bool bCheck = false; + const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); + for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i ) + { + SdrMark* pMark = rMarkList.GetMark(i); + bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL; + if ( bCheck ) + aNewRect.Union(pMark->GetMarkedSdrObj()->GetLastBoundRect()); + } + + switch(pHdl->GetKind()) + { + case HDL_LEFT: + case HDL_UPLFT: + case HDL_LWLFT: + case HDL_UPPER: + aNewRect.Left() += nX; + aNewRect.Top() += nY; + break; + case HDL_UPRGT: + case HDL_RIGHT: + case HDL_LWRGT: + case HDL_LOWER: + aNewRect.setWidth(aNewRect.getWidth() + nX); + aNewRect.setHeight(aNewRect.getHeight() + nY); + break; + default: + break; + } + if ( !(bCheck && isOver(aNewRect,*rReportSection.getPage(),rView)) ) + rView.MovAction(aEndPoint); + rView.EndDragObj(); + + // restore snap + if ( !bWasNoSnap ) + ((SdrDragStat&)rDragStat).SetNoSnap( bWasNoSnap ); + if ( bWasSnapEnabled ) + rView.SetSnapEnabled( bWasSnapEnabled ); + } + + // make moved handle visible + const Rectangle aVisRect( aEndPoint - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) ); + rView.MakeVisible( aVisRect, rReportSection); + } + } + rView.AdjustMarkHdl(); + } + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::stopScrollTimer() +{ + ::std::for_each(m_aSections.begin(),m_aSections.end(), + ::std::compose1(::boost::mem_fn(&OReportSection::stopScrollTimer),TReportPairHelper())); +} +// ----------------------------------------------------------------------------- +void OViewsWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const +{ + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for (sal_uInt16 i = 0;aIter != aEnd ; ++aIter,++i) + { + if ( (*aIter)->getStartMarker().isCollapsed() ) + _rCollapsedPositions.push_back(i); + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::collapseSections(const uno::Sequence< beans::PropertyValue>& _aCollpasedSections) +{ + const beans::PropertyValue* pIter = _aCollpasedSections.getConstArray(); + const beans::PropertyValue* pEnd = pIter + _aCollpasedSections.getLength(); + for (; pIter != pEnd; ++pIter) + { + sal_uInt16 nPos = sal_uInt16(-1); + if ( (pIter->Value >>= nPos) && nPos < m_aSections.size() ) + { + m_aSections[nPos]->setCollapsed(sal_True); + } + } +} +// ----------------------------------------------------------------------------- +void OViewsWindow::zoom(const Fraction& _aZoom) +{ + const MapMode& aMapMode = GetMapMode(); + + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + if ( _aZoom < aMapMode.GetScaleX() ) + aStartWidth *= aMapMode.GetScaleX(); + else + aStartWidth *= _aZoom; + + setZoomFactor(_aZoom,*this); + + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) + { + (*aIter)->zoom(_aZoom); + } // for (;aIter != aEnd ; ++aIter) + + Resize(); + + Size aOut = GetOutputSizePixel(); + aOut.Width() = aStartWidth; + aOut = PixelToLogic(aOut); + + Rectangle aRect(PixelToLogic(Point(0,0)),aOut); + Invalidate(aRect,/*INVALIDATE_NOERASE | */INVALIDATE_NOCHILDREN /*| INVALIDATE_TRANSPARENT*/); +} +//---------------------------------------------------------------------------- +void OViewsWindow::scrollChildren(const Point& _aThumbPos) +{ + const Point aPos(PixelToLogic(_aThumbPos)); + { + MapMode aMapMode = GetMapMode(); + const Point aOld = aMapMode.GetOrigin(); + aMapMode.SetOrigin(m_pParent->GetMapMode().GetOrigin()); + + const Point aPosY(m_pParent->PixelToLogic(_aThumbPos,aMapMode)); + + aMapMode.SetOrigin( Point(aOld.X() , - aPosY.Y())); + SetMapMode( aMapMode ); + //OWindowPositionCorrector aCorrector(this,0,-( aOld.Y() + aPosY.Y())); + Scroll(0, -( aOld.Y() + aPosY.Y()),SCROLL_CHILDREN); + Resize(); + Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_TRANSPARENT); + } + + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) + { + (*aIter)->scrollChildren(aPos.X()); + } // for (;aIter != aEnd ; ++aIter) +} +// ----------------------------------------------------------------------------- +void OViewsWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const +{ + TSectionsMap::const_iterator aIter = m_aSections.begin(); + TSectionsMap::const_iterator aEnd = m_aSections.end(); + for(;aIter != aEnd; ++aIter) + { + (*aIter)->getReportSection().fillControlModelSelection(_rSelection); + } +} +//============================================================================== +} // rptui +//============================================================================== diff --git a/reportdesign/source/ui/report/dlgedclip.cxx b/reportdesign/source/ui/report/dlgedclip.cxx new file mode 100644 index 000000000000..d0c1b03bda11 --- /dev/null +++ b/reportdesign/source/ui/report/dlgedclip.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "dlgedclip.hxx" +#include <comphelper/processfactory.hxx> +#include <com/sun/star/datatransfer/XMimeContentType.hpp> +#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp> + +namespace rptui +{ + +using namespace comphelper; +using namespace ::com::sun::star; + +//============================================================================ +// OReportExchange +//============================================================================ +//---------------------------------------------------------------------------- +OReportExchange::OReportExchange(const TSectionElements& _rCopyElements ) +: m_aCopyElements(_rCopyElements) +{ +} +//-------------------------------------------------------------------- +sal_uInt32 OReportExchange::getDescriptorFormatId() +{ + static sal_uInt32 s_nFormat = (sal_uInt32)-1; + if ((sal_uInt32)-1 == s_nFormat) + { + s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"report.ReportObjectsTransfer\"")); + OSL_ENSURE((sal_uInt32)-1 != s_nFormat, "OReportExchange::getDescriptorFormatId: bad exchange id!"); + } + return s_nFormat; +} +//-------------------------------------------------------------------- +void OReportExchange::AddSupportedFormats() +{ + AddFormat(getDescriptorFormatId()); +} +//-------------------------------------------------------------------- +sal_Bool OReportExchange::GetData( const datatransfer::DataFlavor& _rFlavor ) +{ + const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor); + return (nFormatId == getDescriptorFormatId()) ? + SetAny( uno::Any(m_aCopyElements), _rFlavor ) + : sal_False; +} +// ----------------------------------------------------------------------------- +sal_Bool OReportExchange::canExtract(const DataFlavorExVector& _rFlavor) +{ + return IsFormatSupported(_rFlavor,getDescriptorFormatId()); +} +// ----------------------------------------------------------------------------- +OReportExchange::TSectionElements OReportExchange::extractCopies(const TransferableDataHelper& _rData) +{ + sal_Int32 nKnownFormatId = getDescriptorFormatId(); + if ( _rData.HasFormat( nKnownFormatId ) ) + { + // extract the any from the transferable + datatransfer::DataFlavor aFlavor; +#if OSL_DEBUG_LEVEL > 0 + sal_Bool bSuccess = +#endif + SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor); + OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid data format (no flavor)!"); + + uno::Any aDescriptor = _rData.GetAny(aFlavor); + + TSectionElements aCopies; +#if OSL_DEBUG_LEVEL > 0 + bSuccess = +#endif + aDescriptor >>= aCopies; + OSL_ENSURE(bSuccess, "OReportExchange::extractCopies: invalid clipboard format!"); + + // build the real descriptor + return aCopies; + } + + return TSectionElements(); +} +//============================================================================ +} // rptui +//============================================================================ diff --git a/reportdesign/source/ui/report/dlgedfac.cxx b/reportdesign/source/ui/report/dlgedfac.cxx new file mode 100644 index 000000000000..7e6bd00d0091 --- /dev/null +++ b/reportdesign/source/ui/report/dlgedfac.cxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "dlgedfac.hxx" +#ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC +#include "uistrings.hrc" +#endif +#include "RptObject.hxx" +#include <RptDef.hxx> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/awt/ScrollBarOrientation.hpp> +#include <svx/svdoole2.hxx> +namespace rptui +{ +using namespace ::com::sun::star; + +//---------------------------------------------------------------------------- + +DlgEdFactory::DlgEdFactory() +{ + SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) ); +} + +//---------------------------------------------------------------------------- + +DlgEdFactory::~DlgEdFactory() +{ + SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) ); +} + +//---------------------------------------------------------------------------- + +IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory ) +{ + if ( pObjFactory->nInventor == ReportInventor ) + { + switch( pObjFactory->nIdentifier ) + { + case OBJ_DLG_FIXEDTEXT: + pObjFactory->pNewObj = new OUnoObject( SERVICE_FIXEDTEXT + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")) + ,OBJ_DLG_FIXEDTEXT); + break; + case OBJ_DLG_IMAGECONTROL: + pObjFactory->pNewObj = new OUnoObject( SERVICE_IMAGECONTROL + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.DatabaseImageControl")) + ,OBJ_DLG_IMAGECONTROL); + break; + case OBJ_DLG_FORMATTEDFIELD: + pObjFactory->pNewObj = new OUnoObject( SERVICE_FORMATTEDFIELD + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FormattedField")) + ,OBJ_DLG_FORMATTEDFIELD); + break; + case OBJ_DLG_VFIXEDLINE: + case OBJ_DLG_HFIXEDLINE: + { + OUnoObject* pObj = new OUnoObject( SERVICE_FIXEDLINE + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlFixedLineModel")) + ,pObjFactory->nIdentifier); + pObjFactory->pNewObj = pObj; + if ( pObjFactory->nIdentifier == OBJ_DLG_HFIXEDLINE ) + { + uno::Reference<beans::XPropertySet> xProp = pObj->getAwtComponent(); + xProp->setPropertyValue( PROPERTY_ORIENTATION, uno::makeAny(sal_Int32(0)) ); + } + } + break; + case OBJ_CUSTOMSHAPE: + pObjFactory->pNewObj = new OCustomShape(SERVICE_SHAPE); + break; + case OBJ_DLG_SUBREPORT: + pObjFactory->pNewObj = new OOle2Obj(SERVICE_REPORTDEFINITION,OBJ_DLG_SUBREPORT); + break; + case OBJ_OLE2: + pObjFactory->pNewObj = new OOle2Obj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.ChartDocument")),OBJ_OLE2); + break; + default: + OSL_ENSURE(0,"Unknown object id"); + break; + } + } + + return 0; +} +//---------------------------------------------------------------------------- +} diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx new file mode 100644 index 000000000000..1535ce7d6ee1 --- /dev/null +++ b/reportdesign/source/ui/report/dlgedfunc.cxx @@ -0,0 +1,1119 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include <vcl/scrbar.hxx> +#include <vcl/svapp.hxx> +#include <vcl/seleng.hxx> +#include <com/sun/star/linguistic2/XSpellChecker1.hpp> +#include <com/sun/star/embed/EmbedStates.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <svx/svdview.hxx> +#include <svx/svdpagv.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/unolingu.hxx> +#include <svx/svdetc.hxx> +#include <editeng/editstat.hxx> +#include <svx/svdoutl.hxx> +#include <svx/svddrgmt.hxx> +#include <svx/svdoashp.hxx> +#include <svx/svxids.hrc> +#include <svx/svditer.hxx> + +#include <toolkit/helper/vclunohelper.hxx> + +#include "dlgedfunc.hxx" +#include "ReportSection.hxx" +#include "DesignView.hxx" +#include "ReportController.hxx" +#include "SectionView.hxx" +#include "ViewsWindow.hxx" +#include "ReportWindow.hxx" +#include "RptObject.hxx" +#include "ScrollHelper.hxx" + +#include "ReportRuler.hxx" +#include "UITools.hxx" + +#include <uistrings.hrc> +#include "UndoEnv.hxx" +#include <RptModel.hxx> +#include <tools/diagnose_ex.h> + +#define DEFAUL_MOVE_SIZE 100 +namespace rptui +{ +using namespace ::com::sun::star; +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- + +IMPL_LINK( DlgEdFunc, ScrollTimeout, Timer *, ) +{ + ForceScroll( m_pParent->PixelToLogic( m_pParent->GetPointerPosPixel() ) ); + return 0; +} + +//---------------------------------------------------------------------------- + +void DlgEdFunc::ForceScroll( const Point& rPos ) +{ + aScrollTimer.Stop(); + + OReportWindow* pReportWindow = m_pParent->getSectionWindow()->getViewsWindow()->getView(); + OScrollWindowHelper* pScrollWindow = pReportWindow->getScrollWindow(); + + Size aOut = pReportWindow->GetOutputSizePixel(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= m_pParent->GetMapMode().GetScaleX(); + + aOut.Width() -= (long)aStartWidth; + + Rectangle aOutRect( pScrollWindow->getThumbPos(), aOut ); + aOutRect = m_pParent->PixelToLogic( aOutRect ); + //Rectangle aWorkArea = m_pParent->getView()->GetWorkArea(); + Point aGcc3WorkaroundTemporary; + Rectangle aWorkArea(aGcc3WorkaroundTemporary,pScrollWindow->getTotalSize()); + aWorkArea.Right() -= (long)aStartWidth; + aWorkArea = pScrollWindow->PixelToLogic( aWorkArea ); + if( !aOutRect.IsInside( rPos ) && aWorkArea.IsInside( rPos ) ) + { + ScrollBar* pHScroll = pScrollWindow->GetHScroll(); + ScrollBar* pVScroll = pScrollWindow->GetVScroll(); + ScrollType eH = SCROLL_LINEDOWN,eV = SCROLL_LINEDOWN; + if( rPos.X() < aOutRect.Left() ) + eH = SCROLL_LINEUP; + else if( rPos.X() <= aOutRect.Right() ) + eH = SCROLL_DONTKNOW; + + if( rPos.Y() < aOutRect.Top() ) + eV = SCROLL_LINEUP; + else if( rPos.Y() <= aOutRect.Bottom() ) + eV = SCROLL_DONTKNOW; + + pHScroll->DoScrollAction(eH); + pVScroll->DoScrollAction(eV); + } + + aScrollTimer.Start(); +} + +//---------------------------------------------------------------------------- + +DlgEdFunc::DlgEdFunc( OReportSection* _pParent ) +:m_pParent(_pParent), + m_rView(_pParent->getSectionView()), + m_xOverlappingObj(NULL), + m_pOverlappingObj(NULL), + m_bSelectionMode(false), + m_bUiActive(false), + m_bShowPropertyBrowser(false) +{ + // m_pParent = _pParent; + aScrollTimer.SetTimeoutHdl( LINK( this, DlgEdFunc, ScrollTimeout ) ); + m_rView.SetActualWin( m_pParent); + aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL ); +} + +//---------------------------------------------------------------------------- +void DlgEdFunc::setOverlappedControlColor(sal_Int32 _nColor) +{ + m_nOverlappedControlColor = _nColor; +} +// ----------------------------------------------------------------------------- +sal_Int32 lcl_setColorOfObject(uno::Reference< uno::XInterface > _xObj, long _nColorTRGB) +{ + sal_Int32 nBackColor = 0; + try + { + uno::Reference<report::XReportComponent> xComponent(_xObj, uno::UNO_QUERY_THROW); + // NOT NEED if UNO_QUERY_THROW: + // if (xComponent.is()) + // { + uno::Reference< beans::XPropertySet > xProp(xComponent, uno::UNO_QUERY_THROW); + // if (xProp.is()) + // { + // ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlBackground")) + // is PROPERTY_CONTROLBACKGROUND + uno::Any aAny = xProp->getPropertyValue(PROPERTY_CONTROLBACKGROUND); + if (aAny.hasValue()) + { + aAny >>= nBackColor; + // try to set background color at the ReportComponent + uno::Any aBlackColorAny = uno::makeAny(_nColorTRGB); + xProp->setPropertyValue(PROPERTY_CONTROLBACKGROUND, aBlackColorAny); + } + // aCopies.push_back(xComponent->createClone()); + } + catch(uno::Exception&) + { + // bit my shiny metal as! + // OSL_ENSURE(0,"Can't copy report elements!"); + } + return nBackColor; +} +// ----------------------------------------------------------------------------- +DlgEdFunc::~DlgEdFunc() +{ + unColorizeOverlappedObj(); + aScrollTimer.Stop(); +} + +//---------------------------------------------------------------------------- + +BOOL DlgEdFunc::MouseButtonDown( const MouseEvent& rMEvt ) +{ + m_aMDPos = m_pParent->PixelToLogic( rMEvt.GetPosPixel() ); + m_pParent->GrabFocus(); + BOOL bHandled = FALSE; + if ( rMEvt.IsLeft() ) + { + if ( rMEvt.GetClicks() > 1 ) + { + // show property browser + if ( m_pParent->GetMode() != RPTUI_READONLY ) + { + uno::Sequence<beans::PropertyValue> aArgs(1); + aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowProperties")); + aArgs[0].Value <<= sal_True; + m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_SHOW_PROPERTYBROWSER,aArgs); + m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView); + // TODO character in shapes + // SdrViewEvent aVEvt; + // m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); + // if ( aVEvt.pRootObj && aVEvt.pRootObj->ISA(SdrTextObj) ) + // SetInEditMode(static_cast<SdrTextObj *>(aVEvt.pRootObj),rMEvt, FALSE); + bHandled = TRUE; + } + } + else + { + SdrHdl* pHdl = m_rView.PickHandle(m_aMDPos); + //m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(m_pView); + + // if selected object was hit, drag object + if ( pHdl!=NULL || m_rView.IsMarkedHit(m_aMDPos) ) + { + bHandled = TRUE; + m_pParent->CaptureMouse(); + m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, pHdl,&m_rView); + } + } + } + else if ( rMEvt.IsRight() && !rMEvt.IsLeft() && rMEvt.GetClicks() == 1 ) // mark object when context menu was selected + { + SdrPageView* pPV = m_rView.GetSdrPageView(); + SdrViewEvent aVEvt; + if ( m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt) != SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() ) + m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL); + if ( aVEvt.pRootObj ) + m_rView.MarkObj(aVEvt.pRootObj, pPV); + else + m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL); + + bHandled = TRUE; + } + else if( !rMEvt.IsLeft() ) + bHandled = TRUE; + if ( !bHandled ) + m_pParent->CaptureMouse(); + return bHandled; +} + +//---------------------------------------------------------------------------- + +BOOL DlgEdFunc::MouseButtonUp( const MouseEvent& /*rMEvt*/ ) +{ + BOOL bHandled = FALSE; + m_pParent->getSectionWindow()->getViewsWindow()->stopScrollTimer(); + return bHandled; +} +// ----------------------------------------------------------------------------- +void DlgEdFunc::checkTwoCklicks(const MouseEvent& rMEvt) +{ + deactivateOle(); + + const USHORT nClicks = rMEvt.GetClicks(); + if ( nClicks == 2 && rMEvt.IsLeft() ) + { + if ( m_rView.AreObjectsMarked() ) + { + const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + const SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + activateOle(pObj); + } // if (rMarkList.GetMarkCount() == 1) + } // if ( pView->AreObjectsMarked() ) + } +} +// ----------------------------------------------------------------------------- +void DlgEdFunc::stopScrollTimer() +{ + unColorizeOverlappedObj(); + aScrollTimer.Stop(); + if ( m_pParent->IsMouseCaptured() ) + m_pParent->ReleaseMouse(); +} +//---------------------------------------------------------------------------- + +BOOL DlgEdFunc::MouseMove( const MouseEvent& /*rMEvt*/ ) +{ + return FALSE; +} +//------------------------------------------------------------------------------ +sal_Bool DlgEdFunc::handleKeyEvent(const KeyEvent& _rEvent) +{ + BOOL bReturn = FALSE; + + if ( !m_bUiActive ) + { + const KeyCode& rCode = _rEvent.GetKeyCode(); + USHORT nCode = rCode.GetCode(); + + switch ( nCode ) + { + case KEY_ESCAPE: + { + if ( m_pParent->getSectionWindow()->getViewsWindow()->IsAction() ) + { + m_pParent->getSectionWindow()->getViewsWindow()->BrkAction(); + bReturn = TRUE; + } + else if ( m_rView.IsTextEdit() ) + { + m_rView.SdrEndTextEdit(); + bReturn = TRUE; + } + else if ( m_rView.AreObjectsMarked() ) + { + const SdrHdlList& rHdlList = m_rView.GetHdlList(); + SdrHdl* pHdl = rHdlList.GetFocusHdl(); + if ( pHdl ) + ((SdrHdlList&)rHdlList).ResetFocusHdl(); + else + m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL); + //m_rView.UnmarkAll(); + + deactivateOle(true); + bReturn = FALSE; + } + else + { + deactivateOle(true); + } + } + break; + case KEY_TAB: + { + if ( !rCode.IsMod1() && !rCode.IsMod2() ) + { + // mark next object + if ( !m_rView.MarkNextObj( !rCode.IsShift() ) ) + { + // if no next object, mark first/last + m_rView.UnmarkAllObj(); + m_rView.MarkNextObj( !rCode.IsShift() ); + } + + if ( m_rView.AreObjectsMarked() ) + m_rView.MakeVisible( m_rView.GetAllMarkedRect(), *m_pParent); + + bReturn = TRUE; + } + else if ( rCode.IsMod1() && rCode.IsMod2()) + { + // selected handle + const SdrHdlList& rHdlList = m_rView.GetHdlList(); + ((SdrHdlList&)rHdlList).TravelFocusHdl( !rCode.IsShift() ); + + // guarantee visibility of focused handle + SdrHdl* pHdl = rHdlList.GetFocusHdl(); + if ( pHdl ) + { + Point aHdlPosition( pHdl->GetPos() ); + Rectangle aVisRect( aHdlPosition - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) ); + m_rView.MakeVisible( aVisRect, *m_pParent); + } + + bReturn = TRUE; + } + } + break; + case KEY_UP: + case KEY_DOWN: + case KEY_LEFT: + case KEY_RIGHT: + { + m_pParent->getSectionWindow()->getViewsWindow()->handleKey(rCode); + bReturn = TRUE; + } + break; + case KEY_RETURN: + if ( !rCode.IsMod1() ) + { + const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList(); + if ( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + activateOle(pObj); + } + } + break; + case KEY_DELETE: + if ( !rCode.IsMod1() && !rCode.IsMod2() ) + { + bReturn = TRUE; + break; + } // if ( !rCode.IsMod1() && !rCode.IsMod2() ) + // run through + default: + { + bReturn = m_rView.KeyInput(_rEvent, m_pParent); + } + break; + } + } + + if ( bReturn && m_pParent->IsMouseCaptured() ) + m_pParent->ReleaseMouse(); + + return bReturn; +} +// ----------------------------------------------------------------------------- +void DlgEdFunc::activateOle(SdrObject* _pObj) +{ + if ( _pObj ) + { + const UINT16 nSdrObjKind = _pObj->GetObjIdentifier(); + // + // OLE: activate + // + if (nSdrObjKind == OBJ_OLE2) + { + bool bIsInplaceOle = false; + if (!bIsInplaceOle) + { + SdrOle2Obj* pOleObj = dynamic_cast<SdrOle2Obj*>(_pObj); + if ( pOleObj->GetObjRef().is() ) + { + if (m_rView.IsTextEdit()) + { + m_rView.SdrEndTextEdit(); + } + + pOleObj->AddOwnLightClient(); + pOleObj->SetWindow(VCLUnoHelper::GetInterface(m_pParent)); + try + { + pOleObj->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE ); + m_bUiActive = true; + OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController(); + m_bShowPropertyBrowser = rController.isCommandChecked(SID_SHOW_PROPERTYBROWSER); + if ( m_bShowPropertyBrowser ) + rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >()); + } + catch( uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + } // if (nSdrObjKind == OBJ_OLE2) + } // if ( _pObj ) +} +// ----------------------------------------------------------------------------- +void DlgEdFunc::deactivateOle(bool _bSelect) +{ + OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache(); + const ULONG nCount = rObjCache.Count(); + for(ULONG i = 0 ; i< nCount;++i) + { + SdrOle2Obj* pObj = reinterpret_cast<SdrOle2Obj*>(rObjCache.GetObject(i)); + if ( m_pParent->getPage() == pObj->GetPage() ) + { + uno::Reference< embed::XEmbeddedObject > xObj = pObj->GetObjRef(); + if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::UI_ACTIVE ) + { + xObj->changeState( embed::EmbedStates::RUNNING ); + m_bUiActive = false; + if ( m_bShowPropertyBrowser ) + { + OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController(); + rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >()); + } + + if ( _bSelect ) + { + SdrPageView* pPV = m_rView.GetSdrPageView(); + m_rView.MarkObj(pObj, pPV); + } + } // if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::UI_ACTIVE ) + } + } // for(ULONG i = 0 ; i< nCount;++i) +} +// ----------------------------------------------------------------------------- +void DlgEdFunc::colorizeOverlappedObject(SdrObject* _pOverlappedObj) +{ + OObjectBase* pObj = dynamic_cast<OObjectBase*>(_pOverlappedObj); + if ( pObj ) + { + uno::Reference<report::XReportComponent> xComponent = pObj->getReportComponent(); + if (xComponent.is() && xComponent != m_xOverlappingObj) + { + OReportModel* pRptModel = static_cast<OReportModel*>(_pOverlappedObj->GetModel()); + if ( pRptModel ) + { + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + + // uncolorize an old object, if there is one + unColorizeOverlappedObj(); + + m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor); + m_xOverlappingObj = xComponent; + m_pOverlappingObj = _pOverlappedObj; + } + } + } +} +// ----------------------------------------------------------------------------- +void DlgEdFunc::unColorizeOverlappedObj() +{ + // uncolorize an old object, if there is one + if (m_xOverlappingObj.is()) + { + OReportModel* pRptModel = static_cast<OReportModel*>(m_pOverlappingObj->GetModel()); + if ( pRptModel ) + { + OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + + lcl_setColorOfObject(m_xOverlappingObj, m_nOldColor); + m_xOverlappingObj = NULL; + m_pOverlappingObj = NULL; + } + } +} +// ----------------------------------------------------------------------------- +bool DlgEdFunc::isOverlapping(const MouseEvent& rMEvt) +{ + bool bOverlapping = false; + SdrViewEvent aVEvt; + bOverlapping = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONUP, aVEvt) != SDRHIT_NONE; + if (bOverlapping && aVEvt.pObj) + { + colorizeOverlappedObject(aVEvt.pObj); + } + else + { + unColorizeOverlappedObj(); + } + + return bOverlapping; +} +// ----------------------------------------------------------------------------- +void DlgEdFunc::checkMovementAllowed(const MouseEvent& rMEvt) +{ + if ( m_pParent->getSectionWindow()->getViewsWindow()->IsDragObj() ) + { + if ( isRectangleHit(rMEvt) ) + { + // there is an other component under use, break action + m_pParent->getSectionWindow()->getViewsWindow()->BrkAction(); + } + // object was dragged + Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) ); + if (m_bSelectionMode) + { + m_pParent->getSectionWindow()->getViewsWindow()->EndAction(); + } + else + { + bool bControlKeyPressed = rMEvt.IsMod1(); + // Don't allow points smaller 0 + if (bControlKeyPressed && (aPnt.Y() < 0)) + { + aPnt.Y() = 0; + } + if (m_rView.IsDragResize()) + { + // we resize the object don't resize to above sections + if ( aPnt.Y() < 0 ) + { + aPnt.Y() = 0; + } + } + m_pParent->getSectionWindow()->getViewsWindow()->EndDragObj( bControlKeyPressed, &m_rView, aPnt ); + } + m_pParent->getSectionWindow()->getViewsWindow()->ForceMarkedToAnotherPage(); + m_pParent->Invalidate(INVALIDATE_CHILDREN); + } + else + m_pParent->getSectionWindow()->getViewsWindow()->EndAction(); +} +// ----------------------------------------------------------------------------- +bool DlgEdFunc::isOnlyCustomShapeMarked() +{ + bool bReturn = true; + const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList(); + for (sal_uInt32 i = 0; i < rMarkList.GetMarkCount();++i ) + { + SdrMark* pMark = rMarkList.GetMark(i); + // bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL; + SdrObject* pObj = pMark->GetMarkedSdrObj(); + if (pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE) + { + // we found an object in the marked objects, which is not a custom shape. + bReturn = false; + break; + } + } + return bReturn; +} +// ----------------------------------------------------------------------------- +bool DlgEdFunc::isRectangleHit(const MouseEvent& rMEvt) +{ + if (isOnlyCustomShapeMarked()) + { + return false; + } + + SdrViewEvent aVEvt; + const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEMOVE, aVEvt); + bool bIsSetPoint = (eHit == SDRHIT_UNMARKEDOBJECT); + if ( !bIsSetPoint ) + { + // no drag rect, we have to check every single select rect + //const Rectangle& rRect = m_rView.GetDragStat().GetActionRect(); + const SdrDragStat& rDragStat = m_rView.GetDragStat(); + if (rDragStat.GetDragMethod() != NULL) + { + SdrObjListIter aIter(*m_pParent->getPage(),IM_DEEPNOGROUPS); + SdrObject* pObjIter = NULL; + // loop through all marked objects and check if there new rect overlapps an old one. + while( (pObjIter = aIter.Next()) != NULL && !bIsSetPoint) + { + if ( m_rView.IsObjMarked(pObjIter) + && dynamic_cast<OUnoObject*>(pObjIter) != NULL ) + { + Rectangle aNewRect = pObjIter->GetLastBoundRect(); + long nDx = rDragStat.IsHorFixed() ? 0 : rDragStat.GetDX(); + long nDy = rDragStat.IsVerFixed() ? 0 : rDragStat.GetDY(); + if ( (nDx + aNewRect.Left()) < 0 ) + nDx = -aNewRect.Left(); + if ( (nDy + aNewRect.Top()) < 0 ) + nDy = -aNewRect.Top(); + + if ( rDragStat.GetDragMethod()->getMoveOnly() ) + aNewRect.Move(nDx,nDy); + else + ::ResizeRect(aNewRect,rDragStat.GetRef1(),rDragStat.GetXFact(),rDragStat.GetYFact()); + + + SdrObject* pObjOverlapped = isOver(aNewRect,*m_pParent->getPage(),m_rView,false,pObjIter, ISOVER_IGNORE_CUSTOMSHAPES); + bIsSetPoint = pObjOverlapped ? true : false; + if (pObjOverlapped && !m_bSelectionMode) + { + colorizeOverlappedObject(pObjOverlapped); + } + } + } + } + } + else if ( aVEvt.pObj && !m_bSelectionMode) + { + colorizeOverlappedObject(aVEvt.pObj); + } + return bIsSetPoint; +} +// ----------------------------------------------------------------------------- +bool DlgEdFunc::setMovementPointer(const MouseEvent& rMEvt) +{ + bool bIsSetPoint = isRectangleHit(rMEvt); + if ( bIsSetPoint ) + m_pParent->SetPointer( Pointer(POINTER_NOTALLOWED)); + else + { + bool bCtrlKey = rMEvt.IsMod1(); + (void)bCtrlKey; + if (bCtrlKey) + { + m_pParent->SetPointer( Pointer(POINTER_MOVEDATALINK )); + bIsSetPoint = true; + } + } + return bIsSetPoint; +} +//---------------------------------------------------------------------------- + +DlgEdFuncInsert::DlgEdFuncInsert( OReportSection* _pParent ) : + DlgEdFunc( _pParent ) +{ + m_rView.SetCreateMode( TRUE ); +} + +//---------------------------------------------------------------------------- + +DlgEdFuncInsert::~DlgEdFuncInsert() +{ + m_rView.SetEditMode( TRUE ); +} + +//---------------------------------------------------------------------------- + +BOOL DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( DlgEdFunc::MouseButtonDown(rMEvt) ) + return TRUE; + + SdrViewEvent aVEvt; + sal_Int16 nId = m_rView.GetCurrentObjIdentifier(); + + const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); + +// eHit == SDRHIT_UNMARKEDOBJECT under the mouse cursor is a unmarked object + + if (eHit == SDRHIT_UNMARKEDOBJECT && + nId != OBJ_CUSTOMSHAPE) + { + // there is an object under the mouse cursor, but not a customshape + // rtl::OUString suWasN = m_rView.getInsertObjString(); + // rtl::OUString suWasN2 = m_pParent->getSectionWindow()->getViewsWindow()->GetInsertObjString(); + + m_pParent->getSectionWindow()->getViewsWindow()->BrkAction(); + return FALSE; + } + + if( eHit != SDRHIT_UNMARKEDOBJECT || nId == OBJ_CUSTOMSHAPE) + { + // if no action, create object + if ( !m_pParent->getSectionWindow()->getViewsWindow()->IsAction() ) + { + deactivateOle(true); + if ( m_pParent->getSectionWindow()->getViewsWindow()->HasSelection() ) + m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(&m_rView); + m_rView.BegCreateObj(m_aMDPos); + m_pParent->getSectionWindow()->getViewsWindow()->createDefault(); + } + } + else + { + if( !rMEvt.IsShift() ) + { + // shift key pressed? + m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL); + } + m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos,&m_rView ); + } + + return TRUE; +} + +//---------------------------------------------------------------------------- +BOOL DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( DlgEdFunc::MouseButtonUp( rMEvt ) ) + return TRUE; + + const Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) ); + const USHORT nHitLog = USHORT ( m_pParent->PixelToLogic(Size(3,0)).Width() ); + + BOOL bReturn = TRUE; + // object creation active? + if ( m_rView.IsCreateObj() ) + { + if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),m_rView) ) + { + m_pParent->getSectionWindow()->getViewsWindow()->BrkAction(); + // BrkAction disables the create mode + m_rView.SetCreateMode( TRUE ); + return TRUE; + } + + m_rView.EndCreateObj(SDRCREATE_FORCEEND); + + if ( !m_rView.AreObjectsMarked() ) + { + m_rView.MarkObj(aPos, nHitLog); + } + + bReturn = m_rView.AreObjectsMarked(); + if ( bReturn ) + { + OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController(); + const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList(); + for (sal_uInt32 i = 0; i < rMarkList.GetMarkCount();++i ) + { + SdrMark* pMark = rMarkList.GetMark(i); + // bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL; + OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj()); + if ( pObj && !pObj->IsEmpty() ) + { + pObj->initializeChart(rController.getModel()); + } + } + } + } + else + checkMovementAllowed(rMEvt); + + if ( !m_rView.AreObjectsMarked() && + Abs(m_aMDPos.X() - aPos.X()) < nHitLog && + Abs(m_aMDPos.Y() - aPos.Y()) < nHitLog && + !rMEvt.IsShift() && !rMEvt.IsMod2() ) + { + SdrPageView* pPV = m_rView.GetSdrPageView(); + SdrViewEvent aVEvt; + m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); + m_rView.MarkObj(aVEvt.pRootObj, pPV); + } // ift() && !rMEvt.IsMod2() ) + checkTwoCklicks(rMEvt); + m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView); + return bReturn; +} + +//---------------------------------------------------------------------------- + +BOOL DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt ) +{ + if ( DlgEdFunc::MouseMove(rMEvt ) ) + return TRUE; + Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) ); + + if ( m_rView.IsCreateObj() ) + { + m_rView.SetOrtho(SdrObjCustomShape::doConstructOrthogonal(m_rView.getReportSection()->getSectionWindow()->getViewsWindow()->getShapeType()) ? !rMEvt.IsShift() : rMEvt.IsShift()); + m_rView.SetAngleSnapEnabled(rMEvt.IsShift()); + } + + bool bIsSetPoint = false; + if ( m_rView.IsAction() ) + { + if ( m_rView.IsDragResize() ) + { + // we resize the object don't resize to above sections + if ( aPos.Y() < 0 ) + { + aPos.Y() = 0; + } + } + bIsSetPoint = setMovementPointer(rMEvt); + ForceScroll(aPos); + m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPos,&m_rView, m_rView.GetDragMethod() == NULL, false); + } + + //if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),*m_pView) ) + // m_pParent->SetPointer( Pointer(POINTER_NOTALLOWED)); + //else + if ( !bIsSetPoint ) + m_pParent->SetPointer( m_rView.GetPreferedPointer( aPos, m_pParent) ); + + return TRUE; +} + +//---------------------------------------------------------------------------- + +DlgEdFuncSelect::DlgEdFuncSelect( OReportSection* _pParent ) : + DlgEdFunc( _pParent ) +{ +} + +//---------------------------------------------------------------------------- + +DlgEdFuncSelect::~DlgEdFuncSelect() +{ +} + +//---------------------------------------------------------------------------- + +BOOL DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt ) +{ + m_bSelectionMode = false; + if ( DlgEdFunc::MouseButtonDown(rMEvt) ) + return TRUE; + + SdrViewEvent aVEvt; + const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); + if( eHit == SDRHIT_UNMARKEDOBJECT ) + { + // if not multi selection, unmark all + if ( !rMEvt.IsShift() ) + m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL); + + if ( m_rView.MarkObj(m_aMDPos) && rMEvt.IsLeft() ) + { + // drag object + m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, m_rView.PickHandle(m_aMDPos), &m_rView); + } + else + { + // select object + m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj(m_aMDPos,&m_rView); + } + } + else + { + if( !rMEvt.IsShift() ) + m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL); + //m_rView.UnmarkAll(); + + if ( rMEvt.GetClicks() == 1 ) + { + m_bSelectionMode = true; + m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos ,&m_rView); + } + else + { + m_rView.SdrBeginTextEdit( aVEvt.pRootObj,m_rView.GetSdrPageView(),m_pParent,sal_False ); + } + } + + return TRUE; +} + +//---------------------------------------------------------------------------- + +BOOL DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( DlgEdFunc::MouseButtonUp( rMEvt ) ) + return TRUE; + + // get view from parent + const Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) ); + + if ( rMEvt.IsLeft() ) // left mousebutton pressed + checkMovementAllowed(rMEvt); + + m_pParent->getSectionWindow()->getViewsWindow()->EndAction(); + checkTwoCklicks(rMEvt); + + m_pParent->SetPointer( m_rView.GetPreferedPointer( aPnt, m_pParent) ); + + if ( !m_bUiActive ) + m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView); + m_bSelectionMode = false; + return TRUE; +} + +//---------------------------------------------------------------------------- + +BOOL DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt ) +{ + if ( DlgEdFunc::MouseMove(rMEvt ) ) + return TRUE; + + Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) ); + bool bIsSetPoint = false; + + if ( m_rView.IsAction() ) // Drag Mode + { + bIsSetPoint = setMovementPointer(rMEvt); + ForceScroll(aPnt); + if (m_rView.GetDragMethod()==NULL) + { + // create a selection + m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, true, false); + } + else + { + if ( m_rView.IsDragResize() ) + { + // we resize the object don't resize to above sections + if ( aPnt.Y() < 0 ) + { + aPnt.Y() = 0; + } + // grow section if it is under the current section +// else +// { +// const Size& aSectionSize = m_rView->GetSizePixel(); +// if ( aPnt.Y() > aSectionSize.Height() ) +// { +// aPnt.Y() = aSectionSize.Height(); +// } +// } + } + // drag or resize an object + bool bControlKey = rMEvt.IsMod1(); + m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, false, bControlKey); + } + } + + if ( !bIsSetPoint ) + { + m_pParent->SetPointer( m_rView.GetPreferedPointer( aPnt, m_pParent) ); + + // restore color + unColorizeOverlappedObj(); + } + + return TRUE; +} +// ----------------------------------------------------------------------------- +//void DlgEdFuncSelect::SetInEditMode(SdrTextObj* _pTextObj,const MouseEvent& rMEvt, BOOL bQuickDrag) +//{ +// +// SdrPageView* pPV = m_rView.GetSdrPageView(); +// if( _pTextObj && _pTextObj->GetPage() == pPV->GetPage() ) +// { +// m_rView.SetCurrentObj(OBJ_TEXT); +// m_rView.SetEditMode(SDREDITMODE_EDIT); +// +// BOOL bEmptyOutliner = FALSE; +// +// if (!_pTextObj->GetOutlinerParaObject() && m_rView.GetTextEditOutliner()) +// { +// ::SdrOutliner* pOutl = m_rView.GetTextEditOutliner(); +// ULONG nParaAnz = pOutl->GetParagraphCount(); +// Paragraph* p1stPara = pOutl->GetParagraph( 0 ); +// +// if (nParaAnz==1 && p1stPara) +// { +// // Bei nur einem Pararaph +// if (pOutl->GetText(p1stPara).Len() == 0) +// { +// bEmptyOutliner = TRUE; +// } +// } +// } +// +// if (_pTextObj != m_rView.GetTextEditObject() || bEmptyOutliner) +// { +// UINT32 nInv = _pTextObj->GetObjInventor(); +// UINT16 nSdrObjKind = _pTextObj->GetObjIdentifier(); +// +// if (nInv == SdrInventor && _pTextObj->HasTextEdit() && +// (nSdrObjKind == OBJ_TEXT || +// nSdrObjKind == OBJ_TITLETEXT || +// nSdrObjKind == OBJ_OUTLINETEXT || +// (_pTextObj->ISA(SdrTextObj) && !_pTextObj->IsEmptyPresObj()))) +// { +// // Neuen Outliner machen (gehoert der SdrObjEditView) +// SdrModel* pModel = _pTextObj->GetModel(); +// SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, pModel ); +// pOutl->SetMinDepth(0); +// pOutl->SetStyleSheetPool((SfxStyleSheetPool*) pModel->GetStyleSheetPool()); +// //pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl)); +// ULONG nCntrl = pOutl->GetControlWord(); +// nCntrl |= EE_CNTRL_ALLOWBIGOBJS; +// nCntrl |= EE_CNTRL_URLSFXEXECUTE; +// nCntrl |= EE_CNTRL_MARKFIELDS; +// nCntrl |= EE_CNTRL_AUTOCORRECT; +// +// nCntrl &= ~EE_CNTRL_ULSPACESUMMATION; +// //if ( pModel->IsSummationOfParagraphs() ) +// // nCntrl |= EE_CNTRL_ULSPACESUMMATION; +// +// //SetSpellOptions( nCntrl ); +// +// pOutl->SetControlWord(nCntrl); +// +// uno::Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() ); +// if ( xSpellChecker.is() ) +// pOutl->SetSpeller( xSpellChecker ); +// +// uno::Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() ); +// if( xHyphenator.is() ) +// pOutl->SetHyphenator( xHyphenator ); +// +// pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguage() ); +// +// // in einem Gliederungstext darf nicht auf die 0-te +// // Ebene ausgerueckt werden +// if (_pTextObj->GetObjInventor() == SdrInventor && +// _pTextObj->GetObjIdentifier() == OBJ_OUTLINETEXT) +// { +// pOutl->SetMinDepth(1); +// } +// +// if (bEmptyOutliner) +// { +// m_rView.SdrEndTextEdit(sal_True); +// } +// +// if( _pTextObj ) +// { +// OutlinerParaObject* pOPO = _pTextObj->GetOutlinerParaObject(); +// if( ( pOPO && pOPO->IsVertical() ) /*|| +// nSlotId == SID_ATTR_CHAR_VERTICAL || +// nSlotId == SID_TEXT_FITTOSIZE_VERTICAL */) +// pOutl->SetVertical( TRUE ); +// +// +// if (m_rView.SdrBeginTextEdit(_pTextObj, pPV, pParent, sal_True, pOutl) && _pTextObj->GetObjInventor() == SdrInventor) +// { +// //bFirstObjCreated = TRUE; +// //DeleteDefaultText(); +// +// OutlinerView* pOLV = m_rView.GetTextEditOutlinerView(); +// +// nSdrObjKind = _pTextObj->GetObjIdentifier(); +// +// SdrViewEvent aVEvt; +// SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); +// +// if (eHit == SDRHIT_TEXTEDIT) +// { +// // Text getroffen +// if (nSdrObjKind == OBJ_TEXT || +// nSdrObjKind == OBJ_TITLETEXT || +// nSdrObjKind == OBJ_OUTLINETEXT || +// //nSlotId == SID_TEXTEDIT || +// !bQuickDrag) +// { +// pOLV->MouseButtonDown(rMEvt); +// pOLV->MouseMove(rMEvt); +// pOLV->MouseButtonUp(rMEvt); +// } +// +// if ( bQuickDrag && _pTextObj->GetOutlinerParaObject()) +// { +// pOLV->MouseButtonDown(rMEvt); +// } +// } +// else +// { +// // #98198# Move cursor to end of text +// ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); +// pOLV->SetSelection(aNewSelection); +// } +// } +// else +// { +// //RestoreDefaultText(); +// } +// } +// } +// } +// } +// else +// _pTextObj = NULL; +//} + + +//---------------------------------------------------------------------------- +} diff --git a/reportdesign/source/ui/report/makefile.mk b/reportdesign/source/ui/report/makefile.mk new file mode 100644 index 000000000000..3c19923f4c19 --- /dev/null +++ b/reportdesign/source/ui/report/makefile.mk @@ -0,0 +1,72 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=$(PRJ)$/source +PRJNAME=reportdesign +TARGET=report + +ENABLE_EXCEPTIONS=TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +# .INCLUDE : $(PRJ)$/util$/dll.pmk + +IMGLST_SRS=$(SRS)$/$(TARGET).srs +# --- Files -------------------------------------------------------- + +SLOFILES =\ + $(SLO)$/SectionWindow.obj \ + $(SLO)$/ReportController.obj \ + $(SLO)$/ReportControllerObserver.obj \ + $(SLO)$/FormattedFieldBeautifier.obj \ + $(SLO)$/FixedTextColor.obj \ + $(SLO)$/ReportSection.obj \ + $(SLO)$/SectionView.obj \ + $(SLO)$/ViewsWindow.obj \ + $(SLO)$/ScrollHelper.obj \ + $(SLO)$/StartMarker.obj \ + $(SLO)$/EndMarker.obj \ + $(SLO)$/dlgedfunc.obj \ + $(SLO)$/dlgedfac.obj \ + $(SLO)$/dlgedclip.obj \ + $(SLO)$/ReportWindow.obj \ + $(SLO)$/DesignView.obj \ + $(SLO)$/propbrw.obj + + +SRS1NAME=$(TARGET) +SRC1FILES = report.src + +# --- Targets ------------------------------------------------------- + + +.INCLUDE : target.mk + +$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx new file mode 100644 index 000000000000..9e9ae8dffced --- /dev/null +++ b/reportdesign/source/ui/report/propbrw.cxx @@ -0,0 +1,619 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "precompiled_reportdesign.hxx" +#include "propbrw.hxx" +#include "RptObject.hxx" +#include "ReportController.hxx" +#include <cppuhelper/component_context.hxx> +#ifndef _REPORT_DLGRESID_HRC +#include <RptResId.hrc> +#endif +#ifndef _RPTUI_SLOTID_HRC_ +#include "rptui_slotid.hrc" +#endif +#include <tools/debug.hxx> +#include <com/sun/star/awt/XLayoutConstrains.hpp> +#include <com/sun/star/inspection/ObjectInspector.hpp> +#include <com/sun/star/inspection/DefaultHelpProvider.hpp> +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif +#include <vcl/stdtext.hxx> +#include <svx/svdview.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdpage.hxx> +#include <svx/svditer.hxx> + +#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +#include <toolkit/unohlp.hxx> +#endif +#include <comphelper/property.hxx> +#include <comphelper/namecontainer.hxx> +#include <comphelper/composedprops.hxx> +#include <comphelper/stl_types.hxx> +#include <comphelper/types.hxx> +#include <comphelper/sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/report/inspection/DefaultComponentInspectorModel.hpp> +#include <comphelper/processfactory.hxx> +#include "SectionView.hxx" +#include "ReportSection.hxx" +#ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC +#include "uistrings.hrc" +#endif +#include "DesignView.hxx" +#include "ViewsWindow.hxx" +#include "UITools.hxx" +#include <unotools/confignode.hxx> + +namespace rptui +{ +#define STD_WIN_SIZE_X 300 +#define STD_WIN_SIZE_Y 350 + +using namespace ::com::sun::star; +using namespace uno; +using namespace lang; +using namespace frame; +using namespace beans; +using namespace container; +using namespace ::comphelper; + +//---------------------------------------------------------------------------- +//----------------------------------------------------------------------- +namespace +{ + static bool lcl_shouldEnableHelpSection( const Reference< XMultiServiceFactory >& _rxFactory ) + { + const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign/PropertyBrowser/" ) ); + const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DirectHelp" ) ); + + ::utl::OConfigurationTreeRoot aConfiguration( + ::utl::OConfigurationTreeRoot::createWithServiceFactory( _rxFactory, sConfigName ) ); + + bool bEnabled = false; + OSL_VERIFY( aConfiguration.getNodeValue( sPropertyName ) >>= bEnabled ); + return bEnabled; + } +} +//----------------------------------------------------------------------- +//============================================================================ +// PropBrw +//============================================================================ + +DBG_NAME( rpt_PropBrw ) + +//---------------------------------------------------------------------------- + +PropBrw::PropBrw(const Reference< XMultiServiceFactory >& _xORB,Window* pParent,ODesignView* _pDesignView) + :DockingWindow(pParent,WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE)) + ,m_xORB(_xORB) + ,m_pDesignView(_pDesignView) + ,m_pView( NULL ) + ,m_bInitialStateChange(sal_True) +{ + DBG_CTOR( rpt_PropBrw,NULL); + + Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y); + SetOutputSizePixel(aPropWinSize); + + try + { + // create a frame wrapper for myself + m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame"))), UNO_QUERY); + if (m_xMeAsFrame.is()) + { + m_xMeAsFrame->initialize( VCLUnoHelper::GetInterface ( this ) ); + m_xMeAsFrame->setName(::rtl::OUString::createFromAscii("report property browser")); // change name! + } + } + catch (Exception&) + { + DBG_ERROR("PropBrw::PropBrw: could not create/initialize my frame!"); + m_xMeAsFrame.clear(); + } + + if (m_xMeAsFrame.is()) + { + Reference< XComponentContext > xOwnContext; + try + { + // our own component context + Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW ); + xOwnContext.set( + xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), + UNO_QUERY_THROW ); + + /*uno::Reference< XComponent> xModel = new OContextHelper(m_xORB,uno::Reference< XComponent>(m_pDesignView->getController().getModel(),uno::UNO_QUERY) ); + uno::Reference< XComponent> xDialogParentWindow = new OContextHelper(m_xORB,uno::Reference< XComponent>(VCLUnoHelper::GetInterface ( this ),uno::UNO_QUERY) ); + uno::Reference< XComponent> xConnection = new OContextHelper(m_xORB,uno::Reference< XComponent>(m_pDesignView->getController().getConnection(),uno::UNO_QUERY) );*/ + // a ComponentContext for the + ::cppu::ContextEntry_Init aHandlerContextInfo[] = + { + ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( m_pDesignView->getController().getModel() )), + ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface ( this ) )), + ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ), makeAny( m_pDesignView->getController().getConnection() ) ), + }; + m_xInspectorContext.set( + ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), + xOwnContext ) ); + // create a property browser controller + bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB ); + Reference< inspection::XObjectInspectorModel> xInspectorModel( bEnableHelpSection + ? report::inspection::DefaultComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 8 ) + : report::inspection::DefaultComponentInspectorModel::createDefault( m_xInspectorContext ) ); + + m_xBrowserController = inspection::ObjectInspector::createWithModel(m_xInspectorContext, xInspectorModel); + if ( !m_xBrowserController.is() ) + { + const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) ); + ShowServiceNotAvailableError(pParent, sServiceName, sal_True); + } + else + { + m_xBrowserController->attachFrame(m_xMeAsFrame); + m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow(); + OSL_ENSURE(m_xBrowserComponentWindow.is(), "PropBrw::PropBrw: attached the controller, but have no component window!"); + if ( bEnableHelpSection ) + { + uno::Reference< inspection::XObjectInspector > xInspector( m_xBrowserController, uno::UNO_QUERY_THROW ); + uno::Reference< inspection::XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() ); + uno::Reference< uno::XInterface > xDefaultHelpProvider( inspection::DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI ) ); + } + } + xFactoryProperties->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ,makeAny(xOwnContext)); + } + catch (Exception&) + { + DBG_ERROR("PropBrw::PropBrw: could not create/initialize the browser controller!"); + try + { + ::comphelper::disposeComponent(m_xBrowserController); + ::comphelper::disposeComponent(m_xBrowserComponentWindow); + Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW ); + if ( xOwnContext.is() ) + xFactoryProperties->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ,makeAny(xOwnContext)); + } + catch(Exception&) { } + m_xBrowserController.clear(); + m_xBrowserComponentWindow.clear(); + } + } + + if (m_xBrowserComponentWindow.is()) + { + + m_xBrowserComponentWindow->setPosSize(0, 0, aPropWinSize.Width(), aPropWinSize.Height(), + awt::PosSize::WIDTH | awt::PosSize::HEIGHT | awt::PosSize::X | awt::PosSize::Y); + Resize(); + m_xBrowserComponentWindow->setVisible(sal_True); + } + ::rptui::notifySystemWindow(pParent,this,::comphelper::mem_fun(&TaskPaneList::AddWindow)); +} + +//---------------------------------------------------------------------------- + +PropBrw::~PropBrw() +{ + if (m_xBrowserController.is()) + implDetachController(); + + try + { + uno::Reference<container::XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY); + if ( xName.is() ) + { + const ::rtl::OUString pProps[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ) + , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ) + , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) )}; + for (size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i) + xName->removeByName(pProps[i]); + } + } + catch(Exception&) + {} + + ::rptui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); + + DBG_DTOR( rpt_PropBrw,NULL); +} +// ----------------------------------------------------------------------------- +void PropBrw::setCurrentPage(const ::rtl::OUString& _sLastActivePage) +{ + m_sLastActivePage = _sLastActivePage; +} +//---------------------------------------------------------------------------- + +void PropBrw::implDetachController() +{ + m_sLastActivePage = getCurrentPage(); + implSetNewObject( ); + + if ( m_xMeAsFrame.is() ) + m_xMeAsFrame->setComponent( NULL, NULL ); + + if ( m_xBrowserController.is() ) + m_xBrowserController->attachFrame( NULL ); + + m_xMeAsFrame.clear(); + m_xBrowserController.clear(); + m_xBrowserComponentWindow.clear(); +} +//----------------------------------------------------------------------- +::rtl::OUString PropBrw::getCurrentPage() const +{ + ::rtl::OUString sCurrentPage; + try + { + if ( m_xBrowserController.is() ) + { + OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage ); + } + + if ( !sCurrentPage.getLength() ) + sCurrentPage = m_sLastActivePage; + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "PropBrw::getCurrentPage: caught an exception while retrieving the current page!" ); + } + return sCurrentPage; +} +//---------------------------------------------------------------------------- + +sal_Bool PropBrw::Close() +{ + m_xLastSection.clear(); + // suspend the controller (it is allowed to veto) + if ( m_xMeAsFrame.is() ) + { + try + { + Reference< XController > xController( m_xMeAsFrame->getController() ); + if ( xController.is() && !xController->suspend( sal_True ) ) + return sal_False; + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "FmPropBrw::Close: caught an exception while asking the controller!" ); + } + } + implDetachController(); + + if( IsRollUp() ) + RollDown(); + + m_pDesignView->getController().executeUnChecked(SID_PROPERTYBROWSER_LAST_PAGE,uno::Sequence< beans::PropertyValue>()); + + return TRUE; +} + +//---------------------------------------------------------------------------- + +uno::Sequence< Reference<uno::XInterface> > PropBrw::CreateCompPropSet(const SdrMarkList& _rMarkList) +{ + sal_uInt32 nMarkCount = _rMarkList.GetMarkCount(); + ::std::vector< uno::Reference< uno::XInterface> > aSets; + aSets.reserve(nMarkCount); + + for(sal_uInt32 i=0;i<nMarkCount;++i) + { + SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj(); + + ::std::auto_ptr<SdrObjListIter> pGroupIterator; + if (pCurrent->IsGroupObject()) + { + pGroupIterator.reset(new SdrObjListIter(*pCurrent->GetSubList())); + pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL; + } + + while (pCurrent) + { + OObjectBase* pObj = dynamic_cast<OObjectBase*>(pCurrent); + if ( pObj ) + aSets.push_back(CreateComponentPair(pObj)); + + // next element + pCurrent = pGroupIterator.get() && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL; + } + } + Reference<uno::XInterface> *pSets = aSets.empty() ? NULL : &aSets[0]; + return uno::Sequence< Reference<uno::XInterface> >(pSets, aSets.size()); +} +//---------------------------------------------------------------------------- +void PropBrw::implSetNewObject( const uno::Sequence< Reference<uno::XInterface> >& _aObjects ) +{ + if ( m_xBrowserController.is() ) + { + try + { + m_xBrowserController->inspect(uno::Sequence< Reference<uno::XInterface> >()); + m_xBrowserController->inspect(_aObjects); + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "FmPropBrw::StateChanged: caught an exception while setting the initial page!" ); + } + + //Resize(); + } + SetText( GetHeadlineName(_aObjects) ); +} + +//---------------------------------------------------------------------------- + +::rtl::OUString PropBrw::GetHeadlineName( const uno::Sequence< Reference<uno::XInterface> >& _aObjects ) +{ + ::rtl::OUString aName; + if ( !_aObjects.getLength() ) + { + aName = String(ModuleRes(RID_STR_BRWTITLE_NO_PROPERTIES)); + } + else if ( _aObjects.getLength() == 1 ) // single selection + { + sal_uInt16 nResId = 0; + aName = String(ModuleRes(RID_STR_BRWTITLE_PROPERTIES)); + + uno::Reference< container::XNameContainer > xNameCont(_aObjects[0],uno::UNO_QUERY); + Reference< lang::XServiceInfo > xServiceInfo( xNameCont->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent"))), UNO_QUERY ); + if ( xServiceInfo.is() ) + { + if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT ) ) + { + nResId = RID_STR_PROPTITLE_FIXEDTEXT; + } + else if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL ) ) + { + nResId = RID_STR_PROPTITLE_IMAGECONTROL; + } + else if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD ) ) + { + nResId = RID_STR_PROPTITLE_FORMATTED; + } + else if ( xServiceInfo->supportsService( SERVICE_SHAPE ) ) + { + nResId = RID_STR_PROPTITLE_SHAPE; + } + else if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) ) + { + nResId = RID_STR_PROPTITLE_REPORT; + } + else if ( xServiceInfo->supportsService( SERVICE_SECTION ) ) + { + nResId = RID_STR_PROPTITLE_SECTION; + } + else if ( xServiceInfo->supportsService( SERVICE_FUNCTION ) ) + { + nResId = RID_STR_PROPTITLE_FUNCTION; + } + else if ( xServiceInfo->supportsService( SERVICE_GROUP ) ) + { + nResId = RID_STR_PROPTITLE_GROUP; + } + else if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE ) ) + { + nResId = RID_STR_PROPTITLE_FIXEDLINE; + } + else + { + OSL_ENSURE(0,"Unknown service name!"); + nResId = RID_STR_CLASS_FORMATTEDFIELD; + } + + if (nResId) + { + aName += String(ModuleRes(nResId)); + } + } + } + else // multiselection + { + aName = String(ModuleRes(RID_STR_BRWTITLE_PROPERTIES)); + aName += String(ModuleRes(RID_STR_BRWTITLE_MULTISELECT)); + } + + return aName; +} +// ----------------------------------------------------------------------------- +uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(OObjectBase* _pObj) +{ + _pObj->initializeOle(); + return CreateComponentPair(_pObj->getAwtComponent(),_pObj->getReportComponent()); +} +//---------------------------------------------------------------------------- +uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(const uno::Reference< uno::XInterface>& _xFormComponent + ,const uno::Reference< uno::XInterface>& _xReportComponent) +{ + uno::Reference< container::XNameContainer > xNameCont = ::comphelper::NameContainer_createInstance(::getCppuType(static_cast<Reference<XInterface> * >(NULL))); + xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormComponent")),uno::makeAny(_xFormComponent)); + xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent")),uno::makeAny(_xReportComponent)); + xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RowSet")) + ,uno::makeAny(uno::Reference< uno::XInterface>(m_pDesignView->getController().getRowSet()))); + + return xNameCont.get(); +} +// ----------------------------------------------------------------------------- +::Size PropBrw::getMinimumSize() const +{ + ::Size aSize; + Reference< awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY ); + if( xLayoutConstrains.is() ) + { + awt::Size aMinSize = xLayoutConstrains->getMinimumSize(); + aMinSize.Height += 4; + aMinSize.Width += 4; + aSize.setHeight( aMinSize.Height ); + aSize.setWidth( aMinSize.Width ); + } + return aSize; +} +//---------------------------------------------------------------------------- +void PropBrw::Resize() +{ + Window::Resize(); + + Reference< awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY ); + if( xLayoutConstrains.is() ) + { + ::Size aMinSize = getMinimumSize(); + SetMinOutputSizePixel( aMinSize ); + ::Size aSize = GetOutputSizePixel(); + sal_Bool bResize = sal_False; + if( aSize.Width() < aMinSize.Width() ) + { + aSize.setWidth( aMinSize.Width() ); + bResize = sal_True; + } + if( aSize.Height() < aMinSize.Height() ) + { + aSize.setHeight( aMinSize.Height() ); + bResize = sal_True; + } + if( bResize ) + SetOutputSizePixel( aSize ); + } + // adjust size + if (m_xBrowserComponentWindow.is()) + { + Size aSize = GetOutputSizePixel(); + m_xBrowserComponentWindow->setPosSize(0, 0, aSize.Width(), aSize.Height(), + awt::PosSize::WIDTH | awt::PosSize::HEIGHT); + } +} +//---------------------------------------------------------------------------- +void PropBrw::Update( OSectionView* pNewView ) +{ + try + { + if ( m_pView ) + { + EndListening( *(m_pView->GetModel()) ); + m_pView = NULL; + } + + // set focus on initialization + if ( m_bInitialStateChange ) + { + // if we're just newly created, we want to have the focus + PostUserEvent( LINK( this, PropBrw, OnAsyncGetFocus ) ); + m_bInitialStateChange = sal_False; + // and additionally, we want to show the page which was active during + // our previous incarnation + if ( m_sLastActivePage.getLength() && m_xBrowserController.is() ) + { + try + { + m_xBrowserController->restoreViewData( makeAny( m_sLastActivePage ) ); + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "FmPropBrw::StateChanged: caught an exception while setting the initial page!" ); + } + } + } + + if ( !pNewView ) + return; + else + m_pView = pNewView; + + uno::Sequence< Reference<uno::XInterface> > aMarkedObjects; + OViewsWindow* pViews = m_pView->getReportSection()->getSectionWindow()->getViewsWindow(); + const USHORT nSectionCount = pViews->getSectionCount(); + for (USHORT i = 0; i < nSectionCount; ++i) + { + ::boost::shared_ptr<OSectionWindow> pSectionWindow = pViews->getSectionWindow(i); + if ( pSectionWindow ) + { + const SdrMarkList& rMarkList = pSectionWindow->getReportSection().getSectionView().GetMarkedObjectList(); + aMarkedObjects = ::comphelper::concatSequences(aMarkedObjects,CreateCompPropSet( rMarkList )); + } + } + + if ( aMarkedObjects.getLength() ) // multiple selection + { + m_xLastSection.clear(); + implSetNewObject( aMarkedObjects ); + } + else if ( m_xLastSection != m_pView->getReportSection()->getSection() ) + { + uno::Reference< uno::XInterface> xTemp(m_pView->getReportSection()->getSection()); + m_xLastSection = xTemp; + uno::Reference< container::XNameContainer > xNameCont = ::comphelper::NameContainer_createInstance(::getCppuType(static_cast<Reference<XInterface> * >(NULL))); + xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent")),uno::makeAny(xTemp)); + xTemp = xNameCont; + + implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) ); + } + + StartListening( *(m_pView->GetModel()) ); + } + catch ( Exception& ) + { + DBG_ERROR( "PropBrw::Update: Exception occured!" ); + } +} +//---------------------------------------------------------------------------- +void PropBrw::Update( const uno::Reference< uno::XInterface>& _xReportComponent) +{ + if ( m_xLastSection != _xReportComponent ) + { + m_xLastSection = _xReportComponent; + try + { + if ( m_pView ) + { + EndListening( *(m_pView->GetModel()) ); + m_pView = NULL; + } // if ( m_pView ) + + uno::Reference< uno::XInterface> xTemp(CreateComponentPair(_xReportComponent,_xReportComponent)); + implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) ); + } + catch ( Exception& ) + { + DBG_ERROR( "PropBrw::Update: Exception occured!" ); + } + } +} +//----------------------------------------------------------------------- +IMPL_LINK( PropBrw, OnAsyncGetFocus, void*, ) +{ + if (m_xBrowserComponentWindow.is()) + m_xBrowserComponentWindow->setFocus(); + return 0L; +} +//---------------------------------------------------------------------------- +void PropBrw::LoseFocus() +{ + DockingWindow::LoseFocus(); + m_pDesignView->getController().InvalidateAll(); +} +//---------------------------------------------------------------------------- +} diff --git a/reportdesign/source/ui/report/report.src b/reportdesign/source/ui/report/report.src new file mode 100644 index 000000000000..4a84f7bd034d --- /dev/null +++ b/reportdesign/source/ui/report/report.src @@ -0,0 +1,700 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "RptResId.hrc" +#include "rptui_slotid.hrc" +#ifndef _GLOBLMN_HRC +#include <svx/globlmn.hrc> +#endif +#ifndef _SBASLTID_HRC +#include <svx/svxids.hrc> +#endif + + +// Dialog Controls --------------------------------------------------------------- + +String RID_STR_CLASS_FIXEDTEXT +{ + Text = "Label" ; +}; +String RID_STR_CLASS_FIXEDLINE +{ + Text = "Line" ; +}; +String RID_STR_CLASS_IMAGECONTROL +{ + Text = "Graphic" ; +}; +String RID_STR_CLASS_FORMATTEDFIELD +{ + Text = "FormattedField" ; +}; + + +// Property Browser Headline ---------------------------------------------------------------- + +String RID_STR_BRWTITLE_PROPERTIES +{ + Text [ en-US ] = "Properties: "; +}; +String RID_STR_BRWTITLE_NO_PROPERTIES +{ + Text [ en-US ] = "No Control marked"; +}; +String RID_STR_BRWTITLE_MULTISELECT +{ + Text [ en-US ] = "Multiselection"; +}; + +String RID_STR_PROPTITLE_IMAGECONTROL +{ + Text [ en-US ] = "Image Control" ; +}; +String RID_STR_PROPTITLE_FIXEDTEXT +{ + Text [ en-US ] = "Label field" ; +}; +String RID_STR_PROPTITLE_FIXEDLINE +{ + Text [ en-US ] = "Line" ; + Text [ x-comment ] = " "; +}; +String RID_STR_PROPTITLE_FORMATTED +{ + Text [ en-US ] = "Formatted Field"; + Text [ x-comment ] = " "; +}; +String RID_STR_PROPTITLE_SHAPE +{ + Text [ en-US ] = "Shape"; + Text [ x-comment ] = " "; +}; +String RID_STR_PROPTITLE_REPORT +{ + Text [ en-US ] = "Report"; +}; +String RID_STR_PROPTITLE_SECTION +{ + Text [ en-US ] = "Section"; +}; +String RID_STR_PROPTITLE_FUNCTION +{ + Text [ en-US ] = "Function"; +}; +String RID_STR_PROPTITLE_GROUP +{ + Text [ en-US ] = "Group"; +}; +// ----------------------------------------------------------------------- + +Image RID_IMG_TREENODE_COLLAPSED +{ + ImageBitmap = Bitmap { File = "plus.bmp"; } ; + MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }; +}; + +Image RID_IMG_TREENODE_EXPANDED +{ + ImageBitmap = Bitmap { File = "minus.bmp"; } ; + MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }; +}; + +Image RID_IMG_TREENODE_COLLAPSED_HC +{ + ImageBitmap = Bitmap { File = "plus_sch.bmp"; } ; + MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }; +}; + +Image RID_IMG_TREENODE_EXPANDED_HC +{ + ImageBitmap = Bitmap { File = "minus_sch.bmp"; } ; + MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }; +}; + +String STR_SHOW_RULER +{ + Text [ en-US ] = "Show ruler"; +}; + +String STR_SHOW_GRID +{ + Text [ en-US ] = "Show grid"; +}; + +String RID_STR_UNDO_CHANGEPOSITION +{ + Text [ en-US ] = "Change Object"; +}; +String RID_STR_UNDO_MOVE_GROUP +{ + Text [ en-US ] = "Move Group(s)"; +}; +String RID_STR_UNDO_CONDITIONAL_FORMATTING +{ + Text [ en-US ] = "Conditional Formatting"; +}; +String RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER +{ + Text [ en-US ] = "Remove report header / report footer"; +}; + +String RID_STR_UNDO_ADD_REPORTHEADERFOOTER +{ + Text [ en-US ] = "Add report header / report footer"; +}; + +String RID_STR_UNDO_REMOVE_PAGEHEADERFOOTER +{ + Text [ en-US ] = "Remove page header / page footer"; +}; + +String RID_STR_UNDO_ADD_PAGEHEADERFOOTER +{ + Text [ en-US ] = "Add page header / page footer"; +}; + +String RID_STR_UNDO_PROPERTY +{ + Text [ en-US ] = "Change property '#'"; + Text = "The # character is used for replacing"; +}; + +String RID_STR_UNDO_ADD_GROUP_HEADER +{ + Text [ en-US ] = "Add group header "; +}; + +String RID_STR_UNDO_REMOVE_GROUP_HEADER +{ + Text [ en-US ] = "Remove group header "; +}; + +String RID_STR_UNDO_ADD_GROUP_FOOTER +{ + Text [ en-US ] = "Add group footer "; +}; + +String RID_STR_UNDO_REMOVE_GROUP_FOOTER +{ + Text [ en-US ] = "Remove group footer "; +}; +String RID_STR_UNDO_ADDFUNCTION +{ + Text [ en-US ] = "Add function"; +}; + +String RID_STR_UNDO_DELETEFUNCTION +{ + Text [ en-US ] = "Delete function"; +}; + +String RID_STR_DESIGN_VIEW +{ + Text [ en-US ] = "Design"; +}; + +String RID_STR_PREVIEW_VIEW +{ + Text [ en-US ] = "Preview"; +}; + +String STR_RPT_TITLE +{ + Text [ en-US ] = "Report #" ; + Text [ x-comment ] = " "; +}; + +String STR_RPT_LABEL +{ + Text [ en-US ] = "~Report name" ; +}; + +String RID_STR_UNDO_REMOVE_GROUP +{ + Text [ en-US ] = "Delete Group" ; +}; + +String RID_STR_UNDO_APPEND_GROUP +{ + Text [ en-US ] = "Add Group" ; +}; + +String RID_STR_UNDO_REMOVE_SELECTION +{ + Text [ en-US ] = "Delete Selection" ; +}; +String RID_STR_UNDO_REMOVE_FUNCTION +{ + Text [ en-US ] = "Delete Function" ; +}; + +String RID_STR_UNDO_CHANGE_SIZE +{ + Text [ en-US ] = "Change Size" ; +}; + +String RID_STR_UNDO_PASTE +{ + Text [ en-US ] = "Paste" ; +}; + +String RID_STR_UNDO_INSERT_CONTROL +{ + Text [ en-US ] = "Insert Control" ; +}; + +String RID_STR_UNDO_DELETE_CONTROL +{ + Text [ en-US ] = "Delete Control" ; +}; + +String RID_STR_UNDO_GROUP +{ + Text [ en-US ] = "Insert Group" ; +}; + +String RID_STR_UNDO_UNGROUP +{ + Text [ en-US ] = "Delete Group" ; +}; + +String RID_STR_GROUPHEADER +{ + Text [ en-US ] = "GroupHeader"; + Text [ x-comment ] = "Please try to avoid spaces in the name. It is used as a programatic one."; +}; +String RID_STR_GROUPFOOTER +{ + Text [ en-US ] = "GroupFooter"; + Text [ x-comment ] = "Please try to avoid spaces in the name. It is used as a programatic one."; +}; +Menu RID_MENU_REPORT +{ + ItemList = + { + MenuItem + { + Identifier = SID_SORTINGANDGROUPING; + HelpId = SID_SORTINGANDGROUPING ; + Command = ".uno:DbSortingAndGrouping"; + Text [ en-US ] = "Sorting and Grouping..."; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_ATTR_CHAR_COLOR_BACKGROUND; + HelpId = SID_ATTR_CHAR_COLOR_BACKGROUND ; + Command = ".uno:DBBackgroundColor"; + Text [ en-US ] = "Background Color..."; + }; + MenuItem + { + Identifier = SID_RULER; + HelpId = SID_RULER ; + Command = ".uno:ShowRuler"; + Checkable = TRUE; + Text [ en-US ] = "Ruler..."; + }; + MenuItem + { + Identifier = SID_GRID_VISIBLE; + HelpId = SID_GRID_VISIBLE ; + Command = ".uno:GridVisible"; + Checkable = TRUE; + Text [ en-US ] = "Grid..."; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_PAGEHEADERFOOTER; + HelpId = SID_PAGEHEADERFOOTER ; + Command = ".uno:PageHeaderFooter"; + Checkable = TRUE; + }; + MenuItem + { + Identifier = SID_REPORTHEADERFOOTER; + HelpId = SID_REPORTHEADERFOOTER ; + Command = ".uno:ReportHeaderFooter"; + Checkable = TRUE; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_ARRANGEMENU ; + HelpID = SID_ARRANGEMENU ; + Command = ".uno:ArrangeMenu" ; + Text [ en-US ] = "~Arrange" ; + SubMenu = Menu + { + ItemList = + { + MenuItem + { + ITEM_FORMAT_FRAME_TO_TOP + }; + MenuItem + { + Identifier = SID_FRAME_UP ; + HelpID = SID_FRAME_UP ; + Text [ en-US ] = "Bring ~Forward" ; + }; + MenuItem + { + Identifier = SID_FRAME_DOWN ; + HelpID = SID_FRAME_DOWN ; + Text [ en-US ] = "Send Back~ward" ; + }; + MenuItem + { + ITEM_FORMAT_FRAME_TO_BOTTOM + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + ITEM_FORMAT_OBJECT_HEAVEN + }; + MenuItem + { + ITEM_FORMAT_OBJECT_HELL + }; + }; + }; + }; + MenuItem + { + ITEM_FORMAT_OBJECT_ALIGN + SubMenu = Menu + { + ItemList = + { + MenuItem + { + ITEM_FORMAT_OBJECT_ALIGN_LEFT + }; + MenuItem + { + ITEM_FORMAT_OBJECT_ALIGN_CENTER + }; + MenuItem + { + ITEM_FORMAT_OBJECT_ALIGN_RIGHT + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + ITEM_FORMAT_OBJECT_ALIGN_UP + }; + MenuItem + { + ITEM_FORMAT_OBJECT_ALIGN_MIDDLE + }; + MenuItem + { + ITEM_FORMAT_OBJECT_ALIGN_DOWN + }; + }; + }; + }; + MenuItem + { + Separator = TRUE; + }; + + MenuItem + { + Identifier = SID_OBJECT_RESIZING ; + Command = ".uno:ObjectResize" ; + HelpID = SID_OBJECT_RESIZING ; + Text [ en-US ] = "~Object Resizing" ; + Text [ x-comment ] = " "; + SubMenu = Menu + { + ItemList = + { + MenuItem + { + Identifier = SID_OBJECT_SMALLESTWIDTH ; + Command = ".uno:SmallestWidth" ; + HelpID = SID_OBJECT_SMALLESTWIDTH ; + Text [ en-US ] = "~Fit to smallest width" ; + Text [ x-comment ] = " "; + }; + MenuItem + { + Identifier = SID_OBJECT_GREATESTWIDTH ; + Command = ".uno:GreatestWidth" ; + HelpID = SID_OBJECT_GREATESTWIDTH ; + Text [ en-US ] = "~Fit to greatest width" ; + Text [ x-comment ] = " "; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_OBJECT_SMALLESTHEIGHT ; + Command = ".uno:SmallestHeight" ; + HelpID = SID_OBJECT_SMALLESTHEIGHT ; + Text [ en-US ] = "~Fit to smallest height" ; + Text [ x-comment ] = " "; + }; + MenuItem + { + Identifier = SID_OBJECT_GREATESTHEIGHT ; + Command = ".uno:GreatestHeight" ; + HelpID = SID_OBJECT_GREATESTHEIGHT ; + Text [ en-US ] = "~Fit to greatest height" ; + Text [ x-comment ] = " "; + }; + }; + }; + }; + + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_SECTION_SHRINK_MENU ; + Command = ".uno:SectionShrinkMenu" ; + HelpID = SID_SECTION_SHRINK_MENU ; + Text [ en-US ] = "Section" ; + Text [ x-comment ] = " "; + SubMenu = Menu + { + ItemList = + { + MenuItem + { + Identifier = SID_SECTION_SHRINK ; + Command = ".uno:SectionShrink" ; + HelpID = SID_SECTION_SHRINK ; + Text [ en-US ] = "Shrink" ; + Text [ x-comment ] = " "; + }; + MenuItem + { + Identifier = SID_SECTION_SHRINK_TOP ; + Command = ".uno:SectionShrinkTop" ; + HelpID = SID_SECTION_SHRINK_TOP ; + Text [ en-US ] = "Shrink from top" ; + Text [ x-comment ] = " "; + }; + MenuItem + { + Identifier = SID_SECTION_SHRINK_BOTTOM ; + Command = ".uno:SectionShrinkBottom" ; + HelpID = SID_SECTION_SHRINK_BOTTOM ; + Text [ en-US ] = "Shrink from bottom" ; + Text [ x-comment ] = " "; + }; + }; + }; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_DISTRIBUTION; + HelpId = SID_DISTRIBUTION ; + Command = ".uno:Distribution"; + Text [ en-US ] = "Distribution..." ; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_SHOW_PROPERTYBROWSER; + HelpId = SID_SHOW_PROPERTYBROWSER ; + Command = ".uno:FormProperties"; + Text [ en-US ] = "Properties..."; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + ITEM_EDIT_CUT + }; + MenuItem + { + ITEM_EDIT_COPY + }; + MenuItem + { + ITEM_EDIT_PASTE + }; + }; +}; +String RID_STR_FIELDSELECTION +{ + Text [ en-US ] = "Add field:"; +}; + +String RID_STR_FILTER +{ + Text [ en-US ] = "Filter" ; +}; + +String RID_APP_TITLE +{ + Text [ en-US ] = " - %PRODUCTNAME Base Report" ; +}; + +String RID_APP_NEW_DOC +{ + Text [ en-US ] = "Untitled" ; +}; +String RID_STR_UNDO_ALIGNMENT +{ + Text [ en-US ] = "Change Alignment" ; +}; +String RID_STR_HEADER +{ + Text [ en-US ] = "# Header" ; + Text[ x-comment ] = "# will be replaced with a name."; +}; +String RID_STR_FOOTER +{ + Text [ en-US ] = "# Footer" ; + Text[ x-comment ] = "# will be replaced with a name."; +}; +String RID_STR_IMPORT_GRAPHIC +{ + Text [ en-US ] = "Insert graphics" ; +}; +String RID_STR_DELETE +{ + Text [ en-US ] = "Delete" ; +}; +String RID_STR_FUNCTION +{ + Text [ en-US ] = "Function" ; +}; +Image REPORT_TREE_ICON +{ + ImageBitmap = Bitmap { File = "report_16"; }; + MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }; +}; +String RID_STR_COULD_NOT_CREATE_REPORT +{ + Text [ en-US ] = "An error occurred while creating the report." ; +}; +String RID_STR_CAUGHT_FOREIGN_EXCEPTION +{ + Text [ en-US ] = "An exception of type $type$ was caught." ; +}; +String RID_STR_UNDO_CHANGEFONT +{ + Text [ en-US ] = "Change font"; +}; +String RID_STR_UNDO_CHANGEPAGE +{ + Text [ en-US ] = "Change page attributes"; +}; +String RID_STR_PAGEHEADERFOOTER_INSERT +{ + Text [ en-US ] = "Insert Page Header/Footer"; +}; +String RID_STR_PAGEHEADERFOOTER_DELETE +{ + Text [ en-US ] = "Delete Page Header/Footer"; +}; +String RID_STR_COLUMNHEADERFOOTER_INSERT +{ + Text [ en-US ] = "Insert Column Header/Footer"; +}; +String RID_STR_COLUMNHEADERFOOTER_DELETE +{ + Text [ en-US ] = "Delete Column Header/Footer"; +}; +String RID_STR_REPORTHEADERFOOTER_INSERT +{ + Text [ en-US ] = "Insert Report Header/Footer"; +}; +String RID_STR_REPORTHEADERFOOTER_DELETE +{ + Text [ en-US ] = "Delete Report Header/Footer"; +}; +String RID_ERR_NO_COMMAND +{ + Text [ en-US ] = "The report can not be executed unless it is bound to content."; +}; +String RID_ERR_NO_OBJECTS +{ + Text [ en-US ] = "The report can not be executed unless at least one object has been inserted."; +}; +String RID_STR_UNDO_SHRINK +{ + Text [ en-US ] = "Shrink Section"; +}; +String RID_STR_DETAIL +{ + Text [ en-US ] = "Detail"; +}; +String RID_STR_PAGE_HEADER +{ + Text [ en-US ] = "Page Header"; +}; +String RID_STR_PAGE_FOOTER +{ + Text [ en-US ] = "Page Footer"; +}; +String RID_STR_REPORT_HEADER +{ + Text [ en-US ] = "Report Header"; +}; +String RID_STR_REPORT_FOOTER +{ + Text [ en-US ] = "Report Footer"; +}; +String RID_STR_INSERT +{ + Text [ en-US ] = "Insert"; +}; |