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

Generated by: LCOV version 1.11