diff options
Diffstat (limited to 'sw/source/uibase/dialog')
-rw-r--r-- | sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx | 844 | ||||
-rw-r--r-- | sw/source/uibase/dialog/regionsw.cxx | 239 | ||||
-rw-r--r-- | sw/source/uibase/dialog/regionsw.hrc | 42 | ||||
-rw-r--r-- | sw/source/uibase/dialog/regionsw.src | 69 | ||||
-rw-r--r-- | sw/source/uibase/dialog/swabstdlg.cxx | 59 | ||||
-rw-r--r-- | sw/source/uibase/dialog/swwrtshitem.cxx | 43 | ||||
-rw-r--r-- | sw/source/uibase/dialog/wordcountwrapper.cxx | 49 |
7 files changed, 1345 insertions, 0 deletions
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx new file mode 100644 index 000000000000..3a2ae61ea5e8 --- /dev/null +++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx @@ -0,0 +1,844 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <SwSpellDialogChildWindow.hxx> +#include <vcl/msgbox.hxx> +#include <editeng/svxacorr.hxx> +#include <editeng/acorrcfg.hxx> +#include <svx/svxids.hrc> +#include <sfx2/app.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <editeng/unolingu.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editview.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 <unotools/linguprops.hxx> +#include <unotools/lingucfg.hxx> +#include <doc.hxx> +#include <docsh.hxx> +#include <docary.hxx> +#include <frmfmt.hxx> +#include <dcontact.hxx> +#include <edtwin.hxx> +#include <pam.hxx> +#include <drawbase.hxx> +#include <unotextrange.hxx> +#include <dialog.hrc> +#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_WITHID(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 + sal_uInt16 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; + sal_Int32 m_nPointPos; + sal_Int32 m_nMarkPos; + const SdrOutliner* m_pOutliner; + ESelection m_aESelection; + + // iterating over draw text objects + std::list<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; + } +}; + +static 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); + } +} + +SwSpellDialogChildWindow::SwSpellDialogChildWindow ( + Window* _pParent, + sal_uInt16 nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo) + : svx::SpellDialogChildWindow ( + _pParent, nId, pBindings, pInfo) + , m_bIsGrammarCheckingOn(false) + , m_pSpellState(new SpellState) +{ + OUString aPropName(UPN_IS_GRAMMAR_INTERACTIVE); + SvtLinguConfig().GetProperty( aPropName ) >>= m_bIsGrammarCheckingOn; +} + +SwSpellDialogChildWindow::~SwSpellDialogChildWindow () +{ + SwWrtShell* pWrtShell = GetWrtShell_Impl(); + if(!m_pSpellState->m_bInitialCall && pWrtShell) + pWrtShell->SpellEnd(); + delete m_pSpellState; +} + +SfxChildWinInfo SwSpellDialogChildWindow::GetInfo (void) const +{ + SfxChildWinInfo aInfo = svx::SpellDialogChildWindow::GetInfo(); + aInfo.bVisible = false; + return aInfo; +} + +svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence(bool bRecheck) +{ + svx::SpellPortions aRet; + SwWrtShell* pWrtShell = GetWrtShell_Impl(); + if(pWrtShell) + { + if (!bRecheck) + { + // first set continuation point for spell/grammar check to the + // end of the current sentence + pWrtShell->MoveContinuationPosToEndOfCheckedSentence(); + } + + 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 + { + pWrtShell->ExpandToSentenceBorders(); + m_pSpellState->m_bStartedInSelection = true; + } + // determine if the selection is outside of the body text + bOtherText = !(pWrtShell->GetFrmType(0,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 ); + } + else + { + SwPaM* pCrsr = pWrtShell->GetCrsr(); + // mark the start position only if not at start of doc + if(!pWrtShell->IsStartOfDoc()) + { + m_pSpellState->m_xStartRange = + SwXTextRange::CreateXTextRange( + *pWrtShell->GetDoc(), + *pCrsr->Start(), pCrsr->End()); + } + pWrtShell->SpellStart( DOCPOS_START, DOCPOS_END, DOCPOS_CURR ); + } + } + 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(); + // start checking at the top of the drawing object + pOLV->SetSelection( ESelection() ); + m_pSpellState->m_aStartDrawingSelection = ESelection(); +/* +Note: spelling in a selection only, or starting in a mid of a drawing object requires +further changes elsewhere. (Especially if it should work in sc and sd as well.) +The code below would only be part of the solution. +(Keeping it a as a comment for the time being) + ESelection aCurSel( pOLV->GetSelection() ); + ESelection aSentenceSel( pOLV->GetEditView().GetEditEngine()->SelectSentence( aCurSel ) ); + if (!aCurSel.HasRange()) + { + aSentenceSel.nEndPara = aSentenceSel.nStartPara; + aSentenceSel.nEndPos = aSentenceSel.nStartPos; + } + pOLV->SetSelection( aSentenceSel ); + m_pSpellState->m_aStartDrawingSelection = aSentenceSel; +*/ + } + + 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 ); + 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 ); + 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)) + { + // if there is a selection (within body or header/footer text) + // then spell/grammar checking should not move outside of it. + if (!m_pSpellState->m_bStartedInSelection) + { + // find out which text has been spelled body or other + bOtherText = !(pWrtShell->GetFrmType(0,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 ); + 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 ); + 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 ); + 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) + { + OSL_ENSURE(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 ); + sal_uInt16 nRet = QueryBox( GetWindow(), SW_RES(RID_QB_SPELL_CONTINUE)).Execute(); + if(RET_YES == nRet) + { + SwUnoInternalPaM aPam(*pWrtShell->GetDoc()); + if (::sw::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 ); + OUString 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; + +} + +void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rChanged, bool bRecheck) +{ + SwWrtShell* pWrtShell = GetWrtShell_Impl(); + OSL_ENSURE(!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; + + // evaluate if the same sentence should be rechecked or not. + // Sentences that got grammar checked should always be rechecked in order + // to detect possible errors that get introduced with the changes + bRecheck |= pWrtShell->HasLastSentenceGotGrammarChecked(); + + if(bNormalText) + pWrtShell->ApplyChangedSentence(rChanged, bRecheck); + else if(bDrawText ) + { + SdrView* pDrView = pWrtShell->GetDrawView(); + SdrOutliner *pOutliner = pDrView->GetTextEditOutliner(); + pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, bRecheck); + } + } +} + +void SwSpellDialogChildWindow::AddAutoCorrection( + const OUString& rOld, const OUString& rNew, LanguageType eLanguage) +{ + SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect(); + pACorr->PutText( rOld, rNew, eLanguage ); +} + +bool SwSpellDialogChildWindow::HasAutoCorrection() +{ + return true; +} + +bool SwSpellDialogChildWindow::HasGrammarChecking() +{ + return SvtLinguConfig().HasGrammarChecker(); +} + +bool SwSpellDialogChildWindow::IsGrammarChecking() +{ + return m_bIsGrammarCheckingOn; +} + +void SwSpellDialogChildWindow::SetGrammarChecking(bool bOn) +{ + uno::Any aVal; + aVal <<= bOn; + m_bIsGrammarCheckingOn = bOn; + OUString aPropName(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; + OSL_ENSURE(pOutliner, "No Outliner in SwSpellDialogChildWindow::SetGrammarChecking"); + if(pOutliner) + { + pOutliner->PutSpellingToSentenceStart( pSdrView->GetTextEditOutlinerView()->GetEditView() ); + } + } + } +} + +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(); + OSL_ENSURE(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(); +} + +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(); + OSL_ENSURE(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; +} + +void SwSpellDialogChildWindow::InvalidateSpellDialog() +{ + SwWrtShell* pWrtShell = GetWrtShell_Impl(); + if(!m_pSpellState->m_bInitialCall && pWrtShell) + pWrtShell->SpellEnd(0, false); + m_pSpellState->Reset(); + svx::SpellDialogChildWindow::InvalidateSpellDialog(); +} + +SwWrtShell* SwSpellDialogChildWindow::GetWrtShell_Impl() +{ + SfxDispatcher* pDispatch = GetBindings().GetDispatcher(); + SwView* pView = 0; + if(pDispatch) + { + sal_uInt16 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; +} + +// 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: + OSL_FAIL("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; +} + +// 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 list of drawing objects + if(!m_pSpellState->m_bTextObjectsCollected ) + { + m_pSpellState->m_bTextObjectsCollected = true; + std::list<SdrTextObj*> aTextObjs; + SwDrawContact::GetTextObjectsFromFmt( aTextObjs, pDoc ); + if(pCurrentTextObj) + { + m_pSpellState->m_aTextObjects.remove(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::list<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, true ); + rView.AttrChangedNotify(&rSh); + bNextDoc = true; + } + } + } + } + return bNextDoc; +} + +bool SwSpellDialogChildWindow::SpellDrawText_Impl(SwWrtShell& rSh, ::svx::SpellPortions& rPortions) +{ + bool bRet = false; + SdrView* pSdrView = rSh.GetDrawView(); + SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0; + OSL_ENSURE(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; +} + +void SwSpellDialogChildWindow::LockFocusNotification(bool bLock) +{ + OSL_ENSURE(m_pSpellState->m_bLockFocus != bLock, "invalid locking - no change of state"); + m_pSpellState->m_bLockFocus = bLock; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dialog/regionsw.cxx b/sw/source/uibase/dialog/regionsw.cxx new file mode 100644 index 000000000000..299c26c23f56 --- /dev/null +++ b/sw/source/uibase/dialog/regionsw.cxx @@ -0,0 +1,239 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <hintids.hxx> +#include <uitool.hxx> +#include <comphelper/string.hxx> +#include <svl/urihelper.hxx> +#include <svl/PasswordHelper.hxx> +#include <vcl/msgbox.hxx> +#include <svl/stritem.hxx> +#include <svl/eitem.hxx> +#include <sot/formats.hxx> +#include <sfx2/passwd.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/request.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/linkmgr.hxx> +#include <editeng/sizeitem.hxx> +#include <svtools/htmlcfg.hxx> +#include <section.hxx> +#include <docary.hxx> +#include <regionsw.hxx> +#include <basesh.hxx> +#include <wdocsh.hxx> +#include <view.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <swundo.hxx> +#include <column.hxx> +#include <fmtfsize.hxx> +#include <shellio.hxx> +#include <helpid.h> +#include <cmdid.h> +#include <regionsw.hrc> +#include <comcore.hrc> +#include <globals.hrc> +#include <sfx2/bindings.hxx> +#include <sfx2/htmlmode.hxx> +#include <svx/dlgutil.hxx> +#include "swabstdlg.hxx" +#include <boost/scoped_ptr.hpp> + +void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) +{ + SwWrtShell& rSh = GetShell(); + const SfxItemSet *pSet = rReq.GetArgs(); + + SfxItemSet aSet(GetPool(), + RES_COL, RES_COL, + RES_LR_SPACE, RES_LR_SPACE, + RES_COLUMNBALANCE, RES_FRAMEDIR, + RES_BACKGROUND, RES_BACKGROUND, + RES_FRM_SIZE, RES_FRM_SIZE, + RES_FTN_AT_TXTEND, RES_END_AT_TXTEND, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + 0); + + if (!pSet || pSet->Count()==0) + { + SwRect aRect; + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); + + long nWidth = aRect.Width(); + aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); + + // height=width for more consistent preview (analog to edit region) + aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( + &GetView().GetViewFrame()->GetWindow(), aSet , rSh); + OSL_ENSURE(aTabDlg, "Dialogdiet fail!"); + aTabDlg->Execute(); + rReq.Ignore(); + delete aTabDlg; + } + else + { + const SfxPoolItem *pItem = 0; + OUString aTmpStr; + if ( SFX_ITEM_SET == + pSet->GetItemState(FN_PARAM_REGION_NAME, true, &pItem) ) + { + const OUString sRemoveWhenUniStringIsGone = ((const SfxStringItem *)pItem)->GetValue(); + aTmpStr = rSh.GetUniqueSectionName(&sRemoveWhenUniStringIsGone); + } + else + aTmpStr = rSh.GetUniqueSectionName(); + + SwSectionData aSection(CONTENT_SECTION, aTmpStr); + rReq.SetReturnValue(SfxStringItem(FN_INSERT_REGION, aTmpStr)); + + aSet.Put( *pSet ); + if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_COLUMNS, false, &pItem)|| + SFX_ITEM_SET == pSet->GetItemState(FN_INSERT_REGION, false, &pItem)) + { + SwFmtCol aCol; + SwRect aRect; + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); + long nWidth = aRect.Width(); + + sal_uInt16 nCol = ((SfxUInt16Item *)pItem)->GetValue(); + if(nCol) + { + aCol.Init( nCol, 0, static_cast< sal_uInt16 >(nWidth) ); + aSet.Put(aCol); + } + } + else if(SFX_ITEM_SET == pSet->GetItemState(RES_COL, false, &pItem)) + { + aSet.Put(*pItem); + } + + const bool bHidden = SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_REGION_HIDDEN, true, &pItem) && + ((const SfxBoolItem *)pItem)->GetValue(); + const bool bProtect = SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_REGION_PROTECT, true, &pItem) && + ((const SfxBoolItem *)pItem)->GetValue(); + // #114856# edit in readonly sections + const bool bEditInReadonly = SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_REGION_EDIT_IN_READONLY, true, &pItem) && + ((const SfxBoolItem *)pItem)->GetValue(); + + aSection.SetProtectFlag(bProtect); + aSection.SetHidden(bHidden); + // #114856# edit in readonly sections + aSection.SetEditInReadonlyFlag(bEditInReadonly); + + if(SFX_ITEM_SET == + pSet->GetItemState(FN_PARAM_REGION_CONDITION, true, &pItem)) + aSection.SetCondition(((const SfxStringItem *)pItem)->GetValue()); + + OUString aFile, aSub; + if(SFX_ITEM_SET == + pSet->GetItemState(FN_PARAM_1, true, &pItem)) + aFile = ((const SfxStringItem *)pItem)->GetValue(); + + if(SFX_ITEM_SET == + pSet->GetItemState(FN_PARAM_3, true, &pItem)) + aSub = ((const SfxStringItem *)pItem)->GetValue(); + + if(!aFile.isEmpty() || !aSub.isEmpty()) + { + OUString sLinkFileName = OUString(sfx2::cTokenSeparator); + sLinkFileName += OUString(sfx2::cTokenSeparator); + sLinkFileName = comphelper::string::setToken(sLinkFileName, 0, sfx2::cTokenSeparator, aFile); + + if(SFX_ITEM_SET == + pSet->GetItemState(FN_PARAM_2, true, &pItem)) + { + sLinkFileName = comphelper::string::setToken(sLinkFileName, 1, sfx2::cTokenSeparator, + ((const SfxStringItem *)pItem)->GetValue()); + } + + sLinkFileName += aSub; + aSection.SetType( FILE_LINK_SECTION ); + aSection.SetLinkFileName(sLinkFileName); + } + rSh.InsertSection(aSection, aSet.Count() ? &aSet : 0); + rReq.Done(); + } +} + +IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect ) +{ + boost::scoped_ptr<SwSectionData> xSectionData(pSect); + if (xSectionData.get()) + { + SfxItemSet aSet(pThis->GetView().GetPool(), + RES_COL, RES_COL, + RES_BACKGROUND, RES_BACKGROUND, + RES_FRM_SIZE, RES_FRM_SIZE, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + 0); + SwRect aRect; + pThis->CalcBoundRect(aRect, FLY_AS_CHAR); + long nWidth = aRect.Width(); + aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); + // height=width for more consistent preview (analog to edit region) + aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( + &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis); + OSL_ENSURE(aTabDlg, "Dialogdiet fail!"); + aTabDlg->SetSectionData(*xSectionData); + aTabDlg->Execute(); + + delete aTabDlg; + } + return 0; +} + +void SwBaseShell::EditRegionDialog(SfxRequest& rReq) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + sal_uInt16 nSlot = rReq.GetSlot(); + const SfxPoolItem* pItem = 0; + if(pArgs) + pArgs->GetItemState(nSlot, false, &pItem); + SwWrtShell& rWrtShell = GetShell(); + + switch ( nSlot ) + { + case FN_EDIT_REGION: + { + Window* pParentWin = &GetView().GetViewFrame()->GetWindow(); + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractEditRegionDlg* pEditRegionDlg = pFact->CreateEditRegionDlg(pParentWin, rWrtShell); + OSL_ENSURE(pEditRegionDlg, "Dialogdiet fail!"); + if(pItem && pItem->ISA(SfxStringItem)) + { + pEditRegionDlg->SelectSection(((const SfxStringItem*)pItem)->GetValue()); + } + pEditRegionDlg->Execute(); + delete pEditRegionDlg; + } + } + break; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dialog/regionsw.hrc b/sw/source/uibase/dialog/regionsw.hrc new file mode 100644 index 000000000000..b7d45f309c8d --- /dev/null +++ b/sw/source/uibase/dialog/regionsw.hrc @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _REGIONSW_HRC +#define _REGIONSW_HRC + +#include "dialog.hrc" + +#define ST_INSERT 45 + +/* global resources */ +#define STR_REG_DUPLICATE (RC_REGIONSW_BEGIN+6) +#define STR_INFO_DUPLICATE (RC_REGIONSW_BEGIN+7) + +#define QB_CONNECT (RC_REGIONSW_BEGIN+10) +#define REG_WRONG_PASSWORD (RC_REGIONSW_BEGIN+11) +#define REG_WRONG_PASSWD_REPEAT (RC_REGIONSW_BEGIN+12) + +//ImageList elements +#define BMP_HIDE 1 +#define BMP_NO_HIDE 2 +#define BMP_PROT_HIDE 3 +#define BMP_PROT_NO_HIDE 4 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dialog/regionsw.src b/sw/source/uibase/dialog/regionsw.src new file mode 100644 index 000000000000..f23fe2b4d250 --- /dev/null +++ b/sw/source/uibase/dialog/regionsw.src @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "regionsw.hrc" +#include "cmdid.h" +#include "globals.hrc" +#include "helpid.h" + +#define DLG_IMAGE_IDLIST \ + IdList = \ + { \ + BMP_HIDE /*1*/ ;\ + BMP_NO_HIDE /*2*/ ;\ + BMP_PROT_HIDE /*3*/ ;\ + BMP_PROT_NO_HIDE /*4*/ ;\ + }; \ + IdCount = { 4 ; }; + +ImageList IL_SECTION_BITMAPS +{ + Prefix = "re"; + MaskColor = IMAGE_MASK_COLOR ; + DLG_IMAGE_IDLIST +}; + +String STR_REG_DUPLICATE +{ + Text [ en-US ] = "Section name changed:" ; +}; +String STR_INFO_DUPLICATE +{ + Text [ en-US ] = "Duplicate section name" ; +}; +QueryBox QB_CONNECT +{ + Buttons = WB_YES_NO ; + DefButton = WB_DEF_NO ; + Message [ en-US ] = "A file connection will delete the contents of the current section. Connect anyway?" ; +}; +InfoBox REG_WRONG_PASSWORD +{ + BUTTONS = WB_OK ; + DEFBUTTON = WB_DEF_OK ; + Message [ en-US ] = "The password entered is invalid." ; +}; +InfoBox REG_WRONG_PASSWD_REPEAT +{ + BUTTONS = WB_OK ; + DEFBUTTON = WB_DEF_OK ; + Message [ en-US ] = "The password has not been set." ; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dialog/swabstdlg.cxx b/sw/source/uibase/dialog/swabstdlg.cxx new file mode 100644 index 000000000000..8cf41aa5604d --- /dev/null +++ b/sw/source/uibase/dialog/swabstdlg.cxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <config_features.h> +#include <config_libraries.h> + +#include "swabstdlg.hxx" + +#include <osl/module.hxx> + +typedef SwAbstractDialogFactory* (SAL_CALL *SwFuncPtrCreateDialogFactory)(); + +#ifndef DISABLE_DYNLOADING + +extern "C" { static void SAL_CALL thisModule() {} } + +#else + +extern "C" SwAbstractDialogFactory* SwCreateDialogFactory(); + +#endif + +SwAbstractDialogFactory* SwAbstractDialogFactory::Create() +{ + SwFuncPtrCreateDialogFactory fp = 0; +#if HAVE_FEATURE_DESKTOP +#ifndef DISABLE_DYNLOADING + static ::osl::Module aDialogLibrary; + static const OUString sLibName(LIBO_LIBRARY(swui)); + if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, sLibName, + SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY ) ) + fp = ( SwAbstractDialogFactory* (SAL_CALL*)() ) + aDialogLibrary.getFunctionSymbol( OUString("SwCreateDialogFactory")); +#else + fp = SwCreateDialogFactory(); +#endif +#endif + if ( fp ) + return fp(); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dialog/swwrtshitem.cxx b/sw/source/uibase/dialog/swwrtshitem.cxx new file mode 100644 index 000000000000..591a6b5403f5 --- /dev/null +++ b/sw/source/uibase/dialog/swwrtshitem.cxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "swwrtshitem.hxx" +TYPEINIT1(SwWrtShellItem,SfxPoolItem); +SwWrtShellItem::SwWrtShellItem( sal_uInt16 _nWhich, SwWrtShell* pSh ) + : SfxPoolItem( _nWhich ), pWrtSh( pSh ) +{ + +} +SwWrtShellItem::SwWrtShellItem( const SwWrtShellItem& rItem) : + SfxPoolItem( rItem.Which() ), + pWrtSh( rItem.pWrtSh ) +{ +} + +bool SwWrtShellItem::operator==( const SfxPoolItem& rItem) const +{ + return ((SwWrtShellItem&)rItem).pWrtSh == pWrtSh; +} + +SfxPoolItem* SwWrtShellItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwWrtShellItem( *this ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/dialog/wordcountwrapper.cxx b/sw/source/uibase/dialog/wordcountwrapper.cxx new file mode 100644 index 000000000000..78cf4ee95a5b --- /dev/null +++ b/sw/source/uibase/dialog/wordcountwrapper.cxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swtypes.hxx> +#include <wordcountdialog.hxx> +#include <docstat.hxx> +#include <dialog.hrc> +#include <cmdid.h> + +SFX_IMPL_CHILDWINDOW_WITHID(SwWordCountWrapper, FN_WORDCOUNT_DIALOG) + +SwWordCountWrapper::SwWordCountWrapper( Window *pParentWindow, + sal_uInt16 nId, + SfxBindings* pBindings, + SfxChildWinInfo* pInfo ) : + SfxChildWindow(pParentWindow, nId) +{ + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); + pAbstDlg = pFact->CreateSwWordCountDialog(pBindings, this, pParentWindow, pInfo); + OSL_ENSURE(pAbstDlg, "Dialog construction failed!"); + pWindow = pAbstDlg->GetWindow(); + + eChildAlignment = SFX_ALIGN_NOALIGNMENT; +} + +SfxChildWinInfo SwWordCountWrapper::GetInfo() const +{ + SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); + return aInfo; +} + +void SwWordCountWrapper::UpdateCounts() +{ + pAbstDlg->UpdateCounts(); +} + +void SwWordCountWrapper::SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat) +{ + pAbstDlg->SetCounts(rCurrCnt, rDocStat); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |