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