LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - ReportController.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2303 0.0 %
Date: 2014-04-14 Functions: 0 117 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #define RPTUI_ID_LRSPACE    1
      21             : #define RPTUI_ID_ULSPACE    2
      22             : #define RPTUI_ID_PAGE       3
      23             : #define RPTUI_ID_SIZE       4
      24             : #define RPTUI_ID_PAGE_MODE  5
      25             : #define RPTUI_ID_START      6
      26             : #define RPTUI_ID_END        7
      27             : #define RPTUI_ID_BRUSH      8
      28             : #define RPTUI_ID_METRIC     9
      29             : 
      30             : #include "ReportController.hxx"
      31             : #include "ReportDefinition.hxx"
      32             : #include "CondFormat.hxx"
      33             : #include "UITools.hxx"
      34             : #include "AddField.hxx"
      35             : #include <toolkit/helper/vclunohelper.hxx>
      36             : #include "DateTime.hxx"
      37             : 
      38             : #include <sfx2/filedlghelper.hxx>
      39             : #include <tools/diagnose_ex.h>
      40             : #include "rptui_slotid.hrc"
      41             : #include "reportformula.hxx"
      42             : 
      43             : #include <comphelper/documentconstants.hxx>
      44             : #include <unotools/mediadescriptor.hxx>
      45             : #include <comphelper/processfactory.hxx>
      46             : #include <comphelper/property.hxx>
      47             : #include <comphelper/sequenceashashmap.hxx>
      48             : #include <comphelper/types.hxx>
      49             : 
      50             : #include <connectivity/dbtools.hxx>
      51             : #include <com/sun/star/view/PaperFormat.hpp>
      52             : #include <com/sun/star/style/GraphicLocation.hpp>
      53             : #include <com/sun/star/style/XStyle.hpp>
      54             : #include <com/sun/star/style/PageStyleLayout.hpp>
      55             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      56             : #include <com/sun/star/util/NumberFormatter.hpp>
      57             : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      58             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      59             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      60             : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      61             : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      62             : #include <com/sun/star/datatransfer/XTransferable.hpp>
      63             : #include <com/sun/star/container/XChild.hpp>
      64             : #include <com/sun/star/container/XNameContainer.hpp>
      65             : #include <com/sun/star/report/XImageControl.hpp>
      66             : #include <com/sun/star/report/XFixedLine.hpp>
      67             : #include <com/sun/star/report/Function.hpp>
      68             : #include <com/sun/star/report/XShape.hpp>
      69             : #include <com/sun/star/awt/FontDescriptor.hpp>
      70             : #include <com/sun/star/sdb/XDocumentDataSource.hpp>
      71             : #include <com/sun/star/sdb/XParametersSupplier.hpp>
      72             : #include <com/sun/star/sdb/CommandType.hpp>
      73             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      74             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      75             : #include <com/sun/star/embed/ElementModes.hpp>
      76             : #include <com/sun/star/embed/EmbedMapUnits.hpp>
      77             : #include <comphelper/streamsection.hxx>
      78             : #include <com/sun/star/awt/FontWeight.hpp>
      79             : #include <com/sun/star/awt/FontUnderline.hpp>
      80             : #include <com/sun/star/awt/TextAlign.hpp>
      81             : #include <com/sun/star/awt/FontSlant.hpp>
      82             : #include <com/sun/star/frame/Desktop.hpp>
      83             : #include <com/sun/star/frame/status/FontHeight.hpp>
      84             : #include <com/sun/star/report/ReportEngine.hpp>
      85             : #include <com/sun/star/report/XFormattedField.hpp>
      86             : #include <com/sun/star/sdb/SQLContext.hpp>
      87             : #include <com/sun/star/sdbc/SQLWarning.hpp>
      88             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      89             : #include <com/sun/star/document/XUndoManagerSupplier.hpp>
      90             : 
      91             : #include <vcl/svapp.hxx>
      92             : #include <vcl/msgbox.hxx>
      93             : #include <vcl/waitobj.hxx>
      94             : 
      95             : #include <svx/fmview.hxx>
      96             : #include <editeng/paperinf.hxx>
      97             : #include <editeng/memberids.hrc>
      98             : #include <svx/svxids.hrc>
      99             : #include <svx/svdobj.hxx>
     100             : #include <svx/dataaccessdescriptor.hxx>
     101             : #include <editeng/svxenum.hxx>
     102             : #include <svx/pageitem.hxx>
     103             : #include <editeng/lrspitem.hxx>
     104             : #include <editeng/ulspitem.hxx>
     105             : #include <editeng/sizeitem.hxx>
     106             : #include <sfx2/zoomitem.hxx>
     107             : #include <svx/zoomslideritem.hxx>
     108             : #include <editeng/brushitem.hxx>
     109             : #include <svx/flagsdef.hxx>
     110             : #include <svx/svdpagv.hxx>
     111             : #include <svx/svxdlg.hxx>
     112             : #include <svx/zoom_def.hxx>
     113             : #include <svx/dialogs.hrc>
     114             : 
     115             : #include "DesignView.hxx"
     116             : #include "ModuleHelper.hxx"
     117             : #include "RptObject.hxx"
     118             : #include "RptUndo.hxx"
     119             : #include "uistrings.hrc"
     120             : #include "RptDef.hxx"
     121             : #include "ReportSection.hxx"
     122             : #include "SectionView.hxx"
     123             : #include "UndoActions.hxx"
     124             : #include "dlgpage.hxx"
     125             : #include "RptResId.hrc"
     126             : 
     127             : #include <svl/itempool.hxx>
     128             : #include <svl/itemset.hxx>
     129             : #include <svl/aeitem.hxx>
     130             : #include <svtools/cliplistener.hxx>
     131             : #include <unotools/syslocale.hxx>
     132             : #include <unotools/viewoptions.hxx>
     133             : 
     134             : #include <osl/mutex.hxx>
     135             : #include "PropertyForward.hxx"
     136             : #include "SectionWindow.hxx"
     137             : 
     138             : #include <toolkit/helper/convert.hxx>
     139             : #include "GroupsSorting.hxx"
     140             : #include "PageNumber.hxx"
     141             : #include "UndoEnv.hxx"
     142             : #include "ReportControllerObserver.hxx"
     143             : 
     144             : #include <boost/mem_fn.hpp>
     145             : #include <boost/bind.hpp>
     146             : #include <boost/utility.hpp>
     147             : #include <boost/scoped_ptr.hpp>
     148             : 
     149             : #include <cppuhelper/exc_hlp.hxx>
     150             : #include <unotools/confignode.hxx>
     151             : #include <helpids.hrc>
     152             : 
     153             : #include <ReportControllerObserver.hxx>
     154             : 
     155             : #define MAX_ROWS_FOR_PREVIEW    20
     156             : 
     157             : using namespace ::com::sun::star;
     158             : using namespace uno;
     159             : using namespace io;
     160             : using namespace beans;
     161             : using namespace frame;
     162             : using namespace util;
     163             : using namespace lang;
     164             : using namespace container;
     165             : using namespace sdbcx;
     166             : using namespace sdbc;
     167             : using namespace sdb;
     168             : using namespace ui;
     169             : using namespace ui::dialogs;
     170             : using namespace ::dbtools;
     171             : using namespace ::rptui;
     172             : using namespace ::dbaui;
     173             : using namespace ::comphelper;
     174             : using namespace ::cppu;
     175             : 
     176             : 
     177             : namespace
     178             : {
     179             :     // comparing two PropertyValue instances
     180             :     struct PropertyValueCompare : public ::std::binary_function< beans::PropertyValue, OUString , bool >
     181             :     {
     182           0 :         bool operator() (const beans::PropertyValue& x, const OUString& y) const
     183             :         {
     184           0 :             return x.Name.equals(y);
     185             :         }
     186             :     };
     187             : 
     188           0 :     void lcl_setFontWPU_nothrow(const uno::Reference< report::XReportControlFormat>& _xReportControlFormat,const sal_Int32 _nId)
     189             :     {
     190           0 :         if ( _xReportControlFormat.is() )
     191             :         {
     192             :             try
     193             :             {
     194           0 :                 awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
     195           0 :                 switch(_nId)
     196             :                 {
     197             :                     case SID_ATTR_CHAR_WEIGHT:
     198           0 :                         aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight;
     199           0 :                         break;
     200             :                     case SID_ATTR_CHAR_POSTURE:
     201           0 :                         aFontDescriptor.Slant = static_cast<awt::FontSlant>(static_cast<sal_Int16>(awt::FontSlant_ITALIC) - static_cast<sal_Int16>(aFontDescriptor.Slant));
     202           0 :                         break;
     203             :                     case SID_ATTR_CHAR_UNDERLINE:
     204           0 :                         aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline;
     205           0 :                         break;
     206             :                     default:
     207             :                         OSL_FAIL("Illegal value in default!");
     208           0 :                         break;
     209             :                 }
     210             : 
     211           0 :                 _xReportControlFormat->setFontDescriptor(aFontDescriptor);
     212             :             }
     213           0 :             catch(const beans::UnknownPropertyException&)
     214             :             {
     215             :             }
     216             :         }
     217           0 :     }
     218             : }
     219             : 
     220             : 
     221           0 : static void lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs,
     222             :                                  ODesignView* _pView,
     223             :                                  uno::Reference< awt::XWindow>& _xWindow,
     224             :                                  ::std::vector< uno::Reference< uno::XInterface > >& _rControlsFormats)
     225             : {
     226           0 :     uno::Reference< report::XReportControlFormat> xReportControlFormat;
     227           0 :     if ( aArgs.getLength() )
     228             :     {
     229           0 :         SequenceAsHashMap aMap(aArgs);
     230           0 :         xReportControlFormat = aMap.getUnpackedValueOrDefault(REPORTCONTROLFORMAT,uno::Reference< report::XReportControlFormat>());
     231           0 :         _xWindow = aMap.getUnpackedValueOrDefault(CURRENT_WINDOW,uno::Reference< awt::XWindow>());
     232             :     }
     233             : 
     234           0 :     if ( !xReportControlFormat.is() )
     235             :     {
     236           0 :         _pView->fillControlModelSelection(_rControlsFormats);
     237             :     }
     238             :     else
     239             :     {
     240           0 :         uno::Reference<uno::XInterface> xInterface(xReportControlFormat);
     241           0 :         _rControlsFormats.push_back(xInterface);
     242             :     }
     243             : 
     244           0 :     if ( !_xWindow.is() )
     245           0 :         _xWindow = VCLUnoHelper::GetInterface(_pView);
     246           0 : }
     247             : 
     248           0 : OUString SAL_CALL OReportController::getImplementationName() throw( RuntimeException, std::exception )
     249             : {
     250           0 :     return getImplementationName_Static();
     251             : }
     252             : 
     253             : 
     254           0 : OUString OReportController::getImplementationName_Static() throw( RuntimeException )
     255             : {
     256           0 :     return OUString("com.sun.star.report.comp.ReportDesign");
     257             : }
     258             : 
     259           0 : Sequence< OUString> OReportController::getSupportedServiceNames_Static(void) throw( RuntimeException )
     260             : {
     261           0 :     Sequence< OUString> aSupported(1);
     262           0 :     aSupported[0] = "com.sun.star.sdb.ReportDesign";
     263           0 :     return aSupported;
     264             : }
     265             : 
     266           0 : Sequence< OUString> SAL_CALL OReportController::getSupportedServiceNames() throw(RuntimeException, std::exception)
     267             : {
     268           0 :     return getSupportedServiceNames_Static();
     269             : }
     270             : 
     271           0 : Reference< XInterface > OReportController::create(Reference< XComponentContext > const & xContext)
     272             : {
     273           0 :     return *(new OReportController(xContext));
     274             : }
     275             : 
     276             : #define PROPERTY_ID_ZOOMVALUE   1
     277             : 
     278             : 
     279           0 : OReportController::OReportController(Reference< XComponentContext > const & xContext)
     280             :     :OReportController_BASE(xContext)
     281             :     ,OPropertyStateContainer(OGenericUnoController_Base::rBHelper)
     282           0 :     ,m_aSelectionListeners( getMutex() )
     283             :     ,m_pClipbordNotifier(NULL)
     284             :     ,m_pGroupsFloater(NULL)
     285             :     ,m_sMode("normal")
     286             :     ,m_nSplitPos(-1)
     287             :     ,m_nPageNum(-1)
     288             :     ,m_nSelectionCount(0)
     289             :     ,m_nAspect(0)
     290             :     ,m_nZoomValue(100)
     291             :     ,m_eZoomType(SVX_ZOOM_PERCENT)
     292             :     ,m_bShowRuler(sal_True)
     293             :     ,m_bGridVisible(sal_True)
     294             :     ,m_bGridUse(sal_True)
     295             :     ,m_bShowProperties(sal_True)
     296             :     ,m_bGroupFloaterWasVisible(sal_False)
     297             :     ,m_bHelplinesMove(sal_True)
     298             :     ,m_bChartEnabled(false)
     299             :     ,m_bChartEnabledAsked(false)
     300           0 :     ,m_bInGeneratePreview(false)
     301             : {
     302             :     // new Observer
     303           0 :     m_pReportControllerObserver = new OXReportControllerObserver(*this);
     304           0 :     m_pReportControllerObserver->acquire();
     305             :     registerProperty(OUString("ZoomValue"), PROPERTY_ID_ZOOMVALUE,
     306             :                      beans::PropertyAttribute::BOUND | beans::PropertyAttribute::TRANSIENT,
     307           0 :                      &m_nZoomValue, ::getCppuType(static_cast< sal_Int16*>(0)));
     308             : 
     309           0 : }
     310             : 
     311           0 : OReportController::~OReportController()
     312             : {
     313           0 : }
     314             : 
     315           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2(OReportController,OReportController_BASE,OReportController_Listener)
     316           0 : IMPLEMENT_FORWARD_XINTERFACE2(OReportController,OReportController_BASE,OReportController_Listener)
     317             : 
     318           0 : void OReportController::disposing()
     319             : {
     320             : 
     321           0 :     if ( m_pClipbordNotifier )
     322             :     {
     323           0 :         m_pClipbordNotifier->ClearCallbackLink();
     324           0 :         m_pClipbordNotifier->AddRemoveListener( getView(), false );
     325           0 :         m_pClipbordNotifier->release();
     326           0 :         m_pClipbordNotifier = NULL;
     327             :     }
     328           0 :     if ( m_pGroupsFloater )
     329             :     {
     330           0 :         SvtViewOptions aDlgOpt( E_WINDOW, OUString::number( RID_GROUPS_SORTING ) );
     331           0 :         aDlgOpt.SetWindowState(OStringToOUString(m_pGroupsFloater->GetWindowState(WINDOWSTATE_MASK_ALL), RTL_TEXTENCODING_ASCII_US));
     332             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     333           0 :         ::std::auto_ptr<FloatingWindow> aTemp(m_pGroupsFloater);
     334             :         SAL_WNODEPRECATED_DECLARATIONS_POP
     335           0 :         m_pGroupsFloater = NULL;
     336             :     }
     337             : 
     338             :     try
     339             :     {
     340           0 :         m_xHoldAlive.clear();
     341           0 :         m_xColumns.clear();
     342           0 :         ::comphelper::disposeComponent( m_xRowSet );
     343           0 :         ::comphelper::disposeComponent( m_xRowSetMediator );
     344           0 :         ::comphelper::disposeComponent( m_xFormatter );
     345             :     }
     346           0 :     catch(const uno::Exception&)
     347             :     {
     348             :         OSL_FAIL("Exception caught while disposing row sets.");
     349             :     }
     350           0 :     m_xRowSet.clear();
     351           0 :     m_xRowSetMediator.clear();
     352             : 
     353           0 :     if ( m_xReportDefinition.is() )
     354             :     {
     355             :         try
     356             :         {
     357           0 :             ::boost::shared_ptr<OSectionWindow> pSectionWindow;
     358           0 :             if ( getDesignView() )
     359           0 :                 pSectionWindow = getDesignView()->getMarkedSection();
     360           0 :             if ( pSectionWindow )
     361           0 :                 pSectionWindow->getReportSection().deactivateOle();
     362           0 :             clearUndoManager();
     363           0 :             if ( m_aReportModel )
     364           0 :                 listen(false);
     365           0 :             m_pReportControllerObserver->Clear();
     366           0 :             m_pReportControllerObserver->release();
     367             :         }
     368           0 :         catch(const uno::Exception&)
     369             :         {
     370             :             DBG_UNHANDLED_EXCEPTION();
     371             :         }
     372             :     }
     373             : 
     374             :     {
     375           0 :         EventObject aDisposingEvent( *this );
     376           0 :         m_aSelectionListeners.disposeAndClear( aDisposingEvent );
     377             :     }
     378             : 
     379           0 :     OReportController_BASE::disposing();
     380             : 
     381             : 
     382             :     try
     383             :     {
     384           0 :         m_xReportDefinition.clear();
     385           0 :         m_aReportModel.reset();
     386           0 :         m_xFrameLoader.clear();
     387           0 :         m_xReportEngine.clear();
     388             :     }
     389           0 :     catch(const uno::Exception&)
     390             :     {
     391             :     }
     392           0 :     if ( getDesignView() )
     393           0 :         EndListening( *getDesignView() );
     394           0 :     clearView();
     395           0 : }
     396             : 
     397           0 : FeatureState OReportController::GetState(sal_uInt16 _nId) const
     398             : {
     399           0 :     FeatureState aReturn;
     400             :     // (disabled automatically)
     401           0 :     aReturn.bEnabled = false;
     402             :     // check this first
     403           0 :     if ( !getView() )
     404           0 :         return aReturn;
     405             : 
     406           0 :     switch (_nId)
     407             :     {
     408             :         case SID_RPT_TEXTDOCUMENT:
     409           0 :             aReturn.bEnabled = isEditable();
     410           0 :             aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_TEXT);
     411           0 :             break;
     412             :         case SID_RPT_SPREADSHEET:
     413           0 :             aReturn.bEnabled = isEditable();
     414           0 :             aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET);
     415           0 :             break;
     416             :         case SID_REPORTHEADER_WITHOUT_UNDO:
     417             :         case SID_REPORTFOOTER_WITHOUT_UNDO:
     418             :         case SID_REPORTHEADERFOOTER:
     419             :             {
     420           0 :                 aReturn.bEnabled = isEditable();
     421           0 :                 OUString sText = ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT);
     422           0 :                 aReturn.sTitle = sText;
     423             :             }
     424           0 :             break;
     425             :         case SID_PAGEHEADER_WITHOUT_UNDO:
     426             :         case SID_PAGEFOOTER_WITHOUT_UNDO:
     427             :         case SID_PAGEHEADERFOOTER:
     428             :             {
     429           0 :                 aReturn.bEnabled = isEditable();
     430           0 :                 OUString sText = ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT);
     431           0 :                 aReturn.sTitle = sText;
     432             :             }
     433           0 :             break;
     434             :         case SID_GROUP_APPEND:
     435             :         case SID_GROUP_REMOVE:
     436             :         case SID_GROUPHEADER_WITHOUT_UNDO:
     437             :         case SID_GROUPHEADER:
     438             :         case SID_GROUPFOOTER_WITHOUT_UNDO:
     439             :         case SID_GROUPFOOTER:
     440           0 :             aReturn.bEnabled = isEditable();
     441           0 :             break;
     442             :         case SID_ADD_CONTROL_PAIR:
     443           0 :             aReturn.bEnabled = isEditable();
     444           0 :             break;
     445             :         case SID_REDO:
     446             :         case SID_UNDO:
     447             :             {
     448             :                 size_t ( SfxUndoManager::*retrieveCount )( bool const ) const =
     449           0 :                     ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionCount : &SfxUndoManager::GetRedoActionCount;
     450             : 
     451           0 :                 SfxUndoManager& rUndoManager( getUndoManager() );
     452           0 :                 aReturn.bEnabled = ( rUndoManager.*retrieveCount )( ::svl::IUndoManager::TopLevel ) > 0;
     453           0 :                 if ( aReturn.bEnabled )
     454             :                 {
     455             :                     // TODO: add "Undo/Redo: prefix"
     456             :                     OUString ( SfxUndoManager::*retrieveComment )( size_t, bool const ) const =
     457           0 :                         ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionComment : &SfxUndoManager::GetRedoActionComment;
     458           0 :                     aReturn.sTitle = (rUndoManager.*retrieveComment)( 0, ::svl::IUndoManager::TopLevel );
     459             :                 }
     460             :             }
     461           0 :             break;
     462             :         case SID_OBJECT_RESIZING:
     463             :         case SID_OBJECT_SMALLESTWIDTH:
     464             :         case SID_OBJECT_SMALLESTHEIGHT:
     465             :         case SID_OBJECT_GREATESTWIDTH:
     466             :         case SID_OBJECT_GREATESTHEIGHT:
     467           0 :             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
     468           0 :             if ( aReturn.bEnabled )
     469           0 :                 aReturn.bEnabled = m_nSelectionCount > 1;
     470           0 :             break;
     471             : 
     472             :         case SID_DISTRIBUTION:
     473           0 :             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
     474           0 :             if ( aReturn.bEnabled )
     475             :             {
     476           0 :                 OSectionView* pSectionView = getCurrentSectionView();
     477           0 :                 aReturn.bEnabled = pSectionView && pSectionView->GetMarkedObjectCount() > 2;
     478             :             }
     479           0 :             break;
     480             :         case SID_ARRANGEMENU:
     481             :         case SID_FRAME_DOWN:
     482             :         case SID_FRAME_UP:
     483             :         case SID_FRAME_TO_TOP:
     484             :         case SID_FRAME_TO_BOTTOM:
     485             :         case SID_OBJECT_HEAVEN:
     486             :         case SID_OBJECT_HELL:
     487           0 :             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
     488           0 :             if ( aReturn.bEnabled )
     489             :             {
     490           0 :                 OSectionView* pSectionView = getCurrentSectionView();
     491           0 :                 aReturn.bEnabled = pSectionView && pSectionView->OnlyShapesMarked();
     492           0 :                 if ( aReturn.bEnabled )
     493             :                 {
     494           0 :                     if ( SID_OBJECT_HEAVEN == _nId )
     495           0 :                         aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_FRONT;
     496           0 :                     else if ( SID_OBJECT_HELL == _nId )
     497           0 :                         aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_BACK;
     498             :                 }
     499             :             }
     500           0 :             break;
     501             : 
     502             :         case SID_SECTION_SHRINK:
     503             :         case SID_SECTION_SHRINK_TOP:
     504             :         case SID_SECTION_SHRINK_BOTTOM:
     505             :             {
     506           0 :                 sal_Int32 nCount = 0;
     507           0 :                 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
     508           0 :                 if ( xSection.is() )
     509             :                 {
     510           0 :                     nCount = xSection->getCount();
     511             :                 }
     512           0 :                 aReturn.bEnabled = isEditable() && nCount > 0;
     513             :             }
     514           0 :             break;
     515             :         case SID_OBJECT_ALIGN:
     516             :         case SID_OBJECT_ALIGN_LEFT:
     517             :         case SID_OBJECT_ALIGN_CENTER:
     518             :         case SID_OBJECT_ALIGN_RIGHT:
     519             :         case SID_OBJECT_ALIGN_UP:
     520             :         case SID_OBJECT_ALIGN_MIDDLE:
     521             :         case SID_OBJECT_ALIGN_DOWN:
     522             :         case SID_SECTION_ALIGN:
     523             :         case SID_SECTION_ALIGN_LEFT:
     524             :         case SID_SECTION_ALIGN_CENTER:
     525             :         case SID_SECTION_ALIGN_RIGHT:
     526             :         case SID_SECTION_ALIGN_UP:
     527             :         case SID_SECTION_ALIGN_MIDDLE:
     528             :         case SID_SECTION_ALIGN_DOWN:
     529           0 :             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
     530           0 :             break;
     531             :         case SID_CUT:
     532           0 :             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId);
     533           0 :             break;
     534             :         case SID_COPY:
     535           0 :             aReturn.bEnabled = getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId);
     536           0 :             break;
     537             :         case SID_PASTE:
     538           0 :             aReturn.bEnabled = isEditable()  && !getDesignView()->isHandleEvent(_nId) && getDesignView()->IsPasteAllowed();
     539           0 :             break;
     540             :         case SID_SELECTALL:
     541           0 :             aReturn.bEnabled = !getDesignView()->isHandleEvent(_nId);
     542           0 :             break;
     543             :         case SID_SELECTALL_IN_SECTION:
     544           0 :             aReturn.bEnabled = !getDesignView()->isHandleEvent(_nId);
     545           0 :             if ( aReturn.bEnabled )
     546           0 :                 aReturn.bEnabled = getCurrentSectionView() != NULL;
     547           0 :             break;
     548             :         case SID_ESCAPE:
     549           0 :             aReturn.bEnabled = getDesignView()->GetMode() == RPTUI_INSERT;
     550           0 :             break;
     551             :         case SID_TERMINATE_INPLACEACTIVATION:
     552           0 :             aReturn.bEnabled = true;
     553           0 :             break;
     554             :         case SID_SELECT_ALL_EDITS:
     555             :         case SID_SELECT_ALL_LABELS:
     556           0 :             aReturn.bEnabled = true;
     557           0 :             break;
     558             :         case SID_RPT_NEW_FUNCTION:
     559           0 :             aReturn.bEnabled = isEditable();
     560           0 :             break;
     561             :         case SID_COLLAPSE_SECTION:
     562             :         case SID_EXPAND_SECTION:
     563             :         case SID_NEXT_MARK:
     564             :         case SID_PREV_MARK:
     565           0 :             aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent(_nId);
     566           0 :             break;
     567             :         case SID_SELECT:
     568             :         case SID_SELECT_REPORT:
     569           0 :             aReturn.bEnabled = true;
     570           0 :             break;
     571             :         case SID_EXECUTE_REPORT:
     572           0 :             aReturn.bEnabled = isConnected() && m_xReportDefinition.is();
     573           0 :             break;
     574             :         case SID_DELETE:
     575           0 :             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId);
     576           0 :             if ( aReturn.bEnabled )
     577             :             {
     578           0 :                 ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
     579           0 :                 if ( pSectionWindow )
     580           0 :                     aReturn.bEnabled = !pSectionWindow->getReportSection().isUiActive();
     581             :             }
     582             :             {
     583           0 :                 OUString sText = ModuleRes(RID_STR_DELETE);
     584           0 :                 aReturn.sTitle = sText;
     585             :             }
     586           0 :             break;
     587             :         case SID_GRID_VISIBLE:
     588           0 :             aReturn.bEnabled = isEditable();
     589           0 :             aReturn.bChecked = m_bGridVisible;
     590           0 :             break;
     591             :         case SID_GRID_USE:
     592           0 :             aReturn.bEnabled = isEditable();
     593           0 :             aReturn.bChecked = m_bGridUse;
     594           0 :             break;
     595             :         case SID_HELPLINES_MOVE:
     596           0 :             aReturn.bEnabled = isEditable();
     597           0 :             aReturn.bChecked = m_bHelplinesMove;
     598           0 :             break;
     599             :         case SID_RULER:
     600           0 :             aReturn.bEnabled = isEditable();
     601           0 :             aReturn.bChecked = m_bShowRuler;
     602           0 :             break;
     603             :         case SID_OBJECT_SELECT:
     604           0 :             aReturn.bEnabled = true;
     605           0 :             aReturn.bChecked = getDesignView()->GetMode() == RPTUI_SELECT;
     606           0 :             break;
     607             :         case SID_INSERT_DIAGRAM:
     608           0 :             aReturn.bEnabled = isEditable();
     609           0 :             aReturn.bInvisible = optional< bool >(!m_bChartEnabled);
     610           0 :             aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_OLE2;
     611           0 :             break;
     612             :         case SID_FM_FIXEDTEXT:
     613           0 :             aReturn.bEnabled = isEditable();
     614           0 :             aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FIXEDTEXT;
     615           0 :             break;
     616             :         case SID_INSERT_HFIXEDLINE:
     617           0 :             aReturn.bEnabled = isEditable();
     618           0 :             aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_HFIXEDLINE;
     619           0 :             break;
     620             :         case SID_INSERT_VFIXEDLINE:
     621           0 :             aReturn.bEnabled = isEditable();
     622           0 :             aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_VFIXEDLINE;
     623           0 :             break;
     624             :         case SID_FM_EDIT:
     625           0 :             aReturn.bEnabled = isEditable();
     626           0 :             aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FORMATTEDFIELD;
     627           0 :             break;
     628             :         case SID_FM_IMAGECONTROL:
     629           0 :             aReturn.bEnabled = isEditable();
     630           0 :             aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_IMAGECONTROL;
     631           0 :             break;
     632             :         case SID_DRAWTBX_CS_BASIC:
     633             :         case SID_DRAWTBX_CS_BASIC1:
     634             :         case SID_DRAWTBX_CS_BASIC2:
     635             :         case SID_DRAWTBX_CS_BASIC3:
     636             :         case SID_DRAWTBX_CS_BASIC4:
     637             :         case SID_DRAWTBX_CS_BASIC5:
     638             :         case SID_DRAWTBX_CS_BASIC6:
     639             :         case SID_DRAWTBX_CS_BASIC7:
     640             :         case SID_DRAWTBX_CS_BASIC8:
     641             :         case SID_DRAWTBX_CS_BASIC9:
     642             :         case SID_DRAWTBX_CS_BASIC10:
     643             :         case SID_DRAWTBX_CS_BASIC11:
     644             :         case SID_DRAWTBX_CS_BASIC12:
     645             :         case SID_DRAWTBX_CS_BASIC13:
     646             :         case SID_DRAWTBX_CS_BASIC14:
     647             :         case SID_DRAWTBX_CS_BASIC15:
     648             :         case SID_DRAWTBX_CS_BASIC16:
     649             :         case SID_DRAWTBX_CS_BASIC17:
     650             :         case SID_DRAWTBX_CS_BASIC18:
     651             :         case SID_DRAWTBX_CS_BASIC19:
     652             :         case SID_DRAWTBX_CS_BASIC20:
     653             :         case SID_DRAWTBX_CS_BASIC21:
     654             :         case SID_DRAWTBX_CS_BASIC22:
     655           0 :             impl_fillCustomShapeState_nothrow("diamond",aReturn);
     656           0 :             break;
     657             :         case SID_DRAWTBX_CS_SYMBOL:
     658             :         case SID_DRAWTBX_CS_SYMBOL1:
     659             :         case SID_DRAWTBX_CS_SYMBOL2:
     660             :         case SID_DRAWTBX_CS_SYMBOL3:
     661             :         case SID_DRAWTBX_CS_SYMBOL4:
     662             :         case SID_DRAWTBX_CS_SYMBOL5:
     663             :         case SID_DRAWTBX_CS_SYMBOL6:
     664             :         case SID_DRAWTBX_CS_SYMBOL7:
     665             :         case SID_DRAWTBX_CS_SYMBOL8:
     666             :         case SID_DRAWTBX_CS_SYMBOL9:
     667             :         case SID_DRAWTBX_CS_SYMBOL10:
     668             :         case SID_DRAWTBX_CS_SYMBOL11:
     669             :         case SID_DRAWTBX_CS_SYMBOL12:
     670             :         case SID_DRAWTBX_CS_SYMBOL13:
     671             :         case SID_DRAWTBX_CS_SYMBOL14:
     672             :         case SID_DRAWTBX_CS_SYMBOL15:
     673             :         case SID_DRAWTBX_CS_SYMBOL16:
     674             :         case SID_DRAWTBX_CS_SYMBOL17:
     675             :         case SID_DRAWTBX_CS_SYMBOL18:
     676           0 :             impl_fillCustomShapeState_nothrow("smiley",aReturn);
     677           0 :             break;
     678             :         case SID_DRAWTBX_CS_ARROW:
     679             :         case SID_DRAWTBX_CS_ARROW1:
     680             :         case SID_DRAWTBX_CS_ARROW2:
     681             :         case SID_DRAWTBX_CS_ARROW3:
     682             :         case SID_DRAWTBX_CS_ARROW4:
     683             :         case SID_DRAWTBX_CS_ARROW5:
     684             :         case SID_DRAWTBX_CS_ARROW6:
     685             :         case SID_DRAWTBX_CS_ARROW7:
     686             :         case SID_DRAWTBX_CS_ARROW8:
     687             :         case SID_DRAWTBX_CS_ARROW9:
     688             :         case SID_DRAWTBX_CS_ARROW10:
     689             :         case SID_DRAWTBX_CS_ARROW11:
     690             :         case SID_DRAWTBX_CS_ARROW12:
     691             :         case SID_DRAWTBX_CS_ARROW13:
     692             :         case SID_DRAWTBX_CS_ARROW14:
     693             :         case SID_DRAWTBX_CS_ARROW15:
     694             :         case SID_DRAWTBX_CS_ARROW16:
     695             :         case SID_DRAWTBX_CS_ARROW17:
     696             :         case SID_DRAWTBX_CS_ARROW18:
     697             :         case SID_DRAWTBX_CS_ARROW19:
     698             :         case SID_DRAWTBX_CS_ARROW20:
     699             :         case SID_DRAWTBX_CS_ARROW21:
     700             :         case SID_DRAWTBX_CS_ARROW22:
     701             :         case SID_DRAWTBX_CS_ARROW23:
     702             :         case SID_DRAWTBX_CS_ARROW24:
     703             :         case SID_DRAWTBX_CS_ARROW25:
     704             :         case SID_DRAWTBX_CS_ARROW26:
     705           0 :             impl_fillCustomShapeState_nothrow("left-right-arrow",aReturn);
     706           0 :             break;
     707             :         case SID_DRAWTBX_CS_STAR:
     708             :         case SID_DRAWTBX_CS_STAR1:
     709             :         case SID_DRAWTBX_CS_STAR2:
     710             :         case SID_DRAWTBX_CS_STAR3:
     711             :         case SID_DRAWTBX_CS_STAR4:
     712             :         case SID_DRAWTBX_CS_STAR5:
     713             :         case SID_DRAWTBX_CS_STAR6:
     714             :         case SID_DRAWTBX_CS_STAR7:
     715             :         case SID_DRAWTBX_CS_STAR8:
     716             :         case SID_DRAWTBX_CS_STAR9:
     717             :         case SID_DRAWTBX_CS_STAR10:
     718             :         case SID_DRAWTBX_CS_STAR11:
     719             :         case SID_DRAWTBX_CS_STAR12:
     720           0 :             impl_fillCustomShapeState_nothrow("star5",aReturn);
     721           0 :             break;
     722             :         case SID_DRAWTBX_CS_FLOWCHART:
     723             :         case SID_DRAWTBX_CS_FLOWCHART1:
     724             :         case SID_DRAWTBX_CS_FLOWCHART2:
     725             :         case SID_DRAWTBX_CS_FLOWCHART3:
     726             :         case SID_DRAWTBX_CS_FLOWCHART4:
     727             :         case SID_DRAWTBX_CS_FLOWCHART5:
     728             :         case SID_DRAWTBX_CS_FLOWCHART6:
     729             :         case SID_DRAWTBX_CS_FLOWCHART7:
     730             :         case SID_DRAWTBX_CS_FLOWCHART8:
     731             :         case SID_DRAWTBX_CS_FLOWCHART9:
     732             :         case SID_DRAWTBX_CS_FLOWCHART10:
     733             :         case SID_DRAWTBX_CS_FLOWCHART11:
     734             :         case SID_DRAWTBX_CS_FLOWCHART12:
     735             :         case SID_DRAWTBX_CS_FLOWCHART13:
     736             :         case SID_DRAWTBX_CS_FLOWCHART14:
     737             :         case SID_DRAWTBX_CS_FLOWCHART15:
     738             :         case SID_DRAWTBX_CS_FLOWCHART16:
     739             :         case SID_DRAWTBX_CS_FLOWCHART17:
     740             :         case SID_DRAWTBX_CS_FLOWCHART18:
     741             :         case SID_DRAWTBX_CS_FLOWCHART19:
     742             :         case SID_DRAWTBX_CS_FLOWCHART20:
     743             :         case SID_DRAWTBX_CS_FLOWCHART21:
     744             :         case SID_DRAWTBX_CS_FLOWCHART22:
     745             :         case SID_DRAWTBX_CS_FLOWCHART23:
     746             :         case SID_DRAWTBX_CS_FLOWCHART24:
     747             :         case SID_DRAWTBX_CS_FLOWCHART25:
     748             :         case SID_DRAWTBX_CS_FLOWCHART26:
     749             :         case SID_DRAWTBX_CS_FLOWCHART27:
     750             :         case SID_DRAWTBX_CS_FLOWCHART28:
     751           0 :             impl_fillCustomShapeState_nothrow("flowchart-internal-storage",aReturn);
     752           0 :             break;
     753             :         case SID_DRAWTBX_CS_CALLOUT:
     754             :         case SID_DRAWTBX_CS_CALLOUT1:
     755             :         case SID_DRAWTBX_CS_CALLOUT2:
     756             :         case SID_DRAWTBX_CS_CALLOUT3:
     757             :         case SID_DRAWTBX_CS_CALLOUT4:
     758             :         case SID_DRAWTBX_CS_CALLOUT5:
     759             :         case SID_DRAWTBX_CS_CALLOUT6:
     760             :         case SID_DRAWTBX_CS_CALLOUT7:
     761           0 :             impl_fillCustomShapeState_nothrow("round-rectangular-callout",aReturn);
     762           0 :             break;
     763             :         case SID_RPT_SHOWREPORTEXPLORER:
     764           0 :             aReturn.bEnabled = m_xReportDefinition.is();
     765           0 :             aReturn.bChecked = getDesignView() && getDesignView()->isReportExplorerVisible();
     766           0 :             break;
     767             :         case SID_FM_ADD_FIELD:
     768           0 :             aReturn.bEnabled = isConnected() && isEditable() && m_xReportDefinition.is()
     769           0 :                 && !m_xReportDefinition->getCommand().isEmpty();
     770           0 :             aReturn.bChecked = getDesignView() && getDesignView()->isAddFieldVisible();
     771           0 :             break;
     772             :         case SID_SHOW_PROPERTYBROWSER:
     773           0 :             aReturn.bEnabled = true;
     774           0 :             aReturn.bChecked = m_bShowProperties;
     775           0 :             break;
     776             :         case SID_PROPERTYBROWSER_LAST_PAGE:
     777           0 :             aReturn.bEnabled = true;
     778           0 :             aReturn.aValue <<= m_sLastActivePage;
     779           0 :             break;
     780             :         case SID_SPLIT_POSITION:
     781           0 :             aReturn.bEnabled = true;
     782           0 :             aReturn.aValue <<= getSplitPos();
     783           0 :             break;
     784             :         case SID_SAVEDOC:
     785           0 :             aReturn.bEnabled = impl_isModified() && isEditable();
     786           0 :             break;
     787             :         case SID_SAVEASDOC:
     788           0 :             aReturn.bEnabled = isConnected() && isEditable();
     789           0 :             break;
     790             :         case SID_SAVEACOPY:
     791           0 :             aReturn.bEnabled = isConnected() && isEditable();
     792           0 :             break;
     793             :         case SID_EDITDOC:
     794           0 :             aReturn.bChecked = isEditable();
     795           0 :             break;
     796             :         case SID_PAGEDIALOG:
     797           0 :             aReturn.bEnabled = isEditable();
     798           0 :             break;
     799             :         case SID_BACKGROUND_COLOR:
     800           0 :             impl_fillState_nothrow(PROPERTY_CONTROLBACKGROUND,aReturn);
     801           0 :             break;
     802             :         case SID_ATTR_CHAR_COLOR_BACKGROUND:
     803           0 :             aReturn.bEnabled = isEditable();
     804             :             {
     805           0 :                 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
     806           0 :                 if ( xSection.is() )
     807             :                     try
     808             :                     {
     809           0 :                         aReturn.aValue <<= xSection->getBackColor();
     810           0 :                         const uno::Reference< report::XReportControlModel> xControlModel(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
     811           0 :                         aReturn.bEnabled = !xControlModel.is();
     812             :                     }
     813           0 :                     catch(const beans::UnknownPropertyException&)
     814             :                     {
     815             :                     }
     816             :                 else
     817           0 :                     aReturn.bEnabled = false;
     818             :             }
     819           0 :             break;
     820             :         case SID_SORTINGANDGROUPING:
     821           0 :             aReturn.bEnabled = true;
     822           0 :             aReturn.bChecked = m_pGroupsFloater && m_pGroupsFloater->IsVisible();
     823           0 :             break;
     824             :         case SID_ATTR_CHAR_WEIGHT:
     825             :         case SID_ATTR_CHAR_POSTURE:
     826             :         case SID_ATTR_CHAR_UNDERLINE:
     827           0 :             impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
     828           0 :             if ( aReturn.bEnabled )
     829             :             {
     830           0 :                 awt::FontDescriptor aFontDescriptor;
     831           0 :                 aReturn.aValue >>= aFontDescriptor;
     832           0 :                 aReturn.aValue.clear();
     833             : 
     834           0 :                 switch(_nId)
     835             :                 {
     836             :                     case SID_ATTR_CHAR_WEIGHT:
     837           0 :                         aReturn.bChecked = awt::FontWeight::BOLD == aFontDescriptor.Weight;
     838           0 :                         break;
     839             :                     case SID_ATTR_CHAR_POSTURE:
     840           0 :                         aReturn.bChecked = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
     841           0 :                         break;
     842             :                     case SID_ATTR_CHAR_UNDERLINE:
     843           0 :                         aReturn.bChecked = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
     844           0 :                         break;
     845             :                     default:
     846             :                         ;
     847           0 :                     }
     848             :             }
     849           0 :             break;
     850             :         case SID_ATTR_CHAR_COLOR:
     851             :         case SID_ATTR_CHAR_COLOR2:
     852           0 :             impl_fillState_nothrow(PROPERTY_CHARCOLOR,aReturn);
     853           0 :             break;
     854             :         case SID_ATTR_CHAR_FONT:
     855           0 :             impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
     856           0 :             break;
     857             :         case SID_ATTR_CHAR_FONTHEIGHT:
     858           0 :             impl_fillState_nothrow(PROPERTY_CHARHEIGHT,aReturn);
     859           0 :             if ( aReturn.aValue.hasValue() )
     860             :             {
     861           0 :                 frame::status::FontHeight aFontHeight;
     862           0 :                 aReturn.aValue >>= aFontHeight.Height;
     863           0 :                 aReturn.aValue <<= aFontHeight; // another type is needed here, so
     864             :             }
     865           0 :             break;
     866             :         case SID_ATTR_PARA_ADJUST_LEFT:
     867             :         case SID_ATTR_PARA_ADJUST_CENTER:
     868             :         case SID_ATTR_PARA_ADJUST_RIGHT:
     869             :         case SID_ATTR_PARA_ADJUST_BLOCK:
     870           0 :             impl_fillState_nothrow(PROPERTY_PARAADJUST,aReturn);
     871           0 :             if ( aReturn.bEnabled )
     872             :             {
     873           0 :                 ::sal_Int16 nParaAdjust = 0;
     874           0 :                 if ( aReturn.aValue >>= nParaAdjust )
     875             :                 {
     876           0 :                     switch(nParaAdjust)
     877             :                     {
     878             :                         case style::ParagraphAdjust_LEFT:
     879           0 :                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_LEFT;
     880           0 :                             break;
     881             :                         case style::ParagraphAdjust_RIGHT:
     882           0 :                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_RIGHT;
     883           0 :                             break;
     884             :                         case style::ParagraphAdjust_BLOCK:
     885             :                         case style::ParagraphAdjust_STRETCH:
     886           0 :                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_BLOCK;
     887           0 :                             break;
     888             :                         case style::ParagraphAdjust_CENTER:
     889           0 :                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_CENTER;
     890           0 :                             break;
     891             :                     }
     892             :                 }
     893           0 :                 aReturn.aValue.clear();
     894             :             }
     895           0 :             break;
     896             : 
     897             :         case SID_INSERT_GRAPHIC:
     898           0 :             aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
     899           0 :             break;
     900             :         case SID_CHAR_DLG:
     901             :         case SID_SETCONTROLDEFAULTS:
     902           0 :             aReturn.bEnabled = m_xReportDefinition.is() && isEditable();
     903           0 :             if ( aReturn.bEnabled )
     904             :             {
     905           0 :                 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
     906           0 :                 getDesignView()->fillControlModelSelection(aSelection);
     907           0 :                 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
     908           0 :                 for(; aIter != aSelection.end()
     909           0 :                     && !uno::Reference< report::XFixedLine >(*aIter,uno::UNO_QUERY).is()
     910           0 :                     && !uno::Reference< report::XImageControl >(*aIter,uno::UNO_QUERY).is()
     911           0 :                     && uno::Reference< report::XReportControlFormat >(*aIter,uno::UNO_QUERY).is() ;++aIter)
     912             :                     ;
     913           0 :                 aReturn.bEnabled = !aSelection.empty() && aIter == aSelection.end();
     914             :             }
     915           0 :             break;
     916             :         case SID_CONDITIONALFORMATTING:
     917             :             {
     918           0 :                 const uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
     919           0 :                 aReturn.bEnabled = xFormattedField.is();
     920             :             }
     921           0 :             break;
     922             :         case SID_INSERT_FLD_PGNUMBER:
     923             :         case SID_DATETIME:
     924           0 :             aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
     925           0 :             break;
     926             :         case SID_EXPORTDOC:
     927             :         case SID_EXPORTDOCASPDF:
     928           0 :             aReturn.bEnabled = m_xReportDefinition.is();
     929           0 :             break;
     930             :         case SID_PRINTPREVIEW:
     931           0 :             aReturn.bEnabled = false;
     932           0 :             break;
     933             :         case SID_ATTR_ZOOM:
     934           0 :             aReturn.bEnabled = true;
     935             :             {
     936           0 :                 SvxZoomItem aZoom(m_eZoomType,m_nZoomValue);
     937           0 :                 aZoom.SetValueSet(SVX_ZOOM_ENABLE_50|SVX_ZOOM_ENABLE_75|SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_200);
     938           0 :                 aZoom.QueryValue(aReturn.aValue);
     939             :             }
     940           0 :             break;
     941             :         case SID_ATTR_ZOOMSLIDER:
     942           0 :             aReturn.bEnabled = true;
     943             :             {
     944           0 :                 SvxZoomSliderItem aZoomSlider(m_nZoomValue,20,400);
     945           0 :                 aZoomSlider.AddSnappingPoint(50);
     946           0 :                 aZoomSlider.AddSnappingPoint(75);
     947           0 :                 aZoomSlider.AddSnappingPoint(100);
     948           0 :                 aZoomSlider.AddSnappingPoint(200);
     949           0 :                 aZoomSlider.QueryValue(aReturn.aValue);
     950             :             }
     951           0 :             break;
     952             :         default:
     953           0 :             aReturn = OReportController_BASE::GetState(_nId);
     954             :     }
     955           0 :     return aReturn;
     956             : }
     957             : 
     958             : 
     959             : namespace
     960             : {
     961             :     /** extracts a background color from a dispatched SID_BACKGROUND_COLOR call
     962             : 
     963             :         The dispatch might originate from either the toolbar, or the conditional
     964             :         formatting dialog. In both cases, argument formats are different.
     965             :     */
     966           0 :     util::Color lcl_extractBackgroundColor( const Sequence< PropertyValue >& _rDispatchArgs )
     967             :     {
     968           0 :         util::Color aColor( COL_TRANSPARENT );
     969           0 :         if ( _rDispatchArgs.getLength() == 1 )
     970             :         {
     971           0 :             OSL_VERIFY( _rDispatchArgs[0].Value >>= aColor );
     972             :         }
     973             :         else
     974             :         {
     975           0 :             SequenceAsHashMap aMap( _rDispatchArgs );
     976           0 :             aColor = aMap.getUnpackedValueOrDefault( PROPERTY_FONTCOLOR, aColor );
     977             :         }
     978           0 :         return aColor;
     979             :     }
     980             : }
     981             : 
     982             : 
     983           0 : void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
     984             : {
     985           0 :     SolarMutexGuard aSolarGuard;
     986           0 :     ::osl::MutexGuard aGuard( getMutex() );
     987             : 
     988           0 :     sal_Bool bForceBroadcast = sal_False;
     989           0 :     switch(_nId)
     990             :     {
     991             :         case SID_RPT_TEXTDOCUMENT:
     992           0 :             if ( m_xReportDefinition.is() )
     993           0 :                 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_TEXT );
     994           0 :             break;
     995             :         case SID_RPT_SPREADSHEET:
     996           0 :             if (m_xReportDefinition.is() )
     997           0 :                 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET );
     998           0 :             break;
     999             :         case SID_REPORTHEADER_WITHOUT_UNDO:
    1000             :         case SID_REPORTFOOTER_WITHOUT_UNDO:
    1001             :         case SID_REPORTHEADERFOOTER:
    1002           0 :             switchReportSection(_nId);
    1003           0 :             break;
    1004             :         case SID_PAGEHEADER_WITHOUT_UNDO:
    1005             :         case SID_PAGEFOOTER_WITHOUT_UNDO:
    1006             :         case SID_PAGEHEADERFOOTER:
    1007           0 :             switchPageSection(_nId);
    1008           0 :             break;
    1009             :         case SID_GROUP_APPEND:
    1010             :         case SID_GROUP_REMOVE:
    1011           0 :             modifyGroup(_nId == SID_GROUP_APPEND,aArgs);
    1012           0 :             break;
    1013             :         case SID_GROUPHEADER_WITHOUT_UNDO:
    1014             :         case SID_GROUPHEADER:
    1015           0 :             createGroupSection(SID_GROUPHEADER == _nId,true,aArgs);
    1016           0 :             break;
    1017             :         case SID_GROUPFOOTER_WITHOUT_UNDO:
    1018             :         case SID_GROUPFOOTER:
    1019           0 :             createGroupSection(SID_GROUPFOOTER == _nId,false,aArgs);
    1020           0 :             break;
    1021             :         case SID_ADD_CONTROL_PAIR:
    1022           0 :             addPairControls(aArgs);
    1023           0 :             break;
    1024             :         case SID_REDO:
    1025             :         case SID_UNDO:
    1026             :         {
    1027           0 :             const OXUndoEnvironment::OUndoMode aLock( m_aReportModel->GetUndoEnv() );
    1028             :             bool ( SfxUndoManager::*doXDo )() =
    1029           0 :                 ( _nId == SID_UNDO ) ? &SfxUndoManager::Undo : &SfxUndoManager::Redo;
    1030             : 
    1031           0 :             SfxUndoManager& rUndoManager( getUndoManager() );
    1032           0 :             (rUndoManager.*doXDo)();
    1033           0 :             InvalidateAll();
    1034           0 :             updateFloater();
    1035             :         }
    1036           0 :         break;
    1037             :         case SID_CUT:
    1038           0 :             executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Cut));
    1039           0 :             break;
    1040             :         case SID_COPY:
    1041           0 :             getDesignView()->Copy();
    1042           0 :             break;
    1043             :         case SID_PASTE:
    1044           0 :             executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fun(&ODesignView::Paste));
    1045           0 :             break;
    1046             : 
    1047             :         case SID_FRAME_TO_TOP:
    1048             :         case SID_FRAME_DOWN:
    1049             :         case SID_FRAME_UP:
    1050             :         case SID_FRAME_TO_BOTTOM:
    1051             :         case SID_OBJECT_HEAVEN:
    1052             :         case SID_OBJECT_HELL:
    1053           0 :             changeZOrder(_nId);
    1054           0 :             break;
    1055             :         case SID_DISTRIBUTION:
    1056             :             {
    1057           0 :                 OSectionView* pSectionView = getCurrentSectionView();
    1058           0 :                 if ( pSectionView )
    1059           0 :                     pSectionView->DistributeMarkedObjects();
    1060             :             }
    1061           0 :             break;
    1062             :         case SID_OBJECT_SMALLESTWIDTH:
    1063           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_SMALLEST);
    1064           0 :             break;
    1065             :         case SID_OBJECT_SMALLESTHEIGHT:
    1066           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_SMALLEST);
    1067           0 :             break;
    1068             :         case SID_OBJECT_GREATESTWIDTH:
    1069           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_GREATEST);
    1070           0 :             break;
    1071             :         case SID_OBJECT_GREATESTHEIGHT:
    1072           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_GREATEST);
    1073           0 :             break;
    1074             :         case SID_SECTION_ALIGN_LEFT:
    1075             :         case SID_OBJECT_ALIGN_LEFT:
    1076           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::LEFT,SID_SECTION_ALIGN_LEFT == _nId);
    1077           0 :             break;
    1078             :         case SID_SECTION_ALIGN_CENTER:
    1079             :         case SID_OBJECT_ALIGN_CENTER:
    1080           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_HORIZONTAL,SID_SECTION_ALIGN_CENTER == _nId);
    1081           0 :             break;
    1082             :         case SID_SECTION_ALIGN_RIGHT:
    1083             :         case SID_OBJECT_ALIGN_RIGHT:
    1084           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::RIGHT,SID_SECTION_ALIGN_RIGHT == _nId);
    1085           0 :             break;
    1086             :         case SID_SECTION_ALIGN_UP:
    1087             :         case SID_OBJECT_ALIGN_UP:
    1088           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::TOP,SID_SECTION_ALIGN_UP == _nId);
    1089           0 :             break;
    1090             :         case SID_SECTION_ALIGN_MIDDLE:
    1091             :         case SID_OBJECT_ALIGN_MIDDLE:
    1092           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_VERTICAL,SID_SECTION_ALIGN_MIDDLE == _nId);
    1093           0 :             break;
    1094             :         case SID_SECTION_ALIGN_DOWN:
    1095             :         case SID_OBJECT_ALIGN_DOWN:
    1096           0 :             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::BOTTOM,SID_SECTION_ALIGN_DOWN == _nId);
    1097           0 :             break;
    1098             : 
    1099             :         case SID_SECTION_SHRINK_BOTTOM:
    1100             :         case SID_SECTION_SHRINK_TOP:
    1101             :         case SID_SECTION_SHRINK:
    1102             :             {
    1103           0 :                 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
    1104           0 :                 shrinkSection(RID_STR_UNDO_SHRINK, xSection, _nId);
    1105             :             }
    1106           0 :             break;
    1107             : 
    1108             :         case SID_SELECTALL:
    1109           0 :             getDesignView()->SelectAll(OBJ_NONE);
    1110           0 :             break;
    1111             :         case SID_SELECTALL_IN_SECTION:
    1112             :             {
    1113           0 :                 OSectionView* pSectionView = getCurrentSectionView();
    1114           0 :                 if ( pSectionView )
    1115           0 :                     pSectionView->MarkAll();
    1116             :             }
    1117           0 :             break;
    1118             :         case SID_ESCAPE:
    1119           0 :             getDesignView()->SetMode(RPTUI_SELECT);
    1120           0 :             InvalidateFeature( SID_OBJECT_SELECT );
    1121           0 :             break;
    1122             :         case SID_SELECT_ALL_EDITS:
    1123           0 :             getDesignView()->SelectAll(OBJ_DLG_FORMATTEDFIELD);
    1124           0 :             break;
    1125             :         case SID_SELECT_ALL_LABELS:
    1126           0 :             getDesignView()->SelectAll(OBJ_DLG_FIXEDTEXT);
    1127           0 :             break;
    1128             :         case SID_TERMINATE_INPLACEACTIVATION:
    1129             :             {
    1130           0 :                 ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection();
    1131           0 :                 if ( pSection )
    1132           0 :                     pSection->getReportSection().deactivateOle();
    1133             :             }
    1134           0 :             break;
    1135             :         case SID_SELECT:
    1136           0 :             if ( aArgs.getLength() == 1 )
    1137           0 :                 select(aArgs[0].Value);
    1138           0 :             break;
    1139             :         case SID_SELECT_REPORT:
    1140           0 :             select(uno::makeAny(m_xReportDefinition));
    1141           0 :             break;
    1142             :         case SID_EXECUTE_REPORT:
    1143           0 :             getView()->PostUserEvent(LINK(this, OReportController,OnExecuteReport));
    1144           0 :             break;
    1145             :         case SID_RPT_NEW_FUNCTION:
    1146           0 :             createNewFunction(aArgs[0].Value);
    1147           0 :             break;
    1148             :         case SID_COLLAPSE_SECTION:
    1149           0 :             collapseSection(true);
    1150           0 :             break;
    1151             :         case SID_EXPAND_SECTION:
    1152           0 :             collapseSection(false);
    1153           0 :             break;
    1154             :         case SID_NEXT_MARK:
    1155           0 :             markSection(true);
    1156           0 :             break;
    1157             :         case SID_PREV_MARK:
    1158           0 :             markSection(false);
    1159           0 :             break;
    1160             :         case SID_DELETE:
    1161           0 :             if ( aArgs.getLength() == 1 )
    1162             :             {
    1163           0 :                 uno::Reference< report::XFunction> xFunction;
    1164           0 :                 aArgs[0].Value >>= xFunction;
    1165           0 :                 if ( xFunction.is() )
    1166             :                 {
    1167           0 :                     uno::Reference< report::XFunctions> xFunctions(xFunction->getParent(),uno::UNO_QUERY_THROW);
    1168           0 :                     sal_Int32 nIndex = getPositionInIndexAccess(xFunctions.get(),xFunction);
    1169           0 :                     const OUString sUndoAction = ModuleRes(RID_STR_UNDO_REMOVE_FUNCTION);
    1170           0 :                     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    1171           0 :                     xFunctions->removeByIndex(nIndex);
    1172           0 :                     select(uno::makeAny(xFunctions->getParent()));
    1173           0 :                     InvalidateFeature( SID_SAVEDOC );
    1174           0 :                     InvalidateFeature( SID_UNDO );
    1175           0 :                 }
    1176             :             }
    1177             :             else
    1178           0 :                 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Delete));
    1179           0 :             break;
    1180             :         case SID_GRID_USE:
    1181           0 :             getDesignView()->setGridSnap(m_bGridUse = !m_bGridUse);
    1182           0 :             break;
    1183             :         case SID_HELPLINES_MOVE:
    1184           0 :             getDesignView()->setDragStripes(m_bHelplinesMove = !m_bHelplinesMove);
    1185           0 :             break;
    1186             :         case SID_GRID_VISIBLE:
    1187           0 :             getDesignView()->toggleGrid(m_bGridVisible = !m_bGridVisible);
    1188           0 :             break;
    1189             :         case SID_RULER:
    1190           0 :             getDesignView()->showRuler(m_bShowRuler = !m_bShowRuler);
    1191           0 :             break;
    1192             :         case SID_OBJECT_SELECT:
    1193           0 :             getDesignView()->SetMode(RPTUI_SELECT);
    1194           0 :             InvalidateAll();
    1195           0 :             break;
    1196             :         case SID_INSERT_DIAGRAM:
    1197           0 :             getDesignView()->SetMode( RPTUI_INSERT );
    1198           0 :             getDesignView()->SetInsertObj( OBJ_OLE2);
    1199           0 :             createDefaultControl(aArgs);
    1200           0 :             InvalidateAll();
    1201           0 :             break;
    1202             :         case SID_FM_FIXEDTEXT:
    1203           0 :             getDesignView()->SetMode( RPTUI_INSERT );
    1204           0 :             getDesignView()->SetInsertObj( OBJ_DLG_FIXEDTEXT );
    1205           0 :             createDefaultControl(aArgs);
    1206           0 :             InvalidateAll();
    1207           0 :             break;
    1208             :         case SID_INSERT_HFIXEDLINE:
    1209           0 :             getDesignView()->SetMode( RPTUI_INSERT );
    1210           0 :             getDesignView()->SetInsertObj( OBJ_DLG_HFIXEDLINE );
    1211           0 :             createDefaultControl(aArgs);
    1212           0 :             InvalidateAll();
    1213           0 :             break;
    1214             :         case SID_INSERT_VFIXEDLINE:
    1215           0 :             getDesignView()->SetMode( RPTUI_INSERT );
    1216           0 :             getDesignView()->SetInsertObj( OBJ_DLG_VFIXEDLINE );
    1217           0 :             createDefaultControl(aArgs);
    1218           0 :             InvalidateAll();
    1219           0 :             break;
    1220             :         case SID_FM_EDIT:
    1221           0 :             getDesignView()->SetMode( RPTUI_INSERT );
    1222           0 :             getDesignView()->SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
    1223           0 :             createDefaultControl(aArgs);
    1224           0 :             InvalidateAll();
    1225           0 :             break;
    1226             :         case SID_FM_IMAGECONTROL:
    1227           0 :             getDesignView()->SetMode( RPTUI_INSERT );
    1228           0 :             getDesignView()->SetInsertObj( OBJ_DLG_IMAGECONTROL );
    1229           0 :             createDefaultControl(aArgs);
    1230           0 :             InvalidateAll();
    1231           0 :             break;
    1232             :         case SID_DRAWTBX_CS_BASIC:
    1233             :         case SID_DRAWTBX_CS_BASIC1:
    1234             :         case SID_DRAWTBX_CS_BASIC2:
    1235             :         case SID_DRAWTBX_CS_BASIC3:
    1236             :         case SID_DRAWTBX_CS_BASIC4:
    1237             :         case SID_DRAWTBX_CS_BASIC5:
    1238             :         case SID_DRAWTBX_CS_BASIC6:
    1239             :         case SID_DRAWTBX_CS_BASIC7:
    1240             :         case SID_DRAWTBX_CS_BASIC8:
    1241             :         case SID_DRAWTBX_CS_BASIC9:
    1242             :         case SID_DRAWTBX_CS_BASIC10:
    1243             :         case SID_DRAWTBX_CS_BASIC11:
    1244             :         case SID_DRAWTBX_CS_BASIC12:
    1245             :         case SID_DRAWTBX_CS_BASIC13:
    1246             :         case SID_DRAWTBX_CS_BASIC14:
    1247             :         case SID_DRAWTBX_CS_BASIC15:
    1248             :         case SID_DRAWTBX_CS_BASIC16:
    1249             :         case SID_DRAWTBX_CS_BASIC17:
    1250             :         case SID_DRAWTBX_CS_BASIC18:
    1251             :         case SID_DRAWTBX_CS_BASIC19:
    1252             :         case SID_DRAWTBX_CS_BASIC20:
    1253             :         case SID_DRAWTBX_CS_BASIC21:
    1254             :         case SID_DRAWTBX_CS_BASIC22:
    1255             :         case SID_DRAWTBX_CS_SYMBOL1:
    1256             :         case SID_DRAWTBX_CS_SYMBOL2:
    1257             :         case SID_DRAWTBX_CS_SYMBOL3:
    1258             :         case SID_DRAWTBX_CS_SYMBOL4:
    1259             :         case SID_DRAWTBX_CS_SYMBOL5:
    1260             :         case SID_DRAWTBX_CS_SYMBOL6:
    1261             :         case SID_DRAWTBX_CS_SYMBOL7:
    1262             :         case SID_DRAWTBX_CS_SYMBOL8:
    1263             :         case SID_DRAWTBX_CS_SYMBOL9:
    1264             :         case SID_DRAWTBX_CS_SYMBOL10:
    1265             :         case SID_DRAWTBX_CS_SYMBOL11:
    1266             :         case SID_DRAWTBX_CS_SYMBOL12:
    1267             :         case SID_DRAWTBX_CS_SYMBOL13:
    1268             :         case SID_DRAWTBX_CS_SYMBOL14:
    1269             :         case SID_DRAWTBX_CS_SYMBOL15:
    1270             :         case SID_DRAWTBX_CS_SYMBOL16:
    1271             :         case SID_DRAWTBX_CS_SYMBOL17:
    1272             :         case SID_DRAWTBX_CS_SYMBOL18:
    1273             :         case SID_DRAWTBX_CS_ARROW1:
    1274             :         case SID_DRAWTBX_CS_ARROW2:
    1275             :         case SID_DRAWTBX_CS_ARROW3:
    1276             :         case SID_DRAWTBX_CS_ARROW4:
    1277             :         case SID_DRAWTBX_CS_ARROW5:
    1278             :         case SID_DRAWTBX_CS_ARROW6:
    1279             :         case SID_DRAWTBX_CS_ARROW7:
    1280             :         case SID_DRAWTBX_CS_ARROW8:
    1281             :         case SID_DRAWTBX_CS_ARROW9:
    1282             :         case SID_DRAWTBX_CS_ARROW10:
    1283             :         case SID_DRAWTBX_CS_ARROW11:
    1284             :         case SID_DRAWTBX_CS_ARROW12:
    1285             :         case SID_DRAWTBX_CS_ARROW13:
    1286             :         case SID_DRAWTBX_CS_ARROW14:
    1287             :         case SID_DRAWTBX_CS_ARROW15:
    1288             :         case SID_DRAWTBX_CS_ARROW16:
    1289             :         case SID_DRAWTBX_CS_ARROW17:
    1290             :         case SID_DRAWTBX_CS_ARROW18:
    1291             :         case SID_DRAWTBX_CS_ARROW19:
    1292             :         case SID_DRAWTBX_CS_ARROW20:
    1293             :         case SID_DRAWTBX_CS_ARROW21:
    1294             :         case SID_DRAWTBX_CS_ARROW22:
    1295             :         case SID_DRAWTBX_CS_ARROW23:
    1296             :         case SID_DRAWTBX_CS_ARROW24:
    1297             :         case SID_DRAWTBX_CS_ARROW25:
    1298             :         case SID_DRAWTBX_CS_ARROW26:
    1299             :         case SID_DRAWTBX_CS_STAR1:
    1300             :         case SID_DRAWTBX_CS_STAR2:
    1301             :         case SID_DRAWTBX_CS_STAR3:
    1302             :         case SID_DRAWTBX_CS_STAR4:
    1303             :         case SID_DRAWTBX_CS_STAR5:
    1304             :         case SID_DRAWTBX_CS_STAR6:
    1305             :         case SID_DRAWTBX_CS_STAR7:
    1306             :         case SID_DRAWTBX_CS_STAR8:
    1307             :         case SID_DRAWTBX_CS_STAR9:
    1308             :         case SID_DRAWTBX_CS_STAR10:
    1309             :         case SID_DRAWTBX_CS_STAR11:
    1310             :         case SID_DRAWTBX_CS_STAR12:
    1311             :         case SID_DRAWTBX_CS_FLOWCHART1:
    1312             :         case SID_DRAWTBX_CS_FLOWCHART2:
    1313             :         case SID_DRAWTBX_CS_FLOWCHART3:
    1314             :         case SID_DRAWTBX_CS_FLOWCHART4:
    1315             :         case SID_DRAWTBX_CS_FLOWCHART5:
    1316             :         case SID_DRAWTBX_CS_FLOWCHART6:
    1317             :         case SID_DRAWTBX_CS_FLOWCHART7:
    1318             :         case SID_DRAWTBX_CS_FLOWCHART8:
    1319             :         case SID_DRAWTBX_CS_FLOWCHART9:
    1320             :         case SID_DRAWTBX_CS_FLOWCHART10:
    1321             :         case SID_DRAWTBX_CS_FLOWCHART11:
    1322             :         case SID_DRAWTBX_CS_FLOWCHART12:
    1323             :         case SID_DRAWTBX_CS_FLOWCHART13:
    1324             :         case SID_DRAWTBX_CS_FLOWCHART14:
    1325             :         case SID_DRAWTBX_CS_FLOWCHART15:
    1326             :         case SID_DRAWTBX_CS_FLOWCHART16:
    1327             :         case SID_DRAWTBX_CS_FLOWCHART17:
    1328             :         case SID_DRAWTBX_CS_FLOWCHART18:
    1329             :         case SID_DRAWTBX_CS_FLOWCHART19:
    1330             :         case SID_DRAWTBX_CS_FLOWCHART20:
    1331             :         case SID_DRAWTBX_CS_FLOWCHART21:
    1332             :         case SID_DRAWTBX_CS_FLOWCHART22:
    1333             :         case SID_DRAWTBX_CS_FLOWCHART23:
    1334             :         case SID_DRAWTBX_CS_FLOWCHART24:
    1335             :         case SID_DRAWTBX_CS_FLOWCHART25:
    1336             :         case SID_DRAWTBX_CS_FLOWCHART26:
    1337             :         case SID_DRAWTBX_CS_FLOWCHART27:
    1338             :         case SID_DRAWTBX_CS_FLOWCHART28:
    1339             :         case SID_DRAWTBX_CS_CALLOUT1:
    1340             :         case SID_DRAWTBX_CS_CALLOUT2:
    1341             :         case SID_DRAWTBX_CS_CALLOUT3:
    1342             :         case SID_DRAWTBX_CS_CALLOUT4:
    1343             :         case SID_DRAWTBX_CS_CALLOUT5:
    1344             :         case SID_DRAWTBX_CS_CALLOUT6:
    1345             :         case SID_DRAWTBX_CS_CALLOUT7:
    1346             :         case SID_DRAWTBX_CS_SYMBOL:
    1347             :         case SID_DRAWTBX_CS_ARROW:
    1348             :         case SID_DRAWTBX_CS_FLOWCHART:
    1349             :         case SID_DRAWTBX_CS_CALLOUT:
    1350             :         case SID_DRAWTBX_CS_STAR:
    1351           0 :             getDesignView()->SetMode( RPTUI_INSERT );
    1352             :             {
    1353           0 :                 URL aUrl = getURLForId(_nId);
    1354           0 :                 sal_Int32 nIndex = 1;
    1355           0 :                 OUString sType = aUrl.Complete.getToken(0,'.',nIndex);
    1356           0 :                 if ( nIndex == -1 || sType.isEmpty() )
    1357             :                 {
    1358           0 :                     switch(_nId)
    1359             :                     {
    1360             :                         case SID_DRAWTBX_CS_SYMBOL:
    1361           0 :                             sType = "smiley";
    1362           0 :                             break;
    1363             :                         case SID_DRAWTBX_CS_ARROW:
    1364           0 :                             sType = "left-right-arrow";
    1365           0 :                             break;
    1366             :                         case SID_DRAWTBX_CS_FLOWCHART:
    1367           0 :                             sType = "flowchart-internal-storage";
    1368           0 :                             break;
    1369             :                         case SID_DRAWTBX_CS_CALLOUT:
    1370           0 :                             sType = "round-rectangular-callout";
    1371           0 :                             break;
    1372             :                         case SID_DRAWTBX_CS_STAR:
    1373           0 :                             sType = "star5";
    1374           0 :                             break;
    1375             :                         default:
    1376           0 :                             sType = "diamond";
    1377             :                     }
    1378             :                 }
    1379             :                 else
    1380           0 :                     sType = aUrl.Complete.getToken(0,'.',nIndex);
    1381             : 
    1382           0 :                 getDesignView()->SetInsertObj( OBJ_CUSTOMSHAPE ,sType);
    1383           0 :                 createDefaultControl(aArgs);
    1384             :             }
    1385           0 :             InvalidateAll();
    1386           0 :             break;
    1387             :         case SID_RPT_SHOWREPORTEXPLORER:
    1388           0 :             if ( isUiVisible() )
    1389           0 :                 getDesignView()->toggleReportExplorer();
    1390           0 :             break;
    1391             :         case SID_FM_ADD_FIELD:
    1392           0 :             if ( isUiVisible() )
    1393           0 :                 getDesignView()->toggleAddField();
    1394           0 :             break;
    1395             :         case SID_SHOW_PROPERTYBROWSER:
    1396           0 :             if ( m_bShowProperties )
    1397           0 :                 m_sLastActivePage = getDesignView()->getCurrentPage();
    1398             :             else
    1399           0 :                 getDesignView()->setCurrentPage(m_sLastActivePage);
    1400             : 
    1401           0 :             if ( isUiVisible() )
    1402             :             {
    1403           0 :                 m_bShowProperties = !m_bShowProperties;
    1404           0 :                 if ( aArgs.getLength() == 1 )
    1405           0 :                     aArgs[0].Value >>= m_bShowProperties;
    1406             : 
    1407           0 :                 getDesignView()->togglePropertyBrowser(m_bShowProperties);
    1408             :             }
    1409           0 :             break;
    1410             :         case SID_PROPERTYBROWSER_LAST_PAGE: // nothing to do
    1411           0 :             m_sLastActivePage = getDesignView()->getCurrentPage();
    1412           0 :             break;
    1413             :         case SID_SPLIT_POSITION:
    1414           0 :             getDesignView()->Resize();
    1415           0 :             break;
    1416             :         case SID_PAGEDIALOG:
    1417             :         case SID_ATTR_CHAR_COLOR_BACKGROUND:
    1418             :             {
    1419           0 :                 uno::Reference<report::XSection> xSection;
    1420           0 :                 if (aArgs.getLength() == 1 )
    1421           0 :                     aArgs[0].Value >>= xSection;
    1422           0 :                 openPageDialog(xSection);
    1423           0 :                 bForceBroadcast = sal_True;
    1424             :             }
    1425           0 :             break;
    1426             :         case SID_SORTINGANDGROUPING:
    1427           0 :             openSortingAndGroupingDialog();
    1428           0 :             m_bGroupFloaterWasVisible = m_pGroupsFloater && m_pGroupsFloater->IsVisible();
    1429           0 :             break;
    1430             :         case SID_BACKGROUND_COLOR:
    1431             :             {
    1432           0 :                 const util::Color aColor( lcl_extractBackgroundColor( aArgs ) );
    1433           0 :                 if ( !impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CONTROLBACKGROUND,uno::makeAny(aColor),aArgs) )
    1434             :                 {
    1435           0 :                     uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
    1436           0 :                     if ( xSection.is() )
    1437             :                     {
    1438           0 :                         xSection->setBackColor( aColor );
    1439           0 :                     }
    1440             :                 }
    1441           0 :                 bForceBroadcast = sal_True;
    1442             :             }
    1443           0 :             break;
    1444             :         case SID_ATTR_CHAR_WEIGHT:
    1445             :         case SID_ATTR_CHAR_POSTURE:
    1446             :         case SID_ATTR_CHAR_UNDERLINE:
    1447             :             {
    1448           0 :                 uno::Reference< awt::XWindow> xWindow;
    1449           0 :                 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
    1450           0 :                 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
    1451             : 
    1452           0 :                 const OUString sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT));
    1453           0 :                 UndoContext aUndoContext( getUndoManager(), sUndoAction );
    1454             : 
    1455           0 :                 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin();
    1456           0 :                 for(; aIter != aControlsFormats.end();++aIter)
    1457             :                 {
    1458           0 :                     uno::Reference< report::XReportControlFormat> xReportControlFormat(*aIter,uno::UNO_QUERY);
    1459           0 :                     lcl_setFontWPU_nothrow(xReportControlFormat,_nId);
    1460           0 :                 }
    1461             :             }
    1462           0 :             break;
    1463             :         case SID_ATTR_CHAR_COLOR:
    1464             :         case SID_ATTR_CHAR_COLOR2:
    1465             :             {
    1466           0 :                 const SequenceAsHashMap aMap(aArgs);
    1467           0 :                 const util::Color aColor = aMap.getUnpackedValueOrDefault(PROPERTY_FONTCOLOR,util::Color());
    1468           0 :                 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARCOLOR,uno::makeAny(aColor),aArgs);
    1469           0 :                 bForceBroadcast = sal_True;
    1470             :             }
    1471           0 :             break;
    1472             :         case SID_ATTR_CHAR_FONT:
    1473           0 :             if ( aArgs.getLength() == 1 )
    1474             :             {
    1475           0 :                 awt::FontDescriptor aFont;
    1476           0 :                 if ( aArgs[0].Value >>= aFont )
    1477             :                 {
    1478           0 :                     impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARFONTNAME,uno::makeAny(aFont.Name),aArgs);
    1479           0 :                 }
    1480             :             }
    1481           0 :             break;
    1482             :         case SID_ATTR_CHAR_FONTHEIGHT:
    1483           0 :             if ( aArgs.getLength() == 1 )
    1484             :             {
    1485           0 :                 float fSelVal = 0.0;
    1486           0 :                 if ( aArgs[0].Value >>= fSelVal )
    1487           0 :                     impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARHEIGHT,aArgs[0].Value,aArgs);
    1488             :             }
    1489           0 :             break;
    1490             :         case SID_ATTR_PARA_ADJUST_LEFT:
    1491             :         case SID_ATTR_PARA_ADJUST_CENTER:
    1492             :         case SID_ATTR_PARA_ADJUST_RIGHT:
    1493             :         case SID_ATTR_PARA_ADJUST_BLOCK:
    1494             :             {
    1495           0 :                 sal_Int16 eParagraphAdjust = style::ParagraphAdjust_LEFT;
    1496           0 :                 switch(_nId)
    1497             :                 {
    1498             :                     case SID_ATTR_PARA_ADJUST_LEFT:
    1499           0 :                         eParagraphAdjust = style::ParagraphAdjust_LEFT;
    1500           0 :                         break;
    1501             :                     case SID_ATTR_PARA_ADJUST_CENTER:
    1502           0 :                         eParagraphAdjust = style::ParagraphAdjust_CENTER;
    1503           0 :                         break;
    1504             :                     case SID_ATTR_PARA_ADJUST_RIGHT:
    1505           0 :                         eParagraphAdjust = style::ParagraphAdjust_RIGHT;
    1506           0 :                         break;
    1507             :                     case SID_ATTR_PARA_ADJUST_BLOCK:
    1508           0 :                         eParagraphAdjust = style::ParagraphAdjust_BLOCK;
    1509           0 :                         break;
    1510             :                 }
    1511           0 :                 impl_setPropertyAtControls_throw(RID_STR_UNDO_ALIGNMENT,PROPERTY_PARAADJUST,uno::makeAny(eParagraphAdjust),aArgs);
    1512             : 
    1513           0 :                 InvalidateFeature(SID_ATTR_PARA_ADJUST_LEFT);
    1514           0 :                 InvalidateFeature(SID_ATTR_PARA_ADJUST_CENTER);
    1515           0 :                 InvalidateFeature(SID_ATTR_PARA_ADJUST_RIGHT);
    1516           0 :                 InvalidateFeature(SID_ATTR_PARA_ADJUST_BLOCK);
    1517             :             }
    1518           0 :             break;
    1519             :         case SID_CHAR_DLG:
    1520             :             {
    1521           0 :                 uno::Sequence< beans::NamedValue > aSettings;
    1522           0 :                 uno::Reference< awt::XWindow> xWindow;
    1523           0 :                 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
    1524           0 :                 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
    1525             : 
    1526           0 :                 if ( !aControlsFormats.empty() )
    1527             :                 {
    1528           0 :                     const OUString sUndoAction( ModuleRes( RID_STR_UNDO_CHANGEFONT ) );
    1529           0 :                     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    1530             : 
    1531           0 :                     ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin();
    1532           0 :                     for(; aIter != aControlsFormats.end();++aIter)
    1533             :                     {
    1534           0 :                         uno::Reference< report::XReportControlFormat > xFormat( *aIter, uno::UNO_QUERY );
    1535           0 :                         if ( !xFormat.is() )
    1536           0 :                             continue;
    1537             : 
    1538           0 :                         if ( aSettings.getLength() == 0 )
    1539             :                         {
    1540           0 :                             ::rptui::openCharDialog( xFormat, xWindow, aSettings );
    1541           0 :                             if ( aSettings.getLength() == 0 )
    1542           0 :                                 break;
    1543             :                         }
    1544             : 
    1545           0 :                         applyCharacterSettings( xFormat, aSettings );
    1546           0 :                     }
    1547             : 
    1548           0 :                     InvalidateAll();
    1549           0 :                 }
    1550             :             }
    1551           0 :             break;
    1552             :         case SID_INSERT_GRAPHIC:
    1553           0 :             insertGraphic();
    1554           0 :             break;
    1555             :         case SID_SETCONTROLDEFAULTS:
    1556           0 :             break;
    1557             :         case SID_CONDITIONALFORMATTING:
    1558             :             {
    1559           0 :                 uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
    1560           0 :                 if ( xFormattedField.is() )
    1561             :                 {
    1562           0 :                     ConditionalFormattingDialog aDlg( getView(), xFormattedField.get(), *this );
    1563           0 :                     aDlg.Execute();
    1564           0 :                 }
    1565             :             }
    1566           0 :             break;
    1567             :         case SID_DATETIME:
    1568           0 :             if ( m_xReportDefinition.is() )
    1569             :             {
    1570           0 :                 if ( !aArgs.getLength() )
    1571             :                 {
    1572           0 :                     ODateTimeDialog aDlg(getView(),getDesignView()->getCurrentSection(),this);
    1573           0 :                     aDlg.Execute();
    1574             :                 }
    1575             :                 else
    1576           0 :                     createDateTime(aArgs);
    1577             :             }
    1578           0 :             break;
    1579             :         case SID_INSERT_FLD_PGNUMBER:
    1580           0 :             if ( m_xReportDefinition.is() )
    1581             :             {
    1582           0 :                 if ( !aArgs.getLength() )
    1583             :                 {
    1584           0 :                     OPageNumberDialog aDlg(getView(),m_xReportDefinition,this);
    1585           0 :                     aDlg.Execute();
    1586             :                 }
    1587             :                 else
    1588           0 :                     createPageNumber(aArgs);
    1589             :             }
    1590           0 :             break;
    1591             :         case SID_EXPORTDOC:
    1592             :         case SID_EXPORTDOCASPDF:
    1593           0 :             break;
    1594             :         case SID_PRINTPREVIEW:
    1595           0 :             if ( m_xReportDefinition.is() )
    1596             :             {
    1597             :             }
    1598           0 :             break;
    1599             :         case SID_EDITDOC:
    1600           0 :             if(isEditable())
    1601             :             { // the state should be changed to not editable
    1602           0 :                 switch (saveModified())
    1603             :                 {
    1604             :                     case RET_CANCEL:
    1605             :                         // don't change anything here so return
    1606           0 :                         return;
    1607             :                     case RET_NO:
    1608           0 :                         setModified(sal_False);     // and we are not modified yet
    1609           0 :                         break;
    1610             :                     default:
    1611           0 :                         break;
    1612             :                 }
    1613             :             }
    1614           0 :             setEditable(!isEditable());
    1615           0 :             InvalidateAll();
    1616           0 :             return;
    1617             :         case SID_GROUP:
    1618           0 :             break;
    1619             :         case SID_ATTR_ZOOM:
    1620           0 :             if ( aArgs.getLength() == 0 )
    1621             :             {
    1622           0 :                 openZoomDialog();
    1623             :             }
    1624           0 :             else if ( aArgs.getLength() == 1 && aArgs[0].Name == "Zoom" )
    1625             :             {
    1626           0 :                 SvxZoomItem aZoomItem;
    1627           0 :                 aZoomItem.PutValue(aArgs[0].Value);
    1628           0 :                 m_nZoomValue = aZoomItem.GetValue();
    1629           0 :                 m_eZoomType = aZoomItem.GetType();
    1630           0 :                 impl_zoom_nothrow();
    1631             :             }
    1632           0 :             break;
    1633             :         case SID_ATTR_ZOOMSLIDER:
    1634           0 :             if ( aArgs.getLength() == 1 && aArgs[0].Name == "ZoomSlider" )
    1635             :             {
    1636           0 :                 SvxZoomSliderItem aZoomSlider;
    1637           0 :                 aZoomSlider.PutValue(aArgs[0].Value);
    1638           0 :                 m_nZoomValue = aZoomSlider.GetValue();
    1639           0 :                 m_eZoomType = SVX_ZOOM_PERCENT;
    1640           0 :                 impl_zoom_nothrow();
    1641             :             }
    1642           0 :             break;
    1643             :         default:
    1644           0 :             OReportController_BASE::Execute(_nId,aArgs);
    1645             :     }
    1646           0 :     InvalidateFeature(_nId,Reference< XStatusListener >(),bForceBroadcast);
    1647             : }
    1648             : 
    1649           0 : short OReportController::saveModified()
    1650             : {
    1651           0 :     return RET_NO;
    1652             : }
    1653             : 
    1654             : 
    1655           0 : void OReportController::impl_initialize( )
    1656             : {
    1657           0 :     OReportController_BASE::impl_initialize();
    1658             : 
    1659           0 :     const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
    1660             : 
    1661           0 :     rArguments.get_ensureType( (OUString)PROPERTY_REPORTNAME, m_sName );
    1662           0 :     if ( m_sName.isEmpty() )
    1663           0 :         rArguments.get_ensureType( "DocumentTitle", m_sName );
    1664             : 
    1665             :     try
    1666             :     {
    1667           0 :         if ( m_xReportDefinition.is() )
    1668             :         {
    1669           0 :             getView()->initialize();    // show the windows and fill with our information
    1670             : 
    1671           0 :             m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition);
    1672           0 :             if ( !m_aReportModel )
    1673           0 :                 throw RuntimeException();
    1674           0 :             m_aReportModel->attachController( *this );
    1675             : 
    1676           0 :             clearUndoManager();
    1677           0 :             UndoSuppressor aSuppressUndo( getUndoManager() );
    1678             : 
    1679           0 :             ::comphelper::NamedValueCollection aArgs(getModel()->getArgs());
    1680           0 :             setMode(aArgs.getOrDefault("Mode", OUString("normal")));
    1681             : 
    1682           0 :             listen(true);
    1683           0 :             setEditable( !m_aReportModel->IsReadOnly() );
    1684           0 :             m_xFormatter.set(util::NumberFormatter::create(m_xContext), UNO_QUERY_THROW);
    1685           0 :             m_xFormatter->attachNumberFormatsSupplier(Reference< XNumberFormatsSupplier>(m_xReportDefinition,uno::UNO_QUERY));
    1686             : 
    1687           0 :             utl::MediaDescriptor aDescriptor( m_xReportDefinition->getArgs() );
    1688           0 :             OUString sHierarchicalDocumentName;
    1689           0 :             sHierarchicalDocumentName = aDescriptor.getUnpackedValueOrDefault("HierarchicalDocumentName",sHierarchicalDocumentName);
    1690             : 
    1691           0 :             if ( sHierarchicalDocumentName.isEmpty() && getConnection().is() )
    1692             :             {
    1693           0 :                 uno::Reference<sdbcx::XTablesSupplier> xTablesSup(getConnection(),uno::UNO_QUERY_THROW);
    1694           0 :                 uno::Reference<container::XNameAccess> xTables = xTablesSup->getTables();
    1695           0 :                 const uno::Sequence< OUString > aNames( xTables->getElementNames() );
    1696             : 
    1697           0 :                 if ( aNames.hasElements() )
    1698             :                 {
    1699           0 :                     m_xReportDefinition->setCommand(aNames[0]);
    1700           0 :                     m_xReportDefinition->setCommandType(sdb::CommandType::TABLE);
    1701           0 :                 }
    1702             :             }
    1703             : 
    1704           0 :             m_aVisualAreaSize = m_xReportDefinition->getVisualAreaSize(0);
    1705             : 
    1706             :         }
    1707             : 
    1708             :         // check if chart is supported by the engine
    1709           0 :         checkChartEnabled();
    1710             :         // restore the view data
    1711           0 :         getDesignView()->toggleGrid(m_bGridVisible);
    1712           0 :         getDesignView()->showRuler(m_bShowRuler);
    1713           0 :         getDesignView()->togglePropertyBrowser(m_bShowProperties);
    1714           0 :         getDesignView()->setCurrentPage(m_sLastActivePage);
    1715           0 :         getDesignView()->unmarkAllObjects(NULL);
    1716             : 
    1717           0 :         if ( m_nPageNum != -1 )
    1718             :         {
    1719           0 :             if ( m_nPageNum < m_aReportModel->GetPageCount() )
    1720             :             {
    1721           0 :                 const OReportPage* pPage = dynamic_cast<OReportPage*>(m_aReportModel->GetPage(static_cast<sal_uInt16>(m_nPageNum)));
    1722           0 :                 if ( pPage )
    1723             :                 {
    1724           0 :                     uno::Sequence< beans::PropertyValue> aArgs(1);
    1725           0 :                     aArgs[0].Value <<= pPage->getSection();
    1726           0 :                     executeUnChecked(SID_SELECT,aArgs);
    1727             :                 }
    1728             :             }
    1729             :             else
    1730           0 :                 m_nPageNum = -1;
    1731             :         }
    1732           0 :         getDesignView()->collapseSections(m_aCollapsedSections);
    1733           0 :         impl_zoom_nothrow();
    1734           0 :         getDesignView()->Resize();
    1735           0 :         getDesignView()->Invalidate();
    1736           0 :         InvalidateAll();
    1737             : 
    1738           0 :         if ( m_bShowProperties && m_nPageNum == -1 )
    1739             :         {
    1740           0 :             m_sLastActivePage = "Data";
    1741           0 :             getDesignView()->setCurrentPage(m_sLastActivePage);
    1742           0 :             uno::Sequence< beans::PropertyValue> aArgs;
    1743           0 :             executeUnChecked(SID_SELECT_REPORT,aArgs);
    1744             :         }
    1745             : 
    1746           0 :         setModified(sal_False);     // and we are not modified yet
    1747             : 
    1748             :         // open the global help agent
    1749             :         // we need a Frame but at this time there is no frame, therefore we send a UserEvent
    1750           0 :         getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent));
    1751             :     }
    1752           0 :     catch(const SQLException&)
    1753             :     {
    1754             :         DBG_UNHANDLED_EXCEPTION();
    1755             :     }
    1756           0 : }
    1757             : 
    1758           0 : IMPL_LINK( OReportController, OnOpenHelpAgent, void* ,/*_pMemfun*/)
    1759             : {
    1760           0 :     doOpenHelpAgent();
    1761           0 :     return 0L;
    1762             : }
    1763             : 
    1764           0 : IMPL_LINK( OReportController, OnCreateHdl, OAddFieldWindow* ,_pAddFieldDlg)
    1765             : {
    1766           0 :     WaitObject aObj( getDesignView() );
    1767           0 :     uno::Sequence< beans::PropertyValue > aArgs = _pAddFieldDlg->getSelectedFieldDescriptors();
    1768             :     // we use this way to create undo actions
    1769           0 :     if ( aArgs.getLength() )
    1770             :     {
    1771           0 :         executeChecked(SID_ADD_CONTROL_PAIR,aArgs);
    1772             :     }
    1773           0 :     return 0L;
    1774             : }
    1775             : 
    1776             : 
    1777           0 : void OReportController::doOpenHelpAgent()
    1778             : {
    1779           0 :     if (getFrame().is())
    1780             :     {
    1781           0 :         OUString suURL("vnd.sun.star.help://shared/text/shared/explorer/database/rep_main.xhp?UseDB=no&DbPAR=swriter");
    1782           0 :         openHelpAgent(suURL);
    1783             :     }
    1784             :     else
    1785             :     {
    1786             :         // as long as we don't get a Frame, we send the user event again.
    1787           0 :         getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent));
    1788             :     }
    1789           0 : }
    1790             : 
    1791           0 : bool OReportController::Construct(Window* pParent)
    1792             : {
    1793           0 :     ODesignView* pMyOwnView = new ODesignView( pParent, m_xContext, *this );
    1794           0 :     StartListening( *pMyOwnView );
    1795           0 :     setView( *pMyOwnView );
    1796             : 
    1797             :     // now that we have a view we can create the clipboard listener
    1798           0 :     m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
    1799           0 :     m_aSystemClipboard.StartClipboardListening( );
    1800           0 :     m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OReportController, OnClipboardChanged ) );
    1801           0 :     m_pClipbordNotifier->acquire();
    1802           0 :     m_pClipbordNotifier->AddRemoveListener( getView(), true );
    1803             : 
    1804           0 :     OReportController_BASE::Construct(pParent);
    1805           0 :     return true;
    1806             : }
    1807             : 
    1808           0 : sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException, std::exception )
    1809             : {
    1810           0 :     if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
    1811           0 :         return sal_True;
    1812             : 
    1813           0 :     SolarMutexGuard aSolarGuard;
    1814           0 :     ::osl::MutexGuard aGuard( getMutex() );
    1815             : 
    1816           0 :     if ( getView() && getView()->IsInModalMode() )
    1817           0 :         return sal_False;
    1818             : 
    1819             :     // this suspend will be handled in the DBAccess interceptor implementation
    1820           0 :     return sal_True;
    1821             : }
    1822             : 
    1823           0 : void OReportController::describeSupportedFeatures()
    1824             : {
    1825           0 :     DBSubComponentController::describeSupportedFeatures();
    1826             : 
    1827           0 :     implDescribeSupportedFeature( ".uno:TextDocument",              SID_RPT_TEXTDOCUMENT,           CommandGroup::APPLICATION );
    1828           0 :     implDescribeSupportedFeature( ".uno:Spreadsheet",               SID_RPT_SPREADSHEET,            CommandGroup::APPLICATION );
    1829             : 
    1830           0 :     implDescribeSupportedFeature( ".uno:Redo",                      SID_REDO,                       CommandGroup::EDIT );
    1831           0 :     implDescribeSupportedFeature( ".uno:Undo",                      SID_UNDO,                       CommandGroup::EDIT );
    1832           0 :     implDescribeSupportedFeature( ".uno:SelectAll",                 SID_SELECTALL,                  CommandGroup::EDIT );
    1833           0 :     implDescribeSupportedFeature( ".uno:SelectAllInSection",        SID_SELECTALL_IN_SECTION,       CommandGroup::EDIT );
    1834           0 :     implDescribeSupportedFeature( ".uno:Delete",                    SID_DELETE,                     CommandGroup::EDIT );
    1835           0 :     implDescribeSupportedFeature( ".uno:SelectReport",              SID_SELECT_REPORT,              CommandGroup::EDIT );
    1836           0 :     implDescribeSupportedFeature( ".uno:ExecuteReport",             SID_EXECUTE_REPORT,             CommandGroup::EDIT );
    1837             : 
    1838           0 :     implDescribeSupportedFeature( ".uno:GridVisible",               SID_GRID_VISIBLE,               CommandGroup::VIEW );
    1839           0 :     implDescribeSupportedFeature( ".uno:GridUse",                   SID_GRID_USE,                   CommandGroup::VIEW );
    1840           0 :     implDescribeSupportedFeature( ".uno:HelplinesMove",             SID_HELPLINES_MOVE,             CommandGroup::VIEW );
    1841           0 :     implDescribeSupportedFeature( ".uno:ShowRuler",                 SID_RULER,                      CommandGroup::VIEW );
    1842           0 :     implDescribeSupportedFeature( ".uno:AddField",                  SID_FM_ADD_FIELD,               CommandGroup::VIEW );
    1843           0 :     implDescribeSupportedFeature( ".uno:ReportNavigator",           SID_RPT_SHOWREPORTEXPLORER,     CommandGroup::VIEW );
    1844           0 :     implDescribeSupportedFeature( ".uno:ControlProperties",         SID_SHOW_PROPERTYBROWSER,       CommandGroup::VIEW );
    1845           0 :     implDescribeSupportedFeature( ".uno:DbSortingAndGrouping",      SID_SORTINGANDGROUPING,         CommandGroup::VIEW );
    1846           0 :     implDescribeSupportedFeature( ".uno:PageHeaderFooter",          SID_PAGEHEADERFOOTER,           CommandGroup::VIEW );
    1847           0 :     implDescribeSupportedFeature( ".uno:ReportHeaderFooter",        SID_REPORTHEADERFOOTER,         CommandGroup::VIEW );
    1848           0 :     implDescribeSupportedFeature( ".uno:ZoomSlider",                SID_ATTR_ZOOMSLIDER,            CommandGroup::VIEW );
    1849           0 :     implDescribeSupportedFeature( ".uno:Zoom",                      SID_ATTR_ZOOM,                  CommandGroup::VIEW );
    1850             : 
    1851           0 :     implDescribeSupportedFeature( ".uno:ConditionalFormatting",     SID_CONDITIONALFORMATTING,      CommandGroup::FORMAT );
    1852           0 :     implDescribeSupportedFeature( ".uno:PageDialog",                SID_PAGEDIALOG,                 CommandGroup::FORMAT );
    1853           0 :     implDescribeSupportedFeature( ".uno:ResetAttributes",           SID_SETCONTROLDEFAULTS,         CommandGroup::FORMAT );
    1854             : 
    1855           0 :     implDescribeSupportedFeature( ".uno:Bold",                      SID_ATTR_CHAR_WEIGHT,           CommandGroup::FORMAT );
    1856           0 :     implDescribeSupportedFeature( ".uno:Italic",                    SID_ATTR_CHAR_POSTURE,          CommandGroup::FORMAT );
    1857           0 :     implDescribeSupportedFeature( ".uno:Underline",                 SID_ATTR_CHAR_UNDERLINE,        CommandGroup::FORMAT );
    1858           0 :     implDescribeSupportedFeature( ".uno:BackColor",                 SID_ATTR_CHAR_COLOR_BACKGROUND, CommandGroup::FORMAT );
    1859           0 :     implDescribeSupportedFeature( ".uno:BackgroundColor",           SID_BACKGROUND_COLOR,           CommandGroup::FORMAT );
    1860           0 :     implDescribeSupportedFeature( ".uno:Color",                     SID_ATTR_CHAR_COLOR);
    1861           0 :     implDescribeSupportedFeature( ".uno:FontColor",                 SID_ATTR_CHAR_COLOR2,           CommandGroup::FORMAT );
    1862           0 :     implDescribeSupportedFeature( ".uno:FontDialog",                SID_CHAR_DLG,                   CommandGroup::FORMAT );
    1863           0 :     implDescribeSupportedFeature( ".uno:LeftPara",                  SID_ATTR_PARA_ADJUST_LEFT,      CommandGroup::FORMAT );
    1864           0 :     implDescribeSupportedFeature( ".uno:CenterPara",                SID_ATTR_PARA_ADJUST_CENTER,    CommandGroup::FORMAT );
    1865           0 :     implDescribeSupportedFeature( ".uno:RightPara",                 SID_ATTR_PARA_ADJUST_RIGHT,     CommandGroup::FORMAT );
    1866           0 :     implDescribeSupportedFeature( ".uno:JustifyPara",               SID_ATTR_PARA_ADJUST_BLOCK,     CommandGroup::FORMAT );
    1867             : 
    1868           0 :     implDescribeSupportedFeature( ".uno:FontHeight",                SID_ATTR_CHAR_FONTHEIGHT,       CommandGroup::FORMAT );
    1869           0 :     implDescribeSupportedFeature( ".uno:CharFontName",              SID_ATTR_CHAR_FONT,             CommandGroup::FORMAT );
    1870             : 
    1871           0 :     implDescribeSupportedFeature( ".uno:ArrangeMenu",               SID_ARRANGEMENU,                CommandGroup::FORMAT );
    1872           0 :     implDescribeSupportedFeature( ".uno:BringToFront",              SID_FRAME_TO_TOP,               CommandGroup::FORMAT );
    1873           0 :     implDescribeSupportedFeature( ".uno:ObjectBackOne",             SID_FRAME_DOWN,                 CommandGroup::FORMAT );
    1874           0 :     implDescribeSupportedFeature( ".uno:ObjectForwardOne",          SID_FRAME_UP,                   CommandGroup::FORMAT );
    1875           0 :     implDescribeSupportedFeature( ".uno:SendToBack",                SID_FRAME_TO_BOTTOM,            CommandGroup::FORMAT );
    1876           0 :     implDescribeSupportedFeature( ".uno:SetObjectToForeground",     SID_OBJECT_HEAVEN,              CommandGroup::FORMAT );
    1877           0 :     implDescribeSupportedFeature( ".uno:SetObjectToBackground",     SID_OBJECT_HELL,                CommandGroup::FORMAT );
    1878             : 
    1879           0 :     implDescribeSupportedFeature( ".uno:ObjectAlign",               SID_OBJECT_ALIGN,               CommandGroup::FORMAT );
    1880           0 :     implDescribeSupportedFeature( ".uno:ObjectAlignLeft",           SID_OBJECT_ALIGN_LEFT,          CommandGroup::FORMAT );
    1881           0 :     implDescribeSupportedFeature( ".uno:AlignCenter",               SID_OBJECT_ALIGN_CENTER,        CommandGroup::FORMAT );
    1882           0 :     implDescribeSupportedFeature( ".uno:ObjectAlignRight",          SID_OBJECT_ALIGN_RIGHT,         CommandGroup::FORMAT );
    1883           0 :     implDescribeSupportedFeature( ".uno:AlignUp",                   SID_OBJECT_ALIGN_UP,            CommandGroup::FORMAT );
    1884           0 :     implDescribeSupportedFeature( ".uno:AlignMiddle",               SID_OBJECT_ALIGN_MIDDLE,        CommandGroup::FORMAT );
    1885           0 :     implDescribeSupportedFeature( ".uno:AlignDown",                 SID_OBJECT_ALIGN_DOWN,          CommandGroup::FORMAT );
    1886             : 
    1887           0 :     implDescribeSupportedFeature( ".uno:SectionAlign",              SID_SECTION_ALIGN,              CommandGroup::FORMAT );
    1888           0 :     implDescribeSupportedFeature( ".uno:SectionAlignLeft",          SID_SECTION_ALIGN_LEFT,         CommandGroup::FORMAT );
    1889           0 :     implDescribeSupportedFeature( ".uno:SectionAlignCenter",        SID_SECTION_ALIGN_CENTER,       CommandGroup::FORMAT );
    1890           0 :     implDescribeSupportedFeature( ".uno:SectionAlignRight",         SID_SECTION_ALIGN_RIGHT,        CommandGroup::FORMAT );
    1891           0 :     implDescribeSupportedFeature( ".uno:SectionAlignTop",           SID_SECTION_ALIGN_UP,           CommandGroup::FORMAT );
    1892           0 :     implDescribeSupportedFeature( ".uno:SectionAlignMiddle",        SID_SECTION_ALIGN_MIDDLE,       CommandGroup::FORMAT );
    1893           0 :     implDescribeSupportedFeature( ".uno:SectionAlignBottom",        SID_SECTION_ALIGN_DOWN,         CommandGroup::FORMAT );
    1894           0 :     implDescribeSupportedFeature( ".uno:SectionShrink",             SID_SECTION_SHRINK,             CommandGroup::FORMAT );
    1895           0 :     implDescribeSupportedFeature( ".uno:SectionShrinkTop",          SID_SECTION_SHRINK_TOP,         CommandGroup::FORMAT );
    1896           0 :     implDescribeSupportedFeature( ".uno:SectionShrinkBottom",       SID_SECTION_SHRINK_BOTTOM,      CommandGroup::FORMAT );
    1897             : 
    1898           0 :     implDescribeSupportedFeature( ".uno:ObjectResize",              SID_OBJECT_RESIZING,            CommandGroup::FORMAT );
    1899           0 :     implDescribeSupportedFeature( ".uno:SmallestWidth",             SID_OBJECT_SMALLESTWIDTH,       CommandGroup::FORMAT );
    1900           0 :     implDescribeSupportedFeature( ".uno:SmallestHeight",            SID_OBJECT_SMALLESTHEIGHT,      CommandGroup::FORMAT );
    1901           0 :     implDescribeSupportedFeature( ".uno:GreatestWidth",             SID_OBJECT_GREATESTWIDTH,       CommandGroup::FORMAT );
    1902           0 :     implDescribeSupportedFeature( ".uno:GreatestHeight",            SID_OBJECT_GREATESTHEIGHT,      CommandGroup::FORMAT );
    1903           0 :     implDescribeSupportedFeature( ".uno:Distribution",              SID_DISTRIBUTION,               CommandGroup::FORMAT );
    1904             : 
    1905           0 :     implDescribeSupportedFeature( ".uno:HelpMenu",                  SID_HELPMENU,                   CommandGroup::APPLICATION );
    1906           0 :     implDescribeSupportedFeature( ".uno:ExportTo",                  SID_EXPORTDOC,                  CommandGroup::APPLICATION );
    1907           0 :     implDescribeSupportedFeature( ".uno:ExportToPDF",               SID_EXPORTDOCASPDF,             CommandGroup::APPLICATION );
    1908           0 :     implDescribeSupportedFeature( ".uno:PrintPreview",              SID_PRINTPREVIEW,               CommandGroup::APPLICATION );
    1909             : 
    1910           0 :     implDescribeSupportedFeature( ".uno:NewDoc",                    SID_NEWDOC,                     CommandGroup::DOCUMENT );
    1911           0 :     implDescribeSupportedFeature( ".uno:Save",                      SID_SAVEDOC,                    CommandGroup::DOCUMENT );
    1912           0 :     implDescribeSupportedFeature( ".uno:SaveAs",                    SID_SAVEASDOC,                  CommandGroup::DOCUMENT );
    1913           0 :     implDescribeSupportedFeature( ".uno:SaveACopy",                 SID_SAVEACOPY,                  CommandGroup::DOCUMENT );
    1914             : 
    1915           0 :     implDescribeSupportedFeature( ".uno:InsertPageNumberField",     SID_INSERT_FLD_PGNUMBER,        CommandGroup::INSERT );
    1916           0 :     implDescribeSupportedFeature( ".uno:InsertDateTimeField",       SID_DATETIME,                   CommandGroup::INSERT );
    1917           0 :     implDescribeSupportedFeature( ".uno:InsertObjectChart",         SID_INSERT_DIAGRAM,             CommandGroup::INSERT );
    1918           0 :     implDescribeSupportedFeature( ".uno:InsertGraphic",             SID_INSERT_GRAPHIC,             CommandGroup::INSERT );
    1919             :     // controls
    1920           0 :     implDescribeSupportedFeature( ".uno:SelectObject",              SID_OBJECT_SELECT,              CommandGroup::INSERT );
    1921           0 :     implDescribeSupportedFeature( ".uno:Label",                     SID_FM_FIXEDTEXT,               CommandGroup::INSERT );
    1922           0 :     implDescribeSupportedFeature( ".uno:Edit",                      SID_FM_EDIT,                    CommandGroup::INSERT );
    1923           0 :     implDescribeSupportedFeature( ".uno:ImageControl",              SID_FM_IMAGECONTROL,            CommandGroup::INSERT );
    1924           0 :     implDescribeSupportedFeature( ".uno:HFixedLine",                SID_INSERT_HFIXEDLINE,          CommandGroup::INSERT );
    1925           0 :     implDescribeSupportedFeature( ".uno:VFixedLine",                SID_INSERT_VFIXEDLINE,          CommandGroup::INSERT );
    1926             : 
    1927             :     // shapes
    1928           0 :     implDescribeSupportedFeature( ".uno:BasicShapes",               SID_DRAWTBX_CS_BASIC,           CommandGroup::INSERT );
    1929           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.rectangle",     SID_DRAWTBX_CS_BASIC1,          CommandGroup::INSERT );
    1930           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.round-rectangle",SID_DRAWTBX_CS_BASIC2,         CommandGroup::INSERT );
    1931           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.quadrat",       SID_DRAWTBX_CS_BASIC3,          CommandGroup::INSERT );
    1932           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.round-quadrat", SID_DRAWTBX_CS_BASIC4,          CommandGroup::INSERT );
    1933           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.circle",        SID_DRAWTBX_CS_BASIC5,          CommandGroup::INSERT );
    1934           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.ellipse",       SID_DRAWTBX_CS_BASIC6,          CommandGroup::INSERT );
    1935           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.circle-pie",    SID_DRAWTBX_CS_BASIC7,          CommandGroup::INSERT );
    1936           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.isosceles-triangle",SID_DRAWTBX_CS_BASIC8,      CommandGroup::INSERT );
    1937           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.right-triangle",SID_DRAWTBX_CS_BASIC9,          CommandGroup::INSERT );
    1938           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.trapezoid",     SID_DRAWTBX_CS_BASIC10,         CommandGroup::INSERT );
    1939           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.diamond",       SID_DRAWTBX_CS_BASIC11,         CommandGroup::INSERT );
    1940           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.parallelogram", SID_DRAWTBX_CS_BASIC12,         CommandGroup::INSERT );
    1941           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.pentagon",      SID_DRAWTBX_CS_BASIC13,         CommandGroup::INSERT );
    1942           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.hexagon",       SID_DRAWTBX_CS_BASIC14,         CommandGroup::INSERT );
    1943           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.octagon",       SID_DRAWTBX_CS_BASIC15,         CommandGroup::INSERT );
    1944           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.cross",         SID_DRAWTBX_CS_BASIC16,         CommandGroup::INSERT );
    1945           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.ring",          SID_DRAWTBX_CS_BASIC17,         CommandGroup::INSERT );
    1946           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.block-arc",     SID_DRAWTBX_CS_BASIC18,         CommandGroup::INSERT );
    1947           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.can",           SID_DRAWTBX_CS_BASIC19,         CommandGroup::INSERT );
    1948           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.cube",          SID_DRAWTBX_CS_BASIC20,         CommandGroup::INSERT );
    1949           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.paper",         SID_DRAWTBX_CS_BASIC21,         CommandGroup::INSERT );
    1950           0 :     implDescribeSupportedFeature( ".uno:BasicShapes.frame",         SID_DRAWTBX_CS_BASIC22,         CommandGroup::INSERT );
    1951             : 
    1952           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes",              SID_DRAWTBX_CS_SYMBOL,          CommandGroup::INSERT );
    1953             : 
    1954           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.smiley" ,      SID_DRAWTBX_CS_SYMBOL1,         CommandGroup::INSERT );
    1955           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.sun" ,         SID_DRAWTBX_CS_SYMBOL2,         CommandGroup::INSERT );
    1956           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.moon" ,        SID_DRAWTBX_CS_SYMBOL3,         CommandGroup::INSERT );
    1957           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.lightning" ,   SID_DRAWTBX_CS_SYMBOL4,         CommandGroup::INSERT );
    1958           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.heart" ,       SID_DRAWTBX_CS_SYMBOL5,         CommandGroup::INSERT );
    1959           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.flower" ,      SID_DRAWTBX_CS_SYMBOL6,         CommandGroup::INSERT );
    1960           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.cloud" ,       SID_DRAWTBX_CS_SYMBOL7,         CommandGroup::INSERT );
    1961           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.forbidden" ,   SID_DRAWTBX_CS_SYMBOL8,         CommandGroup::INSERT );
    1962           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.puzzle" ,      SID_DRAWTBX_CS_SYMBOL9,         CommandGroup::INSERT );
    1963           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.bracket-pair" ,SID_DRAWTBX_CS_SYMBOL10,        CommandGroup::INSERT );
    1964           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.left-bracket" ,SID_DRAWTBX_CS_SYMBOL11,        CommandGroup::INSERT );
    1965           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.right-bracket",SID_DRAWTBX_CS_SYMBOL12,        CommandGroup::INSERT );
    1966           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.brace-pair" ,  SID_DRAWTBX_CS_SYMBOL13,        CommandGroup::INSERT );
    1967           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.left-brace" ,  SID_DRAWTBX_CS_SYMBOL14,        CommandGroup::INSERT );
    1968           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.right-brace" , SID_DRAWTBX_CS_SYMBOL15,        CommandGroup::INSERT );
    1969           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.quad-bevel" ,  SID_DRAWTBX_CS_SYMBOL16,        CommandGroup::INSERT );
    1970           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.octagon-bevel",SID_DRAWTBX_CS_SYMBOL17,        CommandGroup::INSERT );
    1971           0 :     implDescribeSupportedFeature( ".uno:SymbolShapes.diamond-bevel",SID_DRAWTBX_CS_SYMBOL18,        CommandGroup::INSERT );
    1972             : 
    1973           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow" ,           SID_DRAWTBX_CS_ARROW1,  CommandGroup::INSERT );
    1974           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow" ,          SID_DRAWTBX_CS_ARROW2,  CommandGroup::INSERT );
    1975           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow" ,             SID_DRAWTBX_CS_ARROW3,  CommandGroup::INSERT );
    1976           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow" ,           SID_DRAWTBX_CS_ARROW4,  CommandGroup::INSERT );
    1977           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow" ,     SID_DRAWTBX_CS_ARROW5,  CommandGroup::INSERT );
    1978           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow" ,        SID_DRAWTBX_CS_ARROW6,  CommandGroup::INSERT );
    1979           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow" ,       SID_DRAWTBX_CS_ARROW7,  CommandGroup::INSERT );
    1980           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-down-arrow" ,  SID_DRAWTBX_CS_ARROW8,  CommandGroup::INSERT );
    1981           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow" ,           SID_DRAWTBX_CS_ARROW9,  CommandGroup::INSERT );
    1982           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.corner-right-arrow" ,   SID_DRAWTBX_CS_ARROW10, CommandGroup::INSERT );
    1983           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.split-arrow" ,          SID_DRAWTBX_CS_ARROW11, CommandGroup::INSERT );
    1984           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.striped-right-arrow" ,  SID_DRAWTBX_CS_ARROW12, CommandGroup::INSERT );
    1985           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.notched-right-arrow" ,  SID_DRAWTBX_CS_ARROW13, CommandGroup::INSERT );
    1986           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.pentagon-right" ,       SID_DRAWTBX_CS_ARROW14, CommandGroup::INSERT );
    1987           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.chevron" ,              SID_DRAWTBX_CS_ARROW15, CommandGroup::INSERT );
    1988           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow-callout" ,  SID_DRAWTBX_CS_ARROW16, CommandGroup::INSERT );
    1989           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow-callout" ,   SID_DRAWTBX_CS_ARROW17, CommandGroup::INSERT );
    1990           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow-callout" ,     SID_DRAWTBX_CS_ARROW18, CommandGroup::INSERT );
    1991           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow-callout" ,   SID_DRAWTBX_CS_ARROW19, CommandGroup::INSERT );
    1992           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow-callout",SID_DRAWTBX_CS_ARROW20,       CommandGroup::INSERT );
    1993           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow-callout" ,SID_DRAWTBX_CS_ARROW21, CommandGroup::INSERT );
    1994           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow-callout",SID_DRAWTBX_CS_ARROW22, CommandGroup::INSERT );
    1995           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow-callout" ,   SID_DRAWTBX_CS_ARROW23, CommandGroup::INSERT );
    1996           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.circular-arrow" ,       SID_DRAWTBX_CS_ARROW24, CommandGroup::INSERT );
    1997           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.split-round-arrow" ,    SID_DRAWTBX_CS_ARROW25, CommandGroup::INSERT );
    1998           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes.s-sharped-arrow" ,      SID_DRAWTBX_CS_ARROW26, CommandGroup::INSERT );
    1999             : 
    2000           0 :     implDescribeSupportedFeature( ".uno:StarShapes.bang" ,                  SID_DRAWTBX_CS_STAR1,           CommandGroup::INSERT );
    2001           0 :     implDescribeSupportedFeature( ".uno:StarShapes.star4" ,                 SID_DRAWTBX_CS_STAR2,           CommandGroup::INSERT );
    2002           0 :     implDescribeSupportedFeature( ".uno:StarShapes.star5" ,                 SID_DRAWTBX_CS_STAR3,           CommandGroup::INSERT );
    2003           0 :     implDescribeSupportedFeature( ".uno:StarShapes.star6" ,                 SID_DRAWTBX_CS_STAR4,           CommandGroup::INSERT );
    2004           0 :     implDescribeSupportedFeature( ".uno:StarShapes.star8" ,                 SID_DRAWTBX_CS_STAR5,           CommandGroup::INSERT );
    2005           0 :     implDescribeSupportedFeature( ".uno:StarShapes.star12" ,                SID_DRAWTBX_CS_STAR6,           CommandGroup::INSERT );
    2006           0 :     implDescribeSupportedFeature( ".uno:StarShapes.star24" ,                SID_DRAWTBX_CS_STAR7,           CommandGroup::INSERT );
    2007           0 :     implDescribeSupportedFeature( ".uno:StarShapes.concave-star6" ,         SID_DRAWTBX_CS_STAR8,           CommandGroup::INSERT );
    2008           0 :     implDescribeSupportedFeature( ".uno:StarShapes.vertical-scroll" ,       SID_DRAWTBX_CS_STAR9,           CommandGroup::INSERT );
    2009           0 :     implDescribeSupportedFeature( ".uno:StarShapes.horizontal-scroll" ,     SID_DRAWTBX_CS_STAR10,          CommandGroup::INSERT );
    2010           0 :     implDescribeSupportedFeature( ".uno:StarShapes.signet" ,                SID_DRAWTBX_CS_STAR11,          CommandGroup::INSERT );
    2011           0 :     implDescribeSupportedFeature( ".uno:StarShapes.doorplate" ,             SID_DRAWTBX_CS_STAR12,          CommandGroup::INSERT );
    2012             : 
    2013           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-process" ,            SID_DRAWTBX_CS_FLOWCHART1,          CommandGroup::INSERT );
    2014           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-alternate-process" ,  SID_DRAWTBX_CS_FLOWCHART2,          CommandGroup::INSERT );
    2015           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-decision" ,           SID_DRAWTBX_CS_FLOWCHART3,          CommandGroup::INSERT );
    2016           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-data" ,               SID_DRAWTBX_CS_FLOWCHART4,          CommandGroup::INSERT );
    2017           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-predefined-process" , SID_DRAWTBX_CS_FLOWCHART5,          CommandGroup::INSERT );
    2018           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-internal-storage" ,   SID_DRAWTBX_CS_FLOWCHART6,          CommandGroup::INSERT );
    2019           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-document" ,           SID_DRAWTBX_CS_FLOWCHART7,          CommandGroup::INSERT );
    2020           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-multidocument" ,      SID_DRAWTBX_CS_FLOWCHART8,          CommandGroup::INSERT );
    2021           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-terminator" ,         SID_DRAWTBX_CS_FLOWCHART9,          CommandGroup::INSERT );
    2022           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-preparation" ,        SID_DRAWTBX_CS_FLOWCHART10,         CommandGroup::INSERT );
    2023           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-input" ,       SID_DRAWTBX_CS_FLOWCHART11,         CommandGroup::INSERT );
    2024           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-operation" ,   SID_DRAWTBX_CS_FLOWCHART12,         CommandGroup::INSERT );
    2025           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-connector" ,          SID_DRAWTBX_CS_FLOWCHART13,         CommandGroup::INSERT );
    2026           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-off-page-connector" , SID_DRAWTBX_CS_FLOWCHART14,         CommandGroup::INSERT );
    2027           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-card" ,               SID_DRAWTBX_CS_FLOWCHART15,         CommandGroup::INSERT );
    2028           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-punched-tape" ,       SID_DRAWTBX_CS_FLOWCHART16,         CommandGroup::INSERT );
    2029           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-summing-junction" ,   SID_DRAWTBX_CS_FLOWCHART17,         CommandGroup::INSERT );
    2030           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-or" ,                 SID_DRAWTBX_CS_FLOWCHART18,         CommandGroup::INSERT );
    2031           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-collate" ,            SID_DRAWTBX_CS_FLOWCHART19,         CommandGroup::INSERT );
    2032           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sort" ,               SID_DRAWTBX_CS_FLOWCHART20,         CommandGroup::INSERT );
    2033           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-extract" ,            SID_DRAWTBX_CS_FLOWCHART21,         CommandGroup::INSERT );
    2034           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-merge" ,              SID_DRAWTBX_CS_FLOWCHART22,         CommandGroup::INSERT );
    2035           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-stored-data" ,        SID_DRAWTBX_CS_FLOWCHART23,         CommandGroup::INSERT );
    2036           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-delay" ,              SID_DRAWTBX_CS_FLOWCHART24,         CommandGroup::INSERT );
    2037           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sequential-access" ,  SID_DRAWTBX_CS_FLOWCHART25,         CommandGroup::INSERT );
    2038           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-magnetic-disk" ,      SID_DRAWTBX_CS_FLOWCHART26,         CommandGroup::INSERT );
    2039           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-direct-access-storage",SID_DRAWTBX_CS_FLOWCHART27,        CommandGroup::INSERT );
    2040           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-display" ,            SID_DRAWTBX_CS_FLOWCHART28,         CommandGroup::INSERT );
    2041             : 
    2042           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes.rectangular-callout" ,        SID_DRAWTBX_CS_CALLOUT1,            CommandGroup::INSERT );
    2043           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes.round-rectangular-callout" ,  SID_DRAWTBX_CS_CALLOUT2,            CommandGroup::INSERT );
    2044           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes.round-callout" ,              SID_DRAWTBX_CS_CALLOUT3,            CommandGroup::INSERT );
    2045           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes.cloud-callout" ,              SID_DRAWTBX_CS_CALLOUT4,            CommandGroup::INSERT );
    2046           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-1" ,             SID_DRAWTBX_CS_CALLOUT5,            CommandGroup::INSERT );
    2047           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-2" ,             SID_DRAWTBX_CS_CALLOUT6,            CommandGroup::INSERT );
    2048           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-3" ,             SID_DRAWTBX_CS_CALLOUT7,            CommandGroup::INSERT );
    2049             : 
    2050           0 :     implDescribeSupportedFeature( ".uno:ArrowShapes",               SID_DRAWTBX_CS_ARROW,           CommandGroup::INSERT );
    2051             : 
    2052           0 :     implDescribeSupportedFeature( ".uno:FlowChartShapes",           SID_DRAWTBX_CS_FLOWCHART,       CommandGroup::INSERT );
    2053           0 :     implDescribeSupportedFeature( ".uno:CalloutShapes",             SID_DRAWTBX_CS_CALLOUT,         CommandGroup::INSERT );
    2054           0 :     implDescribeSupportedFeature( ".uno:StarShapes",                SID_DRAWTBX_CS_STAR,            CommandGroup::INSERT );
    2055             : 
    2056             : 
    2057             :     // keys
    2058           0 :     implDescribeSupportedFeature( ".uno:Escape",                    SID_ESCAPE,                     CommandGroup::CONTROLS);
    2059             : 
    2060             :     // internal one
    2061           0 :     implDescribeSupportedFeature( ".uno:RPT_RPTHEADER_UNDO",            SID_REPORTHEADER_WITHOUT_UNDO);
    2062           0 :     implDescribeSupportedFeature( ".uno:RPT_RPTFOOTER_UNDO",            SID_REPORTFOOTER_WITHOUT_UNDO);
    2063           0 :     implDescribeSupportedFeature( ".uno:RPT_PGHEADER_UNDO",             SID_PAGEHEADER_WITHOUT_UNDO);
    2064           0 :     implDescribeSupportedFeature( ".uno:RPT_PGFOOTER_UNDO",             SID_PAGEFOOTER_WITHOUT_UNDO);
    2065           0 :     implDescribeSupportedFeature( ".uno:DBBackgroundColor",             SID_ATTR_CHAR_COLOR_BACKGROUND);
    2066           0 :     implDescribeSupportedFeature( ".uno:SID_GROUPHEADER",               SID_GROUPHEADER);
    2067           0 :     implDescribeSupportedFeature( ".uno:SID_GROUPHEADER_WITHOUT_UNDO",  SID_GROUPHEADER_WITHOUT_UNDO);
    2068           0 :     implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER",               SID_GROUPFOOTER);
    2069           0 :     implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER_WITHOUT_UNDO",  SID_GROUPFOOTER_WITHOUT_UNDO);
    2070           0 :     implDescribeSupportedFeature( ".uno:SID_GROUP_REMOVE",              SID_GROUP_REMOVE);
    2071           0 :     implDescribeSupportedFeature( ".uno:SID_GROUP_APPEND",              SID_GROUP_APPEND);
    2072           0 :     implDescribeSupportedFeature( ".uno:SID_ADD_CONTROL_PAIR",          SID_ADD_CONTROL_PAIR);
    2073           0 :     implDescribeSupportedFeature( ".uno:SplitPosition",                 SID_SPLIT_POSITION);
    2074           0 :     implDescribeSupportedFeature( ".uno:LastPropertyBrowserPage",       SID_PROPERTYBROWSER_LAST_PAGE);
    2075           0 :     implDescribeSupportedFeature( ".uno:Select",                        SID_SELECT);
    2076           0 :     implDescribeSupportedFeature( ".uno:InsertFunction",                SID_RPT_NEW_FUNCTION);
    2077           0 :     implDescribeSupportedFeature( ".uno:NextMark",                      SID_NEXT_MARK);
    2078           0 :     implDescribeSupportedFeature( ".uno:PrevMark",                      SID_PREV_MARK);
    2079           0 :     implDescribeSupportedFeature( ".uno:TerminateInplaceActivation",    SID_TERMINATE_INPLACEACTIVATION);
    2080           0 :     implDescribeSupportedFeature( ".uno:SelectAllLabels",               SID_SELECT_ALL_LABELS);
    2081           0 :     implDescribeSupportedFeature( ".uno:SelectAllEdits",                SID_SELECT_ALL_EDITS);
    2082           0 :     implDescribeSupportedFeature( ".uno:CollapseSection",           SID_COLLAPSE_SECTION);
    2083           0 :     implDescribeSupportedFeature( ".uno:ExpandSection",             SID_EXPAND_SECTION);
    2084           0 : }
    2085             : 
    2086           0 : void OReportController::impl_onModifyChanged()
    2087             : {
    2088             :     try
    2089             :     {
    2090           0 :         if ( m_xReportDefinition.is() )
    2091           0 :             m_xReportDefinition->setModified( impl_isModified() );
    2092           0 :         DBSubComponentController::impl_onModifyChanged();
    2093             :     }
    2094           0 :     catch(const uno::Exception&)
    2095             :     {
    2096             :         DBG_UNHANDLED_EXCEPTION();
    2097             :     }
    2098           0 : }
    2099             : 
    2100           0 : void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager)
    2101             : {
    2102           0 :     if ( _xLayoutManager.is() )
    2103             :     {
    2104             :         static const OUString s_sMenu[] = {
    2105             :              OUString("private:resource/statusbar/statusbar")
    2106             :             ,OUString("private:resource/toolbar/reportcontrols")
    2107             :             ,OUString("private:resource/toolbar/drawbar")
    2108             :             ,OUString("private:resource/toolbar/Formatting")
    2109             :             ,OUString("private:resource/toolbar/alignmentbar")
    2110             :             ,OUString("private:resource/toolbar/sectionalignmentbar")
    2111             :             ,OUString("private:resource/toolbar/resizebar")
    2112             :             ,OUString("private:resource/toolbar/sectionshrinkbar")
    2113           0 :         };
    2114           0 :         for (size_t i = 0; i< sizeof(s_sMenu)/sizeof(s_sMenu[0]); ++i)
    2115             :         {
    2116           0 :             _xLayoutManager->createElement( s_sMenu[i] );
    2117           0 :             _xLayoutManager->requestElement( s_sMenu[i] );
    2118             :         }
    2119             :     }
    2120           0 : }
    2121             : 
    2122           0 : void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _bShow)
    2123             : {
    2124           0 :     uno::Reference< report::XGroup> xGroup(_rEvent.Element,uno::UNO_QUERY);
    2125           0 :     if ( xGroup.is() )
    2126             :     {
    2127           0 :         SolarMutexGuard aSolarGuard;
    2128           0 :         ::osl::MutexGuard aGuard( getMutex() );
    2129           0 :         sal_Int32 nGroupPos = 0;
    2130           0 :         _rEvent.Accessor >>= nGroupPos;
    2131             : 
    2132           0 :         if ( _bShow )
    2133             :         {
    2134           0 :             xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
    2135           0 :             xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
    2136             :         }
    2137             :         else
    2138             :         {
    2139           0 :             xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
    2140           0 :             xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
    2141             :         }
    2142             : 
    2143           0 :         if ( xGroup->getHeaderOn() )
    2144             :         {
    2145           0 :             groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow);
    2146           0 :             if (_bShow)
    2147             :             {
    2148           0 :                 m_pReportControllerObserver->AddSection(xGroup->getHeader());
    2149             :             }
    2150             :             else
    2151             :             {
    2152           0 :                 m_pReportControllerObserver->RemoveSection(xGroup->getHeader());
    2153             :             }
    2154             :         }
    2155           0 :         if ( xGroup->getFooterOn() )
    2156             :         {
    2157           0 :             groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow);
    2158           0 :             if (_bShow)
    2159             :             {
    2160           0 :                 m_pReportControllerObserver->AddSection(xGroup->getFooter());
    2161             :             }
    2162             :             else
    2163             :             {
    2164           0 :                 m_pReportControllerObserver->RemoveSection(xGroup->getFooter());
    2165             :             }
    2166           0 :         }
    2167           0 :     }
    2168           0 : }
    2169             : 
    2170             : // ::container::XContainerListener
    2171           0 : void SAL_CALL OReportController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException, std::exception)
    2172             : {
    2173           0 :     notifyGroupSections(_rEvent,true);
    2174           0 : }
    2175             : 
    2176           0 : void SAL_CALL OReportController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException, std::exception)
    2177             : {
    2178           0 :     notifyGroupSections(_rEvent,false);
    2179           0 : }
    2180             : 
    2181           0 : void SAL_CALL OReportController::elementReplaced( const ContainerEvent& /*_rEvent*/ ) throw(RuntimeException, std::exception)
    2182             : {
    2183           0 :     SolarMutexGuard aSolarGuard;
    2184           0 :     ::osl::MutexGuard aGuard( getMutex() );
    2185           0 :     OSL_FAIL("Not yet implemented!");
    2186           0 : }
    2187             : 
    2188           0 : void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException, std::exception)
    2189             : {
    2190           0 :     SolarMutexGuard aSolarGuard;
    2191           0 :     ::osl::MutexGuard aGuard( getMutex() );
    2192             :     try
    2193             :     {
    2194           0 :         sal_Bool bShow = sal_False;
    2195           0 :         evt.NewValue >>= bShow;
    2196           0 :         if ( evt.Source == m_xReportDefinition )
    2197             :         {
    2198           0 :             if ( evt.PropertyName.equals( PROPERTY_REPORTHEADERON ) )
    2199             :             {
    2200           0 :                 const sal_uInt16 nPosition = m_xReportDefinition->getPageHeaderOn() ? 1 : 0;
    2201           0 :                 if ( bShow )
    2202             :                 {
    2203           0 :                     getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER,nPosition);
    2204           0 :                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportHeader());
    2205             :                 }
    2206             :                 else
    2207             :                 {
    2208           0 :                     getDesignView()->removeSection(nPosition);
    2209             :                 }
    2210             :             }
    2211           0 :             else if ( evt.PropertyName.equals( PROPERTY_REPORTFOOTERON ) )
    2212             :             {
    2213           0 :                 sal_uInt16 nPosition = getDesignView()->getSectionCount();
    2214           0 :                 if ( m_xReportDefinition->getPageFooterOn() )
    2215           0 :                     --nPosition;
    2216           0 :                 if ( bShow )
    2217             :                 {
    2218           0 :                     getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER,nPosition);
    2219           0 :                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportFooter());
    2220             :                 }
    2221             :                 else
    2222             :                 {
    2223           0 :                     getDesignView()->removeSection(nPosition - 1);
    2224             :                 }
    2225             :             }
    2226           0 :             else if ( evt.PropertyName.equals( PROPERTY_PAGEHEADERON ) )
    2227             :             {
    2228           0 :                 if ( bShow )
    2229             :                 {
    2230           0 :                     getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER,0);
    2231           0 :                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageHeader());
    2232             :                 }
    2233             :                 else
    2234             :                 {
    2235           0 :                     getDesignView()->removeSection(sal_uInt16(0));
    2236             :                 }
    2237             :             }
    2238           0 :             else if ( evt.PropertyName.equals( PROPERTY_PAGEFOOTERON ) )
    2239             :             {
    2240           0 :                 if ( bShow )
    2241             :                 {
    2242           0 :                     getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
    2243           0 :                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageFooter());
    2244             :                 }
    2245             :                 else
    2246             :                 {
    2247           0 :                     getDesignView()->removeSection(getDesignView()->getSectionCount() - 1);
    2248             :                 }
    2249             :             }
    2250           0 :             else if (   evt.PropertyName.equals( PROPERTY_COMMAND )
    2251           0 :                     ||  evt.PropertyName.equals( PROPERTY_COMMANDTYPE )
    2252           0 :                     ||  evt.PropertyName.equals( PROPERTY_ESCAPEPROCESSING )
    2253           0 :                     ||  evt.PropertyName.equals( PROPERTY_FILTER )
    2254             :                     )
    2255             :             {
    2256           0 :                 m_xColumns.clear();
    2257           0 :                 m_xHoldAlive.clear();
    2258           0 :                 InvalidateFeature(SID_FM_ADD_FIELD);
    2259           0 :                 if ( !getDesignView()->isAddFieldVisible() && isUiVisible() )
    2260           0 :                     getDesignView()->toggleAddField();
    2261             :             }
    2262             :             /// TODO: check what we need to notify here TitleHelper
    2263             :             /*else if (   evt.PropertyName.equals( PROPERTY_CAPTION ) )
    2264             :                 updateTitle();*/
    2265             :         }
    2266             :         else
    2267             :         {
    2268           0 :             uno::Reference< report::XGroup> xGroup(evt.Source,uno::UNO_QUERY);
    2269           0 :             if ( xGroup.is() )
    2270             :             {
    2271           0 :                 sal_Int32 nGroupPos = getGroupPosition(xGroup);
    2272             : 
    2273           0 :                 groupChange(xGroup,evt.PropertyName,nGroupPos,bShow);
    2274           0 :             }
    2275             :         }
    2276             :     }
    2277           0 :     catch(const uno::Exception&)
    2278             :     {
    2279             :         DBG_UNHANDLED_EXCEPTION();
    2280           0 :     }
    2281           0 : }
    2282             : 
    2283             : 
    2284           0 : void SAL_CALL OReportController::disposing( const lang::EventObject& Source ) throw(uno::RuntimeException, std::exception)
    2285             : {
    2286             :     // simply disambiguate
    2287           0 :     OReportController_BASE::disposing(Source);
    2288           0 : }
    2289             : 
    2290             : 
    2291           0 : static sal_uInt16 lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups
    2292             :                           ,sal_Int32 _nGroupPos
    2293             :                           ,::std::mem_fun_t<sal_Bool,OGroupHelper>&_pGroupMemberFunction)
    2294             : {
    2295           0 :     uno::Reference< report::XGroup> xGroup;
    2296           0 :     sal_uInt16 nNonVisibleGroups = 0;
    2297           0 :     sal_Int32 nCount = _xGroups->getCount();
    2298           0 :     for( sal_Int32 i = 0; i < _nGroupPos && i < nCount; ++i)
    2299             :     {
    2300           0 :         xGroup.set(_xGroups->getByIndex(i),uno::UNO_QUERY);
    2301             :         OSL_ENSURE(xGroup.is(),"Group is NULL! -> GPF");
    2302           0 :         OGroupHelper aGroupHelper(xGroup);
    2303           0 :         if ( !_pGroupMemberFunction(&aGroupHelper) )
    2304           0 :             ++nNonVisibleGroups;
    2305           0 :     }
    2306           0 :     return nNonVisibleGroups;
    2307             : }
    2308             : 
    2309           0 : void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGroup,const OUString& _sPropName,sal_Int32 _nGroupPos,bool _bShow)
    2310             : {
    2311           0 :     ::std::mem_fun_t<sal_Bool,OGroupHelper> pMemFun = ::std::mem_fun(&OGroupHelper::getHeaderOn);
    2312           0 :     ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader);
    2313           0 :     OUString sColor(DBGROUPHEADER);
    2314           0 :     sal_uInt16 nPosition = 0;
    2315           0 :     bool bHandle = false;
    2316           0 :     if ( _sPropName.equals( PROPERTY_HEADERON ) )
    2317             :     {
    2318           0 :         nPosition = m_xReportDefinition->getPageHeaderOn() ? (m_xReportDefinition->getReportHeaderOn() ? 2 : 1) : (m_xReportDefinition->getReportHeaderOn() ? 1 : 0);
    2319           0 :         nPosition += (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
    2320           0 :         bHandle = true;
    2321             :     }
    2322           0 :     else if ( _sPropName.equals( PROPERTY_FOOTERON ) )
    2323             :     {
    2324           0 :         pMemFun = ::std::mem_fun(&OGroupHelper::getFooterOn);
    2325           0 :         pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter);
    2326           0 :         nPosition = getDesignView()->getSectionCount();
    2327             : 
    2328           0 :         if ( m_xReportDefinition->getPageFooterOn() )
    2329           0 :             --nPosition;
    2330           0 :         if ( m_xReportDefinition->getReportFooterOn() )
    2331           0 :             --nPosition;
    2332           0 :         sColor = DBGROUPFOOTER;
    2333           0 :         nPosition -= (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
    2334           0 :         if ( !_bShow )
    2335           0 :             --nPosition;
    2336           0 :         bHandle = true;
    2337             :     }
    2338           0 :     if ( bHandle )
    2339             :     {
    2340           0 :         if ( _bShow )
    2341             :         {
    2342           0 :             OGroupHelper aGroupHelper(_xGroup);
    2343           0 :             getDesignView()->addSection(pMemFunSection(&aGroupHelper),sColor,nPosition);
    2344             :         }
    2345             :         else
    2346             :         {
    2347           0 :             getDesignView()->removeSection(nPosition);
    2348             :         }
    2349           0 :     }
    2350           0 : }
    2351             : 
    2352           0 : IMPL_LINK_NOARG(OReportController, OnClipboardChanged)
    2353             : {
    2354           0 :     OnInvalidateClipboard();
    2355           0 :     return 0;
    2356             : }
    2357             : 
    2358           0 : void OReportController::OnInvalidateClipboard()
    2359             : {
    2360           0 :     InvalidateFeature(SID_CUT);
    2361           0 :     InvalidateFeature(SID_COPY);
    2362           0 :     InvalidateFeature(SID_PASTE);
    2363           0 : }
    2364             : 
    2365           0 : void OReportController::openPageDialog(const uno::Reference<report::XSection>& _xSection)
    2366             : {
    2367           0 :     if ( !m_xReportDefinition.is() )
    2368           0 :         return;
    2369             : 
    2370             :     // UNO->ItemSet
    2371             :     static SfxItemInfo aItemInfos[] =
    2372             :     {
    2373             :         { SID_ATTR_LRSPACE,     SFX_ITEM_POOLABLE },
    2374             :         { SID_ATTR_ULSPACE,     SFX_ITEM_POOLABLE },
    2375             :         { SID_ATTR_PAGE,        SFX_ITEM_POOLABLE },
    2376             :         { SID_ATTR_PAGE_SIZE,   SFX_ITEM_POOLABLE },
    2377             :         { SID_ENUM_PAGE_MODE,   SFX_ITEM_POOLABLE },
    2378             :         { SID_PAPER_START,      SFX_ITEM_POOLABLE },
    2379             :         { SID_PAPER_END,        SFX_ITEM_POOLABLE },
    2380             :         { SID_ATTR_BRUSH,       SFX_ITEM_POOLABLE },
    2381             :         { SID_FLAG_TYPE,        SFX_ITEM_POOLABLE },
    2382             :         { SID_ATTR_METRIC,      SFX_ITEM_POOLABLE }
    2383             :     };
    2384             : 
    2385           0 :     MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
    2386           0 :     FieldUnit eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
    2387             :     SfxPoolItem* pDefaults[] =
    2388             :     {
    2389           0 :         new SvxLRSpaceItem(RPTUI_ID_LRSPACE),
    2390           0 :         new SvxULSpaceItem(RPTUI_ID_ULSPACE),
    2391           0 :         new SvxPageItem(RPTUI_ID_PAGE),
    2392           0 :         new SvxSizeItem(RPTUI_ID_SIZE),
    2393           0 :         new SfxAllEnumItem(RPTUI_ID_PAGE_MODE,SVX_PAGE_MODE_STANDARD),
    2394           0 :         new SfxAllEnumItem(RPTUI_ID_START,PAPER_A4),
    2395           0 :         new SfxAllEnumItem(RPTUI_ID_END,PAPER_E),
    2396           0 :         new SvxBrushItem(RPTUI_ID_BRUSH),
    2397           0 :         new SfxUInt16Item(RPTUI_ID_METRIC,static_cast<sal_uInt16>(eUserMetric))
    2398           0 :     };
    2399             : 
    2400             :     static const sal_uInt16 pRanges[] =
    2401             :     {
    2402             :         RPTUI_ID_LRSPACE,RPTUI_ID_BRUSH,
    2403             :         SID_ATTR_METRIC,SID_ATTR_METRIC,
    2404             :         0
    2405             :     };
    2406           0 :     SfxItemPool* pPool( new SfxItemPool(OUString("ReportPageProperties"), RPTUI_ID_LRSPACE,RPTUI_ID_METRIC, aItemInfos, pDefaults) );
    2407           0 :     pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );    // ripped, don't understand why
    2408           0 :     pPool->FreezeIdRanges();                        // the same
    2409             : 
    2410             :     try
    2411             :     {
    2412             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    2413           0 :         ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
    2414             :         SAL_WNODEPRECATED_DECLARATIONS_POP
    2415             :         // fill it
    2416           0 :         if ( _xSection.is() )
    2417           0 :             pDescriptor->Put(SvxBrushItem(::Color(_xSection->getBackColor()),RPTUI_ID_BRUSH));
    2418             :         else
    2419             :         {
    2420           0 :             pDescriptor->Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE))));
    2421             :             pDescriptor->Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN)
    2422           0 :                                             ,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE));
    2423           0 :             pDescriptor->Put(SvxULSpaceItem(static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN))
    2424           0 :                                             ,static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE));
    2425           0 :             pDescriptor->Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<sal_uInt16>(eUserMetric)));
    2426             : 
    2427           0 :             uno::Reference< style::XStyle> xPageStyle(getUsedStyle(m_xReportDefinition));
    2428           0 :             if ( xPageStyle.is() )
    2429             :             {
    2430           0 :                 SvxPageItem aPageItem(RPTUI_ID_PAGE);
    2431           0 :                 aPageItem.SetDescName(xPageStyle->getName());
    2432           0 :                 uno::Reference<beans::XPropertySet> xProp(xPageStyle,uno::UNO_QUERY_THROW);
    2433           0 :                 aPageItem.PutValue(xProp->getPropertyValue(PROPERTY_PAGESTYLELAYOUT),MID_PAGE_LAYOUT);
    2434           0 :                 aPageItem.SetLandscape(getStyleProperty<sal_Bool>(m_xReportDefinition,PROPERTY_ISLANDSCAPE));
    2435           0 :                 aPageItem.SetNumType((SvxNumType)getStyleProperty<sal_Int16>(m_xReportDefinition,PROPERTY_NUMBERINGTYPE));
    2436           0 :                 pDescriptor->Put(aPageItem);
    2437           0 :                 pDescriptor->Put(SvxBrushItem(::Color(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH));
    2438           0 :             }
    2439             :         }
    2440             : 
    2441             :         {   // want the dialog to be destroyed before our set
    2442           0 :             ORptPageDialog aDlg(getView(), pDescriptor.get(),_xSection.is()
    2443             :                 ? OString("BackgroundDialog")
    2444           0 :                 : OString("PageDialog"));
    2445           0 :             if (RET_OK == aDlg.Execute())
    2446             :             {
    2447             : 
    2448             :                 // ItemSet->UNO
    2449             :                 // UNO-properties
    2450           0 :                 const SfxItemSet* pSet = aDlg.GetOutputItemSet();
    2451           0 :                 if ( _xSection.is() )
    2452             :                 {
    2453             :                     const SfxPoolItem* pItem;
    2454           0 :                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,true,&pItem))
    2455           0 :                         _xSection->setBackColor(static_cast<const SvxBrushItem*>(pItem)->GetColor().GetColor());
    2456             :                 }
    2457             :                 else
    2458             :                 {
    2459           0 :                     uno::Reference< beans::XPropertySet> xProp(getUsedStyle(m_xReportDefinition),uno::UNO_QUERY_THROW);
    2460           0 :                     const OUString sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEPAGE));
    2461           0 :                     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    2462           0 :                     const SfxPoolItem* pItem = NULL;
    2463           0 :                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_SIZE,true,&pItem))
    2464             :                     {
    2465           0 :                         uno::Any aValue;
    2466           0 :                         static_cast<const SvxSizeItem*>(pItem)->QueryValue(aValue,MID_SIZE_SIZE);
    2467           0 :                         xProp->setPropertyValue(PROPERTY_PAPERSIZE,aValue);
    2468           0 :                         resetZoomType();
    2469             :                     }
    2470             : 
    2471           0 :                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_LRSPACE,true,&pItem))
    2472             :                     {
    2473           0 :                         Any aValue;
    2474           0 :                         static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_L_MARGIN);
    2475           0 :                         xProp->setPropertyValue(PROPERTY_LEFTMARGIN,aValue);
    2476           0 :                         static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_R_MARGIN);
    2477           0 :                         xProp->setPropertyValue(PROPERTY_RIGHTMARGIN,aValue);
    2478             :                     }
    2479           0 :                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_ULSPACE,true,&pItem))
    2480             :                     {
    2481           0 :                         xProp->setPropertyValue(PROPERTY_TOPMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()));
    2482           0 :                         xProp->setPropertyValue(PROPERTY_BOTTOMMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetLower()));
    2483             :                     }
    2484           0 :                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_PAGE,true,&pItem))
    2485             :                     {
    2486           0 :                         const SvxPageItem* pPageItem = static_cast<const SvxPageItem*>(pItem);
    2487           0 :                         xProp->setPropertyValue(PROPERTY_ISLANDSCAPE,uno::makeAny(static_cast<sal_Bool>(pPageItem->IsLandscape())));
    2488           0 :                         xProp->setPropertyValue(PROPERTY_NUMBERINGTYPE,uno::makeAny(static_cast<sal_Int16>(pPageItem->GetNumType())));
    2489           0 :                         uno::Any aValue;
    2490           0 :                         pPageItem->QueryValue(aValue,MID_PAGE_LAYOUT);
    2491           0 :                         xProp->setPropertyValue(PROPERTY_PAGESTYLELAYOUT,aValue);
    2492           0 :                         resetZoomType();
    2493             :                     }
    2494           0 :                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,true,&pItem))
    2495             :                     {
    2496           0 :                         ::Color aBackColor = static_cast<const SvxBrushItem*>(pItem)->GetColor();
    2497           0 :                         xProp->setPropertyValue(PROPERTY_BACKTRANSPARENT,uno::makeAny(aBackColor == COL_TRANSPARENT));
    2498           0 :                         xProp->setPropertyValue(PROPERTY_BACKCOLOR,uno::makeAny(aBackColor.GetColor()));
    2499           0 :                     }
    2500             :                 }
    2501           0 :             }
    2502           0 :         }
    2503             :     }
    2504           0 :     catch(const Exception&)
    2505             :     {
    2506             :         DBG_UNHANDLED_EXCEPTION();
    2507             :     }
    2508           0 :     SfxItemPool::Free(pPool);
    2509             : 
    2510           0 :     for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
    2511           0 :         delete pDefaults[i];
    2512             : 
    2513             : }
    2514             : 
    2515             : 
    2516           0 : sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel) throw( uno::RuntimeException, std::exception )
    2517             : {
    2518           0 :     ::osl::MutexGuard aGuard( getMutex() );
    2519             : 
    2520           0 :     uno::Reference< report::XReportDefinition > xReportDefinition( xModel, UNO_QUERY );
    2521           0 :     if ( !xReportDefinition.is() )
    2522           0 :         return sal_False;
    2523             : 
    2524           0 :     uno::Reference< document::XUndoManagerSupplier > xTestSuppUndo( xModel, UNO_QUERY );
    2525           0 :     if ( !xTestSuppUndo.is() )
    2526           0 :         return sal_False;
    2527             : 
    2528           0 :     m_xReportDefinition = xReportDefinition;
    2529           0 :     return sal_True;
    2530             : }
    2531             : 
    2532             : 
    2533           0 : void OReportController::openSortingAndGroupingDialog()
    2534             : {
    2535           0 :     if ( !m_xReportDefinition.is() )
    2536           0 :         return;
    2537           0 :     if ( !m_pGroupsFloater )
    2538             :     {
    2539           0 :         m_pGroupsFloater = new OGroupsSortingDialog(getView(),!isEditable(),this);
    2540           0 :         SvtViewOptions aDlgOpt( E_WINDOW, OUString::number( RID_GROUPS_SORTING) );
    2541           0 :         if ( aDlgOpt.Exists() )
    2542           0 :             m_pGroupsFloater->SetWindowState(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_ASCII_US));
    2543           0 :         m_pGroupsFloater->AddEventListener(LINK(this,OReportController,EventLstHdl));
    2544             :     }
    2545           0 :     else if ( isUiVisible() )
    2546           0 :         m_pGroupsFloater->Show(!m_pGroupsFloater->IsVisible());
    2547             : }
    2548             : 
    2549           0 : sal_Int32 OReportController::getGroupPosition(const uno::Reference< report::XGroup >& _xGroup)
    2550             : {
    2551           0 :     return rptui::getPositionInIndexAccess(m_xReportDefinition->getGroups().get(),_xGroup);
    2552             : }
    2553             : 
    2554             : 
    2555           0 : IMPL_LINK( OReportController, EventLstHdl, VclWindowEvent*, _pEvent )
    2556             : {
    2557           0 :     if ( _pEvent && _pEvent->GetId() == VCLEVENT_WINDOW_CLOSE )
    2558             :     {
    2559           0 :         InvalidateFeature(SID_SORTINGANDGROUPING);
    2560           0 :         InvalidateFeature(SID_FM_ADD_FIELD);
    2561           0 :         InvalidateFeature(SID_RPT_SHOWREPORTEXPLORER);
    2562             :     }
    2563           0 :     return 1L;
    2564             : }
    2565             : 
    2566           0 : void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHint)
    2567             : {
    2568           0 :     if (_rHint.ISA(DlgEdHint)
    2569           0 :         && (static_cast< DlgEdHint const & >(_rHint).GetKind()
    2570             :             == RPTUI_HINT_SELECTIONCHANGED))
    2571             :     {
    2572           0 :         const sal_Int32 nSelectionCount = getDesignView()->getMarkedObjectCount();
    2573           0 :         if ( m_nSelectionCount != nSelectionCount )
    2574             :         {
    2575           0 :             m_nSelectionCount = nSelectionCount;
    2576           0 :             InvalidateAll();
    2577             :         }
    2578           0 :         lang::EventObject aEvent(*this);
    2579             :         m_aSelectionListeners.forEach<view::XSelectionChangeListener>(
    2580           0 :             ::boost::bind(&view::XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent)));
    2581             : 
    2582             :     }
    2583           0 : }
    2584             : 
    2585           0 : void OReportController::executeMethodWithUndo(sal_uInt16 _nUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun)
    2586             : {
    2587           0 :     const OUString sUndoAction = ModuleRes(_nUndoStrId);
    2588           0 :     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    2589           0 :     _pMemfun( getDesignView() );
    2590           0 :     InvalidateFeature( SID_SAVEDOC );
    2591           0 :     InvalidateFeature( SID_UNDO );
    2592           0 : }
    2593             : 
    2594           0 : void OReportController::alignControlsWithUndo(sal_uInt16 _nUndoStrId,sal_Int32 _nControlModification,bool _bAlignAtSection)
    2595             : {
    2596           0 :     const OUString sUndoAction = ModuleRes(_nUndoStrId);
    2597           0 :     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    2598           0 :     getDesignView()->alignMarkedObjects(_nControlModification,_bAlignAtSection);
    2599           0 :     InvalidateFeature( SID_SAVEDOC );
    2600           0 :     InvalidateFeature( SID_UNDO );
    2601           0 : }
    2602             : 
    2603           0 : void OReportController::shrinkSectionBottom(uno::Reference<report::XSection> _xSection)
    2604             : {
    2605           0 :     const sal_Int32 nElements = _xSection->getCount();
    2606           0 :     if (nElements == 0)
    2607             :     {
    2608             :         // there are no elements
    2609           0 :         return;
    2610             :     }
    2611           0 :     const sal_Int32 nSectionHeight = _xSection->getHeight();
    2612           0 :     sal_Int32 nMaxPositionY = 0;
    2613           0 :     uno::Reference< report::XReportComponent> xReportComponent;
    2614             : 
    2615             :     // for every component get its Y-position and compare it to the current Y-position
    2616           0 :     for (int i=0;i<nElements;i++)
    2617             :     {
    2618           0 :         xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
    2619           0 :         const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
    2620           0 :         const sal_Int32 nReportComponentHeight = xReportComponent->getHeight();
    2621           0 :         const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight;
    2622           0 :         nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY);
    2623             :     }
    2624             :     // now we know the minimal Y-Position and maximal Y-Position
    2625             : 
    2626           0 :     if (nMaxPositionY > (nSectionHeight - 7) ) // Magic Number, we use a little bit less heights for right positioning
    2627             :     {
    2628             :         // the lowest position is already 0
    2629           0 :         return;
    2630             :     }
    2631           0 :     _xSection->setHeight(nMaxPositionY);
    2632             : }
    2633             : 
    2634           0 : void OReportController::shrinkSectionTop(uno::Reference<report::XSection> _xSection)
    2635             : {
    2636           0 :     const sal_Int32 nElements = _xSection->getCount();
    2637           0 :     if (nElements == 0)
    2638             :     {
    2639             :         // there are no elements
    2640           0 :         return;
    2641             :     }
    2642             : 
    2643           0 :     const sal_Int32 nSectionHeight = _xSection->getHeight();
    2644           0 :     sal_Int32 nMinPositionY = nSectionHeight;
    2645           0 :     uno::Reference< report::XReportComponent> xReportComponent;
    2646             : 
    2647             :     // for every component get its Y-position and compare it to the current Y-position
    2648           0 :     for (int i=0;i<nElements;i++)
    2649             :     {
    2650           0 :         xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
    2651           0 :         const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
    2652           0 :         nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY);
    2653             :     }
    2654             :     // now we know the minimal Y-Position and maximal Y-Position
    2655           0 :     if (nMinPositionY == 0)
    2656             :     {
    2657             :         // the lowest position is already 0
    2658           0 :         return;
    2659             :     }
    2660           0 :     for (int i=0;i<nElements;i++)
    2661             :     {
    2662           0 :         xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
    2663           0 :         const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
    2664           0 :         const sal_Int32 nNewPositionY = nReportComponentPositionY - nMinPositionY;
    2665           0 :         xReportComponent->setPositionY(nNewPositionY);
    2666             :     }
    2667           0 :     const sal_Int32 nNewSectionHeight = nSectionHeight - nMinPositionY;
    2668           0 :     _xSection->setHeight(nNewSectionHeight);
    2669             : }
    2670             : 
    2671           0 : void OReportController::shrinkSection(sal_uInt16 _nUndoStrId, uno::Reference<report::XSection> _xSection, sal_Int32 _nSid)
    2672             : {
    2673           0 :     if ( _xSection.is() )
    2674             :     {
    2675           0 :         const OUString sUndoAction = ModuleRes(_nUndoStrId);
    2676           0 :         UndoContext aUndoContext( getUndoManager(), sUndoAction );
    2677             : 
    2678           0 :         if (_nSid == SID_SECTION_SHRINK)
    2679             :         {
    2680           0 :             shrinkSectionTop(_xSection);
    2681           0 :             shrinkSectionBottom(_xSection);
    2682             :         }
    2683           0 :         else if (_nSid == SID_SECTION_SHRINK_TOP)
    2684             :         {
    2685           0 :             shrinkSectionTop(_xSection);
    2686             :         }
    2687           0 :         else if (_nSid == SID_SECTION_SHRINK_BOTTOM)
    2688             :         {
    2689           0 :             shrinkSectionBottom(_xSection);
    2690           0 :         }
    2691             :     }
    2692             : 
    2693           0 :     InvalidateFeature( SID_SAVEDOC );
    2694           0 :     InvalidateFeature( SID_UNDO );
    2695           0 : }
    2696             : 
    2697             : 
    2698           0 : uno::Any SAL_CALL OReportController::getViewData(void) throw( uno::RuntimeException, std::exception )
    2699             : {
    2700           0 :     ::osl::MutexGuard aGuard( getMutex() );
    2701             : 
    2702             :     sal_Int32 nCommandIDs[] =
    2703             :     {
    2704             :         SID_GRID_VISIBLE,
    2705             :         SID_GRID_USE,
    2706             :         SID_HELPLINES_MOVE,
    2707             :         SID_RULER,
    2708             :         SID_SHOW_PROPERTYBROWSER,
    2709             :         SID_PROPERTYBROWSER_LAST_PAGE,
    2710             :         SID_SPLIT_POSITION
    2711           0 :     };
    2712             : 
    2713           0 :     ::comphelper::NamedValueCollection aCommandProperties;
    2714           0 :     for ( size_t i=0; i < sizeof (nCommandIDs) / sizeof (nCommandIDs[0]); ++i )
    2715             :     {
    2716           0 :         const FeatureState aFeatureState = GetState( nCommandIDs[i] );
    2717             : 
    2718           0 :         OUString sCommandURL( getURLForId( nCommandIDs[i] ).Main );
    2719             :         OSL_ENSURE( sCommandURL.startsWith( ".uno:" ), "OReportController::getViewData: illegal command URL!" );
    2720           0 :         sCommandURL = sCommandURL.copy( 5 );
    2721             : 
    2722           0 :         Any aCommandState;
    2723           0 :         if ( !!aFeatureState.bChecked )
    2724           0 :             aCommandState <<= (*aFeatureState.bChecked) ? sal_True : sal_False;
    2725           0 :         else if ( aFeatureState.aValue.hasValue() )
    2726           0 :             aCommandState = aFeatureState.aValue;
    2727             : 
    2728           0 :         aCommandProperties.put( sCommandURL, aCommandState );
    2729           0 :     }
    2730             : 
    2731           0 :     ::comphelper::NamedValueCollection aViewData;
    2732           0 :     aViewData.put( "CommandProperties", aCommandProperties.getPropertyValues() );
    2733             : 
    2734           0 :     if ( getDesignView() )
    2735             :     {
    2736           0 :         ::std::vector<sal_uInt16> aCollapsedPositions;
    2737           0 :         getDesignView()->fillCollapsedSections(aCollapsedPositions);
    2738           0 :         if ( !aCollapsedPositions.empty() )
    2739             :         {
    2740           0 :             uno::Sequence<beans::PropertyValue> aCollapsedSections(aCollapsedPositions.size());
    2741           0 :             beans::PropertyValue* pCollapsedIter = aCollapsedSections.getArray();
    2742           0 :             ::std::vector<sal_uInt16>::iterator aIter = aCollapsedPositions.begin();
    2743           0 :             ::std::vector<sal_uInt16>::iterator aEnd = aCollapsedPositions.end();
    2744           0 :             for (sal_Int32 i = 1; aIter != aEnd ; ++aIter,++pCollapsedIter,++i)
    2745             :             {
    2746           0 :                 pCollapsedIter->Name = PROPERTY_SECTION + OUString::number(i);
    2747           0 :                 pCollapsedIter->Value <<= static_cast<sal_Int32>(*aIter);
    2748             :             }
    2749             : 
    2750           0 :             aViewData.put( "CollapsedSections", aCollapsedSections );
    2751             :         }
    2752             : 
    2753           0 :         ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
    2754           0 :         if ( pSectionWindow.get() )
    2755             :         {
    2756           0 :             aViewData.put( "MarkedSection", (sal_Int32)pSectionWindow->getReportSection().getPage()->GetPageNum() );
    2757           0 :         }
    2758             :     }
    2759             : 
    2760           0 :     aViewData.put( "ZoomFactor", m_nZoomValue );
    2761           0 :     return uno::makeAny( aViewData.getPropertyValues() );
    2762             : }
    2763             : 
    2764           0 : void SAL_CALL OReportController::restoreViewData(const uno::Any& i_data) throw( uno::RuntimeException, std::exception )
    2765             : {
    2766           0 :     ::osl::MutexGuard aGuard( getMutex() );
    2767             : 
    2768             :     try
    2769             :     {
    2770           0 :         const ::comphelper::NamedValueCollection aViewData( i_data );
    2771             : 
    2772           0 :         m_aCollapsedSections = aViewData.getOrDefault( "CollapsedSections", m_aCollapsedSections );
    2773           0 :         m_nPageNum = aViewData.getOrDefault( "MarkedSection", m_nPageNum );
    2774           0 :         m_nZoomValue = aViewData.getOrDefault( "ZoomFactor", m_nZoomValue );
    2775             :         // TODO: setting those 3 members is not enough - in theory, restoreViewData can be called when the
    2776             :         // view is fully alive, so we need to reflect those 3 values in the view.
    2777             :         // (At the moment, the method is called only during construction phase)
    2778             : 
    2779             : 
    2780           0 :         ::comphelper::NamedValueCollection aCommandProperties( aViewData.get( "CommandProperties" ) );
    2781           0 :         const ::std::vector< OUString > aCommandNames( aCommandProperties.getNames() );
    2782             : 
    2783           0 :         for (   ::std::vector< OUString >::const_iterator commandName = aCommandNames.begin();
    2784           0 :                 commandName != aCommandNames.end();
    2785             :                 ++commandName
    2786             :             )
    2787             :         {
    2788           0 :             const Any& rCommandValue = aCommandProperties.get( *commandName );
    2789           0 :             if ( !rCommandValue.hasValue() )
    2790           0 :                 continue;
    2791             : 
    2792           0 :             if ( getView() )
    2793             :             {
    2794           0 :                 util::URL aCommand;
    2795           0 :                 aCommand.Complete = ".uno:" + *commandName;
    2796             : 
    2797           0 :                 Sequence< PropertyValue > aCommandArgs(1);
    2798           0 :                 aCommandArgs[0].Name = "Value";
    2799           0 :                 aCommandArgs[0].Value = rCommandValue;
    2800             : 
    2801           0 :                 executeUnChecked( aCommand, aCommandArgs );
    2802             :             }
    2803             :             else
    2804             :             {
    2805           0 :                 if ( *commandName == "ShowRuler" )
    2806           0 :                     OSL_VERIFY( rCommandValue >>= m_bShowRuler );
    2807           0 :                 else if ( *commandName == "HelplinesMove" )
    2808           0 :                     OSL_VERIFY( rCommandValue >>= m_bHelplinesMove );
    2809           0 :                 else if ( *commandName == "GridVisible" )
    2810           0 :                     OSL_VERIFY( rCommandValue >>= m_bGridVisible );
    2811           0 :                 else if ( *commandName == "GridUse" )
    2812           0 :                     OSL_VERIFY( rCommandValue >>= m_bGridUse );
    2813           0 :                 else if ( *commandName == "ControlProperties" )
    2814           0 :                     OSL_VERIFY( rCommandValue >>= m_bShowProperties );
    2815           0 :                 else if ( *commandName == "LastPropertyBrowserPage" )
    2816           0 :                     OSL_VERIFY( rCommandValue >>= m_sLastActivePage );
    2817           0 :                 else if ( *commandName == "SplitPosition" )
    2818           0 :                     OSL_VERIFY( rCommandValue >>= m_nSplitPos );
    2819             :             }
    2820           0 :         }
    2821             :     }
    2822           0 :     catch(const IllegalArgumentException&)
    2823             :     {
    2824             :         DBG_UNHANDLED_EXCEPTION();
    2825           0 :     }
    2826           0 : }
    2827             : 
    2828           0 : void OReportController::updateFloater()
    2829             : {
    2830           0 :        if ( m_pGroupsFloater && m_pGroupsFloater->IsVisible() )
    2831           0 :         m_pGroupsFloater->UpdateData();
    2832           0 : }
    2833             : 
    2834             : 
    2835           0 : Reference<XFrame> OReportController::getXFrame()
    2836             : {
    2837           0 :     if ( !m_xFrameLoader.is() )
    2838             :     {
    2839           0 :         m_xFrameLoader.set( frame::Desktop::create(m_xContext) );
    2840             :     }
    2841           0 :     const sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
    2842           0 :     const OUString sTarget("_blank");
    2843           0 :     Reference<XFrame> xFrame = m_xFrameLoader->findFrame(sTarget,nFrameSearchFlag);
    2844           0 :     return xFrame;
    2845             : }
    2846             : 
    2847             : 
    2848           0 : uno::Reference<frame::XModel> OReportController::executeReport()
    2849             : {
    2850             :     OSL_ENSURE(m_xReportDefinition.is(),"Where is my report?");
    2851             : 
    2852           0 :     uno::Reference<frame::XModel> xModel;
    2853           0 :     if ( m_xReportDefinition.is() )
    2854             :     {
    2855           0 :         sal_uInt16 nErrorId = RID_ERR_NO_COMMAND;
    2856           0 :         bool bEnabled = !m_xReportDefinition->getCommand().isEmpty();
    2857           0 :         if ( bEnabled )
    2858             :         {
    2859           0 :             bEnabled = false;
    2860           0 :             const sal_uInt16 nCount = m_aReportModel->GetPageCount();
    2861           0 :             sal_uInt16 i = 0;
    2862           0 :             for (; i < nCount && !bEnabled ; ++i)
    2863             :             {
    2864           0 :                 const SdrPage* pPage = m_aReportModel->GetPage(i);
    2865           0 :                 bEnabled = pPage->GetObjCount() != 0;
    2866             :             }
    2867           0 :             if ( !bEnabled )
    2868           0 :                 nErrorId = RID_ERR_NO_OBJECTS;
    2869             :         }
    2870             : 
    2871           0 :         dbtools::SQLExceptionInfo aInfo;
    2872           0 :         if ( !bEnabled )
    2873             :         {
    2874           0 :             sdb::SQLContext aFirstMessage;
    2875           0 :             OUString sInfo = ModuleRes( nErrorId );
    2876           0 :             aFirstMessage.Message = sInfo;
    2877           0 :             aInfo = aFirstMessage;
    2878           0 :             if ( isEditable() )
    2879             :             {
    2880           0 :                 sal_uInt16 nCommand = 0;
    2881           0 :                 if ( nErrorId == RID_ERR_NO_COMMAND )
    2882             :                 {
    2883           0 :                     if ( !m_bShowProperties )
    2884           0 :                         executeUnChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue>());
    2885             : 
    2886           0 :                     m_sLastActivePage = "Data";
    2887           0 :                     getDesignView()->setCurrentPage(m_sLastActivePage);
    2888           0 :                     nCommand = SID_SELECT_REPORT;
    2889             :                 }
    2890           0 :                 else if ( getDesignView() && !getDesignView()->isAddFieldVisible() )
    2891             :                 {
    2892           0 :                     nCommand = SID_FM_ADD_FIELD;
    2893             :                 }
    2894           0 :                 if ( nCommand )
    2895             :                 {
    2896           0 :                     uno::Sequence< beans::PropertyValue> aArgs;
    2897           0 :                     executeUnChecked(nCommand,aArgs);
    2898             :                 }
    2899           0 :             }
    2900             :         }
    2901             :         else
    2902             :         {
    2903           0 :             m_bInGeneratePreview = true;
    2904             :             try
    2905             :             {
    2906           0 :                 WaitObject aWait(getView()); // cursor
    2907           0 :                 if ( !m_xReportEngine.is() )
    2908           0 :                     m_xReportEngine.set( report::ReportEngine::create(m_xContext) );
    2909           0 :                 m_xReportEngine->setReportDefinition(m_xReportDefinition);
    2910           0 :                 m_xReportEngine->setActiveConnection(getConnection());
    2911           0 :                 Reference<XFrame> xFrame = getXFrame();
    2912           0 :                 xModel = m_xReportEngine->createDocumentAlive(xFrame);
    2913             :             }
    2914           0 :             catch(const sdbc::SQLException&)
    2915             :             {   // SQLExceptions and derived exceptions must not be translated
    2916           0 :                 aInfo = ::cppu::getCaughtException();
    2917             :             }
    2918           0 :             catch(const uno::Exception& e)
    2919             :             {
    2920           0 :                 uno::Any aCaughtException( ::cppu::getCaughtException() );
    2921             : 
    2922             :                 // our first message says: we caught an exception
    2923           0 :                 sdb::SQLContext aFirstMessage;
    2924           0 :                 OUString sInfo(ModuleRes(RID_STR_CAUGHT_FOREIGN_EXCEPTION).toString());
    2925           0 :                 sInfo = sInfo.replaceAll("$type$", aCaughtException.getValueTypeName());
    2926           0 :                 aFirstMessage.Message = sInfo;
    2927             : 
    2928             :                 // our second message: the message of the exception we caught
    2929           0 :                 sdbc::SQLException aSecondMessage;
    2930           0 :                 aSecondMessage.Message = e.Message;
    2931           0 :                 aSecondMessage.Context = e.Context;
    2932             : 
    2933             :                 // maybe our third message: the message which is wrapped in the exception we caught
    2934           0 :                 sdbc::SQLException aThirdMessage;
    2935           0 :                 lang::WrappedTargetException aWrapped;
    2936           0 :                 if ( aCaughtException >>= aWrapped )
    2937             :                 {
    2938           0 :                     aThirdMessage.Message = aWrapped.Message;
    2939           0 :                     aThirdMessage.Context = aWrapped.Context;
    2940             :                 }
    2941             : 
    2942           0 :                 if ( !aThirdMessage.Message.isEmpty() )
    2943           0 :                     aSecondMessage.NextException <<= aThirdMessage;
    2944           0 :                 aFirstMessage.NextException <<= aSecondMessage;
    2945             : 
    2946           0 :                 aInfo = aFirstMessage;
    2947             :             }
    2948           0 :             if (aInfo.isValid())
    2949             :             {
    2950           0 :                 const OUString suSQLContext = ModuleRes( RID_STR_COULD_NOT_CREATE_REPORT );
    2951           0 :                 aInfo.prepend(suSQLContext);
    2952             :             }
    2953           0 :             m_bInGeneratePreview = false;
    2954             :         }
    2955             : 
    2956           0 :         if (aInfo.isValid())
    2957             :         {
    2958           0 :             showError(aInfo);
    2959           0 :         }
    2960             :     }
    2961           0 :     return xModel;
    2962             : }
    2963             : 
    2964           0 : uno::Reference< frame::XModel >  SAL_CALL OReportController::getModel(void) throw( uno::RuntimeException, std::exception )
    2965             : {
    2966           0 :     return m_xReportDefinition.get();
    2967             : }
    2968             : 
    2969           0 : uno::Reference< sdbc::XRowSet > OReportController::getRowSet()
    2970             : {
    2971             :     OSL_PRECOND( m_xReportDefinition.is(), "OReportController::getRowSet: no report definition?!" );
    2972             : 
    2973           0 :     if ( m_xRowSet.is() || !m_xReportDefinition.is() )
    2974           0 :         return m_xRowSet;
    2975             : 
    2976             :     try
    2977             :     {
    2978             :         uno::Reference< sdbc::XRowSet > xRowSet(
    2979           0 :             getORB()->getServiceManager()->createInstanceWithContext("com.sun.star.sdb.RowSet", getORB()),
    2980           0 :             uno::UNO_QUERY );
    2981           0 :         uno::Reference< beans::XPropertySet> xRowSetProp( xRowSet, uno::UNO_QUERY_THROW );
    2982             : 
    2983           0 :         xRowSetProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, uno::makeAny( getConnection() ) );
    2984           0 :         xRowSetProp->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( sal_True ) );
    2985             : 
    2986           0 :         ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
    2987           0 :         TPropertyNamePair aPropertyMediation;
    2988           0 :         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMAND, TPropertyConverter(PROPERTY_COMMAND,aNoConverter) ) );
    2989           0 :         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMANDTYPE, TPropertyConverter(PROPERTY_COMMANDTYPE,aNoConverter) ) );
    2990           0 :         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_ESCAPEPROCESSING, TPropertyConverter(PROPERTY_ESCAPEPROCESSING,aNoConverter) ) );
    2991           0 :         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_FILTER, TPropertyConverter(PROPERTY_FILTER,aNoConverter) ) );
    2992             : 
    2993           0 :         m_xRowSetMediator = new OPropertyMediator( m_xReportDefinition.get(), xRowSetProp, aPropertyMediation );
    2994           0 :         m_xRowSet = xRowSet;
    2995             :     }
    2996           0 :     catch(const uno::Exception&)
    2997             :     {
    2998             :         DBG_UNHANDLED_EXCEPTION();
    2999             :     }
    3000             : 
    3001           0 :     return m_xRowSet;
    3002             : }
    3003             : 
    3004           0 : void OReportController::insertGraphic()
    3005             : {
    3006           0 :     const OUString sTitle(ModuleRes(RID_STR_IMPORT_GRAPHIC));
    3007             :     // build some arguments for the upcoming dialog
    3008             :     try
    3009             :     {
    3010           0 :         uno::Reference< report::XSection> xSection = getDesignView()->getCurrentSection();
    3011           0 :         ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, SFXWB_GRAPHIC );
    3012           0 :         aDialog.SetTitle( sTitle );
    3013             : 
    3014           0 :         uno::Reference< ui::dialogs::XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY_THROW);
    3015           0 :         xController->setValue(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, css::uno::Any(true));
    3016           0 :         xController->enableControl(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False/*sal_True*/);
    3017           0 :         xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, css::uno::Any(true) );
    3018             : 
    3019           0 :         if ( ERRCODE_NONE == aDialog.Execute() )
    3020             :         {
    3021           0 :             sal_Bool bLink = sal_True;
    3022           0 :             xController->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bLink;
    3023           0 :             uno::Sequence<beans::PropertyValue> aArgs(2);
    3024           0 :             aArgs[0].Name = PROPERTY_IMAGEURL;
    3025           0 :             aArgs[0].Value <<= OUString(aDialog.GetPath());
    3026           0 :             aArgs[1].Name = PROPERTY_PRESERVEIRI;
    3027           0 :             aArgs[1].Value <<= bLink;
    3028           0 :             createControl(aArgs,xSection,OUString(),OBJ_DLG_IMAGECONTROL);
    3029           0 :         }
    3030             :     }
    3031           0 :     catch(const Exception&)
    3032             :     {
    3033             :         DBG_UNHANDLED_EXCEPTION();
    3034           0 :     }
    3035           0 : }
    3036             : 
    3037           0 : ::boost::shared_ptr<rptui::OReportModel> OReportController::getSdrModel() const
    3038             : {
    3039           0 :     return m_aReportModel;
    3040             : }
    3041             : 
    3042           0 : sal_Bool SAL_CALL OReportController::select( const Any& aSelection ) throw (IllegalArgumentException, RuntimeException, std::exception)
    3043             : {
    3044           0 :     ::osl::MutexGuard aGuard( getMutex() );
    3045           0 :     sal_Bool bRet = sal_True;
    3046           0 :     if ( getDesignView() )
    3047             :     {
    3048           0 :         getDesignView()->unmarkAllObjects(NULL);
    3049           0 :         getDesignView()->SetMode(RPTUI_SELECT);
    3050             : 
    3051           0 :         uno::Sequence< uno::Reference<report::XReportComponent> > aElements;
    3052           0 :         if ( aSelection >>= aElements )
    3053             :         {
    3054           0 :             if ( aElements.getLength() > 0 )
    3055           0 :                 getDesignView()->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY));
    3056           0 :             getDesignView()->setMarked(aElements,sal_True);
    3057             :         }
    3058             :         else
    3059             :         {
    3060           0 :             uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY);
    3061           0 :             uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY);
    3062           0 :             if ( xProp.is() )
    3063             :             {
    3064           0 :                 getDesignView()->showProperties(xObject);
    3065           0 :                 aElements.realloc(1);
    3066           0 :                 aElements[0] = xProp;
    3067           0 :                 getDesignView()->setMarked(aElements,sal_True);
    3068             :             }
    3069             :             else
    3070             :             {
    3071           0 :                 uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY);
    3072           0 :                 if ( !xSection.is() && xObject.is() )
    3073           0 :                     getDesignView()->showProperties(xObject);
    3074           0 :                 getDesignView()->setMarked(xSection,xSection.is());
    3075           0 :             }
    3076             :         }
    3077           0 :         InvalidateAll();
    3078             :     }
    3079           0 :     return bRet;
    3080             : }
    3081             : 
    3082           0 : Any SAL_CALL OReportController::getSelection(  ) throw (RuntimeException, std::exception)
    3083             : {
    3084           0 :     ::osl::MutexGuard aGuard( getMutex() );
    3085           0 :     Any aRet;
    3086           0 :     if ( getDesignView() )
    3087             :     {
    3088           0 :         aRet = getDesignView()->getCurrentlyShownProperty();
    3089           0 :         if ( !aRet.hasValue() )
    3090           0 :             aRet <<= getDesignView()->getCurrentSection();
    3091             :     }
    3092           0 :     return aRet;
    3093             : }
    3094             : 
    3095           0 : void SAL_CALL OReportController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException, std::exception)
    3096             : {
    3097           0 :     m_aSelectionListeners.addInterface( _Listener );
    3098           0 : }
    3099             : 
    3100           0 : void SAL_CALL OReportController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException, std::exception)
    3101             : {
    3102           0 :     m_aSelectionListeners.removeInterface( _Listener );
    3103           0 : }
    3104             : 
    3105           0 : void OReportController::createNewFunction(const uno::Any& _aValue)
    3106             : {
    3107           0 :     uno::Reference< container::XIndexContainer> xFunctions(_aValue,uno::UNO_QUERY_THROW);
    3108           0 :     const OUString sNewName = ModuleRes(RID_STR_FUNCTION);
    3109           0 :     uno::Reference< report::XFunction> xFunction(report::Function::create(m_xContext));
    3110           0 :     xFunction->setName(sNewName);
    3111             :     // the call below will also create an undo action -> listener
    3112           0 :     xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(xFunction));
    3113           0 : }
    3114             : 
    3115           0 : IMPL_LINK( OReportController, OnExecuteReport, void* ,/*_pMemfun*/)
    3116             : {
    3117           0 :     executeReport();
    3118           0 :     return 0L;
    3119             : }
    3120             : 
    3121           0 : void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,const uno::Reference< report::XSection>& _xSection,const OUString& _sFunction,sal_uInt16 _nObjectId)
    3122             : {
    3123           0 :     SequenceAsHashMap aMap(_aArgs);
    3124           0 :     getDesignView()->setMarked(_xSection ,sal_True);
    3125           0 :     ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
    3126           0 :     if ( !pSectionWindow )
    3127           0 :         return;
    3128             : 
    3129             :     OSL_ENSURE(pSectionWindow->getReportSection().getSection() == _xSection,"Invalid section after marking the corrct one.");
    3130             : 
    3131           0 :     sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
    3132           0 :     const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
    3133           0 :     const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
    3134           0 :     awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
    3135           0 :     if ( aPos.X < nLeftMargin )
    3136           0 :         aPos.X = nLeftMargin;
    3137             : 
    3138           0 :     SdrObject* pNewControl = NULL;
    3139           0 :     uno::Reference< report::XReportComponent> xShapeProp;
    3140           0 :     if ( _nObjectId == OBJ_CUSTOMSHAPE )
    3141             :     {
    3142           0 :         pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() );
    3143           0 :         xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY);
    3144           0 :         OUString sCustomShapeType = getDesignView()->GetInsertObjString();
    3145           0 :         if ( sCustomShapeType.isEmpty() )
    3146           0 :             sCustomShapeType = "diamond";
    3147           0 :         pSectionWindow->getReportSection().createDefault(sCustomShapeType,pNewControl);
    3148           0 :         pNewControl->SetLogicRect(Rectangle(3000,500,6000,3500)); // switch height and width
    3149             :     }
    3150           0 :     else if ( _nObjectId == OBJ_OLE2 || OBJ_DLG_SUBREPORT == _nObjectId  )
    3151             :     {
    3152           0 :         pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() );
    3153             : 
    3154           0 :         pNewControl->SetLogicRect(Rectangle(3000,500,8000,5500)); // switch height and width
    3155           0 :         xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW);
    3156           0 :         OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl);
    3157           0 :         if ( pObj && !pObj->IsEmpty() )
    3158             :         {
    3159           0 :             pObj->initializeChart(getModel());
    3160           0 :         }
    3161             :     }
    3162             :     else
    3163             :     {
    3164           0 :         SdrUnoObj* pLabel( NULL );
    3165           0 :         SdrUnoObj* pControl( NULL );
    3166           0 :         FmFormView::createControlLabelPair( getDesignView()
    3167             :                             ,nLeftMargin,0
    3168             :                             ,NULL,NULL,_nObjectId,OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT,
    3169           0 :                          NULL,pSectionWindow->getReportSection().getPage(),m_aReportModel.get(),
    3170           0 :                          pLabel,pControl);
    3171           0 :         delete pLabel;
    3172             : 
    3173           0 :         pNewControl = pControl;
    3174           0 :         OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl);
    3175             :         assert(pObj);
    3176           0 :         if(pObj)
    3177             :         {
    3178           0 :             uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY);
    3179           0 :             xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY);
    3180           0 :             uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
    3181           0 :             uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
    3182             : 
    3183             :             const OUString sProps[] = {   OUString(PROPERTY_NAME)
    3184             :                                           ,OUString(PROPERTY_FONTDESCRIPTOR)
    3185             :                                           ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
    3186             :                                           ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
    3187             :                                           ,OUString(PROPERTY_ORIENTATION)
    3188             :                                           ,OUString(PROPERTY_BORDER)
    3189             :                                           ,OUString(PROPERTY_FORMATSSUPPLIER)
    3190             :                                           ,OUString(PROPERTY_BACKGROUNDCOLOR)
    3191           0 :             };
    3192           0 :             for(size_t i = 0; i < sizeof (sProps) / sizeof (sProps[0]); ++i)
    3193             :             {
    3194           0 :                 if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) )
    3195           0 :                     xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i]));
    3196             :             }
    3197             : 
    3198           0 :             if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
    3199           0 :                 xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
    3200             : 
    3201             : 
    3202           0 :             if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && !_sFunction.isEmpty() )
    3203             :             {
    3204           0 :                 ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction );
    3205           0 :                 xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) );
    3206             :             }
    3207             : 
    3208           0 :             sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0));
    3209           0 :             if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
    3210           0 :                 xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) );
    3211             : 
    3212           0 :             OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,OUString());
    3213           0 :             if ( !sUrl.isEmpty() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) )
    3214           0 :                 xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) );
    3215             : 
    3216           0 :             pObj->CreateMediator(sal_True);
    3217             : 
    3218           0 :             if ( _nObjectId == OBJ_DLG_FIXEDTEXT ) // special case for fixed text
    3219           0 :                 xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj)));
    3220           0 :             else if ( _nObjectId == OBJ_DLG_VFIXEDLINE )
    3221             :             {
    3222           0 :                 awt::Size aOlSize = xShapeProp->getSize();
    3223           0 :                 xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width
    3224           0 :             }
    3225             :         }
    3226             :     }
    3227             : 
    3228           0 :     const sal_Int32 nShapeWidth = aMap.getUnpackedValueOrDefault(PROPERTY_WIDTH,xShapeProp->getWidth());
    3229           0 :     if ( nShapeWidth != xShapeProp->getWidth() )
    3230           0 :         xShapeProp->setWidth( nShapeWidth );
    3231             : 
    3232           0 :     const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
    3233           0 :     if ( bChangedPos )
    3234           0 :         aPos.X = nPaperWidth - nShapeWidth;
    3235           0 :     xShapeProp->setPosition(aPos);
    3236             : 
    3237           0 :     correctOverlapping(pNewControl,pSectionWindow->getReportSection());
    3238             : }
    3239             : 
    3240           0 : void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs)
    3241             : {
    3242           0 :     getDesignView()->unmarkAllObjects(NULL);
    3243             : 
    3244           0 :     const OUString sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL));
    3245           0 :     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    3246             : 
    3247           0 :     SequenceAsHashMap aMap(_aArgs);
    3248           0 :     aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0)));
    3249             : 
    3250           0 :     uno::Reference< report::XSection> xSection = aMap.getUnpackedValueOrDefault(PROPERTY_SECTION,uno::Reference< report::XSection>());
    3251           0 :     OUString sFunction;
    3252             : 
    3253           0 :     sal_Bool bDate = aMap.getUnpackedValueOrDefault(PROPERTY_DATE_STATE,sal_False);
    3254           0 :     if ( bDate )
    3255             :     {
    3256           0 :         sFunction = "TODAY()";
    3257           0 :         createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
    3258             :     }
    3259           0 :     sal_Bool bTime = aMap.getUnpackedValueOrDefault(PROPERTY_TIME_STATE,sal_False);
    3260           0 :     if ( bTime )
    3261             :     {
    3262           0 :         sFunction = "TIMEVALUE(NOW())";
    3263           0 :         aMap[PROPERTY_FORMATKEY] <<= aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYTIME,sal_Int32(0));
    3264           0 :         createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
    3265           0 :     }
    3266           0 : }
    3267             : 
    3268           0 : void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs)
    3269             : {
    3270           0 :     getDesignView()->unmarkAllObjects(NULL);
    3271             : 
    3272           0 :     const OUString sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL));
    3273           0 :     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    3274             : 
    3275           0 :     if ( !m_xReportDefinition->getPageHeaderOn() )
    3276             :     {
    3277           0 :         uno::Sequence< beans::PropertyValue > aArgs;
    3278           0 :         executeChecked(SID_PAGEHEADERFOOTER,aArgs);
    3279             :     }
    3280             : 
    3281           0 :     SequenceAsHashMap aMap(_aArgs);
    3282           0 :     sal_Bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE,sal_False);
    3283             : 
    3284           0 :     OUString sFunction( ModuleRes(STR_RPT_PN_PAGE).toString() );
    3285           0 :     sFunction = sFunction.replaceFirst("#PAGENUMBER#", "PageNumber()");
    3286             : 
    3287           0 :     if ( bStateOfPage )
    3288             :     {
    3289           0 :         sFunction += ModuleRes(STR_RPT_PN_PAGE_OF).toString();
    3290           0 :         sFunction = sFunction.replaceFirst("#PAGECOUNT#", "PageCount()");
    3291             :     }
    3292             : 
    3293           0 :     sal_Bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON,sal_True);
    3294           0 :     createControl(_aArgs,bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter(),sFunction);
    3295           0 : }
    3296             : 
    3297             : 
    3298           0 : void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
    3299             : {
    3300           0 :     getDesignView()->unmarkAllObjects(NULL);
    3301             : 
    3302             :     // Anhand des FormatKeys wird festgestellt, welches Feld benoetigt wird
    3303           0 :     ::boost::shared_ptr<OSectionWindow> pSectionWindow[2];
    3304           0 :     pSectionWindow[0] = getDesignView()->getMarkedSection();
    3305             : 
    3306           0 :     if ( !pSectionWindow[0] )
    3307             :     {
    3308           0 :         select(uno::makeAny(m_xReportDefinition->getDetail()));
    3309           0 :         pSectionWindow[0] = getDesignView()->getMarkedSection();
    3310           0 :         if ( !pSectionWindow[0] )
    3311           0 :             return;
    3312             :     }
    3313             : 
    3314           0 :     uno::Reference<report::XSection> xCurrentSection = getDesignView()->getCurrentSection();
    3315           0 :     UndoContext aUndoContext( getUndoManager(), OUString( ModuleRes( RID_STR_UNDO_INSERT_CONTROL ) ) );
    3316             : 
    3317             :     try
    3318             :     {
    3319           0 :         bool bHandleOnlyOne = false;
    3320           0 :         const PropertyValue* pIter = aArgs.getConstArray();
    3321           0 :         const PropertyValue* pEnd  = pIter + aArgs.getLength();
    3322           0 :         for(;pIter != pEnd && !bHandleOnlyOne;++pIter)
    3323             :         {
    3324           0 :             Sequence< PropertyValue > aValue;
    3325           0 :             if ( !(pIter->Value >>= aValue) )
    3326             :             {   // the sequence has only one element which already contains the descriptor
    3327           0 :                 bHandleOnlyOne = true;
    3328           0 :                 aValue = aArgs;
    3329             :             }
    3330           0 :             ::svx::ODataAccessDescriptor aDescriptor(aValue);
    3331           0 :             SequenceAsHashMap aMap(aValue);
    3332           0 :             uno::Reference<report::XSection> xSection = aMap.getUnpackedValueOrDefault("Section",xCurrentSection);
    3333           0 :             uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
    3334             : 
    3335           0 :             getDesignView()->setMarked(xSection,sal_True);
    3336           0 :             pSectionWindow[0] = getDesignView()->getMarkedSection();
    3337             : 
    3338           0 :             sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
    3339           0 :             awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
    3340           0 :             if ( aPos.X < nLeftMargin )
    3341           0 :                 aPos.X = nLeftMargin;
    3342             : 
    3343             :             // LLA: new feature, add the Label in dependency of the given DND_ACTION one section up, normal or one section down
    3344           0 :             sal_Int8 nDNDAction = aMap.getUnpackedValueOrDefault("DNDAction", sal_Int8(0));
    3345           0 :             pSectionWindow[1] = pSectionWindow[0];
    3346           0 :             sal_Bool bLabelAboveTextField = nDNDAction == DND_ACTION_COPY;
    3347           0 :             if ( bLabelAboveTextField || nDNDAction == DND_ACTION_LINK )
    3348             :             {
    3349             :                 // Add the Label one Section up
    3350           0 :                 pSectionWindow[1] = getDesignView()->getMarkedSection(bLabelAboveTextField ? PREVIOUS : POST);
    3351           0 :                 if (!pSectionWindow[1])
    3352             :                 {
    3353             :                     // maybe out of bounds
    3354           0 :                     pSectionWindow[1] = pSectionWindow[0];
    3355             :                 }
    3356             :             }
    3357             :             // clear all selections
    3358           0 :             getDesignView()->unmarkAllObjects(NULL);
    3359             : 
    3360           0 :             uno::Reference< beans::XPropertySet > xField( aDescriptor[ ::svx::daColumnObject ], uno::UNO_QUERY );
    3361           0 :             uno::Reference< lang::XComponent > xHoldAlive;
    3362           0 :             if ( !xField.is() )
    3363             :             {
    3364           0 :                 OUString sCommand;
    3365           0 :                 OUString sColumnName;
    3366           0 :                 sal_Int32 nCommandType( -1 );
    3367           0 :                 OSL_VERIFY( aDescriptor[ ::svx::daCommand ] >>= sCommand );
    3368           0 :                 OSL_VERIFY( aDescriptor[ ::svx::daColumnName ] >>= sColumnName );
    3369           0 :                 OSL_VERIFY( aDescriptor[ ::svx::daCommandType ] >>= nCommandType );
    3370             : 
    3371           0 :                 uno::Reference< container::XNameAccess > xColumns;
    3372           0 :                 uno::Reference< sdbc::XConnection > xConnection( getConnection() );
    3373           0 :                 if ( !sCommand.isEmpty() && nCommandType != -1 && !sColumnName.isEmpty() && xConnection.is() )
    3374             :                 {
    3375           0 :                     if ( xReportDefinition->getCommand().isEmpty() )
    3376             :                     {
    3377           0 :                         xReportDefinition->setCommand(sCommand);
    3378           0 :                         xReportDefinition->setCommandType(nCommandType);
    3379             :                     }
    3380             : 
    3381           0 :                     xColumns = dbtools::getFieldsByCommandDescriptor(xConnection,nCommandType,sCommand,xHoldAlive);
    3382           0 :                     if ( xColumns.is() && xColumns->hasByName(sColumnName) )
    3383           0 :                         xField.set( xColumns->getByName( sColumnName ), uno::UNO_QUERY );
    3384             :                 }
    3385             : 
    3386           0 :                 if ( !xField.is() )
    3387             :                 {
    3388             :                 #if OSL_DEBUG_LEVEL > 0
    3389             :                     try
    3390             :                     {
    3391             :                         uno::Reference< beans::XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
    3392             :                         OUString sRowSetCommand;
    3393             :                         sal_Int32 nRowSetCommandType( -1 );
    3394             :                         OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sRowSetCommand );
    3395             :                         OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nRowSetCommandType );
    3396             :                         OSL_ENSURE( ( sRowSetCommand == sCommand ) && ( nCommandType == nRowSetCommandType ),
    3397             :                             "OReportController::addPairControls: this only works for a data source which equals our current settings!" );
    3398             :                         // if this asserts, then either our row set and our report definition are not in sync, or somebody
    3399             :                         // requested the creation of a control/pair for another data source than what our report
    3400             :                         // definition is bound to - which is not supported for the parameters case, since we
    3401             :                         // can retrieve parameters from the RowSet only.
    3402             :                     }
    3403             :                     catch(const Exception&)
    3404             :                     {
    3405             :                         DBG_UNHANDLED_EXCEPTION();
    3406             :                     }
    3407             :                 #endif
    3408             : 
    3409             :                     // no column name - perhaps a parameter name?
    3410           0 :                     uno::Reference< sdb::XParametersSupplier > xSuppParam( getRowSet(), uno::UNO_QUERY_THROW );
    3411           0 :                     uno::Reference< container::XIndexAccess > xParams( xSuppParam->getParameters(), uno::UNO_QUERY_THROW );
    3412           0 :                     sal_Int32 nParamCount( xParams->getCount() );
    3413           0 :                     for ( sal_Int32 i=0; i<nParamCount; ++i)
    3414             :                     {
    3415           0 :                         uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
    3416           0 :                         OUString sParamName;
    3417           0 :                         OSL_VERIFY( xParamCol->getPropertyValue("Name") >>= sParamName );
    3418           0 :                         if ( sParamName == sColumnName )
    3419             :                         {
    3420           0 :                             xField = xParamCol;
    3421           0 :                             break;
    3422             :                         }
    3423           0 :                     }
    3424           0 :                 }
    3425             :             }
    3426           0 :             if ( !xField.is() )
    3427           0 :                 continue;
    3428             : 
    3429           0 :             sal_uInt16 nOBJID = 0;
    3430           0 :             sal_Int32 nDataType = sdbc::DataType::BINARY;
    3431           0 :             xField->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
    3432           0 :             switch ( nDataType )
    3433             :             {
    3434             :                 case sdbc::DataType::BINARY:
    3435             :                 case sdbc::DataType::VARBINARY:
    3436             :                 case sdbc::DataType::LONGVARBINARY:
    3437           0 :                     nOBJID = OBJ_DLG_IMAGECONTROL;
    3438           0 :                     break;
    3439             :                 default:
    3440           0 :                     nOBJID = OBJ_DLG_FORMATTEDFIELD;
    3441           0 :                     break;
    3442             :             }
    3443             : 
    3444           0 :             if ( !nOBJID )
    3445           0 :                 continue;
    3446             : 
    3447           0 :             Reference< util::XNumberFormatsSupplier >  xSupplier = getReportNumberFormatter()->getNumberFormatsSupplier();
    3448           0 :             if ( !xSupplier.is() )
    3449           0 :                 continue;
    3450             : 
    3451           0 :             Reference< XNumberFormats >  xNumberFormats(xSupplier->getNumberFormats());
    3452             :             SdrUnoObj* pControl[2];
    3453           0 :             pControl[0] = NULL;
    3454           0 :             pControl[1] = NULL;
    3455           0 :             const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
    3456           0 :             const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
    3457             :             OSectionView* pSectionViews[2];
    3458           0 :             pSectionViews[0] = &pSectionWindow[1]->getReportSection().getSectionView();
    3459           0 :             pSectionViews[1] = &pSectionWindow[0]->getReportSection().getSectionView();
    3460             :             // find this in svx
    3461           0 :             FmFormView::createControlLabelPair( getDesignView()
    3462             :                 ,nLeftMargin,0
    3463             :                 ,xField,xNumberFormats,nOBJID,OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT,
    3464           0 :                 pSectionWindow[1]->getReportSection().getPage(),pSectionWindow[0]->getReportSection().getPage(),m_aReportModel.get(),
    3465           0 :                 pControl[0],pControl[1]);
    3466           0 :             if ( pControl[0] && pControl[1] )
    3467             :             {
    3468             :                 SdrPageView* pPgViews[2];
    3469           0 :                 pPgViews[0] = pSectionViews[0]->GetSdrPageView();
    3470           0 :                 pPgViews[1] = pSectionViews[1]->GetSdrPageView();
    3471           0 :                 if ( pPgViews[0] && pPgViews[1] )
    3472             :                 {
    3473           0 :                     OUString sDefaultName;
    3474           0 :                     size_t i = 0;
    3475             :                     OUnoObject* pObjs[2];
    3476           0 :                     for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
    3477             :                     {
    3478           0 :                         pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i]);
    3479           0 :                         uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
    3480           0 :                         uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW);
    3481           0 :                         xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME));
    3482             : 
    3483           0 :                         uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
    3484           0 :                         uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
    3485             :                         const OUString sProps[] = {   OUString(PROPERTY_FONTDESCRIPTOR)
    3486             :                                                             ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
    3487             :                                                             ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
    3488             :                                                             ,OUString(PROPERTY_BORDER)
    3489             :                                                             ,OUString(PROPERTY_BACKGROUNDCOLOR)
    3490           0 :                         };
    3491           0 :                         for(size_t k = 0; k < sizeof(sProps)/sizeof(sProps[0]);++k)
    3492             :                         {
    3493           0 :                             if ( xInfo->hasPropertyByName(sProps[k]) && xShapeInfo->hasPropertyByName(sProps[k]) )
    3494           0 :                                 xUnoProp->setPropertyValue(sProps[k],xShapeProp->getPropertyValue(sProps[k]));
    3495             :                         }
    3496           0 :                         if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
    3497             :                         {
    3498           0 :                             OUString sName;
    3499           0 :                             xUnoProp->getPropertyValue(PROPERTY_DATAFIELD) >>= sName;
    3500           0 :                             sDefaultName = sName;
    3501           0 :                             xUnoProp->setPropertyValue(PROPERTY_NAME,uno::makeAny(sDefaultName));
    3502             : 
    3503           0 :                             ReportFormula aFormula( ReportFormula::Field, sName );
    3504           0 :                             xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFormula.getCompleteFormula() ) );
    3505             :                         }
    3506             : 
    3507           0 :                         if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
    3508           0 :                             xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
    3509             : 
    3510           0 :                         pObjs[i]->CreateMediator(sal_True);
    3511             : 
    3512           0 :                         const sal_Int32 nShapeWidth = xShapeProp->getWidth();
    3513           0 :                         const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
    3514           0 :                         if ( bChangedPos )
    3515           0 :                             aPos.X = nPaperWidth - nShapeWidth;
    3516           0 :                         xShapeProp->setPosition(aPos);
    3517           0 :                         if ( bChangedPos )
    3518           0 :                             aPos.Y += xShapeProp->getHeight();
    3519           0 :                         aPos.X += nShapeWidth;
    3520           0 :                     }
    3521           0 :                     OUString sLabel;
    3522           0 :                     if ( xField->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
    3523           0 :                         xField->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
    3524             : 
    3525           0 :                     if (pSectionViews[0] != pSectionViews[1] &&
    3526             :                         nOBJID == OBJ_DLG_FORMATTEDFIELD) // we want this nice feature only at FORMATTEDFIELD
    3527             :                     {
    3528           0 :                         uno::Reference< report::XReportComponent> xShapePropLabel(pObjs[0]->getUnoShape(),uno::UNO_QUERY_THROW);
    3529           0 :                         uno::Reference< report::XReportComponent> xShapePropTextField(pObjs[1]->getUnoShape(),uno::UNO_QUERY_THROW);
    3530           0 :                         if ( !sLabel.isEmpty() )
    3531           0 :                             xShapePropTextField->setName(sLabel);
    3532           0 :                         awt::Point aPosLabel = xShapePropLabel->getPosition();
    3533           0 :                         awt::Point aPosTextField = xShapePropTextField->getPosition();
    3534           0 :                         aPosTextField.X = aPosLabel.X;
    3535           0 :                         xShapePropTextField->setPosition(aPosTextField);
    3536           0 :                         if (bLabelAboveTextField)
    3537             :                         {
    3538             :                             // move the label down near the splitter
    3539           0 :                             const uno::Reference<report::XSection> xLabelSection = pSectionWindow[1]->getReportSection().getSection();
    3540           0 :                             aPosLabel.Y = xLabelSection->getHeight() - xShapePropLabel->getHeight();
    3541             :                         }
    3542             :                         else
    3543             :                         {
    3544             :                             // move the label up to the splitter
    3545           0 :                             aPosLabel.Y = 0;
    3546             :                         }
    3547           0 :                         xShapePropLabel->setPosition(aPosLabel);
    3548             :                     }
    3549           0 :                     OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0]);
    3550           0 :                     uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
    3551           0 :                     xShapeProp->setName(xShapeProp->getName() + sDefaultName );
    3552             : 
    3553           0 :                     for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) // insert controls
    3554             :                     {
    3555           0 :                         correctOverlapping(pControl[i],pSectionWindow[1-i]->getReportSection());
    3556             :                     }
    3557             : 
    3558           0 :                     if (!bLabelAboveTextField )
    3559             :                     {
    3560           0 :                         if ( pSectionViews[0] == pSectionViews[1] )
    3561             :                         {
    3562           0 :                             Rectangle aLabel = getRectangleFromControl(pControl[0]);
    3563           0 :                             Rectangle aTextfield = getRectangleFromControl(pControl[1]);
    3564             : 
    3565             :                             // create a Union of the given Label and Textfield
    3566           0 :                             Rectangle aLabelAndTextfield( aLabel );
    3567           0 :                             aLabelAndTextfield.Union(aTextfield);
    3568             : 
    3569             :                             // check if there exists other fields and if yes, move down
    3570           0 :                             bool bOverlapping = true;
    3571           0 :                             bool bHasToMove = false;
    3572           0 :                             while ( bOverlapping )
    3573             :                             {
    3574           0 :                                 const SdrObject* pOverlappedObj = isOver(aLabelAndTextfield, *pSectionWindow[0]->getReportSection().getPage(), *pSectionViews[0], true, pControl, 2);
    3575           0 :                                 bOverlapping = pOverlappedObj != NULL;
    3576           0 :                                 if ( bOverlapping )
    3577             :                                 {
    3578           0 :                                     const Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
    3579           0 :                                     aLabelAndTextfield.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aLabelAndTextfield.Top());
    3580           0 :                                     bHasToMove = true;
    3581             :                                 }
    3582             :                             }
    3583             : 
    3584           0 :                             if (bHasToMove)
    3585             :                             {
    3586             :                                 // There was a move down, we need to move the Label and the Textfield down
    3587           0 :                                 aLabel.Move(0, aLabelAndTextfield.Top() - aLabel.Top());
    3588           0 :                                 aTextfield.Move(0, aLabelAndTextfield.Top() - aTextfield.Top());
    3589             : 
    3590           0 :                                 uno::Reference< report::XReportComponent> xLabel(pControl[0]->getUnoShape(),uno::UNO_QUERY_THROW);
    3591           0 :                                 xLabel->setPositionY(aLabel.Top());
    3592             : 
    3593           0 :                                 uno::Reference< report::XReportComponent> xTextfield(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW);
    3594           0 :                                 xTextfield->setPositionY(aTextfield.Top());
    3595             :                         }
    3596             :                     }
    3597           0 :                     }
    3598           0 :                 }
    3599             :             }
    3600             :             else
    3601             :             {
    3602           0 :                 for(size_t i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
    3603           0 :                     delete pControl[i];
    3604             :             }
    3605           0 :         }
    3606             :     }
    3607           0 :     catch(const Exception&)
    3608             :     {
    3609             :         DBG_UNHANDLED_EXCEPTION();
    3610           0 :     }
    3611             : }
    3612             : 
    3613             : 
    3614           0 : OSectionView* OReportController::getCurrentSectionView() const
    3615             : {
    3616           0 :     OSectionView* pSectionView = NULL;
    3617           0 :     ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
    3618           0 :     if ( pSectionWindow.get() )
    3619           0 :         pSectionView = &pSectionWindow->getReportSection().getSectionView();
    3620           0 :     return pSectionView;
    3621             : }
    3622             : 
    3623           0 : void OReportController::changeZOrder(sal_Int32 _nId)
    3624             : {
    3625           0 :     OSectionView* pSectionView = getCurrentSectionView();
    3626           0 :     if ( pSectionView )
    3627             :     {
    3628           0 :         switch(_nId)
    3629             :         {
    3630             :             case SID_FRAME_TO_BOTTOM:
    3631           0 :                 pSectionView->PutMarkedToBtm();
    3632           0 :                 break;
    3633             :             case SID_FRAME_TO_TOP:
    3634           0 :                 pSectionView->PutMarkedToTop();
    3635           0 :                 break;
    3636             :             case SID_FRAME_DOWN:
    3637           0 :                 pSectionView->MovMarkedToBtm();
    3638           0 :                 break;
    3639             :             case SID_FRAME_UP:
    3640           0 :                 pSectionView->MovMarkedToTop();
    3641           0 :                 break;
    3642             : 
    3643             :             case SID_OBJECT_HEAVEN:
    3644           0 :                 pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT );
    3645           0 :                 break;
    3646             :             case SID_OBJECT_HELL:
    3647           0 :                 pSectionView->SetMarkedToLayer( RPT_LAYER_BACK );
    3648           0 :                 break;
    3649             :         }
    3650             :     }
    3651           0 : }
    3652             : 
    3653           0 : void OReportController::listen(const bool _bAdd)
    3654             : {
    3655             :     const OUString aProps [] = {    OUString(PROPERTY_REPORTHEADERON),OUString(PROPERTY_REPORTFOOTERON)
    3656             :                                             ,OUString(PROPERTY_PAGEHEADERON),OUString(PROPERTY_PAGEFOOTERON)
    3657             :                                             ,OUString(PROPERTY_COMMAND), OUString(PROPERTY_COMMANDTYPE),OUString(PROPERTY_CAPTION)
    3658           0 :     };
    3659             : 
    3660             :     void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const OUString&, const uno::Reference< XPropertyChangeListener >& ) =
    3661           0 :         _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
    3662             : 
    3663           0 :     for (size_t i = 0; i < sizeof(aProps)/sizeof(aProps[0]); ++i)
    3664           0 :         (m_xReportDefinition.get()->*pPropertyListenerAction)( aProps[i], static_cast< XPropertyChangeListener* >( this ) );
    3665             : 
    3666           0 :     OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
    3667           0 :     uno::Reference< XPropertyChangeListener > xUndo = &rUndoEnv;
    3668           0 :     uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties();
    3669           0 :     const beans::Property* pIter = aSeq.getConstArray();
    3670           0 :     const beans::Property* pEnd   = pIter + aSeq.getLength();
    3671           0 :     const OUString* pPropsBegin = &aProps[0];
    3672           0 :     const OUString* pPropsEnd   = pPropsBegin + (sizeof(aProps)/sizeof(aProps[0])) - 3;
    3673           0 :     for(;pIter != pEnd;++pIter)
    3674             :     {
    3675           0 :         if ( ::std::find(pPropsBegin,pPropsEnd,pIter->Name) == pPropsEnd )
    3676           0 :             (m_xReportDefinition.get()->*pPropertyListenerAction)( pIter->Name, xUndo );
    3677             :     }
    3678             : 
    3679             :     // Add Listeners to UndoEnvironment
    3680             :     void (OXUndoEnvironment::*pElementUndoFunction)( const uno::Reference< uno::XInterface >& ) =
    3681           0 :         _bAdd ? &OXUndoEnvironment::AddElement : &OXUndoEnvironment::RemoveElement;
    3682             : 
    3683           0 :     (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getStyleFamilies() );
    3684           0 :     (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getFunctions() );
    3685             : 
    3686             :     // Add Listeners to ReportControllerObserver
    3687           0 :     OXReportControllerObserver& rObserver = *m_pReportControllerObserver;
    3688             : 
    3689           0 :     if ( m_xReportDefinition->getPageHeaderOn() && _bAdd )
    3690             :     {
    3691           0 :         getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER);
    3692           0 :         rObserver.AddSection(m_xReportDefinition->getPageHeader());
    3693             :     }
    3694           0 :     if ( m_xReportDefinition->getReportHeaderOn() && _bAdd )
    3695             :     {
    3696           0 :         getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER);
    3697           0 :         rObserver.AddSection(m_xReportDefinition->getReportHeader());
    3698             :     }
    3699             : 
    3700           0 :     uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
    3701           0 :     const sal_Int32 nCount = xGroups->getCount();
    3702           0 :     _bAdd ? xGroups->addContainerListener(&rUndoEnv) : xGroups->removeContainerListener(&rUndoEnv);
    3703           0 :     _bAdd ? xGroups->addContainerListener(&rObserver) : xGroups->removeContainerListener(&rObserver);
    3704             : 
    3705           0 :     for (sal_Int32 i=0;i<nCount ; ++i)
    3706             :     {
    3707           0 :         uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY);
    3708           0 :         (xGroup.get()->*pPropertyListenerAction)( OUString(PROPERTY_HEADERON), static_cast< XPropertyChangeListener* >( this ) );
    3709           0 :         (xGroup.get()->*pPropertyListenerAction)( OUString(PROPERTY_FOOTERON), static_cast< XPropertyChangeListener* >( this ) );
    3710             : 
    3711           0 :         (rUndoEnv.*pElementUndoFunction)( xGroup );
    3712           0 :         (rUndoEnv.*pElementUndoFunction)( xGroup->getFunctions() );
    3713           0 :         if ( xGroup->getHeaderOn() && _bAdd )
    3714             :         {
    3715           0 :             getDesignView()->addSection(xGroup->getHeader(),DBGROUPHEADER);
    3716           0 :             rObserver.AddSection(xGroup->getHeader());
    3717             :         }
    3718           0 :     }
    3719             : 
    3720           0 :     if ( _bAdd )
    3721             :     {
    3722           0 :         getDesignView()->addSection(m_xReportDefinition->getDetail(),DBDETAIL);
    3723           0 :         rObserver.AddSection(m_xReportDefinition->getDetail());
    3724             : 
    3725           0 :         for (sal_Int32 i=nCount;i > 0 ; --i)
    3726             :         {
    3727           0 :             uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i-1),uno::UNO_QUERY);
    3728           0 :             if ( xGroup->getFooterOn() )
    3729             :             {
    3730           0 :                 getDesignView()->addSection(xGroup->getFooter(),DBGROUPFOOTER);
    3731           0 :                 rObserver.AddSection(xGroup->getFooter());
    3732             :             }
    3733           0 :         }
    3734           0 :         if ( m_xReportDefinition->getReportFooterOn() )
    3735             :         {
    3736           0 :             getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER);
    3737           0 :             rObserver.AddSection(m_xReportDefinition->getReportFooter());
    3738             :         }
    3739           0 :         if ( m_xReportDefinition->getPageFooterOn())
    3740             :         {
    3741           0 :             getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
    3742           0 :             rObserver.AddSection(m_xReportDefinition->getPageFooter());
    3743             :         }
    3744             : 
    3745           0 :         xGroups->addContainerListener(static_cast<XContainerListener*>(this));
    3746           0 :         m_xReportDefinition->addModifyListener(static_cast<XModifyListener*>(this));
    3747             :     }
    3748             :     else /* ! _bAdd */
    3749             :     {
    3750           0 :         rObserver.RemoveSection(m_xReportDefinition->getDetail());
    3751           0 :         xGroups->removeContainerListener(static_cast<XContainerListener*>(this));
    3752           0 :         m_xReportDefinition->removeModifyListener(static_cast<XModifyListener*>(this));
    3753           0 :         m_aReportModel->detachController();
    3754           0 :     }
    3755           0 : }
    3756             : 
    3757           0 : void OReportController::switchReportSection(const sal_Int16 _nId)
    3758             : {
    3759             :     OSL_ENSURE(_nId == SID_REPORTHEADER_WITHOUT_UNDO || _nId == SID_REPORTFOOTER_WITHOUT_UNDO || _nId == SID_REPORTHEADERFOOTER ,"Illegal id given!");
    3760             : 
    3761           0 :     if ( m_xReportDefinition.is() )
    3762             :     {
    3763           0 :         const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
    3764           0 :         const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn();
    3765             : 
    3766           0 :         ::boost::scoped_ptr< UndoContext > pUndoContext;
    3767           0 :         if ( SID_REPORTHEADERFOOTER == _nId )
    3768             :         {
    3769           0 :             const OUString sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
    3770           0 :             pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
    3771             : 
    3772           0 :             addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO
    3773           0 :                                                             ,::std::mem_fun(&OReportHelper::getReportHeader)
    3774             :                                                             ,m_xReportDefinition
    3775             :                                                             ,bSwitchOn ? Inserted : Removed
    3776             :                                                             ,0
    3777           0 :                                                             ));
    3778             : 
    3779           0 :             addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO
    3780           0 :                                                             ,::std::mem_fun(&OReportHelper::getReportFooter)
    3781             :                                                             ,m_xReportDefinition
    3782             :                                                             ,bSwitchOn ? Inserted : Removed
    3783             :                                                             ,0
    3784           0 :                                                             ));
    3785             :         }
    3786             : 
    3787           0 :         switch( _nId )
    3788             :         {
    3789             :             case SID_REPORTHEADER_WITHOUT_UNDO:
    3790           0 :                 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
    3791           0 :                 break;
    3792             :             case SID_REPORTFOOTER_WITHOUT_UNDO:
    3793           0 :                 m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() );
    3794           0 :                 break;
    3795             :             case SID_REPORTHEADERFOOTER:
    3796           0 :                 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
    3797           0 :                 m_xReportDefinition->setReportFooterOn( bSwitchOn );
    3798           0 :                 break;
    3799             :         }
    3800             : 
    3801           0 :         if ( SID_REPORTHEADERFOOTER == _nId )
    3802           0 :             pUndoContext.reset();
    3803           0 :         getView()->Resize();
    3804             :     }
    3805           0 : }
    3806             : 
    3807           0 : void OReportController::switchPageSection(const sal_Int16 _nId)
    3808             : {
    3809             :     OSL_ENSURE(_nId == SID_PAGEHEADERFOOTER || _nId == SID_PAGEHEADER_WITHOUT_UNDO || _nId == SID_PAGEFOOTER_WITHOUT_UNDO ,"Illegal id given!");
    3810           0 :     if ( m_xReportDefinition.is() )
    3811             :     {
    3812           0 :         const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
    3813           0 :         const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn();
    3814             : 
    3815           0 :         ::boost::scoped_ptr< UndoContext > pUndoContext;
    3816           0 :         if ( SID_PAGEHEADERFOOTER == _nId )
    3817             :         {
    3818           0 :             const OUString sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
    3819           0 :             pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
    3820             : 
    3821           0 :             addUndoAction(new OReportSectionUndo(*m_aReportModel
    3822             :                                                             ,SID_PAGEHEADER_WITHOUT_UNDO
    3823           0 :                                                             ,::std::mem_fun(&OReportHelper::getPageHeader)
    3824             :                                                             ,m_xReportDefinition
    3825             :                                                             ,bSwitchOn ? Inserted : Removed
    3826             :                                                             ,0
    3827           0 :                                                             ));
    3828             : 
    3829           0 :             addUndoAction(new OReportSectionUndo(*m_aReportModel
    3830             :                                                             ,SID_PAGEFOOTER_WITHOUT_UNDO
    3831           0 :                                                             ,::std::mem_fun(&OReportHelper::getPageFooter)
    3832             :                                                             ,m_xReportDefinition
    3833             :                                                             ,bSwitchOn ? Inserted : Removed
    3834             :                                                             ,0
    3835           0 :                                                             ));
    3836             :         }
    3837           0 :         switch( _nId )
    3838             :         {
    3839             :             case SID_PAGEHEADER_WITHOUT_UNDO:
    3840           0 :                 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
    3841           0 :                 break;
    3842             :             case SID_PAGEFOOTER_WITHOUT_UNDO:
    3843           0 :                 m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() );
    3844           0 :                 break;
    3845             :             case SID_PAGEHEADERFOOTER:
    3846           0 :                 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
    3847           0 :                 m_xReportDefinition->setPageFooterOn( bSwitchOn );
    3848           0 :                 break;
    3849             :         }
    3850           0 :         if ( SID_PAGEHEADERFOOTER == _nId )
    3851           0 :             pUndoContext.reset();
    3852           0 :         getView()->Resize();
    3853             :     }
    3854           0 : }
    3855             : 
    3856           0 : void OReportController::modifyGroup(const bool _bAppend, const Sequence< PropertyValue >& _aArgs)
    3857             : {
    3858           0 :     if ( !m_xReportDefinition.is() )
    3859           0 :         return;
    3860             : 
    3861             :     try
    3862             :     {
    3863           0 :         const SequenceAsHashMap aMap( _aArgs );
    3864           0 :         uno::Reference< report::XGroup > xGroup = aMap.getUnpackedValueOrDefault( PROPERTY_GROUP, uno::Reference< report::XGroup >() );
    3865           0 :         if ( !xGroup.is() )
    3866           0 :             return;
    3867             : 
    3868           0 :         OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
    3869           0 :         uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
    3870           0 :         if ( _bAppend )
    3871             :         {
    3872           0 :             const sal_Int32 nPos = aMap.getUnpackedValueOrDefault( PROPERTY_POSITIONY, xGroups->getCount() );
    3873           0 :             xGroups->insertByIndex( nPos, uno::makeAny( xGroup ) );
    3874           0 :             rUndoEnv.AddElement( xGroup->getFunctions() );
    3875             :         }
    3876             : 
    3877             :         addUndoAction( new OGroupUndo(
    3878           0 :             *m_aReportModel,
    3879             :             _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP,
    3880             :             _bAppend ? Inserted : Removed,
    3881             :             xGroup,
    3882             :             m_xReportDefinition
    3883           0 :         ) );
    3884             : 
    3885           0 :         if ( !_bAppend )
    3886             :         {
    3887           0 :             rUndoEnv.RemoveElement( xGroup->getFunctions() );
    3888           0 :             const sal_Int32 nPos = getGroupPosition( xGroup );
    3889           0 :             const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
    3890           0 :             xGroups->removeByIndex( nPos );
    3891           0 :         }
    3892             :     }
    3893           0 :     catch(const Exception&)
    3894             :     {
    3895             :         DBG_UNHANDLED_EXCEPTION();
    3896             :     }
    3897             : }
    3898             : 
    3899             : 
    3900           0 : void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader, const Sequence< PropertyValue >& _aArgs)
    3901             : {
    3902           0 :     if ( m_xReportDefinition.is() )
    3903             :     {
    3904           0 :         const SequenceAsHashMap aMap(_aArgs);
    3905           0 :         const sal_Bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? OUString(PROPERTY_HEADERON) : OUString(PROPERTY_FOOTERON), sal_False);
    3906           0 :         uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>());
    3907           0 :         if ( xGroup.is() )
    3908             :         {
    3909           0 :             const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv());
    3910           0 :             if ( _bUndo )
    3911           0 :                 addUndoAction(new OGroupSectionUndo(*m_aReportModel
    3912             :                                                                 ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO
    3913           0 :                                                                 ,_bHeader ? ::std::mem_fun(&OGroupHelper::getHeader) : ::std::mem_fun(&OGroupHelper::getFooter)
    3914             :                                                                 ,xGroup
    3915             :                                                                 ,bSwitchOn ? Inserted : Removed
    3916             :                                                                 , ( _bHeader ?
    3917             :                                                                         (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER)
    3918             :                                                                        :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER)
    3919             :                                                                   )
    3920           0 :                                                                 ));
    3921             : 
    3922           0 :             if ( _bHeader )
    3923           0 :                 xGroup->setHeaderOn( bSwitchOn );
    3924             :             else
    3925           0 :                 xGroup->setFooterOn( bSwitchOn );
    3926           0 :         }
    3927             :     }
    3928           0 : }
    3929             : 
    3930           0 : void OReportController::collapseSection(const bool _bCollapse)
    3931             : {
    3932           0 :     ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection();
    3933           0 :     if ( pSection )
    3934             :     {
    3935           0 :         pSection->setCollapsed(_bCollapse);
    3936           0 :     }
    3937           0 : }
    3938             : 
    3939           0 : void OReportController::markSection(const bool _bNext)
    3940             : {
    3941           0 :     ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection();
    3942           0 :     if ( pSection )
    3943             :     {
    3944           0 :         ::boost::shared_ptr<OSectionWindow> pPrevSection = getDesignView()->getMarkedSection(_bNext ? POST : PREVIOUS);
    3945           0 :         if ( pPrevSection != pSection && pPrevSection )
    3946           0 :             select(uno::makeAny(pPrevSection->getReportSection().getSection()));
    3947             :         else
    3948           0 :             select(uno::makeAny(m_xReportDefinition));
    3949             :     }
    3950             :     else
    3951             :     {
    3952           0 :         getDesignView()->markSection(_bNext ? 0 : getDesignView()->getSectionCount() - 1);
    3953           0 :         pSection = getDesignView()->getMarkedSection();
    3954           0 :         if ( pSection )
    3955           0 :             select(uno::makeAny(pSection->getReportSection().getSection()));
    3956           0 :     }
    3957           0 : }
    3958             : 
    3959           0 : void OReportController::createDefaultControl(const uno::Sequence< beans::PropertyValue>& _aArgs)
    3960             : {
    3961           0 :     uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
    3962           0 :     if ( !xSection.is() )
    3963           0 :         xSection = m_xReportDefinition->getDetail();
    3964             : 
    3965           0 :     if ( xSection.is() )
    3966             :     {
    3967           0 :         const OUString sKeyModifier("KeyModifier");
    3968           0 :         const beans::PropertyValue* pIter = _aArgs.getConstArray();
    3969           0 :         const beans::PropertyValue* pEnd  = pIter + _aArgs.getLength();
    3970           0 :         const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyValueCompare(),boost::cref(sKeyModifier)));
    3971           0 :         sal_Int16 nKeyModifier = 0;
    3972           0 :         if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) )
    3973             :         {
    3974           0 :             Sequence< PropertyValue > aCreateArgs;
    3975           0 :             getDesignView()->unmarkAllObjects(NULL);
    3976           0 :             createControl(aCreateArgs,xSection,OUString(),getDesignView()->GetInsertObj());
    3977           0 :         }
    3978           0 :     }
    3979           0 : }
    3980             : 
    3981           0 : uno::Reference< util::XNumberFormatter > OReportController::getReportNumberFormatter() const
    3982             : {
    3983           0 :     return m_xFormatter;
    3984             : }
    3985             : 
    3986           0 : void OReportController::checkChartEnabled()
    3987             : {
    3988           0 :     if ( !m_bChartEnabledAsked )
    3989             :     {
    3990           0 :         m_bChartEnabledAsked = true;
    3991           0 :         const OUString sConfigName( "/org.openoffice.Office.ReportDesign" );
    3992           0 :         const OUString sPropertyName( "UserData/Chart" );
    3993             : 
    3994             :         try
    3995             :         {
    3996             :             ::utl::OConfigurationTreeRoot aConfiguration(
    3997           0 :                 ::utl::OConfigurationTreeRoot::createWithComponentContext( m_xContext, sConfigName ) );
    3998             : 
    3999           0 :             sal_Bool bChartEnabled = sal_False;
    4000           0 :             if ( aConfiguration.hasByHierarchicalName(sPropertyName) )
    4001           0 :                 aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled;
    4002           0 :             m_bChartEnabled = bChartEnabled;
    4003             :         }
    4004           0 :         catch(const Exception&)
    4005             :         {
    4006           0 :         }
    4007             :     }
    4008           0 : }
    4009             : 
    4010             : 
    4011             : // css.frame.XTitle
    4012           0 : OUString SAL_CALL OReportController::getTitle()
    4013             :     throw (uno::RuntimeException, std::exception)
    4014             : {
    4015           0 :     SolarMutexGuard aSolarGuard;
    4016           0 :     ::osl::MutexGuard aGuard( getMutex() );
    4017             : 
    4018           0 :     uno::Reference< frame::XTitle> xTitle(m_xReportDefinition,uno::UNO_QUERY_THROW);
    4019             : 
    4020           0 :     return xTitle->getTitle ();
    4021             : }
    4022             : 
    4023           0 : void OReportController::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
    4024             : {
    4025           0 :     _rDefault <<= sal_Int16(100);
    4026           0 : }
    4027             : 
    4028             : // comphelper::OPropertyArrayUsageHelper
    4029           0 : ::cppu::IPropertyArrayHelper* OReportController::createArrayHelper( ) const
    4030             : {
    4031           0 :     Sequence< Property > aProps;
    4032           0 :     describeProperties(aProps);
    4033           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
    4034             : }
    4035             : 
    4036             : 
    4037             : // cppu::OPropertySetHelper
    4038           0 : ::cppu::IPropertyArrayHelper& SAL_CALL OReportController::getInfoHelper()
    4039             : {
    4040             :     typedef ::comphelper::OPropertyArrayUsageHelper<OReportController_BASE> OReportController_PROP;
    4041           0 :     return *OReportController_PROP::getArrayHelper();
    4042             : }
    4043             : 
    4044           0 : void SAL_CALL OReportController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any& _aValue) throw (Exception, std::exception)
    4045             : {
    4046           0 :     if ( _nHandle == PROPERTY_ID_ZOOMVALUE )
    4047             :     {
    4048           0 :         _aValue >>= m_nZoomValue;
    4049           0 :         impl_zoom_nothrow();
    4050             :     }
    4051           0 : }
    4052           0 : void SAL_CALL OReportController::setMode( const OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception)
    4053             : {
    4054           0 :     ::osl::MutexGuard aGuard( getMutex() );
    4055           0 :     m_sMode = aMode;
    4056           0 : }
    4057           0 : OUString SAL_CALL OReportController::getMode(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    4058             : {
    4059           0 :     ::osl::MutexGuard aGuard( getMutex() );
    4060           0 :     return m_sMode;
    4061             : }
    4062           0 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL OReportController::getSupportedModes(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    4063             : {
    4064             :     static const OUString s_sModes[] = { OUString("remote"),
    4065           0 :                                           OUString("normal") };
    4066           0 :     return uno::Sequence< OUString> (&s_sModes[0],sizeof(s_sModes)/sizeof(s_sModes[0]));
    4067             : }
    4068           0 : sal_Bool SAL_CALL OReportController::supportsMode( const OUString& aMode ) throw (::com::sun::star::uno::RuntimeException, std::exception)
    4069             : {
    4070           0 :     uno::Sequence< OUString> aModes = getSupportedModes();
    4071           0 :     const OUString* pIter = aModes.getConstArray();
    4072           0 :     const OUString* pEnd  = pIter + aModes.getLength();
    4073           0 :     for(;pIter != pEnd;++pIter)
    4074             :     {
    4075           0 :         if ( pIter->equals(aMode ) )
    4076           0 :             break;
    4077             :     }
    4078           0 :     return pIter != pEnd;
    4079             : }
    4080             : 
    4081           0 : bool OReportController::isUiVisible() const
    4082             : {
    4083           0 :     return m_sMode != "remote";
    4084             : }
    4085             : 
    4086           0 : void OReportController::impl_fillState_nothrow(const OUString& _sProperty,dbaui::FeatureState& _rState) const
    4087             : {
    4088           0 :     _rState.bEnabled = isEditable();
    4089           0 :     if ( _rState.bEnabled )
    4090             :     {
    4091           0 :         ::std::vector< uno::Reference< uno::XInterface > > aSelection;
    4092           0 :         getDesignView()->fillControlModelSelection(aSelection);
    4093           0 :         _rState.bEnabled = !aSelection.empty();
    4094           0 :         if ( _rState.bEnabled )
    4095             :         {
    4096           0 :             uno::Any aTemp;
    4097           0 :             ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
    4098           0 :             for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter)
    4099             :             {
    4100           0 :                 uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY);
    4101             :                 try
    4102             :                 {
    4103           0 :                     uno::Any aTemp2 = xProp->getPropertyValue(_sProperty);
    4104           0 :                     if ( aIter == aSelection.begin() )
    4105             :                     {
    4106           0 :                         aTemp = aTemp2;
    4107             :                     }
    4108           0 :                     else if ( !comphelper::compare(aTemp,aTemp2) )
    4109           0 :                         break;
    4110             :                 }
    4111           0 :                 catch(const beans::UnknownPropertyException&)
    4112             :                 {
    4113           0 :                     _rState.bEnabled = false;
    4114             :                 }
    4115           0 :             }
    4116           0 :             if ( aIter == aSelection.end() )
    4117           0 :                 _rState.aValue = aTemp;
    4118           0 :         }
    4119             :     }
    4120           0 : }
    4121             : 
    4122           0 : void OReportController::impl_zoom_nothrow()
    4123             : {
    4124           0 :     Fraction aZoom(m_nZoomValue,100);
    4125           0 :     setZoomFactor( aZoom,*getDesignView() );
    4126           0 :     getDesignView()->zoom(aZoom);
    4127           0 :     InvalidateFeature(SID_ATTR_ZOOM,Reference< XStatusListener >(), true);
    4128           0 :     InvalidateFeature(SID_ATTR_ZOOMSLIDER,Reference< XStatusListener >(), true);
    4129           0 : }
    4130             : 
    4131           0 : sal_Bool OReportController::isFormatCommandEnabled(sal_uInt16 _nCommand,const uno::Reference< report::XReportControlFormat>& _xReportControlFormat) const
    4132             : {
    4133           0 :     sal_Bool bRet = sal_False;
    4134           0 :     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
    4135             :     {
    4136             :         try
    4137             :         {
    4138           0 :             const awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
    4139             : 
    4140           0 :             switch(_nCommand)
    4141             :             {
    4142             :                 case SID_ATTR_CHAR_WEIGHT:
    4143           0 :                     bRet = awt::FontWeight::BOLD == aFontDescriptor.Weight;
    4144           0 :                     break;
    4145             :                 case SID_ATTR_CHAR_POSTURE:
    4146           0 :                     bRet = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
    4147           0 :                     break;
    4148             :                 case SID_ATTR_CHAR_UNDERLINE:
    4149           0 :                     bRet = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
    4150           0 :                     break;
    4151             :                 default:
    4152             :                     ;
    4153           0 :             }
    4154             :         }
    4155           0 :         catch(const uno::Exception&)
    4156             :         {
    4157             :         }
    4158             :     }
    4159           0 :     return bRet;
    4160             : }
    4161             : 
    4162           0 : bool OReportController::impl_setPropertyAtControls_throw(const sal_uInt16 _nUndoResId,const OUString& _sProperty,const uno::Any& _aValue,const Sequence< PropertyValue >& _aArgs)
    4163             : {
    4164           0 :     ::std::vector< uno::Reference< uno::XInterface > > aSelection;
    4165           0 :     uno::Reference< awt::XWindow> xWindow;
    4166           0 :     lcl_getReportControlFormat( _aArgs, getDesignView(), xWindow, aSelection );
    4167           0 :     ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
    4168             : 
    4169           0 :     const OUString sUndoAction = ModuleRes( _nUndoResId );
    4170           0 :     UndoContext aUndoContext( getUndoManager(), sUndoAction );
    4171             : 
    4172           0 :     for(;  aIter != aSelection.end();++aIter)
    4173             :     {
    4174           0 :         const uno::Reference< beans::XPropertySet > xControlModel(*aIter,uno::UNO_QUERY);
    4175           0 :         if ( xControlModel.is() )
    4176           0 :             xControlModel->setPropertyValue(_sProperty,_aValue);
    4177           0 :     }
    4178             : 
    4179           0 :     return !aSelection.empty();
    4180             : }
    4181             : 
    4182           0 : void OReportController::impl_fillCustomShapeState_nothrow(const char* _pCustomShapeType,dbaui::FeatureState& _rState) const
    4183             : {
    4184           0 :     _rState.bEnabled = isEditable();
    4185           0 :     _rState.bChecked = getDesignView()->GetInsertObj() == OBJ_CUSTOMSHAPE && getDesignView()->GetInsertObjString().equalsAscii(_pCustomShapeType);
    4186           0 : }
    4187             : 
    4188             : 
    4189           0 : ::boost::shared_ptr<OSectionWindow> OReportController::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const
    4190             : {
    4191           0 :     if ( getDesignView() )
    4192             :     {
    4193           0 :         return  getDesignView()->getSectionWindow(_xSection);
    4194             :     }
    4195             : 
    4196             :     // throw NullPointerException?
    4197           0 :     ::boost::shared_ptr<OSectionWindow> pEmpty;
    4198           0 :     return pEmpty;
    4199             : }
    4200             : 
    4201             : 
    4202             : 
    4203           0 : void OReportController::openZoomDialog()
    4204             : {
    4205           0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    4206           0 :     if ( pFact )
    4207             :     {
    4208             :         static SfxItemInfo aItemInfos[] =
    4209             :         {
    4210             :             { SID_ATTR_ZOOM, SFX_ITEM_POOLABLE }
    4211             :         };
    4212             :         SfxPoolItem* pDefaults[] =
    4213             :         {
    4214           0 :             new SvxZoomItem()
    4215           0 :         };
    4216             :         static const sal_uInt16 pRanges[] =
    4217             :         {
    4218             :             SID_ATTR_ZOOM,SID_ATTR_ZOOM,
    4219             :             0
    4220             :         };
    4221           0 :         SfxItemPool* pPool( new SfxItemPool(OUString("ZoomProperties"), SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, pDefaults) );
    4222           0 :         pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );    // ripped, don't understand why
    4223           0 :         pPool->FreezeIdRanges();                        // the same
    4224             :         try
    4225             :         {
    4226             :             SAL_WNODEPRECATED_DECLARATIONS_PUSH
    4227           0 :             ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
    4228             :             SAL_WNODEPRECATED_DECLARATIONS_POP
    4229             :             // fill it
    4230           0 :             SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM );
    4231           0 :             aZoomItem.SetValueSet(SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_WHOLEPAGE|SVX_ZOOM_ENABLE_PAGEWIDTH);
    4232           0 :             pDescriptor->Put(aZoomItem);
    4233             : 
    4234             :             SAL_WNODEPRECATED_DECLARATIONS_PUSH
    4235           0 :             ::std::auto_ptr<AbstractSvxZoomDialog> pDlg( pFact->CreateSvxZoomDialog(NULL, *pDescriptor.get()) );
    4236             :             SAL_WNODEPRECATED_DECLARATIONS_POP
    4237           0 :             pDlg->SetLimits( 20, 400 );
    4238           0 :             bool bCancel = ( RET_CANCEL == pDlg->Execute() );
    4239             : 
    4240           0 :             if ( !bCancel )
    4241             :             {
    4242           0 :                 const SvxZoomItem&  rZoomItem = (const SvxZoomItem&)pDlg->GetOutputItemSet()->Get( SID_ATTR_ZOOM );
    4243           0 :                 m_eZoomType = rZoomItem.GetType();
    4244           0 :                 m_nZoomValue = rZoomItem.GetValue();
    4245           0 :                 if ( m_eZoomType != SVX_ZOOM_PERCENT )
    4246           0 :                     m_nZoomValue = getDesignView()->getZoomFactor( m_eZoomType );
    4247             : 
    4248           0 :                 impl_zoom_nothrow();
    4249           0 :             }
    4250             :         }
    4251           0 :         catch(const uno::Exception&)
    4252             :         {
    4253             :             DBG_UNHANDLED_EXCEPTION();
    4254             :         }
    4255           0 :         SfxItemPool::Free(pPool);
    4256             : 
    4257           0 :         for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
    4258           0 :             delete pDefaults[i];
    4259             :     }
    4260           0 : }
    4261             : 
    4262             : 
    4263             : // XVisualObject
    4264           0 : void SAL_CALL OReportController::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException, std::exception)
    4265             : {
    4266           0 :     ::osl::MutexGuard aGuard( getMutex() );
    4267             :         bool bChanged =
    4268           0 :             (m_aVisualAreaSize.Width != _aSize.Width ||
    4269           0 :              m_aVisualAreaSize.Height != _aSize.Height);
    4270           0 :         m_aVisualAreaSize = _aSize;
    4271           0 :         if( bChanged )
    4272           0 :             setModified( sal_True );
    4273           0 :     m_nAspect = _nAspect;
    4274           0 : }
    4275             : 
    4276           0 : awt::Size SAL_CALL OReportController::getVisualAreaSize( ::sal_Int64 /*nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException, std::exception)
    4277             : {
    4278           0 :     ::osl::MutexGuard aGuard( getMutex() );
    4279           0 :     return m_aVisualAreaSize;
    4280             : }
    4281             : 
    4282           0 : embed::VisualRepresentation SAL_CALL OReportController::getPreferredVisualRepresentation( ::sal_Int64 _nAspect ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException, std::exception)
    4283             : {
    4284           0 :     SolarMutexGuard aSolarGuard;
    4285           0 :     ::osl::MutexGuard aGuard( getMutex() );
    4286           0 :     embed::VisualRepresentation aResult;
    4287           0 :     if ( !m_bInGeneratePreview )
    4288             :     {
    4289           0 :         m_bInGeneratePreview = true;
    4290             :         try
    4291             :         {
    4292           0 :             if ( !m_xReportEngine.is() )
    4293           0 :                 m_xReportEngine.set( report::ReportEngine::create(m_xContext) );
    4294           0 :             const sal_Int32 nOldMaxRows = m_xReportEngine->getMaxRows();
    4295           0 :             m_xReportEngine->setMaxRows(MAX_ROWS_FOR_PREVIEW);
    4296           0 :             m_xReportEngine->setReportDefinition(m_xReportDefinition);
    4297           0 :             m_xReportEngine->setActiveConnection(getConnection());
    4298             :             try
    4299             :             {
    4300           0 :                 Reference<embed::XVisualObject> xTransfer(m_xReportEngine->createDocumentModel(),UNO_QUERY);
    4301           0 :                 if ( xTransfer.is() )
    4302             :                 {
    4303           0 :                     xTransfer->setVisualAreaSize(m_nAspect,m_aVisualAreaSize);
    4304           0 :                     aResult = xTransfer->getPreferredVisualRepresentation( _nAspect );
    4305           0 :                 }
    4306             :             }
    4307           0 :             catch(const uno::Exception&)
    4308             :             {
    4309             :             }
    4310           0 :             m_xReportEngine->setMaxRows(nOldMaxRows);
    4311             :         }
    4312           0 :         catch(const uno::Exception&)
    4313             :         {
    4314             :         }
    4315           0 :         m_bInGeneratePreview = false;
    4316             :     }
    4317           0 :     return aResult;
    4318             : }
    4319             : 
    4320           0 : ::sal_Int32 SAL_CALL OReportController::getMapUnit( ::sal_Int64 /*nAspect*/ ) throw (uno::Exception, uno::RuntimeException, std::exception)
    4321             : {
    4322           0 :     return embed::EmbedMapUnits::ONE_100TH_MM;
    4323             : }
    4324             : 
    4325           0 : uno::Reference< container::XNameAccess > OReportController::getColumns() const
    4326             : {
    4327           0 :     if ( !m_xColumns.is() && m_xReportDefinition.is() && !m_xReportDefinition->getCommand().isEmpty() )
    4328             :     {
    4329           0 :         m_xColumns = dbtools::getFieldsByCommandDescriptor(getConnection(),m_xReportDefinition->getCommandType(),m_xReportDefinition->getCommand(),m_xHoldAlive);
    4330             :     }
    4331           0 :     return m_xColumns;
    4332             : }
    4333             : 
    4334           0 : OUString OReportController::getColumnLabel_throw(const OUString& i_sColumnName) const
    4335             : {
    4336           0 :     OUString sLabel;
    4337           0 :     uno::Reference< container::XNameAccess > xColumns = getColumns();
    4338           0 :     if ( xColumns.is() && xColumns->hasByName(i_sColumnName) )
    4339             :     {
    4340           0 :         uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(i_sColumnName),uno::UNO_QUERY_THROW);
    4341           0 :         if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
    4342           0 :             xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
    4343             :     }
    4344           0 :     return sLabel;
    4345             : }
    4346             : 
    4347             : 
    4348           0 : SfxUndoManager& OReportController::getUndoManager() const
    4349             : {
    4350             :     DBG_TESTSOLARMUTEX();
    4351             :         // this is expected to be called during UI actions, so the SM is assumed to be locked
    4352             : 
    4353           0 :     ::boost::shared_ptr< OReportModel > pReportModel( getSdrModel() );
    4354           0 :     ENSURE_OR_THROW( !!pReportModel, "no access to our model" );
    4355             : 
    4356           0 :     SfxUndoManager* pUndoManager( pReportModel->GetSdrUndoManager() );
    4357           0 :     ENSURE_OR_THROW( pUndoManager != NULL, "no access to our model's UndoManager" );
    4358             : 
    4359           0 :     return *pUndoManager;
    4360             : }
    4361             : 
    4362             : 
    4363           0 : void OReportController::clearUndoManager() const
    4364             : {
    4365           0 :     getUndoManager().Clear();
    4366           0 : }
    4367             : 
    4368             : 
    4369           0 : void OReportController::addUndoAction( SfxUndoAction* i_pAction )
    4370             : {
    4371           0 :     getUndoManager().AddUndoAction( i_pAction );
    4372             : 
    4373           0 :     InvalidateFeature( SID_UNDO );
    4374           0 :     InvalidateFeature( SID_REDO );
    4375           0 : }
    4376             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10