2009-04-09 12:51:41 +0200 b_michaelsen r270689 : #i94949# cleaned up assertions after rebasing
2009-04-08 17:37:08 +0200 b_michaelsen r270658 : fixing sw/source/ui/utlui/makefile.mk
2009-04-07 17:56:54 +0200 b_michaelsen r270606 : added bookctrl.cxx to EXCEPTIONFILES, because this is needed for stl on unxsols4
2009-04-07 17:05:20 +0200 b_michaelsen r270603 : added crbm.cxx to EXCEPTIONFILES, because this is needed for stl on unxsols4
2009-04-02 23:44:38 +0200 b_michaelsen r270436 : CWS-TOOLING: rebase CWS swrefactormarks2 to trunk@270033 (milestone: DEV300:m45)
2009-02-27 16:25:31 +0100 b_michaelsen r268606 : #i94949# fixed Windows buildbreaker
2009-02-25 18:01:13 +0100 b_michaelsen r268464 : #i94949# Bookmarktest document filter roundtrips
2009-02-24 18:23:55 +0100 b_michaelsen r268404 : #i94949# Bookmark unittests
2009-02-23 19:47:44 +0100 b_michaelsen r268370 : #i94949# added unittest for bookmarks
2009-02-23 12:22:07 +0100 b_michaelsen r268348 : #i94949# fixing CheckCrossReferences testcase
2009-02-20 18:12:50 +0100 b_michaelsen r268335 : #i94949# fixing SwXTextRange
2009-02-18 18:32:57 +0100 b_michaelsen r268252 : #i94949# deregistering DdeBookmarks on delete
2009-02-18 18:29:08 +0100 b_michaelsen r268251 : fixing dbgoutsw.cxx for debug builds
2009-02-16 18:42:43 +0100 b_michaelsen r267834 : CWS-TOOLING: rebase CWS swrefactormarks2 to trunk@267171 (milestone: DEV300:m41)
2009-02-12 15:32:02 +0100 b_michaelsen r267667 : #i94949 fixed crossrefbookmark naming
2009-02-11 18:30:08 +0100 b_michaelsen r267624 : #94949# fixing bookmark navigation
2009-02-11 13:55:26 +0100 b_michaelsen r267599 : #i94949# fixed bookmark naming
2009-02-10 17:53:05 +0100 b_michaelsen r267571 : #i94949# renamed HasOtherMarkPos to IsExpanded
2009-02-10 17:23:01 +0100 b_michaelsen r267564 : #i94949# renamed ::sw::bookmark namespace to more fitting ::sw::mark
2009-02-10 16:16:32 +0100 b_michaelsen r267553 : #i94949# creating only CrossRefBookmark per Txtnode
2009-02-10 12:14:05 +0100 b_michaelsen r267547 : #i94949# fixed bookmark count in navigator
2009-02-09 19:12:18 +0100 b_michaelsen r267532 : #i94949# lcl_CopyBookmarks(..) - handle marks on boundaries correctly
2009-02-09 17:32:45 +0100 b_michaelsen r267524 : #i94949# setting the refobject of the DdeBookmark in Sin SwServerObject::SetDdeBookmark(..)
2009-02-09 17:22:15 +0100 b_michaelsen r267523 : #i94949# trying to harden SwServerObject
2009-02-09 16:47:32 +0100 b_michaelsen r267521 : #i94949# lcl_CopyBookmarks(..): try to get the source mark name, if possible
2009-02-09 16:05:42 +0100 b_michaelsen r267519 : #i94949# clearing the OtherMarkPos if PaM has no mark in repositionMark(..), swapping inverted bookmarks without hissing an assertion
2009-02-09 15:55:38 +0100 b_michaelsen r267518 : #i94949# checking for out-of-bounds in SwView::ExecuteStatusLine(..)
2009-02-09 15:23:47 +0100 b_michaelsen r267517 : #i94949# using an UNO_BOOKMARK in ui/dbui/dbinsdlg.cxx
2009-02-09 14:14:47 +0100 b_michaelsen r267514 : #i94949# IDocumentMarkAccess::GetType(..) asserts on unknown type
2009-02-09 14:04:25 +0100 b_michaelsen r267513 : #i94949# using rtl strings instead of tools-strings in CrossRefBookmarks
2009-02-09 13:55:01 +0100 b_michaelsen r267510 : #i94949# using empty string for UnoMark construction
2009-02-09 13:46:46 +0100 b_michaelsen r267509 : #i94949# removed superfluous #includes, removed superfluous member DdeBookmark::bGenerateName, initialized DdeBookmark::m_aRefObj removed superfluous local _FindItem::ClearObj
2009-02-06 14:38:37 +0100 b_michaelsen r267462 : #i94949# fixing FN_STAT_BOOKMARK dispatches
2009-02-05 18:05:07 +0100 b_michaelsen r267436 : #i94949# removing superfluous #includes
2009-02-04 15:51:31 +0100 b_michaelsen r267391 : fixing resync merge error
2009-02-02 19:39:55 +0100 b_michaelsen r267294 : #i94949# bookmark performance
2009-01-30 19:30:51 +0100 b_michaelsen r267229 : #i94949# throwing IllegalArgumentException, if appropriate
2009-01-30 19:29:56 +0100 b_michaelsen r267228 : #i94949# refactored lcl_FillBookmarkArray, comments, constness
2009-01-30 19:23:49 +0100 b_michaelsen r267227 : #i94949# refactored lcl_FillBookmarkArray, comments, constness
2009-01-30 19:16:06 +0100 b_michaelsen r267226 : #i94949# refactored lcl_FillBookmarkArray
2009-01-30 17:59:27 +0100 b_michaelsen r267222 : #i94949# removed superficial #include
2009-01-30 17:50:02 +0100 b_michaelsen r267220 : #i94949# SwXTextRange remembers its UNO bookmark
2009-01-29 20:19:58 +0100 b_michaelsen r267168 : #i94949# implemented IDocumentMarkAccess::findBookmark
2009-01-29 17:22:17 +0100 b_michaelsen r267162 : #i94949# implemented renameMark in Markmanager
2009-01-29 14:17:10 +0100 b_michaelsen r267134 : #i94949# cleanup in SwXBookmark, whitespace
2009-01-29 13:21:54 +0100 b_michaelsen r267125 : #i94949# cleanup in SwXBookmark, whitespace
2009-01-29 13:06:10 +0100 b_michaelsen r267120 : #i94949# cleanup in SwXBookmark, whitespace
2009-01-29 13:00:09 +0100 b_michaelsen r267118 : #i94949# cleanup in SwXBookmark, whitespace
2009-01-29 10:35:10 +0100 b_michaelsen r267101 : #i94949# renamed SetCrsrToBkmk to SetCrsrToMark, moving to start/end of doc if no more bookmarks can be found
2009-01-28 17:05:36 +0100 b_michaelsen r267070 : #i94949# fixed order in aProvNamesId in unocoll.cxx
2009-01-28 15:46:13 +0100 b_michaelsen r267063 : #i94949# documentation
2009-01-28 15:36:59 +0100 b_michaelsen r267062 : #i94949# removing superficial #include
2009-01-28 15:30:36 +0100 b_michaelsen r267061 : #i94949# basic code conventions
2009-01-28 11:14:30 +0100 b_michaelsen r267039 : #i94949# comparing to the actual name of the new mark
2009-01-26 15:22:25 +0100 b_michaelsen r266927 : #i94949# performance fixes
2009-01-14 21:16:56 +0100 b_michaelsen r266332 : #i94949# fixing linux x86-64 compiler warnings
2009-01-14 19:52:06 +0100 b_michaelsen r266331 : #i94949# fixing some compiler warnings
2008-12-15 13:04:49 +0100 b_michaelsen r265474 : #i94949# fixed microsoft compiler warnings
2008-12-12 18:26:02 +0100 b_michaelsen r265434 : #i94949# fixed pro platform buildbreakers
2008-12-11 17:51:24 +0100 b_michaelsen r265342 : CWS-TOOLING: rebase CWS swrefactormarks2 to trunk@264807 (milestone: DEV300:m37)
2008-12-09 18:30:59 +0100 b_michaelsen r265134 : #i94949# fixed IDocumentMarkAccess::GetType for new mark inheritance tree
2008-12-09 16:56:26 +0100 b_michaelsen r265118 : #i94949# fixed deleteMark optimization
2008-12-09 14:55:58 +0100 b_michaelsen r265092 : #i94949# DdeLink and DdeBookmark
2008-12-05 18:28:05 +0100 b_michaelsen r264914 : #i94949# fixed InitDoc in bookmarks
2008-12-02 02:23:51 +0100 b_michaelsen r264649 : #i94949# removed obsolete naming proposal code in SwXTextRange, fixed navigator reminders to forget the oldest reminder when the pool is empty
2008-12-02 02:05:19 +0100 b_michaelsen r264648 : #i94949# using bisect search for delete
2008-12-02 01:58:16 +0100 b_michaelsen r264647 : #i94949# using bisect search for delete
2008-12-02 01:37:33 +0100 b_michaelsen r264646 : #i94949# using bisect search for delete
2008-12-02 01:03:29 +0100 b_michaelsen r264645 : #i94949# fixed deleteMark crash
2008-12-01 20:55:00 +0100 b_michaelsen r264638 : #i94949# removed crossrefs from ui enumerations
2008-12-01 15:48:12 +0100 b_michaelsen r264613 : #i94949# removed superfluous local functions
2008-12-01 15:01:19 +0100 b_michaelsen r264608 : #i94949# optimized insertion of new marks
2008-12-01 14:33:21 +0100 b_michaelsen r264603 : #i94949# simplified code finding Fieldmark for a position
2008-12-01 14:05:55 +0100 b_michaelsen r264598 : #i94949# fixed reverse travelling through marks, removed obsolete getUniqueMarkName()
2008-11-27 18:48:15 +0100 b_michaelsen r264515 : #i94949# fixed _SaveCntntIdx and friends
2008-11-27 15:59:49 +0100 b_michaelsen r264500 : #i94949# fix Mark position only in ctor
2008-11-27 15:52:28 +0100 b_michaelsen r264497 : #i94949# fixed Bug in SwXBookmark, was using pDoc too early
2008-11-26 14:54:22 +0100 b_michaelsen r264396 : #i94949# fixed documentation, simplified navigator reminder code
2008-11-24 20:45:51 +0100 b_michaelsen r264266 : #i94949# removed last obsolete getUniqueMarkName calls
2008-11-24 20:21:35 +0100 b_michaelsen r264265 : #i94949# fixed typo in IDocumentMarkAccess, removed obsolete getUniqueMarkName calls
2008-11-24 18:34:32 +0100 b_michaelsen r264264 : #i94949# repositioning of Marks, removed possibility to delete marks by name in the core, refactoring of navigator reminder generation
2008-11-21 14:08:49 +0100 b_michaelsen r264137 : #i94949# simplified makeMark
2008-11-21 12:07:09 +0100 b_michaelsen r264120 : #i94949# moved ShortName and KeyCode from IMark to IBookmark
2008-11-19 12:50:49 +0100 b_michaelsen r263981 : #i94949# starting refactoring of bookmark naming
2008-11-19 11:31:08 +0100 b_michaelsen r263972 : #i94949# getting rid of obsolete dynamic casts
2008-11-18 19:06:09 +0100 b_michaelsen r263795 : #i94949# getting rid of index based mark access, IDocumentMarkAccess already provides iterators
2008-11-18 17:50:18 +0100 b_michaelsen r263792 : #i94949# getting rid of index based mark access, IDocumentMarkAccess already provides iterators
2008-11-18 16:48:20 +0100 b_michaelsen r263783 : #i94949# removed methods from crsrsh which are already available directly via IDocumentMarkAccess
2008-11-18 11:31:35 +0100 b_michaelsen r263753 : #i94949# cleaning up mark code in crsrsh
2008-11-17 10:15:25 +0100 b_michaelsen r263705 : #i94949# removed possible integer overflow
2008-11-14 18:48:45 +0100 b_michaelsen r263695 : #i94949# management of mark names in MarkManager
2008-11-14 18:23:40 +0100 b_michaelsen r263693 : #i94949# using polymorphism to do mark-specific setup in SwDoc
2008-11-14 16:27:09 +0100 b_michaelsen r263684 : #i94949# got rid of makeCrossRefBookmark
2008-11-14 13:03:32 +0100 b_michaelsen r263674 : #i94949# refactored Correction methods
2008-11-13 12:27:55 +0100 b_michaelsen r263631 : #i94949# got rid of old-style tools assertions in new code
2008-11-12 16:58:16 +0100 b_michaelsen r263608 : #i94949# added assertion for unique names
2008-11-12 16:55:18 +0100 b_michaelsen r263607 : #i94949# maked XFormField deprecated
2008-11-12 13:04:29 +0100 b_michaelsen r263587 : #i94949# replaced IDocumentMarkAccess::GetType with simple dynamic_cast where possible
2008-11-11 18:45:53 +0100 b_michaelsen r263572 : #i94949# cleaned up SwHstryBookmark
2008-11-11 13:48:18 +0100 b_michaelsen r263557 : #i94949# removed dynamic_casts to SwModify by inheriting IMark from it
2008-11-11 11:26:28 +0100 b_michaelsen r263548 : #i94949# fixed SwXBookmark
2008-11-10 17:01:19 +0100 b_michaelsen r263529 : #i94949# fixed DdeBookmarks in clipboard
2008-11-10 16:44:52 +0100 b_michaelsen r263527 : #i94949# formatting
2008-11-10 16:29:16 +0100 b_michaelsen r263526 : #i94949# fixing unoobj.cxx
2008-11-10 16:23:50 +0100 b_michaelsen r263525 : #i94949# cleaning up crossrefbookmark.cxx/.hxx
2008-11-10 16:02:08 +0100 b_michaelsen r263524 : #i94949# Pdf Export should only generate 'real' bookmarks
2008-11-10 15:33:58 +0100 b_michaelsen r263521 : #i94949# removed const_casts
2008-11-10 15:12:06 +0100 b_michaelsen r263520 : #i94949# moved _DelBookmarks into MarksManager
2008-11-07 18:48:38 +0100 b_michaelsen r263480 : #i94949# using iterator interface
2008-11-07 18:41:46 +0100 b_michaelsen r263478 : #i94949# using iterator interface
2008-11-07 18:07:41 +0100 b_michaelsen r263477 : #i94949# using iterator interface
2008-11-07 17:54:41 +0100 b_michaelsen r263476 : #i94949# using iterator interface
2008-11-07 17:44:41 +0100 b_michaelsen r263475 : #i94949# moved correction methods into MarkManager
2008-11-06 18:47:28 +0100 b_michaelsen r263404 : #i94949# getting rid of superfluous const_casts
2008-11-06 17:58:01 +0100 b_michaelsen r263403 : #i94949# no more setting of mark positions outside of the core
2008-11-06 17:08:37 +0100 b_michaelsen r263401 : #i94949# removed setters from IMark
2008-11-06 13:55:25 +0100 b_michaelsen r263383 : #i94949 SwDoc does not implement IDocumentMarkAccess anymore
2008-11-04 18:17:03 +0100 b_michaelsen r263333 : #i94949# began removing IDocumentMarkAccess from SwDoc
2008-11-04 16:48:34 +0100 b_michaelsen r263330 : removing dead code (SwBitArray) found by mst
2008-11-04 16:29:32 +0100 b_michaelsen r263329 : removing dead code (SwBitArray) found by mst
2008-11-04 14:57:48 +0100 b_michaelsen r263326 : removing dead code (SwBitArray) found by mst
2008-11-04 14:50:18 +0100 b_michaelsen r263325 : #i94949# stricter typing in IDocumentMarkAccess
2008-10-24 15:16:27 +0200 b_michaelsen r262647 : #i94949# renamed ::sw:🔖:SimpleMark to NavigatorReminder to fit the IDocumentMarkAccess enum
2008-10-24 15:10:10 +0200 b_michaelsen r262646 : #i94949# only 'real' bookmark implement IBookmark, Marks also get removed from m_vFieldmarks on delete/clear
2008-10-24 13:06:23 +0200 b_michaelsen r262636 : #i94949# Fieldmark tabnavigation
2008-10-23 12:16:36 +0200 b_michaelsen r262619 : #i94949# Fieldmark classes and filters
2008-10-22 13:17:18 +0200 b_michaelsen r262597 : #i94949# writer import fixes
2008-10-21 11:30:38 +0200 b_michaelsen r262565 : #i94949# renamed methods containing Bookmark in the generic IMark interface
2008-10-20 14:09:02 +0200 b_michaelsen r262318 : #i94949# fixed SwDoc::CorrRel
2008-10-16 22:45:13 +0200 b_michaelsen r262273 : #i94949 simplified Before/After methods
2008-10-16 21:40:57 +0200 b_michaelsen r262271 : #i94949 renamed SimpleMark to NavigatorReminder
2008-10-16 21:15:23 +0200 b_michaelsen r262270 : #i94949 using shared_ptr only in MarkManager
2008-10-16 17:46:37 +0200 b_michaelsen r262269 : #i94949# getFieldmarkBefore and getFieldmarkAfter
2008-10-16 17:12:13 +0200 b_michaelsen r262265 : #i94949# cleanup in crbm.cxx
2008-10-16 12:49:01 +0200 b_michaelsen r262257 : #i94949# fixed usage of invalid iterator, fixed invalid cast
2008-10-15 15:34:20 +0200 b_michaelsen r262239 : #i94949# added moved files
2008-10-15 15:26:45 +0200 b_michaelsen r262237 : #i94949# initial reimplementation of Bookmarks
899 lines
36 KiB
C++
899 lines
36 KiB
C++
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: SwSpellDialogChildWindow.cxx,v $
|
|
* $Revision: 1.15 $
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
#include "precompiled_sw.hxx"
|
|
#include <SwSpellDialogChildWindow.hxx>
|
|
#include <vcl/msgbox.hxx>
|
|
#include <svx/svxacorr.hxx>
|
|
#include <svx/acorrcfg.hxx>
|
|
#ifndef _SVX_SVXIDS_HRC
|
|
#include <svx/svxids.hrc>
|
|
#endif
|
|
#include <sfx2/app.hxx>
|
|
#include <sfx2/bindings.hxx>
|
|
#include <sfx2/dispatch.hxx>
|
|
#include <svx/unolingu.hxx>
|
|
#include <wrtsh.hxx>
|
|
#include <sfx2/printer.hxx>
|
|
#include <svx/svdoutl.hxx>
|
|
#include <svx/svdview.hxx>
|
|
#include <svx/svditer.hxx>
|
|
#include <svx/svdogrp.hxx>
|
|
#include <svtools/linguprops.hxx>
|
|
#include <svtools/lingucfg.hxx>
|
|
#include <doc.hxx>
|
|
#ifndef _DOCSH_HXX
|
|
#include <docsh.hxx>
|
|
#endif
|
|
#include <docary.hxx>
|
|
#include <frmfmt.hxx>
|
|
#include <dcontact.hxx>
|
|
#include <edtwin.hxx>
|
|
#include <pam.hxx>
|
|
#include <drawbase.hxx>
|
|
#include <unoobj.hxx>
|
|
#ifndef _DIALOG_HXX
|
|
#include <dialog.hrc>
|
|
#endif
|
|
#include <cmdid.h>
|
|
|
|
using namespace ::com::sun::star;
|
|
using namespace ::com::sun::star::uno;
|
|
using namespace ::com::sun::star::text;
|
|
using namespace ::com::sun::star::linguistic2;
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
SFX_IMPL_CHILDWINDOW(SwSpellDialogChildWindow, FN_SPELL_GRAMMAR_DIALOG)
|
|
|
|
|
|
#define SPELL_START_BODY 0 // body text area
|
|
#define SPELL_START_OTHER 1 // frame, footnote, header, footer
|
|
#define SPELL_START_DRAWTEXT 2 // started in a draw text object
|
|
|
|
struct SpellState
|
|
{
|
|
bool m_bInitialCall;
|
|
bool m_bLockFocus; //lock the focus notification while a modal dialog is active
|
|
bool m_bLostFocus;
|
|
|
|
//restart and progress information
|
|
USHORT m_SpellStartPosition;
|
|
bool m_bBodySpelled; //body already spelled
|
|
bool m_bOtherSpelled; //frames, footnotes, headers and footers spelled
|
|
bool m_bStartedInOther; //started the spelling insided of the _other_ area
|
|
bool m_bStartedInSelection; // there was an initial text selection
|
|
SwPaM* pOtherCursor; // position where the spelling inside the _other_ area started
|
|
bool m_bDrawingsSpelled; //all drawings spelled
|
|
Reference<XTextRange> m_xStartRange; //text range that marks the start of spelling
|
|
const SdrObject* m_pStartDrawing; //draw text object spelling started in
|
|
ESelection m_aStartDrawingSelection; //draw text start selection
|
|
bool m_bRestartDrawing; // the first selected drawing object is found again
|
|
|
|
//lose/get focus information to decide if spelling can be continued
|
|
ShellModes m_eSelMode;
|
|
const SwNode* m_pPointNode;
|
|
const SwNode* m_pMarkNode;
|
|
xub_StrLen m_nPointPos;
|
|
xub_StrLen m_nMarkPos;
|
|
const SdrOutliner* m_pOutliner;
|
|
ESelection m_aESelection;
|
|
|
|
//iterating over draw text objects
|
|
std::vector<SdrTextObj*> m_aTextObjects;
|
|
bool m_bTextObjectsCollected;
|
|
|
|
SpellState() :
|
|
m_bInitialCall(true),
|
|
m_bLockFocus(false),
|
|
m_bLostFocus(false),
|
|
m_SpellStartPosition(SPELL_START_BODY),
|
|
m_bBodySpelled(false),
|
|
m_bOtherSpelled(false),
|
|
m_bStartedInOther(false),
|
|
m_bStartedInSelection(false),
|
|
pOtherCursor(0),
|
|
m_bDrawingsSpelled(false),
|
|
m_pStartDrawing(0),
|
|
m_bRestartDrawing(false),
|
|
|
|
m_eSelMode(SHELL_MODE_OBJECT), //initially invalid
|
|
m_pPointNode(0),
|
|
m_pMarkNode(0),
|
|
m_nPointPos(0),
|
|
m_nMarkPos(0),
|
|
m_pOutliner(0),
|
|
m_bTextObjectsCollected(false)
|
|
{}
|
|
|
|
~SpellState() {delete pOtherCursor;}
|
|
|
|
// reset state in ::InvalidateSpellDialog
|
|
void Reset()
|
|
{ m_bInitialCall = true;
|
|
m_bBodySpelled = m_bOtherSpelled = m_bDrawingsSpelled = false;
|
|
m_xStartRange = 0;
|
|
m_pStartDrawing = 0;
|
|
m_bRestartDrawing = false;
|
|
m_bTextObjectsCollected = false;
|
|
m_aTextObjects.clear();
|
|
m_bStartedInOther = false;
|
|
delete pOtherCursor;
|
|
pOtherCursor = 0;
|
|
}
|
|
};
|
|
/*-- 30.10.2003 14:33:26---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void lcl_LeaveDrawText(SwWrtShell& rSh)
|
|
{
|
|
if(rSh.GetDrawView())
|
|
{
|
|
rSh.GetDrawView()->SdrEndTextEdit( TRUE );
|
|
Point aPt(LONG_MIN, LONG_MIN);
|
|
//go out of the frame
|
|
rSh.SelectObj(aPt, SW_LEAVE_FRAME);
|
|
rSh.EnterStdMode();
|
|
rSh.GetView().AttrChangedNotify(&rSh);
|
|
}
|
|
}
|
|
/*-- 09.09.2003 10:39:22---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
SwSpellDialogChildWindow::SwSpellDialogChildWindow (
|
|
Window* _pParent,
|
|
USHORT nId,
|
|
SfxBindings* pBindings,
|
|
SfxChildWinInfo* pInfo) :
|
|
svx::SpellDialogChildWindow (
|
|
_pParent, nId, pBindings, pInfo),
|
|
m_pSpellState(new SpellState)
|
|
{
|
|
|
|
String aPropName( String::CreateFromAscii(UPN_IS_GRAMMAR_INTERACTIVE ) );
|
|
SvtLinguConfig().GetProperty( aPropName ) >>= m_bIsGrammarCheckingOn;
|
|
}
|
|
/*-- 09.09.2003 10:39:22---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
SwSpellDialogChildWindow::~SwSpellDialogChildWindow ()
|
|
{
|
|
SwWrtShell* pWrtShell = GetWrtShell_Impl();
|
|
if(!m_pSpellState->m_bInitialCall && pWrtShell)
|
|
pWrtShell->SpellEnd();
|
|
delete m_pSpellState;
|
|
}
|
|
|
|
/*-- 09.09.2003 12:40:07---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
SfxChildWinInfo SwSpellDialogChildWindow::GetInfo (void) const
|
|
{
|
|
SfxChildWinInfo aInfo = svx::SpellDialogChildWindow::GetInfo();
|
|
aInfo.bVisible = FALSE;
|
|
return aInfo;
|
|
}
|
|
|
|
/*-- 09.09.2003 10:39:40---------------------------------------------------
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
|
svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void)
|
|
{
|
|
svx::SpellPortions aRet;
|
|
SwWrtShell* pWrtShell = GetWrtShell_Impl();
|
|
if(pWrtShell)
|
|
{
|
|
ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
|
|
bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode;
|
|
bool bNormalText =
|
|
SHELL_MODE_TABLE_TEXT == eSelMode ||
|
|
SHELL_MODE_LIST_TEXT == eSelMode ||
|
|
SHELL_MODE_TABLE_LIST_TEXT == eSelMode ||
|
|
SHELL_MODE_TEXT == eSelMode;
|
|
//Writer text outside of the body
|
|
bool bOtherText = false;
|
|
|
|
if( m_pSpellState->m_bInitialCall )
|
|
{
|
|
//if no text selection exists the cursor has to be set into the text
|
|
if(!bDrawText && !bNormalText)
|
|
{
|
|
if(!MakeTextSelection_Impl(*pWrtShell, eSelMode))
|
|
return aRet;
|
|
else
|
|
{
|
|
// the selection type has to be checked again - both text types are possible
|
|
if(0 != (pWrtShell->GetSelectionType()& nsSelectionType::SEL_DRW_TXT))
|
|
bDrawText = true;
|
|
bNormalText = !bDrawText;
|
|
}
|
|
}
|
|
if(bNormalText)
|
|
{
|
|
//set cursor to the start of the sentence
|
|
if(!pWrtShell->HasSelection())
|
|
pWrtShell->GoStartSentence();
|
|
else
|
|
m_pSpellState->m_bStartedInSelection = true;
|
|
//determine if the selection is outside of the body text
|
|
bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
|
|
m_pSpellState->m_SpellStartPosition = bOtherText ? SPELL_START_OTHER : SPELL_START_BODY;
|
|
if(bOtherText)
|
|
{
|
|
m_pSpellState->pOtherCursor = new SwPaM(*pWrtShell->GetCrsr()->GetPoint());
|
|
m_pSpellState->m_bStartedInOther = true;
|
|
pWrtShell->SpellStart( DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_CURR, FALSE );
|
|
}
|
|
else
|
|
{
|
|
SwPaM* pCrsr = pWrtShell->GetCrsr();
|
|
//mark the start position only if not at start of doc
|
|
if(!pWrtShell->IsStartOfDoc())
|
|
{
|
|
m_pSpellState->m_xStartRange = SwXTextRange::CreateTextRangeFromPosition(
|
|
pWrtShell->GetDoc(), *pCrsr->Start(), pCrsr->End());
|
|
}
|
|
pWrtShell->SpellStart( DOCPOS_START, DOCPOS_END, DOCPOS_CURR, FALSE );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SdrView* pSdrView = pWrtShell->GetDrawView();
|
|
m_pSpellState->m_SpellStartPosition = SPELL_START_DRAWTEXT;
|
|
m_pSpellState->m_pStartDrawing = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
|
|
OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
|
|
m_pSpellState->m_aStartDrawingSelection = pOLV->GetSelection();
|
|
}
|
|
|
|
m_pSpellState->m_bInitialCall = false;
|
|
}
|
|
if( bDrawText )
|
|
{
|
|
// spell inside of the current draw text
|
|
if(!SpellDrawText_Impl(*pWrtShell, aRet))
|
|
{
|
|
if(!FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet))
|
|
{
|
|
lcl_LeaveDrawText(*pWrtShell);
|
|
//now the drawings have been spelled
|
|
m_pSpellState->m_bDrawingsSpelled = true;
|
|
//the spelling continues at the other content
|
|
//if there's any that has not been spelled yet
|
|
if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt())
|
|
{
|
|
pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART, FALSE );
|
|
if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
|
|
{
|
|
pWrtShell->SpellEnd();
|
|
m_pSpellState->m_bOtherSpelled = true;
|
|
}
|
|
}
|
|
else
|
|
m_pSpellState->m_bOtherSpelled = true;
|
|
//if no result has been found try at the body text - completely
|
|
if(!m_pSpellState->m_bBodySpelled && !aRet.size())
|
|
{
|
|
pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START, FALSE );
|
|
if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
|
|
{
|
|
m_pSpellState->m_bBodySpelled = true;
|
|
pWrtShell->SpellEnd();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//spell inside of the Writer text
|
|
if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
|
|
{
|
|
//find out which text has been spelled body or other
|
|
bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
|
|
if(bOtherText && m_pSpellState->m_bStartedInOther && m_pSpellState->pOtherCursor)
|
|
{
|
|
m_pSpellState->m_bStartedInOther = false;
|
|
pWrtShell->SetSelection(*m_pSpellState->pOtherCursor);
|
|
pWrtShell->SpellEnd();
|
|
delete m_pSpellState->pOtherCursor;
|
|
m_pSpellState->pOtherCursor = 0;
|
|
pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_CURR, DOCPOS_OTHERSTART, FALSE );
|
|
pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn);
|
|
}
|
|
if(!aRet.size())
|
|
{
|
|
//end spelling
|
|
pWrtShell->SpellEnd();
|
|
if(bOtherText)
|
|
{
|
|
m_pSpellState->m_bOtherSpelled = true;
|
|
//has the body been spelled?
|
|
if(!m_pSpellState->m_bBodySpelled)
|
|
{
|
|
pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START, FALSE );
|
|
if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
|
|
{
|
|
m_pSpellState->m_bBodySpelled = true;
|
|
pWrtShell->SpellEnd();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_pSpellState->m_bBodySpelled = true;
|
|
if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt())
|
|
{
|
|
pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART, FALSE );
|
|
if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
|
|
{
|
|
pWrtShell->SpellEnd();
|
|
m_pSpellState->m_bOtherSpelled = true;
|
|
}
|
|
}
|
|
else
|
|
m_pSpellState->m_bOtherSpelled = true;
|
|
}
|
|
}
|
|
|
|
//search for a draw text object that contains error and spell it
|
|
if(!aRet.size() &&
|
|
(m_pSpellState->m_bDrawingsSpelled ||
|
|
!FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet)))
|
|
{
|
|
lcl_LeaveDrawText(*pWrtShell);
|
|
m_pSpellState->m_bDrawingsSpelled = true;
|
|
}
|
|
}
|
|
}
|
|
// now only the rest of the body text can be spelled -
|
|
// if the spelling started inside of the body
|
|
//
|
|
bool bCloseMessage = true;
|
|
if(!aRet.size() && !m_pSpellState->m_bStartedInSelection)
|
|
{
|
|
DBG_ASSERT(m_pSpellState->m_bDrawingsSpelled &&
|
|
m_pSpellState->m_bOtherSpelled && m_pSpellState->m_bBodySpelled,
|
|
"not all parts of the document are already spelled");
|
|
if(m_pSpellState->m_xStartRange.is())
|
|
{
|
|
LockFocusNotification( true );
|
|
USHORT nRet = QueryBox( GetWindow(), SW_RES(RID_QB_SPELL_CONTINUE)).Execute();
|
|
if(RET_YES == nRet)
|
|
{
|
|
SwUnoInternalPaM aPam(*pWrtShell->GetDoc());
|
|
if(SwXTextRange::XTextRangeToSwPaM(aPam, m_pSpellState->m_xStartRange))
|
|
{
|
|
pWrtShell->SetSelection(aPam);
|
|
pWrtShell->SpellStart(DOCPOS_START, DOCPOS_CURR, DOCPOS_START);
|
|
if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn))
|
|
pWrtShell->SpellEnd();
|
|
}
|
|
m_pSpellState->m_xStartRange = 0;
|
|
LockFocusNotification( false );
|
|
//take care that the now valid selection is stored
|
|
LoseFocus();
|
|
}
|
|
else
|
|
bCloseMessage = false; //no closing message if a wrap around has been denied
|
|
}
|
|
}
|
|
if(!aRet.size())
|
|
{
|
|
if(bCloseMessage)
|
|
{
|
|
LockFocusNotification( true );
|
|
String sInfo(SW_RES(STR_SPELLING_COMPLETED));
|
|
//#i84610#
|
|
Window* pTemp = GetWindow(); // temporary needed for g++ 3.3.5
|
|
InfoBox(pTemp, sInfo ).Execute();
|
|
LockFocusNotification( false );
|
|
//take care that the now valid selection is stored
|
|
LoseFocus();
|
|
}
|
|
|
|
//close the spelling dialog
|
|
GetBindings().GetDispatcher()->Execute(FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
|
|
}
|
|
}
|
|
return aRet;
|
|
|
|
}
|
|
/*-- 09.09.2003 10:39:40---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rChanged)
|
|
{
|
|
SwWrtShell* pWrtShell = GetWrtShell_Impl();
|
|
DBG_ASSERT(!m_pSpellState->m_bInitialCall, "ApplyChangedSentence in initial call or after resume");
|
|
if(pWrtShell && !m_pSpellState->m_bInitialCall)
|
|
{
|
|
ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
|
|
bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode;
|
|
bool bNormalText =
|
|
SHELL_MODE_TABLE_TEXT == eSelMode ||
|
|
SHELL_MODE_LIST_TEXT == eSelMode ||
|
|
SHELL_MODE_TABLE_LIST_TEXT == eSelMode ||
|
|
SHELL_MODE_TEXT == eSelMode;
|
|
if(bNormalText)
|
|
pWrtShell->ApplyChangedSentence(rChanged, m_bIsGrammarCheckingOn);
|
|
else if(bDrawText )
|
|
{
|
|
SdrView* pDrView = pWrtShell->GetDrawView();
|
|
SdrOutliner *pOutliner = pDrView->GetTextEditOutliner();
|
|
pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, m_bIsGrammarCheckingOn);
|
|
}
|
|
}
|
|
}
|
|
/*-- 21.10.2003 09:33:57---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void SwSpellDialogChildWindow::AddAutoCorrection(
|
|
const String& rOld, const String& rNew, LanguageType eLanguage)
|
|
{
|
|
SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get()->GetAutoCorrect();
|
|
pACorr->PutText( rOld, rNew, eLanguage );
|
|
}
|
|
/*-- 21.10.2003 09:33:59---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
bool SwSpellDialogChildWindow::HasAutoCorrection()
|
|
{
|
|
return true;
|
|
}
|
|
/*-- 16.06.2008 11:59:17---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
bool SwSpellDialogChildWindow::HasGrammarChecking()
|
|
{
|
|
return SvtLinguConfig().HasGrammarChecker();
|
|
}
|
|
/*-- 18.06.2008 12:27:11---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
bool SwSpellDialogChildWindow::IsGrammarChecking()
|
|
{
|
|
return m_bIsGrammarCheckingOn;
|
|
}
|
|
/*-- 18.06.2008 12:27:11---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void SwSpellDialogChildWindow::SetGrammarChecking(bool bOn)
|
|
{
|
|
uno::Any aVal;
|
|
aVal <<= bOn;
|
|
m_bIsGrammarCheckingOn = bOn;
|
|
String aPropName( C2S(UPN_IS_GRAMMAR_INTERACTIVE ) );
|
|
SvtLinguConfig().SetProperty( aPropName, aVal );
|
|
// set current spell position to the start of the current sentence to
|
|
// continue with this sentence after grammar checking state has been changed
|
|
SwWrtShell* pWrtShell = GetWrtShell_Impl();
|
|
if(pWrtShell)
|
|
{
|
|
ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
|
|
bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode;
|
|
bool bNormalText =
|
|
SHELL_MODE_TABLE_TEXT == eSelMode ||
|
|
SHELL_MODE_LIST_TEXT == eSelMode ||
|
|
SHELL_MODE_TABLE_LIST_TEXT == eSelMode ||
|
|
SHELL_MODE_TEXT == eSelMode;
|
|
if( bNormalText )
|
|
pWrtShell->PutSpellingToSentenceStart();
|
|
else if( bDrawText )
|
|
{
|
|
SdrView* pSdrView = pWrtShell->GetDrawView();
|
|
SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0;
|
|
DBG_ASSERT(pOutliner, "No Outliner in SwSpellDialogChildWindow::SetGrammarChecking");
|
|
if(pOutliner)
|
|
{
|
|
pOutliner->PutSpellingToSentenceStart( pSdrView->GetTextEditOutlinerView()->GetEditView() );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/*-- 28.10.2003 08:41:09---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void SwSpellDialogChildWindow::GetFocus()
|
|
{
|
|
if(m_pSpellState->m_bLockFocus)
|
|
return;
|
|
bool bInvalidate = false;
|
|
SwWrtShell* pWrtShell = GetWrtShell_Impl();
|
|
if(pWrtShell && !m_pSpellState->m_bInitialCall)
|
|
{
|
|
ShellModes eSelMode = pWrtShell->GetView().GetShellMode();
|
|
if(eSelMode != m_pSpellState->m_eSelMode)
|
|
{
|
|
//prevent initial invalidation
|
|
if(m_pSpellState->m_bLostFocus)
|
|
bInvalidate = true;
|
|
}
|
|
else
|
|
{
|
|
switch(m_pSpellState->m_eSelMode)
|
|
{
|
|
case SHELL_MODE_TEXT:
|
|
case SHELL_MODE_LIST_TEXT:
|
|
case SHELL_MODE_TABLE_TEXT:
|
|
case SHELL_MODE_TABLE_LIST_TEXT:
|
|
{
|
|
SwPaM* pCursor = pWrtShell->GetCrsr();
|
|
if(m_pSpellState->m_pPointNode != pCursor->GetNode(TRUE) ||
|
|
m_pSpellState->m_pMarkNode != pCursor->GetNode(FALSE)||
|
|
m_pSpellState->m_nPointPos != pCursor->GetPoint()->nContent.GetIndex()||
|
|
m_pSpellState->m_nMarkPos != pCursor->GetMark()->nContent.GetIndex())
|
|
bInvalidate = true;
|
|
}
|
|
break;
|
|
case SHELL_MODE_DRAWTEXT:
|
|
{
|
|
SdrView* pSdrView = pWrtShell->GetDrawView();
|
|
SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0;
|
|
if(!pOutliner || m_pSpellState->m_pOutliner != pOutliner)
|
|
bInvalidate = true;
|
|
else
|
|
{
|
|
OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
|
|
DBG_ASSERT(pOLV, "no OutlinerView in SwSpellDialogChildWindow::GetFocus()");
|
|
if(!pOLV || !m_pSpellState->m_aESelection.IsEqual(pOLV->GetSelection()))
|
|
bInvalidate = true;
|
|
}
|
|
}
|
|
break;
|
|
default: bInvalidate = true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bInvalidate = true;
|
|
}
|
|
if(bInvalidate)
|
|
InvalidateSpellDialog();
|
|
}
|
|
/*-- 28.10.2003 08:41:09---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void SwSpellDialogChildWindow::LoseFocus()
|
|
{
|
|
//prevent initial invalidation
|
|
m_pSpellState->m_bLostFocus = true;
|
|
if(m_pSpellState->m_bLockFocus)
|
|
return;
|
|
SwWrtShell* pWrtShell = GetWrtShell_Impl();
|
|
if(pWrtShell)
|
|
{
|
|
m_pSpellState->m_eSelMode = pWrtShell->GetView().GetShellMode();
|
|
m_pSpellState->m_pPointNode = m_pSpellState->m_pMarkNode = 0;
|
|
m_pSpellState->m_nPointPos = m_pSpellState->m_nMarkPos = 0;
|
|
m_pSpellState->m_pOutliner = 0;
|
|
|
|
switch(m_pSpellState->m_eSelMode)
|
|
{
|
|
case SHELL_MODE_TEXT:
|
|
case SHELL_MODE_LIST_TEXT:
|
|
case SHELL_MODE_TABLE_TEXT:
|
|
case SHELL_MODE_TABLE_LIST_TEXT:
|
|
{
|
|
//store a node pointer and a pam-position to be able to check on next GetFocus();
|
|
SwPaM* pCursor = pWrtShell->GetCrsr();
|
|
m_pSpellState->m_pPointNode = pCursor->GetNode(TRUE);
|
|
m_pSpellState->m_pMarkNode = pCursor->GetNode(FALSE);
|
|
m_pSpellState->m_nPointPos = pCursor->GetPoint()->nContent.GetIndex();
|
|
m_pSpellState->m_nMarkPos = pCursor->GetMark()->nContent.GetIndex();
|
|
|
|
}
|
|
break;
|
|
case SHELL_MODE_DRAWTEXT:
|
|
{
|
|
SdrView* pSdrView = pWrtShell->GetDrawView();
|
|
SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
|
|
m_pSpellState->m_pOutliner = pOutliner;
|
|
OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
|
|
DBG_ASSERT(pOutliner && pOLV, "no Outliner/OutlinerView in SwSpellDialogChildWindow::LoseFocus()");
|
|
if(pOLV)
|
|
{
|
|
m_pSpellState->m_aESelection = pOLV->GetSelection();
|
|
}
|
|
}
|
|
break;
|
|
default:;//prevent warning
|
|
}
|
|
}
|
|
else
|
|
m_pSpellState->m_eSelMode = SHELL_MODE_OBJECT;
|
|
}
|
|
/*-- 18.09.2003 12:50:18---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void SwSpellDialogChildWindow::InvalidateSpellDialog()
|
|
{
|
|
SwWrtShell* pWrtShell = GetWrtShell_Impl();
|
|
if(!m_pSpellState->m_bInitialCall && pWrtShell)
|
|
pWrtShell->SpellEnd(0, false);
|
|
m_pSpellState->Reset();
|
|
svx::SpellDialogChildWindow::InvalidateSpellDialog();
|
|
}
|
|
|
|
/*-- 18.09.2003 12:54:59---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
SwWrtShell* SwSpellDialogChildWindow::GetWrtShell_Impl()
|
|
{
|
|
SfxDispatcher* pDispatch = GetBindings().GetDispatcher();
|
|
SwView* pView = 0;
|
|
if(pDispatch)
|
|
{
|
|
USHORT nShellIdx = 0;
|
|
SfxShell* pShell;
|
|
while(0 != (pShell = pDispatch->GetShell(nShellIdx++)))
|
|
if(pShell->ISA(SwView))
|
|
{
|
|
pView = static_cast<SwView* >(pShell);
|
|
break;
|
|
}
|
|
}
|
|
return pView ? pView->GetWrtShellPtr(): 0;
|
|
}
|
|
|
|
/*-- 13.10.2003 15:19:04---------------------------------------------------
|
|
set the cursor into the body text - necessary if any object is selected
|
|
on start of the spelling dialog
|
|
-----------------------------------------------------------------------*/
|
|
bool SwSpellDialogChildWindow::MakeTextSelection_Impl(SwWrtShell& rShell, ShellModes eSelMode)
|
|
{
|
|
SwView& rView = rShell.GetView();
|
|
switch(eSelMode)
|
|
{
|
|
case SHELL_MODE_TEXT:
|
|
case SHELL_MODE_LIST_TEXT:
|
|
case SHELL_MODE_TABLE_TEXT:
|
|
case SHELL_MODE_TABLE_LIST_TEXT:
|
|
case SHELL_MODE_DRAWTEXT:
|
|
DBG_ERROR("text already active in SwSpellDialogChildWindow::MakeTextSelection_Impl()");
|
|
break;
|
|
|
|
case SHELL_MODE_FRAME:
|
|
{
|
|
rShell.UnSelectFrm();
|
|
rShell.LeaveSelFrmMode();
|
|
rView.AttrChangedNotify(&rShell);
|
|
}
|
|
break;
|
|
|
|
case SHELL_MODE_DRAW:
|
|
case SHELL_MODE_DRAW_CTRL:
|
|
case SHELL_MODE_DRAW_FORM:
|
|
case SHELL_MODE_BEZIER:
|
|
if(FindNextDrawTextError_Impl(rShell))
|
|
{
|
|
rView.AttrChangedNotify(&rShell);
|
|
break;
|
|
}
|
|
//otherwise no break to deselect the object
|
|
case SHELL_MODE_GRAPHIC:
|
|
case SHELL_MODE_OBJECT:
|
|
{
|
|
if ( rShell.IsDrawCreate() )
|
|
{
|
|
rView.GetDrawFuncPtr()->BreakCreate();
|
|
rView.AttrChangedNotify(&rShell);
|
|
}
|
|
else if ( rShell.HasSelection() || rView.IsDrawMode() )
|
|
{
|
|
SdrView *pSdrView = rShell.GetDrawView();
|
|
if(pSdrView && pSdrView->AreObjectsMarked() &&
|
|
pSdrView->GetHdlList().GetFocusHdl())
|
|
{
|
|
((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl();
|
|
}
|
|
else
|
|
{
|
|
rView.LeaveDrawCreate();
|
|
Point aPt(LONG_MIN, LONG_MIN);
|
|
//go out of the frame
|
|
rShell.SelectObj(aPt, SW_LEAVE_FRAME);
|
|
SfxBindings& rBind = rView.GetViewFrame()->GetBindings();
|
|
rBind.Invalidate( SID_ATTR_SIZE );
|
|
rShell.EnterStdMode();
|
|
rView.AttrChangedNotify(&rShell);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:; //prevent warning
|
|
}
|
|
return true;
|
|
}
|
|
/*-- 13.10.2003 15:20:09---------------------------------------------------
|
|
select the next draw text object that has a spelling error
|
|
-----------------------------------------------------------------------*/
|
|
bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh)
|
|
{
|
|
bool bNextDoc = false;
|
|
SdrView* pDrView = rSh.GetDrawView();
|
|
if(!pDrView)
|
|
return bNextDoc;
|
|
SwView& rView = rSh.GetView();
|
|
SwDoc* pDoc = rView.GetDocShell()->GetDoc();
|
|
const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
|
|
//start at the current draw object - if there is any selected
|
|
SdrTextObj* pCurrentTextObj = 0;
|
|
if ( rMarkList.GetMarkCount() == 1 )
|
|
{
|
|
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
|
|
if( pObj && pObj->ISA(SdrTextObj) )
|
|
pCurrentTextObj = static_cast<SdrTextObj*>(pObj);
|
|
}
|
|
//at first fill the vector of drawing objects
|
|
if(!m_pSpellState->m_bTextObjectsCollected )
|
|
{
|
|
m_pSpellState->m_bTextObjectsCollected = true;
|
|
sal_uInt16 n = 0;
|
|
//iterate in the 'normal' array of objects
|
|
while( n < pDoc->GetSpzFrmFmts()->Count() )
|
|
{
|
|
SwFrmFmt* pFly = (*pDoc->GetSpzFrmFmts())[ n ];
|
|
if( pFly->IsA( TYPE(SwDrawFrmFmt) ) )
|
|
{
|
|
SwClientIter aIter( (SwFmt&) *pFly );
|
|
if( aIter.First( TYPE(SwDrawContact) ) )
|
|
{
|
|
SdrObject* pSdrO = ((SwDrawContact*)aIter())->GetMaster();
|
|
if ( pSdrO )
|
|
{
|
|
if ( pSdrO->IsA( TYPE(SdrObjGroup) ) )
|
|
{
|
|
SdrObjListIter aListIter( *pSdrO, IM_DEEPNOGROUPS );
|
|
//iterate inside of a grouped object
|
|
while( aListIter.IsMore() )
|
|
{
|
|
SdrObject* pSdrOElement = aListIter.Next();
|
|
if( pSdrOElement && pSdrOElement->IsA( TYPE(SdrTextObj) ) &&
|
|
static_cast<SdrTextObj*>( pSdrOElement)->HasText() &&
|
|
pCurrentTextObj != pSdrOElement)
|
|
{
|
|
m_pSpellState->m_aTextObjects.push_back((SdrTextObj*) pSdrOElement);
|
|
}
|
|
}
|
|
}
|
|
else if( pSdrO->IsA( TYPE(SdrTextObj) ) &&
|
|
static_cast<SdrTextObj*>( pSdrO )->HasText() &&
|
|
pCurrentTextObj != pSdrO)
|
|
{
|
|
m_pSpellState->m_aTextObjects.push_back((SdrTextObj*) pSdrO);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
++n;
|
|
}
|
|
if(pCurrentTextObj)
|
|
m_pSpellState->m_aTextObjects.push_back(pCurrentTextObj);
|
|
}
|
|
if(m_pSpellState->m_aTextObjects.size())
|
|
{
|
|
Reference< XSpellChecker1 > xSpell( GetSpellChecker() );
|
|
while(!bNextDoc && m_pSpellState->m_aTextObjects.size())
|
|
{
|
|
std::vector<SdrTextObj*>::iterator aStart = m_pSpellState->m_aTextObjects.begin();
|
|
SdrTextObj* pTextObj = *aStart;
|
|
if(m_pSpellState->m_pStartDrawing == pTextObj)
|
|
m_pSpellState->m_bRestartDrawing = true;
|
|
m_pSpellState->m_aTextObjects.erase(aStart);
|
|
OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
|
|
if ( pParaObj )
|
|
{
|
|
bool bHasSpellError = false;
|
|
{
|
|
SdrOutliner aTmpOutliner(pDoc->GetDrawModel()->
|
|
GetDrawOutliner().GetEmptyItemSet().GetPool(),
|
|
OUTLINERMODE_TEXTOBJECT );
|
|
aTmpOutliner.SetRefDevice( pDoc->getPrinter( false ) );
|
|
MapMode aMapMode (MAP_TWIP);
|
|
aTmpOutliner.SetRefMapMode(aMapMode);
|
|
aTmpOutliner.SetPaperSize( pTextObj->GetLogicRect().GetSize() );
|
|
aTmpOutliner.SetSpeller( xSpell );
|
|
|
|
OutlinerView* pOutlView = new OutlinerView( &aTmpOutliner, &(rView.GetEditWin()) );
|
|
pOutlView->GetOutliner()->SetRefDevice( rSh.getIDocumentDeviceAccess()->getPrinter( false ) );
|
|
aTmpOutliner.InsertView( pOutlView );
|
|
Point aPt;
|
|
Size aSize(1,1);
|
|
Rectangle aRect( aPt, aSize );
|
|
pOutlView->SetOutputArea( aRect );
|
|
aTmpOutliner.SetText( *pParaObj );
|
|
aTmpOutliner.ClearModifyFlag();
|
|
bHasSpellError = EE_SPELL_OK != aTmpOutliner.HasSpellErrors();
|
|
aTmpOutliner.RemoveView( pOutlView );
|
|
delete pOutlView;
|
|
}
|
|
if(bHasSpellError)
|
|
{
|
|
//now the current one has to be deselected
|
|
if(pCurrentTextObj)
|
|
pDrView->SdrEndTextEdit( TRUE );
|
|
//and the found one should be activated
|
|
rSh.MakeVisible(pTextObj->GetLogicRect());
|
|
Point aTmp( 0,0 );
|
|
rSh.SelectObj( aTmp, 0, pTextObj );
|
|
SdrPageView* pPV = pDrView->GetSdrPageView();
|
|
rView.BeginTextEdit( pTextObj, pPV, &rView.GetEditWin(), FALSE );
|
|
rView.AttrChangedNotify(&rSh);
|
|
bNextDoc = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return bNextDoc;
|
|
}
|
|
|
|
/*-- 13.10.2003 15:24:27---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
bool SwSpellDialogChildWindow::SpellDrawText_Impl(SwWrtShell& rSh, ::svx::SpellPortions& rPortions)
|
|
{
|
|
bool bRet = false;
|
|
SdrView* pSdrView = rSh.GetDrawView();
|
|
SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0;
|
|
DBG_ASSERT(pOutliner, "No Outliner in SwSpellDialogChildWindow::SpellDrawText_Impl");
|
|
if(pOutliner)
|
|
{
|
|
bRet = pOutliner->SpellSentence(pSdrView->GetTextEditOutlinerView()->GetEditView(), rPortions, m_bIsGrammarCheckingOn);
|
|
//find out if the current selection is in the first spelled drawing object
|
|
//and behind the initial selection
|
|
if(bRet && m_pSpellState->m_bRestartDrawing)
|
|
{
|
|
OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
|
|
ESelection aCurrentSelection = pOLV->GetSelection();
|
|
if(m_pSpellState->m_aStartDrawingSelection.nEndPara < aCurrentSelection.nEndPara ||
|
|
(m_pSpellState->m_aStartDrawingSelection.nEndPara == aCurrentSelection.nEndPara &&
|
|
m_pSpellState->m_aStartDrawingSelection.nEndPos < aCurrentSelection.nEndPos))
|
|
{
|
|
bRet = false;
|
|
rPortions.clear();
|
|
}
|
|
}
|
|
}
|
|
return bRet;
|
|
}
|
|
/*-- 30.10.2003 14:54:59---------------------------------------------------
|
|
|
|
-----------------------------------------------------------------------*/
|
|
void SwSpellDialogChildWindow::LockFocusNotification(bool bLock)
|
|
{
|
|
DBG_ASSERT(m_pSpellState->m_bLockFocus != bLock, "invalid locking - no change of state");
|
|
m_pSpellState->m_bLockFocus = bLock;
|
|
}
|
|
|
|
|