LCOV - code coverage report
Current view: top level - basctl/source/dlged - dlged.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 649 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 44 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11