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