LCOV - code coverage report
Current view: top level - basctl/source/dlged - dlged.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 703 0.0 %
Date: 2012-08-25 Functions: 0 54 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                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include "basidesh.hxx"
      22                 :            : #include "dlged.hxx"
      23                 :            : #include "dlgedclip.hxx"
      24                 :            : #include "dlgeddef.hxx"
      25                 :            : #include "dlgedfac.hxx"
      26                 :            : #include "dlgedfunc.hxx"
      27                 :            : #include "dlgedmod.hxx"
      28                 :            : #include "dlgedobj.hxx"
      29                 :            : #include "dlgedpage.hxx"
      30                 :            : #include "dlgedview.hxx"
      31                 :            : #include "iderdll.hxx"
      32                 :            : #include "localizationmgr.hxx"
      33                 :            : #include "propbrw.hxx"
      34                 :            : 
      35                 :            : #include <com/sun/star/awt/XDialog.hpp>
      36                 :            : #include <com/sun/star/resource/XStringResourcePersistence.hpp>
      37                 :            : #include <com/sun/star/util/XCloneable.hpp>
      38                 :            : #include <comphelper/types.hxx>
      39                 :            : #include <sfx2/viewfrm.hxx>
      40                 :            : #include <svl/itempool.hxx>
      41                 :            : #include <svx/sdrpaintwindow.hxx>
      42                 :            : #include <svx/svxids.hrc>
      43                 :            : #include <toolkit/helper/vclunohelper.hxx>
      44                 :            : #include <vcl/svapp.hxx>
      45                 :            : #include <xmlscript/xml_helper.hxx>
      46                 :            : #include <xmlscript/xmldlg_imexp.hxx>
      47                 :            : 
      48                 :            : using namespace comphelper;
      49                 :            : using namespace ::com::sun::star;
      50                 :            : using namespace ::com::sun::star::uno;
      51                 :            : using namespace ::com::sun::star::beans;
      52                 :            : using namespace ::com::sun::star::io;
      53                 :            : using ::rtl::OUString;
      54                 :            : 
      55                 :          0 : static ::rtl::OUString aResourceResolverPropName( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ));
      56                 :          0 : static ::rtl::OUString aDecorationPropName( RTL_CONSTASCII_USTRINGPARAM( "Decoration" ));
      57                 :          0 : static ::rtl::OUString aTitlePropName( RTL_CONSTASCII_USTRINGPARAM( "Title" ));
      58                 :            : 
      59                 :            : 
      60                 :            : //============================================================================
      61                 :            : // DlgEdHint
      62                 :            : //============================================================================
      63                 :            : 
      64                 :          0 : TYPEINIT1( DlgEdHint, SfxHint );
      65                 :            : 
      66                 :          0 : DlgEdHint::DlgEdHint( DlgEdHintKind eHint )
      67                 :          0 :     :eHintKind( eHint )
      68                 :            : {
      69                 :          0 : }
      70                 :            : 
      71                 :            : 
      72                 :          0 : DlgEdHint::DlgEdHint( DlgEdHintKind eHint, DlgEdObj* pObj )
      73                 :            :     :eHintKind( eHint )
      74                 :          0 :     ,pDlgEdObj( pObj )
      75                 :            : {
      76                 :          0 : }
      77                 :            : 
      78                 :            : 
      79                 :          0 : DlgEdHint::~DlgEdHint()
      80                 :            : {
      81                 :          0 : }
      82                 :            : 
      83                 :            : 
      84                 :            : //============================================================================
      85                 :            : // DlgEditor
      86                 :            : //============================================================================
      87                 :            : 
      88                 :          0 : void DlgEditor::ShowDialog()
      89                 :            : {
      90                 :          0 :     uno::Reference< lang::XMultiServiceFactory >  xMSF = getProcessServiceFactory();
      91                 :            : 
      92                 :            :     // create a dialog
      93                 :          0 :     uno::Reference< awt::XControl > xDlg( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), uno::UNO_QUERY );
      94                 :            : 
      95                 :            :     // clone the dialog model
      96                 :          0 :     uno::Reference< util::XCloneable > xC( m_xUnoControlDialogModel, uno::UNO_QUERY );
      97                 :          0 :     uno::Reference< util::XCloneable > xNew = xC->createClone();
      98                 :          0 :     uno::Reference< awt::XControlModel > xDlgMod( xNew, uno::UNO_QUERY );
      99                 :            : 
     100                 :          0 :     uno::Reference< beans::XPropertySet > xSrcDlgModPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
     101                 :          0 :     uno::Reference< beans::XPropertySet > xNewDlgModPropSet( xDlgMod, uno::UNO_QUERY );
     102                 :          0 :     if( xNewDlgModPropSet.is() )
     103                 :            :     {
     104                 :          0 :         if( xSrcDlgModPropSet.is() )
     105                 :            :         {
     106                 :            :             try
     107                 :            :             {
     108                 :          0 :                 Any aResourceResolver = xSrcDlgModPropSet->getPropertyValue( aResourceResolverPropName );
     109                 :          0 :                 xNewDlgModPropSet->setPropertyValue( aResourceResolverPropName, aResourceResolver );
     110                 :            :             }
     111                 :          0 :             catch(const UnknownPropertyException& )
     112                 :            :             {
     113                 :            :                 OSL_FAIL( "DlgEditor::ShowDialog(): No ResourceResolver property" );
     114                 :            :             }
     115                 :            :         }
     116                 :            : 
     117                 :            :         // Disable decoration
     118                 :          0 :         bool bDecoration = true;
     119                 :            :         try
     120                 :            :         {
     121                 :          0 :             Any aDecorationAny = xSrcDlgModPropSet->getPropertyValue( aDecorationPropName );
     122                 :          0 :             aDecorationAny >>= bDecoration;
     123                 :          0 :             if( !bDecoration )
     124                 :            :             {
     125                 :          0 :                 xNewDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) );
     126                 :          0 :                 xNewDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( ::rtl::OUString() ) );
     127                 :          0 :             }
     128                 :            :         }
     129                 :          0 :         catch(const UnknownPropertyException& )
     130                 :            :         {}
     131                 :            :     }
     132                 :            : 
     133                 :            :     // set the model
     134                 :          0 :     xDlg->setModel( xDlgMod );
     135                 :            : 
     136                 :            :     // create a peer
     137                 :          0 :     uno::Reference< awt::XToolkit> xToolkit( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.ExtToolkit" ) ) ), uno::UNO_QUERY );
     138                 :          0 :     xDlg->createPeer( xToolkit, pWindow->GetComponentInterface() );
     139                 :            : 
     140                 :          0 :     uno::Reference< awt::XDialog > xD( xDlg, uno::UNO_QUERY );
     141                 :          0 :     xD->execute();
     142                 :            : 
     143                 :          0 :     uno::Reference< lang::XComponent > xComponent(xDlg, uno::UNO_QUERY);
     144                 :          0 :     if (xComponent.is())
     145                 :          0 :         xComponent->dispose();
     146                 :          0 : }
     147                 :            : 
     148                 :            : 
     149                 :          0 : bool DlgEditor::UnmarkDialog()
     150                 :            : {
     151                 :          0 :     SdrObject*      pDlgObj = pDlgEdModel->GetPage(0)->GetObj(0);
     152                 :          0 :     SdrPageView*    pPgView = pDlgEdView->GetSdrPageView();
     153                 :            : 
     154                 :          0 :     bool bWasMarked = pDlgEdView->IsObjMarked( pDlgObj );
     155                 :            : 
     156                 :          0 :     if( bWasMarked )
     157                 :          0 :         pDlgEdView->MarkObj( pDlgObj, pPgView, true );
     158                 :            : 
     159                 :          0 :     return bWasMarked;
     160                 :            : }
     161                 :            : 
     162                 :            : 
     163                 :          0 : bool DlgEditor::RemarkDialog()
     164                 :            : {
     165                 :          0 :     SdrObject*      pDlgObj = pDlgEdModel->GetPage(0)->GetObj(0);
     166                 :          0 :     SdrPageView*    pPgView = pDlgEdView->GetSdrPageView();
     167                 :            : 
     168                 :          0 :     bool bWasMarked = pDlgEdView->IsObjMarked( pDlgObj );
     169                 :            : 
     170                 :          0 :     if( !bWasMarked )
     171                 :          0 :         pDlgEdView->MarkObj( pDlgObj, pPgView, false );
     172                 :            : 
     173                 :          0 :     return bWasMarked;
     174                 :            : }
     175                 :            : 
     176                 :            : 
     177                 :          0 : DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel )
     178                 :            :     :pHScroll(NULL)
     179                 :            :     ,pVScroll(NULL)
     180                 :            :     ,pDlgEdModel(NULL)
     181                 :            :     ,pDlgEdPage(NULL)
     182                 :            :     ,pDlgEdView(NULL)
     183                 :            :     ,pDlgEdForm(NULL)
     184                 :            :     ,m_xUnoControlDialogModel(NULL)
     185                 :            :     ,m_ClipboardDataFlavors(1)
     186                 :            :     ,m_ClipboardDataFlavorsResource(2)
     187                 :            :     ,pObjFac(NULL)
     188                 :            :     ,pWindow(NULL)
     189                 :            :     ,pFunc(NULL)
     190                 :            :     ,eMode( DLGED_SELECT )
     191                 :            :     ,eActObj( OBJ_DLG_PUSHBUTTON )
     192                 :            :     ,bFirstDraw(false)
     193                 :            :     ,aGridSize( 100, 100 )  // 100TH_MM
     194                 :            :     ,bGridVisible(false)
     195                 :            :     ,bGridSnap(true)
     196                 :            :     ,bCreateOK(true)
     197                 :            :     ,bDialogModelChanged(false)
     198                 :            :     ,mnPaintGuard(0)
     199                 :          0 :     ,m_xDocument( xModel )
     200                 :            : {
     201                 :          0 :     pDlgEdModel = new DlgEdModel();
     202                 :          0 :     pDlgEdModel->GetItemPool().FreezeIdRanges();
     203                 :          0 :     pDlgEdModel->SetScaleUnit( MAP_100TH_MM );
     204                 :            : 
     205                 :          0 :     SdrLayerAdmin& rAdmin = pDlgEdModel->GetLayerAdmin();
     206                 :          0 :     rAdmin.NewLayer( rAdmin.GetControlLayerName() );
     207                 :          0 :     rAdmin.NewLayer( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HiddenLayer")) );
     208                 :            : 
     209                 :          0 :     pDlgEdPage = new DlgEdPage( *pDlgEdModel );
     210                 :          0 :     pDlgEdModel->InsertPage( pDlgEdPage );
     211                 :            : 
     212                 :          0 :     pObjFac = new DlgEdFactory(xModel);
     213                 :            : 
     214                 :          0 :     pFunc = new DlgEdFuncSelect( this );
     215                 :            : 
     216                 :            :     // set clipboard data flavors
     217                 :          0 :     m_ClipboardDataFlavors[0].MimeType =             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.xml.dialog" ));
     218                 :          0 :     m_ClipboardDataFlavors[0].HumanPresentableName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dialog 6.0" ));
     219                 :          0 :     m_ClipboardDataFlavors[0].DataType =             ::getCppuType( (const Sequence< sal_Int8 >*) 0 );
     220                 :            : 
     221                 :          0 :     m_ClipboardDataFlavorsResource[0] =                      m_ClipboardDataFlavors[0];
     222                 :          0 :     m_ClipboardDataFlavorsResource[1].MimeType =             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.xml.dialogwithresource" ));
     223                 :          0 :     m_ClipboardDataFlavorsResource[1].HumanPresentableName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dialog 8.0" ));
     224                 :          0 :     m_ClipboardDataFlavorsResource[1].DataType =             ::getCppuType( (const Sequence< sal_Int8 >*) 0 );
     225                 :            : 
     226                 :          0 :     aPaintTimer.SetTimeout( 1 );
     227                 :          0 :     aPaintTimer.SetTimeoutHdl( LINK( this, DlgEditor, PaintTimeout ) );
     228                 :            : 
     229                 :          0 :     aMarkTimer.SetTimeout( 100 );
     230                 :          0 :     aMarkTimer.SetTimeoutHdl( LINK( this, DlgEditor, MarkTimeout ) );
     231                 :          0 : }
     232                 :            : 
     233                 :            : 
     234                 :          0 : DlgEditor::~DlgEditor()
     235                 :            : {
     236                 :          0 :     aPaintTimer.Stop();
     237                 :          0 :     aMarkTimer.Stop();
     238                 :            : 
     239                 :          0 :     ::comphelper::disposeComponent( m_xControlContainer );
     240                 :            : 
     241                 :          0 :     delete pObjFac;
     242                 :          0 :     delete pFunc;
     243                 :          0 :     delete pDlgEdView;
     244                 :          0 :     delete pDlgEdModel;
     245                 :          0 : }
     246                 :            : 
     247                 :            : 
     248                 :          0 : Reference< awt::XControlContainer > DlgEditor::GetWindowControlContainer()
     249                 :            : {
     250                 :          0 :     if ( !m_xControlContainer.is() && pWindow )
     251                 :          0 :         m_xControlContainer = VCLUnoHelper::CreateControlContainer( pWindow );
     252                 :          0 :     return m_xControlContainer;
     253                 :            : }
     254                 :            : 
     255                 :            : 
     256                 :          0 : void DlgEditor::SetWindow( Window* pWindow_ )
     257                 :            : {
     258                 :          0 :     DlgEditor::pWindow = pWindow_;
     259                 :          0 :     pWindow_->SetMapMode( MapMode( MAP_100TH_MM ) );
     260                 :          0 :     pDlgEdPage->SetSize( pWindow_->PixelToLogic( Size( DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN ) ) );
     261                 :            : 
     262                 :          0 :     pDlgEdView = new DlgEdView( pDlgEdModel, pWindow_, this );
     263                 :          0 :     pDlgEdView->ShowSdrPage(pDlgEdView->GetModel()->GetPage(0));
     264                 :          0 :     pDlgEdView->SetLayerVisible( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HiddenLayer")), false );
     265                 :          0 :     pDlgEdView->SetMoveSnapOnlyTopLeft(true);
     266                 :          0 :     pDlgEdView->SetWorkArea( Rectangle( Point( 0, 0 ), pDlgEdPage->GetSize() ) );
     267                 :            : 
     268                 :          0 :     pDlgEdView->SetGridCoarse( aGridSize );
     269                 :          0 :     pDlgEdView->SetSnapGridWidth(Fraction(aGridSize.Width(), 1), Fraction(aGridSize.Height(), 1));
     270                 :          0 :     pDlgEdView->SetGridSnap( bGridSnap );
     271                 :          0 :     pDlgEdView->SetGridVisible( bGridVisible );
     272                 :          0 :     pDlgEdView->SetDragStripes(false);
     273                 :            : 
     274                 :          0 :     pDlgEdView->SetDesignMode(true);
     275                 :            : 
     276                 :          0 :     ::comphelper::disposeComponent( m_xControlContainer );
     277                 :          0 : }
     278                 :            : 
     279                 :            : 
     280                 :          0 : void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS )
     281                 :            : {
     282                 :          0 :     pHScroll = pHS;
     283                 :          0 :     pVScroll = pVS;
     284                 :            : 
     285                 :          0 :     InitScrollBars();
     286                 :          0 : }
     287                 :            : 
     288                 :            : 
     289                 :          0 : void DlgEditor::InitScrollBars()
     290                 :            : {
     291                 :            :     DBG_ASSERT( pHScroll, "DlgEditor::InitScrollBars: no horizontal scroll bar!" );
     292                 :            :     DBG_ASSERT( pVScroll, "DlgEditor::InitScrollBars: no vertical scroll bar!" );
     293                 :          0 :     if ( !pHScroll || !pVScroll )
     294                 :          0 :         return;
     295                 :            : 
     296                 :          0 :     Size aOutSize = pWindow->GetOutputSize();
     297                 :          0 :     Size aPgSize  = pDlgEdPage->GetSize();
     298                 :            : 
     299                 :          0 :     pHScroll->SetRange( Range( 0, aPgSize.Width()  ));
     300                 :          0 :     pVScroll->SetRange( Range( 0, aPgSize.Height() ));
     301                 :          0 :     pHScroll->SetVisibleSize( (sal_uLong)aOutSize.Width() );
     302                 :          0 :     pVScroll->SetVisibleSize( (sal_uLong)aOutSize.Height() );
     303                 :            : 
     304                 :          0 :     pHScroll->SetLineSize( aOutSize.Width() / 10 );
     305                 :          0 :     pVScroll->SetLineSize( aOutSize.Height() / 10 );
     306                 :          0 :     pHScroll->SetPageSize( aOutSize.Width() / 2 );
     307                 :          0 :     pVScroll->SetPageSize( aOutSize.Height() / 2 );
     308                 :            : 
     309                 :          0 :     DoScroll( pHScroll );
     310                 :          0 :     DoScroll( pVScroll );
     311                 :            : }
     312                 :            : 
     313                 :            : 
     314                 :          0 : void DlgEditor::DoScroll( ScrollBar* )
     315                 :            : {
     316                 :          0 :     if( !pHScroll || !pVScroll )
     317                 :            :         return;
     318                 :            : 
     319                 :          0 :     MapMode aMap = pWindow->GetMapMode();
     320                 :          0 :     Point aOrg = aMap.GetOrigin();
     321                 :            : 
     322                 :          0 :     Size  aScrollPos( pHScroll->GetThumbPos(), pVScroll->GetThumbPos() );
     323                 :          0 :     aScrollPos = pWindow->LogicToPixel( aScrollPos );
     324                 :          0 :     aScrollPos = pWindow->PixelToLogic( aScrollPos );
     325                 :            : 
     326                 :          0 :     long  nX   = aScrollPos.Width() + aOrg.X();
     327                 :          0 :     long  nY   = aScrollPos.Height() + aOrg.Y();
     328                 :            : 
     329                 :          0 :     if( !nX && !nY )
     330                 :            :         return;
     331                 :            : 
     332                 :          0 :     pWindow->Update();
     333                 :            : 
     334                 :            :     // #i31562#
     335                 :            :     // When scrolling, someone was rescuing the Wallpaper and forced the window scroll to
     336                 :            :     // be done without background refresh. I do not know why, but that causes the repaint
     337                 :            :     // problems. Taking that out.
     338                 :            :     //  Wallpaper aOldBackground = pWindow->GetBackground();
     339                 :            :     //  pWindow->SetBackground();
     340                 :            : 
     341                 :            :     // #i74769# children should be scrolled
     342                 :          0 :     pWindow->Scroll( -nX, -nY, SCROLL_CHILDREN);
     343                 :          0 :     aMap.SetOrigin( Point( -aScrollPos.Width(), -aScrollPos.Height() ) );
     344                 :          0 :     pWindow->SetMapMode( aMap );
     345                 :          0 :     pWindow->Update();
     346                 :            : 
     347                 :          0 :     DlgEdHint aHint( DLGED_HINT_WINDOWSCROLLED );
     348                 :          0 :     Broadcast( aHint );
     349                 :            : }
     350                 :            : 
     351                 :            : 
     352                 :          0 : void DlgEditor::UpdateScrollBars()
     353                 :            : {
     354                 :          0 :     MapMode aMap = pWindow->GetMapMode();
     355                 :          0 :     Point aOrg = aMap.GetOrigin();
     356                 :            : 
     357                 :          0 :     if ( pHScroll )
     358                 :          0 :         pHScroll->SetThumbPos( -aOrg.X() );
     359                 :            : 
     360                 :          0 :     if ( pVScroll )
     361                 :          0 :         pVScroll->SetThumbPos( -aOrg.Y() );
     362                 :          0 : }
     363                 :            : 
     364                 :            : 
     365                 :          0 : void DlgEditor::SetDialog( uno::Reference< container::XNameContainer > xUnoControlDialogModel )
     366                 :            : {
     367                 :            :     // set dialog model
     368                 :          0 :     m_xUnoControlDialogModel = xUnoControlDialogModel;
     369                 :            : 
     370                 :            :     // create dialog form
     371                 :          0 :     pDlgEdForm = new DlgEdForm();
     372                 :          0 :     uno::Reference< awt::XControlModel > xDlgMod( m_xUnoControlDialogModel , uno::UNO_QUERY );
     373                 :          0 :     pDlgEdForm->SetUnoControlModel(xDlgMod);
     374                 :          0 :     pDlgEdForm->SetDlgEditor( this );
     375                 :          0 :     ((DlgEdPage*)pDlgEdModel->GetPage(0))->SetDlgEdForm( pDlgEdForm );
     376                 :          0 :     pDlgEdModel->GetPage(0)->InsertObject( pDlgEdForm );
     377                 :          0 :     AdjustPageSize();
     378                 :          0 :     pDlgEdForm->SetRectFromProps();
     379                 :          0 :     pDlgEdForm->UpdateTabIndices();     // for backward compatibility
     380                 :          0 :     pDlgEdForm->StartListening();
     381                 :            : 
     382                 :            :     // create controls
     383                 :          0 :     Reference< ::com::sun::star::container::XNameAccess > xNameAcc( m_xUnoControlDialogModel, UNO_QUERY );
     384                 :          0 :     if ( xNameAcc.is() )
     385                 :            :     {
     386                 :            :         // get sequence of control names
     387                 :          0 :         Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
     388                 :          0 :         const ::rtl::OUString* pNames = aNames.getConstArray();
     389                 :          0 :         sal_Int32 nCtrls = aNames.getLength();
     390                 :            : 
     391                 :            :         // create a map of tab indices and control names, sorted by tab index
     392                 :          0 :         IndexToNameMap aIndexToNameMap;
     393                 :          0 :         for ( sal_Int32 i = 0; i < nCtrls; ++i )
     394                 :            :         {
     395                 :            :             // get name
     396                 :          0 :             ::rtl::OUString aName( pNames[i] );
     397                 :            : 
     398                 :            :             // get tab index
     399                 :          0 :             sal_Int16 nTabIndex = -1;
     400                 :          0 :             Any aCtrl = xNameAcc->getByName( aName );
     401                 :          0 :             Reference< ::com::sun::star::beans::XPropertySet > xPSet;
     402                 :          0 :                aCtrl >>= xPSet;
     403                 :          0 :             if ( xPSet.is() )
     404                 :          0 :                 xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
     405                 :            : 
     406                 :            :             // insert into map
     407                 :          0 :             aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
     408                 :          0 :         }
     409                 :            : 
     410                 :            :         // create controls and insert them into drawing page
     411                 :          0 :         for ( IndexToNameMap::iterator aIt = aIndexToNameMap.begin(); aIt != aIndexToNameMap.end(); ++aIt )
     412                 :            :         {
     413                 :          0 :             Any aCtrl = xNameAcc->getByName( aIt->second );
     414                 :          0 :             Reference< ::com::sun::star::awt::XControlModel > xCtrlModel;
     415                 :          0 :             aCtrl >>= xCtrlModel;
     416                 :          0 :             DlgEdObj* pCtrlObj = new DlgEdObj();
     417                 :          0 :             pCtrlObj->SetUnoControlModel( xCtrlModel );
     418                 :          0 :             pCtrlObj->SetDlgEdForm( pDlgEdForm );
     419                 :          0 :             pDlgEdForm->AddChild( pCtrlObj );
     420                 :          0 :             pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
     421                 :          0 :             pCtrlObj->SetRectFromProps();
     422                 :          0 :             pCtrlObj->UpdateStep();
     423                 :          0 :             pCtrlObj->StartListening();
     424                 :          0 :         }
     425                 :            :     }
     426                 :            : 
     427                 :          0 :     bFirstDraw = true;
     428                 :            : 
     429                 :          0 :     pDlgEdModel->SetChanged(false);
     430                 :          0 : }
     431                 :            : 
     432                 :          0 : void DlgEditor::ResetDialog ()
     433                 :            : {
     434                 :          0 :     DlgEdForm* pOldDlgEdForm = pDlgEdForm;
     435                 :          0 :     DlgEdPage* pPage = (DlgEdPage*)pDlgEdModel->GetPage(0);
     436                 :          0 :     SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
     437                 :          0 :     bool bWasMarked = pDlgEdView->IsObjMarked( pOldDlgEdForm );
     438                 :          0 :     pDlgEdView->UnmarkAll();
     439                 :          0 :     pPage->Clear();
     440                 :          0 :     pPage->SetDlgEdForm( NULL );
     441                 :          0 :     SetDialog( m_xUnoControlDialogModel );
     442                 :          0 :     if( bWasMarked )
     443                 :          0 :         pDlgEdView->MarkObj( pDlgEdForm, pPgView, false );
     444                 :          0 : }
     445                 :            : 
     446                 :            : 
     447                 :          0 : Reference< util::XNumberFormatsSupplier > const & DlgEditor::GetNumberFormatsSupplier()
     448                 :            : {
     449                 :          0 :     if ( !m_xSupplier.is() )
     450                 :            :     {
     451                 :          0 :         Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
     452                 :          0 :         Reference< util::XNumberFormatsSupplier > xSupplier( xMSF->createInstance(
     453                 :          0 :             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatsSupplier") ) ), UNO_QUERY );
     454                 :            : 
     455                 :          0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     456                 :          0 :         if ( !m_xSupplier.is() )
     457                 :            :         {
     458                 :          0 :             m_xSupplier = xSupplier;
     459                 :          0 :         }
     460                 :            :     }
     461                 :          0 :     return m_xSupplier;
     462                 :            : }
     463                 :            : 
     464                 :            : 
     465                 :          0 : void DlgEditor::MouseButtonDown( const MouseEvent& rMEvt )
     466                 :            : {
     467                 :          0 :     if( pWindow )
     468                 :          0 :         pWindow->GrabFocus();
     469                 :          0 :     pFunc->MouseButtonDown( rMEvt );
     470                 :          0 : }
     471                 :            : 
     472                 :            : 
     473                 :          0 : void DlgEditor::MouseButtonUp( const MouseEvent& rMEvt )
     474                 :            : {
     475                 :          0 :     bool bRet = pFunc->MouseButtonUp( rMEvt );
     476                 :            : 
     477                 :          0 :     if( eMode == DLGED_INSERT )
     478                 :          0 :         bCreateOK = bRet;
     479                 :          0 : }
     480                 :            : 
     481                 :            : 
     482                 :          0 : void DlgEditor::MouseMove( const MouseEvent& rMEvt )
     483                 :            : {
     484                 :          0 :     pFunc->MouseMove( rMEvt );
     485                 :          0 : }
     486                 :            : 
     487                 :            : 
     488                 :          0 : bool DlgEditor::KeyInput( const KeyEvent& rKEvt )
     489                 :            : {
     490                 :          0 :     return pFunc->KeyInput( rKEvt );
     491                 :            : }
     492                 :            : 
     493                 :            : 
     494                 :          0 : void DlgEditor::Paint( const Rectangle& rRect )
     495                 :            : {
     496                 :          0 :     aPaintRect = rRect;
     497                 :          0 :     PaintTimeout( &aPaintTimer );
     498                 :          0 : }
     499                 :            : 
     500                 :            : 
     501                 :          0 : IMPL_LINK_NOARG(DlgEditor, PaintTimeout)
     502                 :            : {
     503                 :          0 :     if( !pDlgEdView )
     504                 :          0 :         return 0;
     505                 :            : 
     506                 :          0 :     mnPaintGuard++;
     507                 :            : 
     508                 :          0 :     Size aMacSize;
     509                 :          0 :     if( bFirstDraw &&
     510                 :          0 :         pWindow->IsVisible() &&
     511                 :          0 :         (pWindow->GetOutputSize() != aMacSize) )
     512                 :            :     {
     513                 :          0 :         bFirstDraw = false;
     514                 :            : 
     515                 :            :         // get property set
     516                 :          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  xPSet(pDlgEdForm->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
     517                 :            : 
     518                 :          0 :         if ( xPSet.is() )
     519                 :            :         {
     520                 :            :             // get dialog size from properties
     521                 :          0 :             sal_Int32 nWidth = 0, nHeight = 0;
     522                 :          0 :             xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
     523                 :          0 :             xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
     524                 :            : 
     525                 :          0 :             if ( nWidth == 0 && nHeight == 0 )
     526                 :            :             {
     527                 :          0 :                 Size   aSize = pWindow->PixelToLogic( Size( 400, 300 ) );
     528                 :            : 
     529                 :            :                 // align with grid
     530                 :          0 :                 Size aGridSize_(long(pDlgEdView->GetSnapGridWidthX()), long(pDlgEdView->GetSnapGridWidthY()));
     531                 :          0 :                 aSize.Width()  -= aSize.Width()  % aGridSize_.Width();
     532                 :          0 :                 aSize.Height() -= aSize.Height() % aGridSize_.Height();
     533                 :            : 
     534                 :          0 :                 Point  aPos;
     535                 :          0 :                 Size   aOutSize = pWindow->GetOutputSize();
     536                 :          0 :                 aPos.X() = (aOutSize.Width()>>1)  -  (aSize.Width()>>1);
     537                 :          0 :                 aPos.Y() = (aOutSize.Height()>>1) -  (aSize.Height()>>1);
     538                 :            : 
     539                 :            :                 // align with grid
     540                 :          0 :                 aPos.X() -= aPos.X() % aGridSize_.Width();
     541                 :          0 :                 aPos.Y() -= aPos.Y() % aGridSize_.Height();
     542                 :            : 
     543                 :            :                 // don't put in the corner
     544                 :          0 :                 Point aMinPos = pWindow->PixelToLogic( Point( 30, 20 ) );
     545                 :          0 :                 if( (aPos.X() < aMinPos.X()) || (aPos.Y() < aMinPos.Y()) )
     546                 :            :                 {
     547                 :          0 :                     aPos = aMinPos;
     548                 :          0 :                     aPos.X() -= aPos.X() % aGridSize_.Width();
     549                 :          0 :                     aPos.Y() -= aPos.Y() % aGridSize_.Height();
     550                 :            :                 }
     551                 :            : 
     552                 :            :                 // set dialog position and size
     553                 :          0 :                 pDlgEdForm->SetSnapRect( Rectangle( aPos, aSize ) );
     554                 :          0 :                 pDlgEdForm->EndListening(false);
     555                 :          0 :                 pDlgEdForm->SetPropsFromRect();
     556                 :          0 :                 pDlgEdForm->GetDlgEditor()->SetDialogModelChanged(true);
     557                 :          0 :                 pDlgEdForm->StartListening();
     558                 :            : 
     559                 :            :                 // set position and size of controls
     560                 :            :                 sal_uLong nObjCount;
     561                 :          0 :                 if ( pDlgEdPage && ( ( nObjCount = pDlgEdPage->GetObjCount() ) > 0 ) )
     562                 :            :                 {
     563                 :          0 :                     for ( sal_uLong i = 0 ; i < nObjCount ; i++ )
     564                 :          0 :                         if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pDlgEdPage->GetObj(i)))
     565                 :          0 :                             if (!dynamic_cast<DlgEdForm*>(pDlgEdObj))
     566                 :          0 :                                 pDlgEdObj->SetRectFromProps();
     567                 :            :                 }
     568                 :            :             }
     569                 :          0 :         }
     570                 :            :     }
     571                 :            : 
     572                 :            :     // repaint, get PageView and prepare Region
     573                 :          0 :     SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
     574                 :          0 :     const Region aPaintRectRegion(aPaintRect);
     575                 :            : 
     576                 :            : 
     577                 :            :     // #i74769#
     578                 :          0 :     SdrPaintWindow* pTargetPaintWindow = 0;
     579                 :            : 
     580                 :            :     // mark repaint start
     581                 :          0 :     if(pPgView)
     582                 :            :     {
     583                 :          0 :         pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(pWindow, aPaintRectRegion);
     584                 :            :         OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
     585                 :            :     }
     586                 :            : 
     587                 :            :     // draw background self using wallpaper
     588                 :            :     // #i79128# ...and use correct OutDev for that
     589                 :          0 :     if(pTargetPaintWindow)
     590                 :            :     {
     591                 :          0 :         OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
     592                 :          0 :         rTargetOutDev.DrawWallpaper(aPaintRect, Wallpaper(Color(COL_WHITE)));
     593                 :            :     }
     594                 :            : 
     595                 :            :     // do paint (unbuffered) and mark repaint end
     596                 :          0 :     if(pPgView)
     597                 :            :     {
     598                 :            :         // paint of control layer is done in EndDrawLayers anyway...
     599                 :          0 :         pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
     600                 :            :     }
     601                 :            : 
     602                 :          0 :     mnPaintGuard--;
     603                 :            : 
     604                 :            :     DBG_ASSERT(pWindow,"Window not set");
     605                 :          0 :     return 0;
     606                 :            : }
     607                 :            : 
     608                 :            : 
     609                 :          0 : IMPL_LINK_NOARG(DlgEditor, MarkTimeout)
     610                 :            : {
     611                 :          0 :     BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
     612                 :            : 
     613                 :          0 :     SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
     614                 :          0 :     SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SHOW_PROPERTYBROWSER ) : NULL;
     615                 :          0 :     if ( !pChildWin )
     616                 :          0 :         return 0L;
     617                 :            : 
     618                 :          0 :     ((PropBrw*)(pChildWin->GetWindow()))->Update( pIDEShell );
     619                 :            : 
     620                 :          0 :     return 1;
     621                 :            : }
     622                 :            : 
     623                 :            : 
     624                 :          0 : void DlgEditor::SetMode( DlgEdMode eNewMode )
     625                 :            : {
     626                 :          0 :     if ( eNewMode != eMode )
     627                 :            :     {
     628                 :          0 :         delete pFunc;
     629                 :            : 
     630                 :          0 :         if ( eNewMode == DLGED_INSERT )
     631                 :          0 :             pFunc = new DlgEdFuncInsert( this );
     632                 :            :         else
     633                 :          0 :             pFunc = new DlgEdFuncSelect( this );
     634                 :            : 
     635                 :          0 :         if ( eNewMode == DLGED_READONLY )
     636                 :          0 :             pDlgEdModel->SetReadOnly( true );
     637                 :            :         else
     638                 :          0 :             pDlgEdModel->SetReadOnly( false );
     639                 :            :     }
     640                 :            : 
     641                 :          0 :     if ( eNewMode == DLGED_TEST )
     642                 :          0 :         ShowDialog();
     643                 :            : 
     644                 :          0 :     eMode = eNewMode;
     645                 :          0 : }
     646                 :            : 
     647                 :            : 
     648                 :          0 : void DlgEditor::SetInsertObj( sal_uInt16 eObj )
     649                 :            : {
     650                 :          0 :     eActObj = eObj;
     651                 :            : 
     652                 :          0 :     if( pDlgEdView )
     653                 :          0 :         pDlgEdView->SetCurrentObj( eActObj, DlgInventor );
     654                 :          0 : }
     655                 :            : 
     656                 :            : 
     657                 :          0 : sal_uInt16 DlgEditor::GetInsertObj() const
     658                 :            : {
     659                 :          0 :     return eActObj;
     660                 :            : }
     661                 :            : 
     662                 :            : 
     663                 :          0 : void DlgEditor::CreateDefaultObject()
     664                 :            : {
     665                 :            :     // create object by factory
     666                 :          0 :     SdrObject* pObj = SdrObjFactory::MakeNewObject( pDlgEdView->GetCurrentObjInventor(), pDlgEdView->GetCurrentObjIdentifier(), pDlgEdPage );
     667                 :            : 
     668                 :          0 :     if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj))
     669                 :            :     {
     670                 :            :         // set position and size
     671                 :          0 :         Size aSize = pWindow->PixelToLogic( Size( 96, 24 ) );
     672                 :          0 :         Point aPoint = (pDlgEdForm->GetSnapRect()).Center();
     673                 :          0 :         aPoint.X() -= aSize.Width() / 2;
     674                 :          0 :         aPoint.Y() -= aSize.Height() / 2;
     675                 :          0 :         pDlgEdObj->SetSnapRect( Rectangle( aPoint, aSize ) );
     676                 :            : 
     677                 :            :         // set default property values
     678                 :          0 :         pDlgEdObj->SetDefaults();
     679                 :            : 
     680                 :            :         // insert object into drawing page
     681                 :          0 :         SdrPageView* pPageView = pDlgEdView->GetSdrPageView();
     682                 :          0 :         pDlgEdView->InsertObjectAtView( pDlgEdObj, *pPageView);
     683                 :            : 
     684                 :            :         // start listening
     685                 :          0 :         pDlgEdObj->StartListening();
     686                 :            :     }
     687                 :          0 : }
     688                 :            : 
     689                 :            : 
     690                 :          0 : void DlgEditor::Cut()
     691                 :            : {
     692                 :          0 :     Copy();
     693                 :          0 :     Delete();
     694                 :          0 : }
     695                 :            : 
     696                 :            : 
     697                 :          0 : void implCopyStreamToByteSequence( Reference< XInputStream > xStream,
     698                 :            :     Sequence< sal_Int8 >& bytes )
     699                 :            : {
     700                 :          0 :     sal_Int32 nRead = xStream->readBytes( bytes, xStream->available() );
     701                 :          0 :     for (;;)
     702                 :            :     {
     703                 :          0 :         Sequence< sal_Int8 > readBytes;
     704                 :          0 :         nRead = xStream->readBytes( readBytes, 1024 );
     705                 :          0 :         if (! nRead)
     706                 :            :             break;
     707                 :            : 
     708                 :          0 :         sal_Int32 nPos = bytes.getLength();
     709                 :          0 :         bytes.realloc( nPos + nRead );
     710                 :          0 :         ::rtl_copyMemory( bytes.getArray() + nPos, readBytes.getConstArray(), (sal_uInt32)nRead );
     711                 :          0 :     }
     712                 :          0 : }
     713                 :            : 
     714                 :          0 : void DlgEditor::Copy()
     715                 :            : {
     716                 :          0 :     if( !pDlgEdView->AreObjectsMarked() )
     717                 :          0 :         return;
     718                 :            : 
     719                 :            :     // stop all drawing actions
     720                 :          0 :     pDlgEdView->BrkAction();
     721                 :            : 
     722                 :            :     // create an empty clipboard dialog model
     723                 :          0 :     Reference< util::XCloneable > xClone( m_xUnoControlDialogModel, UNO_QUERY );
     724                 :          0 :     Reference< util::XCloneable > xNewClone = xClone->createClone();
     725                 :          0 :     Reference< container::XNameContainer > xClipDialogModel( xNewClone, UNO_QUERY );
     726                 :            : 
     727                 :          0 :     Reference< container::XNameAccess > xNAcc( xClipDialogModel, UNO_QUERY );
     728                 :          0 :     if ( xNAcc.is() )
     729                 :            :     {
     730                 :          0 :            Sequence< OUString > aNames = xNAcc->getElementNames();
     731                 :          0 :            const OUString* pNames = aNames.getConstArray();
     732                 :          0 :         sal_uInt32 nCtrls = aNames.getLength();
     733                 :            : 
     734                 :          0 :         for ( sal_uInt32 n = 0; n < nCtrls; n++ )
     735                 :            :         {
     736                 :          0 :                xClipDialogModel->removeByName( pNames[n] );
     737                 :          0 :         }
     738                 :            :     }
     739                 :            : 
     740                 :            :     // insert control models of marked objects into clipboard dialog model
     741                 :          0 :     sal_uLong nMark = pDlgEdView->GetMarkedObjectList().GetMarkCount();
     742                 :          0 :     for( sal_uLong i = 0; i < nMark; i++ )
     743                 :            :     {
     744                 :          0 :         SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
     745                 :          0 :         DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj);
     746                 :            : 
     747                 :          0 :         if (pDlgEdObj && !dynamic_cast<DlgEdForm*>(pDlgEdObj))
     748                 :            :         {
     749                 :          0 :             ::rtl::OUString aName;
     750                 :          0 :             Reference< beans::XPropertySet >  xMarkPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY);
     751                 :          0 :             if (xMarkPSet.is())
     752                 :            :             {
     753                 :          0 :                 xMarkPSet->getPropertyValue( DLGED_PROP_NAME ) >>= aName;
     754                 :            :             }
     755                 :            : 
     756                 :          0 :             Reference< container::XNameAccess > xNameAcc(m_xUnoControlDialogModel, UNO_QUERY );
     757                 :          0 :             if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
     758                 :            :             {
     759                 :          0 :                 Any aCtrl = xNameAcc->getByName( aName );
     760                 :            : 
     761                 :            :                 // clone control model
     762                 :          0 :                 Reference< util::XCloneable > xCtrl;
     763                 :          0 :                    aCtrl >>= xCtrl;
     764                 :          0 :                 Reference< util::XCloneable > xNewCtrl = xCtrl->createClone();
     765                 :          0 :                 Any aNewCtrl;
     766                 :          0 :                 aNewCtrl <<= xNewCtrl;
     767                 :            : 
     768                 :          0 :                 if (xClipDialogModel.is())
     769                 :          0 :                     xClipDialogModel->insertByName( aName , aNewCtrl );
     770                 :          0 :             }
     771                 :            :         }
     772                 :            :     }
     773                 :            : 
     774                 :            :     // export clipboard dialog model to xml
     775                 :          0 :     Reference< XComponentContext > xContext;
     776                 :          0 :     Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
     777                 :            :     OSL_ASSERT( xProps.is() );
     778                 :          0 :     OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
     779                 :          0 :     Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
     780                 :          0 :     Reference< XInputStream > xStream( xISP->createInputStream() );
     781                 :          0 :     Sequence< sal_Int8 > DialogModelBytes;
     782                 :          0 :     implCopyStreamToByteSequence( xStream, DialogModelBytes );
     783                 :          0 :     xStream->closeInput();
     784                 :            : 
     785                 :            :     // set clipboard content
     786                 :          0 :     Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
     787                 :          0 :     if ( xClipboard.is() )
     788                 :            :     {
     789                 :            :         // With resource?
     790                 :          0 :         uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
     791                 :          0 :         uno::Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
     792                 :          0 :         if( xDialogModelPropSet.is() )
     793                 :            :         {
     794                 :            :             try
     795                 :            :             {
     796                 :          0 :                 Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
     797                 :          0 :                 aResourceResolver >>= xStringResourcePersistence;
     798                 :            :             }
     799                 :          0 :             catch(const UnknownPropertyException& )
     800                 :            :             {}
     801                 :            :         }
     802                 :            : 
     803                 :          0 :         DlgEdTransferableImpl* pTrans = NULL;
     804                 :          0 :         if( xStringResourcePersistence.is() )
     805                 :            :         {
     806                 :            :             // With resource, support old and new format
     807                 :            : 
     808                 :            :             // Export xClipDialogModel another time with ids replaced by current language string
     809                 :            :             uno::Reference< resource::XStringResourceManager >
     810                 :          0 :                 xStringResourceManager( xStringResourcePersistence, uno::UNO_QUERY );
     811                 :          0 :             LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourceManager );
     812                 :          0 :             Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
     813                 :          0 :             Reference< XInputStream > xStream2( xISP2->createInputStream() );
     814                 :          0 :             Sequence< sal_Int8 > NoResourceDialogModelBytes;
     815                 :          0 :             implCopyStreamToByteSequence( xStream2, NoResourceDialogModelBytes );
     816                 :          0 :             xStream2->closeInput();
     817                 :            : 
     818                 :            :             // Old format contains dialog with replaced ids
     819                 :          0 :             Sequence< Any > aSeqData(2);
     820                 :          0 :             Any aNoResourceDialogModelBytesAny;
     821                 :          0 :             aNoResourceDialogModelBytesAny <<= NoResourceDialogModelBytes;
     822                 :          0 :             aSeqData[0] = aNoResourceDialogModelBytesAny;
     823                 :            : 
     824                 :            :             // New format contains dialog and resource
     825                 :          0 :             Sequence< sal_Int8 > aResData = xStringResourcePersistence->exportBinary();
     826                 :            : 
     827                 :            :             // Create sequence for combined dialog and resource
     828                 :          0 :             sal_Int32 nDialogDataLen = DialogModelBytes.getLength();
     829                 :          0 :             sal_Int32 nResDataLen = aResData.getLength();
     830                 :            : 
     831                 :            :             // Combined data = 4 Bytes 32Bit Offset to begin of resource data, lowest byte first
     832                 :            :             // + nDialogDataLen bytes dialog data + nResDataLen resource data
     833                 :          0 :             sal_Int32 nTotalLen = 4 + nDialogDataLen + nResDataLen;
     834                 :          0 :             sal_Int32 nResOffset = 4 + nDialogDataLen;
     835                 :          0 :             Sequence< sal_Int8 > aCombinedData( nTotalLen );
     836                 :          0 :             sal_Int8* pCombinedData = aCombinedData.getArray();
     837                 :            : 
     838                 :            :             // Write offset
     839                 :          0 :             sal_Int32 n = nResOffset;
     840                 :          0 :             for( sal_Int16 i = 0 ; i < 4 ; i++ )
     841                 :            :             {
     842                 :          0 :                 pCombinedData[i] = sal_Int8( n & 0xff );
     843                 :          0 :                 n >>= 8;
     844                 :            :             }
     845                 :          0 :             ::rtl_copyMemory( pCombinedData + 4, DialogModelBytes.getConstArray(), nDialogDataLen );
     846                 :          0 :             ::rtl_copyMemory( pCombinedData + nResOffset, aResData.getConstArray(), nResDataLen );
     847                 :            : 
     848                 :          0 :             Any aCombinedDataAny;
     849                 :          0 :             aCombinedDataAny <<= aCombinedData;
     850                 :          0 :             aSeqData[1] = aCombinedDataAny;
     851                 :            : 
     852                 :          0 :             pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavorsResource, aSeqData );
     853                 :            :         }
     854                 :            :         else
     855                 :            :         {
     856                 :            :             // No resource, support only old format
     857                 :          0 :             Sequence< Any > aSeqData(1);
     858                 :          0 :             Any aDialogModelBytesAny;
     859                 :          0 :             aDialogModelBytesAny <<= DialogModelBytes;
     860                 :          0 :             aSeqData[0] = aDialogModelBytesAny;
     861                 :          0 :             pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , aSeqData );
     862                 :            :         }
     863                 :          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
     864                 :          0 :         xClipboard->setContents( pTrans , pTrans );
     865                 :          0 :         Application::AcquireSolarMutex( nRef );
     866                 :          0 :     }
     867                 :            : }
     868                 :            : 
     869                 :            : 
     870                 :          0 : void DlgEditor::Paste()
     871                 :            : {
     872                 :            :     // stop all drawing actions
     873                 :          0 :     pDlgEdView->BrkAction();
     874                 :            : 
     875                 :            :     // unmark all objects
     876                 :          0 :     pDlgEdView->UnmarkAll();
     877                 :            : 
     878                 :            :     // get clipboard
     879                 :          0 :     Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
     880                 :          0 :     if ( xClipboard.is() )
     881                 :            :     {
     882                 :            :         // get clipboard content
     883                 :          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
     884                 :          0 :         Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
     885                 :          0 :         Application::AcquireSolarMutex( nRef );
     886                 :          0 :         if ( xTransf.is() )
     887                 :            :         {
     888                 :            :             // Is target dialog (library) localized?
     889                 :          0 :             uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
     890                 :          0 :             uno::Reference< resource::XStringResourceManager > xStringResourceManager;
     891                 :          0 :             if( xDialogModelPropSet.is() )
     892                 :            :             {
     893                 :            :                 try
     894                 :            :                 {
     895                 :          0 :                     Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
     896                 :          0 :                     aResourceResolver >>= xStringResourceManager;
     897                 :            :                 }
     898                 :          0 :                 catch(const UnknownPropertyException& )
     899                 :            :                 {}
     900                 :            :             }
     901                 :          0 :             bool bLocalized = false;
     902                 :          0 :             if( xStringResourceManager.is() )
     903                 :          0 :                 bLocalized = ( xStringResourceManager->getLocales().getLength() > 0 );
     904                 :            : 
     905                 :          0 :             if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
     906                 :            :             {
     907                 :            :                 // create clipboard dialog model from xml
     908                 :          0 :                 Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
     909                 :          0 :                 Reference< container::XNameContainer > xClipDialogModel( xMSF->createInstance
     910                 :          0 :                     ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ),
     911                 :          0 :                         uno::UNO_QUERY );
     912                 :            : 
     913                 :          0 :                 bool bSourceIsLocalized = false;
     914                 :          0 :                 Sequence< sal_Int8 > DialogModelBytes;
     915                 :          0 :                 Sequence< sal_Int8 > aResData;
     916                 :          0 :                 if( bLocalized && xTransf->isDataFlavorSupported( m_ClipboardDataFlavorsResource[1] ) )
     917                 :            :                 {
     918                 :          0 :                     bSourceIsLocalized = true;
     919                 :            : 
     920                 :          0 :                     Any aCombinedDataAny = xTransf->getTransferData( m_ClipboardDataFlavorsResource[1] );
     921                 :          0 :                     Sequence< sal_Int8 > aCombinedData;
     922                 :          0 :                     aCombinedDataAny >>= aCombinedData;
     923                 :          0 :                     const sal_Int8* pCombinedData = aCombinedData.getConstArray();
     924                 :            : 
     925                 :          0 :                     sal_Int32 nTotalLen = aCombinedData.getLength();
     926                 :            : 
     927                 :            :                     // Reading offset
     928                 :          0 :                     sal_Int32 nResOffset = 0;
     929                 :          0 :                     sal_Int32 nFactor = 1;
     930                 :          0 :                     for( sal_Int16 i = 0; i < 4; i++ )
     931                 :            :                     {
     932                 :          0 :                         nResOffset += nFactor * sal_uInt8( pCombinedData[i] );
     933                 :          0 :                         nFactor *= 256;
     934                 :            :                     }
     935                 :            : 
     936                 :          0 :                     sal_Int32 nResDataLen = nTotalLen - nResOffset;
     937                 :          0 :                     sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
     938                 :            : 
     939                 :          0 :                     DialogModelBytes.realloc( nDialogDataLen );
     940                 :          0 :                     ::rtl_copyMemory( DialogModelBytes.getArray(), pCombinedData + 4, nDialogDataLen );
     941                 :            : 
     942                 :          0 :                     aResData.realloc( nResDataLen );
     943                 :          0 :                     ::rtl_copyMemory( aResData.getArray(), pCombinedData + nResOffset, nResDataLen );
     944                 :            :                 }
     945                 :            :                 else
     946                 :            :                 {
     947                 :          0 :                     Any aAny = xTransf->getTransferData( m_ClipboardDataFlavors[0] );
     948                 :          0 :                     aAny >>= DialogModelBytes;
     949                 :            :                 }
     950                 :            : 
     951                 :          0 :                 if ( xClipDialogModel.is() )
     952                 :            :                 {
     953                 :          0 :                     Reference< XComponentContext > xContext;
     954                 :          0 :                     Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
     955                 :            :                     OSL_ASSERT( xProps.is() );
     956                 :          0 :                     OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
     957                 :          0 :                     ::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument );
     958                 :            :                 }
     959                 :            : 
     960                 :            :                 // get control models from clipboard dialog model
     961                 :          0 :                 Reference< ::com::sun::star::container::XNameAccess > xNameAcc( xClipDialogModel, UNO_QUERY );
     962                 :          0 :                 if ( xNameAcc.is() )
     963                 :            :                 {
     964                 :          0 :                        Sequence< OUString > aNames = xNameAcc->getElementNames();
     965                 :          0 :                        const OUString* pNames = aNames.getConstArray();
     966                 :          0 :                     sal_uInt32 nCtrls = aNames.getLength();
     967                 :            : 
     968                 :          0 :                     Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
     969                 :          0 :                     if( nCtrls > 0 && bSourceIsLocalized )
     970                 :            :                     {
     971                 :          0 :                         Reference< lang::XMultiServiceFactory > xSMgr = getProcessServiceFactory();
     972                 :          0 :                         xStringResourcePersistence = Reference< resource::XStringResourcePersistence >( xSMgr->createInstance
     973                 :          0 :                             ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.resource.StringResource" )) ), UNO_QUERY );
     974                 :          0 :                         if( xStringResourcePersistence.is() )
     975                 :          0 :                             xStringResourcePersistence->importBinary( aResData );
     976                 :            :                     }
     977                 :          0 :                     for( sal_uInt32 n = 0; n < nCtrls; n++ )
     978                 :            :                     {
     979                 :          0 :                            Any aA = xNameAcc->getByName( pNames[n] );
     980                 :          0 :                         Reference< ::com::sun::star::awt::XControlModel > xCM;
     981                 :          0 :                            aA >>= xCM;
     982                 :            : 
     983                 :            :                         // clone the control model
     984                 :          0 :                         Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY );
     985                 :          0 :                         Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY );
     986                 :            : 
     987                 :          0 :                         DlgEdObj* pCtrlObj = new DlgEdObj();
     988                 :          0 :                         pCtrlObj->SetDlgEdForm(pDlgEdForm);         // set parent form
     989                 :          0 :                         pDlgEdForm->AddChild(pCtrlObj);             // add child to parent form
     990                 :          0 :                         pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model
     991                 :            : 
     992                 :            :                         // set new name
     993                 :          0 :                         ::rtl::OUString aOUniqueName( pCtrlObj->GetUniqueName() );
     994                 :          0 :                         Reference< beans::XPropertySet > xPSet( xCtrlModel , UNO_QUERY );
     995                 :          0 :                         Any aUniqueName;
     996                 :          0 :                         aUniqueName <<= aOUniqueName;
     997                 :          0 :                         xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
     998                 :            : 
     999                 :            :                         // set tabindex
    1000                 :          0 :                         Reference< container::XNameAccess > xNA( m_xUnoControlDialogModel , UNO_QUERY );
    1001                 :          0 :                            Sequence< OUString > aNames_ = xNA->getElementNames();
    1002                 :          0 :                         Any aTabIndex;
    1003                 :          0 :                         aTabIndex <<= (sal_Int16) aNames_.getLength();
    1004                 :          0 :                         xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
    1005                 :            : 
    1006                 :          0 :                         if( bLocalized )
    1007                 :            :                         {
    1008                 :          0 :                             Any aControlAny;
    1009                 :          0 :                             aControlAny <<= xCtrlModel;
    1010                 :          0 :                             if( bSourceIsLocalized && xStringResourcePersistence.is() )
    1011                 :            :                             {
    1012                 :            :                                 Reference< resource::XStringResourceResolver >
    1013                 :          0 :                                     xSourceStringResolver( xStringResourcePersistence, UNO_QUERY );
    1014                 :            :                                 LocalizationMgr::copyResourcesForPastedEditorObject( this,
    1015                 :          0 :                                     aControlAny, aOUniqueName, xSourceStringResolver );
    1016                 :            :                             }
    1017                 :            :                             else
    1018                 :            :                             {
    1019                 :            :                                 LocalizationMgr::setControlResourceIDsForNewEditorObject
    1020                 :          0 :                                     ( this, aControlAny, aOUniqueName );
    1021                 :          0 :                             }
    1022                 :            :                         }
    1023                 :            : 
    1024                 :            :                         // insert control model in editor dialog model
    1025                 :          0 :                         Any aCtrlModel;
    1026                 :          0 :                         aCtrlModel <<= xCtrlModel;
    1027                 :          0 :                         m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel );
    1028                 :            : 
    1029                 :            :                         // insert object into drawing page
    1030                 :          0 :                         pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
    1031                 :          0 :                         pCtrlObj->SetRectFromProps();
    1032                 :          0 :                         pCtrlObj->UpdateStep();
    1033                 :          0 :                         pDlgEdForm->UpdateTabOrderAndGroups();
    1034                 :          0 :                         pCtrlObj->StartListening();                         // start listening
    1035                 :            : 
    1036                 :            :                         // mark object
    1037                 :          0 :                         SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
    1038                 :          0 :                         pDlgEdView->MarkObj( pCtrlObj, pPgView, false, true);
    1039                 :          0 :                     }
    1040                 :            : 
    1041                 :            :                     // center marked objects in dialog editor form
    1042                 :          0 :                     Point aMarkCenter = (pDlgEdView->GetMarkedObjRect()).Center();
    1043                 :          0 :                     Point aFormCenter = (pDlgEdForm->GetSnapRect()).Center();
    1044                 :          0 :                     Point aPoint = aFormCenter - aMarkCenter;
    1045                 :          0 :                     Size  aSize( aPoint.X() , aPoint.Y() );
    1046                 :          0 :                     pDlgEdView->MoveMarkedObj( aSize );                     // update of control model properties (position + size) in NbcMove
    1047                 :          0 :                     pDlgEdView->MarkListHasChanged();
    1048                 :            : 
    1049                 :            :                     // dialog model changed
    1050                 :          0 :                     SetDialogModelChanged(true);
    1051                 :          0 :                 }
    1052                 :          0 :             }
    1053                 :          0 :         }
    1054                 :          0 :     }
    1055                 :          0 : }
    1056                 :            : 
    1057                 :            : 
    1058                 :          0 : void DlgEditor::Delete()
    1059                 :            : {
    1060                 :          0 :     if( !pDlgEdView->AreObjectsMarked() )
    1061                 :          0 :         return;
    1062                 :            : 
    1063                 :            :     // remove control models of marked objects from dialog model
    1064                 :          0 :     sal_uLong nMark = pDlgEdView->GetMarkedObjectList().GetMarkCount();
    1065                 :            : 
    1066                 :          0 :     for( sal_uLong i = 0; i < nMark; i++ )
    1067                 :            :     {
    1068                 :          0 :         SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
    1069                 :          0 :         DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj);
    1070                 :            : 
    1071                 :          0 :         if ( pDlgEdObj && !dynamic_cast<DlgEdForm*>(pDlgEdObj) )
    1072                 :            :         {
    1073                 :            :             // get name from property
    1074                 :          0 :             ::rtl::OUString aName;
    1075                 :          0 :             uno::Reference< beans::XPropertySet >  xPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY);
    1076                 :          0 :             if (xPSet.is())
    1077                 :            :             {
    1078                 :          0 :                 xPSet->getPropertyValue( DLGED_PROP_NAME ) >>= aName;
    1079                 :            :             }
    1080                 :            : 
    1081                 :            :             // remove control from dialog model
    1082                 :          0 :             Reference< ::com::sun::star::container::XNameAccess > xNameAcc(pDlgEdObj->GetDlgEdForm()->GetUnoControlModel(), UNO_QUERY );
    1083                 :          0 :             if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
    1084                 :            :             {
    1085                 :          0 :                 Reference< ::com::sun::star::container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
    1086                 :          0 :                 if ( xCont.is() )
    1087                 :            :                 {
    1088                 :          0 :                     if( xCont->hasByName( aName ) )
    1089                 :            :                     {
    1090                 :          0 :                         Any aAny = xCont->getByName( aName );
    1091                 :          0 :                         LocalizationMgr::deleteControlResourceIDsForDeletedEditorObject( this, aAny, aName );
    1092                 :            :                     }
    1093                 :          0 :                     xCont->removeByName( aName );
    1094                 :          0 :                 }
    1095                 :            :             }
    1096                 :            : 
    1097                 :            :             // remove child from parent form
    1098                 :          0 :             pDlgEdForm->RemoveChild( pDlgEdObj );
    1099                 :            :         }
    1100                 :            :     }
    1101                 :            : 
    1102                 :            :     // update tab indices
    1103                 :          0 :     pDlgEdForm->UpdateTabIndices();
    1104                 :            : 
    1105                 :          0 :     pDlgEdView->BrkAction();
    1106                 :            : 
    1107                 :          0 :     bool const bDlgMarked = UnmarkDialog();
    1108                 :          0 :     pDlgEdView->DeleteMarked();
    1109                 :          0 :     if( bDlgMarked )
    1110                 :          0 :         RemarkDialog();
    1111                 :            : }
    1112                 :            : 
    1113                 :            : 
    1114                 :          0 : bool DlgEditor::IsPasteAllowed()
    1115                 :            : {
    1116                 :            :     // get clipboard
    1117                 :          0 :     Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
    1118                 :          0 :     if ( xClipboard.is() )
    1119                 :            :     {
    1120                 :            :         // get clipboard content
    1121                 :          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    1122                 :          0 :         Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
    1123                 :          0 :         Application::AcquireSolarMutex( nRef );
    1124                 :          0 :         return xTransf.is() && xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] );
    1125                 :            :     }
    1126                 :          0 :     return false;
    1127                 :            : }
    1128                 :            : 
    1129                 :            : 
    1130                 :          0 : void DlgEditor::ShowProperties()
    1131                 :            : {
    1132                 :          0 :     BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
    1133                 :          0 :     SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
    1134                 :          0 :     if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) )
    1135                 :          0 :         pViewFrame->ToggleChildWindow( SID_SHOW_PROPERTYBROWSER );
    1136                 :          0 : }
    1137                 :            : 
    1138                 :            : 
    1139                 :          0 : void DlgEditor::UpdatePropertyBrowserDelayed()
    1140                 :            : {
    1141                 :          0 :     aMarkTimer.Start();
    1142                 :          0 : }
    1143                 :            : 
    1144                 :            : 
    1145                 :          0 : bool DlgEditor::IsModified() const
    1146                 :            : {
    1147                 :          0 :     return pDlgEdModel->IsChanged() || bDialogModelChanged;
    1148                 :            : }
    1149                 :            : 
    1150                 :            : 
    1151                 :          0 : void DlgEditor::ClearModifyFlag()
    1152                 :            : {
    1153                 :          0 :     pDlgEdModel->SetChanged(false);
    1154                 :          0 :     bDialogModelChanged = false;
    1155                 :          0 : }
    1156                 :            : 
    1157                 :            : 
    1158                 :            : #define LMARGPRN        1700
    1159                 :            : #define RMARGPRN         900
    1160                 :            : #define TMARGPRN        2000
    1161                 :            : #define BMARGPRN        1000
    1162                 :            : #define BORDERPRN       300
    1163                 :            : 
    1164                 :            : 
    1165                 :          0 : void lcl_PrintHeader( Printer* pPrinter, const ::rtl::OUString& rTitle ) // not working yet
    1166                 :            : {
    1167                 :          0 :     pPrinter->Push();
    1168                 :            : 
    1169                 :          0 :     short nLeftMargin = LMARGPRN;
    1170                 :          0 :     Size aSz = pPrinter->GetOutputSize();
    1171                 :          0 :     short nBorder = BORDERPRN;
    1172                 :            : 
    1173                 :          0 :     pPrinter->SetLineColor( COL_BLACK );
    1174                 :          0 :     pPrinter->SetFillColor();
    1175                 :            : 
    1176                 :          0 :     Font aFont( pPrinter->GetFont() );
    1177                 :          0 :     aFont.SetWeight( WEIGHT_BOLD );
    1178                 :          0 :     aFont.SetAlign( ALIGN_BOTTOM );
    1179                 :          0 :     pPrinter->SetFont( aFont );
    1180                 :            : 
    1181                 :          0 :     long nFontHeight = pPrinter->GetTextHeight();
    1182                 :            : 
    1183                 :            :     // 1st border => line, 2+3 border = free space
    1184                 :          0 :     long nYTop = TMARGPRN-3*nBorder-nFontHeight;
    1185                 :            : 
    1186                 :          0 :     long nXLeft = nLeftMargin-nBorder;
    1187                 :          0 :     long nXRight = aSz.Width()-RMARGPRN+nBorder;
    1188                 :            : 
    1189                 :            :     pPrinter->DrawRect( Rectangle(
    1190                 :            :         Point( nXLeft, nYTop ),
    1191                 :          0 :         Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
    1192                 :            : 
    1193                 :          0 :     long nY = TMARGPRN-2*nBorder;
    1194                 :          0 :     Point aPos( nLeftMargin, nY );
    1195                 :          0 :     pPrinter->DrawText( aPos, rTitle );
    1196                 :            : 
    1197                 :          0 :     nY = TMARGPRN-nBorder;
    1198                 :            : 
    1199                 :          0 :     pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
    1200                 :            : 
    1201                 :          0 :     pPrinter->Pop();
    1202                 :          0 : }
    1203                 :            : 
    1204                 :            : 
    1205                 :          0 : sal_Int32 DlgEditor::countPages( Printer* )
    1206                 :            : {
    1207                 :          0 :     return 1;
    1208                 :            : }
    1209                 :            : 
    1210                 :          0 : void DlgEditor::printPage( sal_Int32 nPage, Printer* pPrinter, const ::rtl::OUString& rTitle )
    1211                 :            : {
    1212                 :          0 :     if( nPage == 0 )
    1213                 :          0 :         Print( pPrinter, rTitle );
    1214                 :          0 : }
    1215                 :            : 
    1216                 :            : 
    1217                 :          0 : void DlgEditor::Print( Printer* pPrinter, const ::rtl::OUString& rTitle )    // not working yet
    1218                 :            : {
    1219                 :          0 :     if( pDlgEdView )
    1220                 :            :     {
    1221                 :          0 :         MapMode aOldMap( pPrinter->GetMapMode());
    1222                 :          0 :         Font aOldFont( pPrinter->GetFont() );
    1223                 :            : 
    1224                 :          0 :         MapMode aMap( MAP_100TH_MM );
    1225                 :          0 :         pPrinter->SetMapMode( aMap );
    1226                 :          0 :         Font aFont;
    1227                 :          0 :         aFont.SetAlign( ALIGN_BOTTOM );
    1228                 :          0 :         aFont.SetSize( Size( 0, 360 ));
    1229                 :          0 :         pPrinter->SetFont( aFont );
    1230                 :            : 
    1231                 :          0 :         Size aPaperSz = pPrinter->GetOutputSize();
    1232                 :          0 :         aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
    1233                 :          0 :         aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
    1234                 :            : 
    1235                 :          0 :         lcl_PrintHeader( pPrinter, rTitle );
    1236                 :            : 
    1237                 :          0 :         Bitmap aDlg;
    1238                 :          0 :         Size aBmpSz( pPrinter->PixelToLogic( aDlg.GetSizePixel() ) );
    1239                 :          0 :         double nPaperSzWidth = aPaperSz.Width();
    1240                 :          0 :         double nPaperSzHeight = aPaperSz.Height();
    1241                 :          0 :         double nBmpSzWidth = aBmpSz.Width();
    1242                 :          0 :         double nBmpSzHeight = aBmpSz.Height();
    1243                 :          0 :         double nScaleX = (nPaperSzWidth / nBmpSzWidth );
    1244                 :          0 :         double nScaleY = (nPaperSzHeight / nBmpSzHeight );
    1245                 :            : 
    1246                 :          0 :         Size aOutputSz;
    1247                 :          0 :         if( nBmpSzHeight * nScaleX <= nPaperSzHeight )
    1248                 :            :         {
    1249                 :          0 :             aOutputSz.Width() = (long)(((double)nBmpSzWidth) * nScaleX);
    1250                 :          0 :             aOutputSz.Height() = (long)(((double)nBmpSzHeight) * nScaleX);
    1251                 :            :         }
    1252                 :            :         else
    1253                 :            :         {
    1254                 :          0 :             aOutputSz.Width() = (long)(((double)nBmpSzWidth) * nScaleY);
    1255                 :          0 :             aOutputSz.Height() = (long)(((double)nBmpSzHeight) * nScaleY);
    1256                 :            :         }
    1257                 :            : 
    1258                 :            :         Point aPosOffs(
    1259                 :          0 :             (aPaperSz.Width() / 2) - (aOutputSz.Width() / 2),
    1260                 :          0 :             (aPaperSz.Height()/ 2) - (aOutputSz.Height() / 2));
    1261                 :            : 
    1262                 :          0 :         aPosOffs.X() += LMARGPRN;
    1263                 :          0 :         aPosOffs.Y() += TMARGPRN;
    1264                 :            : 
    1265                 :          0 :         pPrinter->DrawBitmap( aPosOffs, aOutputSz, aDlg );
    1266                 :            : 
    1267                 :          0 :         pPrinter->SetMapMode( aOldMap );
    1268                 :          0 :         pPrinter->SetFont( aOldFont );
    1269                 :            :     }
    1270                 :          0 : }
    1271                 :            : 
    1272                 :            : 
    1273                 :          0 : bool DlgEditor::AdjustPageSize()
    1274                 :            : {
    1275                 :          0 :     bool bAdjustedPageSize = false;
    1276                 :          0 :     Reference< beans::XPropertySet > xPSet( m_xUnoControlDialogModel, UNO_QUERY );
    1277                 :          0 :     if ( xPSet.is() )
    1278                 :            :     {
    1279                 :          0 :         sal_Int32 nFormXIn = 0, nFormYIn = 0, nFormWidthIn = 0, nFormHeightIn = 0;
    1280                 :          0 :         xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nFormXIn;
    1281                 :          0 :         xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nFormYIn;
    1282                 :          0 :         xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nFormWidthIn;
    1283                 :          0 :         xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nFormHeightIn;
    1284                 :            : 
    1285                 :            :         sal_Int32 nFormX, nFormY, nFormWidth, nFormHeight;
    1286                 :          0 :         if ( pDlgEdForm && pDlgEdForm->TransformFormToSdrCoordinates( nFormXIn, nFormYIn, nFormWidthIn, nFormHeightIn, nFormX, nFormY, nFormWidth, nFormHeight ) )
    1287                 :            :         {
    1288                 :          0 :             Size aPageSizeDelta( 400, 300 );
    1289                 :            :             DBG_ASSERT( pWindow, "DlgEditor::AdjustPageSize: no window!" );
    1290                 :          0 :             if ( pWindow )
    1291                 :          0 :                 aPageSizeDelta = pWindow->PixelToLogic( aPageSizeDelta, MapMode( MAP_100TH_MM ) );
    1292                 :            : 
    1293                 :          0 :             sal_Int32 nNewPageWidth = nFormX + nFormWidth + aPageSizeDelta.Width();
    1294                 :          0 :             sal_Int32 nNewPageHeight = nFormY + nFormHeight + aPageSizeDelta.Height();
    1295                 :            : 
    1296                 :          0 :             Size aPageSizeMin( DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN );
    1297                 :            :             DBG_ASSERT( pWindow, "DlgEditor::AdjustPageSize: no window!" );
    1298                 :          0 :             if ( pWindow )
    1299                 :          0 :                 aPageSizeMin = pWindow->PixelToLogic( aPageSizeMin, MapMode( MAP_100TH_MM ) );
    1300                 :          0 :             sal_Int32 nPageWidthMin = aPageSizeMin.Width();
    1301                 :          0 :             sal_Int32 nPageHeightMin = aPageSizeMin.Height();
    1302                 :            : 
    1303                 :          0 :             if ( nNewPageWidth < nPageWidthMin )
    1304                 :          0 :                 nNewPageWidth = nPageWidthMin;
    1305                 :            : 
    1306                 :          0 :             if ( nNewPageHeight < nPageHeightMin )
    1307                 :          0 :                 nNewPageHeight = nPageHeightMin;
    1308                 :            : 
    1309                 :          0 :             if ( pDlgEdPage )
    1310                 :            :             {
    1311                 :          0 :                 Size aPageSize = pDlgEdPage->GetSize();
    1312                 :          0 :                 if ( nNewPageWidth != aPageSize.Width() || nNewPageHeight != aPageSize.Height() )
    1313                 :            :                 {
    1314                 :          0 :                     Size aNewPageSize( nNewPageWidth, nNewPageHeight );
    1315                 :          0 :                     pDlgEdPage->SetSize( aNewPageSize );
    1316                 :            :                     DBG_ASSERT( pDlgEdView, "DlgEditor::AdjustPageSize: no view!" );
    1317                 :          0 :                     if ( pDlgEdView )
    1318                 :          0 :                         pDlgEdView->SetWorkArea( Rectangle( Point( 0, 0 ), aNewPageSize ) );
    1319                 :          0 :                     bAdjustedPageSize = true;
    1320                 :            :                 }
    1321                 :            :             }
    1322                 :            :         }
    1323                 :            :     }
    1324                 :            : 
    1325                 :          0 :     return bAdjustedPageSize;
    1326                 :          0 : }
    1327                 :            : 
    1328                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10