1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <editeng/editeng.hxx>
31 #include <editeng/eeitem.hxx>
32 #include <editeng/editview.hxx>
33 #include <editeng/editobj.hxx>
34 #include <editeng/editstat.hxx>
36 #include <editeng/flditem.hxx>
37 #include <svx/svxacorr.hxx>
38 #include <tools/fsys.hxx>
39 #include <svx/xpoly.hxx>
41 #include <vcl/window.hxx>
42 #include <vcl/svapp.hxx>
43 #include <vcl/font.hxx>
44 #include <vcl/sound.hxx>
45 #include <vcl/print.hxx>
46 #include <vcl/toolbox.hxx>
47 #include <vcl/help.hxx>
48 #include <vcl/scrbar.hxx>
49 #include <vcl/wrkwin.hxx>
50 #include <vcl/msgbox.hxx>
52 #include <dialdll.hxx>
54 #define SERVICE_SIMPLEREGISTRY "com.sun.star.registry.SimpleRegistry"
55 #include <comphelper/processfactory.hxx>
56 #include <cppuhelper/servicefactory.hxx>
57 #include <cppuhelper/bootstrap.hxx>
58 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
59 #include <com/sun/star/lang/XInitialization.hpp>
60 #include <com/sun/star/registry/XSimpleRegistry.hpp>
61 #include <sfx2/sfxuno.hxx>
64 #include <editeng/lrspitem.hxx>
65 #include <editeng/shdditem.hxx>
66 #include <editeng/cntritem.hxx>
67 #include <editeng/crsditem.hxx>
68 #include <editeng/udlnitem.hxx>
69 #include <editeng/lspcitem.hxx>
70 #include <editeng/escpitem.hxx>
71 #include <editeng/kernitem.hxx>
72 #include <editeng/akrnitem.hxx>
73 #include <editeng/wrlmitem.hxx>
74 #include <editeng/colritem.hxx>
75 #include <editeng/ulspitem.hxx>
76 #include <editeng/postitem.hxx>
77 #include <editeng/adjitem.hxx>
78 #include <editeng/wghtitem.hxx>
79 #include <editeng/fhgtitem.hxx>
80 #include <editeng/fontitem.hxx>
81 #include <fwdtitem.hxx>
84 #include <svl/undo.hxx>
85 #include <svl/itemset.hxx>
86 #include <svl/itempool.hxx>
87 #include <svl/poolitem.hxx>
88 #include <svtools/printdlg.hxx>
90 #include <osl/file.hxx>
91 #include <osl/process.h>
92 #include <rtl/bootstrap.hxx>
103 #define TB_UNDERLINE 10
117 #define TB_PARATTR1 35
121 #define TB_BINOBJ1 47
122 #define TB_BINOBJ3 49
123 #define TB_BINOBJ4 50
124 #define TB_BINOBJ1b 51
125 #define TB_BINOBJ2b 52
126 #define TB_ATTRIBS 54
129 #define TB_CLONEBIN 57
142 #define TB_ONLINESPELL 70
143 #define TB_REDLINES 71
144 #define TB_AUTOCORRECT 72
151 sal_Bool bURLClicked
= sal_False
;
153 using namespace ::com::sun::star::connection
;
154 using namespace ::vos
;
155 using namespace ::rtl
;
156 using namespace ::com::sun::star::uno
;
157 using namespace ::com::sun::star::registry
;
158 using namespace ::com::sun::star::lang
;
162 Reference
< XMultiServiceFactory
> createApplicationServiceManager()
164 Reference
< XMultiServiceFactory
> xMS
;
167 Reference
< XComponentContext
> xComponentContext
= ::cppu::defaultBootstrap_InitialComponentContext();
168 if ( xComponentContext
.is() )
169 xMS
= xMS
.query( xComponentContext
->getServiceManager() );
171 catch( ::com::sun::star::uno::Exception
& )
178 // --- class EditApp -------------------------------------------------
180 SV_DECL_PTRARR_DEL( StringList
, String
*, 0 );
181 SV_IMPL_PTRARR( StringList
, String
* );
182 StringList aSimpleHistory
;
184 class EditApp
: public Application
190 class MyEditEngine
: public EditEngine
193 MyEditEngine( SfxItemPool
* pPool
) : EditEngine( pPool
) { ; }
194 virtual String
CalcFieldValue( const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
, Color
*& rTxtColor
, Color
*& rFldColor
);
195 virtual void FieldClicked( const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
);
196 virtual void FieldSelected( const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
);
199 XubString __EXPORT
MyEditEngine::CalcFieldValue( const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
, Color
*& rpTxtColor
, Color
*& rpFldColor
)
201 const SvxFieldData
* pField
= rField
.GetField();
203 return String( RTL_CONSTASCII_USTRINGPARAM( "<Empty>" ) );
205 if ( pField
->ISA( SvxDateField
) )
206 return ((const SvxDateField
*)pField
)->GetFormatted( LANGUAGE_SYSTEM
, LANGUAGE_SYSTEM
);
207 else if ( pField
->ISA( SvxURLField
) )
209 const SvxURLField
* pURL
= (const SvxURLField
*)pField
;
213 rpTxtColor
= new Color( COL_BLUE
);
218 rpTxtColor
= new Color( COL_RED
);
220 rpFldColor
= new Color( COL_YELLOW
);
222 if ( pURL
->GetFormat() == SVXURLFORMAT_URL
)
223 return pURL
->GetURL();
224 return pURL
->GetRepresentation();
226 return String( RTL_CONSTASCII_USTRINGPARAM( "???" ) );
229 void __EXPORT
MyEditEngine::FieldClicked( const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
)
231 EditEngine::FieldClicked( rField
, nPara
, nPos
); // Falls URL
232 const SvxFieldData
* pField
= rField
.GetField();
236 if ( pField
->ISA( SvxURLField
) )
245 void __EXPORT
MyEditEngine::FieldSelected( const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
)
247 const SvxFieldData
* pField
= rField
.GetField();
251 InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "Feld selektiert!" ) ) ).Execute();
255 class MyView
: public WorkWindow
258 EditEngine
* pEditEngine
;
262 MyView( Window
* pParent
, EditEngine
* pEditEngine
);
265 virtual void Paint( const Rectangle
& );
266 virtual void Resize();
267 virtual void KeyInput( const KeyEvent
& rKeyEvt
);
268 virtual void MouseMove( const MouseEvent
& rMEvt
);
269 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
270 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
271 virtual void Command( const CommandEvent
& rCEvt
);
272 BOOL
Drop( const DropEvent
& rEvt
);
273 BOOL
QueryDrop( DropEvent
& rEvt
);
276 MyView::MyView( Window
* pParent
, EditEngine
* pEE
) : WorkWindow( pParent
, WinBits( WB_STDWORK
) )
279 pEditView
= new EditView( pEditEngine
, this );
280 pEditEngine
->InsertView( pEditView
);
281 SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Another View..." ) ) );
283 SetBackgroundBrush( Brush( Color( COL_LIGHTBLUE
) ) );
289 pEditEngine
->RemoveView( pEditView
);
293 void __EXPORT
MyView::Paint( const Rectangle
& rRec
)
295 pEditView
->Paint( rRec
);
298 void __EXPORT
MyView::Resize()
300 Size
aPaperSz( GetOutputSize() );
301 // aPaperSz.Width() /= 2;
302 // aPaperSz.Height() /= 2;
303 pEditView
->SetOutputArea( Rectangle( Point( 0,0 ), aPaperSz
) );
304 pEditView
->SetVisArea( Rectangle( Point( 0,0 ), aPaperSz
) );
306 pEditView
->ShowCursor();
309 // --- MyView::KeyInput() --------------------------------------
310 void __EXPORT
MyView::KeyInput( const KeyEvent
& rKEvt
)
312 pEditView
->PostKeyEvent( rKEvt
);
315 void __EXPORT
MyView::MouseMove( const MouseEvent
& rMEvt
)
317 Point aPos
= PixelToLogic( rMEvt
.GetPosPixel() );
318 if ( pEditView
->GetOutputArea().IsInside( aPos
) )
319 SetPointer( pEditView
->GetPointer() );
321 SetPointer( Pointer() );
324 pEditView
->MouseMove( rMEvt
);
327 void __EXPORT
MyView::MouseButtonDown( const MouseEvent
& rMEvt
)
329 pEditView
->MouseButtonDown( rMEvt
);
332 void __EXPORT
MyView::MouseButtonUp( const MouseEvent
& rMEvt
)
334 pEditView
->MouseButtonUp( rMEvt
);
337 void __EXPORT
MyView::Command( const CommandEvent
& rCEvt
)
339 if ( rCEvt
.GetCommand() == COMMAND_STARTDRAG
)
340 pEditView
->Command(rCEvt
);
343 BOOL __EXPORT
MyView::Drop( const DropEvent
& rEvt
)
345 return pEditView
->Drop( rEvt
);
348 BOOL __EXPORT
MyView::QueryDrop( DropEvent
& rEvt
)
350 return pEditView
->QueryDrop( rEvt
);
353 // --- class EditMainWindow --------------------------------------------
355 class EditViewWindow
: public Window
358 MyEditEngine
* pEditEngine
;
362 WorkWindow
* pTmpWindow
;
368 EditViewWindow( Window
* pParent
);
371 virtual void Paint( const Rectangle
& );
372 virtual void Resize();
373 virtual void KeyInput( const KeyEvent
& rKeyEvt
);
374 virtual void MouseMove( const MouseEvent
& rMEvt
);
375 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
376 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
377 virtual void Command( const CommandEvent
& rCEvt
);
378 void MarkOutputArea();
379 BOOL
Drop( const DropEvent
& rEvt
);
380 BOOL
QueryDrop( DropEvent
& rEvt
);
382 EditView
* GetEditView() { return pEditView
; }
385 class EditMainWindow
: public WorkWindow
389 ScrollBar aHScrollBar
;
390 ScrollBar aVScrollBar
;
391 EditViewWindow aViewWin
;
394 WorkWindow
* pTmpWindow
;
396 EditTextObject
* pRTFObj
;
397 EditTextObject
* pBinObj
;
399 FileDialog
* pFileDialogBox
;
400 FileDialog
* pFileDialogBox2
;
404 void SetScrollBars();
405 void SetScrollBarRanges();
406 void CreatePolygon();
408 virtual void GetFocus();
414 virtual void Resize();
416 DECL_LINK( TBSelect
, ToolBox
* );
417 void UpdateToolBox();
419 DECL_LINK( HScrollHdl
, ScrollBar
* );
420 DECL_LINK( VScrollHdl
, ScrollBar
* );
421 DECL_LINK( ShowStatus
, EditStatus
* );
426 EditMainWindow::~EditMainWindow()
430 delete pFileDialogBox
;
431 delete pFileDialogBox2
;
436 EditMainWindow::EditMainWindow() :
437 WorkWindow( NULL
, WB_APP
| WB_STDWORK
| WB_SVLOOK
| WB_CLIPCHILDREN
) ,
439 aToolBox( this, WinBits( WB_BORDER
| WB_SVLOOK
| WB_SCROLL
| WB_LINESPACING
) ),
440 aHScrollBar( this, WinBits( WB_HSCROLL
| WB_DRAG
) ),
441 aVScrollBar( this, WinBits( WB_VSCROLL
| WB_DRAG
) )
446 pFileDialogBox
= new FileDialog( this, WinBits( WB_OPEN
| WB_SVLOOK
) );
447 pFileDialogBox
->SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Open" ) ) );
448 pFileDialogBox
->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Text" )), String( RTL_CONSTASCII_USTRINGPARAM( "*.txt" ) ) );
449 pFileDialogBox
->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.rtf" ) ) );
450 pFileDialogBox
->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "HTML" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.htm;*.html" ) ) );
451 pFileDialogBox
->SetCurFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ) );
453 pFileDialogBox2
= new FileDialog( this, WinBits( WB_SAVEAS
| WB_SVLOOK
) );
454 pFileDialogBox2
->SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Save" ) ) );
455 pFileDialogBox2
->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.txt" ) ) );
456 pFileDialogBox2
->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.rtf" ) ) );
457 pFileDialogBox2
->AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "HTML" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.htm" ) ) );
458 pFileDialogBox2
->SetCurFilter( String( RTL_CONSTASCII_USTRINGPARAM( "Rich Text Format" ) ) );
460 pPrinter
= new Printer
;
461 pPrinter
->SetMapMode( MAP_100TH_MM
);
462 aViewWin
.SetMapMode( pPrinter
->GetMapMode() );
463 aViewWin
.GetEditView()->GetEditEngine()->SetRefDevice( pPrinter
);
467 pTmpWindow
= new WorkWindow( this, WB_STDWORK
);
469 aToolBox
.SetButtonType( BUTTON_TEXT
);
470 aToolBox
.SetLineCount( 4 );
473 aToolBox
.InsertItem( TB_OPEN
, String( RTL_CONSTASCII_USTRINGPARAM( "Open" ) ) );
474 aToolBox
.InsertItem( TB_SAVE
, String( RTL_CONSTASCII_USTRINGPARAM( "Save" ) ) );
475 aToolBox
.InsertItem( TB_PRINT
, String( RTL_CONSTASCII_USTRINGPARAM( "Print" ) ) );
476 aToolBox
.InsertSeparator();
477 aToolBox
.InsertItem( TB_LEFT
, String( RTL_CONSTASCII_USTRINGPARAM( "L" ) ) );
478 aToolBox
.InsertItem( TB_CENTER
, String( RTL_CONSTASCII_USTRINGPARAM( "C" ) ) );
479 aToolBox
.InsertItem( TB_RIGHT
, String( RTL_CONSTASCII_USTRINGPARAM( "R" ) ) );
480 aToolBox
.InsertItem( TB_BLOCK
, String( RTL_CONSTASCII_USTRINGPARAM( "B" ) ) );
481 aToolBox
.InsertSeparator();
482 aToolBox
.InsertItem( TB_UNDO
, String( RTL_CONSTASCII_USTRINGPARAM( "Undo" ) ) );
483 aToolBox
.InsertItem( TB_REDO
, String( RTL_CONSTASCII_USTRINGPARAM( "Redo" ) ) );
484 aToolBox
.InsertSeparator();
485 aToolBox
.InsertItem( TB_FONT1
, String( RTL_CONSTASCII_USTRINGPARAM( "Font1" ) ) );
486 aToolBox
.InsertItem( TB_FONT2
, String( RTL_CONSTASCII_USTRINGPARAM( "Font2" ) ) );
487 aToolBox
.InsertItem( TB_DEFTAB
, String( RTL_CONSTASCII_USTRINGPARAM( "DefTab" ) ) );
488 aToolBox
.InsertBreak();
489 aToolBox
.InsertItem( TB_OPEN2
, String( RTL_CONSTASCII_USTRINGPARAM( "Read" ) ) );
490 aToolBox
.InsertItem( TB_SAVE2
, String( RTL_CONSTASCII_USTRINGPARAM( "Write" ) ) );
491 aToolBox
.InsertSeparator();
492 aToolBox
.InsertItem( TB_FONT
, String( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) ) );
493 aToolBox
.InsertItem( TB_ITALIC
, String( RTL_CONSTASCII_USTRINGPARAM( "K" ) ) );
494 aToolBox
.InsertItem( TB_BOLD
, String( RTL_CONSTASCII_USTRINGPARAM( "F" ) ) );
495 aToolBox
.InsertItem( TB_UNDERLINE
, String( RTL_CONSTASCII_USTRINGPARAM( "U" ) ) );
496 aToolBox
.InsertItem( TB_SUPER
, String( RTL_CONSTASCII_USTRINGPARAM( "SP" ) ) );
497 aToolBox
.InsertItem( TB_SUB
, String( RTL_CONSTASCII_USTRINGPARAM( "SB" ) ) );
498 aToolBox
.InsertItem( TB_PKERN
, String( RTL_CONSTASCII_USTRINGPARAM( "PK" ) ) );
499 aToolBox
.InsertItem( TB_KERN
, String( RTL_CONSTASCII_USTRINGPARAM( "TK" ) ) );
500 aToolBox
.InsertItem( TB_WLM
, String( RTL_CONSTASCII_USTRINGPARAM( "W!" ) ) );
501 aToolBox
.InsertSeparator();
502 aToolBox
.InsertItem( TB_BLACK
, String( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) );
503 aToolBox
.InsertItem( TB_GREEN
, String( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) );
504 aToolBox
.InsertItem( TB_RED
, String( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) );
505 aToolBox
.InsertSeparator();
506 aToolBox
.InsertItem( TB_SBL
, String( RTL_CONSTASCII_USTRINGPARAM( "SBL" ) ) );
507 aToolBox
.InsertItem( TB_SBSA
, String( RTL_CONSTASCII_USTRINGPARAM( "SBSA" ) ) );
508 aToolBox
.InsertItem( TB_LR
, String( RTL_CONSTASCII_USTRINGPARAM( "LR" ) ) );
509 aToolBox
.InsertSeparator();
510 aToolBox
.InsertItem( TB_DRAW
, String( RTL_CONSTASCII_USTRINGPARAM( "Draw!" ) ) );
511 aToolBox
.InsertItem( TB_ROTATE
, String( RTL_CONSTASCII_USTRINGPARAM( "Rotate!" ) ) );
512 aToolBox
.InsertItem( TB_MOVE
, String( RTL_CONSTASCII_USTRINGPARAM( "Move->2" ) ) );
513 aToolBox
.InsertItem( TB_PARATTR1
, String( RTL_CONSTASCII_USTRINGPARAM( "ParaAttr0" ) ) );
514 aToolBox
.InsertItem( TB_ATTRIBS
, String( RTL_CONSTASCII_USTRINGPARAM( "GetAttribs" ) ) );
515 aToolBox
.InsertSeparator();
516 aToolBox
.InsertItem( TB_INSFLD
, String( RTL_CONSTASCII_USTRINGPARAM( "InsFld" ) ) );
517 aToolBox
.InsertItem( TB_UPDFLD
, String( RTL_CONSTASCII_USTRINGPARAM( "UpdFld" ) ) );
519 aToolBox
.InsertBreak();
521 aToolBox
.InsertItem( TB_ONLINESPELL
, String( RTL_CONSTASCII_USTRINGPARAM( "Spell" ) ) );
522 aToolBox
.InsertItem( TB_REDLINES
, String( RTL_CONSTASCII_USTRINGPARAM( "RedLine" ) ) );
523 aToolBox
.InsertItem( TB_AUTOCORRECT
, String( RTL_CONSTASCII_USTRINGPARAM( "Auto*" ) ) );
524 aToolBox
.InsertItem( TB_HYPH
, String( RTL_CONSTASCII_USTRINGPARAM( "Hyph" ) ) );
525 aToolBox
.InsertItem( TB_STDSEL
, String( RTL_CONSTASCII_USTRINGPARAM( "StdSel" ) ) );
526 aToolBox
.InsertItem( TB_FLAT
, String( RTL_CONSTASCII_USTRINGPARAM( "FlatMode" ) ) );
527 aToolBox
.InsertItem( TB_OUTL
, String( RTL_CONSTASCII_USTRINGPARAM( "Ocomphelper" ) ) );
528 aToolBox
.InsertItem( TB_POLY
, String( RTL_CONSTASCII_USTRINGPARAM( "Poly" ) ) );
529 aToolBox
.InsertItem( TB_COLORS
, String( RTL_CONSTASCII_USTRINGPARAM( "Colors" ) ));
530 aToolBox
.InsertItem( TB_IDLE
, String( RTL_CONSTASCII_USTRINGPARAM( "Idle!" ) ) );
531 aToolBox
.InsertItem( TB_INSERT
, String( RTL_CONSTASCII_USTRINGPARAM( "Insert" ) ) );
532 aToolBox
.InsertSeparator();
533 aToolBox
.InsertItem( TB_BINOBJ1
, String( RTL_CONSTASCII_USTRINGPARAM( ">BINObj" ) ) );
534 aToolBox
.InsertItem( TB_BINOBJ1b
, String( RTL_CONSTASCII_USTRINGPARAM( ">>BINObj" ) ) );
535 aToolBox
.InsertItem( TB_BINOBJ2b
, String( RTL_CONSTASCII_USTRINGPARAM( "<<BINObj" ) ) );
536 aToolBox
.InsertItem( TB_CLONEBIN
, String( RTL_CONSTASCII_USTRINGPARAM( "Clone" ) ) );
537 aToolBox
.InsertSeparator();
538 aToolBox
.InsertItem( TB_BINOBJ3
, String( RTL_CONSTASCII_USTRINGPARAM( "StoreBin" ) ) );
539 aToolBox
.InsertItem( TB_BINOBJ4
, String( RTL_CONSTASCII_USTRINGPARAM( "CreatBin" ) ) );
542 aToolBox
.SetPosPixel( Point( 0, 0 ) );
543 aToolBox
.SetSelectHdl( LINK( this, EditMainWindow
, TBSelect
) );
545 SetBackgroundBrush( Brush( Color( COL_LIGHTGRAY
) ) );
550 aVScrollBar
.SetScrollHdl ( LINK( this, EditMainWindow
, VScrollHdl
) );
551 aVScrollBar
.SetLineSize( 300 );
552 aVScrollBar
.SetPageSize( 2000 );
553 aHScrollBar
.SetScrollHdl ( LINK( this, EditMainWindow
, HScrollHdl
) );
554 aHScrollBar
.SetLineSize( 300 );
555 aHScrollBar
.SetPageSize( 2000 );
556 aHScrollBar
.Enable();
557 aVScrollBar
.Enable();
559 aViewWin
.GetEditView()->GetEditEngine()->SetStatusEventHdl( LINK( this, EditMainWindow
, ShowStatus
) );
568 void EditMainWindow::SetTitle()
570 String
aHeading( String( RTL_CONSTASCII_USTRINGPARAM( "SvEdit! - Zoom " ) ) );
571 aHeading
+= String::CreateFromInt32(nZoom
);
573 EditEngine
* pEditEngine
= aViewWin
.GetEditView()->GetEditEngine();
574 if ( pEditEngine
->GetControlWord() & EE_CNTRL_STRETCHING
)
577 pEditEngine
->GetGlobalCharStretching( nX
, nY
);
578 aHeading
+= String( RTL_CONSTASCII_USTRINGPARAM( ", Stretch=(" ) );
579 aHeading
+= String::CreateFromInt32(nX
);
580 aHeading
+= String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
581 aHeading
+= String::CreateFromInt32(nY
);
587 void EditMainWindow::UpdateToolBox()
589 EditView
* pEditView
= aViewWin
.GetEditView();
590 EditEngine
* pEditEngine
= pEditView
->GetEditEngine();
591 SfxItemSet
aCurSet( pEditView
->GetAttribs() );
593 ULONG nControl
= pEditEngine
->GetControlWord();
594 aToolBox
.EnableItem( TB_UNDO
, (BOOL
)pEditEngine
->GetUndoManager().GetUndoActionCount() );
595 aToolBox
.EnableItem( TB_REDO
, (BOOL
)pEditEngine
->GetUndoManager().GetRedoActionCount() );
596 aToolBox
.EnableItem( TB_BINOBJ2b
, (BOOL
)(long)pBinObj
);
597 aToolBox
.EnableItem( TB_MOVE
, pEditEngine
->GetParagraphCount() > 3 );
598 aToolBox
.CheckItem( TB_ONLINESPELL
, nControl
& EE_CNTRL_ONLINESPELLING
? TRUE
: FALSE
);
599 aToolBox
.CheckItem( TB_AUTOCORRECT
, nControl
& EE_CNTRL_AUTOCORRECT
? TRUE
: FALSE
);
600 // aToolBox.CheckItem( TB_HYPH, nControl & EE_CNTRL_HYPHENATE ? TRUE : FALSE );
601 aToolBox
.CheckItem( TB_REDLINES
, nControl
& EE_CNTRL_NOREDLINES
? FALSE
: TRUE
);
602 aToolBox
.CheckItem( TB_STDSEL
, pEditView
->GetSelectionMode() == EE_SELMODE_STD
);
603 aToolBox
.CheckItem( TB_FLAT
, pEditEngine
->IsFlatMode() );
604 aToolBox
.CheckItem( TB_OUTL
, ( nControl
& EE_CNTRL_OUTLINER
) ? TRUE
: FALSE
);
605 aToolBox
.CheckItem( TB_POLY
, pEditEngine
->GetPolygon() ? TRUE
: FALSE
);
606 aToolBox
.CheckItem( TB_COLORS
, ( nControl
& EE_CNTRL_NOCOLORS
) ? FALSE
: TRUE
);
607 aToolBox
.CheckItem( TB_IDLE
, pEditEngine
->IsIdleFormatterEnabled() );
608 aToolBox
.CheckItem( TB_INSERT
, pEditView
->IsInsertMode() );
610 for ( USHORT nWhich
= EE_ITEMS_START
; nWhich
<= EE_ITEMS_END
; nWhich
++)
612 // if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF )
614 // else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_DONTCARE )
616 // else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_ON )
618 const SfxPoolItem
& rItem
= aCurSet
.Get( nWhich
);
621 case EE_PARA_HYPHENATE
:
622 aToolBox
.CheckItem( TB_HYPH
, ((SfxBoolItem
&)rItem
).GetValue() != 0 );
624 case EE_PARA_LRSPACE
:
625 aToolBox
.CheckItem( TB_LR
, ((SvxLRSpaceItem
&)rItem
).GetTxtLeft() != 0 );
627 case EE_PARA_ULSPACE
:
628 aToolBox
.CheckItem( TB_SBSA
, ((SvxULSpaceItem
&)rItem
).GetUpper() != 0 );
631 aToolBox
.CheckItem( TB_SBL
, ((SvxLineSpacingItem
&)rItem
).GetPropLineSpace() != 100 );
635 SvxAdjust e
= ((SvxAdjustItem
&)rItem
).GetAdjust();
636 aToolBox
.CheckItem( TB_LEFT
, e
== SVX_ADJUST_LEFT
);
637 aToolBox
.CheckItem( TB_RIGHT
, e
== SVX_ADJUST_RIGHT
);
638 aToolBox
.CheckItem( TB_CENTER
, e
== SVX_ADJUST_CENTER
);
639 aToolBox
.CheckItem( TB_BLOCK
, e
== SVX_ADJUST_BLOCK
);
646 Color
aColor( ((SvxColorItem
&)rItem
).GetValue() );
647 aToolBox
.CheckItem( TB_BLACK
, aColor
== COL_BLACK
);
648 aToolBox
.CheckItem( TB_GREEN
, aColor
== COL_GREEN
);
649 aToolBox
.CheckItem( TB_RED
, aColor
== COL_RED
);
652 case EE_CHAR_FONTINFO
:
654 FontFamily e
= ((SvxFontItem
&)rItem
).GetFamily();
655 aToolBox
.CheckItem( TB_FONT1
, e
== FAMILY_ROMAN
);
656 aToolBox
.CheckItem( TB_FONT2
, e
== FAMILY_SWISS
);
659 case EE_CHAR_FONTHEIGHT
:
663 FontWeight e
= ((SvxWeightItem
&)rItem
).GetWeight();
664 aToolBox
.CheckItem( TB_BOLD
, e
== WEIGHT_BOLD
);
667 case EE_CHAR_UNDERLINE
:
669 aToolBox
.CheckItem( TB_UNDERLINE
, ((SvxUnderlineItem
&)rItem
).GetLineStyle() );
674 aToolBox
.CheckItem( TB_WLM
, ((SvxWordLineModeItem
&)rItem
).GetValue() );
677 case EE_CHAR_PAIRKERNING
:
679 aToolBox
.CheckItem( TB_PKERN
, ((SvxAutoKernItem
&)rItem
).GetValue() );
682 case EE_CHAR_KERNING
:
684 aToolBox
.CheckItem( TB_KERN
, (BOOL
)((SvxKerningItem
&)rItem
).GetValue() );
687 case EE_CHAR_ESCAPEMENT
:
689 aToolBox
.CheckItem( TB_SUPER
, ((SvxEscapementItem
&)rItem
).GetEsc() > 0 );
690 aToolBox
.CheckItem( TB_SUB
, ((SvxEscapementItem
&)rItem
).GetEsc() < 0 );
693 case EE_CHAR_STRIKEOUT
:
697 FontItalic e
= ((SvxPostureItem
&)rItem
).GetPosture();
698 aToolBox
.CheckItem( TB_ITALIC
, e
== ITALIC_NORMAL
);
701 case EE_CHAR_OUTLINE
:
710 IMPL_LINK( EditMainWindow
, TBSelect
, ToolBox
*, p
)
712 EditView
* pEditView
= aViewWin
.GetEditView();
713 EditEngine
* pEditEngine
= pEditView
->GetEditEngine();
714 USHORT nId
= aToolBox
.GetCurItemId();
715 BOOL bChecked
= aToolBox
.IsItemChecked( nId
);
716 SfxPoolItem
* pNewItem
= 0;
719 case TB_LEFT
: pNewItem
= new SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
);
721 case TB_RIGHT
: pNewItem
= new SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
);
723 case TB_CENTER
: pNewItem
= new SvxAdjustItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
);
725 case TB_BLOCK
: pNewItem
= new SvxAdjustItem( SVX_ADJUST_BLOCK
, EE_PARA_JUST
);
727 case TB_HYPH
: pNewItem
= new SfxBoolItem( EE_PARA_HYPHENATE
, !bChecked
);
729 case TB_UNDO
: pEditView
->Undo();
730 pEditView
->ShowCursor();
732 case TB_REDO
: pEditView
->Redo();
733 pEditView
->ShowCursor();
735 case TB_ONLINESPELL
: {
736 ULONG nControl
= pEditView
->GetEditEngine()->GetControlWord();
738 nControl
= nControl
& ~EE_CNTRL_ONLINESPELLING
;
740 nControl
= nControl
| EE_CNTRL_ONLINESPELLING
;
741 pEditView
->GetEditEngine()->SetControlWord( nControl
);
745 ULONG nControl
= pEditView
->GetEditEngine()->GetControlWord();
747 nControl
= nControl
& ~EE_CNTRL_NOREDLINES
;
749 nControl
= nControl
| EE_CNTRL_NOREDLINES
;
750 pEditView
->GetEditEngine()->SetControlWord( nControl
);
753 case TB_AUTOCORRECT
: {
754 ULONG nControl
= pEditView
->GetEditEngine()->GetControlWord();
756 nControl
= nControl
& ~EE_CNTRL_AUTOCORRECT
;
758 nControl
= nControl
| EE_CNTRL_AUTOCORRECT
;
759 pEditView
->GetEditEngine()->SetControlWord( nControl
);
762 case TB_STDSEL
: if ( bChecked
)
763 pEditView
->SetSelectionMode( EE_SELMODE_TXTONLY
);
765 pEditView
->SetSelectionMode( EE_SELMODE_STD
);
767 case TB_FLAT
: pEditEngine
->SetFlatMode( !pEditEngine
->IsFlatMode() );
770 ULONG nControl
= pEditView
->GetEditEngine()->GetControlWord();
772 nControl
= nControl
| EE_CNTRL_NOCOLORS
;
774 nControl
= nControl
& ~EE_CNTRL_NOCOLORS
;
775 pEditView
->GetEditEngine()->SetControlWord( nControl
);
777 // aViewWin.Invalidate();
778 pEditView
->GetEditEngine()->Draw( pEditView
->GetWindow(), pEditView
->GetOutputArea(), pEditView
->GetVisArea().TopLeft() );
781 ULONG nControl
= pEditView
->GetEditEngine()->GetControlWord();
783 nControl
= nControl
| EE_CNTRL_OUTLINER
;
785 nControl
= nControl
& ~EE_CNTRL_OUTLINER
;
786 pEditView
->GetEditEngine()->SetControlWord( nControl
);
793 pEditView
->GetEditEngine()->ClearPolygon();
796 case TB_IDLE
: pEditEngine
->EnableIdleFormatter( !pEditEngine
->IsIdleFormatterEnabled() );
799 static BYTE nFld
= 0;
804 SvxFieldItem
aFld( SvxURLField( String( RTL_CONSTASCII_USTRINGPARAM( "www.mopo.de" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "Bla" ) ), SVXURLFORMAT_REPR
), EE_FEATURE_FIELD
);
805 pEditView
->InsertField( aFld
);
807 else if ( nFld
== 1 )
808 pEditView
->InsertField( SvxFieldItem( SvxURLField( String( RTL_CONSTASCII_USTRINGPARAM( "www.mopo.de" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "Morgenpost" ) ), SVXURLFORMAT_URL
), EE_FEATURE_FIELD
) );
809 else if ( nFld
== 2 )
810 pEditView
->InsertField( SvxFieldItem( SvxDateField( Date( 1,1,1995 ), SVXDATETYPE_FIX
, SVXDATEFORMAT_D
), EE_FEATURE_FIELD
) );
815 case TB_UPDFLD
: pEditEngine
->UpdateFields();
817 case TB_INSERT
: pEditView
->SetInsertMode( !pEditView
->IsInsertMode() );
819 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
);
821 case TB_FONT2
: pNewItem
= new SvxFontItem( FAMILY_SWISS
, String( RTL_CONSTASCII_USTRINGPARAM( "Helv" ) ), String(), PITCH_DONTKNOW
, RTL_TEXTENCODING_MS_1252
, EE_CHAR_FONTINFO
);
823 case TB_BOLD
: if ( bChecked
)
824 pNewItem
= new SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
);
826 pNewItem
= new SvxWeightItem( WEIGHT_BOLD
, EE_CHAR_WEIGHT
);
828 case TB_ITALIC
: if ( bChecked
)
829 pNewItem
= new SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
);
831 pNewItem
= new SvxPostureItem( ITALIC_NORMAL
, EE_CHAR_ITALIC
);
833 case TB_UNDERLINE
: if ( bChecked
)
834 pNewItem
= new SvxUnderlineItem( UNDERLINE_NONE
, EE_CHAR_UNDERLINE
);
836 pNewItem
= new SvxUnderlineItem( UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
);
838 case TB_WLM
: pNewItem
= new SvxWordLineModeItem( !bChecked
, EE_CHAR_WLM
);
840 case TB_PKERN
: pNewItem
= new SvxAutoKernItem( !bChecked
, EE_CHAR_PAIRKERNING
);
842 case TB_KERN
: if ( bChecked
)
843 pNewItem
= new SvxKerningItem( 0, EE_CHAR_KERNING
);
845 pNewItem
= new SvxKerningItem( 100, EE_CHAR_KERNING
);
847 case TB_SUPER
: if ( bChecked
)
848 pNewItem
= new SvxEscapementItem( SVX_ESCAPEMENT_OFF
, EE_CHAR_ESCAPEMENT
);
850 // pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT);
851 pNewItem
= new SvxEscapementItem( 50, 100, EE_CHAR_ESCAPEMENT
);
853 case TB_SUB
: if ( bChecked
)
854 pNewItem
= new SvxEscapementItem( SVX_ESCAPEMENT_OFF
, EE_CHAR_ESCAPEMENT
);
856 // pNewItem = new SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT);
857 pNewItem
= new SvxEscapementItem( -50, 100, EE_CHAR_ESCAPEMENT
);
859 case TB_GREEN
: pNewItem
= new SvxColorItem( Color(COL_GREEN
), EE_CHAR_COLOR
);
861 case TB_RED
: pNewItem
= new SvxColorItem( Color(COL_RED
), EE_CHAR_COLOR
);
863 case TB_BLACK
: pNewItem
= new SvxColorItem( Color(COL_BLACK
), EE_CHAR_COLOR
);
865 case TB_SBL
: pNewItem
= new SvxLineSpacingItem( 0, EE_PARA_SBL
);
868 ((SvxLineSpacingItem
*)pNewItem
)->SetInterLineSpace( 0 );
872 ((SvxLineSpacingItem
*)pNewItem
)->SetPropLineSpace( 150 );
875 case TB_SBSA
: pNewItem
= new SvxULSpaceItem( EE_PARA_ULSPACE
);
878 ((SvxULSpaceItem
*)pNewItem
)->SetUpper( 400 );
879 ((SvxULSpaceItem
*)pNewItem
)->SetLower( 400 );
882 case TB_LR
: pNewItem
= new SvxLRSpaceItem( EE_PARA_LRSPACE
);
885 ((SvxLRSpaceItem
*)pNewItem
)->SetTxtLeft( 1000 );
886 ((SvxLRSpaceItem
*)pNewItem
)->SetTxtFirstLineOfst( -500 );
887 ((SvxLRSpaceItem
*)pNewItem
)->SetRight( 500 );
890 case TB_DEFTAB
: if ( bChecked
)
891 pEditEngine
->SetDefTab( 2000 );
893 pEditEngine
->SetDefTab( 600 );
894 pEditView
->ShowCursor();
895 aToolBox
.CheckItem( nId
, !bChecked
);
898 pTmpWindow
->SetMapMode( aViewWin
.GetMapMode() );
899 pTmpWindow
->SetBackgroundBrush( Brush( Color( COL_GRAY
) ) );
900 pTmpWindow
->SetFillInBrush( Brush( Color( COL_LIGHTGRAY
) ) );
902 pTmpWindow
->Invalidate();
903 pTmpWindow
->Update();
904 pTmpWindow
->DrawText( Point( 20, 20 ), String( RTL_CONSTASCII_USTRINGPARAM( "It's a Test..." ) ) );
905 Rectangle
aRect( Point( 500, 500 ), Size( 10000, 4000 ) );
906 pTmpWindow
->DrawRect( aRect
);
907 pEditEngine
->Draw( pTmpWindow
, aRect
, Point( 0, 0 ) );
913 if ( nRotation
== 3600 )
915 pTmpWindow
->SetMapMode( aViewWin
.GetMapMode() );
916 pTmpWindow
->SetBackgroundBrush( Brush( Color( COL_LIGHTGRAY
) ) );
917 pTmpWindow
->SetFillInBrush( Brush( Color( COL_LIGHTGRAY
) ) );
919 pTmpWindow
->Invalidate();
920 pTmpWindow
->Update();
921 pTmpWindow
->DrawText( Point( 20, 20 ), String( RTL_CONSTASCII_USTRINGPARAM( "It's a Test..." ) ) );
922 Rectangle
aRect( Point( 500, 500 ), Size( 10000, 4000 ) );
923 pEditEngine
->Draw( pTmpWindow
, Point( 2000, 4000 ), nRotation
);
929 ESelection aESel
= pEditView
->GetSelection();
930 USHORT nStartPara
= Min( aESel
.nStartPara
, aESel
.nEndPara
);
931 USHORT nEndPara
= Max( aESel
.nStartPara
, aESel
.nEndPara
);
932 pEditView
->MoveParagraphs( Range(nStartPara
,nEndPara
), 2 );
937 pEditEngine
->SetUpdateMode( FALSE
);
939 SfxItemSet
aSet( pEditEngine
->GetEmptyItemSet() );
940 aSet
.Put( SvxFontItem( FAMILY_DECORATIVE
, String( RTL_CONSTASCII_USTRINGPARAM( "StarBats" ) ), String(),PITCH_DONTKNOW
, RTL_TEXTENCODING_MS_1252
, EE_CHAR_FONTINFO
) );
941 aSet
.Put( SvxColorItem( Color(COL_MAGENTA
), EE_CHAR_COLOR
) );
942 aSet
.Put( SvxFontHeightItem(600, 100, EE_CHAR_FONTHEIGHT
) );
943 aSet
.Put( SvxPostureItem( ITALIC_NORMAL
, EE_CHAR_ITALIC
) );
944 aSet
.Put( SvxLRSpaceItem( 0, 0, 1000, 0, EE_PARA_LRSPACE
) );
945 pEditView
->SetParaAttribs( aSet
, nPara
);
946 pEditEngine
->SetUpdateMode( TRUE
);
947 pEditView
->ShowCursor();
953 pBinObj
= pEditEngine
->CreateTextObject();
959 pBinObj
= pEditView
->CreateTextObject();
966 EditTextObject
* p
= pBinObj
->Clone();
976 pEditView
->InsertText( *pBinObj
);
982 if ( !pFileDialogBox2
->Execute() )
984 DirEntry
aDirEntry( pFileDialogBox2
->GetPath() );
985 SvFileStream
aStrm( aDirEntry
.GetFull(), STREAM_WRITE
| STREAM_TRUNC
);
986 EditTextObject
* pTmpObj
= pEditEngine
->CreateTextObject();
987 pTmpObj
->Store( aStrm
);
988 DBG_ASSERT( !aStrm
.GetError(), "Store: Error!" );
994 if ( !pFileDialogBox
->Execute() )
996 DirEntry
aDirEntry( pFileDialogBox
->GetPath() );
997 SvFileStream
aStrm( aDirEntry
.GetFull(), STREAM_READ
);
999 pBinObj
= EditTextObject::Create( aStrm
);
1000 // EditTextObject* pTmpObj = pEditEngine->CreateTextObject( aStrm );
1001 // pEditEngine->SetText( *pTmpObj );
1002 // pEditView->ShowCursor();
1009 if ( !pFileDialogBox
->Execute() )
1011 DirEntry
aDirEntry( pFileDialogBox
->GetPath() );
1013 String
aFileName( aDirEntry
.GetFull() );
1014 SvFileStream
aStrm( aFileName
, STREAM_READ
);
1015 if ( aStrm
.GetError() )
1016 InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "StreamError!" ) ) ).Execute();
1017 Application::EnterWait();
1018 if ( nId
== TB_OPEN
)
1020 if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) )
1021 pEditEngine
->Read( aStrm
, EE_FORMAT_RTF
);
1022 if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1023 pEditEngine
->Read( aStrm
, EE_FORMAT_HTML
);
1024 if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1025 pEditEngine
->Read( aStrm
, EE_FORMAT_HTML
);
1026 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1027 pEditEngine
->Read( aStrm
, EE_FORMAT_BIN
);
1029 pEditEngine
->Read( aStrm
, EE_FORMAT_TEXT
);
1031 pEditView
->ShowCursor();
1035 if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) )
1036 pEditView
->Read( aStrm
, EE_FORMAT_RTF
);
1037 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1038 pEditView
->Read( aStrm
, EE_FORMAT_BIN
);
1039 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1040 pEditView
->Read( aStrm
, EE_FORMAT_HTML
);
1041 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1042 pEditView
->Read( aStrm
, EE_FORMAT_HTML
);
1044 pEditView
->Read( aStrm
, EE_FORMAT_TEXT
);
1047 Application::LeaveWait();
1053 pPrinter
->SetPageQueueSize( 1 );
1054 PrintDialog
aPrnDlg( this );
1055 aPrnDlg
.SetPrinter( pPrinter
);
1056 if ( aPrnDlg
.Execute() )
1058 pPrinter
->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "SvEdit - PrinterTest" ) ) );
1059 pPrinter
->StartPage();
1060 Size
aSz( pEditEngine
->CalcTextWidth(), pEditEngine
->GetTextHeight() );
1061 Pen
aPen( PEN_SOLID
);
1062 aPen
.SetColor( Color( COL_BLACK
) );
1063 pPrinter
->SetPen( aPen
);
1064 Rectangle
aR( Point( 2000, 4000 ), aSz
);
1065 pPrinter
->DrawRect( aR
);
1066 // So folgt auf IIISi, 75DPI kein Ausdruck!
1067 // pPrinter->SetClipRegion( Region( aR ) );
1068 pEditEngine
->Draw( pPrinter
, Point( 2000, 4000 ), nRotation
);
1069 // pPrinter->SetClipRegion();
1070 pPrinter
->EndPage();
1078 if ( !pFileDialogBox2
->Execute() )
1080 DirEntry
aDirEntry( pFileDialogBox2
->GetPath() );
1081 // DirEntry aDirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\xxx.rtf" ) ) );
1082 SvFileStream
aStrm( aDirEntry
.GetFull(), STREAM_WRITE
| STREAM_TRUNC
);
1083 Application::EnterWait();
1084 if ( nId
== TB_SAVE
)
1086 if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "rtf") )
1087 pEditEngine
->Write( aStrm
, EE_FORMAT_RTF
);
1088 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1089 pEditEngine
->Write( aStrm
, EE_FORMAT_BIN
);
1090 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1091 pEditEngine
->Write( aStrm
, EE_FORMAT_HTML
);
1092 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1093 pEditEngine
->Write( aStrm
, EE_FORMAT_HTML
);
1095 pEditEngine
->Write( aStrm
, EE_FORMAT_TEXT
);
1099 if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "rtf" ) )
1100 pEditView
->Write( aStrm
, EE_FORMAT_RTF
);
1101 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "bin" ) )
1102 pEditView
->Write( aStrm
, EE_FORMAT_BIN
);
1103 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "html" ) )
1104 pEditView
->Write( aStrm
, EE_FORMAT_HTML
);
1105 else if ( aDirEntry
.GetExtension().EqualsIgnoreCaseAscii( "htm" ) )
1106 pEditView
->Write( aStrm
, EE_FORMAT_HTML
);
1108 pEditView
->Write( aStrm
, EE_FORMAT_TEXT
);
1110 Application::LeaveWait();
1115 SfxItemSet aCurSet
= pEditView
->GetAttribs();
1116 XubString
aDebStr( String( RTL_CONSTASCII_USTRINGPARAM( "Attribute in Selektion:" ) ) );
1117 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "\nVorlage:" ) );
1119 // pEditView->GetStyleSheet( aStyle, eFam );
1121 for ( USHORT nWhich
= EE_ITEMS_START
; nWhich
<= EE_ITEMS_END
; nWhich
++)
1123 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "\n" ) );
1124 aDebStr
+= String::CreateFromInt32( nWhich
);
1125 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "\t" ) );
1126 if ( aCurSet
.GetItemState( nWhich
) == SFX_ITEM_OFF
)
1127 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "---" ) );
1128 else if ( aCurSet
.GetItemState( nWhich
) == SFX_ITEM_DONTCARE
)
1129 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "XXX" ) );
1130 else if ( aCurSet
.GetItemState( nWhich
) == SFX_ITEM_ON
)
1132 const SfxPoolItem
& rItem
= aCurSet
.Get( nWhich
);
1135 case EE_PARA_LRSPACE
:
1136 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "FI=" ) );
1137 aDebStr
+= String::CreateFromInt32( ((SvxLRSpaceItem
&)rItem
).GetTxtFirstLineOfst() );
1138 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( ", LI=" ) );
1139 aDebStr
+= String::CreateFromInt32( ((SvxLRSpaceItem
&)rItem
).GetTxtLeft() );
1140 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( ", RI=" ) );
1141 aDebStr
+= String::CreateFromInt32( ((SvxLRSpaceItem
&)rItem
).GetRight() );
1143 case EE_PARA_ULSPACE
:
1144 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "SB=" ) );
1145 aDebStr
+= String::CreateFromInt32( ((SvxULSpaceItem
&)rItem
).GetUpper() );
1146 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( ", SA=" ) );
1147 aDebStr
+= String::CreateFromInt32( ((SvxULSpaceItem
&)rItem
).GetLower() );
1150 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "SBL=" ) );
1151 aDebStr
+= String::CreateFromInt32( ((SvxLineSpacingItem
&)rItem
).GetInterLineSpace() );
1154 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "SvxAdust=" ) );
1155 aDebStr
+= String::CreateFromInt32( (USHORT
)((SvxAdjustItem
&)rItem
).GetAdjust() );
1158 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "Tabs = ?" ) );
1162 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "Color= " ) );
1163 Color
aColor( ((SvxColorItem
&)rItem
).GetValue() );
1164 aDebStr
+= String::CreateFromInt32( aColor
.GetRed() );
1165 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
1166 aDebStr
+= String::CreateFromInt32( aColor
.GetGreen() );
1167 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
1168 aDebStr
+= String::CreateFromInt32( aColor
.GetBlue() );
1171 case EE_CHAR_FONTINFO
:
1172 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "Font=" ) );
1173 aDebStr
+= ((SvxFontItem
&)rItem
).GetFamilyName();
1175 case EE_CHAR_FONTHEIGHT
:
1176 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "Groesse=" ) );
1177 aDebStr
+= String::CreateFromInt32( ((SvxFontHeightItem
&)rItem
).GetHeight() );
1179 case EE_CHAR_WEIGHT
:
1180 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "FontWeight=" ) );
1181 aDebStr
+= String::CreateFromInt32( ((SvxWeightItem
&)rItem
).GetWeight() );
1183 case EE_CHAR_UNDERLINE
:
1184 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline=" ) );
1185 aDebStr
+= String::CreateFromInt32( ((SvxUnderlineItem
&)rItem
).GetLineStyle() );
1188 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "WordLineMode=" ) );
1189 aDebStr
+= String::CreateFromInt32( ((SvxWordLineModeItem
&)rItem
).GetValue() );
1191 case EE_CHAR_STRIKEOUT
:
1192 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout=" ) );
1193 aDebStr
+= String::CreateFromInt32( ((SvxCrossedOutItem
&)rItem
).GetStrikeout() );
1195 case EE_CHAR_ITALIC
:
1196 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "FontPosture=" ) );
1197 aDebStr
+= String::CreateFromInt32( ((SvxPostureItem
&)rItem
).GetPosture() );
1199 case EE_CHAR_OUTLINE
:
1200 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "FontOutline=" ) );
1201 aDebStr
+= String::CreateFromInt32( ((SvxContourItem
&)rItem
).GetValue() );
1203 case EE_CHAR_SHADOW
:
1204 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "FontShadowed=" ) );
1205 aDebStr
+= String::CreateFromInt32( ((SvxShadowedItem
&)rItem
).GetValue() );
1210 aDebStr
+= String( RTL_CONSTASCII_USTRINGPARAM( "?" ) );
1212 InfoBox( 0, aDebStr
).Execute();
1219 SfxItemSet aSet
= pEditView
->GetEmptyItemSet();
1220 aSet
.Put( *pNewItem
);
1221 pEditView
->SetAttribs( aSet
);
1228 void EditMainWindow::CreatePolygon()
1230 EditView
* pEditView
= aViewWin
.GetEditView();
1231 Size aSz
= pEditView
->GetWindow()->GetOutputSize();
1232 Point
aOffset( aSz
.Width()/8, aSz
.Height()/8 );
1238 aPoly
.SetPoint( Point( aSz
.Width()/2, 0 ), 0 );
1239 aPoly
.SetPoint( Point( aSz
.Width(), aSz
.Height()/3 ), 1 );
1240 aPoly
.SetPoint( Point( aSz
.Width()/2, aSz
.Height() ), 2 );
1241 aPoly
.SetPoint( Point( 0, aSz
.Height()/2 ), 3 );
1242 aPoly
.SetPoint( Point( aSz
.Width()/2, 0 ), 4 );
1243 PolyPolygon
aPPoly( aPoly
);
1244 pEditView
->GetEditEngine()->SetPolygon( aPPoly
);
1245 pEditView
->SetOutputArea( Rectangle( aOffset
, aSz
) );
1246 ULONG nWord
= pEditView
->GetControlWord();
1247 nWord
&= ~(EV_CNTRL_AUTOSCROLL
);
1248 pEditView
->SetControlWord( nWord
);
1249 aViewWin
.Invalidate();
1252 void __EXPORT
EditMainWindow::GetFocus()
1254 aViewWin
.GrabFocus();
1257 IMPL_LINK_INLINE_START( EditMainWindow
, HScrollHdl
, ScrollBar
*, pScrl
)
1259 EditView
* pEditView
= aViewWin
.GetEditView();
1260 pEditView
->Scroll( -pScrl
->GetDelta(), 0, RGCHK_PAPERSZ1
);
1263 IMPL_LINK_INLINE_END( EditMainWindow
, HScrollHdl
, ScrollBar
*, pScrl
)
1265 IMPL_LINK_INLINE_START( EditMainWindow
, VScrollHdl
, ScrollBar
*, pScrl
)
1267 EditView
* pEditView
= aViewWin
.GetEditView();
1268 pEditView
->Scroll( 0, -pScrl
->GetDelta(), RGCHK_PAPERSZ1
);
1271 IMPL_LINK_INLINE_END( EditMainWindow
, VScrollHdl
, ScrollBar
*, pScrl
)
1273 void EditMainWindow::SetScrollBarRanges()
1275 EditView
* pEditView
= aViewWin
.GetEditView();
1276 long y
= pEditView
->GetEditEngine()->GetTextHeight();
1277 long x
= pEditView
->GetEditEngine()->GetPaperSize().Width();
1279 aHScrollBar
.SetRange( Range( 0, x
) );
1280 aVScrollBar
.SetRange( Range( 0, y
) );
1283 void EditMainWindow::SetScrollBars()
1285 EditView
* pEditView
= aViewWin
.GetEditView();
1286 Size aSz
= GetOutputSizePixel();
1287 Size
aRealSz( aSz
);
1288 long nScrollbarWidthPixel
= aVScrollBar
.GetSizePixel().Width();
1289 long nTBHeight
= aToolBox
.GetSizePixel().Height();
1290 aSz
.Height() -= nTBHeight
;
1295 Point
aPoint( ( aSz
.Width()- nScrollbarWidthPixel
+1 ), -1+nTBHeight
);
1296 aSz
.Width() = nScrollbarWidthPixel
;
1297 aVScrollBar
.SetPosSizePixel( aPoint
, aSz
);
1301 Point
aPoint2( 0, aRealSz
.Height()-aHScrollBar
.GetSizePixel().Height()+1 ); // TB-Height schon drin!
1302 aSz
.Width() -= aVScrollBar
.GetSizePixel().Width();
1305 aSz
.Height() = nScrollbarWidthPixel
;
1306 aHScrollBar
.SetPosSizePixel( aPoint2
, aSz
);
1308 aHScrollBar
.SetVisibleSize( pEditView
->GetOutputArea().GetWidth() );
1309 aVScrollBar
.SetVisibleSize( pEditView
->GetOutputArea().GetHeight() );
1311 SetScrollBarRanges();
1317 void __EXPORT
EditMainWindow::Resize()
1319 long nBorder
= aVScrollBar
.GetSizePixel().Width();
1321 Size aTBSz
= aToolBox
.CalcWindowSizePixel();
1322 Size
aOutSzPixel( GetOutputSizePixel() );
1323 aToolBox
.SetSizePixel( Size( aOutSzPixel
.Width(), aTBSz
.Height()) );
1325 aViewWin
.SetSizePixel( Size( aOutSzPixel
.Width()-nBorder
-2*nExtra
, aOutSzPixel
.Height()-aTBSz
.Height()-2*nExtra
-nBorder
) );
1327 aViewWin
.SetPosPixel( Point( nExtra
, aTBSz
.Height()+nExtra
) );
1331 EditView
* pEditView
= aViewWin
.GetEditView();
1332 if ( pEditView
&& pEditView
->GetEditEngine()->GetPolygon() )
1336 IMPL_LINK( EditMainWindow
, ShowStatus
, EditStatus
*, pStat
)
1338 EditView
* pEditView
= aViewWin
.GetEditView();
1339 EditEngine
* pEditEngine
= pEditView
->GetEditEngine();
1340 if ( ( pStat
->GetStatusWord() & EE_STAT_TEXTWIDTHCHANGED
) || ( pStat
->GetStatusWord() & EE_STAT_TEXTHEIGHTCHANGED
) )
1342 aViewWin
.MarkOutputArea();
1343 if ( pEditEngine
->GetTextHeight() < (ULONG
)pEditView
->GetOutputArea().GetHeight() )
1345 // Wird durch RGCHK_PAPERSZ1 'geklippt'
1346 if ( !( pEditEngine
->GetControlWord() & EE_CNTRL_AUTOPAGESIZE
) )
1347 pEditView
->Scroll( -(long)pEditEngine
->CalcTextWidth(), -(long)pEditEngine
->GetTextHeight(), RGCHK_PAPERSZ1
);
1349 SetScrollBarRanges();
1351 if ( pStat
->GetStatusWord() & EE_STAT_HSCROLL
)
1352 aHScrollBar
.SetThumbPos( pEditView
->GetVisArea().Left() );
1353 if ( pStat
->GetStatusWord() & EE_STAT_VSCROLL
)
1354 aVScrollBar
.SetThumbPos( pEditView
->GetVisArea().Top() );
1360 EditViewWindow::~EditViewWindow()
1362 pEditEngine
->RemoveView( pEditView
);
1364 // Beim Zerstoeren der Styles am Ende, EditEngine noch nicht kaputt,
1365 // wird der Handler gerufen, ich zerstore hier aber schon die View!
1366 pEditEngine
->SetStatusEventHdl( Link() );
1367 // SvxAutoCorrect* pAutoCorrekt = pEditEngine->GetAutoCorrect();
1368 // pEditEngine->SetAutoCorrect( 0 );
1369 // delete pAutoCorrekt;
1373 EditViewWindow::EditViewWindow( Window
* pParent
) :
1374 Window( pParent
), aURLPtr( POINTER_HAND
)
1376 SetBackgroundBrush( Brush( Color( COL_WHITE
) ) );
1377 SetMapMode( MAP_100TH_MM
);
1380 SfxItemPool
* pPool
= EditEngine::CreatePool();
1381 Font aFont
= GetSettings().GetStyleSettings().GetAppFont();
1382 MapMode
aPntMode( MAP_POINT
);
1383 MapMode
aCurrent( GetMapMode() );
1384 Size
aSz( LogicToLogic( Size( 12, 0 ), &aPntMode
, &aCurrent
) );
1385 aFont
.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) ) );
1386 pPool
->SetPoolDefaultItem( SvxFontItem( aFont
.GetFamily(), aFont
.GetName(), String(),aFont
.GetPitch(), aFont
.GetCharSet(), EE_CHAR_FONTINFO
) );
1387 pPool
->SetPoolDefaultItem( SvxFontHeightItem( aSz
.Width(), 100, EE_CHAR_FONTHEIGHT
) );
1388 pEditEngine
= new MyEditEngine( pPool
);
1390 Size
aPaperSz( 10000,8000 );
1391 pEditEngine
->SetPaperSize( aPaperSz
);
1393 pEditView
= new EditView( pEditEngine
, this );
1394 pEditView
->SetBackgroundColor( Color( COL_WHITE
) );
1395 pEditView
->SetOutputArea( Rectangle( Point( 100, 100 ), aPaperSz
) );
1396 pEditEngine
->SetDefaultLanguage( LANGUAGE_ENGLISH
);
1397 pEditEngine
->InsertView( pEditView
);
1399 SetPosSizePixel( Point( 10, 10 ), Size( 600, 400 ) );
1403 // Feldbefehle grau hinterlegen
1404 ULONG n
= pEditEngine
->GetControlWord();
1405 n
= n
| (EE_CNTRL_MARKFIELDS
|EE_CNTRL_AUTOCOMPLETE
);
1406 pEditEngine
->SetControlWord( n
);
1408 // Test: Autozentrierung
1409 // ULONG n = pEditEngine->GetControlWord();
1410 // n = n | EE_CNTRL_AUTOPAGESIZE;
1411 // pEditEngine->SetControlWord( n );
1415 // pEditEngine->CreateSpeller( DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "n:\\offenv\\wnti" ) ) ),
1416 // DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "n:\\offenv\\wnti" ) ) ) );
1417 // pEditEngine->GetSpeller()->SetActualLanguage( LANGUAGE_GERMAN );
1418 // pEditEngine->GetSpeller()->SetDefaultLanguage( LANGUAGE_GERMAN );
1419 // pEditEngine->GetSpeller()->SetMinTrail( 2 );
1421 // AutoCorrect wird nie zerstoert
1422 // pEditEngine->SetAutoCorrect( new SvxAutoCorrect( String( RTL_CONSTASCII_USTRINGPARAM( "d:\\prj\\office\\autotext\\autocorr.dat" ) ) ) );
1426 void __EXPORT
EditViewWindow::Paint( const Rectangle
& rRec
)
1428 if ( pEditView
->GetEditEngine()->GetPolygon() )
1430 // Die Punkte des Polygons beziehen sich auf die View...
1431 MapMode
aMapMode( GetMapMode() );
1432 aMapMode
.SetOrigin( pEditView
->GetOutputArea().TopLeft() );
1433 SetMapMode( aMapMode
);
1434 DrawPolyPolygon( *pEditView
->GetEditEngine()->GetPolygon() );
1435 aMapMode
.SetOrigin( Point() );
1436 SetMapMode( aMapMode
);
1438 pEditView
->Paint( rRec
);
1442 void EditViewWindow::MarkOutputArea()
1444 static Rectangle aCurFrame
;
1445 Rectangle
aOutArea( pEditView
->GetOutputArea() );
1446 aOutArea
= LogicToPixel( aOutArea
);
1450 aOutArea
.Bottom()++;
1451 aOutArea
= PixelToLogic( aOutArea
);
1452 SetPen( Pen( Color( COL_RED
) ) );
1453 SetFillInBrush( Brush( BRUSH_NULL
) );
1454 DrawRect( aOutArea
);
1455 if ( !aCurFrame
.IsEmpty() )
1457 if ( aCurFrame
.Left() < aOutArea
.Left() )
1458 Invalidate( Rectangle( aCurFrame
.TopLeft(), Size( aOutArea
.Left()-aCurFrame
.Left(), aCurFrame
.GetHeight() ) ) );
1459 if ( aCurFrame
.Right() > aOutArea
.Right() )
1461 long nW
= aCurFrame
.Right() - aOutArea
.Right();
1462 Point
aPos( aCurFrame
.TopRight() );
1464 Invalidate( Rectangle( aPos
, Size( nW
, aCurFrame
.GetHeight() ) ) );
1466 if ( aCurFrame
.Top() < aOutArea
.Top() )
1467 Invalidate( Rectangle( aCurFrame
.TopLeft(), Size( aCurFrame
.GetWidth(), aOutArea
.Top() - aCurFrame
.Top() ) ) );
1468 if ( aCurFrame
.Bottom() > aOutArea
.Bottom() )
1470 long nH
= aCurFrame
.Bottom() - aOutArea
.Bottom();
1471 Point
aPos( aCurFrame
.BottomLeft() );
1473 Invalidate( Rectangle( aPos
, Size( aCurFrame
.GetWidth(), nH
) ) );
1476 aCurFrame
= aOutArea
;
1479 void __EXPORT
EditViewWindow::Resize()
1481 Size
aPaperSz( GetOutputSize() );
1482 pEditView
->SetOutputArea( Rectangle( Point(0,0), aPaperSz
) );
1483 pEditEngine
->SetPaperSize( Size( aPaperSz
.Width()*1, aPaperSz
.Height()*1 ) );
1484 pEditView
->ShowCursor();
1488 void __EXPORT
EditViewWindow::KeyInput( const KeyEvent
& rKEvt
)
1490 sal_Unicode nCharCode
= rKEvt
.GetCharCode();
1492 USHORT nCode
= rKEvt
.GetKeyCode().GetCode();
1493 // Auswertung fuer besondere Einstellungen....
1494 if ( ( nCode
== KEY_A
) && rKEvt
.GetKeyCode().IsMod1() )
1495 pEditView
->SetSelection( ESelection( 0, 0, 0xFFFF, 0xFFFF ) );
1496 else if ( ( nCode
== KEY_R
) && rKEvt
.GetKeyCode().IsMod2() )
1498 else if ( ( nCode
== KEY_L
) && rKEvt
.GetKeyCode().IsMod2() )
1500 ULONG n
= pEditEngine
->GetControlWord();
1501 n
= n
| EE_CNTRL_ONECHARPERLINE
;
1502 pEditEngine
->SetControlWord( n
);
1503 pEditEngine
->QuickFormatDoc();
1505 else if ( ( nCode
== KEY_Z
) && rKEvt
.GetKeyCode().IsMod2() )
1507 pEditView
->RemoveAttribs();
1509 else if ( ( nCode
== KEY_V
) && rKEvt
.GetKeyCode().IsMod2() )
1511 pEditEngine
->SetVertical( TRUE
);
1514 else if ( ( ( nCode
== KEY_ADD
) || ( nCode
== KEY_SUBTRACT
) )&& rKEvt
.GetKeyCode().IsMod2() )
1516 short nDiff
= ( nCode
== KEY_ADD
) ? (+5) : (-5);
1521 if ( ( nZoom
+ nDiff
) > 0 )
1523 MapMode
aMapMode( MAP_100TH_MM
, Point(0,0), Fraction(nZoom
,100), Fraction(nZoom
,100) );
1524 SetMapMode( aMapMode
);
1525 ((EditMainWindow
*)GetParent())->SetTitle();
1527 if ( rKEvt
.GetKeyCode().IsMod1() )
1529 InfoBox( 0, String( RTL_CONSTASCII_USTRINGPARAM( "ChangingRefMapMode..." ) ) ).Execute();
1530 pEditEngine
->SetRefMapMode( aMapMode
);
1534 else if ( rKEvt
.GetKeyCode().IsMod2() &&
1535 ( ( nCode
== KEY_UP
) || ( nCode
== KEY_DOWN
) ||
1536 ( nCode
== KEY_LEFT
) || ( nCode
== KEY_RIGHT
) ) )
1538 if( rKEvt
.GetKeyCode().IsMod1() )
1540 ULONG nCtrl
= pEditEngine
->GetControlWord();
1541 if ( ! ( nCtrl
& EE_CNTRL_STRETCHING
) )
1543 nCtrl
|= EE_CNTRL_STRETCHING
;
1544 pEditEngine
->SetControlWord( nCtrl
);
1547 pEditEngine
->GetGlobalCharStretching( nX
, nY
);
1548 if ( ( nCode
== KEY_DOWN
) && ( nY
> 5 ) )
1550 else if ( nCode
== KEY_UP
)
1552 else if ( nCode
== KEY_RIGHT
)
1554 else if ( ( nCode
== KEY_LEFT
) && ( nX
> 5 ) )
1556 pEditEngine
->SetGlobalCharStretching( nX
, nY
);
1557 ((EditMainWindow
*)GetParent())->SetTitle();
1561 SfxItemSet
aAttrs( pEditView
->GetAttribs() );
1562 SfxItemSet
aNewAttrs( pEditEngine
->GetEmptyItemSet() );
1563 const SvxFontWidthItem
& rItem
= (const SvxFontWidthItem
&)aAttrs
.Get( EE_CHAR_FONTWIDTH
);
1564 USHORT nProp
= rItem
.GetProp();
1565 if ( nCode
== KEY_RIGHT
)
1567 else if ( ( nCode
== KEY_LEFT
) && ( nProp
> 5 ) )
1569 aNewAttrs
.Put( SvxFontWidthItem( 0, nProp
, EE_CHAR_FONTWIDTH
) );
1570 pEditView
->SetAttribs( aNewAttrs
);
1573 else if ( ( nCode
== KEY_O
) && rKEvt
.GetKeyCode().IsMod2() )
1575 MapMode
aMapMode( GetMapMode() );
1576 aMapMode
.SetOrigin( Point( 41, 41 ) );
1577 SetMapMode( aMapMode
);
1580 else if ( ( nCode
== KEY_B
) && rKEvt
.GetKeyCode().IsMod2() )
1582 SfxItemSet aSet
= pEditView
->GetEmptyItemSet();
1583 aSet
.Put( SvxFontHeightItem(800, 100, EE_CHAR_FONTHEIGHT
) );
1584 pEditView
->SetAttribs( aSet
);
1586 else if ( ( nCode
== KEY_P
) && rKEvt
.GetKeyCode().IsMod2() )
1588 // ESelection aSel = pEditView->GetSelection();
1589 // for ( ULONG n = aSel.nStartPara; n <= aSel.nEndPara; n++ )
1591 // InfoBox( 0, pEditEngine->GetText( n ) ).Execute();
1593 InfoBox( 0, pEditView
->GetSelected() ).Execute();
1596 else if ( rKEvt
.GetKeyCode().IsMod2() &&
1597 ( nCode
>= KEY_1
) && ( nCode
<= KEY_9
) )
1599 ULONG nEECtrl
= pEditEngine
->GetControlWord();
1600 nEECtrl
= nEECtrl
| EE_CNTRL_AUTOPAGESIZE
;
1601 pEditEngine
->SetControlWord( nEECtrl
);
1603 ULONG nEVCtrl
= pEditView
->GetControlWord();
1604 nEVCtrl
|= EV_CNTRL_AUTOSIZE
;
1605 pEditView
->SetControlWord( nEVCtrl
);
1607 pEditView
->SetAnchorMode( (EVAnchorMode
)(nCode
-KEY_1
) );
1608 pEditView
->SetOutputArea( Rectangle( Point(0,0), GetOutputSize() ) );
1609 pEditEngine
->SetMaxAutoPaperSize( GetOutputSize() );
1610 pEditEngine
->SetPaperSize( Size( 0, 0 ) );
1612 else if ( rKEvt
.GetKeyCode().IsMod2() && ( nCode
== KEY_0
) )
1614 ULONG nEVCtrl
= pEditView
->GetControlWord();
1615 nEVCtrl
= nEVCtrl
| EV_CNTRL_AUTOSIZE
;
1616 pEditView
->SetControlWord( nEVCtrl
);
1618 Size
aOutSz( GetOutputSize() );
1619 Size
aPaperSz( aOutSz
.Width() / 2, 0 );
1620 pEditView
->SetOutputArea( Rectangle( Point(), aPaperSz
) );
1621 pEditEngine
->SetPaperSize( aPaperSz
);
1622 // Max-Height wird bei View verwendet,
1623 // MinSize/MaxSize nur, wenn AUTOPAGESIZE ( KEY_1 - KEY_9 )
1624 pEditEngine
->SetMaxAutoPaperSize( Size( aOutSz
.Width() / 2, aOutSz
.Height() / 2 ) );
1625 pEditEngine
->SetMinAutoPaperSize( Size( aOutSz
.Width() / 8, aOutSz
.Height() / 8 ) );
1627 else if ( ( nCode
== KEY_J
) && rKEvt
.GetKeyCode().IsMod2() )
1629 Size
aTextSz( pEditEngine
->CalcTextWidth(), pEditEngine
->GetTextHeight() );
1630 Rectangle
aRect( pEditView
->GetOutputArea().TopLeft(), aTextSz
);
1631 Brush
aTmpBrush( Color( COL_LIGHTBLUE
), BRUSH_25
);
1632 Brush
aOldBrush( GetFillInBrush() );
1633 SetFillInBrush( aTmpBrush
);
1635 SetFillInBrush( aOldBrush
);
1636 pEditView
->Paint( aRect
);
1638 else if ( ( nCode
== KEY_H
) && rKEvt
.GetKeyCode().IsMod2() )
1641 Size
aSz( pEditEngine
->CalcTextWidth(), pEditEngine
->GetTextHeight() );
1642 Pen
aPen( PEN_SOLID
);
1643 Brush
aBrush( Color( COL_GRAY
), BRUSH_SOLID
);
1644 aPen
.SetColor( Color( COL_BLACK
) );
1646 SetFillInBrush( aBrush
);
1647 Rectangle
aR( pEditView
->GetOutputArea().TopLeft(), aSz
);
1650 pEditEngine
->Draw( this, pEditView
->GetOutputArea() );
1651 pEditView
->ShowCursor( TRUE
, TRUE
);
1654 // Eingabe an EditEngine...
1657 BOOL bDone
= pEditView
->PostKeyEvent( rKEvt
);
1659 Window::KeyInput( rKEvt
);
1662 ((EditMainWindow
*)GetParent())->UpdateToolBox();
1665 void __EXPORT
EditViewWindow::MouseMove( const MouseEvent
& rMEvt
)
1667 Point aPos
= PixelToLogic( rMEvt
.GetPosPixel() );
1668 if ( pEditView
->GetOutputArea().IsInside( aPos
) )
1670 const SvxFieldItem
* pField
= pEditView
->GetFieldUnderMousePointer();
1672 SetPointer( aURLPtr
);
1674 SetPointer( pEditView
->GetPointer() );
1676 // aPos -= pEditView->GetOutputArea().TopLeft();
1677 // aPos += pEditView->GetVisArea().TopLeft();
1678 // if ( pEditView->GetEditEngine()->IsTextPos( aPos, PixelToLogic( Size( 5, 0 ) ).Width() ) )
1679 // SetPointer( pEditView->GetPointer() );
1681 // SetPointer( Pointer( POINTER_REFHAND ) );
1685 SetPointer( aStdPtr
);
1687 // static long x = 0;
1689 // DBG_ASSERT( x < 1000, String( RTL_CONSTASCII_USTRINGPARAM( "?" ) ) );
1690 pEditView
->MouseMove( rMEvt
);
1693 void __EXPORT
EditViewWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
1696 pEditView
->MouseButtonDown( rMEvt
);
1699 void __EXPORT
EditViewWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
1701 pEditView
->MouseButtonUp( rMEvt
);
1702 ((EditMainWindow
*)GetParent())->UpdateToolBox();
1705 void __EXPORT
EditViewWindow::Command( const CommandEvent
& rCEvt
)
1707 if ( rCEvt
.GetCommand() == COMMAND_CONTEXTMENU
)
1709 if( pEditView
->IsWrongSpelledWordAtPos( rCEvt
.GetMousePosPixel() ) )
1710 pEditView
->ExecuteSpellPopup( rCEvt
.GetMousePosPixel() );
1713 pEditView
->Command(rCEvt
);
1717 BOOL __EXPORT
EditViewWindow::Drop( const DropEvent
& rEvt
)
1719 return pEditView
->Drop( rEvt
);
1722 BOOL __EXPORT
EditViewWindow::QueryDrop( DropEvent
& rEvt
)
1724 return pEditView
->QueryDrop( rEvt
);
1727 // --- aEditApp ------------------------------------------------------
1729 void __EXPORT
EditApp::Main()
1735 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xSMgr
= createApplicationServiceManager();
1736 ::comphelper::setProcessServiceFactory( xSMgr
);
1739 SvxGlobalItemData aItemData
;
1740 SvxFieldItem::GetClassManager().SV_CLASS_REGISTER( SvxDateField
);
1741 SvxFieldItem::GetClassManager().SV_CLASS_REGISTER( SvxURLField
);
1743 Help::EnableQuickHelp();
1745 EditMainWindow aWindow
;
1751 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */