1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 #include <editeng/editeng.hxx> 28 #include <editeng/eeitem.hxx> 29 #include <editeng/editview.hxx> 30 #include <editeng/editobj.hxx> 31 #include <editeng/editstat.hxx> 32 #include <eerdll.hxx> 33 #include <editeng/flditem.hxx> 34 #include <tools/urlobj.hxx> 35 #include <svx/svxacorr.hxx> 36 #include <tools/fsys.hxx> 37 #include <svx/xpoly.hxx> 38 #include <svtools/filedlg.hxx> 39 40 #include <vcl/window.hxx> 41 #include <vcl/svapp.hxx> 42 #include <vcl/font.hxx> 43 #include <vcl/sound.hxx> 44 #include <vcl/print.hxx> 45 #include <vcl/toolbox.hxx> 46 #include <vcl/help.hxx> 47 #include <vcl/scrbar.hxx> 48 #include <vcl/wrkwin.hxx> 49 #include <vcl/msgbox.hxx> 50 51 #include <dialdll.hxx> 52 53 54 #define SERVICE_SIMPLEREGISTRY "com.sun.star.registry.SimpleRegistry" 55 #include <comphelper/processfactory.hxx> 56 #include <comphelper/regpathhelper.hxx> 57 #include <cppuhelper/servicefactory.hxx> 58 #include <cppuhelper/bootstrap.hxx> 59 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 60 #include <com/sun/star/lang/XInitialization.hpp> 61 #include <com/sun/star/registry/XSimpleRegistry.hpp> 62 #include <sfx2/sfxuno.hxx> 63 64 // SVX 65 #include <editeng/lrspitem.hxx> 66 #include <editeng/shdditem.hxx> 67 #include <editeng/cntritem.hxx> 68 #include <editeng/crsditem.hxx> 69 #include <editeng/udlnitem.hxx> 70 #include <editeng/lspcitem.hxx> 71 #include <editeng/escpitem.hxx> 72 #include <editeng/kernitem.hxx> 73 #include <editeng/akrnitem.hxx> 74 #include <editeng/wrlmitem.hxx> 75 #include <editeng/colritem.hxx> 76 #include <editeng/ulspitem.hxx> 77 #include <editeng/postitem.hxx> 78 #include <editeng/adjitem.hxx> 79 #include <editeng/wghtitem.hxx> 80 #include <editeng/fhgtitem.hxx> 81 #include <editeng/fontitem.hxx> 82 #include <fwdtitem.hxx> 83 84 // SVTOOLS 85 #include <svl/undo.hxx> 86 #include <svl/itemset.hxx> 87 #include <svl/itempool.hxx> 88 #include <svl/poolitem.hxx> 89 #include <svtools/printdlg.hxx> 90 91 #include <osl/file.hxx> 92 #include <osl/process.h> 93 #include <rtl/bootstrap.hxx> 94 95 #define TB_LEFT 1 96 #define TB_RIGHT 2 97 #define TB_CENTER 3 98 #define TB_UNDO 4 99 #define TB_REDO 5 100 #define TB_FONT1 6 101 #define TB_FONT2 7 102 #define TB_ITALIC 8 103 #define TB_BOLD 9 104 #define TB_UNDERLINE 10 105 #define TB_BLACK 11 106 #define TB_GREEN 12 107 #define TB_OPEN 13 108 #define TB_SAVE 14 109 #define TB_SBL 15 110 #define TB_SBSA 16 111 #define TB_LR 17 112 #define TB_DRAW 18 113 #define TB_DEFTAB 19 114 #define TB_OPEN2 20 115 #define TB_SAVE2 21 116 #define TB_STDSEL 33 117 #define TB_MOVE 34 118 #define TB_PARATTR1 35 119 #define TB_ROTATE 38 120 #define TB_RED 43 121 #define TB_FLAT 46 122 #define TB_BINOBJ1 47 123 #define TB_BINOBJ3 49 124 #define TB_BINOBJ4 50 125 #define TB_BINOBJ1b 51 126 #define TB_BINOBJ2b 52 127 #define TB_ATTRIBS 54 128 #define TB_IDLE 55 129 #define TB_BLOCK 56 130 #define TB_CLONEBIN 57 131 #define TB_INSERT 58 132 #define TB_PKERN 59 133 #define TB_KERN 60 134 #define TB_SUPER 61 135 #define TB_SUB 62 136 #define TB_PRINT 63 137 #define TB_FONT 64 138 #define TB_COLORS 65 139 #define TB_WLM 66 140 #define TB_OUTL 67 141 #define TB_INSFLD 68 142 #define TB_UPDFLD 69 143 #define TB_ONLINESPELL 70 144 #define TB_REDLINES 71 145 #define TB_AUTOCORRECT 72 146 #define TB_POLY 73 147 #define TB_HYPH 74 148 149 // VARS... 150 short nRotation = 0; 151 USHORT nZoom = 100; 152 sal_Bool bURLClicked = sal_False; 153 154 using namespace ::com::sun::star::connection; 155 using namespace ::vos; 156 using namespace ::rtl; 157 using namespace ::com::sun::star::uno; 158 using namespace ::com::sun::star::registry; 159 using namespace ::com::sun::star::lang; 160 161 162 163 Reference< XMultiServiceFactory > createApplicationServiceManager() 164 { 165 Reference< XMultiServiceFactory > xMS; 166 try 167 { 168 Reference< XComponentContext > xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext(); 169 if ( xComponentContext.is() ) 170 xMS = xMS.query( xComponentContext->getServiceManager() ); 171 } 172 catch( ::com::sun::star::uno::Exception& ) 173 { 174 } 175 176 return xMS; 177 } 178 179 // --- class EditApp ------------------------------------------------- 180 181 SV_DECL_PTRARR_DEL( StringList, String*, 0, 4 ); 182 SV_IMPL_PTRARR( StringList, String* ); 183 StringList aSimpleHistory; 184 185 class EditApp : public Application 186 { 187 public: 188 virtual void Main(); 189 }; 190 191 class MyEditEngine : public EditEngine 192 { 193 public: 194 MyEditEngine( SfxItemPool* pPool ) : EditEngine( pPool ) { ; } 195 virtual String CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos, Color*& rTxtColor, Color*& rFldColor ); 196 virtual void FieldClicked( const SvxFieldItem& rField, USHORT nPara, USHORT nPos ); 197 virtual void FieldSelected( const SvxFieldItem& rField, USHORT nPara, USHORT nPos ); 198 }; 199 200 XubString __EXPORT MyEditEngine::CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos, Color*& rpTxtColor, Color*& rpFldColor ) 201 { 202 const SvxFieldData* pField = rField.GetField(); 203 if ( !pField ) 204 return String( RTL_CONSTASCII_USTRINGPARAM( "<Empty>" ) ); 205 206 if ( pField->ISA( SvxDateField ) ) 207 return ((const SvxDateField*)pField)->GetFormatted( LANGUAGE_SYSTEM, LANGUAGE_SYSTEM ); 208 else if ( pField->ISA( SvxURLField ) ) 209 { 210 const SvxURLField* pURL = (const SvxURLField*)pField; 211 if ( !bURLClicked ) 212 { 213 delete rpTxtColor; 214 rpTxtColor = new Color( COL_BLUE ); 215 } 216 else 217 { 218 delete rpTxtColor; 219 rpTxtColor = new Color( COL_RED ); 220 delete rpFldColor; 221 rpFldColor = new Color( COL_YELLOW ); 222 } 223 if ( pURL->GetFormat() == SVXURLFORMAT_URL ) 224 return pURL->GetURL(); 225 return pURL->GetRepresentation(); 226 } 227 return String( RTL_CONSTASCII_USTRINGPARAM( "???" ) ); 228 } 229 230 void __EXPORT MyEditEngine::FieldClicked( const SvxFieldItem& rField, USHORT nPara, USHORT nPos ) 231 { 232 EditEngine::FieldClicked( rField, nPara, nPos ); // Falls URL 233 const SvxFieldData* pField = rField.GetField(); 234 if ( !pField ) 235 return; 236 237 if ( pField->ISA( SvxURLField ) ) 238 { 239 bURLClicked = TRUE; 240 UpdateFields(); 241 } 242 else 243 Sound::Beep(); 244 } 245 246 void __EXPORT MyEditEngine::FieldSelected( const SvxFieldItem& rField, USHORT nPara, USHORT nPos ) 247 { 248 const SvxFieldData* pField = rField.GetField(); 249 if ( !pField ) 250 return; 251 252 InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "Feld selektiert!" ) ) ).Execute(); 253 } 254 255 256 class MyView : public WorkWindow 257 { 258 private: 259 EditEngine* pEditEngine; 260 EditView* pEditView; 261 262 public: 263 MyView( Window* pParent, EditEngine* pEditEngine ); 264 ~MyView(); 265 266 virtual void Paint( const Rectangle& ); 267 virtual void Resize(); 268 virtual void KeyInput( const KeyEvent& rKeyEvt ); 269 virtual void MouseMove( const MouseEvent& rMEvt ); 270 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 271 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 272 virtual void Command( const CommandEvent& rCEvt ); 273 BOOL Drop( const DropEvent& rEvt ); 274 BOOL QueryDrop( DropEvent& rEvt ); 275 }; 276 277 MyView::MyView( Window* pParent, EditEngine* pEE ) : WorkWindow( pParent, WinBits( WB_STDWORK ) ) 278 { 279 pEditEngine = pEE; 280 pEditView = new EditView( pEditEngine, this ); 281 pEditEngine->InsertView( pEditView ); 282 SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Another View..." ) ) ); 283 // EnableDrop(); 284 SetBackgroundBrush( Brush( Color( COL_LIGHTBLUE ) ) ); 285 Show(); 286 } 287 288 MyView::~MyView() 289 { 290 pEditEngine->RemoveView( pEditView ); 291 delete pEditView; 292 } 293 294 void __EXPORT MyView::Paint( const Rectangle& rRec ) 295 { 296 pEditView->Paint( rRec ); 297 } 298 299 void __EXPORT MyView::Resize() 300 { 301 Size aPaperSz( GetOutputSize() ); 302 // aPaperSz.Width() /= 2; 303 // aPaperSz.Height() /= 2; 304 pEditView->SetOutputArea( Rectangle( Point( 0,0 ), aPaperSz ) ); 305 pEditView->SetVisArea( Rectangle( Point( 0,0 ), aPaperSz ) ); 306 Invalidate(); 307 pEditView->ShowCursor(); 308 } 309 310 // --- MyView::KeyInput() -------------------------------------- 311 void __EXPORT MyView::KeyInput( const KeyEvent& rKEvt ) 312 { 313 pEditView->PostKeyEvent( rKEvt ); 314 } 315 316 void __EXPORT MyView::MouseMove( const MouseEvent& rMEvt ) 317 { 318 Point aPos = PixelToLogic( rMEvt.GetPosPixel() ); 319 if ( pEditView->GetOutputArea().IsInside( aPos ) ) 320 SetPointer( pEditView->GetPointer() ); 321 else 322 SetPointer( Pointer() ); 323 324 325 pEditView->MouseMove( rMEvt ); 326 } 327 328 void __EXPORT MyView::MouseButtonDown( const MouseEvent& rMEvt ) 329 { 330 pEditView->MouseButtonDown( rMEvt ); 331 } 332 333 void __EXPORT MyView::MouseButtonUp( const MouseEvent& rMEvt ) 334 { 335 pEditView->MouseButtonUp( rMEvt ); 336 } 337 338 void __EXPORT MyView::Command( const CommandEvent& rCEvt ) 339 { 340 if ( rCEvt.GetCommand() == COMMAND_STARTDRAG ) 341 pEditView->Command(rCEvt); 342 } 343 344 BOOL __EXPORT MyView::Drop( const DropEvent& rEvt ) 345 { 346 return pEditView->Drop( rEvt ); 347 } 348 349 BOOL __EXPORT MyView::QueryDrop( DropEvent& rEvt ) 350 { 351 return pEditView->QueryDrop( rEvt ); 352 } 353 354 // --- class EditMainWindow -------------------------------------------- 355 DECLARE_LIST( ViewList, MyView* ); 356 357 class EditViewWindow : public Window 358 { 359 private: 360 MyEditEngine* pEditEngine; 361 EditView* pEditView; 362 Pointer aStdPtr; 363 Pointer aURLPtr; 364 WorkWindow* pTmpWindow; 365 ViewList aViewList; 366 367 XubString aTestStr; 368 369 370 public: 371 EditViewWindow( Window* pParent ); 372 ~EditViewWindow(); 373 374 virtual void Paint( const Rectangle& ); 375 virtual void Resize(); 376 virtual void KeyInput( const KeyEvent& rKeyEvt ); 377 virtual void MouseMove( const MouseEvent& rMEvt ); 378 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 379 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 380 virtual void Command( const CommandEvent& rCEvt ); 381 void MarkOutputArea(); 382 BOOL Drop( const DropEvent& rEvt ); 383 BOOL QueryDrop( DropEvent& rEvt ); 384 385 EditView* GetEditView() { return pEditView; } 386 }; 387 388 class EditMainWindow : public WorkWindow 389 { 390 private: 391 ToolBox aToolBox; 392 ScrollBar aHScrollBar; 393 ScrollBar aVScrollBar; 394 EditViewWindow aViewWin; 395 Printer* pPrinter; 396 397 WorkWindow* pTmpWindow; 398 399 EditTextObject* pRTFObj; 400 EditTextObject* pBinObj; 401 402 FileDialog* pFileDialogBox; 403 FileDialog* pFileDialogBox2; 404 405 406 protected: 407 void SetScrollBars(); 408 void SetScrollBarRanges(); 409 void CreatePolygon(); 410 411 virtual void GetFocus(); 412 413 public: 414 EditMainWindow(); 415 ~EditMainWindow(); 416 417 virtual void Resize(); 418 419 DECL_LINK( TBSelect, ToolBox * ); 420 void UpdateToolBox(); 421 422 DECL_LINK( HScrollHdl, ScrollBar * ); 423 DECL_LINK( VScrollHdl, ScrollBar * ); 424 DECL_LINK( ShowStatus, EditStatus * ); 425 void SetTitle(); 426 }; 427 428 429 EditMainWindow::~EditMainWindow() 430 { 431 delete pRTFObj; 432 delete pBinObj; 433 delete pFileDialogBox; 434 delete pFileDialogBox2; 435 delete pTmpWindow; 436 delete pPrinter; 437 } 438 439 EditMainWindow::EditMainWindow() : 440 WorkWindow( NULL, WB_APP | WB_STDWORK | WB_SVLOOK | WB_CLIPCHILDREN ) , 441 aViewWin( this ), 442 aToolBox( this, WinBits( WB_BORDER | WB_SVLOOK | WB_SCROLL | WB_LINESPACING ) ), 443 aHScrollBar( this, WinBits( WB_HSCROLL | WB_DRAG ) ), 444 aVScrollBar( this, WinBits( WB_VSCROLL | WB_DRAG ) ) 445 { 446 pRTFObj = 0; 447 pBinObj = 0; 448 449 pFileDialogBox = new FileDialog( this, WinBits( WB_OPEN | WB_SVLOOK ) ); 450 pFileDialogBox->SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Open" ) ) ); 451 pFileDialogBox->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Text" )), String( RTL_CONSTASCII_USTRINGPARAM( "*.txt" ) ) ); 452 pFileDialogBox->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.rtf" ) ) ); 453 pFileDialogBox->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "HTML" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.htm;*.html" ) ) ); 454 pFileDialogBox->SetCurFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ) ); 455 456 pFileDialogBox2 = new FileDialog( this, WinBits( WB_SAVEAS| WB_SVLOOK ) ); 457 pFileDialogBox2->SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Save" ) ) ); 458 pFileDialogBox2->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.txt" ) ) ); 459 pFileDialogBox2->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.rtf" ) ) ); 460 pFileDialogBox2->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "HTML" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.htm" ) ) ); 461 pFileDialogBox2->SetCurFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ) ); 462 463 pPrinter = new Printer; 464 pPrinter->SetMapMode( MAP_100TH_MM ); 465 aViewWin.SetMapMode( pPrinter->GetMapMode() ); 466 aViewWin.GetEditView()->GetEditEngine()->SetRefDevice( pPrinter ); 467 468 469 470 pTmpWindow = new WorkWindow( this, WB_STDWORK ); 471 472 aToolBox.SetButtonType( BUTTON_TEXT ); 473 aToolBox.SetLineCount( 4 ); 474 475 { 476 aToolBox.InsertItem( TB_OPEN, String( RTL_CONSTASCII_USTRINGPARAM( "Open" ) ) ); 477 aToolBox.InsertItem( TB_SAVE, String( RTL_CONSTASCII_USTRINGPARAM( "Save" ) ) ); 478 aToolBox.InsertItem( TB_PRINT, String( RTL_CONSTASCII_USTRINGPARAM( "Print" ) ) ); 479 aToolBox.InsertSeparator(); 480 aToolBox.InsertItem( TB_LEFT, String( RTL_CONSTASCII_USTRINGPARAM( "L" ) ) ); 481 aToolBox.InsertItem( TB_CENTER, String( RTL_CONSTASCII_USTRINGPARAM( "C" ) ) ); 482 aToolBox.InsertItem( TB_RIGHT, String( RTL_CONSTASCII_USTRINGPARAM( "R" ) ) ); 483 aToolBox.InsertItem( TB_BLOCK, String( RTL_CONSTASCII_USTRINGPARAM( "B" ) ) ); 484 aToolBox.InsertSeparator(); 485 aToolBox.InsertItem( TB_UNDO, String( RTL_CONSTASCII_USTRINGPARAM( "Undo" ) ) ); 486 aToolBox.InsertItem( TB_REDO, String( RTL_CONSTASCII_USTRINGPARAM( "Redo" ) ) ); 487 aToolBox.InsertSeparator(); 488 aToolBox.InsertItem( TB_FONT1, String( RTL_CONSTASCII_USTRINGPARAM( "Font1" ) ) ); 489 aToolBox.InsertItem( TB_FONT2, String( RTL_CONSTASCII_USTRINGPARAM( "Font2" ) ) ); 490 aToolBox.InsertItem( TB_DEFTAB, String( RTL_CONSTASCII_USTRINGPARAM( "DefTab" ) ) ); 491 aToolBox.InsertBreak(); 492 aToolBox.InsertItem( TB_OPEN2, String( RTL_CONSTASCII_USTRINGPARAM( "Read" ) ) ); 493 aToolBox.InsertItem( TB_SAVE2, String( RTL_CONSTASCII_USTRINGPARAM( "Write" ) ) ); 494 aToolBox.InsertSeparator(); 495 aToolBox.InsertItem( TB_FONT, String( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) ) ); 496 aToolBox.InsertItem( TB_ITALIC, String( RTL_CONSTASCII_USTRINGPARAM( "K" ) ) ); 497 aToolBox.InsertItem( TB_BOLD, String( RTL_CONSTASCII_USTRINGPARAM( "F" ) ) ); 498 aToolBox.InsertItem( TB_UNDERLINE, String( RTL_CONSTASCII_USTRINGPARAM( "U" ) ) ); 499 aToolBox.InsertItem( TB_SUPER, String( RTL_CONSTASCII_USTRINGPARAM( "SP" ) ) ); 500 aToolBox.InsertItem( TB_SUB, String( RTL_CONSTASCII_USTRINGPARAM( "SB" ) ) ); 501 aToolBox.InsertItem( TB_PKERN, String( RTL_CONSTASCII_USTRINGPARAM( "PK" ) ) ); 502 aToolBox.InsertItem( TB_KERN, String( RTL_CONSTASCII_USTRINGPARAM( "TK" ) ) ); 503 aToolBox.InsertItem( TB_WLM, String( RTL_CONSTASCII_USTRINGPARAM( "W!" ) ) ); 504 aToolBox.InsertSeparator(); 505 aToolBox.InsertItem( TB_BLACK, String( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) ); 506 aToolBox.InsertItem( TB_GREEN, String( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) ); 507 aToolBox.InsertItem( TB_RED, String( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) ); 508 aToolBox.InsertSeparator(); 509 aToolBox.InsertItem( TB_SBL, String( RTL_CONSTASCII_USTRINGPARAM( "SBL" ) ) ); 510 aToolBox.InsertItem( TB_SBSA, String( RTL_CONSTASCII_USTRINGPARAM( "SBSA" ) ) ); 511 aToolBox.InsertItem( TB_LR, String( RTL_CONSTASCII_USTRINGPARAM( "LR" ) ) ); 512 aToolBox.InsertSeparator(); 513 aToolBox.InsertItem( TB_DRAW, String( RTL_CONSTASCII_USTRINGPARAM( "Draw!" ) ) ); 514 aToolBox.InsertItem( TB_ROTATE, String( RTL_CONSTASCII_USTRINGPARAM( "Rotate!" ) ) ); 515 aToolBox.InsertItem( TB_MOVE, String( RTL_CONSTASCII_USTRINGPARAM( "Move->2" ) ) ); 516 aToolBox.InsertItem( TB_PARATTR1, String( RTL_CONSTASCII_USTRINGPARAM( "ParaAttr0" ) ) ); 517 aToolBox.InsertItem( TB_ATTRIBS, String( RTL_CONSTASCII_USTRINGPARAM( "GetAttribs" ) ) ); 518 aToolBox.InsertSeparator(); 519 aToolBox.InsertItem( TB_INSFLD, String( RTL_CONSTASCII_USTRINGPARAM( "InsFld" ) ) ); 520 aToolBox.InsertItem( TB_UPDFLD, String( RTL_CONSTASCII_USTRINGPARAM( "UpdFld" ) ) ); 521 } 522 aToolBox.InsertBreak(); 523 { 524 aToolBox.InsertItem( TB_ONLINESPELL, String( RTL_CONSTASCII_USTRINGPARAM( "Spell" ) ) ); 525 aToolBox.InsertItem( TB_REDLINES, String( RTL_CONSTASCII_USTRINGPARAM( "RedLine" ) ) ); 526 aToolBox.InsertItem( TB_AUTOCORRECT, String( RTL_CONSTASCII_USTRINGPARAM( "Auto*" ) ) ); 527 aToolBox.InsertItem( TB_HYPH, String( RTL_CONSTASCII_USTRINGPARAM( "Hyph" ) ) ); 528 aToolBox.InsertItem( TB_STDSEL, String( RTL_CONSTASCII_USTRINGPARAM( "StdSel" ) ) ); 529 aToolBox.InsertItem( TB_FLAT, String( RTL_CONSTASCII_USTRINGPARAM( "FlatMode" ) ) ); 530 aToolBox.InsertItem( TB_OUTL, String( RTL_CONSTASCII_USTRINGPARAM( "Ocomphelper" ) ) ); 531 aToolBox.InsertItem( TB_POLY, String( RTL_CONSTASCII_USTRINGPARAM( "Poly" ) ) ); 532 aToolBox.InsertItem( TB_COLORS, String( RTL_CONSTASCII_USTRINGPARAM( "Colors" ) )); 533 aToolBox.InsertItem( TB_IDLE, String( RTL_CONSTASCII_USTRINGPARAM( "Idle!" ) ) ); 534 aToolBox.InsertItem( TB_INSERT, String( RTL_CONSTASCII_USTRINGPARAM( "Insert" ) ) ); 535 aToolBox.InsertSeparator(); 536 aToolBox.InsertItem( TB_BINOBJ1, String( RTL_CONSTASCII_USTRINGPARAM( ">BINObj" ) ) ); 537 aToolBox.InsertItem( TB_BINOBJ1b, String( RTL_CONSTASCII_USTRINGPARAM( ">>BINObj" ) ) ); 538 aToolBox.InsertItem( TB_BINOBJ2b, String( RTL_CONSTASCII_USTRINGPARAM( "<<BINObj" ) ) ); 539 aToolBox.InsertItem( TB_CLONEBIN, String( RTL_CONSTASCII_USTRINGPARAM( "Clone" ) ) ); 540 aToolBox.InsertSeparator(); 541 aToolBox.InsertItem( TB_BINOBJ3, String( RTL_CONSTASCII_USTRINGPARAM( "StoreBin" ) ) ); 542 aToolBox.InsertItem( TB_BINOBJ4, String( RTL_CONSTASCII_USTRINGPARAM( "CreatBin" ) ) ); 543 } 544 545 aToolBox.SetPosPixel( Point( 0, 0 ) ); 546 aToolBox.SetSelectHdl( LINK( this, EditMainWindow, TBSelect ) ); 547 548 SetBackgroundBrush( Brush( Color( COL_LIGHTGRAY ) ) ); 549 550 SetPen( PEN_NULL ); 551 Show(); 552 553 aVScrollBar.SetScrollHdl ( LINK( this, EditMainWindow, VScrollHdl ) ); 554 aVScrollBar.SetLineSize( 300 ); 555 aVScrollBar.SetPageSize( 2000 ); 556 aHScrollBar.SetScrollHdl ( LINK( this, EditMainWindow, HScrollHdl ) ); 557 aHScrollBar.SetLineSize( 300 ); 558 aHScrollBar.SetPageSize( 2000 ); 559 aHScrollBar.Enable(); 560 aVScrollBar.Enable(); 561 562 aViewWin.GetEditView()->GetEditEngine()->SetStatusEventHdl( LINK( this, EditMainWindow, ShowStatus ) ); 563 564 SetTitle(); 565 566 UpdateToolBox(); 567 aToolBox.Show(); 568 aViewWin.Show(); 569 } 570 571 void EditMainWindow::SetTitle() 572 { 573 String aHeading( String( RTL_CONSTASCII_USTRINGPARAM( "SvEdit! - Zoom " ) ) ); 574 aHeading += String::CreateFromInt32(nZoom); 575 aHeading += '%'; 576 EditEngine* pEditEngine = aViewWin.GetEditView()->GetEditEngine(); 577 if ( pEditEngine->GetControlWord() & EE_CNTRL_STRETCHING ) 578 { 579 USHORT nX, nY; 580 pEditEngine->GetGlobalCharStretching( nX, nY ); 581 aHeading += String( RTL_CONSTASCII_USTRINGPARAM( ", Stretch=(" ) ); 582 aHeading += String::CreateFromInt32(nX); 583 aHeading += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) ); 584 aHeading += String::CreateFromInt32(nY); 585 aHeading += ')'; 586 } 587 SetText( aHeading ); 588 } 589 590 void EditMainWindow::UpdateToolBox() 591 { 592 EditView* pEditView = aViewWin.GetEditView(); 593 EditEngine* pEditEngine = pEditView->GetEditEngine(); 594 SfxItemSet aCurSet( pEditView->GetAttribs() ); 595 596 ULONG nControl = pEditEngine->GetControlWord(); 597 aToolBox.EnableItem( TB_UNDO, (BOOL)pEditEngine->GetUndoManager().GetUndoActionCount() ); 598 aToolBox.EnableItem( TB_REDO, (BOOL)pEditEngine->GetUndoManager().GetRedoActionCount() ); 599 aToolBox.EnableItem( TB_BINOBJ2b, (BOOL)(long)pBinObj ); 600 aToolBox.EnableItem( TB_MOVE, pEditEngine->GetParagraphCount() > 3 ); 601 aToolBox.CheckItem( TB_ONLINESPELL, nControl & EE_CNTRL_ONLINESPELLING ? TRUE : FALSE ); 602 aToolBox.CheckItem( TB_AUTOCORRECT, nControl & EE_CNTRL_AUTOCORRECT ? TRUE : FALSE ); 603 // aToolBox.CheckItem( TB_HYPH, nControl & EE_CNTRL_HYPHENATE ? TRUE : FALSE ); 604 aToolBox.CheckItem( TB_REDLINES, nControl & EE_CNTRL_NOREDLINES ? FALSE : TRUE ); 605 aToolBox.CheckItem( TB_STDSEL, pEditView->GetSelectionMode() == EE_SELMODE_STD ); 606 aToolBox.CheckItem( TB_FLAT, pEditEngine->IsFlatMode() ); 607 aToolBox.CheckItem( TB_OUTL, ( nControl & EE_CNTRL_OUTLINER ) ? TRUE : FALSE ); 608 aToolBox.CheckItem( TB_POLY, pEditEngine->GetPolygon() ? TRUE : FALSE ); 609 aToolBox.CheckItem( TB_COLORS, ( nControl & EE_CNTRL_NOCOLORS ) ? FALSE : TRUE ); 610 aToolBox.CheckItem( TB_IDLE, pEditEngine->IsIdleFormatterEnabled() ); 611 aToolBox.CheckItem( TB_INSERT, pEditView->IsInsertMode() ); 612 613 for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_ITEMS_END; nWhich++) 614 { 615 // if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF ) 616 // ; 617 // else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE ) 618 // ; 619 // else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_ON ) 620 { 621 const SfxPoolItem& rItem = aCurSet.Get( nWhich ); 622 switch ( nWhich ) 623 { 624 case EE_PARA_HYPHENATE: 625 aToolBox.CheckItem( TB_HYPH, ((SfxBoolItem&)rItem).GetValue() != 0 ); 626 break; 627 case EE_PARA_LRSPACE: 628 aToolBox.CheckItem( TB_LR, ((SvxLRSpaceItem&)rItem).GetTxtLeft() != 0 ); 629 break; 630 case EE_PARA_ULSPACE: 631 aToolBox.CheckItem( TB_SBSA, ((SvxULSpaceItem&)rItem).GetUpper() != 0 ); 632 break; 633 case EE_PARA_SBL: 634 aToolBox.CheckItem( TB_SBL, ((SvxLineSpacingItem&)rItem).GetPropLineSpace() != 100 ); 635 break; 636 case EE_PARA_JUST: 637 { 638 SvxAdjust e = ((SvxAdjustItem&)rItem).GetAdjust(); 639 aToolBox.CheckItem( TB_LEFT, e == SVX_ADJUST_LEFT ); 640 aToolBox.CheckItem( TB_RIGHT, e == SVX_ADJUST_RIGHT); 641 aToolBox.CheckItem( TB_CENTER, e == SVX_ADJUST_CENTER); 642 aToolBox.CheckItem( TB_BLOCK, e == SVX_ADJUST_BLOCK ); 643 } 644 break; 645 case EE_PARA_TABS: 646 break; 647 case EE_CHAR_COLOR: 648 { 649 Color aColor( ((SvxColorItem&)rItem).GetValue() ); 650 aToolBox.CheckItem( TB_BLACK, aColor == COL_BLACK ); 651 aToolBox.CheckItem( TB_GREEN, aColor == COL_GREEN ); 652 aToolBox.CheckItem( TB_RED, aColor == COL_RED ); 653 } 654 break; 655 case EE_CHAR_FONTINFO: 656 { 657 FontFamily e = ((SvxFontItem&)rItem).GetFamily(); 658 aToolBox.CheckItem( TB_FONT1, e == FAMILY_ROMAN ); 659 aToolBox.CheckItem( TB_FONT2, e == FAMILY_SWISS ); 660 } 661 break; 662 case EE_CHAR_FONTHEIGHT: 663 break; 664 case EE_CHAR_WEIGHT: 665 { 666 FontWeight e = ((SvxWeightItem&)rItem).GetWeight(); 667 aToolBox.CheckItem( TB_BOLD, e == WEIGHT_BOLD ); 668 } 669 break; 670 case EE_CHAR_UNDERLINE: 671 { 672 aToolBox.CheckItem( TB_UNDERLINE, ((SvxUnderlineItem&)rItem).GetLineStyle() ); 673 } 674 break; 675 case EE_CHAR_WLM: 676 { 677 aToolBox.CheckItem( TB_WLM, ((SvxWordLineModeItem&)rItem).GetValue() ); 678 } 679 break; 680 case EE_CHAR_PAIRKERNING: 681 { 682 aToolBox.CheckItem( TB_PKERN, ((SvxAutoKernItem&)rItem).GetValue() ); 683 } 684 break; 685 case EE_CHAR_KERNING: 686 { 687 aToolBox.CheckItem( TB_KERN, (BOOL)((SvxKerningItem&)rItem).GetValue() ); 688 } 689 break; 690 case EE_CHAR_ESCAPEMENT: 691 { 692 aToolBox.CheckItem( TB_SUPER, ((SvxEscapementItem&)rItem).GetEsc() > 0 ); 693 aToolBox.CheckItem( TB_SUB, ((SvxEscapementItem&)rItem).GetEsc() < 0 ); 694 } 695 break; 696 case EE_CHAR_STRIKEOUT: 697 break; 698 case EE_CHAR_ITALIC: 699 { 700 FontItalic e = ((SvxPostureItem&)rItem).GetPosture(); 701 aToolBox.CheckItem( TB_ITALIC, e == ITALIC_NORMAL ); 702 } 703 break; 704 case EE_CHAR_OUTLINE: 705 break; 706 case EE_CHAR_SHADOW: 707 break; 708 } 709 } 710 } 711 } 712 713 IMPL_LINK( EditMainWindow, TBSelect, ToolBox *, p ) 714 { 715 EditView* pEditView = aViewWin.GetEditView(); 716 EditEngine* pEditEngine = pEditView->GetEditEngine(); 717 USHORT nId = aToolBox.GetCurItemId(); 718 BOOL bChecked = aToolBox.IsItemChecked( nId ); 719 SfxPoolItem* pNewItem = 0; 720 switch ( nId ) 721 { 722 case TB_LEFT: pNewItem = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ); 723 break; 724 case TB_RIGHT: pNewItem = new SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ); 725 break; 726 case TB_CENTER: pNewItem = new SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ); 727 break; 728 case TB_BLOCK: pNewItem = new SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ); 729 break; 730 case TB_HYPH: pNewItem = new SfxBoolItem( EE_PARA_HYPHENATE, !bChecked ); 731 break; 732 case TB_UNDO: pEditView->Undo(); 733 pEditView->ShowCursor(); 734 break; 735 case TB_REDO: pEditView->Redo(); 736 pEditView->ShowCursor(); 737 break; 738 case TB_ONLINESPELL: { 739 ULONG nControl = pEditView->GetEditEngine()->GetControlWord(); 740 if ( bChecked ) 741 nControl = nControl & ~EE_CNTRL_ONLINESPELLING; 742 else 743 nControl = nControl | EE_CNTRL_ONLINESPELLING; 744 pEditView->GetEditEngine()->SetControlWord( nControl ); 745 } 746 break; 747 case TB_REDLINES: { 748 ULONG nControl = pEditView->GetEditEngine()->GetControlWord(); 749 if ( !bChecked ) 750 nControl = nControl & ~EE_CNTRL_NOREDLINES; 751 else 752 nControl = nControl | EE_CNTRL_NOREDLINES; 753 pEditView->GetEditEngine()->SetControlWord( nControl ); 754 } 755 break; 756 case TB_AUTOCORRECT: { 757 ULONG nControl = pEditView->GetEditEngine()->GetControlWord(); 758 if ( bChecked ) 759 nControl = nControl & ~EE_CNTRL_AUTOCORRECT; 760 else 761 nControl = nControl | EE_CNTRL_AUTOCORRECT; 762 pEditView->GetEditEngine()->SetControlWord( nControl ); 763 } 764 break; 765 case TB_STDSEL: if ( bChecked ) 766 pEditView->SetSelectionMode( EE_SELMODE_TXTONLY ); 767 else 768 pEditView->SetSelectionMode( EE_SELMODE_STD ); 769 break; 770 case TB_FLAT: pEditEngine->SetFlatMode( !pEditEngine->IsFlatMode() ); 771 break; 772 case TB_COLORS: { 773 ULONG nControl = pEditView->GetEditEngine()->GetControlWord(); 774 if ( bChecked ) 775 nControl = nControl | EE_CNTRL_NOCOLORS; 776 else 777 nControl = nControl & ~EE_CNTRL_NOCOLORS; 778 pEditView->GetEditEngine()->SetControlWord( nControl ); 779 } 780 // aViewWin.Invalidate(); 781 pEditView->GetEditEngine()->Draw( pEditView->GetWindow(), pEditView->GetOutputArea(), pEditView->GetVisArea().TopLeft() ); 782 break; 783 case TB_OUTL: { 784 ULONG nControl = pEditView->GetEditEngine()->GetControlWord(); 785 if ( !bChecked ) 786 nControl = nControl | EE_CNTRL_OUTLINER; 787 else 788 nControl = nControl & ~EE_CNTRL_OUTLINER; 789 pEditView->GetEditEngine()->SetControlWord( nControl ); 790 } 791 break; 792 case TB_POLY: { 793 if ( !bChecked ) 794 CreatePolygon(); 795 else 796 pEditView->GetEditEngine()->ClearPolygon(); 797 } 798 break; 799 case TB_IDLE: pEditEngine->EnableIdleFormatter( !pEditEngine->IsIdleFormatterEnabled() ); 800 break; 801 case TB_INSFLD: { 802 static BYTE nFld = 0; 803 if ( nFld > 2 ) 804 nFld = 0; 805 if ( nFld == 0 ) 806 { 807 SvxFieldItem aFld( SvxURLField( String( RTL_CONSTASCII_USTRINGPARAM( "www.mopo.de" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "Bla" ) ), SVXURLFORMAT_REPR ), EE_FEATURE_FIELD ); 808 pEditView->InsertField( aFld ); 809 } 810 else if ( nFld == 1 ) 811 pEditView->InsertField( SvxFieldItem( SvxURLField( String( RTL_CONSTASCII_USTRINGPARAM( "www.mopo.de" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "Morgenpost" ) ), SVXURLFORMAT_URL ), EE_FEATURE_FIELD ) ); 812 else if ( nFld == 2 ) 813 pEditView->InsertField( SvxFieldItem( SvxDateField( Date( 1,1,1995 ), SVXDATETYPE_FIX, SVXDATEFORMAT_D ), EE_FEATURE_FIELD ) ); 814 815 nFld++; 816 } 817 break; 818 case TB_UPDFLD: pEditEngine->UpdateFields(); 819 break; 820 case TB_INSERT: pEditView->SetInsertMode( !pEditView->IsInsertMode() ); 821 break; 822 case TB_FONT1: pNewItem = new SvxFontItem( FAMILY_ROMAN, String( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) ), String(), PITCH_DONTKNOW, RTL_TEXTENCODING_MS_1252, EE_CHAR_FONTINFO ); 823 break; 824 case TB_FONT2: pNewItem = new SvxFontItem( FAMILY_SWISS, String( RTL_CONSTASCII_USTRINGPARAM( "Helv" ) ), String(), PITCH_DONTKNOW, RTL_TEXTENCODING_MS_1252, EE_CHAR_FONTINFO ); 825 break; 826 /* 827 case TB_FONT: 828 { 829 FontDialog* pDlg = new FontDialog( this, WB_SVLOOK ); 830 pDlg->SetPrinter( pPrinter ); 831 Font aFont = pEditEngine->CreateFontFromItemSet( pEditView->GetAttribs() ); 832 MapMode aPntMode( MAP_POINT ); 833 MapMode aCurrent( aViewWin.GetMapMode() ); 834 Size aSz( aViewWin.LogicToLogic( aFont.GetSize(), &aCurrent, &aPntMode ) ); 835 aSz.Width() *= 10; 836 aSz.Height() *= 10; 837 aFont.SetSize( aSz ); 838 pDlg->SetSelectFont( aFont ); 839 if ( pDlg->Execute() ) 840 { 841 Font aNewFont( pDlg->GetSelectFont() ); 842 aSz = aViewWin.LogicToLogic( aNewFont.GetSize(), &aPntMode, &aCurrent ); 843 aSz.Width() /= 10; 844 aSz.Height() /= 10; 845 aNewFont.SetSize( aSz ); 846 847 SfxItemSet aSet( pEditEngine->GetEmptyItemSet() ); 848 849 pEditEngine->SetFontInfoInItemSet( aSet, aNewFont ); 850 pEditView->SetAttribs( aSet ); 851 } 852 delete pDlg; 853 } 854 break; 855 */ 856 case TB_BOLD: if ( bChecked ) 857 pNewItem = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT); 858 else 859 pNewItem = new SvxWeightItem( WEIGHT_BOLD, EE_CHAR_WEIGHT); 860 break; 861 case TB_ITALIC: if ( bChecked ) 862 pNewItem = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ); 863 else 864 pNewItem = new SvxPostureItem( ITALIC_NORMAL, EE_CHAR_ITALIC ); 865 break; 866 case TB_UNDERLINE: if ( bChecked ) 867 pNewItem = new SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ); 868 else 869 pNewItem = new SvxUnderlineItem( UNDERLINE_SINGLE, EE_CHAR_UNDERLINE ); 870 break; 871 case TB_WLM: pNewItem = new SvxWordLineModeItem( !bChecked, EE_CHAR_WLM ); 872 break; 873 case TB_PKERN: pNewItem = new SvxAutoKernItem( !bChecked, EE_CHAR_PAIRKERNING ); 874 break; 875 case TB_KERN: if ( bChecked ) 876 pNewItem = new SvxKerningItem( 0, EE_CHAR_KERNING ); 877 else 878 pNewItem = new SvxKerningItem( 100, EE_CHAR_KERNING); 879 break; 880 case TB_SUPER: if ( bChecked ) 881 pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_OFF, EE_CHAR_ESCAPEMENT); 882 else 883 // pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT); 884 pNewItem = new SvxEscapementItem( 50, 100, EE_CHAR_ESCAPEMENT ); 885 break; 886 case TB_SUB: if ( bChecked ) 887 pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_OFF, EE_CHAR_ESCAPEMENT); 888 else 889 // pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT); 890 pNewItem = new SvxEscapementItem( -50, 100, EE_CHAR_ESCAPEMENT ); 891 break; 892 case TB_GREEN: pNewItem = new SvxColorItem( Color(COL_GREEN), EE_CHAR_COLOR); 893 break; 894 case TB_RED: pNewItem = new SvxColorItem( Color(COL_RED), EE_CHAR_COLOR); 895 break; 896 case TB_BLACK: pNewItem = new SvxColorItem( Color(COL_BLACK), EE_CHAR_COLOR); 897 break; 898 case TB_SBL: pNewItem = new SvxLineSpacingItem( 0, EE_PARA_SBL ); 899 if ( bChecked ) 900 { 901 ((SvxLineSpacingItem*)pNewItem)->SetInterLineSpace( 0 ); 902 } 903 else 904 { 905 ((SvxLineSpacingItem*)pNewItem)->SetPropLineSpace( 150 ); 906 } 907 break; 908 case TB_SBSA: pNewItem = new SvxULSpaceItem( EE_PARA_ULSPACE ); 909 if ( !bChecked ) 910 { 911 ((SvxULSpaceItem*)pNewItem)->SetUpper( 400 ); 912 ((SvxULSpaceItem*)pNewItem)->SetLower( 400 ); 913 } 914 break; 915 case TB_LR: pNewItem = new SvxLRSpaceItem( EE_PARA_LRSPACE ); 916 if ( !bChecked ) 917 { 918 ((SvxLRSpaceItem*)pNewItem)->SetTxtLeft( 1000 ); 919 ((SvxLRSpaceItem*)pNewItem)->SetTxtFirstLineOfst( -500 ); 920 ((SvxLRSpaceItem*)pNewItem)->SetRight( 500 ); 921 } 922 break; 923 case TB_DEFTAB: if ( bChecked ) 924 pEditEngine->SetDefTab( 2000 ); 925 else 926 pEditEngine->SetDefTab( 600 ); 927 pEditView->ShowCursor(); 928 aToolBox.CheckItem( nId, !bChecked ); 929 break; 930 case TB_DRAW: { 931 pTmpWindow->SetMapMode( aViewWin.GetMapMode() ); 932 pTmpWindow->SetBackgroundBrush( Brush( Color( COL_GRAY ) ) ); 933 pTmpWindow->SetFillInBrush( Brush( Color( COL_LIGHTGRAY ) ) ); 934 pTmpWindow->Show(); 935 pTmpWindow->Invalidate(); 936 pTmpWindow->Update(); 937 pTmpWindow->DrawText( Point( 20, 20 ), String( RTL_CONSTASCII_USTRINGPARAM( "It's a Test..." ) ) ); 938 Rectangle aRect( Point( 500, 500 ), Size( 10000, 4000 ) ); 939 pTmpWindow->DrawRect( aRect ); 940 pEditEngine->Draw( pTmpWindow, aRect, Point( 0, 0 ) ); 941 nRotation = 0; 942 } 943 break; 944 case TB_ROTATE: { 945 nRotation += 100; 946 if ( nRotation == 3600 ) 947 nRotation = 0; 948 pTmpWindow->SetMapMode( aViewWin.GetMapMode() ); 949 pTmpWindow->SetBackgroundBrush( Brush( Color( COL_LIGHTGRAY ) ) ); 950 pTmpWindow->SetFillInBrush( Brush( Color( COL_LIGHTGRAY ) ) ); 951 pTmpWindow->Show(); 952 pTmpWindow->Invalidate(); 953 pTmpWindow->Update(); 954 pTmpWindow->DrawText( Point( 20, 20 ), String( RTL_CONSTASCII_USTRINGPARAM( "It's a Test..." ) ) ); 955 Rectangle aRect( Point( 500, 500 ), Size( 10000, 4000 ) ); 956 pEditEngine->Draw( pTmpWindow, Point( 2000, 4000 ), nRotation ); 957 } 958 break; 959 960 case TB_MOVE: 961 { 962 ESelection aESel = pEditView->GetSelection(); 963 USHORT nStartPara = Min( aESel.nStartPara, aESel.nEndPara ); 964 USHORT nEndPara = Max( aESel.nStartPara, aESel.nEndPara ); 965 pEditView->MoveParagraphs( Range(nStartPara,nEndPara), 2 ); 966 } 967 break; 968 case TB_PARATTR1: 969 { 970 pEditEngine->SetUpdateMode( FALSE ); 971 USHORT nPara = 0; 972 SfxItemSet aSet( pEditEngine->GetEmptyItemSet() ); 973 aSet.Put( SvxFontItem( FAMILY_DECORATIVE, String( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) ), String(),PITCH_DONTKNOW, RTL_TEXTENCODING_MS_1252, EE_CHAR_FONTINFO ) ); 974 aSet.Put( SvxColorItem( Color(COL_MAGENTA), EE_CHAR_COLOR ) ); 975 aSet.Put( SvxFontHeightItem(600, 100, EE_CHAR_FONTHEIGHT) ); 976 aSet.Put( SvxPostureItem( ITALIC_NORMAL, EE_CHAR_ITALIC ) ); 977 aSet.Put( SvxLRSpaceItem( 0, 0, 1000, 0, EE_PARA_LRSPACE ) ); 978 pEditView->SetParaAttribs( aSet, nPara ); 979 pEditEngine->SetUpdateMode( TRUE ); 980 pEditView->ShowCursor(); 981 } 982 break; 983 case TB_BINOBJ1: 984 { 985 delete pBinObj; 986 pBinObj = pEditEngine->CreateTextObject(); 987 } 988 break; 989 case TB_BINOBJ1b: 990 { 991 delete pBinObj; 992 pBinObj = pEditView->CreateTextObject(); 993 } 994 break; 995 case TB_CLONEBIN: 996 { 997 if ( pBinObj ) 998 { 999 EditTextObject* p = pBinObj->Clone(); 1000 delete pBinObj; 1001 pBinObj = p; 1002 } 1003 } 1004 break; 1005 case TB_BINOBJ2b: 1006 { 1007 if ( pBinObj ) 1008 { 1009 pEditView->InsertText( *pBinObj ); 1010 } 1011 } 1012 break; 1013 case TB_BINOBJ3: 1014 { 1015 if ( !pFileDialogBox2->Execute() ) 1016 return FALSE; 1017 DirEntry aDirEntry( pFileDialogBox2->GetPath() ); 1018 SvFileStream aStrm( aDirEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC ); 1019 EditTextObject* pTmpObj = pEditEngine->CreateTextObject(); 1020 pTmpObj->Store( aStrm ); 1021 DBG_ASSERT( !aStrm.GetError(), "Store: Error!" ); 1022 delete pTmpObj; 1023 } 1024 break; 1025 case TB_BINOBJ4: 1026 { 1027 if ( !pFileDialogBox->Execute() ) 1028 return FALSE; 1029 DirEntry aDirEntry( pFileDialogBox->GetPath() ); 1030 SvFileStream aStrm( aDirEntry.GetFull(), STREAM_READ ); 1031 delete pBinObj; 1032 pBinObj = EditTextObject::Create( aStrm ); 1033 // EditTextObject* pTmpObj = pEditEngine->CreateTextObject( aStrm ); 1034 // pEditEngine->SetText( *pTmpObj ); 1035 // pEditView->ShowCursor(); 1036 // delete pTmpObj; 1037 } 1038 break; 1039 case TB_OPEN: 1040 case TB_OPEN2: 1041 { 1042 if ( !pFileDialogBox->Execute() ) 1043 return FALSE; 1044 DirEntry aDirEntry( pFileDialogBox->GetPath() ); 1045 aDirEntry.ToAbs(); 1046 String aFileName( aDirEntry.GetFull() ); 1047 SvFileStream aStrm( aFileName, STREAM_READ ); 1048 if ( aStrm.GetError() ) 1049 InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "StreamError!" ) ) ).Execute(); 1050 Application::EnterWait(); 1051 if ( nId == TB_OPEN ) 1052 { 1053 if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) ) 1054 pEditEngine->Read( aStrm, EE_FORMAT_RTF ); 1055 if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) ) 1056 pEditEngine->Read( aStrm, EE_FORMAT_HTML ); 1057 if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) ) 1058 pEditEngine->Read( aStrm, EE_FORMAT_HTML ); 1059 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) ) 1060 pEditEngine->Read( aStrm, EE_FORMAT_BIN ); 1061 else 1062 pEditEngine->Read( aStrm, EE_FORMAT_TEXT ); 1063 1064 pEditView->ShowCursor(); 1065 } 1066 else 1067 { 1068 if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) ) 1069 pEditView->Read( aStrm, EE_FORMAT_RTF ); 1070 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) ) 1071 pEditView->Read( aStrm, EE_FORMAT_BIN ); 1072 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) ) 1073 pEditView->Read( aStrm, EE_FORMAT_HTML ); 1074 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) ) 1075 pEditView->Read( aStrm, EE_FORMAT_HTML ); 1076 else 1077 pEditView->Read( aStrm, EE_FORMAT_TEXT ); 1078 } 1079 1080 Application::LeaveWait(); 1081 1082 } 1083 break; 1084 case TB_PRINT: 1085 { 1086 pPrinter->SetPageQueueSize( 1 ); 1087 PrintDialog aPrnDlg( this ); 1088 aPrnDlg.SetPrinter( pPrinter ); 1089 if ( aPrnDlg.Execute() ) 1090 { 1091 pPrinter->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "SvEdit - PrinterTest" ) ) ); 1092 pPrinter->StartPage(); 1093 Size aSz( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() ); 1094 Pen aPen( PEN_SOLID ); 1095 aPen.SetColor( Color( COL_BLACK ) ); 1096 pPrinter->SetPen( aPen ); 1097 Rectangle aR( Point( 2000, 4000 ), aSz ); 1098 pPrinter->DrawRect( aR ); 1099 // So folgt auf IIISi, 75DPI kein Ausdruck! 1100 // pPrinter->SetClipRegion( Region( aR ) ); 1101 pEditEngine->Draw( pPrinter, Point( 2000, 4000 ), nRotation ); 1102 // pPrinter->SetClipRegion(); 1103 pPrinter->EndPage(); 1104 pPrinter->EndJob(); 1105 } 1106 } 1107 break; 1108 case TB_SAVE: 1109 case TB_SAVE2: 1110 { 1111 if ( !pFileDialogBox2->Execute() ) 1112 return FALSE; 1113 DirEntry aDirEntry( pFileDialogBox2->GetPath() ); 1114 // DirEntry aDirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\xxx.rtf" ) ) ); 1115 SvFileStream aStrm( aDirEntry.GetFull(), STREAM_WRITE | STREAM_TRUNC ); 1116 Application::EnterWait(); 1117 if ( nId == TB_SAVE ) 1118 { 1119 if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf") ) 1120 pEditEngine->Write( aStrm, EE_FORMAT_RTF ); 1121 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) ) 1122 pEditEngine->Write( aStrm, EE_FORMAT_BIN ); 1123 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) ) 1124 pEditEngine->Write( aStrm, EE_FORMAT_HTML ); 1125 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) ) 1126 pEditEngine->Write( aStrm, EE_FORMAT_HTML ); 1127 else 1128 pEditEngine->Write( aStrm, EE_FORMAT_TEXT ); 1129 } 1130 else 1131 { 1132 if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) ) 1133 pEditView->Write( aStrm, EE_FORMAT_RTF ); 1134 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "bin" ) ) 1135 pEditView->Write( aStrm, EE_FORMAT_BIN ); 1136 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "html" ) ) 1137 pEditView->Write( aStrm, EE_FORMAT_HTML ); 1138 else if ( aDirEntry.GetExtension().EqualsIgnoreCaseAscii( "htm" ) ) 1139 pEditView->Write( aStrm, EE_FORMAT_HTML ); 1140 else 1141 pEditView->Write( aStrm, EE_FORMAT_TEXT ); 1142 } 1143 Application::LeaveWait(); 1144 } 1145 break; 1146 case TB_ATTRIBS: 1147 { 1148 SfxItemSet aCurSet = pEditView->GetAttribs(); 1149 XubString aDebStr( String( RTL_CONSTASCII_USTRINGPARAM( "Attribute in Selektion:" ) ) ); 1150 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "\nVorlage:" ) ); 1151 XubString aStyle; 1152 // pEditView->GetStyleSheet( aStyle, eFam ); 1153 aDebStr += aStyle; 1154 for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_ITEMS_END; nWhich++) 1155 { 1156 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "\n" ) ); 1157 aDebStr += String::CreateFromInt32( nWhich ); 1158 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "\t" ) ); 1159 if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF ) 1160 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "---" ) ); 1161 else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE ) 1162 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) ); 1163 else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_ON ) 1164 { 1165 const SfxPoolItem& rItem = aCurSet.Get( nWhich ); 1166 switch ( nWhich ) 1167 { 1168 case EE_PARA_LRSPACE: 1169 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FI=" ) ); 1170 aDebStr += String::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetTxtFirstLineOfst() ); 1171 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", LI=" ) ); 1172 aDebStr += String::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetTxtLeft() ); 1173 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", RI=" ) ); 1174 aDebStr += String::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetRight() ); 1175 break; 1176 case EE_PARA_ULSPACE: 1177 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "SB=" ) ); 1178 aDebStr += String::CreateFromInt32( ((SvxULSpaceItem&)rItem).GetUpper() ); 1179 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", SA=" ) ); 1180 aDebStr += String::CreateFromInt32( ((SvxULSpaceItem&)rItem).GetLower() ); 1181 break; 1182 case EE_PARA_SBL: 1183 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "SBL=" ) ); 1184 aDebStr += String::CreateFromInt32( ((SvxLineSpacingItem&)rItem).GetInterLineSpace() ); 1185 break; 1186 case EE_PARA_JUST: 1187 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "SvxAdust=" ) ); 1188 aDebStr += String::CreateFromInt32( (USHORT)((SvxAdjustItem&)rItem).GetAdjust() ); 1189 break; 1190 case EE_PARA_TABS: 1191 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Tabs = ?" ) ); 1192 break; 1193 case EE_CHAR_COLOR: 1194 { 1195 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Color= " ) ); 1196 Color aColor( ((SvxColorItem&)rItem).GetValue() ); 1197 aDebStr += String::CreateFromInt32( aColor.GetRed() ); 1198 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) ); 1199 aDebStr += String::CreateFromInt32( aColor.GetGreen() ); 1200 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) ); 1201 aDebStr += String::CreateFromInt32( aColor.GetBlue() ); 1202 } 1203 break; 1204 case EE_CHAR_FONTINFO: 1205 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Font=" ) ); 1206 aDebStr += ((SvxFontItem&)rItem).GetFamilyName(); 1207 break; 1208 case EE_CHAR_FONTHEIGHT: 1209 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "Groesse=" ) ); 1210 aDebStr += String::CreateFromInt32( ((SvxFontHeightItem&)rItem).GetHeight() ); 1211 break; 1212 case EE_CHAR_WEIGHT: 1213 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontWeight=" ) ); 1214 aDebStr += String::CreateFromInt32( ((SvxWeightItem&)rItem).GetWeight() ); 1215 break; 1216 case EE_CHAR_UNDERLINE: 1217 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline=" ) ); 1218 aDebStr += String::CreateFromInt32( ((SvxUnderlineItem&)rItem).GetLineStyle() ); 1219 break; 1220 case EE_CHAR_WLM: 1221 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "WordLineMode=" ) ); 1222 aDebStr += String::CreateFromInt32( ((SvxWordLineModeItem&)rItem).GetValue() ); 1223 break; 1224 case EE_CHAR_STRIKEOUT: 1225 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout=" ) ); 1226 aDebStr += String::CreateFromInt32( ((SvxCrossedOutItem&)rItem).GetStrikeout() ); 1227 break; 1228 case EE_CHAR_ITALIC: 1229 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontPosture=" ) ); 1230 aDebStr += String::CreateFromInt32( ((SvxPostureItem&)rItem).GetPosture() ); 1231 break; 1232 case EE_CHAR_OUTLINE: 1233 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontOutline=" ) ); 1234 aDebStr += String::CreateFromInt32( ((SvxContourItem&)rItem).GetValue() ); 1235 break; 1236 case EE_CHAR_SHADOW: 1237 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "FontShadowed=" ) ); 1238 aDebStr += String::CreateFromInt32( ((SvxShadowedItem&)rItem).GetValue() ); 1239 break; 1240 } 1241 } 1242 else 1243 aDebStr += String( RTL_CONSTASCII_USTRINGPARAM( "?" ) ); 1244 } 1245 InfoBox( 0, aDebStr ).Execute(); 1246 } 1247 break; 1248 } 1249 1250 if ( pNewItem ) 1251 { 1252 SfxItemSet aSet = pEditView->GetEmptyItemSet(); 1253 aSet.Put( *pNewItem ); 1254 pEditView->SetAttribs( aSet ); 1255 delete pNewItem; 1256 } 1257 UpdateToolBox(); 1258 return 0; 1259 } 1260 1261 void EditMainWindow::CreatePolygon() 1262 { 1263 EditView* pEditView = aViewWin.GetEditView(); 1264 Size aSz = pEditView->GetWindow()->GetOutputSize(); 1265 Point aOffset( aSz.Width()/8, aSz.Height()/8 ); 1266 aSz.Width() *= 3; 1267 aSz.Width() /= 4; 1268 aSz.Height() *= 3; 1269 aSz.Height() /= 4; 1270 Polygon aPoly( 5 ); 1271 aPoly.SetPoint( Point( aSz.Width()/2, 0 ), 0 ); 1272 aPoly.SetPoint( Point( aSz.Width(), aSz.Height()/3 ), 1 ); 1273 aPoly.SetPoint( Point( aSz.Width()/2, aSz.Height() ), 2 ); 1274 aPoly.SetPoint( Point( 0, aSz.Height()/2 ), 3 ); 1275 aPoly.SetPoint( Point( aSz.Width()/2, 0 ), 4 ); 1276 PolyPolygon aPPoly( aPoly ); 1277 pEditView->GetEditEngine()->SetPolygon( aPPoly ); 1278 pEditView->SetOutputArea( Rectangle( aOffset, aSz ) ); 1279 ULONG nWord = pEditView->GetControlWord(); 1280 nWord &= ~(EV_CNTRL_AUTOSCROLL); 1281 pEditView->SetControlWord( nWord ); 1282 aViewWin.Invalidate(); 1283 } 1284 1285 void __EXPORT EditMainWindow::GetFocus() 1286 { 1287 aViewWin.GrabFocus(); 1288 } 1289 1290 IMPL_LINK_INLINE_START( EditMainWindow, HScrollHdl, ScrollBar *, pScrl ) 1291 { 1292 EditView* pEditView = aViewWin.GetEditView(); 1293 pEditView->Scroll( -pScrl->GetDelta(), 0, RGCHK_PAPERSZ1 ); 1294 return 0; 1295 } 1296 IMPL_LINK_INLINE_END( EditMainWindow, HScrollHdl, ScrollBar *, pScrl ) 1297 1298 IMPL_LINK_INLINE_START( EditMainWindow, VScrollHdl, ScrollBar *, pScrl ) 1299 { 1300 EditView* pEditView = aViewWin.GetEditView(); 1301 pEditView->Scroll( 0, -pScrl->GetDelta(), RGCHK_PAPERSZ1 ); 1302 return 0; 1303 } 1304 IMPL_LINK_INLINE_END( EditMainWindow, VScrollHdl, ScrollBar *, pScrl ) 1305 1306 void EditMainWindow::SetScrollBarRanges() 1307 { 1308 EditView* pEditView = aViewWin.GetEditView(); 1309 long y = pEditView->GetEditEngine()->GetTextHeight(); 1310 long x = pEditView->GetEditEngine()->GetPaperSize().Width(); 1311 1312 aHScrollBar.SetRange( Range( 0, x ) ); 1313 aVScrollBar.SetRange( Range( 0, y ) ); 1314 } 1315 1316 void EditMainWindow::SetScrollBars() 1317 { 1318 EditView* pEditView = aViewWin.GetEditView(); 1319 Size aSz = GetOutputSizePixel(); 1320 Size aRealSz( aSz ); 1321 long nScrollbarWidthPixel = aVScrollBar.GetSizePixel().Width(); 1322 long nTBHeight = aToolBox.GetSizePixel().Height(); 1323 aSz.Height() -= nTBHeight; 1324 Size aOrgSz( aSz ); 1325 1326 // VScroll... 1327 aSz.Height() += 2; 1328 Point aPoint( ( aSz.Width()- nScrollbarWidthPixel+1 ), -1+nTBHeight); 1329 aSz.Width() = nScrollbarWidthPixel; 1330 aVScrollBar.SetPosSizePixel( aPoint, aSz ); 1331 1332 // HScroll... 1333 aSz = aOrgSz; 1334 Point aPoint2( 0, aRealSz.Height()-aHScrollBar.GetSizePixel().Height()+1 ); // TB-Height schon drin! 1335 aSz.Width() -= aVScrollBar.GetSizePixel().Width(); 1336 aSz.Width() += 2; 1337 1338 aSz.Height() = nScrollbarWidthPixel; 1339 aHScrollBar.SetPosSizePixel( aPoint2, aSz ); 1340 1341 aHScrollBar.SetVisibleSize( pEditView->GetOutputArea().GetWidth() ); 1342 aVScrollBar.SetVisibleSize( pEditView->GetOutputArea().GetHeight() ); 1343 1344 SetScrollBarRanges(); 1345 1346 aVScrollBar.Show(); 1347 aHScrollBar.Show(); 1348 } 1349 1350 void __EXPORT EditMainWindow::Resize() 1351 { 1352 long nBorder = aVScrollBar.GetSizePixel().Width(); 1353 long nExtra = 10; 1354 Size aTBSz = aToolBox.CalcWindowSizePixel(); 1355 Size aOutSzPixel( GetOutputSizePixel() ); 1356 aToolBox.SetSizePixel( Size( aOutSzPixel.Width(), aTBSz.Height()) ); 1357 1358 aViewWin.SetSizePixel( Size( aOutSzPixel.Width()-nBorder-2*nExtra, aOutSzPixel.Height()-aTBSz.Height()-2*nExtra-nBorder) ); 1359 1360 aViewWin.SetPosPixel( Point( nExtra, aTBSz.Height()+nExtra ) ); 1361 1362 SetScrollBars(); 1363 1364 EditView* pEditView = aViewWin.GetEditView(); 1365 if ( pEditView && pEditView->GetEditEngine()->GetPolygon() ) 1366 CreatePolygon(); 1367 } 1368 1369 IMPL_LINK( EditMainWindow, ShowStatus, EditStatus *, pStat ) 1370 { 1371 EditView* pEditView = aViewWin.GetEditView(); 1372 EditEngine* pEditEngine = pEditView->GetEditEngine(); 1373 if ( ( pStat->GetStatusWord() & EE_STAT_TEXTWIDTHCHANGED ) || ( pStat->GetStatusWord() & EE_STAT_TEXTHEIGHTCHANGED ) ) 1374 { 1375 aViewWin.MarkOutputArea(); 1376 if ( pEditEngine->GetTextHeight() < (ULONG)pEditView->GetOutputArea().GetHeight() ) 1377 { 1378 // Wird durch RGCHK_PAPERSZ1 'geklippt' 1379 if ( !( pEditEngine->GetControlWord() & EE_CNTRL_AUTOPAGESIZE) ) 1380 pEditView->Scroll( -(long)pEditEngine->CalcTextWidth(), -(long)pEditEngine->GetTextHeight(), RGCHK_PAPERSZ1 ); 1381 } 1382 SetScrollBarRanges(); 1383 } 1384 if ( pStat->GetStatusWord() & EE_STAT_HSCROLL ) 1385 aHScrollBar.SetThumbPos( pEditView->GetVisArea().Left() ); 1386 if ( pStat->GetStatusWord() & EE_STAT_VSCROLL ) 1387 aVScrollBar.SetThumbPos( pEditView->GetVisArea().Top() ); 1388 1389 return 0; 1390 } 1391 1392 1393 EditViewWindow::~EditViewWindow() 1394 { 1395 // erst die angemeldeten Views zerstoeren 1396 // (melden sich selbst ab) 1397 MyView* pView = aViewList.First(); 1398 while ( pView ) 1399 { 1400 delete pView; 1401 pView = aViewList.Next(); 1402 } 1403 1404 pEditEngine->RemoveView( pEditView ); 1405 delete pEditView; 1406 // Beim Zerstoeren der Styles am Ende, EditEngine noch nicht kaputt, 1407 // wird der Handler gerufen, ich zerstore hier aber schon die View! 1408 pEditEngine->SetStatusEventHdl( Link() ); 1409 // SvxAutoCorrect* pAutoCorrekt = pEditEngine->GetAutoCorrect(); 1410 // pEditEngine->SetAutoCorrect( 0 ); 1411 // delete pAutoCorrekt; 1412 delete pEditEngine; 1413 } 1414 1415 EditViewWindow::EditViewWindow( Window* pParent ) : 1416 Window( pParent ), aURLPtr( POINTER_HAND ) 1417 { 1418 SetBackgroundBrush( Brush( Color( COL_WHITE ) ) ); 1419 SetMapMode( MAP_100TH_MM ); 1420 // EnableDrop(); 1421 1422 SfxItemPool* pPool = EditEngine::CreatePool(); 1423 Font aFont = GetSettings().GetStyleSettings().GetAppFont(); 1424 MapMode aPntMode( MAP_POINT ); 1425 MapMode aCurrent( GetMapMode() ); 1426 Size aSz( LogicToLogic( Size( 12, 0 ), &aPntMode, &aCurrent ) ); 1427 aFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) ) ); 1428 pPool->SetPoolDefaultItem( SvxFontItem( aFont.GetFamily(), aFont.GetName(), String(),aFont.GetPitch(), aFont.GetCharSet(), EE_CHAR_FONTINFO ) ); 1429 pPool->SetPoolDefaultItem( SvxFontHeightItem( aSz.Width(), 100, EE_CHAR_FONTHEIGHT ) ); 1430 pEditEngine = new MyEditEngine( pPool ); 1431 1432 Size aPaperSz( 10000,8000 ); 1433 pEditEngine->SetPaperSize( aPaperSz ); 1434 1435 pEditView = new EditView( pEditEngine, this ); 1436 pEditView->SetBackgroundColor( Color( COL_WHITE ) ); 1437 pEditView->SetOutputArea( Rectangle( Point( 100, 100 ), aPaperSz ) ); 1438 pEditEngine->SetDefaultLanguage( LANGUAGE_ENGLISH ); 1439 pEditEngine->InsertView( pEditView ); 1440 1441 SetPosSizePixel( Point( 10, 10 ), Size( 600, 400 ) ); 1442 SetPen( PEN_NULL ); 1443 Show(); 1444 1445 // Feldbefehle grau hinterlegen 1446 ULONG n = pEditEngine->GetControlWord(); 1447 n = n | (EE_CNTRL_MARKFIELDS|EE_CNTRL_AUTOCOMPLETE); 1448 pEditEngine->SetControlWord( n ); 1449 1450 // Test: Autozentrierung 1451 // ULONG n = pEditEngine->GetControlWord(); 1452 // n = n | EE_CNTRL_AUTOPAGESIZE; 1453 // pEditEngine->SetControlWord( n ); 1454 1455 // OneLineSpeling 1456 #ifdef WNT 1457 // pEditEngine->CreateSpeller( DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "n:\\offenv\\wnti" ) ) ), 1458 // DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "n:\\offenv\\wnti" ) ) ) ); 1459 // pEditEngine->GetSpeller()->SetActualLanguage( LANGUAGE_GERMAN ); 1460 // pEditEngine->GetSpeller()->SetDefaultLanguage( LANGUAGE_GERMAN ); 1461 // pEditEngine->GetSpeller()->SetMinTrail( 2 ); 1462 1463 // AutoCorrect wird nie zerstoert 1464 // pEditEngine->SetAutoCorrect( new SvxAutoCorrect( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\prj\\office\\autotext\\autocorr.dat" ) ) ) ); 1465 #endif 1466 } 1467 1468 void __EXPORT EditViewWindow::Paint( const Rectangle& rRec ) 1469 { 1470 if ( pEditView->GetEditEngine()->GetPolygon() ) 1471 { 1472 // Die Punkte des Polygons beziehen sich auf die View... 1473 MapMode aMapMode( GetMapMode() ); 1474 aMapMode.SetOrigin( pEditView->GetOutputArea().TopLeft() ); 1475 SetMapMode( aMapMode ); 1476 DrawPolyPolygon( *pEditView->GetEditEngine()->GetPolygon() ); 1477 aMapMode.SetOrigin( Point() ); 1478 SetMapMode( aMapMode ); 1479 } 1480 pEditView->Paint( rRec ); 1481 MarkOutputArea(); 1482 } 1483 1484 void EditViewWindow::MarkOutputArea() 1485 { 1486 static Rectangle aCurFrame; 1487 Rectangle aOutArea( pEditView->GetOutputArea() ); 1488 aOutArea = LogicToPixel( aOutArea ); 1489 aOutArea.Left()--; 1490 aOutArea.Right()++; 1491 aOutArea.Top()--; 1492 aOutArea.Bottom()++; 1493 aOutArea = PixelToLogic( aOutArea ); 1494 SetPen( Pen( Color( COL_RED ) ) ); 1495 SetFillInBrush( Brush( BRUSH_NULL ) ); 1496 DrawRect( aOutArea ); 1497 if ( !aCurFrame.IsEmpty() ) 1498 { 1499 if ( aCurFrame.Left() < aOutArea.Left() ) 1500 Invalidate( Rectangle( aCurFrame.TopLeft(), Size( aOutArea.Left()-aCurFrame.Left(), aCurFrame.GetHeight() ) ) ); 1501 if ( aCurFrame.Right() > aOutArea.Right() ) 1502 { 1503 long nW = aCurFrame.Right() - aOutArea.Right(); 1504 Point aPos( aCurFrame.TopRight() ); 1505 aPos.X() -= nW; 1506 Invalidate( Rectangle( aPos, Size( nW, aCurFrame.GetHeight() ) ) ); 1507 } 1508 if ( aCurFrame.Top() < aOutArea.Top() ) 1509 Invalidate( Rectangle( aCurFrame.TopLeft(), Size( aCurFrame.GetWidth(), aOutArea.Top() - aCurFrame.Top() ) ) ); 1510 if ( aCurFrame.Bottom() > aOutArea.Bottom() ) 1511 { 1512 long nH = aCurFrame.Bottom() - aOutArea.Bottom(); 1513 Point aPos( aCurFrame.BottomLeft() ); 1514 aPos.Y() -= nH; 1515 Invalidate( Rectangle( aPos, Size( aCurFrame.GetWidth(), nH ) ) ); 1516 } 1517 } 1518 aCurFrame = aOutArea; 1519 } 1520 1521 void __EXPORT EditViewWindow::Resize() 1522 { 1523 Size aPaperSz( GetOutputSize() ); 1524 pEditView->SetOutputArea( Rectangle( Point(0,0), aPaperSz ) ); 1525 pEditEngine->SetPaperSize( Size( aPaperSz.Width()*1, aPaperSz.Height()*1 ) ); 1526 pEditView->ShowCursor(); 1527 Invalidate(); 1528 } 1529 1530 void __EXPORT EditViewWindow::KeyInput( const KeyEvent& rKEvt ) 1531 { 1532 sal_Unicode nCharCode = rKEvt.GetCharCode(); 1533 1534 USHORT nCode = rKEvt.GetKeyCode().GetCode(); 1535 // Auswertung fuer besondere Einstellungen.... 1536 if ( ( nCode == KEY_A) && rKEvt.GetKeyCode().IsMod1() ) 1537 pEditView->SetSelection( ESelection( 0, 0, 0xFFFF, 0xFFFF ) ); 1538 else if ( ( nCode == KEY_R ) && rKEvt.GetKeyCode().IsMod2() ) 1539 Invalidate(); 1540 else if ( ( nCode == KEY_L ) && rKEvt.GetKeyCode().IsMod2() ) 1541 { 1542 ULONG n = pEditEngine->GetControlWord(); 1543 n = n | EE_CNTRL_ONECHARPERLINE; 1544 pEditEngine->SetControlWord( n ); 1545 pEditEngine->QuickFormatDoc(); 1546 } 1547 else if ( ( nCode == KEY_Z ) && rKEvt.GetKeyCode().IsMod2() ) 1548 { 1549 pEditView->RemoveAttribs(); 1550 } 1551 else if ( ( nCode == KEY_V ) && rKEvt.GetKeyCode().IsMod2() ) 1552 { 1553 pEditEngine->SetVertical( TRUE ); 1554 Invalidate(); 1555 } 1556 else if ( ( ( nCode == KEY_ADD ) || ( nCode == KEY_SUBTRACT ) )&& rKEvt.GetKeyCode().IsMod2() ) 1557 { 1558 short nDiff = ( nCode == KEY_ADD ) ? (+5) : (-5); 1559 if ( nZoom > 1000 ) 1560 nDiff *= 20; 1561 if ( nZoom <= 25 ) 1562 nDiff /= 5; 1563 if ( ( nZoom + nDiff ) > 0 ) 1564 nZoom += nDiff; 1565 MapMode aMapMode( MAP_100TH_MM, Point(0,0), Fraction(nZoom,100), Fraction(nZoom,100) ); 1566 SetMapMode( aMapMode ); 1567 ((EditMainWindow*)GetParent())->SetTitle(); 1568 1569 if ( rKEvt.GetKeyCode().IsMod1() ) 1570 { 1571 InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "ChangingRefMapMode..." ) ) ).Execute(); 1572 pEditEngine->SetRefMapMode( aMapMode ); 1573 } 1574 Invalidate(); 1575 } 1576 else if ( rKEvt.GetKeyCode().IsMod2() && 1577 ( ( nCode == KEY_UP) || ( nCode == KEY_DOWN ) || 1578 ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) ) ) 1579 { 1580 if( rKEvt.GetKeyCode().IsMod1() ) 1581 { 1582 ULONG nCtrl = pEditEngine->GetControlWord(); 1583 if ( ! ( nCtrl & EE_CNTRL_STRETCHING ) ) 1584 { 1585 nCtrl |= EE_CNTRL_STRETCHING; 1586 pEditEngine->SetControlWord( nCtrl ); 1587 } 1588 USHORT nX, nY; 1589 pEditEngine->GetGlobalCharStretching( nX, nY ); 1590 if ( ( nCode == KEY_DOWN ) && ( nY > 5 ) ) 1591 nY += 5; 1592 else if ( nCode == KEY_UP ) 1593 nY -= 5; 1594 else if ( nCode == KEY_RIGHT ) 1595 nX += 5; 1596 else if ( ( nCode == KEY_LEFT ) && ( nX > 5 ) ) 1597 nX -= 5; 1598 pEditEngine->SetGlobalCharStretching( nX, nY ); 1599 ((EditMainWindow*)GetParent())->SetTitle(); 1600 } 1601 else // ZeichenAttr 1602 { 1603 SfxItemSet aAttrs( pEditView->GetAttribs() ); 1604 SfxItemSet aNewAttrs( pEditEngine->GetEmptyItemSet() ); 1605 const SvxFontWidthItem& rItem = (const SvxFontWidthItem&)aAttrs.Get( EE_CHAR_FONTWIDTH ); 1606 USHORT nProp = rItem.GetProp(); 1607 if ( nCode == KEY_RIGHT ) 1608 nProp += 5; 1609 else if ( ( nCode == KEY_LEFT ) && ( nProp > 5 ) ) 1610 nProp -= 5; 1611 aNewAttrs.Put( SvxFontWidthItem( 0, nProp, EE_CHAR_FONTWIDTH ) ); 1612 pEditView->SetAttribs( aNewAttrs ); 1613 } 1614 } 1615 else if ( ( nCode == KEY_O ) && rKEvt.GetKeyCode().IsMod2() ) 1616 { 1617 MapMode aMapMode( GetMapMode() ); 1618 aMapMode.SetOrigin( Point( 41, 41 ) ); 1619 SetMapMode( aMapMode ); 1620 Invalidate(); 1621 } 1622 else if ( ( nCode == KEY_B ) && rKEvt.GetKeyCode().IsMod2() ) 1623 { 1624 SfxItemSet aSet = pEditView->GetEmptyItemSet(); 1625 aSet.Put( SvxFontHeightItem(800, 100, EE_CHAR_FONTHEIGHT) ); 1626 pEditView->SetAttribs( aSet ); 1627 } 1628 else if ( ( nCode == KEY_P ) && rKEvt.GetKeyCode().IsMod2() ) 1629 { 1630 // ESelection aSel = pEditView->GetSelection(); 1631 // for ( ULONG n = aSel.nStartPara; n <= aSel.nEndPara; n++ ) 1632 // { 1633 // InfoBox( 0, pEditEngine->GetText( n ) ).Execute(); 1634 // } 1635 InfoBox( 0, pEditView->GetSelected() ).Execute(); 1636 1637 } 1638 else if ( rKEvt.GetKeyCode().IsMod2() && 1639 ( nCode >= KEY_1 ) && ( nCode <= KEY_9 ) ) 1640 { 1641 ULONG nEECtrl = pEditEngine->GetControlWord(); 1642 nEECtrl = nEECtrl | EE_CNTRL_AUTOPAGESIZE; 1643 pEditEngine->SetControlWord( nEECtrl ); 1644 1645 ULONG nEVCtrl = pEditView->GetControlWord(); 1646 nEVCtrl |= EV_CNTRL_AUTOSIZE; 1647 pEditView->SetControlWord( nEVCtrl ); 1648 1649 pEditView->SetAnchorMode( (EVAnchorMode)(nCode-KEY_1) ); 1650 pEditView->SetOutputArea( Rectangle( Point(0,0), GetOutputSize() ) ); 1651 pEditEngine->SetMaxAutoPaperSize( GetOutputSize() ); 1652 pEditEngine->SetPaperSize( Size( 0, 0 ) ); 1653 } 1654 else if ( rKEvt.GetKeyCode().IsMod2() && ( nCode == KEY_0 ) ) 1655 { 1656 ULONG nEVCtrl = pEditView->GetControlWord(); 1657 nEVCtrl = nEVCtrl | EV_CNTRL_AUTOSIZE; 1658 pEditView->SetControlWord( nEVCtrl ); 1659 1660 Size aOutSz( GetOutputSize() ); 1661 Size aPaperSz( aOutSz.Width() / 2, 0 ); 1662 pEditView->SetOutputArea( Rectangle( Point(), aPaperSz ) ); 1663 pEditEngine->SetPaperSize( aPaperSz ); 1664 // Max-Height wird bei View verwendet, 1665 // MinSize/MaxSize nur, wenn AUTOPAGESIZE ( KEY_1 - KEY_9 ) 1666 pEditEngine->SetMaxAutoPaperSize( Size( aOutSz.Width() / 2, aOutSz.Height() / 2 ) ); 1667 pEditEngine->SetMinAutoPaperSize( Size( aOutSz.Width() / 8, aOutSz.Height() / 8 ) ); 1668 } 1669 else if ( ( nCode == KEY_J ) && rKEvt.GetKeyCode().IsMod2() ) 1670 { 1671 Size aTextSz( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() ); 1672 Rectangle aRect( pEditView->GetOutputArea().TopLeft(), aTextSz ); 1673 Brush aTmpBrush( Color( COL_LIGHTBLUE ), BRUSH_25 ); 1674 Brush aOldBrush( GetFillInBrush() ); 1675 SetFillInBrush( aTmpBrush ); 1676 DrawRect( aRect ); 1677 SetFillInBrush( aOldBrush ); 1678 pEditView->Paint( aRect ); 1679 } 1680 else if ( ( nCode == KEY_H ) && rKEvt.GetKeyCode().IsMod2() ) 1681 { 1682 Push(); 1683 Size aSz( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() ); 1684 Pen aPen( PEN_SOLID ); 1685 Brush aBrush( Color( COL_GRAY ), BRUSH_SOLID ); 1686 aPen.SetColor( Color( COL_BLACK ) ); 1687 SetPen( aPen ); 1688 SetFillInBrush( aBrush ); 1689 Rectangle aR( pEditView->GetOutputArea().TopLeft(), aSz ); 1690 DrawRect( aR ); 1691 Pop(); 1692 pEditEngine->Draw( this, pEditView->GetOutputArea() ); 1693 pEditView->ShowCursor( TRUE, TRUE ); 1694 } 1695 1696 // Eingabe an EditEngine... 1697 else 1698 { 1699 BOOL bDone = pEditView->PostKeyEvent( rKEvt ); 1700 if ( !bDone ) 1701 Window::KeyInput( rKEvt ); 1702 } 1703 1704 ((EditMainWindow*)GetParent())->UpdateToolBox(); 1705 } 1706 1707 void __EXPORT EditViewWindow::MouseMove( const MouseEvent& rMEvt ) 1708 { 1709 Point aPos = PixelToLogic( rMEvt.GetPosPixel() ); 1710 if ( pEditView->GetOutputArea().IsInside( aPos ) ) 1711 { 1712 const SvxFieldItem* pField = pEditView->GetFieldUnderMousePointer(); 1713 if ( pField ) 1714 SetPointer( aURLPtr ); 1715 else 1716 SetPointer( pEditView->GetPointer() ); 1717 1718 // aPos -= pEditView->GetOutputArea().TopLeft(); 1719 // aPos += pEditView->GetVisArea().TopLeft(); 1720 // if ( pEditView->GetEditEngine()->IsTextPos( aPos, PixelToLogic( Size( 5, 0 ) ).Width() ) ) 1721 // SetPointer( pEditView->GetPointer() ); 1722 // else 1723 // SetPointer( Pointer( POINTER_REFHAND ) ); 1724 1725 } 1726 else 1727 SetPointer( aStdPtr ); 1728 1729 // static long x = 0; 1730 // x++; 1731 // DBG_ASSERT( x < 1000, String( RTL_CONSTASCII_USTRINGPARAM( "?" ) ) ); 1732 pEditView->MouseMove( rMEvt ); 1733 } 1734 1735 void __EXPORT EditViewWindow::MouseButtonDown( const MouseEvent& rMEvt ) 1736 { 1737 GrabFocus(); 1738 pEditView->MouseButtonDown( rMEvt ); 1739 } 1740 1741 void __EXPORT EditViewWindow::MouseButtonUp( const MouseEvent& rMEvt ) 1742 { 1743 pEditView->MouseButtonUp( rMEvt ); 1744 ((EditMainWindow*)GetParent())->UpdateToolBox(); 1745 } 1746 1747 void __EXPORT EditViewWindow::Command( const CommandEvent& rCEvt ) 1748 { 1749 if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) 1750 { 1751 if( pEditView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel() ) ) 1752 pEditView->ExecuteSpellPopup( rCEvt.GetMousePosPixel() ); 1753 } 1754 else 1755 pEditView->Command(rCEvt); 1756 1757 } 1758 1759 BOOL __EXPORT EditViewWindow::Drop( const DropEvent& rEvt ) 1760 { 1761 return pEditView->Drop( rEvt ); 1762 } 1763 1764 BOOL __EXPORT EditViewWindow::QueryDrop( DropEvent& rEvt ) 1765 { 1766 return pEditView->QueryDrop( rEvt ); 1767 } 1768 1769 // --- aEditApp ------------------------------------------------------ 1770 1771 void __EXPORT EditApp::Main() 1772 { 1773 #ifdef WNT 1774 SvFactory::Init(); 1775 #endif 1776 1777 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr = createApplicationServiceManager(); 1778 ::comphelper::setProcessServiceFactory( xSMgr ); 1779 1780 EditDLL aEditDll; 1781 SvxGlobalItemData aItemData; 1782 SvxFieldItem::GetClassManager().SV_CLASS_REGISTER( SvxDateField ); 1783 SvxFieldItem::GetClassManager().SV_CLASS_REGISTER( SvxURLField ); 1784 1785 Help::EnableQuickHelp(); 1786 1787 EditMainWindow aWindow; 1788 Execute(); 1789 } 1790 1791 EditApp aEditApp; 1792