LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - ReportController.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2292 0.0 %
Date: 2012-08-25 Functions: 0 117 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10