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_sw.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <swtypes.hxx> 32*cdf0e10cSrcweir #include <globals.hrc> 33*cdf0e10cSrcweir #include <misc.hrc> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <utlui.hrc> 36*cdf0e10cSrcweir #include <unotools.hrc> 37*cdf0e10cSrcweir #include <unotools.hxx> 38*cdf0e10cSrcweir #include <unoprnms.hxx> 39*cdf0e10cSrcweir #include <tools/debug.hxx> 40*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 41*cdf0e10cSrcweir #include <com/sun/star/text/XTextViewCursorSupplier.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/view/XScreenCursor.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/view/DocumentZoomType.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/text/XTextDocument.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/view/XViewSettingsSupplier.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp> 51*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 52*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 53*cdf0e10cSrcweir #include <svl/stritem.hxx> 54*cdf0e10cSrcweir #include <shellio.hxx> 55*cdf0e10cSrcweir #include <docsh.hxx> 56*cdf0e10cSrcweir #include <view.hxx> 57*cdf0e10cSrcweir #include <wrtsh.hxx> 58*cdf0e10cSrcweir #include <swmodule.hxx> 59*cdf0e10cSrcweir #include <TextCursorHelper.hxx> 60*cdf0e10cSrcweir #include <unocrsr.hxx> 61*cdf0e10cSrcweir #include <doc.hxx> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #include <unomid.h> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using namespace ::com::sun::star; 67*cdf0e10cSrcweir using ::rtl::OUString; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir const sal_Char cFrameControl[] = "com.sun.star.frame.FrameControl"; 70*cdf0e10cSrcweir const sal_Char cFactory[] = "private:factory/swriter"; 71*cdf0e10cSrcweir /************************************************************************ 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir ************************************************************************/ 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir sal_Bool SwOneExampleFrame::bShowServiceNotAvailableMessage = sal_True; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir /* -----------------27.07.99 15:26------------------- 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir --------------------------------------------------*/ 80*cdf0e10cSrcweir SwOneExampleFrame::SwOneExampleFrame( Window& rWin, 81*cdf0e10cSrcweir sal_uInt32 nFlags, 82*cdf0e10cSrcweir const Link* pInitializedLink, 83*cdf0e10cSrcweir String* pURL ) : 84*cdf0e10cSrcweir aTopWindow( rWin.GetParent(), 0, this ), 85*cdf0e10cSrcweir rWindow(rWin), 86*cdf0e10cSrcweir aMenuRes(SW_RES(RES_FRMEX_MENU)), 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir pModuleView(SW_MOD()->GetView()), 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir nStyleFlags(nFlags), 91*cdf0e10cSrcweir bIsInitialized(sal_False), 92*cdf0e10cSrcweir bServiceAvailable(sal_False) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if(pURL && pURL->Len()) 95*cdf0e10cSrcweir sArgumentURL = *pURL; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir aTopWindow.SetPaintTransparent(sal_True); 98*cdf0e10cSrcweir aTopWindow.SetPosSizePixel(rWin.GetPosPixel(), rWin.GetSizePixel()); 99*cdf0e10cSrcweir aTopWindow.SetZOrder( &rWin, WINDOW_ZORDER_FIRST ); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir if( pInitializedLink ) 102*cdf0e10cSrcweir aInitializedLink = *pInitializedLink; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // the controller is asynchronously set 105*cdf0e10cSrcweir aLoadedTimer.SetTimeoutHdl(LINK(this, SwOneExampleFrame, TimeoutHdl)); 106*cdf0e10cSrcweir // aLoadedTimer.SetTimeout(500); 107*cdf0e10cSrcweir aLoadedTimer.SetTimeout(200); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir rWin.Enable(sal_False); 110*cdf0e10cSrcweir CreateControl(); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir aTopWindow.Show(); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir /* -----------------------------08.12.99 13:44-------------------------------- 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 118*cdf0e10cSrcweir void SwOneExampleFrame::CreateErrorMessage(Window* pParent) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir if(SwOneExampleFrame::bShowServiceNotAvailableMessage) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir String sInfo(SW_RES(STR_SERVICE_UNAVAILABLE)); 123*cdf0e10cSrcweir sInfo += C2S(cFrameControl); 124*cdf0e10cSrcweir InfoBox(pParent, sInfo).Execute(); 125*cdf0e10cSrcweir SwOneExampleFrame::bShowServiceNotAvailableMessage = sal_False; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir /* -----------------27.07.99 15:26------------------- 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir --------------------------------------------------*/ 131*cdf0e10cSrcweir SwOneExampleFrame::~SwOneExampleFrame() 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir DisposeControl(); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir /* -----------------------------21.12.00 10:16-------------------------------- 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 138*cdf0e10cSrcweir void SwOneExampleFrame::CreateControl() 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir if(_xControl.is()) 141*cdf0e10cSrcweir return ; 142*cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > 143*cdf0e10cSrcweir xMgr = comphelper::getProcessServiceFactory(); 144*cdf0e10cSrcweir uno::Reference< uno::XInterface > xInst = xMgr->createInstance( C2U("com.sun.star.frame.FrameControl") ); 145*cdf0e10cSrcweir _xControl = uno::Reference< awt::XControl >(xInst, uno::UNO_QUERY); 146*cdf0e10cSrcweir if(_xControl.is()) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir uno::Reference< awt::XWindowPeer > xParent( rWindow.GetComponentInterface() ); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir uno::Reference< awt::XToolkit > xToolkit( xMgr->createInstance( C2U("com.sun.star.awt.Toolkit") ), uno::UNO_QUERY ); 151*cdf0e10cSrcweir if(xToolkit.is()) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir _xControl->createPeer( xToolkit, xParent ); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY ); 156*cdf0e10cSrcweir xWin->setVisible( sal_False ); 157*cdf0e10cSrcweir Size aWinSize(rWindow.GetOutputSizePixel()); 158*cdf0e10cSrcweir xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE ); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPrSet(xInst, uno::UNO_QUERY); 161*cdf0e10cSrcweir uno::Any aURL; 162*cdf0e10cSrcweir // 163*cdf0e10cSrcweir // create new doc 164*cdf0e10cSrcweir String sTempURL = C2S(cFactory); 165*cdf0e10cSrcweir if(sArgumentURL.Len()) 166*cdf0e10cSrcweir sTempURL = sArgumentURL; 167*cdf0e10cSrcweir aURL <<= OUString(sTempURL); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aSeq(3); 170*cdf0e10cSrcweir beans::PropertyValue* pValues = aSeq.getArray(); 171*cdf0e10cSrcweir pValues[0].Name = C2U("ReadOnly"); 172*cdf0e10cSrcweir sal_Bool bTrue = sal_True; 173*cdf0e10cSrcweir pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType()); 174*cdf0e10cSrcweir pValues[1].Name = C2U("OpenFlags"); 175*cdf0e10cSrcweir pValues[1].Value <<= C2U("-RB"); 176*cdf0e10cSrcweir pValues[2].Name = C2U("Referer"); 177*cdf0e10cSrcweir pValues[2].Value <<= C2U("private:user"); 178*cdf0e10cSrcweir uno::Any aArgs; 179*cdf0e10cSrcweir aArgs.setValue(&aSeq, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0)); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir xPrSet->setPropertyValue( C2U("LoaderArguments"), aArgs ); 182*cdf0e10cSrcweir //save and set readonly??? 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir xPrSet->setPropertyValue(C2U("ComponentURL"), aURL); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir aLoadedTimer.Start(); 187*cdf0e10cSrcweir bServiceAvailable = sal_True; 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir /* -----------------------------21.12.00 10:16-------------------------------- 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 196*cdf0e10cSrcweir void SwOneExampleFrame::DisposeControl() 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir _xCursor = 0; 199*cdf0e10cSrcweir if(_xControl.is()) 200*cdf0e10cSrcweir _xControl->dispose(); 201*cdf0e10cSrcweir _xControl = 0; 202*cdf0e10cSrcweir _xModel = 0; 203*cdf0e10cSrcweir _xController = 0; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir /* -----------------27.07.99 15:26------------------- 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir --------------------------------------------------*/ 208*cdf0e10cSrcweir IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer ) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir if(!_xControl.is()) 211*cdf0e10cSrcweir return 0; 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir // now get the model 214*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPrSet(_xControl, uno::UNO_QUERY); 215*cdf0e10cSrcweir uno::Any aFrame = xPrSet->getPropertyValue(C2U("Frame")); 216*cdf0e10cSrcweir uno::Reference< frame::XFrame > xFrm; 217*cdf0e10cSrcweir aFrame >>= xFrm; 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( xFrm, uno::UNO_QUERY ); 220*cdf0e10cSrcweir if ( xPropSet.is() ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir try 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir uno::Reference< frame::XLayoutManager > xLayoutManager; 225*cdf0e10cSrcweir uno::Any aValue = xPropSet->getPropertyValue(C2U("LayoutManager")); 226*cdf0e10cSrcweir aValue >>= xLayoutManager; 227*cdf0e10cSrcweir if ( xLayoutManager.is() ) 228*cdf0e10cSrcweir xLayoutManager->setVisible( sal_False ); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir catch ( uno::Exception& ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir _xController = xFrm->getController(); 236*cdf0e10cSrcweir if(_xController.is()) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir _xModel = _xController->getModel(); 239*cdf0e10cSrcweir //now the ViewOptions should be set properly 240*cdf0e10cSrcweir uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY); 241*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings(); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir sal_Bool bTrue = sal_True; 244*cdf0e10cSrcweir sal_Bool bFalse = sal_False; 245*cdf0e10cSrcweir uno::Any aTrueSet( &bTrue, ::getBooleanCppuType() ); 246*cdf0e10cSrcweir uno::Any aFalseSet( &bFalse, ::getBooleanCppuType() ); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir if( !bIsInitialized ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_BREAKS )), aFalseSet); 251*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_DRAWINGS )), aTrueSet); 252*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_FIELD_COMMANDS )), aFalseSet); 253*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_GRAPHICS )), aTrueSet); 254*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_PARAGRAPHS )), aFalseSet); 255*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_TEXT )), aFalseSet); 256*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_RULER )), aFalseSet); 257*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_PARA_BREAKS )), aFalseSet); 258*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_PROTECTED_SPACES )), aFalseSet); 259*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_SOFT_HYPHENS )), aFalseSet); 260*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_SPACES )), aFalseSet); 261*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABLES )), aTrueSet); 262*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABSTOPS )), aFalseSet); 263*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_RULER )), aFalseSet); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if(0 ==(nStyleFlags&EX_SHOW_ONLINE_LAYOUT)) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir uno::Any aZoom; 268*cdf0e10cSrcweir aZoom <<= (sal_Int16)view::DocumentZoomType::PAGE_WIDTH_EXACT; 269*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir else 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir uno::Any aZoom; 274*cdf0e10cSrcweir aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE; 275*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir sal_Int16 nZoomValue = 50; 278*cdf0e10cSrcweir if(EX_SHOW_BUSINESS_CARDS == nStyleFlags) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir nZoomValue = 80; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir aZoom <<= nZoomValue; 283*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir // set onlinelayout property behind setting the zoom 286*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_ONLINE_LAYOUT)), 287*cdf0e10cSrcweir (nStyleFlags&EX_SHOW_ONLINE_LAYOUT) ? aTrueSet : aFalseSet ); 288*cdf0e10cSrcweir bIsInitialized = sal_True; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir uno::Reference< text::XTextDocument > xDoc(_xModel, uno::UNO_QUERY); 292*cdf0e10cSrcweir uno::Reference< text::XText > xText = xDoc->getText(); 293*cdf0e10cSrcweir _xCursor = xText->createTextCursor(); 294*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xCrsrProp(_xCursor, uno::UNO_QUERY); 295*cdf0e10cSrcweir uno::Any aPageStyle = xCrsrProp->getPropertyValue( 296*cdf0e10cSrcweir C2U(SW_PROP_NAME_STR(UNO_NAME_PAGE_STYLE_NAME))); 297*cdf0e10cSrcweir OUString sPageStyle; 298*cdf0e10cSrcweir aPageStyle >>= sPageStyle; 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir uno::Reference< style::XStyleFamiliesSupplier > xSSupp( xDoc, uno::UNO_QUERY); 301*cdf0e10cSrcweir uno::Reference< container::XNameAccess > xStyles = xSSupp->getStyleFamilies(); 302*cdf0e10cSrcweir uno::Any aPFamily = xStyles->getByName( C2U("PageStyles" ) ); 303*cdf0e10cSrcweir uno::Reference< container::XNameContainer > xPFamily; 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir if( 0 == (EX_SHOW_DEFAULT_PAGE == nStyleFlags) 306*cdf0e10cSrcweir && (aPFamily >>= xPFamily) && sPageStyle.getLength() ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir uno::Any aPStyle = xPFamily->getByName( sPageStyle ); 309*cdf0e10cSrcweir uno::Reference< style::XStyle > xPStyle; 310*cdf0e10cSrcweir aPStyle >>= xPStyle; 311*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPProp(xPStyle, uno::UNO_QUERY); 312*cdf0e10cSrcweir uno::Any aSize = xPProp->getPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SIZE))); 313*cdf0e10cSrcweir awt::Size aPSize; 314*cdf0e10cSrcweir aSize >>= aPSize; 315*cdf0e10cSrcweir //TODO: set page width to card width 316*cdf0e10cSrcweir aPSize.Width = 10000; 317*cdf0e10cSrcweir aSize.setValue(&aPSize, ::getCppuType((awt::Size*)0)); 318*cdf0e10cSrcweir xPProp->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SIZE)), aSize); 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir uno::Any aZero; aZero <<= (sal_Int32)0; 321*cdf0e10cSrcweir xPProp->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LEFT_MARGIN)), aZero); 322*cdf0e10cSrcweir xPProp->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_RIGHT_MARGIN)), aZero); 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir // can only be done here - the SFX changes the ScrollBar values 326*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_SCROLL_BAR )), aFalseSet); 327*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_SCROLL_BAR )), aFalseSet); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir if( aInitializedLink.IsSet() ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir rWindow.Enable(sal_False, sal_True); 332*cdf0e10cSrcweir //rWindow.Enable(sal_True, sal_False); 333*cdf0e10cSrcweir aInitializedLink.Call(this); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY); 337*cdf0e10cSrcweir uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY); 338*cdf0e10cSrcweir if(xScrCrsr.is()) 339*cdf0e10cSrcweir xScrCrsr->screenUp(); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY ); 342*cdf0e10cSrcweir xWin->setVisible( sal_True ); 343*cdf0e10cSrcweir rWindow.Show(); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY); 346*cdf0e10cSrcweir if( xTunnel.is() ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething( 349*cdf0e10cSrcweir OTextCursorHelper::getUnoTunnelId() )); 350*cdf0e10cSrcweir if( pCrsr ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell(); 353*cdf0e10cSrcweir if( pSh->ActionCount() ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir pSh->EndAllAction(); 356*cdf0e10cSrcweir pSh->UnlockPaint(); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir SW_MOD()->SetView(pModuleView); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir else 364*cdf0e10cSrcweir pTimer->Start(); 365*cdf0e10cSrcweir return 0; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir /* -----------------------------27.12.99 09:59-------------------------------- 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 370*cdf0e10cSrcweir void SwOneExampleFrame::ClearDocument( sal_Bool bStartUpdateTimer ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY); 373*cdf0e10cSrcweir if( xTunnel.is() ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>(xTunnel->getSomething( 376*cdf0e10cSrcweir OTextCursorHelper::getUnoTunnelId()) ); 377*cdf0e10cSrcweir if( pCrsr ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir SwDoc* pDoc = pCrsr->GetDoc(); 380*cdf0e10cSrcweir SwEditShell* pSh = pDoc->GetEditShell(); 381*cdf0e10cSrcweir pSh->LockPaint(); 382*cdf0e10cSrcweir pSh->StartAllAction(); 383*cdf0e10cSrcweir pDoc->ClearDoc(); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir if( aLoadedTimer.IsActive() || !bStartUpdateTimer ) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir pSh->EndAllAction(); 388*cdf0e10cSrcweir pSh->UnlockPaint(); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir if( bStartUpdateTimer ) 391*cdf0e10cSrcweir aLoadedTimer.Start(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir else 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir _xCursor->gotoStart(sal_False); 396*cdf0e10cSrcweir _xCursor->gotoEnd(sal_True); 397*cdf0e10cSrcweir _xCursor->setString(OUString()); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir /* -----------------------------15.12.99 11:09-------------------------------- 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 404*cdf0e10cSrcweir static const sal_Int16 nZoomValues[] = 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir 20, 407*cdf0e10cSrcweir 40, 408*cdf0e10cSrcweir 50, 409*cdf0e10cSrcweir 75, 410*cdf0e10cSrcweir 100 411*cdf0e10cSrcweir }; 412*cdf0e10cSrcweir //--------------------------------------------------------------------------- 413*cdf0e10cSrcweir #define ITEM_UP 100 414*cdf0e10cSrcweir #define ITEM_DOWN 200 415*cdf0e10cSrcweir #define ITEM_ZOOM 300 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir void SwOneExampleFrame::CreatePopup(const Point& rPt) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir PopupMenu aPop; 420*cdf0e10cSrcweir PopupMenu aSubPop1; 421*cdf0e10cSrcweir ResStringArray& rArr = aMenuRes.GetMenuArray(); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir aPop.InsertItem(ITEM_UP, rArr.GetString(rArr.FindIndex(ST_MENU_UP ))); 424*cdf0e10cSrcweir aPop.InsertItem(ITEM_DOWN, rArr.GetString(rArr.FindIndex(ST_MENU_DOWN ))); 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir Link aSelLk = LINK(this, SwOneExampleFrame, PopupHdl ); 427*cdf0e10cSrcweir aPop.SetSelectHdl(aSelLk); 428*cdf0e10cSrcweir if(EX_SHOW_ONLINE_LAYOUT == nStyleFlags) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir aPop.InsertItem(ITEM_ZOOM, rArr.GetString(rArr.FindIndex(ST_MENU_ZOOM ))); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY); 433*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings(); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir uno::Any aZoom = xViewProps->getPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE))); 436*cdf0e10cSrcweir sal_Int16 nZoom = 0; 437*cdf0e10cSrcweir aZoom >>= nZoom; 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < 5; i++ ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir String sTemp; 442*cdf0e10cSrcweir sTemp = String::CreateFromInt32(nZoomValues[i]); 443*cdf0e10cSrcweir sTemp += String::CreateFromAscii(" %"); 444*cdf0e10cSrcweir aSubPop1.InsertItem( ITEM_ZOOM + i + 1, sTemp); 445*cdf0e10cSrcweir if(nZoom == nZoomValues[i]) 446*cdf0e10cSrcweir aSubPop1.CheckItem(ITEM_ZOOM + i + 1); 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir aPop.SetPopupMenu( ITEM_ZOOM, &aSubPop1 ); 449*cdf0e10cSrcweir aSubPop1.SetSelectHdl(aSelLk); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir aPop.Execute( &aTopWindow, rPt ); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir /* -----------------------------15.12.99 11:09-------------------------------- 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 457*cdf0e10cSrcweir IMPL_LINK(SwOneExampleFrame, PopupHdl, Menu*, pMenu ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir sal_uInt16 nId = pMenu->GetCurItemId(); 460*cdf0e10cSrcweir if( nId > ITEM_ZOOM && nId < ITEM_ZOOM + 100 ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir sal_Int16 nZoom = nZoomValues[nId - ITEM_ZOOM - 1]; 463*cdf0e10cSrcweir uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY); 464*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings(); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir uno::Any aZoom; 467*cdf0e10cSrcweir aZoom <<= nZoom; 468*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom); 469*cdf0e10cSrcweir aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE; 470*cdf0e10cSrcweir xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir else if(ITEM_UP == nId || ITEM_DOWN == nId) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY); 475*cdf0e10cSrcweir uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY); 476*cdf0e10cSrcweir if(ITEM_UP == nId) 477*cdf0e10cSrcweir xScrCrsr->screenUp(); 478*cdf0e10cSrcweir else 479*cdf0e10cSrcweir xScrCrsr->screenDown(); 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir return 0; 482*cdf0e10cSrcweir }; 483*cdf0e10cSrcweir /* -----------------------------15.12.99 10:37-------------------------------- 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 486*cdf0e10cSrcweir SwFrmCtrlWindow::SwFrmCtrlWindow(Window* pParent, WinBits nBits, 487*cdf0e10cSrcweir SwOneExampleFrame* pFrame) : 488*cdf0e10cSrcweir Window(pParent, nBits), 489*cdf0e10cSrcweir pExampleFrame(pFrame) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir /* -----------------------------15.12.99 09:57-------------------------------- 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 495*cdf0e10cSrcweir void SwFrmCtrlWindow::Command( const CommandEvent& rCEvt ) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir switch ( rCEvt.GetCommand() ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir case COMMAND_CONTEXTMENU: 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir //#125881# quickly clicking crashes because the control is not fully initialized 502*cdf0e10cSrcweir if(pExampleFrame->GetController().is()) 503*cdf0e10cSrcweir pExampleFrame->CreatePopup(rCEvt.GetMousePosPixel()); 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir break; 506*cdf0e10cSrcweir case COMMAND_WHEEL: 507*cdf0e10cSrcweir case COMMAND_STARTAUTOSCROLL: 508*cdf0e10cSrcweir case COMMAND_AUTOSCROLL: 509*cdf0e10cSrcweir break; 510*cdf0e10cSrcweir default:; 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir /* -----------------------------15.12.99 12:57-------------------------------- 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 516*cdf0e10cSrcweir MenuResource::MenuResource(const ResId& rResId) : 517*cdf0e10cSrcweir Resource(rResId), 518*cdf0e10cSrcweir aMenuArray(ResId(1,*rResId.GetResMgr())) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir FreeResource(); 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir 523